"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[1552],{41552:function(rt,j,e){e.r(j),e.d(j,{TechDocsCustomHome:function(){return ot}});var a=e(77e3),m=e(85668),S=e(35848),h=e(40476),P=e(89576),b=e(83856),p=e(15940),E=e(89640),R=e(21148);function B(){const t=(0,p.yk)(E.S),{loading:o,value:n}=(0,S.default)(async()=>{const{ownershipEntityRefs:r}=await t.getBackstageIdentity();return r},[]),s=(0,m.useMemo)(()=>{const r=new Set(n!=null?n:[]);return i=>{const l=(0,R.q)(i,P.ag).map(b.gH);for(const c of l)if(r.has(c))return!0;return!1}},[n]);return{loading:o,isOwnedEntity:s}}var H=e(33776),A=e(52300),D=e(33748),W=e(94388),v=e(91720),O=e(98832),G=e(36336),f=e(33584),T=e(93644);const N=t=>(0,T.c)({root:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22em, 1fr))",gridAutoRows:"1fr",gridGap:t.spacing(2)}}),M=(0,h.c)(N,{name:"BackstageItemCardGrid"});function F(t){const{children:o,...n}=t,s=M(n);return(0,a.jsx)(f.c,{className:s.root,...n,children:o})}var I=e(94700);const L=t=>(0,T.c)({root:{color:t.palette.common.white,padding:t.spacing(2,2,3),backgroundImage:t.getPageTheme({themeId:"card"}).backgroundImage,backgroundPosition:0,backgroundSize:"inherit"}}),U=(0,h.c)(L,{name:"BackstageItemCardHeader"});function z(t){const{title:o,subtitle:n,children:s}=t,r=U(t);return(0,a.jsxs)(f.c,{className:r.root,children:[n&&(0,a.jsx)(I.c,{variant:"subtitle2",component:"h3",children:n}),o&&(0,a.jsx)(I.c,{variant:"h6",component:"h4",children:o}),s]})}var V=e(692),Y=e(42704),$=e(96196),J=e(43152),K=e(8084);const Q=t=>{const{entities:o}=t,n=(0,O.M)(W.uE),s=(0,p.yk)(G.c);return o?(0,a.jsx)(F,{"data-testid":"docs-explore",children:o!=null&&o.length?o.map((r,i)=>{var l,c;return(0,a.jsxs)(Y.c,{children:[(0,a.jsx)($.c,{children:(0,a.jsx)(z,{title:(l=r.metadata.title)!==null&&l!==void 0?l:r.metadata.name})}),(0,a.jsx)(J.c,{children:r.metadata.description}),(0,a.jsx)(K.c,{children:(0,a.jsx)(V.E,{to:n({namespace:(0,v.o)((c=r.metadata.namespace)!==null&&c!==void 0?c:"default",s),kind:(0,v.o)(r.kind,s),name:(0,v.o)(r.metadata.name,s)}),color:"primary","data-testid":"read_docs",children:"Read Docs"})})]},i)}):null}):null};var y=e(54720),X=e(6080),Z=e(19e3),x=e(46160),k=e(12824),w=e(66972),q=e(43932),_=e(62984),tt=e(95394);const et=(0,h.c)(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:o,onChange:n,selectedIndex:s}=t,[r,i]=(0,m.useState)(s!=null?s:0),l=et(),c=(0,m.useCallback)((u,d)=>{s===void 0&&i(d),n&&n(d)},[s,n]);return(0,m.useEffect)(()=>{s!==void 0&&i(s)},[s]),(0,a.jsx)(f.c,{className:l.tabsWrapper,children:(0,a.jsx)(tt.c,{indicatorColor:"primary",textColor:"inherit",variant:"scrollable",scrollButtons:"auto","aria-label":"tabs",onChange:c,value:r,children:o.map((u,d)=>(0,m.createElement)(_.c,{...u.tabProps,"data-testid":`header-tab-${d}`,label:u.label,key:u.id,value:d,className:l.defaultTab,classes:{selected:l.selected,root:l.tabRoot}}))})})}const nt={DocsTable:D.m,DocsCardGrid:Q},st=({config:t,entities:o,index:n})=>{const r=(0,h.c)({panelContainer:{marginBottom:"2rem",...t.panelCSS?t.panelCSS:{}}})(),{loading:i,isOwnedEntity:l}=B(),c=nt[t.panelType],u=o.filter(d=>t.filterPredicate==="ownedByUser"?i?!1:l(d):typeof t.filterPredicate=="function"&&t.filterPredicate(d));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(X.Y,{title:t.title,description:t.description,children:n===0?(0,a.jsx)(Z.i,{children:"Discover documentation in your ecosystem."}):null}),(0,a.jsx)("div",{className:r.panelContainer,children:(0,a.jsx)(c,{"data-testid":"techdocs-custom-panel",entities:u})})]})},ot=t=>{const{tabsConfig:o}=t,[n,s]=(0,m.useState)(0),r=(0,p.yk)(H.s),{value:i,loading:l,error:c}=(0,S.default)(async()=>(await r.getEntities({filter:{"metadata.annotations.backstage.io/techdocs-ref":A.q},fields:["apiVersion","kind","metadata","relations","spec.owner","spec.type"]})).items.filter(g=>{var C;return!!(!((C=g.metadata.annotations)===null||C===void 0)&&C["backstage.io/techdocs-ref"])})),u=o[n];return l?(0,a.jsx)(y.c,{children:(0,a.jsx)(x.k,{children:(0,a.jsx)(k.b,{})})}):c?(0,a.jsx)(y.c,{children:(0,a.jsx)(x.k,{children:(0,a.jsx)(w.E,{severity:"error",title:"Could not load available documentation.",children:(0,a.jsx)(q.U,{language:"text",text:c.toString()})})})}):(0,a.jsxs)(y.c,{children:[(0,a.jsx)(at,{selectedIndex:n,onChange:d=>s(d),tabs:o.map(({label:d},g)=>({id:g.toString(),label:d}))}),(0,a.jsx)(x.k,{"data-testid":"techdocs-content",children:u.panels.map((d,g)=>(0,a.jsx)(st,{config:d,entities:i||[],index:g},g))})]})}}}]);})();

//# sourceMappingURL=1552.1512a288.chunk.js.map