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

//# sourceMappingURL=4109.703c7257.chunk.js.map