// 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:{"widgets/DistrictLookup/search":function(){define("dojo/_base/declare dijit/_WidgetBase dojo/Evented dojo/_base/lang dojo/_base/array esri/dijit/Search esri/tasks/locator esri/layers/FeatureLayer jimu/utils dojo/dom-construct jimu/LayerInfos/LayerInfos ./searchSourceUtils dojo/when dojo/Deferred dojo/promise/all dojo/on esri/InfoTemplate".split(" "),function(I,T,g,Q,O,M,H,F,t,k,A,m,e,d,r,y,z){return I([T,g],{config:null,map:null,searchOptions:null,layerInfosObj:null,_urlParams:{},
constructor:function(h){Q.mixin(this,h)},postCreate:function(){this._urlParams={}},startup:function(){this.inherited(arguments);A.getInstance(this.map,this.map.itemInfo).then(Q.hitch(this,function(h){this.layerInfosObj=h;this.own(this.layerInfosObj.on("layerInfosFilterChanged",Q.hitch(this,this.onLayerInfosFilterChanged)));m.setMap(this.map);m.setLayerInfosObj(this.layerInfosObj);m.setAppConfig(this.appConfig);e(m.getConfigInfo(this.config.searchSourceSettings)).then(Q.hitch(this,function(v){this.config.searchSourceSettings||
(this.config.searchSourceSettings=v);return r(this._convertConfig(v)).then(function(L){return O.filter(L,function(J){return J})})})).then(Q.hitch(this,function(v){this.domNode&&this._init(v)}))}))},_convertConfig:function(h){return O.map(h.sources,Q.hitch(this,function(v){var L=new d;if(v&&v.url&&"locator"===v.type){var J={locator:new H(v.url||""),outFields:["*"],singleLineFieldName:v.singleLineFieldName||"",name:t.stripHTML(v.name||""),placeholder:t.stripHTML(v.placeholder||""),countryCode:v.countryCode||
"",maxSuggestions:v.maxSuggestions,maxResults:v.maxResults||6,zoomScale:v.zoomScale||5E4,useMapExtent:!!v.searchInCurrentMapExtent};v.enableLocalSearch&&(J.localSearchOptions={minScale:v.localSearchMinScale,distance:v.localSearchDistance});L.resolve(J)}else v&&v.url&&"query"===v.type?(J=new F(v.url||null,{outFields:["*"]}),this.own(y(J,"load",Q.hitch(this,function(U){var S=U.layer;var N=this._getInfoTemplate(S,v,v.displayField);var D=null;v.searchFields&&0<v.searchFields.length?D=v.searchFields:(D=
[],O.forEach(S.fields,function(G){"esriFieldTypeOID"!==G.type&&G.name!==S.objectIdField&&"esriFieldTypeGeometry"!==G.type&&D.push(G.name)}));U={featureLayer:S,outFields:["*"],searchFields:D,displayField:v.displayField||"",exactMatch:!!v.exactMatch,name:t.stripHTML(v.name||""),placeholder:t.stripHTML(v.placeholder||""),maxSuggestions:v.maxSuggestions||6,maxResults:v.maxResults||6,zoomScale:v.zoomScale||5E4,infoTemplate:N,useMapExtent:!!v.searchInCurrentMapExtent,_featureLayerId:v.layerId};N||delete U.infoTemplate;
U._featureLayerId&&(N=this.layerInfosObj.getLayerInfoById(U._featureLayerId),S.setDefinitionExpression(N.getFilter()));L.resolve(U)}))),this.own(y(J,"error",function(){L.resolve(null)}))):L.resolve(null);return L}))},_getInfoTemplate:function(h,v,L){var J;var U=(J=this.layerInfosObj.getLayerInfoById(v.layerId))&&J.getInfoTemplate();var S=J&&U;if(J&&!S)return null;S||(U=new z,U.setTitle("\x26nbsp;"),U.setContent(Q.hitch(this,"_formatContent",v.name,h,L)));return U},_init:function(h){var v=1===h.length?
0:"all";h={map:this.map,addLayersFromMap:!1,autoNavigate:!1,autoComplete:!0,minCharacters:0,searchDelay:100,enableInfoWindow:!0,enableHighlight:this.config.searchSourceSettings.showInfoWindowOnSelect,showInfoWindowOnSelect:this.config.searchSourceSettings.showInfoWindowOnSelect,allPlaceholder:t.stripHTML(this.config.searchSourceSettings.allPlaceholder),sources:h,activeSourceIndex:v};Q.mixin(h,this.searchOptions);this._urlParams=this._getUrlParams();this.search=new M(h,k.create("div",{"class":"searchControl"}));
k.place(this.search.domNode,this.domNode);this.own(this.search.on("load",Q.hitch(this,this._load)));this.own(this.search.on("select-result",Q.hitch(this,this._selectResult)));this.own(this.search.on("clear-search",Q.hitch(this,this._clear)));this.own(this.search.on("search-results",Q.hitch(this,this._results)));this.own(this.search.on("suggest-results",Q.hitch(this,this._results)));this.search.startup()},_getUrlParams:function(){var h=t.urlToObject(document.location.href);h.query=h.query||{};return h.query},
setSearchText:function(h){this.search.set("value",h)},clearSearchText:function(){this.search&&this.search.clear()},_setSearchString:function(){this._urlParams.find&&(this.search.set("value",this._urlParams.find),setTimeout(Q.hitch(this,function(){this.search.search()}),1E3))},onLayerInfosFilterChanged:function(h){O.some(h,Q.hitch(this,function(v){this.search&&this.search.sources&&0<this.search.sources.length&&O.forEach(this.search.sources,function(L){L._featureLayerId===v.id&&L.featureLayer.setDefinitionExpression(v.getFilter())})}))},
_load:function(h){this.emit("search-loaded",h);this._setSearchString()},_results:function(h){this.emit("search-results",h)},_clear:function(h){this.emit("clear-search",h)},_selectResult:function(h){this.search.blur();this.emit("select-result",h)}})})},"esri/dijit/Search":function(){define("require dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/Evented dojo/Deferred dojo/keys dojo/on dojo/query dojo/uacss dojo/regexp dojo/dom dojo/dom-attr dojo/dom-class dojo/dom-style dojo/dom-construct dojo/date/locale dojo/i18n!../nls/jsapi dojo/text!./Search/templates/Search.html dijit/_WidgetBase dijit/_TemplatedMixin dijit/_FocusMixin dijit/a11yclick dijit/focus ../lang ../InfoTemplate ../kernel ../SpatialReference ../graphic ../promiseList ../symbols/PictureMarkerSymbol ../symbols/SimpleMarkerSymbol ../symbols/SimpleLineSymbol ../symbols/SimpleFillSymbol ../symbols/TextSymbol ../symbols/Font ../geometry/Point ../geometry/Extent ../geometry/normalizeUtils ../geometry/scaleUtils ../tasks/locator ../tasks/query ../Color ../styles/basic".split(" "),
function(I,T,g,Q,O,M,H,F,t,k,A,m,e,d,r,y,z,h,v,L,J,U,S,N,D,G,aa,ca,Z,ea,C,da,Y,w,n,u,W,ja,ba,ka,sa,qa,ya,ra){function Ea(b,l){b&&l&&(b._layer=l,b._sourceLayer=l)}T=T([L,J,U,O],{declaredClass:"esri.dijit.Search",templateString:v,reHostedFS:/https?:\/\/services.*\.arcgis\.com/i,constructor:function(b,l){this.css={searchGroup:"searchGroup",searchInput:"searchInput",searchInputGroup:"searchInputGroup",searchBtn:"searchBtn",searchSubmit:"searchSubmit",searchIcon:"searchIcon esri-icon-search",searchButtonText:"searchButtonText",
searchToggle:"searchToggle",searchToggleIcon:"searchIcon esri-icon-down-arrow",searchMenu:"searchMenu",searchMenuHeader:"menuHeader",searchClear:"searchClear",searchClearIcon:"searchIcon esri-icon-close searchClose",searchSpinner:"searchIcon esri-icon-loading-indicator searchSpinner",searchSourceName:"sourceName",suggestionsMenu:"suggestionsMenu",sourcesMenu:"sourcesMenu",activeSource:"active",hasValue:"hasValue",hasButtonMode:"hasButtonMode",hasMultipleSources:"hasMultipleSources",showSuggestions:"showSuggestions",
showSources:"showSources",showNoResults:"showNoResults",searchLoading:"searchLoading",latLonHeader:"searchLatLongHeader",searchMoreResults:"moreResults",searchMoreResultsList:"resultsList",searchMoreResultsHeader:"moreHeader",searchMoreResultsItem:"moreItem",searchMoreResultsListHeader:"popupHeader",searchShowMoreResults:"showMoreResults",searchNoResultsMenu:"noResultsMenu",searchNoResultsBody:"noResultsBody",searchNoResultsHeader:"noResultsHeader",searchNoValueIcon:"noValueIcon esri-icon-notice-triangle",
searchNoValueText:"noValueText",searchNoResultsText:"noResultsText",searchExpandContainer:"searchExpandContainer",searchAnimateContainer:"searchAnimate",searchExpanded:"searchExpanded",searchCollapsed:"searchCollapsed",searchClearFloat:"searchClearFloat"};this._allIndex="all";this._objectIdIdentifier="_objectId";this._deferreds=[];this._sourceNames=[];this.defaultSource={locator:new sa("//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),singleLineFieldName:"SingleLine",outFields:["Addr_type",
"Match_addr","StAddr","City"],name:h.widgets.Search.main.esriLocatorName,localSearchOptions:{minScale:3E5,distance:5E4},placeholder:h.widgets.Search.main.placeholder,highlightSymbol:(new C(I.toUrl("./Search/images/search-pointer.png"),36,36)).setOffset(9,18)};this.options={map:null,theme:"arcgisSearch",visible:!0,value:"",allPlaceholder:"",sources:[this.defaultSource],activeSourceIndex:0,suggestionDelay:150,enableSourcesMenu:!0,enableSuggestionsMenu:!0,enableInfoWindow:!0,showInfoWindowOnSelect:!0,
enableSuggestions:!0,enableButtonMode:!1,autoNavigate:!0,autoSelect:!0,addLayersFromMap:!1,zoomScale:1E3,graphicsLayer:null,enableHighlight:!0,highlightGraphic:null,enableLabel:!1,labelSymbol:(new n).setColor(new ya([181,56,46,.9])).setFont(new u("14px",u.STYLE_NORMAL,u.VARIANT_NORMAL,u.WEIGHT_BOLD,"Arial")),labelGraphic:null,infoTemplate:new G(h.widgets.Search.main.searchResult,'\x3cdiv class\x3d"${searchTheme}"\x3e\x3cdiv id\x3d"${searchMoreResultsId}" class\x3d"${searchMoreResults}"\x3e\x3cdiv class\x3d"${searchMoreResultsItem}"\x3e${searchResult}\x3c/div\x3e\x3cdiv\x3e${searchMoreResultsHtml}\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e'),
searchResults:null,suggestResults:null,selectedResult:null,magicKey:null,selectedFeatureId:null,expanded:!1,maxLength:128,maxResults:6,maxSuggestions:6,locationToAddressDistance:1500,minCharacters:3,enableSearchingAll:!0};b=g.mixin({},this.options,b);this.set(b);this._updateActiveSource();this._i18n=h;this._defaultSR=new ca(4326);this.domNode=l},startup:function(){this.inherited(arguments);this.sources||(this.sources=[]);this._mapLoaded().then(g.hitch(this,this._init))},postCreate:function(){var b=
this;this.inherited(arguments);this._moreResultsId=this.id+"_more_results";this.own(F(this.submitNode,S,g.hitch(this,this._searchButton)));this.own(F(this.sourcesBtnNode,S,g.hitch(this,this._toggleSourcesMenu)));this.own(F(this.inputNode,S,g.hitch(this,this._inputClick)));this.own(F(this.clearNode,S,g.hitch(this,this._clearButton)));this.own(F(this.formNode,"submit",g.hitch(this,function(l){l.preventDefault();this._cancelSuggest();this.search()})));this.own(F(this.inputNode,"keyup",g.hitch(this,function(l){this._inputKey(l)})));
this.own(F(this.sourcesBtnNode,"keyup",g.hitch(this,function(l){this._sourceBtnKey(l)})));this.own(F(this.suggestionsNode,"li:click, li:keyup",function(l){b._suggestionsEvent(l,this)}));this.own(F(this.sourcesNode,"li:click, li:keyup",function(l){b._sourcesEvent(l,this)}));this.own(F(this.inputNode,"input, paste",g.hitch(this,function(){this._suggestDelay()})));this.map&&this.map.infoWindow&&this.map.infoWindow.domNode&&this.enableInfoWindow&&(this.own(F(this.map.infoWindow.domNode,"#"+this._moreResultsId+
"_show:click",g.hitch(this,function(l){this._showMoreResultsClick(l)}))),this.own(F(this.map.infoWindow.domNode,"#"+this._moreResultsId+"_list li a:click",g.hitch(this,function(l){this._moreResultsClick(l)}))),this.own(F(this.map.infoWindow.domNode,"#"+this._moreResultsId+" [data-switch-coordinates]:click",g.hitch(this,function(l){this._switchCoordinatesClick(l)}))));this.value&&this._checkStatus();this._hideMenus();this._updateVisible();this._insertSources(this.sources);this._setPlaceholder(this.activeSourceIndex);
this._updateButtonMode(this.enableButtonMode);this.toggle(this.expanded)},destroy:function(){this.clear();y.empty(this.domNode);this.inherited(arguments)},clear:function(){this.clearGraphics();e.get(this.inputNode,"value")&&e.set(this.inputNode,"value","");this._changeAttrValue("value","");this.set("searchResults",null);this.set("suggestResults",null);this.set("selectedResult",null);this.set("magicKey",null);this.set("selectedFeatureId",null);d.remove(this.containerNode,this.css.hasValue);e.set(this.clearNode,
"title","");this._hideMenus();this._closePopup();this._hideLoading();this.emit("clear-search")},show:function(){r.set(this.domNode,"display","block")},hide:function(){r.set(this.domNode,"display","none")},expand:function(){this.enableButtonMode&&(d.add(this.containerNode,this.css.searchExpanded),d.remove(this.containerNode,this.css.searchCollapsed),this._hideMenus(),this.set("expanded",!0))},collapse:function(){this.enableButtonMode&&(d.remove(this.containerNode,this.css.searchExpanded),d.add(this.containerNode,
this.css.searchCollapsed),this._hideMenus(),this.set("expanded",!1))},toggle:function(b){this.enableButtonMode&&("undefined"===typeof b&&(b=!this.expanded),b?this.expand():this.collapse())},search:function(b){var l=new M;this._mapLoaded().then(g.hitch(this,function(){this._searchDeferred(b).then(g.hitch(this,function(B){var E=B.results;this.set("searchResults",E);0===B.numResults&&(this._noResults(B.value),this._showNoResultsMenu());this._hideLoading();this.emit("search-results",B);this._selectFirstResult(E,
B.activeSourceIndex);l.resolve(E)}),g.hitch(this,function(B){l.reject(B)}))}));return l.promise},suggest:function(b){var l=new M;this._mapLoaded().then(g.hitch(this,function(){this._suggestDeferred(b).then(g.hitch(this,function(B){if(B){var E=B.results;this.set("suggestResults",E);this._insertSuggestions(E,B.value);this.emit("suggest-results",B);l.resolve(E)}}),g.hitch(this,function(B){l.reject(B)}))}));return l.promise},select:function(b){var l=this._getDefaultSymbol(b),B=this.labelSymbol,E=this.sources,
P=this.activeSourceIndex,fa=this.enableHighlight,la=this.enableLabel,va=this.autoNavigate,oa=this.showInfoWindowOnSelect,ta=this.enableInfoWindow,pa=this.infoTemplate,Aa=b.feature?new Z(b.feature.toJson()):null,Qa=Aa?b.feature._sourceLayer:null;Ea(Aa,Qa);if(P===this._allIndex){var Ma=this._getSourceIndexOfResult(b);if(null!==Ma){var Ba=E[Ma];P=Ma}}else Ba=E[P];Ba&&(Ba.hasOwnProperty("highlightSymbol")&&(l=Ba.highlightSymbol),Ba.hasOwnProperty("labelSymbol")&&(B=Ba.labelSymbol),Ba.hasOwnProperty("enableHighlight")&&
(fa=Ba.enableHighlight),Ba.hasOwnProperty("enableLabel")&&(la=Ba.enableLabel),Ba.hasOwnProperty("autoNavigate")&&(va=Ba.autoNavigate),Ba.hasOwnProperty("showInfoWindowOnSelect")&&(oa=Ba.showInfoWindowOnSelect),Ba.hasOwnProperty("enableInfoWindow")&&(ta=Ba.enableInfoWindow),Ba.hasOwnProperty("infoTemplate")?pa=Ba.infoTemplate:Ba.featureLayer&&Ba.featureLayer.infoTemplate&&(pa=Ba.featureLayer.infoTemplate));this._hideMenus();this._hideLoading();if(Aa){E=this.highlightGraphic;var Oa=this.graphicsLayer;
Ma=this.labelGraphic;var Sa=g.mixin({},Aa.attributes,{searchTheme:this.theme,searchResult:this._searchResultHTML(b),searchMoreResults:this.css.searchMoreResults,searchMoreResultsItem:this.css.searchMoreResultsItem,searchMoreResultsId:this._moreResultsId,searchMoreResultsHtml:this._moreResultsHTML(b)}),Va=null;ta&&(Va=pa);Ma?(Ma.setGeometry(Aa.geometry),Ma.setAttributes(Sa),Ma.setSymbol(B),B&&"textsymbol"===B.type&&Ma.symbol.setText(b.name)):(Ma=new Z(Aa.geometry,B,Sa),Ea(Ma,Qa),B&&"textsymbol"===
B.type&&Ma.symbol.setText(b.name),la&&(Oa?Oa.add(Ma):this.map&&this.map.graphics&&this.map.graphics.add(Ma)));E?(E.setGeometry(Aa.geometry),E.setAttributes(Sa),E.setInfoTemplate(Va),E.setSymbol(l)):(E=new Z(Aa.geometry,l,Sa,Va),Ea(E,Qa),fa&&(Oa?Oa.add(E):this.map&&this.map.graphics&&this.map.graphics.add(E)));E&&E.symbol&&"textsymbol"===E.symbol.type&&E.symbol.setText(b.name);this.map&&this.map.infoWindow&&ta&&oa&&(this.map.infoWindow.setFeatures([E]),l=this._getPointFromGeometry(E.geometry),this.map.infoWindow.show(l));
this.map&&va&&b&&b.hasOwnProperty("extent")&&"function"===typeof this.map.setExtent&&this.map.setExtent(b.extent,!0);this.set("highlightGraphic",E);this.set("labelGraphic",Ma)}this.set("selectedResult",b);this.emit("select-result",{result:b,source:Ba,sourceIndex:P})},focus:function(){N.focus(this.inputNode)},blur:function(){this.inputNode.blur();N.curNode&&N.curNode.blur()},clearGraphics:function(){var b=this.highlightGraphic,l=this.graphicsLayer,B=this.labelGraphic;b&&(l?l.remove(b):this.map&&this.map.graphics&&
this.map.graphics.remove(b));B&&(l?l.remove(B):this.map&&this.map.graphics&&this.map.graphics.remove(B));this.set("labelGraphic",null);this.set("highlightGraphic",null)},_mapLoaded:function(){var b=new M;if(this.map)if(this.map.loaded)b.resolve();else F.once(this.map,"load",g.hitch(this,function(){b.resolve()}));else b.resolve();return b.promise},_init:function(){this._getMapLayers().then(g.hitch(this,function(){this.set("loaded",!0);this.emit("load")}))},_clearButton:function(){this.clear();N.focus(this.inputNode)},
_error:function(b){return Error(this.declaredClass+" "+b)},_searchDeferred:function(b){var l=new M,B=this.value,E=this.activeSourceIndex;b&&b.hasOwnProperty("index")&&(E=b.index);this._showLoading();this._hideMenus();this._closePopup();this.clearGraphics();var P={magicKey:this.magicKey,text:B};b?"string"===typeof b?(P.text=b,b=this._searchQueries(P)):b="object"===typeof b&&b.hasOwnProperty("magicKey")?this._searchQueries(b):"object"===typeof b&&b.hasOwnProperty("geometry")?this._searchQueries({geometry:b}):
"object"===typeof b&&b.hasOwnProperty(this._objectIdIdentifier)?this._searchQueries(b):"object"===typeof b&&"point"===b.type?this._searchQueries({point:b}):b instanceof Array&&2===b.length?this._searchQueries({latlon:b}):this._searchQueries(P):b=this._searchQueries(P);b.always(g.hitch(this,function(fa){fa=this._formatResults(fa,E,B);l.resolve(fa)}));return l.promise},_suggestDeferred:function(b){var l=new M;this._deferreds.push(l);b||(b=this.value);var B=this.activeSourceIndex;this._suggestQueries({text:b}).always(g.hitch(this,
function(E){var P;if(E)for(var fa=0;fa<E.length;fa++)E[fa]&&(P=!0);P?(E=this._formatResults(E,B,b),l.resolve(E)):l.resolve()}));return l.promise},_getDefaultSymbol:function(b){var l;this.map&&(l=this.map.getBasemap());l||(l="topo");if(b&&b.feature&&b.feature.geometry)var B=b.feature.geometry.type;"polyline"===B?B="line":"circle"===B||"extent"===B?B="polygon":"multipoint"===B&&(B="point");if(B){if(b=ra.getSchemes({theme:"default",basemap:l,geometryType:B}))var E=b.primaryScheme;if(E){E.color&&E.hasOwnProperty("opacity")&&
(E.color.a=E.opacity);var P=E;b=E.color;E=E.size;switch(B){case "point":var fa=new da;fa.setColor(b);fa.setSize(null!==E?E:P.size);B=new Y;B.setColor(P.outline.color);B.setWidth(P.outline.width);fa.setOutline(B);break;case "line":fa=new Y;fa.setColor(b);fa.setWidth(null!==E?E:P.width);break;case "polygon":fa=new w,fa.setColor(b),B=new Y,B.setColor(P.outline.color),B.setWidth(P.outline.width),fa.setOutline(B)}P=fa}}return P},_selectFirstResult:function(b,l){if(this.autoSelect&&b){var B;l===this._allIndex?
B=this._getFirstResult(b):b[l]&&b[l][0]&&(B=b[l][0]);B&&this.select(B)}},_getSourceIndexOfResult:function(b){var l=this.searchResults;if(l)for(var B in l)if(l[B]&&l[B].length)for(var E=0;E<l[B].length;E++)if(l[B][E]===b)return parseInt(B,10);return null},_getFirstResult:function(b){if(b)for(var l in b)if(b[l]&&b[l][0])return b[l][0];return!1},_onFocus:function(){this.map&&"function"===typeof this.map.disableKeyboardNavigation&&this.map.disableKeyboardNavigation();this.emit("focus");this.inherited(arguments)},
_onBlur:function(){this._hideMenus();this.map&&"function"===typeof this.map.enableKeyboardNavigation&&this.map.enableKeyboardNavigation();this.enableButtonMode&&this.loaded&&this.collapse();this.emit("blur");this.inherited(arguments)},_getMapLayers:function(){var b=new M;if(this.addLayersFromMap&&this.map){var l=[],B=this.map.graphicsLayerIds;if(B&&B.length){for(var E=0;E<B.length;E++){var P=this.map.getLayer(B[E]);P&&l.push(this._featureLayerLoaded(P))}ea(l).always(g.hitch(this,function(fa){for(var la,
va=this.sources,oa=0;oa<fa.length;oa++)fa[oa]&&fa[oa].loaded&&"Feature Layer"===fa[oa].type&&(va.push({featureLayer:fa[oa],enableSuggestions:!0}),la=!0);la&&this.set("sources",va);b.resolve()}))}else b.resolve()}else b.resolve();return b.promise},_switchCoordinatesClick:function(b){b.preventDefault();if(b=e.get(b.target,"data-switch-coordinates"))this._cancelSuggest(),this.set("value",b),this.search()},_moreResultsClick:function(b){b.preventDefault();var l=b.target;b=parseInt(e.get(l,"data-source-index"),
10);l=parseInt(e.get(l,"data-index"),10);var B=this.searchResults;B&&B[b]&&(b=B[b][l])&&this.select(b)},_showMoreResultsClick:function(b){b.preventDefault();if(b=m.byId(this._moreResultsId)){d.toggle(b,this.css.searchShowMoreResults);var l=m.byId(this._moreResultsId+"_show");l&&(d.contains(b,this.css.searchShowMoreResults)?e.set(l,"textContent",h.widgets.Search.main.hideMoreResults):e.set(l,"textContent",h.widgets.Search.main.showMoreResults))}},_featureLayerLoaded:function(b){var l=new M;if(b.loaded)l.resolve(b);
else if(b.loadError)l.reject(this._error("Layer failed to load."));else{var B=F.once(b,"load",g.hitch(this,function(){E.remove();l.resolve(b)}));var E=F.once(b,"error",g.hitch(this,function(){B.remove();l.reject(this._error("Layer could not be loaded."))}))}return l.promise},_getObjectSize:function(b){var l=0,B;for(B in b)b.hasOwnProperty(B)&&l++;return l},_sourcesEvent:function(b,l){var B=e.get(l,"data-index"),E=t("li",this.sourcesNode);l=Q.indexOf(E,l);B!==this._allIndex&&(B=parseInt(B,10));"click"===
b.type||b.keyCode===H.ENTER?(this.set("activeSourceIndex",B),N.focus(this.inputNode),this._hideSourcesMenu()):b.keyCode===H.UP_ARROW?(b.stopPropagation(),b.preventDefault(),b=l-1,0>b?N.focus(this.sourcesBtnNode):N.focus(E[b])):b.keyCode===H.DOWN_ARROW?(b.stopPropagation(),b.preventDefault(),b=l+1,b>=E.length?N.focus(this.sourcesBtnNode):N.focus(E[b])):b.keyCode===H.ESCAPE&&(this._hideSourcesMenu(),N.focus(this.inputNode))},_suggestionsEvent:function(b,l){var B=e.get(l,"data-source-index"),E=parseInt(e.get(l,
"data-index"),10),P=t("li",this.suggestionsNode),fa=this.sources;l=Q.indexOf(P,l);B!==this._allIndex&&(B=parseInt(B,10));var la;this._clearQueryTimeout();"click"===b.type||b.keyCode===H.ENTER?((P=this.suggestResults)&&P[B]&&P[B][E]&&(la=P[B][E]),la&&(la.index=B,fa[B].featureLayer?(B=fa[B].featureLayer.objectIdField,la[this._objectIdIdentifier]=la.feature.attributes[B],this.set("value",this._getSuggestionName(la)),this.set("selectedFeatureId",la.feature.attributes[B])):la.magicKey&&la.text&&(this.set("value",
la.text),this.set("magicKey",la.magicKey)),this.search(la),N.focus(this.inputNode))):b.keyCode===H.BACKSPACE||b.keyCode===H.DELETE?N.focus(this.inputNode):b.keyCode===H.UP_ARROW?(b.stopPropagation(),b.preventDefault(),la=l-1,0>la?N.focus(this.inputNode):N.focus(P[la])):b.keyCode===H.DOWN_ARROW?(b.stopPropagation(),b.preventDefault(),la=l+1,la>=P.length?N.focus(this.inputNode):N.focus(P[la])):b.keyCode===H.ESCAPE&&(this._hideMenus(),N.focus(this.inputNode))},_getResultName:function(b){var l;b.hasOwnProperty("name")&&
null!==b.name&&(l=b.name.toString());l||(l=h.widgets.Search.main.untitledResult);return l},_getSuggestionName:function(b){var l;b.hasOwnProperty("name")&&null!==b.name&&(l=b.name.toString());b=b.text||l;b||(b=h.widgets.Search.main.untitledResult);return b},_searchResultHTML:function(b){var l="";if(b.feature&&b.feature.attributes&&b.feature.attributes.Addr_type&&"LatLong"===b.feature.attributes.Addr_type){var B=b.name.split(" ");if(2===B.length){var E=B[0];var P=B[1]}P&&E?(b=parseFloat(E),P=parseFloat(P),
B=P+", "+b,l+='\x3cdiv class\x3d"'+this.css.searchMoreResultsItem+'"\x3e',l+='\x3cdiv class\x3d"'+this.css.latLonHeader+'"\x3e'+h.widgets.Search.main.lonlat+"\x3c/div\x3e",l=l+(b+", "+P)+'\x3c/div\x3e\x3cdiv class\x3d"'+(this.css.searchMoreResultsItem+'"\x3e'),b===P||90<b||-90>b||180<P||-180>P||(l+='\x3cdiv class\x3d"'+this.css.latLonHeader+'"\x3e'+h.widgets.Search.main.reverseLonLatHeader+"\x3c/div\x3e",l+='\x3ca data-switch-coordinates\x3d"'+B+'" tabindex\x3d"0" href\x3d"#"\x3e'+B+"\x3c/a\x3e\x3c/div\x3e")):
l=b.name}else l=b.name;return l},_moreResultsHTML:function(b){var l="",B="",E=this.searchResults,P=this.sources,fa=0;if(E){B+='\x3cdiv class\x3d"'+this.css.searchMoreResultsItem+'"\x3e';B+='\x3ca href\x3d"#" id\x3d"'+this._moreResultsId+'_show"\x3e'+h.widgets.Search.main.showMoreResults+"\x3c/a\x3e";B=B+'\x3c/div\x3e\x3cdiv class\x3d"'+(this.css.searchMoreResultsList+'"\x3e');B+='\x3cdiv id\x3d"'+this._moreResultsId+'_list"\x3e';for(var la in E)if(E[la]){var va=E[la].length;if(va){var oa=1===va&&
E[la][0]===b;if(1<this._getObjectSize(E)&&!oa){var ta=this._getSourceName(la);B+='\x3cdiv class\x3d"'+this.css.searchMoreResultsListHeader+'"\x3e'+ta+"\x3c/div\x3e"}if(va&&!oa){B+="\x3cul\x3e";ta=P[la].maxResults||this.maxResults;for(oa=0;oa<va&&oa<ta;++oa)if(E[la][oa]!==b){var pa=this._getResultName(E[la][oa]);B+='\x3cli\x3e\x3ca tabindex\x3d"0" data-index\x3d"'+oa+'" data-source-index\x3d"'+la+'" href\x3d"#"\x3e'+pa+"\x3c/a\x3e\x3c/li\x3e";fa++}B+="\x3c/ul\x3e"}}}B+="\x3c/div\x3e\x3c/div\x3e"}fa&&
(l+=B);return l},_validField:function(b,l){return b.getField(l)},_validFields:function(b,l){if(b&&l&&l.length){for(var B=0;B<l.length;B++)if(!this._validField(b,l[B]))return!1;return!0}return!1},_getCodedName:function(b,l){if(b&&b.length)for(var B=0,E=b.length;B<E;B++){var P=b[B];if(P.code===l)return P.name}},_getCodedValue:function(b,l,B){if(b&&b.length)for(var E=0,P=b.length;E<P;E++){var fa=b[E],la=fa.name,va=l;B||(la=la.toLowerCase(),va=va.toLowerCase());if(la===va)return fa.code}return!1},_whereClause:function(b,
l,B,E){var P=null;if(b){var fa="";this.reHostedFS.test(l.url)&&this._containsNonLatinCharacter(b)&&(fa="N");if(B&&B.length)for(var la=0,va=B.length;la<va;la++){var oa="",ta=b.replace(/'/g,"''");oa=B[la];var pa=l.getField(oa),Aa=l.getDomain(oa);Aa&&"codedValue"===Aa.type&&(ta=this._getCodedValue(Aa.codedValues,ta,E));!1!==ta&&(pa=pa.type,"esriFieldTypeString"===pa||"esriFieldTypeDate"===pa?oa=E?oa+" \x3d "+fa+"'"+ta+"'":"UPPER("+oa+") LIKE "+fa+"'%"+ta.toUpperCase()+"%'":"esriFieldTypeOID"===pa||"esriFieldTypeSmallInteger"===
pa||"esriFieldTypeInteger"===pa||"esriFieldTypeSingle"===pa||"esriFieldTypeDouble"===pa?(ta=parseFloat(ta),oa=isNaN(ta)?!1:oa+" \x3d "+ta):oa=oa+" \x3d "+ta,oa&&(P=P?P+" or ":"",P+=oa))}}return P},_suggest:function(b){b||(b={index:this.activeSourceIndex,text:this.value});var l=new M,B=b.index,E=this.sources[B],P=this.enableSuggestions;E.hasOwnProperty("enableSuggestions")&&(P=E.enableSuggestions);var fa=0;if(b.hasOwnProperty("text")&&b.text){var la=g.trim(b.text);fa=b.text.length}b=E.minCharacters||
this.minCharacters;if(P&&la&&fa>=b&&this._supportsPagination(E)){var va="";E.prefix&&(va+=E.prefix);va+=la;E.suffix&&(va+=E.suffix);var oa=this._defaultSR;this.map&&(oa=this.map.spatialReference);P={};E.locator?(E.categories&&(P.categories=E.categories),E.locator.outSpatialReference=oa,this.map&&E.localSearchOptions&&E.localSearchOptions.hasOwnProperty("distance")&&E.localSearchOptions.hasOwnProperty("minScale")&&(fa=this._getScale(),!E.localSearchOptions.minScale||fa&&fa<=parseFloat(E.localSearchOptions.minScale))&&
(P.location=this.map.extent.getCenter(),P.distance=E.localSearchOptions.distance),P.text=va,E.useMapExtent&&this.map&&this.map.extent&&(P.searchExtent=this.map.extent),E.searchExtent&&(P.searchExtent=E.searchExtent),P.maxSuggestions=E.maxSuggestions||this.maxSuggestions,E.sourceCountry&&(P.countryCode=E.sourceCountry),E.countryCode&&(P.countryCode=E.countryCode),E.locator.suggestLocations(P).then(g.hitch(this,function(ta){l.resolve(ta)}),g.hitch(this,function(ta){ta||(ta=this._error("Locator suggestLocations could not be performed."));
l.reject(ta)}))):E.featureLayer?this._featureLayerLoaded(E.featureLayer).then(g.hitch(this,function(){var ta=this._getDisplayField(E),pa=E.searchFields||[ta],Aa=[];E.suggestionTemplate?E.suggestionTemplate.replace(/(?:\$\{([^}]+)\})/g,function(Oa,Sa){Aa.push(Sa)}):Aa=[ta];-1===Q.indexOf(Aa,E.featureLayer.objectIdField)&&Aa.push(E.featureLayer.objectIdField);ta=this._validField(E.featureLayer,ta);var Qa=this._validFields(E.featureLayer,Aa),Ma=this._validFields(E.featureLayer,pa);if(ta&&Qa&&Ma){ta=
new qa;E.hasOwnProperty("suggestQueryParams")&&g.mixin(ta,E.suggestQueryParams);ta.outSpatialReference=oa;ta.returnGeometry=!1;ta.num=E.maxSuggestions||this.maxSuggestions;ta.outFields=Aa;E.useMapExtent&&this.map&&this.map.extent&&(ta.geometry=this.map.extent);E.searchExtent&&(ta.geometry=E.searchExtent);if(pa=this._whereClause(va,E.featureLayer,pa,!1)){ta.where=pa;var Ba=!0}Ba?E.featureLayer.queryFeatures(ta,g.hitch(this,function(Oa){var Sa;(Oa=Oa.features)&&(Sa=this._hydrateResults(Oa,B,!0));l.resolve(Sa)}),
g.hitch(this,function(Oa){Oa||(Oa=this._error("FeatureLayer queryFeatures errored with suggestions"));l.reject(Oa)})):l.resolve()}else l.reject(this._error("Invalid FeatureLayer field"))})):l.reject(this._error("Invalid source"))}else l.resolve();return l.promise},_supportsPagination:function(b){var l;b.locator?l=!0:b.featureLayer&&b.featureLayer.advancedQueryCapabilities&&b.featureLayer.advancedQueryCapabilities.supportsPagination&&(l=!0);return l},_suggestQueries:function(b){var l=this.sources,
B=this.activeSourceIndex,E=[];if(B===this._allIndex)for(B=0;B<l.length;B++){var P=b;P.index=B;P=this._suggest(P);E.push(P)}else b.index=B,P=this._suggest(b),E.push(P);return ea(E)},_getPointFromGeometry:function(b){switch(b.type){case "extent":var l=b.getCenter();break;case "multipoint":l=b.getPoint(0);break;case "point":l=b;break;case "polygon":l=b.getCentroid();break;case "polyline":l=b.getPoint(0,0)}return l},_searchQueries:function(b){b.hasOwnProperty("index")||(b.index=this.activeSourceIndex);
var l=[];if(b.index===this._allIndex)for(var B=this.sources,E=0;E<B.length;E++){var P=b;P.index=E;P=this._search(P);l.push(P)}else b=this._search(b),l.push(b);return ea(l)},_searchButton:function(){this.enableButtonMode&&!this.expanded?(this.expand(),N.focus(this.inputNode)):(this._cancelSuggest(),this.search())},_search:function(b){b||(b={text:this.value,magicKey:null,geometry:null,point:null,index:this.activeSourceIndex,latlon:null});this.selectedFeatureId&&(b.text=null,b[this._objectIdIdentifier]=
this.selectedFeatureId);var l,B=new M,E=b.index,P=this.sources[E],fa;b.hasOwnProperty("text")&&b.text&&(fa=g.trim(b.text));if(P){var la="";P.prefix&&!b.magicKey&&(la+=P.prefix);la+=fa;P.suffix&&!b.magicKey&&(la+=P.suffix);var va=this._defaultSR;this.map&&(va=this.map.spatialReference);if(P.locator)if(b.hasOwnProperty("text")&&fa){var oa={};P.categories&&(oa.categories=P.categories);P.locationType&&(oa.locationType=P.locationType);va&&(P.locator.outSpatialReference=va);if(this.map&&P.localSearchOptions&&
P.localSearchOptions.hasOwnProperty("distance")&&P.localSearchOptions.hasOwnProperty("minScale")){var ta=this._getScale();if(!P.localSearchOptions.minScale||ta&&ta<=parseFloat(P.localSearchOptions.minScale))oa.location=this.map.extent.getCenter(),oa.distance=P.localSearchOptions.distance}oa.address={};oa.maxLocations=P.maxResults||this.maxResults;P.useMapExtent&&this.map&&this.map.extent&&(oa.searchExtent=this.map.extent);P.searchExtent&&(oa.searchExtent=P.searchExtent);P.sourceCountry&&(oa.countryCode=
P.sourceCountry);P.countryCode&&(oa.countryCode=P.countryCode);b.magicKey&&(oa.magicKey=b.magicKey);P.singleLineFieldName?oa.address[P.singleLineFieldName]=la:oa.address["Single Line Input"]=la;P.outFields&&(oa.outFields=P.outFields);P.locator.addressToLocations(oa).then(g.hitch(this,function(pa){pa=this._hydrateResults(pa,E,!1);B.resolve(pa)}),g.hitch(this,function(pa){pa||(pa=this._error("Locator addressToLocations could not be performed"));B.reject(pa)}))}else b.geometry?(l=this._getPointFromGeometry(b.geometry.geometry))?
this._reverseGeocodePoint(E,l).then(function(pa){B.resolve(pa)},function(pa){B.reject(pa)}):B.reject(this._error("Invalid point to reverse geocode")):b.point?this._reverseGeocodePoint(E,b.point).then(function(pa){B.resolve(pa)},function(pa){B.reject(pa)}):b.latlon?(oa=new W(b.latlon,this._defaultSR),this._reverseGeocodePoint(E,oa).then(function(pa){B.resolve(pa)},function(pa){B.reject(pa)})):b.hasOwnProperty("text")&&!fa?B.resolve([]):B.reject(this._error("Invalid query type for Locator"));else P.featureLayer?
this._featureLayerLoaded(P.featureLayer).then(g.hitch(this,function(){var pa=this._getDisplayField(P),Aa=P.searchFields||[pa];pa=this._validField(P.featureLayer,pa);var Qa=this._validFields(P.featureLayer,Aa);if(pa&&Qa){pa=new qa;P.hasOwnProperty("searchQueryParams")&&g.mixin(pa,P.searchQueryParams);va&&(pa.outSpatialReference=va,Qa=this.map&&this.map.getMaxResolution()||1/ka.getUnitValueForSR(va))&&(pa.maxAllowableOffset=Qa);pa.returnGeometry=!0;P.outFields&&(pa.outFields=P.outFields);if(!b.hasOwnProperty(this._objectIdIdentifier)){this._supportsPagination(P)&&
(pa.num=P.maxResults||this.maxResults);P.useMapExtent&&this.map&&this.map.extent&&(pa.geometry=this.map.extent);P.searchExtent&&(pa.geometry=P.searchExtent);var Ma=P.exactMatch}b.hasOwnProperty("text")&&fa?(Aa=this._whereClause(la,P.featureLayer,Aa,Ma))?(pa.where=Aa,Aa=!0):Aa=!1:b.hasOwnProperty(this._objectIdIdentifier)?(pa.objectIds=[b[this._objectIdIdentifier]],Aa=!0):b.geometry?(pa.geometry=b.geometry,Aa=!0):b.point?(pa.geometry=b.point,Aa=!0):b.latlon?(l=new W(b.latlon,this._defaultSR),pa.geometry=
l,Aa=!0):(b.hasOwnProperty("text")&&!fa?B.resolve([]):B.reject(this._error("Invalid query type for FeatureLayer")),Aa=!1);Aa?P.featureLayer.queryFeatures(pa,g.hitch(this,function(Ba){Ba=Ba.features;var Oa;Ba&&(Oa=this._hydrateResults(Ba,E,!1));B.resolve(Oa)}),g.hitch(this,function(Ba){Ba||(Ba=this._error("FeatureLayer queryFeatures could not be performed"));B.reject(Ba)})):B.resolve()}else B.reject(this._error("Invalid FeatureLayer field"))})):B.reject(this._error("Invalid source"))}else B.reject(this._error("Source is undefined"));
return B.promise},_clearQueryTimeout:function(){this._queryTimer&&clearTimeout(this._queryTimer)},_formatResults:function(b,l,B){B={activeSourceIndex:l,value:B,numResults:0,numErrors:0,errors:null,results:null};var E={},P={};if(b)if(l===this._allIndex)for(l=0;l<b.length;l++)b[l]&&(b[l]instanceof Error?(E[l]=b[l],B.numErrors++):(P[l]=b[l],B.numResults+=b[l].length));else b[0]&&(b[0]instanceof Error?(E[l]=b[0],B.numErrors++):(P[l]=b[0],B.numResults+=b[0].length));B.numErrors&&(B.errors=E);B.numResults&&
(B.results=P);return B},_reverseGeocodePoint:function(b,l){var B=new M,E=this.sources[b];if(l&&E){var P=E.locationToAddressDistance||this.locationToAddressDistance;E.locator.outSpatialReference=this._defaultSR;this.map&&(E.locator.outSpatialReference=this.map.spatialReference);E.locator.locationToAddress(l,P,g.hitch(this,function(fa){fa=this._hydrateResults([fa],b,!1);B.resolve(fa)}),g.hitch(this,function(fa){fa||(fa=this._error("Locator locationToAddress could not be performed"));B.reject(fa)}))}else B.reject(this._error("No point or source defined for reverse geocoding"));
return B.promise},_cancelDeferreds:function(){if(this._deferreds&&this._deferreds.length)for(var b=0;b<this._deferreds.length;b++)this._deferreds[b].cancel(this.declaredClass+" cancelling request");this._deferreds=[]},_sourceBtnKey:function(b){if(b){var l=t("li",this.sourcesNode);b.keyCode===H.UP_ARROW?(b.stopPropagation(),b.preventDefault(),this._showSourcesMenu(),(b=l.length)&&N.focus(l[b-1])):b.keyCode===H.DOWN_ARROW&&(b.stopPropagation(),b.preventDefault(),this._showSourcesMenu(),l[0]&&N.focus(l[0]))}},
_inputKey:function(b){if(b){var l=t("li",this.suggestionsNode),B=this.suggestResults;if(b.keyCode===H.TAB||b.keyCode===H.ESCAPE)this._cancelSuggest(),this._hideMenus();else if(b.keyCode===H.UP_ARROW)b.stopPropagation(),b.preventDefault(),this._cancelSuggest(),B&&this._showSuggestionsMenu(),(b=l.length)&&N.focus(l[b-1]);else if(b.keyCode===H.DOWN_ARROW)b.stopPropagation(),b.preventDefault(),this._cancelSuggest(),B&&this._showSuggestionsMenu(),l[0]&&N.focus(l[0]);else{if(b.ctrlKey||b.metaKey||b.keyCode===
H.copyKey||b.keyCode===H.LEFT_ARROW||b.keyCode===H.RIGHT_ARROW||b.keyCode===H.ENTER)return b;this._suggestDelay()}}},_cancelSuggest:function(){this._cancelDeferreds();this._clearQueryTimeout()},_suggestDelay:function(){this._cancelSuggest();this._changeValue();this._queryTimer=setTimeout(g.hitch(this,function(){this.suggest()}),this.suggestionDelay)},_changeValue:function(){this.set("magicKey",null);this.set("selectedFeatureId",null);this._changeAttrValue("value",this.inputNode.value);this._checkStatus()},
_inputClick:function(){this._hideSourcesMenu();this._hideNoResultsMenu()},_getSourceName:function(b){return this._sourceNames[b]},_loadSources:function(b){b=Q.filter(b,function(l){return!!l.featureLayer});b=Q.map(b,function(l){return this._featureLayerLoaded(l.featureLayer)},this);return ea(b)},_createSourceNameMap:function(b){return this._loadSources(b).then(g.hitch(this,function(){var l=Q.map(b,function(B){return B.name||B.featureLayer&&B.featureLayer.name||h.widgets.Search.main.untitledSource});
this._preventDuplicateSourceNames(b,l);return l}))},_getDuplicateSourceNameIndexes:function(b){var l={},B=[];Q.forEach(b,function(E,P){l.hasOwnProperty(E)?(-1===B.indexOf(l[E])&&B.push(l[E]),B.push(P)):b.lastIndexOf(E)!==P&&(l[E]=P)});return B},_preventDuplicateSourceNames:function(b,l){if(l&&1<l.length){var B=this._getDuplicateSourceNameIndexes(l);Q.forEach(B,function(E){l[E]+=this._getFieldsString(b[E])},this)}},_getFieldsString:function(b){var l="",B=b.featureLayer;if(B){b=b.searchFields||[this._getDisplayField(b)];
for(var E=0;E<b.length;E++){l=0===E?l+": ":l+", ";var P=b[E],fa=B.getFieldLabel(P);l+=fa||P}}return l},_splitResult:function(b,l){l=A.escapeString(l);return b.replace(new RegExp("(^|)("+l+")(|$)","ig"),"$1|$2|$3").split("|")},_insertSuggestions:function(b,l){if(this.enableSuggestionsMenu&&this.suggestionsNode){this._hideSourcesMenu();this._hideNoResultsMenu();var B=this.sources;if(b){var E=y.create("div");for(var P in b)if(b[P]&&b[P].length){var fa=this._getSourceName(P);1<B.length&&this.activeSourceIndex===
this._allIndex&&y.create("div",{className:this.css.searchMenuHeader,textContent:fa},E);fa=y.create("ul",{role:"menu"},E);for(var la=B[P].maxSuggestions||this.maxSuggestions,va=0;va<b[P].length&&va<la;++va){var oa=y.create("li",{"data-index":va,"data-source-index":P,role:"menuitem",tabindex:0},fa),ta=this._getSuggestionName(b[P][va]);ta=this._splitResult(ta,l);for(var pa=ta.length,Aa=0;Aa<pa;Aa++){var Qa=ta[Aa];Qa.toLowerCase()===l.toLowerCase()?y.create("strong",{textContent:Qa},oa):(Qa=document.createTextNode(Qa),
y.place(Qa,oa))}}}}E?(y.place(E,this.suggestionsNode,"only"),this._showSuggestionsMenu()):(y.empty(this.suggestionsNode),this._hideSuggestionsMenu())}},_insertSources:function(b){if(this.enableSourcesMenu&&b&&1<b.length){var l,B=this.activeSourceIndex,E=y.create("ul",{role:"menu"});if(this.enableSearchingAll){var P="";B===this._allIndex&&(P="active");y.create("li",{"data-index":this._allIndex,role:"menuitem",className:P,tabIndex:0,textContent:h.widgets.Search.main.all},E)}for(l=0;l<b.length;l++){P=
"";l===B&&(P=this.css.activeSource);var fa=this._getSourceName(l);y.create("li",{"data-index":l,role:"menuitem",className:P,tabIndex:0,textContent:fa},E)}d.add(this.containerNode,this.css.hasMultipleSources);y.place(E,this.sourcesNode,"only")}else d.remove(this.containerNode,this.css.hasMultipleSources),y.empty(this.sourcesNode)},_showLoading:function(){d.add(this.containerNode,this.css.searchLoading)},_hideLoading:function(){d.remove(this.containerNode,this.css.searchLoading)},_checkStatus:function(){this.value?
(d.add(this.containerNode,this.css.hasValue),e.set(this.clearNode,"title",h.widgets.Search.main.clearButtonTitle)):this.clear()},_closePopup:function(){this.enableInfoWindow&&this.map&&this.map.infoWindow&&this.map.infoWindow.hide()},_noResults:function(b){var l;b&&(l=g.trim(b));var B=y.create("div",{className:this.css.searchNoResultsBody});b&&l?(y.create("div",{className:this.css.searchNoResultsHeader,textContent:h.widgets.Search.main.noResults},B),y.create("div",{className:this.css.searchNoResultsText,
textContent:D.substitute({value:'"'+b+'"'},h.widgets.Search.main.noResultsFound)},B)):(b=y.create("div",{},B),y.create("span",{"aria-hidden":"true",className:this.css.searchNoValueIcon},b),y.create("span",{className:this.css.searchNoValueText,textContent:h.widgets.Search.main.emptyValue},b));y.place(B,this.noResultsMenuNode,"only")},_hideMenus:function(){this._hideSourcesMenu();this._hideSuggestionsMenu();this._hideNoResultsMenu()},_hideNoResultsMenu:function(){d.remove(this.containerNode,this.css.showNoResults)},
_showNoResultsMenu:function(){this._hideSourcesMenu();this._hideSuggestionsMenu();d.add(this.containerNode,this.css.showNoResults)},_hideSourcesMenu:function(){d.remove(this.containerNode,this.css.showSources)},_hideSuggestionsMenu:function(){d.remove(this.containerNode,this.css.showSuggestions)},_showSourcesMenu:function(){this._hideSuggestionsMenu();this._hideNoResultsMenu();d.add(this.containerNode,this.css.showSources)},_showSuggestionsMenu:function(){this._hideSourcesMenu();this._hideNoResultsMenu();
d.add(this.containerNode,this.css.showSuggestions)},_toggleSourcesMenu:function(){this._hideSuggestionsMenu();this._hideNoResultsMenu();d.toggle(this.containerNode,this.css.showSources)},_getFirstStringField:function(b){if(b&&(b=b.fields)&&b.length)for(var l=0;l<b.length;l++){var B=b[l];if("esriFieldTypeString"===B.type)return B.name}return""},_getDisplayField:function(b){return b.displayField||b.featureLayer.displayField||this._getFirstStringField(b.featureLayer)},_validLocation:function(b){return b&&
"number"===typeof b.x&&"number"===typeof b.y},_validExtent:function(b){return b&&"number"===typeof b.xmin&&"number"===typeof b.ymin&&"number"===typeof b.xmax&&"number"===typeof b.ymax},_hydrateResult:function(b,l,B){var E={},P=this._defaultSR;l=this.sources[l];this.map&&(P=this.map.spatialReference);if(b.hasOwnProperty("text")&&b.hasOwnProperty("magicKey"))return b;if(b.hasOwnProperty("geometry")){var fa=new Z(b.toJson());E.feature=fa;(fa=E.feature.geometry)&&fa.setSpatialReference(P)}else if(b.hasOwnProperty("location")&&
this._validLocation(b.location)){var la=new W(b.location.x,b.location.y,P);fa={};b.hasOwnProperty("attributes")&&(fa=b.attributes);b.hasOwnProperty("address")&&"object"===typeof b.address&&g.mixin(fa,b.address);b.hasOwnProperty("score")&&(fa.score=b.score);E.feature=new Z(la,null,fa,null)}!E.feature&&B&&(fa={},b.hasOwnProperty("attributes")&&(fa=b.attributes),b.hasOwnProperty("score")&&(fa.score=b.score),E.feature=new Z(null,null,fa,null));if(E.feature){if(b.hasOwnProperty("extent")&&this._validExtent(b.extent))E.extent=
new ja(b.extent),E.extent.setSpatialReference(P);else if(E.feature&&E.feature.geometry)switch(E.feature.geometry.type){case "extent":E.extent=E.feature.geometry;break;case "multipoint":E.extent=ba.getDenormalizedExtent(E.feature.geometry);break;case "polygon":E.extent=ba.getDenormalizedExtent(E.feature.geometry);break;case "polyline":E.extent=ba.getDenormalizedExtent(E.feature.geometry);break;case "point":this.map?(P=this.zoomScale,l&&l.zoomScale&&(P=l.zoomScale),this._getScale()>P?E.extent=ka.getExtentForScale(this.map,
P).centerAt(E.feature.geometry):E.extent=this.map.extent.centerAt(E.feature.geometry)):E.extent=new ja({xmin:E.feature.geometry.x-.25,ymin:E.feature.geometry.y-.25,xmax:E.feature.geometry.x+.25,ymax:E.feature.geometry.y+.25,spatialReference:this._defaultSR})}else E.extent=null;E.name="";l.featureLayer?l.suggestionTemplate&&B?E.name=D.substitute(b.attributes,l.suggestionTemplate):l.searchTemplate?E.name=D.substitute(b.attributes,l.searchTemplate):(fa=this._getDisplayField(l),B=l.featureLayer.getField(fa),
P=l.featureLayer.getDomain(fa),fa&&b.hasOwnProperty("attributes")&&b.attributes.hasOwnProperty(fa)&&(b=b.attributes[fa],P&&"codedValue"===P.type?E.name=this._getCodedName(P.codedValues,b):B&&"esriFieldTypeDate"===B.type&&!isNaN(b)?E.name=z.format(new Date(b)):E.name=b)):b.address&&l.searchTemplate?E.name=D.substitute(b.address,l.searchTemplate):b.hasOwnProperty("name")?E.name=b.name:b.hasOwnProperty("attributes")&&"object"===typeof b.attributes&&b.attributes.LongLabel?E.name=b.attributes.LongLabel:
b.hasOwnProperty("attributes")&&"object"===typeof b.attributes&&b.attributes.Match_addr?(E.name=b.attributes.Match_addr,b.attributes.Addr_type&&"POI"===b.attributes.Addr_type&&b.attributes.StAddr&&b.attributes.City?E.name+=" - "+b.attributes.StAddr+", "+b.attributes.City:b.attributes.Addr_type&&"POI"===b.attributes.Addr_type&&b.attributes.City&&(E.name+=" - "+b.attributes.City)):b.hasOwnProperty("address")&&"string"===typeof b.address?E.name=b.address:b.hasOwnProperty("address")&&"object"===typeof b.address&&
b.address.hasOwnProperty("Address")?b.address.hasOwnProperty("Match_addr")?E.name=b.address.Match_addr:b.address.hasOwnProperty("Address")&&(E.name=b.address.Address):E.feature&&E.feature.geometry&&(E.name=E.feature.geometry.x+","+E.feature.geometry.y);l.featureLayer&&E.feature&&Ea(E.feature,l.featureLayer);return E}},_getScale:function(){var b;this.map&&"function"===typeof this.map.getScale&&(b=this.map.getScale());return b},_hydrateResults:function(b,l,B,E){E=[];var P=0;if(b&&b.length)for(P;P<b.length;P++){var fa=
this._hydrateResult(b[P],l,B);fa&&E.push(fa)}return E},_containsNonLatinCharacter:function(b){for(var l=0;l<b.length;l++)if(255<b.charCodeAt(l))return!0;return!1},_setPlaceholder:function(b){var l="",B=this.sources[b];b===this._allIndex?l=this.allPlaceholder||h.widgets.Search.main.allPlaceholder:B&&B.placeholder&&(l=B.placeholder);var E=h.widgets.Search.main.all;B&&(E=this._getSourceName(b));e.set(this.sourceNameNode,"textContent",E);e.set(this.inputNode,"placeholder",l);e.set(this.inputNode,"title",
l)},_updateActiveSource:function(){var b=this.sources,l=this.activeSourceIndex,B;b&&b[l]&&(B=b[l]);B?this.set("activeSource",B):this.set("activeSource",null)},_updateVisible:function(){this.visible?this.show():this.hide()},_updateButtonMode:function(b){b?(d.toggle(this.containerNode,this.css.searchExpanded,this.expanded),d.toggle(this.containerNode,this.css.searchCollapsed,!this.expanded),d.add(this.containerNode,this.css.hasButtonMode)):(d.remove(this.containerNode,this.css.searchExpanded),d.remove(this.containerNode,
this.css.searchCollapsed),d.remove(this.containerNode,this.css.hasButtonMode))},_setDefaultActiveSourceIndex:function(b){b&&1===b.length||!this.enableSearchingAll?this.set("activeSourceIndex",0):this.set("activeSourceIndex",this._allIndex)},_setEnableSourcesMenuAttr:function(b){this._set("enableSourcesMenu",b);this._created&&this._insertSources(this.sources)},_setEnableSearchingAllAttr:function(b){this._set("enableSearchingAll",b);this._created&&(this._setDefaultActiveSourceIndex(this.sources),this._hideMenus(),
this._insertSources(this.sources))},_setSourcesAttr:function(b){this._createSourceNameMap(b).then(g.hitch(this,function(l){this._sourceNames=l;this._created&&(this._setDefaultActiveSourceIndex(b),this._hideMenus(),this._insertSources(b))}));this._set("sources",b)},_setAllPlaceholderAttr:function(b){this._set("allPlaceholder",b);this._created&&this._setPlaceholder(this.activeSourceIndex)},_setActiveSourceIndexAttr:function(b){this._set("activeSourceIndex",b);this._updateActiveSource();this._created&&
(this._setPlaceholder(b),this._hideMenus(),this._insertSources(this.sources))},_setMaxLengthAttr:function(b){this._set("maxLength",b);this._created&&e.set(this.inputNode,"maxLength",b)},_setValueAttr:function(b){this.set("magicKey",null);this.set("selectedFeatureId",null);this._set("value",b);this._created&&(e.set(this.inputNode,"value",b),this._checkStatus())},_setVisibleAttr:function(b){this._set("visible",b);this._created&&this._updateVisible()},_setEnableButtonModeAttr:function(b){this._set("enableButtonMode",
b);this._created&&this._updateButtonMode(b)},_setThemeAttr:function(b){this._created&&(d.remove(this.domNode,this.theme),d.add(this.domNode,b));this._set("theme",b)}});k("extend-esri")&&g.setObject("dijit.Search",T,aa);return T})},"esri/tasks/locator":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/Deferred dojo/_base/json dojo/has ../kernel ../request ../deferredUtils ./Task ./AddressCandidate".split(" "),function(I,T,g,Q,O,M,H,F,t,k,A){I=I(k,{declaredClass:"esri.tasks.Locator",
_eventMap:{"address-to-locations-complete":["addresses"],"addresses-to-locations-complete":["addresses"],"location-to-address-complete":["address"],"suggest-locations-complete":["suggestions"]},constructor:function(m){this._geocodeHandler=T.hitch(this,this._geocodeHandler);this._geocodeAddressesHandler=T.hitch(this,this._geocodeAddressesHandler);this._reverseGeocodeHandler=T.hitch(this,this._reverseGeocodeHandler);this.registerConnectEvents()},outSpatialReference:null,setOutSpatialReference:function(m){this.outSpatialReference=
m},_geocodeHandler:function(m,e,d,r,y){try{var z=m.candidates;e=[];var h,v=z.length,L=m.spatialReference,J;for(h=0;h<v;h++){var U=z[h];if(J=U.location)J.spatialReference=L;e[h]=new A(U)}this._successHandler([e],"onAddressToLocationsComplete",d,y)}catch(S){this._errorHandler(S,r,y)}},_geocodeAddressesHandler:function(m,e,d,r,y){try{var z=m.locations;e=[];var h,v=z.length,L=m.spatialReference,J;for(h=0;h<v;h++){if(J=z[h].location)J.spatialReference=L;e[h]=new A(z[h])}this._successHandler([e],"onAddressesToLocationsComplete",
d,y)}catch(U){this._errorHandler(U,r,y)}},addressToLocations:function(m,e,d,r,y){var z;if(m.address){r=d;d=e;e=m.outFields;y=m.searchExtent;var h=m.countryCode;var v=m.magicKey;var L=m.distance;var J=m.categories;m.location&&this.normalization&&(z=m.location.normalize());var U=m.locationType;var S=m.maxLocations;var N=m.forStorage;m=m.address}y&&(y=y.shiftCentralMeridian());var D=this.outSpatialReference;m=this._encode(T.mixin({},this._url.query,m,{f:"json",outSR:D&&O.toJson(D.toJson()),outFields:e&&
e.join(",")||null,searchExtent:y&&O.toJson(y.toJson()),category:J&&J.join(",")||null,countryCode:h||null,magicKey:v||null,distance:L||null,location:z||null,locationType:U||null,maxLocations:S||null,forStorage:N||null}));var G=this._geocodeHandler,aa=this._errorHandler,ca=new Q(t._dfdCanceller);ca._pendingDfd=F({url:this._url.path+"/findAddressCandidates",content:m,callbackParamName:"callback",load:function(Z,ea){G(Z,ea,d,r,ca)},error:function(Z){aa(Z,r,ca)}});return ca},suggestLocations:function(m){var e=
new Q(t._dfdCanceller);m.hasOwnProperty("location")&&this.normalization&&(m.location=m.location.normalize());m.searchExtent&&(m.searchExtent=m.searchExtent.shiftCentralMeridian());m=this._encode(T.mixin({},this._url.query,{f:"json",text:m.text,maxSuggestions:m.maxSuggestions,searchExtent:m.searchExtent&&O.toJson(m.searchExtent.toJson()),category:m.categories&&m.categories.join(",")||null,countryCode:m.countryCode||null,location:m.location||null,distance:m.distance||null},{f:"json"}));m=F({url:this._url.path+
"/suggest",content:m,callbackParamName:"callback"});e._pendingDfd=m;m.then(T.hitch(this,function(d){d=d.suggestions||[];this.onSuggestLocationsComplete(d);e.resolve(d)}),T.hitch(this,function(d){this._errorHandler(d);e.reject(d)}));return e},addressesToLocations:function(m,e,d){var r=this.outSpatialReference,y=[],z=m.categories,h=m.locationType,v=m.countryCode;g.forEach(m.addresses,function(S,N){y.push({attributes:S})});m=this._encode(T.mixin({},this._url.query,{category:z&&z.join(",")||null,locationType:h||
null,sourceCountry:v||null},{addresses:O.toJson({records:y})},{f:"json",outSR:r&&O.toJson(r.toJson())}));var L=this._geocodeAddressesHandler,J=this._errorHandler,U=new Q(t._dfdCanceller);U._pendingDfd=F({url:this._url.path+"/geocodeAddresses",content:m,callbackParamName:"callback",load:function(S,N){L(S,N,e,d,U)},error:function(S){J(S,d,U)}});return U},_reverseGeocodeHandler:function(m,e,d,r,y){try{var z=new A({address:m.address,location:m.location,score:100});this._successHandler([z],"onLocationToAddressComplete",
d,y)}catch(h){this._errorHandler(h,r,y)}},locationToAddress:function(m,e,d,r){m&&this.normalization&&(m=m.normalize());var y=this.outSpatialReference;m=this._encode(T.mixin({},this._url.query,{outSR:y&&O.toJson(y.toJson()),location:m&&O.toJson(m.toJson()),distance:e,f:"json"}));var z=this._reverseGeocodeHandler,h=this._errorHandler,v=new Q(t._dfdCanceller);v._pendingDfd=F({url:this._url.path+"/reverseGeocode",content:m,callbackParamName:"callback",load:function(L,J){z(L,J,d,r,v)},error:function(L){h(L,
r,v)}});return v},onSuggestLocationsComplete:function(){},onAddressToLocationsComplete:function(){},onAddressesToLocationsComplete:function(){},onLocationToAddressComplete:function(){}});M("extend-esri")&&T.setObject("tasks.Locator",I,H);return I})},"esri/tasks/AddressCandidate":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel","../geometry/Point"],function(I,T,g,Q,O){I=I(null,{declaredClass:"esri.tasks.AddressCandidate",constructor:function(M){T.mixin(this,M);this.location=
new O(this.location)}});g("extend-esri")&&T.setObject("tasks.AddressCandidate",I,Q);return I})},"esri/styles/basic":function(){define(["dojo/_base/array","dojo/_base/lang","dojo/has","../kernel","../Color"],function(I,T,g,Q,O){function M(A,m){if(A){var e={};e.color=new O(A.color);e.opacity=A.opacity||1;switch(m){case "point":e.outline={color:new O(A.outline.color),width:A.outline.width};e.size=A.size;break;case "line":e.width=A.width;break;case "polygon":e.outline={color:new O(A.outline.color),width:A.outline.width}}}return e}
function H(A){if("esriGeometryPoint"===A||"esriGeometryMultipoint"===A)A="point";else if("esriGeometryPolyline"===A)A="line";else if("esriGeometryPolygon"===A||"esriGeometryMultiPatch"===A)A="polygon";return A}var F={"default":{name:"default",label:"Default",description:"Default theme for basic visualization of features.",basemapGroups:{light:"streets gray topo terrain national-geographic oceans osm gray-vector streets-vector topo-vector streets-relief-vector streets-navigation-vector".split(" "),
dark:["satellite","hybrid","dark-gray","dark-gray-vector","streets-night-vector"]},pointSchemes:{light:{primary:{color:[77,77,77,1],outline:{color:[255,255,255,.25],width:1},size:8},secondary:[{color:[226,119,40,1],outline:{color:[255,255,255,.25],width:1},size:8},{color:[255,255,255,1],outline:{color:[51,51,51,.25],width:1},size:8}]},dark:{primary:{color:[255,255,255,1],outline:{color:[92,92,92,.25],width:1},size:8},secondary:[{color:[226,119,40,1],outline:{color:[255,255,255,.25],width:1},size:8},
{color:[26,26,26,1],outline:{color:[178,178,178,.25],width:1},size:8}]}},lineSchemes:{light:{primary:{color:[77,77,77,1],width:2},secondary:[{color:[226,119,40,1],width:2},{color:[255,255,255,1],width:2}]},dark:{primary:{color:[255,255,255,1],width:2},secondary:[{color:[226,119,40,1],width:2},{color:[26,26,26,1],width:2}]}},polygonSchemes:{light:{primary:{color:[227,139,79,1],outline:{color:[255,255,255,.25],width:1},opacity:.8},secondary:[{color:[128,128,128,1],outline:{color:[255,255,255,.25],width:1},
opacity:.8},{color:[255,255,255,1],outline:{color:[128,128,128,.25],width:1},opacity:.8}]},dark:{primary:{color:[227,139,79,1],outline:{color:[92,92,92,.25],width:1},opacity:.8},secondary:[{color:[178,178,178,1],outline:{color:[92,92,92,.25],width:1},opacity:.8},{color:[26,26,26,1],outline:{color:[128,128,128,.25],width:1},opacity:.8}]}}}},t={};(function(){var A,m,e;for(A in F){var d=F[A];var r=d.basemapGroups;var y=t[A]={basemaps:[].concat(r.light).concat(r.dark),point:{},line:{},polygon:{}};for(m in r){var z=
r[m];for(e=0;e<z.length;e++){var h=z[e];d.pointSchemes&&(y.point[h]=d.pointSchemes[m]);d.lineSchemes&&(y.line[h]=d.lineSchemes[m]);d.polygonSchemes&&(y.polygon[h]=d.polygonSchemes[m])}}}})();var k={getAvailableThemes:function(A){var m=[],e;for(e in F){var d=F[e];var r=t[e];A&&-1===I.indexOf(r.basemaps,A)||m.push({name:d.name,label:d.label,description:d.description,basemaps:r.basemaps.slice(0)})}return m},getSchemes:function(A){var m=A.theme,e=A.basemap,d=H(A.geometryType);A=t[m];var r;(A=(A=A&&A[d])&&
A[e])&&(r={primaryScheme:M(A.primary,d),secondarySchemes:I.map(A.secondary,function(y){return M(y,d)})});return r},cloneScheme:function(A){if(A){var m=T.mixin({},A);m.color&&(m.color=new O(m.color));m.outline&&(m.outline={color:m.outline.color&&new O(m.outline.color),width:m.outline.width})}return m}};g("extend-esri")&&T.setObject("styles.basic",k,Q);return k})},"widgets/DistrictLookup/searchSourceUtils":function(){define("dojo/_base/lang dojo/_base/array dojo/Deferred dojo/when dojo/promise/all jimu/portalUtils esri/lang esri/request".split(" "),
function(I,T,g,Q,O,M,H,F){return{map:null,layerInfosObj:null,appConfig:null,_esriLocatorRegExp:/geocode(.){0,3}\.arcgis.com\/arcgis\/rest\/services\/World\/GeocodeServer/g,setMap:function(t){this.map=t},setLayerInfosObj:function(t){this.layerInfosObj=t},setAppConfig:function(t){this.appConfig=t},getConfigInfo:function(t){if(t&&t.sources&&0<t.sources.length){var k=null;return this.searchLayer(this.map)&&t.upgradeFromGeocoder?(k=this.map.itemInfo.itemData.applicationProperties.viewing.search,k=T.map(k.layers,
I.hitch(this,function(A,m){m.hintText=A;return this._getQueryTypeGeocoder(m)},k.hintText)),O(k).then(I.hitch(this,function(A){t.sources=[].concat(A).concat(t.sources);return t}))):t}return Q(this._getSoucesFromPortalAndWebmap()).then(I.hitch(this,function(A){return{allPlaceholder:"",showInfoWindowOnSelect:!0,sources:A}}))},_getSoucesFromPortalAndWebmap:function(){var t=[],k=null;this.searchLayer(this.map)&&(k=this.map.itemInfo.itemData.applicationProperties.viewing.search,T.forEach(k.layers,I.hitch(this,
function(A,m){m.hintText=A;t.push(this._getQueryTypeGeocoder(m))},k.hintText)));return M.getPortalSelfInfo(this.appConfig.portalUrl).then(I.hitch(this,function(A){if((A=A.helperServices&&A.helperServices.geocode)&&0<A.length)for(var m=0,e=A.length;m<e;m++){var d=A[m];d&&t.push(this._processSingleLine(d))}return O(t).then(I.hitch(this,function(r){for(var y=[],z=0;z<r.length;z++){var h=r[z];h&&(h&&"query"===h.type?y.push(h):(h={name:h.name||this._getGeocodeName(h.url),url:h.url,singleLineFieldName:h.singleLineFieldName,
placeholder:h.placeholder||window.jimuNls.common.findAddressOrPlace||h.name||this._getGeocodeName(h.url),maxResults:6,searchInCurrentMapExtent:!1,type:"locator"},h.enableLocalSearch=this._isEsriLocator(h.url),h.localSearchMinScale=3E5,h.localSearchDistance=5E4,y.push(h)))}return y}))}))},_getQueryTypeGeocoder:function(t){var k=this.map.getLayer(t.id),A=null,m=null,e=null;e=H.isDefined(t.subLayer)?t.id+"_"+t.subLayer:t.id;A=this.layerInfosObj.traversal(function(d){return d.id===e?(m=d,!0):!1});return k&&
A&&m?(A=H.isDefined(t.subLayer)?m.url||k.url+"/"+t.subLayer:m.url||k.url,{name:m.title,layerId:e,url:A,placeholder:t.hintText||window.jimuNls.common.findAddressOrPlace,searchFields:[t.field.name],displayField:t.field.name,exactMatch:t.field.exactMatch||!1,maxResults:6,searchInCurrentMapExtent:!1,type:"query"}):null},_isEsriLocator:function(t){this._esriLocatorRegExp.lastIndex=0;return this._esriLocatorRegExp.test(t)},_processSingleLine:function(t){if(t.singleLineFieldName)return t;if(this._isEsriLocator(t.url))return t.singleLineFieldName=
"SingleLine",t;var k=new g;F({url:t.url,content:{f:"json"},handleAs:"json",callbackParamName:"callback"}).then(I.hitch(this,function(A){A.singleLineAddressField&&A.singleLineAddressField.name?(t.singleLineFieldName=A.singleLineAddressField.name,k.resolve(t)):(console.warn(t.url+"has no singleLineFieldName"),k.resolve(null))}),I.hitch(this,function(A){console.error(A);k.resolve(null)}));return k.promise},_getGeocodeName:function(t){if("string"!==typeof t)return"geocoder";t=t.split("/");return t[t.length-
2]||"geocoder"},getGeocoderName:function(t){return this._getGeocodeName(t)},hasAppSearchInfo:function(t){return t.itemInfo&&t.itemInfo.itemData&&t.itemInfo.itemData.applicationProperties&&t.itemInfo.itemData.applicationProperties.viewing&&t.itemInfo.itemData.applicationProperties.viewing.search},searchLayer:function(t){if(!this.hasAppSearchInfo(t))return!1;t=t.itemInfo.itemData.applicationProperties.viewing.search;return t.enabled&&0!==t.layers.length?!0:!1}}})},"esri/dijit/Directions":function(){define("require dojo/_base/declare dojo/_base/lang dojo/_base/kernel dojo/_base/array dojo/_base/Color dijit/a11yclick dijit/_TemplatedMixin dijit/form/Select dijit/form/ValidationTextBox dijit/form/DateTextBox dijit/form/TimeTextBox dojo/store/Memory dojo/data/ObjectStore dojo/keys dojo/has dojo/on dojo/mouse dojo/dom dojo/dom-geometry dojo/dom-style dojo/dom-class dojo/dom-attr dojo/query dojo/number dojo/i18n!../nls/jsapi dojo/text!./templates/Directions.html ./Search dojo/dom-construct dojo/promise/all dojo/Deferred dojo/dnd/Source dojo/json ../kernel ../urlUtils ../graphic ../units ../TimeExtent ../InfoTemplate ../SpatialReference ../layers/ArcGISDynamicMapServiceLayer ../layers/GraphicsLayer ../geometry/webMercatorUtils ../geometry/geodesicUtils ../arcgis/utils ../geometry/Point ../geometry/Extent ../geometry/Polyline ../geometry/mathUtils ../symbols/SimpleMarkerSymbol ../symbols/PictureMarkerSymbol ../symbols/CartographicLineSymbol ../symbols/TextSymbol ../renderers/UniqueValueRenderer ../symbols/Font ./_EventedWidget ../tasks/FeatureSet ../tasks/RouteTask ../tasks/RouteParameters ../tasks/GeometryService ../tasks/DistanceParameters ../tasks/PrintTask ../tasks/PrintParameters ../tasks/PrintTemplate ../toolbars/edit ../toolbars/draw ../config ../tasks/ProjectParameters dojo/uacss".split(" "),
function(I,T,g,Q,O,M,H,F,t,k,A,m,e,d,r,y,z,h,v,L,J,U,S,N,D,G,aa,ca,Z,ea,C,da,Y,w,n,u,W,ja,ba,ka,sa,qa,ya,ra,Ea,b,l,B,E,P,fa,la,va,oa,ta,pa,Aa,Qa,Ma,Ba,Oa,Sa,Va,fb,Ya,Za,gb,$a){var Ta=n.getProtocolForWebResource(),ab=ca.createSubclass({_setSourcesAttr:function(a){a&&(a=a.map(function(c){c.locator&&null==c.locationType&&(c=g.mixin({locationType:"street"},c));return c}));this.inherited(arguments,[a])}});T=T("esri.dijit.Directions",[pa,F],{templateString:aa,mapClickActive:!1,barrierToolActive:!1,_eventMap:{activate:!0,
deactivate:!1,load:!0,"directions-start":!0,"directions-finish":["result"],"directions-clear":!0,"segment-select":["graphic"],"segment-highlight":["graphic"],error:["error"],"stops-update":["stops"],"route-item-created":!0,"route-item-updated":!0,"feature-collection-created":!0},_emptyStop:{name:""},constructor:function(a,c){if(!a.map)throw Error('Required "map" parameter is missing. Cannot instantiate Directions Widget.');if(!c)throw Error('Required "srcNodeRef" parameter is missing. Cannot instantiate Directions Widget.');
this._i18n=G;this._css={widgetContainerClass:"esriDirectionsContainer",searchSourceContainerClass:"esriSearchSourceContainer",stopsContainerClass:"esriStopsContainer",stopsTableContainerClass:"esriStopsTableContainer",stopsTableCoverClass:"esriStopsTableCover",reverseStopsClass:"esriStopsReverse",addStopsClass:"esriStopsAdd",stopsClass:"esriStops",stopsRemovableClass:"esriStopsRemovable",stopsButtonContainerClass:"esriStopsButtons",stopsOptionsButtonClass:"esriStopsOptionsButton",stopsAddDestinationClass:"esriStopsAddDestination",
stopsAddDestinationBtnClass:"esriStopsAddDestinationBtn",stopsGetDirectionsContainerClass:"esriStopsGetDirectionsContainer",stopsGetDirectionsClass:"esriStopsGetDirections",stopsClearDirectionsClass:"esriStopsClearDirections",stopsInnerGeocoderClass:"esriInnerGeocoder",stopsOptionsOptionsEnabledClass:"esriStopsOptionsEnabled",stopsOptionsMenuClass:"esriStopsOptionsMenu",stopsFindOptimalOrderClass:"esriFindOptimalOrderOption",stopsUseTrafficClass:"esriUseTrafficOption",stopsReturnToStartClass:"esriReturnToStartOption",
stopsOptionsCheckboxesClass:"esriOptionsCheckboxes",stopsOptionsToggleContainerClass:"esriOptionsToggleContainer",stopsOptionsUnitsContainerClass:"esriOptionsUnitsContainer",stopsOptionsUnitsMiClass:"esriOptionsUnitsMi",stopsOptionsUnitsKmClass:"esriOptionsUnitsKm",stopsOptionsImpedanceContainerClass:"esriOptionsImpedanceContainer",stopsOptionsImpedanceTimeClass:"esriOptionsImpedanceTime",stopsOptionsImpedanceDistanceClass:"esriOptionsImpedanceDistance",stopClass:"esriStop",stopOriginClass:"esriStopOrigin",
stopDestinationClass:"esriStopDestination",stopUnreachedFirstOrLastClass:"esriStopUnreachedFirstOrLast",stopUnreachedClass:"esriStopUnreached",esriStopGeocoderColumnClass:"esriStopGeocoderColumn",esriStopReverseColumnClass:"esriStopReverseColumn",stopDnDHandleClass:"esriStopDnDHandle",stopDnDHandleClassHidden:"esriStopDnDHandleHidden",stopIconColumnClass:"esriStopIconColumn",stopIconClass:"esriStopIcon",stopIconRemoveColumnClass:"esriStopIconRemoveColumn",stopIconRemoveClass:"esriStopIconRemove",
stopIconRemoveClassHidden:"esriStopIconRemoveHidden",resultsContainerClass:"esriResultsContainer",resultsLoadingClass:"esriResultsLoading",resultsPrintClass:"esriResultsPrint",resultsSaveClass:"esriResultsSave",resultsSummaryClass:"esriResultsSummary",routesContainerClass:"esriRoutesContainer",routesClass:"esriRoutes",routesErrorClass:"esriRoutesError",routesInfoClass:"esriRoutesInfo",routeClass:"esriRoute",routeTextColumnClass:"esriRouteTextColumn",routeTextClass:"esriRouteText",routeLengthClass:"esriRouteLength",
routeOriginClass:"esriDMTStopOrigin",routeDestinationClass:"esriDMTStopDestination",routeInfoClass:"esriRouteInfo",routeIconColumnClass:"esriRouteIconColumn",routeIconClass:"esriRouteIcon",infoWindowRouteClass:"esriInfoWindowRoute",routeZoomClass:"esriRouteZoom",esriPrintPageClass:"esriPrintPage",esriPrintBarClass:"esriPrintBar",esriPrintButtonClass:"esriPrintButton",esriCloseButtonClass:"esriCloseButton",esriPrintMainClass:"esriPrintMain",esriPrintHeaderClass:"esriPrintHeader",esriPrintLogoClass:"esriPrintLogo",
esriPrintMapClass:"esriPrintMap",esriPrintNameClass:"esriPrintName",esriPrintNotesClass:"esriPrintNotes",esriPrintLengthClass:"esriPrintLength",esriPrintDirectionsClass:"esriPrintDirections",esriPrintFooterClass:"esriPrintFooter",esriPrintStopLabelClass:"esriPrintStopLabel",clearClass:"esriClear",dndDragBodyClass:"esriDndDragDirection",stopsButtonClass:"esriDirectionsButton",stopsButtonTabClass:"esriDirectionsTabButton",stopsButtonTabLastClass:"esriDirectionsTabLastButton",stopsPressedButtonClass:"esriDirectionsPressedButton",
linkButtonClass:"esriLinkButton",activateButtonClass:"esriActivateButton",lineBarrierButtonClass:"esriLineBarrierButton",travelModesContainerClass:"esriTravelModesContainer"};this.options={map:null,autoSolve:!0,minStops:2,maxStops:20,theme:"simpleDirections",alphabet:"1234567890",directions:null,returnToStart:!1,optimalRoute:!1,routeTaskUrl:Ta+"//route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",printTaskUrl:Ta+"//utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task",
geometryTaskUrl:Ta+"//utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",routeParams:{},stops:["",""],searchOptions:{},stopsInfoTemplate:new ba(G.widgets.directions.stop,"${address}${error}"),waypointInfoTemplate:new ba(G.widgets.directions.maneuver,G.widgets.directions.waypoint),segmentInfoTemplate:new ba(G.widgets.directions.maneuver,'\x3cdiv class\x3d"${maneuverType}"\x3e\x3cdiv class\x3d"'+this._css.routeIconClass+" "+this._css.infoWindowRouteClass+'"\x3e\x3cstrong\x3e${step}.\x3c/strong\x3e ${formattedText}\x3c/div\x3e\x3c/div\x3e'),
textSymbolFont:new ta("11px",ta.STYLE_NORMAL,ta.VARIANT_NORMAL,ta.WEIGHT_NORMAL,"Arial, Helvetica, sans-serif"),textSymbolColor:new M([255,255,255]),textSymbolOffset:{x:0,y:10.875},fromSymbol:(new fa({url:I.toUrl("./images/Directions/greenPoint.png"),height:21.75,width:15.75,type:"esriPMS"})).setOffset(0,10.875),fromSymbolDrag:(new fa({url:I.toUrl("./images/Directions/greenPointMove.png"),height:21.75,width:15.75,type:"esriPMS"})).setOffset(0,10.875),stopSymbol:(new fa({url:I.toUrl("./images/Directions/bluePoint.png"),
height:21.75,width:15.75,type:"esriPMS"})).setOffset(0,10.875),stopSymbolDrag:(new fa({url:I.toUrl("./images/Directions/bluePointMove.png"),height:21.75,width:15.75,type:"esriPMS"})).setOffset(0,10.875),toSymbol:(new fa({url:I.toUrl("./images/Directions/redPoint.png"),height:21.75,width:15.75,type:"esriPMS"})).setOffset(0,10.875),toSymbolDrag:(new fa({url:I.toUrl("./images/Directions/redPointMove.png"),height:21.75,width:15.75,type:"esriPMS"})).setOffset(0,10.875),unreachedSymbol:(new fa({url:I.toUrl("./images/Directions/grayPoint.png"),
height:21.75,width:15.75,type:"esriPMS"})).setOffset(0,10.875),unreachedSymbolDrag:(new fa({url:I.toUrl("./images/Directions/grayPointMove.png"),height:21.75,width:15.75,type:"esriPMS"})).setOffset(0,10.875),waypointSymbol:new P({color:[255,255,255,255],size:10,type:"esriSMS",style:"esriSMSCircle",outline:{color:[20,89,127,255],width:2.5,type:"esriSLS",style:"esriSLSSolid"}}),maneuverSymbol:new P({color:[255,255,255,255],size:4,type:"esriSMS",style:"esriSMSCircle",outline:{color:[30,99,137,255],width:1,
type:"esriSLS",style:"esriSLSSolid"}}),routeSymbol:(new la).setColor(new M([20,89,127,.75])).setWidth(10).setCap(la.CAP_ROUND).setJoin(la.JOIN_ROUND),segmentSymbol:(new la).setColor(new M([255,255,255,1])).setWidth(6).setCap(la.CAP_ROUND).setJoin(la.JOIN_ROUND),barrierRenderer:new oa({type:"uniqueValue",field1:"BarrierType",defaultSymbol:{type:"esriPMS",imageData:"PHN2ZyB3aWR0aD0iMjIyIiBoZWlnaHQ9IjIyMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGc+CjxlbGxpcHNlIGZpbGw9IiNmZjAwMDAiIHN0cm9rZT0iIzAwMCIgc3Ryb2tlLXdpZHRoPSIyMCIgY3g9IjExMiIgY3k9IjExMSIgaWQ9InN2Z181IiByeD0iMTAwIiByeT0iMTAwIi8+CjxlbGxpcHNlIGZpbGw9IiNmZjAwMDAiIHN0cm9rZT0iI2ZmZmZmZiIgc3Ryb2tlLXdpZHRoPSIyMCIgY3g9IjExMiIgY3k9IjExMSIgaWQ9InN2Z182IiByeD0iOTUiIHJ5PSI5NSIvPgo8cmVjdCBmaWxsPSIjZmYwMDAwIiBzdHJva2Utd2lkdGg9IjIwIiB4PSI2NC41IiB5PSIxMDIiIHdpZHRoPSI5NSIgaGVpZ2h0PSIxOCIgaWQ9InN2Z183IiBzdHJva2U9IiNmZmZmZmYiLz4KPC9nPgo8L3N2Zz4\x3d",
contentType:"image/svg+xml",width:18,height:18},uniqueValueInfos:[{value:"2",symbol:{type:"esriPMS",imageData:"PHN2ZyB3aWR0aD0iMjg2IiBoZWlnaHQ9IjI1NiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGc+CjxwYXRoIGZpbGw9IiNmZmYiIHN0cm9rZS13aWR0aD0iMTAiIGQ9Im04Ljc0OTk5MiwyNTEuNzQ5OTk3bDEzNC45OTk5OTgsLTI0MS45OTk5OThsMTM0Ljk5OTk5OCwyNDEuOTk5OTk4bC0yNjkuOTk5OTk1LDBsLTAuMDAwMDAxLDB6IiBpZD0ic3ZnXzEiIHN0cm9rZT0iIzAwMCIvPgo8cGF0aCBzdHJva2U9IiNmZmYiIGZpbGw9IiNmZjAwMDAiIHN0cm9rZS13aWR0aD0iMTUiIGQ9Im0yMy41MDAwMDQsMjQyLjUwMDAwNWwxMTkuOTk5OTkyLC0yMTUuOTk5OTk5bDExOS45OTk5OTIsMjE1Ljk5OTk5OWwtMjM5Ljk5OTk4MywwbC0wLjAwMDAwMSwweiIgaWQ9InN2Z18yIi8+Cjx0ZXh0IGZvbnQtd2VpZ2h0PSJib2xkIiBmaWxsPSIjZmZmZmZmIiBzdHJva2U9IiNmZjAwMDAiIHN0cm9rZS13aWR0aD0iMCIgeD0iMTA5IiB5PSIyMjIuNzUiIGlkPSJzdmdfNSIgZm9udC1zaXplPSIxODAiIGZvbnQtZmFtaWx5PSJHZW9yZ2lhLCBUaW1lcywgJ1RpbWVzIE5ldyBSb21hbicsIHNlcmlmIiB0ZXh0LWFuY2hvcj0ic3RhcnQiIHhtbDpzcGFjZT0icHJlc2VydmUiPiE8L3RleHQ+CjwvZz4KPC9zdmc+",
contentType:"image/svg+xml",width:19,height:18}}]}),polylineBarrierRenderer:new oa({type:"uniqueValue",field1:"BarrierType",defaultSymbol:{color:[255,0,0,184],width:7.5,type:"esriSLS",style:"esriSLSSolid"},uniqueValueInfos:[{value:"1",symbol:{color:[255,85,0,184],width:7.5,type:"esriSLS",style:"esriSLSSolid"}}]}),polygonBarrierRenderer:new oa({type:"uniqueValue",field1:"BarrierType",defaultSymbol:{color:[255,0,0,156],outline:{color:[255,0,0,153],width:2.4,type:"esriSLS",style:"esriSLSSolid"},type:"esriSFS",
style:"esriSFSSolid"},uniqueValueInfos:[{value:"1",symbol:{color:[255,170,0,156],outline:{color:[255,0,0,153],width:7.5,type:"esriSLS",style:"esriSLSSolid"},type:"esriSFS",style:"esriSFSSolid"}}]}),printPage:"",printTemplate:"",focusOnNewStop:!0,dragging:!0,canModifyStops:!0,canModifyWaypoints:!0,directionsLengthUnits:null,directionsLanguage:null,traffic:!1,trafficLayer:null,showPrintPage:!0,showSaveButton:!1,showSegmentPopup:!1,showSegmentHighlight:!0,showReverseStopsButton:!0,showReturnToStartOption:!0,
showOptimalRouteOption:!0,showTravelModesOption:!0,showMilesKilometersOption:!0,showClearButton:!1,showActivateButton:!0,showBarriersButton:!0,loaded:!1,routeLayer:{itemId:null,title:null,isItemOwner:!0,ownerFolder:null},startTime:"now"};this.userOptions=a;this.defaults=g.mixin({},this.options,a,{_waypointName:"DWWP",_userDefinedStopName:"UserDefinedStopName",_solveInProgress:!1,_moveInProgress:!1,_stopSequence:1E3});if(!this.defaults.minStops||2>this.defaults.minStops)this.defaults.minStops=2;if(2<
this.defaults.minStops&&this.defaults.stops&&","===this.defaults.stops.toString())for(a=2;a<this.defaults.minStops;a++)this.defaults.stops.splice(0,0,"");this.domNode=c},postCreate:function(){this.inherited(arguments);this.own(z(this._activateButtonNode,H,g.hitch(this,function(){this.mapClickActive?this.deactivate():this.activate()})));this.own(z(this._lineBarrierButtonNode,H,g.hitch(this,function(){this.barrierToolActive?this.deactivateBarrierTool():this.activateBarrierTool()})));this.own(z(this._addDestinationNode,
H,g.hitch(this,this._addStopButton)));this.own(z(this._optionsButtonNode,H,g.hitch(this,this._toggleOptionsMenu)));this.own(z(this._saveMenuButton,H,g.hitch(this,this._toggleSaveMenu)));this.own(z(this._saveButton,H,g.hitch(this,function(){this._saveButton._enabled&&this._storeRouteUI()})));this.own(z(this._saveAsButton,H,g.hitch(this,function(){g.mixin(this.routeLayer,{itemId:null,title:null,ownerFolder:null});this._storeRouteUI()})));this.own(z(this._findOptimalOrderNode,H,g.hitch(this,this._toggleCheckbox)));
this.own(z(this._returnToStartNode,H,g.hitch(this,this._toggleCheckbox)));this.own(z(this._useTrafficNode,H,g.hitch(this,this._toggleCheckbox)));this.own(z(this._useMilesNode,H,g.hitch(this,this._toggleUnits)));this.own(z(this._useKilometersNode,H,g.hitch(this,this._toggleUnits)));this.own(z(this._getDirectionsButtonNode,H,g.hitch(this,this.getDirections)));this.own(z(this._clearDirectionsButtonNode,H,g.hitch(this,function(){this.clearDirections()})));var a=g.hitch(this,function(){clearTimeout(this._startTimeMenu._hideTimer);
this._startTimeMenu._hideTimer=setTimeout(g.hitch(this,function(){J.set(this._startTimeMenu,"display","none")}),100)});this.own(z(this._startTimeButtonNode,H,g.hitch(this,function(){this._startTimeButtonNode.disabled||"block"===J.get(this._startTimeMenu,"display")?J.set(this._startTimeMenu,"display","none"):(J.set(this._startTimeMenu,"display","block"),this["now"===this.startTime?"_startTimeMenuLeaveNow":"none"===this.startTime?"_startTimeMenuNone":"_startTimeMenuDepartAt"].focus())})));this.own(z(this._startTimeMenuLeaveNow,
"blur",a));this.own(z(this._startTimeMenuDepartAt,"blur",a));this.own(z(this._startTimeMenuNone,"blur",a));this.own(z(this._startTimeMenuLeaveNow,"mousedown",g.hitch(this,function(){this.startTime="now";this._updateStartTimeUI();this._clearDisplayBeforeSolve()})));this.own(z(this._startTimeMenuDepartAt,"mousedown",g.hitch(this,function(){this.startTime=(new Date).getTime();this._updateStartTimeUI();this._clearDisplayBeforeSolve()})));this.own(z(this._startTimeMenuNone,"mousedown",g.hitch(this,function(){this.startTime=
"none";this._updateStartTimeUI();this._clearDisplayBeforeSolve()})));this._symbolEventPaddingDirections=(new la).setColor(new M([0,255,0,0])).setWidth(20).setCap(la.CAP_ROUND);this._stopLayer=new qa({id:"directions_stopLayer_"+this.id,displayOnPan:!0});this._routeLayer=new qa({id:"directions_routeLayer_"+this.id,displayOnPan:!0});this._waypointsEventLayer=new qa({id:"directions_waypointsEventLayer_"+this.id,displayOnPan:!0});this._barriersLayer=new qa({id:"directions_barriersLayer_"+this.id,displayOnPan:!0});
this._polylineBarriersLayer=new qa({id:"directions_polylineBarriersLayer_"+this.id,displayOnPan:!0});this._polygonBarriersLayer=new qa({id:"directions_polygonBarriersLayer_"+this.id,displayOnPan:!0});this._barriersLayer.setRenderer(this.defaults.barrierRenderer);this._polylineBarriersLayer.setRenderer(this.defaults.polylineBarrierRenderer);this._polygonBarriersLayer.setRenderer(this.defaults.polygonBarrierRenderer);this.map&&(this.map.addLayer(this._routeLayer),this.map.addLayer(this._polygonBarriersLayer),
this.map.addLayer(this._polylineBarriersLayer),this.map.addLayer(this._barriersLayer),this.map.addLayer(this._stopLayer),this._externalTimeExtent=this.map.timeExtent);this._snappingManager=this.map.enableSnapping({layerInfos:[{layer:this._waypointsEventLayer,snapToVertex:!1,snapToPoint:!0,snapToEdge:!0}],tolerance:15});this._setWidgetProperties();var c=new u(null,this.waypointSymbol,{});a=g.hitch(this,function(){this._moveInProgress||this._solveInProgress||!c._isShown()||(this.editToolbar.deactivate(),
this._stopLayer.remove(c),clearTimeout(c._solveTimeout),c._solveTimeout=null,c.attributes.isWaypoint=!0,c._isStopIcon&&this.stopGraphics[c._index]&&(this._stopLayer.add(this.stopGraphics[c._index]),this._stopLayer.add(this.textGraphics[c._index])));c._showTooltip()});this._handle=g.mixin(c,{_isHandle:!0,_tooltip:Z.create("div",{className:this.theme+" esriDirectionsRouteTooltip",onmouseover:a},this.map.container),_showTooltip:g.hitch(this,function(f){c._tooltip.style.display=!f||f instanceof MouseEvent?
"none":"inline";f&&(f="string"===typeof f?f:"\x3ctable class\x3d'esriRoutesTooltip'\x3e"+this._renderDirectionsItemTR(f)+"\x3c/table\x3e",c._tooltip.innerHTML!==f&&(c._tooltip.innerHTML=f))}),_isShown:g.hitch(this,function(){return-1<O.indexOf(this._stopLayer.graphics,c)}),_remove:a});this._activate(this.mapClickActive)},startup:function(){this.inherited(arguments);return this._enqueue(this._init)},destroy:function(){this.deactivate();this.map.removeLayer(this._barriersLayer);this.map.removeLayer(this._polylineBarriersLayer);
this.map.removeLayer(this._polygonBarriersLayer);this.map.removeLayer(this._routeLayer);this.map.removeLayer(this._stopLayer);this.map.removeLayer(this._waypointsEventLayer);this._disconnectEvents();Z.empty(this.domNode);this.inherited(arguments)},activate:function(){return this._enqueue(function(){this.deactivateBarrierTool().then(g.hitch(this,function(){this.set("mapClickActive",!0)}))})},deactivate:function(){return this._enqueue(function(){this.deactivateBarrierTool().then(g.hitch(this,function(){this.set("mapClickActive",
!1)}))})},activateBarrierTool:function(){return this._enqueue(function(){this.set("mapClickActive",!1);this.set("barrierToolActive",!0)})},deactivateBarrierTool:function(){return this._enqueue(function(){this.set("mapClickActive",!1);this.set("barrierToolActive",!1)})},clearDirections:function(){return this._enqueue(function(){this.clearMessages();return this._clearDirections()})},reset:function(){return this._enqueue(this._reset)},modifyStopSequence:function(a,c){return this._enqueue(function(){return this._modifyStopSequence(a,
c)})},onActivate:function(){},onDeactivate:function(){},onActivateBarrierTool:function(){},onDeactivateBarrierTool:function(){},onLoad:function(){this._enableButton(this._getDirectionsButtonNode)},onDirectionsStart:function(){this._clearDisplayBeforeSolve();this.set("solving",!0);this._showLoadingSpinner(!0)},onDirectionsFinish:function(){this._showLoadingSpinner(!1);this.set("solving",!1)},onDirectionsClear:function(){},onSegmentSelect:function(){},onSegmentHighlight:function(){},onStopsUpdate:function(){},
onRouteItemCreated:function(){},onRouteItemUpdated:function(){},onFeatureCollectionCreated:function(){},onError:function(){},removeStops:function(){return this.reset()},removeStop:function(a,c,f){return this._enqueue(function(){this.clearMessages();return this._removeStop(a,c,f)})},updateStops:function(a){return this._enqueue(function(){return this._updateStops(a)})},addStops:function(a,c){return this._enqueue(function(){return this._addStops(a,c)}).then(g.hitch(this,this.zoomToFullRoute))},addStop:function(a,
c){return this._enqueue(function(){return this._addStop(a,c)},{_incrementalSolveStopRange:this._incrementalSolveStopRange})},updateStop:function(a,c,f){return this._enqueue(function(){return this._updateStop(a,c,f)},{_incrementalSolveStopRange:this._incrementalSolveStopRange})},setBarriers:function(a){this.routeParams.barriers=a;return this._getDirections().then(g.hitch(this,function(){this.zoomToFullRoute()}))},setPolylineBarriers:function(a){this.routeParams.polylineBarriers=a;return this._getDirections().then(g.hitch(this,
function(){this.zoomToFullRoute()}))},setPolygonBarriers:function(a){this.routeParams.polygonBarriers=a;return this._getDirections().then(g.hitch(this,function(){this.zoomToFullRoute()}))},clearMessages:function(){this.messages=[];this._msgNode&&(this._msgNode.innerHTML="")},getDirections:function(a){return this._enqueue(function(){return this._getDirections().then(g.hitch(this,function(){!0!==a&&this.zoomToFullRoute()}))})},selectSegment:function(a){if(!(!this.directions||!this.directions.features||
0>a||a>=this.directions.features.length))for(var c=N("[data-segment]",this._resultsNode),f=0;f<c.length;f++){var x=parseInt(S.get(c[f],"data-segment"),10);if(a===x&&c[f]!==this._focusedDirectionsItem){this._focusedDirectionsItem=c[f];this.centerAtSegmentStart(a);this.onSegmentSelect(this.directions.features[a]);c[f].focus();break}}},unhighlightSegment:function(a){var c=this._segmentGraphics;if(c&&(!this._focusedDirectionsItem||a)){for(a=0;a<c.length;a++)this._routeLayer.remove(c[a]);this._segmentGraphics=
[]}},highlightSegment:function(a,c){if(!(this._focusedDirectionsItem&&!c||a>=this.directions.features.length)){a=a||0;var f=g.hitch(this,function(wa){var ua=this.map.toMap({x:0,y:0});return this.map.toScreen(ua.offset(wa,0)).x}),x=g.hitch(this,function(wa){for(var ua=0,Ca=0;Ca<wa.length;Ca++)for(var Ha=1;Ha<wa[Ca].length;Ha++){var Pa=wa[Ca][Ha-1],Ja=wa[Ca][Ha];ua+=f(Math.sqrt((Pa[0]-Ja[0])*(Pa[0]-Ja[0])+(Pa[1]-Ja[1])*(Pa[1]-Ja[1])))}return ua}),q=g.hitch(this,function(wa){var ua=this.map.toMap({x:0,
y:0});return this.map.toMap({x:wa,y:0}).x-ua.x}),K=function(wa,ua,Ca){ua=Math.max(1,ua);for(var Ha=Ca?wa[0].length-1:0,Pa=0,Ja,Ia,Ga,za=[[wa[0][Ca?Ha:0]]];Ca&&0<Ha||!Ca&&Ha<wa[0].length-1;){Ia=wa[0][Ca?Ha-1:Ha];Ga=wa[0][Ca?Ha:Ha+1];if(Ja=f(Math.sqrt((Ia[0]-Ga[0])*(Ia[0]-Ga[0])+(Ia[1]-Ga[1])*(Ia[1]-Ga[1]))))if(Pa+Ja<ua)Ca?za[0].splice(0,0,Ia):za[0].push(Ga),Pa+=Ja;else{ua=(ua-Pa)/Ja;Ca?za[0].splice(0,0,[Ga[0]-(Ga[0]-Ia[0])*ua,Ga[1]-(Ga[1]-Ia[1])*ua]):za[0].push([Ia[0]+(Ga[0]-Ia[0])*ua,Ia[1]+(Ga[1]-
Ia[1])*ua]);break}Ha+=Ca?-1:1}return 0<Pa+Ja?za:wa};c=this.get("directions").features[a];var R=new B(c.geometry),V=40*Math.PI/180;g.mixin(c.attributes,{_index:a});if(a){var X=K(this.get("directions").features[a-1].geometry.paths,25,!0),ha="esriDMTStop"!==c.attributes.maneuverType?K(R.paths,25,!1):X;X=ha!==X?[X[0].concat(ha[0])]:ha;var ia=(new B(ha)).getExtent();if(1<ha[0].length&&15<=f(Math.max(ia.getWidth(),ia.getHeight()))){K=15*Math.cos(V/2);x=15*Math.sin(V/2);var ma=ha[0].length-2;V=ha[0][ma+
1];for(ia=0;0<=ma&&!ia;){var na=ha[0][ma];ia=f(Math.sqrt((na[0]-V[0])*(na[0]-V[0])+(na[1]-V[1])*(na[1]-V[1])));ma--}22>ia&&(ha=ia+(22-ia)/3,ma=ia+2*(22-ia)/3,ma=[na[0]+ma/ia*(V[0]-na[0]),na[1]+ma/ia*(V[1]-na[1])],na=[V[0]-ha/ia*(V[0]-na[0]),V[1]-ha/ia*(V[1]-na[1])],V=ma,ia=22);K/=ia;ha=[V[0]-(V[0]-na[0])*K,V[1]-(V[1]-na[1])*K];na[1]!==V[1]?(K=(V[0]-na[0])/(V[1]-na[1]),na=q(x/Math.sqrt(1+K*K)),q=K*na):(na=0,q=q(x));Infinity===Math.abs(na)||Infinity===Math.abs(q)||isNaN(na)||isNaN(q)||(X[0].push(V),
X[0].push([ha[0]-na,ha[1]+q]),X[0].push([ha[0]+na,ha[1]-q]),X[0].push(V))}else X=K(X,2*x(ha),!0);R.paths=X}this.unhighlightSegment(this._segmentGraphics&&this._segmentGraphics.length);q=g.clone(this.routeSymbol).setWidth(this.segmentSymbol.width).setColor(new M([parseInt(.9*this.segmentSymbol.color.r),parseInt(.9*this.segmentSymbol.color.g),parseInt(.9*this.segmentSymbol.color.b)]));this._segmentGraphics=[new u(c.geometry,q,c.attributes,this.get("segmentInfoTemplate")),new u(R,this.routeSymbol,c.attributes,
this.get("segmentInfoTemplate")),new u(R,this.segmentSymbol,c.attributes,this.get("segmentInfoTemplate"))];this.get("showSegmentHighlight")&&(this._routeLayer.add(this._segmentGraphics[0]),this._routeLayer.add(this._segmentGraphics[1]),this._routeLayer.add(this._segmentGraphics[2]));c=g.hitch(this,function(wa){if(0<wa&&wa<this.directions.features.length){wa=this.directions.features[wa]._associatedFeaturesWithWaypoints;for(var ua=0;ua<wa.length;ua++)wa[ua]._associatedSnapFeature&&wa[ua]._associatedSnapFeature.getDojoShape()&&
wa[ua]._associatedSnapFeature.getDojoShape().moveToFront()}});c(a-1);c(a);this.onSegmentHighlight(this.directions.features[a])}},zoomToSegment:function(a){var c=new C;if(this.directions&&this.directions.features){var f=Math.max(0,Math.min(this.directions.features.length-1,a||0));this.map.setExtent(this.get("directions").features[f].geometry.getExtent(),!0).promise.always(g.hitch(this,function(){this.highlightSegment(f);c.resolve()}))}else c.reject(Error("No directions."));return c.promise},centerAtSegmentStart:function(a){var c=
new C;if(this.directions&&this.directions.features){var f=Math.max(0,Math.min(this.directions.features.length-1,a||0));var x=this.directions.features[f];this.map.centerAt(x.geometry.getPoint(0,0)).promise.always(g.hitch(this,function(){this.highlightSegment(f,!0);this._showSegmentPopup(x,f);c.resolve()}))}else c.reject(Error("No directions."));return c.promise},zoomToFullRoute:function(){var a=new C;this.directions&&this.directions.features?(this._clearInfoWindow(),this.unhighlightSegment(),this.get("map").setExtent(this.get("directions").extent,
!0).promise.always(a.resolve)):a.resolve();return a.promise},setListIcons:function(){var a,c=this._dnd.getAllNodes();for(a=0;a<c.length;a++){var f=N("."+this._css.stopIconClass,c[a])[0];f&&(f.innerHTML=this._getLetter(a));U.remove(c[a],this._css.stopOriginClass+" "+this._css.stopDestinationClass+" "+this._css.stopUnreachedClass+" "+this._css.stopUnreachedFirstOrLastClass);f=this._getStopSymbol(this.stops[a]);f===this.fromSymbol?U.add(c[a],this._css.stopOriginClass):f===this.toSymbol?U.add(c[a],this._css.stopDestinationClass):
f===this.unreachedSymbol&&U.add(c[a],this._css.stopUnreachedClass)}a=N("[data-reverse-td]",this._dndNode)[0];Z.destroy(a);this.get("showReverseStopsButton")&&Z.create("td",{"data-reverse-td":"true",rowspan:c.length,className:this._css.esriStopReverseColumnClass,innerHTML:'\x3cdiv role\x3d"button" class\x3d"'+this._css.reverseStopsClass+'" data-reverse-stops\x3d"true" title\x3d"'+G.widgets.directions.reverseDirections+'"\x3e\x3c/div\x3e',onmouseover:function(x){x.stopPropagation()},onmouseout:function(x){x.stopPropagation()}},
c[0])},addRouteSymbols:function(){if(this.stopGraphics.length){this._moveLayersToFront();for(var a=0;a<this.stopGraphics.length;a++)if(this.stopGraphics[a]&&(!this._handle._isShown()||this._handle._isShown()&&this._handle._index!==a)){this._stopLayer.add(this.stopGraphics[a]);var c=this.stopGraphics[a].getDojoShape();c&&c.moveToFront();this._stopLayer.add(this.textGraphics[a]);(c=this.textGraphics[a].getDojoShape())&&c.moveToFront()}this._moveInProgress&&!this._handle.attributes.isWaypoint&&this._handle.getDojoShape()&&
this._handle.getDojoShape().moveToFront()}},createRouteSymbols:function(){this._clearStopGraphics();for(var a=this.stops,c=function(V){var X={},ha;for(ha in V)V.hasOwnProperty(ha)&&0===ha.indexOf("Attr_")&&(X[ha]=V[ha]);return X},f=0;f<a.length;f++){var x=a[f];if(x&&x.feature){var q=x.feature.attributes,K=q?q.Status:void 0,R=null;this._isStopAWaypoint(x)||(R=new va(this._getLetter(f),this.get("textSymbolFont"),this.get("textSymbolColor")),this.get("textSymbolOffset")&&R.setOffset(this.get("textSymbolOffset").x,
this.get("textSymbolOffset").y));R=new u(x.feature.geometry,R,{address:x.name},this.get("stopsInfoTemplate"));R._isStopLabel=!0;R._index=f;x=new u(x.feature.geometry,this._getStopSymbol(x),g.mixin({address:x.name,Status:void 0===K?0:K,CurbApproach:q&&q.CurbApproach?q.CurbApproach:null,TimeWindowStart:q&&q.TimeWindowStart?q.TimeWindowStart:null,TimeWindowEnd:q&&q.TimeWindowEnd?q.TimeWindowEnd:null,isWaypoint:this._isStopAWaypoint(x)},c(q)),this.get(this._isStopAWaypoint(x)?"waypointInfoTemplate":"stopsInfoTemplate"));
x._isStopIcon=!0;x._index=f;this.stopGraphics[f]=x;this.textGraphics[f]=R}}this.set("stopGraphics",this.stopGraphics);this.set("textGraphics",this.textGraphics);this._showBarriers();this.addRouteSymbols();this.setListIcons()},setTravelMode:function(a){return this._enqueue(function(){this.clearMessages();this._travelModeSelector.setValue(a);return this._setTravelMode(a)})},getSupportedTravelModeNames:function(){var a=[],c=this.serviceDescription;if(c&&c.supportedTravelModes&&c.supportedTravelModes.length){c=
c.supportedTravelModes;for(var f=0;f<c.length;f++)a.push(c[f].name)}return a},setDirectionsLengthUnits:function(){var a=1===arguments.length?arguments[0]:this.get("directionsLengthUnits");return this._enqueue(function(){this.clearMessages();return this._setDirectionsLengthUnits(a)})},setDirectionsLanguage:function(){var a=1===arguments.length?arguments[0]:this.get("directionsLanguage");return this._enqueue(function(){this.clearMessages();return this._setDirectionsLanguage(a)})},useMyCurrentLocation:function(a){this.clearMessages();
return this._createLocateButton(this.geocoders[a],!0,!0)},loadRoute:function(a){return this._enqueue(g.hitch(this,function(){return this._loadRoute(a)}))},_getStopsAttr:function(){return this.returnToStart&&this._returnToStartStop?this.stops.concat(this._returnToStartStop):this.stops},_getTravelModeNameAttr:function(){return this.routeParams&&this.routeParams.travelMode&&this.routeParams.travelMode.name},_reset:function(){var a=this.mapClickActive||this.barrierToolActive;this._clearBarriersGraphics();
this._setWidgetProperties();return this._init().then(g.hitch(this,function(){this.mapClickActive=!a;this.set("mapClickActive",a);this._searchSourceSelector&&this._searchSourceSelector.setValue("all")}))},_activate:function(){var a=this.get("mapClickActive"),c=g.hitch(this,function(f){for(var x=f?[this.textGraphics,this.stopGraphics,this.displayedManeuverPointGraphics,this.displayedRouteGraphics]:[this.displayedRouteGraphics,this.displayedManeuverPointGraphics,this.stopGraphics,this.textGraphics],
q=0;q<x.length;q++)for(var K=x[q],R=0;R<K.length;R++){var V=K[R].getDojoShape();V&&V[f?"moveToBack":"moveToFront"].call(V)}});this.drawToolbar&&(this.barrierToolActive=!1,this.drawToolbar.deactivate(),U.remove(this._lineBarrierButtonNode,this._css.stopsPressedButtonClass));this._addStopOnMapClickListener&&this._addStopOnMapClickListener.remove();a?(this.map.activeDirectionsWidget&&this.map.activeDirectionsWidget!==this&&this.map.activeDirectionsWidget.deactivate(),this.map.activeDirectionsWidget=
this,this._addStopOnMapClickListener=z(this.map,"click",g.hitch(this,function(f){this.canModifyStops&&!this._solveInProgress&&(this.map.infoWindow.hide(),this.addStop(new u(f.mapPoint)))})),this.map.addLayer(this._waypointsEventLayer),this._moveLayersToFront(),U.add(this._activateButtonNode,this._css.stopsPressedButtonClass),this.onActivate()):(this.map.removeLayer(this._waypointsEventLayer),U.remove(this._activateButtonNode,this._css.stopsPressedButtonClass),this.onDeactivate());c(!a);this.emit("map-click-active",
{mapClickActive:this.mapClickActive})},_activateBarrierTool:function(){this.get("barrierToolActive")?(this.map.activeDirectionsWidget&&this.map.activeDirectionsWidget!==this&&this.map.activeDirectionsWidget.deactivate(),this.map.activeDirectionsWidget=this,this.drawToolbar.activate(Za.FREEHAND_POLYLINE),U.add(this._lineBarrierButtonNode,this._css.stopsPressedButtonClass),this.onActivateBarrierTool()):(this.drawToolbar.deactivate(),U.remove(this._lineBarrierButtonNode,this._css.stopsPressedButtonClass),
this.onDeactivateBarrierTool());this.emit("barrier-tool-active",{barrierToolActive:this.barrierToolActive})},_moveLayersToFront:function(){var a=this.get("map"),c=a.graphicsLayerIds.length-1;a.reorderLayer(this._routeLayer,c);a.reorderLayer(this._polygonBarriersLayer,c);a.reorderLayer(this._polylineBarriersLayer,c);a.reorderLayer(this._barriersLayer,c);a.reorderLayer(this._waypointsEventLayer,c);a.reorderLayer(this._stopLayer,c)},_destroyGeocoders:function(){for(;this.geocoders&&this.geocoders.length;){if(this.geocoders[0])try{this.geocoders[0].destroy()}catch(a){}this.geocoders.splice(0,
1)}this.geocoders=[]},_disconnectEvents:function(){var a=this._clearDirections(!0),c;if(this._watchEvents&&this._watchEvents.length)for(c=0;c<this._watchEvents.length;c++)this._watchEvents[c].unwatch();if(this._onEvents&&this._onEvents.length)for(c=0;c<this._onEvents.length;c++)this._onEvents[c].remove();if(this._geocoderEvents)for(c=0;c<this._geocoderEvents.length;c++)this._geocoderEvents[c].value.unwatch(),this._geocoderEvents[c].blur.remove(),this._geocoderEvents[c].select.remove(),this._geocoderEvents[c].suggest.remove();
this._onEvents=[];this._watchEvents=[];this._geocoderEvents=[];this._disconnectResults();this._destroyGeocoders();this._destroyGlobalGeocoder();this._destroyDnD();return a},_getDirections:function(){var a=new C;this._removeEmptyStops();1<this._getStopCount()+this._getWaypointCount()&&this.loaded?(this.onDirectionsStart(),this.clearMessages(),this._dnd.sync(),this._sortGeocoders(),this._getCandidates(this.stops).then(g.hitch(this,function(c){this.stops=c;this._setStops();this._configureRoute().always(g.hitch(this,
function(f){a.resolve(f)}))}),g.hitch(this,function(c){this.set("directions",null);this._clearRouteGraphics();a.reject(c);this.onDirectionsFinish(c)}))):this._clearDirections(!0).always(g.hitch(this,function(){this.createRouteSymbols();a.resolve()}));return a.promise},_clearDirections:function(){var a=new C;this._handle&&this._handle._remove();this.get("routeParams")&&this.get("routeParams").stops?this.get("routeParams").stops.features.length?(this.get("routeParams").stops.features=[],this.onDirectionsClear(),
a.resolve()):arguments.length?a.resolve():this._reset().then(a.resolve,a.reject):a.resolve();this.set("directions",null);this._clearDisplayBeforeSolve();this._clearDisplayAfterSolve();this._routeLayer.clear();this._waypointsEventLayer.clear();this._stopLayer.clear();return a.promise},_setTravelMode:function(a){var c=new C,f=this.serviceDescription,x=function(){c.resolve(a)};if(f&&f.supportedTravelModes&&f.supportedTravelModes.length){var q=f.supportedTravelModes,K=!1;for(f=0;f<q.length;f++)if(q[f].name===
a){K=!0;!this.routeParams.travelMode||this.routeParams.travelMode&&this.routeParams.travelMode.name!==a?(this.routeParams.travelMode=q[f].impedanceAttributeName?q[f]:q[f].itemId,this._checkStartTimeUIAvailability(),this._solveAndZoom().always(x)):x();this._travelModeSelector&&this._travelModeSelector.domNode&&(this._travelModeSelector.domNode.title=q[f].description);break}K||c.reject(a)}else c.reject(a);return c.promise},_setDirectionsLengthUnits:function(a){this._clearDisplayBeforeSolve();var c=
new C;U.remove(this._useMilesNode,this._css.stopsPressedButtonClass);U.remove(this._useKilometersNode,this._css.stopsPressedButtonClass);a===W.KILOMETERS?U.add(this._useKilometersNode,this._css.stopsPressedButtonClass):a===W.MILES&&U.add(this._useMilesNode,this._css.stopsPressedButtonClass);a===W.KILOMETERS||a===W.METERS||a===W.MILES||a===W.FEET||a===W.YARDS||a===W.NAUTICAL_MILES?(this.directionsLengthUnits=a,c.resolve(a)):c.reject(a);return c.promise},_setDirectionsLanguage:function(a){this._clearDisplayBeforeSolve();
var c=new C;a=this._setDirectionsLanguageByLocale(a);this._solveAndZoom().always(function(){c.resolve(a)},c.reject);return c.promise},_showLoadingSpinner:function(a){void 0===a&&(a=this._requestQueueTail&&!this._requestQueueTail.isFulfilled()||this._moveInProgress);a?(U.add(this._widgetContainer,this._css.resultsLoadingClass),U.add(this._resultsNode,"esriRoutesContainerBusy")):(U.remove(this._widgetContainer,this._css.resultsLoadingClass),U.remove(this._resultsNode,"esriRoutesContainerBusy"))},_enqueue:function(a,
c){var f=new C;this._requestQueueTail||(this._requestQueueTail=new C,this._requestQueueTail.resolve());this._requestQueueTail.promise.always(g.hitch(this,function(){try{g.mixin(this,{_incrementalSolveStopRange:null},c);var x=a.call(this);x&&"object"===typeof x&&x.hasOwnProperty("isFulfilled")?x.then(g.hitch(this,function(q){f.resolve(q);this._showLoadingSpinner()}),g.hitch(this,function(q){f.reject(q);this._showLoadingSpinner()})):(f.resolve(x),this._showLoadingSpinner())}catch(q){f.reject(q),this._showLoadingSpinner()}}));
this._requestQueueTail=f;this._showLoadingSpinner();return f.promise},_createDnD:function(){this._dnd=new da(this._dndNode,{skipForm:!0,withHandles:!0})},_destroyDnD:function(){Z.empty(this._dndNode);this._dnd&&(this._dnd.destroy(),this._dnd=null)},_createDepartAtControls:function(){if(this._departAtTime)this.map&&this._restoreMapTimeExtent(),this._useTrafficItemNode.title=G.widgets.directions.trafficLabelLive,U.remove(this._departAtContainer,"departAtContainerVisible"),this.startTime="now",this._updateStartTimeUI();
else{var a=this,c=function(){this._keepDirections||a._clearDisplayBeforeSolve();this._keepDirections=!1},f=g.hitch(this,function(){this.map&&this.map.disableKeyboardNavigation()}),x=g.hitch(this,function(){this.map&&this.map.enableKeyboardNavigation()});this._departAtTime=new m({required:!0,value:new Date,onChange:c,onFocus:f,onBlur:x},this._departAtTimeContainer);this._departAtDate=new A({required:!0,value:new Date,onChange:c,onFocus:f,onBlur:x,constraints:{min:new Date(864E5)}},this._departAtDateContainer)}},
_setStartTime:function(a,c,f){if(isNaN(f))this.startTime="now"===f?f:"none";else{c=f instanceof Date?f:new Date(f);f=this.directions&&this.directions.features&&this.directions.features[0]&&this.directions.features[0].attributes;var x=6E4*-c.getTimezoneOffset();c=new Date(c-x+(f&&f.arriveTimeUTC?f.ETA-f.arriveTimeUTC:x));this._departAtTime._keepDirections=!a;this._departAtDate._keepDirections=!a;this._departAtTime.setValue(c);this._departAtDate.setValue(c)}this._updateStartTimeUI()},_checkStartTimeUIAvailability:function(){var a=
this._getImpedanceAttribute();a=this._isTimeUnits(a?a.units:"")||this.serviceDescription&&10.6<=this.serviceDescription.currentVersion;this._startTimeButtonNode.disabled=!a;U[a?"remove":"add"].apply(this,[this._startTimeButtonNodeContainer,"esriLinkButtonDisabled"]);U[a?"remove":"add"].apply(this,[this._startTimeDDLArrow,"esriDirectionsDDLArrowDisabled"]);a||this.set("startTime","now")},_usingAGOL:function(a){a||(a=this.routeTaskUrl);return-1<a.search(/^(https?:)*\/\/*[^.]*\.arcgis\.com.*$/i)},_usingRouteAGOL:function(){return-1<
this.get("routeTaskUrl").search(/^(https?:)*\/\/route*[^.]*\.arcgis\.com.*$/i)},_setSearchOptions:function(){var a={map:this.get("map"),autoNavigate:!1,enableInfoWindow:!1,enableHighlight:!1,enableSourcesMenu:!1};this.searchOptions=g.mixin({maxResults:1,locationToAddressDistance:100},this.defaults.searchOptions,a)},_setDefaultUnits:function(){if(!this.get("directionsLengthUnits")){var a="EN-US"===Q.locale.toUpperCase()?W.MILES:W.KILOMETERS;this.defaults.directionsLengthUnits?a=this.defaults.directionsLengthUnits:
this.userOptions.routeParams&&this.userOptions.routeParams.directionsLengthUnits&&(a=this.userOptions.routeParams.directionsLengthUnits);this.set("directionsLengthUnits",a)}this._setDirectionsLengthUnits(this.directionsLengthUnits)},_setTrafficOptions:function(){this._usingRouteAGOL()&&!this.trafficLayer&&(this.trafficLayer=new sa(Ta+"//traffic.arcgis.com/arcgis/rest/services/World/Traffic/MapServer",{opacity:.4}));this.trafficLayer&&this.trafficLayer.url&&this._usingAGOL(this.trafficLayer.url)&&
(this._trafficAvailabilityButton.style.display="inline-block");this.set("showTrafficOption",(this.defaults.showTrafficOption||!this.defaults.hasOwnProperty("showTrafficOption"))&&!!this.trafficLayer);this._optionsMenu()},_updateCanModifyStops:function(a,c){this.canModifyStops||this.canModifyWaypoints||this.set("mapClickActive",!1);c||!this.canModifyStops||this.canModifyWaypoints||this.set("mapClickActive",!0);this._showAddDestination();this._showMapClickActiveButton();this._stopsTableCover.style.display=
this.canModifyStops?"none":"inline"},_updateCanAddWaypoints:function(a,c){this.canModifyStops||this.canModifyWaypoints||this.set("mapClickActive",!1);c||this.canModifyStops||!this.canModifyWaypoints||this.set("mapClickActive",!0);this._showMapClickActiveButton();this._handle._remove()},_updateStartTimeUI:function(){isNaN(this.startTime)?(this._startTimeButtonLabel.innerHTML="now"==this.startTime?this._i18n.widgets.directions.leaveNow:this._i18n.widgets.directions.noStartTime,U.remove(this._startTimeButtonNodeContainer,
"departAtButton"),U.remove(this._departAtContainer,"departAtContainerVisible")):(U.add(this._startTimeButtonNodeContainer,"departAtButton"),U.add(this._departAtContainer,"departAtContainerVisible"),this._startTimeButtonLabel.innerHTML=this._i18n.widgets.directions.departAt)},_setWidgetProperties:function(){this._disconnectEvents();this.set(this.defaults);this.routeLayer=g.clone(this.defaults.routeLayer);this._folderSelector&&(this._outputLayer.setValue(""),this._outputLayer.set("disabled",!0),this._folderSelector.set("disabled",
!0));this.set("stops",[]);this._updateCanModifyStops()},_updateStops:function(a){var c=new C;a?this.get("loaded")?this._reset().then(g.hitch(this,function(){this._addStops(a).then(c.resolve,c.reject)}),c.reject):this._addStops(a).then(c.resolve,c.reject):c.reject();return c.promise},_removeStop:function(a,c,f,x){var q=new C,K=g.hitch(this,function(V){this.stops.splice(V,1);var X=this._dnd.getAllNodes()[V],ha=this.get("geocoders");this._geocoderEvents[X.id]&&(this._geocoderEvents[X.id].blur.remove(),
this._geocoderEvents[X.id].select.remove(),this._geocoderEvents[X.id].suggest.remove(),this._geocoderEvents[X.id].value.unwatch());ha[V].destroy();ha.splice(V,1);this.set("geocoders",ha);Z.destroy(X);this._dnd.sync();this._stopsRemovable();this._optionsMenu();this._checkMaxStops();this.setListIcons();this._sortGeocoders()});if(0>a||a>=this.stops.length||void 0===a)a=this.stops.length-1;var R=!1;for(x=this.stopGraphics[a]&&this._isStopAWaypoint(this.stops[a])||x;!R;)K(a),x?R=!0:(a-=0>=a||a<this.stops.length&&
this._isStopAWaypoint(this.stops[a])?0:1,R=!this._isStopAWaypoint(this.stops[a]));for(;this.stops.length-this._getWaypointCount()<this.minStops;)this._addStop();this._clearStopsStatusAttr();this._setStops();this.createRouteSymbols();f?(this._clearDisplayBeforeSolve(),this._clearDisplayAfterSolve(),this.createRouteSymbols(),q.resolve()):this._solveAndZoom(c).then(q.resolve,q.reject);return q.promise},_removeTrafficLayer:function(){this.trafficLayer&&this.map&&this.map.removeLayer(this.trafficLayer);
this._trafficLayerAdded=!1},_addStops:function(a,c){var f=new C,x=[],q=this.autoSolve;this.autoSolve=!1;void 0===c&&(c=this._getStopCount());for(var K=0;K<Math.min(a.length,this.maxStops-this._getStopCount());K++){var R=new C;this._addStop(a[K],c+K,!0).always(R.resolve);x.push(R)}ea(x).always(g.hitch(this,function(){this.autoSolve=q;this._getDirections().always(function(){f.resolve(a)})}));return f.promise},_addStop:function(a,c,f){var x=new C;this._checkMaxStops();this.maxStopsReached?(this._showMessage(G.widgets.directions.error.maximumStops),
x.reject(Error(G.widgets.directions.error.maximumStops))):(void 0===a&&void 0===c&&(c=this.stops.length),a instanceof u&&a.attributes&&a.attributes.isWaypoint&&(!c||c===this.stops.length||2>this._getStopCount())&&!f?(this._showMessage(G.widgets.directions.error.waypointShouldBeInBetweenStops),x.reject(Error(G.widgets.directions.error.waypointShouldBeInBetweenStops))):this._getCandidate(a).then(g.hitch(this,function(q){this._isStopAWaypoint(q)&&q&&q.feature&&(q.feature.attributes=g.mixin({},q.feature.attributes,
{isWaypoint:!0,CurbApproach:3}));this._insertStop(q,c);this.autoSolve&&""!==q.name?this._getDirections().always(function(){x.resolve(q,c)}):x.resolve(q,c)}),g.hitch(this,function(q){x.reject(q)})));return x.promise},_removeEmptyStops:function(){for(var a=0,c=this.stops.length-this._getWaypointCount()-this.minStops;a<this.stops.length&&0<c;)this.stops[a]&&this.stops[a].name?a++:(this._removeStop(a,!0,!0,!0),c--,this._moveInProgress&&this._handle._index>=a&&this._handle._isStopIcon&&this._handle._index--)},
_setReverseGeocode:function(a,c,f){if(a.feature.geometry&&-1<f){var x={address:a.name};this.stopGraphics[f]&&(g.mixin(this.stopGraphics[f].attributes,x),this.stopGraphics[f].setGeometry(c));this.textGraphics[f]&&(g.mixin(this.textGraphics[f].attributes,x),this.textGraphics[f].setGeometry(c));this.set("stopGraphics",this.stopGraphics);this.set("textGraphics",this.textGraphics);(x=this.geocoders[f])&&x.inputNode&&(x.value=a.name,x.inputNode.value=a.name);g.mixin(a.feature.attributes,this.stops[f].feature.attributes);
this.stops[f]=a;this.stops[f].feature.setGeometry(c);this._setStops();return this._enqueue(function(){return this._getDirections()})}},_insertStop:function(a,c){var f;if(void 0===c)for(f=0;f<this.geocoders.length;f++){if(!this.geocoders[f].get("value")){var x=this.geocoders[f];break}}else f=c,this.geocoders[f]&&!this.geocoders[f].get("value")&&(x=this.geocoders[f]);!x||void 0!==c&&c!==f||this._isStopAWaypoint(a)?(void 0===c&&(c=this.geocoders.length),this.stops.splice(c,0,a),this._createGeocoder(a,
c)):(this.stops[f]=a,x.set("value",a.name),x._stopReference=a);this._optionsMenu()},_createGeocoder:function(a,c){var f=this._dnd.getAllNodes(),x=!1,q=!1,K=f.length;f[c]?(q=f[c],x=!0):x=q=!1;var R=g.hitch(this,function(ia,ma){var na=ma?this._css.stopDnDHandleClass:this._css.stopDnDHandleClassHidden,wa=ma?this._css.stopDnDHandleClassHidden:this._css.stopDnDHandleClass;U.replace(ia.children[0],na,wa);2<this.geocoders.length&&(na=ma?this._css.stopIconRemoveClass:this._css.stopIconRemoveClassHidden,wa=
ma?this._css.stopIconRemoveClassHidden:this._css.stopIconRemoveClass,U.replace(ia.children[3].children[0],na,wa))}),V=Z.create("tr",{className:this._css.stopClass,style:this._isStopAWaypoint(a)?"display:none;":"",onmouseover:function(){R(this,!0)},onmouseout:function(){R(this,!1)}});Z.create("td",{className:this._css.stopDnDHandleClassHidden+" dojoDndHandle"},V);f=Z.create("td",{className:this._css.stopIconColumnClass},V);Z.create("div",{className:this._css.stopIconClass+" dojoDndHandle",innerHTML:this._getLetter(K),
"data-center-at":"true"},f);K=Z.create("td",{className:this._css.esriStopGeocoderColumnClass},V);K=Z.create("div",{},K);f=Z.create("td",{className:this._css.stopIconRemoveColumnClass},V);Z.create("div",{className:this._css.stopIconRemoveClassHidden,role:"button","data-remove":"true"},f);this._dnd.insertNodes(!1,[V],x,q);x=g.mixin({},this.get("searchOptions"),{value:a.name,activeSourceIndex:this._globalGeocoder.activeSourceIndex});var X=new ab(x,K),ha=g.hitch(this,function(ia,ma){this._enqueue(function(){if(ma!==
ia&&X._stopReference&&X._stopReference.name!==ma){var na=O.indexOf(this.stops,X._stopReference);this.stops[na]={name:ma};this._handle._remove();this._removeSomeWaypoints(this._markWPsForRemovalAfterUserChangedStopSequence(na));this._setStops();this._clearDisplayBeforeSolve();this._clearDisplayAfterSolve();this.createRouteSymbols()}})});X._tr=V;X._stopReference=a;X.startup();this.geocoders.splice(c,0,X);this._geocoderEvents[V.id]={blur:X.on("blur",function(){""!==this.value&&this._stopReference&&!this._stopReference.feature&&
this.search()}),select:X.on("select-result",g.hitch(this,function(ia){var ma=!0;if(ia&&(ia.results||ia.result)){var na=this._dnd.getAllNodes();na=O.indexOf(na,V);var wa=X.value,ua=ia.results&&ia.results.results&&ia.results.results.length?ia.results.results[0]:ia.result;ua?(ua.name=wa,this.stops[na]=this._toPointGeometry(ua),this.geocoders[na]._stopReference=this.stops[na],ha("",wa)):(this.removeStop(na),this.set("directions",null),this._showMessage(G.widgets.directions.error.unknownStop.replace("\x3cname\x3e",
ia.target.get("value"))),this._clearRouteGraphics(),ma=!1);ma&&this.getDirections()}})),suggest:X.on("suggest-results",function(){if(document.activeElement===this.inputNode)for(var ia=N("LI[role\x3d'menuitem']",this.suggestionsNode),ma=0;ma<ia.length;ma++)S.set(ia[ma],"tabindex",-1);else this._hideSuggestionsMenu()}),value:X.watch("value",function(ia,ma,na){ha(ma,na)})};this._checkMaxStops();this.setListIcons();this._stopsRemovable();this._optionsMenu();this._sortGeocoders()},_blurGeocoders:function(){if(document.activeElement)for(var a=
0;a<this.geocoders.length;a++)if(this.geocoders[a].inputNode===document.activeElement){this.geocoders[a]._hideSuggestionsMenu();this.geocoders[a].inputNode.blur();1<this._getStopCount()+this._getWaypointCount()&&this.getDirections(!0);break}},_decorateEmptyAGOLGeocoderResponse:function(a){a&&", , "===a.name&&(a.name=a.feature&&a.feature.attributes&&a.feature.attributes.Match_addr?a.feature.attributes.Match_addr+("POI"===a.feature.attributes.Addr_type&&a.feature.attributes.City&&-1===a.feature.attributes.Match_addr.indexOf(a.feature.attributes.City)?
", "+a.feature.attributes.City:""):"");return a},_toPointGeometry:function(a){var c=a.feature.geometry;c&&(c.getCentroid?a.feature.geometry=c.getCentroid():c.getExtent&&(c=c.getExtent())&&(a.feature.geometry=c.getCenter()));return a},_removeLocateButtonVisibilityEvents:function(){for(var a=0;a<this.geocoders.length;a++){var c=this.geocoders[a];c._onMouseEnter&&c._onMouseEnter.remove();c._onMouseOut&&c._onMouseOut.remove();c._onKeyPress&&c._onKeyPress.remove();c._locateButton&&(c._locateButton._onMouseEnter&&
c._locateButton._onMouseEnter.remove(),c._locateButton._onMouseOut&&c._locateButton._onMouseOut.remove())}},_setLocateButtonVisibilityEvents:function(){this._removeLocateButtonVisibilityEvents();for(var a=this,c=function(X){X instanceof FocusEvent?this._geocoder._lbShown_f=!0:this._geocoder._lbShown_g=!0;a._createLocateButton(this._geocoder,!0)},f=function(X){X instanceof FocusEvent?this._geocoder._lbShown_f=!1:this._geocoder._lbShown_g=!1;clearTimeout(this._destroyTimeout);this._destroyTimeout=setTimeout(g.hitch(this,
function(){this._geocoder._lbShown_lb||this._geocoder._lbShown_f||a._destroyLocateButton(this._locateButton)}),400)},x=function(){this._geocoder._lbShown_g=!0;clearTimeout(this._destroyTimeout);this._destroyTimeout=setTimeout(g.hitch(this,function(){""===this.value?a._createLocateButton(this._geocoder,!0):a._destroyLocateButton(this._locateButton)}),400)},q=function(){this._geocoder._lbShown_lb=!0;clearTimeout(this._geocoder._destroyTimeout)},K=function(){this._geocoder._lbShown_lb=!1;clearTimeout(this._geocoder._destroyTimeout);
this._geocoder._destroyTimeout=setTimeout(g.hitch(this,function(){this._geocoder._lbShown_g||this._geocoder._lbShown_f||a._destroyLocateButton(this._geocoder.inputNode._locateButton)}),400)},R=0;R<this.geocoders.length;R++){var V=this.geocoders[R];V&&V.inputNode&&(V.inputNode._geocoder=V,V._onMouseEnter=z(V.inputNode,h.enter,c),V._onMouseOut=z(V.inputNode,[h.leave,"blur"],f),V._onKeyPress=z(V.inputNode,"keydown",x),V.inputNode._locateButton&&(V=V.inputNode._locateButton,V._onMouseEnter=z(V.domNode,
h.enter,q),V._onMouseOut=z(V.domNode,h.leave,K)))}},_createLocateButton:function(a,c,f){var x=new C;a.inputNode._locateButton&&a.inputNode._locateButton._locating?x.resolve():I(["./LocateButton"],g.hitch(this,function(q){this._destroyLocateButton(a.inputNode._locateButton);if(a&&!this._solveInProgress){var K=Z.create("div",{},a.domNode);U.add(a.domNode,this._css.stopsInnerGeocoderClass);var R=new q({map:this.map,highlightLocation:!1,centerAt:!1,setScale:!1,useTracking:!1},K);R.startup();a.inputNode._locateButton=
R;R.domNode._geocoder=a;this._setLocateButtonVisibilityEvents();q=g.hitch(this,function(){R._locating=!0;a.set("value","");a.inputNode.placeholder=G.widgets.directions.retrievingMyLocation.toUpperCase()});R._onBeforeLocate=z(R._locateNode,H,q);R._onLocate=z(R,"locate",g.hitch(this,function(V){R._locating=!1;V.graphic?(c&&this._destroyLocateButton(a.inputNode._locateButton),this.updateStop(new u(V.graphic.geometry),O.indexOf(this.geocoders,a)).then(g.hitch(this,function(){1<this.stopGraphics.length?
this.getDirections().always(function(){x.resolve(V)}):x.resolve(V)}))):(a.set("value",""),a.inputNode.placeholder=G.widgets.directions.myLocationError.toUpperCase(),console.error(V.error),x.reject(V.error))}));f?(q(),R.locate().then(null,x.reject)):x.resolve()}else x.resolve()}));return x.promise},_destroyLocateButton:function(a){if(a){var c=a.domNode._geocoder;clearTimeout(c._destroyTimeout);a._locating?c._destroyTimeout=setTimeout(g.hitch(this,function(){c._lbShown_lb||c._lbShown_f||this._destroyLocateButton(a)}),
100):(a.clear(),a._onBeforeLocate.remove(),a._onLocate.remove(),a._onMouseEnter&&a._onMouseEnter.remove(),a._onMouseOut&&a._onMouseOut.remove(),a.destroy(),c.inputNode&&(c.inputNode._locateButton=null,c._setPlaceholder(c.activeSourceIndex)))}},_sortStops:function(){this.stops.length&&(this.stops.sort(g.hitch(this,function(a,c){for(var f,x,q=0;q<this.get("geocoders").length;q++)this.geocoders[q]._stopReference===a?f=q:this.geocoders[q]._stopReference===c&&(x=q);return f>x?1:x>f?-1:0})),this._setStops())},
_getCandidate:function(a){var c=new C,f=typeof a;a?"object"===f&&a.hasOwnProperty("feature")&&a.hasOwnProperty("name")?(a.feature.attributes&&void 0!==a.feature.attributes.displayName&&!this._isStopAWaypoint(a)&&(a.name=a.feature.attributes.displayName,a.feature.attributes.Name=this._userDefinedStopName),a.name=this._isStopAWaypoint(a)?this._waypointName:String(a.name),"point"!==a.feature.geometry.type&&(a.feature.geometry=new b([a.feature.geometry.x,a.feature.geometry.y],this.map.spatialReference)),
c.resolve(a)):"object"===f&&a.hasOwnProperty("address")&&a.hasOwnProperty("location")?(a=this._globalGeocoder._hydrateResult(a),c.resolve(a)):"object"!==f||!a.hasOwnProperty("name")||null!==a.name&&""!==a.name?a instanceof u&&a.attributes&&(void 0!==a.attributes.Name||a.attributes.isWaypoint)?(f=this._addStopWrapperToGraphic(a,a.attributes.isWaypoint?this._waypointName:String(a.attributes.Name)),String(a.attributes.Name)&&(f.feature.attributes.Name=this._userDefinedStopName),c.resolve(f)):("object"===
f&&a.hasOwnProperty("name")&&(a=String(a.name)),this._reverseGeocode(a).then(c.resolve,c.reject)):c.resolve(g.clone(this._emptyStop)):c.resolve(g.clone(this._emptyStop));return c.promise},_reverseGeocode:function(a){var c=new C,f,x=a.geometry?a.geometry:a;if(this._globalGeocoder){var q=g.hitch(this,function(X){var ha=new C,ia=500;if(this.map){var ma=this.map.toScreen(x);ma.x+=Ea._calculateClickTolerance([X]);this.map.spatialReference.isWebMercator()?(ia=Math.abs(this.map.toMap(ma).x-x.x),ha.resolve(ia)):
4326===this.map.spatialReference.wkid?(ia=Math.abs(ya.geographicToWebMercator(this.map.toMap(ma)).x-ya.geographicToWebMercator(x).x),ha.resolve(ia)):this._geometryService&&(X=new Oa,X.distanceUnit=Ba.UNIT_METER,X.geometry1=x,X.geometry2=this.map.toMap(ma),this._geometryService.distance(X,function(na){ia=na;ha.resolve(ia)},function(){ha.resolve(ia)}))}return ha.promise}),K=[],R=this._globalGeocoder.sources,V=function(){R[f].featureLayer&&K.push(q(R[f].featureLayer).then(g.hitch(R[f],function(X){this.searchQueryParams=
g.mixin(this.searchQueryParams,{distance:X})})))};if("all"===this._globalGeocoder.activeSourceIndex)for(f=0;f<R.length;f++)V();else f=this._globalGeocoder.activeSourceIndex,V();ea(K).always(g.hitch(this,function(){this._globalGeocoder.search(x).then(g.hitch(this,function(X){var ha=!1;if(X){var ia=null;for(f=0;f<this._globalGeocoder.sources.length;f++)if(X[f]&&X[f].length){var ma=X[f];break}if(ma.length&&(ha=!0,ia=ma[0],this._globalGeocoder.sources[f].featureLayer))for(X=Number.POSITIVE_INFINITY,f=
0;f<ma.length;f++){ma[f]=this._toPointGeometry(ma[f]);var na=ra.geodesicLengths([new B({paths:[[ya.xyToLngLat(x.x,x.y),ya.xyToLngLat(ma[f].feature.geometry.x,ma[f].feature.geometry.y)]],spatialReference:{wkid:this.map.spatialReference.wkid}})],"esriMeters")[0];X>na&&(X=na,ia=ma[f])}(ia=this._decorateEmptyAGOLGeocoderResponse(ia))&&""!==ia.name&&null!==ia.name&&void 0!==ia.name?(ia.name=String(ia.name),isNaN(x.x)||isNaN(x.y)||this.map.spatialReference.wkid!==x.spatialReference.wkid?!ia.feature.geometry||
isNaN(ia.feature.geometry.x)||isNaN(ia.feature.geometry.y)?(this._showMessage(G.widgets.directions.error.locator),c.reject(Error(G.widgets.directions.error.locator))):c.resolve(ia):(ia.feature.geometry=x,c.resolve(ia))):ha=!1}ha||(a instanceof b?a=new u(a):a instanceof Array&&(a=new u(new b(a[0],a[1]))),a instanceof u?this._decorateUngeocodedStop(a).then(c.resolve,c.reject):(this._showMessage(G.widgets.directions.error.unknownStop.replace("\x3cname\x3e",a.toString())),c.reject(Error(G.widgets.directions.error.unknownStop.replace("\x3cname\x3e",
a.toString())))))}))}))}else this._showMessage(G.widgets.directions.error.locatorUndefined),c.reject(Error(G.widgets.directions.error.locatorUndefined));return c.promise},_updateStop:function(a,c,f){var x=new C;this.stops&&this.stops[c]?a instanceof u&&a.attributes&&a.attributes.isWaypoint&&(!c||c===this.stops.length-1||2>this._getStopCount())?(this._showMessage(G.widgets.directions.error.waypointShouldBeInBetweenStops),x.reject(Error(G.widgets.directions.error.waypointShouldBeInBetweenStops))):this._getCandidate(a).then(g.hitch(this,
function(q){var K=q.feature;K=K?K.geometry:null;var R=this.stops[c].feature;R=R?R.geometry:null;K=K&&R&&(K.x!==R.x||K.y!==R.y)||!K&&R;this.stops[c]=q;this.geocoders[c]||this._createGeocoder(q,c);R=this.geocoders[c];R._stopReference=q;R._tr.style.display=this._isStopAWaypoint(q)?"none":"";R.value=q.name;R.inputNode&&(R.inputNode.value=q.name);K&&this.autoSolve&&1<this._getStopCount()+this._getWaypointCount()||f?this._getDirections().then(x.resolve,x.reject):(this._setStops(),x.resolve(q))}),g.hitch(this,
function(q){x.reject(q)})):(this._showMessage(G.widgets.directions.error.couldNotUpdateStop),x.reject(Error(G.widgets.directions.error.couldNotUpdateStop)));this._optionsMenu();return x.promise},_renderDirections:function(){var a=this.get("directions");if(this._resultsNode){var c='\x3cdiv class\x3d"'+this._css.clearClass+'"\x3e\x3c/div\x3e';c+=this._renderDirectionsSummary(a);c+='\x3cdiv class\x3d"'+this._css.clearClass+'"\x3e\x3c/div\x3e';c+='\x3cdiv class\x3d"'+this._css.routesClass+'"\x3e';c+=
this._renderDirectionsTable(a);c+="\x3cdiv class\x3d'esriPrintFooter'\x3e"+G.widgets.directions.printDisclaimer+"\x3c/div\x3e";c+="\x3c/div\x3e";this._resultsNode&&(this._resultsNode.innerHTML=c);this._disconnectResults();(a=N("[data-segment]",this._resultsNode))&&a.length&&O.forEach(a,g.hitch(this,function(f){this._resultEvents.push(z(f,h.enter,g.hitch(this,function(){if(!this._focusedDirectionsItem){var x=parseInt(S.get(f,"data-segment"),10);this.highlightSegment(x)}})));this._resultEvents.push(z(f,
"focusout",g.hitch(this,function(){this._focusedDirectionsItem=null;this.unhighlightSegment(!0)})));this._resultEvents.push(z(f,h.leave,this.unhighlightSegment));this._resultEvents.push(z(f,"click, keydown",g.hitch(this,function(x){x&&("click"===x.type||"keydown"===x.type&&x.keyCode===r.ENTER)&&(this._focusedDirectionsItem!==f?this.selectSegment(parseInt(S.get(f,"data-segment"),10)):(f.blur(),this.map.infoWindow.hide(),this._focusedDirectionsItem=null,this.unhighlightSegment(!0)))})))}))}},_renderDirectionsSummary:function(a){var c=
"",f=g.hitch(this,function(){for(var R={},V=this._getDirectionsTimeAttribute()||{},X=this._getTimeNeutralAttribute()||{},ha=0,ia=0,ma=this.get("stops"),na=ma.length-1;0<=na;na--)if(null!==ma[na].feature.attributes.ArriveCurbApproach){R=ma[na].feature.attributes;break}for(var wa in R)R.hasOwnProperty(wa)&&(wa==="Cumul_"+V.name&&(ha=R[wa]),wa==="Cumul_"+X.name&&(ia=R[wa]));R="esriTrafficLabelHidden";ma=G.widgets.directions.noTraffic;na=a.totalTime-a.totalDriveTime;na=(ia-this._convertCostValue(na,V.units,
X.units))/(ha-na||1);0<na&&.8>na?(R="esriTrafficLabelHeavy",ma=G.widgets.directions.heavyTraffic):1===na?(R="esriTrafficLabelNone",ma=G.widgets.directions.noTraffic):1.25<na&&(R="esriTrafficLabelLight",ma=G.widgets.directions.ligthTraffic);X=this._formatTime(ia,!1,X.units);return{label:ma,labelClass:R,ratio:na,noTrafficCostStr:1!==na&&X?X+" "+G.widgets.directions.onAverage+"\x3cbr\x3e":"",trafficCost:ha,noTrafficCost:ia,timeAtt:V}});if(a.totalLength||a.totalTime){f=f();var x=this._getImpedanceAttribute();
c+="\x3cdiv class\x3d'"+this._css.resultsSummaryClass+"' data-full-route\x3d'true'\x3e\x3cdiv class\x3d'esriImpedanceCost'\x3e";if(this._isTimeUnits(x.units))c+=this._formatTime(f.trafficCost,!0,f.timeAtt.units)+"\x3cdiv class\x3d'esriImpedanceCostHrMin'\x3e\x3cdiv class\x3d'esriImpedanceCostHr'\x3e"+G.widgets.directions.time.hr+"\x3c/div\x3e\x3cdiv class\x3d'esriImpedanceCostMin'\x3e"+G.widgets.directions.time.min+"\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class\x3d'esriOtherCosts'\x3e"+(f.noTrafficCost?
"\x3cdiv class\x3d'esriTrafficLabel "+f.labelClass+"'\x3e"+f.label+"\x3c/div\x3e"+f.noTrafficCostStr:"")+this._formatDistance(a.totalLength);else{x=(x=G.widgets.directions.units[this.directionsLengthUnits])?x.name:"";var q=this.serviceDescription&&10.6<=this.serviceDescription.currentVersion,K=this.directions.features[0].attributes;c+=D.format(a.totalLength,{places:1})+"\x3cdiv class\x3d'esriImpedanceCostDist'\x3e"+x+"\x3c/div\x3e\x3c/div\x3e\x3cdiv class\x3d'esriOtherCosts'\x3e"+(f.noTrafficCost&&
q?"\x3cdiv class\x3d'esriTrafficLabel "+f.labelClass+"'\x3e"+f.label+"\x3c/div\x3e"+f.noTrafficCostStr:"")+this._formatTime(a.totalTime)+" "+("none"!==this.startTime&&f.noTrafficCost&&q?G.widgets.directions.atTheMoment+" "+this._toSpatiallyLocalTimeString(K.arriveTimeUTC,K.ETA):"")}c+="\x3c/div\x3e\x3c/div\x3e"}return c},_renderDirectionsTable:function(a){for(var c=0,f=0,x=0,q='\x3ctable summary\x3d"'+a.routeName+'"\x3e\x3ctbody role\x3d"menu"\x3e',K=0;K<a.features.length;K++){var R=a.features[K].attributes;
"esriDMTDepart"===R.maneuverType&&(f=x=0);x+=R.length;f+=R.time;c+=R.time;q+=this._renderDirectionsItemTR(a.features[K],x,f,c)}return q+"\x3c/tbody\x3e\x3c/table\x3e"},_renderDirectionsItemTR:function(a,c,f,x){var q=this.directions,K=q?O.indexOf(q.features,a):-1;x="";var R=this._css.routeClass,V=a._associatedStopWithReturnToStart&&a._associatedStopWithReturnToStart.attributes,X=a.attributes;if(-1<K){X&&(X.step=K+1);X.maneuverType&&(R+=" "+X.maneuverType);V&&null===V.ArriveCurbApproach&&null!==V.DepartCurbApproach?
R+=" "+this._css.routeOriginClass:V&&null!==V.ArriveCurbApproach&&null===V.DepartCurbApproach&&(R+=" "+this._css.routeDestinationClass+" "+this._css.routeLastClass);x+='\x3ctr tabindex\x3d"0" role\x3d"menuitem" class\x3d"'+R+" "+this._css.routeZoomClass+'" data-segment\x3d"'+K+'"\x3e';x+='\x3ctd class\x3d"'+this._css.routeIconColumnClass+'"\x3e';x+='\x3cdiv class\x3d"'+this._css.routeIconClass+'"\x3e';x+=this._getLetter(a._associatedStop);x=x+'\x3c/div\x3e\x3c/td\x3e\x3ctd class\x3d"'+(this._css.routeTextColumnClass+
'"\x3e');x+='\x3cdiv class\x3d"'+this._css.routeInfoClass+'"\x3e';x+='\x3cdiv class\x3d"'+this._css.routeTextClass+'"\x3e';a=(q.strings[K]||[]).slice();if("esriDMTDepart"===X.maneuverType||"esriDMTStop"===X.maneuverType)for(q=0;q<this.stops.length;q++)this.stops[q]&&this.stops[q].name&&a.push({string:this.stops[q].name});if(a){R=X.text;for(q=0;q<a.length;q++)R=this._boldText(R,a[q].string);X.formattedText=R}else X.formattedText=X.text;if("esriDMTStop"===X.maneuverType&&(c||f)||"esriDMTDepart"===X.maneuverType&&
0===K)c=this._formatDistance(c-X.length,!0),f=this._formatTime(f-X.time),K=this._formatTime(X.time),a=this._formatDistance(X.length,!0),X.formattedText+="\x3cdiv class\x3d'esriRouteTextColumnCumulative'\x3e"+c+(c&&f?" \x26middot; ":"")+f+(c||f?"\x3cbr\x3e":"")+(K?G.widgets.directions.serviceTime+":\x26nbsp;"+K:"")+(K&&a?"\x3cbr\x3e":"")+(a?G.widgets.directions.serviceDistance+":\x26nbsp;"+a:"")+"\x3c/div\x3e";x+="\x3cstrong\x3e"+D.format(X.step)+".\x3c/strong\x3e "+X.formattedText;x+="\x3c/div\x3e";
c=this._formatDistance(X.length,!0);f=this._formatTime(X.time);"esriDMTStop"!==X.maneuverType&&"esriDMTDepart"!==X.maneuverType||!this.routeParams.startTime||-22091616E5===X.ETA?c&&(x+='\x3cdiv class\x3d"'+this._css.routeLengthClass+'"\x3e',x+=c,f&&(x+="\x26nbsp;\x26middot;\x3cwbr\x3e\x26nbsp;"+f),x+="\x3c/div\x3e"):x+='\x3cdiv class\x3d"'+this._css.routeLengthClass+'"\x3e'+this._toSpatiallyLocalTimeString(X.arriveTimeUTC,X.ETA)+"\x3c/div\x3e";x+="\x3c/div\x3e\x3c/td\x3e\x3c/tr\x3e"}return x},_toSpatiallyLocalTimeString:function(a,
c){var f=new Date(c),x=new Date(f.getTime()+6E4*f.getTimezoneOffset());x=Q.date.locale.format(x,{selector:"time"});var q="";a?(c=(c-a)/1E3/60/60,a=Math.floor(c),c=60*(c-a),a=G.widgets.directions.GMT+(0>a?"":"+")+D.format(a,{pattern:"00"})+D.format(c,{pattern:"00"}),q=x+" "+a):q="now"===this.startTime?Q.date.locale.format(f,{selector:"time"}):x;return q},_addStopWrapperToGraphic:function(a,c){return{extent:new l({xmin:a.geometry.x-.25,ymin:a.geometry.y-.25,xmax:a.geometry.x+.25,ymax:a.geometry.y+.25,
spatialReference:a.geometry.spatialReference}),feature:a,name:c}},_clearBarriersGraphics:function(){this._barriersLayer.clear();this._polylineBarriersLayer.clear();this._polygonBarriersLayer.clear()},_showBarriers:function(){this._clearBarriersGraphics();var a=this.routeParams,c=a.polylineBarriers&&a.polylineBarriers.features||[],f=a.polygonBarriers&&a.polygonBarriers.features||[];O.forEach(a.barriers&&a.barriers.features||[],g.hitch(this,function(x){this._barriersLayer.add(x)}));O.forEach(c,g.hitch(this,
function(x){this._polylineBarriersLayer.add(x)}));O.forEach(f,g.hitch(this,function(x){this._polygonBarriersLayer.add(x)}));this._barriersLayer.refresh();this._polylineBarriersLayer.refresh();this._polygonBarriersLayer.refresh()},_showRoute:function(a){this._clearDisplayAfterSolve();var c=a.routeResults[0].directions,f=new C;if(c){this.set("solveResult",a);this.set("directions",c);var x=a.routeResults[0].stops,q,K;if(x&&x.length){var R=[];for(q=0;q<x.length;q++){var V=x[q];V.attributes.isWaypoint=
V.attributes.Name===this._waypointName||V.attributes.isWaypoint;V=this._addStopWrapperToGraphic(V,V.attributes.Name);this.stops[q]&&this.stops[q].feature&&this.stops[q].feature.attributes&&this.stops[q].feature.attributes.Name===this._userDefinedStopName&&(V.feature.attributes.Name=this._userDefinedStopName);this._returnToStartStop&&this._returnToStartStop._resultsStopIndex===q?this._returnToStartStop=V:R.push(V)}if(this.stops.length>R.length)for(q=0;q<this.stops.length;q++)this.stops[q].feature||
""!==this.stops[q].name||R.splice(q,0,this._emptyStop);this.stops=R;for(q=0;q<this.stops.length;q++)this._updateStop(this.stops[q],q);this._setStops();this._setMenuNodeValues()}this.set("mergedRouteGraphic",new u(c.mergedGeometry,this.get("routeSymbol")));x=[];R=[];for(q=V=0;q<c.featuresWithWaypoints.length;q++){var X=c.featuresWithWaypoints[q];if("esriDMTDepart"===X.attributes.maneuverType)for(K=0;K<this.stops.length;K++)if(this.stops[K].feature===X._associatedStop){V=K+1;break}X.setSymbol(this.get("routeSymbol"));
this._routeLayer.add(X);x.push(X);(K=X.getDojoShape())&&K.moveToBack();K=new u(X.geometry,this._symbolEventPaddingDirections,X.attributes);K._nextStopIndex=V-.5;K._isSnapFeature=!0;X._associatedSnapFeature=K;this._waypointsEventLayer.add(K);"esriDMTDepart"!==X.attributes.maneuverType&&(K=X.geometry.getPoint(0,0))&&(K=new u(K,this.maneuverSymbol),K._directionsFeature=X._associatedFeatureNoWaypoints,R.push(K),this._waypointsEventLayer.add(R[R.length-1]))}this.set("displayedRouteGraphics",x);this.set("displayedManeuverPointGraphics",
R);this._renderDirections();for(q=0;q<this.stops.length;q++)if(this._isStopAWaypoint(this.stops[q])&&this._modifiedWaypointIndex===q){for(K=0;K<c.featuresWithWaypoints.length;K++)if(x=c.featuresWithWaypoints[K],x._associatedStop===this.stops[q].feature){if("esriDMTStop"===x.attributes.maneuverType||"esriDMTDepart"===x.attributes.maneuverType)this.stops[q].feature.geometry.x=x.geometry.paths[0][0][0],this.stops[q].feature.geometry.y=x.geometry.paths[0][0][1];break}this._modifiedWaypointIndex=null;
break}J.set(this._savePrintBtnContainer,"display","inline-block");this.onDirectionsFinish(a)}else a=a.routeResults[0].route,a.setSymbol(this.routeSymbol),this._routeLayer.add(a),this._incrementalRouteSegment=a;f.resolve();this._moveLayersToFront();this.createRouteSymbols();return f.promise},_setGeocodersStopReference:function(){if(this.geocoders)for(var a=0;a<this.geocoders.length;a++)this.geocoders[a]&&this.stops[a]&&(this.geocoders[a]._stopReference=this.stops[a])},_setStops:function(){this._setGeocodersStopReference();
this.createRouteSymbols();this._set("stops",this.stops);this.onStopsUpdate(this.stops)},_getCandidates:function(a){var c=[];if(a&&a.length){for(var f=0;f<a.length;f++)c.push(this._getCandidate(a[f]));return ea(c)}a=new C;a.resolve([]);return a.promise},_clearResultsHTML:function(){this._resultsNode.innerHTML="";J.set(this._savePrintBtnContainer,"display","none")},_showSegmentPopup:function(a){if(a&&this.get("showSegmentPopup")&&this.get("map").infoWindow){var c=a.geometry.getPoint(0,0);a=new u(c,
null,a.attributes,this.get("segmentInfoTemplate"));var f=this.get("map").infoWindow;f.setFeatures([a]);f.show(c)}},_addStopButton:function(){this.addStop().then(g.hitch(this,function(){this.get("focusOnNewStop")&&this.geocoders[this.stops.length-1].focus()}))},_sortGeocoders:function(){var a=this._dnd.getAllNodes();this.geocoders.sort(g.hitch(this,function(f,x){return f.domNode&&f.domNode.parentNode&&f.domNode.parentNode.parentNode&&x.domNode&&x.domNode.parentNode&&x.domNode.parentNode.parentNode?
O.indexOf(a,f.domNode.parentNode.parentNode)>O.indexOf(a,x.domNode.parentNode.parentNode)?1:-1:0}));this.stops.length===this.geocoders.length&&this._sortStops();for(var c=0;c<this.geocoders.length;c++)this.geocoders[c]&&this.geocoders[c].inputNode&&(this.geocoders[c].inputNode.title=G.widgets.directions.stopNoTitle+(c+1));this._setLocateButtonVisibilityEvents()},_disconnectResults:function(){if(this._resultEvents&&this._resultEvents.length)for(var a=0;a<this._resultEvents.length;a++)this._resultEvents[a]&&
this._resultEvents[a].remove();this._resultEvents=[]},_formatArbitraryCostsForRouteTooltip:function(a){var c="",f;for(f in a)if(0===f.indexOf("Total_")&&a.hasOwnProperty(f)){var x=this._getCostAttribute(f.substr(6));x&&(c+=this._isTimeUnits(x.units)?this._formatTime(a[f],!1,x.units):this._formatDistance(a[f],!0,x.units),c+=c?" \x26middot; ":"")}c&&(c=G.widgets.directions.toNearbyStops+": \x3cb\x3e"+c.substr(0,c.length-10)+"\x3c/b\x3e");return c},_formatTime:function(a,c,f){f||(f=(this._getDirectionsTimeAttribute()||
{}).units);var x="";f=Math.round(this._convertCostValue(a,f,"esriNAUMinutes"));a=Math.floor(f/60);f=Math.floor(f%60);c?x=D.format(a,{pattern:100>a?"00":"000"})+":"+D.format(f,{pattern:"00"}):(a&&(x+=a+" "+G.widgets.directions.time.hr+" "),x+=a||f?f+" "+G.widgets.directions.time.min:"");return x},_formatDistance:function(a,c,f){f||(f=this.directionsLengthUnits);var x=this.directionsLengthUnits,q=G.widgets.directions.units[x],K=x.replace("esri","").toLowerCase();a=this._convertCostValue(a,f,x);q&&(K=
c?q.abbr:q.name);return a?D.format(a,{locale:"root",places:2})+" "+K:""},_projectToGeographic:function(a){var c=new C;if(!a)return c.reject("Directions:: 'geometry' is not defined.",{geometry:a}),c.promise;if(4326==a.spatialReference.wkid)return c.resolve(a),c.promise;if(!this._geometryService)return c.reject("Directions:: Geometry service is not defined."),c.promise;var f=new $a;f.outSR=new ka(4326);f.geometries=[a];this._geometryService.project(f).then(function(x){c.resolve(x&&x[0])},c.reject);
return c.promise},_createToolbars:function(){this.editToolbar||(this.editToolbar=new Ya(this.map));this.drawToolbar||(this.drawToolbar=new Za(this.map),G.toolbars.draw.freehand=G.widgets.directions.lineBarrierFreehand,this.drawToolbar.onDrawComplete=g.hitch(this,function(a){var c=new u(a.geometry,null,{BarrierType:0});this._projectToGeographic(a.geographicGeometry||a.geometry).then(g.hitch(this,function(f){1<ra.geodesicLengths([f],W.METERS)[0]&&(this._polylineBarriersLayer.add(c),this.routeParams.polylineBarriers||
(this.routeParams.polylineBarriers=new Aa),this.routeParams.polylineBarriers.features.push(c),this._clearStopsStatusAttr(),this.getDirections(!0))}))}))},_destroyGlobalGeocoder:function(){this._globalGeocoder&&(this._globalGeocoder.destroy(),this._globalGeocoder=null)},_createGlobalGeocoder:function(){var a=new C;this._globalGeocoder=new ab(this.get("searchOptions"));z.once(this._globalGeocoder,"load",a.resolve,a.reject);this._globalGeocoder.startup();return a.promise},_init:function(){var a=new C;
this.set("loaded",!1);this._enableButton(this._getDirectionsButtonNode,!1);J.set(this._saveAsButton,"display","none");this.clearMessages();if(this.get("map").loaded)this._configure().always(a.resolve);else z.once(this.get("map"),"load",g.hitch(this,function(){this._configure().always(a.resolve)}));return a.promise},_setDefaultStops:function(){var a=new C;this.defaults.stops&&this.defaults.stops.length?this._updateStops(this.defaults.stops).then(g.hitch(this,function(){this._removeEmptyStops();a.resolve()}),
a.reject):a.resolve();return a.promise},_configure:function(){var a=new C;this._handle&&this._handle._remove();this._createDnD();this._createDepartAtControls();this._setSearchOptions();this._createGlobalGeocoder().then(g.hitch(this,function(){this._createToolbars();this._usingAGOL()||(this.printTaskUrl=this.geometryTaskUrl=null);this._createGeometryTask();this._createPrintTask();this._showActivateButton();this._showBarriersButton();this._createTravelModesDDL();this._createSearchSourceDDL();var c=
[this._createRouteTask(),this._setDefaultStops()];ea(c).then(g.hitch(this,function(){this._setDefaultUnits();this._setTrafficOptions();this._setMenuNodeValues();this._setupEvents();var f=this.directionsLanguage||this.userOptions.routeParams&&this.userOptions.routeParams.directionsLanguage||Q.locale.toLowerCase();this._setDirectionsLanguageByLocale(f);this._setupTravelModes().then(g.hitch(this,function(){this.set("loaded",!0);this.onLoad();a.resolve(!0)}),function(x){a.reject(x)})}),function(f){a.reject(f)})}),
function(c){a.reject(c)});this._naRouteSharing=null;return a.promise},_setDirectionsLanguageByLocale:function(a){var c=this.serviceDescription.directionsSupportedLanguages,f=function(q){if(c)for(var K=0;K<c.length;K++)if(c[K].toLowerCase().substr(0,2)===q)return c[K];return null},x=f(a);x||(a=a.substr(0,2),x=f(a));this.directionsLanguage=x;return this.routeParams.directionsLanguage=x},_getStopSymbol:function(a,c){var f=a&&(a.feature&&a.feature.attributes||a.attributes),x=this.stopSymbol;f&&(x=this._isStopAWaypoint(a)?
this.waypointSymbol:void 0===f.Status||0===f.Status||6===f.Status?null===f.ArriveCurbApproach&&null!==f.DepartCurbApproach?this.get(c?"fromSymbolDrag":"fromSymbol"):null!==f.ArriveCurbApproach&&null===f.DepartCurbApproach?this.get(c?"toSymbolDrag":"toSymbol"):this.get(c?"stopSymbolDrag":"stopSymbol"):this.get(c?"unreachedSymbolDrag":"unreachedSymbol"));return x},_addTrafficLayer:function(){this.trafficLayer&&!this._trafficLayerAdded&&this.map&&(this.map.addLayer(this.trafficLayer),this.trafficLayer.show(),
this._trafficLayerAdded=!0)},_toggleUnits:function(a){a.target===this._useMilesNode?this.setDirectionsLengthUnits(W.MILES):a.target===this._useKilometersNode&&this.setDirectionsLengthUnits(W.KILOMETERS)},_toggleCheckbox:function(a){var c=S.get(a.target,"checked");a.target===this._findOptimalOrderNode?this.set("optimalRoute",c):a.target===this._useTrafficNode?this.set("traffic",c):a.target===this._returnToStartNode&&this.set("returnToStart",c)},_isStopLocated:function(a){return a&&a.feature&&a.feature.attributes&&
(!a.feature.attributes.Status||6===a.feature.attributes.Status)},_configureRouteOptions:function(){var a=this.get("routeParams"),c;this.get("directionsLengthUnits")?a.directionsLengthUnits=this.get("directionsLengthUnits"):this.set("directionsLengthUnits",a.directionsLengthUnits);a.findBestSequence=this.get("optimalRoute");if(a.findBestSequence)for(a.preserveFirstStop=this._isStopLocated(this.stops[0]),a.preserveLastStop=!this.returnToStart&&this._isStopLocated(this.stops[this.stops.length-1])||this.returnToStart&&
this._isStopLocated(this.stops[0]),c=0;c<this.stops.length;)this._isStopAWaypoint(this.stops[c])?this._removeStop(c,!0,!0):c++;if(!this.returnToStart&&this.stops.length&&this._isStopAWaypoint(this.stops[this.stops.length-1]))for(c=this.stops.length-1;0<c;)this._isStopAWaypoint(this.stops[c])&&this._removeStop(c,!0,!0),c--;if(this._isTimeUnits(this._getImpedanceAttribute().units)||this.serviceDescription&&10.6<=this.serviceDescription.currentVersion)if(a.useTimeWindows=!0,"now"===this.startTime)a.timeWindowsAreUTC=
!0,a.startTimeIsUTC=!0,a.startTime=new Date;else if("none"===this.startTime)a.startTime=null;else{a.timeWindowsAreUTC=!1;a.startTimeIsUTC=!1;var f=this._departAtTime,x=6E4*f.getValue().getTimezoneOffset();f=new Date(f.getValue().getTime()+this._departAtDate.getValue().getTime()-x);f=new Date(f.getTime()-6E4*f.getTimezoneOffset());a.startTime=f}else a.startTime=null,a.useTimeWindows=!1;f=this._getImpedanceAttribute();x=this._getTimeNeutralAttribute();var q=this._getDirectionsTimeAttribute();c=this.routeParams.accumulateAttributes||
this.serviceDescription.accumulateAttributeNames;x&&-1===O.indexOf(c,x.name)&&c.push(x.name);!this._isTimeUnits(f.units)&&this.serviceDescription&&10.6<=this.serviceDescription.currentVersion&&q&&-1===O.indexOf(c,q.name)&&c.push(q.name);this.routeParams.accumulateAttributes=c;a.returnStops=!0;q=[];for(c=0;c<this.stopGraphics.length;c++)if(this.stopGraphics[c]&&(q.push(new u(this.stopGraphics[c].toJson())),c)){var K=q[0].attributes,R=q[c].attributes;for(V in R)R.hasOwnProperty(V)&&!K.hasOwnProperty(V)&&
(K[V]=null)}if(this.get("returnToStart")&&this.stopGraphics.length&&this._isStopLocated(this.stops[0])){var V=new u(this.stopGraphics[0].toJson());this._returnToStartStop=this._addStopWrapperToGraphic(V,V.attributes.Name);q.push(V)}else this._returnToStartStop=null;a.stops.features=q;if(x)for(c=0;c<q.length;c++)q[c].attributes["Attr_"+x.name]=this._convertCostValue(q[c].attributes["Attr_"+f.name],f.units,x.units);this.set("routeParams",a)},_configureRoute:function(){var a=new C;a.promise.always(g.hitch(this,
function(){this._checkMaxStops()}));this.createRouteSymbols();this._configureRouteOptions();if(this.routeParams.returnRoutes&&this._incrementalSolveStopRange){var c=this._incrementalSolveStopRange;c.start<c.end?this.routeParams.stops.features=this.routeParams.stops.features.slice(c.start,c.end+1):c.start>c.end&&(this.routeParams.stops.features=this.routeParams.stops.features.slice(c.start,this.routeParams.stops.features.length-1).concat(this.routeParams.stops.features.slice(0,c.end+1)))}else this._incrementalSolveStopRange=
null;var f={},x=this.routeParams.stops.features;for(c=0;c<x.length;c++){var q=x[c].attributes.address;var K=(c===this._handle._index&&!this._handle.attributes.isWaypoint&&this._incrementalSolveStopRange?this._waypointName:q)+"_"+this._stopSequence++;x[c].attributes.Name=K;f[K]=q;delete x[c].attributes.address;delete x[c].attributes.isWaypoint;delete x[c].attributes.Status}this._solveInProgress=!0;var R={_incrementalSolveStopRange:this._incrementalSolveStopRange};this.routeTask.solve(this.routeParams,
g.hitch(this,function(V){this._solveResultProcessing(V,f,R).then(a.resolve,a.reject)}),g.hitch(this,function(V){g.mixin(this,R);this._solveInProgress=!1;for(var X=0;X<this.stops.length;X++)this.stops[X].feature&&(this.stops[X].feature.attributes=g.mixin(this.stops[X].feature.attributes,{Status:5}));this.set("directions",null);this._clearDisplayAfterSolve();this.createRouteSymbols();this._routeTaskError(V);a.reject(V)}));return a.promise},_solveResultProcessing:function(a,c,f){var x=new C;g.mixin(this,
f);this._solveInProgress=!1;f=a.routeResults[0];var q=f.directions;f=f.stops;if(q){this._solverMessages=a.messages;var K=function(ia){for(var ma in c)if(ia&&0===q.routeName.indexOf(ma)||!ia&&0<q.routeName.indexOf(ma))return c[ma];return""};var R=K(!0);K=K(!1);q.routeName=(R!==this._waypointName?R:G.widgets.directions.waypoint)+" \u2014 "+(K!==this._waypointName?K:G.widgets.directions.waypoint);for(R=0;R<q.features.length;R++)if(K=q.features[R].attributes,"esriDMTDepart"===K.maneuverType||"esriDMTStop"===
K.maneuverType)for(var V in c)if(c.hasOwnProperty(V)&&-1<K.text.indexOf(V)){K.text=K.text.replace(V,c[V]);for(var X=0;X<f.length;X++){var ha=f[X].attributes;if(ha.Name===V){g.mixin(q.features[R],{_associatedStop:f[this.returnToStart&&X===f.length-1?0:X],_associatedStopWithReturnToStart:f[X]});if(!ha.ArriveTime&&!ha.ArriveTimeUTC&&K.ETA&&K.arriveTimeUTC){ha.ArriveTime=K.ETA;ha.ArriveTimeUTC=K.arriveTimeUTC;X=0;if(0==R&&"esriDMTDepart"===K.maneuverType||0<R&&"esriDMTStop"===K.maneuverType)X=this._convertCostValue(K.time,
(this._getDirectionsTimeAttribute()||{}).units,"milliseconds");ha.DepartTime=ha.ArriveTime+X;ha.DepartTimeUTC=ha.ArriveTimeUTC+X}break}}}for(R=0;R<f.length;R++)this._returnToStartStop&&f[R].attributes.Name===this._returnToStartStop.feature.attributes.Name&&(this._returnToStartStop._resultsStopIndex=R),f[R].attributes.Name=c[f[R].attributes.Name];this._directionsPostprocessing(q);this.traffic&&this._updateMapTimeExtent()}this._showRoute(a).always(g.hitch(this,function(){this._incrementalSolveStopRange=
null;x.resolve(a)}));return x.promise},_directionsPostprocessing:function(a){var c,f=function(K,R){var V=a.features[K]._associatedFeaturesWithWaypoints||[];V.push(a.featuresWithWaypoints[R]);a.features[K]._associatedFeaturesWithWaypoints=V;a.featuresWithWaypoints[R]._associatedFeatureNoWaypoints=a.features[K]};var x=g.hitch(this,function(K){return"\x3cdiv class\x3d'"+this.theme+"'\x3e\x3ctable class\x3d'esriRoutesTooltip'\x3e"+this._renderDirectionsItemTR(K._associatedFeatureNoWaypoints)+"\x3c/table\x3e\x3c/div\x3e"});
a.featuresWithWaypoints=[];for(c=0;c<a.features.length;c++){var q=new u(a.features[c].toJson());q.setInfoTemplate(new ba({title:this._i18n.widgets.directions.maneuver,content:x}));a.featuresWithWaypoints.push(q);a.featuresWithWaypoints[c]._associatedStop=a.features[c]._associatedStop;a.featuresWithWaypoints[c]._associatedStopWithReturnToStart=a.features[c]._associatedStopWithReturnToStart}a.stringsWithWaypoints=g.mixin([],a.strings);a.eventsWithWaypoints=g.mixin([],a.events);for(x=c=0;c<a.features.length;)a.features[c]._associatedStop&&
a.features[c]._associatedStop.attributes.Name===this._waypointName?(a.features.splice(c,c?2:1),a.strings.splice(c,c?2:1),a.events.splice(c,c?2:1),c&&a.features[c]&&"esriDMTStraight"===a.features[c].attributes.maneuverType?(q=a.features.splice(c,1)[0],a.strings[c-1]=(a.strings[c-1]||[]).concat(a.strings.splice(c,1)[0]||[]),a.strings[c-1].length||(a.strings[c-1]=void 0),a.events[c-1]=(a.events[c-1]||[]).concat(a.events.splice(c,1)[0]||[]),a.events[c-1].length||(a.events[c-1]=void 0),a.features[c-1].attributes.length+=
q.attributes.length,a.features[c-1].attributes.time+=q.attributes.time,a.features[c-1].geometry.paths[0]=a.features[c-1].geometry.paths[0].concat(q.geometry.paths[0]),f(c-1,x++),f(c-1,x++),f(c-1,x++)):(c&&f(c-1,x++),c<a.features.length&&f(c,x++))):(f(c,x++),c++)},_boldText:function(a,c){try{var f=new RegExp("[^\x3cstrong\x3e\x26nbsp;]"+c.replace(/(\||\$|\^|\(|\)|\[|\]|\{|\}|\/|\.|\+|\*|\?|\?)/g,"\\$1")+"[^\x26nbsp;\x3c/strong\x3e]","g");a=(" "+a+" ").replace(f,"\x3cstrong\x3e\x26nbsp;"+c+"\x26nbsp;\x3c/strong\x3e");
a=a.trim()}catch(x){}return a},_clearStopGraphics:function(){if(this.stopGraphics&&this.stopGraphics.length)for(var a=0;a<this.stopGraphics.length;a++)this._stopLayer.remove(this.stopGraphics[a]),this._stopLayer.remove(this.textGraphics[a]);this.set("stopGraphics",[]);this.set("textGraphics",[])},_updateMapTimeExtent:function(){if(this.map){var a=this.directions&&this.directions.features[0]&&this.directions.features[0].attributes||{},c=(new Date).getTime();c="none"==this.startTime?c:a.arriveTimeUTC||
c;this._useTrafficItemNode.title="none"!==this.startTime&&a.arriveTimeUTC?G.widgets.directions.trafficLabelDepartAt+": "+this._toSpatiallyLocalTimeString(a.arriveTimeUTC,a.ETA):"";this._myTimeExtentUpdate=!0;a=new Date(c);this.map.setTimeExtent(new ja(a,a))}},_restoreMapTimeExtent:function(){this.map&&(this._myTimeExtentUpdate=!0,this.map.setTimeExtent(this._externalTimeExtent))},_clearRouteGraphics:function(){for(var a=this.displayedRouteGraphics,c=this.displayedManeuverPointGraphics,f=this._routeLayer,
x=this._waypointsEventLayer,q=0,K=0,R=this._incrementalSolveStopRange?this._incrementalSolveStopRange:{start:0,end:this.stops?this.stops.length:-1};a&&K<a.length;){if(a[K]._associatedStop)for(var V=0;V<this.stops.length;V++)if(this.stops[V].feature===a[K]._associatedStop){q=V;break}q>=R.start&&q<R.end||R.start>=R.end&&(q>=R.start||q<R.end)?(f.remove(a[K]),a.splice(K,1)):K++}f.remove(this._incrementalRouteSegment);this.set("displayedRouteGraphics",a?a:[]);c&&c.length&&O.forEach(c,function(X){x.remove(X)});
this.set("displayedManeuverPointGraphics",[]);this._waypointsEventLayer.clear();this.unhighlightSegment(!0)},_clearInfoWindow:function(){var a=this.get("map").infoWindow;a&&(a.hide(),a.clearFeatures())},_clearDisplayBeforeSolve:function(){this._toggleSaveMenu(!1);this._clearInfoWindow();this._clearResultsHTML()},_clearDisplayAfterSolve:function(){this._clearStopGraphics();this._clearRouteGraphics();this._clearBarriersGraphics();this.clearMessages()},_getLetter:function(a){var c=this.alphabet,f="",
x=function(R){var V="";"0123456789"===c||"1234567890"===c?V=String(R+1):(R=R||0,R>=c.length&&(V=x(Math.floor(R/c.length)-1),R%=c.length),V+=c[R]);return V},q=a instanceof u?g.hitch(this,function(){for(var R=this.get("returnToStart")?0:-1,V=0;V<this.stops.length;V++)if(this.stops[V].feature===a){R=V;break}return R})():a;if(-1<q&&c&&c.length){c instanceof Array&&(c=c.toString().replace(/,/g,""));f=-1;for(var K=0;K<=q;K++)f+=this._isStopAWaypoint(this.stops[K])?0:1;f=x(f)}return f},_solveAndZoom:function(a){if(this.autoSolve)return this._getDirections().then(g.hitch(this,
function(){a||this.zoomToFullRoute()}));var c=new C;c.resolve();return c.promise},_setupEvents:function(){this._onEvents.push(z(this.domNode,"[data-blur-on-click]:click",function(){this.blur()}));this._onEvents.push(z(this._dndNode,"[data-reverse-stops]:click, [data-reverse-stops]:keydown",g.hitch(this,function(q){q&&("click"===q.type||"keydown"===q.type&&q.keyCode===r.ENTER)&&this.modifyStopSequence()})));this._onEvents.push(z(this._printButton,"click, keydown",g.hitch(this,function(q){q&&("click"===
q.type||"keydown"===q.type&&q.keyCode===r.ENTER)&&this._printDirections()})));this._onEvents.push(z(this._resultsNode,"[data-full-route]:click, [data-full-route]:keydown",g.hitch(this,function(q){q&&("click"===q.type||"keydown"===q.type&&q.keyCode===r.ENTER)&&this.zoomToFullRoute()})));this._onEvents.push(z(this._dndNode,"[data-remove]:click, [data-remove]:keydown",g.hitch(this,function(q){if(q&&("click"===q.type||"keydown"===q.type&&q.keyCode===r.ENTER)){var K=N("[data-remove]",this._dndNode);q=
O.indexOf(K,q.target);this.removeStop(q)}})));this._onEvents.push(z(this._dndNode,"[data-center-at]:click, [data-center-at]:keydown",g.hitch(this,function(q){if(q&&("click"===q.type||"keydown"===q.type&&q.keyCode===r.ENTER)){var K=N("[data-center-at]",this._dndNode);q=O.indexOf(K,q.target);this.stops[q]&&this.stops[q].feature&&this.stops[q].feature.geometry&&this.map.centerAndZoom(this.stops[q].feature.geometry)}})));this._onEvents.push(z(this.map,"zoom-end",g.hitch(this,function(){var q=this._segmentGraphics;
q&&q[0]&&void 0!==q[0].attributes._index&&this.highlightSegment(q[0].attributes._index,!0)})));this._onEvents.push(z(this._dnd,"Drop",g.hitch(this,function(){this._dnd.sync();this.set("optimalRoute",!1);var q,K=!1,R=[],V=this._dnd.getAllNodes();for(q=0;q<this.geocoders.length;q++){var X=O.indexOf(V,this.geocoders[q]._tr);if(-1<X&&q!==X&&q!==X-1){for(;0<X&&this._isStopAWaypoint(this.stops[X]);)X--;K=!0;break}}K&&(R=this._markWPsForRemovalAfterUserChangedStopSequence(q,X));this._sortGeocoders();this.setListIcons();
this._removeSomeWaypoints(R);this.stops[X].name&&this.getDirections()})));this._onEvents.push(z(this._dnd,"DndStart",g.hitch(this,function(){var q=N("body")[0];U.add(q,this._css.dndDragBodyClass);this._removeLocateButtonVisibilityEvents()})));this._onEvents.push(z(this._dnd,"DndDrop, DndCancel",g.hitch(this,function(){var q=N("body")[0];U.remove(q,this._css.dndDragBodyClass);this._setLocateButtonVisibilityEvents()})));var a=this._handle,c=g.hitch(this,function(q){var K=g.hitch(this,function(V,X,ha,
ia,ma){var na=a._isShown();a.setGeometry(V);a._tooltip.style.left=q.screenPoint.x+"px";a._tooltip.style.top=q.screenPoint.y+"px";!na||a._index===ha&&a.attributes.isWaypoint===ia||(a._remove(),na=!1);a.setSymbol(X);a._index=ha;a._isStopIcon=a._index===Math.floor(a._index);a.attributes.isWaypoint=ia;a._isStopIcon&&(a.attributes.address=this.stopGraphics[ha].attributes.address,a.setInfoTemplate(this.stopGraphics[ha].infoTemplate));if(this.canModifyWaypoints||a._isStopIcon)na||(this._stopLayer.add(a),
(V=a.getDojoShape())&&V[ia?"moveToBack":"moveToFront"].call(V)),this.editToolbar.activate(Ya.MOVE,a);ia=ia?a._isStopIcon?G.widgets.directions.dragWaypoint:this.canModifyWaypoints?G.widgets.directions.dragRoute:"":G.widgets.directions.dragStop;a._showTooltip(ma||ia)});this.unhighlightSegment();if(this.mapClickActive&&this.dragging&&!this._solveInProgress&&!this._moveInProgress&&!a._solveTimeout)if(clearTimeout(a._removeTimeout),(q.graphic._isStopIcon||q.graphic._isStopLabel)&&!q.graphic.attributes.isWaypoint&&
this.canModifyStops||q.graphic._isStopIcon&&q.graphic.attributes.isWaypoint&&this.canModifyWaypoints){var R=q.graphic._isStopLabel?this.stopGraphics[q.graphic._index]:q.graphic;K(R.geometry,this._getStopSymbol(this.stops[R._index],!0),R._index,!0===R.attributes.isWaypoint);this._stopLayer.remove(this.stopGraphics[R._index]);this._stopLayer.remove(this.textGraphics[R._index])}else if(q.graphic._isSnapFeature||q.graphic._isHandle&&!q.graphic._isStopIcon)this._snappingManager||(this._snappingManager=
this.map.snappingManager),this._snappingManager.getSnappingPoint(q.screenPoint).then(g.hitch(this,function(V){if(!this.maxStopsReached&&!this._moveInProgress&&V){for(var X=this.displayedManeuverPointGraphics,ha=null,ia=0;ia<X.length;ia++)if(X[ia].geometry.x===V.x&&X[ia].geometry.y===V.y){ha=X[ia]._directionsFeature;X=O.indexOf(this.directions.features,ha);-1<X&&this.highlightSegment(X);break}K(V,q.graphic._isHandle?a.symbol:this.waypointSymbol,q.graphic._isHandle?a._index:q.graphic._nextStopIndex,
q.graphic._isHandle?a.attributes.isWaypoint:!0,ha)}}))}),f=g.hitch(this,function(){clearTimeout(a._removeTimeout);a._removeTimeout=setTimeout(a._remove,100);this.unhighlightSegment()}),x=g.hitch(this,function(q){if(this.barrierToolActive){q=q.graphic;var K=this.routeParams,R=K.barriers?O.indexOf(K.barriers.features,q):-1,V=K.polygonBarriers?O.indexOf(K.polygonBarriers.features,q):-1,X=K.polylineBarriers?O.indexOf(K.polylineBarriers.features,q):-1;-1<R&&K.barriers.features.splice(R,1);-1<V&&K.polygonBarriers.features.splice(V,
1);-1<X&&K.polylineBarriers.features.splice(X,1);this._barriersLayer.remove(q);this._polygonBarriersLayer.remove(q);this._polylineBarriersLayer.remove(q);this._clearStopsStatusAttr();this.getDirections(!0)}});this._onEvents.push(this._waypointsEventLayer.on("mouse-move",c));this._onEvents.push(this._waypointsEventLayer.on("mouse-out",f));this._onEvents.push(this._stopLayer.on("mouse-move",c));this._onEvents.push(this._stopLayer.on("mouse-out",f));this._onEvents.push(this._barriersLayer.on("click",
x));this._onEvents.push(this._polylineBarriersLayer.on("click",x));this._onEvents.push(this._polygonBarriersLayer.on("click",x));this._editToolbarEvents();this._watchEvents.push(this.watch("theme",this._updateThemeWatch));this._watchEvents.push(this.watch("canModifyStops",this._updateCanModifyStops));this._watchEvents.push(this.watch("canModifyWaypoints",this._updateCanAddWaypoints));this._watchEvents.push(this.watch("showReturnToStartOption",this._optionsMenu));this._watchEvents.push(this.watch("showOptimalRouteOption",
this._optionsMenu));this._watchEvents.push(this.watch("returnToStart",this._setMenuNodeValues));this._watchEvents.push(this.watch("optimalRoute",this._setMenuNodeValues));this._watchEvents.push(this.watch("startTime",this._setStartTime));this._watchEvents.push(this.watch("traffic",this._setMenuNodeValues));this._watchEvents.push(this.watch("trafficLayer",this._trafficLayerUpdate));this._watchEvents.push(this.watch("routeTaskUrl",g.hitch(this,function(){this._createRouteTask();this._setTrafficOptions()})));
this._watchEvents.push(this.watch("printTaskUrl",g.hitch(this,function(){this._createPrintTask()})));this._watchEvents.push(this.watch("geometryTaskUrl",g.hitch(this,function(){this._createGeometryTask()})));this._watchEvents.push(this.watch("routeParams",g.hitch(this,function(){this._createRouteParams();this._setDefaultUnits()})));this._watchEvents.push(this.watch("searchOptions",g.hitch(this,function(){this._setSearchOptions();this._createGlobalGeocoder();var q=this.get("searchOptions").sources;
if(q)for(var K=0;K<this.geocoders.length;K++)this.geocoders[K].set("sources",q)})));this._watchEvents.push(this.watch("showReverseStopsButton",this.setListIcons));this._watchEvents.push(this.watch("editToolbar",this._editToolbarEvents));this._watchEvents.push(this.watch("showTravelModesOption",this._showTravelModesOption));this._watchEvents.push(this.watch("showMilesKilometersOption",this._showMilesKilometersOption));this._watchEvents.push(this.watch("showClearButton",this._showClearButton));this._watchEvents.push(this.watch("directionsLengthUnits",
this.setDirectionsLengthUnits));this._watchEvents.push(this.watch("directionsLanguage",this.setDirectionsLanguage));this._watchEvents.push(this.watch("mapClickActive",this._activate));this._watchEvents.push(this.watch("barrierToolActive",this._activateBarrierTool));this._watchEvents.push(this.watch("showActivateButton",this._showActivateButton));this._watchEvents.push(this.watch("showBarriersButton",this._showBarriersButton));this._watchEvents.push(this.watch("showPrintPage",function(){J.set(this._printButton,
"display",this.showPrintPage?"inline-block":"none")}));this._watchEvents.push(this.watch("showSaveButton",function(){J.set(this._saveMenuButton,"display",this.showSaveButton&&this.owningSystemUrl?"inline-block":"none")}))},_editToolbarEvents:function(){var a=g.hitch(this,function(f){var x="";if((f=f.routeResults?f.routeResults[0]:null)&&f.route){f=f.route.attributes;var q=this.routeParams.travelMode;if(q){x+="\x3cb\x3e"+q.name+"\x3c/b\x3e "+G.widgets.directions.toNearbyStops+": ";var K=void 0!==f["Total_"+
q.timeAttributeName]?this._formatTime(f["Total_"+q.timeAttributeName],!1,(this._getCostAttribute(q.timeAttributeName)||{}).units):"";x+=(void 0!==f["Total_"+q.distanceAttributeName]?this._formatDistance(f["Total_"+q.distanceAttributeName],!0,(this._getCostAttribute(q.distanceAttributeName)||{}).units):"")+(K?" \x26middot; "+K:"")}else x=this._formatArbitraryCostsForRouteTooltip(f)}this._handle._showTooltip(x)}),c=g.hitch(this,function(f,x){var q=new C,K=this._handle,R=this.map.toScreen(K._origPoint).offset(f.transform.dx+
K.symbol.xoffset,f.transform.dy+K.symbol.yoffset);f.origMapPoint||(f.origMapPoint=this.map.toMap(R));J.set(K._tooltip,"left",R.x+"px");J.set(K._tooltip,"top",R.y+"px");clearTimeout(K._solveTimeout);if(this._solveInProgress||!this._requestQueueTail.isFulfilled())K._solveTimeout=setTimeout(function(){c(f,x).always(q.resolve)},100);else if(K._isStopIcon){R=f.graphic._index;var V=this.stops[R];(V=V?{name:V.name,extent:V.extent,feature:new u(V.feature.toJson())}:null)?(V.feature.setGeometry(f.origMapPoint),
this._modifiedWaypointIndex=this._isStopAWaypoint(this.stops[R])?R:null,this._incrementalSolveStopRange={start:this.returnToStart?(this.stops.length+R-1)%this.stops.length:Math.max(0,R-1),end:this.returnToStart?(R+1)%this.stops.length:Math.min(this.stops.length-1,R+1)},this.updateStop(V,R,x).always(g.hitch(this,function(X){K._solveTimeout=null;X.routeResults&&a(X);q.resolve()}))):q.resolve()}else q.resolve();return q.promise});this._onEvents.push(z(this.editToolbar,"graphic-click",g.hitch(this,function(f){if(f.graphic.attributes.isWaypoint)!f.graphic._isStopIcon||
this._moveInProgress||this._solveInProgress||(this._handle._remove(),this._moveInProgress=!0,this.removeStop(f.graphic._index,!0).always(g.hitch(this,function(){this._moveInProgress=!1})));else{var x=this.get("map").infoWindow;x&&(x.setFeatures([f.graphic]),x.show(f.graphic.geometry))}})));this._onEvents.push(z(this.editToolbar,"graphic-move-start",g.hitch(this,function(f){this._blurGeocoders();this._moveInProgress=!0;this._removeEmptyStops();this.routeParams.returnDirections=!1;this.routeParams.returnRoutes=
!0;f=f.graphic;f._origPoint=new b(f.geometry.toJson());f._maxDeviation=0;f._solveHasHappened=!1;this.map.disableMapNavigation()})));this._onEvents.push(z(this.editToolbar,"graphic-move-stop",g.hitch(this,function(f){this.map.enableMapNavigation();this.routeParams.returnDirections=!0;this.routeParams.returnRoutes=!1;if(this._handle._isStopIcon)if(this._handle._solveHasHappened)if(this._handle.attributes.isWaypoint)c(f,!0).always(g.hitch(this,function(){this._moveInProgress=!1;this._handle._isStopIcon=
!0;this._handle._remove();this._showLoadingSpinner()}));else{clearTimeout(this._handle._solveTimeout);this._handle._solveTimeout=null;var x=this.stops[f.graphic._index],q=(x&&x.feature&&x.feature.attributes&&x.feature.attributes.Name)===this._userDefinedStopName,K=x&&x.name;this._reverseGeocode(new u(f.graphic.toJson())).then(g.hitch(this,function(R){q&&(R.name=K,R.feature.attributes.Name=this._userDefinedStopName);this._setReverseGeocode(R,R.feature.geometry,f.graphic._index).always(g.hitch(this,
function(){this._moveInProgress=!1;this._handle._remove();this._showLoadingSpinner()}))}))}else this._moveInProgress=!1;else this._moveInProgress=!1})));this._onEvents.push(z(this.editToolbar,"graphic-move",g.hitch(this,function(f){var x=this._handle,q=f.transform;q.dx&&q.dy&&(f.graphic._maxDeviation=Math.max(x._maxDeviation,Math.sqrt(q.dx*q.dx+q.dy*q.dy)));10<x._maxDeviation&&(x._solveHasHappened=!0,f.graphic===x&&x.attributes.isWaypoint&&!x._isStopIcon?(this.set("optimalRoute",!1),x._index+=.5,
x._isStopIcon=!0,f.graphic._stopIndex=x._index,this._incrementalSolveStopRange={start:this.returnToStart?(this.stops.length+x._index-1)%this.stops.length:Math.max(0,x._index-1),end:this.returnToStart?(x._index+1)%(this.stops.length+1):Math.min(this.stops.length,x._index+1)},this.addStop({name:this._waypointName,feature:new u(x.geometry,x.symbol,{isWaypoint:!0,CurbApproach:3})},f.graphic._stopIndex)):((x=f.graphic.getDojoShape())&&x.moveToFront(),c(f)))})))},_isStopAWaypoint:function(a){return a&&
a.feature&&a.feature.attributes&&a.feature.attributes.isWaypoint},_getStopCount:function(){var a=0,c;for(c=0;c<this.stops.length;c++)a+=!this._isStopAWaypoint(this.stops[c])&&this.stops[c].name?1:0;return a},_getWaypointCount:function(){var a=0,c;for(c=0;c<this.stops.length;c++)a+=this._isStopAWaypoint(this.stops[c])?1:0;return a},_decorateUngeocodedStop:function(a){var c=new C,f=function(q,K){c.resolve({name:void 0===q?G.widgets.directions.unlocatedStop:q.toFixed(6)+" "+K.toFixed(6),feature:a})};
if(a.geometry)if(a.geometry.spatialReference&&4326!==a.geometry.spatialReference.wkid)if(this.map&&this.map.spatialReference&&this.map.spatialReference.isWebMercator()){var x=ya.xyToLngLat(a.geometry.x,a.geometry.y);f(x[0],x[1])}else this._geometryService?(x=new $a,x.outSR=new ka(4326),x.geometries=[a.geometry],this._geometryService.project(x).then(g.hitch(this,function(q){q&&q.length?f(q[0].x,q[0].y):f(a.geometry.x,a.geometry.y)}),g.hitch(this,function(){f()}))):f(a.geometry.x,a.geometry.y);else f(a.geometry.x,
a.geometry.y);else f();return c.promise},_trafficLayerUpdate:function(a,c,f){a=this.get("map");c&&this._trafficLayerAdded&&(a.removeLayer(c),this._trafficLayerAdded=!1);f&&this.get("traffic")&&!this._trafficLayerAdded&&(a.addLayer(f),f.show(),this._trafficLayerAdded=!0)},_routeTaskError:function(a){var c=G.widgets.directions.error.routeTask,f=a.details,x=function(q){return(res=q.match(/(\d+)/))?": "+res[0]:"."};f&&1===f.length&&("The distance between any inputs must be less than 50 miles (80 kilometers) when walking."===
f[0]?c=G.widgets.directions.error.maxWalkingDistance:"Driving a truck is currently not supported outside of North America and Central America."===f[0]?c=G.widgets.directions.error.nonNAmTruckingMode:0===f[0].indexOf("The number of input locations loaded into Barriers")?c=G.widgets.directions.error.tooManyBarriers+x(f[0]):0===f[0].indexOf("The number of input locations loaded into PolygonBarriers")?c=G.widgets.directions.error.tooManyPolygonBarriers+x(f[0]):0===f[0].indexOf("The number of input locations loaded into PolylineBarriers")&&
(c=G.widgets.directions.error.tooManyPolylineBarriers+x(f[0])));this._showMessage(c);this.onDirectionsFinish(a)},_showMessage:function(a,c){var f="";this.messages.push({msg:a,error:!c});if(this.messages.length){f+="\x3cul\x3e";for(var x=0;x<this.messages.length;x++)f+='\x3cli class\x3d"'+(this.messages[x].error?this._css.routesErrorClass:this._css.routesInfoClass)+'"\x3e'+this.messages[x].msg+"\x3c/li\x3e";f+="\x3c/ul\x3e"}this._msgNode&&(this._msgNode.innerHTML=f);if(!c)this.onError(a)},_isTimeUnits:function(a){return"milliseconds"===
a||"esriNAUSeconds"===a||"esriNAUMinutes"===a||"esriNAUHours"===a||"esriNAUDays"===a},_getImpedanceAttribute:function(){return this._getCostAttribute(this.routeParams&&this.routeParams.travelMode&&this.routeParams.travelMode.impedanceAttributeName||this.routeParams.impedanceAttribute||this.serviceDescription.impedance)},_getDirectionsTimeAttribute:function(){return this._getCostAttribute(this.routeParams&&this.routeParams.travelMode&&this.routeParams.travelMode.timeAttributeName||this.routeParams.directionsTimeAttribute||
this.serviceDescription.directionsTimeAttribute)},_getTimeNeutralAttribute:function(){var a=(this._getDirectionsTimeAttribute()||{}).timeNeutralAttributeName;return this._getCostAttribute(a)},_getCostAttribute:function(a){for(var c=this.serviceDescription&&this.serviceDescription.networkDataset.networkAttributes||[],f,x=0;x<c.length;x++)if(c[x].name===a&&"esriNAUTCost"===c[x].usageType){f=c[x];break}return f},_convertCostValue:function(a,c,f){var x=this._isTimeUnits(c),q=this._isTimeUnits(f);c=x?
this._toMinutes(a,c):this._toMeters(a,c);return x===q?q?this._fromMinutes(c,f):this._fromMeters(c,f):a},_toMinutes:function(a,c,f){a=a||0;switch(c){case "milliseconds":a/=Math.pow(6E4,f?-1:1);break;case "esriNAUSeconds":a/=Math.pow(60,f?-1:1);break;case "esriNAUHours":a*=Math.pow(60,f?-1:1);break;case "esriNAUDays":a*=Math.pow(1440,f?-1:1)}return a},_fromMinutes:function(a,c){return this._toMinutes(a,c,!0)},_toMeters:function(a,c,f){a=a||0;switch((c||"").replace("esriNAU","esri")){case "esriInches":a*=
Math.pow(.0254,f?-1:1);break;case "esriFeet":a*=Math.pow(.3048,f?-1:1);break;case "esriYards":a*=Math.pow(.9144,f?-1:1);break;case "esriMiles":a*=Math.pow(1609.344,f?-1:1);break;case "esriNauticalMiles":a*=Math.pow(1851.995396854,f?-1:1);break;case "esriMillimeters":a/=Math.pow(1E3,f?-1:1);break;case "esriCentimeters":a/=Math.pow(100,f?-1:1);break;case "esriKilometers":a*=Math.pow(1E3,f?-1:1);break;case "esriDecimeters":a/=Math.pow(10,f?-1:1)}return a},_fromMeters:function(a,c){return this._toMeters(a,
c,!0)},_createRouteTask:function(){var a=new C;this.set("routeTask",new Qa(this.get("routeTaskUrl")));this._createRouteParams();this.routeTask.getServiceDescription(this.travelModesServiceUrl,this.doNotFetchTravelModesFromOwningSystem).then(g.hitch(this,function(c){c.networkDataset?(this.set("serviceDescription",c),this.set("maxStops",parseInt(this.userOptions.maxStops||c.serviceLimits&&c.serviceLimits.Route_MaxStops||this.defaults.maxStops)),this.defaults.portalUrl?(this.owningSystemUrl=this.defaults.portalUrl,
a.resolve()):this.routeTask.getOwningSystemUrl().then(g.hitch(this,function(f){this.owningSystemUrl=f;a.resolve()}),a.reject)):(this._showMessage(G.widgets.directions.error.cantFindRouteServiceDescription),a.reject(Error(G.widgets.directions.error.cantFindRouteServiceDescription)))}),g.hitch(this,function(){this._showMessage(G.widgets.directions.error.cantFindRouteServiceDescription);a.reject(Error(G.widgets.directions.error.cantFindRouteServiceDescription));this.mapClickActive=!1;this._activate()}));
return a.promise},_createSearchSourceDDL:function(){if(this._globalGeocoder&&this._globalGeocoder.sources&&1<this._globalGeocoder.sources.length){var a=g.hitch(this,function(x){this._searchSourceSelector.domNode.blur();this._globalGeocoder.set("activeSourceIndex",x);for(var q=0;q<this.geocoders.length;q++)this.geocoders[q].set("activeSourceIndex",x);this._truncateSearchSourceIfNeeded()});if(!this._searchSourceSelector){for(var c=[{value:"all",label:G.widgets.Search.main.all,selected:!0}],f=0;f<this._globalGeocoder.sources.length;f++)c.push({value:String(f),
label:this._globalGeocoder.sources[f].name});this._searchSourceSelector=new t({className:"esriSearchSourcesDDL",style:"width:100%;",options:c},this._searchSourceSelectorContainer);this._searchSourceSelector.startup();this._searchSourceSelector.on("change",a);this._searchSourceSelector.domNode.style.width=""}a("all")}else 2>this._globalGeocoder.sources.length&&(this._searchSourceContainerNode.style.display="none")},_createTravelModesDDL:function(){this._travelModeSelector||(this._travelModeSelector=
new t({className:"esriTravelModesDDL",style:"width:100%;"},this._travelModeSelectorContainer),this._travelModeSelector.startup(),this._travelModeSelector._interractive=!0,this._travelModeSelector.on("change",g.hitch(this,function(a){this._travelModeSelector._interractive?this._enqueue(function(){return this._setTravelMode(a).always(g.hitch(this,function(){this._travelModeSelector._interractive=!0}))}):this._travelModeSelector._interractive=!0})))},_setupTravelModes:function(){var a=this.get("serviceDescription"),
c=a.supportedTravelModes,f=new C;if(c&&c.length&&this._travelModeSelector){for(var x=c[0].name,q=[],K=0;K<c.length;K++){for(var R="AUTOMOBILE"===c[K].type?"Driving":"TRUCK"===c[K].type?"Trucking":"WALK"===c[K].type?"Walking":"Other",V="",X=a.networkDataset.networkAttributes,ha=0;ha<X.length;ha++){var ia=X[ha];if(ia.name===c[K].impedanceAttributeName){if("esriNAUCentimeters"===ia.units||"esriNAUDecimalDegrees"===ia.units||"esriNAUDecimeters"===ia.units||"esriNAUFeet"===ia.units||"esriNAUInches"===
ia.units||"esriNAUKilometers"===ia.units||"esriNAUMeters"===ia.units||"esriNAUMiles"===ia.units||"esriNAUMillimeters"===ia.units||"esriNAUNauticalMiles"===ia.units||"esriNAUYards"===ia.units)V="Distance";else if("esriNAUDays"===ia.units||"esriNAUHours"===ia.units||"esriNAUMinutes"===ia.units||"esriNAUSeconds"===ia.units)V="Time";break}}q.push({id:c[K].name,label:'\x3cdiv class\x3d"esriTravelModesDirectionsIcon esriTravelModesType'+R+V+'"\x3e\x26nbsp;\x3c/div\x3e\x3cdiv class\x3d"esriTravelModesTypeName" title\x3d"'+
c[K].description+'"\x3e'+c[K].name+"\x3c/div\x3e"});!a.defaultTravelMode||c[K].id!==a.defaultTravelMode&&c[K].itemId!==a.defaultTravelMode||(x=c[K].name)}this._showTravelModesOption();this._travelModeSelector.setStore(new d({objectStore:new e({data:q})}));this._travelModeSelector._interractive=!1;this._travelModeSelector.setValue(x);this._setTravelMode(x).always(f.resolve)}else this._checkStartTimeUIAvailability(),this.set("showTravelModesOption",!1),f.resolve();return f.promise},_createPrintTask:function(){this._printService=
(this.printTaskUrl=this._usingAGOL()?this.printTaskUrl:this.defaults.printTaskUrl)?new Sa(this.printTaskUrl,{async:!1}):null;var a=new fb;a.exportOptions={width:670,height:750,dpi:96};a.format="PNG32";a.layout="MAP_ONLY";a.preserveScale=!1;a.showAttribution=!1;var c=new Va;c.map=this.map;c.outSpatialReference=this.map.spatialReference;c.template=a;this._printParams=c},_createGeometryTask:function(){this._geometryService=null;this._usingAGOL()?this._geometryService=new Ba(this.geometryTaskUrl):this.geometryTaskUrl=
(this._geometryService=this.defaults.geometryTaskUrl?new Ba(this.defaults.geometryTaskUrl):gb.defaults.geometryService)?this._geometryService.url:null},_showTravelModesOption:function(){var a=this.get("serviceDescription");J.set(this._travelModeContainerNode,"display",this.showTravelModesOption&&a&&a.supportedTravelModes&&a.supportedTravelModes.length&&!this.doNotFetchTravelModesFromOwningSystem?"block":"none")},_showMilesKilometersOption:function(){J.set(this._agolDistanceUnitsNode,"display",this.showMilesKilometersOption?
"block":"none")},_showClearButton:function(){J.set(this._clearDirectionsButtonNode,"display",this.showClearButton?"inline-block":"none")},_showActivateButton:function(){J.set(this._activateButtonNode,"display",this.showActivateButton?"inline-block":"none");this.showActivateButton||this.deactivate()},_showBarriersButton:function(){J.set(this._lineBarrierButtonNode,"display",this.showBarriersButton?"inline-block":"none");this.showBarriersButton||this.deactivateBarrierTool()},_createRouteParams:function(){var a=
{returnDirections:!0,returnRoutes:!1,outputLines:"esriNAOutputLineTrueShape",preserveFirstStop:!0,preserveLastStop:!0,directionsOutputType:"complete",stops:new Aa,ignoreInvalidLocations:!0,doNotLocateOnRestrictedElements:!0,outSpatialReference:this.get("map").spatialReference};this.get("routeParams")||(this.routeParams={});var c=new Ma;this.routeParams=g.mixin(c,{outputGeometryPrecision:0,outputGeometryPrecisionUnits:"esriMeters",restrictUTurns:"esriNFSBAtDeadEndsOnly"},this.get("routeParams"),a)},
_markWPsForRemovalAfterUserChangedStopSequence:function(a,c){for(var f=a-1,x=[];0<=f&&this._isStopAWaypoint(this.stops[f]);)x.push(this.stops[f]),f--;for(f=a+1;f<this.stops.length&&this._isStopAWaypoint(this.stops[f]);)x.push(this.stops[f]),f++;if(c>a)for(f=c+1;f<this.stops.length&&this._isStopAWaypoint(this.stops[f]);)x.push(this.stops[f]),f++;else if(void 0!==c)for(f=c-1;0<=f&&this._isStopAWaypoint(this.stops[f]);)x.push(this.stops[f]),f--;else if(this.returnToStart&&0===a)for(f=this.stops.length-
1;0<=f&&this._isStopAWaypoint(this.stops[f]);)x.push(this.stops[f]),f--;return x},_removeSomeWaypoints:function(a){for(var c=new C,f=[],x=0;x<a.length;x++){var q=O.indexOf(this.stops,a[x]);-1<q&&f.push(this._removeStop(q,!0,!0))}ea(f).always(c.resolve);return c.promise},_modifyStopSequence:function(a,c){var f=this._dnd.getAllNodes(),x=new C,q,K=[];if(f.length)if(this._removeLocateButtonVisibilityEvents(),arguments.length&&void 0!==a)if(0<=a&&0<=c&&a<this.stops.length&&c<this.stops.length&&a!==c){f=
this._markWPsForRemovalAfterUserChangedStopSequence(a,c);var R=this.stops.splice(a,1);this.stops.splice(c,0,R[0]);for(q=0;q<this.stops.length;q++)K.push(this._updateStop(this.stops[q],q));K.push(this._removeSomeWaypoints(f));ea(K).always(g.hitch(this,function(){this._solveAndZoom().always(x.resolve)}))}else x.reject("Invalid From and To values.");else{for(q=0;q<this.stops.length;)this._isStopAWaypoint(this.stops[q])?K.push(this._removeStop(q,!0,!0)):q++;ea(K).always(g.hitch(this,function(){K=[];this.stops.reverse();
for(q=0;q<this.stops.length;q++)K.push(this._updateStop(this.stops[q],q));ea(K).always(g.hitch(this,function(){this._solveAndZoom().always(x.resolve)}))}))}else x.resolve();return x.promise},_setMenuNodeValues:function(a){"traffic"!==a&&this._clearDisplayBeforeSolve();a=this.get("optimalRoute");this._findOptimalOrderNode&&S.set(this._findOptimalOrderNode,"checked",a);this._returnToStartNode&&(a=this.returnToStart&&!this.maxStopsReached&&this.stops[0]&&(!this.stops[0].feature||this._isStopLocated(this.stops[0])),
S.set(this._returnToStartNode,"checked",a),this.set("returnToStart",a),this.maxStopsReached&&this.returnToStart&&this._showMessage(G.widgets.directions.error.maximumStops));if(!this.returnToStart&&!this._incrementalSolveStopRange&&this.directions)for(this._incrementalSolveStopRange={start:this.stops.length-1,end:this.stops.length},this._clearRouteGraphics(),this._incrementalSolveStopRange=null,a=this.stops.length;0<a--&&this._isStopAWaypoint(this.stops[a]);)this._removeSomeWaypoints([this.stops[a]]);
this._useTrafficNode&&(S.set(this._useTrafficNode,"checked",this.traffic),this.traffic?(this._updateMapTimeExtent(),this._addTrafficLayer()):(this._removeTrafficLayer(),this._restoreMapTimeExtent()));switch(this.get("directionsLengthUnits")){case W.KILOMETERS:S.set(this._useKilometersNode,"checked",!0);S.set(this._useMilesNode,"checked",!1);break;case W.MILES:S.set(this._useKilometersNode,"checked",!1),S.set(this._useMilesNode,"checked",!0)}J.set(this._printButton,"display",this.showPrintPage?"inline-block":
"none");J.set(this._saveMenuButton,"display",this.showSaveButton&&this.owningSystemUrl?"inline-block":"none");this._showMilesKilometersOption();this._showClearButton()},_optionsMenu:function(){this._useTrafficItemNode&&J.set(this._useTrafficItemNode,"display",this.get("showTrafficOption")?"block":"none");this._returnToStartItemNode&&J.set(this._returnToStartItemNode,"display",this.get("showReturnToStartOption")?"block":"none");this._findOptimalOrderItemNode&&J.set(this._findOptimalOrderItemNode,"display",
this.get("showOptimalRouteOption")&&3<this._getStopCount()?"block":"none");this.stops.length>=this.get("minStops")?U.add(this._widgetContainer,this._css.stopsOptionsOptionsEnabledClass):(U.remove(this._widgetContainer,this._css.stopsOptionsOptionsEnabledClass),this._optionsMenuNode&&"block"===J.get(this._optionsMenuNode,"display")&&this._toggleOptionsMenu())},_stopsRemovable:function(){2<this._dnd.getAllNodes().length-this._getWaypointCount()?U.add(this._widgetContainer,this._css.stopsRemovableClass):
U.remove(this._widgetContainer,this._css.stopsRemovableClass)},_checkMaxStops:function(){this.set("maxStopsReached",this._getStopCount()+this._getWaypointCount()+(this.returnToStart?1:0)>=this.maxStops);this._showAddDestination()},_updateThemeWatch:function(a,c,f){U.remove(this.domNode,c);U.add(this.domNode,f)},_toggleOptionsMenu:function(){"block"===J.get(this._optionsMenuNode,"display")?(J.set(this._optionsMenuNode,"display","none"),U.remove(this._optionsButtonNode,"esriStopsOptionsOpen"),this._optionsButtonNode.innerHTML=
G.widgets.directions.showOptions):(J.set(this._optionsMenuNode,"display","block"),U.add(this._optionsButtonNode,"esriStopsOptionsOpen"),this._optionsButtonNode.innerHTML=G.widgets.directions.hideOptions)},_toggleSaveMenu:function(a){"block"===J.get(this._saveMenuNode,"display")||!1===a?(J.set(this._saveMenuNode,"display","none"),U.remove(this._saveMenuButton,this._css.stopsPressedButtonClass)):(this.clearMessages(),J.set(this._saveMenuNode,"display","block"),U.add(this._saveMenuButton,this._css.stopsPressedButtonClass),
this._enableSharing().then(g.hitch(this,function(){this._outputLayer.setValue(this.routeLayer.title?this.routeLayer.title:this.directions&&this.directions.routeName);if(this.routeLayer.ownerFolder)for(var c=this._folderSelector.store.objectStore.data,f=0;f<c.length;f++)if(c[f].folderId===this.routeLayer.ownerFolder){this._folderSelector.getValue()!==c[f].id&&(this._folderSelector._interractive=!1,this._folderSelector.setValue(c[f].id));break}this._enableButton(this._saveButton,this.routeLayer.isItemOwner||
!this._userCanCreatePortalItem);this._outputLayer.set("disabled",!1)})))},_showToolbar:function(){U[this.stops.length<this.maxStops&&this.canModifyStops||this.canModifyWaypoints?"add":"remove"].call(Z,this._widgetContainer,this._css.addStopsClass)},_showAddDestination:function(){this._showToolbar();this._addDestinationNode.style.display=this.stops.length<this.maxStops&&this.canModifyStops?"inline":"none"},_showMapClickActiveButton:function(){this._showToolbar();this._activateButtonNode.style.display=
this.canModifyStops||this.canModifyWaypoints?"inline-block":"none"},_getAbsoluteUrl:function(a){a=I.toUrl(a);return/^https?:/i.test(a)?a:/^\/\//i.test(a)?Ta+a:/^\//i.test(a)?Ta+"//"+window.location.host+a:a},_getManeuverImage:function(a){return a?"esriDMTStop"===a||"esriDMTDepart"===a?"":this._getAbsoluteUrl("./images/Directions/maneuvers/"+a+".png"):""},_loadPrintDirections:function(a){var c=this.get("printTemplate"),f=new C;this.directionsLengthUnits!==this.routeParams.directionsLengthUnits?this.getDirections().then(f.resolve,
f.reject):f.resolve();f.then(g.hitch(this,function(){if(!c&&this.directions){var x=this._getAbsoluteUrl("./css/Directions.css"),q=this._getAbsoluteUrl("./css/DirectionsPrint.css"),K=this._getAbsoluteUrl("./images/Directions/print-logo.png");var R=L.isBodyLtr()?"ltr":"rtl";c="";c+="\x3c!DOCTYPE HTML\x3e";c+='\x3chtml lang\x3d"en" class\x3d"'+this.get("theme")+'" dir\x3d"'+R+'"\x3e';c+="\x3chead\x3e";c+='\x3cmeta charset\x3d"utf-8"\x3e';c+='\x3cmeta http-equiv\x3d"X-UA-Compatible" content\x3d"IE\x3dEdge,chrome\x3d1"\x3e';
c+="\x3ctitle\x3e"+this.get("directions").routeName+"\x3c/title\x3e";c+='\x3clink rel\x3d"stylesheet" media\x3d"screen" type\x3d"text/css" href\x3d"'+x+'" /\x3e';c+='\x3clink rel\x3d"stylesheet" media\x3d"print" type\x3d"text/css" href\x3d"'+q+'" /\x3e';c+="\x3c/head\x3e";c+='\x3cbody class\x3d"'+this._css.esriPrintPageClass+'"\x3e';c+='\x3cdiv class\x3d"'+this._css.esriPrintBarClass+'"\x3e';c+='\x3cdiv class\x3d"'+this._css.esriCloseButtonClass+'" title\x3d"'+G.common.close+'" onclick\x3d"window.close();"\x3e'+
G.common.close+"\x3c/div\x3e";c+='\x3cdiv id\x3d"printButton" class\x3d"'+this._css.esriPrintButtonClass+'" title\x3d"'+G.widgets.directions.print+'" onclick\x3d"window.print();"\x3e'+G.widgets.directions.print+"\x3c/div\x3e";c+="\x3c/div\x3e";c+='\x3cdiv class\x3d"'+this._css.esriPrintMainClass+'"\x3e';c+='\x3cdiv class\x3d"'+this._css.esriPrintHeaderClass+'"\x3e';c+='\x3cimg class\x3d"'+this._css.esriPrintLogoClass+'" src\x3d"'+K+'" /\x3e';c+='\x3cdiv class\x3d"'+this._css.esriPrintNameClass+'"\x3e'+
this.get("directions").routeName+"\x3c/div\x3e";c+=this._renderDirectionsSummary(this.directions);a&&(c+='\x3cdiv id\x3d"divMap" class\x3d"esriPrintMap esriPrintWait"\x3e\x3c/div\x3e',c+='\x3chr class\x3d"esriNoPrint"/\x3e');c+='\x3cdiv id\x3d"print_helper"\x3e\x3c/div\x3e';c+='\x3ctextarea onkeyup\x3d"document.getElementById(\'print_helper\').innerHTML\x3dthis.value;" id\x3d"print_area" class\x3d"'+this._css.esriPrintNotesClass+'" placeholder\x3d"'+G.widgets.directions.printNotes+'"\x3e\x3c/textarea\x3e';
c+='\x3cdiv class\x3d"'+this._css.clearClass+'"\x3e\x3c/div\x3e';c+="\x3c/div\x3e";c+='\x3cdiv class\x3d"'+this._css.esriPrintDirectionsClass+'"\x3e';c+=this._renderDirectionsTable(this.directions);c+="\x3c/div\x3e";c+='\x3cdiv class\x3d"'+this._css.esriPrintFooterClass+'"\x3e';c+="\x3cp\x3e"+G.widgets.directions.printDisclaimer+"\x3c/p\x3e";c+="\x3c/div\x3e";c+="\x3c/div\x3e";c+="\x3c/body\x3e";c+="\x3c/html\x3e"}this._printWindow.document.open("text/html","replace");this._printWindow.document.write(c);
this._printWindow.document.close()}))},resize:function(){this._truncateSearchSourceIfNeeded()},_truncateSearchSourceIfNeeded:function(){var a=this._searchSourceSelector,c=a.containerNode.firstChild;a.domNode.clientWidth>this.domNode.clientWidth?J.set(c,"width",this._searchSourceContainerNode.clientWidth-20+"px"):J.set(c,"width","")},_printDirections:function(){if(this.directions){var a=screen.width/2,c=screen.height/1.5;a="toolbar\x3dno, location\x3dno, directories\x3dno, status\x3dyes, menubar\x3dno, scrollbars\x3dyes, resizable\x3dyes, width\x3d"+
a+", height\x3d"+c+", top\x3d"+(screen.height/2-c/2)+", left\x3d"+(screen.width/2-a/2);this.get("printPage")?(window.directions=this.get("directions"),window.open(this.get("printPage"),"directions_widget_print",a,!0)):(this._printWindow=window.open("","directions_widget_print",a,!0),this._loadPrintDirections(!!this._printService),this._printService&&I(["dojo/_base/window"],g.hitch(this,function(f){this.zoomToFullRoute().then(g.hitch(this,function(){this._printService.execute(this._printParams,g.hitch(this,
function(x){f.withDoc(this._printWindow.document,function(){var q=v.byId("divMap");q&&(U.remove(q,"esriPrintWait"),U.add(q,"esriPageBreak"),Z.create("img",{src:x.url,"class":"esriPrintMapImg"},q))})}),g.hitch(this,function(x){f.withDoc(this._printWindow.document,function(){var q=v.byId("divMap");q&&U.remove(q,"esriPrintWait")});console.error("Error while calling print service:\n "+x)}))}))})))}},_enableButton:function(a,c){c=c||void 0===c;U[c?"remove":"add"].apply(this,[a,"esriDisabledDirectionsButton"]);
a._enabled=c},_clearStopsStatusAttr:function(){for(var a=0;a<this.stops.length;a++)this.stops[a].feature&&this.stops[a].feature.attributes&&(this.stops[a].feature.attributes.Status=void 0)},_enableSharing:function(){var a=new C;!this._naRouteSharing&&this.owningSystemUrl?I(["../tasks/NARouteSharing"],g.hitch(this,function(c){this._naRouteSharing=new c(this.owningSystemUrl,this.map.spatialReference);this._folderSelector||(this._folderSelector=new t({className:"esriFoldersDDL",style:"width: 100%;",
sortByLabel:!1,disabled:!0,_interractive:!0,onChange:g.hitch(this,function(){this._folderSelector._interractive?this._enableButton(this._saveButton,!this.routeLayer.itemId):this._folderSelector._interractive=!0})},this._folderSelectorContainer),this._folderSelector.startup(),this._outputLayer=new k({style:"width: 100%",required:!0,trim:!0,regExp:'[^\x26|\x3c|\x3e|%|#|?|\\|"|/|+]+',maxLength:98,disabled:!0,onKeyPress:g.hitch(this,function(){this._enableButton(this._saveButton,!this.routeLayer.itemId||
!this._userCanCreatePortalItem)}),onFocus:g.hitch(this,function(){this.map&&this.map.disableKeyboardNavigation()}),onBlur:g.hitch(this,function(){this.map&&this.map.enableKeyboardNavigation()})},this._outputLayerContainer),this._outputLayer.startup());this._naRouteSharing.getFolders().then(g.hitch(this,function(f){for(var x=[],q=0;q<f.length;q++)x.push({id:f[q].url,folderId:f[q].id,label:f[q].title});this._folderSelector.setStore(new d({objectStore:new e({data:x})}));this._naRouteSharing.canCreateItem().then(g.hitch(this,
function(K){this._folderSelector.set("disabled",!K);this._userCanCreatePortalItem=K}));this._enableButton(this._saveButton);a.resolve()}),g.hitch(this,function(f){console.log(f);this._naRouteSharing=null;this._toggleSaveMenu(!1);a.reject(f)}))})):this.owningSystemUrl?a.resolve():(a.reject(Error("Owning system is not defined, or the Directions widget is not done initializing.")),this._naRouteSharing=null);return a.promise},_storeRouteUI:function(){var a=new C;this._outputLayer&&this._outputLayer.isValid()?
this._storeRoute(this._outputLayer.getValue(),this._folderSelector.getValue(),this._folderSelector.store.objectStore.get(this._folderSelector.getValue()).folderId).then(a.resolve,a.reject):(this._outputLayer&&this._outputLayer.focus(),a.reject(Error("Need result layer name specified.")));return a.promise},_storeRoute:function(a,c,f){var x=new C,q=this.directions;if(this._savingRoute||!this._naRouteSharing)return this._saveButton.blur(),x.reject(Error("Not ready to store route.")),x.promise;this.clearMessages();
x.then(null,g.hitch(this,function(xa){console.log("ERR",xa);this._showMessage(G.widgets.directions.error.cantSaveRoute)}));x.promise.always(g.hitch(this,function(){this._enableButton(this._saveButton);J.set(this._saveAsButton,"display",this.routeLayer.itemId&&this._userCanCreatePortalItem?"inline-block":"none");this._showLoadingSpinner();this._savingRoute=!1}));if(q&&q.features&&q.features.length&&this.stops&&this.stops.length)if(this.owningSystemUrl)if(this.routeParams&&this.routeParams.travelMode)if(a&&
c){var K=g.hitch(this,function(xa){return this._naRouteSharing.getAttributeUnits(xa,this.serviceDescription)});var R=this.routeParams.travelMode.timeAttributeName;var V=this.routeParams.travelMode.distanceAttributeName,X=K(R),ha=K(V),ia=this.routeParams.directionsLengthUnits||this.serviceDescription.directionsLengthUnits,ma=this._naRouteSharing.toMeters,na=this._naRouteSharing.toMinutes,wa=function(xa,Fa,Ka){var La;for(La in xa)if(xa.hasOwnProperty(La)&&0===La.indexOf(Fa)&&-1===O.indexOf(Ka,La.substr(Fa.length))){var Wa=
Wa||{};Wa[La.substr(Fa.length)]=xa[La]}return Wa},ua=[],Ca=[],Ha=[];if(R&&X&&V&&ha){var Pa=[],Ja=this.routeParams.accumulateAttributes||this.serviceDescription.accumulateAttributeNames||[],Ia=this.serviceDescription.networkDataset.networkAttributes;for(K=0;K<Ia.length;K++)"esriNAUTCost"===Ia[K].usageType&&-1===O.indexOf(Ja,Ia[K].name)&&Ia[K].name!==R&&Ia[K].name!==V&&Pa.push(Ia[K].name);Ja=this.get("stops");var Ga={xmin:Infinity,ymin:Infinity,xmax:-Infinity,ymax:-Infinity};for(K=0;K<Ja.length;K++)if(Ja[K].feature&&
Ja[K].feature.toJson){Ia=Ja[K].feature.toJson();var za=Ia.attributes;var Da=Ia.geometry,Na=this._naRouteSharing.getUTCOffset(za.ArriveTime,za.ArriveTimeUTC),Ra=this._naRouteSharing.getUTCOffset(za.DepartTime,za.DepartTimeUTC);g.mixin(Ga,{xmin:Ga.xmin>Da.x?Da.x:Ga.xmin,ymin:Ga.ymin>Da.y?Da.y:Ga.ymin,xmax:Ga.xmax<Da.x?Da.x:Ga.xmax,ymax:Ga.ymax<Da.y?Da.y:Ga.ymax});Ia.attributes={__OBJECTID:K+1,CurbApproach:za.CurbApproach,ArrivalCurbApproach:za.ArriveCurbApproach,DepartureCurbApproach:za.DepartCurbApproach,
Name:za.Name===this._waypointName?G.widgets.directions.waypoint:za.Name===this._userDefinedStopName?Ja[K].name:za.Name,RouteName:q.routeName,Sequence:za.Sequence,Status:za.Status,LocationType:za.isWaypoint?1:0,TimeWindowStart:za.TimeWindowStart,TimeWindowEnd:za.TimeWindowEnd,TimeWindowStartUTCOffset:Na,TimeWindowEndUTCOffset:Na,ServiceMinutes:na(za["Attr_"+R],X),ServiceMeters:ma(za["Attr_"+V],ha),ServiceCosts:Y.stringify(wa(za,"Attr_",Pa)),CumulativeMinutes:na(za["Cumul_"+R],X),CumulativeMeters:ma(za["Cumul_"+
V],ha),CumulativeCosts:Y.stringify(wa(za,"Cumul_",Pa)),LateMinutes:na(za["Violation_"+R],X),WaitMinutes:na(za["Wait_"+R],X),ArrivalTime:this._naRouteSharing.toUTCTime(za.ArriveTime,Na),DepartureTime:this._naRouteSharing.toUTCTime(za.DepartTime,Ra),ArrivalUTCOffset:Na,DepartureUTCOffset:Ra};ua.push(Ia)}V=0;ha=function(xa){try{xa.strings=Y.parse(xa.strings)}catch(Ka){Xa.strings=void 0}if(xa.strings&&xa.strings.length)for(var Fa=0;Fa<xa.strings.length;Fa++)if("esriDSTGeneral"===xa.strings[Fa].stringType)return xa.strings[Fa].string};
Ja=function(xa,Fa){for(var Ka=[],La=0;La<(xa||[]).length;La++)xa[La].stringType!==Fa&&Fa||Ka.push(xa[La].string);return Ka.length?Ka.toString():void 0};Ia=function(xa){switch(xa){case "esriDMTStop":return"esriDPTManeuverArrive";case "esriDMTDepart":return"esriDPTManeuverDepart";case "esriDMTDoorPassage":return"esriDPTManeuverDoor";case "esriDMTBearLeft":return"esriDPTManeuverBearLeft";case "esriDMTBearRight":return"esriDPTManeuverBearRight";case "esriDMTElevator":return"esriDPTManeuverElevator";case "esriDMTEscalator":return"esriDPTManeuverEscalator";
case "esriDMTFerry":return"esriDPTManeuverFerryOn";case "esriDMTEndOfFerry":return"esriDPTManeuverFerryOff";case "esriDMTForkCenter":return"esriDPTManeuverForkCenter";case "esriDMTForkLeft":return"esriDPTManeuverForkLeft";case "esriDMTForkRight":return"esriDPTManeuverForkRight";case "esriDMTPedestrianRamp":return"esriDPTManeuverPedestrianRamp";case "esriDMTRampLeft":return"esriDPTManeuverRampLeft";case "esriDMTRampRight":return"esriDPTManeuverRampRight";case "esriDMTRoundabout":return"esriDPTManeuverRoundabout";
case "esriDMTTurnLeft":return"esriDPTManeuverTurnLeft";case "esriDMTLeftLeft":return"esriDPTManeuverTurnLeftLeft";case "esriDMTLeftRight":return"esriDPTManeuverTurnLeftRight";case "esriDMTTurnRight":return"esriDPTManeuverTurnRight";case "esriDMTRightLeft":return"esriDPTManeuverTurnRightLeft";case "esriDMTRightRight":return"esriDPTManeuverTurnRightRight";case "esriDMTSharpLeft":return"esriDPTManeuverSharpLeft";case "esriDMTSharpRight":return"esriDPTManeuverSharpRight";case "esriDMTStraight":return"esriDPTManeuverStraight";
case "esriDMTStrairs":return"esriDPTManeuverStairs";case "esriDMTUTurn":return"esriDPTManeuverUTurn"}return"esriDPTUnknown"};for(K=0;K<q.featuresWithWaypoints.length;K++){var Ua=q.featuresWithWaypoints[K];Da=Ua.toJson();Na=Da.attributes;Ra=Da.geometry&&Da.geometry.paths&&Da.geometry.paths[0]||[];var bb=Da.geometry.hasM||Ra[0]&&3===Ra[0].length;za=this._naRouteSharing.getUTCOffset(Na.ETA,Na.arriveTimeUTC);Da.attributes={__OBJECTID:K+1,Sequence:++V,StopID:function(){var xa=void 0,Fa=Ua._associatedStopWithReturnToStart&&
Ua._associatedStopWithReturnToStart.attributes.Sequence;if(Fa)for(var Ka=0;Ka<ua.length;Ka++)if(ua[Ka].attributes.Sequence===Fa){xa=ua[Ka].attributes.__OBJECTID;break}return xa}(),DirectionPointType:Ia(Na.maneuverType),DisplayText:Ua._associatedStopWithReturnToStart&&Ua._associatedStopWithReturnToStart.attributes.isWaypoint?Na.text.replace(this._waypointName,G.widgets.directions.waypoint):Na.text,ArrivalTime:this._naRouteSharing.toUTCTime(Na.ETA,za),ArrivalUTCOffset:za,Azimuth:void 0,Name:Ja(q.stringsWithWaypoints[K],
"esriDSTStreetName"),AlternateName:Ja(q.stringsWithWaypoints[K],"esriDSTAltName"),ExitName:Ja(q.stringsWithWaypoints[K],"esriDSTExit"),IntersectingName:Ja(q.stringsWithWaypoints[K],"esriDSTCrossStreet"),BranchName:Ja(q.stringsWithWaypoints[K],"esriDSTBranch"),TowardName:Ja(q.stringsWithWaypoints[K],"esriDSTToward"),ShortVoiceInstruction:void 0,VoiceInstruction:void 0,Level:void 0};delete Da.symbol;delete Da.infoTemplate;Ra.length?(Da.geometry={x:Ra[0][0],y:Ra[0][1],spatialReference:Da.geometry.spatialReference},
bb&&g.mixin(Da.geometry,{m:Ra[0][2]})):delete Da.geometry;Ca.push(Da);Da=Ua.toJson();Na=Da.attributes;Ra=Da.geometry&&Da.geometry.paths&&Da.geometry.paths[0]||[];za=!0;for(R=0;R<Ra.length-1;R++)if(Ra[R][0]!==Ra[R+1][0]||Ra[R][1]!==Ra[R+1][1]){za=!1;break}za||(Da.attributes={DirectionPointID:K+1,DirectionLineType:"esriDLTSegment",Meters:ma(Na.length,ia),Minutes:na(Na.time,X),FromLevel:void 0,ToLevel:void 0},Da.geometry.hasM=bb,delete Da.symbol,delete Da.infoTemplate,Ha.push(Da));var Xa=q.eventsWithWaypoints[Da.attributes.Sequence]||
[];for(R=0;R<Xa.length;R++)Da=Xa[R].toJson(),Na=Da.attributes,za=this._naRouteSharing.getUTCOffset(Na.ETA,Na.arriveTimeUTC),Da.attributes={Sequence:++V,DirectionPointType:"esriDPTEvent",DisplayText:ha(Na),ArrivalTime:this._naRouteSharing.toUTCTime(Na.ETA,za),ArrivalUTCOffset:za,Name:Na.strings},Ca.push(Da)}R=this.routeParams.barriers&&this.routeParams.barriers.features||[];var cb=[];for(K=0;K<R.length;K++)V=R[K].toJson(),ha=V.attributes,V.attributes={BarrierType:ha.BarrierType||0,FullEdge:ha.FullEdge||
!1,AddedCost:ha["Attr_"+this._getImpedanceAttribute().name]||0,Costs:Y.stringify(wa(ha,"Attr_",Pa)),CurbApproach:ha.CurbApproach||0,Name:ha.Name},cb.push(V);R=this.routeParams.polylineBarriers&&this.routeParams.polylineBarriers.features||[];var db=[];for(K=0;K<R.length;K++)V=R[K].toJson(),ha=V.attributes,V.attributes={BarrierType:ha.BarrierType||0,ScaleFactor:ha["Attr_"+this._getImpedanceAttribute().name]||1,Costs:Y.stringify(wa(ha,"Attr_",Pa)),Name:ha.Name},db.push(V);R=this.routeParams.polygonBarriers&&
this.routeParams.polygonBarriers.features||[];var eb=[];for(K=0;K<R.length;K++)V=R[K].toJson(),ha=V.attributes,V.attributes={BarrierType:ha.BarrierType||0,ScaleFactor:ha["Attr_"+this._getImpedanceAttribute().name]||1,Costs:Y.stringify(wa(ha,"Attr_",Pa)),Name:ha.Name},eb.push(V);var hb={geometry:q.mergedGeometry,attributes:{RouteName:q.routeName,TotalMinutes:na(q.totalTime,X),TotalMeters:ma(q.totalLength,ia),TotalLateMinutes:function(){for(var xa=0,Fa=0;Fa<ua.length;Fa++)xa+=ua[Fa].attributes.LateMinutes||
0;return xa}(),TotalWaitMinutes:function(){for(var xa=0,Fa=0;Fa<ua.length;Fa++)xa+=ua[Fa].attributes.WaitMinutes||0;return xa}(),TotalCosts:ua[ua.length-1].attributes.CumulativeCosts,StartTime:"none"!==this.startTime?ua[0].attributes.ArrivalTime:null,EndTime:"none"!==this.startTime?ua[ua.length-1].attributes.DepartureTime:null,StartUTCOffset:ua[0].attributes.ArrivalUTCOffset,EndUTCOffset:ua[ua.length-1].attributes.DepartureUTCOffset,Messages:Y.stringify(this._solverMessages),AnalysisSettings:Y.stringify({travelMode:g.hitch(this,
function(){var xa=g.clone(this.routeParams.travelMode);"\x26lt;"===xa.name.substr(0,4)&&"\x26gt;"===xa.name.substr(xa.name.length-4,4)&&(xa.name=xa.name.substr(4,xa.name.length-8));return xa})(),directionsLanguage:this.routeParams.directionsLanguage||this.serviceDescription.directionsLanguage,startTimeIsUTC:this.routeParams.startTimeIsUTC,timeWindowsAreUTC:this.routeParams.timeWindowsAreUTC,findBestSequence:this.routeParams.findBestSequence,preserveFirstStop:this.routeParams.preserveFirstStop,preserveLastStop:this.routeParams.preserveLastStop,
accumulateAttributeNames:this.routeParams.accumulateAttributes||this.serviceDescription.accumulateAttributeNames})}};this._enableButton(this._saveButton,!1);this._savingRoute=!0;this._showLoadingSpinner(!0);g.hitch(this,function(){var xa=new C;this._printService?this.zoomToFullRoute().then(g.hitch(this,function(){var Fa=this._printParams.template,Ka=Fa.exportOptions;Fa.exportOptions={width:200,height:133,dpi:96};this._printService.execute(this._printParams,function(La){Fa.exportOptions=Ka;xa.resolve(La.url)},
function(La){Fa.exportOptions=Ka;console.error("Error while calling print service:\n "+La);xa.resolve()})})):xa.resolve();return xa.promise})().then(g.hitch(this,function(xa){var Fa={folder:c,name:a,stops:ua,directionPoints:Ca,directionLines:Ha,barriers:cb,polylineBarriers:db,polygonBarriers:eb,extent:g.mixin(g.clone(q.extent),{xmin:Ga.xmin>q.extent.xmin?q.extent.xmin:Ga.xmin,ymin:Ga.ymin>q.extent.ymin?q.extent.ymin:Ga.ymin,xmax:Ga.xmax<q.extent.xmax?q.extent.xmax:Ga.xmax,ymax:Ga.ymax<q.extent.ymax?
q.extent.ymax:Ga.ymax}),routeInfo:hb,thumbnail:xa};this._userCanCreatePortalItem?this._naRouteSharing.store(Fa,this.routeLayer.itemId,"1.0.0").then(g.hitch(this,function(Ka){if(Ka.success){var La=this._naRouteSharing.portal;La="//"+(La.isPortal?La.portalHostname:La.urlKey+"."+La.customBaseUrl);this._toggleSaveMenu();this._showMessage(G.widgets.directions.routeIsSaved+"\x3cbr/\x3e\x3ca class\x3d'esriLinkButton' target\x3d'_blank' href\x3d'"+La+"/home/item.html?id\x3d"+Ka.id+"'\x3e"+G.widgets.directions.share+
"\x3c/a\x3e",!0);if(this.routeLayer.itemId)this.onRouteItemUpdated(Ka.id);else this.onRouteItemCreated(Ka.id);g.mixin(this.routeLayer,{itemId:Ka.id,title:Fa.name,isItemOwner:!0,ownerFolder:f});x.resolve(Ka)}else x.reject(Ka)}),x.reject):this._naRouteSharing.createFeatureCollection(Fa,"1.0.0").then(g.hitch(this,function(Ka){x.resolve(Ka);this._toggleSaveMenu();this.onFeatureCollectionCreated(Ka)}),x.reject)}))}else x.reject(Error("Cannot deduce the impedance used."))}else x.reject(Error("Missing required parameter: layerName, folder must be specified."));
else x.reject(Error("Shared route must be built using a Travel Mode."));else x.reject(Error("Cannot store route: owning system to store routes is not defined. Please specify Portal or ArcGIS Online Url in constructor."));else x.reject(Error("No route to share. Build a route first."));return x.promise},_loadRoute:function(a){var c=new C;c.promise.always(g.hitch(this,function(){this._showLoadingSpinner(!1);J.set(this._saveAsButton,"display",this.routeLayer.itemId&&this._userCanCreatePortalItem?"inline-block":
"none");this._enableButton(this._saveButton,this.routeLayer.isItemOwner)}));this._reset().then(g.hitch(this,function(){this._showLoadingSpinner(!0);this._enableSharing().then(g.hitch(this,function(){var f=g.clone(this.serviceDescription),x=g.hitch(this,function(X){g.mixin(this.routeLayer,{itemId:a,title:X.title,isItemOwner:X.isItemOwner,ownerFolder:X.ownerFolder})}),q,K,R,V;f.directionsLengthUnits=this.directionsLengthUnits;this._naRouteSharing.load(a,f).then(g.hitch(this,function(X){if(X.routeParameters){g.mixin(this.routeParams,
X.routeParameters);this.routeParams.accumulateAttributes=X.routeParameters.accumulateAttributeNames;this.set("optimalRoute",this.routeParams.findBestSequence);this.startTime=this.routeParams.startTime?this.routeParams.startTime:"none";this._setStartTime(void 0,void 0,this.startTime);var ha=X.routeParameters.travelMode,ia=ha?this._getCostAttribute(ha.impedanceAttributeName):void 0;ia=ia?this._isTimeUnits(ia.units)?"Time":"Distance":"";V=f.supportedTravelModes&&f.supportedTravelModes.length?this._travelModeSelector.store.objectStore.data.slice():
[];if(canUseRouteLayerTM=1!==X.successCode&&ia){var ma="AUTOMOBILE"===ha.type?"Driving":"TRUCK"===ha.type?"Trucking":"WALK"===ha.type?"Walking":"Other";ha.name="\x26lt;"+ha.name+"\x26gt;";this.serviceDescription.supportedTravelModes=(f.supportedTravelModes||[]).concat(ha);V.push({id:ha.name,label:'\x3cdiv class\x3d"esriTravelModesDirectionsIcon esriTravelModesType'+ma+ia+'"\x3e\x26nbsp;\x3c/div\x3e\x3cdiv class\x3d"esriTravelModesTypeName"\x3e'+ha.name+"\x3c/div\x3e"});this._travelModeSelector.setStore(new d({objectStore:new e({data:V})}));
this._travelModeSelector._interractive=!1;this._travelModeSelector.setValue(ha.name)}else{ia=!1;if(ha&&ha.name)for(V=f.supportedTravelModes||[],q=0;q<V.length;q++)if(V[q].name===ha.name){ia=!0;this._travelModeSelector._interractive=!1;this._travelModeSelector.setValue(ha.name);this.routeParams.travelMode=V[q].impedanceAttributeName?V[q]:V[q].itemId;X.loadMessages.push({message:G.widgets.directions.error.tmFromPortalSameName+" "+ha.name,messageType:"Warning"});break}if(!ia)if((ha=f.defaultTravelMode)&&
V)for(q=0;q<V.length;q++){if(V[q].id===ha){this.routeParams.travelMode=V[q].impedanceAttributeName?V[q]:V[q].itemId;X.loadMessages.push({message:G.widgets.directions.error.tmFromPortalDefault+" "+(V[q].name?V[q].name:V[q].itemId),messageType:"Warning"});break}}else this.routeParams.travelMode=null}this._checkStartTimeUIAvailability()}if(X.solveResult&&X.solveResult.routeResults){var na=Infinity,wa=-Infinity;ha=X.solveResult.routeResults[0].stops;var ua=X.solveResult.routeResults[0].directions.features;
ia={};for(q=0;q<ha.length;q++){var Ca=ha[q].attributes;if(Ca.isWaypoint)for(K=0;K<ua.length;K++)ma=ua[K].attributes,ma._stopSequence===Ca.Sequence&&(ma.text=ma.text.replace(Ca.Name,this._waypointName));R=Ca.Name+"_"+this._stopSequence++;ia[R]=Ca.isWaypoint?this._waypointName:Ca.Name;Ca.Name=R;if(Ca.Sequence<na&&(null!==Ca.ArriveCurbApproach||null!==Ca.DepartCurbApproach)){var Ha=Ca.Name;na=Ca.Sequence}if(Ca.Sequence>wa&&(null!==Ca.ArriveCurbApproach||null!==Ca.DepartCurbApproach)){var Pa=Ca.Name;
wa=Ca.Sequence}}R=Ha+" - "+Pa;X.solveResult.routeResults[0].routeName=R;X.solveResult.routeResults[0].directions.routeName=R;for(q=0;q<ua.length;q++)if(ma=ua[q].attributes,void 0!==ma._stopSequence)for(K=0;K<ha.length;K++)if(ma._stopSequence===ha[K].attributes.Sequence){R=ha[K].attributes.Name;ma.text=(ma.text||"").replace(ia[R],R);delete ma._stopSequence;break}Ha=ha[ha.length-1];ha[0].geometry.x===Ha.geometry.x&&ha[0].geometry.y===Ha.geometry.y&&(this._returnToStartStop=this._addStopWrapperToGraphic(new u(Ha.geometry,
null,Ha.attributes),ia[Ha.attributes.Name]),this.set("returnToStart",!0));this._solveResultProcessing(X.solveResult,ia).then(g.hitch(this,function(){this._setStartTime(void 0,void 0,this.startTime);x(X);this.zoomToFullRoute();c.resolve(X)}),c.reject)}else{if(X.routeParameters){Ha=X.routeParameters.stops.features;this.stops=[];for(q=0;q<Ha.length;q++)this.stops.push(this._addStopWrapperToGraphic(Ha[q],Ha[q].attributes.Name)),this._updateStop(this.stops[q],q);this._setStops();X.loadMessages.push({message:G.widgets.directions.routeLayerStopsOnly,
messageType:"Warning"})}else X.loadMessages.push({message:G.widgets.directions.routeLayerEmpty,messageType:"Warning"});x(X);c.resolve(X)}for(q=0;q<X.loadMessages.length;q++)this._showMessage(X.loadMessages[q].message)}),g.hitch(this,function(X){c.reject(X);this._showMessage("GWM_0003"===X.messageCode?G.widgets.directions.error.accessDenied+this._naRouteSharing.portal.getPortalUser().username:G.widgets.directions.error.loadError)}))}),c.reject)}),c.reject);return c.promise}});y("extend-esri")&&g.setObject("dijit.Directions",
T,w);return T})},"dojo/data/ObjectStore":function(){define("../_base/lang ../Evented ../_base/declare ../_base/Deferred ../promise/all ../_base/array ../_base/connect ../regexp".split(" "),function(I,T,g,Q,O,M,H,F){function t(k){return"*"==k?".*":"?"==k?".":k}return g("dojo.data.ObjectStore",[T],{objectStore:null,constructor:function(k){this._dirtyObjects=[];k.labelAttribute&&(k.labelProperty=k.labelAttribute);I.mixin(this,k)},labelProperty:"label",getValue:function(k,A,m){return"function"===typeof k.get?
k.get(A):A in k?k[A]:m},getValues:function(k,A){k=this.getValue(k,A);return k instanceof Array?k:void 0===k?[]:[k]},getAttributes:function(k){var A=[],m;for(m in k)!k.hasOwnProperty(m)||"_"==m.charAt(0)&&"_"==m.charAt(1)||A.push(m);return A},hasAttribute:function(k,A){return A in k},containsValue:function(k,A,m){return-1<M.indexOf(this.getValues(k,A),m)},isItem:function(k){return"object"==typeof k&&k&&!(k instanceof Date)},isItemLoaded:function(k){return k&&"function"!==typeof k.load},loadItem:function(k){var A;
"function"===typeof k.item.load?Q.when(k.item.load(),function(m){A=m;var e=m instanceof Error?k.onError:k.onItem;e&&e.call(k.scope,m)}):k.onItem&&k.onItem.call(k.scope,k.item);return A},close:function(k){return k&&k.abort&&k.abort()},fetch:function(k){function A(h){k.onError&&k.onError.call(e,h,k)}k=I.delegate(k,k&&k.queryOptions);var m=this,e=k.scope||m,d=k.query;if("object"==typeof d){d=I.delegate(d);for(var r in d){var y=d[r];"string"==typeof y&&(d[r]=RegExp("^"+F.escapeString(y,"*?\\").replace(/\\.|\*|\?/g,
t)+"$",k.ignoreCase?"mi":"m"),d[r].toString=function(h){return function(){return h}}(y))}}var z=this.objectStore.query(d,k);Q.when(z.total,function(h){Q.when(z,function(v){k.onBegin&&k.onBegin.call(e,h||v.length,k);if(k.onItem)for(var L=0;L<v.length;L++)k.onItem.call(e,v[L],k);k.onComplete&&k.onComplete.call(e,k.onItem?null:v,k);return v},A)},A);k.abort=function(){z.cancel&&z.cancel()};z.observe&&(this.observing&&this.observing.cancel(),this.observing=z.observe(function(h,v,L){if(-1==M.indexOf(m._dirtyObjects,
h))if(-1==v)m.onNew(h);else if(-1==L)m.onDelete(h);else for(var J in h)if(J!=m.objectStore.idProperty)m.onSet(h,J,null,h[J])},!0));this.onFetch(z);k.store=this;return k},getFeatures:function(){return{"dojo.data.api.Read":!!this.objectStore.get,"dojo.data.api.Identity":!0,"dojo.data.api.Write":!!this.objectStore.put,"dojo.data.api.Notification":!0}},getLabel:function(k){if(this.isItem(k))return this.getValue(k,this.labelProperty)},getLabelAttributes:function(k){return[this.labelProperty]},getIdentity:function(k){return this.objectStore.getIdentity?
this.objectStore.getIdentity(k):k[this.objectStore.idProperty||"id"]},getIdentityAttributes:function(k){return[this.objectStore.idProperty]},fetchItemByIdentity:function(k){var A;Q.when(this.objectStore.get(k.identity),function(m){A=m;k.onItem.call(k.scope,m)},function(m){k.onError.call(k.scope,m)});return A},newItem:function(k,A){if(A){var m=this.getValue(A.parent,A.attribute,[]);m=m.concat([k]);k.__parent=m;this.setValue(A.parent,A.attribute,m)}this._dirtyObjects.push({object:k,save:!0});this.onNew(k);
return k},deleteItem:function(k){this.changing(k,!0);this.onDelete(k)},setValue:function(k,A,m){var e=k[A];this.changing(k);k[A]=m;this.onSet(k,A,e,m)},setValues:function(k,A,m){if(!I.isArray(m))throw Error("setValues expects to be passed an Array object as its value");this.setValue(k,A,m)},unsetAttribute:function(k,A){this.changing(k);var m=k[A];delete k[A];this.onSet(k,A,m,void 0)},changing:function(k,A){k.__isDirty=!0;for(var m=0;m<this._dirtyObjects.length;m++){var e=this._dirtyObjects[m];if(k==
e.object){A&&(e.object=!1,this._saveNotNeeded||(e.save=!0));return}}e=k instanceof Array?[]:{};for(m in k)k.hasOwnProperty(m)&&(e[m]=k[m]);this._dirtyObjects.push({object:!A&&k,old:e,save:!this._saveNotNeeded})},save:function(k){k=k||{};var A=[],m=[],e=this,d=this._dirtyObjects;try{H.connect(k,"onError",function(){if(!1!==k.revertOnError){var J=d;d=m;e.revert();e._dirtyObjects=J}else e._dirtyObjects=d.concat(m)});var r;this.objectStore.transaction&&(r=this.objectStore.transaction());for(var y=0;y<
d.length;y++){var z=d[y],h=z.object,v=z.old;delete h.__isDirty;if(h){var L=this.objectStore.put(h,{overwrite:!!v});A.push(L)}else"undefined"!=typeof v&&(L=this.objectStore.remove(this.getIdentity(v)),A.push(L));m.push(z);d.splice(y--,1)}O(A).then(function(J){k.onComplete&&k.onComplete.call(k.scope,J)},function(J){k.onError&&k.onError.call(k.scope,J)});r&&r.commit()}catch(J){k.onError.call(k.scope,value)}},revert:function(){for(var k=this._dirtyObjects,A=k.length;0<A;){A--;var m=k[A],e=m.object;m=
m.old;if(e&&m){for(var d in m)m.hasOwnProperty(d)&&e[d]!==m[d]&&(this.onSet(e,d,e[d],m[d]),e[d]=m[d]);for(d in e)m.hasOwnProperty(d)||(this.onSet(e,d,e[d]),delete e[d])}else if(m)this.onNew(m);else this.onDelete(e);delete (e||m).__isDirty;k.splice(A,1)}},isDirty:function(k){return k?k.__isDirty:!!this._dirtyObjects.length},onSet:function(){},onNew:function(){},onDelete:function(){},onFetch:function(k){}})})},"esri/tasks/RouteTask":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/has ../kernel ../graphic ../request ../geometry/normalizeUtils ./Task ./RouteResult ./NAMessage ./NAServiceDescription".split(" "),
function(I,T,g,Q,O,M,H,F,t,k,A,m){I=I([t,m],{declaredClass:"esri.tasks.RouteTask",_eventMap:{"solve-complete":["result"]},constructor:function(e){this._url.orig=this._url.path;this._url.path+="/solve";this._handler=T.hitch(this,this._handler);this.registerConnectEvents()},__msigns:[{n:"solve",c:3,a:[{i:0,p:["stops.features","barriers.features","polylineBarriers.features","polygonBarriers.features"]}],e:2}],_handler:function(e,d,r,y,z){try{var h=[],v=[],L=e.directions||[],J=e.routes?e.routes.features:
[],U=e.stops?e.stops.features:[],S=e.barriers?e.barriers.features:[],N=e.polygonBarriers?e.polygonBarriers.features:[],D=e.polylineBarriers?e.polylineBarriers.features:[],G=e.messages,aa=g.forEach,ca=g.indexOf,Z=!0,ea,C,da=e.routes&&e.routes.spatialReference||e.stops&&e.stops.spatialReference||e.barriers&&e.barriers.spatialReference||e.polygonBarriers&&e.polygonBarriers.spatialReference||e.polylineBarriers&&e.polylineBarriers.spatialReference;this._chk=e.checksum;aa(L,function(n){h.push(ea=n.routeName);
v[ea]={directions:n}});aa(J,function(n){-1===ca(h,ea=n.attributes.Name)&&(h.push(ea),v[ea]={});v[ea].route=n});aa(U,function(n){C=n.attributes;-1===ca(h,ea=C.RouteName||"esri.tasks.RouteTask.NULL_ROUTE_NAME")&&(h.push(ea),v[ea]={});"esri.tasks.RouteTask.NULL_ROUTE_NAME"!==ea&&(Z=!1);void 0===v[ea].stops&&(v[ea].stops=[]);v[ea].stops.push(n)});0<U.length&&!0===Z&&(v[h[0]].stops=v["esri.tasks.RouteTask.NULL_ROUTE_NAME"].stops,delete v["esri.tasks.RouteTask.NULL_ROUTE_NAME"],h.splice(g.indexOf(h,"esri.tasks.RouteTask.NULL_ROUTE_NAME"),
1));var Y=[];aa(h,function(n,u){v[n].routeName="esri.tasks.RouteTask.NULL_ROUTE_NAME"===n?null:n;v[n].spatialReference=da;Y.push(new k(v[n]))});e=function(n){aa(n,function(u,W){u.geometry&&(u.geometry.spatialReference=da);n[W]=new M(u)});return n};aa(G,function(n,u){G[u]=new A(n)});var w={routeResults:Y,barriers:e(S),polygonBarriers:e(N),polylineBarriers:e(D),messages:G};this._successHandler([w],"onSolveComplete",r,z)}catch(n){this._errorHandler(n,y,z)}},solve:function(e,d,r,y){var z=y.assembly;e=
this._encode(T.mixin({},this._url.query,{f:"json"},e.toJson(z&&z[0]),this._chk?{checksum:this._chk}:{}));var h=this._handler,v=this._errorHandler;return H({url:this._url.path,timeout:25E4,content:e,callbackParamName:"callback",load:function(L,J){h(L,J,d,r,y.dfd)},error:function(L){v(L,r,y.dfd)}})},onSolveComplete:function(){}});F._createWrappers(I);Q("extend-esri")&&T.setObject("tasks.RouteTask",I,O);return I})},"esri/tasks/RouteResult":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/has ../kernel ../graphic ./DirectionsFeatureSet".split(" "),
function(I,T,g,Q,O,M,H){I=I(null,{declaredClass:"esri.tasks.RouteResult",constructor:function(F){var t=F.spatialReference,k=F.route;if(F.directions){var A=[],m=[],e=[];g.forEach(F.directions.features,function(r,y){m[y]=r.compressedGeometry;A[y]=r.strings;e[y]=r.events});F.directions.strings=A;F.directions.events=e;this.directions=new H(F.directions,m)}this.routeName=F.routeName;k&&(k.geometry&&(k.geometry.spatialReference=t),this.route=new M(k));if(F.stops){var d=this.stops=[];g.forEach(F.stops,function(r,
y){r.geometry&&(r.geometry.spatialReference=t);d[r.attributes.Sequence-1]=new M(r)})}},routeName:null,directions:null,route:null,stops:null});Q("extend-esri")&&T.setObject("tasks.RouteResult",I,O);return I})},"esri/tasks/DirectionsFeatureSet":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/has dojo/json ../kernel ../geometry/Extent ../geometry/Polyline ../geometry/Point ../graphic ./FeatureSet".split(" "),function(I,T,g,Q,O,M,H,F,t,k,A){I=I(A,{declaredClass:"esri.tasks.DirectionsFeatureSet",
constructor:function(m,e){this.routeId=m.routeId;this.routeName=m.routeName;T.mixin(this,m.summary);this.extent=new H(this.envelope);var d=this._fromCompressedGeometry,r=this.features,y=this.extent.spatialReference,z=[];g.forEach(e,function(h,v){r[v].setGeometry(z[v]=h?d(h,y):r[v].geometry)});this.mergedGeometry=this._mergePolylinesToSinglePath(z,y);this.geometryType="esriGeometryPolyline";g.forEach(m.events,function(h,v){g.forEach(h,function(L,J){h[J]=new k(new t(L.point.x,L.point.y,y),null,{ETA:L.ETA,
strings:O.stringify(L.strings),arriveTimeUTC:L.arriveTimeUTC})});m.events[v]=h});delete this.envelope},_fromCompressedGeometry:function(m,e){var d=0,r=0,y=0,z=0,h=[],v=0,L=0,J=0;(m=m.match(/((\+|\-)[^\+\-\|]+|\|)/g))||(m=[]);if(0===parseInt(m[v],32)){v=2;var U=parseInt(m[v],32);v++;var S=parseInt(m[v],32);v++;if(U&1){L=g.indexOf(m,"|")+1;var N=parseInt(m[L],32);L++}if(U&2){J=g.indexOf(m,"|",L)+1;var D=parseInt(m[J],32);J++}}else S=parseInt(m[v],32),v++;for(;v<m.length&&"|"!==m[v];){U=parseInt(m[v],
32)+d;v++;d=U;var G=parseInt(m[v],32)+r;v++;r=G;U=[U/S,G/S];L&&(G=parseInt(m[L],32)+y,L++,y=G,U.push(G/N));J&&(G=parseInt(m[J],32)+z,J++,z=G,U.push(G/D));h.push(U)}d=new F({paths:[h],hasZ:0<L,hasM:0<J});d.setSpatialReference(e);return d},_mergePolylinesToSinglePath:function(m,e){var d=[],r=!1;g.forEach(m,function(h){g.forEach(h.paths,function(v){r=r||h.hasM;d=d.concat(v)})});var y=[],z=[0,0];g.forEach(d,function(h){if(h[0]!==z[0]||h[1]!==z[1])y.push(h),z=h});return new F({paths:[y],spatialReference:e,
hasM:r})}});Q("extend-esri")&&T.setObject("tasks.DirectionsFeatureSet",I,M);return I})},"esri/tasks/NAMessage":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel"],function(I,T,g,Q){I=I(null,{declaredClass:"esri.tasks.NAMessage",constructor:function(O){T.mixin(this,O)}});T.mixin(I,{TYPE_INFORMATIVE:0,TYPE_PROCESS_DEFINITION:1,TYPE_PROCESS_START:2,TYPE_PROCESS_STOP:3,TYPE_WARNING:50,TYPE_ERROR:100,TYPE_EMPTY:101,TYPE_ABORT:200});g("extend-esri")&&T.setObject("tasks.NAMessage",
I,Q);return I})},"esri/tasks/NAServiceDescription":function(){define(["dojo/_base/declare","dojo/json","dojo/Deferred","dojo/_base/lang","../request"],function(I,T,g,Q,O){return I(null,{declaredClass:"esri.tasks._NAServiceDescription",_sd:null,getServiceDescription:function(M,H){var F=new g;if(this._sd)F.resolve(this._sd);else if(this._url&&this._url.orig){var t=this._url.orig,k=(this._url.path.match(/\/solve$/)||[]).length?"Route":(this._url.path.match(/\/solveClosestFacility$/)||[]).length?"ClosestFacility":
"ServiceAreas",A,m=function(e){O({url:e+("/"===e[e.length-1]?"":"/")+"GetTravelModes/execute",content:{f:"json",serviceName:k},callbackParamName:"callback"}).then(function(d){var r=[],y=null;if(d&&d.results&&d.results.length)for(var z=0;z<d.results.length;z++)if("supportedTravelModes"===d.results[z].paramName){if(d.results[z].value&&d.results[z].value.features)for(var h=0;h<d.results[z].value.features.length;h++)if(d.results[z].value.features[h].attributes){var v=T.parse(d.results[z].value.features[h].attributes.TravelMode);
r.push(v)}}else"defaultTravelMode"===d.results[z].paramName&&(y=d.results[z].value);A.supportedTravelModes=r;A.defaultTravelMode=y;F.resolve(A)},function(d){console.log("Could not read from the routingUtilities service.");F.reject(d)})};O({url:t,content:{f:"json"},callbackParamName:"callback"}).then(function(e){A=e;A.supportedTravelModes||(A.supportedTravelModes=[]);for(e=0;e<A.supportedTravelModes.length;e++)A.supportedTravelModes[e].id||(A.supportedTravelModes[e].id=A.supportedTravelModes[e].itemId);
H?F.resolve(A):M?m(M):10.4<=A.currentVersion?O({url:t+("/"===t[t.length-1]?"":"/")+"retrieveTravelModes",content:{f:"json"},callbackParamName:"callback"}).then(function(d){A.supportedTravelModes=d.supportedTravelModes;A.defaultTravelMode=d.defaultTravelMode;F.resolve(A)},function(d){console.log("Could not get to the NAServer's retrieveTravelModes.");F.reject(d)}):O({url:t.substring(0,t.indexOf("/rest/")+6)+"info",content:{f:"json"},callbackParamName:"callback"}).then(function(d){d.owningSystemUrl?
(t=d.owningSystemUrl,O({url:t+("/"===t[t.length-1]?"":"/")+"sharing/rest/portals/self",content:{f:"json"},callbackParamName:"callback"}).then(function(r){r&&r.helperServices&&r.helperServices.routingUtilities&&r.helperServices.routingUtilities.url?m(r.helperServices.routingUtilities.url):(console.log("Portal does not have helperServices.routingUtilities defined."),F.resolve(A))},function(r){console.log("Could not get to the portal's self.");F.reject(r)})):F.resolve(A)},function(d){console.log("Could not get to the NAServer service description.");
F.reject(d)})},function(e){F.reject(e)})}else F.reject("NA Task has no URL specified.");F.then(Q.hitch(this,function(e){this._sd=e}),Q.hitch(this,function(){this._sd=null}));return F.promise},getOwningSystemUrl:function(){var M=new g;if(this._url&&this._url.orig){var H=this._url.orig;O({url:H.substring(0,H.indexOf("/rest/")+6)+"info",content:{f:"json"},callbackParamName:"callback"}).promise.always(function(F){M.resolve(F.owningSystemUrl)})}else M.resolve(void 0);return M.promise}})})},"esri/tasks/RouteParameters":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/json dojo/has ../kernel ../lang ../graphicsUtils ./NATypes".split(" "),
function(I,T,g,Q,O,M,H,F){I=I(null,{declaredClass:"esri.tasks.RouteParameters",accumulateAttributes:null,attributeParameterValues:null,barriers:null,directionsLanguage:null,directionsLengthUnits:null,directionsOutputType:null,directionsStyleName:null,directionsTimeAttribute:null,doNotLocateOnRestrictedElements:!0,findBestSequence:null,ignoreInvalidLocations:null,impedanceAttribute:null,outputLines:"esriNAOutputLineTrueShape",outputGeometryPrecision:null,outputGeometryPrecisionUnits:null,outSpatialReference:null,
overrides:null,polygonBarriers:null,polylineBarriers:null,preserveFirstStop:null,preserveLastStop:null,restrictionAttributes:null,restrictUTurns:null,returnBarriers:!1,returnDirections:!1,returnPolygonBarriers:!1,returnPolylineBarriers:!1,returnRoutes:!0,returnStops:!1,returnZ:!0,startTime:null,startTimeIsUTC:null,timeWindowsAreUTC:null,stops:null,useHierarchy:null,useTimeWindows:null,travelMode:null,toJson:function(t){var k={returnDirections:this.returnDirections,returnRoutes:this.returnRoutes,returnZ:this.returnZ,
returnStops:this.returnStops,returnBarriers:this.returnBarriers,returnPolygonBarriers:this.returnPolygonBarriers,returnPolylineBarriers:this.returnPolylineBarriers,attributeParameterValues:this.attributeParameterValues&&g.toJson(this.attributeParameterValues),outSR:this.outSpatialReference?this.outSpatialReference.wkid||g.toJson(this.outSpatialReference.toJson()):null,outputLines:this.outputLines,overrides:this.overrides,findBestSequence:this.findBestSequence,preserveFirstStop:this.preserveFirstStop,
preserveLastStop:this.preserveLastStop,useTimeWindows:this.useTimeWindows,startTime:this.startTime?this.startTime.getTime():null,startTimeIsUTC:this.startTimeIsUTC,timeWindowsAreUTC:this.timeWindowsAreUTC,accumulateAttributeNames:this.accumulateAttributes?this.accumulateAttributes.join(","):null,ignoreInvalidLocations:this.ignoreInvalidLocations,impedanceAttributeName:this.impedanceAttribute,restrictionAttributeNames:this.restrictionAttributes?this.restrictionAttributes.join(","):null,restrictUTurns:this.restrictUTurns,
useHierarchy:this.useHierarchy,directionsLanguage:this.directionsLanguage,outputGeometryPrecision:this.outputGeometryPrecision,outputGeometryPrecisionUnits:this.outputGeometryPrecisionUnits,directionsLengthUnits:F.LengthUnit[this.directionsLengthUnits],directionsTimeAttributeName:this.directionsTimeAttribute,directionsStyleName:this.directionsStyleName,travelMode:"object"===typeof this.travelMode?g.toJson(this.travelMode):this.travelMode},A=this.stops;"esri.tasks.FeatureSet"===A.declaredClass&&0<
A.features.length?k.stops=g.toJson({type:"features",features:H._encodeGraphics(A.features,t&&t["stops.features"]),doNotLocateOnRestrictedElements:this.doNotLocateOnRestrictedElements}):"esri.tasks.DataLayer"===A.declaredClass?k.stops=A:"esri.tasks.DataFile"===A.declaredClass&&(k.stops=g.toJson({type:"features",url:A.url,doNotLocateOnRestrictedElements:this.doNotLocateOnRestrictedElements}));if(this.directionsOutputType)switch(this.directionsOutputType.toLowerCase()){case "complete":k.directionsOutputType=
"esriDOTComplete";break;case "complete-no-events":k.directionsOutputType="esriDOTCompleteNoEvents";break;case "instructions-only":k.directionsOutputType="esriDOTInstructionsOnly";break;case "standard":k.directionsOutputType="esriDOTStandard";break;case "summary-only":k.directionsOutputType="esriDOTSummaryOnly";break;default:k.directionsOutputType=this.directionsOutputType}A=function(m,e){return m?"esri.tasks.FeatureSet"===m.declaredClass?0<m.features.length?g.toJson({type:"features",features:H._encodeGraphics(m.features,
t&&t[e])}):null:"esri.tasks.DataLayer"===m.declaredClass?m:"esri.tasks.DataFile"===m.declaredClass?g.toJson({type:"features",url:m.url}):g.toJson(m):null};this.barriers&&(k.barriers=A(this.barriers,"barriers.features"));this.polygonBarriers&&(k.polygonBarriers=A(this.polygonBarriers,"polygonBarriers.features"));this.polylineBarriers&&(k.polylineBarriers=A(this.polylineBarriers,"polylineBarriers.features"));return M.filter(k,function(m){if(null!==m)return!0})}});Q("extend-esri")&&T.setObject("tasks.RouteParameters",
I,O);return I})},"esri/tasks/NATypes":function(){define(["dojo/_base/lang","dojo/has","../kernel"],function(I,T,g){var Q={esriFeet:"esriNAUFeet",esriKilometers:"esriNAUKilometers",esriMeters:"esriNAUMeters",esriMiles:"esriNAUMiles",esriNauticalMiles:"esriNAUNauticalMiles",esriYards:"esriNAUYards"},O={NONE:"esriNAOutputLineNone",STRAIGHT:"esriNAOutputLineStraight",TRUE_SHAPE:"esriNAOutputLineTrueShape",TRUE_SHAPE_WITH_MEASURE:"esriNAOutputLineTrueShapeWithMeasure"},M={ALLOW_BACKTRACK:"esriNFSBAllowBacktrack",
AT_DEAD_ENDS_ONLY:"esriNFSBAtDeadEndsOnly",NO_BACKTRACK:"esriNFSBNoBacktrack",AT_DEAD_ENDS_AND_INTERSECTIONS:"esriNFSBAtDeadEndsAndIntersections"},H={NONE:"esriNAOutputPolygonNone",SIMPLIFIED:"esriNAOutputPolygonSimplified",DETAILED:"esriNAOutputPolygonDetailed"},F={FROM_FACILITY:"esriNATravelDirectionFromFacility",TO_FACILITY:"esriNATravelDirectionToFacility"},t={LengthUnit:Q,OutputLine:O,UTurn:M,OutputPolygon:H,TravelDirection:F};T("extend-esri")&&(I.setObject("tasks._NALengthUnit",Q,g),I.setObject("tasks.NAOutputLine",
O,g),I.setObject("tasks.NAUTurn",M,g),I.setObject("tasks.NAOutputPolygon",H,g),I.setObject("tasks.NATravelDirection",F,g));return t})},"esri/tasks/DistanceParameters":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/json dojo/has ../kernel ../geometry/jsonUtils".split(" "),function(I,T,g,Q,O,M){I=I(null,{declaredClass:"esri.tasks.DistanceParameters",geometry1:null,geometry2:null,distanceUnit:null,geodesic:null,toJson:function(){var H={},F=this.geometry1;F&&(H.geometry1=g.toJson({geometryType:M.getJsonType(F),
geometry:F}));if(F=this.geometry2)H.geometry2=g.toJson({geometryType:M.getJsonType(F),geometry:F});H.sr=g.toJson(this.geometry1.spatialReference.toJson());this.distanceUnit&&(H.distanceUnit=this.distanceUnit);this.geodesic&&(H.geodesic=this.geodesic);return H}});Q("extend-esri")&&T.setObject("tasks.DistanceParameters",I,O);return I})},"esri/tasks/PrintTask":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/json dojo/_base/Deferred dojo/has ../kernel ../lang ../layerUtils ../deferredUtils ../Color ../request ../urlUtils ../geometry/Polygon ../renderers/SimpleRenderer ../symbols/FillSymbol ./Geoprocessor ./PrintTemplate ./Task dojo/dom-attr dojo/dom-construct dojox/gfx/_base dojox/gfx/canvas dojox/json/query dojo/has!extend-esri?./PrintParameters dojo/has!extend-esri?./LegendLayer".split(" "),
function(I,T,g,Q,O,M,H,F,t,k,A,m,e,d,r,y,z,h,v,L,J,U,S,N){I=I(v,{declaredClass:"esri.tasks.PrintTask",constructor:function(D,G){this.url=D;this.printGp=new z(this.url);this._handler=T.hitch(this,this._handler);G&&G.async&&(this.async=!0);this._colorEvaluator=N("$..color")},async:!1,_vtlExtent:null,_cimVersion:null,_is11xService:!1,_loadGpServerMetadata:!0,execute:function(D,G,aa){if(!this._loadGpServerMetadata)return this._execute(D,G,aa);var ca=new O(k._dfdCanceller),Z=this._url.path,ea=Z.lastIndexOf("/GPServer/");
0<ea&&(Z=Z.slice(0,ea+9));ca._pendingDfd=m({url:Z,callbackParamName:"callback",content:T.mixin({},this._url.query,{f:"json"})}).then(T.hitch(this,function(C){this._loadGpServerMetadata=!1;this.async="esriExecutionTypeAsynchronous"===C.executionType;this._cimVersion=C.cimVersion;this._is11xService=!!this._cimVersion;ca._pendingDfd=this._execute(D);return ca._pendingDfd})).then(T.hitch(this,function(C){this._successHandler([C],null,G,ca)})).otherwise(function(C){aa&&aa(C);ca.errback(C)});return ca},
_handler:function(D,G,aa,ca,Z){try{if(this.async)"esriJobSucceeded"===D.jobStatus?this.printGp.getResultData(D.jobId,"Output_File",T.hitch(this,function(C){ea=C.value;this._successHandler([ea],"onComplete",aa,Z)})):this._errorHandler(Error(D.jobStatus),ca,Z);else{var ea=D[0].value;this._successHandler([ea],"onComplete",aa,Z)}}catch(C){this._errorHandler(C,ca,Z)}},_execute:function(D,G,aa){var ca=this._handler,Z=this._errorHandler,ea=D.template||new h;ea.hasOwnProperty("showLabels")||(ea.showLabels=
!0);var C=ea.exportOptions,da;C&&(da={outputSize:[C.width,C.height],dpi:C.dpi});C=ea.layoutOptions;var Y=[];if(C){this.legendAll=!1;C.legendLayers?g.forEach(C.legendLayers,function(ra){var Ea={};Ea.id=ra.layerId;ra.subLayerIds&&(Ea.subLayerIds=ra.subLayerIds);Y.push(Ea)}):this.legendAll=!0;if("Miles"===C.scalebarUnit||"Kilometers"===C.scalebarUnit){var w="esriKilometers";var n="esriMiles"}else if("Meters"===C.scalebarUnit||"Feet"===C.scalebarUnit)w="esriMeters",n="esriFeet";var u={esriMiles:"mi",
esriKilometers:"km",esriFeet:"ft",esriMeters:"m"};u={titleText:C.titleText,authorText:C.authorText,copyrightText:C.copyrightText,customTextElements:C.customTextElements,scaleBarOptions:{metricUnit:w,metricLabel:u[w],nonMetricUnit:n,nonMetricLabel:u[n]},legendOptions:{operationalLayers:Y}}}w=this._getPrintDefinition(D.map,ea);D.outSpatialReference&&(w.mapOptions.spatialReference=D.outSpatialReference.toJson());D.template&&F.isDefined(D.template.showAttribution)&&(w.mapOptions.showAttribution=D.template.showAttribution);
T.mixin(w,{exportOptions:da,layoutOptions:u});this.allLayerslegend&&T.mixin(w.layoutOptions,{legendOptions:{operationalLayers:this.allLayerslegend}});if(w.operationalLayers){da=w.operationalLayers;var W=function(ra){return F.fixJson(T.mixin(ra,{type:"esriSLS",cap:void 0,join:void 0,meterLimit:void 0}))},ja=/[\u4E00-\u9FFF\u0E00-\u0E7F\u0900-\u097F\u3040-\u309F\u30A0-\u30FF\u31F0-\u31FF]/,ba=/[\u0600-\u06FF]/,ka=function(ra){var Ea=ra.text,b=(ra=ra.font)&&ra.family&&ra.family.toLowerCase();Ea&&ra&&
("arial"===b||"arial unicode ms"===b)&&(ra.family=ja.test(Ea)?"Arial Unicode MS":"Arial","normal"!==ra.style&&ba.test(Ea)&&(ra.family="Arial Unicode MS"))};for(u=0;u<da.length;u++)if(da[u].featureCollection&&da[u].featureCollection.layers)for(n=0;n<da[u].featureCollection.layers.length;n++){var sa=da[u].featureCollection.layers[n];if(sa.layerDefinition&&sa.layerDefinition.drawingInfo&&sa.layerDefinition.drawingInfo.renderer&&sa.layerDefinition.drawingInfo.renderer.symbol){var qa=sa.layerDefinition.drawingInfo.renderer;
"esriCLS"===qa.symbol.type?qa.symbol=W(qa.symbol):"esriTS"===qa.symbol.type?ka(qa.symbol):qa.symbol.outline&&"esriCLS"===qa.symbol.outline.type&&(qa.symbol.outline=W(qa.symbol.outline))}if(sa.featureSet&&sa.featureSet.features)for(C=0;C<sa.featureSet.features.length;C++)qa=sa.featureSet.features[C],qa.symbol&&("esriCLS"===qa.symbol.type?qa.symbol=W(qa.symbol):"esriTS"===qa.symbol.type?ka(qa.symbol):qa.symbol.outline&&"esriCLS"===qa.symbol.outline.type&&(qa.symbol.outline=W(qa.symbol.outline)))}}ea=
{Web_Map_as_JSON:Q.toJson(F.fixJson(w)),Format:ea.format,Layout_Template:ea.layout};D.extraParameters&&(ea=T.mixin(ea,D.extraParameters));var ya=new O(k._dfdCanceller);D=function(ra,Ea){ca(ra,Ea,G,aa,ya)};w=function(ra){Z(ra,aa,ya)};ya._pendingDfd=this.async?this.printGp.submitJob(ea,D,null,w):this.printGp.execute(ea,D,w);return ya},onComplete:function(){},_createMultipointLayer:function(){return{layerDefinition:{name:"multipointLayer",geometryType:"esriGeometryMultipoint",drawingInfo:{renderer:null}},
featureSet:{geometryType:"esriGeometryMultipoint",features:[]}}},_createPolygonLayer:function(){return{layerDefinition:{name:"polygonLayer",geometryType:"esriGeometryPolygon",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPolygon",features:[]}}},_createPointLayer:function(){return{layerDefinition:{name:"pointLayer",geometryType:"esriGeometryPoint",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPoint",features:[]}}},_createPolylineLayer:function(){return{layerDefinition:{name:"polylineLayer",
geometryType:"esriGeometryPolyline",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPolyline",features:[]}}},_convertSvgSymbol:function(D){if(!(8>=M("ie")||!D.path&&"image/svg+xml"!==D.contentType)){var G=S.createSurface(J.create("div"),1024,1024);var aa="image/svg+xml"===D.contentType?G.createObject(S.Image,{src:"data:image/svg+xml;base64,"+D.imageData,width:U.pt2px(D.width),height:U.pt2px(D.height),x:0,y:0}):G.createObject(S.Path,D.path).setFill(D.color).setStroke(D.outline);
"pendingRender"in G&&G._render(!0);var ca=G.rawNode.getContext("2d"),Z=Math.ceil(aa.getBoundingBox().width),ea=Math.ceil(aa.getBoundingBox().height);aa=ca.getImageData(aa.getBoundingBox().x,aa.getBoundingBox().y,Z,ea);ca.canvas.width=Z;ca.canvas.height=ea;ca.putImageData(aa,0,0);ca=ca.canvas.toDataURL("image/png");D={type:"esriPMS",imageData:ca.substr(22,ca.length),angle:D.angle,contentType:"image/png",height:D.size?D.size:U.px2pt(ea),width:D.size?Z/ea*D.size:U.px2pt(Z),xoffset:D.xoffset,yoffset:D.yoffset};
G.destroy();return D}},_convertSvgRenderer:function(D){"simple"===D.type&&D.symbol&&(D.symbol.path||"image/svg+xml"===D.symbol.contentType)?D.symbol=this._convertSvgSymbol(D.symbol):"uniqueValue"===D.type?(D.defaultSymbol&&(D.defaultSymbol.path||"image/svg+xml"===D.defaultSymbol.contentType)&&(D.defaultSymbol=this._convertSvgSymbol(D.defaultSymbol)),D.uniqueValueInfos&&g.forEach(D.uniqueValueInfos,function(G){if(G.symbol.path||"image/svg+xml"===G.symbol.contentType)G.symbol=this._convertSvgSymbol(G.symbol)},
this)):"classBreaks"===D.type&&(D.defaultSymbol&&(D.defaultSymbol.path||"image/svg+xml"===D.defaultSymbol.contentType)&&(D.defaultSymbol=this._convertSvgSymbol(D.defaultSymbol)),D.classBreakInfos&&g.forEach(D.classBreakInfos,function(G){if(G.symbol.path||"image/svg+xml"===G.symbol.contentType)G.symbol=this._convertSvgSymbol(G.symbol)},this))},_createFeatureCollection:function(D,G,aa,ca){var Z=this._createPolygonLayer(),ea=this._createPolylineLayer(),C=this._createPointLayer(),da=this._createMultipointLayer(),
Y=this._createPointLayer();Y.layerDefinition.name="textLayer";delete Y.layerDefinition.drawingInfo;if("esri.layers.FeatureLayer"===D.declaredClass||"esri.layers.StreamLayer"===D.declaredClass)Z.layerDefinition.name=ea.layerDefinition.name=C.layerDefinition.name=da.layerDefinition.name=T.getObject("arcgisProps.title",!1,D)||D.name||D.id;var w=D.renderer&&"esri.renderer.SimpleRenderer"===D.renderer.declaredClass;if(!D.renderer||D.renderer.valueExpression||T.isFunction(D.renderer.attributeField))delete Z.layerDefinition.drawingInfo,
delete ea.layerDefinition.drawingInfo,delete C.layerDefinition.drawingInfo,delete da.layerDefinition.drawingInfo;else{var n=D.renderer.toJson({useLegacyRotationProperties:!0});if("temporal"===n.type){n={latestObservationRenderer:n.latestObservationRenderer,trackLinesRenderer:n.trackRenderer,observationAger:n.observationAger,renderer:n.observationRenderer};var u={};D._trackIdField&&(u.trackIdField=D._trackIdField);D._startTimeField&&(u.startTimeField=D._startTimeField);D._endTimeField&&(u.endTimeField=
D._endTimeField);Z.layerDefinition.drawingInfo=n;Z.layerDefinition.timeInfo=u;ea.layerDefinition.drawingInfo=n;ea.layerDefinition.timeInfo=u;C.layerDefinition.drawingInfo=n;C.layerDefinition.timeInfo=u;da.layerDefinition.drawingInfo=n;da.layerDefinition.timeInfo=u}else Z.layerDefinition.drawingInfo.renderer=n,ea.layerDefinition.drawingInfo.renderer=n,C.layerDefinition.drawingInfo.renderer=n,da.layerDefinition.drawingInfo.renderer=n}n=D.fields;n||!D.renderer||D.renderer.valueExpression||T.isFunction(D.renderer.attributeField)||
("esri.renderer.ClassBreaksRenderer"===D.renderer.declaredClass?(n=[{name:D.renderer.attributeField,type:"esriFieldTypeDouble"}],D.renderer.normalizationField&&n.push({name:D.renderer.normalizationField,type:"esriFieldTypeDouble"})):"esri.renderer.UniqueValueRenderer"===D.renderer.declaredClass&&(n=[{name:D.renderer.attributeField,type:"esriFieldTypeString"}],D.renderer.attributeField2&&n.push({name:D.renderer.attributeField2,type:"esriFieldTypeString"}),D.renderer.attributeField3&&n.push({name:D.renderer.attributeField3,
type:"esriFieldTypeString"})));n&&(Z.layerDefinition.fields=n,ea.layerDefinition.fields=n,C.layerDefinition.fields=n,da.layerDefinition.fields=n);n=D.graphics;D.isFeatureReductionActive&&D.isFeatureReductionActive()&&(n=D.getSingleGraphics());u=n.length;var W;for(W=0;W<u;W++){var ja=n[W];if(!1!==ja.visible&&ja.geometry){var ba=ja.toJson();ba.symbol&&ba.symbol.outline&&ba.symbol.outline.color&&ba.symbol.outline.color[3]&&!this._is11xService&&(ba.symbol.outline.color[3]=255);if(D.renderer&&!ba.symbol&&
(T.isFunction(D.renderer.attributeField)||D.renderer.valueExpression||this._isFeatureCollectionRequired(D.renderer,D)||"esri.renderer.DotDensityRenderer"===D.renderer.declaredClass||aa)){aa=aa||D.renderer;var ka=null;try{ka=aa.getSymbol(ja)}catch(sa){}if(!ka)continue;ba.symbol=ka.toJson();this._isFeatureCollectionRequired(aa,D)&&this._applyVisualVariables(ba.symbol,{renderer:aa,graphic:ja,symbol:ka,mapResolution:G&&G.getResolutionInMeters(),mapScale:G&&G.getScale()})}ba.symbol&&(ba.symbol.path||"image/svg+xml"===
ba.symbol.contentType?ba.symbol=this._convertSvgSymbol(ba.symbol):ba.symbol.text&&delete ba.attributes);switch(ja.geometry.type){case "polygon":Z.featureSet.features.push(ba);break;case "polyline":ea.featureSet.features.push(ba);break;case "point":ba.symbol&&ba.symbol.text?Y.featureSet.features.push(ba):C.featureSet.features.push(ba);break;case "multipoint":da.featureSet.features.push(ba);break;case "extent":ba.geometry=d.fromExtent(ja.geometry).toJson(),Z.featureSet.features.push(ba)}}}G=[];0<Z.featureSet.features.length&&
G.push(Z);0<ea.featureSet.features.length&&G.push(ea);0<da.featureSet.features.length&&G.push(da);0<C.featureSet.features.length&&G.push(C);0<Y.featureSet.features.length&&G.push(Y);if(!G.length)return null;g.forEach(G,function(sa){var qa=g.every(sa.featureSet.features,function(ya){return ya.symbol});if(w||qa)ca&&ca.forceFeatureAttributes||g.forEach(sa.featureSet.features,function(ya){delete ya.attributes}),ca.forceFeatureAttributes||delete sa.layerDefinition.fields;qa&&delete sa.layerDefinition.drawingInfo});
g.forEach(G,function(sa){sa.layerDefinition.drawingInfo&&sa.layerDefinition.drawingInfo.renderer&&this._convertSvgRenderer(sa.layerDefinition.drawingInfo.renderer)},this);return{id:D.id,opacity:D.opacity,minScale:D.minScale||0,maxScale:D.maxScale||0,featureCollection:{layers:G}}},_getPrintDefinition:function(D,G){var aa={operationalLayers:this._createOperationalLayers(D,G)},ca=this._vtlExtent||D.extent,Z=D.spatialReference;this._vtlExtent=null;D.spatialReference._isWrappable()&&(ca=ca._normalize(!0),
Z=ca.spatialReference);ca={mapOptions:{showAttribution:D.showAttribution,extent:ca.toJson(),spatialReference:Z.toJson()}};G.preserveScale&&T.mixin(ca.mapOptions,{scale:G.outScale||D.getScale()});D.timeExtent&&T.mixin(ca.mapOptions,{time:[D.timeExtent.startTime.getTime(),D.timeExtent.endTime.getTime()]});D={};T.mixin(D,ca,aa);return D},_createOperationalLayers:function(D,G){var aa,ca=[],Z=0;G.preserveScale&&(Z=G.outScale||D.getScale());this.allLayerslegend=this.legendAll?[]:null;this._vtlExtent=null;
var ea=g.map(D.layerIds,D.getLayer,D);D._mapImageLyr&&ea.push(D._mapImageLyr);for(aa=0;aa<ea.length;aa++){var C=ea[aa];if(C.loaded&&C.visible&&(!Z||C.isVisibleAtScale(Z))){var da=C.declaredClass;var Y={id:C.id,title:T.getObject("arcgisProps.title",!1,C)||C.id,opacity:C.opacity,minScale:C.minScale||0,maxScale:C.maxScale||0};Y=T.mixin(Y,this._getUrlAndToken(C));C.getNode()&&L.get(C.getNode(),"data-reference")&&(Y._isRefLayer=!0);switch(da){case "esri.layers.ArcGISDynamicMapServiceLayer":var w=[];da=
!!C._params.layers;if(C._params.dynamicLayers)da=G.outScale?C._getDynLayerObjs(G.outScale):Q.fromJson(C._params.dynamicLayers),g.forEach(da,function(ba){w.push({id:ba.id,name:ba.name,layerDefinition:ba});delete ba.id;delete ba.name;delete ba.maxScale;delete ba.minScale}),0===w.length&&(Y.visibleLayers=[-1]);else if(C.supportsDynamicLayers){if(da||C.layerDefinitions||C.layerTimeOptions){var n=C.createDynamicLayerInfosFromLayerInfos(),u=null;da&&(u=C.visibleLayers);u=t._getVisibleLayers(n,u);var W=
t._getLayersForScale(G.outScale||D.getScale(),n);g.forEach(n,function(ba){if(!ba.subLayerIds){var ka=ba.id;-1<g.indexOf(u,ka)&&-1<g.indexOf(W,ka)&&(ba={source:ba.source.toJson()},C.layerDefinitions&&C.layerDefinitions[ka]&&(ba.definitionExpression=C.layerDefinitions[ka]),C.layerTimeOptions&&C.layerTimeOptions[ka]&&(ba.layerTimeOptions=C.layerTimeOptions[ka].toJson()),w.push({id:ka,layerDefinition:ba}))}});0===w.length&&(Y.visibleLayers=[-1])}}else g.forEach(C.layerInfos,function(ba){var ka={id:ba.id,
layerDefinition:{}};C.layerDefinitions&&C.layerDefinitions[ba.id]&&(ka.layerDefinition.definitionExpression=C.layerDefinitions[ba.id]);C.layerTimeOptions&&C.layerTimeOptions[ba.id]&&(ka.layerDefinition.layerTimeOptions=C.layerTimeOptions[ba.id].toJson());(ka.layerDefinition.definitionExpression||ka.layerDefinition.layerTimeOptions)&&w.push(ka)}),da&&(Y.visibleLayers=C.visibleLayers.length?C.visibleLayers:[-1]);w.length&&(Y.layers=w);ca.push(Y);this.allLayerslegend&&this.allLayerslegend.push({id:C.id,
subLayerIds:C.visibleLayers});break;case "esri.layers.ArcGISImageServiceLayer":Y=T.mixin(Y,{url:C.url,bandIds:C.bandIds,compressionQuality:C.compressionQuality,format:C.format,interpolation:C.interpolation});C.mosaicRule&&T.mixin(Y,{mosaicRule:C.mosaicRule.toJson()});if(C.renderingRule||C.renderer)this._is11xService?(C.renderingRule&&(Y.renderingRule=C.renderingRule.toJson()),C.renderer&&(Y.layerDefinition=Y.layerDefinition||{},Y.layerDefinition.drawingInfo=Y.layerDefinition.drawingInfo||{},Y.layerDefinition.drawingInfo.renderer=
C.renderer.toJson())):(da=C.getExportImageRenderingRule())&&T.mixin(Y,{renderingRule:da.toJson()});ca.push(Y);this.allLayerslegend&&this.allLayerslegend.push({id:C.id});break;case "esri.layers.RasterXLayer":this._is11xService&&(Y=T.mixin(Y,{url:C.url,bandIds:C.bandIds,interpolation:C.interpolation}),C.renderer&&(Y.layerDefinition=Y.layerDefinition||{},Y.layerDefinition.drawingInfo=Y.layerDefinition.drawingInfo||{},Y.layerDefinition.drawingInfo.renderer=C.renderer.toJson()),ca.push(Y),this.allLayerslegend&&
this.allLayerslegend.push({id:C.id}));break;case "esri.layers.WMSLayer":Y=T.mixin(Y,{url:C.url,title:C.title,type:"wms",version:C.version,transparentBackground:C.imageTransparency,visibleLayers:C.visibleLayers});ca.push(Y);this.allLayerslegend&&this.allLayerslegend.push({id:C.id,subLayerIds:C.visibleLayers});break;case "esri.virtualearth.VETiledLayer":da=C.mapStyle;"roadOnDemand"===da?da="Road":"aerialWithLabelsOnDemand"===da&&(da="Hybrid");Y=T.mixin(Y,{visibility:C.visible,type:"BingMaps"+da,culture:C.culture,
key:C.bingMapsKey});ca.push(Y);break;case "esri.layers.OpenStreetMapLayer":Y=T.mixin(Y,{credits:C.copyright,type:"OpenStreetMap",url:e.getAbsoluteUrl(C.tileServers[0])});ca.push(Y);break;case "esri.layers.WMTSLayer":Y=T.mixin(Y,{url:C.url,type:"wmts",layer:C._identifier,style:C._style,format:C.format,tileMatrixSet:C._tileMatrixSetId});ca.push(Y);break;case "esri.layers.MapImageLayer":da=C.getImages();g.forEach(da,function(ba,ka){ba.visible&&ba.href&&(Y={id:C.id+"_image"+ka,type:"image",title:C.id,
minScale:C.minScale||0,maxScale:C.maxScale||0,opacity:C.opacity*ba.opacity,extent:ba.extent.toJson()},"data:image/png;base64,"===ba.href.substr(0,22)?Y.imageData=ba.href.substr(22):Y.url=ba.href,ca.push(Y))});break;case "esri.layers.VectorTileLayer":delete Y.url;delete Y.token;if(this._is11xService&&C.currentStyleInfo.serviceUrl&&C.currentStyleInfo.styleUrl&&(da=H.id&&H.id.findCredential(C.currentStyleInfo.styleUrl),n=H.id&&H.id.findCredential(C.currentStyleInfo.serviceUrl),!da&&!n||"2.1.0"!==this._cimVersion)){Y.type=
"VectorTileLayer";Y.styleUrl=C.currentStyleInfo.styleUrl;da&&(Y.token=da.token);n&&n.token!==Y.token&&(Y.additionalTokens=[{url:C.currentStyleInfo.serviceUrl,token:n.token}]);ca.push(Y);break}Y.type="image";da=this._vtlExtent||D.extent.offset(0,0);var ja=G.exportOptions&&G.exportOptions.dpi||96;n={format:"png",pixelRatio:ja/96};"MAP_ONLY"!==G.layout||!G.preserveScale||G.outScale&&G.outScale!==D.getScale()||96!==ja||!G.exportOptions||G.exportOptions.width%2===D.width%2&&G.exportOptions.height%2===
D.height%2||(n.area={x:0,y:0,width:D.width,height:D.height},G.exportOptions.width%2!==D.width%2&&--n.area.width,G.exportOptions.height%2!==D.height%2&&--n.area.height,this._vtlExtent||(ja=D.toMap({x:n.area.width,y:n.area.height}),da.update(da.xmin,ja.y,ja.x,da.ymax,da.spatialReference),this._vtlExtent=da));Y.extent=da._normalize(!0).toJson();da=C.takeScreenshot(n);da.isResolved()?da.then(function(ba){"data:image/png;base64,"===ba.dataURL.substr(0,22)&&(Y.imageData=ba.dataURL.substr(22))}):console.error("PrintTask: VectorTileLayer.takeScreenshot() returned an unresolved Promise");
Y.imageData&&ca.push(Y);break;case "esri.layers.WebTiledLayer":da=C.url.replace(/\$\{/g,"{");Y=T.mixin(Y,{type:"WebTiledLayer",urlTemplate:da,credits:C.copyright});C.subDomains&&0<C.subDomains.length&&(Y.subDomains=C.subDomains);C._wmtsInfo&&(Y.wmtsInfo=C._wmtsInfo);delete Y.url;ca.push(Y);break;default:if(C.getTileUrl||C.getImageUrl)Y=T.mixin(Y,{url:C.url}),ca.push(Y)}}}ea=g.map(D.graphicsLayerIds,D.getLayer,D);for(aa=0;aa<ea.length;aa++)C=ea[aa],C.isFeatureReductionActive&&C.isFeatureReductionActive()&&
(C.getSingleGraphics().length?ea.splice(++aa,0,C.getFeatureReductionLayer()):ea[aa]=C.getFeatureReductionLayer());for(aa=0;aa<ea.length;aa++)if(C=ea[aa],C.loaded&&C.visible&&(!Z||C.isVisibleAtScale(Z)))switch(da=C.declaredClass,da){case "esri.layers.CSVLayer":if(this._is11xService){Y={id:C.id,url:C.url,title:C.title,opacity:C.opacity,minScale:C.minScale||0,maxScale:C.maxScale||0,type:"CSV",locationInfo:{latitudeFieldName:C.latitudeFieldName,longitudeFieldName:C.longitudeFieldName},layerDefinition:{drawingInfo:{renderer:C.renderer&&
C.renderer.toJson({useLegacyRotationProperties:!0})}}};ca.push(Y);break}case "esri.layers.FeatureLayer":case "esri.layers.LabelLayer":case "esri.layers.StreamLayer":if("esri.layers.LabelLayer"===da&&!G.showLabels||C.renderer&&"esri.renderer.HeatmapRenderer"===C.renderer.declaredClass)continue;da=null;C.url&&C.renderer&&("esri.renderer.ScaleDependentRenderer"===C.renderer.declaredClass?"scale"===C.renderer.rangeType?da=C.renderer.getRendererInfoByScale(D.getScale())&&C.renderer.getRendererInfoByScale(D.getScale()).renderer:
"zoom"===C.renderer.rangeType&&(da=C.renderer.getRendererInfoByZoom(D.getZoom())&&C.renderer.getRendererInfoByZoom(D.getZoom()).renderer):da=C.renderer);n=da&&"esri.layers.CSVLayer"!==C.declaredClass&&!this._isFeatureCollectionRequired(da,C)&&!da.valueExpression;ja=C.isFeatureReductionActive&&C.isFeatureReductionActive();if(da&&!ja&&"esri.renderer.DotDensityRenderer"!==da.declaredClass&&"esri.layers.StreamLayer"!==C.declaredClass&&(this._is11xService||n)&&("esri.renderer.SimpleRenderer"===da.declaredClass||
"esri.renderer.TemporalRenderer"===da.declaredClass||null==da.attributeField||T.isString(da.attributeField)&&C._getField(da.attributeField,!0)))if(Y={id:C.id,title:T.getObject("arcgisProps.title",!1,C)||C.id,opacity:C.opacity,minScale:C.minScale||0,maxScale:C.maxScale||0,layerDefinition:{drawingInfo:{renderer:da.toJson({useLegacyRotationProperties:!0})}}},Y=T.mixin(Y,this._getUrlAndToken(C)),"esri.renderer.TemporalRenderer"===da.declaredClass&&(n=Y.layerDefinition.drawingInfo,n.latestObservationRenderer=
n.renderer.latestObservationRenderer,n.trackLinesRenderer=n.renderer.trackRenderer,n.observationAger=n.renderer.observationAger,n.renderer=n.renderer.observationRenderer,C._trackIdField&&(Y.layerDefinition.timeInfo={trackIdField:C._trackIdField})),this._convertSvgRenderer(Y.layerDefinition.drawingInfo.renderer),this._is11xService||1>C.opacity||"esri.renderer.TemporalRenderer"===da.declaredClass||this._updateLayerOpacity(Y))if(C._params.source&&(da=C._params.source.toJson(),T.mixin(Y.layerDefinition,
{source:da})),C.getDefinitionExpression()&&T.mixin(Y.layerDefinition,{definitionExpression:C.getDefinitionExpression()}),2!==C.mode)0<C.getSelectedFeatures().length&&(da=g.map(C.getSelectedFeatures(),function(ba){return ba.attributes[C.objectIdField]}),0<da.length&&C.getSelectionSymbol()&&T.mixin(Y,{selectionObjectIds:da,selectionSymbol:C.getSelectionSymbol().toJson()}));else{da=g.map(C.getSelectedFeatures(),function(ba){return ba.attributes[C.objectIdField]});if(0===da.length||!C._params.drawMode)break;
T.mixin(Y.layerDefinition,{objectIds:da});da=null;C.getSelectionSymbol()&&(da=new r(C.getSelectionSymbol()));T.mixin(Y.layerDefinition.drawingInfo,{renderer:da&&da.toJson()})}else Y=this._createFeatureCollection(C,D,null,G);else Y=da&&(da.valueExpression||this._isFeatureCollectionRequired(da,C)||"esri.renderer.DotDensityRenderer"===da.declaredClass)?this._createFeatureCollection(C,D,da,G):this._createFeatureCollection(C,D,null,G);if(!Y)continue;ca.push(Y);this.allLayerslegend&&this.allLayerslegend.push({id:C.id});
break;case "esri.layers._GraphicsLayer":case "esri.layers.GraphicsLayer":case "esri.layers.WFSLayer":Y=this._createFeatureCollection(C,D,null,G);if(!Y)continue;ca.push(Y);this.allLayerslegend&&this.allLayerslegend.push({id:C.id});break;case "esri.layers.ArcGISImageServiceVectorLayer":Y={id:C.id,title:T.getObject("arcgisProps.title",!1,C)||C.id,opacity:C.opacity,minScale:C.minScale||0,maxScale:C.maxScale||0,visibility:C.visible,symbolTileSize:C.symbolTileSize,layerDefinition:{drawingInfo:{renderer:C.renderer.toJson({useLegacyRotationProperties:!0})}}},
Y=T.mixin(Y,this._getUrlAndToken(C)),C.mosaicRule&&T.mixin(Y,{mosaicRule:C.mosaicRule.toJson()}),ca.push(Y),this.allLayerslegend&&this.allLayerslegend.push({id:C.id})}Z&&g.forEach(ca,function(ba){ba.minScale=0;ba.maxScale=0});D.graphics&&0<D.graphics.graphics.length&&(Y=this._createFeatureCollection(D.graphics,D,null,G))&&ca.push(Y);D._labels&&G.showLabels&&(Y=this._createFeatureCollection(D._labels,D,null,G))&&ca.push(Y);g.forEach(ca,function(ba,ka,sa){ba._isRefLayer&&(delete ba._isRefLayer,sa.splice(ka,
1),sa.push(ba))});return ca},_getUrlAndToken:function(D){return{token:D._getToken(),url:D._url?D._url.path:null}},_updateLayerOpacity:function(D){var G=this._colorEvaluator(D);G=g.filter(G,function(ea){return T.isArray(ea)&&4===ea.length});var aa=!0;if(G.length){var ca=G[0][3],Z;for(Z=1;Z<G.length;Z++)if(ca!==G[Z][3]){aa=!1;break}if(aa)for(D.opacity=ca/255,Z=0;Z<G.length;Z++)G[Z][3]=255}return aa},_isFeatureCollectionRequired:function(D,G){if(G&&G.isFeatureReductionActive&&G.isFeatureReductionActive())return!0;
var aa=!1;if(G=this._getVariable(D,"rotationInfo",!1))aa=(aa=G.field)&&T.isFunction(aa)||G.valueExpression;return D.hasVisualVariables("sizeInfo")||D.hasVisualVariables("colorInfo")||D.hasVisualVariables("opacityInfo")||aa},_getVariable:function(D,G,aa){if(D)var ca=(D=D.getVisualVariablesForType(G,aa))&&D[0];return ca},_applyVisualVariables:function(D,G){var aa=G.renderer,ca=G.graphic,Z=G.symbol,ea=G.mapResolution,C=G.mapScale,da=Z.type;if("textsymbol"!==da&&"shieldlabelsymbol"!==da){var Y=this._getVariable(aa,
"sizeInfo",!1),w=this._getVariable(aa,"colorInfo",!1),n=this._getVariable(aa,"opacityInfo",!1);G=this._getVariable(aa,"rotationInfo",!1);Z instanceof y&&(Y=this._getVariable(aa,"sizeInfo","outline")||Y);ea=Y?aa.getSize(ca,{sizeInfo:Y,shape:"simplemarkersymbol"===da?Z.style:null,resolution:ea,scale:C}):ca.size;null!=ea&&("simplemarkersymbol"===da?D.size=U.px2pt(ea):"picturemarkersymbol"===da?(C=Z.width/Z.height*ea,D.width=U.px2pt(C),D.height=U.px2pt(ea),0!==Z.xoffset&&(D.xoffset=U.px2pt(Z.xoffset/
Z.width*C)),0!==Z.yoffset&&(D.yoffset=U.px2pt(Z.yoffset/Z.height*ea))):"simplelinesymbol"===da?D.width=U.px2pt(ea):D.outline&&(D.outline.width=U.px2pt(ea)));w&&(!(Z=aa.getColor(ca,{colorInfo:w}))||"simplemarkersymbol"!==da&&"simplelinesymbol"!==da&&"simplefillsymbol"!==da||(D.color=A.toJsonColor(Z)));n&&(Z=aa.getOpacity(ca,{opacityInfo:n}),null!=Z&&D.color&&(D.color[3]=Math.round(255*Z)));G&&(aa=aa.getRotationAngle(ca,{rotationInfo:G}))&&(D.angle=-aa)}}});M("extend-esri")&&T.setObject("tasks.PrintTask",
I,H);return I})},"esri/tasks/Geoprocessor":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/Deferred dojo/_base/json dojo/has dojo/io-query ../kernel ../request ../deferredUtils ../geometry/normalizeUtils ./Task ./FeatureSet ./JobInfo ./GPMessage ./LinearUnit ./DataFile ./RasterData ./Date ./ParameterValue ./GPResultImageLayer ../layers/ArcGISDynamicMapServiceLayer ../layers/MapImage".split(" "),function(I,T,g,Q,O,M,H,F,t,k,A,m,e,d,r,y,z,h,v,L,J,U,S){I=I(m,{declaredClass:"esri.tasks.Geoprocessor",
_eventMap:{"execute-complete":["results","messages"],"get-result-data-complete":["result"],"get-result-image-complete":["mapImage"],"get-result-image-layer-complete":["layer"],"job-cancel":["jobInfo"],"job-complete":["jobInfo"],"status-update":["jobInfo"]},constructor:function(N){this._jobUpdateHandler=T.hitch(this,this._jobUpdateHandler);this._getJobStatus=T.hitch(this,this._getJobStatus);this._getResultDataHandler=T.hitch(this,this._getResultDataHandler);this._getResultImageHandler=T.hitch(this,
this._getResultImageHandler);this._executeHandler=T.hitch(this,this._executeHandler);this._updateTimers=[];this.registerConnectEvents()},updateDelay:1E3,processSpatialReference:null,outputSpatialReference:null,outSpatialReference:null,setUpdateDelay:function(N){this.updateDelay=N},setProcessSpatialReference:function(N){this.processSpatialReference=N},setOutputSpatialReference:function(N){this._setOutSR(N)},setOutSpatialReference:function(N){this._setOutSR(N)},__msigns:[{n:"execute",c:3,a:[{i:0,p:["*"]}],
e:2,f:1},{n:"submitJob",c:4,a:[{i:0,p:["*"]}],e:3}],_setOutSR:function(N){this.outSpatialReference=this.outputSpatialReference=N},_getOutSR:function(){return this.outSpatialReference||this.outputSpatialReference},_gpEncode:function(N,D,G){for(var aa in N){var ca=N[aa];T.isArray(ca)?N[aa]=O.toJson(g.map(ca,function(Z){return this._gpEncode({item:Z},!0).item},this)):ca instanceof Date&&(N[aa]=ca.getTime())}return this._encode(N,D,G)},_decode:function(N){var D=N.dataType,G=new L(N);if(-1!==g.indexOf(["GPBoolean",
"GPDouble","GPLong","GPString"],D))return G;if("GPLinearUnit"===D)G.value=new y(G.value);else if("GPFeatureRecordSetLayer"===D||"GPRecordSet"===D)G.value=new e(G.value);else if("GPDataFile"===D)G.value=new z(G.value);else if("GPDate"===D)N=G.value,T.isString(N)?G.value=new v({date:N}):G.value=new Date(N);else if("GPRasterData"===D||"GPRasterDataLayer"===D)N=N.value.mapImage,G.value=N?new S(N):new h(G.value);else if(-1!==D.indexOf("GPMultiValue:")){var aa=D.split(":")[1];N=G.value;G.value=g.map(N,
function(ca){return this._decode({paramName:"_name",dataType:aa,value:ca}).value},this)}else console.log(this.declaredClass+" : GP Data type not handled. : "+G.dataType),G=null;return G},submitJob:function(N,D,G,aa,ca){var Z=this._getOutSR(),ea=ca.assembly;N=this._gpEncode(T.mixin({},this._url.query,{f:"json","env:outSR":Z?Z.wkid||O.toJson(Z.toJson()):null,"env:processSR":this.processSpatialReference?this.processSpatialReference.wkid||O.toJson(this.processSpatialReference.toJson()):null},N),null,
ea&&ea[0]);var C=this._jobUpdateHandler,da=this._errorHandler;return t({url:this._url.path+"/submitJob",content:N,callbackParamName:"callback",load:function(Y,w){C(Y,w,!1,D,G,ca.dfd)},error:function(Y){da(Y,aa,ca.dfd)}})},_jobUpdateHandler:function(N,D,G,aa,ca,Z){var ea=N.jobId;D=new d(N);this._successHandler([D],"onStatusUpdate",ca,G&&Z);if(!G)switch(clearTimeout(this._updateTimers[ea]),this._updateTimers[ea]=null,Z&&Z.progress(D),N.jobStatus){case d.STATUS_SUBMITTED:case d.STATUS_EXECUTING:case d.STATUS_WAITING:case d.STATUS_NEW:var C=
this._getJobStatus;this._updateTimers[ea]=setTimeout(function(){C(ea,G,aa,ca,Z)},this.updateDelay);break;default:this._successHandler([D],"onJobComplete",aa,Z)}},_getJobStatus:function(N,D,G,aa,ca){var Z=this._jobUpdateHandler;t({url:this._url.path+"/jobs/"+N,content:T.mixin({},this._url.query,{f:"json"}),callbackParamName:"callback",load:function(ea,C){Z(ea,C,D,G,aa,ca)},error:this._errorHandler})},_getResultDataHandler:function(N,D,G,aa,ca){try{var Z=this._decode(N);this._successHandler([Z],"onGetResultDataComplete",
G,ca)}catch(ea){this._errorHandler(ea,aa,ca)}},getResultData:function(N,D,G,aa){var ca=this._getResultDataHandler,Z=this._errorHandler,ea=new Q(k._dfdCanceller);ea._pendingDfd=t({url:this._url.path+"/jobs/"+N+"/results/"+D,content:T.mixin({},this._url.query,{f:"json",returnType:"data"}),callbackParamName:"callback",load:function(C,da){ca(C,da,G,aa,ea)},error:function(C){Z(C,aa,ea)}});return ea},checkJobStatus:function(N,D,G){var aa=this._jobUpdateHandler,ca=this._errorHandler,Z=new Q(k._dfdCanceller);
Z._pendingDfd=t({url:this._url.path+"/jobs/"+N,content:T.mixin({},this._url.query,{f:"json"}),callbackParamName:"callback",load:function(ea,C){aa(ea,C,!0,null,D,Z)},error:function(ea){ca(ea,G,Z)}});return Z},cancelJob:function(N,D,G){var aa=this._errorHandler,ca=new Q(k._dfdCanceller);ca._pendingDfd=t({url:this._url.path+"/jobs/"+N+"/cancel",content:T.mixin({},this._url.query,{f:"json"}),callbackParamName:"callback",load:T.hitch(this,function(Z,ea){this._successHandler([Z],"onJobCancel",D,ca)}),error:function(Z){aa(Z,
G,ca)}});return ca},execute:function(N,D,G,aa){var ca=this._getOutSR(),Z=aa.assembly;N=this._gpEncode(T.mixin({},this._url.query,{f:"json","env:outSR":ca?ca.wkid||O.toJson(ca.toJson()):null,"env:processSR":this.processSpatialReference?this.processSpatialReference.wkid||O.toJson(this.processSpatialReference.toJson()):null},N),null,Z&&Z[0]);var ea=this._executeHandler,C=this._errorHandler;return t({url:this._url.path+"/execute",content:N,callbackParamName:"callback",load:function(da,Y){ea(da,Y,D,G,
aa.dfd)},error:function(da){C(da,G,aa.dfd)}})},_executeHandler:function(N,D,G,aa,ca){try{var Z=N.results,ea,C=N.messages;var da=0;for(ea=Z.length;da<ea;da++)Z[da]=this._decode(Z[da]);da=0;for(ea=C.length;da<ea;da++)C[da]=new r(C[da]);this._successHandler([Z,C],"onExecuteComplete",G,ca)}catch(Y){this._errorHandler(Y,aa,ca)}},_getResultImageHandler:function(N,D,G,aa,ca){try{var Z=this._decode(N);this._successHandler([Z],"onGetResultImageComplete",G,ca)}catch(ea){this._errorHandler(ea,aa,ca)}},getResultImage:function(N,
D,G,aa,ca){var Z=this._getResultImageHandler,ea=this._errorHandler;G=this._gpEncode(T.mixin({},this._url.query,{f:"json"},G.toJson()));var C=new Q(k._dfdCanceller);C._pendingDfd=t({url:this._url.path+"/jobs/"+N+"/results/"+D,content:G,callbackParamName:"callback",load:function(da,Y){Z(da,Y,aa,ca,C)},error:function(da){ea(da,ca,C)}});return C},cancelJobStatusUpdates:function(N){clearTimeout(this._updateTimers[N]);this._updateTimers[N]=null},getResultImageLayer:function(N,D,G,aa){if(null==D){var ca=
this._url.path.indexOf("/GPServer/");N=this._url.path.substring(0,ca)+"/MapServer/jobs/"+N}else N=this._url.path+"/jobs/"+N+"/results/"+D;this._url.query&&(N+="?"+H.objectToQuery(this._url.query));D=null==D?new U(N,{imageParameters:G}):new J(N,{imageParameters:G},!0);this.onGetResultImageLayerComplete(D);aa&&aa(D);return D},onStatusUpdate:function(){},onJobComplete:function(){},onExecuteComplete:function(){},onGetResultDataComplete:function(){},onGetResultImageComplete:function(){},onGetResultImageLayerComplete:function(){},
onJobCancel:function(){}});A._createWrappers(I);M("extend-esri")&&T.setObject("tasks.Geoprocessor",I,F);return I})},"esri/tasks/JobInfo":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel","./GPMessage"],function(I,T,g,Q,O){I=I(null,{declaredClass:"esri.tasks.JobInfo",constructor:function(M){this.messages=[];T.mixin(this,M);M=this.messages;var H,F=M.length;for(H=0;H<F;H++)M[H]=new O(M[H])},jobId:"",jobStatus:""});T.mixin(I,{STATUS_CANCELLED:"esriJobCancelled",STATUS_CANCELLING:"esriJobCancelling",
STATUS_DELETED:"esriJobDeleted",STATUS_DELETING:"esriJobDeleting",STATUS_EXECUTING:"esriJobExecuting",STATUS_FAILED:"esriJobFailed",STATUS_NEW:"esriJobNew",STATUS_SUBMITTED:"esriJobSubmitted",STATUS_SUCCEEDED:"esriJobSucceeded",STATUS_TIMED_OUT:"esriJobTimedOut",STATUS_WAITING:"esriJobWaiting"});g("extend-esri")&&T.setObject("tasks.JobInfo",I,Q);return I})},"esri/tasks/GPMessage":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel"],function(I,T,g,Q){I=I(null,{declaredClass:"esri.tasks.GPMessage",
constructor:function(O){T.mixin(this,O)}});T.mixin(I,{TYPE_INFORMATIVE:"esriJobMessageTypeInformative",TYPE_PROCESS_DEFINITION:"esriJobMessageTypeProcessDefinition",TYPE_PROCESS_START:"esriJobMessageTypeProcessStart",TYPE_PROCESS_STOP:"esriJobMessageTypeProcessStop",TYPE_WARNING:"esriJobMessageTypeWarning",TYPE_ERROR:"esriJobMessageTypeError",TYPE_EMPTY:"esriJobMessageTypeEmpty",TYPE_ABORT:"esriJobMessageTypeAbort"});g("extend-esri")&&T.setObject("tasks.GPMessage",I,Q);return I})},"esri/tasks/LinearUnit":function(){define(["dojo/_base/declare",
"dojo/_base/lang","dojo/has","../kernel"],function(I,T,g,Q){I=I(null,{declaredClass:"esri.tasks.LinearUnit",constructor:function(O){O&&T.mixin(this,O)},distance:0,units:null,toJson:function(){var O={};this.distance&&(O.distance=this.distance);this.units&&(O.units=this.units);return O}});g("extend-esri")&&T.setObject("tasks.LinearUnit",I,Q);return I})},"esri/tasks/DataFile":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel"],function(I,T,g,Q){I=I(null,{declaredClass:"esri.tasks.DataFile",
constructor:function(O){O&&T.mixin(this,O)},url:null,itemID:null,toJson:function(){var O={};this.url&&(O.url=this.url);this.itemID&&(O.itemID=this.itemID);return O}});g("extend-esri")&&T.setObject("tasks.DataFile",I,Q);return I})},"esri/tasks/RasterData":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel"],function(I,T,g,Q){I=I(null,{declaredClass:"esri.tasks.RasterData",constructor:function(O){O&&T.mixin(this,O)},url:null,format:null,itemID:null,toJson:function(){var O=
{};this.url&&(O.url=this.url);this.format&&(O.format=this.format);this.itemID&&(O.itemID=this.itemID);return O}});g("extend-esri")&&T.setObject("tasks.RasterData",I,Q);return I})},"esri/tasks/Date":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/date/locale","dojo/has","../kernel"],function(I,T,g,Q,O){I=I(null,{declaredClass:"esri.tasks.Date",constructor:function(M){M&&(M.format&&(this.format=M.format),this.date=g.parse(M.date,{selector:"date",datePattern:this.format}))},date:new Date,
format:"EEE MMM dd HH:mm:ss zzz yyyy",toJson:function(){return{date:g.format(this.date,{selector:"date",datePattern:this.format}),format:this.format}}});Q("extend-esri")&&T.setObject("tasks.Date",I,O);return I})},"esri/tasks/ParameterValue":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel"],function(I,T,g,Q){I=I(null,{declaredClass:"esri.tasks.ParameterValue",constructor:function(O){T.mixin(this,O)}});g("extend-esri")&&T.setObject("tasks.ParameterValue",I,Q);return I})},
"esri/tasks/GPResultImageLayer":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/json dojo/has dojo/io-query ../kernel ../layers/ArcGISDynamicMapServiceLayer".split(" "),function(I,T,g,Q,O,M,H){I=I(H,{declaredClass:"esri.tasks._GPResultImageLayer",constructor:function(F,t){t&&t.imageParameters&&t.imageParameters.extent&&(this.initialExtent=this.fullExtent=t.imageParameters.extent,this.spatialReference=this.initialExtent.spatialReference);this.getImageUrl=T.hitch(this,this.getImageUrl);
this.loaded=!0;this.onLoad(this)},getImageUrl:function(F,t,k,A){var m=F.spatialReference.wkid;A(this._url.path+"?"+O.objectToQuery(T.mixin(this._params,{f:"image",bbox:g.toJson(F.toJson()),bboxSR:m,imageSR:m,size:t+","+k})))}});Q("extend-esri")&&T.setObject("tasks._GPResultImageLayer",I,M);return I})},"esri/tasks/PrintTemplate":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel"],function(I,T,g,Q){I=I(null,{declaredClass:"esri.tasks.PrintTemplate",label:null,exportOptions:{width:800,
height:1100,dpi:96},layoutOptions:null,format:"PNG32",layout:"MAP_ONLY",outScale:0,preserveScale:!0,forceFeatureAttributes:!1,showAttribution:null,showLabels:!0});g("extend-esri")&&T.setObject("tasks.PrintTemplate",I,Q);return I})},"dojox/gfx/canvas":function(){define("./_base dojo/_base/lang dojo/_base/array dojo/_base/declare dojo/_base/window dojo/dom-geometry dojo/dom ./shape ./path ./arc ./matrix ./decompose ./bezierutils".split(" "),function(I,T,g,Q,O,M,H,F,t,k,A,m,e){function d(w,n,u,W,ja,
ba,ka,sa,qa,ya){var ra=n.length,Ea=0;if(ya){var b=ya.l/ja;Ea=ya.i}else b=n[0]/ja;for(;ba<ka;){if(ba+b>ka){var l={l:(ba+b-ka)*ja,i:Ea};b=ka-ba}Ea%2||(w.beginPath(),w.arc(u,W,ja,ba,ba+b,sa),qa&&w.stroke());ba+=b;++Ea;b=n[Ea%ra]/ja}return l}function r(w,n,u,W){var ja=0,ba=0,ka=0;if(W){var sa=W.l;ka=W.i}else sa=n[0];for(;1>ba;)ba=e.tAtLength(w,sa),1==ba&&(ja=e.computeLength(w),ja={l:sa-ja,i:ka}),w=e.splitBezierAtT(w,ba),ka%2||u.push(w[0]),w=w[1],++ka,sa=n[ka%n.length];return ja}function y(w,n,u,W){var ja=
[n.last.x,n.last.y].concat(u),ba=!(w instanceof Array);u=4===u.length?"quadraticCurveTo":"bezierCurveTo";var ka=[];n=r(ja,n.canvasDash,ka,W);for(W=0;W<ka.length;++W)ja=ka[W],ba?(w.moveTo(ja[0],ja[1]),w[u].apply(w,ja.slice(2))):(w.push("moveTo",[ja[0],ja[1]]),w.push(u,ja.slice(2)));return n}function z(w,n,u,W,ja,ba,ka){var sa=0,qa=0,ya=0,ra=e.distance(u,W,ja,ba),Ea=0;n=n.canvasDash;var b=u,l=W,B=!(w instanceof Array);ka?(ya=ka.l,Ea=ka.i):ya+=n[0];for(;.01<Math.abs(1-qa);){ya>ra&&(sa={l:ya-ra,i:Ea},
ya=ra);qa=ya/ra;ka=u+(ja-u)*qa;var E=W+(ba-W)*qa;Ea++%2||(B?(w.moveTo(b,l),w.lineTo(ka,E)):(w.push("moveTo",[b,l]),w.push("lineTo",[ka,E])));b=ka;l=E;ya+=n[Ea%n.length]}return sa}var h=I.canvas={},v=null,L=A.multiplyPoint,J=Math.PI,U=2*J,S=J/2;m=T.extend;if(O.global.CanvasRenderingContext2D){O=O.doc.createElement("canvas").getContext("2d");var N="function"==typeof O.setLineDash,D="function"==typeof O.fillText}var G={solid:"none",shortdash:[4,1],shortdot:[1,1],shortdashdot:[4,1,1,1],shortdashdotdot:[4,
1,1,1,1,1],dot:[1,3],dash:[4,3],longdash:[8,3],dashdot:[4,3,1,3],longdashdot:[8,3,1,3],longdashdotdot:[8,3,1,3,1,3]};h.Shape=Q("dojox.gfx.canvas.Shape",F.Shape,{_render:function(w){w.save();this._renderTransform(w);this._renderClip(w);this._renderShape(w);this._renderFill(w,!0);this._renderStroke(w,!0);w.restore()},_renderClip:function(w){this.canvasClip&&(this.canvasClip.render(w),w.clip())},_renderTransform:function(w){if("canvasTransform"in this){var n=this.canvasTransform;w.translate(n.dx,n.dy);
w.rotate(n.angle2);w.scale(n.sx,n.sy);w.rotate(n.angle1)}},_renderShape:function(w){},_renderFill:function(w,n){if("canvasFill"in this){var u=this.fillStyle;if("canvasFillImage"in this){var W=u.width,ja=u.height,ba=this.canvasFillImage.width,ka=this.canvasFillImage.height,sa=Math.min(W==ba?1:W/ba,ja==ka?1:ja/ka),qa=(W-sa*ba)/2,ya=(ja-sa*ka)/2;v.width=W;v.height=ja;var ra=v.getContext("2d");ra.clearRect(0,0,W,ja);ra.drawImage(this.canvasFillImage,0,0,ba,ka,qa,ya,sa*ba,sa*ka);this.canvasFill=w.createPattern(v,
"repeat");delete this.canvasFillImage}w.fillStyle=this.canvasFill;n&&("pattern"!==u.type||0===u.x&&0===u.y||w.translate(u.x,u.y),w.fill())}else w.fillStyle="rgba(0,0,0,0.0)"},_renderStroke:function(w,n){var u=this.strokeStyle;u?(w.strokeStyle=u.color.toString(),w.lineWidth=u.width,w.lineCap=u.cap,"number"==typeof u.join?(w.lineJoin="miter",w.miterLimit=u.join):w.lineJoin=u.join,this.canvasDash?N?(w.setLineDash(this.canvasDash),n&&w.stroke()):this._renderDashedStroke(w,n):n&&w.stroke()):n||(w.strokeStyle=
"rgba(0,0,0,0.0)")},_renderDashedStroke:function(w,n){},getEventSource:function(){return null},on:function(){},connect:function(){},disconnect:function(){},canvasClip:null,setClip:function(w){this.inherited(arguments);var n=w?"width"in w?"rect":"cx"in w?"ellipse":"points"in w?"polyline":"d"in w?"path":null:null;if(w&&!n)return this;this.canvasClip=w?aa(n,w):null;this.parent&&this.parent._makeDirty();return this}});var aa=function(w,n){switch(w){case "ellipse":return{canvasEllipse:C({shape:n}),render:function(u){return h.Ellipse.prototype._renderShape.call(this,
u)}};case "rect":return{shape:T.delegate(n,{r:0}),render:function(u){return h.Rect.prototype._renderShape.call(this,u)}};case "path":return{canvasPath:ca(n),render:function(u){this.canvasPath._renderShape(u)}};case "polyline":return{canvasPolyline:n.points,render:function(u){return h.Polyline.prototype._renderShape.call(this,u)}}}return null},ca=function(w){var n=new dojox.gfx.canvas.Path;n.canvasPath=[];n._setPath(w.d);return n},Z=function(w,n,u){var W=w.prototype[n];w.prototype[n]=u?function(){this.parent&&
this.parent._makeDirty();W.apply(this,arguments);u.call(this);return this}:function(){this.parent&&this.parent._makeDirty();return W.apply(this,arguments)}};Z(h.Shape,"setTransform",function(){this.matrix?this.canvasTransform=I.decompose(this.matrix):delete this.canvasTransform});Z(h.Shape,"setFill",function(){var w=this.fillStyle;if(w){if("object"==typeof w&&"type"in w){var n=this.surface.rawNode.getContext("2d");switch(w.type){case "linear":case "radial":var u="linear"==w.type?n.createLinearGradient(w.x1,
w.y1,w.x2,w.y2):n.createRadialGradient(w.cx,w.cy,0,w.cx,w.cy,w.r);g.forEach(w.colors,function(W){u.addColorStop(W.offset,I.normalizeColor(W.color).toString())});break;case "pattern":v||(v=document.createElement("canvas")),n=new Image,this.surface.downloadImage(n,w.src),this.canvasFillImage=n}}else u=w.toString();this.canvasFill=u}else delete this.canvasFill});Z(h.Shape,"setStroke",function(){var w=this.strokeStyle;if(w){var n=this.strokeStyle.style.toLowerCase();n in G&&(n=G[n]);if(n instanceof Array){this.canvasDash=
n=n.slice();var u;for(u=0;u<n.length;++u)n[u]*=w.width;if("butt"!=w.cap){for(u=0;u<n.length;u+=2)n[u]-=w.width,1>n[u]&&(n[u]=1);for(u=1;u<n.length;u+=2)n[u]+=w.width}}else delete this.canvasDash}else delete this.canvasDash;this._needsDash=!N&&!!this.canvasDash});Z(h.Shape,"setShape");h.Group=Q("dojox.gfx.canvas.Group",h.Shape,{constructor:function(){F.Container._init.call(this)},_render:function(w){w.save();this._renderTransform(w);this._renderClip(w);for(var n=0;n<this.children.length;++n)this.children[n]._render(w);
w.restore()},destroy:function(){F.Container.clear.call(this,!0);h.Shape.prototype.destroy.apply(this,arguments)}});h.Rect=Q("dojox.gfx.canvas.Rect",[h.Shape,F.Rect],{_renderShape:function(w){var n=this.shape,u=Math.min(n.r,n.height/2,n.width/2),W=n.x,ja=W+n.width,ba=n.y;n=ba+n.height;var ka=W+u,sa=ja-u,qa=ba+u,ya=n-u;w.beginPath();w.moveTo(ka,ba);u?(w.arc(sa,qa,u,-S,0,!1),w.arc(sa,ya,u,0,S,!1),w.arc(ka,ya,u,S,J,!1),w.arc(ka,qa,u,J,J+S,!1)):(w.lineTo(sa,ba),w.lineTo(ja,ya),w.lineTo(ka,n),w.lineTo(W,
qa));w.closePath()},_renderDashedStroke:function(w,n){var u=this.shape,W=Math.min(u.r,u.height/2,u.width/2),ja=u.x,ba=ja+u.width,ka=u.y,sa=ka+u.height,qa=ja+W,ya=ba-W,ra=ka+W,Ea=sa-W;W?(w.beginPath(),u=z(w,this,qa,ka,ya,ka),n&&w.stroke(),u=d(w,this.canvasDash,ya,ra,W,-S,0,!1,n,u),w.beginPath(),u=z(w,this,ba,ra,ba,Ea,u),n&&w.stroke(),u=d(w,this.canvasDash,ya,Ea,W,0,S,!1,n,u),w.beginPath(),u=z(w,this,ya,sa,qa,sa,u),n&&w.stroke(),u=d(w,this.canvasDash,qa,Ea,W,S,J,!1,n,u),w.beginPath(),u=z(w,this,ja,
Ea,ja,ra,u),n&&w.stroke(),d(w,this.canvasDash,qa,ra,W,J,J+S,!1,n,u)):(w.beginPath(),u=z(w,this,qa,ka,ya,ka),u=z(w,this,ya,ka,ba,Ea,u),u=z(w,this,ba,Ea,qa,sa,u),z(w,this,qa,sa,ja,ra,u),n&&w.stroke())}});var ea=[];(function(){var w=k.curvePI4;ea.push(w.s,w.c1,w.c2,w.e);for(var n=45;360>n;n+=45){var u=A.rotateg(n);ea.push(L(u,w.c1),L(u,w.c2),L(u,w.e))}})();var C=function(w){var n=[],u=w.shape,W=A.normalize([A.translate(u.cx,u.cy),A.scale(u.rx,u.ry)]);var ja=L(W,ea[0]);n.push([ja.x,ja.y]);for(u=1;u<ea.length;u+=
3){var ba=L(W,ea[u]);var ka=L(W,ea[u+1]);ja=L(W,ea[u+2]);n.push([ba.x,ba.y,ka.x,ka.y,ja.x,ja.y])}if(w._needsDash){ja=[];ba=n[0];for(u=1;u<n.length;++u)ka=[],r(ba.concat(n[u]),w.canvasDash,ka),ba=[n[u][4],n[u][5]],ja.push(ka);w._dashedPoints=ja}return n};h.Ellipse=Q("dojox.gfx.canvas.Ellipse",[h.Shape,F.Ellipse],{setShape:function(){this.inherited(arguments);this.canvasEllipse=C(this);return this},setStroke:function(){this.inherited(arguments);N||(this.canvasEllipse=C(this));return this},_renderShape:function(w){var n=
this.canvasEllipse,u;w.beginPath();w.moveTo.apply(w,n[0]);for(u=1;u<n.length;++u)w.bezierCurveTo.apply(w,n[u]);w.closePath()},_renderDashedStroke:function(w,n){var u=this._dashedPoints;w.beginPath();for(var W=0;W<u.length;++W)for(var ja=u[W],ba=0;ba<ja.length;++ba){var ka=ja[ba];w.moveTo(ka[0],ka[1]);w.bezierCurveTo(ka[2],ka[3],ka[4],ka[5],ka[6],ka[7])}n&&w.stroke()}});h.Circle=Q("dojox.gfx.canvas.Circle",[h.Shape,F.Circle],{_renderShape:function(w){var n=this.shape;w.beginPath();w.arc(n.cx,n.cy,
n.r,0,U,1)},_renderDashedStroke:function(w,n){var u=this.shape,W=0,ja=this.canvasDash.length;for(i=0;W<U;){var ba=this.canvasDash[i%ja]/u.r;i%2||(w.beginPath(),w.arc(u.cx,u.cy,u.r,W,W+ba,0),n&&w.stroke());W+=ba;++i}}});h.Line=Q("dojox.gfx.canvas.Line",[h.Shape,F.Line],{_renderShape:function(w){var n=this.shape;w.beginPath();w.moveTo(n.x1,n.y1);w.lineTo(n.x2,n.y2)},_renderDashedStroke:function(w,n){var u=this.shape;w.beginPath();z(w,this,u.x1,u.y1,u.x2,u.y2);n&&w.stroke()}});h.Polyline=Q("dojox.gfx.canvas.Polyline",
[h.Shape,F.Polyline],{setShape:function(){this.inherited(arguments);var w=this.shape.points,n=w[0],u;this.bbox=null;this._normalizePoints();if(w.length)if("number"==typeof n)n=w;else for(n=[],u=0;u<w.length;++u){var W=w[u];n.push(W.x,W.y)}else n=[];this.canvasPolyline=n;return this},_renderShape:function(w){var n=this.canvasPolyline;if(n.length){w.beginPath();w.moveTo(n[0],n[1]);for(var u=2;u<n.length;u+=2)w.lineTo(n[u],n[u+1])}},_renderDashedStroke:function(w,n){var u=this.canvasPolyline,W=0;w.beginPath();
for(var ja=0;ja<u.length;ja+=2)W=z(w,this,u[ja],u[ja+1],u[ja+2],u[ja+3],W);n&&w.stroke()}});h.Image=Q("dojox.gfx.canvas.Image",[h.Shape,F.Image],{setShape:function(){this.inherited(arguments);var w=new Image;this.surface.downloadImage(w,this.shape.src);this.canvasImage=w;return this},_renderShape:function(w){var n=this.shape;w.drawImage(this.canvasImage,n.x,n.y,n.width,n.height)}});h.Text=Q("dojox.gfx.canvas.Text",[h.Shape,F.Text],{_setFont:function(){this.fontStyle?this.canvasFont=I.makeFontString(this.fontStyle):
delete this.canvasFont},getTextWidth:function(){var w=this.shape,n=0;if(w.text){var u=this.surface.rawNode.getContext("2d");u.save();this._renderTransform(u);this._renderFill(u,!1);this._renderStroke(u,!1);this.canvasFont&&(u.font=this.canvasFont);n=u.measureText(w.text).width;u.restore()}return n},_render:function(w){w.save();this._renderTransform(w);this._renderFill(w,!1);this._renderStroke(w,!1);this._renderShape(w);w.restore()},_renderShape:function(w){var n=this.shape;n.text&&(w.textAlign="middle"===
n.align?"center":n.align,this.canvasFont&&(w.font=this.canvasFont),this.canvasFill&&w.fillText(n.text,n.x,n.y),this.strokeStyle&&(w.beginPath(),w.strokeText(n.text,n.x,n.y),w.closePath()))}});Z(h.Text,"setFont");D||h.Text.extend({getTextWidth:function(){return 0},getBoundingBox:function(){return null},_renderShape:function(){}});var da={M:"_moveToA",m:"_moveToR",L:"_lineToA",l:"_lineToR",H:"_hLineToA",h:"_hLineToR",V:"_vLineToA",v:"_vLineToR",C:"_curveToA",c:"_curveToR",S:"_smoothCurveToA",s:"_smoothCurveToR",
Q:"_qCurveToA",q:"_qCurveToR",T:"_qSmoothCurveToA",t:"_qSmoothCurveToR",A:"_arcTo",a:"_arcTo",Z:"_closePath",z:"_closePath"};h.Path=Q("dojox.gfx.canvas.Path",[h.Shape,t.Path],{constructor:function(){this.lastControl={}},setShape:function(){this.canvasPath=[];this._dashedPath=[];return this.inherited(arguments)},setStroke:function(){this.inherited(arguments);N||(this.segmented=!1,this._confirmSegmented());return this},_setPath:function(){this._dashResidue=null;this.inherited(arguments)},_updateWithSegment:function(w){var n=
T.clone(this.last);this[da[w.action]](this.canvasPath,w.action,w.args,this._needsDash?this._dashedPath:null);this.last=n;this.inherited(arguments)},_renderShape:function(w){var n=this.canvasPath;w.beginPath();for(var u=0;u<n.length;u+=2)w[n[u]].apply(w,n[u+1])},_renderDashedStroke:N?function(){}:function(w,n){var u=this._dashedPath;w.beginPath();for(var W=0;W<u.length;W+=2)w[u[W]].apply(w,u[W+1]);n&&w.stroke()},_moveToA:function(w,n,u,W){w.push("moveTo",[u[0],u[1]]);W&&W.push("moveTo",[u[0],u[1]]);
for(n=2;n<u.length;n+=2)w.push("lineTo",[u[n],u[n+1]]),W&&(this._dashResidue=z(W,this,u[n-2],u[n-1],u[n],u[n+1],this._dashResidue));this.last.x=u[u.length-2];this.last.y=u[u.length-1];this.lastControl={}},_moveToR:function(w,n,u,W){n="x"in this.last?[this.last.x+=u[0],this.last.y+=u[1]]:[this.last.x=u[0],this.last.y=u[1]];w.push("moveTo",n);W&&W.push("moveTo",n);for(n=2;n<u.length;n+=2)w.push("lineTo",[this.last.x+=u[n],this.last.y+=u[n+1]]),W&&(this._dashResidue=z(W,this,W[W.length-1][0],W[W.length-
1][1],this.last.x,this.last.y,this._dashResidue));this.lastControl={}},_lineToA:function(w,n,u,W){for(n=0;n<u.length;n+=2)W&&(this._dashResidue=z(W,this,this.last.x,this.last.y,u[n],u[n+1],this._dashResidue)),w.push("lineTo",[u[n],u[n+1]]);this.last.x=u[u.length-2];this.last.y=u[u.length-1];this.lastControl={}},_lineToR:function(w,n,u,W){for(n=0;n<u.length;n+=2)w.push("lineTo",[this.last.x+=u[n],this.last.y+=u[n+1]]),W&&(this._dashResidue=z(W,this,W[W.length-1][0],W[W.length-1][1],this.last.x,this.last.y,
this._dashResidue));this.lastControl={}},_hLineToA:function(w,n,u,W){for(n=0;n<u.length;++n)w.push("lineTo",[u[n],this.last.y]),W&&(this._dashResidue=z(W,this,W[W.length-1][0],W[W.length-1][1],u[n],this.last.y,this._dashResidue));this.last.x=u[u.length-1];this.lastControl={}},_hLineToR:function(w,n,u,W){for(n=0;n<u.length;++n)w.push("lineTo",[this.last.x+=u[n],this.last.y]),W&&(this._dashResidue=z(W,this,W[W.length-1][0],W[W.length-1][1],this.last.x,this.last.y,this._dashResidue));this.lastControl=
{}},_vLineToA:function(w,n,u,W){for(n=0;n<u.length;++n)w.push("lineTo",[this.last.x,u[n]]),W&&(this._dashResidue=z(W,this,W[W.length-1][0],W[W.length-1][1],this.last.x,u[n],this._dashResidue));this.last.y=u[u.length-1];this.lastControl={}},_vLineToR:function(w,n,u,W){for(n=0;n<u.length;++n)w.push("lineTo",[this.last.x,this.last.y+=u[n]]),W&&(this._dashResidue=z(W,this,W[W.length-1][0],W[W.length-1][1],this.last.x,this.last.y,this._dashResidue));this.lastControl={}},_curveToA:function(w,n,u,W){for(n=
0;n<u.length;n+=6)w.push("bezierCurveTo",u.slice(n,n+6)),W&&(this._dashResidue=y(W,this,w[w.length-1],this._dashResidue));this.last.x=u[u.length-2];this.last.y=u[u.length-1];this.lastControl.x=u[u.length-4];this.lastControl.y=u[u.length-3];this.lastControl.type="C"},_curveToR:function(w,n,u,W){for(n=0;n<u.length;n+=6)w.push("bezierCurveTo",[this.last.x+u[n],this.last.y+u[n+1],this.lastControl.x=this.last.x+u[n+2],this.lastControl.y=this.last.y+u[n+3],this.last.x+u[n+4],this.last.y+u[n+5]]),W&&(this._dashResidue=
y(W,this,w[w.length-1],this._dashResidue)),this.last.x+=u[n+4],this.last.y+=u[n+5];this.lastControl.type="C"},_smoothCurveToA:function(w,n,u,W){for(n=0;n<u.length;n+=4){var ja="C"==this.lastControl.type;w.push("bezierCurveTo",[ja?2*this.last.x-this.lastControl.x:this.last.x,ja?2*this.last.y-this.lastControl.y:this.last.y,u[n],u[n+1],u[n+2],u[n+3]]);W&&(this._dashResidue=y(W,this,w[w.length-1],this._dashResidue));this.lastControl.x=u[n];this.lastControl.y=u[n+1];this.lastControl.type="C"}this.last.x=
u[u.length-2];this.last.y=u[u.length-1]},_smoothCurveToR:function(w,n,u,W){for(n=0;n<u.length;n+=4){var ja="C"==this.lastControl.type;w.push("bezierCurveTo",[ja?2*this.last.x-this.lastControl.x:this.last.x,ja?2*this.last.y-this.lastControl.y:this.last.y,this.last.x+u[n],this.last.y+u[n+1],this.last.x+u[n+2],this.last.y+u[n+3]]);W&&(this._dashResidue=y(W,this,w[w.length-1],this._dashResidue));this.lastControl.x=this.last.x+u[n];this.lastControl.y=this.last.y+u[n+1];this.lastControl.type="C";this.last.x+=
u[n+2];this.last.y+=u[n+3]}},_qCurveToA:function(w,n,u,W){for(n=0;n<u.length;n+=4)w.push("quadraticCurveTo",u.slice(n,n+4));W&&(this._dashResidue=y(W,this,w[w.length-1],this._dashResidue));this.last.x=u[u.length-2];this.last.y=u[u.length-1];this.lastControl.x=u[u.length-4];this.lastControl.y=u[u.length-3];this.lastControl.type="Q"},_qCurveToR:function(w,n,u,W){for(n=0;n<u.length;n+=4)w.push("quadraticCurveTo",[this.lastControl.x=this.last.x+u[n],this.lastControl.y=this.last.y+u[n+1],this.last.x+u[n+
2],this.last.y+u[n+3]]),W&&(this._dashResidue=y(W,this,w[w.length-1],this._dashResidue)),this.last.x+=u[n+2],this.last.y+=u[n+3];this.lastControl.type="Q"},_qSmoothCurveToA:function(w,n,u,W){for(n=0;n<u.length;n+=2){var ja="Q"==this.lastControl.type;w.push("quadraticCurveTo",[this.lastControl.x=ja?2*this.last.x-this.lastControl.x:this.last.x,this.lastControl.y=ja?2*this.last.y-this.lastControl.y:this.last.y,u[n],u[n+1]]);W&&(this._dashResidue=y(W,this,w[w.length-1],this._dashResidue));this.lastControl.type=
"Q"}this.last.x=u[u.length-2];this.last.y=u[u.length-1]},_qSmoothCurveToR:function(w,n,u,W){for(n=0;n<u.length;n+=2){var ja="Q"==this.lastControl.type;w.push("quadraticCurveTo",[this.lastControl.x=ja?2*this.last.x-this.lastControl.x:this.last.x,this.lastControl.y=ja?2*this.last.y-this.lastControl.y:this.last.y,this.last.x+u[n],this.last.y+u[n+1]]);W&&(this._dashResidue=y(W,this,w[w.length-1],this._dashResidue));this.lastControl.type="Q";this.last.x+=u[n];this.last.y+=u[n+1]}},_arcTo:function(w,n,
u,W){n="a"==n;for(var ja=0;ja<u.length;ja+=7){var ba=u[ja+5],ka=u[ja+6];n&&(ba+=this.last.x,ka+=this.last.y);var sa=k.arcAsBezier(this.last,u[ja],u[ja+1],u[ja+2],u[ja+3]?1:0,u[ja+4]?1:0,ba,ka);g.forEach(sa,function(qa){w.push("bezierCurveTo",qa)});W&&(this._dashResidue=y(W,this,p,this._dashResidue));this.last.x=ba;this.last.y=ka}this.lastControl={}},_closePath:function(w,n,u,W){w.push("closePath",[]);W&&(this._dashResidue=z(W,this,this.last.x,this.last.y,W[1][0],W[1][1],this._dashResidue));this.lastControl=
{}}});g.forEach("moveTo lineTo hLineTo vLineTo curveTo smoothCurveTo qCurveTo qSmoothCurveTo arcTo closePath".split(" "),function(w){Z(h.Path,w)});h.TextPath=Q("dojox.gfx.canvas.TextPath",[h.Shape,t.TextPath],{_renderShape:function(w){},_setText:function(){},_setFont:function(){}});h.Surface=Q("dojox.gfx.canvas.Surface",F.Surface,{constructor:function(){F.Container._init.call(this);this.pendingImageCount=0;this.makeDirty()},destroy:function(){F.Container.clear.call(this,!0);this.inherited(arguments)},
setDimensions:function(w,n){this.width=I.normalizedLength(w);this.height=I.normalizedLength(n);if(!this.rawNode)return this;w=!1;this.rawNode.width!=this.width&&(this.rawNode.width=this.width,w=!0);this.rawNode.height!=this.height&&(this.rawNode.height=this.height,w=!0);w&&this.makeDirty();return this},getDimensions:function(){return this.rawNode?{width:this.rawNode.width,height:this.rawNode.height}:null},_render:function(w){!this.rawNode||!w&&this.pendingImageCount||(w=this.rawNode.getContext("2d"),
w.clearRect(0,0,this.rawNode.width,this.rawNode.height),this.render(w),"pendingRender"in this&&(clearTimeout(this.pendingRender),delete this.pendingRender))},render:function(w){w.save();for(var n=0;n<this.children.length;++n)this.children[n]._render(w);w.restore()},makeDirty:function(){this.pendingImagesCount||"pendingRender"in this||this._batch||(this.pendingRender=setTimeout(T.hitch(this,this._render),0))},downloadImage:function(w,n){var u=T.hitch(this,this.onImageLoad);!this.pendingImageCount++&&
"pendingRender"in this&&(clearTimeout(this.pendingRender),delete this.pendingRender);w.onload=u;w.onerror=u;w.onabort=u;w.src=n},onImageLoad:function(){--this.pendingImageCount||(this.onImagesLoaded(),this._render())},onImagesLoaded:function(){},getEventSource:function(){return null},connect:function(){},disconnect:function(){},on:function(){}});h.createSurface=function(w,n,u){if(!n&&!u){var W=M.position(w);n=n||W.w;u=u||W.h}"number"==typeof n&&(n+="px");"number"==typeof u&&(u+="px");W=new h.Surface;
w=H.byId(w);var ja=w.ownerDocument.createElement("canvas");ja.width=I.normalizedLength(n);ja.height=I.normalizedLength(u);w.appendChild(ja);W.rawNode=ja;W._parent=w;return W.surface=W};var Y=F.Container;Q={openBatch:function(){++this._batch;return this},closeBatch:function(){this._batch=0<this._batch?--this._batch:0;this._makeDirty();return this},_makeDirty:function(){this._batch||this.surface.makeDirty()},add:function(w){this._makeDirty();return Y.add.apply(this,arguments)},remove:function(w,n){this._makeDirty();
return Y.remove.apply(this,arguments)},clear:function(){this._makeDirty();return Y.clear.apply(this,arguments)},getBoundingBox:Y.getBoundingBox,_moveChildToFront:function(w){this._makeDirty();return Y._moveChildToFront.apply(this,arguments)},_moveChildToBack:function(w){this._makeDirty();return Y._moveChildToBack.apply(this,arguments)}};t={createObject:function(w,n){w=new w;w.surface=this.surface;w.setShape(n);this.add(w);return w}};m(h.Group,Q);m(h.Group,F.Creator);m(h.Group,t);m(h.Surface,Q);m(h.Surface,
F.Creator);m(h.Surface,t);h.fixTarget=function(w,n){return!0};return h})},"dojox/gfx/shape":function(){define("./_base dojo/_base/lang dojo/_base/declare dojo/_base/kernel dojo/_base/sniff dojo/on dojo/_base/array dojo/dom-construct dojo/_base/Color ./matrix".split(" "),function(I,T,g,Q,O,M,H,F,t,k){function A(e,d){for(var r=e.length-1;d<r;)e[d]=e[++d];e.length=r}var m=I.shape={};m.Shape=g("dojox.gfx.shape.Shape",null,{constructor:function(){this.parentMatrix=this.parent=this.bbox=this.strokeStyle=
this.fillStyle=this.matrix=this.shape=this.rawNode=null;if(O("gfxRegistry")){var e=m.register(this);this.getUID=function(){return e}}},destroy:function(){O("gfxRegistry")&&m.dispose(this);this.rawNode&&"__gfxObject__"in this.rawNode&&(this.rawNode.__gfxObject__=null);this.rawNode=null},getNode:function(){return this.rawNode},getShape:function(){return this.shape},getTransform:function(){return this.matrix},getFill:function(){return this.fillStyle},getStroke:function(){return this.strokeStyle},getParent:function(){return this.parent},
getBoundingBox:function(){return this.bbox},getTransformedBoundingBox:function(){var e=this.getBoundingBox();if(!e)return null;var d=this._getRealMatrix();return[k.multiplyPoint(d,e.x,e.y),k.multiplyPoint(d,e.x+e.width,e.y),k.multiplyPoint(d,e.x+e.width,e.y+e.height),k.multiplyPoint(d,e.x,e.y+e.height)]},getEventSource:function(){return this.rawNode},setClip:function(e){this.clip=e},getClip:function(){return this.clip},setShape:function(e){this.shape=I.makeParameters(this.shape,e);this.bbox=null;
return this},setFill:function(e){if(!e)return this.fillStyle=null,this;var d=null;if("object"==typeof e&&"type"in e)switch(e.type){case "linear":d=I.makeParameters(I.defaultLinearGradient,e);break;case "radial":d=I.makeParameters(I.defaultRadialGradient,e);break;case "pattern":d=I.makeParameters(I.defaultPattern,e)}else d=I.normalizeColor(e);this.fillStyle=d;return this},setStroke:function(e){if(!e)return this.strokeStyle=null,this;if("string"==typeof e||T.isArray(e)||e instanceof t)e={color:e};e=
this.strokeStyle=I.makeParameters(I.defaultStroke,e);e.color=I.normalizeColor(e.color);return this},setTransform:function(e){this.matrix=k.clone(e?k.normalize(e):k.identity);return this._applyTransform()},_applyTransform:function(){return this},moveToFront:function(){var e=this.getParent();e&&(e._moveChildToFront(this),this._moveToFront());return this},moveToBack:function(){var e=this.getParent();e&&(e._moveChildToBack(this),this._moveToBack());return this},_moveToFront:function(){},_moveToBack:function(){},
applyRightTransform:function(e){return e?this.setTransform([this.matrix,e]):this},applyLeftTransform:function(e){return e?this.setTransform([e,this.matrix]):this},applyTransform:function(e){return e?this.setTransform([this.matrix,e]):this},removeShape:function(e){this.parent&&this.parent.remove(this,e);return this},_setParent:function(e,d){this.parent=e;return this._updateParentMatrix(d)},_updateParentMatrix:function(e){this.parentMatrix=e?k.clone(e):null;return this._applyTransform()},_getRealMatrix:function(){for(var e=
this.matrix,d=this.parent;d;)d.matrix&&(e=k.multiply(d.matrix,e)),d=d.parent;return e}});m._eventsProcessing={on:function(e,d){return M(this.getEventSource(),e,m.fixCallback(this,I.fixTarget,d))},connect:function(e,d,r){"on"==e.substring(0,2)&&(e=e.substring(2));return this.on(e,r?T.hitch(d,r):d)},disconnect:function(e){return e.remove()}};m.fixCallback=function(e,d,r,y){y||(y=r,r=null);if(T.isString(y)){r=r||Q.global;if(!r[y])throw['dojox.gfx.shape.fixCallback: scope["',y,'"] is null (scope\x3d"',
r,'")'].join("");return function(z){return d(z,e)?r[y].apply(r,arguments||[]):void 0}}return r?function(z){return d(z,e)?y.apply(r,arguments||[]):void 0}:function(z){return d(z,e)?y.apply(r,arguments):void 0}};T.extend(m.Shape,m._eventsProcessing);m.Container={_init:function(){this.children=[];this._batch=0},openBatch:function(){return this},closeBatch:function(){return this},add:function(e){var d=e.getParent();d&&d.remove(e,!0);this.children.push(e);return e._setParent(this,this._getRealMatrix())},
remove:function(e,d){for(var r=0;r<this.children.length;++r)if(this.children[r]==e){d||(e.parent=null,e.parentMatrix=null);A(this.children,r);break}return this},clear:function(e){for(var d,r=0;r<this.children.length;++r)d=this.children[r],d.parent=null,d.parentMatrix=null,e&&d.destroy();this.children=[];return this},getBoundingBox:function(){if(this.children){var e=null;H.forEach(this.children,function(d){var r=d.getBoundingBox();r&&((d=d.getTransform())&&(r=k.multiplyRectangle(d,r)),e?(e.x=Math.min(e.x,
r.x),e.y=Math.min(e.y,r.y),e.endX=Math.max(e.endX,r.x+r.width),e.endY=Math.max(e.endY,r.y+r.height)):e={x:r.x,y:r.y,endX:r.x+r.width,endY:r.y+r.height})});e&&(e.width=e.endX-e.x,e.height=e.endY-e.y);return e}return null},_moveChildToFront:function(e){for(var d=0;d<this.children.length;++d)if(this.children[d]==e){A(this.children,d);this.children.push(e);break}return this},_moveChildToBack:function(e){for(var d=0;d<this.children.length;++d)if(this.children[d]==e){A(this.children,d);this.children.unshift(e);
break}return this}};m.Surface=g("dojox.gfx.shape.Surface",null,{constructor:function(){this._parent=this.rawNode=null;this._nodes=[];this._events=[]},destroy:function(){H.forEach(this._nodes,F.destroy);this._nodes=[];H.forEach(this._events,function(e){e&&e.remove()});this._events=[];this.rawNode=null;if(O("ie"))for(;this._parent.lastChild;)F.destroy(this._parent.lastChild);else this._parent.innerHTML="";this._parent=null},getEventSource:function(){return this.rawNode},_getRealMatrix:function(){return null},
isLoaded:!0,onLoad:function(e){},whenLoaded:function(e,d){var r=T.hitch(e,d);if(this.isLoaded)r(this);else M.once(this,"load",function(y){r(y)})}});T.extend(m.Surface,m._eventsProcessing);m.Rect=g("dojox.gfx.shape.Rect",m.Shape,{constructor:function(e){this.shape=I.getDefault("Rect");this.rawNode=e},getBoundingBox:function(){return this.shape}});m.Ellipse=g("dojox.gfx.shape.Ellipse",m.Shape,{constructor:function(e){this.shape=I.getDefault("Ellipse");this.rawNode=e},getBoundingBox:function(){if(!this.bbox){var e=
this.shape;this.bbox={x:e.cx-e.rx,y:e.cy-e.ry,width:2*e.rx,height:2*e.ry}}return this.bbox}});m.Circle=g("dojox.gfx.shape.Circle",m.Shape,{constructor:function(e){this.shape=I.getDefault("Circle");this.rawNode=e},getBoundingBox:function(){if(!this.bbox){var e=this.shape;this.bbox={x:e.cx-e.r,y:e.cy-e.r,width:2*e.r,height:2*e.r}}return this.bbox}});m.Line=g("dojox.gfx.shape.Line",m.Shape,{constructor:function(e){this.shape=I.getDefault("Line");this.rawNode=e},getBoundingBox:function(){if(!this.bbox){var e=
this.shape;this.bbox={x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)}}return this.bbox}});m.Polyline=g("dojox.gfx.shape.Polyline",m.Shape,{constructor:function(e){this.shape=I.getDefault("Polyline");this.rawNode=e},setShape:function(e,d){e&&e instanceof Array?(this.inherited(arguments,[{points:e}]),d&&this.shape.points.length&&this.shape.points.push(this.shape.points[0])):this.inherited(arguments,[e]);return this},_normalizePoints:function(){var e=
this.shape.points,d=e&&e.length;if(d&&"number"==typeof e[0]){for(var r=[],y=0;y<d;y+=2)r.push({x:e[y],y:e[y+1]});this.shape.points=r}},getBoundingBox:function(){if(!this.bbox&&this.shape.points.length){for(var e=this.shape.points,d=e.length,r=e[0],y=r.x,z=r.y,h=r.x,v=r.y,L=1;L<d;++L)r=e[L],y>r.x&&(y=r.x),h<r.x&&(h=r.x),z>r.y&&(z=r.y),v<r.y&&(v=r.y);this.bbox={x:y,y:z,width:h-y,height:v-z}}return this.bbox}});m.Image=g("dojox.gfx.shape.Image",m.Shape,{constructor:function(e){this.shape=I.getDefault("Image");
this.rawNode=e},getBoundingBox:function(){return this.shape},setStroke:function(){return this},setFill:function(){return this}});m.Text=g(m.Shape,{constructor:function(e){this.fontStyle=null;this.shape=I.getDefault("Text");this.rawNode=e},getFont:function(){return this.fontStyle},setFont:function(e){this.fontStyle="string"==typeof e?I.splitFontString(e):I.makeParameters(I.defaultFont,e);this._setFont();return this},getBoundingBox:function(){var e=null;this.getShape().text&&(e=I._base._computeTextBoundingBox(this));
return e}});m.Creator={createShape:function(e){switch(e.type){case I.defaultPath.type:return this.createPath(e);case I.defaultRect.type:return this.createRect(e);case I.defaultCircle.type:return this.createCircle(e);case I.defaultEllipse.type:return this.createEllipse(e);case I.defaultLine.type:return this.createLine(e);case I.defaultPolyline.type:return this.createPolyline(e);case I.defaultImage.type:return this.createImage(e);case I.defaultText.type:return this.createText(e);case I.defaultTextPath.type:return this.createTextPath(e)}return null},
createGroup:function(){return this.createObject(I.Group)},createRect:function(e){return this.createObject(I.Rect,e)},createEllipse:function(e){return this.createObject(I.Ellipse,e)},createCircle:function(e){return this.createObject(I.Circle,e)},createLine:function(e){return this.createObject(I.Line,e)},createPolyline:function(e){return this.createObject(I.Polyline,e)},createImage:function(e){return this.createObject(I.Image,e)},createText:function(e){return this.createObject(I.Text,e)},createPath:function(e){return this.createObject(I.Path,
e)},createTextPath:function(e){return this.createObject(I.TextPath,{}).setText(e)},createObject:function(e,d){return null}};return m})},"dojox/gfx/path":function(){define(["./_base","dojo/_base/lang","dojo/_base/declare","./matrix","./shape"],function(I,T,g,Q,O){O=g("dojox.gfx.path.Path",O.Shape,{constructor:function(M){this.shape=T.clone(I.defaultPath);this.segments=[];this.tbbox=null;this.absolute=!0;this.last={};this.rawNode=M;this.segmented=!1},setAbsoluteMode:function(M){this._confirmSegmented();
this.absolute="string"==typeof M?"absolute"==M:M;return this},getAbsoluteMode:function(){this._confirmSegmented();return this.absolute},getBoundingBox:function(){this._confirmSegmented();return this.bbox&&"l"in this.bbox?{x:this.bbox.l,y:this.bbox.t,width:this.bbox.r-this.bbox.l,height:this.bbox.b-this.bbox.t}:null},_getRealBBox:function(){this._confirmSegmented();if(this.tbbox)return this.tbbox;var M=this.bbox,H=this._getRealMatrix();this.bbox=null;for(var F=0,t=this.segments.length;F<t;++F)this._updateWithSegment(this.segments[F],
H);H=this.bbox;this.bbox=M;return this.tbbox=H?[{x:H.l,y:H.t},{x:H.r,y:H.t},{x:H.r,y:H.b},{x:H.l,y:H.b}]:null},getLastPosition:function(){this._confirmSegmented();return"x"in this.last?this.last:null},_applyTransform:function(){this.tbbox=null;return this.inherited(arguments)},_updateBBox:function(M,H,F){F&&(H=Q.multiplyPoint(F,M,H),M=H.x,H=H.y);this.bbox&&"l"in this.bbox?(this.bbox.l>M&&(this.bbox.l=M),this.bbox.r<M&&(this.bbox.r=M),this.bbox.t>H&&(this.bbox.t=H),this.bbox.b<H&&(this.bbox.b=H)):
this.bbox={l:M,b:H,r:M,t:H}},_updateWithSegment:function(M,H){var F=M.args,t=F.length,k;switch(M.action){case "M":case "L":case "C":case "S":case "Q":case "T":for(k=0;k<t;k+=2)this._updateBBox(F[k],F[k+1],H);this.last.x=F[t-2];this.last.y=F[t-1];this.absolute=!0;break;case "H":for(k=0;k<t;++k)this._updateBBox(F[k],this.last.y,H);this.last.x=F[t-1];this.absolute=!0;break;case "V":for(k=0;k<t;++k)this._updateBBox(this.last.x,F[k],H);this.last.y=F[t-1];this.absolute=!0;break;case "m":k=0;"x"in this.last||
(this._updateBBox(this.last.x=F[0],this.last.y=F[1],H),k=2);for(;k<t;k+=2)this._updateBBox(this.last.x+=F[k],this.last.y+=F[k+1],H);this.absolute=!1;break;case "l":case "t":for(k=0;k<t;k+=2)this._updateBBox(this.last.x+=F[k],this.last.y+=F[k+1],H);this.absolute=!1;break;case "h":for(k=0;k<t;++k)this._updateBBox(this.last.x+=F[k],this.last.y,H);this.absolute=!1;break;case "v":for(k=0;k<t;++k)this._updateBBox(this.last.x,this.last.y+=F[k],H);this.absolute=!1;break;case "c":for(k=0;k<t;k+=6)this._updateBBox(this.last.x+
F[k],this.last.y+F[k+1],H),this._updateBBox(this.last.x+F[k+2],this.last.y+F[k+3],H),this._updateBBox(this.last.x+=F[k+4],this.last.y+=F[k+5],H);this.absolute=!1;break;case "s":case "q":for(k=0;k<t;k+=4)this._updateBBox(this.last.x+F[k],this.last.y+F[k+1],H),this._updateBBox(this.last.x+=F[k+2],this.last.y+=F[k+3],H);this.absolute=!1;break;case "A":for(k=0;k<t;k+=7)this._updateBBox(F[k+5],F[k+6],H);this.last.x=F[t-2];this.last.y=F[t-1];this.absolute=!0;break;case "a":for(k=0;k<t;k+=7)this._updateBBox(this.last.x+=
F[k+5],this.last.y+=F[k+6],H);this.absolute=!1}M=[M.action];for(k=0;k<t;++k)M.push(I.formatNumber(F[k],!0));if("string"==typeof this.shape.path)this.shape.path+=M.join("");else for(k=0,t=M.length;k<t;++k)this.shape.path.push(M[k])},_validSegments:{m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},_pushSegment:function(M,H){this.tbbox=null;var F=this._validSegments[M.toLowerCase()];"number"==typeof F&&(F?H.length>=F&&(M={action:M,args:H.slice(0,H.length-H.length%F)},this.segments.push(M),this._updateWithSegment(M)):
(M={action:M,args:[]},this.segments.push(M),this._updateWithSegment(M)))},_collectArgs:function(M,H){for(var F=0;F<H.length;++F){var t=H[F];"boolean"==typeof t?M.push(t?1:0):"number"==typeof t?M.push(t):t instanceof Array?this._collectArgs(M,t):"x"in t&&"y"in t&&M.push(t.x,t.y)}},moveTo:function(){this._confirmSegmented();var M=[];this._collectArgs(M,arguments);this._pushSegment(this.absolute?"M":"m",M);return this},lineTo:function(){this._confirmSegmented();var M=[];this._collectArgs(M,arguments);
this._pushSegment(this.absolute?"L":"l",M);return this},hLineTo:function(){this._confirmSegmented();var M=[];this._collectArgs(M,arguments);this._pushSegment(this.absolute?"H":"h",M);return this},vLineTo:function(){this._confirmSegmented();var M=[];this._collectArgs(M,arguments);this._pushSegment(this.absolute?"V":"v",M);return this},curveTo:function(){this._confirmSegmented();var M=[];this._collectArgs(M,arguments);this._pushSegment(this.absolute?"C":"c",M);return this},smoothCurveTo:function(){this._confirmSegmented();
var M=[];this._collectArgs(M,arguments);this._pushSegment(this.absolute?"S":"s",M);return this},qCurveTo:function(){this._confirmSegmented();var M=[];this._collectArgs(M,arguments);this._pushSegment(this.absolute?"Q":"q",M);return this},qSmoothCurveTo:function(){this._confirmSegmented();var M=[];this._collectArgs(M,arguments);this._pushSegment(this.absolute?"T":"t",M);return this},arcTo:function(){this._confirmSegmented();var M=[];this._collectArgs(M,arguments);this._pushSegment(this.absolute?"A":
"a",M);return this},closePath:function(){this._confirmSegmented();this._pushSegment("Z",[]);return this},_confirmSegmented:function(){if(!this.segmented){var M=this.shape.path;this.shape.path=[];this._setPath(M);this.shape.path=this.shape.path.join("");this.segmented=!0}},_setPath:function(M){M=T.isArray(M)?M:M.match(I.pathSvgRegExp);this.segments=[];this.absolute=!0;this.bbox={};this.last={};if(M){for(var H="",F=[],t=M.length,k=0;k<t;++k){var A=M[k],m=parseFloat(A);isNaN(m)?(H&&this._pushSegment(H,
F),F=[],H=A):F.push(m)}this._pushSegment(H,F)}},setShape:function(M){this.inherited(arguments,["string"==typeof M?{path:M}:M]);this.segmented=!1;this.segments=[];I.lazyPathSegmentation||this._confirmSegmented();return this},_2PI:2*Math.PI});g=g("dojox.gfx.path.TextPath",O,{constructor:function(M){"text"in this||(this.text=T.clone(I.defaultTextPath));"fontStyle"in this||(this.fontStyle=T.clone(I.defaultFont))},getText:function(){return this.text},setText:function(M){this.text=I.makeParameters(this.text,
"string"==typeof M?{text:M}:M);this._setText();return this},getFont:function(){return this.fontStyle},setFont:function(M){this.fontStyle="string"==typeof M?I.splitFontString(M):I.makeParameters(I.defaultFont,M);this._setFont();return this}});return I.path={Path:O,TextPath:g}})},"dojox/gfx/arc":function(){define(["./_base","dojo/_base/lang","./matrix"],function(I,T,g){function Q(k){var A=Math.cos(k);k=Math.sin(k);var m={x:A+4/3*(1-A),y:k-4/3*A*(1-A)/k};return{s:{x:A,y:-k},c1:{x:m.x,y:-m.y},c2:m,e:{x:A,
y:k}}}var O=2*Math.PI,M=Math.PI/4,H=Math.PI/8,F=M+H,t=Q(H);return I.arc={unitArcAsBezier:Q,curvePI4:t,arcAsBezier:function(k,A,m,e,d,r,y,z){d=!!d;r=!!r;var h=g._degToRad(e);e=A*A;var v=m*m,L=g.multiplyPoint(g.rotate(-h),{x:(k.x-y)/2,y:(k.y-z)/2}),J=L.x*L.x,U=L.y*L.y;e=Math.sqrt((e*v-e*U-v*J)/(e*U+v*J));isNaN(e)&&(e=0);e={x:e*A*L.y/m,y:-e*m*L.x/A};d==r&&(e={x:-e.x,y:-e.y});e=g.multiplyPoint([g.translate((k.x+y)/2,(k.y+z)/2),g.rotate(h)],e);A=g.normalize([g.translate(e.x,e.y),g.rotate(h),g.scale(A,
m)]);e=g.invert(A);k=g.multiplyPoint(e,k);z=g.multiplyPoint(e,y,z);y=Math.atan2(k.y,k.x);e=y-Math.atan2(z.y,z.x);r&&(e=-e);0>e?e+=O:e>O&&(e-=O);m=H;z=t;m=r?m:-m;k=[];for(d=e;0<d;d-=M)d<F&&(m=d/2,z=Q(m),m=r?m:-m,d=0),L=g.normalize([A,g.rotate(y+m)]),r?(e=g.multiplyPoint(L,z.c1),h=g.multiplyPoint(L,z.c2),L=g.multiplyPoint(L,z.e)):(e=g.multiplyPoint(L,z.c2),h=g.multiplyPoint(L,z.c1),L=g.multiplyPoint(L,z.s)),k.push([e.x,e.y,h.x,h.y,L.x,L.y]),y+=2*m;return k}}})},"dojox/gfx/decompose":function(){define(["./_base",
"dojo/_base/lang","./matrix"],function(I,T,g){function Q(t,k){return Math.abs(t-k)<=1E-6*(Math.abs(t)+Math.abs(k))}function O(t,k,A,m){if(!isFinite(t))return A;if(!isFinite(A))return t;k=Math.abs(k);m=Math.abs(m);return(k*t+m*A)/(k+m)}function M(t){t=g.normalize(t);var k=-t.xx-t.yy,A=t.xx*t.yy-t.xy*t.yx,m=Math.sqrt(k*k-4*A);k=-(k+(0>k?-m:m))/2;A/=k;m=t.xy/(k-t.xx);var e=1,d=t.xy/(A-t.xx),r=1;Q(k,A)&&(m=1,d=e=0,r=1);isFinite(m)||(m=1,e=(k-t.xx)/t.xy,isFinite(e)||(m=(k-t.yy)/t.yx,e=1,isFinite(m)||(m=
1,e=t.yx/(k-t.yy))));isFinite(d)||(d=1,r=(A-t.xx)/t.xy,isFinite(r)||(d=(A-t.yy)/t.yx,r=1,isFinite(d)||(d=1,r=t.yx/(A-t.yy))));t=Math.sqrt(m*m+e*e);var y=Math.sqrt(d*d+r*r);isFinite(m/=t)||(m=0);isFinite(e/=t)||(e=0);isFinite(d/=y)||(d=0);isFinite(r/=y)||(r=0);return{value1:k,value2:A,vector1:{x:m,y:e},vector2:{x:d,y:r}}}function H(t,k){var A=0>t.xx*t.yy||0<t.xy*t.yx?-1:1,m=k.angle1=(Math.atan2(t.yx,t.yy)+Math.atan2(-A*t.xy,A*t.xx))/2;A=Math.cos(m);m=Math.sin(m);k.sx=O(t.xx/A,A,-t.xy/m,m);k.sy=O(t.yy/
A,A,t.yx/m,m);return k}function F(t,k){var A=0>t.xx*t.yy||0<t.xy*t.yx?-1:1,m=k.angle2=(Math.atan2(A*t.yx,A*t.xx)+Math.atan2(-t.xy,t.yy))/2;A=Math.cos(m);m=Math.sin(m);k.sx=O(t.xx/A,A,t.yx/m,m);k.sy=O(t.yy/A,A,-t.xy/m,m);return k}return I.decompose=function(t){var k=g.normalize(t);t={dx:k.dx,dy:k.dy,sx:1,sy:1,angle1:0,angle2:0};if(Q(k.xy,0)&&Q(k.yx,0))return T.mixin(t,{sx:k.xx,sy:k.yy});if(Q(k.xx*k.yx,-k.xy*k.yy))return H(k,t);if(Q(k.xx*k.xy,-k.yx*k.yy))return F(k,t);var A=new g.Matrix2D(k);var m=
T.mixin(A,{dx:0,dy:0,xy:A.yx,yx:A.xy});A=M([k,m]);m=M([m,k]);A=new g.Matrix2D({xx:A.vector1.x,xy:A.vector2.x,yx:A.vector1.y,yy:A.vector2.y});m=new g.Matrix2D({xx:m.vector1.x,xy:m.vector1.y,yx:m.vector2.x,yy:m.vector2.y});k=new g.Matrix2D([g.invert(A),k,g.invert(m)]);H(m,t);k.xx*=t.sx;k.yy*=t.sy;F(A,t);k.xx*=t.sx;k.yy*=t.sy;return T.mixin(t,{sx:k.xx,sy:k.yy})}})},"dojox/gfx/bezierutils":function(){define(["./_base"],function(I){I=I.bezierutils={};I.tAtLength=function(H,F){var t=0,k=6==H.length,A=0,
m=0,e=k?Q:M,d=function(r,y){for(var z=0,h=0;h<r.length-2;h+=2)z+=g(r[h],r[h+1],r[h+2],r[h+3]);h=k?g(H[0],H[1],H[4],H[5]):g(H[0],H[1],H[6],H[7]);z-h>y||A+z>F+y?(++m,r=e(r,.5),d(r[0],y),Math.abs(A-F)<=y||d(r[1],y)):(A+=z,t+=1/(1<<m))};F&&d(H,.5);return t};var T=I.computeLength=function(H){for(var F=6==H.length,t=0,k=0;k<H.length-2;k+=2)t+=g(H[k],H[k+1],H[k+2],H[k+3]);k=F?g(H[0],H[1],H[4],H[5]):g(H[0],H[1],H[6],H[7]);return.1<t-k?(H=F?Q(H,.5):O(H,.5),t=T(H[0],F),t+=T(H[1],F)):t},g=I.distance=function(H,
F,t,k){return Math.sqrt((t-H)*(t-H)+(k-F)*(k-F))},Q=function(H,F){var t=1-F,k=t*t,A=F*F,m=H[0],e=H[1],d=H[2],r=H[3],y=H[4];H=H[5];var z=k*m+2*t*F*d+A*y;k=k*e+2*t*F*r+A*H;return[[m,e,t*m+F*d,t*e+F*r,z,k],[z,k,t*d+F*y,t*r+F*H,y,H]]},O=function(H,F){var t=1-F,k=t*t,A=k*t,m=F*F,e=m*F,d=H[0],r=H[1],y=H[2],z=H[3],h=H[4],v=H[5],L=H[6];H=H[7];var J=A*d+3*k*F*y+3*t*m*h+e*L;A=A*r+3*k*F*z+3*t*m*v+e*H;return[[d,r,t*d+F*y,t*r+F*z,k*d+2*t*F*y+m*h,k*r+2*t*F*z+m*v,J,A],[J,A,k*y+2*t*F*h+m*L,k*z+2*t*F*v+m*H,t*h+F*
L,t*v+F*H,L,H]]},M=I.splitBezierAtT=function(H,F){return 6==H.length?Q(H,F):O(H,F)};return I})},"dojox/json/query":function(){define(["dojo/_base/kernel","dojo/_base/lang","dojox","dojo/_base/array"],function(I,T,g){T.getObject("json",!0,g);g.json._slice=function(Q,O,M,H){var F=Q.length,t=[];M=M||F;O=0>O?Math.max(0,O+F):Math.min(F,O);for(M=0>M?Math.max(0,M+F):Math.min(F,M);O<M;O+=H)t.push(Q[O]);return t};g.json._find=function(Q,O){function M(t){O&&(!0!==O||t instanceof Array?t[O]&&H.push(t[O]):H.push(t));
for(var k in t){var A=t[k];O?A&&"object"==typeof A&&M(A):H.push(A)}}var H=[];if(O instanceof Array){if(1==O.length)return Q[O[0]];for(var F=0;F<O.length;F++)H.push(Q[O[F]])}else M(Q);return H};g.json._distinctFilter=function(Q,O){for(var M=[],H={},F=0,t=Q.length;F<t;++F){var k=Q[F];O(k,F,Q)&&("object"==typeof k&&k?k.__included||(k.__included=!0,M.push(k)):H[k+typeof k]||(H[k+typeof k]=!0,M.push(k)))}F=0;for(t=M.length;F<t;++F)M[F]&&delete M[F].__included;return M};return g.json.query=function(Q,O){function M(m,
e,d,r,y,z,h,v){return F[v].match(/[\*\?]/)||"~"==h?"/^"+F[v].substring(1,F[v].length-1).replace(/\\([btnfr\\"'])|([^\w\*\?])/g,"\\$1$2").replace(/([\*\?])/g,"[\\w\\W]$1")+("~"==h?"$/i":"$/")+".test("+e+")":m}var H=0,F=[];Q=Q.replace(/"(\\.|[^"\\])*"|'(\\.|[^'\\])*'|[\[\]]/g,function(m){H+="["==m?1:"]"==m?-1:0;return"]"==m&&0<H?"`]":'"'==m.charAt(0)||"'"==m.charAt(0)?"`"+(F.push(m)-1):m});var t="";Q.replace(/(\]|\)|push|pop|shift|splice|sort|reverse)\s*\(/,function(){throw Error("Unsafe function call");
});Q=Q.replace(/([^<>=]=)([^=])/g,"$1\x3d$2").replace(/@|(\.\s*)?[a-zA-Z\$_]+(\s*:)?/g,function(m){return"."==m.charAt(0)?m:"@"==m?"$obj":(m.match(/:|^(\$|Math|true|false|null)$/)?"":"$obj.")+m}).replace(/\.?\.?\[(`\]|[^\]])*\]|\?.*|\.\.([\w\$_]+)|\.\*/g,function(m,e,d){return(e=m.match(/^\.?\.?(\[\s*\^?\?|\^?\?|\[\s*==)(.*?)\]?$/))?(d="",m.match(/^\./)&&(t="dojox.json._find("+t,d=",true)"),t=(e[1].match(/=/)?"dojo.map":e[1].match(/\^/)?"dojox.json._distinctFilter":"dojo.filter")+"("+t,d+",function($obj){return "+
e[2]+"})"):(e=m.match(/^\[\s*([\/\\].*)\]/))?".concat().sort(function(a,b){"+e[1].replace(/\s*,?\s*([\/\\])\s*([^,\\\/]+)/g,function(r,y,z){return"var av\x3d "+z.replace(/\$obj/,"a")+",bv\x3d "+z.replace(/\$obj/,"b")+";if(av\x3ebv||bv\x3d\x3dnull){return "+("/"==y?1:-1)+";}\nif(bv\x3eav||av\x3d\x3dnull){return "+("/"==y?-1:1)+";}\n"})+"return 0;})":(e=m.match(/^\[(-?[0-9]*):(-?[0-9]*):?(-?[0-9]*)\]/))?(t="dojox.json._slice("+t,","+(e[1]||0)+","+(e[2]||0)+","+(e[3]||1)+")"):m.match(/^\.\.|\.\*|\[\s*\*\s*\]|,/)?
(t="dojox.json._find("+t,("."==m.charAt(1)?",'"+d+"'":m.match(/,/)?","+m:"")+")"):m}).replace(/(\$obj\s*((\.\s*[\w_$]+\s*)|(\[\s*`([0-9]+)\s*`\]))*)(==|~)\s*`([0-9]+)/g,M).replace(/`([0-9]+)\s*(==|~)\s*(\$obj\s*((\.\s*[\w_$]+)|(\[\s*`([0-9]+)\s*`\]))*)/g,function(m,e,d,r,y,z,h,v){return M(m,r,y,z,h,v,d,e)});Q=t+("$"==Q.charAt(0)?"":"$")+Q.replace(/`([0-9]+|\])/g,function(m,e){return"]"==e?"]":F[e]});for(var k=eval("1\x26\x26function($,$1,$2,$3,$4,$5,$6,$7,$8,$9){var $obj\x3d$;return "+Q+"}"),A=0;A<
arguments.length-1;A++)arguments[A]=arguments[A+1];return O?k.apply(this,arguments):k}})},"esri/tasks/PrintParameters":function(){define(["dojo/_base/declare","dojo/_base/lang","dojo/has","../kernel"],function(I,T,g,Q){I=I(null,{declaredClass:"esri.tasks.PrintParameters",map:null,template:null,outSpatialReference:null,extraParameters:null});g("extend-esri")&&T.setObject("tasks.PrintParameters",I,Q);return I})},"esri/toolbars/edit":function(){define("require dojo/_base/declare dojo/_base/lang dojo/_base/connect dojo/_base/array dojo/_base/Color dojo/has dojo/dom-construct dojo/dom-style ../kernel ../lang ../sniff ./_toolbar ./_Box ./_GraphicMover ./_VertexEditor ./TextEditor ../symbols/SimpleMarkerSymbol ../symbols/SimpleLineSymbol ../symbols/TextSymbol ../graphic".split(" "),
function(I,T,g,Q,O,M,H,F,t,k,A,m,e,d,r,y,z,h,v,L,J){var U=T(e,{declaredClass:"esri.toolbars.Edit",constructor:function(S,N){this._map=S;this._tool=0;if(this._map.loaded)this._scratchGL=S.graphics;else var D=Q.connect(this._map,"onLoad",this,function(){Q.disconnect(D);D=null;this._scratchGL=this._map.graphics});S=H("esri-mobile");this._defaultOptions=g.mixin({vertexSymbol:new h(h.STYLE_CIRCLE,S?20:12,new v(v.STYLE_SOLID,new M([0,0,0,.5]),1),new M([128,128,128])),ghostVertexSymbol:new h(h.STYLE_CIRCLE,
S?18:10,new v(v.STYLE_SOLID,new M([0,0,0,.5]),1),new M([255,255,255,.75])),ghostLineSymbol:new v(v.STYLE_DOT,new M([128,128,128]),2),allowDeleteVertices:!0,allowAddVertices:!0,rotateHandleOffset:S?24:16,boxLineSymbol:new v(v.STYLE_DASH,new M([64,64,64]),1),boxHandleSymbol:new h(h.STYLE_SQUARE,S?16:9,new v(v.STYLE_SOLID,new M([0,0,0,.5]),1),new M([255,255,255,.75])),textAnchorSymbol:new h(h.STYLE_CIRCLE,10,null,new M([255,0,0]))},N||{})},activate:function(S,N,D){this.deactivate();this._graphic=N;this._options=
g.mixin(g.mixin({},this._defaultOptions),D||{});var G=U.MOVE;D=U.EDIT_VERTICES;var aa=U.SCALE,ca=U.ROTATE,Z=U.EDIT_TEXT,ea=!1,C=!1,da=!1,Y=this._map,w=Y.spatialReference,n=N.geometry.spatialReference;this._geo=!(!w||!n||w.equals(n)||!w.isWebMercator()||4326!==n.wkid);this._isTextPoint=this._prepareTextSymbolEditing(N,S);(S&G)===G&&(ea=this._enableMove(N));G=(S&aa)===aa;ca=(S&ca)===ca;if(G||ca)da=this._enableBoxEditing(N,G,ca);(S&D)===D&&(C=this._enableVertexEditing(N));(S&Z)===Z&&this._enableTextEditing(N);
if(!(ea||C||da))throw Error("[esri.toolbars.Edit::activate] Unable to activate the tool. Check if the tool is valid for the given geometry type.");if(this._tool=S)this._mapPanEndHandle=Q.connect(Y,"onPanEnd",this,this._mapPanEndHandler),this._mapExtChgHandle=Q.connect(Y,"onExtentChange",this,this._mapExtentChangeHandler),this.onActivate(this._tool,N);Y.snappingManager&&(ea||C)&&Y.snappingManager._startSelectionLayerQuery()},deactivate:function(){this._isTextPoint=null;var S=this._tool,N=this._graphic;
if(S){var D=!!this._modified;this._clear();Q.disconnect(this._mapPanEndHandle);Q.disconnect(this._mapExtChgHandle);this._graphic=this._geo=this._mapPanEndHandle=this._mapExtChgHandle=null;this.onDeactivate(S,N,{isModified:D});this._map.snappingManager&&this._map.snappingManager._stopSelectionLayerQuery()}},refresh:function(){this._refreshMoveables(!0)},getCurrentState:function(){return{tool:this._tool,graphic:this._graphic,isModified:!!this._modified}},onActivate:function(S,N){},onDeactivate:function(S,
N,D){},onGraphicMoveStart:function(S){},onGraphicFirstMove:function(S){this._modified=!0},onGraphicMove:function(S,N){},onGraphicMoveStop:function(S,N){},onGraphicClick:function(S,N){},onVertexMoveStart:function(S,N){},onVertexFirstMove:function(S,N){this._modified=!0},onVertexMove:function(S,N,D){},onVertexMoveStop:function(S,N,D){},onVertexAdd:function(S,N){this._modified=!0},onVertexClick:function(S,N){},onVertexMouseOver:function(S,N){},onVertexMouseOut:function(S,N){},onVertexDelete:function(S,
N){this._modified=!0},onTextEditStart:function(S,N){},onTextEditEnd:function(S){},onScaleStart:function(S){},onScaleFirstMove:function(S){this._modified=!0},onScale:function(S,N){},onScaleStop:function(S,N){},onRotateStart:function(S){},onRotateFirstMove:function(S){this._modified=!0},onRotate:function(S,N){},onRotateStop:function(S,N){},_eventMap:{activate:["tool","graphic"],deactivate:["tool","graphic","info"],"graphic-move-start":["graphic"],"graphic-first-move":["graphic"],"graphic-move":["graphic",
"transform"],"graphic-move-stop":["graphic","transform"],"graphic-click":["graphic","info"],"vertex-move-start":["graphic","vertexinfo"],"vertex-first-move":["graphic","vertexinfo"],"vertex-move":["graphic","vertexinfo","transform"],"vertex-move-stop":["graphic","vertexinfo","transform"],"vertex-add":["graphic","vertexinfo"],"vertex-click":["graphic","vertexinfo"],"vertex-mouse-over":["graphic","vertexinfo"],"vertex-mouse-out":["graphic","vertexinfo"],"vertex-delete":["graphic","vertexinfo"],"scale-start":["graphic"],
"scale-first-move":["graphic"],scale:["graphic","info"],"scale-stop":["graphic","info"],"rotate-start":["graphic"],"rotate-first-move":["graphic"],rotate:["graphic","info"],"rotate-stop":["graphic","info"]},_prepareTextSymbolEditing:function(S,N){if("point"===S.geometry.type||"multipoint"===S.geometry.type){var D=S.getLayer(),G=D.renderer;D=S.symbol||D._getSymbol(S);!D&&(G.hasVisualVariables("sizeInfo",!1)||G.hasVisualVariables("colorInfo",!1)||G.hasVisualVariables("opacityInfo",!1))&&G.addBreak&&
G.infos&&1===G.infos.length&&(D=G.infos[0].symbol||G.defaultSymbol);if(D&&"textsymbol"===D.type){if((N&U.SCALE)===U.SCALE||(N&U.ROTATE)===U.ROTATE||(N&U.EDIT_TEXT)===U.EDIT_TEXT){S.setSymbol(new L(D.toJson()));var aa=this;this._textSymbolEditor?(this._textSymbolEditor.createForm(S),this._textSymbolEditor.show()):this._options&&this._options.textSymbolEditor?(this._textSymbolEditor=this._options.textSymbolEditor,this._textSymbolEditor.on("symbol-change",function(){aa._boxEditor&&aa._boxEditor.refresh()})):
I(["../dijit/SymbolEditor"],function(ca){if(!aa._textSymbolEditor){var Z=aa._options.textSymbolEditorHolder?F.create("div",null,aa._options.textSymbolEditorHolder):F.create("div",null,aa._map.root);aa._textSymbolEditor=new ca({graphic:S},Z);ca=aa._textSymbolEditor.domNode.parentNode.id;t.set(aa._textSymbolEditor.domNode,{position:"map_root"===ca?"absolute":"relative",left:"map_root"===ca?aa._map.width/2-100+"px":"5px",top:"20px","z-index":50});aa._textSymbolEditor.startup();aa._textSymbolEditor.createForm(S);
aa._textSymbolEditor.show();aa._textSymbolEditor.on("symbol-change",function(){aa._boxEditor&&aa._boxEditor.refresh()})}})}if((N&U.MOVE)===U.MOVE||(N&U.ROTATE)===U.ROTATE||(N&U.SCALE)===U.SCALE)this._textAnchor=new J(S.geometry,this._options.textAnchorSymbol),this._scratchGL.add(this._textAnchor);return!0}}return!1},_enableMove:function(S){var N=this._map;switch(S.geometry.type){case "point":case "polyline":case "polygon":return this._graphicMover=new r(S,N,this,this._textAnchor),!0}return!1},_enableVertexEditing:function(S){var N=
this._map;switch(S.geometry.type){case "multipoint":case "polyline":case "polygon":return this._vertexEditor=y.create(S,N,this),!0}return!1},_enableBoxEditing:function(S,N,D){var G=this._map,aa=S.geometry.type;return"polyline"===aa||"polygon"===aa||this._isTextPoint?(this._boxEditor=new d(S,G,this,N,D,this._options.uniformScaling,this._isTextPoint),!0):!1},_enableTextEditing:function(S){return this._isTextPoint?(this._textEditor=new z(S,this._map,this),Q.connect(this._textEditor,"onEditStart",g.hitch(this,
function(){this._textAnchor&&(this._textAnchor.getLayer().remove(this._textAnchor),this._textAnchor=null);this._map.disableKeyboardNavigation();this._disableMove();this._disableBoxEditing()})),!0):!1},_disableMove:function(){var S=this._graphicMover;S&&(S.destroy(),this._graphicMover=null)},_disableVertexEditing:function(){var S=this._vertexEditor;S&&(S.destroy(),this._vertexEditor=null)},_disableBoxEditing:function(){var S=this._boxEditor;S&&(S.destroy(),this._boxEditor=null)},_disableTextEditing:function(){this._textEditor&&
(this._textEditor.destroy(),this._textEditor=null);this._map.enableKeyboardNavigation()},_disableSymbolEditing:function(){this._textSymbolEditor&&this._textSymbolEditor.hide()},_clear:function(){this._disableMove();this._disableVertexEditing();this._disableBoxEditing();this._disableTextEditing();this._disableSymbolEditing();this._textAnchor&&(this._textAnchor.getLayer().remove(this._textAnchor),this._textAnchor=null);this._tool=0;this._modified=!1},_mapPanEndHandler:function(){this._refreshMoveables()},
_mapExtentChangeHandler:function(S,N,D){D&&this._refreshMoveables()},_refreshMoveables:function(S){var N=O.filter([this._graphicMover,this._vertexEditor,this._boxEditor],A.isDefined);O.forEach(N,function(D){D.refresh(S)})},_beginOperation:function(S){O.forEach(this._getAffectedTools(S),function(N){N.suspend()})},_endOperation:function(S){O.forEach(this._getAffectedTools(S),function(N){N.resume()})},_getAffectedTools:function(S){var N=[];switch(S){case "MOVE":N=[this._vertexEditor,this._boxEditor];
break;case "VERTICES":N=[this._boxEditor];break;case "BOX":N=[this._vertexEditor]}return N=O.filter(N,A.isDefined)}});g.mixin(U,{MOVE:1,EDIT_VERTICES:2,SCALE:4,ROTATE:8,EDIT_TEXT:16});H("extend-esri")&&g.setObject("toolbars.Edit",U,k);return U})},"esri/toolbars/_Box":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/connect dojo/_base/Color dojo/has dojo/dom-style dojox/gfx/Moveable dojox/gfx/matrix ../kernel ../lang ../geometry/Point ../geometry/Polyline ../symbols/SimpleMarkerSymbol ../geometry/webMercatorUtils ../geometry/jsonUtils ../graphic".split(" "),
function(I,T,g,Q,O,M,H,F,t,k,A,m,e,d,r,y,z){I=I(null,{declaredClass:"esri.toolbars._Box",constructor:function(h,v,L,J,U,S,N){this._graphic=h;this._map=v;this._toolbar=L;this._scale=J;this._rotate=U;this._defaultEventArgs={};this._scaleEvent="Scale";this._rotateEvent="Rotate";this._uniformScaling=S;h=L._options;this._markerSymbol=h.boxHandleSymbol;this._lineSymbol=h.boxLineSymbol;this._moveStartHandler=T.hitch(this,this._moveStartHandler);this._firstMoveHandler=T.hitch(this,this._firstMoveHandler);
this._moveStopHandler=T.hitch(this,this._moveStopHandler);this._moveHandler=T.hitch(this,this._moveHandler);this._isTextPoint=N;this._init()},destroy:function(){this._cleanUp();this._graphic=this._map=this._toolbar=this._markerSymbol=this._lineSymbol=null},refresh:function(){this._draw()},suspend:function(){g.forEach(this._getAllGraphics(),function(h){h.hide()})},resume:function(){g.forEach(this._getAllGraphics(),function(h){h.show()});this._draw()},_init:function(){this._draw()},_cleanUp:function(){this._connects&&
g.forEach(this._connects,Q.disconnect);var h=this._toolbar._scratchGL;this._anchors&&g.forEach(this._anchors,function(v){h.remove(v.graphic);(v=v.moveable)&&v.destroy()});this._box&&h.remove(this._box);this._box=this._anchors=this._connects=null},_draw:function(){if(this._graphic.getDojoShape()){var h=this._map,v=this._toolbar._scratchGL,L=this._getBoxCoords(),J=new e(h.spatialReference),U=T.clone(g.filter(L,function(S,N){return 8!==N&&0===N%2}));U[0]&&U.push([U[0][0],U[0][1]]);J.addPath(U);this._rotate&&
J.addPath([L[1],L[8]]);this._box?this._box.setGeometry(J):(this._box=new z(J,this._lineSymbol),v.add(this._box));this._anchors?g.forEach(this._anchors,function(S,N){this._scale||(N=8);var D=new m(L[N],h.spatialReference);S.graphic.setGeometry(D);D=S.moveable;var G=S.graphic.getDojoShape();G&&(D?G!==D.shape&&(D.destroy(),S.moveable=this._getMoveable(S.graphic,N)):S.moveable=this._getMoveable(S.graphic,N))},this):(this._anchors=[],this._connects=[],g.forEach(L,function(S,N){!this._scale&&8>N||(S=new m(S,
h.spatialReference),S=new z(S,this._markerSymbol),this._isTextPoint&&1===N%2&&S.hide(),v.add(S),this._anchors.push({graphic:S,moveable:this._getMoveable(S,N)}))},this))}else this._cleanUp()},_getBoxCoords:function(h){var v=this._map,L=[],J,U,S;if(this._isTextPoint){var N=this._graphic.getNode().getBoundingClientRect();var D=v.__container.getBoundingClientRect();N=[{x:N.left-D.left,y:N.top-D.top},{x:N.right-D.left,y:N.top-D.top},{x:N.right-D.left,y:N.bottom-D.top},{x:N.left-D.left,y:N.bottom-D.top}]}else N=
this._getTransformedBoundingBox(this._graphic);g.forEach(N,function(G,aa,ca){J=G;(U=ca[aa+1])||(U=ca[0]);S={x:(J.x+U.x)/2,y:(J.y+U.y)/2};h||(J=v.toMap(J),S=v.toMap(S));L.push([J.x,J.y]);L.push([S.x,S.y])});this._rotate&&(N=T.clone(L[1]),N=h?{x:N[0],y:N[1]}:v.toScreen({x:N[0],y:N[1],spatialReference:v.spatialReference}),N.y-=this._toolbar._options.rotateHandleOffset,h||(N=v.toMap(N)),L.push([N.x,N.y]));return L},_getTransformedBoundingBox:function(h){var v=this._map,L=h.geometry.getExtent(),J=h.geometry.spatialReference;
h=new m(L.xmin,L.ymax,J);L=new m(L.xmax,L.ymin,J);h=v.toScreen(h);L=v.toScreen(L);return[{x:h.x,y:h.y},{x:L.x,y:h.y},{x:L.x,y:L.y},{x:h.x,y:L.y}]},_getAllGraphics:function(){var h=[this._box];this._anchors&&g.forEach(this._anchors,function(v){h.push(v.graphic)});return h=g.filter(h,A.isDefined)},_getMoveable:function(h,v){var L=h.getDojoShape();if(L)return h=new F(L),h._index=v,this._connects.push(Q.connect(h,"onMoveStart",this._moveStartHandler)),this._connects.push(Q.connect(h,"onFirstMove",this._firstMoveHandler)),
this._connects.push(Q.connect(h,"onMoveStop",this._moveStopHandler)),h.onMove=this._moveHandler,(L=L.getEventSource())&&H.set(L,"cursor",this._toolbar._cursors["box"+v]),h},_moveStartHandler:function(h){this._toolbar["on"+(8===h.host._index?this._rotateEvent:this._scaleEvent)+"Start"](this._graphic)},_firstMoveHandler:function(h){this._toolbar._deactivateScrollWheel();var v=h.host._index,L=this._wrapOffset=h.host.shape._wrapOffsets[0]||0,J=this._graphic.getLayer().getNavigationTransform();h=g.map(this._getBoxCoords(!0),
function(S){return{x:S[0]+L,y:S[1]}});var U=this._isTextPoint?this._map.toScreen(this._graphic.geometry):{x:h[1].x,y:h[3].y};this._centerCoord=t.multiplyPoint(t.invert(J),U);if(8===v)U=t.multiplyPoint(t.invert(J),h[1]),this._isTextPoint&&(this._centerCoord=this._deNormalizePoint(this._centerCoord,U)),this._startLine=[this._centerCoord,U],this._moveLine=T.clone(this._startLine);else if(U=t.multiplyPoint(t.invert(J),h[v]),J=t.multiplyPoint(t.invert(J),h[(v+4)%8]),this._isTextPoint&&(this._centerCoord=
this._deNormalizePoint(this._centerCoord,U)),this._firstMoverToAnchor=Math.sqrt((U.x-this._centerCoord.x)*(U.x-this._centerCoord.x)+(U.y-this._centerCoord.y)*(U.y-this._centerCoord.y)),this._startBox=J,this._startBox.width=h[4].x-h[0].x,this._startBox.height=h[4].y-h[0].y,this._moveBox=T.clone(this._startBox),this._xfactor=U.x>J.x?1:-1,this._yfactor=U.y>J.y?1:-1,1===v||5===v)this._xfactor=0;else if(3===v||7===v)this._yfactor=0;this._toolbar._beginOperation("BOX");this._toolbar["on"+(8===v?this._rotateEvent:
this._scaleEvent)+"FirstMove"](this._graphic)},_moveHandler:function(h,v){h=h.host._index;var L=this._defaultEventArgs;L.angle=0;L.scaleX=1;L.scaleY=1;if(8===h){var J=this._startLine;var U=this._moveLine;var S=U[1];S.x+=v.dx;S.y+=v.dy;v=this._getAngle(J,U);this._isTextPoint&&(v+=this._graphic.symbol.angle);U=t.rotategAt(v,J[0]);this._graphic.getDojoShape().setTransform(U);L.transform=U;L.angle=v;L.around=J[0]}else{J=this._startBox;U=this._moveBox;U.width+=v.dx*this._xfactor;U.height+=v.dy*this._yfactor;
this._uniformScaling||this._isTextPoint?(J=U.x+this._xfactor*U.width,U=U.y+this._yfactor*U.height,J=Math.sqrt((J-this._centerCoord.x)*(J-this._centerCoord.x)+(U-this._centerCoord.y)*(U-this._centerCoord.y)),this._scaleRatio=v=S=J/this._firstMoverToAnchor,J=this._centerCoord):(v=U.width/J.width,S=U.height/J.height,J={x:J.x,y:J.y});if(isNaN(v)||Infinity===v||-Infinity===v)v=1;if(isNaN(S)||Infinity===S||-Infinity===S)S=1;U=t.scaleAt(v,S,J);if(this._isTextPoint){var N=t.rotategAt(this._graphic.symbol.angle,
J);this._graphic.getDojoShape().setTransform([N,U])}else this._graphic.getDojoShape().setTransform(U);L.transform=U;L.scaleX=v;L.scaleY=S;L.around=J}this._toolbar["on"+(8===h?this._rotateEvent:this._scaleEvent)](this._graphic,L)},_moveStopHandler:function(h){this._toolbar._activateScrollWheel();var v=this._graphic,L=this._toolbar,J=L._geo?r.geographicToWebMercator(v.geometry):v.geometry,U=J.spatialReference,S=v.getDojoShape(),N=S.getTransform(),D=v.getLayer().getNavigationTransform();this._isTextPoint?
(v=this._graphic.symbol,8===h.host._index?v.angle+=this._getAngle(this._startLine,this._moveLine):v.font.setSize(Math.round(v.font.size*this._scaleRatio*100)/100),this._graphic.setSymbol(v)):(J=J.toJson(),this._updateSegments(J.paths||J.rings,N,D,U),S.setTransform(null),J=y.fromJson(J),v.setGeometry(L._geo?r.webMercatorToGeographic(J,!0):J));this._draw();this._startLine=this._moveLine=this._startBox=this._moveBox=this._xfactor=this._yfactor=null;L._endOperation("BOX");this._defaultEventArgs.transform=
N;L["on"+(8===h.host._index?this._rotateEvent:this._scaleEvent)+"Stop"](this._graphic,this._defaultEventArgs)},_updateSegments:function(h,v,L,J){var U=this._map,S=this._wrapOffset||0;g.forEach(h,function(N){g.forEach(N,function(D){this._updatePoint(D,J,S,t,U,L,v)},this)},this)},_updatePoint:function(h,v,L,J,U,S,N){v=U.toScreen({x:h[0],y:h[1],spatialReference:v},!0);v.x+=L;v=J.multiplyPoint([S,N,J.invert(S)],v);v.x-=L;L=U.toMap(v);h[0]=L.x;h[1]=L.y},_getAngle:function(h,v){return 180*Math.atan2(v[0].y-
v[1].y,v[0].x-v[1].x)/Math.PI-180*Math.atan2(h[0].y-h[1].y,h[0].x-h[1].x)/Math.PI},_deNormalizePoint:function(h,v){var L=this._map._getFrameWidth();if(-1===L)return h;for(h={x:h.x,y:h.y};Math.abs(h.x-v.x)>=L;)h.x=h.x<v.x?h.x+L:h.x-L;var J=Math.abs(h.x-v.x);Math.abs(h.x-v.x+L)<J?h.x+=L:Math.abs(h.x-v.x-L)<J&&(h.x-=L);return h}});M("extend-esri")&&T.setObject("toolbars._Box",I,k);return I})},"dojox/gfx/Moveable":function(){define("dojo/_base/lang dojo/_base/declare dojo/_base/array dojo/_base/event dojo/topic dojo/touch dojo/dom-class dojo/_base/window ./Mover dojo/mouse".split(" "),
function(I,T,g,Q,O,M,H,F,t,k){return T("dojox.gfx.Moveable",null,{constructor:function(A,m){this.shape=A;this.delay=m&&0<m.delay?m.delay:0;this.mover=m&&m.mover?m.mover:t;this.leftButtonOnly=m&&m.leftButtonOnly;this.events=[this.shape.on(M.press,I.hitch(this,"onMouseDown"))]},destroy:function(){g.forEach(this.events,function(A){A.remove()});this.events=this.shape=null},onMouseDown:function(A){this.delay?(this.events.push(this.shape.on(M.move,I.hitch(this,"onMouseMove")),this.shape.on(M.release,I.hitch(this,
"onMouseUp"))),this._lastX=A.clientX,this._lastY=A.clientY):this.leftButtonOnly&&!k.isLeft(A)||new this.mover(this.shape,A,this);Q.stop(A)},onMouseMove:function(A){var m=A.clientY;if(Math.abs(A.clientX-this._lastX)>this.delay||Math.abs(m-this._lastY)>this.delay)this.onMouseUp(A),new this.mover(this.shape,A,this);Q.stop(A)},onMouseUp:function(A){this.events.pop().remove()},onMoveStart:function(A){O.publish("/gfx/move/start",A);H.add(F.body(),"dojoMove")},onMoveStop:function(A){O.publish("/gfx/move/stop",
A);H.remove(F.body(),"dojoMove")},onFirstMove:function(A){},onMove:function(A,m,e){this.onMoving(A,m,e);this.shape.applyLeftTransform(m);this.onMoved(A,m)},onMoving:function(A,m){},onMoved:function(A,m){}})})},"dojox/gfx/Mover":function(){define("dojo/_base/lang dojo/_base/array dojo/_base/declare dojo/on dojo/touch dojo/_base/event".split(" "),function(I,T,g,Q,O,M){return g("dojox.gfx.Mover",null,{constructor:function(H,F,t){this.shape=H;this.lastX=F.clientX;this.lastY=F.clientY;H=this.host=t;F=
document;t=Q(F,O.move,I.hitch(this,"onFirstMove"));this.events=[Q(F,O.move,I.hitch(this,"onMouseMove")),Q(F,O.release,I.hitch(this,"destroy")),Q(F,"dragstart",I.hitch(M,"stop")),Q(F,"selectstart",I.hitch(M,"stop")),t];if(H&&H.onMoveStart)H.onMoveStart(this)},onMouseMove:function(H){var F=H.clientX,t=H.clientY;this.host.onMove(this,{dx:F-this.lastX,dy:t-this.lastY},H);this.lastX=F;this.lastY=t;M.stop(H)},onFirstMove:function(){this.host.onFirstMove(this);this.events.pop().remove()},destroy:function(){T.forEach(this.events,
function(F){F.remove()});var H=this.host;if(H&&H.onMoveStop)H.onMoveStop(this);this.events=this.shape=null}})})},"esri/toolbars/_GraphicMover":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/connect dojo/_base/json dojo/dom-style dojox/gfx/Moveable dojox/gfx/Mover dojox/gfx/matrix ../kernel ../PointerEvents ../sniff ../geometry/webMercatorUtils ../geometry/ScreenPoint ../geometry/Point".split(" "),function(I,T,g,Q,O,M,H,F,t,k,A,m,e,d){var r=I(null,{declaredClass:"esri.toolbars._GraphicMover",
constructor:function(y,z,h,v){this.graphic=y;this.map=z;this.toolbar=h;this.tempPt=v;this._enableGraphicMover();this._moved=!1},refresh:function(y){var z=this.graphic.getDojoShape();!z||!y&&z._hostGraphic||(this._disableGraphicMover(),this._enableGraphicMover())},destroy:function(){this._disableGraphicMover()},hasMoved:function(){return this._moved},_enableGraphicMover:function(){var y=this.graphic,z=y.getDojoShape();z&&(z._hostGraphic=y,this._moveable=new M(z,{mover:r.Mover}),this._moveStartHandle=
g.connect(this._moveable,"onMoveStart",this,this._moveStartHandler),this._firstMoveHandle=g.connect(this._moveable,"onFirstMove",this,this._firstMoveHandler),this._movingHandle=g.connect(this._moveable,"onMoving",this,this._movingHandler),this._moveStopHandle=g.connect(this._moveable,"onMoveStop",this,this._moveStopHandler),(y=z.getEventSource())&&O.set(y,"cursor",this.toolbar._cursors.move))},_disableGraphicMover:function(){var y=this._moveable;if(y){g.disconnect(this._moveStartHandle);g.disconnect(this._firstMoveHandle);
g.disconnect(this._movingHandle);g.disconnect(this._moveStopHandle);var z=y.shape;z&&(z._hostGraphic=null,(z=z.getEventSource())&&O.set(z,"cursor","inherit"));y.destroy()}this._moveable=null},_moveStartHandler:function(){var y=this.graphic,z=this.map;this._startTx=y.getDojoShape().getTransform();"point"===this.graphic.geometry.type&&z.snappingManager&&z.snappingManager._setUpSnapping();this.toolbar.onGraphicMoveStart(y)},_firstMoveHandler:function(){this.toolbar._beginOperation("MOVE");this.toolbar.onGraphicFirstMove(this.graphic)},
_movingHandler:function(y,z,h){y=y.shape.getTransform();z=this.map;var v;A("esri-pointer")?v=z.navigationManager.pointerEvents._processTouchEvent(h,h):h&&"pointermove"===h.type&&(v=k.prototype._processTouchEvent.call({map:z},h,h));v&&z.snappingManager&&z.snappingManager._onSnappingMouseMoveHandler(v);this.tempPt&&this.tempPt.getDojoShape().setTransform(y);this.toolbar.onGraphicMove(this.graphic,y)},_moveStopHandler:function(y){var z=this.graphic,h=this.toolbar,v=this.map,L=h._geo?m.geographicToWebMercator(z.geometry):
z.geometry,J=L.type,U=z.getDojoShape(),S=U.getTransform();if(Q.toJson(S)!==Q.toJson(this._startTx)){this._moved=!0;switch(J){case "point":J=[S,F.invert(this._startTx)];if(v.snappingManager)var N=v.snappingManager._snappingPoint;L=N||v.toMap(F.multiplyPoint(J,v.toScreen(L,!0)));v.snappingManager&&v.snappingManager._killOffSnapping();break;case "polyline":L=this._updatePolyGeometry(L,L.paths,S);break;case "polygon":L=this._updatePolyGeometry(L,L.rings,S)}U.setTransform(null);z.setGeometry(h._geo?m.webMercatorToGeographic(L,
!0):L);this.tempPt&&this.tempPt.setGeometry(new d(z.geometry.toJson()))}else this._moved=!1;h._endOperation("MOVE");h.onGraphicMoveStop(z,S);this._moved||(y=y.__e,v=this.map.position,y=new e(y.pageX-v.x,y.pageY-v.y),h.onGraphicClick(z,{screenPoint:y,mapPoint:this.map.toMap(y)}))},_updatePolyGeometry:function(y,z,h){var v=this.map,L=y.getPoint(0,0);v=v.toMap(v.toScreen(L).offset(h.dx,h.dy));h=v.x-L.x;L=v.y-L.y;var J;for(v=0;v<z.length;v++){var U=z[v];for(J=0;J<U.length;J++){var S=y.getPoint(v,J);y.setPoint(v,
J,S.offset(h,L))}}return y}});r.Mover=I(H,{declaredClass:"esri.toolbars._Mover",constructor:function(y,z,h){this.__e=z}});A("extend-esri")&&(T.setObject("toolbars._GraphicMover",r,t),T.setObject("toolbars._Mover",r.Mover,t));return r})},"esri/toolbars/_VertexEditor":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/connect dojo/_base/array dojo/has dijit/Menu dijit/MenuItem ../kernel ./_VertexMover ../geometry/Point ../geometry/jsonUtils dojo/i18n!../nls/jsapi".split(" "),function(I,
T,g,Q,O,M,H,F,t,k,A,m){var e=I(null,{declaredClass:"esri.toolbars._GraphicVertexEditor",constructor:function(d,r,y){this.graphic=d;this.map=r;this.toolbar=y;d=y._options;this._symbol1=d.vertexSymbol;this._symbol2=d.ghostVertexSymbol;r=d.ghostLineSymbol;this._lineStroke={style:r.style,width:r.width,color:r.color};this._canDel=d.allowDeleteVertices;this._canAdd=d.allowAddVertices;this._addControllers()},destroy:function(){this._removeControllers()},refresh:function(d){d?(this._removeControllers(),this._addControllers()):
(this._refresh(this._vertexMovers),this._refresh(this._mpVertexMovers))},suspend:function(){this._suspended||this._removeControllers();this._suspended=!0},resume:function(){this._suspended&&this._addControllers();this._suspended=!1},_addControllers:function(){this._firstMoveHandle=g.connect(t,"onFirstMove",this,this._firstMoveHandler);this._moveStopHandle=g.connect(t,"onMoveStop",this,this._moveStopHandler);this._vertexMovers=this._add(this._getSegments(this.graphic.geometry),this._symbol1);this._canAdd&&
(this._mpVertexMovers=this._add(this._getMidpointSegments(this.graphic.geometry),this._symbol2,!0));var d=this._getGraphicsLayer();this._mouseOverHandle=g.connect(d,"onMouseOver",this,this._mouseOverHandler);this._mouseOutHandle=g.connect(d,"onMouseOut",this,this._mouseOutHandler);this._canDel&&(this._ctxMenu=new M({style:"font-size: 12px; margin-left: 5px; margin-top: 5px;"}),d=this._ctxDelete=new H({label:m.toolbars.edit.deleteLabel,iconClass:"vertexDeleteIcon",style:"outline: none;"}),this._deleteHandle=
g.connect(d,"onClick",this,this._deleteHandler),this._ctxMenu.addChild(d),this._ctxMenu.startup())},_removeControllers:function(){g.disconnect(this._firstMoveHandle);g.disconnect(this._moveStopHandle);g.disconnect(this._mouseOverHandle);g.disconnect(this._mouseOutHandle);g.disconnect(this._deleteHandle);this._ctxMenu&&(this._ctxDelete=null,this._unbindCtxNode(),this._ctxMenu.destroyRecursive());this._remove(this._vertexMovers);this._remove(this._mpVertexMovers);this._vertexMovers=this._mpVertexMovers=
null},_add:function(d,r,y){var z,h,v=this.graphic,L=[];for(z=0;z<d.length;z++){var J=d[z],U=[];for(h=0;h<J.length;h++)U.push(new t(J[h],r,v,z,h,J.length,this,y));L.push(U)}return L},_remove:function(d){d&&Q.forEach(d,function(r){Q.forEach(r,function(y){y.destroy()})})},_refresh:function(d){d&&Q.forEach(d,function(r){Q.forEach(r,function(y){y.refresh()})})},_isNew:function(d){return-1===Q.indexOf(this._vertexMovers[d.segIndex],d)?!0:!1},_getGraphicsLayer:function(){return this.toolbar._scratchGL},
_deleteHandler:function(d){d=this._selectedMover;this._updateRelatedGraphic(d,d.relatedGraphic,d.graphic.geometry,d.segIndex,d.ptIndex,d.segLength,!1,!0);this._canAdd&&this._deleteMidpoints(d);this._deleteVertex(d);this.toolbar._endOperation("VERTICES")},_mouseOverHandler:function(d){d=d.graphic;var r=this._findMover(d);r&&(this.toolbar.onVertexMouseOver(this.graphic,r._getInfo()),r._placeholder||(this._selectedMover=r,this._canDel&&this._bindCtxNode(d.getDojoShape().getNode())))},_mouseOutHandler:function(d){if(d=
this._findMover(d.graphic))this.toolbar.onVertexMouseOut(this.graphic,d._getInfo())},_bindCtxNode:function(d){this._unbindCtxNode();this._ctxDelete.set("disabled",this._selectedMover.segLength<=this.minLength?!0:!1);this._ctxMenu.bindDomNode(d);this._bindNode=d},_unbindCtxNode:function(){var d=this._bindNode;d&&this._ctxMenu.unBindDomNode(d)},_findMover:function(d){var r=[];var y=this._mpVertexMovers;Q.forEach(this._vertexMovers,function(h){r=r.concat(h)});y&&Q.forEach(y,function(h){r=r.concat(h)});
for(y=0;y<r.length;y++){var z=r[y];if(z.graphic===d)return z}},_firstMoveHandler:function(d){!this._isNew(d)&&this._canAdd&&this._hideRelatedMidpoints(d);this.toolbar._beginOperation("VERTICES")},_moveStopHandler:function(d,r){var y=this._isNew(d);r&&(r.dx||r.dy)?(this._updateRelatedGraphic(d,d.relatedGraphic,d.graphic.geometry,d.segIndex,d.ptIndex,d.segLength,y),this._canAdd&&(y?this._addMidpoints(d):(this._repositionRelatedMidpoints(d),this._showRelatedMidpoints(d))),this.toolbar._endOperation("VERTICES")):
!y&&this._canAdd&&this._showRelatedMidpoints(d)},_showRelatedMidpoints:function(d){var r=this._getAdjacentMidpoints(d.ptIndex,d.segLength),y=this._mpVertexMovers[d.segIndex];for(d=0;d<r.length;d++){var z=y[r[d]];z.graphic.show();z.refresh()}},_hideRelatedMidpoints:function(d){var r=this._getAdjacentMidpoints(d.ptIndex,d.segLength),y=this._mpVertexMovers[d.segIndex];for(d=0;d<r.length;d++)y[r[d]].graphic.hide()},_repositionRelatedMidpoints:function(d){var r,y=this._getAdjacentMidpoints(d.ptIndex,d.segLength),
z=this._mpVertexMovers[d.segIndex];for(r=0;r<y.length;r++){var h=this._getAdjacentVertices(y[r],d.segLength),v=d.relatedGraphic.geometry.getPoint(d.segIndex,h[0]);h=d.relatedGraphic.geometry.getPoint(d.segIndex,h[1]);v=new k({x:(v.x+h.x)/2,y:(v.y+h.y)/2,spatialReference:v.spatialReference.toJson()});z[y[r]].graphic.setGeometry(v)}},_addMidpoints:function(d){var r=d.segIndex,y=d.ptIndex,z=d.segLength,h=y+1,v,L=z+1;this._mpVertexMovers[r].splice(y,1);var J=this._vertexMovers[r];for(v=0;v<h;v++)J[v].segLength+=
1;for(v=h;v<J.length;v++)J[v].ptIndex+=1,J[v].segLength+=1;d.ptIndex=h;d.segLength=J.length+1;J.splice(h,0,d);d.graphic.setSymbol(this._symbol1);J=this._mpVertexMovers[r];for(v=0;v<y;v++)J[v].segLength+=1;for(v=y;v<z-1;v++)J[v].ptIndex+=1,J[v].segLength+=1;h=this._getAdjacentVertices(y,L);r=this._getAdjacentVertices(y+1,L);z=d.relatedGraphic.geometry.getPoint(d.segIndex,h[0]);v=d.relatedGraphic.geometry.getPoint(d.segIndex,h[1]);h=new k({x:(z.x+v.x)/2,y:(z.y+v.y)/2,spatialReference:z.spatialReference.toJson()});
z=d.relatedGraphic.geometry.getPoint(d.segIndex,r[0]);v=d.relatedGraphic.geometry.getPoint(d.segIndex,r[1]);r=new k({x:(z.x+v.x)/2,y:(z.y+v.y)/2,spatialReference:z.spatialReference.toJson()});z=new t(h,this._symbol2,this.graphic,d.segIndex,y,L,this,!0);d=new t(r,this._symbol2,this.graphic,d.segIndex,y+1,L,this,!0);J.splice(y,0,z,d)},_deleteVertex:function(d){var r,y=d.ptIndex,z=this._vertexMovers[d.segIndex];for(r=0;r<y;r++)--z[r].segLength;for(r=y+1;r<z.length;r++){var h=z[r];--h.ptIndex;--h.segLength}z.splice(y,
1);r=d._getInfo();d.destroy();this.toolbar.onVertexDelete(this.graphic,r)}});T.mixin(e,{create:function(d,r,y){switch(d.geometry.type){case "multipoint":return new e.MultipointVertexEditor(d,r,y);case "polyline":return new e.PolylineVertexEditor(d,r,y);case "polygon":return new e.PolygonVertexEditor(d,r,y)}}});e.MultipointVertexEditor=I(e,{declaredClass:"esri.toolbars._MultipointVertexEditor",minLength:1,constructor:function(){this._moveStartHandle=g.connect(t,"onMoveStart",this,this._moveStartHandler);
g.disconnect(this._firstMoveHandle)},destroy:function(){this.inherited(arguments);g.disconnect(this._moveStartHandle)},_getSegments:function(d){var r=d.points,y=[],z=d.spatialReference;for(d=0;d<r.length;d++){var h=r[d];y.push(new k({x:h[0],y:h[1],spatialReference:z.toJson()}))}return[y]},_getMidpointSegments:function(d){return[]},_getControlPoints:function(d,r,y,z,h){return[]},_getGraphicsLayer:function(){return this.graphic._graphicsLayer},_mouseOverHandler:function(d){var r=d.graphic;if(d=this._findMover(d))this.toolbar.onVertexMouseOver(r,
d._getInfo()),this._selectedMover=d,this._canDel&&this._bindCtxNode(d.graphic.getDojoShape().getNode())},_mouseOutHandler:function(d){var r=d.graphic;if(d=this._findMover(d))this.toolbar.onVertexMouseOut(r,d._getInfo())},_findMover:function(d){var r=[].concat(this._vertexMovers[0]),y=d.target;for(d=0;d<r.length;d++){var z=r[d];if(z.graphic.getDojoShape().getNode()===y)return z}},_moveStartHandler:function(d){var r=d.ptIndex,y=d.segLength-1,z=d.relatedGraphic.geometry.points;d=z.splice(r,1);z.push(d[0]);
z=this._vertexMovers[0];for(d=y;d>r;d--)--z[d].ptIndex;d=z.splice(r,1);z.push(d[0]);d[0].ptIndex=y},_moveStopHandler:function(d){this._updateRelatedGraphic(d,d.relatedGraphic,d.graphic.geometry,d.segIndex,d.ptIndex,d.segLength);this.toolbar._endOperation("VERTICES")},_updateRelatedGraphic:function(d,r,y,z,h,v,L,J){d=r.geometry;J?d.removePoint(h):d.setPoint(h,y);r.setGeometry(d)},_deleteMidpoints:function(d){}});e.PolylineVertexEditor=I(e,{declaredClass:"esri.toolbars._PolylineVertexEditor",minLength:2,
_getSegments:function(d){var r,y,z=d.paths,h=[];for(r=0;r<z.length;r++){var v=z[r],L=[];for(y=0;y<v.length;y++)L.push(d.getPoint(r,y));h.push(L)}return h},_getMidpointSegments:function(d){var r,y,z=d.paths,h=[],v=d.spatialReference;for(r=0;r<z.length;r++){var L=z[r],J=[];for(y=0;y<L.length-1;y++){var U=d.getPoint(r,y),S=d.getPoint(r,y+1);U=new k({x:(U.x+S.x)/2,y:(U.y+S.y)/2,spatialReference:v.toJson()});J.push(U)}h.push(J)}return h},_getControlPoints:function(d,r,y,z,h){var v=this.map,L,J;this._isNew(d)?
(d=z,z+=1,0<=d&&(L=v.toScreen(r.getPoint(y,d))),z<=h&&(J=v.toScreen(r.getPoint(y,z)))):(d=z-1,z+=1,0<=d&&(L=v.toScreen(r.getPoint(y,d))),z<h&&(J=v.toScreen(r.getPoint(y,z))));return[L,J]},_getAdjacentMidpoints:function(d,r){var y=[],z=d-1;0<=z&&y.push(z);d<r-1&&y.push(d);return y},_getAdjacentVertices:function(d,r){return[d,d+1]},_deleteMidpoints:function(d){var r=this._mpVertexMovers[d.segIndex],y=r.length-1,z=this._getAdjacentMidpoints(d.ptIndex,d.segLength).sort(),h,v=z[0];for(h=0;h<v;h++)--r[h].segLength;
for(h=v+1;h<r.length;h++){var L=r[h];--L.ptIndex;--L.segLength}if(1===z.length)r.splice(v,1)[0].destroy();else for(L=this._getAdjacentVertices(v,y),h=d.relatedGraphic.geometry.getPoint(d.segIndex,L[0]),L=d.relatedGraphic.geometry.getPoint(d.segIndex,L[1]),h=new k({x:(h.x+L.x)/2,y:(h.y+L.y)/2,spatialReference:h.spatialReference.toJson()}),d=new t(h,this._symbol2,this.graphic,d.segIndex,v,y,this,!0),r=r.splice(v,z.length,d),h=0;h<r.length;h++)r[h].destroy()},_updateRelatedGraphic:function(d,r,y,z,h,
v,L,J){d=r.geometry;L?d.insertPoint(z,h+1,A.fromJson(y.toJson())):J?d.removePoint(z,h):d.setPoint(z,h,A.fromJson(y.toJson()));r.setGeometry(d)}});e.PolygonVertexEditor=I(e,{declaredClass:"esri.toolbars._PolygonVertexEditor",minLength:3,_getSegments:function(d){var r,y,z=d.rings,h=[];for(r=0;r<z.length;r++){var v=z[r],L=[];for(y=0;y<v.length-1;y++)L.push(d.getPoint(r,y));h.push(L)}return h},_getMidpointSegments:function(d){var r,y,z=d.rings,h=[],v=d.spatialReference;for(r=0;r<z.length;r++){var L=z[r],
J=[];for(y=0;y<L.length-1;y++){var U=d.getPoint(r,y),S=d.getPoint(r,y+1);U=new k({x:(U.x+S.x)/2,y:(U.y+S.y)/2,spatialReference:v.toJson()});J.push(U)}h.push(J)}return h},_getControlPoints:function(d,r,y,z,h){var v=this.map;this._isNew(d)?d=z:(d=z-1,d=0>d?(h+d)%h:d);z=(z+1)%h;h=v.toScreen(r.getPoint(y,d));r=v.toScreen(r.getPoint(y,z));return[h,r]},_getAdjacentMidpoints:function(d,r){var y=d-1;return[0>y?(r+y)%r:y,d]},_getAdjacentVertices:function(d,r){return[d,(d+1)%r]},_deleteMidpoints:function(d){var r=
d.ptIndex,y=this._mpVertexMovers[d.segIndex],z=y.length-1,h=this._getAdjacentMidpoints(r,d.segLength).sort();var v=h[0];var L=h[h.length-1];if(0===r){var J=this._getAdjacentVertices(z-1,z);r=d.relatedGraphic.geometry.getPoint(d.segIndex,J[0]);J=d.relatedGraphic.geometry.getPoint(d.segIndex,J[1]);r=new k({x:(r.x+J.x)/2,y:(r.y+J.y)/2,spatialReference:r.spatialReference.toJson()});d=new t(r,this._symbol2,this.graphic,d.segIndex,z-1,z,this,!0);y.splice(L,1,d)[0].destroy();y.splice(v,1)[0].destroy();for(h=
0;h<y.length-1;h++)v=y[h],--v.ptIndex,--v.segLength}else{J=this._getAdjacentVertices(v,z);r=d.relatedGraphic.geometry.getPoint(d.segIndex,J[0]);J=d.relatedGraphic.geometry.getPoint(d.segIndex,J[1]);r=new k({x:(r.x+J.x)/2,y:(r.y+J.y)/2,spatialReference:r.spatialReference.toJson()});d=new t(r,this._symbol2,this.graphic,d.segIndex,v,z,this,!0);L=y.splice(v,h.length,d);for(h=0;h<L.length;h++)L[h].destroy();for(h=0;h<v;h++)--y[h].segLength;for(h=v+1;h<y.length;h++)v=y[h],--v.ptIndex,--v.segLength}},_updateRelatedGraphic:function(d,
r,y,z,h,v,L,J){d=r.geometry;L?d.insertPoint(z,h+1,A.fromJson(y.toJson())):J?(d.removePoint(z,h),0===h&&d.setPoint(z,v-1,A.fromJson(d.getPoint(z,0).toJson()))):(d.setPoint(z,h,A.fromJson(y.toJson())),0===h&&d.setPoint(z,v,A.fromJson(y.toJson())));r.setGeometry(d)}});O("extend-esri")&&(T.setObject("toolbars._GraphicVertexEditor",e,F),T.setObject("toolbars._MultipointVertexEditor",e.MultipointVertexEditor,F),T.setObject("toolbars._PolylineVertexEditor",e.PolylineVertexEditor,F),T.setObject("toolbars._PolygonVertexEditor",
e.PolygonVertexEditor,F));return e})},"esri/toolbars/_VertexMover":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/connect dojo/sniff dojo/dom-style dojox/gfx/Moveable dojox/gfx/matrix ../kernel ../PointerEvents ../sniff ../geometry/Point ../graphic ../geometry/webMercatorUtils".split(" "),function(I,T,g,Q,O,M,H,F,t,k,A,m,e){I=I(null,{declaredClass:"esri.toolbars.VertexMover",constructor:function(d,r,y,z,h,v,L,J){this.point=d;this.symbol=r;this.relatedGraphic=y;this.segIndex=z;this.ptIndex=
h;this.segLength=v;this.editor=L;this.map=L.map;this._scratchGL=L.toolbar._scratchGL;this._placeholder=J||!1;this._type=y.geometry.type;this._init();this._enable()},refresh:function(d){if(d||this._needRefresh())this._disable(),this._enable()},destroy:function(){this._disable();this.graphic&&this._scratchGL.remove(this.graphic);this.point=this.symbol=this.graphic=this.relatedGraphic=this.segIndex=this.ptIndex=this.segLength=this.editor=this.map=this._scratchGL=null},_init:function(){var d=new A(this.point.toJson());
d=new m(d,this.symbol);switch(this._type){case "multipoint":d._shape=this.relatedGraphic.getDojoShape().children[this.ptIndex];break;case "polyline":case "polygon":this._scratchGL.add(d)}this.graphic=d},_enable:function(){var d=this.graphic.getDojoShape();d&&(d._hasMover=!0,this._moveable=this._getMoveable(d),(d=d.getEventSource())&&O.set(d,"cursor",this.editor.toolbar._cursors[this._placeholder?"move-gv":"move-v"]))},_disable:function(){var d=this._moveable;if(d){g.disconnect(this._startHandle);
g.disconnect(this._firstHandle);g.disconnect(this._movingHandle);g.disconnect(this._stopHandle);var r=d.shape;r&&(r=r.getEventSource())&&O.set(r,"cursor","inherit");d.destroy();this._moveable=null}},_needRefresh:function(){var d=this.graphic.getDojoShape(),r=!1;if(d)switch(this._type){case "multipoint":var y=this.relatedGraphic.getDojoShape();y&&(y=y.children[this.ptIndex],d!==y&&(this.graphic._shape=y,r=!0));break;case "polyline":case "polygon":r=!d._hasMover}return r},_getMoveable:function(d){d=
new M(d,Q("mac")&&Q("ff")&&!k("esri-touch")&&{leftButtonOnly:!0});this._startHandle=g.connect(d,"onMoveStart",this,this._moveStartHandler);this._firstHandle=g.connect(d,"onFirstMove",this,this._firstMoveHandler);this._movingHandle=g.connect(d,"onMoving",this,this._movingHandler);this._stopHandle=g.connect(d,"onMoveStop",this,this._moveStopHandler);return d},_getPtIndex:function(){return this.ptIndex+(this._placeholder?1:0)},_getInfo:function(){return{graphic:this.graphic,isGhost:this._placeholder,
segmentIndex:this.segIndex,pointIndex:this._getPtIndex()}},_moveStartHandler:function(d){var r=this.map;r.snappingManager&&r.snappingManager._setUpSnapping();this.editor.toolbar._deactivateScrollWheel();this._startTx=this.graphic.getDojoShape().getTransform();d.shape.moveToFront();this.constructor.onMoveStart(this);this.editor.toolbar.onVertexMoveStart(this.relatedGraphic,this._getInfo())},_firstMoveHandler:function(d){var r=d.shape,y=this._getControlEdges(),z=this._scratchGL._div,h,v=[],L=d.host.shape._wrapOffsets[0]||
0;for(h=0;h<y.length;h++){var J=y[h];J.x1+=L;J.x2+=L;v.push([z.createLine({x1:J.x1,y1:J.y1,x2:J.x2,y2:J.y2}).setStroke(this.editor._lineStroke),J.x1,J.y1,J.x2,J.y2])}r._lines=v;d.shape.moveToFront();this.constructor.onFirstMove(this);this.editor.toolbar.onVertexFirstMove(this.relatedGraphic,this._getInfo())},_movingHandler:function(d,r,y){r=this.map;var z;k("esri-pointer")?z=r.navigationManager.pointerEvents._processTouchEvent(y,y):y&&"pointermove"===y.type&&(z=t.prototype._processTouchEvent.call({map:r},
y,y));z&&r.snappingManager&&r.snappingManager._onSnappingMouseMoveHandler(z);y=d.shape;d=y.getTransform();y=y._lines;for(z=0;z<y.length;z++)r=y[z],r[0].setShape({x1:r[1]+d.dx,y1:r[2]+d.dy,x2:r[3],y2:r[4]});this.editor.toolbar.onVertexMove(this.relatedGraphic,this._getInfo(),d)},_moveStopHandler:function(d){d=d.shape;var r=this.editor.toolbar,y=d.getTransform(),z=this.map,h=this.graphic,v=r._geo?e.geographicToWebMercator(h.geometry):h.geometry;r._activateScrollWheel();var L,J=d._lines;if(J){for(L=
0;L<J.length;L++)J[L][0].removeShape();d._lines=null}L=!1;J=!0;var U=this._getInfo();y&&(y.dx||y.dy)?this._placeholder&&(this._placeholder=!1,L=!0):J=!1;if(z.snappingManager)var S=z.snappingManager._snappingPoint;var N=[y,H.invert(this._startTx)];S=S||z.toMap(H.multiplyPoint(N,z.toScreen(v,!0)));z.snappingManager&&z.snappingManager._killOffSnapping();d.setTransform(null);h.setGeometry(r._geo?e.webMercatorToGeographic(S,!0):S);this.constructor.onMoveStop(this,y);r.onVertexMoveStop(this.relatedGraphic,
U,y);if(!J)r.onVertexClick(this.relatedGraphic,U);if(L)r.onVertexAdd(this.relatedGraphic,this._getInfo())},_getControlEdges:function(){var d=this.map,r=this.relatedGraphic.geometry,y=this.segIndex,z=this.ptIndex,h=this.segLength,v=this._scratchGL.getNavigationTransform(),L=v.dx;v=v.dy;var J=d.toScreen(this.graphic.geometry);d=J.x-L;J=J.y-v;var U=[];r=this.editor._getControlPoints(this,r,y,z,h);r[0]&&U.push({x1:d,y1:J,x2:r[0].x-L,y2:r[0].y-v});r[1]&&U.push({x1:d,y1:J,x2:r[1].x-L,y2:r[1].y-v});return U}});
k("extend-esri")&&T.setObject("toolbars.VertexMover",I,F);T.mixin(I,{onMoveStart:function(){},onFirstMove:function(){},onMoveStop:function(){}});return I})},"esri/toolbars/TextEditor":function(){define("dojo/_base/declare dojo/_base/lang dojo/_base/connect dojo/_base/event dojo/has dojo/dom-construct dojo/dom-class dojo/dom-style dojo/keys ../kernel".split(" "),function(I,T,g,Q,O,M,H,F,t,k){I=I(null,{declaredClass:"esri.toolbars.TextEditor",constructor:function(A,m,e){this._graphic=A;this._map=m;
this._toolbar=e;this._enable(this._graphic)},destroy:function(){this._disable()},onEditStart:function(){},onEditEnd:function(){},_enable:function(A){this._editBox?(g.disconnect(this._addEditBoxHandler),this._addEditBoxHandler=null):(this._map.navigationManager.setImmediateClick(!0),this._addEditBoxHandler=g.connect(A.getLayer(),"onDblClick",this,function(m){this._map.navigationManager.setImmediateClick(!1);m.graphic==A&&(Q.stop(m),g.disconnect(this._addEditBoxHandler),this._addEditBoxHandler=null,
this._addTextBox(A))}))},_disable:function(){this._applyEdit();this._addEditBoxHandler&&(g.disconnect(this._addEditBoxHandler),this._addEditBoxHandler=null);this._removeTextBox();this.onEditEnd(this._graphic);this._toolbar.onTextEditEnd(this._graphic)},_addTextBox:function(A,m){if(!this._editBox){if(!A.symbol.text){A.symbol.text="Tempt text";A.setSymbol(A.symbol);var e=""}var d=this._createInputTextStyle(A,this._map);""!==e&&(e=m||A.symbol.text);this._editBox=M.create("input",{type:"text",value:e});
F.set(this._editBox,d);H.add(this._editBox,"esriTextEditorInput");this._map.container.appendChild(this._editBox);this._editBox.focus();this._editBoxKeyHandler=g.connect(this._editBox,"onkeyup",T.hitch(this,function(y){y.keyCode!=t.ENTER&&y.keyCode!==t.TAB||this._disable()}));this._editBoxBlurHandler=g.connect(this._editBox,"onblur",T.hitch(this,function(y){this._disable()}));A.symbol.text="";A.setSymbol(A.symbol);A.hide();var r=this._editBox;this._disableBoxHandler||(this._disableBoxHandler=this._map.on("zoom-start",
T.hitch(this,function(){this._disable()})));this._moveBoxHandler=this._map.on("pan",function(y){F.set(r,{left:this._editBoxLeft+y.delta.x+"px",top:this._editBoxTop+y.delta.y+"px"})});this._moveBoxStartHandler=this._map.on("pan-start",function(){this._editBoxLeft=parseFloat(F.get(r,"left"));this._editBoxTop=parseFloat(F.get(r,"top"))});this.onEditStart(A,this._editBox);this._toolbar.onTextEditStart(A,this._editBox)}},_removeTextBox:function(){this._editBoxBlurHandler&&(g.disconnect(this._editBoxBlurHandler),
this._editBoxBlurHandler=null);this._editBox&&(this._editBox.parentNode.removeChild(this._editBox),this._editBox=null);this._disableBoxHandler&&(this._disableBoxHandler.remove(),this._disableBoxHandler=null);this._moveBoxHandler&&(this._moveBoxHandler.remove(),this._moveBoxHandler=null);this._moveBoxStartHandler&&(this._moveBoxStartHandler.remove(),this._moveBoxStartHandler=null);this._editBoxKeyHandler&&(g.disconnect(this._editBoxKeyHandler),this._editBoxKeyHandler=null)},_createInputTextStyle:function(A,
m){m=A.getDojoShape().getTransformedBoundingBox();var e=A.getLayer();e=e.hasLocalNavigationTransform()?{dx:0,dy:0}:e.getNavigationTransform();var d=A.symbol.font;return{"font-family":d.family,"font-size":d.size+"px","font-style":d.style,"font-variant":d.variant,"font-weight":d.weight,left:m[0].x+e.dx+"px",top:m[0].y+e.dy+"px",width:Math.abs(m[0].x-m[1].x)/Math.cos(A.symbol.angle/180*Math.PI)+"px"}},_applyEdit:function(){if(this._editBox)if(this._editBox.value){this._graphic.show();var A=this._graphic.symbol;
A.text=this._editBox.value;this._graphic.setSymbol(A)}else this._graphic.getLayer().remove(this._graphic)}});O("extend-esri")&&T.setObject("toolbars.TextEditor",I,k);return I})},"widgets/DistrictLookup/utils":function(){define(["dojo/_base/declare","dijit/_WidgetBase","dojo/_base/array","dojo/_base/lang"],function(I,T,g,Q){return I([T],{map:null,postCreate:function(){},getLayerDetailsFromMap:function(O,M,H){var F={},t;this.map&&this.map.webMapResponse&&this.map.webMapResponse.itemInfo&&this.map.webMapResponse.itemInfo.itemData&&
this.map.webMapResponse.itemInfo.itemData.operationalLayers&&g.forEach(this.map.webMapResponse.itemInfo.itemData.operationalLayers,Q.hitch(this,function(k){k.layerObject&&("ArcGISMapServiceLayer"===k.layerType||"ArcGISTiledMapServiceLayer"===k.layerType?(t=H&&H.substring(0,H.lastIndexOf("_")),t&&k.id!==t||(F.isMapServer=!0,F.id=k.id+"_"+M,O.substring(0,O.length-1)===k.url&&(g.forEach(k.resourceInfo.layers,Q.hitch(this,function(A){A.id===parseInt(M,10)&&(F.title=A.name)})),g.forEach(k.layers,Q.hitch(this,
function(A){A.id===parseInt(M,10)&&(A.name&&(F.title=A.name),F.popupInfo=A.popupInfo,A.layerDefinition&&(A.layerDefinition.definitionExpression&&(F.definitionExpression=A.layerDefinition.definitionExpression),A.layerDefinition.drawingInfo&&A.layerDefinition.drawingInfo.renderer&&(F.renderer=A.layerDefinition.drawingInfo.renderer)))}))))):H&&k.id!==H||!k.url||k.url.replace(/.*?:\/\//g,"")!==(O+M).replace(/.*?:\/\//g,"")||(F.isMapServer=!1,F.title=k.title,F.popupInfo=k.popupInfo,F.id=k.id,k.layerDefinition&&
(k.layerDefinition.definitionExpression&&(F.definitionExpression=k.layerDefinition.definitionExpression),k.layerDefinition.drawingInfo&&k.layerDefinition.drawingInfo.renderer&&(F.renderer=k.layerDefinition.drawingInfo.renderer))))}));return F}})})},"widgets/DistrictLookup/_build-generate_module":function(){define(["dojo/text!./Widget.html","dojo/text!./css/style.css","dojo/i18n!./nls/strings"],function(){})},"url:esri/dijit/Search/templates/Search.html":'\x3cdiv role\x3d"presentation" class\x3d"${theme}"\x3e\r\n  \x3cdiv role\x3d"presentation" class\x3d"${css.searchGroup}" data-dojo-attach-point\x3d"containerNode"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"expandNode" class\x3d"${css.searchExpandContainer}"\x3e\r\n      \x3cdiv class\x3d"${css.searchAnimateContainer}"\x3e\r\n        \x3cdiv role\x3d"button" title\x3d"${_i18n.widgets.Search.main.searchIn}" id\x3d"${id}_menu_button" class\x3d"${css.searchBtn} ${css.searchToggle}" tabindex\x3d"0" data-dojo-attach-point\x3d"sourcesBtnNode"\x3e\r\n          \x3cspan aria-hidden\x3d"true" role\x3d"presentation" class\x3d"${css.searchToggleIcon}"\x3e\x3c/span\x3e\x3cspan class\x3d"${css.searchSourceName}" data-dojo-attach-point\x3d"sourceNameNode"\x3e\x3c/span\x3e\r\n        \x3c/div\x3e\r\n        \x3cdiv class\x3d"${css.searchInputGroup}"\x3e\r\n          \x3cform data-dojo-attach-point\x3d"formNode"\x3e\r\n            \x3cinput maxlength\x3d"${maxLength}" autocomplete\x3d"off" type\x3d"text" tabindex\x3d"0" class\x3d"${css.searchInput}" value\x3d"${value}" aria-haspopup\x3d"true" id\x3d"${id}_input" data-dojo-attach-point\x3d"inputNode" role\x3d"textbox"\x3e\r\n          \x3c/form\x3e\r\n          \x3cdiv role\x3d"button" class\x3d"${css.searchClear}" tabindex\x3d"0" data-dojo-attach-point\x3d"clearNode"\x3e\x3cspan aria-hidden\x3d"true" class\x3d"${css.searchClearIcon}"\x3e\x3c/span\x3e\x3cspan aria-hidden\x3d"true" class\x3d"${css.searchSpinner}"\x3e\x3c/span\x3e\r\n          \x3c/div\x3e\r\n          \x3cdiv data-dojo-attach-point\x3d"suggestionsNode" class\x3d"${css.searchMenu} ${css.suggestionsMenu}"\x3e\x3c/div\x3e\r\n        \x3c/div\x3e\r\n      \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv role\x3d"button" title\x3d"${_i18n.widgets.Search.main.searchButtonTitle}" class\x3d"${css.searchBtn} ${css.searchSubmit}" tabindex\x3d"0" data-dojo-attach-point\x3d"submitNode"\x3e\r\n      \x3cspan aria-hidden\x3d"true" role\x3d"presentation" class\x3d"${css.searchIcon}"\x3e\x3c/span\x3e\r\n      \x3cspan class\x3d"${css.searchButtonText}"\x3e${_i18n.widgets.Search.main.searchButtonTitle}\x3c/span\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"sourcesNode" class\x3d"${css.searchMenu} ${css.sourcesMenu}"\x3e\x3c/div\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"noResultsMenuNode" class\x3d"${css.searchMenu} ${css.searchNoResultsMenu}"\x3e\x3c/div\x3e\r\n    \x3cdiv class\x3d"${css.searchClearFloat}"\x3e\x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e',
"url:esri/dijit/templates/Directions.html":'\x3cdiv class\x3d"${options.theme}" role\x3d"presentation"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"_widgetContainer" class\x3d"${_css.widgetContainerClass}" role\x3d"presentation"\x3e\r\n        \x3cdiv class\x3d"${_css.stopsContainerClass}" role\x3d"presentation"\x3e\r\n            \x3cdiv id\x3d"search-source-container" class\x3d"${_css.searchSourceContainerClass}" data-dojo-attach-point\x3d"_searchSourceContainerNode"\x3e\r\n                \x3cdiv data-dojo-attach-point\x3d"_searchSourceSelectorContainer"\x3e\x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"${_css.stopsTableContainerClass}"\x3e\r\n                \x3ctable class\x3d"${_css.stopsClass}" data-dojo-attach-point\x3d"_dndNode"\x3e\x3c/table\x3e\r\n                \x3cdiv class\x3d"${_css.stopsTableCoverClass}" data-dojo-attach-point\x3d"_stopsTableCover"\x3e\x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"${_css.clearClass}"\x3e\x3c/div\x3e\r\n            \x3cdiv class\x3d"${_css.stopsButtonContainerClass}"\x3e\r\n                \x3cdiv class\x3d"${_css.stopsAddDestinationClass}"\x3e\r\n                    \x3cdiv tabindex\x3d"0" role\x3d"button" data-dojo-attach-point\x3d"_activateButtonNode" title\x3d"${_i18n.widgets.directions.activate}" class\x3d"${_css.activateButtonClass} ${_css.stopsButtonClass} ${_css.stopsButtonTabClass} ${_css.stopsPressedButtonClass}" data-blur-on-click\x3d"true"\x3e\x3c/div\x3e\r\n                    \x3cdiv tabindex\x3d"0" role\x3d"button" data-dojo-attach-point\x3d"_lineBarrierButtonNode" title\x3d"${_i18n.widgets.directions.lineBarrier}" class\x3d"${_css.lineBarrierButtonClass} ${_css.stopsButtonClass} ${_css.stopsButtonTabClass}" data-blur-on-click\x3d"true"\x3e\x3c/div\x3e\r\n                    \x3cdiv role\x3d"button" tabindex\x3d"0" class\x3d"${_css.linkButtonClass} ${_css.stopsAddDestinationBtnClass}" data-dojo-attach-point\x3d"_addDestinationNode" data-blur-on-click\x3d"true"\x3e${_i18n.widgets.directions.addDestination}\x3c/div\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv class\x3d"${_css.travelModesContainerClass}" data-dojo-attach-point\x3d"_travelModeContainerNode"\x3e\r\n                    \x3cdiv data-dojo-attach-point\x3d"_travelModeSelectorContainer"\x3e\x3c/div\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.linkButtonClass} startTimeMenuButton" data-blur-on-click\x3d"true" data-dojo-attach-point\x3d"_startTimeButtonNodeContainer"\x3e\r\n                    \x3cdiv data-dojo-attach-point\x3d"_startTimeButtonNode"\x3e\r\n                        \x3cspan data-dojo-attach-point\x3d"_startTimeButtonLabel"\x3e${_i18n.widgets.directions.leaveNow}\x3c/span\x3e\r\n                        \x3cdiv data-dojo-attach-point\x3d"_startTimeDDLArrow" class\x3d"esriDirectionsDDLArrow"\x3e\x3c/div\x3e\r\n                    \x3c/div\x3e\r\n                    \x3cdiv class\x3d"startTimeMenu" data-dojo-attach-point\x3d"_startTimeMenu"\x3e\r\n                        \x3cul role\x3d"menu"\x3e\r\n                            \x3cli data-dojo-attach-point\x3d"_startTimeMenuLeaveNow" tabindex\x3d"0" class\x3d"esriRouteZoom startTimeMenuItem" role\x3d"menuitemradio" aria-checked\x3d"true"\x3e${_i18n.widgets.directions.leaveNow}\x3c/li\x3e\r\n                            \x3cli data-dojo-attach-point\x3d"_startTimeMenuDepartAt" tabindex\x3d"0" class\x3d"esriRouteZoom startTimeMenuItem" role\x3d"menuitemradio"\x3e${_i18n.widgets.directions.departAt}\x3c/li\x3e\r\n                            \x3cli data-dojo-attach-point\x3d"_startTimeMenuNone" tabindex\x3d"0" class\x3d"esriRouteZoom startTimeMenuItem" role\x3d"menuitemradio"\x3e${_i18n.widgets.directions.noStartTime}\x3c/li\x3e\r\n                        \x3c/ul\x3e\r\n                    \x3c/div\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.linkButtonClass} ${_css.stopsOptionsButtonClass}" data-dojo-attach-point\x3d"_optionsButtonNode" data-blur-on-click\x3d"true"\x3e${_i18n.widgets.directions.showOptions}\x3c/div\x3e\r\n            \t\x3cdiv class\x3d"${_css.clearClass}"\x3e\x3c/div\x3e\r\n                \x3cdiv class\x3d"departAtContainer" data-dojo-attach-point\x3d"_departAtContainer"\x3e\r\n                    \x3cdiv id\x3d"${id}_directionsDepartAtTime" data-dojo-attach-point\x3d"_departAtTimeContainer"\x3e\x3c/div\x3e\r\n                    \x3cdiv id\x3d"${id}_directionsDepartAtDate" data-dojo-attach-point\x3d"_departAtDateContainer"\x3e\x3c/div\x3e\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv role\x3d"presentation" class\x3d"${_css.stopsOptionsMenuClass}" data-dojo-attach-point\x3d"_optionsMenuNode"\x3e\r\n                \x3cdiv class\x3d"${_css.stopsOptionsCheckboxesClass}"\x3e\r\n                    \x3cul\x3e\r\n                        \x3cli class\x3d"${_css.stopsFindOptimalOrderClass}" data-dojo-attach-point\x3d"_findOptimalOrderItemNode"\x3e\x3cinput tabindex\x3d"0" data-dojo-attach-point\x3d"_findOptimalOrderNode" type\x3d"checkbox" id\x3d"${id}_find_optimal_order" /\x3e\x3clabel for\x3d"${id}_find_optimal_order"\x3e${_i18n.widgets.directions.findOptimalOrder}\x3c/label\x3e\x3c/li\x3e\r\n                        \x3cli class\x3d"${_css.stopsReturnToStartClass}" data-dojo-attach-point\x3d"_returnToStartItemNode"\x3e\x3cinput tabindex\x3d"0" data-dojo-attach-point\x3d"_returnToStartNode" type\x3d"checkbox" id\x3d"${id}_stopsReturnToStart" /\x3e\x3clabel for\x3d"${id}_stopsReturnToStart"\x3e${_i18n.widgets.directions.returnToStart}\x3c/label\x3e\x3c/li\x3e\r\n                        \x3cli class\x3d"${_css.stopsUseTrafficClass}" data-dojo-attach-point\x3d"_useTrafficItemNode" title\x3d"${_i18n.widgets.directions.trafficLabelLive}"\x3e\r\n                            \x3cinput tabindex\x3d"0" data-dojo-attach-point\x3d"_useTrafficNode" type\x3d"checkbox" id\x3d"${id}_stopsUseTraffic" /\x3e\x3clabel for\x3d"${id}_stopsUseTraffic"\x3e${_i18n.widgets.directions.useTraffic}\x3c/label\x3e\r\n                            \x3ca data-dojo-attach-point\x3d"_trafficAvailabilityButton" style\x3d"display: none;" href\x3d"http://www.arcgis.com/home/item.html?id\x3db7a893e8e1e04311bd925ea25cb8d7c7" target\x3d"_blank"\x3e\x3cdiv class\x3d"esriTrafficAvailabilityButton" title\x3d"${_i18n.widgets.directions.seeTrafficAvailability}"\x3e\x3c/div\x3e\x3c/a\x3e\r\n                        \x3c/li\x3e\r\n                    \x3c/ul\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv class\x3d"${_css.stopsOptionsToggleContainerClass}"\x3e\r\n                    \x3cdiv class\x3d"${_css.stopsOptionsUnitsContainerClass}"  data-dojo-attach-point\x3d"_agolDistanceUnitsNode"\x3e\r\n                        \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.stopsOptionsUnitsMiClass} ${_css.stopsButtonClass}" data-dojo-attach-point\x3d"_useMilesNode" data-blur-on-click\x3d"true"\x3e${_i18n.widgets.directions.units.esriMiles.abbr}\x3c/div\x3e\r\n                        \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.stopsOptionsUnitsKmClass} ${_css.stopsButtonClass} ${_css.stopsButtonTabLastClass} ${_css.stopsPressedButtonClass}" data-dojo-attach-point\x3d"_useKilometersNode" data-blur-on-click\x3d"true"\x3e${_i18n.widgets.directions.units.esriKilometers.abbr}\x3c/div\x3e\r\n                        \x3cdiv class\x3d"${_css.clearClass}"\x3e\x3c/div\x3e\r\n                    \x3c/div\x3e\r\n                    \x3cdiv class\x3d"${_css.clearClass}"\x3e\x3c/div\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv class\x3d"${_css.clearClass}"\x3e\x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"${_css.stopsGetDirectionsContainerClass}"\x3e\r\n                \x3cdiv class\x3d"getDirectionsBtnContainer"\x3e\r\n                    \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.stopsButtonClass} ${_css.stopsGetDirectionsClass} esriDisabledDirectionsButton" data-dojo-attach-point\x3d"_getDirectionsButtonNode" data-blur-on-click\x3d"true"\x3e${_i18n.widgets.directions.getDirections}\x3c/div\x3e\r\n                    \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.linkButtonClass} ${_css.stopsClearDirectionsClass}" data-dojo-attach-point\x3d"_clearDirectionsButtonNode" data-blur-on-click\x3d"true"\x3e${_i18n.widgets.directions.clearDirections}\x3c/div\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv class\x3d"savePrintBtnContainer" data-dojo-attach-point\x3d"_savePrintBtnContainer"\x3e\r\n                    \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.resultsSaveClass} ${_css.stopsButtonClass} ${_css.stopsButtonTabClass}" data-blur-on-click\x3d"true" data-dojo-attach-point\x3d"_saveMenuButton" title\x3d"${_i18n.widgets.directions.saveTitle}" \x3e\x3c/div\x3e\r\n                    \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.resultsPrintClass} ${_css.stopsButtonClass} ${_css.stopsButtonTabClass}" data-blur-on-click\x3d"true" data-dojo-attach-point\x3d"_printButton" title\x3d"${_i18n.widgets.directions.print}" \x3e\x3c/div\x3e\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv role\x3d"presentation" class\x3d"${_css.stopsOptionsMenuClass} esriSaveContainer" data-dojo-attach-point\x3d"_saveMenuNode"\x3e\r\n                \x3cdiv class\x3d"esriLayerNameLabel"\x3e${_i18n.widgets.directions.layerName}\x3c/div\x3e\r\n                \x3cinput type\x3d"text" data-dojo-attach-point\x3d"_outputLayerContainer"\x3e\r\n                \x3cdiv data-dojo-attach-point\x3d"_folderSelectorContainer"\x3e\x3c/div\x3e\r\n                \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"${_css.stopsButtonClass} esriSaveButton esriDisabledDirectionsButton" data-dojo-attach-point\x3d"_saveButton" data-blur-on-click\x3d"true"\x3e${_i18n.widgets.directions.save}\x3c/div\x3e\r\n                \x3cdiv tabindex\x3d"0" role\x3d"button" class\x3d"esriLinkButton esriSaveAsButton" data-dojo-attach-point\x3d"_saveAsButton" data-blur-on-click\x3d"true"\x3e${_i18n.widgets.directions.saveAs}\x3c/div\x3e\r\n            \x3c/div\x3e\r\n    \t\x3c/div\x3e\r\n    \t\x3cdiv class\x3d"${_css.clearClass}"\x3e\x3c/div\x3e\r\n    \t\x3cdiv data-dojo-attach-point\x3d"_msgNode" role\x3d"presentation"\x3e\x3c/div\x3e\r\n    \t\x3cdiv class\x3d"${_css.resultsContainerClass}" role\x3d"presentation"\x3e\r\n        \t\x3cdiv class\x3d"${_css.routesContainerClass}" data-dojo-attach-point\x3d"_resultsNode" role\x3d"presentation"\x3e\x3c/div\x3e\r\n    \t\x3c/div\x3e\r\n    \x3c/div\x3e\r\n\x3c/div\x3e',
"url:widgets/DistrictLookup/Widget.html":'\x3cdiv class\x3d"esriCTPolligPlaceContainer esriCTFullHeight"\x3e\r\n    \x3cdiv class\x3d"esriCTFullHeight" data-dojo-attach-point\x3d"widgetMainNode"\x3e\r\n        \x3cdiv class\x3d"esriCTSearchOuterContainer"\x3e\r\n            \x3cdiv class\x3d"esriCTSearchHeader firstFocusNode" data-dojo-attach-point\x3d"searchHeaderTextNode" tabindex\x3d"0"\r\n                role\x3d"presentation" aria-label\x3d"${nls.searchHeaderText}"\x3e\r\n                ${nls.searchHeaderText}\x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTSearchContainer"\x3e\r\n                \x3cdiv class\x3d"esriCTSearchDiv"\x3e\r\n                    \x3cdiv data-dojo-attach-point\x3d"search"\x3e\r\n                    \x3c/div\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv role\x3d"button" tabindex\x3d"0" aria-label\x3d"${nls.mouseOverTooltip}" class\x3d"esriCTSelectLocationDiv esriCTImgButtons esriCTSelectLocation esriCTHidden"\r\n                    data-dojo-attach-point\x3d"selectLocation" title\x3d"${nls.mouseOverTooltip}"\x3e\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n        \x3cdiv class\x3d"esriCTResultsPanel esriCTTopBorder esriCTHidden" data-dojo-attach-point\x3d"featuresListNode"\x3e\r\n        \x3c/div\x3e\r\n        \x3cdiv class\x3d"esriCTResultsPanel esriCTHidden" data-dojo-attach-point\x3d"resultsPanel"\x3e\r\n            \x3cdiv tabindex\x3d"0" aria-label\x3d"${nls.common.back}" role\x3d"button" class\x3d"esriCTBackButton esriCTTopBorder"\r\n                data-dojo-attach-point\x3d"backButtonNode"\x3e\r\n                \x3cdiv class\x3d"esriCTItemLeftArrow "\x3e\r\n                \x3c/div\x3e\r\n                \x3cdiv class\x3d"esriCTBackButtonText " title\x3d"${nls.common.back}"\x3e\r\n                    ${nls.common.back}\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv data-dojo-attach-point\x3d"tabContainerPanel"\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"esriCTWidgetErrorNode" data-dojo-attach-point\x3d"widgetErrorNode"\x3e\r\n    \x3c/div\x3e\r\n\x3c/div\x3e\r\n',
"url:widgets/DistrictLookup/css/style.css":".esriCTPolligPlaceContainer{min-width: 222px; height: 100%; -webkit-overflow-scrolling: touch;}.esriCTPollingPlaceContentPanel{padding: 15px 0px !important;}.jimu-widget-districtlookup .esriCTHidden{display: none;}.jimu-widget-districtlookup .esriCTWidgetErrorNode{color: Red;}.jimu-widget-districtlookup .esriCTFullHeight{height: 100%;}.jimu-widget-districtlookup .esriCTSearchOuterContainer{padding: 0px 15px 15px 20px; clear: both;}.jimu-widget-districtlookup .esriCTSearchHeader{padding: 0px 0px 10px 0px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline-offset: -2px;}.jimu-widget-districtlookup .esriCTSearchDiv{float: left; clear: both;}.jimu-widget-districtlookup .esriCTSearchDiv .arcgisSearch{float: left; width: 100% !important;}.jimu-widget-districtlookup .esriCTSearchContainer{width: 100%; height: 35px;}.jimu-widget-districtlookup .arcgisSearch .searchGroup .searchInput{width: 170px;}.jimu-widget-districtlookup .arcgisSearch .searchBtn{padding: 6px;}.jimu-widget-districtlookup .arcgisSearch .searchToggle:focus{outline: 2px solid #18acc2;}.jimu-widget-search .arcgisSearch .searchGroup .searchInputGroup .searchInput{width: auto;}.jimu-widget-districtlookup .esriCTFisrtInfoContentDiv{padding-bottom: 15px;}.jimu-widget-districtlookup .esriCTInformationPanel{margin-top: 10px;}.jimu-widget-districtlookup .esriCTListPanel{height: calc(100% - 65px); overflow-y: auto;}.jimu-widget-districtlookup .esriCTResultsPanel{height: calc(100% - 61px);}.jimu-widget-districtlookup .esriCTResultsPanelOverrideHeight{height: calc(100% - 95px);}.jimu-widget-districtlookup .esriCTInfoContent{margin: 0px;}.jimu-widget-districtlookup .esriCTDirectionPanel{padding: 20px;}.jimu-widget-districtlookup .esriCTlistOfResultPanel{width: calc(100% - 12px); height: 36px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 35px; padding: 0px 10px 0 0; float: left;}.jimu-widget-districtlookup .esriCTItemLeftArrow{background-image: url('../images/left-arrow.png'); float: left; height: 20px; width: 10px; background-repeat: no-repeat; background-color: Gray; margin-top: 7px; margin-left: 20px;}.jimu-widget-districtlookup .esriCTItemRighttArrow{background-image: url('../images/right-arrow.png'); background-repeat: no-repeat; background-color: Gray; height: 20px; width: 10px; float: left; margin-top: 10px;}.jimu-widget-districtlookup .esriCTBackButtonText{margin-left: 51px; font-weight: bold;}.jimu-widget-districtlookup .esriCTBackButton{height: 35px; width: 100%; cursor: pointer; line-height: 35px;}.jimu-widget-districtlookup .esriCTTopBorder{border-top: 1px solid #464646;}.jimu-widget-districtlookup .esriCTMiddleBorder{border-bottom: 1px solid #D8D8D8; width: 100%; float: left; padding: 0 20px;}.jimu-widget-districtlookup .esriCTSelectLocationDiv{margin: 0px 0px 0px 10px; float: right;}.jimu-widget-districtlookup .esriCTSelectLocation{background-image: url(\"../images/select-location.png\");}.jimu-widget-districtlookup .esriCTSelectLocationActive{background-image: url(\"../images/select-location-active.png\"); background-color: #57585A;}.jimu-widget-districtlookup .esriCTImgButtons{cursor: pointer; width: 32px; height: 34px; border: 1px solid #57585A; border-radius: 4px; background-size: 20px; background-position: center center; background-repeat: no-repeat;}.jimu-widget-districtlookup .jimu-tab \x3e .jimu-viewstack{top: 0px; position: relative; height: calc(100% - 30px); -webkit-overflow-scrolling: touch; min-height: 80px; overflow: auto;}.jimu-widget-districtlookup .dijitContentPane{overflow: hidden; padding: 20px;}.jimu-widget-districtlookup .esriResultsLoading{display: none;}.jimu-widget-districtlookup .simpleDirections .esriStopsContainer{height: 0px; margin: 0px;}.jimu-widget-districtlookup .simpleDirections .esriSearchSourceContainer{display: none;}.jimu-widget-districtlookup .getDirectionsBtnContainer{display: none;}.jimu-widget-districtlookup .esriStopsTableContainer{display: none;}.jimu-widget-districtlookup .esriStopsButtons{display: none;}.jimu-widget-districtlookup .simpleDirections .savePrintBtnContainer{position: relative; top: 15px; left: 90%; margin: 0px; z-index: 1;}.jimu-launchpad-panel .jimu-widget-districtlookup .simpleDirections .savePrintBtnContainer{top: 10px;}.jimu-launchpad-panel .jimu-widget-districtlookup .simpleDirections .esriStopsGetDirectionsContainer{padding-top: 0; margin: 0px 10px;}.jimu-widget-districtlookup .simpleDirections{margin-top: 20px;}.jimu-widget-districtlookup .simpleDirections .esriResultsSummary{padding: 0 40px;}.jimu-widget-districtlookup .simpleDirections .esriResultsLoading .esriResultsContainer{display: none;}.jimu-widget-districtlookup .esriCTThumbnailContainer{margin: 2px;}.jimu-widget-districtlookup .esriCTAttachmentHeader{margin: 2px; word-wrap: break-word; color: #888888;}.jimu-widget-districtlookup .esriCTAttachmentHolder{margin: 5px; float: left; width: auto; height: 60px;}.jimu-widget-districtlookup .esriCTAttachmentImg{cursor: pointer;}.jimu-widget-districtlookup .esriCTImageLoader{cursor: default; display: block; background-position: center center; background-image: url(../images/list-loader.gif); background-repeat: no-repeat; width: 90px; height: 60px;}.jimu-widget-districtlookup .esriCTAutoHeight{height: auto;}.jimu-widget-districtlookup .esriCTNoAttachmentsFoundMsg{margin: 2px;}.jimu-widget-districtlookup .esriCTResultsPanel .editSummarySection{display: none;}.jimu-widget-districtlookup .mediaSection{padding-bottom: 10px; clear: both;}.jimu-widget-districtlookup .esriViewPopup .break{display: none;}.esriCTMapTooltip{width: 100px; word-wrap: break-word; border: 1px solid #7EABCD; background-color: white; padding: 5px; font-size: 9pt; z-index: 9999; -o-border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;}.esriRtl .jimu-widget-districtlookup .esriCTItemLeftArrow{background-image: url('../images/right-arrow.png'); float: right; margin-right: 22px;}.esriRtl .jimu-widget-districtlookup .esriCTItemRighttArrow{background-image: url('../images/left-arrow.png');}.esriRtl .jimu-widget-districtlookup .esriCTlistOfResultPanel{float: right;}.esriRtl .jimu-widget-districtlookup .simpleDirections .savePrintBtnContainer{left: 0px; right: 90%;}.esriRtl .jimu-widget-districtlookup .esriCTSearchDiv{float: right;}.esriRtl .jimu-widget-districtlookup .esriCTSelectLocationDiv{margin: 0px 0px 10px 0px; float: left;}.jimu-widget-districtlookup .esriCTInformationContentRegion:focus{outline: 2px solid #18acc2; outline-offset: -2px;}",
"*now":function(I){I(['dojo/i18n!*preload*widgets/DistrictLookup/nls/Widget*["ar","bs","ca","cs","da","de","en","el","es","et","fi","fr","he","hr","hu","id","it","ja","ko","lt","lv","nb","nl","pl","pt-br","pt-pt","ro","ru","sk","sl","sr","sv","th","tr","zh-cn","uk","vi","zh-hk","zh-tw","ROOT"]'])},"*noref":1}});
define("dojo/_base/declare jimu/BaseWidget dojo/on dojo/dom-construct dojo/dom-class dojo/query dojo/keys dojo/_base/Color dojo/_base/lang ./search jimu/portalUtils esri/layers/GraphicsLayer esri/dijit/Directions esri/units esri/layers/FeatureLayer esri/symbols/SimpleMarkerSymbol esri/symbols/SimpleLineSymbol esri/geometry/Point esri/SpatialReference esri/graphicsUtils esri/graphic esri/tasks/GeometryService dojo/Deferred dojo/dom-attr dojo/dom-geometry dojo/dom-style esri/symbols/jsonUtils esri/tasks/locator esri/geometry/webMercatorUtils esri/InfoTemplate esri/dijit/PopupTemplate esri/tasks/query esri/request esri/tasks/RelationshipQuery jimu/dijit/Message jimu/dijit/TabContainer dijit/layout/ContentPane jimu/dijit/LoadingIndicator dojo/_base/array dijit/registry jimu/LayerInfos/LayerInfos ./utils esri/renderers/jsonUtils jimu/utils dojo/_base/event".split(" "),function(I,
T,g,Q,O,M,H,F,t,k,A,m,e,d,r,y,z,h,v,L,J,U,S,N,D,G,aa,ca,Z,ea,C,da,Y,w,n,u,W,ja,ba,ka,sa,qa,ya,ra,Ea){return I([T],{baseClass:"jimu-widget-districtlookup",_highlightGraphicsLayer:null,_loading:null,_precinctLayer:null,_pollingPlaceLayer:null,_selectedPollingPlace:null,_selectedLocation:null,_precinctInfoContent:null,_pollingPlaceInfoContent:null,_precinctInfoContentDiv:null,_pollingPlaceInfoContentDiv:null,_locatorInstance:null,_mapClickHandler:null,_mapMoveHandler:null,_mapTooltip:null,_searchContainerNodeElement:null,
_directionPanel:null,_directionsWidget:null,_isValidConfig:null,_hasMulitpleSourcesInSearch:!0,_tables:[],appUtils:null,_precintRelatedRecordsPanel:null,_pollingRelatedRecordsPanel:null,_searchInstance:null,_geocoderSpatialRef:null,postMixInProperties:function(){this.nls.common={};t.mixin(this.nls.common,window.jimuNls.common)},postCreate:function(){this._tables=[];this.config.routeService&&(this.config.routeService=this._replaceRouteTaskUrlWithAppProxy(this.config.routeService));this.openAtStartAysn=
!0},startup:function(){O.add(this.domNode.parentElement,"esriCTPollingPlaceContentPanel");O.add(this.domNode.parentElement,this.baseClass);this.appConfig.portalUrl&&""!==t.trim(this.appConfig.portalUrl)?A.getPortalSelfInfo(this.appConfig.portalUrl).then(t.hitch(this,function(b){this.config.helperServices=b.helperServices;(this._isValidConfig=this._validateConfig())?(this.appUtils=new qa({map:this.map}),this._updateConfig(),O.remove(this.widgetMainNode,"esriCTHidden"),O.add(this.widgetErrorNode,"esriCTHidden"),
this._initLoading(),this._initWidgetComponents()):(O.add(this.widgetMainNode,"esriCTHidden"),O.remove(this.widgetErrorNode,"esriCTHidden"))})):(N.set(this.widgetErrorNode,"innerHTML",this.nls.invalidPortalUrlMsg),this._showMessage(this.nls.invalidPortalUrlMsg),O.add(this.widgetMainNode,"esriCTHidden"),O.remove(this.widgetErrorNode,"esriCTHidden"))},_replaceRouteTaskUrlWithAppProxy:function(b){var l=b;!window.isBuilder&&!this.appConfig.mode&&this.appConfig.appProxies&&0<this.appConfig.appProxies.length&&
ba.some(this.appConfig.appProxies,function(B){if(b===B.sourceUrl)return l=B.proxyUrl,!0});return l},_initLoading:function(){this._loading=new ja({hidden:!0});this._loading.placeAt(this.widgetMainNode);this._loading.startup()},_showMessage:function(b){(new n({message:b})).message=b},onOpen:function(){this._isValidConfig&&(this._onWindowResize(),this.config.showLocationTool||this._connectMapEventHandler());this._updateLayerFilters();ra.isAutoFocusFirstNodeWidget(this)&&ra.focusFirstFocusNode(this.domNode)},
_updateLayerFilters:function(){sa.getInstance(this.map,this.map.webMapResponse.itemInfo).then(t.hitch(this,function(b){var l;this.config&&this.config.precinctLayerInfo&&this.config.precinctLayerInfo.id&&(l=b.getLayerInfoById(this.config.precinctLayerInfo.id))&&(l=l.getFilter(),l!==this.config.precinctLayerInfo.definitionExpression&&(this.config.precinctLayerInfo.definitionExpression=l,this._precinctLayer&&this._precinctLayer.setDefinitionExpression(this.config.precinctLayerInfo.definitionExpression)));
this.config&&this.config.pollingPlaceLayerInfo&&this.config.pollingPlaceLayerInfo.id&&(b=b.getLayerInfoById(this.config.pollingPlaceLayerInfo.id))&&(l=b.getFilter(),l!==this.config.precinctLayerInfo.definitionExpression&&(this.config.pollingPlaceLayerInfo.definitionExpression=l,this._pollingPlaceLayer&&this._pollingPlaceLayer.setDefinitionExpression(this.config.pollingPlaceLayerInfo.definitionExpression)))}))},resize:function(){this._onWindowResize()},destroy:function(){this._clearResults();this.inherited(arguments)},
onClose:function(){this._isValidConfig&&(this._disconnectMapEventHandler(),this._clearResults(),this._searchInstance&&this._searchInstance.clearSearchText())},onDeActive:function(){this._isValidConfig&&this.config.showLocationTool&&this._disconnectMapEventHandler()},_validateConfig:function(){return this.config.precinctLayerInfo&&this.config.precinctLayerInfo.url?this.config.pollingPlaceLayerInfo&&this.config.pollingPlaceLayerInfo.url?!0:(N.set(this.widgetErrorNode,"innerHTML",this.nls.invalidRelatedPointLayerMsg),
this._showMessage(this.nls.invalidRelatedPointLayerMsg),!1):(N.set(this.widgetErrorNode,"innerHTML",this.nls.invalidPolygonLayerMsg),this._showMessage(this.nls.invalidPolygonLayerMsg),!1)},_updateConfig:function(){t.mixin(this.config.precinctLayerInfo,this.appUtils.getLayerDetailsFromMap(this.config.precinctLayerInfo.baseURL,this.config.precinctLayerInfo.layerId,this.config.precinctLayerInfo.id));t.mixin(this.config.pollingPlaceLayerInfo,this.appUtils.getLayerDetailsFromMap(this.config.pollingPlaceLayerInfo.baseURL,
this.config.pollingPlaceLayerInfo.layerId,this.config.pollingPlaceLayerInfo.id));this.config.highlightColor||(this.config.highlightColor="#00FFFF")},_initWidgetComponents:function(){this.config.response=this.map.webMapResponse;this._createWidgetUI();this._createSearchInstance();this._initReverseGeocoder();this._setLayers();this._mapTooltip=Q.create("div",{"class":"esriCTMapTooltip",innerHTML:this.nls.mouseOverTooltip},this.map.container);G.set(this._mapTooltip,"position","fixed");G.set(this._mapTooltip,
"display","none");this.config.showLocationTool?(this._connectSelectLocationHandler(),O.remove(this.selectLocation,"esriCTHidden")):this._connectMapEventHandler();this._onWindowResize()},_connectSelectLocationHandler:function(){g(this.selectLocation,"click",t.hitch(this,function(){this._onSelectionButtonClick()}));g(this.selectLocation,"keydown",t.hitch(this,function(b){b.keyCode!==H.ENTER&&b.keyCode!==H.SPACE||this._onSelectionButtonClick()}))},_onSelectionButtonClick:function(){O.contains(this.selectLocation,
"esriCTSelectLocationActive")?this._disconnectMapEventHandler():(O.replace(this.selectLocation,"esriCTSelectLocationActive","esriCTSelectLocation"),this._connectMapEventHandler())},_createWidgetUI:function(){var b;this.informationPanel=b=Q.create("div",{"class":"esriCTInformationContentRegion"});N.set(this.informationPanel,"tabindex",0);N.set(this.informationPanel,"role","region");this._pollingPlaceInfoContentDiv=Q.create("div",{"class":"esriCTInfoContent esriCTHidden esriCTFisrtInfoContentDiv"},
b);this._precinctInfoContentDiv=Q.create("div",{"class":"esriCTInfoContent  esriCTHidden"},b);this.config.hasOwnProperty("enableDirection")||(this.config.enableDirection=this.map.webMapResponse.itemInfo.itemData&&this.map.webMapResponse.itemInfo.itemData.applicationProperties&&this.map.webMapResponse.itemInfo.itemData.applicationProperties.viewing&&this.map.webMapResponse.itemInfo.itemData.applicationProperties.viewing.routing&&this.map.webMapResponse.itemInfo.itemData.applicationProperties.viewing.routing.enabled?
!0:!1);this.config.enableDirection?(this._directionPanel=Q.create("div",{"class":"esriCTDirectionPanel"}),this.tabContainer=new u({tabs:[{title:this.nls.informationTabTitle,content:b},{title:this.nls.directionTabTitle,content:this._directionPanel}]},this.tabContainerPanel),this.own(this.tabContainer.on("tabChanged",t.hitch(this,function(l){l===this.nls.directionTabTitle?(this._routeCalculated||this._routeSelectedLocations(),ra.initLastFocusNode(this.domNode,ra.getFocusNodesInDom(this._directionsWidget.domNode).reverse()[0])):
this._getFeatureInfoLastNode();this.id&&ka.byId(this.id)&&ka.byId(this.id).resize()}))),this.tabContainer.startup(),this._attachEventToTab()):(O.add(b,"esriCTTopBorder"),Q.place(b,this.resultsPanel,"second"));this.own(g(this.backButtonNode,"click",t.hitch(this,function(){this._backButtonClick()})));this.own(g(this.backButtonNode,"keydown",t.hitch(this,function(l){l.keyCode!==H.ENTER&&l.keyCode!==H.SPACE||this._backButtonClick()})));this._pollingRelatedRecordsPanel=Q.create("div",{"class":"esriCTRelatedRecordPanel"},
b);this._precintRelatedRecordsPanel=Q.create("div",{"class":"esriCTRelatedRecordPanel"},b)},_backButtonClick:function(){O.add(this.resultsPanel,"esriCTHidden");O.remove(this.featuresListNode,"esriCTHidden");this._clearGrahics();O.add(this._precinctInfoContentDiv,"esriCTHidden");O.add(this._pollingPlaceInfoContentDiv,"esriCTHidden");this._directionsWidget&&(this._directionsWidget.clearDirections(),this._routeCalculated=!1);this.tabContainer&&this.tabContainer.selectTab(this.nls.informationTabTitle);
this._getMainScreenLastNode();M(".esriCTMiddleBorder",this.domNode)[0].focus()},_getMainScreenLastNode:function(){var b,l;(l=M(".esriCTLastFeature",this.domNode))&&l[0]&&(b=l[0]);!b&&this.config.showLocationTool&&(b=this.selectLocation);!b&&this._searchInstance&&this._searchInstance.search&&this._searchInstance.search.submitNode&&(b=this._searchInstance.search.submitNode);ra.initLastFocusNode(this.domNode,b)},_getFeatureInfoLastNode:function(){var b,l,B=[];B=M(".esriCTPopupInfo",this.domNode);for(var E=
B.length-1;0<=E&&((l=ra.getFocusNodesInDom(B[E]))&&0<l.length&&(b=l.reverse()[0]),b||(l=M(".esriCTAttachmentImg",B[E]))&&0<l.length&&(b=l[l.length-1]),!b);E--);b||(""!==this.tabContainer&&null!==this.tabContainer&&void 0!==this.tabContainer?(B=this.tabContainer.viewStack.getSelectedLabel(),B===this.nls.informationTabTitle&&(b=this.informationPanel)):void 0===this.tabContainer&&(b=this.informationPanel));b||O.contains(this.backButtonNode,"esriCTHidden")||(b=this.backButtonNode);""!==this.tabContainer&&
null!==this.tabContainer&&void 0!==this.tabContainer&&this.tabContainer.viewStack&&(B=this.tabContainer.viewStack.getSelectedLabel(),B===this.nls.informationTabTitle&&this.tabContainer.controlNodes&&0<this.tabContainer.controlNodes.length&&(b||(b=this.tabContainer.controlNodes[0])));!b&&this.config.showLocationTool&&(b=this.selectLocation);!b&&this._searchInstance&&(b=this._searchInstance.search.submitNode);b&&ra.initLastFocusNode(this.domNode,b)},_showResultPanel:function(){O.remove(this.resultsPanel,
"esriCTHidden");this.id&&ka.byId(this.id)&&ka.byId(this.id).resize();this._resetComponents()},_hideResultPanel:function(){this.resultsPanel&&O.add(this.resultsPanel,"esriCTHidden")},_createSearchInstance:function(){this._searchInstance=new k({searchOptions:{addLayersFromMap:!1,autoNavigate:!1,autoComplete:!0,minCharacters:0,maxLocations:5,searchDelay:100,enableHighlight:!1},config:this.config,appConfig:this.appConfig,nls:this.nls,map:this.map},Q.create("div",{},this.search));this.own(this._searchInstance.on("select-result",
t.hitch(this,function(b){b.isFeatureFromMapClick=!1;this._initWorkflow(b)})));this.own(this._searchInstance.on("clear-search",t.hitch(this,function(){this._clearResults()})));this.own(this._searchInstance.on("search-results",t.hitch(this,function(){this._clearResults(!0)})));this.own(this._searchInstance.on("search-loaded",t.hitch(this,function(){setTimeout(t.hitch(this,function(){this._searchContainerNodeElement=M(".arcgisSearch .searchGroup .searchInput",this.domNode)[0];2>this._searchInstance.search.sources.length&&
(this._hasMulitpleSourcesInSearch=!1);this._getMainScreenLastNode();this._onWindowResize()}),1E3)})));this._searchInstance.startup()},_initReverseGeocoder:function(){var b;this.config.searchSourceSettings&&this.config.searchSourceSettings.sources&&(ba.some(this.config.searchSourceSettings.sources,t.hitch(this,function(l){if(l&&l.url&&"locator"===l.type)return b=l.url,!0})),b&&(this._loading.show(),Y({url:b,content:{f:"json"},handleAs:"json",callbackPrams:"callback"}).then(t.hitch(this,function(l){this._loading.hide();
this._geocoderSpatialRef=new v(l.spatialReference);this._locatorInstance=new ca(b);this.own(this._locatorInstance.on("location-to-address-complete",t.hitch(this,this._onLocationToAddressComplete)))}))))},_onLocationToAddressComplete:function(b){if(b.address&&b.address.address){if(b.address.address.Match_addr)var l=b.address.address.Match_addr;else{l="";for(var B in b.address.address)"Loc_name"!==B&&b.address.address[B]&&(l+=b.address.address[B]+" ");l=t.trim(l)}this._searchInstance&&this._searchInstance.setSearchText(l);
b=new ea;b.setContent("${Match_addr}");b.setTitle(this.nls.searchLocationTitle);this.map.infoWindow.clearFeatures();this.map.infoWindow.setTitle(this.nls.searchLocationTitle);this.map.infoWindow.setContent(l);l=this.map.toScreen(this._selectedLocation.geometry);this.map.infoWindow.show(l,this.map.getInfoWindowAnchor(l))}},showReverseGeocodedAddress:function(){this._geocoderSpatialRef&&this._locatorInstance&&this._selectedLocation&&this.getProjectedGeometry(this._selectedLocation.geometry,this._geocoderSpatialRef).then(t.hitch(this,
function(b){this._locatorInstance.locationToAddress(b,100)}))},getProjectedGeometry:function(b,l){var B=new U(this.config.helperServices.geometry.url);var E=new S;if(Z.canProject(b,l)){var P=Z.project(b,l);E.resolve(P)}else B.project([b],l,function(fa){P=fa[0];E.resolve(P)});return E.promise},_setLayers:function(){this._tables=this.map.webMapResponse.itemInfo.itemData.tables;this._highlightGraphicsLayer=new m;this.map.addLayer(this._highlightGraphicsLayer);this._precinctLayer=new r(this.config.precinctLayerInfo.url);
this.config.precinctLayerInfo.definitionExpression&&this._precinctLayer.setDefinitionExpression(this.config.precinctLayerInfo.definitionExpression);this.config.precinctLayerInfo.id&&(this._precinctLayer.id=this.config.precinctLayerInfo.id);this.config.precinctLayerInfo.renderer&&this._precinctLayer.setRenderer(ya.fromJson(this.config.precinctLayerInfo.renderer));this.config.precinctLayerInfo.popupInfo&&this._precinctLayer.setInfoTemplate(new C(this.config.precinctLayerInfo.popupInfo));this._precinctLayer.loaded?
this._precinctLayer.tableInfos=this._getRelatedTableInfo(this._precinctLayer,this.config.precinctLayerInfo):this.own(this._precinctLayer.on("load",t.hitch(this,function(){this._precinctLayer.tableInfos=this._getRelatedTableInfo(this._precinctLayer,this.config.precinctLayerInfo)})));this._pollingPlaceLayer=new r(this.config.pollingPlaceLayerInfo.url);this.config.pollingPlaceLayerInfo.definitionExpression&&this._pollingPlaceLayer.setDefinitionExpression(this.config.pollingPlaceLayerInfo.definitionExpression);
this.config.pollingPlaceLayerInfo.id&&(this._pollingPlaceLayer.id=this.config.pollingPlaceLayerInfo.id);this.config.pollingPlaceLayerInfo.renderer&&this._pollingPlaceLayer.setRenderer(ya.fromJson(this.config.pollingPlaceLayerInfo.renderer));this.config.pollingPlaceLayerInfo.popupInfo&&this._pollingPlaceLayer.setInfoTemplate(new C(this.config.pollingPlaceLayerInfo.popupInfo));this._pollingPlaceLayer.loaded?this._pollingPlaceLayer.tableInfos=this._getRelatedTableInfo(this._pollingPlaceLayer,this.config.pollingPlaceLayerInfo):
this.own(this._pollingPlaceLayer.on("load",t.hitch(this,function(){this._pollingPlaceLayer.tableInfos=this._getRelatedTableInfo(this._pollingPlaceLayer,this.config.pollingPlaceLayerInfo)})));this._updateLayerFilters()},_initWorkflow:function(b){var l;this._clearResults(!0);this._updateLayerFilters();this._selectedLocation=l=this._getSelectedFeatureFromResult(b);this._locatorInstance&&b.isFeatureFromMapClick&&this._selectedLocation&&this._selectedLocation.geometry&&this.showReverseGeocodedAddress();
l&&l.geometry&&"point"===l.geometry.type?this._pollingPlaceLayer.infoTemplate||this._precinctLayer.infoTemplate?this._getPrecinctPolygon(l):this._showMessage(this.nls.allPopupsDisabledMsg):this.map.setExtent(l.geometry.getExtent().expand(1.5));M(".firstFocusNode",this.domNode)&&M(".firstFocusNode",this.domNode)[0]&&M(".firstFocusNode",this.domNode)[0].focus()},_getSelectedFeatureFromResult:function(b){if(b)if(b.feature)var l=b.feature;else b.result&&b.result.feature&&(l=b.result.feature);return l},
_clearResults:function(b){this._highlightGraphicsLayer&&this._highlightGraphicsLayer.clear();this.featuresListNode&&!O.contains(this.featuresListNode,"esriCTHidden")&&O.add(this.featuresListNode,"esriCTHidden");this.resultsPanel&&!O.contains(this.resultsPanel,"esriCTHidden")&&O.remove(this.resultsPanel,"esriCTHidden");this._directionsWidget&&(this._directionsWidget.clearDirections(),this._routeCalculated=!1);this.tabContainer&&this.tabContainer.selectTab(this.nls.informationTabTitle);this._hideResultPanel();
this._precinctInfoContentDiv&&O.add(this._precinctInfoContentDiv,"esriCTHidden");this._pollingPlaceInfoContentDiv&&O.add(this._pollingPlaceInfoContentDiv,"esriCTHidden");this._selectedPollingPlace=this._selectedLocation=null;this._clearFeatureList();!b&&this.map&&this.map.infoWindow&&this.map.infoWindow.hide();this._pollingRelatedRecordsPanel&&Q.empty(this._pollingRelatedRecordsPanel);this._precintRelatedRecordsPanel&&Q.empty(this._precintRelatedRecordsPanel);this._getMainScreenLastNode()},_connectMapEventHandler:function(){this._mapClickHandler||
(this._disableWebMapPopup(),this._mapClickHandler=this.own(this.map.on("click",t.hitch(this,this._onMapClick)))[0],"ontouchstart"in document.documentElement?G.set(this._mapTooltip,"display","none"):(this._mapMoveHandler=this.own(this.map.on("mouse-move",t.hitch(this,this._onMapMouseMove)))[0],this.own(this.map.on("mouse-out",t.hitch(this,function(){G.set(this._mapTooltip,"display","none")})))))},_onMapClick:function(b){this.config.showLocationTool&&this._disconnectMapEventHandler();this.map.infoWindow.hide();
this._searchInstance&&this._searchInstance.clearSearchText();this._initWorkflow({feature:new J(b.mapPoint),isFeatureFromMapClick:!0})},_onMapMouseMove:function(b){if(b.clientX||b.pageY){var l=b.clientX;b=b.clientY}else l=b.clientX+document.body.scrollLeft-document.body.clientLeft,b=b.clientY+document.body.scrollTop-document.body.clientTop;G.set(this._mapTooltip,"display","none");G.set(this._mapTooltip,{left:l+15+"px",top:b+"px"});G.set(this._mapTooltip,"display","")},_disconnectMapEventHandler:function(){this._enableWebMapPopup();
this.config.showLocationTool&&O.replace(this.selectLocation,"esriCTSelectLocation","esriCTSelectLocationActive");this._mapClickHandler&&(this._mapClickHandler.remove(),this._mapClickHandler=null);this._mapMoveHandler&&(this._mapMoveHandler.remove(),this._mapMoveHandler=null,this._mapTooltip.style.display="none")},_enableWebMapPopup:function(){this.map&&this.map.setInfoWindowOnClick(!0)},_disableWebMapPopup:function(){this.map&&this.map.setInfoWindowOnClick(!1)},_getPrecinctPolygon:function(b){if(b&&
b.geometry){this._loading.show();var l=new da;l.outFields=["*"];l.returnGeometry=!0;l.geometry=b.geometry;this._precinctLayer.queryFeatures(l,t.hitch(this,function(B){var E;if(B&&B.features&&0<B.features.length)if(1<B.features.length)for(this._clearFeatureList(),this._clearGrahics(),O.remove(this.featuresListNode,"esriCTHidden"),O.remove(this.backButtonNode,"esriCTHidden"),O.add(this.resultsPanel,"esriCTResultsPanelOverrideHeight"),this.stackedPolygons=B.features,E=0;E<B.features.length;E++){var P=
Q.create("div",{"class":"esriCTMiddleBorder",tabindex:"0","aria-label":ra.stripHTML(B.features[E].getTitle()||""),role:"button"},this.featuresListNode);Q.create("div",{innerHTML:B.features[E].getTitle(),title:ra.stripHTML(B.features[E].getTitle()||""),"class":"esriCTlistOfResultPanel"},P);Q.create("div",{"class":"esriCTItemRighttArrow"},P);N.set(P,"index",E);this.own(g(P,"click",t.hitch(this,this.rowClicked,!1)));this.own(g(P,"keydown",t.hitch(this,this.rowClicked,!0)));B.features.length-1===E&&(O.add(P,
"esriCTLastFeature"),ra.initLastFocusNode(this.domNode,P));this._loading.hide()}else O.add(this.backButtonNode,"esriCTHidden"),O.remove(this.resultsPanel,"esriCTResultsPanelOverrideHeight"),this._showSelectedFeature(B.features[0]),M(".firstFocusNode",this.domNode)&&M(".firstFocusNode",this.domNode)[0]&&M(".firstFocusNode",this.domNode)[0].focus();else this._showNoPrecinctFoundMsg(),this._loading.hide();this._highlightSelectedLocation(this._selectedLocation)}),t.hitch(this,function(){this._loading.hide()}))}else this._showNoPrecinctFoundMsg(),
this._loading.hide()},_showNoPrecinctFoundMsg:function(){var b=this.nls.noPrecinctFoundMsg;this.config.hasOwnProperty("errorMessage")&&(b=ra.sanitizeHTML(this.config.errorMessage));b&&this._showMessage(b)},rowClicked:function(b,l){b&&l.keyCode!==H.ENTER&&l.keyCode!==H.SPACE||(b=parseInt(N.get(l.currentTarget,"index"),10),this._showSelectedFeature(this.stackedPolygons[b]))},_showSelectedFeature:function(b){O.add(this.featuresListNode,"esriCTHidden");O.remove(this.resultsPanel,"esriCTHidden");this._highlightPrecinctPolygon(b);
this._precinctInfoContent&&(Q.destroy(this._precinctInfoContent.domNode),Q.empty(this._precinctInfoContentDiv));this._pollingPlaceInfoContent&&(Q.destroy(this._pollingPlaceInfoContent.domNode),Q.empty(this._pollingPlaceInfoContentDiv));if(this._precinctLayer.infoTemplate){O.remove(this._precinctInfoContentDiv,"esriCTHidden");this._precinctInfoContent=new W({"class":"esriCTPopupInfo"},Q.create("div",{},this._precinctInfoContentDiv));this._precinctInfoContent.startup();var l=b.getContent();var B=ka.byId(l.id);
this.own(g(B,"content-update",t.hitch(this,function(){this._getFeatureInfoLastNode()})));this._precinctInfoContent.set("content",l);this.id&&ka.byId(this.id)&&ka.byId(this.id).resize();this._precinctLayer.hasAttachments&&this.config.precinctLayerInfo.popupInfo.showAttachments&&(B=M(".attachmentsSection",this._precinctInfoContentDiv),0<B.length&&(B=B[0],O.remove(B,"hidden")),this._showAttachments(b,B,this._precinctLayer))}this._getRelatedPollingPlaces(b);this._getRelatedRecords(b,!1)},_getRelatedTableInfo:function(b,
l){var B=[];b&&ba.forEach(b.relationships,t.hitch(this,function(E){ba.forEach(this._tables,t.hitch(this,function(P,fa){P.url.replace(/.*?:\/\//g,"")===(l.baseURL+E.relatedTableId).replace(/.*?:\/\//g,"")&&P.popupInfo&&(P.relationshipIds||(P.relationshipIds={}),P.relationshipIds[b.id]=E.id,B.push(fa))}))}));return B},_getRelatedRecords:function(b,l){var B;if(b){if(l){l=this._pollingPlaceLayer.tableInfos;var E=this._pollingPlaceLayer;var P=this._pollingRelatedRecordsPanel}else l=this._precinctLayer.tableInfos,
E=this._precinctLayer,P=this._precintRelatedRecordsPanel;P&&Q.empty(P);ba.forEach(l,t.hitch(this,function(fa){B=b.attributes[E.objectIdField];this._queryRelatedRecords(E,this._tables[fa],B,P)}))}},_queryRelatedRecords:function(b,l,B,E){if(l&&b){var P=new w;P.objectIds=[parseInt(B,10)];P.outFields=["*"];P.relationshipId=l.relationshipIds[b.id];l.layerDefinition&&l.layerDefinition.definitionExpression&&(P.where=l.layerDefinition.definitionExpression);b.queryRelatedFeatures(P,t.hitch(this,function(fa){fa=
fa[B];ba.forEach(fa?fa.features:[],t.hitch(this,function(la){la.setInfoTemplate(new C(l.popupInfo));this._showPopupInfo(la,E)}))}))}},_showPopupInfo:function(b,l){if(b){Q.create("div",{},l);l=new W({"class":"esriCTPopupInfo"},void 0);l.startup();var B=b.getContent();b=ka.byId(B.id);this.own(g(b,"content-update",t.hitch(this,function(){this._getFeatureInfoLastNode()})));l.set("content",B)}},_clearFeatureList:function(){this.featuresListNode&&(this.stackedPolygons=[],Q.empty(this.featuresListNode))},
_clearGrahics:function(){this._highlightGraphicsLayer&&this._highlightGraphicsLayer.clear()},_getRelatedPollingPlaces:function(b){var l=new w;l.outFields=[this._pollingPlaceLayer.objectIdField];l.returnGeometry=!0;l.relationshipId=this.config.pollingPlaceLayerInfo.relationShipId;l.definitionExpression=this.config.pollingPlaceLayerInfo.definitionExpression;l.objectIds=[b.attributes[this._precinctLayer.objectIdField]];this._precinctLayer.queryRelatedFeatures(l,t.hitch(this,function(B){B=(B=B[b.attributes[this._precinctLayer.objectIdField]])?
B.features:[];0<B.length?(B=B[0].attributes[this._pollingPlaceLayer.objectIdField],this._getPollingPlacePoint(B)):(this._zoomToResult(),this._showMessage(this.nls.noPollingPlaceFoundMsg),O.add(this._pollingPlaceInfoContentDiv,"esriCTHidden"),this._selectedPollingPlace=null,this._loading.hide())}),t.hitch(this,function(){this._zoomToResult();this._loading.hide()}))},_getPollingPlacePoint:function(b){var l=new da;l.outFields=["*"];l.returnGeometry=!0;l.outSpatialReference=this.map.spatialReference;
l.objectIds=[b];this._pollingPlaceLayer.queryFeatures(l,t.hitch(this,function(B){if(B&&B.features&&0<B.features.length){this._highlightPollingPlacePoint(B.features[0]);this._selectedPollingPlace=B.features[0];if(this._pollingPlaceLayer.infoTemplate){O.remove(this._pollingPlaceInfoContentDiv,"esriCTHidden");B.features[0].setInfoTemplate(this._pollingPlaceLayer.infoTemplate);this._pollingPlaceInfoContent=new W({"class":"esriCTPopupInfo"},Q.create("div",{},this._pollingPlaceInfoContentDiv));this._pollingPlaceInfoContent.startup();
var E=B.features[0].getContent();var P=ka.byId(E.id);g(P,"content-update",t.hitch(this,function(){this._getFeatureInfoLastNode()}));this._pollingPlaceInfoContent.set("content",E);this._pollingPlaceLayer.hasAttachments&&this.config.pollingPlaceLayerInfo.popupInfo.showAttachments&&(P=M(".attachmentsSection",this._pollingPlaceInfoContentDiv)[0],O.remove(P,"hidden"),this._showAttachments(B.features[0],P,this._pollingPlaceLayer));this._getRelatedRecords(B.features[0],!0)}(this._pollingPlaceLayer.infoTemplate||
this._precinctLayer.infoTemplate)&&this._showResultPanel()}else this._showMessage(this.nls.noPollingPlaceFoundMsg),O.add(this._pollingPlaceInfoContentDiv,"esriCTHidden"),this._selectedPollingPlace=null,this._loading.hide();this._zoomToResult();this._loading.hide()}),t.hitch(this,function(){this._zoomToResult();this._loading.hide()}))},_highlightSelectedLocation:function(b){if(b){var l=aa.fromJson(this.config.symbols.graphicLocationSymbol);this._selectedLocation=new J(b.geometry,l);this._highlightGraphicsLayer.add(this._selectedLocation)}},
_highlightPrecinctPolygon:function(b){var l=aa.fromJson(this.config.symbols.precinctSymbol);this._highlightGraphicsLayer.add(new J(b.geometry,l))},_highlightPollingPlacePoint:function(b){b=this._getPointSymbol(b,this._pollingPlaceLayer);this._highlightGraphicsLayer.add(b)},_zoomToResult:function(){var b;this._highlightGraphicsLayer&&this._highlightGraphicsLayer.graphics&&0<this._highlightGraphicsLayer.graphics.length&&(b=L.graphicsExtent(this._highlightGraphicsLayer.graphics))&&ra.zoomToExtent(this.map,
b.expand(1.5))},_getPointSymbol:function(b,l){var B,E;var P=!1;var fa=new y(y.STYLE_SQUARE,null,new z(z.STYLE_SOLID,new F(this.config.highlightColor),3));fa.setColor(null);fa.size=30;if(l&&l.renderer)if(l.renderer.symbol)P=!0,fa=this._updatePointSymbolProperties(fa,l.renderer.symbol);else if(l.renderer.infos&&0<l.renderer.infos.length){for(E=0;E<l.renderer.infos.length;E++){l.typeIdField?B=b.attributes[l.typeIdField]:l.renderer.attributeField&&(B=b.attributes[l.renderer.attributeField]);var la=l.renderer.infos[E].value;
void 0!==B&&null!==B&&""!==B&&void 0!==la&&null!==la&&""!==la&&B.toString()===la.toString()&&(P=!0,fa=this._updatePointSymbolProperties(fa,l.renderer.infos[E].symbol))}!P&&l.renderer.defaultSymbol&&(P=!0,fa=this._updatePointSymbolProperties(fa,l.renderer.defaultSymbol))}l=new h(b.geometry.x,b.geometry.y,new v({wkid:b.geometry.spatialReference.wkid}));return new J(l,fa,b.attributes)},_updatePointSymbolProperties:function(b,l){if(l.hasOwnProperty("height")&&l.hasOwnProperty("width")){var B=l.height;
var E=l.width;B=(B>E?B:E)+10;b.size=B}l.hasOwnProperty("size")&&(!B||B<l.size)&&(b.size=l.size+10);l.hasOwnProperty("xoffset")&&(b.xoffset=l.xoffset);l.hasOwnProperty("yoffset")&&(b.yoffset=l.yoffset);return b},_showAttachments:function(b,l,B){var E,P,fa,la,va;b=b.attributes[B.objectIdField];Q.empty(l);B.queryAttachmentInfos(b,t.hitch(this,function(oa){if(oa&&0<oa.length){Q.create("div",{innerHTML:this.nls.attachmentHeader,"class":"esriCTAttachmentHeader"},l);E=Q.create("div",{"class":"esriCTThumbnailContainer"},
l);for(va=0;va<oa.length;va++)la=this.folderUrl+"/images/no-attachment.png",-1<oa[va].contentType.indexOf("image")&&(la=oa[va].url),fa=Q.create("span",{"class":"esriCTAttachmentHolder col"},E),O.add(fa,"esriCTImageLoader"),P=Q.create("img",{alt:oa[va].url,"class":"esriCTAttachmentImg esriCTAutoHeight",src:la,role:"button","aria-label":oa[va].name||oa[va].url,tabindex:"0"},fa),this.own(g(P,"load",t.hitch(this,this._onImageLoad))),this.own(g(P,"click",t.hitch(this,this._displayImageAttachments))),this.own(g(P,
"keydown",t.hitch(this,this._imageKeyDown)));this._getFeatureInfoLastNode()}ka.byId(this.domNode.parentElement.id).resize()}))},_imageKeyDown:function(b){b.keyCode!==H.ENTER&&b.keyCode!==H.SPACE||this._displayImageAttachments(b)},_setImageDimensions:function(b){var l=b.parentElement;b&&0<b.offsetHeight&&(N.set(b,"originalHeight",b.offsetHeight),G.set(b,"maxHeight",b.offsetHeight+"px"),G.set(b,"maxWidth",b.offsetWidth+"px"));var B=parseFloat(N.get(b,"originalHeight"));0<l.offsetHeight&&(l.offsetHeight<
b.offsetHeight||B>l.offsetHeight)&&(B=b.offsetWidth/b.offsetHeight,l=l.offsetHeight-2,B=Math.floor(l*B),O.remove(b,"esriCTAutoHeight"),G.set(b,"width",B+"px"),G.set(b,"height",l+"px"))},_displayImageAttachments:function(b){window.open(b.target.alt)},_onImageLoad:function(b){O.remove(b.target.parentNode,"esriCTImageLoader");this._setImageDimensions(b.target,!0)},_routeSelectedLocations:function(){var b=[],l={};this._directionsWidget||(l={map:this.map,directionsLengthUnits:d[this.config.directionLengthUnit.value],
showTrafficOption:!1,dragging:!1,routeSymbol:aa.fromJson(this.config.symbols.routeSymbol),routeTaskUrl:this.config.routeService},this._directionsWidget=new e(l,Q.create("div",{},this._directionPanel)),this._directionsWidget.startup());this.own(this._directionsWidget.on("directions-finish",t.hitch(this,function(){this.id&&ka.byId(this.id)&&ka.byId(this.id).resize();ra.initLastFocusNode(this.domNode,ra.getFocusNodesInDom(this._directionsWidget.domNode).reverse()[0]);this._loading.hide()})));this._directionsWidget.clearDirections();
this._selectedLocation&&this._selectedPollingPlace&&(this._loading.show(),b.push(this._selectedLocation),b.push(this._selectedPollingPlace),this._directionsWidget.updateStops(b).then(t.hitch(this,function(){this._directionsWidget.getDirections();this._routeCalculated=!0}),t.hitch(this,function(){this._showMessage(this.nls.failedToGenerateRouteMsg);this._loading.hide()})))},_onWindowResize:function(){this._windowResizeTimer&&clearTimeout(this._windowResizeTimer);this._windowResizeTimer=setTimeout(t.hitch(this,
this._resetComponents),500)},_resetComponents:function(){var b;var l=[];var B=M(".arcgisSearch .searchGroup",this.domNode)[0];l=M(".jimu-tab \x3e .jimu-viewstack",this.domNode);l.push(this.domNode);ba.forEach(l,t.hitch(this,function(E){G.set(E,"-webkit-overflow-scrolling","auto")}));this._searchContainerNodeElement||(this._searchContainerNodeElement=M(".arcgisSearch .searchGroup .searchInput",this.domNode)[0]);this.widgetMainNode&&this._searchContainerNodeElement&&(b=D.position(this.widgetMainNode))&&
b.w&&(b=b.w-144,this._hasMulitpleSourcesInSearch||(b+=32),0<b&&(this.config.showLocationTool&&(b-=45),this._searchContainerNodeElement.style.setProperty("width",b+"px","important"),B&&B.style.setProperty("max-width","100%","important")));0<l.length&&setTimeout(t.hitch(this,function(){ba.forEach(l,t.hitch(this,function(E){G.set(E,"-webkit-overflow-scrolling","touch")}))}),500)},_attachEventToTab:function(){""!==this.tabContainer&&null!==this.tabContainer&&void 0!==this.tabContainer&&this.tabContainer.controlNodes&&
1<this.tabContainer.controlNodes.length&&this.own(g(this.tabContainer.controlNodes[1],"keydown",t.hitch(this,function(b){b.keyCode===H.TAB&&!b.shiftKey&&this.tabContainer.viewStack&&this.tabContainer.viewStack.getSelectedLabel()===this.nls.informationTabTitle&&(Ea.stop(b),ra.focusFirstFocusNode(this.domNode))})))}})});