import{REDOCLY_TEAMS_RBAC as f}from"@redocly/config";function m(a,r,o){if(!r)throw new Error("Visitor required");if(a){a.description&&r(a,"description",o.location.absolutePointer+"/description",o);for(const t in a["x-enumDescriptions"])r(a["x-enumDescriptions"],t,o.location.absolutePointer+"/x-enumDescriptions/"+t,o)}}const b=/^[a-zA-Z0-9\s\-,.!\?:;'"()/]+$/,i=({outputRelativePath:a})=>{const r=function(t,c,p,u){const{node:n}=u.resolve(t[c]);if(!n||typeof n!="string"||n.match(b))return;const e=u.getVisitorData();e.markdocChunks=e.markdocChunks||[],e.markdocChunks.push({node:t,pointer:p,markdown:n,relativePath:a,key:c})};return{any:{leave(o,t){m(o,r,t)}},ref:{leave(o,t){m(o,r,t)}}}},s=()=>{const a={};return{Tag:{enter(r){r?.["x-rbac"]&&(a[String(r.name)]=r["x-rbac"])}},any:{leave(r,o){if((o.type.name==="Operation"||o.type.name==="Webhook")&&"tags"in r&&Array.isArray(r.tags))for(const t of r.tags)a[t]&&(r["x-rbac"]=r["x-rbac"]||a[t]);r?.["x-rbac"]&&(r[f]=r["x-rbac"],delete r["x-rbac"])}}}};function l(a,r){const o={id:"markdown",decorators:{oas2:{markdown:i,rbac:s},oas3:{markdown:i,rbac:s},async3:{markdown:i,rbac:s}}};return{...a,decorators:{"markdown/rbac":"on","markdown/markdown":{outputRelativePath:r},...a.decorators||{}},plugins:[...a.plugins||[],o]}}export{i as MarkdownParserDecorator,s as RbacDecorator,l as injectDecoratorIntoConfig};
