<Window x:Class="LiamWorkflowDiagnostics.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="LIAM Workflow Diagnostics" Width="1100"
        Icon="/AppIcon.ico"
        WindowStartupLocation="CenterScreen">
    <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
        <Grid Margin="12">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="2*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <GroupBox Header="Provider Settings" Grid.Row="0" Margin="0,0,0,8">
            <Grid Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="180"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="160"/>
                    <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="Config Class ID" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="ProviderConfigIdTextBox"
                         Grid.Row="0" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                <TextBlock Text="Config Object ID" Grid.Row="0" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="ProviderConfigObjectIdTextBox"
                         Grid.Row="0" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                <TextBlock Text="Provider Type" Grid.Row="1" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <ComboBox x:Name="ProviderTypeCombo"
                          Grid.Row="1" Grid.Column="1" Margin="0,0,16,8" Height="26"
                          SelectionChanged="ProviderTypeCombo_SelectionChanged"/>

                <TextBlock Text="Domain" Grid.Row="1" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="DomainTextBox"
                         Grid.Row="1" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                <TextBlock Text="Target / Root Path" Grid.Row="2" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="RootPathTextBox"
                         Grid.Row="2" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                <TextBlock Text="Max Depth" Grid.Row="2" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="MaxDepthTextBox"
                         Grid.Row="2" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                <TextBlock Text="Group Filter" Grid.Row="3" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="GroupFilterTextBox"
                         Grid.Row="3" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                <TextBlock Text="Group Path / OU" Grid.Row="3" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="GroupPathTextBox"
                         Grid.Row="3" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                    <TextBlock Text="Data Area Filter" Grid.Row="4" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="DataAreaFilterTextBox"
                         Grid.Row="4" Grid.Column="1" Margin="0,0,16,8" Height="26" Visibility="Collapsed"/>

                    <TextBlock Text="Data Area Regex" Grid.Row="4" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="DataAreaRegexTextBox"
                         Grid.Row="4" Grid.Column="3" Margin="0,0,0,8" Height="26" Visibility="Collapsed"/>

                <TextBlock Text="Group Strategy" Grid.Row="5" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <ComboBox x:Name="GroupStrategyCombo"
                          Grid.Row="5" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                    <TextBlock Text="Group Regex" Grid.Row="5" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="GroupRegexTextBox"
                         Grid.Row="5" Grid.Column="3" Margin="0,0,0,8" Height="26" Visibility="Collapsed"/>

                    <TextBlock Text="Traverse Group" Grid.Row="6" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="TraverseGroupTextBox"
                         Grid.Row="6" Grid.Column="1" Margin="0,0,16,8" Height="26" Visibility="Collapsed"/>

                    <TextBlock Text="Owner Group (Global)" Grid.Row="6" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="OwnerGroupGlobalTextBox"
                         Grid.Row="6" Grid.Column="3" Margin="0,0,0,8" Height="26" Visibility="Collapsed"/>

                    <TextBlock Text="Owner Group (Local)" Grid.Row="7" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="OwnerGroupLocalTextBox"
                         Grid.Row="7" Grid.Column="1" Margin="0,0,16,8" Height="26" Visibility="Collapsed"/>

                    <TextBlock Text="Write Group (Global)" Grid.Row="7" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="WriteGroupGlobalTextBox"
                         Grid.Row="7" Grid.Column="3" Margin="0,0,0,8" Height="26" Visibility="Collapsed"/>

                    <TextBlock Text="Write Group (Local)" Grid.Row="8" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="WriteGroupLocalTextBox"
                         Grid.Row="8" Grid.Column="1" Margin="0,0,16,8" Height="26" Visibility="Collapsed"/>

                    <TextBlock Text="Read Group (Global)" Grid.Row="8" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="ReadGroupGlobalTextBox"
                         Grid.Row="8" Grid.Column="3" Margin="0,0,0,8" Height="26" Visibility="Collapsed"/>

                    <TextBlock Text="Read Group (Local)" Grid.Row="9" Grid.Column="0" Margin="0,0,8,0" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="ReadGroupLocalTextBox"
                         Grid.Row="9" Grid.Column="1" Margin="0,0,16,0" Height="26" Visibility="Collapsed"/>
            </Grid>
        </GroupBox>

        <GroupBox Header="Credentials" Grid.Row="1" Margin="0,0,0,8">
            <Grid Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="180"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="160"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBlock Text="Account (UPN / User)" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="CredentialUserTextBox"
                         Grid.Row="0" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                <TextBlock Text="Credential Domain" Grid.Row="0" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="CredentialDomainTextBox"
                         Grid.Row="0" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                <TextBlock Text="Password / Secret" Grid.Row="1" Grid.Column="0" Margin="0,0,8,0" VerticalAlignment="Center"/>
                <PasswordBox x:Name="CredentialPasswordBox"
                             Grid.Row="1" Grid.Column="1" Margin="0,0,16,0" Height="26"/>

                <TextBlock Text="Mask in log as" Grid.Row="1" Grid.Column="2" Margin="0,0,8,0" VerticalAlignment="Center" Visibility="Collapsed"/>
                <TextBox x:Name="MaskTokenTextBox"
                         Grid.Row="1" Grid.Column="3" Margin="0,0,0,0" Height="26" Text="***" Visibility="Collapsed"/>
            </Grid>
        </GroupBox>

        <GroupBox Header="License &amp; Matrix42 Environment" Grid.Row="2" Margin="0,0,0,8">
            <Grid Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="180"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="160"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBlock Text="Portal Server Name" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                <TextBox x:Name="ServerNameTextBox"
                         Grid.Row="0" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                <TextBlock Text="Use HTTPS" Grid.Row="0" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center" Visibility="Collapsed"/>
                <CheckBox x:Name="UseHttpsCheckBox"
                          Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" Visibility="Collapsed"/>

                <TextBlock Text="License XML (raw string)" Grid.Row="1" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                <TextBox x:Name="LicenseTextBox"
                         Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,0,0,8"
                         Height="120" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                <TextBlock Text="Optional: provide JSON to load provider data (sanitized output from logs)" Grid.Row="2" Grid.Column="0" Margin="0,0,8,0" VerticalAlignment="Top"/>
                <TextBox x:Name="RawJsonTextBox"
                         Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,0,0,0"
                         Height="120" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>
            </Grid>
        </GroupBox>

        <Expander Header="Advanced Configuration (Optional)" Grid.Row="3" Margin="0,0,0,8" IsExpanded="False">
            <Grid Margin="10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0" Grid.Column="0" Margin="0,0,12,0">
                    <TextBlock Text="Additional Configuration (key=value per line)" Margin="0,0,0,4"/>
                    <TextBox x:Name="AdditionalConfigTextBox"
                             Height="120" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>
                </StackPanel>

                <StackPanel Grid.Row="0" Grid.Column="1" Margin="0,0,12,0">
                    <TextBlock Text="Custom Tags (key=value per line)" Margin="0,0,0,4"/>
                    <TextBox x:Name="CustomTagsTextBox"
                             Height="120" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>
                </StackPanel>

                <StackPanel Grid.Row="0" Grid.Column="2">
                    <TextBlock Text="Naming Conventions JSON Array" Margin="0,0,0,4"/>
                    <TextBox x:Name="NamingConventionsTextBox"
                             Height="120" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>
                </StackPanel>

                <StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Horizontal" Margin="0,12,0,0">
                    <TextBlock Text="Tip: leave blank fields untouched if not required by the chosen provider." Foreground="Gray" VerticalAlignment="Center"/>
                </StackPanel>
            </Grid>
        </Expander>

        <GroupBox x:Name="ActionsGroupBox" Header="Provider Actions" Grid.Row="4" Margin="0,0,0,8" IsEnabled="False">
            <Grid Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBlock x:Name="ActionHintTextBlock"
                           Grid.Row="0"
                           Margin="0,0,0,8"
                           Foreground="Gray"
                           Text="Initialisiere zuerst einen Provider. Danach erscheinen hier die provider-spezifischen Anlage-Aktionen."/>

                <Grid Grid.Row="1">
                    <Grid x:Name="NtfsActionPanel" Visibility="Collapsed">
                        <TabControl>
                            <TabItem Header="Create Folder">
                                <Grid Margin="10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="180"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <TextBlock Text="New Folder Path" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="NtfsCreateFolderPathTextBox" Grid.Row="0" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Parent Folder Path" Grid.Row="1" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="NtfsCreateParentPathTextBox" Grid.Row="1" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Owner SIDs" Grid.Row="2" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                                    <TextBox x:Name="NtfsCreateOwnerSidsTextBox" Grid.Row="2" Grid.Column="1" Margin="0,0,0,8" Height="60" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                                    <TextBlock Text="Reader SIDs" Grid.Row="3" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                                    <TextBox x:Name="NtfsCreateReaderSidsTextBox" Grid.Row="3" Grid.Column="1" Margin="0,0,0,8" Height="60" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                                    <TextBlock Text="Writer SIDs" Grid.Row="4" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                                    <TextBox x:Name="NtfsCreateWriterSidsTextBox" Grid.Row="4" Grid.Column="1" Margin="0,0,0,8" Height="60" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                                    <Button x:Name="ExecuteNtfsCreateButton" Grid.Row="5" Grid.Column="1" Width="180" HorizontalAlignment="Right" Content="Create NTFS Folder" Click="ExecuteNtfsCreateButton_Click"/>
                                </Grid>
                            </TabItem>
                            <TabItem Header="Ensure Groups / ACLs">
                                <Grid Margin="10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="180"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <TextBlock Text="Folder Path" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="NtfsEnsureFolderPathTextBox" Grid.Row="0" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Owner SIDs" Grid.Row="1" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                                    <TextBox x:Name="NtfsEnsureOwnerSidsTextBox" Grid.Row="1" Grid.Column="1" Margin="0,0,0,8" Height="60" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                                    <TextBlock Text="Reader SIDs" Grid.Row="2" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                                    <TextBox x:Name="NtfsEnsureReaderSidsTextBox" Grid.Row="2" Grid.Column="1" Margin="0,0,0,8" Height="60" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                                    <TextBlock Text="Writer SIDs" Grid.Row="3" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                                    <TextBox x:Name="NtfsEnsureWriterSidsTextBox" Grid.Row="3" Grid.Column="1" Margin="0,0,0,8" Height="60" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                                    <CheckBox x:Name="NtfsEnsureTraverseCheckBox" Grid.Row="4" Grid.Column="1" Margin="0,0,0,8" Content="Ensure traverse groups and ACLs on parent path"/>

                                    <Button x:Name="ExecuteNtfsEnsureButton" Grid.Row="5" Grid.Column="1" Width="220" HorizontalAlignment="Right" Content="Ensure Missing Groups / ACLs" Click="ExecuteNtfsEnsureButton_Click"/>
                                </Grid>
                            </TabItem>
                        </TabControl>
                    </Grid>

                    <Grid x:Name="AdActionPanel" Visibility="Collapsed">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="180"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="160"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <TextBlock Text="Service Name" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                        <TextBox x:Name="AdServiceNameTextBox" Grid.Row="0" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                        <TextBlock Text="Description" Grid.Row="0" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                        <TextBox x:Name="AdDescriptionTextBox" Grid.Row="0" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                        <TextBlock Text="Group Scope" Grid.Row="1" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                        <ComboBox x:Name="AdScopeComboBox" Grid.Row="1" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                        <TextBlock Text="Group Type" Grid.Row="1" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                        <ComboBox x:Name="AdGroupTypeComboBox" Grid.Row="1" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                        <TextBlock Text="Owner SIDs" Grid.Row="2" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                        <TextBox x:Name="AdOwnerSidsTextBox" Grid.Row="2" Grid.Column="1" Margin="0,0,16,8" Height="70" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                        <TextBlock Text="Member SIDs" Grid.Row="2" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Top"/>
                        <TextBox x:Name="AdMemberSidsTextBox" Grid.Row="2" Grid.Column="3" Margin="0,0,0,8" Height="70" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                        <TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Margin="0,0,0,8" Foreground="Gray"
                                   Text="Erstellt bzw. sichert die Owner- und Member-Gruppe für einen Service additiv ab."/>

                        <Button x:Name="ExecuteAdCreateButton" Grid.Row="4" Grid.Column="3" Width="180" HorizontalAlignment="Right" Content="Ensure Service Groups" Click="ExecuteAdCreateButton_Click"/>
                    </Grid>

                    <Grid x:Name="MsTeamsActionPanel" Visibility="Collapsed">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="180"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="160"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <TextBlock Text="Source Team ID" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                        <TextBox x:Name="MsTeamsSourceTeamIdTextBox" Grid.Row="0" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                        <TextBlock Text="New Team Name" Grid.Row="0" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                        <TextBox x:Name="MsTeamsNewNameTextBox" Grid.Row="0" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                        <TextBlock Text="Description" Grid.Row="1" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                        <TextBox x:Name="MsTeamsDescriptionTextBox" Grid.Row="1" Grid.Column="1" Margin="0,0,16,8" Height="26"/>

                        <TextBlock Text="Visibility" Grid.Row="1" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Center"/>
                        <ComboBox x:Name="MsTeamsVisibilityComboBox" Grid.Row="1" Grid.Column="3" Margin="0,0,0,8" Height="26"/>

                        <TextBlock Text="Parts To Clone" Grid.Row="2" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                        <WrapPanel Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,0,0,8">
                            <CheckBox x:Name="MsTeamsCloneAppsCheckBox" Margin="0,0,16,0" Content="Apps"/>
                            <CheckBox x:Name="MsTeamsCloneTabsCheckBox" Margin="0,0,16,0" Content="Tabs"/>
                            <CheckBox x:Name="MsTeamsCloneSettingsCheckBox" Margin="0,0,16,0" Content="Settings"/>
                            <CheckBox x:Name="MsTeamsCloneChannelsCheckBox" Margin="0,0,16,0" Content="Channels"/>
                            <CheckBox x:Name="MsTeamsCloneMembersCheckBox" Content="Members"/>
                        </WrapPanel>

                        <TextBlock Text="Additional Members" Grid.Row="3" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Top"/>
                        <TextBox x:Name="MsTeamsAdditionalMembersTextBox" Grid.Row="3" Grid.Column="1" Margin="0,0,16,8" Height="70" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                        <TextBlock Text="Additional Owners" Grid.Row="3" Grid.Column="2" Margin="0,0,8,8" VerticalAlignment="Top"/>
                        <TextBox x:Name="MsTeamsAdditionalOwnersTextBox" Grid.Row="3" Grid.Column="3" Margin="0,0,0,8" Height="70" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"/>

                        <Button x:Name="ExecuteMsTeamsCloneButton" Grid.Row="4" Grid.Column="3" Width="140" HorizontalAlignment="Right" Content="Clone Team" Click="ExecuteMsTeamsCloneButton_Click"/>
                    </Grid>

                    <Grid x:Name="ExchangeActionPanel" Visibility="Collapsed">
                        <TabControl>
                            <TabItem Header="Shared Mailbox">
                                <Grid Margin="10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="180"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <TextBlock Text="Name" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="ExchangeMailboxNameTextBox" Grid.Row="0" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Alias" Grid.Row="1" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="ExchangeMailboxAliasTextBox" Grid.Row="1" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Display Name" Grid.Row="2" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="ExchangeMailboxDisplayNameTextBox" Grid.Row="2" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Primary SMTP" Grid.Row="3" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="ExchangeMailboxPrimarySmtpTextBox" Grid.Row="3" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <Button x:Name="ExecuteExchangeMailboxButton" Grid.Row="4" Grid.Column="1" Width="190" HorizontalAlignment="Right" Content="Create Shared Mailbox" Click="ExecuteExchangeMailboxButton_Click"/>
                                </Grid>
                            </TabItem>
                            <TabItem Header="Distribution Group">
                                <Grid Margin="10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="180"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <TextBlock Text="Name" Grid.Row="0" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="ExchangeDistributionNameTextBox" Grid.Row="0" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Alias" Grid.Row="1" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="ExchangeDistributionAliasTextBox" Grid.Row="1" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Display Name" Grid.Row="2" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="ExchangeDistributionDisplayNameTextBox" Grid.Row="2" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <TextBlock Text="Primary SMTP" Grid.Row="3" Grid.Column="0" Margin="0,0,8,8" VerticalAlignment="Center"/>
                                    <TextBox x:Name="ExchangeDistributionPrimarySmtpTextBox" Grid.Row="3" Grid.Column="1" Margin="0,0,0,8" Height="26"/>

                                    <Button x:Name="ExecuteExchangeDistributionButton" Grid.Row="4" Grid.Column="1" Width="200" HorizontalAlignment="Right" Content="Create Distribution Group" Click="ExecuteExchangeDistributionButton_Click"/>
                                </Grid>
                            </TabItem>
                        </TabControl>
                    </Grid>
                </Grid>
            </Grid>
        </GroupBox>

        <Grid Grid.Row="5" Margin="0,0,0,8">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <CheckBox x:Name="WhatIfCheckBox"
                      Grid.Column="0"
                      Content="WhatIf aktiv (Schreibaktionen nur simulieren)"
                      Margin="0,0,16,0"
                      VerticalAlignment="Center"
                      IsChecked="True"
                      Click="WhatIfCheckBox_Click"/>

            <WrapPanel Grid.Column="1"
                       HorizontalAlignment="Right"
                       ItemHeight="26"
                       Orientation="Horizontal">
                <Button x:Name="LoadJsonButton" Content="Load JSON" Width="110" Margin="0,0,8,8" Click="LoadJsonButton_Click"/>
                <Button x:Name="ExportJsonButton" Content="Export Sanitized JSON" Width="170" Margin="0,0,8,8" Click="ExportJsonButton_Click"/>
                <Button x:Name="InitializeButton" Content="Initialize Provider" Width="160" Margin="0,0,8,8" Click="InitializeButton_Click"/>
                <Button x:Name="FetchDataAreasButton" Content="Fetch Data Areas" Width="160" Margin="0,0,8,8" Click="FetchDataAreasButton_Click"/>
                <Button x:Name="FetchSecurityGroupsButton" Content="Fetch Security Groups" Width="170" Margin="0,0,8,8" Click="FetchSecurityGroupsButton_Click"/>
                <Button x:Name="ClearLogButton" Content="Clear Log" Width="110" Margin="0,0,0,8" Click="ClearLogButton_Click"/>
            </WrapPanel>
        </Grid>

        <GroupBox Header="Result" Grid.Row="6" Margin="0,0,0,8">
            <Grid Margin="10">
                <TextBox x:Name="ResultTextBox"
                         TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto"
                         HorizontalScrollBarVisibility="Auto"/>
            </Grid>
        </GroupBox>

        <GroupBox Header="Session Log" Grid.Row="7">
            <Grid Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <TextBlock x:Name="StatusTextBlock" Grid.Row="0" Margin="0,0,0,6" Foreground="Gray"/>
                <ListBox x:Name="LogListBox" Grid.Row="1"
                         SelectionMode="Extended"
                         KeyDown="LogListBox_KeyDown"
                         ScrollViewer.VerticalScrollBarVisibility="Auto"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto"
                         ScrollViewer.CanContentScroll="True"/>
            </Grid>
        </GroupBox>
    </Grid>
    </ScrollViewer>
</Window>
