import{u as Y,V as Z,l as $,cB as z,k as _,R as B,o as h,S as P,cs as I,dl as Q,aW as X,b as aa,j as c,ar as ea,fd as sa,i as b,h as D,D as k,dn as ta,dp as ia,aR as na,be as d,a4 as N,bd as oa,w as O,s as ra,ag as V}from"./app-BgLa5dit.js";import{u as ca}from"./ekVIVtrT.chunk.js";import{E as da}from"./CPYC3VpT.chunk.js";import{D as A}from"./BE59vaMU.chunk.js";import{u as la}from"./BchTdWrs.chunk.js";import{a as g}from"./CGQPfl0D.chunk.js";import{D as ua}from"./JAv_fVmZ.chunk.js";import{D as fa}from"./BYqcacqE.chunk.js";import{C as pa}from"./gSHF4kJG.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"./D6bTl1fN.chunk.js";import"./kOrk-qeI.chunk.js";function ma(e){const[n,y]=Y(Z.AI_GENERATED_DASHBOARD_PROCESS_ID),l=$(),u=z(),E=_(),t=B.useCallback(()=>{n&&E(A.getTopicAiGeneratedDashboardProcess(n,f=>{f.status===g.Submitted||f.status===g.Processing||(S(),y(""),f.status===g.Completed&&(u([`ai:generated:dashboard:${e.classificationId}`,"dashboard"]),l.success("Dashboard successfully created.")),f.status===g.Failed&&l.error("Failed to generate dashboard, please try again."))}))},[n]),S=la(t,void 0,!!n)}function Oa(e){var M,j;const[n,y]=B.useState(!0),l=_(),u=h(P.presentation(e.presentationId)),E=h(na.currentUser()),t=h(P.classification(e.classificationId)),S=t.data&&!I.isTopLevelTopic(t.data),f=h(S&&A.getTopicAiGeneratedDashboard(e.classificationId));ma({classificationId:e.classificationId});function R(a){return A.dashboards({targetType:k.Classification,classificationId:e.classificationId},n,a)}function F(a){l(R(a))}const H=ca(R,F),L=(j=(M=h(P.classificationMembers(e.classificationId,Q.Tags)).data)==null?void 0:M.data)==null?void 0:j.find(a=>a.name===X.MOVIES_AND_TV),{hasPermissions:v}=aa();function U(){return!!(v(N.TopicDashboardStatusUpdate)||L&&v(N.MoviesAndTvDashboardStatusUpdate)||I.isTertiary(e.presentationId)||I.isNewZealandTopic(e.presentationId)||I.isInternationalTopic(e.presentationId)||I.isCanadaTopic(e.presentationId))}async function x(a,o){const m=a.reduce((i,s,C)=>{var T;let p=s.name;if(!p){const r=a[C-1];r&&r.templateId===oa.Heading&&(p=r.name)}return(T=s.data.objectIds)==null||T.forEach(r=>{i[r]=p}),s.data.playlistId&&(i[s.data.playlistId]=p),i},{}),W=Object.keys(m),J=O.chunk(W,25).map(i=>l(ra.curationStudioExport(i))),K=O.flatten(await Promise.all(J)).reduce((i,s)=>{var C;if(s.typeId===V.Playlist||s.typeId===V.Series){const p=s,T=m[s.id];return i.concat(((C=p.videos)==null?void 0:C.data.map(r=>({video:r,heading:T})))||[])}return i.concat({video:s,heading:m[s.id]})},[]);ua.exportDashboardReport(K,u.data.description,t.data.name,o)}async function w(a){return x(a.widgets.filter(o=>o.widgetId===d.CuratedSeries),a.name)}async function G(a){const o=[d.PlaylistMedia,d.CuratedMedia,d.ClassificationMedia,d.LatestReleasedVideos,d.ClassificationFeaturedVideo,d.ClassificationPinnedVideos];x(a.widgets.filter(m=>o.includes(m.widgetId)),a.name)}function q(a){return l(A.updateDashboard(a.id,a))}return!u.data||!E.data||!t.data?c.jsx("div",{className:"text-center py-3",children:c.jsx(ea,{as:"div",animation:"border",role:"status"})}):c.jsxs(c.Fragment,{children:[c.jsx(da,{memberType:e.memberType,presentation:u.data,classificationId:e.classificationId,getTabs:(a,o)=>sa.getEditClassificationTabs(b.SUBJECTS,a,o,v)}),c.jsx(pa,{classification:t.data,active:"new-releases"}),c.jsx(fa,{dashboards:H.items,classification:t.data,presentation:u.data,onStatusChange:q,canPublish:U(),columns:ta.getColumnSet(ia.ClassificationDashboard),filterArchivedDashboards:n,setFilterArchivedDashboards:y,aiGeneratedProcess:f.data,shouldShowAiGeneration:S,getEditDetailsAppLink:a=>({application:b.SUBJECTS,action:D.Subjects.EDIT_CLASSIFICATION_DASHBOARD,args:[e.classificationId,a]}),getDeleteAppLink:a=>({application:b.SUBJECTS,action:D.Subjects.REMOVE_CLASSIFICATION_DASHBOARD,args:[e.classificationId,a]}),getNewDashboardAppLink:()=>({application:b.SUBJECTS,action:D.Subjects.NEW_CLASSIFICATION_DASHBOARD,args:[e.classificationId,e.presentationId,k.Classification]}),getCopyDashboardAppLink:a=>({application:b.SUBJECTS,action:D.Subjects.COPY_CLASSIFICATION_DASHBOARD,args:[a]}),onClickExportVideos:G,onClickExportSeriesVideos:w})]})}export{Oa as EditClassificationDashboardListView};
//# sourceMappingURL=gxVGUNLU.chunk.js.map
