2023-07-16 03:26:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import ThemeViewState from "./src/Models/ThemeViewState"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import SvelteUIElement from "./src/UI/Base/SvelteUIElement"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import ThemeViewGUI from "./src/UI/ThemeViewGUI.svelte"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import LayoutConfig from "./src/Models/ThemeConfig/LayoutConfig";
							 
						 
					
						
							
								
									
										
										
										
											2023-12-06 12:57:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import MetaTagging from "./src/Logic/MetaTagging";
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:21:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import { FixedUiElement } from "./src/UI/Base/FixedUiElement";
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 02:01:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import { Utils } from "./src/Utils"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import Constants from "./src/Models/Constants"
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 16:58:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 17:29:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function webgl_support() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        var canvas = document.createElement("canvas")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return (
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            !!window.WebGLRenderingContext &&
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            (canvas.getContext("webgl") || canvas.getContext("experimental-webgl"))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } catch (e) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 02:01:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								async function getAvailableLayers(): Promise<Set<string>> {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const host = new URL(Constants.VectorTileServer).host
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const status = await Utils.downloadJson("https://" + host + "/summary/status.json")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return new Set<string>(status.layers)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } catch (e) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console.error("Could not get MVT available layers due to", e)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return new Set<string>()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2023-09-22 11:20:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 02:01:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								async function main() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if (!webgl_support()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         new FixedUiElement("WebGL is not supported or not enabled. This is essential for MapComplete to function, please enable this.").SetClass("block alert").AttachTo("maindiv")
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }else{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const availableLayers = await getAvailableLayers()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        MetaTagging.setThemeMetatagging(new ThemeMetaTagging())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // LAYOUT.ADD_LAYERS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const state = new ThemeViewState(new LayoutConfig(<any> layout), availableLayers)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const main = new SvelteUIElement(ThemeViewGUI, { state })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        main.AttachTo("maindiv")
							 
						 
					
						
							
								
									
										
										
										
											2024-03-21 22:39:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        Array.from(document.getElementsByClassName("delete-on-load")).forEach(el => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    el.parentElement.removeChild(el)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                })
							 
						 
					
						
							
								
									
										
										
										
											2024-02-20 02:01:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								main()