/*
 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
 */
//>>built
define("esri/layers/FeatureLayer",["dojo/_base/declare","dojo/_base/connect","dojo/_base/lang","dojo/_base/array","dojo/_base/json","dojo/_base/Deferred","dojo/date/locale","dojo/sniff","dojo/io-query","dojo/dom-construct","dojo/i18n","esri/kernel","esri/lang","esri/request","esri/deferredUtils","esri/SpatialReference","esri/symbols/SimpleMarkerSymbol","esri/symbols/SimpleLineSymbol","esri/symbols/SimpleFillSymbol","esri/symbols/jsonUtils","esri/renderers/SimpleRenderer","esri/renderers/UniqueValueRenderer","esri/renderers/jsonUtils","esri/tasks/QueryTask","esri/tasks/query","esri/tasks/FeatureSet","esri/geometry/Extent","esri/geometry/jsonUtils","esri/geometry/normalizeUtils","esri/layers/GraphicsLayer","esri/layers/Field","esri/layers/TimeInfo","esri/layers/FeatureType","esri/layers/FeatureTemplate","esri/layers/FeatureEditResult","esri/layers/SnapshotMode","esri/layers/OnDemandMode","esri/layers/SelectionMode","esri/layers/TrackManager","dojo/i18n!esri/nls/jsapi","dojo/has!extend-esri?esri/layers/agscommon"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_1a,_1b,_1c,_1d,_1e,_1f,_20,_21,_22,_23,_24,_25,_26,_27){var _28=_1(_1e,{declaredClass:"esri.layers.FeatureLayer",invalidParams:"query contains one or more unsupported parameters",_eventMap:{"add-attachment-complete":["result"],"before-apply-edits":["adds","updates","deletes"],"delete-attachments-complete":["results"],"edits-complete":["adds","updates","deletes"],"query-attachment-infos-complete":["results"],"query-count-complete":["count"],"query-features-complete":["featureSet"],"query-ids-complete":["objectIds"],"query-related-features-complete":["featureSets"],"selection-complete":["features","method"],"update-end":["error","info"]},constructor:function(url,_29){this.i18n=_b.getLocalization("esri","jsapi");this._outFields=_29&&_29.outFields;this._loadCallback=_29&&_29.loadCallback;var _2a=_29&&_29._usePatch;this._usePatch=(_2a===null||_2a===undefined)?true:_2a;this._trackIdField=_29&&_29.trackIdField;this.objectIdField=_29&&_29.objectIdField;this._maxOffset=_29&&_29.maxAllowableOffset;this._optEditable=_29&&_29.editable;this._optAutoGen=_29&&_29.autoGeneralize;this.editSummaryCallback=_29&&_29.editSummaryCallback;this.userId=_29&&_29.userId;this.userIsAdmin=_29&&_29.userIsAdmin;this.useMapTime=(_29&&_29.hasOwnProperty("useMapTime"))?(!!_29.useMapTime):true;this.source=_29&&_29.source;this.gdbVersion=_29&&_29.gdbVersion;this._selectedFeatures={};this._selectedFeaturesArr=[];this._newFeatures=[];this._deletedFeatures={};this._ulid=this._getUniqueId();var _2b=this.constructor,_2c=this.mode=(_d.isDefined(_29&&_29.mode)?_29.mode:_2b.MODE_ONDEMAND);switch(_2c){case _2b.MODE_SNAPSHOT:this._mode=new _24(this);this._isSnapshot=true;break;case _2b.MODE_ONDEMAND:this._tileWidth=(_29&&_29.tileWidth)||512;this._tileHeight=(_29&&_29.tileHeight)||512;this._mode=new _25(this);var _2d=_29&&_29.latticeTiling;this.latticeTiling=_2d;break;case _2b.MODE_SELECTION:this._mode=new _26(this);this._isSelOnly=true;break;}this._initLayer=_3.hitch(this,this._initLayer);this._selectHandler=_3.hitch(this,this._selectHandler);this._editable=false;if(_3.isObject(url)&&url.layerDefinition){var _2e=url;this._collection=true;this.mode=_2b.MODE_SNAPSHOT;this._initLayer(_2e);return this;}this._task=new _18(this.url,{source:this.source,gdbVersion:this.gdbVersion});var _2f=this._url.path;this._fserver=false;if(_2f.search(/\/FeatureServer\//i)!==-1){this._fserver=true;}var _30=_29&&_29.resourceInfo;if(_30){this._initLayer(_30);}else{if(this.source){var _31={source:this.source.toJson()};this._url.query=_3.mixin(this._url.query,{layer:_5.toJson(_31)});}if(this.gdbVersion){this._url.query=_3.mixin(this._url.query,{gdbVersion:this.gdbVersion});}_e({url:_2f,content:_3.mixin({f:"json"},this._url.query),callbackParamName:"callback",load:this._initLayer,error:this._errorHandler});}this.registerConnectEvents();},_initLayer:function(_32,io){if(_32||io){this._json=_32;this._findCredential();var ssl=(this.credential&&this.credential.ssl)||(_32&&_32._ssl);if(ssl){this._useSSL();this._task._useSSL();}if(this._collection){this._mode=new _24(this);this._isSnapshot=true;this._featureSet=_32.featureSet;this._nextId=_32.nextObjectId;_32=_32.layerDefinition;}if(_32.hasOwnProperty("capabilities")){var _33=(this.capabilities=_32.capabilities);if(_33&&_33.toLowerCase().indexOf("editing")!==-1){this._editable=true;}else{this._editable=false;}}else{if(!this._collection){this._editable=this._fserver;}}if(_d.isDefined(this._optEditable)){this._editable=this._optEditable;delete this._optEditable;}this._json=_5.toJson(this._json);if(this.isEditable()){delete this._maxOffset;}else{if(this.mode!==this.constructor.MODE_SNAPSHOT&&((_32.geometryType==="esriGeometryPolyline")||(_32.geometryType==="esriGeometryPolygon"))){this._autoGeneralize=_d.isDefined(this._optAutoGen)?this._optAutoGen:(this.mode===this.constructor.MODE_ONDEMAND);delete this._optAutoGen;}}var _34=_32.effectiveMinScale||_32.minScale,_35=_32.effectiveMaxScale||_32.maxScale;if(!this._hasMin&&_34){this.setMinScale(_34);}if(!this._hasMax&&_35){this.setMaxScale(_35);}this.layerId=_32.id;this.name=_32.name;this.description=_32.description;this.copyright=_32.copyrightText;this.type=_32.type;this.geometryType=_32.geometryType;this.displayField=_32.displayField;this.defaultDefinitionExpression=_32.definitionExpression;this.fullExtent=new _1b(_32.extent);this.initialExtent=new _1b(this.fullExtent.toJson());if(this.fullExtent.spatialReference){this.spatialReference=new _10(this.fullExtent.spatialReference.toJson());}this.defaultVisibility=_32.defaultVisibility;if((this.geometryType==="esriGeometryPoint")||(this.geometryType==="esriGeometryMultipoint")){this.latticeTiling=false;}this.indexedFields=_32.indexedFields;this.maxRecordCount=_32.maxRecordCount;this.canModifyLayer=_32.canModifyLayer;this.supportsStatistics=_32.supportsStatistics;this.supportsAdvancedQueries=_32.supportsAdvancedQueries;this.hasLabels=_32.hasLabels;this.canScaleSymbols=_32.canScaleSymbols;this.supportsRollbackOnFailure=_32.supportsRollbackOnFailure;this.syncCanReturnChanges=_32.syncCanReturnChanges;this.isDataVersioned=_32.isDataVersioned;this.editFieldsInfo=_32.editFieldsInfo;this.ownershipBasedAccessControlForFeatures=_32.ownershipBasedAccessControlForFeatures;if(this.editFieldsInfo&&this.ownershipBasedAccessControlForFeatures){this.creatorField=this.editFieldsInfo.creatorField;}this.relationships=_32.relationships;this.allowGeometryUpdates=_d.isDefined(_32.allowGeometryUpdates)?_32.allowGeometryUpdates:true;this._isTable=(this.type==="Table");var _36=(this.fields=[]),_37=_32.fields,i;for(i=0;i<_37.length;i++){_36.push(new _1f(_37[i]));}if(!this.objectIdField){this.objectIdField=_32.objectIdField;if(!this.objectIdField){_37=_32.fields;for(i=0;i<_37.length;i++){var _38=_37[i];if(_38.type==="esriFieldTypeOID"){this.objectIdField=_38.name;break;}}}if(!this.objectIdField){console.debug("esri.layers.FeatureLayer: "+_d.substitute({url:this.url},"objectIdField is not set [url: ${url}]"));}}if(!_d.isDefined(this._nextId)){var _39=this.objectIdField,_3a=-1;if(this._collection&&_39){var _3b=this._featureSet,_3c=_3b&&_3b.features,il=_3c?_3c.length:0,oid,_3d;for(i=0;i<il;i++){_3d=_3c[i].attributes;oid=_3d&&_3d[_39];if(oid>_3a){_3a=oid;}}}this._nextId=(_3a+1);}this.globalIdField=_32.globalIdField;var _3e=(this.typeIdField=_32.typeIdField),_3f;if(_3e){_3f=!this._getField(_3e)&&this._getField(_3e,true);if(_3f){this.typeIdField=_3f.name;}}this.visibilityField=_32.visibilityField;var _40=_32.defaultSymbol;if(_40){this.defaultSymbol=_14.fromJson(_40);}var _41=this.types=[],_42=_32.types,_43,_44,_45,_46=this.editFieldsInfo,_47=_46&&_46.creatorField,_48=_46&&_46.editorField,fix=(_47||_48),_49=[];if(_42){for(i=0;i<_42.length;i++){_43=new _21(_42[i]);_44=_43.templates;if(fix&&_44&&_44.length){_49=_49.concat(_44);}_41.push(_43);}}var _4a=_32.templates,_4b,_4c=this.templates=[];if(_4a){for(i=0;i<_4a.length;i++){_4b=new _22(_4a[i]);if(fix){_49.push(_4b);}_4c.push(_4b);}}for(i=0;i<_49.length;i++){_45=_3.getObject("prototype.attributes",false,_49[i]);if(_45){if(_47){delete _45[_47];}if(_48){delete _45[_48];}}}var _4d=_32.timeInfo;if(_4d){this.timeInfo=new _20(_4d);this._startTimeField=_4d.startTimeField;this._endTimeField=_4d.endTimeField;if(this._startTimeField&&this._endTimeField){this._twoTimeFields=true;}if(this._trackIdField){_4d.trackIdField=this._trackIdField;}else{this._trackIdField=_4d.trackIdField;}}this.hasAttachments=(!this._collection&&_32.hasAttachments)?true:false;this.htmlPopupType=_32.htmlPopupType;var _4e=_32.drawingInfo,_4f;if(!this.renderer){if(_4e&&_4e.renderer){_4f=_4e.renderer;this.setRenderer(_17.fromJson(_4f));if(_4f.type==="classBreaks"){this.renderer.setMaxInclusive(true);}if(!this._collection){var _50=_4f.type,_51=[];_4f=this.renderer;switch(_50){case "simple":_51.push(_4f.symbol);break;case "uniqueValue":case "classBreaks":_51.push(_4f.defaultSymbol);_51=_51.concat(_4.map(_4f.infos,function(_52){return _52.symbol;}));break;}_51=_4.filter(_51,_d.isDefined);var _53=this._url.path+"/images/",_54=this._getToken();_4.forEach(_51,function(sym){var url=sym.url;if(url){if((url.search(/https?\:/)===-1)&&(url.indexOf("data:")===-1)){sym.url=_53+url;}if(_54&&sym.url.search(/https?\:/)!==-1){sym.url+=("?token="+_54);}}});}}else{if(_40){_42=this.types;if(_42.length>0){_4f=new _16(this.defaultSymbol,this.typeIdField);_4.forEach(_42,function(_55){_4f.addValue(_55.id,_55.symbol);});}else{_4f=new _15(this.defaultSymbol);}this.setRenderer(_4f);}else{if(!this._isTable){var _56;switch(this.geometryType){case "esriGeometryPoint":case "esriGeometryMultipoint":_56=new _11();break;case "esriGeometryPolyline":_56=new _12();break;case "esriGeometryPolygon":_56=new _13();break;}this.setRenderer(_56?new _15(_56):null);}}}}var _57=(_4e&&_4e.transparency)||0;if(!_d.isDefined(this.opacity)&&_57>0){this.opacity=1-(_57/100);}this.version=_32.currentVersion;if(!this.version){var ver;if("capabilities" in _32||"drawingInfo" in _32||"hasAttachments" in _32||"htmlPopupType" in _32||"relationships" in _32||"timeInfo" in _32||"typeIdField" in _32||"types" in _32){ver=10;}else{ver=9.3;}this.version=ver;}if((_8("ie")||_8("safari"))&&this.isEditable()&&this.version<10.02){this._ts=true;}this.loaded=true;this._fixRendererFields();this._checkFields();this._updateCaps();var _58=function(){this.onLoad(this);var _59=this._loadCallback;if(_59){delete this._loadCallback;_59(this);}};if(this._collection){this._fireUpdateStart();var _5a=this._featureSet;delete this._featureSet;this._mode._drawFeatures(new _1a(_5a));this._fcAdded=true;_58.call(this);}else{this._forceIdentity(_58);}}},setRenderer:function(ren){this.inherited("setRenderer",arguments);var _5b=this.renderer;if(_5b){this._ager=(_5b.declaredClass.indexOf("TemporalRenderer")!==-1&&_5b.observationAger&&_5b.observationRenderer);var _5c=_4.filter([_5b,_5b.observationRenderer,_5b.latestObservationRenderer,_5b.trackRenderer],_d.isDefined);var _5d=[];_4.forEach(_5c,function(rnd){if(!_3.isFunction(rnd.attributeField)){_5d.push(rnd.attributeField);}_5d.push(rnd.attributeField2);_5d.push(rnd.attributeField3);},this);this._rendererFields=_4.filter(_5d,_d.isDefined);}else{this._ager=false;this._rendererFields=[];}if(this.loaded&&this._rendererFields.length>0){this._fixRendererFields();this._checkFields(this._rendererFields);}if(this.loaded&&this._collection){this._typesDirty=true;}},_setMap:function(map){var div=this.inherited(arguments),_5e=this._mode;if(_5e){_5e.initialize(map);}return div;},_unsetMap:function(map){var _5f=this._mode;if(_5f){_5f.suspend();}if(this._trackManager){this._trackManager.destroy();this._trackManager=null;}_2.disconnect(this._zoomConnect);this._zoomConnect=null;this._toggleTime(false);this.inherited("_unsetMap",arguments);},refresh:function(){var _60=this._mode;if(_60){_60.refresh();}},getOutFields:function(){return _4.filter(this._getOutFields(),function(_61){return (_61==="*"||!!this._getField(_61));},this);},setEditable:function(_62){if(!this._collection){console.log("FeatureLayer:setEditable - this functionality is not yet supported for layer in a feature service");return this;}if(!this.loaded){this._optEditable=_62;return this;}var _63=this._editable;this._editable=_62;this._updateCaps();if(_63!==_62){this.onCapabilitiesChange();}return this;},getEditCapabilities:function(_64){var _65={"canCreate":false,"canUpdate":false,"canDelete":false};if(!this.loaded||!this.isEditable()){return _65;}var _66=_64&&_64.feature,_67=_64&&_64.userId,_68=_4.map((this.capabilities?this.capabilities.toLowerCase().split(","):[]),_3.trim),_69=_4.indexOf(_68,"editing")>-1,_6a=_69&&(_4.indexOf(_68,"create")>-1),_6b=_69&&(_4.indexOf(_68,"update")>-1),_6c=_69&&(_4.indexOf(_68,"delete")>-1),_6d=this.ownershipBasedAccessControlForFeatures,_6e=this.editFieldsInfo,_6f=_6e&&_6e.creatorField,_70=_6e&&_6e.realm,_71=_66&&_66.attributes,_72=(_71&&_6f)?_71[_6f]:undefined,_73,_74=!!this.userIsAdmin,_75=!_6d||_74||!!(_6d.allowOthersToUpdate||_6d.allowUpdateToOthers),_76=!_6d||_74||!!(_6d.allowOthersToDelete||_6d.allowDeleteToOthers);if(_74||(_69&&!(_6a||_6b||_6c))){_6a=_6b=_6c=true;}_73={"canCreate":_6a,"canUpdate":_6b,"canDelete":_6c};if(_72===null){_73.canUpdate=_6b&&_75;_73.canDelete=_6c&&_76;}else{if(_72===""){return _73;}else{if(_72){_67=_67||this.getUserId();if(_67&&_70){_67=_67+"@"+_70;}if(_67.toLowerCase()===_72.toLowerCase()){return _73;}else{_73.canUpdate=_6b&&_75;_73.canDelete=_6c&&_76;}}}}return _73;},getUserId:function(){var _77;if(this.loaded){_77=(this.credential&&this.credential.userId)||this.userId||"";}return _77;},setUserIsAdmin:function(_78){this.userIsAdmin=_78;},setEditSummaryCallback:function(_79){this.editSummaryCallback=_79;},getEditSummary:function(_7a,_7b,_7c){_7c=_d.isDefined(_7c)?_7c:(new Date()).getTime();var _7d="",_7e=this.getEditInfo(_7a,_7b,_7c),_7f=(_7b&&_7b.callback)||this.editSummaryCallback;if(_7f){_7e=_7f(_7a,_7e)||"";}if(_3.isString(_7e)){_7d=_7e;}else{if(_7e){var _80=_7e.action,_81=_7e.userId,_82=_7e.timeValue,_83=0;if(_80){_83++;}if(_81){_83++;}if(_d.isDefined(_82)){_83++;}if(_83>1){_7d=(_80==="edit"?"edit":"create")+(_81?"User":"")+(_d.isDefined(_82)?_7e.displayPattern:"");}}_7d=_7d&&_d.substitute(_7e,this.i18n.layers.FeatureLayer[_7d]);}return _7d;},getEditInfo:function(_84,_85,_86){if(!this.loaded){return;}_86=_d.isDefined(_86)?_86:(new Date()).getTime();var _87=(_85&&_85.action)||"last",_88=this.editFieldsInfo,_89=_88&&_88.creatorField,_8a=_88&&_88.creationDateField,_8b=_88&&_88.editorField,_8c=_88&&_88.editDateField,_8d=_88&&_88.realm,_8e=_84&&_84.attributes,_8f=(_8e&&_89)?_8e[_89]:undefined,_90=(_8e&&_8a)?_8e[_8a]:null,_91=(_8e&&_8b)?_8e[_8b]:undefined,_92=(_8e&&_8c)?_8e[_8c]:null,_93=this._getEditData(_8f,_90,_86),_94=this._getEditData(_91,_92,_86),_95;switch(_87){case "creation":_95=_93;break;case "edit":_95=_94;break;case "last":_95=_94||_93;break;}if(_95){_95.action=(_95===_94)?"edit":"creation";}return _95;},_getEditData:function(_96,_97,_98){var _99,_9a,_9b,_9c=60000,_9d=3600000,_9e=2*_9d,_9f=24*_9d,_a0=7*_9f;if(_d.isDefined(_97)){_9a=_98-_97;if(_9a<0){_9b="Full";}else{if(_9a<_9c){_9b="Seconds";}else{if(_9a<(2*_9c)){_9b="Minute";}else{if(_9a<_9d){_9b="Minutes";}else{if(_9a<_9e){_9b="Hour";}else{if(_9a<_9f){_9b="Hours";}else{if(_9a<_a0){_9b="WeekDay";}else{_9b="Full";}}}}}}}}if((_96!==undefined)||_9b){_99=_99||{};_99.userId=_96;if(_9b){var _a1=_7.format,_a2=new Date(_97);_99.minutes=Math.floor(_9a/_9c);_99.hours=Math.floor(_9a/_9d);_99.weekDay=_a1(_a2,{datePattern:"EEEE",selector:"date"});_99.formattedDate=_a1(_a2,{selector:"date"});_99.formattedTime=_a1(_a2,{selector:"time"});_99.displayPattern=_9b;_99.timeValue=_97;}}return _99;},isEditable:function(){return !!(this._editable||this.userIsAdmin);},setMaxAllowableOffset:function(_a3){if(!this.isEditable()){this._maxOffset=_a3;}return this;},getMaxAllowableOffset:function(){return this._maxOffset;},setAutoGeneralize:function(_a4){if(!this.loaded){this._optAutoGen=_a4;}else{if(!this.isEditable()&&(this.mode!==this.constructor.MODE_SNAPSHOT)&&((this.geometryType==="esriGeometryPolyline")||(this.geometryType==="esriGeometryPolygon"))){this._autoGeneralize=_a4;if(_a4){var map=this._map;if(map&&map.loaded){this._maxOffset=Math.floor(map.extent.getWidth()/map.width);}}else{delete this._maxOffset;}}}return this;},setGDBVersion:function(_a5){if(!this._collection&&(_a5!==this.gdbVersion)&&(_a5||this.gdbVersion)){this.gdbVersion=_a5;this._task.gdbVersion=_a5;this._url.query=_3.mixin(this._url.query,{gdbVersion:_a5});if(this.loaded){this.clearSelection();if(this._map){this.refresh();}}this.onGDBVersionChange();}return this;},setDefinitionExpression:function(_a6){this._defnExpr=_a6;var _a7=this._mode;if(_a7){_a7.propertyChangeHandler(1);}return this;},getDefinitionExpression:function(){return this._defnExpr;},setTimeDefinition:function(_a8){if(this._isSnapshot){this._timeDefn=_a8;var _a9=this._mode;if(_a9){_a9.propertyChangeHandler(2);}}else{console.log("FeatureLayer.setTimeDefinition: layer in on-demand or selection mode does not support time definitions. Layer id = "+this.id+", Layer URL = "+this.url);}return this;},getTimeDefinition:function(){return this._timeDefn;},setTimeOffset:function(_aa,_ab){this._timeOffset=_aa;this._timeOffsetUnits=_ab;var _ac=this._mode;if(_ac){_ac.propertyChangeHandler(0);}return this;},setUseMapTime:function(use){this.useMapTime=use;this._toggleTime(!this.suspended);var _ad=this._mode;if(_ad){_ad.propertyChangeHandler(0);}},selectFeatures:function(_ae,_af,_b0,_b1){_af=_af||this.constructor.SELECTION_NEW;var _b2=this._getShallowClone(_ae),map=this._map,_b3,dfd=_f._fixDfd(new _6(_f._dfdCanceller));_b2.outFields=this.getOutFields();_b2.returnGeometry=true;if(map){_b2.outSpatialReference=new _10(map.spatialReference.toJson());}if(!this._applyQueryFilters(_b2)){_b3={features:[]};this._selectHandler(_b3,_af,_b0,_b1,dfd);return dfd;}var _b4=this._canDoClientSideQuery(_b2);if(_b4){_b3={features:this._doQuery(_b2,_b4)};this._selectHandler(_b3,_af,_b0,_b1,dfd);return dfd;}else{if(this._collection){var err=new Error("FeatureLayer::selectFeatures - "+this.invalidParams);this._resolve([err],null,_b1,dfd,true);return dfd;}var _b5=this;if(this._ts){_b2._ts=(new Date()).getTime();}var _b6=dfd._pendingDfd=this._task.execute(_b2);_b6.addCallbacks(function(_b7){_b5._selectHandler(_b7,_af,_b0,_b1,dfd);},function(err){_b5._resolve([err],null,_b1,dfd,true);});return dfd;}},getSelectedFeatures:function(){var _b8=this._selectedFeatures,_b9=[],_ba;for(_ba in _b8){if(_b8.hasOwnProperty(_ba)){_b9.push(_b8[_ba]);}}return _b9;},clearSelection:function(_bb){var _bc=this._selectedFeatures,_bd=this._mode,_be;for(_be in _bc){if(_bc.hasOwnProperty(_be)){this._unSelectFeatureIIf(_be,_bd);_bd._removeFeatureIIf(_be);}}this._selectedFeatures={};if(this._isSelOnly){_bd._applyTimeFilter(true);}if(!_bb){this.onSelectionClear();}return this;},setSelectionSymbol:function(_bf){this._selectionSymbol=_bf;if(_bf){var _c0=this._selectedFeatures,_c1;for(_c1 in _c0){if(_c0.hasOwnProperty(_c1)){_c0[_c1].setSymbol(_bf);}}}return this;},getSelectionSymbol:function(){return this._selectionSymbol;},__msigns:[{n:"applyEdits",c:5,a:[{i:0},{i:1}],e:4,f:1}],applyEdits:function(_c2,_c3,_c4,_c5,_c6,_c7){var _c8=_c7.assembly,dfd=_c7.dfd;this._applyNormalized(_c2,_c8&&_c8[0]);this._applyNormalized(_c3,_c8&&_c8[1]);this.onBeforeApplyEdits(_c2,_c3,_c4);var i,_c9={},_ca=this.objectIdField,_cb={f:"json"},_cc=false;if(this._collection){var _cd={};_cd.addResults=_c2?_4.map(_c2,function(){_cc=true;return {objectId:this._nextId++,success:true};},this):null;_cd.updateResults=_c3?_4.map(_c3,function(_ce){_cc=true;var oid=_ce.attributes[_ca];_c9[oid]=_ce;return {objectId:oid,success:true};},this):null;_cd.deleteResults=_c4?_4.map(_c4,function(_cf){_cc=true;return {objectId:_cf.attributes[_ca],success:true};},this):null;if(_cc){this._editHandler(_cd,_c2,_c9,_c5,_c6,dfd);}return;}if(_c2&&_c2.length>0){_cb.adds=this._convertFeaturesToJson(_c2,0,1);_cc=true;}if(_c3&&_c3.length>0){for(i=0;i<_c3.length;i++){var _d0=_c3[i];_c9[_d0.attributes[_ca]]=_d0;}_cb.updates=this._convertFeaturesToJson(_c3,0,0,1);_cc=true;}if(_c4&&_c4.length>0){var ids=[];for(i=0;i<_c4.length;i++){ids.push(_c4[i].attributes[_ca]);}_cb.deletes=ids.join(",");_cc=true;}if(_cc){var _d1=this;return _e({url:this._url.path+"/applyEdits",content:_3.mixin(_cb,this._url.query),callbackParamName:"callback",load:function(_d2){_d1._editHandler(_d2,_c2,_c9,_c5,_c6,dfd);},error:function(err){_d1._resolve([err],null,_c6,dfd,true);}},{usePost:true});}},queryFeatures:function(_d3,_d4,_d5){return this._query("execute","onQueryFeaturesComplete",_d3,_d4,_d5);},queryRelatedFeatures:function(_d6,_d7,_d8){return this._query("executeRelationshipQuery","onQueryRelatedFeaturesComplete",_d6,_d7,_d8);},queryIds:function(_d9,_da,_db){return this._query("executeForIds","onQueryIdsComplete",_d9,_da,_db);},queryCount:function(_dc,_dd,_de){return this._query("executeForCount","onQueryCountComplete",_dc,_dd,_de);},queryAttachmentInfos:function(_df,_e0,_e1){var url=this._url.path+"/"+_df+"/attachments",dfd=new _6(_f._dfdCanceller),_e2=this;dfd._pendingDfd=_e({url:url,content:_3.mixin({f:"json"},this._url.query),callbackParamName:"callback",load:function(_e3){var _e4=_e3.attachmentInfos,_e5;_4.forEach(_e4,function(_e6){_e5=_9.objectToQuery({gdbVersion:_e2._url.query&&_e2._url.query.gdbVersion,layer:_e2._url.query&&_e2._url.query.layer,token:_e2._getToken()});_e6.url=url+"/"+_e6.id+(_e5?("?"+_e5):"");_e6.objectId=_df;});_e2._resolve([_e4],"onQueryAttachmentInfosComplete",_e0,dfd);},error:function(err){_e2._resolve([err],null,_e1,dfd,true);}});return dfd;},addAttachment:function(_e7,_e8,_e9,_ea){return this._sendAttachment("add",_e7,_e8,_e9,_ea);},updateAttachment:function(_eb,_ec,_ed,_ee,_ef){_ed.appendChild(_a.create("input",{type:"hidden",name:"attachmentId",value:_ec}));return this._sendAttachment("update",_eb,_ed,_ee,_ef);},deleteAttachments:function(_f0,_f1,_f2,_f3){var url=this._url.path+"/"+_f0+"/deleteAttachments",dfd=new _6(_f._dfdCanceller),_f4=this,_f5={f:"json",attachmentIds:_f1.join(",")};dfd._pendingDfd=_e({url:url,content:_3.mixin(_f5,this._url.query),callbackParamName:"callback",load:_3.hitch(this,function(_f6){var _f7=_f6.deleteAttachmentResults;_f7=_4.map(_f7,function(_f8){var res=new _23(_f8);res.attachmentId=res.objectId;res.objectId=_f0;return res;});_f4._resolve([_f7],"onDeleteAttachmentsComplete",_f2,dfd);}),error:function(err){_f4._resolve([err],null,_f3,dfd,true);}},{usePost:true});return dfd;},addType:function(_f9){var _fa=this.types;if(_fa){var _fb=_4.some(_fa,function(_fc){if(_fc.id==_f9.id){return true;}return false;});if(_fb){return false;}else{_fa.push(_f9);}}else{this.types=[_f9];}this._typesDirty=true;return true;},deleteType:function(_fd){if(!this._collection){return;}var _fe=this.types;if(_fe){var _ff=-1;_4.some(_fe,function(type,_100){if(type.id==_fd){_ff=_100;return true;}return false;});if(_ff>-1){this._typesDirty=true;return _fe.splice(_ff,1)[0];}}},toJson:function(){var _101=this._json,json=_3.isString(_101)?_5.fromJson(_101):_3.clone(_101);if(!json){return;}json=json.layerDefinition?json:{layerDefinition:json};var _102=json.layerDefinition,_103=this._collection;if(_103&&this._typesDirty){_102.types=_4.map(this.types||[],function(type){return type.toJson();});var _104=this.renderer,_105=_102.drawingInfo;if(_105&&_104&&_104.declaredClass.indexOf("TemporalRenderer")===-1){_105.renderer=_104.toJson();}}var _106=null;if(!(_103&&!this._fcAdded)){_106={geometryType:_102.geometryType,features:this._convertFeaturesToJson(this.graphics,true)};}json.featureSet=_3.mixin({},json.featureSet||{},_106);if(_103){json.nextObjectId=this._nextId;_102.capabilities=this.capabilities;}return json;},onSelectionComplete:function(){},onSelectionClear:function(){},onBeforeApplyEdits:function(){},onEditsComplete:function(){},onQueryFeaturesComplete:function(){},onQueryRelatedFeaturesComplete:function(){},onQueryIdsComplete:function(){},onQueryCountComplete:function(){},onQueryAttachmentInfosComplete:function(){},onAddAttachmentComplete:function(){},onUpdateAttachmentComplete:function(){},onDeleteAttachmentsComplete:function(){},onCapabilitiesChange:function(){},onGDBVersionChange:function(){},onQueryLimitExceeded:function(){},_forceIdentity:function(_107){var self=this,path=this._url&&this._url.path;if((this.ownershipBasedAccessControlForFeatures||this.userIsAdmin)&&!this._getToken()&&path&&_c.id&&_c.id._hasPortalSession()&&_c.id._doPortalSignIn(path)){_c.id.getCredential(path).then(function(){self._findCredential();_107.call(self);},function(){_107.call(self);});}else{_107.call(this);}},_updateCaps:function(){var _108=this._editable,_109=_3.trim(this.capabilities||""),_10a=_4.map((_109?_109.split(","):[]),_3.trim),caps=_4.map((_109?_109.toLowerCase().split(","):[]),_3.trim),_10b=_4.indexOf(caps,"editing"),cap,i,_10c,_10d={"Create":_4.indexOf(caps,"create"),"Update":_4.indexOf(caps,"update"),"Delete":_4.indexOf(caps,"delete")};if(_108&&_10b===-1){_10a.push("Editing");}else{if(!_108&&_10b>-1){_10c=[_10b];for(cap in _10d){if(_10d[cap]>-1){_10c.push(_10d[cap]);}}_10c.sort();for(i=_10c.length-1;i>=0;i--){_10a.splice(_10c[i],1);}}}this.capabilities=_10a.join(",");},_counter:{value:0},_getUniqueId:function(){return this._counter.value++;},onSuspend:function(){this.inherited(arguments);this._toggleTime(false);var mode=this._mode;if(mode){mode.suspend();}},onResume:function(evt){this.inherited(arguments);this._toggleTime(true);this._updateMaxOffset();var mode=this._mode,map=this._map,_10e=this.renderer;if(evt.firstOccurrence){this.clearSelection();if(this.timeInfo){if(this._trackIdField||(_10e&&(_10e.latestObservationRenderer||_10e.trackRenderer))){this._trackManager=new _27(this);this._trackManager.initialize(map);}}this._zoomConnect=_2.connect(map,"onZoomEnd",this,this._updateMaxOffset);}if(mode){evt.firstOccurrence?mode.startup():mode.resume();}},_updateMaxOffset:function(){var map=this._map;if(map&&map.loaded){if(this._autoGeneralize){this._maxOffset=Math.floor(map.extent.getWidth()/map.width);}}},_toggleTime:function(_10f){var map=this._map;if(_10f&&this.timeInfo&&this.useMapTime&&map){this._mapTimeExtent=map.timeExtent;if(!this._timeConnect){this._timeConnect=_2.connect(map,"onTimeExtentChange",this,this._timeChangeHandler);}}else{this._mapTimeExtent=null;_2.disconnect(this._timeConnect);this._timeConnect=null;}},_timeChangeHandler:function(_110){this._mapTimeExtent=_110;var mode=this._mode;if(mode){mode.propertyChangeHandler(0);}},_getOffsettedTE:function(_111){var _112=this._timeOffset,_113=this._timeOffsetUnits;return (_111&&_112&&_113)?_111.offset(-1*_112,_113):_111;},_getTimeOverlap:function(_114,_115){if(_114&&_115){return _114.intersection(_115);}else{return _114||_115;}},_getTimeFilter:function(_116){var _117=this.getTimeDefinition(),_118=null,_119;if(_117||_118){_119=this._getTimeOverlap(_117,_118);if(!_119){return [false];}}if(_116){_116=_119?this._getTimeOverlap(_116,_119):_116;if(!_116){return [false];}}else{_116=_119;}return [true,_116];},_getAttributeFilter:function(_11a){var _11b=this.getDefinitionExpression();if(_11a){_11a=_11b?"("+_11b+") AND ("+_11a+")":_11a;}else{_11a=_11b;}return _11a;},_applyQueryFilters:function(_11c){_11c.where=this._getAttributeFilter(_11c.where);_11c.maxAllowableOffset=this._maxOffset;if(this.timeInfo){var _11d=this._getTimeFilter(_11c.timeExtent);if(!_11d[0]){return false;}else{_11c.timeExtent=_11d[1];}}return true;},_add:function(_11e){var _11f=this._selectionSymbol,attr=_11e.attributes,_120=this.visibilityField;if(_11f&&this._isSelOnly){_11e.setSymbol(_11f);}if(_120&&attr&&attr.hasOwnProperty(_120)){_11e[attr[_120]?"show":"hide"]();}return this.add.apply(this,arguments);},_remove:function(){return this.remove.apply(this,arguments);},_canDoClientSideQuery:function(_121){var _122=[],map=this._map;if(this._isTable||!map){return;}if(_121.text||(_121.where&&_121.where!==this.getDefinitionExpression())){return;}var _123=this._isSnapshot,_124=this._isSelOnly;var _125=_121.geometry;if(_125){if(!_124&&_121.spatialRelationship===_19.SPATIAL_REL_INTERSECTS&&(_125.type==="extent"&&(_123||map.extent.contains(_125)))){_122.push(1);}else{return;}}var ids=_121.objectIds;if(ids){if(_123){_122.push(2);}else{var len=ids.length,mode=this._mode,_126=0,i;for(i=0;i<len;i++){if(mode._getFeature(ids[i])){_126++;}}if(_126===len){_122.push(2);}else{return;}}}if(this.timeInfo){var _127=_121.timeExtent,_128=this._mapTimeExtent;if(_123){if(_127){_122.push(3);}}else{if(_124){if(_127){return;}}else{if(_128){if(_4.indexOf(_122,2)!==-1){if(_127){_122.push(3);}}else{return;}}else{if(_122.length>0){if(_127){_122.push(3);}}else{if(_127){return;}}}}}}return _122.length>0?_122:null;},_doQuery:function(_129,_12a,_12b){var _12c=[],mode=this._mode,_12d=this.objectIdField,i,len,_12e;if(_4.indexOf(_12a,2)!==-1){_12c=[];var ids=_129.objectIds;len=ids.length;for(i=0;i<len;i++){var obj=mode._getFeature(ids[i]);if(obj){_12c.push(obj);}}if(_12c.length===0){return [];}}if(_4.indexOf(_12a,1)!==-1){_12e=_12c.length>0?_12c:this.graphics;len=_12e.length;var _12f=_129.geometry._normalize(null,true);_12c=[];for(i=0;i<len;i++){var _130=_12e[i],_131=_130.geometry;if(_131){if(this.normalization&&_12f.length){if(_12f[0].intersects(_131)||_12f[1].intersects(_131)){_12c.push(_130);}}else{if(_12f.intersects(_131)){_12c.push(_130);}}}}if(_12c.length===0){return [];}}if(_4.indexOf(_12a,3)!==-1){if(this.timeInfo){_12e=_12c.length>0?_12c:this.graphics;var time=_129.timeExtent,_132=this._filterByTime(_12e,time.startTime,time.endTime);_12c=_132.match;}}if(_12b){return _4.map(_12c,function(obj){return obj.attributes[_12d];},this);}else{return _12c;}},_filterByTime:function(_133,_134,_135){var _136=this._startTimeField,_137=this._endTimeField,_138;if(!this._twoTimeFields){_138=_136||_137;}var _139=_d.isDefined,yea=[],nay=[],i,len=_133.length,_13a,_13b;_134=_134?_134.getTime():-Infinity;_135=_135?_135.getTime():Infinity;if(_138){for(i=0;i<len;i++){_13a=_133[i];_13b=_13a.attributes;var time=_13b[_138];if(time>=_134&&time<=_135){yea.push(_13a);}else{nay.push(_13a);}}}else{for(i=0;i<len;i++){_13a=_133[i];_13b=_13a.attributes;var _13c=_13b[_136],end=_13b[_137];_13c=_139(_13c)?_13c:-Infinity;end=_139(end)?end:Infinity;if((_13c>=_134&&_13c<=_135)||(end>=_134&&end<=_135)||(_134>=_13c&&_135<=end)){yea.push(_13a);}else{nay.push(_13a);}}}return {match:yea,noMatch:nay};},_resolve:function(args,_13d,_13e,dfd,_13f){if(_13d){this[_13d].apply(this,args);}if(_13e){_13e.apply(null,args);}if(dfd){_f._resDfd(dfd,args,_13f);}},_getShallowClone:function(_140){var _141=new _19(),prop;for(prop in _140){if(_140.hasOwnProperty(prop)){_141[prop]=_140[prop];}}return _141;},_query:function(type,_142,_143,_144,_145){var that=this,map=this._map,dfd=new _6(_f._dfdCanceller),_146=_143;var _147=function(_148,_149){if(!_149&&type==="execute"&&!that._isTable){var _14a=_148.features,mode=that._mode,_14b=that.objectIdField,il=_14a.length,i;for(i=il-1;i>=0;i--){var oid=_14a[i].attributes[_14b];var _14c=mode._getFeature(oid);if(_14c){_14a.splice(i,1,_14c);}}}that._resolve([_148],_142,_144,dfd);};if(type!=="executeRelationshipQuery"){_146=this._getShallowClone(_143);_146.outFields=this.getOutFields();_146.returnGeometry=_143.hasOwnProperty("returnGeometry")?_143.returnGeometry:true;var _14d;if(map){_146.outSpatialReference=new _10(map.spatialReference.toJson());}if(!this._applyQueryFilters(_146)){switch(type){case "execute":_14d=new _1a({features:[]});break;case "executeForIds":_14d=[];break;case "executeForCount":_14d=0;break;}_147(_14d,true);return dfd;}var _14e=this._canDoClientSideQuery(_146);if(_14e){var _14f=this._doQuery(_146,_14e,(type==="executeForIds"||type==="executeForCount"));switch(type){case "execute":_14d=new _1a();_14d.features=_14f;break;case "executeForIds":_14d=_14f;break;case "executeForCount":_14d=_14f.length;break;}_147(_14d,true);return dfd;}}if(this._collection){var err=new Error("FeatureLayer::_query - "+this.invalidParams);this._resolve([err],null,_145,dfd,true);return dfd;}if(this._ts){_146._ts=(new Date()).getTime();}var temp=dfd._pendingDfd=this._task[type](_146);temp.addCallbacks(_147,function(err){that._resolve([err],null,_145,dfd,true);});return dfd;},_convertFeaturesToJson:function(_150,_151,_152,_153){var json=[],_154=this._selectionSymbol,_155=this.visibilityField,i,_156,_157=this.objectIdField;if(this.loaded&&(_152||_153)){_156=_4.filter(this.fields,function(_158){return (_158.editable===false)&&(!_153||(_158.name!==_157));});}for(i=0;i<_150.length;i++){var _159=_150[i],_15a={},_15b=_159.geometry,attr=_159.attributes,_15c=_159.symbol;if(_15b&&(!_153||!this.loaded||this.allowGeometryUpdates)){_15a.geometry=_15b.toJson();}if(_155){_15a.attributes=attr=_3.mixin({},attr);attr[_155]=_159.visible?1:0;}else{if(attr){_15a.attributes=_3.mixin({},attr);}}if(_15a.attributes&&_156&&_156.length){_4.forEach(_156,function(_15d){delete _15a.attributes[_15d.name];});}if(_15c&&(_15c!==_154)){_15a.symbol=_15c.toJson();}json.push(_15a);}return _151?json:_5.toJson(json);},_selectHandler:function(_15e,_15f,_160,_161,dfd){var _162,ctor=this.constructor;switch(_15f){case ctor.SELECTION_NEW:this.clearSelection(true);_162=true;break;case ctor.SELECTION_ADD:_162=true;break;case ctor.SELECTION_SUBTRACT:_162=false;break;}var i,_163=_15e.features,mode=this._mode,_164=[],_165=this.objectIdField,_166,oid;if(_162){for(i=0;i<_163.length;i++){_166=_163[i];oid=_166.attributes[_165];var _167=mode._addFeatureIIf(oid,_166);_164.push(_167);this._selectFeatureIIf(oid,_167,mode);}}else{for(i=0;i<_163.length;i++){_166=_163[i];oid=_166.attributes[_165];this._unSelectFeatureIIf(oid,mode);var _168=mode._removeFeatureIIf(oid);_164.push(_168||_166);}}if(this._isSelOnly){mode._applyTimeFilter(true);}this._resolve([_164,_15f,_15e.exceededTransferLimit?{queryLimitExceeded:true}:null],"onSelectionComplete",_160,dfd);if(_15e.exceededTransferLimit){this.onQueryLimitExceeded();}},_selectFeatureIIf:function(oid,_169,mode){var _16a=this._selectedFeatures,_16b=_16a[oid];if(!_16b){mode._incRefCount(oid);_16a[oid]=_169;if(!this._isTable){this._setSelectSymbol(_169);}}return _16b||_169;},_unSelectFeatureIIf:function(oid,mode){var _16c=this._selectedFeatures[oid];if(_16c){mode._decRefCount(oid);delete this._selectedFeatures[oid];if(!this._isTable){this._setUnSelectSymbol(_16c);}}return _16c;},_isSelected:function(_16d){},_setSelectSymbol:function(_16e){var _16f=this._selectionSymbol;if(_16f&&!this._isSelOnly){_16e.setSymbol(_16f);}},_setUnSelectSymbol:function(_170){var _171=this._selectionSymbol;if(_171&&!this._isSelOnly){if(_171===_170.symbol){_170.setSymbol(null,true);}}},_getOutFields:function(){var _172=_4.filter([this.objectIdField,this.typeIdField,this.creatorField,this._startTimeField,this._endTimeField,this._trackIdField].concat(this._rendererFields),function(_173,_174,arr){return !!_173&&(_4.indexOf(arr,_173)===_174);});var _175=_3.clone(this._outFields);if(_175){if(_4.indexOf(_175,"*")!==-1){return _175;}_4.forEach(_172,function(_176){if(_4.indexOf(_175,_176)===-1){_175.push(_176);}});return _175;}else{return _172;}},_checkFields:function(_177){var _178=_177||this._getOutFields();_4.forEach(_178,function(_179){if(_179==="*"){return;}if(!this._getField(_179)){console.debug("esri.layers.FeatureLayer: "+_d.substitute({url:this.url,field:_179},"unable to find '${field}' field in the layer 'fields' information [url: ${url}]"));}},this);if(!_177&&!this._isTable&&!this._fserver&&!this._collection){var _17a=_4.some(this.fields,function(_17b){return (_17b&&_17b.type==="esriFieldTypeGeometry")?true:false;});if(!_17a){console.debug("esri.layers.FeatureLayer: "+_d.substitute({url:this.url},"unable to find a field of type 'esriFieldTypeGeometry' in the layer 'fields' information. If you are using a map service layer, features will not have geometry [url: ${url}]"));}}},_fixRendererFields:function(){var _17c=this.renderer;if(_17c&&this.fields.length>0){var _17d=_4.filter([_17c,_17c.observationRenderer,_17c.latestObservationRenderer,_17c.trackRenderer],_d.isDefined);var _17e=[];_4.forEach(_17d,function(rnd){var _17f,_180;_180=rnd.attributeField;if(_180&&!_3.isFunction(_180)){_17f=!this._getField(_180)&&this._getField(_180,true);if(_17f){rnd.attributeField=_17f.name;}}_180=rnd.attributeField2;if(_180){_17f=!this._getField(_180)&&this._getField(_180,true);if(_17f){rnd.attributeField2=_17f.name;}}_180=rnd.attributeField3;if(_180){_17f=!this._getField(_180)&&this._getField(_180,true);if(_17f){rnd.attributeField3=_17f.name;}}if(!_3.isFunction(rnd.attributeField)){_17e.push(rnd.attributeField);}_17e.push(rnd.attributeField2);_17e.push(rnd.attributeField3);},this);this._rendererFields=_4.filter(_17e,_d.isDefined);}},_getField:function(_181,_182){var _183=this.fields;if(!_183||_183.length===0){return null;}var _184;if(_182){_181=_181.toLowerCase();}_4.some(_183,function(_185){var _186=false;if(_182){_186=(_185&&_185.name.toLowerCase()===_181)?true:false;}else{_186=(_185&&_185.name===_181)?true:false;}if(_186){_184=_185;}return _186;});return _184;},_getDateOpts:function(){if(!this._dtOpts){var _187=_4.map(_4.filter(this.fields,function(_188){return !!(_188&&_188.type==="esriFieldTypeDate");}),function(_189){return _189.name;});this._dtOpts={properties:_187};}return this._dtOpts;},_applyNormalized:function(_18a,_18b){if(_18a&&_18b){_4.forEach(_18a,function(_18c,_18d){if(_18c&&_18b[_18d]){_18c.setGeometry(_18b[_18d]);}});}},_editHandler:function(_18e,adds,_18f,_190,_191,dfd){var _192=_18e.addResults,_193=_18e.updateResults,_194=_18e.deleteResults,i,_195,oid,_196,attr,_197=this.objectIdField,mode=this._mode,_198=this._isTable;var _199=this.editFieldsInfo,_19a=this.getOutFields()||[],_19b=_199&&_199.creatorField,_19c=_199&&_199.creationDateField,_19d=_199&&_199.editorField,_19e=_199&&_199.editDateField,_19f=_199&&_199.realm;if(_4.indexOf(_19a,"*")===-1){if(_19b&&_4.indexOf(_19a,_19b)===-1){_19b=null;}if(_19c&&_4.indexOf(_19a,_19c)===-1){_19c=null;}if(_19d&&_4.indexOf(_19a,_19d)===-1){_19d=null;}if(_19e&&_4.indexOf(_19a,_19e)===-1){_19e=null;}}var _1a0=(_19c||_19e)?(new Date()).getTime():null,_1a1=(_19b||_19d)?this.getUserId():undefined;if(_1a1&&_19f){_1a1=_1a1+"@"+_19f;}if(_192){for(i=0;i<_192.length;i++){_192[i]=new _23(_192[i]);if(_198){continue;}_195=_192[i];if(_195.success){oid=_195.objectId;_196=adds[i];var gl=_196._graphicsLayer;if(gl&&gl!==this){gl.remove(_196);}attr=_196.attributes||{};attr[_197]=oid;if(_19b){attr[_19b]=_1a1;}if(_19d){attr[_19d]=_1a1;}if(_19c){attr[_19c]=_1a0;}if(_19e){attr[_19e]=_1a0;}_196.setAttributes(attr);if(mode._init){mode.drawFeature(_196);}}}}if(_193){for(i=0;i<_193.length;i++){_193[i]=new _23(_193[i]);if(_198){continue;}_195=_193[i];if(_195.success){oid=_195.objectId;_196=_18f[oid];var _1a2=mode._getFeature(oid);if(_1a2){if(_1a2.geometry!==_196.geometry){_1a2.setGeometry(_1c.fromJson(_196.geometry.toJson()));}this._repaint(_1a2,oid);}_196=_1a2||_196;attr=_196.attributes||{};if(_19d){attr[_19d]=_1a1;}if(_19e){attr[_19e]=_1a0;}_196.setAttributes(attr);}}}if(_194){var _1a3=[];for(i=0;i<_194.length;i++){_194[i]=new _23(_194[i]);if(_198){continue;}_195=_194[i];if(_195.success){oid=_195.objectId;_196=mode._getFeature(oid);if(_196){if(this._unSelectFeatureIIf(oid,mode)){_1a3.push(_196);}_196._count=0;mode._removeFeatureIIf(oid);}}}if(_1a3.length>0){this.onSelectionComplete(_1a3,this.constructor.SELECTION_SUBTRACT);}}this._resolve([_192,_193,_194],"onEditsComplete",_190,dfd);},_sendAttachment:function(type,_1a4,_1a5,_1a6,_1a7){var _1a8=(type==="add")?"addAttachment":"updateAttachment",url=this._url.path+"/"+_1a4+"/"+_1a8,self=this;var dfd=_e({url:url,form:_1a5,content:_3.mixin(this._url.query,{f:"json",token:this._getToken()||undefined}),callbackParamName:"callback.html",handleAs:"json"}).addCallback(function(_1a9){var _1aa=(type==="add")?"addAttachmentResult":"updateAttachmentResult",_1ab=(type==="add")?"onAddAttachmentComplete":"onUpdateAttachmentComplete",_1ac=new _23(_1a9[_1aa]);_1ac.attachmentId=_1ac.objectId;_1ac.objectId=_1a4;self._resolve([_1ac],_1ab,_1a6);return _1ac;}).addErrback(function(_1ad){self._resolve([_1ad],null,_1a7,null,true);});return dfd;},_repaint:function(_1ae,oid,_1af){oid=_d.isDefined(oid)?oid:_1ae.attributes[this.objectIdField];if(!(oid in this._selectedFeatures)||!this._selectionSymbol){_1ae.setSymbol(_1ae.symbol,_1af);}},_getKind:function(_1b0){var _1b1=this._trackManager;if(_1b1){return _1b1.isLatestObservation(_1b0)?1:0;}return 0;}});_3.mixin(_28,{MODE_SNAPSHOT:0,MODE_ONDEMAND:1,MODE_SELECTION:2,SELECTION_NEW:3,SELECTION_ADD:4,SELECTION_SUBTRACT:5,POPUP_NONE:"esriServerHTMLPopupTypeNone",POPUP_HTML_TEXT:"esriServerHTMLPopupTypeAsHTMLText",POPUP_URL:"esriServerHTMLPopupTypeAsURL"});_1d._createWrappers(_28);if(_8("extend-esri")){_3.setObject("layers.FeatureLayer",_28,_c);}return _28;});