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