All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.RealmSettingsSection-3cf71e46.js Maven / Gradle / Ivy

There is a newer version: 25.0.1
Show newest version
import{bl as is,r as c,aA as Ht,k as rs,cy as Et,ca as vt,q as je,g as O,u as M,c as ae,d as oe,e as pe,Q as ye,j as e,P as Q,F as f,cX as dt,h as k,C as L,S as X,a4 as st,cY as os,L as he,aO as cs,B as E,A as ee,ad as Qe,f as yt,a0 as Pt,y as Se,l as te,V as me,cZ as be,W as Me,aU as wt,X as Be,N as ot,aB as Bt,ap as ds,aq as Je,o as et,b as Ge,K as Ee,T as Gt,c_ as At,c$ as ms,d0 as pt,d1 as us,d2 as ps,d3 as hs,as as gs,Y as fs,M as xs,d4 as Dt,D as bs,a7 as js,G as tt,a8 as qe,cV as ht,cW as St,O as vs,d5 as ys,a as zt,d6 as Rt,d7 as Ss,d8 as Ts,d9 as Nt,da as Ot,db as _t,bt as mt,x as Mt,bo as Cs,aV as ks,Z as Is,aF as Ls,z as Es}from"./index-0cda761d.js";import{u as Ps}from"./useParams-bc47a968.js";import{u as ce}from"./ConfirmDialog-100e6a40.js";import{R as at,u as nt}from"./RoutableTabs-56121a9c.js";import{F as gt,V as ws}from"./ViewHeader-ff389f8e.js";import{u as $t,F as ft}from"./useIsFeatureEnabled-7d978ee4.js";import{F as Y,b as As,S as qt,a as Ie}from"./FormAccess-835af982.js";import{K as le}from"./KeycloakTextInput-ada01047.js";import{P as Ds}from"./PasswordInput-bb06acaa.js";import{F as ie}from"./FormPanel-8c11e1e2.js";import{u as Ne}from"./useToggle-3764a2a4.js";import"./realm-settings-section-4ed993c7.js";import{C as xt}from"./Checkbox-3affa1d3.js";import{A as ge,F as Tt}from"./Form-4087ddae.js";import{a as ut}from"./ActionListItem-c859aeaf.js";import{K as Rs}from"./KeyValueInput-597f6e1a.js";import{S as re,a as ue,b as se,d as Vt}from"./Select-68736f55.js";import{P as Ns,L as Le}from"./PaginatingTableToolbar-11bdf18a.js";import{M as Oe,a as He}from"./Modal-ea09312d.js";import{a8 as Kt,Y as Os,al as Ms,am as Vs,an as Ks,N as Fe}from"./Td-d9b96677.js";import{i as Wt}from"./isEqual-16c26b6b.js";import{b as fe,T as Jt,c as Fs,a as Us}from"./ToolbarContent-fee3570e.js";import{T as Hs,m as Bs,n as Gs,K as Ve}from"./KeycloakDataTable-a1a2bfca.js";import{T as Re,a as zs}from"./Text-b9444fb8.js";import{J as _s}from"./JsonFileUpload-9098f471.js";import{e as Xt,D as Yt,a as Qt,c as Zt,d as bt}from"./DataListItemRow-7ca17a45.js";import{F as es}from"./Flex-a3793595.js";import{F as Ue}from"./FlexItem-742749b8.js";import{R as lt}from"./Radio-a79edd45.js";import{C as Ct,L as kt}from"./CodeEditor-781232a0.js";import{T as q,t as $s}from"./TimeSelector-5680ad0f.js";import{N as it}from"./NumberInput-1d7f57ff.js";import{R as qs}from"./AddRoleMappingModal-71c36ce9.js";import{G as Ws}from"./GroupPickerDialog-9d38b823.js";import{T as rt}from"./Trans-4d909f1b.js";import{Q as Js}from"./question-circle-icon-38235421.js";import{T as It,a as U,b as H}from"./Tabs-76c5b0e3.js";import{F as ts}from"./filter-icon-56a9cd24.js";import{D as ss}from"./DraggableTable-852f161b.js";import{KeyProviderForm as Xs}from"./KeyProviderForm-e2483dde.js";import{u as Lt,U as Ys}from"./UserProfileContext-2c96f79e.js";import"./copy-icon-b8d617db.js";import"./GridItem-1535d986.js";import"./CardHeader-3276a0b8.js";import"./Card-d5c0a973.js";import"./CardTitle-2a7bf3d6.js";import"./CardBody-8867799e.js";import"./check-fc57dbe1.js";import"./minus-icon-21b0d1e4.js";import"./minus-circle-icon-ac3563ca.js";import"./plus-circle-icon-fe78809e.js";import"./EmptyStateBody-f9d2c033.js";import"./star-icon-2ee5dfa7.js";import"./EmptyStateSecondaryActions-e8364506.js";import"./TableToolbar-470a2060.js";import"./grip-vertical-icon-ba7b06db.js";import"./FileUploadForm-eb2a90b9.js";import"./FileUpload-2469f593.js";import"./data-list-7d55714c.js";import"./plus-icon-4f91635d.js";import"./useLocaleSort-ef2c79ac.js";import"./resource-0803fa9b.js";import"./admin-ui-endpoint-f934fa67.js";import"./getAuthorizationHeaders-f2376d1a.js";import"./MenuList-7fad6760.js";import"./DynamicComponents-fe8010c1.js";import"./ClientSelect-ab12f3f6.js";import"./MultiLineInput-05f00b93.js";import"./KeycloakTextArea-9049d04c.js";function Qs(s,a){return a=typeof a=="function"?a:void 0,s&&s.length?is(s,void 0,a):[]}const jt=({value:s,rowIndex:a,cellIndex:t,props:n,handleTextInputChange:l,inputAriaLabel:r,isDisabled:m=!1})=>c.createElement(c.Fragment,null,c.createElement("div",{className:Kt.inlineEditValue},s),c.createElement("div",{className:Kt.inlineEditInput},c.createElement(Ht,{isDisabled:m,value:n.editableValue!==void 0?n.editableValue:s,validated:n.isValid!==!1?"default":"error",type:"text",onChange:(o,b)=>{l(o,b,a,t)},"aria-label":r}),c.createElement("div",{className:rs(Et.formHelperText,Et.modifiers.error),"aria-live":"polite"},n.errorText)));jt.displayName="EditableTextCell";function Zs(){const{whoAmI:s}=vt(),[a,t]=c.useState(),n=s.getUserId();return je(()=>O.users.findOne({id:n}),t,[n]),a}const ea=({realm:s,save:a})=>{const{t}=M("realm-settings"),{realm:n}=ae(),{addAlert:l,addError:r}=oe(),m=Zs(),{register:o,control:b,handleSubmit:i,watch:v,reset:g,getValues:C,formState:{errors:p}}=pe({defaultValues:s}),j=()=>g(s),d=v("smtpServer.from",""),u=v("smtpServer.host",""),[h,x]=Ne(),N=ye({control:b,name:"smtpServer.auth",defaultValue:""}),A=async()=>{const w=V=>Number(V),T=V=>V===(!0).toString(),P=new Map([["port",w],["ssl",T],["starttls",T],["auth",T]]),F={...C().smtpServer};for(const[V,y]of P.entries())F[V]=y(F[V]);F.port===0&&(F.port=null);try{x(),await O.realms.testSMTPConnection({realm:s.realm},F),l(t("testConnectionSuccess"),ee.success)}catch(V){r("realm-settings:testConnectionError",V)}x()};return e.jsxs(Q,{variant:"light",children:[e.jsx(ie,{title:t("template"),className:"kc-email-template",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:i(a),children:[e.jsx(f,{label:t("from"),fieldId:"kc-display-name",isRequired:!0,validated:p.smtpServer?.from?"error":"default",helperTextInvalid:t("users:emailInvalid"),children:e.jsx(le,{type:"email",id:"kc-sender-email-address","data-testid":"sender-email-address",placeholder:"Sender email address",validated:p.smtpServer?.from?"error":"default",...o("smtpServer.from",{pattern:dt,required:!0})})}),e.jsx(f,{label:t("fromDisplayName"),fieldId:"kc-from-display-name",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:fromDisplayName"),fieldLabelId:"realm-settings:authentication"}),children:e.jsx(le,{id:"kc-from-display-name","data-testid":"from-display-name",placeholder:"Display name for Sender email address",...o("smtpServer.fromDisplayName")})}),e.jsx(f,{label:t("replyTo"),fieldId:"kc-reply-to",validated:p.smtpServer?.replyTo?"error":"default",helperTextInvalid:t("users:emailInvalid"),children:e.jsx(le,{type:"email",id:"kc-reply-to",placeholder:"Reply to email address",validated:p.smtpServer?.replyTo?"error":"default",...o("smtpServer.replyTo",{pattern:dt})})}),e.jsx(f,{label:t("replyToDisplayName"),fieldId:"kc-reply-to-display-name",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:replyToDisplayName"),fieldLabelId:"realm-settings:replyToDisplayName"}),children:e.jsx(le,{id:"kc-reply-to-display-name",placeholder:'Display name for "reply to" email address',...o("smtpServer.replyToDisplayName")})}),e.jsx(f,{label:t("envelopeFrom"),fieldId:"kc-envelope-from",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:envelopeFrom"),fieldLabelId:"realm-settings:envelopeFrom"}),children:e.jsx(le,{id:"kc-envelope-from",placeholder:"Sender envelope email address",...o("smtpServer.envelopeFrom")})})]})}),e.jsx(ie,{className:"kc-email-connection",title:t("connectionAndAuthentication"),children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:i(a),children:[e.jsx(f,{label:t("host"),fieldId:"kc-host",isRequired:!0,validated:p.smtpServer?.host?"error":"default",helperTextInvalid:t("common:required"),children:e.jsx(le,{id:"kc-host",placeholder:"SMTP host",validated:p.smtpServer?.host?"error":"default",...o("smtpServer.host",{required:!0})})}),e.jsx(f,{label:t("port"),fieldId:"kc-port",children:e.jsx(le,{id:"kc-port",placeholder:"SMTP port (defaults to 25)",...o("smtpServer.port")})}),e.jsxs(f,{label:t("encryption"),fieldId:"kc-html-display-name",children:[e.jsx(L,{name:"smtpServer.ssl",control:b,defaultValue:"false",render:({field:w})=>e.jsx(xt,{id:"kc-enable-ssl","data-testid":"enable-ssl",label:t("enableSSL"),isChecked:w.value==="true",onChange:T=>w.onChange(""+T)})}),e.jsx(L,{name:"smtpServer.starttls",control:b,defaultValue:"false",render:({field:w})=>e.jsx(xt,{id:"kc-enable-start-tls","data-testid":"enable-start-tls",label:t("enableStartTLS"),isChecked:w.value==="true",onChange:T=>w.onChange(""+T)})})]}),e.jsx(f,{hasNoPaddingTop:!0,label:t("authentication"),fieldId:"kc-authentication",children:e.jsx(L,{name:"smtpServer.auth",control:b,defaultValue:"",render:({field:w})=>e.jsx(X,{id:"kc-authentication-switch","data-testid":"email-authentication-switch",label:t("common:enabled"),labelOff:t("common:disabled"),isChecked:w.value==="true",onChange:T=>{w.onChange(""+T)},"aria-label":t("authentication")})})}),N==="true"&&e.jsxs(e.Fragment,{children:[e.jsx(f,{label:t("username"),fieldId:"kc-username",isRequired:!0,validated:p.smtpServer?.user?"error":"default",helperTextInvalid:t("common:required"),children:e.jsx(le,{id:"kc-username","data-testid":"username-input",placeholder:"Login username",validated:p.smtpServer?.user?"error":"default",...o("smtpServer.user",{required:!0})})}),e.jsx(f,{label:t("password"),fieldId:"kc-username",isRequired:!0,validated:p.smtpServer?.password?"error":"default",helperTextInvalid:t("common:required"),labelIcon:e.jsx(k,{helpText:t("realm-settings-help:password"),fieldLabelId:"realm-settings:password"}),children:e.jsx(Ds,{id:"kc-password","data-testid":"password-input","aria-label":t("password"),validated:p.smtpServer?.password?"error":"default",...o("smtpServer.password",{required:!0})})})]}),m&&e.jsx(f,{id:"descriptionTestConnection",children:m.email?e.jsx(st,{variant:"info",isInline:!0,title:t("testConnectionHint.withEmail",{email:m.email})}):e.jsx(st,{variant:"warning",component:"h2",isInline:!0,title:t("testConnectionHint.withoutEmail",{userName:m.username}),actionLinks:e.jsx(os,{component:w=>e.jsx(he,{...w,to:cs({realm:n,id:m.id,tab:"settings"})}),children:t("testConnectionHint.withoutEmailAction")})})}),e.jsxs(ge,{children:[e.jsx(ut,{children:e.jsx(E,{variant:"primary",type:"submit","data-testid":"email-tab-save",children:t("common:save")})}),e.jsx(ut,{children:e.jsx(E,{variant:"secondary",onClick:()=>A(),"data-testid":"test-connection-button",isDisabled:!(dt.test(d)&&u)||!m?.email,"aria-describedby":"descriptionTestConnection",isLoading:h,spinnerAriaValueText:t("testingConnection"),children:t("common:testConnection")})}),e.jsx(ut,{children:e.jsx(E,{variant:"link",onClick:j,"data-testid":"email-tab-revert",children:t("common:revert")})})]})]})})]})},ta=({realm:s,save:a})=>{const{t}=M("realm-settings"),{realm:n}=ae(),l=pe(),{register:r,control:m,handleSubmit:o,setValue:b,formState:{isDirty:i,errors:v}}=l,g=$t(),[C,p]=c.useState(!1),j=["all","external","none"],d=()=>{if(Se(s,b),s.attributes?.["acr.loa.map"]){const u=Object.entries(JSON.parse(s.attributes["acr.loa.map"])).flatMap(([h,x])=>({key:h,value:x}));u.concat({key:"",value:""}),b(Qe("attributes.acr.loa.map"),u)}};return c.useEffect(d,[]),e.jsx(Q,{variant:"light",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:o(a),children:[e.jsx(f,{label:t("realmId"),fieldId:"kc-realm-id",isRequired:!0,validated:v.realm?"error":"default",helperTextInvalid:v.realm?.message,children:e.jsx(L,{name:"realm",control:m,rules:{required:{value:!0,message:t("common:required")},pattern:{value:/^[a-zA-Z0-9-_]+$/,message:t("realm:invalidRealmName")}},defaultValue:"",render:({field:u})=>e.jsx(As,{"data-testid":"realmName",onChange:u.onChange,children:u.value})})}),e.jsx(f,{label:t("displayName"),fieldId:"kc-display-name",children:e.jsx(le,{id:"kc-display-name",...r("displayName")})}),e.jsx(f,{label:t("htmlDisplayName"),fieldId:"kc-html-display-name",children:e.jsx(le,{id:"kc-html-display-name",...r("displayNameHtml")})}),e.jsx(f,{label:t("frontendUrl"),fieldId:"kc-frontend-url",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:frontendUrl"),fieldLabelId:"realm-settings:frontendUrl"}),children:e.jsx(le,{type:"url",id:"kc-frontend-url",...r(Qe("attributes.frontendUrl"))})}),e.jsx(f,{label:t("requireSsl"),fieldId:"kc-require-ssl",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:requireSsl"),fieldLabelId:"realm-settings:requireSsl"}),children:e.jsx(L,{name:"sslRequired",defaultValue:"none",control:m,render:({field:u})=>e.jsx(re,{toggleId:"kc-require-ssl",onToggle:()=>p(!C),onSelect:(h,x)=>{u.onChange(x),p(!1)},selections:u.value,variant:ue.single,"aria-label":t("requireSsl"),isOpen:C,children:j.map(h=>e.jsx(se,{selected:h===u.value,value:h,children:t(`sslType.${h}`)},h))})})}),e.jsx(f,{label:t("clients:acrToLoAMapping"),fieldId:"acrToLoAMapping",labelIcon:e.jsx(k,{helpText:t("clients-help:acrToLoAMapping"),fieldLabelId:"clients:acrToLoAMapping"}),children:e.jsx(yt,{...l,children:e.jsx(Rs,{name:Qe("attributes.acr.loa.map")})})}),e.jsx(f,{hasNoPaddingTop:!0,label:t("userManagedAccess"),labelIcon:e.jsx(k,{helpText:t("realm-settings-help:userManagedAccess"),fieldLabelId:"realm-settings:userManagedAccess"}),fieldId:"kc-user-managed-access",children:e.jsx(L,{name:"userManagedAccessAllowed",control:m,defaultValue:!1,render:({field:u})=>e.jsx(X,{id:"kc-user-managed-access","data-testid":"user-managed-access-switch",label:t("common:on"),labelOff:t("common:off"),isChecked:u.value,onChange:u.onChange,"aria-label":t("userManagedAccess")})})}),g(ft.DeclarativeUserProfile)&&e.jsx(f,{hasNoPaddingTop:!0,label:t("userProfileEnabled"),labelIcon:e.jsx(k,{helpText:t("realm-settings-help:userProfileEnabled"),fieldLabelId:"realm-settings:userProfileEnabled"}),fieldId:"kc-user-profile-enabled",children:e.jsx(L,{name:Qe("attributes.userProfileEnabled"),control:m,defaultValue:"false",render:({field:u})=>e.jsx(X,{id:"kc-user-profile-enabled","data-testid":"user-profile-enabled-switch",label:t("common:on"),labelOff:t("common:off"),isChecked:u.value==="true",onChange:h=>u.onChange(h.toString()),"aria-label":t("userProfileEnabled")})})}),e.jsx(f,{label:t("endpoints"),labelIcon:e.jsx(k,{helpText:t("realm-settings-help:endpoints"),fieldLabelId:"realm-settings:endpoints"}),fieldId:"kc-endpoints",children:e.jsxs(qt,{children:[e.jsx(Ie,{children:e.jsx(gt,{href:`${Pt(O.baseUrl)}realms/${n}/.well-known/openid-configuration`,title:t("openIDEndpointConfiguration")})}),e.jsx(Ie,{children:e.jsx(gt,{href:`${Pt(O.baseUrl)}realms/${n}/protocol/saml/descriptor`,title:t("samlIdentityProviderMetadata")})})]})}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",type:"submit","data-testid":"general-tab-save",isDisabled:!i,children:t("common:save")}),e.jsx(E,{"data-testid":"general-tab-revert",variant:"link",onClick:d,children:t("common:revert")})]})]})})},sa=({handleModalToggle:s,save:a,form:{register:t,handleSubmit:n,formState:{errors:l}}})=>{const{t:r}=M("realm-settings");return e.jsx(Oe,{variant:He.small,title:r("addMessageBundle"),isOpen:!0,onClose:s,actions:[e.jsx(E,{"data-testid":"add-bundle-confirm-button",variant:"primary",type:"submit",form:"bundle-form",children:r("common:create")},"confirm"),e.jsx(E,{id:"modal-cancel","data-testid":"cancel",variant:te.link,onClick:()=>{s()},children:r("common:cancel")},"cancel")],children:e.jsxs(Tt,{id:"bundle-form",isHorizontal:!0,onSubmit:n(a),children:[e.jsx(f,{label:r("common:key"),name:"key",fieldId:"key-id",helperTextInvalid:r("common:required"),validated:l.key?me.error:me.default,isRequired:!0,children:e.jsx(le,{"data-testid":"key-input",autoFocus:!0,id:"key-id",validated:l.key?me.error:me.default,...t("key",{required:!0})})}),e.jsx(f,{label:r("common:value"),name:"add-value",fieldId:"value-id",helperTextInvalid:r("common:required"),validated:l.value?me.error:me.default,isRequired:!0,children:e.jsx(le,{"data-testid":"value-input",id:"value-id",validated:l.value?me.error:me.default,...t("value",{required:!0})})})]})})},Ce=s=>{try{return new Intl.DisplayNames([s],{type:"language"}).of(s)}catch{return s}},aa=({save:s,realm:a})=>{const{t}=M("realm-settings"),[n,l]=c.useState(!1),[r,m]=c.useState(!1),[o,b]=c.useState(!1),[i,v]=c.useState(!1),[g,C]=c.useState(be),{setValue:p,getValues:j,control:d,handleSubmit:u,formState:h}=pe(),[x,N]=c.useState(!1),[A,w]=c.useState([]),[T,P]=c.useState([]),F=Me().themes,V=c.useMemo(()=>{const I=Object.values(F).flatMap(R=>R.flatMap(({locales:J})=>J||[]));return Array.from(new Set(I))},[F]),y=pe({mode:"onChange"}),{addAlert:K,addError:W}=oe(),{realm:D}=ae(),{whoAmI:z}=vt(),_=a.supportedLocales?.length?a.supportedLocales:[be],de=()=>{Se(a,p),p("supportedLocales",_)};c.useEffect(de,[]);const xe=ye({control:d,name:"supportedLocales",defaultValue:_}),G=ye({control:d,name:"internationalizationEnabled",defaultValue:a.internationalizationEnabled}),[ze,Z]=c.useState(0),[Te,Xe]=c.useState(10),[Pe,Ke]=c.useState(0),[we,ct]=c.useState(""),_e=()=>{Z(ze+1)};je(async()=>{let I=await O.realms.getRealmLocalizationTexts({first:Pe,max:Te,realm:a.realm,selectedLocale:g||j("defaultLocale")||z.getLocale()}).catch(()=>[]);const R=J=>Object.entries(I).filter($=>$[J].includes(we));if(we){const J=Qs(R(0).concat(R(1)),Wt);I=Object.fromEntries(J)}return{result:I}},({result:I})=>{const R=Object.entries(I).slice(Pe,Pe+Te+1);w(R);const J=R.map($=>({rowEditBtnAriaLabel:()=>t("rowEditBtnAriaLabel",{messageBundle:$[1]}),rowSaveBtnAriaLabel:()=>t("rowSaveBtnAriaLabel",{messageBundle:$[1]}),rowCancelBtnAriaLabel:()=>t("rowCancelBtnAriaLabel",{messageBundle:$[1]}),cells:[{title:(ne,ve,De,$e)=>e.jsx(jt,{value:ne,rowIndex:ve,cellIndex:De,props:$e,isDisabled:!0,handleTextInputChange:Ye,inputAriaLabel:$[0]}),props:{value:$[0]}},{title:(ne,ve,De,$e)=>e.jsx(jt,{value:ne,rowIndex:ve,cellIndex:De,props:$e,handleTextInputChange:Ye,inputAriaLabel:$[1]}),props:{value:$[1]}}]}));return P(J),R},[ze,we,Pe,Te]);const Ye=(I,R,J,$)=>{P(ne=>{const ve=wt(ne),De=ve[J]?.cells?.[$];return De.props.editableValue=I,ve})},S=async(I,R,J)=>{if(R===void 0)return;const $=wt(T);let ne;const ve=!!J&&Object.keys(J).length>0;if(ve?ne=Ms($[R],I,J):I==="cancel"?ne=Vs($[R]):ne=Ks($[R],I),$[R]=ne,!ve&&I==="save"){const De=(ne.cells?.[0]).props.value,$e=(ne.cells?.[1]).props.value;try{await O.realms.addLocalization({realm:a.realm,selectedLocale:g||j("defaultLocale")||be,key:De},$e),K(t("updateMessageBundleSuccess"),ee.success)}catch{K(t("updateMessageBundleError"),ee.danger)}}P($)},B=()=>{l(!n)},Ae=[e.jsx(Vt,{label:t("defaultLocale"),children:e.jsx(se,{value:be,children:Ce(be)},be)},"group1"),e.jsx(Be,{},"divider"),e.jsx(Vt,{label:t("supportedLocales"),children:xe.map(I=>e.jsx(se,{value:I,children:Ce(I)},I))},"group2")],ns=async I=>{try{await O.realms.addLocalization({realm:D,selectedLocale:g||j("defaultLocale")||be,key:I.key},I.value),O.setConfig({realmName:D}),_e(),K(t("addMessageBundleSuccess"),ee.success)}catch(R){W(t("addMessageBundleError"),R)}},ls=async I=>{try{await O.realms.deleteRealmLocalizationTexts({realm:D,selectedLocale:g,key:I}),_e(),K(t("deleteMessageBundleSuccess"))}catch(R){W("realm-settings:deleteMessageBundleError",R)}};return e.jsxs(e.Fragment,{children:[n&&e.jsx(sa,{handleModalToggle:B,save:I=>{ns(I),B()},form:y}),e.jsxs(Q,{variant:"light",children:[e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:u(s),children:[e.jsx(f,{label:t("internationalization"),fieldId:"kc-internationalization",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:internationalization"),fieldLabelId:"realm-settings:internationalization"}),children:e.jsx(L,{name:"internationalizationEnabled",control:d,defaultValue:a.internationalizationEnabled,render:({field:I})=>e.jsx(X,{id:"kc-l-internationalization",label:t("common:enabled"),labelOff:t("common:disabled"),isChecked:I.value,"data-testid":I.value?"internationalization-enabled":"internationalization-disabled",onChange:I.onChange,"aria-label":t("internationalization")})})}),G&&e.jsxs(e.Fragment,{children:[e.jsx(f,{label:t("supportedLocales"),fieldId:"kc-l-supported-locales",children:e.jsx(L,{name:"supportedLocales",control:d,defaultValue:_,render:({field:I})=>e.jsx(re,{toggleId:"kc-l-supported-locales",onToggle:R=>{m(R)},onSelect:(R,J)=>{const $=J;I.value.includes($)?I.onChange(I.value.filter(ne=>ne!==$)):I.onChange([...I.value,$])},onClear:()=>{I.onChange([])},selections:I.value,variant:ue.typeaheadMulti,"aria-label":t("supportedLocales"),isOpen:r,placeholderText:t("selectLocales"),children:V.map(R=>e.jsx(se,{selected:I.value.includes(R),value:R,children:Ce(R)},R))})})}),e.jsx(f,{label:t("defaultLocale"),fieldId:"kc-l-default-locale",children:e.jsx(L,{name:"defaultLocale",control:d,defaultValue:be,render:({field:I})=>e.jsx(re,{toggleId:"kc-default-locale",onToggle:()=>b(!o),onSelect:(R,J)=>{I.onChange(J),b(!1)},selections:I.value?Ce(I.value):a.defaultLocale!==""?Ce(a.defaultLocale||be):t("placeholderText"),variant:ue.single,"aria-label":t("defaultLocale"),isOpen:o,placeholderText:t("placeholderText"),"data-testid":"select-default-locale",children:xe.map((R,J)=>e.jsx(se,{value:R,children:Ce(R)},`default-locale-${J}`))})})})]}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",isDisabled:!h.isDirty,type:"submit","data-testid":"localization-tab-save",children:t("common:save")}),e.jsx(E,{variant:"link",onClick:de,children:t("common:revert")})]})]}),e.jsxs(ie,{className:"kc-message-bundles",title:"Edit message bundles",children:[e.jsx(ot,{className:"messageBundleDescription",children:t("messageBundleDescription")}),e.jsx("div",{className:"tableBorder",children:e.jsxs(Ns,{count:A.length,first:Pe,max:Te,onNextClick:Ke,onPreviousClick:Ke,onPerPageSelect:(I,R)=>{Ke(I),Xe(R)},inputGroupName:"common:search",inputGroupOnEnter:I=>{ct(I),Ke(0),Xe(10)},inputGroupPlaceholder:t("searchForMessageBundle"),toolbarItem:e.jsx(E,{"data-testid":"add-bundle-button",onClick:()=>l(!0),children:t("addMessageBundle")}),searchTypeComponent:e.jsx(fe,{children:e.jsx(re,{width:180,"data-testid":"filter-by-locale-select",isOpen:i,className:"kc-filter-by-locale-select",variant:ue.single,isDisabled:!G,onToggle:I=>v(I),onSelect:(I,R)=>{C(R.toString()),N(!0),_e(),v(!1)},selections:x?Ce(g):a.defaultLocale!==""?Ce(be):t("placeholderText"),children:Ae})}),children:[A.length===0&&!we&&e.jsx(Le,{hasIcon:!0,message:t("noMessageBundles"),instructions:t("noMessageBundlesInstructions"),onPrimaryAction:B}),A.length===0&&we&&e.jsx(Le,{hasIcon:!0,icon:Bt,isSearchVariant:!0,message:t("common:noSearchResults"),instructions:t("common:noSearchResultsInstructions")}),A.length!==0&&e.jsxs(Hs,{"aria-label":t("editableRowsTable"),"data-testid":"editable-rows-table",variant:Os.compact,cells:[t("common:key"),t("common:value")],rows:T,onRowEdit:(I,R,J,$,ne)=>S(R,$,ne),actions:[{title:t("common:delete"),onClick:(I,R)=>ls((T[R].cells?.[0]).props.value)}],children:[e.jsx(Bs,{}),e.jsx(Gs,{})]})]})})]})]})]})},na=({realm:s,refresh:a})=>{const{t}=M("realm-settings"),{addAlert:n,addError:l}=oe(),{realm:r}=ae(),m=async o=>{const b=Array.isArray(o)?Object.keys(o[0])[0]:Object.keys(o)[0];try{await O.realms.update({realm:r},Array.isArray(o)?o.reduce((i,v)=>Object.assign(i,v),s):Object.assign(s,o)),n(t("enableSwitchSuccess",{switch:t(b)})),a()}catch(i){l(t("enableSwitchError"),i)}};return e.jsxs(Q,{variant:"light",children:[e.jsx(ie,{className:"kc-login-screen",title:t("loginScreenCustomization"),children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",children:[e.jsx(f,{label:t("registrationAllowed"),fieldId:"kc-user-reg",labelIcon:e.jsx(k,{helpText:t("userRegistrationHelpText"),fieldLabelId:"realm-settings:registrationAllowed"}),hasNoPaddingTop:!0,children:e.jsx(X,{id:"kc-user-reg-switch","data-testid":"user-reg-switch",value:s.registrationAllowed?"on":"off",label:t("common:on"),labelOff:t("common:off"),isChecked:s.registrationAllowed,onChange:o=>{m({registrationAllowed:o})},"aria-label":t("registrationAllowed")})}),e.jsx(f,{label:t("resetPasswordAllowed"),fieldId:"kc-forgot-pw",labelIcon:e.jsx(k,{helpText:t("realm-settings:forgotPasswordHelpText"),fieldLabelId:"realm-settings:resetPasswordAllowed"}),hasNoPaddingTop:!0,children:e.jsx(X,{id:"kc-forgot-pw-switch","data-testid":"forgot-pw-switch",name:"resetPasswordAllowed",value:s.resetPasswordAllowed?"on":"off",label:t("common:on"),labelOff:t("common:off"),isChecked:s.resetPasswordAllowed,onChange:o=>{m({resetPasswordAllowed:o})},"aria-label":t("resetPasswordAllowed")})}),e.jsx(f,{label:t("rememberMe"),fieldId:"kc-remember-me",labelIcon:e.jsx(k,{helpText:t("realm-settings:rememberMeHelpText"),fieldLabelId:"realm-settings:rememberMe"}),hasNoPaddingTop:!0,children:e.jsx(X,{id:"kc-remember-me-switch","data-testid":"remember-me-switch",value:s.rememberMe?"on":"off",label:t("common:on"),labelOff:t("common:off"),isChecked:s.rememberMe,onChange:o=>{m({rememberMe:o})},"aria-label":t("rememberMe")})})]})}),e.jsx(ie,{className:"kc-email-settings",title:t("emailSettings"),children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",children:[e.jsx(f,{label:t("registrationEmailAsUsername"),fieldId:"kc-email-as-username",labelIcon:e.jsx(k,{helpText:t("realm-settings:emailAsUsernameHelpText"),fieldLabelId:"realm-settings:registrationEmailAsUsername"}),hasNoPaddingTop:!0,children:e.jsx(X,{id:"kc-email-as-username-switch","data-testid":"email-as-username-switch",value:s.registrationEmailAsUsername?"on":"off",label:t("common:on"),labelOff:t("common:off"),isChecked:s.registrationEmailAsUsername,onChange:o=>{m([{registrationEmailAsUsername:o},{duplicateEmailsAllowed:!1}])},"aria-label":t("registrationEmailAsUsername")})}),e.jsx(f,{label:t("loginWithEmailAllowed"),fieldId:"kc-login-with-email",labelIcon:e.jsx(k,{helpText:t("realm-settings:loginWithEmailHelpText"),fieldLabelId:"realm-settings:loginWithEmailAllowed"}),hasNoPaddingTop:!0,children:e.jsx(X,{id:"kc-login-with-email-switch","data-testid":"login-with-email-switch",value:s.loginWithEmailAllowed?"on":"off",label:t("common:on"),labelOff:t("common:off"),isChecked:s.loginWithEmailAllowed,onChange:o=>{m([{loginWithEmailAllowed:o},{duplicateEmailsAllowed:!1}])},"aria-label":t("loginWithEmailAllowed")})}),e.jsx(f,{label:t("duplicateEmailsAllowed"),fieldId:"kc-duplicate-emails",labelIcon:e.jsx(k,{helpText:t("realm-settings:duplicateEmailsHelpText"),fieldLabelId:"realm-settings:duplicateEmailsAllowed"}),hasNoPaddingTop:!0,children:e.jsx(X,{id:"kc-duplicate-emails-switch","data-testid":"duplicate-emails-switch",label:t("common:on"),labelOff:t("common:off"),isChecked:s.duplicateEmailsAllowed||s.loginWithEmailAllowed&&s.registrationEmailAsUsername,onChange:o=>{m({duplicateEmailsAllowed:o})},isDisabled:s.loginWithEmailAllowed||s.registrationEmailAsUsername,"aria-label":t("duplicateEmailsAllowed")})}),e.jsx(f,{label:t("verifyEmail"),fieldId:"kc-verify-email",labelIcon:e.jsx(k,{helpText:t("realm-settings:verifyEmailHelpText"),fieldLabelId:"realm-settings:verifyEmail"}),hasNoPaddingTop:!0,children:e.jsx(X,{id:"kc-verify-email-switch","data-testid":"verify-email-switch",name:"verifyEmail",value:s.verifyEmail?"on":"off",label:t("common:on"),labelOff:t("common:off"),isChecked:s.verifyEmail,onChange:o=>{m({verifyEmail:o})},"aria-label":t("verifyEmail")})})]})}),e.jsx(ie,{className:"kc-user-info-settings",title:t("userInfoSettings"),children:e.jsx(Y,{isHorizontal:!0,role:"manage-realm",children:e.jsx(f,{label:t("editUsernameAllowed"),fieldId:"kc-edit-username",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:editUsername"),fieldLabelId:"realm-settings:editUsernameAllowed"}),hasNoPaddingTop:!0,children:e.jsx(X,{id:"kc-edit-username-switch","data-testid":"edit-username-switch",value:s.editUsernameAllowed?"on":"off",label:t("common:on"),labelOff:t("common:off"),isChecked:s.editUsernameAllowed,onChange:o=>{m({editUsernameAllowed:o})},"aria-label":t("editUsernameAllowed")})})})})]})};const la=({isOpen:s,onClose:a})=>{const{t}=M("realm-settings"),{realm:n}=ae(),{addAlert:l,addError:r}=oe(),[m,o]=c.useState(!1),[b,i]=c.useState(!1),[v,g]=c.useState(!1),C=m||b;async function p(){g(!0);try{const j=await O.realms.export({realm:n,exportClients:b,exportGroupsAndRoles:m});ds.saveAs(new Blob([Je(j)],{type:"application/json"}),"realm-export.json"),l(t("exportSuccess"),ee.success),a()}catch(j){r("exportFail",j)}g(!1)}return e.jsxs(Oe,{variant:He.small,title:t("partialExport"),isOpen:s,onClose:a,actions:[e.jsx(E,{"data-testid":"export-button",isDisabled:v,onClick:p,children:t("common:export")},"export"),e.jsx(E,{"data-testid":"cancel-button",variant:te.link,onClick:a,children:t("common:cancel")},"cancel")],children:[e.jsx(ot,{children:e.jsx(Re,{children:t("partialExportHeaderText")})}),e.jsxs(Tt,{isHorizontal:!0,className:"keycloak__realm-settings__partial-import_form",children:[e.jsx(f,{label:t("includeGroupsAndRoles"),fieldId:"include-groups-and-roles-check",hasNoPaddingTop:!0,children:e.jsx(X,{id:"include-groups-and-roles-check","data-testid":"include-groups-and-roles-check",isChecked:m,onChange:o,label:t("common:on"),labelOff:t("common:off"),"aria-label":t("includeGroupsAndRoles")})}),e.jsx(f,{label:t("includeClients"),fieldId:"include-clients-check",hasNoPaddingTop:!0,children:e.jsx(X,{id:"include-clients-check","data-testid":"include-clients-check",onChange:i,isChecked:b,label:t("common:on"),labelOff:t("common:off"),"aria-label":t("includeClients")})})]}),C&&e.jsx(st,{"data-testid":"warning-message",variant:"warning",title:t("exportWarningTitle"),isInline:!0,children:t("exportWarningDescription")})]})},Ft={users:!1,clients:!1,groups:!1,identityProviders:!1,realmRoles:!1,clientRoles:!1},ia=s=>{const{t:a}=M("realm-settings"),{realm:t}=ae(),[n,l]=c.useState(),r=!!n,[m,o]=c.useState(!1),[b,i]=c.useState(!1),[v,g]=c.useState(!1),[C,p]=c.useState("FAIL"),[j,d]=c.useState({}),[u,h]=c.useState(),{addError:x}=oe(),[N,A]=c.useState(Ft),w=Object.values(N).some(S=>S),T=()=>{A(Ft)},P=()=>{l(void 0),d({}),p("FAIL"),T()};c.useEffect(()=>{g(!1),h(void 0),P()},[s.open]);const F=S=>{P(),l(S),Array.isArray(S)?S.length>0&&d(S[0]):d(S)},V=S=>{d(S),o(!1),T()},y=(S,B)=>{const Ae=B.currentTarget.name;A({...N,[Ae]:S})},K=S=>S.map(B=>e.jsx(se,{value:B,"data-testid":B.id+"-select-option",children:B.realm||B.id},B.id)),W=(S,B)=>{p(B),i(!1)},D=()=>[e.jsx(se,{value:"FAIL",children:a("FAIL")},"fail"),e.jsx(se,{value:"SKIP",children:a("SKIP")},"skip"),e.jsx(se,{value:"OVERWRITE",children:a("OVERWRITE")},"overwrite")],z=()=>_("users")||_("groups")||_("clients")||_("identityProviders")||de()||xe(),_=S=>{const B=j[S];return B!==void 0&&B.length>0},de=()=>{const S=j.roles?.realm;return S!==void 0&&S.length>0},xe=()=>{const S=j.roles?.client;return S!==void 0&&Object.keys(S).length>0},G=S=>r?S==="realmRoles"?j.roles?.realm?.length??0:S==="clientRoles"?xe()?ze(j.roles.client):0:j[S]?.length??0:0,ze=S=>Object.values(S).reduce((B,Ae)=>B+Ae.length,0),Z=(S,B)=>e.jsx(Yt,{"aria-labelledby":`${S}-list-item`,children:e.jsx(Qt,{children:e.jsx(Zt,{dataListCells:[e.jsx(bt,{children:e.jsx(xt,{id:`${S}-checkbox`,label:`${G(S)} ${B}`,"aria-labelledby":`${S}-checkbox`,name:S,isChecked:N[S],onChange:y,"data-testid":S+"-checkbox"})},S)]})})}),Te=()=>{const S={ifResourceExists:C,id:j.id,realm:j.realm};return N.users&&(S.users=j.users),N.groups&&(S.groups=j.groups),N.identityProviders&&(S.identityProviders=j.identityProviders),N.clients&&(S.clients=j.clients),(N.realmRoles||N.clientRoles)&&(S.roles=j.roles,N.realmRoles||delete S.roles?.realm,N.clientRoles||delete S.roles?.client),S};async function Xe(){if(!v){g(!0);try{const S=await O.realms.partialImport({realm:t,rep:Te()});h(S)}catch(S){x("realm-settings:importFail",S)}g(!1)}}const Pe=()=>e.jsx(Oe,{variant:He.medium,title:a("partialImport"),isOpen:s.open,onClose:s.toggleDialog,actions:[e.jsx(E,{id:"modal-import","data-testid":"import-button",isDisabled:!w,onClick:()=>{Xe()},children:a("import")},"import"),e.jsx(E,{id:"modal-cancel","data-testid":"cancel-button",variant:te.link,onClick:()=>{s.toggleDialog()},children:a("common:cancel")},"cancel")],children:e.jsxs(qt,{hasGutter:!0,children:[e.jsx(Ie,{children:e.jsx(ot,{children:e.jsx(Re,{children:a("partialImportHeaderText")})})}),e.jsx(Ie,{children:e.jsx(_s,{id:"partial-import-file",allowEditingUploadedText:!0,onChange:F})}),r&&z()&&e.jsxs(e.Fragment,{children:[e.jsx(Ie,{children:e.jsx(Be,{})}),Array.isArray(n)&&n.length>1&&e.jsxs(Ie,{children:[e.jsxs(Re,{children:[a("selectRealm"),":"]}),e.jsx(re,{toggleId:"realm-selector",isOpen:m,onToggle:()=>o(!m),onSelect:(S,B)=>V(B),placeholderText:j.realm||j.id,children:K(n)})]}),e.jsxs(Ie,{children:[e.jsxs(Re,{children:[a("chooseResources"),":"]}),e.jsxs(Xt,{"aria-label":a("resourcesToImport"),isCompact:!0,children:[_("users")&&Z("users",a("common:users")),_("groups")&&Z("groups",a("common:groups")),_("clients")&&Z("clients",a("common:clients")),_("identityProviders")&&Z("identityProviders",a("common:identityProviders")),de()&&Z("realmRoles",a("common:realmRoles")),xe()&&Z("clientRoles",a("common:clientRoles"))]})]}),e.jsxs(Ie,{children:[e.jsxs(Re,{children:[a("selectIfResourceExists"),":"]}),e.jsx(re,{isOpen:b,direction:"up",onToggle:()=>{i(!b)},onSelect:W,placeholderText:a(C),children:D()})]})]})]})}),Ke=()=>`${a("importAdded",{count:u?.added})}  ${a("importSkipped",{count:u?.skipped})} ${a("importOverwritten",{count:u?.overwritten})}`,we=async(S=0,B=15)=>{if(!u)return[];const Ae=Math.min(S+B,u.results.length);return u.results.slice(S,Ae)},ct=S=>{switch(S.action){case"ADDED":return e.jsx(et,{color:"green",children:a("added")},S.id);case"SKIPPED":return e.jsx(et,{color:"orange",children:a("skipped")},S.id);case"OVERWRITTEN":return e.jsx(et,{color:"purple",children:a("overwritten")},S.id);default:return""}},_e=S=>{const B=new Map([["CLIENT",a("common:clients")],["REALM_ROLE",a("common:realmRoles")],["USER",a("common:users")],["CLIENT_ROLE",a("common:clientRoles")],["IDP",a("common:identityProviders")],["GROUP",a("common:groups")]]);return e.jsx("span",{children:B.get(S.resourceType)})},Ye=()=>e.jsxs(Oe,{variant:He.medium,title:a("partialImport"),isOpen:s.open,onClose:s.toggleDialog,actions:[e.jsx(E,{id:"modal-close","data-testid":"close-button",variant:te.primary,onClick:()=>{s.toggleDialog()},children:a("common:close")},"close")],children:[e.jsx(st,{variant:"success",isInline:!0,title:Ke()}),e.jsx(Ve,{loader:we,isPaginated:!0,ariaLabelKey:"realm-settings:partialImport",columns:[{name:"action",displayKey:"common:action",cellRenderer:ct},{name:"resourceType",displayKey:"common:type",cellRenderer:_e},{name:"resourceName",displayKey:"common:name"},{name:"id",displayKey:"common:id"}]})]});return u?Ye():Pe()},ra=()=>{const{t:s}=M("realm-settings"),{addAlert:a,addError:t}=oe(),{realm:n}=ae(),l=Ge(),[r,m]=c.useState(!1),[o,b]=c.useState(),[i,v]=c.useState(),[g,C]=c.useState(0),[p,j]=c.useState(),[d,u]=c.useState(),h=()=>C(g+1),x=pe({mode:"onChange"});je(()=>O.clientPolicies.listPolicies(),y=>{b(y.policies),u(y.policies||[]),j(Je(y.policies))},[g]);const N=async()=>o??[],A=async()=>{const y=x.getValues(),K=o?.map(W=>{const D=y[W.name];return{...W,enabled:D}});try{await O.clientPolicies.updatePolicy({policies:K}),l(pt({realm:n,tab:"policies"})),a(s("realm-settings:updateClientPolicySuccess"),ee.success)}catch(W){t("realm-settings:updateClientPolicyError",W)}},w=({name:y})=>e.jsx(he,{to:ms({realm:n,policyName:y}),children:y}),T=({clientPolicy:y})=>{const[K,W]=ce({titleKey:"realm-settings:disablePolicyConfirmTitle",messageKey:"realm-settings:disablePolicyConfirm",continueButtonLabel:"common:disable",onConfirm:()=>{x.setValue(y.name,!1),A()}});return e.jsxs(e.Fragment,{children:[e.jsx(W,{}),e.jsx(L,{name:y.name,"data-testid":`${y.name}-switch`,defaultValue:y.enabled,control:x.control,render:({field:D})=>e.jsx(X,{label:s("common:enabled"),labelOff:s("common:disabled"),isChecked:D.value,onChange:z=>{z?(D.onChange(z),A()):K()},"aria-label":y.name})})]})},P=async()=>{if(p)try{const y=JSON.parse(p);try{await O.clientPolicies.updatePolicy({policies:y}),a(s("realm-settings:updateClientPoliciesSuccess"),ee.success),h()}catch(K){t("realm-settings:updateClientPoliciesError",K)}}catch(y){console.warn("Invalid json, ignoring value using {}"),t("realm-settings:updateClientPoliciesError",y)}},[F,V]=ce({titleKey:s("deleteClientPolicyConfirmTitle"),messageKey:s("deleteClientPolicyConfirm",{policyName:i?.name}),continueButtonLabel:s("delete"),continueButtonVariant:te.danger,onConfirm:async()=>{const y=o?.filter(K=>K.name!==i?.name);try{await O.clientPolicies.updatePolicy({policies:y}),a(s("deleteClientPolicySuccess"),ee.success),h()}catch(K){t(s("deleteClientPolicyError"),K)}}});return o?e.jsxs(e.Fragment,{children:[e.jsx(V,{}),e.jsx(Q,{children:e.jsxs(es,{className:"kc-policies-config-section",children:[e.jsx(Ue,{children:e.jsx(Gt,{headingLevel:"h1",size:"md",children:s("policiesConfigType")})}),e.jsx(Ue,{children:e.jsx(lt,{isChecked:!r,name:"policiesView",onChange:()=>m(!1),label:s("policiesConfigTypes.formView"),id:"formView-policiesView","data-testid":"formView-policiesView",className:"kc-form-radio-btn pf-u-mr-sm pf-u-ml-sm"})}),e.jsx(Ue,{children:e.jsx(lt,{isChecked:r,name:"policiesView",onChange:()=>m(!0),label:s("policiesConfigTypes.jsonEditor"),id:"jsonEditor-policiesView","data-testid":"jsonEditor-policiesView",className:"kc-editor-radio-btn"})})]})}),e.jsx(Be,{}),r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pf-u-mt-md pf-u-ml-lg",children:e.jsx(Ct,{isLineNumbersVisible:!0,isLanguageLabelVisible:!0,isReadOnly:!1,code:p,language:kt.json,height:"30rem",onChange:j})}),e.jsxs("div",{className:"pf-u-mt-md",children:[e.jsx(E,{variant:te.primary,className:"pf-u-mr-md pf-u-ml-lg","data-testid":"jsonEditor-policies-saveBtn",onClick:P,children:s("save")}),e.jsx(E,{variant:te.link,"data-testid":"jsonEditor-reloadBtn",onClick:()=>{j(Je(d))},children:s("reload")})]})]}):e.jsx(Ve,{emptyState:e.jsx(Le,{message:s("realm-settings:noClientPolicies"),instructions:s("realm-settings:noClientPoliciesInstructions"),primaryActionText:s("realm-settings:createClientPolicy"),onPrimaryAction:()=>l(At({realm:n}))}),ariaLabelKey:"realm-settings:clientPolicies",searchPlaceholderKey:"realm-settings:clientPolicySearch",loader:N,toolbarItem:e.jsx(fe,{children:e.jsx(E,{id:"createPolicy",component:y=>e.jsx(he,{...y,to:At({realm:n})}),"data-testid":"createPolicy",children:s("createClientPolicy")})}),actions:[{title:s("common:delete"),onRowClick:y=>{F(),v(y)}}],columns:[{name:"name",cellRenderer:w},{name:"enabled",displayKey:"realm-settings:status",cellRenderer:y=>e.jsx(T,{clientPolicy:y})},{name:"description"}]},o.length)]}):e.jsx(Ee,{})};function oa(){const{t:s}=M("realm-settings"),{realm:a}=ae(),{addAlert:t,addError:n}=oe(),[l,r]=c.useState(),[m,o]=c.useState(),[b,i]=c.useState(),[v,g]=c.useState(!1),[C,p]=c.useState(),[j,d]=c.useState(0);je(()=>O.clientPolicies.listProfiles({includeGlobalProfiles:!0}),T=>{o(T.globalProfiles);const P=T.globalProfiles?.map(y=>({...y,global:!0})),F=T.profiles?.map(y=>({...y,global:!1})),V=P?.concat(F??[]);r(V||[]),p(JSON.stringify(V,null,2))},[j]);const u=async()=>l??[],h=T=>ps(T,"global"),[x,N]=ce({titleKey:s("deleteClientProfileConfirmTitle"),messageKey:s("deleteClientProfileConfirm",{profileName:b?.name}),continueButtonLabel:s("delete"),continueButtonVariant:te.danger,onConfirm:async()=>{const T=l?.filter(P=>P.name!==b?.name&&!P.global).map(P=>h(P));try{await O.clientPolicies.createProfiles({profiles:T,globalProfiles:m}),t(s("deleteClientSuccess"),ee.success),d(j+1)}catch(P){n(s("deleteClientError"),P)}}}),A=T=>e.jsxs(he,{to:hs({realm:a,profileName:T.name}),children:[T.name," ",T.global&&e.jsx(et,{color:"blue",children:s("global")})]},T.name);if(!l)return e.jsx(Ee,{});const w=async()=>{if(C)try{const T=JSON.parse(C),P=T.filter(V=>!V.global).map(V=>h(V)),F=T.filter(V=>V.global).map(V=>h(V));try{await O.clientPolicies.createProfiles({profiles:P,globalProfiles:F}),t(s("realm-settings:updateClientProfilesSuccess"),ee.success),d(j+1)}catch(V){n("realm-settings:updateClientProfilesError",V)}}catch{console.warn("Invalid json, ignoring value using {}")}};return e.jsxs(e.Fragment,{children:[e.jsx(N,{}),e.jsx(Q,{children:e.jsxs(es,{className:"kc-profiles-config-section",children:[e.jsx(Ue,{children:e.jsx(Gt,{headingLevel:"h1",size:"md",children:s("profilesConfigType")})}),e.jsx(Ue,{children:e.jsx(lt,{isChecked:!v,name:"profilesView",onChange:()=>g(!1),label:s("profilesConfigTypes.formView"),id:"formView-profilesView",className:"kc-form-radio-btn pf-u-mr-sm pf-u-ml-sm","data-testid":"formView-profilesView"})}),e.jsx(Ue,{children:e.jsx(lt,{isChecked:v,name:"profilesView",onChange:()=>g(!0),label:s("profilesConfigTypes.jsonEditor"),id:"jsonEditor-profilesView",className:"kc-editor-radio-btn","data-testid":"jsonEditor-profilesView"})})]})}),e.jsx(Be,{}),v?e.jsxs(f,{fieldId:"jsonEditor",children:[e.jsx("div",{className:"pf-u-mt-md pf-u-ml-lg",children:e.jsx(Ct,{isLineNumbersVisible:!0,isLanguageLabelVisible:!0,isReadOnly:!1,code:C,language:kt.json,height:"30rem",onChange:T=>{p(T??"")}})}),e.jsx(ge,{children:e.jsxs("div",{className:"pf-u-mt-md",children:[e.jsx(E,{variant:te.primary,className:"pf-u-mr-md pf-u-ml-lg",onClick:w,"data-testid":"jsonEditor-saveBtn",children:s("save")}),e.jsx(E,{variant:te.link,onClick:()=>{p(Je(l))},"data-testid":"jsonEditor-reloadBtn",children:s("reload")})]})})]}):e.jsx(Ve,{ariaLabelKey:"realm-settings:profiles",searchPlaceholderKey:"realm-settings:clientProfileSearch",loader:u,toolbarItem:e.jsx(fe,{children:e.jsx(E,{id:"createProfile",component:T=>e.jsx(he,{...T,to:us({realm:a,tab:"profiles"})}),"data-testid":"createProfile",children:s("createClientProfile")})}),isRowDisabled:T=>T.global,actions:[{title:s("common:delete"),onRowClick:T=>{i(T),x()}}],columns:[{name:"name",displayKey:s("common:name"),cellRenderer:A},{name:"description",displayKey:s("clientProfileDescription")}],emptyState:e.jsx(Le,{message:s("emptyClientProfiles"),instructions:s("emptyClientProfilesInstructions")})},l.length)]})}const ca=({realm:s,save:a})=>{const{t}=M("realm-settings"),{setValue:n,control:l,handleSubmit:r,formState:m}=pe(),o=ye({control:l,name:"offlineSessionMaxLifespanEnabled"}),b=()=>{Se(s,n)};return c.useEffect(b,[]),e.jsxs(Q,{variant:"light",children:[e.jsx(ie,{title:t("SSOSessionSettings"),className:"kc-sso-session-template",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",onSubmit:r(a),children:[e.jsx(f,{label:t("SSOSessionIdle"),fieldId:"SSOSessionIdle",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:ssoSessionIdle"),fieldLabelId:"realm-settings:SSOSessionIdle"}),children:e.jsx(L,{name:"ssoSessionIdleTimeout",defaultValue:s.ssoSessionIdleTimeout,control:l,render:({field:i})=>e.jsx(q,{className:"kc-sso-session-idle","data-testid":"sso-session-idle-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:t("SSOSessionMax"),fieldId:"SSOSessionMax",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:ssoSessionMax"),fieldLabelId:"realm-settings:SSOSessionMax"}),children:e.jsx(L,{name:"ssoSessionMaxLifespan",control:l,render:({field:i})=>e.jsx(q,{className:"kc-sso-session-max","data-testid":"sso-session-max-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:t("SSOSessionIdleRememberMe"),fieldId:"SSOSessionIdleRememberMe",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:ssoSessionIdleRememberMe"),fieldLabelId:"realm-settings:SSOSessionIdleRememberMe"}),children:e.jsx(L,{name:"ssoSessionIdleTimeoutRememberMe",control:l,render:({field:i})=>e.jsx(q,{className:"kc-sso-session-idle-remember-me","data-testid":"sso-session-idle-remember-me-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:t("SSOSessionMaxRememberMe"),fieldId:"SSOSessionMaxRememberMe",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:ssoSessionMaxRememberMe"),fieldLabelId:"realm-settings:SSOSessionMaxRememberMe"}),children:e.jsx(L,{name:"ssoSessionMaxLifespanRememberMe",control:l,render:({field:i})=>e.jsx(q,{className:"kc-sso-session-max-remember-me","data-testid":"sso-session-max-remember-me-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})})]})}),e.jsx(ie,{title:t("clientSessionSettings"),className:"kc-client-session-template",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:r(a),children:[e.jsx(f,{label:t("clientSessionIdle"),fieldId:"clientSessionIdle",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:clientSessionIdle"),fieldLabelId:"realm-settings:clientSessionIdle"}),children:e.jsx(L,{name:"clientSessionIdleTimeout",control:l,render:({field:i})=>e.jsx(q,{className:"kc-client-session-idle","data-testid":"client-session-idle-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:t("clientSessionMax"),fieldId:"clientSessionMax",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:clientSessionMax"),fieldLabelId:"realm-settings:clientSessionMax"}),children:e.jsx(L,{name:"clientSessionMaxLifespan",control:l,render:({field:i})=>e.jsx(q,{className:"kc-client-session-max","data-testid":"client-session-max-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})})]})}),e.jsx(ie,{title:t("offlineSessionSettings"),className:"kc-offline-session-template",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:r(a),children:[e.jsx(f,{label:t("offlineSessionIdle"),fieldId:"offlineSessionIdle",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:offlineSessionIdle"),fieldLabelId:"realm-settings:offlineSessionIdle"}),children:e.jsx(L,{name:"offlineSessionIdleTimeout",control:l,render:({field:i})=>e.jsx(q,{className:"kc-offline-session-idle","data-testid":"offline-session-idle-input","aria-label":"offline-session-idle-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{hasNoPaddingTop:!0,label:t("offlineSessionMaxLimited"),fieldId:"kc-offlineSessionMaxLimited",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:offlineSessionMaxLimited"),fieldLabelId:"realm-settings:offlineSessionMaxLimited"}),children:e.jsx(L,{name:"offlineSessionMaxLifespanEnabled",control:l,defaultValue:!1,render:({field:i})=>e.jsx(X,{id:"kc-offline-session-max","data-testid":"offline-session-max-switch","aria-label":t("offlineSessionMaxLimited"),label:t("common:enabled"),labelOff:t("common:disabled"),isChecked:i.value,onChange:i.onChange})})}),o&&e.jsx(f,{label:t("offlineSessionMax"),fieldId:"offlineSessionMax",id:"offline-session-max-label",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:offlineSessionMax"),fieldLabelId:"realm-settings:offlineSessionMax"}),children:e.jsx(L,{name:"offlineSessionMaxLifespan",control:l,render:({field:i})=>e.jsx(q,{className:"kc-offline-session-max","data-testid":"offline-session-max-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})})]})}),e.jsx(ie,{className:"kc-login-settings-template",title:t("loginSettings"),children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:r(a),children:[e.jsx(f,{label:t("loginTimeout"),id:"kc-login-timeout-label",fieldId:"offlineSessionIdle",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:loginTimeout"),fieldLabelId:"realm-settings:loginTimeout"}),children:e.jsx(L,{name:"accessCodeLifespanLogin",control:l,render:({field:i})=>e.jsx(q,{className:"kc-login-timeout","data-testid":"login-timeout-input","aria-label":"login-timeout-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:t("loginActionTimeout"),fieldId:"loginActionTimeout",id:"login-action-timeout-label",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:loginActionTimeout"),fieldLabelId:"realm-settings:loginActionTimeout"}),children:e.jsx(L,{name:"accessCodeLifespanUserAction",control:l,render:({field:i})=>e.jsx(q,{className:"kc-login-action-timeout","data-testid":"login-action-timeout-input",value:i.value,onChange:i.onChange,units:["minute","hour","day"]})})}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",type:"submit","data-testid":"sessions-tab-save",isDisabled:!m.isDirty,children:t("common:save")}),e.jsx(E,{variant:"link",onClick:b,children:t("common:revert")})]})]})})]})},da=({realm:s,save:a})=>{const{t}=M("realm-settings"),[n,l]=c.useState(!1),[r,m]=c.useState(!1),[o,b]=c.useState(!1),[i,v]=c.useState(!1),{control:g,handleSubmit:C,setValue:p}=pe(),j=Me().themes,d=()=>{Se(s,p)};return c.useEffect(d,[]),e.jsx(Q,{variant:"light",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:C(a),children:[e.jsx(f,{label:t("loginTheme"),fieldId:"kc-login-theme",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:loginTheme"),fieldLabelId:"realm-settings:loginTheme"}),children:e.jsx(L,{name:"loginTheme",control:g,defaultValue:"",render:({field:u})=>e.jsx(re,{toggleId:"kc-login-theme",onToggle:()=>l(!n),onSelect:(h,x)=>{u.onChange(x),l(!1)},selections:u.value,variant:ue.single,"aria-label":t("loginTheme"),isOpen:n,placeholderText:"Select a theme","data-testid":"select-login-theme",children:j.login.map((h,x)=>e.jsx(se,{selected:h.name===u.value,value:h.name,children:t(`${h.name}`)},`login-theme-${x}`))})})}),e.jsx(f,{label:t("accountTheme"),fieldId:"kc-account-theme",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:accountTheme"),fieldLabelId:"realm-settings:accountTheme"}),children:e.jsx(L,{name:"accountTheme",control:g,defaultValue:"",render:({field:u})=>e.jsx(re,{toggleId:"kc-account-theme",onToggle:()=>m(!r),onSelect:(h,x)=>{u.onChange(x),m(!1)},selections:u.value,variant:ue.single,"aria-label":t("accountTheme"),isOpen:r,placeholderText:"Select a theme","data-testid":"select-account-theme",children:j.account.map((h,x)=>e.jsx(se,{selected:h.name===u.value,value:h.name,children:t(`${h.name}`)},`account-theme-${x}`))})})}),e.jsx(f,{label:t("adminTheme"),fieldId:"kc-admin-ui-theme",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:adminUITheme"),fieldLabelId:"realm-settings:adminTheme"}),children:e.jsx(L,{name:"adminTheme",control:g,defaultValue:"",render:({field:u})=>e.jsx(re,{toggleId:"kc-admin-ui-theme",onToggle:()=>b(!o),onSelect:(h,x)=>{u.onChange(x),b(!1)},selections:u.value,variant:ue.single,"aria-label":t("adminUITheme"),isOpen:o,placeholderText:"Select a theme","data-testid":"select-admin-theme",children:j.admin.map((h,x)=>e.jsx(se,{selected:h.name===u.value,value:h.name,children:t(`${h.name}`)},`admin-theme-${x}`))})})}),e.jsx(f,{label:t("emailTheme"),fieldId:"kc-email-theme",labelIcon:e.jsx(k,{helpText:t("realm-settings-help:emailTheme"),fieldLabelId:"realm-settings:emailTheme"}),children:e.jsx(L,{name:"emailTheme",control:g,defaultValue:"",render:({field:u})=>e.jsx(re,{toggleId:"kc-email-theme",onToggle:()=>v(!i),onSelect:(h,x)=>{u.onChange(x),v(!1)},selections:u.value,variant:ue.single,"aria-label":t("emailTheme"),isOpen:i,placeholderText:"Select a theme","data-testid":"select-email-theme",children:j.email.map((h,x)=>e.jsx(se,{selected:h.name===u.value,value:h.name,children:t(`${h.name}`)},`email-theme-${x}`))})})}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",type:"submit","data-testid":"themes-tab-save",children:t("common:save")}),e.jsx(E,{variant:"link",onClick:d,children:t("common:revert")})]})]})})},ma=({realm:s,reset:a,save:t})=>{const{t:n}=M("realm-settings"),l=Me(),{whoAmI:r}=vt(),[m,o]=c.useState(!1),b=gs(l.providers.signature.providers),i=pe(),{setValue:v,control:g}=i,C=ye({control:g,name:"offlineSessionMaxLifespanEnabled",defaultValue:s.offlineSessionMaxLifespanEnabled}),p=ye({control:g,name:"ssoSessionIdleTimeout",defaultValue:36e3}),j=ye({control:g,name:"revokeRefreshToken",defaultValue:!1});return c.useEffect(()=>{Se(s,v)},[]),e.jsxs(Q,{variant:"light",children:[e.jsx(ie,{title:n("realm-settings:general"),className:"kc-sso-session-template",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",onSubmit:i.handleSubmit(t),children:[e.jsx(f,{label:n("defaultSigAlg"),fieldId:"kc-default-signature-algorithm",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:defaultSigAlg"),fieldLabelId:"realm-settings:algorithm"}),children:e.jsx(L,{name:"defaultSignatureAlgorithm",defaultValue:"RS256",control:i.control,render:({field:d})=>e.jsx(re,{toggleId:"kc-default-sig-alg",onToggle:()=>o(!m),onSelect:(u,h)=>{d.onChange(h.toString()),o(!1)},selections:[d.value?.toString()],variant:ue.single,"aria-label":n("defaultSigAlg"),isOpen:m,"data-testid":"select-default-sig-alg",children:b.map((u,h)=>e.jsx(se,{selected:u===d.value,value:u},`default-sig-alg-${h}`))})})}),e.jsx(f,{label:n("oAuthDeviceCodeLifespan"),fieldId:"oAuthDeviceCodeLifespan",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:oAuthDeviceCodeLifespan"),fieldLabelId:"realm-settings:oAuthDeviceCodeLifespan"}),children:e.jsx(L,{name:"oauth2DeviceCodeLifespan",defaultValue:0,control:i.control,render:({field:d})=>e.jsx(q,{id:"oAuthDeviceCodeLifespan","data-testid":"oAuthDeviceCodeLifespan",value:d.value||0,onChange:d.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:n("oAuthDevicePollingInterval"),fieldId:"oAuthDevicePollingInterval",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:oAuthDevicePollingInterval"),fieldLabelId:"realm-settings:oAuthDevicePollingInterval"}),children:e.jsx(L,{name:"oauth2DevicePollingInterval",defaultValue:0,control:i.control,render:({field:d})=>e.jsx(it,{id:"oAuthDevicePollingInterval",value:d.value,min:0,onPlus:()=>d.onChange(d.value||0+1),onMinus:()=>d.onChange(d.value||0-1),onChange:u=>{const h=Number(u.currentTarget.value);d.onChange(isNaN(h)?0:h)},placeholder:n("oAuthDevicePollingInterval")})})}),e.jsx(f,{label:n("shortVerificationUri"),fieldId:"shortVerificationUri",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:shortVerificationUriTooltip"),fieldLabelId:"realm-settings:shortVerificationUri"}),children:e.jsx(le,{id:"shortVerificationUri",placeholder:n("shortVerificationUri"),...i.register("attributes.shortVerificationUri")})})]})}),e.jsx(ie,{title:n("realm-settings:refreshTokens"),className:"kc-client-session-template",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:i.handleSubmit(t),children:[e.jsx(f,{hasNoPaddingTop:!0,label:n("revokeRefreshToken"),fieldId:"kc-revoke-refresh-token",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:revokeRefreshToken"),fieldLabelId:"realm-settings:revokeRefreshToken"}),children:e.jsx(L,{name:"revokeRefreshToken",control:i.control,defaultValue:!1,render:({field:d})=>e.jsx(X,{id:"kc-revoke-refresh-token","data-testid":"revoke-refresh-token-switch","aria-label":n("revokeRefreshToken"),label:n("common:enabled"),labelOff:n("common:disabled"),isChecked:d.value,onChange:d.onChange})})}),j&&e.jsx(f,{label:n("refreshTokenMaxReuse"),labelIcon:e.jsx(k,{helpText:n("realm-settings-help:refreshTokenMaxReuse"),fieldLabelId:"realm-settings:refreshTokenMaxReuse"}),fieldId:"refreshTokenMaxReuse",children:e.jsx(L,{name:"refreshTokenMaxReuse",defaultValue:0,control:i.control,render:({field:d})=>e.jsx(it,{type:"text",id:"refreshTokenMaxReuseMs",value:d.value,onPlus:()=>d.onChange(d.value+1),onMinus:()=>d.onChange(d.value-1),onChange:u=>d.onChange(Number(u.target.value))})})})]})}),e.jsx(ie,{title:n("realm-settings:accessTokens"),className:"kc-offline-session-template",children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:i.handleSubmit(t),children:[e.jsx(f,{label:n("accessTokenLifespan"),fieldId:"accessTokenLifespan",helperText:n("recommendedSsoTimeout",{time:$s(p,r.getLocale())}),labelIcon:e.jsx(k,{helpText:n("realm-settings-help:accessTokenLifespan"),fieldLabelId:"realm-settings:accessTokenLifespan"}),children:e.jsx(L,{name:"accessTokenLifespan",control:i.control,render:({field:d})=>e.jsx(q,{validated:d.value>p?"warning":"default",className:"kc-access-token-lifespan","data-testid":"access-token-lifespan-input","aria-label":"access-token-lifespan",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:n("accessTokenLifespanImplicitFlow"),fieldId:"accessTokenLifespanImplicitFlow",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:accessTokenLifespanImplicitFlow"),fieldLabelId:"realm-settings:accessTokenLifespanImplicitFlow"}),children:e.jsx(L,{name:"accessTokenLifespanForImplicitFlow",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-access-token-lifespan-implicit","data-testid":"access-token-lifespan-implicit-input",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:n("clientLoginTimeout"),fieldId:"clientLoginTimeout",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:clientLoginTimeout"),fieldLabelId:"realm-settings:clientLoginTimeout"}),children:e.jsx(L,{name:"accessCodeLifespan",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-client-login-timeout","data-testid":"client-login-timeout-input","aria-label":"client-login-timeout",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})}),C&&e.jsx(f,{label:n("offlineSessionMax"),fieldId:"offlineSessionMax",id:"offline-session-max-label",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:offlineSessionMax"),fieldLabelId:"realm-settings:offlineSessionMax"}),children:e.jsx(L,{name:"offlineSessionMaxLifespan",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-offline-session-max","data-testid":"offline-session-max-input",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})})]})}),e.jsx(ie,{className:"kc-login-settings-template",title:n("actionTokens"),children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"pf-u-mt-lg",onSubmit:i.handleSubmit(t),children:[e.jsx(f,{label:n("userInitiatedActionLifespan"),id:"kc-user-initiated-action-lifespan",fieldId:"userInitiatedActionLifespan",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:userInitiatedActionLifespan"),fieldLabelId:"realm-settings:userInitiatedActionLifespan"}),children:e.jsx(L,{name:"actionTokenGeneratedByUserLifespan",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-user-initiated-action-lifespan","data-testid":"user-initiated-action-lifespan","aria-label":"user-initiated-action-lifespan",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:n("defaultAdminInitiated"),fieldId:"defaultAdminInitiated",id:"default-admin-initiated-label",labelIcon:e.jsx(k,{helpText:n("realm-settings-help:defaultAdminInitiatedActionLifespan"),fieldLabelId:"realm-settings:defaultAdminInitiated"}),children:e.jsx(L,{name:"actionTokenGeneratedByAdminLifespan",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-default-admin-initiated","data-testid":"default-admin-initated-input","aria-label":"default-admin-initated-input",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})}),e.jsx(Re,{className:"kc-override-action-tokens-subtitle",component:zs.h1,children:n("overrideActionTokens")}),e.jsx(f,{label:n("emailVerification"),fieldId:"emailVerification",id:"email-verification",children:e.jsx(L,{name:"attributes.actionTokenGeneratedByUserLifespan-verify-email",defaultValue:"",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-email-verification","data-testid":"email-verification-input",value:d.value,onChange:u=>d.onChange(u.toString()),units:["minute","hour","day"]})})}),e.jsx(f,{label:n("idpAccountEmailVerification"),fieldId:"idpAccountEmailVerification",id:"idp-acct-label",children:e.jsx(L,{name:"attributes.actionTokenGeneratedByUserLifespan-idp-verify-account-via-email",defaultValue:"",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-idp-email-verification","data-testid":"idp-email-verification-input",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:n("forgotPassword"),fieldId:"forgotPassword",id:"forgot-password-label",children:e.jsx(L,{name:"attributes.actionTokenGeneratedByUserLifespan-reset-credentials",defaultValue:"",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-forgot-pw","data-testid":"forgot-pw-input",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})}),e.jsx(f,{label:n("executeActions"),fieldId:"executeActions",id:"execute-actions",children:e.jsx(L,{name:"attributes.actionTokenGeneratedByUserLifespan-execute-actions",defaultValue:"",control:i.control,render:({field:d})=>e.jsx(q,{className:"kc-execute-actions","data-testid":"execute-actions-input",value:d.value,onChange:d.onChange,units:["minute","hour","day"]})})}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",type:"submit","data-testid":"tokens-tab-save",isDisabled:!i.formState.isDirty,children:n("common:save")}),e.jsx(E,{variant:"link",onClick:a,children:n("common:revert")})]})]})})]})},ua=()=>{const{t:s}=M("realm-settings"),[a,t]=Ne(),[n,l]=Ne(),[r,m]=c.useState(),[o,b]=c.useState([]),[i,v]=c.useState(0),[g,C]=c.useState(0),p=()=>C(g+1),{realm:j}=ae(),{addAlert:d,addError:u}=oe(),{enabled:h}=fs();je(()=>O.realms.getDefaultGroups({realm:j}),P=>{m(P),v(i+1)},[g]);const x=()=>Promise.resolve(r),N=async()=>{try{await Promise.all(o.map(P=>O.realms.removeDefaultGroup({realm:j,id:P.id}))),d(s("groupRemove",{count:o.length}),ee.success),b([])}catch(P){u("realm-settings:groupRemoveError",P)}p()},A=async P=>{try{await Promise.all(P.map(F=>O.realms.addDefaultGroup({realm:j,id:F.id}))),d(s("defaultGroupAdded",{count:P.length}),ee.success)}catch(F){u("realm-settings:defaultGroupAddedError",F)}p()},[w,T]=ce({titleKey:s("removeConfirmTitle",{count:o.length}),messageKey:s("removeConfirm",{count:o.length}),continueButtonLabel:"common:delete",continueButtonVariant:te.danger,onConfirm:N});return r?e.jsxs(e.Fragment,{children:[e.jsx(T,{}),n&&e.jsx(Ws,{type:"selectMany",text:{title:"realm-settings:addDefaultGroups",ok:"common:add"},onConfirm:P=>{A(P||[]),l()},onClose:l}),h&&e.jsx(xs,{bodyContent:e.jsxs(rt,{i18nKey:"realm-settings-help:defaultGroups",children:[" ",e.jsx(he,{to:Dt({realm:j})}),"."]}),children:e.jsx(ot,{className:"keycloak__section_intro__help",style:{paddingLeft:"var(--pf-c-page__main-section--PaddingLeft)"},children:e.jsxs(Re,{children:[e.jsx(Js,{})," ",s("whatIsDefaultGroups")]})})}),e.jsx(Ve,{canSelectAll:!0,onSelect:P=>b([...P]),loader:x,ariaLabelKey:"realm-settings:defaultGroups",searchPlaceholderKey:"realm-settings:searchForGroups",toolbarItem:e.jsxs(e.Fragment,{children:[e.jsx(fe,{children:e.jsx(E,{"data-testid":"openCreateGroupModal",variant:"primary",onClick:l,children:s("addGroups")})}),e.jsx(fe,{children:e.jsx(bs,{toggle:e.jsx(js,{onToggle:t,isDisabled:o.length===0}),isOpen:a,isPlain:!0,dropdownItems:[e.jsx(tt,{component:"button",onClick:()=>{w(),t()},children:s("common:remove")},"action")]})})]}),actions:[{title:s("common:remove"),onRowClick:P=>(b([P]),w(),Promise.resolve(!1))}],columns:[{name:"name",displayKey:"groups:groupName"},{name:"path",displayKey:"groups:path"}],emptyState:e.jsx(Le,{hasIcon:!0,message:s("noDefaultGroups"),instructions:e.jsxs(rt,{i18nKey:"realm-settings:noDefaultGroupsInstructions",children:[" ",e.jsx(he,{className:"pf-u-font-weight-light",to:Dt({realm:j})}),"Add groups..."]}),primaryActionText:s("addGroups"),onPrimaryAction:l})},i)]}):e.jsx(Ee,{})},pa=()=>{const{t:s}=M("realm-settings"),[a,t]=c.useState(),[n,l]=c.useState(10),[r,m]=c.useState(0),{addAlert:o,addError:b}=oe(),{realm:i}=ae();if(je(()=>O.realms.findOne({realm:i}),t,[]),!a)return e.jsx(Ee,{});const v=async g=>{const C=g;try{await O.roles.createComposite({roleId:a.defaultRole.id,realm:i},C),m(r+1),o(s("roles:addAssociatedRolesSuccess"),ee.success)}catch(p){b("roles:addAssociatedRolesError",p)}};return e.jsxs(It,{activeKey:n,onSelect:(g,C)=>l(C),children:[e.jsx(U,{id:"roles",eventKey:10,title:e.jsx(H,{children:s("defaultRoles")}),children:e.jsx(qs,{name:a.defaultRole.name,id:a.defaultRole.id,type:"roles",isManager:!0,save:g=>v(g.map(C=>C.role))})},r),e.jsx(U,{id:"groups",eventKey:20,title:e.jsx(H,{children:s("defaultGroups")}),children:e.jsx(ua,{})})]})};function as({ariaLabelKey:s="userEventsRegistered",eventTypes:a,addTypes:t,onSelect:n,onDelete:l}){const{t:r}=M("realm-settings"),m=a.map(o=>({id:o,name:r(`eventTypes.${o}.name`),description:r(`eventTypes.${o}.description`)}));return e.jsx(Ve,{ariaLabelKey:s,searchPlaceholderKey:"realm-settings:searchEventType",loader:m,onSelect:n||void 0,canSelectAll:!!n,toolbarItem:t&&e.jsx(fe,{children:e.jsx(E,{id:"addTypes",onClick:t,"data-testid":"addTypes",children:r("addSavedTypes")})}),actions:l?[{title:r("common:remove"),onRowClick:l}]:[],columns:[{name:"name",displayKey:"realm-settings:eventType"},{name:"description",displayKey:"description"}],emptyState:e.jsx(Le,{message:r("emptyEvents"),instructions:r("emptyEventsInstructions")})})}const ha=({onConfirm:s,onClose:a,configured:t})=>{const{t:n}=M("realm-settings"),{enums:l}=Me(),[r,m]=c.useState([]);return e.jsx(Oe,{variant:He.medium,title:n("addTypes"),isOpen:!0,onClose:a,actions:[e.jsx(E,{"data-testid":"addEventTypeConfirm",variant:"primary",onClick:()=>s(r),children:n("common:add")},"confirm"),e.jsx(E,{"data-testid":"moveCancel",variant:"link",onClick:a,children:n("common:cancel")},"cancel")],children:e.jsx(as,{ariaLabelKey:"addTypes",onSelect:o=>m(o),eventTypes:l.eventType.filter(o=>!t.includes(o))})})},Ut=({type:s,form:a,reset:t,clear:n})=>{const{t:l}=M("realm-settings"),{control:r,watch:m,setValue:o,formState:{isDirty:b}}=a,i=s==="admin"?"adminEventsEnabled":"eventsEnabled",v=m(i),[g,C]=ce({titleKey:"realm-settings:events-disable-title",messageKey:"realm-settings:events-disable-confirm",continueButtonLabel:"realm-settings:confirm",onConfirm:()=>o(i,!1,{shouldDirty:!0})});return e.jsxs(e.Fragment,{children:[e.jsx(C,{}),e.jsx(f,{hasNoPaddingTop:!0,label:l("saveEvents"),fieldId:i,labelIcon:e.jsx(k,{helpText:l(`realm-settings-help:save-${s}-events`),fieldLabelId:"realm-settings:saveEvents"}),children:e.jsx(L,{name:i,defaultValue:!1,control:r,render:({field:p})=>e.jsx(X,{"data-testid":i,id:`${i}-switch`,label:l("common:on"),labelOff:l("common:off"),isChecked:p.value,onChange:j=>{j?p.onChange(j):g()},"aria-label":l("saveEvents")})})}),v&&e.jsxs(e.Fragment,{children:[s==="admin"&&e.jsx(f,{hasNoPaddingTop:!0,label:l("includeRepresentation"),fieldId:"includeRepresentation",labelIcon:e.jsx(k,{helpText:l("realm-settings-help:includeRepresentation"),fieldLabelId:"realm-settings:includeRepresentation"}),children:e.jsx(L,{name:"adminEventsDetailsEnabled",defaultValue:!1,control:r,render:({field:p})=>e.jsx(X,{"data-testid":"includeRepresentation",id:"includeRepresentation",label:l("common:on"),labelOff:l("common:off"),isChecked:p.value,onChange:p.onChange,"aria-label":l("includeRepresentation")})})}),e.jsx(f,{label:l("expiration"),fieldId:"expiration",labelIcon:e.jsx(k,{helpText:l("realm-settings-help:expiration"),fieldLabelId:"realm-settings:expiration"}),children:e.jsx(L,{name:s==="user"?"eventsExpiration":"adminEventsExpiration",defaultValue:"",control:r,render:({field:p})=>e.jsx(q,{value:p.value,onChange:p.onChange,units:["minute","hour","day"]})})})]}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",type:"submit",id:`save-${s}`,"data-testid":`save-${s}`,isDisabled:!b,children:l("common:save")}),e.jsx(E,{variant:"link",onClick:t,children:l("common:revert")})]}),e.jsx(Be,{}),e.jsx(f,{label:l(s==="user"?"clearUserEvents":"clearAdminEvents"),fieldId:`clear-${s}-events`,labelIcon:e.jsx(k,{helpText:l(`realm-settings-help:${s}-clearEvents`),fieldLabelId:`realm-settings:clear-${s}-events`}),children:e.jsx(E,{variant:"danger",id:`clear-${s}-events`,"data-testid":`clear-${s}-events`,onClick:()=>n(),children:l(s==="user"?"clearUserEvents":"clearAdminEvents")})})]})},ga=({form:s,reset:a})=>{const{t}=M("realm-settings"),{control:n,formState:{isDirty:l}}=s,[r,m]=c.useState(!1),b=Me().providers?.eventsListener.providers;return e.jsxs(e.Fragment,{children:[e.jsx(f,{hasNoPaddingTop:!0,label:t("eventListeners"),fieldId:"kc-eventListeners",labelIcon:e.jsx(k,{helpText:t("eventListenersHelpText"),fieldLabelId:"realm-settings:eventListeners"}),children:e.jsx(L,{name:"eventsListeners",defaultValue:"",control:n,render:({field:i})=>e.jsx(re,{name:"eventsListeners",className:"kc_eventListeners_select","data-testid":"eventListeners-select",chipGroupProps:{numChips:3,expandedText:t("common:hide"),collapsedText:t("common:showRemaining")},variant:ue.typeaheadMulti,typeAheadAriaLabel:"Select",onToggle:v=>m(v),selections:i.value,onSelect:(v,g)=>{const C=g.toString(),p=i.value.includes(C)?i.value.filter(j=>j!==C):[...i.value,C];i.onChange(p)},onClear:v=>{v.stopPropagation(),i.onChange([])},isOpen:r,"aria-labelledby":"eventsListeners",children:Object.keys(b).map(v=>e.jsx(se,{value:v},v))})})}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",type:"submit","data-testid":"saveEventListenerBtn",isDisabled:!l,children:t("common:save")}),e.jsx(E,{variant:"link","data-testid":"revertEventListenerBtn",onClick:a,children:t("common:revert")})]})]})},fa=({realm:s})=>{const{t:a}=M("realm-settings"),t=pe(),{setValue:n,handleSubmit:l}=t,[r,m]=c.useState(0),o=()=>m(new Date().getTime()),[b,i]=c.useState(0),v=()=>i(new Date().getTime()),[g,C]=c.useState("event"),[p,j]=c.useState(),[d,u]=c.useState(),[h,x]=c.useState(!1),{addAlert:N,addError:A}=oe(),{realm:w}=ae(),T=D=>{j(D),Se(D||{},n)},P=async D=>{u(D),F()},[F,V]=ce({titleKey:"realm-settings:deleteEvents",messageKey:"realm-settings:deleteEventsConfirm",continueButtonLabel:"common:clear",continueButtonVariant:te.danger,onConfirm:async()=>{try{switch(d){case"admin":await O.realms.clearAdminEvents({realm:w});break;case"user":await O.realms.clearEvents({realm:w});break}N(a(`${d}-events-cleared`),ee.success)}catch(D){A(`realm-settings:${d}-events-cleared-error`,D)}}});je(()=>O.realms.getConfigEvents({realm:w}),D=>{T({...D,adminEventsExpiration:s.attributes?.adminEventsExpiration}),v()},[r]);const y=async D=>{const z=!Wt(p?.eventsListeners,D.eventsListeners),{adminEventsExpiration:_,...de}=D;s.attributes?.adminEventsExpiration!==_&&await O.realms.update({realm:w},{...s,attributes:{...s.attributes||{},adminEventsExpiration:_}});try{await O.realms.updateConfigEvents({realm:w},de),T({...p,...de,adminEventsExpiration:_}),N(a(z?"realm-settings:saveEventListenersSuccess":"realm-settings:eventConfigSuccessfully"),ee.success)}catch(xe){A(a(z?"realm-settings:saveEventListenersError":"realm-settings:eventConfigError"),xe)}},K=async D=>{const z=D.map(de=>de.id),_=p.enabledEventTypes?.concat(z);await W(_)},W=async(D=[])=>{const z={...t.getValues(),enabledEventTypes:D};await y(z),x(!1),o()};return e.jsxs(e.Fragment,{children:[e.jsx(V,{}),h&&e.jsx(ha,{onConfirm:D=>K(D),configured:p?.enabledEventTypes||[],onClose:()=>x(!1)}),e.jsxs(It,{activeKey:g,onSelect:(D,z)=>C(z),children:[e.jsx(U,{eventKey:"event",title:e.jsx(H,{children:a("eventListeners")}),"data-testid":"rs-event-listeners-tab",children:e.jsx(Q,{children:e.jsx(Y,{role:"manage-events",isHorizontal:!0,onSubmit:l(y),children:e.jsx(ga,{form:t,reset:()=>T(p)})})})}),e.jsxs(U,{eventKey:"user",title:e.jsx(H,{children:a("userEventsSettings")}),"data-testid":"rs-events-tab",children:[e.jsx(Q,{children:e.jsx(Y,{role:"manage-events",isHorizontal:!0,onSubmit:l(y),children:e.jsx(Ut,{type:"user",form:t,reset:()=>T(p),clear:()=>P("user")})})}),e.jsx(Q,{children:e.jsx(as,{addTypes:()=>x(!0),eventTypes:p?.enabledEventTypes||[],onDelete:D=>{const z=p?.enabledEventTypes?.filter(_=>_!==D.id);W(z),j({...p,enabledEventTypes:z})}},b)})]}),e.jsx(U,{eventKey:"admin",title:e.jsx(H,{children:a("adminEventsSettings")}),"data-testid":"rs-admin-events-tab",children:e.jsx(Q,{children:e.jsx(Y,{role:"manage-events",isHorizontal:!0,onSubmit:l(y),children:e.jsx(Ut,{type:"admin",form:t,reset:()=>T(p),clear:()=>P("admin")})})})})]})]})},We=["ACTIVE","PASSIVE","DISABLED"],xa=({onFilter:s})=>{const{t:a}=M("realm-settings"),[t,n]=c.useState(We[0]),[l,r]=Ne();return e.jsx(re,{width:300,"data-testid":"filter-type-select",isOpen:l,className:"kc-filter-type-select",variant:ue.single,onToggle:r,toggleIcon:e.jsx(ts,{}),onSelect:(m,o)=>{const b=We.find(i=>i===o.toString())||We[0];n(b),s(b),r()},selections:t,children:We.map(m=>e.jsx(se,{"data-testid":`${m}-option`,value:m,children:a(`keysFilter.${m}`)},m))})},ba=({realmComponents:s})=>{const{t:a}=M("realm-settings"),t=Ge(),[n,l]=c.useState(""),[r,m]=c.useState(""),{realm:o}=ae(),[b,i]=c.useState(),[v,g]=c.useState();je(async()=>(await O.realms.getKeys({realm:o})).keys?.map(h=>{const x=s.find(N=>N.id===h.providerId);return{...h,provider:x?.name}}),i,[]);const[C,p]=ce({titleKey:a("publicKeys").slice(0,-1),messageKey:n,continueButtonLabel:"common:close",continueButtonVariant:te.primary,onConfirm:()=>Promise.resolve()}),[j,d]=ce({titleKey:a("certificate"),messageKey:r,continueButtonLabel:"common:close",continueButtonVariant:te.primary,onConfirm:()=>Promise.resolve()});return b?e.jsxs(Q,{variant:"light",padding:{default:"noPadding"},children:[e.jsx(p,{}),e.jsx(d,{}),e.jsx(Ve,{isNotCompact:!0,className:"kc-keys-list",loader:v||b,ariaLabelKey:"realm-settings:keysList",searchPlaceholderKey:"realm-settings:searchKey",searchTypeComponent:e.jsx(xa,{onFilter:u=>g(u!==We[0]?b.filter(({status:h})=>h===u):void 0)}),canSelectAll:!0,columns:[{name:"algorithm",displayKey:"realm-settings:algorithm",cellFormatters:[qe()],transforms:[Fe(15)]},{name:"type",displayKey:"type",cellFormatters:[qe()],transforms:[Fe(10)]},{name:"kid",displayKey:"realm-settings:kid",cellFormatters:[qe()],transforms:[Fe(10)]},{name:"use",displayKey:"realm-settings:use",cellFormatters:[qe()],transforms:[Fe(10)]},{name:"provider",displayKey:"realm-settings:provider",cellRenderer:({provider:u})=>u||"",cellFormatters:[qe()],transforms:[Fe(10)]},{name:"publicKeys",displayKey:"realm-settings:publicKeys",cellRenderer:({type:u,publicKey:h,certificate:x})=>u==="EC"?e.jsx(E,{onClick:()=>{C(),l(h)},variant:"secondary",id:"kc-public-key",children:a("publicKeys").slice(0,-1)}):u==="RSA"?e.jsxs("div",{className:"button-wrapper",children:[e.jsx(E,{onClick:()=>{C(),l(h)},variant:"secondary",id:h,children:a("publicKeys").slice(0,-1)}),e.jsx(E,{onClick:()=>{j(),m(x)},variant:"secondary",id:x,className:"kc-certificate",children:a("certificate")})]}):"",cellFormatters:[],transforms:[Fe(20)]}],isSearching:!!v,emptyState:e.jsx(Le,{hasIcon:!0,message:a("noKeys"),instructions:a("noKeysDescription"),primaryActionText:a("addProvider"),onPrimaryAction:()=>t(ht({realm:o,tab:"providers"}))})})]}):e.jsx(Ee,{})},ja=({providerType:s,onClose:a})=>{const{t}=M("realm-settings");return e.jsx(Oe,{className:"add-provider-modal",variant:He.medium,title:t("addProvider"),isOpen:!0,onClose:a,children:e.jsx(Xs,{providerType:s,onClose:a})})},va=({onConfirm:s,onClose:a})=>{const{t}=M("realm-settings"),l=Me().componentTypes?.[St]??[];return e.jsx(Oe,{variant:"medium",title:t("addProvider"),isOpen:!0,onClose:a,children:e.jsx(Xt,{onSelectDataListItem:r=>{s(r)},"aria-label":t("addPredefinedMappers"),isCompact:!0,children:l.map(r=>e.jsx(Yt,{"aria-label":r.id,id:r.id,children:e.jsx(Qt,{children:e.jsx(Zt,{dataListCells:[e.jsx(bt,{"data-testid":`option-${r.id}`,children:r.id},`name-${r.id}`),e.jsx(bt,{width:2,children:r.helpText},`helpText-${r.helpText}`)]})})},r.id))})})},ya=({realmComponents:s,refresh:a})=>{const{t}=M("realm-settings"),{addAlert:n,addError:l}=oe(),{realm:r}=ae(),[m,o]=c.useState(""),[b,i]=c.useState([]),[v,g]=Ne(),p=Me().componentTypes?.[St]??[],[j,d]=Ne(),[u,h]=c.useState(),[x,N]=c.useState(),A=c.useMemo(()=>s.map(y=>{const K=p.find(W=>y.providerId===W.id);return{...y,providerDescription:K?.helpText}}),[s]),[w,T]=ce({titleKey:"realm-settings:deleteProviderTitle",messageKey:t("deleteProviderConfirm",{provider:x?.name}),continueButtonLabel:"common:delete",continueButtonVariant:te.danger,onConfirm:async()=>{try{await O.components.del({id:x.id,realm:r}),a(),n(t("deleteProviderSuccess"),ee.success)}catch(y){l("realm-settings:deleteProviderError",y)}}}),P=()=>{if(m!==""){o(m);const y=A.filter(K=>K.name?.includes(m)||K.providerId?.includes(m));i(y)}else o(""),i(A)},F=y=>{y.key==="Enter"&&P()},V=y=>{o(y)};return e.jsxs(e.Fragment,{children:[j&&e.jsx(va,{onClose:()=>d(),onConfirm:y=>{g(),h(y),d()}}),v&&u&&e.jsx(ja,{providerType:u,onClose:()=>{g(),a()}}),e.jsx(T,{}),e.jsxs(Q,{variant:"light",padding:{default:"noPadding"},children:[e.jsx(Jt,{children:e.jsxs(Fs,{className:"providers-toolbar",children:[e.jsx(fe,{children:e.jsxs(vs,{children:[e.jsx(Ht,{name:"inputGroupName",id:"inputGroupName","data-testid":"provider-search-input",type:"search","aria-label":t("common:search"),placeholder:t("common:search"),onChange:V,onKeyDown:F}),e.jsx(E,{variant:te.control,"aria-label":t("common:search"),onClick:P,children:e.jsx(Bt,{})})]})}),e.jsx(fe,{children:e.jsx(E,{"data-testid":"addProviderDropdown",className:"add-provider-dropdown",onClick:()=>d(),children:t("addProvider")})})]})}),e.jsx(ss,{variant:"compact",className:"kc-draggable-table",keyField:"id",data:b.length===0?A:b,onDragFinish:async(y,K)=>{const W=A.map(D=>{const z={...D};return delete z.providerDescription,O.components.update({id:D.id},{...z,config:{priority:[(K.length-K.indexOf(D.id)+100).toString()]}})});try{await Promise.all(W),a(),n(t("saveProviderListSuccess"),ee.success)}catch(D){l("realm-settings:saveProviderError",D)}},columns:[{name:"name",displayKey:"realm-settings:name",cellRenderer:y=>e.jsx(he,{"data-testid":"provider-name-link",to:ys({realm:r,id:y.id,providerType:y.providerId}),children:y.name},y.name)},{name:"providerId",displayKey:"realm-settings:provider"},{name:"providerDescription",displayKey:"realm-settings:providerDescription"}],actions:[{title:t("common:delete"),onClick:(y,K,W)=>{N(W),w()}}]})]})]})},Sa=s=>[...s].sort((t,n)=>{const l=Number(t.config?.priority),r=Number(n.config?.priority);return(isNaN(r)?0:r)-(isNaN(l)?0:l)}),Ta=()=>{const{t:s}=M("realm-settings"),{realm:a}=ae(),[t,n]=c.useState(),[l,r]=c.useState(0),m=()=>{r(l+1)};je(()=>O.components.find({type:St,realm:a}),v=>n(Sa(v)),[l]);const o=v=>nt(ht({realm:a,tab:v})),b=o("list"),i=o("providers");return t?e.jsxs(at,{mountOnEnter:!0,unmountOnExit:!0,defaultLocation:ht({realm:a,tab:"list"}),children:[e.jsx(U,{id:"keysList","data-testid":"rs-keys-list-tab","aria-label":"keys-list-subtab",title:e.jsx(H,{children:s("keysList")}),...b,children:e.jsx(ba,{realmComponents:t})}),e.jsx(U,{id:"providers","data-testid":"rs-providers-tab","aria-label":"rs-providers-tab",title:e.jsx(H,{children:s("providers")}),...i,children:e.jsx(ya,{realmComponents:t,refresh:m})})]}):e.jsx(Ee,{})},ke=({fieldName:s,url:a})=>{const{t}=M("realm-settings"),{register:n}=zt(),l=s.substr(s.indexOf(".")+1);return e.jsx(f,{label:t(l),fieldId:l,labelIcon:e.jsx(k,{helpText:e.jsxs(rt,{i18nKey:`realm-settings-help:${l}`,children:["Default value prevents pages from being included",e.jsx(gt,{href:a,title:t("common:learnMore")})]}),fieldLabelId:l}),children:e.jsx(le,{id:l,...n(s)})})};const Ca=({realm:s,save:a})=>{const{t}=M(),n=pe(),{setValue:l,formState:{isDirty:r},handleSubmit:m}=n,o=()=>Se(s,l);return c.useEffect(o,[]),e.jsx(yt,{...n,children:e.jsxs(Y,{isHorizontal:!0,role:"manage-realm",className:"keycloak__security-defences__form",onSubmit:m(a),children:[e.jsx(ke,{fieldName:"browserSecurityHeaders.xFrameOptions",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),e.jsx(ke,{fieldName:"browserSecurityHeaders.contentSecurityPolicy",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy"}),e.jsx(ke,{fieldName:"browserSecurityHeaders.contentSecurityPolicyReportOnly",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only"}),e.jsx(ke,{fieldName:"browserSecurityHeaders.xContentTypeOptions",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options"}),e.jsx(ke,{fieldName:"browserSecurityHeaders.xRobotsTag",url:"https://developers.google.com/search/docs/advanced/robots/robots_meta_tag"}),e.jsx(ke,{fieldName:"browserSecurityHeaders.xXSSProtection",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection"}),e.jsx(ke,{fieldName:"browserSecurityHeaders.strictTransportSecurity",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security"}),e.jsx(ke,{fieldName:"browserSecurityHeaders.referrerPolicy",url:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy"}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",type:"submit","data-testid":"headers-form-tab-save",isDisabled:!r,children:t("common:save")}),e.jsx(E,{variant:"link",onClick:o,children:t("common:revert")})]})]})})},Ze=({name:s,style:a})=>{const{t}=M("realm-settings"),{control:n,formState:{errors:l}}=zt();return e.jsx(f,{style:a,label:t(s),fieldId:s,labelIcon:e.jsx(k,{helpText:t(`realm-settings-help:${s}`),fieldLabelId:`realm-settings:${s}`}),validated:l[s]?me.error:me.default,helperTextInvalid:t("common:required"),children:e.jsx(L,{name:s,defaultValue:"",control:n,rules:{required:!0},render:({field:r})=>e.jsx(q,{"data-testid":s,value:r.value,onChange:r.onChange,validated:l[s]?me.error:me.default})})})},ka=({realm:s,save:a})=>{const{t}=M("realm-settings"),n=pe(),{setValue:l,handleSubmit:r,control:m,formState:{isDirty:o}}=n,b=ye({control:m,name:"bruteForceProtected"}),i=ye({control:m,name:"permanentLockout"}),v=()=>Se(s,l);return c.useEffect(v,[]),e.jsx(yt,{...n,children:e.jsxs(Y,{role:"manage-realm",isHorizontal:!0,onSubmit:r(a),children:[e.jsx(f,{label:t("common:enabled"),fieldId:"bruteForceProtected",hasNoPaddingTop:!0,children:e.jsx(L,{name:"bruteForceProtected",defaultValue:!1,control:m,render:({field:g})=>e.jsx(X,{id:"bruteForceProtected",label:t("common:on"),labelOff:t("common:off"),isChecked:g.value,onChange:g.onChange})})}),b&&e.jsxs(e.Fragment,{children:[e.jsx(f,{label:t("failureFactor"),labelIcon:e.jsx(k,{helpText:t("realm-settings-help:failureFactor"),fieldLabelId:"realm-settings:failureFactor"}),fieldId:"failureFactor",children:e.jsx(L,{name:"failureFactor",defaultValue:0,control:m,rules:{required:!0},render:({field:g})=>e.jsx(it,{type:"text",id:"failureFactor",value:g.value,onPlus:()=>g.onChange(g.value+1),onMinus:()=>g.onChange(g.value-1),onChange:C=>g.onChange(Number(C.target.value))})})}),e.jsx(f,{label:t("permanentLockout"),fieldId:"permanentLockout",hasNoPaddingTop:!0,children:e.jsx(L,{name:"permanentLockout",defaultValue:!1,control:m,render:({field:g})=>e.jsx(X,{id:"permanentLockout",label:t("common:on"),labelOff:t("common:off"),isChecked:g.value,onChange:g.onChange,"aria-label":t("permanentLockout")})})}),!i&&e.jsxs(e.Fragment,{children:[e.jsx(Ze,{name:"waitIncrementSeconds"}),e.jsx(Ze,{name:"maxFailureWaitSeconds"}),e.jsx(Ze,{name:"maxDeltaTimeSeconds"})]}),e.jsx(f,{label:t("quickLoginCheckMilliSeconds"),labelIcon:e.jsx(k,{helpText:t("realm-settings-help:quickLoginCheckMilliSeconds"),fieldLabelId:"realm-settings:quickLoginCheckMilliSeconds"}),fieldId:"quickLoginCheckMilliSeconds",children:e.jsx(L,{name:"quickLoginCheckMilliSeconds",defaultValue:0,control:m,render:({field:g})=>e.jsx(it,{type:"text",id:"quickLoginCheckMilliSeconds",value:g.value,onPlus:()=>g.onChange(g.value+1),onMinus:()=>g.onChange(g.value-1),onChange:C=>g.onChange(Number(C.target.value))})})}),e.jsx(Ze,{name:"minimumQuickLoginWaitSeconds"})]}),e.jsxs(ge,{children:[e.jsx(E,{variant:"primary",type:"submit","data-testid":"brute-force-tab-save",isDisabled:!o,children:t("common:save")}),e.jsx(E,{variant:"link",onClick:v,children:t("common:revert")})]})]})})},Ia=({realm:s,save:a})=>{const{t}=M("realm-settings"),[n,l]=c.useState(10);return e.jsxs(It,{activeKey:n,onSelect:(r,m)=>l(m),children:[e.jsx(U,{id:"headers",eventKey:10,title:e.jsx(H,{children:t("headers")}),children:e.jsx(Q,{variant:"light",children:e.jsx(Ca,{realm:s,save:a})})}),e.jsx(U,{id:"bruteForce",eventKey:20,title:e.jsx(H,{children:t("bruteForceDetection")}),children:e.jsx(Q,{variant:"light",children:e.jsx(ka,{realm:s,save:a})})})]})},La=()=>{const{config:s,save:a}=Lt(),{t}=M("realm-settings"),n=Ge(),{realm:l}=ae(),[r,m]=c.useState(0),[o,b]=c.useState();c.useEffect(()=>m(p=>p+1),[s]);async function i(){return s?.groups??[]}const[v,g]=ce({titleKey:"realm-settings:deleteDialogTitle",children:e.jsxs(rt,{i18nKey:"realm-settings:deleteDialogDescription",children:[" ",e.jsx("strong",{children:{group:o?.name}}),"."]}),continueButtonLabel:"common:delete",continueButtonVariant:te.danger,onConfirm(){const p=(s?.groups??[]).filter(j=>j!==o);a({...s,groups:p},{successMessageKey:"realm-settings:deleteSuccess",errorMessageKey:"realm-settings:deleteAttributeGroupError"})}});function C(p){b(p),v()}return e.jsxs(Q,{variant:"light",className:"pf-u-p-0",children:[e.jsx(g,{}),e.jsx(Ve,{loader:i,ariaLabelKey:"realm-settings:tableTitle",toolbarItem:e.jsx(fe,{children:e.jsx(E,{component:p=>e.jsx(he,{...p,to:Rt({realm:l})}),children:t("createGroupText")})}),columns:[{name:"name",displayKey:"realm-settings:columnName",cellRenderer:p=>e.jsx(he,{to:Ss({realm:l,name:p.name}),children:p.name})},{name:"displayHeader",displayKey:"realm-settings:columnDisplayName"},{name:"displayDescription",displayKey:"realm-settings:columnDisplayDescription"}],actions:[{title:t("common:delete"),onRowClick:C}],emptyState:e.jsx(Le,{message:t("emptyStateMessage"),instructions:t("emptyStateInstructions"),primaryActionText:t("createGroupText"),onPrimaryAction:()=>n(Rt({realm:l}))})},r)]})},Ea=["username","email"],Pa=()=>{const{config:s,save:a}=Lt(),{realm:t}=ae(),{t:n}=M("realm-settings"),l=Ge(),[r,m]=c.useState("allGroups"),[o,b]=Ne(),[i,v]=c.useState(s?.attributes),[g,C]=c.useState(""),p=async(x,N)=>{const A=s?.attributes.findIndex(T=>T.name===x.name);let w={};w=s?.attributes[A],s?.attributes.splice(A,1),s?.attributes.splice(N,0,w),a({attributes:s?.attributes,groups:s?.groups},{successMessageKey:"realm-settings:updatedUserProfileSuccess",errorMessageKey:"realm-settings:updatedUserProfileError"})},j=s?.attributes.filter(x=>x.name!==g),[d,u]=ce({titleKey:n("deleteAttributeConfirmTitle"),messageKey:n("deleteAttributeConfirm",{attributeName:g}),continueButtonLabel:n("common:delete"),continueButtonVariant:te.danger,onConfirm:async()=>{a({attributes:j,groups:s?.groups},{successMessageKey:"realm-settings:deleteAttributeSuccess",errorMessageKey:"realm-settings:deleteAttributeError"}),C("")}}),h=x=>e.jsx(he,{to:Nt({realm:t,attributeName:x.name}),children:x.name},x.name);return s?.attributes?e.jsxs(e.Fragment,{children:[e.jsx(Jt,{children:e.jsxs(Us,{children:[e.jsx(fe,{children:e.jsx(re,{width:200,"data-testid":"filter-select",isOpen:o,variant:ue.single,onToggle:b,toggleIcon:e.jsx(ts,{}),onSelect:(x,N)=>{const A=N.toString();m(A),v(A==="allGroups"?s.attributes:s.attributes?.filter(w=>w.group===A)),b()},selections:r==="allGroups"?n(r):r,children:[e.jsx(se,{"data-testid":"all-groups",value:"allGroups",children:n("allGroups")},"allGroups"),...s.attributes.filter(x=>!!x.group).map(x=>e.jsx(se,{"data-testid":`${x.group}-option`,value:x.group},x.group))]})}),e.jsx(fe,{className:"kc-toolbar-attributesTab",children:e.jsx(E,{"data-testid":"createAttributeBtn",variant:"primary",component:x=>e.jsx(he,{...x,to:Ts({realm:t})}),children:n("createAttribute")})})]})}),e.jsx(Be,{}),e.jsx(u,{}),e.jsx(ss,{keyField:"name",onDragFinish:async(x,N)=>{const A=s.attributes.map(F=>F.name),w=N.indexOf(x),T=A.indexOf(x),P=s.attributes[T];P.name&&p(P,w)},actions:[{title:n("common:edit"),onClick:(x,N,A)=>{l(Nt({realm:t,attributeName:A.name}))}},{title:n("common:delete"),isActionable:({name:x})=>!Ea.includes(x),onClick:(x,N,A)=>{C(A.name),d()}}],columns:[{name:"name",displayKey:n("attributeName"),cellRenderer:h},{name:"displayName",displayKey:n("attributeDisplayName")},{name:"group",displayKey:n("attributeGroup")}],data:i||s.attributes})]}):e.jsx(Ee,{})},wa=()=>{const{config:s,save:a,isSaving:t}=Lt(),{t:n}=M(),{addError:l}=oe(),[r,m]=c.useState();c.useEffect(()=>o(),[s,r]);function o(){r?.setValue(s?Je(s):"")}async function b(){const i=r?.getValue();if(i)try{await a(JSON.parse(i))}catch(v){l("realm-settings:invalidJsonError",v);return}}return e.jsxs(Q,{variant:"light",children:[e.jsx(Ct,{language:kt.json,height:"30rem",onEditorDidMount:i=>m(i),isLanguageLabelVisible:!0}),e.jsx(Tt,{children:e.jsxs(ge,{children:[e.jsx(E,{"data-testid":"save",variant:"primary",onClick:b,isDisabled:t,children:n("common:save")}),e.jsx(E,{variant:"link",onClick:o,isDisabled:t,children:n("common:revert")})]})})]})},Aa=()=>{const{realm:s}=ae(),{t:a}=M("realm-settings"),t=m=>nt(Ot({realm:s,tab:m})),n=t("attributes"),l=t("attributes-group"),r=t("json-editor");return e.jsx(Ys,{children:e.jsxs(at,{defaultLocation:Ot({realm:s,tab:"attributes"}),mountOnEnter:!0,children:[e.jsx(U,{title:e.jsx(H,{children:a("attributes")}),"data-testid":"attributesTab",...n,children:e.jsx(Pa,{})}),e.jsx(U,{title:e.jsx(H,{children:a("attributesGroup")}),"data-testid":"attributesGroupTab",...l,children:e.jsx(La,{})}),e.jsx(U,{title:e.jsx(H,{children:a("jsonEditor")}),"data-testid":"jsonEditorTab",...r,children:e.jsx(wa,{})})]})})},Da=({save:s,onChange:a,value:t,realmName:n,refresh:l})=>{const{t:r}=M("realm-settings"),{refresh:m}=_t(),{addAlert:o,addError:b}=oe(),i=Ge(),[v,g]=c.useState(!1),[C,p]=c.useState(!1),[j,d]=ce({titleKey:"realm-settings:disableConfirmTitle",messageKey:"realm-settings:disableConfirm",continueButtonLabel:"common:disable",onConfirm:()=>{a(!t),s()}}),[u,h]=ce({titleKey:"realm-settings:deleteConfirmTitle",messageKey:"realm-settings:deleteConfirm",continueButtonLabel:"common:delete",continueButtonVariant:te.danger,onConfirm:async()=>{try{await O.realms.del({realm:n}),o(r("deletedSuccess"),ee.success),await m(),i(Cs({realm:ks.masterRealm})),l()}catch(x){b("realm-settings:deleteError",x)}}});return e.jsxs(e.Fragment,{children:[e.jsx(d,{}),e.jsx(h,{}),e.jsx(ia,{open:v,toggleDialog:()=>g(!v)}),e.jsx(la,{isOpen:C,onClose:()=>p(!1)}),e.jsx(ws,{titleKey:n,subKey:"realm-settings:realmSettingsExplain",helpUrl:Is.realmSettingsUrl,divider:!1,dropdownItems:[e.jsx(tt,{"data-testid":"openPartialImportModal",onClick:()=>{g(!0)},children:r("partialImport")},"import"),e.jsx(tt,{"data-testid":"openPartialExportModal",onClick:()=>p(!0),children:r("partialExport")},"export"),e.jsx(Ls,{},"separator"),e.jsx(tt,{onClick:u,children:r("common:delete")},"delete")],isEnabled:t,onToggle:x=>{x?(a(x),s()):j()}})]})},Ra=({realm:s,refresh:a})=>{const{t}=M("realm-settings"),{addAlert:n,addError:l}=oe(),{realm:r}=ae(),{refresh:m}=_t(),o=Ge(),b=$t(),{control:i,setValue:v,getValues:g}=pe({mode:"onChange"}),[C,p]=c.useState(0),j=()=>{p(C+1)},d=(G=s)=>{Se(G,v)};c.useEffect(d,[]);const u=async G=>{G=Es(G),G.attributes?.["acr.loa.map"]&&typeof G.attributes["acr.loa.map"]!="string"&&(G.attributes["acr.loa.map"]=JSON.stringify(Object.fromEntries(G.attributes["acr.loa.map"].filter(({key:Z})=>Z!=="").map(({key:Z,value:Te})=>[Z,Te]))));try{const Z={...s,...G,id:G.realm};Z.smtpServer?.port===""&&(Z.smtpServer={...Z.smtpServer,port:null}),await O.realms.update({realm:r},Z),n(t("saveSuccess"),ee.success)}catch(Z){l("realm-settings:saveError",Z)}r!==(G.realm||s.realm)&&(await m(),o(mt({realm:G.realm,tab:"general"}))),a()},h=G=>nt(mt({realm:r,tab:G})),x=h("general"),N=h("login"),A=h("email"),w=h("themes"),T=h("keys"),P=h("events"),F=h("localization"),V=h("security-defenses"),y=h("sessions"),K=h("tokens"),W=h("client-policies"),D=h("user-profile"),z=h("user-registration"),_=G=>nt(pt({realm:r,tab:G})),de=_("profiles"),xe=_("policies");return e.jsxs(e.Fragment,{children:[e.jsx(L,{name:"enabled",defaultValue:!0,control:i,render:({field:G})=>e.jsx(Da,{value:G.value,onChange:G.onChange,realmName:r,refresh:j,save:()=>u(g())})}),e.jsx(Q,{variant:"light",className:"pf-u-p-0",children:e.jsxs(at,{isBox:!0,mountOnEnter:!0,"aria-label":"realm-settings-tabs",defaultLocation:mt({realm:r,tab:"general"}),children:[e.jsx(U,{title:e.jsx(H,{children:t("general")}),"data-testid":"rs-general-tab",...x,children:e.jsx(ta,{realm:s,save:u})}),e.jsx(U,{title:e.jsx(H,{children:t("login")}),"data-testid":"rs-login-tab",...N,children:e.jsx(na,{refresh:a,realm:s})}),e.jsx(U,{title:e.jsx(H,{children:t("email")}),"data-testid":"rs-email-tab",...A,children:e.jsx(ea,{realm:s,save:u})}),e.jsx(U,{title:e.jsx(H,{children:t("themes")}),"data-testid":"rs-themes-tab",...w,children:e.jsx(da,{realm:s,save:u})}),e.jsx(U,{title:e.jsx(H,{children:t("realm-settings:keys")}),"data-testid":"rs-keys-tab",...T,children:e.jsx(Ta,{})}),e.jsx(U,{title:e.jsx(H,{children:t("events")}),"data-testid":"rs-realm-events-tab",...P,children:e.jsx(fa,{realm:s})}),e.jsx(U,{title:e.jsx(H,{children:t("localization")}),"data-testid":"rs-localization-tab",...F,children:e.jsx(aa,{refresh:a,save:u,realm:s},C)}),e.jsx(U,{title:e.jsx(H,{children:t("securityDefences")}),"data-testid":"rs-security-defenses-tab",...V,children:e.jsx(Ia,{realm:s,save:u})}),e.jsx(U,{title:e.jsx(H,{children:t("realm-settings:sessions")}),"data-testid":"rs-sessions-tab",...y,children:e.jsx(ca,{realm:s,save:u},C)}),e.jsx(U,{title:e.jsx(H,{children:t("realm-settings:tokens")}),"data-testid":"rs-tokens-tab",...K,children:e.jsx(ma,{save:u,realm:s})}),b(ft.ClientPolicies)&&e.jsx(U,{title:e.jsx(H,{children:t("realm-settings:clientPolicies")}),"data-testid":"rs-clientPolicies-tab",...W,children:e.jsxs(at,{mountOnEnter:!0,defaultLocation:pt({realm:r,tab:"profiles"}),children:[e.jsx(U,{id:"profiles","data-testid":"rs-policies-clientProfiles-tab","aria-label":t("clientProfilesSubTab"),title:e.jsx(H,{children:t("profiles")}),tooltip:e.jsx(Mt,{content:t("realm-settings:clientPoliciesProfilesHelpText")}),...de,children:e.jsx(oa,{})}),e.jsx(U,{id:"policies","data-testid":"rs-policies-clientPolicies-tab","aria-label":t("clientPoliciesSubTab"),...xe,title:e.jsx(H,{children:t("policies")}),tooltip:e.jsx(Mt,{content:t("realm-settings:clientPoliciesPoliciesHelpText")}),children:e.jsx(ra,{})})]})}),b(ft.DeclarativeUserProfile)&&s.attributes?.userProfileEnabled==="true"&&e.jsx(U,{title:e.jsx(H,{children:t("realm-settings:userProfile")}),"data-testid":"rs-user-profile-tab",...D,children:e.jsx(Aa,{})}),e.jsx(U,{title:e.jsx(H,{children:t("userRegistration")}),"data-testid":"rs-userRegistration-tab",...z,children:e.jsx(pa,{})})]})})]})};function Yn(){const{realm:s}=Ps(),[a,t]=c.useState(),[n,l]=c.useState(0),r=()=>{l(n+1),t(void 0)};return je(()=>O.realms.findOne({realm:s}),t,[n]),a?e.jsx(Ra,{realm:a,refresh:r}):e.jsx(Ee,{})}export{Yn as default};
//# sourceMappingURL=RealmSettingsSection-3cf71e46.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy