import{REDOCLY_TEAMS_RBAC as i}from"@redocly/config";import{combineUrls as l}from"@redocly/theme/core/utils";import{FEEDBACK_TYPES as c}from"../../../constants/common.js";import{normalizeRouteSlug as g}from"../../../utils/path/normalize-route-slug.js";function p(t){const{contentItems:r,sidebarItems:a,routeSlug:o,navItem:n}=t;let u=!0;for(const e of r){let s;switch(e.type){case"group":a.push({type:"separator",label:e.name,[i]:e[i]}),p({...t,contentItems:e.items,sidebarItems:a});break;case"tag":s=l(o,e.href);const m={type:"group",label:e.name,items:[],link:s,routeSlug:s,[i]:e[i]};a.push(m),p({routeSlug:o,contentItems:e.items,sidebarItems:m.items||[],navItem:n});break;case"operation":case"schema":case"mcp":e.isWebhook&&u&&(a.push({type:"separator",label:"Webhooks",variant:"secondary"}),u=!1),s=l(o,e.href),a.push({type:"link",label:e.name,httpVerb:e.type==="operation"?e.httpVerb:e.type,routeSlug:g(s),badges:e.badges,link:s,deprecated:e.deprecated,[i]:e[i]});break;case"section":if(e.depth===-1)continue;s=l(o,e.href);const b=e.href==="/",h={type:e.items.length?"group":"link",label:b&&n?.label?n.label:e.name,labelTranslationKey:n?.labelTranslationKey,routeSlug:s.split("#")[0]===o?o:g(s),link:s,items:[],...b&&n?.icon&&{icon:typeof n.icon=="object"?n.icon.srcSet:n.icon}};a.push(h),e.items.length&&p({routeSlug:o,contentItems:e.items,sidebarItems:h.items});break}}}function S({item:t}){return t.id===""?!0:t.type!=="group"||t.description!==""}const I=t=>(typeof t=="string"?t:t?.raw)?.replace(/\[(.*?)\][\[\(].*?[\]\)]/g,"$1")||"";function E(t){if(!t)return;let r="";const{type:a,settings:o}=t;switch(a){case c.RATING:r="Rate this section";break;case c.SENTIMENT:r="Was this section helpful?";break;case c.MOOD:r="Was this section helpful?";break;case c.COMMENT:r="Share your feedback about this section";break;case c.SCALE:r="How would you rate this section?";break}return{...t,settings:{...o,label:o?.label||r}}}function T(t){return(typeof t=="string"?t:t?.raw||"").replace(/<[^>]*>/g,"").replace(/```([\s\S]*?)```/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").trim()}export{p as convertOpenAPIDocs2Sidebar,E as normalizeFeedbackOptions,I as removeMarkdownLinks,S as shouldAddRoute,T as stripFormatting};
