/*! 1.6.0 | © Algolia | github.com/algolia/places */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["placesAutocompleteDataset"] = factory(); else root["placesAutocompleteDataset"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 83); /******/ }) /************************************************************************/ /******/ ([ /* 0 */, /* 1 */, /* 2 */, /* 3 */, /* 4 */, /* 5 */, /* 6 */, /* 7 */, /* 8 */, /* 9 */, /* 10 */, /* 11 */, /* 12 */ /***/ (function(module, exports) { module.exports = "\n" /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = '1.6.0'; /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.default = createAutocompleteDataset; var _createAutocompleteSource = __webpack_require__(23); var _createAutocompleteSource2 = _interopRequireDefault(_createAutocompleteSource); var _defaultTemplates = __webpack_require__(24); var _defaultTemplates2 = _interopRequireDefault(_defaultTemplates); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function createAutocompleteDataset(options) { var templates = _extends({}, _defaultTemplates2.default, options.templates); var source = (0, _createAutocompleteSource2.default)(_extends({}, options, { formatInputValue: templates.value, templates: undefined })); return { source: source, templates: templates, displayKey: 'value', name: 'places' }; } /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // polyfill for navigator.language (IE <= 10) // not polyfilled by https://cdn.polyfill.io/v2/docs/ // Defined: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#navigatorlanguage // with allowable values at http://www.ietf.org/rfc/bcp/bcp47.txt // Note that the HTML spec suggests that anonymizing services return "en-US" by default for // user privacy (so your app may wish to provide a means of changing the locale) if (!('language' in navigator)) { navigator.language = // IE 10 in IE8 mode on Windows 7 uses upper-case in // navigator.userLanguage country codes but per // http://msdn.microsoft.com/en-us/library/ie/ms533052.aspx (via // http://msdn.microsoft.com/en-us/library/ie/ms534713.aspx), they // appear to be in lower case, so we bring them into harmony with navigator.language. navigator.userLanguage && navigator.userLanguage.replace(/-[a-z]{2}$/, String.prototype.toUpperCase) || 'en-US'; // Default for anonymizing services: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#navigatorlanguage } /***/ }), /* 16 */ /***/ (function(module, exports) { var containers = []; // will store container HTMLElement references var styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement} var usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).'; function insertCss(css, options) { options = options || {}; if (css === undefined) { throw new Error(usage); } var position = options.prepend === true ? 'prepend' : 'append'; var container = options.container !== undefined ? options.container : document.querySelector('head'); var containerId = containers.indexOf(container); // first time we see this container, create the necessary entries if (containerId === -1) { containerId = containers.push(container) - 1; styleElements[containerId] = {}; } // try to get the correponding container + position styleElement, create it otherwise var styleElement; if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) { styleElement = styleElements[containerId][position]; } else { styleElement = styleElements[containerId][position] = createStyleElement(); if (position === 'prepend') { container.insertBefore(styleElement, container.childNodes[0]); } else { container.appendChild(styleElement); } } // strip potential UTF-8 BOM if css was read from a file if (css.charCodeAt(0) === 0xFEFF) { css = css.substr(1, css.length); } // actually add the stylesheet if (styleElement.styleSheet) { styleElement.styleSheet.cssText += css } else { styleElement.textContent += css; } return styleElement; }; function createStyleElement() { var styleElement = document.createElement('style'); styleElement.setAttribute('type', 'text/css'); return styleElement; } module.exports = insertCss; module.exports.insertCss = insertCss; /***/ }), /* 17 */ /***/ (function(module, exports) { module.exports = ".algolia-places {\n width: 100%;\n}\n\n.ap-input, .ap-hint {\n width: 100%;\n padding-right: 35px;\n padding-left: 16px;\n line-height: 40px;\n height: 40px;\n border: 1px solid #CCC;\n border-radius: 3px;\n outline: none;\n font: inherit;\n appearance: none;\n -webkit-appearance: none;\n box-sizing: border-box;\n}\n\n.ap-input::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n.ap-input::-ms-clear {\n display: none;\n}\n\n.ap-input:hover ~ .ap-input-icon svg,\n.ap-input:focus ~ .ap-input-icon svg,\n.ap-input-icon:hover svg {\n fill: #aaaaaa;\n}\n\n.ap-dropdown-menu {\n width: 100%;\n background: #ffffff;\n box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1);\n border-radius: 3px;\n margin-top: 3px;\n overflow: hidden;\n}\n\n.ap-suggestion {\n cursor: pointer;\n height: 46px;\n line-height: 46px;\n padding-left: 18px;\n overflow: hidden;\n}\n\n.ap-suggestion em {\n font-weight: bold;\n font-style: normal;\n}\n\n.ap-address {\n font-size: smaller;\n margin-left: 12px;\n color: #aaaaaa;\n}\n\n.ap-suggestion-icon {\n margin-right: 10px;\n width: 14px;\n height: 20px;\n vertical-align: middle;\n}\n\n.ap-suggestion-icon svg {\n -webkit-transform: scale(0.9) translateY(2px);\n transform: scale(0.9) translateY(2px);\n fill: #cfcfcf;\n}\n\n.ap-input-icon {\n border: 0;\n background: transparent;\n position: absolute;\n top: 0;\n bottom: 0;\n right: 16px;\n outline: none;\n}\n\n.ap-input-icon.ap-icon-pin {\n cursor: initial;\n}\n\n.ap-input-icon svg {\n fill: #cfcfcf;\n position: absolute;\n top: 50%;\n right: 0;\n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n}\n\n.ap-cursor {\n background: #efefef;\n}\n\n.ap-cursor .ap-suggestion-icon svg {\n -webkit-transform: scale(1) translateY(2px);\n transform: scale(1) translateY(2px);\n fill: #aaaaaa;\n}\n\n.ap-footer {\n opacity: .8;\n text-align: right;\n padding: .5em 1em .5em 0;\n font-size: 12px;\n line-height: 12px;\n}\n\n.ap-footer a {\n color: inherit;\n text-decoration: none;\n}\n\n.ap-footer a svg {\n vertical-align: text-bottom;\n max-width: 60px;\n}\n\n.ap-footer:hover {\n opacity: 1;\n}\n" /***/ }), /* 18 */, /* 19 */, /* 20 */, /* 21 */, /* 22 */, /* 23 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.default = createAutocompleteSource; var _formatHit = __webpack_require__(28); var _formatHit2 = _interopRequireDefault(_formatHit); var _version = __webpack_require__(13); var _version2 = _interopRequireDefault(_version); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function createAutocompleteSource(_ref) { var algoliasearch = _ref.algoliasearch, clientOptions = _ref.clientOptions, apiKey = _ref.apiKey, appId = _ref.appId, hitsPerPage = _ref.hitsPerPage, aroundLatLng = _ref.aroundLatLng, aroundRadius = _ref.aroundRadius, aroundLatLngViaIP = _ref.aroundLatLngViaIP, insideBoundingBox = _ref.insideBoundingBox, insidePolygon = _ref.insidePolygon, countries = _ref.countries, formatInputValue = _ref.formatInputValue, _ref$computeQueryPara = _ref.computeQueryParams, computeQueryParams = _ref$computeQueryPara === undefined ? function (params) { return params; } : _ref$computeQueryPara, _ref$useDeviceLocatio = _ref.useDeviceLocation, useDeviceLocation = _ref$useDeviceLocatio === undefined ? false : _ref$useDeviceLocatio, _ref$language = _ref.language, language = _ref$language === undefined ? navigator.language.split('-')[0] : _ref$language, _ref$onHits = _ref.onHits, onHits = _ref$onHits === undefined ? function () {} : _ref$onHits, _ref$onError = _ref.onError, onError = _ref$onError === undefined ? function (e) { throw e; } : _ref$onError, onRateLimitReached = _ref.onRateLimitReached, type = _ref.type; var placesClient = algoliasearch.initPlaces(appId, apiKey, clientOptions); placesClient.as.addAlgoliaAgent('Algolia Places ' + _version2.default); var defaultQueryParams = { countries: countries, hitsPerPage: hitsPerPage || 5, language: language, type: type }; if (Array.isArray(defaultQueryParams.countries)) { defaultQueryParams.countries = defaultQueryParams.countries.map(function (country) { return country.toLowerCase(); }); } if (typeof defaultQueryParams.language === 'string') { defaultQueryParams.language = defaultQueryParams.language.toLowerCase(); } if (aroundLatLng) { defaultQueryParams.aroundLatLng = aroundLatLng; } else if (aroundLatLngViaIP !== undefined) { defaultQueryParams.aroundLatLngViaIP = aroundLatLngViaIP; } if (aroundRadius) { defaultQueryParams.aroundRadius = aroundRadius; } if (insideBoundingBox) { defaultQueryParams.insideBoundingBox = insideBoundingBox; } if (insidePolygon) { defaultQueryParams.insidePolygon = insidePolygon; } var userCoords = void 0; if (useDeviceLocation) { navigator.geolocation.watchPosition(function (_ref2) { var coords = _ref2.coords; userCoords = coords.latitude + ',' + coords.longitude; }); } return function (query, cb) { var _extends2; return placesClient.search(computeQueryParams(_extends({}, defaultQueryParams, (_extends2 = {}, _defineProperty(_extends2, userCoords ? 'aroundLatLng' : undefined, userCoords), _defineProperty(_extends2, 'query', query), _extends2)))).then(function (content) { var hits = content.hits.map(function (hit, hitIndex) { return (0, _formatHit2.default)({ formatInputValue: formatInputValue, hit: hit, hitIndex: hitIndex, query: query, rawAnswer: content }); }); onHits({ hits: hits, query: query, rawAnswer: content }); return hits; }).then(cb).catch(function (e) { if (e.statusCode === 429) { onRateLimitReached(); return; } onError(e); }); }; } /***/ }), /* 24 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _formatInputValue = __webpack_require__(29); var _formatInputValue2 = _interopRequireDefault(_formatInputValue); var _formatDropdownValue = __webpack_require__(27); var _formatDropdownValue2 = _interopRequireDefault(_formatDropdownValue); var _algolia = __webpack_require__(31); var _algolia2 = _interopRequireDefault(_algolia); var _osm = __webpack_require__(35); var _osm2 = _interopRequireDefault(_osm); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = { footer: '
', value: _formatInputValue2.default, suggestion: _formatDropdownValue2.default }; /***/ }), /* 25 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = findCountryCode; function findCountryCode(tags) { for (var tagIndex = 0; tagIndex < tags.length; tagIndex++) { var tag = tags[tagIndex]; var find = tag.match(/country\/(.*)?/); if (find) { return find[1]; } } return undefined; } /***/ }), /* 26 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = findType; function findType(tags) { var types = { country: 'country', city: 'city', 'amenity/bus_station': 'busStop', 'amenity/townhall': 'townhall', 'railway/station': 'trainStation', 'aeroway/aerodrome': 'airport', 'aeroway/terminal': 'airport', 'aeroway/gate': 'airport' }; for (var t in types) { if (tags.indexOf(t) !== -1) { return types[t]; } } return 'address'; } /***/ }), /* 27 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = formatDropdownValue; var _address = __webpack_require__(12); var _address2 = _interopRequireDefault(_address); var _city = __webpack_require__(33); var _city2 = _interopRequireDefault(_city); var _country = __webpack_require__(34); var _country2 = _interopRequireDefault(_country); var _bus = __webpack_require__(32); var _bus2 = _interopRequireDefault(_bus); var _train = __webpack_require__(38); var _train2 = _interopRequireDefault(_train); var _townhall = __webpack_require__(37); var _townhall2 = _interopRequireDefault(_townhall); var _plane = __webpack_require__(36); var _plane2 = _interopRequireDefault(_plane); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var icons = { address: _address2.default, city: _city2.default, country: _country2.default, busStop: _bus2.default, trainStation: _train2.default, townhall: _townhall2.default, airport: _plane2.default }; function formatDropdownValue(_ref) { var type = _ref.type, highlight = _ref.highlight; var name = highlight.name, administrative = highlight.administrative, city = highlight.city, country = highlight.country; var out = (' \n' + name + '\n\n ' + [city, administrative, country].filter(function (token) { return token !== undefined; }).join(', ') + '').replace(/\s*\n\s*/g, ' '); return out; } /***/ }), /* 28 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.default = formatHit; var _findCountryCode = __webpack_require__(25); var _findCountryCode2 = _interopRequireDefault(_findCountryCode); var _findType = __webpack_require__(26); var _findType2 = _interopRequireDefault(_findType); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function getBestHighlightedForm(highlightedValues) { var defaultValue = highlightedValues[0].value; // collect all other matches var bestAttributes = []; for (var i = 1; i < highlightedValues.length; ++i) { if (highlightedValues[i].matchLevel !== 'none') { bestAttributes.push({ index: i, words: highlightedValues[i].matchedWords }); } } // no matches in this attribute, retrieve first value if (bestAttributes.length === 0) { return defaultValue; } // sort the matches by `desc(words), asc(index)` bestAttributes.sort(function (a, b) { if (a.words > b.words) { return -1; } else if (a.words < b.words) { return 1; } return a.index - b.index; }); // and append the best match to the first value return bestAttributes[0].index === 0 ? defaultValue + ' (' + highlightedValues[bestAttributes[1].index].value + ')' : highlightedValues[bestAttributes[0].index].value + ' (' + defaultValue + ')'; } function formatHit(_ref) { var formatInputValue = _ref.formatInputValue, hit = _ref.hit, hitIndex = _ref.hitIndex, query = _ref.query, rawAnswer = _ref.rawAnswer; try { var name = hit.locale_names[0]; var country = hit.country; var administrative = hit.administrative && hit.administrative[0] !== name ? hit.administrative[0] : undefined; var city = hit.city && hit.city[0] !== name ? hit.city[0] : undefined; var suburb = hit.suburb && hit.suburb[0] !== name ? hit.suburb[0] : undefined; var highlight = { name: getBestHighlightedForm(hit._highlightResult.locale_names), city: city ? getBestHighlightedForm(hit._highlightResult.city) : undefined, administrative: administrative ? getBestHighlightedForm(hit._highlightResult.administrative) : undefined, country: country ? hit._highlightResult.country.value : undefined, suburb: suburb ? getBestHighlightedForm(hit._highlightResult.suburb) : undefined }; var suggestion = { name: name, administrative: administrative, city: city, suburb: suburb, country: country, countryCode: (0, _findCountryCode2.default)(hit._tags), type: (0, _findType2.default)(hit._tags), latlng: { lat: hit._geoloc.lat, lng: hit._geoloc.lng }, postcode: hit.postcode && hit.postcode[0] }; // this is the value to put inside the \n