/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */

window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["require","esri.dijit.editing.tools.ToggleToolBase"],["require","esri.dijit.editing.tools.ButtonToolBase"],["provide","esri.dijit.editing.tools.AdvancedTools"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.dijit.editing.tools.AdvancedTools"]){_4._hasResource["esri.dijit.editing.tools.AdvancedTools"]=true;_4.require("esri.dijit.editing.tools.ToggleToolBase");_4.require("esri.dijit.editing.tools.ButtonToolBase");_4.provide("esri.dijit.editing.tools.AdvancedTools");_4.declare("esri.dijit.editing.tools.Cut",[esri.dijit.editing.tools.ToggleToolBase],{id:"btnFeatureCut",_enabledIcon:"toolbarIcon cutIcon",_disabledIcon:"toolbarIcon cutIcon",_drawType:esri.toolbars.Draw.POLYLINE,_enabled:true,_label:"NLS_cutLbl",_cutConnects:[],activate:function(){this._cutConnects.push(_4.connect(this._toolbar,"onDrawEnd",this,"_onDrawEnd"));this.inherited(arguments);},deactivate:function(){this.inherited(arguments);_4.forEach(this._cutConnects,"dojo.disconnect(item);");this._cutConnects=[];this._edits=[];},_onDrawEnd:function(_7){var _8=this._settings.layers;var _9=this._cutLayers=_4.filter(_8,function(_a){return ((_a.geometryType==="esriGeometryPolygon")||(_a.geometryType==="esriGeometryPolyline")&&_a.visible&&_a._isMapAtVisibleScale());});this._cutConnects=this._cutConnects.concat(_4.map(_9,_4.hitch(this,function(_b){return _4.connect(_b,"onEditsComplete",_4.hitch(this,function(_c,_d,_e){if(this._settings.undoRedoManager){var _f=this._settings.undoRedoManager;_4.forEach(this._edits,_4.hitch(this,function(_10){_f.add(new esri.dijit.editing.Cut({featureLayer:_10.layer,addedGraphics:_10.adds,preUpdatedGraphics:_10.preUpdates,postUpdatedGraphics:_10.updates}));}),this);}this.onFinished();}));})));var _11=new esri.tasks.Query();_11.geometry=_7;_4.forEach(_9,function(_12,idx){this._settings.editor._selectionHelper.selectFeatures([_12],_11,esri.layers.FeatureLayer.SELECTION_NEW,_4.hitch(this,"_cutFeatures",_12,_11));},this);},_cutFeatures:function(_13,_14,_15){if(!_15||!_15.length){return;}this._edits=[];var _16=[];_16.push(this._settings.geometryService.cut(esri.getGeometries(_15),_14.geometry,_4.hitch(this,"_cutHandler",_13,_15)));var _17=new _4.DeferredList(_16).addCallback(_4.hitch(this,function(){this.onApplyEdits(this._edits);}));},_cutHandler:function(_18,_19,_1a){var _1b=[];var _1c=[];var _1d=_4.map(_19,"return new esri.Graphic(dojo.clone(item.toJson()))");var _1e;var _1f;_4.forEach(_1a.cutIndexes,function(_20,i){if(_1e!=_20){_1e=_20;_1c.push(_19[_20].setGeometry(_1a.geometries[i]));}else{_1f=new esri.Graphic(_1a.geometries[i],null,_4.mixin({},_19[_20].attributes),null);_1f.attributes[_19[0].getLayer().objectIdField]=null;_1b.push(_1f);}},this);this._edits.push({layer:_18,adds:_1b,updates:_1c,preUpdates:_1d});}});_4.declare("esri.dijit.editing.tools.Reshape",[esri.dijit.editing.tools.ToggleToolBase],{id:"btnFeatureReshape",_enabledIcon:"toolbarIcon reshapeIcon",_disabledIcon:"toolbarIcon reshapeIcon",_drawType:esri.toolbars.Draw.POLYLINE,_enabled:true,_label:"NLS_reshapeLbl",activate:function(){_4.disconnect(this._rConnect);this._rConnect=_4.connect(this._toolbar,"onDrawEnd",this,"_onDrawEnd");this.inherited(arguments);},deactivate:function(){this.inherited(arguments);_4.disconnect(this._rConnect);delete this._rConnect;},_onDrawEnd:function(_21){var _22=this._settings.layers;var _23=new esri.tasks.Query();_23.geometry=_21;var _24=this._reshapeLayers=_4.filter(_22,function(_25){return (_25.geometryType==="esriGeometryPolygon"||"esriGeometryPolyline");});this._settings.editor._selectionHelper.selectFeatures(_24,_23,esri.layers.FeatureLayer.SELECTION_NEW,_4.hitch(this,"_reshape",_23));},_reshape:function(_26,_27){var _28=[];var _29=_27;if(_29.length!==1){return;}this._settings.geometryService.reshape(_29[0].geometry,_26.geometry,_4.hitch(this,function(_2a){var _2b=[_29[0].setGeometry(_2a)];this.onApplyEdits([{layer:_29[0].getLayer(),updates:_2b}],_4.hitch(this,function(){this._settings.editor._selectionHelper.clearSelection(false);this.onFinished();}));}));}});_4.declare("esri.dijit.editing.tools.Union",[esri.dijit.editing.tools.ButtonToolBase],{id:"btnFeatureUnion",_enabledIcon:"toolbarIcon unionIcon",_disabledIcon:"toolbarIcon unionIcon",_drawType:esri.toolbars.Draw.POLYLINE,_enabled:true,_label:"NLS_unionLbl",_onClick:function(evt){this._settings.editor._activeTool="UNION";var _2c=this._settings.layers;var _2d=_4.filter(_2c,"return (item.geometryType === 'esriGeometryPolygon') && (item.visible && item._isMapAtVisibleScale());");var _2e=[];var _2f=0;_4.forEach(_2d,function(_30,idx){var _31=_30.getSelectedFeatures();if(_31.length>=2){_2f++;var _32=_4.map(_31,"return new esri.Graphic(dojo.clone(item.toJson()))");this._settings.geometryService.union(esri.getGeometries(_31),_4.hitch(this,function(_33){var _34=[_31.pop().setGeometry(_33)];_2e.push({layer:_30,updates:_34,deletes:_31,preUpdates:_32});_2f--;if(_2f<=0){this.onApplyEdits(_2e,_4.hitch(this,function(){if(this._settings.undoRedoManager){var _35=this._settings.undoRedoManager;_4.forEach(this._edits,_4.hitch(this,function(_36){_35.add(new esri.dijit.editing.Union({featureLayer:_36.layer,addedGraphics:_36.deletes,preUpdatedGraphics:_36.preUpdates,postUpdatedGraphics:_36.updates}));}),this);}this._settings.editor._selectionHelper.clearSelection(false);this.onFinished();}));}}));}},this);}});}}};});