@spotify/backstage-plugin-soundcheck 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +16 -3
- package/config.d.ts +9 -0
- package/dist/esm/{EntitySoundcheckContent-61aee236.esm.js → EntitySoundcheckContent-aecd6416.esm.js} +2 -2
- package/dist/esm/OverviewPageContent-433c8dc6.esm.js +2 -0
- package/dist/esm/{RefetchingIndicator-e114bc04.esm.js → RefetchingIndicator-3707a744.esm.js} +2 -2
- package/dist/esm/{index-e3458e3b.esm.js → index-01c3a9f5.esm.js} +2 -2
- package/dist/esm/index-29e115b6.esm.js +2 -0
- package/dist/esm/index-6e141f2f.esm.js +429 -0
- package/dist/esm/{index-7f1f7ff1.esm.js → index-a224cc6f.esm.js} +2 -2
- package/dist/index.esm.js +1 -1
- package/package.json +18 -16
- package/dist/esm/OverviewPageContent-31025374.esm.js +0 -2
- package/dist/esm/index-0208f72c.esm.js +0 -2
- package/dist/esm/index-7b347cd4.esm.js +0 -388
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @spotify/backstage-plugin-soundcheck
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added entity type/lifecycle/kind filters to Soundcheck's Tech Health page.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Resolved an issue with Check filters generated via UI not applying to parent Tracks.
|
|
12
|
+
|
|
13
|
+
Resolved an edge case where the displayed entity counts on the Overview page tabs could be mismatched.
|
|
14
|
+
|
|
15
|
+
- Added grid view for Checks, Tracks, Entities and Teams tabs on Tech Health page.
|
|
16
|
+
- Souncheck's overview table will now show entities by title rather than name if title is present.
|
|
17
|
+
- Added .csv export functionality to the Soundcheck Tech Health pages.
|
|
18
|
+
- Added "Export to CSV" buttons for graphs on Tech Health Summary Page.
|
|
19
|
+
- Updated default page pagination to 10 and enabled pagination options on the Soundcheck Checks and Tracks pages.
|
|
20
|
+
- Resolved an issue that could prevent newly created tracks from displaying on the Tech Health page and recently deleted tracks are now immediately removed.
|
|
21
|
+
- Upgraded Backstage to v1.19.0
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @spotify/backstage-plugin-soundcheck-common@0.9.0
|
|
24
|
+
- @spotify/backstage-plugin-core@0.5.7
|
|
25
|
+
|
|
3
26
|
## 0.8.2
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ Together, they show you how any given software component is performing against y
|
|
|
45
45
|
- [Aggregations](#aggregations)
|
|
46
46
|
- [Filters](#filters-1)
|
|
47
47
|
- [Trends](#trends)
|
|
48
|
+
- [Data Export](#data-export)
|
|
48
49
|
<!-- TOC -->
|
|
49
50
|
|
|
50
51
|
## Prerequisites
|
|
@@ -331,15 +332,21 @@ The check result and certification data can be aggregated by:
|
|
|
331
332
|
The data can be filtered by the following categories:
|
|
332
333
|
|
|
333
334
|
- `Entities`: check and certification pass rates will be calculated only for selected entities.
|
|
334
|
-
- `Entity
|
|
335
|
+
- `Entity Kind`: check and certification pass rates will be calculated only for the entities
|
|
336
|
+
with selected kinds.
|
|
337
|
+
- `Entity Type`: check and certification pass rates will be calculated only for the entities
|
|
338
|
+
with selected types.
|
|
339
|
+
- `Entity Owner`: check and certification pass rates will be calculated only for the entities
|
|
335
340
|
owned by selected teams and their child teams recursively.
|
|
341
|
+
- `Entity Lifecycle`: check and certification pass rates will be calculated only for the entities
|
|
342
|
+
with selected lifecycles.
|
|
336
343
|
- `Tracks`: check and certification pass rates will be calculated only for selected tracks and
|
|
337
344
|
checks included in these tracks.
|
|
338
|
-
- `Track
|
|
345
|
+
- `Track Level`: check and certification pass rates will be calculated only for selected track
|
|
339
346
|
levels and checks included in these track levels.
|
|
340
347
|
- `Checks`: check pass rates will be calculated only for selected checks. Certification pass rates
|
|
341
348
|
will be calculated only for track levels that include these checks.
|
|
342
|
-
- `Check
|
|
349
|
+
- `Check Owner`: check pass rates will be calculated only for the checks owned by selected teams.
|
|
343
350
|
Certification pass rates will be calculated only for track levels that include checks owned by
|
|
344
351
|
selected teams.
|
|
345
352
|
|
|
@@ -356,3 +363,9 @@ Check result history and certification history must be enabled in order to be ab
|
|
|
356
363
|
|
|
357
364
|
- [Enabling check result history](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#enabling-check-result-history)
|
|
358
365
|
- [Enabling certification history](https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#enabling-certification-history)
|
|
366
|
+
|
|
367
|
+
### Data Export
|
|
368
|
+
|
|
369
|
+
The aggregated data from each Tech Health Page tab can be exported into a Comma-Separated Values (CSV)
|
|
370
|
+
file format. The CSV format is widely supported and can be easily imported into various data analysis
|
|
371
|
+
tools, spreadsheets, and databases.
|
package/config.d.ts
CHANGED
package/dist/esm/{EntitySoundcheckContent-61aee236.esm.js → EntitySoundcheckContent-aecd6416.esm.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{useState as W,useEffect as $}from"react";import{Link as O,useParams as Q,Routes as j,Route as k,Navigate as I}from"react-router-dom";import{makeStyles as p,Typography as f,Box as U,Tab as L,Tabs as T,Paper as V,Divider as Y}from"@material-ui/core";import{SpotifyLicenseBanner as q}from"@spotify/backstage-plugin-core";import{useEntity as u}from"@backstage/plugin-catalog-react";import{R as G}from"./RefetchingIndicator-
|
|
2
|
-
//# sourceMappingURL=EntitySoundcheckContent-
|
|
1
|
+
import e,{useState as W,useEffect as $}from"react";import{Link as O,useParams as Q,Routes as j,Route as k,Navigate as I}from"react-router-dom";import{makeStyles as p,Typography as f,Box as U,Tab as L,Tabs as T,Paper as V,Divider as Y}from"@material-ui/core";import{SpotifyLicenseBanner as q}from"@spotify/backstage-plugin-core";import{useEntity as u}from"@backstage/plugin-catalog-react";import{R as G}from"./RefetchingIndicator-3707a744.esm.js";import{s as H,R as o,A as y,F as B,a as J,u as x,L as K,N as X,b as C,c as g,d as Z,C as _,e as ee,i as te,f as F,S as ae}from"./index-6e141f2f.esm.js";import{Skeleton as s}from"@material-ui/lab";import{MarkdownContent as P}from"@backstage/core-components";import{stringifyEntityRef as ne}from"@backstage/catalog-model";import{useApi as re,useRouteRef as b,useRouteRefParams as ie}from"@backstage/core-plugin-api";import{useQuery as le}from"@tanstack/react-query";import ce from"react-use/lib/useMeasure";import A from"react-use/lib/usePrevious";import oe from"react-confetti";import"react-use/lib/useDebounce";import"graphql-request";import"graphql-tag";import"lodash";import"@material-ui/core/styles/makeStyles";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function se(t,n,a){const r=re(H),i=ne(t);return le(["soundcheck/check-details",i,n,a],async()=>r.getCheckResultDetails(i,n,a),{enabled:!!n&&!!a})}const me=p({markdownContent:{"& :last-child":{marginBottom:0}}}),de=({state:t,notes:n})=>{const a=me(),r={[o.Passed]:"success",[o.Failed]:"error",[o.NotReported]:"info",[o.NotApplicable]:"info"}[t],i={[o.Passed]:"Check passed",[o.Failed]:"Check did not pass",[o.NotReported]:"Check not reported",[o.NotApplicable]:"Check not applicable"}[t];return e.createElement(y,{severity:r,title:i},n?e.createElement(P,{className:a.markdownContent,content:n}):null)},pe=()=>{const t=D();return e.createElement(B,null,e.createElement("div",{className:t.root,"data-testid":"check-details-view"},e.createElement("div",{className:t.topBar},e.createElement(f,{variant:"h2",className:t.title},e.createElement(s,{width:300,height:32})),e.createElement(s,{width:100,height:32})),e.createElement(s,{variant:"rect",height:120}),e.createElement("div",{"data-testid":"soundcheck-check-details-description"},e.createElement(f,{variant:"h3"},e.createElement(s,null)),e.createElement(s,null),e.createElement(s,null),e.createElement(s,null))))},D=p(t=>({root:{padding:`${t.spacing(3)}px ${t.spacing(5)}px`},title:{fontWeight:"normal",fontSize:t.typography.h5.fontSize},description:{padding:`${t.spacing(3)}px 0`},subtitle:{fontWeight:"normal",fontSize:t.typography.h6.fontSize},topBar:{display:"flex",justifyContent:"space-between",marginBottom:t.spacing(2)}})),ue=({programId:t,checkId:n})=>{const a=D(),{entity:r}=u(),{data:i,isLoading:l,isError:c}=se(r,t,n);if(c)return e.createElement(U,{padding:2},e.createElement(y,{severity:"error",title:"Error loading check details"}));if(l||!t||!n)return e.createElement(pe,null);if(!i)return null;const{name:h,description:d,result:v,timestamp:m,notes:E}=i;return e.createElement("div",{className:a.root,"data-testid":"check-details-view"},e.createElement("div",{className:a.topBar},e.createElement(f,{variant:"h2",className:a.title},h),m?e.createElement(J,{timestamp:m,description:"Last updated"}):null),e.createElement(de,{state:v,notes:E}),e.createElement("div",{className:a.description,"data-testid":"soundcheck-check-details-description"},e.createElement(f,{variant:"h3",className:a.subtitle},"Description"),e.createElement(P,{content:d})))},he=p(()=>({root:{position:"absolute",width:"100%",height:"100%"}})),Ee=({programId:t})=>{var n,a;const r=he(),{entity:i}=u(),{data:l,isLoading:c}=x(i,t),[h,{width:d,height:v}]=ce(),m=c?void 0:(a=(n=l==null?void 0:l.highestLevel)==null?void 0:n.ordinal)!=null?a:-1,E=A(m),R=A(t),[M,S]=W(!1);return $(()=>{typeof E!="undefined"&&typeof m!="undefined"&&t===R&&m>E&&S(!0)},[m,E,t,R]),M?e.createElement("div",{ref:h,className:r.root},e.createElement(oe,{width:d,height:v,numberOfPieces:1e3,gravity:1,initialVelocityY:20,recycle:!1,onConfettiComplete:()=>S(!1)})):null},z=p(t=>({root:{maxWidth:"80ch",textTransform:"uppercase",paddingTop:t.spacing(2),paddingBottom:t.spacing(2)},wrapper:{display:"inline-block",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},badge:{marginRight:t.spacing(1)}})),fe=({id:t,name:n,badge:a,href:r,selected:i=!1})=>{const l=z();return e.createElement(L,{className:l.root,classes:{wrapper:l.wrapper},value:t,label:e.createElement(e.Fragment,null,a?e.createElement(K,{badge:a,className:l.badge}):e.createElement(X,{className:l.badge}),n),component:O,to:r,selected:i})},w=()=>{const t=z();return e.createElement(L,{className:t.root,classes:{wrapper:t.wrapper},label:e.createElement(s,{width:180})})},ge=()=>e.createElement(B,null,e.createElement(T,{value:!1,indicatorColor:"primary"},e.createElement(w,null),e.createElement(w,null),e.createElement(w,null)));function ve(t=[],n){const a=t.findIndex(r=>r.program.id===n);return a<0?!1:a}const ke=({trackId:t})=>{const{entity:n}=u(),{isLoading:a,data:r}=C(n),i=b(g);if(a||!t)return e.createElement(ge,null);const l=ve(r,t);return e.createElement(T,{value:l,indicatorColor:"primary","aria-label":"Certifications",variant:"scrollable"},r&&r.map(({program:{id:c,name:h},highestLevel:d})=>e.createElement(fe,{key:c,id:c,name:h,badge:d==null?void 0:d.badge,selected:c===t,href:i({trackId:c})})))},ye=p({paper:{overflow:"hidden",position:"relative"},view:{display:"grid",gridTemplateColumns:"1fr 2fr"}}),Ce=()=>{const{trackId:t,checkId:n}=Q(),a=ye(),{entity:r}=u(),{isError:i,isFetched:l,data:c}=C(r);return i?e.createElement(y,{severity:"error",title:"Error loading certifications"}):l&&!(c!=null&&c.length)?e.createElement(Z,null):e.createElement(V,{className:a.paper},e.createElement(G,null),e.createElement(ke,{trackId:t}),e.createElement(Y,null),e.createElement("div",{"data-testid":"soundcheck-certification-view",className:a.view},e.createElement(_,{trackId:t,checkId:n}),e.createElement(ue,{programId:t,checkId:n}),e.createElement(Ee,{programId:t})))},be=p(t=>({root:{"&:not(:first-child)":{marginTop:t.spacing(2)}}})),N=()=>{const t=be();return e.createElement(e.Fragment,null,e.createElement(q,{backend:ee,invalidLicenseMessage:te,inline:!0}),e.createElement("div",{className:t.root},e.createElement(Ce,null)))},we=()=>{var t;const{entity:n}=u(),a=b(g),{data:r}=C(n),i=(t=r==null?void 0:r[0])==null?void 0:t.program.id;return i?e.createElement(I,{to:a({trackId:i}),replace:!0}):null},Ne=()=>{var t,n;const{entity:a}=u(),{trackId:r}=ie(g),i=b(F),{data:l}=x(a,r),c=(n=(t=l==null?void 0:l.levels[0])==null?void 0:t.checks[0])==null?void 0:n.id;return c?e.createElement(I,{to:i({trackId:r,checkId:c}),replace:!0}):null},Re=()=>e.createElement(j,null,e.createElement(k,{path:"/",element:e.createElement(e.Fragment,null,e.createElement(N,null),e.createElement(we,null))}),e.createElement(k,{path:g.path,element:e.createElement(e.Fragment,null,e.createElement(N,null),e.createElement(Ne,null))}),e.createElement(k,{path:F.path,element:e.createElement(N,null)})),Se=()=>e.createElement(ae,null,e.createElement(Re,null));export{Se as EntitySoundcheckContent};
|
|
2
|
+
//# sourceMappingURL=EntitySoundcheckContent-aecd6416.esm.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import t,{useState as B,useEffect as E,useMemo as P,useCallback as j,createContext as ge,useContext as he,memo as b,Fragment as fe}from"react";import{useSearchParams as ye}from"react-router-dom";import{makeStyles as f,alpha as M,TextField as ve,CircularProgress as Ee,Tooltip as K,LinearProgress as ke,withStyles as be,Grid as C,Typography as k}from"@material-ui/core";import Ce from"@material-ui/lab/Autocomplete";import{stringifyEntityRef as A,parseEntityRef as R}from"@backstage/catalog-model";import{useApi as v,identityApiRef as U,useRouteRef as F,configApiRef as Re}from"@backstage/core-plugin-api";import{useQuery as T}from"@tanstack/react-query";import{s as D,R as w,h as we,B as Ne,L as Q,N as _,Q as q,A as $e,d as xe,j as Te}from"./index-6e141f2f.esm.js";import{catalogApiRef as O,humanizeEntityRef as L,entityRouteRef as S}from"@backstage/plugin-catalog-react";import Le from"react-use/lib/useAsync";import{HeaderTabs as J,MarkdownContent as Ie,Link as z,EmptyState as Be}from"@backstage/core-components";import{R as Oe}from"./RefetchingIndicator-3707a744.esm.js";import Pe,{countBy as X}from"lodash";import{Skeleton as H}from"@material-ui/lab";import{VariableSizeGrid as Ae}from"react-window";function Y(e,r){const a=v(D);return T(["soundcheck/track-overview-for-owner",e,r],async()=>a.getProgramOverviewForOwner(e,r),{enabled:!!e&&!!(r!=null&&r.kind)})}function Z(){const e=v(O);return T(["soundcheck/all-groups"],async()=>{const{items:r}=await e.getEntities({filter:{kind:"Group"},fields:["spec.profile.displayName","metadata.title","metadata.name","metadata.namespace","kind"]});return r.filter(a=>(a==null?void 0:a.kind)==="Group").map(a=>{var n,l,s,i;return{name:(i=(s=(l=(n=a.spec)==null?void 0:n.profile)==null?void 0:l.displayName)!=null?s:a.metadata.title)!=null?i:a.metadata.name,ref:A(a)}})},{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function Fe(){const e=v(U),r=v(O);return T(["soundcheck/user-groups-claims"],async()=>{const{ownershipEntityRefs:a}=await e.getBackstageIdentity();return(await r.getEntitiesByRefs({entityRefs:a})).items.filter(n=>(n==null?void 0:n.kind)==="Group").map(n=>{var l,s,i,c;return{name:(c=(i=(s=(l=n.spec)==null?void 0:l.profile)==null?void 0:s.displayName)!=null?i:n.metadata.title)!=null?c:n.metadata.name,ref:A(n)}})})}function Se(e){const r=v(D);return T(["soundcheck/facets-for-owner",e],async()=>r.getFacetsForOwner(e),{enabled:!!e})}const ze=()=>{const[e,r]=ye(),a=Object.fromEntries(e.entries()),[n,l]=B(a);return E(()=>{r(n,{replace:!0})},[n]),[n,l]},ee=()=>{const{data:e,isLoading:r,isError:a}=Fe(),{data:n,isLoading:l,isError:s}=Z();return{options:P(()=>{const i=[];return e&&i.push(...e.map(({name:c,ref:o})=>({name:c,ref:o,key:"My Groups"}))),n&&i.push(...n.map(({name:c,ref:o})=>({name:c,ref:o,key:"All Groups"}))),i},[e,n]),isLoading:r||l,isError:a||s}},He=f(e=>({root:{width:"100%",minWidth:250},textField:{"& $notchedOutline":{borderColor:M(e.page.fontColor,.25)},"&:hover $notchedOutline":{borderColor:e.page.fontColor}},input:{backgroundColor:"transparent",color:e.page.fontColor},clearIndicator:{color:e.page.fontColor},popupIndicator:{color:e.page.fontColor},notchedOutline:{}})),We=e=>{const{onChange:r,initialValue:a,setError:n}=e,{options:l,isLoading:s,isError:i}=ee(),c=He(),[o,d]=B(null);E(()=>{if(!s&&l!=null&&l.length&&!o){const m=a?l.find(p=>p.ref===a):l[0];m&&(d(m),r==null||r(m.ref))}},[s,l,o,r,a]);const u=j((m,p)=>{d(p),r==null||r(p==null?void 0:p.ref)},[r,d]);return E(()=>{n==null||n(i?new Error("Error loading groups"):void 0)},[i,n]),i?null:t.createElement(Ce,{"aria-label":"Current group",className:c.root,classes:{clearIndicator:c.clearIndicator,popupIndicator:c.popupIndicator},disableClearable:!0,options:l!=null?l:[],loading:s,groupBy:m=>m.key,value:o,freeSolo:!1,onChange:u,getOptionLabel:m=>m.name,renderInput:m=>t.createElement(ve,{...m,variant:"outlined",placeholder:s?"Loading":"Select a group",className:c.textField,InputProps:{...m.InputProps,className:c.input,classes:{notchedOutline:c.notchedOutline},endAdornment:t.createElement(t.Fragment,null,s?t.createElement(Ee,{color:"inherit",size:20}):null,m.InputProps.endAdornment)}})})},te={loading:!1},re=ge(te),Ge=()=>he(re),Ve=({children:e})=>{const[r,a]=B(te),n=v(O),l=v(U),{value:s,loading:i,error:c}=Le(async()=>{const[{token:o},d]=await Promise.all([l.getCredentials(),l.getBackstageIdentity()]);return o?await n.getEntityByRef(d.userEntityRef):null},[n,l]);return E(()=>{if(s){const o=A(s);a({user:s,userEntityRef:o,loading:i,error:c})}else a({loading:i,error:c})},[s,i,c]),t.createElement(re.Provider,{value:r},e)},je=e=>({key:`skeleton${e}`,label:"",id:`skeleton${e}`}),Me=()=>{const e=Array.from({length:4},(r,a)=>je(a));return t.createElement(J,{tabs:e})},Ke=f(e=>({root:{borderTop:`1px solid ${e.palette.divider}`,borderBottom:`1px solid ${e.palette.divider}`},tab:{textTransform:"uppercase",paddingTop:e.spacing(2),paddingBottom:e.spacing(2)}})),Ue=({unfilteredFacets:e,onChange:r,kind:a,type:n})=>{var l,s,i;const c=Ke(),o={types:(l=e==null?void 0:e.types.filter(({count:p})=>p>0))!=null?l:[]},d=j(p=>{var g;r((g=o==null?void 0:o.types[p].kind)!=null?g:"",o==null?void 0:o.types[p].type)},[o==null?void 0:o.types,r]);E(()=>{var p,g,y;const h=(o==null?void 0:o.types)&&o.types.length>=0,I=!a&&h,G=a&&h&&!(o!=null&&o.types.find(({kind:$,type:x})=>a===$&&(!n&&!x||n===x)));(I||G)&&r((g=(p=o==null?void 0:o.types[0])==null?void 0:p.kind)!=null?g:"",(y=o==null?void 0:o.types[0])==null?void 0:y.type)},[a,n,o==null?void 0:o.types,r]);const u=(s=o==null?void 0:o.types.map(({kind:p,type:g,count:y})=>{const h=`${p}|${g!=null?g:""}`;return{key:h,label:`${g!=null?g:p} (${y>50?"50+":y})`,id:h,tabProps:{className:c.tab}}}))!=null?s:[];if(!u.length)return null;const m=(i=o==null?void 0:o.types.findIndex(p=>p.kind===a&&(!p.type&&!n||p.type===n)))!=null?i:-1;return t.createElement(t.Fragment,null,t.createElement(Oe,null),t.createElement(J,{onChange:d,tabs:u,selectedIndex:m>-1?m:void 0}))},De=f(e=>({root:{height:"8px",minWidth:"64px",marginLeft:e.spacing(2),borderRadius:"100vh",backgroundColor:e.palette.background.default},bar:{backgroundColor:e.palette.success.main,transition:"none"}})),ae=e=>{var r,a;const n=De(e),l=P(()=>Object.entries(e.progress).reduce((i,[,c])=>i+c,0),[e.progress]);if(l===0)return null;const s=(r=e.progress[w.Passed])!=null?r:0;return t.createElement(K,{arrow:!0,title:`Check passing for ${s} of ${l} ${l===1?"entity":"entities"}`,enterDelay:0,placement:"top"},t.createElement(ke,{variant:"determinate",value:((a=e.progress[w.Passed])!=null?a:0)/l*100,classes:{root:n.root,bar:n.bar}}))},Qe=f(e=>({headerWrapper:{marginTop:e.spacing(.5)},entityRefName:{fontWeight:"bold"},iconWrapper:{padding:e.spacing(1.5,.5),display:"flex",alignItems:"center",justifyContent:"center"}})),_e=({check:{name:e,description:r},icon:a,entityRef:n})=>{const l=Qe(),s=R(n);return t.createElement(C,{spacing:1},t.createElement(C,{container:!0,direction:"row",spacing:1,wrap:"nowrap"},t.createElement("div",{className:l.iconWrapper},a),t.createElement(k,{variant:"h6",className:l.headerWrapper,noWrap:!0},e)),t.createElement(C,{item:!0,wrap:"nowrap"},t.createElement(k,{variant:"subtitle2",className:l.entityRefName},L(s,{defaultKind:s.kind}))),t.createElement(Ie,{content:r}))},qe=be(e=>{const r=e.palette.type==="dark"?e.palette.common.black:e.palette.grey[300];return{tooltip:{backgroundColor:r,color:e.palette.type==="dark"?e.palette.common.white:e.palette.grey[700]},arrow:{color:r}}})(K),Je=({children:e,check:r,icon:a,entityRef:n})=>t.createElement(qe,{arrow:!0,title:t.createElement(_e,{check:r,icon:a,entityRef:n}),enterDelay:150,placement:"top"},e),Xe=f(e=>({root:{padding:0},iconWrapper:{padding:e.spacing(1.5),display:"flex",alignItems:"center",justifyContent:"center"},link:{"&:hover $iconWrapper, &:active $iconWrapper, &:focus $iconWrapper":{backgroundColor:e.palette.infoBackground}},icon:{width:"17px",height:"17px"},virtualized:{borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),ne=b(({programId:e,check:r,entityRef:a,result:n,entityRoute:l,isVirtualized:s})=>{const i=Xe();if(typeof a!="string"){const u=t.createElement("div",{className:i.iconWrapper},t.createElement("div",{className:i.icon}));return s?t.createElement("div",{className:`${i.root} ${i.virtualized}`,"aria-hidden":!0},u):t.createElement("td",{className:i.root,"aria-hidden":!0},u)}const c=t.createElement(we,{className:i.icon,result:n!=null?n:w.NotReported}),o=t.createElement("div",{className:i.iconWrapper},c),d=n&&n===w.NotApplicable?o:t.createElement(z,{className:i.link,to:`${l(R(a))}/soundcheck/${e}/${r.id}`},o);return s?t.createElement("div",{className:`${i.root} ${i.virtualized}`},t.createElement(Je,{check:r,icon:c,entityRef:a},d)):t.createElement("td",{className:`${i.root}`},d)}),le=8,Ye=16,N={programTitle:70,levelTitle:30,check:42,entityRefFooter:100},W={programTitle:350+Ye*2,checkResult:42},Ze=e=>e.reduce((r,a)=>r+a.height,0),et=e=>e*W.checkResult+W.programTitle,tt=e=>e.filter(r=>r!==void 0).map(r=>{const a=R(r);return L(a,{defaultKind:a.kind})}).reduce((r,a)=>r.length>a.length?r:a,""),rt=e=>le*e+le,oe="NoLevel",at=e=>({name:oe,badge:{options:{level:0,color:""},variant:Ne.Medal},entityRef:e,ordinal:0}),ie=f(e=>({checkNameCell:{padding:0,backgroundColor:e.palette.background.paper},checkNameContent:{padding:`0 ${e.spacing(2)}px`,display:"flex",justifyContent:"space-between",alignItems:"center"},checkNameTypography:{overflow:"hidden",textOverflow:"ellipsis"},checkIndicator:{flexBasis:e.spacing(8)},checkNameCellVirtualized:{height:`${N.check}px`,lineHeight:`${N.check}px`,borderBottom:`1px solid ${e.palette.divider}`,borderRight:`1px solid ${e.palette.divider}`}})),nt=b(({programId:e,programName:r,check:a,entityRefs:n,results:l,entityRoute:s})=>{const i=ie(),c=P(()=>X(l.filter(({result:d})=>d!==w.NotApplicable),"result"),[l]),o=new Map(l.map(d=>[d.entityRef,d.result]));return t.createElement("tr",{"data-testid":"track-check-row"},t.createElement("th",{scope:"row",className:i.checkNameCell,"aria-label":`${a.name} check for ${r} track`},t.createElement("div",{className:i.checkNameContent},t.createElement(k,{className:i.checkNameTypography,variant:"subtitle2",component:"p"},a.name),t.createElement(ae,{className:i.checkIndicator,progress:c}))),n.map((d,u)=>t.createElement(ne,{key:u,programId:e,check:a,entityRef:d,result:typeof d=="string"?o.get(d):void 0,entityRoute:s})))}),lt=({name:e,progress:r})=>{const a=ie();return t.createElement("div",{className:a.checkNameCell,"aria-label":`${e} check`},t.createElement("div",{className:`${a.checkNameContent} ${a.checkNameCellVirtualized}`},t.createElement(k,{variant:"subtitle2",component:"p",className:a.checkNameTypography},e),t.createElement(ae,{className:a.checkIndicator,progress:r})))},ot=f(e=>({virtualized:{borderRight:`1px solid ${e.palette.divider}`,height:`${N.programTitle}px`,display:"flex",justifyContent:"center",alignItems:"center"}})),it=b(({entityRef:e,highestLevels:r})=>{const a=r.find(n=>n.entityRef===e);return t.createElement(t.Fragment,null,a!=null&&a.badge?t.createElement(Q,{badge:a.badge}):t.createElement(_,null))}),st=({highestLevel:e})=>{const r=ot();if(!(e!=null&&e.badge))return t.createElement("div",{className:r.virtualized},"\xA0");const a=e.name!==oe;return t.createElement("div",{className:r.virtualized},a?t.createElement(Q,{badge:e.badge}):t.createElement(_,null))},se=f(e=>({programNameCell:{padding:0,position:"sticky",backgroundColor:e.palette.background.paper},programNameContent:{padding:e.spacing(2)},programNameTypography:{overflow:"hidden",textOverflow:"ellipsis"},badgeCellContent:{display:"flex",justifyContent:"center",alignItems:"center"},programNameCellVirtualized:{borderRight:`1px solid ${e.palette.divider}`}})),ct=b(({program:e,entityRefs:r,highestLevels:a})=>{const n=se();return t.createElement("tr",{"data-testid":"track-title-row"},t.createElement("th",{scope:"row",className:n.programNameCell},t.createElement("div",{className:n.programNameContent},t.createElement(k,{className:n.programNameTypography,variant:"h5",component:"p"},e.name))),r.map((l,s)=>typeof l!="string"?t.createElement("td",{key:s,"aria-hidden":!0}):t.createElement("td",{key:s,"data-testid":"track-certification-cell"},t.createElement("div",{className:n.badgeCellContent},t.createElement(it,{entityRef:l,highestLevels:a})))))}),dt=b(({name:e})=>{const r=se();return t.createElement("div",{className:`${r.programNameCell} ${r.programNameCellVirtualized}`},t.createElement("div",{className:r.programNameContent},t.createElement(k,{className:r.programNameTypography,variant:"h5",component:"p"},e)))}),V=f(e=>{const r=e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100];return{root:{color:M(e.palette.getContrastText(r),.8),backgroundColor:r},levelContent:{padding:`${e.spacing(.5)}px ${e.spacing(2)}px`,backgroundColor:r},levelTypography:{overflow:"hidden",textOverflow:"ellipsis"},levelHeaderCell:{padding:`${e.spacing(.5)}px ${e.spacing(2)}px`,borderRight:`1px solid ${e.palette.divider}`,height:`${N.levelTitle}px`}}}),pt=b(({level:e,entityRefs:r,programName:a})=>{const n=V();return t.createElement("tr",{className:n.root,"data-testid":"track-level-row"},t.createElement("th",{scope:"row",className:n.root},t.createElement("div",{className:n.levelContent},t.createElement(k,{className:n.levelTypography,variant:"subtitle2",component:"p","aria-label":`${e.name} for ${a} track`},e.name))),r.map((l,s)=>t.createElement("td",{key:s,className:n.root,"aria-hidden":!0})))}),mt=({name:e})=>{const r=V();return t.createElement("div",{className:`${r.levelHeaderCell} ${r.root}`,"aria-label":`${e}`},t.createElement(k,{variant:"subtitle2",component:"p",className:r.levelTypography},e))},ut=()=>{const e=V();return t.createElement("div",{className:`${e.levelHeaderCell} ${e.root}`},"\xA0")},gt=({program:e,highestLevels:r,levels:a,entityRefs:n,entityRoute:l})=>t.createElement("tbody",null,t.createElement(ct,{program:e,entityRefs:n,highestLevels:r}),a.map((s,i)=>t.createElement(fe,{key:i},t.createElement(pt,{entityRefs:n,level:s,programName:e.name}),s.checks.map(({check:c,results:o},d)=>t.createElement(nt,{key:d,check:c,programId:e.id,programName:e.name,entityRefs:n,results:o,entityRoute:l}))))),ce=e=>{const r=v(O);return T([q.EntityByRef,e],async()=>r.getEntityByRef(e),{onError:()=>{},enabled:!!e})},ht=e=>{const r=v(O);return T([q.EntitiesByRefs,e],async()=>r.getEntitiesByRefs({entityRefs:e.entityRefs,fields:e.fields}),{onError:()=>{},enabled:!!e.entityRefs})},de=f(e=>({root:{position:"sticky",bottom:"-1px",backgroundColor:e.palette.background.default,boxShadow:`0 -1px ${e.palette.divider}`,"& td$cell, & th$cell":{border:0,padding:e.spacing(1)},"& td$cell":{backgroundColor:e.palette.background.default}},row:{boxShadow:`1px 0 ${e.palette.background.default}, -1px 0 ${e.palette.background.default}`},cell:{verticalAlign:"top"},cellInner:{textOrientation:"mixed",writingMode:"vertical-lr",transform:"rotate(-20deg)",transformOrigin:`100% ${e.spacing(1)}px`,wordBreak:"keep-all",fontWeight:"bold",overflow:"hidden",textOverflow:"ellipsis",maxHeight:"max(15vh, 175px)"}})),ft=({entityRefs:e})=>{const r=F(S),a=de(),{data:n}=ht({entityRefs:Pe.compact(e),fields:["kind","metadata.name","metadata.namespace","metadata.title"]});return t.createElement("tfoot",{className:a.root,"data-testid":"results-table-footer"},t.createElement("tr",{className:a.row},t.createElement("td",{className:a.cell}),e.map((l,s)=>{if(typeof l!="string")return t.createElement("th",{key:s,className:a.cell,"aria-hidden":!0});const i=R(l),c=n==null?void 0:n.items.find(o=>o&&A(o)===l);return t.createElement("th",{scope:"col",key:s,className:a.cell},t.createElement("div",{className:a.cellInner},t.createElement(z,{to:r(i)},c!=null&&c.metadata.title?c.metadata.title:L(i,{defaultKind:i.kind}))))})))},yt=({entityRef:e})=>{const{data:r}=ce(e),a=F(S),n=de(),l=e?R(e):void 0,s=l?t.createElement(z,{to:a(l)},r!=null&&r.metadata.title?r.metadata.title:L(l,{defaultKind:l.kind})):t.createElement(t.Fragment,null);return t.createElement("div",{className:n.cell},t.createElement("div",{className:n.cellInner},s))},vt=f(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap","& th, & td":{border:`1px solid ${e.palette.divider}`,borderCollapse:"collapse"},paddingBottom:e.spacing(2)},programTitle:{padding:e.spacing(2)},checkResult:{padding:e.spacing(1.5)},title:{padding:`${e.spacing(1)}px ${e.spacing(2)}px`},header:{backgroundColor:e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100]}})),pe=()=>{const e=vt(),r=new Array(25).fill(void 0),a=new Array(5).fill(void 0),n=new Array(3).fill(void 0);return t.createElement("table",{className:e.table},t.createElement("tbody",null,t.createElement("tr",null,t.createElement("td",{className:e.programTitle},t.createElement(H,{width:180,height:40})),r.map((l,s)=>t.createElement("td",{key:s}))),n.map((l,s)=>t.createElement(t.Fragment,{key:s},t.createElement("tr",{className:e.header},t.createElement("td",{className:e.title},t.createElement(H,{width:180})),r.map((i,c)=>t.createElement("td",{key:c}))),a.map((i,c)=>t.createElement("tr",{key:c},t.createElement("td",{className:e.title},t.createElement(H,{width:240})),r.map((o,d)=>t.createElement("td",{key:d,className:e.checkResult},t.createElement(H,{width:18,height:18,variant:"rect"})))))))))},Et=f(e=>({root:{width:"100%"},table:{overflow:"auto",backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left","& th, & td":{border:`1px solid ${e.palette.divider}`,borderCollapse:"collapse"},"& th:first-of-type":{position:"sticky",left:0,zIndex:1,maxWidth:"60ch"},"& tfoot":{bottom:0,zIndex:1e3},"& tbody td:first-of-type":{border:`1px solid ${e.palette.divider}`,boxShadow:`1px 0 ${e.palette.background.default}, -1px 0 ${e.palette.background.default}`}}})),kt=b(e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,s=Et(),i=F(S),{data:c,isLoading:o,isError:d}=Y(l,{kind:a,type:n});if(E(()=>{r==null||r(d?new Error("Error loading track overview"):void 0)},[d,r]),o)return t.createElement(pe,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c;if(!o&&!u.length)return t.createElement(Be,{missing:"data",title:"Missing tracks",description:t.createElement(t.Fragment,null,"Looks like the group"," ",L(R(l),{defaultKind:"Group"})," ","doesn't own any ",n!=null?n:a," components that have Soundcheck tracks set up.",t.createElement("br",null),t.createElement("br",null),"If you're an administrator, you can learn more about configuring and filtering tracks in the"," ",t.createElement(z,{to:"https://www.npmjs.com/package/@spotify/backstage-plugin-soundcheck-backend#entity-filter"},"docs"),".")});if(d)return null;const p=m.length>=25?m:[...m,...Array.from({length:25-m.length},()=>{})];return t.createElement("div",{className:s.root},t.createElement("table",{className:s.table,"aria-label":"Check results"},u.map(({program:g,levels:y,highestLevels:h},I)=>t.createElement(gt,{key:I,program:g,entityRefs:p,levels:y,highestLevels:h,entityRoute:i})),t.createElement(ft,{entityRefs:p})))}),bt=e=>t.createElement(dt,{name:e}),Ct=e=>({type:"ProgramHeader",render:()=>bt(e)}),Rt=e=>e?t.createElement(mt,{name:e}):t.createElement(ut,null),me=e=>({type:"LevelHeader",render:()=>Rt(e)}),wt=(e,r)=>t.createElement(lt,{name:e,progress:r}),Nt=(e,r)=>({type:"CheckTitle",render:()=>wt(e,r)}),$t=(e,r,a,n,l)=>t.createElement(ne,{check:r,entityRef:a,entityRoute:l,programId:e,result:n,isVirtualized:!0}),xt=(e,r,a,n,l)=>({type:"CheckResult",render:()=>$t(e,r,a,n,l)}),Tt=e=>t.createElement(yt,{entityRef:e}),ue=e=>({type:"EntityHeader",render:()=>Tt(e)}),Lt=e=>t.createElement(st,{highestLevel:e}),It=e=>({type:"LevelBadge",render:()=>Lt(e)}),Bt=e=>r=>{const a=e[r.rowIndex].cells[r.columnIndex];return a?t.createElement("div",{style:r.style},a.render()):t.createElement("div",{style:r.style})},Ot=(e,r,a)=>{var n;const l=[];for(const{program:i,levels:c,highestLevels:o}of e){l.push({height:N.programTitle,cells:[Ct(i.name),...r.map(d=>{const u=d?o.find(m=>m.entityRef===d)||at(d):void 0;return It(u)})]});for(const d of c){l.push({height:N.levelTitle,cells:[me(d.name),...r.map(u=>me(""))]});for(const{check:u,results:m}of d.checks)l.push({height:N.check,cells:[Nt(u.name,X(m.filter(({result:p})=>p!==w.NotApplicable),"result")),...r.map(p=>{var g,y;return xt(i.id,u,p,(y=(g=m.find(h=>h.entityRef===p))==null?void 0:g.result)!=null?y:w.NotApplicable,a)})]})}}const s=tt(r!=null?r:[]);return l.push({height:rt((n=s.length)!=null?n:1),cells:[ue(""),...r.map(i=>ue(i||""))]}),l},Pt=f(e=>({table:{backgroundColor:e.palette.background.paper,borderCollapse:"collapse",whiteSpace:"nowrap",textAlign:"left",overflow:"auto"}})),At=e=>{const{setError:r,kind:a,type:n,ownerEntityRef:l}=e,s=Pt(),i=F(S),{data:c,isLoading:o,isError:d}=Y(l,{kind:a,type:n});if(E(()=>{r==null||r(d?new Error("Error loading program overview"):void 0)},[d,r]),o)return t.createElement(pe,null);if(!c||!l)return null;const{programs:u,entityRefs:m}=c,p=m.length>=25?m:[...m,...Array.from({length:25-m.length},()=>{})],g=Ot(u,p,i),y=Bt(g);return t.createElement(C,{"aria-label":`Check results for ${n!=null?n:a}`,key:`${a}|${n!=null?n:""}`,item:!0,xs:12},t.createElement(Ae,{className:s.table,columnCount:p.length+1,columnWidth:h=>h===0?W.programTitle:W.checkResult,rowCount:g.length,rowHeight:h=>g[h].height,height:Ze(g),width:et(p.length)},y))},Ft=({facets:e,ownerEntityRef:r,kind:a,type:n,setError:l})=>{const s=P(()=>{const i=new Map;return e.types.forEach(({kind:c,type:o})=>{const d=`${c}|${o!=null?o:""}`;i.set(d,t.createElement(At,{key:d,ownerEntityRef:r,kind:c,type:o,setError:l}))}),i},[e,r,l]);return t.createElement("div",null,s.get(`${a}|${n!=null?n:""}`))},St=f(()=>({scrollContainer:{overflow:"auto"}})),zt=({facets:e,ownerEntityRef:r,hasError:a,kind:n,type:l,setError:s,useVirtualizedResultsTable:i,isFixedGroup:c})=>{var o,d,u;const m=St();if(a)return t.createElement($e,{severity:"error",title:a.message});const p="Use the groups drop-down list at the top-right of the page to select another group.";return e&&((d=(o=e.types)==null?void 0:o.length)!=null?d:0)>0?(u=e.types)!=null&&u.find(g=>g.count>0)?t.createElement("div",{className:m.scrollContainer},i?t.createElement(Ft,{facets:e,kind:n,type:l,setError:s,ownerEntityRef:r,hasError:a}):t.createElement(kt,{ownerEntityRef:r,kind:n,type:l,setError:s})):t.createElement(xe,{description:t.createElement(t.Fragment,null,"Looks like the group '",L(R(r),{defaultKind:"Group"}),"' doesn't own any entities that have any applicable tracks configured.",!c&&t.createElement(t.Fragment,null,t.createElement("br",null),t.createElement("br",null),p))}):t.createElement(Te,{ownerEntityRef:r,selectGroupHint:c?void 0:p})},Ht=f(()=>({tableContainer:{padding:0,backgroundColor:"transparent"}})),Wt=({groupSelectorError:e,searchParams:r,setSearchParams:a,isFixedGroup:n=!1})=>{var l;const{group:s,kind:i,type:c}=r,[o,d]=B(void 0),[u,m]=B(void 0);E(()=>{((o==null?void 0:o.kind)!==i||(o==null?void 0:o.type)!==c)&&d({kind:i,type:c})},[i,c,o]);const{data:p,isLoading:g}=Se(s),y=(l=v(Re).getOptionalBoolean("soundcheck.virtualizeOverviewPage"))!=null?l:!0,h=u||e,I=($,x)=>{$&&(d({kind:$,type:x}),x?a({...r,kind:$,type:x}):(r!=null&&r.hasOwnProperty("type")&&delete r.type,a({...r,kind:$})))},G=Ht();return t.createElement(C,{container:!0,spacing:0},t.createElement(C,{item:!0,xs:12},g?t.createElement(Me,null):t.createElement(Ue,{unfilteredFacets:p,kind:o==null?void 0:o.kind,type:o==null?void 0:o.type,onChange:I})),t.createElement(C,{item:!0,xs:12,className:G.tableContainer},!g&&t.createElement(zt,{facets:p,kind:o==null?void 0:o.kind,type:o==null?void 0:o.type,setError:m,hasError:h,ownerEntityRef:s,useVirtualizedResultsTable:y,isFixedGroup:n})))};export{We as G,Wt as O,Ve as U,ee as a,Ge as b,Z as c,ce as d,ze as u};
|
|
2
|
+
//# sourceMappingURL=OverviewPageContent-433c8dc6.esm.js.map
|
package/dist/esm/{RefetchingIndicator-e114bc04.esm.js → RefetchingIndicator-3707a744.esm.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t,{useState as n}from"react";import{makeStyles as a,LinearProgress as m}from"@material-ui/core";import s from"react-use/lib/useDebounce";import"@backstage/catalog-model";import"@backstage/core-plugin-api";import{useIsFetching as c}from"@tanstack/react-query";import{F as d}from"./index-
|
|
2
|
-
//# sourceMappingURL=RefetchingIndicator-
|
|
1
|
+
import t,{useState as n}from"react";import{makeStyles as a,LinearProgress as m}from"@material-ui/core";import s from"react-use/lib/useDebounce";import"@backstage/catalog-model";import"@backstage/core-plugin-api";import{useIsFetching as c}from"@tanstack/react-query";import{F as d}from"./index-6e141f2f.esm.js";import"@backstage/plugin-catalog-react";import"react-router-dom";const p=a(e=>({indicator:{position:"absolute",width:"100%",zIndex:e.zIndex.speedDial}})),l=()=>{const e=c(),i=p(),[r,o]=n(!!e);return s(()=>{o(!!e)},250,[e]),r?t.createElement(d,null,t.createElement("div",{className:i.indicator},t.createElement(m,{variant:"indeterminate","data-testid":"refetching-indicator"}))):null};export{l as R};
|
|
2
|
+
//# sourceMappingURL=RefetchingIndicator-3707a744.esm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"react";import{S as o,g as i}from"./index-
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import t from"react";import{S as o,g as i}from"./index-6e141f2f.esm.js";import"@backstage/core-plugin-api";import"graphql-request";import"graphql-tag";import"@tanstack/react-query";import"lodash";import"@material-ui/core/styles/makeStyles";import"@material-ui/core";import"@backstage/core-components";import"@backstage/plugin-catalog-react";import"@spotify/backstage-plugin-core";import"@backstage/catalog-model";import"@material-ui/lab";import"react-router-dom";import"classnames";import"@material-ui/icons/Schedule";import"luxon";import"@material-ui/icons/Check";import"@material-ui/icons/Close";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";const m=({title:r})=>t.createElement(o,null,t.createElement(i,{title:r}));export{m as EntitySoundcheckCard};
|
|
2
|
+
//# sourceMappingURL=index-01c3a9f5.esm.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import t,{useState as y,useCallback as ee,createContext as Ae,useContext as $e,useEffect as $,useMemo as _,useReducer as va,useRef as Wn,memo as Hn}from"react";import{useSearchParams as Rt,useNavigate as Ye,Routes as Ea,Route as Qe,useParams as qn,useLocation as Un}from"react-router-dom";import{MarkdownContent as fa,Link as Kn,DismissableBanner as jn,TabbedLayout as W,Page as Yn,Header as Qn}from"@backstage/core-components";import{DATA_VIZ_DARK_THEME as Xn,DATA_VIZ_LIGHT_THEME as Zn,SpotifyLicenseBanner as Jn}from"@spotify/backstage-plugin-core";import{Box as k,Paper as Me,Grid as g,Button as H,Slide as er,Dialog as tr,AppBar as ar,Toolbar as nr,Typography as b,IconButton as Pe,TextField as G,Collapse as rr,makeStyles as x,ButtonGroup as ya,Menu as Nt,MenuItem as ge,FormControl as Lt,InputLabel as St,Select as Dt,RadioGroup as lr,Radio as Ca,Divider as Xe,FormControlLabel as Ze,Checkbox as Be,Card as It,ListItemIcon as Q,ListItemText as X,withStyles as or,CardHeader as sr,CardContent as ir,CardActions as cr,List as Je,ListItem as oe,Tooltip as K,InputAdornment as ba,NativeSelect as ka,TablePagination as Ot,Chip as Ft,CircularProgress as dr,useTheme as et,Table as mr,TableHead as ur,TableRow as xa,TableCell as Pa,TableBody as pr,Switch as hr,Tabs as gr,Tab as At}from"@material-ui/core";import{makeStyles as z,createStyles as vr}from"@material-ui/core/styles";import{a as Er,b as tt,c as fr,d as yr,u as Cr,U as br,G as kr,O as xr}from"./OverviewPageContent-433c8dc6.esm.js";import wa from"@material-ui/icons/Close";import{Controller as U,useWatch as $t,useForm as Ta}from"react-hook-form";import Ra from"@material-ui/icons/ArrowDropUp";import Mt from"@material-ui/icons/ArrowDropDown";import Na from"@material-ui/icons/Delete";import{useApi as I,alertApiRef as Pr,useRouteRef as ve,configApiRef as wr}from"@backstage/core-plugin-api";import{useQuery as B,useQueryClient as Ee,useMutation as fe}from"@tanstack/react-query";import{s as F,Q as L,k as se,M as ye,l as at,t as Tr,m as Rr,n as Nr,o as Lr,p as Sr,q as Dr,S as Ir,w as Or}from"./index-6e141f2f.esm.js";import{asArray as Bt,FrequencySchema as Fr,parseFactRef as Vt,stringifyFactRef as Ar,soundcheckCheckUpdatePermission as $r,soundcheckCheckDeletePermission as Mr,soundcheckCheckCreatePermission as Br,soundcheckTrackUpdatePermission as Vr,soundcheckTrackDeletePermission as Gr,soundcheckTrackCreatePermission as zr,soundcheckCollectorUpdatePermission as _r,soundcheckCampaignUpdatePermission as Wr,soundcheckCollectorReadPermission as Hr}from"@spotify/backstage-plugin-soundcheck-common";import qr from"lodash/isObject";import Ve from"lodash";import Ur from"cron-validate";import Kr from"cronstrue";import{v4 as La}from"uuid";import{Autocomplete as Gt,Skeleton as zt,ToggleButtonGroup as jr,ToggleButton as Sa}from"@material-ui/lab";import Da from"@material-ui/icons/CheckBox";import Ia from"@material-ui/icons/CheckBoxOutlineBlank";import Yr from"@material-ui/icons/ExpandMore";import{catalogApiRef as Qr,EntityRefLink as Ge,humanizeEntityRef as Xr,entityRouteRef as Oa}from"@backstage/plugin-catalog-react";import{parseEntityRef as M,stringifyEntityRef as Zr}from"@backstage/catalog-model";import Jr from"@material-ui/icons/MoreVert";import nt from"@material-ui/icons/Group";import{usePermission as te}from"@backstage/plugin-permission-react";import el from"@material-ui/icons/Search";import{useDrag as tl,useDrop as al,DndProvider as nl}from"react-dnd";import{HTML5Backend as rl}from"react-dnd-html5-backend";import ll from"@material-ui/icons/OpenInNew";import ol from"@material-ui/icons/DoneAllRounded";import sl from"@material-ui/icons/Menu";import Fa from"@material-ui/icons/DragIndicator";import il from"@material-ui/icons/Visibility";import cl from"@material-ui/icons/Add";import dl from"@material-ui/icons/Remove";import{ResponsiveContainer as Aa,LineChart as _t,CartesianGrid as rt,XAxis as ze,YAxis as _e,Line as Wt,Tooltip as $a,Legend as Ma,BarChart as Ba,Bar as Va,Cell as ml}from"recharts";import{DateTime as lt}from"luxon";import{motion as Ht}from"framer-motion";import Ga from"react-use/lib/useLocalStorage";import ul from"@material-ui/icons/GetApp";import{CSVLink as za}from"react-csv";import{CircularProgressbar as pl,buildStyles as hl}from"react-circular-progressbar";import"react-circular-progressbar/dist/styles.css";import gl from"@material-ui/icons/TrendingUp";import vl from"@material-ui/icons/TrendingDown";import El from"@material-ui/icons/TrendingFlat";import fl from"@material-ui/icons/Reorder";import yl from"@material-ui/icons/Apps";import Cl from"@material-ui/icons/GridOn";import bl from"@material-ui/icons/KeyboardArrowDown";import kl from"../images/catalog.svg";import xl from"../images/git.svg";import Pl from"../images/octocat.svg";import wl from"../images/settings.svg";import Tl from"../images/soundcheck.png";import Rl from"../images/tech_insights.png";import"@material-ui/lab/Autocomplete";import"react-use/lib/useAsync";import"./RefetchingIndicator-3707a744.esm.js";import"react-use/lib/useDebounce";import"react-window";import"graphql-request";import"graphql-tag";import"@material-ui/core/styles/makeStyles";import"classnames";import"@material-ui/icons/Schedule";import"@material-ui/icons/Check";import"@material-ui/icons/RemoveCircleOutline";import"@material-ui/icons/HelpOutline";function qt(e,n,a){const r=I(F);return B([L.GetChecks,e,n,a],async()=>r.getChecks(e,n,a),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function _a(e,n,a){const r=I(F);return B([L.GetAllPrograms,e,n,a],async()=>r.getAllPrograms(e,n,a),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const Nl="Error Creating Track";function Ll(){const e=I(F),n=Ee(),{showAlert:a}=se(),r=async l=>{const o=await e.createProgram(l);if(!o)throw new Error("Failed to create track.");return o};return fe([ye.CreateProgram],r,{onSuccess:async()=>{const l=[L.GetAllPrograms,L.GetOverallTrackPassRate,L.GetIndividualTrackPassRate];for(const o of l)n.invalidateQueries({queryKey:[o]})},onError:l=>{let o="Failed to create track.";l instanceof Error&&(o=l.message),a({severity:"error",title:Nl,message:o})}})}const Sl=()=>{const[e,n]=y([]),[a,r]=y([[]]),[l,o]=y([!1]),s=ee((d,p)=>{r(h=>{const v=[...h];return v[p]=[...v[p],d],v}),n(h=>h==null?void 0:h.filter(v=>v.id!==d.id)),o(h=>{if(h[p]){const v=[...h];return v[p]=!1,v}return h})},[]),i=ee((d,p)=>{r(h=>{const v=[...h];return v[p]=v[p].filter(C=>C.id!==d.id),v}),n(h=>[...h!=null?h:[],d])},[]),c=ee(()=>{r(d=>[...d,[]]),o(d=>[...d,!1])},[]),u=ee(d=>{a.length>1&&r(p=>{const h=[...p],v=h.splice(d,1)[0];return n(C=>[...C!=null?C:[],...v]),h})},[a]),m=ee(()=>{const d=a.map(p=>p.length===0);return o(d),!d.some(p=>p)},[a]);return{chips:e,setChips:n,inputChipsList:a,handleDrop:s,handleDelete:i,addInput:c,removeInput:u,inputErrors:l,setInputErrors:o,areInputsValid:m,setInputChipsList:r}},Dl=e=>{const n=I(F);return B([L.GetOverallCheckPassRates,e],async()=>n.getOverallCheckPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Il=e=>{const n=I(F);return B([L.GetIndividualCheckPassRate,e],async()=>n.getIndividualCheckPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Ol=e=>{const n=I(F);return B([L.GetOverallTrackPassRate,e],async()=>n.getOverallTrackPassRate(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Fl=e=>{const n=I(F);return B([L.GetIndividualTrackPassRate,e],async()=>n.getIndividualTrackPassRate(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Al=e=>{const n=I(F);return B([L.GetOverallEntityPassRates,e],async()=>n.getOverallEntityPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},$l=e=>{const n=I(F);return B([L.GetIndividualEntityPassRate,e],async()=>n.getIndividualEntityPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Ml=e=>{const n=I(F);return B([L.GetOverallGroupPassRates,e],async()=>n.getOverallGroupPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Bl=e=>{const n=I(F);return B([L.GetIndividualGroupPassRates,e],async()=>n.getIndividualGroupPassRates(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})},Vl=z(e=>({box:{zIndex:9,position:"fixed",bottom:"0",width:"100%"},footer:{padding:e.spacing(2)}})),Ut=({onCancel:e,saveButtonText:n,isLoading:a,onSave:r,disableSave:l})=>{const o=Vl();return t.createElement(k,{className:o.box},t.createElement(Me,{elevation:3,className:o.footer},t.createElement(g,{container:!0,item:!0,spacing:2,justifyContent:"space-between"},t.createElement(g,{item:!0},t.createElement(H,{variant:"contained",color:"primary",onClick:e},"Cancel")),t.createElement(g,{item:!0},r&&t.createElement(H,{variant:"contained",color:"primary",disabled:a||l,onClick:r?()=>r():void 0},n)))))},Wa=Ae({selectedProgram:null,setSelectedProgram:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{}}),Gl=({children:e})=>{const[n,a]=y(null),[r,l]=y(!1),[o,s]=y(!1);return t.createElement(Wa.Provider,{value:{selectedProgram:n,setSelectedProgram:a,isLoading:r,setIsLoading:l,showAddModal:o,setShowAddModal:s}},e)},we=()=>$e(Wa),Ha=()=>Ae({selectedItem:null,setSelectedItem:()=>{},isLoading:!1,setIsLoading:()=>{},showAddModal:!1,setShowAddModal:()=>{},isReadOnly:!1,showReadOnlyModal:()=>{},hideModal:()=>{}}),qa=e=>({children:n})=>{const[a,r]=y(null),[l,o]=y(!1),[s,i]=y(!1),[c,u]=y(!1),m=p=>{o(!0),r(p)},d=()=>{r(null),o(!1),u(!1)};return t.createElement(e.Provider,{value:{selectedItem:a,setSelectedItem:r,isLoading:s,setIsLoading:i,showAddModal:c,setShowAddModal:u,isReadOnly:l,showReadOnlyModal:m,hideModal:d}},n)},Ua=e=>$e(e),Ka=Ha(),zl=qa(Ka),ae=()=>Ua(Ka),ja=Ha(),_l=qa(ja),Wl=()=>Ua(ja),Ya=Ae({selectedCollector:null,setSelectedCollector:()=>{},showModal:!1,setShowModal:()=>{},hideModal:()=>{}}),Hl=({children:e})=>{const[n,a]=y(null),[r,l]=y(!1),o=()=>{a(null),l(!1)};return t.createElement(Ya.Provider,{value:{selectedCollector:n,setSelectedCollector:a,showModal:r,setShowModal:l,hideModal:o}},e)},ot=()=>$e(Ya),ql=z(e=>({appBar:{position:"relative"},title:{flex:1,fontSize:e.typography.h6.fontSize},closeIcon:{marginRight:e.spacing(2)},content:{flex:"1 0 auto",padding:e.spacing(2),margin:"0 0 5rem",overflowX:"hidden",overflowY:"hidden",backgroundColor:e.palette.type==="dark"?"#333":e.palette.common.white}})),Ul=t.forwardRef(function(e,n){return t.createElement(er,{direction:"up",ref:n,...e})}),st=({open:e,handleClose:n,title:a,children:r})=>{const l=ql();return t.createElement(tr,{fullScreen:!0,open:e,onClose:n,TransitionComponent:Ul},t.createElement(ar,{className:l.appBar},t.createElement(nr,null,t.createElement(b,{className:l.title},a),t.createElement(Pe,{"data-testid":"close-dialog",edge:"end",color:"inherit",onClick:n,"aria-label":"close",className:l.closeIcon},t.createElement(wa,null)))),t.createElement(k,{className:l.content},r))},We=({name:e,control:n,error:a,label:r,placeholder:l,disabled:o,rules:s,messages:i,helperText:c,multiline:u,minRows:m})=>t.createElement(U,{name:e,control:n,defaultValue:"",rules:s,render:({field:d})=>t.createElement(G,{...d,fullWidth:!0,multiline:u,minRows:m,placeholder:l,label:r,disabled:o,variant:"outlined",margin:"normal",error:!!a,helperText:a&&i?i[a.type]:c})}),Kl=z(()=>({section:{gap:0}})),jl=({control:e,error:n,isLoading:a,disabled:r})=>{const l=Kl();return t.createElement("div",{className:l.section},t.createElement(We,{name:"checkName",control:e,error:n,label:"Check Name",placeholder:"Choose a name",disabled:a||r,rules:{required:!0,maxLength:100},messages:{required:"This field is required",maxLength:"Input must be less than 100 characters"}}))},Yl=z(e=>({root:{display:"flex",flexDirection:"column",gap:0},button:{marginLeft:-e.spacing(1)},title:{fontWeight:700,color:e.palette.primary.main,cursor:"pointer"}})),He=({title:e,children:n})=>{const[a,r]=y(!1),l=Yl(),o=()=>{r(!a)};return t.createElement("div",{className:l.root},t.createElement(g,{container:!0,alignItems:"center",spacing:0},t.createElement(g,{item:!0},t.createElement(Pe,{onClick:o,className:l.button},a?t.createElement(Mt,{fontSize:"large"}):t.createElement(Ra,{fontSize:"large"}))),t.createElement(g,{item:!0},t.createElement(b,{onClick:o,className:l.title},e))),t.createElement(rr,{in:a},n))},Ql=({control:e,passError:n,failError:a,isLoading:r,disabled:l})=>t.createElement(He,{title:l?"Pass and fail messages":"Pass and fail messages (optional)"},t.createElement(We,{name:"passMessage",control:e,error:n,label:"Pass Message",placeholder:"Enter pass message...",disabled:r||l}),t.createElement(We,{name:"failMessage",control:e,error:a,label:"Fail Message",placeholder:"Enter fail message...",disabled:r||l})),Xl=({control:e,error:n,isLoading:a,disabled:r})=>t.createElement(We,{name:"description",control:e,error:n,label:"Check Description",disabled:a||r,multiline:!0,minRows:4,placeholder:r?void 0:"Enter a brief description about the check",helperText:r?void 0:"Enter a brief description about the check",rules:{required:!0,maxLength:500},messages:{required:"This field is required",maxLength:"Description must be less than 500 characters"}}),Zl=x(e=>({button:{backgroundColor:e.palette.background.default,color:e.palette.primary.main},label:{paddingRight:e.spacing(2)},icon:{borderLeft:`1px solid ${e.palette.primary.main}`,padding:e.spacing(1,0,0,1)},menu:{marginTop:"52px"}})),Jl=({onAddCondition:e,onAddExpression:n})=>{const a=Zl(),[r,l]=y(null),o=!!r,s=c=>{l(c.currentTarget)},i=()=>{l(null)};return t.createElement(k,null,t.createElement(ya,{color:"primary"},t.createElement(H,{"data-testid":"add-button",id:"add-button",className:a.button,"aria-controls":o?"add-menu":void 0,"aria-haspopup":"true","aria-expanded":o?"true":void 0,onClick:s},t.createElement(k,{className:a.label},"Add"),t.createElement(k,{className:a.icon},t.createElement(Mt,null)))),t.createElement(Nt,{id:"add-menu",anchorEl:r,open:o,onClose:i,classes:{paper:a.menu},MenuListProps:{"aria-labelledby":"add-button"}},t.createElement(ge,{"data-testid":"add-condition",onClick:()=>{e(),i()}},"Add Condition"),t.createElement(ge,{"data-testid":"add-expression",onClick:()=>{n(),i()}},"Add Expression")))},Qa=({name:e,control:n,selectLabel:a,options:r,disabled:l,rules:o})=>t.createElement(U,{name:e,control:n,rules:o,render:({field:s,fieldState:i})=>t.createElement(Lt,{variant:"outlined",style:{minWidth:200}},t.createElement(St,{id:`${e}-select-label`},a),t.createElement(Dt,{...s,disabled:l,error:i.invalid,"data-testid":`${e}-select`,labelId:`${e}-select-label`,label:a},r.map(({value:c,label:u})=>t.createElement(ge,{key:c,value:c},u))))});var ie=(e=>(e.AllOf="all",e.AnyOf="any",e))(ie||{});const eo={all:"ALL OF",any:"ANY OF"};var Xa=(e=>(e.Equal="equal",e.NotEqual="notEqual",e.Matches="matches",e.LessThan="lessThan",e.LessThanInclusive="lessThanInclusive",e.GreaterThan="greaterThan",e.GreaterThanInclusive="greaterThanInclusive",e.In="in",e.NotIn="notIn",e.Contains="contains",e.DoesNotContain="doesNotContain",e.SemverGt="semverGt",e.SemverGte="semverGte",e.SemverLt="semverLt",e.SemverLte="semverLte",e.SemverEq="semverEq",e.SemverNeq="semverNeq",e.SemverSatisfies="semverSatisfies",e.SemverGtr="semverGtr",e.SemverLtr="semverLtr",e.After="after",e.Before="before",e))(Xa||{});const to={equal:"Equals",notEqual:"Does Not Equal",matches:"Matches",semverGt:"Version Greater Than",semverGte:"Version Greater Than or Equals",semverLt:"Version Less Than",semverLte:"Version Less Than or Equals",semverEq:"Version Equals",semverNeq:"Version Not Equals",semverSatisfies:"Version Satisfies Range",semverGtr:"Version Greater Than Range",semverLtr:"Version Less Than Range",lessThan:"Less Than",lessThanInclusive:"Less Than or Equals",greaterThan:"Greater Than",greaterThanInclusive:"Greater Than or Equals",in:"In Array",notIn:"Not in Array",contains:"Contains",doesNotContain:"Does Not Contain",after:"DateTime is After",before:"DateTime is Before"},ao=x(e=>({container:{borderLeft:`1px solid ${e.palette.grey[500]}`,marginLeft:e.spacing(2),padding:e.spacing(2,0,2,0),display:"flex",flexDirection:"row",alignItems:"center",gap:e.spacing(0)},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"45px"},innerContainer:{backgroundColor:e.palette.background.default,border:`1px solid ${e.palette.grey[500]}`,display:"flex",flexDirection:"column"},inputsContainer:{padding:e.spacing(2),display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:e.spacing(1)},header:{background:"linear-gradient(90deg, #007DFF 0%, #0057B2 100%)",width:"100%",height:"8px"},deleteButton:{marginLeft:e.spacing(1),width:"45px",height:"45px"},deleteIcon:{color:e.palette.type==="dark"?e.palette.background.default:e.palette.common.black}}));function Za(e){const n=I(F);return B([L.GetCollectors,e],async()=>n.getCollectors(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}function no(e,n){const a=I(F);return B([L.GetFactSchema,e,n],()=>a.getFactSchema(e,n),{enabled:!!e&&!!n,staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const it=()=>({selectedKinds:[],selectedLifecycles:[],selectedOwners:[],selectedSystems:[],selectedTags:[],selectedTypes:[]}),ro=[{facet:"kind",label:"Kind",key:"selectedKinds"},{facet:"spec.type",label:"Type",key:"selectedTypes"},{facet:"spec.lifecycle",label:"Lifecycle",key:"selectedLifecycles"},{facet:"spec.owner",label:"Owner",key:"selectedOwners"},{facet:"spec.system",label:"System",key:"selectedSystems"},{facet:"metadata.tags",label:"Tags",key:"selectedTags"}],Te={selectedKinds:"kind",selectedTypes:"spec.type",selectedLifecycles:"spec.lifecycle",selectedOwners:"spec.owner",selectedSystems:"spec.system",selectedTags:"metadata.tags"},Ja=e=>!e||Object.values(e).every(n=>n.length===0)?void 0:{catalog:Object.entries(e).reduce((n,[a,r])=>{const l=Te[a];return r.length>0&&(n[l]=r),n},{})},en=e=>Object.keys(Te).reduce((n,a)=>{var r,l;return n[a]=Bt((l=(r=e==null?void 0:e.catalog)==null?void 0:r[Te[a]])!=null?l:[]),n},{}),ct=e=>{if(!e||Object.values(e).every(a=>a.length===0))return;const n={};for(const[a,r]of Object.entries(e))(r==null?void 0:r.length)>0&&(n[Te[a]]=r);return[n]},Kt=e=>{if(e&&Array.isArray(e)&&e.length){const n=e[0];return Object.keys(Te).reduce((a,r)=>{var l;return a[r]=Bt((l=n==null?void 0:n[Te[r]])!=null?l:[]),a},{})}return it()};var A=(e=>(e.Months="months",e.Weeks="weeks",e.Days="days",e.Hours="hours",e.Minutes="minutes",e.Seconds="seconds",e))(A||{});const jt=()=>({type:"HumanDuration",unit:A.Hours,value:1,cron:""}),Yt=[A.Months,A.Weeks,A.Days,A.Hours,A.Minutes,A.Seconds];function lo(e){return Yt.includes(e)}function dt(e){switch(e){case"months":return A.Months;case"weeks":return A.Weeks;case"days":return A.Days;case"hours":return A.Hours;case"minutes":return A.Minutes;case"seconds":return A.Seconds;default:return null}}function Qt(e){if(e){const{cron:n,type:a,unit:r,value:l}=e;return a==="HumanDuration"?{[r]:l}:{cron:n}}}function Xt(e){var n;const a=jt();if(e&&Ve.isObject(e)){if("cron"in e)return{...a,type:"cron",cron:e.cron};const r=Object.entries(e);if(r.length){const[l,o]=r[0];return{...a,unit:(n=dt(l))!=null?n:A.Hours,value:o}}}return a}const oo=e=>Ur(e).isValid(),tn=e=>{try{return Kr.toString(e)}catch(n){return typeof n=="string"?n.replace(/^Error:\s*/,""):"Invalid cron expression"}},an=1,nn=31536e3,rn=e=>{if(e){if(isNaN(e))return"Invalid value";if(e<1)return"Minimum of 1";if(e>31536e3)return"Maximum exceeded"}else return"Enter a value";return!0},so=x(e=>({divider:{marginTop:e.spacing(3),marginBottom:e.spacing(3)},title:{cursor:"pointer"}})),ln=({value:e,onChange:n,disabled:a,errors:r})=>{var l;const o=so(),[s,i]=y(e),[c,u]=y(`${e.value}`);$(()=>{n&&n(s)},[s,n]);const m=E=>{i({...e,type:E.target.value})},d=E=>{u(E.target.value);const f=parseInt(E.target.value,10);i({...e,value:isNaN(f)?0:f})},p=E=>{var f;i({...s,unit:(f=dt(E.target.value))!=null?f:A.Hours})},h=E=>{const f=E.target.value;i({...s,cron:f})},v=()=>{i({...s,type:"cron"})},C=()=>{i({...s,type:"HumanDuration"})};return t.createElement(g,{container:!0,direction:"row"},t.createElement(g,{item:!0},t.createElement(lr,{name:"frequencyType",value:s.type,onChange:m},t.createElement(g,{container:!0,alignItems:"flex-start"},t.createElement(g,{item:!0,style:{paddingLeft:0}},t.createElement(Ca,{disabled:a,value:"HumanDuration"})),t.createElement(g,{item:!0},t.createElement(b,{variant:"body1",className:o.title,onClick:C},"Run on a regular interval"),t.createElement(b,{variant:"caption"},"Run on a regular interval that you define"),s.type==="HumanDuration"&&t.createElement(g,{container:!0,style:{alignItems:"flex-start"}},t.createElement(g,{item:!0},t.createElement(G,{id:"every",type:"number",inputProps:{min:an,max:nn},label:"Every",name:"every",disabled:a,value:c,error:!!(r!=null&&r.message),helperText:r==null?void 0:r.message,onChange:d})),t.createElement(g,{item:!0},t.createElement(Lt,null,t.createElement(St,{id:"frequency-unit"},"Unit"),t.createElement(Dt,{labelId:"frequency-unit",disabled:a,value:s.unit,onChange:p,"data-testid":"frequency-unit"},Yt.map(E=>t.createElement(ge,{key:E,value:E},E)))))))),t.createElement(Xe,{className:o.divider}),t.createElement(g,{container:!0,alignItems:"flex-start"},t.createElement(g,{item:!0,style:{paddingLeft:0}},t.createElement(Ca,{disabled:a,value:"cron"})),t.createElement(g,{item:!0},t.createElement(b,{variant:"body1",className:o.title,onClick:v},"Run on a schedule"),t.createElement(b,{variant:"caption"},"Run on a schedule defined via cron expression"),s.type==="cron"&&t.createElement(g,{item:!0},t.createElement(G,{id:"cron-expression","data-testid":"cron-expression",style:{minWidth:250},label:(l=r==null?void 0:r.message)!=null?l:tn(s.cron),disabled:a,placeholder:"* * * * *",error:!!(r!=null&&r.message),value:s.cron,onChange:h})))))))},io=(e,n,a,r)=>{const l={};return r&&r.forEach(o=>{var s,i,c;o&&(l[o.id]={id:o.id,name:(s=o.name)!=null?s:o.id,description:(i=o.description)!=null?i:"",filter:(c=o.filter)!=null?c:void 0})}),e.map((o,s)=>{const i=o.map(c=>l[c.id]);return{name:n[s],description:a[s],ordinal:s+1,checks:i}})},co=e=>e.map(n=>n.checks.map(a=>{var r;return{id:a.id,label:(r=a.name)!=null?r:a.id}})),mo=e=>{var n;return{id:e.id,name:e.name,description:e.description||"",ownerEntityRef:e.ownerEntityRef,documentationURL:e.documentationURL||"",levels:((n=e.levels)==null?void 0:n.map(a=>({ordinal:a.ordinal,name:a.name||"",description:a.description||"",checks:a.checks.map(r=>({id:r.id,name:r.name,description:r.description}))})))||[],filter:e.filter}},uo=e=>{var n;if(qr(e)&&"frequency"in e){const a=Fr.safeParse(e.frequency);if(a.success){const r=a.data;if("cron"in r)return{enabled:!0,frequency:{type:"cron",unit:A.Hours,value:1,cron:r.cron}};const l=Object.keys(r);if(l.length){const o=l[0];if(lo(o))return{enabled:!0,frequency:{type:"HumanDuration",unit:o,value:(n=r[o])!=null?n:1,cron:""}}}}}return{enabled:!1,frequency:{type:"HumanDuration",unit:A.Hours,value:1,cron:""}}},po=(e,n)=>{const{enabled:a,frequency:r}=e;if(a){const{cron:l,type:o,unit:s,value:i}=r;return o==="HumanDuration"?{frequency:{[s]:i},filter:ct(n)}:{frequency:{cron:l}}}},ho=(e,n)=>{const a=e?co(e.levels):[[]],r=a.flat().map(o=>o.id),l=n.filter(o=>!r.includes(o.id));return{inputChips:a,used:l}},go=()=>({enabled:!1,frequency:jt()}),Zt=e=>{var n;if(!e)return{};if(e.expressionType){const a={[e.expressionType]:(n=e.conditions)==null?void 0:n.map(r=>({factRef:r.factRef,path:r.path,operator:r.operator,value:r.value}))};return e.expressions&&e.expressions.forEach(r=>{var l;(l=a[e.expressionType])==null||l.push(Zt(r))}),a}if(e.expressions)return e.expressions.map(Zt);if(e.conditions&&e.conditions.length===1){const a=e.conditions[0];return{factRef:a.factRef,path:a.path,operator:a.operator,value:a.value}}return{}},on=(e,n=!0)=>{if(!e)return{conditions:[]};const a=Object.keys(e),r=a.includes("all")||n&&!a.includes("any")?ie.AllOf:ie.AnyOf;if(a.includes(r)||n){const l=e[r]||[e],o=[],s=[];return l.forEach(i=>{const c=Object.keys(i);c.includes("all")||c.includes("any")?s.push(on(i,!1)):o.push({factRef:i.factRef,path:i.path,operator:i.operator,value:i.value})}),{expressions:s.length>0?s:void 0,conditions:o,expressionType:r}}return{expressionType:ie.AllOf,conditions:[{factRef:e.factRef,path:e.path,operator:e.operator,value:e.value}]}},vo=e=>({checkName:e.name||"",description:e.description||"",teamOwner:e.ownerEntityRef||"",supportChannel:e.supportChannel||"",expressions:on(e.rule),passMessage:e.passedMessage||void 0,failMessage:e.failedMessage||void 0,filters:en(e.filter),schedule:uo(e.schedule)}),Eo=(e,n)=>{var a,r,l,o;return{id:n?n.id:La(),ownerEntityRef:(a=e.teamOwner)!=null?a:void 0,name:e.checkName,description:e.description,passedMessage:(r=e.passMessage)!=null?r:void 0,failedMessage:(l=e.failMessage)!=null?l:void 0,rule:Zt(e.expressions),filter:e.filters?Ja(e.filters):void 0,supportChannel:(o=e.supportChannel)!=null?o:void 0,schedule:po(e.schedule,e.filters)}},Jt=(e,n="$")=>{const a=[];if(e.type==="object"&&e.properties){const r=e.properties;for(const l in r)if(r.hasOwnProperty(l)){const o=`${n}.${l}`;a.push(o);const s=r[l];a.push(...Jt(s,o))}}if(e.type==="array"&&e.items){const r=`${n}[*]`;a.push(r);const l=Array.isArray(e.items)?e.items:[e.items];for(const o of l)a.push(...Jt(o,r))}return a},fo={checkName:"",description:"",teamOwner:"",supportChannel:"",expressions:{expressionType:ie.AllOf,expressions:void 0,conditions:[{factRef:"",path:"",operator:"",value:"",conditions:[]}]},filters:it(),schedule:go()},yo=(e,n)=>{const{data:a,isLoading:r}=Za(),l=$t({control:n,name:`${e}.factRef`}),[o,s]=y(()=>sn(l));$(()=>{s(sn(l))},[l]);const{data:i}=no(o==null?void 0:o.source,o==null?void 0:o.name),c=_(()=>i?Jt(i.schema):[],[i]),u=_(()=>a==null?void 0:a.flatMap(m=>m.factNames.map(d=>{const p=Vt(d,{defaultSource:m.id,defaultScope:"default"});return{label:p.name,value:Ar(p)}})),[a]);return{isLoading:r,pathOptions:c,factRefOptions:u}};function sn(e){if(e)try{return Vt(e,{defaultSource:"unknown",defaultScope:"default"})}catch{return null}return null}const cn=({name:e,rules:n,label:a,control:r,options:l,getOptionLabel:o,getOptionValue:s,onChange:i,onInputChange:c,disabled:u})=>t.createElement(U,{name:e,control:r,rules:n,render:({field:m,fieldState:d})=>t.createElement(Gt,{...m,freeSolo:!0,"data-testid":`${e}-autocomplete`,style:{minWidth:250},disabled:u,options:l,getOptionLabel:o,renderInput:p=>t.createElement(G,{...p,variant:"outlined",label:a,error:d.invalid,helperText:d.error?d.error.message:null}),onChange:(p,h)=>{const v=s?s(h):h;i==null||i(v),m.onChange(v)},onInputChange:(p,h)=>{const v=s?s(h):h;c==null||c(v),m.onChange(v)}})}),Co=e=>{try{return Vt(e),!0}catch{return"Invalid fact reference. [source]:[scope]/[name]."}},bo=({control:e,name:n,handleDelete:a,disabled:r,disableDelete:l,setValue:o,getValues:s})=>{var i;const c=ao(),u=_(()=>Object.values(Xa).map(f=>({value:f,label:to[f]})),[]),{pathOptions:m,factRefOptions:d,isLoading:p}=yo(n,e),h={required:!0},v=_(()=>{var f;return(f=d==null?void 0:d.map(P=>P.value))!=null?f:[]},[d]),C=(i=s("expressions.conditions"))==null?void 0:i.map(({factRef:f})=>f),E=f=>{f&&!(C!=null&&C.includes(f))&&(o(`${n}.path`,""),o(`${n}.operator`,""),o(`${n}.value`,""))};return t.createElement(k,{className:c.container},t.createElement(k,{className:c.connector}),t.createElement(k,{className:c.innerContainer},t.createElement(k,{className:c.header}),t.createElement(k,{className:c.inputsContainer},d&&t.createElement(cn,{name:`${n}.factRef`,control:e,rules:{...h,maxLength:500,validate:Co},label:"Fact",options:v,getOptionLabel:f=>{var P,T;return(T=(P=d==null?void 0:d.find(S=>f===S.value))==null?void 0:P.label)!=null?T:f},getOptionValue:f=>{var P,T,S;return(S=(T=(P=d==null?void 0:d.find(N=>f===N.label))==null?void 0:P.value)!=null?T:f)!=null?S:""},disabled:r||p,onChange:E,onInputChange:E}),t.createElement(cn,{name:`${n}.path`,label:"Path",rules:h,control:e,disabled:r||p,options:m}),t.createElement(Qa,{name:`${n}.operator`,rules:h,control:e,selectLabel:"Operator",options:u,disabled:r}),t.createElement(U,{name:`${n}.value`,control:e,defaultValue:"",rules:h,render:({field:f,fieldState:P})=>t.createElement(G,{...f,label:"Value",variant:"outlined",placeholder:"Enter a value",error:P.invalid,helperText:P.error?P.error.message:null,disabled:r})}))),!r&&!l&&t.createElement(Pe,{onClick:a,className:c.deleteButton,"data-test-id":`${n}-delete-button`},t.createElement(Na,{className:c.deleteIcon})))},ko=({conditions:e,control:n,name:a,handleDelete:r,disabled:l,disableDelete:o,setValue:s,getValues:i,depth:c})=>t.createElement(t.Fragment,null,e.map((u,m)=>t.createElement(g,{item:!0,key:m},t.createElement(bo,{control:n,name:`${a}.conditions[${m}]`,"data-testid":`${a}-condition-input`,handleDelete:()=>r(m),disabled:l,disableDelete:c===0&&m===0?!0:o,setValue:s,getValues:i})))),xo=({expression:e,control:n,name:a,depth:r,getValues:l,setValue:o,trigger:s,disabled:i})=>e?t.createElement(g,{item:!0},t.createElement(dn,{control:n,name:`${a}`,depth:r+1,getValues:l,setValue:o,trigger:s,disabled:i})):null,Po=x(e=>({button:{fontWeight:700,backgroundColor:e.palette.background.default,color:e.palette.primary.main,"&:hover":{backgroundColor:"rgba(46, 119, 208, 0.2)"}},selectedButton:{backgroundColor:"rgba(46, 119, 208, 0.15)"}})),wo=({control:e,name:n,getValues:a,disabled:r})=>{const l=Po(),o=`${n}`,s=a(o),[i,c]=y(s||ie.AllOf),u=m=>{c(m)};return t.createElement(U,{control:e,name:n,render:({field:{onChange:m}})=>t.createElement(ya,{color:"primary"},Object.values(ie).map(d=>t.createElement(H,{key:d,className:i===d?`${l.selectedButton} ${l.button}`:`${l.button}`,onClick:()=>{u(d),m(d)},disabled:r},eo[d])))})},To=(e,n,a,r)=>({handleAddCondition:async()=>{const l=`${e}`,o=n(l),s=[...(o==null?void 0:o.conditions)||[],{factRef:"",path:"",operator:"",value:""}],i=`${e}.conditions`;a(i,s),await r(i)},handleAddExpression:async()=>{const l=`${e}.expressions`,o=n(l)||[];o.push({expressionType:ie.AllOf,expressions:void 0,conditions:[{factRef:"",path:"",operator:"",value:""}]}),a(l,o),await r(l)},handleDeleteCondition:async(l,o)=>{const s=o.split("[")[0],i=`${o}.conditions`,c=n(i);if(c.splice(l,1),c.length===0){a(i,void 0);const u=parseInt(o.slice(o.lastIndexOf("[")+1,o.lastIndexOf("]")),10),m=n(s);m.splice(u,1),a(s,m.length>0?m:void 0),await r(s)}else a(i,c),await r(i)}}),Ro=z(e=>({root:{backgroundColor:e.palette.type==="dark"?e.palette.grey[700]:e.palette.grey[100],border:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(2)},inner:{marginLeft:e.spacing(2),paddingBottom:e.spacing(2),borderLeft:`1px solid ${e.palette.grey[500]}`,display:"flex",flexDirection:"row",gap:0},connector:{borderBottom:`1px solid ${e.palette.grey[500]}`,padding:e.spacing(0),width:"15px",height:"20px"}})),dn=({control:e,name:n,depth:a,getValues:r,setValue:l,trigger:o,disabled:s})=>{const i=Ro(),{handleAddCondition:c,handleAddExpression:u,handleDeleteCondition:m}=To(n,r,l,o),d=`${n}`,p=r(d),h=(p==null?void 0:p.conditions)||[],v=p==null?void 0:p.expressions;return t.createElement(k,{className:a>0?i.inner:i.root},a>0&&t.createElement(k,{className:i.connector}),t.createElement(g,{container:!0,spacing:0,direction:"column"},t.createElement(g,{item:!0},t.createElement(wo,{control:e,disabled:s,name:`${n}.expressionType`,getValues:r})),t.createElement(g,{item:!0,container:!0,spacing:0,direction:"column"},t.createElement(ko,{depth:a,handleDelete:C=>m(C,n),disabled:s,conditions:h,control:e,name:n,setValue:l,getValues:r}),v==null?void 0:v.map((C,E)=>t.createElement(xo,{key:E,expression:C,control:e,name:`${n}.expressions[${E}]`,depth:a,getValues:r,setValue:l,trigger:o,disabled:s}))),!s&&t.createElement(g,{item:!0},t.createElement(Jl,{onAddCondition:c,onAddExpression:u}))))},No=({control:e,supportContactError:n,disabled:a,isLoading:r,options:l})=>{var o;return t.createElement(He,{title:a?"Owner Details":"Owner Details (optional)"},t.createElement(Qa,{name:"teamOwner",control:e,selectLabel:"Owner",options:(o=l==null?void 0:l.map(s=>({value:s.ref,label:s.name})))!=null?o:[],disabled:a||r}),t.createElement(We,{name:"supportChannel",control:e,error:n,label:"Support channel",placeholder:"Enter a channel or email to get check support",disabled:a||r,rules:{},messages:{}}))},mt=e=>{const n=I(Pr),a=I(Qr);return B([L.GetEntityFacets,e],async()=>{var r;return((r=(await a.getEntityFacets({facets:[e]})).facets[e])==null?void 0:r.map(l=>l.value).sort())||[]},{onError:()=>{n.post({message:`Failed to load facet: ${e}`,severity:"error"})}})},Lo=x({container:{padding:0},formControl:{flexGrow:1}}),So=({facet:e,label:n,values:a,onChange:r,disabled:l})=>{var o;const s=Lo(),{data:i,isLoading:c,error:u}=mt(e),m=_(()=>i==null?void 0:i.map(C=>C.toLocaleLowerCase("en-US")),[i]),d=(o=a==null?void 0:a.map(C=>C.toLocaleLowerCase("en-US")))!=null?o:[],p=ee((C,E)=>{r(m&&m.every(f=>E.includes(f))?void 0:E)},[m,r]),h=ee(()=>{r(a!=null&&a.length?a:void 0)},[a,r]);if(!i||!m||u)return t.createElement(b,{color:"error"},"Failed to load facet: ",e);const v=l||c||!(a!=null&&a.length)&&(!(i!=null&&i.length)||!(m!=null&&m.length));return t.createElement(k,{pb:1,pt:1,className:s.container},t.createElement(b,{variant:"subtitle2"},n),t.createElement(Gt,{className:s.formControl,multiple:!0,limitTags:4,disableCloseOnSelect:!0,"aria-label":n,options:m,value:d,getOptionLabel:C=>{var E;return(E=i[m.indexOf(C)])!=null?E:C},onChange:p,onBlur:h,disabled:v,renderOption:(C,{selected:E})=>{var f;return t.createElement(Ze,{control:t.createElement(Be,{icon:t.createElement(Ia,{fontSize:"small"}),checkedIcon:t.createElement(Da,{fontSize:"small"}),checked:E}),label:(f=i[m.indexOf(C)])!=null?f:C})},size:"small",popupIcon:t.createElement(Yr,{"data-testid":"selected-facets-expand"}),renderInput:C=>t.createElement(G,{...C,variant:"outlined"})}))},Do=x(()=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap"}})),ea=({value:e,onChange:n,disabled:a})=>{const r=Do(),l=o=>s=>{n({...e,[o]:s!=null?s:[]})};return t.createElement(g,{container:!0,className:r.filterContainer,spacing:2},ro.map(o=>t.createElement(g,{item:!0,xs:12,sm:6,md:4,key:o.key},t.createElement(So,{facet:o.facet,label:o.label,values:e==null?void 0:e[o.key],onChange:l(o.key),disabled:a}))))},Io=x(e=>({title:{fontWeight:700},container:{padding:e.spacing(0,1.5)},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)}})),Oo=({control:e,disabled:n})=>{const a=Io();return t.createElement(He,{title:n?"Filters":"Filters (optional)"},t.createElement(g,{className:a.container,item:!0,xs:12},!n&&t.createElement(b,{variant:"body2"},"Apply filters so it's only applicable to relevant entities."),t.createElement(g,{item:!0,xs:12},t.createElement(Me,null,t.createElement(U,{name:"filters",control:e,render:({field:r})=>{var l;return t.createElement(ea,{value:(l=r.value)!=null?l:it(),onChange:r.onChange})}})))))},mn=({type:e,cron:n,value:a})=>{if(e==="cron"){if(!oo(n))return tn(n)}else if(e==="HumanDuration")return rn(a);return!0},Fo=x(e=>({container:{padding:e.spacing(0,1.5)}})),Ao=({control:e,disabled:n})=>{const a=Fo(),r=$t({control:e,name:"schedule"});return t.createElement(g,{className:a.container,item:!0,xs:12},t.createElement(g,{item:!0},t.createElement(U,{name:"schedule.enabled",control:e,render:({field:l})=>t.createElement(Ze,{disabled:n,control:t.createElement(Be,{checked:l.value,onChange:l.onChange}),label:"Schedule check"})})),t.createElement(g,{item:!0},t.createElement(U,{name:"schedule.frequency",control:e,rules:{validate:mn},render:({field:l})=>t.createElement(ln,{disabled:n||!r.enabled,value:l.value,onChange:l.onChange})})))},$o=x(e=>({container:{padding:e.spacing(0,1.5)},scheduleContainer:{padding:e.spacing(2)}})),Mo=({control:e,disabled:n})=>{const a=$o();return t.createElement(He,{title:n?"Schedule":"Schedule (optional)"},t.createElement(g,{className:a.container,item:!0,xs:12},t.createElement(g,{item:!0},t.createElement(b,{variant:"body2"},"By default checks are execute when any fact they depend on is updated. However, you may also schedule a check to run on a schedule.")),t.createElement(g,{item:!0,xs:12},t.createElement(Me,{className:a.scheduleContainer},t.createElement(Ao,{disabled:n,control:e})))))},Bo=e=>{const{selectedItem:n}=ae();let a=fo;n&&(a=vo(n));const{control:r,handleSubmit:l,getValues:o,setValue:s,trigger:i,formState:{errors:c}}=Ta({defaultValues:a}),{showModal:u}=at();return{control:r,handleSubmit:l,getValues:o,setValue:s,trigger:i,errors:c,onSubmit:async m=>{if(!await u({title:"Save Check",message:`Are you sure you want to save check: ${m.checkName}?`,error:!1}))return;const d=Eo(m,n);e(d)}}},Vo=()=>t.createElement("div",{style:{display:"flex",gap:"10px",flexDirection:"column"}},t.createElement(b,{variant:"h6"},"Creating and managing checks"),t.createElement(b,{variant:"body1"},"Checks are entities created from four components: facts, paths, operators and values. These components are then organized via a boolean calculator in the UI."),t.createElement(b,{variant:"body1"},"To create a check, select the components that you want to use, organize them into rules and give your check a meaningful name and a description."),t.createElement(b,{variant:"body1"},"Once created, you will be able to manage and edit your track on its detail page.")),un=z(e=>({root:{overflow:"hidden",display:"flex",marginBottom:"53px"},card:{padding:e.spacing(3),display:"flex",gap:e.spacing(2.5)},sectionLabel:{fontWeight:700,margin:e.spacing(2,0),color:e.palette.primary.main}})),ta=({title:e,open:n,onSave:a})=>{const r=un(),{hideModal:l,isLoading:o,isReadOnly:s}=ae(),{control:i,handleSubmit:c,getValues:u,setValue:m,trigger:d,errors:p,onSubmit:h}=Bo(a),{options:v}=Er();return t.createElement(st,{handleClose:l,title:e,open:n},t.createElement("form",{onSubmit:c(h)},t.createElement(g,{container:!0,spacing:2,className:r.root},t.createElement(g,{item:!0,xs:9},t.createElement(It,{className:r.card},t.createElement(b,{className:r.sectionLabel,style:{margin:0}},"Check Details"),t.createElement(jl,{control:i,error:p.checkName,isLoading:o,disabled:s}),t.createElement(Xl,{control:i,error:p.description,isLoading:o,disabled:s}),t.createElement(No,{control:i,disabled:s,isLoading:o,options:v}),t.createElement(b,{className:r.sectionLabel},"Rules"),t.createElement(dn,{control:i,getValues:u,setValue:m,trigger:d,disabled:s,name:"expressions",depth:0}),t.createElement(Oo,{control:i,disabled:s}),t.createElement(Ql,{control:i,passError:p.passMessage,failError:p.failMessage,isLoading:o,disabled:s}),t.createElement(Mo,{control:i,disabled:s}))),t.createElement(g,{item:!0,xs:3},t.createElement(Vo,null))),t.createElement(g,{container:!0,spacing:4,className:r.root},t.createElement(Ut,{onCancel:l,saveButtonText:"Save Check",isLoading:o,onSave:s?void 0:c(h)}))))},Go="Error Creating Check";function zo(){const e=I(F),n=Ee(),{showAlert:a}=se(),r=async l=>{const o=await e.updateCheck(l);if(!o)throw new Error("Failed to update check.");return o};return fe([ye.UpdateCheck],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[L.GetChecks]})},onError:l=>{let o="Failed to update check.";l instanceof Error&&(o=l.message),a({severity:"error",title:Go,message:o})}})}const _o=()=>{const{selectedItem:e,hideModal:n}=ae(),{setIsLoading:a}=ae(),{mutateAsync:r,isLoading:l}=zo();return $(()=>{a(l)},[a,l]),t.createElement(ta,{title:"Edit a Check",open:!!e,onSave:async o=>{await r(o)&&n()}})},Wo="Error Creating Check";function Ho(){const e=I(F),n=Ee(),{showAlert:a}=se(),r=async l=>{const o=await e.createCheck(l);if(!o)throw new Error("Failed to create check.");return o};return fe([ye.CreateCheck],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[L.GetChecks]})},onError:l=>{let o="Failed to create check.";l instanceof Error&&(o=l.message),a({severity:"error",title:Wo,message:o})}})}const qo=()=>{const{hideModal:e,showAddModal:n,setIsLoading:a}=ae(),{mutateAsync:r,isLoading:l}=Ho();return $(()=>{a(l)},[a,l]),t.createElement(ta,{title:"Create a Check",open:n,onSave:async o=>{await r(o,{onSuccess:()=>e()})}})},Uo=({handleDelete:e})=>{const[n,a]=y(null),r=!!n,l=s=>{s.stopPropagation(),a(s.currentTarget)},o=s=>{s.stopPropagation(),a(null)};return t.createElement(t.Fragment,null,t.createElement(Pe,{"aria-label":"summary-card-actions",id:"summary-card-action-menu-button","aria-controls":r?"summary-card-action-menu":void 0,"aria-expanded":r?"true":void 0,"aria-haspopup":"true",onClick:l},t.createElement(Jr,null)),t.createElement(Nt,{id:"summary-card-action-menu",anchorEl:n,open:r,onClose:o,getContentAnchorEl:null,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{"aria-labelledby":"summary-card-action-menu-button"}},e&&t.createElement(ge,{"data-testid":"summary-card-action-delete",onClick:s=>{e(s),o(s)}},t.createElement(Q,null,t.createElement(Na,{fontSize:"small"})),t.createElement(X,null,"Delete"))))},Ko=or(e=>vr({root:{width:"100%",height:"100%",minHeight:"385px",display:"flex",flexDirection:"column",padding:e.spacing(2),position:"relative"}}))(It),jo=x(e=>({root:{position:"relative",height:"100%"},summaryName:{fontSize:e.typography.pxToRem(24),color:e.palette.primary.main,maxHeight:"250px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical","-webkit-line-clamp":4,"-webkit-box-orient":"vertical",wordBreak:"break-word"},summaryDescription:{padding:0,maxHeight:"175px",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical",wordBreak:"break-word"},card:{paddingTop:e.spacing(1),paddingBottom:0,paddingLeft:e.spacing(1),paddingRight:e.spacing(1)}})),qe=({title:e,description:n,viewLabel:a="View",editLabel:r="Edit",children:l,handleDelete:o,handleEdit:s,handleView:i})=>{const c=jo();return t.createElement(Ko,{className:c.card,"data-testid":e},t.createElement(sr,{title:e,titleTypographyProps:{className:c.summaryName},subheader:t.createElement(fa,{className:c.summaryDescription,content:n!=null?n:""}),action:o&&t.createElement(Uo,{handleDelete:o})}),t.createElement(ir,null,l),t.createElement(Xe,null),t.createElement(cr,null,t.createElement(H,{"aria-label":s?r:a,"data-testid":`${e}-button`,size:"medium",color:"primary",role:"link",onClick:s||i,disabled:!i&&!s},s?r:a)))},Yo="Error Deleting Check";function Qo(){const e=I(F),n=Ee(),{showAlert:a}=se(),r=async l=>{const o=await e.deleteCheck(l);if(!o)throw new Error(`Failed to delete check ${l}`);return o};return fe([ye.DeleteCheck],r,{onSuccess:()=>Promise.all([n.invalidateQueries({queryKey:[L.GetChecks]}),n.invalidateQueries({queryKey:[L.GetAllPrograms]})]),onError:(l,o)=>{let s=`Failed to delete check ${o}`;l instanceof Error&&(s=l.message),a({severity:"error",title:Yo,message:s})}})}const Xo=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Zo=({check:e})=>{var n;const a=Xo();return t.createElement(Je,{dense:!0,disablePadding:!0,className:a.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Check Details"),t.createElement(oe,{disableGutters:!0,className:a.listItem},t.createElement(K,{title:"Owner"},t.createElement(Q,null,t.createElement(nt,{color:"action",fontSize:"small"}))),t.createElement(X,{className:a.listItemText,primary:t.createElement(Ge,{entityRef:(n=e.ownerEntityRef)!=null?n:"No Owner"})})))},Jo=({check:e})=>{const{id:n,name:a,description:r,isEditable:l,ownerEntityRef:o}=e,{loading:s,allowed:i}=te({permission:$r,resourceRef:n}),{loading:c,allowed:u}=te({permission:Mr,resourceRef:n}),{showModal:m}=at(),{mutate:d}=Qo(),{showReadOnlyModal:p,setSelectedItem:h}=ae(),v=ee(async()=>{await m({title:"Delete Check",message:`Are you sure you want to delete the check '${a!=null?a:n}'?`})&&d(n)},[m,a,d,n]);return t.createElement(qe,{title:a!=null?a:n,description:r,children:o&&t.createElement(Zo,{check:e}),handleView:()=>p(e),handleEdit:l&&!s&&i?()=>h(e):void 0,handleDelete:l&&!c&&u?v:void 0})},pn=()=>t.createElement(t.Fragment,null,Array.from({length:10},(e,n)=>t.createElement(g,{key:`loading-${n}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(zt,{variant:"rect",height:385})))),es=x(()=>({searchIcon:{opacity:".5"},clearButton:{height:"36px",width:"36px"}})),aa=({searchTerm:e,setSearchTerm:n,showClear:a=!0,placeholder:r="Search...",...l})=>{const o=es(),s=c=>{n(c.target.value)},i=()=>{n("")};return t.createElement(G,{...l,fullWidth:!0,placeholder:r,value:e,onChange:s,InputProps:{startAdornment:t.createElement(ba,{position:"start"},t.createElement(el,{className:o.searchIcon,"data-testid":"search-icon"})),endAdornment:a&&e?t.createElement(ba,{position:"end"},t.createElement(Pe,{edge:"end",onClick:i,className:o.clearButton},t.createElement(wa,null))):null}})},ts=x(()=>({searchbar:{maxWidth:"350px"},filters:{display:"flex",alignItems:"center"},dropdownFilters:{margin:"0 15px",display:"flex",alignItems:"center"},selectHolder:{marginLeft:"10px"}})),na=({searchPlaceholder:e,isLoading:n,searchTerm:a,setSearchTerm:r,filterAlpha:l,handleAlphabeticalFilterChange:o,filterOwner:s,handleOwnerFilterChange:i,owners:c})=>{const u=ts();return t.createElement(g,{item:!0,xs:9,className:u.filters},t.createElement(aa,{searchTerm:a,disabled:n,setSearchTerm:r,placeholder:e||"Search",variant:"outlined",size:"small",className:u.searchbar}),t.createElement("div",{className:u.dropdownFilters},t.createElement(b,null,"Sort by: "),t.createElement(ka,{className:u.selectHolder,value:l,onChange:o},t.createElement("option",{value:"default"},"Default"),t.createElement("option",{value:"ascending"},"Name A-Z"),t.createElement("option",{value:"descending"},"Name Z-A"))),t.createElement("div",{className:u.dropdownFilters},t.createElement(b,null,"Filter by owner: "),t.createElement(ka,{className:u.selectHolder,value:s,onChange:i},t.createElement("option",{key:"all",value:"all"},"All"),c==null?void 0:c.map((m,d)=>t.createElement("option",{key:m+d,value:m},m)))))},as=(e,n)=>e==null?void 0:e.sort((a,r)=>{var l,o,s,i;const c=(o=(l=a==null?void 0:a.name)==null?void 0:l.toLocaleLowerCase())!=null?o:a==null?void 0:a.id.toLocaleLowerCase(),u=(i=(s=r==null?void 0:r.name)==null?void 0:s.toLocaleLowerCase())!=null?i:r==null?void 0:r.id.toLocaleLowerCase();return!c||!u?0:c<u?n==="ascending"?-1:1:c>u?n==="ascending"?1:-1:0}),hn=e=>{const n=e==null?void 0:e.map(a=>a==null?void 0:a.ownerEntityRef).filter(a=>a!=="");return[...new Set(n)]},Re=({searchTermProp:e,filterAlphaProp:n,filterOwnerProp:a,checks:r,tracks:l})=>{var o,s;const i=r||l||[],c=(o=i==null?void 0:i.filter)==null?void 0:o.call(i,m=>{var d;return((d=m==null?void 0:m.name)!=null?d:m==null?void 0:m.id).toLocaleLowerCase().includes(e.toLocaleLowerCase())}),u=a&&a!=="all"?(s=c==null?void 0:c.filter)==null?void 0:s.call(c,m=>{var d;return((d=m==null?void 0:m.ownerEntityRef)==null?void 0:d.toLowerCase())===a.toLowerCase()}):c;return n==="default"?u:as(u!=null?u:[],n)},ns=x(e=>({pagination:{width:"-webkit-fill-available",display:"flex",justifyContent:"center",position:"fixed",bottom:"0",backgroundColor:e.palette.type==="dark"?"#333333":"#F8F8F8",marginRight:"40px"}})),ra=({response:e,listingsPerPage:n,cursor:a,setCursor:r,prevCursors:l,setPrevCursors:o,labelPerPageDropdown:s,urlRoute:i})=>{var c;const u=ns(),m=e!=null&&e.edges?e==null?void 0:e.edges[(e==null?void 0:e.edges.length)-1]:{cursor:""},[d,p]=y(0),h=()=>{o(f=>[...f,a]),r(m==null?void 0:m.cursor)},v=()=>{r(l[l.length-1]),o(f=>f.slice(0,-1))},C=(f,P)=>{p(T=>(P>T?h():v(),P))},E=f=>{window.open(`/soundcheck/${i!=null?i:"tracks?tracksPerPage="}${f.target.value}`,"_self")};return t.createElement(Ot,{className:u.pagination,component:"div",count:(c=e==null?void 0:e.totalCount)!=null?c:-1,rowsPerPage:n!=null?n:10,onPageChange:C,page:d,onRowsPerPageChange:E,labelRowsPerPage:s!=null?s:"Listings per page:",rowsPerPageOptions:[10,25,50]})},rs=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"center"},header:{padding:e.spacing(0,0,1)}})),ls=({checksPerPage:e,currentCursor:n})=>{const a=rs(),[r,l]=y(n),[o,s]=y([]),{data:i,isLoading:c}=qt(void 0,e,r),{loading:u,allowed:m}=te({permission:Br}),[d,p]=y(i);$(()=>{i&&p(()=>{var D;return{endCursor:i.endCursor,totalCount:i.totalCount,hasNextPage:(D=i==null?void 0:i.hasNextPage)!=null?D:!1,edges:i.edges}})},[i]);const h=d==null?void 0:d.edges.map(D=>D.checker),{setShowAddModal:v}=ae(),[C,E]=y(),[f,P]=y(""),[T,S]=y("default"),[N,w]=y("all"),[Ie,re]=y([]),xe=D=>{const q=Re({searchTermProp:f,filterAlphaProp:D.target.value,filterOwnerProp:N,checks:h!=null?h:[]});S(D.target.value),E(q)},Oe=D=>{const q=Re({searchTermProp:f,filterAlphaProp:T,filterOwnerProp:D.target.value,checks:h!=null?h:[]});w(D.target.value),E(q)};return $(()=>{const D=d==null?void 0:d.edges.map(pe=>pe.checker),q=hn(D!=null?D:[]);E(D),re(q!=null?q:[])},[c,d]),$(()=>{const D=d==null?void 0:d.edges.map(pe=>pe.checker),q=Re({searchTermProp:f,filterAlphaProp:T,filterOwnerProp:N,checks:D!=null?D:[]});E(q)},[f,T,N,d]),t.createElement(g,{container:!0,direction:"row"},t.createElement(g,{container:!0,spacing:4,className:a.header},t.createElement(na,{searchPlaceholder:"Search available checks",isLoading:c,searchTerm:f,setSearchTerm:P,filterAlpha:T,handleAlphabeticalFilterChange:xe,filterOwner:N,handleOwnerFilterChange:Oe,owners:Ie}),t.createElement(g,{item:!0,xs:3},t.createElement("div",{className:a.headerButtons},!u&&t.createElement(H,{disabled:!m,variant:"contained",color:"primary",onClick:()=>v(!0)},"Create Check")))),t.createElement(g,{container:!0,spacing:4,role:"list","aria-label":"checks"},c?t.createElement(pn,null):C==null?void 0:C.map(D=>t.createElement(g,{key:D.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(Jo,{check:D})))),t.createElement(ra,{response:d,listingsPerPage:e,cursor:r,setCursor:l,prevCursors:o,setPrevCursors:s,labelPerPageDropdown:"Checks Per Page:",urlRoute:"checks?checksPerPage="}))},os=()=>{const{selectedItem:e}=ae();return t.createElement(ta,{title:"Check Details",open:!!e,onSave:()=>{}})},ss=x(e=>({checksPageContainer:{padding:e.spacing(3)}})),is=()=>{const e=ss(),[n]=Rt(),a=n.get("checksPerPage"),r=a?parseInt(a,10):10,{selectedItem:l,showAddModal:o,isReadOnly:s}=ae();return t.createElement("div",{className:e.checksPageContainer},t.createElement(ls,{checksPerPage:r}),o&&t.createElement(qo,null),l&&!s&&t.createElement(_o,null),l&&s&&t.createElement(os,null))},cs=()=>t.createElement(zl,null,t.createElement(is,null)),ds=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),ms=({program:e})=>{var n,a,r;const l=ds(),o=(a=(n=e.levels)==null?void 0:n.length)!=null?a:0,s=(r=e.levels)==null?void 0:r.reduce((i,c)=>i+c.checks.length,0);return t.createElement(Je,{dense:!0,disablePadding:!0,className:l.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Track Details"),t.createElement(oe,{disableGutters:!0,className:l.listItem},t.createElement(K,{title:"Levels"},t.createElement(Q,null,t.createElement(sl,{color:"action",fontSize:"small"}))),t.createElement(X,{className:l.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},`${o} ${o===1?"Level":"Levels"}`)})),t.createElement(oe,{disableGutters:!0,className:l.listItem},t.createElement(K,{title:"Checks"},t.createElement(Q,null,t.createElement(ol,{color:"action",fontSize:"small"}))),t.createElement(X,{className:l.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},`${s} ${s===1?"Check":"Checks"}`)})),e.documentationURL&&t.createElement(oe,{disableGutters:!0,className:l.listItem},t.createElement(K,{title:"Documentation"},t.createElement(Q,null,t.createElement(ll,{color:"action",fontSize:"small"}))),t.createElement(X,{className:l.listItemText,primary:t.createElement(Kn,{to:e.documentationURL,target:"_blank",rel:"noopener noreferrer"},"Learn more")})),t.createElement(oe,{disableGutters:!0,className:l.listItem},t.createElement(K,{title:"Owner"},t.createElement(Q,null,t.createElement(nt,{color:"action",fontSize:"small"}))),t.createElement(X,{className:l.listItemText,primary:t.createElement(Ge,{entityRef:e.ownerEntityRef})})))},us="Error Deleting Track";function ps(){const e=I(F),n=Ee(),{showAlert:a}=se(),r=async l=>{const o=await e.deleteProgram(l);if(!o)throw new Error(`Failed to delete track ${l}`);return o};return fe([ye.DeleteProgram],r,{onSuccess:()=>{const l=[L.GetAllPrograms,L.GetOverallTrackPassRate,L.GetIndividualTrackPassRate];for(const o of l)n.invalidateQueries({queryKey:[o]})},onError:(l,o)=>{let s=`Failed to delete track ${o}`;l instanceof Error&&(s=l.message),a({severity:"error",title:us,message:s})}})}const hs=({summary:e})=>{const{loading:n,allowed:a}=te({permission:Vr,resourceRef:e.id}),{loading:r,allowed:l}=te({permission:Gr,resourceRef:e.id}),{showModal:o}=at(),{mutate:s}=ps(),{setSelectedProgram:i}=we(),c=ee(async()=>{await o({title:"Delete Track",message:`Are you sure you want to delete track ${e.name}?`})&&s(e.id)},[o,e.id,e.name,s]);return t.createElement(qe,{title:e.name,description:e.description,children:t.createElement(ms,{program:e}),handleView:()=>{i(e)},handleEdit:e.isEditable&&!n&&a?()=>{i(e)}:void 0,handleDelete:e.isEditable&&!r&&l?c:void 0})},gs=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,n)=>t.createElement(g,{key:`loading-${n}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(zt,{variant:"rect",height:385})))),vs=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end"},header:{padding:e.spacing(0,0,1)}})),Es=({programsPerPage:e,currentCursor:n})=>{var a;const r=vs(),{loading:l,allowed:o}=te({permission:zr}),{setShowAddModal:s}=we(),[i,c]=y(n),[u,m]=y([]),{data:d,isLoading:p}=_a(void 0,e,i),[h,v]=y(d);$(()=>{d&&v(()=>{var O;return{endCursor:d.endCursor,totalCount:d.totalCount,hasNextPage:(O=d==null?void 0:d.hasNextPage)!=null?O:!1,edges:d.edges}})},[d]);const C=(a=h==null?void 0:h.edges)==null?void 0:a.map(O=>O==null?void 0:O.program),{userEntityRef:E}=tt(),{showAlert:f}=se(),[P,T]=y(),[S,N]=y(""),[w,Ie]=y("default"),[re,xe]=y("all"),[Oe,D]=y([]),q=O=>{const j=Re({searchTermProp:S,filterAlphaProp:O.target.value,filterOwnerProp:re,tracks:C!=null?C:[]});Ie(O.target.value),T(j)},pe=O=>{const j=Re({searchTermProp:S,filterAlphaProp:w,filterOwnerProp:O.target.value,tracks:C!=null?C:[]});xe(O.target.value),T(j)};$(()=>{const O=h==null?void 0:h.edges.map(Fe=>Fe.program),j=hn(O!=null?O:[]);T(O),D(j!=null?j:[])},[p,h]),$(()=>{const O=h==null?void 0:h.edges.map(Fe=>Fe.program),j=Re({searchTermProp:S,filterAlphaProp:w,filterOwnerProp:re,tracks:O!=null?O:[]});T(j)},[S,w,re,h]);const je=()=>{E?s(!0):f({severity:"error",title:"User Error",message:"Logged in user has not been found in Catalog. Unable to create a Track at this time"})};return t.createElement(g,{container:!0,direction:"row"},t.createElement(g,{container:!0,spacing:4,className:r.header},t.createElement(na,{searchPlaceholder:"Search available tracks",isLoading:p,searchTerm:S,setSearchTerm:N,filterAlpha:w,handleAlphabeticalFilterChange:q,filterOwner:re,handleOwnerFilterChange:pe,owners:Oe}),t.createElement(g,{item:!0,xs:3},t.createElement("div",{className:r.headerButtons},!l&&t.createElement(H,{disabled:!o,variant:"contained",color:"primary",onClick:()=>je()},"Create Track")))),t.createElement(g,{container:!0,spacing:4,role:"list","aria-label":"tracks"},p?t.createElement(gs,null):P==null?void 0:P.map(O=>t.createElement(g,{key:O.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(hs,{summary:O})))),t.createElement(ra,{response:h,listingsPerPage:e,cursor:i,setCursor:c,prevCursors:u,setPrevCursors:m,labelPerPageDropdown:"Track Per Page:",urlRoute:"tracks?tracksPerPage="}))},fs=x(e=>({titleInput:{marginBottom:e.spacing(1)},title:{fontWeight:700}})),ys=({programName:e,programNameError:n,handleProgramNameChange:a,disabled:r})=>{const l=fs();return t.createElement(g,{item:!0,xs:12},t.createElement(G,{name:"trackName",fullWidth:!0,placeholder:"Untitled track",value:e,onChange:a,disabled:r,className:l.titleInput,variant:"outlined",size:"small",margin:"normal",error:n,helperText:n?"Track name must be at least 1 character and less than 100 characters":""}))},gn=x(e=>{const n=e.palette.type==="dark",a=n?e.palette.common.white:e.palette.common.black,r=n?e.palette.grey[700]:e.palette.common.white,l=n?e.palette.grey[500]:e.palette.grey[300],o=n?e.palette.common.white:e.palette.common.black;return{chip:{width:"100%",height:"36px",color:a,justifyContent:"space-between",background:r,border:`1px solid ${l}`,borderRadius:4,boxShadow:"0px 2px 5px rgba(0, 0, 0, 0.1)",cursor:"move","& *":{fontWeight:700},"&:focus":{background:r,borderColor:o,"& $icon":{color:e.palette.primary.main}}},icon:{},deleteButton:{marginRight:"auto"}}}),Cs=({chip:e,disabled:n})=>{var a;const[r,l]=tl(()=>({type:"chip",item:{id:e.id,label:e.label},collect:s=>({isDragging:s.isDragging()})})),o=gn();return t.createElement(Ft,{ref:l,label:e.label,className:o.chip,icon:t.createElement(Fa,{"data-testid":"drag-indicator-icon"}),disabled:n,onDelete:()=>{},deleteIcon:t.createElement(K,{title:(a=e.description)!=null?a:""},t.createElement(il,{className:o.icon,"data-testid":"visibility-icon"}))})},vn=x(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{color:e.palette.primary.main,fontWeight:"bold"},chipContainer:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:e.spacing(1),gap:e.spacing(1)},loadingContainer:{marginTop:e.spacing(1),display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}})),bs=()=>{const e=vn();return t.createElement(g,{container:!0,className:e.loadingContainer},t.createElement(dr,null))},ks=({chips:e,disabled:n})=>t.createElement(t.Fragment,null,e.map(a=>t.createElement(Cs,{disabled:n,key:a.id,chip:a}))),xs=()=>t.createElement(b,{variant:"body1",color:"textSecondary"},"There are no matches."),Ps=({isLoading:e,chips:n=[],disabled:a})=>{const r=vn(),[l,o]=y(""),s=n.filter(u=>u.label.toLowerCase().includes(l.toLowerCase())),i=n.length>0||l;let c=null;return e?c=t.createElement(bs,null):s.length>0?c=t.createElement(ks,{disabled:a!=null?a:!1,chips:s}):i&&(c=t.createElement(xs,null)),t.createElement(g,{container:!0},t.createElement(g,{item:!0,xs:12,className:r.columnHeader},t.createElement(b,{className:r.subtitle},"Checks")),t.createElement(g,{item:!0,xs:12},t.createElement(aa,{searchTerm:l,disabled:e||a,setSearchTerm:o,placeholder:"Search available checks",variant:"outlined",size:"small"})),t.createElement(g,{item:!0,className:r.chipContainer,xs:12},c))},ws=x(e=>({button:{border:"none",fontWeight:700,fontSize:e.typography.subtitle2.fontSize,lineHeight:"19px",color:e.palette.primary.main,textTransform:"none"}})),En=({label:e,...n})=>{const a=ws();return t.createElement(H,{className:a.button,...n},e)},Ts=x(e=>({input:{border:`1px solid ${e.palette.grey[600]}`,borderRadius:4,padding:e.spacing(1),minHeight:80},hoverBackground:{background:e.palette.type==="dark"?e.palette.grey[600]:e.palette.grey[200]},normalBackground:{background:e.palette.type==="dark"?e.palette.grey[700]:e.palette.common.white},error:{border:"1px solid red"},chipContainer:{display:"flex",flexDirection:"column",fontWeight:"bold",fontSize:e.typography.pxToRem(16),color:e.palette.grey[600]}})),Rs=({chips:e,onDelete:n,onDrop:a,error:r=!1,placeholder:l="",disabled:o})=>{const s=Ts(),i=gn(),[{isOver:c},u]=al(()=>({accept:"chip",drop:m=>{a(m)},collect:m=>({isOver:m.isOver()})}));return t.createElement("div",{ref:u,className:`${s.input} ${r?s.error:""} ${c?s.hoverBackground:s.normalBackground}`,"data-testid":"droppable-input"},t.createElement("div",{className:s.chipContainer},e!=null&&e.length?e.map(m=>t.createElement(Ft,{key:m.id,label:m.label,className:i.chip,icon:t.createElement(Fa,null),style:{cursor:"pointer"},onDelete:()=>n(m),disabled:o})):l))},Ns=x(e=>({inputBase:{fontSize:e.typography.subtitle1.fontSize,fontWeight:700}})),Ls=({levelName:e,handleLevelNameChange:n,disabled:a})=>{const r=Ns();return t.createElement(G,{name:"levelName",fullWidth:!0,placeholder:"Untitled level",value:e,size:"small",variant:"outlined",onChange:n,label:"Level Name",disabled:a,InputProps:{classes:{input:r.inputBase}}})},Ss=x(e=>({inputBase:{fontSize:e.typography.fontSize,fontWeight:"normal"}})),Ds=({levelDescription:e,levelNameLabel:n,handleLevelDescriptionChange:a,disabled:r})=>{const l=Ss();return t.createElement(G,{name:"levelDescription",fullWidth:!0,placeholder:"Enter description here",multiline:!0,value:e,size:"small",variant:"outlined",label:`${n} Description`,onChange:a,disabled:r,InputProps:{classes:{input:l.inputBase}}})},Is=x(e=>({columnHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},subtitle:{fontWeight:"bold",color:e.palette.primary.main},levelHeader:{display:"flex",alignItems:"center"},removeButton:{minWidth:150}})),Os=({inputChipsList:e,handleDelete:n,handleDrop:a,addInput:r,removeInput:l,levelsErrors:o,levelNames:s,levelDescriptions:i,handleLevelNameChange:c,handleLevelDescriptionChange:u,disabled:m})=>{const d=Is();return t.createElement(g,{container:!0},t.createElement(g,{item:!0,xs:12,className:d.columnHeader},t.createElement(b,{className:d.subtitle},"Levels"),!m&&t.createElement(En,{label:"Add Level",startIcon:t.createElement(cl,null),onClick:r,disabled:m})),t.createElement(g,{container:!0,item:!0,spacing:5},e.map((p,h)=>t.createElement(g,{container:!0,item:!0,xs:12,key:h,spacing:2},t.createElement(g,{item:!0,xs:12,className:d.levelHeader},t.createElement(g,{container:!0,spacing:1},t.createElement(g,{item:!0,xs:!0},t.createElement(Ls,{levelName:s[h],handleLevelNameChange:v=>c(v.target.value,h),disabled:m!=null?m:!1})),e.length>1&&!m&&t.createElement(g,{item:!0,className:d.removeButton},t.createElement(En,{label:"Remove Level",startIcon:t.createElement(dl,null),onClick:()=>l(h),disabled:m})))),t.createElement(g,{item:!0,xs:12},t.createElement(Rs,{chips:p,onDelete:v=>n(v,h),onDrop:v=>a(v,h),error:o[h],placeholder:"Drag and drop checks here to include them in this level",disabled:m})),t.createElement(g,{item:!0,xs:12},t.createElement(Ds,{levelDescription:i[h],levelNameLabel:s[h],handleLevelDescriptionChange:v=>u(v.target.value,h),disabled:m!=null?m:!1}))))))},Fs=x(e=>({titleInput:{marginBottom:e.spacing(1)},regularFontSize:{fontSize:e.typography.fontSize},title:{fontWeight:700,fontSize:e.typography.fontSize}})),As=({programDescription:e,programDescriptionError:n,handleProgramDescriptionChange:a,disabled:r})=>{const l=Fs();return t.createElement(g,{item:!0,xs:12},t.createElement(G,{name:"trackDescription",fullWidth:!0,placeholder:"Example: Make sure the project has a ReadMe file and is using the latest version of JavaScript",value:e,onChange:a,disabled:r,className:l.titleInput,minRows:4,variant:"outlined",size:"small",margin:"normal",multiline:!0,InputProps:{classes:{input:l.regularFontSize}},error:n,helperText:n?"Track description must be at least 1 character and less than 250 characters":""}))};var $s=(e=>(e.SetProgramNameError="VALIDATE_NAME",e.SetName="SET_NAME",e))($s||{});const Ms={programName:"",programNameError:!1},Bs=(e,n)=>{switch(n.type){case"SET_NAME":return{...e,programName:n.value};case"VALIDATE_NAME":return{...e,programNameError:n.value};default:return e}},Vs=(e="")=>{const[n,a]=va(Bs,{...Ms,programName:e}),r=()=>{const s=n.programName.trim().length,i=s>0&&s<=100;return a({type:"VALIDATE_NAME",value:!i}),i},l=s=>{a({type:"SET_NAME",value:s})},o=s=>{l(s.target.value),n.programNameError&&r()};return{programName:n.programName,programNameError:n.programNameError,handleProgramNameChange:o,setProgramName:l,isProgramNameValid:r}};var Gs=(e=>(e.SetProgramDescriptionError="VALIDATE_DESCRIPTION",e.SetDescription="SET_DESCRIPTION",e))(Gs||{});const zs={programDescription:"",programDescriptionError:!1},_s=(e,n)=>{switch(n.type){case"SET_DESCRIPTION":return{...e,programDescription:n.value};case"VALIDATE_DESCRIPTION":return{...e,programDescriptionError:n.value};default:return e}},Ws=(e="")=>{const[n,a]=va(_s,{...zs,programDescription:e}),r=()=>{const s=n.programDescription.trim().length,i=s>0&&s<=250;return a({type:"VALIDATE_DESCRIPTION",value:!i}),i},l=s=>{a({type:"SET_DESCRIPTION",value:s})},o=s=>{l(s.target.value),n.programDescriptionError&&r()};return{programDescription:n.programDescription,programDescriptionError:n.programDescriptionError,handleProgramDescriptionChange:o,setProgramDescription:l,isProgramDescriptionValid:r}},Hs=({programName:e,programDescription:n,areInputsValid:a,isProgramNameValid:r,isProgramDescriptionValid:l,inputChipsList:o,checkers:s,onSave:i,programId:c,levelNames:u,levelDescriptions:m,filters:d})=>{const{showModal:p}=at(),{userEntityRef:h}=tt();return async()=>{if(!(r()&&l()&&a())||!await p({title:"Save Track",message:`Are you sure you want to save track: ${e}?`})||!h)return;const v=c!=null?c:La(),C=io(o,u,m,s),E={description:n,id:v,levels:C,name:e,ownerEntityRef:h,filter:Ja(d)};i(E)}},qs=e=>{var n;const a=Wn([]),r=_(()=>e?mo(e):null,[e]),{chips:l,setChips:o,inputChipsList:s,handleDrop:i,handleDelete:c,addInput:u,removeInput:m,inputErrors:d,areInputsValid:p,setInputChipsList:h}=Sl(),{data:v,isLoading:C}=qt(),E=v==null?void 0:v.edges.map(P=>P.checker),f=(n=E==null?void 0:E.filter(P=>!!P).map(P=>{var T,S,N;return{id:(T=P.id)!=null?T:"",label:(S=P.name)!=null?S:P.id,description:(N=P.description)!=null?N:""}}))!=null?n:[];return a.current=f,$(()=>{const{inputChips:P,used:T}=ho(r,a.current);h(P),o(T)},[f==null?void 0:f.length,r,h,o]),{checkers:E,checkersLoading:C,chips:l,inputChipsList:s,handleDrop:i,handleDelete:c,addInput:u,removeInput:m,inputErrors:d,areInputsValid:p}},Us=e=>{const[n,a]=y(e);return{levelNames:n,handleLevelNameChange:(r,l)=>{a(n.map((o,s)=>s===l?r:o))},addLevelName:r=>{a([...n,r])},removeLevelName:r=>{a(n.filter((l,o)=>o!==r))}}},Ks=e=>{const[n,a]=y(e);return{levelDescriptions:n,handleLevelDescriptionChange:(r,l)=>{a(n.map((o,s)=>s===l?r:o))},addLevelDescription:r=>{a([...n,r])},removeLevelDescription:r=>{a(n.filter((l,o)=>o!==r))}}},js=x(e=>({title:{fontWeight:700},filterContainer:{display:"flex",flexWrap:"wrap",padding:e.spacing(2)},description:{fontSize:e.typography.fontSize}})),Ys=({filters:e,setFilters:n,disabled:a})=>{const r=js();return t.createElement(He,{title:a?"Filters":"Filters (optional)"},t.createElement(g,{container:!0,item:!0,xs:12,spacing:2},!a&&t.createElement(g,{item:!0},t.createElement(b,{className:r.description},"Apply filters so it's only applicable to relevant entities.")),t.createElement(g,{item:!0,xs:12},t.createElement(Me,null,t.createElement(ea,{value:e,onChange:n})))))},Qs=x(e=>({regularFontSize:{fontSize:e.typography.fontSize,fontWeight:"bold"},description:{fontWeight:"normal",fontSize:e.typography.fontSize},root:{overflow:"hidden",display:"flex",padding:e.spacing(1),marginBottom:"53px"}})),fn=({onSave:e,title:n,open:a,handleClose:r})=>{var l,o,s,i;const{selectedProgram:c,isLoading:u,setSelectedProgram:m}=we(),{checkers:d,checkersLoading:p,chips:h,inputChipsList:v,handleDrop:C,handleDelete:E,addInput:f,removeInput:P,inputErrors:T,areInputsValid:S}=qs(c),{programName:N,programNameError:w,handleProgramNameChange:Ie,isProgramNameValid:re}=Vs(c==null?void 0:c.name),{programDescription:xe,programDescriptionError:Oe,handleProgramDescriptionChange:D,isProgramDescriptionValid:q}=Ws(c==null?void 0:c.description),pe=(o=c?(l=c.levels)==null?void 0:l.map(Y=>{var le;return(le=Y.name)!=null?le:`Level ${Y.ordinal}`}):v.map((Y,le)=>`Level ${le+1}`))!=null?o:[],{levelNames:je,handleLevelNameChange:O,addLevelName:j,removeLevelName:Fe}=Us(pe),An=(i=c?(s=c.levels)==null?void 0:s.map(Y=>{var le;return(le=Y.description)!=null?le:""}):v.map((Y,le)=>""))!=null?i:[],{levelDescriptions:pa,handleLevelDescriptionChange:$n,addLevelDescription:Mn,removeLevelDescription:Bn}=Ks(An),Vn=()=>{f(),j(`Level ${v.length+1}`),Mn("")},Gn=Y=>{P(Y),Fe(Y),Bn(Y)},[ha,zn]=y(en(c==null?void 0:c.filter)),_n=Hs({programName:N,programDescription:xe,areInputsValid:S,isProgramNameValid:re,isProgramDescriptionValid:q,inputChipsList:v,checkers:d,onSave:e,programId:c==null?void 0:c.id,levelNames:je,levelDescriptions:pa,filters:ha}),Tt=Qs(),ga=un(),he=c?!(c!=null&&c.isEditable):!1;return t.createElement(st,{handleClose:r,title:n,open:a},t.createElement(g,{container:!0,spacing:4,className:Tt.root},t.createElement(g,{item:!0,xs:12},t.createElement(g,{item:!0,xs:12},t.createElement(b,{className:ga.sectionLabel,style:{margin:0}},"Track Details"),t.createElement(ys,{disabled:u||he,programName:N,programNameError:w,handleProgramNameChange:Ie})),t.createElement(g,{item:!0,xs:12},t.createElement(As,{disabled:u||he,programDescription:xe,programDescriptionError:Oe,handleProgramDescriptionChange:D}))),t.createElement(g,{item:!0,xs:12},t.createElement(Ys,{filters:ha,setFilters:zn})),t.createElement(g,{item:!0,xs:12},t.createElement(g,{container:!0,spacing:4},t.createElement(g,{item:!0,xs:12},t.createElement(b,{className:ga.sectionLabel,style:{margin:0}},"Track Levels"),!he&&t.createElement(b,{className:Tt.description},"Add the checks that apply to each level. You can preview the checks to see the rules that apply to each check.")),!he&&t.createElement(g,{item:!0,xs:5},t.createElement(Ps,{chips:h,isLoading:p||u,disabled:he})),t.createElement(g,{item:!0,xs:7},t.createElement(Os,{inputChipsList:v,handleDelete:E,handleDrop:C,addInput:Vn,removeInput:Gn,levelsErrors:T,levelNames:je,handleLevelNameChange:O,levelDescriptions:pa,handleLevelDescriptionChange:$n,disabled:he}))))),t.createElement(g,{container:!0,spacing:4,className:Tt.root},t.createElement(Ut,{onCancel:()=>{m(null),r()},saveButtonText:"Save Track",isLoading:u||p,onSave:_n,disableSave:he})))},Xs=()=>{const{setIsLoading:e,setShowAddModal:n,showAddModal:a}=we(),{mutateAsync:r,isLoading:l}=Ll();return $(()=>{e(l)},[e,l]),t.createElement(fn,{handleClose:()=>n(!1),title:"Create Track",open:a,onSave:async o=>{await r(o,{onSuccess:()=>n(!1)})}})},Zs="Error Updating Track";function Js(){const e=I(F),n=Ee(),{showAlert:a}=se(),r=async l=>{const o=await e.updateProgram(l);if(!o)throw new Error("Failed to update track.");return o};return fe([ye.UpdateProgram],r,{onSuccess:async()=>{await n.invalidateQueries({queryKey:[L.GetAllPrograms]})},onError:l=>{let o="Failed to update track.";l instanceof Error&&(o=l.message),a({severity:"error",title:Zs,message:o})}})}const ei=()=>{const{setSelectedProgram:e,setIsLoading:n,selectedProgram:a}=we(),{mutateAsync:r,isLoading:l}=Js();$(()=>n(l),[n,l]);const o=async s=>{await r(s,{onSuccess:()=>e(null)})};return t.createElement(fn,{handleClose:()=>e(null),title:a!=null&&a.isEditable?"Edit Track":"View Track",open:!!a,onSave:o})},ti=x(e=>({programsPageContainer:{padding:e.spacing(3)},headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap"}})),ai=()=>{const{selectedProgram:e,showAddModal:n}=we(),[a]=Rt(),r=a.get("tracksPerPage"),l=r?parseInt(r,10):10,o=ti(),s="Programs will now be referred to as Tracks throughout the Soundcheck UI.";return t.createElement("div",{className:o.programsPageContainer},t.createElement(jn,{variant:"info",message:s,id:"programTrackBanner"}),t.createElement(nl,{backend:rl},t.createElement(Es,{programsPerPage:l}),n&&t.createElement(Xs,null),e&&t.createElement(ei,null)))},ni=()=>t.createElement(Gl,null,t.createElement(ai,null)),ri=e=>e?e.palette.type:"",yn=e=>ri(e).toLowerCase()==="dark",ne=e=>yn(e)?e.palette.grey[200]:e.palette.grey[800],ut=e=>yn(e)?Xn:Zn;function la(e,n){return(n?e.minus({days:n}):e).toFormat("MMM dd")}function ce(e){const n=lt.utc();return e.map((a,r)=>({name:la(n,e.length-r-1),passRate:a}))}var li=(e=>(e.Bar="bar",e.Line="line",e))(li||{});const oi=-25,Ce=[0,100],Cn=85,oa=25,pt="name",si=250,ht=.5,bn="circle",kn=8,xn="monotone",gt=({children:e})=>t.createElement(Aa,{minHeight:si,debounce:1},e),ii=z(e=>({container:{position:"relative"},chartMessage:{position:"absolute",top:"50%",left:"50%",fontWeight:"bold",transform:"translate(-50%, -50%)",backgroundColor:e.palette.background.default,padding:e.spacing(1),borderRadius:"5px",textAlign:"center",width:"50%",zIndex:2}})),ci=()=>{const e=[{x:"A",y:25},{x:"B",y:50},{x:"C",y:75}],n=ii();return t.createElement("div",{className:n.container},t.createElement(gt,null,t.createElement(_t,{data:e},t.createElement(rt,{strokeDasharray:"3 3",vertical:!1,opacity:ht}),t.createElement(ze,{dataKey:"x",stroke:"#ccc",hide:!0}),t.createElement(_e,{domain:Ce,stroke:"#ccc",hide:!0}),t.createElement(Wt,{type:"monotone",dataKey:"y",stroke:"#ccc",dot:!1}))),t.createElement(b,{className:n.chartMessage},"No Data"))},di=x(e=>({legend:{color:ne(e)}})),vt=({data:e,lines:n})=>{const a=et(),r=ut(a),l=ne(a),o=di();return e.length?t.createElement(gt,null,t.createElement(_t,{data:e},t.createElement(rt,{vertical:!1,opacity:ht}),t.createElement(ze,{dataKey:pt,stroke:l}),t.createElement(_e,{width:oa,domain:Ce,stroke:l}),t.createElement($a,{position:{y:oi},contentStyle:{backgroundColor:a.palette.background.paper}}),n.length>1&&t.createElement(Ma,{iconType:bn,iconSize:kn,formatter:s=>t.createElement("span",{className:o.legend},s)}),n.map((s,i)=>t.createElement(Wt,{key:s.dataKey,dataKey:s.dataKey,stroke:r[i%r.length],strokeWidth:2,dot:!1,name:s.name,type:xn})))):t.createElement(ci,null)},mi=({data:e,lines:n})=>{const a=et(),r=ut(a);return t.createElement(Aa,{height:50,width:100},t.createElement(_t,{data:e},t.createElement(ze,{hide:!0,dataKey:pt}),t.createElement(_e,{width:0,domain:Ce}),n.map((l,o)=>t.createElement(Wt,{key:l.dataKey,dataKey:l.dataKey,stroke:r[o%r.length],strokeWidth:2,dot:!1,name:l.name,type:xn}))))},Ue=({chartData:e,tableChart:n})=>{const a=[{dataKey:"passRate",name:"Pass rate"}];return n?t.createElement(mi,{data:e,lines:a}):t.createElement(vt,{data:e,lines:a})};var R=(e=>(e.Entity="Entity",e.Kind="Entity Kind",e.Type="Entity Type",e.EntityOwner="Entity Owner",e.Lifecycle="Entity Lifecycle",e.Track="Track",e.Level="Track Level",e.Check="Check",e.CheckOwner="Check Owner",e))(R||{});function ui(e){var n;const a=I(F),[r,l]=y(null),o=async()=>(await a.getEntityRefsForTechHealthFilter(e)).entityRefsForTechHealthFilter,s=B([L.GetSoftwareEntityRefsForUser,e],o,{retry:!1,onError:l,enabled:e!==null,staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1});return{data:(n=s.data)!=null?n:[],isLoading:s.isLoading,error:r}}const pi=(e,n)=>{var a,r,l,o;const s=[];for(const c of e)s.push({label:(a=c.name)!=null?a:c.id,value:c.id});const i=e.map(c=>c.id);for(const c of n)for(const u of(r=c.levels)!=null?r:[])for(const m of(l=u.checks)!=null?l:[])i.includes(m.id)||(i.push(m.id),s.push({label:(o=m.name)!=null?o:m.id,value:m.id}));return s},hi=e=>{var n;const a=[];for(const r of e!=null?e:[])for(const l of(n=r.levels)!=null?n:[])a.includes(l.ordinal)||a.push(l.ordinal);return a.sort().map(r=>({label:`Level ${r}`,value:`${r}`}))},gi=(e,n)=>{const a=new Set(e.filter(r=>r.ownerEntityRef).map(r=>r.ownerEntityRef));return Array.from(a).map(r=>{var l;return{label:(l=n[r])!=null?l:r,value:r}})},vi=()=>{const[e,n]=y(!1),{userEntityRef:a}=tt(),{data:r,isLoading:l}=ui(a),{data:o,isLoading:s}=fr(),i=_(()=>Ve.mapValues(Ve.keyBy(o!=null?o:[],"ref"),N=>N.name),[o]),{data:c,isLoading:u}=_a(void 0,100),m=_(()=>{var N;return(N=c==null?void 0:c.edges.map(w=>w.program))!=null?N:[]},[c]),{data:d,isLoading:p}=qt(void 0,100),h=_(()=>{var N;return(N=d==null?void 0:d.edges.map(w=>w.checker))!=null?N:[]},[d]),{data:v,isLoading:C}=mt("kind"),{data:E,isLoading:f}=mt("spec.lifecycle"),{data:P,isLoading:T}=mt("spec.type"),S=_(()=>{var N;return{[R.Kind]:(v!=null?v:[]).map(w=>({label:w,value:w})),[R.Lifecycle]:(E!=null?E:[]).map(w=>({label:w,value:w})),[R.Type]:(P!=null?P:[]).map(w=>({label:w,value:w})),[R.Entity]:r.map(w=>({label:M(w).name,value:w})),[R.EntityOwner]:(N=o==null?void 0:o.map(w=>({label:w.name,value:w.ref})))!=null?N:[],[R.Track]:m.map(w=>({label:w.name,value:w.id})),[R.Level]:hi(m),[R.Check]:pi(h,m),[R.CheckOwner]:gi(h,i)}},[v,E,P,r,o,i,m,h]);return $(()=>{n(C||f||T||l||s||u||p)},[C,f,T,l,s,u,p]),{facetOptions:S,isLoading:e}},Ne=30,be=2,Le=90,ke=()=>Object.fromEntries(Object.values(R).map(e=>[e,[]])),Ei=(e,n,a)=>{if(n.length)return n.map(r=>({track:r,levels:a.length?a.map(l=>parseInt(l,10)):void 0}));if(a.length)return e.map(r=>({track:r.value,levels:a.map(l=>parseInt(l,10))}))},Pn=(e,n,a,r)=>({checkIdFilter:n[R.Check].length?{included:n[R.Check]}:void 0,checkOwnerFilters:n[R.CheckOwner].length?{included:n[R.CheckOwner]}:void 0,entityOwnerFilters:n[R.EntityOwner].length?{included:n[R.EntityOwner]}:void 0,entityRefFilters:n[R.Entity].length?{included:n[R.Entity]}:void 0,trackFilters:Ei(e[R.Track],n[R.Track],n[R.Level]),numberOfDays:a!=null?a:Ne,context:r?{loggedInUser:r}:void 0,entityTypes:n[R.Type].length?{included:n[R.Type]}:void 0,entityKinds:n[R.Kind].length?{included:n[R.Kind]}:void 0,entityLifecycles:n[R.Lifecycle].length?{included:n[R.Lifecycle]}:void 0});function fi({angle:e,arc:n,direction:a,dist:r,emoji:l,delay:o,fontSize:s,speed:i}){return t.createElement(Ht.div,{style:{position:"absolute",fontSize:s},initial:{top:0,left:"50%",x:"-50%",y:"-100%",rotate:0,originX:`${n*a}px`,originY:`${n}px`},animate:{opacity:[0,1,0,0,0,0],y:`${-r}px`,rotate:e*a},transition:{delay:o,duration:i,ease:[.2,.83,.46,.63],repeat:1/0}},l)}const yi=["\u{1F4C8}","\u{1F4CA}","\u{1F4C9}","\u{1F680}","\u2B50\uFE0F"],Ci=x(()=>({container:{position:"relative"}}));function bi({angle:e=125,density:n=20,emojis:a=yi,fontSizeMin:r=6,fontSizeMax:l=24,size:o=300,speed:s=4}){const i=Ci(),c=_(()=>Array.from({length:n*a.length}).map((u,m)=>({emoji:a[Math.floor(Math.random()*a.length)],arc:Math.random()*o*.5,delay:Math.random()*s,dist:Math.random()*o,direction:m%2?1:-1,fontSize:Math.random()*(l-r)+r,angle:e,speed:s})),[n,a,s,o,e,l,r]);return t.createElement("div",{className:i.container},t.createElement(b,{variant:"h1"},"\u{1F469}\u200D\u{1F4BB}"),c.map((u,m)=>t.createElement(fi,{key:`${u.emoji}-${m}`,...u})))}const ki=x(()=>({container:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,height:"100%"},textContainer:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}}));function Se({title:e,subtitle:n}){const a=ki();return t.createElement("div",{className:a.container},t.createElement("div",{className:a.textContainer},t.createElement(bi,null),t.createElement(Ht.div,{animate:{y:0,opacity:1},initial:{y:100,opacity:0}},e&&t.createElement(b,{align:"center",variant:"h6"},e),n&&t.createElement(b,{align:"center",variant:"subtitle2"},n))))}const xi=x(e=>({container:{display:"flex",margin:"-24px",backgroundColor:e.palette.background.paper,borderTop:`1px solid ${e.palette.border}`,flex:1},fixedColumn:{width:"300px",flex:"none",borderRight:`1px solid ${e.palette.border}`},flexibleColumn:{display:"flex",flexDirection:"column",flex:1,backgroundColor:e.palette.background.default,height:"100%",maxWidth:"100%"},tabsPlaceholder:{height:"36.5px",backgroundColor:e.palette.background.paper}})),Pi=()=>{const e=xi();return t.createElement("div",{className:e.container},t.createElement("div",{className:e.fixedColumn}),t.createElement("div",{className:e.flexibleColumn},t.createElement("div",{className:e.tabsPlaceholder}),t.createElement(Se,null)))},wn=Ae({facetOptionsLoading:!1,getFacetOptions:()=>[],getFacetOptionLabel:()=>"",facetFilters:ke(),clearAllFilters:()=>{},getSelectedFacetValues:()=>[],setSelectedFacetValues:()=>{},numberOfDays:Ne,setNumberOfDays:()=>{},filter:{},loggedInUser:"Unknown"}),de=()=>$e(wn),wi=e=>{const{userEntityRef:n}=tt(),{isLoading:a,facetOptions:r}=vi(),[l,o]=Ga("soundcheck.techHealth.facetFilters",ke());l&&Object.values(R).forEach(E=>{l[E]||(l[E]=[])});const[s,i]=Ga("soundcheck.techHealth.numberOfDays",Ne),[c,u]=y(Pn(r,l!=null?l:ke(),s,n));$(()=>{u(Pn(r,l!=null?l:ke(),s,n))},[r,l,s,u,n]);const m=()=>{i(Ne),o(ke())},d=E=>r[E].map(f=>f.value),p=(E,f)=>{var P;let T=(P=r[E].find(S=>S.value===f))==null?void 0:P.label;if(!T)try{const S=M(f);T=Xr(S)}catch{}return T!=null?T:f},h=E=>l?l[E]:[],v=(E,f)=>{const P={...l!=null?l:ke()};P[E]=f,o(P)},C={facetOptionsLoading:a,getFacetOptions:d,getFacetOptionLabel:p,facetFilters:l!=null?l:ke(),clearAllFilters:m,getSelectedFacetValues:h,setSelectedFacetValues:v,numberOfDays:s!=null?s:Ne,setNumberOfDays:i,filter:c!=null?c:{},loggedInUser:"Unknown"};return a?t.createElement(Pi,null):t.createElement(wn.Provider,{...e,value:C})},Ti={hidden:{height:0,opacity:0,overflow:"hidden"},visible:{height:"auto",opacity:1,overflow:"visible"}};function Ri({visible:e,...n}){return t.createElement(Ht.div,{...n,animate:e?"visible":"hidden",initial:"hidden",variants:Ti})}const Ni=x(({palette:e,spacing:n})=>({header:{display:"flex",alignItems:"center",flexDirection:"row",cursor:"pointer"},headerTitle:{flex:"1 1 0%"},chip:{backgroundColor:e.info.dark,textOverflow:"ellipsis",overflow:"hidden"},autoCompleteInput:{"&& input":{margin:n(1,0,0,0),width:"100%"}}})),Li=({facet:e})=>{var n;const a=Ni(),{getFacetOptions:r,getFacetOptionLabel:l,getSelectedFacetValues:o,setSelectedFacetValues:s}=de(),[i,c]=y(!!((n=o(e))!=null&&n.length)),[u,m]=y(!1),[d,p]=y(""),h=()=>{c(E=>!E)},v=E=>{(E.key==="Enter"||E.key===" ")&&h()},C=E=>{if(e===R.Entity&&E[E.length-1]){const f=E[E.length-1];if(!f.includes(":")||!f.includes("/")){m(!0),p("Custom entities require a valid kind and namespace such as: component:default/entity");return}}m(!1),p(""),s(e,E)};return t.createElement(k,null,t.createElement("div",{className:a.header,onClick:h,onKeyDown:v,role:"button",tabIndex:0},t.createElement(k,{className:a.headerTitle},t.createElement(b,{variant:"subtitle2"},e)),t.createElement(k,null,t.createElement(Pe,{size:"small",onKeyDown:v},i?t.createElement(Ra,{fontSize:"small"}):t.createElement(Mt,{fontSize:"small"})))),t.createElement(Ri,{visible:i},t.createElement(Gt,{disableCloseOnSelect:!0,className:a.autoComplete,fullWidth:!0,multiple:!0,freeSolo:e===R.Entity,popupIcon:null,ChipProps:{color:"primary",className:a.chip,size:"small"},options:r(e),getOptionLabel:E=>l(e,E),value:o(e),onChange:(E,f)=>C(f),renderInput:E=>t.createElement(G,{...E,className:a.autoCompleteInput,margin:"normal",placeholder:`Search for ${e}`,error:u,helperText:d}),renderOption:(E,{selected:f})=>t.createElement(Ze,{onClick:P=>P.preventDefault(),control:t.createElement(Be,{icon:t.createElement(Ia,{fontSize:"small"}),checkedIcon:t.createElement(Da,{fontSize:"small"}),checked:f}),label:l(e,E)})})))},Si=x(({palette:e,spacing:n})=>({root:{padding:({size:a})=>a==="small"?n(1,2):n(2),borderBottom:`1px solid ${e.border}`}}));function sa(e){const n=Si(e);return t.createElement(k,{...e,className:n.root})}const Di=x(e=>({root:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingBottom:e.spacing(.25)}}));function Ii(){const e=Di(),{numberOfDays:n,facetFilters:a,clearAllFilters:r}=de(),l=Object.keys(R).some(o=>a[R[o]].length)||n!==Ne;return t.createElement(k,{className:e.root},t.createElement(k,null,t.createElement(b,{variant:"h6"},"Filters")),l&&t.createElement(k,null,t.createElement(H,{onClick:r,size:"small"},"Clear all")))}const Oi=x(({palette:e,spacing:n})=>({select:{width:"100%",margin:n(1,0)},chip:{backgroundColor:e.info.dark}})),Et=[7,30,90].map(e=>({value:e,label:`Last ${e} days`}));function Fi(){const e=Oi(),{numberOfDays:n,setNumberOfDays:a}=de(),r=[...Et];Et.map(d=>d.value).includes(n)||r.push({value:n,label:`Last ${n} days`});const[l,o]=y(r),[s,i]=y(""),c=()=>{if(s.length){const d=parseInt(s,10);return!isNaN(d)&&(d<be||d>Le)}return!1},u=()=>{const d=parseInt(s,10);if(d<be)return`Minimum of ${be} days`;if(d>Le)return`Maximum of ${Le} days`},m=d=>{if(d.key==="Enter"){const p=parseInt(s,10);p>=be&&p<=Le?(Et.map(h=>h.value).includes(p)||o([...Et,{value:p,label:`Last ${p} days`}]),a(p),i("")):p<be?i(`${be}`):i(`${Le}`)}};return t.createElement(k,null,t.createElement(k,{marginBottom:2},t.createElement(k,null,l.sort((d,p)=>d.value-p.value).map(({label:d,value:p})=>t.createElement(Ft,{key:p,label:d,className:n===p?e.chip:void 0,color:n===p?"primary":void 0,size:"small",onClick:()=>a(p)})))),t.createElement(k,null,t.createElement(G,{fullWidth:!0,placeholder:"Number of days",inputProps:{min:be,max:Le},onKeyDown:m,helperText:u(),value:s,type:"number",error:c(),onChange:d=>i(d.target.value)})))}const Ai=x(e=>({filters:{maxWidth:"300px",width:"100%",backgroundColor:e.palette.background.paper}})),$i=()=>{const e=Ai();return t.createElement(k,{className:e.filters},t.createElement(sa,null,t.createElement(Ii,null)),t.createElement(sa,null,t.createElement(Fi,null)),Object.values(R).map(n=>t.createElement(sa,{key:n,size:"small"},t.createElement(Li,{facet:n}))))},Tn=Ae({checkPassRateOverview:{data:void 0,isLoading:!0,isError:!1},trackPassRateOverview:{data:void 0,isLoading:!0,isError:!1},entityPassRatesOverview:{data:void 0,isLoading:!0,isError:!1},groupPassRatesOverview:{data:void 0,isLoading:!0,isError:!1}}),me=()=>$e(Tn),Mi=e=>{const{filter:n}=de(),a=Dl(n),r=Ol(n),l=Al(n),o=Ml(n),s=_(()=>({checkPassRateOverview:a,trackPassRateOverview:r,entityPassRatesOverview:l,groupPassRatesOverview:o}),[a,r,l,o]);return a.isLoading||r.isLoading||l.isLoading||o.isLoading?t.createElement(Se,null):t.createElement(Tn.Provider,{...e,value:s})},Rn=e=>{const n=(e==null?void 0:e.overallTrackPassRate)||[];if(!n.length)return[];const a=lt.utc();return n.reduce((r,{trendPassRates:l,levelOrdinal:o},s)=>{var i;const c=(i=l==null?void 0:l.map((u,m)=>({name:la(a,l.length-m-1),[`Level${o}`]:u})))!=null?i:[];return s===0?c:r.map((u,m)=>({...u,...c[m]}))},[])},Bi=()=>{var e,n;const{trackPassRateOverview:{data:a,isError:r}}=me();if(r)return t.createElement(b,{color:"error"},"Failed to load track data.");const l=Rn(a),o=(n=(e=a==null?void 0:a.overallTrackPassRate)==null?void 0:e.map(({levelOrdinal:s})=>({dataKey:`Level${s}`,name:`Level ${s}`})))!=null?n:[];return t.createElement(vt,{data:l,lines:o})},Vi=e=>{const n=(e==null?void 0:e.overallEntityPassRates)||[];if(!n.length)return[];const a=lt.utc();return n.reduce((r,{trendPassRates:l,id:o},s)=>{var i;const c=(i=l==null?void 0:l.map((u,m)=>({name:la(a,l.length-m-1),[o]:u})))!=null?i:[];return s===0?c:r.map((u,m)=>({...u,...c[m]}))},[])},Gi=()=>{var e,n;const{entityPassRatesOverview:{data:a}}=me(),r=(n=(e=a==null?void 0:a.overallEntityPassRates)==null?void 0:e.map(({id:o})=>({dataKey:o,name:M(o).name})))!=null?n:[],l=Vi(a);return t.createElement(vt,{data:l,lines:r})},zi=z(e=>({container:{position:"relative"},chartMessage:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontWeight:"bold",backgroundColor:e.palette.background.default,padding:e.spacing(1),borderRadius:"5px",textAlign:"center",width:"50%",zIndex:2}})),_i=({layout:e,theme:n})=>{const a=e===ft.Vertical,r=[{x:"A",y:25},{x:"B",y:50},{x:"C",y:75}],l=[{x:"A",y:100},{x:"B",y:90},{x:"C",y:80},{x:"C",y:70},{x:"C",y:60}],o=zi();return t.createElement("div",{className:o.container},t.createElement(gt,null,t.createElement(Ba,{data:a?l:r,margin:{left:0},layout:e},t.createElement(rt,{strokeDasharray:"3 3",vertical:a,horizontal:!a,opacity:ht}),t.createElement(ze,{dataKey:a?void 0:"x",type:a?Ke.Number:Ke.Category,domain:a?Ce:void 0,hide:!0}),t.createElement(_e,{width:a?Cn:oa,dataKey:a?"x":void 0,type:a?Ke.Category:Ke.Number,domain:a?void 0:Ce,hide:!0}),t.createElement(Va,{dataKey:"y",fill:n.palette.divider,barSize:a?Nn:Ln}))),t.createElement(b,{className:o.chartMessage},"No Data"))},Wi=x(e=>({legend:{color:ne(e)}}));var ft=(e=>(e.Horizontal="horizontal",e.Vertical="vertical",e))(ft||{});const Nn=20,Ln=50;var Ke=(e=>(e.Category="category",e.Number="number",e))(Ke||{});const Sn={dataKey:"passRate",name:"Pass rate"},Dn=Hn(({data:e,layout:n})=>{const a=n==="vertical",r=et(),l=ut(r),o=ne(r),s=Wi();return e.length?t.createElement(gt,{"aria-label":"Bar chart representing data points."},t.createElement(Ba,{data:e,layout:n},t.createElement(rt,{vertical:a,horizontal:!a,opacity:ht}),t.createElement(ze,{dataKey:a?void 0:pt,type:a?"number":"category",domain:a?Ce:void 0,stroke:o}),t.createElement(_e,{width:a?Cn:oa,dataKey:a?pt:void 0,type:a?"category":"number",domain:a?void 0:Ce,stroke:o}),t.createElement($a,{contentStyle:{backgroundColor:r.palette.background.default},itemStyle:{color:ne(r)},cursor:{fill:"transparent"}}),t.createElement(Ma,{iconType:bn,iconSize:kn,formatter:i=>t.createElement("span",{className:s.legend},i),payload:e.map(({name:i},c)=>({id:i,value:i,color:l[c%l.length]}))}),t.createElement(Va,{barSize:a?Nn:Ln,dataKey:Sn.dataKey,name:Sn.name},e.map(({name:i},c)=>t.createElement(ml,{key:i,fill:l[c%l.length]}))))):t.createElement(_i,{layout:n,theme:r})}),Hi=e=>{var n,a;return(a=(n=e==null?void 0:e.overallTrackPassRate)==null?void 0:n.map(({levelOrdinal:r,snapshotPassRate:l})=>({name:`Level ${r}`,passRate:l})))!=null?a:[]},qi=()=>{const{trackPassRateOverview:{data:e,isError:n}}=me();if(n)return t.createElement(b,{color:"error"},"Failed to load track data.");const a=Hi(e);return t.createElement(Dn,{data:a,layout:ft.Horizontal})},Ui=e=>{var n;return(n=e==null?void 0:e.map(({id:a,groupTitle:r,snapshotPassRate:l})=>({name:r!=null?r:M(a).name,passRate:l})))!=null?n:[]},Ki=()=>{var e;const{groupPassRatesOverview:{data:n}}=me(),a=(e=n==null?void 0:n.groupPassRates)==null?void 0:e.sort((l,o)=>o.snapshotPassRate-l.snapshotPassRate),r=Ui(a);return t.createElement(Dn,{data:r,layout:ft.Vertical})},ji=z(e=>({card:{display:"flex",flexDirection:"column",gap:e.spacing(1),border:`1px solid ${e.palette.divider}`,boxShadow:"none",width:"99%"},title:{fontWeight:"bold",fontSize:e.typography.h5.fontSize,lineHeight:`${e.typography.h3.fontSize}px`},subtitle:{fontSize:e.typography.pxToRem(14),lineHeight:`${e.typography.h6.fontSize}px`,color:e.palette.grey[800]},headerRow:{display:"flex",padding:e.spacing(1,2),borderBottom:`1px solid ${e.palette.divider}`,gap:e.spacing(2)},headerSection:{display:"flex",flexDirection:"column",gap:e.spacing(.5)},headerExportSection:{display:"flex",alignItems:"center",marginLeft:"auto",marginRight:0},contentRow:{padding:e.spacing(2.5,2),display:"flex",gap:e.spacing(2)},leftSection:{width:"200px"},summaryCard:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},chartSection:{flex:1,width:"100%",minWidth:"200px"},chartDisplaySummary:{flex:1,display:"flex",flexDirection:"row",gap:e.spacing(1),alignItems:"center",justifyContent:"end"}})),yt=({title:e,subtitle:n,summaryCardContent:a,chartSectionContent:r,disableDataExport:l,csvData:o,csvFilename:s})=>{const i=ji();return t.createElement(It,{className:i.card},t.createElement(k,{className:i.headerRow},t.createElement(k,{className:i.headerSection},t.createElement(b,{className:i.title},e),t.createElement(b,{variant:"caption"},n)),t.createElement(k,{className:i.headerExportSection},t.createElement(za,{data:o,filename:s,onClick:()=>!l},t.createElement(K,{title:"Export to CSV"},t.createElement("span",null,t.createElement(H,{disabled:l},t.createElement(ul,null))))))),t.createElement(k,{className:i.contentRow},a&&t.createElement(k,{className:i.leftSection},t.createElement(k,{className:i.summaryCard},a)),t.createElement(k,{className:i.chartSection},r)))};function ue(e,n){const a=e;if(n){const r=lt.utc();for(let l=n-1;l>=0;l--)a.push(r.minus({day:l}).toISODate())}return a}function De(e){return e?Math.max(...e.map(n=>{var a,r;return(r=(a=n.trendPassRates)==null?void 0:a.length)!=null?r:1})):0}function Yi(e){const n=[];return n.push(ue(["check_id","check_name","check_owner_ref"],De(e))),e!=null&&e.length&&e.map(a=>{var r;n.push([a.id,a.checkName,a.checkOwnerRef,...(r=a.trendPassRates)!=null?r:[a.snapshotPassRate]])}),n}function Qi(e){const n=[];return n.push(ue(["entity_ref","entity_name","entity_owner_ref"],De(e))),e!=null&&e.length&&e.map(a=>{var r;n.push([a.id,M(a.id).name,a.entityOwnerRef,...(r=a.trendPassRates)!=null?r:[a.snapshotPassRate]])}),n}function Xi(e){const n=[];return n.push(ue(["team_ref","team_name"],De(e))),e!=null&&e.length&&e.map(a=>{var r,l;n.push([a.id,(r=a.groupTitle)!=null?r:M(a.id).name,...(l=a.trendPassRates)!=null?l:[a.snapshotPassRate]])}),n}function Zi(e){const n=[],a=e!=null&&e.length?Math.max(...e.map(r=>De(r.levels))):0;return n.push(ue(["track_id","track_name","track_owner_ref","level_ordinal","level_name"],a)),e!=null&&e.length&&e.map(r=>{var l;(l=r.levels)==null||l.map(o=>{var s,i;n.push([r.id,r.trackName,r.trackOwnerRef,o.levelOrdinal,(s=o.levelName)!=null?s:`Level ${o.levelOrdinal}`,...(i=o.trendPassRates)!=null?i:[o.snapshotPassRate]])})}),n}function Ji(e){var n,a,r;const l=[];return l.push(ue(["name"],(a=(n=e==null?void 0:e.overallCheckPassRates)==null?void 0:n.length)!=null?a:0)),(r=e==null?void 0:e.overallCheckPassRates)!=null&&r.length&&l.push(["Check Pass Rate",...e.overallCheckPassRates]),l}function ec(e){var n;const a=[];return a.push(ue(["level_ordinal","level_name"],De(e==null?void 0:e.overallTrackPassRate))),(n=e==null?void 0:e.overallTrackPassRate)!=null&&n.length&&e.overallTrackPassRate.map(r=>{var l;a.push([r.levelOrdinal,`Level ${r.levelOrdinal}`,...(l=r.trendPassRates)!=null?l:[r.snapshotPassRate]])}),a}function tc(e){var n;const a=[];return a.push(ue(["entity_ref","entity_name"],De(e==null?void 0:e.overallEntityPassRates))),(n=e==null?void 0:e.overallEntityPassRates)!=null&&n.length&&e.overallEntityPassRates.map(r=>{var l;a.push([r.id,M(r.id).name,...(l=r.trendPassRates)!=null?l:[0]])}),a}function ac(e){var n,a;const r=[];return r.push(ue(["team_ref","team_name"],1)),(n=e==null?void 0:e.groupPassRates)!=null&&n.length&&((a=e==null?void 0:e.groupPassRates)==null||a.map(l=>{var o;r.push([l.id,(o=l.groupTitle)!=null?o:M(l.id).name,l.snapshotPassRate])})),r}const nc="check-pass-rates-summary.csv",rc="track-pass-rates-summary.csv",lc="entity-pass-rates-summary.csv",oc="team-pass-rates-summary.csv",sc="check-pass-rates.csv",ic="track-pass-rates.csv",cc="entity-pass-rates.csv",dc="team-pass-rates.csv",mc=x(e=>({chartHeader:{marginBottom:e.spacing(2)},overallSummaryBox:{display:"flex",flexDirection:"column",height:"100%",color:ne(e),textAlign:"center",gap:e.spacing(2)},percentage:{fontSize:e.typography.pxToRem(65),lineHeight:`${e.typography.pxToRem(88)}px`,fontWeight:"bold"},summaryText:{fontSize:e.typography.pxToRem(14),lineHeight:`${e.typography.pxToRem(14)}px`}})),uc=()=>{var e,n,a;const r=et(),l=mc(),{checkPassRateOverview:{data:o,isLoading:s,isError:i}}=me(),c=(n=(e=o==null?void 0:o.overallCheckPassRates)==null?void 0:e.length)!=null?n:0,u=ce((a=o==null?void 0:o.overallCheckPassRates)!=null?a:[]),m=o!=null&&o.overallCheckPassRates&&c?Math.round(o.overallCheckPassRates[c-1]):0;let d;!(o!=null&&o.overallCheckPassRates)||!c?d="No Data":d=`${m}%`;const p=t.createElement(k,{className:l.overallSummaryBox},t.createElement(pl,{value:m,text:d,styles:hl({textColor:ne(r),pathColor:ut(r)[0],trailColor:r.palette.divider,textSize:c?void 0:8})}),t.createElement(b,{className:l.summaryText},"Current check pass rate")),h=!(o!=null&&o.overallCheckPassRates)||!c||s||i;return t.createElement(yt,{title:"Check pass rate",subtitle:"Aggregate pass rate for checks",summaryCardContent:p,chartSectionContent:t.createElement(Ue,{chartData:u}),disableDataExport:h,csvFilename:nc,csvData:Ji(o)})},pc=()=>{var e;const n=t.createElement(qi,null),a=t.createElement(Bi,null),{trackPassRateOverview:{data:r,isLoading:l,isError:o}}=me(),s=(e=r==null?void 0:r.overallTrackPassRate)==null?void 0:e.length,i=!(r!=null&&r.overallTrackPassRate)||!s||l||o;return t.createElement(yt,{title:"Track pass rate",subtitle:"Aggregate pass rate for tracks",summaryCardContent:n,chartSectionContent:a,disableDataExport:i,csvFilename:rc,csvData:ec(r)})},hc=()=>{var e;const{entityPassRatesOverview:{data:n,isLoading:a,isError:r}}=me(),l=(e=n==null?void 0:n.overallEntityPassRates)==null?void 0:e.length,o=!(n!=null&&n.overallEntityPassRates)||!l||a||r;return t.createElement(yt,{title:"Entity pass rate",subtitle:"Compare the aggregate pass rate for entities",chartSectionContent:t.createElement(Gi,null),disableDataExport:o,csvFilename:lc,csvData:tc(n)})},gc=()=>{var e;const{groupPassRatesOverview:{data:n,isLoading:a,isError:r}}=me(),l=(e=n==null?void 0:n.groupPassRates)==null?void 0:e.length,o=!(n!=null&&n.groupPassRates)||!l||a||r;return t.createElement(yt,{title:"Team pass rate",subtitle:"Compare the aggregate pass rate for teams",chartSectionContent:t.createElement(Ki,null),disableDataExport:o,csvFilename:oc,csvData:ac(n)})},vc=z(e=>({root:{display:"flex",flexDirection:"column",gap:e.spacing(2),flex:1,background:e.palette.background.default}})),Ec=()=>{const e=vc();return t.createElement(k,{className:e.root},t.createElement(Mi,null,t.createElement(uc,null),t.createElement(pc,null),t.createElement(hc,null),t.createElement(gc,null)))},fc=z(e=>({paper:{width:"100%",boxShadow:"none",border:`1px solid ${e.palette.divider}`,borderRadius:e.shape.borderRadius},tableHeaderCell:{fontWeight:"bold"}})),Ct=({data:e,columns:n})=>{const a=fc(),[r,l]=y(0),[o,s]=y(10);$(()=>{l(0)},[e.length]);const i=(d,p)=>{l(p)},c=d=>{s(+d.target.value),l(0)},u=r*o,m=u+o;return t.createElement(Me,{className:a.paper},t.createElement(mr,{size:"small"},t.createElement(ur,null,t.createElement(xa,null,n.map(d=>t.createElement(Pa,{key:`header-${d.id}`,className:a.tableHeaderCell},d.label)))),t.createElement(pr,null,e.slice(u,m).map(d=>t.createElement(xa,{key:d.id},n.map(p=>t.createElement(Pa,{key:`cell-${p.id}`},p.renderCell?p.renderCell(d):d[p.id])))))),t.createElement(Ot,{rowsPerPageOptions:[10,25,50],component:"div",count:e.length,rowsPerPage:o,page:r,onPageChange:i,onRowsPerPageChange:c}))};var yc=(e=>(e.Check="check",e.Track="track",e.Entity="entity",e.Group="group",e))(yc||{});const Z=z(e=>({root:{display:"flex",flexDirection:"column",flex:1,background:e.palette.background.default},ownerText:{fontWeight:500,color:ne(e)},flexColumn:{display:"flex",flexDirection:"column",gap:e.spacing(.5)},boldText:{fontWeight:"bold"},descriptionText:{maxWidth:400,color:ne(e),fontSize:e.typography.subtitle2.fontSize,lineHeight:e.typography.subtitle1.fontSize},detailButton:{textTransform:"none",backgroundColor:"transparent","&:hover":{backgroundColor:e.palette.action.hover}}})),bt=({name:e="",description:n=""})=>{const a=Z();return t.createElement(k,{className:a.flexColumn},t.createElement(b,{className:a.boldText},e),t.createElement(fa,{className:a.descriptionText,content:n!=null?n:""}))},kt=({navigateTo:e})=>{const n=Z(),a=Ye();return t.createElement(H,{variant:"text",className:n.detailButton,onClick:()=>a(e)},t.createElement(b,{className:n.ownerText},"View detail"))},Cc=e=>(e==null?void 0:e.kind)==="Group",bc=e=>(e==null?void 0:e.kind)==="User",ia=({ownerEntityRef:e})=>{var n,a;const{data:r,error:l}=yr(e!=null?e:void 0);if(r){let o;return Cc(r)||bc(r)?o=(a=r.metadata.title)!=null?a:(n=r.spec.profile)==null?void 0:n.displayName:o=r.metadata.name,t.createElement(Ge,{entityRef:Zr(r),title:o})}else if(l&&e)return t.createElement(K,{title:"Unable to pull owner reference from Catalog API"},t.createElement(b,{style:{color:"red"},variant:"body2"},(()=>{try{return M(e).name}catch{return e}})()));return null},kc=({row:{trendPassRates:e,snapshotPassRate:n}})=>{const a=Z(),r=ce(e!=null?e:[]);return t.createElement(k,{className:a.flexColumn},t.createElement(b,{className:a.boldText},Math.round(n),"%"),t.createElement(Ue,{chartData:r,tableChart:!0}))};var J=(e=>(e[e.UP=0]="UP",e[e.DOWN=1]="DOWN",e[e.FLAT=2]="FLAT",e))(J||{});const xc=x(e=>({cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),Pc=({ownerEntityRef:e,passRates:n})=>{const a=xc();return t.createElement(Je,{dense:!0,disablePadding:!0,className:a.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Details"),e&&t.createElement(oe,{disableGutters:!0,className:a.listItem},t.createElement(K,{title:"Owner"},t.createElement(Q,null,t.createElement(nt,{color:"action",fontSize:"small"}))),t.createElement(X,{className:a.listItemText,primary:t.createElement(Ge,{entityRef:e!=null?e:"No Owner"})})),n.map(({name:r,value:l,trend:o},s)=>t.createElement(oe,{disableGutters:!0,className:a.listItem,key:s},t.createElement(K,{title:"The most recent pass rate."},t.createElement(Q,null,o===J.UP&&t.createElement(gl,{color:"primary",fontSize:"small"}),o===J.DOWN&&t.createElement(vl,{color:"error",fontSize:"small"}),o===J.FLAT&&t.createElement(El,{color:"action",fontSize:"small"}))),t.createElement(X,{className:a.listItemText,primary:t.createElement(b,{variant:"body2",color:"textSecondary"},r!=null?r:"Latest Pass Rate",": ",t.createElement("b",null,Math.round(l),"%"))}))))},wc=z(e=>({root:{display:"flex",flexDirection:"column",width:"100%"},gridContainer:{flexGrow:1},cardContent:{display:"flex",flexDirection:"column",gap:e.spacing(1),height:"100%"},footer:{display:"flex",flexDirection:"column",gap:e.spacing(1),justifyContent:"end",marginTop:"auto"}})),xt=({data:e})=>{const n=wc(),a=Ye(),[r,l]=y(0),[o,s]=y(10);$(()=>{l(0)},[e.length]);const i=(p,h)=>{l(h)},c=p=>{try{const h=Number.parseInt(p.target.value,10);s(h),l(0)}catch{}},u=r*o,m=u+o,d=[{dataKey:"passRate",name:"Pass rate"}];return t.createElement(k,{className:n.root},t.createElement(g,{container:!0,spacing:2,className:n.gridContainer},e.slice(u,m).map((p,h)=>{var v,C;return t.createElement(g,{item:!0,key:h,xs:12,sm:12,md:6,lg:4,xl:3},t.createElement(qe,{title:(v=p.name)!=null?v:p.id,description:p.description,children:t.createElement(k,{className:n.cardContent},t.createElement(k,{className:n.footer},t.createElement(Pc,{ownerEntityRef:p.owner,passRates:p.lineChart.snapshotPassRates}),t.createElement(vt,{data:p.lineChart.trendPassRates,lines:(C=p.lineChart.lineConfigs)!=null?C:d}))),handleView:()=>a(p.navigateTo)}))})),t.createElement(Ot,{rowsPerPageOptions:[10,25,50],component:"div",count:e.length,rowsPerPage:o,page:r,onPageChange:i,onRowsPerPageChange:c}))};var V=(e=>(e[e.TABLE=0]="TABLE",e[e.GRID=1]="GRID",e))(V||{});function Pt(e){if(!e||!e.length)return J.FLAT;if(e.length===1)return e[0]>0?J.UP:J.FLAT;const n=e[e.length-1]-e[0];return n<0?J.DOWN:n>0?J.UP:J.FLAT}function Tc(e,n){return e.map(a=>{var r,l,o,s,i;return{id:a.id,name:(r=a.checkName)!=null?r:a.id,description:(l=a.checkDescription)!=null?l:void 0,lineChart:{snapshotPassRates:[{value:a.snapshotPassRate,trend:Pt((o=a.trendPassRates)!=null?o:[])}],trendPassRates:ce((s=a.trendPassRates)!=null?s:[])},owner:(i=a.checkOwnerRef)!=null?i:void 0,navigateTo:n()}})}function Rc(e,n){return e.map(a=>{var r,l,o,s;return{id:a.id,name:M(a.id).name,description:(r=a.entityDescription)!=null?r:void 0,lineChart:{snapshotPassRates:[{value:a.snapshotPassRate,trend:Pt((l=a.trendPassRates)!=null?l:[])}],trendPassRates:ce((o=a.trendPassRates)!=null?o:[])},owner:(s=a.entityOwnerRef)!=null?s:void 0,navigateTo:`${n(M(a.id))}/soundcheck`}})}function Nc(e,n){return e.map(a=>{var r,l,o;return{id:a.id,name:(r=a.groupTitle)!=null?r:M(a.id).name,lineChart:{snapshotPassRates:[{value:a.snapshotPassRate,trend:Pt((l=a.trendPassRates)!=null?l:[])}],trendPassRates:ce((o=a.trendPassRates)!=null?o:[])},navigateTo:n(M(a.id))}})}function Lc(e,n){return e.map(a=>{var r,l,o,s,i,c,u;return{id:a.id,name:(r=a.trackName)!=null?r:a.id,description:(l=a.trackDescription)!=null?l:void 0,lineChart:{snapshotPassRates:(s=(o=a.levels)==null?void 0:o.map(({levelOrdinal:m,levelName:d,snapshotPassRate:p,trendPassRates:h})=>({name:d?`Level ${m} (${d})`:`Level ${m}`,value:p,trend:Pt(h!=null?h:[])})))!=null?s:[],trendPassRates:Rn({overallTrackPassRate:a.levels}),lineConfigs:(c=(i=a.levels)==null?void 0:i.map(({levelOrdinal:m,levelName:d})=>({dataKey:`Level${m}`,name:d!=null?d:`Level ${m}`})))!=null?c:[]},owner:(u=a.trackOwnerRef)!=null?u:void 0,navigateTo:n({trackId:a.id})}})}const Sc=z(e=>({header:{padding:e.spacing(0,0,1),display:"flex"},headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"end"},exportButton:{height:"40px",width:"112px"},listItemIcon:{minWidth:"30px"},menuItem:{width:"112px"}})),wt=({viewMode:e,setViewMode:n,isLoading:a,searchTerm:r,setSearchTerm:l,searchPlaceholder:o,csvData:s,csvFilename:i})=>{const c=Sc(),u=(C,E)=>{E!==null&&n(E)},[m,d]=t.useState(null),p=!!m,h=C=>{d(C.currentTarget)},v=()=>{d(null)};return t.createElement(g,{container:!0,spacing:2,className:c.header},t.createElement(g,{item:!0,xs:6},t.createElement(aa,{searchTerm:r,setSearchTerm:l,disabled:a,placeholder:o||"Search",variant:"outlined",size:"small"})),t.createElement(g,{item:!0,xs:6,className:c.headerButtons},t.createElement(H,{id:"export-button",className:c.exportButton,disabled:a,variant:"contained",color:"primary","aria-controls":p?"export-menu":void 0,"aria-haspopup":"true","aria-expanded":p?"true":void 0,onClick:h,endIcon:t.createElement(bl,null)},"Export"),t.createElement(Nt,{id:"export-menu",anchorEl:m,getContentAnchorEl:null,open:p,onClose:v,MenuListProps:{"aria-labelledby":"export-button",disablePadding:!0},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"}},t.createElement(za,{data:s,filename:i},t.createElement(ge,{onClick:v,className:c.menuItem},t.createElement(Q,{className:c.listItemIcon},t.createElement(Cl,null)),t.createElement(X,null,"CSV")))),t.createElement(jr,{size:"small",value:e,exclusive:!0,onChange:u},t.createElement(Sa,{value:V.TABLE},t.createElement(fl,{color:"primary"})),t.createElement(Sa,{value:V.GRID},t.createElement(yl,{color:"primary"})))))},Dc=(e,n)=>{const a=Math.min(5,n-e+1);return Array.from({length:a}).map((r,l)=>{const o=e+l;return{label:`LEVEL ${o}`,id:`levels-${l}`,renderCell:s=>{var i;const c=(i=s.levels)==null?void 0:i.find(({levelOrdinal:u})=>u===o);return c?t.createElement(kc,{row:c}):t.createElement(t.Fragment,null)}}})},Ic=(e,n)=>{const a=e.flatMap(o=>{var s;return((s=o.levels)==null?void 0:s.map(i=>i.levelOrdinal))||[]}),r=Math.min(...a),l=Math.max(...a);return[{label:"NAME",id:"trackName",renderCell:o=>{var s;return t.createElement(bt,{name:(s=o.trackName)!=null?s:o.id,description:o.trackDescription})}},...Dc(r,l),{label:"OWNER",id:"trackOwnerRef",renderCell:o=>{var s;return t.createElement(ia,{ownerEntityRef:(s=o.trackOwnerRef)!=null?s:void 0})}},{label:"ACTION",id:"action",renderCell:o=>t.createElement(kt,{navigateTo:n({trackId:o.id})})}]},Oc=()=>{const e=Z(),{filter:n}=de(),a=ve(Tr),{data:r,isLoading:l,isError:o}=Fl(n),[s,i]=y(V.TABLE),[c,u]=y(""),m=_(()=>{var v;return Ic((v=r==null?void 0:r.individualTrackPassRate)!=null?v:[],a)},[r==null?void 0:r.individualTrackPassRate,a]);if(l)return t.createElement(Se,null);if(o)return t.createElement(b,{color:"error"},"Failed to load tracks");const{individualTrackPassRate:d}=r;if(!d)return t.createElement(b,{color:"error"},"No available tracks");const p=c.length?d.filter(({id:v,trackName:C})=>{var E;return((E=C==null?void 0:C.toLowerCase())==null?void 0:E.includes(c.toLowerCase()))||v.toLowerCase().includes(c.toLowerCase())}):d,h=Zi(p);return t.createElement(k,{className:e.root},t.createElement(g,{container:!0,direction:"row"},t.createElement(wt,{viewMode:s,setViewMode:i,isLoading:l,searchTerm:c,setSearchTerm:u,searchPlaceholder:"Search available tracks",csvData:h,csvFilename:ic}),s===V.TABLE&&t.createElement(Ct,{data:p,columns:m}),s===V.GRID&&t.createElement(xt,{data:Lc(p,a)})))},Fc=({row:{trendPassRates:e,snapshotPassRate:n}})=>{const a=Z(),r=ce(e!=null?e:[]);return t.createElement(k,{className:a.flexColumn},t.createElement(b,{className:a.boldText},Math.round(n),"%"),t.createElement(Ue,{chartData:r,tableChart:!0}))};function Ac(e){return[{label:"NAME",id:"entityName",renderCell:({id:n,entityDescription:a})=>t.createElement(bt,{name:M(n).name,description:a})},{label:"TREND",id:"trend",renderCell:n=>t.createElement(Fc,{row:n})},{label:"OWNER",id:"entityOwnerRef",renderCell:({entityOwnerRef:n})=>t.createElement(ia,{ownerEntityRef:n!=null?n:void 0})},{label:"ACTION",id:"action",renderCell:({id:n})=>t.createElement(kt,{navigateTo:`${e(M(n))}/soundcheck`})}]}const $c=()=>{const e=Z(),{filter:n}=de(),a=ve(Oa),{data:r,isLoading:l,isError:o}=$l(n),[s,i]=y(V.TABLE),[c,u]=y("");if(l)return t.createElement(Se,null);if(o)return t.createElement(b,{color:"error"},"Failed to load entities");const{individualEntityPassRates:m}=r;if(!m)return t.createElement(b,{color:"error"},"No available entities");const d=c.length?m.filter(({id:h})=>{var v;return(v=h.toLowerCase())==null?void 0:v.includes(c.toLowerCase())}):m,p=Qi(d);return t.createElement(k,{className:e.root},t.createElement(g,{container:!0,direction:"row"},t.createElement(wt,{viewMode:s,setViewMode:i,isLoading:l,searchTerm:c,setSearchTerm:u,searchPlaceholder:"Search available entities",csvData:p,csvFilename:cc}),s===V.TABLE&&t.createElement(Ct,{data:d,columns:Ac(a)}),s===V.GRID&&t.createElement(xt,{data:Rc(d,a)})))},Mc=({row:{trendPassRates:e,snapshotPassRate:n}})=>{const a=Z(),r=ce(e!=null?e:[]);return r.length?t.createElement(k,{className:a.flexColumn},t.createElement(b,{className:a.boldText},Math.round(n),"%"),t.createElement(Ue,{chartData:r,tableChart:!0})):t.createElement(k,{className:a.flexColumn},t.createElement(b,null,"No data"))};function Bc(e){return[{label:"NAME",id:"groupName",renderCell:({groupTitle:n,id:a})=>t.createElement(bt,{name:n!=null?n:M(a).name})},{label:"TREND",id:"trend",renderCell:n=>t.createElement(Mc,{row:n})},{label:"ACTION",id:"action",renderCell:({id:n})=>t.createElement(kt,{navigateTo:e(M(n))})}]}const Vc=()=>{const e=Z(),{filter:n}=de();n.context=void 0;const a=ve(Oa),{data:r,isLoading:l,isError:o}=Bl(n),[s,i]=y(V.TABLE),[c,u]=y("");if(l)return t.createElement(Se,null);if(o)return t.createElement(b,{color:"error"},"Failed to load groups");const{groupPassRates:m}=r;if(!m)return t.createElement(b,{color:"error"},"No available groups");const d=c.length?m.filter(({id:h,groupTitle:v})=>{var C;return((C=v==null?void 0:v.toLowerCase())==null?void 0:C.includes(c.toLowerCase()))||h.toLowerCase().includes(c.toLowerCase())}):m,p=Xi(d);return t.createElement(k,{className:e.root},t.createElement(g,{container:!0,direction:"row"},t.createElement(wt,{viewMode:s,setViewMode:i,isLoading:l,searchTerm:c,setSearchTerm:u,searchPlaceholder:"Search available teams",csvFilename:dc,csvData:p}),s===V.TABLE&&t.createElement(Ct,{data:d,columns:Bc(a)}),s===V.GRID&&t.createElement(xt,{data:Nc(d,a)})))},Gc=({row:e})=>{var n;const a=Z(),r=ce((n=e.trendPassRates)!=null?n:[]);return t.createElement(k,{className:a.flexColumn},t.createElement(b,{className:a.boldText},Math.round(e.snapshotPassRate),"%"),t.createElement(Ue,{chartData:r,tableChart:!0}))};function zc(e){return[{label:"NAME",id:"checkName",renderCell:n=>{var a;return t.createElement(bt,{name:(a=n.checkName)!=null?a:n.id,description:n.checkDescription})}},{label:"TREND",id:"snapshotPassRate",renderCell:n=>t.createElement(Gc,{row:n})},{label:"OWNER",id:"checkOwner",renderCell:n=>{var a;return t.createElement(ia,{ownerEntityRef:(a=n.checkOwnerRef)!=null?a:void 0})}},{label:"ACTION",id:"action",renderCell:()=>t.createElement(kt,{navigateTo:e()})}]}const _c=()=>{const e=Z(),{filter:n}=de(),a=ve(Rr),{data:r,isLoading:l,isError:o}=Il(n),[s,i]=y(V.TABLE),[c,u]=y("");if(l)return t.createElement(Se,null);if(o)return t.createElement(b,{color:"error"},"Failed to load checks");const{individualCheckPassRates:m}=r;if(!m)return t.createElement(b,{color:"error"},"No available checks");const d=c.length?m.filter(({id:h,checkName:v})=>{var C;return((C=v==null?void 0:v.toLowerCase())==null?void 0:C.includes(c.toLowerCase()))||h.toLowerCase().includes(c.toLowerCase())}):m,p=Yi(d);return t.createElement(k,{className:e.root},t.createElement(g,{container:!0,direction:"row"},t.createElement(wt,{viewMode:s,setViewMode:i,isLoading:l,searchTerm:c,setSearchTerm:u,searchPlaceholder:"Search available checks",csvData:p,csvFilename:sc}),s===V.TABLE&&t.createElement(Ct,{data:d,columns:zc(a)}),s===V.GRID&&t.createElement(xt,{data:Tc(d,a)})))},Wc=x(e=>({container:{display:"flex",margin:"-24px",backgroundColor:e.palette.background.paper,borderTop:`1px solid ${e.palette.border}`,flex:1},fixedColumn:{width:"300px",flex:"none",borderRight:`1px solid ${e.palette.border}`},flexibleColumn:{display:"flex",flexDirection:"column",flex:1,backgroundColor:e.palette.background.paper,height:"100%",maxWidth:"100%"},pageLayout:{display:"flex",flexDirection:"column",flex:"1 1 0%",backgroundColor:e.palette.background.default,"& > article":{display:"flex",flexDirection:"column",flex:"1 1 auto",borderTop:`1px solid ${e.palette.border}`}}})),Hc=()=>{const e=Wc();return t.createElement(wi,null,t.createElement("div",{className:e.container},t.createElement("div",{className:e.fixedColumn},t.createElement($i,null)),t.createElement("div",{className:e.flexibleColumn},t.createElement(k,{className:e.pageLayout},t.createElement(Ea,null,t.createElement(Qe,{path:"/*",element:t.createElement(W,null,t.createElement(W.Route,{title:"Summary",path:"/"},t.createElement(Ec,null)),t.createElement(W.Route,{title:"Checks",path:"/checks"},t.createElement(_c,null)),t.createElement(W.Route,{title:"Tracks",path:"/tracks"},t.createElement(Oc,null)),t.createElement(W.Route,{title:"Entities",path:"/entities"},t.createElement($c,null)),t.createElement(W.Route,{title:"Teams",path:"/teams"},t.createElement(Vc,null)))}))))))},qc=({collector:e,children:n})=>{const{description:a,id:r,isEditable:l,name:o}=e,{setSelectedCollector:s,setShowModal:i}=ot(),{loading:c,allowed:u}=te({permission:_r}),m=l&&!c&&u,d=()=>{i(!0),s(e)};return t.createElement(qe,{title:o!=null?o:r,description:a,viewLabel:"Configure",editLabel:"Configure",children:n,handleView:void 0,handleEdit:m?d:void 0})},Uc=()=>t.createElement(t.Fragment,null,Array.from({length:6},(e,n)=>t.createElement(g,{key:`loading-${n}`,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem"},t.createElement(zt,{variant:"rect",height:385}))));function Kc(e){switch(e){case"catalog":return kl;case"github":return Pl;case"scm":return xl;case"soundcheck":return Tl;case"techinsights":return Rl;default:return wl}}const jc=x(e=>({container:{display:"flex",justifyContent:"center",alignItems:"center"},imageContainer:{width:"150px",height:"150px"},image:{width:"100%",height:"100%",objectFit:"contain"}})),Yc=({collector:e})=>{const{id:n}=e,a=jc();return t.createElement(t.Fragment,null,t.createElement("div",{className:a.container},t.createElement("div",{className:a.imageContainer},t.createElement("img",{src:Kc(n),alt:n,className:a.image}))))},Qc=()=>{const{data:e,isLoading:n}=Za();return t.createElement(g,{container:!0,direction:"row"},t.createElement(g,{container:!0,spacing:4,role:"list","aria-label":"checks"},n?t.createElement(Uc,null):e==null?void 0:e.sort((a,r)=>{var l,o;return((l=a.name)!=null?l:a.id).localeCompare((o=r.name)!=null?o:r.id)}).map(a=>t.createElement(g,{key:a.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(qc,{collector:a},t.createElement(Yc,{collector:a}))))))},In=()=>({enabled:!1,hasDuration:!1,unit:A.Days,value:1});function ca(e){if(e){const{enabled:n,hasDuration:a}=e;if(n&&a){const{unit:r,value:l}=e;return{duration:{[r]:l}}}return n}}function da(e){var n;const a=In();if(!e)return a;if(typeof e=="boolean")return{...a,enabled:e};if(!Ve.isObject(e)||!("duration"in e))return a;const r=e.duration;if(!Ve.isObject(r))return a;const l=Object.entries(r);if(l.length===0)return a;const[o,s]=l[0];return{...a,enabled:!0,hasDuration:!0,unit:(n=dt(o))!=null?n:A.Days,value:s}}const Xc=x(e=>({duration:{display:"flex",padding:e.spacing(1),gap:e.spacing(2),alignItems:"flex-start"},checkbox:{margin:e.spacing(-1.5,0)},label:{cursor:"pointer"}})),Zc=({value:e,onChange:n,disabled:a,errors:r})=>{const l=Xc(),[o,s]=y(e),[i,c]=y(`${e.value}`);$(()=>{n&&n(o)},[o,n]);const u=h=>{s({...o,enabled:h.target.checked,hasDuration:h.target.checked&&o.hasDuration})},m=h=>{s({...o,hasDuration:h.target.checked})},d=h=>{c(h.target.value);const v=parseInt(h.target.value,10);s({...o,value:isNaN(v)?0:v})},p=h=>{var v;s({...o,unit:(v=dt(h.target.value))!=null?v:A.Hours})};return t.createElement(g,{container:!0,direction:"column"},t.createElement(g,{item:!0},t.createElement(g,{container:!0,alignItems:"center"},t.createElement(g,{item:!0},t.createElement(Be,{id:"enableCaching",disabled:a,checked:o.enabled,onChange:u,"data-testid":"enableCaching"})),t.createElement(g,{item:!0},t.createElement("label",{htmlFor:"enableCaching",className:l.label},"Enable caching")))),t.createElement(g,{item:!0},t.createElement(g,{container:!0,alignItems:"flex-start"},t.createElement(g,{item:!0,className:l.checkbox},t.createElement(Be,{id:"hasDuration",disabled:a||!o.enabled,checked:o.enabled&&o.hasDuration,onChange:m,"data-testid":"hasDuration"})),t.createElement(g,{item:!0},t.createElement("label",{htmlFor:"hasDuration",className:o.enabled?l.label:""},"Duration")),t.createElement(g,{className:l.duration},t.createElement(g,{item:!0},t.createElement(G,{id:"every",type:"number",label:"For",name:"for",disabled:a||!o.hasDuration,value:i,onChange:d,error:!!(r!=null&&r.message),helperText:r==null?void 0:r.message,inputProps:{min:an,max:nn},"data-testid":"forTextField"})),t.createElement(g,{item:!0},t.createElement(Lt,null,t.createElement(St,{id:"duration-unit"},"Unit"),t.createElement(Dt,{labelId:"duration-unit",disabled:a||!o.hasDuration,value:o.unit,onChange:p,"data-testid":"unitSelect"},Yt.map(h=>t.createElement(ge,{key:h,value:h},h)))))))))},Jc=({enabled:e,hasDuration:n,value:a})=>e&&n?rn(a):!0,ed=x(e=>({root:{padding:e.spacing(1)},tabsContainer:{marginRight:16},tab:{height:"64px",textAlign:"left"},contentContainer:{width:"100%",padding:e.spacing(1)},divider:{marginTop:e.spacing(8),marginBottom:e.spacing(8)}})),ma=({name:e,label:n,description:a,control:r,disabled:l,errors:o})=>{const[s,i]=y(0),c=$t({control:r,name:`${e}.enabled`}),u=(d,p)=>{i(p)},m=ed();return t.createElement("div",{className:m.root},t.createElement(U,{name:`${e}.enabled`,control:r,render:({field:d})=>t.createElement(Ze,{control:t.createElement(hr,{...d,checked:d.value,"data-testid":`${e}-switch`}),label:t.createElement(k,{display:"flex",flexDirection:"column"},t.createElement(b,{variant:"body1",component:"span"},t.createElement("b",null,`${n}`)),t.createElement(b,{variant:"caption",color:"textSecondary",component:"p"},`${a}`))})}),c&&t.createElement("div",null,t.createElement(gr,{orientation:"horizontal",variant:"scrollable",value:s,onChange:u,className:m.tabsContainer},t.createElement(At,{label:"Frequency",className:m.tab}),t.createElement(At,{label:"Filters",className:m.tab}),t.createElement(At,{label:"Caching",className:m.tab})),t.createElement("div",{className:m.contentContainer},s===0&&t.createElement("div",null,t.createElement(U,{name:`${e}.frequency`,control:r,rules:{validate:mn},render:({field:d})=>t.createElement(ln,{disabled:l,value:d.value,onChange:d.onChange,errors:o==null?void 0:o.frequency})})),s===1&&t.createElement("div",null,t.createElement(U,{name:`${e}.filters`,control:r,render:({field:d})=>t.createElement(ea,{disabled:l,value:d.value,onChange:d.onChange})})),s===2&&t.createElement("div",null,t.createElement(U,{name:`${e}.cacheConfig`,control:r,rules:{validate:Jc},render:({field:d})=>t.createElement(Zc,{disabled:l,value:d.value,onChange:d.onChange,errors:o==null?void 0:o.cacheConfig})})))))},ua=()=>({enabled:!1,filters:{...it(),selectedKinds:["Component"]},frequency:jt(),cacheConfig:In()}),On=()=>({branchProtections:ua(),repositoryDetails:ua(),repositoryLanguages:ua()});function td(e){const{branchProtections:n,repositoryDetails:a,repositoryLanguages:r}=e;if(n.enabled||a.enabled||r.enabled){const l={},o=[];if(l.collects=o,n.enabled){const{cacheConfig:s,frequency:i,filters:c}=n;o.push({factName:"branch_protections",type:"BranchProtections",frequency:Qt(i),filters:ct(c),cache:ca(s)})}if(a.enabled){const{cacheConfig:s,frequency:i,filters:c}=a;o.push({factName:"repository_details",type:"RepositoryDetails",frequency:Qt(i),filters:ct(c),cache:ca(s)})}if(r.enabled){const{cacheConfig:s,frequency:i,filters:c}=r;o.push({factName:"repository_languages",type:"RepositoryLanguages",frequency:Qt(i),filters:ct(c),cache:ca(s)})}return l}return[]}function ad(e){var n,a,r,l,o,s;const i=On();if(e){const c=e.collects;if(c)for(const u of Bt(c)){const m=u.type;m==="BranchProtections"&&(i.branchProtections={enabled:!0,frequency:Xt((n=u.frequency)!=null?n:e.frequency),filters:Kt((a=u.filters)!=null?a:e.filters),cacheConfig:da(u.cache)}),m==="RepositoryDetails"&&(i.repositoryDetails={enabled:!0,frequency:Xt((r=u.frequency)!=null?r:e.frequency),filters:Kt((l=u.filters)!=null?l:e.filters),cacheConfig:da(u.cache)}),m==="RepositoryLanguages"&&(i.repositoryLanguages={enabled:!0,frequency:Xt((o=u.frequency)!=null?o:e.frequency),filters:Kt((s=u.filters)!=null?s:e.filters),cacheConfig:da(u.cache)})}}return i}const nd="Error Configuring Collector";function rd(){const e=I(F),n=Ee(),{showAlert:a}=se(),r=async l=>{const o=await e.updateCollectorConfig(l);if(!o)throw new Error("Failed to update collector configuration.");return o};return fe([ye.UpdateCollectorConfig],r,{onSuccess:()=>{n.invalidateQueries({queryKey:[L.GetCollectors]})},onError:l=>{let o="Failed to update collector configuration.";l instanceof Error&&(o=l.message),a({severity:"error",title:nd,message:o})}})}const ld=({disabled:e})=>{const{hideModal:n,selectedCollector:a}=ot(),{control:r,formState:{errors:l},handleSubmit:o}=Ta({defaultValues:a?ad(a.config):On(),mode:"onChange"}),s=!!l.branchProtections||!!l.repositoryDetails||!!l.repositoryLanguages,{mutateAsync:i}=rd(),c=async u=>{const m=td(u);await i({collectorId:"github",config:m})&&n()};return t.createElement("form",{onSubmit:o(c)},t.createElement(ma,{name:"branchProtections",label:"Branch Protections",description:"Collects branch protection information from an entity's repository.",control:r,disabled:e,errors:l.branchProtections}),t.createElement(Xe,null),t.createElement(ma,{name:"repositoryDetails",label:"Repository Details",description:"Collects details about the an entity's repository.",control:r,disabled:e,errors:l.repositoryDetails}),t.createElement(Xe,null),t.createElement(ma,{name:"repositoryLanguages",label:"Repository Languages",description:"Collects details about the languages used in an entity's repository.",control:r,disabled:e,errors:l.repositoryLanguages}),t.createElement(g,{container:!0,spacing:4},t.createElement(Ut,{onCancel:n,saveButtonText:"Save",isLoading:!1,onSave:o(c),disableSave:s})))},od=({title:e,open:n,handleClose:a})=>{const{selectedCollector:r}=ot();return t.createElement(st,{handleClose:a,title:e,open:n},(r==null?void 0:r.id)==="github"&&t.createElement(ld,null))},sd=x(e=>({container:{padding:e.spacing(3)}})),id=()=>{var e;const n=sd(),{selectedCollector:a,showModal:r,hideModal:l}=ot();return t.createElement("div",{className:n.container},t.createElement(Qc,null),t.createElement(od,{title:a?(e=a.name)!=null?e:a.id:"",open:r,handleClose:l}))},cd=()=>t.createElement(Hl,null,t.createElement(id,null)),dd=x(e=>({root:{position:"relative",height:"100%"},cardSection:{marginBottom:e.spacing(2)},listItem:{padding:0},listItemText:{margin:0}})),md=({campaign:e})=>{var n;const a=dd();return t.createElement(Je,{dense:!0,disablePadding:!0,className:a.cardSection},t.createElement(b,{variant:"overline",color:"textSecondary"},"Campaign Details"),t.createElement(oe,{disableGutters:!0,className:a.listItem},t.createElement(K,{title:"Owner"},t.createElement(Q,null,t.createElement(nt,{color:"action",fontSize:"small"}))),t.createElement(X,{className:a.listItemText,primary:t.createElement(Ge,{entityRef:(n=e.ownerEntityRef)!=null?n:"No Owner"})})))},ud=({campaign:e})=>{const{id:n,name:a,description:r,ownerEntityRef:l}=e,o=ve(Nr),s=ve(Lr),i=Ye(),{loading:c,allowed:u}=te({permission:Wr,resourceRef:e.id});return t.createElement(qe,{title:a!=null?a:n,description:r,children:l&&t.createElement(md,{campaign:e}),handleView:()=>i(o({campaignId:e.id})),handleEdit:!c&&u?()=>i(s({campaignId:e.id})):void 0})};function pd(e){const n=I(F);return B([L.GetCampaigns,JSON.stringify(e)],async()=>n.getCampaigns(e),{staleTime:5*60*1e3,refetchInterval:!1,refetchOnWindowFocus:!1})}const hd=x(e=>({headerButtons:{display:"flex",gap:e.spacing(1),flexWrap:"nowrap",justifyContent:"end",alignItems:"center"},header:{padding:e.spacing(0,0,1)}})),gd=({campaignsPerPage:e,currentCursor:n})=>{const a=hd(),[r,l]=y(n),[o,s]=y([]),{data:i,isLoading:c}=pd({ids:void 0,first:e,after:r}),[u,m]=y(i);$(()=>{i&&m(()=>{var w;return{endCursor:i.endCursor,totalCount:i.totalCount,hasNextPage:(w=i==null?void 0:i.hasNextPage)!=null?w:!1,edges:i.edges}})},[i]);const d=u==null?void 0:u.edges.map(w=>w.campaign),{setShowAddModal:p}=Wl(),[h,v]=y(""),[C,E]=y("default"),[f,P]=y("all"),[T]=y([]),S=w=>{E(w.target.value)},N=w=>{P(w.target.value)};return t.createElement(g,{container:!0,direction:"row"},t.createElement(g,{container:!0,spacing:4,className:a.header},t.createElement(na,{searchPlaceholder:"Search available campaigns",isLoading:c,searchTerm:h,setSearchTerm:v,filterAlpha:C,handleAlphabeticalFilterChange:S,filterOwner:f,handleOwnerFilterChange:N,owners:T}),t.createElement(g,{item:!0,xs:3},t.createElement("div",{className:a.headerButtons},t.createElement(H,{variant:"contained",color:"primary",onClick:()=>p(!0)},"Create Campaign")))),t.createElement(g,{container:!0,spacing:4,role:"list","aria-label":"campaigns"},c?t.createElement(pn,null):d==null?void 0:d.map(w=>t.createElement(g,{key:w.id,xs:12,sm:12,md:6,lg:4,xl:3,item:!0,role:"listitem","aria-label":"result"},t.createElement(ud,{campaign:w})))),((u==null?void 0:u.hasNextPage)||(o==null?void 0:o.length)>0)&&t.createElement(ra,{response:u,listingsPerPage:e,cursor:r,setCursor:l,prevCursors:o,setPrevCursors:s,labelPerPageDropdown:"Campaigns Per Page:",urlRoute:"campaigns?campaignsPerPage="}))},vd=x(e=>({campaignsPageContainer:{padding:e.spacing(3)}})),Ed=()=>{const e=vd(),[n]=Rt(),a=n.get("campaignsPerPage"),r=a?parseInt(a,10):9;return t.createElement("div",{className:e.campaignsPageContainer},t.createElement(gd,{campaignsPerPage:r}))},fd=()=>t.createElement(_l,null,t.createElement(Ed,null)),Fn=()=>{const e=Ye(),n=ve(Sr),{campaignId:a}=qn();return t.createElement(st,{title:"Campaign Detail View",open:!0,handleClose:()=>e(n())},t.createElement("div",null,"Campaign: ",a),t.createElement("div",null,"Placeholder"))},yd=x(()=>({tabContent:{margin:0,padding:0},root:{"& > *":{display:"flex",flexDirection:"column",flexGrow:1}},pageContent:{display:"flex",flexDirection:"row",flexGrow:1},pageLayout:{display:"flex",flexDirection:"column",flex:"1 1 0%","& > article":{display:"flex",flexDirection:"column",flex:"1 1 auto"}}})),Cd=({title:e="Soundcheck"})=>{var n;const a=yd(),[r,l]=Cr(),{group:o}=r,[s,i]=y(void 0),c=(n=I(wr).getOptionalBoolean("soundcheck.campaigns.enable"))!=null?n:!1,{loading:u,allowed:m}=te({permission:Hr}),d=h=>{h&&l({...r,group:h})},p=Un();return t.createElement(Dr,null,t.createElement(br,null,t.createElement(Ir,null,t.createElement(Or,null,t.createElement(k,{className:a.root},t.createElement(Yn,{themeId:"tool"},t.createElement(Jn,{backend:"soundcheck",invalidLicenseMessage:"Submitted facts and check results will still be stored, but it will not be possible to view certifications or individual results until a valid license is present."}),t.createElement(Qn,{title:e},p.pathname.split("/").length-1===1&&t.createElement(kr,{onChange:d,initialValue:o,setError:i})),t.createElement(k,{className:a.pageContent},t.createElement(k,{className:a.pageLayout},t.createElement(Ea,null,t.createElement(Qe,{path:"/*",element:t.createElement(W,null,t.createElement(W.Route,{title:"Overview",path:"/"},t.createElement("div",{className:a.tabContent},t.createElement(xr,{groupSelectorError:s,searchParams:r,setSearchParams:l}))),c&&t.createElement(W.Route,{title:"Campaigns",path:"/campaigns"},t.createElement(fd,null)),t.createElement(W.Route,{title:"Tech Health",path:"/tech-health"},t.createElement(Hc,null)),t.createElement(W.Route,{title:"Checks",path:"/checks"},t.createElement(cs,null)),t.createElement(W.Route,{title:"Tracks",path:"/tracks"},t.createElement(ni,null)),!u&&m&&t.createElement(W.Route,{title:"Collectors",path:"/collectors"},t.createElement(cd,null)))}),t.createElement(Qe,{element:t.createElement(Fn,null),path:"/campaigns/:campaignId"}),t.createElement(Qe,{element:t.createElement(Fn,null),path:"/campaigns/:campaignId/edit"}))))))))))};export{Cd as RoutingPage};
|
|
2
|
+
//# sourceMappingURL=index-29e115b6.esm.js.map
|