import{aT as j,w as C,dn as v,dp as x,R as T,dq as y,j as i,ap as S,dm as P,ai as g,dr as w,f5 as I,dt as D}from"./app-BgLa5dit.js";import{S as V}from"./BT3VnoQK.chunk.js";import{S as M}from"./B9ND9p3V.chunk.js";import{C as k}from"./CTg_3F42.chunk.js";function R(e,s){j.useEffect(()=>{!e.presentations||e.currentPresentation||V.getSetStateByKey(s,"currentPresentation")(C.first(e.presentations))},[e.presentations])}function B(e){var d,l,o;const s=(d=Object.keys((e==null?void 0:e.classificationsPaths)||{}))==null?void 0:d.reduce((t,n)=>(e.classificationsPaths[n].forEach(u=>{const r=u.map(m=>m.map(h=>h.name).join(" -> "));t[n]=r}),t),{}),c=(l=e.availableClassifications)==null?void 0:l.map(t=>{var f,u;const n=e.presentations.find(r=>r.id===t.presentationId);return{...t,path:s==null?void 0:s[t.id],presentation:(n==null?void 0:n.name)??"",presentationDescription:(n==null?void 0:n.description)??"",visibility:(f=e.visibleInClassifications)==null?void 0:f.includes(t.id),shouldShowVisibility:!!((u=e==null?void 0:e.mappedClassification)!=null&&u.find(r=>t.id===r.id))}}).filter(t=>!!t.presentation),a=v.getColumnSet(x.VideoClassificationMapping),b=T.useMemo(()=>y({columns:a,columnData:e.columnData}),[e.columnData]);return(o=e.availableClassifications)!=null&&o.length?i.jsx(S,{theme:k,columns:b,data:c,enableSort:!0}):i.jsx("p",{className:"py-3",children:i.jsx("i",{children:"There are no available topics for this video. Please ensure you've mapped the video to a backbone subject first"})})}function E({objectClassifications:e,objectSubjectClassifications:s}){const c=[...e,...s].map(a=>a.id);return a=>!c.includes(a.id)}function F({objectClassifications:e,objectSubjectClassifications:s}){const c=[...e,...s.filter(a=>a.type===I.CurriculumLeaf)].map(a=>a.id);return a=>!c.includes(a.id)}function $(e){var l,o;const s=P.singularizeMemberType(e.memberType);let c;e!=null&&e.isVideoClassification||(c=e.presentationType===g.Subject?E(e):F(e));const a=!!e.currentPresentation&&!!((o=(l=e.classificationTree)==null?void 0:l.children)!=null&&o.length),b=()=>i.jsxs(i.Fragment,{children:[i.jsx("h6",{children:"Topic visibility"}),i.jsx("p",{children:"Select which available presentations to add the video into. Modify whether the video can be hidden or visible in the topic. In both cases the video will be searchable."}),i.jsx(B,{availableClassifications:e.availableClassifications,presentations:e.presentations,classificationsPaths:e.classificationsPaths,visibleInClassifications:e.visibleInClassification,isFetchingVisibility:e.isFetchingVisibility,videoId:e.videoId,columnData:e.columnData,mappedClassification:e.mappedClassification})]}),d=()=>i.jsxs(i.Fragment,{children:[i.jsx("h6",{children:"Topics"}),i.jsx("p",{children:`Select a presentation to view its topics and map them to this ${s}.`}),i.jsx("div",{className:"w-50 pb-3",children:i.jsx(D,{presentations:e.presentations,currentPresentationId:e.currentPresentation.id,setCurrentPresentation:e.setCurrentPresentation})}),a?i.jsxs(i.Fragment,{children:[i.jsx("p",{children:"Only topics which are mapped to one of the backbone subjects selected above can be selected."}),i.jsx(M,{initialValues:{classificationIds:e.objectClassifications.map(t=>t.id)},presentationId:e.currentPresentation.id,presentationType:e.presentationType,classificationTree:e.classificationTree,saveClassifications:e.saveClassifications,isClassificationDisabled:c})]}):i.jsx("p",{children:"This presentation has no topics."})]});return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"border-bottom pb-3 mb-3",children:[i.jsx("h2",{className:"h6",children:"Backbone Subjects"}),i.jsx("p",{children:`Select which backbone subjects this ${s} is mapped to.`}),i.jsx(w,{initialValues:{backboneClassificationIds:e.objectSubjects.map(t=>t.id)},presentationType:e.presentationType,subjectTree:e.subjectTree,saveSubjects:e.saveSubjects,memberType:e.memberType,saveBtnText:"Save Backbone Subjects",allowMultiple:!0})]}),e.isVideoClassification?i.jsx(b,{}):i.jsx(d,{})]})}export{$ as E,R as u};
//# sourceMappingURL=B7G3Oog2.chunk.js.map
