//>>built
define("dstore/SimpleQuery",["dojo/_base/declare","dojo/_base/array"],function(m,e){function q(a,b){if(-1<a.indexOf(".")){var d=a.split("."),k=d.length;return function(a){for(var f=0;f<k;f++)a=a&&(b&&a.get?a.get(d[f]):a[d[f]]);return a}}return function(b){return b.get?b.get(a):b[a]}}var n={eq:function(a,b){return a===b},"in":function(a,b){return-1<e.indexOf(b.data||b,a)},ne:function(a,b){return a!==b},lt:function(a,b){return a<b},lte:function(a,b){return a<=b},gt:function(a,b){return a>b},gte:function(a,
b){return a>=b},match:function(a,b,d){return b.test(a,d)},contains:function(a,b,d,k){var g=this;b=b.data?b.data:Array.isArray(b)?b:[b];return e.every(b,function(b){if("object"===typeof b&&b.type){var c=g._getFilterComparator(b.type);return e.some(a,function(a){return c.call(g,a,b.args[1],d,k)})}return-1<e.indexOf(a,b)})}};return m(null,{_createFilterQuerier:function(a){function b(a){var c,f,h=a.type;a=a.args;var g=k._getFilterComparator(h);if(g){var e=a[0],m=q(e,d),l=a[1];l&&l.fetchSync&&(l=l.fetchSync());
return function(a){return g.call(k,m(a),l,a,e)}}switch(h){case "and":case "or":for(var p=0,n=a.length;p<n;p++)f=b(a[p]),c=c?function(a,b){return"and"===h?function(c){return a(c)&&b(c)}:function(c){return a(c)||b(c)}}(c,f):f;return c;case "function":return a[0];case "string":c=k[a[0]];if(!c)throw Error("No filter function "+a[0]+" was found in the collection");return c;case void 0:return function(){return!0};default:throw Error('Unknown filter operation "'+h+'"');}}var d=this.queryAccessors,k=this,
g=b(a);return function(a){return e.filter(a,g)}},_getFilterComparator:function(a){return n[a]||this.inherited(arguments)},_createSelectQuerier:function(a){return function(b){var d=a.length;return e.map(b,a instanceof Array?function(b){for(var g={},f=0;f<d;f++){var c=a[f];g[c]=b[c]}return g}:function(b){return b[a]})}},_createSortQuerier:function(a){var b=this.queryAccessors;return function(d){d=d.slice();d.sort("function"==typeof a?a:function(d,g){for(var f=0;f<a.length;f++){var c,e=a[f];if("function"==
typeof e)c=e(d,g);else{c=e.get||(e.get=q(e.property,b));var e=e.descending,h=c(d);c=c(g);null!=h&&(h=h.valueOf());null!=c&&(c=c.valueOf());c=h===c?0:!!e===("undefined"===typeof c||null===c&&"undefined"!==typeof h||null!=h&&h<c)?1:-1}if(0!==c)return c}return 0});return d}}})});
//# sourceMappingURL=SimpleQuery.js.map