import{j as a,aO as E,bk as g,T,e6 as N,at as f,dj as v,l as L,a as o,R as A,bi as G,e7 as I,h as b,i as u,dq as O,bE as P,ar as B,ap as H,y as m}from"./app-BgLa5dit.js";import{E as l}from"./0GREfvNX.chunk.js";import{D}from"./JAv_fVmZ.chunk.js";import{D as R}from"./CGQPfl0D.chunk.js";function _(e){return a.jsxs(l,{className:"py-5",children:[a.jsx(l.Image,{src:E.EmptyStates.Dashboard.DASHBOARDS}),a.jsx(l.Heading,{children:"No dashboards yet"}),a.jsx(l.Info,{children:"Create a new dashboard for each user type."}),a.jsx(l.Cta,{text:"New dashboard",icon:g,appLink:e.newDashboardAppLink})]})}const x="Generate dashboard with AI";function U(e){var c;if(!e.shouldShowAiGeneration)return a.jsx(a.Fragment,{});const n=(c=e.aiGeneratedProcess)==null?void 0:c.some(h=>R.isDashboardProcessOnGoing(h.status));return a.jsx(T,{spanHack:!0,title:n?"AI dashboard generation in progress. Please wait for it to complete before creating another.":"",children:a.jsx(N,{shouldShow:!n,wrapperClassName:"py-1 pe-2",children:n?a.jsx(v,{variant:"outline",disabled:!0,showSpinner:!0,spinnerText:x}):a.jsx(f,{appLink:{...e.getNewDashboardAppLink(),params:{isAi:!0}},className:"py-1 cursor-pointer",svg:g,disabled:n,children:x})})})}function J(e){var p;const n=L(),c=o.getDashboardTargetInfo((p=e.dashboards)==null?void 0:p[0]),h=o.isContentPartnerDashboard(c),S=A.useMemo(()=>{var t;return(t=e.dashboards)==null?void 0:t.map(s=>({...s,dateCreated:G.convertUTCToLocal(s.dateCreated).toString()})).sort((s,i)=>new Date(i.dateCreated).getTime()-new Date(s.dateCreated).getTime())},[e.dashboards]);async function w(t,s){try{if(await e.onStatusChange({...t,status:s}),s===m.Archived){n.success("The dashboard has been successfully archived");return}n.success("The dashboard has been successfully drafted")}catch{if(s===m.Archived){n.error("Something went wrong while archiving the dashboard");return}n.error("Something went wrong while drafting the dashboard")}}function C(t){const s=D.getIsDeleteDisabled(t.status),i=o.isSystemGeneratedDashboard(t.widgets),r=h&&t.metadata.systemGenerated,d=[{label:"Edit details",appLink:e.getEditDetailsAppLink(t.id),disabled:r,tooltip:r&&"System Generated dashboards cannot be edited.",className:r?"disabled":""},{label:"Edit content",appLink:{application:u.DASHBOARD_EDITOR,action:b.DashboardEditor.EDIT_DASHBOARD,args:[t.id]},disabled:r,tooltip:r&&"System Generated dashboards cannot be edited.",className:r?"disabled":""}];return d.push({label:"Copy dashboard",appLink:e.getCopyDashboardAppLink(t.id),className:i?"disabled":"",tooltip:i&&"System Generated dashboards cannot be copied.",disabled:i}),t.status!==m.Published&&o.isClassificationDashboard(o.getDashboardTargetInfo(t))&&d.push({label:"Add unused videos",appLink:{application:u.SUBJECTS,action:b.Subjects.ADD_UNUSED_VIDEOS,args:[t.id]}}),e.onClickExportVideos&&d.push({label:"Export video report",onClick:()=>e.onClickExportVideos(t)}),e.onClickExportSeriesVideos&&d.push({label:"Export series videos report",onClick:()=>e.onClickExportSeriesVideos(t)}),d.push({label:"Delete",appLink:e.getDeleteAppLink(t.id),className:s?"disabled":"text-danger",tooltip:s&&"Can only delete unpublished dashboards",disabled:s}),d}const k={actions:C,appLinks:{[I.Dashboard]:t=>({application:u.DASHBOARD_EDITOR,action:b.DashboardEditor.EDIT_DASHBOARD,args:[t.id]})},extraData:{getExtraAppLinkActions:t=>D.getStatusActions(e.dashboards,t,e.presentation,(s,i)=>w(t,i),e.classification),disableActions:!e.canPublish}},j=A.useMemo(()=>O({columns:e.columns,columnData:k}),[e.dashboards,e.canPublish]);function y(){return e.dashboards?e.dashboards.length===0?a.jsx(_,{newDashboardAppLink:e.getNewDashboardAppLink()}):a.jsx(H,{theme:D.getDashboardTableTheme(),data:S,columns:j}):a.jsx("div",{className:"text-center py-3",children:a.jsx(B,{as:"div",animation:"border",role:"status"})})}return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"d-flex justify-content-between align-items-end mb-2",children:[a.jsxs("div",{className:"d-flex align-items-center justify-content-end",children:[a.jsx("div",{className:"fw-semibold me-2",children:"Show archived dashboards"}),a.jsx(P,{on:!e.filterArchivedDashboards,onClick:()=>e.setFilterArchivedDashboards(!e.filterArchivedDashboards)})]}),a.jsxs("div",{className:"d-flex align-items-center",children:[a.jsx(U,{shouldShowAiGeneration:e.shouldShowAiGeneration,aiGeneratedProcess:e.aiGeneratedProcess,getNewDashboardAppLink:e.getNewDashboardAppLink}),a.jsx(f,{appLink:e.getNewDashboardAppLink(),className:"btn btn-dark ms-2",svg:g,children:"New dashboard"})]})]}),y()]})}export{J as D};
//# sourceMappingURL=BYqcacqE.chunk.js.map
