import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as m}from"@redocly/config";import{SEARCH_DOCUMENT_METADATA_KEY as _}from"../../../constants/plugins/search.js";import{canAccessFeature as A}from"../../../utils/entitlements/can-access-feature.js";import{normalizeFrontmatterKeywords as E}from"../../helpers/normalize-frontmatter-keywords.js";import{extractDocumentSearchFacets as x,setDocumentSearchFacets as F}from"./search-facets.js";function O(e,r,i,h){return async(s,R,C)=>{if(!e||e?.excludeFromSearch)return[];const o=e.search?.title||e.seo?.title||e.title,a=e.search?.description||e.seo?.description||e.description;if(!o&&!a)return[];const n=s.slug||r,{result:c}=E(e?.search?.keywords),p=s.metadata||{},d=x(p,i);F(d,i,h);const D=A("rbac")?e?.rbac:void 0,u={id:n,url:n,title:o||r,text:a||"",path:[],facets:d,[m]:D||s[m],[l]:s[l]};if(c){const t={curated:!0};c.includes&&(t.includes=c.includes),c.excludes&&(t.excludes=c.excludes),u[_]=t}return[u]}}export{O as searchResolver};
