@defra/interactive-map 0.0.59-alpha → 0.0.60-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/templates/add-polygons.njk +2 -2
- package/assets/templates/add-symbols.njk +2 -2
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/panel-definition.md +30 -0
- package/docs/api/symbol-config.md +12 -0
- package/docs/api.md +21 -2
- package/docs/assets/images/slot-map.svg +3 -3
- package/docs/plugins/datasets.md +11 -1
- package/package.json +1 -1
- package/plugins/datasets/dist/esm/index.js +1 -1
- package/plugins/datasets/dist/esm/layerAdapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/index.js +1 -1
- package/plugins/datasets/src/index.js +0 -1
- package/plugins/datasets/src/index.test.js +2 -8
- package/plugins/datasets/src/registry/dataset.test.js +9 -0
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/src/components/Form/Form.module.scss +1 -0
- package/providers/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/esri/src/esriProvider.js +10 -21
- package/providers/esri/src/utils/coords.js +37 -7
- package/providers/esri/src/utils/coords.test.js +22 -1
- package/providers/esri/src/utils/spatial.js +1 -47
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/src/maplibreProvider.js +5 -14
- package/providers/maplibre/src/maplibreProvider.test.js +143 -146
- package/providers/maplibre/src/utils/spatial.js +0 -40
- package/providers/maplibre/src/utils/spatial.test.js +0 -35
- package/providers/openlayers/dist/esm/im-openlayers-provider.js +1 -1
- package/providers/openlayers/dist/umd/im-openlayers-provider.js +1 -1
- package/providers/openlayers/src/openlayersProvider.js +5 -14
- package/providers/openlayers/src/openlayersProvider.test.js +12 -10
- package/providers/openlayers/src/utils/spatial.js +0 -39
- package/providers/openlayers/src/utils/spatial.test.js +1 -26
- package/src/App/components/Hints/Hints.jsx +9 -21
- package/src/App/components/Hints/Hints.test.jsx +20 -33
- package/src/App/components/Panel/Panel.jsx +16 -1
- package/src/App/components/Panel/Panel.test.jsx +44 -0
- package/src/App/hooks/useCrossHairAPI.js +27 -28
- package/src/App/hooks/useCrossHairAPI.test.js +64 -7
- package/src/App/hooks/useLayoutMeasurements.js +175 -131
- package/src/App/hooks/useLayoutMeasurements.test.js +227 -122
- package/src/App/hooks/useMapProviderOverrides.js +114 -35
- package/src/App/hooks/useMapProviderOverrides.test.js +188 -5
- package/src/App/hooks/useModalPanelBehaviour.js +18 -32
- package/src/App/hooks/useModalPanelBehaviour.test.js +45 -33
- package/src/App/hooks/useVisibleGeometry.js +35 -45
- package/src/App/hooks/useVisibleGeometry.test.js +149 -121
- package/src/App/layout/Layout.jsx +4 -4
- package/src/App/layout/layout.module.scss +124 -61
- package/src/App/store/AppProvider.jsx +3 -0
- package/src/App/store/appDispatchMiddleware.js +18 -10
- package/src/App/store/appDispatchMiddleware.test.js +42 -4
- package/src/InteractiveMap/InteractiveMap.js +3 -2
- package/src/InteractiveMap/InteractiveMap.test.js +2 -2
- package/src/config/events.js +1 -1
- package/src/config/mapPanelSlots.js +8 -0
- package/src/config/symbolConfig.js +1 -1
- package/src/services/symbolRegistry.js +1 -1
- package/src/services/symbolRegistry.test.js +19 -0
- package/src/types.js +29 -8
- package/src/utils/getFitMove.js +73 -0
- package/src/utils/getFitMove.test.js +114 -0
- package/src/utils/getSafeZoneInset.js +122 -77
- package/src/utils/getSafeZoneInset.test.js +241 -54
- package/src/utils/getValueForStyle.js +10 -5
- package/src/utils/getValueForStyle.test.js +13 -2
- package/src/utils/renderedBoxes.js +25 -0
- package/src/utils/renderedBoxes.test.js +61 -0
- package/src/utils/screenBox.js +70 -0
- package/src/utils/screenBox.test.js +69 -0
- package/src/utils/symbolUtils.js +9 -9
- package/src/utils/symbolUtils.test.js +21 -0
- package/providers/esri/src/utils/spatial.test.js +0 -58
package/dist/esm/im-shell.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/regenerator";import r from"@babel/runtime/helpers/asyncToGenerator";import a from"@babel/runtime/helpers/objectWithoutProperties";import s from"@babel/runtime/helpers/createForOfIteratorHelper";import u from"@babel/runtime/helpers/objectSpread2";var l=["mapViewParamKey"],c=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)},d=function(e){var t=e.behaviour,n=e.hybridWidth,i=e.maxMobileWidth;if("hybrid"!==t)return!1;var o=null!=n?n:i;return window.matchMedia("(max-width: ".concat(o,"px)")).matches},p=function(e){var t=e.behaviour;return["mapOnly","buttonFirst"].includes(t)||d(e)};function h(){v.forEach(function(e){!function(e,t){var n;if(!1!==e.config.manageHistoryState){e._isClosingViaBack=!1;var i=e.id===t,o="hybrid"===e.config.behaviour&&!d(e.config),r=null===(n=e.rootEl)||void 0===n?void 0:n.children.length;!i||r&&!e._isHidden?i||!r||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,c(e.config.mapViewQueryParam))})}var v=new Map,f=!1;var m={register:function(e){f||(globalThis.addEventListener("popstate",h),f=!0),v.set(e.id,e)},unregister:function(e){v.delete(e.id),0===v.size&&(globalThis.removeEventListener("popstate",h),f=!1)}};function _(e){try{return JSON.parse(e)}catch(t){return e}}function y(e,t){e.innerHTML='<div class="im-c-error">'.concat(t,"</div>")}var b=function(e,t,n,i){return e!==t&&!(null!=n&&n.contains(e))&&e.matches(":not([aria-hidden]):not([data-fm-inert])")&&i.contains(e)};function A(e){var t,n=e.containerEl,i=e.isFullscreen,o=e.boundaryEl,r=void 0===o?document.body:o,a=Array.from(r.querySelectorAll("[data-fm-inert]"));if(n&&(a=a.filter(function(e){return!n.contains(e)})),a.forEach(function(e){e.removeAttribute("aria-hidden"),delete e.dataset.fmInert}),i){null===(t=document.activeElement)||void 0===t||t.blur();for(var u=n;null!==(l=u)&&void 0!==l&&l.parentNode&&u!==r&&u!==document.body;){var l,c,d=u.parentNode,p=s(d.children);try{for(p.s();!(c=p.n()).done;){var h=c.value;b(h,u,n,r)&&(h.setAttribute("aria-hidden","true"),h.dataset.fmInert="")}}catch(e){p.e(e)}finally{p.f()}u=d}}}function P(e){var t=e.id,n=e.behaviour,i=e.manageHistoryState;return"mapOnly"===n||("buttonFirst"===n?!1===i||c(e.mapViewQueryParam)===t:d(e)&&c(e.mapViewQueryParam)===t)}function E(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).isFullscreen,n=e.config,i=e.rootEl,o=n.pageTitle,r=n.behaviour,a=n.containerHeight,s=null!=t?t:P(n);["mapOnly","buttonFirst","hybrid"].includes(r)&&(A({containerEl:i,isFullscreen:s}),document.documentElement.classList.toggle("im-is-fullscreen",s),i.classList.toggle("im-is-fullscreen",s)),["buttonFirst","hybrid"].includes(r)&&function(e){var t=e.pageTitle,n=e.isFullscreen,i=document.title.split(": "),o=i[i.length-1];document.title=n?"".concat(t,": ").concat(o):o}({pageTitle:o,isFullscreen:s});var u=s||"buttonFirst"!==r&&!d(n)?a:"auto";return i.style.height=s?"100%":u,{isFullscreen:s}}function g(){document.body.classList.remove("im-is-loading")}var w="[interactive-map]",k={warn:function(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return(e=console).warn.apply(e,[w].concat(n))},error:function(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return(e=console).error.apply(e,[w].concat(n))}};var T={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",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_SET_APPLICATION_MODE:"app:setapplicationmode",APP_CLEAR_APPLICATION_MODE:"app:clearapplicationmode",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_SPATIAL_LIST:"map:setspatiallist",MAP_SET_SPATIAL_LIST_SUPPRESSED:"map:setspatiallistsuppressed",MAP_SET_ACTIVE_ITEM:"map:setactiveitem",MAP_SELECT_ITEM:"map:selectitem",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"};function S(e){var t=e.id,n=e.behaviour,i=c(e.mapViewQueryParam)===t;return["mapOnly","inline"].includes(n)||"hybrid"===n&&!d(e)||i}var O={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,enableMapControls:!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,mapControlsHintText:'A "map 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 M(e){var t,n=e.maxMobileWidth,i=e.minDesktopWidth,o=e.containerEl,r="unknown",a=new Set,s=function(e){e!==r&&(r=e,requestAnimationFrame(function(){r===e&&a.forEach(function(t){return t(e)})}))};if(o){var u=function(e,t,n){e.style.containerType="inline-size";var i=e.getBoundingClientRect().width,o=t(i);e.dataset.breakpoint=o;var r=new window.ResizeObserver(function(i){var o,r,a=(null===(o=i[0])||void 0===o||null===(o=o.borderBoxSize)||void 0===o||null===(o=o[0])||void 0===o?void 0:o.inlineSize)||(null===(r=i[0])||void 0===r?void 0:r.contentRect.width),s=t(a);e.dataset.breakpoint=s,n(s)});return r.observe(e),{initialType:o,cleanup:function(){r.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,i)},s);r=u.initialType,s(u.initialType),t=u.cleanup}else{var l=function(e,t,n){var i={mobile:window.matchMedia("(max-width: ".concat(e,"px)")),desktop:window.matchMedia("(min-width: ".concat(t,"px)"))},o=function(){var e="tablet";i.mobile.matches?e="mobile":i.desktop.matches&&(e="desktop"),n(e)};return i.mobile.addEventListener("change",o),i.desktop.addEventListener("change",o),o(),{cleanup:function(){i.mobile.removeEventListener("change",o),i.desktop.removeEventListener("change",o)}}}(n,i,s);t=l.cleanup}return{subscribe:function(e){return a.add(e),function(){return a.delete(e)}},getBreakpoint:function(){return r},destroy:function(){var e;null===(e=t)||void 0===e||e(),a.clear()}}}var B=window.matchMedia("(pointer: coarse)").matches?"touch":"unknown",L=new Set,x=new Set;var C=new Set(["Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape"]),D=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]);function R(e){B!==e&&(B=e,x.forEach(function(t){return t(e)}),L.forEach(function(t){return t(e)}))}function I(){var e=window.matchMedia("(pointer: coarse)"),t=function(e){R(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!==B&&(B=n,x.forEach(function(e){return e(n)}),setTimeout(function(){L.forEach(function(e){return e(n)})},150))},i=function(e){var t;("Tab"===e.key||C.has(e.key)&&(!(t=e.target)||"TEXTAREA"!==t.tagName&&!t.isContentEditable&&("INPUT"!==t.tagName||D.has(t.type))))&&R("keyboard")};return window.addEventListener("pointerdown",n,{passive:!0}),window.addEventListener("keydown",i,{passive:!0}),function(){e.removeEventListener("change",t),window.removeEventListener("pointerdown",n),window.removeEventListener("keydown",i)}}function N(){return"unknown"===B?(B="mouse","mouse"):B}function H(e){return L.add(e),function(){L.delete(e)}}var F=null;function U(e,t){var n=e.url,i=e.transformRequest,a=e.load;F=function(){var e=r(o().m(function e(r,s){var u;return o().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,a();case 1:return u=e.v,e.a(2,u(n,i,t,r,s))}},e)}));return function(t,n){return e.apply(this,arguments)}}()}function V(){return null!==F}function W(e,t){if(!F)throw new Error("ReverseGeocode not initialised");return F(e,t)}var j=function(){return i(function e(){n(this,e),this.events={},this._queued={}},[{key:"on",value:function(e,n){if(this.events[e]||(this.events[e]=[]),this.events[e].push(n),void 0!==this._queued[e]){try{n.apply(void 0,t(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,i=function(){n.off(e,i),t.apply(void 0,arguments)};return this.on(e,i)}},{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),i=1;i<t;i++)n[i-1]=arguments[i];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),i=1;i<t;i++)n[i-1]=arguments[i];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,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];var r="".concat(e,"Requested"),a="".concat(e,"Ready"),s=function(){return t.emit.apply(t,[a].concat(i))};return this.on(r,s),s(),function(){return t.off(r,s)}}},{key:"requestOnce",value:function(e,t){var n="".concat(e,"Requested"),i="".concat(e,"Ready");return this.once(i,t),this.emit(n,e),this}},{key:"destroy",value:function(){this.events={},this._queued={}}}])}();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 z=!Object.hasOwn;z&&(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)});var G="undefined"!=typeof AbortController&&!Object.getPrototypeOf((new AbortController).signal).throwIfAborted;G&&(Object.getPrototypeOf((new AbortController).signal).throwIfAborted=function(){if(this.aborted){var e=new Error("The operation was aborted.");throw e.name="AbortError",e}});if((G||z)&&"undefined"!=typeof URL&&URL.createObjectURL){var K="text/javascript",Q=["if(!Object.hasOwn){Object.hasOwn=function(o,k){return Object.prototype.hasOwnProperty.call(o,k)}}\n",G?'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(""),Y=URL.createObjectURL.bind(URL);if(URL.createObjectURL=function(e){return e instanceof Blob&&e.type===K&&(e=new Blob([Q,e],{type:K})),Y(e)},"undefined"!=typeof Worker){var Z=Worker;Worker=function(e,t){if("string"==typeof e&&!e.startsWith("blob:")&&"module"!==(null==t?void 0:t.type)){var n=new Blob(["".concat(Q,"importScripts(").concat(JSON.stringify(e),")")],{type:K});e=Y(n)}return new Z(e,t)},Worker.prototype=Z.prototype}}var J=function(){return i(function t(i){var o,r,a,s,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n(this,t),e(this,"_openButton",null),e(this,"_root",null),e(this,"_breakpointDetector",null),e(this,"_interfaceDetectorCleanup",null),e(this,"_hybridBehaviourCleanup",null),e(this,"_isHidden",!1),e(this,"_isClosingViaBack",!1),e(this,"_isLoading",!1),this.id=i,this.rootEl=document.getElementById(i),!this.rootEl)throw new Error('Element with id "'.concat(i,'" not found'));this.eventBus=new j,this.config=this._buildConfig(l),o=this.rootEl,r=this.config,a=r.mapProvider,s=r.deviceNotSupportedText,u=null==a?void 0:a.checkDeviceCapabilities(),(a?null!=u&&u.isSupported||(y(o,s),g(),k.warn(null==u?void 0:u.error),0):(k.warn("No map provider"),0))&&(["buttonFirst","hybrid"].includes(this.config.behaviour)&&m.register(this),this._breakpointDetector=M({maxMobileWidth:this.config.maxMobileWidth,minDesktopWidth:this.config.minDesktopWidth,containerEl:this.rootEl}),this._interfaceDetectorCleanup=I(),this._initialize())},[{key:"_buildConfig",value:function(e){var t=function(e){for(var t=u({},null==e?void 0:e.dataset),n={},i=0,o=Object.keys(t);i<o.length;i++){var r=o[i];n[r]=_(t[r])}return n}(this.rootEl);return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.mapViewParamKey,n=a(e,l),i=u(u({},O),n);return void 0!==t&&(console.warn("[InteractiveMap] mapViewParamKey is deprecated — use mapViewQueryParam instead."),i.mapViewQueryParam=t),"mapOnly"===i.behaviour&&i.hasExitButton&&(console.warn("[InteractiveMap] hasExitButton has no effect when behaviour is 'mapOnly' — there is nothing to exit to."),i.hasExitButton=!1),i}(u(u({id:this.id,title:document.title},t),e))}},{key:"_initialize",value:function(){var e,t=this;["buttonFirst","hybrid"].includes(this.config.behaviour)&&(this._openButton=function(e,t,n){var i=e.id,o=e.buttonText,r=e.buttonClass,a='\n <a class="'.concat(r,"\" 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 ");t.insertAdjacentHTML("beforebegin",a);var s=t.previousElementSibling,u=new URL(window.location.href);return u.searchParams.set(e.mapViewQueryParam,i),s.setAttribute("href",u.toString()),s.addEventListener("click",function(e){e.preventDefault(),n(e)}),s}(this.config,this.rootEl,function(e){t._handleButtonClick(e)})),this._hybridBehaviourCleanup=function(e){var t=e.config,n=t.behaviour,i=t.hybridWidth,o=t.maxMobileWidth;if("buttonFirst"===n&&e._breakpointDetector.subscribe(function(){S(e.config)?e.loadApp():e.removeApp()}),"hybrid"===n){var r=null!=i?i:o,a=window.matchMedia("(max-width: ".concat(r,"px)")),s=function(){if(S(e.config))if(e._isHidden)e.showApp();else if(null==e._root)e.loadApp();else{var t=E(e).isFullscreen;e.eventBus.emit(T.APP_FULLSCREEN_CHANGE,{isFullscreen:t})}else e._root&&e.hideApp()};return a.addEventListener("change",s),function(){return a.removeEventListener("change",s)}}return null}(this),S(this.config)?(P((e=this).config)||(E(e,{isFullscreen:!1}),g()),this.loadApp()):g()}},{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,i=this._removeMapParamFromUrl(location.href,n);history.replaceState(history.state,"",i)}else this.config.preserveStateOnClose?this.hideApp():this.removeApp()}},{key:"loadApp",value:(t=r(o().m(function e(){var t,n,i,r,a,s,l,c,d,p,h,v,f,m,_=this,b=arguments;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=(b.length>0&&void 0!==b[0]?b[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,import(/* webpackChunkName: "im-core" */ "./im-core.js");case 3:return i=e.v,r=i.initialiseApp,e.n=4,this.config.mapProvider.load();case 4:return a=e.v,s=a.MapProvider,l=a.mapFramework,c=a.mapProviderConfig,this.config.reverseGeocodeProvider&&U(this.config.reverseGeocodeProvider,c.crs),e.n=5,r(this.rootEl,u(u({id:this.id,initialBreakpoint:this._breakpointDetector.getBreakpoint(),initialInterfaceType:N(),focusOnMount:n},this.config),{},{MapProvider:s,mapProviderConfig:c,mapFramework:l,eventBus:this.eventBus,breakpointDetector:this._breakpointDetector,handleExitClick:this._handleExitClick.bind(this)}));case 5:d=e.v,this._root=d._root,delete d._root,p=new Set(["on","off","emit"]),Object.keys(d).forEach(function(e){p.has(e)||(_[e]=d[e])}),h=E(this),v=h.isFullscreen,this.eventBus.emit(T.APP_OPENED,{statePreserved:!1,isFullscreen:v}),e.n=7;break;case 6:throw e.p=6,m=e.v,null===(f=this._openButton)||void 0===f||f.removeAttribute("style"),y(this.rootEl,this.config.genericErrorText),console.error(m),m;case 7:return e.p=7,this._isLoading=!1,e.f(7);case 8:return e.a(2)}},e,this,[[2,6,7,8]])})),function(){return t.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()),E(this,{isFullscreen:!1}),this.eventBus.emit(T.APP_CLOSED,{statePreserved:!1}),this.eventBus.emit(T.MAP_DESTROY,{mapId:this.id})}},{key:"hideApp",value:function(){this._isHidden=!0,this.rootEl.style.display="none",A({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(T.APP_CLOSED,{statePreserved:!0})}},{key:"showApp",value:function(){this._isHidden=!1,this.rootEl.style.display="",this._openButton&&(this._openButton.style.display="none");var e=E(this).isFullscreen;this.eventBus.emit(T.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.unregister(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(T.APP_ADD_MARKER,{id:e,coords:t,options:n})}},{key:"updateMarker",value:function(e,t){this.eventBus.emit(T.APP_UPDATE_MARKER,{id:e,options:t})}},{key:"removeMarker",value:function(e){this.eventBus.emit(T.APP_REMOVE_MARKER,e)}},{key:"addButton",value:function(e,t){this.eventBus.emit(T.APP_ADD_BUTTON,{id:e,config:t})}},{key:"toggleButtonState",value:function(e,t,n){this.eventBus.emit(T.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(T.APP_ADD_PANEL,{id:e,config:t})}},{key:"removePanel",value:function(e){this.eventBus.emit(T.APP_REMOVE_PANEL,e)}},{key:"showPanel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.focus,i=void 0===n||n,o=t.triggeringElement,r=null!=o?o:document.activeElement&&document.activeElement!==document.body?document.activeElement:void 0;this.eventBus.emit(T.APP_SHOW_PANEL,{id:e,focus:i,triggeringElement:r})}},{key:"hidePanel",value:function(e){this.eventBus.emit(T.APP_HIDE_PANEL,e)}},{key:"setApplicationMode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.include,i=void 0===n?null:n,o=t.exclude,r=void 0===o?null:o;this.eventBus.emit(T.APP_SET_APPLICATION_MODE,{id:e,include:i,exclude:r})}},{key:"clearApplicationMode",value:function(e){this.eventBus.emit(T.APP_CLEAR_APPLICATION_MODE,e)}},{key:"addControl",value:function(e,t){this.eventBus.emit(T.APP_ADD_CONTROL,{id:e,config:t})}},{key:"showHint",value:function(e,t){this.eventBus.emit(T.APP_SHOW_HINT,{text:e,options:t})}},{key:"dismissHint",value:function(){this.eventBus.emit(T.APP_DISMISS_HINT)}},{key:"fitToBounds",value:function(e){this.eventBus.emitWhenReady(T.MAP_FIT_TO_BOUNDS,e)}},{key:"setView",value:function(e){this.eventBus.emitWhenReady(T.MAP_SET_VIEW,e)}},{key:"open",value:function(){this._isHidden?this.showApp():this._root||this.loadApp()}},{key:"close",value:function(){this._handleExitClick()}}]);var t}();export{T as E,J as I,N as a,g as b,p as g,V as h,k as l,W as r,H as s,A as t};
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/regenerator";import r from"@babel/runtime/helpers/asyncToGenerator";import a from"@babel/runtime/helpers/objectWithoutProperties";import s from"@babel/runtime/helpers/createForOfIteratorHelper";import u from"@babel/runtime/helpers/objectSpread2";var l=["mapViewParamKey"],c=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)},d=function(e){var t=e.behaviour,n=e.hybridWidth,i=e.maxMobileWidth;if("hybrid"!==t)return!1;var o=null!=n?n:i;return window.matchMedia("(max-width: ".concat(o,"px)")).matches},p=function(e){var t=e.behaviour;return["mapOnly","buttonFirst"].includes(t)||d(e)};function h(){v.forEach(function(e){!function(e,t){var n;if(!1!==e.config.manageHistoryState){e._isClosingViaBack=!1;var i=e.id===t,o="hybrid"===e.config.behaviour&&!d(e.config),r=null===(n=e.rootEl)||void 0===n?void 0:n.children.length;!i||r&&!e._isHidden?i||!r||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,c(e.config.mapViewQueryParam))})}var v=new Map,f=!1;var m={register:function(e){f||(globalThis.addEventListener("popstate",h),f=!0),v.set(e.id,e)},unregister:function(e){v.delete(e.id),0===v.size&&(globalThis.removeEventListener("popstate",h),f=!1)}};function _(e){try{return JSON.parse(e)}catch(t){return e}}function y(e,t){e.innerHTML='<div class="im-c-error">'.concat(t,"</div>")}var b=function(e,t,n,i){return e!==t&&!(null!=n&&n.contains(e))&&e.matches(":not([aria-hidden]):not([data-fm-inert])")&&i.contains(e)};function A(e){var t,n=e.containerEl,i=e.isFullscreen,o=e.boundaryEl,r=void 0===o?document.body:o,a=Array.from(r.querySelectorAll("[data-fm-inert]"));if(n&&(a=a.filter(function(e){return!n.contains(e)})),a.forEach(function(e){e.removeAttribute("aria-hidden"),delete e.dataset.fmInert}),i){null===(t=document.activeElement)||void 0===t||t.blur();for(var u=n;null!==(l=u)&&void 0!==l&&l.parentNode&&u!==r&&u!==document.body;){var l,c,d=u.parentNode,p=s(d.children);try{for(p.s();!(c=p.n()).done;){var h=c.value;b(h,u,n,r)&&(h.setAttribute("aria-hidden","true"),h.dataset.fmInert="")}}catch(e){p.e(e)}finally{p.f()}u=d}}}function P(e){var t=e.id,n=e.behaviour,i=e.manageHistoryState;return"mapOnly"===n||("buttonFirst"===n?!1===i||c(e.mapViewQueryParam)===t:d(e)&&c(e.mapViewQueryParam)===t)}function E(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).isFullscreen,n=e.config,i=e.rootEl,o=n.pageTitle,r=n.behaviour,a=n.containerHeight,s=null!=t?t:P(n);["mapOnly","buttonFirst","hybrid"].includes(r)&&(A({containerEl:i,isFullscreen:s}),document.documentElement.classList.toggle("im-is-fullscreen",s),i.classList.toggle("im-is-fullscreen",s)),["buttonFirst","hybrid"].includes(r)&&function(e){var t=e.pageTitle,n=e.isFullscreen,i=document.title.split(": "),o=i[i.length-1];document.title=n?"".concat(t,": ").concat(o):o}({pageTitle:o,isFullscreen:s});var u=s||"buttonFirst"!==r&&!d(n)?a:"auto";return i.style.height=s?"100%":u,{isFullscreen:s}}function g(){document.body.classList.remove("im-is-loading")}var w="[interactive-map]",k={warn:function(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return(e=console).warn.apply(e,[w].concat(n))},error:function(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return(e=console).error.apply(e,[w].concat(n))}};var T={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",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_SET_APPLICATION_MODE:"app:setapplicationmode",APP_CLEAR_APPLICATION_MODE:"app:clearapplicationmode",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_SPATIAL_LIST:"map:setspatiallist",MAP_SET_SPATIAL_LIST_SUPPRESSED:"map:setspatiallistsuppressed",MAP_SET_ACTIVE_ITEM:"map:setactiveitem",MAP_SELECT_ITEM:"map:selectitem",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"};function S(e){var t=e.id,n=e.behaviour,i=c(e.mapViewQueryParam)===t;return["mapOnly","inline"].includes(n)||"hybrid"===n&&!d(e)||i}var O={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,enableMapControls:!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,mapControlsHintText:'A "map 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 M(e){var t,n=e.maxMobileWidth,i=e.minDesktopWidth,o=e.containerEl,r="unknown",a=new Set,s=function(e){e!==r&&(r=e,requestAnimationFrame(function(){r===e&&a.forEach(function(t){return t(e)})}))};if(o){var u=function(e,t,n){e.style.containerType="inline-size";var i=e.getBoundingClientRect().width,o=t(i);e.dataset.breakpoint=o;var r=new window.ResizeObserver(function(i){var o,r,a=(null===(o=i[0])||void 0===o||null===(o=o.borderBoxSize)||void 0===o||null===(o=o[0])||void 0===o?void 0:o.inlineSize)||(null===(r=i[0])||void 0===r?void 0:r.contentRect.width),s=t(a);e.dataset.breakpoint=s,n(s)});return r.observe(e),{initialType:o,cleanup:function(){r.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,i)},s);r=u.initialType,s(u.initialType),t=u.cleanup}else{var l=function(e,t,n){var i={mobile:window.matchMedia("(max-width: ".concat(e,"px)")),desktop:window.matchMedia("(min-width: ".concat(t,"px)"))},o=function(){var e="tablet";i.mobile.matches?e="mobile":i.desktop.matches&&(e="desktop"),n(e)};return i.mobile.addEventListener("change",o),i.desktop.addEventListener("change",o),o(),{cleanup:function(){i.mobile.removeEventListener("change",o),i.desktop.removeEventListener("change",o)}}}(n,i,s);t=l.cleanup}return{subscribe:function(e){return a.add(e),function(){return a.delete(e)}},getBreakpoint:function(){return r},destroy:function(){var e;null===(e=t)||void 0===e||e(),a.clear()}}}var B=window.matchMedia("(pointer: coarse)").matches?"touch":"unknown",L=new Set,x=new Set;var C=new Set(["Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape"]),D=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]);function R(e){B!==e&&(B=e,x.forEach(function(t){return t(e)}),L.forEach(function(t){return t(e)}))}function I(){var e=window.matchMedia("(pointer: coarse)"),t=function(e){R(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!==B&&(B=n,x.forEach(function(e){return e(n)}),setTimeout(function(){L.forEach(function(e){return e(n)})},150))},i=function(e){var t;("Tab"===e.key||C.has(e.key)&&(!(t=e.target)||"TEXTAREA"!==t.tagName&&!t.isContentEditable&&("INPUT"!==t.tagName||D.has(t.type))))&&R("keyboard")};return window.addEventListener("pointerdown",n,{passive:!0}),window.addEventListener("keydown",i,{passive:!0}),function(){e.removeEventListener("change",t),window.removeEventListener("pointerdown",n),window.removeEventListener("keydown",i)}}function N(){return"unknown"===B?(B="mouse","mouse"):B}function H(e){return L.add(e),function(){L.delete(e)}}var F=null;function U(e,t){var n=e.url,i=e.transformRequest,a=e.load;F=function(){var e=r(o().m(function e(r,s){var u;return o().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,a();case 1:return u=e.v,e.a(2,u(n,i,t,r,s))}},e)}));return function(t,n){return e.apply(this,arguments)}}()}function V(){return null!==F}function W(e,t){if(!F)throw new Error("ReverseGeocode not initialised");return F(e,t)}var j=function(){return i(function e(){n(this,e),this.events={},this._queued={}},[{key:"on",value:function(e,n){if(this.events[e]||(this.events[e]=[]),this.events[e].push(n),void 0!==this._queued[e]){try{n.apply(void 0,t(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,i=function(){n.off(e,i),t.apply(void 0,arguments)};return this.on(e,i)}},{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),i=1;i<t;i++)n[i-1]=arguments[i];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),i=1;i<t;i++)n[i-1]=arguments[i];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,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];var r="".concat(e,"Requested"),a="".concat(e,"Ready"),s=function(){return t.emit.apply(t,[a].concat(i))};return this.on(r,s),s(),function(){return t.off(r,s)}}},{key:"requestOnce",value:function(e,t){var n="".concat(e,"Requested"),i="".concat(e,"Ready");return this.once(i,t),this.emit(n,e),this}},{key:"destroy",value:function(){this.events={},this._queued={}}}])}();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 z=!Object.hasOwn;z&&(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)});var G="undefined"!=typeof AbortController&&!Object.getPrototypeOf((new AbortController).signal).throwIfAborted;G&&(Object.getPrototypeOf((new AbortController).signal).throwIfAborted=function(){if(this.aborted){var e=new Error("The operation was aborted.");throw e.name="AbortError",e}});if((G||z)&&"undefined"!=typeof URL&&URL.createObjectURL){var K="text/javascript",Q=["if(!Object.hasOwn){Object.hasOwn=function(o,k){return Object.prototype.hasOwnProperty.call(o,k)}}\n",G?'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(""),Y=URL.createObjectURL.bind(URL);if(URL.createObjectURL=function(e){return e instanceof Blob&&e.type===K&&(e=new Blob([Q,e],{type:K})),Y(e)},"undefined"!=typeof Worker){var Z=Worker;Worker=function(e,t){if("string"==typeof e&&!e.startsWith("blob:")&&"module"!==(null==t?void 0:t.type)){var n=new Blob(["".concat(Q,"importScripts(").concat(JSON.stringify(e),")")],{type:K});e=Y(n)}return new Z(e,t)},Worker.prototype=Z.prototype}}var J=function(){return i(function t(i){var o,r,a,s,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n(this,t),e(this,"_openButton",null),e(this,"_root",null),e(this,"_breakpointDetector",null),e(this,"_interfaceDetectorCleanup",null),e(this,"_hybridBehaviourCleanup",null),e(this,"_isHidden",!1),e(this,"_isClosingViaBack",!1),e(this,"_isLoading",!1),this.id=i,this.rootEl=document.getElementById(i),!this.rootEl)throw new Error('Element with id "'.concat(i,'" not found'));this.eventBus=new j,this.config=this._buildConfig(l),o=this.rootEl,r=this.config,a=r.mapProvider,s=r.deviceNotSupportedText,u=null==a?void 0:a.checkDeviceCapabilities(),(a?null!=u&&u.isSupported||(y(o,s),g(),k.warn(null==u?void 0:u.error),0):(k.warn("No map provider"),0))&&(["buttonFirst","hybrid"].includes(this.config.behaviour)&&m.register(this),this._breakpointDetector=M({maxMobileWidth:this.config.maxMobileWidth,minDesktopWidth:this.config.minDesktopWidth,containerEl:this.rootEl}),this._interfaceDetectorCleanup=I(),this._initialize())},[{key:"_buildConfig",value:function(e){var t=function(e){for(var t=u({},null==e?void 0:e.dataset),n={},i=0,o=Object.keys(t);i<o.length;i++){var r=o[i];n[r]=_(t[r])}return n}(this.rootEl);return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.mapViewParamKey,n=a(e,l),i=u(u({},O),n);return void 0!==t&&(console.warn("[InteractiveMap] mapViewParamKey is deprecated — use mapViewQueryParam instead."),i.mapViewQueryParam=t),"mapOnly"===i.behaviour&&i.hasExitButton&&(console.warn("[InteractiveMap] hasExitButton has no effect when behaviour is 'mapOnly' — there is nothing to exit to."),i.hasExitButton=!1),i}(u(u({id:this.id,title:document.title},t),e))}},{key:"_initialize",value:function(){var e,t=this;["buttonFirst","hybrid"].includes(this.config.behaviour)&&(this._openButton=function(e,t,n){var i=e.id,o=e.buttonText,r=e.buttonClass,a='\n <a class="'.concat(r,"\" 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 ");t.insertAdjacentHTML("beforebegin",a);var s=t.previousElementSibling,u=new URL(window.location.href);return u.searchParams.set(e.mapViewQueryParam,i),s.setAttribute("href",u.toString()),s.addEventListener("click",function(e){e.preventDefault(),n(e)}),s}(this.config,this.rootEl,function(e){t._handleButtonClick(e)})),this._hybridBehaviourCleanup=function(e){var t=e.config,n=t.behaviour,i=t.hybridWidth,o=t.maxMobileWidth;if("buttonFirst"===n&&e._breakpointDetector.subscribe(function(){S(e.config)?e.loadApp():e.removeApp()}),"hybrid"===n){var r=null!=i?i:o,a=window.matchMedia("(max-width: ".concat(r,"px)")),s=function(){if(S(e.config))if(e._isHidden)e.showApp();else if(null==e._root)e.loadApp();else{var t=E(e).isFullscreen;e.eventBus.emit(T.APP_FULLSCREEN_CHANGE,{isFullscreen:t})}else e._root&&e.hideApp()};return a.addEventListener("change",s),function(){return a.removeEventListener("change",s)}}return null}(this),S(this.config)?(P((e=this).config)||(E(e,{isFullscreen:!1}),g()),this.loadApp()):g()}},{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,i=this._removeMapParamFromUrl(location.href,n);history.replaceState(history.state,"",i)}else this.config.preserveStateOnClose?this.hideApp():this.removeApp()}},{key:"loadApp",value:(t=r(o().m(function e(){var t,n,i,r,a,s,l,c,d,p,h,v,f,m,_=this,b=arguments;return o().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=(b.length>0&&void 0!==b[0]?b[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,import(/* webpackChunkName: "im-core" */ "./im-core.js");case 3:return i=e.v,r=i.initialiseApp,e.n=4,this.config.mapProvider.load();case 4:return a=e.v,s=a.MapProvider,l=a.mapFramework,c=a.mapProviderConfig,this.config.reverseGeocodeProvider&&U(this.config.reverseGeocodeProvider,c.crs),e.n=5,r(this.rootEl,u(u({id:this.id,initialBreakpoint:this._breakpointDetector.getBreakpoint(),initialInterfaceType:N(),focusOnMount:n},this.config),{},{MapProvider:s,mapProviderConfig:c,mapFramework:l,eventBus:this.eventBus,breakpointDetector:this._breakpointDetector,handleExitClick:this._handleExitClick.bind(this)}));case 5:d=e.v,this._root=d._root,delete d._root,p=new Set(["on","off","emit"]),Object.keys(d).forEach(function(e){p.has(e)||(_[e]=d[e])}),h=E(this),v=h.isFullscreen,this.eventBus.emit(T.APP_OPENED,{statePreserved:!1,isFullscreen:v}),e.n=7;break;case 6:throw e.p=6,m=e.v,null===(f=this._openButton)||void 0===f||f.removeAttribute("style"),y(this.rootEl,this.config.genericErrorText),console.error(m),m;case 7:return e.p=7,this._isLoading=!1,e.f(7);case 8:return e.a(2)}},e,this,[[2,6,7,8]])})),function(){return t.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()),E(this,{isFullscreen:!1}),this.eventBus.emit(T.APP_CLOSED,{statePreserved:!1}),this.eventBus.emit(T.MAP_DESTROY,{mapId:this.id})}},{key:"hideApp",value:function(){this._isHidden=!0,this.rootEl.style.display="none",A({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(T.APP_CLOSED,{statePreserved:!0})}},{key:"showApp",value:function(){this._isHidden=!1,this.rootEl.style.display="",this._openButton&&(this._openButton.style.display="none");var e=E(this).isFullscreen;this.eventBus.emit(T.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.unregister(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(T.APP_ADD_MARKER,{id:e,coords:t,options:n})}},{key:"updateMarker",value:function(e,t){this.eventBus.emit(T.APP_UPDATE_MARKER,{id:e,options:t})}},{key:"removeMarker",value:function(e){this.eventBus.emit(T.APP_REMOVE_MARKER,e)}},{key:"addButton",value:function(e,t){this.eventBus.emit(T.APP_ADD_BUTTON,{id:e,config:t})}},{key:"toggleButtonState",value:function(e,t,n){this.eventBus.emit(T.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(T.APP_ADD_PANEL,{id:e,config:t})}},{key:"removePanel",value:function(e){this.eventBus.emit(T.APP_REMOVE_PANEL,e)}},{key:"showPanel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.focus,i=void 0===n||n,o=t.triggeringElement,r=null!=o?o:document.activeElement&&document.activeElement!==document.body?document.activeElement:void 0;this.eventBus.emit(T.APP_SHOW_PANEL,{id:e,focus:i,triggeringElement:r})}},{key:"hidePanel",value:function(e){this.eventBus.emit(T.APP_HIDE_PANEL,e)}},{key:"setApplicationMode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.include,i=void 0===n?null:n,o=t.exclude,r=void 0===o?null:o;this.eventBus.emit(T.APP_SET_APPLICATION_MODE,{id:e,include:i,exclude:r})}},{key:"clearApplicationMode",value:function(e){this.eventBus.emit(T.APP_CLEAR_APPLICATION_MODE,e)}},{key:"addControl",value:function(e,t){this.eventBus.emit(T.APP_ADD_CONTROL,{id:e,config:t})}},{key:"showHint",value:function(e,t){this.eventBus.emit(T.APP_SHOW_HINT,{text:e,options:t})}},{key:"dismissHint",value:function(){this.eventBus.emit(T.APP_DISMISS_HINT)}},{key:"fitToBounds",value:function(e,t){this.eventBus.emitWhenReady(T.MAP_FIT_TO_BOUNDS,e,t)}},{key:"setView",value:function(e){this.eventBus.emitWhenReady(T.MAP_SET_VIEW,e)}},{key:"open",value:function(){this._isHidden?this.showApp():this._root||this.loadApp()}},{key:"close",value:function(){this._handleExitClick()}}]);var t}();export{T as E,J as I,N as a,g as b,p as g,V as h,k as l,W as r,H as s,A as t};
|