// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/ReportPlayer/core/supportClasses/map/WebMapsUtil","dojo/_base/lang dojo/Deferred dojo/_base/Deferred dojo/when esri/kernel esri/IdentityManager esri/arcgis/utils esri/geometry/Extent esri/request esri/dijit/geoenrichment/utils/UrlUtil".split(" "),function(p,u,q,g,r,v,l,m,t,h){var e={};h.isPageRunOnWebService()||(r.id.getCredential=function(){var a=new q;a.reject(Error("Can't get credentials"));return a});var n={_itemsCache:{},_siCache:{},loadItem:function(a){this._itemsCache[a]||
(this._itemsCache[a]=l.getItem(a));return g(this._itemsCache[a],function(a){return a&&p.clone(a)})},loadServiceInfo:function(a,d){this._siCache[a]||(this._siCache[a]=d({url:a,content:{f:"json"}}));return this._siCache[a]}};e.getItem=function(a){return n.loadItem(a)};e.isWebMapType=function(a){return a&&"Web Map"===a.type};e.createMap=function(a,d,c){c=c||{};if(a&&a.item)return g(!e.isWebMapType(a.item)&&e.createItemDataForNonWebMapItem(a,{defaultBasemapId:c.defaultBasemapId}),function(){return l.createMap(a,
d,{usePopupManager:!0,mapOptions:{extent:c.extent,sliderPosition:c.sliderPosition}})})};e.createItemDataForNonWebMapItem=function(a,d){function c(){b.url=function(a){["FeatureServer","MapServer","ImageServer"].some(function(b){if(-1!==a.indexOf(b))return a=a.substr(0,a.lastIndexOf(b)+b.length),!0});return a}(b.url);var a=d.requestFunc||t;h.registerCORS(b.url);return n.loadServiceInfo(b.url,a).then(function(a){return g(function(a,b){if(!a.extent){var c=b.initialExtent||b.fullExtent||b.extent;!c||c instanceof
m||(c=new m(c));a.extent=c}}(b,a),function(){return a})})}function f(b){return g(function(){var a={title:"My basemap",baseMapLayers:[{id:"basemapLayer01",opacity:d.hideBasemap?0:1,visibility:!d.hideBasemap,url:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"}]};return d.defaultBasemapId?e.getItem(d.defaultBasemapId).then(function(b){return b&&b.itemData&&b.itemData.baseMap||a}):a}(),function(c){a.itemData={baseMap:c,operationalLayers:b};return a})}d=d||{};a.itemData=
null;var b=a.item;if("Feature Service"===b.type)return c().then(function(a){for(var c=[],d=0;d<a.layers.length;d++){var e=a.layers[d],k=e.id;c.unshift({url:b.url+"/"+k,capabilities:a.capabilities||"Query",id:"featureServiceLayer_"+k,visibility:e.defaultVisibility,mode:1,title:e.name||"Feature Service Layer "+k})}return f(c)});if("Map Service"===b.type)return c().then(function(a){return f([{url:b.url,id:"mapServiceLayer01",visibility:!0,opacity:1,title:"Map Service Layer"}])});if("Image Service"===
b.type)return c().then(function(a){return f([{url:b.url,id:"imageServiceLayer01",visibility:!0,opacity:1,title:"Image Service Layer"}])});if("Vector Tile Service"===b.type)return c().then(function(a){return f([{url:b.url,id:"vectorTileServiceLayer01",visibility:!0,opacity:1,title:"Vector Tile Service Layer"}])});if("WMSServer"===b.type)return c().then(function(a){return f([{url:b.url,id:"wmsLayer01",visibility:!0,opacity:1,title:"WMS Layer"}])});if("WMTS"===b.type)return c().then(function(a){return f([{url:b.url,
id:"wmtsLayer01",visibility:!0,opacity:1,title:"WMTS Layer"}])});if("WFS"===b.type)return c().then(function(a){return f([{url:b.url,id:"wfsLayer01",visibility:!0,opacity:1,title:"WFS Layer"}])});if("KML"===b.type)return h.registerCORS(b.url),f([{url:b.url,id:"kmlLayer01",visibility:!0,opacity:1,title:"KML Layer",type:"KML"}])};return e});