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C,EAASlH,KAAKgH,IAAIR,EAAKS,EAAGJ,EAAKI,GAAKA,EAE1CxC,EAAY0C,MAAMC,IAAM,GAAGH,MAC3BxC,EAAY0C,MAAME,KAAO,GAAGzD,MAC5Ba,EAAY0C,MAAMD,OAAS,GAAGA,MAC9BzC,EAAY0C,MAAMJ,MAAQ,GAAGA,MAE7BpC,EAAc2C,gBAAgBC,QACjC,IAUN,C,uCCxJA,IAAIC,EAAiB,WACjBC,EAAiB,WACjBC,EAAwB,WACxBC,EAAsB,WACtBC,EAAkB,WAUtB1J,EAAQsJ,eAAiBA,EACzBtJ,EAAQuJ,eAAiBA,EACzBvJ,EAAQwJ,sBAAwBA,EAChCxJ,EAAQyJ,oBAAsBA,EAC9BzJ,EAAQ0J,gBAAkBA,EAC1B1J,EAAQ0B,cAbR,UAAuB,OAAEuB,EAAM,OAAEhD,EAAM,cAAEmD,EAAa,YAAEf,EAAW,QAAEf,IACnEgI,EAAerG,GACfsG,EAAetJ,GACfuJ,EAAsBpG,GACtBqG,EAAoBpH,GACpBqH,EAAgBpI,EAClB,C,gBCZAtB,EAAQ,EAAsB,SAA6BqC,GACzD,GAA2B,iBAAhBA,EAA0B,CACnC,MAAMd,EAAgBC,MAAMC,QAAQY,GAAe,eAAiBA,EACpE,MAAM,IAAInC,MAAM,mDAAmDqB,IACrE,CAEA,GAAIc,GAAe,EACjB,MAAM,IAAInC,MAAM,4DAA4DmC,IAEhF,C","sources":["..\\..\\..\\LSWebUICore.ClientApp\\./node_modules/circle-to-polygon/input-validation/validateRadius.js","..\\..\\..\\LSWebUICore.ClientApp\\external script [\"https://cdn.jsdelivr.net/npm/tippy.js@6/dist/tippy.umd.min.js\",\"tippy\"]","..\\..\\..\\LSWebUICore.ClientApp\\external script [\"https://api.mapbox.com/mapbox-gl-js/v2.1.1/mapbox-gl.js\",\"mapboxgl\"]","..\\..\\..\\LSWebUICore.ClientApp\\./node_modules/circle-to-polygon/input-validation/validateBearing.js","..\\..\\..\\LSWebUICore.ClientApp\\./node_modules/circle-to-polygon/index.js","..\\..\\..\\LSWebUICore.ClientApp\\./node_modules/circle-to-polygon/input-validation/validateCenter.js","..\\..\\..\\LSWebUICore.ClientApp\\./node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js","..\\..\\..\\LSWebUICore.ClientApp\\./Utils/MapGeofence/index.ts","..\\..\\..\\LSWebUICore.ClientApp\\./node_modules/circle-to-polygon/input-validation/index.js","..\\..\\..\\LSWebUICore.ClientApp\\./node_modules/circle-to-polygon/input-validation/validateEarthRadius.js"],"sourcesContent":["exports.validateRadius = function validateRadius(radius) {\n if (typeof radius !== \"number\") {\n throw new Error(`ERROR! Radius has to be a positive number but was: ${typeof radius}`);\n }\n\n if (radius <= 0) {\n throw new Error(`ERROR! Radius has to be a positive number but was: ${radius}`);\n }\n};\n","var __webpack_error__ = new Error();\nmodule.exports = new Promise((resolve, reject) => {\n\tif(typeof tippy !== \"undefined\") return resolve();\n\t__webpack_require__.l(\"https://cdn.jsdelivr.net/npm/tippy.js@6/dist/tippy.umd.min.js\", (event) => {\n\t\tif(typeof tippy !== \"undefined\") return resolve();\n\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n\t\tvar realSrc = event && event.target && event.target.src;\n\t\t__webpack_error__.message = 'Loading script failed.\\n(' + errorType + ': ' + realSrc + ')';\n\t\t__webpack_error__.name = 'ScriptExternalLoadError';\n\t\t__webpack_error__.type = errorType;\n\t\t__webpack_error__.request = realSrc;\n\t\treject(__webpack_error__);\n\t}, \"tippy\");\n}).then(() => (tippy));","var __webpack_error__ = new Error();\nmodule.exports = new Promise((resolve, reject) => {\n\tif(typeof mapboxgl !== \"undefined\") return resolve();\n\t__webpack_require__.l(\"https://api.mapbox.com/mapbox-gl-js/v2.1.1/mapbox-gl.js\", (event) => {\n\t\tif(typeof mapboxgl !== \"undefined\") return resolve();\n\t\tvar errorType = event && (event.type === 'load' ? 'missing' : event.type);\n\t\tvar realSrc = event && event.target && event.target.src;\n\t\t__webpack_error__.message = 'Loading script failed.\\n(' + errorType + ': ' + realSrc + ')';\n\t\t__webpack_error__.name = 'ScriptExternalLoadError';\n\t\t__webpack_error__.type = errorType;\n\t\t__webpack_error__.request = realSrc;\n\t\treject(__webpack_error__);\n\t}, \"mapboxgl\");\n}).then(() => (mapboxgl));","exports.validateBearing = function validateBearing(bearing) {\n if (typeof bearing !== \"number\") {\n const ARGUMENT_TYPE = Array.isArray(bearing) ? \"array\" : typeof bearing;\n throw new Error(`ERROR! Bearing has to be a number but was: ${ARGUMENT_TYPE}`);\n }\n};\n","\"use strict\";\nvar { validateInput } = require(\"./input-validation\");\n\nconst defaultEarthRadius = 6378137; // equatorial Earth radius\n\nfunction toRadians(angleInDegrees) {\n return (angleInDegrees * Math.PI) / 180;\n}\n\nfunction toDegrees(angleInRadians) {\n return (angleInRadians * 180) / Math.PI;\n}\n\nfunction offset(c1, distance, earthRadius, bearing) {\n var lat1 = toRadians(c1[1]);\n var lon1 = toRadians(c1[0]);\n var dByR = distance / earthRadius;\n var lat = Math.asin(\n Math.sin(lat1) * Math.cos(dByR) + Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing)\n );\n var lon =\n lon1 +\n Math.atan2(\n Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),\n Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat)\n );\n return [toDegrees(lon), toDegrees(lat)];\n}\n\nmodule.exports = function circleToPolygon(center, radius, options) {\n var n = getNumberOfEdges(options);\n var earthRadius = getEarthRadius(options);\n var bearing = getBearing(options);\n var direction = getDirection(options);\n\n // validateInput() throws error on invalid input and do nothing on valid input\n validateInput({ center, radius, numberOfEdges: n, earthRadius, bearing });\n\n var start = toRadians(bearing);\n var coordinates = [];\n for (var i = 0; i < n; ++i) {\n coordinates.push(\n offset(\n center, radius, earthRadius, start + (direction * 2 * Math.PI * -i) / n\n )\n );\n }\n coordinates.push(coordinates[0]);\n\n return {\n type: \"Polygon\",\n coordinates: [coordinates]\n };\n};\n\nfunction getNumberOfEdges(options) {\n if (isUndefinedOrNull(options)) {\n return 32;\n } else if (isObjectNotArray(options)) {\n var numberOfEdges = options.numberOfEdges;\n return numberOfEdges === undefined ? 32 : numberOfEdges;\n }\n return options;\n}\n\nfunction getEarthRadius(options) {\n if (isUndefinedOrNull(options)) {\n return defaultEarthRadius;\n } else if (isObjectNotArray(options)) {\n var earthRadius = options.earthRadius;\n return earthRadius === undefined ? defaultEarthRadius : earthRadius;\n }\n return defaultEarthRadius;\n}\n\nfunction getDirection(options){\n if (isObjectNotArray(options) && options.rightHandRule){\n return -1;\n }\n return 1;\n}\n\nfunction getBearing(options) {\n if (isUndefinedOrNull(options)) {\n return 0;\n } else if (isObjectNotArray(options)) {\n var bearing = options.bearing;\n return bearing === undefined ? 0 : bearing;\n }\n return 0;\n}\n\nfunction isObjectNotArray(argument) {\n return argument !== null && typeof argument === \"object\" && !Array.isArray(argument);\n}\n\nfunction isUndefinedOrNull(argument) {\n return argument === null || argument === undefined;\n}\n","exports.validateCenter = function validateCenter(center) {\n var validCenterLengths = [2, 3];\n if (!Array.isArray(center) || !validCenterLengths.includes(center.length)) {\n throw new Error(\"ERROR! Center has to be an array of length two or three\");\n }\n\n var [lng, lat] = center;\n if (typeof lng !== \"number\" || typeof lat !== \"number\") {\n throw new Error(\n `ERROR! Longitude and Latitude has to be numbers but where ${typeof lng} and ${typeof lat}`\n );\n }\n if (lng > 180 || lng < -180) {\n throw new Error(`ERROR! Longitude has to be between -180 and 180 but was ${lng}`);\n }\n\n if (lat > 90 || lat < -90) {\n throw new Error(`ERROR! Latitude has to be between -90 and 90 but was ${lat}`);\n }\n};\n","exports.validateNumberOfEdges = function validateNumberOfEdges(numberOfEdges) {\n if (typeof numberOfEdges !== \"number\") {\n const ARGUMENT_TYPE = Array.isArray(numberOfEdges) ? \"array\" : typeof numberOfEdges;\n throw new Error(`ERROR! Number of edges has to be a number but was: ${ARGUMENT_TYPE}`);\n }\n\n if (numberOfEdges < 3) {\n throw new Error(`ERROR! Number of edges has to be at least 3 but was: ${numberOfEdges}`);\n }\n};\n","import type { Map, GeoJSONSource, GeoJSONSourceRaw, MapMouseEvent, MapboxGeoJSONFeature } from \"mapbox-gl\";\r\nimport { LngLat } from \"mapbox-gl\";\r\nimport type { ISearchGeofence, SearchGeofenceCustomCTA } from \"Services/API/API\";\r\nimport tippy from \"tippy.js\";\r\nimport circleToPolygon from \"circle-to-polygon\";\r\n\r\ntype IGeoFenceProperties = {\r\n IGeoFenceProperties: true,\r\n customCTAUrl?: SearchGeofenceCustomCTA[\"url\"],\r\n customCTAText?: SearchGeofenceCustomCTA[\"text\"],\r\n} & Pick\r\n\r\nconst GEOFENCE_SOURCE_NAME = \"geofencing\";\r\nconst GEOFENCE_LAYER_NAME = \"geofencing\";\r\n\r\nconst createGeoJSONCircleFeature = function (geoFence: ISearchGeofence, numberOfEdges?: number): GeoJSON.Feature {\r\n if (!numberOfEdges) numberOfEdges = 64;\r\n\r\n const properties: IGeoFenceProperties = {\r\n IGeoFenceProperties: true,\r\n radiusMeters: geoFence.radiusMeters,\r\n latitude: geoFence.latitude,\r\n longitude: geoFence.longitude,\r\n message: geoFence.message,\r\n venueId: geoFence.venueId\r\n }\r\n\r\n if (geoFence.customCTA) {\r\n properties.customCTAUrl = geoFence.customCTA.url;\r\n properties.customCTAText = geoFence.customCTA.text;\r\n }\r\n\r\n return {\r\n type: \"Feature\",\r\n geometry: circleToPolygon([geoFence.longitude, geoFence.latitude], geoFence.radiusMeters, numberOfEdges),\r\n properties\r\n };\r\n}\r\n\r\nexport function setGeofencesData(map: Map, geofences: ISearchGeofence[]): void {\r\n (map.getSource(GEOFENCE_SOURCE_NAME) as GeoJSONSource)?.setData({\r\n type: \"FeatureCollection\",\r\n features: geofences.map(x => createGeoJSONCircleFeature(x))\r\n })\r\n}\r\n\r\nexport function initGeofencesLayer(map: Map, geofences: ISearchGeofence[]): void {\r\n const initGeoJSON: GeoJSONSourceRaw = {\r\n type: \"geojson\",\r\n data: {\r\n type: \"FeatureCollection\",\r\n features: geofences.map(x => createGeoJSONCircleFeature(x))\r\n }\r\n };\r\n map.addSource(GEOFENCE_SOURCE_NAME, initGeoJSON);\r\n map.addLayer({\r\n \"id\": GEOFENCE_LAYER_NAME,\r\n \"type\": \"fill\",\r\n \"source\": GEOFENCE_SOURCE_NAME,\r\n \"layout\": {},\r\n \"paint\": {\r\n \"fill-antialias\": true,\r\n \"fill-color\": \"rgba(255, 141, 107, 0.20)\",\r\n \"fill-opacity\": 1,\r\n \"fill-outline-color\": \"#FF8D6B\",\r\n }\r\n });\r\n\r\n function getProperties(event: MapMouseEvent & { features?: MapboxGeoJSONFeature[] | undefined; }) {\r\n return event.features\r\n ?.filter(f => f.properties && f.properties.IGeoFenceProperties)\r\n .map(x => x.properties as IGeoFenceProperties)\r\n .sort((a, b) => a.radiusMeters - b.radiusMeters)[0];\r\n }\r\n\r\n const canvasContainer = map.getCanvasContainer();\r\n const popupContentElement = document.createElement(\"div\");\r\n popupContentElement.className = \"hq_popup\";\r\n popupContentElement.id = \"hq_popup\";\r\n\r\n const popupAnchor = document.createElement(\"div\");\r\n popupAnchor.className = \"hq_popup-anchor\";\r\n canvasContainer.append(popupAnchor);\r\n\r\n const tippyInstance = tippy(popupAnchor, {\r\n arrow: true,\r\n interactiveBorder: 0,\r\n interactive: true,\r\n maxWidth: \"none\",\r\n content: popupContentElement,\r\n offset: [0, 0],\r\n placement: \"top\",\r\n appendTo: document.body,\r\n theme: \"liquidspace\"\r\n });\r\n\r\n let venueId: Guid | undefined;\r\n map.on(\"mousemove\", GEOFENCE_LAYER_NAME, e => {\r\n const properties = getProperties(e);\r\n if (properties) {\r\n if (properties.venueId != venueId) {\r\n popupContentElement.innerHTML = \"\";\r\n\r\n popupContentElement.append(properties.message);\r\n\r\n if (properties.customCTAUrl && properties.customCTAText) {\r\n const ctaElement = document.createElement(\"a\");\r\n ctaElement.className = \"hq_popup-CTA\";\r\n ctaElement.href = properties.customCTAUrl;\r\n ctaElement.innerText = properties.customCTAText;\r\n ctaElement.target = \"_blank\";\r\n\r\n popupContentElement.append(ctaElement);\r\n }\r\n\r\n\r\n tippyInstance.setContent(popupContentElement);\r\n venueId = properties.venueId;\r\n }\r\n\r\n const featureCenter = new LngLat(properties.longitude, properties.latitude).wrap();\r\n\r\n const featureBounds = featureCenter.toBounds(properties.radiusMeters);\r\n const f_ne = map.project(featureBounds.getNorthEast());\r\n const f_sw = map.project(featureBounds.getSouthWest());\r\n\r\n const mapBounds = map.getBounds();\r\n const m_ne = map.project(mapBounds.getNorthEast());\r\n const m_sw = map.project(mapBounds.getSouthWest());\r\n\r\n const x = Math.max(f_sw.x, m_sw.x);\r\n const width = Math.min(f_ne.x, m_ne.x) - x;\r\n\r\n const y = Math.max(f_ne.y, m_ne.y);\r\n const height = Math.min(f_sw.y, m_sw.y) - y;\r\n\r\n popupAnchor.style.top = `${y}px`;\r\n popupAnchor.style.left = `${x}px`;\r\n popupAnchor.style.height = `${height}px`;\r\n popupAnchor.style.width = `${width}px`;\r\n\r\n tippyInstance.popperInstance?.update();\r\n }\r\n });\r\n // map.on(\"mouseleave\", GEOFENCE_LAYER_NAME, () => {\r\n // popupAnchor.style.top = \"0\";\r\n // popupAnchor.style.left = \"0\";\r\n // popupAnchor.style.height = \"0\";\r\n // popupAnchor.style.width = \"0\";\r\n\r\n // tippyInstance.hide();\r\n // });\r\n}","var validateCenter = require(\"./validateCenter\").validateCenter;\nvar validateRadius = require(\"./validateRadius\").validateRadius;\nvar validateNumberOfEdges = require(\"./validateNumberOfEdges\").validateNumberOfEdges;\nvar validateEarthRadius = require(\"./validateEarthRadius\").validateEarthRadius;\nvar validateBearing = require(\"./validateBearing\").validateBearing;\n\nfunction validateInput({ center, radius, numberOfEdges, earthRadius, bearing }) {\n validateCenter(center);\n validateRadius(radius);\n validateNumberOfEdges(numberOfEdges);\n validateEarthRadius(earthRadius);\n validateBearing(bearing);\n}\n\nexports.validateCenter = validateCenter;\nexports.validateRadius = validateRadius;\nexports.validateNumberOfEdges = validateNumberOfEdges;\nexports.validateEarthRadius = validateEarthRadius;\nexports.validateBearing = validateBearing;\nexports.validateInput = validateInput;\n","exports.validateEarthRadius = function validateEarthRadius(earthRadius) {\n if (typeof earthRadius !== \"number\") {\n const ARGUMENT_TYPE = Array.isArray(earthRadius) ? \"array\" : typeof earthRadius;\n throw new Error(`ERROR! Earth radius has to be a number but was: ${ARGUMENT_TYPE}`);\n }\n\n if (earthRadius <= 0) {\n throw new Error(`ERROR! Earth radius has to be a positive number but was: ${earthRadius}`);\n }\n};\n"],"names":["exports","radius","Error","__webpack_error__","module","Promise","resolve","reject","tippy","__webpack_require__","l","event","errorType","type","realSrc","target","src","message","name","request","then","mapboxgl","bearing","ARGUMENT_TYPE","Array","isArray","validateInput","defaultEarthRadius","toRadians","angleInDegrees","Math","PI","toDegrees","angleInRadians","offset","c1","distance","earthRadius","lat1","lon1","dByR","lat","asin","sin","cos","atan2","isObjectNotArray","argument","isUndefinedOrNull","center","options","n","numberOfEdges","undefined","getNumberOfEdges","getEarthRadius","getBearing","direction","rightHandRule","getDirection","start","coordinates","i","push","includes","length","lng","GEOFENCE_SOURCE_NAME","GEOFENCE_LAYER_NAME","createGeoJSONCircleFeature","geoFence","properties","IGeoFenceProperties","radiusMeters","latitude","longitude","venueId","customCTA","customCTAUrl","url","customCTAText","text","geometry","circleToPolygon","setGeofencesData","map","geofences","getSource","setData","features","x","initGeofencesLayer","initGeoJSON","data","addSource","addLayer","canvasContainer","getCanvasContainer","popupContentElement","document","createElement","className","id","popupAnchor","append","tippyInstance","arrow","interactiveBorder","interactive","maxWidth","content","placement","appendTo","body","theme","on","e","filter","f","sort","a","b","innerHTML","ctaElement","href","innerText","setContent","featureBounds","LngLat","wrap","toBounds","f_ne","project","getNorthEast","f_sw","getSouthWest","mapBounds","getBounds","m_ne","m_sw","max","width","min","y","height","style","top","left","popperInstance","update","validateCenter","validateRadius","validateNumberOfEdges","validateEarthRadius","validateBearing"],"sourceRoot":""}