(()=>{function e(t,r,a,i,e,o){var u="tenant/loginOptions",c={headers:Object.assign({"content-type":"application/json",UseXBasic:!0})},n=a.createEnum([{name:"BASIC",value:"basic"},{name:"OAUTH2",value:"oauth2"},{name:"OAUTH2_INTERNAL",value:"oauth2_internal"}]),s=a.createEnum([{name:"CUSTOM",value:"CUSTOM",label:e("Custom"),componentName:"c8ySsoCustomTemplate"},{name:"AZURE",value:"AZURE",label:e("Azure AD"),componentName:"c8ySsoAadTemplate"}]),l=a.createEnum([{name:"CUSTOM",value:"CUSTOM",label:e("Custom"),signatureVerificationConfigFragment:"manual"},{name:"AZURE",value:"AZURE",label:e("Azure AD"),signatureVerificationConfigFragment:"aad"},{name:"ADFS",value:"ADFS",label:e("ADFS manifest"),signatureVerificationConfigFragment:"adfsManifest"},{name:"JWKS",value:"JWKS",label:e("JWKS"),signatureVerificationConfigFragment:"jwks"}]),m=a.createEnum([{name:"PCKS",value:"PCKS",label:e("X.509 certificate (PEM format)")},{name:"RSA",value:"RSA",label:e("RSA public key (X.509 Subject Public Key Info)")}]),e=a.createEnum([{name:"EXECUTE",value:"EXECUTE",label:e("Log out immediately")},{name:"REDIRECT",value:"REDIRECT",label:e("Redirect to…")}]);return{loginOptions:n,templateTypes:s,certificateTypes:l,algorithmTypes:m,defaultConfiguration:{authorizationRequest:{body:"",headers:{},method:"GET",operation:"REDIRECT",requestParams:{response_type:"token",client_id:"${clientId}",redirect_uri:"${redirectUri}",scope:""}},tokenRequest:{body:"grant_type=authorization_code&code=${code}&redirect_uri=${redirectUri}&client_id=${clientId}",headers:{},method:"POST",operation:"EXECUTE",requestParams:{response_type:"code",client_id:"${clientId}",redirect_uri:"${redirectUri}",scope:""}},refreshRequest:{body:"grant_type=refresh_token&refresh_token=${refreshToken}&client_id=${clientId}",headers:{Authorization:""},method:"POST",operation:"EXECUTE",requestParams:{response_type:"refresh ",client_id:"${clientId}"}},logoutRequest:{headers:{},method:"POST",operation:"REDIRECT",requestParams:{}},type:"oauth2",grantType:"AUTHORIZATION_CODE",onNewUser:{dynamicMapping:{mappings:[]}},userIdConfig:{useConstantValue:!0},signatureVerificationConfig:{manual:{certIdFromField:!1}}},operationTypes:e,list:g,detail:p,save:function(e){return(e.id?e=>{var n=a.url("".concat(u,"/").concat(e.id)),t=e;return d(_.cloneDeep(c)).then(function(e){return r.put(n,t,e)})}:e=>{var n=a.url(u),t=e;return d(_.cloneDeep(c)).then(function(e){return r.post(n,t,e)})})(e)},remove:function(e){var e=a.url("".concat(u,"/").concat(e.id)),n=_.cloneDeep(c);return r.delete(e,n)},isSsoEnabled:function(){return g({}).then(function(e){return e.data.loginOptions.some(function(e){return"OAUTH2"===e.type&&"REMOTE"===e.userManagementSource})})},isSsoClearingUserRolesOnEveryLogin:function(){return p("oauth2",{silentError:!0}).then(function(e){var e=_.get(e,"onNewUser.dynamicMapping.configuration"),n=_.get(e,"mapRolesOnlyForNewUser",!1),e=_.get(e,"manageRolesOnlyFromAccessMapping",!1);return!n&&!e})},getStrongPasswordSettings:function(){return g({}).then(function(e){e=e.data.loginOptions.find(function(e){e=e.type;return[n.BASIC.name,n.OAUTH2_INTERNAL.name].includes(e)});return e?_.pick(e,["enforceStrength","greenMinLength","strengthValidity"]):{enforceStrength:!0,greenMinLength:8,strengthValidity:!0}})}};function d(n){return _.has(n,"params.tenantId")?t.resolve(n):o.current().then(function(e){return e&&e.name},function(){return t.resolve(null)}).then(function(e){return e||(e=i.getCurrentUser(),t.resolve(e&&e.tenant))}).then(function(e){return e&&_.set(n,"params.tenantId",e),n})}function g(e){var n=a.url(u);return d(e).then(function(e){return r.get(n,Object.assign(e,c))})}function p(e,n){e=e.id||e,e=a.url("".concat(u,"/").concat(e));return r.get(e,n).then(a.getResData)}}e.$inject=["$q","$http","c8yBase","c8yUser","gettext","c8yTenant"],angular.module("c8y.core").factory("c8yLoginOptions",e)})();