//>>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(h,t,p,u,q,v,w,r,n){return t("dojox.data.CssRuleStore",null,{_storeRef:"_S",_labelAttribute:"selector",_cache:null,_browserMap:null,_cName:"dojox.data.CssRuleStore",constructor:function(a){a&&h.mixin(this,a);this._cache={};this._allItems=null;this._waiting=[];this.gatherHandle=null;var c=this;
this.gatherHandle=setInterval(function(){try{for(c.context=n.determineContext(c.context),c.gatherHandle&&(clearInterval(c.gatherHandle),c.gatherHandle=null);c._waiting.length;){var b=c._waiting.pop();n.rules.forEach(b.forFunc,null,c.context);b.finishFunc()}}catch(e){}},250)},setContext:function(a){a&&(this.close(),this.context=n.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!=p.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)&&h.isString(b)&&
(b=b.split(",")):"classes"===c?b=a.classes:"rule"===c?b=a.rule.rule:"style"===c?b=a.rule.style:"cssText"===c?v("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&&(h.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=r.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||q.global;if(null===this._allItems){this._allItems={};try{this.gatherHandle?this._waiting.push({forFunc:h.hitch(this,this._handleRule),finishFunc:h.hitch(this,this._handleReturn)}):(n.rules.forEach(h.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(" "),l=[],m=0;m<d.length;m++){var f=d[m],k=f.indexOf(".");if(f&&0<f.length&&-1!==k){var g=f.indexOf(",")||f.indexOf("[");f=f.substring(k,-1!==g&&g>k?g:f.length);l.push(f)}}d={};d.rule=a;d.styleSheet=c;d.href=b;d.classes=l;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){b=this._allItems[e];for(var 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||q.global,b=[],e="all";a.query&&(e=u.toJson(a.query));if(this._cache[e])b=this._cache[e];else if(a.query){for(g in a._items){var d=a._items[g],l=a.queryOptions?a.queryOptions.ignoreCase:!1,m={},f;for(f in a.query){var k=a.query[f];"string"===typeof k&&(m[f]=r.patternToRegExp(k,l))}l=!0;for(f in a.query)k=a.query[f],this._containsValue(d,f,k,m[f])||(l=!1);l&&b.push(d)}this._cache[e]=
b}else for(g in a._items)b.push(a._items[g]);e=b.length;a.sort&&b.sort(w.createSortFunction(a.sort,this));var g=0;d=b.length;0<a.start&&a.start<b.length&&(g=a.start);a.count&&a.count&&(d=a.count);d=g+d;d>b.length&&(d=b.length);b=b.slice(g,d);a.onBegin&&a.onBegin.call(c,e,a);if(a.onItem){if(h.isArray(b)){for(g=0;g<b.length;g++)a.onItem.call(c,b[g],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 p.some(this.getValues(a,c),function(d){if(null!==d&&!h.isObject(d)&&e){if(d.toString().match(e))return!0}else if(b===d)return!0;return!1})}})});