//>>built
define("dojox/grid/enhanced/plugins/Search","dojo/_base/kernel,dojo/_base/lang,dojo/_base/declare,dojo/_base/array,dojo/data/util/filter,../../EnhancedGrid,../_Plugin".split(","),function(h,a,k,i,j,l,m){h=k("dojox.grid.enhanced.plugins.Search",m,{name:"search",constructor:function(b,c){this.grid=b;c=c&&a.isObject(c)?c:{};this._cacheSize=c.cacheSize||-1;b.searchRow=a.hitch(this,"searchRow")},searchRow:function(b,c){if(a.isFunction(c)){a.isString(b)&&(b=j.patternToRegExp(b));var g=!1;if(b instanceof
RegExp)g=!0;else if(a.isObject(b)){var e=!0,f;for(f in b)a.isString(b[f])&&(b[f]=j.patternToRegExp(b[f])),e=!1;if(e)return}else return;this._search(b,0,c,g)}},_search:function(b,c,g,e){var f=this,d=this._cacheSize,a={start:c,query:this.grid.query,sort:this.grid.getSortProps(),queryOptions:this.grid.queryOptions,onBegin:function(b){f._storeSize=b},onComplete:function(a){i.some(a,function(a,d){return f._checkRow(a,b,e)?(g(c+d,a),!0):!1})||(0<d&&c+d<f._storeSize?f._search(b,c+d,g,e):g(-1,null))}};if(0<
d)a.count=d;this.grid._storeLayerFetch(a)},_checkRow:function(b,c,a){var e=this.grid,f=e.store,d,e=i.filter(e.layout.cells,function(a){return!a.hidden});if(a)return i.some(e,function(a){try{if(a.field)return 0<=(""+f.getValue(b,a.field)).search(c)}catch(d){}return!1});for(d in c)if(c[d]instanceof RegExp){for(a=e.length-1;0<=a;--a)if(e[a].field==d)try{if(0>(""+f.getValue(b,d)).search(c[d]))return!1;break}catch(h){return!1}if(0>a)return!1}return!0}});l.registerPlugin(h);return h});