{"version":3,"file":"storeFinder.js","mappings":";AAAA;AACA;AACA;AACA;AACA;AACA,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA,oBAAoB,6BAA6B;AACjD;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;;AAEP;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;;AAEA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,iCAAiC,gBAAgB;AACjD,MAAM;AACN,iCAAiC,gBAAgB;AACjD,MAAM;AACN;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA,qCAAqC,YAAY;AACjD,qCAAqC,sBAAsB,IAAI,qBAAqB,IAAI,aAAa,IAAI,cAAc;AACvH,qCAAqC,mBAAmB;AACxD,6CAA6C,iBAAiB,wBAAwB,YAAY;AAClG,oFAAoF,YAAY,4CAA4C,UAAU;AACtJ;AACA;;AAEA;;AAEA;AACA,uBAAuB,qCAAqC;AAC5D,GAAG;AACH;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA,WAAW;;AAEX;AACA,SAAS;AACT;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;AACA,oBAAoB,mFAAmF;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;;AAEP;AACA;AACA;;AAEA;AACA,OAAO;;AAEP;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA,8BAA8B,qCAAqC;AACnE;AACA;;AAEA;;AAEA;AACA;AACA,SAAS;;AAET;AACA,4BAA4B,uDAAuD;AACnF;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;;AAEA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,MAAM;AACN;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;;AAEA;AACA;AACA,QAAQ;AACR,oCAAoC,cAAc;AAClD;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH,CAAC","sources":["webpack://build/../missmoda/assets/javascripts/pages/storeFinder.js"],"sourcesContent":["window.google;\nwindow.geocoder;\nwindow.bounds;\nwindow.mapPlaces;\nwindow.searchBox;\nwindow.initialLatLang = { lat: -14.2400732, lng: -53.1805017 };\n\nwindow.statesInfo = {\n AC: {\n name: 'Acre',\n sigla: 'AC',\n metropolis: 'Rio Branco',\n latitude: -8.77,\n longitude: -70.5,\n },\n AL: {\n name: 'Alagoas',\n sigla: 'AL',\n metropolis: 'Maceió',\n latitude: -9.71,\n longitude: -35.73,\n },\n AM: {\n name: 'Amazonas',\n sigla: 'AM',\n metropolis: 'Manaus',\n latitude: -3.07,\n longitude: -61.66,\n },\n AP: {\n name: 'Amapá',\n sigla: 'AP',\n metropolis: 'Macapá',\n latitude: 1.41,\n longitude: -51.77,\n },\n BA: {\n name: 'Bahia',\n metropolis: 'Salvador',\n latitude: -12.96,\n longitude: -38.51,\n },\n CE: {\n name: 'Ceará',\n sigla: 'CE',\n metropolis: 'Fortaleza',\n latitude: -3.71,\n longitude: -38.54,\n },\n DF: {\n name: 'Distrito Federal',\n sigla: 'DF',\n metropolis: 'Brasília',\n latitude: -15.83,\n longitude: -47.86,\n },\n ES: {\n name: 'Espírito Santo',\n sigla: 'ES',\n metropolis: 'Vitória',\n latitude: -19.19,\n longitude: -40.34,\n },\n GO: {\n name: 'Goiás',\n sigla: 'GO',\n metropolis: 'Goiânia',\n latitude: -16.64,\n longitude: -49.31,\n },\n MA: {\n name: 'Maranhão',\n sigla: 'MA',\n metropolis: 'São Luís',\n latitude: -2.55,\n longitude: -44.3,\n },\n MG: {\n name: 'Minas Gerais',\n sigla: 'MG',\n metropolis: 'Belo Horizonte',\n latitude: -18.1,\n longitude: -44.38,\n },\n MS: {\n name: 'Mato Grosso do Sul',\n sigla: 'MS',\n metropolis: 'Campo Grande',\n latitude: -20.51,\n longitude: -54.54,\n },\n MT: {\n name: 'Mato Grosso',\n sigla: 'MT',\n metropolis: 'Cuiabá',\n latitude: -12.64,\n longitude: -55.42,\n },\n PA: {\n name: 'Pará',\n sigla: 'PA',\n metropolis: 'Belém',\n latitude: -5.53,\n longitude: -52.29,\n },\n PB: {\n name: 'Paraíba',\n sigla: 'PB',\n metropolis: 'João Pessoa',\n latitude: -7.06,\n longitude: -35.55,\n },\n PE: {\n name: 'Pernambuco',\n sigla: 'PE',\n metropolis: 'Recife',\n latitude: -8.28,\n longitude: -35.07,\n },\n PI: {\n name: 'Piauí',\n sigla: 'PI',\n metropolis: 'Teresina',\n latitude: -8.28,\n longitude: -43.68,\n },\n PR: {\n name: 'Paraná',\n sigla: 'PR',\n metropolis: 'Curitiba',\n latitude: -24.89,\n longitude: -51.55,\n },\n RJ: {\n name: 'Rio de Janeiro',\n sigla: 'RJ',\n metropolis: 'Rio de Janeiro',\n latitude: -22.84,\n longitude: -43.15,\n },\n RN: {\n name: 'Rio Grande do Norte',\n sigla: 'RN',\n metropolis: 'Natal',\n latitude: -5.22,\n longitude: -36.52,\n },\n RO: {\n name: 'Rondônia',\n sigla: 'RO',\n metropolis: 'Porto Velho',\n latitude: -11.22,\n longitude: -62.8,\n },\n RR: {\n name: 'Roraima',\n sigla: 'RR',\n metropolis: 'Boa Vista',\n latitude: -1.89,\n longitude: -61.22,\n },\n RS: {\n name: 'Rio Grande do Sul',\n sigla: 'RS',\n metropolis: 'Porto Alegre',\n latitude: -30.01,\n longitude: -51.22,\n },\n SC: {\n name: 'Santa Catarina',\n sigla: 'SC',\n metropolis: 'Florianopolis',\n latitude: -27.33,\n longitude: -49.44,\n },\n SE: {\n name: 'Sergipe',\n sigla: 'SE',\n metropolis: 'Aracaju',\n latitude: -10.9,\n longitude: -37.07,\n },\n SP: {\n name: 'São Paulo',\n sigla: 'SP',\n metropolis: 'São Paulo',\n latitude: -23.55,\n longitude: -46.64,\n },\n TO: {\n name: 'Tocantins',\n sigla: 'TO',\n metropolis: 'Palmas',\n latitude: -10.25,\n longitude: -48.25,\n },\n};\n\nwindow.storeFinder = {\n origPlaces: [],\n origPlacesSortedByState: [],\n quantityPlaces: 0,\n states: {},\n distance: function (lat1, lon1, lat2, lon2, unit) {\n if (lat1 == lat2 && lon1 == lon2) {\n return 0;\n } else {\n var radlat1 = (Math.PI * lat1) / 180;\n var radlat2 = (Math.PI * lat2) / 180;\n var theta = lon1 - lon2;\n var radtheta = (Math.PI * theta) / 180;\n var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);\n\n if (dist > 1) {\n dist = 1;\n }\n\n dist = Math.acos(dist);\n dist = (dist * 180) / Math.PI;\n dist = dist * 60 * 1.1515;\n\n if (unit == 'K') {\n dist = dist * 1.609344;\n }\n if (unit == 'N') {\n dist = dist * 0.8684;\n }\n\n return dist;\n }\n },\n getPlaceById: function (id) {\n var _this = this;\n var place;\n\n for (var i = 0; i < _this.origPlaces.length; i++) {\n if (_this.origPlaces[i].id == id) {\n place = _this.origPlaces[i];\n break;\n }\n }\n\n return place;\n },\n sortPlacesByState: function () {\n // Ordena os places por estado\n var _this = this;\n\n _this.origPlacesSortedByState.sort((a, b) => {\n var stateA = a.state.toLowerCase();\n var stateB = b.state.toLowerCase();\n\n if (stateA < stateB) {\n return -1;\n }\n if (stateA > stateB) {\n return 1;\n }\n\n return 0;\n });\n },\n renderPlacesByState: function (filter) {\n var _this = this;\n\n if (filter == 'all') {\n _this.emptyPlaces();\n\n _this.origPlaces.forEach((place, index) => {\n _this.renderPlace(place, index + 1);\n });\n\n _this.setPlaceMap(false, true, 4);\n _this.setQuantityPlaces(_this.origPlaces);\n } else {\n if (filter.state) {\n // pegando as infos do estado\n var state = statesInfo[filter.state];\n\n // filtrando places\n var resultsPlaces = _this.origPlaces.filter((place) => {\n return place.state == filter.state;\n });\n\n _this.emptyPlaces();\n\n resultsPlaces.forEach((place, index) => {\n _this.renderPlace(place, index + 1);\n });\n\n _this.setPlaceMap(state, false, 6);\n _this.setQuantityPlaces(resultsPlaces);\n }\n }\n },\n listAllStates: function () {\n var _this = this;\n var states = _this.states;\n var boxStates = document.querySelector('[data-select-states]');\n\n // Cria o elemente selecionar todos\n var selectAll = document.createElement('option');\n selectAll.value = 'all';\n selectAll.innerHTML = 'Selecionar Estado';\n\n boxStates.append(selectAll);\n\n // Percorre o json dos locais\n _this.origPlacesSortedByState.forEach((place, index) => {\n // Pega o estado atual\n var state = place.state;\n\n // Verifica se existe o estado dentro do objeto\n if (!states[state]) {\n // Cria o objeto dentro do objeto de estados\n states[state] = {};\n\n // Monta o HTML do box do estado\n var optionState = document.createElement('option');\n optionState.value = state;\n optionState.innerHTML = statesInfo[state].name;\n\n // Adiciona o html no select\n boxStates.append(optionState);\n }\n });\n },\n resetStateSelection: function () {\n var boxStates = document.querySelector('[data-select-states]');\n var options = boxStates.querySelectorAll('option');\n\n options.forEach((option) => {\n if (option.selected && option.value != 'All') {\n option.selected = false;\n options[0].selected = true;\n }\n });\n },\n setQuantityPlaces: function (_places) {\n // Seta a quntidade de itens encontrados ho cabeçalho da lista\n var quantityPlaces = _places.length;\n\n var boxQuantity = document.querySelector('[data-results-places-count]');\n\n console.info('_places', _places);\n console.info('_places.length', _places.length);\n\n if (quantityPlaces > 1) {\n boxQuantity.innerHTML = `${_places.length} Lojas encontradas`;\n } else if (quantityPlaces == 1) {\n boxQuantity.innerHTML = `${_places.length} Loja encontrada`;\n } else if (quantityPlaces <= 0) {\n boxQuantity.innerHTML = 'Nenhuma loja encontrada';\n }\n },\n emptyPlaces: function () {\n const boxPlaces = document.querySelector('[data-results-places-list]');\n boxPlaces.innerHTML = '';\n },\n renderPlace: function (_place, _index) {\n var _this = this;\n const boxPlaces = document.querySelector('[data-results-places-list]');\n var htmlPlace = document.createElement('li');\n\n htmlPlace.innerHTML = `\n
\n

${_place.name}

\n

${_place.address_line_1}, ${_place.neighborhood} - ${_place.city} - ${_place.state}

\n

${_place.first_phone}

\n Website

\n
Mostrar no mapa\n
\n `;\n\n htmlPlace.classList.add('store-list-item');\n\n boxPlaces.append(htmlPlace);\n boxPlaces.scroll({ top: 0, left: 0, behavior: 'smooth' });\n },\n setPlaceMap: function (_options, initial, zoom) {\n if (initial) {\n window.mapPlaces.setZoom(zoom);\n window.mapPlaces.setCenter(initialLatLang);\n } else {\n window.mapPlaces.setCenter({\n lat: Number(parseFloat(_options.latitude)),\n lng: Number(parseFloat(_options.longitude)),\n });\n window.mapPlaces.setZoom(zoom);\n }\n },\n initMap: function () {\n var _this = this;\n\n // Create a map object and specify the DOM element for display.\n window.geocoder = new google.maps.Geocoder();\n window.mapPlaces = new google.maps.Map(document.getElementById('map-canvas'), {\n // Centro do Brasil\n center: initialLatLang,\n scrollwheel: true,\n mapTypeId: 'roadmap',\n zoom: 4,\n zoomControlOptions: {\n position: google.maps.ControlPosition.RIGHT_TOP,\n style: google.maps.ZoomControlStyle.LARGE,\n },\n });\n\n // Seta o campo de busca\n const input = document.getElementById('pac-input');\n\n window.searchBox = new google.maps.places.SearchBox(input);\n\n window.mapPlaces.addListener('bounds_changed', function () {\n window.searchBox.setBounds(window.mapPlaces.getBounds());\n });\n\n window.searchBox.addListener('places_changed', function () {\n var places = window.searchBox.getPlaces();\n var resultsPlaces = [];\n var bounds;\n\n // Se não tem lugar retorna ao estado inicial do mapa\n if (places.length == 0) {\n _this.setPlaceMap(false, true, 4);\n\n return;\n }\n\n // Se tem lugar seta no mapa\n if (places.length == 1) {\n bounds = new google.maps.LatLngBounds();\n\n places.forEach((place) => {\n if (place.geometry.viewport) {\n // Only geocodes have viewport.\n bounds.union(place.geometry.viewport);\n } else {\n bounds.extend(place.geometry.location);\n }\n\n resultsPlaces = _this.findPlacesInMap(place);\n\n _this.emptyPlaces();\n\n resultsPlaces.forEach((place, index) => {\n _this.renderPlace(place, index + 1);\n });\n\n _this.setQuantityPlaces(resultsPlaces);\n });\n }\n\n window.mapPlaces.fitBounds(bounds);\n });\n\n // reseta o mapa se o input fica vazio\n input.addEventListener('change', function () {\n if (this.value == '') {\n _this.renderPlacesByState('all');\n _this.setQuantityPlaces(_this.origPlaces);\n _this.setPlaceMap(false, true, 4);\n }\n });\n\n _this.setMarkersAndClusters(_this.origPlaces);\n },\n setMarkersAndClusters: function (_places) {\n var _this = this;\n\n var markers = _places.map(function (place, i) {\n // Posiciona o texto do label de acordo com a quantidade de caracteres\n var point = i + 1 < 9 ? [4, 33] : i + 1 < 100 ? [8, 33] : [12, 33];\n\n var marker = new MarkerWithLabel({\n position: { lat: Number(parseFloat(place.latitude)), lng: Number(parseFloat(place.longitude)) },\n map: window.mapPlaces,\n draggable: false,\n placeId: place.id,\n labelContent: '' /*+ (i + 1).toString()*/ + '',\n labelAnchor: new google.maps.Point(point[0], point[1]),\n labelClass: 'pin-label',\n labelInBackground: false,\n icon: {\n url: \"../images/pin.svg\",\n scaledSize: new google.maps.Size(32, 32),\n },\n });\n\n // Quando clica no pin do mapa aproxima\n google.maps.event.addListener(marker, 'click', function (e) {\n var place = _this.getPlaceById(this.placeId);\n\n _this.setPlaceMap(place, false, 17);\n });\n\n return marker;\n });\n\n new MarkerClusterer(window.mapPlaces, markers, {\n styles: [\n {\n url: '/images/cluster.svg',\n height: 50,\n width: 50,\n textColor: '#da9d00',\n textSize: 22,\n },\n ],\n maxZoom: 15,\n });\n },\n findPlaceLocation: function (position) {\n var _this = this;\n var resultsPlaces = [];\n\n var coordinates = {\n lat: position.coords.latitude,\n lng: position.coords.longitude,\n };\n\n // console.info('buscando por', coordinates);\n\n window.geocoder.geocode({ location: coordinates, region: 'BR' }, function (results, status) {\n if (status == google.maps.GeocoderStatus.OK) {\n resultsPlaces = _this.findPlacesInMap(results[0], status);\n\n _this.emptyPlaces();\n\n resultsPlaces.forEach((place, index) => {\n _this.renderPlace(place, index + 1);\n });\n\n _this.setQuantityPlaces(resultsPlaces);\n _this.setPlaceMap({ latitude: coordinates.lat, longitude: coordinates.lng }, false, 11);\n _this.resetStateSelection();\n }\n });\n },\n findPlacesInMap: function (_placeMap) {\n var _this = this;\n\n var point = _placeMap.geometry.location;\n var pointLit = { lat: point.lat(), lng: point.lng() };\n\n const getPlacesByState = (_state) => {\n // Busca places com o mesmo estado selecionado\n var places = _this.origPlaces.filter(function (curr, i) {\n if (curr.state == _state) {\n return curr;\n }\n });\n\n return places;\n };\n\n const getPlacesByCity = (_city) => {\n // Busca places com a mesma cidade selecionada\n var places = _this.origPlaces.filter(function (curr, i) {\n if (curr.city.toLowerCase() == _city.toLowerCase()) {\n return curr;\n }\n });\n\n return places;\n };\n\n const getPlacesByDistance = (_lat1, _lng1, _lat2, _lng2, _raio) => {\n // Busca places pela distancia entre os pontos considerando o raio em Km passados por parametro\n var distanceKm = _this.distance(_lat1, _lng1, _lat2, _lng2, 'K');\n\n // console.info('distance', parseFloat(distanceKm), parseFloat(_raio));\n\n if (parseFloat(distanceKm) < parseFloat(_raio)) {\n return true;\n } else {\n return false;\n }\n };\n\n if (_placeMap.types[0] == 'administrative_area_level_1') {\n // Busca para estados\n closest = getPlacesByState(_placeMap.address_components[0].short_name);\n } else if (_placeMap.types[0] == 'locality') {\n // Busca para cidades\n\n closest = getPlacesByCity(_placeMap.address_components[0].long_name);\n } else if (_placeMap.types[0] == 'sublocality_level_1') {\n // Busca para bairros e distritos (proximidade de 10Km)\n closest = _this.origPlaces.filter(function (curr, i) {\n if (getPlacesByDistance(pointLit.lat, pointLit.lng, curr.latitude, curr.longitude, 10)) {\n return curr;\n }\n });\n } else {\n // Busca para o restante dos lugares (proximidade de 20Km)\n closest = _this.origPlaces.filter((curr) => {\n if (getPlacesByDistance(pointLit.lat, pointLit.lng, curr.latitude, curr.longitude, 20)) {\n return curr;\n }\n });\n }\n\n return closest;\n },\n init: function (_places) {\n var _this = this;\n\n const mapWrapper = document.querySelector('[data-results-map]');\n const listWrapper = document.querySelector('[data-results-places]');\n\n _this.origPlaces = JSON.parse(JSON.stringify(_places));\n _this.origPlacesSortedByState = JSON.parse(JSON.stringify(_this.origPlaces));\n _this.quantityPlaces = _this.origPlaces;\n\n _this.sortPlacesByState();\n _this.initMap();\n _this.listAllStates();\n _this.renderPlacesByState('all');\n\n // Quando clica no botão mostrar no mapa\n var places = document.querySelectorAll('[data-place]');\n\n // usando jquery pq os elementos sao criados e excluidos do dom\n $(document).on('click', '[data-place]', function (event) {\n event.preventDefault();\n\n // Fecha a lista e abre o mapa no mobile\n listWrapper.classList.remove('open');\n mapWrapper.classList.add('open');\n\n var place = _this.getPlaceById($(this).data('place-id'));\n\n _this.setPlaceMap(place, false, 17);\n });\n\n // Quando seleciona o estado\n document.querySelector('[data-select-states]').addEventListener('change', (e) => {\n e.preventDefault();\n\n const state = e.target.value;\n\n if (state == 'all') {\n _this.renderPlacesByState('all');\n } else {\n _this.renderPlacesByState({ state: state });\n }\n });\n\n // Quando usa geolocalização\n document.querySelector('[data-geolocation]').addEventListener('click', (e) => {\n e.preventDefault();\n\n const getLocation = () => {\n if (navigator.geolocation) {\n navigator.geolocation.getCurrentPosition(getPosition);\n } else {\n x.innerHTML = 'Geolocation is not supported by this browser.';\n }\n };\n\n const getPosition = (position) => {\n _this.findPlaceLocation(position);\n };\n\n getLocation();\n });\n\n // Lida com a abertura e fechamento da lista e do mapa no mobile\n document.querySelector('[data-open-list]').addEventListener('click', (e) => {\n e.preventDefault();\n\n if (!listWrapper.classList.contains('open')) {\n listWrapper.classList.add('open');\n }\n if (mapWrapper.classList.contains('open')) {\n mapWrapper.classList.remove('open');\n }\n });\n\n document.querySelector('[data-open-map]').addEventListener('click', (e) => {\n e.preventDefault();\n\n if (!mapWrapper.classList.contains('open')) {\n mapWrapper.classList.add('open');\n }\n if (listWrapper.classList.contains('open')) {\n listWrapper.classList.remove('open');\n }\n });\n },\n};\n\nconst loadShops = (places) => {\n storeFinder.init(places);\n};\n\ndocument.addEventListener('DOMContentLoaded', () => {\n $.getJSON('/locais', function (data) {\n loadShops(data);\n });\n});\n"],"names":[],"sourceRoot":""}