import{bp as A,ao as r,ap as E,bS as O,bT as T,aI as f,bc as y,aO as I,bq as w,L as b,v as S,az as x,ak as p,gz as R,gy as h,bN as q,f as z,e as B,c4 as D,aq as H,m as M}from"./app-k0jcl5PQ.js";import{a as F}from"./BcYgJJPz.chunk.js";import{P as G}from"./BpwqQXZV.chunk.js";import{O as U,P as $}from"./Kb3MNbLP.chunk.js";import"./DwDhXSrj.chunk.js";import"./EHuWazu9.chunk.js";import"./CCtuxSlD.chunk.js";import"./CPXlV0fg.chunk.js";import"./ApI7cEru.chunk.js";import"./DXxHdeNz.chunk.js";import"./CpGXOT1_.chunk.js";import"./DkDkjje4.chunk.js";import"./hKqzfsO4.chunk.js";import"./fstW5ZQE.chunk.js";import"./9ls1F1Ve.chunk.js";import"./DRKUY7jf.chunk.js";import"./BzSUSuAL.chunk.js";function V(e){const s=A(),{curriculums:i,center:a,onClick:u,selectionId:n}=e;return r.jsx("ul",{className:E((a||s.sm||s.xs)&&"mx-auto","w-100 px-0 row g-3 list-unstyled"),children:i.map(t=>{const c=t.cover?O.createUrl(t.cover.url,{size:T.Small}):"";return r.jsx("li",{className:"col-lg-3 col-12",children:r.jsx(F,{data:t,coverUrl:c,onClick:()=>u(t),isSelected:n===t.id,className:"h-auto",coverBgColor:"white",multiline:!0})},t.id)})})}const v="subjects.curriculumSelector",d=b.encloseNamespace(v);function W(e){var P;const[s,i]=f.useState(!1),[a,u]=f.useState((P=e.currentCurriculum)==null?void 0:P.id),[n,t]=f.useState(!0),c=y();f.useEffect(()=>{e.isOnboarding&&e.currentCurriculum&&t(!1)},[e.isOnboarding,e.currentCurriculum]);function l(o){var m;if(a===o.id){u(null),t(!0);return}o.id===((m=e.currentCurriculum)==null?void 0:m.id)&&!e.isOnboarding?t(!0):n&&t(!1),u(o.id)}function g(){var m;if(n)return;if(((m=e.currentCurriculum)==null?void 0:m.id)===a&&e.nextAppLink){S.trigger(e.nextAppLink);return}i(!0);const o=e.curriculums.find(L=>L.id===a);e.saveChanges(o,C,N)}function C(){if(i(!1),!e.isOnboarding){c.success(d("success")),t(!0);return}e.nextAppLink&&S.trigger(e.nextAppLink)}function N(){i(!1),c.error(d("error"))}function k(){return e.isOnboarding?e.nextAppLink?d("next"):d("getStarted"):d("save")}return r.jsx(I.Provider,{value:v,children:r.jsxs("form",{children:[r.jsx("div",{className:"position-relative",children:r.jsx(V,{curriculums:e.curriculums,onClick:l,selectionId:a})}),r.jsx(w,{variant:"dark",disabled:n,onClick:g,showSpinner:s,children:k()})]})})}const j="settings.curriculum",_=b.encloseNamespace(j);function me(){var c;const e=x(p.availablePresentations()),s=x(R.presentation(h.Curriculum));q({title:_("pageTitle")});const i=x(p.allLevelPreferences()),a=((c=e.data)==null?void 0:c.length)&&U.hasManyPresentationTypes(e.data).hasManyCurriculumPresentations;f.useEffect(()=>{e.hasCompleted&&(a||S.trigger({application:B.SETTINGS,action:z.Settings.TOPIC_PREFERENCES},{replace:!0}))},[e.hasCompleted]);const u=D();function n(l,g,C){M(u,p.setPresentation(l,h.Curriculum,g,C))}const t=!!(s.hasCompleted&&e.hasCompleted);return r.jsxs($,{availablePresentations:e.data,audiences:i.data,children:[r.jsx("p",{className:"mt-3",children:r.jsx(H,{namespace:j,phrase:"info"})}),t&&a?r.jsx(W,{curriculums:e.data.filter(l=>l.type===h.Curriculum),currentCurriculum:s.data,saveChanges:n}):r.jsx(G,{count:2})]})}export{me as CurriculumProfileView};
//# sourceMappingURL=BUAXGlWo.chunk.js.map
