/
knockback-full-stack.min.js
13 lines (13 loc) · 154 KB
/
knockback-full-stack.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
knockback-full-stack.js 0.20.5
Copyright (c) 2011-2014 Kevin Malakoff.
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Source: https://github.com/kmalakoff/knockback
Dependencies: Knockout.js, Backbone.js, and Underscore.js (or LoDash.js).
Optional dependencies: Backbone.ModelRef.js and BackboneORM.
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?exports.kb=t(require("jquery")):e.kb=t(e.jQuery)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){n(1),n(2),n(3),n(4),n(5),n(6),n(7),n(8),n(9),n(10),n(11),n(12),n(13),n(15),n(16),n(17),n(18),n(19),e.exports=n(14)},function(e,t,n){var r,i,o,s,a,u,l,c,d=function(e,t){return function(){return e.apply(t,arguments)}},p=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};c=a=n(6),l=c._,u=c.ko,o=0,r=-1,i=1,s=["destroy","shareOptions","filters","comparator","sortAttribute","viewModelByModel","hasViewModels"],a.compare=function(e,t){return l.isString(e)?e.localeCompare(""+t):l.isString(t)?t.localeCompare(""+e):e===t?o:t>e?r:i},a.CollectionObservable=function(){function e(e,t,n){this._onCollectionChange=d(this._onCollectionChange,this);var r;return r=Array.prototype.slice.call(l.isArguments(e)?e:arguments),a.ignore(function(t){return function(){var i,o,c,d,p;for(e=r[0]instanceof a.Collection?r.shift():l.isArray(r[0])?new a.Collection(r.shift()):new a.Collection,l.isFunction(r[0])&&(r[0]={view_model:r[0]}),n={},d=0,p=r.length;p>d;d++)i=r[d],l.extend(n,i);return c=a.utils.wrappedObservable(t,u.observableArray([])),c.__kb_is_co=!0,t.in_edit=0,t.__kb||(t.__kb={}),n=a.utils.collapseOptions(n),n.auto_compact&&(t.auto_compact=!0),t._comparator=u.observable(n.sort_attribute?t._attributeComparator(n.sort_attribute):n.comparator),t._filters=u.observableArray(n.filters?l.isArray(n.filters)?n.filters:n.filters?[n.filters]:void 0:[]),o=t.create_options={store:a.Store.useOptionsOrCreate(n,e,c)},a.utils.wrappedObject(c,e),t.path=n.path,o.factory=a.utils.wrappedFactory(c,t._shareOrCreateFactory(n)),o.path=a.utils.pathJoin(n.path,"models"),o.creator=o.factory.creatorForPath(null,o.path),o.creator&&(t.models_only=o.creator.models_only),a.publishMethods(c,t,s),t._collection=u.observable(e),c.collection=t.collection=u.computed({read:function(){return t._collection()},write:function(e){return a.ignore(function(){var n;if((n=t._collection())!==e)return a.utils.wrappedObject(c,e),n&&n.unbind("all",t._onCollectionChange),e&&e.bind("all",t._onCollectionChange),t._collection(e)})}}),e&&e.bind("all",t._onCollectionChange),t._mapper=u.computed(function(){var e,n,r,i,o,s,d,p,f;if(e=t._comparator(),i=t._filters())for(p=0,f=i.length;f>p;p++)r=i[p],u.utils.unwrapObservable(r);n=t._collection(),t.in_edit||(c=a.utils.wrappedObservable(t),s=a.peek(c),n&&(o=n.models),o&&0!==n.models.length?(o=l.filter(o,function(e){return!i.length||t._selectModel(e)}),d=e?l.map(o,function(e){return t._createViewModel(e)}).sort(e):t.models_only?i.length?o:o.slice():l.map(o,function(e){return t._createViewModel(e)})):d=[],t.in_edit++,c(d),t.in_edit--)}),c.subscribe(l.bind(t._onObservableArrayChange,t)),!a.statistics||a.statistics.register("CollectionObservable",t),c}}(this))}return e.extend=a.extend,e.prototype.destroy=function(){var e,t,n;return this.__kb_released=!0,n=a.utils.wrappedObservable(this),t=a.peek(this._collection),a.utils.wrappedObject(n,null),t&&(t.unbind("all",this._onCollectionChange),e=a.peek(n),e.splice(0,e.length)),this.collection.dispose(),this._collection=n.collection=this.collection=null,this._mapper.dispose(),this._mapper=null,a.release(this._filters),this._filters=null,this._comparator(null),this._comparator=null,this.create_options=null,n.collection=null,a.utils.wrappedDestroy(this),!a.statistics||a.statistics.unregister("CollectionObservable",this)},e.prototype.shareOptions=function(){var e;return e=a.utils.wrappedObservable(this),{store:a.utils.wrappedStore(e),factory:a.utils.wrappedFactory(e)}},e.prototype.filters=function(e){return this._filters(e?l.isArray(e)?e:[e]:[])},e.prototype.comparator=function(e){return this._comparator(e)},e.prototype.sortAttribute=function(e){return this._comparator(e?this._attributeComparator(e):null)},e.prototype.viewModelByModel=function(e){var t;return this.models_only?null:(t=e.hasOwnProperty(e.idAttribute)?e.idAttribute:"cid",l.find(a.peek(a.utils.wrappedObservable(this)),function(n){var r;return(null!=n&&null!=(r=n.__kb)?r.object:void 0)?n.__kb.object[t]===e[t]:!1}))},e.prototype.hasViewModels=function(){return!this.models_only},e.prototype.compact=function(){return a.ignore(function(e){return function(){var t;return t=a.utils.wrappedObservable(e),a.utils.wrappedStoreIsOwned(t)?(a.utils.wrappedStore(t).clear(),e._collection.notifySubscribers(e._collection())):void 0}}(this))},e.prototype._shareOrCreateFactory=function(e){var t,n,r,i;if(t=a.utils.pathJoin(e.path,"models"),r=e.factories,(i=e.factory)&&(n=i.creatorForPath(null,t))&&(!r||r.models===n)){if(!r)return i;if(i.hasPathMappings(r,e.path))return i}return i=new a.Factory(e.factory),r&&i.addPathMappings(r,e.path),i.creatorForPath(null,t)||(e.hasOwnProperty("models_only")?e.models_only?i.addPathMapping(t,{models_only:!0}):i.addPathMapping(t,a.ViewModel):e.view_model?i.addPathMapping(t,e.view_model):e.create?i.addPathMapping(t,{create:e.create}):i.addPathMapping(t,a.ViewModel)),i},e.prototype._onCollectionChange=function(e,t){return a.ignore(function(n){return function(){var r,i,o,s;if(!n.in_edit&&!a.wasReleased(n))switch(e){case"reset":n.auto_compact?n.compact():n._collection.notifySubscribers(n._collection());break;case"sort":case"resort":n._collection.notifySubscribers(n._collection());break;case"new":case"add":if(!n._selectModel(t))return;if(o=a.utils.wrappedObservable(n),r=n._collection(),-1===r.indexOf(t))return;if(s=n.viewModelByModel(t))return;n.in_edit++,(i=n._comparator())?(o().push(n._createViewModel(t)),o.sort(i)):o.splice(r.indexOf(t),0,n._createViewModel(t)),n.in_edit--;break;case"remove":case"destroy":n._onModelRemove(t);break;case"change":if(!n._selectModel(t))return n._onModelRemove(t);if(s=n.models_only?t:n.viewModelByModel(t),!s)return n._onCollectionChange("add",t);if(!(i=n._comparator()))return;n.in_edit++,a.utils.wrappedObservable(n).sort(i),n.in_edit--}}}(this))},e.prototype._onModelRemove=function(e){var t,n;return(n=this.models_only?e:this.viewModelByModel(e))?(t=a.utils.wrappedObservable(this),this.in_edit++,t.remove(n),this.in_edit--):void 0},e.prototype._onObservableArrayChange=function(e){return a.ignore(function(t){return function(){var n,r,i,o,s,u,c,d,p,f;if(!t.in_edit&&(t.models_only&&(!e.length||a.isModel(e[0]))||!t.models_only&&(!e.length||l.isObject(e[0])&&!a.isModel(e[0]))||a._throwUnexpected(t,"incorrect type passed"),u=a.utils.wrappedObservable(t),n=a.peek(t._collection),i=a.peek(t._filters).length,n)){if(d=e,t.models_only)s=l.filter(e,function(e){return!i||t._selectModel(e)});else for(!i||(d=[]),s=[],p=0,f=e.length;f>p;p++){if(c=e[p],o=a.utils.wrappedObject(c),i){if(!t._selectModel(o))continue;d.push(c)}(r=t.create_options.store.find(o,t.create_options.creator))&&(r.constructor===c.constructor||a._throwUnexpected(t,"replacing different type of view model")),t.create_options.store.retain(c,o,t.create_options.creator),s.push(o)}t.in_edit++,e.length===d.length||u(d),l.isEqual(n.models,s)||n.reset(s),t.in_edit--}}}(this))},e.prototype._attributeComparator=function(e){var t;return t=function(t,n){var r;return r=u.utils.unwrapObservable(e),a.compare(t.get(r),n.get(r))},this.models_only?t:function(e,n){return t(a.utils.wrappedModel(e),a.utils.wrappedModel(n))}},e.prototype._createViewModel=function(e){return this.models_only?e:this.create_options.store.retainOrCreate(e,this.create_options)},e.prototype._selectModel=function(e){var t,n,r,i,o;for(n=a.peek(this._filters),r=0,i=n.length;i>r;r++)if(t=n[r],t=a.peek(t),l.isFunction(t)){if(!t(e))return!1}else if(l.isArray(t)){if(o=e.id,p.call(t,o)<0)return!1}else if(e.id!==t)return!1;return!0},e}(),a.collectionObservable=function(){return new a.CollectionObservable(arguments)}},function(e,t,n){var r,i,o,s,a,u,l;l=i=n(6),u=l._,s=l.ko,r={"default":null,"backbone-orm":null,"backbone-associations":n(23),"backbone-relational":n(24),supermodel:n(25)},i.orm=r["default"];for(o in r)if(a=r[o],a&&a.isAvailable()){i.orm=a;break}e.exports=function(e){var t;null==e&&(e={});for(o in e)switch(a=e[o],o){case"orm":if(u.isString(a)){if(!r.hasOwnProperty(a)){console.log("Knockback configure: could not find orm: "+a+". Available: "+u.keys(r).join(", "));continue}if((t=r[a])&&!t.isAvailable()){console.log("Knockback configure: could not enable orm "+a+". Make sure it is included before Knockback");continue}i.orm=t;continue}i.orm=a;break;default:i[o]=a}}},function(e,t,n){var r,i,o,s,a=function(e,t){return function(){return e.apply(t,arguments)}};s=r=n(6),o=s._,i=s.ko,r.EventWatcher=function(){function e(e,t,n){this._unbindCallbacks=a(this._unbindCallbacks,this),this._onModelUnloaded=a(this._onModelUnloaded,this),this._onModelLoaded=a(this._onModelLoaded,this),this.__kb||(this.__kb={}),this.__kb.callbacks={},this.ee=null,n&&this.registerCallbacks(t,n),e&&this.emitter(e)}return e.useOptionsOrCreate=function(e,t,n,i){return e.event_watcher?(e.event_watcher.emitter()!==t&&e.event_watcher.model_ref!==t&&r._throwUnexpected(this,"emitter not matching"),r.utils.wrappedEventWatcher(n,e.event_watcher).registerCallbacks(n,i)):(r.utils.wrappedEventWatcherIsOwned(n,!0),r.utils.wrappedEventWatcher(n,new r.EventWatcher(t)).registerCallbacks(n,i))},e.prototype.destroy=function(){return this.emitter(null),this.__kb.callbacks=null,r.utils.wrappedDestroy(this)},e.prototype.emitter=function(e){return 0===arguments.length||this.ee===e?this.ee:(this.model_ref&&(this.model_ref.unbind("loaded",this._onModelLoaded),this.model_ref.unbind("unloaded",this._onModelUnloaded),this.model_ref.release(),this.model_ref=null),r.Backbone&&r.Backbone.ModelRef&&e instanceof r.Backbone.ModelRef?(this.model_ref=e,this.model_ref.retain(),this.model_ref.bind("loaded",this._onModelLoaded),this.model_ref.bind("unloaded",this._onModelUnloaded),e=this.model_ref.model()||null):delete this.model_ref,this.ee!==e&&(e?this._onModelLoaded(e):this._onModelUnloaded(this.ee)),e)},e.prototype.registerCallbacks=function(e,t){var n,s,a,u,l,c;for(e||r._throwMissing(this,"obj"),t||r._throwMissing(this,"callback_info"),s=t.event_selector?t.event_selector.split(" "):["change"],a=this.ee,u=function(n){return function(s){var u,l;return(u=n.__kb.callbacks[s])||(u=n.__kb.callbacks[s]={model:null,list:[],fn:function(e){var t,n,o,a;for(a=u.list,n=0,o=a.length;o>n;n++)t=a[n],t.update&&(e&&t.key&&e.hasChanged&&!e.hasChanged(i.utils.unwrapObservable(t.key))||(!r.statistics||r.statistics.addModelEvent({name:s,model:e,key:t.key,path:t.path}),t.update()));return null}}),u.list.push(l=o.defaults({obj:e},t)),a?n._onModelLoaded(a):void 0}}(this),l=0,c=s.length;c>l;l++)n=s[l],n&&u(n);return this},e.prototype.releaseCallbacks=function(e){var t,n,i;this.ee=null,i=this.__kb.callbacks;for(n in i)t=i[n],this._unbindCallbacks(n,t,r.wasReleased(e));return delete this.__kb.callbacks},e.prototype._onModelLoaded=function(e){var t,n,i,o,s,a,u,l;this.ee=e,a=this.__kb.callbacks;for(n in a)for(t=a[n],t.model&&t.model!==e&&this._unbindCallbacks(n,t,!0),t.model||(t.model=e,e.bind(n,t.fn)),u=t.list,o=0,s=u.length;s>o;o++)i=u[o],i.unbind_fn||(i.unbind_fn=null!=(l=r.orm)?l.bind(e,i.key,i.update,i.path):void 0),i.emitter&&i.emitter(e)},e.prototype._onModelUnloaded=function(e){var t,n,r;if(this.ee===e){this.ee=null,r=this.__kb.callbacks;for(n in r)t=r[n],this._unbindCallbacks(n,t)}},e.prototype._unbindCallbacks=function(e,t,n){var i,o,s,a;for(t.model&&(t.model.unbind(e,t.fn),t.model=null),a=t.list,o=0,s=a.length;s>o;o++)i=a[o],i.unbind_fn&&(i.unbind_fn(),i.unbind_fn=null),!i.emitter||n||r.wasReleased(i.obj)||i.emitter(null)},e}(),r.emitterObservable=function(e,t){return new r.EventWatcher(e,t)}},function(e,t,n){var r,i;i=(r=n(6))._,r.Factory=function(){function e(e){this.paths={},e&&(this.parent_factory=e)}return e.useOptionsOrCreate=function(e,t,n){var i;return e.factory&&(!e.factories||e.factories&&e.factory.hasPathMappings(e.factories,n))?r.utils.wrappedFactory(t,e.factory):(i=r.utils.wrappedFactory(t,new r.Factory(e.factory)),e.factories&&i.addPathMappings(e.factories,n),i)},e.prototype.hasPath=function(e){var t;return this.paths.hasOwnProperty(e)||(null!=(t=this.parent_factory)?t.hasPath(e):void 0)},e.prototype.addPathMapping=function(e,t){return this.paths[e]=t},e.prototype.addPathMappings=function(e,t){var n,i;for(i in e)n=e[i],this.paths[r.utils.pathJoin(t,i)]=n},e.prototype.hasPathMappings=function(e,t){var n,i,o,s;n=!0;for(s in e)i=e[s],n&=(o=this.creatorForPath(null,r.utils.pathJoin(t,s)))&&i===o;return n},e.prototype.creatorForPath=function(e,t){var n,r;return(n=this.paths[t])?n.view_model?n.view_model:n:(n=null!=(r=this.parent_factory)?r.creatorForPath(e,t):void 0)?n:null},e}()},function(e,t,n){(function(e){var t,r,i,o,s,a,u,l;s=null!=s?s:e,l=r=n(6),a=l._,i=l.ko,t=l.$,r.RECUSIVE_AUTO_INJECT=!0,i.bindingHandlers.inject={init:function(e,t,n,o){return r.Inject.inject(i.utils.unwrapObservable(t()),o,e,t,n)}},r.Inject=function(){function e(){}return e.inject=function(e,t,n,i,o,s){var u;return u=function(e){var u,l,c;if(a.isFunction(e))t=new e(t,n,i,o),r.releaseOnNodeRemove(t,n);else{e.view_model&&(t=new e.view_model(t,n,i,o),r.releaseOnNodeRemove(t,n));for(u in e)c=e[u],"view_model"!==u&&("create"===u?c(t,n,i,o):a.isObject(c)&&!a.isFunction(c)?(l=s||c&&c.create?{}:t,t[u]=r.Inject.inject(c,l,n,i,o,!0)):t[u]=c)}return t},s?u(e):r.ignore(function(){return u(e)})},e.injectViewModels=function(e){var t,n,i,o,u,l,c,d,p,f;for(d=[],l=function(e){var t,n,r,i,o;for(e.__kb_injected||e.attributes&&(t=a.find(e.attributes,function(e){return"kb-inject"===e.name}))&&(e.__kb_injected=!0,d.push({el:e,view_model:{},binding:t.value})),o=e.childNodes,r=0,i=o.length;i>r;r++)n=o[r],l(n)},!e&&(null!=s?s.document:void 0)&&(e=s.document),l(e),p=0,f=d.length;f>p;p++)n=d[p],(u=n.binding)&&(u.search(/[:]/)<0||(u="{"+u+"}"),o=new Function("","return ( "+u+" )")(),o||(o={}),!o.options||(c=o.options,delete o.options),c||(c={}),n.view_model=r.Inject.inject(o,n.view_model,n.el,null,null,!0),t=n.view_model.afterBinding||c.afterBinding,i=n.view_model.beforeBinding||c.beforeBinding),i&&i.call(n.view_model,n.view_model,n.el,c),r.applyBindings(n.view_model,n.el,c),t&&t.call(n.view_model,n.view_model,n.el,c);return d},e}(),u=i.applyBindings,i.applyBindings=function(e,t){var n;return n=r.RECUSIVE_AUTO_INJECT?r.injectViewModels(t):[],n.length?void 0:u.apply(this,arguments)},r.injectViewModels=r.Inject.injectViewModels,"undefined"!=typeof document&&null!==document&&(t?t(function(){return r.injectViewModels()}):(o=function(){return"complete"!==document.readyState?setTimeout(o,0):r.injectViewModels()})())}).call(t,function(){return this}())},function(e,t,n){(function(t){var r,i,o,s,a,u;a=null!=a?a:t,s=n(32),i=["release","destroy","dispose"],e.exports=o=function(){function e(){}var t;return e.VERSION="0.20.5",e.TYPE_UNKNOWN=0,e.TYPE_SIMPLE=1,e.TYPE_ARRAY=2,e.TYPE_MODEL=3,e.TYPE_COLLECTION=4,e.wasReleased=function(e){return!e||e.__kb_released},e.isReleaseable=function(t,n){var r,o,a,u,l;if(null==n&&(n=0),!t||t!==Object(t)||t.__kb_released)return!1;if(s.isObservable(t)||t instanceof e.ViewModel)return!0;if("function"==typeof t||e.isModel(t)||e.isCollection(t))return!1;for(u=0,l=i.length;l>u;u++)if(o=i[u],"function"==typeof t[o])return!0;if(n>0)return!1;for(r in t)if(a=t[r],"__kb"!==r&&e.isReleaseable(a,n+1))return!0;return!1},e.release=function(t){var n,r,o,a,l,c;if(e.isReleaseable(t)){if(t.__kb_released=!0,!u.isArray(t)){if(s.isObservable(t)&&u.isArray(n=e.peek(t))){if(t.__kb_is_co||t.__kb_is_o&&t.valueType()===e.TYPE_COLLECTION)return"function"==typeof t.destroy?t.destroy():void 0;for(r in n)a=n[r],e.isReleaseable(a)&&(n[r]=null,e.release(a));return void("function"==typeof t.dispose&&t.dispose())}for(l=0,c=i.length;c>l;l++)if(o=i[l],"function"==typeof t[o])return t[o].call(t);return s.isObservable(t)?void 0:this.releaseKeys(t)}for(r in t)a=t[r],e.isReleaseable(a)&&(t[r]=null,e.release(a))}},e.releaseKeys=function(t){var n,r;for(n in t)r=t[n],"__kb"!==n&&e.isReleaseable(r)&&(t[n]=null,e.release(r))},e.releaseOnNodeRemove=function(t,n){return t||e._throwUnexpected(this,"missing view model"),n||e._throwUnexpected(this,"missing node"),s.utils.domNodeDisposal.addDisposeCallback(n,function(){return e.release(t)})},e.renderTemplate=function(t,n,r){var i,o,u;return null==r&&(r={}),(i=null!=a?a.document:void 0)?(o=i.createElement("div"),u=s.renderTemplate(t,n,r,o,"replaceChildren"),1===o.childNodes.length?o=o.childNodes[0]:o.childNodes.length&&s.storedBindingContextForNode(o,s.contextFor(o.childNodes[0])),e.releaseOnNodeRemove(n,o),u.dispose(),n.afterRender&&!r.afterRender&&n.afterRender(o),o):"undefined"!=typeof console&&null!==console?console.log("renderTemplate: document is undefined"):void 0},e.applyBindings=function(t,n){var r,i,o,a,u;if(n.length)for(u=[document.createElement("div"),n],n=u[0],i=u[1],o=0,a=i.length;a>o;o++)r=i[o],n.appendChild(r);return s.applyBindings(t,n),e.releaseOnNodeRemove(t,n),n},e.getValue=function(t,n,r){var i;if(t)return u.isFunction(t[n])&&(null!=(i=e.orm)?i.useFunction(t,n):void 0)?t[n]():r?t.get.apply(t,u.map([n].concat(r),function(t){return e.peek(t)})):t.get(n)},e.setValue=function(t,n,r){var i,o;if(t)return u.isFunction(t[n])&&(null!=(o=e.orm)?o.useFunction(t,n):void 0)?t[n](r):((i={})[n]=r,t.set(i))},e.ignore=(null!=(t=s.dependencyDetection)?t.ignore:void 0)||function(e,t,n){var r;return r=null,s.computed(function(){return r=e.apply(t,n||[])}).dispose(),r},e.extend=n(26),e._throwMissing=function(e,t){throw""+(u.isString(e)?e:e.constructor.name)+": "+t+" is missing"},e._throwUnexpected=function(e,t){throw""+(u.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"},e.publishMethods=function(t,n,r){var i,o,s;for(o=0,s=r.length;s>o;o++)i=r[o],t[i]=e._.bind(n[i],n)},e.peek=function(t){return s.isObservable(t)?t.peek?t.peek():e.ignore(function(){return t()}):t},e.isModel=function(t){return t&&(t instanceof e.Model||"function"==typeof t.get&&"function"==typeof t.bind)},e.isCollection=function(t){return t&&t instanceof e.Collection},e}(),a.Parse?(r=o.Parse=a.Parse,u=o._=a.Parse._):(r=o.Backbone=n(30),u=o._=n(31)),o.ko=s,o.Collection=r.Collection,o.Model=r.Object||r.Model,o.Events=r.Events,o.$=a.jQuery||a.$;try{o.$||(o.$=n(20))}catch(l){}}).call(t,function(){return this}())},function(e,t,n){var r,i,o,s,a;i=(r=n(6)).ko,(null!=(s=i.subscribable)&&null!=(a=s.fn)?a.extend:void 0)&&(o=i.subscribable.fn.extend,i.subscribable.fn.extend=function(){var e,t;return e=o.apply(this,arguments),e!==this&&r.isReleaseable(this)&&(t=e.dispose,e.dispose=function(n){return function(){return null!=t&&t.apply(e,arguments),r.release(n)}}(this)),e})},function(e,t,n){var r,i,o,s,a,u,l;l=s=n(6),u=l._,a=l.ko,o=n(11),i=["value","valueType","destroy"],r=["args","read","write"],s.Observable=function(){function e(e,t,n,l){return this._vm=null!=l?l:{},s.ignore(function(l){return function(){var c,d,p,f,h,v;for(t||s._throwMissing(l,"key_or_info"),l.key=t.key||t,h=0,v=r.length;v>h;h++)p=r[h],t[p]&&(l[p]=t[p]);return c=s.utils.collapseOptions(n),d=c.event_watcher,delete c.event_watcher,l._value=new o(c),l._model=a.observable(),f=s.utils.wrappedObservable(l,a.computed({read:function(){var e,t,n,r,i,o,c;for(i=l._model(),o=t=[l.key].concat(l.args||[]),n=0,r=o.length;r>n;n++)e=o[n],a.utils.unwrapObservable(e);return null!=(c=s.utils.wrappedEventWatcher(l))&&c.emitter(i||null),l.read?l.update(l.read.apply(l._vm,t)):u.isUndefined(i)||s.ignore(function(){return l.update(s.getValue(i,s.peek(l.key),l.args))}),l._value.value()},write:function(e){return s.ignore(function(){var t,n;return t=s.utils.unwrapModels(e),n=s.peek(l._model),l.write?(l.write.call(l._vm,t),e=s.getValue(n,s.peek(l.key),l.args)):n&&s.setValue(n,s.peek(l.key),t),l.update(e)})},owner:l._vm})),f.__kb_is_o=!0,c.store=s.utils.wrappedStore(f,c.store),c.path=s.utils.pathJoin(c.path,l.key),c.factories&&("function"==typeof c.factories||c.factories.create)?(c.factory=s.utils.wrappedFactory(f,new s.Factory(c.factory)),c.factory.addPathMapping(c.path,c.factories)):c.factory=s.Factory.useOptionsOrCreate(c,f,c.path),delete c.factories,s.publishMethods(f,l,i),f.model=l.model=a.computed({read:function(){return a.utils.unwrapObservable(l._model)},write:function(e){return s.ignore(function(){var t;if(!l.__kb_released&&s.peek(l._model)!==e)return t=s.getValue(e,s.peek(l.key),l.args),l._model(e),e?u.isUndefined(t)?void 0:l.update(t):l.update(null)})}}),s.EventWatcher.useOptionsOrCreate({event_watcher:d},e||null,l,{emitter:l.model,update:function(){return s.ignore(function(){return l.update()})},key:l.key,path:c.path}),l._value.rawValue()||l._value.update(),s.LocalizedObservable&&t.localizer&&(f=new t.localizer(f)),s.DefaultObservable&&t.hasOwnProperty("default")&&(f=s.defaultObservable(f,t["default"])),f}}(this))}return e.prototype.destroy=function(){var e;return e=s.utils.wrappedObservable(this),this.__kb_released=!0,this._value.destroy(),this._value=null,this.model.dispose(),this.model=e.model=null,s.utils.wrappedDestroy(this)},e.prototype.value=function(){return this._value.rawValue()},e.prototype.valueType=function(){return this._value.valueType(s.peek(this._model),s.peek(this.key))},e.prototype.update=function(e){return this.__kb_released?void 0:(arguments.length||(e=s.getValue(s.peek(this._model),s.peek(this.key))),this._value.update(e))},e}(),s.observable=function(e,t,n,r){return new s.Observable(e,t,n,r)}},function(e,t,n){var r,i;i=(r=n(6))._,e.exports=r.Statistics=function(){function e(){this.model_events_tracker=[],this.registered_tracker={}}return e.prototype.clear=function(){return this.model_events_tracker=[]},e.prototype.addModelEvent=function(e){return this.model_events_tracker.push(e)},e.prototype.modelEventsStatsString=function(){var e,t,n,r;n="",n+="Total Count: "+this.model_events_tracker.length,e=i.groupBy(this.model_events_tracker,function(e){return"event name: '"+e.name+"', attribute name: '"+e.key+"'"});for(t in e)r=e[t],n+="\n "+t+", count: "+r.length;return n},e.prototype.register=function(e,t){return this.registeredTracker(e).push(t)},e.prototype.unregister=function(e,t){var n,r;return r=this.registeredTracker(e),(n=i.indexOf(r,t))<0?"undefined"!=typeof console&&null!==console?console.log("kb.Statistics: failed to unregister type: "+e):void 0:r.splice(n,1)},e.prototype.registeredCount=function(e){var t,n,r;if(e)return this.registeredTracker(e).length;t=0,r=this.registered_tracker[e];for(e in r)n=r[e],t+=n.length;return t},e.prototype.registeredStatsString=function(e){var t,n,r,i,o;t="",o=this.registered_tracker;for(n in o)r=o[n],r.length&&(i&&(t+="\n "),t+=""+(n?n:"No Name")+": "+r.length,i=!0);return t?t:e},e.prototype.registeredTracker=function(e){var t;return this.registered_tracker.hasOwnProperty(e)?this.registered_tracker[e]:(t=[],this.registered_tracker[e]=t,t)},e.eventsStats=function(e,t){var n,r,o,s,a,u,l;for(o={count:0},n=e._events||e._callbacks||{},l=t?[t]:i.keys(n),a=0,u=l.length;u>a;a++)if(t=l[a],r=n[t]){if(i.isArray(r))o[t]=i.compact(r).length;else for(o[t]=0,s=r.tail;(r=r.next)!==s;)o[t]++;o.count+=o[t]}return o},e}()},function(e,t,n){var r,i,o,s;s=r=n(6),o=s._,i=s.ko,e.exports=r.Store=function(){function e(){this.observable_records={},this.replaced_observables=[],r.Store.instances.push(this)}return e.instances=[],e.useOptionsOrCreate=function(e,t,n){var i;return e.store||r.utils.wrappedStoreIsOwned(n,!0),i=r.utils.wrappedStore(n,e.store||new r.Store),i.retain(n,t,e.creator),i},e.prototype.destroy=function(){var e;return this.__kb_released=!0,this.clear(),(e=o.indexOf(r.Store.instances,this))>=0?r.Store.instances.splice(e,1):void 0},e.prototype.clear=function(){var e,t,n,r,i,o,s,a,u,l;u=[this.observable_records,{}],r=u[0],this.observable_records=u[1];for(t in r){i=r[t];for(e in i)n=i[e],this.release(n,!0)}for(l=[this.replaced_observables,[]],o=l[0],this.replaced_observables=l[1],s=0,a=o.length;a>s;s++)n=o[s],n.__kb_released||this.release(n,!0)},e.prototype.compact=function(){var e,t,n,r,i;i=this.observable_records;for(t in i){r=i[t];for(e in r)n=r[e],n.__kb_released&&delete r[e]}},e.prototype.retain=function(e,t,n){var r;if(this._canRegister(e)){if(n||(n=e.constructor),r=this.find(t,n)){if(r===e)return this._getOrCreateStoreReferences(e).ref_count++,e;this._retire(r)}return this._add(e,t,n),this._getOrCreateStoreReferences(e).ref_count++,e}},e.prototype.retainOrCreate=function(e,t){var n,s;if(!(n=this._creator(e,t)))return r.utils.createFromDefaultCreator(e,t);if(n.models_only)return e;if(s=this.find(e,n))return s;if(!o.isFunction(n.create||n))throw new Error('Invalid factory for "'+t.path+'"');return s=r.ignore(function(r){return function(){return t=o.defaults({store:r,creator:n},t),s=n.create?n.create(e,t):new n(e,t),s||i.observable(null)}}(this)),this.retain(s,e,n),s},e.prototype.reuse=function(e,t){var n,i,s;if((i=r.utils.wrappedObject(e))!==t){if(!this._canRegister(e))throw new Error("Cannot reuse a simple observable");if(1!==this._refCount(e))throw new Error("Trying to change a shared view model. Ref count: "+this._refCount(e));n=r.utils.wrappedCreator(e)||e.constructor,o.isUndefined(i)||(s=this.find(i,n)),this.retain(e,t,n),s&&this.release(s)}},e.prototype.release=function(e,t){var n;if(!this._canRegister(e))return r.release(e);if(n=this._storeReferences(e)){if(!t&&--n.ref_count>0)return;this._clearStoreReferences(e)}return this._remove(e),e.__kb_released?void 0:t||this._refCount(e)<=1?r.release(e):void 0},e.prototype.find=function(e,t){var n,r,i;return(r=this.observable_records[this._creatorId(t)])?(null!=(i=n=r[this._cid(e)])?i.__kb_released:void 0)?(delete r[this._cid(e)],null):n:null},e.prototype._refCount=function(e){var t;return e.__kb_released?("undefined"!=typeof console&&null!==console&&console.log("Observable already released"),0):(t=r.utils.get(e,"stores_references"))?o.reduce(t,function(e,t){return e+t.ref_count},0):1},e.prototype._canRegister=function(e){return e&&!i.isObservable(e)&&!e.__kb_is_co},e.prototype._cid=function(e){var t;return t=e?e.cid||(e.cid=o.uniqueId("c")):"null"},e.prototype._creatorId=function(e){var t,n,r,i,s;for(t=e.create||e,t.__kb_cids||(t.__kb_cids=[]),s=t.__kb_cids,r=0,i=s.length;i>r;r++)if(n=s[r],n.create===t)return n.cid;return t.__kb_cids.push(n={create:t,cid:o.uniqueId("kb")}),n.cid},e.prototype._storeReferences=function(e){var t;if(t=r.utils.get(e,"stores_references"))return o.find(t,function(e){return function(t){return t.store===e}}(this))},e.prototype._getOrCreateStoreReferences=function(e){var t,n;return n=r.utils.orSet(e,"stores_references",[]),(t=o.find(n,function(e){return function(t){return t.store===e}}(this)))||n.push(t={store:this,ref_count:0,release:function(t){return function(){return t.release(e)}}(this)}),t},e.prototype._clearStoreReferences=function(e){var t,n,i,o;if(i=r.utils.get(e,"stores_references")){o=e.__kb.stores_references;for(t in o)if(n=o[t],n.store===this){e.__kb.stores_references.splice(t,1);break}}},e.prototype._retire=function(e){return this._clearStoreReferences(e),this.replaced_observables.push(e),this._remove(e)},e.prototype._add=function(e,t,n){var i,o;return n||(n=e.constructor),r.utils.wrappedObject(e,t),r.utils.wrappedCreator(e,n),((i=this.observable_records)[o=this._creatorId(n)]||(i[o]={}))[this._cid(t)]=e},e.prototype._remove=function(e){var t,n,i;return t=r.utils.wrappedCreator(e)||e.constructor,(n=this.find(i=r.utils.wrappedObject(e),t))&&n===e&&delete this.observable_records[this._creatorId(t)][this._cid(i)],r.utils.wrappedObject(e,null),r.utils.wrappedCreator(e,null)},e.prototype._creator=function(e,t){var n;return t.creator?t.creator:(n=r.utils.inferCreator(e,t.factory,t.path))?n:r.isModel(e)?r.ViewModel:void 0},e}()},function(e,t,n){var r,i,o,s,a;a=i=n(6),s=a._,o=a.ko,e.exports=r=function(){function e(e){this.create_options=e,this._vo=o.observable(null)}return e.prototype.destroy=function(){var e;return this.__kb_released=!0,(e=this.__kb_value)&&(this.__kb_value=null,this.create_options.store&&i.utils.wrappedCreator(e)?this.create_options.store.release(e):i.release(e)),this.create_options=null},e.prototype.value=function(){return o.utils.unwrapObservable(this._vo())},e.prototype.rawValue=function(){return this.__kb_value},e.prototype.valueType=function(e,t){var n;return n=i.getValue(e,t),this.value_type||this._updateValueObservable(n),this.value_type},e.prototype.update=function(e){var t,n,r;if(!this.__kb_released){switch(void 0!==e||(e=null),t=i.utils.valueType(e),(null!=(r=this.__kb_value)?r.__kb_released:void 0)&&(this.__kb_value=this.value_type=void 0),n=this.__kb_value,this.value_type){case i.TYPE_COLLECTION:if(this.value_type===i.TYPE_COLLECTION&&t===i.TYPE_ARRAY)return n(e);if(t===i.TYPE_COLLECTION||s.isNull(e))return void(e&&e instanceof i.CollectionObservable?this._updateValueObservable(i.utils.wrappedObject(e),e):i.peek(n.collection)!==e&&n.collection(e));break;case i.TYPE_MODEL:if(t===i.TYPE_MODEL||s.isNull(e))return void(e&&!i.isModel(e)?this._updateValueObservable(i.utils.wrappedObject(e),e):i.utils.wrappedObject(n)!==i.utils.resolveModel(e)&&this._updateValueObservable(e))}if(this.value_type!==t||s.isUndefined(this.value_type)){if(i.peek(n)!==e)return this._updateValueObservable(e)}else if(i.peek(n)!==e)return n(e)}},e.prototype._updateValueObservable=function(e,t){var n,r,a,u,l,c;return n=this.create_options,r=i.utils.inferCreator(e,n.factory,n.path),null!==e||r||(this.value_type===i.TYPE_MODEL?r=i.ViewModel:this.value_type===i.TYPE_COLLECTION&&(r=i.CollectionObservable)),n.creator=r,l=i.TYPE_UNKNOWN,c=[this.__kb_value,void 0],a=c[0],this.__kb_value=c[1],t?(u=t,n.store&&n.store.retain(t,e,r)):r?n.store?u=n.store.retainOrCreate(e,n):r.models_only?(u=e,l=i.TYPE_SIMPLE):u=r.create?r.create(e,n):new r(e,n):s.isArray(e)?(l=i.TYPE_ARRAY,u=o.observableArray(e)):(l=i.TYPE_SIMPLE,u=o.observable(e)),(this.value_type=l)===i.TYPE_UNKNOWN&&(o.isObservable(u)?u.__kb_is_co?(this.value_type=i.TYPE_COLLECTION,i.utils.wrappedObject(u,e)):this.value_type||(this.value_type=i.TYPE_SIMPLE):(this.value_type=i.TYPE_MODEL,i.utils.wrappedObject(u,i.utils.resolveModel(e)))),a&&(this.create_options.store?this.create_options.store.release(a):i.release(a)),this.__kb_value=u,this._vo(u)},e.prototype._inferType=function(){},e}()},function(e,t,n){var r,i,o,s;s=r=n(6),o=s._,i=s.ko,r.utils=function(){function e(){}return e.get=function(e,t,n){return e.__kb&&e.__kb.hasOwnProperty(t)?e.__kb[t]:n},e.set=function(e,t,n){return(e.__kb||(e.__kb={}))[t]=n},e.orSet=function(e,t,n){return(e.__kb||(e.__kb={})).hasOwnProperty(t)||(e.__kb[t]=n),e.__kb[t]},e.has=function(e,t){return e.__kb&&e.__kb.hasOwnProperty(t)},e.wrappedObservable=function(e,t){return 1===arguments.length?r.utils.get(e,"observable"):r.utils.set(e,"observable",t)},e.wrappedObject=function(e,t){return 1===arguments.length?r.utils.get(e,"object"):r.utils.set(e,"object",t)},e.wrappedCreator=function(e,t){return 1===arguments.length?r.utils.get(e,"creator"):r.utils.set(e,"creator",t)},e.wrappedModel=function(e,t){return 1===arguments.length?o.isUndefined(t=r.utils.get(e,"object"))?e:t:r.utils.set(e,"object",t)},e.wrappedStore=function(e,t){return 1===arguments.length?r.utils.get(e,"store"):r.utils.set(e,"store",t)},e.wrappedStoreIsOwned=function(e,t){return 1===arguments.length?r.utils.get(e,"store_is_owned"):r.utils.set(e,"store_is_owned",t)},e.wrappedFactory=function(e,t){return 1===arguments.length?r.utils.get(e,"factory"):r.utils.set(e,"factory",t)},e.wrappedEventWatcher=function(e,t){return 1===arguments.length?r.utils.get(e,"event_watcher"):r.utils.set(e,"event_watcher",t)},e.wrappedEventWatcherIsOwned=function(e,t){return 1===arguments.length?r.utils.get(e,"event_watcher_is_owned"):r.utils.set(e,"event_watcher_is_owned",t)},e.wrappedDestroy=n(27),e.valueType=function(e){return e?e.__kb_is_o?e.valueType():e.__kb_is_co||e instanceof r.Collection?r.TYPE_COLLECTION:e instanceof r.ViewModel||e instanceof r.Model?r.TYPE_MODEL:o.isArray(e)?r.TYPE_ARRAY:r.TYPE_SIMPLE:r.TYPE_UNKNOWN
},e.pathJoin=function(e,t){return(e?"."!==e[e.length-1]?""+e+".":e:"")+t},e.optionsPathJoin=function(e,t){return o.defaults({path:this.pathJoin(e.path,t)},e)},e.inferCreator=function(e,t,n){var i;return t&&(i=t.creatorForPath(e,n))?i:e?e instanceof r.Model?r.ViewModel:e instanceof r.Collection?r.CollectionObservable:null:null},e.createFromDefaultCreator=function(e,t){return r.isModel(e)?r.viewModel(e,t):r.isCollection(e)?r.collectionObservable(e,t):o.isArray(e)?i.observableArray(e):i.observable(e)},e.collapseOptions=n(28),e.unwrapModels=n(29),e.resolveModel=function(e){return e&&r.Backbone&&r.Backbone.ModelRef&&e instanceof r.Backbone.ModelRef?e.model():e},e}()},function(e,t,n){var r,i,o,s,a,u,l,c;c=a=n(6),l=c._,u=c.ko,i=function(e,t){var n;return n=e.__kb.internals&&l.contains(e.__kb.internals,t)?"_"+t:t,e.__kb.view_model.hasOwnProperty(n)?void 0:(e.__kb.view_model[n]=null,n)},o=function(e,t,n,r){var o;if(!(e.__kb.excludes&&l.contains(e.__kb.excludes,n)||e.__kb.statics&&l.contains(e.__kb.statics,n)||!(o=i(e,n))))return e[o]=e.__kb.view_model[o]=a.observable(t,n,r,e)},s=function(e,t){var n,r,o,s,a;for(a=e.__kb.statics,o=0,s=a.length;s>o;o++)n=a[o],(r=i(e,n))&&(t.has(r)?e[r]=e.__kb.view_model[r]=t.get(r):e.__kb.static_defaults&&r in e.__kb.static_defaults?e[r]=e.__kb.view_model[r]=e.__kb.static_defaults[r]:delete e.__kb.view_model[r])},r=["keys","internals","excludes","statics","static_defaults"],a.ViewModel=function(){function e(e,t){var n;return null==t&&(t={}),n=Array.prototype.slice.call(l.isArguments(e)?e:arguments),a.ignore(function(i){return function(){var o,c,d,p,f,h,v,m;for(!(e=n.shift())||a.isModel(e)||a._throwUnexpected(i,"not a model"),l.isArray(n[0])&&(n[0]={keys:n[0]}),i.__kb||(i.__kb={}),i.__kb.view_model=n.length>1?n.pop():i,t={},p=0,h=n.length;h>p;p++)o=n[p],l.extend(t,o);for(t=a.utils.collapseOptions(t),f=0,v=r.length;v>f;f++)d=r[f],t.hasOwnProperty(d)&&(i.__kb[d]=t[d]);return a.Store.useOptionsOrCreate(t,e,i),i.__kb.path=t.path,a.Factory.useOptionsOrCreate(t,i,t.path),m=a.utils.set(i,"_model",u.observable()),i.model=u.computed({read:function(){return u.utils.unwrapObservable(m)},write:function(e){return a.ignore(function(){return a.utils.wrappedObject(i)!==e&&!a.wasReleased(i)&&c?(i.__kb.store.reuse(i,a.utils.resolveModel(e)),c.emitter(e),m(c.ee),!c.ee||i.createObservables(c.ee)):void 0})}}),c=a.utils.wrappedEventWatcher(i,new a.EventWatcher(e,i,{emitter:i._model,update:function(){return a.ignore(function(){return!(null!=c?c.ee:void 0)||i.createObservables(null!=c?c.ee:void 0)})}})),a.utils.wrappedObject(i,e=c.ee),m(c.ee),i.__kb.create_options={store:a.utils.wrappedStore(i),factory:a.utils.wrappedFactory(i),path:i.__kb.path,event_watcher:a.utils.wrappedEventWatcher(i)},!t.requires||i.createObservables(e,t.requires),!i.__kb.internals||i.createObservables(e,i.__kb.internals),!t.mappings||i.createObservables(e,t.mappings),!i.__kb.statics||s(i,e),i.createObservables(e,i.__kb.keys),!a.statistics||a.statistics.register("ViewModel",i),i}}(this))}return e.extend=a.extend,e.prototype.destroy=function(){var e;if(this.__kb_released=!0,this.__kb.view_model!==this)for(e in this.__kb.vm_keys)this.__kb.view_model[e]=null;return this.__kb.view_model=this.__kb.create_options=null,a.releaseKeys(this),a.utils.wrappedDestroy(this),!a.statistics||a.statistics.unregister("ViewModel",this)},e.prototype.shareOptions=function(){return{store:a.utils.wrappedStore(this),factory:a.utils.wrappedFactory(this)}},e.prototype.createObservables=function(e,t){var n,r,s,u,c,d,p,f,h;if(t)if(l.isArray(t))for(d=0,f=t.length;f>d;d++)n=t[d],o(this,e,n,this.__kb.create_options);else for(n in t)r=t[n],(u=i(this,n))&&(l.isString(r)||r.key||(r.key=u),this[u]=this.__kb.view_model[u]=a.observable(e,r,this.__kb.create_options,this));else{if(this.__kb.keys||!e)return;for(n in e.attributes)o(this,e,n,this.__kb.create_options);if(s=null!=(h=a.orm)&&"function"==typeof h.keys?h.keys(e):void 0)for(c=0,p=s.length;p>c;c++)n=s[c],o(this,e,n,this.__kb.create_options)}},e}(),a.viewModel=function(){return new a.ViewModel(arguments)}},function(e,t,n){var r,i,o,s,a;if(e.exports=r=n(6),r.configure=n(2),r.modules={underscore:r._,backbone:r.Parse||r.Backbone,knockout:r.ko},"undefined"!=typeof window&&null!==window)for(a=["_","Backbone","Parse","ko","$"],o=0,s=a.length;s>o;o++)i=a[o],r[i]&&!Object.prototype.hasOwnProperty.call(window,i)&&(window[i]=r[i])},function(e,t,n){var r,i,o,s,a;a=i=n(6),s=a._,o=a.ko,n(21),r=["destroy","setToDefault"],e.exports=i.DefaultObservable=function(){function e(e,t){var n;return this.dv=t,n=i.utils.wrappedObservable(this,o.computed({read:function(t){return function(){var n;return n=o.utils.unwrapObservable(e()),s.isNull(n)||s.isUndefined(n)?o.utils.unwrapObservable(t.dv):n}}(this),write:function(t){return e(t)}})),i.publishMethods(n,this,r),n}return e.prototype.destroy=function(){return i.utils.wrappedDestroy(this)},e.prototype.setToDefault=function(){return i.utils.wrappedObservable(this)(this.dv)},e}(),i.defaultObservable=function(e,t){return new i.DefaultObservable(e,t)}},function(e,t,n){var r,i,o,s,a;a=i=n(6),s=a._,o=a.ko,r=Array.prototype.slice,i.toFormattedString=function(e){var t,n,i,a,u,l;u=e.slice(),n=r.call(arguments,1);for(i in n)for(t=n[i],l=o.utils.unwrapObservable(t),(s.isUndefined(l)||s.isNull(l))&&(l=""),a=e.indexOf("{"+i+"}");a>=0;)u=u.replace("{"+i+"}",l),a=e.indexOf("{"+i+"}",a+1);return u},i.parseFormattedString=function(e,t){var n,r,i,o,a,u,l,c,d,p,f,h,v;for(p=t.slice(),i=0,u=0,c={};p.search("\\{"+i+"\\}")>=0;){for(l=t.indexOf("{"+i+"}");l>=0;)p=p.replace("{"+i+"}","(.*)"),c[l]=i,u++,l=t.indexOf("{"+i+"}",l+1);i++}if(n=i,d=new RegExp(p),a=d.exec(e),a&&a.shift(),!a||a.length!==u){for(f=[];n-->0;)f.push("");return f}v=s.sortBy(s.keys(c),function(e){return parseInt(e,10)}),r={};for(o in v)l=v[o],i=c[l],r.hasOwnProperty(i)||(r[i]=o);for(h=[],i=0;n>i;)h.push(a[r[i]]),i++;return h},e.exports=i.FormattedObservable=function(){function e(e,t){var n,a;return s.isArray(t)?(e=e,a=t):a=r.call(arguments,1),n=i.utils.wrappedObservable(this,o.computed({read:function(){var n,r,s;for(t=[o.utils.unwrapObservable(e)],r=0,s=a.length;s>r;r++)n=a[r],t.push(o.utils.unwrapObservable(n));return i.toFormattedString.apply(null,t)},write:function(t){var n,r,s;for(r=i.parseFormattedString(t,o.utils.unwrapObservable(e)),s=Math.min(a.length,r.length),n=0;s>n;)a[n](r[n]),n++}}))}return e.prototype.destroy=function(){return i.utils.wrappedDestroy(this)},e}(),i.formattedObservable=function(e){return new i.FormattedObservable(e,r.call(arguments,1))}},function(e,t,n){var r,i,o,s,a;a=i=n(6),s=a._,o=a.ko,r=["destroy","observedValue","resetToCurrent"],i.locale_manager||(i.locale_manager=void 0),e.exports=i.LocalizedObservable=function(){function e(e,t,n){var a;return this.value=e,this.vm=n,t||(t={}),this.vm||(this.vm={}),this.read||i._throwMissing(this,"read"),i.locale_manager||i._throwMissing(this,"kb.locale_manager"),this.__kb||(this.__kb={}),this.__kb._onLocaleChange=s.bind(this._onLocaleChange,this),this.__kb._onChange=t.onChange,this.value&&(e=o.utils.unwrapObservable(this.value)),this.vo=o.observable(e?this.read(e,null):null),a=i.utils.wrappedObservable(this,o.computed({read:function(e){return function(){return e.value&&o.utils.unwrapObservable(e.value),e.vo(),e.read(o.utils.unwrapObservable(e.value))}}(this),write:function(e){return function(t){return e.write||i._throwUnexpected(e,"writing to read-only"),e.write(t,o.utils.unwrapObservable(e.value)),e.vo(t),e.__kb._onChange?e.__kb._onChange(t):void 0}}(this),owner:this.vm})),i.publishMethods(a,this,r),i.locale_manager.bind("change",this.__kb._onLocaleChange),t.hasOwnProperty("default")&&(a=i.DefaultObservable&&o.defaultObservable(a,t["default"])),a}return e.extend=i.extend,e.prototype.destroy=function(){return i.locale_manager.unbind("change",this.__kb._onLocaleChange),this.vm=null,i.utils.wrappedDestroy(this)},e.prototype.resetToCurrent=function(){var e,t;return t=i.utils.wrappedObservable(this),e=this.value?this.read(o.utils.unwrapObservable(this.value)):null,t()!==e?t(e):void 0},e.prototype.observedValue=function(e){return 0===arguments.length?this.value:(this.value=e,void this._onLocaleChange())},e.prototype._onLocaleChange=function(){var e;return e=this.read(o.utils.unwrapObservable(this.value)),this.vo(e),this.__kb._onChange?this.__kb._onChange(e):void 0},e}(),i.localizedObservable=function(e,t,n){return new i.LocalizedObservable(e,t,n)}},function(e,t,n){var r,i,o,s,a;a=i=n(6),s=a._,o=a.ko,r=["destroy"],e.exports=i.TriggeredObservable=function(){function e(e,t){var n;return this.event_selector=t,e||i._throwMissing(this,"emitter"),this.event_selector||i._throwMissing(this,"event_selector"),this.vo=o.observable(),n=i.utils.wrappedObservable(this,o.computed(function(e){return function(){return e.vo()}}(this))),i.publishMethods(n,this,r),i.utils.wrappedEventWatcher(this,new i.EventWatcher(e,this,{emitter:s.bind(this.emitter,this),update:s.bind(this.update,this),event_selector:this.event_selector})),n}return e.prototype.destroy=function(){return i.utils.wrappedDestroy(this)},e.prototype.emitter=function(e){return 0===arguments.length||this.ee===e?this.ee:(this.ee=e)?this.update():void 0},e.prototype.update=function(){return this.ee?this.vo()!==this.ee?this.vo(this.ee):this.vo.valueHasMutated():void 0},e}(),i.triggeredObservable=function(e,t){return new i.TriggeredObservable(e,t)}},function(e,t,n){var r,i,o,s,a,u;u=o=n(6),a=u._,s=u.ko,r=u.$,n(22),i=function(e){return e=s.utils.unwrapObservable(e),"function"==typeof e?e.apply(null,Array.prototype.slice.call(arguments,1)):e},e.exports=o.Validation=function(){function e(){}return e}(),o.valueValidator=function(e,t,n){return null==n&&(n={}),n&&!("function"==typeof n)||(n={}),s.computed(function(){var r,o,u,l,c,d,p,f;p={$error_count:0},o=s.utils.unwrapObservable(e),!("disable"in n)||(u=i(n.disable)),!("enable"in n)||(u=!i(n.enable)),d=n.priorities||[],a.isArray(d)||(d=[d]),r=d.length+1;for(l in t)f=t[l],p[l]=!u&&i(f,o),p[l]&&(p.$error_count++,(c=a.indexOf(d,l)>=0)||(c=d.length),p.$active_error&&r>c?(p.$active_error=l,r=c):p.$active_error||(p.$active_error=l,r=c));return p.$enabled=!u,p.$disable=!!u,p.$valid=0===p.$error_count,p})},o.inputValidator=function(e,t,n){var i,s,u,l,c,d,p,f,h,v;if(null==n&&(n={}),n&&!("function"==typeof n)||(n={}),h=o.valid,i=r(t),(l=i.attr("name"))&&!a.isString(l)&&(l=null),!(s=i.attr("data-bind")))return null;if(c=new Function("sc","with(sc[0]) { return { "+s+" } }")([e]),!c||!c.value)return null;if(!c.validation_options||(a.defaults(c.validation_options,n),n=c.validation_options),s={},!h[p=i.attr("type")]||(s[p]=h[p]),!i.attr("required")||(s.required=h.required),c.validations){v=c.validations;for(u in v)f=v[u],s[u]=f}return d=o.valueValidator(c.value,s,n),!l&&!n.no_attach||(e["$"+l]=d),d},o.formValidator=function(e,t){var n,i,u,l,c,d,p,f,h,v,m,b,g;for(p={},v=[],n=r(t),(u=n.attr("name"))&&!a.isString(u)&&(u=null),(i=n.attr("data-bind"))&&(d=new Function("sc","with(sc[0]) { return { "+i+" } }")([e]),f=d.validation_options),f||(f={}),f.no_attach=!!u,g=n.find("input"),m=0,b=g.length;b>m;m++)l=g[m],(c=r(l).attr("name"))&&(h=o.inputValidator(e,l,f),!h||v.push(p[c]=h));return p.$error_count=s.computed(function(){var e,t,n;for(e=0,t=0,n=v.length;n>t;t++)h=v[t],e+=h().$error_count;return e}),p.$valid=s.computed(function(){return 0===p.$error_count()}),p.$enabled=s.computed(function(){var e,t,n;for(e=!0,t=0,n=v.length;n>t;t++)h=v[t],e&=h().$enabled;return e}),p.$disabled=s.computed(function(){return!p.$enabled()}),u&&(e["$"+u]=p),p}},function(t){t.exports=e},function(e,t,n){var r,i,o,s;s=r=n(6),o=s._,i=s.ko,r.Observable.prototype.setToDefault=function(){var e;null!=(e=this.__kb_value)&&"function"==typeof e.setToDefault&&e.setToDefault()},r.ViewModel.prototype.setToDefault=function(){var e,t;for(e in this.__kb.vm_keys)null!=(t=this[e])&&"function"==typeof t.setToDefault&&t.setToDefault()},r.utils.setToDefault=function(e){var t,n;if(e){if(i.isObservable(e))"function"==typeof e.setToDefault&&e.setToDefault();else if(o.isObject(e))for(t in e)n=e[t],!n||!i.isObservable(n)&&"function"==typeof n||"_"===t[0]&&!t.search("__kb")||this.setToDefault(n);return e}}},function(e,t,n){var r,i,o,s,a,u,l,c;c=a=n(6),l=c._,u=c.ko,r=c.$,s=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,i=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/,o=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,a.valid={required:function(e){return!e},url:function(e){return!s.test(e)},email:function(e){return!i.test(e)},number:function(e){return!o.test(e)}},a.hasChangedFn=function(e){var t,n;return n=null,t=null,function(){var r;return n!==(r=u.utils.unwrapObservable(e))?(n=r,t=n?n.toJSON():null,!1):n&&t?!l.isEqual(n.toJSON(),t):!1}},a.minLengthFn=function(e){return function(t){return!t||t.length<e}},a.uniqueValueFn=function(e,t,n){return function(r){var i,o,s;return s=u.utils.unwrapObservable(e),o=u.utils.unwrapObservable(t),i=u.utils.unwrapObservable(n),s&&o&&i?!!l.find(i.models,function(){return function(e){return e!==s&&e.get(o)===r}}(this)):!1}},a.untilTrueFn=function(e,t,n){var r;return r=!1,n&&u.isObservable(n)&&n.subscribe(function(){return r=!1}),function(n){var i,o;return(i=u.utils.unwrapObservable(t))?(r|=!!(o=i(u.utils.unwrapObservable(n))),r?o:u.utils.unwrapObservable(e)):u.utils.unwrapObservable(e)}},a.untilFalseFn=function(e,t,n){var r;return r=!1,n&&u.isObservable(n)&&n.subscribe(function(){return r=!1}),function(n){var i,o;return(i=u.utils.unwrapObservable(t))?(r|=!(o=i(u.utils.unwrapObservable(n))),r?o:u.utils.unwrapObservable(e)):u.utils.unwrapObservable(e)}}},function(e,t,n){var r,i,o,s,a,u;u=s=n(6),a=u._,i=u.Backbone,r=null,e.exports=o=function(){function e(){}return e.isAvailable=function(){return!!(r=null!=i?i.AssociatedModel:void 0)},e.keys=function(e){return e instanceof r?a.map(e.relations,function(e){return e.key}):null},e.relationType=function(e,t){var n;return e instanceof r&&(n=a.find(e.relations,function(e){return e.key===t}))?"Many"===n.type?s.TYPE_COLLECTION:s.TYPE_MODEL:null},e.useFunction=function(){return!1},e}()},function(e,t,n){var r,i,o,s,a,u;u=s=n(6),a=u._,r=u.Backbone,o=null,e.exports=i=function(){function e(){}return e.isAvailable=function(){return!!(o=null!=r?r.RelationalModel:void 0)},e.relationType=function(e,t){var n;return e instanceof o&&(n=a.find(e.getRelations(),function(e){return e.key===t}))?n.collectionType||a.isArray(n.keyContents)?s.TYPE_COLLECTION:s.TYPE_MODEL:null},e.bind=function(e,t,n,r){var i,o,a,u,l,c;if(!(u=this.relationType(e,t)))return null;if(a=function(e){return!s.statistics||s.statistics.addModelEvent({name:"update (relational)",model:e,key:t,path:r}),n()},o=s.Backbone.Relation.prototype.sanitizeOptions?["update","add","remove"]:["change","add","remove"],u===s.TYPE_COLLECTION)for(l=0,c=o.length;c>l;l++)i=o[l],e.bind(""+i+":"+t,a);else e.bind(""+o[0]+":"+t,a);return function(){var n,r;if(u===s.TYPE_COLLECTION)for(n=0,r=o.length;r>n;n++)i=o[n],e.unbind(""+i+":"+t,a);else e.unbind(""+o[0]+":"+t,a)}},e.useFunction=function(){return!1},e}()},function(e,t,n){(function(t){var r,i,o,s;o="undefined"!=typeof window&&null!==window?window:t,s=(i=n(6))._,r=null,e.exports=r=function(){function e(){}return e.isAvailable=function(){return!!(e=o.Supermodel)},e.keys=function(t){return t instanceof e.Model?s.keys(t.constructor.associations()):null},e.relationType=function(t,n){var r;return t instanceof e.Model&&(r=t.constructor.associations()[n])?r.add?i.TYPE_COLLECTION:i.TYPE_MODEL:null},e.bind=function(e,t,n,r){var o,s;return(s=this.relationType(e,t))?(o=function(e,o){var s,a;return!i.statistics||i.statistics.addModelEvent({name:"update (supermodel)",model:e,key:t,path:r}),a=e.constructor.associations()[t],s=e[a.store],e[a.store]=o,n(o),e[a.store]=s},s===i.TYPE_MODEL?(e.bind("associate:"+t,o),function(){return e.unbind("associate:"+t,o)}):void 0):null},e.useFunction=function(e,t){return!!this.relationType(e,t)},e}()}).call(t,function(){return this}())},function(e){var t;t=function(e,t){var n,r;for(n in t)r=t[n],e[n]=r;return e};var n=function(){},r=function(e,r,i){var o;return o=r&&r.hasOwnProperty("constructor")?r.constructor:function(){e.apply(this,arguments)},t(o,e),n.prototype=e.prototype,o.prototype=new n,r&&t(o.prototype,r),i&&t(o,i),o.prototype.constructor=o,o.__super__=e.prototype,o},i=function(e,t){var n=r(this,e,t);return n.extend=this.extend,n};e.exports=i},function(e,t,n){var r,i;i=n(6)._,e.exports=r=function(e){var t,n;if(e.__kb&&(e.__kb.event_watcher&&e.__kb.event_watcher.releaseCallbacks(e),n=e.__kb,e.__kb=null,n.observable&&(n.observable.destroy=n.observable.release=null,r(n.observable),n.observable=null),n.factory=null,n.event_watcher_is_owned&&n.event_watcher.destroy(),n.event_watcher=null,n.store_is_owned&&n.store.destroy(),n.store=null,n.stores_references))for(;t=n.stores_references.pop();)t.store.__kb_released||t.store.release(e)}},function(e,t,n){var r,i,o,s,a;r=n(6)._,o=function(e,t,n){return e[t]||(e[t]=[]),r.isArray(n)||(n=[n]),e[t]=e[t].length?r.union(e[t],n):n,e},s=function(e,t,n){return e[t]||(e[t]={}),r.extend(e[t],n)},i=function(e){var t,n,r,i;for(n={},r=0,i=e.length;i>r;r++)t=e[r],n[t]={key:t};return n},a=function(e,t){var n,u;if(!t)return e;for(n in t)switch(u=t[n],n){case"internals":case"requires":case"excludes":case"statics":o(e,n,u);break;case"keys":r.isObject(u)&&!r.isArray(u)||r.isObject(e[n])&&!r.isArray(e[n])?(r.isObject(u)||(u=[u]),r.isArray(u)&&(u=i(u)),r.isArray(e[n])&&(e[n]=i(e[n])),s(e,n,u)):o(e,n,u);break;case"factories":r.isFunction(u)?e[n]=u:s(e,n,u);break;case"static_defaults":s(e,n,u);break;case"options":break;default:e[n]=u}return a(e,t.options)},e.exports=function(e){return a({},e)}},function(e,t,n){var r,i;i=n(6)._,e.exports=r=function(e){var t,n,o;if(!e)return e;if(e.__kb)return e.__kb.hasOwnProperty("object")?e.__kb.object:e;if(i.isArray(e))return i.map(e,function(e){return r(e)});if(i.isObject(e)&&e.constructor==={}.constructor){n={};for(t in e)o=e[t],n[t]=r(o);return n}return e}},function(e,t,n){var r,i;!function(o,s){r=[n(31),n(20),t],i=function(e,t,n){o.Backbone=s(o,n,e,t)}.apply(t,r),!(void 0!==i&&(e.exports=i))}(this,function(e,t,n,r){{var i=e.Backbone,o=[],s=(o.push,o.slice);o.splice}t.VERSION="1.1.2",t.$=r,t.noConflict=function(){return e.Backbone=i,this},t.emulateHTTP=!1,t.emulateJSON=!1;var a=t.Events={on:function(e,t,n){if(!l(this,"on",e,[t,n])||!t)return this;this._events||(this._events={});var r=this._events[e]||(this._events[e]=[]);return r.push({callback:t,context:n,ctx:n||this}),this},once:function(e,t,r){if(!l(this,"once",e,[t,r])||!t)return this;var i=this,o=n.once(function(){i.off(e,o),t.apply(this,arguments)});return o._callback=t,this.on(e,o,r)},off:function(e,t,r){var i,o,s,a,u,c,d,p;if(!this._events||!l(this,"off",e,[t,r]))return this;if(!e&&!t&&!r)return this._events=void 0,this;for(a=e?[e]:n.keys(this._events),u=0,c=a.length;c>u;u++)if(e=a[u],s=this._events[e]){if(this._events[e]=i=[],t||r)for(d=0,p=s.length;p>d;d++)o=s[d],(t&&t!==o.callback&&t!==o.callback._callback||r&&r!==o.context)&&i.push(o);i.length||delete this._events[e]}return this},trigger:function(e){if(!this._events)return this;var t=s.call(arguments,1);if(!l(this,"trigger",e,t))return this;var n=this._events[e],r=this._events.all;return n&&c(n,t),r&&c(r,arguments),this},stopListening:function(e,t,r){var i=this._listeningTo;if(!i)return this;var o=!t&&!r;r||"object"!=typeof t||(r=this),e&&((i={})[e._listenId]=e);for(var s in i)e=i[s],e.off(t,r,this),(o||n.isEmpty(e._events))&&delete this._listeningTo[s];return this}},u=/\s+/,l=function(e,t,n,r){if(!n)return!0;if("object"==typeof n){for(var i in n)e[t].apply(e,[i,n[i]].concat(r));return!1}if(u.test(n)){for(var o=n.split(u),s=0,a=o.length;a>s;s++)e[t].apply(e,[o[s]].concat(r));return!1}return!0},c=function(e,t){var n,r=-1,i=e.length,o=t[0],s=t[1],a=t[2];switch(t.length){case 0:for(;++r<i;)(n=e[r]).callback.call(n.ctx);return;case 1:for(;++r<i;)(n=e[r]).callback.call(n.ctx,o);return;case 2:for(;++r<i;)(n=e[r]).callback.call(n.ctx,o,s);return;case 3:for(;++r<i;)(n=e[r]).callback.call(n.ctx,o,s,a);return;default:for(;++r<i;)(n=e[r]).callback.apply(n.ctx,t);return}},d={listenTo:"on",listenToOnce:"once"};n.each(d,function(e,t){a[t]=function(t,r,i){var o=this._listeningTo||(this._listeningTo={}),s=t._listenId||(t._listenId=n.uniqueId("l"));return o[s]=t,i||"object"!=typeof r||(i=this),t[e](r,i,this),this}}),a.bind=a.on,a.unbind=a.off,n.extend(t,a);var p=t.Model=function(e,t){var r=e||{};t||(t={}),this.cid=n.uniqueId("c"),this.attributes={},t.collection&&(this.collection=t.collection),t.parse&&(r=this.parse(r,t)||{}),r=n.defaults({},r,n.result(this,"defaults")),this.set(r,t),this.changed={},this.initialize.apply(this,arguments)};n.extend(p.prototype,a,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(){return n.clone(this.attributes)},sync:function(){return t.sync.apply(this,arguments)},get:function(e){return this.attributes[e]},escape:function(e){return n.escape(this.get(e))},has:function(e){return null!=this.get(e)},set:function(e,t,r){var i,o,s,a,u,l,c,d;if(null==e)return this;if("object"==typeof e?(o=e,r=t):(o={})[e]=t,r||(r={}),!this._validate(o,r))return!1;s=r.unset,u=r.silent,a=[],l=this._changing,this._changing=!0,l||(this._previousAttributes=n.clone(this.attributes),this.changed={}),d=this.attributes,c=this._previousAttributes,this.idAttribute in o&&(this.id=o[this.idAttribute]);for(i in o)t=o[i],n.isEqual(d[i],t)||a.push(i),n.isEqual(c[i],t)?delete this.changed[i]:this.changed[i]=t,s?delete d[i]:d[i]=t;if(!u){a.length&&(this._pending=r);for(var p=0,f=a.length;f>p;p++)this.trigger("change:"+a[p],this,d[a[p]],r)}if(l)return this;if(!u)for(;this._pending;)r=this._pending,this._pending=!1,this.trigger("change",this,r);return this._pending=!1,this._changing=!1,this},unset:function(e,t){return this.set(e,void 0,n.extend({},t,{unset:!0}))},clear:function(e){var t={};for(var r in this.attributes)t[r]=void 0;return this.set(t,n.extend({},e,{unset:!0}))},hasChanged:function(e){return null==e?!n.isEmpty(this.changed):n.has(this.changed,e)},changedAttributes:function(e){if(!e)return this.hasChanged()?n.clone(this.changed):!1;var t,r=!1,i=this._changing?this._previousAttributes:this.attributes;for(var o in e)n.isEqual(i[o],t=e[o])||((r||(r={}))[o]=t);return r},previous:function(e){return null!=e&&this._previousAttributes?this._previousAttributes[e]:null},previousAttributes:function(){return n.clone(this._previousAttributes)},fetch:function(e){e=e?n.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=this,r=e.success;return e.success=function(n){return t.set(t.parse(n,e),e)?(r&&r(t,n,e),void t.trigger("sync",t,n,e)):!1},j(this,e),this.sync("read",this,e)},save:function(e,t,r){var i,o,s,a=this.attributes;if(null==e||"object"==typeof e?(i=e,r=t):(i={})[e]=t,r=n.extend({validate:!0},r),i&&!r.wait){if(!this.set(i,r))return!1}else if(!this._validate(i,r))return!1;i&&r.wait&&(this.attributes=n.extend({},a,i)),void 0===r.parse&&(r.parse=!0);var u=this,l=r.success;return r.success=function(e){u.attributes=a;var t=u.parse(e,r);return r.wait&&(t=n.extend(i||{},t)),n.isObject(t)&&!u.set(t,r)?!1:(l&&l(u,e,r),void u.trigger("sync",u,e,r))},j(this,r),o=this.isNew()?"create":r.patch?"patch":"update","patch"===o&&(r.attrs=i),s=this.sync(o,this,r),i&&r.wait&&(this.attributes=a),s},destroy:function(e){e=e?n.clone(e):{};var t=this,r=e.success,i=function(){t.trigger("destroy",t,t.collection,e)};if(e.success=function(n){(e.wait||t.isNew())&&i(),r&&r(t,n,e),t.isNew()||t.trigger("sync",t,n,e)},this.isNew())return e.success(),!1;j(this,e);var o=this.sync("delete",this,e);return e.wait||i(),o},url:function(){var e=n.result(this,"urlRoot")||n.result(this.collection,"url")||I();return this.isNew()?e:e.replace(/([^\/])$/,"$1/")+encodeURIComponent(this.id)},parse:function(e){return e},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(e){return this._validate({},n.extend(e||{},{validate:!0}))},_validate:function(e,t){if(!t.validate||!this.validate)return!0;e=n.extend({},this.attributes,e);var r=this.validationError=this.validate(e,t)||null;return r?(this.trigger("invalid",this,r,n.extend(t,{validationError:r})),!1):!0}});var f=["keys","values","pairs","invert","pick","omit"];n.each(f,function(e){p.prototype[e]=function(){var t=s.call(arguments);return t.unshift(this.attributes),n[e].apply(n,t)}});var h=t.Collection=function(e,t){t||(t={}),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,n.extend({silent:!0},t))},v={add:!0,remove:!0,merge:!0},m={add:!0,remove:!1};n.extend(h.prototype,a,{model:p,initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},sync:function(){return t.sync.apply(this,arguments)},add:function(e,t){return this.set(e,n.extend({merge:!1},t,m))},remove:function(e,t){var r=!n.isArray(e);e=r?[e]:n.clone(e),t||(t={});var i,o,s,a;for(i=0,o=e.length;o>i;i++)a=e[i]=this.get(e[i]),a&&(delete this._byId[a.id],delete this._byId[a.cid],s=this.indexOf(a),this.models.splice(s,1),this.length--,t.silent||(t.index=s,a.trigger("remove",a,this,t)),this._removeReference(a,t));return r?e[0]:e},set:function(e,t){t=n.defaults({},t,v),t.parse&&(e=this.parse(e,t));var r=!n.isArray(e);e=r?e?[e]:[]:n.clone(e);var i,o,s,a,u,l,c,d=t.at,f=this.model,h=this.comparator&&null==d&&t.sort!==!1,m=n.isString(this.comparator)?this.comparator:null,b=[],g=[],y={},_=t.add,w=t.merge,x=t.remove,k=!h&&_&&x?[]:!1;for(i=0,o=e.length;o>i;i++){if(u=e[i]||{},s=u instanceof p?a=u:u[f.prototype.idAttribute||"id"],l=this.get(s))x&&(y[l.cid]=!0),w&&(u=u===a?a.attributes:u,t.parse&&(u=l.parse(u,t)),l.set(u,t),h&&!c&&l.hasChanged(m)&&(c=!0)),e[i]=l;else if(_){if(a=e[i]=this._prepareModel(u,t),!a)continue;b.push(a),this._addReference(a,t)}a=l||a,!k||!a.isNew()&&y[a.id]||k.push(a),y[a.id]=!0}if(x){for(i=0,o=this.length;o>i;++i)y[(a=this.models[i]).cid]||g.push(a);g.length&&this.remove(g,t)}if(b.length||k&&k.length)if(h&&(c=!0),this.length+=b.length,null!=d)for(i=0,o=b.length;o>i;i++)this.models.splice(d+i,0,b[i]);else{k&&(this.models.length=0);var E=k||b;for(i=0,o=E.length;o>i;i++)this.models.push(E[i])}if(c&&this.sort({silent:!0}),!t.silent){for(i=0,o=b.length;o>i;i++)(a=b[i]).trigger("add",a,this,t);(c||k&&k.length)&&this.trigger("sort",this,t)}return r?e[0]:e},reset:function(e,t){t||(t={});for(var r=0,i=this.models.length;i>r;r++)this._removeReference(this.models[r],t);return t.previousModels=this.models,this._reset(),e=this.add(e,n.extend({silent:!0},t)),t.silent||this.trigger("reset",this,t),e},push:function(e,t){return this.add(e,n.extend({at:this.length},t))},pop:function(e){var t=this.at(this.length-1);return this.remove(t,e),t},unshift:function(e,t){return this.add(e,n.extend({at:0},t))},shift:function(e){var t=this.at(0);return this.remove(t,e),t},slice:function(){return s.apply(this.models,arguments)},get:function(e){return null==e?void 0:this._byId[e]||this._byId[e.id]||this._byId[e.cid]},at:function(e){return this.models[e]},where:function(e,t){return n.isEmpty(e)?t?void 0:[]:this[t?"find":"filter"](function(t){for(var n in e)if(e[n]!==t.get(n))return!1;return!0})},findWhere:function(e){return this.where(e,!0)},sort:function(e){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");return e||(e={}),n.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(n.bind(this.comparator,this)),e.silent||this.trigger("sort",this,e),this},pluck:function(e){return n.invoke(this.models,"get",e)},fetch:function(e){e=e?n.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=e.success,r=this;return e.success=function(n){var i=e.reset?"reset":"set";r[i](n,e),t&&t(r,n,e),r.trigger("sync",r,n,e)},j(this,e),this.sync("read",this,e)},create:function(e,t){if(t=t?n.clone(t):{},!(e=this._prepareModel(e,t)))return!1;t.wait||this.add(e,t);var r=this,i=t.success;return t.success=function(e,n){t.wait&&r.add(e,t),i&&i(e,n,t)},e.save(null,t),e},parse:function(e){return e},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(e instanceof p)return e;t=t?n.clone(t):{},t.collection=this;var r=new this.model(e,t);return r.validationError?(this.trigger("invalid",this,r.validationError,t),!1):r},_addReference:function(e){this._byId[e.cid]=e,null!=e.id&&(this._byId[e.id]=e),e.collection||(e.collection=this),e.on("all",this._onModelEvent,this)},_removeReference:function(e){this===e.collection&&delete e.collection,e.off("all",this._onModelEvent,this)},_onModelEvent:function(e,t,n,r){("add"!==e&&"remove"!==e||n===this)&&("destroy"===e&&this.remove(t,r),t&&e==="change:"+t.idAttribute&&(delete this._byId[t.previous(t.idAttribute)],null!=t.id&&(this._byId[t.id]=t)),this.trigger.apply(this,arguments))}});var b=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain","sample"];n.each(b,function(e){h.prototype[e]=function(){var t=s.call(arguments);return t.unshift(this.models),n[e].apply(n,t)}});var g=["groupBy","countBy","sortBy","indexBy"];n.each(g,function(e){h.prototype[e]=function(t,r){var i=n.isFunction(t)?t:function(e){return e.get(t)};return n[e](this.models,i,r)}});var y=t.View=function(e){this.cid=n.uniqueId("view"),e||(e={}),n.extend(this,n.pick(e,w)),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},_=/^(\S+)\s*(.*)$/,w=["model","collection","el","id","attributes","className","tagName","events"];n.extend(y.prototype,a,{tagName:"div",$:function(e){return this.$el.find(e)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this.stopListening(),this},setElement:function(e,n){return this.$el&&this.undelegateEvents(),this.$el=e instanceof t.$?e:t.$(e),this.el=this.$el[0],n!==!1&&this.delegateEvents(),this},delegateEvents:function(e){if(!e&&!(e=n.result(this,"events")))return this;this.undelegateEvents();for(var t in e){var r=e[t];if(n.isFunction(r)||(r=this[e[t]]),r){var i=t.match(_),o=i[1],s=i[2];r=n.bind(r,this),o+=".delegateEvents"+this.cid,""===s?this.$el.on(o,r):this.$el.on(o,s,r)}}return this},undelegateEvents:function(){return this.$el.off(".delegateEvents"+this.cid),this},_ensureElement:function(){if(this.el)this.setElement(n.result(this,"el"),!1);else{var e=n.extend({},n.result(this,"attributes"));this.id&&(e.id=n.result(this,"id")),this.className&&(e["class"]=n.result(this,"className"));var r=t.$("<"+n.result(this,"tagName")+">").attr(e);this.setElement(r,!1)}}}),t.sync=function(e,r,i){var o=k[e];n.defaults(i||(i={}),{emulateHTTP:t.emulateHTTP,emulateJSON:t.emulateJSON});var s={type:o,dataType:"json"};if(i.url||(s.url=n.result(r,"url")||I()),null!=i.data||!r||"create"!==e&&"update"!==e&&"patch"!==e||(s.contentType="application/json",s.data=JSON.stringify(i.attrs||r.toJSON(i))),i.emulateJSON&&(s.contentType="application/x-www-form-urlencoded",s.data=s.data?{model:s.data}:{}),i.emulateHTTP&&("PUT"===o||"DELETE"===o||"PATCH"===o)){s.type="POST",i.emulateJSON&&(s.data._method=o);var a=i.beforeSend;i.beforeSend=function(e){return e.setRequestHeader("X-HTTP-Method-Override",o),a?a.apply(this,arguments):void 0}}"GET"===s.type||i.emulateJSON||(s.processData=!1),"PATCH"===s.type&&x&&(s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var u=i.xhr=t.ajax(n.extend(s,i));return r.trigger("request",r,u,i),u};var x=!("undefined"==typeof window||!window.ActiveXObject||window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent),k={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};
t.ajax=function(){return t.$.ajax.apply(t.$,arguments)};var E=t.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},O=/\((.*?)\)/g,C=/(\(\?)?:\w+/g,S=/\*\w+/g,T=/[\-{}\[\]+?.,\\\^$|#\s]/g;n.extend(E.prototype,a,{initialize:function(){},route:function(e,r,i){n.isRegExp(e)||(e=this._routeToRegExp(e)),n.isFunction(r)&&(i=r,r=""),i||(i=this[r]);var o=this;return t.history.route(e,function(n){var s=o._extractParameters(e,n);o.execute(i,s),o.trigger.apply(o,["route:"+r].concat(s)),o.trigger("route",r,s),t.history.trigger("route",o,r,s)}),this},execute:function(e,t){e&&e.apply(this,t)},navigate:function(e,n){return t.history.navigate(e,n),this},_bindRoutes:function(){if(this.routes){this.routes=n.result(this,"routes");for(var e,t=n.keys(this.routes);null!=(e=t.pop());)this.route(e,this.routes[e])}},_routeToRegExp:function(e){return e=e.replace(T,"\\$&").replace(O,"(?:$1)?").replace(C,function(e,t){return t?e:"([^/?]+)"}).replace(S,"([^?]*?)"),new RegExp("^"+e+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(e,t){var r=e.exec(t).slice(1);return n.map(r,function(e,t){return t===r.length-1?e||null:e?decodeURIComponent(e):null})}});var N=t.History=function(){this.handlers=[],n.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},D=/^[#\/]|\s+$/g,M=/^\/+|\/+$/g,A=/msie [\w.]+/,R=/\/$/,P=/#.*$/;N.started=!1,n.extend(N.prototype,a,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getFragment:function(e,t){if(null==e)if(this._hasPushState||!this._wantsHashChange||t){e=decodeURI(this.location.pathname+this.location.search);var n=this.root.replace(R,"");e.indexOf(n)||(e=e.slice(n.length))}else e=this.getHash();return e.replace(D,"")},start:function(e){if(N.started)throw new Error("Backbone.history has already been started");N.started=!0,this.options=n.extend({root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment(),i=document.documentMode,o=A.exec(navigator.userAgent.toLowerCase())&&(!i||7>=i);if(this.root=("/"+this.root+"/").replace(M,"/"),o&&this._wantsHashChange){var s=t.$('<iframe src="javascript:0" tabindex="-1">');this.iframe=s.hide().appendTo("body")[0].contentWindow,this.navigate(r)}this._hasPushState?t.$(window).on("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!o?t.$(window).on("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.fragment=r;var a=this.location;if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot())return this.fragment=this.getFragment(null,!0),this.location.replace(this.root+"#"+this.fragment),!0;this._hasPushState&&this.atRoot()&&a.hash&&(this.fragment=this.getHash().replace(D,""),this.history.replaceState({},document.title,this.root+this.fragment))}return this.options.silent?void 0:this.loadUrl()},stop:function(){t.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),N.started=!1},route:function(e,t){this.handlers.unshift({route:e,callback:t})},checkUrl:function(){var e=this.getFragment();return e===this.fragment&&this.iframe&&(e=this.getFragment(this.getHash(this.iframe))),e===this.fragment?!1:(this.iframe&&this.navigate(e),void this.loadUrl())},loadUrl:function(e){return e=this.fragment=this.getFragment(e),n.any(this.handlers,function(t){return t.route.test(e)?(t.callback(e),!0):void 0})},navigate:function(e,t){if(!N.started)return!1;t&&t!==!0||(t={trigger:!!t});var n=this.root+(e=this.getFragment(e||""));if(e=e.replace(P,""),this.fragment!==e){if(this.fragment=e,""===e&&"/"!==n&&(n=n.slice(0,-1)),this._hasPushState)this.history[t.replace?"replaceState":"pushState"]({},document.title,n);else{if(!this._wantsHashChange)return this.location.assign(n);this._updateHash(this.location,e,t.replace),this.iframe&&e!==this.getFragment(this.getHash(this.iframe))&&(t.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,e,t.replace))}return t.trigger?this.loadUrl(e):void 0}},_updateHash:function(e,t,n){if(n){var r=e.href.replace(/(javascript:|#).*$/,"");e.replace(r+"#"+t)}else e.hash="#"+t}}),t.history=new N;var F=function(e,t){var r,i=this;r=e&&n.has(e,"constructor")?e.constructor:function(){return i.apply(this,arguments)},n.extend(r,i,t);var o=function(){this.constructor=r};return o.prototype=i.prototype,r.prototype=new o,e&&n.extend(r.prototype,e),r.__super__=i.prototype,r};p.extend=h.extend=E.extend=y.extend=N.extend=F;var I=function(){throw new Error('A "url" property or function must be specified')},j=function(e,t){var n=t.error;t.error=function(r){n&&n(e,r,t),e.trigger("error",e,r,t)}};return t})},function(e,t){var n,r;(function(){var i=this,o=i._,s=Array.prototype,a=Object.prototype,u=Function.prototype,l=s.push,c=s.slice,d=s.concat,p=a.toString,f=a.hasOwnProperty,h=Array.isArray,v=Object.keys,m=u.bind,b=function(e){return e instanceof b?e:this instanceof b?void(this._wrapped=e):new b(e)};"undefined"!=typeof e&&e.exports&&(t=e.exports=b),t._=b,b.VERSION="1.7.0";var g=function(e,t,n){if(void 0===t)return e;switch(null==n?3:n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)};case 4:return function(n,r,i,o){return e.call(t,n,r,i,o)}}return function(){return e.apply(t,arguments)}};b.iteratee=function(e,t,n){return null==e?b.identity:b.isFunction(e)?g(e,t,n):b.isObject(e)?b.matches(e):b.property(e)},b.each=b.forEach=function(e,t,n){if(null==e)return e;t=g(t,n);var r,i=e.length;if(i===+i)for(r=0;i>r;r++)t(e[r],r,e);else{var o=b.keys(e);for(r=0,i=o.length;i>r;r++)t(e[o[r]],o[r],e)}return e},b.map=b.collect=function(e,t,n){if(null==e)return[];t=b.iteratee(t,n);for(var r,i=e.length!==+e.length&&b.keys(e),o=(i||e).length,s=Array(o),a=0;o>a;a++)r=i?i[a]:a,s[a]=t(e[r],r,e);return s};var y="Reduce of empty array with no initial value";b.reduce=b.foldl=b.inject=function(e,t,n,r){null==e&&(e=[]),t=g(t,r,4);var i,o=e.length!==+e.length&&b.keys(e),s=(o||e).length,a=0;if(arguments.length<3){if(!s)throw new TypeError(y);n=e[o?o[a++]:a++]}for(;s>a;a++)i=o?o[a]:a,n=t(n,e[i],i,e);return n},b.reduceRight=b.foldr=function(e,t,n,r){null==e&&(e=[]),t=g(t,r,4);var i,o=e.length!==+e.length&&b.keys(e),s=(o||e).length;if(arguments.length<3){if(!s)throw new TypeError(y);n=e[o?o[--s]:--s]}for(;s--;)i=o?o[s]:s,n=t(n,e[i],i,e);return n},b.find=b.detect=function(e,t,n){var r;return t=b.iteratee(t,n),b.some(e,function(e,n,i){return t(e,n,i)?(r=e,!0):void 0}),r},b.filter=b.select=function(e,t,n){var r=[];return null==e?r:(t=b.iteratee(t,n),b.each(e,function(e,n,i){t(e,n,i)&&r.push(e)}),r)},b.reject=function(e,t,n){return b.filter(e,b.negate(b.iteratee(t)),n)},b.every=b.all=function(e,t,n){if(null==e)return!0;t=b.iteratee(t,n);var r,i,o=e.length!==+e.length&&b.keys(e),s=(o||e).length;for(r=0;s>r;r++)if(i=o?o[r]:r,!t(e[i],i,e))return!1;return!0},b.some=b.any=function(e,t,n){if(null==e)return!1;t=b.iteratee(t,n);var r,i,o=e.length!==+e.length&&b.keys(e),s=(o||e).length;for(r=0;s>r;r++)if(i=o?o[r]:r,t(e[i],i,e))return!0;return!1},b.contains=b.include=function(e,t){return null==e?!1:(e.length!==+e.length&&(e=b.values(e)),b.indexOf(e,t)>=0)},b.invoke=function(e,t){var n=c.call(arguments,2),r=b.isFunction(t);return b.map(e,function(e){return(r?t:e[t]).apply(e,n)})},b.pluck=function(e,t){return b.map(e,b.property(t))},b.where=function(e,t){return b.filter(e,b.matches(t))},b.findWhere=function(e,t){return b.find(e,b.matches(t))},b.max=function(e,t,n){var r,i,o=-1/0,s=-1/0;if(null==t&&null!=e){e=e.length===+e.length?e:b.values(e);for(var a=0,u=e.length;u>a;a++)r=e[a],r>o&&(o=r)}else t=b.iteratee(t,n),b.each(e,function(e,n,r){i=t(e,n,r),(i>s||i===-1/0&&o===-1/0)&&(o=e,s=i)});return o},b.min=function(e,t,n){var r,i,o=1/0,s=1/0;if(null==t&&null!=e){e=e.length===+e.length?e:b.values(e);for(var a=0,u=e.length;u>a;a++)r=e[a],o>r&&(o=r)}else t=b.iteratee(t,n),b.each(e,function(e,n,r){i=t(e,n,r),(s>i||1/0===i&&1/0===o)&&(o=e,s=i)});return o},b.shuffle=function(e){for(var t,n=e&&e.length===+e.length?e:b.values(e),r=n.length,i=Array(r),o=0;r>o;o++)t=b.random(0,o),t!==o&&(i[o]=i[t]),i[t]=n[o];return i},b.sample=function(e,t,n){return null==t||n?(e.length!==+e.length&&(e=b.values(e)),e[b.random(e.length-1)]):b.shuffle(e).slice(0,Math.max(0,t))},b.sortBy=function(e,t,n){return t=b.iteratee(t,n),b.pluck(b.map(e,function(e,n,r){return{value:e,index:n,criteria:t(e,n,r)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||void 0===n)return 1;if(r>n||void 0===r)return-1}return e.index-t.index}),"value")};var _=function(e){return function(t,n,r){var i={};return n=b.iteratee(n,r),b.each(t,function(r,o){var s=n(r,o,t);e(i,r,s)}),i}};b.groupBy=_(function(e,t,n){b.has(e,n)?e[n].push(t):e[n]=[t]}),b.indexBy=_(function(e,t,n){e[n]=t}),b.countBy=_(function(e,t,n){b.has(e,n)?e[n]++:e[n]=1}),b.sortedIndex=function(e,t,n,r){n=b.iteratee(n,r,1);for(var i=n(t),o=0,s=e.length;s>o;){var a=o+s>>>1;n(e[a])<i?o=a+1:s=a}return o},b.toArray=function(e){return e?b.isArray(e)?c.call(e):e.length===+e.length?b.map(e,b.identity):b.values(e):[]},b.size=function(e){return null==e?0:e.length===+e.length?e.length:b.keys(e).length},b.partition=function(e,t,n){t=b.iteratee(t,n);var r=[],i=[];return b.each(e,function(e,n,o){(t(e,n,o)?r:i).push(e)}),[r,i]},b.first=b.head=b.take=function(e,t,n){return null==e?void 0:null==t||n?e[0]:0>t?[]:c.call(e,0,t)},b.initial=function(e,t,n){return c.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))},b.last=function(e,t,n){return null==e?void 0:null==t||n?e[e.length-1]:c.call(e,Math.max(e.length-t,0))},b.rest=b.tail=b.drop=function(e,t,n){return c.call(e,null==t||n?1:t)},b.compact=function(e){return b.filter(e,b.identity)};var w=function(e,t,n,r){if(t&&b.every(e,b.isArray))return d.apply(r,e);for(var i=0,o=e.length;o>i;i++){var s=e[i];b.isArray(s)||b.isArguments(s)?t?l.apply(r,s):w(s,t,n,r):n||r.push(s)}return r};b.flatten=function(e,t){return w(e,t,!1,[])},b.without=function(e){return b.difference(e,c.call(arguments,1))},b.uniq=b.unique=function(e,t,n,r){if(null==e)return[];b.isBoolean(t)||(r=n,n=t,t=!1),null!=n&&(n=b.iteratee(n,r));for(var i=[],o=[],s=0,a=e.length;a>s;s++){var u=e[s];if(t)s&&o===u||i.push(u),o=u;else if(n){var l=n(u,s,e);b.indexOf(o,l)<0&&(o.push(l),i.push(u))}else b.indexOf(i,u)<0&&i.push(u)}return i},b.union=function(){return b.uniq(w(arguments,!0,!0,[]))},b.intersection=function(e){if(null==e)return[];for(var t=[],n=arguments.length,r=0,i=e.length;i>r;r++){var o=e[r];if(!b.contains(t,o)){for(var s=1;n>s&&b.contains(arguments[s],o);s++);s===n&&t.push(o)}}return t},b.difference=function(e){var t=w(c.call(arguments,1),!0,!0,[]);return b.filter(e,function(e){return!b.contains(t,e)})},b.zip=function(e){if(null==e)return[];for(var t=b.max(arguments,"length").length,n=Array(t),r=0;t>r;r++)n[r]=b.pluck(arguments,r);return n},b.object=function(e,t){if(null==e)return{};for(var n={},r=0,i=e.length;i>r;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},b.indexOf=function(e,t,n){if(null==e)return-1;var r=0,i=e.length;if(n){if("number"!=typeof n)return r=b.sortedIndex(e,t),e[r]===t?r:-1;r=0>n?Math.max(0,i+n):n}for(;i>r;r++)if(e[r]===t)return r;return-1},b.lastIndexOf=function(e,t,n){if(null==e)return-1;var r=e.length;for("number"==typeof n&&(r=0>n?r+n+1:Math.min(r,n+1));--r>=0;)if(e[r]===t)return r;return-1},b.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=n||1;for(var r=Math.max(Math.ceil((t-e)/n),0),i=Array(r),o=0;r>o;o++,e+=n)i[o]=e;return i};var x=function(){};b.bind=function(e,t){var n,r;if(m&&e.bind===m)return m.apply(e,c.call(arguments,1));if(!b.isFunction(e))throw new TypeError("Bind must be called on a function");return n=c.call(arguments,2),r=function(){if(!(this instanceof r))return e.apply(t,n.concat(c.call(arguments)));x.prototype=e.prototype;var i=new x;x.prototype=null;var o=e.apply(i,n.concat(c.call(arguments)));return b.isObject(o)?o:i}},b.partial=function(e){var t=c.call(arguments,1);return function(){for(var n=0,r=t.slice(),i=0,o=r.length;o>i;i++)r[i]===b&&(r[i]=arguments[n++]);for(;n<arguments.length;)r.push(arguments[n++]);return e.apply(this,r)}},b.bindAll=function(e){var t,n,r=arguments.length;if(1>=r)throw new Error("bindAll must be passed function names");for(t=1;r>t;t++)n=arguments[t],e[n]=b.bind(e[n],e);return e},b.memoize=function(e,t){var n=function(r){var i=n.cache,o=t?t.apply(this,arguments):r;return b.has(i,o)||(i[o]=e.apply(this,arguments)),i[o]};return n.cache={},n},b.delay=function(e,t){var n=c.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},b.defer=function(e){return b.delay.apply(b,[e,1].concat(c.call(arguments,1)))},b.throttle=function(e,t,n){var r,i,o,s=null,a=0;n||(n={});var u=function(){a=n.leading===!1?0:b.now(),s=null,o=e.apply(r,i),s||(r=i=null)};return function(){var l=b.now();a||n.leading!==!1||(a=l);var c=t-(l-a);return r=this,i=arguments,0>=c||c>t?(clearTimeout(s),s=null,a=l,o=e.apply(r,i),s||(r=i=null)):s||n.trailing===!1||(s=setTimeout(u,c)),o}},b.debounce=function(e,t,n){var r,i,o,s,a,u=function(){var l=b.now()-s;t>l&&l>0?r=setTimeout(u,t-l):(r=null,n||(a=e.apply(o,i),r||(o=i=null)))};return function(){o=this,i=arguments,s=b.now();var l=n&&!r;return r||(r=setTimeout(u,t)),l&&(a=e.apply(o,i),o=i=null),a}},b.wrap=function(e,t){return b.partial(t,e)},b.negate=function(e){return function(){return!e.apply(this,arguments)}},b.compose=function(){var e=arguments,t=e.length-1;return function(){for(var n=t,r=e[t].apply(this,arguments);n--;)r=e[n].call(this,r);return r}},b.after=function(e,t){return function(){return--e<1?t.apply(this,arguments):void 0}},b.before=function(e,t){var n;return function(){return--e>0?n=t.apply(this,arguments):t=null,n}},b.once=b.partial(b.before,2),b.keys=function(e){if(!b.isObject(e))return[];if(v)return v(e);var t=[];for(var n in e)b.has(e,n)&&t.push(n);return t},b.values=function(e){for(var t=b.keys(e),n=t.length,r=Array(n),i=0;n>i;i++)r[i]=e[t[i]];return r},b.pairs=function(e){for(var t=b.keys(e),n=t.length,r=Array(n),i=0;n>i;i++)r[i]=[t[i],e[t[i]]];return r},b.invert=function(e){for(var t={},n=b.keys(e),r=0,i=n.length;i>r;r++)t[e[n[r]]]=n[r];return t},b.functions=b.methods=function(e){var t=[];for(var n in e)b.isFunction(e[n])&&t.push(n);return t.sort()},b.extend=function(e){if(!b.isObject(e))return e;for(var t,n,r=1,i=arguments.length;i>r;r++){t=arguments[r];for(n in t)f.call(t,n)&&(e[n]=t[n])}return e},b.pick=function(e,t,n){var r,i={};if(null==e)return i;if(b.isFunction(t)){t=g(t,n);for(r in e){var o=e[r];t(o,r,e)&&(i[r]=o)}}else{var s=d.apply([],c.call(arguments,1));e=new Object(e);for(var a=0,u=s.length;u>a;a++)r=s[a],r in e&&(i[r]=e[r])}return i},b.omit=function(e,t,n){if(b.isFunction(t))t=b.negate(t);else{var r=b.map(d.apply([],c.call(arguments,1)),String);t=function(e,t){return!b.contains(r,t)}}return b.pick(e,t,n)},b.defaults=function(e){if(!b.isObject(e))return e;for(var t=1,n=arguments.length;n>t;t++){var r=arguments[t];for(var i in r)void 0===e[i]&&(e[i]=r[i])}return e},b.clone=function(e){return b.isObject(e)?b.isArray(e)?e.slice():b.extend({},e):e},b.tap=function(e,t){return t(e),e};var k=function(e,t,n,r){if(e===t)return 0!==e||1/e===1/t;if(null==e||null==t)return e===t;e instanceof b&&(e=e._wrapped),t instanceof b&&(t=t._wrapped);var i=p.call(e);if(i!==p.call(t))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!==+e?+t!==+t:0===+e?1/+e===1/t:+e===+t;case"[object Date]":case"[object Boolean]":return+e===+t}if("object"!=typeof e||"object"!=typeof t)return!1;for(var o=n.length;o--;)if(n[o]===e)return r[o]===t;var s=e.constructor,a=t.constructor;if(s!==a&&"constructor"in e&&"constructor"in t&&!(b.isFunction(s)&&s instanceof s&&b.isFunction(a)&&a instanceof a))return!1;n.push(e),r.push(t);var u,l;if("[object Array]"===i){if(u=e.length,l=u===t.length)for(;u--&&(l=k(e[u],t[u],n,r)););}else{var c,d=b.keys(e);if(u=d.length,l=b.keys(t).length===u)for(;u--&&(c=d[u],l=b.has(t,c)&&k(e[c],t[c],n,r)););}return n.pop(),r.pop(),l};b.isEqual=function(e,t){return k(e,t,[],[])},b.isEmpty=function(e){if(null==e)return!0;if(b.isArray(e)||b.isString(e)||b.isArguments(e))return 0===e.length;for(var t in e)if(b.has(e,t))return!1;return!0},b.isElement=function(e){return!(!e||1!==e.nodeType)},b.isArray=h||function(e){return"[object Array]"===p.call(e)},b.isObject=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},b.each(["Arguments","Function","String","Number","Date","RegExp"],function(e){b["is"+e]=function(t){return p.call(t)==="[object "+e+"]"}}),b.isArguments(arguments)||(b.isArguments=function(e){return b.has(e,"callee")}),b.isFunction=function(e){return"function"==typeof e||!1},b.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},b.isNaN=function(e){return b.isNumber(e)&&e!==+e},b.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"===p.call(e)},b.isNull=function(e){return null===e},b.isUndefined=function(e){return void 0===e},b.has=function(e,t){return null!=e&&f.call(e,t)},b.noConflict=function(){return i._=o,this},b.identity=function(e){return e},b.constant=function(e){return function(){return e}},b.noop=function(){},b.property=function(e){return function(t){return t[e]}},b.matches=function(e){var t=b.pairs(e),n=t.length;return function(e){if(null==e)return!n;e=new Object(e);for(var r=0;n>r;r++){var i=t[r],o=i[0];if(i[1]!==e[o]||!(o in e))return!1}return!0}},b.times=function(e,t,n){var r=Array(Math.max(0,e));t=g(t,n,1);for(var i=0;e>i;i++)r[i]=t(i);return r},b.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},b.now=Date.now||function(){return(new Date).getTime()};var E={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},O=b.invert(E),C=function(e){var t=function(t){return e[t]},n="(?:"+b.keys(e).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(e){return e=null==e?"":""+e,r.test(e)?e.replace(i,t):e}};b.escape=C(E),b.unescape=C(O),b.result=function(e,t){if(null==e)return void 0;var n=e[t];return b.isFunction(n)?e[t]():n};var S=0;b.uniqueId=function(e){var t=++S+"";return e?e+t:t},b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,N={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,M=function(e){return"\\"+N[e]};b.template=function(e,t,n){!t&&n&&(t=n),t=b.defaults({},t,b.templateSettings);var r=RegExp([(t.escape||T).source,(t.interpolate||T).source,(t.evaluate||T).source].join("|")+"|$","g"),i=0,o="__p+='";e.replace(r,function(t,n,r,s,a){return o+=e.slice(i,a).replace(D,M),i=a+t.length,n?o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?o+="'+\n((__t=("+r+"))==null?'':__t)+\n'":s&&(o+="';\n"+s+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var s=new Function(t.variable||"obj","_",o)}catch(a){throw a.source=o,a}var u=function(e){return s.call(this,e,b)},l=t.variable||"obj";return u.source="function("+l+"){\n"+o+"}",u},b.chain=function(e){var t=b(e);return t._chain=!0,t};var A=function(e){return this._chain?b(e).chain():e};b.mixin=function(e){b.each(b.functions(e),function(t){var n=b[t]=e[t];b.prototype[t]=function(){var e=[this._wrapped];return l.apply(e,arguments),A.call(this,n.apply(b,e))}})},b.mixin(b),b.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=s[e];b.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],A.call(this,n)}}),b.each(["concat","join","slice"],function(e){var t=s[e];b.prototype[e]=function(){return A.call(this,t.apply(this._wrapped,arguments))}}),b.prototype.value=function(){return this._wrapped},n=[],r=function(){return b}.apply(t,n),!(void 0!==r&&(e.exports=r))}).call(this)},function(e,t,n){var r=n;!function(){var n=!0;!function(i){var o=this||(0,eval)("this"),s=o.document,a=o.navigator,u=o.jQuery,l=o.JSON;!function(n){if("function"==typeof r&&"object"==typeof t&&"object"==typeof e){var i=e.exports||t;n(i,r)}else"function"==typeof define&&define.amd?define(["exports","require"],n):n(o.ko={})}(function(e,t){function r(e,t){var n=null===e||typeof e in m;return n?e===t:!1}function c(e,t){var n;return function(){n||(n=setTimeout(function(){n=i,e()},t))}}function d(e,t){var n;return function(){clearTimeout(n),n=setTimeout(e,t)}}function p(e){var t=this;return e&&v.utils.objectForEach(e,function(e,n){var r=v.extenders[e];"function"==typeof r&&(t=r(t,n)||t)}),t}function f(e){v.bindingHandlers[e]={init:function(t,n,r,i,o){var s=function(){var t={};return t[e]=n(),t};return v.bindingHandlers.event.init.call(this,t,s,r,i,o)}}}function h(e,t,n,r){v.bindingHandlers[e]={init:function(e,i,o,s,a){var u,l;return v.computed(function(){var o=v.utils.unwrapObservable(i()),s=!n!=!o,c=!l,d=c||t||s!==u;d&&(c&&v.computedContext.getDependenciesCount()&&(l=v.utils.cloneNodes(v.virtualElements.childNodes(e),!0)),s?(c||v.virtualElements.setDomNodeChildren(e,v.utils.cloneNodes(l)),v.applyBindingsToDescendants(r?r(a,o):a,e)):v.virtualElements.emptyNode(e),u=s)},null,{disposeWhenNodeIsRemoved:e}),{controlsDescendantBindings:!0}}},v.expressionRewriting.bindingRewriteValidators[e]=!1,v.virtualElements.allowedBindings[e]=!0}var v="undefined"!=typeof e?e:{};v.exportSymbol=function(e,t){for(var n=e.split("."),r=v,i=0;i<n.length-1;i++)r=r[n[i]];r[n[n.length-1]]=t},v.exportProperty=function(e,t,n){e[t]=n},v.version="3.2.0",v.exportSymbol("version",v.version),v.utils=function(){function e(e,t){for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])}function t(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function n(e,t){return e.__proto__=t,e}function r(e,t){if("input"!==v.utils.tagNameLower(e)||!e.type)return!1;if("click"!=t.toLowerCase())return!1;var n=e.type;return"checkbox"==n||"radio"==n}var c={__proto__:[]}instanceof Array,d={},p={},f=a&&/Firefox\/2/i.test(a.userAgent)?"KeyboardEvent":"UIEvents";d[f]=["keyup","keydown","keypress"],d.MouseEvents=["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave"],e(d,function(e,t){if(t.length)for(var n=0,r=t.length;r>n;n++)p[t[n]]=e});var h={propertychange:!0},m=s&&function(){for(var e=3,t=s.createElement("div"),n=t.getElementsByTagName("i");t.innerHTML="<!--[if gt IE "+ ++e+"]><i></i><![endif]-->",n[0];);return e>4?e:i}(),b=6===m,g=7===m;return{fieldsIncludedWithJsonPost:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],arrayForEach:function(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)},arrayIndexOf:function(e,t){if("function"==typeof Array.prototype.indexOf)return Array.prototype.indexOf.call(e,t);for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1},arrayFirst:function(e,t,n){for(var r=0,i=e.length;i>r;r++)if(t.call(n,e[r],r))return e[r];return null},arrayRemoveItem:function(e,t){var n=v.utils.arrayIndexOf(e,t);n>0?e.splice(n,1):0===n&&e.shift()},arrayGetDistinctValues:function(e){e=e||[];for(var t=[],n=0,r=e.length;r>n;n++)v.utils.arrayIndexOf(t,e[n])<0&&t.push(e[n]);return t},arrayMap:function(e,t){e=e||[];for(var n=[],r=0,i=e.length;i>r;r++)n.push(t(e[r],r));return n},arrayFilter:function(e,t){e=e||[];for(var n=[],r=0,i=e.length;i>r;r++)t(e[r],r)&&n.push(e[r]);return n},arrayPushAll:function(e,t){if(t instanceof Array)e.push.apply(e,t);else for(var n=0,r=t.length;r>n;n++)e.push(t[n]);return e},addOrRemoveItem:function(e,t,n){var r=v.utils.arrayIndexOf(v.utils.peekObservable(e),t);0>r?n&&e.push(t):n||e.splice(r,1)},canSetPrototype:c,extend:t,setPrototypeOf:n,setPrototypeOfOrExtend:c?n:t,objectForEach:e,objectMap:function(e,t){if(!e)return e;var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r],r,e));return n},emptyDomNode:function(e){for(;e.firstChild;)v.removeNode(e.firstChild)},moveCleanedNodesToContainerElement:function(e){for(var t=v.utils.makeArray(e),n=s.createElement("div"),r=0,i=t.length;i>r;r++)n.appendChild(v.cleanNode(t[r]));return n},cloneNodes:function(e,t){for(var n=0,r=e.length,i=[];r>n;n++){var o=e[n].cloneNode(!0);i.push(t?v.cleanNode(o):o)}return i},setDomNodeChildren:function(e,t){if(v.utils.emptyDomNode(e),t)for(var n=0,r=t.length;r>n;n++)e.appendChild(t[n])},replaceDomNodes:function(e,t){var n=e.nodeType?[e]:e;if(n.length>0){for(var r=n[0],i=r.parentNode,o=0,s=t.length;s>o;o++)i.insertBefore(t[o],r);for(var o=0,s=n.length;s>o;o++)v.removeNode(n[o])}},fixUpContinuousNodeArray:function(e,t){if(e.length){for(t=8===t.nodeType&&t.parentNode||t;e.length&&e[0].parentNode!==t;)e.shift();if(e.length>1){var n=e[0],r=e[e.length-1];for(e.length=0;n!==r;)if(e.push(n),n=n.nextSibling,!n)return;e.push(r)}}return e},setOptionNodeSelectionState:function(e,t){7>m?e.setAttribute("selected",t):e.selected=t},stringTrim:function(e){return null===e||e===i?"":e.trim?e.trim():e.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},stringStartsWith:function(e,t){return e=e||"",t.length>e.length?!1:e.substring(0,t.length)===t},domNodeIsContainedBy:function(e,t){if(e===t)return!0;if(11===e.nodeType)return!1;if(t.contains)return t.contains(3===e.nodeType?e.parentNode:e);if(t.compareDocumentPosition)return 16==(16&t.compareDocumentPosition(e));for(;e&&e!=t;)e=e.parentNode;return!!e},domNodeIsAttachedToDocument:function(e){return v.utils.domNodeIsContainedBy(e,e.ownerDocument.documentElement)},anyDomNodeIsAttachedToDocument:function(e){return!!v.utils.arrayFirst(e,v.utils.domNodeIsAttachedToDocument)},tagNameLower:function(e){return e&&e.tagName&&e.tagName.toLowerCase()},registerEventHandler:function(e,t,n){var r=m&&h[t];if(!r&&u)u(e).bind(t,n);else if(r||"function"!=typeof e.addEventListener){if("undefined"==typeof e.attachEvent)throw new Error("Browser doesn't support addEventListener or attachEvent");var i=function(t){n.call(e,t)},o="on"+t;e.attachEvent(o,i),v.utils.domNodeDisposal.addDisposeCallback(e,function(){e.detachEvent(o,i)})}else e.addEventListener(t,n,!1)},triggerEvent:function(e,t){if(!e||!e.nodeType)throw new Error("element must be a DOM node when calling triggerEvent");var n=r(e,t);if(u&&!n)u(e).trigger(t);else if("function"==typeof s.createEvent){if("function"!=typeof e.dispatchEvent)throw new Error("The supplied element doesn't support dispatchEvent");var i=p[t]||"HTMLEvents",a=s.createEvent(i);a.initEvent(t,!0,!0,o,0,0,0,0,0,!1,!1,!1,!1,0,e),e.dispatchEvent(a)}else if(n&&e.click)e.click();else{if("undefined"==typeof e.fireEvent)throw new Error("Browser doesn't support triggering events");e.fireEvent("on"+t)}},unwrapObservable:function(e){return v.isObservable(e)?e():e},peekObservable:function(e){return v.isObservable(e)?e.peek():e},toggleDomNodeCssClass:function(e,t,n){if(t){var r=/\S+/g,i=e.className.match(r)||[];v.utils.arrayForEach(t.match(r),function(e){v.utils.addOrRemoveItem(i,e,n)}),e.className=i.join(" ")}},setTextContent:function(e,t){var n=v.utils.unwrapObservable(t);(null===n||n===i)&&(n="");var r=v.virtualElements.firstChild(e);!r||3!=r.nodeType||v.virtualElements.nextSibling(r)?v.virtualElements.setDomNodeChildren(e,[e.ownerDocument.createTextNode(n)]):r.data=n,v.utils.forceRefresh(e)},setElementName:function(e,t){if(e.name=t,7>=m)try{e.mergeAttributes(s.createElement("<input name='"+e.name+"'/>"),!1)}catch(n){}},forceRefresh:function(e){if(m>=9){var t=1==e.nodeType?e:e.parentNode;t.style&&(t.style.zoom=t.style.zoom)}},ensureSelectElementIsRenderedCorrectly:function(e){if(m){var t=e.style.width;e.style.width=0,e.style.width=t}},range:function(e,t){e=v.utils.unwrapObservable(e),t=v.utils.unwrapObservable(t);for(var n=[],r=e;t>=r;r++)n.push(r);return n},makeArray:function(e){for(var t=[],n=0,r=e.length;r>n;n++)t.push(e[n]);return t},isIe6:b,isIe7:g,ieVersion:m,getFormFields:function(e,t){for(var n=v.utils.makeArray(e.getElementsByTagName("input")).concat(v.utils.makeArray(e.getElementsByTagName("textarea"))),r="string"==typeof t?function(e){return e.name===t}:function(e){return t.test(e.name)},i=[],o=n.length-1;o>=0;o--)r(n[o])&&i.push(n[o]);return i},parseJson:function(e){return"string"==typeof e&&(e=v.utils.stringTrim(e))?l&&l.parse?l.parse(e):new Function("return "+e)():null},stringifyJson:function(e,t,n){if(!l||!l.stringify)throw new Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js");return l.stringify(v.utils.unwrapObservable(e),t,n)},postJson:function(t,n,r){r=r||{};var i=r.params||{},o=r.includeFields||this.fieldsIncludedWithJsonPost,a=t;if("object"==typeof t&&"form"===v.utils.tagNameLower(t)){var u=t;a=u.action;for(var l=o.length-1;l>=0;l--)for(var c=v.utils.getFormFields(u,o[l]),d=c.length-1;d>=0;d--)i[c[d].name]=c[d].value}n=v.utils.unwrapObservable(n);var p=s.createElement("form");p.style.display="none",p.action=a,p.method="post";for(var f in n){var h=s.createElement("input");h.type="hidden",h.name=f,h.value=v.utils.stringifyJson(v.utils.unwrapObservable(n[f])),p.appendChild(h)}e(i,function(e,t){var n=s.createElement("input");n.type="hidden",n.name=e,n.value=t,p.appendChild(n)}),s.body.appendChild(p),r.submitter?r.submitter(p):p.submit(),setTimeout(function(){p.parentNode.removeChild(p)},0)}}}(),v.exportSymbol("utils",v.utils),v.exportSymbol("utils.arrayForEach",v.utils.arrayForEach),v.exportSymbol("utils.arrayFirst",v.utils.arrayFirst),v.exportSymbol("utils.arrayFilter",v.utils.arrayFilter),v.exportSymbol("utils.arrayGetDistinctValues",v.utils.arrayGetDistinctValues),v.exportSymbol("utils.arrayIndexOf",v.utils.arrayIndexOf),v.exportSymbol("utils.arrayMap",v.utils.arrayMap),v.exportSymbol("utils.arrayPushAll",v.utils.arrayPushAll),v.exportSymbol("utils.arrayRemoveItem",v.utils.arrayRemoveItem),v.exportSymbol("utils.extend",v.utils.extend),v.exportSymbol("utils.fieldsIncludedWithJsonPost",v.utils.fieldsIncludedWithJsonPost),v.exportSymbol("utils.getFormFields",v.utils.getFormFields),v.exportSymbol("utils.peekObservable",v.utils.peekObservable),v.exportSymbol("utils.postJson",v.utils.postJson),v.exportSymbol("utils.parseJson",v.utils.parseJson),v.exportSymbol("utils.registerEventHandler",v.utils.registerEventHandler),v.exportSymbol("utils.stringifyJson",v.utils.stringifyJson),v.exportSymbol("utils.range",v.utils.range),v.exportSymbol("utils.toggleDomNodeCssClass",v.utils.toggleDomNodeCssClass),v.exportSymbol("utils.triggerEvent",v.utils.triggerEvent),v.exportSymbol("utils.unwrapObservable",v.utils.unwrapObservable),v.exportSymbol("utils.objectForEach",v.utils.objectForEach),v.exportSymbol("utils.addOrRemoveItem",v.utils.addOrRemoveItem),v.exportSymbol("unwrap",v.utils.unwrapObservable),Function.prototype.bind||(Function.prototype.bind=function(e){var t=this,n=Array.prototype.slice.call(arguments),e=n.shift();return function(){return t.apply(e,n.concat(Array.prototype.slice.call(arguments)))}}),v.utils.domData=new function(){function e(e,o){var s=e[n],a=s&&"null"!==s&&r[s];if(!a){if(!o)return i;s=e[n]="ko"+t++,r[s]={}}return r[s]}var t=0,n="__ko__"+(new Date).getTime(),r={};return{get:function(t,n){var r=e(t,!1);return r===i?i:r[n]},set:function(t,n,r){if(r!==i||e(t,!1)!==i){var o=e(t,!0);o[n]=r}},clear:function(e){var t=e[n];return t?(delete r[t],e[n]=null,!0):!1},nextKey:function(){return t++ +n}}},v.exportSymbol("utils.domData",v.utils.domData),v.exportSymbol("utils.domData.clear",v.utils.domData.clear),v.utils.domNodeDisposal=new function(){function e(e,t){var n=v.utils.domData.get(e,o);return n===i&&t&&(n=[],v.utils.domData.set(e,o,n)),n
}function t(e){v.utils.domData.set(e,o,i)}function n(t){var n=e(t,!1);if(n){n=n.slice(0);for(var i=0;i<n.length;i++)n[i](t)}v.utils.domData.clear(t),v.utils.domNodeDisposal.cleanExternalData(t),a[t.nodeType]&&r(t)}function r(e){for(var t,r=e.firstChild;t=r;)r=t.nextSibling,8===t.nodeType&&n(t)}var o=v.utils.domData.nextKey(),s={1:!0,8:!0,9:!0},a={1:!0,9:!0};return{addDisposeCallback:function(t,n){if("function"!=typeof n)throw new Error("Callback must be a function");e(t,!0).push(n)},removeDisposeCallback:function(n,r){var i=e(n,!1);i&&(v.utils.arrayRemoveItem(i,r),0==i.length&&t(n))},cleanNode:function(e){if(s[e.nodeType]&&(n(e),a[e.nodeType])){var t=[];v.utils.arrayPushAll(t,e.getElementsByTagName("*"));for(var r=0,i=t.length;i>r;r++)n(t[r])}return e},removeNode:function(e){v.cleanNode(e),e.parentNode&&e.parentNode.removeChild(e)},cleanExternalData:function(e){u&&"function"==typeof u.cleanData&&u.cleanData([e])}}},v.cleanNode=v.utils.domNodeDisposal.cleanNode,v.removeNode=v.utils.domNodeDisposal.removeNode,v.exportSymbol("cleanNode",v.cleanNode),v.exportSymbol("removeNode",v.removeNode),v.exportSymbol("utils.domNodeDisposal",v.utils.domNodeDisposal),v.exportSymbol("utils.domNodeDisposal.addDisposeCallback",v.utils.domNodeDisposal.addDisposeCallback),v.exportSymbol("utils.domNodeDisposal.removeDisposeCallback",v.utils.domNodeDisposal.removeDisposeCallback),function(){function e(e){var t=v.utils.stringTrim(e).toLowerCase(),n=s.createElement("div"),r=t.match(/^<(thead|tbody|tfoot)/)&&[1,"<table>","</table>"]||!t.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!t.indexOf("<td")||!t.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||[0,"",""],i="ignored<div>"+r[1]+e+r[2]+"</div>";for("function"==typeof o.innerShiv?n.appendChild(o.innerShiv(i)):n.innerHTML=i;r[0]--;)n=n.lastChild;return v.utils.makeArray(n.lastChild.childNodes)}function t(e){if(u.parseHTML)return u.parseHTML(e)||[];var t=u.clean([e]);if(t&&t[0]){for(var n=t[0];n.parentNode&&11!==n.parentNode.nodeType;)n=n.parentNode;n.parentNode&&n.parentNode.removeChild(n)}return t}v.utils.parseHtmlFragment=function(n){return u?t(n):e(n)},v.utils.setHtml=function(e,t){if(v.utils.emptyDomNode(e),t=v.utils.unwrapObservable(t),null!==t&&t!==i)if("string"!=typeof t&&(t=t.toString()),u)u(e).html(t);else for(var n=v.utils.parseHtmlFragment(t),r=0;r<n.length;r++)e.appendChild(n[r])}}(),v.exportSymbol("utils.parseHtmlFragment",v.utils.parseHtmlFragment),v.exportSymbol("utils.setHtml",v.utils.setHtml),v.memoization=function(){function e(){return(4294967296*(1+Math.random())|0).toString(16).substring(1)}function t(){return e()+e()}function n(e,t){if(e)if(8==e.nodeType){var r=v.memoization.parseMemoText(e.nodeValue);null!=r&&t.push({domNode:e,memoId:r})}else if(1==e.nodeType)for(var i=0,o=e.childNodes,s=o.length;s>i;i++)n(o[i],t)}var r={};return{memoize:function(e){if("function"!=typeof e)throw new Error("You can only pass a function to ko.memoization.memoize()");var n=t();return r[n]=e,"<!--[ko_memo:"+n+"]-->"},unmemoize:function(e,t){var n=r[e];if(n===i)throw new Error("Couldn't find any memo with ID "+e+". Perhaps it's already been unmemoized.");try{return n.apply(null,t||[]),!0}finally{delete r[e]}},unmemoizeDomNodeAndDescendants:function(e,t){var r=[];n(e,r);for(var i=0,o=r.length;o>i;i++){var s=r[i].domNode,a=[s];t&&v.utils.arrayPushAll(a,t),v.memoization.unmemoize(r[i].memoId,a),s.nodeValue="",s.parentNode&&s.parentNode.removeChild(s)}},parseMemoText:function(e){var t=e.match(/^\[ko_memo\:(.*?)\]$/);return t?t[1]:null}}}(),v.exportSymbol("memoization",v.memoization),v.exportSymbol("memoization.memoize",v.memoization.memoize),v.exportSymbol("memoization.unmemoize",v.memoization.unmemoize),v.exportSymbol("memoization.parseMemoText",v.memoization.parseMemoText),v.exportSymbol("memoization.unmemoizeDomNodeAndDescendants",v.memoization.unmemoizeDomNodeAndDescendants),v.extenders={throttle:function(e,t){e.throttleEvaluation=t;var n=null;return v.dependentObservable({read:e,write:function(r){clearTimeout(n),n=setTimeout(function(){e(r)},t)}})},rateLimit:function(e,t){var n,r,i;"number"==typeof t?n=t:(n=t.timeout,r=t.method),i="notifyWhenChangesStop"==r?d:c,e.limit(function(e){return i(e,n)})},notify:function(e,t){e.equalityComparer="always"==t?null:r}};var m={undefined:1,"boolean":1,number:1,string:1};v.exportSymbol("extenders",v.extenders),v.subscription=function(e,t,n){this.target=e,this.callback=t,this.disposeCallback=n,this.isDisposed=!1,v.exportProperty(this,"dispose",this.dispose)},v.subscription.prototype.dispose=function(){this.isDisposed=!0,this.disposeCallback()},v.subscribable=function(){v.utils.setPrototypeOfOrExtend(this,v.subscribable.fn),this._subscriptions={}};var b="change",g={subscribe:function(e,t,n){var r=this;n=n||b;var i=t?e.bind(t):e,o=new v.subscription(r,i,function(){v.utils.arrayRemoveItem(r._subscriptions[n],o),r.afterSubscriptionRemove&&r.afterSubscriptionRemove(n)});return r.beforeSubscriptionAdd&&r.beforeSubscriptionAdd(n),r._subscriptions[n]||(r._subscriptions[n]=[]),r._subscriptions[n].push(o),o},notifySubscribers:function(e,t){if(t=t||b,this.hasSubscriptionsForEvent(t))try{v.dependencyDetection.begin();for(var n,r=this._subscriptions[t].slice(0),i=0;n=r[i];++i)n.isDisposed||n.callback(e)}finally{v.dependencyDetection.end()}},limit:function(e){var t,n,r,i=this,o=v.isObservable(i),s="beforeChange";i._origNotifySubscribers||(i._origNotifySubscribers=i.notifySubscribers,i.notifySubscribers=function(e,t){t&&t!==b?t===s?i._rateLimitedBeforeChange(e):i._origNotifySubscribers(e,t):i._rateLimitedChange(e)});var a=e(function(){o&&r===i&&(r=i()),t=!1,i.isDifferent(n,r)&&i._origNotifySubscribers(n=r)});i._rateLimitedChange=function(e){t=!0,r=e,a()},i._rateLimitedBeforeChange=function(e){t||(n=e,i._origNotifySubscribers(e,s))}},hasSubscriptionsForEvent:function(e){return this._subscriptions[e]&&this._subscriptions[e].length},getSubscriptionsCount:function(){var e=0;return v.utils.objectForEach(this._subscriptions,function(t,n){e+=n.length}),e},isDifferent:function(e,t){return!this.equalityComparer||!this.equalityComparer(e,t)},extend:p};v.exportProperty(g,"subscribe",g.subscribe),v.exportProperty(g,"extend",g.extend),v.exportProperty(g,"getSubscriptionsCount",g.getSubscriptionsCount),v.utils.canSetPrototype&&v.utils.setPrototypeOf(g,Function.prototype),v.subscribable.fn=g,v.isSubscribable=function(e){return null!=e&&"function"==typeof e.subscribe&&"function"==typeof e.notifySubscribers},v.exportSymbol("subscribable",v.subscribable),v.exportSymbol("isSubscribable",v.isSubscribable),v.computedContext=v.dependencyDetection=function(){function e(){return++o}function t(e){i.push(r),r=e}function n(){r=i.pop()}var r,i=[],o=0;return{begin:t,end:n,registerDependency:function(t){if(r){if(!v.isSubscribable(t))throw new Error("Only subscribable things can act as dependencies");r.callback(t,t._id||(t._id=e()))}},ignore:function(e,r,i){try{return t(),e.apply(r,i||[])}finally{n()}},getDependenciesCount:function(){return r?r.computed.getDependenciesCount():void 0},isInitial:function(){return r?r.isInitial:void 0}}}(),v.exportSymbol("computedContext",v.computedContext),v.exportSymbol("computedContext.getDependenciesCount",v.computedContext.getDependenciesCount),v.exportSymbol("computedContext.isInitial",v.computedContext.isInitial),v.exportSymbol("computedContext.isSleeping",v.computedContext.isSleeping),v.observable=function(e){function t(){return arguments.length>0?(t.isDifferent(r,arguments[0])&&(t.valueWillMutate(),r=arguments[0],n&&(t._latestValue=r),t.valueHasMutated()),this):(v.dependencyDetection.registerDependency(t),r)}var r=e;return v.subscribable.call(t),v.utils.setPrototypeOfOrExtend(t,v.observable.fn),n&&(t._latestValue=r),t.peek=function(){return r},t.valueHasMutated=function(){t.notifySubscribers(r)},t.valueWillMutate=function(){t.notifySubscribers(r,"beforeChange")},v.exportProperty(t,"peek",t.peek),v.exportProperty(t,"valueHasMutated",t.valueHasMutated),v.exportProperty(t,"valueWillMutate",t.valueWillMutate),t},v.observable.fn={equalityComparer:r};var y=v.observable.protoProperty="__ko_proto__";v.observable.fn[y]=v.observable,v.utils.canSetPrototype&&v.utils.setPrototypeOf(v.observable.fn,v.subscribable.fn),v.hasPrototype=function(e,t){return null===e||e===i||e[y]===i?!1:e[y]===t?!0:v.hasPrototype(e[y],t)},v.isObservable=function(e){return v.hasPrototype(e,v.observable)},v.isWriteableObservable=function(e){return"function"==typeof e&&e[y]===v.observable?!0:"function"==typeof e&&e[y]===v.dependentObservable&&e.hasWriteFunction?!0:!1},v.exportSymbol("observable",v.observable),v.exportSymbol("isObservable",v.isObservable),v.exportSymbol("isWriteableObservable",v.isWriteableObservable),v.exportSymbol("isWritableObservable",v.isWriteableObservable),v.observableArray=function(e){if(e=e||[],"object"!=typeof e||!("length"in e))throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");var t=v.observable(e);return v.utils.setPrototypeOfOrExtend(t,v.observableArray.fn),t.extend({trackArrayChanges:!0})},v.observableArray.fn={remove:function(e){for(var t=this.peek(),n=[],r="function"!=typeof e||v.isObservable(e)?function(t){return t===e}:e,i=0;i<t.length;i++){var o=t[i];r(o)&&(0===n.length&&this.valueWillMutate(),n.push(o),t.splice(i,1),i--)}return n.length&&this.valueHasMutated(),n},removeAll:function(e){if(e===i){var t=this.peek(),n=t.slice(0);return this.valueWillMutate(),t.splice(0,t.length),this.valueHasMutated(),n}return e?this.remove(function(t){return v.utils.arrayIndexOf(e,t)>=0}):[]},destroy:function(e){var t=this.peek(),n="function"!=typeof e||v.isObservable(e)?function(t){return t===e}:e;this.valueWillMutate();for(var r=t.length-1;r>=0;r--){var i=t[r];n(i)&&(t[r]._destroy=!0)}this.valueHasMutated()},destroyAll:function(e){return e===i?this.destroy(function(){return!0}):e?this.destroy(function(t){return v.utils.arrayIndexOf(e,t)>=0}):[]},indexOf:function(e){var t=this();return v.utils.arrayIndexOf(t,e)},replace:function(e,t){var n=this.indexOf(e);n>=0&&(this.valueWillMutate(),this.peek()[n]=t,this.valueHasMutated())}},v.utils.arrayForEach(["pop","push","reverse","shift","sort","splice","unshift"],function(e){v.observableArray.fn[e]=function(){var t=this.peek();this.valueWillMutate(),this.cacheDiffForKnownOperation(t,e,arguments);var n=t[e].apply(t,arguments);return this.valueHasMutated(),n}}),v.utils.arrayForEach(["slice"],function(e){v.observableArray.fn[e]=function(){var t=this();return t[e].apply(t,arguments)}}),v.utils.canSetPrototype&&v.utils.setPrototypeOf(v.observableArray.fn,v.observable.fn),v.exportSymbol("observableArray",v.observableArray);var _="arrayChange";v.extenders.trackArrayChanges=function(e){function t(){if(!r){r=!0;var t=e.notifySubscribers;e.notifySubscribers=function(e,n){return n&&n!==b||++o,t.apply(this,arguments)};var s=[].concat(e.peek()||[]);i=null,e.subscribe(function(t){if(t=[].concat(t||[]),e.hasSubscriptionsForEvent(_)){var r=n(s,t);r.length&&e.notifySubscribers(r,_)}s=t,i=null,o=0})}}function n(e,t){return(!i||o>1)&&(i=v.utils.compareArrays(e,t,{sparse:!0})),i}if(!e.cacheDiffForKnownOperation){var r=!1,i=null,o=0,s=e.subscribe;e.subscribe=e.subscribe=function(e,n,r){return r===_&&t(),s.apply(this,arguments)},e.cacheDiffForKnownOperation=function(e,t,n){function s(e,t,n){return a[a.length]={status:e,value:t,index:n}}if(r&&!o){var a=[],u=e.length,l=n.length,c=0;switch(t){case"push":c=u;case"unshift":for(var d=0;l>d;d++)s("added",n[d],c+d);break;case"pop":c=u-1;case"shift":u&&s("deleted",e[c],c);break;case"splice":for(var p=Math.min(Math.max(0,n[0]<0?u+n[0]:n[0]),u),f=1===l?u:Math.min(p+(n[1]||0),u),h=p+l-2,m=Math.max(f,h),b=[],g=[],d=p,y=2;m>d;++d,++y)f>d&&g.push(s("deleted",e[d],d)),h>d&&b.push(s("added",n[y],d));v.utils.findMovesInArrayComparison(g,b);break;default:return}i=a}}}},v.computed=v.dependentObservable=function(e,t,r){function o(e,t){S[t]||(S[t]=e.subscribe(u),++T)}function s(){v.utils.objectForEach(S,function(e,t){t.dispose()}),S={}}function a(){s(),T=0,g=!0,h=!1}function u(){var e=c.throttleEvaluation;e&&e>=0?(clearTimeout(N),N=setTimeout(l,e)):c._evalRateLimited?c._evalRateLimited():l()}function l(e){if(m){if(_)throw Error("A 'pure' computed must not be called recursively")}else if(!g){if(O&&O()){if(!b)return void C()}else b=!1;if(m=!0,w)try{var r={};v.dependencyDetection.begin({callback:function(e,t){r[t]||(r[t]=1,++T)},computed:c,isInitial:i}),T=0,f=y.call(t)}finally{v.dependencyDetection.end(),m=!1}else try{var s=S,a=T;v.dependencyDetection.begin({callback:function(e,t){g||(a&&s[t]?(S[t]=s[t],++T,delete s[t],--a):o(e,t))},computed:c,isInitial:_?i:!T}),S={},T=0;try{var u=t?y.call(t):y()}finally{v.dependencyDetection.end(),a&&v.utils.objectForEach(s,function(e,t){t.dispose()}),h=!1}c.isDifferent(f,u)&&(c.notifySubscribers(f,"beforeChange"),f=u,n&&(c._latestValue=f),e!==!0&&c.notifySubscribers(f))}finally{m=!1}T||C()}}function c(){if(arguments.length>0){if("function"!=typeof x)throw new Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");return x.apply(t,arguments),this}return v.dependencyDetection.registerDependency(c),h&&l(!0),f}function d(){return h&&!T&&l(!0),f}function p(){return h||T>0}var f,h=!0,m=!1,b=!1,g=!1,y=e,_=!1,w=!1;if(y&&"object"==typeof y?(r=y,y=r.read):(r=r||{},y||(y=r.read)),"function"!=typeof y)throw new Error("Pass a function that returns the value of the ko.computed");var x=r.write,k=r.disposeWhenNodeIsRemoved||r.disposeWhenNodeIsRemoved||null,E=r.disposeWhen||r.disposeWhen,O=E,C=a,S={},T=0,N=null;t||(t=r.owner),v.subscribable.call(c),v.utils.setPrototypeOfOrExtend(c,v.dependentObservable.fn),c.peek=d,c.getDependenciesCount=function(){return T},c.hasWriteFunction="function"==typeof r.write,c.dispose=function(){C()},c.isActive=p;var D=c.limit;return c.limit=function(e){D.call(c,e),c._evalRateLimited=function(){c._rateLimitedBeforeChange(f),h=!0,c._rateLimitedChange(c)}},r.pure?(_=!0,w=!0,c.beforeSubscriptionAdd=function(){w&&(w=!1,l(!0))},c.afterSubscriptionRemove=function(){c.getSubscriptionsCount()||(s(),w=h=!0)}):r.deferEvaluation&&(c.beforeSubscriptionAdd=function(){d(),delete c.beforeSubscriptionAdd}),v.exportProperty(c,"peek",c.peek),v.exportProperty(c,"dispose",c.dispose),v.exportProperty(c,"isActive",c.isActive),v.exportProperty(c,"getDependenciesCount",c.getDependenciesCount),k&&(b=!0,k.nodeType&&(O=function(){return!v.utils.domNodeIsAttachedToDocument(k)||E&&E()})),w||r.deferEvaluation||l(),k&&p()&&k.nodeType&&(C=function(){v.utils.domNodeDisposal.removeDisposeCallback(k,C),a()},v.utils.domNodeDisposal.addDisposeCallback(k,C)),c},v.isComputed=function(e){return v.hasPrototype(e,v.dependentObservable)};var w=v.observable.protoProperty;v.dependentObservable[w]=v.observable,v.dependentObservable.fn={equalityComparer:r},v.dependentObservable.fn[w]=v.dependentObservable,v.utils.canSetPrototype&&v.utils.setPrototypeOf(v.dependentObservable.fn,v.subscribable.fn),v.exportSymbol("dependentObservable",v.dependentObservable),v.exportSymbol("computed",v.dependentObservable),v.exportSymbol("isComputed",v.isComputed),v.pureComputed=function(e,t){return"function"==typeof e?v.computed(e,t,{pure:!0}):(e=v.utils.extend({},e),e.pure=!0,v.computed(e,t))},v.exportSymbol("pureComputed",v.pureComputed),function(){function e(r,o,s){s=s||new n,r=o(r);var a=!("object"!=typeof r||null===r||r===i||r instanceof Date||r instanceof String||r instanceof Number||r instanceof Boolean);if(!a)return r;var u=r instanceof Array?[]:{};return s.save(r,u),t(r,function(t){var n=o(r[t]);switch(typeof n){case"boolean":case"number":case"string":case"function":u[t]=n;break;case"object":case"undefined":var a=s.get(n);u[t]=a!==i?a:e(n,o,s)}}),u}function t(e,t){if(e instanceof Array){for(var n=0;n<e.length;n++)t(n);"function"==typeof e.toJSON&&t("toJSON")}else for(var r in e)t(r)}function n(){this.keys=[],this.values=[]}var r=10;v.toJS=function(t){if(0==arguments.length)throw new Error("When calling ko.toJS, pass the object you want to convert.");return e(t,function(e){for(var t=0;v.isObservable(e)&&r>t;t++)e=e();return e})},v.toJSON=function(e,t,n){var r=v.toJS(e);return v.utils.stringifyJson(r,t,n)},n.prototype={constructor:n,save:function(e,t){var n=v.utils.arrayIndexOf(this.keys,e);n>=0?this.values[n]=t:(this.keys.push(e),this.values.push(t))},get:function(e){var t=v.utils.arrayIndexOf(this.keys,e);return t>=0?this.values[t]:i}}}(),v.exportSymbol("toJS",v.toJS),v.exportSymbol("toJSON",v.toJSON),function(){var e="__ko__hasDomDataOptionValue__";v.selectExtensions={readValue:function(t){switch(v.utils.tagNameLower(t)){case"option":return t[e]===!0?v.utils.domData.get(t,v.bindingHandlers.options.optionValueDomDataKey):v.utils.ieVersion<=7?t.getAttributeNode("value")&&t.getAttributeNode("value").specified?t.value:t.text:t.value;case"select":return t.selectedIndex>=0?v.selectExtensions.readValue(t.options[t.selectedIndex]):i;default:return t.value}},writeValue:function(t,n,r){switch(v.utils.tagNameLower(t)){case"option":switch(typeof n){case"string":v.utils.domData.set(t,v.bindingHandlers.options.optionValueDomDataKey,i),e in t&&delete t[e],t.value=n;break;default:v.utils.domData.set(t,v.bindingHandlers.options.optionValueDomDataKey,n),t[e]=!0,t.value="number"==typeof n?n:""}break;case"select":(""===n||null===n)&&(n=i);for(var o,s=-1,a=0,u=t.options.length;u>a;++a)if(o=v.selectExtensions.readValue(t.options[a]),o==n||""==o&&n===i){s=a;break}(r||s>=0||n===i&&t.size>1)&&(t.selectedIndex=s);break;default:(null===n||n===i)&&(n=""),t.value=n}}}}(),v.exportSymbol("selectExtensions",v.selectExtensions),v.exportSymbol("selectExtensions.readValue",v.selectExtensions.readValue),v.exportSymbol("selectExtensions.writeValue",v.selectExtensions.writeValue),v.expressionRewriting=function(){function e(e){if(v.utils.arrayIndexOf(r,e)>=0)return!1;var t=e.match(i);return null===t?!1:t[1]?"Object("+t[1]+")"+t[2]:e}function t(e){var t=v.utils.stringTrim(e);123===t.charCodeAt(0)&&(t=t.slice(1,-1));var n,r,i=[],o=t.match(d),s=0;if(o){o.push(",");for(var a,u=0;a=o[u];++u){var l=a.charCodeAt(0);if(44===l){if(0>=s){n&&i.push(r?{key:n,value:r.join("")}:{unknown:n}),n=r=s=0;continue}}else if(58===l){if(!r)continue}else if(47===l&&u&&a.length>1){var c=o[u-1].match(p);c&&!f[c[0]]&&(t=t.substr(t.indexOf(a)+1),o=t.match(d),o.push(","),u=-1,a="/")}else if(40===l||123===l||91===l)++s;else if(41===l||125===l||93===l)--s;else if(!n&&!r){n=34===l||39===l?a.slice(1,-1):a;continue}r?r.push(a):r=[a]}}return i}function n(n,r){function i(t,n){function r(e){return e&&e.preprocess?n=e.preprocess(n,t,i):!0}var l;if(!u){if(!r(v.getBindingHandler(t)))return;h[t]&&(l=e(n))&&s.push("'"+t+"':function(_z){"+l+"=_z}")}a&&(n="function(){return "+n+" }"),o.push("'"+t+"':"+n)}r=r||{};var o=[],s=[],a=r.valueAccessors,u=r.bindingParams,l="string"==typeof n?t(n):n;return v.utils.arrayForEach(l,function(e){i(e.key||e.unknown,e.value)}),s.length&&i("_ko_property_writers","{"+s.join(",")+" }"),o.join(",")}var r=["true","false","null","undefined"],i=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,o='"(?:[^"\\\\]|\\\\.)*"',s="'(?:[^'\\\\]|\\\\.)*'",a="/(?:[^/\\\\]|\\\\.)*/w*",u=",\"'{}()/:[\\]",l="[^\\s:,/][^"+u+"]*[^\\s"+u+"]",c="[^\\s]",d=RegExp(o+"|"+s+"|"+a+"|"+l+"|"+c,"g"),p=/[\])"'A-Za-z0-9_$]+$/,f={"in":1,"return":1,"typeof":1},h={};return{bindingRewriteValidators:[],twoWayBindings:h,parseObjectLiteral:t,preProcessBindings:n,keyValueArrayContainsKey:function(e,t){for(var n=0;n<e.length;n++)if(e[n].key==t)return!0;return!1},writeValueToProperty:function(e,t,n,r,i){if(e&&v.isObservable(e))!v.isWriteableObservable(e)||i&&e.peek()===r||e(r);else{var o=t.get("_ko_property_writers");o&&o[n]&&o[n](r)}}}}(),v.exportSymbol("expressionRewriting",v.expressionRewriting),v.exportSymbol("expressionRewriting.bindingRewriteValidators",v.expressionRewriting.bindingRewriteValidators),v.exportSymbol("expressionRewriting.parseObjectLiteral",v.expressionRewriting.parseObjectLiteral),v.exportSymbol("expressionRewriting.preProcessBindings",v.expressionRewriting.preProcessBindings),v.exportSymbol("expressionRewriting._twoWayBindings",v.expressionRewriting.twoWayBindings),v.exportSymbol("jsonExpressionRewriting",v.expressionRewriting),v.exportSymbol("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",v.expressionRewriting.preProcessBindings),function(){function e(e){return 8==e.nodeType&&a.test(o?e.text:e.nodeValue)}function t(e){return 8==e.nodeType&&u.test(o?e.text:e.nodeValue)}function n(n,r){for(var i=n,o=1,s=[];i=i.nextSibling;){if(t(i)&&(o--,0===o))return s;s.push(i),e(i)&&o++}if(!r)throw new Error("Cannot find closing comment tag to match: "+n.nodeValue);return null}function r(e,t){var r=n(e,t);return r?r.length>0?r[r.length-1].nextSibling:e.nextSibling:null}function i(n){var i=n.firstChild,o=null;if(i)do if(o)o.push(i);else if(e(i)){var s=r(i,!0);s?i=s:o=[i]}else t(i)&&(o=[i]);while(i=i.nextSibling);return o}var o=s&&"<!--test-->"===s.createComment("test").text,a=o?/^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,u=o?/^<!--\s*\/ko\s*-->$/:/^\s*\/ko\s*$/,l={ul:!0,ol:!0};v.virtualElements={allowedBindings:{},childNodes:function(t){return e(t)?n(t):t.childNodes},emptyNode:function(t){if(e(t))for(var n=v.virtualElements.childNodes(t),r=0,i=n.length;i>r;r++)v.removeNode(n[r]);else v.utils.emptyDomNode(t)},setDomNodeChildren:function(t,n){if(e(t)){v.virtualElements.emptyNode(t);for(var r=t.nextSibling,i=0,o=n.length;o>i;i++)r.parentNode.insertBefore(n[i],r)}else v.utils.setDomNodeChildren(t,n)},prepend:function(t,n){e(t)?t.parentNode.insertBefore(n,t.nextSibling):t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)},insertAfter:function(t,n,r){r?e(t)?t.parentNode.insertBefore(n,r.nextSibling):r.nextSibling?t.insertBefore(n,r.nextSibling):t.appendChild(n):v.virtualElements.prepend(t,n)},firstChild:function(n){return e(n)?!n.nextSibling||t(n.nextSibling)?null:n.nextSibling:n.firstChild},nextSibling:function(n){return e(n)&&(n=r(n)),n.nextSibling&&t(n.nextSibling)?null:n.nextSibling},hasBindingValue:e,virtualNodeBindingValue:function(e){var t=(o?e.text:e.nodeValue).match(a);return t?t[1]:null},normaliseVirtualElementDomStructure:function(e){if(l[v.utils.tagNameLower(e)]){var t=e.firstChild;if(t)do if(1===t.nodeType){var n=i(t);if(n)for(var r=t.nextSibling,o=0;o<n.length;o++)r?e.insertBefore(n[o],r):e.appendChild(n[o])}while(t=t.nextSibling)}}}}(),v.exportSymbol("virtualElements",v.virtualElements),v.exportSymbol("virtualElements.allowedBindings",v.virtualElements.allowedBindings),v.exportSymbol("virtualElements.emptyNode",v.virtualElements.emptyNode),v.exportSymbol("virtualElements.insertAfter",v.virtualElements.insertAfter),v.exportSymbol("virtualElements.prepend",v.virtualElements.prepend),v.exportSymbol("virtualElements.setDomNodeChildren",v.virtualElements.setDomNodeChildren),function(){function e(e,n,r){var i=e+(r&&r.valueAccessors||"");return n[i]||(n[i]=t(e,r))}function t(e,t){var n=v.expressionRewriting.preProcessBindings(e,t),r="with($context){with($data||{}){return{"+n+"}}}";return new Function("$context","$element",r)}var n="data-bind";v.bindingProvider=function(){this.bindingCache={}},v.utils.extend(v.bindingProvider.prototype,{nodeHasBindings:function(e){switch(e.nodeType){case 1:return null!=e.getAttribute(n)||v.components.getComponentNameForNode(e);case 8:return v.virtualElements.hasBindingValue(e);default:return!1}},getBindings:function(e,t){var n=this.getBindingsString(e,t),r=n?this.parseBindingsString(n,t,e):null;return v.components.addBindingsForCustomElement(r,e,t,!1)},getBindingAccessors:function(e,t){var n=this.getBindingsString(e,t),r=n?this.parseBindingsString(n,t,e,{valueAccessors:!0}):null;return v.components.addBindingsForCustomElement(r,e,t,!0)},getBindingsString:function(e){switch(e.nodeType){case 1:return e.getAttribute(n);case 8:return v.virtualElements.virtualNodeBindingValue(e);default:return null}},parseBindingsString:function(t,n,r,i){try{var o=e(t,this.bindingCache,i);return o(n,r)}catch(s){throw s.message="Unable to parse bindings.\nBindings value: "+t+"\nMessage: "+s.message,s}}}),v.bindingProvider.instance=new v.bindingProvider}(),v.exportSymbol("bindingProvider",v.bindingProvider),function(){function e(e){return function(){return e}}function t(e){return e()}function n(e){return v.utils.objectMap(v.dependencyDetection.ignore(e),function(t,n){return function(){return e()[n]}})}function r(t,r,i){return"function"==typeof t?n(t.bind(null,r,i)):v.utils.objectMap(t,e)}function s(e,t){return n(this.getBindings.bind(this,e,t))}function a(e){var t=v.virtualElements.allowedBindings[e];if(!t)throw new Error("The binding '"+e+"' cannot be used with virtual elements")}function l(e,t,n){var r,i=v.virtualElements.firstChild(t),o=v.bindingProvider.instance,s=o.preprocessNode;if(s){for(;r=i;)i=v.virtualElements.nextSibling(r),s.call(o,r);i=v.virtualElements.firstChild(t)}for(;r=i;)i=v.virtualElements.nextSibling(r),c(e,r,n)}function c(e,t,n){var r=!0,i=1===t.nodeType;i&&v.virtualElements.normaliseVirtualElementDomStructure(t);var o=i&&n||v.bindingProvider.instance.nodeHasBindings(t);o&&(r=p(t,null,e,n).shouldBindDescendants),r&&!h[v.utils.tagNameLower(t)]&&l(e,t,!i)}function d(e){var t=[],n={},r=[];return v.utils.objectForEach(e,function i(o){if(!n[o]){var s=v.getBindingHandler(o);s&&(s.after&&(r.push(o),v.utils.arrayForEach(s.after,function(t){if(e[t]){if(-1!==v.utils.arrayIndexOf(r,t))throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+r.join(", "));i(t)}}),r.length--),t.push({key:o,handler:s})),n[o]=!0}}),t}function p(e,n,r,o){function u(){return v.utils.objectMap(h?h():c,t)}var l=v.utils.domData.get(e,m);if(!n){if(l)throw Error("You cannot apply bindings multiple times to the same element.");v.utils.domData.set(e,m,!0)}!l&&o&&v.storedBindingContextForNode(e,r);var c;if(n&&"function"!=typeof n)c=n;else{var p=v.bindingProvider.instance,f=p.getBindingAccessors||s,h=v.dependentObservable(function(){return c=n?n(r,e):f.call(p,e,r),c&&r._subscribable&&r._subscribable(),c},null,{disposeWhenNodeIsRemoved:e});c&&h.isActive()||(h=null)}var b;if(c){var g=h?function(e){return function(){return t(h()[e])}}:function(e){return c[e]};u.get=function(e){return c[e]&&t(g(e))},u.has=function(e){return e in c};var y=d(c);v.utils.arrayForEach(y,function(t){var n=t.handler.init,o=t.handler.update,s=t.key;8===e.nodeType&&a(s);try{"function"==typeof n&&v.dependencyDetection.ignore(function(){var t=n(e,g(s),u,r.$data,r);if(t&&t.controlsDescendantBindings){if(b!==i)throw new Error("Multiple bindings ("+b+" and "+s+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");b=s}}),"function"==typeof o&&v.dependentObservable(function(){o(e,g(s),u,r.$data,r)},null,{disposeWhenNodeIsRemoved:e})}catch(l){throw l.message='Unable to process binding "'+s+": "+c[s]+'"\nMessage: '+l.message,l}})}return{shouldBindDescendants:b===i}}function f(e){return e&&e instanceof v.bindingContext?e:new v.bindingContext(e)}v.bindingHandlers={};var h={script:!0};v.getBindingHandler=function(e){return v.bindingHandlers[e]},v.bindingContext=function(e,t,n,r){function o(){var i=l?e():e,o=v.utils.unwrapObservable(i);return t?(t._subscribable&&t._subscribable(),v.utils.extend(u,t),c&&(u._subscribable=c)):(u.$parents=[],u.$root=o,u.ko=v),u.$rawData=i,u.$data=o,n&&(u[n]=o),r&&r(u,t,o),u.$data}function s(){return a&&!v.utils.anyDomNodeIsAttachedToDocument(a)}var a,u=this,l="function"==typeof e&&!v.isObservable(e),c=v.dependentObservable(o,null,{disposeWhen:s,disposeWhenNodeIsRemoved:!0});c.isActive()&&(u._subscribable=c,c.equalityComparer=null,a=[],c._addNode=function(e){a.push(e),v.utils.domNodeDisposal.addDisposeCallback(e,function(e){v.utils.arrayRemoveItem(a,e),a.length||(c.dispose(),u._subscribable=c=i)})})},v.bindingContext.prototype.createChildContext=function(e,t,n){return new v.bindingContext(e,this,t,function(e,t){e.$parentContext=t,e.$parent=t.$data,e.$parents=(t.$parents||[]).slice(0),e.$parents.unshift(e.$parent),n&&n(e)})},v.bindingContext.prototype.extend=function(e){return new v.bindingContext(this._subscribable||this.$data,this,null,function(t,n){t.$rawData=n.$rawData,v.utils.extend(t,"function"==typeof e?e():e)})};var m=v.utils.domData.nextKey(),b=v.utils.domData.nextKey();v.storedBindingContextForNode=function(e,t){return 2!=arguments.length?v.utils.domData.get(e,b):(v.utils.domData.set(e,b,t),void(t._subscribable&&t._subscribable._addNode(e)))},v.applyBindingAccessorsToNode=function(e,t,n){return 1===e.nodeType&&v.virtualElements.normaliseVirtualElementDomStructure(e),p(e,t,f(n),!0)},v.applyBindingsToNode=function(e,t,n){var i=f(n);return v.applyBindingAccessorsToNode(e,r(t,i,e),i)},v.applyBindingsToDescendants=function(e,t){(1===t.nodeType||8===t.nodeType)&&l(f(e),t,!0)},v.applyBindings=function(e,t){if(!u&&o.jQuery&&(u=o.jQuery),t&&1!==t.nodeType&&8!==t.nodeType)throw new Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");t=t||o.document.body,c(f(e),t,!0)},v.contextFor=function(e){switch(e.nodeType){case 1:case 8:var t=v.storedBindingContextForNode(e);if(t)return t;if(e.parentNode)return v.contextFor(e.parentNode)}return i},v.dataFor=function(e){var t=v.contextFor(e);return t?t.$data:i},v.exportSymbol("bindingHandlers",v.bindingHandlers),v.exportSymbol("applyBindings",v.applyBindings),v.exportSymbol("applyBindingsToDescendants",v.applyBindingsToDescendants),v.exportSymbol("applyBindingAccessorsToNode",v.applyBindingAccessorsToNode),v.exportSymbol("applyBindingsToNode",v.applyBindingsToNode),v.exportSymbol("contextFor",v.contextFor),v.exportSymbol("dataFor",v.dataFor)}(),function(e){function t(t,n){return t.hasOwnProperty(n)?t[n]:e}function n(e,n){var i,a=t(o,e);a||(a=o[e]=new v.subscribable,r(e,function(t){s[e]=t,delete o[e],i?a.notifySubscribers(t):setTimeout(function(){a.notifySubscribers(t)},0)}),i=!0),a.subscribe(n)}function r(e,t){i("getConfig",[e],function(n){n?i("loadComponent",[e,n],function(e){t(e)}):t(null)})}function i(t,n,r,o){o||(o=v.components.loaders.slice(0));var s=o.shift();if(s){var a=s[t];if(a){var u=!1,l=a.apply(s,n.concat(function(e){u?r(null):null!==e?r(e):i(t,n,r,o)}));if(l!==e&&(u=!0,!s.suppressLoaderExceptions))throw new Error("Component loaders must supply values by invoking the callback, not by returning values synchronously.")}else i(t,n,r,o)}else r(null)}var o={},s={};v.components={get:function(e,r){var i=t(s,e);i?setTimeout(function(){r(i)},0):n(e,r)},clearCachedDefinition:function(e){delete s[e]},_getFirstResultFromLoaders:i},v.components.loaders=[],v.exportSymbol("components",v.components),v.exportSymbol("components.get",v.components.get),v.exportSymbol("components.clearCachedDefinition",v.components.clearCachedDefinition)}(),function(){function e(e,t,n,r){var i={},o=2,s=function(){0===--o&&r(i)},a=n.template,u=n.viewModel;a?l(t,a,function(t){v.components._getFirstResultFromLoaders("loadTemplate",[e,t],function(e){i.template=e,s()})}):s(),u?l(t,u,function(t){v.components._getFirstResultFromLoaders("loadViewModel",[e,t],function(e){i[p]=e,s()})}):s()}function n(e,t,n){if("string"==typeof t)n(v.utils.parseHtmlFragment(t));else if(t instanceof Array)n(t);else if(u(t))n(v.utils.makeArray(t.childNodes));else if(t.element){var r=t.element;if(a(r))n(i(r));else if("string"==typeof r){var o=s.getElementById(r);o?n(i(o)):e("Cannot find element with ID "+r)}else e("Unknown element type: "+r)}else e("Unknown template value: "+t)}function r(e,t,n){if("function"==typeof t)n(function(e){return new t(e)});else if("function"==typeof t[p])n(t[p]);else if("instance"in t){var i=t.instance;n(function(){return i})}else"viewModel"in t?r(e,t.viewModel,n):e("Unknown viewModel value: "+t)}function i(e){switch(v.utils.tagNameLower(e)){case"script":return v.utils.parseHtmlFragment(e.text);case"textarea":return v.utils.parseHtmlFragment(e.value);
case"template":if(u(e.content))return v.utils.cloneNodes(e.content.childNodes)}return v.utils.cloneNodes(e.childNodes)}function a(e){return o.HTMLElement?e instanceof HTMLElement:e&&e.tagName&&1===e.nodeType}function u(e){return o.DocumentFragment?e instanceof DocumentFragment:e&&11===e.nodeType}function l(e,n,r){"string"==typeof n.require?t||o.require?(t||o.require)([n.require],r):e("Uses require, but no AMD loader is present"):r(n)}function c(e){return function(t){throw new Error("Component '"+e+"': "+t)}}var d={};v.components.register=function(e,t){if(!t)throw new Error("Invalid configuration for "+e);if(v.components.isRegistered(e))throw new Error("Component "+e+" is already registered");d[e]=t},v.components.isRegistered=function(e){return e in d},v.components.unregister=function(e){delete d[e],v.components.clearCachedDefinition(e)},v.components.defaultLoader={getConfig:function(e,t){var n=d.hasOwnProperty(e)?d[e]:null;t(n)},loadComponent:function(t,n,r){var i=c(t);l(i,n,function(n){e(t,i,n,r)})},loadTemplate:function(e,t,r){n(c(e),t,r)},loadViewModel:function(e,t,n){r(c(e),t,n)}};var p="createViewModel";v.exportSymbol("components.register",v.components.register),v.exportSymbol("components.isRegistered",v.components.isRegistered),v.exportSymbol("components.unregister",v.components.unregister),v.exportSymbol("components.defaultLoader",v.components.defaultLoader),v.components.loaders.push(v.components.defaultLoader),v.components._allRegisteredComponents=d}(),function(){function e(e,n){var r=e.getAttribute("params");if(r){var i=t.parseBindingsString(r,n,e,{valueAccessors:!0,bindingParams:!0}),o=v.utils.objectMap(i,function(t){return v.computed(t,null,{disposeWhenNodeIsRemoved:e})}),s=v.utils.objectMap(o,function(t){return t.isActive()?v.computed(function(){return v.utils.unwrapObservable(t())},null,{disposeWhenNodeIsRemoved:e}):t.peek()});return s.hasOwnProperty("$raw")||(s.$raw=o),s}return{$raw:{}}}v.components.getComponentNameForNode=function(e){var t=v.utils.tagNameLower(e);return v.components.isRegistered(t)&&t},v.components.addBindingsForCustomElement=function(t,n,r,i){if(1===n.nodeType){var o=v.components.getComponentNameForNode(n);if(o){if(t=t||{},t.component)throw new Error('Cannot use the "component" binding on a custom element matching a component');var s={name:o,params:e(n,r)};t.component=i?function(){return s}:s}}return t};var t=new v.bindingProvider;v.utils.ieVersion<9&&(v.components.register=function(e){return function(t){return s.createElement(t),e.apply(this,arguments)}}(v.components.register),s.createDocumentFragment=function(e){return function(){var t=e(),n=v.components._allRegisteredComponents;for(var r in n)n.hasOwnProperty(r)&&t.createElement(r);return t}}(s.createDocumentFragment))}(),function(){function e(e,t,n){var r=t.template;if(!r)throw new Error("Component '"+e+"' has no template");var i=v.utils.cloneNodes(r);v.virtualElements.setDomNodeChildren(n,i)}function t(e,t,n){var r=e.createViewModel;return r?r.call(e,n,{element:t}):n}var n=0;v.bindingHandlers.component={init:function(r,i,o,s,a){var u,l,c=function(){var e=u&&u.dispose;"function"==typeof e&&e.call(u),l=null};return v.utils.domNodeDisposal.addDisposeCallback(r,c),v.computed(function(){var o,s,d=v.utils.unwrapObservable(i());if("string"==typeof d?o=d:(o=v.utils.unwrapObservable(d.name),s=v.utils.unwrapObservable(d.params)),!o)throw new Error("No component name specified");var p=l=++n;v.components.get(o,function(n){if(l===p){if(c(),!n)throw new Error("Unknown component '"+o+"'");e(o,n,r);var i=t(n,r,s),d=a.createChildContext(i);u=i,v.applyBindingsToDescendants(d,r)}})},null,{disposeWhenNodeIsRemoved:r}),{controlsDescendantBindings:!0}}},v.virtualElements.allowedBindings.component=!0}();var x={"class":"className","for":"htmlFor"};v.bindingHandlers.attr={update:function(e,t){var n=v.utils.unwrapObservable(t())||{};v.utils.objectForEach(n,function(t,n){n=v.utils.unwrapObservable(n);var r=n===!1||null===n||n===i;r&&e.removeAttribute(t),v.utils.ieVersion<=8&&t in x?(t=x[t],r?e.removeAttribute(t):e[t]=n):r||e.setAttribute(t,n.toString()),"name"===t&&v.utils.setElementName(e,r?"":n.toString())})}},function(){v.bindingHandlers.checked={after:["value","attr"],init:function(e,t,n){function r(){var r=e.checked,i=d?s():r;if(!v.computedContext.isInitial()&&(!u||r)){var o=v.dependencyDetection.ignore(t);l?c!==i?(r&&(v.utils.addOrRemoveItem(o,i,!0),v.utils.addOrRemoveItem(o,c,!1)),c=i):v.utils.addOrRemoveItem(o,i,r):v.expressionRewriting.writeValueToProperty(o,n,"checked",i,!0)}}function o(){var n=v.utils.unwrapObservable(t());e.checked=l?v.utils.arrayIndexOf(n,s())>=0:a?n:s()===n}var s=v.pureComputed(function(){return n.has("checkedValue")?v.utils.unwrapObservable(n.get("checkedValue")):n.has("value")?v.utils.unwrapObservable(n.get("value")):e.value}),a="checkbox"==e.type,u="radio"==e.type;if(a||u){var l=a&&v.utils.unwrapObservable(t())instanceof Array,c=l?s():i,d=u||l;u&&!e.name&&v.bindingHandlers.uniqueName.init(e,function(){return!0}),v.computed(r,null,{disposeWhenNodeIsRemoved:e}),v.utils.registerEventHandler(e,"click",r),v.computed(o,null,{disposeWhenNodeIsRemoved:e})}}},v.expressionRewriting.twoWayBindings.checked=!0,v.bindingHandlers.checkedValue={update:function(e,t){e.value=v.utils.unwrapObservable(t())}}}();var k="__ko__cssValue";v.bindingHandlers.css={update:function(e,t){var n=v.utils.unwrapObservable(t());"object"==typeof n?v.utils.objectForEach(n,function(t,n){n=v.utils.unwrapObservable(n),v.utils.toggleDomNodeCssClass(e,t,n)}):(n=String(n||""),v.utils.toggleDomNodeCssClass(e,e[k],!1),e[k]=n,v.utils.toggleDomNodeCssClass(e,n,!0))}},v.bindingHandlers.enable={update:function(e,t){var n=v.utils.unwrapObservable(t());n&&e.disabled?e.removeAttribute("disabled"):n||e.disabled||(e.disabled=!0)}},v.bindingHandlers.disable={update:function(e,t){v.bindingHandlers.enable.update(e,function(){return!v.utils.unwrapObservable(t())})}},v.bindingHandlers.event={init:function(e,t,n,r,i){var o=t()||{};v.utils.objectForEach(o,function(o){"string"==typeof o&&v.utils.registerEventHandler(e,o,function(e){var s,a=t()[o];if(a){try{var u=v.utils.makeArray(arguments);r=i.$data,u.unshift(r),s=a.apply(r,u)}finally{s!==!0&&(e.preventDefault?e.preventDefault():e.returnValue=!1)}var l=n.get(o+"Bubble")!==!1;l||(e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation())}})})}},v.bindingHandlers.foreach={makeTemplateValueAccessor:function(e){return function(){var t=e(),n=v.utils.peekObservable(t);return n&&"number"!=typeof n.length?(v.utils.unwrapObservable(t),{foreach:n.data,as:n.as,includeDestroyed:n.includeDestroyed,afterAdd:n.afterAdd,beforeRemove:n.beforeRemove,afterRender:n.afterRender,beforeMove:n.beforeMove,afterMove:n.afterMove,templateEngine:v.nativeTemplateEngine.instance}):{foreach:t,templateEngine:v.nativeTemplateEngine.instance}}},init:function(e,t){return v.bindingHandlers.template.init(e,v.bindingHandlers.foreach.makeTemplateValueAccessor(t))},update:function(e,t,n,r,i){return v.bindingHandlers.template.update(e,v.bindingHandlers.foreach.makeTemplateValueAccessor(t),n,r,i)}},v.expressionRewriting.bindingRewriteValidators.foreach=!1,v.virtualElements.allowedBindings.foreach=!0;var E="__ko_hasfocusUpdating",O="__ko_hasfocusLastValue";v.bindingHandlers.hasfocus={init:function(e,t,n){var r=function(r){e[E]=!0;var i=e.ownerDocument;if("activeElement"in i){var o;try{o=i.activeElement}catch(s){o=i.body}r=o===e}var a=t();v.expressionRewriting.writeValueToProperty(a,n,"hasfocus",r,!0),e[O]=r,e[E]=!1},i=r.bind(null,!0),o=r.bind(null,!1);v.utils.registerEventHandler(e,"focus",i),v.utils.registerEventHandler(e,"focusin",i),v.utils.registerEventHandler(e,"blur",o),v.utils.registerEventHandler(e,"focusout",o)},update:function(e,t){var n=!!v.utils.unwrapObservable(t());e[E]||e[O]===n||(n?e.focus():e.blur(),v.dependencyDetection.ignore(v.utils.triggerEvent,null,[e,n?"focusin":"focusout"]))}},v.expressionRewriting.twoWayBindings.hasfocus=!0,v.bindingHandlers.hasFocus=v.bindingHandlers.hasfocus,v.expressionRewriting.twoWayBindings.hasFocus=!0,v.bindingHandlers.html={init:function(){return{controlsDescendantBindings:!0}},update:function(e,t){v.utils.setHtml(e,t())}},h("if"),h("ifnot",!1,!0),h("with",!0,!1,function(e,t){return e.createChildContext(t)});var C={};v.bindingHandlers.options={init:function(e){if("select"!==v.utils.tagNameLower(e))throw new Error("options binding applies only to SELECT elements");for(;e.length>0;)e.remove(0);return{controlsDescendantBindings:!0}},update:function(e,t,n){function r(){return v.utils.arrayFilter(e.options,function(e){return e.selected})}function o(e,t,n){var r=typeof t;return"function"==r?t(e):"string"==r?e[t]:n}function s(t,r,s){s.length&&(c=s[0].selected?[v.selectExtensions.readValue(s[0])]:[],b=!0);var a=e.ownerDocument.createElement("option");if(t===C)v.utils.setTextContent(a,n.get("optionsCaption")),v.selectExtensions.writeValue(a,i);else{var u=o(t,n.get("optionsValue"),t);v.selectExtensions.writeValue(a,v.utils.unwrapObservable(u));var l=o(t,n.get("optionsText"),u);v.utils.setTextContent(a,l)}return[a]}function a(t,n){if(c.length){var r=v.utils.arrayIndexOf(c,v.selectExtensions.readValue(n[0]))>=0;v.utils.setOptionNodeSelectionState(n[0],r),b&&!r&&v.dependencyDetection.ignore(v.utils.triggerEvent,null,[e,"change"])}}var u,l,c,d=0==e.length,p=!d&&e.multiple?e.scrollTop:null,f=v.utils.unwrapObservable(t()),h=n.get("optionsIncludeDestroyed"),m={};c=e.multiple?v.utils.arrayMap(r(),v.selectExtensions.readValue):e.selectedIndex>=0?[v.selectExtensions.readValue(e.options[e.selectedIndex])]:[],f&&("undefined"==typeof f.length&&(f=[f]),l=v.utils.arrayFilter(f,function(e){return h||e===i||null===e||!v.utils.unwrapObservable(e._destroy)}),n.has("optionsCaption")&&(u=v.utils.unwrapObservable(n.get("optionsCaption")),null!==u&&u!==i&&l.unshift(C)));var b=!1;m.beforeRemove=function(t){e.removeChild(t)};var g=a;n.has("optionsAfterRender")&&(g=function(e,t){a(e,t),v.dependencyDetection.ignore(n.get("optionsAfterRender"),null,[t[0],e!==C?e:i])}),v.utils.setDomNodeChildrenFromArrayMapping(e,l,s,m,g),v.dependencyDetection.ignore(function(){if(n.get("valueAllowUnset")&&n.has("value"))v.selectExtensions.writeValue(e,v.utils.unwrapObservable(n.get("value")),!0);else{var t;t=e.multiple?c.length&&r().length<c.length:c.length&&e.selectedIndex>=0?v.selectExtensions.readValue(e.options[e.selectedIndex])!==c[0]:c.length||e.selectedIndex>=0,t&&v.utils.triggerEvent(e,"change")}}),v.utils.ensureSelectElementIsRenderedCorrectly(e),p&&Math.abs(p-e.scrollTop)>20&&(e.scrollTop=p)}},v.bindingHandlers.options.optionValueDomDataKey=v.utils.domData.nextKey(),v.bindingHandlers.selectedOptions={after:["options","foreach"],init:function(e,t,n){v.utils.registerEventHandler(e,"change",function(){var r=t(),i=[];v.utils.arrayForEach(e.getElementsByTagName("option"),function(e){e.selected&&i.push(v.selectExtensions.readValue(e))}),v.expressionRewriting.writeValueToProperty(r,n,"selectedOptions",i)})},update:function(e,t){if("select"!=v.utils.tagNameLower(e))throw new Error("values binding applies only to SELECT elements");var n=v.utils.unwrapObservable(t());n&&"number"==typeof n.length&&v.utils.arrayForEach(e.getElementsByTagName("option"),function(e){var t=v.utils.arrayIndexOf(n,v.selectExtensions.readValue(e))>=0;v.utils.setOptionNodeSelectionState(e,t)})}},v.expressionRewriting.twoWayBindings.selectedOptions=!0,v.bindingHandlers.style={update:function(e,t){var n=v.utils.unwrapObservable(t()||{});v.utils.objectForEach(n,function(t,n){n=v.utils.unwrapObservable(n),(null===n||n===i||n===!1)&&(n=""),e.style[t]=n})}},v.bindingHandlers.submit={init:function(e,t,n,r,i){if("function"!=typeof t())throw new Error("The value for a submit binding must be a function");v.utils.registerEventHandler(e,"submit",function(n){var r,o=t();try{r=o.call(i.$data,e)}finally{r!==!0&&(n.preventDefault?n.preventDefault():n.returnValue=!1)}})}},v.bindingHandlers.text={init:function(){return{controlsDescendantBindings:!0}},update:function(e,t){v.utils.setTextContent(e,t())}},v.virtualElements.allowedBindings.text=!0,function(){if(o&&o.navigator)var e=function(e){return e?parseFloat(e[1]):void 0},t=o.opera&&o.opera.version&&parseInt(o.opera.version()),r=o.navigator.userAgent,s=e(r.match(/^(?:(?!chrome).)*version\/([^ ]*) safari/i)),a=e(r.match(/Firefox\/([^ ]*)/));if(v.utils.ieVersion<10)var u=v.utils.domData.nextKey(),l=v.utils.domData.nextKey(),c=function(e){var t=this.activeElement,n=t&&v.utils.domData.get(t,l);n&&n(e)},d=function(e,t){var n=e.ownerDocument;v.utils.domData.get(n,u)||(v.utils.domData.set(n,u,!0),v.utils.registerEventHandler(n,"selectionchange",c)),v.utils.domData.set(e,l,t)};v.bindingHandlers.textInput={init:function(e,r,o){var u,l,c=e.value,p=function(t){clearTimeout(u),l=u=i;var s=e.value;c!==s&&(n&&t&&(e._ko_textInputProcessedEvent=t.type),c=s,v.expressionRewriting.writeValueToProperty(r(),o,"textInput",s))},f=function(t){if(!u){l=e.value;var r=n?p.bind(e,{type:t.type}):p;u=setTimeout(r,4)}},h=function(){var t=v.utils.unwrapObservable(r());return(null===t||t===i)&&(t=""),l!==i&&t===l?void setTimeout(h,4):void(e.value!==t&&(c=t,e.value=t))},m=function(t,n){v.utils.registerEventHandler(e,t,n)};n&&v.bindingHandlers.textInput._forceUpdateOn?v.utils.arrayForEach(v.bindingHandlers.textInput._forceUpdateOn,function(e){"after"==e.slice(0,5)?m(e.slice(5),f):m(e,p)}):v.utils.ieVersion<10?(m("propertychange",function(e){"value"===e.propertyName&&p(e)}),8==v.utils.ieVersion&&(m("keyup",p),m("keydown",p)),v.utils.ieVersion>=8&&(d(e,p),m("dragend",f))):(m("input",p),5>s&&"textarea"===v.utils.tagNameLower(e)?(m("keydown",f),m("paste",f),m("cut",f)):11>t?m("keydown",f):4>a&&(m("DOMAutoComplete",p),m("dragdrop",p),m("drop",p))),m("change",p),v.computed(h,null,{disposeWhenNodeIsRemoved:e})}},v.expressionRewriting.twoWayBindings.textInput=!0,v.bindingHandlers.textinput={preprocess:function(e,t,n){n("textInput",e)}}}(),v.bindingHandlers.uniqueName={init:function(e,t){if(t()){var n="ko_unique_"+ ++v.bindingHandlers.uniqueName.currentIndex;v.utils.setElementName(e,n)}}},v.bindingHandlers.uniqueName.currentIndex=0,v.bindingHandlers.value={after:["options","foreach"],init:function(e,t,n){if("input"==e.tagName.toLowerCase()&&("checkbox"==e.type||"radio"==e.type))return void v.applyBindingAccessorsToNode(e,{checkedValue:t});var r=["change"],i=n.get("valueUpdate"),o=!1,s=null;i&&("string"==typeof i&&(i=[i]),v.utils.arrayPushAll(r,i),r=v.utils.arrayGetDistinctValues(r));var a=function(){s=null,o=!1;var r=t(),i=v.selectExtensions.readValue(e);v.expressionRewriting.writeValueToProperty(r,n,"value",i)},u=v.utils.ieVersion&&"input"==e.tagName.toLowerCase()&&"text"==e.type&&"off"!=e.autocomplete&&(!e.form||"off"!=e.form.autocomplete);u&&-1==v.utils.arrayIndexOf(r,"propertychange")&&(v.utils.registerEventHandler(e,"propertychange",function(){o=!0}),v.utils.registerEventHandler(e,"focus",function(){o=!1}),v.utils.registerEventHandler(e,"blur",function(){o&&a()})),v.utils.arrayForEach(r,function(t){var n=a;v.utils.stringStartsWith(t,"after")&&(n=function(){s=v.selectExtensions.readValue(e),setTimeout(a,0)},t=t.substring("after".length)),v.utils.registerEventHandler(e,t,n)});var l=function(){var r=v.utils.unwrapObservable(t()),i=v.selectExtensions.readValue(e);if(null!==s&&r===s)return void setTimeout(l,0);var o=r!==i;if(o)if("select"===v.utils.tagNameLower(e)){var a=n.get("valueAllowUnset"),u=function(){v.selectExtensions.writeValue(e,r,a)};u(),a||r===v.selectExtensions.readValue(e)?setTimeout(u,0):v.dependencyDetection.ignore(v.utils.triggerEvent,null,[e,"change"])}else v.selectExtensions.writeValue(e,r)};v.computed(l,null,{disposeWhenNodeIsRemoved:e})},update:function(){}},v.expressionRewriting.twoWayBindings.value=!0,v.bindingHandlers.visible={update:function(e,t){var n=v.utils.unwrapObservable(t()),r=!("none"==e.style.display);n&&!r?e.style.display="":!n&&r&&(e.style.display="none")}},f("click"),v.templateEngine=function(){},v.templateEngine.prototype.renderTemplateSource=function(){throw new Error("Override renderTemplateSource")},v.templateEngine.prototype.createJavaScriptEvaluatorBlock=function(){throw new Error("Override createJavaScriptEvaluatorBlock")},v.templateEngine.prototype.makeTemplateSource=function(e,t){if("string"==typeof e){t=t||s;var n=t.getElementById(e);if(!n)throw new Error("Cannot find template with ID "+e);return new v.templateSources.domElement(n)}if(1==e.nodeType||8==e.nodeType)return new v.templateSources.anonymousTemplate(e);throw new Error("Unknown template type: "+e)},v.templateEngine.prototype.renderTemplate=function(e,t,n,r){var i=this.makeTemplateSource(e,r);return this.renderTemplateSource(i,t,n)},v.templateEngine.prototype.isTemplateRewritten=function(e,t){return this.allowTemplateRewriting===!1?!0:this.makeTemplateSource(e,t).data("isRewritten")},v.templateEngine.prototype.rewriteTemplate=function(e,t,n){var r=this.makeTemplateSource(e,n),i=t(r.text());r.text(i),r.data("isRewritten",!0)},v.exportSymbol("templateEngine",v.templateEngine),v.templateRewriting=function(){function e(e){for(var t=v.expressionRewriting.bindingRewriteValidators,n=0;n<e.length;n++){var r=e[n].key;if(t.hasOwnProperty(r)){var i=t[r];if("function"==typeof i){var o=i(e[n].value);if(o)throw new Error(o)}else if(!i)throw new Error("This template engine does not support the '"+r+"' binding within its templates")}}}function t(t,n,r,i){var o=v.expressionRewriting.parseObjectLiteral(t);e(o);var s=v.expressionRewriting.preProcessBindings(o,{valueAccessors:!0}),a="ko.__tr_ambtns(function($context,$element){return(function(){return{ "+s+" } })()},'"+r.toLowerCase()+"')";return i.createJavaScriptEvaluatorBlock(a)+n}var n=/(<([a-z]+\d*)(?:\s+(?!data-bind\s*=\s*)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi,r=/<!--\s*ko\b\s*([\s\S]*?)\s*-->/g;return{ensureTemplateIsRewritten:function(e,t,n){t.isTemplateRewritten(e,n)||t.rewriteTemplate(e,function(e){return v.templateRewriting.memoizeBindingAttributeSyntax(e,t)},n)},memoizeBindingAttributeSyntax:function(e,i){return e.replace(n,function(){return t(arguments[4],arguments[1],arguments[2],i)}).replace(r,function(){return t(arguments[1],"<!-- ko -->","#comment",i)})},applyMemoizedBindingsToNextSibling:function(e,t){return v.memoization.memoize(function(n,r){var i=n.nextSibling;i&&i.nodeName.toLowerCase()===t&&v.applyBindingAccessorsToNode(i,e,r)})}}}(),v.exportSymbol("__tr_ambtns",v.templateRewriting.applyMemoizedBindingsToNextSibling),function(){v.templateSources={},v.templateSources.domElement=function(e){this.domElement=e},v.templateSources.domElement.prototype.text=function(){var e=v.utils.tagNameLower(this.domElement),t="script"===e?"text":"textarea"===e?"value":"innerHTML";if(0==arguments.length)return this.domElement[t];var n=arguments[0];"innerHTML"===t?v.utils.setHtml(this.domElement,n):this.domElement[t]=n};var e=v.utils.domData.nextKey()+"_";v.templateSources.domElement.prototype.data=function(t){return 1===arguments.length?v.utils.domData.get(this.domElement,e+t):void v.utils.domData.set(this.domElement,e+t,arguments[1])};var t=v.utils.domData.nextKey();v.templateSources.anonymousTemplate=function(e){this.domElement=e},v.templateSources.anonymousTemplate.prototype=new v.templateSources.domElement,v.templateSources.anonymousTemplate.prototype.constructor=v.templateSources.anonymousTemplate,v.templateSources.anonymousTemplate.prototype.text=function(){if(0==arguments.length){var e=v.utils.domData.get(this.domElement,t)||{};return e.textData===i&&e.containerData&&(e.textData=e.containerData.innerHTML),e.textData}var n=arguments[0];v.utils.domData.set(this.domElement,t,{textData:n})},v.templateSources.domElement.prototype.nodes=function(){if(0==arguments.length){var e=v.utils.domData.get(this.domElement,t)||{};return e.containerData}var n=arguments[0];v.utils.domData.set(this.domElement,t,{containerData:n})},v.exportSymbol("templateSources",v.templateSources),v.exportSymbol("templateSources.domElement",v.templateSources.domElement),v.exportSymbol("templateSources.anonymousTemplate",v.templateSources.anonymousTemplate)}(),function(){function e(e,t,n){for(var r,i=e,o=v.virtualElements.nextSibling(t);i&&(r=i)!==o;)i=v.virtualElements.nextSibling(r),n(r,i)}function t(t,n){if(t.length){var r=t[0],i=t[t.length-1],o=r.parentNode,s=v.bindingProvider.instance,a=s.preprocessNode;if(a){if(e(r,i,function(e,t){var n=e.previousSibling,o=a.call(s,e);o&&(e===r&&(r=o[0]||t),e===i&&(i=o[o.length-1]||n))}),t.length=0,!r)return;r===i?t.push(r):(t.push(r,i),v.utils.fixUpContinuousNodeArray(t,o))}e(r,i,function(e){(1===e.nodeType||8===e.nodeType)&&v.applyBindings(n,e)}),e(r,i,function(e){(1===e.nodeType||8===e.nodeType)&&v.memoization.unmemoizeDomNodeAndDescendants(e,[n])}),v.utils.fixUpContinuousNodeArray(t,o)}}function n(e){return e.nodeType?e:e.length>0?e[0]:null}function r(e,r,i,o,s){s=s||{};var u=e&&n(e),l=u&&u.ownerDocument,c=s.templateEngine||a;v.templateRewriting.ensureTemplateIsRewritten(i,c,l);var d=c.renderTemplate(i,o,s,l);if("number"!=typeof d.length||d.length>0&&"number"!=typeof d[0].nodeType)throw new Error("Template engine must return an array of DOM nodes");var p=!1;switch(r){case"replaceChildren":v.virtualElements.setDomNodeChildren(e,d),p=!0;break;case"replaceNode":v.utils.replaceDomNodes(e,d),p=!0;break;case"ignoreTargetNode":break;default:throw new Error("Unknown renderMode: "+r)}return p&&(t(d,o),s.afterRender&&v.dependencyDetection.ignore(s.afterRender,null,[d,o.$data])),d}function o(e,t,n){return v.isObservable(e)?e():"function"==typeof e?e(t,n):e}function s(e,t){var n=v.utils.domData.get(e,u);n&&"function"==typeof n.dispose&&n.dispose(),v.utils.domData.set(e,u,t&&t.isActive()?t:i)}var a;v.setTemplateEngine=function(e){if(e!=i&&!(e instanceof v.templateEngine))throw new Error("templateEngine must inherit from ko.templateEngine");a=e},v.renderTemplate=function(e,t,s,u,l){if(s=s||{},(s.templateEngine||a)==i)throw new Error("Set a template engine before calling renderTemplate");if(l=l||"replaceChildren",u){var c=n(u),d=function(){return!c||!v.utils.domNodeIsAttachedToDocument(c)},p=c&&"replaceNode"==l?c.parentNode:c;return v.dependentObservable(function(){var i=t&&t instanceof v.bindingContext?t:new v.bindingContext(v.utils.unwrapObservable(t)),a=o(e,i.$data,i),d=r(u,l,a,i,s);"replaceNode"==l&&(u=d,c=n(u))},null,{disposeWhen:d,disposeWhenNodeIsRemoved:p})}return v.memoization.memoize(function(n){v.renderTemplate(e,t,s,n,"replaceNode")})},v.renderTemplateForEach=function(e,n,s,a,u){var l,c=function(t,n){l=u.createChildContext(t,s.as,function(e){e.$index=n});var i=o(e,t,l);return r(null,"ignoreTargetNode",i,l,s)},d=function(e,n){t(n,l),s.afterRender&&s.afterRender(n,e)};return v.dependentObservable(function(){var e=v.utils.unwrapObservable(n)||[];"undefined"==typeof e.length&&(e=[e]);var t=v.utils.arrayFilter(e,function(e){return s.includeDestroyed||e===i||null===e||!v.utils.unwrapObservable(e._destroy)});v.dependencyDetection.ignore(v.utils.setDomNodeChildrenFromArrayMapping,null,[a,t,c,s,d])},null,{disposeWhenNodeIsRemoved:a})};var u=v.utils.domData.nextKey();v.bindingHandlers.template={init:function(e,t){var n=v.utils.unwrapObservable(t());if("string"==typeof n||n.name)v.virtualElements.emptyNode(e);else{var r=v.virtualElements.childNodes(e),i=v.utils.moveCleanedNodesToContainerElement(r);new v.templateSources.anonymousTemplate(e).nodes(i)}return{controlsDescendantBindings:!0}},update:function(e,t,n,r,i){var o,a,u=t(),l=v.utils.unwrapObservable(u),c=!0,d=null;if("string"==typeof l?(a=u,l={}):(a=l.name,"if"in l&&(c=v.utils.unwrapObservable(l["if"])),c&&"ifnot"in l&&(c=!v.utils.unwrapObservable(l.ifnot)),o=v.utils.unwrapObservable(l.data)),"foreach"in l){var p=c&&l.foreach||[];d=v.renderTemplateForEach(a||e,p,l,e,i)}else if(c){var f="data"in l?i.createChildContext(o,l.as):i;d=v.renderTemplate(a||e,f,l,e)}else v.virtualElements.emptyNode(e);s(e,d)}},v.expressionRewriting.bindingRewriteValidators.template=function(e){var t=v.expressionRewriting.parseObjectLiteral(e);return 1==t.length&&t[0].unknown?null:v.expressionRewriting.keyValueArrayContainsKey(t,"name")?null:"This template engine does not support anonymous templates nested within its templates"},v.virtualElements.allowedBindings.template=!0}(),v.exportSymbol("setTemplateEngine",v.setTemplateEngine),v.exportSymbol("renderTemplate",v.renderTemplate),v.utils.findMovesInArrayComparison=function(e,t,n){if(e.length&&t.length){var r,i,o,s,a;for(r=i=0;(!n||n>r)&&(s=e[i]);++i){for(o=0;a=t[o];++o)if(s.value===a.value){s.moved=a.index,a.moved=s.index,t.splice(o,1),r=o=0;break}r+=o}}},v.utils.compareArrays=function(){function e(e,i,o){return o="boolean"==typeof o?{dontLimitMoves:o}:o||{},e=e||[],i=i||[],e.length<=i.length?t(e,i,n,r,o):t(i,e,r,n,o)}function t(e,t,n,r,i){var o,s,a,u,l,c,d=Math.min,p=Math.max,f=[],h=e.length,m=t.length,b=m-h||1,g=h+m+1;for(o=0;h>=o;o++)for(u=a,f.push(a=[]),l=d(m,o+b),c=p(0,o-1),s=c;l>=s;s++)if(s)if(o)if(e[o-1]===t[s-1])a[s]=u[s-1];else{var y=u[s]||g,_=a[s-1]||g;a[s]=d(y,_)+1}else a[s]=s+1;else a[s]=o+1;var w,x=[],k=[],E=[];for(o=h,s=m;o||s;)w=f[o][s]-1,s&&w===f[o][s-1]?k.push(x[x.length]={status:n,value:t[--s],index:s}):o&&w===f[o-1][s]?E.push(x[x.length]={status:r,value:e[--o],index:o}):(--s,--o,i.sparse||x.push({status:"retained",value:t[s]}));return v.utils.findMovesInArrayComparison(k,E,10*h),x.reverse()}var n="added",r="deleted";return e}(),v.exportSymbol("utils.compareArrays",v.utils.compareArrays),function(){function e(e,t,n,r,o){var s=[],a=v.dependentObservable(function(){var i=t(n,o,v.utils.fixUpContinuousNodeArray(s,e))||[];s.length>0&&(v.utils.replaceDomNodes(s,i),r&&v.dependencyDetection.ignore(r,null,[n,i,o])),s.length=0,v.utils.arrayPushAll(s,i)},null,{disposeWhenNodeIsRemoved:e,disposeWhen:function(){return!v.utils.anyDomNodeIsAttachedToDocument(s)}});return{mappedNodes:s,dependentObservable:a.isActive()?a:i}}var t=v.utils.domData.nextKey();v.utils.setDomNodeChildrenFromArrayMapping=function(n,r,o,s,a){function u(e,t){c=h[t],_!==t&&(E[e]=c),c.indexObservable(_++),v.utils.fixUpContinuousNodeArray(c.mappedNodes,n),g.push(c),x.push(c)}function l(e,t){if(e)for(var n=0,r=t.length;r>n;n++)t[n]&&v.utils.arrayForEach(t[n].mappedNodes,function(r){e(r,n,t[n].arrayEntry)})}r=r||[],s=s||{};for(var c,d,p,f=v.utils.domData.get(n,t)===i,h=v.utils.domData.get(n,t)||[],m=v.utils.arrayMap(h,function(e){return e.arrayEntry}),b=v.utils.compareArrays(m,r,s.dontLimitMoves),g=[],y=0,_=0,w=[],x=[],k=[],E=[],O=[],C=0;d=b[C];C++)switch(p=d.moved,d.status){case"deleted":p===i&&(c=h[y],c.dependentObservable&&c.dependentObservable.dispose(),w.push.apply(w,v.utils.fixUpContinuousNodeArray(c.mappedNodes,n)),s.beforeRemove&&(k[C]=c,x.push(c))),y++;break;case"retained":u(C,y++);break;case"added":p!==i?u(C,p):(c={arrayEntry:d.value,indexObservable:v.observable(_++)},g.push(c),x.push(c),f||(O[C]=c))}l(s.beforeMove,E),v.utils.arrayForEach(w,s.beforeRemove?v.cleanNode:v.removeNode);for(var S,T,C=0,N=v.virtualElements.firstChild(n);c=x[C];C++){c.mappedNodes||v.utils.extend(c,e(n,o,c.arrayEntry,a,c.indexObservable));for(var D=0;T=c.mappedNodes[D];N=T.nextSibling,S=T,D++)T!==N&&v.virtualElements.insertAfter(n,T,S);!c.initialized&&a&&(a(c.arrayEntry,c.mappedNodes,c.indexObservable),c.initialized=!0)}l(s.beforeRemove,k),l(s.afterMove,E),l(s.afterAdd,O),v.utils.domData.set(n,t,g)}}(),v.exportSymbol("utils.setDomNodeChildrenFromArrayMapping",v.utils.setDomNodeChildrenFromArrayMapping),v.nativeTemplateEngine=function(){this.allowTemplateRewriting=!1},v.nativeTemplateEngine.prototype=new v.templateEngine,v.nativeTemplateEngine.prototype.constructor=v.nativeTemplateEngine,v.nativeTemplateEngine.prototype.renderTemplateSource=function(e){var t=!(v.utils.ieVersion<9),n=t?e.nodes:null,r=n?e.nodes():null;if(r)return v.utils.makeArray(r.cloneNode(!0).childNodes);var i=e.text();return v.utils.parseHtmlFragment(i)},v.nativeTemplateEngine.instance=new v.nativeTemplateEngine,v.setTemplateEngine(v.nativeTemplateEngine.instance),v.exportSymbol("nativeTemplateEngine",v.nativeTemplateEngine),function(){v.jqueryTmplTemplateEngine=function(){function e(){if(2>n)throw new Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.")}function t(e,t,n){return u.tmpl(e,t,n)}var n=this.jQueryTmplVersion=function(){if(!u||!u.tmpl)return 0;try{if(u.tmpl.tag.tmpl.open.toString().indexOf("__")>=0)return 2}catch(e){}return 1}();this.renderTemplateSource=function(n,r,i){i=i||{},e();var o=n.data("precompiled");if(!o){var a=n.text()||"";a="{{ko_with $item.koBindingContext}}"+a+"{{/ko_with}}",o=u.template(null,a),n.data("precompiled",o)}var l=[r.$data],c=u.extend({koBindingContext:r},i.templateOptions),d=t(o,l,c);return d.appendTo(s.createElement("div")),u.fragments={},d},this.createJavaScriptEvaluatorBlock=function(e){return"{{ko_code ((function() { return "+e+" })()) }}"},this.addTemplate=function(e,t){s.write("<script type='text/html' id='"+e+"'>"+t+"</script>")},n>0&&(u.tmpl.tag.ko_code={open:"__.push($1 || '');"},u.tmpl.tag.ko_with={open:"with($1) {",close:"} "})},v.jqueryTmplTemplateEngine.prototype=new v.templateEngine,v.jqueryTmplTemplateEngine.prototype.constructor=v.jqueryTmplTemplateEngine;var e=new v.jqueryTmplTemplateEngine;e.jQueryTmplVersion>0&&v.setTemplateEngine(e),v.exportSymbol("jqueryTmplTemplateEngine",v.jqueryTmplTemplateEngine)}()})}()}()}])});