@defra/interactive-map 0.0.47-alpha → 0.0.48-fmp-1
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/package.json +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/src/registry/datasetRegistry.js +6 -6
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/src/adapters/openlayers/snap/snapEngine.js +8 -1
- package/plugins/draw/src/adapters/openlayers/snap/snapEngine.test.js +17 -0
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/map-key/src/api/addKeyItem.js +3 -0
- package/plugins/map-key/src/api/addKeyItem.test.js +14 -0
- package/plugins/map-key/src/api/index.js +7 -0
- package/plugins/map-key/src/api/index.test.js +13 -0
- package/plugins/map-key/src/api/removeKeyItem.js +3 -0
- package/plugins/map-key/src/api/removeKeyItem.test.js +14 -0
- package/plugins/map-key/src/components/Key/MapKey.jsx +11 -3
- package/plugins/map-key/src/initialise/MapKeyInit.jsx +17 -3
- package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +43 -7
- package/plugins/map-key/src/manifest.js +5 -1
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +68 -0
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +91 -0
- package/plugins/map-key/src/reducers/pluginState.js +68 -0
- package/plugins/map-key/src/reducers/pluginState.test.js +82 -0
- package/plugins/map-key/src/utils/mergeKeyGroupItems.js +0 -12
- package/plugins/map-key/src/utils/mergeKeyGroupItems.test.js +0 -53
|
@@ -25,7 +25,14 @@ const buildTileBoundaryState = (layer, map) => {
|
|
|
25
25
|
const getClipContext = (state, coord) => {
|
|
26
26
|
if (!state) { return null }
|
|
27
27
|
const { tileGrid, viewProj, sourceProj, zoom } = state
|
|
28
|
-
|
|
28
|
+
// Same-code projections need no reprojection — skipping the call also avoids depending
|
|
29
|
+
// on ol/proj's registry having a transform for the pair, which can be missing when the
|
|
30
|
+
// draw plugin and the map provider ship as separate bundles each with their own ol/proj4.
|
|
31
|
+
const codeOf = (projection) => (typeof projection === 'string' ? projection : projection.getCode())
|
|
32
|
+
const toSource = (coordinate) => {
|
|
33
|
+
if (!coordinate) { return null }
|
|
34
|
+
return codeOf(sourceProj) === codeOf(viewProj) ? coordinate : projTransform(coordinate, viewProj, sourceProj)
|
|
35
|
+
}
|
|
29
36
|
const anchor = toSource(coord)
|
|
30
37
|
const tileCoord = tileGrid.getTileCoordForCoordAndZ(anchor, zoom)
|
|
31
38
|
const extent = tileGrid.getTileCoordExtent(tileCoord)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import VectorLayer from 'ol/layer/Vector.js'
|
|
2
2
|
import VectorTileLayer from 'ol/layer/VectorTile.js'
|
|
3
3
|
import VectorSource from 'ol/source/Vector.js'
|
|
4
|
+
import { Projection, addProjection, addCoordinateTransforms } from 'ol/proj.js'
|
|
4
5
|
import { createSnapEngine } from './snapEngine.js'
|
|
5
6
|
import { polygonFeature } from '../__helpers__/harness.js'
|
|
6
7
|
|
|
@@ -177,6 +178,22 @@ describe('vector-tile layers', () => {
|
|
|
177
178
|
map.layers.unshift(new VectorLayer({})) // a non-tile layer sits in the stack
|
|
178
179
|
expect(engine.query([600, 2005], 12)).toEqual({ type: 'edge', coord: [600, 2000] })
|
|
179
180
|
})
|
|
181
|
+
|
|
182
|
+
test('reprojects the query coordinate when the tile source has a genuinely different projection', () => {
|
|
183
|
+
// Real ol/proj Projection objects (not the bare code strings the other tests use), with
|
|
184
|
+
// different codes and an identity transform between them, so toSource actually calls
|
|
185
|
+
// transform() instead of short-circuiting, while leaving the mocked tileGrid's numbers valid.
|
|
186
|
+
const viewProj = new Projection({ code: 'x-test-view', units: 'm' })
|
|
187
|
+
const sourceProj = new Projection({ code: 'x-test-source', units: 'm' })
|
|
188
|
+
addProjection(viewProj)
|
|
189
|
+
addProjection(sourceProj)
|
|
190
|
+
addCoordinateTransforms(viewProj, sourceProj, (c) => c, (c) => c)
|
|
191
|
+
|
|
192
|
+
const { engine, map } = setupVT({ features: [renderFeature('LineString', [500, 2000, 1500, 2000])] })
|
|
193
|
+
map.getView = () => ({ getResolution: () => 1, getProjection: () => viewProj })
|
|
194
|
+
map.layers[0].getSource().getProjection = () => sourceProj
|
|
195
|
+
expect(engine.query([600, 2005], 12)).toEqual({ type: 'edge', coord: [600, 2000] })
|
|
196
|
+
})
|
|
180
197
|
})
|
|
181
198
|
|
|
182
199
|
describe('invisible shared fill boundaries', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as e,useEffect as t}from"preact/compat";import{jsx as r,jsxs as o}from"preact/jsx-runtime";import n from"@babel/runtime/helpers/defineProperty";import l from"@babel/runtime/helpers/asyncToGenerator";var a=null,i=e=>a=e,c={"cross-hatch":'<path d="M0 4.486V3.485h3.5V.001h1v3.484h7.002V.001h1v3.484h3.5v1.001h-3.5v7h3.5v.999h-3.5v3.516h-1v-3.516H4.499v3.516h-1v-3.516H0v-.999h3.5v-7H0zm11.501 0H4.499v7h7.002v-7z" fill="{{foregroundColor}}"/>',"diagonal-cross-hatch":'<path d="M0 8.707V7.293L7.293 0h1.414L16 7.293v1.414L8.707 16H7.293L0 8.707zM.707 8L8 15.293 15.293 8 8 .707.707 8z" fill="{{foregroundColor}}"/>',"forward-diagonal-hatch":'<path d="M16 8.707V7.293L7.293 16h1.414L16 8.707zm-16 0L8.707 0H7.293L0 7.293v1.414z" fill="{{foregroundColor}}"/>',"backward-diagonal-hatch":'<path d="M0 8.707V7.293L8.707 16H7.293L0 8.707zm16 0L7.293 0h1.414L16 7.293v1.414z" fill="{{foregroundColor}}"/>',"horizontal-hatch":'<path d="M0 4.5V3.499h15.999V4.5H0zm0 7h15.999V12.5H0v-1.001z" fill="{{foregroundColor}}"/>',"vertical-hatch":'<path d="M3.501 16.001V0h1v16.001h-1zm7.998 0V0h1v16.001h-1z" fill="{{foregroundColor}}"/>',dot:'<path d="M3.999 2A2 2 0 0 1 6 3.999C6 5.103 5.103 6 3.999 6a2 2 0 0 1-1.999-2.001A2 2 0 0 1 3.999 2zm0 7.999C5.103 10 6 10.897 6 12.001A2 2 0 0 1 3.999 14a2 2 0 0 1-1.999-1.999A2 2 0 0 1 3.999 10zM11.999 2A2 2 0 0 1 14 3.999C14 5.103 13.103 6 11.999 6S10 5.103 10 3.999A2 2 0 0 1 11.999 2zm0 7.999c1.104 0 2.001.897 2.001 2.001A2 2 0 0 1 11.999 14 2 2 0 0 1 10 12.001c0-1.104.897-2.001 1.999-2.001z" fill="{{foregroundColor}}"/>',diamond:'<path d="M4 .465L7.535 4 4 7.535.465 4 4 .465zm0 7.999l3.535 3.535L4 15.535.465 11.999 4 8.464zm8-8l3.535 3.535-3.536 3.536L8.464 4 12 .464zm0 8.001L15.536 12 12 15.536 8.465 12 12 8.465z" fill="{{foregroundColor}}"/>'},s=(e,t)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null},p=(e,t,r)=>e.replace(/\{\{foregroundColor\}\}/g,t||"black").replace(/\{\{backgroundColor\}\}/g,r),u=new Map,f={register(e,t){u.set(e,{id:e,svgContent:t})},get:e=>u.get(e),list:()=>[...u.values()],clear(){u.clear()},initialise(){Object.entries(c).forEach(e=>{var[t,r]=e;this.register(t,r)})},getPatternInnerContent(e){return e.fillPatternSvgContent?e.fillPatternSvgContent:e.fillPattern&&null!==(t=null===(r=this.get(e.fillPattern))||void 0===r?void 0:r.svgContent)&&void 0!==t?t:null;var t,r},getKeyPatternPaths(e,t){var r=this.getPatternInnerContent(e);if(!r)return null;var o=s(e.fillPatternForegroundColor,t)||"black",n=s(e.fillPatternBackgroundColor,t)||"transparent",l=s(e.stroke,t)||o;return{border:p('<path d="M19 2.862v14.275c0 1.028-.835 1.862-1.862 1.862H2.863c-1.028 0-1.862-.835-1.862-1.862V2.862C1.001 1.834 1.836 1 2.863 1h14.275C18.166 1 19 1.835 19 2.862z" fill="{{backgroundColor}}" stroke="{{foregroundColor}}" stroke-width="2"/>',l,n),content:p(r,o,n)}},getPatternImageId(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=this.getPatternInnerContent(e);if(!o)return null;var n=s(e.fillPatternForegroundColor,t)||"black",l=s(e.fillPatternBackgroundColor,t)||"transparent",a=(e=>Math.max(2,2*e))(r);return"pattern-".concat((e=>{var t=0;for(var r of e)t=Math.trunc((t<<5)-t+r.codePointAt(0));return Math.abs(t).toString(36)})(o+n+l),"-").concat(a,"x")}};f.initialise();var d={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},h={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},y={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:h.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},m={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:h.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},g={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:h.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},v=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),b=e=>{if(!(e=>!(!e.symbol&&!e.symbolSvgContent))(e))return{};var t={};return v.forEach(r=>{if(null!=e[r]){var o=r.charAt(6).toLowerCase()+r.slice(7);t[o]=e[r]}}),t},O=(e,t)=>{var r;return e.symbolViewBox?e.symbolViewBox:null!==(r=null==t?void 0:t.viewBox)&&void 0!==r?r:"0 0 38 38"},k={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}};function j(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 w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var C=new Map,S=new Map,P={},D=e=>{var t=0;for(var r of e)t=Math.trunc((t<<5)-t+r.codePointAt(0));return Math.abs(t).toString(36)},M=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function x(e,t,r){var o,n,l,a,i=null==r?void 0:r.id,c=Object.fromEntries(Object.entries(e||{}).filter(e=>{var[t]=e;return!M.has(t)})),p=Object.fromEntries(Object.entries(P).filter(e=>{var[t]=e;return!M.has(t)})),u=Object.fromEntries(Object.entries(t).filter(e=>{var[,t]=e;return null!=t})),f=w(w(w(w({},d),p),c),u),y=null!==(o=k[null==r?void 0:r.mapColorScheme])&&void 0!==o?o:k.light;return f.haloColor=null!==(n=null==r?void 0:r.haloColor)&&void 0!==n?n:y.haloColor,f.selectedColor=null!==(l=null==r?void 0:r.selectedColor)&&void 0!==l?l:y.selectedColor,f.activeColor=null!==(a=null==r?void 0:r.activeColor)&&void 0!==a?a:y.activeColor,"string"==typeof f.graphic&&h[f.graphic]&&(f.graphic=h[f.graphic]),Object.fromEntries(Object.entries(f).map(e=>{var[t,r]=e;return[t,s(r,i)||""]}))}function L(e,t){return Object.entries(t).reduce((e,t)=>{var[r,o]=t;return e.replaceAll("{{".concat(r,"}}"),o)},e)}var z={setDefaults(e){P=e||{}},getDefaults:()=>w(w({},d),P),register(e){C.set(e.id,e)},get:e=>C.get(e),list:()=>[...C.values()],clear(){C.clear()},initialise(){this.register(y),this.register(m),this.register(g)},resolve(e,t,r){var o=x(e,t||{},r);return e?(o.selectedColor="none",o.activeColor="none",L(e.svg,o)):""},resolveActive(e,t,r){var o=x(e,t||{},r);return e?L(e.svg,o):""},resolveSelected(e,t,r){var o=x(e,t||{},r);return e?(o.activeColor="none",L(e.svg,o)):""},getSymbolImageId(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,n=this.getSymbolDef(e);if(!n)return null;var l=b(e),a=r?this.resolveActive(n,l,t):this.resolve(n,l,t);return"symbol-".concat(r?"act-":"").concat(D(a),"-").concat(o,"x")},getSymbolDef(e){return e.symbolSvgContent?{svg:e.symbolSvgContent}:e.symbol?this.get(e.symbol):void 0},rasteriseSymbolImage(e,t,r,o){var n=this;return l(function*(){var l=n.getSymbolDef(e);if(!l)return null;var a,i,c=b(e);"active"===r?(a=n.resolveActive(l,c,t),i="act-"):"selected"===r?(a=n.resolveSelected(l,c,t),i="sel-"):(a=n.resolve(l,c,t),i="");var s="symbol-".concat(i).concat(D(a),"-").concat(o,"x"),p=S.get(s);if(!p){var u=O(e,l),[,,f,d]=u.split(" ").map(Number),h='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(f*o,'" height="').concat(d*o,'" viewBox="').concat(u,'">').concat(a,"</svg>");p=yield((e,t,r)=>new Promise((o,n)=>{var l="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(e)),a=new Image(t,r);a.onload=()=>{var e=document.createElement("canvas");e.width=t,e.height=r;var n=e.getContext("2d");n.drawImage(a,0,0,t,r),o(n.getImageData(0,0,t,r))},a.onerror=()=>{n(new Error("Failed to rasterise SVG: ".concat(e.slice(0,80))))},a.src=l}))(h,f*o,d*o),S.set(s,p)}return{imageId:s,imageData:p}})()}};function I(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 H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}z.initialise();var V=e=>{var{text:t}=e;return r("div",{className:"im-c-map-key",children:r("p",{className:"im-c-map-key__empty-message",children:t})})};function E(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 _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var B=20,A={xmlns:"http://www.w3.org/2000/svg",width:B,height:B,viewBox:"0 0 ".concat(B," ").concat(B),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},N=_(_({},A),{},{width:44,height:44,className:"im-c-map-key-symbol im-c-map-key-symbol--point"});function K(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 G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var T=e=>{var{keyDefinition:t,mapStyle:n}=e,{style:l}=t,a=f.getKeyPatternPaths(l,n.id);return a?o("svg",G(G({},A),{},{children:[r("g",{dangerouslySetInnerHTML:{__html:a.border}}),r("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:a.content}})]})):null};function W(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 q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?W(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):W(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var F=e=>{var t,{keyDefinition:o,mapStyle:n,symbolDef:l}=e,{style:a}=o,i=null!==(t=null==n?void 0:n.appColorScheme)&&void 0!==t?t:"light",c=q(q({},n),{},{mapColorScheme:i}),s=z.resolve(l,b(a),c),p=O(a,l);return s&&p?r("svg",q(q({},N),{},{viewBox:p,children:r("g",{dangerouslySetInnerHTML:{__html:s}})})):null};function R(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 Z(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var U=e=>{var{mapStyle:t,keyDefinition:o}=e,{style:n}=o,l=n.strokeWidth,a=s(n.stroke,t.id);return r("svg",Z(Z({},A),{},{children:r("line",{x1:l/2,y1:10,x2:B-l/2,y2:10,stroke:a,strokeWidth:l,strokeLinecap:"round"})}))};function J(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 Q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?J(Object(r),!0).forEach(function(t){n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):J(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var X=e=>{var{mapStyle:t,keyDefinition:o}=e,{style:n}=o,l=n.strokeWidth,a=s(n.fill,t.id),i=s(n.stroke,t.id);return r("svg",Q(Q({},A),{},{children:r("rect",{x:l/2,y:l/2,width:B-l,height:B-l,rx:l,ry:l,fill:a,stroke:i,strokeWidth:l,strokeLinejoin:"round"})}))},Y=e=>{var{mapStyle:t,keyDefinition:o}=e,{style:n}=o,l=s(n.fill,t.id),a=s(n.fill,t.id);return r("svg",{viewBox:"0 0 5 5",preserveAspectRatio:"none",fill:l,stroke:a,strokeWidth:"1",children:r("path",{d:"M0 0h5v5H0z"})})},$="horizontal-ramp",ee=e=>{var{keyDefinition:t,groupStyle:o,mapStyle:n}=e,{symbolShape:l,symbolDef:a}=((e,t)=>{if(!e)return{symbolShape:null,symbolDef:null};var{hasSymbol:r,hasPattern:o,style:n}=e;if(t===$)return{symbolShape:$,symbolDef:null};if(r){var l=z.getSymbolDef(n);return{symbolShape:l?"symbol":"rect",symbolDef:l}}return o?{symbolShape:"pattern",symbolDef:null}:"line"===n.keySymbolShape?{symbolShape:"line",symbolDef:null}:{symbolShape:"rect",symbolDef:null}})(t,o);return l?"symbol"===l?r(F,{mapStyle:n,keyDefinition:t,symbolDef:a}):r("pattern"===l?T:"line"===l?U:l===$?Y:X,{mapStyle:n,keyDefinition:t}):null},te=e=>{var{keyDefinition:t,groupStyle:n,mapStyle:l}=e,a=t.label,i=s(t.symbolDescription,l.id);return o("div",{className:"im-c-map-key-list__item",children:[r("dt",{className:"im-c-map-key-list__item-symbol",children:r(ee,{keyDefinition:t,groupStyle:n,mapStyle:l})}),o("dd",{className:"im-c-map-key-list__item-label",children:[a,i&&o("span",{className:"govuk-visually-hidden",children:["(",i,")"]})]})]})},re=e=>{var{headingId:t,label:n,groupStyle:l,keyDefinitions:a,mapStyle:i}=e,c="im-c-map-key-list"+(l?" im-c-map-key-list-".concat(l):"");return o("section",{className:"im-c-map-key__group","aria-labelledby":t,children:[r("h3",{id:t,className:"im-c-map-key__group-heading",children:n}),r("dl",{className:c,children:a.map(e=>r(te,{keyDefinition:e,mapStyle:i,groupStyle:l},"".concat(e.id)))})]})},oe="im-c-map-key",ne=e=>{var{item:t,groupStyle:o,mapStyle:n}=e;return"group"===t.type?r(re,{headingId:"key-heading-".concat(t.id),label:t.groupLabel,groupStyle:o,keyDefinitions:t.keyDefinitions,mapStyle:n}):r(te,{keyDefinition:t.keyDefinition,mapStyle:n})},le=e=>{var{noKeyItemText:t,keyGroups:o,hasGroups:n,mapStyle:l}=e;if(null==o||!o.length)return r(V,{text:t});var a=n?"".concat(oe," ").concat("im-c-map-key--has-groups"):oe;return r("div",{className:a,children:o.map(e=>r(ne,{item:e,mapStyle:l,groupStyle:e.groupStyle},e.id))})};var ae={InitComponent:function(e){var{mapState:r,services:o}=e,{eventBus:n}=o;t(()=>{r.isMapReady&&n.requestOnce("datasets:registry",i)},[r.isMapReady])},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(o){var{mapState:{mapStyle:n},pluginConfig:{noKeyItemText:l,groups:i},services:{eventBus:c}}=o,[s,p]=e(a),[u,f]=e(()=>{var e;return null!==(e=null==s?void 0:s.keyItems().items)&&void 0!==e?e:[]}),[d,h]=e(()=>{var e;return null!==(e=null==s?void 0:s.keyItems().hasGroups)&&void 0!==e&&e}),y=()=>{var{items:e,hasGroups:t}=s.keyItems(),r=((e,t)=>e?t.map(t=>{var{id:r}=t;return e[r]?H(H({},t),e[r]):t}):t)(i,e);f(r),h(t)},m=e=>{s.invalidateKeyItemsOnMenuStateChange(e),y()};return t(()=>s?(y(),c.on("menu:changed",m).on("datasets:changed",y),()=>c.off("menu:changed",m).off("datasets:changed",y)):(c.requestOnce("datasets:registry",p),()=>{}),[s]),r(le,{noKeyItemText:l,keyGroups:u,hasGroups:d,mapStyle:n})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{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"/>'}]};export{ae as manifest};
|
|
1
|
+
import{useState as e,useEffect as t,useRef as r}from"preact/compat";import{jsx as o,jsxs as n}from"preact/jsx-runtime";import i from"@babel/runtime/helpers/defineProperty";import l from"@babel/runtime/helpers/asyncToGenerator";var a=null,c=e=>a=e,s={"cross-hatch":'<path d="M0 4.486V3.485h3.5V.001h1v3.484h7.002V.001h1v3.484h3.5v1.001h-3.5v7h3.5v.999h-3.5v3.516h-1v-3.516H4.499v3.516h-1v-3.516H0v-.999h3.5v-7H0zm11.501 0H4.499v7h7.002v-7z" fill="{{foregroundColor}}"/>',"diagonal-cross-hatch":'<path d="M0 8.707V7.293L7.293 0h1.414L16 7.293v1.414L8.707 16H7.293L0 8.707zM.707 8L8 15.293 15.293 8 8 .707.707 8z" fill="{{foregroundColor}}"/>',"forward-diagonal-hatch":'<path d="M16 8.707V7.293L7.293 16h1.414L16 8.707zm-16 0L8.707 0H7.293L0 7.293v1.414z" fill="{{foregroundColor}}"/>',"backward-diagonal-hatch":'<path d="M0 8.707V7.293L8.707 16H7.293L0 8.707zm16 0L7.293 0h1.414L16 7.293v1.414z" fill="{{foregroundColor}}"/>',"horizontal-hatch":'<path d="M0 4.5V3.499h15.999V4.5H0zm0 7h15.999V12.5H0v-1.001z" fill="{{foregroundColor}}"/>',"vertical-hatch":'<path d="M3.501 16.001V0h1v16.001h-1zm7.998 0V0h1v16.001h-1z" fill="{{foregroundColor}}"/>',dot:'<path d="M3.999 2A2 2 0 0 1 6 3.999C6 5.103 5.103 6 3.999 6a2 2 0 0 1-1.999-2.001A2 2 0 0 1 3.999 2zm0 7.999C5.103 10 6 10.897 6 12.001A2 2 0 0 1 3.999 14a2 2 0 0 1-1.999-1.999A2 2 0 0 1 3.999 10zM11.999 2A2 2 0 0 1 14 3.999C14 5.103 13.103 6 11.999 6S10 5.103 10 3.999A2 2 0 0 1 11.999 2zm0 7.999c1.104 0 2.001.897 2.001 2.001A2 2 0 0 1 11.999 14 2 2 0 0 1 10 12.001c0-1.104.897-2.001 1.999-2.001z" fill="{{foregroundColor}}"/>',diamond:'<path d="M4 .465L7.535 4 4 7.535.465 4 4 .465zm0 7.999l3.535 3.535L4 15.535.465 11.999 4 8.464zm8-8l3.535 3.535-3.536 3.536L8.464 4 12 .464zm0 8.001L15.536 12 12 15.536 8.465 12 12 8.465z" fill="{{foregroundColor}}"/>'},p=(e,t)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null},u=(e,t,r)=>e.replace(/\{\{foregroundColor\}\}/g,t||"black").replace(/\{\{backgroundColor\}\}/g,r),f=new Map,y={register(e,t){f.set(e,{id:e,svgContent:t})},get:e=>f.get(e),list:()=>[...f.values()],clear(){f.clear()},initialise(){Object.entries(s).forEach(e=>{var[t,r]=e;this.register(t,r)})},getPatternInnerContent(e){return e.fillPatternSvgContent?e.fillPatternSvgContent:e.fillPattern&&null!==(t=null===(r=this.get(e.fillPattern))||void 0===r?void 0:r.svgContent)&&void 0!==t?t:null;var t,r},getKeyPatternPaths(e,t){var r=this.getPatternInnerContent(e);if(!r)return null;var o=p(e.fillPatternForegroundColor,t)||"black",n=p(e.fillPatternBackgroundColor,t)||"transparent",i=p(e.stroke,t)||o;return{border:u('<path d="M19 2.862v14.275c0 1.028-.835 1.862-1.862 1.862H2.863c-1.028 0-1.862-.835-1.862-1.862V2.862C1.001 1.834 1.836 1 2.863 1h14.275C18.166 1 19 1.835 19 2.862z" fill="{{backgroundColor}}" stroke="{{foregroundColor}}" stroke-width="2"/>',i,n),content:u(r,o,n)}},getPatternImageId(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=this.getPatternInnerContent(e);if(!o)return null;var n=p(e.fillPatternForegroundColor,t)||"black",i=p(e.fillPatternBackgroundColor,t)||"transparent",l=(e=>Math.max(2,2*e))(r);return"pattern-".concat((e=>{var t=0;for(var r of e)t=Math.trunc((t<<5)-t+r.codePointAt(0));return Math.abs(t).toString(36)})(o+n+i),"-").concat(l,"x")}};y.initialise();var d={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},g={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},h={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:g.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},v={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:g.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},m={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:g.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},b=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),O=e=>{if(!(e=>!(!e.symbol&&!e.symbolSvgContent))(e))return{};var t={};return b.forEach(r=>{if(null!=e[r]){var o=r.charAt(6).toLowerCase()+r.slice(7);t[o]=e[r]}}),t},j=(e,t)=>{var r;return e.symbolViewBox?e.symbolViewBox:null!==(r=null==t?void 0:t.viewBox)&&void 0!==r?r:"0 0 38 38"},k={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}};function w(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(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var S=new Map,D=new Map,C={},M=e=>{var t=0;for(var r of e)t=Math.trunc((t<<5)-t+r.codePointAt(0));return Math.abs(t).toString(36)},E=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function I(e,t,r){var o,n,i,l,a=null==r?void 0:r.id,c=Object.fromEntries(Object.entries(e||{}).filter(e=>{var[t]=e;return!E.has(t)})),s=Object.fromEntries(Object.entries(C).filter(e=>{var[t]=e;return!E.has(t)})),u=Object.fromEntries(Object.entries(t).filter(e=>{var[,t]=e;return null!=t})),f=P(P(P(P({},d),s),c),u),y=null!==(o=k[null==r?void 0:r.mapColorScheme])&&void 0!==o?o:k.light;return f.haloColor=null!==(n=null==r?void 0:r.haloColor)&&void 0!==n?n:y.haloColor,f.selectedColor=null!==(i=null==r?void 0:r.selectedColor)&&void 0!==i?i:y.selectedColor,f.activeColor=null!==(l=null==r?void 0:r.activeColor)&&void 0!==l?l:y.activeColor,"string"==typeof f.graphic&&g[f.graphic]&&(f.graphic=g[f.graphic]),Object.fromEntries(Object.entries(f).map(e=>{var[t,r]=e;return[t,p(r,a)||""]}))}function x(e,t){return Object.entries(t).reduce((e,t)=>{var[r,o]=t;return e.replaceAll("{{".concat(r,"}}"),o)},e)}var L={setDefaults(e){C=e||{}},getDefaults:()=>P(P({},d),C),register(e){S.set(e.id,e)},get:e=>S.get(e),list:()=>[...S.values()],clear(){S.clear()},initialise(){this.register(h),this.register(v),this.register(m)},resolve(e,t,r){var o=I(e,t||{},r);return e?(o.selectedColor="none",o.activeColor="none",x(e.svg,o)):""},resolveActive(e,t,r){var o=I(e,t||{},r);return e?x(e.svg,o):""},resolveSelected(e,t,r){var o=I(e,t||{},r);return e?(o.activeColor="none",x(e.svg,o)):""},getSymbolImageId(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,n=this.getSymbolDef(e);if(!n)return null;var i=O(e),l=r?this.resolveActive(n,i,t):this.resolve(n,i,t);return"symbol-".concat(r?"act-":"").concat(M(l),"-").concat(o,"x")},getSymbolDef(e){return e.symbolSvgContent?{svg:e.symbolSvgContent}:e.symbol?this.get(e.symbol):void 0},rasteriseSymbolImage(e,t,r,o){var n=this;return l(function*(){var i=n.getSymbolDef(e);if(!i)return null;var l,a,c=O(e);"active"===r?(l=n.resolveActive(i,c,t),a="act-"):"selected"===r?(l=n.resolveSelected(i,c,t),a="sel-"):(l=n.resolve(i,c,t),a="");var s="symbol-".concat(a).concat(M(l),"-").concat(o,"x"),p=D.get(s);if(!p){var u=j(e,i),[,,f,y]=u.split(" ").map(Number),d='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(f*o,'" height="').concat(y*o,'" viewBox="').concat(u,'">').concat(l,"</svg>");p=yield((e,t,r)=>new Promise((o,n)=>{var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(e)),l=new Image(t,r);l.onload=()=>{var e=document.createElement("canvas");e.width=t,e.height=r;var n=e.getContext("2d");n.drawImage(l,0,0,t,r),o(n.getImageData(0,0,t,r))},l.onerror=()=>{n(new Error("Failed to rasterise SVG: ".concat(e.slice(0,80))))},l.src=i}))(d,f*o,y*o),D.set(s,p)}return{imageId:s,imageData:p}})()}};function _(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 z(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}L.initialise();var H={},V=null,A=[],K=()=>{var e;if(null===(e=H)||void 0===e||!e.current)return[];if(V===H.current)return A;V=H.current;var{groups:t=[],keyDefinitions:r=[]}=H.current;return A=t.map(e=>"flat"===e.type?z(z({},e),{},{keyDefinition:r.find(t=>t.id===e.id)}):z(z({},e),{},{keyDefinitions:r.filter(t=>t.groupId===e.id)}))},B=e=>{var{text:t}=e;return o("div",{className:"im-c-map-key",children:o("p",{className:"im-c-map-key__empty-message",children:t})})};function N(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 G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var T=20,R={xmlns:"http://www.w3.org/2000/svg",width:T,height:T,viewBox:"0 0 ".concat(T," ").concat(T),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},W=G(G({},R),{},{width:44,height:44,className:"im-c-map-key-symbol im-c-map-key-symbol--point"});function Y(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 q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Y(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var F=e=>{var{keyDefinition:t,mapStyle:r}=e,{style:i}=t,l=y.getKeyPatternPaths(i,r.id);return l?n("svg",q(q({},R),{},{children:[o("g",{dangerouslySetInnerHTML:{__html:l.border}}),o("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:l.content}})]})):null};function Z(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(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Z(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Z(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var J=e=>{var t,{keyDefinition:r,mapStyle:n,symbolDef:i}=e,{style:l}=r,a=null!==(t=null==n?void 0:n.appColorScheme)&&void 0!==t?t:"light",c=U(U({},n),{},{mapColorScheme:a}),s=L.resolve(i,O(l),c),p=j(l,i);return s&&p?o("svg",U(U({},W),{},{viewBox:p,children:o("g",{dangerouslySetInnerHTML:{__html:s}})})):null};function Q(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 X(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var $=e=>{var{mapStyle:t,keyDefinition:r}=e,{style:n}=r,i=n.strokeWidth,l=p(n.stroke,t.id);return o("svg",X(X({},R),{},{children:o("line",{x1:i/2,y1:10,x2:T-i/2,y2:10,stroke:l,strokeWidth:i,strokeLinecap:"round"})}))};function ee(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 te(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ee(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var re=e=>{var{mapStyle:t,keyDefinition:r}=e,{style:n}=r,i=n.strokeWidth,l=p(n.fill,t.id),a=p(n.stroke,t.id);return o("svg",te(te({},R),{},{children:o("rect",{x:i/2,y:i/2,width:T-i,height:T-i,rx:i,ry:i,fill:l,stroke:a,strokeWidth:i,strokeLinejoin:"round"})}))},oe=e=>{var{mapStyle:t,keyDefinition:r}=e,{style:n}=r,i=p(n.fill,t.id),l=p(n.fill,t.id);return o("svg",{viewBox:"0 0 5 5",preserveAspectRatio:"none",fill:i,stroke:l,strokeWidth:"1",children:o("path",{d:"M0 0h5v5H0z"})})},ne="horizontal-ramp",ie=e=>{var{keyDefinition:t,groupStyle:r,mapStyle:n}=e,{symbolShape:i,symbolDef:l}=((e,t)=>{if(!e)return{symbolShape:null,symbolDef:null};var{hasSymbol:r,hasPattern:o,style:n}=e;if(t===ne)return{symbolShape:ne,symbolDef:null};if(r){var i=L.getSymbolDef(n);return{symbolShape:i?"symbol":"rect",symbolDef:i}}return o?{symbolShape:"pattern",symbolDef:null}:"line"===n.keySymbolShape?{symbolShape:"line",symbolDef:null}:{symbolShape:"rect",symbolDef:null}})(t,r);return i?"symbol"===i?o(J,{mapStyle:n,keyDefinition:t,symbolDef:l}):o("pattern"===i?F:"line"===i?$:i===ne?oe:re,{mapStyle:n,keyDefinition:t}):null},le=e=>{var{keyDefinition:t,groupStyle:r,mapStyle:i}=e,l=t.label,a=p(t.symbolDescription,i.id);return n("div",{className:"im-c-map-key-list__item",children:[o("dt",{className:"im-c-map-key-list__item-symbol",children:o(ie,{keyDefinition:t,groupStyle:r,mapStyle:i})}),n("dd",{className:"im-c-map-key-list__item-label",children:[l,a&&n("span",{className:"govuk-visually-hidden",children:["(",a,")"]})]})]})},ae=e=>{var{headingId:t,label:r,groupStyle:i,keyDefinitions:l,mapStyle:a}=e,c="im-c-map-key-list"+(i?" im-c-map-key-list-".concat(i):"");return n("section",{className:"im-c-map-key__group","aria-labelledby":t,children:[o("h3",{id:t,className:"im-c-map-key__group-heading",children:r}),o("dl",{className:c,children:l.map(e=>o(le,{keyDefinition:e,mapStyle:a,groupStyle:i},"".concat(e.id)))})]})},ce="im-c-map-key",se=e=>{var{item:t,groupStyle:r,mapStyle:n}=e;return"group"===t.type?o(ae,{headingId:"key-heading-".concat(t.id),label:t.groupLabel,groupStyle:r,keyDefinitions:t.keyDefinitions,mapStyle:n}):o(le,{keyDefinition:t.keyDefinition,mapStyle:n})},pe=e=>{var{noKeyItemText:t,keyGroups:r,hasGroups:n,mapStyle:i}=e;if(null==r||!r.length)return o(B,{text:t});var l=n?"".concat(ce," ").concat("im-c-map-key--has-groups"):ce;return o("div",{className:l,children:r.map(e=>o(se,{item:e,mapStyle:i,groupStyle:e.groupStyle},e.id))})};function ue(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 fe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ue(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ue(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ye(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 de(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ye(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ye(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ge={InitComponent:function(e){var{pluginConfig:o,pluginState:n,mapState:i,services:l}=e,{dispatch:a}=n,{eventBus:s}=l,p=r(n);p.current=n,t(()=>{i.isMapReady&&((e=>{H=e})(p),s.requestOnce("datasets:registry",c))},[i.isMapReady]),t(()=>{if(o.groups){var e=Object.entries(o.groups).map(e=>{var[t,r]=e;return fe(fe({},r),{},{id:t,label:r.groupLabel})});a({type:"ADD_KEY_GROUPS",payload:e})}},[o.groups])},reducer:{initialState:{keyDefinitions:[],groups:[]},actions:{ADD_KEY_ITEM:(e,t)=>{var r,{id:o,groupLabel:n}=t,i=t.groupId||((r=n)?r.toLowerCase().replace(/\s+/g,"-"):null),l=((e,t,r)=>e.groups.find(e=>"group"===e.type&&e.id===r||"flat"===e.type&&e.id===t))(e,o,i),a=l?null:((e,t,r)=>t?{id:t,type:"group",groupLabel:r}:{id:e,type:"flat"})(o,i,n),c=a?[...e.groups,a]:e.groups,s=[...e.keyDefinitions,de(de({},t),{},{type:"manual"},i?{groupId:i}:{})];return de(de({},e),{},{keyDefinitions:s,groups:c})},REMOVE_KEY_ITEM:(e,t)=>{var{id:r}=t;return de(de({},e),{},{keyDefinitions:e.keyDefinitions.filter(e=>e.id!==r)})},ADD_KEY_GROUPS:(e,t)=>de(de({},e),{},{groups:[...e.groups,...t]})}},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(r){var{mapState:{mapStyle:n},pluginConfig:{noKeyItemText:i},pluginState:l,services:{eventBus:c}}=r,[s,p]=e(a),[u,f]=e(()=>{var e;return null!==(e=null==s?void 0:s.keyItems().items)&&void 0!==e?e:[]}),[y,d]=e(()=>{var e;return null!==(e=null==s?void 0:s.keyItems().hasGroups)&&void 0!==e&&e}),g=()=>{var{items:e,hasGroups:t}=s.keyItems(),r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[...K()];return 0===t.length?e:[...e.map(e=>{var r=t.findIndex(t=>t.id===e.id);if(-1===r)return e;var o=t.splice(r,1)[0];return z(z(z({},e),o),{},{keyDefinitions:[...o.keyDefinitions||[],...e.keyDefinitions||[]]})}),...t].filter(e=>{var t;return"flat"===e.type&&e.keyDefinition||"group"===e.type&&(null===(t=e.keyDefinitions)||void 0===t?void 0:t.length)})}(e);f(r),d(t)},h=e=>{s.invalidateKeyItemsOnMenuStateChange(e),g()};return t(()=>s?(g(),c.on("menu:changed",h).on("datasets:changed",g),()=>c.off("menu:changed",h).off("datasets:changed",g)):(c.requestOnce("datasets:registry",p),()=>{}),[s]),t(()=>{s&&g()},[l]),o(pe,{noKeyItemText:i,keyGroups:u,hasGroups:y,mapStyle:n})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{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:{addKeyItem:(e,t)=>{var{pluginState:{dispatch:r}}=e;r({type:"ADD_KEY_ITEM",payload:t})},removeKeyItem:(e,t)=>{var{pluginState:{dispatch:r}}=e;r({type:"REMOVE_KEY_ITEM",payload:t})}}};export{ge as manifest};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see im-map-key-plugin.js.LICENSE.txt */
|
|
2
|
-
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[414],{249(t,e,r){r.r(e),r.d(e,{manifest:()=>Et});var n=r(738),o=null,i=function(t){return o=t};function l(t){return l="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},l(t)}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 c(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){u(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 u(t,e,r){return(e=function(t){var e=function(t){if("object"!=l(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==l(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var f=r(287),s=function(t){var e=t.text;return(0,f.jsx)("div",{className:"im-c-map-key",children:(0,f.jsx)("p",{className:"im-c-map-key__empty-message",children:e})})};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 m(t){return m="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},m(t)}function b(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?b(Object(r),!0).forEach(function(e){d(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function d(t,e,r){return(e=function(t){var e=function(t){if("object"!=m(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==m(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var h=20,g={xmlns:"http://www.w3.org/2000/svg",width:h,height:h,viewBox:"0 0 ".concat(h," ").concat(h),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},S=v(v({},g),{},{width:44,height:44,className:"im-c-map-key-symbol im-c-map-key-symbol--point"}),j={"cross-hatch":'<path d="M0 4.486V3.485h3.5V.001h1v3.484h7.002V.001h1v3.484h3.5v1.001h-3.5v7h3.5v.999h-3.5v3.516h-1v-3.516H4.499v3.516h-1v-3.516H0v-.999h3.5v-7H0zm11.501 0H4.499v7h7.002v-7z" fill="{{foregroundColor}}"/>',"diagonal-cross-hatch":'<path d="M0 8.707V7.293L7.293 0h1.414L16 7.293v1.414L8.707 16H7.293L0 8.707zM.707 8L8 15.293 15.293 8 8 .707.707 8z" fill="{{foregroundColor}}"/>',"forward-diagonal-hatch":'<path d="M16 8.707V7.293L7.293 16h1.414L16 8.707zm-16 0L8.707 0H7.293L0 7.293v1.414z" fill="{{foregroundColor}}"/>',"backward-diagonal-hatch":'<path d="M0 8.707V7.293L8.707 16H7.293L0 8.707zm16 0L7.293 0h1.414L16 7.293v1.414z" fill="{{foregroundColor}}"/>',"horizontal-hatch":'<path d="M0 4.5V3.499h15.999V4.5H0zm0 7h15.999V12.5H0v-1.001z" fill="{{foregroundColor}}"/>',"vertical-hatch":'<path d="M3.501 16.001V0h1v16.001h-1zm7.998 0V0h1v16.001h-1z" fill="{{foregroundColor}}"/>',dot:'<path d="M3.999 2A2 2 0 0 1 6 3.999C6 5.103 5.103 6 3.999 6a2 2 0 0 1-1.999-2.001A2 2 0 0 1 3.999 2zm0 7.999C5.103 10 6 10.897 6 12.001A2 2 0 0 1 3.999 14a2 2 0 0 1-1.999-1.999A2 2 0 0 1 3.999 10zM11.999 2A2 2 0 0 1 14 3.999C14 5.103 13.103 6 11.999 6S10 5.103 10 3.999A2 2 0 0 1 11.999 2zm0 7.999c1.104 0 2.001.897 2.001 2.001A2 2 0 0 1 11.999 14 2 2 0 0 1 10 12.001c0-1.104.897-2.001 1.999-2.001z" fill="{{foregroundColor}}"/>',diamond:'<path d="M4 .465L7.535 4 4 7.535.465 4 4 .465zm0 7.999l3.535 3.535L4 15.535.465 11.999 4 8.464zm8-8l3.535 3.535-3.536 3.536L8.464 4 12 .464zm0 8.001L15.536 12 12 15.536 8.465 12 12 8.465z" fill="{{foregroundColor}}"/>'};function O(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 w=function(t,e,r){return t.replace(/\{\{foregroundColor\}\}/g,e||"black").replace(/\{\{backgroundColor\}\}/g,r||"transparent")};function k(t,e){if(t){if("string"==typeof t)return P(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)?P(t,e):void 0}}function P(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 C=new Map,x={register:function(t,e){C.set(t,{id:t,svgContent:e})},get:function(t){return C.get(t)},list:function(){return function(t){if(Array.isArray(t))return P(t)}(t=C.values())||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||k(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.")}();var t},clear:function(){C.clear()},initialise:function(){var t=this;Object.entries(j).forEach(function(e){var r,n,o=(n=2,function(t){if(Array.isArray(t))return t}(r=e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,l,a=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){u=!0,o=t}finally{try{if(!c&&null!=r.return&&(l=r.return(),Object(l)!==l))return}finally{if(u)throw o}}return a}}(r,n)||k(r,n)||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.")}()),i=o[0],l=o[1];t.register(i,l)})},getPatternInnerContent:function(t){return t.fillPatternSvgContent?t.fillPatternSvgContent:t.fillPattern&&null!==(e=null===(r=this.get(t.fillPattern))||void 0===r?void 0:r.svgContent)&&void 0!==e?e:null;var e,r},getKeyPatternPaths:function(t,e){var r=this.getPatternInnerContent(t);if(!r)return null;var n=p(t.fillPatternForegroundColor,e)||"black",o=p(t.fillPatternBackgroundColor,e)||"transparent",i=p(t.stroke,e)||n;return{border:w('<path d="M19 2.862v14.275c0 1.028-.835 1.862-1.862 1.862H2.863c-1.028 0-1.862-.835-1.862-1.862V2.862C1.001 1.834 1.836 1 2.863 1h14.275C18.166 1 19 1.835 19 2.862z" fill="{{backgroundColor}}" stroke="{{foregroundColor}}" stroke-width="2"/>',i,o),content:w(r,n,o)}},getPatternImageId:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=this.getPatternInnerContent(t);if(!n)return null;var o=p(t.fillPatternForegroundColor,e)||"black",i=p(t.fillPatternBackgroundColor,e)||"transparent",l=function(t){return Math.max(2,2*t)}(r);return"pattern-".concat(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 O(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)?O(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,l=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return l=t.done,t},e:function(t){a=!0,i=t},f:function(){try{l||null==r.return||r.return()}finally{if(a)throw i}}}}(t);try{for(n.s();!(e=n.n()).done;){var o=e.value;r=Math.trunc((r<<5)-r+o.codePointAt(0))}}catch(t){n.e(t)}finally{n.f()}return Math.abs(r).toString(36)}(n+o+i),"-").concat(l,"x")}};function D(t){return D="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},D(t)}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 M(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){I(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 I(t,e,r){return(e=function(t){var e=function(t){if("object"!=D(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=D(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==D(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}x.initialise();var E=function(t){var e=t.keyDefinition,r=t.mapStyle,n=e.style,o=x.getKeyPatternPaths(n,r.id);return o?(0,f.jsxs)("svg",M(M({},g),{},{children:[(0,f.jsx)("g",{dangerouslySetInnerHTML:{__html:o.border}}),(0,f.jsx)("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:o.content}})]})):null},L=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),z=function(t){if(!function(t){return!(!t.symbol&&!t.symbolSvgContent)}(t))return{};var e={};return L.forEach(function(r){if(null!=t[r]){var n=r.charAt(6).toLowerCase()+r.slice(7);e[n]=t[r]}}),e},H=function(t,e){var r;return t.symbolViewBox?t.symbolViewBox:null!==(r=null==e?void 0:e.viewBox)&&void 0!==r?r:"0 0 38 38"},T={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},_={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},V={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:_.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},B={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:_.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},G={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:_.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},N={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},K=function(t,e,r){return new Promise(function(n,o){var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t)),l=new Image(e,r);l.onload=function(){var t=document.createElement("canvas");t.width=e,t.height=r;var o=t.getContext("2d");o.drawImage(l,0,0,e,r),n(o.getImageData(0,0,e,r))},l.onerror=function(){o(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},l.src=i})};function F(t){return F="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},F(t)}function W(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof a?n:a,u=Object.create(c.prototype);return U(u,"_invoke",function(r,n,o){var i,a,c,u=0,f=o||[],s=!1,y={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,r){return i=e,a=0,c=t,y.n=r,l}};function p(r,n){for(a=r,c=n,e=0;!s&&u&&!o&&e<f.length;e++){var o,i=f[e],p=y.p,m=i[2];r>3?(o=m===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=p&&((o=r<2&&p<i[1])?(a=0,y.v=n,y.n=i[1]):p<m&&(o=r<3||i[0]>n||n>m)&&(i[4]=r,i[5]=n,y.n=m,a=0))}if(o||r>1)return l;throw s=!0,n}return function(o,f,m){if(u>1)throw TypeError("Generator is already running");for(s&&1===f&&p(f,m),a=f,c=m;(e=a<2?t:c)||!s;){i||(a?a<3?(a>1&&(y.n=-1),p(a,c)):y.n=c:y.v=c);try{if(u=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(s=y.n<0)?c:r.call(n,y))!==l)break}catch(e){i=t,a=1,c=e}finally{u=1}}return{value:e,done:s}}}(r,o,i),!0),u}var l={};function a(){}function c(){}function u(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(U(e={},n,function(){return this}),e),s=u.prototype=a.prototype=Object.create(f);function y(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,U(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=u,U(s,"constructor",u),U(u,"constructor",c),c.displayName="GeneratorFunction",U(u,o,"GeneratorFunction"),U(s),U(s,o,"Generator"),U(s,n,function(){return this}),U(s,"toString",function(){return"[object Generator]"}),(W=function(){return{w:i,m:y}})()}function U(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}U=function(t,e,r,n){function i(e,r){U(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))},U(t,e,r,n)}function q(t,e,r,n,o,i,l){try{var a=t[i](l),c=a.value}catch(t){return void r(t)}a.done?e(c):Promise.resolve(c).then(n,o)}function R(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 Z(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?R(Object(r),!0).forEach(function(e){$(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function $(t,e,r){return(e=function(t){var e=function(t){if("object"!=F(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=F(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==F(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,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,l,a=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){u=!0,o=t}finally{try{if(!c&&null!=r.return&&(l=r.return(),Object(l)!==l))return}finally{if(u)throw o}}return a}}(t,e)||Q(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 Q(t,e){if(t){if("string"==typeof t)return X(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)?X(t,e):void 0}}function X(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 Y=new Map,tt=new Map,et={},rt=function(t){var e,r=0,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Q(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,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){l=!0,o=t},f:function(){try{i||null==e.return||e.return()}finally{if(l)throw o}}}}(t);try{for(n.s();!(e=n.n()).done;){var o=e.value;r=Math.trunc((r<<5)-r+o.codePointAt(0))}}catch(t){n.e(t)}finally{n.f()}return Math.abs(r).toString(36)},nt=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function ot(t,e,r){var n,o,i,l,a=null==r?void 0:r.id,c=Object.fromEntries(Object.entries(t||{}).filter(function(t){var e=J(t,1)[0];return!nt.has(e)})),u=Object.fromEntries(Object.entries(et).filter(function(t){var e=J(t,1)[0];return!nt.has(e)})),f=Object.fromEntries(Object.entries(e).filter(function(t){return null!=J(t,2)[1]})),s=Z(Z(Z(Z({},T),u),c),f),y=null!==(n=N[null==r?void 0:r.mapColorScheme])&&void 0!==n?n:N.light;return s.haloColor=null!==(o=null==r?void 0:r.haloColor)&&void 0!==o?o:y.haloColor,s.selectedColor=null!==(i=null==r?void 0:r.selectedColor)&&void 0!==i?i:y.selectedColor,s.activeColor=null!==(l=null==r?void 0:r.activeColor)&&void 0!==l?l:y.activeColor,"string"==typeof s.graphic&&_[s.graphic]&&(s.graphic=_[s.graphic]),Object.fromEntries(Object.entries(s).map(function(t){var e=J(t,2),r=e[0],n=e[1];return[r,p(n,a)||""]}))}function it(t,e){return Object.entries(e).reduce(function(t,e){var r=J(e,2),n=r[0],o=r[1];return t.replaceAll("{{".concat(n,"}}"),o)},t)}var lt={setDefaults:function(t){et=t||{}},getDefaults:function(){return Z(Z({},T),et)},register:function(t){Y.set(t.id,t)},get:function(t){return Y.get(t)},list:function(){return function(t){if(Array.isArray(t))return X(t)}(t=Y.values())||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Q(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.")}();var t},clear:function(){Y.clear()},initialise:function(){this.register(V),this.register(B),this.register(G)},resolve:function(t,e,r){var n=ot(t,e||{},r);return t?(n.selectedColor="none",n.activeColor="none",it(t.svg,n)):""},resolveActive:function(t,e,r){var n=ot(t,e||{},r);return t?it(t.svg,n):""},resolveSelected:function(t,e,r){var n=ot(t,e||{},r);return t?(n.activeColor="none",it(t.svg,n)):""},getSymbolImageId:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,o=this.getSymbolDef(t);if(!o)return null;var i=z(t),l=r?this.resolveActive(o,i,e):this.resolve(o,i,e);return"symbol-".concat(r?"act-":"").concat(rt(l),"-").concat(n,"x")},getSymbolDef:function(t){return t.symbolSvgContent?{svg:t.symbolSvgContent}:t.symbol?this.get(t.symbol):void 0},rasteriseSymbolImage:function(t,e,r,n){var o,i=this;return(o=W().m(function o(){var l,a,c,u,f,s,y,p,m,b,v,d;return W().w(function(o){for(;;)switch(o.n){case 0:if(l=i.getSymbolDef(t)){o.n=1;break}return o.a(2,null);case 1:if(a=z(t),"active"===r?(c=i.resolveActive(l,a,e),u="act-"):"selected"===r?(c=i.resolveSelected(l,a,e),u="sel-"):(c=i.resolve(l,a,e),u=""),f="symbol-".concat(u).concat(rt(c),"-").concat(n,"x"),s=tt.get(f)){o.n=3;break}return y=H(t,l),p=y.split(" ").map(Number),m=J(p,4),b=m[2],v=m[3],d='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(b*n,'" height="').concat(v*n,'" viewBox="').concat(y,'">').concat(c,"</svg>"),o.n=2,K(d,b*n,v*n);case 2:s=o.v,tt.set(f,s);case 3:return o.a(2,{imageId:f,imageData:s})}},o)}),function(){var t=this,e=arguments;return new Promise(function(r,n){var i=o.apply(t,e);function l(t){q(i,r,n,l,a,"next",t)}function a(t){q(i,r,n,l,a,"throw",t)}l(void 0)})})()}};function at(t){return at="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},at(t)}function ct(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 ut(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ct(Object(r),!0).forEach(function(e){ft(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ct(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function ft(t,e,r){return(e=function(t){var e=function(t){if("object"!=at(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=at(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==at(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}lt.initialise();var st=function(t){var e,r=t.keyDefinition,n=t.mapStyle,o=t.symbolDef,i=r.style,l=null!==(e=null==n?void 0:n.appColorScheme)&&void 0!==e?e:"light",a=ut(ut({},n),{},{mapColorScheme:l}),c=lt.resolve(o,z(i),a),u=H(i,o);return c&&u?(0,f.jsx)("svg",ut(ut({},S),{},{viewBox:u,children:(0,f.jsx)("g",{dangerouslySetInnerHTML:{__html:c}})})):null};function yt(t){return yt="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},yt(t)}function pt(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 mt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?pt(Object(r),!0).forEach(function(e){bt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function bt(t,e,r){return(e=function(t){var e=function(t){if("object"!=yt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var vt=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=p(r.stroke,e.id);return(0,f.jsx)("svg",mt(mt({},g),{},{children:(0,f.jsx)("line",{x1:n/2,y1:10,x2:h-n/2,y2:10,stroke:o,strokeWidth:n,strokeLinecap:"round"})}))};function dt(t){return dt="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},dt(t)}function ht(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 gt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ht(Object(r),!0).forEach(function(e){St(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ht(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function St(t,e,r){return(e=function(t){var e=function(t){if("object"!=dt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=dt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==dt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var jt=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=p(r.fill,e.id),i=p(r.stroke,e.id);return(0,f.jsx)("svg",gt(gt({},g),{},{children:(0,f.jsx)("rect",{x:n/2,y:n/2,width:h-n,height:h-n,rx:n,ry:n,fill:o,stroke:i,strokeWidth:n,strokeLinejoin:"round"})}))},Ot=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=p(r.fill,e.id),o=p(r.fill,e.id);return(0,f.jsx)("svg",{viewBox:"0 0 5 5",preserveAspectRatio:"none",fill:n,stroke:o,strokeWidth:"1",children:(0,f.jsx)("path",{d:"M0 0h5v5H0z"})})},wt="horizontal-ramp",kt=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=function(t,e){if(!t)return{symbolShape:null,symbolDef:null};var r=t.hasSymbol,n=t.hasPattern,o=t.style;if(e===wt)return{symbolShape:wt,symbolDef:null};if(r){var i=lt.getSymbolDef(o);return{symbolShape:i?"symbol":"rect",symbolDef:i}}return n?{symbolShape:"pattern",symbolDef:null}:"line"===o.keySymbolShape?{symbolShape:"line",symbolDef:null}:{symbolShape:"rect",symbolDef:null}}(e,r),i=o.symbolShape,l=o.symbolDef;return i?"symbol"===i?(0,f.jsx)(st,{mapStyle:n,keyDefinition:e,symbolDef:l}):"pattern"===i?(0,f.jsx)(E,{mapStyle:n,keyDefinition:e}):"line"===i?(0,f.jsx)(vt,{mapStyle:n,keyDefinition:e}):i===wt?(0,f.jsx)(Ot,{mapStyle:n,keyDefinition:e}):(0,f.jsx)(jt,{mapStyle:n,keyDefinition:e}):null},Pt=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=e.label,i=p(e.symbolDescription,n.id);return(0,f.jsxs)("div",{className:"im-c-map-key-list__item",children:[(0,f.jsx)("dt",{className:"im-c-map-key-list__item-symbol",children:(0,f.jsx)(kt,{keyDefinition:e,groupStyle:r,mapStyle:n})}),(0,f.jsxs)("dd",{className:"im-c-map-key-list__item-label",children:[o,i&&(0,f.jsxs)("span",{className:"govuk-visually-hidden",children:["(",i,")"]})]})]})},Ct=function(t){var e=t.headingId,r=t.label,n=t.groupStyle,o=t.keyDefinitions,i=t.mapStyle,l="im-c-map-key-list"+(n?" im-c-map-key-list-".concat(n):"");return(0,f.jsxs)("section",{className:"im-c-map-key__group","aria-labelledby":e,children:[(0,f.jsx)("h3",{id:e,className:"im-c-map-key__group-heading",children:r}),(0,f.jsx)("dl",{className:l,children:o.map(function(t){return(0,f.jsx)(Pt,{keyDefinition:t,mapStyle:i,groupStyle:n},"".concat(t.id))})})]})},xt="im-c-map-key",Dt=function(t){var e=t.item,r=t.groupStyle,n=t.mapStyle;return"group"===e.type?(0,f.jsx)(Ct,{headingId:"key-heading-".concat(e.id),label:e.groupLabel,groupStyle:r,keyDefinitions:e.keyDefinitions,mapStyle:n}):(0,f.jsx)(Pt,{keyDefinition:e.keyDefinition,mapStyle:n})},At=function(t){var e=t.noKeyItemText,r=t.keyGroups,n=t.hasGroups,o=t.mapStyle;if(null==r||!r.length)return(0,f.jsx)(s,{text:e});var i=n?"".concat(xt," ").concat("im-c-map-key--has-groups"):xt;return(0,f.jsx)("div",{className:i,children:r.map(function(t){return(0,f.jsx)(Dt,{item:t,mapStyle:o,groupStyle:t.groupStyle},t.id)})})};function Mt(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,l,a=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){u=!0,o=t}finally{try{if(!c&&null!=r.return&&(l=r.return(),Object(l)!==l))return}finally{if(u)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return It(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)?It(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.")}()}function It(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 Et={InitComponent:function(t){var e=t.mapState,r=t.services.eventBus;(0,n.useEffect)(function(){e.isMapReady&&r.requestOnce("datasets:registry",i)},[e.isMapReady])},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(t){var e=t.mapState.mapStyle,r=t.pluginConfig,i=r.noKeyItemText,l=r.groups,a=t.services.eventBus,u=Mt((0,n.useState)(o),2),s=u[0],y=u[1],p=Mt((0,n.useState)(function(){var t;return null!==(t=null==s?void 0:s.keyItems().items)&&void 0!==t?t:[]}),2),m=p[0],b=p[1],v=Mt((0,n.useState)(function(){var t;return null!==(t=null==s?void 0:s.keyItems().hasGroups)&&void 0!==t&&t}),2),d=v[0],h=v[1],g=function(){var t=s.keyItems(),e=t.items,r=t.hasGroups,n=function(t,e){return t?e.map(function(e){var r=e.id;return t[r]?c(c({},e),t[r]):e}):e}(l,e);b(n),h(r)},S=function(t){s.invalidateKeyItemsOnMenuStateChange(t),g()};return(0,n.useEffect)(function(){return s?(g(),a.on("menu:changed",S).on("datasets:changed",g),function(){return a.off("menu:changed",S).off("datasets:changed",g)}):(a.requestOnce("datasets:registry",y),function(){})},[s]),(0,f.jsx)(At,{noKeyItemText:i,keyGroups:m,hasGroups:d,mapStyle:e})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{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"/>'}]}}}]);
|
|
2
|
+
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[414],{935(t,r,e){e.r(r),e.d(r,{manifest:()=>Yt});var n=e(738),o=null,i=function(t){return o=t};function a(t){return a="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},a(t)}function l(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return u(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?u(t,r):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 u(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function c(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function f(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?c(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):c(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function s(t,r,e){return(r=function(t){var r=function(t){if("object"!=a(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=a(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==a(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var y={},p=null,b=[],m=e(287),v=function(t){var r=t.text;return(0,m.jsx)("div",{className:"im-c-map-key",children:(0,m.jsx)("p",{className:"im-c-map-key__empty-message",children:r})})};function d(t){return d="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},d(t)}var h=function(t,r){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===d(t)){if(r&&t[r])return t[r];var e=Object.values(t)[0];return null!=e?e:null}return null};function g(t){return g="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},g(t)}function S(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function j(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?S(Object(e),!0).forEach(function(r){O(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):S(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function O(t,r,e){return(r=function(t){var r=function(t){if("object"!=g(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=g(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==g(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var w=20,P={xmlns:"http://www.w3.org/2000/svg",width:w,height:w,viewBox:"0 0 ".concat(w," ").concat(w),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},k=j(j({},P),{},{width:44,height:44,className:"im-c-map-key-symbol im-c-map-key-symbol--point"}),D={"cross-hatch":'<path d="M0 4.486V3.485h3.5V.001h1v3.484h7.002V.001h1v3.484h3.5v1.001h-3.5v7h3.5v.999h-3.5v3.516h-1v-3.516H4.499v3.516h-1v-3.516H0v-.999h3.5v-7H0zm11.501 0H4.499v7h7.002v-7z" fill="{{foregroundColor}}"/>',"diagonal-cross-hatch":'<path d="M0 8.707V7.293L7.293 0h1.414L16 7.293v1.414L8.707 16H7.293L0 8.707zM.707 8L8 15.293 15.293 8 8 .707.707 8z" fill="{{foregroundColor}}"/>',"forward-diagonal-hatch":'<path d="M16 8.707V7.293L7.293 16h1.414L16 8.707zm-16 0L8.707 0H7.293L0 7.293v1.414z" fill="{{foregroundColor}}"/>',"backward-diagonal-hatch":'<path d="M0 8.707V7.293L8.707 16H7.293L0 8.707zm16 0L7.293 0h1.414L16 7.293v1.414z" fill="{{foregroundColor}}"/>',"horizontal-hatch":'<path d="M0 4.5V3.499h15.999V4.5H0zm0 7h15.999V12.5H0v-1.001z" fill="{{foregroundColor}}"/>',"vertical-hatch":'<path d="M3.501 16.001V0h1v16.001h-1zm7.998 0V0h1v16.001h-1z" fill="{{foregroundColor}}"/>',dot:'<path d="M3.999 2A2 2 0 0 1 6 3.999C6 5.103 5.103 6 3.999 6a2 2 0 0 1-1.999-2.001A2 2 0 0 1 3.999 2zm0 7.999C5.103 10 6 10.897 6 12.001A2 2 0 0 1 3.999 14a2 2 0 0 1-1.999-1.999A2 2 0 0 1 3.999 10zM11.999 2A2 2 0 0 1 14 3.999C14 5.103 13.103 6 11.999 6S10 5.103 10 3.999A2 2 0 0 1 11.999 2zm0 7.999c1.104 0 2.001.897 2.001 2.001A2 2 0 0 1 11.999 14 2 2 0 0 1 10 12.001c0-1.104.897-2.001 1.999-2.001z" fill="{{foregroundColor}}"/>',diamond:'<path d="M4 .465L7.535 4 4 7.535.465 4 4 .465zm0 7.999l3.535 3.535L4 15.535.465 11.999 4 8.464zm8-8l3.535 3.535-3.536 3.536L8.464 4 12 .464zm0 8.001L15.536 12 12 15.536 8.465 12 12 8.465z" fill="{{foregroundColor}}"/>'};function C(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var x=function(t,r,e){return t.replace(/\{\{foregroundColor\}\}/g,r||"black").replace(/\{\{backgroundColor\}\}/g,e||"transparent")};function A(t,r){if(t){if("string"==typeof t)return E(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?E(t,r):void 0}}function E(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var I=new Map,M={register:function(t,r){I.set(t,{id:t,svgContent:r})},get:function(t){return I.get(t)},list:function(){return function(t){if(Array.isArray(t))return E(t)}(t=I.values())||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||A(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.")}();var t},clear:function(){I.clear()},initialise:function(){var t=this;Object.entries(D).forEach(function(r){var e,n,o=(n=2,function(t){if(Array.isArray(t))return t}(e=r)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(e,n)||A(e,n)||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.")}()),i=o[0],a=o[1];t.register(i,a)})},getPatternInnerContent:function(t){return t.fillPatternSvgContent?t.fillPatternSvgContent:t.fillPattern&&null!==(r=null===(e=this.get(t.fillPattern))||void 0===e?void 0:e.svgContent)&&void 0!==r?r:null;var r,e},getKeyPatternPaths:function(t,r){var e=this.getPatternInnerContent(t);if(!e)return null;var n=h(t.fillPatternForegroundColor,r)||"black",o=h(t.fillPatternBackgroundColor,r)||"transparent",i=h(t.stroke,r)||n;return{border:x('<path d="M19 2.862v14.275c0 1.028-.835 1.862-1.862 1.862H2.863c-1.028 0-1.862-.835-1.862-1.862V2.862C1.001 1.834 1.836 1 2.863 1h14.275C18.166 1 19 1.835 19 2.862z" fill="{{backgroundColor}}" stroke="{{foregroundColor}}" stroke-width="2"/>',i,o),content:x(e,n,o)}},getPatternImageId:function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=this.getPatternInnerContent(t);if(!n)return null;var o=h(t.fillPatternForegroundColor,r)||"black",i=h(t.fillPatternBackgroundColor,r)||"transparent",a=function(t){return Math.max(2,2*t)}(e);return"pattern-".concat(function(t){var r,e=0,n=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return C(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?C(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);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,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(t);try{for(n.s();!(r=n.n()).done;){var o=r.value;e=Math.trunc((e<<5)-e+o.codePointAt(0))}}catch(t){n.e(t)}finally{n.f()}return Math.abs(e).toString(36)}(n+o+i),"-").concat(a,"x")}};function _(t){return _="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},_(t)}function L(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function T(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?L(Object(e),!0).forEach(function(r){z(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):L(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function z(t,r,e){return(r=function(t){var r=function(t){if("object"!=_(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=_(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}M.initialise();var H=function(t){var r=t.keyDefinition,e=t.mapStyle,n=r.style,o=M.getKeyPatternPaths(n,e.id);return o?(0,m.jsxs)("svg",T(T({},P),{},{children:[(0,m.jsx)("g",{dangerouslySetInnerHTML:{__html:o.border}}),(0,m.jsx)("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:o.content}})]})):null},V=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),K=function(t){if(!function(t){return!(!t.symbol&&!t.symbolSvgContent)}(t))return{};var r={};return V.forEach(function(e){if(null!=t[e]){var n=e.charAt(6).toLowerCase()+e.slice(7);r[n]=t[e]}}),r},B=function(t,r){var e;return t.symbolViewBox?t.symbolViewBox:null!==(e=null==r?void 0:r.viewBox)&&void 0!==e?e:"0 0 38 38"},G={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},N={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},U={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:N.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},R={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:N.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},F={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:N.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},$={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},W=function(t,r,e){return new Promise(function(n,o){var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t)),a=new Image(r,e);a.onload=function(){var t=document.createElement("canvas");t.width=r,t.height=e;var o=t.getContext("2d");o.drawImage(a,0,0,r,e),n(o.getImageData(0,0,r,e))},a.onerror=function(){o(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},a.src=i})};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)}function q(){var t,r,e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",o=e.toStringTag||"@@toStringTag";function i(e,n,o,i){var u=n&&n.prototype instanceof l?n:l,c=Object.create(u.prototype);return Z(c,"_invoke",function(e,n,o){var i,l,u,c=0,f=o||[],s=!1,y={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(r,e){return i=r,l=0,u=t,y.n=e,a}};function p(e,n){for(l=e,u=n,r=0;!s&&c&&!o&&r<f.length;r++){var o,i=f[r],p=y.p,b=i[2];e>3?(o=b===n)&&(u=i[(l=i[4])?5:(l=3,3)],i[4]=i[5]=t):i[0]<=p&&((o=e<2&&p<i[1])?(l=0,y.v=n,y.n=i[1]):p<b&&(o=e<3||i[0]>n||n>b)&&(i[4]=e,i[5]=n,y.n=b,l=0))}if(o||e>1)return a;throw s=!0,n}return function(o,f,b){if(c>1)throw TypeError("Generator is already running");for(s&&1===f&&p(f,b),l=f,u=b;(r=l<2?t:u)||!s;){i||(l?l<3?(l>1&&(y.n=-1),p(l,u)):y.n=u:y.v=u);try{if(c=2,i){if(l||(o="next"),r=i[o]){if(!(r=r.call(i,u)))throw TypeError("iterator result is not an object");if(!r.done)return r;u=r.value,l<2&&(l=0)}else 1===l&&(r=i.return)&&r.call(i),l<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),l=1);i=t}else if((r=(s=y.n<0)?u:e.call(n,y))!==a)break}catch(r){i=t,l=1,u=r}finally{c=1}}return{value:r,done:s}}}(e,o,i),!0),c}var a={};function l(){}function u(){}function c(){}r=Object.getPrototypeOf;var f=[][n]?r(r([][n]())):(Z(r={},n,function(){return this}),r),s=c.prototype=l.prototype=Object.create(f);function y(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,Z(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return u.prototype=c,Z(s,"constructor",c),Z(c,"constructor",u),u.displayName="GeneratorFunction",Z(c,o,"GeneratorFunction"),Z(s),Z(s,o,"Generator"),Z(s,n,function(){return this}),Z(s,"toString",function(){return"[object Generator]"}),(q=function(){return{w:i,m:y}})()}function Z(t,r,e,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Z=function(t,r,e,n){function i(r,e){Z(t,r,function(t){return this._invoke(r,e,t)})}r?o?o(t,r,{value:e,enumerable:!n,configurable:!n,writable:!n}):t[r]=e:(i("next",0),i("throw",1),i("return",2))},Z(t,r,e,n)}function J(t,r,e,n,o,i,a){try{var l=t[i](a),u=l.value}catch(t){return void e(t)}l.done?r(u):Promise.resolve(u).then(n,o)}function Q(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function X(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Q(Object(e),!0).forEach(function(r){tt(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Q(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function tt(t,r,e){return(r=function(t){var r=function(t){if("object"!=Y(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=Y(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Y(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function rt(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||et(t,r)||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 et(t,r){if(t){if("string"==typeof t)return nt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?nt(t,r):void 0}}function nt(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var ot=new Map,it=new Map,at={},lt=function(t){var r,e=0,n=function(t){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=et(t))){r&&(t=r);var e=0,n=function(){};return{s:n,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},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(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(n.s();!(r=n.n()).done;){var o=r.value;e=Math.trunc((e<<5)-e+o.codePointAt(0))}}catch(t){n.e(t)}finally{n.f()}return Math.abs(e).toString(36)},ut=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function ct(t,r,e){var n,o,i,a,l=null==e?void 0:e.id,u=Object.fromEntries(Object.entries(t||{}).filter(function(t){var r=rt(t,1)[0];return!ut.has(r)})),c=Object.fromEntries(Object.entries(at).filter(function(t){var r=rt(t,1)[0];return!ut.has(r)})),f=Object.fromEntries(Object.entries(r).filter(function(t){return null!=rt(t,2)[1]})),s=X(X(X(X({},G),c),u),f),y=null!==(n=$[null==e?void 0:e.mapColorScheme])&&void 0!==n?n:$.light;return s.haloColor=null!==(o=null==e?void 0:e.haloColor)&&void 0!==o?o:y.haloColor,s.selectedColor=null!==(i=null==e?void 0:e.selectedColor)&&void 0!==i?i:y.selectedColor,s.activeColor=null!==(a=null==e?void 0:e.activeColor)&&void 0!==a?a:y.activeColor,"string"==typeof s.graphic&&N[s.graphic]&&(s.graphic=N[s.graphic]),Object.fromEntries(Object.entries(s).map(function(t){var r=rt(t,2),e=r[0],n=r[1];return[e,h(n,l)||""]}))}function ft(t,r){return Object.entries(r).reduce(function(t,r){var e=rt(r,2),n=e[0],o=e[1];return t.replaceAll("{{".concat(n,"}}"),o)},t)}var st={setDefaults:function(t){at=t||{}},getDefaults:function(){return X(X({},G),at)},register:function(t){ot.set(t.id,t)},get:function(t){return ot.get(t)},list:function(){return function(t){if(Array.isArray(t))return nt(t)}(t=ot.values())||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||et(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.")}();var t},clear:function(){ot.clear()},initialise:function(){this.register(U),this.register(R),this.register(F)},resolve:function(t,r,e){var n=ct(t,r||{},e);return t?(n.selectedColor="none",n.activeColor="none",ft(t.svg,n)):""},resolveActive:function(t,r,e){var n=ct(t,r||{},e);return t?ft(t.svg,n):""},resolveSelected:function(t,r,e){var n=ct(t,r||{},e);return t?(n.activeColor="none",ft(t.svg,n)):""},getSymbolImageId:function(t,r){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,o=this.getSymbolDef(t);if(!o)return null;var i=K(t),a=e?this.resolveActive(o,i,r):this.resolve(o,i,r);return"symbol-".concat(e?"act-":"").concat(lt(a),"-").concat(n,"x")},getSymbolDef:function(t){return t.symbolSvgContent?{svg:t.symbolSvgContent}:t.symbol?this.get(t.symbol):void 0},rasteriseSymbolImage:function(t,r,e,n){var o,i=this;return(o=q().m(function o(){var a,l,u,c,f,s,y,p,b,m,v,d;return q().w(function(o){for(;;)switch(o.n){case 0:if(a=i.getSymbolDef(t)){o.n=1;break}return o.a(2,null);case 1:if(l=K(t),"active"===e?(u=i.resolveActive(a,l,r),c="act-"):"selected"===e?(u=i.resolveSelected(a,l,r),c="sel-"):(u=i.resolve(a,l,r),c=""),f="symbol-".concat(c).concat(lt(u),"-").concat(n,"x"),s=it.get(f)){o.n=3;break}return y=B(t,a),p=y.split(" ").map(Number),b=rt(p,4),m=b[2],v=b[3],d='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(m*n,'" height="').concat(v*n,'" viewBox="').concat(y,'">').concat(u,"</svg>"),o.n=2,W(d,m*n,v*n);case 2:s=o.v,it.set(f,s);case 3:return o.a(2,{imageId:f,imageData:s})}},o)}),function(){var t=this,r=arguments;return new Promise(function(e,n){var i=o.apply(t,r);function a(t){J(i,e,n,a,l,"next",t)}function l(t){J(i,e,n,a,l,"throw",t)}a(void 0)})})()}};function yt(t){return yt="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},yt(t)}function pt(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function bt(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?pt(Object(e),!0).forEach(function(r){mt(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):pt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function mt(t,r,e){return(r=function(t){var r=function(t){if("object"!=yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=yt(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}st.initialise();var vt=function(t){var r,e=t.keyDefinition,n=t.mapStyle,o=t.symbolDef,i=e.style,a=null!==(r=null==n?void 0:n.appColorScheme)&&void 0!==r?r:"light",l=bt(bt({},n),{},{mapColorScheme:a}),u=st.resolve(o,K(i),l),c=B(i,o);return u&&c?(0,m.jsx)("svg",bt(bt({},k),{},{viewBox:c,children:(0,m.jsx)("g",{dangerouslySetInnerHTML:{__html:u}})})):null};function dt(t){return dt="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},dt(t)}function ht(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function gt(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?ht(Object(e),!0).forEach(function(r){St(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):ht(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function St(t,r,e){return(r=function(t){var r=function(t){if("object"!=dt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=dt(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==dt(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var jt=function(t){var r=t.mapStyle,e=t.keyDefinition.style,n=e.strokeWidth,o=h(e.stroke,r.id);return(0,m.jsx)("svg",gt(gt({},P),{},{children:(0,m.jsx)("line",{x1:n/2,y1:10,x2:w-n/2,y2:10,stroke:o,strokeWidth:n,strokeLinecap:"round"})}))};function Ot(t){return Ot="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},Ot(t)}function wt(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function Pt(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?wt(Object(e),!0).forEach(function(r){kt(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):wt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function kt(t,r,e){return(r=function(t){var r=function(t){if("object"!=Ot(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=Ot(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ot(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var Dt=function(t){var r=t.mapStyle,e=t.keyDefinition.style,n=e.strokeWidth,o=h(e.fill,r.id),i=h(e.stroke,r.id);return(0,m.jsx)("svg",Pt(Pt({},P),{},{children:(0,m.jsx)("rect",{x:n/2,y:n/2,width:w-n,height:w-n,rx:n,ry:n,fill:o,stroke:i,strokeWidth:n,strokeLinejoin:"round"})}))},Ct=function(t){var r=t.mapStyle,e=t.keyDefinition.style,n=h(e.fill,r.id),o=h(e.fill,r.id);return(0,m.jsx)("svg",{viewBox:"0 0 5 5",preserveAspectRatio:"none",fill:n,stroke:o,strokeWidth:"1",children:(0,m.jsx)("path",{d:"M0 0h5v5H0z"})})},xt="horizontal-ramp",At=function(t){var r=t.keyDefinition,e=t.groupStyle,n=t.mapStyle,o=function(t,r){if(!t)return{symbolShape:null,symbolDef:null};var e=t.hasSymbol,n=t.hasPattern,o=t.style;if(r===xt)return{symbolShape:xt,symbolDef:null};if(e){var i=st.getSymbolDef(o);return{symbolShape:i?"symbol":"rect",symbolDef:i}}return n?{symbolShape:"pattern",symbolDef:null}:"line"===o.keySymbolShape?{symbolShape:"line",symbolDef:null}:{symbolShape:"rect",symbolDef:null}}(r,e),i=o.symbolShape,a=o.symbolDef;return i?"symbol"===i?(0,m.jsx)(vt,{mapStyle:n,keyDefinition:r,symbolDef:a}):"pattern"===i?(0,m.jsx)(H,{mapStyle:n,keyDefinition:r}):"line"===i?(0,m.jsx)(jt,{mapStyle:n,keyDefinition:r}):i===xt?(0,m.jsx)(Ct,{mapStyle:n,keyDefinition:r}):(0,m.jsx)(Dt,{mapStyle:n,keyDefinition:r}):null},Et=function(t){var r=t.keyDefinition,e=t.groupStyle,n=t.mapStyle,o=r.label,i=h(r.symbolDescription,n.id);return(0,m.jsxs)("div",{className:"im-c-map-key-list__item",children:[(0,m.jsx)("dt",{className:"im-c-map-key-list__item-symbol",children:(0,m.jsx)(At,{keyDefinition:r,groupStyle:e,mapStyle:n})}),(0,m.jsxs)("dd",{className:"im-c-map-key-list__item-label",children:[o,i&&(0,m.jsxs)("span",{className:"govuk-visually-hidden",children:["(",i,")"]})]})]})},It=function(t){var r=t.headingId,e=t.label,n=t.groupStyle,o=t.keyDefinitions,i=t.mapStyle,a="im-c-map-key-list"+(n?" im-c-map-key-list-".concat(n):"");return(0,m.jsxs)("section",{className:"im-c-map-key__group","aria-labelledby":r,children:[(0,m.jsx)("h3",{id:r,className:"im-c-map-key__group-heading",children:e}),(0,m.jsx)("dl",{className:a,children:o.map(function(t){return(0,m.jsx)(Et,{keyDefinition:t,mapStyle:i,groupStyle:n},"".concat(t.id))})})]})},Mt="im-c-map-key",_t=function(t){var r=t.item,e=t.groupStyle,n=t.mapStyle;return"group"===r.type?(0,m.jsx)(It,{headingId:"key-heading-".concat(r.id),label:r.groupLabel,groupStyle:e,keyDefinitions:r.keyDefinitions,mapStyle:n}):(0,m.jsx)(Et,{keyDefinition:r.keyDefinition,mapStyle:n})},Lt=function(t){var r=t.noKeyItemText,e=t.keyGroups,n=t.hasGroups,o=t.mapStyle;if(null==e||!e.length)return(0,m.jsx)(v,{text:r});var i=n?"".concat(Mt," ").concat("im-c-map-key--has-groups"):Mt;return(0,m.jsx)("div",{className:i,children:e.map(function(t){return(0,m.jsx)(_t,{item:t,mapStyle:o,groupStyle:t.groupStyle},t.id)})})};function Tt(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return zt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?zt(t,r):void 0}}(t,r)||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 zt(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Ht(t){return Ht="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},Ht(t)}function Vt(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function Kt(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Vt(Object(e),!0).forEach(function(r){Bt(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Vt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Bt(t,r,e){return(r=function(t){var r=function(t){if("object"!=Ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=Ht(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ht(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Gt(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Nt(t){return Nt="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},Nt(t)}function Ut(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function Rt(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Ut(Object(e),!0).forEach(function(r){Ft(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ut(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Ft(t,r,e){return(r=function(t){var r=function(t){if("object"!=Nt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=Nt(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Nt(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function $t(t){return function(t){if(Array.isArray(t))return Wt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return Wt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Wt(t,r):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 Wt(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Yt={InitComponent:function(t){var r=t.pluginConfig,e=t.pluginState,o=t.mapState,a=t.services,l=e.dispatch,u=a.eventBus,c=(0,n.useRef)(e);c.current=e,(0,n.useEffect)(function(){o.isMapReady&&(function(t){y=t}(c),u.requestOnce("datasets:registry",i))},[o.isMapReady]),(0,n.useEffect)(function(){if(r.groups){var t=Object.entries(r.groups).map(function(t){var r,e,n=(e=2,function(t){if(Array.isArray(t))return t}(r=t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(r,e)||function(t,r){if(t){if("string"==typeof t)return Gt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Gt(t,r):void 0}}(r,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.")}()),o=n[0],i=n[1];return Kt(Kt({},i),{},{id:o,label:i.groupLabel})});l({type:"ADD_KEY_GROUPS",payload:t})}},[r.groups])},reducer:{initialState:{keyDefinitions:[],groups:[]},actions:{ADD_KEY_ITEM:function(t,r){var e,n=r.id,o=r.groupLabel,i=r.groupId||((e=o)?e.toLowerCase().replace(/\s+/g,"-"):null),a=function(t,r,e){return t.groups.find(function(t){return"group"===t.type&&t.id===e||"flat"===t.type&&t.id===r})}(t,n,i),l=a?null:function(t,r,e){return r?{id:r,type:"group",groupLabel:e}:{id:t,type:"flat"}}(n,i,o),u=l?[].concat($t(t.groups),[l]):t.groups,c=[].concat($t(t.keyDefinitions),[Rt(Rt({},r),{},{type:"manual"},i?{groupId:i}:{})]);return Rt(Rt({},t),{},{keyDefinitions:c,groups:u})},REMOVE_KEY_ITEM:function(t,r){var e=r.id;return Rt(Rt({},t),{},{keyDefinitions:t.keyDefinitions.filter(function(t){return t.id!==e})})},ADD_KEY_GROUPS:function(t,r){return Rt(Rt({},t),{},{groups:[].concat($t(t.groups),$t(r))})}}},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(t){var r=t.mapState.mapStyle,e=t.pluginConfig.noKeyItemText,i=t.pluginState,a=t.services.eventBus,u=Tt((0,n.useState)(o),2),c=u[0],s=u[1],v=Tt((0,n.useState)(function(){var t;return null!==(t=null==c?void 0:c.keyItems().items)&&void 0!==t?t:[]}),2),d=v[0],h=v[1],g=Tt((0,n.useState)(function(){var t;return null!==(t=null==c?void 0:c.keyItems().hasGroups)&&void 0!==t&&t}),2),S=g[0],j=g[1],O=function(){var t=c.keyItems(),r=t.items,e=t.hasGroups,n=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=l(function(){var t;if(null===(t=y)||void 0===t||!t.current)return[];if(p===y.current)return b;p=y.current;var r=y.current,e=r.groups,n=void 0===e?[]:e,o=r.keyDefinitions,i=void 0===o?[]:o;return b=n.map(function(t){return"flat"===t.type?f(f({},t),{},{keyDefinition:i.find(function(r){return r.id===t.id})}):f(f({},t),{},{keyDefinitions:i.filter(function(r){return r.groupId===t.id})})})}());if(0===r.length)return t;var e=t.map(function(t){var e=r.findIndex(function(r){return r.id===t.id});if(-1===e)return t;var n=r.splice(e,1)[0];return f(f(f({},t),n),{},{keyDefinitions:[].concat(l(n.keyDefinitions||[]),l(t.keyDefinitions||[]))})});return[].concat(l(e),l(r)).filter(function(t){var r;return"flat"===t.type&&t.keyDefinition||"group"===t.type&&(null===(r=t.keyDefinitions)||void 0===r?void 0:r.length)})}(r);h(n),j(e)},w=function(t){c.invalidateKeyItemsOnMenuStateChange(t),O()};return(0,n.useEffect)(function(){return c?(O(),a.on("menu:changed",w).on("datasets:changed",O),function(){return a.off("menu:changed",w).off("datasets:changed",O)}):(a.requestOnce("datasets:registry",s),function(){})},[c]),(0,n.useEffect)(function(){c&&O()},[i]),(0,m.jsx)(Lt,{noKeyItemText:e,keyGroups:d,hasGroups:S,mapStyle:r})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{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:{addKeyItem:function(t,r){(0,t.pluginState.dispatch)({type:"ADD_KEY_ITEM",payload:r})},removeKeyItem:function(t,r){(0,t.pluginState.dispatch)({type:"REMOVE_KEY_ITEM",payload:r})}}}}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.mapKeyPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat},287(e){e.exports=preactJsxRuntime}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>"im-map-key-plugin.js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.mapKeyPlugin:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var u,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){u=l;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",t+i),u.src=r),e[r]=[n];var s=(t,n)=>{u.onerror=u.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(e=>e(n)),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=s.bind(null,u.onerror),u.onload=s.bind(null,u.onload),c&&document.head.appendChild(u)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={57:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=i);var a=o.p+o.u(t),u=new Error;o.l(a,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[a,u,c]=r,f=0;if(a.some(t=>0!==e[t])){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(t&&t(r);f<a.length;f++)i=a[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function u(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof f?n:f,p=Object.create(u.prototype);return c(p,"_invoke",function(r,n,o){var i,u,c,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,u=0,c=e,s.n=r,a}};function d(r,n){for(u=r,c=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(u=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,u=0))}if(o||r>1)return a;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),u=p,c=b;(t=u<2?e:c)||!l;){i||(u?u<3?(u>1&&(s.n=-1),d(u,c)):s.n=c:s.v=c);try{if(f=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=e}else if((t=(l=s.n<0)?c:r.call(n,s))!==a)break}catch(t){i=e,u=1,c=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var a={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(c(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,c(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,c(d,"constructor",l),c(l,"constructor",p),p.displayName="GeneratorFunction",c(l,o,"GeneratorFunction"),c(d),c(d,o,"Generator"),c(d,n,function(){return this}),c(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:b}})()}function c(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,r,n){function i(t,r){c(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},c(e,t,r,n)}function f(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t;return l(l({noKeyItemText:"No features displayed"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"mapKey",load:(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(414).then(o.bind(o,
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.mapKeyPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat},287(e){e.exports=preactJsxRuntime}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>"im-map-key-plugin.js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.mapKeyPlugin:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var u,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){u=l;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",t+i),u.src=r),e[r]=[n];var s=(t,n)=>{u.onerror=u.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(e=>e(n)),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=s.bind(null,u.onerror),u.onload=s.bind(null,u.onload),c&&document.head.appendChild(u)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={57:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=i);var a=o.p+o.u(t),u=new Error;o.l(a,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[a,u,c]=r,f=0;if(a.some(t=>0!==e[t])){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(t&&t(r);f<a.length;f++)i=a[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function u(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof f?n:f,p=Object.create(u.prototype);return c(p,"_invoke",function(r,n,o){var i,u,c,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,u=0,c=e,s.n=r,a}};function d(r,n){for(u=r,c=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(u=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,u=0))}if(o||r>1)return a;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),u=p,c=b;(t=u<2?e:c)||!l;){i||(u?u<3?(u>1&&(s.n=-1),d(u,c)):s.n=c:s.v=c);try{if(f=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=e}else if((t=(l=s.n<0)?c:r.call(n,s))!==a)break}catch(t){i=e,u=1,c=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var a={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(c(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,c(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,c(d,"constructor",l),c(l,"constructor",p),p.displayName="GeneratorFunction",c(l,o,"GeneratorFunction"),c(d),c(d,o,"Generator"),c(d,n,function(){return this}),c(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:b}})()}function c(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,r,n){function i(t,r){c(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},c(e,t,r,n)}function f(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t;return l(l({noKeyItemText:"No features displayed"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"mapKey",load:(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(414).then(o.bind(o,935));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){f(i,n,o,a,u,"next",e)}function u(e){f(i,n,o,a,u,"throw",e)}a(void 0)})},function(){return t.apply(this,arguments)})})}return o.d(i,{default:()=>d}),i.default})());
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { addKeyItem } from './addKeyItem.js'
|
|
2
|
+
|
|
3
|
+
describe('addKeyItem', () => {
|
|
4
|
+
it('dispatches an ADD_KEY_ITEM action with the key definition', () => {
|
|
5
|
+
const dispatch = jest.fn()
|
|
6
|
+
|
|
7
|
+
addKeyItem({ pluginState: { dispatch } }, { id: 'map-key', groupLabel: 'Map key' })
|
|
8
|
+
|
|
9
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
10
|
+
type: 'ADD_KEY_ITEM',
|
|
11
|
+
payload: { id: 'map-key', groupLabel: 'Map key' }
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { api } from './index.js'
|
|
2
|
+
import { addKeyItem } from './addKeyItem.js'
|
|
3
|
+
import { removeKeyItem } from './removeKeyItem.js'
|
|
4
|
+
|
|
5
|
+
describe('api/index', () => {
|
|
6
|
+
it('exports the addKeyItem API', () => {
|
|
7
|
+
expect(api.addKeyItem).toBe(addKeyItem)
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('exports the removeKeyItem API', () => {
|
|
11
|
+
expect(api.removeKeyItem).toBe(removeKeyItem)
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { removeKeyItem } from './removeKeyItem.js'
|
|
2
|
+
|
|
3
|
+
describe('removeKeyItem', () => {
|
|
4
|
+
it('dispatches a REMOVE_KEY_ITEM action with the key definition', () => {
|
|
5
|
+
const dispatch = jest.fn()
|
|
6
|
+
|
|
7
|
+
removeKeyItem({ pluginState: { dispatch } }, { id: 'map-key' })
|
|
8
|
+
|
|
9
|
+
expect(dispatch).toHaveBeenCalledWith({
|
|
10
|
+
type: 'REMOVE_KEY_ITEM',
|
|
11
|
+
payload: { id: 'map-key' }
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
2
|
import { getDatasetRegistry } from '../../registry/index.js'
|
|
3
|
-
import { mergeKeyGroupItems } from '../../
|
|
3
|
+
import { mergeKeyGroupItems } from '../../reducers/mergeKeyGroupItems.js'
|
|
4
4
|
import { Key } from './Key.jsx'
|
|
5
5
|
|
|
6
6
|
export function MapKey ({
|
|
7
7
|
mapState: { mapStyle },
|
|
8
|
-
pluginConfig: { noKeyItemText
|
|
8
|
+
pluginConfig: { noKeyItemText },
|
|
9
|
+
pluginState,
|
|
9
10
|
services: { eventBus }
|
|
10
11
|
}) {
|
|
11
12
|
const [datasetRegistry, setDatasetRegistry] = useState(getDatasetRegistry())
|
|
@@ -18,7 +19,7 @@ export function MapKey ({
|
|
|
18
19
|
const getKeyItems = () => {
|
|
19
20
|
const { items, hasGroups: _hasGroups } = datasetRegistry.keyItems()
|
|
20
21
|
// Post Process the items - based on the map-key pluginConfig adding any groupConfigs
|
|
21
|
-
const groupItems = mergeKeyGroupItems(
|
|
22
|
+
const groupItems = mergeKeyGroupItems(items)
|
|
22
23
|
setKeyGroups(groupItems)
|
|
23
24
|
setHasGroups(_hasGroups)
|
|
24
25
|
}
|
|
@@ -44,6 +45,13 @@ export function MapKey ({
|
|
|
44
45
|
}
|
|
45
46
|
}, [datasetRegistry])
|
|
46
47
|
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!datasetRegistry) {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
getKeyItems()
|
|
53
|
+
}, [pluginState])
|
|
54
|
+
|
|
47
55
|
return (
|
|
48
56
|
<Key
|
|
49
57
|
noKeyItemText={noKeyItemText}
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
2
|
import { setDatasetRegistry } from '../registry/getDatasetRegistry.js'
|
|
3
|
+
import { attachPluginStateRef } from '../reducers/mergeKeyGroupItems.js'
|
|
3
4
|
|
|
4
|
-
// additional possible params here are: pluginConfig,
|
|
5
|
-
export function MapKeyInit ({ mapState, services }) {
|
|
5
|
+
// additional possible params here are: pluginConfig, appState, mapProvider,
|
|
6
|
+
export function MapKeyInit ({ pluginConfig, pluginState, mapState, services }) {
|
|
7
|
+
const { dispatch } = pluginState
|
|
6
8
|
const { eventBus } = services
|
|
9
|
+
const pluginStateRef = useRef(pluginState)
|
|
10
|
+
pluginStateRef.current = pluginState
|
|
7
11
|
|
|
8
12
|
useEffect(() => {
|
|
9
13
|
if (!mapState.isMapReady) {
|
|
10
14
|
return
|
|
11
15
|
}
|
|
16
|
+
attachPluginStateRef(pluginStateRef)
|
|
12
17
|
// Request a handle on the datasetsRegistry singleton
|
|
13
18
|
eventBus.requestOnce('datasets:registry', setDatasetRegistry)
|
|
14
19
|
}, [mapState.isMapReady])
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!pluginConfig.groups) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
const groups = Object.entries(pluginConfig.groups).map(([id, group]) => ({ ...group, id, label: group.groupLabel }))
|
|
26
|
+
|
|
27
|
+
dispatch({ type: 'ADD_KEY_GROUPS', payload: groups })
|
|
28
|
+
}, [pluginConfig.groups])
|
|
15
29
|
}
|
|
@@ -7,33 +7,69 @@ jest.mock('../registry/getDatasetRegistry.js', () => ({
|
|
|
7
7
|
}))
|
|
8
8
|
|
|
9
9
|
const eventBus = { requestOnce: jest.fn() }
|
|
10
|
-
const
|
|
10
|
+
const pluginState = { dispatch: jest.fn() }
|
|
11
|
+
const pluginConfig = {
|
|
12
|
+
groups: {
|
|
13
|
+
alpha: { groupLabel: 'Alpha' }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
11
16
|
|
|
12
17
|
beforeEach(() => {
|
|
13
18
|
jest.clearAllMocks()
|
|
14
19
|
})
|
|
15
20
|
|
|
16
21
|
describe('MapKeyInit', () => {
|
|
22
|
+
const renderInit = ({ isMapReady = false, config = {} } = {}) => render(
|
|
23
|
+
<MapKeyInit
|
|
24
|
+
pluginConfig={config}
|
|
25
|
+
pluginState={pluginState}
|
|
26
|
+
mapState={{ isMapReady }}
|
|
27
|
+
services={{ eventBus }}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
|
|
17
31
|
it('does not call requestOnce when map is not ready', () => {
|
|
18
|
-
|
|
32
|
+
renderInit({ isMapReady: false })
|
|
19
33
|
expect(eventBus.requestOnce).not.toHaveBeenCalled()
|
|
20
34
|
})
|
|
21
35
|
|
|
22
36
|
it('calls requestOnce for datasets:registry when map is ready', () => {
|
|
23
|
-
|
|
37
|
+
renderInit({ isMapReady: true })
|
|
24
38
|
expect(eventBus.requestOnce).toHaveBeenCalledWith('datasets:registry', setDatasetRegistry)
|
|
25
39
|
})
|
|
26
40
|
|
|
41
|
+
it('dispatches configured groups when pluginConfig.groups is provided', () => {
|
|
42
|
+
renderInit({ isMapReady: true, config: pluginConfig })
|
|
43
|
+
expect(pluginState.dispatch).toHaveBeenCalledWith({
|
|
44
|
+
type: 'ADD_KEY_GROUPS',
|
|
45
|
+
payload: [{ id: 'alpha', groupLabel: 'Alpha', label: 'Alpha' }]
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
27
49
|
it('calls requestOnce when isMapReady changes to true', () => {
|
|
28
|
-
const { rerender } =
|
|
50
|
+
const { rerender } = renderInit({ isMapReady: false })
|
|
29
51
|
expect(eventBus.requestOnce).not.toHaveBeenCalled()
|
|
30
|
-
rerender(
|
|
52
|
+
rerender(
|
|
53
|
+
<MapKeyInit
|
|
54
|
+
pluginConfig={{}}
|
|
55
|
+
pluginState={pluginState}
|
|
56
|
+
mapState={{ isMapReady: true }}
|
|
57
|
+
services={{ eventBus }}
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
31
60
|
expect(eventBus.requestOnce).toHaveBeenCalledTimes(1)
|
|
32
61
|
})
|
|
33
62
|
|
|
34
63
|
it('does not call requestOnce again on re-render when isMapReady stays true', () => {
|
|
35
|
-
const { rerender } =
|
|
36
|
-
rerender(
|
|
64
|
+
const { rerender } = renderInit({ isMapReady: true })
|
|
65
|
+
rerender(
|
|
66
|
+
<MapKeyInit
|
|
67
|
+
pluginConfig={{}}
|
|
68
|
+
pluginState={pluginState}
|
|
69
|
+
mapState={{ isMapReady: true }}
|
|
70
|
+
services={{ eventBus }}
|
|
71
|
+
/>
|
|
72
|
+
)
|
|
37
73
|
expect(eventBus.requestOnce).toHaveBeenCalledTimes(1)
|
|
38
74
|
})
|
|
39
75
|
})
|