@defra/interactive-map 0.0.14-alpha → 0.0.16-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/docusaurus.css +104 -0
- package/assets/images/favicon.svg +1 -0
- package/assets/images/hero.png +0 -0
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/slot-map.svg +1 -0
- package/docs/api/slots.md +89 -6
- package/docs/api.md +1 -1
- package/docs/architecture.md +3 -1
- package/docs/{demo.mdx → examples.mdx} +1 -1
- package/docs/getting-started.md +1 -3
- package/docs/index.mdx +42 -0
- package/docs/plugins/interact.md +176 -55
- package/docs/plugins/map-styles.md +64 -7
- package/docs/plugins/search.md +207 -63
- package/docs/plugins.md +7 -15
- package/docusaurus.config.cjs +34 -34
- package/jest.setup.js +1 -1
- package/package.json +5 -4
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/src/DatasetsInit.jsx +1 -1
- package/plugins/beta/datasets/src/api/addDataset.js +1 -1
- package/plugins/beta/datasets/src/api/hideDataset.js +1 -1
- package/plugins/beta/datasets/src/api/hideFeatures.js +1 -1
- package/plugins/beta/datasets/src/api/removeDataset.js +1 -1
- package/plugins/beta/datasets/src/api/showDataset.js +1 -1
- package/plugins/beta/datasets/src/api/showFeatures.js +1 -1
- package/plugins/beta/datasets/src/datasets.js +4 -4
- package/plugins/beta/datasets/src/defaults.js +1 -1
- package/plugins/beta/datasets/src/fetch/createDynamicSource.js +5 -5
- package/plugins/beta/datasets/src/handleSetMapStyle.js +1 -1
- package/plugins/beta/datasets/src/manifest.js +7 -7
- package/plugins/beta/datasets/src/mapLayers.js +2 -3
- package/plugins/beta/datasets/src/panels/Key.jsx +31 -29
- package/plugins/beta/datasets/src/panels/Layers.jsx +8 -9
- package/plugins/beta/datasets/src/utils/bbox.js +4 -4
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/DrawInit.jsx +16 -16
- package/plugins/beta/draw-es/src/api/addFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/deleteFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/editFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/newPolygon.js +3 -3
- package/plugins/beta/draw-es/src/events.js +52 -20
- package/plugins/beta/draw-es/src/events.test.js +301 -0
- package/plugins/beta/draw-es/src/graphic.js +1 -1
- package/plugins/beta/draw-es/src/manifest.js +4 -4
- package/plugins/beta/draw-es/src/reducer.js +1 -1
- package/plugins/beta/draw-es/src/sketchViewModel.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/src/DrawInit.jsx +49 -52
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +1 -1
- package/plugins/beta/draw-ml/src/api/editFeature.js +8 -5
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -1
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -1
- package/plugins/beta/draw-ml/src/api/split.js +4 -4
- package/plugins/beta/draw-ml/src/defaults.js +1 -1
- package/plugins/beta/draw-ml/src/events.js +8 -6
- package/plugins/beta/draw-ml/src/manifest.js +15 -15
- package/plugins/beta/draw-ml/src/mapboxDraw.js +1 -1
- package/plugins/beta/draw-ml/src/mapboxSnap.js +17 -18
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +31 -31
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +1 -1
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +11 -11
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +8 -8
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +32 -24
- package/plugins/beta/draw-ml/src/reducer.js +1 -1
- package/plugins/beta/draw-ml/src/undoStack.js +4 -4
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +12 -12
- package/plugins/beta/draw-ml/src/utils/spatial.js +11 -11
- package/plugins/beta/frame/src/Frame.jsx +4 -4
- package/plugins/beta/frame/src/FrameInit.jsx +4 -4
- package/plugins/beta/frame/src/api/addFrame.js +1 -1
- package/plugins/beta/frame/src/api/editFeature.js +1 -1
- package/plugins/beta/frame/src/config.js +1 -1
- package/plugins/beta/frame/src/manifest.js +3 -3
- package/plugins/beta/frame/src/reducer.js +1 -1
- package/plugins/beta/frame/src/utils.js +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/src/MapStyles.jsx +18 -18
- package/plugins/beta/map-styles/src/manifest.js +2 -2
- package/plugins/beta/scale-bar/src/ScaleBar.jsx +5 -5
- package/plugins/beta/use-location/src/UseLocation.jsx +1 -1
- package/plugins/beta/use-location/src/defaults.js +1 -1
- package/plugins/beta/use-location/src/events.js +3 -3
- package/plugins/interact/src/InteractInit.jsx +1 -2
- package/plugins/interact/src/api/enable.js +8 -5
- package/plugins/interact/src/api/enable.test.js +2 -2
- package/plugins/interact/src/api/selectFeature.js +4 -4
- package/plugins/interact/src/api/unselectFeature.js +5 -5
- package/plugins/interact/src/defaults.js +0 -1
- package/plugins/interact/src/events.test.js +15 -15
- package/plugins/interact/src/hooks/useHighlightSync.js +1 -1
- package/plugins/interact/src/hooks/useInteractionHandlers.js +2 -2
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -5
- package/plugins/interact/src/manifest.js +2 -2
- package/plugins/interact/src/manifest.test.js +3 -4
- package/plugins/interact/src/reducer.js +3 -3
- package/plugins/interact/src/reducer.test.js +0 -1
- package/plugins/interact/src/utils/spatial.js +10 -10
- package/plugins/interact/src/utils/spatial.test.js +14 -14
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/Search.jsx +7 -6
- package/plugins/search/src/Search.test.jsx +23 -23
- package/plugins/search/src/components/CloseButton/CloseButton.jsx +15 -15
- package/plugins/search/src/components/CloseButton/CloseButton.test.jsx +2 -2
- package/plugins/search/src/components/Form/Form.jsx +14 -14
- package/plugins/search/src/components/Form/Form.test.jsx +11 -11
- package/plugins/search/src/components/OpenButton/OpenButton.jsx +16 -15
- package/plugins/search/src/components/OpenButton/OpenButton.test.jsx +6 -2
- package/plugins/search/src/components/SubmitButton/SubmitButton.jsx +15 -15
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +6 -6
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +4 -4
- package/plugins/search/src/datasets.js +12 -13
- package/plugins/search/src/datasets.test.js +1 -1
- package/plugins/search/src/defaults.js +1 -1
- package/plugins/search/src/events/fetchSuggestions.js +4 -4
- package/plugins/search/src/events/fetchSuggestions.test.js +5 -5
- package/plugins/search/src/events/formHandlers.js +3 -3
- package/plugins/search/src/events/formHandlers.test.js +1 -1
- package/plugins/search/src/events/index.js +2 -2
- package/plugins/search/src/events/index.test.js +2 -2
- package/plugins/search/src/events/inputHandlers.js +4 -4
- package/plugins/search/src/events/inputHandlers.test.js +1 -1
- package/plugins/search/src/events/suggestionHandlers.js +2 -2
- package/plugins/search/src/events/suggestionHandlers.test.js +1 -1
- package/plugins/search/src/index.js +2 -1
- package/plugins/search/src/index.test.js +3 -3
- package/plugins/search/src/manifest.js +6 -4
- package/plugins/search/src/reducer.js +1 -2
- package/plugins/search/src/reducer.test.js +2 -2
- package/plugins/search/src/search.scss +18 -6
- package/plugins/search/src/utils/parseOsNamesResults.js +1 -2
- package/plugins/search/src/utils/parseOsNamesResults.test.js +2 -2
- package/plugins/search/src/utils/updateMap.js +1 -1
- package/plugins/search/src/utils/updateMap.test.js +5 -5
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/src/esriProvider.js +5 -5
- package/providers/beta/esri/src/utils/coords.js +1 -1
- package/providers/beta/esri/src/utils/esriFixes.js +1 -1
- package/providers/beta/esri/src/utils/query.js +4 -4
- package/providers/beta/esri/src/utils/spatial.js +1 -2
- package/providers/beta/esri/src/utils/spatial.test.js +4 -1
- package/providers/beta/open-names/src/utils/mapToLocationModel.test.js +1 -1
- package/providers/maplibre/src/appEvents.test.js +1 -1
- package/providers/maplibre/src/index.js +1 -1
- package/providers/maplibre/src/index.test.js +3 -5
- package/providers/maplibre/src/mapEvents.test.js +15 -5
- package/providers/maplibre/src/maplibreProvider.test.js +6 -2
- package/providers/maplibre/src/utils/calculateLinearTextSize.js +4 -4
- package/providers/maplibre/src/utils/calculateLinearTextSize.test.js +3 -3
- package/providers/maplibre/src/utils/detectWebgl.test.js +1 -1
- package/providers/maplibre/src/utils/highlightFeatures.js +2 -2
- package/providers/maplibre/src/utils/highlightFeatures.test.js +12 -6
- package/providers/maplibre/src/utils/labels.js +19 -20
- package/providers/maplibre/src/utils/labels.test.js +15 -13
- package/providers/maplibre/src/utils/maplibreFixes.test.js +1 -1
- package/providers/maplibre/src/utils/queryFeatures.js +6 -6
- package/providers/maplibre/src/utils/queryFeatures.test.js +13 -13
- package/providers/maplibre/src/utils/spatial.js +0 -1
- package/providers/maplibre/src/utils/spatial.test.js +26 -27
- package/src/App/components/Panel/Panel.module.scss +1 -0
- package/src/App/hooks/useLayoutMeasurements.js +1 -10
- package/src/App/hooks/useLayoutMeasurements.test.js +2 -5
- package/src/App/hooks/useVisibleGeometry.js +7 -13
- package/src/App/hooks/useVisibleGeometry.test.js +72 -47
- package/src/App/layout/Layout.jsx +0 -3
- package/src/App/layout/Layout.test.jsx +0 -1
- package/src/App/layout/layout.module.scss +11 -77
- package/src/App/registry/pluginRegistry.js +17 -0
- package/src/App/registry/pluginRegistry.test.js +33 -0
- package/src/App/renderer/HtmlElementHost.jsx +0 -1
- package/src/App/renderer/HtmlElementHost.test.jsx +20 -11
- package/src/App/renderer/mapButtons.js +3 -2
- package/src/App/renderer/mapPanels.test.js +3 -3
- package/src/App/renderer/slotHelpers.js +2 -2
- package/src/App/renderer/slotHelpers.test.js +3 -3
- package/src/App/renderer/slots.js +0 -3
- package/src/App/store/AppProvider.jsx +0 -1
- package/src/App/store/appDispatchMiddleware.js +33 -1
- package/src/App/store/appDispatchMiddleware.test.js +250 -222
- package/src/config/appConfig.js +4 -4
- package/src/utils/getSafeZoneInset.js +139 -42
- package/src/utils/getSafeZoneInset.test.js +298 -122
- package/src/utils/logger.js +6 -0
- package/src/utils/logger.test.js +32 -0
- package/webpack.dev.mjs +22 -18
- package/docs/govuk-prototype.md +0 -23
- package/docs/index.md +0 -19
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see im-datasets-plugin.js.LICENSE.txt */
|
|
2
|
-
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[447],{802(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function u(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?a(Object(r),!0).forEach(function(e){l(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function l(t,e,r){return(e=c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}r.r(e),r.d(e,{manifest:()=>Q});var s={SET_DATASETS:function(t,e){var r=e.datasets,n=e.datasetDefaults;return u(u({},t),{},{datasets:r.map(function(t){return u(u({},n),t)})})},ADD_DATASET:function(t,e){var r=e.dataset,n=e.datasetDefaults;return u(u({},t),{},{datasets:[].concat(o(t.datasets||[]),[u(u({},n),r)])})},REMOVE_DATASET:function(t,e){var r,n=e.id;return u(u({},t),{},{datasets:(null===(r=t.datasets)||void 0===r?void 0:r.filter(function(t){return t.id!==n}))||[]})},SET_DATASET_VISIBILITY:function(t,e){var r,n=e.id,o=e.visibility;return u(u({},t),{},{datasets:null===(r=t.datasets)||void 0===r?void 0:r.map(function(t){return t.id===n?u(u({},t),{},{visibility:o}):t})})},HIDE_FEATURES:function(t,e){var r=e.layerId,n=e.idProperty,i=e.featureIds,a=t.hiddenFeatures[r],c=(null==a?void 0:a.ids)||[],s=o(new Set([].concat(o(c),o(i))));return u(u({},t),{},{hiddenFeatures:u(u({},t.hiddenFeatures),{},l({},r,{idProperty:n,ids:s}))})},SHOW_FEATURES:function(t,e){var r=e.layerId,n=e.featureIds,o=t.hiddenFeatures[r];if(!o)return t;var i=o.ids.filter(function(t){return!n.includes(t)});if(0===i.length){var a=t.hiddenFeatures,s=(a[r],function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],-1===e.indexOf(r)&&{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(a,[r].map(c)));return u(u({},t),{},{hiddenFeatures:s})}return u(u({},t),{},{hiddenFeatures:u(u({},t.hiddenFeatures),{},l({},r,u(u({},o),{},{ids:i})))})}},f=r(738),d={stroke:"#d4351c",strokeWidth:2,fill:"transparent",symbolDescription:"red outline",minZoom:6,maxZoom:24,showInKey:!1,showInLayers:!1,visibility:"visible"};function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}var p=function(t,e){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===y(t)){if(e&&t[e])return t[e];var r=Object.values(t)[0];return null!=r?r:null}return null};function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function m(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?m(Object(r),!0).forEach(function(e){h(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function h(t,e,r){return(e=function(t){var e=function(t){if("object"!=v(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=v(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==v(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var S=function(t){var e,r=0,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return g(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(t);try{for(n.s();!(e=n.n()).done;)r=(r<<5)-r+e.value.codePointAt(0),r&=r}catch(t){n.e(t)}finally{n.f()}return Math.abs(r).toString(36)},j=function(t){if(t.tiles){var e=Array.isArray(t.tiles)?t.tiles.join(","):t.tiles;return"tiles-".concat(S(e))}return t.geojson?w(t)?"geojson-dynamic-".concat(t.id):"string"==typeof t.geojson?"geojson-".concat(S(t.geojson)):"geojson-".concat(t.id):"source-".concat(t.id)},w=function(t){return"string"==typeof t.geojson&&!!t.idProperty&&"function"==typeof t.transformRequest},O=function(t,e,r){var n=j(r);if(!t.getSource(n))if(r.tiles)t.addSource(n,{type:"vector",tiles:r.tiles,minzoom:r.minZoom||0,maxzoom:r.maxZoom||22});else if(r.geojson){var o=w(r)?{type:"FeatureCollection",features:[]}:r.geojson;t.addSource(n,{type:"geojson",data:o})}var i=!!r.fill,a=!!r.stroke,u=i?r.id:null,l=a?i?"".concat(r.id,"-stroke"):r.id:null,c="hidden"===r.visibility?"none":"visible";if(i&&!t.getLayer(u)){var s,f=p(r.fill,e);t.addLayer(b({id:u,type:"fill",source:n,"source-layer":null!=r&&null!==(s=r.tiles)&&void 0!==s&&s.length?r.sourceLayer:void 0,layout:{visibility:c},paint:{"fill-color":f,"fill-opacity":r.opacity||1}},r.filter?{filter:r.filter}:{}))}if(a&&!t.getLayer(l)){var d,y=p(r.stroke,e);t.addLayer(b({id:l,type:"line",source:n,"source-layer":null!=r&&null!==(d=r.tiles)&&void 0!==d&&d.length?r.sourceLayer:void 0,layout:{visibility:c},paint:b({"line-color":y,"line-width":r.strokeWidth||1,"line-opacity":r.opacity||1},r.strokeDashArray?{"line-dasharray":r.strokeDashArray}:{})},r.filter?{filter:r.filter}:{}))}},k=function(t,e,r,n,o){if(t.getLayer(e)){var i=function(t,e,r){if(!r||0===r.length)return t;var n=["!",["in",["to-string",["get",e]],["literal",r.map(function(t){return String(t)})]]];return t?["all",t,n]:n}(r,n,o);t.setFilter(e,i)}};function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function P(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var l=n&&n.prototype instanceof u?n:u,c=Object.create(l.prototype);return E(c,"_invoke",function(r,n,o){var i,u,l,c=0,s=o||[],f=!1,d={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,l=t,d.n=r,a}};function y(r,n){for(u=r,l=n,e=0;!f&&c&&!o&&e<s.length;e++){var o,i=s[e],y=d.p,p=i[2];r>3?(o=p===n)&&(l=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,d.v=n,d.n=i[1]):y<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,d.n=p,u=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&y(s,p),u=s,l=p;(e=u<2?t:l)||!f;){i||(u?u<3?(u>1&&(d.n=-1),y(u,l)):d.n=l:d.v=l);try{if(c=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(f=d.n<0)?l:r.call(n,d))!==a)break}catch(e){i=t,u=1,l=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function u(){}function l(){}function c(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(E(e={},n,function(){return this}),e),f=c.prototype=u.prototype=Object.create(s);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,E(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return l.prototype=c,E(f,"constructor",c),E(c,"constructor",l),l.displayName="GeneratorFunction",E(c,o,"GeneratorFunction"),E(f),E(f,o,"Generator"),E(f,n,function(){return this}),E(f,"toString",function(){return"[object Generator]"}),(P=function(){return{w:i,m:d}})()}function E(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}E=function(t,e,r,n){function i(e,r){E(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},E(t,e,r,n)}function I(t,e,r,n,o,i,a){try{var u=t[i](a),l=u.value}catch(t){return void r(t)}u.done?e(l):Promise.resolve(l).then(n,o)}var x=function(){var t,e=(t=P().m(function t(e,r,n){var o,i,a,u,l,c,s;return P().w(function(t){for(;;)switch(t.n){case 0:return o=n(e,r),a=(i="string"==typeof o?{url:o}:o).url,u=i.headers,l=void 0===u?{}:u,t.n=1,fetch(a,{headers:l});case 1:if((c=t.v).ok){t.n=2;break}throw new Error("Failed to fetch GeoJSON: ".concat(c.status," ").concat(c.statusText));case 2:return t.n=3,c.json();case 3:if("FeatureCollection"!==(s=t.v).type){t.n=4;break}return t.a(2,s);case 4:if("Feature"!==s.type){t.n=5;break}return t.a(2,{type:"FeatureCollection",features:[s]});case 5:if(!Array.isArray(s)){t.n=6;break}return t.a(2,{type:"FeatureCollection",features:s});case 6:throw new Error("Invalid GeoJSON response");case 7:return t.a(2)}},t)}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){I(i,n,o,a,u,"next",t)}function u(t){I(i,n,o,a,u,"throw",t)}a(void 0)})});return function(t,r,n){return e.apply(this,arguments)}}();function T(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var D=function(t){var e=t.getBounds();return[e.getWest(),e.getSouth(),e.getEast(),e.getNorth()]},_=function(t,e){return!(!t||!e)&&e[0]>=t[0]&&e[1]>=t[1]&&e[2]<=t[2]&&e[3]<=t[3]},L=function(t,e){return t?[Math.min(t[0],e[0]),Math.min(t[1],e[1]),Math.max(t[2],e[2]),Math.max(t[3],e[3])]:function(t){if(Array.isArray(t))return T(t)}(r=e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return T(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?T(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var r},F=function(t,e){return!(!t||!e||t[2]<e[0]||t[0]>e[2]||t[3]<e[1]||t[1]>e[3])},M=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0,i=function(t,a){var u;0===a?(u=t,e=Math.min(e,u[0]),r=Math.min(r,u[1]),n=Math.max(n,u[0]),o=Math.max(o,u[1])):t.forEach(function(t){return i(t,a-1)})};switch(t.type){case"Point":i(t.coordinates,0);break;case"LineString":case"MultiPoint":i(t.coordinates,1);break;case"Polygon":case"MultiLineString":i(t.coordinates,2);break;case"MultiPolygon":i(t.coordinates,3);break;case"GeometryCollection":t.geometries.forEach(function(t){var i=M(t);e=Math.min(e,i[0]),r=Math.min(r,i[1]),n=Math.max(n,i[2]),o=Math.max(o,i[3])})}return[e,r,n,o]};function C(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var l=n&&n.prototype instanceof u?n:u,c=Object.create(l.prototype);return N(c,"_invoke",function(r,n,o){var i,u,l,c=0,s=o||[],f=!1,d={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,l=t,d.n=r,a}};function y(r,n){for(u=r,l=n,e=0;!f&&c&&!o&&e<s.length;e++){var o,i=s[e],y=d.p,p=i[2];r>3?(o=p===n)&&(l=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,d.v=n,d.n=i[1]):y<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,d.n=p,u=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&y(s,p),u=s,l=p;(e=u<2?t:l)||!f;){i||(u?u<3?(u>1&&(d.n=-1),y(u,l)):d.n=l:d.v=l);try{if(c=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(f=d.n<0)?l:r.call(n,d))!==a)break}catch(e){i=t,u=1,l=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function u(){}function l(){}function c(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(N(e={},n,function(){return this}),e),f=c.prototype=u.prototype=Object.create(s);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,N(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return l.prototype=c,N(f,"constructor",c),N(c,"constructor",l),l.displayName="GeneratorFunction",N(c,o,"GeneratorFunction"),N(f),N(f,o,"Generator"),N(f,n,function(){return this}),N(f,"toString",function(){return"[object Generator]"}),(C=function(){return{w:i,m:d}})()}function N(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}N=function(t,e,r,n){function i(e,r){N(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},N(t,e,r,n)}function W(t,e,r,n,o,i,a){try{var u=t[i](a),l=u.value}catch(t){return void r(t)}u.done?e(l):Promise.resolve(l).then(n,o)}function G(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||R(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(t,e){if(t){if("string"==typeof t)return U(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?U(t,e):void 0}}function U(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var z=function(t){var e=t.pluginConfig,r=t.pluginStateRef,n=t.mapStyleId,o=t.mapProvider,i=t.events,a=t.eventBus,u=o.map,l=e.datasets,c=new Map,s=function(){return r.current.datasets||l};l.forEach(function(t){if(O(u,n,t),w(t)){var e=j(t),r=function(t){var e,r,n,o=t.dataset,i=t.map,a=t.sourceId,u=t.onUpdate,l=o.geojson,c=o.idProperty,s=o.transformRequest,f=o.maxFeatures,d=o.minZoom,y=void 0===d?0:d,p=new Map,v=null,m=!1,b=function(){return{type:"FeatureCollection",features:Array.from(p.values()).map(function(t){return t.feature})}},h=function(t){var e,r;return c&&null!==(e=null===(r=t.properties)||void 0===r?void 0:r[c])&&void 0!==e?e:t.id},g=function(t){if(f&&!(p.size<=1.2*f)){var e,r=f,n=[],o=[],i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=R(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==e.return||e.return()}finally{if(a)throw o}}}}(p);try{for(i.s();!(e=i.n()).done;){var a=G(e.value,2),u=a[0],l=a[1];F(l.bbox,t)?n.push(u):o.push({id:u,addedAt:l.addedAt})}}catch(t){i.e(t)}finally{i.f()}o.sort(function(t,e){return t.addedAt-e.addedAt});for(var c=p.size-r,s=0;s<c&&s<o.length;s++)p.delete(o[s].id);if(p.size>r)for(var d=p.size-r,y=n.map(function(t){return{id:t,addedAt:p.get(t).addedAt}}).sort(function(t,e){return t.addedAt-e.addedAt}),v=0;v<d&&v<y.length;v++)p.delete(y[v].id)}},S=function(){var t,e=(t=C().m(function t(){var e,r,n,c,f,d;return C().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!((e=i.getZoom())<y)){t.n=1;break}return t.a(2);case 1:if(r=D(i),!v||!_(v,r)){t.n=2;break}return t.a(2);case 2:if(!m){t.n=3;break}return t.a(2);case 3:return m=!0,t.p=4,n={bbox:r,zoom:e,dataset:o},t.n=5,x(l,n,s);case 5:c=t.v,f=Date.now(),c.features.forEach(function(t){var e=h(t);null!=e?p.set(e,{feature:t,bbox:M(t.geometry),addedAt:p.has(e)?p.get(e).addedAt:f}):console.warn("Feature missing ID, skipping:",t)}),v=L(v,r),g(r),u(a,b()),t.n=7;break;case 6:t.p=6,d=t.v,console.error("Failed to fetch dynamic GeoJSON for ".concat(o.id,":"),d);case 7:return t.p=7,m=!1,t.f(7);case 8:return t.a(2)}},t,null,[[4,6,7,8]])}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){W(i,n,o,a,u,"next",t)}function u(t){W(i,n,o,a,u,"throw",t)}a(void 0)})});return function(){return e.apply(this,arguments)}}(),j=(e=S,n=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(function(){return e.apply(void 0,n)},200)},n.cancel=function(){clearTimeout(r),r=null},n),w=function(){j()};return i.on("moveend",w),S(),{destroy:function(){i.off("moveend",w),j.cancel()},clear:function(){p.clear(),v=null,u(a,{type:"FeatureCollection",features:[]})},refresh:function(){p.clear(),v=null,S()},getFeatureCount:function(){return p.size},reapply:function(){p.size>0&&u(a,b())}}}({dataset:t,map:u,sourceId:e,onUpdate:function(t,e){return function(t,e,r){var n=t.getSource(e);n&&"function"==typeof n.setData&&n.setData(r)}(u,t,e)}});c.set(t.id,r)}}),u.once("idle",function(){a.emit("datasets:ready")});var f=function(t){var e=t.map,r=t.events,n=t.getDatasets,o=t.getHiddenFeatures,i=t.getDynamicSources,a=function(t){e.once("idle",function(){var r=t.id,a=n(),u=o(),l=i?i():new Map;a.forEach(function(t){O(e,r,t)}),l.forEach(function(t){t.reapply()}),Object.entries(u).forEach(function(t){var r=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return A(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?A(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),n=r[0],o=r[1],i=o.idProperty,u=o.ids,l=a.find(function(t){return t.id===n});if(l){var c=l.filter||null,s=!!l.fill,f=!!l.stroke,d=s?n:null,y=f?s?"".concat(n,"-stroke"):n:null;d&&k(e,d,c,i,u),y&&k(e,y,c,i,u)}})})};return t.eventBus.on(r.MAP_SET_STYLE,a),a}({map:u,events:i,eventBus:a,getDatasets:s,getHiddenFeatures:function(){return r.current.hiddenFeatures||{}},getDynamicSources:function(){return c}});return{remove:function(){a.off(i.MAP_SET_STYLE,f),c.forEach(function(t){return t.destroy()}),c.clear();var t=s(),e=new Set;t.forEach(function(t){var r=j(t),n=function(t,e){var r=t.getStyle();return null!=r&&r.layers?r.layers.filter(function(t){return t.source===e}).map(function(t){return t.id}):[]}(u,r);n.forEach(function(t){return u.removeLayer(t)}),!e.has(r)&&u.getSource(r)&&(u.removeSource(r),e.add(r))})},refreshDataset:function(t){var e=c.get(t);e&&e.refresh()},clearDatasetCache:function(t){var e=c.get(t);e&&e.clear()},getFeatureCount:function(t){var e=c.get(t);return e?e.getFeatureCount():null}}},B=function(t,e){var r=t.mapProvider,n=t.pluginState,o=r.map;o.getLayer(e)&&o.setLayoutProperty(e,"visibility","visible"),o.getLayer("".concat(e,"-stroke"))&&o.setLayoutProperty("".concat(e,"-stroke"),"visibility","visible"),n.dispatch({type:"SET_DATASET_VISIBILITY",payload:{id:e,visibility:"visible"}})},K=function(t,e){var r=t.mapProvider,n=t.pluginState,o=r.map;o.getLayer(e)&&o.setLayoutProperty(e,"visibility","none"),o.getLayer("".concat(e,"-stroke"))&&o.setLayoutProperty("".concat(e,"-stroke"),"visibility","none"),n.dispatch({type:"SET_DATASET_VISIBILITY",payload:{id:e,visibility:"hidden"}})},H=r(287);function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}function $(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function V(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$(Object(r),!0).forEach(function(e){Y(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Y(t,e,r){return(e=function(t){var e=function(t){if("object"!=Z(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Z(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Z(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function J(t){return function(t){if(Array.isArray(t))return q(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return q(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Q={InitComponent:function(t){var e,r=t.pluginConfig,n=t.pluginState,o=t.appState,i=t.mapState,a=t.mapProvider,u=t.services,l=n.dispatch,c=u.events,s=u.eventBus,y=!(null===(e=a.map)||void 0===e||!e.getStyle()),p=(0,f.useRef)(n);p.current=n;var v=(0,f.useRef)(null);return(0,f.useEffect)(function(){var t,e,u,f,m=null===(t=null===(e=r.includeModes)||void 0===e?void 0:e.includes(o.mode))||void 0===t||t,b=null!==(u=null===(f=r.excludeModes)||void 0===f?void 0:f.includes(o.mode))&&void 0!==u&&u;y&&m&&!b&&(v.current||(n.datasets||l({type:"SET_DATASETS",payload:{datasets:r.datasets,datasetDefaults:d}}),v.current=z({mapStyleId:i.mapStyle.id,pluginConfig:r,pluginStateRef:p,mapProvider:a,events:c,eventBus:s})))},[y,o.mode]),(0,f.useEffect)(function(){return function(){v.current&&(v.current.remove(),v.current=null)}},[]),null},reducer:{initialState:{datasets:null,hiddenFeatures:{}},actions:s},panels:[{id:"datasetsLayers",label:"Layers",mobile:{slot:"bottom",modal:!0,dismissible:!0},tablet:{slot:"inset",dismissible:!0,exclusive:!0,width:"300px"},desktop:{slot:"inset",modal:!1,dismissible:!0,exclusive:!0,width:"320px"},render:function(t){var e=t.pluginState,r=t.mapProvider,n=function(t){var n=t.target,o=n.value;n.checked?B({mapProvider:r,pluginState:e},o):K({mapProvider:r,pluginState:e},o)};return(0,H.jsx)("div",{className:"im-c-datasets-layers",children:(0,H.jsx)("div",{className:"govuk-form-group",children:(0,H.jsxs)("fieldset",{className:"govuk-fieldset",children:[(0,H.jsx)("legend",{className:"govuk-visually-hidden",children:"Layers"}),(0,H.jsx)("div",{className:"govuk-checkboxes govuk-checkboxes--small","data-module":"govuk-checkboxes",children:(e.datasets||[]).filter(function(t){return t.showInLayers}).map(function(t){return(0,H.jsx)("div",{className:"im-c-datasets-layers__item".concat("hidden"!==t.visibility?" im-c-datasets-layers__item--checked":""),children:(0,H.jsxs)("div",{className:"govuk-checkboxes__item",children:[(0,H.jsx)("input",{className:"govuk-checkboxes__input",id:t.id,name:"layers",type:"checkbox",value:t.id,checked:"hidden"!==t.visibility,onChange:n}),(0,H.jsx)("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:t.id,children:t.label})]})},t.id)})})]})})})}},{id:"datasetsKey",label:"Key",mobile:{slot:"bottom",modal:!0},tablet:{slot:"inset",width:"300px"},desktop:{slot:"inset",width:"320px"},render:function(t){var e=t.mapState,r=t.pluginState,n=e.mapStyle,o=function(t){return(0,H.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:"line"===t.keySymbolShape?(0,H.jsx)("line",{x1:t.strokeWidth/2,y1:"10",x2:20-t.strokeWidth/2,y2:"10",stroke:p(t.stroke,n.id),strokeWidth:t.strokeWidth,strokeLinecap:"round"}):(0,H.jsx)("rect",{x:t.strokeWidth/2,y:t.strokeWidth/2,width:20-t.strokeWidth,height:20-t.strokeWidth,rx:t.strokeWidth,ry:t.strokeWidth,fill:p(t.fill,n.id),stroke:p(t.stroke,n.id),strokeWidth:t.strokeWidth,strokeLinejoin:"round"})})};return(0,H.jsx)("div",{className:"im-c-datasets-key",children:(r.datasets||[]).filter(function(t){return t.showInKey&&"hidden"!==t.visibility}).map(function(t){return(0,H.jsx)("div",{className:"im-c-datasets-key__item",children:(0,H.jsxs)("div",{className:"im-c-datasets-key__item-label",children:[o(t),t.label,t.symbolDescription&&(0,H.jsxs)("span",{className:"govuk-visually-hidden",children:["(",p(t.symbolDescription,n.id),")"]})]})},t.id)})})}}],buttons:[{id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",iconId:"layers",excludeWhen:function(t){return!t.pluginConfig.datasets.find(function(t){return t.showInLayers})},mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}},{id:"datasetsKey",label:"Key",panelId:"datasetsKey",iconId:"key",excludeWhen:function(t){return!t.pluginConfig.datasets.find(function(t){return t.showInKey})},mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"layers",svgContent:'<path d="M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74z"></path><path d="m20 14.285 1.5.845a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74l1.5-.845"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{showDataset:B,hideDataset:K,addDataset:function(t,e){var r=t.mapProvider,n=t.mapState,o=t.pluginState,i=r.map;O(i,n.mapStyle.id,V(V({},d),e)),o.dispatch({type:"ADD_DATASET",payload:{dataset:e,datasetDefaults:d}})},removeDataset:function(t,e){var r,n,o=t.mapProvider,i=t.pluginState,a=o.map,u=null===(r=i.datasets)||void 0===r?void 0:r.find(function(t){return t.id===e});if(u){var l=function(t){var e=!!t.fill,r=!!t.stroke,n=e?t.id:null,o=null;return r&&(o=e?"".concat(t.id,"-stroke"):t.id),{fillLayerId:n,strokeLayerId:o}}(u),c=l.fillLayerId,s=l.strokeLayerId,f=j(u);[s,c].forEach(function(t){t&&a.getLayer(t)&&a.removeLayer(t)}),!(null===(n=i.datasets)||void 0===n?void 0:n.some(function(t){return t.id!==e&&j(t)===f}))&&a.getSource(f)&&a.removeSource(f),i.dispatch({type:"REMOVE_DATASET",payload:{id:e}})}},showFeatures:function(t,e){var r,n=t.mapProvider,o=t.pluginState,i=e.featureIds,a=e.idProperty,u=e.datasetId,l=n.map,c=o.hiddenFeatures[u];if(c){var s=null===(r=o.datasets)||void 0===r?void 0:r.find(function(t){return t.id===u});if(s){var f=s.filter||null,d=!!s.fill,y=!!s.stroke,p=d?u:null,v=null;y&&(v=d?"".concat(u,"-stroke"):u);var m=c.ids.filter(function(t){return!i.includes(t)});o.dispatch({type:"SHOW_FEATURES",payload:{layerId:u,featureIds:i}}),p&&k(l,p,f,a,m),v&&k(l,v,f,a,m)}}},hideFeatures:function(t,e){var r,n=t.mapProvider,o=t.pluginState,i=e.featureIds,a=e.idProperty,u=e.datasetId,l=n.map,c=null===(r=o.datasets)||void 0===r?void 0:r.find(function(t){return t.id===u});if(c){var s=c.filter||null,f=!!c.fill,d=!!c.stroke,y=f?u:null,p=null;d&&(p=f?"".concat(u,"-stroke"):u);var v=o.hiddenFeatures[u],m=v?J(new Set([].concat(J(v.ids),J(i)))):i;o.dispatch({type:"HIDE_FEATURES",payload:{layerId:u,idProperty:a,featureIds:i}}),y&&k(l,y,s,a,m),p&&k(l,p,s,a,m)}}}}}}]);
|
|
2
|
+
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[447],{802(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function u(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?a(Object(r),!0).forEach(function(e){l(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function l(t,e,r){return(e=c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function c(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}r.r(e),r.d(e,{manifest:()=>Q});var s={SET_DATASETS:function(t,e){var r=e.datasets,n=e.datasetDefaults;return u(u({},t),{},{datasets:r.map(function(t){return u(u({},n),t)})})},ADD_DATASET:function(t,e){var r=e.dataset,n=e.datasetDefaults;return u(u({},t),{},{datasets:[].concat(o(t.datasets||[]),[u(u({},n),r)])})},REMOVE_DATASET:function(t,e){var r,n=e.id;return u(u({},t),{},{datasets:(null===(r=t.datasets)||void 0===r?void 0:r.filter(function(t){return t.id!==n}))||[]})},SET_DATASET_VISIBILITY:function(t,e){var r,n=e.id,o=e.visibility;return u(u({},t),{},{datasets:null===(r=t.datasets)||void 0===r?void 0:r.map(function(t){return t.id===n?u(u({},t),{},{visibility:o}):t})})},HIDE_FEATURES:function(t,e){var r=e.layerId,n=e.idProperty,i=e.featureIds,a=t.hiddenFeatures[r],c=(null==a?void 0:a.ids)||[],s=o(new Set([].concat(o(c),o(i))));return u(u({},t),{},{hiddenFeatures:u(u({},t.hiddenFeatures),{},l({},r,{idProperty:n,ids:s}))})},SHOW_FEATURES:function(t,e){var r=e.layerId,n=e.featureIds,o=t.hiddenFeatures[r];if(!o)return t;var i=o.ids.filter(function(t){return!n.includes(t)});if(0===i.length){var a=t.hiddenFeatures,s=(a[r],function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],-1===e.indexOf(r)&&{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(a,[r].map(c)));return u(u({},t),{},{hiddenFeatures:s})}return u(u({},t),{},{hiddenFeatures:u(u({},t.hiddenFeatures),{},l({},r,u(u({},o),{},{ids:i})))})}},f=r(738),d={stroke:"#d4351c",strokeWidth:2,fill:"transparent",symbolDescription:"red outline",minZoom:6,maxZoom:24,showInKey:!1,showInLayers:!1,visibility:"visible"};function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}var p=function(t,e){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===y(t)){if(e&&t[e])return t[e];var r=Object.values(t)[0];return null!=r?r:null}return null};function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function m(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?m(Object(r),!0).forEach(function(e){h(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function h(t,e,r){return(e=function(t){var e=function(t){if("object"!=v(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=v(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==v(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var S=function(t){var e,r=0,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return g(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(t);try{for(n.s();!(e=n.n()).done;)r=(r<<5)-r+e.value.codePointAt(0),r&=r}catch(t){n.e(t)}finally{n.f()}return Math.abs(r).toString(36)},j=function(t){if(t.tiles){var e=Array.isArray(t.tiles)?t.tiles.join(","):t.tiles;return"tiles-".concat(S(e))}return t.geojson?w(t)?"geojson-dynamic-".concat(t.id):"string"==typeof t.geojson?"geojson-".concat(S(t.geojson)):"geojson-".concat(t.id):"source-".concat(t.id)},w=function(t){return"string"==typeof t.geojson&&!!t.idProperty&&"function"==typeof t.transformRequest},O=function(t,e,r){var n=j(r);if(!t.getSource(n))if(r.tiles)t.addSource(n,{type:"vector",tiles:r.tiles,minzoom:r.minZoom||0,maxzoom:r.maxZoom||22});else if(r.geojson){var o=w(r)?{type:"FeatureCollection",features:[]}:r.geojson;t.addSource(n,{type:"geojson",data:o})}var i=!!r.fill,a=!!r.stroke,u=i?r.id:null,l=a?i?"".concat(r.id,"-stroke"):r.id:null,c="hidden"===r.visibility?"none":"visible";if(i&&!t.getLayer(u)){var s,f=p(r.fill,e);t.addLayer(b({id:u,type:"fill",source:n,"source-layer":null!=r&&null!==(s=r.tiles)&&void 0!==s&&s.length?r.sourceLayer:void 0,layout:{visibility:c},paint:{"fill-color":f,"fill-opacity":r.opacity||1}},r.filter?{filter:r.filter}:{}))}if(a&&!t.getLayer(l)){var d,y=p(r.stroke,e);t.addLayer(b({id:l,type:"line",source:n,"source-layer":null!=r&&null!==(d=r.tiles)&&void 0!==d&&d.length?r.sourceLayer:void 0,layout:{visibility:c},paint:b({"line-color":y,"line-width":r.strokeWidth||1,"line-opacity":r.opacity||1},r.strokeDashArray?{"line-dasharray":r.strokeDashArray}:{})},r.filter?{filter:r.filter}:{}))}},k=function(t,e,r,n,o){if(t.getLayer(e)){var i=function(t,e,r){if(!r||0===r.length)return t;var n=["!",["in",["to-string",["get",e]],["literal",r.map(function(t){return String(t)})]]];return t?["all",t,n]:n}(r,n,o);t.setFilter(e,i)}};function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function P(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var l=n&&n.prototype instanceof u?n:u,c=Object.create(l.prototype);return E(c,"_invoke",function(r,n,o){var i,u,l,c=0,s=o||[],f=!1,d={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,l=t,d.n=r,a}};function y(r,n){for(u=r,l=n,e=0;!f&&c&&!o&&e<s.length;e++){var o,i=s[e],y=d.p,p=i[2];r>3?(o=p===n)&&(l=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,d.v=n,d.n=i[1]):y<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,d.n=p,u=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&y(s,p),u=s,l=p;(e=u<2?t:l)||!f;){i||(u?u<3?(u>1&&(d.n=-1),y(u,l)):d.n=l:d.v=l);try{if(c=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(f=d.n<0)?l:r.call(n,d))!==a)break}catch(e){i=t,u=1,l=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function u(){}function l(){}function c(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(E(e={},n,function(){return this}),e),f=c.prototype=u.prototype=Object.create(s);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,E(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return l.prototype=c,E(f,"constructor",c),E(c,"constructor",l),l.displayName="GeneratorFunction",E(c,o,"GeneratorFunction"),E(f),E(f,o,"Generator"),E(f,n,function(){return this}),E(f,"toString",function(){return"[object Generator]"}),(P=function(){return{w:i,m:d}})()}function E(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}E=function(t,e,r,n){function i(e,r){E(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},E(t,e,r,n)}function I(t,e,r,n,o,i,a){try{var u=t[i](a),l=u.value}catch(t){return void r(t)}u.done?e(l):Promise.resolve(l).then(n,o)}var x=function(){var t,e=(t=P().m(function t(e,r,n){var o,i,a,u,l,c,s;return P().w(function(t){for(;;)switch(t.n){case 0:return o=n(e,r),a=(i="string"==typeof o?{url:o}:o).url,u=i.headers,l=void 0===u?{}:u,t.n=1,fetch(a,{headers:l});case 1:if((c=t.v).ok){t.n=2;break}throw new Error("Failed to fetch GeoJSON: ".concat(c.status," ").concat(c.statusText));case 2:return t.n=3,c.json();case 3:if("FeatureCollection"!==(s=t.v).type){t.n=4;break}return t.a(2,s);case 4:if("Feature"!==s.type){t.n=5;break}return t.a(2,{type:"FeatureCollection",features:[s]});case 5:if(!Array.isArray(s)){t.n=6;break}return t.a(2,{type:"FeatureCollection",features:s});case 6:throw new Error("Invalid GeoJSON response");case 7:return t.a(2)}},t)}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){I(i,n,o,a,u,"next",t)}function u(t){I(i,n,o,a,u,"throw",t)}a(void 0)})});return function(t,r,n){return e.apply(this,arguments)}}();function T(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var D=function(t){var e=t.getBounds();return[e.getWest(),e.getSouth(),e.getEast(),e.getNorth()]},_=function(t,e){return!(!t||!e)&&e[0]>=t[0]&&e[1]>=t[1]&&e[2]<=t[2]&&e[3]<=t[3]},L=function(t,e){return t?[Math.min(t[0],e[0]),Math.min(t[1],e[1]),Math.max(t[2],e[2]),Math.max(t[3],e[3])]:function(t){if(Array.isArray(t))return T(t)}(r=e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return T(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?T(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var r},F=function(t,e){return!(!t||!e||t[2]<e[0]||t[0]>e[2]||t[3]<e[1]||t[1]>e[3])},M=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0,i=function(t,a){var u;0===a?(u=t,e=Math.min(e,u[0]),r=Math.min(r,u[1]),n=Math.max(n,u[0]),o=Math.max(o,u[1])):t.forEach(function(t){return i(t,a-1)})};switch(t.type){case"Point":i(t.coordinates,0);break;case"LineString":case"MultiPoint":i(t.coordinates,1);break;case"Polygon":case"MultiLineString":i(t.coordinates,2);break;case"MultiPolygon":i(t.coordinates,3);break;case"GeometryCollection":t.geometries.forEach(function(t){var i=M(t);e=Math.min(e,i[0]),r=Math.min(r,i[1]),n=Math.max(n,i[2]),o=Math.max(o,i[3])})}return[e,r,n,o]};function C(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var l=n&&n.prototype instanceof u?n:u,c=Object.create(l.prototype);return N(c,"_invoke",function(r,n,o){var i,u,l,c=0,s=o||[],f=!1,d={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,l=t,d.n=r,a}};function y(r,n){for(u=r,l=n,e=0;!f&&c&&!o&&e<s.length;e++){var o,i=s[e],y=d.p,p=i[2];r>3?(o=p===n)&&(l=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,d.v=n,d.n=i[1]):y<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,d.n=p,u=0))}if(o||r>1)return a;throw f=!0,n}return function(o,s,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===s&&y(s,p),u=s,l=p;(e=u<2?t:l)||!f;){i||(u?u<3?(u>1&&(d.n=-1),y(u,l)):d.n=l:d.v=l);try{if(c=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(f=d.n<0)?l:r.call(n,d))!==a)break}catch(e){i=t,u=1,l=e}finally{c=1}}return{value:e,done:f}}}(r,o,i),!0),c}var a={};function u(){}function l(){}function c(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(N(e={},n,function(){return this}),e),f=c.prototype=u.prototype=Object.create(s);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,N(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return l.prototype=c,N(f,"constructor",c),N(c,"constructor",l),l.displayName="GeneratorFunction",N(c,o,"GeneratorFunction"),N(f),N(f,o,"Generator"),N(f,n,function(){return this}),N(f,"toString",function(){return"[object Generator]"}),(C=function(){return{w:i,m:d}})()}function N(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}N=function(t,e,r,n){function i(e,r){N(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},N(t,e,r,n)}function W(t,e,r,n,o,i,a){try{var u=t[i](a),l=u.value}catch(t){return void r(t)}u.done?e(l):Promise.resolve(l).then(n,o)}function G(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||R(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(t,e){if(t){if("string"==typeof t)return U(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?U(t,e):void 0}}function U(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var z=function(t){var e=t.pluginConfig,r=t.pluginStateRef,n=t.mapStyleId,o=t.mapProvider,i=t.events,a=t.eventBus,u=o.map,l=e.datasets,c=new Map,s=function(){return r.current.datasets||l};l.forEach(function(t){if(O(u,n,t),w(t)){var e=j(t),r=function(t){var e,r,n,o=t.dataset,i=t.map,a=t.sourceId,u=t.onUpdate,l=o.geojson,c=o.idProperty,s=o.transformRequest,f=o.maxFeatures,d=o.minZoom,y=void 0===d?0:d,p=new Map,v=null,m=!1,b=function(){return{type:"FeatureCollection",features:Array.from(p.values()).map(function(t){return t.feature})}},h=function(t){var e,r;return c&&null!==(e=null===(r=t.properties)||void 0===r?void 0:r[c])&&void 0!==e?e:t.id},g=function(t){if(f&&!(p.size<=1.2*f)){var e,r=f,n=[],o=[],i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=R(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==e.return||e.return()}finally{if(a)throw o}}}}(p);try{for(i.s();!(e=i.n()).done;){var a=G(e.value,2),u=a[0],l=a[1];F(l.bbox,t)?n.push(u):o.push({id:u,addedAt:l.addedAt})}}catch(t){i.e(t)}finally{i.f()}o.sort(function(t,e){return t.addedAt-e.addedAt});for(var c=p.size-r,s=0;s<c&&s<o.length;s++)p.delete(o[s].id);if(p.size>r)for(var d=p.size-r,y=n.map(function(t){return{id:t,addedAt:p.get(t).addedAt}}).sort(function(t,e){return t.addedAt-e.addedAt}),v=0;v<d&&v<y.length;v++)p.delete(y[v].id)}},S=function(){var t,e=(t=C().m(function t(){var e,r,n,c,f,d;return C().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!((e=i.getZoom())<y)){t.n=1;break}return t.a(2);case 1:if(r=D(i),!v||!_(v,r)){t.n=2;break}return t.a(2);case 2:if(!m){t.n=3;break}return t.a(2);case 3:return m=!0,t.p=4,n={bbox:r,zoom:e,dataset:o},t.n=5,x(l,n,s);case 5:c=t.v,f=Date.now(),c.features.forEach(function(t){var e=h(t);null!=e?p.set(e,{feature:t,bbox:M(t.geometry),addedAt:p.has(e)?p.get(e).addedAt:f}):console.warn("Feature missing ID, skipping:",t)}),v=L(v,r),g(r),u(a,b()),t.n=7;break;case 6:t.p=6,d=t.v,console.error("Failed to fetch dynamic GeoJSON for ".concat(o.id,":"),d);case 7:return t.p=7,m=!1,t.f(7);case 8:return t.a(2)}},t,null,[[4,6,7,8]])}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){W(i,n,o,a,u,"next",t)}function u(t){W(i,n,o,a,u,"throw",t)}a(void 0)})});return function(){return e.apply(this,arguments)}}(),j=(e=S,n=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(function(){return e.apply(void 0,n)},200)},n.cancel=function(){clearTimeout(r),r=null},n),w=function(){j()};return i.on("moveend",w),S(),{destroy:function(){i.off("moveend",w),j.cancel()},clear:function(){p.clear(),v=null,u(a,{type:"FeatureCollection",features:[]})},refresh:function(){p.clear(),v=null,S()},getFeatureCount:function(){return p.size},reapply:function(){p.size>0&&u(a,b())}}}({dataset:t,map:u,sourceId:e,onUpdate:function(t,e){return function(t,e,r){var n=t.getSource(e);n&&"function"==typeof n.setData&&n.setData(r)}(u,t,e)}});c.set(t.id,r)}}),u.once("idle",function(){a.emit("datasets:ready")});var f=function(t){var e=t.map,r=t.events,n=t.getDatasets,o=t.getHiddenFeatures,i=t.getDynamicSources,a=function(t){e.once("idle",function(){var r=t.id,a=n(),u=o(),l=i?i():new Map;a.forEach(function(t){O(e,r,t)}),l.forEach(function(t){t.reapply()}),Object.entries(u).forEach(function(t){var r=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return A(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?A(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),n=r[0],o=r[1],i=o.idProperty,u=o.ids,l=a.find(function(t){return t.id===n});if(l){var c=l.filter||null,s=!!l.fill,f=!!l.stroke,d=s?n:null,y=f?s?"".concat(n,"-stroke"):n:null;d&&k(e,d,c,i,u),y&&k(e,y,c,i,u)}})})};return t.eventBus.on(r.MAP_SET_STYLE,a),a}({map:u,events:i,eventBus:a,getDatasets:s,getHiddenFeatures:function(){return r.current.hiddenFeatures||{}},getDynamicSources:function(){return c}});return{remove:function(){a.off(i.MAP_SET_STYLE,f),c.forEach(function(t){return t.destroy()}),c.clear();var t=s(),e=new Set;t.forEach(function(t){var r=j(t),n=function(t,e){var r=t.getStyle();return null!=r&&r.layers?r.layers.filter(function(t){return t.source===e}).map(function(t){return t.id}):[]}(u,r);n.forEach(function(t){return u.removeLayer(t)}),!e.has(r)&&u.getSource(r)&&(u.removeSource(r),e.add(r))})},refreshDataset:function(t){var e=c.get(t);e&&e.refresh()},clearDatasetCache:function(t){var e=c.get(t);e&&e.clear()},getFeatureCount:function(t){var e=c.get(t);return e?e.getFeatureCount():null}}},B=function(t,e){var r=t.mapProvider,n=t.pluginState,o=r.map;o.getLayer(e)&&o.setLayoutProperty(e,"visibility","visible"),o.getLayer("".concat(e,"-stroke"))&&o.setLayoutProperty("".concat(e,"-stroke"),"visibility","visible"),n.dispatch({type:"SET_DATASET_VISIBILITY",payload:{id:e,visibility:"visible"}})},K=function(t,e){var r=t.mapProvider,n=t.pluginState,o=r.map;o.getLayer(e)&&o.setLayoutProperty(e,"visibility","none"),o.getLayer("".concat(e,"-stroke"))&&o.setLayoutProperty("".concat(e,"-stroke"),"visibility","none"),n.dispatch({type:"SET_DATASET_VISIBILITY",payload:{id:e,visibility:"hidden"}})},H=r(287);function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}function $(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function V(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$(Object(r),!0).forEach(function(e){Y(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Y(t,e,r){return(e=function(t){var e=function(t){if("object"!=Z(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Z(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Z(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function J(t){return function(t){if(Array.isArray(t))return q(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return q(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Q={InitComponent:function(t){var e,r=t.pluginConfig,n=t.pluginState,o=t.appState,i=t.mapState,a=t.mapProvider,u=t.services,l=n.dispatch,c=u.events,s=u.eventBus,y=!(null===(e=a.map)||void 0===e||!e.getStyle()),p=(0,f.useRef)(n);p.current=n;var v=(0,f.useRef)(null);return(0,f.useEffect)(function(){var t,e,u,f,m=null===(t=null===(e=r.includeModes)||void 0===e?void 0:e.includes(o.mode))||void 0===t||t,b=null!==(u=null===(f=r.excludeModes)||void 0===f?void 0:f.includes(o.mode))&&void 0!==u&&u;y&&m&&!b&&(v.current||(n.datasets||l({type:"SET_DATASETS",payload:{datasets:r.datasets,datasetDefaults:d}}),v.current=z({mapStyleId:i.mapStyle.id,pluginConfig:r,pluginStateRef:p,mapProvider:a,events:c,eventBus:s})))},[y,o.mode]),(0,f.useEffect)(function(){return function(){v.current&&(v.current.remove(),v.current=null)}},[]),null},reducer:{initialState:{datasets:null,hiddenFeatures:{}},actions:s},panels:[{id:"datasetsLayers",label:"Layers",mobile:{slot:"bottom",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"300px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"320px"},render:function(t){var e=t.pluginState,r=t.mapProvider,n=function(t){var n=t.target,o=n.value;n.checked?B({mapProvider:r,pluginState:e},o):K({mapProvider:r,pluginState:e},o)};return(0,H.jsx)("div",{className:"im-c-datasets-layers",children:(0,H.jsx)("div",{className:"govuk-form-group",children:(0,H.jsxs)("fieldset",{className:"govuk-fieldset",children:[(0,H.jsx)("legend",{className:"govuk-visually-hidden",children:"Layers"}),(0,H.jsx)("div",{className:"govuk-checkboxes govuk-checkboxes--small","data-module":"govuk-checkboxes",children:(e.datasets||[]).filter(function(t){return t.showInLayers}).map(function(t){return(0,H.jsx)("div",{className:"im-c-datasets-layers__item".concat("hidden"!==t.visibility?" im-c-datasets-layers__item--checked":""),children:(0,H.jsxs)("div",{className:"govuk-checkboxes__item",children:[(0,H.jsx)("input",{className:"govuk-checkboxes__input",id:t.id,name:"layers",type:"checkbox",value:t.id,checked:"hidden"!==t.visibility,onChange:n}),(0,H.jsx)("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:t.id,children:t.label})]})},t.id)})})]})})})}},{id:"datasetsKey",label:"Key",mobile:{slot:"bottom",modal:!0},tablet:{slot:"left-top",width:"300px"},desktop:{slot:"left-top",width:"320px"},render:function(t){var e=t.mapState,r=t.pluginState,n=e.mapStyle,o=function(t){return(0,H.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:"line"===t.keySymbolShape?(0,H.jsx)("line",{x1:t.strokeWidth/2,y1:"10",x2:20-t.strokeWidth/2,y2:"10",stroke:p(t.stroke,n.id),strokeWidth:t.strokeWidth,strokeLinecap:"round"}):(0,H.jsx)("rect",{x:t.strokeWidth/2,y:t.strokeWidth/2,width:20-t.strokeWidth,height:20-t.strokeWidth,rx:t.strokeWidth,ry:t.strokeWidth,fill:p(t.fill,n.id),stroke:p(t.stroke,n.id),strokeWidth:t.strokeWidth,strokeLinejoin:"round"})})};return(0,H.jsx)("div",{className:"im-c-datasets-key",children:(r.datasets||[]).filter(function(t){return t.showInKey&&"hidden"!==t.visibility}).map(function(t){return(0,H.jsx)("div",{className:"im-c-datasets-key__item",children:(0,H.jsxs)("div",{className:"im-c-datasets-key__item-label",children:[o(t),t.label,t.symbolDescription&&(0,H.jsxs)("span",{className:"govuk-visually-hidden",children:["(",p(t.symbolDescription,n.id),")"]})]})},t.id)})})}}],buttons:[{id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",iconId:"layers",excludeWhen:function(t){return!t.pluginConfig.datasets.find(function(t){return t.showInLayers})},mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}},{id:"datasetsKey",label:"Key",panelId:"datasetsKey",iconId:"key",excludeWhen:function(t){return!t.pluginConfig.datasets.find(function(t){return t.showInKey})},mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"layers",svgContent:'<path d="M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74z"></path><path d="m20 14.285 1.5.845a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74l1.5-.845"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{showDataset:B,hideDataset:K,addDataset:function(t,e){var r=t.mapProvider,n=t.mapState,o=t.pluginState,i=r.map;O(i,n.mapStyle.id,V(V({},d),e)),o.dispatch({type:"ADD_DATASET",payload:{dataset:e,datasetDefaults:d}})},removeDataset:function(t,e){var r,n,o=t.mapProvider,i=t.pluginState,a=o.map,u=null===(r=i.datasets)||void 0===r?void 0:r.find(function(t){return t.id===e});if(u){var l=function(t){var e=!!t.fill,r=!!t.stroke,n=e?t.id:null,o=null;return r&&(o=e?"".concat(t.id,"-stroke"):t.id),{fillLayerId:n,strokeLayerId:o}}(u),c=l.fillLayerId,s=l.strokeLayerId,f=j(u);[s,c].forEach(function(t){t&&a.getLayer(t)&&a.removeLayer(t)}),!(null===(n=i.datasets)||void 0===n?void 0:n.some(function(t){return t.id!==e&&j(t)===f}))&&a.getSource(f)&&a.removeSource(f),i.dispatch({type:"REMOVE_DATASET",payload:{id:e}})}},showFeatures:function(t,e){var r,n=t.mapProvider,o=t.pluginState,i=e.featureIds,a=e.idProperty,u=e.datasetId,l=n.map,c=o.hiddenFeatures[u];if(c){var s=null===(r=o.datasets)||void 0===r?void 0:r.find(function(t){return t.id===u});if(s){var f=s.filter||null,d=!!s.fill,y=!!s.stroke,p=d?u:null,v=null;y&&(v=d?"".concat(u,"-stroke"):u);var m=c.ids.filter(function(t){return!i.includes(t)});o.dispatch({type:"SHOW_FEATURES",payload:{layerId:u,featureIds:i}}),p&&k(l,p,f,a,m),v&&k(l,v,f,a,m)}}},hideFeatures:function(t,e){var r,n=t.mapProvider,o=t.pluginState,i=e.featureIds,a=e.idProperty,u=e.datasetId,l=n.map,c=null===(r=o.datasets)||void 0===r?void 0:r.find(function(t){return t.id===u});if(c){var s=c.filter||null,f=!!c.fill,d=!!c.stroke,y=f?u:null,p=null;d&&(p=f?"".concat(u,"-stroke"):u);var v=o.hiddenFeatures[u],m=v?J(new Set([].concat(J(v.ids),J(i)))):i;o.dispatch({type:"HIDE_FEATURES",payload:{layerId:u,idProperty:a,featureIds:i}}),y&&k(l,y,s,a,m),p&&k(l,p,s,a,m)}}}}}}]);
|
|
@@ -31,7 +31,7 @@ export function DatasetsInit ({ pluginConfig, pluginState, appState, mapState, m
|
|
|
31
31
|
|
|
32
32
|
// Only initialise state if not already set
|
|
33
33
|
if (!pluginState.datasets) {
|
|
34
|
-
dispatch({ type: 'SET_DATASETS', payload: { datasets: pluginConfig.datasets, datasetDefaults }})
|
|
34
|
+
dispatch({ type: 'SET_DATASETS', payload: { datasets: pluginConfig.datasets, datasetDefaults } })
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
datasetsInstanceRef.current = createDatasets({
|
|
@@ -52,7 +52,7 @@ export const createDatasets = ({
|
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
return {
|
|
55
|
-
remove() {
|
|
55
|
+
remove () {
|
|
56
56
|
eventBus.off(events.MAP_SET_STYLE, styleHandler)
|
|
57
57
|
|
|
58
58
|
// Clean up dynamic sources
|
|
@@ -82,7 +82,7 @@ export const createDatasets = ({
|
|
|
82
82
|
* Refresh a dynamic source - clears cache and re-fetches
|
|
83
83
|
* @param {string} datasetId - Dataset ID to refresh
|
|
84
84
|
*/
|
|
85
|
-
refreshDataset(datasetId) {
|
|
85
|
+
refreshDataset (datasetId) {
|
|
86
86
|
const dynamicSource = dynamicSources.get(datasetId)
|
|
87
87
|
if (dynamicSource) {
|
|
88
88
|
dynamicSource.refresh()
|
|
@@ -93,7 +93,7 @@ export const createDatasets = ({
|
|
|
93
93
|
* Clear a dynamic source's cache
|
|
94
94
|
* @param {string} datasetId - Dataset ID to clear
|
|
95
95
|
*/
|
|
96
|
-
clearDatasetCache(datasetId) {
|
|
96
|
+
clearDatasetCache (datasetId) {
|
|
97
97
|
const dynamicSource = dynamicSources.get(datasetId)
|
|
98
98
|
if (dynamicSource) {
|
|
99
99
|
dynamicSource.clear()
|
|
@@ -105,7 +105,7 @@ export const createDatasets = ({
|
|
|
105
105
|
* @param {string} datasetId - Dataset ID
|
|
106
106
|
* @returns {number|null} Feature count or null if not a dynamic source
|
|
107
107
|
*/
|
|
108
|
-
getFeatureCount(datasetId) {
|
|
108
|
+
getFeatureCount (datasetId) {
|
|
109
109
|
const dynamicSource = dynamicSources.get(datasetId)
|
|
110
110
|
return dynamicSource ? dynamicSource.getFeatureCount() : null
|
|
111
111
|
}
|
|
@@ -164,7 +164,7 @@ export const createDynamicSource = ({ dataset, map, sourceId, onUpdate }) => {
|
|
|
164
164
|
/**
|
|
165
165
|
* Clean up event listeners
|
|
166
166
|
*/
|
|
167
|
-
destroy() {
|
|
167
|
+
destroy () {
|
|
168
168
|
map.off('moveend', handleMoveEnd)
|
|
169
169
|
debouncedFetch.cancel()
|
|
170
170
|
},
|
|
@@ -172,7 +172,7 @@ export const createDynamicSource = ({ dataset, map, sourceId, onUpdate }) => {
|
|
|
172
172
|
/**
|
|
173
173
|
* Clear all cached features and reset fetch tracking
|
|
174
174
|
*/
|
|
175
|
-
clear() {
|
|
175
|
+
clear () {
|
|
176
176
|
features.clear()
|
|
177
177
|
fetchedBbox = null
|
|
178
178
|
onUpdate(sourceId, { type: 'FeatureCollection', features: [] })
|
|
@@ -181,7 +181,7 @@ export const createDynamicSource = ({ dataset, map, sourceId, onUpdate }) => {
|
|
|
181
181
|
/**
|
|
182
182
|
* Force refresh - clear cache and fetch current viewport
|
|
183
183
|
*/
|
|
184
|
-
refresh() {
|
|
184
|
+
refresh () {
|
|
185
185
|
features.clear()
|
|
186
186
|
fetchedBbox = null
|
|
187
187
|
fetchData()
|
|
@@ -190,14 +190,14 @@ export const createDynamicSource = ({ dataset, map, sourceId, onUpdate }) => {
|
|
|
190
190
|
/**
|
|
191
191
|
* Get current feature count
|
|
192
192
|
*/
|
|
193
|
-
getFeatureCount() {
|
|
193
|
+
getFeatureCount () {
|
|
194
194
|
return features.size
|
|
195
195
|
},
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Re-push cached features to the source (e.g., after style change)
|
|
199
199
|
*/
|
|
200
|
-
reapply() {
|
|
200
|
+
reapply () {
|
|
201
201
|
if (features.size > 0) {
|
|
202
202
|
onUpdate(sourceId, toFeatureCollection())
|
|
203
203
|
}
|
|
@@ -27,20 +27,20 @@ export const manifest = {
|
|
|
27
27
|
dismissible: true
|
|
28
28
|
},
|
|
29
29
|
tablet: {
|
|
30
|
-
slot: '
|
|
30
|
+
slot: 'left-top',
|
|
31
31
|
dismissible: true,
|
|
32
32
|
exclusive: true,
|
|
33
33
|
width: '300px'
|
|
34
34
|
},
|
|
35
35
|
desktop: {
|
|
36
|
-
slot: '
|
|
36
|
+
slot: 'left-top',
|
|
37
37
|
modal: false,
|
|
38
38
|
dismissible: true,
|
|
39
39
|
exclusive: true,
|
|
40
40
|
width: '320px'
|
|
41
41
|
},
|
|
42
42
|
render: Layers
|
|
43
|
-
},{
|
|
43
|
+
}, {
|
|
44
44
|
id: 'datasetsKey',
|
|
45
45
|
label: 'Key',
|
|
46
46
|
mobile: {
|
|
@@ -48,11 +48,11 @@ export const manifest = {
|
|
|
48
48
|
modal: true
|
|
49
49
|
},
|
|
50
50
|
tablet: {
|
|
51
|
-
slot: '
|
|
51
|
+
slot: 'left-top',
|
|
52
52
|
width: '300px'
|
|
53
53
|
},
|
|
54
54
|
desktop: {
|
|
55
|
-
slot: '
|
|
55
|
+
slot: 'left-top',
|
|
56
56
|
width: '320px'
|
|
57
57
|
},
|
|
58
58
|
render: Key
|
|
@@ -76,7 +76,7 @@ export const manifest = {
|
|
|
76
76
|
slot: 'top-left',
|
|
77
77
|
showLabel: true
|
|
78
78
|
}
|
|
79
|
-
},{
|
|
79
|
+
}, {
|
|
80
80
|
id: 'datasetsKey',
|
|
81
81
|
label: 'Key',
|
|
82
82
|
panelId: 'datasetsKey',
|
|
@@ -99,7 +99,7 @@ export const manifest = {
|
|
|
99
99
|
icons: [{
|
|
100
100
|
id: 'layers',
|
|
101
101
|
svgContent: '<path d="M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74z"></path><path d="m20 14.285 1.5.845a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74l1.5-.845"></path>'
|
|
102
|
-
},{
|
|
102
|
+
}, {
|
|
103
103
|
id: 'key',
|
|
104
104
|
svgContent: '<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'
|
|
105
105
|
}],
|
|
@@ -81,7 +81,6 @@ const addMapLayers = (map, mapStyleId, dataset) => {
|
|
|
81
81
|
|
|
82
82
|
// --- Add source (shared across datasets with same tiles/data URL) ---
|
|
83
83
|
if (!map.getSource(sourceId)) {
|
|
84
|
-
|
|
85
84
|
if (dataset.tiles) {
|
|
86
85
|
// Tiles
|
|
87
86
|
map.addSource(sourceId, {
|
|
@@ -111,7 +110,7 @@ const addMapLayers = (map, mapStyleId, dataset) => {
|
|
|
111
110
|
const hasStroke = !!dataset.stroke
|
|
112
111
|
const fillLayerId = hasFill ? dataset.id : null
|
|
113
112
|
const strokeLayerId = hasStroke ? (hasFill ? `${dataset.id}-stroke` : dataset.id) : null
|
|
114
|
-
|
|
113
|
+
|
|
115
114
|
// --- Determie visiblity ---
|
|
116
115
|
const visibility = dataset.visibility === 'hidden' ? 'none' : 'visible'
|
|
117
116
|
|
|
@@ -162,4 +161,4 @@ export {
|
|
|
162
161
|
addMapLayers,
|
|
163
162
|
isDynamicSource,
|
|
164
163
|
updateSourceData
|
|
165
|
-
}
|
|
164
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import { getValueForStyle } from '../../../../../src/utils/getValueForStyle'
|
|
3
3
|
|
|
4
4
|
export const Key = ({ mapState, pluginState }) => {
|
|
@@ -13,42 +13,44 @@ export const Key = ({ mapState, pluginState }) => {
|
|
|
13
13
|
aria-hidden='true'
|
|
14
14
|
focusable='false'
|
|
15
15
|
>
|
|
16
|
-
{dataset.keySymbolShape === 'line'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
16
|
+
{dataset.keySymbolShape === 'line'
|
|
17
|
+
? (
|
|
18
|
+
<line
|
|
19
|
+
x1={dataset.strokeWidth / 2}
|
|
20
|
+
y1='10'
|
|
21
|
+
x2={20 - dataset.strokeWidth / 2}
|
|
22
|
+
y2='10'
|
|
23
|
+
stroke={getValueForStyle(dataset.stroke, mapStyle.id)}
|
|
24
|
+
strokeWidth={dataset.strokeWidth}
|
|
25
|
+
strokeLinecap='round'
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
: (
|
|
29
|
+
<rect
|
|
30
|
+
x={dataset.strokeWidth / 2}
|
|
31
|
+
y={dataset.strokeWidth / 2}
|
|
32
|
+
width={20 - dataset.strokeWidth}
|
|
33
|
+
height={20 - dataset.strokeWidth}
|
|
34
|
+
rx={dataset.strokeWidth}
|
|
35
|
+
ry={dataset.strokeWidth}
|
|
36
|
+
fill={getValueForStyle(dataset.fill, mapStyle.id)}
|
|
37
|
+
stroke={getValueForStyle(dataset.stroke, mapStyle.id)}
|
|
38
|
+
strokeWidth={dataset.strokeWidth}
|
|
39
|
+
strokeLinejoin='round'
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
40
42
|
</svg>
|
|
41
43
|
)
|
|
42
44
|
|
|
43
45
|
return (
|
|
44
|
-
<div className=
|
|
46
|
+
<div className='im-c-datasets-key'>
|
|
45
47
|
{(pluginState.datasets || []).filter(dataset => dataset.showInKey && dataset.visibility !== 'hidden').map(dataset => (
|
|
46
|
-
<div key={dataset.id} className=
|
|
47
|
-
<div className=
|
|
48
|
+
<div key={dataset.id} className='im-c-datasets-key__item'>
|
|
49
|
+
<div className='im-c-datasets-key__item-label'>
|
|
48
50
|
{itemSymbol(dataset)}
|
|
49
51
|
{dataset.label}
|
|
50
52
|
{dataset.symbolDescription && (
|
|
51
|
-
<span className=
|
|
53
|
+
<span className='govuk-visually-hidden'>
|
|
52
54
|
({getValueForStyle(dataset.symbolDescription, mapStyle.id)})
|
|
53
55
|
</span>
|
|
54
56
|
)}
|
|
@@ -3,7 +3,6 @@ import { showDataset } from '../api/showDataset'
|
|
|
3
3
|
import { hideDataset } from '../api/hideDataset'
|
|
4
4
|
|
|
5
5
|
export const Layers = ({ pluginState, mapProvider }) => {
|
|
6
|
-
|
|
7
6
|
const handleChange = (e) => {
|
|
8
7
|
const { value, checked } = e.target
|
|
9
8
|
if (checked) {
|
|
@@ -14,18 +13,18 @@ export const Layers = ({ pluginState, mapProvider }) => {
|
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
return (
|
|
17
|
-
<div className=
|
|
18
|
-
<div className=
|
|
19
|
-
<fieldset className=
|
|
20
|
-
<legend className=
|
|
16
|
+
<div className='im-c-datasets-layers'>
|
|
17
|
+
<div className='govuk-form-group'>
|
|
18
|
+
<fieldset className='govuk-fieldset'>
|
|
19
|
+
<legend className='govuk-visually-hidden'>
|
|
21
20
|
Layers
|
|
22
21
|
</legend>
|
|
23
|
-
<div className=
|
|
22
|
+
<div className='govuk-checkboxes govuk-checkboxes--small' data-module='govuk-checkboxes'>
|
|
24
23
|
{(pluginState.datasets || []).filter(dataset => dataset.showInLayers).map(dataset => (
|
|
25
24
|
<div key={dataset.id} className={`im-c-datasets-layers__item${dataset.visibility !== 'hidden' ? ' im-c-datasets-layers__item--checked' : ''}`}>
|
|
26
|
-
<div className=
|
|
27
|
-
<input className=
|
|
28
|
-
<label className=
|
|
25
|
+
<div className='govuk-checkboxes__item'>
|
|
26
|
+
<input className='govuk-checkboxes__input' id={dataset.id} name='layers' type='checkbox' value={dataset.id} checked={dataset.visibility !== 'hidden'} onChange={handleChange} />
|
|
27
|
+
<label className='im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label' htmlFor={dataset.id}>
|
|
29
28
|
{dataset.label}
|
|
30
29
|
</label>
|
|
31
30
|
</div>
|
|
@@ -22,7 +22,7 @@ export const bboxContains = (outer, inner) => {
|
|
|
22
22
|
inner[0] >= outer[0] && // west
|
|
23
23
|
inner[1] >= outer[1] && // south
|
|
24
24
|
inner[2] <= outer[2] && // east
|
|
25
|
-
inner[3] <= outer[3]
|
|
25
|
+
inner[3] <= outer[3] // north
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -40,7 +40,7 @@ export const expandBbox = (existing, addition) => {
|
|
|
40
40
|
Math.min(existing[0], addition[0]), // west
|
|
41
41
|
Math.min(existing[1], addition[1]), // south
|
|
42
42
|
Math.max(existing[2], addition[2]), // east
|
|
43
|
-
Math.max(existing[3], addition[3])
|
|
43
|
+
Math.max(existing[3], addition[3]) // north
|
|
44
44
|
]
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -58,7 +58,7 @@ export const bboxIntersects = (a, b) => {
|
|
|
58
58
|
a[2] < b[0] || // a is left of b
|
|
59
59
|
a[0] > b[2] || // a is right of b
|
|
60
60
|
a[3] < b[1] || // a is below b
|
|
61
|
-
a[1] > b[3]
|
|
61
|
+
a[1] > b[3] // a is above b
|
|
62
62
|
)
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -68,7 +68,7 @@ export const bboxIntersects = (a, b) => {
|
|
|
68
68
|
* @returns {number[]} bbox as [west, south, east, north]
|
|
69
69
|
*/
|
|
70
70
|
export const getGeometryBbox = (geometry) => {
|
|
71
|
-
let minX = Infinity
|
|
71
|
+
let minX = Infinity; let minY = Infinity; let maxX = -Infinity; let maxY = -Infinity
|
|
72
72
|
|
|
73
73
|
const processCoord = (coord) => {
|
|
74
74
|
minX = Math.min(minX, coord[0])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import{useEffect as t}from"preact/compat";import r from"@arcgis/core/widgets/Sketch/SketchViewModel.js";import o from"@arcgis/core/layers/GraphicsLayer.js";import a from"@babel/runtime/helpers/asyncToGenerator";import*as n from"@arcgis/core/geometry/operators/simplifyOperator.js";import i from"@arcgis/core/Graphic.js";function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function p(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?l(Object(o),!0).forEach(function(r){e(t,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):l(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})}return t}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import{useEffect as t}from"preact/compat";import r from"@arcgis/core/widgets/Sketch/SketchViewModel.js";import o from"@arcgis/core/layers/GraphicsLayer.js";import a from"@babel/runtime/helpers/asyncToGenerator";import*as n from"@arcgis/core/geometry/operators/simplifyOperator.js";import i from"@arcgis/core/Graphic.js";function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function p(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?l(Object(o),!0).forEach(function(r){e(t,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):l(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})}return t}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function u(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?c(Object(o),!0).forEach(function(r){e(t,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):c(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})}return t}function s(e){return{type:"simple-fill",color:[0,120,255,.2],outline:{color:"dark"===e?"#ffffff":"#d4351c",width:2}}}function d(e,t,r){return new i({geometry:{type:"polygon",rings:t,spatialReference:27700},attributes:{id:e},symbol:s(r)})}function y(e){if(null==e||!e.geometry)throw new Error("Invalid graphic");var{geometry:t,attributes:r={}}=e;switch(t.type){case"point":return{type:"Feature",geometry:{type:"Point",coordinates:[t.x,t.y]},properties:u({},r)};case"polyline":return{type:"Feature",geometry:{type:"LineString",coordinates:t.paths[0]},properties:u({},r)};case"polygon":return{type:"Feature",geometry:{type:"Polygon",coordinates:t.rings},properties:u({},r)};default:throw new Error("Unsupported geometry type: ".concat(t.type))}}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function v(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?m(Object(o),!0).forEach(function(r){e(t,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):m(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})}return t}var f={mobile:{slot:"actions",showLabel:!0},tablet:{slot:"actions",showLabel:!0},desktop:{slot:"actions",showLabel:!0}},h={reducer:{initialState:{mode:null,feature:null,tempFeature:null},actions:{SET_MODE:(e,t)=>p(p({},e),{},{mode:t}),SET_FEATURE:(e,t)=>p(p({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature})}},InitComponent:e=>{var i,l,p,c,{appState:u,mapState:m,pluginConfig:v,pluginState:f,services:h,mapProvider:g,buttonConfig:b}=e,{events:O,eventBus:w}=h,{mapColorScheme:S}=m.mapStyle||{},E=null===(i=null===(l=v.includeModes)||void 0===l?void 0:l.includes(u.mode))||void 0===i||i,k=null!==(p=null===(c=v.excludeModes)||void 0===c?void 0:c.includes(u.mode))&&void 0!==p&&p,P=m.isMapReady&&E&&!k;t(()=>{if(P&&!g.sketchViewModel){var{sketchViewModel:e,sketchLayer:t,emptySketchLayer:a}=(e=>{var{mapProvider:t}=e,{view:a}=t,n=new o({id:"sketchLayer"});a.map.add(n);var i=new o({id:"emptySketchLayer"});return a.map.add(i),{sketchViewModel:new r({view:a,layer:i,defaultUpdateOptions:{tool:"reshape",updateOnGraphicClick:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,highlightOptions:{enabled:!1}}}),emptySketchLayer:i,sketchLayer:n}})({mapProvider:g});return g.sketchViewModel=e,g.sketchLayer=t,g.emptySketchLayer=a,w.emit("draw:ready"),()=>{g.sketchViewModel=null,g.sketchLayer=null,g.emptySketchLayer=null}}},[m.isMapReady,u.mode]),t(()=>{if(P&&g.sketchViewModel){var e=function(e){var{pluginState:t,mapProvider:r,events:o,eventBus:i,buttonConfig:l,mapColorScheme:p}=e,{view:c,sketchViewModel:u,sketchLayer:m,emptySketchLayer:v}=r;if(!u)return null;var{drawDone:f,drawCancel:h}=l,{dispatch:g,mode:b,feature:O}=t,w=function(){var e=a(function*(){var e,r=null===(e=t.feature)||void 0===e||null===(e=e.properties)||void 0===e?void 0:e.id,o=null,a="active"===u.state&&!r;if("active"===u.state&&r&&(u.cancel(),yield new Promise(e=>setTimeout(e,50))),u.polygonSymbol=s(p),null==m||m.graphics.items.forEach(e=>{var t=d(e.attributes.id,e.geometry.rings,p);e.symbol=t.symbol,r===e.attributes.id&&(o=e)}),o&&!a&&u.layer===m)try{yield u.update(o,{tool:"reshape",toggleToolOnClick:!1})}catch(e){"AbortError"!==e.name&&console.error("Error updating sketch:",e)}});return function(){return e.apply(this,arguments)}}(),S=()=>{var e,t,r=null!==(e=null===(t=m.graphics)||void 0===t||null===(t=t.items)||void 0===t?void 0:t[0])&&void 0!==e?e:null;r&&setTimeout(()=>u.update(r),0)},E=()=>w(),k=e=>{if(e){var t=y(e);i.emit("draw:updated",t),g({type:"SET_FEATURE",payload:{tempFeature:t}})}},P=function(){var e=a(function*(){b&&((u.updateGraphics||[]).length||S())});return function(){return e.apply(this,arguments)}}(),j=function(){var e=a(function*(e){var{toolEventInfo:t}=e,r=null==e?void 0:e.graphic;if(r&&"vertex-add"===(null==t?void 0:t.type)){var o,a,n=null===(o=r.geometry)||void 0===o?void 0:o.rings;(null==n?void 0:n.length)>1?setTimeout(()=>u.undo(),0):(null==n||null===(a=n[0])||void 0===a?void 0:a.length)>3&&k(r)}});return function(t){return e.apply(this,arguments)}}(),T=function(){var e=a(function*(e){var t,r=null==e||null===(t=e.graphics)||void 0===t?void 0:t[0];k(r)});return function(t){return e.apply(this,arguments)}}();i.on(o.MAP_STYLE_CHANGE,E);var C=u.on("update",e=>{var t,r=null===(t=e.toolEventInfo)||void 0===t?void 0:t.type,o=e.graphics[0];"move-start"===r&&(u.cancel(),S()),"reshape"===r&&(n.isSimple(o.geometry)||u.undo()),"reshape-stop"!==r&&"vertex-remove"!==r||k(o)}),F=c.on("click",P),L=u.on("create",j),M=u.on("undo",T),D=f.onClick,_=h.onClick;return f.onClick=()=>{u.cancel(),u.layer=v,g({type:"SET_MODE",payload:null}),g({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),i.emit("draw:done",{newFeature:t.tempFeature})},h.onClick=()=>{if(u.cancel(),m.removeAll(),O){var e=d(O.id||O.properties.id,O.geometry.coordinates,p);m.add(e)}u.layer=v,g({type:"SET_MODE",payload:null}),i.emit("draw:cancelled")},()=>{i.off(o.MAP_STYLE_CHANGE,E),C.remove(),F.remove(),L.remove(),M.remove(),f.onClick=D,h.onClick=_}}({pluginState:f,mapProvider:g,events:O,eventBus:w,buttonConfig:b,mapColorScheme:S});return()=>{e()}}},[P,S,f])},buttons:[v({id:"drawDone",label:"Done",variant:"primary",hiddenWhen:e=>{var{pluginState:t}=e;return!t.mode},enableWhen:e=>{var{pluginState:t}=e;return!!t.tempFeature}},f),v({id:"drawCancel",label:"Cancel",variant:"tertiary",hiddenWhen:e=>{var{pluginState:t}=e;return!t.mode}},f)],api:{newPolygon:(e,t)=>{var{mapState:r,pluginState:o,mapProvider:a,services:n}=e,{dispatch:i}=o,{sketchViewModel:l,sketchLayer:p}=a,{eventBus:c}=n;l.layer=p;var u=l.on("create",e=>{if("complete"===e.state){e.graphic.attributes={id:t},requestAnimationFrame(()=>{l.update(e.graphic,{tool:"reshape",toggleToolOnClick:!1})});var r=y(e.graphic);c.emit("draw:created",r),i({type:"SET_FEATURE",payload:{tempFeature:r}}),u.remove()}});l.polygonSymbol=s(r.mapStyle.mapColorScheme),l.create("polygon"),i({type:"SET_MODE",payload:"new-polygon"})},editFeature:(e,t)=>{var{pluginState:r,mapProvider:o}=e,{dispatch:a}=r,{sketchViewModel:n,sketchLayer:i}=o,l=i.graphics.items.find(e=>e.attributes.id===t),p=l.geometry.extent,c=[p.xmin,p.ymin,p.xmax,p.ymax];o.fitToBounds(c),n.layer=i,n.update(l,{tool:"reshape",toggleToolOnClick:!1,enableRotation:!1,enableScaling:!1}),a({type:"SET_FEATURE",payload:{feature:y(l)}}),a({type:"SET_MODE",payload:"edit-feature"})},addFeature:(e,t)=>{var{pluginState:r,mapState:o,mapProvider:a,services:n}=e,{dispatch:i}=r,{mapStyle:l}=o,{sketchViewModel:p,sketchLayer:c,emptySketchLayer:u}=a,{eventBus:s}=n,y=d(t.id,t.geometry.coordinates,l.mapColorScheme);c.add(y),p.layer=u,i({type:"SET_FEATURE",payload:{feature:t}}),s.emit("draw:add",t)},deleteFeature:(e,t)=>{var{pluginState:r,mapProvider:o,services:a}=e,{dispatch:n}=r,{sketchViewModel:i,sketchLayer:l,emptySketchLayer:p}=o,{eventBus:c}=a,u=l.graphics.items.find(e=>e.attributes.id===t);i.cancel(),l.remove(u),i.layer=p,n({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),c.emit("draw:delete",{featureId:t}),n({type:"SET_MODE",payload:null})}}};export{h as manifest};
|