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UC,EAAGC,GAAK,OAAOA,EAAExC,QAAQ5C,GAAoB4I,cAAczD,EAAEvC,QAAQ5C,GAAsB,IAClI8B,EAAMN,YAAY,CAAEO,MAAO0E,GAC/B,EARJkC,EASI/E,EACJ8E,EAAOvB,iBAAiB,UAAU,SAAUC,GACxC,IAAIhH,EACArC,EAAQ2K,EAAO3K,MACQ,QAA1BqC,EAAKuI,EAAS5K,UAA2B,IAAPqC,GAAyBA,EAAGT,KAAKgJ,GACpE7G,EAAMV,sBACNU,EAAMH,YACV,IACO,CAAC,EACZ,GACJ,GACJ,EAIAzB,EAAoB2B,UAAUZ,KAAO,WACjC3B,KAAK6B,qBACL7B,KAAKgC,sBACLhC,KAAK+B,uBACT,EACOnB,CACX,CAzWwC,GA2WxC,W","sources":["webpack:///./helpers/index.ts","webpack:///./modules/branch-finder/index.ts"],"sourcesContent":["/**\n * Toggles hidden attribute on HTML elements\n */\nexport var toggleHidden = function (element, shouldHide) {\n if (shouldHide) {\n element.setAttribute('hidden', 'hidden');\n }\n else {\n element.removeAttribute('hidden');\n }\n};\n/**\n * Converts metres to miles\n */\nexport var metresToMiles = function (meters) {\n return meters * 0.000621371;\n};\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nimport { metresToMiles, toggleHidden } from \"../../helpers\";\nvar latLngDataAttribute = 'branchLatLng';\nvar distanceDataAttribute = 'branchDistance';\nvar titleDataAttribute = 'branchTitle';\nvar white = 'rgba(255, 255, 255, 1)';\nvar blue = 'rgba(0, 67, 122, 1)';\nvar gold = 'rgba(251, 186, 0, 1)';\n/**\n * Manages progressively enhancing branch finder lists\n */\nvar BranchFinderHandler = /** @class */ (function () {\n function BranchFinderHandler(props) {\n var _a;\n this.wrapper = undefined;\n this.locationFilter = undefined;\n this.geoLocationFilter = undefined;\n this.sortOrderFilter = undefined;\n this.map = undefined;\n this.list = undefined;\n this.autoComplete = undefined;\n this.googleMap = undefined;\n this.googleMapMarkers = [];\n this.googleMapDefaultZoom = undefined;\n this.minimumIncludedMapLocations = undefined;\n this.init = this.init.bind(this);\n this.initLocationFilter = this.initLocationFilter.bind(this);\n this.resetLocationFilter = this.resetLocationFilter.bind(this);\n this.initGeoLocationFilter = this.initGeoLocationFilter.bind(this);\n this.initSortOrderFilter = this.initSortOrderFilter.bind(this);\n this.csvToLatLng = this.csvToLatLng.bind(this);\n this.renderItems = this.renderItems.bind(this);\n this.renderMap = this.renderMap.bind(this);\n this.renderMapLocations = this.renderMapLocations.bind(this);\n this.destroyMap = this.destroyMap.bind(this);\n this.sortItemsByDistance = this.sortItemsByDistance.bind(this);\n this.wrapper = props.wrapper;\n this.locationFilter = props.locationFilter;\n this.geoLocationFilter = props.geoLocationFilter;\n this.sortOrderFilter = props.sortOrderFilter;\n this.map = props.map;\n this.list = props.list;\n this.googleMapDefaultZoom = props.googleMapDefaultZoom;\n this.minimumIncludedMapLocations = (_a = props.minimumIncludedMapLocations) !== null && _a !== void 0 ? _a : 2;\n this.init();\n }\n /**\n * Re-renders the location item list\n */\n BranchFinderHandler.prototype.renderItems = function (_a) {\n var _this = this;\n var items = _a.items, shouldRenderIndexing = _a.shouldRenderIndexing;\n this.list.innerHTML = '';\n items.forEach(function (item, index) {\n var indexElement = item.querySelector('[data-branch-index]');\n var distanceElement = item.querySelector('[data-branch-distance]');\n var icon = \"\\n \\n \".concat(index + 1, \"\\n \");\n if (indexElement) {\n toggleHidden(indexElement, !shouldRenderIndexing);\n indexElement.innerHTML = shouldRenderIndexing ? icon : '';\n }\n if (distanceElement) {\n if (shouldRenderIndexing) {\n var distanceInMetres = Number(item.dataset[distanceDataAttribute]);\n var distanceInMiles = metresToMiles(distanceInMetres);\n if (!isNaN(distanceInMiles)) {\n distanceElement.innerHTML = \"(\".concat(Math.trunc(distanceInMiles).toString(), \" miles)\");\n }\n else {\n distanceElement.innerHTML = '';\n }\n }\n else {\n distanceElement.innerHTML = '';\n }\n toggleHidden(distanceElement, !shouldRenderIndexing);\n }\n _this.list.appendChild(item);\n });\n };\n /**\n * Renders the map wrapper and initialises the Google map\n */\n BranchFinderHandler.prototype.renderMap = function (_a) {\n var zoom = _a.zoom, center = _a.center;\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_b) {\n this.destroyMap();\n toggleHidden(this.map, false);\n this.googleMap = new google.maps.Map(this.map, {\n zoom: zoom,\n center: center,\n mapTypeControl: false,\n fullscreenControl: false,\n mapId: 'branch-finder',\n });\n return [2 /*return*/];\n });\n });\n };\n /**\n * Renders the markers for the user's searched location and the branches on the Google map\n */\n BranchFinderHandler.prototype.renderMapLocations = function (_a) {\n var _b, _c;\n var searchLocation = _a.searchLocation;\n return __awaiter(this, void 0, void 0, function () {\n var _d, AdvancedMarkerElement, PinElement, branchLocations, items, bounds, pinBackground, i, closestLatLng;\n var _this = this;\n return __generator(this, function (_e) {\n switch (_e.label) {\n case 0: return [4 /*yield*/, google.maps.importLibrary(\"marker\")];\n case 1:\n _d = _e.sent(), AdvancedMarkerElement = _d.AdvancedMarkerElement, PinElement = _d.PinElement;\n branchLocations = [];\n items = Array.from((_c = (_b = this.list) === null || _b === void 0 ? void 0 : _b.children) !== null && _c !== void 0 ? _c : []);\n items.forEach(function (item) {\n var title = item.dataset[titleDataAttribute];\n var latLng = _this.csvToLatLng(item.dataset[latLngDataAttribute]);\n if (latLng !== null) {\n var distance = window.google.maps.geometry.spherical.computeDistanceBetween(searchLocation, latLng);\n item.dataset[distanceDataAttribute] = Math.trunc(distance).toString();\n branchLocations.push({\n title: title,\n latLng: latLng,\n distance: distance\n });\n }\n });\n branchLocations.sort(function (a, b) { return a.distance - b.distance; });\n this.renderMap({\n zoom: this.googleMapDefaultZoom,\n center: searchLocation\n });\n this.sortOrderFilter.querySelector('select').value = '3';\n bounds = new window.google.maps.LatLngBounds();\n pinBackground = new PinElement({\n glyphColor: blue,\n borderColor: blue,\n background: gold,\n });\n this.googleMapMarkers.push(new AdvancedMarkerElement({\n position: searchLocation,\n map: this.googleMap,\n title: \"We think you're here\",\n content: pinBackground.element\n }));\n branchLocations.forEach(function (branchLocation, index) {\n var pinBackground = new PinElement({\n glyph: (index + 1).toString(),\n glyphColor: white,\n borderColor: blue,\n background: blue,\n });\n _this.googleMapMarkers.push(new AdvancedMarkerElement({\n position: branchLocation.latLng,\n map: _this.googleMap,\n title: branchLocation.title,\n content: pinBackground.element\n }));\n });\n bounds.extend(searchLocation);\n for (i = 0; i < branchLocations.length; i++) {\n if (i < this.minimumIncludedMapLocations) {\n closestLatLng = branchLocations[i].latLng;\n bounds.extend(closestLatLng);\n }\n }\n this.googleMap.fitBounds(bounds);\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Converts a valid CSV to a Google maps LatLng object\n */\n BranchFinderHandler.prototype.csvToLatLng = function (csv) {\n var csvParts = csv.split(',');\n if (csvParts.length <= 1) {\n console.debug(\"csv \".concat(csv, \" is not in valid coords format\"));\n return null;\n }\n var lat = Number(csvParts[0]);\n var lng = Number(csvParts[1]);\n if (isNaN(lat) || isNaN(lng)) {\n console.debug(\"csv \".concat(csv, \" is not valid latLng\"));\n return null;\n }\n var latLng = new window.google.maps.LatLng({\n lat: lat,\n lng: lng\n });\n return latLng;\n };\n /**\n * Hides the map wrapper and tears down the Google map instance\n */\n BranchFinderHandler.prototype.destroyMap = function () {\n this.map.setAttribute('hidden', 'hidden');\n this.googleMapMarkers.forEach(function (marker) {\n marker.setMap(null);\n marker = null;\n });\n this.googleMapMarkers = [];\n this.googleMap = null;\n };\n /**\n * Sorts the location item list by proximity to the user's seatrched location, ordered by closest first\n */\n BranchFinderHandler.prototype.sortItemsByDistance = function () {\n var _a, _b;\n var items = Array.from((_b = (_a = this.list) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []);\n var sortedItems = items.sort(function (a, b) {\n var aDistance = Number(a.dataset[distanceDataAttribute]);\n var bDistance = Number(b.dataset[distanceDataAttribute]);\n return aDistance - bDistance;\n });\n this.renderItems({ items: sortedItems, shouldRenderIndexing: true });\n };\n /**\n * Initialises the location search filter\n */\n BranchFinderHandler.prototype.initLocationFilter = function () {\n var _this = this;\n var input = this.locationFilter.querySelector('input');\n var bounds = new window.google.maps.LatLngBounds();\n bounds.extend(new window.google.maps.LatLng(49.64828404100335, -10.963513944150023));\n bounds.extend(new window.google.maps.LatLng(59.340361664775195, -0.04310367356441767));\n this.autoComplete = new window.google.maps.places.Autocomplete(input, {\n bounds: bounds,\n strictBounds: false,\n });\n this.autoComplete.setFields([\"place_id\", \"geometry\", \"name\"]);\n this.autoComplete.addListener(\"place_changed\", function () { return __awaiter(_this, void 0, void 0, function () {\n var place, searchLocation;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n place = this.autoComplete.getPlace();\n if (!(place && place.geometry)) return [3 /*break*/, 2];\n searchLocation = place.geometry.location;\n return [4 /*yield*/, this.renderMapLocations({ searchLocation: searchLocation })];\n case 1:\n _a.sent();\n this.sortItemsByDistance();\n _a.label = 2;\n case 2: return [2 /*return*/];\n }\n });\n }); });\n /**\n * Jump through an absurd number of hoops to support the user hitting enter in the Google Maps Autocomplete\n * because it's 2023 now but the control still doesn't support it\n */\n this.locationFilter.addEventListener('submit', function (event) {\n event.preventDefault();\n var service = new window.google.maps.places.AutocompleteService();\n var input = _this.autoComplete.getPlace().name;\n service.getPlacePredictions({\n input: input,\n locationBias: bounds\n }, function (predictions, status) {\n if (status === window.google.maps.places.PlacesServiceStatus.OK && predictions.length > 0) {\n var place = predictions[0];\n var placeId = place['place_id'];\n var geoCoder = new google.maps.Geocoder();\n geoCoder\n .geocode({ placeId: placeId })\n .then(function (_a) {\n var results = _a.results;\n return __awaiter(_this, void 0, void 0, function () {\n var result, searchLocation;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (!(results.length > 0)) return [3 /*break*/, 2];\n result = results[0];\n searchLocation = result.geometry.location;\n return [4 /*yield*/, this.renderMapLocations({ searchLocation: searchLocation })];\n case 1:\n _b.sent();\n this.sortItemsByDistance();\n _b.label = 2;\n case 2: return [2 /*return*/];\n }\n });\n });\n })\n .catch(function (e) { return console.debug(\"Geocoder failed due to: \" + e); });\n }\n });\n });\n };\n /**\n * Resets the location search filter to initial state\n */\n BranchFinderHandler.prototype.resetLocationFilter = function () {\n var input = this.locationFilter.querySelector('input');\n input.value = '';\n };\n /**\n * Initialises the geolocation search filter\n */\n BranchFinderHandler.prototype.initGeoLocationFilter = function () {\n var _this = this;\n this.geoLocationFilter.addEventListener('click', function () {\n window.navigator.geolocation.getCurrentPosition(function (position) { return __awaiter(_this, void 0, void 0, function () {\n var coords, searchLocation;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n coords = position.coords;\n searchLocation = new window.google.maps.LatLng({\n lat: coords.latitude,\n lng: coords.longitude\n });\n return [4 /*yield*/, this.renderMapLocations({ searchLocation: searchLocation })];\n case 1:\n _a.sent();\n this.resetLocationFilter();\n this.sortItemsByDistance();\n return [2 /*return*/];\n }\n });\n }); }, function () {\n // TODO - if anything\n });\n });\n };\n /**\n * Initialises the location search results sorter\n */\n BranchFinderHandler.prototype.initSortOrderFilter = function () {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function () {\n var select, items, handlers;\n var _c;\n var _this = this;\n return __generator(this, function (_d) {\n select = this.sortOrderFilter.querySelector('select');\n items = Array.from((_b = (_a = this.list) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []);\n handlers = (_c = {},\n _c['1'] = function () {\n var sortedItems = items.sort(function (a, b) { return a.dataset[titleDataAttribute].localeCompare(b.dataset[titleDataAttribute]); });\n _this.renderItems({ items: sortedItems });\n },\n _c['2'] = function () {\n var sortedItems = items.sort(function (a, b) { return b.dataset[titleDataAttribute].localeCompare(a.dataset[titleDataAttribute]); });\n _this.renderItems({ items: sortedItems });\n },\n _c);\n select.addEventListener('change', function (event) {\n var _a;\n var value = select.value;\n (_a = handlers[value]) === null || _a === void 0 ? void 0 : _a.call(handlers);\n _this.resetLocationFilter();\n _this.destroyMap();\n });\n return [2 /*return*/];\n });\n });\n };\n /**\n * Initialises the module\n */\n BranchFinderHandler.prototype.init = function () {\n this.initLocationFilter();\n this.initSortOrderFilter();\n this.initGeoLocationFilter();\n };\n return BranchFinderHandler;\n}());\nexport { BranchFinderHandler };\nexport default BranchFinderHandler;\n"],"names":["toggleHidden","element","shouldHide","setAttribute","removeAttribute","metresToMiles","meters","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","__generator","body","f","y","t","g","_","label","sent","trys","ops","verb","Symbol","iterator","this","n","v","op","TypeError","call","pop","length","push","distanceDataAttribute","titleDataAttribute","blue","BranchFinderHandler","props","_a","wrapper","undefined","locationFilter","geoLocationFilter","sortOrderFilter","map","list","autoComplete","googleMap","googleMapMarkers","googleMapDefaultZoom","minimumIncludedMapLocations","init","bind","initLocationFilter","resetLocationFilter","initGeoLocationFilter","initSortOrderFilter","csvToLatLng","renderItems","renderMap","renderMapLocations","destroyMap","sortItemsByDistance","prototype","_this","items","shouldRenderIndexing","innerHTML","forEach","item","index","indexElement","querySelector","distanceElement","icon","concat","distanceInMetres","Number","dataset","distanceInMiles","isNaN","Math","trunc","toString","appendChild","zoom","center","_b","google","maps","Map","mapTypeControl","fullscreenControl","mapId","_c","searchLocation","_d","AdvancedMarkerElement","PinElement","branchLocations","bounds","pinBackground","i","closestLatLng","_e","importLibrary","Array","from","children","title","latLng","distance","window","geometry","spherical","computeDistanceBetween","sort","a","b","LatLngBounds","glyphColor","borderColor","background","position","content","branchLocation","glyph","extend","fitBounds","csv","csvParts","split","console","debug","lat","lng","LatLng","marker","setMap","sortedItems","input","places","Autocomplete","strictBounds","setFields","addListener","place","getPlace","location","addEventListener","event","preventDefault","service","AutocompleteService","name","getPlacePredictions","locationBias","predictions","status","PlacesServiceStatus","OK","placeId","Geocoder","geocode","results","catch","navigator","geolocation","getCurrentPosition","coords","latitude","longitude","select","handlers","localeCompare"],"sourceRoot":""}