//>>built
define("dojox/data/CssRuleStore","dojo/_base/lang dojo/_base/declare dojo/_base/array dojo/_base/json dojo/_base/kernel dojo/_base/sniff dojo/data/util/sorter dojo/data/util/filter ./css".split(" "),function(f,r,n,t,p,u,v,q,l){return r("dojox.data.CssRuleStore",null,{_storeRef:"_S",_labelAttribute:"selector",_cache:null,_browserMap:null,_cName:"dojox.data.CssRuleStore",constructor:function(a){a&&f.mixin(this,a);this._cache={};this._allItems=null;this._waiting=[];this.gatherHandle=null;var c=this;
this.gatherHandle=setInterval(function(){try{for(c.context=l.determineContext(c.context),c.gatherHandle&&(clearInterval(c.gatherHandle),c.gatherHandle=null);c._waiting.length;){var a=c._waiting.pop();l.rules.forEach(a.forFunc,null,c.context);a.finishFunc()}}catch(e){}},250)},setContext:function(a){a&&(this.close(),this.context=l.determineContext(a))},getFeatures:function(){return{"dojo.data.api.Read":!0}},isItem:function(a){return a&&a[this._storeRef]==this?!0:!1},hasAttribute:function(a,c){this._assertIsItem(a);
this._assertIsAttribute(c);var b=this.getAttributes(a);return-1!=n.indexOf(b,c)?!0:!1},getAttributes:function(a){this._assertIsItem(a);var c="selector classes rule style cssText styleSheet parentStyleSheet parentStyleSheetHref".split(" ");if(a=a.rule.style)for(var b in a)c.push("style."+b);return c},getValue:function(a,c,b){return(a=this.getValues(a,c))&&0<a.length?a[0]:b},getValues:function(a,c){this._assertIsItem(a);this._assertIsAttribute(c);var b=null;"selector"===c?(b=a.rule.selectorText)&&f.isString(b)&&
(b=b.split(",")):"classes"===c?b=a.classes:"rule"===c?b=a.rule.rule:"style"===c?b=a.rule.style:"cssText"===c?u("ie")?a.rule.style&&(b=a.rule.style.cssText)&&(b="{ "+b.toLowerCase()+" }"):(b=a.rule.cssText)&&(b=b.substring(b.indexOf("{"),b.length)):"styleSheet"===c?b=a.rule.styleSheet:"parentStyleSheet"===c?b=a.rule.parentStyleSheet:"parentStyleSheetHref"===c?a.href&&(b=a.href):0===c.indexOf("style.")?(b=c.substring(c.indexOf("."),c.length),b=a.rule.style[b]):b=[];void 0!==b&&(f.isArray(b)||(b=[b]));
return b},getLabel:function(a){this._assertIsItem(a);return this.getValue(a,this._labelAttribute)},getLabelAttributes:function(a){return[this._labelAttribute]},containsValue:function(a,c,b){var e=void 0;"string"===typeof b&&(e=q.patternToRegExp(b,!1));return this._containsValue(a,c,b,e)},isItemLoaded:function(a){return this.isItem(a)},loadItem:function(a){this._assertIsItem(a.item)},fetch:function(a){a=a||{};a.store||(a.store=this);this._pending&&0<this._pending.length?this._pending.push({request:a,
fetch:!0}):(this._pending=[{request:a,fetch:!0}],this._fetch(a));return a},_fetch:function(a){var c=a.scope||p.global;if(null===this._allItems){this._allItems={};try{this.gatherHandle?this._waiting.push({forFunc:f.hitch(this,this._handleRule),finishFunc:f.hitch(this,this._handleReturn)}):(l.rules.forEach(f.hitch(this,this._handleRule),null,this.context),this._handleReturn())}catch(b){a.onError&&a.onError.call(c,b,a)}}else this._handleReturn()},_handleRule:function(a,c,b){for(var e=a.selectorText,
d=e.split(" "),g=[],f=0;f<d.length;f++){var h=d[f],k=h.indexOf(".");if(h&&0<h.length&&-1!==k){var m=h.indexOf(",")||h.indexOf("["),h=h.substring(k,-1!==m&&m>k?m:h.length);g.push(h)}}d={};d.rule=a;d.styleSheet=c;d.href=b;d.classes=g;d[this._storeRef]=this;this._allItems[e]||(this._allItems[e]=[]);this._allItems[e].push(d)},_handleReturn:function(){var a=[],c=[],b=null,e;for(e in this._allItems){var b=this._allItems[e],d;for(d in b)c.push(b[d])}for(;this._pending.length;)b=this._pending.pop(),b.request._items=
c,a.push(b);for(;a.length;)b=a.pop(),this._handleFetchReturn(b.request)},_handleFetchReturn:function(a){var c=a.scope||p.global,b=[],e="all",d;a.query&&(e=t.toJson(a.query));if(this._cache[e])b=this._cache[e];else if(a.query){for(d in a._items){var g=a._items[d],l=a.queryOptions?a.queryOptions.ignoreCase:!1,h={},k,m;for(k in a.query)m=a.query[k],"string"===typeof m&&(h[k]=q.patternToRegExp(m,l));l=!0;for(k in a.query)m=a.query[k],this._containsValue(g,k,m,h[k])||(l=!1);l&&b.push(g)}this._cache[e]=
b}else for(d in a._items)b.push(a._items[d]);e=b.length;a.sort&&b.sort(v.createSortFunction(a.sort,this));d=0;g=b.length;0<a.start&&a.start<b.length&&(d=a.start);a.count&&a.count&&(g=a.count);g=d+g;g>b.length&&(g=b.length);b=b.slice(d,g);a.onBegin&&a.onBegin.call(c,e,a);if(a.onItem){if(f.isArray(b)){for(d=0;d<b.length;d++)a.onItem.call(c,b[d],a);a.onComplete&&a.onComplete.call(c,null,a)}}else a.onComplete&&a.onComplete.call(c,b,a);return a},close:function(){this._cache={};this._allItems=null},_assertIsItem:function(a){if(!this.isItem(a))throw Error(this._cName+
": Invalid item argument.");},_assertIsAttribute:function(a){if("string"!==typeof a)throw Error(this._cName+": Invalid attribute argument.");},_containsValue:function(a,c,b,e){return n.some(this.getValues(a,c),function(a){if(null!==a&&!f.isObject(a)&&e){if(a.toString().match(e))return!0}else if(b===a)return!0;return!1})}})});