function SearchParametersVM(){var n=this;n.FirstNames=ko.observable(null);n.LastName=ko.observable(null);n.ModifiedFromDate=ko.observable(null);n.ModifiedToDate=ko.observable(null);n.GroupLinked=ko.observable(!1);n.PageIndex=ko.observable(null);n.clear=function(){var i,t;for(i in n)t=n[i],ko.isObservable(t)&&t(null)}}function SearchResultsVM(n){var t=this,i={Results:{create:function(n){return new SearchResultVM(n.data)},key:function(n){return ko.utils.unwrapObservable(n.ID)}}};ko.mapping.fromJS(n,i,t);t.pageNumbers=ko.computed(function(){for(var i=[],n=1;n<=t.NumPages();n++)i.push(n);return i})}function SearchResultVM(n){var t=this;ko.mapping.fromJS(n,{},t);t.isSelected=ko.observable(!1);t.editUrl=function(){return myIllModule.getUrls().editIllustration+"/"+t.EncodedID()}}var myIllModule=function(){var n=null,t=null,f=ko.observable(!1),i,e=ko.observable(!0),o=function(r,u){i=r;n=new SearchParametersVM;t=new SearchResultsVM(u);ko.applyBindings(t,$("#content").get(0))},u=function(){var r=i.search,u=ko.mapping.toJSON(n);ajaxModule.postJson(r,u,function(i){ko.mapping.fromJS(i.Data,t);f(n.GroupLinked())})},s=function(t){n.PageIndex(t);u()},h=function(){n.PageIndex(1);u()},c=function(){n.PageIndex(t.NumPages());u()},r=ko.computed({read:function(){return _.filter(t.Results(),function(n){return n.isSelected()})},deferEvaluation:!0}),l=ko.computed({read:function(){return r().length==1&&r()[0].CanGenerateReport()},deferEvaluation:!0}),a=function(){var n="Fidelity-Life-illustration-"+r()[0].PreparedFor().replace(" ","-")+".pdf";window.open(i.getIllustrationReport+"/"+r()[0].ID()+"/"+n,"_blank")},v=ko.computed({read:function(){return r().length>0},deferEvaluation:!0}),y=function(){var t=[],f,n;_.each(r(),function(n){t.push(n.ID())});f=i.checkIfParentIllustrationExists;n=ko.toJSON(t);ajaxModule.postJson(f,n,function(t){var r;r=t.Data?"One or more of the selected illustrations have previously been duplicated. All duplicated illustrations will be unlinked from the original. Are you sure you wish to proceed?":"Are you sure you wish to delete the selected illustrations?";utilModule.confirm(r,function(){var t=i.deleteIllustrations;ajaxModule.overrideRequestFlag();ajaxModule.postJson(t,n,function(){ajaxModule.overrideRequestFlag();u()})})})},p=function(){n.PageIndex(1);u()};return{init:o,getUrls:function(){return i},getSearchParameters:function(){return n},getSearchResults:function(){return t},getLastSearchWasGrouped:function(){return f},userSearch:p,changePage:s,canPreview:l,getIllustrationReport:a,canDelete:v,deleteIllustrations:y,searchAvailable:e,firstPage:h,lastPage:c}}()