import{a7 as H,h1 as q,dl as a,l as w,aD as J,d_ as z,R as E,d$ as C,w as G,dk as I,j as K,fd as Q,h as d,i as u,e7 as r,ai as X,fb as W,dm as l,S as M,e0 as T}from"./app-BgLa5dit.js";import{u as Y}from"./ekVIVtrT.chunk.js";import{u as Z}from"./8Im-OACs.chunk.js";import{E as ee,C as ie}from"./7ILDX1zd.chunk.js";import{g as se}from"./DPqnN5u1.chunk.js";import"./g56uS58q.chunk.js";import"./B5-QmNlz.chunk.js";import"./CPYC3VpT.chunk.js";import"./CJkmdwb7.chunk.js";import"./CTg_3F42.chunk.js";const te={classificationVideos(s,o,t){return{key:`presentation:${o}:classification:${s}:videos${t?`:${t}`:""}`,url:H.urlBuilder(`/ajax/topics/${s}/videos`,{query:q(a.Videos,o),cursor:t})}}},y=se(X.Subject),oe={[r.Video]:s=>y.video(s.id),[r.Series]:s=>({application:u.SERIES,action:d.Series.EDIT_SERIES,args:[s.id]}),[`${r.Video}:${r.Audience}`]:s=>y.videoAudiences(s.id),[`${r.Series}:${r.Audience}`]:s=>({application:u.SERIES,action:d.Series.EDIT_SERIES_AUDIENCES,args:[s==null?void 0:s.id]}),library:(s,o)=>({application:u.SUBJECTS,action:o==="exchange"?d.Libraries.EXCHANGE:d.Libraries.HOSTED_LIBRARIES,args:[s]})};function ne(s,o,t){const m=I();function b(p){return M.classificationMembers(s,o,t,p)}function f(p){m(b(p))}return Y(b,f).items}function Se(s){const{presentationId:o,classificationId:t}=s,m=w(),b=J(z.SUBJECT),[f,p]=E.useState(),[c,R]=E.useState(),[O,$]=E.useState();C(T.getPresentationFetchOptions(o,p),[]),C(T.getClassificationFetchOptions(t,R),[t]),C(T.getAudiencesFetchOptions(o,$),[t]);const V=ne(t,a.PinnedVideos,o),g=V?G.toObject(V,"id"):{};function A(e){return te.classificationVideos(t,o,e)}const S=I();function j(e){S(A(e))}const{items:x,isFetching:F,hasMore:L,nextCursor:U}=Z(A,j);function k(e){const i={...c,pinnedVideoMasterId:e};b.updateClassification(t,i)}function h(e){const i=l.singularizeMemberType(a.Videos),n=e==="add"?`Successfully added ${i} to topic`:`Successfully removed ${i} from topic`;m.success(n)}function v(e){const i=l.singularizeMemberType(a.Videos),n=e==="add"?`Failed to add ${i} to topic`:`Failed to remove ${i} from topic`;m.error(n)}function B(e,i){S(M.addObjectsToClassification(c.id,[e],i,()=>h("add"),()=>v("add")))}function N(e,i){S(M.removeObjectsFromClassification(c.id,[e],i,()=>h("remove"),()=>v("remove")))}function D(e){const i={application:u.SUBJECTS,action:d.Subjects,subjectId:t,ownerType:W.Classification,memberType:a.Videos,memberId:e.id},n=g[e.id];return[l.buildMemberAction({actionName:"pinVideo",callback:()=>k(e.id),...i}),l.buildMemberAction({actionName:n?"hideInClassification":"showInClassification",callback:()=>n?N(e.id,a.PinnedVideos):B(e.id,a.PinnedVideos),...i}),l.buildMemberAction({actionName:"remove",...i})]}function P(e){ie.exportMembers(e,a.Videos,c==null?void 0:c.name)}function _(e,i,n){return{application:u.SUBJECTS,action:d.Subjects.BULK_REMOVE_CLASSIFICATION_MEMBERS,args:[e,i],params:{memberIds:n}}}return K.jsx(ee,{classificationId:t,memberType:a.Videos,presentation:f,classification:c,audiences:O,visibleVideos:g,items:x,isFetching:F,hasMore:L,nextCursor:U,fetchNext:j,columnActions:D,appLinks:oe,getTabs:(e,i,n)=>Q.getEditClassificationTabs(u.SUBJECTS,e,i,n),onExport:P,bulkRemoveAppLink:_})}export{Se as EditClassificationVideosView};
//# sourceMappingURL=ByaR8bOn.chunk.js.map
