import{REDOCLY_TEAMS_RBAC as c}from"@redocly/config";import{DEFAULT_SSO_IDP_TITLE as b,DEV_LOGIN_SLUG as g,INVITE_SLUG as h,PUBLIC_RBAC_SCOPE_ITEM as f,UI_ACCESSIBLE_CONFIG_PROPS as D,CONFIG_FILE_NAME as p}from"../../../constants/common.js";import{isDevelopMode as P}from"../../utils/envs/is-develop-mode.js";import{getTemplatePath as s}from"./get-template-path.js";import{resolveLinksFromConfig as n}from"../nav-utils.js";import{resolveLogoConfig as _}from"./resolve-logo.js";import{extractTeamNames as E}from"./extract-team-names.js";import{resolveProductsConfig as F}from"./resolve-products-config.js";import{getExcludedFromLinkCheckerPatterns as y}from"../sidebars/utils.js";import{resolveEntitiesCatalogConfig as O}from"./resolve-catalog-entities.js";import{telemetryTraceStep as A}from"../../../cli/telemetry/helpers/trace-step.js";async function q(i){return{id:"Default Theme",async processContent(e){await A("build.plugin.default_theme",async()=>{const t=v(e),a=Object.keys(e.getConfig()?.ssoDirect||{}).length>0,o=e.createTemplate("invite",s("../../../../dist/client/app/pages/Invite/Invite.js"));if(e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:h,[c]:f,fsPath:h,templateId:o}),i.devLogin&&a){let r={frontmatter:{},seo:{title:"Login page"},authIdps:t.filter(m=>m.title!=b),rbac:{teams:E(e.getConfig().rbac)}};const l=e.createTemplate("dev-login",s("../../../../dist/client/app/pages/DevLogin/DevLogin.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:g,[c]:f,fsPath:g,templateId:l,getStaticData:async()=>({props:r})})}else if(t.length>1){let r={frontmatter:{},seo:{title:"Login page"},authIdps:t};const l=e.createTemplate("login",s("../../../../dist/client/app/pages/Login/Login.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:g,[c]:f,fsPath:g,templateId:l,getStaticData:async()=>({props:r})})}e.createTemplate("404",s("../../../../dist/client/app/pages/404/404.js")),e.createTemplate("403",s("../../../../dist/client/app/pages/403/403.js")),e.createTemplate("403OIDC",s("../../../../dist/client/app/pages/403/403OIDC.js")),P()&&e.createTemplate("compilation-error",s("../../../../dist/client/app/pages/CompilationError/CompilationError.js"))})},async afterRoutesCreated(e,t){const{contentDir:a,outdir:o}=e,r=e.getConfig(),{navbar:l,footer:m,userMenu:u,search:I,breadcrumbs:C,products:S}=r,L=Object.keys(r?.ssoDirect||{}).length>0,d=y(r),T={navFile:p,excludedFromLinkCheckerPatterns:d};e.setGlobalData({...j(r),navbar:await n(l,a,e,t,T),footer:await n(m,a,e,t,T),breadcrumbs:{...C,prefixItems:await n(C?.prefixItems||[],a,e,t,{navFile:p,excludedFromLinkCheckerPatterns:d})},userMenu:{...u,hide:u?.hide??!L,menu:await n(u?.items,a,e,t,{navFile:p,excludedFromLinkCheckerPatterns:d})},logo:await _(r.logo,p,o,t.fs),auth:{idpsInfo:v(e),devLogin:i.devLogin&&L},products:await F(S,e,t),search:{...I,suggestedPages:await n(I?.suggestedPages,a,e,t,{navFile:p,excludedFromLinkCheckerPatterns:d})},entitiesCatalog:await O(r.entitiesCatalog,p,o,t.fs),headScriptTags:void 0,linkTags:void 0,postBodyScriptTags:void 0,preBodyScriptTags:void 0})}}}function v(i){const e=i.getConfig().ssoDirect;return Object.entries(e||{}).map(([a,o])=>({idpId:a,type:o.type,title:o.title}))}function j(i){const e={};for(const t of D)i[t]&&(e[t]=i[t]);return e}export{q as defaultThemePlugin,j as pickUiAccessibleConfig};
