mahal_map 2.2.2 → 2.2.3

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.mjs CHANGED
@@ -67,7 +67,7 @@ var Se=Object.defineProperty;var B=(i,e)=>{for(var t in e)Se(i,t,{get:e[t],enume
67
67
  />
68
68
  </clipPath>
69
69
  </defs>
70
- </svg>`;var G=class{constructor(e){this.props=e;this.element=this.createElement()}createElement(){let e=document.createElement("div");e.style.cursor="pointer";let t=this.props.svg?this.applyColorToCustomSvg(this.props.svg):pe(this.props.color??"#278960",{innerSvg:this.props.innerSvg,innerUrl:this.props.innerUrl});return e.innerHTML=t,this.props.draggable&&(e.draggable=!0),e}applyColorToCustomSvg(e){return this.props.color?e.replace(/fill="[^"]*"/g,`fill="${this.props.color}"`):e}getElement(){return this.element}getCoordinates(){return this.props.coordinates}isDraggable(){return!!this.props.draggable}getAnchor(){return this.props.anchor||"center"}};function he(i,e,t){return new i.Marker({element:t.getElement(),draggable:t.isDraggable?.()??!1,anchor:t.getAnchor?.()??"center"}).setLngLat(t.getCoordinates()).addTo(e)}var Je={dark:"#ffffff",light:"#19191a"},de="buildings",l=class l{constructor(){this.isReady=!1;this.readyCallbacks=[];this.language="tj";this.instanceKey="";this.gramBase=R;this.styleFamily="default";this.presetIsExplicit=!1;this.buildingsEnabled=!1;this.pendingLayerSubscribers=new Set}static getInstanceKey(e){return typeof e.container=="string"&&e.container?e.container:"map"}static normalizeLanguage(e){return e==="ru"?"ru":"tj"}static setDefaultLanguage(e){l.defaultLanguage=l.normalizeLanguage(e)}static getFallbackStyle(){return Y(_,l.getMapToken())}static getMapToken(){let e=M();if(!e)throw new Error("[MahalMap SDK] Map API key is required. Call keyUtils.saveKey() before creating the map or pass apikey in the SDK script URL.");return e}static getMaps3DCtor(e){if(e)return e;if(typeof window>"u")return;let t=window.Maps3D;return typeof t=="function"?t:t?.Maps3D}static async ensureJSApiSubscription(e){if(e)return;let t=M();if(!t)return;let r;try{r=await C(t)}catch(a){console.warn("[MahalMap SDK] JSApi subscription check failed, continuing without it:",a);return}if(!r.success)throw new Error(`[MahalMap SDK] JSApi subscription is not active for this key: ${r.message}`)}static async createAsync(e,t,r){return await l.ensureJSApiSubscription(l.getMaps3DCtor(r)),l.create(e,t,r)}static resolveStyleName(e,t,r){return e.style||e.preset||T(t,r)}static buildPlatformMapOptions(e,t,r,a,s){try{return e.mapOptions?e.mapOptions({base:t,apiKey:r,style:a,antialias:s}):{style:e.styleUrl?e.styleUrl(a,t):l.requireAbsoluteStyle(a),transformRequest:e.transformRequest({base:t,apiKey:r}),...s?{canvasContextAttributes:{antialias:!0}}:{}}}catch(n){throw new Error(`[MahalMap SDK] Maps3D rejected the style "${a}": ${n instanceof Error?n.message:String(n)}`)}}static requireAbsoluteStyle(e){if(/^https?:/i.test(e))return e;throw new Error("this Maps3D build has no styleUrl() \u2014 pass options.style as a full URL or upgrade @grammaps/maps3d-web to >=0.5.0")}static create(e,t,r){let a=typeof window<"u"?window.maplibregl:void 0,s=t||a;if(!s)throw new Error("[MahalMap SDK] MapLibre GL was not found. Pass it as the second argument or include it through a script.");let n=l.normalizeLanguage(e.lang||l.defaultLanguage),p=e.theme==="dark"?"dark":"light",o=new l,h=l.getInstanceKey(e);o.options=e,o.language=n,o.instanceKey=h,o.maplibre=s;let d=l.getMapToken(),u=l.getMaps3DCtor(r);o.gramBase=(e.base||R).replace(/\/+$/,""),o.styleFamily=e.family||"default",o.presetIsExplicit=!!(e.style||e.preset),o.maps3dCtor=u;let c=e.enable3D!==!1&&!!u;o.buildingsEnabled=c&&e.maps3d?.buildings!==!1,e.enable3D!==!1&&!u&&console.warn("[MahalMap SDK] Maps3D was not found \u2014 falling back to the plain vector style without 3D. Pass Maps3D as the third argument to create() or include it through a script (window.Maps3D).");let m=e.antialias!==void 0?e.antialias:c,g=u?l.buildPlatformMapOptions(u,o.gramBase,d,l.resolveStyleName(e,o.styleFamily,p),m):void 0,b=c?58:0;return o.map=new s.Map({container:e.container||"map",style:g?g.style:e.style||l.getFallbackStyle(),center:e.center||[69.624024,40.279687],zoom:e.zoom!==void 0?e.zoom:5,attributionControl:!1,pitch:e.pitch!==void 0?e.pitch:b,...e.bearing!==void 0?{bearing:e.bearing}:{},...g?{transformRequest:g.transformRequest,...g.canvasContextAttributes?{canvasContextAttributes:g.canvasContextAttributes}:{}}:{}}),c&&(o.maps3dLayer=o.createMaps3DLayer(d),o.attachMaps3DLayer(o.maps3dLayer)),o.watchWorkerHealth(),o.addLogo(p),o.map.on("load",()=>{o.isReady=!0,o.camera=new v(o.map),o.readyCallbacks.forEach(be=>be(o.map)),o.readyCallbacks=[]}),l.instances.set(h,o),o}static onReady(e,t){if(!l.instances.has(e)){let a=setInterval(()=>{l.instances.has(e)&&(clearInterval(a),l.onReady(e,t))},50);return}let r=l.getInstance(e);r.isReady?t(r.map):r.readyCallbacks.push(t)}static getInstance(e){let t=l.instances.get(e);if(!t)throw new Error("[MahalMap SDK] Map instance is not created");return t}static hasInstance(e){return l.instances.has(e)}static removeInstance(e){return l.instances.delete(e)}static addMarker(e,t){return e.addMarker(t)}static getCamera(e){return e.getCamera()}static getMap(e){return e.getMap()}static setStyle(e,t){e.setStyle(t)}static getMaps3DLayer(e){return e.getMaps3DLayer()}static whenMaps3DReady(e){return e.whenMaps3DReady()}static toggle3DBuildings(e,t){e.toggle3DBuildings(t)}static setLayer(e,t,r,a){return e.setLayer(t,r,a)}static getLayerState(e,t){return e.getLayerState(t)}static getLayers(e){return e.getLayers()}static onLayers(e,t){return e.onLayers(t)}static refreshLayers(e){e.refreshLayers()}static getIndoorLevels(e){return e.getIndoorLevels()}static setIndoorLevel(e,t){e.setIndoorLevel(t)}static refreshIndoor(e){e.refreshIndoor()}static showPlace(e,t,r,a,s){e.showPlace(t,r,a,s)}static onBuildingClick(e,t){e.onBuildingClick(t)}static selectBuilding(e,t,r){return e.selectBuilding(t,r)}static clearSelection(e){e.clearSelection()}static selectedBuilding(e){return e.selectedBuilding()}static setSelectionStyle(e,t){e.setSelectionStyle(t)}static onRoadClick(e,t){e.onRoadClick(t)}static roadAt(e,t,r){return e.roadAt(t,r)}static onParkingHover(e,t){e.onParkingHover(t)}static setParkingHoverStyle(e,t){e.setParkingHoverStyle(t)}static setParkingHoverEnabled(e,t){e.setParkingHoverEnabled(t)}static hoverParking(e,t){return e.hoverParking(t)}static hoveredParking(e){return e.hoveredParking()}static onParkingClick(e,t){e.onParkingClick(t)}static parkingAt(e,t,r){return e.parkingAt(t,r)}static onBuildingHover(e,t){e.onBuildingHover(t)}static setHoverEnabled(e,t){e.setHoverEnabled(t)}static setHoverStyle(e,t){e.setHoverStyle(t)}static hoverBuilding(e,t){return e.hoverBuilding(t)}static hoveredBuilding(e){return e.hoveredBuilding()}static setLanguage(e,t){e.setLanguage(t)}static setCenter(e,t){e.setCenter(t)}static setZoom(e,t){e.setZoom(t)}static destroy(e){e.destroy()}addMarker(e){return he(this.maplibre,this.map,e)}init(e){this.map=e,this.camera=new v(e)}getCamera(){return this.camera}getMap(){return this.map}setStyle(e){if(this.options.theme=e,this.presetIsExplicit)return;let t=this.resolvePlatformStyle(T(this.styleFamily,e));t&&(this.refreshLayersOnStyleChange(),this.map.setStyle(t),this.updateLogoColor(e))}resolvePlatformStyle(e){let t=this.maps3dCtor;if(t)try{return t.mapOptions?t.mapOptions({base:this.gramBase,apiKey:M(),style:e}).style:t.styleUrl?.(e,this.gramBase)}catch(r){console.error(`[MahalMap SDK] Maps3D rejected the style "${e}"`,r);return}}refreshLayersOnStyleChange(){let e=this.map;if(typeof e.on!="function"||typeof e.off!="function")return;this.styleChangeHandler&&e.off("styledata",this.styleChangeHandler);let t=()=>{typeof e.isStyleLoaded=="function"&&!e.isStyleLoaded()||(e.off?.("styledata",t),this.styleChangeHandler=void 0,this.maps3dLayer?.refreshLayers?.())};this.styleChangeHandler=t,e.on("styledata",t)}setLanguage(e){this.language=l.normalizeLanguage(e),this.options.lang=this.language}getMaps3DLayer(){return this.maps3dLayer}toggle3DBuildings(e){if(!(!this.maps3dLayer&&e&&(this.maps3dCtor=this.maps3dCtor||l.getMaps3DCtor(),!this.maps3dCtor))){if(this.buildingsEnabled=e,!this.maps3dLayer){if(!e)return;this.maps3dLayer=this.createMaps3DLayer(M()||void 0),this.attachMaps3DLayer(this.maps3dLayer);return}this.applyMaps3DBuildingMode(e)}}whenMaps3DReady(){return this.maps3dReady||Promise.resolve(void 0)}setLayer(e,t,r){return e===de&&(this.buildingsEnabled=t),this.maps3dLayer?.setLayer?.(e,t,r)??!1}getLayerState(e){return this.maps3dLayer?.layer?.(e)??null}getLayers(){return this.maps3dLayer?.layers?.()??[]}onLayers(e){let t={callback:e,unsubscribe:this.maps3dLayer?.onLayers?.(e)};return this.pendingLayerSubscribers.add(t),()=>{this.pendingLayerSubscribers.delete(t)&&t.unsubscribe?.()}}refreshLayers(){this.maps3dLayer?.refreshLayers?.()}getIndoorLevels(){return this.maps3dLayer?.indoorLevels??[]}setIndoorLevel(e){this.maps3dLayer?.setIndoorLevel?.(e)}refreshIndoor(){this.maps3dLayer?.refreshIndoor?.()}showPlace(e,t,r,a){this.maps3dLayer?.showPlace?.(e,t,r,a)}onBuildingClick(e){this.pendingBuildingClick=e,this.maps3dLayer?.onBuildingClick?.(e)}selectBuilding(e,t){return this.maps3dLayer?.selectBuilding?.(e,t)??!1}clearSelection(){this.maps3dLayer?.clearSelection?.()}selectedBuilding(){return this.maps3dLayer?.selectedBuilding?.()??null}setSelectionStyle(e){this.pendingSelectionStyle=e,this.maps3dLayer?.setSelectionStyle?.(e)}onRoadClick(e){this.pendingRoadClick=e,this.maps3dLayer?.onRoadClick?.(e)}roadAt(e,t){return this.maps3dLayer?.roadAt?.(e,t)??null}get roadsNamed(){return this.maps3dLayer?.roadsNamed??!1}onParkingHover(e){this.maps3dLayer?.onParkingHover?.(e)}setParkingHoverStyle(e){this.maps3dLayer?.setParkingHoverStyle?.(e)}setParkingHoverEnabled(e){this.maps3dLayer?.setParkingHoverEnabled?.(e)}get parkingHoverEnabled(){return this.maps3dLayer?.parkingHoverEnabled??!1}hoverParking(e){return this.maps3dLayer?.hoverParking?.(e)??!1}hoveredParking(){return this.maps3dLayer?.hoveredParking?.()??null}onParkingClick(e){this.maps3dLayer?.onParkingClick?.(e)}parkingAt(e,t){return this.maps3dLayer?.parkingAt?.(e,t)??null}onBuildingHover(e){this.pendingBuildingHover=e,this.maps3dLayer?.onBuildingHover?.(e)}setHoverEnabled(e){this.pendingHoverEnabled=e,this.maps3dLayer?.setHoverEnabled?.(e)}get hoverEnabled(){return this.maps3dLayer?.hoverEnabled??!1}setHoverStyle(e){this.pendingHoverStyle=e,this.maps3dLayer?.setHoverStyle?.(e)}hoverBuilding(e){return this.maps3dLayer?.hoverBuilding?.(e)??!1}hoveredBuilding(){return this.maps3dLayer?.hoveredBuilding?.()??null}createMaps3DLayer(e){let t={...this.options.maps3d,apiKey:e,base:this.gramBase};return this.maps3dCtor.enhance?this.maps3dCtor.enhance(this.map,t):new this.maps3dCtor(t)}applyPendingSubscriptions(e){this.pendingBuildingClick&&e.onBuildingClick?.(this.pendingBuildingClick),this.pendingRoadClick&&e.onRoadClick?.(this.pendingRoadClick),this.pendingSelectionStyle&&e.setSelectionStyle?.(this.pendingSelectionStyle),this.pendingBuildingHover!==void 0&&e.onBuildingHover?.(this.pendingBuildingHover),this.pendingHoverStyle&&e.setHoverStyle?.(this.pendingHoverStyle),this.pendingHoverEnabled!==void 0&&e.setHoverEnabled?.(this.pendingHoverEnabled);for(let t of this.pendingLayerSubscribers)t.unsubscribe=e.onLayers?.(t.callback)}attachMaps3DLayer(e){this.applyPendingSubscriptions(e);let t;try{t=e.ready??e.attach(this.map)}catch(r){t=Promise.reject(r)}this.maps3dReady=Promise.resolve(t).then(()=>{if(this.maps3dLayer!==e){l.teardownMaps3DLayer(e);return}return this.applyMaps3DBuildingMode(this.buildingsEnabled),e}).catch(r=>{l.teardownMaps3DLayer(e),this.maps3dLayer===e&&(this.maps3dLayer=void 0,this.buildingsEnabled=!1,console.error("[MahalMap SDK] Failed to attach Maps3D layer",r))})}static teardownMaps3DLayer(e){l.disposedMaps3DLayers.has(e)||(l.disposedMaps3DLayers.add(e),e.destroy?e.destroy():e.remove?.())}watchWorkerHealth(){let e=this.options.workerCheck;if(e===!1||typeof setTimeout!="function")return;let t=typeof e=="number"?e:l.WORKER_CHECK_DELAY;this.workerCheckTimer=setTimeout(()=>{this.workerCheckTimer=void 0,this.reportBrokenWorker()},t)}reportBrokenWorker(){if(typeof document<"u"&&document.hidden)return;let e=this.map;if(!(!e||typeof e.getStyle!="function"||typeof e.isStyleLoaded!="function"||typeof e.queryRenderedFeatures!="function")){try{let t=e.getStyle()?.sources??{};if(!Object.values(t).some(a=>a?.type==="vector"||a?.type==="geojson")||e.isStyleLoaded()||e.queryRenderedFeatures().length>0)return}catch{return}console.warn(`[MahalMap SDK] \u041A\u0430\u0440\u0442\u0430 \u043F\u0443\u0441\u0442\u0430: \u043D\u0438 \u043E\u0434\u0438\u043D \u0432\u0435\u043A\u0442\u043E\u0440\u043D\u044B\u0439 \u0442\u0430\u0439\u043B \u043D\u0435 \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u043D \u2014 \u043F\u043E\u0445\u043E\u0436\u0435, \u043D\u0435 \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u043B\u0441\u044F \u0432\u0435\u0431-\u0432\u043E\u0440\u043A\u0435\u0440 MapLibre.
70
+ </svg>`;var G=class{constructor(e){this.props=e;this.element=this.createElement()}createElement(){let e=document.createElement("div");e.style.cursor="pointer";let t=this.props.svg?this.applyColorToCustomSvg(this.props.svg):pe(this.props.color??"#278960",{innerSvg:this.props.innerSvg,innerUrl:this.props.innerUrl});return e.innerHTML=t,e}applyColorToCustomSvg(e){return this.props.color?e.replace(/fill="[^"]*"/g,`fill="${this.props.color}"`):e}getElement(){return this.element}getCoordinates(){return this.props.coordinates}isDraggable(){return!!this.props.draggable}getAnchor(){return this.props.anchor||"center"}};function he(i,e,t){return new i.Marker({element:t.getElement(),draggable:t.isDraggable?.()??!1,anchor:t.getAnchor?.()??"center"}).setLngLat(t.getCoordinates()).addTo(e)}var Je={dark:"#ffffff",light:"#19191a"},de="buildings",l=class l{constructor(){this.isReady=!1;this.readyCallbacks=[];this.language="tj";this.instanceKey="";this.gramBase=R;this.styleFamily="default";this.presetIsExplicit=!1;this.buildingsEnabled=!1;this.pendingLayerSubscribers=new Set}static getInstanceKey(e){return typeof e.container=="string"&&e.container?e.container:"map"}static normalizeLanguage(e){return e==="ru"?"ru":"tj"}static setDefaultLanguage(e){l.defaultLanguage=l.normalizeLanguage(e)}static getFallbackStyle(){return Y(_,l.getMapToken())}static getMapToken(){let e=M();if(!e)throw new Error("[MahalMap SDK] Map API key is required. Call keyUtils.saveKey() before creating the map or pass apikey in the SDK script URL.");return e}static getMaps3DCtor(e){if(e)return e;if(typeof window>"u")return;let t=window.Maps3D;return typeof t=="function"?t:t?.Maps3D}static async ensureJSApiSubscription(e){if(e)return;let t=M();if(!t)return;let r;try{r=await C(t)}catch(a){console.warn("[MahalMap SDK] JSApi subscription check failed, continuing without it:",a);return}if(!r.success)throw new Error(`[MahalMap SDK] JSApi subscription is not active for this key: ${r.message}`)}static async createAsync(e,t,r){return await l.ensureJSApiSubscription(l.getMaps3DCtor(r)),l.create(e,t,r)}static resolveStyleName(e,t,r){return e.style||e.preset||T(t,r)}static buildPlatformMapOptions(e,t,r,a,s){try{return e.mapOptions?e.mapOptions({base:t,apiKey:r,style:a,antialias:s}):{style:e.styleUrl?e.styleUrl(a,t):l.requireAbsoluteStyle(a),transformRequest:e.transformRequest({base:t,apiKey:r}),...s?{canvasContextAttributes:{antialias:!0}}:{}}}catch(n){throw new Error(`[MahalMap SDK] Maps3D rejected the style "${a}": ${n instanceof Error?n.message:String(n)}`)}}static requireAbsoluteStyle(e){if(/^https?:/i.test(e))return e;throw new Error("this Maps3D build has no styleUrl() \u2014 pass options.style as a full URL or upgrade @grammaps/maps3d-web to >=0.5.0")}static create(e,t,r){let a=typeof window<"u"?window.maplibregl:void 0,s=t||a;if(!s)throw new Error("[MahalMap SDK] MapLibre GL was not found. Pass it as the second argument or include it through a script.");let n=l.normalizeLanguage(e.lang||l.defaultLanguage),p=e.theme==="dark"?"dark":"light",o=new l,h=l.getInstanceKey(e);o.options=e,o.language=n,o.instanceKey=h,o.maplibre=s;let d=l.getMapToken(),u=l.getMaps3DCtor(r);o.gramBase=(e.base||R).replace(/\/+$/,""),o.styleFamily=e.family||"default",o.presetIsExplicit=!!(e.style||e.preset),o.maps3dCtor=u;let c=e.enable3D!==!1&&!!u;o.buildingsEnabled=c&&e.maps3d?.buildings!==!1,e.enable3D!==!1&&!u&&console.warn("[MahalMap SDK] Maps3D was not found \u2014 falling back to the plain vector style without 3D. Pass Maps3D as the third argument to create() or include it through a script (window.Maps3D).");let m=e.antialias!==void 0?e.antialias:c,g=u?l.buildPlatformMapOptions(u,o.gramBase,d,l.resolveStyleName(e,o.styleFamily,p),m):void 0,b=c?58:0;return o.map=new s.Map({container:e.container||"map",style:g?g.style:e.style||l.getFallbackStyle(),center:e.center||[69.624024,40.279687],zoom:e.zoom!==void 0?e.zoom:5,attributionControl:!1,pitch:e.pitch!==void 0?e.pitch:b,...e.bearing!==void 0?{bearing:e.bearing}:{},...g?{transformRequest:g.transformRequest,...g.canvasContextAttributes?{canvasContextAttributes:g.canvasContextAttributes}:{}}:{}}),c&&(o.maps3dLayer=o.createMaps3DLayer(d),o.attachMaps3DLayer(o.maps3dLayer)),o.watchWorkerHealth(),o.addLogo(p),o.map.on("load",()=>{o.isReady=!0,o.camera=new v(o.map),o.readyCallbacks.forEach(be=>be(o.map)),o.readyCallbacks=[]}),l.instances.set(h,o),o}static onReady(e,t){if(!l.instances.has(e)){let a=setInterval(()=>{l.instances.has(e)&&(clearInterval(a),l.onReady(e,t))},50);return}let r=l.getInstance(e);r.isReady?t(r.map):r.readyCallbacks.push(t)}static getInstance(e){let t=l.instances.get(e);if(!t)throw new Error("[MahalMap SDK] Map instance is not created");return t}static hasInstance(e){return l.instances.has(e)}static removeInstance(e){return l.instances.delete(e)}static addMarker(e,t){return e.addMarker(t)}static getCamera(e){return e.getCamera()}static getMap(e){return e.getMap()}static setStyle(e,t){e.setStyle(t)}static getMaps3DLayer(e){return e.getMaps3DLayer()}static whenMaps3DReady(e){return e.whenMaps3DReady()}static toggle3DBuildings(e,t){e.toggle3DBuildings(t)}static setLayer(e,t,r,a){return e.setLayer(t,r,a)}static getLayerState(e,t){return e.getLayerState(t)}static getLayers(e){return e.getLayers()}static onLayers(e,t){return e.onLayers(t)}static refreshLayers(e){e.refreshLayers()}static getIndoorLevels(e){return e.getIndoorLevels()}static setIndoorLevel(e,t){e.setIndoorLevel(t)}static refreshIndoor(e){e.refreshIndoor()}static showPlace(e,t,r,a,s){e.showPlace(t,r,a,s)}static onBuildingClick(e,t){e.onBuildingClick(t)}static selectBuilding(e,t,r){return e.selectBuilding(t,r)}static clearSelection(e){e.clearSelection()}static selectedBuilding(e){return e.selectedBuilding()}static setSelectionStyle(e,t){e.setSelectionStyle(t)}static onRoadClick(e,t){e.onRoadClick(t)}static roadAt(e,t,r){return e.roadAt(t,r)}static onParkingHover(e,t){e.onParkingHover(t)}static setParkingHoverStyle(e,t){e.setParkingHoverStyle(t)}static setParkingHoverEnabled(e,t){e.setParkingHoverEnabled(t)}static hoverParking(e,t){return e.hoverParking(t)}static hoveredParking(e){return e.hoveredParking()}static onParkingClick(e,t){e.onParkingClick(t)}static parkingAt(e,t,r){return e.parkingAt(t,r)}static onBuildingHover(e,t){e.onBuildingHover(t)}static setHoverEnabled(e,t){e.setHoverEnabled(t)}static setHoverStyle(e,t){e.setHoverStyle(t)}static hoverBuilding(e,t){return e.hoverBuilding(t)}static hoveredBuilding(e){return e.hoveredBuilding()}static setLanguage(e,t){e.setLanguage(t)}static setCenter(e,t){e.setCenter(t)}static setZoom(e,t){e.setZoom(t)}static destroy(e){e.destroy()}addMarker(e){return he(this.maplibre,this.map,e)}init(e){this.map=e,this.camera=new v(e)}getCamera(){return this.camera}getMap(){return this.map}setStyle(e){if(this.options.theme=e,this.presetIsExplicit)return;let t=this.resolvePlatformStyle(T(this.styleFamily,e));t&&(this.refreshLayersOnStyleChange(),this.map.setStyle(t),this.updateLogoColor(e))}resolvePlatformStyle(e){let t=this.maps3dCtor;if(t)try{return t.mapOptions?t.mapOptions({base:this.gramBase,apiKey:M(),style:e}).style:t.styleUrl?.(e,this.gramBase)}catch(r){console.error(`[MahalMap SDK] Maps3D rejected the style "${e}"`,r);return}}refreshLayersOnStyleChange(){let e=this.map;if(typeof e.on!="function"||typeof e.off!="function")return;this.styleChangeHandler&&e.off("styledata",this.styleChangeHandler);let t=()=>{typeof e.isStyleLoaded=="function"&&!e.isStyleLoaded()||(e.off?.("styledata",t),this.styleChangeHandler=void 0,this.maps3dLayer?.refreshLayers?.())};this.styleChangeHandler=t,e.on("styledata",t)}setLanguage(e){this.language=l.normalizeLanguage(e),this.options.lang=this.language}getMaps3DLayer(){return this.maps3dLayer}toggle3DBuildings(e){if(!(!this.maps3dLayer&&e&&(this.maps3dCtor=this.maps3dCtor||l.getMaps3DCtor(),!this.maps3dCtor))){if(this.buildingsEnabled=e,!this.maps3dLayer){if(!e)return;this.maps3dLayer=this.createMaps3DLayer(M()||void 0),this.attachMaps3DLayer(this.maps3dLayer);return}this.applyMaps3DBuildingMode(e)}}whenMaps3DReady(){return this.maps3dReady||Promise.resolve(void 0)}setLayer(e,t,r){return e===de&&(this.buildingsEnabled=t),this.maps3dLayer?.setLayer?.(e,t,r)??!1}getLayerState(e){return this.maps3dLayer?.layer?.(e)??null}getLayers(){return this.maps3dLayer?.layers?.()??[]}onLayers(e){let t={callback:e,unsubscribe:this.maps3dLayer?.onLayers?.(e)};return this.pendingLayerSubscribers.add(t),()=>{this.pendingLayerSubscribers.delete(t)&&t.unsubscribe?.()}}refreshLayers(){this.maps3dLayer?.refreshLayers?.()}getIndoorLevels(){return this.maps3dLayer?.indoorLevels??[]}setIndoorLevel(e){this.maps3dLayer?.setIndoorLevel?.(e)}refreshIndoor(){this.maps3dLayer?.refreshIndoor?.()}showPlace(e,t,r,a){this.maps3dLayer?.showPlace?.(e,t,r,a)}onBuildingClick(e){this.pendingBuildingClick=e,this.maps3dLayer?.onBuildingClick?.(e)}selectBuilding(e,t){return this.maps3dLayer?.selectBuilding?.(e,t)??!1}clearSelection(){this.maps3dLayer?.clearSelection?.()}selectedBuilding(){return this.maps3dLayer?.selectedBuilding?.()??null}setSelectionStyle(e){this.pendingSelectionStyle=e,this.maps3dLayer?.setSelectionStyle?.(e)}onRoadClick(e){this.pendingRoadClick=e,this.maps3dLayer?.onRoadClick?.(e)}roadAt(e,t){return this.maps3dLayer?.roadAt?.(e,t)??null}get roadsNamed(){return this.maps3dLayer?.roadsNamed??!1}onParkingHover(e){this.maps3dLayer?.onParkingHover?.(e)}setParkingHoverStyle(e){this.maps3dLayer?.setParkingHoverStyle?.(e)}setParkingHoverEnabled(e){this.maps3dLayer?.setParkingHoverEnabled?.(e)}get parkingHoverEnabled(){return this.maps3dLayer?.parkingHoverEnabled??!1}hoverParking(e){return this.maps3dLayer?.hoverParking?.(e)??!1}hoveredParking(){return this.maps3dLayer?.hoveredParking?.()??null}onParkingClick(e){this.maps3dLayer?.onParkingClick?.(e)}parkingAt(e,t){return this.maps3dLayer?.parkingAt?.(e,t)??null}onBuildingHover(e){this.pendingBuildingHover=e,this.maps3dLayer?.onBuildingHover?.(e)}setHoverEnabled(e){this.pendingHoverEnabled=e,this.maps3dLayer?.setHoverEnabled?.(e)}get hoverEnabled(){return this.maps3dLayer?.hoverEnabled??!1}setHoverStyle(e){this.pendingHoverStyle=e,this.maps3dLayer?.setHoverStyle?.(e)}hoverBuilding(e){return this.maps3dLayer?.hoverBuilding?.(e)??!1}hoveredBuilding(){return this.maps3dLayer?.hoveredBuilding?.()??null}createMaps3DLayer(e){let t={...this.options.maps3d,apiKey:e,base:this.gramBase};return this.maps3dCtor.enhance?this.maps3dCtor.enhance(this.map,t):new this.maps3dCtor(t)}applyPendingSubscriptions(e){this.pendingBuildingClick&&e.onBuildingClick?.(this.pendingBuildingClick),this.pendingRoadClick&&e.onRoadClick?.(this.pendingRoadClick),this.pendingSelectionStyle&&e.setSelectionStyle?.(this.pendingSelectionStyle),this.pendingBuildingHover!==void 0&&e.onBuildingHover?.(this.pendingBuildingHover),this.pendingHoverStyle&&e.setHoverStyle?.(this.pendingHoverStyle),this.pendingHoverEnabled!==void 0&&e.setHoverEnabled?.(this.pendingHoverEnabled);for(let t of this.pendingLayerSubscribers)t.unsubscribe=e.onLayers?.(t.callback)}attachMaps3DLayer(e){this.applyPendingSubscriptions(e);let t;try{t=e.ready??e.attach(this.map)}catch(r){t=Promise.reject(r)}this.maps3dReady=Promise.resolve(t).then(()=>{if(this.maps3dLayer!==e){l.teardownMaps3DLayer(e);return}return this.applyMaps3DBuildingMode(this.buildingsEnabled),e}).catch(r=>{l.teardownMaps3DLayer(e),this.maps3dLayer===e&&(this.maps3dLayer=void 0,this.buildingsEnabled=!1,console.error("[MahalMap SDK] Failed to attach Maps3D layer",r))})}static teardownMaps3DLayer(e){l.disposedMaps3DLayers.has(e)||(l.disposedMaps3DLayers.add(e),e.destroy?e.destroy():e.remove?.())}watchWorkerHealth(){let e=this.options.workerCheck;if(e===!1||typeof setTimeout!="function")return;let t=typeof e=="number"?e:l.WORKER_CHECK_DELAY;this.workerCheckTimer=setTimeout(()=>{this.workerCheckTimer=void 0,this.reportBrokenWorker()},t)}reportBrokenWorker(){if(typeof document<"u"&&document.hidden)return;let e=this.map;if(!(!e||typeof e.getStyle!="function"||typeof e.isStyleLoaded!="function"||typeof e.queryRenderedFeatures!="function")){try{let t=e.getStyle()?.sources??{};if(!Object.values(t).some(a=>a?.type==="vector"||a?.type==="geojson")||e.isStyleLoaded()||e.queryRenderedFeatures().length>0)return}catch{return}console.warn(`[MahalMap SDK] \u041A\u0430\u0440\u0442\u0430 \u043F\u0443\u0441\u0442\u0430: \u043D\u0438 \u043E\u0434\u0438\u043D \u0432\u0435\u043A\u0442\u043E\u0440\u043D\u044B\u0439 \u0442\u0430\u0439\u043B \u043D\u0435 \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u043D \u2014 \u043F\u043E\u0445\u043E\u0436\u0435, \u043D\u0435 \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u043B\u0441\u044F \u0432\u0435\u0431-\u0432\u043E\u0440\u043A\u0435\u0440 MapLibre.
71
71
  \u041E\u0431\u044B\u0447\u043D\u043E \u0432\u0438\u043D\u043E\u0432\u0430\u0442 \u0441\u0431\u043E\u0440\u0449\u0438\u043A: \u043E\u043D \u043D\u0435 \u043F\u0435\u0440\u0435\u043D\u043E\u0441\u0438\u0442 \u0444\u0430\u0439\u043B \u0432\u043E\u0440\u043A\u0435\u0440\u0430, \u0438 \u0432\u043C\u0435\u0441\u0442\u043E \u0441\u043A\u0440\u0438\u043F\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043E\u0442\u0434\u0430\u0451\u0442 HTML.
72
72
  \u0420\u0435\u0448\u0435\u043D\u0438\u044F:
73
73
  1) \u0432\u0437\u044F\u0442\u044C \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u0443 \u0443 \u043F\u043B\u0430\u0442\u0444\u043E\u0440\u043C\u044B: const maplibregl = await Maps3D.maplibre({ base });