@defra/interactive-map 0.0.42-fmp-5 → 0.0.43-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/css/index.css +1 -1
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/esm/im-shell.js +1 -1
  4. package/dist/umd/im-core.js +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/package.json +1 -1
  7. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  8. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  9. package/plugins/datasets/src/registry/dataset.js +8 -12
  10. package/plugins/datasets/src/registry/dataset.test.js +17 -0
  11. package/plugins/datasets/src/registry/datasetRegistry.js +4 -5
  12. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  13. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  14. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  15. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  16. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  17. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  18. package/plugins/draw/src/DrawInit.jsx +23 -13
  19. package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.js +15 -0
  20. package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.test.js +18 -0
  21. package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +9 -0
  22. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +12 -1
  23. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +18 -0
  24. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  25. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  26. package/plugins/interact/dist/umd/index.js +1 -1
  27. package/plugins/interact/src/hooks/useCrossHairVisibility.js +8 -3
  28. package/plugins/interact/src/hooks/useMapItemList.js +41 -12
  29. package/plugins/interact/src/hooks/useMapItemList.test.js +68 -3
  30. package/plugins/interact/src/utils/spatial.js +24 -1
  31. package/plugins/interact/src/utils/spatial.test.js +26 -1
  32. package/plugins/map-key/dist/css/index.css +1 -1
  33. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
  34. package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
  35. package/plugins/map-key/dist/umd/index.js +1 -1
  36. package/plugins/map-key/src/components/Key/Key.jsx +3 -4
  37. package/plugins/map-key/src/components/Key/Key.module.scss +10 -8
  38. package/plugins/map-key/src/components/Key/KeyGroupItem.test.jsx +2 -2
  39. package/plugins/map-key/src/components/Key/KeyItem.jsx +2 -2
  40. package/plugins/map-key/src/components/Key/KeySvg.jsx +9 -7
  41. package/plugins/map-key/src/components/Key/KeySvg.test.jsx +4 -4
  42. package/plugins/map-key/src/components/Key/MapKey.jsx +5 -3
  43. package/plugins/map-key/src/manifest.js +1 -1
  44. package/plugins/map-key/src/utils/groupStyles.js +7 -0
  45. package/plugins/map-key/src/utils/mergeKeyGroupItems.js +12 -0
  46. package/plugins/map-key/src/utils/mergeKeyGroupItems.test.js +53 -0
  47. package/plugins/menu/dist/esm/im-menu-plugin.js +1 -1
  48. package/plugins/menu/dist/umd/im-menu-plugin.js +1 -1
  49. package/plugins/menu/dist/umd/index.js +1 -1
  50. package/plugins/menu/src/initialise/MenuInit.jsx +15 -3
  51. package/plugins/menu/src/initialise/MenuInit.test.jsx +25 -0
  52. package/plugins/menu/src/initialise/createMenu.js +3 -1
  53. package/plugins/menu/src/initialise/createMenu.test.js +20 -5
  54. package/plugins/menu/src/initialise/updateUrl.js +44 -0
  55. package/plugins/menu/src/initialise/updateUrl.test.js +91 -0
  56. package/plugins/menu/src/reducers/menuStateReducer.js +19 -1
  57. package/plugins/menu/src/reducers/menuStateReducer.test.js +53 -20
  58. package/plugins/menu/src/reducers/pluginState.js +1 -6
  59. package/plugins/menu/src/reducers/pluginState.test.js +0 -25
  60. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
  61. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
  62. package/providers/beta/openlayers/src/openlayersProvider.js +3 -3
  63. package/providers/beta/openlayers/src/openlayersProvider.test.js +6 -3
  64. package/providers/beta/openlayers/src/utils/queryFeatures.js +72 -0
  65. package/providers/beta/openlayers/src/utils/queryFeatures.test.js +122 -1
  66. package/src/App/components/CrossHair/CrossHair.jsx +19 -11
  67. package/src/App/components/CrossHair/CrossHair.module.scss +33 -12
  68. package/src/App/components/CrossHair/CrossHair.test.jsx +35 -11
  69. package/src/App/components/Markers/SymbolMarker.jsx +2 -3
  70. package/src/App/components/Markers/SymbolMarker.test.jsx +8 -9
  71. package/src/App/components/Panel/Panel.jsx +9 -1
  72. package/src/App/components/Panel/Panel.test.jsx +26 -4
  73. package/src/App/components/Viewport/Features.jsx +18 -4
  74. package/src/App/components/Viewport/Features.module.scss +4 -4
  75. package/src/App/components/Viewport/Features.test.jsx +155 -11
  76. package/src/App/components/Viewport/Viewport.jsx +3 -3
  77. package/src/App/hooks/useCrossHairAPI.js +29 -1
  78. package/src/App/hooks/useCrossHairAPI.test.js +17 -1
  79. package/src/App/hooks/useFeatureFocus.js +86 -28
  80. package/src/App/hooks/useFeatureFocus.test.js +167 -0
  81. package/src/App/hooks/useFeatureItems.js +1 -1
  82. package/src/App/hooks/useInterfaceAPI.js +2 -1
  83. package/src/App/hooks/useInterfaceAPI.test.js +9 -0
  84. package/src/InteractiveMap/InteractiveMap.js +13 -2
  85. package/src/InteractiveMap/InteractiveMap.test.js +33 -0
  86. package/src/config/appConfig.js +2 -2
