import{R as G,k as W,o as m,S as h,dl as U,aW as w,b as Y,j as c,ar as z,fd as J,i as l,h as A,D as R,dn as K,dp as Q,aR as X,be as r,a4 as L,bd as Z,w as y,s as $,ag as N}from"./app-BgLa5dit.js";import{u as aa}from"./ekVIVtrT.chunk.js";import{E as ea}from"./CPYC3VpT.chunk.js";import{D as M}from"./BE59vaMU.chunk.js";import{D as ta}from"./JAv_fVmZ.chunk.js";import{D as sa}from"./BYqcacqE.chunk.js";import"./KIVqng-q.chunk.js";import"./B5-QmNlz.chunk.js";import"./CTg_3F42.chunk.js";import"./DEF_vJGe.chunk.js";import"./0GREfvNX.chunk.js";import"./CGQPfl0D.chunk.js";function ba(t){var D,E;const[S,v]=G.useState(!0),I=W(),u=m(h.presentation(t.presentationId)),x=m(X.currentUser()),b=m(h.classification(t.classificationId));function g(a){return M.dashboards({targetType:R.Classification,classificationId:t.classificationId},S,a)}function _(a){I(g(a))}const k=aa(g,_),O=(E=(D=m(h.classificationMembers(t.classificationId,U.Tags)).data)==null?void 0:D.data)==null?void 0:E.find(a=>a.name===w.MOVIES_AND_TV),{hasPermissions:C}=Y();function V(){return!!(C(L.TopicDashboardStatusUpdate)||O&&C(L.MoviesAndTvDashboardStatusUpdate))}async function T(a,i){const n=a.reduce((s,e,p)=>{var f;let d=e.name;if(!d){const o=a[p-1];o&&o.templateId===Z.Heading&&(d=o.name)}return(f=e.data.objectIds)==null||f.forEach(o=>{s[o]=d}),e.data.playlistId&&(s[e.data.playlistId]=d),s},{}),P=Object.keys(n),j=y.chunk(P,25).map(s=>I($.curationStudioExport(s))),q=y.flatten(await Promise.all(j)).reduce((s,e)=>{var p;if(e.typeId===N.Playlist||e.typeId===N.Series){const d=e,f=n[e.id];return s.concat(((p=d.videos)==null?void 0:p.data.map(o=>({video:o,heading:f})))||[])}return s.concat({video:e,heading:n[e.id]})},[]);ta.exportDashboardReport(q,u.data.description,b.data.name,i)}async function B(a){return T(a.widgets.filter(i=>i.widgetId===r.CuratedSeries),a.name)}async function F(a){const i=[r.PlaylistMedia,r.CuratedMedia,r.ClassificationMedia,r.LatestReleasedVideos,r.ClassificationFeaturedVideo,r.ClassificationPinnedVideos];T(a.widgets.filter(n=>i.includes(n.widgetId)),a.name)}function H(a){return I(M.updateDashboard(a.id,a))}return!u.data||!x.data||!b.data?c.jsx("div",{className:"text-center py-3",children:c.jsx(z,{as:"div",animation:"border",role:"status"})}):c.jsxs(c.Fragment,{children:[c.jsx(ea,{memberType:t.memberType,presentation:u.data,classificationId:t.classificationId,getTabs:(a,i,n)=>J.getEditClassificationTabs(l.STREAMABLE_LEARNING,a,i,n)}),c.jsx(sa,{presentation:u.data,dashboards:k.items,onStatusChange:H,canPublish:V(),columns:K.getColumnSet(Q.ClassificationDashboard),filterArchivedDashboards:S,setFilterArchivedDashboards:v,getEditDetailsAppLink:a=>({application:l.STREAMABLE_LEARNING,action:A.StreamableLearning.EDIT_CLASSIFICATION_DASHBOARD,args:[t.classificationId,a]}),getDeleteAppLink:a=>({application:l.STREAMABLE_LEARNING,action:A.StreamableLearning.REMOVE_CLASSIFICATION_DASHBOARD,args:[t.classificationId,a]}),getNewDashboardAppLink:()=>({application:l.STREAMABLE_LEARNING,action:A.StreamableLearning.NEW_CLASSIFICATION_DASHBOARD,args:[t.classificationId,t.presentationId,R.Classification]}),getCopyDashboardAppLink:a=>({application:l.STREAMABLE_LEARNING,action:A.StreamableLearning.COPY_CLASSIFICATION_DASHBOARD,args:[a]}),onClickExportVideos:F,onClickExportSeriesVideos:B})]})}export{ba as EditClassificationDashboardListView};
//# sourceMappingURL=BQJr2NJO.chunk.js.map
