import{REDOCLY_TEAMS_RBAC as i}from"@redocly/config";import{combineUrls as p}from"@redocly/theme/core/utils";import{FEEDBACK_TYPES as c}from"../../../constants/index.js";import{normalizeRouteSlug as g}from"../../../shared/utils.js";function l(t){const{contentItems:r,sidebarItems:s,routeSlug:o,navItem:n}=t;let u=!0;for(const e of r){let a;switch(e.type){case"group":s.push({type:"separator",label:e.name,[i]:e[i]}),l({...t,contentItems:e.items,sidebarItems:s});break;case"tag":a=p(o,e.href);const m={type:"group",label:e.name,items:[],link:a,routeSlug:a,[i]:e[i]};s.push(m),l({routeSlug:o,contentItems:e.items,sidebarItems:m.items||[],navItem:n});break;case"operation":case"schema":e.isWebhook&&u&&(s.push({type:"separator",label:"Webhooks",variant:"secondary"}),u=!1),a=p(o,e.href),s.push({type:"link",label:e.name,httpVerb:e.type==="schema"?"schema":e.httpVerb,routeSlug:g(a),badges:e.badges,link:a,deprecated:e.deprecated,[i]:e[i]});break;case"section":if(e.depth===-1)continue;a=p(o,e.href);const b=e.href==="/",h={type:e.items.length?"group":"link",label:b&&n?.label?n.label:e.name,routeSlug:a.split("#")[0]===o?o:g(a),link:a,items:[],...b&&n?.icon&&{icon:typeof n.icon=="object"?n.icon.srcSet:n.icon}};s.push(h),e.items.length&&l({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:s,settings:o}=t;switch(s){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 w(t){const r=typeof t=="string"?t:t?.raw||"";return[/<[^>]*>/g,/```[\s\S]*?```/g,/`([^`]+)`/g,/\*\*(.*?)\*\*/g,/\*(.*?)\*/g].reduce((s,o)=>s.replace(o,""),r)}export{l as convertOpenAPIDocs2Sidebar,E as normalizeFeedbackOptions,I as removeMarkdownLinks,S as shouldAddRoute,w as stripFormatting};
