"use strict";(()=>{(self.webpackChunktechdocs_cli_embedded_app=self.webpackChunktechdocs_cli_embedded_app||[]).push([[2924],{12924:function(at,j,e){e.r(j),e.d(j,{TechDocsCustomHome:function(){return et}});var a=e(52322),h=e(2784),Z=e(64279),p=e(79692),b=e(81269),D=e(88624),P=e(88797),H=e(16787),I=e(95573),g=e(51953),B=e(37321),y=e(44394),A=e(6542),v=e(62774),T=e(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:s,...o}=t,n=E(o);return(0,a.jsx)(v.Z,{className:n.root,...o,children:s})}var S=e(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:s,subtitle:o,children:n}=t,d=F(t);return(0,a.jsxs)(v.Z,{className:d.root,children:[o&&(0,a.jsx)(S.Z,{variant:"subtitle2",component:"h3",children:o}),s&&(0,a.jsx)(S.Z,{variant:"h6",component:"h4",children:s}),n]})}var O=e(15929),V=e(94339),L=e(16111),z=e(24579),M=e(14503);const Q=t=>{const{entities:s}=t,o=(0,B.t)(I.Fw),n=(0,y.h_)(A.D);return s?(0,a.jsx)(W,{"data-testid":"docs-explore",children:s!=null&&s.length?s.map((d,c)=>{var l,i;return(0,a.jsxs)(V.Z,{children:[(0,a.jsx)(L.Z,{children:(0,a.jsx)(N,{title:(l=d.metadata.title)!==null&&l!==void 0?l:d.metadata.name})}),(0,a.jsx)(z.Z,{children:d.metadata.description}),(0,a.jsx)(M.Z,{children:(0,a.jsx)(O.Q,{to:o({namespace:(0,g.D)((i=d.metadata.namespace)!==null&&i!==void 0?i:"default",n),kind:(0,g.D)(d.kind,n),name:(0,g.D)(d.metadata.name,n)}),color:"primary","data-testid":"read_docs",children:"Read Docs"})})]},c)}):null}):null};var f=e(42081),U=e(30706),$=e(13788),x=e(42398),J=e(55015),K=e(538),X=e(9791),Y=e(6487),k=e(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:s,onChange:o,selectedIndex:n}=t,[d,c]=(0,h.useState)(n!=null?n:0),l=w(),i=(0,h.useCallback)((u,r)=>{n===void 0&&c(r),o&&o(r)},[n,o]);return(0,h.useEffect)(()=>{n!==void 0&&c(n)},[n]),(0,a.jsx)(v.Z,{className:l.tabsWrapper,children:(0,a.jsx)(k.Z,{selectionFollowsFocus:!0,indicatorColor:"primary",textColor:"inherit",variant:"scrollable",scrollButtons:"auto","aria-label":"tabs",onChange:i,value:d,children:s.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:s,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=s.filter(r=>t.filterPredicate==="ownedByUser"?c?!1:l(r):typeof t.filterPredicate=="function"&&t.filterPredicate(r));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(U.y,{title:t.title,description:t.description,children:o===0?(0,a.jsx)($.q,{children:"Discover documentation in your ecosystem."}):null}),(0,a.jsx)("div",{className:d.panelContainer,children:(0,a.jsx)(i,{"data-testid":"techdocs-custom-panel",entities:u})})]})},et=t=>{const{tabsConfig:s}=t,[o,n]=(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 C;return!!(!((C=m.metadata.annotations)===null||C===void 0)&&C["backstage.io/techdocs-ref"])})),u=s[o];return l?(0,a.jsx)(f.j,{children:(0,a.jsx)(x.V,{children:(0,a.jsx)(J.E,{})})}):i?(0,a.jsx)(f.j,{children:(0,a.jsx)(x.V,{children:(0,a.jsx)(K.G,{severity:"error",title:"Could not load available documentation.",children:(0,a.jsx)(X.O,{language:"text",text:i.toString()})})})}):(0,a.jsxs)(f.j,{children:[(0,a.jsx)(q,{selectedIndex:o,onChange:r=>n(r),tabs:s.map(({label:r},m)=>({id:m.toString(),label:r}))}),(0,a.jsx)(x.V,{"data-testid":"techdocs-content",children:u.panels.map((r,m)=>(0,a.jsx)(tt,{config:r,entities:c||[],index:m},m))})]})}}}]);})();

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