@minmaps-dev/mm-web-sdk 1.0.0-rc.13 → 1.0.0-rc.14
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +99 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +18 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/themes/alt3-hybrid-style.json +36 -0
- package/src/themes/high-contrast-style.json +0 -411
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("maplibre-gl"),e=require("pmtiles");function o(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:function(){return t[o]}})}}),e.default=t,Object.freeze(e)}var i=o(require("@turf/turf"));let n=!1;function r(o,i){const r="string"==typeof o?document.getElementById(o):o;if(!r)throw new Error("Map container not found");return function(){if(n)return;const o=new e.Protocol;t.addProtocol("pmtiles",o.tile),n=!0}(),new t.Map({container:r,style:i,center:[0,0],zoom:16,pitch:45,bearing:0,minPitch:30,maxPitch:55})}const s={ensureGeoJson(t,e){t.getSource(e)||t.addSource(e,{type:"geojson",data:{type:"FeatureCollection",features:[]}})},setData(t,e,o){const i=t.getSource(e);i?.setData?.(o)}},a="indoor-data",l="poi-data",c="unit-walls",u="route-data",d="poi-highlight-data",p=["boundary-fill","boundary-outline","units-fill","units-wall-extrusion","units-wall-custom-extrusion","corridors-fill","corridors-outline","building-extrusion"],g=()=>{};function f(t){const e=Boolean(t?.enabled),o=function(t){const e=String(t||"").trim();return e?`[${e}]`:""}(t?.prefix||"MinuteMapsSDK");return e?{debug:(...t)=>console.debug(o,...t),log:(...t)=>console.log(o,...t),warn:(...t)=>console.warn(o,...t),error:(...t)=>console.error(o,...t)}:{debug:g,log:g,warn:g,error:g}}f({enabled:!0,prefix:"MinuteMapsSDK"});const h={applyFloor(t,e,o=1){h.updateWalls(t,e,o),h.updateIndoor(t,e,o)},updateIndoor(t,e,o=1){const n=function(t,e){if(!t)return{type:"FeatureCollection",features:[]};if(!Number.isFinite(e)||e<=0)return t;const o=(t.features||[]).map(t=>{const o=t?.properties?.featureType;if(!o||!y.has(o))return t;const n=t?.geometry?.type;if("Polygon"!==n&&"MultiPolygon"!==n)return t;try{const o=i.buffer(t,-e,{units:"feet"});return o?.geometry?{...t,geometry:o.geometry}:t}catch{return t}});return{...t,features:o}}(e.geojson,o);s.setData(t,a,n);try{const t=e?.geojson?.features||[],o={};for(const e of t){const t=e?.properties?.featureType,i=null==t?"(missing)":String(t);o[i]=(o[i]||0)+1}Object.entries(o).sort((t,e)=>e[1]-t[1]).slice(0,15)}catch{}},updateWalls(t,e,o=1){const n=function(t,e=1){const o=Math.max(Number(e)||1,.5)/2,n=t=>{const e=t?.geometry?.type;if("Polygon"!==e&&"MultiPolygon"!==e)return null;try{const e=i.polygonToLine(t),n=i.buffer(e,o,{units:"feet"});return n?.geometry?n:null}catch{return null}},r=t=>{if(0===t.length)return null;if(1===t.length)return t[0];try{return i.union(i.featureCollection(t))}catch{return null}},s=[],a=[];for(const e of t.features||[]){const t=e?.properties?.featureType;if("Boundary"===t){const t=n(e);t&&s.push(t)}else if("Units"===t){const t=n(e);t&&a.push(t)}}const l=r(s),c=r(a);let u=c;if(c?.geometry&&l?.geometry)try{u=i.difference(i.featureCollection([c,l]))}catch{u=c}const d=[];l?.geometry&&d.push({type:"Feature",geometry:l.geometry,properties:{featureType:"UnitWalls",wallKind:"perimeter"}});u?.geometry&&d.push({type:"Feature",geometry:u.geometry,properties:{featureType:"UnitWalls",wallKind:"interior"}});return{type:"FeatureCollection",features:d}}(e.geojson,o);s.setData(t,c,n)},boundsFromGeoJson(t){try{const[e,o,n,r]=i.bbox(t),s=Math.min(e,n),a=Math.max(e,n),l=Math.min(o,r);return[[s,l],[a,Math.max(o,r)]]}catch{return null}},selectDefaultFloor:t=>Array.isArray(t)&&0!==t.length&&(t.find(t=>t.isDefault)||t[0])||null,selectInitialFloor(t,e){if(!Array.isArray(t)||0===t.length)return null;if(null!=e){const o=t.find(t=>t.id===e);if(o)return o}return h.selectDefaultFloor(t)},async activateFloor(t,e,o){if(!t)throw new Error("activateFloor requires an initialized map");if(e?.geojson&&h.applyFloor(t,e,o.wallFeet),await o.updatePOIs(e),!e?.geojson)return void(t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom));const i=h.boundsFromGeoJson(e.geojson);if(!i)return;const n=!o.didFit;let r=n;if(!r){const[[e,o],[n,s]]=i,a=t.getBounds();r=a.getWest()>n||a.getEast()<e||a.getSouth()>s||a.getNorth()<o}r?(t.fitBounds(i,{padding:o.boundsPadding,animate:!n,duration:700,bearing:t.getBearing(),pitch:t.getPitch()}),t.once("moveend",()=>{t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom)}),o.setDidFit(!0),o.log?.("camera :: fitToFloor",{floorId:e.id,animated:!n})):(t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom),o.log?.("camera :: fit skipped (floor overlaps viewport)",{floorId:e.id}))}},y=new Set(["Restrooms","Back-of-house","Obstacles","Escalators","Stairs","Elevators"]);class m{floors=[];currentFloor=null;didFit=!1;getMap;getConfig;updatePoiSource;logFn;constructor(t){this.getMap=t.getMap,this.getConfig=t.getConfig,this.updatePoiSource=t.updatePoiSource,this.logFn=t.log}log(...t){this.logFn&&this.logFn(...t)}setFloors(t){this.floors=t}getFloors(){return[...this.floors]}getCurrentFloor(){return this.currentFloor}setDidFit(t){this.didFit=t}getDefaultFloor(){return h.selectDefaultFloor(this.floors)}getInitialFloor(){const t=this.getConfig();return h.selectInitialFloor(this.floors,t.options?.initialFloor)}async setCurrentFloor(t){const e=this.getMap();if(!e)throw new Error("Map is not initialized");this.currentFloor=t,this.log("floor :: setCurrentFloor",{id:t.id,name:t.name,geojsonFeatures:t.geojson?.features?.length??0});const o=this.getConfig(),i=o.options?.wallThickness??1,n=o.options?.boundsPadding??50,r=o.options?.minIndoorZoom??16.5;await h.activateFloor(e,t,{wallFeet:i,updatePOIs:t=>this.updatePoiSource(t),didFit:this.didFit,setDidFit:t=>{this.didFit=t},boundsPadding:n,minIndoorZoom:r,log:(t,e)=>this.log(t,e)})}}const w=f({enabled:!0,prefix:"MinuteMapsSDK"}),b=new Map,F={async getSpriteKeys(t){const e=function(t){if(!t)return;if("string"==typeof t)return t;if(Array.isArray(t)){const e=t[0];if(e&&"string"==typeof e.url)return e.url}if("object"==typeof t&&null!==t){const e=t?.url;if("string"==typeof e)return e}return}(t?.getStyle?.()?.sprite);if(!e||"function"!=typeof fetch)return new Set;const o=e.endsWith(".json")?e:`${e}.json`;if(b.has(o))return b.get(o);try{const t=await fetch(o);if(!t.ok)throw new Error(`Failed to load sprite JSON (${t.status})`);const e=await t.json(),i=new Set(Object.keys(e||{}));return b.set(o,i),i}catch(t){w.warn("sprite fetch failed",o,t);const e=new Set;return b.set(o,e),e}}};const I=f({enabled:!0,prefix:"MinuteMapsSDK amenityIcons"});const x={async register(t,e,o={}){if(!Array.isArray(e)||0===e.length)return;const i=o.size??64;await Promise.all(e.map(async e=>{const n=function(t,e){const o=t?.uris;if(!Array.isArray(o)||0===o.length)return null;const i=t=>"image/svg+xml"===t?.mimeType||"svg-icon"===t?.resourceType,n=t=>{if(!Array.isArray(t)||0===t.length)return null;if(e){const o=t.find(t=>t?.locale===e);if(o?.uriPath)return o.uriPath}return t.find(t=>t?.uriPath)?.uriPath??null};for(const t of o){if(!i(t))continue;const e=n(t.locales);if(e)return e}for(const t of o){const e=n(t?.locales);if(e)return e}return null}(e,o.preferredLocale);if(!n)return;const r=`amenity-${e.id}`;if(t.hasImage(r))e.iconId=r;else try{const o=await async function(t,e){const o=await fetch(t,{mode:"cors"});if(!o.ok)throw new Error(`HTTP ${o.status}`);const i=await o.text();let n=i;try{const t=(new DOMParser).parseFromString(i,"image/svg+xml"),o=t.documentElement;!(t.getElementsByTagName("parsererror").length>0)&&o&&"svg"===o.nodeName.toLowerCase()&&(o.hasAttribute("width")||o.setAttribute("width",String(e)),o.hasAttribute("height")||o.setAttribute("height",String(e)),n=(new XMLSerializer).serializeToString(o))}catch{}const r=new Blob([n],{type:"image/svg+xml"}),s=URL.createObjectURL(r);return new Promise((t,e)=>{const o=new Image;o.onload=()=>{URL.revokeObjectURL(s),t(o)},o.onerror=t=>{URL.revokeObjectURL(s),e(t)},o.src=s})}(n,i);t.hasImage(r)||t.addImage(r,o),e.iconId=r}catch(t){I.warn("icon load failed",{amenityId:e.id,url:n,error:t?.message??String(t)})}}))}},v="units-outline-2d",A=["units-wall-extrusion","units-wall-custom-extrusion"];class S{getMap;is3dEnabled=!0;isUnits2dEnabled=!1;isFlatMode=!1;cachedExtrusionIds=null;extrusionOriginalVisibility=null;unitsExtrusionOriginalVisibility=null;unitsOutlineOriginalVisibility=null;constructor(t){this.getMap=t}onStyleData(){if(this.map){if(this.cachedExtrusionIds=null,!this.is3dEnabled){const t=this.listExtrusionLayerIds();this.setLayersVisibility(t,"none")}this.isUnits2dEnabled&&this.applyUnits2dVisibility(!0)}}set3dEnabled(t){const e=this.map;if(!e)return;const o=this.listExtrusionLayerIds();if(this.cachedExtrusionIds=o,!this.extrusionOriginalVisibility){const t={};o.forEach(o=>{try{const i=e.getLayoutProperty(o,"visibility")||"visible";t[o]=i}catch{t[o]="visible"}}),this.extrusionOriginalVisibility=t}if(t){const t=this.extrusionOriginalVisibility||{};o.forEach(o=>{const i=t[o]??"visible";try{e.getLayer(o)&&e.setLayoutProperty(o,"visibility",i)}catch{}})}else this.setLayersVisibility(o,"none");this.is3dEnabled=t,e.triggerRepaint()}toggle3d(){this.set3dEnabled(!this.is3dEnabled)}getIs3dEnabled(){return this.is3dEnabled}setUnits2dEnabled(t){const e=this.map;e&&(this.applyUnits2dVisibility(t),this.isUnits2dEnabled=t,e.triggerRepaint())}toggleUnits2d(){this.setUnits2dEnabled(!this.isUnits2dEnabled)}getIsUnits2dEnabled(){return this.isUnits2dEnabled}setFlatMode(t){this.map&&(t?(this.set3dEnabled(!1),this.setUnits2dEnabled(!0)):(this.setUnits2dEnabled(!1),this.set3dEnabled(!0)),this.isFlatMode=t)}toggleFlatMode(){this.setFlatMode(!this.isFlatMode)}getIsFlatMode(){return this.isFlatMode}applyUnits2dVisibility(t){const e=this.map;if(e){if(!this.unitsExtrusionOriginalVisibility){const t={};A.forEach(o=>{try{const i=e.getLayoutProperty(o,"visibility")||"visible";t[o]=i}catch{t[o]="visible"}}),this.unitsExtrusionOriginalVisibility=t}if(null==this.unitsOutlineOriginalVisibility)try{const t=e.getLayoutProperty(v,"visibility");this.unitsOutlineOriginalVisibility=t??"none"}catch{this.unitsOutlineOriginalVisibility="none"}if(e.getLayer(v)){const o=t?"visible":this.unitsOutlineOriginalVisibility??"none";try{e.setLayoutProperty(v,"visibility",o)}catch{}}if(t)A.forEach(t=>{if(e.getLayer(t))try{e.setLayoutProperty(t,"visibility","none")}catch{}});else{const t=this.unitsExtrusionOriginalVisibility||{};A.forEach(o=>{const i=t[o]??"visible";if(e.getLayer(o))try{e.setLayoutProperty(o,"visibility",i)}catch{}})}}}listExtrusionLayerIds(){const t=this.map;if(!t)return[];try{const e=t.getStyle(),o=e?.layers||[],i=o.filter(t=>"fill-extrusion"===t?.type).map(t=>t.id),n=Array.isArray(p)?p:[],r=[];return n.forEach(t=>{const e=o.find(e=>e.id===t);e&&"fill-extrusion"===e.type&&r.push(t)}),[...new Set([...i,...r])]}catch{return this.cachedExtrusionIds||[]}}setLayersVisibility(t,e){const o=this.map;o&&t.forEach(t=>{try{o.getLayer(t)&&o.setLayoutProperty(t,"visibility",e)}catch{}})}get map(){return this.getMap()}}function M(t){if(!t)return null;const e=t.getCenter(),o=(t,e=6)=>function(t,e=6){const o=Number(t.toFixed(e));return Object.is(o,-0)?0:o}(t,e);return{center:[o(e.lng),o(e.lat)],zoom:o(t.getZoom(),4),pitch:o(t.getPitch(),2),bearing:o(t.getBearing(),2)}}const k={async updatePOIs(t,e,o){const[i,n]=await Promise.all([o.getAmenities(e.id),o.getDestinations(e.id)]),r=k.buildPOIs(e,i,n,o.spriteKeys);s.setData(t,l,k.toFeatureCollection(r))},buildPOIs(t,e=[],o=[],i,n){if(!t?.id)return[];const r=t.mapId??t.id,s=[];for(const o of e||[]){if(!o.waypoints)continue;const e=o.iconId||z(o.svg,i)||void 0;for(const i of o.waypoints||[]){if(i.mapId!==r||!C(i.coordinates))continue;const[n,a]=i.coordinates,l=i.id??i._?.id;s.push({id:o.id,type:"amenity",name:o.name||"Amenity",coordinates:[n,a],iconId:e,floorId:t.id,amenityType:o.type,keywords:o.keywords||[],showLabel:!0,waypointId:l,waypoint:i})}}for(const e of o||[])if(e.waypoints)for(const o of e.waypoints||[]){if(o.mapId!==r||!C(o.coordinates))continue;const[i,n]=o.coordinates,a=o.id??o._?.id;s.push({id:e.id,type:"destination",name:e.name||"Destination",coordinates:[i,n],floorId:t.id,showLabel:!0,waypointId:a,waypoint:o})}return n&&String(n.floorId)===String(t.id)&&C(n.coordinates)&&s.push({id:"kiosk-you-are-here",type:"kiosk",name:"You are here",coordinates:n.coordinates,iconId:"YouAreHere",floorId:t.id,showLabel:!0,isYouAreHere:!0,waypointId:n.waypointId,waypoint:n.waypoint}),s},toFeatureCollection:t=>({type:"FeatureCollection",features:t.map(t=>({type:"Feature",geometry:{type:"Point",coordinates:t.coordinates},properties:{id:t.id,name:t.name,poiType:t.type,iconId:t.iconId,floorId:t.floorId,keywords:t.keywords,amenityType:t.amenityType,showLabel:!1!==t.showLabel,isYouAreHere:!0===t.isYouAreHere}}))})};function P(t){return t.find(t=>t.isYouAreHere)||null}function C(t){return Array.isArray(t)&&t.length>=2}function z(t,e){if(!t||!e)return null;const o=/<svg[^>]*\bid\s*=\s*["']([^"']+)["']/i.exec(t),i=o?.[1];return i&&e.has(i)?i:null}function E(t){const e=t=>(t??"").toLowerCase(),o=e(t.name),i=(t.keywords||[]).map(t=>e(t)),n=t.extensors||{},r=e(n.type),s="kiosk"===o||o.includes("kiosk"),a=i.some(t=>t.includes("kiosk"));return s||a||"assistance"===r}class T{deps;routeAnimationFrame=null;routeAnimationStart=null;routeAnimationDurationMs=1200;routeActive=!1;routeBounds=null;constructor(t){this.deps=t}buildWayfindFeatureCollection(t){if(!t)return this.deps.warn?.("wayfind :: no result"),null;const e=[],o=t=>{if(!t)return;const o=t.coordinates||t.xyz||t._?.coordinates;if(Array.isArray(o)&&o.length>=2){const t=Number(o[0]),i=Number(o[1]);Number.isFinite(t)&&Number.isFinite(i)&&e.push([t,i])}};return Array.isArray(t)?t.length>0&&Array.isArray(t[0]?.points)?t[0].points.forEach(o):t.forEach(o):Array.isArray(t.points)?t.points.forEach(o):Array.isArray(t.path)?t.path.forEach(o):Array.isArray(t.paths?.[0]?.points)&&t.paths[0].points.forEach(o),e.length<2?(this.deps.warn?.("wayfind :: not enough coordinates to draw a route",{resultShape:{isArray:Array.isArray(t),hasPoints:Array.isArray(t.points),hasPath:Array.isArray(t.path),hasPaths0Points:Array.isArray(t.paths?.[0]?.points)},extractedCount:e.length}),null):(this.deps.log?.("wayfind :: extracted coordinates for route",{count:e.length,first:e[0],last:e[e.length-1]}),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:e},properties:{}}]})}async wayfindBetweenWaypoints(t,e,o){const i=this.deps.getMap();if(!this.deps.getVenue()||!i)return this.deps.warn?.("wayfindBetweenWaypoints :: venue or map not ready"),null;let n=null;try{n=await this.deps.computeRoute(t,e)}catch(t){return this.deps.warn?.("wayfind :: computeRoute failed",t),null}this.deps.log?.("wayfind :: result",n);const r=this.buildWayfindFeatureCollection(n);if(!r)return n;s.setData(i,u,r),this.routeBounds=function(t){const e=t.features[0]?.geometry;if(!e||"LineString"!==e.type)return null;const o=e.coordinates;if(0===o.length)return null;let i=1/0,n=1/0,r=-1/0,s=-1/0;for(const[t,e]of o)t<i&&(i=t),t>r&&(r=t),e<n&&(n=e),e>s&&(s=e);return[[i,n],[r,s]]}(r),this.deps.log?.("wayfind :: route source updated",{featureCount:r.features.length}),this.startRouteAnimation();const a=o?.centerMode??"route",l=o?.zoom??19;if("none"!==a){const t=r.features[0]?.geometry;if(t&&"LineString"===t.type&&Array.isArray(t.coordinates)){const e=t.coordinates;if("destination"===a){const t=e[e.length-1];i.flyTo({center:t,zoom:l,pitch:45,bearing:0,animate:!0,duration:900})}else if("route"===a){const t=e.map(t=>t[0]),o=e.map(t=>t[1]),n=[[Math.min(...t),Math.min(...o)],[Math.max(...t),Math.max(...o)]];i.setMinPitch(0);const r=this.deps.getBoundsPadding();let s=null,a=0;for(const t of[1,.66,.4,.2,0])if(s=i.cameraForBounds(n,{padding:B(r,t),bearing:0}),s){a=t;break}const l=i.getContainer();this.deps.log?.("wayfind :: route fit",{requestedPadding:r,paddingScaleApplied:a,canvas:[l.clientWidth,l.clientHeight],camera:s?{zoom:s.zoom}:"no fit at any padding"}),s?i.easeTo({center:s.center,zoom:s.zoom-j,bearing:0,pitch:0,duration:800}):i.easeTo({pitch:0,bearing:0,duration:800})}}}return n}async navigateFromKioskToDestination(t){const e=this.deps.getMap(),o=this.deps.getVenue();if(!e||!o)return null;const i=this.deps.getYouAreHerePOI();if(!i||!i.waypoint)return this.deps.warn?.("navigateFromKioskToDestination :: no you-are-here waypoint available",i),null;const n=t.waypoint||t.waypoints?.[0];if(!n)return this.deps.warn?.("navigateFromKioskToDestination :: destination has no waypoint",t),null;this.deps.log?.("navigateFromKioskToDestination :: from kiosk to destination",{kioskWaypoint:i.waypoint,destWaypoint:n});const r=this.deps.getYouAreHereCoordinates()??i.waypoint?.coordinates,s=n.coordinates||n.xyz||n._?.coordinates,a=Array.isArray(s)&&s.length>=2?[Number(s[0]),Number(s[1])]:null;return r&&a?this.showRouteContext(r,a):this.deps.warn?.("navigateFromKioskToDestination :: could not derive endpoint coordinates",{fromCoords:r,rawDest:s}),this.wayfindBetweenWaypoints(i.waypoint,n,{centerMode:"route"})}clearRoute(){const t=this.deps.getMap();if(!t)return;this.stopRouteAnimation();s.setData(t,u,{type:"FeatureCollection",features:[]}),this.routeBounds=null,t.getMinPitch()<30&&(t.setMinPitch(30),t.easeTo({pitch:45,duration:400})),this.deps.log?.("wayfind :: route cleared")}getActiveRouteBounds(){return this.routeActive?this.routeBounds:null}setPoiLayersVisible(t){const e=this.deps.getMap();if(!e)return;const o=t?"visible":"none";["poi-accessibility-icons","poi-destination-circles","poi-destination-labels","poi-entrance-exit-icons","poi-parking-icons","poi-other-amenity-icons"].forEach(t=>{e.getLayer(t)&&e.setLayoutProperty(t,"visibility",o)})}updateRouteEndpoints(t,e){const o=this.deps.getMap();if(!o)return;const i=o.getSource("route-endpoints");if(!i)return;const n={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:t},properties:{role:"source"}},{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{role:"destination"}}]};i.setData(n)}clearRouteEndpoints(){const t=this.deps.getMap();if(!t)return;const e=t.getSource("route-endpoints");if(!e)return;e.setData({type:"FeatureCollection",features:[]})}showRouteContext(t,e){this.updateRouteEndpoints(t,e)}hideRouteContext(){this.setPoiLayersVisible(!0),this.clearRouteEndpoints()}startRouteAnimation(){if(!this.deps.getMap())return;if("undefined"==typeof window)return;null!=this.routeAnimationFrame&&(cancelAnimationFrame(this.routeAnimationFrame),this.routeAnimationFrame=null),this.routeAnimationStart=performance.now(),this.routeActive=!0;const t=this.deps.debug,e=o=>{const i=this.deps.getMap();if(!i||!this.routeActive||null==this.routeAnimationStart)return;const n=o-this.routeAnimationStart,r=Math.min(1,n/this.routeAnimationDurationMs),s=Math.max(.001,r);t&&this.deps.log?.("route animation frame",{t:r,clamped:s});const a=.001,l=Math.min(Math.max(s-.01,a),.998),c=Math.min(Math.max(s+.01,l+a),.999),u=["interpolate",["linear"],["line-progress"],0,"rgba(0,122,255,1.0)",l,"rgba(0,122,255,1.0)",c,"rgba(0,122,255,0.0)",1,"rgba(0,122,255,0.0)"],d=["interpolate",["linear"],["line-progress"],0,"rgba(255,255,255,0.7)",l,"rgba(255,255,255,0.7)",c,"rgba(255,255,255,0.0)",1,"rgba(255,255,255,0.0)"];i.getLayer("route-line")&&i.setPaintProperty("route-line","line-gradient",u),i.getLayer("route-halo")&&i.setPaintProperty("route-halo","line-gradient",d),this.routeAnimationFrame=r<1?requestAnimationFrame(e):null};this.routeAnimationFrame=requestAnimationFrame(e)}stopRouteAnimation(){this.routeActive=!1,null!=this.routeAnimationFrame&&"undefined"!=typeof window&&cancelAnimationFrame(this.routeAnimationFrame),this.routeAnimationFrame=null,this.routeAnimationStart=null;const t=this.deps.getMap();t&&(t.getLayer("route-line")&&(t.setPaintProperty("route-line","line-gradient",void 0),t.setPaintProperty("route-line","line-color","#007aff")),t.getLayer("route-halo")&&(t.setPaintProperty("route-halo","line-gradient",void 0),t.setPaintProperty("route-halo","line-color","#ffffff")))}}const j=1;function B(t,e){return"number"==typeof t?t*e:{top:t.top*e,bottom:t.bottom*e,left:t.left*e,right:t.right*e}}function L(t){const[e,o]=t.coordinates??[];return`${t.mapId}|${e}|${o}`}class O{getVenue;getFloors;getFloorById;logFn;constructor(t){this.getVenue=t.getVenue,this.getFloors=t.getFloors,this.getFloorById=t.getFloorById,this.logFn=t.log}get venue(){return this.getVenue()}log(...t){this.logFn&&this.logFn(...t)}loadForFloor(t){if(!t||!this.venue)return[];try{const e=this.venue.amenities?.getByMap(t.id)||[];return Array.isArray(e)?e.map(e=>{const o=e;return o.floorId=t.id,o}):[]}catch{return[]}}getAll(){return this.getFloors().flatMap(t=>this.loadForFloor(t))}getDistinct(){const t=new Map;for(const e of this.getFloors())for(const o of this.loadForFloor(e)){const e=String(o.id),i=t.get(e);if(!i){const i={id:o.id,name:o.name,svg:o.svg,uris:o.uris,iconId:o.iconId,keywords:o.keywords,type:o.type,extensors:o.extensors,waypoints:[...o.waypoints??[]]};t.set(e,i);continue}const n=new Set((i.waypoints??[]).map(L));for(const t of o.waypoints??[]){const e=L(t);n.has(e)||((i.waypoints??=[]).push(t),n.add(e))}}return Array.from(t.values())}getByFloorId(t){const e=this.getFloorById(t);return e?this.loadForFloor(e):[]}getAllKiosks(){return this.getAll().filter(t=>E(t))}getKioskForFloor(t){const e=this.getFloorById(t);if(!e)return null;return this.loadForFloor(e).find(t=>E(t))??null}logKioskForFloor(t){const e=this.getFloorById(t);if(!e)return;const o=this.getKioskForFloor(t);o?this.log("amenity :: kiosk found",{floorId:e.id,id:o.id,name:o.name,keywords:o.keywords,waypoints:o.waypoints,raw:o}):this.log("amenity :: kiosk not found on floor",{floorId:e.id})}}const U="poi-highlight-ring";class R{getMap;log;raf=null;constructor(t){this.getMap=t.getMap,this.log=t.log??(()=>{})}highlight(t){const e=this.getMap();e&&(s.setData(e,d,{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:t},properties:{}}]}),this.log("highlight :: set",t),this.startPulse())}clear(){this.stopPulse();const t=this.getMap();t&&s.setData(t,d,{type:"FeatureCollection",features:[]})}destroy(){this.stopPulse()}startPulse(){const t=this.getMap();if(!t||!t.getLayer(U))return;if(this.stopPulse(),"undefined"!=typeof window&&!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return void this.applyRing(t,.35);const e=performance.now(),o=i=>{const n=(i-e)%1600/1600;this.applyRing(t,n),this.raf=requestAnimationFrame(o)};this.raf=requestAnimationFrame(o)}applyRing(t,e){t.getLayer(U)&&(t.setPaintProperty(U,"circle-radius",14+26*e),t.setPaintProperty(U,"circle-opacity",.45*(1-e)))}stopPulse(){null!=this.raf&&(cancelAnimationFrame(this.raf),this.raf=null)}}f({enabled:!0,prefix:"MinuteMapsSDK"});class D{mode;proxyBaseUrl;direct;fetchImpl;tokenCache=null;constructor(t){const e="undefined"!=typeof window?window:globalThis,o=t.fetchImpl??e.fetch;if("function"!=typeof o)throw new Error("Fetch API is not available in this environment");this.fetchImpl=o.bind(e),this.mode=t.mode,this.proxyBaseUrl=("proxy"===t.mode?t.proxyBaseUrl:void 0)||"/api/jacs","direct"===t.mode?this.direct={host:this.normalizeHost(t.host),clientId:t.clientId,username:t.username,password:t.password}:this.direct=null}async getPolygonLayers(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/polygon-layer`,o=await this.getJson(e);return this.extractArray(o)}async getFloorMapTemplate3d(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor/${encodeURIComponent(String(t.floorId))}/map-template/3d`,o=await this.getJson(e);return this.extractArray(o)}async getFloors(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor`,o=await this.getJson(e);return this.extractArray(o)}async getVenueAll(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/all`,o=await this.getJson(e),i=o?.data||o?.result||o;if(!i||"object"!=typeof i)throw new Error("JACS venue/all response was not a JSON object");return i}async getVenue(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}`,o=await this.getJson(e),i=o?.venue||o?.data||o;if(!i||"object"!=typeof i)throw new Error("JACS venue response was not a JSON object");return i}async getFloorMapGeojson(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor/${encodeURIComponent(String(t.floorId))}/map/geojson`,o=await this.getJson(e),i=o?.geojson||o?.data||o;if(!i||"FeatureCollection"!==i.type||!Array.isArray(i.features))throw new Error("JACS floor geojson did not look like a GeoJSON FeatureCollection");return i}async getBuildingFull(t){const e=new URLSearchParams;e.set("mapProfile",String(t.mapProfile??"public")),e.set("geojson",String(t.geojson??!0));const o=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/full?${e.toString()}`,i=await this.getJson(o),n=i?.data||i?.result||i;if(!n||"object"!=typeof n)throw new Error("JACS building full response was not a JSON object");return n}async getDestinations(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/destination`,o=await this.getJson(e);return this.extractArray(o)}async getAmenities(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/amenity`,o=await this.getJson(e);return this.extractArray(o)}async getBuildings(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building`,o=await this.getJson(e);return this.extractArray(o)}async getStylesheet3d(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/stylesheet/3d`,o=await this.getJson(e),i=o?.style||o?.data||o;if(!i||"object"!=typeof i)throw new Error("JACS stylesheet response was not a JSON object");return i}invalidateToken(){this.tokenCache=null}async getJson(t){if("proxy"===this.mode){const e=this.proxyBaseUrl.replace(/\/+$/,""),o=t.startsWith("/")?t:`/${t}`,i=await this.fetchImpl(`${e}${o}`,{method:"GET",headers:{Accept:"application/json"}});if(!i.ok){const t=await this.safeReadText(i);throw new Error(`JACS proxy GET failed (${i.status} ${i.statusText}) :: ${t}`)}return await i.json()}const e=this.direct;if(!e)throw new Error("JacsProvider is not configured for direct mode");const o=await this.getJwtToken(),i=this.joinUrl(e.host,t),n=await this.fetchImpl(i,{method:"GET",headers:{Authorization:`Bearer ${o}`,Accept:"application/json"}});if(!n.ok){const t=await this.safeReadText(n);throw new Error(`JACS GET failed (${n.status} ${n.statusText}) :: ${t}`)}return await n.json()}extractArray(t){return(Array.isArray(t)?t:null)||(Array.isArray(t?.data)?t.data:null)||(Array.isArray(t?.items)?t.items:null)||(Array.isArray(t?.results)?t.results:null)||[]}async getJwtToken(){const t=this.direct;if(!t)throw new Error("getJwtToken should not be called in proxy mode");const e=Date.now(),o=this.tokenCache;if(o?.token&&e<o.expiresAtMs-3e4)return o.token;const i=this.joinUrl(t.host,"/auth/token"),n=new URLSearchParams;n.set("grant_type","password"),n.set("client_id",t.clientId),n.set("username",t.username),n.set("password",t.password);const r=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:n.toString()});if(!r.ok){const t=await this.safeReadText(r);throw new Error(`JACS auth failed (${r.status} ${r.statusText}) :: ${t}`)}const s=await r.json(),a=s?.access_token||s?.token||s?.jwt||s?.accessToken;if(!a)throw new Error("JACS auth response did not contain a token");const l=s?.expires_in??s?.expiresIn??s?.expires??s?.ttl,c="number"==typeof l?l:Number(l),u=Number.isFinite(c)&&c>0?c:600;return this.tokenCache={token:a,expiresAtMs:Date.now()+1e3*u},a}normalizeHost(t){return String(t||"").replace(/\/+$/,"")}joinUrl(t,e){const o=this.normalizeHost(t),i=String(e||"");return i?`${o}${i.startsWith("/")?"":"/"}${i}`:o}async safeReadText(t){try{return await t.text()}catch{return""}}}const $=f({enabled:!0,prefix:"MinuteMapsSDK jacs"});function V(t){return null!=t&&"object"==typeof t?t.id:t}class J{config;jacs;floors=[];buildingId=null;destinationsByMapId=new Map;amenitiesByMapId=new Map;venueLike=null;async init(t){this.config=t;const e=t.jacs;if(!e?.mode)throw new Error("config.jacs.mode is required");if("proxy"!==e.mode){if(!e.host)throw new Error("config.jacs.host is required (direct mode)");if(!e.auth?.clientId)throw new Error("config.jacs.auth.clientId is required (direct mode)");if(!e.auth?.username)throw new Error("config.jacs.auth.username is required (direct mode)");if(!e.auth?.password)throw new Error("config.jacs.auth.password is required (direct mode)");this.jacs=new D({mode:"direct",host:e.host,clientId:e.auth.clientId,username:e.auth.username,password:e.auth.password})}else this.jacs=new D({mode:"proxy",proxyBaseUrl:e.proxyBaseUrl||"/api/jacs"})}async loadVenue(){const t=this.config.jmap.customerId,e=this.config.jmap.venueId;if(null==t)throw new Error("config.jmap.customerId is required");if(null==e)throw new Error("config.jmap.venueId is required");const o=await this.jacs.getVenueAll({customerId:t,venueId:e}),i=Array.isArray(o?.buildings)?o.buildings:[],n=i[0],r=n?.id??n?.buildingId;if(!n||!r)throw new Error("No buildings found for this venue in /all response");this.buildingId=r;const s=Array.isArray(o?.waypoints)?o.waypoints:[],a=Array.isArray(o?.destinations)?o.destinations:[],l=Array.isArray(o?.amenities)?o.amenities:[],c=new Map;for(const t of s){const e=t?.mapId;if(null==e)continue;const o=c.get(e)??[];o.push(t),c.set(e,o)}const u=Array.isArray(n?.floors)?n.floors:[],d=n?.defaultFloorId,p=u.map(t=>{const e=t.map?.id??t.mapId;return{id:t.id,mapId:e,name:t.name??t.shortName??String(t.id),sequence:t.level??t.preference,isDefault:t.id===d,geojson:void 0,mapTemplate3d:[],_waypoints:null!=e?c.get(e)??[]:[]}});this.floors=p;const g=new Map;for(const t of p)null!=t.mapId&&g.set(t.mapId,t.id);const f=o?.venue?.coordinates,h=new Map;for(const t of u){const e=t?.map?.id??t?.mapId,o="string"==typeof t?.map?.svg?t.map.svg:"";if(null==e||!o)continue;const i=/viewBox\s*=\s*["']([^"']+)["']/i.exec(o);if(!i)continue;const n=i[1].trim().split(/\s+/).map(Number);if(4!==n.length||n.some(t=>!Number.isFinite(t)))continue;const[,,r,s]=n;r>0&&s>0&&h.set(e,{width:r,height:s})}const y=(t,e,o)=>{if(!f)return null;const i=h.get(t);if(!i)return null;return[f.topLng+e/i.width*(f.bottomLng-f.topLng),f.topLat+o/i.height*(f.bottomLat-f.topLat)]},m=new Map;for(const t of s){const e=t?.id;if(null!=e){if(!Array.isArray(t.coordinates)&&null!=t.x&&null!=t.y&&null!=t.mapId){const e=y(t.mapId,Number(t.x),Number(t.y));e&&(t.coordinates=e)}m.set(e,t)}}let w=null;const b=this.config?.jmap?.deviceId;if(null!=b&&""!==b){const t=(Array.isArray(o?.devices)?o.devices:[]).find(t=>String(t?.id)===String(b)||t?.uuid===b);if(t){const e=s.find(e=>Array.isArray(e?.deviceIds)&&e.deviceIds.includes(t.id));e&&Array.isArray(e.coordinates)?w={waypointId:e.id,floorId:g.get(e.mapId)??e.mapId,coordinates:e.coordinates,deviceName:t.name,waypoint:e}:$.warn("kiosk device has no placed waypoint",{deviceId:b})}else $.warn("kiosk device not found in venue devices",{deviceId:b})}const F=t=>Array.isArray(t)?t.map(t=>t&&"object"==typeof t?t:m.get(t)).filter(Boolean):[];for(const t of l)t.waypoints=F(t?.waypoints);for(const t of a)t.waypoints=F(t?.waypoints);this.amenitiesByMapId.clear();for(const t of l)for(const e of t?.waypoints??[]){const o=e?.mapId;if(null==o)continue;const i=g.get(o)??o,n=this.amenitiesByMapId.get(i)??[];n.push(t),this.amenitiesByMapId.set(i,n)}this.destinationsByMapId.clear();for(const t of a)for(const e of t?.waypoints??[]){const o=e?.mapId;if(null==o)continue;const i=g.get(o)??o,n=this.destinationsByMapId.get(i)??[];n.push(t),this.destinationsByMapId.set(i,n)}const I=o?.venue??{};return this.venueLike={...I,floors:p,polygonLayers:[],destinations:{items:[...a],getByMap:t=>this.destinationsByMapId.get(V(t))??[]},amenities:{items:[...l],getByMap:t=>this.amenitiesByMapId.get(V(t))??[]},buildings:{items:[...i],getAllFloors:()=>this.floors},styleSheet:null,kioskWaypoint:w},this.venueLike}async ensureFloorGeojson(t){if(t.geojson)return;const e=this.config.jmap.customerId,o=this.config.jmap.venueId;try{const i=await this.jacs.getFloorMapGeojson({customerId:e,venueId:o,buildingId:this.buildingId,floorId:t.id});t.geojson=function(t){return(t?.type?t:t?.data)??null}(i)}catch(e){$.warn("floor geojson fetch failed",{floorId:t.id,e:e})}}async preloadRemainingFloors(){const t=this.floors.filter(t=>!t.geojson);0!==t.length&&(await Promise.all(t.map(t=>this.ensureFloorGeojson(t))),$.debug("preloaded geojson for remaining floors",{count:t.length}))}async getFloors(){return this.floors}async getAmenities(t){return this.amenitiesByMapId.get(t)??[]}async getDestinations(t){return this.destinationsByMapId.get(t)??[]}}class K{handlers=new Map;on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){e?this.handlers.get(t)?.delete(e):this.handlers.delete(t)}emit(t,e){this.handlers.get(t)?.forEach(t=>{try{t(e)}catch{}})}}var N={version:8,name:"Hospital Indoor Mapping - Hybrid Style Healthcare Compliant",metadata:{description:"Accessibility-focused hospital navigation with proper healthcare standards",author:"Hospital Mapping Team",version:"7.1.0"},sprite:"http://localhost:4000/sprites/sprite",glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",sources:{protomaps:{type:"vector",url:"pmtiles://https://jacsdevtiles-gjgbejbpdzbgcge8.z01.azurefd.net/pmtiles/base/usa.pmtiles",attribution:"© OpenStreetMap contributors"},"indoor-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"poi-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"accessibility-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"unit-walls":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"route-data":{type:"geojson",data:{type:"FeatureCollection",features:[]},lineMetrics:!0},"route-endpoints":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"poi-highlight-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}}},layers:[{id:"background",type:"background",paint:{"background-color":"#f0f0f0"}},{id:"basemap-earth",type:"fill",source:"protomaps","source-layer":"earth",paint:{"fill-color":"#EFEAE0"}},{id:"basemap-landuse-park",type:"fill",source:"protomaps","source-layer":"landuse",filter:["in",["get","kind"],["literal",["park","forest","wood","nature_reserve","grass","garden","playground","cemetery","golf_course"]]],paint:{"fill-color":"#dde8d4","fill-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"basemap-water",type:"fill",source:"protomaps","source-layer":"water",paint:{"fill-color":"#d9e8f6"}},{id:"basemap-roads-minor",type:"line",source:"protomaps","source-layer":"roads",minzoom:13,filter:["in",["get","kind"],["literal",["minor_road","path","service","other"]]],paint:{"line-color":"#FFFFFF","line-width":["interpolate",["linear"],["zoom"],13,.5,16,1.5,19,4],"line-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"basemap-roads-major",type:"line",source:"protomaps","source-layer":"roads",minzoom:10,filter:["in",["get","kind"],["literal",["highway","major_road","medium_road"]]],paint:{"line-color":"#ecc97e","line-width":["interpolate",["linear"],["zoom"],10,.5,14,1.5,18,6],"line-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"pattern-water",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Water"],paint:{"fill-color":"#cfe1ec","fill-opacity":.6}},{id:"pattern-grass",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Grass"],paint:{"fill-color":"#d2e0c6","fill-opacity":.5}},{id:"pattern-trees",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Trees"],paint:{"fill-color":"#cdd9c9","fill-opacity":.4}},{id:"pattern-pavement",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Pavement"],paint:{"fill-color":"#E0E0E0","fill-opacity":.6}},{id:"pattern-outdoor-terrace",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-OutdoorTerrace"],paint:{"fill-color":"#cabfb6","fill-opacity":.3}},{id:"parking-lots",type:"fill",source:"indoor-data",filter:["==",["get","featureType"],"Parking-Lots"],paint:{"fill-color":"#e0e0dd","fill-opacity":.5}},{id:"parking-lots-outline",type:"line",source:"indoor-data",filter:["==",["get","featureType"],"Parking-Lots"],paint:{"line-color":"#b0b0ad","line-width":1,"line-dasharray":[3,2]}},{id:"boundary-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],paint:{"fill-color":"#FAF3E2","fill-opacity":1}},{id:"building-roof-fill",type:"fill",source:"indoor-data",minzoom:15.8,filter:["==",["get","featureType"],"Boundary"],paint:{"fill-color":"#162e51","fill-opacity":["interpolate",["linear"],["zoom"],15.8,0,16.5,1]}},{id:"corridors-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],paint:{"fill-color":"#F0E6D1"}},{id:"accessible-routes",type:"line",source:"accessibility-data",minzoom:16.5,filter:["==",["get","accessible"],!0],paint:{"line-color":"#2E7D32","line-width":["interpolate",["linear"],["zoom"],15,2,18,3,20,4],"line-dasharray":[.5,1],"line-opacity":.7}},{id:"units-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Units"],paint:{"fill-color":["case",["has","category"],["match",["get","category"],"healthcare","#73b3e7","surgical","#73b3e7","waiting","#73b3e7","diagnostic","#97d4ea","amenities","#97d4ea","emergency","#f2938c","retail","#fee685","fnb","#fee685","admin","#dfe1e2","staff","#dfe1e2","security","#dfe1e2","#73b3e7"],"#73b3e7"],"fill-opacity":["interpolate",["linear"],["zoom"],15,.85,17,.92,19,.95]}},{id:"units-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Units"],layout:{visibility:"none","line-join":"round","line-cap":"round"},paint:{"line-color":"#162e51","line-opacity":.9,"line-width":["interpolate",["linear"],["zoom"],16,.8,18,1.4,20,2.2]}},{id:"backofhouse-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"fill-color":"#e6e6e2","fill-opacity":.7}},{id:"backofhouse-pattern",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"line-color":"#c4c4c4","line-width":.5,"line-opacity":.4}},{id:"backofhouse-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#b0b1b5","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"restrooms-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],paint:{"fill-color":"#5f9070","fill-opacity":1}},{id:"restrooms-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#3f5d4a","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"obstacles-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],paint:{"fill-color":"#E8E9ED","fill-opacity":.85}},{id:"obstacles-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#B0B1B5","line-width":["interpolate",["linear"],["zoom"],16,.5,18,.9,20,1.2],"line-opacity":.9}},{id:"escalators-stairs-elevators",type:"fill",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],paint:{"fill-color":"#a9aeb1","fill-opacity":1}},{id:"escalators-stairs-elevators-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#6f7780","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"exits-doors",type:"fill",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Exits","Doors","Exit","Door"]]],paint:{"fill-color":"#cdd9c9","fill-opacity":.6}},{id:"kiosks-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Kiosks"],paint:{"fill-color":"#ffe396","fill-opacity":.7}},{id:"pattern-lounge",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Lounge"],paint:{"fill-color":"#ddd2e0","fill-opacity":.5}},{id:"pattern-indoor-foodcourt",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-IndoorFoodcourt"],paint:{"fill-color":"#f3e4c4","fill-opacity":.6}},{id:"corridors-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],paint:{"line-color":"#BCAAA4","line-width":["interpolate",["linear"],["zoom"],15,.5,18,1,20,1.5]}},{id:"boundary-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],paint:{"line-color":"#263238","line-width":["interpolate",["linear"],["zoom"],12,2,15,2.5,18,3,20,3.5],"line-opacity":["interpolate",["linear"],["zoom"],12,.7,17,.85,18,1]}},{id:"building-roof-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#c8a85a","line-width":["interpolate",["linear"],["zoom"],15,1.5,18,2,20,2.5],"line-opacity":.55}},{id:"interior-parking-lots",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"fill-color":"#757575","fill-opacity":.8}},{id:"interior-parking-lots-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"line-color":"#616161","line-width":1.5}},{id:"building-extrusion",type:"fill-extrusion",source:"indoor-data",filter:["==",["get","featureType"],"Boundary"],paint:{"fill-extrusion-color":"#162e51","fill-extrusion-height":15,"fill-extrusion-base":0,"fill-extrusion-opacity":["interpolate",["linear"],["zoom"],15.8,1,16.5,0]}},{id:"units-wall-extrusion",type:"fill-extrusion",source:"unit-walls",minzoom:16.5,filter:["all",["==",["get","featureType"],"UnitWalls"],["!",["has","custom_height"]]],paint:{"fill-extrusion-color":"#c4c8cb","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,["case",["==",["get","wallKind"],"interior"],.5,1],17.5,["case",["==",["get","wallKind"],"interior"],.7,1.4],18.2,["case",["==",["get","wallKind"],"interior"],.9,1.6]],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":1}},{id:"units-wall-custom-extrusion",type:"fill-extrusion",source:"unit-walls",minzoom:16.5,filter:["has","custom_height"],paint:{"fill-extrusion-color":"#c4c8cb","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":1}},{id:"corridors-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],layout:{visibility:"none"},paint:{"fill-extrusion-color":"#FFF8E1","fill-extrusion-height":["step",["zoom"],0,18,3.2],"fill-extrusion-base":0,"fill-extrusion-opacity":["step",["zoom"],0,18,.85]}},{id:"backofhouse-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"fill-extrusion-color":"#e6e6e2","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":1}},{id:"restrooms-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],paint:{"fill-extrusion-color":"#5f9070","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":.95}},{id:"obstacles-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],paint:{"fill-extrusion-color":"#E8E9ED","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,.4,17.5,.6,18.2,.8],"fill-extrusion-base":0,"fill-extrusion-opacity":1}},{id:"escalators-stairs-elevators-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],paint:{"fill-extrusion-color":"#a9aeb1","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":.9}},{id:"interior-parking-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"fill-extrusion-color":"#757575","fill-extrusion-height":["interpolate",["linear"],["zoom"],15,0,16,1,17,1.4,18,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":.85}},{id:"route-line",type:"line",source:"route-data",minzoom:16.5,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#007aff","line-width":["interpolate",["linear"],["zoom"],16.5,3,18,5,20,7],"line-opacity":.9}},{id:"route-halo",type:"line",source:"route-data",minzoom:16.5,paint:{"line-color":"white","line-width":["interpolate",["linear"],["zoom"],16.5,5,18,7,20,9],"line-opacity":.7}},{id:"route-endpoint-source",type:"circle",source:"route-endpoints",minzoom:16.5,filter:["==",["get","role"],"source"],paint:{"circle-radius":6,"circle-color":"#ffffff","circle-stroke-width":3,"circle-stroke-color":"#007aff","circle-opacity":1}},{id:"route-endpoint-destination",type:"circle",source:"route-endpoints",minzoom:16.5,filter:["==",["get","role"],"destination"],paint:{"circle-radius":7,"circle-color":"#007aff","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":1}},{id:"poi-accessibility-icons",type:"symbol",source:"poi-data",filter:["==",["get","accessible"],!0],minzoom:16.5,layout:{"icon-image":"wheelchair-accessible","icon-size":["interpolate",["linear"],["zoom"],15,.4,17,.6,19,.8],"icon-allow-overlap":!1,"icon-padding":4}},{id:"poi-destination-circles",type:"circle",source:"poi-data",filter:["==",["get","poiType"],"destination"],minzoom:16.5,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,6,18,8,20,10],"circle-color":"#ffffff","circle-stroke-width":3,"circle-stroke-color":"#162e51","circle-opacity":1}},{id:"poi-destination-labels",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"destination"],["==",["get","showLabel"],!0]],minzoom:16.5,layout:{"symbol-sort-key":0,"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16.5,18,18,20,20,23],"text-offset":[0,-.9],"text-anchor":"bottom","text-font":["Noto Sans Bold"],"text-max-width":12,"text-allow-overlap":!1,"text-padding":4,"text-rotation-alignment":"viewport"},paint:{"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1}},{id:"poi-entrance-exit-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["any",["!=",["index-of","entrance",["get","keywords"]],-1],["!=",["index-of","exit",["get","keywords"]],-1],["!=",["index-of","door",["get","keywords"]],-1]]],minzoom:15,layout:{"symbol-sort-key":1,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-parking-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["any",["!=",["index-of","parking",["get","keywords"]],-1],["!=",["index-of","park",["get","keywords"]],-1]]],minzoom:14,layout:{"symbol-sort-key":2,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-other-amenity-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["==",["index-of","entrance",["get","keywords"]],-1],["==",["index-of","exit",["get","keywords"]],-1],["==",["index-of","door",["get","keywords"]],-1],["==",["index-of","parking",["get","keywords"]],-1],["==",["index-of","park",["get","keywords"]],-1]],minzoom:16.5,layout:{"symbol-sort-key":3,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-you-are-here-ring",type:"circle",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,14,18,18,20,24],"circle-color":"#face00","circle-opacity":.25,"circle-pitch-alignment":"map"}},{id:"poi-you-are-here-dot",type:"circle",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,7,18,9,20,12],"circle-color":"#face00","circle-opacity":1,"circle-stroke-color":"#ffffff","circle-stroke-width":3,"circle-stroke-opacity":1}},{id:"poi-you-are-here",type:"symbol",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,layout:{"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,17,18,19,20,22],"text-offset":[0,-1.8],"text-anchor":"bottom","text-font":["Noto Sans Bold"],"text-allow-overlap":!0,"text-ignore-placement":!0,"text-optional":!1},paint:{"text-color":"#ffffff","text-halo-color":"#162e51","text-halo-width":2.5,"text-halo-blur":.5}},{id:"poi-highlight-ring",type:"circle",source:"poi-highlight-data",paint:{"circle-radius":14,"circle-color":"#005ea2","circle-opacity":.45,"circle-pitch-alignment":"map"}},{id:"poi-highlight-core",type:"circle",source:"poi-highlight-data",paint:{"circle-radius":9,"circle-color":"#005ea2","circle-opacity":1,"circle-stroke-color":"#ffffff","circle-stroke-width":3,"circle-stroke-opacity":1,"circle-pitch-alignment":"map"}}]};function H(t,e,o={}){t.sources||={},t.sources[e]||(t.sources[e]={type:"geojson",data:{type:"FeatureCollection",features:[]},...o})}function W(t){let e=structuredClone(t.style);if(e.sprite=t.customSprite||e.sprite||t.defaultSpriteUrl,H(e,a),H(e,c),H(e,l),H(e,u,{lineMetrics:!0}),H(e,"route-endpoints"),t.floorLayers)for(const o of Object.keys(t.floorLayers))H(e,`amenity_${o}`),H(e,`destination_${o}`),H(e,`pathTypes_${o}`);return e}const _="https://demotiles.maplibre.org/styles/osm-bright-gl-style/sprite";class Y{config;map=null;data=new J;wayfindingProvider={wayfindBetweenWaypoints:async()=>{throw new Error("Wayfinding is not yet implemented in the SDK")}};events=new K;floorsApi;venue=null;spriteKeys=null;debug;logger;defaultCamera=null;viewModes;amenityManager;wayfinding;highlightManager;static POI_CATEGORY_LAYERS=[{id:"poi-destination-circles",category:"destination"},{id:"poi-destination-labels",category:"destination"},{id:"poi-entrance-exit-icons",category:"amenity"},{id:"poi-parking-icons",category:"amenity"},{id:"poi-other-amenity-icons",category:"amenity"}];poiVisibleTypes=null;constructor(t){this.config=t,this.debug=Boolean(t.debug??t.options?.debug),this.logger=f({enabled:this.debug,prefix:"MinuteMapsSDK"}),this.viewModes=new S(()=>this.map),this.floorsApi=new m({getMap:()=>this.map,getConfig:()=>this.config,updatePoiSource:async t=>{const e=this.map;if(!e)return;const o=this.getAllPOIs(t),i=k.toFeatureCollection(o);s.setData(e,l,i)},log:(...t)=>this.logger.debug(...t)}),this.amenityManager=new O({getVenue:()=>this.venue,getFloors:()=>this.floorsApi.getFloors(),getFloorById:t=>this.floorsApi.getFloors().find(e=>e.id===t)??null,log:(...t)=>this.logger.debug(...t)}),this.wayfinding=new T({getMap:()=>this.map,getVenue:()=>this.venue,getYouAreHerePOI:t=>this.getYouAreHerePOI(t),getYouAreHereCoordinates:t=>this.getYouAreHereCoordinates(t),getBoundsPadding:()=>this.getBoundsPadding(),computeRoute:async(t,e)=>{const o=this.config.jmap.customerId,i=this.config.jmap.venueId;if(null==o)throw new Error("config.jmap.customerId is required");if(null==i)throw new Error("config.jmap.venueId is required");return this.wayfindingProvider.wayfindBetweenWaypoints({customerId:o,venueId:i,from:t,to:e})},log:(...t)=>this.logger.debug(...t),warn:(...t)=>this.logger.warn(...t),debug:this.debug}),this.highlightManager=new R({getMap:()=>this.map,log:(...t)=>this.logger.debug(...t)})}async init(){const{venueId:t,customerId:e}=this.config?.jmap;if(null==t||null==e)throw new Error("config.jmap.customerId and config.jmap.venueId are required");if(!this.config.container)throw new Error("config.container is required (HTMLElement or element id)");this.logger.debug("init :: starting (JACS)",{venueId:t,customerId:e});try{await this.data.init(this.config),this.logger.debug("providers :: JACS ready"),this.venue=await this.data.loadVenue(),this.logger.debug("JACS :: venue loaded",this.venue.id),this.floorsApi.setFloors(this.venue.floors),this.logger.debug("JACS :: floors loaded",{count:this.venue.floors.length});const t=W({style:N,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:_});this.ensureFloorLayersFromStyle(t),this.map=r(this.config.container,t),await new Promise(t=>this.map.once("load",()=>t())),this.map.on("error",t=>{const e=t?.error?.message||t?.message||t;this.logger.error("map :: error",{msg:e,sourceId:t?.sourceId,tile:t?.tile})}),this.map.on("styledata",()=>{try{this.viewModes.onStyleData()}catch{}}),this.map.on("move",()=>{if(!this.map)return;const t=M(this.map);t&&this.events.emit("cameraChange",{camera:t})}),this.ensureCoreSources(),this.spriteKeys=await F.getSpriteKeys(this.map);try{await x.register(this.map,this.venue?.amenities?.items)}catch(t){this.logger.warn("amenity icon registration failed",t)}const e=this.floorsApi.getInitialFloor();Boolean(e?.geojson?.features?.length)||this.applyInitialViewFromVenue(),e&&await this.setCurrentFloor(e),this.defaultCamera=M(this.map),this.events.emit("ready",{venue:this.venue}),this.events.emit("floorsLoaded",{})}catch(t){throw this.logger.error("init :: failed (JACS)",t),this.events.emit("error",{error:t}),t}}on(t,e){this.events.on(t,e)}off(t,e){this.events.off(t,e)}addControl(t,e){this.map?.addControl(t,e)}setView(t){!function(t,e){if(!t)return;const{center:o,zoom:i,pitch:n,bearing:r,animate:s,duration:a}=e;if(s){const e=t.getCenter(),s=o||[e.lng,e.lat],l=i??t.getZoom(),c=n??t.getPitch(),u=r??t.getBearing(),d="number"==typeof a?a:900;return void t.flyTo({center:s,zoom:l,pitch:c,bearing:u,duration:d,essential:!0})}o&&t.setCenter(o),void 0!==i&&t.setZoom(i),void 0!==n&&t.setPitch(n),void 0!==r&&t.setBearing(r)}(this.map,t)}get amenities(){return this.amenityManager}resetView(t){!function(t,e,o){if(!t||!e)return;const{center:i,zoom:n,pitch:r,bearing:s}=e,a=Boolean(o?.animate),l="number"==typeof o?.duration?o.duration:800;a?t.easeTo({center:i,zoom:n,pitch:r,bearing:s,duration:l}):t.jumpTo({center:i,zoom:n,pitch:r,bearing:s})}(this.map,this.defaultCamera,t)}refit(t){if(!this.map)return;const e=this.wayfinding.getActiveRouteBounds();if(e)return void this.fitToBounds(e,t);const o=this.getCurrentFloor();if(!o?.geojson)return;const i=h.boundsFromGeoJson(o.geojson);i&&this.fitToBounds(i,t)}fitToBounds(t,e){const o=this.map;if(o)try{o.fitBounds(t,{padding:this.getBoundsPadding(),bearing:o.getBearing(),pitch:o.getPitch(),animate:e?.animate??!0,duration:e?.duration??600,maxZoom:21})}catch(t){this.logger.warn("refit :: fitBounds failed",t)}}set3dEnabled(t){this.viewModes.set3dEnabled(t)}toggle3d(){this.viewModes.toggle3d()}getIs3dEnabled(){return this.viewModes.getIs3dEnabled()}setUnits2dEnabled(t){this.viewModes.setUnits2dEnabled(t)}toggleUnits2d(){this.viewModes.toggleUnits2d()}getIsUnits2dEnabled(){return this.viewModes.getIsUnits2dEnabled()}setFlatMode(t){this.viewModes.setFlatMode(t)}toggleFlatMode(){this.viewModes.toggleFlatMode()}getIsFlatMode(){return this.viewModes.getIsFlatMode()}getFloors(){return this.floorsApi.getFloors()}getCurrentFloor(){return this.floorsApi.getCurrentFloor()}getDefaultFloor(){return this.floorsApi.getDefaultFloor()}getDestinations(t){const e=t||this.getCurrentFloor();return function(t,e){if(!t||!e)return[];try{const o=t.destinations?.getByMap?.({id:e.id})||[];return Array.isArray(o)?o:[]}catch{return[]}}(this.venue,e)}getPolygonLayers(){return this.venue?.polygonLayers??[]}getFloorMapTemplate3d(t){return this.venue?.mapTemplates3d?.[String(t)]??[]}getAllPOIs(t){const e=t||this.getCurrentFloor();if(!e)return[];return function(t,e,o,i,n){return k.buildPOIs(t,e,o,i,n)}(e,this.amenityManager.getByFloorId(e.id),this.getDestinations(e),this.spriteKeys,this.venue?.kioskWaypoint)}getYouAreHerePOI(t){return P(this.getAllPOIs(t))}getYouAreHereCoordinates(t){return function(t){const e=P(t);return e?.coordinates??null}(this.getAllPOIs(t))}searchPOIs(t,e){return function(t,e){const o=e.trim().toLowerCase();return o?t.filter(t=>{const e=t.name?.toLowerCase().includes(o),i=(t.keywords||[]).some(t=>t.toLowerCase().includes(o));return e||i}):[]}(this.getAllPOIs(e),t)}searchAllPOIs(t){const e=t?.trim();return e?this.getFloors().flatMap(t=>this.searchPOIs(e,t)):[]}async wayfindBetweenWaypoints(t,e,o){return this.wayfinding.wayfindBetweenWaypoints(t,e,o)}async navigateFromKioskToDestination(t){return this.wayfinding.navigateFromKioskToDestination(t)}async navigateFromKioskToPOI(t){const e=t?.waypoint;if(!e)return void this.logger.warn("navigateFromKioskToPOI :: POI has no waypoint",t);const o=this.getYouAreHerePOI()?.waypoint;if(o)return this.wayfinding.wayfindBetweenWaypoints(o,e,{centerMode:"route"});this.logger.warn("navigateFromKioskToPOI :: no kiosk waypoint available")}clearRoute(){this.wayfinding.clearRoute()}async highlightPOI(t){let e=null,o=null;for(const i of this.getFloors()){const n=this.getAllPOIs(i).find(e=>String(e.id)===String(t));if(n){e=n,o=i;break}}e&&o?(String(this.getCurrentFloor()?.id)!==String(o.id)&&await this.setCurrentFloor(o),this.setView({center:e.coordinates,animate:!0,duration:600}),this.highlightManager.highlight(e.coordinates)):this.logger.warn("highlightPOI :: no POI found for id",t)}clearHighlight(){this.highlightManager.clear()}setPOIFilter(t){this.poiVisibleTypes=new Set(t),this.applyPOIFilter()}clearPOIFilter(){this.poiVisibleTypes=null,this.applyPOIFilter()}applyPOIFilter(){const t=this.map;if(!t)return;const e=this.poiVisibleTypes;for(const{id:o,category:i}of Y.POI_CATEGORY_LAYERS){if(!t.getLayer(o))continue;const n=null===e||e.has(i);t.setLayoutProperty(o,"visibility",n?"visible":"none")}}findClosestWaypoint(t,e){if(!t?.length)return null;const o=e??this.getYouAreHereCoordinates();if(!o)return t.find(t=>Array.isArray(t.coordinates)&&t.coordinates.length>=2)??null;let i=null,n=1/0;for(const e of t){const t=e.coordinates;if(!Array.isArray(t)||t.length<2)continue;const r=t[0]-o[0],s=t[1]-o[1],a=r*r+s*s;a<n&&(n=a,i=e)}return i}async highlightAmenity(t){const e=this.amenityManager.getDistinct().find(e=>String(e.id)===String(t));if(!e||!e.waypoints?.length)return void this.logger.warn("highlightAmenity :: no waypoints for amenity",t);const o=this.findClosestWaypoint(e.waypoints);if(!o||!Array.isArray(o.coordinates)||o.coordinates.length<2)return void this.logger.warn("highlightAmenity :: no usable waypoint",t);const i=this.findFloorForWaypoint(o);i&&String(this.getCurrentFloor()?.id)!==String(i.id)&&await this.setCurrentFloor(i);const n=[o.coordinates[0],o.coordinates[1]];this.setView({center:n,animate:!0,duration:600}),this.highlightManager.highlight(n)}findFloorForWaypoint(t){const e=t.mapId;return null==e?null:this.getFloors().find(t=>{const o=t.mapId??t.id;return String(o)===String(e)})??null}getCameraPosition(){return M(this.map)}getMap(){return this.map}destroy(){this.highlightManager.destroy(),this.map?.remove(),this.map=null,this.floorsApi.setFloors([]),this.defaultCamera=null,this.viewModes=new S(()=>this.map)}async setCurrentFloor(t){await this.data.ensureFloorGeojson(t),await this.floorsApi.setCurrentFloor(t),this.setFloorLayerVisibility(t.id),this.events.emit("floorChanged",{floor:t})}isReady(){return!!this.map}setFloorLayerVisibility(t){const e=this.map;if(!e)return;const o=this.venue?.styleSheet?.floorLayers;if(o)for(const[i,n]of Object.entries(o)){const o=String(i)===String(t);for(const t of n)e.getLayer(t.id)&&e.setLayoutProperty(t.id,"visibility",o?"visible":"none")}}getBoundsPadding(){const t=this.config.options?.boundsPadding??50;if("number"==typeof t||!this.map)return t;const e=this.map.getContainer();return this.clampPadding(t,e.clientWidth,e.clientHeight)}clampPadding(t,e,o){const i=(t,e,o)=>{if(!(o>0))return[t,e];const i=.8*o,n=t+e;if(n<=i)return[t,e];const r=i/n;return[t*r,e*r]},[n,r]=i(t.top,t.bottom,o),[s,a]=i(t.left,t.right,e);return{top:n,bottom:r,left:s,right:a}}getVenueBounds(){const t=this.venue?.coordinates;if(!t)return null;const{bottomLng:e,bottomLat:o,topLng:i,topLat:n}=t;if(null==e||null==o||null==i||null==n)return null;const r=Math.min(e,i),s=Math.max(e,i);return[[r,Math.min(o,n)],[s,Math.max(o,n)]]}applyInitialViewFromVenue(){const t=this.map;if(!t)return;const e=this.getVenueBounds();if(e)try{t.resize(),t.fitBounds(e,{padding:this.getBoundsPadding(),animate:!1,duration:0,maxZoom:21})}catch(t){this.logger.warn("applyInitialViewFromVenue :: fitBounds failed",t)}}async loadAndPatchVenueStyle(){const t=this.venue?.styleSheet?.styleUrl,e=this.venue?.styleSheet?.floorLayers,o=N;if("sdkTemplate"===this.config.options?.styleMode)return this.logger.debug("style :: styleMode=sdkTemplate, ignoring venue styleUrl"),W({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:_});if(!t)return this.logger.warn("style :: venue.styleSheet.styleUrl missing, using baseStyle"),W({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:_});try{const o=await fetch(t);if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);return W({style:await o.json(),floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:_})}catch(t){return this.logger.warn("style :: failed to fetch venue styleUrl, using baseStyle",t),W({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:_})}}ensureFloorLayersFromStyle(t){const e=this.venue?.styleSheet?.floorLayers;if(e&&Object.keys(e).length)return;const o={};for(const e of t.layers||[]){const t=e.id||"",i=/_(\d+)$/.exec(t);if(!i)continue;const n=i[1];o[n]||=[],o[n].push({id:t})}this.venue||={},this.venue.styleSheet||={},this.venue.styleSheet.floorLayers=o}ensureCoreSources(){const t=this.map;if(!t)return;const e={type:"FeatureCollection",features:[]};s.ensureGeoJson(t,a),s.ensureGeoJson(t,c),s.ensureGeoJson(t,l),s.ensureGeoJson(t,d),t.getSource(u)||t.addSource(u,{type:"geojson",data:e,lineMetrics:!0}),t.getSource("route-endpoints")||t.addSource("route-endpoints",{type:"geojson",data:e})}}exports.MinuteMaps=Y,exports.createMinuteMapsSDK=function(t){return new Y(t)};
|
|
1
|
+
"use strict";var e=require("maplibre-gl"),t=require("pmtiles");function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}}),t.default=e,Object.freeze(t)}var i=o(require("@turf/turf"));let n=!1;function r(o,i){const r="string"==typeof o?document.getElementById(o):o;if(!r)throw new Error("Map container not found");return function(){if(n)return;const o=new t.Protocol;e.addProtocol("pmtiles",o.tile),n=!0}(),new e.Map({container:r,style:i,center:[0,0],zoom:16,pitch:45,bearing:0,minPitch:30,maxPitch:55})}const s={ensureGeoJson(e,t){e.getSource(t)||e.addSource(t,{type:"geojson",data:{type:"FeatureCollection",features:[]}})},setData(e,t,o){const i=e.getSource(t);i?.setData?.(o)}},a="indoor-data",l="poi-data",c="unit-walls",d="route-data",u="poi-highlight-data",p=["boundary-fill","boundary-outline","units-fill","units-wall-extrusion","units-wall-custom-extrusion","corridors-fill","corridors-outline","building-extrusion"],f=()=>{};function g(e){const t=Boolean(e?.enabled),o=function(e){const t=String(e||"").trim();return t?`[${t}]`:""}(e?.prefix||"MinuteMapsSDK");return t?{debug:(...e)=>console.debug(o,...e),log:(...e)=>console.log(o,...e),warn:(...e)=>console.warn(o,...e),error:(...e)=>console.error(o,...e)}:{debug:f,log:f,warn:f,error:f}}g({enabled:!0,prefix:"MinuteMapsSDK"});const h={applyFloor(e,t,o=1){h.updateWalls(e,t,o),h.updateIndoor(e,t,o)},updateIndoor(e,t,o=1){const n=function(e,t){if(!e)return{type:"FeatureCollection",features:[]};if(!Number.isFinite(t)||t<=0)return e;const o=(e.features||[]).map(e=>{const o=e?.properties?.featureType;if(!o||!y.has(o))return e;const n=e?.geometry?.type;if("Polygon"!==n&&"MultiPolygon"!==n)return e;try{const o=i.buffer(e,-t,{units:"feet"});return o?.geometry?{...e,geometry:o.geometry}:e}catch{return e}});return{...e,features:o}}(t.geojson,o);s.setData(e,a,n);try{const e=t?.geojson?.features||[],o={};for(const t of e){const e=t?.properties?.featureType,i=null==e?"(missing)":String(e);o[i]=(o[i]||0)+1}Object.entries(o).sort((e,t)=>t[1]-e[1]).slice(0,15)}catch{}},updateWalls(e,t,o=1){const n=function(e,t=1){const o=Math.max(Number(t)||1,.5)/2,n=e=>{const t=e?.geometry?.type;if("Polygon"!==t&&"MultiPolygon"!==t)return null;try{const t=i.polygonToLine(e),n=i.buffer(t,o,{units:"feet"});return n?.geometry?n:null}catch{return null}},r=e=>{if(0===e.length)return null;if(1===e.length)return e[0];try{return i.union(i.featureCollection(e))}catch{return null}},s=[],a=[];for(const t of e.features||[]){const e=t?.properties?.featureType;if("Boundary"===e){const e=n(t);e&&s.push(e)}else if("Units"===e){const e=n(t);e&&a.push(e)}}const l=r(s),c=r(a);let d=c;if(c?.geometry&&l?.geometry)try{d=i.difference(i.featureCollection([c,l]))}catch{d=c}const u=[];l?.geometry&&u.push({type:"Feature",geometry:l.geometry,properties:{featureType:"UnitWalls",wallKind:"perimeter"}});d?.geometry&&u.push({type:"Feature",geometry:d.geometry,properties:{featureType:"UnitWalls",wallKind:"interior"}});return{type:"FeatureCollection",features:u}}(t.geojson,o);s.setData(e,c,n)},boundsFromGeoJson(e){try{const[t,o,n,r]=i.bbox(e),s=Math.min(t,n),a=Math.max(t,n),l=Math.min(o,r);return[[s,l],[a,Math.max(o,r)]]}catch{return null}},selectDefaultFloor:e=>Array.isArray(e)&&0!==e.length&&(e.find(e=>e.isDefault)||e[0])||null,selectInitialFloor(e,t){if(!Array.isArray(e)||0===e.length)return null;if(null!=t){const o=e.find(e=>e.id===t);if(o)return o}return h.selectDefaultFloor(e)},async activateFloor(e,t,o){if(!e)throw new Error("activateFloor requires an initialized map");if(t?.geojson&&h.applyFloor(e,t,o.wallFeet),await o.updatePOIs(t),!t?.geojson)return void(e.getZoom()<o.minIndoorZoom&&e.setZoom(o.minIndoorZoom));const i=h.boundsFromGeoJson(t.geojson);if(!i)return;const n=!o.didFit;let r=n;if(!r){const[[t,o],[n,s]]=i,a=e.getBounds();r=a.getWest()>n||a.getEast()<t||a.getSouth()>s||a.getNorth()<o}r?(e.fitBounds(i,{padding:o.boundsPadding,animate:!n,duration:700,bearing:e.getBearing(),pitch:e.getPitch()}),e.once("moveend",()=>{e.getZoom()<o.minIndoorZoom&&e.setZoom(o.minIndoorZoom)}),o.setDidFit(!0),o.log?.("camera :: fitToFloor",{floorId:t.id,animated:!n})):(e.getZoom()<o.minIndoorZoom&&e.setZoom(o.minIndoorZoom),o.log?.("camera :: fit skipped (floor overlaps viewport)",{floorId:t.id}))}},y=new Set(["Restrooms","Back-of-house","Obstacles","Escalators","Stairs","Elevators"]);class m{floors=[];currentFloor=null;didFit=!1;getMap;getConfig;updatePoiSource;logFn;constructor(e){this.getMap=e.getMap,this.getConfig=e.getConfig,this.updatePoiSource=e.updatePoiSource,this.logFn=e.log}log(...e){this.logFn&&this.logFn(...e)}setFloors(e){this.floors=e}getFloors(){return[...this.floors]}getCurrentFloor(){return this.currentFloor}setDidFit(e){this.didFit=e}getDefaultFloor(){return h.selectDefaultFloor(this.floors)}getInitialFloor(){const e=this.getConfig();return h.selectInitialFloor(this.floors,e.options?.initialFloor)}async setCurrentFloor(e){const t=this.getMap();if(!t)throw new Error("Map is not initialized");this.currentFloor=e,this.log("floor :: setCurrentFloor",{id:e.id,name:e.name,geojsonFeatures:e.geojson?.features?.length??0});const o=this.getConfig(),i=o.options?.wallThickness??1,n=o.options?.boundsPadding??50,r=o.options?.minIndoorZoom??16.5;await h.activateFloor(t,e,{wallFeet:i,updatePOIs:e=>this.updatePoiSource(e),didFit:this.didFit,setDidFit:e=>{this.didFit=e},boundsPadding:n,minIndoorZoom:r,log:(e,t)=>this.log(e,t)})}}const w=g({enabled:!0,prefix:"MinuteMapsSDK"}),b=new Map,F={async getSpriteKeys(e){const t=function(e){if(!e)return;if("string"==typeof e)return e;if(Array.isArray(e)){const t=e[0];if(t&&"string"==typeof t.url)return t.url}if("object"==typeof e&&null!==e){const t=e?.url;if("string"==typeof t)return t}return}(e?.getStyle?.()?.sprite);if(!t||"function"!=typeof fetch)return new Set;const o=t.endsWith(".json")?t:`${t}.json`;if(b.has(o))return b.get(o);try{const e=await fetch(o);if(!e.ok)throw new Error(`Failed to load sprite JSON (${e.status})`);const t=await e.json(),i=new Set(Object.keys(t||{}));return b.set(o,i),i}catch(e){w.warn("sprite fetch failed",o,e);const t=new Set;return b.set(o,t),t}}};const I=g({enabled:!0,prefix:"MinuteMapsSDK amenityIcons"});const v={async register(e,t,o={}){if(!Array.isArray(t)||0===t.length)return;const i=o.size??64;await Promise.all(t.map(async t=>{const n=function(e,t){const o=e?.uris;if(!Array.isArray(o)||0===o.length)return null;const i=e=>"image/svg+xml"===e?.mimeType||"svg-icon"===e?.resourceType,n=e=>{if(!Array.isArray(e)||0===e.length)return null;if(t){const o=e.find(e=>e?.locale===t);if(o?.uriPath)return o.uriPath}return e.find(e=>e?.uriPath)?.uriPath??null};for(const e of o){if(!i(e))continue;const t=n(e.locales);if(t)return t}for(const e of o){const t=n(e?.locales);if(t)return t}return null}(t,o.preferredLocale);if(!n)return;const r=`amenity-${t.id}`;if(e.hasImage(r))t.iconId=r;else try{const o=await async function(e,t){const o=await fetch(e,{mode:"cors"});if(!o.ok)throw new Error(`HTTP ${o.status}`);const i=await o.text();let n=i;try{const e=(new DOMParser).parseFromString(i,"image/svg+xml"),o=e.documentElement;!(e.getElementsByTagName("parsererror").length>0)&&o&&"svg"===o.nodeName.toLowerCase()&&(o.hasAttribute("width")||o.setAttribute("width",String(t)),o.hasAttribute("height")||o.setAttribute("height",String(t)),n=(new XMLSerializer).serializeToString(o))}catch{}const r=new Blob([n],{type:"image/svg+xml"}),s=URL.createObjectURL(r);return new Promise((e,t)=>{const o=new Image;o.onload=()=>{URL.revokeObjectURL(s),e(o)},o.onerror=e=>{URL.revokeObjectURL(s),t(e)},o.src=s})}(n,i);e.hasImage(r)||e.addImage(r,o),t.iconId=r}catch(e){I.warn("icon load failed",{amenityId:t.id,url:n,error:e?.message??String(e)})}}))}},x="units-outline-2d",A=["units-wall-extrusion","units-wall-custom-extrusion"];class S{getMap;is3dEnabled=!0;isUnits2dEnabled=!1;isFlatMode=!1;cachedExtrusionIds=null;extrusionOriginalVisibility=null;unitsExtrusionOriginalVisibility=null;unitsOutlineOriginalVisibility=null;constructor(e){this.getMap=e}onStyleData(){if(this.map){if(this.cachedExtrusionIds=null,!this.is3dEnabled){const e=this.listExtrusionLayerIds();this.setLayersVisibility(e,"none")}this.isUnits2dEnabled&&this.applyUnits2dVisibility(!0)}}set3dEnabled(e){const t=this.map;if(!t)return;const o=this.listExtrusionLayerIds();if(this.cachedExtrusionIds=o,!this.extrusionOriginalVisibility){const e={};o.forEach(o=>{try{const i=t.getLayoutProperty(o,"visibility")||"visible";e[o]=i}catch{e[o]="visible"}}),this.extrusionOriginalVisibility=e}if(e){const e=this.extrusionOriginalVisibility||{};o.forEach(o=>{const i=e[o]??"visible";try{t.getLayer(o)&&t.setLayoutProperty(o,"visibility",i)}catch{}})}else this.setLayersVisibility(o,"none");this.is3dEnabled=e,t.triggerRepaint()}toggle3d(){this.set3dEnabled(!this.is3dEnabled)}getIs3dEnabled(){return this.is3dEnabled}setUnits2dEnabled(e){const t=this.map;t&&(this.applyUnits2dVisibility(e),this.isUnits2dEnabled=e,t.triggerRepaint())}toggleUnits2d(){this.setUnits2dEnabled(!this.isUnits2dEnabled)}getIsUnits2dEnabled(){return this.isUnits2dEnabled}setFlatMode(e){this.map&&(e?(this.set3dEnabled(!1),this.setUnits2dEnabled(!0)):(this.setUnits2dEnabled(!1),this.set3dEnabled(!0)),this.isFlatMode=e)}toggleFlatMode(){this.setFlatMode(!this.isFlatMode)}getIsFlatMode(){return this.isFlatMode}applyUnits2dVisibility(e){const t=this.map;if(t){if(!this.unitsExtrusionOriginalVisibility){const e={};A.forEach(o=>{try{const i=t.getLayoutProperty(o,"visibility")||"visible";e[o]=i}catch{e[o]="visible"}}),this.unitsExtrusionOriginalVisibility=e}if(null==this.unitsOutlineOriginalVisibility)try{const e=t.getLayoutProperty(x,"visibility");this.unitsOutlineOriginalVisibility=e??"none"}catch{this.unitsOutlineOriginalVisibility="none"}if(t.getLayer(x)){const o=e?"visible":this.unitsOutlineOriginalVisibility??"none";try{t.setLayoutProperty(x,"visibility",o)}catch{}}if(e)A.forEach(e=>{if(t.getLayer(e))try{t.setLayoutProperty(e,"visibility","none")}catch{}});else{const e=this.unitsExtrusionOriginalVisibility||{};A.forEach(o=>{const i=e[o]??"visible";if(t.getLayer(o))try{t.setLayoutProperty(o,"visibility",i)}catch{}})}}}listExtrusionLayerIds(){const e=this.map;if(!e)return[];try{const t=e.getStyle(),o=t?.layers||[],i=o.filter(e=>"fill-extrusion"===e?.type).map(e=>e.id),n=Array.isArray(p)?p:[],r=[];return n.forEach(e=>{const t=o.find(t=>t.id===e);t&&"fill-extrusion"===t.type&&r.push(e)}),[...new Set([...i,...r])]}catch{return this.cachedExtrusionIds||[]}}setLayersVisibility(e,t){const o=this.map;o&&e.forEach(e=>{try{o.getLayer(e)&&o.setLayoutProperty(e,"visibility",t)}catch{}})}get map(){return this.getMap()}}function M(e,t){if(!e)return;const{center:o,zoom:i,pitch:n,bearing:r,animate:s,duration:a}=t;if(s){const t=e.getCenter(),s=o||[t.lng,t.lat],l=i??e.getZoom(),c=n??e.getPitch(),d=r??e.getBearing(),u="number"==typeof a?a:900;return void e.flyTo({center:s,zoom:l,pitch:c,bearing:d,duration:u,essential:!0})}o&&e.setCenter(o),void 0!==i&&e.setZoom(i),void 0!==n&&e.setPitch(n),void 0!==r&&e.setBearing(r)}function k(e){if(!e)return null;const t=e.getCenter(),o=(e,t=6)=>function(e,t=6){const o=Number(e.toFixed(t));return Object.is(o,-0)?0:o}(e,t);return{center:[o(t.lng),o(t.lat)],zoom:o(e.getZoom(),4),pitch:o(e.getPitch(),2),bearing:o(e.getBearing(),2)}}const P={async updatePOIs(e,t,o){const[i,n]=await Promise.all([o.getAmenities(t.id),o.getDestinations(t.id)]),r=P.buildPOIs(t,i,n,o.spriteKeys);s.setData(e,l,P.toFeatureCollection(r))},buildPOIs(e,t=[],o=[],i,n){if(!e?.id)return[];const r=e.mapId??e.id,s=[];for(const o of t||[]){if(!o.waypoints)continue;const t=o.iconId||T(o.svg,i)||void 0;for(const i of o.waypoints||[]){if(i.mapId!==r||!z(i.coordinates))continue;const[n,a]=i.coordinates,l=i.id??i._?.id;s.push({id:o.id,type:"amenity",name:o.name||"Amenity",coordinates:[n,a],iconId:t,floorId:e.id,amenityType:o.type,keywords:o.keywords||[],showLabel:!0,waypointId:l,waypoint:i})}}for(const t of o||[])if(t.waypoints)for(const o of t.waypoints||[]){if(o.mapId!==r||!z(o.coordinates))continue;const[i,n]=o.coordinates,a=o.id??o._?.id;s.push({id:t.id,type:"destination",name:t.name||"Destination",coordinates:[i,n],floorId:e.id,showLabel:!0,waypointId:a,waypoint:o})}return n&&String(n.floorId)===String(e.id)&&z(n.coordinates)&&s.push({id:"kiosk-you-are-here",type:"kiosk",name:"You are here",coordinates:n.coordinates,iconId:"YouAreHere",floorId:e.id,showLabel:!0,isYouAreHere:!0,heading:n.heading??null,waypointId:n.waypointId,waypoint:n.waypoint}),s},toFeatureCollection:e=>({type:"FeatureCollection",features:e.map(e=>{const t=e.heading;return{type:"Feature",geometry:{type:"Point",coordinates:e.coordinates},properties:{id:e.id,name:e.name,poiType:e.type,iconId:e.iconId,floorId:e.floorId,keywords:e.keywords,amenityType:e.amenityType,showLabel:!1!==e.showLabel,isYouAreHere:!0===e.isYouAreHere,heading:"number"==typeof t?t:null,hasHeading:"number"==typeof t}}})})};function C(e){return e.find(e=>e.isYouAreHere)||null}function z(e){return Array.isArray(e)&&e.length>=2}function T(e,t){if(!e||!t)return null;const o=/<svg[^>]*\bid\s*=\s*["']([^"']+)["']/i.exec(e),i=o?.[1];return i&&t.has(i)?i:null}function E(e){const t=e=>(e??"").toLowerCase(),o=t(e.name),i=(e.keywords||[]).map(e=>t(e)),n=e.extensors||{},r=t(n.type),s="kiosk"===o||o.includes("kiosk"),a=i.some(e=>e.includes("kiosk"));return s||a||"assistance"===r}class j{deps;routeAnimationFrame=null;routeAnimationStart=null;routeAnimationDurationMs=1200;routeActive=!1;routeBounds=null;constructor(e){this.deps=e}buildWayfindFeatureCollection(e){if(!e)return this.deps.warn?.("wayfind :: no result"),null;const t=[],o=e=>{if(!e)return;const o=e.coordinates||e.xyz||e._?.coordinates;if(Array.isArray(o)&&o.length>=2){const e=Number(o[0]),i=Number(o[1]);Number.isFinite(e)&&Number.isFinite(i)&&t.push([e,i])}};return Array.isArray(e)?e.length>0&&Array.isArray(e[0]?.points)?e[0].points.forEach(o):e.forEach(o):Array.isArray(e.points)?e.points.forEach(o):Array.isArray(e.path)?e.path.forEach(o):Array.isArray(e.paths?.[0]?.points)&&e.paths[0].points.forEach(o),t.length<2?(this.deps.warn?.("wayfind :: not enough coordinates to draw a route",{resultShape:{isArray:Array.isArray(e),hasPoints:Array.isArray(e.points),hasPath:Array.isArray(e.path),hasPaths0Points:Array.isArray(e.paths?.[0]?.points)},extractedCount:t.length}),null):(this.deps.log?.("wayfind :: extracted coordinates for route",{count:t.length,first:t[0],last:t[t.length-1]}),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:t},properties:{}}]})}async wayfindBetweenWaypoints(e,t,o){const i=this.deps.getMap();if(!this.deps.getVenue()||!i)return this.deps.warn?.("wayfindBetweenWaypoints :: venue or map not ready"),null;const n={accessible:o?.accessible,avoidStairs:o?.avoidStairs};let r=null;try{r=await this.deps.computeRoute(e,t,n)}catch(e){return this.deps.warn?.("wayfind :: computeRoute failed",e),null}this.deps.log?.("wayfind :: result",r);const a=this.buildWayfindFeatureCollection(r);if(!a)return r;s.setData(i,d,a),this.routeBounds=function(e){const t=e.features[0]?.geometry;if(!t||"LineString"!==t.type)return null;const o=t.coordinates;if(0===o.length)return null;let i=1/0,n=1/0,r=-1/0,s=-1/0;for(const[e,t]of o)e<i&&(i=e),e>r&&(r=e),t<n&&(n=t),t>s&&(s=t);return[[i,n],[r,s]]}(a),this.deps.log?.("wayfind :: route source updated",{featureCount:a.features.length}),this.startRouteAnimation();const l=o?.centerMode??"route",c=o?.zoom??19,u=!0===this.deps.getReducedMotion?.();if("none"!==l){const e=a.features[0]?.geometry;if(e&&"LineString"===e.type&&Array.isArray(e.coordinates)){const t=e.coordinates;if("destination"===l){const e=t[t.length-1];i.flyTo({center:e,zoom:c,pitch:45,bearing:0,animate:!u,duration:u?0:900})}else if("route"===l){const e=t.map(e=>e[0]),o=t.map(e=>e[1]),n=[[Math.min(...e),Math.min(...o)],[Math.max(...e),Math.max(...o)]];i.setMinPitch(0);const r=this.deps.getBoundsPadding();let s=null,a=0;for(const e of[1,.66,.4,.2,0])if(s=i.cameraForBounds(n,{padding:L(r,e),bearing:0}),s){a=e;break}const l=i.getContainer();this.deps.log?.("wayfind :: route fit",{requestedPadding:r,paddingScaleApplied:a,canvas:[l.clientWidth,l.clientHeight],camera:s?{zoom:s.zoom}:"no fit at any padding"}),s?i.easeTo({center:s.center,zoom:s.zoom-B,bearing:0,pitch:0,duration:u?0:800}):i.easeTo({pitch:0,bearing:0,duration:u?0:800})}}}return r}async navigateFromKioskToDestination(e){const t=this.deps.getMap(),o=this.deps.getVenue();if(!t||!o)return null;const i=this.deps.getYouAreHerePOI();if(!i||!i.waypoint)return this.deps.warn?.("navigateFromKioskToDestination :: no you-are-here waypoint available",i),null;const n=e.waypoint||e.waypoints?.[0];if(!n)return this.deps.warn?.("navigateFromKioskToDestination :: destination has no waypoint",e),null;this.deps.log?.("navigateFromKioskToDestination :: from kiosk to destination",{kioskWaypoint:i.waypoint,destWaypoint:n});const r=this.deps.getYouAreHereCoordinates()??i.waypoint?.coordinates,s=n.coordinates||n.xyz||n._?.coordinates,a=Array.isArray(s)&&s.length>=2?[Number(s[0]),Number(s[1])]:null;return r&&a?this.showRouteContext(r,a):this.deps.warn?.("navigateFromKioskToDestination :: could not derive endpoint coordinates",{fromCoords:r,rawDest:s}),this.wayfindBetweenWaypoints(i.waypoint,n,{centerMode:"route"})}clearRoute(){const e=this.deps.getMap();if(!e)return;this.stopRouteAnimation();if(s.setData(e,d,{type:"FeatureCollection",features:[]}),this.routeBounds=null,e.getMinPitch()<30){e.setMinPitch(30);const t=!0===this.deps.getReducedMotion?.();e.easeTo({pitch:45,duration:t?0:400})}this.deps.log?.("wayfind :: route cleared")}getActiveRouteBounds(){return this.routeActive?this.routeBounds:null}setPoiLayersVisible(e){const t=this.deps.getMap();if(!t)return;const o=e?"visible":"none";["poi-accessibility-icons","poi-destination-circles","poi-destination-labels","poi-entrance-exit-icons","poi-parking-icons","poi-other-amenity-icons"].forEach(e=>{t.getLayer(e)&&t.setLayoutProperty(e,"visibility",o)})}updateRouteEndpoints(e,t){const o=this.deps.getMap();if(!o)return;const i=o.getSource("route-endpoints");if(!i)return;const n={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{role:"source"}},{type:"Feature",geometry:{type:"Point",coordinates:t},properties:{role:"destination"}}]};i.setData(n)}clearRouteEndpoints(){const e=this.deps.getMap();if(!e)return;const t=e.getSource("route-endpoints");if(!t)return;t.setData({type:"FeatureCollection",features:[]})}showRouteContext(e,t){this.updateRouteEndpoints(e,t)}hideRouteContext(){this.setPoiLayersVisible(!0),this.clearRouteEndpoints()}startRouteAnimation(){const e=this.deps.getMap();if(!e)return;if("undefined"==typeof window)return;if(null!=this.routeAnimationFrame&&(cancelAnimationFrame(this.routeAnimationFrame),this.routeAnimationFrame=null),this.routeAnimationStart=performance.now(),this.routeActive=!0,!0===this.deps.getReducedMotion?.())return e.getLayer("route-line")&&(e.setPaintProperty("route-line","line-gradient",void 0),e.setPaintProperty("route-line","line-color","#007aff")),void(e.getLayer("route-halo")&&(e.setPaintProperty("route-halo","line-gradient",void 0),e.setPaintProperty("route-halo","line-color","#ffffff")));const t=this.deps.debug,o=e=>{const i=this.deps.getMap();if(!i||!this.routeActive||null==this.routeAnimationStart)return;const n=e-this.routeAnimationStart,r=Math.min(1,n/this.routeAnimationDurationMs),s=Math.max(.001,r);t&&this.deps.log?.("route animation frame",{t:r,clamped:s});const a=.001,l=Math.min(Math.max(s-.01,a),.998),c=Math.min(Math.max(s+.01,l+a),.999),d=["interpolate",["linear"],["line-progress"],0,"rgba(0,122,255,1.0)",l,"rgba(0,122,255,1.0)",c,"rgba(0,122,255,0.0)",1,"rgba(0,122,255,0.0)"],u=["interpolate",["linear"],["line-progress"],0,"rgba(255,255,255,0.7)",l,"rgba(255,255,255,0.7)",c,"rgba(255,255,255,0.0)",1,"rgba(255,255,255,0.0)"];i.getLayer("route-line")&&i.setPaintProperty("route-line","line-gradient",d),i.getLayer("route-halo")&&i.setPaintProperty("route-halo","line-gradient",u),this.routeAnimationFrame=r<1?requestAnimationFrame(o):null};this.routeAnimationFrame=requestAnimationFrame(o)}stopRouteAnimation(){this.routeActive=!1,null!=this.routeAnimationFrame&&"undefined"!=typeof window&&cancelAnimationFrame(this.routeAnimationFrame),this.routeAnimationFrame=null,this.routeAnimationStart=null;const e=this.deps.getMap();e&&(e.getLayer("route-line")&&(e.setPaintProperty("route-line","line-gradient",void 0),e.setPaintProperty("route-line","line-color","#007aff")),e.getLayer("route-halo")&&(e.setPaintProperty("route-halo","line-gradient",void 0),e.setPaintProperty("route-halo","line-color","#ffffff")))}}const B=1;function L(e,t){return"number"==typeof e?e*t:{top:e.top*t,bottom:e.bottom*t,left:e.left*t,right:e.right*t}}function O(e){const[t,o]=e.coordinates??[];return`${e.mapId}|${t}|${o}`}class U{getVenue;getFloors;getFloorById;logFn;constructor(e){this.getVenue=e.getVenue,this.getFloors=e.getFloors,this.getFloorById=e.getFloorById,this.logFn=e.log}get venue(){return this.getVenue()}log(...e){this.logFn&&this.logFn(...e)}loadForFloor(e){if(!e||!this.venue)return[];try{const t=this.venue.amenities?.getByMap(e.id)||[];return Array.isArray(t)?t.map(t=>{const o=t;return o.floorId=e.id,o}):[]}catch{return[]}}getAll(){return this.getFloors().flatMap(e=>this.loadForFloor(e))}getDistinct(){const e=new Map;for(const t of this.getFloors())for(const o of this.loadForFloor(t)){const t=String(o.id),i=e.get(t);if(!i){const i={id:o.id,name:o.name,svg:o.svg,uris:o.uris,iconId:o.iconId,keywords:o.keywords,type:o.type,extensors:o.extensors,waypoints:[...o.waypoints??[]]};e.set(t,i);continue}const n=new Set((i.waypoints??[]).map(O));for(const e of o.waypoints??[]){const t=O(e);n.has(t)||((i.waypoints??=[]).push(e),n.add(t))}}return Array.from(e.values())}getByFloorId(e){const t=this.getFloorById(e);return t?this.loadForFloor(t):[]}getAllKiosks(){return this.getAll().filter(e=>E(e))}getKioskForFloor(e){const t=this.getFloorById(e);if(!t)return null;return this.loadForFloor(t).find(e=>E(e))??null}logKioskForFloor(e){const t=this.getFloorById(e);if(!t)return;const o=this.getKioskForFloor(e);o?this.log("amenity :: kiosk found",{floorId:t.id,id:o.id,name:o.name,keywords:o.keywords,waypoints:o.waypoints,raw:o}):this.log("amenity :: kiosk not found on floor",{floorId:t.id})}}const R="poi-highlight-ring";class D{getMap;log;raf=null;constructor(e){this.getMap=e.getMap,this.log=e.log??(()=>{})}highlight(e){const t=this.getMap();t&&(s.setData(t,u,{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}}]}),this.log("highlight :: set",e),this.startPulse())}clear(){this.stopPulse();const e=this.getMap();e&&s.setData(e,u,{type:"FeatureCollection",features:[]})}destroy(){this.stopPulse()}startPulse(){const e=this.getMap();if(!e||!e.getLayer(R))return;if(this.stopPulse(),"undefined"!=typeof window&&!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return void this.applyRing(e,.35);const t=performance.now(),o=i=>{const n=(i-t)%1600/1600;this.applyRing(e,n),this.raf=requestAnimationFrame(o)};this.raf=requestAnimationFrame(o)}applyRing(e,t){e.getLayer(R)&&(e.setPaintProperty(R,"circle-radius",14+26*t),e.setPaintProperty(R,"circle-opacity",.45*(1-t)))}stopPulse(){null!=this.raf&&(cancelAnimationFrame(this.raf),this.raf=null)}}g({enabled:!0,prefix:"MinuteMapsSDK"});class ${mode;proxyBaseUrl;direct;fetchImpl;tokenCache=null;constructor(e){const t="undefined"!=typeof window?window:globalThis,o=e.fetchImpl??t.fetch;if("function"!=typeof o)throw new Error("Fetch API is not available in this environment");this.fetchImpl=o.bind(t),this.mode=e.mode,this.proxyBaseUrl=("proxy"===e.mode?e.proxyBaseUrl:void 0)||"/api/jacs","direct"===e.mode?this.direct={host:this.normalizeHost(e.host),clientId:e.clientId,username:e.username,password:e.password}:this.direct=null}async getPolygonLayers(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/polygon-layer`,o=await this.getJson(t);return this.extractArray(o)}async getFloorMapTemplate3d(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/building/${encodeURIComponent(String(e.buildingId))}/floor/${encodeURIComponent(String(e.floorId))}/map-template/3d`,o=await this.getJson(t);return this.extractArray(o)}async getFloors(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/building/${encodeURIComponent(String(e.buildingId))}/floor`,o=await this.getJson(t);return this.extractArray(o)}async getVenueAll(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/all`,o=await this.getJson(t),i=o?.data||o?.result||o;if(!i||"object"!=typeof i)throw new Error("JACS venue/all response was not a JSON object");return i}async getVenue(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}`,o=await this.getJson(t),i=o?.venue||o?.data||o;if(!i||"object"!=typeof i)throw new Error("JACS venue response was not a JSON object");return i}async getFloorMapGeojson(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/building/${encodeURIComponent(String(e.buildingId))}/floor/${encodeURIComponent(String(e.floorId))}/map/geojson`,o=await this.getJson(t),i=o?.geojson||o?.data||o;if(!i||"FeatureCollection"!==i.type||!Array.isArray(i.features))throw new Error("JACS floor geojson did not look like a GeoJSON FeatureCollection");return i}async getBuildingFull(e){const t=new URLSearchParams;t.set("mapProfile",String(e.mapProfile??"public")),t.set("geojson",String(e.geojson??!0));const o=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/building/${encodeURIComponent(String(e.buildingId))}/full?${t.toString()}`,i=await this.getJson(o),n=i?.data||i?.result||i;if(!n||"object"!=typeof n)throw new Error("JACS building full response was not a JSON object");return n}async getDestinations(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/destination`,o=await this.getJson(t);return this.extractArray(o)}async getAmenities(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/amenity`,o=await this.getJson(t);return this.extractArray(o)}async getBuildings(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/building`,o=await this.getJson(t);return this.extractArray(o)}async getStylesheet3d(e){const t=`/customer/${encodeURIComponent(String(e.customerId))}/venue/${encodeURIComponent(String(e.venueId))}/building/${encodeURIComponent(String(e.buildingId))}/stylesheet/3d`,o=await this.getJson(t),i=o?.style||o?.data||o;if(!i||"object"!=typeof i)throw new Error("JACS stylesheet response was not a JSON object");return i}invalidateToken(){this.tokenCache=null}async getJson(e){if("proxy"===this.mode){const t=this.proxyBaseUrl.replace(/\/+$/,""),o=e.startsWith("/")?e:`/${e}`,i=await this.fetchImpl(`${t}${o}`,{method:"GET",headers:{Accept:"application/json"}});if(!i.ok){const e=await this.safeReadText(i);throw new Error(`JACS proxy GET failed (${i.status} ${i.statusText}) :: ${e}`)}return await i.json()}const t=this.direct;if(!t)throw new Error("JacsProvider is not configured for direct mode");const o=await this.getJwtToken(),i=this.joinUrl(t.host,e),n=await this.fetchImpl(i,{method:"GET",headers:{Authorization:`Bearer ${o}`,Accept:"application/json"}});if(!n.ok){const e=await this.safeReadText(n);throw new Error(`JACS GET failed (${n.status} ${n.statusText}) :: ${e}`)}return await n.json()}extractArray(e){return(Array.isArray(e)?e:null)||(Array.isArray(e?.data)?e.data:null)||(Array.isArray(e?.items)?e.items:null)||(Array.isArray(e?.results)?e.results:null)||[]}async getJwtToken(){const e=this.direct;if(!e)throw new Error("getJwtToken should not be called in proxy mode");const t=Date.now(),o=this.tokenCache;if(o?.token&&t<o.expiresAtMs-3e4)return o.token;const i=this.joinUrl(e.host,"/auth/token"),n=new URLSearchParams;n.set("grant_type","password"),n.set("client_id",e.clientId),n.set("username",e.username),n.set("password",e.password);const r=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:n.toString()});if(!r.ok){const e=await this.safeReadText(r);throw new Error(`JACS auth failed (${r.status} ${r.statusText}) :: ${e}`)}const s=await r.json(),a=s?.access_token||s?.token||s?.jwt||s?.accessToken;if(!a)throw new Error("JACS auth response did not contain a token");const l=s?.expires_in??s?.expiresIn??s?.expires??s?.ttl,c="number"==typeof l?l:Number(l),d=Number.isFinite(c)&&c>0?c:600;return this.tokenCache={token:a,expiresAtMs:Date.now()+1e3*d},a}normalizeHost(e){return String(e||"").replace(/\/+$/,"")}joinUrl(e,t){const o=this.normalizeHost(e),i=String(t||"");return i?`${o}${i.startsWith("/")?"":"/"}${i}`:o}async safeReadText(e){try{return await e.text()}catch{return""}}}const V=g({enabled:!0,prefix:"MinuteMapsSDK jacs"});function J(e){return null!=e&&"object"==typeof e?e.id:e}class N{config;jacs;floors=[];buildingId=null;destinationsByMapId=new Map;amenitiesByMapId=new Map;venueLike=null;async init(e){this.config=e;const t=e.jacs;if(!t?.mode)throw new Error("config.jacs.mode is required");if("proxy"!==t.mode){if(!t.host)throw new Error("config.jacs.host is required (direct mode)");if(!t.auth?.clientId)throw new Error("config.jacs.auth.clientId is required (direct mode)");if(!t.auth?.username)throw new Error("config.jacs.auth.username is required (direct mode)");if(!t.auth?.password)throw new Error("config.jacs.auth.password is required (direct mode)");this.jacs=new $({mode:"direct",host:t.host,clientId:t.auth.clientId,username:t.auth.username,password:t.auth.password})}else this.jacs=new $({mode:"proxy",proxyBaseUrl:t.proxyBaseUrl||"/api/jacs"})}async loadVenue(){const e=this.config.jmap.customerId,t=this.config.jmap.venueId;if(null==e)throw new Error("config.jmap.customerId is required");if(null==t)throw new Error("config.jmap.venueId is required");const o=await this.jacs.getVenueAll({customerId:e,venueId:t}),i=Array.isArray(o?.buildings)?o.buildings:[],n=i[0],r=n?.id??n?.buildingId;if(!n||!r)throw new Error("No buildings found for this venue in /all response");this.buildingId=r;const s=Array.isArray(o?.waypoints)?o.waypoints:[],a=Array.isArray(o?.destinations)?o.destinations:[],l=Array.isArray(o?.amenities)?o.amenities:[],c=new Map;for(const e of s){const t=e?.mapId;if(null==t)continue;const o=c.get(t)??[];o.push(e),c.set(t,o)}const d=Array.isArray(n?.floors)?n.floors:[],u=n?.defaultFloorId,p=d.map(e=>{const t=e.map?.id??e.mapId;return{id:e.id,mapId:t,name:e.name??e.shortName??String(e.id),sequence:e.level??e.preference,isDefault:e.id===u,geojson:void 0,mapTemplate3d:[],_waypoints:null!=t?c.get(t)??[]:[]}});this.floors=p;const f=new Map;for(const e of p)null!=e.mapId&&f.set(e.mapId,e.id);const g=o?.venue?.coordinates,h=new Map;for(const e of d){const t=e?.map?.id??e?.mapId,o="string"==typeof e?.map?.svg?e.map.svg:"";if(null==t||!o)continue;const i=/viewBox\s*=\s*["']([^"']+)["']/i.exec(o);if(!i)continue;const n=i[1].trim().split(/\s+/).map(Number);if(4!==n.length||n.some(e=>!Number.isFinite(e)))continue;const[,,r,s]=n;r>0&&s>0&&h.set(t,{width:r,height:s})}const y=(e,t,o)=>{if(!g)return null;const i=h.get(e);if(!i)return null;return[g.topLng+t/i.width*(g.bottomLng-g.topLng),g.topLat+o/i.height*(g.bottomLat-g.topLat)]},m=new Map;for(const e of s){const t=e?.id;if(null!=t){if(!Array.isArray(e.coordinates)&&null!=e.x&&null!=e.y&&null!=e.mapId){const t=y(e.mapId,Number(e.x),Number(e.y));t&&(e.coordinates=t)}m.set(t,e)}}let w=null;const b=this.config?.jmap?.deviceId;if(null!=b&&""!==b){const e=(Array.isArray(o?.devices)?o.devices:[]).find(e=>String(e?.id)===String(b)||e?.uuid===b);if(e){const t=s.find(t=>Array.isArray(t?.deviceIds)&&t.deviceIds.includes(e.id));if(t&&Array.isArray(t.coordinates)){const o=e?.heading,i="number"==typeof o&&Number.isFinite(o)?o:null;w={waypointId:t.id,floorId:f.get(t.mapId)??t.mapId,coordinates:t.coordinates,deviceName:e.name,heading:i,waypoint:t}}else V.warn("kiosk device has no placed waypoint",{deviceId:b})}else V.warn("kiosk device not found in venue devices",{deviceId:b})}const F=e=>Array.isArray(e)?e.map(e=>e&&"object"==typeof e?e:m.get(e)).filter(Boolean):[];for(const e of l)e.waypoints=F(e?.waypoints);for(const e of a)e.waypoints=F(e?.waypoints);this.amenitiesByMapId.clear();for(const e of l)for(const t of e?.waypoints??[]){const o=t?.mapId;if(null==o)continue;const i=f.get(o)??o,n=this.amenitiesByMapId.get(i)??[];n.push(e),this.amenitiesByMapId.set(i,n)}this.destinationsByMapId.clear();for(const e of a)for(const t of e?.waypoints??[]){const o=t?.mapId;if(null==o)continue;const i=f.get(o)??o,n=this.destinationsByMapId.get(i)??[];n.push(e),this.destinationsByMapId.set(i,n)}const I=o?.venue??{};return this.venueLike={...I,floors:p,polygonLayers:[],destinations:{items:[...a],getByMap:e=>this.destinationsByMapId.get(J(e))??[]},amenities:{items:[...l],getByMap:e=>this.amenitiesByMapId.get(J(e))??[]},buildings:{items:[...i],getAllFloors:()=>this.floors},styleSheet:null,kioskWaypoint:w},this.venueLike}async ensureFloorGeojson(e){if(e.geojson)return;const t=this.config.jmap.customerId,o=this.config.jmap.venueId;try{const i=await this.jacs.getFloorMapGeojson({customerId:t,venueId:o,buildingId:this.buildingId,floorId:e.id});e.geojson=function(e){return(e?.type?e:e?.data)??null}(i)}catch(t){V.warn("floor geojson fetch failed",{floorId:e.id,e:t})}}async preloadRemainingFloors(){const e=this.floors.filter(e=>!e.geojson);0!==e.length&&(await Promise.all(e.map(e=>this.ensureFloorGeojson(e))),V.debug("preloaded geojson for remaining floors",{count:e.length}))}async getFloors(){return this.floors}async getAmenities(e){return this.amenitiesByMapId.get(e)??[]}async getDestinations(e){return this.destinationsByMapId.get(e)??[]}}class H{handlers=new Map;on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t)}off(e,t){t?this.handlers.get(e)?.delete(t):this.handlers.delete(e)}emit(e,t){this.handlers.get(e)?.forEach(e=>{try{e(t)}catch{}})}}var K={version:8,name:"Hospital Indoor Mapping - Hybrid Style Healthcare Compliant",metadata:{description:"Accessibility-focused hospital navigation with proper healthcare standards",author:"Hospital Mapping Team",version:"7.1.0"},sprite:"http://localhost:4000/sprites/sprite",glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",sources:{protomaps:{type:"vector",url:"pmtiles://https://jacsdevtiles-gjgbejbpdzbgcge8.z01.azurefd.net/pmtiles/base/usa.pmtiles",attribution:"© OpenStreetMap contributors"},"indoor-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"poi-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"accessibility-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"unit-walls":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"route-data":{type:"geojson",data:{type:"FeatureCollection",features:[]},lineMetrics:!0},"route-endpoints":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"poi-highlight-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}}},layers:[{id:"background",type:"background",paint:{"background-color":"#f0f0f0"}},{id:"basemap-earth",type:"fill",source:"protomaps","source-layer":"earth",paint:{"fill-color":"#EFEAE0"}},{id:"basemap-landuse-park",type:"fill",source:"protomaps","source-layer":"landuse",filter:["in",["get","kind"],["literal",["park","forest","wood","nature_reserve","grass","garden","playground","cemetery","golf_course"]]],paint:{"fill-color":"#dde8d4","fill-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"basemap-water",type:"fill",source:"protomaps","source-layer":"water",paint:{"fill-color":"#d9e8f6"}},{id:"basemap-roads-minor",type:"line",source:"protomaps","source-layer":"roads",minzoom:13,filter:["in",["get","kind"],["literal",["minor_road","path","service","other"]]],paint:{"line-color":"#FFFFFF","line-width":["interpolate",["linear"],["zoom"],13,.5,16,1.5,19,4],"line-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"basemap-roads-major",type:"line",source:"protomaps","source-layer":"roads",minzoom:10,filter:["in",["get","kind"],["literal",["highway","major_road","medium_road"]]],paint:{"line-color":"#ecc97e","line-width":["interpolate",["linear"],["zoom"],10,.5,14,1.5,18,6],"line-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"pattern-water",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Water"],paint:{"fill-color":"#cfe1ec","fill-opacity":.6}},{id:"pattern-grass",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Grass"],paint:{"fill-color":"#d2e0c6","fill-opacity":.5}},{id:"pattern-trees",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Trees"],paint:{"fill-color":"#cdd9c9","fill-opacity":.4}},{id:"pattern-pavement",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Pavement"],paint:{"fill-color":"#E0E0E0","fill-opacity":.6}},{id:"pattern-outdoor-terrace",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-OutdoorTerrace"],paint:{"fill-color":"#cabfb6","fill-opacity":.3}},{id:"parking-lots",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Parking-Lots"],paint:{"fill-color":"#e0e0dd","fill-opacity":.5}},{id:"parking-lots-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Parking-Lots"],paint:{"line-color":"#b0b0ad","line-width":1,"line-dasharray":[3,2]}},{id:"boundary-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],paint:{"fill-color":"#FAF3E2","fill-opacity":1}},{id:"building-roof-fill",type:"fill",source:"indoor-data",minzoom:15.8,filter:["==",["get","featureType"],"Boundary"],paint:{"fill-color":"#162e51","fill-opacity":["interpolate",["linear"],["zoom"],15.8,0,16.5,1]}},{id:"corridors-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],paint:{"fill-color":"#F0E6D1"}},{id:"accessible-routes",type:"line",source:"accessibility-data",minzoom:16.5,filter:["==",["get","accessible"],!0],paint:{"line-color":"#2E7D32","line-width":["interpolate",["linear"],["zoom"],15,2,18,3,20,4],"line-dasharray":[.5,1],"line-opacity":.7}},{id:"units-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Units"],paint:{"fill-color":["case",["has","category"],["match",["get","category"],"healthcare","#73b3e7","surgical","#73b3e7","waiting","#73b3e7","diagnostic","#97d4ea","amenities","#97d4ea","emergency","#f2938c","retail","#fee685","fnb","#fee685","admin","#dfe1e2","staff","#dfe1e2","security","#dfe1e2","#73b3e7"],"#73b3e7"],"fill-opacity":["interpolate",["linear"],["zoom"],15,.85,17,.92,19,.95]}},{id:"units-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Units"],layout:{visibility:"none","line-join":"round","line-cap":"round"},paint:{"line-color":"#162e51","line-opacity":.9,"line-width":["interpolate",["linear"],["zoom"],16,.8,18,1.4,20,2.2]}},{id:"backofhouse-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"fill-color":"#e6e6e2","fill-opacity":.7}},{id:"backofhouse-pattern",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"line-color":"#c4c4c4","line-width":.5,"line-opacity":.4}},{id:"backofhouse-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#b0b1b5","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"restrooms-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],paint:{"fill-color":"#5f9070","fill-opacity":1}},{id:"restrooms-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#3f5d4a","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"obstacles-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],paint:{"fill-color":"#E8E9ED","fill-opacity":.85}},{id:"obstacles-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#B0B1B5","line-width":["interpolate",["linear"],["zoom"],16,.5,18,.9,20,1.2],"line-opacity":.9}},{id:"escalators-stairs-elevators",type:"fill",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],paint:{"fill-color":"#a9aeb1","fill-opacity":1}},{id:"escalators-stairs-elevators-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#6f7780","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"exits-doors",type:"fill",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Exits","Doors","Exit","Door"]]],paint:{"fill-color":"#cdd9c9","fill-opacity":.6}},{id:"kiosks-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Kiosks"],paint:{"fill-color":"#ffe396","fill-opacity":.7}},{id:"pattern-lounge",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Lounge"],paint:{"fill-color":"#ddd2e0","fill-opacity":.5}},{id:"pattern-indoor-foodcourt",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-IndoorFoodcourt"],paint:{"fill-color":"#f3e4c4","fill-opacity":.6}},{id:"corridors-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],paint:{"line-color":"#BCAAA4","line-width":["interpolate",["linear"],["zoom"],15,.5,18,1,20,1.5]}},{id:"boundary-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],paint:{"line-color":"#263238","line-width":["interpolate",["linear"],["zoom"],12,2,15,2.5,18,3,20,3.5],"line-opacity":["interpolate",["linear"],["zoom"],12,.7,17,.85,18,1]}},{id:"building-roof-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#c8a85a","line-width":["interpolate",["linear"],["zoom"],15,1.5,18,2,20,2.5],"line-opacity":.55}},{id:"interior-parking-lots",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"fill-color":"#757575","fill-opacity":.8}},{id:"interior-parking-lots-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"line-color":"#616161","line-width":1.5}},{id:"building-extrusion",type:"fill-extrusion",source:"indoor-data",filter:["==",["get","featureType"],"Boundary"],paint:{"fill-extrusion-color":"#162e51","fill-extrusion-height":15,"fill-extrusion-base":0,"fill-extrusion-opacity":["interpolate",["linear"],["zoom"],15.8,1,16.5,0]}},{id:"units-wall-extrusion",type:"fill-extrusion",source:"unit-walls",minzoom:16.5,filter:["all",["==",["get","featureType"],"UnitWalls"],["!",["has","custom_height"]]],paint:{"fill-extrusion-color":"#c4c8cb","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,["case",["==",["get","wallKind"],"interior"],.5,1],17.5,["case",["==",["get","wallKind"],"interior"],.7,1.4],18.2,["case",["==",["get","wallKind"],"interior"],.9,1.6]],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":1}},{id:"units-wall-custom-extrusion",type:"fill-extrusion",source:"unit-walls",minzoom:16.5,filter:["has","custom_height"],paint:{"fill-extrusion-color":"#c4c8cb","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":1}},{id:"corridors-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],layout:{visibility:"none"},paint:{"fill-extrusion-color":"#FFF8E1","fill-extrusion-height":["step",["zoom"],0,18,3.2],"fill-extrusion-base":0,"fill-extrusion-opacity":["step",["zoom"],0,18,.85]}},{id:"backofhouse-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"fill-extrusion-color":"#e6e6e2","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":1}},{id:"restrooms-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],paint:{"fill-extrusion-color":"#5f9070","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":.95}},{id:"obstacles-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],paint:{"fill-extrusion-color":"#E8E9ED","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,.4,17.5,.6,18.2,.8],"fill-extrusion-base":0,"fill-extrusion-opacity":1}},{id:"escalators-stairs-elevators-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],paint:{"fill-extrusion-color":"#a9aeb1","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":.9}},{id:"interior-parking-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"fill-extrusion-color":"#757575","fill-extrusion-height":["interpolate",["linear"],["zoom"],15,0,16,1,17,1.4,18,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":.85}},{id:"route-line",type:"line",source:"route-data",minzoom:16.5,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#007aff","line-width":["interpolate",["linear"],["zoom"],16.5,3,18,5,20,7],"line-opacity":.9}},{id:"route-halo",type:"line",source:"route-data",minzoom:16.5,paint:{"line-color":"white","line-width":["interpolate",["linear"],["zoom"],16.5,5,18,7,20,9],"line-opacity":.7}},{id:"route-endpoint-source",type:"circle",source:"route-endpoints",minzoom:16.5,filter:["==",["get","role"],"source"],paint:{"circle-radius":6,"circle-color":"#ffffff","circle-stroke-width":3,"circle-stroke-color":"#007aff","circle-opacity":1}},{id:"route-endpoint-destination",type:"circle",source:"route-endpoints",minzoom:16.5,filter:["==",["get","role"],"destination"],paint:{"circle-radius":7,"circle-color":"#007aff","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":1}},{id:"poi-accessibility-icons",type:"symbol",source:"poi-data",filter:["==",["get","accessible"],!0],minzoom:16.5,layout:{"icon-image":"wheelchair-accessible","icon-size":["interpolate",["linear"],["zoom"],15,.4,17,.6,19,.8],"icon-allow-overlap":!1,"icon-padding":4}},{id:"poi-destination-circles",type:"circle",source:"poi-data",filter:["==",["get","poiType"],"destination"],minzoom:16.5,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,6,18,8,20,10],"circle-color":"#ffffff","circle-stroke-width":3,"circle-stroke-color":"#162e51","circle-opacity":1}},{id:"poi-destination-labels",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"destination"],["==",["get","showLabel"],!0]],minzoom:16.5,layout:{"symbol-sort-key":0,"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16.5,18,18,20,20,23],"text-offset":[0,-.9],"text-anchor":"bottom","text-font":["Noto Sans Bold"],"text-max-width":12,"text-allow-overlap":!1,"text-padding":4,"text-rotation-alignment":"viewport"},paint:{"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1}},{id:"poi-entrance-exit-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["any",["!=",["index-of","entrance",["get","keywords"]],-1],["!=",["index-of","exit",["get","keywords"]],-1],["!=",["index-of","door",["get","keywords"]],-1]]],minzoom:15,layout:{"symbol-sort-key":1,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-parking-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["any",["!=",["index-of","parking",["get","keywords"]],-1],["!=",["index-of","park",["get","keywords"]],-1]]],minzoom:14,layout:{"symbol-sort-key":2,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-other-amenity-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["==",["index-of","entrance",["get","keywords"]],-1],["==",["index-of","exit",["get","keywords"]],-1],["==",["index-of","door",["get","keywords"]],-1],["==",["index-of","parking",["get","keywords"]],-1],["==",["index-of","park",["get","keywords"]],-1]],minzoom:16.5,layout:{"symbol-sort-key":3,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-you-are-here-heading",type:"symbol",source:"poi-data",filter:["all",["==",["get","isYouAreHere"],!0],["==",["get","hasHeading"],!0]],minzoom:16,layout:{"text-field":"▲","text-size":["interpolate",["linear"],["zoom"],16,28,18,34,20,42],"text-font":["Noto Sans Bold"],"text-anchor":"bottom","text-offset":[0,-.45],"text-rotate":["get","heading"],"text-rotation-alignment":"map","text-pitch-alignment":"map","text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#face00","text-halo-color":"#162e51","text-halo-width":2.5,"text-opacity":.9}},{id:"poi-you-are-here-ring",type:"circle",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,14,18,18,20,24],"circle-color":"#face00","circle-opacity":.25,"circle-pitch-alignment":"map"}},{id:"poi-you-are-here-dot",type:"circle",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,7,18,9,20,12],"circle-color":"#face00","circle-opacity":1,"circle-stroke-color":"#ffffff","circle-stroke-width":3,"circle-stroke-opacity":1}},{id:"poi-you-are-here",type:"symbol",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,layout:{"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,17,18,19,20,22],"text-offset":[0,-1.8],"text-anchor":"bottom","text-font":["Noto Sans Bold"],"text-allow-overlap":!0,"text-ignore-placement":!0,"text-optional":!1},paint:{"text-color":"#ffffff","text-halo-color":"#162e51","text-halo-width":2.5,"text-halo-blur":.5}},{id:"poi-highlight-ring",type:"circle",source:"poi-highlight-data",paint:{"circle-radius":14,"circle-color":"#005ea2","circle-opacity":.45,"circle-pitch-alignment":"map"}},{id:"poi-highlight-core",type:"circle",source:"poi-highlight-data",paint:{"circle-radius":9,"circle-color":"#005ea2","circle-opacity":1,"circle-stroke-color":"#ffffff","circle-stroke-width":3,"circle-stroke-opacity":1,"circle-pitch-alignment":"map"}}]};const W={"#162e51":"#000000","#263238":"#000000","#c8a85a":"#ffd600","#face00":"#ffd600","#73b3e7":"#1565c0","#97d4ea":"#1976d2","#f2938c":"#c62828","#fee685":"#f9a825","#dfe1e2":"#757575","#faf3e2":"#ffffff","#f0e6d1":"#f5f5f5","#5f9070":"#2e7d32","#3f5d4a":"#1b5e20","#c4c8cb":"#616161","#a9aeb1":"#424242","#6f7780":"#212121","#e8e9ed":"#bdbdbd","#b0b1b5":"#424242","#e6e6e2":"#9e9e9e","#242930":"#000000","#b0b0ad":"#000000","#cfe1ec":"#b3e5fc","#d2e0c6":"#c8e6c9","#cdd9c9":"#a5d6a7","#e0e0e0":"#eeeeee","#cabfb6":"#bcaaa4","#ddd2e0":"#ce93d8","#f3e4c4":"#ffe082","#e0e0dd":"#bdbdbd","#b0b0ad ":"#000000","#bcaaa4":"#5d4037","#757575":"#424242","#616161":"#212121","#007aff":"#0050b3","#ffffff":"#ffffff","#005ea2":"#0050b3"};function Y(e){if(Array.isArray(e))return e.map(Y);if(e&&"object"==typeof e){const t={};for(const[o,i]of Object.entries(e))t[o]=Y(i);return t}return"string"!=typeof(t=e)?t:W[t.toLowerCase()]??t;var t}const _=function(){const e=structuredClone(K);for(const t of e.layers??[])if(t.paint&&(t.paint=Y(t.paint)),t.paint&&"text-halo-width"in t.paint){const e=t.paint["text-halo-width"];"number"==typeof e&&(t.paint["text-halo-width"]=e+2)}return e}(),q=K;function G(e){return"high-contrast"===e?_:q}function Z(e,t,o={}){e.sources||={},e.sources[t]||(e.sources[t]={type:"geojson",data:{type:"FeatureCollection",features:[]},...o})}function X(e){let t=structuredClone(e.style);if(t.sprite=e.customSprite||t.sprite||e.defaultSpriteUrl,Z(t,a),Z(t,c),Z(t,l),Z(t,d,{lineMetrics:!0}),Z(t,"route-endpoints"),e.floorLayers)for(const o of Object.keys(e.floorLayers))Z(t,`amenity_${o}`),Z(t,`destination_${o}`),Z(t,`pathTypes_${o}`);return t}const Q="https://demotiles.maplibre.org/styles/osm-bright-gl-style/sprite";class ee{config;map=null;data=new N;wayfindingProvider={wayfindBetweenWaypoints:async()=>{throw new Error("Wayfinding is not yet implemented in the SDK")}};events=new H;floorsApi;venue=null;spriteKeys=null;debug;logger;defaultCamera=null;viewModes;reducedMotion=!1;activeThemeName="default";amenityManager;wayfinding;highlightManager;static POI_CATEGORY_LAYERS=[{id:"poi-destination-circles",category:"destination"},{id:"poi-destination-labels",category:"destination"},{id:"poi-entrance-exit-icons",category:"amenity"},{id:"poi-parking-icons",category:"amenity"},{id:"poi-other-amenity-icons",category:"amenity"}];poiVisibleTypes=null;constructor(e){this.config=e,this.debug=Boolean(e.debug??e.options?.debug),this.logger=g({enabled:this.debug,prefix:"MinuteMapsSDK"}),this.viewModes=new S(()=>this.map),this.reducedMotion=Boolean(e.options?.reducedMotion),this.activeThemeName="high-contrast"===e.options?.theme?"high-contrast":"default",this.floorsApi=new m({getMap:()=>this.map,getConfig:()=>this.config,updatePoiSource:async e=>{const t=this.map;if(!t)return;const o=this.getAllPOIs(e),i=P.toFeatureCollection(o);s.setData(t,l,i)},log:(...e)=>this.logger.debug(...e)}),this.amenityManager=new U({getVenue:()=>this.venue,getFloors:()=>this.floorsApi.getFloors(),getFloorById:e=>this.floorsApi.getFloors().find(t=>t.id===e)??null,log:(...e)=>this.logger.debug(...e)}),this.wayfinding=new j({getMap:()=>this.map,getVenue:()=>this.venue,getYouAreHerePOI:e=>this.getYouAreHerePOI(e),getYouAreHereCoordinates:e=>this.getYouAreHereCoordinates(e),getBoundsPadding:()=>this.getBoundsPadding(),computeRoute:async(e,t,o)=>{const i=this.config.jmap.customerId,n=this.config.jmap.venueId;if(null==i)throw new Error("config.jmap.customerId is required");if(null==n)throw new Error("config.jmap.venueId is required");return this.wayfindingProvider.wayfindBetweenWaypoints({customerId:i,venueId:n,from:e,to:t,options:o})},getReducedMotion:()=>this.reducedMotion,log:(...e)=>this.logger.debug(...e),warn:(...e)=>this.logger.warn(...e),debug:this.debug}),this.highlightManager=new D({getMap:()=>this.map,log:(...e)=>this.logger.debug(...e)})}async init(){const{venueId:e,customerId:t}=this.config?.jmap;if(null==e||null==t)throw new Error("config.jmap.customerId and config.jmap.venueId are required");if(!this.config.container)throw new Error("config.container is required (HTMLElement or element id)");this.logger.debug("init :: starting (JACS)",{venueId:e,customerId:t});try{await this.data.init(this.config),this.logger.debug("providers :: JACS ready"),this.venue=await this.data.loadVenue(),this.logger.debug("JACS :: venue loaded",this.venue.id),this.floorsApi.setFloors(this.venue.floors),this.logger.debug("JACS :: floors loaded",{count:this.venue.floors.length});const e=X({style:G("custom"===this.activeThemeName?"default":this.activeThemeName),customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Q});this.ensureFloorLayersFromStyle(e),this.map=r(this.config.container,e),await new Promise(e=>this.map.once("load",()=>e())),this.map.on("error",e=>{const t=e?.error?.message||e?.message||e;this.logger.error("map :: error",{msg:t,sourceId:e?.sourceId,tile:e?.tile})}),this.map.on("styledata",()=>{try{this.viewModes.onStyleData()}catch{}}),this.map.on("move",()=>{if(!this.map)return;const e=k(this.map);e&&this.events.emit("cameraChange",{camera:e})}),this.ensureCoreSources(),this.spriteKeys=await F.getSpriteKeys(this.map);try{await v.register(this.map,this.venue?.amenities?.items)}catch(e){this.logger.warn("amenity icon registration failed",e)}const t=this.floorsApi.getInitialFloor();Boolean(t?.geojson?.features?.length)||this.applyInitialViewFromVenue(),t&&await this.setCurrentFloor(t),this.defaultCamera=k(this.map),this.events.emit("ready",{venue:this.venue}),this.events.emit("floorsLoaded",{})}catch(e){throw this.logger.error("init :: failed (JACS)",e),this.events.emit("error",{error:e}),e}}on(e,t){this.events.on(e,t)}off(e,t){this.events.off(e,t)}addControl(e,t){this.map?.addControl(e,t)}setView(e){M(this.map,e)}get amenities(){return this.amenityManager}resetView(e){!function(e,t,o){if(!e||!t)return;const{center:i,zoom:n,pitch:r,bearing:s}=t,a=Boolean(o?.animate),l="number"==typeof o?.duration?o.duration:800;a?e.easeTo({center:i,zoom:n,pitch:r,bearing:s,duration:l}):e.jumpTo({center:i,zoom:n,pitch:r,bearing:s})}(this.map,this.defaultCamera,e)}refit(e){if(!this.map)return;const t=this.wayfinding.getActiveRouteBounds();if(t)return void this.fitToBounds(t,e);const o=this.getCurrentFloor();if(!o?.geojson)return;const i=h.boundsFromGeoJson(o.geojson);i&&this.fitToBounds(i,e)}fitToBounds(e,t){const o=this.map;if(o)try{o.fitBounds(e,{padding:this.getBoundsPadding(),bearing:o.getBearing(),pitch:o.getPitch(),animate:t?.animate??!0,duration:t?.duration??600,maxZoom:21})}catch(e){this.logger.warn("refit :: fitBounds failed",e)}}set3dEnabled(e){this.viewModes.set3dEnabled(e)}toggle3d(){this.viewModes.toggle3d()}getIs3dEnabled(){return this.viewModes.getIs3dEnabled()}async setTheme(e){const t=this.map;if(!t)return void this.logger.warn("setTheme :: map not initialized");const o="default"===e?"default":"high-contrast"===e?"high-contrast":"custom";if("custom"!==o&&o===this.activeThemeName)return void this.logger.debug("setTheme :: noop, theme already active",o);const i=e=>{const o=t.getSource(e);return o?._data??null},n=i(a),r=i(c),s=i(l),p=i(d),f=i("route-endpoints"),g=i(u),h=X({style:"custom"===o?e:G(o),customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Q});await new Promise((e,i)=>{const y=()=>{try{const i=(e,o)=>{if(null==o)return;const i=t.getSource(e);i?.setData&&i.setData(o)};i(a,n),i(c,r),i(l,s),i(d,p),i("route-endpoints",f),i(u,g),t.off("style.load",y),this.activeThemeName=o,this.events.emit("themeChanged",{theme:o}),this.logger.debug("setTheme :: applied",o),e()}catch(e){this.logger.warn("setTheme :: restore failed",e),i(e)}};t.on("style.load",y),t.setStyle(h,{diff:!1})})}getActiveTheme(){return this.activeThemeName}setReducedMotion(e){this.reducedMotion=Boolean(e)}getReducedMotion(){return this.reducedMotion}setUnits2dEnabled(e){this.viewModes.setUnits2dEnabled(e)}toggleUnits2d(){this.viewModes.toggleUnits2d()}getIsUnits2dEnabled(){return this.viewModes.getIsUnits2dEnabled()}setFlatMode(e){this.viewModes.setFlatMode(e)}toggleFlatMode(){this.viewModes.toggleFlatMode()}getIsFlatMode(){return this.viewModes.getIsFlatMode()}getFloors(){return this.floorsApi.getFloors()}getCurrentFloor(){return this.floorsApi.getCurrentFloor()}getDefaultFloor(){return this.floorsApi.getDefaultFloor()}getDestinations(e){const t=e||this.getCurrentFloor();return function(e,t){if(!e||!t)return[];try{const o=e.destinations?.getByMap?.({id:t.id})||[];return Array.isArray(o)?o:[]}catch{return[]}}(this.venue,t)}getPolygonLayers(){return this.venue?.polygonLayers??[]}getFloorMapTemplate3d(e){return this.venue?.mapTemplates3d?.[String(e)]??[]}getAllPOIs(e){const t=e||this.getCurrentFloor();if(!t)return[];return function(e,t,o,i,n){return P.buildPOIs(e,t,o,i,n)}(t,this.amenityManager.getByFloorId(t.id),this.getDestinations(t),this.spriteKeys,this.venue?.kioskWaypoint)}getYouAreHerePOI(e){return C(this.getAllPOIs(e))}getYouAreHereCoordinates(e){return function(e){const t=C(e);return t?.coordinates??null}(this.getAllPOIs(e))}getKioskHeading(){const e=this.venue?.kioskWaypoint,t=e?.heading;return"number"==typeof t&&Number.isFinite(t)?t:null}recenterOnKiosk(e){const t=this.map;if(!t)return;const o=this.getYouAreHereCoordinates();if(!o)return void this.logger.warn("recenterOnKiosk :: no You-Are-Here coordinates available");const i=(e?.animate??!0)&&!this.reducedMotion,n=i?e?.duration??600:0,r=!1!==e?.useHeading?this.getKioskHeading():null;M(t,{center:o,zoom:e?.zoom,pitch:e?.pitch,bearing:r??void 0,animate:i,duration:n})}searchPOIs(e,t){return function(e,t){const o=t.trim().toLowerCase();return o?e.filter(e=>{const t=e.name?.toLowerCase().includes(o),i=(e.keywords||[]).some(e=>e.toLowerCase().includes(o));return t||i}):[]}(this.getAllPOIs(t),e)}searchAllPOIs(e){const t=e?.trim();return t?this.getFloors().flatMap(e=>this.searchPOIs(t,e)):[]}async wayfindBetweenWaypoints(e,t,o){return this.wayfinding.wayfindBetweenWaypoints(e,t,o)}async navigateFromKioskToDestination(e){return this.wayfinding.navigateFromKioskToDestination(e)}async navigateFromKioskToPOI(e,t){const o=e?.waypoint;if(!o)return void this.logger.warn("navigateFromKioskToPOI :: POI has no waypoint",e);const i=this.getYouAreHerePOI()?.waypoint;if(i)return this.wayfinding.wayfindBetweenWaypoints(i,o,{centerMode:"route",accessible:t?.accessible,avoidStairs:t?.avoidStairs});this.logger.warn("navigateFromKioskToPOI :: no kiosk waypoint available")}clearRoute(){this.wayfinding.clearRoute()}async highlightPOI(e){let t=null,o=null;for(const i of this.getFloors()){const n=this.getAllPOIs(i).find(t=>String(t.id)===String(e));if(n){t=n,o=i;break}}t&&o?(String(this.getCurrentFloor()?.id)!==String(o.id)&&await this.setCurrentFloor(o),this.setView({center:t.coordinates,animate:!0,duration:600}),this.highlightManager.highlight(t.coordinates)):this.logger.warn("highlightPOI :: no POI found for id",e)}clearHighlight(){this.highlightManager.clear()}setPOIFilter(e){this.poiVisibleTypes=new Set(e),this.applyPOIFilter()}clearPOIFilter(){this.poiVisibleTypes=null,this.applyPOIFilter()}applyPOIFilter(){const e=this.map;if(!e)return;const t=this.poiVisibleTypes;for(const{id:o,category:i}of ee.POI_CATEGORY_LAYERS){if(!e.getLayer(o))continue;const n=null===t||t.has(i);e.setLayoutProperty(o,"visibility",n?"visible":"none")}}findClosestWaypoint(e,t){if(!e?.length)return null;const o=t??this.getYouAreHereCoordinates();if(!o)return e.find(e=>Array.isArray(e.coordinates)&&e.coordinates.length>=2)??null;let i=null,n=1/0;for(const t of e){const e=t.coordinates;if(!Array.isArray(e)||e.length<2)continue;const r=e[0]-o[0],s=e[1]-o[1],a=r*r+s*s;a<n&&(n=a,i=t)}return i}async highlightAmenity(e){const t=this.amenityManager.getDistinct().find(t=>String(t.id)===String(e));if(!t||!t.waypoints?.length)return void this.logger.warn("highlightAmenity :: no waypoints for amenity",e);const o=this.findClosestWaypoint(t.waypoints);if(!o||!Array.isArray(o.coordinates)||o.coordinates.length<2)return void this.logger.warn("highlightAmenity :: no usable waypoint",e);const i=this.findFloorForWaypoint(o);i&&String(this.getCurrentFloor()?.id)!==String(i.id)&&await this.setCurrentFloor(i);const n=[o.coordinates[0],o.coordinates[1]];this.setView({center:n,animate:!0,duration:600}),this.highlightManager.highlight(n)}findFloorForWaypoint(e){const t=e.mapId;return null==t?null:this.getFloors().find(e=>{const o=e.mapId??e.id;return String(o)===String(t)})??null}getCameraPosition(){return k(this.map)}getMap(){return this.map}destroy(){this.highlightManager.destroy(),this.map?.remove(),this.map=null,this.floorsApi.setFloors([]),this.defaultCamera=null,this.viewModes=new S(()=>this.map)}async setCurrentFloor(e){await this.data.ensureFloorGeojson(e),await this.floorsApi.setCurrentFloor(e),this.setFloorLayerVisibility(e.id),this.events.emit("floorChanged",{floor:e})}isReady(){return!!this.map}setFloorLayerVisibility(e){const t=this.map;if(!t)return;const o=this.venue?.styleSheet?.floorLayers;if(o)for(const[i,n]of Object.entries(o)){const o=String(i)===String(e);for(const e of n)t.getLayer(e.id)&&t.setLayoutProperty(e.id,"visibility",o?"visible":"none")}}getBoundsPadding(){const e=this.config.options?.boundsPadding??50;if("number"==typeof e||!this.map)return e;const t=this.map.getContainer();return this.clampPadding(e,t.clientWidth,t.clientHeight)}clampPadding(e,t,o){const i=(e,t,o)=>{if(!(o>0))return[e,t];const i=.8*o,n=e+t;if(n<=i)return[e,t];const r=i/n;return[e*r,t*r]},[n,r]=i(e.top,e.bottom,o),[s,a]=i(e.left,e.right,t);return{top:n,bottom:r,left:s,right:a}}getVenueBounds(){const e=this.venue?.coordinates;if(!e)return null;const{bottomLng:t,bottomLat:o,topLng:i,topLat:n}=e;if(null==t||null==o||null==i||null==n)return null;const r=Math.min(t,i),s=Math.max(t,i);return[[r,Math.min(o,n)],[s,Math.max(o,n)]]}applyInitialViewFromVenue(){const e=this.map;if(!e)return;const t=this.getVenueBounds();if(t)try{e.resize(),e.fitBounds(t,{padding:this.getBoundsPadding(),animate:!1,duration:0,maxZoom:21})}catch(e){this.logger.warn("applyInitialViewFromVenue :: fitBounds failed",e)}}async loadAndPatchVenueStyle(){const e=this.venue?.styleSheet?.styleUrl,t=this.venue?.styleSheet?.floorLayers,o=q;if("sdkTemplate"===this.config.options?.styleMode)return this.logger.debug("style :: styleMode=sdkTemplate, ignoring venue styleUrl"),X({style:o,floorLayers:t,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Q});if(!e)return this.logger.warn("style :: venue.styleSheet.styleUrl missing, using baseStyle"),X({style:o,floorLayers:t,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Q});try{const o=await fetch(e);if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);return X({style:await o.json(),floorLayers:t,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Q})}catch(e){return this.logger.warn("style :: failed to fetch venue styleUrl, using baseStyle",e),X({style:o,floorLayers:t,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Q})}}ensureFloorLayersFromStyle(e){const t=this.venue?.styleSheet?.floorLayers;if(t&&Object.keys(t).length)return;const o={};for(const t of e.layers||[]){const e=t.id||"",i=/_(\d+)$/.exec(e);if(!i)continue;const n=i[1];o[n]||=[],o[n].push({id:e})}this.venue||={},this.venue.styleSheet||={},this.venue.styleSheet.floorLayers=o}ensureCoreSources(){const e=this.map;if(!e)return;const t={type:"FeatureCollection",features:[]};s.ensureGeoJson(e,a),s.ensureGeoJson(e,c),s.ensureGeoJson(e,l),s.ensureGeoJson(e,u),e.getSource(d)||e.addSource(d,{type:"geojson",data:t,lineMetrics:!0}),e.getSource("route-endpoints")||e.addSource("route-endpoints",{type:"geojson",data:t})}}exports.MinuteMaps=ee,exports.createMinuteMapsSDK=function(e){return new ee(e)};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|