//>>built
define("dijit/tree/_dndSelector","dojo/_base/array dojo/_base/declare dojo/_base/kernel dojo/_base/lang dojo/dnd/common dojo/dom dojo/mouse dojo/on dojo/touch ../a11yclick ./_dndContainer".split(" "),function(e,m,n,f,k,p,q,g,h,l,r){return m("dijit.tree._dndSelector",r,{constructor:function(){this.selection={};this.anchor=null;this.events.push(g(this.tree.domNode,h.press,f.hitch(this,"onMouseDown")),g(this.tree.domNode,h.release,f.hitch(this,"onMouseUp")),g(this.tree.domNode,h.move,f.hitch(this,"onMouseMove")),
g(this.tree.domNode,l.press,f.hitch(this,"onClickPress")),g(this.tree.domNode,l.release,f.hitch(this,"onClickRelease")))},singular:!1,getSelectedTreeNodes:function(){var a=[],b=this.selection,c;for(c in b)a.push(b[c]);return a},selectNone:function(){this.setSelection([]);return this},destroy:function(){this.inherited(arguments);this.selection=this.anchor=null},addTreeNode:function(a,b){this.setSelection(this.getSelectedTreeNodes().concat([a]));b&&(this.anchor=a);return a},removeTreeNode:function(a){var b=
e.filter(this.getSelectedTreeNodes(),function(c){return!p.isDescendant(c.domNode,a.domNode)});this.setSelection(b);return a},isTreeNodeSelected:function(a){return a.id&&!!this.selection[a.id]},setSelection:function(a){var b=this.getSelectedTreeNodes();e.forEach(this._setDifference(b,a),f.hitch(this,function(c){c.setSelected(!1);this.anchor==c&&delete this.anchor;delete this.selection[c.id]}));e.forEach(this._setDifference(a,b),f.hitch(this,function(c){c.setSelected(!0);this.selection[c.id]=c}));this._updateSelectionProperties()},
_setDifference:function(a,b){e.forEach(b,function(d){d.__exclude__=!0});var c=e.filter(a,function(d){return!d.__exclude__});e.forEach(b,function(d){delete d.__exclude__});return c},_updateSelectionProperties:function(){var a=this.getSelectedTreeNodes(),b=[],c=[];e.forEach(a,function(d){var t=d.getTreePath();c.push(d);b.push(t)},this);a=e.map(c,function(d){return d.item});this.tree._set("paths",b);this.tree._set("path",b[0]||[]);this.tree._set("selectedNodes",c);this.tree._set("selectedNode",c[0]||
null);this.tree._set("selectedItems",a);this.tree._set("selectedItem",a[0]||null)},onClickPress:function(a){if(!(this.current&&this.current.isExpandable&&this.tree.isExpandoNode(a.target,this.current))){"mousedown"==a.type&&q.isLeft(a)&&a.preventDefault();var b="keydown"==a.type?this.tree.focusedChild:this.current;if(b){var c=k.getCopyKeyState(a),d=b.id;this.singular||a.shiftKey||!this.selection[d]?(this._doDeselect=!1,this.userSelect(b,c,a.shiftKey)):this._doDeselect=!0}}},onClickRelease:function(a){this._doDeselect&&
(this._doDeselect=!1,this.userSelect("keyup"==a.type?this.tree.focusedChild:this.current,k.getCopyKeyState(a),a.shiftKey))},onMouseMove:function(){this._doDeselect=!1},onMouseDown:function(){},onMouseUp:function(){},_compareNodes:function(a,b){if(a===b)return 0;if("sourceIndex"in document.documentElement)return a.sourceIndex-b.sourceIndex;if("compareDocumentPosition"in document.documentElement)return a.compareDocumentPosition(b)&2?1:-1;if(document.createRange){var c=doc.createRange();c.setStartBefore(a);
var d=doc.createRange();d.setStartBefore(b);return c.compareBoundaryPoints(c.END_TO_END,d)}throw Error("dijit.tree._compareNodes don't know how to compare two different nodes in this browser");},userSelect:function(a,b,c){if(this.singular)this.anchor==a&&b?this.selectNone():(this.setSelection([a]),this.anchor=a);else if(c&&this.anchor){b=this._compareNodes(this.anchor.rowNode,a.rowNode);c=this.anchor;0>b?b=c:(b=a,a=c);for(c=[];b!=a;)c.push(b),b=this.tree._getNext(b);c.push(a);this.setSelection(c)}else this.selection[a.id]&&
b?this.removeTreeNode(a):b?this.addTreeNode(a,!0):(this.setSelection([a]),this.anchor=a)},getItem:function(a){return{data:this.selection[a],type:["treeNode"]}},forInSelectedItems:function(a,b){b=b||n.global;for(var c in this.selection)a.call(b,this.getItem(c),c,this)}})});