//>>built
define("dojox/data/OpmlStore","dojo/_base/declare dojo/_base/lang dojo/_base/xhr dojo/data/util/simpleFetch dojo/data/util/filter dojo/_base/kernel".split(" "),function(m,q,r,x,t,n){m=m("dojox.data.OpmlStore",null,{constructor:function(a){this._xmlData=null;this._arrayOfTopLevelItems=[];this._arrayOfAllItems=[];this._metadataNodes=null;this._loadFinished=!1;this.url=a.url;this._opmlData=a.data;a.label&&(this.label=a.label);this._loadInProgress=!1;this._queuedFetches=[];this._identityMap={};this._identCount=
0;this._idProp="_I";a&&"urlPreventCache"in a&&(this.urlPreventCache=a.urlPreventCache?!0:!1)},label:"text",url:"",urlPreventCache:!1,_assertIsItem:function(a){if(!this.isItem(a))throw Error("dojo.data.OpmlStore: a function was passed an item argument that was not an item");},_assertIsAttribute:function(a){if(!q.isString(a))throw Error("dojox.data.OpmlStore: a function was passed an attribute argument that was not an attribute object nor an attribute name string");},_removeChildNodesThatAreNotElementNodes:function(a,
b){var c=a.childNodes;if(0!==c.length){var d=[],e;for(e=0;e<c.length;++e){var f=c[e];1!=f.nodeType&&d.push(f)}for(e=0;e<d.length;++e)f=d[e],a.removeChild(f);if(b)for(e=0;e<c.length;++e)f=c[e],this._removeChildNodesThatAreNotElementNodes(f,b)}},_processRawXmlTree:function(a){this._loadFinished=!0;this._xmlData=a;var b=a.getElementsByTagName("head")[0];b&&(this._removeChildNodesThatAreNotElementNodes(b),this._metadataNodes=b.childNodes);a=a.getElementsByTagName("body");if(b=a[0])for(this._removeChildNodesThatAreNotElementNodes(b,
!0),a=a[0].childNodes,b=0;b<a.length;++b){var c=a[b];"outline"==c.tagName&&(this._identityMap[this._identCount]=c,this._identCount++,this._arrayOfTopLevelItems.push(c),this._arrayOfAllItems.push(c),this._checkChildNodes(c))}},_checkChildNodes:function(a){if(a.firstChild)for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];"outline"==c.tagName&&(this._identityMap[this._identCount]=c,this._identCount++,this._arrayOfAllItems.push(c),this._checkChildNodes(c))}},_getItemsArray:function(a){return a&&
a.deep?this._arrayOfAllItems:this._arrayOfTopLevelItems},getValue:function(a,b,c){this._assertIsItem(a);this._assertIsAttribute(b);if("children"==b)return a.firstChild||c;a=a.getAttribute(b);return void 0!==a?a:c},getValues:function(a,b){this._assertIsItem(a);this._assertIsAttribute(b);var c=[];if("children"==b)for(var d=0;d<a.childNodes.length;++d)c.push(a.childNodes[d]);else null!==a.getAttribute(b)&&c.push(a.getAttribute(b));return c},getAttributes:function(a){this._assertIsItem(a);for(var b=[],
c=a.attributes,d=0;d<c.length;++d){var e=c.item(d);b.push(e.nodeName)}0<a.childNodes.length&&b.push("children");return b},hasAttribute:function(a,b){return 0<this.getValues(a,b).length},containsValue:function(a,b,c){var d=void 0;"string"===typeof c&&(d=t.patternToRegExp(c,!1));return this._containsValue(a,b,c,d)},_containsValue:function(a,b,c,d){a=this.getValues(a,b);for(b=0;b<a.length;++b){var e=a[b];if("string"===typeof e&&d)return null!==e.match(d);if(c===e)return!0}return!1},isItem:function(a){return a&&
1==a.nodeType&&"outline"==a.tagName&&a.ownerDocument===this._xmlData},isItemLoaded:function(a){return this.isItem(a)},loadItem:function(a){},getLabel:function(a){if(this.isItem(a))return this.getValue(a,this.label)},getLabelAttributes:function(a){return[this.label]},_fetchItems:function(a,b,c){var d=this,e=function(f,g){var k=null;if(f.query){k=[];var l=f.queryOptions?f.queryOptions.ignoreCase:!1,u={},h;for(h in f.query){var p=f.query[h];"string"===typeof p&&(u[h]=t.patternToRegExp(p,l))}for(l=0;l<
g.length;++l){var v=!0,w=g[l];for(h in f.query)p=f.query[h],d._containsValue(w,h,p,u[h])||(v=!1);v&&k.push(w)}}else 0<g.length&&(k=g.slice(0,g.length));b(k,f)};if(this._loadFinished)e(a,this._getItemsArray(a.queryOptions));else if(this._loadInProgress)this._queuedFetches.push({args:a,filter:e});else if(""!==this.url)this._loadInProgress=!0,c=r.get({url:d.url,handleAs:"xml",preventCache:d.urlPreventCache}),c.addCallback(function(f){d._processRawXmlTree(f);e(a,d._getItemsArray(a.queryOptions));d._handleQueuedFetches()}),
c.addErrback(function(f){throw f;});else if(this._opmlData)this._processRawXmlTree(this._opmlData),this._opmlData=null,e(a,this._getItemsArray(a.queryOptions));else throw Error("dojox.data.OpmlStore: No OPML source data was provided as either URL or XML data input.");},getFeatures:function(){return{"dojo.data.api.Read":!0,"dojo.data.api.Identity":!0}},getIdentity:function(a){if(this.isItem(a))for(var b in this._identityMap)if(this._identityMap[b]===a)return b;return null},fetchItemByIdentity:function(a){if(this._loadFinished)c=
this._identityMap[a.identity],this.isItem(c)||(c=null),a.onItem&&(d=a.scope?a.scope:n.global,a.onItem.call(d,c));else{var b=this;if(""!==this.url)this._loadInProgress?this._queuedFetches.push({args:a}):(this._loadInProgress=!0,c=r.get({url:b.url,handleAs:"xml"}),c.addCallback(function(e){var f=a.scope?a.scope:n.global;try{b._processRawXmlTree(e);var g=b._identityMap[a.identity];b.isItem(g)||(g=null);a.onItem&&a.onItem.call(f,g);b._handleQueuedFetches()}catch(k){a.onError&&a.onError.call(f,k)}}),c.addErrback(function(e){this._loadInProgress=
!1;a.onError&&a.onError.call(a.scope?a.scope:n.global,e)}));else if(this._opmlData){this._processRawXmlTree(this._opmlData);this._opmlData=null;var c=this._identityMap[a.identity];b.isItem(c)||(c=null);if(a.onItem){var d=a.scope?a.scope:n.global;a.onItem.call(d,c)}}}},getIdentityAttributes:function(a){return null},_handleQueuedFetches:function(){if(0<this._queuedFetches.length){for(var a=0;a<this._queuedFetches.length;a++){var b=this._queuedFetches[a],c=b.args;(b=b.filter)?b(c,this._getItemsArray(c.queryOptions)):
this.fetchItemByIdentity(c)}this._queuedFetches=[]}},close:function(a){}});q.extend(m,x);return m});