﻿var Things;(function(n){var t=function(){function t(t){this.data=t;var i=this,r=$.map(t||[],function(t){return new n.Thing(t)});this.Things=ko.observableArray(r),this.Things()[0].IsSelected(!0),this.SelectedItem=ko.observable(this.Things()[0]),this.CheckedItems=ko.computed(function(){return ko.utils.arrayFilter(i.Things(),function(n){return n.IsChecked()})}),this.CheckedCount=ko.computed(function(){return i.CheckedItems().length}),this.select=this.selectInternal.bind(this)}return t.prototype.getItem=function(n){var t;return this.Things().forEach(function(i){if(i.Id===n)return t=i,!1}),t},t.prototype.replace=function(n){var t=this;this.Things().forEach(function(i){if(i.Id===n.Id)return t.Things.replace(i,n),n.IsSelected(i.IsSelected()),n.IsChecked(i.IsChecked()),n.IsSelected()&&t.SelectedItem(n),!1})},t.prototype.selectInternal=function(n){var t=this;this.Things().forEach(function(i){var r=i.Id===n.Id;i.IsSelected(r),r&&t.SelectedItem(i)})},t}();n.ThingList=t})(Things||(Things={}))