/* * Kendo UI Beta v2013.2.716 (http://kendoui.com) * Copyright 2013 Telerik AD. All rights reserved. * * Kendo UI Beta license terms available at * http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx */ ("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.core.min","./kendo.data.odata.min","./kendo.data.xml.min"],function(){!function(e,t){function r(e,t,r,n){return function(i){var a,s={};for(a in i)s[a]=i[a];s.field=n?r+"."+i.field:r,e.trigger(t,s),t==_t&&e._notifyChange&&e._notifyChange(s)}}function n(t,r){if(t===r)return!0;var i,a=e.type(t),s=e.type(r);if(a!==s)return!1;if("date"===a)return t.getTime()===r.getTime();if("object"!==a&&"array"!==a)return!1;for(i in t)if(!n(t[i],r[i]))return!1;return!0}function i(e,t){var r,n;for(n in e){if(r=e[n],et(r)&&r.field&&r.field===t)return r;if(r===t)return r}return null}function a(e){this.data=e||[]}function s(e,r){if(e){var n=typeof e===ft?{field:e,dir:r}:e,i=rt(n)?n:n!==t?[n]:[];return nt(i,function(e){return!!e.dir})}}function o(e){var t,r,n,i,a=e.filters;if(a)for(t=0,r=a.length;r>t;t++)n=a[t],i=n.operator,i&&typeof i===ft&&(n.operator=B[i.toLowerCase()]||i),o(n)}function u(e){return e&&!tt(e)?((rt(e)||!e.filters)&&(e={logic:"and",filters:rt(e)?e:[e]}),o(e),e):t}function l(e){return rt(e)?e:[e]}function f(e,r){var n=typeof e===ft?{field:e,dir:r}:e,i=rt(n)?n:n!==t?[n]:[];return D(i,function(e){return{field:e.field,dir:e.dir||"asc",aggregates:e.aggregates}})}function d(e,t){return e&&e.getTime&&t&&t.getTime?e.getTime()===t.getTime():e===t}function c(e,t,r,n,i){var a,s,o,u,l;for(t=t||[],u=t.length,a=0;u>a;a++)s=t[a],o=s.aggregate,l=s.field,e[l]=e[l]||{},e[l][o]=G[o.toLowerCase()](e[l][o],r,ot.accessor(l),n,i)}function h(e){var t,r=e.length,n=Array(r);for(t=0;r>t;t++)n[t]=e[t].toJSON();return n}function g(e,t){t=t||{};var r=new a(e),n=t.aggregate,i=t.filter;return i&&(r=r.filter(i)),r.aggregate(n)}function p(e,t,r,n,i){var a,s,o,u,l;for(u=0,l=e.length;l>u;u++){a=e[u];for(s in t)o=i[s],o&&o!==s&&(a[o]=t[s](a),delete a[s])}}function _(e,t,r,n,i){var a,s,o,u,l;for(u=0,l=e.length;l>u;u++){a=e[u];for(s in t)a[s]=r._parse(s,t[s](a)),o=i[s],o&&o!==s&&delete a[o]}}function v(e,t,r,n,i){var a,s,o,u;for(s=0,u=e.length;u>s;s++)a=e[s],o=n[a.field],o&&o!=a.field&&(a.field=o),a.value=r._parse(a.field,a.value),a.hasSubgroups?v(a.items,t,r,n,i):_(a.items,t,r,n,i)}function m(e,t,r,n,i,a){return function(s){return s=e(s),s&&!tt(n)&&("[object Array]"===Dt.call(s)||s instanceof Gt||(s=[s]),r(s,n,new t,i,a)),s||[]}}function y(e,t,r,n){for(var i,a,s=0;t.length&&n&&(i=t[s],a=i.items,e&&e.field===i.field&&e.value===i.value?(e.hasSubgroups&&e.items.length?y(e.items[e.items.length-1],i.items,r,n):(a=a.slice(r,n),n-=a.length,e.items=e.items.concat(a)),t.splice(s--,1)):(a=a.slice(r,n),n-=a.length,i.items=a,i.items.length||t.splice(s--,1)),r=0,!(++s>=t.length)););}function S(e){var t,r,n=[];for(t=0,r=e.length;r>t;t++)n=e[t].hasSubgroups?n.concat(S(e[t].items)):n.concat(e[t].items.slice());return n}function w(e,t){var r,n,i,a;if(t)for(r=0,n=e.length;n>r;r++)i=e[r],a=i.items,i.hasSubgroups?w(a,t):!a.length||a[0]instanceof t||(a.type=t,a.wrapAll(a,a))}function b(e,t){var r,n;for(r=0,n=e.length;n>r;r++)if(e[r].hasSubgroups){if(b(e[r].items,t))return!0}else if(t(e[r].items,e[r]))return!0}function k(e,t){var r,n;for(r=0,n=e.length;n>r;r++)if(e[r].uid==t.uid)return t=e[r],e.splice(r,1),t}function x(e,t){var r,n,i,a;for(i=e.length-1,a=0;i>=a;i--)n=e[i],r={value:t.get(n.field),field:n.field,items:r?[r]:[t],hasSubgroups:!!r,aggregates:{}};return r}function q(e,t){return t?z(e,function(e){return e[t.idField]===t.id}):-1}function C(e,t){return t?z(e,function(e){return e.uid==t.uid}):-1}function z(e,t){var r,n;for(r=0,n=e.length;n>r;r++)if(t(e[r]))return r;return-1}function O(e,t){if(e&&!tt(e)){var r=e[t];return et(r)?r.from||r.field||t:e[t]}return t}function F(e,t){var r,n,i,a={};for(i in e)"filters"!==i&&(a[i]=e[i]);if(e.filters&&e.filters.length)for(a.filters=[],r=0,n=e.filters.length;n>r;r++)a.filters[r]=F(e.filters[r],t);else a.field=O(t.fields,a.field);return a}function R(e,t){var r,n,i,a,s,o=[];for(r=0,n=e.length;n>r;r++){i={},a=e[r];for(s in a)i[s]=a[s];i.field=O(t.fields,i.field),i.aggregates&&rt(i.aggregates)&&(i.aggregates=R(i.aggregates,t)),o.push(i)}return o}function P(t,r){var n,i,a,s,o,u=e(t)[0].children,l=[],f=r[0],d=r[1];for(n=0,i=u.length;i>n;n++)a={},o=u[n],o.disabled||(a[f.field]=o.text,s=o.attributes.value,s=s&&s.specified?o.value:o.text,a[d.field]=s,l.push(a));return l}function T(t,r){var n,i,a,s,o,u,l,f=e(t)[0].tBodies[0],d=f?f.rows:[],c=r.length,h=[];for(n=0,i=d.length;i>n;n++){for(o={},l=!0,s=d[n].cells,a=0;c>a;a++)u=s[a],"th"!==u.nodeName.toLowerCase()&&(l=!1,o[r[a].field]=u.innerHTML);l||h.push(o)}return h}function M(e){return function(){var t=this._data,r=U.fn[e].apply(this,Mt.call(arguments));return this._data!=t&&this._attachBubbleHandlers(),r}}function A(t,r){var n,i,a,s,o,u,l,f,d=e(t).children(),c=[],h=r[0].field,g=r[1]&&r[1].field,p=r[2]&&r[2].field,_=r[3]&&r[3].field;for(n=0,i=d.length;i>n;n++)a={_loaded:!0},s=d.eq(n),u=s[0].firstChild,f=s.children(),t=f.filter("ul"),f=f.filter(":not(ul)"),o=s.attr("data-id"),o&&(a.id=o),u&&(a[h]=3==u.nodeType?u.nodeValue:f.text()),g&&(a[g]=f.find("a").attr("href")),_&&(a[_]=f.find("img").attr("src")),p&&(l=f.find(".k-sprite").prop("className"),a[p]=l&&e.trim(l.replace("k-sprite",""))),t.length&&(a.items=A(t.eq(0),r)),"true"==s.attr("data-hasChildren")&&(a.hasChildren=!0),c.push(a);return c}var D,N,j,I,B,G,L,E,H,J,U,V,W,Q,$,K,X=e.extend,Y=e.proxy,Z=e.isFunction,et=e.isPlainObject,tt=e.isEmptyObject,rt=e.isArray,nt=e.grep,it=e.ajax,at=e.each,st=e.noop,ot=window.kendo,ut=ot.Observable,lt=ot.Class,ft="string",dt="function",ct="create",ht="read",gt="update",pt="destroy",_t="change",vt="sync",mt="get",yt="error",St="requestStart",wt="progress",bt="requestEnd",kt=[ct,ht,gt,pt],xt=function(e){return e},qt=ot.getter,Ct=ot.stringify,zt=Math,Ot=[].push,Ft=[].join,Rt=[].pop,Pt=[].splice,Tt=[].shift,Mt=[].slice,At=[].unshift,Dt={}.toString,Nt=ot.support.stableSort,jt=/^\/Date\((.*?)\)\/$/,It=/(\r+|\n+)/g,Bt=/(?=['\\])/g,Gt=ut.extend({init:function(e,t){var r=this;r.type=t||Lt,ut.fn.init.call(r),r.length=e.length,r.wrapAll(e,r)},toJSON:function(){var e,t,r=this.length,n=Array(r);for(e=0;r>e;e++)t=this[e],t instanceof Lt&&(t=t.toJSON()),n[e]=t;return n},parent:st,wrapAll:function(e,t){var r,n,i=this,a=function(){return i};for(t=t||[],r=0,n=e.length;n>r;r++)t[r]=i.wrap(e[r],a);return t},wrap:function(e,t){var r,n=this;return null!==e&&"[object Object]"===Dt.call(e)&&(r=e instanceof n.type||e instanceof Jt,r||(e=e instanceof Lt?e.toJSON():e,e=new n.type(e)),e.parent=t,e.bind(_t,function(e){n.trigger(_t,{field:e.field,node:e.node,index:e.index,items:e.items||[this],action:e.node?e.action||"itemchange":"itemchange"})})),e},push:function(){var e,t=this.length,r=this.wrapAll(arguments);return e=Ot.apply(this,r),this.trigger(_t,{action:"add",index:t,items:r}),e},slice:Mt,join:Ft,pop:function(){var e=this.length,t=Rt.apply(this);return e&&this.trigger(_t,{action:"remove",index:e-1,items:[t]}),t},splice:function(e,t,r){var n,i,a,s=this.wrapAll(Mt.call(arguments,2));if(n=Pt.apply(this,[e,t].concat(s)),n.length)for(this.trigger(_t,{action:"remove",index:e,items:n}),i=0,a=n.length;a>i;i++)n[i].children&&n[i].unbind(_t);return r&&this.trigger(_t,{action:"add",index:e,items:s}),n},shift:function(){var e=this.length,t=Tt.apply(this);return e&&this.trigger(_t,{action:"remove",index:0,items:[t]}),t},unshift:function(){var e,t=this.wrapAll(arguments);return e=At.apply(this,t),this.trigger(_t,{action:"add",index:0,items:t}),e},indexOf:function(e){var t,r,n=this;for(t=0,r=n.length;r>t;t++)if(n[t]===e)return t;return-1},forEach:function(e){for(var t=0,r=this.length;r>t;t++)e(this[t],t,this)},map:function(e){for(var t=0,r=[],n=this.length;n>t;t++)r[t]=e(this[t],t,this);return r},filter:function(e){for(var t,r=0,n=[],i=this.length;i>r;r++)t=this[r],e(t,r,this)&&(n[n.length]=t);return n},find:function(e){for(var t,r=0,n=this.length;n>r;r++)if(t=this[r],e(t,r,this))return t},every:function(e){for(var t,r=0,n=this.length;n>r;r++)if(t=this[r],!e(t,r,this))return!1;return!0},some:function(e){for(var t,r=0,n=this.length;n>r;r++)if(t=this[r],e(t,r,this))return!0;return!1},remove:function(e){this.splice(this.indexOf(e),1)}}),Lt=ut.extend({init:function(e){var t,r,n=this,i=function(){return n};ut.fn.init.call(this);for(r in e)t=e[r],"_"!=r.charAt(0)&&(t=n.wrap(t,r,i)),n[r]=t;n.uid=ot.guid()},shouldSerialize:function(e){return this.hasOwnProperty(e)&&"_events"!==e&&typeof this[e]!==dt&&"uid"!==e},forEach:function(e){for(var t in this)this.shouldSerialize(t)&&e(this[t],t)},toJSON:function(){var e,t,r={};for(t in this)this.shouldSerialize(t)&&(e=this[t],(e instanceof Lt||e instanceof Gt)&&(e=e.toJSON()),r[t]=e);return r},get:function(e){var t,r=this;return r.trigger(mt,{field:e}),t="this"===e?r:ot.getter(e,!0)(r)},_set:function(e,t){var r,n,i,a=this,s=e.indexOf(".")>=0;if(s)for(r=e.split("."),n="";r.length>1;){if(n+=r.shift(),i=ot.getter(n,!0)(a),i instanceof Lt)return i.set(r.join("."),t),s;n+="."}return ot.setter(e)(a,t),s},set:function(e,t){var r=this,n=ot.getter(e,!0)(r);n!==t&&(r.trigger("set",{field:e,value:t})||(!r._set(e,r.wrap(t,e,function(){return r}))||e.indexOf("(")>=0||e.indexOf("[")>=0)&&r.trigger(_t,{field:e}))},parent:st,wrap:function(e,t,n){var i,a,s=this,o=Dt.call(e);return null==e||"[object Object]"!==o&&"[object Array]"!==o||(i=e instanceof Gt,a=e instanceof U,"[object Object]"!==o||a||i?("[object Array]"===o||i||a)&&(i||a||(e=new Gt(e)),e.parent()!=n()&&e.bind(_t,r(s,_t,t,!1))):(e instanceof Lt||(e=new Lt(e)),e.parent()!=n()&&(e.bind(mt,r(s,mt,t,!0)),e.bind(_t,r(s,_t,t,!0)))),e.parent=n),e}}),Et={number:function(e){return ot.parseFloat(e)},date:function(e){return ot.parseDate(e)},"boolean":function(e){return typeof e===ft?"true"===e.toLowerCase():null!=e?!!e:e},string:function(e){return null!=e?e+"":e},"default":function(e){return e}},Ht={string:"",number:0,date:new Date,"boolean":!1,"default":""},Jt=Lt.extend({init:function(r){var n=this;(!r||e.isEmptyObject(r))&&(r=e.extend({},n.defaults,r)),Lt.fn.init.call(n,r),n.dirty=!1,n.idField&&(n.id=n.get(n.idField),n.id===t&&(n.id=n._defaultId))},shouldSerialize:function(e){return Lt.fn.shouldSerialize.call(this,e)&&"uid"!==e&&!("id"!==this.idField&&"id"===e)&&"dirty"!==e&&"_accessors"!==e},_parse:function(e,t){var r,n=this,a=e,s=n.fields||{};return e=s[e],e||(e=i(s,a)),e&&(r=e.parse,!r&&e.type&&(r=Et[e.type.toLowerCase()])),r?r(t):t},_notifyChange:function(e){var t=e.action;("add"==t||"remove"==t)&&(this.dirty=!0)},editable:function(e){return e=(this.fields||{})[e],e?e.editable!==!1:!0},set:function(e,t,r){var i=this;i.editable(e)&&(t=i._parse(e,t),n(t,i.get(e))||(i.dirty=!0,Lt.fn.set.call(i,e,t,r)))},accept:function(e){var t,r=this,n=function(){return r};for(t in e)r._set(t,r.wrap(e[t],t,n));r.idField&&(r.id=r.get(r.idField)),r.dirty=!1},isNew:function(){return this.id===this._defaultId}});Jt.define=function(e,r){r===t&&(r=e,e=Jt);var n,i,a,s,o,u,l,f,d=X({defaults:{}},r),c={},h=d.id;if(h&&(d.idField=h),d.id&&delete d.id,h&&(d.defaults[h]=d._defaultId=""),"[object Array]"===Dt.call(d.fields)){for(u=0,l=d.fields.length;l>u;u++)a=d.fields[u],typeof a===ft?c[a]={}:a.field&&(c[a.field]=a);d.fields=c}for(i in d.fields)a=d.fields[i],s=a.type||"default",o=null,f=i,i=typeof a.field===ft?a.field:i,a.nullable||(o=d.defaults[f!==i?f:i]=a.defaultValue!==t?a.defaultValue:Ht[s.toLowerCase()]),r.id===i&&(d._defaultId=o),d.defaults[f!==i?f:i]=o,a.parse=a.parse||Et[s];return n=e.extend(d),n.define=function(e){return Jt.define(n,e)},d.fields&&(n.fields=d.fields,n.idField=d.idField),n},N={selector:function(e){return Z(e)?e:qt(e)},compare:function(e){var t=this.selector(e);return function(e,r){return e=t(e),r=t(r),null==e&&null==r?0:null==e?-1:null==r?1:e.localeCompare?e.localeCompare(r):e>r?1:r>e?-1:0}},create:function(e){var t=e.compare||this.compare(e.field);return"desc"==e.dir?function(e,r){return t(r,e,!0)}:t},combine:function(e){return function(t,r){var n,i,a=e[0](t,r);for(n=1,i=e.length;i>n;n++)a=a||e[n](t,r);return a}}},j=X({},N,{asc:function(e){var t=this.selector(e);return function(e,r){var n=t(e),i=t(r);return n&&n.getTime&&i&&i.getTime&&(n=n.getTime(),i=i.getTime()),n===i?e.__position-r.__position:null==n?-1:null==i?1:n.localeCompare?n.localeCompare(i):n>i?1:-1}},desc:function(e){var t=this.selector(e);return function(e,r){var n=t(e),i=t(r);return n&&n.getTime&&i&&i.getTime&&(n=n.getTime(),i=i.getTime()),n===i?e.__position-r.__position:null==n?1:null==i?-1:i.localeCompare?i.localeCompare(n):i>n?1:-1}},create:function(e){return this[e.dir](e.field)}}),D=function(e,t){var r,n=e.length,i=Array(n);for(r=0;n>r;r++)i[r]=t(e[r],r,e);return i},I=function(){function e(e){return e.replace(Bt,"\\").replace(It,"")}function t(t,r,n,i){var a;return null!=n&&(typeof n===ft&&(n=e(n),a=jt.exec(n),a?n=new Date(+a[1]):i?(n="'"+n.toLowerCase()+"'",r="("+r+" || '').toLowerCase()"):n="'"+n+"'"),n.getTime&&(r="("+r+"?"+r+".getTime():"+r+")",n=n.getTime())),r+" "+t+" "+n}return{eq:function(e,r,n){return t("==",e,r,n)},neq:function(e,r,n){return t("!=",e,r,n)},gt:function(e,r,n){return t(">",e,r,n)},gte:function(e,r,n){return t(">=",e,r,n)},lt:function(e,r,n){return t("<",e,r,n)},lte:function(e,r,n){return t("<=",e,r,n)},startswith:function(t,r,n){return n&&(t="("+t+" || '').toLowerCase()",r&&(r=r.toLowerCase())),r&&(r=e(r)),t+".lastIndexOf('"+r+"', 0) == 0"},endswith:function(t,r,n){return n&&(t="("+t+" || '').toLowerCase()",r&&(r=r.toLowerCase())),r&&(r=e(r)),t+".indexOf('"+r+"', "+t+".length - "+(r||"").length+") >= 0"},contains:function(t,r,n){return n&&(t="("+t+" || '').toLowerCase()",r&&(r=r.toLowerCase())),r&&(r=e(r)),t+".indexOf('"+r+"') >= 0"},doesnotcontain:function(t,r,n){return n&&(t="("+t+" || '').toLowerCase()",r&&(r=r.toLowerCase())),r&&(r=e(r)),t+".indexOf('"+r+"') == -1"}}}(),a.filterExpr=function(e){var r,n,i,s,o,u,l=[],f={and:" && ",or:" || "},d=[],c=[],h=e.filters;for(r=0,n=h.length;n>r;r++)i=h[r],o=i.field,u=i.operator,i.filters?(s=a.filterExpr(i),i=s.expression.replace(/__o\[(\d+)\]/g,function(e,t){return t=+t,"__o["+(c.length+t)+"]"}).replace(/__f\[(\d+)\]/g,function(e,t){return t=+t,"__f["+(d.length+t)+"]"}),c.push.apply(c,s.operators),d.push.apply(d,s.fields)):(typeof o===dt?(s="__f["+d.length+"](d)",d.push(o)):s=ot.expr(o),typeof u===dt?(i="__o["+c.length+"]("+s+", "+i.value+")",c.push(u)):i=I[(u||"eq").toLowerCase()](s,i.value,i.ignoreCase!==t?i.ignoreCase:!0)),l.push(i);return{expression:"("+l.join(f[e.logic])+")",fields:d,operators:c}},B={"==":"eq",equals:"eq",isequalto:"eq",equalto:"eq",equal:"eq","!=":"neq",ne:"neq",notequals:"neq",isnotequalto:"neq",notequalto:"neq",notequal:"neq","<":"lt",islessthan:"lt",lessthan:"lt",less:"lt","<=":"lte",le:"lte",islessthanorequalto:"lte",lessthanequal:"lte",">":"gt",isgreaterthan:"gt",greaterthan:"gt",greater:"gt",">=":"gte",isgreaterthanorequalto:"gte",greaterthanequal:"gte",ge:"gte",notsubstringof:"doesnotcontain"},a.normalizeFilter=u,a.prototype={toArray:function(){return this.data},range:function(e,t){return new a(this.data.slice(e,e+t))},skip:function(e){return new a(this.data.slice(e))},take:function(e){return new a(this.data.slice(0,e))},select:function(e){return new a(D(this.data,e))},order:function(e,t){var r={dir:t};return e&&(e.compare?r.compare=e.compare:r.field=e),new a(this.data.slice(0).sort(N.create(r)))},orderBy:function(e){return this.order(e,"asc")},orderByDescending:function(e){return this.order(e,"desc")},sort:function(e,t,r){var n,i,a=s(e,t),o=[];if(r=r||N,a.length){for(n=0,i=a.length;i>n;n++)o.push(r.create(a[n]));return this.orderBy({compare:r.combine(o)})}return this},filter:function(e){var t,r,n,i,s,o,l,f,d=this.data,c=[];if(e=u(e),!e||0===e.filters.length)return this;for(i=a.filterExpr(e),o=i.fields,l=i.operators,s=f=Function("d, __f, __o","return "+i.expression),(o.length||l.length)&&(f=function(e){return s(e,o,l)}),t=0,n=d.length;n>t;t++)r=d[t],f(r)&&c.push(r);return new a(c)},group:function(e,t){e=f(e||[]),t=t||this.data;var r,n=this,i=new a(n.data);return e.length>0&&(r=e[0],i=i.groupBy(r).select(function(n){var i=new a(t).filter([{field:n.field,operator:"eq",value:n.value}]);return{field:n.field,value:n.value,items:e.length>1?new a(n.items).group(e.slice(1),i.toArray()).toArray():n.items,hasSubgroups:e.length>1,aggregates:i.aggregate(r.aggregates)}})),i},groupBy:function(e){if(tt(e)||!this.data.length)return new a([]);var t,r,n,i,s=e.field,o=this._sortForGrouping(s,e.dir||"asc"),u=ot.accessor(s),l=u.get(o[0],s),f={field:s,value:l,items:[]},c=[f];for(n=0,i=o.length;i>n;n++)t=o[n],r=u.get(t,s),d(l,r)||(l=r,f={field:s,value:l,items:[]},c.push(f)),f.items.push(t);return new a(c)},_sortForGrouping:function(e,t){var r,n,i=this.data;if(!Nt){for(r=0,n=i.length;n>r;r++)i[r].__position=r;for(i=new a(i).sort(e,t,j).toArray(),r=0,n=i.length;n>r;r++)delete i[r].__position;return i}return this.sort(e,t).toArray()},aggregate:function(e){var t,r,n={};if(e&&e.length)for(t=0,r=this.data.length;r>t;t++)c(n,e,this.data[t],t,r);return n}},G={sum:function(e,t,r){return(e||0)+r.get(t)},count:function(e){return(e||0)+1},average:function(e,t,r,n,i){return e=(e||0)+r.get(t),n==i-1&&(e/=i),e},max:function(e,t,r){var n=r.get(t);return e=e||0,n>e&&(e=n),e},min:function(e,t,r){var n=r.get(t);return e=e||n,e>n&&(e=n),e}},a.process=function(e,r){r=r||{};var n,i=new a(e),o=r.group,u=f(o||[]).concat(s(r.sort||[])),l=r.filter,d=r.skip,c=r.take;return l&&(i=i.filter(l),n=i.toArray().length),u&&(i=i.sort(u),o&&(e=i.toArray())),d!==t&&c!==t&&(i=i.range(d,c)),o&&(i=i.group(o,e)),{total:n,data:i.toArray()}},L=lt.extend({init:function(e){this.data=e.data},read:function(e){e.success(this.data)},update:function(e){e.success(e.data)},create:function(e){e.success(e.data)},destroy:function(e){e.success(e.data)}}),E=lt.extend({init:function(e){var t,r=this;e=r.options=X({},r.options,e),at(kt,function(t,r){typeof e[r]===ft&&(e[r]={url:e[r]})}),r.cache=e.cache?H.create(e.cache):{find:st,add:st},t=e.parameterMap,r.parameterMap=Z(t)?t:function(e){var r={};return at(e,function(e,n){e in t&&(e=t[e],et(e)&&(n=e.value(n),e=e.key)),r[e]=n}),r}},options:{parameterMap:xt},create:function(e){return it(this.setup(e,ct))},read:function(r){var n,i,a,s=this,o=s.cache;r=s.setup(r,ht),n=r.success||st,i=r.error||st,a=o.find(r.data),a!==t?n(a):(r.success=function(e){o.add(r.data,e),n(e)},e.ajax(r))},update:function(e){return it(this.setup(e,gt))},destroy:function(e){return it(this.setup(e,pt))},setup:function(e,t){e=e||{};var r,n=this,i=n.options[t],a=Z(i.data)?i.data(e.data):i.data;return e=X(!0,{},i,e),r=X(!0,{},a,e.data),e.data=n.parameterMap(r,t),Z(e.url)&&(e.url=e.url(r)),e}}),H=lt.extend({init:function(){this._store={}},add:function(e,r){e!==t&&(this._store[Ct(e)]=r)},find:function(e){return this._store[Ct(e)]},clear:function(){this._store={}},remove:function(e){delete this._store[Ct(e)]}}),H.create=function(e){var t={inmemory:function(){return new H}};return et(e)&&Z(e.find)?e:e===!0?new H:t[e]()},J=lt.extend({init:function(e){var t,r,n,i,a,s,o,u,l,f,d,c,h,g=this;e=e||{};for(t in e)r=e[t],g[t]=typeof r===ft?qt(r):r;i=e.modelBase||Jt,et(g.model)&&(g.model=n=i.define(g.model)),g.model&&(s=Y(g.data,g),o=Y(g.groups,g),u=Y(g.serialize,g),l={},f={},d={},c={},h=!1,n=g.model,n.fields&&(at(n.fields,function(e,t){var r;a=e,et(t)&&t.field?a=t.field:typeof t===ft&&(a=t),et(t)&&t.from&&(r=t.from),h=h||r&&r!==e||a!==e,f[e]=qt(r||a),d[e]=qt(e),l[r||a]=e,c[e]=r||a}),!e.serialize&&h&&(g.serialize=m(u,n,p,d,l,c))),g.data=m(s,n,_,f,l,c),g.groups=m(o,n,v,f,l,c))},errors:function(e){return e?e.errors:null},parse:xt,data:xt,total:function(e){return e.length},groups:xt,aggregates:function(){return{}},serialize:function(e){return e}}),U=ut.extend({init:function(e){var r,n,i=this;e&&(n=e.data),e=i.options=X({},i.options,e),i._map={},i._prefetch={},i._data=[],i._pristineData=[],i._ranges=[],i._view=[],i._pristine=[],i._destroyed=[],i._pageSize=e.pageSize,i._page=e.page||(e.pageSize?1:t),i._sort=s(e.sort),i._filter=u(e.filter),i._group=f(e.group),i._aggregate=e.aggregate,i._total=e.total,ut.fn.init.call(i),i.transport=V.create(e,n),i.reader=new ot.data.readers[e.schema.type||"json"](e.schema),r=i.reader.model||{},i._data=i._observe(i._data),i.bind([yt,_t,St,vt,bt,wt],e)},options:{data:[],schema:{modelBase:Jt},serverSorting:!1,serverPaging:!1,serverFiltering:!1,serverGrouping:!1,serverAggregates:!1,batch:!1},_isServerGrouped:function(){var e=this.group()||[];return this.options.serverGrouping&&e.length},_flatData:function(e){return this._isServerGrouped()?S(e):e},parent:st,get:function(e){var t,r,n=this._flatData(this._data);for(t=0,r=n.length;r>t;t++)if(n[t].id==e)return n[t]},getByUid:function(e){var t,r,n=this._flatData(this._data);if(n)for(t=0,r=n.length;r>t;t++)if(n[t].uid==e)return n[t]},indexOf:function(e){return C(this._data,e)},at:function(e){return this._data[e]},data:function(e){var r=this;return e===t?r._data:(r._data=this._observe(e),r._ranges=[],r._addRange(r._data),r._total=r._data.length,r._process(r._data),t)},view:function(){return this._view},add:function(e){return this.insert(this._data.length,e)},_createNewModel:function(e){return this.reader.model?new this.reader.model(e):new Lt(e)},insert:function(e,t){return t||(t=e,e=0),t instanceof Jt||(t=this._createNewModel(t)),this._isServerGrouped()?this._data.splice(e,0,x(this.group(),t)):this._data.splice(e,0,t),t},remove:function(e){var r,n=this,i=n._isServerGrouped();return this._eachItem(n._data,function(a){return r=k(a,e),r&&i?(r.isNew&&r.isNew()||n._destroyed.push(r),!0):t}),e},sync:function(){var t,r,n,i=this,a=[],s=[],o=i._destroyed,u=i._flatData(i._data);if(i.reader.model){for(t=0,r=u.length;r>t;t++)u[t].isNew()?a.push(u[t]):u[t].dirty&&s.push(u[t]);n=i._send("create",a),n.push.apply(n,i._send("update",s)),n.push.apply(n,i._send("destroy",o)),e.when.apply(null,n).then(function(){var e,t;for(e=0,t=arguments.length;t>e;e++)i._accept(arguments[e]);i._change({action:"sync"}),i.trigger(vt)})}},cancelChanges:function(e){var t=this;e instanceof ot.data.Model?t._cancelModel(e):(t._destroyed=[],t._data=t._observe(t._pristineData),t.options.serverPaging&&(t._total=t.reader.total(t._pristine)),t._change())},hasChanges:function(){var e,t,r=this._data;if(this._destroyed.length)return!0;for(e=0,t=r.length;t>e;e++)if(r[e].isNew()||r[e].dirty)return!0;return!1},_accept:function(t){var r,n=this,i=t.models,a=t.response,s=0,o=n._isServerGrouped(),u=n._pristineData,l=t.type;if(n.trigger(bt,{response:a,type:l}),a&&!tt(a)){if(a=n.reader.parse(a),n._handleCustomErrors(a))return;a=n.reader.data(a),e.isArray(a)||(a=[a])}else a=e.map(i,function(e){return e.toJSON()});for("destroy"===l&&(n._destroyed=[]),s=0,r=i.length;r>s;s++)"destroy"!==l?(i[s].accept(a[s]),"create"===l?u.push(o?x(n.group(),i[s]):a[s]):"update"===l&&n._updatePristineForModel(i[s],a[s])):n._removePristineForModel(i[s])},_updatePristineForModel:function(e,t){this._executeOnPristineForModel(e,function(e,r){ot.deepExtend(r[e],t)})},_executeOnPristineForModel:function(e,r){this._eachPristineItem(function(n){var i=q(n,e);return i>-1?(r(i,n),!0):t})},_removePristineForModel:function(e){this._executeOnPristineForModel(e,function(e,t){t.splice(e,1)})},_readData:function(e){var t=this._isServerGrouped()?this.reader.groups:this.reader.data;return t(e)},_eachPristineItem:function(e){this._eachItem(this._pristineData,e)},_eachItem:function(e,t){e&&e.length&&(this._isServerGrouped()?b(e,t):t(e))},_pristineForModel:function(e){var r,n,i=function(i){return n=q(i,e),n>-1?(r=i[n],!0):t};return this._eachPristineItem(i),r},_cancelModel:function(e){var t,r=this._pristineForModel(e);this._eachItem(this._data,function(n){t=C(n,e),-1!=t&&(!e.isNew()&&r?n[t].accept(r):n.splice(t,1))})},_promise:function(t,r,n){var i=this,a=i.transport;return e.Deferred(function(e){i.trigger(St),a[n].call(a,X({success:function(t){e.resolve({response:t,models:r,type:n})},error:function(t,r,n){e.reject(t),i.error(t,r,n)}},t))}).promise()},_send:function(e,t){var r,n,i=this,a=[],s=i.reader.serialize(h(t));if(i.options.batch)t.length&&a.push(i._promise({data:{models:s}},t,e));else for(r=0,n=t.length;n>r;r++)a.push(i._promise({data:s[r]},[t[r]],e));return a},read:function(e){var t=this,r=t._params(e);t._queueRequest(r,function(){t.trigger(St)?t._dequeueRequest():(t.trigger(wt),t._ranges=[],t.transport.read({data:r,success:Y(t.success,t),error:Y(t.error,t)}))})},success:function(r){var n=this,i=n.options;return n.trigger(bt,{response:r,type:"read"}),r=n.reader.parse(r),n._handleCustomErrors(r)?(n._dequeueRequest(),t):(n._pristine=et(r)?e.extend(!0,{},r):r.slice?r.slice(0):r,n._total=n.reader.total(r),n._aggregate&&i.serverAggregates&&(n._aggregateResult=n.reader.aggregates(r)),r=n._readData(r),n._pristineData=r.slice(0),n._data=n._observe(r),n._addRange(n._data),n._process(n._data),n._dequeueRequest(),t)},_addRange:function(e){var t=this,r=t._skip||0,n=r+t._flatData(e).length;t._ranges.push({start:r,end:n,data:e}),t._ranges.sort(function(e,t){return e.start-t.start})},error:function(e,t,r){this._dequeueRequest(),this.trigger(bt,{}),this.trigger(yt,{xhr:e,status:t,errorThrown:r})},_params:function(e){var t=this,r=X({take:t.take(),skip:t.skip(),page:t.page(),pageSize:t.pageSize(),sort:t._sort,filter:t._filter,group:t._group,aggregate:t._aggregate},e);return t.options.serverPaging||(delete r.take,delete r.skip,delete r.page,delete r.pageSize),t.options.serverGrouping?t.reader.model&&r.group&&(r.group=R(r.group,t.reader.model)):delete r.group,t.options.serverFiltering?t.reader.model&&r.filter&&(r.filter=F(r.filter,t.reader.model)):delete r.filter,t.options.serverSorting?t.reader.model&&r.sort&&(r.sort=R(r.sort,t.reader.model)):delete r.sort,t.options.serverAggregates?t.reader.model&&r.aggregate&&(r.aggregate=R(r.aggregate,t.reader.model)):delete r.aggregate,r},_queueRequest:function(e,r){var n=this;n._requestInProgress?n._pending={callback:Y(r,n),options:e}:(n._requestInProgress=!0,n._pending=t,r())},_dequeueRequest:function(){var e=this;e._requestInProgress=!1,e._pending&&e._queueRequest(e._pending.options,e._pending.callback)},_handleCustomErrors:function(e){if(this.reader.errors){var t=this.reader.errors(e);if(t)return this.trigger(yt,{xhr:null,status:"customerror",errorThrown:"custom error",errors:t}),!0}return!1},_observe:function(e){var t=this,r=t.reader.model,n=!1;return r&&e.length&&(n=!(e[0]instanceof r)),e instanceof Gt?n&&(e.type=t.reader.model,e.wrapAll(e,e)):(e=new Gt(e,t.reader.model),e.parent=function(){return t.parent()}),t._isServerGrouped()&&w(e,r),t._changeHandler&&t._data&&t._data instanceof Gt?t._data.unbind(_t,t._changeHandler):t._changeHandler=Y(t._change,t),e.bind(_t,t._changeHandler)},_change:function(e){var t,r,n,i=this,a=e?e.action:"";if("remove"===a)for(t=0,r=e.items.length;r>t;t++)e.items[t].isNew&&e.items[t].isNew()||i._destroyed.push(e.items[t]);!i.options.autoSync||"add"!==a&&"remove"!==a&&"itemchange"!==a?(n=i._total||i.reader.total(i._pristine),"add"===a?n+=e.items.length:"remove"===a?n-=e.items.length:"itemchange"===a||"sync"===a||i.options.serverPaging||(n=i.reader.total(i._pristine)),i._total=n,i._process(i._data,e)):i.sync()},_process:function(e,r){var n,i=this,s={};i.options.serverPaging!==!0&&(s.skip=i._skip,s.take=i._take||i._pageSize,s.skip===t&&i._page!==t&&i._pageSize!==t&&(s.skip=(i._page-1)*i._pageSize)),i.options.serverSorting!==!0&&(s.sort=i._sort),i.options.serverFiltering!==!0&&(s.filter=i._filter),i.options.serverGrouping!==!0&&(s.group=i._group),i.options.serverAggregates!==!0&&(s.aggregate=i._aggregate,i._aggregateResult=g(e,s)),n=a.process(e,s),i._view=n.data,n.total===t||i.options.serverFiltering||(i._total=n.total),r=r||{},r.items=r.items||i._view,i.trigger(_t,r)},_mergeState:function(e){var r=this;return e!==t&&(r._pageSize=e.pageSize,r._page=e.page,r._sort=e.sort,r._filter=e.filter,r._group=e.group,r._aggregate=e.aggregate,r._skip=e.skip,r._take=e.take,r._skip===t&&(r._skip=r.skip(),e.skip=r.skip()),r._take===t&&r._pageSize!==t&&(r._take=r._pageSize,e.take=r._take),e.sort&&(r._sort=e.sort=s(e.sort)),e.filter&&(r._filter=e.filter=u(e.filter)),e.group&&(r._group=e.group=f(e.group)),e.aggregate&&(r._aggregate=e.aggregate=l(e.aggregate))),e},query:function(e){var r,n=this,i=n.options.serverSorting||n.options.serverPaging||n.options.serverFiltering||n.options.serverGrouping||n.options.serverAggregates;i||(n._data===t||0===n._data.length)&&!n._destroyed.length?n.read(n._mergeState(e)):n.trigger(St)||(n.trigger(wt),r=a.process(n._data,n._mergeState(e)),n.options.serverFiltering||(n._total=r.total!==t?r.total:n._data.length),n._view=r.data,n._aggregateResult=g(n._data,e),n.trigger(bt,{}),n.trigger(_t,{items:r.data}))},fetch:function(t){var r=this;return e.Deferred(function(e){var n=function(n){r.unbind(yt,i),e.resolve(),t&&t.call(r,n)},i=function(t){e.reject(t)};r.one(_t,n),r.one(yt,i),r._query()}).promise()},_query:function(e){var t=this;t.query(X({},{page:t.page(),pageSize:t.pageSize(),sort:t.sort(),filter:t.filter(),group:t.group(),aggregate:t.aggregate()},e))},next:function(e){var r=this,n=r.page(),i=r.total();return e=e||{},!n||i&&n+1>r.totalPages()?t:(r._skip=n*r.take(),n+=1,e.page=n,r._query(e),n)},prev:function(e){var r=this,n=r.page();return e=e||{},n&&1!==n?(r._skip=r._skip-r.take(),n-=1,e.page=n,r._query(e),n):t},page:function(e){var r,n=this;return e!==t?(e=zt.max(zt.min(zt.max(e,1),n.totalPages()),1),n._query({page:e}),t):(r=n.skip(),r!==t?zt.round((r||0)/(n.take()||1))+1:t)},pageSize:function(e){var r=this;return e!==t?(r._query({pageSize:e,page:1}),t):r.take()},sort:function(e){var r=this;return e!==t?(r._query({sort:e}),t):r._sort},filter:function(e){var r=this;return e===t?r._filter:(r._query({filter:e,page:1}),t)},group:function(e){var r=this;return e!==t?(r._query({group:e}),t):r._group},total:function(){return this._total||0},aggregate:function(e){var r=this;return e!==t?(r._query({aggregate:e}),t):r._aggregate},aggregates:function(){return this._aggregateResult},totalPages:function(){var e=this,t=e.pageSize()||e.total();return zt.ceil((e.total()||0)/t)},inRange:function(e,t){var r=this,n=zt.min(e+t,r.total());return!r.options.serverPaging&&r.data.length>0?!0:r._findRange(e,n).length>0},lastRange:function(){var e=this._ranges;return e[e.length-1]||{start:0,end:0,data:[]}},firstItemUid:function(){var e=this._ranges;return e.length&&e[0].data.length&&e[0].data[0].uid},range:function(e,r){var n,i,a,s,o,u,l;if(e=zt.min(e||0,this.total()),i=this,a=zt.max(zt.floor(e/r),0)*r,s=zt.min(a+r,i.total()),n=i._findRange(e,zt.min(e+r,i.total())),n.length){i._skip=e>i.skip()?zt.min(s,(i.totalPages()-1)*i.take()):a,i._take=r,o=i.options.serverPaging,u=i.options.serverSorting,l=i.options.serverFiltering;try{i.options.serverPaging=!0,i.options.serverSorting=!0,i.options.serverFiltering=!0,o&&(i._data=n=i._observe(n)),i._process(n)}finally{i.options.serverPaging=o,i.options.serverSorting=u,i.options.serverFiltering=l}}else r!==t&&(i._rangeExists(a,s)?e>a&&i.prefetch(s,r,function(){i.range(e,r)}):i.prefetch(a,r,function(){e>a&&si;i++)if(n=y[i],e>=n.start&&e<=n.end){for(p=0,o=i;_>o;o++)if(n=y[o],g=m._flatData(n.data),g.length&&e+p>=n.start&&(d=n.data,c=n.end,b||(v=f(m.group()||[]).concat(s(m.sort()||[])),h=a.process(n.data,{sort:v,filter:m.filter()}),g=d=h.data,h.total!==t&&(c=h.total)),u=0,e+p>n.start&&(u=e+p-n.start),l=g.length,c>r&&(l-=c-r),p+=l-u,S=m._mergeGroups(S,d,u,l),r<=n.end&&p==r-e))return S;break}return[]},_mergeGroups:function(e,t,r,n){if(this._isServerGrouped()){var i,a=t.toJSON();return e.length&&(i=e[e.length-1]),y(i,a,r,n),e.concat(a)}return e.concat(t.slice(r,n))},skip:function(){var e=this;return e._skip===t?e._page!==t?(e._page-1)*(e.take()||1):t:e._skip},take:function(){return this._take||this._pageSize},_prefetchSuccessHandler:function(e,t,r){var n=this; return function(i){var a,s,o=!1,u={start:e,end:t,data:[]};for(n._dequeueRequest(),a=0,s=n._ranges.length;s>a;a++)if(n._ranges[a].start===e){o=!0,u=n._ranges[a];break}o||n._ranges.push(u),n.trigger(bt,{response:i,type:"read"}),i=n.reader.parse(i),u.data=n._observe(n._readData(i)),u.end=u.start+n._flatData(u.data).length,n._ranges.sort(function(e,t){return e.start-t.start}),n._total=n.reader.total(i),r&&r()}},prefetch:function(e,t,r){var n=this,i=zt.min(e+t,n.total()),a={take:t,skip:e,page:e/t+1,pageSize:t,sort:n._sort,filter:n._filter,group:n._group,aggregate:n._aggregate};n._rangeExists(e,i)?r&&r():(clearTimeout(n._timeout),n._timeout=setTimeout(function(){n._queueRequest(a,function(){n.trigger(St)?n._dequeueRequest():n.transport.read({data:a,success:n._prefetchSuccessHandler(e,i,r)})})},100))},_rangeExists:function(e,t){var r,n,i=this,a=i._ranges;for(r=0,n=a.length;n>r;r++)if(a[r].start<=e&&a[r].end>=t)return!0;return!1}}),V={},V.create=function(e,t){var r,n=e.transport;return n?(n.read=typeof n.read===ft?{url:n.read}:n.read,e.type&&(ot.data.transports[e.type]&&!et(ot.data.transports[e.type])?r=new ot.data.transports[e.type](X(n,{data:t})):n=X(!0,{},ot.data.transports[e.type],n),e.schema=X(!0,{},ot.data.schemas[e.type],e.schema)),r||(r=Z(n.read)?n:new E(n))):r=new L({data:e.data}),r},U.create=function(e){e=e&&e.push?{data:e}:e;var t,r,n,i=e||{},a=i.data,s=i.fields,o=i.table,u=i.select,l={};if(a||!s||i.transport||(o?a=T(o,s):u&&(a=P(u,s))),ot.data.Model&&s&&(!i.schema||!i.schema.model)){for(t=0,r=s.length;r>t;t++)n=s[t],n.type&&(l[n.field]=n);tt(l)||(i.schema=X(!0,i.schema,{model:{fields:l}}))}return i.data=a,i instanceof U?i:new U(i)},W=Jt.define({init:function(e){var t,r=this,n=r.hasChildren||e&&e.hasChildren,i="items",a={};ot.data.Model.fn.init.call(r,e),typeof r.children===ft&&(i=r.children),a={schema:{data:i,model:{hasChildren:n,id:r.idField}}},typeof r.children!==ft&&X(a,r.children),t=a.transport,t&&(t.parameterMap=function(e){return r.parentParameterMap&&(e=r.parentParameterMap.call(this,e)),e[r.idField||"id"]=r.id,e}),a.data=e,n||(n=a.schema.data),typeof n===ft&&(n=ot.getter(n)),Z(n)&&(r.hasChildren=!!n.call(r,r)),r._childrenOptions=a,r.hasChildren&&r._initChildren(),r._loaded=!(!e||!e[i]&&!e._loaded)},_initChildren:function(){var e=this;e.children instanceof Q||(e.children=new Q(e._childrenOptions),e.children.parent=function(){return e},e.children.bind(_t,function(t){t.node=t.node||e,e.trigger(_t,t)}),e.children.bind(yt,function(t){var r=e.parent();r&&(t.node=t.node||e,r.trigger(yt,t))}),e._updateChildrenField())},append:function(e){this._initChildren(),this.loaded(!0),this.children.add(e)},hasChildren:!1,level:function(){for(var e=this.parentNode(),t=0;e&&e.parentNode;)t++,e=e.parentNode?e.parentNode():null;return t},_updateChildrenField:function(){var e=this._childrenOptions.schema.data;this[e||"items"]=this.children.data()},load:function(){var e=this,r={};e.hasChildren&&(e._initChildren(),r[e.idField||"id"]=e.id,e._loaded||(e.children._data=t),e.children.one(_t,function(){e._loaded=!0,e._updateChildrenField()})._query(r))},parentNode:function(){var e=this.parent();return e.parent()},loaded:function(e){return e===t?this._loaded:(this._loaded=e,t)},shouldSerialize:function(e){return Jt.fn.shouldSerialize.call(this,e)&&"children"!==e&&"_loaded"!==e&&"hasChildren"!==e&&"_childrenOptions"!==e}}),Q=U.extend({init:function(e){var t=W.define({children:e});U.fn.init.call(this,X(!0,{},{schema:{modelBase:t,model:t}},e)),this.transport&&(t.fn.parentParameterMap=this.transport.parameterMap),this._attachBubbleHandlers()},_attachBubbleHandlers:function(){var e=this;e._data.bind(yt,function(t){e.trigger(yt,t)})},remove:function(e){var t,r=e.parentNode(),n=this;return r&&r._initChildren&&(n=r.children),t=U.fn.remove.call(n,e),r&&!n.data().length&&(r.hasChildren=!1),t},success:M("success"),data:M("data"),insert:function(e,t){var r=this.parent();return r&&r._initChildren&&(r.hasChildren=!0,r._initChildren()),U.fn.insert.call(this,e,t)},_find:function(e,t){var r,n,i,a,s;if(i=U.fn[e].call(this,t))return i;if(a=this._flatData(this.data()))for(r=0,n=a.length;n>r;r++)if(s=a[r].children,s instanceof Q&&(i=s[e](t)))return i},get:function(e){return this._find("get",e)},getByUid:function(e){return this._find("getByUid",e)}}),Q.create=function(e){e=e&&e.push?{data:e}:e;var t=e||{},r=t.data,n=t.fields,i=t.list;return r&&r._dataSource?r._dataSource:(r||!n||t.transport||i&&(r=A(i,n)),t.data=r,t instanceof Q?t:new Q(t))},$=ot.Observable.extend({init:function(e,t,r){ot.Observable.fn.init.call(this),this._prefetching=!1,this.dataSource=e,this.prefetch=!r;var n=this;e.bind("change",function(){n._change()}),this._syncWithDataSource(),this.setViewSize(t)},setViewSize:function(e){this.viewSize=e,this._recalculate()},at:function(e){var r,n,i=this.pageSize;return e>=this.total()?(this.trigger("endreached",{index:e}),t):((ethis.skip+i)&&(r=Math.floor(e/i)*i,this.range(r)),e===this.prefetchThreshold&&this._prefetch(),e===this.midPageThreshold?this.range(this.nextMidRange):e===this.nextPageThreshold?this.range(this.nextFullRange):e===this.pullBackThreshold&&(this.offset===this.skip?this.range(this.previousMidRange):this.range(this.previousFullRange)),n=this.dataSource.at(e-this.dataOffset),n===t&&this.trigger("endreached",{index:e}),n)},indexOf:function(e){return this.dataSource.data().indexOf(e)+this.dataOffset},_prefetch:function(){var e=this,t=this.pageSize,r=this.skip+t,n=this.dataSource;n.inRange(r,t)||this._prefetching||!this.prefetch||(this._prefetching=!0,this.trigger("prefetching",{skip:r,take:t}),n.prefetch(r,t,function(){e._prefetching=!1,e.trigger("prefetched",{skip:r,take:t})}))},total:function(){return parseInt(this.dataSource.total(),10)},next:function(){var e=this,t=e.pageSize,r=e.skip-e.viewSize,n=zt.max(zt.floor(r/t),0)*t+t;this.offset=r,this.dataSource.prefetch(n,t,function(){e._goToRange(r,!0)})},range:function(e){if(this.offset!==e){var t=this,r=this.pageSize,n=zt.max(zt.floor(e/r),0)*r+r,i=this.dataSource;this.offset=e,this._recalculate(),i.inRange(e,r)?this._goToRange(e):this.prefetch&&i.prefetch(n,r,function(){t._goToRange(e,!0)})}},syncDataSource:function(){var e=this.offset;this.offset=null,this.range(e)},_goToRange:function(e,t){this.offset===e&&(this.dataOffset=e,this._expanding=t,this.dataSource.range(e,this.pageSize))},_change:function(){var e=this.dataSource,t=e.firstItemUid();this.length=e.lastRange().end,this._firstItemUid!==t&&(this._syncWithDataSource(),this._recalculate(),this.trigger("reset",{offset:this.offset})),this.trigger("resize"),this._expanding&&this.trigger("expand"),delete this._expanding},_syncWithDataSource:function(){var e=this.dataSource;this._firstItemUid=e.firstItemUid(),this.dataOffset=this.offset=e.skip(),this.pageSize=e.pageSize()},_recalculate:function(){var e=this.pageSize,t=this.offset,r=this.viewSize,n=Math.ceil(t/e)*e;this.skip=n,this.midPageThreshold=n+e-1,this.nextPageThreshold=n+r-1,this.prefetchThreshold=n+Math.floor(2*(e/3)),this.pullBackThreshold=this.offset-1,this.nextMidRange=n+e-r,this.nextFullRange=n,this.previousMidRange=t-r,this.previousFullRange=n-e}}),K=ot.Observable.extend({init:function(e,t){var r=this;ot.Observable.fn.init.call(r),this.dataSource=e,this.batchSize=t,this._total=0,this.buffer=new $(e,3*t),this.buffer.bind({endreached:function(e){r.trigger("endreached",{index:e.index})},prefetching:function(e){r.trigger("prefetching",{skip:e.skip,take:e.take})},prefetched:function(e){r.trigger("prefetched",{skip:e.skip,take:e.take})},reset:function(){r._total=0,r.trigger("reset")},resize:function(){r._total=this.length/r.batchSize,r.trigger("resize",{total:r.total(),offset:this.offset})}})},syncDataSource:function(){this.buffer.syncDataSource()},at:function(e){var r,n,i=this.buffer,a=e*this.batchSize,s=this.batchSize,o=[];for(i.offset>a&&i.at(i.offset-1),n=0;s>n;n++){if(r=i.at(a+n),r===t)return;o.push(r)}return o},total:function(){return this._total}}),X(!0,ot.data,{readers:{json:J},Query:a,DataSource:U,HierarchicalDataSource:Q,Node:W,ObservableObject:Lt,ObservableArray:Gt,LocalTransport:L,RemoteTransport:E,Cache:H,DataReader:J,Model:Jt,Buffer:$,BatchBuffer:K})}(window.kendo.jQuery)});