/*
 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:[["provide","esri.layers.FeatureLayer"],["require","esri.layers.graphics"],["require","esri.tasks.query"],["require","dojo.io.iframe"],["require","esri.layers.agscommon"],["require","dojo.date.locale"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.layers.FeatureLayer"]){_4._hasResource["esri.layers.FeatureLayer"]=true;_4.provide("esri.layers.FeatureLayer");_4.require("esri.layers.graphics");_4.require("esri.tasks.query");_4.require("dojo.io.iframe");_4.require("esri.layers.agscommon");_4.require("dojo.date.locale");_4.declare("esri.layers.FeatureLayer",esri.layers.GraphicsLayer,{constructor:function(_7,_8){this._outFields=_8&&_8.outFields;this._loadCallback=_8&&_8.loadCallback;var _9=_8&&_8._usePatch;this._usePatch=(_9===null||_9===undefined)?true:_9;this._trackIdField=_8&&_8.trackIdField;this.objectIdField=_8&&_8.objectIdField;this._maxOffset=_8&&_8.maxAllowableOffset;this._optEditable=_8&&_8.editable;this._optAutoGen=_8&&_8.autoGeneralize;this.editSummaryCallback=_8&&_8.editSummaryCallback;this.userId=_8&&_8.userId;this.userIsAdmin=_8&&_8.userIsAdmin;this.useMapTime=(_8&&_8.hasOwnProperty("useMapTime"))?(!!_8.useMapTime):true;this.source=_8&&_8.source;this.gdbVersion=_8&&_8.gdbVersion;this._selectedFeatures={};this._selectedFeaturesArr=[];this._newFeatures=[];this._deletedFeatures={};this._ulid=this._getUniqueId();var _a=this.constructor,_b=this.mode=(esri._isDefined(_8&&_8.mode)?_8.mode:_a.MODE_ONDEMAND);switch(_b){case _a.MODE_SNAPSHOT:this._mode=new esri.layers._SnapshotMode(this);this._isSnapshot=true;break;case _a.MODE_ONDEMAND:this._tileWidth=(_8&&_8.tileWidth)||512;this._tileHeight=(_8&&_8.tileHeight)||512;this._mode=new esri.layers._OnDemandMode(this);var _c=_8&&_8.latticeTiling;this.latticeTiling=_c;break;case _a.MODE_SELECTION:this._mode=new esri.layers._SelectionMode(this);this._isSelOnly=true;break;}this._initLayer=_4.hitch(this,this._initLayer);this._selectHandler=_4.hitch(this,this._selectHandler);this._editable=false;if(_4.isObject(_7)&&_7.layerDefinition){var _d=_7;this._collection=true;this.mode=_a.MODE_SNAPSHOT;this._initLayer(_d);return this;}this._task=new esri.tasks.QueryTask(this.url,{source:this.source,gdbVersion:this.gdbVersion});var _e=this._url.path;this._fserver=false;if(_e.search(/\/FeatureServer\//i)!==-1){this._fserver=true;}var _f=_8&&_8.resourceInfo;if(_f){this._initLayer(_f);}else{if(this.source){var _10={source:this.source.toJson()};this._url.query=_4.mixin(this._url.query,{layer:_4.toJson(_10)});}if(this.gdbVersion){this._url.query=_4.mixin(this._url.query,{gdbVersion:this.gdbVersion});}esri.request({url:_e,content:_4.mixin({f:"json"},this._url.query),callbackParamName:"callback",load:this._initLayer,error:this._errorHandler});}},_initLayer:function(_11,io){if(_11||io){this._json=_11;this._findCredential();if(this._collection){this._mode=new esri.layers._SnapshotMode(this);this._isSnapshot=true;this._featureSet=_11.featureSet;this._nextId=_11.nextObjectId;_11=_11.layerDefinition;}if(_11.hasOwnProperty("capabilities")){var _12=(this.capabilities=_11.capabilities);if(_12&&_12.toLowerCase().indexOf("editing")!==-1){this._editable=true;}else{this._editable=false;}}else{if(!this._collection){this._editable=this._fserver;}}if(esri._isDefined(this._optEditable)){this._editable=this._optEditable;delete this._optEditable;}this._json=_4.toJson(this._json);if(this._editable){delete this._maxOffset;}else{if(this.mode!==this.constructor.MODE_SNAPSHOT&&((_11.geometryType==="esriGeometryPolyline")||(_11.geometryType==="esriGeometryPolygon"))){this._autoGeneralize=esri._isDefined(this._optAutoGen)?this._optAutoGen:(this.mode===this.constructor.MODE_ONDEMAND);delete this._optAutoGen;}}this.minScale=_11.minScale||0;this.maxScale=_11.maxScale||0;this.layerId=_11.id;this.name=_11.name;this.description=_11.description;this.copyright=_11.copyrightText;this.type=_11.type;this.geometryType=_11.geometryType;this.displayField=_11.displayField;this.defaultDefinitionExpression=_11.definitionExpression;this.fullExtent=new esri.geometry.Extent(_11.extent);if((this.geometryType==="esriGeometryPoint")||(this.geometryType==="esriGeometryMultipoint")){this.latticeTiling=false;}this.indexedFields=_11.indexedFields;this.maxRecordCount=_11.maxRecordCount;this.canModifyLayer=_11.canModifyLayer;this.supportsStatistics=_11.supportsStatistics;this.supportsAdvancedQueries=_11.supportsAdvancedQueries;this.hasLabels=_11.hasLabels;this.canScaleSymbols=_11.canScaleSymbols;this.supportsRollbackOnFailure=_11.supportsRollbackOnFailure;this.syncCanReturnChanges=_11.syncCanReturnChanges;this.isDataVersioned=_11.isDataVersioned;this.editFieldsInfo=_11.editFieldsInfo;this.ownershipBasedAccessControlForFeatures=_11.ownershipBasedAccessControlForFeatures;if(this.editFieldsInfo&&this.ownershipBasedAccessControlForFeatures){this.creatorField=this.editFieldsInfo.creatorField;}this.relationships=_11.relationships;this.allowGeometryUpdates=esri._isDefined(_11.allowGeometryUpdates)?_11.allowGeometryUpdates:true;this._isTable=(this.type==="Table");var _13=(this.fields=[]),_14=_11.fields,i;for(i=0;i<_14.length;i++){_13.push(new esri.layers.Field(_14[i]));}if(!this.objectIdField){this.objectIdField=_11.objectIdField;if(!this.objectIdField){_14=_11.fields;for(i=0;i<_14.length;i++){var _15=_14[i];if(_15.type==="esriFieldTypeOID"){this.objectIdField=_15.name;break;}}}if(!this.objectIdField){console.debug("esri.layers.FeatureLayer: "+esri.substitute({url:this.url},esri.bundle.layers.FeatureLayer.noOIDField));}}if(!esri._isDefined(this._nextId)){var _16=this.objectIdField,_17=-1;if(this._collection&&_16){var _18=this._featureSet,_19=_18&&_18.features,il=_19?_19.length:0,oid,_1a;for(i=0;i<il;i++){_1a=_19[i].attributes;oid=_1a&&_1a[_16];if(oid>_17){_17=oid;}}}this._nextId=(_17+1);}this.globalIdField=_11.globalIdField;this.typeIdField=_11.typeIdField;this.visibilityField=_11.visibilityField;var _1b=_11.defaultSymbol;if(_1b){this.defaultSymbol=esri.symbol.fromJson(_1b);}var _1c=this.types=[],_1d=_11.types,_1e,_1f,_20,_21=this.editFieldsInfo,_22=_21&&_21.creatorField,_23=_21&&_21.editorField,fix=(_22||_23),_24=[];if(_1d){for(i=0;i<_1d.length;i++){_1e=new esri.layers.FeatureType(_1d[i]);_1f=_1e.templates;if(fix&&_1f&&_1f.length){_24=_24.concat(_1f);}_1c.push(_1e);}}var _25=_11.templates,_26,_27=this.templates=[];if(_25){for(i=0;i<_25.length;i++){_26=new esri.layers.FeatureTemplate(_25[i]);if(fix){_24.push(_26);}_27.push(_26);}}for(i=0;i<_24.length;i++){_20=_4.getObject("prototype.attributes",false,_24[i]);if(_20){if(_22){delete _20[_22];}if(_23){delete _20[_23];}}}var _28=_11.timeInfo;if(_28){this.timeInfo=new esri.layers.TimeInfo(_28);this._startTimeField=_28.startTimeField;this._endTimeField=_28.endTimeField;if(this._startTimeField&&this._endTimeField){this._twoTimeFields=true;}if(this._trackIdField){_28.trackIdField=this._trackIdField;}else{this._trackIdField=_28.trackIdField;}}this.hasAttachments=(!this._collection&&_11.hasAttachments)?true:false;this.htmlPopupType=_11.htmlPopupType;var _29=_11.drawingInfo,_2a;if(!this.renderer){if(_29&&_29.renderer){_2a=_29.renderer;this.setRenderer(esri.renderer.fromJson(_2a));if(_2a.type==="classBreaks"){this.renderer._setMaxInclusiveness(true);}if(!this._collection){var _2b=_2a.type,_2c=[];_2a=this.renderer;switch(_2b){case "simple":_2c.push(_2a.symbol);break;case "uniqueValue":case "classBreaks":_2c.push(_2a.defaultSymbol);_2c=_2c.concat(_4.map(_2a.infos,function(_2d){return _2d.symbol;}));break;}_2c=_4.filter(_2c,esri._isDefined);var _2e=this._url.path+"/images/",_2f=this._getToken();_4.forEach(_2c,function(sym){var url=sym.url;if(url){if((url.search(/https?\:/)===-1)&&(url.indexOf("data:")===-1)){sym.url=_2e+url;}if(_2f&&sym.url.search(/https?\:/)!==-1){sym.url+=("?token="+_2f);}}});}}else{if(_1b){_1d=this.types;if(_1d.length>0){_2a=new esri.renderer.UniqueValueRenderer(this.defaultSymbol,this.typeIdField);_4.forEach(_1d,function(_30){_2a.addValue(_30.id,_30.symbol);});}else{_2a=new esri.renderer.SimpleRenderer(this.defaultSymbol);}this.setRenderer(_2a);}else{if(!this._isTable){var _31;switch(this.geometryType){case "esriGeometryPoint":case "esriGeometryMultipoint":_31=new esri.symbol.SimpleMarkerSymbol();break;case "esriGeometryPolyline":_31=new esri.symbol.SimpleLineSymbol();break;case "esriGeometryPolygon":_31=new esri.symbol.SimpleFillSymbol();break;}this.setRenderer(_31?new esri.renderer.SimpleRenderer(_31):null);}}}}var _32=(_29&&_29.transparency)||0;if(!esri._isDefined(this.opacity)&&_32>0){this.opacity=1-(_32/100);}this.version=_11.currentVersion;if(!this.version){var ver;if("capabilities" in _11||"drawingInfo" in _11||"hasAttachments" in _11||"htmlPopupType" in _11||"relationships" in _11||"timeInfo" in _11||"typeIdField" in _11||"types" in _11){ver=10;}else{ver=9.3;}this.version=ver;}if((_4.isIE||_4.isSafari)&&this._editable&&this.version<10.02){this._ts=true;}this.loaded=true;this._fixRendererFields();this._checkFields();this._updateCaps();if(this._collection){this._fireUpdateStart();var _33=this._featureSet;delete this._featureSet;this._mode._drawFeatures(new esri.tasks.FeatureSet(_33));this._fcAdded=true;}this.onLoad(this);var _34=this._loadCallback;if(_34){delete this._loadCallback;_34(this);}}},setRenderer:function(ren){this.inherited("setRenderer",arguments);var _35=this.renderer;if(_35){this._ager=(_35.declaredClass.indexOf("TemporalRenderer")!==-1&&_35.observationAger&&_35.observationRenderer);var _36=_4.filter([_35,_35.observationRenderer,_35.latestObservationRenderer,_35.trackRenderer],esri._isDefined);var _37=[];_4.forEach(_36,function(rnd){_37.push(rnd.attributeField);_37.push(rnd.attributeField2);_37.push(rnd.attributeField3);},this);this._rendererFields=_4.filter(_37,esri._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,_38){this._map=map;this._toggleTime(true);var div=this.inherited("_setMap",arguments);this.clearSelection();var _39=this.renderer;if(this.timeInfo){if(this._trackIdField||(_39&&(_39.latestObservationRenderer||_39.trackRenderer))){this._trackManager=new esri.layers._TrackManager(this);this._trackManager.initialize(map);}}this._zoomConnect=_4.connect(map,"onZoomEnd",this,this._zoomHandler);this._zoomHandler();var _3a=this._mode;if(_3a){_3a.initialize(map);}return div;},_unsetMap:function(map,_3b){var _3c=this._mode;if(_3c){_3c.destroy();this._mode=null;}if(this._trackManager){this._trackManager.destroy();this._trackManager=null;}_4.disconnect(this._zoomConnect);this._zoomConnect=null;this._toggleTime(false);this.inherited("_unsetMap",arguments);},refresh:function(){var _3d=this._mode;if(_3d){_3d.refresh();}},setEditable:function(_3e){if(!this._collection){console.log("FeatureLayer:setEditCapabilities - this functionality is not yet supported for layer in a feature service");return this;}if(!this.loaded){this._optEditable=_3e;return this;}var _3f=this._editable;this._editable=_3e;this._updateCaps();if(_3f!==_3e){this.onCapabilitiesChange();}return this;},getEditCapabilities:function(_40){var _41={"canCreate":false,"canUpdate":false,"canDelete":false};if(!this.loaded||!this._editable){return _41;}var _42=_40&&_40.feature,_43=_40&&_40.userId,_44=_4.map((this.capabilities?this.capabilities.toLowerCase().split(","):[]),_4.trim),_45=_4.indexOf(_44,"editing")>-1,_46=_45&&(_4.indexOf(_44,"create")>-1),_47=_45&&(_4.indexOf(_44,"update")>-1),_48=_45&&(_4.indexOf(_44,"delete")>-1),_49=this.ownershipBasedAccessControlForFeatures,_4a=this.editFieldsInfo,_4b=_4a&&_4a.creatorField,_4c=_4a&&_4a.realm,_4d=_42&&_42.attributes,_4e=(_4d&&_4b)?_4d[_4b]:undefined,_4f,_50=!!this.userIsAdmin,_51=!_49||_50||!!(_49.allowOthersToUpdate||_49.allowUpdateToOthers),_52=!_49||_50||!!(_49.allowOthersToDelete||_49.allowDeleteToOthers);if(_45&&(!(_46||_47||_48)||_50)){_46=_47=_48=true;}_4f={"canCreate":_46,"canUpdate":_47,"canDelete":_48};if(_4e===null){_4f.canUpdate=_47&&_51;_4f.canDelete=_48&&_52;}else{if(_4e===""){return _4f;}else{if(_4e){_43=_43||this.getUserId();if(_43&&_4c){_43=_43+"@"+_4c;}if(_43.toLowerCase()===_4e.toLowerCase()){return _4f;}else{_4f.canUpdate=_47&&_51;_4f.canDelete=_48&&_52;}}}}return _4f;},getUserId:function(){var _53;if(this.loaded){_53=(this.credential&&this.credential.userId)||this.userId||"";}return _53;},setUserIsAdmin:function(_54){this.userIsAdmin=_54;},setEditSummaryCallback:function(_55){this.editSummaryCallback=_55;},getEditSummary:function(_56,_57,_58){_58=esri._isDefined(_58)?_58:(new Date()).getTime();var _59="",_5a=this.getEditInfo(_56,_57,_58),_5b=(_57&&_57.callback)||this.editSummaryCallback;if(_5b){_5a=_5b(_56,_5a)||"";}if(_4.isString(_5a)){_59=_5a;}else{if(_5a){var _5c=_5a.action,_5d=_5a.userId,_5e=_5a.timeValue,_5f=0;if(_5c){_5f++;}if(_5d){_5f++;}if(esri._isDefined(_5e)){_5f++;}if(_5f>1){_59=(_5c==="edit"?"edit":"create")+(_5d?"User":"")+(esri._isDefined(_5e)?_5a.displayPattern:"");}}_59=_59&&esri.substitute(_5a,esri.bundle.layers.FeatureLayer[_59]);}return _59;},getEditInfo:function(_60,_61,_62){if(!this.loaded){return;}_62=esri._isDefined(_62)?_62:(new Date()).getTime();var _63=(_61&&_61.action)||"last",_64=this.editFieldsInfo,_65=_64&&_64.creatorField,_66=_64&&_64.creationDateField,_67=_64&&_64.editorField,_68=_64&&_64.editDateField,_69=_64&&_64.realm,_6a=_60&&_60.attributes,_6b=(_6a&&_65)?_6a[_65]:undefined,_6c=(_6a&&_66)?_6a[_66]:null,_6d=(_6a&&_67)?_6a[_67]:undefined,_6e=(_6a&&_68)?_6a[_68]:null,_6f=this._getEditData(_6b,_6c,_62),_70=this._getEditData(_6d,_6e,_62),_71;switch(_63){case "creation":_71=_6f;break;case "edit":_71=_70;break;case "last":_71=_70||_6f;break;}if(_71){_71.action=(_71===_70)?"edit":"creation";}return _71;},_getEditData:function(_72,_73,_74){var _75,_76,_77,_78=60000,_79=3600000,_7a=2*_79,_7b=24*_79,_7c=7*_7b;if(esri._isDefined(_73)){_76=_74-_73;if(_76<0){_77="Full";}else{if(_76<_78){_77="Seconds";}else{if(_76<(2*_78)){_77="Minute";}else{if(_76<_79){_77="Minutes";}else{if(_76<_7a){_77="Hour";}else{if(_76<_7b){_77="Hours";}else{if(_76<_7c){_77="WeekDay";}else{_77="Full";}}}}}}}}if((_72!==undefined)||_77){_75=_75||{};_75.userId=_72;if(_77){var _7d=_4.date.locale.format,_7e=new Date(_73);_75.minutes=Math.floor(_76/_78);_75.hours=Math.floor(_76/_79);_75.weekDay=_7d(_7e,{datePattern:"EEEE",selector:"date"});_75.formattedDate=_7d(_7e,{selector:"date"});_75.formattedTime=_7d(_7e,{selector:"time"});_75.displayPattern=_77;_75.timeValue=_73;}}return _75;},isEditable:function(){return this._editable;},setMaxAllowableOffset:function(_7f){if(!this._editable){this._maxOffset=_7f;}return this;},getMaxAllowableOffset:function(){return this._maxOffset;},setAutoGeneralize:function(_80){if(!this.loaded){this._optAutoGen=_80;}else{if(!this._editable&&(this.mode!==this.constructor.MODE_SNAPSHOT)&&((this.geometryType==="esriGeometryPolyline")||(this.geometryType==="esriGeometryPolygon"))){this._autoGeneralize=_80;if(_80){var map=this._map;if(map&&map.loaded){this._maxOffset=Math.floor(map.extent.getWidth()/map.width);}}else{delete this._maxOffset;}}}return this;},setScaleRange:function(_81,_82){this.minScale=_81||0;this.maxScale=_82||0;if(this._map&&this._map.loaded){this._updateStatus();}},setGDBVersion:function(_83){if(!this._collection&&(_83!==this.gdbVersion)&&(_83||this.gdbVersion)){this.gdbVersion=_83;this._task.gdbVersion=_83;this._url.query=_4.mixin(this._url.query,{gdbVersion:_83});if(this.loaded){this.clearSelection();if(this._map){this.refresh();}}this.onGDBVersionChange();}return this;},setDefinitionExpression:function(_84){this._defnExpr=_84;var _85=this._mode;if(_85){_85.propertyChangeHandler(1);}return this;},getDefinitionExpression:function(){return this._defnExpr;},setTimeDefinition:function(_86){if(this._isSnapshot){this._timeDefn=_86;var _87=this._mode;if(_87){_87.propertyChangeHandler(2);}}return this;},getTimeDefinition:function(){return this._timeDefn;},setTimeOffset:function(_88,_89){this._timeOffset=_88;this._timeOffsetUnits=_89;var _8a=this._mode;if(_8a){_8a.propertyChangeHandler(0);}return this;},setUseMapTime:function(use){this.useMapTime=use;this._toggleTime(!this._suspended);var _8b=this._mode;if(_8b){_8b.propertyChangeHandler(0);}},selectFeatures:function(_8c,_8d,_8e,_8f){_8d=_8d||this.constructor.SELECTION_NEW;var _90=this._getShallowClone(_8c),map=this._map,_91,dfd=esri._fixDfd(new _4.Deferred(esri._dfdCanceller));_90.outFields=this._getOutFields();_90.returnGeometry=true;if(map){_90.outSpatialReference=new esri.SpatialReference(map.spatialReference.toJson());}if(!this._applyQueryFilters(_90)){_91={features:[]};this._selectHandler(_91,_8d,_8e,_8f,dfd);return dfd;}var _92=this._canDoClientSideQuery(_90);if(_92){_91={features:this._doQuery(_90,_92)};this._selectHandler(_91,_8d,_8e,_8f,dfd);return dfd;}else{if(this._collection){var err=new Error("FeatureLayer::selectFeatures - "+esri.bundle.layers.FeatureLayer.invalidParams);this._resolve([err],null,_8f,dfd,true);return dfd;}var _93=this;if(this._ts){_90._ts=(new Date()).getTime();}var _94=dfd._pendingDfd=this._task.execute(_90);_94.addCallbacks(function(_95){_93._selectHandler(_95,_8d,_8e,_8f,dfd);},function(err){_93._resolve([err],null,_8f,dfd,true);});return dfd;}},getSelectedFeatures:function(){var _96=this._selectedFeatures,_97=[],_98;for(_98 in _96){if(_96.hasOwnProperty(_98)){_97.push(_96[_98]);}}return _97;},clearSelection:function(_99){var _9a=this._selectedFeatures,_9b=this._mode,_9c;for(_9c in _9a){if(_9a.hasOwnProperty(_9c)){this._unSelectFeatureIIf(_9c,_9b);_9b._removeFeatureIIf(_9c);}}this._selectedFeatures={};if(this._isSelOnly){_9b._applyTimeFilter(true);}if(!_99){this.onSelectionClear();}return this;},setSelectionSymbol:function(_9d){this._selectionSymbol=_9d;if(_9d){var _9e=this._selectedFeatures,_9f;for(_9f in _9e){if(_9e.hasOwnProperty(_9f)){_9e[_9f].setSymbol(_9d);}}}return this;},getSelectionSymbol:function(){return this._selectionSymbol;},__msigns:[{n:"applyEdits",c:5,a:[{i:0},{i:1}],e:4,f:1}],applyEdits:function(_a0,_a1,_a2,_a3,_a4,_a5){var _a6=_a5.assembly,dfd=_a5.dfd;this._applyNormalized(_a0,_a6&&_a6[0]);this._applyNormalized(_a1,_a6&&_a6[1]);this.onBeforeApplyEdits(_a0,_a1,_a2);var i,_a7={},_a8=this.objectIdField,_a9={f:"json"},_aa=false;if(this._collection){var _ab={};_ab.addResults=_a0?_4.map(_a0,function(){_aa=true;return {objectId:this._nextId++,success:true};},this):null;_ab.updateResults=_a1?_4.map(_a1,function(_ac){_aa=true;var oid=_ac.attributes[_a8];_a7[oid]=_ac;return {objectId:oid,success:true};},this):null;_ab.deleteResults=_a2?_4.map(_a2,function(_ad){_aa=true;return {objectId:_ad.attributes[_a8],success:true};},this):null;if(_aa){this._editHandler(_ab,_a0,_a7,_a3,_a4,dfd);}return;}if(_a0&&_a0.length>0){_a9.adds=this._convertFeaturesToJson(_a0,0,1);_aa=true;}if(_a1&&_a1.length>0){for(i=0;i<_a1.length;i++){var _ae=_a1[i];_a7[_ae.attributes[_a8]]=_ae;}_a9.updates=this._convertFeaturesToJson(_a1,0,0,1);_aa=true;}if(_a2&&_a2.length>0){var ids=[];for(i=0;i<_a2.length;i++){ids.push(_a2[i].attributes[_a8]);}_a9.deletes=ids.join(",");_aa=true;}if(_aa){var _af=this;return esri.request({url:this._url.path+"/applyEdits",content:_4.mixin(_a9,this._url.query),callbackParamName:"callback",load:function(_b0){_af._editHandler(_b0,_a0,_a7,_a3,_a4,dfd);},error:function(err){_af._resolve([err],null,_a4,dfd,true);}},{usePost:true});}},queryFeatures:function(_b1,_b2,_b3){return this._query("execute","onQueryFeaturesComplete",_b1,_b2,_b3);},queryRelatedFeatures:function(_b4,_b5,_b6){return this._query("executeRelationshipQuery","onQueryRelatedFeaturesComplete",_b4,_b5,_b6);},queryIds:function(_b7,_b8,_b9){return this._query("executeForIds","onQueryIdsComplete",_b7,_b8,_b9);},queryCount:function(_ba,_bb,_bc){return this._query("executeForCount","onQueryCountComplete",_ba,_bb,_bc);},queryAttachmentInfos:function(_bd,_be,_bf){var url=this._url.path+"/"+_bd+"/attachments",dfd=new _4.Deferred(esri._dfdCanceller),_c0=this;dfd._pendingDfd=esri.request({url:url,content:_4.mixin({f:"json"},this._url.query),callbackParamName:"callback",load:function(_c1){var _c2=_c1.attachmentInfos,_c3;_4.forEach(_c2,function(_c4){_c3=_4.objectToQuery({gdbVersion:_c0._url.query&&_c0._url.query.gdbVersion,layer:_c0._url.query&&_c0._url.query.layer,token:_c0._getToken()});_c4.url=url+"/"+_c4.id+(_c3?("?"+_c3):"");_c4.objectId=_bd;});_c0._resolve([_c2],"onQueryAttachmentInfosComplete",_be,dfd);},error:function(err){_c0._resolve([err],null,_bf,dfd,true);}});return dfd;},addAttachment:function(_c5,_c6,_c7,_c8){return this._sendAttachment("add",_c5,_c6,_c7,_c8);},updateAttachment:function(_c9,_ca,_cb,_cc,_cd){_cb.appendChild(_4.create("input",{type:"hidden",name:"attachmentId",value:_ca}));return this._sendAttachment("update",_c9,_cb,_cc,_cd);},deleteAttachments:function(_ce,_cf,_d0,_d1){var url=this._url.path+"/"+_ce+"/deleteAttachments",dfd=new _4.Deferred(esri._dfdCanceller),_d2=this,_d3={f:"json",attachmentIds:_cf.join(",")};dfd._pendingDfd=esri.request({url:url,content:_4.mixin(_d3,this._url.query),callbackParamName:"callback",load:_4.hitch(this,function(_d4){var _d5=_d4.deleteAttachmentResults;_d5=_4.map(_d5,function(_d6){var res=new esri.layers.FeatureEditResult(_d6);res.attachmentId=res.objectId;res.objectId=_ce;return res;});_d2._resolve([_d5],"onDeleteAttachmentsComplete",_d0,dfd);}),error:function(err){_d2._resolve([err],null,_d1,dfd,true);}},{usePost:true});return dfd;},addType:function(_d7){if(!this._collection){return false;}var _d8=this.types;if(_d8){var _d9=_4.some(_d8,function(_da){if(_da.id==_d7.id){return true;}return false;});if(_d9){return false;}else{_d8.push(_d7);}}else{this.types=[_d7];}this._typesDirty=true;return true;},deleteType:function(_db){if(!this._collection){return;}var _dc=this.types;if(_dc){var _dd=-1;_4.some(_dc,function(_de,_df){if(_de.id==_db){_dd=_df;return true;}return false;});if(_dd>-1){this._typesDirty=true;return _dc.splice(_dd,1)[0];}}},toJson:function(){var _e0=this._json,_e1=_4.isString(_e0)?_4.fromJson(_e0):_4.clone(_e0);if(!_e1){return;}_e1=_e1.layerDefinition?_e1:{layerDefinition:_e1};var _e2=_e1.layerDefinition,_e3=this._collection;if(_e3&&this._typesDirty){_e2.types=_4.map(this.types||[],function(_e4){return _e4.toJson();});var _e5=this.renderer,_e6=_e2.drawingInfo;if(_e6&&_e5&&_e5.declaredClass.indexOf("TemporalRenderer")===-1){_e6.renderer=_e5.toJson();}}var _e7=null;if(!(_e3&&!this._fcAdded)){_e7={geometryType:_e2.geometryType,features:this._convertFeaturesToJson(this.graphics,true)};}_e1.featureSet=_4.mixin({},_e1.featureSet||{},_e7);if(_e3){_e1.nextObjectId=this._nextId;_e2.capabilities=this.capabilities;}return _e1;},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(){},_updateCaps:function(){var _e8=this._editable,_e9=_4.trim(this.capabilities||""),_ea=_4.map((_e9?_e9.split(","):[]),_4.trim),_eb=_4.map((_e9?_e9.toLowerCase().split(","):[]),_4.trim),_ec=_4.indexOf(_eb,"editing"),cap,i,_ed,_ee={"Create":_4.indexOf(_eb,"create"),"Update":_4.indexOf(_eb,"update"),"Delete":_4.indexOf(_eb,"delete")};if(_e8&&_ec===-1){_ea.push("Editing");}else{if(!_e8&&_ec>-1){_ed=[_ec];for(cap in _ee){if(_ee[cap]>-1){_ed.push(_ee[cap]);}}_ed.sort();for(i=_ed.length-1;i>=0;i--){_ea.splice(_ed[i],1);}}}this.capabilities=_ea.join(",");},_counter:{value:0},_getUniqueId:function(){return this._counter.value++;},_getDesiredStatus:function(){return this.visible&&this._isMapAtVisibleScale();},_isMapAtVisibleScale:function(){if(!this._map){return false;}var _ef=esri.geometry.getScale(this._map);var _f0=this.minScale,_f1=this.maxScale,_f2=!_f0,_f3=!_f1;if(!_f2&&_ef<=_f0){_f2=true;}if(!_f3&&_ef>=_f1){_f3=true;}return (_f2&&_f3)?true:false;},_suspend:function(){this.inherited("_suspend",arguments);this._toggleTime(false);var _f4=this._mode;if(_f4){_f4.suspend();}},_resume:function(){this.inherited("_resume",arguments);this._toggleTime(true);var _f5=this._mode;if(_f5){_f5.resume();}},_zoomHandler:function(){var map=this._map;if(map&&map.loaded){if(this._autoGeneralize){this._maxOffset=Math.floor(map.extent.getWidth()/map.width);}this._updateStatus();}},_toggleTime:function(_f6){var map=this._map;if(_f6&&this.timeInfo&&this.useMapTime&&map){this._mapTimeExtent=map.timeExtent;if(!this._timeConnect){this._timeConnect=_4.connect(map,"onTimeExtentChange",this,this._timeChangeHandler);}}else{this._mapTimeExtent=null;_4.disconnect(this._timeConnect);this._timeConnect=null;}},_timeChangeHandler:function(_f7){this._mapTimeExtent=_f7;var _f8=this._mode;if(_f8){_f8.propertyChangeHandler(0);}},_getOffsettedTE:function(_f9){var _fa=this._timeOffset,_fb=this._timeOffsetUnits;return (_f9&&_fa&&_fb)?_f9.offset(-1*_fa,_fb):_f9;},_getTimeOverlap:function(_fc,_fd){if(_fc&&_fd){return _fc.intersection(_fd);}else{return _fc||_fd;}},_getTimeFilter:function(_fe){var _ff=this.getTimeDefinition(),_100=null,_101;if(_ff||_100){_101=this._getTimeOverlap(_ff,_100);if(!_101){return [false];}}if(_fe){_fe=_101?this._getTimeOverlap(_fe,_101):_fe;if(!_fe){return [false];}}else{_fe=_101;}return [true,_fe];},_getAttributeFilter:function(_102){var _103=this.getDefinitionExpression();if(_102){_102=_103?"("+_103+") AND ("+_102+")":_102;}else{_102=_103;}return _102;},_applyQueryFilters:function(_104){_104.where=this._getAttributeFilter(_104.where);_104.maxAllowableOffset=this._maxOffset;if(this.timeInfo){var _105=this._getTimeFilter(_104.timeExtent);if(!_105[0]){return false;}else{_104.timeExtent=_105[1];}}return true;},_add:function(_106){var _107=this._selectionSymbol,attr=_106.attributes,_108=this.visibilityField;if(_107&&this._isSelOnly){_106.setSymbol(_107);}if(_108&&attr&&attr.hasOwnProperty(_108)){_106[attr[_108]?"show":"hide"]();}return this.add.apply(this,arguments);},_remove:function(){return this.remove.apply(this,arguments);},_canDoClientSideQuery:function(_109){var _10a=[],map=this._map;if(this._isTable||!map){return;}if(_109.text||(_109.where&&_109.where!==this.getDefinitionExpression())){return;}var _10b=this._isSnapshot,_10c=this._isSelOnly;var _10d=_109.geometry;if(_10d){if(!_10c&&_109.spatialRelationship===esri.tasks.Query.SPATIAL_REL_INTERSECTS&&(_10d.type==="extent"&&(_10b||map.extent.contains(_10d)))){_10a.push(1);}else{return;}}var ids=_109.objectIds;if(ids){if(_10b){_10a.push(2);}else{var len=ids.length,mode=this._mode,_10e=0,i;for(i=0;i<len;i++){if(mode._getFeature(ids[i])){_10e++;}}if(_10e===len){_10a.push(2);}else{return;}}}if(this.timeInfo){var _10f=_109.timeExtent,_110=this._mapTimeExtent;if(_10b){if(_10f){_10a.push(3);}}else{if(_10c){if(_10f){return;}}else{if(_110){if(_4.indexOf(_10a,2)!==-1){if(_10f){_10a.push(3);}}else{return;}}else{if(_10a.length>0){if(_10f){_10a.push(3);}}else{if(_10f){return;}}}}}}return _10a.length>0?_10a:null;},_doQuery:function(_111,_112,_113){var _114=[],mode=this._mode,_115=this.objectIdField,i,len,_116;if(_4.indexOf(_112,2)!==-1){_114=[];var ids=_111.objectIds;len=ids.length;for(i=0;i<len;i++){var obj=mode._getFeature(ids[i]);if(obj){_114.push(obj);}}if(_114.length===0){return [];}}if(_4.indexOf(_112,1)!==-1){_116=_114.length>0?_114:this.graphics;len=_116.length;var _117=_111.geometry._normalize(null,true);_114=[];for(i=0;i<len;i++){var _118=_116[i],_119=_118.geometry;if(_119){if(this.normalization&&_117.length){if(_117[0].intersects(_119)||_117[1].intersects(_119)){_114.push(_118);}}else{if(_117.intersects(_119)){_114.push(_118);}}}}if(_114.length===0){return [];}}if(_4.indexOf(_112,3)!==-1){if(this.timeInfo){_116=_114.length>0?_114:this.graphics;var time=_111.timeExtent,_11a=this._filterByTime(_116,time.startTime,time.endTime);_114=_11a.match;}}if(_113){return _4.map(_114,function(obj){return obj.attributes[_115];},this);}else{return _114;}},_filterByTime:function(_11b,_11c,_11d){var _11e=this._startTimeField,_11f=this._endTimeField,_120;if(!this._twoTimeFields){_120=_11e||_11f;}var _121=esri._isDefined,yea=[],nay=[],i,len=_11b.length,_122,_123;_11c=_11c?_11c.getTime():-Infinity;_11d=_11d?_11d.getTime():Infinity;if(_120){for(i=0;i<len;i++){_122=_11b[i];_123=_122.attributes;var time=_123[_120];if(time>=_11c&&time<=_11d){yea.push(_122);}else{nay.push(_122);}}}else{for(i=0;i<len;i++){_122=_11b[i];_123=_122.attributes;var _124=_123[_11e],end=_123[_11f];_124=_121(_124)?_124:-Infinity;end=_121(end)?end:Infinity;if((_124>=_11c&&_124<=_11d)||(end>=_11c&&end<=_11d)||(_11c>=_124&&_11d<=end)){yea.push(_122);}else{nay.push(_122);}}}return {match:yea,noMatch:nay};},_resolve:function(args,_125,_126,dfd,_127){if(_125){this[_125].apply(this,args);}if(_126){_126.apply(null,args);}if(dfd){esri._resDfd(dfd,args,_127);}},_getShallowClone:function(_128){var _129=new esri.tasks.Query(),prop;for(prop in _128){if(_128.hasOwnProperty(prop)){_129[prop]=_128[prop];}}return _129;},_query:function(type,_12a,_12b,_12c,_12d){var that=this,dfd=new _4.Deferred(esri._dfdCanceller);var _12e=function(_12f,_130){if(!_130&&type==="execute"&&!that._isTable){var _131=_12f.features,mode=that._mode,_132=that.objectIdField,il=_131.length,i;for(i=il-1;i>=0;i--){var oid=_131[i].attributes[_132];var _133=mode._getFeature(oid);if(_133){_131.splice(i,1,_133);}}}that._resolve([_12f],_12a,_12c,dfd);};if(type!=="executeRelationshipQuery"){_12b=this._getShallowClone(_12b);_12b.outFields=this._getOutFields();_12b.returnGeometry=true;var map=this._map,_134;if(map){_12b.outSpatialReference=new esri.SpatialReference(map.spatialReference.toJson());}if(!this._applyQueryFilters(_12b)){switch(type){case "execute":_134=new esri.tasks.FeatureSet({features:[]});break;case "executeForIds":_134=[];break;case "executeForCount":_134=0;break;}_12e(_134,true);return dfd;}var _135=this._canDoClientSideQuery(_12b);if(_135){var _136=this._doQuery(_12b,_135,(type==="executeForIds"||type==="executeForCount"));switch(type){case "execute":_134=new esri.tasks.FeatureSet();_134.features=_136;break;case "executeForIds":_134=_136;break;case "executeForCount":_134=_136.length;break;}_12e(_134,true);return dfd;}}if(this._collection){var err=new Error("FeatureLayer::_query - "+esri.bundle.layers.FeatureLayer.invalidParams);this._resolve([err],null,_12d,dfd,true);return dfd;}if(this._ts){_12b._ts=(new Date()).getTime();}var temp=dfd._pendingDfd=this._task[type](_12b);temp.addCallbacks(_12e,function(err){that._resolve([err],null,_12d,dfd,true);});return dfd;},_convertFeaturesToJson:function(_137,_138,_139,_13a){var json=[],_13b=this._selectionSymbol,_13c=this.visibilityField,i,_13d,_13e=this.objectIdField;if(_139||_13a){_13d=_4.filter(this.fields,function(_13f){return (_13f.editable===false)&&(!_13a||(_13f.name!==_13e));});}for(i=0;i<_137.length;i++){var _140=_137[i],_141={},_142=_140.geometry,attr=_140.attributes,_143=_140.symbol;if(_142&&(!_13a||this.allowGeometryUpdates)){_141.geometry=_142.toJson();}if(_13c){_141.attributes=attr=_4.mixin({},attr);attr[_13c]=_140.visible?1:0;}else{if(attr){_141.attributes=_4.mixin({},attr);}}if(_141.attributes&&_13d&&_13d.length){_4.forEach(_13d,function(_144){delete _141.attributes[_144.name];});}if(_143&&(_143!==_13b)){_141.symbol=_143.toJson();}json.push(_141);}return _138?json:_4.toJson(json);},_selectHandler:function(_145,_146,_147,_148,dfd){var _149,ctor=this.constructor;switch(_146){case ctor.SELECTION_NEW:this.clearSelection(true);_149=true;break;case ctor.SELECTION_ADD:_149=true;break;case ctor.SELECTION_SUBTRACT:_149=false;break;}var i,_14a=_145.features,mode=this._mode,_14b=[],_14c=this.objectIdField,_14d,oid;if(_149){for(i=0;i<_14a.length;i++){_14d=_14a[i];oid=_14d.attributes[_14c];var _14e=mode._addFeatureIIf(oid,_14d);_14b.push(_14e);this._selectFeatureIIf(oid,_14e,mode);}}else{for(i=0;i<_14a.length;i++){_14d=_14a[i];oid=_14d.attributes[_14c];this._unSelectFeatureIIf(oid,mode);var _14f=mode._removeFeatureIIf(oid);_14b.push(_14f||_14d);}}if(this._isSelOnly){mode._applyTimeFilter(true);}this._resolve([_14b,_146,_145.exceededTransferLimit?{queryLimitExceeded:true}:null],"onSelectionComplete",_147,dfd);if(_145.exceededTransferLimit){this.onQueryLimitExceeded();}},_selectFeatureIIf:function(oid,_150,mode){var _151=this._selectedFeatures,_152=_151[oid];if(!_152){mode._incRefCount(oid);_151[oid]=_150;if(!this._isTable){this._setSelectSymbol(_150);}}return _152||_150;},_unSelectFeatureIIf:function(oid,mode){var _153=this._selectedFeatures[oid];if(_153){mode._decRefCount(oid);delete this._selectedFeatures[oid];if(!this._isTable){this._setUnSelectSymbol(_153);}}return _153;},_isSelected:function(_154){},_setSelectSymbol:function(_155){var _156=this._selectionSymbol;if(_156&&!this._isSelOnly){_155.setSymbol(_156);}},_setUnSelectSymbol:function(_157){var _158=this._selectionSymbol;if(_158&&!this._isSelOnly){if(_158===_157.symbol){_157.setSymbol(null,true);}}},_getOutFields:function(){var _159=_4.filter([this.objectIdField,this.typeIdField,this.creatorField,this._startTimeField,this._endTimeField,this._trackIdField].concat(this._rendererFields),function(_15a,_15b,arr){return !!_15a&&(_4.indexOf(arr,_15a)===_15b);});var _15c=_4.clone(this._outFields);if(_15c){if(_4.indexOf(_15c,"*")!==-1){return _15c;}_4.forEach(_159,function(_15d){if(_4.indexOf(_15c,_15d)===-1){_15c.push(_15d);}});return _15c;}else{return _159;}},_checkFields:function(_15e){var _15f=_15e||this._getOutFields();_4.forEach(_15f,function(_160){if(_160==="*"){return;}if(!this._getField(_160)){console.debug("esri.layers.FeatureLayer: "+esri.substitute({url:this.url,field:_160},esri.bundle.layers.FeatureLayer.fieldNotFound));}},this);if(!_15e&&!this._isTable&&!this._fserver&&!this._collection){var _161=_4.some(this.fields,function(_162){return (_162&&_162.type==="esriFieldTypeGeometry")?true:false;});if(!_161){console.debug("esri.layers.FeatureLayer: "+esri.substitute({url:this.url},esri.bundle.layers.FeatureLayer.noGeometryField));}}},_fixRendererFields:function(){var _163=this.renderer;if(_163&&this.fields.length>0){var _164=_4.filter([_163,_163.observationRenderer,_163.latestObservationRenderer,_163.trackRenderer],esri._isDefined);var _165=[];_4.forEach(_164,function(rnd){var _166,_167;_167=rnd.attributeField;if(_167){_166=!this._getField(_167)&&this._getField(_167,true);if(_166){rnd.attributeField=_166.name;}}_167=rnd.attributeField2;if(_167){_166=!this._getField(_167)&&this._getField(_167,true);if(_166){rnd.attributeField2=_166.name;}}_167=rnd.attributeField3;if(_167){_166=!this._getField(_167)&&this._getField(_167,true);if(_166){rnd.attributeField3=_166.name;}}_165.push(rnd.attributeField);_165.push(rnd.attributeField2);_165.push(rnd.attributeField3);},this);this._rendererFields=_4.filter(_165,esri._isDefined);}},_getField:function(_168,_169){var _16a=this.fields;if(_16a.length===0){return null;}var _16b;if(_169){_168=_168.toLowerCase();}_4.some(_16a,function(_16c){var _16d=false;if(_169){_16d=(_16c&&_16c.name.toLowerCase()===_168)?true:false;}else{_16d=(_16c&&_16c.name===_168)?true:false;}if(_16d){_16b=_16c;}return _16d;});return _16b;},_getDateOpts:function(){if(!this._dtOpts){var _16e=_4.map(_4.filter(this.fields,function(_16f){return !!(_16f&&_16f.type==="esriFieldTypeDate");}),function(_170){return _170.name;});this._dtOpts={properties:_16e};}return this._dtOpts;},_applyNormalized:function(_171,_172){if(_171&&_172){_4.forEach(_171,function(_173,_174){if(_173&&_172[_174]){_173.setGeometry(_172[_174]);}});}},_editHandler:function(_175,adds,_176,_177,_178,dfd){var _179=_175.addResults,_17a=_175.updateResults,_17b=_175.deleteResults,i,_17c,oid,_17d,attr,_17e=this.objectIdField,mode=this._mode,_17f=this._isTable;var _180=this.editFieldsInfo,_181=this._getOutFields()||[],_182=_180&&_180.creatorField,_183=_180&&_180.creationDateField,_184=_180&&_180.editorField,_185=_180&&_180.editDateField,_186=_180&&_180.realm;if(_4.indexOf(_181,"*")===-1){if(_182&&_4.indexOf(_181,_182)===-1){_182=null;}if(_183&&_4.indexOf(_181,_183)===-1){_183=null;}if(_184&&_4.indexOf(_181,_184)===-1){_184=null;}if(_185&&_4.indexOf(_181,_185)===-1){_185=null;}}var _187=(_183||_185)?(new Date()).getTime():null,_188=(_182||_184)?this.getUserId():undefined;if(_188&&_186){_188=_188+"@"+_186;}if(_179){for(i=0;i<_179.length;i++){_179[i]=new esri.layers.FeatureEditResult(_179[i]);if(_17f){continue;}_17c=_179[i];if(_17c.success){oid=_17c.objectId;_17d=adds[i];var gl=_17d._graphicsLayer;if(gl&&gl!==this){gl.remove(_17d);}attr=_17d.attributes||{};attr[_17e]=oid;if(_182){attr[_182]=_188;}if(_184){attr[_184]=_188;}if(_183){attr[_183]=_187;}if(_185){attr[_185]=_187;}_17d.setAttributes(attr);mode.drawFeature(_17d);}}}if(_17a){for(i=0;i<_17a.length;i++){_17a[i]=new esri.layers.FeatureEditResult(_17a[i]);if(_17f){continue;}_17c=_17a[i];if(_17c.success){oid=_17c.objectId;_17d=_176[oid];var _189=mode._getFeature(oid);if(_189){if(_189.geometry!==_17d.geometry){_189.setGeometry(esri.geometry.fromJson(_17d.geometry.toJson()));}this._repaint(_189,oid);}_17d=_189||_17d;attr=_17d.attributes||{};if(_184){attr[_184]=_188;}if(_185){attr[_185]=_187;}_17d.setAttributes(attr);}}}if(_17b){var _18a=[];for(i=0;i<_17b.length;i++){_17b[i]=new esri.layers.FeatureEditResult(_17b[i]);if(_17f){continue;}_17c=_17b[i];if(_17c.success){oid=_17c.objectId;_17d=mode._getFeature(oid);if(_17d){if(this._unSelectFeatureIIf(oid,mode)){_18a.push(_17d);}_17d._count=0;mode._removeFeatureIIf(oid);}}}if(_18a.length>0){this.onSelectionComplete(_18a,this.constructor.SELECTION_SUBTRACT);}}this._resolve([_179,_17a,_17b],"onEditsComplete",_177,dfd);},_sendAttachment:function(type,_18b,_18c,_18d,_18e){var _18f=(type==="add")?"addAttachment":"updateAttachment",url=this._url.path+"/"+_18b+"/"+_18f,self=this;var dfd=esri.request({url:url,form:_18c,content:_4.mixin(this._url.query,{f:"json",token:this._getToken()||undefined}),callbackParamName:"callback.html",handleAs:"json"}).addCallback(function(_190){var _191=(type==="add")?"addAttachmentResult":"updateAttachmentResult",_192=(type==="add")?"onAddAttachmentComplete":"onUpdateAttachmentComplete",_193=new esri.layers.FeatureEditResult(_190[_191]);_193.attachmentId=_193.objectId;_193.objectId=_18b;self._resolve([_193],_192,_18d);return _193;}).addErrback(function(_194){self._resolve([_194],null,_18e,null,true);});return dfd;},_repaint:function(_195,oid,_196){oid=esri._isDefined(oid)?oid:_195.attributes[this.objectIdField];if(!(oid in this._selectedFeatures)||!this._selectionSymbol){_195.setSymbol(_195.symbol,_196);}},_getKind:function(_197){var _198=this._trackManager;if(_198){return _198.isLatestObservation(_197)?1:0;}return 0;}});_4.mixin(esri.layers.FeatureLayer,{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"});esri._createWrappers("esri.layers.FeatureLayer");_4.declare("esri.layers.FeatureType",null,{constructor:function(json){if(json&&_4.isObject(json)){this.id=json.id;this.name=json.name;var _199=json.symbol;if(_199){this.symbol=esri.symbol.fromJson(_199);}var _19a=json.domains,_19b,i;var _19c=this.domains={};for(_19b in _19a){if(_19a.hasOwnProperty(_19b)){var _19d=_19a[_19b];switch(_19d.type){case "range":_19c[_19b]=new esri.layers.RangeDomain(_19d);break;case "codedValue":_19c[_19b]=new esri.layers.CodedValueDomain(_19d);break;case "inherited":_19c[_19b]=new esri.layers.InheritedDomain(_19d);break;}}}var _19e=json.templates;if(_19e){var _19f=this.templates=[];for(i=0;i<_19e.length;i++){_19f.push(new esri.layers.FeatureTemplate(_19e[i]));}}}},toJson:function(){var json={id:this.id,name:this.name,symbol:this.symbol&&this.symbol.toJson()};var _1a0,_1a1=this.domains,_1a2=this.templates,_1a3=esri._sanitize;if(_1a1){var _1a4=json.domains={};for(_1a0 in _1a1){if(_1a1.hasOwnProperty(_1a0)){_1a4[_1a0]=_1a1[_1a0]&&_1a1[_1a0].toJson();}}_1a3(_1a4);}if(_1a2){json.templates=_4.map(_1a2,function(_1a5){return _1a5.toJson();});}return _1a3(json);}});_4.declare("esri.layers.FeatureTemplate",null,{constructor:function(json){if(json&&_4.isObject(json)){this.name=json.name;this.description=json.description;this.drawingTool=json.drawingTool;var _1a6=json.prototype;this.prototype=new esri.Graphic(_1a6.geometry,null,_1a6.attributes);}},toJson:function(){return esri._sanitize({name:this.name,description:this.description,drawingTool:this.drawingTool,prototype:this.prototype&&this.prototype.toJson()});}});_4.mixin(esri.layers.FeatureTemplate,{TOOL_AUTO_COMPLETE_POLYGON:"esriFeatureEditToolAutoCompletePolygon",TOOL_CIRCLE:"esriFeatureEditToolCircle",TOOL_ELLIPSE:"esriFeatureEditToolEllipse",TOOL_FREEHAND:"esriFeatureEditToolFreehand",TOOL_LINE:"esriFeatureEditToolLine",TOOL_NONE:"esriFeatureEditToolNone",TOOL_POINT:"esriFeatureEditToolPoint",TOOL_POLYGON:"esriFeatureEditToolPolygon",TOOL_RECTANGLE:"esriFeatureEditToolRectangle",TOOL_ARROW:"esriFeatureEditToolArrow",TOOL_TRIANGLE:"esriFeatureEditToolTriangle",TOOL_LEFT_ARROW:"esriFeatureEditToolLeftArrow",TOOL_RIGHT_ARROW:"esriFeatureEditToolRightArrow",TOOL_UP_ARROW:"esriFeatureEditToolUpArrow",TOOL_DOWN_ARROW:"esriFeatureEditToolDownArrow"});_4.declare("esri.layers.FeatureEditResult",null,{constructor:function(json){if(json&&_4.isObject(json)){this.objectId=json.objectId;this.success=json.success;if(!json.success){var err=json.error;this.error=new Error();this.error.code=err.code;this.error.message=err.description;}}}});_4.declare("esri.layers._RenderMode",null,{constructor:function(){this._prefix="jsonp_"+(_4._scopeName||"dojo")+"IoScript";},initialize:function(map){},propertyChangeHandler:function(type){},destroy:function(){},drawFeature:function(_1a7){},suspend:function(){},resume:function(){},refresh:function(){},_incRefCount:function(oid){var _1a8=this._featureMap[oid];if(_1a8){_1a8._count++;}},_decRefCount:function(oid){var _1a9=this._featureMap[oid];if(_1a9){_1a9._count--;}},_getFeature:function(oid){return this._featureMap[oid];},_addFeatureIIf:function(oid,_1aa){var fmap=this._featureMap,_1ab=fmap[oid],_1ac=this.featureLayer;if(!_1ab){fmap[oid]=_1aa;_1ac._add(_1aa);_1aa._count=0;}return _1ab||_1aa;},_removeFeatureIIf:function(oid){var _1ad=this._featureMap[oid],_1ae=this.featureLayer;if(_1ad){if(_1ad._count){return;}delete this._featureMap[oid];_1ae._remove(_1ad);}return _1ad;},_clearIIf:function(){var i,_1af=this.featureLayer,_1b0=_1af.graphics,_1b1=_1af._selectedFeatures,_1b2=_1af.objectIdField;for(i=_1b0.length-1;i>=0;i--){var _1b3=_1b0[i];var oid=_1b3.attributes[_1b2];if(oid in _1b1){_1b3._count=1;continue;}_1b3._count=0;this._removeFeatureIIf(oid);}},_isPending:function(id){var dfd=_4.io.script[this._prefix+id];return dfd?true:false;},_cancelPendingRequest:function(dfd,id){dfd=dfd||_4.io.script[this._prefix+id];if(dfd){try{dfd.cancel();_4.io.script._validCheck(dfd);}catch(e){}}},_purgeRequests:function(){_4.io.script._validCheck(null);},_toggleVisibility:function(show){var _1b4=this.featureLayer,_1b5=_1b4.graphics,_1b6=show?"show":"hide",i,len=_1b5.length;show=show&&_1b4._ager;for(i=0;i<len;i++){var _1b7=_1b5[i];_1b7[_1b6]();if(show){_1b4._repaint(_1b7);}}},_applyTimeFilter:function(_1b8){var _1b9=this.featureLayer;if(!_1b9.timeInfo||_1b9._suspended){return;}if(!_1b8){_1b9._fireUpdateStart();}var _1ba=_1b9._trackManager;if(_1ba){_1ba.clearTracks();}var defn=_1b9.getTimeDefinition(),_1bb=_1b9._getOffsettedTE(_1b9._mapTimeExtent);if(_1bb){_1bb=_1b9._getTimeOverlap(defn,_1bb);if(_1bb){var _1bc=_1b9._filterByTime(_1b9.graphics,_1bb.startTime,_1bb.endTime);if(_1ba){_1ba.addFeatures(_1bc.match);}_4.forEach(_1bc.match,function(_1bd){var _1be=_1bd._shape;if(!_1bd.visible){_1bd.show();_1be=_1bd._shape;_1be&&_1be._moveToFront();}if(_1b9._ager&&_1be){_1b9._repaint(_1bd);}});_4.forEach(_1bc.noMatch,function(_1bf){if(_1bf.visible){_1bf.hide();}});}else{this._toggleVisibility(false);}}else{if(_1ba){_1ba.addFeatures(_1b9.graphics);}this._toggleVisibility(true);}if(_1ba){_1ba.moveLatestToFront();_1ba.drawTracks();}if(!_1b8){_1b9._fireUpdateEnd();}}});_4.declare("esri.layers._SelectionMode",[esri.layers._RenderMode],{constructor:function(_1c0){this.featureLayer=_1c0;this._featureMap={};},initialize:function(map){this.map=map;this._init=true;},propertyChangeHandler:function(type){if(this._init&&type===0){this._applyTimeFilter();}},destroy:function(){this._init=false;},resume:function(){this.propertyChangeHandler(0);}});_4.declare("esri.layers._SnapshotMode",[esri.layers._RenderMode],{constructor:function(_1c1){this.featureLayer=_1c1;this._featureMap={};this._drawFeatures=_4.hitch(this,this._drawFeatures);this._queryErrorHandler=_4.hitch(this,this._queryErrorHandler);},initialize:function(map){this.map=map;var _1c2=this.featureLayer;if(_1c2._collection){this._applyTimeFilter();}else{this._fetchAll();}this._init=true;},propertyChangeHandler:function(type){if(this._init){if(type){this._fetchAll();}else{this._applyTimeFilter();}}},destroy:function(){this._init=false;},drawFeature:function(_1c3){var _1c4=this.featureLayer,_1c5=_1c4.objectIdField,oid=_1c3.attributes[_1c5];this._addFeatureIIf(oid,_1c3);this._incRefCount(oid);},resume:function(){this.propertyChangeHandler(0);},refresh:function(){var _1c6=this.featureLayer;if(_1c6._collection){_1c6._fireUpdateStart();_1c6._refresh(true);_1c6._fireUpdateEnd();}else{this._fetchAll();}},_getRequestId:function(_1c7){var id="_"+_1c7.name+_1c7.layerId+_1c7._ulid;return id.replace(/[^a-zA-Z0-9\_]+/g,"_");},_fetchAll:function(){var _1c8=this.featureLayer;if(_1c8._collection){return;}_1c8._fireUpdateStart();this._clearIIf();this._sendRequest();},_sendRequest:function(){var map=this.map,_1c9=this.featureLayer,_1ca=_1c9.getDefinitionExpression();var _1cb=new esri.tasks.Query();_1cb.outFields=_1c9._getOutFields();_1cb.where=_1ca||"1=1";_1cb.returnGeometry=true;_1cb.outSpatialReference=new esri.SpatialReference(map.spatialReference.toJson());_1cb.timeExtent=_1c9.getTimeDefinition();_1cb.maxAllowableOffset=_1c9._maxOffset;if(_1c9._ts){_1cb._ts=(new Date()).getTime();}var _1cc;if(_1c9._usePatch){_1cc=this._getRequestId(_1c9);this._cancelPendingRequest(null,_1cc);}_1c9._task.execute(_1cb,this._drawFeatures,this._queryErrorHandler,_1cc);},_drawFeatures:function(_1cd){this._purgeRequests();var _1ce=_1cd.features,_1cf=this.featureLayer,_1d0=_1cf.objectIdField,i,len=_1ce.length,_1d1,oid;for(i=0;i<len;i++){_1d1=_1ce[i];oid=_1d1.attributes[_1d0];this._addFeatureIIf(oid,_1d1);this._incRefCount(oid);}this._applyTimeFilter(true);_1cf._fireUpdateEnd(null,_1cd.exceededTransferLimit?{queryLimitExceeded:true}:null);if(_1cd.exceededTransferLimit){_1cf.onQueryLimitExceeded();}},_queryErrorHandler:function(err){this._purgeRequests();var _1d2=this.featureLayer;_1d2._errorHandler(err);_1d2._fireUpdateEnd(err);}});_4.declare("esri.layers._OnDemandMode",[esri.layers._RenderMode],{constructor:function(_1d3){this.featureLayer=_1d3;this._featureMap={};this._queryErrorHandler=_4.hitch(this,this._queryErrorHandler);},initialize:function(map){this.map=map;this._initialize();this._init=true;},propertyChangeHandler:function(type){if(this._init){if(type<2){this._zoomHandler();}}},destroy:function(){this._disableConnectors();this._init=false;},drawFeature:function(_1d4){var _1d5=this._gridLayer,geom=_1d4.geometry,_1d6=[];if(!geom){return;}_1d6=_1d5.getCellsInExtent((geom.type==="point")?{xmin:geom.x,ymin:geom.y,xmax:geom.x,ymax:geom.y}:geom.getExtent(),false).cells;var _1d7=this._cellMap,i,cell,oid=_1d4.attributes[this.featureLayer.objectIdField],_1d8,row,col;for(i=0;i<_1d6.length;i++){cell=_1d6[i];_1d8=cell.latticeID;row=cell.row;col=cell.col;if(_1d8){cell=(_1d7[_1d8]=(_1d7[_1d8]||cell));}else{_1d7[row]=_1d7[row]||{};cell=(_1d7[row][col]=(_1d7[row][col]||cell));}cell.features=cell.features||[];cell.features.push(_1d4);this._addFeatureIIf(oid,_1d4);this._incRefCount(oid);}},suspend:function(){if(!this._init){return;}this._disableConnectors();},resume:function(){if(!this._init){return;}this._enableConnectors();this._zoomHandler();},refresh:function(){this._zoomHandler();},_initialize:function(){var map=this.map,_1d9=this.featureLayer;var _1da=_1d9._srInfo;this._gridLayer=new esri.layers._GridLayout(new esri.geometry.Point(_1da?_1da.valid[0]:map.extent.xmin,map.extent.ymax,map.spatialReference),{width:_1d9._tileWidth,height:_1d9._tileHeight},{width:map.width,height:map.height},_1da);this._ioQueue=[];if(!_1d9._suspended){this._zoomHandler();this._enableConnectors();}},_enableConnectors:function(){var map=this.map;this._zoomConnect=_4.connect(map,"onZoomEnd",this,this._zoomHandler);this._panConnect=_4.connect(map,"onPanEnd",this,this._panHandler);this._resizeConnect=_4.connect(map,"onResize",this,this._panHandler);},_disableConnectors:function(){_4.disconnect(this._zoomConnect);_4.disconnect(this._panConnect);_4.disconnect(this._resizeConnect);},_zoomHandler:function(){this._processIOQueue(true);var _1db=this.featureLayer,map=this.map;if(_1db._suspended){return;}_1db._fireUpdateStart();this._clearIIf();var _1dc=_1db._trackManager;if(_1dc){_1dc.clearTracks();}this._cellMap={};this._gridLayer.setResolution(map.extent);this._sendRequest();},_panHandler:function(){this.featureLayer._fireUpdateStart();this._sendRequest(this.featureLayer._resized&&arguments[0]);},_getRequestId:function(_1dd,cell){var id="_"+_1dd.name+_1dd.layerId+_1dd._ulid+"_"+cell.resolution+"_"+(cell.latticeID||(cell.row+"_"+cell.col));return id.replace(/[^a-zA-Z0-9\_]+/g,"_");},_sendRequest:function(_1de){this._exceeds=false;var _1df=this.featureLayer,map=this.map,_1e0=_1de||map.extent,_1e1=this._gridLayer.getCellsInExtent(_1e0,_1df.latticeTiling),_1e2=_1e1.cells;if(!_1df._editable){var _1e3=this._cellMap;_1e2=_4.filter(_1e2,function(cell){if(cell.lattice){if(_1e3[cell.latticeID]){return false;}}else{if(_1e3[cell.row]&&_1e3[cell.row][cell.col]){return false;}}return true;});}var _1e4=_1df._getOutFields(),_1e5=_1df.getDefinitionExpression(),time=_1df._getOffsettedTE(_1df._mapTimeExtent),_1e6=_1df._usePatch,_1e7=this._ioQueue,i,self=this,func=this._drawFeatures,cell,_1e8,_1e9;this._pending=this._pending||0;for(i=0;i<_1e2.length;i++){cell=_1e2[i];_1e8=new esri.tasks.Query();_1e8.geometry=cell.extent||cell.lattice;_1e8.outFields=_1e4;_1e8.where=_1e5;if(_1df.latticeTiling&&cell.extent){_1e8.spatialRelationship=esri.tasks.Query.SPATIAL_REL_CONTAINS;}_1e8.returnGeometry=true;_1e8.timeExtent=time;_1e8.maxAllowableOffset=_1df._maxOffset;if(_1df._ts){_1e8._ts=(new Date()).getTime();}_1e9=null;if(_1e6){_1e9=this._getRequestId(_1df,cell);if(this._isPending(_1e9)){continue;}}this._pending++;_1e7.push(_1df._task.execute(_1e8,function(){var _1ea=cell;return function(_1eb){func.apply(self,[_1eb,_1ea]);};}.call(this),this._queryErrorHandler,_1e9));}this._removeOldCells(_1e0);this._endCheck();},_drawFeatures:function(_1ec,cell){this._exceeds=this._exceeds||_1ec.exceededTransferLimit;this._finalizeIO();var _1ed=this.featureLayer,map=this.map,_1ee=map.extent,_1ef=cell.extent,row=cell.row,col=cell.col,_1f0=_1ed.objectIdField,_1f1=_1ec.features,_1f2=this._gridLayer,_1f3=this._cellMap,i,len,_1f4=cell.latticeID,_1f5=_1f4?_1f3[_1f4]:(_1f3[row]&&_1f3[row][col]);if((cell.resolution!=_1f2._resolution)||(_1f4?(_1f4!==_1f2.getLatticeID(_1ee)):(!_1f2.intersects(_1ef,_1ee)))){if(_1f5){this._removeCell(row,col,_1f4);}}else{if(_1f5){this._updateCell(_1f5,_1f1);}else{cell.features=_1f1;if(_1f4){_1f3[_1f4]=cell;}else{_1f3[row]=_1f3[row]||{};_1f3[row][col]=cell;}len=_1f1.length;for(i=0;i<len;i++){var _1f6=_1f1[i];var oid=_1f6.attributes[_1f0];this._addFeatureIIf(oid,_1f6);this._incRefCount(oid);}}}this._endCheck();},_queryErrorHandler:function(err){this._finalizeIO();this.featureLayer._errorHandler(err);this._endCheck(true);},_finalizeIO:function(){this._purgeRequests();this._pending--;},_endCheck:function(_1f7){if(this._pending===0){this._processIOQueue();var _1f8=this.featureLayer,_1f9=_1f8._trackManager;if(_1f9){_1f9.clearTracks();_1f9.addFeatures(_1f8.graphics);if(_1f8._ager){_4.forEach(_1f8.graphics,function(_1fa){if(_1fa._shape){_1f8._repaint(_1fa);}});}_1f9.moveLatestToFront();_1f9.drawTracks();}this.featureLayer._fireUpdateEnd(_1f7&&new Error("FeatureLayer: "+esri.bundle.layers.FeatureLayer.updateError),this._exceeds?{queryLimitExceeded:true}:null);if(this._exceeds){_1f8.onQueryLimitExceeded();}}},_processIOQueue:function(_1fb){this._ioQueue=_4.filter(this._ioQueue,function(dfd){var keep=dfd.fired>-1?false:true;return keep;});if(_1fb){_4.forEach(this._ioQueue,this._cancelPendingRequest);}},_removeOldCells:function(_1fc){var _1fd=this._cellMap,_1fe=this._gridLayer,_1ff,_200;for(_1ff in _1fd){if(_1fd[_1ff]){var row=_1fd[_1ff],_201=row.latticeID,_202=0,_203=0;if(_201){_202++;if(_201!==_1fe.getLatticeID(_1fc)){this._removeCell(null,null,_201);_203++;}}else{for(_200 in row){if(row[_200]){_202++;var _204=row[_200].extent;if(!_1fe.intersects(_204,_1fc)){this._removeCell(_1ff,_200);_203++;}}}}if(_203===_202){delete _1fd[_1ff];}}}},_updateCell:function(cell,_205){var _206=this.featureLayer,_207=_206.objectIdField,_208=_206._selectedFeatures,i,len=_205.length;cell.features=cell.features||[];for(i=0;i<len;i++){var _209=_205[i];var oid=_209.attributes[_207];var _20a=this._addFeatureIIf(oid,_209);if(_20a===_209){this._incRefCount(oid);cell.features.push(_20a);}else{if(!(oid in _208)){_20a.setGeometry(_209.geometry);_20a.setAttributes(_209.attributes);}}}},_removeCell:function(row,col,_20b){var _20c=this._cellMap,_20d=this.featureLayer,_20e=_20d.objectIdField;var cell=_20b?_20c[_20b]:(_20c[row]&&_20c[row][col]);if(cell){if(_20b){delete _20c[_20b];}else{delete _20c[row][col];}var _20f=cell.features,i;for(i=0;i<_20f.length;i++){var _210=_20f[i];var oid=_210.attributes[_20e];this._decRefCount(oid);if(oid in _20d._selectedFeatures){continue;}this._removeFeatureIIf(oid);}}}});_4.declare("esri.layers._GridLayout",null,{constructor:function(_211,_212,_213,_214){this.origin=_211;this.cellWidth=_212.width;this.cellHeight=_212.height;this.mapWidth=_213.width;this.mapHeight=_213.height;this.srInfo=_214;},setResolution:function(_215){this._resolution=(_215.xmax-_215.xmin)/this.mapWidth;if(this.srInfo){var _216=Math.round((2*this.srInfo.valid[1])/this._resolution),_217=Math.round(_216/this.cellWidth);this._frameStats=[_217,0,_217-1];}},getCellCoordinates:function(_218){var res=this._resolution,_219=this.origin;return {row:Math.floor((_219.y-_218.y)/(this.cellHeight*res)),col:Math.floor((_218.x-_219.x)/(this.cellWidth*res))};},normalize:function(col){var _21a=this._frameStats;if(_21a){var _21b=_21a[0],m180=_21a[1],p180=_21a[2];if(col<m180){col=col%_21b;col=col<m180?col+_21b:col;}else{if(col>p180){col=col%_21b;}}}return col;},intersects:function(_21c,_21d){var _21e=this.srInfo;if(_21e){return _4.some(_21d._getParts(_21e),function(_21f){return _21c.intersects(_21f.extent);});}else{return _21c.intersects(_21d);}},getCellExtent:function(row,col){var res=this._resolution,_220=this.origin,_221=this.cellWidth,_222=this.cellHeight;return new esri.geometry.Extent((col*_221*res)+_220.x,_220.y-((row+1)*_222*res),((col+1)*_221*res)+_220.x,_220.y-(row*_222*res),new esri.SpatialReference(_220.spatialReference.toJson()));},getLatticeID:function(_223){var _224=this.getCellCoordinates({x:_223.xmin,y:_223.ymax}),_225=this.getCellCoordinates({x:_223.xmax,y:_223.ymin}),_226=_224.row,_227=_225.row,_228=this.normalize(_224.col),_229=this.normalize(_225.col);return _226+"_"+_227+"_"+_228+"_"+_229;},sorter:function(a,b){return (a<b)?-1:1;},getCellsInExtent:function(_22a,_22b){var _22c=this.getCellCoordinates({x:_22a.xmin,y:_22a.ymax}),_22d=this.getCellCoordinates({x:_22a.xmax,y:_22a.ymin}),_22e=_22c.row,_22f=_22d.row,_230=_22c.col,_231=_22d.col,_232=[],i,j,nj,_233=[],_234=[],len,xmin,xmax,ymin,ymax,_235=[],_236,_237;for(i=_22e;i<=_22f;i++){for(j=_230;j<=_231;j++){nj=this.normalize(j);_22a=this.getCellExtent(i,nj);_232.push({row:i,col:nj,extent:_22a,resolution:this._resolution});if(_22b){_233.push(_22a.xmin,_22a.xmax);_234.push(_22a.ymin,_22a.ymax);}}}_230=this.normalize(_230);_231=this.normalize(_231);_233.sort(this.sorter);_234.sort(this.sorter);len=_233.length;for(i=len-1;i>=0;i--){if(i<(len-1)){if(_233[i]===_233[i+1]){_233.splice(i,1);}}}len=_234.length;for(i=len-1;i>=0;i--){if(i<(len-1)){if(_234[i]===_234[i+1]){_234.splice(i,1);}}}if(_233.length&&_234.length){xmin=_233[0];xmax=_233[_233.length-1];ymin=_234[0];ymax=_234[_234.length-1];len=_233.length;for(i=0;i<len;i++){_235.push([[_233[i],ymax],[_233[i],ymin]]);}len=_234.length;for(i=0;i<len;i++){_235.push([[xmin,_234[i]],[xmax,_234[i]]]);}_236=new esri.geometry.Polyline({paths:_235,spatialReference:this.origin.spatialReference.toJson()});_237=_22e+"_"+_22f+"_"+_230+"_"+_231;_232.push({latticeID:_237,lattice:_236,resolution:this._resolution});}return {minRow:_22e,maxRow:_22f,minCol:_230,maxCol:_231,cells:_232};}});_4.declare("esri.layers._TrackManager",null,{constructor:function(_238){this.layer=_238;this.trackMap={};},initialize:function(map){this.map=map;var _239=this.layer,_23a=_239.renderer.trackRenderer;if(_23a&&(_239.geometryType==="esriGeometryPoint")){var _23b=(this.container=new esri.layers._GraphicsLayer({id:_239.id+"_tracks",_child:true}));_23b._setMap(map,_239._div);_23b.setRenderer(_23a);}},addFeatures:function(_23c){var tkid,_23d=this.trackMap,_23e=this.layer,_23f=_23e._trackIdField;_4.forEach(_23c,function(_240){var _241=_240.attributes;tkid=_241[_23f];var ary=(_23d[tkid]=(_23d[tkid]||[]));ary.push(_240);});var _242=_23e._startTimeField,_243=_23e.objectIdField;var _244=function(a,b){var _245=a.attributes[_242],_246=b.attributes[_242];if(_245===_246){return (a.attributes[_243]<b.attributes[_243])?-1:1;}else{return (_245<_246)?-1:1;}};for(tkid in _23d){_23d[tkid].sort(_244);}},drawTracks:function(){var _247=this.container;if(!_247){return;}var _248=this.trackMap,sr=this.map.spatialReference,tkid,ary,path,i,_249;for(tkid in _248){ary=_248[tkid];path=[];for(i=ary.length-1;i>=0;i--){_249=ary[i].geometry;if(_249){path.push([_249.x,_249.y]);}}if(path.length>0){_247.add(new esri.Graphic(new esri.geometry.Polyline({paths:[path],spatialReference:sr})));}}},moveLatestToFront:function(){_4.forEach(this.getLatestObservations(),function(_24a){var _24b=_24a._shape;_24b&&_24b._moveToFront();this._repaint(_24a,null,true);},this.layer);},getLatestObservations:function(){var _24c=[];if(!this.layer.renderer.latestObservationRenderer){return _24c;}var _24d=this.trackMap,tkid;for(tkid in _24d){var ary=_24d[tkid];_24c.push(ary[ary.length-1]);}return _24c;},clearTracks:function(){var _24e=this.getLatestObservations();this.trackMap={};var _24f=this.container;if(_24f){_24f.clear();}_4.forEach(_24e,function(_250){this._repaint(_250,null,true);},this.layer);},isLatestObservation:function(_251){var _252=this.layer._trackIdField;var _253=this.trackMap[_251.attributes[_252]];if(_253){return (_253[_253.length-1]===_251);}return false;},destroy:function(){var _254=this.container;if(_254){_254.clear();_254._unsetMap(this.map,this.layer._div);this.container=null;}this.map=null;this.layer=null;this.trackMap=null;}});}}};});