/*
 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.agsdynamic"],["require","esri.layers.dynamic"],["require","esri.layers.agscommon"],["require","esri._time"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.layers.agsdynamic"]){_4._hasResource["esri.layers.agsdynamic"]=true;_4.provide("esri.layers.agsdynamic");_4.require("esri.layers.dynamic");_4.require("esri.layers.agscommon");_4.require("esri._time");_4.declare("esri.layers.ArcGISDynamicMapServiceLayer",[esri.layers.DynamicMapServiceLayer,esri.layers.ArcGISMapServiceLayer],{constructor:function(_7,_8){var _9=_8&&_8.imageParameters,dh=_4.hitch;if(_9){var _a=_9.layerDefinitions;if(_a){this.setLayerDefinitions(_a);}if(_9.layerOption===esri.layers.ImageParameters.LAYER_OPTION_SHOW){this.visibleLayers=[].concat(_9.layerIds);}}this._setIsPNG32=dh(this,this._setIsPNG32);this.dpi=(_9&&_9.dpi)||96;this.imageFormat=(_9&&_9.format)||"png8";this.imageTransparency=(_9&&_9.transparent===false)?false:true;this._setIsPNG32();this.gdbVersion=_8&&_8.gdbVersion;this._params.gdbVersion=this.gdbVersion;_4.mixin(this._params,this._url.query,{dpi:this.dpi,transparent:this.imageTransparency,format:this.imageFormat},_9?_9.toJson():{});this.getImageUrl=dh(this,this.getImageUrl);this._initLayer=dh(this,this._initLayer);this._load=dh(this,this._load);this.useMapImage=_8?_8.useMapImage:false;if(this.useMapImage){this._imageExportHandler=dh(this,this._imageExportHandler);}this._loadCallback=_8&&_8.loadCallback;var _b=_8&&_8.resourceInfo;if(_b){this._initLayer(_b);}else{if(arguments[2]===undefined||arguments[2]===false){this._load();}}},disableClientCaching:false,layerDefinitions:null,_initLayer:function(_c,io){this.inherited(arguments);if(_c.timeInfo){this.timeInfo=new esri.layers.TimeInfo(_c.timeInfo);}this.loaded=true;this.onLoad(this);var _d=this._loadCallback;if(_d){delete this._loadCallback;_d(this);}},getImageUrl:function(_e,_f,_10,_11){var _12=this._url.path+"/export?",_13=this._params,sr=_e.spatialReference.wkid||_4.toJson(_e.spatialReference.toJson()),_14=this._errorHandler;delete _13._ts;_4.mixin(_13,{bbox:_e.xmin+","+_e.ymin+","+_e.xmax+","+_e.ymax,bboxSR:sr,imageSR:sr,size:_f+","+_10},this.disableClientCaching?{_ts:new Date().getTime()}:{});if(_13.layerDefs){var _15=_13.layerDefs;delete _13.layerDefs;_4.mixin(_13,{layerDefs:_15});}var _16=(_13.token=this._getToken()),_17=esri._getProxiedUrl(_12+_4.objectToQuery(_4.mixin({},_13,{f:"image"})));if((_17.length>esri.config.defaults.io.postLength)||this.useMapImage){this._jsonRequest=esri.request({url:_12,content:_4.mixin(_13,{f:"json"}),callbackParamName:"callback",load:function(_18,io){var _19=_18.href;if(_16){_19+=(_19.indexOf("?")===-1?("?token="+_16):("&token="+_16));}_11(esri._getProxiedUrl(_19));},error:_14});}else{_11(_17);}},_setIsPNG32:function(){var _1a=this.imageFormat.toLowerCase();var _1b=_4.isIE;this.isPNG32=_1b&&_1b===6&&(_1a==="png32"||_1a==="png24")&&this.imageTransparency;},_setTime:function(_1c){var _1d=(this._params.time=_1c?_1c.toJson().join(","):null);if(this.version<10.02&&this.timeInfo){if(!_1d){var _1e=this.layerInfos;if(_1e){var _1f=this.layerTimeOptions,_20=_1f?_1f.slice(0):[],ids=[];_4.forEach(_1e,function(_21){if(!_21.subLayerIds){ids.push(_21.id);}});if(ids.length){_4.forEach(ids,function(id){if(!_20[id]){var opt=new esri.layers.LayerTimeOptions();opt.useTime=false;_20[id]=opt;}});this._params.layerTimeOptions=esri._serializeTimeOptions(_20,ids);}}}else{this._params.layerTimeOptions=esri._serializeTimeOptions(this.layerTimeOptions);}}if(this.version>=10.02&&this.timeInfo){if(!_1d){this._params.time="null,null";}}},setDPI:function(dpi,_22){this.dpi=(this._params.dpi=dpi);if(!_22){this.refresh(true);}},setImageFormat:function(_23,_24){this.imageFormat=(this._params.format=_23);this._setIsPNG32();if(!_24){this.refresh(true);}},setImageTransparency:function(_25,_26){this.imageTransparency=(this._params.transparent=_25);this._setIsPNG32();if(!_26){this.refresh(true);}},setVisibleLayers:function(_27,_28){this.visibleLayers=_27;this._params.layers=esri.layers.ImageParameters.LAYER_OPTION_SHOW+":"+_27.join(",");this._updateDynamicLayers();if(!_28){this.refresh(true);}},setDefaultVisibleLayers:function(_29){this.visibleLayers=this._defaultVisibleLayers;this._params.layers=null;this._updateDynamicLayers();if(!_29){this.refresh(true);}},setLayerDefinitions:function(_2a,_2b){this.layerDefinitions=_2a;this._params.layerDefs=esri._serializeLayerDefinitions(_2a);this._updateDynamicLayers();if(!_2b){this.refresh(true);}},setDefaultLayerDefinitions:function(_2c){this.layerDefinitions=this._params.layerDefs=null;this._updateDynamicLayers();if(!_2c){this.refresh(true);}},setDisableClientCaching:function(_2d){this.disableClientCaching=_2d;},setLayerTimeOptions:function(_2e,_2f){this.layerTimeOptions=_2e;this._params.layerTimeOptions=esri._serializeTimeOptions(_2e);this._updateDynamicLayers();if(!_2f){this.refresh(true);}},refresh:function(_30){if(_30){this.inherited(arguments);}else{var dc=this.disableClientCaching;this.disableClientCaching=true;this.inherited(arguments);this.disableClientCaching=dc;}},setLayerDrawingOptions:function(_31,_32){this.layerDrawingOptions=_31;this._updateDynamicLayers();if(!_32){this.refresh(true);}},setDynamicLayerInfos:function(_33,_34){this.dynamicLayerInfos=_33;this.visibleLayers=esri._getDefaultVisibleLayers(_33);this._updateDynamicLayers();if(!_34){this.refresh(true);}},createDynamicLayerInfosFromLayerInfos:function(){var _35=[],_36,_37;_4.forEach(this.layerInfos,function(_38,idx){_36=new esri.layers.DynamicLayerInfo(_38.toJson());_36.source=new esri.layers.LayerMapSource({mapLayerId:_38.id});_35.push(_36);});return _35;},_onDynamicLayersChange:function(){},_updateDynamicLayers:function(){if((this.dynamicLayerInfos&&this.dynamicLayerInfos.length>0)||(this.layerDrawingOptions&&this.layerDrawingOptions.length>0)){var _39,_3a=this.dynamicLayerInfos?this.dynamicLayerInfos:this.layerInfos,_3b=[],_3c=this._map&&esri.geometry.getScale(this._map),_3d=this.visibleLayers,_3e=_3c?esri._getLayersForScale(_3c,_3a):_3d;_4.forEach(_3a,function(_3f){if(!_3f.subLayerIds){var _40=_3f.id;if(_4.indexOf(_3d,_40)!==-1&&_4.indexOf(_3e,_40)!==-1){var _41={id:_40};if(this.dynamicLayerInfos){_41.source=_3f.source&&_3f.source.toJson();}else{_41.source={type:"mapLayer",mapLayerId:_40};}var _42;if(this.layerDefinitions&&this.layerDefinitions[_40]){_42=this.layerDefinitions[_40];}if(_42){_41.definitionExpression=_42;}var _43;if(this.layerDrawingOptions&&this.layerDrawingOptions[_40]){_43=this.layerDrawingOptions[_40];}if(_43){_41.drawingInfo=_43.toJson();}var _44;if(this.layerTimeOptions&&this.layerTimeOptions[_40]){_44=this.layerTimeOptions[_40];}if(_44){_41.layerTimeOptions=_44.toJson();}_3b.push(_41);}}},this);_39=_4.toJson(_3b);if(_39==="[]"){_39="[{}]";}if(!this._params.dynamicLayers||(this._params.dynamicLayers.length!==_39.length||this._params.dynamicLayers!==_39)){this._params.dynamicLayers=_39;this._onDynamicLayersChange(this._params.dynamicLayers);}}else{if(this._params.dynamicLayers){this._params.dynamicLayers=null;this._onDynamicLayersChange(null);}else{this._params.dynamicLayers=null;}}},_onExtentChangeHandler:function(_45,_46,_47){if(_47){this._updateDynamicLayers();}this.inherited(arguments);},_setMap:function(map,_48,_49){this._map=map;this._updateDynamicLayers();return this.inherited(arguments);},onGDBVersionChange:function(){},setGDBVersion:function(_4a,_4b){this.gdbVersion=_4a;this._params.gdbVersion=_4a;this.onGDBVersionChange();if(!_4b){this.refresh(true);}},exportMapImage:function(_4c,_4d){var m=esri.config.defaults.map,p=_4.mixin({size:m.width+","+m.height},this._params,_4c?_4c.toJson(this.normalization):{},{f:"json"});delete p._ts;if(p.layerDefs){var _4e=p.layerDefs;delete p.layerDefs;_4.mixin(p,{layerDefs:_4e});}this._exportMapImage(this._url.path+"/export",p,_4d);}});_4.declare("esri.layers.ImageParameters",null,{constructor:function(){this.layerDefinitions=[];this._bundle=_4.i18n.getLocalization("esri","jsapi");},bbox:null,extent:null,width:null,height:null,dpi:null,format:null,imageSpatialReference:null,layerOption:null,layerIds:null,transparent:null,timeExtent:null,layerTimeOptions:null,toJson:function(_4f){if(this.bbox){_4.deprecated(this.declaredClass+" : "+this._bundle.layers.imageParameters.deprecateBBox);}var bb=this.bbox||this.extent;bb=bb&&_4f&&bb._normalize(true);var _50=this.layerOption,_51=bb?(bb.spatialReference.wkid||_4.toJson(bb.spatialReference.toJson())):null,_52=this.imageSpatialReference,_53={dpi:this.dpi,format:this.format,transparent:this.transparent,size:(this.width!==null&&this.height!==null?this.width+","+this.height:null),bbox:(bb?(bb.xmin+","+bb.ymin+","+bb.xmax+","+bb.ymax):null),bboxSR:_51,layers:(_50?_50+":"+this.layerIds.join(","):null),imageSR:(_52?(_52.wkid||_4.toJson(_52.toJson())):_51)};_53.layerDefs=esri._serializeLayerDefinitions(this.layerDefinitions);var _54=this.timeExtent;_53.time=_54?_54.toJson().join(","):null;_53.layerTimeOptions=esri._serializeTimeOptions(this.layerTimeOptions);return esri.filter(_53,function(_55){if(_55!==null){return true;}});}});_4.mixin(esri.layers.ImageParameters,{LAYER_OPTION_SHOW:"show",LAYER_OPTION_HIDE:"hide",LAYER_OPTION_INCLUDE:"include",LAYER_OPTION_EXCLUDE:"exclude"});_4.declare("esri.layers.MapImage",null,{constructor:function(_56){_4.mixin(this,_56);this.extent=new esri.geometry.Extent(this.extent);}});}}};});