//>>built
define("dojox/grid/_Builder","../main,dojo/_base/array,dojo/_base/lang,dojo/_base/window,dojo/_base/event,dojo/_base/sniff,dojo/_base/connect,dojo/dnd/Moveable,dojox/html/metrics,./util,dojo/_base/html,dojo/dom-geometry".split(","),function(s,t,j,l,u,m,x,y,z,q,g,A){var n=s.grid,v=function(a){for(;a&&"TABLE"!=a.tagName;a=a.parentNode);return a},B=function(a){var b=a.toUpperCase();return function(a){return a.tagName!=b}},w=q.rowIndexTag,r=q.gridViewTag,o=n._Builder=j.extend(function(a){if(a)this.view=
a,this.grid=a.grid},{view:null,_table:'<table class="dojoxGridRowTable" border="0" cellspacing="0" cellpadding="0" role="presentation"',getTableArray:function(){var a=[this._table];this.view.viewWidth&&a.push([' style="width:',this.view.viewWidth,';"'].join(""));a.push(">");return a},generateCellMarkup:function(a,b,c,f){var e=[],d;if(f){d=a.index!=a.grid.getSortIndex()?"":0<a.grid.sortInfo?'aria-sort="ascending"':'aria-sort="descending"';if(!a.id)a.id=this.grid.id+"Hdr"+a.index;d=['<th tabIndex="-1" aria-readonly="true" role="columnheader"',
d,'id="',a.id,'"']}else d=['<td tabIndex="-1" role="gridcell"',this.grid.editable&&!a.editable?'aria-readonly="true"':""];a.colSpan&&d.push(' colspan="',a.colSpan,'"');a.rowSpan&&d.push(' rowspan="',a.rowSpan,'"');d.push(' class="dojoxGridCell ');a.classes&&d.push(a.classes," ");c&&d.push(c," ");e.push(d.join(""));e.push("");d=['" idx="',a.index,'" style="'];b&&";"!=b[b.length-1]&&(b+=";");d.push(a.styles,b||"",a.hidden?"display:none;":"");a.unitWidth&&d.push("width:",a.unitWidth,";");e.push(d.join(""));
e.push("");d=['"'];a.attrs&&d.push(" ",a.attrs);d.push(">");e.push(d.join(""));e.push("");e.push(f?"</th>":"</td>");return e},isCellNode:function(a){return Boolean(a&&a!=l.doc&&g.attr(a,"idx"))},getCellNodeIndex:function(a){return a?Number(g.attr(a,"idx")):-1},getCellNode:function(a,b){for(var c=0,f;(f=a.firstChild&&((a.firstChild.rows||0)[c]||a.firstChild.childNodes[c]))&&f.cells;c++)for(var e=0,d;d=f.cells[e];e++)if(this.getCellNodeIndex(d)==b)return d;return null},findCellTarget:function(a,b){for(var c=
a;c&&(!this.isCellNode(c)||c.offsetParent&&r in c.offsetParent.parentNode&&c.offsetParent.parentNode[r]!=this.view.id)&&c!=b;)c=c.parentNode;return c!=b?c:null},baseDecorateEvent:function(a){a.dispatch="do"+a.type;a.grid=this.grid;a.sourceView=this.view;a.cellNode=this.findCellTarget(a.target,a.rowNode);a.cellIndex=this.getCellNodeIndex(a.cellNode);a.cell=0<=a.cellIndex?this.grid.getCell(a.cellIndex):null},findTarget:function(a,b){for(var c=a;c&&c!=this.domNode&&(!(b in c)||r in c&&c[r]!=this.view.id);)c=
c.parentNode;return c!=this.domNode?c:null},findRowTarget:function(a){return this.findTarget(a,w)},isIntraNodeEvent:function(a){try{return a.cellNode&&a.relatedTarget&&g.isDescendant(a.relatedTarget,a.cellNode)}catch(b){return!1}},isIntraRowEvent:function(a){try{var b=a.relatedTarget&&this.findRowTarget(a.relatedTarget);return!b&&-1==a.rowIndex||b&&a.rowIndex==b.gridRowIndex}catch(c){return!1}},dispatchEvent:function(a){return a.dispatch in this?this[a.dispatch](a):!1},domouseover:function(a){if(a.cellNode&&
a.cellNode!=this.lastOverCellNode)this.lastOverCellNode=a.cellNode,this.grid.onMouseOver(a);this.grid.onMouseOverRow(a)},domouseout:function(a){if(a.cellNode&&a.cellNode==this.lastOverCellNode&&!this.isIntraNodeEvent(a,this.lastOverCellNode)&&(this.lastOverCellNode=null,this.grid.onMouseOut(a),!this.isIntraRowEvent(a)))this.grid.onMouseOutRow(a)},domousedown:function(a){if(a.cellNode)this.grid.onMouseDown(a);this.grid.onMouseDownRow(a)}}),s=n._ContentBuilder=j.extend(function(a){o.call(this,a)},o.prototype,
{update:function(){this.prepareHtml()},prepareHtml:function(){for(var a=this.grid.get,b=this.view.structure.cells,c=0,f;f=b[c];c++)for(var e=0,d;d=f[e];e++)if(d.get=d.get||void 0==d.value&&a,d.markup=this.generateCellMarkup(d,d.cellStyles,d.cellClasses,!1),!this.grid.editable&&d.editable)this.grid.editable=!0},generateHtml:function(a,b){var c=this.getTableArray(),f=this.view.structure.cells,e=this.grid.getItem(b);q.fire(this.view,"onBeforeRow",[b,f]);for(var d=0,g;g=f[d];d++)if(!g.hidden&&!g.header){c.push(!g.invisible?
"<tr>":'<tr class="dojoxGridInvisible">');for(var h=0,i,p,j,l;i=g[h];h++)p=i.markup,j=i.customClasses=[],l=i.customStyles=[],p[5]=i.format(b,e),p[1]=j.join(" "),p[3]=l.join(";"),c.push.apply(c,p);c.push("</tr>")}c.push("</table>");return c.join("")},decorateEvent:function(a){a.rowNode=this.findRowTarget(a.target);if(!a.rowNode)return!1;a.rowIndex=a.rowNode[w];this.baseDecorateEvent(a);a.cell=this.grid.getCell(a.cellIndex);return!0}}),C=n._HeaderBuilder=j.extend(function(a){this.moveable=null;o.call(this,
a)},o.prototype,{_skipBogusClicks:!1,overResizeWidth:4,minColWidth:1,update:function(){this.tableMap?this.tableMap.mapRows(this.view.structure.cells):this.tableMap=new n._TableMap(this.view.structure.cells)},generateHtml:function(a,b){var c=this.getTableArray(),f=this.view.structure.cells;q.fire(this.view,"onBeforeRow",[-1,f]);for(var e=0,d;d=f[e];e++)if(!d.hidden){c.push(!d.invisible?"<tr>":'<tr class="dojoxGridInvisible">');for(var g=0,h,i;h=d[g];g++){h.customClasses=[];h.customStyles=[];if(this.view.simpleStructure){if(h.draggable)h.headerClasses?
-1==h.headerClasses.indexOf("dojoDndItem")&&(h.headerClasses+=" dojoDndItem"):h.headerClasses="dojoDndItem";h.attrs?-1==h.attrs.indexOf("dndType='gridColumn_")&&(h.attrs+=" dndType='gridColumn_"+this.grid.id+"'"):h.attrs="dndType='gridColumn_"+this.grid.id+"'"}i=this.generateCellMarkup(h,h.headerStyles,h.headerClasses,!0);i[5]=void 0!=b?b:a(h);i[3]=h.customStyles.join(";");i[1]=h.customClasses.join(" ");c.push(i.join(""))}c.push("</tr>")}c.push("</table>");return c.join("")},getCellX:function(a){var b;
b=B("th");for(var c=a.target;c&&b(c);c=c.parentNode);(b=c)?(b=A.position(b),a=a.clientX-b.x):a=a.layerX;return a},decorateEvent:function(a){this.baseDecorateEvent(a);a.rowIndex=-1;a.cellX=this.getCellX(a);return!0},prepareResize:function(a,b){do{var c=a.cellIndex;a.cellNode=c?a.cellNode.parentNode.cells[c+b]:null;a.cellIndex=a.cellNode?this.getCellNodeIndex(a.cellNode):-1}while(a.cellNode&&"none"==a.cellNode.style.display);return Boolean(a.cellNode)},canResize:function(a){if(!a.cellNode||1<a.cellNode.colSpan)return!1;
a=this.grid.getCell(a.cellIndex);return!a.noresize&&a.canResize()},overLeftResizeArea:function(a){if(g.hasClass(l.body(),"dojoDndMove"))return!1;if(m("ie")){var b=a.target;if(g.hasClass(b,"dojoxGridArrowButtonNode")||g.hasClass(b,"dojoxGridArrowButtonChar")||g.hasClass(b,"dojoxGridColCaption"))return!1}return this.grid.isLeftToRight()?0<a.cellIndex&&0<a.cellX&&a.cellX<this.overResizeWidth&&this.prepareResize(a,-1):a.cellNode&&0<a.cellX&&a.cellX<this.overResizeWidth},overRightResizeArea:function(a){if(g.hasClass(l.body(),
"dojoDndMove"))return!1;if(m("ie")){var b=a.target;if(g.hasClass(b,"dojoxGridArrowButtonNode")||g.hasClass(b,"dojoxGridArrowButtonChar")||g.hasClass(b,"dojoxGridColCaption"))return!1}return this.grid.isLeftToRight()?a.cellNode&&a.cellX>=a.cellNode.offsetWidth-this.overResizeWidth:0<a.cellIndex&&a.cellX>=a.cellNode.offsetWidth-this.overResizeWidth&&this.prepareResize(a,-1)},domousemove:function(a){if(!this.moveable){var b=this.overRightResizeArea(a)?"dojoxGridColResize":this.overLeftResizeArea(a)?
"dojoxGridColResize":"";b&&!this.canResize(a)&&(b="dojoxGridColNoResize");g.toggleClass(a.sourceView.headerNode,"dojoxGridColNoResize","dojoxGridColNoResize"==b);g.toggleClass(a.sourceView.headerNode,"dojoxGridColResize","dojoxGridColResize"==b);b&&u.stop(a)}},domousedown:function(a){this.moveable||((this.overRightResizeArea(a)||this.overLeftResizeArea(a))&&this.canResize(a)?this.beginColumnResize(a):(this.grid.onMouseDown(a),this.grid.onMouseOverRow(a)))},doclick:function(a){return this._skipBogusClicks?
(u.stop(a),!0):!1},colResizeSetup:function(a,b){var c=g.contentBox(a.sourceView.headerNode);if(b){this.lineDiv=document.createElement("div");var f=g.position(a.sourceView.headerNode,!0),e=g.contentBox(a.sourceView.domNode),d=a.pageX;!this.grid.isLeftToRight()&&8>m("ie")&&(d-=z.getScrollbar().w);g.style(this.lineDiv,{top:f.y+"px",left:d+"px",height:e.h+c.h+"px"});g.addClass(this.lineDiv,"dojoxGridResizeColLine");this.lineDiv._origLeft=d;l.body().appendChild(this.lineDiv)}for(var f=[],e=this.tableMap.findOverlappingNodes(a.cellNode),
d=0,k;k=e[d];d++)f.push({node:k,index:this.getCellNodeIndex(k),width:k.offsetWidth});e=a.sourceView;k=this.grid.isLeftToRight()?1:-1;for(var h=a.grid.views.views,d=[],i=e.idx+k,j;j=h[i];i+=k)d.push({node:j.headerNode,left:window.parseInt(j.headerNode.style.left)});k=e.headerContentNode.firstChild;return{scrollLeft:a.sourceView.headerNode.scrollLeft,view:e,node:a.cellNode,index:a.cellIndex,w:g.contentBox(a.cellNode).w,vw:c.w,table:k,tw:g.contentBox(k).w,spanners:f,followers:d}},beginColumnResize:function(a){this.moverDiv=
document.createElement("div");g.style(this.moverDiv,{position:"absolute",left:0});l.body().appendChild(this.moverDiv);g.addClass(this.grid.domNode,"dojoxGridColumnResizing");var b=this.moveable=new y(this.moverDiv),c=this.colResizeSetup(a,!0);b.onMove=j.hitch(this,"doResizeColumn",c);x.connect(b,"onMoveStop",j.hitch(this,function(){this.endResizeColumn(c);c.node.releaseCapture&&c.node.releaseCapture();this.moveable.destroy();delete this.moveable;this.moveable=null;g.removeClass(this.grid.domNode,
"dojoxGridColumnResizing")}));a.cellNode.setCapture&&a.cellNode.setCapture();b.onMouseDown(a)},doResizeColumn:function(a,b,c){var f=c.l,f={deltaX:f,w:a.w+(this.grid.isLeftToRight()?f:-f),vw:a.vw+f,tw:a.tw+f};this.dragRecord={inDrag:a,mover:b,leftTop:c};f.w>=this.minColWidth&&(b?g.style(this.lineDiv,"left",this.lineDiv._origLeft+f.deltaX+"px"):this.doResizeNow(a,f))},endResizeColumn:function(a){if(this.dragRecord){var b=this.dragRecord.leftTop,b=this.grid.isLeftToRight()?b.l:-b.l,b=b+(Math.max(a.w+
b,this.minColWidth)-(a.w+b));m("webkit")&&a.spanners.length&&(b+=g._getPadBorderExtents(a.spanners[0].node).w);this.doResizeNow(a,{deltaX:b,w:a.w+b,vw:a.vw+b,tw:a.tw+b});delete this.dragRecord}g.destroy(this.lineDiv);g.destroy(this.moverDiv);g.destroy(this.moverDiv);delete this.moverDiv;this._skipBogusClicks=!0;a.view.update();this._skipBogusClicks=!1;this.grid.onResizeColumn(a.index)},doResizeNow:function(a,b){a.view.convertColPctToFixed();if(a.view.flexCells&&!a.view.testFlexCells()){var c=v(a.node);
if(c)c.style.width=""}for(var f,e,c=0;f=a.spanners[c];c++)if(e=f.width+b.deltaX,0<e)f.node.style.width=e+"px",a.view.setColWidth(f.index,e);if(this.grid.isLeftToRight()||!m("ie"))for(c=0;f=a.followers[c];c++)e=f.left+b.deltaX,f.node.style.left=e+"px";a.node.style.width=b.w+"px";a.view.setColWidth(a.index,b.w);a.view.headerNode.style.width=b.vw+"px";a.view.setColumnsWidth(b.tw);if(!this.grid.isLeftToRight())a.view.headerNode.scrollLeft=a.scrollLeft+b.deltaX}});n._TableMap=j.extend(function(a){this.mapRows(a)},
{map:null,mapRows:function(a){if(a.length){this.map=[];var b;for(b=0;a[b];b++)this.map[b]=[];for(var c=0;b=a[c];c++)for(var f=0,e=0,d,g;d=b[f];f++){for(;this.map[c][e];)e++;this.map[c][e]={c:f,r:c};g=d.rowSpan||1;d=d.colSpan||1;for(var h=0;h<g;h++)for(var i=0;i<d;i++)this.map[c+h][e+i]=this.map[c][e];e+=d}}},dumpMap:function(){for(var a=0,b;b=this.map[a];a++)for(var c=0;b[c];c++);},getMapCoords:function(a,b){for(var c=0,f;f=this.map[c];c++)for(var e=0,d;d=f[e];e++)if(d.c==b&&d.r==a)return{j:c,i:e};
return{j:-1,i:-1}},getNode:function(a,b,c){return(a=a&&a.rows[b])&&a.cells[c]},_findOverlappingNodes:function(a,b,c){var d;for(var f=[],b=this.getMapCoords(b,c),c=0,e;e=this.map[c];c++)c!=b.j&&(d=(e=e[b.i])?this.getNode(a,e.r,e.c):null,e=d)&&f.push(e);return f},findOverlappingNodes:function(a){return this._findOverlappingNodes(v(a),0<=a.parentNode.rowIndex?a.parentNode.rowIndex:t.indexOf(a.parentNode.parentNode.childNodes,a.parentNode),0<=a.cellIndex?a.cellIndex:t.indexOf(a.parentNode.cells,a))}});
return{_Builder:o,_HeaderBuilder:C,_ContentBuilder:s}});