// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
require({cache:{"url:widgets/BasemapGallery/setting/Edit.html":'\x3cdiv style\x3d"width: 100%"\x3e\r\n\x3c!--   \x3cdiv data-dojo-attach-point\x3d"secondPage" \x3e --\x3e\r\n  \x3cdiv class\x3d"setting-content-div" data-dojo-attach-point\x3d"settingContentDiv"\x3e\r\n    \x3cdiv class\x3d"error-massage-div" data-dojo-attach-point\x3d"errorMassage"\x3e\x3c/div\x3e\r\n    \x3cdiv class\x3d"edit-section title-section"\x3e\r\n      \x3cdiv class\x3d"header"\x3e*${nls.title}\x3c/div\x3e\r\n      \x3cdiv class\x3d"input"\x3e\r\n        \x3cinput type\x3d"text" data-dojo-type\x3d"dijit/form/ValidationTextBox" data-dojo-attach-point\x3d"title"\r\n            required\x3d"true" placeHolder\x3d\'${nls.titlePH}\' data-dojo-props\x3d\'style:{width:"100%"}\'/\x3e\x3c/input\x3e\r\n      \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"edit-section thumbnail-section"\x3e\r\n      \x3cdiv class\x3d"header"\x3e${nls.thumbnail}\x3c/div\x3e\r\n      \x3cdiv class\x3d"input"\x3e\r\n        \x3cdiv class\x3d"image_chooser_base thumbnail" data-dojo-attach-point\x3d"imageChooserBase"\x3e\x3c/div\x3e\r\n        \x3cspan class\x3d"thumbnail-tip"\x3e\x26nbsp;\x26nbsp;\x26nbsp;\x26nbsp;(${nls.thumbnailHint}) \x3c/span\x3e\r\n      \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"edit-section url-section" data-dojo-attach-point\x3d"urlEditSection"\x3e\r\n      \x3cdiv class\x3d"header"\x3e${nls.url}\x3c/div\x3e\r\n      \x3cdiv class\x3d"add-layer-url" data-dojo-attach-event\x3d"onclick: onAddLayerUrl"\x3e+ ${nls.addUrl}\x3c/div\x3e\r\n      \x3cdiv class\x3d"input-url"\x3e\r\n        \x3cinput class\x3d"url_field_dom" type\x3d"text" data-dojo-type\x3d"jimu/dijit/ServiceURLInput" data-dojo-attach-point\x3d"url"\r\n            required\x3d"true"\r\n            placeHolder\x3d\'${nls.urlPH}\' data-dojo-props\x3d\'style:{width:"95%"}\'/\x3e\x3c/input\x3e\r\n      \x3c/div\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/html dojo/on dojo/query dojo/Deferred dijit/_WidgetsInTemplateMixin dijit/registry jimu/BaseWidgetSetting jimu/dijit/ImageChooser dojo/text!./Edit.html jimu/dijit/ServiceURLInput jimu/SpatialReference/wkidUtils jimu/utils ../utils".split(" "),function(q,d,r,e,l,m,t,u,v,w,h,x,y,z,n,k){return q([w,u],{baseClass:"jimu-basemapgallery-Edit",ImageChooser:null,templateString:x,validUrl:!1,mapName:null,subLayerUrlNum:0,urlInputS:[],baseMapSRID:null,
spatialReference:null,postCreate:function(){this.inherited(arguments);this.imageChooser=new h({cropImage:!0,defaultSelfSrc:this.folderUrl+"images/default.jpg",showSelfImg:!0,format:[h.GIF,h.JPEG,h.PNG],goldenWidth:84,goldenHeight:67});e.addClass(this.imageChooser.domNode,"img-chooser");e.place(this.imageChooser.domNode,this.imageChooserBase,"replace");this.own(l(this.url,"Change",d.hitch(this,"_onServiceUrlChange")));this.title.proceedValue=!1;this.own(l(this.title,"Change",d.hitch(this,"_onBaseMapTitleChange")));
this.url.proceedValue=!1;this.url.setProcessFunction(d.hitch(this,"_onServiceFetch",this.url),d.hitch(this,"_onServiceFetchError"))},startup:function(){var a=/data:image/;this.basemap&&this.basemap.title&&this.title.set("value",this.basemap.title);a=this.basemap&&this.basemap.thumbnailUrl?a.test(this.basemap.thumbnailUrl)?this.basemap.thumbnailUrl:0===this.basemap.thumbnailUrl.indexOf("//")?this.basemap.thumbnailUrl:n.processUrlInWidgetConfig(this.basemap.thumbnailUrl,this.folderUrl):this.folderUrl+
"images/default.jpg";this.imageChooser.setDefaultSelfSrc(a);if(this.basemap&&this.basemap.layers)if(k.isNoUrlLayerMap(this.basemap.layers))e.destroy(this.urlPart),m(".delete-layer-url",this.urlEditSection).forEach(d.hitch(this,function(c){e.addClass(c,"invisible")})),m(".add-layer-url",this.urlEditSection).forEach(d.hitch(this,function(c){e.addClass(c,"invisible")}));else{a=this.basemap.layers.length;this.basemap.layers[0]&&this.basemap.layers[0].url&&this.url.set("value",this.basemap.layers[0].url);
for(var b=1;b<a;b++)this.addLayerUrl(this.basemap.layers[b].url)}},_onServiceUrlChange:function(){this.popup.disableButton(0)},_checkTitle:function(a){for(var b=!0,c=0;c<this.basemaps.length;c++)this.basemaps[c].title===a&&(b=this.basemap&&this.basemap.title===a?!0:!1);return b},_onBaseMapTitleChange:function(a){var b=this._checkTitle(a),c=null;a?b?this.title.proceedValue=!0:(this.title.proceedValue=!1,c=this.nls.invalidTitle1+a+this.nls.invalidTitle2):this.title.proceedValue=!1;this._checkProceed(c)},
_checkProceed:function(a){var b=!0,c=[];e.setAttr(this.errorMassage,"innerHTML","");if(this.title.proceedValue){c=this._getUrlDijits();for(var f=0;f<c.length;f++)b=b&&c[f].proceedValue}else b=!1;b?this.popup.enableButton(0):(this.popup.disableButton(0),a&&e.setAttr(this.errorMassage,"innerHTML",a))},_onServiceFetch:function(a,b){var c=!1,f=null,g=b.url.replace(/\/*$/g,"");c=this.map.width>this.map.height?this.map.width:this.map.height;if(this._isStringEndWith(g,"/MapServer")||this._isStringEndWith(g,
"/ImageServer")){g=this.map.spatialReference;var p=b.data.spatialReference||b.data.extent.spatialReference||b.data.initialExtent.spatialReference||b.data.fullExtent.spatialReference;g&&p&&z.isSameSR(g.wkid,p.wkid)&&k.tilingSchemeCompatible(this.map.__tileInfo,b.data.tileInfo,c)?c=a.proceedValue=!0:(c=a.proceedValue=!1,f=this.nls.invalidBasemapUrl2)}else c=a.proceedValue=!1,f=this.nls.invalidBasemapUrl1;this._checkProceed(f);return c},_isStringEndWith:function(a,b){return a.lastIndexOf(b)+b.length===
a.length},_onServiceFetchError:function(){},onAddLayerUrl:function(){this.addLayerUrl()},addLayerUrl:function(a){var b=e.create("div",{"class":"input-url"},this.urlEditSection),c=(new y({placeHolder:this.nls.urlPH,required:!0,proceedValue:0,style:{width:"95%"}})).placeAt(b);e.addClass(c.domNode,"url_field_dom");a&&c.set("value",a);a=e.create("div",{"class":"delete-layer-url"},b);this.own(l(a,"click",d.hitch(this,"_onDeleteClick",b)));c.setProcessFunction(d.hitch(this,"_onServiceFetch",c),d.hitch(this,
"_onServiceFetchError"));this._checkProceed()},_onDeleteClick:function(a){e.destroy(a);this._checkProceed()},_getUrlDijits:function(){var a=[];m(".url_field_dom",this.urlEditSection).forEach(d.hitch(this,function(b){a.push(v.byNode(b))}));return a},_getEditedBaseMap:function(){var a=new t,b={title:n.stripHTML(this.title.value),layers:[],spatialReference:this.basemap&&this.basemap.spatialReference||this.map.spatialReference};k.isNoUrlLayerMap(this.basemap?this.basemap.layers:[])?b.layers=this.basemap.layers:
r.forEach(this._getUrlDijits(),function(c){b.layers.push({url:c.value})},this);/data:image/.test(this.imageChooser.imageData)?(b.thumbnailUrl=this.imageChooser.imageData,a.resolve(b)):n.getBase64Data(k.getStanderdUrl(this.imageChooser.imageData)).then(d.hitch(this,function(c){b.thumbnailUrl=c?c:this.folderUrl+"images/default.jpg";a.resolve(b)}));return a},_onEditOk:function(a){this.basemap?this._getEditedBaseMap().then(d.hitch(this,function(b){a.updateBasemap(this.basemap.title,b)})):this._getEditedBaseMap().then(d.hitch(this,
function(b){a.addNewBasemap(b)}));a.popup.close()},_onEditClose:function(a){a.popup&&a.popup.close();this.destroy()}})});