import{REDOCLY_TEAMS_RBAC as p,REDOCLY_ROUTE_RBAC as P}from"@redocly/config";import{resolveFrontmatterKeys as m}from"../resolve-frontmatter-keys.js";import{addLeadingSlash as L,removeTrailingSlash as R}from"../../../shared/utils.js";const u=new WeakMap;async function E(C,a,i,e,d){const o=await i.getConfig(),{ast:t,compoundHash:g,info:f}=await d.parseMarkdoc(C,i),n={...o.markdown?.editPage,...e.markdown?.editPage},b=a.fsPath!=null?await i.fs.getFileInfo(a.fsPath):null,y=!n?.hide&&n?.baseUrl?{to:R(n.baseUrl)+L(b?.realRelativePath||a.fsPath||"")}:void 0,h={...o.feedback,...e.feedback},l=e.feedback?{type:h.type||"sentiment",settings:h.settings||{},hide:e.feedback?.hide}:void 0;let k=u.get(t),s=k?.ast;(!s||k?.compoundHash!==g)&&(s=JSON.stringify(t),u.set(t,{ast:s,compoundHash:g}));const c=e?.seo?await m(e.seo,["image"],a.fsPath||"",d,i):void 0,w=f.tagList;Array.isArray(w)&&w.includes("code-walkthrough")&&(e.markdown=e.markdown||{},e.markdown.toc={hide:!0},e.footer=e.footer||{},e.footer={hide:!0});const r=e?.seo?.title||await a.getNavText?.();return{ast:s,frontmatter:await m({...e,...l!==void 0?{feedback:l}:{},...c!==void 0?{seo:c}:{}},o.markdown?.frontMatterKeysToResolve||["image","links"],a.fsPath||"",d,i),editPage:y,props:{metadata:{markdoc:{tagList:f.tagList}},seo:{...c,...r?{title:r}:{}}},[p]:a[p],[P]:a[P]}}export{E as markdownStaticDataLoader};
