(()=>{"use strict";var e={950:(e,t,a)=>{a.r(t)}},t={};function a(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,a),i.exports}a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a(950),(()=>{var e;const t=async(e,t,a,o)=>{const r=[...t.querySelectorAll(".campus-item")].find((e=>"true"===e.getAttribute("data-active"))).getAttribute("data-location-id"),s=new URL(`/api/2sxc/app/auto/query/GetCourseData/default?Year=${a}&LocationId=${r}`,window.location.origin),u=await fetch(s,{headers:{Pageid:e.pageId,Moduleid:e.moduleId}}).then((e=>e.json())).then((e=>e.default)),p=n(u,o,r,e),h=o.querySelector(".course-container");o.querySelector(".find-out-container").innerHTML=l(p[0]),window.innerWidth>600?h.innerHTML=c(p):h.innerHTML=d(p),i(o)},a=async(e,t,a,o)=>{t.querySelectorAll(".campus-item").forEach((t=>{const s=t.getAttribute("data-location-id"),u=new URL(`/api/2sxc/app/auto/query/GetCourseData/default?Year=${a}&LocationId=${s}`,window.location.origin);t.addEventListener("click",(async()=>{const a=await fetch(u,{headers:{Pageid:e.pageId,Moduleid:e.moduleId}}).then((e=>e.json())).then((e=>e.default)),r=n(a,o,s,e),p=o.querySelector(".course-container");o.querySelector(".find-out-container").innerHTML=l(r[0]),window.innerWidth>600?p.innerHTML=c(r):p.innerHTML=d(r),i(o);const h=new URL(window.location.href);h.searchParams.set("locationId",t.getAttribute("data-location-id")),history.pushState({},"",h)})),t.addEventListener("click",(e=>r(e,"#Courses")))}))},n=(e,t,a,n)=>{var o=[];return e.forEach((e=>{const t=o.find((t=>t.LocationId===e.LocationId)),a=t||{Location:e.Location,LocationId:e.LocationId,RedirectUrl:e.RedirectUrl,Categories:[]},i=a.Categories.find((t=>t.Category===e.CategoryName)),r=i||{Category:e.CategoryName,Courses:[]},s=r.Courses.find((t=>t.CourseId===e.CourseId)),c=s||{CourseId:e.CourseId,Course:e.Course,Level:e.CourseLevel,ShowHyFlex:!1,Dates:[]},d=c.Dates.find((t=>t.StartDate===e.StartDate&&t.ApplicationCloseDate===e.ApplicationClosingDate)),l=d||{ApplicationCloseDate:e.ApplicationClosingDate,StartDate:e.StartDate};if(d||c.Dates.push(l),s||r.Courses.push(c),i||a.Categories.push(r),t||o.push(a),e.SecondaryLocationId){const t=o.find((t=>t.LocationId===e.SecondaryLocationId)),a=t||{Location:e.SecondaryLocation,LocationId:e.SecondaryLocationId,RedirectUrl:e.RedirectUrl,Categories:[]},n=a.Categories.find((t=>t.Category===e.CategoryName)),i=n||{Category:e.CategoryName,Courses:[]},r=i.Courses.find((t=>t.CourseId===e.CourseId)),s=r||{CourseId:e.CourseId,Course:e.Course,Level:e.CourseLevel,ShowHyFlex:1==e.SecondaryLocationId&&30==e.LocationId,Dates:[]},c=s.Dates.find((t=>t.StartDate===e.StartDate&&t.ApplicationCloseDate===e.ApplicationClosingDate)),d=c||{ApplicationCloseDate:e.ApplicationClosingDate,StartDate:e.StartDate};c||s.Dates.push(d),r||i.Courses.push(s),n||a.Categories.push(i),t||o.push(a)}(o=o.filter((e=>!n.locationIdsToRemove.includes(e.LocationId)))).sort(((e,t)=>parseInt(String(e.LocationId))-parseInt(String(t.LocationId)))),o.forEach((e=>{e.Categories.sort(((e,t)=>e.Categoryt.Category?1:0)),e.Categories.forEach((e=>{e.Courses.sort(((e,t)=>e.Courset.Course?1:0))}))}))})),"0"!==a&&(o=o.filter((e=>e.LocationId.toString()===a))),o},o=e=>{e.forEach((t=>{t.addEventListener("click",(()=>{e.forEach((e=>e.setAttribute("data-active","false"))),t.setAttribute("data-active","true")}))}))},i=e=>{e.querySelectorAll(".collapsible").forEach((e=>{const t=e.nextElementSibling,a=e.querySelector(".fa-chevron-up");e.addEventListener("click",(()=>{t.classList.contains("show")?(t.classList.remove("show"),t.style.maxHeight=t.scrollHeight+"px",requestAnimationFrame((()=>{t.style.maxHeight="0px"})),t.addEventListener("transitionend",(function e(){t.style.maxHeight=null,t.removeEventListener("transitionend",e)})),a&&(a.classList.remove("rotate-on"),a.classList.add("rotate-off"))):(t.classList.add("show"),t.style.maxHeight=t.scrollHeight+"px",t.addEventListener("transitionend",(function e(){t.style.maxHeight=null,t.removeEventListener("transitionend",e)})),a&&(a.classList.remove("rotate-off"),a.classList.add("rotate-on")))}))}))},r=(e,t)=>{e.preventDefault();const a=document.querySelector(t);if(a){const e=90,t=a.getBoundingClientRect().top+window.scrollY-e;window.scrollTo({top:t,behavior:"smooth"})}},s=async(e,a,n,o)=>{const r=a.querySelectorAll(".campus-item");if(window.innerWidth<=600){if("false"===o.querySelector(".course-container").getAttribute("mobile-active")){o.querySelector(".course-container").setAttribute("mobile-active","true");const t=[...r].find((e=>"true"===e.getAttribute("data-active"))).getAttribute("data-location-id"),a=new URL(`/api/2sxc/app/auto/query/GetCourseData/default?Year=${n}&LocationId=${t}`,window.location.origin),c=await fetch(a,{headers:{Pageid:e.pageId,Moduleid:e.moduleId}}).then((e=>e.json())).then((e=>e.default));var s=[];c.forEach((t=>{const a=s.find((e=>e.LocationId===t.LocationId)),n=a||{Location:t.Location,LocationId:t.LocationId,RedirectUrl:t.RedirectUrl,Categories:[]},o=n.Categories.find((e=>e.Category===t.CategoryName)),i=o||{Category:t.CategoryName,Courses:[]},r=i.Courses.find((e=>e.CourseId===t.CourseId)),c=r||{CourseId:t.CourseId,Course:t.Course,Level:t.CourseLevel,ShowHyFlex:!1,Dates:[]},d=c.Dates.find((e=>e.StartDate===t.StartDate&&e.ApplicationCloseDate===t.ApplicationClosingDate)),l=d||{ApplicationCloseDate:t.ApplicationClosingDate,StartDate:t.StartDate};if(d||c.Dates.push(l),r||i.Courses.push(c),o||n.Categories.push(i),a||s.push(n),t.SecondaryLocationId){const e=s.find((e=>e.LocationId===t.SecondaryLocationId)),a=e||{Location:t.SecondaryLocation,LocationId:t.SecondaryLocationId,RedirectUrl:t.RedirectUrl,Categories:[]},n=a.Categories.find((e=>e.Category===t.CategoryName)),o=n||{Category:t.CategoryName,Courses:[]},i=o.Courses.find((e=>e.CourseId===t.CourseId)),r=i||{CourseId:t.CourseId,Course:t.Course,Level:t.CourseLevel,ShowHyFlex:1==t.SecondaryLocationId&&30==t.LocationId,Dates:[]},c=r.Dates.find((e=>e.StartDate===t.StartDate&&e.ApplicationCloseDate===t.ApplicationClosingDate)),d=c||{ApplicationCloseDate:t.ApplicationClosingDate,StartDate:t.StartDate};c||r.Dates.push(d),i||o.Courses.push(r),n||a.Categories.push(o),e||s.push(a)}(s=s.filter((t=>!e.locationIdsToRemove.includes(t.LocationId)))).sort(((e,t)=>parseInt(String(e.LocationId))-parseInt(String(t.LocationId)))),s.forEach((e=>{e.Categories.sort(((e,t)=>e.Categoryt.Category?1:0)),e.Categories.forEach((e=>{e.Courses.sort(((e,t)=>e.Courset.Course?1:0))}))}))})),"0"!==t&&(s=s.filter((e=>e.LocationId.toString()===t)));const l=o.querySelector(".course-container"),u=d(s);l.innerHTML=u,i(o)}}else"true"===o.querySelector(".course-container").getAttribute("mobile-active")&&(t(e,a,n,o),o.querySelector(".course-container").setAttribute("mobile-active","false"))},c=e=>e.map((e=>`\n
\n

\n ${e.Location}\n

\n ${e.Categories.map((t=>`\n \n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n ${t.Courses.map((t=>`\n \n \n \n \n \n\n \n\n \n \n `)).join("")} \n \n
CourseLevelNext Intake(s)\n ${4===e.LocationId?"Enrolments Close":""}\n
\n
\n
\n ${t.Course}\n
\n ${t.ShowHyFlex?'\n \n ':""}\n
\n \n
${"0"!==t.Level?t.Level:""}\n
\n ${t.Dates.map((e=>`\n
${new Date(e.StartDate).toLocaleDateString("en-NZ",{day:"numeric",month:"long"})}
\n `)).join("")}\n
\n
\n ${4===e.LocationId?`\n
\n ${t.Dates.map((e=>`\n
${new Date(e.ApplicationCloseDate).toLocaleDateString("en-NZ",{day:"numeric",month:"long"})}
\n `)).join("")} \n
`:""}\n
\n
\n Details\n \n
\n
\n
\n
\n `)).join("")}\n
\n `)).join(""),d=e=>e.map((e=>`\n
\n

\n ${e.Location}\n

\n ${e.Categories.map((t=>`\n \n\n
\n
\n ${t.Courses.map((t=>`\n
\n
\n
\n
\n ${t.Course}\n
\n ${"0"!==t.Level?`\n
\n Level:  \n
${t.Level}
\n
\n `:""} \n
\n\n ${t.ShowHyFlex?'\n \n ':""}\n
\n \n \n \n \n ${4===e.LocationId?'':""} \n \n \n \n ${t.Dates.map((t=>{let a=new Date(t.StartDate).toLocaleDateString("en-NZ",{day:"numeric",month:"long"}),n=new Date(t.ApplicationCloseDate).toLocaleDateString("en-NZ",{day:"numeric",month:"long"});return`\n \n \n ${4===e.LocationId?``:""} \n \n \n `})).join("")}\n \n
Next Intake(s)Enrolments Close
${a}${n}
\n
\n \n
\n
\n Details\n \n
\n
\n
\n
\n \n `)).join("")} \n
\n
\n
\n `)).join("")}\n \n `)).join(""),l=e=>e?`\n \n `:"",u=window;u.EnrollingNow??(u.EnrollingNow={}),(e=u.EnrollingNow).InitCourseList??(e.InitCourseList=e=>{const n=document.querySelector(`.enrolling-now-container[data-key="${e.key}"]`),r=n.querySelectorAll(".year-text"),c=n.querySelector(".campuses-container");var d=c.querySelectorAll(".campus-item");d.forEach((t=>{t.getAttribute("data-location-id")===e.selectedLocationId.toString()&&t.setAttribute("data-active","true")})),r.forEach((t=>{t.getAttribute("data-year")===e.selectedYear.toString()&&t.setAttribute("data-active","true")})),a(e,c,e.selectedYear.toString(),n),r.forEach((i=>{i.addEventListener("click",(async()=>{const r=i.getAttribute("data-year"),s=new URL(`/api/2sxc/app/auto/query/GetLocations/default?Year=${r}`,window.location.origin);var l=(l=await fetch(s,{headers:{Pageid:e.pageId,Moduleid:e.moduleId}}).then((e=>e.json())).then((e=>e.default))).filter((t=>!e.locationIdsToRemove.includes(t.LocationId)));const u=[{LocationId:0,Name:"All"},...l],p=c.clientHeight;c.style.minHeight=null;const h=u.map((e=>`\n \n `)).join("");var g="0";const C=[...d].find((e=>"true"===e.getAttribute("data-active")));C&&(g=C.getAttribute("data-location-id")),c.innerHTML=h,d=c.querySelectorAll(".campus-item");const v=[...d].find((e=>e.getAttribute("data-location-id")===g)),L=new URL(window.location.href);v?(v.setAttribute("data-active","true"),L.searchParams.set("locationId",g)):(c.querySelector('.campus-item[data-location-id="0"]').setAttribute("data-active","true"),L.searchParams.set("locationId","0")),t(e,c,r,n),a(e,c,r,n),o(d);const y=c.clientHeight;window.innerWidth>=991&&(c.style.minHeight=`${p>y?p:y}px`),L.searchParams.set("year",i.getAttribute("data-year")),history.pushState({},"",L)}))})),r.forEach((e=>{e.addEventListener("click",(()=>{r.forEach((e=>e.setAttribute("data-active","false"))),e.setAttribute("data-active","true")}))})),o(d),i(n),window.innerWidth<=600&&s(e,c,e.selectedYear.toString(),n),window.addEventListener("resize",(()=>{s(e,c,e.selectedYear.toString(),n)}))})})()})(); //# sourceMappingURL=CourseList.min.js.map ;;;