UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

2 lines 71.7 kB
module.exports=function(e){function t(i){if(r[i])return r[i].exports;var n=r[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}({0:function(e,t,r){e.exports=r(1100)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1049:function(e,t){e.exports=require("./kendo.core")},1100:function(e,t,r){var i,n,a;!function(s,define){n=[r(1049),r(1101),r(1102)],i=s,a="function"==typeof i?i.apply(t,n):i,!(void 0!==a&&(e.exports=a))}(function(){return function(e,t){function r(e,t,r,i){return function(n){var a,s={};for(a in n)s[a]=n[a];s.field=i?r+"."+n.field:r,t==Ae&&e._notifyChange&&e._notifyChange(s),e.trigger(t,s)}}function i(e,t){var r=[];for(e=e||{};e;)Object.getOwnPropertyNames(e).forEach(function(e){r.indexOf(e)===-1&&(!t||nt.indexOf(e)<0)&&r.push(e)}),e=Object.getPrototypeOf(e);return r}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 a(e,t){var r,i;for(i in e){if(r=e[i],ve(r)&&r.field&&r.field===t)return r;if(r===t)return r}return null}function s(e){this.data=e||[]}function o(e,r){if(e){var i=typeof e===qe?{field:e,dir:r}:e,n=Se(i)?i:i!==t?[i]:[];return be(n,function(e){return!!e.dir})}}function u(e,r){var i,n,a,s={};if(e)for(i=typeof e===qe?{field:e,dir:r}:e,n=Se(i)?i:i!==t?[i]:[],a=0;a<n.length;a++)s[n[a].field]={dir:n[a].dir,index:a+1};return s}function l(e){var t,r,i,n,a=e.filters;if(a)for(t=0,r=a.length;t<r;t++)i=a[t],n=i.operator,n&&typeof n===qe&&(i.operator=ne[n.toLowerCase()]||n),l(i)}function g(e){if(e&&!ye(e))return!Se(e)&&e.filters||(e={logic:"and",filters:Se(e)?e:[e]}),l(e),e}function d(e,t){return!e.logic&&!t.logic&&(e.field===t.field&&e.value===t.value&&e.operator===t.operator)}function h(e){return e=e||{},ye(e)?{logic:"and",filters:[]}:g(e)}function f(e,t){return t.logic||e.field>t.field?1:e.field<t.field?-1:0}function c(e,t){var r,i,n,a,s;if(e=h(e),t=h(t),e.logic!==t.logic)return!1;if(n=(e.filters||[]).slice(),a=(t.filters||[]).slice(),n.length!==a.length)return!1;for(n=n.sort(f),a=a.sort(f),s=0;s<n.length;s++)if(r=n[s],i=a[s],r.logic&&i.logic){if(!c(r,i))return!1}else if(!d(r,i))return!1;return!0}function p(e){return Se(e)?e:[e]}function _(e,r,i,n){var a=typeof e===qe?{field:e,dir:r,compare:i,skipItemSorting:n}:e,s=Se(a)?a:a!==t?[a]:[];return $(s,function(e){return{field:e.field,dir:e.dir||"asc",aggregates:e.aggregates,compare:e.compare,skipItemSorting:e.skipItemSorting}})}function m(e,t,r){var i,n=_(e,t,r);for(i=0;i<n.length;i++)delete n[i].compare;return n}function v(e){var t,r=Se(e)?e:[e];for(t=0;t<r.length;t++)if(r[t]&&Fe(r[t].compare))return!0;return!1}function y(e,t){return e&&e.getTime&&t&&t.getTime?e.getTime()===t.getTime():e===t}function S(e,t,r,i,n,a){var s,o,u,l,g;for(t=t||[],l=t.length,s=0;s<l;s++)o=t[s],u=o.aggregate,g=o.field,e[g]=e[g]||{},a[g]=a[g]||{},a[g][u]=a[g][u]||{},e[g][u]=ae[u.toLowerCase()](e[g][u],r,Pe.accessor(g),i,n,a[g][u])}function b(e){return"number"==typeof e&&!isNaN(e)}function k(e){return e&&e.getTime}function w(e){var t,r=e.length,i=Array(r);for(t=0;t<r;t++)i[t]=e[t].toJSON();return i}function x(e,t,r,i,n){var a,s,o,u,l,g={};for(u=0,l=e.length;u<l;u++){a=e[u];for(s in t)o=n[s],o&&o!==s&&(g[o]||(g[o]=Pe.setter(o)),g[o](a,t[s](a)),delete a[s])}}function P(e,t,r,i,n){var a,s,o,u,l;for(u=0,l=e.length;u<l;u++){a=e[u];for(s in t)a[s]=r._parse(s,t[s](a)),o=n[s],o&&o!==s&&delete a[o]}}function F(e,t,r,i,n){var a,s,o,u;for(s=0,u=e.length;s<u;s++)a=e[s],o=i[a.field],o&&o!=a.field&&(a.field=o),a.value=r._parse(a.field,a.value),a.items&&(a.hasSubgroups?F(a.items,t,r,i,n):P(a.items,t,r,i,n))}function R(e,t,r,i,n,a){return function(s){return s=e(s),G(t,r,i,n,a)(s)}}function G(e,t,r,i,n){return function(a){return a&&!ye(r)&&("[object Array]"===tt.call(a)||a instanceof at||(a=[a]),t(a,r,new e,i,n)),a||[]}}function q(e,t){var r,i,n;if(t.items&&t.items.length)for(n=0;n<t.items.length;n++)r=e.items[n],i=t.items[n],r&&i?r.hasSubgroups?q(r,i):r.field&&r.value==i.value?r.items.push.apply(r.items,i.items):e.items.push.apply(e.items,[i]):i&&e.items.push.apply(e.items,[i])}function C(e,t,r,i){for(var n,a,s,o=0;t.length&&i&&(n=t[o],a=n.items,s=a.length,e&&e.field===n.field&&e.value===n.value?(e.hasSubgroups&&e.items.length?C(e.items[e.items.length-1],n.items,r,i):(a=a.slice(r,r+i),e.items=e.items.concat(a)),t.splice(o--,1)):n.hasSubgroups&&a.length?(C(n,a,r,i),n.items.length||t.splice(o--,1)):(a=a.slice(r,r+i),n.items=a,n.items.length||t.splice(o--,1)),0===a.length?r-=s:(r=0,i-=a.length),!(++o>=t.length)););o<t.length&&t.splice(o,t.length-o)}function O(e,t){var r,i,n,a,s=[],o=(e||[]).length,u=Fe(t)?t:function(e,t){return e[t]};for(n=0;n<o;n++)if(r=u(e,n),r.hasSubgroups)s=s.concat(O(r.items));else for(i=r.items,a=0;a<i.length;a++)s.push(u(i,a));return s}function D(e){var t,r,i,n,a,s=[];for(t=0,r=e.length;t<r;t++)if(a=e.at(t),a.items)if(a.hasSubgroups)s=s.concat(D(a.items));else for(i=a.items,n=0;n<i.length;n++)s.push(i.at(n));return s}function z(e,t){var r,i,n;if(t)for(r=0,i=e.length;r<i;r++)n=e.at(r),n.items&&(n.hasSubgroups?z(n.items,t):n.items=new K(n.items,t,n.items._events))}function I(e,t){for(var r=0;r<e.length;r++)if(e[r].hasSubgroups){if(I(e[r].items,t))return!0}else if(t(e[r].items,e[r]))return!0}function T(e,t,r,i){for(var n=0;n<e.length&&e[n].data!==t&&!A(e[n].data,r,i);n++);}function A(e,t,r){for(var i=0,n=e.length;i<n;i++){if(e[i]&&e[i].hasSubgroups)return A(e[i].items,t,r);if(e[i]===t||e[i]===r)return e[i]=r,!0}}function E(e,r,i,n,a){var s,o,u,l;for(s=0,o=e.length;s<o;s++)if(u=e[s],u&&!(u instanceof n))if(u.hasSubgroups===t||a){for(l=0;l<r.length;l++)if(r[l]===u){e[s]=r.at(l),T(i,r,u,e[s]);break}}else E(u.items,r,i,n,a)}function M(e,t){var r,i,n;if(e)for(r=e.length,n=0;n<r;n++)if(i=e[n],i.uid&&i.uid==t.uid)return e.splice(n,1),i}function N(e,t){return t?j(e,function(e){return e.uid&&e.uid==t.uid||e[t.idField]===t.id&&t.id!==t._defaultId}):-1}function L(e,t){return t?j(e,function(e){return e.uid==t.uid}):-1}function j(e,t){var r,i;if(e){for(r=0,i=e.length;r<i;r++)if(t(e[r]))return r;return-1}}function B(e,t){var r,i;return e&&!ye(e)?(r=e[t],i=ve(r)?r.from||r.field||t:e[t]||t,Fe(i)?t:i):t}function H(e,t){var r,i,n,a={};for(n in e)"filters"!==n&&(a[n]=e[n]);if(e.filters)for(a.filters=[],r=0,i=e.filters.length;r<i;r++)a.filters[r]=H(e.filters[r],t);else a.field=B(t.fields,a.field);return a}function U(e,t){var r,i,n,a,s,o=[];for(r=0,i=e.length;r<i;r++){n={},a=e[r];for(s in a)n[s]=a[s];n.field=B(t.fields,n.field),n.aggregates&&Se(n.aggregates)&&(n.aggregates=U(n.aggregates,t)),o.push(n)}return o}function J(t,r){var i,n,a,s,o,u,l,g,d,h;for(t=e(t)[0],i=t.options,n=r[0],a=r[1],s=[],o=0,u=i.length;o<u;o++)d={},g=i[o],l=g.parentNode,l===t&&(l=null),g.disabled||l&&l.disabled||(l&&(d.optgroup=l.label),d[n.field]=g.text,h=g.attributes.value,h=h&&h.specified?g.value:g.text,d[a.field]=h,s.push(d));return s}function V(t,r){var i,n,a,s,o,u,l,g=e(t)[0].tBodies[0],d=g?g.rows:[],h=r.length,f=[];for(i=0,n=d.length;i<n;i++){for(o={},l=!0,s=d[i].cells,a=0;a<h;a++)u=s[a],"th"!==u.nodeName.toLowerCase()&&(l=!1,o[r[a].field]=u.innerHTML);l||f.push(o)}return f}function Q(e){return function(){var t=this._data,r=ge.fn[e].apply(this,Ze.call(arguments));return this._data!=t&&this._attachBubbleHandlers(),r}}function W(t,r){function i(e,t){return e.filter(t).add(e.find(t))}var n,a,s,o,u,l,g,d,h=e(t).children(),f=[],c=r[0].field,p=r[1]&&r[1].field,_=r[2]&&r[2].field,m=r[3]&&r[3].field;for(n=0,a=h.length;n<a;n++)s={_loaded:!0},o=h.eq(n),l=o[0].firstChild,d=o.children(),t=d.filter("ul"),d=d.filter(":not(ul)"),u=o.attr("data-id"),u&&(s.id=u),l&&(s[c]=3==l.nodeType?l.nodeValue:d.text()),p&&(s[p]=i(d,"a").attr("href")),m&&(s[m]=i(d,"img").attr("src")),_&&(g=i(d,".k-sprite").prop("className"),s[_]=g&&Pe.trim(g.replace("k-sprite",""))),t.length&&(s.items=W(t.eq(0),r)),"true"==o.attr("data-hasChildren")&&(s.hasChildren=!0),f.push(s);return f}var $,K,X,Y,Z,ee,te,re,ie,ne,ae,se,oe,ue,le,ge,de,he,fe,ce,pe,_e=e.extend,me=e.proxy,ve=e.isPlainObject,ye=e.isEmptyObject,Se=e.isArray,be=e.grep,ke=e.ajax,we=e.each,xe=e.noop,Pe=window.kendo,Fe=Pe.isFunction,Re=Pe.Observable,Ge=Pe.Class,qe="string",Ce="function",Oe="asc",De="create",ze="read",Ie="update",Te="destroy",Ae="change",Ee="sync",Me="get",Ne="error",Le="requestStart",je="progress",Be="requestEnd",He=[De,ze,Ie,Te],Ue=function(e){return e},Je=Pe.getter,Ve=Pe.stringify,Qe=Math,We=[].push,$e=[].join,Ke=[].pop,Xe=[].splice,Ye=[].shift,Ze=[].slice,et=[].unshift,tt={}.toString,rt=Pe.support.stableSort,it=/^\/Date\((.*?)\)\/$/,nt=[],at=Re.extend({init:function(e,t){var r=this;r.type=t||X,Re.fn.init.call(r),r.length=e.length,r.wrapAll(e,r)},at:function(e){return this[e]},toJSON:function(e){var t,r,i=this.length,n=Array(i);for(t=0;t<i;t++)r=this[t],r instanceof X&&(r=r.toJSON(e)),n[t]=r;return n},parent:xe,wrapAll:function(e,t){var r,i,n=this,a=function(){return n};for(t=t||[],r=0,i=e.length;r<i;r++)t[r]=n.wrap(e[r],a);return t},wrap:function(e,t){var r,i=this;return null!==e&&"[object Object]"===tt.call(e)&&(r=e instanceof i.type||e instanceof ee,r||(e=e instanceof X?e.toJSON():e,e=new i.type(e)),e.parent=t,e.bind(Ae,function(e){i.trigger(Ae,{field:e.field,node:e.node,index:e.index,items:e.items||[this],action:e.node?e.action||"itemloaded":"itemchange"})})),e},push:function(){var e,t=this.length,r=this.wrapAll(arguments);return e=We.apply(this,r),this.omitChangeEvent||this.trigger(Ae,{action:"add",index:t,items:r}),e},slice:Ze,sort:[].sort,join:$e,pop:function(){var e=this.length,t=Ke.apply(this);return e&&this.trigger(Ae,{action:"remove",index:e-1,items:[t]}),t},splice:function(e,t,r){var i,n,a,s=this.wrapAll(Ze.call(arguments,2));if(i=Xe.apply(this,[e,t].concat(s)),i.length)for(this.omitChangeEvent||this.trigger(Ae,{action:"remove",index:e,items:i}),n=0,a=i.length;n<a;n++)i[n]&&i[n].children&&i[n].unbind(Ae);return r&&(this.omitChangeEvent||this.trigger(Ae,{action:"add",index:e,items:s})),i},shift:function(){var e=this.length,t=Ye.apply(this);return e&&this.trigger(Ae,{action:"remove",index:0,items:[t]}),t},unshift:function(){var e,t=this.wrapAll(arguments);return e=et.apply(this,t),this.trigger(Ae,{action:"add",index:0,items:t}),e},indexOf:function(e){var t,r,i=this;for(t=0,r=i.length;t<r;t++)if(i[t]===e)return t;return-1},forEach:function(e,t){for(var r=0,i=this.length,n=t||window;r<i;r++)e.call(n,this[r],r,this)},map:function(e,t){for(var r=0,i=[],n=this.length,a=t||window;r<n;r++)i[r]=e.call(a,this[r],r,this);return i},reduce:function(e){var t,r=0,i=this.length;for(2==arguments.length?t=arguments[1]:r<i&&(t=this[r++]);r<i;r++)t=e(t,this[r],r,this);return t},reduceRight:function(e){var t,r=this.length-1;for(2==arguments.length?t=arguments[1]:r>0&&(t=this[r--]);r>=0;r--)t=e(t,this[r],r,this);return t},filter:function(e,t){for(var r,i=0,n=[],a=this.length,s=t||window;i<a;i++)r=this[i],e.call(s,r,i,this)&&(n[n.length]=r);return n},find:function(e,t){for(var r,i=0,n=this.length,a=t||window;i<n;i++)if(r=this[i],e.call(a,r,i,this))return r},every:function(e,t){for(var r,i=0,n=this.length,a=t||window;i<n;i++)if(r=this[i],!e.call(a,r,i,this))return!1;return!0},some:function(e,t){for(var r,i=0,n=this.length,a=t||window;i<n;i++)if(r=this[i],e.call(a,r,i,this))return!0;return!1},remove:function(e){var t=this.indexOf(e);t!==-1&&this.splice(t,1)},empty:function(){this.splice(0,this.length)}});"undefined"!=typeof Symbol&&Symbol.iterator&&!at.prototype[Symbol.iterator]&&(at.prototype[Symbol.iterator]=[][Symbol.iterator]),K=at.extend({init:function(e,t,r){Re.fn.init.call(this),this.type=t||X,r&&(this._events=r);for(var i=0;i<e.length;i++)this[i]=e[i];this.length=i,this._parent=me(function(){return this},this)},at:function(e){var t=this[e];return t instanceof this.type?t.parent=this._parent:t=this[e]=this.wrap(t,this._parent),t}}),nt=i({},!1),X=Re.extend({init:function(e){var t,r=this,n=i(e,!0),a=function(){return r};Re.fn.init.call(this),this._handlers={},n.forEach(function(i){t=e[i],"object"==typeof t&&t&&!t.getTime&&"_"!=i.charAt(0)&&(t=r.wrap(t,i,a)),r[i]=t}),r.uid=Pe.guid()},shouldSerialize:function(e,t){return this.hasOwnProperty(e)&&"_handlers"!==e&&"_events"!==e&&(t&&t[e]||typeof this[e]!==Ce)&&"uid"!==e},forEach:function(e){for(var t in this)this.shouldSerialize(t)&&e(this[t],t)},toJSON:function(e){var t,r,i={};for(r in this)this.shouldSerialize(r,e)&&(t=this[r],(t instanceof X||t instanceof at)&&(t=t.toJSON(e)),i[r]=t);return i},get:function(e){var t,r=this;return r.trigger(Me,{field:e}),t="this"===e?r:Pe.getter(e,!0)(r)},_set:function(e,t){var r,i,n,a=this,s=e.indexOf(".")>=0;if(s)for(r=e.split("."),i="";r.length>1;){if(i+=r.shift(),n=Pe.getter(i,!0)(a),n instanceof X)return n.set(r.join("."),t),s;i+="."}return Pe.setter(e)(a,t),s},set:function(e,t){var r=this,i=!1,n=e.indexOf(".")>=0,a=Pe.getter(e,!0)(r);return a!==t&&(a instanceof Re&&this._handlers[e]&&(this._handlers[e].get&&a.unbind(Me,this._handlers[e].get),a.unbind(Ae,this._handlers[e].change)),i=r.trigger("set",{field:e,value:t}),i||(n||(t=r.wrap(t,e,function(){return r})),(!r._set(e,t)||e.indexOf("(")>=0||e.indexOf("[")>=0)&&r.trigger(Ae,{field:e}))),i},parent:xe,wrap:function(e,t,i){var n,a,s,o,u=this,l=tt.call(e);return null==e||"[object Object]"!==l&&"[object Array]"!==l||(s=e instanceof at,o=e instanceof ge,"[object Object]"!==l||o||s?("[object Array]"===l||s||o)&&(s||o||(e=new at(e)),a=r(u,Ae,t,!1),e.bind(Ae,a),u._handlers[t]={change:a}):(e instanceof X||(e=new X(e)),n=r(u,Me,t,!0),e.bind(Me,n),a=r(u,Ae,t,!0),e.bind(Ae,a),u._handlers[t]={get:n,change:a}),e.parent=i),e}}),Y={number:function(e){return typeof e===qe&&"null"===e.toLowerCase()?null:Pe.parseFloat(e)},date:function(e){return typeof e===qe&&"null"===e.toLowerCase()?null:Pe.parseDate(e)},"boolean":function(e){return typeof e===qe?"null"===e.toLowerCase()?null:"true"===e.toLowerCase():null!=e?!!e:e},string:function(e){return typeof e===qe&&"null"===e.toLowerCase()?null:null!=e?e+"":e},"default":function(e){return e}},Z={string:"",number:0,date:new Date,"boolean":!1,"default":""},ee=X.extend({init:function(r){var i,n,a=this;if((!r||e.isEmptyObject(r))&&(r=e.extend({},a.defaults,r),a._initializers))for(i=0;i<a._initializers.length;i++)n=a._initializers[i],r[n]=a.defaults[n]();X.fn.init.call(a,r),a.dirty=!1,a.dirtyFields={},a.idField&&(a.id=a.get(a.idField),a.id===t&&(a.id=a._defaultId))},shouldSerialize:function(e){return X.fn.shouldSerialize.call(this,e)&&"uid"!==e&&!("id"!==this.idField&&"id"===e)&&"dirty"!==e&&"dirtyFields"!==e&&"_accessors"!==e},_parse:function(e,t){var r,i=this,n=e,s=i.fields||{};return e=s[e],e||(e=a(s,n)),e&&(r=e.parse,!r&&e.type&&(r=Y[e.type.toLowerCase()])),r?r(t):t},_notifyChange:function(e){var t=e.action;"add"!=t&&"remove"!=t||(this.dirty=!0,this.dirtyFields[e.field]=!0)},editable:function(e){return e=(this.fields||{})[e],!e||e.editable!==!1},set:function(e,t){var r=this,i=r.dirty;r.editable(e)&&(t=r._parse(e,t),n(t,r.get(e))?r.trigger("equalSet",{field:e,value:t}):(r.dirty=!0,r.dirtyFields[e]=!0,X.fn.set.call(r,e,t)&&!i&&(r.dirty=i,r.dirty||(r.dirtyFields[e]=!1))))},accept:function(e){var t,r,i=this,n=function(){return i};for(t in e)r=e[t],"_"!=t.charAt(0)&&(r=i.wrap(e[t],t,n)),i._set(t,r);i.idField&&(i.id=i.get(i.idField)),i.dirty=!1,i.dirtyFields={}},isNew:function(){return this.id===this._defaultId}}),ee.define=function(e,r){r===t&&(r=e,e=ee);var i,n,a,s,o,u,l,g,d=_e({defaults:{}},r),h={},f=d.id,c=[];if(f&&(d.idField=f),d.id&&delete d.id,f&&(d.defaults[f]=d._defaultId=""),"[object Array]"===tt.call(d.fields)){for(u=0,l=d.fields.length;u<l;u++)a=d.fields[u],typeof a===qe?h[a]={}:a.field&&(h[a.field]=a);d.fields=h}for(n in d.fields)a=d.fields[n],s=a.type||"default",o=null,g=n,n=typeof a.field===qe?a.field:n,a.nullable||(o=d.defaults[g!==n?g:n]=a.defaultValue!==t?a.defaultValue:Z[s.toLowerCase()],"function"==typeof o&&c.push(n)),r.id===n&&(d._defaultId=o),d.defaults[g!==n?g:n]=o,a.parse=a.parse||Y[s];return c.length>0&&(d._initializers=c),i=e.extend(d),i.define=function(e){return ee.define(i,e)},d.fields&&(i.fields=d.fields,i.idField=d.idField),i},te={selector:function(e){return Fe(e)?e:Je(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:e<r?-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 i,n,a=e[0](t,r);for(i=1,n=e.length;i<n;i++)a=a||e[i](t,r);return a}}},re=_e({},te,{asc:function(e){var t=this.selector(e);return function(e,r){var i=t(e),n=t(r);return i&&i.getTime&&n&&n.getTime&&(i=i.getTime(),n=n.getTime()),i===n?e.__position-r.__position:null==i?-1:null==n?1:i.localeCompare?i.localeCompare(n):i>n?1:-1}},desc:function(e){var t=this.selector(e);return function(e,r){var i=t(e),n=t(r);return i&&i.getTime&&n&&n.getTime&&(i=i.getTime(),n=n.getTime()),i===n?e.__position-r.__position:null==i?1:null==n?-1:n.localeCompare?n.localeCompare(i):i<n?1:-1}},create:function(e){return this[e.dir](e.field)}}),$=function(e,t){var r,i=e.length,n=Array(i);for(r=0;r<i;r++)n[r]=t(e[r],r,e);return n},ie=function(){function e(e){return"string"==typeof e&&(e=e.replace(/[\r\n]+/g,"")),JSON.stringify(e)}function t(t){return function(r,i,n,a){return i+="",n&&(r="("+r+" + '').toString()"+(a?".toLocaleLowerCase('"+a+"')":".toLowerCase()"),i=a?i.toLocaleLowerCase(a):i.toLowerCase()),t(r,e(i),n)}}function r(t,r,i,n,a){if(null!=i){if(typeof i===qe){var s=it.exec(i);s?i=new Date((+s[1])):n?(i=e(a?i.toLocaleLowerCase(a):i.toLowerCase()),r="(("+r+" || '')+'')"+(a?".toLocaleLowerCase('"+a+"')":".toLowerCase()")):i=e(i)}i.getTime&&(r="("+r+"&&"+r+".getTime?"+r+".getTime():"+r+")",i=i.getTime())}return r+" "+t+" "+i}function i(e){var t,r,i,n;for(t="/^",r=!1,i=0;i<e.length;++i){if(n=e.charAt(i),r)t+="\\"+n;else{if("~"==n){r=!0;continue}t+="*"==n?".*":"?"==n?".":".+^$()[]{}|\\/\n\r\u2028\u2029 ".indexOf(n)>=0?"\\"+n:n}r=!1}return t+"$/"}return{quote:function(t){return t&&t.getTime?"new Date("+t.getTime()+")":e(t)},eq:function(e,t,i,n){return r("==",e,t,i,n)},neq:function(e,t,i,n){return r("!=",e,t,i,n)},gt:function(e,t,i){return r(">",e,t,i)},gte:function(e,t,i){return r(">=",e,t,i)},lt:function(e,t,i){return r("<",e,t,i)},lte:function(e,t,i){return r("<=",e,t,i)},startswith:t(function(e,t){return e+".lastIndexOf("+t+", 0) == 0"}),doesnotstartwith:t(function(e,t){return e+".lastIndexOf("+t+", 0) == -1"}),endswith:t(function(e,t){var r=t?t.length-2:0;return e+".indexOf("+t+", "+e+".length - "+r+") >= 0"}),doesnotendwith:t(function(e,t){var r=t?t.length-2:0;return e+".indexOf("+t+", "+e+".length - "+r+") < 0"}),contains:t(function(e,t){return e+".indexOf("+t+") >= 0"}),doesnotcontain:t(function(e,t){return e+".indexOf("+t+") == -1"}),matches:t(function(e,t){return t=t.substring(1,t.length-1),i(t)+".test("+e+")"}),doesnotmatch:t(function(e,t){return t=t.substring(1,t.length-1),"!"+i(t)+".test("+e+")"}),isempty:function(e){return e+" === ''"},isnotempty:function(e){return e+" !== ''"},isnull:function(e){return"("+e+" == null)"},isnotnull:function(e){return"("+e+" != null)"},isnullorempty:function(e){return"("+e+" === null) || ("+e+" === '')"},isnotnullorempty:function(e){return"("+e+" !== null) && ("+e+" !== '')"}}}(),s.filterExpr=function(e){var r,i,n,a,o,u,l=[],g={and:" && ",or:" || "},d=[],h=[],f=e.filters;for(r=0,i=f.length;r<i;r++)n=f[r],o=n.field,u=n.operator,n.filters?(a=s.filterExpr(n),n=a.expression.replace(/__o\[(\d+)\]/g,function(e,t){return t=+t,"__o["+(h.length+t)+"]"}).replace(/__f\[(\d+)\]/g,function(e,t){return t=+t,"__f["+(d.length+t)+"]"}),h.push.apply(h,a.operators),d.push.apply(d,a.fields)):(typeof o===Ce?(a="__f["+d.length+"](d)",d.push(o)):a=Pe.expr(o),typeof u===Ce?(n="__o["+h.length+"]("+a+", "+ie.quote(n.value)+")",h.push(u)):n=ie[(u||"eq").toLowerCase()](a,n.value,n.ignoreCase===t||n.ignoreCase,e.accentFoldingFiltering)),l.push(n);return{expression:"("+l.join(g[e.logic])+")",fields:d,operators:h}},ne={"==":"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",isnull:"isnull",isempty:"isempty",isnotempty:"isnotempty"},s.normalizeFilter=g,s.compareFilters=c,s.prototype={toArray:function(){return this.data},range:function(e,t){return new s(this.data.slice(e,e+t))},skip:function(e){return new s(this.data.slice(e))},take:function(e){return new s(this.data.slice(0,e))},select:function(e){return new s($(this.data,e))},order:function(e,t,r){var i={dir:t};return e&&(e.compare?i.compare=e.compare:i.field=e),new s(r?this.data.sort(te.create(i)):this.data.slice(0).sort(te.create(i)))},orderBy:function(e,t){return this.order(e,"asc",t)},orderByDescending:function(e,t){return this.order(e,"desc",t)},sort:function(e,t,r,i){var n,a,s=o(e,t),u=[];if(r=r||te,s.length){for(n=0,a=s.length;n<a;n++)u.push(r.create(s[n]));return this.orderBy({compare:r.combine(u)},i)}return this},filter:function(e){var t,r,i,n,a,o,u,l,d=this.data,h=[];if(e=g(e),!e||0===e.filters.length)return this;for(n=s.filterExpr(e),o=n.fields,u=n.operators,a=l=Function("d, __f, __o","return "+n.expression),(o.length||u.length)&&(l=function(e){return a(e,o,u)}),t=0,i=d.length;t<i;t++)r=d[t],l(r)&&h.push(r);return new s(h)},group:function(e,t,r){e=_(e||[]),t=t||this.data;var i,n=this,a=new s(n.data);return e.length>0&&(i=e[0],a=r&&r.groupPaging?new s(t).groupAllData(i,t).select(function(n){var a=new s(t).filter([{field:n.field,operator:"eq",value:n.value,ignoreCase:!1}]),o=e.length>1?new s(n.items).group(e.slice(1),a.toArray(),r).toArray():n.items;return{field:n.field,value:n.value,hasSubgroups:e.length>1,items:o,aggregates:a.aggregate(i.aggregates),uid:Pe.guid(),itemCount:o.length,subgroupCount:o.length}}):a.groupBy(i).select(function(r){var n=new s(t).filter([{field:r.field,operator:"eq",value:r.value,ignoreCase:!1}]);return{field:r.field,value:r.value,items:e.length>1?new s(r.items).group(e.slice(1),n.toArray()).toArray():r.items,hasSubgroups:e.length>1,aggregates:n.aggregate(i.aggregates)}})),a},groupBy:function(e){var t,r,i,n,a,o,u,l,g,d,h=this;if(ye(e)||!this.data.length)return new s([]);for(t=e.field,r=e.skipItemSorting?this.data:this._sortForGrouping(t,e.dir||"asc"),i=Pe.accessor(t),a=i.get(r[0],t),o={field:t,value:a,items:[]},d=[o],l=0,g=r.length;l<g;l++)n=r[l],u=i.get(n,t),y(a,u)||(a=u,o={field:t,value:a,items:[]},d.push(o)),o.items.push(n);return d=h._sortGroups(d,e),new s(d)},groupAllData:function(e,t){if(ye(e)||this.data&&!this.data.length)return new s([]);var r,i,n,a,o=e.field,u=e.skipItemSorting?t:new s(t).sort(o,e.dir||"asc",re).toArray(),l=Pe.accessor(o),g=l.get(u[0],o),d={field:o,value:g,items:[]},h=[d];for(n=0,a=u.length;n<a;n++)r=u[n],i=l.get(r,o),y(g,i)||(g=i,d={field:o,value:g,items:[]},h.push(d)),d.items.push(r);return h=this._sortGroups(h,e),new s(h)},_sortForGrouping:function(e,t){var r,i,n=this.data;if(!rt){for(r=0,i=n.length;r<i;r++)n[r].__position=r;for(n=new s(n).sort(e,t,re).toArray(),r=0,i=n.length;r<i;r++)delete n[r].__position;return n}return this.sort(e,t).toArray()},_sortGroups:function(e,t){var r=e;return t&&Fe(t.compare)&&(r=new s(r).order({compare:t.compare},t.dir||Oe).toArray()),r},aggregate:function(e){var t,r,i={},n={};if(e&&e.length)for(t=0,r=this.data.length;t<r;t++)S(i,e,this.data[t],t,r,n);return i}},ae={sum:function(e,t,r){var i=r.get(t);return b(e)?b(i)&&(e+=i):e=i,e},count:function(e){return(e||0)+1},average:function(e,r,i,n,a,s){var o=i.get(r);return s.count===t&&(s.count=0),b(e)?b(o)&&(e+=o):e=o,b(o)&&s.count++,n==a-1&&b(e)&&(e/=s.count),e},max:function(e,t,r){var i=r.get(t);return b(e)||k(e)||(e=i),e<i&&(b(i)||k(i))&&(e=i),e},min:function(e,t,r){var i=r.get(t);return b(e)||k(e)||(e=i),e>i&&(b(i)||k(i))&&(e=i),e}},s.normalizeGroup=_,s.normalizeSort=o,s.process=function(e,r,i){var n,a,u,l,g,d,h,f,c,p,y,S;return r=r||{},n=r.group,a=v(_(n||[])),u=new s(e),l=m(n||[]),g=o(r.sort||[]),d=a?g:l.concat(g),c=r.filterCallback,p=r.filter,y=r.skip,S=r.take,d&&i&&(u=u.sort(d,t,t,i)),p&&(u=u.filter(p),c&&(u=c(u)),f=u.toArray().length),d&&(i||(u=u.sort(d)),n&&(e=u.toArray())),a?(u=u.group(n,e,r),y!==t&&S!==t&&(u=new s(O(u.toArray())).range(y,S),h=$(l,function(e){return _e({},e,{skipItemSorting:!0})}),u=u.group(h,e,r))):(y!==t&&S!==t&&(u=u.range(y,S)),n&&(u=u.group(n,e,r))),{total:f,data:u.toArray()}},se=Ge.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)}}),oe=Ge.extend({init:function(e){var t,r=this;e=r.options=_e({},r.options,e),we(He,function(t,r){typeof e[r]===qe&&(e[r]={url:e[r]})}),r.cache=e.cache?ue.create(e.cache):{find:xe,add:xe},t=e.parameterMap,e.submit&&(r.submit=e.submit),Fe(e.push)&&(r.push=e.push),r.push||(r.push=Ue),r.parameterMap=Fe(t)?t:function(e){var r={};return we(e,function(e,i){e in t&&(e=t[e],ve(e)&&(i=e.value(i),e=e.key)),r[e]=i}),r}},options:{parameterMap:Ue},create:function(e){return ke(this.setup(e,De))},read:function(r){var i,n,a,s=this,o=s.cache;r=s.setup(r,ze),i=r.success||xe,n=r.error||xe,a=o.find(r.data),a!==t?i(a):(r.success=function(e){o.add(r.data,e),i(e)},e.ajax(r))},update:function(e){return ke(this.setup(e,Ie))},destroy:function(e){return ke(this.setup(e,Te))},setup:function(e,t){e=e||{};var r,i=this,n=i.options[t],a=Fe(n.data)?n.data(e.data):n.data;return e=_e(!0,{},n,e),r=_e(!0,{},a,e.data),e.data=i.parameterMap(r,t),Fe(e.url)&&(e.url=e.url(r)),e}}),ue=Ge.extend({init:function(){this._store={}},add:function(e,r){e!==t&&(this._store[Ve(e)]=r)},find:function(e){return this._store[Ve(e)]},clear:function(){this._store={}},remove:function(e){delete this._store[Ve(e)]}}),ue.create=function(e){var t={inmemory:function(){return new ue}};return ve(e)&&Fe(e.find)?e:e===!0?new ue:t[e]()},le=Ge.extend({init:function(e){var t,r,i,n,a,s,o,u,l,g,d,h,f,c,p=this;e=e||{};for(t in e)r=e[t],p[t]=typeof r===qe?Je(r):r;n=e.modelBase||ee,ve(p.model)&&(p.model=i=n.define(p.model)),a=me(p.data,p),p._dataAccessFunction=a,p.model&&(s=me(p.groups,p),o=me(p.serialize,p),u={},l={},g={},d={},h=!1,i=p.model,i.fields&&(we(i.fields,function(e,t){var r;f=e,ve(t)&&t.field?f=t.field:typeof t===qe&&(f=t),ve(t)&&t.from&&(r=t.from),h=h||r&&r!==e||f!==e,c=r||f,l[e]=c.indexOf(".")!==-1?Je(c,!0):Je(c),g[e]=Je(e),u[r||f]=e,d[e]=r||f}),!e.serialize&&h&&(p.serialize=R(o,i,x,g,u,d))),p._dataAccessFunction=a,p._wrapDataAccessBase=G(i,P,l,u,d),p.data=R(a,i,P,l,u,d),p.groups=R(s,i,F,l,u,d))},errors:function(e){return e?e.errors:null},parse:Ue,data:Ue,total:function(e){return e.length},groups:Ue,aggregates:function(){return{}},serialize:function(e){return e}}),ge=Re.extend({init:function(e){var r,i,n,a=this;e&&(i=e.data),e=a.options=_e({},a.options,e),a._map={},a._prefetch={},a._data=[],a._pristineData=[],a._ranges=[],a._view=[],a._pristineTotal=0,a._destroyed=[],a._pageSize=e.pageSize,a._page=e.page||(e.pageSize?1:t),a._sort=o(e.sort),a._sortFields=u(e.sort),a._filter=g(e.filter),a._group=_(e.group),a._aggregate=e.aggregate,a._total=e.total,a._groupPaging=e.groupPaging,a._groupPaging&&(a._groupsState={}),a._shouldDetachObservableParents=!0,Re.fn.init.call(a),a.transport=de.create(e,i,a),Fe(a.transport.push)&&a.transport.push({pushCreate:me(a._pushCreate,a),pushUpdate:me(a._pushUpdate,a),pushDestroy:me(a._pushDestroy,a)}),null!=e.offlineStorage&&("string"==typeof e.offlineStorage?(n=e.offlineStorage,a._storage={getItem:function(){return JSON.parse(localStorage.getItem(n))},setItem:function(e){localStorage.setItem(n,Ve(a.reader.serialize(e)))}}):a._storage=e.offlineStorage),a.reader=new Pe.data.readers[e.schema.type||"json"](e.schema),r=a.reader.model||{},a._detachObservableParents(),a._data=a._observe(a._data),a._online=!0,a.bind(["push",Ne,Ae,Le,Ee,Be,je],e)},options:{data:null,schema:{modelBase:ee},offlineStorage:null,serverSorting:!1,serverPaging:!1,serverFiltering:!1,serverGrouping:!1,serverAggregates:!1,batch:!1,inPlaceSort:!1},clone:function(){return this},online:function(r){return r!==t?this._online!=r&&(this._online=r,r)?this.sync():e.Deferred().resolve().promise():this._online},offlineData:function(e){return null==this.options.offlineStorage?null:e!==t?this._storage.setItem(e):this._storage.getItem()||[]},_isServerGrouped:function(){var e=this.group()||[];return this.options.serverGrouping&&e.length},_isServerGroupPaged:function(){return this._isServerGrouped()&&this._groupPaging},_isGroupPaged:function(){var e=this._group||[];return this._groupPaging&&e.length},_pushCreate:function(e){this._push(e,"pushCreate")},_pushUpdate:function(e){this._push(e,"pushUpdate")},_pushDestroy:function(e){this._push(e,"pushDestroy")},_push:function(e,t){var r=this._readData(e);r||(r=e),this[t](r)},_flatData:function(e,t){if(e){if(this._isServerGrouped())return D(e);if(!t)for(var r=0;r<e.length;r++)e.at(r)}return e},parent:xe,get:function(e){var t,r,i=this._flatData(this._data,this.options.useRanges);for(t=0,r=i.length;t<r;t++)if(i[t].id==e)return i[t]},getByUid:function(e){return this._getByUid(e,this._data)},_getByUid:function(e,t){var r,i,n=this._flatData(t,this.options.useRanges);if(n)for(r=0,i=n.length;r<i;r++)if(n[r].uid==e)return n[r]},indexOf:function(e){return L(this._data,e)},at:function(e){return this._data.at(e)},data:function(e){var r,i=this;if(e===t){if(i._data)for(r=0;r<i._data.length;r++)i._data.at(r);return i._data}i._detachObservableParents(),i._data=this._observe(e),i._pristineData=e.slice(0),i._storeData(),i._ranges=[],i.trigger("reset"),i._addRange(i._data),i._total=i._data.length,i._pristineTotal=i._total,i._process(i._data)},view:function(e){return e===t?this._view:(this._view=this._observeView(e),t)},_observeView:function(e){var t,r=this;return E(e,r._data,r._ranges,r.reader.model||X,r._isServerGrouped()),t=new K(e,r.reader.model),t.parent=function(){return r.parent()},t},flatView:function(){var e=this.group()||[];return e.length?D(this._view):this._view},add:function(e){return this.insert(this._data.length,e)},_createNewModel:function(e){return this.reader.model?new this.reader.model(e):e instanceof X?e:new X(e)},insert:function(e,t){return t||(t=e,e=0),t instanceof ee||(t=this._createNewModel(t)),this._isServerGrouped()?this._data.splice(e,0,this._wrapInEmptyGroup(t)):this._data.splice(e,0,t),this._insertModelInRange(e,t),t},pushInsert:function(t,r){var i,n,a,s,o,u,l=this,g=l._getCurrentRangeSpan();r||(r=t,t=0),Se(r)||(r=[r]),i=[],n=this.options.autoSync,this.options.autoSync=!1;try{for(a=0;a<r.length;a++)s=r[a],o=this.insert(t,s),i.push(o),u=o.toJSON(),this._isServerGrouped()&&(u=this._wrapInEmptyGroup(u)),this._pristineData.push(u),g&&g.length&&e(g).last()[0].pristineData.push(u),t++}finally{this.options.autoSync=n}i.length&&this.trigger("push",{type:"create",items:i})},pushCreate:function(e){this.pushInsert(this._data.length,e)},pushUpdate:function(e){var t,r,i,n,a;for(Se(e)||(e=[e]),t=[],r=0;r<e.length;r++)i=e[r],n=this._createNewModel(i),a=this.get(n.id),a?(t.push(a),a.accept(i),a.trigger(Ae),this._updatePristineForModel(a,i)):this.pushCreate(i);t.length&&this.trigger("push",{type:"update",items:t})},pushDestroy:function(e){var t=this._removeItems(e);t.length&&this.trigger("push",{type:"destroy",items:t})},_removeItems:function(e,r){var i,n,a,s,o,u,l;Se(e)||(e=[e]),i=t===r||r,n=[],a=this.options.autoSync,this.options.autoSync=!1;try{for(s=0;s<e.length;s++)o=e[s],u=this._createNewModel(o),l=!1,this._eachItem(this._data,function(e){var t,r;for(t=0;t<e.length;t++)if(r=e.at(t),r.id===u.id){n.push(r),e.splice(t,1), l=!0;break}}),l&&i&&(this._removePristineForModel(u),this._destroyed.pop())}finally{this.options.autoSync=a}return n},remove:function(e){var t,r=this,i=r._isServerGrouped();return this._eachItem(r._data,function(n){if(t=M(n,e),t&&i)return t.isNew&&t.isNew()||r._destroyed.push(t),!0}),this._removeModelFromRanges(e),e},destroyed:function(){return this._destroyed},created:function(){var e,t,r=[],i=this._flatData(this._data,this.options.useRanges);for(e=0,t=i.length;e<t;e++)i[e].isNew&&i[e].isNew()&&r.push(i[e]);return r},updated:function(){var e,t,r=[],i=this._flatData(this._data,this.options.useRanges);for(e=0,t=i.length;e<t;e++)i[e].isNew&&!i[e].isNew()&&i[e].dirty&&r.push(i[e]);return r},sync:function(){var t,r=this,i=[],n=[],a=r._destroyed,s=e.Deferred().resolve().promise();if(r.online()){if(!r.reader.model)return s;i=r.created(),n=r.updated(),t=[],r.options.batch&&r.transport.submit?t=r._sendSubmit(i,n,a):(t.push.apply(t,r._send("create",i)),t.push.apply(t,r._send("update",n)),t.push.apply(t,r._send("destroy",a))),s=e.when.apply(null,t).then(function(){var e,t;for(e=0,t=arguments.length;e<t;e++)arguments[e]&&r._accept(arguments[e]);r._storeData(!0),r._syncEnd(),r._change({action:"sync"}),r.trigger(Ee),r._isServerGroupPaged()&&r.read()})}else r._storeData(!0),r._syncEnd(),r._change({action:"sync"});return s},_syncEnd:xe,cancelChanges:function(e){var t=this;e instanceof Pe.data.Model?t._cancelModel(e):(t._destroyed=[],t._detachObservableParents(),t._data=t._observe(t._pristineData),t.options.serverPaging&&(t._total=t._pristineTotal),t._ranges=[],t._addRange(t._data,0),t._changesCanceled(),t._change(),t._markOfflineUpdatesAsDirty(),t._isServerGrouped()&&t.read())},_changesCanceled:xe,_markOfflineUpdatesAsDirty:function(){var e=this;null!=e.options.offlineStorage&&e._eachItem(e._data,function(e){var t,r;for(t=0;t<e.length;t++)r=e.at(t),"update"!=r.__state__&&"create"!=r.__state__||(r.dirty=!0)})},hasChanges:function(){var e,t,r=this._flatData(this._data,this.options.useRanges);if(this._destroyed.length)return!0;for(e=0,t=r.length;e<t;e++)if(r[e].isNew&&r[e].isNew()||r[e].dirty)return!0;return!1},_accept:function(t){var r,i=this,n=t.models,a=t.response,s=0,o=i._isServerGrouped(),u=i._pristineData,l=t.type;if(i.trigger(Be,{response:a,type:l}),a&&!ye(a)){if(a=i.reader.parse(a),i._handleCustomErrors(a))return;a=i.reader.data(a),Se(a)||(a=[a])}else a=e.map(n,function(e){return e.toJSON()});for("destroy"===l&&(i._destroyed=[]),s=0,r=n.length;s<r;s++)"destroy"!==l?(n[s].accept(a[s]),"create"===l?u.push(o?i._wrapInEmptyGroup(n[s].toJSON()):a[s]):"update"===l&&i._updatePristineForModel(n[s],a[s])):i._removePristineForModel(n[s])},_updatePristineForModel:function(e,t){this._executeOnPristineForModel(e,function(e,r){Pe.deepExtend(r[e],t)})},_executeOnPristineForModel:function(e,t){this._eachPristineItem(function(r){var i=N(r,e);if(i>-1)return t(i,r),!0})},_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.call(this.reader,e)},_eachPristineItem:function(e){var t=this,r=t.options,i=t._getCurrentRangeSpan();t._eachItem(t._pristineData,e),r.serverPaging&&r.useRanges&&we(i,function(r,i){t._eachItem(i.pristineData,e)})},_eachItem:function(e,t){e&&e.length&&(this._isServerGrouped()?I(e,t):t(e))},_pristineForModel:function(e){var t,r,i=function(i){if(r=N(i,e),r>-1)return t=i[r],!0};return this._eachPristineItem(i),t},_cancelModel:function(e){var t=this,r=this._pristineForModel(e);this._eachItem(this._data,function(i){var n=L(i,e);n>=0&&(!r||e.isNew()&&!r.__state__?(t._modelCanceled(e),i.splice(n,1),t._removeModelFromRanges(e)):(i[n].accept(r),"update"==r.__state__&&(i[n].dirty=!0)))})},_modelCanceled:xe,_submit:function(t,r){var i=this;i.trigger(Le,{type:"submit"}),i.trigger(je),i.transport.submit(_e({success:function(r,i){var n=e.grep(t,function(e){return e.type==i})[0];n&&n.resolve({response:r,models:n.models,type:i})},error:function(e,r,n){for(var a=0;a<t.length;a++)t[a].reject(e);i.error(e,r,n)}},r))},_sendSubmit:function(t,r,i){var n=this,a=[];return n.options.batch&&(t.length&&a.push(e.Deferred(function(e){e.type="create",e.models=t})),r.length&&a.push(e.Deferred(function(e){e.type="update",e.models=r})),i.length&&a.push(e.Deferred(function(e){e.type="destroy",e.models=i})),n._submit(a,{data:{created:n.reader.serialize(w(t)),updated:n.reader.serialize(w(r)),destroyed:n.reader.serialize(w(i))}})),a},_promise:function(t,r,i){var n=this;return e.Deferred(function(e){n.trigger(Le,{type:i}),n.trigger(je),n.transport[i].call(n.transport,_e({success:function(t){e.resolve({response:t,models:r,type:i})},error:function(t,r,i){e.reject(t),n.error(t,r,i)}},t))}).promise()},_send:function(e,t){var r,i,n=this,a=[],s=n.reader.serialize(w(t));if(n.options.batch)t.length&&a.push(n._promise({data:{models:s}},t,e));else for(r=0,i=t.length;r<i;r++)a.push(n._promise({data:s[r]},[t[r]],e));return a},read:function(t){var r=this,i=r._params(t),n=e.Deferred();return r._queueRequest(i,function(){var e=r.trigger(Le,{type:"read"});e?(r._dequeueRequest(),n.resolve(e)):(r.trigger(je),r._ranges=[],r.trigger("reset"),r.online()?r.transport.read({data:i,success:function(e){r._ranges=[],r.success(e,i),n.resolve()},error:function(){var e=Ze.call(arguments);r.error.apply(r,e),n.reject.apply(n,e)}}):null!=r.options.offlineStorage&&(r.success(r.offlineData(),i),n.resolve()))}),n.promise()},_readAggregates:function(e){return this.reader.aggregates(e)},success:function(e){var r,i,n,a,s,o,u,l,g,d,h,f=this,c=f.options;if(f.trigger(Be,{response:e,type:"read"}),f.online()){if(e=f.reader.parse(e),f._handleCustomErrors(e))return f._dequeueRequest(),t;f._total=f.reader.total(e),f._isServerGroupPaged()&&(f._serverGroupsTotal=f._total),f._pageSize>f._total&&(f._pageSize=f._total,f.options.pageSize&&f.options.pageSize>f._pageSize&&(f._pageSize=f.options.pageSize)),f._aggregate&&c.serverAggregates&&(f._aggregateResult=f._readAggregates(e)),e=f._readData(e),f._destroyed=[]}else{for(e=f._readData(e),r=[],n={},a=f.reader.model,s=a?a.idField:"id",o=0;o<this._destroyed.length;o++)u=this._destroyed[o][s],n[u]=u;for(o=0;o<e.length;o++)l=e[o],g=l.__state__,"destroy"==g?n[l[s]]||this._destroyed.push(this._createNewModel(l)):r.push(l);e=r,f._total=e.length}if(f._pristineTotal=f._total,i=f._skip&&f._data.length&&f._skip<f._data.length,f.options.endless)for(i&&f._pristineData.splice(f._skip,f._pristineData.length),r=e.slice(0),d=0;d<r.length;d++)f._pristineData.push(r[d]);else f._pristineData=e.slice(0);if(f._detachObservableParents(),f.options.endless){for(f._data.unbind(Ae,f._changeHandler),f._isServerGrouped()&&f._data[f._data.length-1].value===e[0].value&&(q(f._data[f._data.length-1],e[0]),e.shift()),e=f._observe(e),i&&f._data.splice(f._skip,f._data.length),h=0;h<e.length;h++)f._data.push(e[h]);f._data.bind(Ae,f._changeHandler)}else f._data=f._observe(e);f._markOfflineUpdatesAsDirty(),f._storeData(),f._addRange(f._data),f._process(f._data),f._dequeueRequest()},_detachObservableParents:function(){if(this._data&&this._shouldDetachObservableParents)for(var e=0;e<this._data.length;e++)this._data[e].parent&&(this._data[e].parent=xe)},_storeData:function(e){function t(e){var r,i,n,a=[];for(r=0;r<e.length;r++)i=e.at(r),n=i.toJSON(),s&&i.items?n.items=t(i.items):(n.uid=i.uid,o&&(i.isNew()?n.__state__="create":i.dirty&&(n.__state__="update"))),a.push(n);return a}var r,i,n,a,s=this._isServerGrouped(),o=this.reader.model;if(null!=this.options.offlineStorage){for(r=t(this._data),i=[],n=0;n<this._destroyed.length;n++)a=this._destroyed[n].toJSON(),a.__state__="destroy",i.push(a);this.offlineData(r.concat(i)),e&&(this._pristineData=this.reader.reader?this.reader.reader._wrapDataAccessBase(r):this.reader._wrapDataAccessBase(r))}},_addRange:function(e,r){var i,n=this,a=t!==r?r:n._skip||0,s={data:e,pristineData:e.toJSON(),timestamp:n._timeStamp()};this._isGroupPaged()?(i=a+e.length,s.outerStart=a,s.outerEnd=i):i=a+n._flatData(e,!0).length,s.start=a,s.end=i,n._ranges.push(s),n._sortRanges(),n._isGroupPaged()&&(n._groupsFlat||(n._groupsFlat=[]),n._appendToGroupsFlat(s.data),n._updateOuterRangesLength())},_appendToGroupsFlat:function(e){var t,r=e.length;for(t=0;t<r;t++)this._groupsFlat.push(e[t])},_getGroupByUid:function(e){var t,r,i=this._groupsFlat.length;for(r=0;r<i;r++)if(t=this._groupsFlat[r],t.uid===e)return t},_sortRanges:function(){this._ranges.sort(function(e,t){return e.start-t.start})},error:function(e,t,r){this._dequeueRequest(),this.trigger(Be,{}),this.trigger(Ne,{xhr:e,status:t,errorThrown:r})},_params:function(e){var t=this,r=_e({take:t.take(),skip:t.skip(),page:t.page(),pageSize:t.pageSize(),sort:t._sort,filter:t._filter,group:t._group,aggregate:t._aggregate,groupPaging:!!t._groupPaging},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=U(r.group,t.reader.model)):delete r.group,t.options.serverFiltering?t.reader.model&&r.filter&&(r.filter=H(r.filter,t.reader.model)):delete r.filter,t.options.serverSorting?t.reader.model&&r.sort&&(r.sort=U(r.sort,t.reader.model)):delete r.sort,t.options.serverAggregates?t.reader.model&&r.aggregate&&(r.aggregate=U(r.aggregate,t.reader.model)):delete r.aggregate,t.options.groupPaging||delete r.groupPaging,r},_queueRequest:function(e,r){var i=this;i._requestInProgress?i._pending={callback:me(r,i),options:e}:(i._requestInProgress=!0,i._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(Ne,{xhr:null,status:"customerror",errorThrown:"custom error",errors:t}),!0}return!1},_shouldWrap:function(e){var t=this.reader.model;return!(!t||!e.length)&&!(e[0]instanceof t)},_observe:function(e){var t,r=this,i=r.reader.model;return r._shouldDetachObservableParents=!0,e instanceof at?(r._shouldDetachObservableParents=!1,r._shouldWrap(e)&&(e.type=r.reader.model,e.wrapAll(e,e))):(t=r.pageSize()&&!r.options.serverPaging?K:at,e=new t(e,r.reader.model),e.parent=function(){return r.parent()}),r._isServerGrouped()&&z(e,i),!(r._changeHandler&&r._data&&r._data instanceof at)||r.options.useRanges&&r.options.serverPaging?r._changeHandler=me(r._change,r):r._data.unbind(Ae,r._changeHandler),e.bind(Ae,r._changeHandler)},_updateTotalForAction:function(e,t){var r=this,i=parseInt(r._total,10);b(r._total)||(i=parseInt(r._pristineTotal,10)),"add"===e?i+=t.length:"remove"===e?i-=t.length:"itemchange"===e||"sync"===e||r.options.serverPaging?"sync"===e&&(i=r._pristineTotal=parseInt(r._total,10)):i=r._pristineTotal,r._total=i},_change:function(e){var t,r,i,n=this,a=e?e.action:"";if("remove"===a)for(t=0,r=e.items.length;t<r;t++)e.items[t].isNew&&e.items[t].isNew()||n._destroyed.push(e.items[t]);!n.options.autoSync||"add"!==a&&"remove"!==a&&"itemchange"!==a?(n._updateTotalForAction(a,e?e.items:[]),n._process(n._data,e)):(i=function(t){"sync"===t.action&&(n.unbind("change",i),n._updateTotalForAction(a,e.items))},n.first("change",i),n.sync())},_calculateAggregates:function(e,t){t=t||{};var r=new s(e),i=t.aggregate,n=t.filter;return n&&(r=r.filter(n)),r.aggregate(i)},_process:function(e,r){var i,n=this,a={};n.options.serverPaging!==!0&&(a.skip=n._skip,a.take=n._take||n._pageSize,a.skip===t&&n._page!==t&&n._pageSize!==t&&(a.skip=(n._page-1)*n._pageSize),n.options.useRanges&&(a.skip=n.currentRangeStart())),n.options.serverSorting!==!0&&(a.sort=n._sort),n.options.serverFiltering!==!0&&(a.filter=n._filter),n.options.serverGrouping!==!0&&(a.group=n._group),n.options.serverAggregates!==!0&&(a.aggregate=n._aggregate),n.options.serverGrouping&&n._clearEmptyGroups(e),a.groupPaging=n._groupPaging,i=n._isGroupPaged()&&r&&("page"===r.action||"expandGroup"===r.action||"collapseGroup"===r.action)?n._queryProcess(e,{aggregate:n._aggregate}):n._queryProcess(e,a),n.options.serverAggregates!==!0&&(n._aggregateResult=n._calculateAggregates(i.dataToAggregate||e,a)),n._setView(i,a,r),n._setFilterTotal(i.total,!1),r=r||{},r.items=r.items||n._view,n.trigger(Ae,r)},_setView:function(e,t,r){var i,n=this;n._isGroupPaged()&&!n._isServerGrouped()?!r||"page"!==r.action&&"expandGroup"!==r.action&&"collapseGroup"!==r.action?(n._ranges=[],i=new s(e.data),n._addRange(n._observe(e.data)),t.skip+t.take>e.data.length&&(t.skip=e.data.length-t.take),n.view(i.range(t.skip,t.take).toArray())):(n.view(e.data),n._updateOuterRangesLength()):n.view(e.data)},_clearEmptyGroups:function(e){var t,r;for(t=e.length-1;t>=0;t--)r=e[t],r.hasSubgroups?this._clearEmptyGroups(r.items):r.items&&!r.items.length&&Xe.apply(r.parent(),[t,1])},_queryProcess:function(e,t){return this.options.inPlaceSort?s.process(e,t,this.options.inPlaceSort):s.process(e,t)},_mergeState:function(r){var i=this;return r!==t&&(i._pageSize=r.pageSize,i._page=r.page,i._sort=r.sort,i._filter=r.filter,i._group=r.group,i._aggregate=r.aggregate,i._skip=i._currentRangeStart=r.skip,i._take=r.take,i._skip===t&&(i._skip=i._currentRangeStart=i.skip(),r.skip=i.skip()),i._take===t&&i._pageSize!==t&&(i._take=i._pageSize,r.take=i._take),r.sort&&(i._sort=r.sort=o(r.sort),i._sortFields=u(r.sort)),r.filter&&(i._filter=r.filter=i.options.accentFoldingFiltering&&!e.isEmptyObject(r.filter)?e.extend({},g(r.filter),{accentFoldingFiltering:i.options.accentFoldingFiltering}):g(r.filter)),r.group&&(i._group=r.group=_(r.group)),r.aggregate&&(i._aggregate=r.aggregate=p(r.aggregate))),r},query:function(r){var i,n,a,s=this.options.serverSorting||this.options.serverPaging||this.options.serverFiltering||this.options.serverGrouping||this.options.serverAggregates;return s||(this._data===t||0===this._data.length)&&!this._destroyed.length?(this.options.endless&&(n=r.pageSize-this.pageSize(),n>0?(n=this.pageSize(),r.page=r.pageSize/n,r.pageSize=n):(r.page=1,this.options.endless=!1)),this.read(this._mergeState(r))):(a=this.trigger(Le,{type:"read"}),a||(this.trigger(je),r&&(r.groupPaging=this._groupPaging),i=this._queryProcess(this._data,this._mergeState(r)),this._setFilterTotal(i.total,!0),this._aggregateResult=this._calculateAggregates(i.dataToAggregate||this._data,r),this._setView(i,r),this.trigger(Be,{type:"read"}),this.trigger(Ae,{items:i.data,action:r?r.action:""})),e.Deferred().resolve(a).promise())},_hasExpandedSubGroups:function(e){var t,r=!1,i=e.items?e.items.length:0;if(!e.hasSubgroups)return!1;for(t=0;t<i;t++)if(this._groupsState[e.items[t].uid]){r=!0;break}return r},_findGroupedRange:function(e,r,i,n,a){var s,o,u,l,g,d,h,f=this,c=e.length;for(d=0;d<c&&(s=e[d],!(i.taken>=i.take));d++)if(f._getGroupByUid(s.uid)||f._groupsFlat.push(s),f._groupsState[s.uid]){if(f._isServerGroupPaged()){if(f._fetchGroupItems(s,i,n,a))return f._fetchingGroupItems=!0,t;if(l=(s.subgroupCount||s.itemCount)+1,g=i.skip-i.skipped,!f._hasExpandedSubGroups(s)&&g>l){i.skipped+=l;continue}}if(i.includeParents&&i.skipped<i.skip?(i.skipped++,s.excludeHeader=!0):i.includeParents&&(i.taken++,s.excludeHeader=!1),s.hasSubgroups&&s.items&&s.items.length)s.currentItems=[],n||(n=[]),n.push(s),f._findGroupedRange(s.items,s.currentItems,i,n,a),n.pop(),s.currentItems.length||i.taken>0?r.push(s):s.excludeHeader=!1;else{for(o=[],u=s.items.length,h=0;h<u;h++)if(i.skipped<i.skip)i.skipped++;else{if(i.taken>=i.take)break;o.push(s.items[h]),i.taken++}o.length||i.taken>0?(s.currentItems=o,r.push(s)):s.excludeHeader=!1}}else{if(i.skipped<i.skip){i.skipped++;continue}r.push(s),i.taken++}},_expandedSubGroupItemsCount:function(e,t,r){var i,n,a,s=this,o=0,u="number"==typeof t,l=u?t:e.subgroupCount;if(!e.hasSubgroups)return o;for(a=0;a<l&&(i=e.items[a],i);a++)if(i.hasSubgroups&&s._groupsState[e.uid]?(n=s._expandedSubGroupItemsCount(i,l,!0),o+=n,u&&(l-=n)):!i.hasSubgroups&&s._groupsState[i.uid]&&(n=i.items?i.items.length:0,o+=n,u&&(l-=n)),r&&(o+=1,u&&(l-=1)),u&&o>l)return o;return o},_fetchGroupItems:function(e,r,i,n){var a,s,o,u,l=this,g=e.hasSubgroups?e.subgroupCount:e.itemCount,d=r.take,h=r.skipped,f=l.take();return r.includeParents&&(h<r.skip?h+=1:d-=1),!e.items||e.items&&!e.items.length?(l.getGroupItems(e,r,i,n,0),!0):(u=this._expandedSubGroupItemsCount(e,r.skip-h),a=Math.max(r.skip-(h+u),0),!(a>=g)&&(s=e.items[a],o=e.items[Math.min(a+d,g-1)],s.notFetched?(l.getGroupItems(e,r,i,n,Qe.max(Qe.floor(a/f),0)*f),!0):o.notFetched?(l.getGroupItems(e,r,i,n,Qe.max(Qe.floor((a+f)/f),0)*f),!0):t))},getGroupItems:function(e,t,r,i,n){var a,s,o,u,l=this;e.items||(e.items=[]),a=l.take(),s=this._composeItemsFilter(e,r),o={page:Qe.floor((n||0)/(a||1))||1,pageSize:a,skip:n,take:a,filter:s,aggregate:l._aggregate,sort:l._sort},u=l.findSubgroups(e),u&&u.length&&(o.group=u,o.groupPaging=!0),clearTimeout(l._timeout),l._timeout=setTimeout(function(){l._queueRequest(o,function(){l.trigger(Le,{type:"read"})?l._dequeueRequest():l.transport.read({data:o,success:l._groupItemsSuccessHandler(e,t.skip,l.take(),i,n),error:function(){var e=Ze.call(arguments);l.error.apply(l,e)}})})},100)},_groupItemsSuccessHandler:function(e,t,r,i,n){var a,s=this,o=s._timeStamp();return i=Fe(i)?i:xe,a=s.options.schema&&s.options.schema.total?s.options.schema.total:"Total",function(u){var l,g,d,h=ee.define(s.options.schema.model);for(s._dequeueRequest(),s.trigger(Be,{response:u,type:"read"}),g=Fe(a)?a(u):u[a],u=s.reader.parse(u),e.hasSubgroups?(l=s.reader.groups(u),e.subgroupCount=g):(l=s.reader.data(u),l=l.map(function(e){return new h(e)})),e.items.omitChangeEvent=!0,d=0;d<g;d++)d>=n&&d<n+r?e.items.splice(d,1,l[d-n]):e.items[d]||e.items.splice(d,0,{notFetched:!0});e.items.omitChangeEvent=!1,s._updateRangePristineData(e),s._fetchingGroupItems=!1,e.countAdded||(s._serverGroupsTotal+=g,e.countAdded=!0),s.range(t,r,i,"expandGroup"),(o>=s._currentRequestTimeStamp||!s._skipRequestsInProgress)&&s.trigger(Ae,{})}},findSubgroups:function(e){var t=this._group.map(function(e){return e.field}).indexOf(e.field);ret