var app=app||{};app.catalogue=app.catalogue||{},function(n,t){"use strict";return t.catalogue.NodeModel=function(i,r){var u=this;u.Parent=r;u.isExpanded=ko.observable(!1);u.Loading=ko.observable(!1);u.ComponentName=i.ComponentName;u.HierarchyId=i.HierarchyId;u.ComponentId=i.ComponentId;u.ParentComponentId=i.ParentComponentId;u.ComponentTypeId=i.ComponentTypeId;u.Children=ko.observableArray([]);u.RootComponentId=i.RootComponentId;u.Icon=ko.observable(i.Icon);u.BreadCrumbParentIds=i.BreadCrumbParentIds;u.ContentUpToDate=ko.observable(!1);u.LastLeafNode=ko.observable(!1);u.Container=i.Container;u.LastAccessDate=ko.safeObservable(i.LastAccessDate);u.Favourite=ko.observable(i.Favorite);u.LaunchButtonText=ko.observable(i.LaunchButtonText);u.HighestScore=ko.observable(i.HighestScore);u.CanSubmitFeedback=ko.observable(i.CanSubmitFeedback);u.Level=i.Level;u.LearningLogicLock=ko.observable(i.LearningLogicLock);u.ComponentStatus=i.ComponentStatus;u.Position=ko.observable(i.Position);u.CertificateStatus=ko.observable(i.CertificateStatus);u.CertificateEnabled=ko.observable(i.CertificateEnabled);u.CertificateSource=encodeURIComponent("catalogue-panelview-certificate");u.SortedChildren=ko.computed(function(){return u.ComponentTypeId<=0?u.Children():u.Children().sort(function(n,t){return n.Position()===t.Position()?0:n.Position()<t.Position()?-1:1})});u.ComputedIcon=ko.computed(function(){return u.Loading()?"component-icon-loading":"component-icon"});u.FavouriteIcon=ko.computed(function(){return u.Favourite()?t.imagePaths.favouriteOnIcon:t.imagePaths.favouriteOffIcon});u.CertificateIcon=ko.computed(function(){switch(u.CertificateStatus()){case 2:return t.imagePaths.certificateIcon;case 1:return t.imagePaths.certificateIconDisabled;default:return""}});u.ShowExpandViewIcon=ko.computed(function(){return u.ComponentTypeId===2||u.Children().length>0&&u.LastLeafNode()===!1});u.toggleVisibility=function(){u.ComponentTypeId!==2||u.ContentUpToDate()||(u.Loading(!0),t.catalogue.AsyncProgrammeExpansion(u).then(function(){u.Loading(!1);t.catalogue.ResizeLeftTreeViewHeight()}));u.isExpanded(!u.isExpanded())};u.selectNode=function(){if(u.ComponentTypeId===2&&!u.ContentUpToDate()){var i=n("#children-loading"),r=n("#catalogueChildComponents");i.show();r.hide();t.catalogue.AsyncProgrammeExpansion(u).then(function(){i.hide();r.show();t.catalogue.ResizeLeftTreeViewHeight()})}u.Children().length===0&&(u.ComponentTypeId===4||u.ComponentTypeId===5||u.ComponentTypeId===6)&&u.LastLeafNode(!0);u.ComponentTypeId!==4&&u.ComponentTypeId!==5&&u.ComponentTypeId!==6||u.ContentUpToDate()||t.catalogue.GetChildComponents(u);t.catalogue.GetSelectedNodeDetails(u);t.catalogue.ResizeLeftTreeViewHeight()};u.getInfo=function(){LaunchCatalogueComponentInfo(u.ComponentId,u.BreadCrumbParentIds)};u.Launch=function(){t.catalogue.launchedComponentId=u.ComponentId;LaunchContent(u.ComponentId,u.BreadCrumbParentIds,!0)};u.SubmitFeedback=function(){LaunchFeedback(u.ComponentId)};u.ToggleFavourite=function(){t.catalogue.toggleFavourite(u)};u.LaunchGuestAccess=function(){t.catalogue.launchedComponentId=u.ComponentId;openGuestAccessComponentModal(u.ComponentId,u.BreadCrumbParentIds,!0)};u.LaunchApplicationGuestAccess=function(){t.catalogue.launchedComponentId=u.ComponentId;LaunchApplicationContent(u.ComponentId,u.BreadCrumbParentIds,!0)};u.Enrol=function(){openEnrolSessionModal(u.ComponentId,u.BreadCrumbParentIds,2)};i.Children&&ko.utils.arrayForEach(i.Children,function(n){this.Children.push(new t.catalogue.NodeModel(n,this))}.bind(this))},n(window).resize(function(){t.catalogue.ResizeLeftTreeViewHeight()}),t.catalogue.ResizeLeftTreeViewHeight=function(){var t=n("#catalogue-components").height(),i=n(window).height()-n("#treeview").offset().top-72,r=i>t?i:t;n("#treeview,#panel-slider").height(r)},t}(window.jQuery,app)