package/dist/umd/index.js CHANGED
@@ -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.InteractiveMap=t())}(this,()=>(()=>{"use strict";var e,t,n,r,o={698(e,t){var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(e,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var i in r={},t)"key"!==i&&(r[i]=t[i]);else r=t;return t=r.ref,{$$typeof:n,type:e,key:o,ref:void 0!==t?t:null,props:r}}t.Fragment=r,t.jsx=o,t.jsxs=o},869(e,t){var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),c=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),d=Symbol.for("react.activity"),h=Symbol.iterator,v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,m={};function b(e,t,n){this.props=e,this.context=t,this.refs=m,this.updater=n||v}function _(){}function g(e,t,n){this.props=e,this.context=t,this.refs=m,this.updater=n||v}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},_.prototype=b.prototype;var w=g.prototype=new _;w.constructor=g,y(w,b.prototype),w.isPureReactComponent=!0;var E=Array.isArray;function P(){}var A={H:null,A:null,T:null,S:null},S=Object.prototype.hasOwnProperty;function O(e,t,r){var o=r.ref;return{$$typeof:n,type:e,key:t,ref:void 0!==o?o:null,props:r}}function k(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var T=/\/+/g;function j(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,r={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return r[e]})):t.toString(36);var n,r}function x(e,t,o,i,a){var u=typeof e;"undefined"!==u&&"boolean"!==u||(e=null);var c,s,l=!1;if(null===e)l=!0;else switch(u){case"bigint":case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case n:case r:l=!0;break;case p:return x((l=e._init)(e._payload),t,o,i,a)}}if(l)return a=a(e),l=""===i?"."+j(e,0):i,E(a)?(o="",null!=l&&(o=l.replace(T,"$&/")+"/"),x(a,t,o,"",function(e){return e})):null!=a&&(k(a)&&(c=a,s=o+(null==a.key||e&&e.key===a.key?"":(""+a.key).replace(T,"$&/")+"/")+l,a=O(c.type,s,c.props)),t.push(a)),1;l=0;var f,d=""===i?".":i+":";if(E(e))for(var v=0;v<e.length;v++)l+=x(i=e[v],t,o,u=d+j(i,v),a);else if("function"==typeof(v=null===(f=e)||"object"!=typeof f?null:"function"==typeof(f=h&&f[h]||f["@@iterator"])?f:null))for(e=v.call(e),v=0;!(i=e.next()).done;)l+=x(i=i.value,t,o,u=d+j(i,v++),a);else if("object"===u){if("function"==typeof e.then)return x(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(P,P):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(e),t,o,i,a);throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return l}function C(e,t,n){if(null==e)return e;var r=[],o=0;return x(e,r,"","",function(e){return t.call(n,e,o++)}),r}function M(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var D="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},R={map:C,forEach:function(e,t,n){C(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return C(e,function(){t++}),t},toArray:function(e){return C(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};t.Activity=d,t.Children=R,t.Component=b,t.Fragment=o,t.Profiler=a,t.PureComponent=g,t.StrictMode=i,t.Suspense=l,t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,t.__COMPILER_RUNTIME={__proto__:null,c:function(e){return A.H.useMemoCache(e)}},t.cache=function(e){return function(){return e.apply(null,arguments)}},t.cacheSignal=function(){return null},t.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var r=y({},e.props),o=e.key;if(null!=t)for(i in void 0!==t.key&&(o=""+t.key),t)!S.call(t,i)||"key"===i||"__self"===i||"__source"===i||"ref"===i&&void 0===t.ref||(r[i]=t[i]);var i=arguments.length-2;if(1===i)r.children=n;else if(1<i){for(var a=Array(i),u=0;u<i;u++)a[u]=arguments[u+2];r.children=a}return O(e.type,o,r)},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:u,_context:e},e},t.createElement=function(e,t,n){var r,o={},i=null;if(null!=t)for(r in void 0!==t.key&&(i=""+t.key),t)S.call(t,r)&&"key"!==r&&"__self"!==r&&"__source"!==r&&(o[r]=t[r]);var a=arguments.length-2;if(1===a)o.children=n;else if(1<a){for(var u=Array(a),c=0;c<a;c++)u[c]=arguments[c+2];o.children=u}if(e&&e.defaultProps)for(r in a=e.defaultProps)void 0===o[r]&&(o[r]=a[r]);return O(e,i,o)},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:s,render:e}},t.isValidElement=k,t.lazy=function(e){return{$$typeof:p,_payload:{_status:-1,_result:e},_init:M}},t.memo=function(e,t){return{$$typeof:f,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=A.T,n={};A.T=n;try{var r=e(),o=A.S;null!==o&&o(n,r),"object"==typeof r&&null!==r&&"function"==typeof r.then&&r.then(P,D)}catch(e){D(e)}finally{null!==t&&null!==n.types&&(t.types=n.types),A.T=t}},t.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},t.use=function(e){return A.H.use(e)},t.useActionState=function(e,t,n){return A.H.useActionState(e,t,n)},t.useCallback=function(e,t){return A.H.useCallback(e,t)},t.useContext=function(e){return A.H.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e,t){return A.H.useDeferredValue(e,t)},t.useEffect=function(e,t){return A.H.useEffect(e,t)},t.useEffectEvent=function(e){return A.H.useEffectEvent(e)},t.useId=function(){return A.H.useId()},t.useImperativeHandle=function(e,t,n){return A.H.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return A.H.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return A.H.useLayoutEffect(e,t)},t.useMemo=function(e,t){return A.H.useMemo(e,t)},t.useOptimistic=function(e,t){return A.H.useOptimistic(e,t)},t.useReducer=function(e,t,n){return A.H.useReducer(e,t,n)},t.useRef=function(e){return A.H.useRef(e)},t.useState=function(e){return A.H.useState(e)},t.useSyncExternalStore=function(e,t,n){return A.H.useSyncExternalStore(e,t,n)},t.useTransition=function(){return A.H.useTransition()},t.version="19.2.4"},540(e,t,n){e.exports=n(869)},848(e,t,n){e.exports=n(698)},205(e,t,n){n.d(t,{N:()=>a,i:()=>u});var r=n(637),o=n(901),i=n(201);function a(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).isFullscreen,n=e.config,a=e.rootEl,u=n.pageTitle,c=n.behaviour,s=n.containerHeight,l=null!=t?t:function(e){var t=e.id,n=e.behaviour,o=e.manageHistoryState;return"mapOnly"===n||("buttonFirst"===n?!1===o||(0,r.q)(e.mapViewQueryParam)===t:(0,i.w)(e)&&(0,r.q)(e.mapViewQueryParam)===t)}(n);["mapOnly","buttonFirst","hybrid"].includes(c)&&((0,o.U)({containerEl:a,isFullscreen:l}),document.documentElement.classList.toggle("im-is-fullscreen",l),a.classList.toggle("im-is-fullscreen",l)),["buttonFirst","hybrid"].includes(c)&&function(e){var t=e.pageTitle,n=e.isFullscreen,r=document.title.split(": "),o=r[r.length-1];document.title=n?"".concat(t,": ").concat(o):o}({pageTitle:u,isFullscreen:l});var f=l||"buttonFirst"!==c&&!(0,i.w)(n)?s:"auto";return a.style.height=l?"100%":f,{isFullscreen:l}}function u(){document.body.classList.remove("im-is-loading")}},12(e,t,n){n.d(t,{q:()=>r});var r={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_FEATURES_SUPPRESSED:"map:setfeaturessuppressed",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"}},0(e,t,n){n.d(t,{v:()=>o});var r="[interactive-map]",o={warn:function(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=console).warn.apply(e,[r].concat(n))},error:function(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=console).error.apply(e,[r].concat(n))}}},233(e,t,n){function r(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function u(n,r,i,a){var u=r&&r.prototype instanceof s?r:s,l=Object.create(u.prototype);return o(l,"_invoke",function(n,r,o){var i,a,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return i=t,a=0,u=e,p.n=n,c}};function d(n,r){for(a=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],d=p.p,h=i[2];n>3?(o=h===r)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=n<2&&d<i[1])?(a=0,p.v=r,p.n=i[1]):d<h&&(o=n<3||i[0]>r||r>h)&&(i[4]=n,i[5]=r,p.n=h,a=0))}if(o||n>1)return c;throw f=!0,r}return function(o,l,h){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,h),a=l,u=h;(t=a<2?e:u)||!f;){i||(a?a<3?(a>1&&(p.n=-1),d(a,u)):p.n=u:p.v=u);try{if(s=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(f=p.n<0)?u:n.call(r,p))!==c)break}catch(t){i=e,a=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,i,a),!0),l}var c={};function s(){}function l(){}function f(){}t=Object.getPrototypeOf;var p=[][i]?t(t([][i]())):(o(t={},i,function(){return this}),t),d=f.prototype=s.prototype=Object.create(p);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,o(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=f,o(d,"constructor",f),o(f,"constructor",l),l.displayName="GeneratorFunction",o(f,a,"GeneratorFunction"),o(d),o(d,a,"Generator"),o(d,i,function(){return this}),o(d,"toString",function(){return"[object Generator]"}),(r=function(){return{w:u,m:h}})()}function o(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}o=function(e,t,n,r){function a(t,n){o(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},o(e,t,n,r)}function i(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}n.d(t,{H_:()=>u,Rt:()=>s,xK:()=>c});var a=null;function u(e,t){var n=e.url,o=e.transformRequest,u=e.load;a=function(){var e,a=(e=r().m(function e(i,a){var c;return r().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,u();case 1:return c=e.v,e.a(2,c(n,o,t,i,a))}},e)}),function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,c,"next",e)}function c(e){i(a,r,o,u,c,"throw",e)}u(void 0)})});return function(e,t){return a.apply(this,arguments)}}()}function c(){return null!==a}function s(e,t){if(!a)throw new Error("ReverseGeocode not initialised");return a(e,t)}},902(e,t,n){n.d(t,{C1:()=>u,Ey:()=>s,ip:()=>c});var r=window.matchMedia("(pointer: coarse)").matches?"touch":"unknown",o=new Set,i=new Set;function a(e){r!==e&&(r=e,i.forEach(function(t){return t(e)}),o.forEach(function(t){return t(e)}))}function u(){var e=window.matchMedia("(pointer: coarse)"),t=function(e){a(e.matches?"touch":"mouse")};e.addEventListener("change",t);var n=function(e){var t,n="pen"===(t=e.pointerType)||"touch"===t?"touch":"mouse"===t?"mouse":"unknown";n!==r&&(r=n,i.forEach(function(e){return e(n)}),setTimeout(function(){o.forEach(function(e){return e(n)})},150))},u=function(e){new Set(["Tab","Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape"]).has(e.key)&&a("keyboard")};return window.addEventListener("pointerdown",n,{passive:!0}),window.addEventListener("keydown",u,{passive:!0}),function(){e.removeEventListener("change",t),window.removeEventListener("pointerdown",n),window.removeEventListener("keydown",u)}}function c(){return"unknown"===r?(r="mouse","mouse"):r}function s(e){return o.add(e),function(){o.delete(e)}}},201(e,t,n){n.d(t,{g:()=>o,w:()=>r});var r=function(e){var t=e.behaviour,n=e.hybridWidth,r=e.maxMobileWidth;if("hybrid"!==t)return!1;var o=null!=n?n:r;return window.matchMedia("(max-width: ".concat(o,"px)")).matches},o=function(e){var t=e.behaviour;return["mapOnly","buttonFirst"].includes(t)||r(e)}},637(e,t,n){n.d(t,{q:()=>r});var r=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null===(t=window.location)||void 0===t?void 0:t.search;return new URLSearchParams(n).get(e)}},901(e,t,n){function r(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 a,u=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){c=!0,a=e},f:function(){try{u||null==n.return||n.return()}finally{if(c)throw a}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,{U:()=>a});var i=function(e,t,n,r){return e!==t&&!(null!=n&&n.contains(e))&&e.matches(":not([aria-hidden]):not([data-fm-inert])")&&r.contains(e)};function a(e){var t,n=e.containerEl,o=e.isFullscreen,a=e.boundaryEl,u=void 0===a?document.body:a,c=Array.from(u.querySelectorAll("[data-fm-inert]"));if(n&&(c=c.filter(function(e){return!n.contains(e)})),c.forEach(function(e){e.removeAttribute("aria-hidden"),delete e.dataset.fmInert}),o){null===(t=document.activeElement)||void 0===t||t.blur();for(var s=n;null!==(l=s)&&void 0!==l&&l.parentNode&&s!==u&&s!==document.body;){var l,f,p=s.parentNode,d=r(p.children);try{for(d.s();!(f=d.n()).done;){var h=f.value;i(h,s,n,u)&&(h.setAttribute("aria-hidden","true"),h.dataset.fmInert="")}}catch(e){d.e(e)}finally{d.f()}s=p}}}}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return o[e](n,n.exports,a),n.exports}a.m=o,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var o=Object.create(null);a.r(o);var i={};e=e||[null,t({}),t([]),t(t)];for(var u=2&r&&n;("object"==typeof u||"function"==typeof u)&&!~e.indexOf(u);u=t(u))Object.getOwnPropertyNames(u).forEach(e=>i[e]=()=>n[e]);return i.default=()=>n,a.d(o,i),o},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,n)=>(a.f[n](e,t),t),[])),a.u=e=>"im-core.js",a.miniCssF=e=>{},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},r="defra.InteractiveMap:",a.l=(e,t,o,i)=>{if(n[e])n[e].push(t);else{var u,c;if(void 0!==o)for(var s=document.getElementsByTagName("script"),l=0;l<s.length;l++){var f=s[l];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==r+o){u=f;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",a.nc&&u.setAttribute("nonce",a.nc),u.setAttribute("data-webpack",r+o),u.src=e),n[e]=[t];var p=(t,r)=>{u.onerror=u.onload=null,clearTimeout(d);var o=n[e];if(delete n[e],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=p.bind(null,u.onerror),u.onload=p.bind(null,u.onload),c&&document.head.appendChild(u)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var r=n.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=n[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={57:0};a.f.j=(t,n)=>{var r=a.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else{var o=new Promise((n,o)=>r=e[t]=[n,o]);n.push(r[2]=o);var i=a.p+a.u(t),u=new Error;a.l(i,n=>{if(a.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var o=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;u.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",u.name="ChunkLoadError",u.type=o,u.request=i,r[1](u)}},"chunk-"+t,t)}};var t=(t,n)=>{var r,o,[i,u,c]=n,s=0;if(i.some(t=>0!==e[t])){for(r in u)a.o(u,r)&&(a.m[r]=u[r]);c&&c(a)}for(t&&t(n);s<i.length;s++)o=i[s],a.o(e,o)&&e[o]&&e[o][0](),e[o]=0},n=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var u={};a.d(u,{default:()=>ie});var c=a(540),s=a(848),l=a.t(s,2),f=a(637),p=a(201);function d(){h.forEach(function(e){!function(e,t){var n;if(!1!==e.config.manageHistoryState){e._isClosingViaBack=!1;var r=e.id===t,o="hybrid"===e.config.behaviour&&!(0,p.w)(e.config),i=null===(n=e.rootEl)||void 0===n?void 0:n.children.length;!r||i&&!e._isHidden?r||!i||o||function(e){var t,n;e.config.preserveStateOnClose?null===(t=e.hideApp)||void 0===t||t.call(e):null===(n=e.removeApp)||void 0===n||n.call(e)}(e):function(e){var t,n;e._isHidden?null===(t=e.showApp)||void 0===t||t.call(e):null===(n=e.loadApp)||void 0===n||n.call(e)}(e)}}(e,(0,f.q)(e.config.mapViewQueryParam))})}var h=new Map,v=!1;const y=function(e){v||(globalThis.addEventListener("popstate",d),v=!0),h.set(e.id,e)},m=function(e){h.delete(e.id),0===h.size&&(globalThis.removeEventListener("popstate",d),v=!1)};function b(e){return b="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},b(e)}function _(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function g(e,t,n){return(t=function(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){try{return JSON.parse(e)}catch(e){return console.log(e),null}}function E(e,t){e.innerHTML='<div class="im-c-error">'.concat(t,"</div>")}var P=a(205),A=a(0),S=a(12);function O(e){var t=e.id,n=e.behaviour,r=(0,f.q)(e.mapViewQueryParam)===t;return["mapOnly","inline"].includes(n)||"hybrid"===n&&!(0,p.w)(e)||r}const k={appColorScheme:"light",autoColorScheme:!1,backgroundColor:"var(--background-color)",behaviour:"buttonFirst",buttonClass:"im-c-open-map-button",buttonText:"Map view",containerHeight:"600px",deviceNotSupportedText:"Your device is not supported. A map is available with a more up-to-date browser or device.",enableFullscreen:!1,enableMoveControls:!0,enableZoomControls:!0,genericErrorText:"There was a problem loading the map. Please try again later.",hasExitButton:!1,backAndContinue:null,hybridWidth:null,keyboardHintText:'<span class="im-u-visually-hidden">Press </span><kbd>Shift</kbd> + <span class="im-u-visually-hidden">Question mark</span><kbd aria-hidden="true">?</kbd> <span class="im-u-visually-hidden">to view </span>keyboard shortcuts',mapHintText:"Press Tab to focus it. Keyboard commands are only available once it has focus.",mapLabel:"Interactive map application",mapProvider:null,mapSize:"small",manageHistoryState:!0,mapViewQueryParam:"mv",urlPosition:"sync",maxMobileWidth:640,minDesktopWidth:835,moveControlsHintText:'A "Move and zoom controls" button is also available, opening further controls for moving and zooming.',nudgePanDelta:5,nudgeZoomDelta:.1,panDelta:100,pageTitle:"Map view",preserveStateOnClose:!1,readMapText:!1,reverseGeocodeProvider:null,zoomDelta:1};function T(e){return T="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},T(e)}var j=["mapViewParamKey"];function x(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?x(Object(n),!0).forEach(function(t){M(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function M(e,t,n){return(t=function(e){var t=function(e){if("object"!=T(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==T(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var D=a(902),R=a(233);function B(e){return B="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},B(e)}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,N(r.key),r)}}function N(e){var t=function(e){if("object"!=B(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=B(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==B(t)?t:t+""}var I=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events={},this._queued={}},t=[{key:"on",value:function(e,t){if(this.events[e]||(this.events[e]=[]),this.events[e].push(t),void 0!==this._queued[e]){try{t.apply(void 0,function(e){return function(e){if(Array.isArray(e))return L(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return L(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?L(e,t):void 0}}(e)||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.")}()}(this._queued[e]))}catch(t){console.error("Error in event handler for '".concat(e,"':"),t)}delete this._queued[e]}return this}},{key:"once",value:function(e,t){var n=this,r=function(){n.off(e,r),t.apply(void 0,arguments)};return this.on(e,r)}},{key:"off",value:function(e,t){return this.events[e]?(this.events[e]=t?this.events[e].filter(function(e){return e!==t}):[],this):this}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return this.events[e]?(this.events[e].forEach(function(t){try{t.apply(void 0,n)}catch(t){console.error("Error in event handler for '".concat(e,"':"),t)}}),this):this}},{key:"emitWhenReady",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return this.events[e]&&0!==this.events[e].length?this.emit.apply(this,[e].concat(n)):(this._queued[e]=n,this)}},{key:"emitWhenRequested",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i="".concat(e,"Requested"),a="".concat(e,"Ready"),u=function(){return t.emit.apply(t,[a].concat(r))};return this.on(i,u),u(),function(){return t.off(i,u)}}},{key:"requestOnce",value:function(e,t){var n="".concat(e,"Requested"),r="".concat(e,"Ready");return this.once(r,t),this.emit(n,e),this}},{key:"destroy",value:function(){this.events={},this._queued={}}}],t&&H(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();new I;var F=a(901);if("undefined"!=typeof crypto&&!crypto.randomUUID){var q=0;crypto.randomUUID=function(){return q=Math.max(Date.now(),q+1),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e,t){var n=t<12?Number.parseInt(q.toString(16).padStart(12,"0")[t],16):16*Math.random()|0;return("x"===e?n:3&n|8).toString(16)})}}var U=!Object.hasOwn;U&&(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)});var V="undefined"!=typeof AbortController&&!Object.getPrototypeOf((new AbortController).signal).throwIfAborted;if(V&&(Object.getPrototypeOf((new AbortController).signal).throwIfAborted=function(){if(this.aborted){var e=new Error("The operation was aborted.");throw e.name="AbortError",e}}),(V||U)&&"undefined"!=typeof URL&&URL.createObjectURL){var W="text/javascript",$=["if(!Object.hasOwn){Object.hasOwn=function(o,k){return Object.prototype.hasOwnProperty.call(o,k)}}\n",V?'if(typeof AbortController!=="undefined"){var _p=Object.getPrototypeOf(new AbortController().signal);if(!_p.throwIfAborted){_p.throwIfAborted=function(){if(this.aborted){var e=new Error("The operation was aborted.");e.name="AbortError";throw e}}}}\n':""].join(""),G=URL.createObjectURL.bind(URL);if(URL.createObjectURL=function(e){return e instanceof Blob&&e.type===W&&(e=new Blob([$,e],{type:W})),G(e)},"undefined"!=typeof Worker){var z=Worker;Worker=function(e,t){if("string"==typeof e&&!e.startsWith("blob:")){var n=new Blob(["".concat($,"importScripts(").concat(JSON.stringify(e),")")],{type:W});e=G(n)}return new z(e,t)},Worker.prototype=z.prototype}}function K(e){return K="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},K(e)}function Q(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return Y(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return i=t,u=0,c=e,p.n=n,a}};function d(n,r){for(u=n,c=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],d=p.p,h=i[2];n>3?(o=h===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=n<2&&d<i[1])?(u=0,p.v=r,p.n=i[1]):d<h&&(o=n<3||i[0]>r||r>h)&&(i[4]=n,i[5]=r,p.n=h,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,h){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,h),u=l,c=h;(t=u<2?e:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),d(u,c)):p.n=c:p.v=c);try{if(s=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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(t){i=e,u=1,c=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Y(t={},r,function(){return this}),t),f=s.prototype=u.prototype=Object.create(l);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,Y(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=s,Y(f,"constructor",s),Y(s,"constructor",c),c.displayName="GeneratorFunction",Y(s,o,"GeneratorFunction"),Y(f),Y(f,o,"Generator"),Y(f,r,function(){return this}),Y(f,"toString",function(){return"[object Generator]"}),(Q=function(){return{w:i,m:p}})()}function Y(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}Y=function(e,t,n,r){function i(t,n){Y(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},Y(e,t,n,r)}function Z(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function J(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J(Object(n),!0).forEach(function(t){te(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ee(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ne(r.key),r)}}function te(e,t,n){return(t=ne(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ne(e){var t=function(e){if("object"!=K(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=K(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==K(t)?t:t+""}var re=function(){return e=function e(t){var n,r,o,i,a,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),te(this,"_openButton",null),te(this,"_root",null),te(this,"_breakpointDetector",null),te(this,"_interfaceDetectorCleanup",null),te(this,"_hybridBehaviourCleanup",null),te(this,"_isHidden",!1),te(this,"_isClosingViaBack",!1),te(this,"_isLoading",!1),this.id=t,this.rootEl=document.getElementById(t),!this.rootEl)throw new Error('Element with id "'.concat(t,'" not found'));this.eventBus=new I,this.config=this._buildConfig(u),n=this.rootEl,o=(r=this.config).mapProvider,i=r.deviceNotSupportedText,a=null==o?void 0:o.checkDeviceCapabilities(),(o?null!=a&&a.isSupported||(E(n,i),(0,P.i)(),A.v.warn(null==a?void 0:a.error),0):(A.v.warn("No map provider"),0))&&(["buttonFirst","hybrid"].includes(this.config.behaviour)&&y(this),this._breakpointDetector=function(e){var t,n=e.maxMobileWidth,r=e.minDesktopWidth,o=e.containerEl,i="unknown",a=new Set,u=function(e){e!==i&&(i=e,requestAnimationFrame(function(){i===e&&a.forEach(function(t){return t(e)})}))};if(o){var c=function(e,t,n){e.style.containerType="inline-size";var r=e.getBoundingClientRect().width,o=t(r);e.dataset.breakpoint=o;var i=new window.ResizeObserver(function(r){var o,i,a=(null===(o=r[0])||void 0===o||null===(o=o.borderBoxSize)||void 0===o||null===(o=o[0])||void 0===o?void 0:o.inlineSize)||(null===(i=r[0])||void 0===i?void 0:i.contentRect.width),u=t(a);e.dataset.breakpoint=u,n(u)});return i.observe(e),{initialType:o,cleanup:function(){i.disconnect(),e.style.containerType="",delete e.dataset.breakpoint}}}(o,function(e){return function(e,t,n){return e<=t?"mobile":e>=n?"desktop":"tablet"}(e,n,r)},u);i=c.initialType,u(c.initialType),t=c.cleanup}else{var s=function(e,t,n){var r={mobile:window.matchMedia("(max-width: ".concat(e,"px)")),desktop:window.matchMedia("(min-width: ".concat(t,"px)"))},o=function(){var e="tablet";r.mobile.matches?e="mobile":r.desktop.matches&&(e="desktop"),n(e)};return r.mobile.addEventListener("change",o),r.desktop.addEventListener("change",o),o(),{cleanup:function(){r.mobile.removeEventListener("change",o),r.desktop.removeEventListener("change",o)}}}(n,r,u);t=s.cleanup}return{subscribe:function(e){return a.add(e),function(){return a.delete(e)}},getBreakpoint:function(){return i},destroy:function(){var e;null===(e=t)||void 0===e||e(),a.clear()}}}({maxMobileWidth:this.config.maxMobileWidth,minDesktopWidth:this.config.minDesktopWidth,containerEl:this.rootEl}),this._interfaceDetectorCleanup=(0,D.C1)(),this._initialize())},t=[{key:"_buildConfig",value:function(e){var t=function(e){for(var t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_(Object(n),!0).forEach(function(t){g(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},null==e?void 0:e.dataset),n={},r=0,o=Object.keys(t);r<o.length;r++){var i=o[r];n[i]=w(t[i])}return n}(this.rootEl);return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.mapViewParamKey,n=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,j),r=C(C({},k),n);return void 0!==t&&(console.warn("[InteractiveMap] mapViewParamKey is deprecated — use mapViewQueryParam instead."),r.mapViewQueryParam=t),"mapOnly"===r.behaviour&&r.hasExitButton&&(console.warn("[InteractiveMap] hasExitButton has no effect when behaviour is 'mapOnly' — there is nothing to exit to."),r.hasExitButton=!1),r}(X(X({id:this.id,title:document.title},t),e))}},{key:"_initialize",value:function(){var e=this;["buttonFirst","hybrid"].includes(this.config.behaviour)&&(this._openButton=function(t,n){var r=t.id,o=t.buttonText,i=t.buttonClass,a='\n <a class="'.concat(i,"\" role=\"button\">\n <svg focusable='false' aria-hidden='true' width='16' height='20' viewBox='0 0 16 20' fillRule='evenodd'>\n <path d='M15 7.5c.009 3.778-4.229 9.665-7.5 12.5C4.229 17.165-.009 11.278 0 7.5a7.5 7.5 0 1 1 15 0z'/>\n <path d='M7.5 12.961a5.46 5.46 0 1 0 0-10.922 5.46 5.46 0 1 0 0 10.922z' fill='#fff'/>\n </svg>\n <span>").concat(o,"</span>\n <span class='im-u-visually-hidden'> (Visual only)</span>\n </a>\n ");n.insertAdjacentHTML("beforebegin",a);var u=n.previousElementSibling,c=new URL(window.location.href);return c.searchParams.set(t.mapViewQueryParam,r),u.setAttribute("href",c.toString()),u.addEventListener("click",function(t){t.preventDefault(),function(t){e._handleButtonClick(t)}(t)}),u}(this.config,this.rootEl)),this._hybridBehaviourCleanup=function(e){var t=e.config,n=t.behaviour,r=t.hybridWidth,o=t.maxMobileWidth;if("buttonFirst"===n&&e._breakpointDetector.subscribe(function(){O(e.config)?e.loadApp():e.removeApp()}),"hybrid"===n){var i=null!=r?r:o,a=window.matchMedia("(max-width: ".concat(i,"px)")),u=function(){if(O(e.config))if(e._isHidden)e.showApp();else if(null==e._root)e.loadApp();else{var t=(0,P.N)(e).isFullscreen;e.eventBus.emit(S.q.APP_FULLSCREEN_CHANGE,{isFullscreen:t})}else e._root&&e.hideApp()};return a.addEventListener("change",u),function(){return a.removeEventListener("change",u)}}return null}(this),O(this.config)?this.loadApp():(0,P.i)()}},{key:"_handleButtonClick",value:function(e){var t;this._isHidden?(this.config.manageHistoryState&&history.pushState({isBack:!0},"",e.currentTarget.getAttribute("href")),this.showApp(),null===(t=this.rootEl.querySelector('[role="application"]'))||void 0===t||t.focus()):this._root||(this.config.manageHistoryState&&history.pushState({isBack:!0},"",e.currentTarget.getAttribute("href")),this.loadApp({focusOnMount:!0}))}},{key:"_removeMapParamFromUrl",value:function(e,t){var n=new RegExp("[?&]".concat(t,"=[^&]*(&|$)"));return n.test(e)?e.replace(n,function(e,t){return"&"===t?"?":""}).replace(/\?$/,""):e}},{key:"_handleExitClick",value:function(){var e,t=this;if(this.config.manageHistoryState)if(null!==(e=history.state)&&void 0!==e&&e.isBack){if(this._isClosingViaBack)return;this._isClosingViaBack=!0,history.back(),setTimeout(function(){t._isClosingViaBack=!1},1e3)}else{this.config.preserveStateOnClose?this.hideApp():this.removeApp();var n=this.config.mapViewQueryParam,r=this._removeMapParamFromUrl(location.href,n);history.replaceState(history.state,"",r)}else this.config.preserveStateOnClose?this.hideApp():this.removeApp()}},{key:"loadApp",value:(n=Q().m(function e(){var t,n,r,o,i,u,c,s,l,f,p,d,h,v,y=this,m=arguments;return Q().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=(m.length>0&&void 0!==m[0]?m[0]:{}).focusOnMount,n=void 0!==t&&t,!this._root&&!this._isLoading){e.n=1;break}return e.a(2);case 1:return this._isLoading=!0,this._openButton&&(this._openButton.style.display="none"),e.p=2,e.n=3,a.e(935).then(a.bind(a,310));case 3:return r=e.v,o=r.initialiseApp,e.n=4,this.config.mapProvider.load();case 4:return i=e.v,u=i.MapProvider,c=i.mapFramework,s=i.mapProviderConfig,this.config.reverseGeocodeProvider&&(0,R.H_)(this.config.reverseGeocodeProvider,s.crs),e.n=5,o(this.rootEl,X(X({id:this.id,initialBreakpoint:this._breakpointDetector.getBreakpoint(),initialInterfaceType:(0,D.ip)(),focusOnMount:n},this.config),{},{MapProvider:u,mapProviderConfig:s,mapFramework:c,eventBus:this.eventBus,breakpointDetector:this._breakpointDetector,handleExitClick:this._handleExitClick.bind(this)}));case 5:l=e.v,this._root=l._root,delete l._root,f=new Set(["on","off","emit"]),Object.keys(l).forEach(function(e){f.has(e)||(y[e]=l[e])}),p=(0,P.N)(this),d=p.isFullscreen,this.eventBus.emit(S.q.APP_OPENED,{statePreserved:!1,isFullscreen:d}),e.n=7;break;case 6:throw e.p=6,v=e.v,null===(h=this._openButton)||void 0===h||h.removeAttribute("style"),E(this.rootEl,this.config.genericErrorText),console.error(v),v;case 7:return e.p=7,this._isLoading=!1,e.f(7);case 8:return e.a(2)}},e,this,[[2,6,7,8]])}),r=function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){Z(i,r,o,a,u,"next",e)}function u(e){Z(i,r,o,a,u,"throw",e)}a(void 0)})},function(){return r.apply(this,arguments)})},{key:"removeApp",value:function(){this._root&&"function"==typeof this.unmount&&(this.unmount(),this._root=null),this._openButton&&(this._openButton.removeAttribute("style"),this._openButton.focus()),(0,P.N)(this,{isFullscreen:!1}),this.eventBus.emit(S.q.APP_CLOSED,{statePreserved:!1}),this.eventBus.emit(S.q.MAP_DESTROY,{mapId:this.id})}},{key:"hideApp",value:function(){this._isHidden=!0,this.rootEl.style.display="none",(0,F.U)({containerEl:this.rootEl,isFullscreen:!1}),this._openButton&&(this._openButton.removeAttribute("style"),this._openButton.focus()),document.documentElement.classList.remove("im-is-fullscreen"),this.rootEl.classList.remove("im-is-fullscreen");var e=document.title.split(": ");e.length>1&&(document.title=e.at(-1)),this.eventBus.emit(S.q.APP_CLOSED,{statePreserved:!0})}},{key:"showApp",value:function(){this._isHidden=!1,this.rootEl.style.display="",this._openButton&&(this._openButton.style.display="none");var e=(0,P.N)(this).isFullscreen;this.eventBus.emit(S.q.APP_OPENED,{statePreserved:!0,isFullscreen:e})}},{key:"destroy",value:function(){var e,t,n;this.removeApp(),null===(e=this._breakpointDetector)||void 0===e||e.destroy(),null===(t=this._interfaceDetectorCleanup)||void 0===t||t.call(this),null===(n=this._hybridBehaviourCleanup)||void 0===n||n.call(this),m(this),this.eventBus.destroy()}},{key:"on",value:function(){var e;(e=this.eventBus).on.apply(e,arguments)}},{key:"off",value:function(){var e;(e=this.eventBus).off.apply(e,arguments)}},{key:"emit",value:function(){var e;(e=this.eventBus).emit.apply(e,arguments)}},{key:"addMarker",value:function(e,t,n){this.eventBus.emit(S.q.APP_ADD_MARKER,{id:e,coords:t,options:n})}},{key:"updateMarker",value:function(e,t){this.eventBus.emit(S.q.APP_UPDATE_MARKER,{id:e,options:t})}},{key:"removeMarker",value:function(e){this.eventBus.emit(S.q.APP_REMOVE_MARKER,e)}},{key:"setMode",value:function(e){this.eventBus.emit(S.q.APP_SET_MODE,e)}},{key:"addButton",value:function(e,t){this.eventBus.emit(S.q.APP_ADD_BUTTON,{id:e,config:t})}},{key:"toggleButtonState",value:function(e,t,n){this.eventBus.emit(S.q.APP_TOGGLE_BUTTON_STATE,{id:e,prop:t,value:n})}},{key:"setContinueEnabled",value:function(e){this.toggleButtonState("journeyContinue","disabled",!e)}},{key:"addPanel",value:function(e,t){this.eventBus.emit(S.q.APP_ADD_PANEL,{id:e,config:t})}},{key:"removePanel",value:function(e){this.eventBus.emit(S.q.APP_REMOVE_PANEL,e)}},{key:"showPanel",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).focus,n=void 0===t||t;this.eventBus.emit(S.q.APP_SHOW_PANEL,{id:e,focus:n})}},{key:"hidePanel",value:function(e){this.eventBus.emit(S.q.APP_HIDE_PANEL,e)}},{key:"addControl",value:function(e,t){this.eventBus.emit(S.q.APP_ADD_CONTROL,{id:e,config:t})}},{key:"showHint",value:function(e,t){this.eventBus.emit(S.q.APP_SHOW_HINT,{text:e,options:t})}},{key:"dismissHint",value:function(){this.eventBus.emit(S.q.APP_DISMISS_HINT)}},{key:"fitToBounds",value:function(e){this.eventBus.emitWhenReady(S.q.MAP_FIT_TO_BOUNDS,e)}},{key:"setView",value:function(e){this.eventBus.emitWhenReady(S.q.MAP_SET_VIEW,e)}},{key:"open",value:function(){this._isHidden?this.showApp():this._root||this.loadApp()}},{key:"close",value:function(){this._handleExitClick()}}],t&&ee(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,r}(),oe="undefined"==typeof window?globalThis:window;oe.defra=oe.defra||{},oe.preactCompat=c,oe.preactJsxRuntime=l,oe.preactHooks={useState:c.useState},oe.defra.InteractiveMap=re,oe.preactCompat.default||(oe.preactCompat.default=oe.preactCompat),oe.preactCompat.createRoot||(oe.preactCompat.createRoot=function(e){return{render:function(t){oe.preactCompat.render(t,e)},unmount:function(){oe.preactCompat.render(null,e)}}});const ie=re;return u.default})());
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.InteractiveMap=t())}(this,()=>(()=>{"use strict";var e,t,n,r,o={698(e,t){var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(e,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var i in r={},t)"key"!==i&&(r[i]=t[i]);else r=t;return t=r.ref,{$$typeof:n,type:e,key:o,ref:void 0!==t?t:null,props:r}}t.Fragment=r,t.jsx=o,t.jsxs=o},869(e,t){var n=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),c=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),d=Symbol.for("react.activity"),h=Symbol.iterator,v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,m={};function b(e,t,n){this.props=e,this.context=t,this.refs=m,this.updater=n||v}function g(){}function _(e,t,n){this.props=e,this.context=t,this.refs=m,this.updater=n||v}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},g.prototype=b.prototype;var w=_.prototype=new g;w.constructor=_,y(w,b.prototype),w.isPureReactComponent=!0;var E=Array.isArray;function P(){}var A={H:null,A:null,T:null,S:null},S=Object.prototype.hasOwnProperty;function O(e,t,r){var o=r.ref;return{$$typeof:n,type:e,key:t,ref:void 0!==o?o:null,props:r}}function k(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var T=/\/+/g;function j(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,r={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return r[e]})):t.toString(36);var n,r}function x(e,t,o,i,a){var u=typeof e;"undefined"!==u&&"boolean"!==u||(e=null);var c,s,l=!1;if(null===e)l=!0;else switch(u){case"bigint":case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case n:case r:l=!0;break;case p:return x((l=e._init)(e._payload),t,o,i,a)}}if(l)return a=a(e),l=""===i?"."+j(e,0):i,E(a)?(o="",null!=l&&(o=l.replace(T,"$&/")+"/"),x(a,t,o,"",function(e){return e})):null!=a&&(k(a)&&(c=a,s=o+(null==a.key||e&&e.key===a.key?"":(""+a.key).replace(T,"$&/")+"/")+l,a=O(c.type,s,c.props)),t.push(a)),1;l=0;var f,d=""===i?".":i+":";if(E(e))for(var v=0;v<e.length;v++)l+=x(i=e[v],t,o,u=d+j(i,v),a);else if("function"==typeof(v=null===(f=e)||"object"!=typeof f?null:"function"==typeof(f=h&&f[h]||f["@@iterator"])?f:null))for(e=v.call(e),v=0;!(i=e.next()).done;)l+=x(i=i.value,t,o,u=d+j(i,v++),a);else if("object"===u){if("function"==typeof e.then)return x(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(P,P):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(e),t,o,i,a);throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return l}function C(e,t,n){if(null==e)return e;var r=[],o=0;return x(e,r,"","",function(e){return t.call(n,e,o++)}),r}function M(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var D="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},R={map:C,forEach:function(e,t,n){C(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return C(e,function(){t++}),t},toArray:function(e){return C(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};t.Activity=d,t.Children=R,t.Component=b,t.Fragment=o,t.Profiler=a,t.PureComponent=_,t.StrictMode=i,t.Suspense=l,t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,t.__COMPILER_RUNTIME={__proto__:null,c:function(e){return A.H.useMemoCache(e)}},t.cache=function(e){return function(){return e.apply(null,arguments)}},t.cacheSignal=function(){return null},t.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var r=y({},e.props),o=e.key;if(null!=t)for(i in void 0!==t.key&&(o=""+t.key),t)!S.call(t,i)||"key"===i||"__self"===i||"__source"===i||"ref"===i&&void 0===t.ref||(r[i]=t[i]);var i=arguments.length-2;if(1===i)r.children=n;else if(1<i){for(var a=Array(i),u=0;u<i;u++)a[u]=arguments[u+2];r.children=a}return O(e.type,o,r)},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:u,_context:e},e},t.createElement=function(e,t,n){var r,o={},i=null;if(null!=t)for(r in void 0!==t.key&&(i=""+t.key),t)S.call(t,r)&&"key"!==r&&"__self"!==r&&"__source"!==r&&(o[r]=t[r]);var a=arguments.length-2;if(1===a)o.children=n;else if(1<a){for(var u=Array(a),c=0;c<a;c++)u[c]=arguments[c+2];o.children=u}if(e&&e.defaultProps)for(r in a=e.defaultProps)void 0===o[r]&&(o[r]=a[r]);return O(e,i,o)},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:s,render:e}},t.isValidElement=k,t.lazy=function(e){return{$$typeof:p,_payload:{_status:-1,_result:e},_init:M}},t.memo=function(e,t){return{$$typeof:f,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=A.T,n={};A.T=n;try{var r=e(),o=A.S;null!==o&&o(n,r),"object"==typeof r&&null!==r&&"function"==typeof r.then&&r.then(P,D)}catch(e){D(e)}finally{null!==t&&null!==n.types&&(t.types=n.types),A.T=t}},t.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},t.use=function(e){return A.H.use(e)},t.useActionState=function(e,t,n){return A.H.useActionState(e,t,n)},t.useCallback=function(e,t){return A.H.useCallback(e,t)},t.useContext=function(e){return A.H.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e,t){return A.H.useDeferredValue(e,t)},t.useEffect=function(e,t){return A.H.useEffect(e,t)},t.useEffectEvent=function(e){return A.H.useEffectEvent(e)},t.useId=function(){return A.H.useId()},t.useImperativeHandle=function(e,t,n){return A.H.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return A.H.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return A.H.useLayoutEffect(e,t)},t.useMemo=function(e,t){return A.H.useMemo(e,t)},t.useOptimistic=function(e,t){return A.H.useOptimistic(e,t)},t.useReducer=function(e,t,n){return A.H.useReducer(e,t,n)},t.useRef=function(e){return A.H.useRef(e)},t.useState=function(e){return A.H.useState(e)},t.useSyncExternalStore=function(e,t,n){return A.H.useSyncExternalStore(e,t,n)},t.useTransition=function(){return A.H.useTransition()},t.version="19.2.4"},540(e,t,n){e.exports=n(869)},848(e,t,n){e.exports=n(698)},205(e,t,n){n.d(t,{N:()=>a,i:()=>u});var r=n(637),o=n(901),i=n(201);function a(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).isFullscreen,n=e.config,a=e.rootEl,u=n.pageTitle,c=n.behaviour,s=n.containerHeight,l=null!=t?t:function(e){var t=e.id,n=e.behaviour,o=e.manageHistoryState;return"mapOnly"===n||("buttonFirst"===n?!1===o||(0,r.q)(e.mapViewQueryParam)===t:(0,i.w)(e)&&(0,r.q)(e.mapViewQueryParam)===t)}(n);["mapOnly","buttonFirst","hybrid"].includes(c)&&((0,o.U)({containerEl:a,isFullscreen:l}),document.documentElement.classList.toggle("im-is-fullscreen",l),a.classList.toggle("im-is-fullscreen",l)),["buttonFirst","hybrid"].includes(c)&&function(e){var t=e.pageTitle,n=e.isFullscreen,r=document.title.split(": "),o=r[r.length-1];document.title=n?"".concat(t,": ").concat(o):o}({pageTitle:u,isFullscreen:l});var f=l||"buttonFirst"!==c&&!(0,i.w)(n)?s:"auto";return a.style.height=l?"100%":f,{isFullscreen:l}}function u(){document.body.classList.remove("im-is-loading")}},12(e,t,n){n.d(t,{q:()=>r});var r={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_FEATURES_SUPPRESSED:"map:setfeaturessuppressed",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"}},0(e,t,n){n.d(t,{v:()=>o});var r="[interactive-map]",o={warn:function(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=console).warn.apply(e,[r].concat(n))},error:function(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=console).error.apply(e,[r].concat(n))}}},233(e,t,n){function r(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function u(n,r,i,a){var u=r&&r.prototype instanceof s?r:s,l=Object.create(u.prototype);return o(l,"_invoke",function(n,r,o){var i,a,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return i=t,a=0,u=e,p.n=n,c}};function d(n,r){for(a=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],d=p.p,h=i[2];n>3?(o=h===r)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=n<2&&d<i[1])?(a=0,p.v=r,p.n=i[1]):d<h&&(o=n<3||i[0]>r||r>h)&&(i[4]=n,i[5]=r,p.n=h,a=0))}if(o||n>1)return c;throw f=!0,r}return function(o,l,h){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,h),a=l,u=h;(t=a<2?e:u)||!f;){i||(a?a<3?(a>1&&(p.n=-1),d(a,u)):p.n=u:p.v=u);try{if(s=2,i){if(a||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=i.return)&&t.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((t=(f=p.n<0)?u:n.call(r,p))!==c)break}catch(t){i=e,a=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,i,a),!0),l}var c={};function s(){}function l(){}function f(){}t=Object.getPrototypeOf;var p=[][i]?t(t([][i]())):(o(t={},i,function(){return this}),t),d=f.prototype=s.prototype=Object.create(p);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,o(e,a,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=f,o(d,"constructor",f),o(f,"constructor",l),l.displayName="GeneratorFunction",o(f,a,"GeneratorFunction"),o(d),o(d,a,"Generator"),o(d,i,function(){return this}),o(d,"toString",function(){return"[object Generator]"}),(r=function(){return{w:u,m:h}})()}function o(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}o=function(e,t,n,r){function a(t,n){o(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},o(e,t,n,r)}function i(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}n.d(t,{H_:()=>u,Rt:()=>s,xK:()=>c});var a=null;function u(e,t){var n=e.url,o=e.transformRequest,u=e.load;a=function(){var e,a=(e=r().m(function e(i,a){var c;return r().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,u();case 1:return c=e.v,e.a(2,c(n,o,t,i,a))}},e)}),function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,c,"next",e)}function c(e){i(a,r,o,u,c,"throw",e)}u(void 0)})});return function(e,t){return a.apply(this,arguments)}}()}function c(){return null!==a}function s(e,t){if(!a)throw new Error("ReverseGeocode not initialised");return a(e,t)}},902(e,t,n){n.d(t,{C1:()=>u,Ey:()=>s,ip:()=>c});var r=window.matchMedia("(pointer: coarse)").matches?"touch":"unknown",o=new Set,i=new Set;function a(e){r!==e&&(r=e,i.forEach(function(t){return t(e)}),o.forEach(function(t){return t(e)}))}function u(){var e=window.matchMedia("(pointer: coarse)"),t=function(e){a(e.matches?"touch":"mouse")};e.addEventListener("change",t);var n=function(e){var t,n="pen"===(t=e.pointerType)||"touch"===t?"touch":"mouse"===t?"mouse":"unknown";n!==r&&(r=n,i.forEach(function(e){return e(n)}),setTimeout(function(){o.forEach(function(e){return e(n)})},150))},u=function(e){new Set(["Tab","Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape"]).has(e.key)&&a("keyboard")};return window.addEventListener("pointerdown",n,{passive:!0}),window.addEventListener("keydown",u,{passive:!0}),function(){e.removeEventListener("change",t),window.removeEventListener("pointerdown",n),window.removeEventListener("keydown",u)}}function c(){return"unknown"===r?(r="mouse","mouse"):r}function s(e){return o.add(e),function(){o.delete(e)}}},201(e,t,n){n.d(t,{g:()=>o,w:()=>r});var r=function(e){var t=e.behaviour,n=e.hybridWidth,r=e.maxMobileWidth;if("hybrid"!==t)return!1;var o=null!=n?n:r;return window.matchMedia("(max-width: ".concat(o,"px)")).matches},o=function(e){var t=e.behaviour;return["mapOnly","buttonFirst"].includes(t)||r(e)}},637(e,t,n){n.d(t,{q:()=>r});var r=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null===(t=window.location)||void 0===t?void 0:t.search;return new URLSearchParams(n).get(e)}},901(e,t,n){function r(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return o(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 a,u=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){c=!0,a=e},f:function(){try{u||null==n.return||n.return()}finally{if(c)throw a}}}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,{U:()=>a});var i=function(e,t,n,r){return e!==t&&!(null!=n&&n.contains(e))&&e.matches(":not([aria-hidden]):not([data-fm-inert])")&&r.contains(e)};function a(e){var t,n=e.containerEl,o=e.isFullscreen,a=e.boundaryEl,u=void 0===a?document.body:a,c=Array.from(u.querySelectorAll("[data-fm-inert]"));if(n&&(c=c.filter(function(e){return!n.contains(e)})),c.forEach(function(e){e.removeAttribute("aria-hidden"),delete e.dataset.fmInert}),o){null===(t=document.activeElement)||void 0===t||t.blur();for(var s=n;null!==(l=s)&&void 0!==l&&l.parentNode&&s!==u&&s!==document.body;){var l,f,p=s.parentNode,d=r(p.children);try{for(d.s();!(f=d.n()).done;){var h=f.value;i(h,s,n,u)&&(h.setAttribute("aria-hidden","true"),h.dataset.fmInert="")}}catch(e){d.e(e)}finally{d.f()}s=p}}}}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return o[e](n,n.exports,a),n.exports}a.m=o,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var o=Object.create(null);a.r(o);var i={};e=e||[null,t({}),t([]),t(t)];for(var u=2&r&&n;("object"==typeof u||"function"==typeof u)&&!~e.indexOf(u);u=t(u))Object.getOwnPropertyNames(u).forEach(e=>i[e]=()=>n[e]);return i.default=()=>n,a.d(o,i),o},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,n)=>(a.f[n](e,t),t),[])),a.u=e=>"im-core.js",a.miniCssF=e=>{},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},r="defra.InteractiveMap:",a.l=(e,t,o,i)=>{if(n[e])n[e].push(t);else{var u,c;if(void 0!==o)for(var s=document.getElementsByTagName("script"),l=0;l<s.length;l++){var f=s[l];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==r+o){u=f;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",a.nc&&u.setAttribute("nonce",a.nc),u.setAttribute("data-webpack",r+o),u.src=e),n[e]=[t];var p=(t,r)=>{u.onerror=u.onload=null,clearTimeout(d);var o=n[e];if(delete n[e],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=p.bind(null,u.onerror),u.onload=p.bind(null,u.onload),c&&document.head.appendChild(u)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var r=n.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=n[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={57:0};a.f.j=(t,n)=>{var r=a.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else{var o=new Promise((n,o)=>r=e[t]=[n,o]);n.push(r[2]=o);var i=a.p+a.u(t),u=new Error;a.l(i,n=>{if(a.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var o=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;u.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",u.name="ChunkLoadError",u.type=o,u.request=i,r[1](u)}},"chunk-"+t,t)}};var t=(t,n)=>{var r,o,[i,u,c]=n,s=0;if(i.some(t=>0!==e[t])){for(r in u)a.o(u,r)&&(a.m[r]=u[r]);c&&c(a)}for(t&&t(n);s<i.length;s++)o=i[s],a.o(e,o)&&e[o]&&e[o][0](),e[o]=0},n=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var u={};a.d(u,{default:()=>ie});var c=a(540),s=a(848),l=a.t(s,2),f=a(637),p=a(201);function d(){h.forEach(function(e){!function(e,t){var n;if(!1!==e.config.manageHistoryState){e._isClosingViaBack=!1;var r=e.id===t,o="hybrid"===e.config.behaviour&&!(0,p.w)(e.config),i=null===(n=e.rootEl)||void 0===n?void 0:n.children.length;!r||i&&!e._isHidden?r||!i||o||function(e){var t,n;e.config.preserveStateOnClose?null===(t=e.hideApp)||void 0===t||t.call(e):null===(n=e.removeApp)||void 0===n||n.call(e)}(e):function(e){var t,n;e._isHidden?null===(t=e.showApp)||void 0===t||t.call(e):null===(n=e.loadApp)||void 0===n||n.call(e)}(e)}}(e,(0,f.q)(e.config.mapViewQueryParam))})}var h=new Map,v=!1;const y=function(e){v||(globalThis.addEventListener("popstate",d),v=!0),h.set(e.id,e)},m=function(e){h.delete(e.id),0===h.size&&(globalThis.removeEventListener("popstate",d),v=!1)};function b(e){return b="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},b(e)}function g(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _(e,t,n){return(t=function(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){try{return JSON.parse(e)}catch(e){return console.log(e),null}}function E(e,t){e.innerHTML='<div class="im-c-error">'.concat(t,"</div>")}var P=a(205),A=a(0),S=a(12);function O(e){var t=e.id,n=e.behaviour,r=(0,f.q)(e.mapViewQueryParam)===t;return["mapOnly","inline"].includes(n)||"hybrid"===n&&!(0,p.w)(e)||r}const k={appColorScheme:"light",autoColorScheme:!1,backgroundColor:"var(--background-color)",behaviour:"buttonFirst",buttonClass:"im-c-open-map-button",buttonText:"Map view",containerHeight:"600px",deviceNotSupportedText:"Your device is not supported. A map is available with a more up-to-date browser or device.",enableFullscreen:!1,enableMoveControls:!0,enableZoomControls:!0,genericErrorText:"There was a problem loading the map. Please try again later.",hasExitButton:!1,backAndContinue:null,hybridWidth:null,keyboardHintText:'<span class="im-u-visually-hidden">Press </span><kbd>Shift</kbd> + <span class="im-u-visually-hidden">Question mark</span><kbd aria-hidden="true">?</kbd> <span class="im-u-visually-hidden">to view </span>keyboard shortcuts',mapHintText:"Press Tab to focus it. Keyboard commands are only available once it has focus.",mapLabel:"Interactive map application",mapProvider:null,mapSize:"small",manageHistoryState:!0,mapViewQueryParam:"mv",urlPosition:"sync",maxMobileWidth:640,minDesktopWidth:835,moveControlsHintText:'A "Move and zoom controls" button is also available, opening further controls for moving and zooming.',nudgePanDelta:5,nudgeZoomDelta:.1,panDelta:100,pageTitle:"Map view",preserveStateOnClose:!1,readMapText:!1,reverseGeocodeProvider:null,zoomDelta:1};function T(e){return T="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},T(e)}var j=["mapViewParamKey"];function x(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?x(Object(n),!0).forEach(function(t){M(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function M(e,t,n){return(t=function(e){var t=function(e){if("object"!=T(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==T(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var D=a(902),R=a(233);function B(e){return B="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},B(e)}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,N(r.key),r)}}function N(e){var t=function(e){if("object"!=B(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=B(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==B(t)?t:t+""}var I=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events={},this._queued={}},t=[{key:"on",value:function(e,t){if(this.events[e]||(this.events[e]=[]),this.events[e].push(t),void 0!==this._queued[e]){try{t.apply(void 0,function(e){return function(e){if(Array.isArray(e))return L(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return L(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?L(e,t):void 0}}(e)||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.")}()}(this._queued[e]))}catch(t){console.error("Error in event handler for '".concat(e,"':"),t)}delete this._queued[e]}return this}},{key:"once",value:function(e,t){var n=this,r=function(){n.off(e,r),t.apply(void 0,arguments)};return this.on(e,r)}},{key:"off",value:function(e,t){return this.events[e]?(this.events[e]=t?this.events[e].filter(function(e){return e!==t}):[],this):this}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return this.events[e]?(this.events[e].forEach(function(t){try{t.apply(void 0,n)}catch(t){console.error("Error in event handler for '".concat(e,"':"),t)}}),this):this}},{key:"emitWhenReady",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return this.events[e]&&0!==this.events[e].length?this.emit.apply(this,[e].concat(n)):(this._queued[e]=n,this)}},{key:"emitWhenRequested",value:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i="".concat(e,"Requested"),a="".concat(e,"Ready"),u=function(){return t.emit.apply(t,[a].concat(r))};return this.on(i,u),u(),function(){return t.off(i,u)}}},{key:"requestOnce",value:function(e,t){var n="".concat(e,"Requested"),r="".concat(e,"Ready");return this.once(r,t),this.emit(n,e),this}},{key:"destroy",value:function(){this.events={},this._queued={}}}],t&&H(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();new I;var F=a(901);if("undefined"!=typeof crypto&&!crypto.randomUUID){var q=0;crypto.randomUUID=function(){return q=Math.max(Date.now(),q+1),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e,t){var n=t<12?Number.parseInt(q.toString(16).padStart(12,"0")[t],16):16*Math.random()|0;return("x"===e?n:3&n|8).toString(16)})}}var U=!Object.hasOwn;U&&(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)});var V="undefined"!=typeof AbortController&&!Object.getPrototypeOf((new AbortController).signal).throwIfAborted;if(V&&(Object.getPrototypeOf((new AbortController).signal).throwIfAborted=function(){if(this.aborted){var e=new Error("The operation was aborted.");throw e.name="AbortError",e}}),(V||U)&&"undefined"!=typeof URL&&URL.createObjectURL){var W="text/javascript",$=["if(!Object.hasOwn){Object.hasOwn=function(o,k){return Object.prototype.hasOwnProperty.call(o,k)}}\n",V?'if(typeof AbortController!=="undefined"){var _p=Object.getPrototypeOf(new AbortController().signal);if(!_p.throwIfAborted){_p.throwIfAborted=function(){if(this.aborted){var e=new Error("The operation was aborted.");e.name="AbortError";throw e}}}}\n':""].join(""),G=URL.createObjectURL.bind(URL);if(URL.createObjectURL=function(e){return e instanceof Blob&&e.type===W&&(e=new Blob([$,e],{type:W})),G(e)},"undefined"!=typeof Worker){var z=Worker;Worker=function(e,t){if("string"==typeof e&&!e.startsWith("blob:")){var n=new Blob(["".concat($,"importScripts(").concat(JSON.stringify(e),")")],{type:W});e=G(n)}return new z(e,t)},Worker.prototype=z.prototype}}function K(e){return K="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},K(e)}function Q(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return Y(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return i=t,u=0,c=e,p.n=n,a}};function d(n,r){for(u=n,c=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],d=p.p,h=i[2];n>3?(o=h===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=n<2&&d<i[1])?(u=0,p.v=r,p.n=i[1]):d<h&&(o=n<3||i[0]>r||r>h)&&(i[4]=n,i[5]=r,p.n=h,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,h){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,h),u=l,c=h;(t=u<2?e:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),d(u,c)):p.n=c:p.v=c);try{if(s=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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(t){i=e,u=1,c=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Y(t={},r,function(){return this}),t),f=s.prototype=u.prototype=Object.create(l);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,Y(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=s,Y(f,"constructor",s),Y(s,"constructor",c),c.displayName="GeneratorFunction",Y(s,o,"GeneratorFunction"),Y(f),Y(f,o,"Generator"),Y(f,r,function(){return this}),Y(f,"toString",function(){return"[object Generator]"}),(Q=function(){return{w:i,m:p}})()}function Y(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}Y=function(e,t,n,r){function i(t,n){Y(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},Y(e,t,n,r)}function Z(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}function J(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J(Object(n),!0).forEach(function(t){te(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ee(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ne(r.key),r)}}function te(e,t,n){return(t=ne(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ne(e){var t=function(e){if("object"!=K(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=K(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==K(t)?t:t+""}var re=function(){return e=function e(t){var n,r,o,i,a,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),te(this,"_openButton",null),te(this,"_root",null),te(this,"_breakpointDetector",null),te(this,"_interfaceDetectorCleanup",null),te(this,"_hybridBehaviourCleanup",null),te(this,"_isHidden",!1),te(this,"_isClosingViaBack",!1),te(this,"_isLoading",!1),this.id=t,this.rootEl=document.getElementById(t),!this.rootEl)throw new Error('Element with id "'.concat(t,'" not found'));this.eventBus=new I,this.config=this._buildConfig(u),n=this.rootEl,o=(r=this.config).mapProvider,i=r.deviceNotSupportedText,a=null==o?void 0:o.checkDeviceCapabilities(),(o?null!=a&&a.isSupported||(E(n,i),(0,P.i)(),A.v.warn(null==a?void 0:a.error),0):(A.v.warn("No map provider"),0))&&(["buttonFirst","hybrid"].includes(this.config.behaviour)&&y(this),this._breakpointDetector=function(e){var t,n=e.maxMobileWidth,r=e.minDesktopWidth,o=e.containerEl,i="unknown",a=new Set,u=function(e){e!==i&&(i=e,requestAnimationFrame(function(){i===e&&a.forEach(function(t){return t(e)})}))};if(o){var c=function(e,t,n){e.style.containerType="inline-size";var r=e.getBoundingClientRect().width,o=t(r);e.dataset.breakpoint=o;var i=new window.ResizeObserver(function(r){var o,i,a=(null===(o=r[0])||void 0===o||null===(o=o.borderBoxSize)||void 0===o||null===(o=o[0])||void 0===o?void 0:o.inlineSize)||(null===(i=r[0])||void 0===i?void 0:i.contentRect.width),u=t(a);e.dataset.breakpoint=u,n(u)});return i.observe(e),{initialType:o,cleanup:function(){i.disconnect(),e.style.containerType="",delete e.dataset.breakpoint}}}(o,function(e){return function(e,t,n){return e<=t?"mobile":e>=n?"desktop":"tablet"}(e,n,r)},u);i=c.initialType,u(c.initialType),t=c.cleanup}else{var s=function(e,t,n){var r={mobile:window.matchMedia("(max-width: ".concat(e,"px)")),desktop:window.matchMedia("(min-width: ".concat(t,"px)"))},o=function(){var e="tablet";r.mobile.matches?e="mobile":r.desktop.matches&&(e="desktop"),n(e)};return r.mobile.addEventListener("change",o),r.desktop.addEventListener("change",o),o(),{cleanup:function(){r.mobile.removeEventListener("change",o),r.desktop.removeEventListener("change",o)}}}(n,r,u);t=s.cleanup}return{subscribe:function(e){return a.add(e),function(){return a.delete(e)}},getBreakpoint:function(){return i},destroy:function(){var e;null===(e=t)||void 0===e||e(),a.clear()}}}({maxMobileWidth:this.config.maxMobileWidth,minDesktopWidth:this.config.minDesktopWidth,containerEl:this.rootEl}),this._interfaceDetectorCleanup=(0,D.C1)(),this._initialize())},t=[{key:"_buildConfig",value:function(e){var t=function(e){for(var t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?g(Object(n),!0).forEach(function(t){_(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},null==e?void 0:e.dataset),n={},r=0,o=Object.keys(t);r<o.length;r++){var i=o[r];n[i]=w(t[i])}return n}(this.rootEl);return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.mapViewParamKey,n=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,j),r=C(C({},k),n);return void 0!==t&&(console.warn("[InteractiveMap] mapViewParamKey is deprecated — use mapViewQueryParam instead."),r.mapViewQueryParam=t),"mapOnly"===r.behaviour&&r.hasExitButton&&(console.warn("[InteractiveMap] hasExitButton has no effect when behaviour is 'mapOnly' — there is nothing to exit to."),r.hasExitButton=!1),r}(X(X({id:this.id,title:document.title},t),e))}},{key:"_initialize",value:function(){var e=this;["buttonFirst","hybrid"].includes(this.config.behaviour)&&(this._openButton=function(t,n){var r=t.id,o=t.buttonText,i=t.buttonClass,a='\n <a class="'.concat(i,"\" role=\"button\">\n <svg focusable='false' aria-hidden='true' width='16' height='20' viewBox='0 0 16 20' fillRule='evenodd'>\n <path d='M15 7.5c.009 3.778-4.229 9.665-7.5 12.5C4.229 17.165-.009 11.278 0 7.5a7.5 7.5 0 1 1 15 0z'/>\n <path d='M7.5 12.961a5.46 5.46 0 1 0 0-10.922 5.46 5.46 0 1 0 0 10.922z' fill='#fff'/>\n </svg>\n <span>").concat(o,"</span>\n <span class='im-u-visually-hidden'> (Visual only)</span>\n </a>\n ");n.insertAdjacentHTML("beforebegin",a);var u=n.previousElementSibling,c=new URL(window.location.href);return c.searchParams.set(t.mapViewQueryParam,r),u.setAttribute("href",c.toString()),u.addEventListener("click",function(t){t.preventDefault(),function(t){e._handleButtonClick(t)}(t)}),u}(this.config,this.rootEl)),this._hybridBehaviourCleanup=function(e){var t=e.config,n=t.behaviour,r=t.hybridWidth,o=t.maxMobileWidth;if("buttonFirst"===n&&e._breakpointDetector.subscribe(function(){O(e.config)?e.loadApp():e.removeApp()}),"hybrid"===n){var i=null!=r?r:o,a=window.matchMedia("(max-width: ".concat(i,"px)")),u=function(){if(O(e.config))if(e._isHidden)e.showApp();else if(null==e._root)e.loadApp();else{var t=(0,P.N)(e).isFullscreen;e.eventBus.emit(S.q.APP_FULLSCREEN_CHANGE,{isFullscreen:t})}else e._root&&e.hideApp()};return a.addEventListener("change",u),function(){return a.removeEventListener("change",u)}}return null}(this),O(this.config)?this.loadApp():(0,P.i)()}},{key:"_handleButtonClick",value:function(e){var t;this._isHidden?(this.config.manageHistoryState&&history.pushState({isBack:!0},"",e.currentTarget.getAttribute("href")),this.showApp(),null===(t=this.rootEl.querySelector('[role="application"]'))||void 0===t||t.focus()):this._root||(this.config.manageHistoryState&&history.pushState({isBack:!0},"",e.currentTarget.getAttribute("href")),this.loadApp({focusOnMount:!0}))}},{key:"_removeMapParamFromUrl",value:function(e,t){var n=new RegExp("[?&]".concat(t,"=[^&]*(&|$)"));return n.test(e)?e.replace(n,function(e,t){return"&"===t?"?":""}).replace(/\?$/,""):e}},{key:"_handleExitClick",value:function(){var e,t=this;if(this.config.manageHistoryState)if(null!==(e=history.state)&&void 0!==e&&e.isBack){if(this._isClosingViaBack)return;this._isClosingViaBack=!0,history.back(),setTimeout(function(){t._isClosingViaBack=!1},1e3)}else{this.config.preserveStateOnClose?this.hideApp():this.removeApp();var n=this.config.mapViewQueryParam,r=this._removeMapParamFromUrl(location.href,n);history.replaceState(history.state,"",r)}else this.config.preserveStateOnClose?this.hideApp():this.removeApp()}},{key:"loadApp",value:(n=Q().m(function e(){var t,n,r,o,i,u,c,s,l,f,p,d,h,v,y=this,m=arguments;return Q().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=(m.length>0&&void 0!==m[0]?m[0]:{}).focusOnMount,n=void 0!==t&&t,!this._root&&!this._isLoading){e.n=1;break}return e.a(2);case 1:return this._isLoading=!0,this._openButton&&(this._openButton.style.display="none"),e.p=2,e.n=3,a.e(935).then(a.bind(a,310));case 3:return r=e.v,o=r.initialiseApp,e.n=4,this.config.mapProvider.load();case 4:return i=e.v,u=i.MapProvider,c=i.mapFramework,s=i.mapProviderConfig,this.config.reverseGeocodeProvider&&(0,R.H_)(this.config.reverseGeocodeProvider,s.crs),e.n=5,o(this.rootEl,X(X({id:this.id,initialBreakpoint:this._breakpointDetector.getBreakpoint(),initialInterfaceType:(0,D.ip)(),focusOnMount:n},this.config),{},{MapProvider:u,mapProviderConfig:s,mapFramework:c,eventBus:this.eventBus,breakpointDetector:this._breakpointDetector,handleExitClick:this._handleExitClick.bind(this)}));case 5:l=e.v,this._root=l._root,delete l._root,f=new Set(["on","off","emit"]),Object.keys(l).forEach(function(e){f.has(e)||(y[e]=l[e])}),p=(0,P.N)(this),d=p.isFullscreen,this.eventBus.emit(S.q.APP_OPENED,{statePreserved:!1,isFullscreen:d}),e.n=7;break;case 6:throw e.p=6,v=e.v,null===(h=this._openButton)||void 0===h||h.removeAttribute("style"),E(this.rootEl,this.config.genericErrorText),console.error(v),v;case 7:return e.p=7,this._isLoading=!1,e.f(7);case 8:return e.a(2)}},e,this,[[2,6,7,8]])}),r=function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){Z(i,r,o,a,u,"next",e)}function u(e){Z(i,r,o,a,u,"throw",e)}a(void 0)})},function(){return r.apply(this,arguments)})},{key:"removeApp",value:function(){this._root&&"function"==typeof this.unmount&&(this.unmount(),this._root=null),this._openButton&&(this._openButton.removeAttribute("style"),this._openButton.focus()),(0,P.N)(this,{isFullscreen:!1}),this.eventBus.emit(S.q.APP_CLOSED,{statePreserved:!1}),this.eventBus.emit(S.q.MAP_DESTROY,{mapId:this.id})}},{key:"hideApp",value:function(){this._isHidden=!0,this.rootEl.style.display="none",(0,F.U)({containerEl:this.rootEl,isFullscreen:!1}),this._openButton&&(this._openButton.removeAttribute("style"),this._openButton.focus()),document.documentElement.classList.remove("im-is-fullscreen"),this.rootEl.classList.remove("im-is-fullscreen");var e=document.title.split(": ");e.length>1&&(document.title=e.at(-1)),this.eventBus.emit(S.q.APP_CLOSED,{statePreserved:!0})}},{key:"showApp",value:function(){this._isHidden=!1,this.rootEl.style.display="",this._openButton&&(this._openButton.style.display="none");var e=(0,P.N)(this).isFullscreen;this.eventBus.emit(S.q.APP_OPENED,{statePreserved:!0,isFullscreen:e})}},{key:"destroy",value:function(){var e,t,n;this.removeApp(),null===(e=this._breakpointDetector)||void 0===e||e.destroy(),null===(t=this._interfaceDetectorCleanup)||void 0===t||t.call(this),null===(n=this._hybridBehaviourCleanup)||void 0===n||n.call(this),m(this),this.eventBus.destroy()}},{key:"on",value:function(){var e;(e=this.eventBus).on.apply(e,arguments)}},{key:"off",value:function(){var e;(e=this.eventBus).off.apply(e,arguments)}},{key:"emit",value:function(){var e;(e=this.eventBus).emit.apply(e,arguments)}},{key:"addMarker",value:function(e,t,n){this.eventBus.emit(S.q.APP_ADD_MARKER,{id:e,coords:t,options:n})}},{key:"updateMarker",value:function(e,t){this.eventBus.emit(S.q.APP_UPDATE_MARKER,{id:e,options:t})}},{key:"removeMarker",value:function(e){this.eventBus.emit(S.q.APP_REMOVE_MARKER,e)}},{key:"setMode",value:function(e){this.eventBus.emit(S.q.APP_SET_MODE,e)}},{key:"addButton",value:function(e,t){this.eventBus.emit(S.q.APP_ADD_BUTTON,{id:e,config:t})}},{key:"toggleButtonState",value:function(e,t,n){this.eventBus.emit(S.q.APP_TOGGLE_BUTTON_STATE,{id:e,prop:t,value:n})}},{key:"setContinueEnabled",value:function(e){this.toggleButtonState("journeyContinue","disabled",!e)}},{key:"addPanel",value:function(e,t){this.eventBus.emit(S.q.APP_ADD_PANEL,{id:e,config:t})}},{key:"removePanel",value:function(e){this.eventBus.emit(S.q.APP_REMOVE_PANEL,e)}},{key:"showPanel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.focus,r=void 0===n||n,o=t.triggeringElement,i=null!=o?o:document.activeElement&&document.activeElement!==document.body?document.activeElement:void 0;this.eventBus.emit(S.q.APP_SHOW_PANEL,{id:e,focus:r,triggeringElement:i})}},{key:"hidePanel",value:function(e){this.eventBus.emit(S.q.APP_HIDE_PANEL,e)}},{key:"addControl",value:function(e,t){this.eventBus.emit(S.q.APP_ADD_CONTROL,{id:e,config:t})}},{key:"showHint",value:function(e,t){this.eventBus.emit(S.q.APP_SHOW_HINT,{text:e,options:t})}},{key:"dismissHint",value:function(){this.eventBus.emit(S.q.APP_DISMISS_HINT)}},{key:"fitToBounds",value:function(e){this.eventBus.emitWhenReady(S.q.MAP_FIT_TO_BOUNDS,e)}},{key:"setView",value:function(e){this.eventBus.emitWhenReady(S.q.MAP_SET_VIEW,e)}},{key:"open",value:function(){this._isHidden?this.showApp():this._root||this.loadApp()}},{key:"close",value:function(){this._handleExitClick()}}],t&&ee(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,r}(),oe="undefined"==typeof window?globalThis:window;oe.defra=oe.defra||{},oe.preactCompat=c,oe.preactJsxRuntime=l,oe.preactHooks={useState:c.useState},oe.defra.InteractiveMap=re,oe.preactCompat.default||(oe.preactCompat.default=oe.preactCompat),oe.preactCompat.createRoot||(oe.preactCompat.createRoot=function(e){return{render:function(t){oe.preactCompat.render(t,e)},unmount:function(){oe.preactCompat.render(null,e)}}});const ie=re;return u.default})());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/interactive-map",
3
- "version": "0.0.42-fmp-5",
3
+ "version": "0.0.43-alpha",
4
4
  "description": "An accessible map component",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- import{useEffect as e,useRef as t}from"preact/compat";import{jsx as a,jsxs as r,Fragment as i}from"preact/jsx-runtime";import s from"@babel/runtime/helpers/defineProperty";import n from"@babel/runtime/helpers/asyncToGenerator";function o(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function l(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?o(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var d=e=>{var{datasets:t=[]}=e,a=[],r=t.filter(e=>{var t;return e.showInMenu||(null===(t=e.sublayers)||void 0===t?void 0:t.some(e=>e.showInMenu))}),i=new Map;return r.forEach(e=>{var t;if(null!==(t=e.sublayers)&&void 0!==t&&t.length){var r=e.sublayers.filter(t=>e.showInMenu?!1!==t.showInMenu:t.showInMenu);if(!1===e.showInMenu&&!r.length)return;var s={id:e.id,groupLabel:e.label,visibleWhen:!0,type:"checkbox",items:r.map(t=>({id:"".concat(e.id,"-").concat(t.id),label:t.label}))};0===s.items.length&&(delete s.groupLabel,s.items.push({id:e.id,label:e.label})),a.push(s)}else if(e.groupLabel){var n=i.has(e.groupLabel)?i.get(e.groupLabel):{id:e.groupLabel,groupLabel:e.groupLabel,visibleWhen:!0,type:"checkbox",items:[]};i.has(e.groupLabel)||(i.set(e.groupLabel,n),a.push(n)),n.items.push({id:e.id,label:e.label})}else a.push({visibleWhen:!0,type:"checkbox",id:e.id,items:[{id:e.id,label:e.label}]})}),a},p=(e,t)=>e.reduce((e,a)=>{var r=a.items.filter(e=>!t.includes(e.id));return r.length&&e.push(l(l({},a),{},{items:r})),e},[]);function u(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function c(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?u(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):u(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var y={minZoom:6,maxZoom:24,showInKey:!1,showInMenu:!1,visible:!0,style:{stroke:"#d4351c",strokeWidth:2,symbolDescription:"red outline"}},h=["stroke","strokeWidth","strokeDashArray","fill","fillPattern","fillPatternSvgContent","fillPatternForegroundColor","fillPatternBackgroundColor","opacity","symbolDescription","keySymbolShape","symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"],v=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"],b=e=>v.some(t=>t in e);function m(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function f(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?m(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):m(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var g=(e,t)=>{var a,{id:r}=t,i=(e=>{!0!==e.visible&&!1!==e.visible&&(e.visible="hidden"!==e.visibility);var t=c(c(c({},y),e),{},{style:c(c({},y.style),e.style)}),a=e.style||{};return!("symbolDescription"in a)&&b(a)&&delete t.style.symbolDescription,h.forEach(e=>delete t[e]),t})(t);t.parentId&&("showInKey"in t||delete i.showInKey,"showInMenu"in t||delete i.showInMenu),e[r]=i;var{orderedDatasets:s}=e;s.push(r);var n=null===(a=t.sublayers)||void 0===a?void 0:a.map(e=>((e,t)=>{var a="".concat(e,"-").concat(t.id),r=t.id;return"hidden"!==t.visibility&&(t.visibility="visible"),f(f({},t),{},{id:a,parentId:e,sublayerId:r})})(r,e));if(null!=n&&n.length){var o=null==n?void 0:n.map(e=>e.id),l=null==n?void 0:n.reduce(g,{orderedDatasets:s});return e[r].sublayerIds=o,delete e[r].sublayers,f(f(f({},e),l),{},{orderedDatasets:s})}return f(f({},e),{},{orderedDatasets:s})},D=e=>{var t=(e.datasets||[]).reduce(g,{orderedDatasets:[]}),{orderedDatasets:a}=t;return delete t.orderedDatasets,f(f({},e),{},{mappedDatasets:t,orderedDatasets:a})},S="[interactive-map]",_={warn:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return console.warn(S,...t)},error:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return console.error(S,...t)}};function O(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function P(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?O(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):O(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var E=function(e,t,a){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"not found";return!!e.mappedDatasets[t]||(_.error("".concat(a,": Dataset with id '").concat(t,"' ").concat(r)),!1)},A=0,I=(e,t,a)=>(A=a.actionsArray.length?A+1:0,P(P({},a),{},{actionsArray:[...a.actionsArray,{method:e,parameters:t,actionId:A}]})),M={SET_DATASETS:(e,t)=>{var{mappedDatasets:a,orderedDatasets:r}=t;return P(P({},e),{},{mappedDatasets:a,orderedDatasets:r})},ADD_DATASET:(e,t)=>{var{dataset:a,mapStyle:r}=t;if(e.mappedDatasets[a.id])return _.error("addDataset: Dataset with id '".concat(a.id,"' already exists")),e;var{mappedDatasets:i,orderedDatasets:s}=D({datasets:[a]}),n=((e,t)=>{var a=[...e.menu],r=d({datasets:[t]}),i=a.find(e=>e.groupLabel===r[0].groupLabel);return i?i.items.push(...r[0].items):a.push(...r),a})(e,a);return I("addDataset",[a.id,r],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),i),orderedDatasets:[...e.orderedDatasets,...s],menu:n}))},REMOVE_DATASET:(e,t)=>{var a,{id:r}=t;if(!E(e,r,"removeDataset"))return e;var i=P({},e.mappedDatasets),s=[r,...(null===(a=i[r])||void 0===a?void 0:a.sublayerIds)||[]];s.forEach(e=>delete i[e]);var n=e.orderedDatasets.filter(e=>!s.includes(e));return P(P({},e),{},{mappedDatasets:i,orderedDatasets:n,menu:p(e.menu,s)})},SET_DATASET_VISIBILITY:(e,t)=>{var{datasetId:a,visible:r}=t;return E(e,a,"setDatasetVisibility")?e.mappedDatasets[a].visible===r?e:I("applyDatasetVisibility",[a,r],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:P(P({},e.mappedDatasets[a]),{},{visible:r})})})):e},SET_GLOBAL_VISIBILITY:(e,t)=>{var{visible:a}=t;return I("applyGlobalVisibility",[a],P(P({},e),{},{globals:P(P({},e.globals),{},{visible:a})}))},SET_DATASET_STYLE:(e,t)=>{var{datasetId:a,styleChanges:r,mapStyle:i}=t;if(!E(e,a,"setDatasetStyle"))return e;var s=P(P({},e.mappedDatasets[a].style),r),n=P(P(P({},e.mappedDatasets[a]),r),{},{style:s});return I("applyStyle",[a,i],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:n})}))},SET_OPACITY:(e,t)=>{var{datasetId:a,opacity:r}=t;if(!E(e,a,"setOpacity"))return e;var i=P(P({},e.mappedDatasets[a].style),{},{opacity:r}),s=P(P({},e.mappedDatasets[a]),{},{style:i});return I("applyDatasetOpacity",[a],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:s})}))},SET_GLOBAL_OPACITY:(e,t)=>{var{opacity:a}=t;return I("applyGlobalOpacity",[],P(P({},e),{},{globals:P(P({},e.globals),{},{opacity:a})}))},HIDE_FEATURES:(e,t)=>{var{datasetId:a,featureIds:r}=t;if(!E(e,a,"setFeatureVisibility - hideFeatures"))return e;var i=P({},e.mappedDatasets[a]),s=i.hiddenFeatures||[],n=Array.from(new Set([...s,...r]));return i.hiddenFeatures=n,I("applyFeatureFilter",[a],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:i})}))},SHOW_FEATURES:(e,t)=>{var{datasetId:a,featureIds:r}=t;if(!E(e,a,"setFeatureVisibility - showFeatures"))return e;var i=P({},e.mappedDatasets[a]),s=(i.hiddenFeatures||[]).filter(e=>!r.includes(e));return i.hiddenFeatures=s.length?s:[-1],I("applyFeatureFilter",[a],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:i})}))},REMOVE_ADAPTER_ACTIONS:(e,t)=>null!=t&&t.length?P(P({},e),{},{actionsArray:e.actionsArray.filter(e=>!t.includes(e))}):e,SET_GLOBAL_STATE:(e,t)=>I("applyGlobalOpacity",[],P(P({},e),{},{globals:P(P({},e.globals),t)})),SET_MENU:(e,t)=>{var{menu:a}=t;return P(P({},e),{},{menu:a})}},T={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_FEATURES_SUPPRESSED:"map:setfeaturessuppressed",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"},w=function(){var e=n(function*(e,t,a,r){var i=a(e,t),s="string"==typeof i?{url:i}:i,{url:n,headers:o={}}=s,l=yield fetch(n,{headers:o,signal:r});if(!l.ok)throw new Error("Failed to fetch GeoJSON: ".concat(l.status," ").concat(l.statusText));var d=yield l.json();if("FeatureCollection"===d.type)return d;if("Feature"===d.type)return{type:"FeatureCollection",features:[d]};if(Array.isArray(d))return{type:"FeatureCollection",features:d};throw new Error("Invalid GeoJSON response")});return function(t,a,r,i){return e.apply(this,arguments)}}(),C=(e,t)=>!(!e||!t)&&!(e[2]<t[0]||e[0]>t[2]||e[3]<t[1]||e[1]>t[3]),j=e=>{var t=1/0,a=1/0,r=-1/0,i=-1/0,s=(e,n)=>{var o;0===n?(o=e,t=Math.min(t,o[0]),a=Math.min(a,o[1]),r=Math.max(r,o[0]),i=Math.max(i,o[1])):e.forEach(e=>s(e,n-1))};switch(e.type){case"Point":s(e.coordinates,0);break;case"LineString":case"MultiPoint":s(e.coordinates,1);break;case"Polygon":case"MultiLineString":s(e.coordinates,2);break;case"MultiPolygon":s(e.coordinates,3);break;case"GeometryCollection":e.geometries.forEach(e=>{var s=j(e);t=Math.min(t,s[0]),a=Math.min(a,s[1]),r=Math.max(r,s[2]),i=Math.max(i,s[3])});break;default:throw new Error("Unsupported geometry type: ".concat(e.type))}return[t,a,r,i]},L=e=>({type:"FeatureCollection",features:Array.from(e.values()).map(e=>e.feature)}),k=function(){var e=n(function*(e,t){var{map:a,dynamicGeoJSON:r,onUpdate:i}=t,{url:s,idProperty:n,transformRequest:o,maxFeatures:l,minZoom:d=0}=r,p=a.getZoom();if(!(p<d)){var u=(e=>{var t=e.getBounds();return[t.getWest(),t.getSouth(),t.getEast(),t.getNorth()]})(a);if(!(e.fetchedBbox&&(c=e.fetchedBbox,y=u,c&&y&&y[0]>=c[0]&&y[1]>=c[1]&&y[2]<=c[2]&&y[3]<=c[3]))){var c,y,h,v;e.currentController&&e.currentController.abort(),e.currentController=new AbortController;try{var b={bbox:u,zoom:p},m=yield w(s,b,o,e.currentController.signal);((e,t,a)=>{var r=Date.now();t.features.forEach(t=>{var i=((e,t)=>{var a,r;return t&&null!==(a=null===(r=e.properties)||void 0===r?void 0:r[t])&&void 0!==a?a:e.id})(t,a);null!=i?e.set(i,{feature:t,bbox:j(t.geometry),lastSeenAt:r}):console.warn("Feature missing ID, skipping:",t)})})(e.features,m,n),e.fetchedBbox=(h=e.fetchedBbox,v=u,h?[Math.min(h[0],v[0]),Math.min(h[1],v[1]),Math.max(h[2],v[2]),Math.max(h[3],v[3])]:[...v]);var f=e.features.size;((e,t,a)=>{if(a&&!(e.size<=1.2*a)){var r=a,i=[],s=[];for(var[n,o]of e)C(o.bbox,t)?i.push(n):s.push({id:n,lastSeenAt:o.lastSeenAt});s.sort((e,t)=>e.lastSeenAt-t.lastSeenAt);for(var l=e.size-r,d=0;d<l&&d<s.length;d++)e.delete(s[d].id);if(e.size>r)for(var p=e.size-r,u=i.map(t=>({id:t,lastSeenAt:e.get(t).lastSeenAt})).sort((e,t)=>e.lastSeenAt-t.lastSeenAt),c=0;c<p&&c<u.length;c++)e.delete(u[c].id)}})(e.features,u,l),e.features.size<f&&(e.fetchedBbox=u),i(r.id,L(e.features))}catch(e){if("AbortError"===e.name)return;console.error("Failed to fetch dynamic GeoJSON for ".concat(r.id,":"),e)}}}});return function(t,a){return e.apply(this,arguments)}}(),F=e=>{var t,a,r,i,{dynamicGeoJSON:s,map:n,onUpdate:o}=e,l={features:new Map,fetchedBbox:null,currentController:null},d=()=>k(l,{map:n,dynamicGeoJSON:s,onUpdate:o}),p=(t=d,a=200,(i=function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];clearTimeout(r),r=setTimeout(()=>t(...i),a)}).cancel=()=>{clearTimeout(r),r=null},i),u=()=>{p()};return n.on("moveend",u),d(),{destroy(){n.off("moveend",u),p.cancel(),l.currentController&&l.currentController.abort()},clear(){l.features.clear(),l.fetchedBbox=null,o(s.id,{type:"FeatureCollection",features:[]})},refresh(){l.features.clear(),l.fetchedBbox=null,d()},getFeatureCount:()=>l.features.size,reapply(){l.features.size>0&&o(s.id,L(l.features))}}},N={},G=e=>{N=e},x=e=>{var t,a=(null===(t=N)||void 0===t||null===(t=t.current)||void 0===t?void 0:t.menuState)||{};for(var[r,i]of Object.entries(e)){var s=a[r];if(!i.includes(s))return!1}return!0},R=e=>(Array.isArray(e)?e:[e]).includes(B()),B=()=>$.mapStyle.id,V=e=>{var t=0;for(var a of e)t=Math.trunc((t<<5)-t+a.codePointAt(0));return Math.abs(t).toString(36)};function K(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}class U{constructor(e){this.id=e.id,this.url=e.url,this.transformRequest=e.transformRequest,this.maxFeatures=e.maxFeatures,this.minZoom=e.minZoom,this.idProperty=e.idProperty,this.hiddenFeaturesIdExpression=["to-string",["get",this.idProperty]],this.sourceId="geojson-dynamic-".concat(this.id),this.source=function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?K(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):K(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}({type:"geojson",data:{type:"FeatureCollection",features:[]}},this.idProperty?{promoteId:this.idProperty}:{generateId:!0})}}var H={},W=(e,t)=>{switch(H.opacityMode){case"global":return H.opacity;case"multiply":return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Math.round(100*(e*t*H.opacity+Number.EPSILON))/100}(e,t);default:return((e,t)=>void 0===e?void 0===t?H.opacity:t:e)(e,t)}},Z=()=>H.visible;function z(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function Y(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?z(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):z(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}class J{constructor(e){this._datasetDefinition=e}get id(){return this._datasetDefinition.id}get label(){return this._datasetDefinition.label}get hasSymbol(){var e;return!this.hasSublayers&&Boolean(null===(e=this.style)||void 0===e?void 0:e.symbol)}get hasPattern(){return!(this.hasSublayers||this.hasSymbol||(e=this.style,!e.fillPattern&&!e.fillPatternSvgContent));var e}get hasFill(){var e,t;return!this.hasSublayers&&!this.hasSymbol&&(this.hasPattern||(null===(e=this.style)||void 0===e?void 0:e.fill)&&"transparent"!==(null===(t=this.style)||void 0===t?void 0:t.fill))}get hasStroke(){var e;return!this.hasSublayers&&!this.hasSymbol&&Boolean(null===(e=this.style)||void 0===e?void 0:e.stroke)}get tiles(){return this._datasetDefinition.tiles}get geojson(){return this._datasetDefinition.geojson}get idProperty(){return this._datasetDefinition.idProperty}get generateIds(){return this._datasetDefinition.generateIds}get parentId(){return this._datasetDefinition.parentId}get minZoom(){var e;return this._datasetDefinition.minZoom||(null===(e=this.parent)||void 0===e?void 0:e.minZoom)}get maxZoom(){var e;return this._datasetDefinition.maxZoom||(null===(e=this.parent)||void 0===e?void 0:e.maxZoom)}get type(){var e;return this._datasetDefinition.type||(null===(e=this.parent)||void 0===e?void 0:e.type)}get showInKey(){var e,t,a=this._datasetDefinition.showInKey;return void 0!==a?a:null!==(e=null===(t=this.parent)||void 0===t?void 0:t.showInKey)&&void 0!==e&&e}get visibleWhen(){var e;return void 0===this._datasetDefinition.visibleWhen?null===(e=this.parent)||void 0===e?void 0:e.visibleWhen:this._datasetDefinition.visibleWhen}get groupLabel(){var e,t;return this._datasetDefinition.groupLabel||(null===(e=this.parent)||void 0===e?void 0:e.groupLabel)||(null===(t=this.parent)||void 0===t?void 0:t.label)}get opacity(){var e,t,a=null===(e=this.style)||void 0===e?void 0:e.opacity,r=null===(t=this.parent)||void 0===t||null===(t=t.style)||void 0===t?void 0:t.opacity;return W(a,r)}get hasDynamicGeoJSON(){return Boolean(this._datasetDefinition.dynamicGeoJSON)}get dynamicGeoJSON(){return new U(Y(Y({},this._datasetDefinition.dynamicGeoJSON),{},{id:this.id,minZoom:this.minZoom}))}get hiddenFeatures(){return this._datasetDefinition.hiddenFeatures}get hasHiddenFeatures(){var e,t;return Boolean((null===(e=this.hiddenFeatures)||void 0===e?void 0:e.length)>0||(null===(t=this.parent)||void 0===t?void 0:t.hasHiddenFeatures))}get filter(){return null}get isHiddenByInheritance(){var e;return this.isSublayer?!(null!==(e=this.parent)&&void 0!==e&&e.visible):!Z()}get isLocallyVisible(){return!!this.isVisible||this._datasetDefinition.visible}get visible(){var e;return this.isSublayer?this._datasetDefinition.visible&&(null===(e=this.parent)||void 0===e?void 0:e.visible):this._datasetDefinition.visible&&Z()}get esriStyleLayerId(){return this._datasetDefinition.esriStyleLayerId}get visibility(){var{visible:e,visibleWhen:t}=this;return e&&t?(e=>{if(null==e)return!0;if("boolean"==typeof e)return e;if("object"==typeof e){for(var[t,a]of Object.entries(e)){if("mapStyleId"===t&&!R(a))return!1;if("menu"===t&&!x(a))return!1}return!0}return!0})(t)?"visible":"none":e?"visible":"none"}get keyVisibility(){return this.showInKey&&"visible"===this.visibility}get symbolAnchor(){var e,t;return null!==(e=this.style)&&void 0!==e&&e.symbolAnchor?this.style.symbolAnchor:null===(t=this.parent)||void 0===t?void 0:t.symbolAnchor}get sourceLayer(){return this.isSublayer?this.parent.sourceLayer:this.tiles?this._datasetDefinition.sourceLayer:void 0}get isSublayer(){return Boolean(this._datasetDefinition.parentId)}get hasSublayers(){var e;return(null===(e=this._datasetDefinition.sublayerIds)||void 0===e?void 0:e.length)>0}get sublayerIds(){return this._datasetDefinition.sublayerIds}get sublayers(){var{sublayerIds:e}=this;return e?e.map(e=>$.getDataset(e)):[]}get parent(){if(this._datasetDefinition.parentId)return $.getDataset(this._datasetDefinition.parentId)}get style(){var e,t=null===(e=this.parent)||void 0===e?void 0:e.style;return t?Y(Y(Y({},t),{},{opacity:void 0},this._datasetDefinition.style),{},{symbolDescription:this.symbolDescription}):this._datasetDefinition.style||{}}get hasCustomVisualStyle(){return b(this._datasetDefinition.style||{})}get symbolDescription(){var e,t;return null!==(e=this._datasetDefinition.style)&&void 0!==e&&e.symbolDescription?this._datasetDefinition.style.symbolDescription:this.hasCustomVisualStyle||null===(t=this.parent)||void 0===t?void 0:t.symbolDescription}get patternConfigs(){var e=this.hasPattern?[this.style]:[];return this.hasSublayers?[...e,...this.sublayers.flatMap(e=>e.patternConfigs)]:e}get symbolConfigs(){var e=this.hasSymbol?[this.style]:[];return this.hasSublayers?[...e,...this.sublayers.flatMap(e=>e.symbolConfigs)]:e}get groupStyle(){var e;return this._datasetDefinition.groupStyle?this._datasetDefinition.groupStyle:null===(e=this.parent)||void 0===e?void 0:e.groupStyle}get hasRampStyleKey(){return"ramp"===this.groupStyle}get keyDefinition(){return{id:this.id,type:"dataset",label:this.label,hasSymbol:this.hasSymbol,hasPattern:this.hasPattern,hasRampStyleKey:this.hasRampStyleKey,style:this.style,symbolDescription:this.symbolDescription}}}class q{constructor(){this.idToDefinitionMap=new Map,this.definitionToInstanceMap=new Map}add(e){this.idToDefinitionMap.set(e.id,e._datasetDefinition),this.definitionToInstanceMap.set(e._datasetDefinition,e)}invalidateDataset(e){var t=this.idToDefinitionMap.get(e.id);[t.id,...(null==t?void 0:t.sublayerIds)||[]].forEach(e=>{var t=this.idToDefinitionMap.get(e);this.definitionToInstanceMap.delete(t),this.idToDefinitionMap.delete(e)})}invalidateChangedDatasets(e){e.forEach(e=>{var t=this.idToDefinitionMap.get(e.id);if(t&&t!==e){var a=this.definitionToInstanceMap.get(t);this.invalidateDataset(a.isSublayer&&a.parent?a.parent:a)}})}getByDefinition(e){return this.definitionToInstanceMap.get(e)}}function X(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function Q(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?X(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):X(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var $={attach(e,t,a){this._datasets=e,this._orderedDatasets=t,this.attachMapStyle(a),this._invalidateChangedDatasets()},_definitionCache:new q,_invalidateCache(){this._definitionCache=new q},_invalidateChangedDatasets(){this._datasets?this._definitionCache.invalidateChangedDatasets(Object.values(this._datasets)):this._invalidateCache()},attachCreateDataset(e){this._createDataset=e},_createDataset:e=>(e=>new J(e))(e),attachMapStyle(e){e&&(this._mapStyle=e)},get mapStyle(){return this._mapStyle},getDataset(e){var t=this.datasets[e];if(t){var a=this._definitionCache.getByDefinition(t);if(a)return a;var r=this._createDataset(t);return this._definitionCache.add(r),r.isSublayer&&this.getDataset(r.parentId),r}},forEach(e){this._orderedDatasets.forEach(t=>e(this.getDataset(t)))},forEachDataset(e){Object.values(this.datasets).filter(e=>!e.parentId).forEach(t=>e(this.getDataset(t.id)))},topLevelDatasets(){return Object.values(this.datasets).filter(e=>!e.parentId).map(e=>this.getDataset(e.id))},getPatternAndSymbolConfigs(){return this.topLevelDatasets().reduce((e,t)=>Q(Q({},e),{},{patternConfigs:[...e.patternConfigs,...t.patternConfigs],symbolConfigs:[...e.symbolConfigs,...t.symbolConfigs]}),{patternConfigs:[],symbolConfigs:[]})},_lastMenuState:{},invalidateKeyItemsOnMenuStateChange(e){e!==this._lastMenuState&&(this._lastMenuState=e,this._lastKeyItemsDatasets=null)},_lastKeyItems:{},keyItems(){if(this.datasets===this._lastKeyItemsDatasets)return this._lastKeyItems;this._lastKeyItemsDatasets=this.datasets;var e=[],t=new Map;this.forEach(a=>{if(a.keyVisibility)if(a.hasSublayers||a.groupLabel){var r=((a,r)=>{if(t.has(a))return t.get(a);var i={type:"group",id:a.toLowerCase().replaceAll(/\s+/g,"-"),groupLabel:a,groupStyle:r,keyDefinitions:[]};return t.set(a,i),e.push(i),i})(a.groupLabel||a.label,a.groupStyle);a.hasSublayers||r.keyDefinitions.push(a.keyDefinition)}else e.push({type:"flat",id:a.id,keyDefinition:a.keyDefinition})});var a=e.filter(e=>{var t;return"flat"===e.type||Boolean(null===(t=e.keyDefinitions)||void 0===t?void 0:t.length)}),r=a.some(e=>"group"===e.type);return this._lastKeyItems={items:a,hasGroups:r},this._lastKeyItems}};Object.defineProperty($,"datasets",{get:()=>$._datasets});var ee,te=e=>{var{adapter:t,pluginConfig:a,mapStyle:r,mapProvider:i,events:s,dispatch:n,eventBus:o}=e,{datasets:l}=a,p=new Map;a.globals&&n({type:"SET_GLOBAL_STATE",payload:a.globals});var u=l.map(e=>((e,t)=>{var a=e.style||{},r=c(c({},t.style),a);!("symbolDescription"in a)&&b(a)&&delete r.symbolDescription;var i=c({},e);delete i.style,h.forEach(e=>delete i[e]);var s=c({},t);return delete s.style,c(c(c({},s),i),r)})(e,y)),{mappedDatasets:v,orderedDatasets:m}=D({datasets:l});t.createDataset&&$.attachCreateDataset(t.createDataset),$.attach(v,m,r);var f=d({datasets:u});o.requestOnce("menu:state",G),n({type:"SET_MENU",payload:{menu:f}}),n({type:"SET_DATASETS",payload:{mappedDatasets:v,orderedDatasets:m}}),t.init().then(()=>{$.forEachDataset(e=>{if(e.hasDynamicGeoJSON){var{dynamicGeoJSON:a}=e,r=F({dynamicGeoJSON:a,map:i.map,onUpdate:(e,a)=>t.setData(e,a)});p.set(e.id,r)}}),t.attachDynamicSources(p),o.emit("datasets:ready")});var g=()=>{t.onMapSizeChange()};o.on(s.MAP_SIZE_CHANGE,g);var S=o.emitWhenRequested("datasets:registry",$);return o.on("menu:changed",e=>{$.invalidateKeyItemsOnMenuStateChange(e),t.applyGlobalVisibility()}),{remove(){o.off(s.MAP_SIZE_CHANGE,g),S(),p.forEach(e=>e.destroy()),p.clear(),t.destroy()},refreshDataset(e){var t;null===(t=p.get(e))||void 0===t||t.refresh()},clearDatasetCache(e){var t;null===(t=p.get(e))||void 0===t||t.clear()},getFeatureCount(e){var t,a;return null!==(t=null===(a=p.get(e))||void 0===a?void 0:a.getFeatureCount())&&void 0!==t?t:null}}},ae=function(){var e=n(function*(e){switch(e.name){case"MapLibreProvider":var{default:t}=yield import(/* webpackChunkName: "im-datasets-ml-adapter" */ "./im-datasets-ml-adapter.js").then(function(e){return e.m});return t;case"EsriProvider":var{default:a}=yield import(/* webpackChunkName: "esriLayerAdapter" */ "./esriLayerAdapter.js");return a;default:throw new Error("No layer adapter available for map provider ".concat(e.name,". Please provide a compatible layer adapter."))}});return function(t){return e.apply(this,arguments)}}(),re={},ie=function(){var e=n(function*(e,t,a){var r,i,s=yield ae(e);return ee=new s(e,t,a),re.removeDataset=ee.removeDataset.bind(ee),re.setData=ee.setData.bind(ee),re.applyStyle=ee.applyStyle.bind(ee),re.applyDatasetVisibility=ee.applyDatasetVisibility.bind(ee),re.applyGlobalVisibility=ee.applyGlobalVisibility.bind(ee),re.applyDatasetOpacity=ee.applyDatasetOpacity.bind(ee),re.applyGlobalOpacity=ee.applyGlobalOpacity.bind(ee),re.addDataset=ee.addDataset.bind(ee),re.applyFeatureFilter=ee.applyFeatureFilter.bind(ee),re.onMapStyleChange=null===(r=ee.onMapStyleChange)||void 0===r?void 0:r.bind(ee),re.onMapSizeChange=null===(i=ee.onMapSizeChange)||void 0===i?void 0:i.bind(ee),ee});return function(t,a,r){return e.apply(this,arguments)}}();var se=function(e,t){var{pluginState:{dispatch:a}}=e,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{datasetId:i,sublayerId:s}=r,n=s?"".concat(i,"-").concat(s):i;a(n?{type:"SET_DATASET_VISIBILITY",payload:{datasetId:n,visible:t}}:{type:"SET_GLOBAL_VISIBILITY",payload:{visible:t}})},ne=e=>{var{menuGroupItem:t,onChange:i}=e,s=$.getDataset(t.id);if(!s)return null;var n=s.isSublayer?s.parentId:s.id,o=s.isSublayer?s.id:void 0,l="im-c-datasets-layers__item govuk-checkboxes govuk-checkboxes--small".concat(s.visible?"":" im-c-datasets-layers__item--checked");return a("div",{className:l,"data-module":"govuk-checkboxes",children:r("div",{className:"govuk-checkboxes__item",children:[a("input",{className:"govuk-checkboxes__input",id:s.id,"data-dataset-id":n,"data-sublayer-id":o,name:"layers",type:"checkbox",value:s.id,checked:s.isLocallyVisible,onChange:i}),a("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:s.id,children:s.label})]})},s.id)},oe=e=>{var{menuGroup:t,children:s}=e;if(!t.groupLabel)return a(i,{children:s});return a("div",{className:"govuk-form-group im-c-datasets-layers-group",children:r("fieldset",{className:"im-c-datasets-layers-group__fieldset",children:[a("legend",{className:"im-c-datasets-layers-group__legend",children:a("h3",{children:t.groupLabel})}),s]})},t.id)},le={InitComponent:function(a){var{pluginConfig:r,pluginState:i,appState:s,mapState:o,mapProvider:l,services:d}=a,{dispatch:p}=i,{eventBus:u,symbolRegistry:c,patternRegistry:y}=d,h=Boolean(null==l?void 0:l.isBaseMapReady());e(()=>{var e=!1!==r.hasMenu&&(e=>e.datasets.some(e=>{var t;return e.showInMenu||(null===(t=e.sublayers)||void 0===t?void 0:t.some(e=>e.showInMenu))}))(r);e||(u.emit(T.APP_REMOVE_PANEL,"datasetsLayers"),u.emit(T.APP_TOGGLE_BUTTON_STATE,{id:"datasetsLayers",prop:"hidden",value:!0}))},[r.hasMenu]),t(i).current=i;var v=t(null);return e(()=>{var e,t,a,i,d=null===(e=null===(t=r.includeModes)||void 0===t?void 0:t.includes(s.mode))||void 0===e||e,b=null!==(a=null===(i=r.excludeModes)||void 0===i?void 0:i.includes(s.mode))&&void 0!==a&&a;if(h&&d&&!b&&!v.current){var m=function(){var e=n(function*(){var e=yield ie(l,c,y);v.current=te({adapter:e,pluginConfig:r,mapStyle:o.mapStyle,mapProvider:l,events:T,dispatch:p,eventBus:u})});return function(){return e.apply(this,arguments)}}();m()}},[h,s.mode]),e(()=>{$.attach(i.mappedDatasets,i.orderedDatasets),u.emit("datasets:changed")},[i.mappedDatasets,i.orderedDatasets]),e(()=>{$.attachMapStyle(o.mapStyle),null!=re&&re.onMapStyleChange&&re.onMapStyleChange()},[o.mapStyle]),e(()=>{return e=i.globals,void(H=e);var e},[i.globals]),e(()=>{var{actionsArray:e}=i;e.length&&(e.forEach(e=>{var{method:t,parameters:a}=e;return re[t](...a)}),p({type:"REMOVE_ADAPTER_ACTIONS",payload:e}))},[i.actionsArray]),e(()=>()=>{v.current&&(v.current.remove(),v.current=null)},[]),null},reducer:{initialState:{globals:{visible:!0,opacity:1,opacityMode:"dataset"},key:{items:[],hasGroups:!1},mappedDatasets:{},orderedDatasets:[],actionsArray:[],menu:[]},actions:M},panels:[{id:"datasetsLayers",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:e=>{var{pluginState:t}=e,{menu:i=[]}=t,s=e=>{var{value:a,checked:r}=e.target;se({pluginState:t},r,{datasetId:a})},n=i.some(e=>e.groupLabel),o="im-c-datasets-layers".concat(n?" im-c-datasets-layers--has-groups":"");return a("div",{className:o,children:i.map(e=>r(oe,{menuGroup:e,children:[" ",e.items.map(e=>a(ne,{menuGroupItem:e,onChange:s},e.id))]},e.id))})}}],buttons:[{id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",iconId:"layers",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"layers",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addDataset:(e,t)=>{var{pluginState:{dispatch:a},mapState:r}=e;a({type:"ADD_DATASET",payload:{dataset:t,mapStyle:r.mapStyle}})},removeDataset:(e,t)=>{var{pluginState:{dispatch:a}}=e;re.removeDataset(t),a({type:"REMOVE_DATASET",payload:{id:t}})},setDatasetVisibility:se,setFeatureVisibility:function(e,t,a){var{pluginState:{dispatch:r}}=e,{datasetId:i=null}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(i){var s=$.getDataset(i);!s||s.idProperty||s.generateIds||_.warn('setFeatureVisibility: Dataset "'.concat(i,'" has no idProperty or generateIds configured. Features may not be matched correctly. Add idProperty to match by a feature property, or add generateIds: true to use auto-generated IDs.'))}r({type:t?"SHOW_FEATURES":"HIDE_FEATURES",payload:{datasetId:i,featureIds:a}})},setStyle:function(e,t){var{pluginState:{dispatch:a},mapState:r}=e,{datasetId:i,sublayerId:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};a({type:"SET_DATASET_STYLE",payload:{datasetId:i=s?"".concat(i,"-").concat(s):i,styleChanges:t,mapStyle:r.mapStyle}})},getStyle:function(e){var{_pluginState:t}=e,{datasetId:a,sublayerId:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a=r?"".concat(a,"-").concat(r):a;var i=$.getDataset(a);return i?i.style:(_.warn("getStyle: Dataset with id ".concat(a," not found")),null)},setOpacity:function(e,t){var{pluginState:{dispatch:a}}=e,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{datasetId:i,sublayerId:s}=r,n=s?"".concat(i,"-").concat(s):i;a(n?{type:"SET_OPACITY",payload:{datasetId:n,opacity:t}}:{type:"SET_GLOBAL_OPACITY",payload:{opacity:t}})},getOpacity:function(e){var t,{pluginState:{globals:a}}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{datasetId:i,sublayerId:s}=r,n=s?"".concat(i,"-").concat(s):i;if(n){var o,l=$.getDataset(n);return l?null!==(o=l.opacity)&&void 0!==o?o:null:(_.warn("getOpacity: Dataset with id ".concat(n," not found")),null)}return null!==(t=a.opacity)&&void 0!==t?t:null},setData:(e,t,a)=>{var{_pluginState:r}=e,{datasetId:i}=a,s=$.getDataset(i);s?null!=s&&s.tiles?_.warn('setData called on vector tile dataset "'.concat(i,'" — has no effect')):re.setData(i,t):_.warn("setData: Dataset with id ".concat(i," not found"))},setGlobals:(e,t)=>{var{pluginState:{dispatch:a}}=e,{opacityMode:r}=t,i={},s=!1;r&&(["dataset","global","multiply"].includes(r)?(s=!0,i.opacityMode=r):_.warn("Ignoring invalid opacityMode: ".concat(r,". Must be one of 'dataset', 'global' or 'multiply'."))),s?a({type:"SET_GLOBAL_STATE",payload:i}):_.warn("setGlobals: requires a valid value for opacityMode to be set")}}},de=Object.freeze({__proto__:null,manifest:le});export{J as D,$ as d,V as h,_ as l,de as m};
1
+ import{useEffect as e,useRef as t}from"preact/compat";import{jsx as a,jsxs as r,Fragment as i}from"preact/jsx-runtime";import s from"@babel/runtime/helpers/defineProperty";import n from"@babel/runtime/helpers/asyncToGenerator";function o(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function l(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?o(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var d=e=>{var{datasets:t=[]}=e,a=[],r=t.filter(e=>{var t;return e.showInMenu||(null===(t=e.sublayers)||void 0===t?void 0:t.some(e=>e.showInMenu))}),i=new Map;return r.forEach(e=>{var t;if(null!==(t=e.sublayers)&&void 0!==t&&t.length){var r=e.sublayers.filter(t=>e.showInMenu?!1!==t.showInMenu:t.showInMenu);if(!1===e.showInMenu&&!r.length)return;var s={id:e.id,groupLabel:e.label,visibleWhen:!0,type:"checkbox",items:r.map(t=>({id:"".concat(e.id,"-").concat(t.id),label:t.label}))};0===s.items.length&&(delete s.groupLabel,s.items.push({id:e.id,label:e.label})),a.push(s)}else if(e.groupLabel){var n=i.has(e.groupLabel)?i.get(e.groupLabel):{id:e.groupLabel,groupLabel:e.groupLabel,visibleWhen:!0,type:"checkbox",items:[]};i.has(e.groupLabel)||(i.set(e.groupLabel,n),a.push(n)),n.items.push({id:e.id,label:e.label})}else a.push({visibleWhen:!0,type:"checkbox",id:e.id,items:[{id:e.id,label:e.label}]})}),a},p=(e,t)=>e.reduce((e,a)=>{var r=a.items.filter(e=>!t.includes(e.id));return r.length&&e.push(l(l({},a),{},{items:r})),e},[]);function u(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function c(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?u(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):u(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var y={minZoom:6,maxZoom:24,showInKey:!1,showInMenu:!1,visible:!0,style:{stroke:"#d4351c",strokeWidth:2,symbolDescription:"red outline"}},h=["stroke","strokeWidth","strokeDashArray","fill","fillPattern","fillPatternSvgContent","fillPatternForegroundColor","fillPatternBackgroundColor","opacity","symbolDescription","keySymbolShape","symbol","symbolSvgContent","symbolViewBox","symbolAnchor","symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"],v=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"],b=e=>v.some(t=>t in e);function m(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function f(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?m(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):m(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var g=(e,t)=>{var a,{id:r}=t,i=(e=>{!0!==e.visible&&!1!==e.visible&&(e.visible="hidden"!==e.visibility);var t=c(c(c({},y),e),{},{style:c(c({},y.style),e.style)}),a=e.style||{};return!("symbolDescription"in a)&&b(a)&&delete t.style.symbolDescription,h.forEach(e=>delete t[e]),t})(t);t.parentId&&("showInKey"in t||delete i.showInKey,"showInMenu"in t||delete i.showInMenu),e[r]=i;var{orderedDatasets:s}=e;s.push(r);var n=null===(a=t.sublayers)||void 0===a?void 0:a.map(e=>((e,t)=>{var a="".concat(e,"-").concat(t.id),r=t.id;return"hidden"!==t.visibility&&(t.visibility="visible"),f(f({},t),{},{id:a,parentId:e,sublayerId:r})})(r,e));if(null!=n&&n.length){var o=null==n?void 0:n.map(e=>e.id),l=null==n?void 0:n.reduce(g,{orderedDatasets:s});return e[r].sublayerIds=o,delete e[r].sublayers,f(f(f({},e),l),{},{orderedDatasets:s})}return f(f({},e),{},{orderedDatasets:s})},D=e=>{var t=(e.datasets||[]).reduce(g,{orderedDatasets:[]}),{orderedDatasets:a}=t;return delete t.orderedDatasets,f(f({},e),{},{mappedDatasets:t,orderedDatasets:a})},S="[interactive-map]",_={warn:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return console.warn(S,...t)},error:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return console.error(S,...t)}};function O(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function P(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?O(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):O(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var E=function(e,t,a){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"not found";return!!e.mappedDatasets[t]||(_.error("".concat(a,": Dataset with id '").concat(t,"' ").concat(r)),!1)},A=0,I=(e,t,a)=>(A=a.actionsArray.length?A+1:0,P(P({},a),{},{actionsArray:[...a.actionsArray,{method:e,parameters:t,actionId:A}]})),M={SET_DATASETS:(e,t)=>{var{mappedDatasets:a,orderedDatasets:r}=t;return P(P({},e),{},{mappedDatasets:a,orderedDatasets:r})},ADD_DATASET:(e,t)=>{var{dataset:a,mapStyle:r}=t;if(e.mappedDatasets[a.id])return _.error("addDataset: Dataset with id '".concat(a.id,"' already exists")),e;var{mappedDatasets:i,orderedDatasets:s}=D({datasets:[a]}),n=((e,t)=>{var a=[...e.menu],r=d({datasets:[t]}),i=a.find(e=>e.groupLabel===r[0].groupLabel);return i?i.items.push(...r[0].items):a.push(...r),a})(e,a);return I("addDataset",[a.id,r],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),i),orderedDatasets:[...e.orderedDatasets,...s],menu:n}))},REMOVE_DATASET:(e,t)=>{var a,{id:r}=t;if(!E(e,r,"removeDataset"))return e;var i=P({},e.mappedDatasets),s=[r,...(null===(a=i[r])||void 0===a?void 0:a.sublayerIds)||[]];s.forEach(e=>delete i[e]);var n=e.orderedDatasets.filter(e=>!s.includes(e));return P(P({},e),{},{mappedDatasets:i,orderedDatasets:n,menu:p(e.menu,s)})},SET_DATASET_VISIBILITY:(e,t)=>{var{datasetId:a,visible:r}=t;return E(e,a,"setDatasetVisibility")?e.mappedDatasets[a].visible===r?e:I("applyDatasetVisibility",[a,r],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:P(P({},e.mappedDatasets[a]),{},{visible:r})})})):e},SET_GLOBAL_VISIBILITY:(e,t)=>{var{visible:a}=t;return I("applyGlobalVisibility",[a],P(P({},e),{},{globals:P(P({},e.globals),{},{visible:a})}))},SET_DATASET_STYLE:(e,t)=>{var{datasetId:a,styleChanges:r,mapStyle:i}=t;if(!E(e,a,"setDatasetStyle"))return e;var s=P(P({},e.mappedDatasets[a].style),r),n=P(P(P({},e.mappedDatasets[a]),r),{},{style:s});return I("applyStyle",[a,i],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:n})}))},SET_OPACITY:(e,t)=>{var{datasetId:a,opacity:r}=t;if(!E(e,a,"setOpacity"))return e;var i=P(P({},e.mappedDatasets[a].style),{},{opacity:r}),s=P(P({},e.mappedDatasets[a]),{},{style:i});return I("applyDatasetOpacity",[a],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:s})}))},SET_GLOBAL_OPACITY:(e,t)=>{var{opacity:a}=t;return I("applyGlobalOpacity",[],P(P({},e),{},{globals:P(P({},e.globals),{},{opacity:a})}))},HIDE_FEATURES:(e,t)=>{var{datasetId:a,featureIds:r}=t;if(!E(e,a,"setFeatureVisibility - hideFeatures"))return e;var i=P({},e.mappedDatasets[a]),s=i.hiddenFeatures||[],n=Array.from(new Set([...s,...r]));return i.hiddenFeatures=n,I("applyFeatureFilter",[a],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:i})}))},SHOW_FEATURES:(e,t)=>{var{datasetId:a,featureIds:r}=t;if(!E(e,a,"setFeatureVisibility - showFeatures"))return e;var i=P({},e.mappedDatasets[a]),s=(i.hiddenFeatures||[]).filter(e=>!r.includes(e));return i.hiddenFeatures=s.length?s:[-1],I("applyFeatureFilter",[a],P(P({},e),{},{mappedDatasets:P(P({},e.mappedDatasets),{},{[a]:i})}))},REMOVE_ADAPTER_ACTIONS:(e,t)=>null!=t&&t.length?P(P({},e),{},{actionsArray:e.actionsArray.filter(e=>!t.includes(e))}):e,SET_GLOBAL_STATE:(e,t)=>I("applyGlobalOpacity",[],P(P({},e),{},{globals:P(P({},e.globals),t)})),SET_MENU:(e,t)=>{var{menu:a}=t;return P(P({},e),{},{menu:a})}},T={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_FEATURES_SUPPRESSED:"map:setfeaturessuppressed",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"},w=function(){var e=n(function*(e,t,a,r){var i=a(e,t),s="string"==typeof i?{url:i}:i,{url:n,headers:o={}}=s,l=yield fetch(n,{headers:o,signal:r});if(!l.ok)throw new Error("Failed to fetch GeoJSON: ".concat(l.status," ").concat(l.statusText));var d=yield l.json();if("FeatureCollection"===d.type)return d;if("Feature"===d.type)return{type:"FeatureCollection",features:[d]};if(Array.isArray(d))return{type:"FeatureCollection",features:d};throw new Error("Invalid GeoJSON response")});return function(t,a,r,i){return e.apply(this,arguments)}}(),C=(e,t)=>!(!e||!t)&&!(e[2]<t[0]||e[0]>t[2]||e[3]<t[1]||e[1]>t[3]),j=e=>{var t=1/0,a=1/0,r=-1/0,i=-1/0,s=(e,n)=>{var o;0===n?(o=e,t=Math.min(t,o[0]),a=Math.min(a,o[1]),r=Math.max(r,o[0]),i=Math.max(i,o[1])):e.forEach(e=>s(e,n-1))};switch(e.type){case"Point":s(e.coordinates,0);break;case"LineString":case"MultiPoint":s(e.coordinates,1);break;case"Polygon":case"MultiLineString":s(e.coordinates,2);break;case"MultiPolygon":s(e.coordinates,3);break;case"GeometryCollection":e.geometries.forEach(e=>{var s=j(e);t=Math.min(t,s[0]),a=Math.min(a,s[1]),r=Math.max(r,s[2]),i=Math.max(i,s[3])});break;default:throw new Error("Unsupported geometry type: ".concat(e.type))}return[t,a,r,i]},L=e=>({type:"FeatureCollection",features:Array.from(e.values()).map(e=>e.feature)}),k=function(){var e=n(function*(e,t){var{map:a,dynamicGeoJSON:r,onUpdate:i}=t,{url:s,idProperty:n,transformRequest:o,maxFeatures:l,minZoom:d=0}=r,p=a.getZoom();if(!(p<d)){var u=(e=>{var t=e.getBounds();return[t.getWest(),t.getSouth(),t.getEast(),t.getNorth()]})(a);if(!(e.fetchedBbox&&(c=e.fetchedBbox,y=u,c&&y&&y[0]>=c[0]&&y[1]>=c[1]&&y[2]<=c[2]&&y[3]<=c[3]))){var c,y,h,v;e.currentController&&e.currentController.abort(),e.currentController=new AbortController;try{var b={bbox:u,zoom:p},m=yield w(s,b,o,e.currentController.signal);((e,t,a)=>{var r=Date.now();t.features.forEach(t=>{var i=((e,t)=>{var a,r;return t&&null!==(a=null===(r=e.properties)||void 0===r?void 0:r[t])&&void 0!==a?a:e.id})(t,a);null!=i?e.set(i,{feature:t,bbox:j(t.geometry),lastSeenAt:r}):console.warn("Feature missing ID, skipping:",t)})})(e.features,m,n),e.fetchedBbox=(h=e.fetchedBbox,v=u,h?[Math.min(h[0],v[0]),Math.min(h[1],v[1]),Math.max(h[2],v[2]),Math.max(h[3],v[3])]:[...v]);var f=e.features.size;((e,t,a)=>{if(a&&!(e.size<=1.2*a)){var r=a,i=[],s=[];for(var[n,o]of e)C(o.bbox,t)?i.push(n):s.push({id:n,lastSeenAt:o.lastSeenAt});s.sort((e,t)=>e.lastSeenAt-t.lastSeenAt);for(var l=e.size-r,d=0;d<l&&d<s.length;d++)e.delete(s[d].id);if(e.size>r)for(var p=e.size-r,u=i.map(t=>({id:t,lastSeenAt:e.get(t).lastSeenAt})).sort((e,t)=>e.lastSeenAt-t.lastSeenAt),c=0;c<p&&c<u.length;c++)e.delete(u[c].id)}})(e.features,u,l),e.features.size<f&&(e.fetchedBbox=u),i(r.id,L(e.features))}catch(e){if("AbortError"===e.name)return;console.error("Failed to fetch dynamic GeoJSON for ".concat(r.id,":"),e)}}}});return function(t,a){return e.apply(this,arguments)}}(),F=e=>{var t,a,r,i,{dynamicGeoJSON:s,map:n,onUpdate:o}=e,l={features:new Map,fetchedBbox:null,currentController:null},d=()=>k(l,{map:n,dynamicGeoJSON:s,onUpdate:o}),p=(t=d,a=200,(i=function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];clearTimeout(r),r=setTimeout(()=>t(...i),a)}).cancel=()=>{clearTimeout(r),r=null},i),u=()=>{p()};return n.on("moveend",u),d(),{destroy(){n.off("moveend",u),p.cancel(),l.currentController&&l.currentController.abort()},clear(){l.features.clear(),l.fetchedBbox=null,o(s.id,{type:"FeatureCollection",features:[]})},refresh(){l.features.clear(),l.fetchedBbox=null,d()},getFeatureCount:()=>l.features.size,reapply(){l.features.size>0&&o(s.id,L(l.features))}}},N={},G=e=>{N=e},x=e=>{var t,a=(null===(t=N)||void 0===t||null===(t=t.current)||void 0===t?void 0:t.menuState)||{};for(var[r,i]of Object.entries(e)){var s=a[r];if(!i.includes(s))return!1}return!0},R=e=>(Array.isArray(e)?e:[e]).includes(B()),B=()=>$.mapStyle.id,V=e=>{var t=0;for(var a of e)t=Math.trunc((t<<5)-t+a.codePointAt(0));return Math.abs(t).toString(36)};function U(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}class K{constructor(e){this.id=e.id,this.url=e.url,this.transformRequest=e.transformRequest,this.maxFeatures=e.maxFeatures,this.minZoom=e.minZoom,this.idProperty=e.idProperty,this.hiddenFeaturesIdExpression=["to-string",["get",this.idProperty]],this.sourceId="geojson-dynamic-".concat(this.id),this.source=function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?U(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):U(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}({type:"geojson",data:{type:"FeatureCollection",features:[]}},this.idProperty?{promoteId:this.idProperty}:{generateId:!0})}}var H={},W=(e,t)=>{switch(H.opacityMode){case"global":return H.opacity;case"multiply":return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Math.round(100*(e*t*H.opacity+Number.EPSILON))/100}(e,t);default:return((e,t)=>void 0===e?void 0===t?H.opacity:t:e)(e,t)}},Z=()=>H.visible;function z(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function Y(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?z(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):z(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}class J{constructor(e){this._datasetDefinition=e}get id(){return this._datasetDefinition.id}get label(){return this._datasetDefinition.label}get hasSymbol(){var e;return!this.hasSublayers&&Boolean(null===(e=this.style)||void 0===e?void 0:e.symbol)}get hasPattern(){return!(this.hasSublayers||this.hasSymbol||(e=this.style,!e.fillPattern&&!e.fillPatternSvgContent));var e}get hasFill(){var e,t;return!this.hasSublayers&&!this.hasSymbol&&(this.hasPattern||(null===(e=this.style)||void 0===e?void 0:e.fill)&&"transparent"!==(null===(t=this.style)||void 0===t?void 0:t.fill))}get hasStroke(){var e;return!this.hasSublayers&&!this.hasSymbol&&Boolean(null===(e=this.style)||void 0===e?void 0:e.stroke)}get tiles(){return this._datasetDefinition.tiles}get geojson(){return this._datasetDefinition.geojson}get idProperty(){return this._datasetDefinition.idProperty}get generateIds(){return this._datasetDefinition.generateIds}get parentId(){return this._datasetDefinition.parentId}get minZoom(){var e;return this._datasetDefinition.minZoom||(null===(e=this.parent)||void 0===e?void 0:e.minZoom)}get maxZoom(){var e;return this._datasetDefinition.maxZoom||(null===(e=this.parent)||void 0===e?void 0:e.maxZoom)}get type(){var e;return this._datasetDefinition.type||(null===(e=this.parent)||void 0===e?void 0:e.type)}get showInKey(){var e,t,a=this._datasetDefinition.showInKey;return void 0!==a?a:null!==(e=null===(t=this.parent)||void 0===t?void 0:t.showInKey)&&void 0!==e&&e}get visibleWhen(){var e;return void 0===this._datasetDefinition.visibleWhen?null===(e=this.parent)||void 0===e?void 0:e.visibleWhen:this._datasetDefinition.visibleWhen}get groupLabel(){var e,t;return this._datasetDefinition.groupLabel||(null===(e=this.parent)||void 0===e?void 0:e.groupLabel)||(null===(t=this.parent)||void 0===t?void 0:t.label)}get groupId(){var e,t=this._datasetDefinition.groupId||(null===(e=this.parent)||void 0===e?void 0:e.groupId);return t||(this.groupLabel?this.groupLabel.toLowerCase().replace(/\s+/g,"-"):null)}get opacity(){var e,t,a=null===(e=this.style)||void 0===e?void 0:e.opacity,r=null===(t=this.parent)||void 0===t||null===(t=t.style)||void 0===t?void 0:t.opacity;return W(a,r)}get hasDynamicGeoJSON(){return Boolean(this._datasetDefinition.dynamicGeoJSON)}get dynamicGeoJSON(){return new K(Y(Y({},this._datasetDefinition.dynamicGeoJSON),{},{id:this.id,minZoom:this.minZoom}))}get hiddenFeatures(){return this._datasetDefinition.hiddenFeatures}get hasHiddenFeatures(){var e,t;return Boolean((null===(e=this.hiddenFeatures)||void 0===e?void 0:e.length)>0||(null===(t=this.parent)||void 0===t?void 0:t.hasHiddenFeatures))}get filter(){return null}get isHiddenByInheritance(){var e;return this.isSublayer?!(null!==(e=this.parent)&&void 0!==e&&e.visible):!Z()}get isLocallyVisible(){return!!this.isVisible||this._datasetDefinition.visible}get visible(){var e;return this.isSublayer?this._datasetDefinition.visible&&(null===(e=this.parent)||void 0===e?void 0:e.visible):this._datasetDefinition.visible&&Z()}get esriStyleLayerId(){return this._datasetDefinition.esriStyleLayerId}get visibility(){var{visible:e,visibleWhen:t}=this;return e&&t?(e=>{if(null==e)return!0;if("boolean"==typeof e)return e;if("object"==typeof e){for(var[t,a]of Object.entries(e)){if("mapStyleId"===t&&!R(a))return!1;if("menu"===t&&!x(a))return!1}return!0}return!0})(t)?"visible":"none":e?"visible":"none"}get keyVisibility(){return this.showInKey&&"visible"===this.visibility}get symbolAnchor(){var e,t;return null!==(e=this.style)&&void 0!==e&&e.symbolAnchor?this.style.symbolAnchor:null===(t=this.parent)||void 0===t?void 0:t.symbolAnchor}get sourceLayer(){return this.isSublayer?this.parent.sourceLayer:this.tiles?this._datasetDefinition.sourceLayer:void 0}get isSublayer(){return Boolean(this._datasetDefinition.parentId)}get hasSublayers(){var e;return(null===(e=this._datasetDefinition.sublayerIds)||void 0===e?void 0:e.length)>0}get sublayerIds(){return this._datasetDefinition.sublayerIds}get sublayers(){var{sublayerIds:e}=this;return e?e.map(e=>$.getDataset(e)):[]}get parent(){if(this._datasetDefinition.parentId)return $.getDataset(this._datasetDefinition.parentId)}get style(){var e,t=null===(e=this.parent)||void 0===e?void 0:e.style;return t?Y(Y(Y({},t),{},{opacity:void 0},this._datasetDefinition.style),{},{symbolDescription:this.symbolDescription}):this._datasetDefinition.style||{}}get hasCustomVisualStyle(){return b(this._datasetDefinition.style||{})}get symbolDescription(){var e,t;return null!==(e=this._datasetDefinition.style)&&void 0!==e&&e.symbolDescription?this._datasetDefinition.style.symbolDescription:this.hasCustomVisualStyle||null===(t=this.parent)||void 0===t?void 0:t.symbolDescription}get patternConfigs(){var e=this.hasPattern?[this.style]:[];return this.hasSublayers?[...e,...this.sublayers.flatMap(e=>e.patternConfigs)]:e}get symbolConfigs(){var e=this.hasSymbol?[this.style]:[];return this.hasSublayers?[...e,...this.sublayers.flatMap(e=>e.symbolConfigs)]:e}get keyDefinition(){return{id:this.id,type:"dataset",label:this.label,hasSymbol:this.hasSymbol,hasPattern:this.hasPattern,style:this.style,symbolDescription:this.symbolDescription}}}class q{constructor(){this.idToDefinitionMap=new Map,this.definitionToInstanceMap=new Map}add(e){this.idToDefinitionMap.set(e.id,e._datasetDefinition),this.definitionToInstanceMap.set(e._datasetDefinition,e)}invalidateDataset(e){var t=this.idToDefinitionMap.get(e.id);[t.id,...(null==t?void 0:t.sublayerIds)||[]].forEach(e=>{var t=this.idToDefinitionMap.get(e);this.definitionToInstanceMap.delete(t),this.idToDefinitionMap.delete(e)})}invalidateChangedDatasets(e){e.forEach(e=>{var t=this.idToDefinitionMap.get(e.id);if(t&&t!==e){var a=this.definitionToInstanceMap.get(t);this.invalidateDataset(a.isSublayer&&a.parent?a.parent:a)}})}getByDefinition(e){return this.definitionToInstanceMap.get(e)}}function X(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function Q(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?X(Object(a),!0).forEach(function(t){s(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):X(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var $={attach(e,t,a){this._datasets=e,this._orderedDatasets=t,this.attachMapStyle(a),this._invalidateChangedDatasets()},_definitionCache:new q,_invalidateCache(){this._definitionCache=new q},_invalidateChangedDatasets(){this._datasets?this._definitionCache.invalidateChangedDatasets(Object.values(this._datasets)):this._invalidateCache()},attachCreateDataset(e){this._createDataset=e},_createDataset:e=>(e=>new J(e))(e),attachMapStyle(e){e&&(this._mapStyle=e)},get mapStyle(){return this._mapStyle},getDataset(e){var t=this.datasets[e];if(t){var a=this._definitionCache.getByDefinition(t);if(a)return a;var r=this._createDataset(t);return this._definitionCache.add(r),r.isSublayer&&this.getDataset(r.parentId),r}},forEach(e){this._orderedDatasets.forEach(t=>e(this.getDataset(t)))},forEachDataset(e){Object.values(this.datasets).filter(e=>!e.parentId).forEach(t=>e(this.getDataset(t.id)))},topLevelDatasets(){return Object.values(this.datasets).filter(e=>!e.parentId).map(e=>this.getDataset(e.id))},getPatternAndSymbolConfigs(){return this.topLevelDatasets().reduce((e,t)=>Q(Q({},e),{},{patternConfigs:[...e.patternConfigs,...t.patternConfigs],symbolConfigs:[...e.symbolConfigs,...t.symbolConfigs]}),{patternConfigs:[],symbolConfigs:[]})},_lastMenuState:{},invalidateKeyItemsOnMenuStateChange(e){e!==this._lastMenuState&&(this._lastMenuState=e,this._lastKeyItemsDatasets=null)},_lastKeyItems:{},keyItems(){if(this.datasets===this._lastKeyItemsDatasets)return this._lastKeyItems;this._lastKeyItemsDatasets=this.datasets;var e=[],t=new Map;this.forEach(a=>{if(a.keyVisibility)if(a.hasSublayers||a.groupLabel){var r=a.groupId,i=((a,r)=>{if(t.has(a))return t.get(a);var i={type:"group",id:r,groupLabel:a,keyDefinitions:[]};return t.set(a,i),e.push(i),i})(a.groupLabel||a.label,r);a.hasSublayers||i.keyDefinitions.push(a.keyDefinition)}else e.push({type:"flat",id:a.id,keyDefinition:a.keyDefinition})});var a=e.filter(e=>{var t;return"flat"===e.type||Boolean(null===(t=e.keyDefinitions)||void 0===t?void 0:t.length)}),r=a.some(e=>"group"===e.type);return this._lastKeyItems={items:a,hasGroups:r},this._lastKeyItems}};Object.defineProperty($,"datasets",{get:()=>$._datasets});var ee,te=e=>{var{adapter:t,pluginConfig:a,mapStyle:r,mapProvider:i,events:s,dispatch:n,eventBus:o}=e,{datasets:l}=a,p=new Map;a.globals&&n({type:"SET_GLOBAL_STATE",payload:a.globals});var u=l.map(e=>((e,t)=>{var a=e.style||{},r=c(c({},t.style),a);!("symbolDescription"in a)&&b(a)&&delete r.symbolDescription;var i=c({},e);delete i.style,h.forEach(e=>delete i[e]);var s=c({},t);return delete s.style,c(c(c({},s),i),r)})(e,y)),{mappedDatasets:v,orderedDatasets:m}=D({datasets:l});t.createDataset&&$.attachCreateDataset(t.createDataset),$.attach(v,m,r);var f=d({datasets:u});o.requestOnce("menu:state",G),n({type:"SET_MENU",payload:{menu:f}}),n({type:"SET_DATASETS",payload:{mappedDatasets:v,orderedDatasets:m}}),t.init().then(()=>{$.forEachDataset(e=>{if(e.hasDynamicGeoJSON){var{dynamicGeoJSON:a}=e,r=F({dynamicGeoJSON:a,map:i.map,onUpdate:(e,a)=>t.setData(e,a)});p.set(e.id,r)}}),t.attachDynamicSources(p),o.emit("datasets:ready")});var g=()=>{t.onMapSizeChange()};o.on(s.MAP_SIZE_CHANGE,g);var S=o.emitWhenRequested("datasets:registry",$);return o.on("menu:changed",e=>{$.invalidateKeyItemsOnMenuStateChange(e),t.applyGlobalVisibility()}),{remove(){o.off(s.MAP_SIZE_CHANGE,g),S(),p.forEach(e=>e.destroy()),p.clear(),t.destroy()},refreshDataset(e){var t;null===(t=p.get(e))||void 0===t||t.refresh()},clearDatasetCache(e){var t;null===(t=p.get(e))||void 0===t||t.clear()},getFeatureCount(e){var t,a;return null!==(t=null===(a=p.get(e))||void 0===a?void 0:a.getFeatureCount())&&void 0!==t?t:null}}},ae=function(){var e=n(function*(e){switch(e.name){case"MapLibreProvider":var{default:t}=yield import(/* webpackChunkName: "im-datasets-ml-adapter" */ "./im-datasets-ml-adapter.js").then(function(e){return e.m});return t;case"EsriProvider":var{default:a}=yield import(/* webpackChunkName: "esriLayerAdapter" */ "./esriLayerAdapter.js");return a;default:throw new Error("No layer adapter available for map provider ".concat(e.name,". Please provide a compatible layer adapter."))}});return function(t){return e.apply(this,arguments)}}(),re={},ie=function(){var e=n(function*(e,t,a){var r,i,s=yield ae(e);return ee=new s(e,t,a),re.removeDataset=ee.removeDataset.bind(ee),re.setData=ee.setData.bind(ee),re.applyStyle=ee.applyStyle.bind(ee),re.applyDatasetVisibility=ee.applyDatasetVisibility.bind(ee),re.applyGlobalVisibility=ee.applyGlobalVisibility.bind(ee),re.applyDatasetOpacity=ee.applyDatasetOpacity.bind(ee),re.applyGlobalOpacity=ee.applyGlobalOpacity.bind(ee),re.addDataset=ee.addDataset.bind(ee),re.applyFeatureFilter=ee.applyFeatureFilter.bind(ee),re.onMapStyleChange=null===(r=ee.onMapStyleChange)||void 0===r?void 0:r.bind(ee),re.onMapSizeChange=null===(i=ee.onMapSizeChange)||void 0===i?void 0:i.bind(ee),ee});return function(t,a,r){return e.apply(this,arguments)}}();var se=function(e,t){var{pluginState:{dispatch:a}}=e,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{datasetId:i,sublayerId:s}=r,n=s?"".concat(i,"-").concat(s):i;a(n?{type:"SET_DATASET_VISIBILITY",payload:{datasetId:n,visible:t}}:{type:"SET_GLOBAL_VISIBILITY",payload:{visible:t}})},ne=e=>{var{menuGroupItem:t,onChange:i}=e,s=$.getDataset(t.id);if(!s)return null;var n=s.isSublayer?s.parentId:s.id,o=s.isSublayer?s.id:void 0,l="im-c-datasets-layers__item govuk-checkboxes govuk-checkboxes--small".concat(s.visible?"":" im-c-datasets-layers__item--checked");return a("div",{className:l,"data-module":"govuk-checkboxes",children:r("div",{className:"govuk-checkboxes__item",children:[a("input",{className:"govuk-checkboxes__input",id:s.id,"data-dataset-id":n,"data-sublayer-id":o,name:"layers",type:"checkbox",value:s.id,checked:s.isLocallyVisible,onChange:i}),a("label",{className:"im-c-datasets-layers__item-label govuk-label govuk-checkboxes__label",htmlFor:s.id,children:s.label})]})},s.id)},oe=e=>{var{menuGroup:t,children:s}=e;if(!t.groupLabel)return a(i,{children:s});return a("div",{className:"govuk-form-group im-c-datasets-layers-group",children:r("fieldset",{className:"im-c-datasets-layers-group__fieldset",children:[a("legend",{className:"im-c-datasets-layers-group__legend",children:a("h3",{children:t.groupLabel})}),s]})},t.id)},le={InitComponent:function(a){var{pluginConfig:r,pluginState:i,appState:s,mapState:o,mapProvider:l,services:d}=a,{dispatch:p}=i,{eventBus:u,symbolRegistry:c,patternRegistry:y}=d,h=Boolean(null==l?void 0:l.isBaseMapReady());e(()=>{var e=!1!==r.hasMenu&&(e=>e.datasets.some(e=>{var t;return e.showInMenu||(null===(t=e.sublayers)||void 0===t?void 0:t.some(e=>e.showInMenu))}))(r);e||(u.emit(T.APP_REMOVE_PANEL,"datasetsLayers"),u.emit(T.APP_TOGGLE_BUTTON_STATE,{id:"datasetsLayers",prop:"hidden",value:!0}))},[r.hasMenu]),t(i).current=i;var v=t(null);return e(()=>{var e,t,a,i,d=null===(e=null===(t=r.includeModes)||void 0===t?void 0:t.includes(s.mode))||void 0===e||e,b=null!==(a=null===(i=r.excludeModes)||void 0===i?void 0:i.includes(s.mode))&&void 0!==a&&a;if(h&&d&&!b&&!v.current){var m=function(){var e=n(function*(){var e=yield ie(l,c,y);v.current=te({adapter:e,pluginConfig:r,mapStyle:o.mapStyle,mapProvider:l,events:T,dispatch:p,eventBus:u})});return function(){return e.apply(this,arguments)}}();m()}},[h,s.mode]),e(()=>{$.attach(i.mappedDatasets,i.orderedDatasets),u.emit("datasets:changed")},[i.mappedDatasets,i.orderedDatasets]),e(()=>{$.attachMapStyle(o.mapStyle),null!=re&&re.onMapStyleChange&&re.onMapStyleChange()},[o.mapStyle]),e(()=>{return e=i.globals,void(H=e);var e},[i.globals]),e(()=>{var{actionsArray:e}=i;e.length&&(e.forEach(e=>{var{method:t,parameters:a}=e;return re[t](...a)}),p({type:"REMOVE_ADAPTER_ACTIONS",payload:e}))},[i.actionsArray]),e(()=>()=>{v.current&&(v.current.remove(),v.current=null)},[]),null},reducer:{initialState:{globals:{visible:!0,opacity:1,opacityMode:"dataset"},key:{items:[],hasGroups:!1},mappedDatasets:{},orderedDatasets:[],actionsArray:[],menu:[]},actions:M},panels:[{id:"datasetsLayers",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:e=>{var{pluginState:t}=e,{menu:i=[]}=t,s=e=>{var{value:a,checked:r}=e.target;se({pluginState:t},r,{datasetId:a})},n=i.some(e=>e.groupLabel),o="im-c-datasets-layers".concat(n?" im-c-datasets-layers--has-groups":"");return a("div",{className:o,children:i.map(e=>r(oe,{menuGroup:e,children:[" ",e.items.map(e=>a(ne,{menuGroupItem:e,onChange:s},e.id))]},e.id))})}}],buttons:[{id:"datasetsLayers",label:"Layers",panelId:"datasetsLayers",iconId:"layers",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"layers",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'},{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addDataset:(e,t)=>{var{pluginState:{dispatch:a},mapState:r}=e;a({type:"ADD_DATASET",payload:{dataset:t,mapStyle:r.mapStyle}})},removeDataset:(e,t)=>{var{pluginState:{dispatch:a}}=e;re.removeDataset(t),a({type:"REMOVE_DATASET",payload:{id:t}})},setDatasetVisibility:se,setFeatureVisibility:function(e,t,a){var{pluginState:{dispatch:r}}=e,{datasetId:i=null}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(i){var s=$.getDataset(i);!s||s.idProperty||s.generateIds||_.warn('setFeatureVisibility: Dataset "'.concat(i,'" has no idProperty or generateIds configured. Features may not be matched correctly. Add idProperty to match by a feature property, or add generateIds: true to use auto-generated IDs.'))}r({type:t?"SHOW_FEATURES":"HIDE_FEATURES",payload:{datasetId:i,featureIds:a}})},setStyle:function(e,t){var{pluginState:{dispatch:a},mapState:r}=e,{datasetId:i,sublayerId:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};a({type:"SET_DATASET_STYLE",payload:{datasetId:i=s?"".concat(i,"-").concat(s):i,styleChanges:t,mapStyle:r.mapStyle}})},getStyle:function(e){var{_pluginState:t}=e,{datasetId:a,sublayerId:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a=r?"".concat(a,"-").concat(r):a;var i=$.getDataset(a);return i?i.style:(_.warn("getStyle: Dataset with id ".concat(a," not found")),null)},setOpacity:function(e,t){var{pluginState:{dispatch:a}}=e,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{datasetId:i,sublayerId:s}=r,n=s?"".concat(i,"-").concat(s):i;a(n?{type:"SET_OPACITY",payload:{datasetId:n,opacity:t}}:{type:"SET_GLOBAL_OPACITY",payload:{opacity:t}})},getOpacity:function(e){var t,{pluginState:{globals:a}}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{datasetId:i,sublayerId:s}=r,n=s?"".concat(i,"-").concat(s):i;if(n){var o,l=$.getDataset(n);return l?null!==(o=l.opacity)&&void 0!==o?o:null:(_.warn("getOpacity: Dataset with id ".concat(n," not found")),null)}return null!==(t=a.opacity)&&void 0!==t?t:null},setData:(e,t,a)=>{var{_pluginState:r}=e,{datasetId:i}=a,s=$.getDataset(i);s?null!=s&&s.tiles?_.warn('setData called on vector tile dataset "'.concat(i,'" — has no effect')):re.setData(i,t):_.warn("setData: Dataset with id ".concat(i," not found"))},setGlobals:(e,t)=>{var{pluginState:{dispatch:a}}=e,{opacityMode:r}=t,i={},s=!1;r&&(["dataset","global","multiply"].includes(r)?(s=!0,i.opacityMode=r):_.warn("Ignoring invalid opacityMode: ".concat(r,". Must be one of 'dataset', 'global' or 'multiply'."))),s?a({type:"SET_GLOBAL_STATE",payload:i}):_.warn("setGlobals: requires a valid value for opacityMode to be set")}}},de=Object.freeze({__proto__:null,manifest:le});export{J as D,$ as d,V as h,_ as l,de as m};