"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[2924],{12924:function(et,j,a){a.r(j),a.d(j,{TechDocsCustomHome:function(){return at}});var e=a(52322),h=a(2784),Z=a(64279),p=a(79692),b=a(81269),D=a(88624),P=a(88797),H=a(16787),I=a(95573),g=a(51953),B=a(37321),y=a(44394),A=a(6542),v=a(62774),T=a(42494);const R=t=>(0,T.Z)({root:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22em, 1fr))",gridAutoRows:"1fr",gridGap:t.spacing(2)}}),E=(0,p.Z)(R,{name:"BackstageItemCardGrid"});function W(t){const{children:n,...o}=t,s=E(o);return(0,e.jsx)(v.Z,{className:s.root,...o,children:n})}var S=a(90436);const G=t=>(0,T.Z)({root:{color:t.palette.common.white,padding:t.spacing(2,2,3),backgroundImage:t.getPageTheme({themeId:"card"}).backgroundImage,backgroundPosition:0,backgroundSize:"inherit"}}),F=(0,p.Z)(G,{name:"BackstageItemCardHeader"});function N(t){const{title:n,subtitle:o,children:s}=t,d=F(t);return(0,e.jsxs)(v.Z,{className:d.root,children:[o&&(0,e.jsx)(S.Z,{variant:"subtitle2",component:"h3",children:o}),n&&(0,e.jsx)(S.Z,{variant:"h6",component:"h4",children:n}),s]})}var O=a(15929),V=a(94339),L=a(16111),z=a(24579),M=a(14503);const Q=t=>{const{entities:n}=t,o=(0,B.t)(I.Fw),s=(0,y.h_)(A.D);return n?(0,e.jsx)(W,{"data-testid":"docs-explore",children:n!=null&&n.length?n.map((d,c)=>{var l,i;return(0,e.jsxs)(V.Z,{children:[(0,e.jsx)(L.Z,{children:(0,e.jsx)(N,{title:(l=d.metadata.title)!==null&&l!==void 0?l:d.metadata.name})}),(0,e.jsx)(z.Z,{children:d.metadata.description}),(0,e.jsx)(M.Z,{children:(0,e.jsx)(O.Q,{to:o({namespace:(0,g.D)((i=d.metadata.namespace)!==null&&i!==void 0?i:"default",s),kind:(0,g.D)(d.kind,s),name:(0,g.D)(d.metadata.name,s)}),color:"primary","data-testid":"read_docs",children:"Read Docs"})})]},c)}):null}):null};var f=a(42081),U=a(30706),$=a(13788),C=a(42398),J=a(55015),K=a(538),X=a(9791),Y=a(6487),k=a(99152);const w=(0,p.Z)(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 q(t){const{tabs:n,onChange:o,selectedIndex:s}=t,[d,c]=(0,h.useState)(s!=null?s:0),l=w(),i=(0,h.useCallback)((u,r)=>{s===void 0&&c(r),o&&s!==r&&o(r)},[s,o]);return(0,h.useEffect)(()=>{s!==void 0&&c(s)},[s]),(0,e.jsx)(v.Z,{className:l.tabsWrapper,children:(0,e.jsx)(k.Z,{selectionFollowsFocus:!0,indicatorColor:"primary",textColor:"inherit",variant:"scrollable",scrollButtons:"auto","aria-label":"tabs",onChange:i,value:d,children:n.map((u,r)=>(0,h.createElement)(Y.Z,{...u.tabProps,"data-testid":`header-tab-${r}`,label:u.label,key:u.id,value:r,className:l.defaultTab,classes:{selected:l.selected,root:l.tabRoot}}))})})}const _={DocsTable:H.H,DocsCardGrid:Q},tt=({config:t,entities:n,index:o})=>{const d=(0,p.Z)({panelContainer:{marginBottom:"2rem",...t.panelCSS?t.panelCSS:{}}})(),{loading:c,isOwnedEntity:l}=(0,b.Z)(),i=_[t.panelType],u=n.filter(r=>t.filterPredicate==="ownedByUser"?c?!1:l(r):typeof t.filterPredicate=="function"&&t.filterPredicate(r));return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(U.y,{title:t.title,description:t.description,children:o===0?(0,e.jsx)($.q,{children:"Discover documentation in your ecosystem."}):null}),(0,e.jsx)("div",{className:d.panelContainer,children:(0,e.jsx)(i,{"data-testid":"techdocs-custom-panel",entities:u})})]})},at=t=>{const{tabsConfig:n}=t,[o,s]=(0,h.useState)(0),d=(0,y.h_)(D.A),{value:c,loading:l,error:i}=(0,Z.default)(async()=>(await d.getEntities({filter:{"metadata.annotations.backstage.io/techdocs-ref":P.n},fields:["apiVersion","kind","metadata","relations","spec.owner","spec.type"]})).items.filter(m=>{var x;return!!(!((x=m.metadata.annotations)===null||x===void 0)&&x["backstage.io/techdocs-ref"])})),u=n[o];return l?(0,e.jsx)(f.j,{children:(0,e.jsx)(C.V,{children:(0,e.jsx)(J.E,{})})}):i?(0,e.jsx)(f.j,{children:(0,e.jsx)(C.V,{children:(0,e.jsx)(K.G,{severity:"error",title:"Could not load available documentation.",children:(0,e.jsx)(X.O,{language:"text",text:i.toString()})})})}):(0,e.jsxs)(f.j,{children:[(0,e.jsx)(q,{selectedIndex:o,onChange:r=>s(r),tabs:n.map(({label:r},m)=>({id:m.toString(),label:r}))}),(0,e.jsx)(C.V,{"data-testid":"techdocs-content",children:u.panels.map((r,m)=>(0,e.jsx)(tt,{config:r,entities:c||[],index:m},m))})]})}}}]);})();

//# sourceMappingURL=2924.e8c74660.chunk.js.map