{"version":3,"sources":["webpack:///./Scripts/Components/StationMap.js","webpack:///./Scripts/Hooks/useGeolocationPosition.js","webpack:///./Scripts/Hooks/useGoogleMaps.js","webpack:///./Scripts/Hooks/useNavigatorPermissionsQuery.js","webpack:///./Scripts/Hooks/useRefreshGeolocationPositionIfPermissionGranted.js","webpack:///./Scripts/Hooks/useSortedStations.js","webpack:///./Scripts/Services/GoogleMaps.js"],"names":["props","divRef","useRef","isRendered","maps","useGoogleMaps","useEffect","current","lat","long","location","LatLng","mapProp","center","zoom","map","Map","stationMarker","Marker","position","title","name","icon","path","fillColor","color","fillOpacity","strokeWeight","scale","anchor","Point","infoWindow","google","InfoWindow","maxWidth","pixelOffset","Size","content","address","phone","event","addListener","open","setZoom","ref","className","useGeolocationPosition","useState","geolocationPosition","setGeolocationPosition","refreshGeolocationPosition","navigator","geolocation","getCurrentPosition","api","setApi","useNavigatorPermissionsQuery","query","status","setStatus","refreshStatus","permissions","then","useRefreshGeolocationPositionIfPermissionGranted","geolocationPermission","state","useSortedStations","stations","googleMaps","filter","station","onlyVisibleInTireHotel","sortedStations","setSortedStations","length","p0","coords","latitude","longitude","newSortedStations","sort","a","b","geometry","spherical","computeDistanceBetween","coordinatesLat","coordinatesLong","instance","promise","Promise","resolve","script","document","createElement","src","async","defer","onload","head","appendChild"],"mappings":"4IA2EA,QAvEmB,SAACA,GAEhB,IAAMC,GAASC,cACTC,GAAaD,aAAO,GAGpBE,GAAOC,UA8Db,OA5DAC,gBAAU,WACN,GACIF,GACAH,EAAOM,UACNJ,EAAWI,SAFZH,MAGAJ,KAAOQ,KAHPJ,MAIAJ,KAAOS,KACT,CACE,IAAMC,EAAW,IAAIN,EAAKO,OAAOX,EAAMQ,IAAKR,EAAMS,MAC5CG,EAAU,CACZC,OAAQH,EACRI,KAAM,IAGJC,EAAM,IAAIX,EAAKY,IAAIf,EAAOM,QAASK,GAEnCK,EAAgB,IAAIb,EAAKc,OAAO,CAClCC,SAAUT,EACVK,IAAKA,EACLK,M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AAAgB,EAAsBN,cAAtB,eAA8BO,QAE9Bf,IATAc,EAAsBJ,kBAW3B,CAACZ,EAAqBgB,EAAsBN,S,izCChBpC,SAASQ,EAAT,GAIZ,IAHClB,EAGD,EAHCA,oBACAmB,EAED,EAFCA,SACAC,EACD,EADCA,WACD,KAC6CrB,cAASoB,EAASE,QAAO,SAACC,GAAD,OAAcA,EAAQC,2BAD5F,GACQC,EADR,KACwBC,EADxB,KAyBC,OAtBAnE,gBAAU,WACN,GAAK0C,GAA2C,IAApBmB,EAASO,QAAiBN,EAAtD,CAGA,IAAMO,EAAK,IAAIP,EAAWzD,OACtBqC,EAAoB4B,OAAOC,SAC3B7B,EAAoB4B,OAAOE,WAEzBC,EAAoB,EAAIZ,GAAUa,MACpC,SAACC,EAAGC,GAAJ,OACId,EAAWe,SAASC,UAAUC,uBAC1B,IAAIjB,EAAWzD,OAAOsE,EAAEK,eAAgBL,EAAEM,iBAC1CZ,GAEJP,EAAWe,SAASC,UAAUC,uBAC1B,IAAIjB,EAAWzD,OAAOuE,EAAEI,eAAgBJ,EAAEK,iBAC1CZ,MAGZF,EAAkBM,MACnB,CAAC/B,EAAqBmB,EAAUC,IAE5BI,I,8CClCJ,IAAMpE,EAAO,CAChBoF,SAAU,KACVC,QAAS,IAAIC,SAAQ,SAACC,GAClB,IAAMC,EAASC,SAASC,cAAc,UACtCF,EAAOG,IACH,4IACJH,EAAOI,OAAQ,EACfJ,EAAOK,OAAQ,EACfL,EAAOM,OAAS,WACZ9F,EAAKoF,SAAWxD,OAAO5B,KACvBuF,EAAQvF,EAAKoF,WAEjBK,SAASM,KAAKC,YAAYR","file":"424.e896f6d076008f3ca431.js","sourcesContent":["import React, { useRef } from 'react'\r\nimport { useEffect } from 'react'\r\nimport { useGoogleMaps } from '../Hooks'\r\n\r\nconst StationMap = (props) => {\r\n // REF\r\n const divRef = useRef()\r\n const isRendered = useRef(false)\r\n\r\n // HOOKS\r\n const maps = useGoogleMaps()\r\n\r\n useEffect(() => {\r\n if (\r\n maps &&\r\n divRef.current &&\r\n !isRendered.current &&\r\n props?.lat &&\r\n props?.long\r\n ) {\r\n const location = new maps.LatLng(props.lat, props.long)\r\n const mapProp = {\r\n center: location,\r\n zoom: 11,\r\n }\r\n\r\n const map = new maps.Map(divRef.current, mapProp)\r\n\r\n const stationMarker = new maps.Marker({\r\n position: location,\r\n map: map,\r\n title: props.name,\r\n icon: {\r\n path: 'M11.83.09A8.08,8.08,0,0,0,3.75,8.17c0,2.37,1.89,6.37,3.49,9.37.81,1.52,1.69,3.08,2.49,4.28,1.3,2,1.61,2.18,2.1,2.18s.8-.24,2.11-2.18c.77-1.2,1.69-2.76,2.49-4.28,1.59-3,3.48-7,3.48-9.37A8.08,8.08,0,0,0,11.83.09Zm0,11.05a3,3,0,1,1,3-3A3,3,0,0,1,11.83,11.14Z',\r\n fillColor: props.color,\r\n fillOpacity: 1,\r\n strokeWeight: 0,\r\n scale: 1.2,\r\n anchor: new maps.Point(20, 25),\r\n },\r\n })\r\n const infoWindow = new google.maps.InfoWindow({\r\n maxWidth: 350,\r\n pixelOffset: new google.maps.Size(-10, -25),\r\n position: location,\r\n content:\r\n '
' +\r\n '
' +\r\n '' +\r\n props.name +\r\n '' +\r\n '
' +\r\n '' +\r\n props.address +\r\n '' +\r\n '
Tel: ' +\r\n `` +\r\n props.phone +\r\n '' +\r\n '
' +\r\n '
',\r\n })\r\n\r\n maps.event.addListener(stationMarker, 'click', () => {\r\n infoWindow.open(map)\r\n map.setZoom(16)\r\n })\r\n\r\n isRendered.current = true\r\n }\r\n }, [divRef, maps])\r\n\r\n return
\r\n}\r\n\r\nexport default StationMap\r\n","import { useState } from 'react'\r\n\r\nexport default function useGeolocationPosition() {\r\n const [geolocationPosition, setGeolocationPosition] = useState(null)\r\n function refreshGeolocationPosition() {\r\n navigator?.geolocation?.getCurrentPosition?.(setGeolocationPosition)\r\n }\r\n return { geolocationPosition, refreshGeolocationPosition }\r\n}\r\n","import { useState, useEffect } from 'react'\r\nimport { maps } from '../Services/GoogleMaps'\r\n\r\nexport default function useGoogleMaps() {\r\n const [api, setApi] = useState(maps.instance)\r\n useEffect(() => {\r\n if (!api) {\r\n maps.promise.then(setApi)\r\n }\r\n }, [api])\r\n return api\r\n}\r\n","import { useState } from 'react'\r\n\r\nexport default function useNavigatorPermissionsQuery(query) {\r\n const [status, setStatus] = useState(null)\r\n function refreshStatus() {\r\n navigator?.permissions?.query(query)?.then(setStatus)\r\n }\r\n return { status, refreshStatus }\r\n}\r\n","import { useEffect } from 'react'\r\n\r\nexport default function useRefreshGeolocationPositionIfPermissionGranted({\r\n geolocationPermission,\r\n geolocationPosition,\r\n refreshGeolocationPosition,\r\n}) {\r\n useEffect(() => {\r\n // init permission status\r\n if (!geolocationPermission.status) {\r\n geolocationPermission.refreshStatus()\r\n return\r\n }\r\n\r\n // eagerly init position if permission already granted\r\n if (\r\n !geolocationPosition &&\r\n geolocationPermission.status?.state === 'granted'\r\n ) {\r\n refreshGeolocationPosition()\r\n }\r\n }, [geolocationPosition, geolocationPermission.status])\r\n}\r\n","import { useState, useEffect } from 'react'\r\n\r\n/**\r\n * NOTE: if stations === sortedStations, no sort has yet occurred\r\n */\r\nexport default function useSortedStations({\r\n geolocationPosition,\r\n stations,\r\n googleMaps,\r\n}) {\r\n const [sortedStations, setSortedStations] = useState(stations.filter((station) => !station.onlyVisibleInTireHotel))\r\n\r\n useEffect(() => {\r\n if (!geolocationPosition || stations.length === 0 || !googleMaps) {\r\n return\r\n }\r\n const p0 = new googleMaps.LatLng(\r\n geolocationPosition.coords.latitude,\r\n geolocationPosition.coords.longitude\r\n )\r\n const newSortedStations = [...stations].sort(\r\n (a, b) => \r\n googleMaps.geometry.spherical.computeDistanceBetween(\r\n new googleMaps.LatLng(a.coordinatesLat, a.coordinatesLong),\r\n p0\r\n ) -\r\n googleMaps.geometry.spherical.computeDistanceBetween(\r\n new googleMaps.LatLng(b.coordinatesLat, b.coordinatesLong),\r\n p0\r\n )\r\n )\r\n setSortedStations(newSortedStations)\r\n }, [geolocationPosition, stations, googleMaps])\r\n\r\n return sortedStations\r\n}\r\n","export const maps = {\r\n instance: null,\r\n promise: new Promise((resolve) => {\r\n const script = document.createElement('script')\r\n script.src =\r\n 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBCq5hqIV9Yk1dZ7IsJeEueAxk2Fu4xqNA&libraries=geometry,places&callback=Function.prototype'\r\n script.async = true\r\n script.defer = true\r\n script.onload = function () {\r\n maps.instance = google.maps\r\n resolve(maps.instance)\r\n }\r\n document.head.appendChild(script)\r\n }),\r\n}\r\n"],"sourceRoot":""}