{"version":3,"file":"esri-leaflet-geocoder.js","sources":["../src/helper.js","../src/Tasks/Geocode.js","../src/Tasks/ReverseGeocode.js","../src/Tasks/Suggest.js","../src/Services/Geocode.js","../src/Classes/GeosearchCore.js","../src/Providers/ArcgisOnlineGeocoder.js","../src/Controls/Geosearch.js","../src/Providers/FeatureLayer.js","../src/Providers/MapService.js","../src/Providers/GeocodeService.js"],"sourcesContent":["export var WorldGeocodingServiceUrl = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/';\r\n","import {\r\n latLng,\r\n latLngBounds\r\n} from 'leaflet';\r\nimport { Task, Util as EsriUtil } from 'esri-leaflet';\r\nimport { WorldGeocodingServiceUrl } from '../helper';\r\n\r\nexport var Geocode = Task.extend({\r\n path: 'findAddressCandidates',\r\n\r\n params: {\r\n outSr: 4326,\r\n forStorage: false,\r\n outFields: '*',\r\n maxLocations: 20\r\n },\r\n\r\n setters: {\r\n 'address': 'address',\r\n 'neighborhood': 'neighborhood',\r\n 'city': 'city',\r\n 'subregion': 'subregion',\r\n 'region': 'region',\r\n 'postal': 'postal',\r\n 'country': 'country',\r\n 'text': 'singleLine',\r\n 'category': 'category',\r\n 'token': 'token',\r\n 'key': 'magicKey',\r\n 'fields': 'outFields',\r\n 'forStorage': 'forStorage',\r\n 'maxLocations': 'maxLocations',\r\n // World Geocoding Service (only works with singleLine)\r\n 'countries': 'sourceCountry'\r\n },\r\n\r\n initialize: function (options) {\r\n options = options || {};\r\n options.url = options.url || WorldGeocodingServiceUrl;\r\n Task.prototype.initialize.call(this, options);\r\n },\r\n\r\n within: function (bounds) {\r\n bounds = latLngBounds(bounds);\r\n this.params.searchExtent = EsriUtil.boundsToExtent(bounds);\r\n return this;\r\n },\r\n\r\n nearby: function (coords, radius) {\r\n var centroid = latLng(coords);\r\n this.params.location = centroid.lng + ',' + centroid.lat;\r\n if (radius) {\r\n this.params.distance = Math.min(Math.max(radius, 2000), 50000);\r\n }\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n if (this.options.customParam) {\r\n this.params[this.options.customParam] = this.params.singleLine;\r\n delete this.params.singleLine;\r\n }\r\n\r\n return this.request(function (error, response) {\r\n var processor = this._processGeocoderResponse;\r\n var results = (!error) ? processor(response) : undefined;\r\n callback.call(context, error, { results: results }, response);\r\n }, this);\r\n },\r\n\r\n _processGeocoderResponse: function (response) {\r\n var results = [];\r\n\r\n for (var i = 0; i < response.candidates.length; i++) {\r\n var candidate = response.candidates[i];\r\n if (candidate.extent) {\r\n var bounds = EsriUtil.extentToBounds(candidate.extent);\r\n }\r\n\r\n results.push({\r\n text: candidate.address,\r\n bounds: bounds,\r\n score: candidate.score,\r\n latlng: latLng(candidate.location.y, candidate.location.x),\r\n properties: candidate.attributes\r\n });\r\n }\r\n return results;\r\n }\r\n});\r\n\r\nexport function geocode (options) {\r\n return new Geocode(options);\r\n}\r\n\r\nexport default geocode;\r\n","import { latLng } from 'leaflet';\r\nimport { Task } from 'esri-leaflet';\r\nimport { WorldGeocodingServiceUrl } from '../helper';\r\n\r\nexport var ReverseGeocode = Task.extend({\r\n path: 'reverseGeocode',\r\n\r\n params: {\r\n outSR: 4326,\r\n returnIntersection: false\r\n },\r\n\r\n setters: {\r\n 'distance': 'distance',\r\n 'language': 'langCode',\r\n 'intersection': 'returnIntersection'\r\n },\r\n\r\n initialize: function (options) {\r\n options = options || {};\r\n options.url = options.url || WorldGeocodingServiceUrl;\r\n Task.prototype.initialize.call(this, options);\r\n },\r\n\r\n latlng: function (coords) {\r\n var centroid = latLng(coords);\r\n this.params.location = centroid.lng + ',' + centroid.lat;\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n return this.request(function (error, response) {\r\n var result;\r\n\r\n if (!error) {\r\n result = {\r\n latlng: latLng(response.location.y, response.location.x),\r\n address: response.address\r\n };\r\n } else {\r\n result = undefined;\r\n }\r\n\r\n callback.call(context, error, result, response);\r\n }, this);\r\n }\r\n});\r\n\r\nexport function reverseGeocode (options) {\r\n return new ReverseGeocode(options);\r\n}\r\n\r\nexport default reverseGeocode;\r\n","import {\r\n latLng,\r\n latLngBounds\r\n} from 'leaflet';\r\nimport { Task, Util as EsriUtil } from 'esri-leaflet';\r\nimport { WorldGeocodingServiceUrl } from '../helper';\r\n\r\nexport var Suggest = Task.extend({\r\n path: 'suggest',\r\n\r\n params: {},\r\n\r\n setters: {\r\n text: 'text',\r\n category: 'category',\r\n countries: 'countryCode',\r\n maxSuggestions: 'maxSuggestions'\r\n },\r\n\r\n initialize: function (options) {\r\n options = options || {};\r\n if (!options.url) {\r\n options.url = WorldGeocodingServiceUrl;\r\n options.supportsSuggest = true;\r\n }\r\n Task.prototype.initialize.call(this, options);\r\n },\r\n\r\n within: function (bounds) {\r\n bounds = latLngBounds(bounds);\r\n bounds = bounds.pad(0.5);\r\n var center = bounds.getCenter();\r\n var ne = bounds.getNorthWest();\r\n this.params.location = center.lng + ',' + center.lat;\r\n this.params.distance = Math.min(Math.max(center.distanceTo(ne), 2000), 50000);\r\n this.params.searchExtent = EsriUtil.boundsToExtent(bounds);\r\n return this;\r\n },\r\n\r\n nearby: function (coords, radius) {\r\n var centroid = latLng(coords);\r\n this.params.location = centroid.lng + ',' + centroid.lat;\r\n if (radius) {\r\n this.params.distance = Math.min(Math.max(radius, 2000), 50000);\r\n }\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n if (this.options.supportsSuggest) {\r\n return this.request(function (error, response) {\r\n callback.call(context, error, response, response);\r\n }, this);\r\n } else {\r\n console.warn('this geocoding service does not support asking for suggestions');\r\n }\r\n }\r\n\r\n});\r\n\r\nexport function suggest (options) {\r\n return new Suggest(options);\r\n}\r\n\r\nexport default suggest;\r\n","import { Service } from 'esri-leaflet';\r\nimport { WorldGeocodingServiceUrl } from '../helper';\r\nimport geocode from '../Tasks/Geocode';\r\nimport reverseGeocode from '../Tasks/ReverseGeocode';\r\nimport suggest from '../Tasks/Suggest';\r\n\r\nexport var GeocodeService = Service.extend({\r\n initialize: function (options) {\r\n options = options || {};\r\n if (options.url) {\r\n Service.prototype.initialize.call(this, options);\r\n this._confirmSuggestSupport();\r\n } else {\r\n options.url = WorldGeocodingServiceUrl;\r\n options.supportsSuggest = true;\r\n Service.prototype.initialize.call(this, options);\r\n }\r\n },\r\n\r\n geocode: function () {\r\n return geocode(this);\r\n },\r\n\r\n reverse: function () {\r\n return reverseGeocode(this);\r\n },\r\n\r\n suggest: function () {\r\n // requires either the Esri World Geocoding Service or a <10.3 ArcGIS Server Geocoding Service that supports suggest.\r\n return suggest(this);\r\n },\r\n\r\n _confirmSuggestSupport: function () {\r\n this.metadata(function (error, response) {\r\n if (error) { return; }\r\n // pre 10.3 geocoding services dont list capabilities (and dont support maxLocations)\r\n // only SOME individual services have been configured to support asking for suggestions\r\n if (!response.capabilities) {\r\n this.options.supportsSuggest = false;\r\n } else if (response.capabilities.indexOf('Suggest') > -1) {\r\n this.options.supportsSuggest = true;\r\n } else {\r\n this.options.supportsSuggest = false;\r\n }\r\n // whether the service supports suggest or not, utilize the metadata response to determine the appropriate parameter name for single line geocoding requests\r\n this.options.customParam = response.singleLineAddressField.name;\r\n }, this);\r\n }\r\n});\r\n\r\nexport function geocodeService (options) {\r\n return new GeocodeService(options);\r\n}\r\n\r\nexport default geocodeService;\r\n","import { Evented, Util, latLngBounds } from 'leaflet';\r\n\r\nexport var GeosearchCore = Evented.extend({\r\n\r\n options: {\r\n zoomToResult: true,\r\n useMapBounds: 12,\r\n searchBounds: null\r\n },\r\n\r\n initialize: function (control, options) {\r\n Util.setOptions(this, options);\r\n this._control = control;\r\n\r\n if (!options || !options.providers || !options.providers.length) {\r\n throw new Error('You must specify at least one provider');\r\n }\r\n\r\n this._providers = options.providers;\r\n },\r\n\r\n _geocode: function (text, key, provider) {\r\n var activeRequests = 0;\r\n var allResults = [];\r\n var bounds;\r\n\r\n var callback = Util.bind(function (error, results) {\r\n activeRequests--;\r\n if (error) {\r\n return;\r\n }\r\n\r\n if (results) {\r\n allResults = allResults.concat(results);\r\n }\r\n\r\n if (activeRequests <= 0) {\r\n bounds = this._boundsFromResults(allResults);\r\n\r\n this.fire('results', {\r\n results: allResults,\r\n bounds: bounds,\r\n latlng: (bounds) ? bounds.getCenter() : undefined,\r\n text: text\r\n }, true);\r\n\r\n if (this.options.zoomToResult && bounds) {\r\n this._control._map.fitBounds(bounds);\r\n }\r\n\r\n this.fire('load');\r\n }\r\n }, this);\r\n\r\n if (key) {\r\n activeRequests++;\r\n provider.results(text, key, this._searchBounds(), callback);\r\n } else {\r\n for (var i = 0; i < this._providers.length; i++) {\r\n activeRequests++;\r\n this._providers[i].results(text, key, this._searchBounds(), callback);\r\n }\r\n }\r\n },\r\n\r\n _suggest: function (text) {\r\n var activeRequests = this._providers.length;\r\n var suggestionsLength = 0;\r\n\r\n var createCallback = Util.bind(function (text, provider) {\r\n return Util.bind(function (error, suggestions) {\r\n activeRequests = activeRequests - 1;\r\n suggestionsLength += suggestions.length;\r\n\r\n if (error) {\r\n // an error occurred for one of the providers' suggest requests\r\n this._control._clearProviderSuggestions(provider);\r\n\r\n // perform additional cleanup when all requests are finished\r\n this._control._finalizeSuggestions(activeRequests, suggestionsLength);\r\n\r\n return;\r\n }\r\n\r\n if (suggestions.length) {\r\n for (var i = 0; i < suggestions.length; i++) {\r\n suggestions[i].provider = provider;\r\n }\r\n } else {\r\n // we still need to update the UI\r\n this._control._renderSuggestions(suggestions);\r\n }\r\n\r\n if (provider._lastRender !== text) {\r\n this._control._clearProviderSuggestions(provider);\r\n }\r\n\r\n if (suggestions.length && this._control._input.value === text) {\r\n provider._lastRender = text;\r\n this._control._renderSuggestions(suggestions);\r\n }\r\n\r\n // perform additional cleanup when all requests are finished\r\n this._control._finalizeSuggestions(activeRequests, suggestionsLength);\r\n }, this);\r\n }, this);\r\n\r\n this._pendingSuggestions = [];\r\n\r\n for (var i = 0; i < this._providers.length; i++) {\r\n var provider = this._providers[i];\r\n var request = provider.suggestions(text, this._searchBounds(), createCallback(text, provider));\r\n this._pendingSuggestions.push(request);\r\n }\r\n },\r\n\r\n _searchBounds: function () {\r\n if (this.options.searchBounds !== null) {\r\n return this.options.searchBounds;\r\n }\r\n\r\n if (this.options.useMapBounds === false) {\r\n return null;\r\n }\r\n\r\n if (this.options.useMapBounds === true) {\r\n return this._control._map.getBounds();\r\n }\r\n\r\n if (this.options.useMapBounds <= this._control._map.getZoom()) {\r\n return this._control._map.getBounds();\r\n }\r\n\r\n return null;\r\n },\r\n\r\n _boundsFromResults: function (results) {\r\n if (!results.length) {\r\n return;\r\n }\r\n\r\n var nullIsland = latLngBounds([0, 0], [0, 0]);\r\n var resultBounds = [];\r\n var resultLatlngs = [];\r\n\r\n // collect the bounds and center of each result\r\n for (var i = results.length - 1; i >= 0; i--) {\r\n var result = results[i];\r\n\r\n resultLatlngs.push(result.latlng);\r\n\r\n // make sure bounds are valid and not 0,0. sometimes bounds are incorrect or not present\r\n if (result.bounds && result.bounds.isValid() && !result.bounds.equals(nullIsland)) {\r\n resultBounds.push(result.bounds);\r\n }\r\n }\r\n\r\n // form a bounds object containing all center points\r\n var bounds = latLngBounds(resultLatlngs);\r\n\r\n // and extend it to contain all bounds objects\r\n for (var j = 0; j < resultBounds.length; j++) {\r\n bounds.extend(resultBounds[j]);\r\n }\r\n\r\n return bounds;\r\n },\r\n\r\n _getAttribution: function () {\r\n var attribs = [];\r\n var providers = this._providers;\r\n\r\n for (var i = 0; i < providers.length; i++) {\r\n if (providers[i].options.attribution) {\r\n attribs.push(providers[i].options.attribution);\r\n }\r\n }\r\n\r\n return attribs.join(', ');\r\n }\r\n\r\n});\r\n\r\nexport function geosearchCore (control, options) {\r\n return new GeosearchCore(control, options);\r\n}\r\n\r\nexport default geosearchCore;\r\n","import { GeocodeService } from '../Services/Geocode';\r\n\r\nexport var ArcgisOnlineProvider = GeocodeService.extend({\r\n options: {\r\n label: 'Places and Addresses',\r\n maxResults: 5\r\n },\r\n\r\n suggestions: function (text, bounds, callback) {\r\n var request = this.suggest().text(text);\r\n\r\n if (bounds) {\r\n request.within(bounds);\r\n }\r\n\r\n if (this.options.nearby) {\r\n // \"distance\"/\"radius\" is not supported by the ArcGIS Online Geocoder,\r\n // so that is intentionally not passed here:\r\n request.nearby(this.options.nearby);\r\n }\r\n\r\n if (this.options.countries) {\r\n request.countries(this.options.countries);\r\n }\r\n\r\n if (this.options.categories) {\r\n request.category(this.options.categories);\r\n }\r\n\r\n // 15 is the maximum number of suggestions that can be returned\r\n request.maxSuggestions(this.options.maxResults);\r\n\r\n return request.run(function (error, results, response) {\r\n var suggestions = [];\r\n if (!error) {\r\n while (response.suggestions.length && suggestions.length <= (this.options.maxResults - 1)) {\r\n var suggestion = response.suggestions.shift();\r\n if (!suggestion.isCollection) {\r\n suggestions.push({\r\n text: suggestion.text,\r\n unformattedText: suggestion.text,\r\n magicKey: suggestion.magicKey\r\n });\r\n }\r\n }\r\n }\r\n callback(error, suggestions);\r\n }, this);\r\n },\r\n\r\n results: function (text, key, bounds, callback) {\r\n var request = this.geocode().text(text);\r\n\r\n if (key) {\r\n request.key(key);\r\n }\r\n // in the future Address/StreetName geocoding requests that include a magicKey will always only return one match\r\n request.maxLocations(this.options.maxResults);\r\n\r\n if (bounds) {\r\n request.within(bounds);\r\n }\r\n\r\n if (this.options.forStorage) {\r\n request.forStorage(true);\r\n }\r\n\r\n if (this.options.nearby) {\r\n // \"distance\"/\"radius\" is not supported by the ArcGIS Online Geocoder,\r\n // so that is intentionally not passed here:\r\n request.nearby(this.options.nearby);\r\n }\r\n\r\n if (this.options.countries) {\r\n request.countries(this.options.countries);\r\n }\r\n\r\n if (this.options.categories) {\r\n request.category(this.options.categories);\r\n }\r\n\r\n return request.run(function (error, response) {\r\n callback(error, response.results);\r\n }, this);\r\n }\r\n});\r\n\r\nexport function arcgisOnlineProvider (options) {\r\n return new ArcgisOnlineProvider(options);\r\n}\r\n\r\nexport default arcgisOnlineProvider;\r\n","import {\r\n Control,\r\n DomEvent,\r\n DomUtil,\r\n Evented,\r\n Util,\r\n latLngBounds\r\n} from 'leaflet';\r\nimport { geosearchCore } from '../Classes/GeosearchCore';\r\nimport { arcgisOnlineProvider } from '../Providers/ArcgisOnlineGeocoder';\r\nimport { Util as EsriUtil } from 'esri-leaflet';\r\n\r\nexport var Geosearch = Control.extend({\r\n includes: Evented.prototype,\r\n\r\n options: {\r\n position: 'topleft',\r\n collapseAfterResult: true,\r\n expanded: false,\r\n allowMultipleResults: true,\r\n placeholder: 'Search for places or addresses',\r\n title: 'Location Search'\r\n },\r\n\r\n initialize: function (options) {\r\n Util.setOptions(this, options);\r\n\r\n if (!options || !options.providers || !options.providers.length) {\r\n if (!options) {\r\n options = {};\r\n }\r\n options.providers = [ arcgisOnlineProvider() ];\r\n }\r\n\r\n // instantiate the underlying class and pass along options\r\n this._geosearchCore = geosearchCore(this, options);\r\n this._geosearchCore._providers = options.providers;\r\n\r\n // bubble each providers events to the control\r\n this._geosearchCore.addEventParent(this);\r\n for (var i = 0; i < this._geosearchCore._providers.length; i++) {\r\n this._geosearchCore._providers[i].addEventParent(this);\r\n }\r\n\r\n this._geosearchCore._pendingSuggestions = [];\r\n\r\n Control.prototype.initialize.call(this, options);\r\n },\r\n\r\n _renderSuggestions: function (suggestions) {\r\n var currentGroup;\r\n\r\n if (suggestions.length > 0) {\r\n this._suggestions.style.display = 'block';\r\n }\r\n\r\n var list;\r\n var header;\r\n var suggestionTextArray = [];\r\n\r\n for (var i = 0; i < suggestions.length; i++) {\r\n var suggestion = suggestions[i];\r\n if (!header && this._geosearchCore._providers.length > 1 && currentGroup !== suggestion.provider.options.label) {\r\n header = DomUtil.create('div', 'geocoder-control-header', suggestion.provider._contentsElement);\r\n header.textContent = suggestion.provider.options.label;\r\n header.innerText = suggestion.provider.options.label;\r\n currentGroup = suggestion.provider.options.label;\r\n }\r\n\r\n if (!list) {\r\n list = DomUtil.create('ul', 'geocoder-control-list', suggestion.provider._contentsElement);\r\n }\r\n\r\n if (suggestionTextArray.indexOf(suggestion.text) === -1) {\r\n var suggestionItem = DomUtil.create('li', 'geocoder-control-suggestion', list);\r\n\r\n suggestionItem.innerHTML = suggestion.text;\r\n suggestionItem.provider = suggestion.provider;\r\n suggestionItem['data-magic-key'] = suggestion.magicKey;\r\n suggestionItem.unformattedText = suggestion.unformattedText;\r\n } else {\r\n for (var j = 0; j < list.childNodes.length; j++) {\r\n // if the same text already appears in the list of suggestions, append an additional ObjectID to its magicKey instead\r\n if (list.childNodes[j].innerHTML === suggestion.text) {\r\n list.childNodes[j]['data-magic-key'] += ',' + suggestion.magicKey;\r\n }\r\n }\r\n }\r\n suggestionTextArray.push(suggestion.text);\r\n }\r\n\r\n // when the geocoder position is either \"topleft\" or \"topright\":\r\n // set the maxHeight of the suggestions box to:\r\n // map height\r\n // - suggestions offset (distance from top of suggestions to top of control)\r\n // - control offset (distance from top of control to top of map)\r\n // - 10 (extra padding)\r\n if (this.getPosition().indexOf('top') > -1) {\r\n this._suggestions.style.maxHeight = (this._map.getSize().y - this._suggestions.offsetTop - this._wrapper.offsetTop - 10) + 'px';\r\n }\r\n\r\n // when the geocoder position is either \"bottomleft\" or \"bottomright\":\r\n // 1. set the maxHeight of the suggestions box to:\r\n // map height\r\n // - corner control container offsetHeight (height of container of bottom corner)\r\n // - control offsetHeight (height of geocoder control wrapper, the main expandable button)\r\n // 2. to move it up, set the top of the suggestions box to:\r\n // negative offsetHeight of suggestions box (its own negative height now that it has children elements\r\n // - control offsetHeight (height of geocoder control wrapper, the main expandable button)\r\n // + 20 (extra spacing)\r\n if (this.getPosition().indexOf('bottom') > -1) {\r\n this._setSuggestionsBottomPosition();\r\n }\r\n },\r\n\r\n _setSuggestionsBottomPosition: function () {\r\n this._suggestions.style.maxHeight = (this._map.getSize().y - this._map._controlCorners[this.getPosition()].offsetHeight - this._wrapper.offsetHeight) + 'px';\r\n this._suggestions.style.top = (-this._suggestions.offsetHeight - this._wrapper.offsetHeight + 20) + 'px';\r\n },\r\n\r\n _boundsFromResults: function (results) {\r\n if (!results.length) {\r\n return;\r\n }\r\n\r\n var nullIsland = latLngBounds([0, 0], [0, 0]);\r\n var resultBounds = [];\r\n var resultLatlngs = [];\r\n\r\n // collect the bounds and center of each result\r\n for (var i = results.length - 1; i >= 0; i--) {\r\n var result = results[i];\r\n\r\n resultLatlngs.push(result.latlng);\r\n\r\n // make sure bounds are valid and not 0,0. sometimes bounds are incorrect or not present\r\n if (result.bounds && result.bounds.isValid() && !result.bounds.equals(nullIsland)) {\r\n resultBounds.push(result.bounds);\r\n }\r\n }\r\n\r\n // form a bounds object containing all center points\r\n var bounds = latLngBounds(resultLatlngs);\r\n\r\n // and extend it to contain all bounds objects\r\n for (var j = 0; j < resultBounds.length; j++) {\r\n bounds.extend(resultBounds[j]);\r\n }\r\n\r\n return bounds;\r\n },\r\n\r\n clear: function () {\r\n this._clearAllSuggestions();\r\n\r\n if (this.options.collapseAfterResult) {\r\n this._input.value = '';\r\n this._lastValue = '';\r\n this._input.placeholder = '';\r\n DomUtil.removeClass(this._wrapper, 'geocoder-control-expanded');\r\n }\r\n\r\n if (!this._map.scrollWheelZoom.enabled() && this._map.options.scrollWheelZoom) {\r\n this._map.scrollWheelZoom.enable();\r\n }\r\n },\r\n\r\n _clearAllSuggestions: function () {\r\n this._suggestions.style.display = 'none';\r\n\r\n for (var i = 0; i < this.options.providers.length; i++) {\r\n this._clearProviderSuggestions(this.options.providers[i]);\r\n }\r\n },\r\n\r\n _clearProviderSuggestions: function (provider) {\r\n provider._contentsElement.innerHTML = '';\r\n },\r\n\r\n _finalizeSuggestions: function (activeRequests, suggestionsLength) {\r\n // check if all requests are finished to remove the loading indicator\r\n if (!activeRequests) {\r\n DomUtil.removeClass(this._input, 'geocoder-control-loading');\r\n\r\n // when the geocoder position is either \"bottomleft\" or \"bottomright\",\r\n // it is necessary in some cases to recalculate the maxHeight and top values of the this._suggestions element,\r\n // even though this is also being done after each provider returns their own suggestions\r\n if (this.getPosition().indexOf('bottom') > -1) {\r\n this._setSuggestionsBottomPosition();\r\n }\r\n\r\n // also check if there were 0 total suggest results to clear the parent suggestions element\r\n // otherwise its display value may be \"block\" instead of \"none\"\r\n if (!suggestionsLength) {\r\n this._clearAllSuggestions();\r\n }\r\n }\r\n },\r\n\r\n _setupClick: function () {\r\n DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\r\n this._input.focus();\r\n },\r\n\r\n disable: function () {\r\n this._input.disabled = true;\r\n DomUtil.addClass(this._input, 'geocoder-control-input-disabled');\r\n DomEvent.removeListener(this._wrapper, 'click', this._setupClick, this);\r\n },\r\n\r\n enable: function () {\r\n this._input.disabled = false;\r\n DomUtil.removeClass(this._input, 'geocoder-control-input-disabled');\r\n DomEvent.addListener(this._wrapper, 'click', this._setupClick, this);\r\n },\r\n\r\n getAttribution: function () {\r\n var attribs = [];\r\n\r\n for (var i = 0; i < this._providers.length; i++) {\r\n if (this._providers[i].options.attribution) {\r\n attribs.push(this._providers[i].options.attribution);\r\n }\r\n }\r\n\r\n return attribs.join(', ');\r\n },\r\n\r\n geocodeSuggestion: function (e) {\r\n var suggestionItem = e.target || e.srcElement;\r\n\r\n if (\r\n suggestionItem.classList.contains('geocoder-control-suggestions') ||\r\n suggestionItem.classList.contains('geocoder-control-header')\r\n ) {\r\n return;\r\n }\r\n\r\n // make sure and point at the actual 'geocoder-control-suggestion'\r\n if (suggestionItem.classList.length < 1) {\r\n suggestionItem = suggestionItem.parentNode;\r\n }\r\n\r\n this._geosearchCore._geocode(suggestionItem.unformattedText, suggestionItem['data-magic-key'], suggestionItem.provider);\r\n this.clear();\r\n },\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n EsriUtil.setEsriAttribution(map);\r\n\r\n this._map = map;\r\n this._wrapper = DomUtil.create('div', 'geocoder-control');\r\n this._input = DomUtil.create('input', 'geocoder-control-input leaflet-bar', this._wrapper);\r\n this._input.title = this.options.title;\r\n\r\n if (this.options.expanded) {\r\n DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\r\n this._input.placeholder = this.options.placeholder;\r\n }\r\n\r\n // create the main suggested results container element\r\n this._suggestions = DomUtil.create('div', 'geocoder-control-suggestions leaflet-bar', this._wrapper);\r\n\r\n // create a child contents container element for each provider inside of this._suggestions\r\n // to maintain the configured order of providers for suggested results\r\n for (var i = 0; i < this.options.providers.length; i++) {\r\n this.options.providers[i]._contentsElement = DomUtil.create('div', null, this._suggestions);\r\n }\r\n\r\n var credits = this._geosearchCore._getAttribution();\r\n\r\n if (map.attributionControl) {\r\n map.attributionControl.addAttribution(credits);\r\n }\r\n\r\n DomEvent.addListener(this._input, 'focus', function (e) {\r\n this._input.placeholder = this.options.placeholder;\r\n DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\r\n }, this);\r\n\r\n DomEvent.addListener(this._wrapper, 'click', this._setupClick, this);\r\n\r\n // make sure both click and touch spawn an address/poi search\r\n DomEvent.addListener(this._suggestions, 'mousedown', this.geocodeSuggestion, this);\r\n\r\n DomEvent.addListener(this._input, 'blur', function (e) {\r\n // TODO: this is too greedy and should not \"clear\"\r\n // when trying to use the scrollbar or clicking on a non-suggestion item (such as a provider header)\r\n this.clear();\r\n }, this);\r\n\r\n DomEvent.addListener(this._input, 'keydown', function (e) {\r\n var text = (e.target || e.srcElement).value;\r\n\r\n DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\r\n\r\n var list = this._suggestions.querySelectorAll('.' + 'geocoder-control-suggestion');\r\n var selected = this._suggestions.querySelectorAll('.' + 'geocoder-control-selected')[0];\r\n var selectedPosition;\r\n\r\n for (var i = 0; i < list.length; i++) {\r\n if (list[i] === selected) {\r\n selectedPosition = i;\r\n break;\r\n }\r\n }\r\n\r\n switch (e.keyCode) {\r\n case 13:\r\n /*\r\n if an item has been selected, geocode it\r\n if focus is on the input textbox, geocode only if multiple results are allowed and more than two characters are present, or if a single suggestion is displayed.\r\n if less than two characters have been typed, abort the geocode\r\n */\r\n if (selected) {\r\n this._input.value = selected.innerText;\r\n this._geosearchCore._geocode(selected.unformattedText, selected['data-magic-key'], selected.provider);\r\n this.clear();\r\n } else if (this.options.allowMultipleResults && text.length >= 2) {\r\n this._geosearchCore._geocode(this._input.value, undefined);\r\n this.clear();\r\n } else {\r\n if (list.length === 1) {\r\n DomUtil.addClass(list[0], 'geocoder-control-selected');\r\n this._geosearchCore._geocode(list[0].innerHTML, list[0]['data-magic-key'], list[0].provider);\r\n } else {\r\n this.clear();\r\n this._input.blur();\r\n }\r\n }\r\n DomEvent.preventDefault(e);\r\n break;\r\n case 38:\r\n if (selected) {\r\n DomUtil.removeClass(selected, 'geocoder-control-selected');\r\n }\r\n\r\n var previousItem = list[selectedPosition - 1];\r\n\r\n if (selected && previousItem) {\r\n DomUtil.addClass(previousItem, 'geocoder-control-selected');\r\n } else {\r\n DomUtil.addClass(list[list.length - 1], 'geocoder-control-selected');\r\n }\r\n DomEvent.preventDefault(e);\r\n break;\r\n case 40:\r\n if (selected) {\r\n DomUtil.removeClass(selected, 'geocoder-control-selected');\r\n }\r\n\r\n var nextItem = list[selectedPosition + 1];\r\n\r\n if (selected && nextItem) {\r\n DomUtil.addClass(nextItem, 'geocoder-control-selected');\r\n } else {\r\n DomUtil.addClass(list[0], 'geocoder-control-selected');\r\n }\r\n DomEvent.preventDefault(e);\r\n break;\r\n default:\r\n // when the input changes we should cancel all pending suggestion requests if possible to avoid result collisions\r\n for (var x = 0; x < this._geosearchCore._pendingSuggestions.length; x++) {\r\n var request = this._geosearchCore._pendingSuggestions[x];\r\n if (request && request.abort && !request.id) {\r\n request.abort();\r\n }\r\n }\r\n break;\r\n }\r\n }, this);\r\n\r\n DomEvent.addListener(this._input, 'keyup', Util.throttle(function (e) {\r\n var key = e.which || e.keyCode;\r\n var text = (e.target || e.srcElement).value;\r\n\r\n // require at least 2 characters for suggestions\r\n if (text.length < 2) {\r\n this._lastValue = this._input.value;\r\n this._clearAllSuggestions();\r\n DomUtil.removeClass(this._input, 'geocoder-control-loading');\r\n return;\r\n }\r\n\r\n // if this is the escape key it will clear the input so clear suggestions\r\n if (key === 27) {\r\n this._clearAllSuggestions();\r\n return;\r\n }\r\n\r\n // if this is NOT the up/down arrows or enter make a suggestion\r\n if (key !== 13 && key !== 38 && key !== 40) {\r\n if (this._input.value !== this._lastValue) {\r\n this._lastValue = this._input.value;\r\n DomUtil.addClass(this._input, 'geocoder-control-loading');\r\n this._geosearchCore._suggest(text);\r\n }\r\n }\r\n }, 50, this), this);\r\n\r\n DomEvent.disableClickPropagation(this._wrapper);\r\n\r\n // when mouse moves over suggestions disable scroll wheel zoom if its enabled\r\n DomEvent.addListener(this._suggestions, 'mouseover', function (e) {\r\n if (map.scrollWheelZoom.enabled() && map.options.scrollWheelZoom) {\r\n map.scrollWheelZoom.disable();\r\n }\r\n });\r\n\r\n // when mouse moves leaves suggestions enable scroll wheel zoom if its disabled\r\n DomEvent.addListener(this._suggestions, 'mouseout', function (e) {\r\n if (!map.scrollWheelZoom.enabled() && map.options.scrollWheelZoom) {\r\n map.scrollWheelZoom.enable();\r\n }\r\n });\r\n\r\n this._geosearchCore.on('load', function (e) {\r\n DomUtil.removeClass(this._input, 'geocoder-control-loading');\r\n this.clear();\r\n this._input.blur();\r\n }, this);\r\n\r\n return this._wrapper;\r\n }\r\n});\r\n\r\nexport function geosearch (options) {\r\n return new Geosearch(options);\r\n}\r\n\r\nexport default geosearch;\r\n","import { Util, geoJson, latLngBounds } from 'leaflet';\r\nimport { FeatureLayerService } from 'esri-leaflet';\r\n\r\nexport var FeatureLayerProvider = FeatureLayerService.extend({\r\n options: {\r\n label: 'Feature Layer',\r\n maxResults: 5,\r\n bufferRadius: 1000,\r\n searchMode: 'contain',\r\n formatSuggestion: function (feature) {\r\n return feature.properties[this.options.searchFields[0]];\r\n }\r\n },\r\n\r\n initialize: function (options) {\r\n FeatureLayerService.prototype.initialize.call(this, options);\r\n if (typeof this.options.searchFields === 'string') {\r\n this.options.searchFields = [this.options.searchFields];\r\n }\r\n this._suggestionsQuery = this.query();\r\n this._resultsQuery = this.query();\r\n },\r\n\r\n suggestions: function (text, bounds, callback) {\r\n var query = this._suggestionsQuery.where(this._buildQuery(text))\r\n .returnGeometry(false);\r\n\r\n if (bounds) {\r\n query.intersects(bounds);\r\n }\r\n\r\n if (this.options.idField) {\r\n query.fields([this.options.idField].concat(this.options.searchFields));\r\n }\r\n\r\n var request = query.run(function (error, results, raw) {\r\n if (error) {\r\n callback(error, []);\r\n } else {\r\n this.options.idField = raw.objectIdFieldName;\r\n var suggestions = [];\r\n for (var i = results.features.length - 1; i >= 0; i--) {\r\n var feature = results.features[i];\r\n suggestions.push({\r\n text: this.options.formatSuggestion.call(this, feature),\r\n unformattedText: feature.properties[this.options.searchFields[0]],\r\n magicKey: feature.id\r\n });\r\n }\r\n callback(error, suggestions.slice(0, this.options.maxResults));\r\n }\r\n }, this);\r\n\r\n return request;\r\n },\r\n\r\n results: function (text, key, bounds, callback) {\r\n var query = this._resultsQuery;\r\n\r\n if (key) {\r\n // if there are 1 or more keys available, use query.featureIds()\r\n delete query.params.where;\r\n query.featureIds([key]);\r\n } else {\r\n // if there are no keys available, use query.where()\r\n query.where(this._buildQuery(text));\r\n }\r\n\r\n if (bounds) {\r\n query.within(bounds);\r\n }\r\n\r\n return query.run(Util.bind(function (error, features) {\r\n var results = [];\r\n for (var i = 0; i < features.features.length; i++) {\r\n var feature = features.features[i];\r\n if (feature) {\r\n var bounds = this._featureBounds(feature);\r\n\r\n var result = {\r\n latlng: bounds.getCenter(),\r\n bounds: bounds,\r\n text: this.options.formatSuggestion.call(this, feature),\r\n properties: feature.properties,\r\n geojson: feature\r\n };\r\n\r\n results.push(result);\r\n\r\n // clear query parameters for the next search\r\n delete this._resultsQuery.params['objectIds'];\r\n }\r\n }\r\n callback(error, results);\r\n }, this));\r\n },\r\n\r\n orderBy: function (fieldName, order) {\r\n this._suggestionsQuery.orderBy(fieldName, order);\r\n },\r\n\r\n _buildQuery: function (text) {\r\n var queryString = [];\r\n\r\n for (var i = this.options.searchFields.length - 1; i >= 0; i--) {\r\n var field = 'upper(\"' + this.options.searchFields[i] + '\")';\r\n if (this.options.searchMode === 'contain') {\r\n queryString.push(field + \" LIKE upper('%\" + text + \"%')\");\r\n } else if (this.options.searchMode === 'startWith') {\r\n queryString.push(field + \" LIKE upper('\" + text + \"%')\");\r\n } else if (this.options.searchMode === 'endWith') {\r\n queryString.push(field + \" LIKE upper('%\" + text + \"')\");\r\n } else if (this.options.searchMode === 'strict') {\r\n queryString.push(field + \" LIKE upper('\" + text + \"')\");\r\n } else {\r\n throw new Error('L.esri.Geocoding.featureLayerProvider: Invalid parameter for \"searchMode\". Use one of \"contain\", \"startWith\", \"endWith\", or \"strict\"');\r\n }\r\n }\r\n if (this.options.where) {\r\n return this.options.where + ' AND (' + queryString.join(' OR ') + ')';\r\n } else {\r\n return queryString.join(' OR ');\r\n }\r\n },\r\n\r\n _featureBounds: function (feature) {\r\n var geojson = geoJson(feature);\r\n if (feature.geometry.type === 'Point') {\r\n var center = geojson.getBounds().getCenter();\r\n var lngRadius = ((this.options.bufferRadius / 40075017) * 360) / Math.cos((180 / Math.PI) * center.lat);\r\n var latRadius = (this.options.bufferRadius / 40075017) * 360;\r\n return latLngBounds([center.lat - latRadius, center.lng - lngRadius], [center.lat + latRadius, center.lng + lngRadius]);\r\n } else {\r\n return geojson.getBounds();\r\n }\r\n }\r\n});\r\n\r\nexport function featureLayerProvider (options) {\r\n return new FeatureLayerProvider(options);\r\n}\r\n\r\nexport default featureLayerProvider;\r\n","import { Util, geoJson, latLngBounds } from 'leaflet';\r\nimport { MapService } from 'esri-leaflet';\r\n\r\nexport var MapServiceProvider = MapService.extend({\r\n options: {\r\n layers: [0],\r\n label: 'Map Service',\r\n bufferRadius: 1000,\r\n maxResults: 5,\r\n formatSuggestion: function (feature) {\r\n return feature.properties[feature.displayFieldName] + ' ' + feature.layerName + '';\r\n }\r\n },\r\n\r\n initialize: function (options) {\r\n MapService.prototype.initialize.call(this, options);\r\n this._getIdFields();\r\n },\r\n\r\n suggestions: function (text, bounds, callback) {\r\n var request = this.find().text(text).fields(this.options.searchFields).returnGeometry(false).layers(this.options.layers);\r\n\r\n return request.run(function (error, results, raw) {\r\n var suggestions = [];\r\n if (!error) {\r\n var count = Math.min(this.options.maxResults, results.features.length);\r\n raw.results = raw.results.reverse();\r\n for (var i = 0; i < count; i++) {\r\n var feature = results.features[i];\r\n var result = raw.results[i];\r\n var layer = result.layerId;\r\n var idField = this._idFields[layer];\r\n feature.layerId = layer;\r\n feature.layerName = this._layerNames[layer];\r\n feature.displayFieldName = this._displayFields[layer];\r\n if (idField) {\r\n suggestions.push({\r\n text: this.options.formatSuggestion.call(this, feature),\r\n unformattedText: feature.properties[feature.displayFieldName],\r\n magicKey: result.attributes[idField] + ':' + layer\r\n });\r\n }\r\n }\r\n }\r\n callback(error, suggestions.reverse());\r\n }, this);\r\n },\r\n\r\n results: function (text, key, bounds, callback) {\r\n var results = [];\r\n var request;\r\n\r\n if (key && !key.includes(',')) {\r\n // if there is only 1 key available, use query()\r\n var featureId = key.split(':')[0];\r\n var layer = key.split(':')[1];\r\n request = this.query().layer(layer).featureIds(featureId);\r\n } else {\r\n // if there are no keys or more than 1 keys available, use find()\r\n request = this.find().text(text).fields(this.options.searchFields).layers(this.options.layers);\r\n }\r\n\r\n return request.run(function (error, features, response) {\r\n if (!error) {\r\n if (response.results) {\r\n response.results = response.results.reverse();\r\n }\r\n for (var i = 0; i < features.features.length; i++) {\r\n var feature = features.features[i];\r\n layer = layer || response.results[i].layerId;\r\n\r\n if (feature && layer !== undefined) {\r\n var bounds = this._featureBounds(feature);\r\n feature.layerId = layer;\r\n feature.layerName = this._layerNames[layer];\r\n feature.displayFieldName = this._displayFields[layer];\r\n\r\n var result = {\r\n latlng: bounds.getCenter(),\r\n bounds: bounds,\r\n text: this.options.formatSuggestion.call(this, feature),\r\n properties: feature.properties,\r\n geojson: feature\r\n };\r\n\r\n results.push(result);\r\n }\r\n }\r\n }\r\n callback(error, results.reverse());\r\n }, this);\r\n },\r\n\r\n _featureBounds: function (feature) {\r\n var geojson = geoJson(feature);\r\n if (feature.geometry.type === 'Point') {\r\n var center = geojson.getBounds().getCenter();\r\n var lngRadius = ((this.options.bufferRadius / 40075017) * 360) / Math.cos((180 / Math.PI) * center.lat);\r\n var latRadius = (this.options.bufferRadius / 40075017) * 360;\r\n return latLngBounds([center.lat - latRadius, center.lng - lngRadius], [center.lat + latRadius, center.lng + lngRadius]);\r\n } else {\r\n return geojson.getBounds();\r\n }\r\n },\r\n\r\n _layerMetadataCallback: function (layerid) {\r\n return Util.bind(function (error, metadata) {\r\n if (error) { return; }\r\n this._displayFields[layerid] = metadata.displayField;\r\n this._layerNames[layerid] = metadata.name;\r\n for (var i = 0; i < metadata.fields.length; i++) {\r\n var field = metadata.fields[i];\r\n if (field.type === 'esriFieldTypeOID') {\r\n this._idFields[layerid] = field.name;\r\n break;\r\n }\r\n }\r\n }, this);\r\n },\r\n\r\n _getIdFields: function () {\r\n this._idFields = {};\r\n this._displayFields = {};\r\n this._layerNames = {};\r\n for (var i = 0; i < this.options.layers.length; i++) {\r\n var layer = this.options.layers[i];\r\n this.get(layer, {}, this._layerMetadataCallback(layer));\r\n }\r\n }\r\n});\r\n\r\nexport function mapServiceProvider (options) {\r\n return new MapServiceProvider(options);\r\n}\r\n\r\nexport default mapServiceProvider;\r\n","import { GeocodeService } from '../Services/Geocode';\r\n\r\nexport var GeocodeServiceProvider = GeocodeService.extend({\r\n options: {\r\n label: 'Geocode Server',\r\n maxResults: 5\r\n },\r\n\r\n suggestions: function (text, bounds, callback) {\r\n if (this.options.supportsSuggest) {\r\n var request = this.suggest().text(text);\r\n if (bounds) {\r\n request.within(bounds);\r\n }\r\n\r\n return request.run(function (error, results, response) {\r\n var suggestions = [];\r\n if (!error) {\r\n while (response.suggestions.length && suggestions.length <= (this.options.maxResults - 1)) {\r\n var suggestion = response.suggestions.shift();\r\n if (!suggestion.isCollection) {\r\n suggestions.push({\r\n text: suggestion.text,\r\n unformattedText: suggestion.text,\r\n magicKey: suggestion.magicKey\r\n });\r\n }\r\n }\r\n }\r\n callback(error, suggestions);\r\n }, this);\r\n } else {\r\n callback(undefined, []);\r\n return false;\r\n }\r\n },\r\n\r\n results: function (text, key, bounds, callback) {\r\n var request = this.geocode().text(text);\r\n\r\n if (key) {\r\n request.key(key);\r\n }\r\n\r\n request.maxLocations(this.options.maxResults);\r\n\r\n if (bounds) {\r\n request.within(bounds);\r\n }\r\n\r\n return request.run(function (error, response) {\r\n callback(error, response.results);\r\n }, this);\r\n }\r\n});\r\n\r\nexport function geocodeServiceProvider (options) {\r\n return new GeocodeServiceProvider(options);\r\n}\r\n\r\nexport default geocodeServiceProvider;\r\n"],"names":["WorldGeocodingServiceUrl","Geocode","Task","extend","path","params","outSr","forStorage","outFields","maxLocations","setters","address","neighborhood","city","subregion","region","postal","country","text","category","token","key","fields","countries","initialize","options","url","prototype","call","this","within","bounds","latLngBounds","searchExtent","EsriUtil","boundsToExtent","nearby","coords","radius","centroid","latLng","location","lng","lat","distance","Math","min","max","run","callback","context","customParam","singleLine","request","error","response","processor","_processGeocoderResponse","results","undefined","i","candidates","length","candidate","extent","extentToBounds","push","score","latlng","y","x","properties","attributes","geocode","ReverseGeocode","outSR","returnIntersection","language","intersection","result","reverseGeocode","Suggest","maxSuggestions","supportsSuggest","center","pad","getCenter","ne","getNorthWest","distanceTo","console","warn","suggest","GeocodeService","Service","_confirmSuggestSupport","reverse","metadata","capabilities","indexOf","singleLineAddressField","name","GeosearchCore","Evented","zoomToResult","useMapBounds","searchBounds","control","Util","setOptions","_control","providers","Error","_providers","_geocode","provider","activeRequests","allResults","bind","concat","_boundsFromResults","fire","_map","fitBounds","_searchBounds","_suggest","suggestionsLength","createCallback","suggestions","_clearProviderSuggestions","_finalizeSuggestions","_renderSuggestions","_lastRender","_input","value","_pendingSuggestions","getZoom","getBounds","nullIsland","resultBounds","resultLatlngs","isValid","equals","j","_getAttribution","attribs","attribution","join","geosearchCore","ArcgisOnlineProvider","label","maxResults","categories","suggestion","shift","isCollection","unformattedText","magicKey","arcgisOnlineProvider","Geosearch","Control","includes","position","collapseAfterResult","expanded","allowMultipleResults","placeholder","title","_geosearchCore","addEventParent","currentGroup","list","header","_suggestions","style","display","suggestionTextArray","DomUtil","create","_contentsElement","textContent","innerText","suggestionItem","innerHTML","childNodes","getPosition","maxHeight","getSize","offsetTop","_wrapper","_setSuggestionsBottomPosition","_controlCorners","offsetHeight","top","clear","_clearAllSuggestions","_lastValue","removeClass","scrollWheelZoom","enabled","enable","_setupClick","addClass","focus","disable","disabled","DomEvent","removeListener","addListener","getAttribution","geocodeSuggestion","e","target","srcElement","classList","contains","parentNode","onAdd","map","setEsriAttribution","credits","attributionControl","addAttribution","selectedPosition","querySelectorAll","selected","keyCode","blur","preventDefault","previousItem","nextItem","abort","id","throttle","which","disableClickPropagation","on","FeatureLayerProvider","FeatureLayerService","bufferRadius","searchMode","formatSuggestion","feature","searchFields","_suggestionsQuery","query","_resultsQuery","where","_buildQuery","returnGeometry","intersects","idField","raw","objectIdFieldName","features","slice","featureIds","_featureBounds","geojson","orderBy","fieldName","order","queryString","field","geoJson","geometry","type","lngRadius","cos","PI","latRadius","MapServiceProvider","MapService","layers","displayFieldName","layerName","_getIdFields","find","count","layer","layerId","_idFields","_layerNames","_displayFields","featureId","split","_layerMetadataCallback","layerid","displayField","get","GeocodeServiceProvider"],"mappings":";;;0UAAWA,EAA2B,uECO3BC,EAAUC,OAAKC,OAAO,CAC/BC,KAAM,wBAENC,OAAQ,CACNC,MAAO,KACPC,YAAY,EACZC,UAAW,IACXC,aAAc,IAGhBC,QAAS,CACPC,QAAW,UACXC,aAAgB,eAChBC,KAAQ,OACRC,UAAa,YACbC,OAAU,SACVC,OAAU,SACVC,QAAW,UACXC,KAAQ,aACRC,SAAY,WACZC,MAAS,QACTC,IAAO,WACPC,OAAU,YACVf,WAAc,aACdE,aAAgB,eAEhBc,UAAa,iBAGfC,WAAY,SAAUC,IACpBA,EAAUA,GAAW,IACbC,IAAMD,EAAQC,KAAO1B,EAC7BE,OAA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