<div class="ui-title">
    {{::AuthenticationText.Title_SecurityConfiguration}}
</div>

<div class="authentication-section ui-fixed-width-wide">
    <div ng-form="$ctrl.form" tooltip-position="left">
        <label tooltip="SettingsTooltips.Windows" class="ui-radio">
            <input type="radio" ng-value="{{::Zap.AuthenticationProtocol.Windows}}" ng-model="$ctrl.config.AuthenticationProtocol">
            <span class="ui-radio-label">{{::SecurityText.AuthenticationProtocol_Windows}}</span>
        </label>

        <div ng-if="$ctrl.config.AuthenticationProtocol == Zap.AuthenticationProtocol.Windows" class="ui-indented ui-field">
            <label tooltip="SettingsTooltips.PrincipalContextContainer" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_PrincipalContextContainer}}</span>
                <input type="text" ng-model="$ctrl.config.ActiveDirectoryPrincipalContextContainer" class="ui-input-box ui-field-input">
            </label>
        </div>

        <label tooltip="SettingsTooltips.Adfs" class="ui-radio">
            <input type="radio" ng-value="{{::Zap.AuthenticationProtocol.WSFederation}}" ng-model="$ctrl.config.AuthenticationProtocol">
            <span class="ui-radio-label">{{::SecurityText.AuthenticationProtocol_WSFederation}}</span>
        </label>

        <div ng-if="$ctrl.config.AuthenticationProtocol == Zap.AuthenticationProtocol.WSFederation" class="ui-indented ui-field">
            <label tooltip="SettingsTooltips.FederationMetadata" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_FederationMetadata}}</span>
                <input required type="text" name="WSFederationAuthenticationProvider" ng-model="$ctrl.config.WSFederationAuthenticationProvider" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_FederationMetadataIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.WTRealm" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_WTRealm}}</span>
                <input required type="text" name="WSFederationWTRealm" ng-model="$ctrl.config.WSFederationWTRealm" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_WTRealmIsEmpty}}"></span>
            </label>
        </div>

        <label tooltip="SettingsTooltips.EntraId" class="ui-radio">
            <input type="radio" ng-value="{{::Zap.AuthenticationProtocol.EntraId}}" ng-model="$ctrl.config.AuthenticationProtocol">
            <span class="ui-radio-label">{{::SecurityText.AuthenticationProtocol_EntraId}}</span>
        </label>

        <div ng-if="$ctrl.config.AuthenticationProtocol == Zap.AuthenticationProtocol.EntraId" class="ui-indented ui-field">
            <label tooltip="SettingsTooltips.Tenant" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_EntraIdTenant}}</span>
                <input required type="text" name="OpenIdConnectTenant" ng-model="$ctrl.config.OpenIdConnectTenant" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_TenantIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.EntraIdClientId" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_EntraIdClientId}}</span>
                <input required type="text" name="OpenIdConnectClientId" ng-model="$ctrl.config.OpenIdConnectClientId" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_EntraIdClientIdIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.ApplicationKey" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_EntraIdAppKey}}</span>
                <input required type="text" name="OpenIdConnectAppKey" ng-model="$ctrl.config.OpenIdConnectAppKey" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_AppKeyIsEmpty}}"></span>
            </label>
            <label tooltip="SettingsTooltips.UseLegacyAzureGraph" class="ui-checkbox ui-text">
                <input type="checkbox" ng-model="$ctrl.config.UseLegacyAzureGraph">
                <span>{{::AuthenticationText.Label_UseLegacyAzureGraph}}</span>
            </label>
        </div>

        <label tooltip="SettingsTooltips.AzureADB2C" class="ui-radio" ng-if="Zap.FeatureSwitch.optionEnabled('ShowDebugSettings')">
            <input type="radio" ng-value="{{::Zap.AuthenticationProtocol.AzureAdB2C}}" ng-model="$ctrl.config.AuthenticationProtocol">
            <span class="ui-radio-label">{{::SecurityText.AuthenticationProtocol_AzureAdB2C}}</span>
        </label>

        <div ng-if="$ctrl.config.AuthenticationProtocol == Zap.AuthenticationProtocol.AzureAdB2C" class="ui-indented ui-field">
            <label tooltip="SettingsTooltips.Tenant" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_AzureAdB2CTenant}}</span>
                <input required type="text" name="OpenIdConnectTenant" ng-model="$ctrl.config.OpenIdConnectTenant" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_TenantIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.ClientId" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_AzureAdB2CClientId}}</span>
                <input required type="text" name="OpenIdConnectClientId" ng-model="$ctrl.config.OpenIdConnectClientId" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_ClientIdIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.ApplicationKey" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_AzureAdB2CAppKey}}</span>
                <input required type="text" name="OpenIdConnectAppKey" ng-model="$ctrl.config.OpenIdConnectAppKey" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_AppKeyIsEmpty}}"></span>
            </label>

            <label class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_RedirectUri}}</span>
                <input required type="text" name="OpenIdConnectRedirectUri" ng-model="$ctrl.config.OpenIdConnectRedirectUri" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_RedirectUriIsEmpty}}"></span>
            </label>

            <label class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_GraphApiClientId}}</span>
                <input required type="text" name="GraphApiAppId" ng-model="$ctrl.config.GraphApiAppId" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_GraphApiClientIdIsEmpty}}"></span>
            </label>

            <label class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_GraphApiAppKey}}</span>
                <input required type="text" name="GraphApiAppKey" ng-model="$ctrl.config.GraphApiAppKey" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_GraphApiAppKeyIsEmpty}}"></span>
            </label>

            <label class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_SignInPolicy}}</span>
                <input required type="text" name="AzureAdB2CSignInPolicy" ng-model="$ctrl.config.AzureAdB2CSignInPolicy" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_SignInPolicyIsEmpty}}"></span>
            </label>

            <label class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_PasswordResetPolicy}}</span>
                <input required type="text" name="AzureAdB2CSignInPolicy" ng-model="$ctrl.config.AzureAdB2CPasswordResetPolicy" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_PasswordResetPolicyIsEmpty}}"></span>
            </label>

            <label class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_IdTokenHintSharedKey}}</span>
                <input type="text" name="AzureAdB2CIdTokenHintSharedKey" ng-model="$ctrl.config.AzureAdB2CIdTokenHintSharedKey" class="ui-input-box ui-field-input">
            </label>
        </div>

        <label tooltip="SettingsTooltips.Okta" class="ui-radio">
            <input type="radio" ng-value="{{::Zap.AuthenticationProtocol.Okta}}" ng-model="$ctrl.config.AuthenticationProtocol">
            <span class="ui-radio-label">{{::SecurityText.AuthenticationProtocol_Okta}}</span>
        </label>

        <div ng-if="$ctrl.config.AuthenticationProtocol == Zap.AuthenticationProtocol.Okta" class="ui-indented ui-field">
            <label tooltip="SettingsTooltips.Issuer" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_Issuer}}</span>
                <input required type="text" name="OpenIdConnectIssuerUrl" ng-model="$ctrl.config.OpenIdConnectIssuerUrl" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_IssureUrlIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.ClientId" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_ClientId}}</span>
                <input required type="text" name="OpenIdConnectClientId" ng-model="$ctrl.config.OpenIdConnectClientId" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_ClientIdIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.ClientSecret" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_ClientSecret}}</span>
                <input required type="text" name="OpenIdConnectAppKey" ng-model="$ctrl.config.OpenIdConnectAppKey" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_ClientSecretIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.OktaApiToken" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_OktaApiToken}}</span>
                <input required type="text" name="OktaApiKey" ng-model="$ctrl.config.OktaApiKey" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_OktaApiTokenIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.OktaSearchLimit" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_OktaSearchLimit}}</span>
                <input required type="number" name="OktaSearchLimit" ng-model="$ctrl.config.OktaSearchLimit" class="ui-input-box ui-field-input" min="1" max="200">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_OktaSearchLimitIsInvalid}}"></span>
            </label>

            <label tooltip="SettingsTooltips.OpenIdRedirectUri" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_RedirectUri}}</span>
                <input type="text" ng-model="$ctrl.loginRedirectUri" class="ui-input-box ui-field-input" disabled>
            </label>

            <label tooltip="SettingsTooltips.OpenIdPostLogoutRedirectUri" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_PostLogoutRedirectUri}}</span>
                <input type="text" ng-model="$ctrl.postLogoutRedirectUri" class="ui-input-box ui-field-input" disabled>
            </label>
        </div>

        <label tooltip="SettingsTooltips.OpenIdConnect" class="ui-radio">
            <input type="radio" ng-value="{{::Zap.AuthenticationProtocol.OpenIdConnect}}" ng-model="$ctrl.config.AuthenticationProtocol">
            <span class="ui-radio-label">{{::SecurityText.AuthenticationProtocol_OpenIdConnect}}</span>
        </label>

        <div ng-if="$ctrl.config.AuthenticationProtocol == Zap.AuthenticationProtocol.OpenIdConnect" class="ui-indented ui-field">
            <label tooltip="SettingsTooltips.Issuer" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_Issuer}}</span>
                <input required type="text" name="OpenIdConnectIssuerUrl" ng-model="$ctrl.config.OpenIdConnectIssuerUrl" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_IssureUrlIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.ClientId" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_ClientId}}</span>
                <input required type="text" name="OpenIdConnectClientId" ng-model="$ctrl.config.OpenIdConnectClientId" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_ClientIdIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.ClientSecret" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_ClientSecret}}</span>
                <input required type="text" name="OpenIdConnectAppKey" ng-model="$ctrl.config.OpenIdConnectAppKey" class="ui-input-box ui-field-input">
                <span class="ui-validation ui-indicator-medium ui-indicator-error" title="{{::AuthenticationText.Validation_ClientSecretIsEmpty}}"></span>
            </label>

            <label tooltip="SettingsTooltips.OpenIdRedirectUri" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_RedirectUri}}</span>
                <input type="text" ng-model="$ctrl.loginRedirectUri" class="ui-input-box ui-field-input" disabled>
            </label>

            <label tooltip="SettingsTooltips.OpenIdPostLogoutRedirectUri" class="ui-field">
                <span class="ui-field-label">{{::AuthenticationText.Label_PostLogoutRedirectUri}}</span>
                <input type="text" ng-model="$ctrl.postLogoutRedirectUri" class="ui-input-box ui-field-input" disabled>
            </label>
        </div>
    </div>

    <div class="authentication-section" ng-if="$ctrl.license.IsLicensedForGuestUser">
        <div class="ui-subtitle">
            {{ ::AuthenticationText.Title_AnonymousAccess }}
        </div>

        <label tooltip="SettingsTooltips.AllowAnonymousViewers" class="ui-checkbox ui-text" ng-if="$ctrl.license.IsLicensedForGuestUser">
            <input type="checkbox" ng-model="$ctrl.config.AllowGuestUser">
            <span>{{::AuthenticationText.Label_AllowAnonymousViewers }}</span>
        </label>
    </div>
</div>
