// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/analysis/tree","dojo/_base/declare dojo/_base/array dojo/_base/Deferred dojo/_base/lang dojo/query dojo/on dojo/has dojo/aspect dgrid/util/has-css3 dgrid/Grid dojo/has!touch?dgrid/util/touch put-selector/put ../../kernel".split(" "),function(F,y,z,A,t,B,C,f,u,D,v,m,E){function w(c,f,h,d){d=this.grid.isRTL?"right":"left";var b=".dgrid-expando-icon";f&&(b+=".ui-icon.ui-icon-triangle-1-"+(h?"se":"e"));c=m("div"+b+"[style\x3dmargin-"+d+": "+c*(this.indentWidth||9)+"px; float: "+d+"]");
c.innerHTML="\x26nbsp;";return c}function x(c){var f=this,h=this.style.height;h&&(this.style.display="0px"==h?"none":"block");c&&(m(this,".dgrid-tree-resetting"),setTimeout(function(){m(f,"!dgrid-tree-resetting")}));this.style.height=""}function k(c){var k=c.renderCell||D.defaultRenderCell,h,d;c||(c={});c.shouldExpand=c.shouldExpand||function(b,c,g){return g};f.after(c,"init",function(){var b=c.grid,k=".dgrid-content .dgrid-column-"+c.id,g=[];b.cleanEmptyObservers=!1;if(!b.store)throw Error("dgrid tree column plugin requires a store to operate.");
c.renderExpando||(c.renderExpando=w);g.push(b.on(c.expandOn||".dgrid-expando-icon:click,"+k+":dblclick,"+k+":keydown",function(a){var c=b.row(a);b.store.mayHaveChildren&&!b.store.mayHaveChildren(c.data)||"keydown"==a.type&&32!=a.keyCode||"dblclick"==a.type&&d&&1<d.count&&c.id==d.id&&-1<a.target.className.indexOf("dgrid-expando-icon")||b.expand(c);-1<a.target.className.indexOf("dgrid-expando-icon")&&(d&&d.id==b.row(a).id?d.count++:d={id:b.row(a).id,count:1})}));u("touch")&&g.push(b.on(v.selector(k,
v.dbltap),function(){b.expand(this)}));b._expanded||(b._expanded={});g.push(f.after(b,"insertRow",function(a){var b=this.row(a);c.shouldExpand(b,h,this._expanded[b.id])&&this.expand(a,!0,!0);return a}));g.push(f.before(b,"removeRow",function(a,c){var e=a.connected;e&&(t("\x3e.dgrid-row",e).forEach(function(a){b.removeRow(a,!0)}),c||m(e,"!"))}));c.collapseOnRefresh&&g.push(f.after(b,"cleanup",function(){this._expanded={}}));b._calcRowHeight=function(a){var b=a.connected;return a.offsetHeight+(b?b.offsetHeight:
0)};b.expand=function(a,e,g){var n=a.element?a:b.row(a),d=u("transitionend");a=n.element;if((a=-1<a.className.indexOf("dgrid-expando-icon")?a:t(".dgrid-expando-icon",a)[0])&&a.mayHaveChildren&&(g||e!==!!this._expanded[n.id])){var f=void 0===e?!this._expanded[n.id]:e;m(a,".ui-icon-triangle-1-"+(f?"se":"e")+"!ui-icon-triangle-1-"+(f?"e":"se"));var k=a.preloadNode;e=n.element;var l,h,q,r={originalQuery:this.query};if(!k){l=e.connected=m("div.dgrid-tree-container");var k=a.preloadNode=m(e,"+",l,"div.dgrid-preload"),
p=function(a){return b.store.getChildren(n.data,a)};c.allowDuplicates&&(r.parentId=n.id);"level"in a&&(p.level=a.level);z.when(b.renderQuery?b._trackError(function(){return b.renderQuery(p,k,r)}):b.renderArray(p(r),k,"level"in p?{queryLevel:p.level}:{}),function(){if(b._expanded[n.id]&&d){var a=l.scrollHeight;l.style.height=a?a+"px":"auto"}});d?B(l,d,x):x.call(l)}l=e.connected;l.hidden=!f;h=l.style;!d||g?(h.display=f?"block":"none",h.height=""):(f?(h.display="block",q=l.scrollHeight,h.height="0px"):
(m(l,".dgrid-tree-resetting"),h.height=l.scrollHeight+"px"),setTimeout(function(){m(l,"!dgrid-tree-resetting");h.height=f?q?q+"px":"auto":"0px"}));f?this._expanded[n.id]=!0:delete this._expanded[n.id]}};f.after(c,"destroy",function(){y.forEach(g,function(a){a.remove()});delete b.expand;delete b._calcRowHeight})});c.renderCell=function(b,f,d,a){var e=c.grid,g=Number(a&&a.queryLevel)+1,n=!e.store.mayHaveChildren||e.store.mayHaveChildren(b),m=a.parentId,g=h=isNaN(g)?0:g,e=c.renderExpando(g,n,e._expanded[(m?
m+"-":"")+e.store.getIdentity(b)],b);e.level=g;e.mayHaveChildren=n;a.level=g;k.call(c,b,f,d,a);d.insertBefore(e,d.firstChild)};return c}k.defaultRenderExpando=w;C("extend-esri")&&A.setObject("dijit.analysis.tree",k,E);return k});