"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[4487],{94487:(rt,y,e)=>{e.r(y),e.d(y,{TechDocsCustomHome:()=>ot});var a=e(31085),u=e(14041),j=e(73466),h=e(58837),I=e(51372),P=e(6820),p=e(72427),B=e(16009),R=e(67871);function H(){const t=(0,p.gf)(B.K),{loading:r,value:s}=(0,j.A)(async()=>{const{ownershipEntityRefs:o}=await t.getBackstageIdentity();return o},[]),n=(0,u.useMemo)(()=>{const o=new Set(s??[]);return l=>{const i=(0,R.t)(l,I.vv).map(P.U2);for(const c of i)if(o.has(c))return!0;return!1}},[s]);return{loading:r,isOwnedEntity:n}}var D=e(7341),b=e(86519),E=e(27125),O=e(82779),f=e(95768),W=e(9222),U=e(65461),v=e(10394),A=e(12398);const G=t=>(0,A.A)({root:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22em, 1fr))",gridAutoRows:"1fr",gridGap:t.spacing(2)}}),N=(0,h.A)(G,{name:"BackstageItemCardGrid"});function V(t){const{children:r,...s}=t,n=N(s);return(0,a.jsx)(v.A,{className:n.root,...s,children:r})}var S=e(72501);const z=t=>(0,A.A)({root:{color:t.palette.common.white,padding:t.spacing(2,2,3),backgroundImage:t.getPageTheme({themeId:"card"}).backgroundImage,backgroundPosition:0,backgroundSize:"inherit"}}),F=(0,h.A)(z,{name:"BackstageItemCardHeader"});function L(t){const{title:r,subtitle:s,children:n}=t,o=F(t);return(0,a.jsxs)(v.A,{className:o.root,children:[s&&(0,a.jsx)(S.A,{variant:"subtitle2",component:"h3",children:s}),r&&(0,a.jsx)(S.A,{variant:"h6",component:"h4",children:r}),n]})}var M=e(73896),$=e(40703),K=e(59469),Y=e(48653),J=e(57369);const Q=t=>{const{entities:r}=t,s=(0,W.S)(O.Oc),n=(0,p.gf)(U.U);return r?(0,a.jsx)(V,{"data-testid":"docs-explore",children:r?.length?r.map((o,l)=>(0,a.jsxs)($.A,{children:[(0,a.jsx)(J.A,{children:(0,a.jsx)(L,{title:o.metadata.title??o.metadata.name})}),(0,a.jsx)(Y.A,{children:o.metadata.description}),(0,a.jsx)(K.A,{children:(0,a.jsx)(M.z,{to:s({namespace:(0,f.V)(o.metadata.namespace??"default",n),kind:(0,f.V)(o.kind,n),name:(0,f.V)(o.metadata.name,n)}),color:"primary","data-testid":"read_docs",children:"Read Docs"})})]},l)):null}):null};var x=e(81859),X=e(59428),Z=e(27586),C=e(26280),k=e(68146),w=e(88640),q=e(77310),_=e(38605),tt=e(31653);const et=(0,h.A)(t=>({tabsWrapper:{gridArea:"pageSubheader",backgroundColor:t.palette.background.paper,paddingLeft:t.spacing(3),minWidth:0},defaultTab:{...t.typography.caption,padding:t.spacing(3,3),textTransform:"uppercase",fontWeight:t.typography.fontWeightBold,color:t.palette.text.secondary},selected:{color:t.palette.text.primary},tabRoot:{"&:hover":{backgroundColor:t.palette.background.default,color:t.palette.text.primary}}}),{name:"BackstageHeaderTabs"});function at(t){const{tabs:r,onChange:s,selectedIndex:n}=t,[o,l]=(0,u.useState)(n??0),i=et(),c=(0,u.useCallback)((m,d)=>{n===void 0&&l(d),s&&s(d)},[n,s]);return(0,u.useEffect)(()=>{n!==void 0&&l(n)},[n]),(0,a.jsx)(v.A,{className:i.tabsWrapper,children:(0,a.jsx)(tt.A,{indicatorColor:"primary",textColor:"inherit",variant:"scrollable",scrollButtons:"auto","aria-label":"tabs",onChange:c,value:o,children:r.map((m,d)=>(0,a.jsx)(_.A,{"data-testid":`header-tab-${d}`,label:m.label,value:d,className:i.defaultTab,classes:{selected:i.selected,root:i.tabRoot},...m.tabProps},m.id))})})}var T=e(86202);const st={DocsTable:E.o,DocsCardGrid:Q},nt=({config:t,entities:r,index:s})=>{const o=(0,h.A)({panelContainer:{marginBottom:"2rem",...t.panelCSS?t.panelCSS:{}}})(),{loading:l,isOwnedEntity:i}=H(),c=st[t.panelType],m=r.filter(d=>t.filterPredicate==="ownedByUser"?l?!1:i(d):typeof t.filterPredicate=="function"&&t.filterPredicate(d));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(X.d,{title:t.title,description:t.description,children:s===0?(0,a.jsx)(Z.Y,{children:"Discover documentation in your ecosystem."}):null}),(0,a.jsx)("div",{className:o.panelContainer,children:(0,a.jsx)(c,{"data-testid":"techdocs-custom-panel",entities:m})})]})},ot=t=>{const{tabsConfig:r}=t,[s,n]=(0,u.useState)(0),o=(0,p.gf)(D.v),{value:l,loading:i,error:c}=(0,j.A)(async()=>(await o.getEntities({filter:{[`metadata.annotations.${T.A}`]:b.c},fields:["apiVersion","kind","metadata","relations","spec.owner","spec.type"]})).items.filter(g=>!!g.metadata.annotations?.[T.A])),m=r[s];return i?(0,a.jsx)(x.S,{children:(0,a.jsx)(C.U,{children:(0,a.jsx)(k.k,{})})}):c?(0,a.jsx)(x.S,{children:(0,a.jsx)(C.U,{children:(0,a.jsx)(w.B,{severity:"error",title:"Could not load available documentation.",children:(0,a.jsx)(q.z,{language:"text",text:c.toString()})})})}):(0,a.jsxs)(x.S,{children:[(0,a.jsx)(at,{selectedIndex:s,onChange:d=>n(d),tabs:r.map(({label:d},g)=>({id:g.toString(),label:d}))}),(0,a.jsx)(C.U,{"data-testid":"techdocs-content",children:m.panels.map((d,g)=>(0,a.jsx)(nt,{config:d,entities:l||[],index:g},g))})]})}}}]);})();

//# sourceMappingURL=4487.bd329be6.chunk.js.map