1import{j as e,r as a}from"./react-vendor.B75MsAI9.js";import{cY as t,u as s,U as l,Q as r,a as i,O as o,L as n,a0 as c,a4 as d,t as m,s as u,r as g,p,cR as _,_ as b,R as h,cQ as j,$ as v,cP as y,i as k,w as x,a2 as $,gy as f,x as S,y as L,z as w}from"./AuthModalContainer.D3JsQqnf.js";import{P as A}from"./PageHeader.DzbSaWOY.js";import{B as I}from"./Block.v-v90TCf.js";import{C as N,g as V,b as C,c as T}from"./main.DrmgIV4z.js";import{F}from"./FiltersPanel.CZMrAA8h.js";import{F as R}from"./FiltersBar.DCM5nKCa.js";import"./RTLProvider.Bmr48mpV.js";import"./LazyFontLoader.5DGfhuFK.js";import"./flatMap.CYmCgMUm.js";import"./pick.uU6gbf1j.js";import"./SelectField.B1q6eOH-.js";import"./Inliner.7-BReDbg.js";const q=({title:a,subText:s})=>{const l="pb-stem-topic-container";return e.jsxs("div",{className:`${l}__coming-soon`,children:[e.jsx("img",{className:`${l}__img`,src:t.comingSoon,alt:"soon"}),e.jsxs("div",{children:[e.jsx("div",{className:`${l}__coming-soon--title`,children:a}),e.jsx("div",{children:s})]})]})},P=({viewport:t,parentClassName:d,getBooksForLpWorkFlow:m,getLpFromBookIdWorkFlow:u,attributes:g,subjectVariant:p,userId:_,userType:b,isRtl:h,eventCategory:j})=>{const v=s(),y="pb-fixed-carousel",k={[y]:!0,[d]:d},{fixedSetAllTopics:x,fixedSetMaths:$,fixedSetScience:f}=g,[S,L]=a.useState([]),[w,A]=a.useState([]),[C,T]=a.useState(!1),F=new URLSearchParams(window.location.search).get("language")||"en";let R=[];("EVS"===p?f:"Maths"===p?$:x).map(e=>(R=[...R,e.bookId],0));const q=(e,a,t)=>{let s=[];if(e.length>0){let t=e.filter(e=>parseInt(e.id,10)===a.id);t.length>0&&(s=t[0].data.filter(e=>e.locale===F))}return t.medium?s:s.slice(0,2)};return a.useEffect(()=>{if(R.length>0){T(!0),m({books:R,pledge:!1}).then(e=>{var a;const t=(null==e?void 0:e.ok)&&(null==(a=null==e?void 0:e.data)?void 0:a.stories)?e.data.stories:(null==e?void 0:e.stories)||(null==e?void 0:e.data)||[];L(Array.isArray(t)?t:[])}).catch(e=>{L([])});const e=R.map(e=>u({id:e}).then(a=>a&&a.ok?{id:e,data:a.data}:{id:e,data:null}).catch(()=>({id:e,data:null})));Promise.all(e).then(e=>{A(e),T(!1)})}},[g]),C?e.jsx(l,{}):e.jsx(a.Fragment,{children:e.jsx(I,{noHorizontalPadding:!0,noVerticalPadding:!0,background:t.large?"transparent":"default",children:e.jsx("div",{className:r(k),children:S.length>0&&e.jsx(N,{parentClassName:`${y}__card-carousel`,viewport:t,popoutControls:t.xxlarge,cardsInFrame:{small:1,medium:1,large:1},dots:!0,arrows:!1,isRtl:h,children:S.map((a,s)=>e.jsxs("div",{className:h?`${y}__carousel--rtl`:`${y}__carousel`,children:[e.jsxs("div",{className:`${y}__image-block--rtl`,children:[e.jsx("div",{className:`${y}__background-circle`}),e.jsx("div",{className:h?`${y}__book-card-block--rtl ${y}__book-card-block`:`${y}__book-card-block`,children:e.jsx(V,{book:a,hideMenu:!0,hideQuickViewBtn:!0,hideAllIcons:!0,readSource:"stem",href:o.stemBook(a.slug,F),originalAuthors:a.original_authors,eventLabel:i.carousel,eventCategory:j,viewport:t},a.id)})]}),e.jsxs("div",{className:`${y}__description-block`,children:[e.jsxs("div",{className:`${y}__book-description`,children:[e.jsx("div",{className:h?`${y}__title--rtl ${y}__title`:`${y}__title`,children:a.title}),e.jsx("div",{className:h?`${y}__description--rtl ${y}__description`:`${y}__description`,children:a.description})]}),e.jsx("div",{className:`${y}__grade-flex`,children:[...q(w,a,t)].map((a,t)=>{let s="maths"===a.subject.toLowerCase();return e.jsx("div",{className:h?`${y}__grade-block--rtl ${y}__grade-block`:`${y}__grade-block`,children:e.jsx(n,{href:o.stemLP(s?"maths":"science",a.id,F),onClick:()=>(e=>{const{event:a,label:t,itemType:s,itemId:l,item_value:r,userId:i,userType:o}=e;window.dataLayer.push({...a&&{event:a},...t&&{label:t},item_type:s||null,item_id:l||null,item_value:r||null,user_profile:o,user_id:i||"00000"})})({event:i.clicked_lesson_plan,label:i.carousel,itemType:i.language_grade_subject,itemId:a.id,item_value:`${a.subject}_${a.grade}_${a.name}`,userId:_,userType:b}),children:e.jsxs("div",{className:`${y}__block-flex`,children:[e.jsx("div",{className:h?`${y}__block-icon--rtl ${y}__block-icon`:`${y}__block-icon`,children:e.jsx("img",{src:s?c.stemMathLogo:c.stemScienceLogo,alt:"math"})}),e.jsxs("div",{title:a.name,className:`${y}__text-block`,children:[e.jsx("div",{className:`${y}__main-title`,children:a.name}),e.jsx("div",{className:`${y}__caps-grade`,children:v("global.grade",{grade:a.grade.split(" ")[1]})})]})]})})},t)})})]})]},a.id||s))})})})})};P.propTypes={viewport:d.object.isRequired,parentClassName:d.string,getBooksForLpWorkFlow:d.func.isRequired,getLpFromBookIdWorkFlow:d.func.isRequired,attributes:d.object.isRequired,subjectVariant:d.string,userId:d.string,userType:d.string,isRtl:d.bool,eventCategory:d.string};const B=new URLSearchParams(window.location.search).get("language")||"en",E=k(B),M={grade:[],subject:[]},U=({parentClassName:t,subjectVariant:i})=>{var n,d;const k=s(),N=m(),V=u(),[U]=g(),O=U.get("language")||B,W=U.getAll("grade")||[],H=U.getAll("subject")||[],[z,K]=a.useState([]),[D,Q]=a.use
1State(W),[G,J]=a.useState(H),[Y,X]=a.useState([]),Z=p(e=>e.viewport),ee=p(e=>e.stem),ae=p(e=>e.user),te=ee.stemStaticData,se=ee.lessonPlans,le=ae.isLoggedIn,re=null==(n=ae.profile)?void 0:n.id,ie=null==(d=ae.profile)?void 0:d.profile_type;ee.isFetchingLpArray,ee.lpArray;const oe="pb-stem-topic-container",ne={[oe]:!0,[t]:t,[`${oe}--rtl`]:E},ce=[{title:te&&te.backToStem,href:o.stemHome(O),isInternal:!0}];if(a.useEffect(()=>{N(_({locale:O}))},[N,O]),a.useEffect(()=>{le&&re&&(N(b({userId:re})),N(h()))},[N,le,re]),a.useEffect(()=>{K([]),N(j({subject:i?[i]:G,grade:D,locale:O}))},[N,D,G,i,O]),a.useEffect(()=>{if(se&&se.length>0){const e=[];se.forEach(a=>{a.activity&&a.activity.forEach(a=>{a.bookId&&e.push(a.bookId)})}),e.length>0&&N(v({books:e,pledge:!1})).then(a=>{var t;const s=(null==a?void 0:a.ok)&&(null==(t=null==a?void 0:a.data)?void 0:t.stories)?a.data.stories:(null==a?void 0:a.stories)||(null==a?void 0:a.data)||[];X(Array.isArray(s)?s:[]),K(e)}).catch(e=>{X([])})}},[N,se]),!te)return e.jsx(l,{});const{maths:de,evs:me,grade1:ue,grade2:ge,grade3:pe,grade4:_e,grade5:be}=te;let he=[{name:de,queryValue:"Maths"},{name:me,queryValue:"EVS"}],je=[{name:ue,queryValue:"1"},{name:ge,queryValue:"2"},{name:pe,queryValue:"3"},{name:_e,queryValue:"4"},{name:be,queryValue:"5"}],ve=[{name:pe,queryValue:"3"},{name:_e,queryValue:"4"},{name:be,queryValue:"5"}],ye={grade:{name:te.grade,queryKey:"grade",queryValues:je},subject:{name:te.subject,queryKey:"subject",queryValues:he}},ke={grade:{name:te.grade,queryKey:"grade",queryValues:i&&i.toLowerCase()===y[0].toLowerCase()?je:ve}};const xe=e=>{const{gaAction:a,gtmLabel:t,itemType:s,itemValue:l,itemId:r}=e;window.dataLayer.push({category:i?x.stemAllStemSubject:x.stemAllStem,...t&&{label:t},...a&&{event:a},item_type:s||null,item_id:r||null,item_value:l||null,user_profile:ie,user_id:re||"00000"})},$e=()=>{const e=S.parse(window.location.search);return Object.entries(e).forEach(([a,t])=>{Array.isArray(M[a])&&!Array.isArray(t)&&(e[a]=[t])}),{...M,...e}},fe=(e,a)=>{const t=L($e());Array.isArray(t[e])?t[e].push(a):t[e]=a,"grade"===e?(Q(t[e]),xe({gaAction:"clicked_grade",gtmLabel:"filter",itemType:"language_grade",itemValue:`${O}_${a}`})):(J(t[e]),xe({gaAction:"clicked_subject",gtmLabel:"filter",itemType:"language_subject",itemValue:`${O}_${a}`})),V(`${location.pathname}?${S.stringify(t)}`.replace(`/${w}`,""),{replace:!0})},Se=(e,a)=>{const t=L($e());if(t[e]){if(Array.isArray(t[e])){const s=t[e].indexOf(a);-1!==s&&t[e].splice(s,1)}else delete t[e];"grade"===e?Q(t[e]):J(t[e]),V(`${location.pathname}?${S.stringify(t)}`.replace(`/${w}`,""),{replace:!0})}},Le=$e();let we=se.slice(0,Z.medium?15:6),Ae=se.slice(Z.medium?15:6);return e.jsxs("div",{className:r(ne),children:[e.jsx(A,{image:i?i.toLowerCase()===y[0].toLowerCase()?c.mathsBgUrl:c.scienceBgUrl:c.stemTopicHeaderBgUrl,pullInBottom:!0,title:i?i.toLowerCase()===y[0].toLowerCase()?te.maths:te.evs:te.stemTopics,isRtl:E,breadcrumbPaths:ce,parentClassName:E&&`${oe}__header-bg-img`}),e.jsxs(I,{children:[Z.medium?e.jsx(R,{noTopBorder:!0,pullUp:!0,filters:i?ke:ye,applyFilter:fe,removeFilter:Se,appliedFilters:Le,levelSearchValue:"",updateSearchValue:()=>{},sortOptions:null,appliedSortOption:Le.sort,itemTypeLabel:te.topics,readCountLabel:te.books,resultsCount:se.length,readCount:z.length>0&&Y.length,userType:ie,isRtl:E,labelSubject:te.subject,labelGrade:te.grade,category:i?x.allStemSubject:x.allStem}):e.jsx(F,{filters:i?ke:ye,applyFilter:fe,removeFilter:Se,sortOptions:null,appliedFilters:Le,appliedSortOption:Le.sort,resultsCount:se.length,readCount:z.length>0&&Y.length,floatingFilter:!0,fromEce:!0,itemTypeLabel:te.topics,readCountLabel:te.books,viewport:Z,eceFilterText:te.filter,eceCloseText:te.close,isRtl:E,labelSubject:te.subject,labelGrade:te.grade,category:i?x.allStemSubject:x.allStem}),e.jsxs("div",{className:`${oe}__sub-section`,children:[e.jsx($,{variant:Z.large?"5up":"4up",isRtl:E,children:we.map(a=>e.jsx(C,{lessonPlan:a,t:k,triggerEvent:()=>xe({gtmLabel:"lesson_plan",gaAction:"clicked_lesson_plan",itemType:"language,lesson_plan",itemId:a.legacyId,itemValue:`${a.subject}_${a.grade}_${a.name}`}),bookmarkEvent:()=>xe({gtmLabel:"bookmarked",gaAction:"clicked_bookmark",itemType:"lesson_plan",itemId:a.legacyId,itemValue:a.name}
1),isLoggedIn:le,isRtl:E},a.legacyId||a.id))}),D.length>0?"":e.jsx(P,{t:k,viewport:Z,parentClassName:oe,getBooksForLpWorkFlow:e=>N(v(e)),getLpFromBookIdWorkFlow:e=>N(f(e)),attributes:te,subjectVariant:i,userId:re,userType:ie,isRtl:E,eventCategory:i?x.stemAllStemSubject:x.stemAllStem}),e.jsx($,{variant:Z.large?"5up":"4up",isRtl:E,children:Ae.map(a=>e.jsx(C,{lessonPlan:a,t:k,triggerEvent:()=>xe({gtmLabel:"lesson_plan",gaAction:"clicked_lesson_plan",itemType:"language,lesson_plan",itemId:a.legacyId,itemValue:`${a.subject}_${a.grade}_${a.name}`}),bookmarkEvent:()=>xe({gtmLabel:"bookmarked",gaAction:"clicked_bookmark",itemType:"lesson_plan",itemId:a.legacyId,itemValue:a.name}),isLoggedIn:le,isRtl:E},a.legacyId||a.id))}),!i&&(()=>{const e=new URLSearchParams(window.location.search);return e.getAll("subject").length>0&&!e.getAll("subject").includes("Maths")&&e.getAll("grade").length>0&&!e.getAll("grade").includes("3")&&!e.getAll("grade").includes("4")&&!e.getAll("grade").includes("5")})()?e.jsxs("div",{className:E?`${oe}__no-data--rtl ${oe}__no-data`:`${oe}__no-data`,children:[e.jsx("p",{className:E?`${oe}__no-data--text--rtl ${oe}__no-data--text`:`${oe}__no-data--text`,children:te.evsNoData}),e.jsx("img",{className:`${oe}__no-data--img`,src:c.evsNoData,alt:"nodata"})]}):se.length<=5&&e.jsx(q,{title:te.comingSoonTitle,subText:te.comingSoonText})]})]}),e.jsx(I,{noHorizontalPadding:!0,noVerticalPadding:!0,children:z.length>0&&Y.length>0&&e.jsxs("div",{className:E?`${oe}__book-shelf--rtl ${oe}__book-shelf`:`${oe}__book-shelf`,children:[e.jsx("p",{className:`${oe}__sub-heading`,children:te.stemBooks}),e.jsx(T,{isRtl:E,books:Y,viewport:Z,readSource:"stem",eventCategory:i?x.stemAllStemSubject:x.stemAllStem,eventLabel:"explore_storybooks"})]})})]})};export{U as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.