/*! 1.19.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["placesInstantsearchWidget"] = factory(); else root["placesInstantsearchWidget"] = factory(); })(window, 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; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // 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 = 72); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var DOM = __webpack_require__(2); function escapeRegExp(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); } module.exports = { // those methods are implemented differently // depending on which build it is, using // $... or angular... or Zepto... or require(...) isArray: null, isFunction: null, isObject: null, bind: null, each: null, map: null, mixin: null, isMsie: function(agentString) { if (agentString === undefined) { agentString = navigator.userAgent; } // from https://github.com/ded/bowser/blob/master/bowser.js if ((/(msie|trident)/i).test(agentString)) { var match = agentString.match(/(msie |rv:)(\d+(.\d+)?)/i); if (match) { return match[2]; } } return false; }, // http://stackoverflow.com/a/6969486 escapeRegExChars: function(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); }, isNumber: function(obj) { return typeof obj === 'number'; }, toStr: function toStr(s) { return s === undefined || s === null ? '' : s + ''; }, cloneDeep: function cloneDeep(obj) { var clone = this.mixin({}, obj); var self = this; this.each(clone, function(value, key) { if (value) { if (self.isArray(value)) { clone[key] = [].concat(value); } else if (self.isObject(value)) { clone[key] = self.cloneDeep(value); } } }); return clone; }, error: function(msg) { throw new Error(msg); }, every: function(obj, test) { var result = true; if (!obj) { return result; } this.each(obj, function(val, key) { if (result) { result = test.call(null, val, key, obj) && result; } }); return !!result; }, any: function(obj, test) { var found = false; if (!obj) { return found; } this.each(obj, function(val, key) { if (test.call(null, val, key, obj)) { found = true; return false; } }); return found; }, getUniqueId: (function() { var counter = 0; return function() { return counter++; }; })(), templatify: function templatify(obj) { if (this.isFunction(obj)) { return obj; } var $template = DOM.element(obj); if ($template.prop('tagName') === 'SCRIPT') { return function template() { return $template.text(); }; } return function template() { return String(obj); }; }, defer: function(fn) { setTimeout(fn, 0); }, noop: function() {}, formatPrefix: function(prefix, noPrefix) { return noPrefix ? '' : prefix + '-'; }, className: function(prefix, clazz, skipDot) { return (skipDot ? '' : '.') + prefix + clazz; }, escapeHighlightedString: function(str, highlightPreTag, highlightPostTag) { highlightPreTag = highlightPreTag || ''; var pre = document.createElement('div'); pre.appendChild(document.createTextNode(highlightPreTag)); highlightPostTag = highlightPostTag || ''; var post = document.createElement('div'); post.appendChild(document.createTextNode(highlightPostTag)); var div = document.createElement('div'); div.appendChild(document.createTextNode(str)); return div.innerHTML .replace(RegExp(escapeRegExp(pre.innerHTML), 'g'), highlightPreTag) .replace(RegExp(escapeRegExp(post.innerHTML), 'g'), highlightPostTag); } }; /***/ }), /* 1 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 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; } var extractParams = function extractParams(_ref) { var hitsPerPage = _ref.hitsPerPage, postcodeSearch = _ref.postcodeSearch, aroundLatLng = _ref.aroundLatLng, aroundRadius = _ref.aroundRadius, aroundLatLngViaIP = _ref.aroundLatLngViaIP, insideBoundingBox = _ref.insideBoundingBox, insidePolygon = _ref.insidePolygon, getRankingInfo = _ref.getRankingInfo, countries = _ref.countries, language = _ref.language, type = _ref.type; var extracted = { countries: countries, hitsPerPage: hitsPerPage || 5, language: language || navigator.language.split('-')[0], type: type }; if (Array.isArray(countries)) { extracted.countries = extracted.countries.map(function (country) { return country.toLowerCase(); }); } if (typeof extracted.language === 'string') { extracted.language = extracted.language.toLowerCase(); } if (aroundLatLng) { extracted.aroundLatLng = aroundLatLng; } else if (aroundLatLngViaIP !== undefined) { extracted.aroundLatLngViaIP = aroundLatLngViaIP; } if (postcodeSearch) { extracted.restrictSearchableAttributes = 'postcode'; } return _objectSpread(_objectSpread({}, extracted), {}, { aroundRadius: aroundRadius, insideBoundingBox: insideBoundingBox, insidePolygon: insidePolygon, getRankingInfo: getRankingInfo }); }; var extractControls = function extractControls(_ref2) { var _ref2$useDeviceLocati = _ref2.useDeviceLocation, useDeviceLocation = _ref2$useDeviceLocati === void 0 ? false : _ref2$useDeviceLocati, _ref2$computeQueryPar = _ref2.computeQueryParams, computeQueryParams = _ref2$computeQueryPar === void 0 ? function (params) { return params; } : _ref2$computeQueryPar, formatInputValue = _ref2.formatInputValue, _ref2$onHits = _ref2.onHits, onHits = _ref2$onHits === void 0 ? function () {} : _ref2$onHits, _ref2$onError = _ref2.onError, onError = _ref2$onError === void 0 ? function (e) { throw e; } : _ref2$onError, onRateLimitReached = _ref2.onRateLimitReached, onInvalidCredentials = _ref2.onInvalidCredentials; return { useDeviceLocation: useDeviceLocation, computeQueryParams: computeQueryParams, formatInputValue: formatInputValue, onHits: onHits, onError: onError, onRateLimitReached: onRateLimitReached, onInvalidCredentials: onInvalidCredentials }; }; var params = {}; var controls = {}; var configure = function configure(configuration) { params = extractParams(_objectSpread(_objectSpread({}, params), configuration)); controls = extractControls(_objectSpread(_objectSpread({}, controls), configuration)); return { params: params, controls: controls }; }; /* harmony default export */ __webpack_exports__["a"] = (configure); /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = { element: null }; /***/ }), /* 3 */ /***/ (function(module, exports) { var hasOwn = Object.prototype.hasOwnProperty; var toString = Object.prototype.toString; module.exports = function forEach (obj, fn, ctx) { if (toString.call(fn) !== '[object Function]') { throw new TypeError('iterator must be a function'); } var l = obj.length; if (l === +l) { for (var i = 0; i < l; i++) { fn.call(ctx, obj[i], i, obj); } } else { for (var k in obj) { if (hasOwn.call(obj, k)) { fn.call(ctx, obj[k], k, obj); } } } }; /***/ }), /* 4 */ /***/ (function(module, exports) { module.exports = function clone(obj) { return JSON.parse(JSON.stringify(obj)); }; /***/ }), /* 5 */ /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || new Function("return this")(); } catch (e) { // This works if the window reference is available if (typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /* 6 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony default export */ __webpack_exports__["default"] = ('1.19.0'); /***/ }), /* 7 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = ("\n"); /***/ }), /* 8 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // CONCATENATED MODULE: ./src/formatInputValue.js function formatInputValue(_ref) { var administrative = _ref.administrative, city = _ref.city, country = _ref.country, name = _ref.name, type = _ref.type; var out = "".concat(name).concat(type !== 'country' && country !== undefined ? ',' : '', "\n ").concat(city ? "".concat(city, ",") : '', "\n ").concat(administrative ? "".concat(administrative, ",") : '', "\n ").concat(country ? country : '').replace(/\s*\n\s*/g, ' ').trim(); return out; } // EXTERNAL MODULE: ./src/icons/address.svg var address = __webpack_require__(7); // CONCATENATED MODULE: ./src/icons/city.svg /* harmony default export */ var city = ("\n"); // CONCATENATED MODULE: ./src/icons/country.svg /* harmony default export */ var country = ("\n \n\n"); // CONCATENATED MODULE: ./src/icons/bus.svg /* harmony default export */ var bus = ("\n"); // CONCATENATED MODULE: ./src/icons/train.svg /* harmony default export */ var train = ("\n \n\n"); // CONCATENATED MODULE: ./src/icons/townhall.svg /* harmony default export */ var townhall = ("\n"); // CONCATENATED MODULE: ./src/icons/plane.svg /* harmony default export */ var plane = ("\n"); // CONCATENATED MODULE: ./src/formatDropdownValue.js var icons = { address: address["a" /* default */], city: city, country: country, busStop: bus, trainStation: train, townhall: townhall, airport: plane }; 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 = "".concat(icons[type].trim(), "\n").concat(name, "\n\n ").concat([city, administrative, country].filter(function (token) { return token !== undefined; }).join(', '), "").replace(/\s*\n\s*/g, ' '); return out; } // CONCATENATED MODULE: ./src/icons/algolia.svg /* harmony default export */ var algolia = (""); // CONCATENATED MODULE: ./src/icons/osm.svg /* harmony default export */ var osm = ("\n \n\n"); // CONCATENATED MODULE: ./src/defaultTemplates.js /* harmony default export */ var defaultTemplates = __webpack_exports__["a"] = ({ footer: "
\n ".concat(algolia.trim(), "\n using ").concat(osm.trim(), " data\n
"), value: formatInputValue, suggestion: formatDropdownValue }); /***/ }), /* 9 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ formatHit; }); // CONCATENATED MODULE: ./src/findCountryCode.js 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; } // CONCATENATED MODULE: ./src/findType.js 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'; } // CONCATENATED MODULE: ./src/formatHit.js function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 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 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 ? "".concat(defaultValue, " (").concat(highlightedValues[bestAttributes[1].index].value, ")") : "".concat(highlightedValues[bestAttributes[0].index].value, " (").concat(defaultValue, ")"); } function getBestPostcode(postcodes, highlightedPostcodes) { var defaultValue = highlightedPostcodes[0].value; // collect all other matches var bestAttributes = []; for (var i = 1; i < highlightedPostcodes.length; ++i) { if (highlightedPostcodes[i].matchLevel !== 'none') { bestAttributes.push({ index: i, words: highlightedPostcodes[i].matchedWords }); } } // no matches in this attribute, retrieve first value if (bestAttributes.length === 0) { return { postcode: postcodes[0], highlightedPostcode: defaultValue }; } // sort the matches by `desc(words)` 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; }); var postcode = postcodes[bestAttributes[0].index]; return { postcode: postcode, highlightedPostcode: highlightedPostcodes[bestAttributes[0].index].value }; } 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 county = hit.county && hit.county[0] !== name ? hit.county[0] : undefined; var _ref2 = hit.postcode && hit.postcode.length ? getBestPostcode(hit.postcode, hit._highlightResult.postcode) : { postcode: undefined, highlightedPostcode: undefined }, postcode = _ref2.postcode, highlightedPostcode = _ref2.highlightedPostcode; 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, county: county ? getBestHighlightedForm(hit._highlightResult.county) : undefined, postcode: highlightedPostcode }; var suggestion = { name: name, administrative: administrative, county: county, city: city, suburb: suburb, country: country, countryCode: findCountryCode(hit._tags), type: findType(hit._tags), latlng: { lat: hit._geoloc.lat, lng: hit._geoloc.lng }, postcode: postcode, postcodes: hit.postcode && hit.postcode.length ? hit.postcode : undefined }; // this is the value to put inside the 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // This file hosts our error definitions // We use custom error "types" so that we can act on them when we need it // e.g.: if error instanceof errors.UnparsableJSON then.. var inherits = __webpack_require__(21); function AlgoliaSearchError(message, extraProperties) { var forEach = __webpack_require__(3); var error = this; // try to get a stacktrace if (typeof Error.captureStackTrace === 'function') { Error.captureStackTrace(this, this.constructor); } else { error.stack = (new Error()).stack || 'Cannot get a stacktrace, browser is too old'; } this.name = 'AlgoliaSearchError'; this.message = message || 'Unknown error'; if (extraProperties) { forEach(extraProperties, function addToErrorObject(value, key) { error[key] = value; }); } } inherits(AlgoliaSearchError, Error); function createCustomError(name, message) { function AlgoliaSearchCustomError() { var args = Array.prototype.slice.call(arguments, 0); // custom message not set, use default if (typeof args[0] !== 'string') { args.unshift(message); } AlgoliaSearchError.apply(this, args); this.name = 'AlgoliaSearch' + name + 'Error'; } inherits(AlgoliaSearchCustomError, AlgoliaSearchError); return AlgoliaSearchCustomError; } // late exports to let various fn defs and inherits take place module.exports = { AlgoliaSearchError: AlgoliaSearchError, UnparsableJSON: createCustomError( 'UnparsableJSON', 'Could not parse the incoming response as JSON, see err.more for details' ), RequestTimeout: createCustomError( 'RequestTimeout', 'Request timed out before getting a response' ), Network: createCustomError( 'Network', 'Network issue, see err.more for details' ), JSONPScriptFail: createCustomError( 'JSONPScriptFail', '