@kystverket/styrbord-kart 0.2.0 → 1.0.0
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/style.js +7 -7
- package/dist/style.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/style.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import Se, { createContext as qe, useMemo as ee, useCallback as W, useEffect as q, useRef as $, useState as J, useContext as be, useId as Ht } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { Surface as Te, NumberInput as Ke, ValidationMessage as pt, useIdProvider as dr, TextInput as pr, Label as fr, LabelContent as gr, Field as yr } from "@kystverket/styrbord";
|
|
4
4
|
import * as Ye from "maplibre-gl";
|
|
5
5
|
import { TerraDrawPolygonMode as kr, TerraDrawLineStringMode as mr, TerraDrawPointMode as hr, TerraDrawSelectMode as vr, TerraDrawRenderMode as _r, TerraDraw as br } from "terra-draw";
|
|
6
6
|
import { TerraDrawMapLibreGLAdapter as Sr } from "terra-draw-maplibre-gl-adapter";
|
|
@@ -4292,7 +4292,7 @@ function $s({
|
|
|
4292
4292
|
},
|
|
4293
4293
|
[e, v]
|
|
4294
4294
|
);
|
|
4295
|
-
return /* @__PURE__ */ i.jsxs(Te, { gap:
|
|
4295
|
+
return /* @__PURE__ */ i.jsxs(Te, { gap: 4, className: [o].filter(Boolean).join(" "), children: [
|
|
4296
4296
|
/* @__PURE__ */ i.jsx(
|
|
4297
4297
|
Tt,
|
|
4298
4298
|
{
|
|
@@ -4305,7 +4305,7 @@ function $s({
|
|
|
4305
4305
|
showCenterAction: d
|
|
4306
4306
|
}
|
|
4307
4307
|
),
|
|
4308
|
-
/* @__PURE__ */ i.jsxs(Te, { horizontal: !0, gap:
|
|
4308
|
+
/* @__PURE__ */ i.jsxs(Te, { horizontal: !0, gap: 4, children: [
|
|
4309
4309
|
/* @__PURE__ */ i.jsx(
|
|
4310
4310
|
Ke,
|
|
4311
4311
|
{
|
|
@@ -4407,7 +4407,7 @@ function Hs({
|
|
|
4407
4407
|
},
|
|
4408
4408
|
[t]
|
|
4409
4409
|
);
|
|
4410
|
-
return /* @__PURE__ */ i.jsxs(Te, { gap:
|
|
4410
|
+
return /* @__PURE__ */ i.jsxs(Te, { gap: 4, className: [o].filter(Boolean).join(" "), children: [
|
|
4411
4411
|
/* @__PURE__ */ i.jsx(
|
|
4412
4412
|
Tt,
|
|
4413
4413
|
{
|
|
@@ -4420,7 +4420,7 @@ function Hs({
|
|
|
4420
4420
|
showCenterAction: d
|
|
4421
4421
|
}
|
|
4422
4422
|
),
|
|
4423
|
-
/* @__PURE__ */ i.jsxs(Te, { horizontal: !0, gap:
|
|
4423
|
+
/* @__PURE__ */ i.jsxs(Te, { horizontal: !0, gap: 4, children: [
|
|
4424
4424
|
/* @__PURE__ */ i.jsx(
|
|
4425
4425
|
Ke,
|
|
4426
4426
|
{
|
|
@@ -4784,7 +4784,7 @@ const xs = ({
|
|
|
4784
4784
|
return e.features.map((c, l) => /* @__PURE__ */ i.jsx(Te, { children: r.map((f) => {
|
|
4785
4785
|
var S, M;
|
|
4786
4786
|
return /* @__PURE__ */ i.jsxs(Te, { children: [
|
|
4787
|
-
/* @__PURE__ */ i.jsxs(Te, { horizontal: !0, width: "full", align: "center", gap:
|
|
4787
|
+
/* @__PURE__ */ i.jsxs(Te, { horizontal: !0, width: "full", align: "center", gap: 2, children: [
|
|
4788
4788
|
/* @__PURE__ */ i.jsxs("span", { children: [
|
|
4789
4789
|
"#",
|
|
4790
4790
|
(S = c.properties) == null ? void 0 : S.nummer
|
|
@@ -4794,7 +4794,7 @@ const xs = ({
|
|
|
4794
4794
|
{
|
|
4795
4795
|
id: o("features", l, "properties", f.name),
|
|
4796
4796
|
value: (M = c.properties) == null ? void 0 : M[f.name],
|
|
4797
|
-
|
|
4797
|
+
width: "full",
|
|
4798
4798
|
onChange: (m) => {
|
|
4799
4799
|
u(l, f.name, m);
|
|
4800
4800
|
}
|
package/dist/style.umd.cjs
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<%s {...props} />
|
|
21
21
|
React keys must be passed directly to JSX without using spread:
|
|
22
22
|
let props = %s;
|
|
23
|
-
<%s key={someKey} {...props} />`,G,q,ie,q),m[q+G]=!0)}if(q=null,V!==void 0&&(r(V),q=""+V),p(N)&&(r(N.key),q=""+N.key),"key"in N){V={};for(var me in N)me!=="key"&&(V[me]=N[me])}else V=N;return q&&u(V,typeof i=="function"?i.displayName||i.name||"Unknown":i),g(i,q,V,a(),fe,ke)}function T(i){h(i)?i._store&&(i._store.validated=1):typeof i=="object"&&i!==null&&i.$$typeof===D&&(i._payload.status==="fulfilled"?h(i._payload.value)&&i._payload.value._store&&(i._payload.value._store.validated=1):i._store&&(i._store.validated=1))}function h(i){return typeof i=="object"&&i!==null&&i.$$typeof===k}var o=n,k=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),$=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),f=Symbol.for("react.client.reference"),w=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=Object.prototype.hasOwnProperty,S=Array.isArray,A=console.createTask?console.createTask:function(){return null};o={react_stack_bottom_frame:function(i){return i()}};var B,R={},z=o.react_stack_bottom_frame.bind(o,d)(),K=A(s(d)),m={};De.Fragment=F,De.jsx=function(i,N,V){var G=1e4>w.recentlyCreatedOwnerStacks++;return L(i,N,V,!1,G?Error("react-stack-top-frame"):z,G?A(s(i)):K)},De.jsxs=function(i,N,V){var G=1e4>w.recentlyCreatedOwnerStacks++;return L(i,N,V,!0,G?Error("react-stack-top-frame"):z,G?A(s(i)):K)}})()),De}var Pt;function kr(){return Pt||(Pt=1,process.env.NODE_ENV==="production"?Ke.exports=gr():Ke.exports=yr()),Ke.exports}var l=kr();function Ue(e){return(e%360+360)%360}function Ye(e){return Math.max(-90,Math.min(90,e))}function qe(e){return Math.max(-180,Math.min(180,e))}function gt(e,t){const r=10**t;return Math.round(e*r)/r}const se=[];for(let e=0;e<256;++e)se.push((e+256).toString(16).slice(1));function mr(e,t=0){return(se[e[t+0]]+se[e[t+1]]+se[e[t+2]]+se[e[t+3]]+"-"+se[e[t+4]]+se[e[t+5]]+"-"+se[e[t+6]]+se[e[t+7]]+"-"+se[e[t+8]]+se[e[t+9]]+"-"+se[e[t+10]]+se[e[t+11]]+se[e[t+12]]+se[e[t+13]]+se[e[t+14]]+se[e[t+15]]).toLowerCase()}const hr=new Uint8Array(16);function vr(){return crypto.getRandomValues(hr)}function _r(e,t,r){return crypto.randomUUID?crypto.randomUUID():br(e)}function br(e,t,r){var a;e=e||{};const s=e.random??((a=e.rng)==null?void 0:a.call(e))??vr();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,mr(s)}const yt=()=>_r(),Nt={mapContainer:"_mapContainer_1krt1_1"},ue={editorWrapper:"_editorWrapper_14o42_1",toolbar:"_toolbar_14o42_6",toolbarButton:"_toolbarButton_14o42_21",active:"_active_14o42_43",danger:"_danger_14o42_49",toolbarDivider:"_toolbarDivider_14o42_58"},kt={latitude:65,longitude:14},mt=5,ht=[[3,57.5],[32,71.5]],Dt={version:8,glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",sources:{},layers:[]},Bt={id:"kartverket-topo",label:"Topografisk",sources:{"kartverket-topo":{type:"raster",tiles:["https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png"],tileSize:256,maxzoom:18,attribution:'© <a href="https://www.kartverket.no/">Kartverket</a>'}},layers:[{id:"kartverket-topo-raster",type:"raster",source:"kartverket-topo"}]},vt=n.createContext({setViewBounds:e=>{},defaultCenter:kt,defaultZoom:mt,defaultBounds:ht}),Sr=({children:e,defaultCenter:t=kt,defaultZoom:r=mt,defaultBounds:s=ht})=>{const[a,d]=n.useState(void 0),p=u=>{d(u)};return l.jsx(vt.Provider,{value:{viewBounds:a,setViewBounds:p,defaultCenter:t,defaultZoom:r,defaultBounds:s},children:e})},ze=[Bt],Lr={availableBaseLayers:ze,activeBaseLayerId:ze[0].id,setActiveBaseLayer:()=>{}},Ze=n.createContext(Lr),wr=({children:e,baseLayers:t,defaultActiveId:r})=>{const s=n.useMemo(()=>t&&t.length>0?t:ze,[t]),[a,d]=n.useState(()=>{var c;return r??((c=s[0])==null?void 0:c.id)??ze[0].id}),p=n.useCallback(c=>{s.some(g=>g.id===c)&&d(c)},[s]),u=n.useMemo(()=>({availableBaseLayers:s,activeBaseLayerId:a,setActiveBaseLayer:p}),[s,a,p]);return l.jsx(Ze.Provider,{value:u,children:e})};function y(e,t,r,s){const a=`kv-${e}`,d={SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:r,STYLES:"",CRS:"EPSG:3857",BBOX:"{bbox-epsg-3857}",GUI:"2",EXCEPTIONS:"XML",WIDTH:256,HEIGHT:256,FORMAT:"image/png",INFOFORMAT:"text/html",TRANSPARENT:"TRUE",QUERYABLE:"true",TRANSITIONEFFECT:"resize"};return{id:e,label:t,category:s,defaultVisible:!1,sources:{[a]:{type:"raster",tiles:["https://services.kystverket.no/mapserv.ashx?"+Object.entries(d).map(([p,u])=>`${p}=${u}`).join("&")],tileSize:256,attribution:'© <a href="https://www.kystverket.no/">Kystverket</a>'}},layers:[{id:`${a}-raster`,type:"raster",source:a}]}}function M(e,t,r,s,a,d){const p=`ext-${e}`,u=s.includes("?")?"&":"?",c={SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:r,STYLES:"",CRS:"EPSG:3857",BBOX:"{bbox-epsg-3857}",EXCEPTIONS:"XML",WIDTH:256,HEIGHT:256,FORMAT:"image/png",TRANSPARENT:"TRUE"};return{id:e,label:t,category:a,defaultVisible:!1,sources:{[p]:{type:"raster",tiles:[`${s}${u}`+Object.entries(c).map(([g,L])=>`${g}=${L}`).join("&")],tileSize:256,attribution:d??`© <a href="${new URL(s).origin}">${new URL(s).hostname}</a>`}},layers:[{id:`${p}-raster`,type:"raster",source:p}]}}const Wt=[M("Skipstrafikk2016SkipOver15M","Skipstrafikk 2016 (skip over 15 m)","AIS-density-Norway-2016","https://wms-geo.kystverket.no/density","All skipstrafikk (2016/2017)",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("Beredskapsdepot","Beredskapsdepot","layer_25","Beredskap"),y("Beredskapsanalyseomrader","Beredskapsanalyseområder","layer_764","Beredskap"),y("Nodhavner","Nødhavner","layer_26","Beredskap"),y("Iua","IUA","layer_493","Beredskap"),y("RitsKjemikalieberedskap","RITS - kjemikalieberedskap","layer_220","Beredskap"),y("Tilsynslag","Tilsynslag","layer_34","Beredskap"),M("AisTilsynslagfartoy","AIS - Tilsynslagfartøy","tracks,trajectories,points,labels_ship_name_scale_independent","https://geomap05.kystverket.no/api/mapserver/a8528a26-0adb-4208-933c-d7ad0452f83e","Beredskap",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("50MeterBuffer","50 meter buffer","layer_583","Buffersoner"),y("100MeterBuffer","100 meter buffer","layer_584","Buffersoner"),y("Fartsomrade1","Fartsområde 1","layer_959","Data fra Sjøfartsdirektoratet"),y("Fartsomrade2","Fartsområde 2","layer_960","Data fra Sjøfartsdirektoratet"),y("Fartsomrade3","Fartsområde 3","layer_961","Data fra Sjøfartsdirektoratet"),y("Fartsomrade4","Fartsområde 4","layer_962","Data fra Sjøfartsdirektoratet"),y("LitenKystfart","Liten kystfart","layer_963","Data fra Sjøfartsdirektoratet"),y("BallastvannOmrade1RostTromso","Ballastvann - Område 1: Røst - Tromsø","layer_968","Data fra Sjøfartsdirektoratet"),y("BallastvannOmrade2Norskehavet","Ballastvann - Område 2: Norskehavet","layer_969","Data fra Sjøfartsdirektoratet"),y("BallastvannOmrade3Vestlandskysten","Ballastvann - Område 3: Vestlandskysten","layer_970","Data fra Sjøfartsdirektoratet"),y("FartsomradeFiskefartoyFjordfiske","Fartsområde fiskefartøy - Fjordfiske","layer_971","Data fra Sjøfartsdirektoratet"),y("FartsomradeFiskefartoyKystfiske","Fartsområde fiskefartøy - Kystfiske","layer_972","Data fra Sjøfartsdirektoratet"),y("VhfTeoretiskDekningsomrade","VHF teoretisk dekningsområde","layer_975","Data fra Sjøfartsdirektoratet"),y("Fiskerihavner","Fiskerihavner","layer_503","Eiendom"),y("FyreiendommerNy","Fyreiendommer (ny)","layer_512","Eiendom"),y("FyreiendommerI3d","Fyreiendommer i 3d","layer_901","Eiendom"),y("FareomraderAndoyaSpaceCenter","Fareområder Andøya Space center","layer_digi_87","Fareområder"),y("Farledsareal","Farledsareal","layer_554","Farled og merker"),y("FritidsfartoyAlleFartsgrenser","For fritidsfartøy - alle fartsgrenser på sjøen","layer_754","Fartsforskrift"),y("NaeringsfartoyAlleFartsgrenser","For næringsfartøy - alle fartsgrenser på sjøen","layer_762","Fartsforskrift"),y("FartsrestriksjonerInnsjoOgElver","Fartsrestriksjoner innsjø og elver","layer_548","Fartsforskrift"),y("Kommuneoversikt","Kommuneoversikt","layer_787","Fartsforskrift"),y("AkvakulturanleggMedInnehaver","Akvakulturanlegg med innehaver","layer_775","Fiskeri og havbruk"),y("HavbrukTilHavsTilrading2019","Havbruk til havs - Tilråding 2019","layer_589","Fiskeri og havbruk"),y("HavbrukTilHavsIdentifiserteOmrader","Havbruk til havs - Identifiserte områder","layer_588","Fiskeri og havbruk"),y("HavbrukTilHavsAnbefaling2022","Havbruk til havs anbefaling 2022","layer_885","Fiskeri og havbruk"),y("Verdensarvomrader","Verdensarvområder","layer_996","Grenser og inndelinger"),y("Kommunegrenser","Kommunegrenser","layer_555","Grenser og inndelinger"),y("Fylkesgrenser","Fylkesgrenser","layer_556","Grenser og inndelinger"),y("OmradeavgrensningArktisPolarkoden","Områdeavgrensning - Arktis (Polarkoden)","layer_98","Grenser og inndelinger"),y("EcaOmrader","ECA områder","layer_557","Grenser og inndelinger"),y("RedningsomradeNord","Redningsområde nord","layer_725","Grenser og inndelinger"),y("RedningsomradeSor","Redningsområde Sør","layer_724","Grenser og inndelinger"),y("Politidistrikt","Politidistrikt","layer_621","Grenser og inndelinger"),y("Grense250Nm","Grense 250 nm","layer_786","Grenser og inndelinger"),M("Oljetankere","Oljetankere","overlay_aistails_with_type1_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("KjemikalieProduktankere","Kjemikalie-/produkttankere","overlay_aistails_with_type2_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("Gasstankere","Gasstankere","overlay_aistails_with_type3_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("Bulkskip","Bulkskip","overlay_aistails_with_type4_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("StykkgodsskipHavbase","Stykkgodsskip","overlay_aistails_with_type5_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("Konteinerskip","Konteinerskip","overlay_aistails_with_type6_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("RoRoLast","Ro Ro last","overlay_aistails_with_type7_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("KjoleFryseskip","Kjøle-/fryseskip","overlay_aistails_with_type8_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("Passasjer","Passasjer","overlay_aistails_with_type9_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("OffshoreSupplySkip","Offshore supply skip","overlay_aistails_with_type10_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AndreOffshoreServiceSkip","Andre offshore service skip","overlay_aistails_with_type11_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AndreAktiviteter","Andre aktiviteter","overlay_aistails_with_type12_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("Fiskefartoy","Fiskefartøy","overlay_aistails_with_type13_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AlleSkipstyper","Alle skipstyper","overlay_aistails_with_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("DigitalPfsa","Digital PFSA","layer_1067","Havn"),y("SikkerLastingLossingBulkskip","Sikker lasting/lossing bulkskip","layer_1049","Havn"),y("BunkringAvDrivstoff","Bunkring av drivstoff","layer_digi_65","Havn"),y("TenTHavnerINorge","Ten-T havner i Norge","layer_993","Havn"),y("AisAnlopspunkter2023","AIS Anløpspunkter 2023","layer_1027","Havn"),y("AisAnlopspolygoner2023","AIS anløpspolygoner 2023","layer_1028","Havn"),y("HavvindApnedeOmrader","Havvind - åpnede områder","layer_882","Havvind"),y("Kystkontur","Kystkontur","layer_611","Kystkontur"),y("BygningsmessigAnleggVann","Bygningsmessig anlegg (vann)","layer_612","Kystkontur"),y("KaiBrygge","Kai & Brygge","layer_614","Kystkontur"),y("Bolgebryter","Bølgebryter","layer_615","Kystkontur"),y("Flytedokkant","Flytedokkant","layer_616","Kystkontur"),y("Molo","Molo","layer_613","Kystkontur"),y("TilskuddTilFiskerihavntiltak","Tilskudd til fiskerihavntiltak (Post 60)","layer_1078","Kystverkets tilskuddsordninger"),y("PosisjonerForLngOpplasting","Posisjoner for LNG opplasting","layer_521","LNG omlasting"),y("LngOmlastingSikkerhetssone540m","LNG omlasting Sikkerhetssone 540 meter","layer_522","LNG omlasting"),y("LngOmlastingSikkerhetssone840m","LNG omlasting Sikkerhetssone 840 meter","layer_523","LNG omlasting"),y("MetanolAnlegg","Metanol-anlegg","layer_713","Lavutslipp"),y("Landstrom","Landstrøm","layer_710","Lavutslipp"),y("LngAnlegg","LNG-anlegg","layer_712","Lavutslipp"),y("LadeanleggFerjer","Ladeanlegg ferjer","layer_709","Lavutslipp"),y("Amoniakk","Amoniakk","layer_1094","Lavutslipp"),y("Hydrogen","Hydrogen","layer_1095","Lavutslipp"),M("AisLosbaterLive","AIS Losbåter (live)","tracks,trajectories,points,labels_ship_name_scale_independent","https://geomap05.kystverket.no/api/mapserver/f7a96d50-5551-445d-88b4-3022288a7605","Los og farledsbevis",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("LosstasjonerOgLosformidling","Losstasjoner og losformidling","layer_59","Los og farledsbevis"),y("Losbordingsfelt","Losbordingsfelt","layer_29","Los og farledsbevis"),y("InnseilingskorrridorerLosplikt","Innseilingskorridorer - Losplikt","layer_99","Los og farledsbevis"),y("Losoldermannskap","Losoldermannskap","layer_534","Los og farledsbevis"),y("FarledsbevisRutenett","Farledsbevis, rutenett","layer_341","Los og farledsbevis"),y("FarledsbevisLokaleBegrensninger","Farledsbevis, lokale begrensninger","layer_532","Los og farledsbevis"),y("FdvLos2025","2025 - FDV LOS","layer_1079","Los og farledsbevis"),y("HovedOgBiled","Hoved- og biled","layer_552","Maritim sikring"),y("IspsHavneanleggSsn","ISPS havneanlegg (SSN)","layer_420","Maritim sikring"),y("IspsCruise","ISPS Cruise","layer_887","Maritim sikring"),y("AnkringsomraderForSjotransporten","Ankringsområder for sjøtransporten","layer_888","Maritim sikring"),y("OpplagsomraderForSjotransporten","Opplagsområder for sjøtransporten","layer_889","Maritim sikring"),y("RiggomraderISjo","Riggområder i sjø","layer_890","Maritim sikring"),y("VaerdataFraKystvaer","Værdata fra Kystvær","layer_1129","Meteorologiske data"),y("InstallasjonerPaNorskSokkel","Installasjoner på norsk sokkel (PostGIS)","layer_1107","Norsk sokkel"),y("VtsTjenesteomrade","VTS tjenesteområde","layer_696","Rutetiltak, rapportering og VTS"),y("Aktsomhetsomrader","Aktsomhetsområder","layer_102","Rutetiltak, rapportering og VTS"),y("Toveisfarled","Toveisfarled","layer_104","Rutetiltak, rapportering og VTS"),y("AnbefalteRuter","Anbefalte ruter","layer_702","Rutetiltak, rapportering og VTS"),y("TssOmrader","TSS områder","layer_706","Rutetiltak, rapportering og VTS"),y("TssAvgrensing","TSS avgrensing","layer_703","Rutetiltak, rapportering og VTS"),y("ForbudsomradePassasjerfartoy150m","Forbudsområde passasjerfartøy over 150 meter ved sterk kuling","layer_1108","Rutetiltak, rapportering og VTS"),y("Sjoulykker20092021","Sjøulykker 2009-2021","layer_799","Sjøsikkerhet"),M("SannsynlighetForUlykke","Sannsynlighet for ulykke","summert_grid20161214162224065","https://services.kystverket.no/qgis.ashx?map=2a9ba3ad-a973-4b84-99ea-b12d6f8b1da4","Sjøsikkerhet",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("SannsynlighetForUlykkeMedUtslipp","Sannsynlighet for ulykke med utslipp","grid_risiko_utslipp20170112124144604","https://services.kystverket.no/qgis.ashx?map=79625cb8-f319-429a-acfc-c63840281a88","Sjøsikkerhet",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("SannsynlighetForUlykkeMedTapAvLiv","Sannsynlighet for ulykke med tap av liv","freq_lossoflife20170317121849742","https://services.kystverket.no/qgis.ashx?map=15ed376d-ee36-4940-afff-865a9a6a7558","Sjøsikkerhet",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AisApenSanntid12Timer","AIS Åpen sanntid (siste 12 timer)","tracks,trajectories,points,labels_ship_name","https://geomap05.kystverket.no/api/mapserver/a0138177-38d3-4868-b5ea-f8b1d7b8b09c","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AisStykkgodsskipLive","AIS - stykkgodsskip (live)","tracks,trajectories,points,labels_ship_name","https://geomap05.kystverket.no/api/mapserver/5cfc32d5-da6a-41d7-b6d1-d4f9193523ce","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AisSjospeiderne","AIS Sjøspeiderne","tracks,trajectories,points,labels_ship_name_scale_independent","https://geomap05.kystverket.no/api/mapserver/7f7c13c3-5a49-4c35-bfb0-8f82af379d0f","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AisRedningsselskapet","AIS Redningsselskapet","tracks,trajectories,points,labels_ship_name_scale_independent","https://geomap05.kystverket.no/api/mapserver/abfc5500-11d1-49fb-9094-754f6dc6c36a","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AisSar","AIS SAR","tracks,trajectories,points,labels_ship_name","https://geomap05.kystverket.no/api/mapserver/ca0b6107-2669-4335-862e-8fcbed8b35f7","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("Skipstrafikk","Skipstrafikk","ais_raster_3575_6min","https://kart.kystverket.no/proxies/xSkipstrafikkProxy.ashx?map=/etc/mapserver/barentswatch.map&sld=https://kart.barentswatch.no/resx/sld_skipstrafikk_month.xml","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("VardoTrafikksentral","Vardø trafikksentral","layer_426","Sjøtrafikksentraltjenestens hendelser"),y("KvitsoyTrafikksentral","Kvitsøy trafikksentral","layer_427","Sjøtrafikksentraltjenestens hendelser"),y("SkrafotoAustAgder2008","Skråfoto - Aust-Agder - 2008","layer_215","Skråfoto"),y("SkrafotoTroms2008","Skråfoto - Troms - 2008","layer_217","Skråfoto"),y("SkrafotoTroms2005","Skråfoto - Troms - 2005","layer_218","Skråfoto"),y("FritidsfartoyStatligeFartsgrenser","For fritidsfartøy - statlige fartsgrenser på sjøen etter HFL","layer_722","Statlig fartsforskrift etter HFL"),y("NaeringsfartoyStatligeFartsgrenser","For næringsfartøy - statlige fartsgrenser på sjøen etter HFL","layer_723","Statlig fartsforskrift etter HFL"),M("EncFullEcdis","ENC - full ECDIS","cells","https://kart.kystverket.no/proxies/xEncProxy.ashx?STYLES=style-id-260","Bakgrunnskart",'© <a href="https://www.kystverket.no/">Kystverket</a>'),M("AkvakultursoknaderUnderBehandling","Akvakultur søknader under behandling","akvakultursoeknad_under_behandling","https://gis.fiskeridir.no/server/services/fiskeridirWMS_akva/MapServer/WMSServer","Akvakultursøknader"),M("TopografiskWebbkarta","Topografisk webbkarta","terrangskuggning,mark_nedtonad,hydrografi_ytor_nedtonad,kurvor_nedtonad,hydrografi_nedtonad,kommunikation_nedtonad,jarnvag_nedtonad,fjallinformation_nedtonad,kraftledningar_nedtonad,anlaggningar_nedtonad,bebyggelse_nedtonad,bestammelser_nedtonad,administrativ_indelning_nedtonad,adresser_nedtonad,text_nedtonad","https://wms.geonorge.no/skwms1/wms.lantmeteriet_topo","Andre grunnkart"),M("Nedbor1TimesIntervall","Nedbør 1 times intervall","precipitation_1h_regional","https://metmaps.met.no/metmaps/default.map?language=eng","Beredskap"),M("Vind1TimesIntervall","Vind 1 times intervall","wind_10m_regional","https://metmaps.met.no/metmaps/default.map?language=eng","Beredskap"),M("BolgehoydeOgRetning","Bølgehøyde og retning","sea_wave_height_direction_regional","https://bw-wms.met.no/barentswatch/default.map","Beredskap"),M("Dumpefelt","Dumpefelt","dumpefelt_a","https://wms.geonorge.no/skwms1/wms.maritim_infrastruktur?language=eng","Fareområder"),M("Navigasjonsinstallasjoner","Navigasjonsinstallasjoner","Skilt6756,Overettlinje_merke4406,Overettlinje_lys28396,Flytende_merke18756,Fast_sjømerke29168,Racon,Sektorflate,Sektorlinje,IB,Lys37331","https://maps.kystverket.cloudgis.no/enterprise/services/PROD/nfs_sistop_ekstern_prod/MapServer/WMSServer","Farled og merker"),M("AkvakulturFlater","Akvakultur - flater","flate_ihht_akvakulturregisteret","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),M("LaksekartWms","Laksekart WMS","layer_21","https://laksekartogc.statsforvalteren.no/wms.ashx","Fiskeri og havbruk"),M("FiskeplasserAktiveRedskap","Fiskeplasser aktive redskap","fiskeplasser_aktive_redskap","https://gis.fiskeridir.no/server/services/fiskeridirWMS_fiskeri/MapServer/WMSServer","Fiskeri og havbruk"),M("FiskeplasserPassiveRedskap","Fiskeplasser passive redskap","fiskeplasser_passive_redskap","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),M("Lassettingsplasser","Låssettingsplasser","laassettingsplasser","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),M("Gyteomrader","Gyteområder","gyteomraader","https://gis.fiskeridir.no/server/services/fiskeridirWMS_fiskeri/MapServer/WMSServer","Fiskeri og havbruk"),M("GytefeltTorsk","Gytefelt torsk","gytefelt_torsk_mb","https://gis.fiskeridir.no/server/services/fiskeridirWMS_fiskeri/MapServer/WMSServer","Fiskeri og havbruk"),M("NasjonaleLaksefjorder","Nasjonale Laksefjorder","nasjonale_laksefjorder","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),M("NytekPlasseringYtterpunkt","NYTEK plassering-ytterpunkt","nytek_plassering_ytterpunkt","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),M("NytekFortoyningsliner","NYTEK fortøyningsliner","nytek_fortoyningslinjer","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),M("NytekFlateSenterpunkt","NYTEK flåte senterpunkt","nytek_flate_senterpunkt","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),M("NytekFlateFortoyningslinjer","NYTEK flåte fortøyningslinjer","nytek_flate_fortoyningslinjer","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),M("ForsvaretsSkyteFeltISjo","Forsvarets skyte- og øvingsfelt i sjø","ovingsfeltsjo","https://wms.geonorge.no/skwms1/wms.ovingsfeltsjo","Grenser og inndelinger"),M("KommuneOgFylkesgrenserWms","Kommune- og fylkesgrenser (WMS)","adm_enheter_V2_WMS","https://wms.geonorge.no/skwms1/wms.adm_enheter2","Grenser og inndelinger"),M("NorgesSjogrenserNavn","Norges sjøgrenser - navn (WMS)","Maritime_grenser_navn","https://wms.geonorge.no/skwms1/wms.nmg","Grenser og inndelinger"),M("NorgesSjogrenser","Norges sjøgrenser","Grunnlinje,1_nautisk_mil,Territorialgrense,Yttergrense_for_tilstotende_sone,Avtalt_avgrensningslinje,200_nautiske_mil,Fiskerigrense,avgrensningslinje_for_sokkel,Sokkelgrense","https://wms.geonorge.no/skwms1/wms.nmg","Grenser og inndelinger"),M("HavneanleggGeonorge","Havneanlegg","havneanlegg","https://wms.geonorge.no/skwms1/wms.havnedata?language=eng","Havnedata"),M("Hoydekoter","Høydekoter","hoydekurver_1m,hoydekurver_5m,hoydetall5linje","https://openwms.statkart.no/skwms1/wms.fkb4","Høydedata"),M("DybdepunktWms","Dybdepunkt (WMS)","Dybdepunkt,grunne,skjaer_punkt","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),M("DybdekonturWms","Dybdekontur (WMS)","Dybdekontur,Torrfall_Grense","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),M("DybdelagWms","Dybdelag (WMS)","Dybdelag,Torrfall","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),M("MaritimInfrastruktur","Maritim infrastruktur","maritim_infrastruktur_wms","https://wms.geonorge.no/skwms1/wms.maritim_infrastruktur?language=eng","Marine grunndata"),M("KystkonturWms","Kystkontur (WMS)","Kystkontur","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),M("KonstruertKystkonturWms","Konstruert kystkontur (WMS)","Konstruertkystkontur","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),M("MgHavbunnsterreng","MG - Havbunnsterreng (WMS)","Dybde50m,Dybde10m,Dybde2m","https://geo.ngu.no/mapserver/MarineGrunnkartWMS","Marine grunnkart"),M("MgGravbarhet","MG - Gravbarhet (WMS)","Gravbarhet","https://geo.ngu.no/mapserver/MarineGrunnkartWMS","Marine grunnkart"),M("Skyggerelieff","Skyggerelieff","Havbunnraster2_WMS","https://openwms.statkart.no/skwms1/wms.havbunnraster2","Marine grunnkart"),M("MarineGrunnkartDatadekning","Marine grunnkart - datadekning","MG_Datadekning","https://geo.ngu.no/mapserver/MarineGrunnkartWMS","Marine grunnkart"),M("ForvaltningsplanomraderHavomradene","Forvaltningsplanområder for havområdene WMS","forvaltningsplaner_havomrader_omrade","https://kart.miljodirektoratet.no/geoserver/forvaltningsplaner_havomrader/wms?SERVICE=WMS","Natur og Miljø"),M("NaturtyperNin","Naturtyper (NiN)","naturtyper_nin_alle","https://kart.miljodirektoratet.no/arcgis/services/naturtyper_nin/MapServer/WmsServer","Natur og Miljø"),M("MarineNaturtyperDnHandbok19","Marine Naturtyper (DN håndbok 19)","naturtyper_marine_hb19_alle","https://kart.miljodirektoratet.no/arcgis/services/naturtyper_marine_hb19/MapServer/WmsServer","Natur og Miljø"),M("ArterAvNasjonalForvaltningsinteresse","Arter av nasjonal forvaltningsinteresse","Alle_arter_av_sarlig_stor_forv_int_pkt,Alle_arter_av_sarlig_stor_forv_int_omr","https://kart.miljodirektoratet.no/arcgis/services/artnasjonal2/MapServer/WmsServer","Natur og Miljø"),M("Korallrev","Korallrev","korallrev_observert_rev","https://kart.hi.no/mareano/mareano_biologi/korallrev_observert_rev/wms?SERVICE=WMS","Natur og Miljø"),M("Vannlokaliteter","Vannlokaliteter","vannlokaliteter_pol","https://kart.miljodirektoratet.no/arcgis/services/vannmiljo/MapServer/WmsServer","Natur og Miljø"),M("VannforekomsterOkologiskTilstand","Vannforekomster - økologisk tilstand","Oekologisk_tilstand_eller_potensial_kystvann,Oekologisk_tilstand_eller_potensial_innsjoe,Oekologisk_tilstand_eller_potensial_elv","http://vann-nett.no/arcgis/services/WMS/Vannforskriften_TilstandPotensialRisiko_OGC/MapServer/WmsServer","Natur og Miljø"),M("NaturtyperDnHandbok13","Naturtyper (DN håndbok 13)","naturtyper_hb13_alle","https://kart.miljodirektoratet.no/arcgis/services/naturtyper_hb13/MapServer/WmsServer","Natur og Miljø"),M("GrenserOgOmraderPaNorskSokkel","Grenser og områder på norsk sokkel","2,3,1","https://factmaps.sodir.no/api/services/Factmaps/FactMapsED50UTM32/MapServer/WMSServer","Norsk sokkel"),M("FeltPaNorskSokkel","Felt på norsk sokkel","37","https://factmaps.sodir.no/api/services/Factmaps/FactMapsED50UTM32/MapServer/WMSServer","Norsk sokkel"),M("TillatelserPaNorskSokkel","Tillatelser på norsk sokkel","16,22,19,12,14","https://factmaps.sodir.no/api/services/Factmaps/FactMapsED50UTM32/MapServer/WMSServer","Norsk sokkel"),M("BronnbanerPaNorskSokkel","Brønnbaner på norsk sokkel","72,73,74,75,76,77","https://factmaps.sodir.no/api/services/Factmaps/FactMapsED50UTM32/MapServer/WMSServer","Norsk sokkel"),M("DybdedatakvalitetB","Datakvalitet på dybdedata (B)","Dybdedatakvalitet_B","https://wms.geonorge.no/skwms1/wms.dybdedatakvalitet_navigasjon?language=eng","Referansedata"),M("DybdedatakvalitetC","Datakvalitet på dybdedata (C)","Dybdedatakvalitet_C","https://wms.geonorge.no/skwms1/wms.dybdedatakvalitet_navigasjon?language=eng","Referansedata"),M("DybdedatakvalitetD","Datakvalitet på dybdedata (D)","Dybdedatakvalitet_D","https://wms.geonorge.no/skwms1/wms.dybdedatakvalitet_navigasjon?language=eng","Referansedata"),M("DybdedatakvalitetU","Datakvalitet på dybdedata (U)","Dybdedatakvalitet_U","https://wms.geonorge.no/skwms1/wms.dybdedatakvalitet_navigasjon?language=eng","Referansedata")],de={light:{primary:{baseDefault:"#000667"},accent:{borderDefault:"#df3c1b",baseDefault:"#FF451F",baseHover:"#ff7559"},neutral:{backgroundDefault:"#ffffff",textDefault:"#2a2b35"}}}.light,pe=e=>e;function Vt(e,t){const r=e.replace("#",""),s=r.length===3?r.split("").map(u=>u+u).join(""):r,a=parseInt(s.slice(0,2),16),d=parseInt(s.slice(2,4),16),p=parseInt(s.slice(4,6),16);return`rgba(${a}, ${d}, ${p}, ${t})`}const J=pe(de.accent.baseDefault),ge=pe(de.neutral.backgroundDefault),Be=.2,Er=pe(de.accent.borderDefault),Cr=pe(de.accent.baseHover),_t=pe(de.primary.baseDefault),$t=_t,Ht=Be,Rt=pe(de.accent.borderDefault),Gt=pe(de.primary.baseDefault),Kt=pe(de.neutral.textDefault),Ut=pe(de.neutral.backgroundDefault),jr=pe(de.accent.borderDefault),we=pe(de.primary.baseDefault),Yt=pe(de.neutral.backgroundDefault),xe="#0062ba",qt=Vt(xe,.4),zt=Vt(xe,.5),Zt="#ff0000",xr="#b0b0b0",bt="#088";function Mr(e){return"include"in e}function Jt(e,t){return t?Mr(t)?t.include.includes(e):!t.exclude.includes(e):!0}function Tr(e){const t={id:e.id,label:e.label,category:e.category,defaultVisible:e.defaultVisible??!0,metadata:e.metadata},r=`custom-${e.id}`;switch(e.type){case"geojson":return{...t,sources:{[r]:{type:"geojson",data:e.data}},layers:[{id:`${r}-fill`,type:"fill",source:r,paint:{"fill-color":e.fillColor??$t,"fill-opacity":e.fillOpacity??Ht},filter:["==","$type","Polygon"]},{id:`${r}-line`,type:"line",source:r,paint:{"line-color":e.lineColor??_t,"line-width":2},filter:["==","$type","LineString"]},{id:`${r}-circle`,type:"circle",source:r,paint:{"circle-color":e.pointColor??Rt,"circle-radius":5,"circle-stroke-color":Gt,"circle-stroke-width":1},filter:["==","$type","Point"]}]};case"wms":return{...t,sources:{[r]:{type:"raster",tiles:[e.url],tileSize:256,attribution:e.attribution}},layers:[{id:`${r}-raster`,type:"raster",source:r}]};case"vector-tiles":{const s=e.renderAs??"fill",a={id:`${r}-${s}`,type:s,source:r,"source-layer":e.sourceLayer};return s==="fill"?a.paint={"fill-color":e.color??bt}:s==="line"?a.paint={"line-color":e.color??bt,"line-width":2}:a.paint={"circle-color":e.color??bt,"circle-radius":5},{...t,sources:{[r]:{type:"vector",tiles:[e.url]}},layers:[a]}}}}const Fr={availableLayers:[],visibleLayerIds:new Set,toggleLayer:()=>{},showLayer:()=>{},hideLayer:()=>{},isVisible:()=>!1},Je=n.createContext(Fr),Ir=({children:e,include:t,exclude:r})=>{const s=n.useMemo(()=>{if(t)return{include:t};if(r)return{exclude:r}},[t,r]),a=n.useMemo(()=>Wt.filter(h=>Jt(h.id,s)),[s]),[d,p]=n.useState(()=>new Set(a.filter(h=>h.defaultVisible!==!1).map(h=>h.id))),u=n.useCallback(h=>{p(o=>{const k=new Set(o);return k.has(h)?k.delete(h):k.add(h),k})},[]),c=n.useCallback(h=>{p(o=>{if(o.has(h))return o;const k=new Set(o);return k.add(h),k})},[]),g=n.useCallback(h=>{p(o=>{if(!o.has(h))return o;const k=new Set(o);return k.delete(h),k})},[]),L=n.useCallback(h=>d.has(h),[d]),T=n.useMemo(()=>({availableLayers:a,visibleLayerIds:d,toggleLayer:u,showLayer:c,hideLayer:g,isVisible:L}),[a,d,u,c,g,L]);return l.jsx(Je.Provider,{value:T,children:e})},Ar={layers:[],visibleLayerIds:new Set,addLayer:()=>{},removeLayer:()=>{},toggleLayer:()=>{},showLayer:()=>{},hideLayer:()=>{},isVisible:()=>!1},Xe=n.createContext(Ar),Or=({children:e,initialLayers:t})=>{const[r,s]=n.useState(()=>t??[]),[a,d]=n.useState(()=>new Set((t??[]).filter(o=>o.defaultVisible!==!1).map(o=>o.id))),p=n.useCallback(o=>{s(k=>k.some(b=>b.id===o.id)?k:[...k,o]),o.defaultVisible!==!1&&d(k=>{if(k.has(o.id))return k;const b=new Set(k);return b.add(o.id),b})},[]),u=n.useCallback(o=>{s(k=>{const b=k.filter(F=>F.id!==o);return b.length===k.length?k:b}),d(k=>{if(!k.has(o))return k;const b=new Set(k);return b.delete(o),b})},[]),c=n.useCallback(o=>{d(k=>{const b=new Set(k);return b.has(o)?b.delete(o):b.add(o),b})},[]),g=n.useCallback(o=>{d(k=>{if(k.has(o))return k;const b=new Set(k);return b.add(o),b})},[]),L=n.useCallback(o=>{d(k=>{if(!k.has(o))return k;const b=new Set(k);return b.delete(o),b})},[]),T=n.useCallback(o=>a.has(o),[a]),h=n.useMemo(()=>({layers:r,visibleLayerIds:a,addLayer:p,removeLayer:u,toggleLayer:c,showLayer:g,hideLayer:L,isVisible:T}),[r,a,p,u,c,g,L,T]);return l.jsx(Xe.Provider,{value:h,children:e})},Pr={loading:!1,error:null,layers:[],visibleLayerIds:new Set,baseUrl:"",catalogEntries:[],toggleLayer:()=>{},showLayer:()=>{},hideLayer:()=>{},isVisible:()=>!1},We=n.createContext(Pr);function Nr(e){var p,u;const r=new DOMParser().parseFromString(e,"text/xml");if(r.querySelector("parsererror"))throw new Error("Failed to parse WMS GetCapabilities XML");const a=[],d=r.querySelectorAll("Layer > Layer");for(const c of d){const g=c.querySelector(":scope > Name"),L=c.querySelector(":scope > Title"),T=(p=g==null?void 0:g.textContent)==null?void 0:p.trim(),h=(u=L==null?void 0:L.textContent)==null?void 0:u.trim();T&&a.push({name:T,title:h||T})}return a}function Dr(e,t,r){const s=`wms-catalog-${e.name}`,a=`wms-cat-${e.name}`,d=t.includes("?")?"&":"?",p={SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:e.name,STYLES:"",CRS:"EPSG:3857",BBOX:"{bbox-epsg-3857}",EXCEPTIONS:"XML",WIDTH:"256",HEIGHT:"256",FORMAT:"image/png",TRANSPARENT:"TRUE"};return{id:s,label:e.title,category:"WMS-katalog",defaultVisible:!1,sources:{[a]:{type:"raster",tiles:[`${t}${d}`+Object.entries(p).map(([u,c])=>`${u}=${c}`).join("&")],tileSize:256,attribution:r}},layers:[{id:`${a}-raster`,type:"raster",source:a}]}}function Br(e){const t=new URL(e);return t.searchParams.delete("service"),t.searchParams.delete("SERVICE"),t.searchParams.delete("request"),t.searchParams.delete("REQUEST"),t.searchParams.delete("version"),t.searchParams.delete("VERSION"),t.toString().replace(/[?&]$/,"")}const Wr=({children:e,capabilitiesUrl:t,attribution:r})=>{const[s,a]=n.useState(!0),[d,p]=n.useState(null),[u,c]=n.useState([]),[g,L]=n.useState(new Set),T=n.useMemo(()=>Br(t),[t]);n.useEffect(()=>{let P=!1;return a(!0),p(null),fetch(t).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}: ${_.statusText}`);return _.text()}).then(_=>{if(P)return;const $=Nr(_);c($),a(!1)}).catch(_=>{P||(p(_ instanceof Error?_.message:String(_)),a(!1))}),()=>{P=!0}},[t]);const h=n.useMemo(()=>u.map(P=>Dr(P,T,r)),[u,T,r]),o=n.useCallback(P=>{L(_=>{const $=new Set(_);return $.has(P)?$.delete(P):$.add(P),$})},[]),k=n.useCallback(P=>{L(_=>{if(_.has(P))return _;const $=new Set(_);return $.add(P),$})},[]),b=n.useCallback(P=>{L(_=>{if(!_.has(P))return _;const $=new Set(_);return $.delete(P),$})},[]),F=n.useCallback(P=>g.has(P),[g]),O=n.useMemo(()=>({loading:s,error:d,layers:h,visibleLayerIds:g,baseUrl:T,catalogEntries:u,toggleLayer:o,showLayer:k,hideLayer:b,isVisible:F}),[s,d,h,g,T,u,o,k,b,F]);return l.jsx(We.Provider,{value:O,children:e})};function St({initialCoordinate:e,disabled:t=!1,onMapClick:r,height:s,showZoomControls:a=!0}={}){const d=n.useRef(null),p=n.useRef(null),u=n.useRef(0),[c,g]=n.useState(0),L=c>0,{viewBounds:T,defaultBounds:h}=n.useContext(vt),o=n.useContext(Ze),k=n.useContext(Je),b=n.useContext(Xe),F=n.useContext(We),O=n.useRef(t);n.useEffect(()=>{O.current=t},[t]);const P=n.useRef(r);P.current=r,n.useEffect(()=>{if(!L)return;const j=p.current;j&&(t?(j.dragPan.disable(),j.scrollZoom.disable(),j.boxZoom.disable(),j.dragRotate.disable(),j.keyboard.disable(),j.doubleClickZoom.disable(),j.touchZoomRotate.disable()):(j.dragPan.enable(),j.scrollZoom.enable(),j.boxZoom.enable(),j.dragRotate.enable(),j.keyboard.enable(),j.doubleClickZoom.enable(),j.touchZoomRotate.enable()))},[t,c]),n.useEffect(()=>{d.current&&(d.current.style.height=s??"")},[s]),n.useEffect(()=>{const j=d.current;if(!j||p.current||typeof document>"u"||typeof window>"u")return;const C=()=>{if(p.current)return;const E=o.availableBaseLayers.find(R=>R.id===o.activeBaseLayerId),S={...Dt,sources:E?{...E.sources}:{},layers:E?[...E.layers]:[]},A={container:j,style:S,attributionControl:{}};e?(A.center=[e.longitude,e.latitude],A.zoom=14):(A.bounds=h,A.fitBoundsOptions={padding:20});const B=new Pe.Map(A);a&&B.addControl(new Pe.NavigationControl({showCompass:!1}),"bottom-right"),_.current=E??null,p.current=B,u.current+=1,g(u.current),B.on("click",R=>{var m;if(O.current)return;const{lng:z,lat:K}=R.lngLat;(m=P.current)==null||m.call(P,{latitude:gt(Ye(K),6),longitude:gt(qe(z),6)})})},I=()=>{const E=p.current;if(!E)return;const S=E.getCanvas(),A=(S==null?void 0:S.getContext("webgl2"))??(S==null?void 0:S.getContext("webgl")),B=A==null?void 0:A.getExtension("WEBGL_lose_context");E.remove(),B==null||B.loseContext(),p.current=null,g(0),_.current=null,$.current=new Set},v=j.getBoundingClientRect(),D=window.innerHeight||document.documentElement.clientHeight,W=window.innerWidth||document.documentElement.clientWidth;if(v.bottom>0&&v.right>0&&v.top<D&&v.left<W)return C(),I;const w=new IntersectionObserver(E=>{E[0].isIntersecting&&(w.disconnect(),C())},{threshold:0});return w.observe(j),()=>{w.disconnect(),I()}},[]),n.useEffect(()=>{if(!L)return;const j=p.current;if(!j||!T||T.length===0)return;const C=T.flat();if(C.length===0)return;let I=1/0,v=-1/0,D=1/0,W=-1/0;for(const[f,w]of C)f<I&&(I=f),f>v&&(v=f),w<D&&(D=w),w>W&&(W=w);j.fitBounds([[I,D],[v,W]],{padding:20,duration:300})},[T,c]);const _=n.useRef(null);n.useEffect(()=>{if(!L)return;const j=p.current;if(!j)return;const C=()=>{var D,W;const I=o.availableBaseLayers.find(f=>f.id===o.activeBaseLayerId),v=_.current;if((v==null?void 0:v.id)!==(I==null?void 0:I.id)){if(v&&Xt(j,v),I){const f=(W=(D=j.getStyle().layers)==null?void 0:D[0])==null?void 0:W.id;for(const[w,E]of Object.entries(I.sources))j.getSource(w)||j.addSource(w,E);for(const w of I.layers)j.getLayer(w.id)||j.addLayer(w,f)}_.current=I??null}};return j.loaded()?C():j.once("load",C),()=>{j.off("load",C)}},[o.activeBaseLayerId,o.availableBaseLayers,c]);const $=n.useRef(new Set);return n.useEffect(()=>{if(!L)return;const j=p.current;if(!j)return;const C=()=>{const I=[...k.availableLayers,...b.layers,...F.layers],v=new Set([...k.visibleLayerIds,...b.visibleLayerIds,...F.visibleLayerIds]),D=new Set(I.map(f=>f.id)),W=$.current;for(const f of W)if(!D.has(f)){const w=Vr(f,I);w&&Xt(j,w),W.delete(f)}for(const f of I){const w=W.has(f.id),E=v.has(f.id);if(w)for(const S of f.layers)j.getLayer(S.id)&&j.setLayoutProperty(S.id,"visibility",E?"visible":"none");else{for(const[S,A]of Object.entries(f.sources))j.getSource(S)||j.addSource(S,A);for(const S of f.layers)j.getLayer(S.id)||j.addLayer(S),j.setLayoutProperty(S.id,"visibility",E?"visible":"none");W.add(f.id)}}};return j.loaded()?C():j.once("load",C),()=>{j.off("load",C)}},[k.availableLayers,k.visibleLayerIds,b.layers,b.visibleLayerIds,F.layers,F.visibleLayerIds,c]),n.useEffect(()=>{if(!L)return;const j=p.current;if(!j)return;const C=()=>{j.getSource("easter-egg-src")||(j.addSource("easter-egg-src",{type:"geojson",data:$r}),j.addLayer({id:"easter-egg-fill",type:"fill",source:"easter-egg-src",minzoom:16,paint:{"fill-color":["get","fill"],"fill-opacity":.85}}),j.addLayer({id:"easter-egg-outline",type:"line",source:"easter-egg-src",minzoom:16,paint:{"line-color":["get","stroke"],"line-width":2}}))};j.loaded()?C():j.once("load",C)},[c]),{mapContainerRef:d,mapRef:p,mapReady:L,mapVersion:c}}function Vr(e,t){return t.find(r=>r.id===e)}function Xt(e,t){for(const r of t.layers)e.getLayer(r.id)&&e.removeLayer(r.id);for(const r of Object.keys(t.sources))e.getSource(r)&&e.removeSource(r)}const $r={type:"FeatureCollection",features:[{type:"Feature",properties:{fill:"#8B4513",stroke:"#5C2D0A"},geometry:{type:"Polygon",coordinates:[[[10.9501935,59.2167004],[10.9501427,59.2167364],[10.950092,59.2167544],[10.9500666,59.2167567],[10.9500412,59.2167544],[10.9499905,59.2167364],[10.9499397,59.2167004],[10.9497705,59.2165504],[10.949735,59.2165099],[10.9497299,59.2164784],[10.9497388,59.216466],[10.9497553,59.2164559],[10.9498111,59.2164424],[10.9498974,59.2164379],[10.9502358,59.2164379],[10.9503221,59.2164424],[10.9503779,59.2164559],[10.9503944,59.216466],[10.9504033,59.2164784],[10.9503982,59.2165099],[10.9503627,59.2165504],[10.9501935,59.2167004]]]}},{type:"Feature",properties:{fill:"#E8466A",stroke:"#A1203E"},geometry:{type:"Polygon",coordinates:[[[6.1024125,62.4597089],[6.1023617,62.4597449],[6.102311,62.4597629],[6.1022856,62.4597652],[6.1022602,62.4597629],[6.1022095,62.4597449],[6.1021587,62.4597089],[6.1019895,62.4595589],[6.101954,62.4595184],[6.1019489,62.4594869],[6.1019578,62.4594745],[6.1019743,62.4594644],[6.1020301,62.4594509],[6.1021164,62.4594464],[6.1024548,62.4594464],[6.1025411,62.4594509],[6.1025969,62.4594644],[6.1026134,62.4594745],[6.1026223,62.4594869],[6.1026172,62.4595184],[6.1025817,62.4595589],[6.1024125,62.4597089]]]}}]};function Qt(e,t,r,s,a){const d=Math.round((r.longitude-s.west)/(s.east-s.west)*a.width),p=Math.round((s.north-r.latitude)/(s.north-s.south)*a.height),u={SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetFeatureInfo",LAYERS:t,QUERY_LAYERS:t,CRS:"EPSG:4326",BBOX:`${s.south},${s.west},${s.north},${s.east}`,WIDTH:String(a.width),HEIGHT:String(a.height),INFO_FORMAT:"text/html",I:String(d),J:String(p),FEATURE_COUNT:"10"},c=e.includes("?")?"&":"?",g=Object.entries(u).map(([L,T])=>`${L}=${encodeURIComponent(T)}`).join("&");return`${e}${c}${g}`}async function Hr(e,t,r,s,a,d,p){const u=Qt(e,r,s,a,d);try{const c=await fetch(u,{signal:p});if(!c.ok)return{layerId:t,layerName:r,html:""};const g=await c.text();return{layerId:t,layerName:r,html:g}}catch{return{layerId:t,layerName:r,html:""}}}function Lt({mapRef:e,coordinate:t,enabled:r=!0}){const{baseUrl:s,catalogEntries:a,visibleLayerIds:d}=n.useContext(We),[p,u]=n.useState(!1),[c,g]=n.useState(null),L=n.useRef(null);return n.useEffect(()=>{var P;if((P=L.current)==null||P.abort(),L.current=null,!r||!t||!s)return;const T=e.current;if(!T)return;const h=a.filter(_=>d.has(`wms-catalog-${_.name}`));if(console.log("Visible WMS catalog entries:",h,a),h.length===0){g({coordinate:t,layerResults:[]});return}const o=T.getBounds(),k={west:o.getWest(),south:o.getSouth(),east:o.getEast(),north:o.getNorth()},b=T.getCanvas(),F={width:b.width,height:b.height},O=new AbortController;return L.current=O,u(!0),Promise.all(h.map(_=>Hr(s,`wms-catalog-${_.name}`,_.name,t,k,F,O.signal))).then(_=>{O.signal.aborted||g({coordinate:t,layerResults:_})}).finally(()=>{O.signal.aborted||u(!1)}),()=>{O.abort()}},[t,r,s,a,d,e]),{loading:p,result:c}}function wt(e){let t=1/0,r=-1/0,s=1/0,a=-1/0,d=!1;function p(u){if(Array.isArray(u))if(typeof u[0]=="number"&&typeof u[1]=="number"){const[c,g]=u;c<t&&(t=c),c>r&&(r=c),g<s&&(s=g),g>a&&(a=g),d=!0}else for(const c of u)p(c)}for(const u of e.features)u.geometry&&"coordinates"in u.geometry&&p(u.geometry.coordinates);return d?[t,s,r,a]:null}const Rr={fillColor:$t,fillOpacity:Ht,lineColor:_t,lineWidth:2,pointRadius:6,pointColor:Rt,pointStrokeColor:Gt,pointStrokeWidth:2},oe="geojson-data",Qe="geojson-fill",et="geojson-line",Et="geojson-point-stroke",tt="geojson-point",Gr=[tt,Et,et,Qe],rt="geojson-hover-fill",nt="geojson-hover-line",st="geojson-hover-point",ot="geojson-selected-fill",at="geojson-selected-line",it="geojson-selected-point",Kr=[rt,nt,st,ot,at,it],Ur=[Qe,et,tt],lt="geojson-label";function ve(e,t){return["coalesce",["get",e],t]}function ct(e){return e.type==="FeatureCollection"?{type:"FeatureCollection",features:e.features}:{type:"FeatureCollection",features:[e]}}function Yr(e){try{for(const t of[...Gr,...Kr])e.getLayer(t)&&e.removeLayer(t);e.getSource(oe)&&e.removeSource(oe)}catch{}}function qr(e,t){e.getLayer(rt)||e.addLayer({id:rt,type:"fill",source:oe,layout:{visibility:"visible"},paint:{"fill-color":qt,"fill-opacity":.5},filter:["==",["get","__hover"],!0]}),e.getLayer(nt)||e.addLayer({id:nt,type:"line",source:oe,layout:{visibility:"visible"},paint:{"line-color":xe,"line-width":t.lineWidth+2,"line-opacity":.6},filter:["==",["get","__hover"],!0]}),e.getLayer(st)||e.addLayer({id:st,type:"circle",source:oe,layout:{visibility:"visible"},paint:{"circle-radius":t.pointRadius+4,"circle-color":qt,"circle-opacity":.6},filter:["==",["get","__hover"],!0]}),e.getLayer(ot)||e.addLayer({id:ot,type:"line",source:oe,layout:{visibility:"visible"},paint:{"line-color":xe,"line-width":4,"line-blur":3,"line-opacity":.8},filter:["==",["get","__selected"],!0]}),e.getLayer(at)||e.addLayer({id:at,type:"line",source:oe,layout:{visibility:"visible"},paint:{"line-color":xe,"line-width":t.lineWidth+4,"line-blur":3,"line-opacity":.8},filter:["==",["get","__selected"],!0]}),e.getLayer(it)||e.addLayer({id:it,type:"circle",source:oe,layout:{visibility:"visible"},paint:{"circle-radius":t.pointRadius+6,"circle-color":zt,"circle-blur":.5,"circle-opacity":.9},filter:["==",["get","__selected"],!0]})}function zr(e,t){const r=t!==null?["==",["id"],t]:["==",["get","__hover"],!0];for(const s of[rt,nt,st])e.getLayer(s)&&e.setFilter(s,r)}function Zr(e,t){const r=t.length>0?["in",["id"],["literal",t]]:["==",["get","__selected"],!0];for(const s of[ot,at,it])e.getLayer(s)&&e.setFilter(s,r)}function er(e,t){let r;switch(e.type){case"Point":case"MultiPoint":r="point";break;case"LineString":case"MultiLineString":r="linestring";break;case"Polygon":case"MultiPolygon":r="polygon";break}return r&&t.includes(r)?r:"static"}function Jr({mapRef:e,mapVersion:t,modes:r,editable:s,deletable:a,disabled:d,singleFeature:p=!1,onChange:u,onSelect:c}){const g=n.useRef(null),[L,T]=n.useState("static"),[h,o]=n.useState(!1),[k,b]=n.useState([]),[F,O]=n.useState(!1),P=n.useRef(!1),_=n.useRef(u);_.current=u;const $=n.useRef(c);$.current=c;const j=n.useRef(p);j.current=p;const C=n.useRef(r);C.current=r;const I=n.useCallback(()=>{const E=g.current;if(!E||!_.current)return;P.current=!0;const B={type:"FeatureCollection",features:E.getSnapshot().filter(R=>{var z;return((z=R.properties)==null?void 0:z.mode)!=="select"}).map(({id:R,geometry:z,properties:K})=>({type:"Feature",...R!=null?{id:R}:{},geometry:z,properties:{...K}}))};_.current(B)},[]);n.useEffect(()=>{const E=e.current;if(!E||!t||d)return;const S=()=>{if(g.current)return;const B=r.map(K=>{switch(K){case"point":return new je.TerraDrawPointMode({styles:{pointColor:J,pointWidth:6,pointOutlineColor:ge,pointOutlineWidth:3}});case"linestring":return new je.TerraDrawLineStringMode({styles:{lineStringColor:J,lineStringWidth:4,closingPointColor:J,closingPointOutlineColor:ge,closingPointOutlineWidth:2,closingPointWidth:5,snappingPointColor:J,snappingPointOutlineColor:ge,snappingPointOutlineWidth:2,snappingPointWidth:5,coordinatePointColor:J,coordinatePointOutlineColor:ge,coordinatePointOutlineWidth:2,coordinatePointWidth:5}});case"polygon":return new je.TerraDrawPolygonMode({styles:{fillColor:J,fillOpacity:Be,outlineColor:J,outlineWidth:4,closingPointColor:J,closingPointOutlineColor:ge,closingPointOutlineWidth:2,closingPointWidth:5,snappingPointColor:J,snappingPointOutlineColor:ge,snappingPointOutlineWidth:2,snappingPointWidth:5,editedPointColor:J,editedPointOutlineColor:ge,editedPointOutlineWidth:2,editedPointWidth:5,coordinatePointColor:J,coordinatePointOutlineColor:ge,coordinatePointOutlineWidth:2,coordinatePointWidth:5}})}});s&&B.push(new je.TerraDrawSelectMode({styles:{selectedPointColor:J,selectedPointWidth:6,selectedPointOutlineColor:Zt,selectedPointOutlineWidth:3,selectedLineStringColor:J,selectedLineStringWidth:4,selectedPolygonColor:J,selectedPolygonFillOpacity:Be,selectedPolygonOutlineColor:J,selectedPolygonOutlineWidth:4,selectionPointColor:Er,selectionPointOutlineColor:Zt,selectionPointOutlineWidth:2,midPointColor:Cr,midPointOutlineColor:ge,midPointOutlineWidth:2},flags:{point:{feature:{draggable:!0}},linestring:{feature:{draggable:!0,coordinates:{midpoints:!0,draggable:!0,deletable:!0}}},polygon:{feature:{draggable:!0,coordinates:{midpoints:!0,draggable:!0,deletable:!0}}}}})),B.push(new je.TerraDrawRenderMode({modeName:"static",styles:{pointColor:J,pointWidth:6,pointOutlineColor:ge,pointOutlineWidth:3,lineStringColor:J,lineStringWidth:4,polygonFillColor:J,polygonFillOpacity:Be,polygonOutlineColor:J,polygonOutlineWidth:4}}));const R=new je.TerraDraw({adapter:new pr.TerraDrawMapLibreGLAdapter({map:E}),modes:B});R.start();const z=p&&r.length>0?r[0]:"static";R.setMode(z),T(z),R.on("change",()=>{const K=R.getMode();K==="linestring"||K==="polygon"||I()}),R.on("finish",K=>{j.current&&r.length>0?Promise.resolve().then(()=>{const m=g.current;if(!m)return;const N=m.getSnapshot().filter(G=>{var fe,ke,q,ie;return((fe=G.properties)==null?void 0:fe.mode)!=="select"&&!((ke=G.properties)!=null&&ke.closingPoint)&&!((q=G.properties)!=null&&q.snappingPoint)&&!((ie=G.properties)!=null&&ie.coordinatePoint)&&G.id!==K}).map(G=>G.id);if(N.length>0)try{m.removeFeatures(N)}catch{}I();const V=r[0];m.getMode()!==V&&(m.setMode(V),T(V))}):I()}),R.on("select",()=>{var i;o(!0);const m=R.getSnapshot().filter(N=>{var V;return((V=N.properties)==null?void 0:V.selected)===!0}).map(({id:N,geometry:V,properties:G})=>({type:"Feature",...N!=null?{id:N}:{},geometry:V,properties:{...G}}));b(m),(i=$.current)==null||i.call($,m.length>0?m:null)}),R.on("deselect",()=>{var K;o(!1),b([]),(K=$.current)==null||K.call($,null)}),g.current=R,O(!0)};let A=null;return E.getStyle()?S():(A=()=>{g.current||S()},E.once("load",A)),()=>{A&&E.off("load",A);const B=g.current;if(B){try{B.stop()}catch{}g.current=null,P.current=!1,O(!1)}}},[e,t,d,r,s,p,I]);const v=n.useCallback(E=>{const S=g.current;if(!S)return;const B=S.getSnapshot().filter(K=>{var m,i,N,V;return((m=K.properties)==null?void 0:m.mode)!=="select"&&!((i=K.properties)!=null&&i.closingPoint)&&!((N=K.properties)!=null&&N.snappingPoint)&&!((V=K.properties)!=null&&V.coordinatePoint)}).map(K=>K.id);if(B.length>0)try{S.removeFeatures(B)}catch{}if(P.current=!1,!E||E.features.length===0)return;const z=ct(E).features.map(K=>({...K,properties:{...K.properties,mode:er(K.geometry,C.current)}}));try{S.addFeatures(z),P.current=!0}catch(K){console.error("[GeoJsonEditor] Error replacing features:",K)}},[]),D=n.useCallback(E=>{const S=g.current;if(!S||!E||P.current)return;const A=ct(E);if(A.features.length===0)return;const B=A.features.map(R=>({...R,properties:{...R.properties,mode:er(R.geometry,C.current)}}));try{S.addFeatures(B),P.current=!0}catch(R){console.error("[GeoJsonEditor] Error loading initial features:",R)}},[]),W=n.useCallback(E=>{const S=g.current;if(S)try{S.setMode(E),T(E)}catch(A){console.error("[GeoJsonEditor] Error setting mode:",A)}},[]),f=n.useCallback(()=>{var B;const E=g.current;if(!E||!a)return;const A=E.getSnapshot().filter(R=>{var z;return((z=R.properties)==null?void 0:z.selected)===!0});if(A.length>0){const R=A.map(z=>z.id);E.removeFeatures(R),o(!1),b([]),(B=$.current)==null||B.call($,null),I()}},[a,I]),w=n.useCallback(()=>{const E=g.current;return E?E.getSnapshot().filter(A=>{var B;return((B=A.properties)==null?void 0:B.mode)!=="select"}).map(({id:A,geometry:B,properties:R})=>({type:"Feature",...A!=null?{id:A}:{},geometry:B,properties:{...R}})):[]},[]);return{activeMode:L,setActiveMode:W,deleteSelected:f,hasSelection:h,selectedFeatures:k,getSnapshot:w,isReady:F,loadInitialData:D,replaceFeatures:v}}const Xr=(()=>{const e=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
23
|
+
<%s key={someKey} {...props} />`,G,q,ie,q),m[q+G]=!0)}if(q=null,V!==void 0&&(r(V),q=""+V),p(N)&&(r(N.key),q=""+N.key),"key"in N){V={};for(var me in N)me!=="key"&&(V[me]=N[me])}else V=N;return q&&u(V,typeof i=="function"?i.displayName||i.name||"Unknown":i),g(i,q,V,a(),fe,ke)}function T(i){h(i)?i._store&&(i._store.validated=1):typeof i=="object"&&i!==null&&i.$$typeof===D&&(i._payload.status==="fulfilled"?h(i._payload.value)&&i._payload.value._store&&(i._payload.value._store.validated=1):i._store&&(i._store.validated=1))}function h(i){return typeof i=="object"&&i!==null&&i.$$typeof===k}var o=n,k=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),$=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),f=Symbol.for("react.client.reference"),w=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=Object.prototype.hasOwnProperty,S=Array.isArray,A=console.createTask?console.createTask:function(){return null};o={react_stack_bottom_frame:function(i){return i()}};var B,R={},z=o.react_stack_bottom_frame.bind(o,d)(),K=A(s(d)),m={};De.Fragment=F,De.jsx=function(i,N,V){var G=1e4>w.recentlyCreatedOwnerStacks++;return L(i,N,V,!1,G?Error("react-stack-top-frame"):z,G?A(s(i)):K)},De.jsxs=function(i,N,V){var G=1e4>w.recentlyCreatedOwnerStacks++;return L(i,N,V,!0,G?Error("react-stack-top-frame"):z,G?A(s(i)):K)}})()),De}var Pt;function kr(){return Pt||(Pt=1,process.env.NODE_ENV==="production"?Ke.exports=gr():Ke.exports=yr()),Ke.exports}var l=kr();function Ue(e){return(e%360+360)%360}function Ye(e){return Math.max(-90,Math.min(90,e))}function qe(e){return Math.max(-180,Math.min(180,e))}function gt(e,t){const r=10**t;return Math.round(e*r)/r}const se=[];for(let e=0;e<256;++e)se.push((e+256).toString(16).slice(1));function mr(e,t=0){return(se[e[t+0]]+se[e[t+1]]+se[e[t+2]]+se[e[t+3]]+"-"+se[e[t+4]]+se[e[t+5]]+"-"+se[e[t+6]]+se[e[t+7]]+"-"+se[e[t+8]]+se[e[t+9]]+"-"+se[e[t+10]]+se[e[t+11]]+se[e[t+12]]+se[e[t+13]]+se[e[t+14]]+se[e[t+15]]).toLowerCase()}const hr=new Uint8Array(16);function vr(){return crypto.getRandomValues(hr)}function _r(e,t,r){return crypto.randomUUID?crypto.randomUUID():br(e)}function br(e,t,r){var a;e=e||{};const s=e.random??((a=e.rng)==null?void 0:a.call(e))??vr();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,mr(s)}const yt=()=>_r(),Nt={mapContainer:"_mapContainer_1krt1_1"},ue={editorWrapper:"_editorWrapper_14o42_1",toolbar:"_toolbar_14o42_6",toolbarButton:"_toolbarButton_14o42_21",active:"_active_14o42_43",danger:"_danger_14o42_49",toolbarDivider:"_toolbarDivider_14o42_58"},kt={latitude:65,longitude:14},mt=5,ht=[[3,57.5],[32,71.5]],Dt={version:8,glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",sources:{},layers:[]},Bt={id:"kartverket-topo",label:"Topografisk",sources:{"kartverket-topo":{type:"raster",tiles:["https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png"],tileSize:256,maxzoom:18,attribution:'© <a href="https://www.kartverket.no/">Kartverket</a>'}},layers:[{id:"kartverket-topo-raster",type:"raster",source:"kartverket-topo"}]},vt=n.createContext({setViewBounds:e=>{},defaultCenter:kt,defaultZoom:mt,defaultBounds:ht}),Sr=({children:e,defaultCenter:t=kt,defaultZoom:r=mt,defaultBounds:s=ht})=>{const[a,d]=n.useState(void 0),p=u=>{d(u)};return l.jsx(vt.Provider,{value:{viewBounds:a,setViewBounds:p,defaultCenter:t,defaultZoom:r,defaultBounds:s},children:e})},ze=[Bt],Lr={availableBaseLayers:ze,activeBaseLayerId:ze[0].id,setActiveBaseLayer:()=>{}},Ze=n.createContext(Lr),wr=({children:e,baseLayers:t,defaultActiveId:r})=>{const s=n.useMemo(()=>t&&t.length>0?t:ze,[t]),[a,d]=n.useState(()=>{var c;return r??((c=s[0])==null?void 0:c.id)??ze[0].id}),p=n.useCallback(c=>{s.some(g=>g.id===c)&&d(c)},[s]),u=n.useMemo(()=>({availableBaseLayers:s,activeBaseLayerId:a,setActiveBaseLayer:p}),[s,a,p]);return l.jsx(Ze.Provider,{value:u,children:e})};function y(e,t,r,s){const a=`kv-${e}`,d={SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:r,STYLES:"",CRS:"EPSG:3857",BBOX:"{bbox-epsg-3857}",GUI:"2",EXCEPTIONS:"XML",WIDTH:256,HEIGHT:256,FORMAT:"image/png",INFOFORMAT:"text/html",TRANSPARENT:"TRUE",QUERYABLE:"true",TRANSITIONEFFECT:"resize"};return{id:e,label:t,category:s,defaultVisible:!1,sources:{[a]:{type:"raster",tiles:["https://services.kystverket.no/mapserv.ashx?"+Object.entries(d).map(([p,u])=>`${p}=${u}`).join("&")],tileSize:256,attribution:'© <a href="https://www.kystverket.no/">Kystverket</a>'}},layers:[{id:`${a}-raster`,type:"raster",source:a}]}}function x(e,t,r,s,a,d){const p=`ext-${e}`,u=s.includes("?")?"&":"?",c={SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:r,STYLES:"",CRS:"EPSG:3857",BBOX:"{bbox-epsg-3857}",EXCEPTIONS:"XML",WIDTH:256,HEIGHT:256,FORMAT:"image/png",TRANSPARENT:"TRUE"};return{id:e,label:t,category:a,defaultVisible:!1,sources:{[p]:{type:"raster",tiles:[`${s}${u}`+Object.entries(c).map(([g,L])=>`${g}=${L}`).join("&")],tileSize:256,attribution:d??`© <a href="${new URL(s).origin}">${new URL(s).hostname}</a>`}},layers:[{id:`${p}-raster`,type:"raster",source:p}]}}const Wt=[x("Skipstrafikk2016SkipOver15M","Skipstrafikk 2016 (skip over 15 m)","AIS-density-Norway-2016","https://wms-geo.kystverket.no/density","All skipstrafikk (2016/2017)",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("Beredskapsdepot","Beredskapsdepot","layer_25","Beredskap"),y("Beredskapsanalyseomrader","Beredskapsanalyseområder","layer_764","Beredskap"),y("Nodhavner","Nødhavner","layer_26","Beredskap"),y("Iua","IUA","layer_493","Beredskap"),y("RitsKjemikalieberedskap","RITS - kjemikalieberedskap","layer_220","Beredskap"),y("Tilsynslag","Tilsynslag","layer_34","Beredskap"),x("AisTilsynslagfartoy","AIS - Tilsynslagfartøy","tracks,trajectories,points,labels_ship_name_scale_independent","https://geomap05.kystverket.no/api/mapserver/a8528a26-0adb-4208-933c-d7ad0452f83e","Beredskap",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("50MeterBuffer","50 meter buffer","layer_583","Buffersoner"),y("100MeterBuffer","100 meter buffer","layer_584","Buffersoner"),y("Fartsomrade1","Fartsområde 1","layer_959","Data fra Sjøfartsdirektoratet"),y("Fartsomrade2","Fartsområde 2","layer_960","Data fra Sjøfartsdirektoratet"),y("Fartsomrade3","Fartsområde 3","layer_961","Data fra Sjøfartsdirektoratet"),y("Fartsomrade4","Fartsområde 4","layer_962","Data fra Sjøfartsdirektoratet"),y("LitenKystfart","Liten kystfart","layer_963","Data fra Sjøfartsdirektoratet"),y("BallastvannOmrade1RostTromso","Ballastvann - Område 1: Røst - Tromsø","layer_968","Data fra Sjøfartsdirektoratet"),y("BallastvannOmrade2Norskehavet","Ballastvann - Område 2: Norskehavet","layer_969","Data fra Sjøfartsdirektoratet"),y("BallastvannOmrade3Vestlandskysten","Ballastvann - Område 3: Vestlandskysten","layer_970","Data fra Sjøfartsdirektoratet"),y("FartsomradeFiskefartoyFjordfiske","Fartsområde fiskefartøy - Fjordfiske","layer_971","Data fra Sjøfartsdirektoratet"),y("FartsomradeFiskefartoyKystfiske","Fartsområde fiskefartøy - Kystfiske","layer_972","Data fra Sjøfartsdirektoratet"),y("VhfTeoretiskDekningsomrade","VHF teoretisk dekningsområde","layer_975","Data fra Sjøfartsdirektoratet"),y("Fiskerihavner","Fiskerihavner","layer_503","Eiendom"),y("FyreiendommerNy","Fyreiendommer (ny)","layer_512","Eiendom"),y("FyreiendommerI3d","Fyreiendommer i 3d","layer_901","Eiendom"),y("FareomraderAndoyaSpaceCenter","Fareområder Andøya Space center","layer_digi_87","Fareområder"),y("Farledsareal","Farledsareal","layer_554","Farled og merker"),y("FritidsfartoyAlleFartsgrenser","For fritidsfartøy - alle fartsgrenser på sjøen","layer_754","Fartsforskrift"),y("NaeringsfartoyAlleFartsgrenser","For næringsfartøy - alle fartsgrenser på sjøen","layer_762","Fartsforskrift"),y("FartsrestriksjonerInnsjoOgElver","Fartsrestriksjoner innsjø og elver","layer_548","Fartsforskrift"),y("Kommuneoversikt","Kommuneoversikt","layer_787","Fartsforskrift"),y("AkvakulturanleggMedInnehaver","Akvakulturanlegg med innehaver","layer_775","Fiskeri og havbruk"),y("HavbrukTilHavsTilrading2019","Havbruk til havs - Tilråding 2019","layer_589","Fiskeri og havbruk"),y("HavbrukTilHavsIdentifiserteOmrader","Havbruk til havs - Identifiserte områder","layer_588","Fiskeri og havbruk"),y("HavbrukTilHavsAnbefaling2022","Havbruk til havs anbefaling 2022","layer_885","Fiskeri og havbruk"),y("Verdensarvomrader","Verdensarvområder","layer_996","Grenser og inndelinger"),y("Kommunegrenser","Kommunegrenser","layer_555","Grenser og inndelinger"),y("Fylkesgrenser","Fylkesgrenser","layer_556","Grenser og inndelinger"),y("OmradeavgrensningArktisPolarkoden","Områdeavgrensning - Arktis (Polarkoden)","layer_98","Grenser og inndelinger"),y("EcaOmrader","ECA områder","layer_557","Grenser og inndelinger"),y("RedningsomradeNord","Redningsområde nord","layer_725","Grenser og inndelinger"),y("RedningsomradeSor","Redningsområde Sør","layer_724","Grenser og inndelinger"),y("Politidistrikt","Politidistrikt","layer_621","Grenser og inndelinger"),y("Grense250Nm","Grense 250 nm","layer_786","Grenser og inndelinger"),x("Oljetankere","Oljetankere","overlay_aistails_with_type1_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("KjemikalieProduktankere","Kjemikalie-/produkttankere","overlay_aistails_with_type2_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("Gasstankere","Gasstankere","overlay_aistails_with_type3_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("Bulkskip","Bulkskip","overlay_aistails_with_type4_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("StykkgodsskipHavbase","Stykkgodsskip","overlay_aistails_with_type5_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("Konteinerskip","Konteinerskip","overlay_aistails_with_type6_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("RoRoLast","Ro Ro last","overlay_aistails_with_type7_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("KjoleFryseskip","Kjøle-/fryseskip","overlay_aistails_with_type8_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("Passasjer","Passasjer","overlay_aistails_with_type9_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("OffshoreSupplySkip","Offshore supply skip","overlay_aistails_with_type10_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AndreOffshoreServiceSkip","Andre offshore service skip","overlay_aistails_with_type11_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AndreAktiviteter","Andre aktiviteter","overlay_aistails_with_type12_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("Fiskefartoy","Fiskefartøy","overlay_aistails_with_type13_and_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AlleSkipstyper","Alle skipstyper","overlay_aistails_with_size_32633","https://havbasemap1.kystverket.no/havbase_cache/","Havbase",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("DigitalPfsa","Digital PFSA","layer_1067","Havn"),y("SikkerLastingLossingBulkskip","Sikker lasting/lossing bulkskip","layer_1049","Havn"),y("BunkringAvDrivstoff","Bunkring av drivstoff","layer_digi_65","Havn"),y("TenTHavnerINorge","Ten-T havner i Norge","layer_993","Havn"),y("AisAnlopspunkter2023","AIS Anløpspunkter 2023","layer_1027","Havn"),y("AisAnlopspolygoner2023","AIS anløpspolygoner 2023","layer_1028","Havn"),y("HavvindApnedeOmrader","Havvind - åpnede områder","layer_882","Havvind"),y("Kystkontur","Kystkontur","layer_611","Kystkontur"),y("BygningsmessigAnleggVann","Bygningsmessig anlegg (vann)","layer_612","Kystkontur"),y("KaiBrygge","Kai & Brygge","layer_614","Kystkontur"),y("Bolgebryter","Bølgebryter","layer_615","Kystkontur"),y("Flytedokkant","Flytedokkant","layer_616","Kystkontur"),y("Molo","Molo","layer_613","Kystkontur"),y("TilskuddTilFiskerihavntiltak","Tilskudd til fiskerihavntiltak (Post 60)","layer_1078","Kystverkets tilskuddsordninger"),y("PosisjonerForLngOpplasting","Posisjoner for LNG opplasting","layer_521","LNG omlasting"),y("LngOmlastingSikkerhetssone540m","LNG omlasting Sikkerhetssone 540 meter","layer_522","LNG omlasting"),y("LngOmlastingSikkerhetssone840m","LNG omlasting Sikkerhetssone 840 meter","layer_523","LNG omlasting"),y("MetanolAnlegg","Metanol-anlegg","layer_713","Lavutslipp"),y("Landstrom","Landstrøm","layer_710","Lavutslipp"),y("LngAnlegg","LNG-anlegg","layer_712","Lavutslipp"),y("LadeanleggFerjer","Ladeanlegg ferjer","layer_709","Lavutslipp"),y("Amoniakk","Amoniakk","layer_1094","Lavutslipp"),y("Hydrogen","Hydrogen","layer_1095","Lavutslipp"),x("AisLosbaterLive","AIS Losbåter (live)","tracks,trajectories,points,labels_ship_name_scale_independent","https://geomap05.kystverket.no/api/mapserver/f7a96d50-5551-445d-88b4-3022288a7605","Los og farledsbevis",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("LosstasjonerOgLosformidling","Losstasjoner og losformidling","layer_59","Los og farledsbevis"),y("Losbordingsfelt","Losbordingsfelt","layer_29","Los og farledsbevis"),y("InnseilingskorrridorerLosplikt","Innseilingskorridorer - Losplikt","layer_99","Los og farledsbevis"),y("Losoldermannskap","Losoldermannskap","layer_534","Los og farledsbevis"),y("FarledsbevisRutenett","Farledsbevis, rutenett","layer_341","Los og farledsbevis"),y("FarledsbevisLokaleBegrensninger","Farledsbevis, lokale begrensninger","layer_532","Los og farledsbevis"),y("FdvLos2025","2025 - FDV LOS","layer_1079","Los og farledsbevis"),y("HovedOgBiled","Hoved- og biled","layer_552","Maritim sikring"),y("IspsHavneanleggSsn","ISPS havneanlegg (SSN)","layer_420","Maritim sikring"),y("IspsCruise","ISPS Cruise","layer_887","Maritim sikring"),y("AnkringsomraderForSjotransporten","Ankringsområder for sjøtransporten","layer_888","Maritim sikring"),y("OpplagsomraderForSjotransporten","Opplagsområder for sjøtransporten","layer_889","Maritim sikring"),y("RiggomraderISjo","Riggområder i sjø","layer_890","Maritim sikring"),y("VaerdataFraKystvaer","Værdata fra Kystvær","layer_1129","Meteorologiske data"),y("InstallasjonerPaNorskSokkel","Installasjoner på norsk sokkel (PostGIS)","layer_1107","Norsk sokkel"),y("VtsTjenesteomrade","VTS tjenesteområde","layer_696","Rutetiltak, rapportering og VTS"),y("Aktsomhetsomrader","Aktsomhetsområder","layer_102","Rutetiltak, rapportering og VTS"),y("Toveisfarled","Toveisfarled","layer_104","Rutetiltak, rapportering og VTS"),y("AnbefalteRuter","Anbefalte ruter","layer_702","Rutetiltak, rapportering og VTS"),y("TssOmrader","TSS områder","layer_706","Rutetiltak, rapportering og VTS"),y("TssAvgrensing","TSS avgrensing","layer_703","Rutetiltak, rapportering og VTS"),y("ForbudsomradePassasjerfartoy150m","Forbudsområde passasjerfartøy over 150 meter ved sterk kuling","layer_1108","Rutetiltak, rapportering og VTS"),y("Sjoulykker20092021","Sjøulykker 2009-2021","layer_799","Sjøsikkerhet"),x("SannsynlighetForUlykke","Sannsynlighet for ulykke","summert_grid20161214162224065","https://services.kystverket.no/qgis.ashx?map=2a9ba3ad-a973-4b84-99ea-b12d6f8b1da4","Sjøsikkerhet",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("SannsynlighetForUlykkeMedUtslipp","Sannsynlighet for ulykke med utslipp","grid_risiko_utslipp20170112124144604","https://services.kystverket.no/qgis.ashx?map=79625cb8-f319-429a-acfc-c63840281a88","Sjøsikkerhet",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("SannsynlighetForUlykkeMedTapAvLiv","Sannsynlighet for ulykke med tap av liv","freq_lossoflife20170317121849742","https://services.kystverket.no/qgis.ashx?map=15ed376d-ee36-4940-afff-865a9a6a7558","Sjøsikkerhet",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AisApenSanntid12Timer","AIS Åpen sanntid (siste 12 timer)","tracks,trajectories,points,labels_ship_name","https://geomap05.kystverket.no/api/mapserver/a0138177-38d3-4868-b5ea-f8b1d7b8b09c","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AisStykkgodsskipLive","AIS - stykkgodsskip (live)","tracks,trajectories,points,labels_ship_name","https://geomap05.kystverket.no/api/mapserver/5cfc32d5-da6a-41d7-b6d1-d4f9193523ce","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AisSjospeiderne","AIS Sjøspeiderne","tracks,trajectories,points,labels_ship_name_scale_independent","https://geomap05.kystverket.no/api/mapserver/7f7c13c3-5a49-4c35-bfb0-8f82af379d0f","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AisRedningsselskapet","AIS Redningsselskapet","tracks,trajectories,points,labels_ship_name_scale_independent","https://geomap05.kystverket.no/api/mapserver/abfc5500-11d1-49fb-9094-754f6dc6c36a","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AisSar","AIS SAR","tracks,trajectories,points,labels_ship_name","https://geomap05.kystverket.no/api/mapserver/ca0b6107-2669-4335-862e-8fcbed8b35f7","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("Skipstrafikk","Skipstrafikk","ais_raster_3575_6min","https://kart.kystverket.no/proxies/xSkipstrafikkProxy.ashx?map=/etc/mapserver/barentswatch.map&sld=https://kart.barentswatch.no/resx/sld_skipstrafikk_month.xml","Sjøtrafikk og AIS",'© <a href="https://www.kystverket.no/">Kystverket</a>'),y("VardoTrafikksentral","Vardø trafikksentral","layer_426","Sjøtrafikksentraltjenestens hendelser"),y("KvitsoyTrafikksentral","Kvitsøy trafikksentral","layer_427","Sjøtrafikksentraltjenestens hendelser"),y("SkrafotoAustAgder2008","Skråfoto - Aust-Agder - 2008","layer_215","Skråfoto"),y("SkrafotoTroms2008","Skråfoto - Troms - 2008","layer_217","Skråfoto"),y("SkrafotoTroms2005","Skråfoto - Troms - 2005","layer_218","Skråfoto"),y("FritidsfartoyStatligeFartsgrenser","For fritidsfartøy - statlige fartsgrenser på sjøen etter HFL","layer_722","Statlig fartsforskrift etter HFL"),y("NaeringsfartoyStatligeFartsgrenser","For næringsfartøy - statlige fartsgrenser på sjøen etter HFL","layer_723","Statlig fartsforskrift etter HFL"),x("EncFullEcdis","ENC - full ECDIS","cells","https://kart.kystverket.no/proxies/xEncProxy.ashx?STYLES=style-id-260","Bakgrunnskart",'© <a href="https://www.kystverket.no/">Kystverket</a>'),x("AkvakultursoknaderUnderBehandling","Akvakultur søknader under behandling","akvakultursoeknad_under_behandling","https://gis.fiskeridir.no/server/services/fiskeridirWMS_akva/MapServer/WMSServer","Akvakultursøknader"),x("TopografiskWebbkarta","Topografisk webbkarta","terrangskuggning,mark_nedtonad,hydrografi_ytor_nedtonad,kurvor_nedtonad,hydrografi_nedtonad,kommunikation_nedtonad,jarnvag_nedtonad,fjallinformation_nedtonad,kraftledningar_nedtonad,anlaggningar_nedtonad,bebyggelse_nedtonad,bestammelser_nedtonad,administrativ_indelning_nedtonad,adresser_nedtonad,text_nedtonad","https://wms.geonorge.no/skwms1/wms.lantmeteriet_topo","Andre grunnkart"),x("Nedbor1TimesIntervall","Nedbør 1 times intervall","precipitation_1h_regional","https://metmaps.met.no/metmaps/default.map?language=eng","Beredskap"),x("Vind1TimesIntervall","Vind 1 times intervall","wind_10m_regional","https://metmaps.met.no/metmaps/default.map?language=eng","Beredskap"),x("BolgehoydeOgRetning","Bølgehøyde og retning","sea_wave_height_direction_regional","https://bw-wms.met.no/barentswatch/default.map","Beredskap"),x("Dumpefelt","Dumpefelt","dumpefelt_a","https://wms.geonorge.no/skwms1/wms.maritim_infrastruktur?language=eng","Fareområder"),x("Navigasjonsinstallasjoner","Navigasjonsinstallasjoner","Skilt6756,Overettlinje_merke4406,Overettlinje_lys28396,Flytende_merke18756,Fast_sjømerke29168,Racon,Sektorflate,Sektorlinje,IB,Lys37331","https://maps.kystverket.cloudgis.no/enterprise/services/PROD/nfs_sistop_ekstern_prod/MapServer/WMSServer","Farled og merker"),x("AkvakulturFlater","Akvakultur - flater","flate_ihht_akvakulturregisteret","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),x("LaksekartWms","Laksekart WMS","layer_21","https://laksekartogc.statsforvalteren.no/wms.ashx","Fiskeri og havbruk"),x("FiskeplasserAktiveRedskap","Fiskeplasser aktive redskap","fiskeplasser_aktive_redskap","https://gis.fiskeridir.no/server/services/fiskeridirWMS_fiskeri/MapServer/WMSServer","Fiskeri og havbruk"),x("FiskeplasserPassiveRedskap","Fiskeplasser passive redskap","fiskeplasser_passive_redskap","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),x("Lassettingsplasser","Låssettingsplasser","laassettingsplasser","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),x("Gyteomrader","Gyteområder","gyteomraader","https://gis.fiskeridir.no/server/services/fiskeridirWMS_fiskeri/MapServer/WMSServer","Fiskeri og havbruk"),x("GytefeltTorsk","Gytefelt torsk","gytefelt_torsk_mb","https://gis.fiskeridir.no/server/services/fiskeridirWMS_fiskeri/MapServer/WMSServer","Fiskeri og havbruk"),x("NasjonaleLaksefjorder","Nasjonale Laksefjorder","nasjonale_laksefjorder","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),x("NytekPlasseringYtterpunkt","NYTEK plassering-ytterpunkt","nytek_plassering_ytterpunkt","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),x("NytekFortoyningsliner","NYTEK fortøyningsliner","nytek_fortoyningslinjer","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),x("NytekFlateSenterpunkt","NYTEK flåte senterpunkt","nytek_flate_senterpunkt","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),x("NytekFlateFortoyningslinjer","NYTEK flåte fortøyningslinjer","nytek_flate_fortoyningslinjer","https://gis.fiskeridir.no/server/services/fiskeridirWMS/MapServer/WMSServer","Fiskeri og havbruk"),x("ForsvaretsSkyteFeltISjo","Forsvarets skyte- og øvingsfelt i sjø","ovingsfeltsjo","https://wms.geonorge.no/skwms1/wms.ovingsfeltsjo","Grenser og inndelinger"),x("KommuneOgFylkesgrenserWms","Kommune- og fylkesgrenser (WMS)","adm_enheter_V2_WMS","https://wms.geonorge.no/skwms1/wms.adm_enheter2","Grenser og inndelinger"),x("NorgesSjogrenserNavn","Norges sjøgrenser - navn (WMS)","Maritime_grenser_navn","https://wms.geonorge.no/skwms1/wms.nmg","Grenser og inndelinger"),x("NorgesSjogrenser","Norges sjøgrenser","Grunnlinje,1_nautisk_mil,Territorialgrense,Yttergrense_for_tilstotende_sone,Avtalt_avgrensningslinje,200_nautiske_mil,Fiskerigrense,avgrensningslinje_for_sokkel,Sokkelgrense","https://wms.geonorge.no/skwms1/wms.nmg","Grenser og inndelinger"),x("HavneanleggGeonorge","Havneanlegg","havneanlegg","https://wms.geonorge.no/skwms1/wms.havnedata?language=eng","Havnedata"),x("Hoydekoter","Høydekoter","hoydekurver_1m,hoydekurver_5m,hoydetall5linje","https://openwms.statkart.no/skwms1/wms.fkb4","Høydedata"),x("DybdepunktWms","Dybdepunkt (WMS)","Dybdepunkt,grunne,skjaer_punkt","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),x("DybdekonturWms","Dybdekontur (WMS)","Dybdekontur,Torrfall_Grense","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),x("DybdelagWms","Dybdelag (WMS)","Dybdelag,Torrfall","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),x("MaritimInfrastruktur","Maritim infrastruktur","maritim_infrastruktur_wms","https://wms.geonorge.no/skwms1/wms.maritim_infrastruktur?language=eng","Marine grunndata"),x("KystkonturWms","Kystkontur (WMS)","Kystkontur","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),x("KonstruertKystkonturWms","Konstruert kystkontur (WMS)","Konstruertkystkontur","https://wms.geonorge.no/skwms1/wms.dybdedata2","Marine grunndata"),x("MgHavbunnsterreng","MG - Havbunnsterreng (WMS)","Dybde50m,Dybde10m,Dybde2m","https://geo.ngu.no/mapserver/MarineGrunnkartWMS","Marine grunnkart"),x("MgGravbarhet","MG - Gravbarhet (WMS)","Gravbarhet","https://geo.ngu.no/mapserver/MarineGrunnkartWMS","Marine grunnkart"),x("Skyggerelieff","Skyggerelieff","Havbunnraster2_WMS","https://openwms.statkart.no/skwms1/wms.havbunnraster2","Marine grunnkart"),x("MarineGrunnkartDatadekning","Marine grunnkart - datadekning","MG_Datadekning","https://geo.ngu.no/mapserver/MarineGrunnkartWMS","Marine grunnkart"),x("ForvaltningsplanomraderHavomradene","Forvaltningsplanområder for havområdene WMS","forvaltningsplaner_havomrader_omrade","https://kart.miljodirektoratet.no/geoserver/forvaltningsplaner_havomrader/wms?SERVICE=WMS","Natur og Miljø"),x("NaturtyperNin","Naturtyper (NiN)","naturtyper_nin_alle","https://kart.miljodirektoratet.no/arcgis/services/naturtyper_nin/MapServer/WmsServer","Natur og Miljø"),x("MarineNaturtyperDnHandbok19","Marine Naturtyper (DN håndbok 19)","naturtyper_marine_hb19_alle","https://kart.miljodirektoratet.no/arcgis/services/naturtyper_marine_hb19/MapServer/WmsServer","Natur og Miljø"),x("ArterAvNasjonalForvaltningsinteresse","Arter av nasjonal forvaltningsinteresse","Alle_arter_av_sarlig_stor_forv_int_pkt,Alle_arter_av_sarlig_stor_forv_int_omr","https://kart.miljodirektoratet.no/arcgis/services/artnasjonal2/MapServer/WmsServer","Natur og Miljø"),x("Korallrev","Korallrev","korallrev_observert_rev","https://kart.hi.no/mareano/mareano_biologi/korallrev_observert_rev/wms?SERVICE=WMS","Natur og Miljø"),x("Vannlokaliteter","Vannlokaliteter","vannlokaliteter_pol","https://kart.miljodirektoratet.no/arcgis/services/vannmiljo/MapServer/WmsServer","Natur og Miljø"),x("VannforekomsterOkologiskTilstand","Vannforekomster - økologisk tilstand","Oekologisk_tilstand_eller_potensial_kystvann,Oekologisk_tilstand_eller_potensial_innsjoe,Oekologisk_tilstand_eller_potensial_elv","http://vann-nett.no/arcgis/services/WMS/Vannforskriften_TilstandPotensialRisiko_OGC/MapServer/WmsServer","Natur og Miljø"),x("NaturtyperDnHandbok13","Naturtyper (DN håndbok 13)","naturtyper_hb13_alle","https://kart.miljodirektoratet.no/arcgis/services/naturtyper_hb13/MapServer/WmsServer","Natur og Miljø"),x("GrenserOgOmraderPaNorskSokkel","Grenser og områder på norsk sokkel","2,3,1","https://factmaps.sodir.no/api/services/Factmaps/FactMapsED50UTM32/MapServer/WMSServer","Norsk sokkel"),x("FeltPaNorskSokkel","Felt på norsk sokkel","37","https://factmaps.sodir.no/api/services/Factmaps/FactMapsED50UTM32/MapServer/WMSServer","Norsk sokkel"),x("TillatelserPaNorskSokkel","Tillatelser på norsk sokkel","16,22,19,12,14","https://factmaps.sodir.no/api/services/Factmaps/FactMapsED50UTM32/MapServer/WMSServer","Norsk sokkel"),x("BronnbanerPaNorskSokkel","Brønnbaner på norsk sokkel","72,73,74,75,76,77","https://factmaps.sodir.no/api/services/Factmaps/FactMapsED50UTM32/MapServer/WMSServer","Norsk sokkel"),x("DybdedatakvalitetB","Datakvalitet på dybdedata (B)","Dybdedatakvalitet_B","https://wms.geonorge.no/skwms1/wms.dybdedatakvalitet_navigasjon?language=eng","Referansedata"),x("DybdedatakvalitetC","Datakvalitet på dybdedata (C)","Dybdedatakvalitet_C","https://wms.geonorge.no/skwms1/wms.dybdedatakvalitet_navigasjon?language=eng","Referansedata"),x("DybdedatakvalitetD","Datakvalitet på dybdedata (D)","Dybdedatakvalitet_D","https://wms.geonorge.no/skwms1/wms.dybdedatakvalitet_navigasjon?language=eng","Referansedata"),x("DybdedatakvalitetU","Datakvalitet på dybdedata (U)","Dybdedatakvalitet_U","https://wms.geonorge.no/skwms1/wms.dybdedatakvalitet_navigasjon?language=eng","Referansedata")],de={light:{primary:{baseDefault:"#000667"},accent:{borderDefault:"#df3c1b",baseDefault:"#FF451F",baseHover:"#ff7559"},neutral:{backgroundDefault:"#ffffff",textDefault:"#2a2b35"}}}.light,pe=e=>e;function Vt(e,t){const r=e.replace("#",""),s=r.length===3?r.split("").map(u=>u+u).join(""):r,a=parseInt(s.slice(0,2),16),d=parseInt(s.slice(2,4),16),p=parseInt(s.slice(4,6),16);return`rgba(${a}, ${d}, ${p}, ${t})`}const J=pe(de.accent.baseDefault),ge=pe(de.neutral.backgroundDefault),Be=.2,Er=pe(de.accent.borderDefault),Cr=pe(de.accent.baseHover),_t=pe(de.primary.baseDefault),$t=_t,Ht=Be,Rt=pe(de.accent.borderDefault),Gt=pe(de.primary.baseDefault),Kt=pe(de.neutral.textDefault),Ut=pe(de.neutral.backgroundDefault),jr=pe(de.accent.borderDefault),we=pe(de.primary.baseDefault),Yt=pe(de.neutral.backgroundDefault),Me="#0062ba",qt=Vt(Me,.4),zt=Vt(Me,.5),Zt="#ff0000",Mr="#b0b0b0",bt="#088";function xr(e){return"include"in e}function Jt(e,t){return t?xr(t)?t.include.includes(e):!t.exclude.includes(e):!0}function Tr(e){const t={id:e.id,label:e.label,category:e.category,defaultVisible:e.defaultVisible??!0,metadata:e.metadata},r=`custom-${e.id}`;switch(e.type){case"geojson":return{...t,sources:{[r]:{type:"geojson",data:e.data}},layers:[{id:`${r}-fill`,type:"fill",source:r,paint:{"fill-color":e.fillColor??$t,"fill-opacity":e.fillOpacity??Ht},filter:["==","$type","Polygon"]},{id:`${r}-line`,type:"line",source:r,paint:{"line-color":e.lineColor??_t,"line-width":2},filter:["==","$type","LineString"]},{id:`${r}-circle`,type:"circle",source:r,paint:{"circle-color":e.pointColor??Rt,"circle-radius":5,"circle-stroke-color":Gt,"circle-stroke-width":1},filter:["==","$type","Point"]}]};case"wms":return{...t,sources:{[r]:{type:"raster",tiles:[e.url],tileSize:256,attribution:e.attribution}},layers:[{id:`${r}-raster`,type:"raster",source:r}]};case"vector-tiles":{const s=e.renderAs??"fill",a={id:`${r}-${s}`,type:s,source:r,"source-layer":e.sourceLayer};return s==="fill"?a.paint={"fill-color":e.color??bt}:s==="line"?a.paint={"line-color":e.color??bt,"line-width":2}:a.paint={"circle-color":e.color??bt,"circle-radius":5},{...t,sources:{[r]:{type:"vector",tiles:[e.url]}},layers:[a]}}}}const Fr={availableLayers:[],visibleLayerIds:new Set,toggleLayer:()=>{},showLayer:()=>{},hideLayer:()=>{},isVisible:()=>!1},Je=n.createContext(Fr),Ir=({children:e,include:t,exclude:r})=>{const s=n.useMemo(()=>{if(t)return{include:t};if(r)return{exclude:r}},[t,r]),a=n.useMemo(()=>Wt.filter(h=>Jt(h.id,s)),[s]),[d,p]=n.useState(()=>new Set(a.filter(h=>h.defaultVisible!==!1).map(h=>h.id))),u=n.useCallback(h=>{p(o=>{const k=new Set(o);return k.has(h)?k.delete(h):k.add(h),k})},[]),c=n.useCallback(h=>{p(o=>{if(o.has(h))return o;const k=new Set(o);return k.add(h),k})},[]),g=n.useCallback(h=>{p(o=>{if(!o.has(h))return o;const k=new Set(o);return k.delete(h),k})},[]),L=n.useCallback(h=>d.has(h),[d]),T=n.useMemo(()=>({availableLayers:a,visibleLayerIds:d,toggleLayer:u,showLayer:c,hideLayer:g,isVisible:L}),[a,d,u,c,g,L]);return l.jsx(Je.Provider,{value:T,children:e})},Ar={layers:[],visibleLayerIds:new Set,addLayer:()=>{},removeLayer:()=>{},toggleLayer:()=>{},showLayer:()=>{},hideLayer:()=>{},isVisible:()=>!1},Xe=n.createContext(Ar),Or=({children:e,initialLayers:t})=>{const[r,s]=n.useState(()=>t??[]),[a,d]=n.useState(()=>new Set((t??[]).filter(o=>o.defaultVisible!==!1).map(o=>o.id))),p=n.useCallback(o=>{s(k=>k.some(b=>b.id===o.id)?k:[...k,o]),o.defaultVisible!==!1&&d(k=>{if(k.has(o.id))return k;const b=new Set(k);return b.add(o.id),b})},[]),u=n.useCallback(o=>{s(k=>{const b=k.filter(F=>F.id!==o);return b.length===k.length?k:b}),d(k=>{if(!k.has(o))return k;const b=new Set(k);return b.delete(o),b})},[]),c=n.useCallback(o=>{d(k=>{const b=new Set(k);return b.has(o)?b.delete(o):b.add(o),b})},[]),g=n.useCallback(o=>{d(k=>{if(k.has(o))return k;const b=new Set(k);return b.add(o),b})},[]),L=n.useCallback(o=>{d(k=>{if(!k.has(o))return k;const b=new Set(k);return b.delete(o),b})},[]),T=n.useCallback(o=>a.has(o),[a]),h=n.useMemo(()=>({layers:r,visibleLayerIds:a,addLayer:p,removeLayer:u,toggleLayer:c,showLayer:g,hideLayer:L,isVisible:T}),[r,a,p,u,c,g,L,T]);return l.jsx(Xe.Provider,{value:h,children:e})},Pr={loading:!1,error:null,layers:[],visibleLayerIds:new Set,baseUrl:"",catalogEntries:[],toggleLayer:()=>{},showLayer:()=>{},hideLayer:()=>{},isVisible:()=>!1},We=n.createContext(Pr);function Nr(e){var p,u;const r=new DOMParser().parseFromString(e,"text/xml");if(r.querySelector("parsererror"))throw new Error("Failed to parse WMS GetCapabilities XML");const a=[],d=r.querySelectorAll("Layer > Layer");for(const c of d){const g=c.querySelector(":scope > Name"),L=c.querySelector(":scope > Title"),T=(p=g==null?void 0:g.textContent)==null?void 0:p.trim(),h=(u=L==null?void 0:L.textContent)==null?void 0:u.trim();T&&a.push({name:T,title:h||T})}return a}function Dr(e,t,r){const s=`wms-catalog-${e.name}`,a=`wms-cat-${e.name}`,d=t.includes("?")?"&":"?",p={SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetMap",LAYERS:e.name,STYLES:"",CRS:"EPSG:3857",BBOX:"{bbox-epsg-3857}",EXCEPTIONS:"XML",WIDTH:"256",HEIGHT:"256",FORMAT:"image/png",TRANSPARENT:"TRUE"};return{id:s,label:e.title,category:"WMS-katalog",defaultVisible:!1,sources:{[a]:{type:"raster",tiles:[`${t}${d}`+Object.entries(p).map(([u,c])=>`${u}=${c}`).join("&")],tileSize:256,attribution:r}},layers:[{id:`${a}-raster`,type:"raster",source:a}]}}function Br(e){const t=new URL(e);return t.searchParams.delete("service"),t.searchParams.delete("SERVICE"),t.searchParams.delete("request"),t.searchParams.delete("REQUEST"),t.searchParams.delete("version"),t.searchParams.delete("VERSION"),t.toString().replace(/[?&]$/,"")}const Wr=({children:e,capabilitiesUrl:t,attribution:r})=>{const[s,a]=n.useState(!0),[d,p]=n.useState(null),[u,c]=n.useState([]),[g,L]=n.useState(new Set),T=n.useMemo(()=>Br(t),[t]);n.useEffect(()=>{let P=!1;return a(!0),p(null),fetch(t).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}: ${_.statusText}`);return _.text()}).then(_=>{if(P)return;const $=Nr(_);c($),a(!1)}).catch(_=>{P||(p(_ instanceof Error?_.message:String(_)),a(!1))}),()=>{P=!0}},[t]);const h=n.useMemo(()=>u.map(P=>Dr(P,T,r)),[u,T,r]),o=n.useCallback(P=>{L(_=>{const $=new Set(_);return $.has(P)?$.delete(P):$.add(P),$})},[]),k=n.useCallback(P=>{L(_=>{if(_.has(P))return _;const $=new Set(_);return $.add(P),$})},[]),b=n.useCallback(P=>{L(_=>{if(!_.has(P))return _;const $=new Set(_);return $.delete(P),$})},[]),F=n.useCallback(P=>g.has(P),[g]),O=n.useMemo(()=>({loading:s,error:d,layers:h,visibleLayerIds:g,baseUrl:T,catalogEntries:u,toggleLayer:o,showLayer:k,hideLayer:b,isVisible:F}),[s,d,h,g,T,u,o,k,b,F]);return l.jsx(We.Provider,{value:O,children:e})};function St({initialCoordinate:e,disabled:t=!1,onMapClick:r,height:s,showZoomControls:a=!0}={}){const d=n.useRef(null),p=n.useRef(null),u=n.useRef(0),[c,g]=n.useState(0),L=c>0,{viewBounds:T,defaultBounds:h}=n.useContext(vt),o=n.useContext(Ze),k=n.useContext(Je),b=n.useContext(Xe),F=n.useContext(We),O=n.useRef(t);n.useEffect(()=>{O.current=t},[t]);const P=n.useRef(r);P.current=r,n.useEffect(()=>{if(!L)return;const j=p.current;j&&(t?(j.dragPan.disable(),j.scrollZoom.disable(),j.boxZoom.disable(),j.dragRotate.disable(),j.keyboard.disable(),j.doubleClickZoom.disable(),j.touchZoomRotate.disable()):(j.dragPan.enable(),j.scrollZoom.enable(),j.boxZoom.enable(),j.dragRotate.enable(),j.keyboard.enable(),j.doubleClickZoom.enable(),j.touchZoomRotate.enable()))},[t,c]),n.useEffect(()=>{d.current&&(d.current.style.height=s??"")},[s]),n.useEffect(()=>{const j=d.current;if(!j||p.current||typeof document>"u"||typeof window>"u")return;const C=()=>{if(p.current)return;const E=o.availableBaseLayers.find(R=>R.id===o.activeBaseLayerId),S={...Dt,sources:E?{...E.sources}:{},layers:E?[...E.layers]:[]},A={container:j,style:S,attributionControl:{}};e?(A.center=[e.longitude,e.latitude],A.zoom=14):(A.bounds=h,A.fitBoundsOptions={padding:20});const B=new Pe.Map(A);a&&B.addControl(new Pe.NavigationControl({showCompass:!1}),"bottom-right"),_.current=E??null,p.current=B,u.current+=1,g(u.current),B.on("click",R=>{var m;if(O.current)return;const{lng:z,lat:K}=R.lngLat;(m=P.current)==null||m.call(P,{latitude:gt(Ye(K),6),longitude:gt(qe(z),6)})})},I=()=>{const E=p.current;if(!E)return;const S=E.getCanvas(),A=(S==null?void 0:S.getContext("webgl2"))??(S==null?void 0:S.getContext("webgl")),B=A==null?void 0:A.getExtension("WEBGL_lose_context");E.remove(),B==null||B.loseContext(),p.current=null,g(0),_.current=null,$.current=new Set},v=j.getBoundingClientRect(),D=window.innerHeight||document.documentElement.clientHeight,W=window.innerWidth||document.documentElement.clientWidth;if(v.bottom>0&&v.right>0&&v.top<D&&v.left<W)return C(),I;const w=new IntersectionObserver(E=>{E[0].isIntersecting&&(w.disconnect(),C())},{threshold:0});return w.observe(j),()=>{w.disconnect(),I()}},[]),n.useEffect(()=>{if(!L)return;const j=p.current;if(!j||!T||T.length===0)return;const C=T.flat();if(C.length===0)return;let I=1/0,v=-1/0,D=1/0,W=-1/0;for(const[f,w]of C)f<I&&(I=f),f>v&&(v=f),w<D&&(D=w),w>W&&(W=w);j.fitBounds([[I,D],[v,W]],{padding:20,duration:300})},[T,c]);const _=n.useRef(null);n.useEffect(()=>{if(!L)return;const j=p.current;if(!j)return;const C=()=>{var D,W;const I=o.availableBaseLayers.find(f=>f.id===o.activeBaseLayerId),v=_.current;if((v==null?void 0:v.id)!==(I==null?void 0:I.id)){if(v&&Xt(j,v),I){const f=(W=(D=j.getStyle().layers)==null?void 0:D[0])==null?void 0:W.id;for(const[w,E]of Object.entries(I.sources))j.getSource(w)||j.addSource(w,E);for(const w of I.layers)j.getLayer(w.id)||j.addLayer(w,f)}_.current=I??null}};return j.loaded()?C():j.once("load",C),()=>{j.off("load",C)}},[o.activeBaseLayerId,o.availableBaseLayers,c]);const $=n.useRef(new Set);return n.useEffect(()=>{if(!L)return;const j=p.current;if(!j)return;const C=()=>{const I=[...k.availableLayers,...b.layers,...F.layers],v=new Set([...k.visibleLayerIds,...b.visibleLayerIds,...F.visibleLayerIds]),D=new Set(I.map(f=>f.id)),W=$.current;for(const f of W)if(!D.has(f)){const w=Vr(f,I);w&&Xt(j,w),W.delete(f)}for(const f of I){const w=W.has(f.id),E=v.has(f.id);if(w)for(const S of f.layers)j.getLayer(S.id)&&j.setLayoutProperty(S.id,"visibility",E?"visible":"none");else{for(const[S,A]of Object.entries(f.sources))j.getSource(S)||j.addSource(S,A);for(const S of f.layers)j.getLayer(S.id)||j.addLayer(S),j.setLayoutProperty(S.id,"visibility",E?"visible":"none");W.add(f.id)}}};return j.loaded()?C():j.once("load",C),()=>{j.off("load",C)}},[k.availableLayers,k.visibleLayerIds,b.layers,b.visibleLayerIds,F.layers,F.visibleLayerIds,c]),n.useEffect(()=>{if(!L)return;const j=p.current;if(!j)return;const C=()=>{j.getSource("easter-egg-src")||(j.addSource("easter-egg-src",{type:"geojson",data:$r}),j.addLayer({id:"easter-egg-fill",type:"fill",source:"easter-egg-src",minzoom:16,paint:{"fill-color":["get","fill"],"fill-opacity":.85}}),j.addLayer({id:"easter-egg-outline",type:"line",source:"easter-egg-src",minzoom:16,paint:{"line-color":["get","stroke"],"line-width":2}}))};j.loaded()?C():j.once("load",C)},[c]),{mapContainerRef:d,mapRef:p,mapReady:L,mapVersion:c}}function Vr(e,t){return t.find(r=>r.id===e)}function Xt(e,t){for(const r of t.layers)e.getLayer(r.id)&&e.removeLayer(r.id);for(const r of Object.keys(t.sources))e.getSource(r)&&e.removeSource(r)}const $r={type:"FeatureCollection",features:[{type:"Feature",properties:{fill:"#8B4513",stroke:"#5C2D0A"},geometry:{type:"Polygon",coordinates:[[[10.9501935,59.2167004],[10.9501427,59.2167364],[10.950092,59.2167544],[10.9500666,59.2167567],[10.9500412,59.2167544],[10.9499905,59.2167364],[10.9499397,59.2167004],[10.9497705,59.2165504],[10.949735,59.2165099],[10.9497299,59.2164784],[10.9497388,59.216466],[10.9497553,59.2164559],[10.9498111,59.2164424],[10.9498974,59.2164379],[10.9502358,59.2164379],[10.9503221,59.2164424],[10.9503779,59.2164559],[10.9503944,59.216466],[10.9504033,59.2164784],[10.9503982,59.2165099],[10.9503627,59.2165504],[10.9501935,59.2167004]]]}},{type:"Feature",properties:{fill:"#E8466A",stroke:"#A1203E"},geometry:{type:"Polygon",coordinates:[[[6.1024125,62.4597089],[6.1023617,62.4597449],[6.102311,62.4597629],[6.1022856,62.4597652],[6.1022602,62.4597629],[6.1022095,62.4597449],[6.1021587,62.4597089],[6.1019895,62.4595589],[6.101954,62.4595184],[6.1019489,62.4594869],[6.1019578,62.4594745],[6.1019743,62.4594644],[6.1020301,62.4594509],[6.1021164,62.4594464],[6.1024548,62.4594464],[6.1025411,62.4594509],[6.1025969,62.4594644],[6.1026134,62.4594745],[6.1026223,62.4594869],[6.1026172,62.4595184],[6.1025817,62.4595589],[6.1024125,62.4597089]]]}}]};function Qt(e,t,r,s,a){const d=Math.round((r.longitude-s.west)/(s.east-s.west)*a.width),p=Math.round((s.north-r.latitude)/(s.north-s.south)*a.height),u={SERVICE:"WMS",VERSION:"1.3.0",REQUEST:"GetFeatureInfo",LAYERS:t,QUERY_LAYERS:t,CRS:"EPSG:4326",BBOX:`${s.south},${s.west},${s.north},${s.east}`,WIDTH:String(a.width),HEIGHT:String(a.height),INFO_FORMAT:"text/html",I:String(d),J:String(p),FEATURE_COUNT:"10"},c=e.includes("?")?"&":"?",g=Object.entries(u).map(([L,T])=>`${L}=${encodeURIComponent(T)}`).join("&");return`${e}${c}${g}`}async function Hr(e,t,r,s,a,d,p){const u=Qt(e,r,s,a,d);try{const c=await fetch(u,{signal:p});if(!c.ok)return{layerId:t,layerName:r,html:""};const g=await c.text();return{layerId:t,layerName:r,html:g}}catch{return{layerId:t,layerName:r,html:""}}}function Lt({mapRef:e,coordinate:t,enabled:r=!0}){const{baseUrl:s,catalogEntries:a,visibleLayerIds:d}=n.useContext(We),[p,u]=n.useState(!1),[c,g]=n.useState(null),L=n.useRef(null);return n.useEffect(()=>{var P;if((P=L.current)==null||P.abort(),L.current=null,!r||!t||!s)return;const T=e.current;if(!T)return;const h=a.filter(_=>d.has(`wms-catalog-${_.name}`));if(console.log("Visible WMS catalog entries:",h,a),h.length===0){g({coordinate:t,layerResults:[]});return}const o=T.getBounds(),k={west:o.getWest(),south:o.getSouth(),east:o.getEast(),north:o.getNorth()},b=T.getCanvas(),F={width:b.width,height:b.height},O=new AbortController;return L.current=O,u(!0),Promise.all(h.map(_=>Hr(s,`wms-catalog-${_.name}`,_.name,t,k,F,O.signal))).then(_=>{O.signal.aborted||g({coordinate:t,layerResults:_})}).finally(()=>{O.signal.aborted||u(!1)}),()=>{O.abort()}},[t,r,s,a,d,e]),{loading:p,result:c}}function wt(e){let t=1/0,r=-1/0,s=1/0,a=-1/0,d=!1;function p(u){if(Array.isArray(u))if(typeof u[0]=="number"&&typeof u[1]=="number"){const[c,g]=u;c<t&&(t=c),c>r&&(r=c),g<s&&(s=g),g>a&&(a=g),d=!0}else for(const c of u)p(c)}for(const u of e.features)u.geometry&&"coordinates"in u.geometry&&p(u.geometry.coordinates);return d?[t,s,r,a]:null}const Rr={fillColor:$t,fillOpacity:Ht,lineColor:_t,lineWidth:2,pointRadius:6,pointColor:Rt,pointStrokeColor:Gt,pointStrokeWidth:2},oe="geojson-data",Qe="geojson-fill",et="geojson-line",Et="geojson-point-stroke",tt="geojson-point",Gr=[tt,Et,et,Qe],rt="geojson-hover-fill",nt="geojson-hover-line",st="geojson-hover-point",ot="geojson-selected-fill",at="geojson-selected-line",it="geojson-selected-point",Kr=[rt,nt,st,ot,at,it],Ur=[Qe,et,tt],lt="geojson-label";function ve(e,t){return["coalesce",["get",e],t]}function ct(e){return e.type==="FeatureCollection"?{type:"FeatureCollection",features:e.features}:{type:"FeatureCollection",features:[e]}}function Yr(e){try{for(const t of[...Gr,...Kr])e.getLayer(t)&&e.removeLayer(t);e.getSource(oe)&&e.removeSource(oe)}catch{}}function qr(e,t){e.getLayer(rt)||e.addLayer({id:rt,type:"fill",source:oe,layout:{visibility:"visible"},paint:{"fill-color":qt,"fill-opacity":.5},filter:["==",["get","__hover"],!0]}),e.getLayer(nt)||e.addLayer({id:nt,type:"line",source:oe,layout:{visibility:"visible"},paint:{"line-color":Me,"line-width":t.lineWidth+2,"line-opacity":.6},filter:["==",["get","__hover"],!0]}),e.getLayer(st)||e.addLayer({id:st,type:"circle",source:oe,layout:{visibility:"visible"},paint:{"circle-radius":t.pointRadius+4,"circle-color":qt,"circle-opacity":.6},filter:["==",["get","__hover"],!0]}),e.getLayer(ot)||e.addLayer({id:ot,type:"line",source:oe,layout:{visibility:"visible"},paint:{"line-color":Me,"line-width":4,"line-blur":3,"line-opacity":.8},filter:["==",["get","__selected"],!0]}),e.getLayer(at)||e.addLayer({id:at,type:"line",source:oe,layout:{visibility:"visible"},paint:{"line-color":Me,"line-width":t.lineWidth+4,"line-blur":3,"line-opacity":.8},filter:["==",["get","__selected"],!0]}),e.getLayer(it)||e.addLayer({id:it,type:"circle",source:oe,layout:{visibility:"visible"},paint:{"circle-radius":t.pointRadius+6,"circle-color":zt,"circle-blur":.5,"circle-opacity":.9},filter:["==",["get","__selected"],!0]})}function zr(e,t){const r=t!==null?["==",["id"],t]:["==",["get","__hover"],!0];for(const s of[rt,nt,st])e.getLayer(s)&&e.setFilter(s,r)}function Zr(e,t){const r=t.length>0?["in",["id"],["literal",t]]:["==",["get","__selected"],!0];for(const s of[ot,at,it])e.getLayer(s)&&e.setFilter(s,r)}function er(e,t){let r;switch(e.type){case"Point":case"MultiPoint":r="point";break;case"LineString":case"MultiLineString":r="linestring";break;case"Polygon":case"MultiPolygon":r="polygon";break}return r&&t.includes(r)?r:"static"}function Jr({mapRef:e,mapVersion:t,modes:r,editable:s,deletable:a,disabled:d,singleFeature:p=!1,onChange:u,onSelect:c}){const g=n.useRef(null),[L,T]=n.useState("static"),[h,o]=n.useState(!1),[k,b]=n.useState([]),[F,O]=n.useState(!1),P=n.useRef(!1),_=n.useRef(u);_.current=u;const $=n.useRef(c);$.current=c;const j=n.useRef(p);j.current=p;const C=n.useRef(r);C.current=r;const I=n.useCallback(()=>{const E=g.current;if(!E||!_.current)return;P.current=!0;const B={type:"FeatureCollection",features:E.getSnapshot().filter(R=>{var z;return((z=R.properties)==null?void 0:z.mode)!=="select"}).map(({id:R,geometry:z,properties:K})=>({type:"Feature",...R!=null?{id:R}:{},geometry:z,properties:{...K}}))};_.current(B)},[]);n.useEffect(()=>{const E=e.current;if(!E||!t||d)return;const S=()=>{if(g.current)return;const B=r.map(K=>{switch(K){case"point":return new je.TerraDrawPointMode({styles:{pointColor:J,pointWidth:6,pointOutlineColor:ge,pointOutlineWidth:3}});case"linestring":return new je.TerraDrawLineStringMode({styles:{lineStringColor:J,lineStringWidth:4,closingPointColor:J,closingPointOutlineColor:ge,closingPointOutlineWidth:2,closingPointWidth:5,snappingPointColor:J,snappingPointOutlineColor:ge,snappingPointOutlineWidth:2,snappingPointWidth:5,coordinatePointColor:J,coordinatePointOutlineColor:ge,coordinatePointOutlineWidth:2,coordinatePointWidth:5}});case"polygon":return new je.TerraDrawPolygonMode({styles:{fillColor:J,fillOpacity:Be,outlineColor:J,outlineWidth:4,closingPointColor:J,closingPointOutlineColor:ge,closingPointOutlineWidth:2,closingPointWidth:5,snappingPointColor:J,snappingPointOutlineColor:ge,snappingPointOutlineWidth:2,snappingPointWidth:5,editedPointColor:J,editedPointOutlineColor:ge,editedPointOutlineWidth:2,editedPointWidth:5,coordinatePointColor:J,coordinatePointOutlineColor:ge,coordinatePointOutlineWidth:2,coordinatePointWidth:5}})}});s&&B.push(new je.TerraDrawSelectMode({styles:{selectedPointColor:J,selectedPointWidth:6,selectedPointOutlineColor:Zt,selectedPointOutlineWidth:3,selectedLineStringColor:J,selectedLineStringWidth:4,selectedPolygonColor:J,selectedPolygonFillOpacity:Be,selectedPolygonOutlineColor:J,selectedPolygonOutlineWidth:4,selectionPointColor:Er,selectionPointOutlineColor:Zt,selectionPointOutlineWidth:2,midPointColor:Cr,midPointOutlineColor:ge,midPointOutlineWidth:2},flags:{point:{feature:{draggable:!0}},linestring:{feature:{draggable:!0,coordinates:{midpoints:!0,draggable:!0,deletable:!0}}},polygon:{feature:{draggable:!0,coordinates:{midpoints:!0,draggable:!0,deletable:!0}}}}})),B.push(new je.TerraDrawRenderMode({modeName:"static",styles:{pointColor:J,pointWidth:6,pointOutlineColor:ge,pointOutlineWidth:3,lineStringColor:J,lineStringWidth:4,polygonFillColor:J,polygonFillOpacity:Be,polygonOutlineColor:J,polygonOutlineWidth:4}}));const R=new je.TerraDraw({adapter:new pr.TerraDrawMapLibreGLAdapter({map:E}),modes:B});R.start();const z=p&&r.length>0?r[0]:"static";R.setMode(z),T(z),R.on("change",()=>{const K=R.getMode();K==="linestring"||K==="polygon"||I()}),R.on("finish",K=>{j.current&&r.length>0?Promise.resolve().then(()=>{const m=g.current;if(!m)return;const N=m.getSnapshot().filter(G=>{var fe,ke,q,ie;return((fe=G.properties)==null?void 0:fe.mode)!=="select"&&!((ke=G.properties)!=null&&ke.closingPoint)&&!((q=G.properties)!=null&&q.snappingPoint)&&!((ie=G.properties)!=null&&ie.coordinatePoint)&&G.id!==K}).map(G=>G.id);if(N.length>0)try{m.removeFeatures(N)}catch{}I();const V=r[0];m.getMode()!==V&&(m.setMode(V),T(V))}):I()}),R.on("select",()=>{var i;o(!0);const m=R.getSnapshot().filter(N=>{var V;return((V=N.properties)==null?void 0:V.selected)===!0}).map(({id:N,geometry:V,properties:G})=>({type:"Feature",...N!=null?{id:N}:{},geometry:V,properties:{...G}}));b(m),(i=$.current)==null||i.call($,m.length>0?m:null)}),R.on("deselect",()=>{var K;o(!1),b([]),(K=$.current)==null||K.call($,null)}),g.current=R,O(!0)};let A=null;return E.getStyle()?S():(A=()=>{g.current||S()},E.once("load",A)),()=>{A&&E.off("load",A);const B=g.current;if(B){try{B.stop()}catch{}g.current=null,P.current=!1,O(!1)}}},[e,t,d,r,s,p,I]);const v=n.useCallback(E=>{const S=g.current;if(!S)return;const B=S.getSnapshot().filter(K=>{var m,i,N,V;return((m=K.properties)==null?void 0:m.mode)!=="select"&&!((i=K.properties)!=null&&i.closingPoint)&&!((N=K.properties)!=null&&N.snappingPoint)&&!((V=K.properties)!=null&&V.coordinatePoint)}).map(K=>K.id);if(B.length>0)try{S.removeFeatures(B)}catch{}if(P.current=!1,!E||E.features.length===0)return;const z=ct(E).features.map(K=>({...K,properties:{...K.properties,mode:er(K.geometry,C.current)}}));try{S.addFeatures(z),P.current=!0}catch(K){console.error("[GeoJsonEditor] Error replacing features:",K)}},[]),D=n.useCallback(E=>{const S=g.current;if(!S||!E||P.current)return;const A=ct(E);if(A.features.length===0)return;const B=A.features.map(R=>({...R,properties:{...R.properties,mode:er(R.geometry,C.current)}}));try{S.addFeatures(B),P.current=!0}catch(R){console.error("[GeoJsonEditor] Error loading initial features:",R)}},[]),W=n.useCallback(E=>{const S=g.current;if(S)try{S.setMode(E),T(E)}catch(A){console.error("[GeoJsonEditor] Error setting mode:",A)}},[]),f=n.useCallback(()=>{var B;const E=g.current;if(!E||!a)return;const A=E.getSnapshot().filter(R=>{var z;return((z=R.properties)==null?void 0:z.selected)===!0});if(A.length>0){const R=A.map(z=>z.id);E.removeFeatures(R),o(!1),b([]),(B=$.current)==null||B.call($,null),I()}},[a,I]),w=n.useCallback(()=>{const E=g.current;return E?E.getSnapshot().filter(A=>{var B;return((B=A.properties)==null?void 0:B.mode)!=="select"}).map(({id:A,geometry:B,properties:R})=>({type:"Feature",...A!=null?{id:A}:{},geometry:B,properties:{...R}})):[]},[]);return{activeMode:L,setActiveMode:W,deleteSelected:f,hasSelection:h,selectedFeatures:k,getSnapshot:w,isReady:F,loadInitialData:D,replaceFeatures:v}}const Xr=(()=>{const e=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
24
24
|
<circle cx="12" cy="12" r="11" fill="${Yt}" stroke="${we}" stroke-width="1.5" opacity="0.9"/>
|
|
25
25
|
<path d="M12 4l-2.5 3h5L12 4z" fill="${we}"/>
|
|
26
26
|
<path d="M12 20l2.5-3h-5L12 20z" fill="${we}"/>
|
|
@@ -30,6 +30,6 @@ React keys must be passed directly to JSX without using spread:
|
|
|
30
30
|
</svg>`;return"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(e)})();function Qr(e=jr,t=we){return`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
|
|
31
31
|
<circle cx="20" cy="20" r="18" fill="${Yt}" stroke="${t}" stroke-width="2"/>
|
|
32
32
|
<polygon points="20,4 25,19 20,17 15,19" fill="${e}"/>
|
|
33
|
-
<polygon points="20,36 15,21 20,23 25,21" fill="${
|
|
33
|
+
<polygon points="20,36 15,21 20,23 25,21" fill="${Mr}"/>
|
|
34
34
|
<circle cx="20" cy="20" r="2.5" fill="${e}"/>
|
|
35
|
-
</svg>`}const tr=35,rr=12,nr=50;function ut(e,t,r){const s=r*Math.PI/180;e.style.transform=`rotate(${r}deg)`,t.style.left=`${nr+Math.sin(s)*tr-rr}px`,t.style.top=`${nr-Math.cos(s)*tr-rr}px`}function sr(){const e=document.createElement("div");e.style.width="100px",e.style.height="100px",e.style.pointerEvents="none";const t=document.createElement("div");t.innerHTML=Qr(),t.style.position="absolute",t.style.left="30px",t.style.top="30px",t.style.width="40px",t.style.height="40px",t.style.cursor="grab",t.style.pointerEvents="auto",e.appendChild(t);const r=document.createElement("img");return r.src=Xr,r.width=24,r.height=24,r.style.position="absolute",r.style.cursor="grab",r.style.userSelect="none",r.style.pointerEvents="auto",r.draggable=!1,e.appendChild(r),{container:e,compass:t,handle:r}}const en=`0 0 0 3px ${zt}`,tn="none";function Ct(e,t){const r=e.querySelector("div");r&&(r.style.outline=t?`2px solid ${xe}`:"none",r.style.outlineOffset=t?"2px":"",r.style.borderRadius=t?"50%":"",r.style.boxShadow=t?en:tn)}function rn({mapRef:e,mapReady:t,disabled:r,activeMode:s,singleFeature:a=!1,onChange:d,onSelect:p}){const u=n.useRef([]),c=n.useRef([]),[g,L]=n.useState(null),T=n.useRef(null),h=n.useRef(!1),o=n.useRef(s);o.current=s;const k=n.useRef(r);k.current=r;const b=n.useRef(d);b.current=d;const F=n.useRef(p);F.current=p,T.current=g;const O=n.useRef(a);O.current=a;const P=n.useCallback(f=>{const w=e.current;if(!w||typeof document>"u")return;const{container:E,compass:S,handle:A}=sr(),[B,R]=f.geometry.coordinates,z=f.properties.direction??0;ut(S,A,z);let K=!1,m=null,i=null,N=!1;const V=()=>u.current.find(Y=>Y.properties.id===f.properties.id),G=Y=>{const Q=V();if(!w||!Q)return 0;const[Ee,Ce]=Q.geometry.coordinates,ce=w.project([Ee,Ce]),re=w.getContainer().getBoundingClientRect(),be=Y.clientX-re.left,Ae=Y.clientY-re.top,Se=be-ce.x,Ft=ce.y-Ae;return Ue(Math.atan2(Se,Ft)*180/Math.PI)},fe=Y=>{if(k.current)return;N=!0,Y.currentTarget.setPointerCapture(Y.pointerId),Y.stopPropagation(),Y.preventDefault(),_(f.properties.id);const Q=Math.round(G(Y));$(f.properties.id,Q)},ke=Y=>{if(!N)return;const Q=Math.round(G(Y));$(f.properties.id,Q)},q=Y=>{var Q;N&&(N=!1,Y.currentTarget.releasePointerCapture(Y.pointerId),Y.stopPropagation(),Y.preventDefault(),(Q=b.current)==null||Q.call(b))},ie=Y=>{if(k.current)return;Y.stopPropagation(),Y.preventDefault(),_(f.properties.id),K=!0,Y.currentTarget.setPointerCapture(Y.pointerId);const Q=w.getContainer().getBoundingClientRect(),Ee=Y.clientX-Q.left,Ce=Y.clientY-Q.top;m=w.unproject([Ee,Ce]);const ce=V();ce&&(i=[ce.geometry.coordinates[0],ce.geometry.coordinates[1]]),w.dragPan.disable()},me=Y=>{if(!K||!m||!i)return;const Q=w.getContainer().getBoundingClientRect(),Ee=Y.clientX-Q.left,Ce=Y.clientY-Q.top,ce=w.unproject([Ee,Ce]),re=ce.lng-m.lng,be=ce.lat-m.lat,Ae=i[0]+re,Se=i[1]+be;j(f.properties.id,Ae,Se)},Fe=Y=>{var Q;K&&(K=!1,m=null,i=null,Y.currentTarget.releasePointerCapture(Y.pointerId),Y.stopPropagation(),Y.preventDefault(),w.dragPan.enable(),(Q=b.current)==null||Q.call(b))},Ie=Y=>{Y.stopPropagation()};A.addEventListener("pointerdown",fe),A.addEventListener("pointermove",ke),A.addEventListener("pointerup",q),A.addEventListener("mousedown",Ie),A.addEventListener("click",Ie),S.addEventListener("pointerdown",ie),S.addEventListener("pointermove",me),S.addEventListener("pointerup",Fe),S.addEventListener("mousedown",Ie),S.addEventListener("click",Ie);const ft=new Pe.Marker({element:E,anchor:"center"}).setLngLat([B,R]).addTo(w),le={featureId:f.properties.id,marker:ft,compass:S,handle:A,container:E};c.current.push(le)},[e]),_=n.useCallback(f=>{var A;const w=T.current;if(w){const B=c.current.find(R=>R.featureId===w);B&&Ct(B.container,!1)}L(f);const E=c.current.find(B=>B.featureId===f);E&&Ct(E.container,!0);const S=u.current.find(B=>B.properties.id===f);(A=F.current)==null||A.call(F,S??null)},[]),$=n.useCallback((f,w)=>{u.current=u.current.map(S=>S.properties.id===f?{...S,properties:{...S.properties,direction:w}}:S);const E=c.current.find(S=>S.featureId===f);E&&ut(E.compass,E.handle,w)},[]),j=n.useCallback((f,w,E)=>{u.current=u.current.map(A=>A.properties.id===f?{...A,geometry:{...A.geometry,coordinates:[w,E]}}:A);const S=c.current.find(A=>A.featureId===f);S&&S.marker.setLngLat([w,E])},[]);n.useEffect(()=>{const f=e.current;if(!f||!t||r)return;const w=E=>{var R;if(o.current!=="directional-point")return;h.current=!0;let S=0;if(O.current&&u.current.length>0){S=u.current[0].properties.direction;for(const z of c.current)z.marker.remove();c.current=[],u.current=[],L(null)}const A=yt(),B={type:"Feature",geometry:{type:"Point",coordinates:[E.lngLat.lng,E.lngLat.lat]},properties:{id:A,direction:O.current?S:0,mode:"directional-point"}};u.current=[...u.current,B],P(B),(R=b.current)==null||R.call(b)};return f.on("click",w),()=>{f.off("click",w)}},[e,t,r,P]);const C=n.useCallback(()=>{var w;const f=T.current;if(f){const E=c.current.find(S=>S.featureId===f);E&&Ct(E.container,!1)}L(null),(w=F.current)==null||w.call(F,null)},[]),I=n.useCallback(()=>{var E,S;const f=T.current;if(!f)return;const w=c.current.find(A=>A.featureId===f);w&&w.marker.remove(),c.current=c.current.filter(A=>A.featureId!==f),u.current=u.current.filter(A=>A.properties.id!==f),L(null),(E=F.current)==null||E.call(F,null),(S=b.current)==null||S.call(b)},[]),v=n.useCallback(()=>u.current,[]),D=n.useCallback(f=>{if(!h.current){h.current=!0,u.current=f;for(const w of f)c.current.some(E=>E.featureId===w.properties.id)||P(w)}},[P]),W=n.useCallback(f=>{for(const w of c.current)w.marker.remove();if(c.current=[],u.current=[],L(null),h.current=!1,f.length!==0){u.current=f,h.current=!0;for(const w of f)P(w)}},[P]);return n.useEffect(()=>()=>{for(const f of c.current)f.marker.remove();c.current=[]},[]),{hasSelection:g!==null,deleteSelected:I,getFeatures:v,loadFeatures:D,replaceFeatures:W,deselect:C}}const nn={"nb-NO":{drawMode:{directionalPoint:"Tegn retningspunkt",linestring:"Tegn linje",point:"Tegn punkt",polygon:"Tegn polygon"},fields:{direction:"Retning (grader)",directionPlaceholder:"0–360",latitude:"Breddegrad",latitudePlaceholder:"f.eks. 63.4305",longitude:"Lengdegrad",longitudePlaceholder:"f.eks. 10.3951"},layers:{backgroundMaps:"Bakgrunnskart",defaultCategory:"Lag",filterAriaLabel:"Filtrer kartlag",hide:"Skjul kartlag",noLayersAvailable:"Ingen kartlag tilgjengelig",noResults:"Ingen lag samsvarer med søket",searchPlaceholder:"Søk etter lag…",show:"Vis kartlag",toggleButtonLabel:"Kartlag"},mapCenterAction:{ariaLabel:"Velg i sentrum av kartet",buttonText:"Velg her"},toolbar:{delete:"Slett valgt",import:"Importer GeoJSON",select:"Velg/rediger"}},"nn-NO":{drawMode:{directionalPoint:"Teikn retningspunkt",linestring:"Teikn linje",point:"Teikn punkt",polygon:"Teikn polygon"},fields:{direction:"Retning (grader)",directionPlaceholder:"0–360",latitude:"Breiddegrad",latitudePlaceholder:"t.d. 63.4305",longitude:"Lengdegrad",longitudePlaceholder:"t.d. 10.3951"},layers:{backgroundMaps:"Bakgrunnskart",defaultCategory:"Lag",filterAriaLabel:"Filtrer kartlag",hide:"Skjul kartlag",noLayersAvailable:"Ingen kartlag tilgjengelege",noResults:"Ingen lag samsvarar med søket",searchPlaceholder:"Søk etter lag…",show:"Vis kartlag",toggleButtonLabel:"Kartlag"},mapCenterAction:{ariaLabel:"Vel i sentrum av kartet",buttonText:"Vel her"},toolbar:{delete:"Slett valt",import:"Importer GeoJSON",select:"Vel/rediger"}},"en-US":{drawMode:{directionalPoint:"Draw directional point",linestring:"Draw line",point:"Draw point",polygon:"Draw polygon"},fields:{direction:"Direction (degrees)",directionPlaceholder:"0–360",latitude:"Latitude",latitudePlaceholder:"e.g. 63.4305",longitude:"Longitude",longitudePlaceholder:"e.g. 10.3951"},layers:{backgroundMaps:"Background maps",defaultCategory:"Layers",filterAriaLabel:"Filter map layers",hide:"Hide map layers",noLayersAvailable:"No map layers available",noResults:"No layers match the search",searchPlaceholder:"Search for layers…",show:"Show map layers",toggleButtonLabel:"Map layers"},mapCenterAction:{ariaLabel:"Select at the center of the map",buttonText:"Select here"},toolbar:{delete:"Delete selected",import:"Import GeoJSON",select:"Select/edit"}}},jt="styrbord-kart",sn=e=>l.jsx(It.NamespaceProvider,{ns:jt,translations:nn,children:e.children}),Ve=It.useTranslation.bind(null,jt),on=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"M480-96Q323.03-227.11 245.51-339.55 168-452 168-549q0-134 89-224.5T480-864q12 0 24 .5t24 2.31V-788q-11-2-23-3t-25-1q-103 0-171.5 69T240-549q0 71 60.5 161T480-191q119-107 179.5-197T720-549v-13.5q0-6.75-1-13.5h72q1 7 1 13.67V-549q0 97-77 209T480-96Zm51-405.21q21-21.21 21-51T530.79-603q-21.21-21-51-21T429-602.79q-21 21.21-21 51T429.21-501q21.21 21 51 21T531-501.21ZM480-552Zm240-96h72v-120h120v-72H792v-120h-72v120H600v72h120v120Z"})}),an=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"M119.79-240Q90-240 69-261.21t-21-51Q48-342 69.04-363t50.59-21q5.37 0 9.87.5 4.5.5 9.5 1.5l200-199.52q-2-5.48-2.5-9.48t-.5-9.37q0-29.55 21.21-50.59 21.21-21.04 51-21.04T459-650.85q21 21.15 21 50.85 0 3-3 18l104.86 105q5.14-2 9-2.5 3.85-.5 9-.5 5.14 0 9.64.5 4.5.5 9.5 1.5l152-151.66q-2-5.34-2.5-9.34t-.5-9.37q0-29.55 21.21-50.59 21.21-21.04 51-21.04T891-698.79q21 21.21 21 51T890.96-597q-21.04 21-50.59 21-5.37 0-9.87-.5-4.5-.5-9.5-1.5L669-426.34q2 5.34 2.5 9.34t.5 9.37q0 29.55-21.21 50.59-21.21 21.04-51 21.04T549-357.04q-21-21.04-21-50.59 0-5.37.5-9.87.5-4.5 1.5-9.5L426.09-531q-5.09 2-9.09 2.5t-9 .5q-5 0-19-2L189-330.48q2 5.48 2.5 9.48t.5 9.37q0 29.55-21.21 50.59-21.21 21.04-51 21.04Z"})}),ln=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"M306-168h349l123-356-298-205-298 205 124 356Zm-52 72L96-552l384-264 384 264L706-96H254Zm226-353Z"})}),cn=()=>l.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:l.jsx("path",{d:"M5,3 L5,19 L10,15 L14,21 L16,20 L12,14 L18,14 Z"})}),un=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("polyline",{points:"3,6 5,6 21,6"}),l.jsx("path",{d:"M6,6 L6,20 C6,21.1 6.9,22 8,22 L16,22 C17.1,22 18,21.1 18,20 L18,6"}),l.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),l.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"}),l.jsx("path",{d:"M9,6 L9,4 C9,3.4 9.4,3 10,3 L14,3 C14.6,3 15,3.4 15,4 L15,6"})]}),dn=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"m312-312 264-72 72-264-264 72-72 264Zm168-120q-20 1-34-13.5T432-480q0-20 14-34t34-14q20 0 34 14t14 34q0 20-14 34t-34 14Zm.28 336Q401-96 331-126t-122.5-82.5Q156-261 126-330.96t-30-149.5Q96-560 126-629.5q30-69.5 82.5-122T330.96-834q69.96-30 149.5-30t149.04 30q69.5 30 122 82.5T834-629.28q30 69.73 30 149Q864-401 834-331t-82.5 122.5Q699-156 629.28-126q-69.73 30-149 30Zm-.05-72Q610-168 701-259.23t91-221Q792-610 700.77-701t-221-91Q350-792 259-700.77t-91 221Q168-350 259.23-259t221 91ZM480-480Z"})}),pn=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"M440-200h80v-167l64 64 56-57-160-160-160 160 57 56 63-63v167ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"})}),fn={point:on,linestring:an,polygon:ln,"directional-point":dn},or={point:"drawMode.point",linestring:"drawMode.linestring",polygon:"drawMode.polygon","directional-point":"drawMode.directionalPoint"};function gn(e){let t;try{t=JSON.parse(e)}catch(s){return{ok:!1,reason:"invalid-json",detail:s instanceof Error?s.message:String(s)}}if(typeof t!="object"||t===null)return{ok:!1,reason:"not-geojson",detail:`Expected a JSON object but got ${t===null?"null":typeof t}`};const r=t;if(r.type==="FeatureCollection"&&Array.isArray(r.features)){const s=r;return s.features.length===0?{ok:!1,reason:"empty-collection",detail:"FeatureCollection contains no features"}:{ok:!0,data:s}}return r.type==="Feature"&&r.geometry?{ok:!0,data:{type:"FeatureCollection",features:[r]}}:typeof r.type=="string"&&(r.coordinates||r.geometries)&&!r.features?{ok:!0,data:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:r}]}}:{ok:!1,reason:"not-geojson",detail:`Unrecognised GeoJSON type: ${typeof r.type=="string"?r.type:"(missing)"}`}}function yn({modes:e,activeMode:t,hasSelection:r,deletable:s,editable:a,onSetMode:d,onDelete:p,onImport:u,onImportError:c}){const{t:g}=Ve(),L=n.useRef(null),T=h=>{var b;const o=(b=h.target.files)==null?void 0:b[0];if(!o)return;const k=new FileReader;k.onload=()=>{const F=k.result;if(typeof F!="string")return;const O=gn(F);O.ok?u(O.data):(console.warn(`GeoJsonEditor: import failed (${O.reason}) — ${O.detail}`),c==null||c(O.reason,O.detail))},k.onerror=()=>{var O;const F=((O=k.error)==null?void 0:O.message)??"Unknown read error";console.warn(`GeoJsonEditor: failed to read file — ${F}`),c==null||c("invalid-json",F)},k.readAsText(o),h.target.value=""};return l.jsxs("div",{className:ue.toolbar,children:[l.jsx("input",{ref:L,type:"file",accept:".geojson,.json,application/geo+json,application/json",style:{display:"none"},onChange:T}),e.map(h=>{const o=fn[h],k=t===h;return l.jsx("button",{type:"button",title:g(or[h]),"aria-label":g(or[h]),"aria-pressed":k,className:[ue.toolbarButton,k&&ue.active].filter(Boolean).join(" "),onClick:()=>d(k?"static":h),children:l.jsx(o,{})},h)}),l.jsx("div",{className:ue.toolbarDivider}),l.jsx("button",{type:"button",title:g("toolbar.import"),"aria-label":g("toolbar.import"),className:ue.toolbarButton,onClick:()=>{var h;return(h=L.current)==null?void 0:h.click()},children:l.jsx(pn,{})}),a&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:ue.toolbarDivider}),l.jsx("button",{type:"button",title:g("toolbar.select"),"aria-label":g("toolbar.select"),"aria-pressed":t==="select",className:[ue.toolbarButton,t==="select"&&ue.active].filter(Boolean).join(" "),onClick:()=>d(t==="select"?"static":"select"),children:l.jsx(cn,{})})]}),s&&r&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:ue.toolbarDivider}),l.jsx("button",{type:"button",title:g("toolbar.delete"),"aria-label":g("toolbar.delete"),className:[ue.toolbarButton,ue.danger].join(" "),onClick:p,children:l.jsx(un,{})})]})]})}function ar(){const e=n.useContext(Ze),t=n.useContext(Je),r=n.useContext(Xe),s=n.useContext(We),a=n.useMemo(()=>new Set(t.availableLayers.map(o=>o.id)),[t.availableLayers]),d=n.useMemo(()=>new Set(r.layers.map(o=>o.id)),[r.layers]),p=n.useMemo(()=>new Set(s.layers.map(o=>o.id)),[s.layers]),u=n.useMemo(()=>{const o=[];for(const k of t.availableLayers)o.push({definition:k,visible:t.visibleLayerIds.has(k.id),origin:"built-in"});for(const k of r.layers)o.push({definition:k,visible:r.visibleLayerIds.has(k.id),origin:"custom"});for(const k of s.layers)o.push({definition:k,visible:s.visibleLayerIds.has(k.id),origin:"wms-catalog"});return o},[t.availableLayers,t.visibleLayerIds,r.layers,r.visibleLayerIds,s.layers,s.visibleLayerIds]),c=n.useMemo(()=>u.filter(o=>o.visible),[u]),g=o=>a.has(o)?(t.toggleLayer(o),!0):d.has(o)?(r.toggleLayer(o),!0):p.has(o)?(s.toggleLayer(o),!0):!1,L=o=>a.has(o)?(t.showLayer(o),!0):d.has(o)?(r.showLayer(o),!0):p.has(o)?(s.showLayer(o),!0):!1,T=o=>a.has(o)?(t.hideLayer(o),!0):d.has(o)?(r.hideLayer(o),!0):p.has(o)?(s.hideLayer(o),!0):!1,h=o=>a.has(o)?t.isVisible(o):d.has(o)?r.isVisible(o):p.has(o)?s.isVisible(o):!1;return{availableBaseLayers:e.availableBaseLayers,activeBaseLayerId:e.activeBaseLayerId,setActiveBaseLayer:e.setActiveBaseLayer,allLayers:u,visibleLayers:c,toggleLayer:g,showLayer:L,hideLayer:T,isVisible:h}}const ae={root:"_root_lgvrt_1",toggleButton:"_toggleButton_lgvrt_13",toggleButtonIcon:"_toggleButtonIcon_lgvrt_34",panel:"_panel_lgvrt_40",filterWrapper:"_filterWrapper_lgvrt_51",filterInput:"_filterInput_lgvrt_56",categoryHeading:"_categoryHeading_lgvrt_78",chevron:"_chevron_lgvrt_99",layerItem:"_layerItem_lgvrt_105",checkbox:"_checkbox_lgvrt_120",radio:"_radio_lgvrt_128",emptyMessage:"_emptyMessage_lgvrt_136"};function kn({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("polygon",{points:"12 2 2 7 12 12 22 7 12 2"}),l.jsx("polyline",{points:"2 17 12 22 22 17"}),l.jsx("polyline",{points:"2 12 12 17 22 12"})]})}function mn({expanded:e,className:t}){return l.jsx("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{transform:e?"rotate(90deg)":void 0,transition:"transform 150ms ease"},children:l.jsx("polyline",{points:"6 4 10 8 6 12"})})}function xt({className:e,defaultOpen:t=!1}){const{t:r}=Ve(),[s,a]=n.useState(t),[d,p]=n.useState(""),[u,c]=n.useState(new Set),{allLayers:g,toggleLayer:L,availableBaseLayers:T,activeBaseLayerId:h,setActiveBaseLayer:o}=ar(),k=n.useRef(null),b=T.length>1,F=n.useCallback(v=>{c(D=>{const W=new Set(D);return W.has(v)?W.delete(v):W.add(v),W})},[]),O=d.trim().toLowerCase(),P=n.useMemo(()=>O?T.filter(v=>v.label.toLowerCase().includes(O)):T,[T,O]),_=n.useMemo(()=>{const v=new Map;for(const D of g){if(O&&!D.definition.label.toLowerCase().includes(O))continue;const W=D.definition.category??r("layers.defaultCategory"),f=v.get(W);f?f.push(D):v.set(W,[D])}return v},[g,O,r]),$=n.useCallback(v=>O?!0:u.has(v),[O,u]),j=[ae.root,e].filter(Boolean).join(" "),C=b&&P.length>0,I=_.size>0||C;return g.length===0&&!b?null:l.jsxs("div",{className:j,children:[l.jsxs("button",{type:"button",className:ae.toggleButton,onClick:()=>a(v=>!v),"aria-expanded":s,"aria-label":r(s?"layers.hide":"layers.show"),title:r(s?"layers.hide":"layers.show"),children:[l.jsx(kn,{className:ae.toggleButtonIcon}),r("layers.toggleButtonLabel")]}),s&&l.jsxs("div",{className:ae.panel,ref:k,role:"group",children:[l.jsx("div",{className:ae.filterWrapper,children:l.jsx("input",{type:"text",className:ae.filterInput,placeholder:r("layers.searchPlaceholder"),value:d,onChange:v=>p(v.target.value),"aria-label":r("layers.filterAriaLabel")})}),I?l.jsxs(l.Fragment,{children:[C&&l.jsxs("div",{children:[l.jsx("span",{className:ae.categoryHeading,children:r("layers.backgroundMaps")}),P.map(v=>l.jsxs("label",{className:ae.layerItem,children:[l.jsx("input",{type:"radio",className:ae.radio,name:"base-layer",checked:v.id===h,onChange:()=>o(v.id)}),v.label]},v.id))]}),Array.from(_.entries()).map(([v,D])=>{const W=_.size>1||C,f=$(v);return l.jsxs("div",{children:[W?l.jsxs("button",{type:"button",className:ae.categoryHeading,onClick:()=>F(v),"aria-expanded":f,children:[l.jsx(mn,{expanded:f,className:ae.chevron}),v]}):null,(!W||f)&&D.map(w=>l.jsxs("label",{className:ae.layerItem,children:[l.jsx("input",{type:"checkbox",className:ae.checkbox,checked:w.visible,onChange:()=>L(w.definition.id)}),w.definition.label]},w.definition.id))]},v)})]}):l.jsx("div",{className:ae.emptyMessage,children:r(O?"layers.noResults":"layers.noLayersAvailable")})]})]})}const hn=e=>e.reduce((t,r)=>{var a;const s=parseInt(String(((a=r.properties)==null?void 0:a.nummer)??0));return s>t?s:t},0),ir=e=>{let t=hn(e.features)+1;return{...e,features:e.features.filter(r=>{var s,a,d;return r.geometry.type==="Point"&&((s=r.geometry.coordinates)==null?void 0:s.length)>0||r.geometry.type==="Polygon"&&((a=r.geometry.coordinates[0][0])==null?void 0:a.length)>0||r.geometry.type==="LineString"&&((d=r.geometry.coordinates[0])==null?void 0:d.length)>0}).map(r=>{var d,p;const s=((d=r.properties)==null?void 0:d.nummer)??t++,a=((p=r.properties)==null?void 0:p.id)??yt();return{...r,properties:{...r.properties,id:a,nummer:s}}})}},$e={popup:"_popup_e7e0k_1",defaultContent:"_defaultContent_e7e0k_17",featureType:"_featureType_e7e0k_23",featureName:"_featureName_e7e0k_28"};function lr({feature:e,position:t,hoverContent:r}){var c;const s=((c=e.properties)==null?void 0:c.type)??"_",a=s?r==null?void 0:r[s]:void 0,d=a?a(e):l.jsx(vn,{feature:e});return l.jsx("div",{className:$e.popup,style:{left:t.x+12,top:t.y+12},role:"tooltip","aria-live":"polite",children:d})}function vn({feature:e}){var s,a,d;const t=(s=e.properties)==null?void 0:s.type,r=(a=e.properties)==null?void 0:a.name;return l.jsxs("div",{className:$e.defaultContent,children:[t&&l.jsx("span",{className:$e.featureType,children:String(t)}),r&&l.jsx("span",{className:$e.featureName,children:String(r)}),!t&&!r&&l.jsx("span",{className:$e.featureType,children:((d=e.geometry)==null?void 0:d.type)??"Feature"})]})}const Mt={crosshair:"_crosshair_mxy17_1",crosshairSvg:"_crosshairSvg_mxy17_11",actionButton:"_actionButton_mxy17_18"};function _n(){return l.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none","aria-hidden":"true",className:Mt.crosshairSvg,children:[l.jsx("line",{x1:"0",y1:"20",x2:"16",y2:"20",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("line",{x1:"24",y1:"20",x2:"40",y2:"20",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("line",{x1:"20",y1:"0",x2:"20",y2:"16",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("line",{x1:"20",y1:"24",x2:"20",y2:"40",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("circle",{cx:"20",cy:"20",r:"3",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})]})}function bn(){return l.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("circle",{cx:"12",cy:"12",r:"6"}),l.jsx("circle",{cx:"12",cy:"12",r:"2"})]})}function Tt({mapRef:e,visible:t}){const[r,s]=n.useState(!1),{t:a}=Ve();if(n.useEffect(()=>{s(window.matchMedia("(pointer: coarse)").matches)},[]),!(t??r))return null;const p=()=>{const u=e.current;if(!u)return;const c=u.getCanvas(),g=c.getBoundingClientRect(),L=g.left+g.width/2,T=g.top+g.height/2,h={clientX:L,clientY:T,bubbles:!0,pointerId:1,isPrimary:!0,pointerType:"touch",button:0,buttons:1};c.dispatchEvent(new PointerEvent("pointermove",h)),c.dispatchEvent(new PointerEvent("pointerdown",h)),c.dispatchEvent(new PointerEvent("pointerup",{...h,buttons:0})),c.dispatchEvent(new MouseEvent("click",{clientX:L,clientY:T,bubbles:!0,button:0}))};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:Mt.crosshair,children:l.jsx(_n,{})}),l.jsxs("button",{type:"button",className:Mt.actionButton,onClick:p,"aria-label":a("mapCenterAction.ariaLabel"),children:[l.jsx(bn,{}),l.jsx("span",{children:a("mapCenterAction.buttonText")})]})]})}const Sn=["point","linestring","polygon"],Ln=e=>{var t;return(t=e.properties)!=null&&t.nummer?`#${e.properties.nummer}`:void 0},Me="geojson-editor-labels",dt="geojson-editor-label";function pt({value:e,onChange:t,modes:r=Sn,editable:s=!0,deletable:a=!0,fitBounds:d=!1,fitBoundsPadding:p=40,showLayerToggle:u=!0,height:c,className:g,disabled:L=!1,hoverable:T=!0,onHover:h,onSelect:o,hoverContent:k,onCoordinateClick:b,onImportError:F,showCenterAction:O,showZoomControls:P,singleFeature:_=!1,getLabel:$=Ln}){const{mapContainerRef:j,mapRef:C,mapReady:I,mapVersion:v}=St({disabled:L,height:c,showZoomControls:P}),[D,W]=n.useState(null),f=n.useRef("static"),[w,E]=n.useState(_?r[0]:"static"),S=n.useRef(b);S.current=b;const{result:A}=Lt({mapRef:C,coordinate:D,enabled:!!b});n.useEffect(()=>{var x;A&&((x=S.current)==null||x.call(S,A))},[A]),n.useEffect(()=>{const x=C.current;if(!x||!I||L||!S.current)return;const U=ee=>{const X=f.current;if(X==="point"||X==="linestring"||X==="polygon"||X==="directional-point")return;const{lng:ne,lat:te}=ee.lngLat;W({latitude:te,longitude:ne})};return x.on("click",U),()=>{x.off("click",U)}},[C,I,L]);const[B,R]=n.useState(null),[z,K]=n.useState(null),m=n.useRef(h);m.current=h;const i=n.useCallback(x=>{var U;(U=N.current)==null||U.deselect(),o==null||o(x)},[o]),N=n.useRef(null),V=n.useRef(()=>{}),G=n.useRef(!1),fe=r.filter(x=>x!=="directional-point").join(","),ke=n.useMemo(()=>fe.split(",").filter(Boolean),[fe]),q=Jr({mapRef:C,mapVersion:v,modes:ke,editable:s,deletable:a,disabled:L,singleFeature:_,onChange:x=>{V.current(x)},onSelect:i}),{activeMode:ie,setActiveMode:me,deleteSelected:Fe,hasSelection:Ie,isReady:ft}=q;f.current=w;const le=rn({mapRef:C,mapReady:I,disabled:L,activeMode:w,singleFeature:_,onChange:()=>{V.current()},onSelect:x=>{x&&(me("static"),o==null||o([x]))}});N.current=le;const Y=n.useCallback(x=>{if(!t)return;G.current=!0;const U=(x==null?void 0:x.features)??q.getSnapshot(),ee=le.getFeatures(),X={type:"FeatureCollection",features:[...U,...ee]};t(ir(X))},[t,q,le]);V.current=Y;const Q=n.useCallback(x=>{x==="directional-point"?me("static"):(le.deselect(),me(x)),E(x)},[me,le]);n.useEffect(()=>{E(x=>x==="directional-point"?x:ie)},[ie]);const Ee=Ie||le.hasSelection,Ce=n.useCallback(()=>{le.hasSelection?le.deleteSelected():Fe()},[le,Fe]),{replaceFeatures:ce}=q,re=n.useMemo(()=>e?ct(e):void 0,[e]),{replaceFeatures:be}=le,Ae=n.useRef($);Ae.current=$;const Se=n.useCallback(x=>{const U=C.current,ee=Ae.current;if(!U||!I||!ee)return;const X=x&&x.features.length>0?{type:"FeatureCollection",features:x.features.map(te=>({...te,properties:{...te.properties,_label:ee(te)??""}}))}:{type:"FeatureCollection",features:[]},ne=()=>{const te=U.getSource(Me);te&&te.setData(X)};U.isStyleLoaded()?ne():U.once("load",ne)},[C,I]),Ft=n.useCallback(x=>{var Ge;const U=q.getSnapshot(),ee=le.getFeatures(),X=[],ne=[];for(const Le of x.features){const he={...Le.properties};delete he.id,delete he.nummer;const _e={...Le,properties:he};((Ge=_e.properties)==null?void 0:Ge.mode)==="directional-point"?X.push(_e):ne.push(_e)}const te=[...U,...ne],Oe=[...ee,...X];ce({type:"FeatureCollection",features:te}),be(Oe);const ye={type:"FeatureCollection",features:[...te,...Oe]},He=ir(ye);t&&(G.current=!0,t(He)),Se(He);const Re=C.current;if(Re){const Le=wt(ye);Le&&Re.fitBounds(Le,{padding:p,maxZoom:16,duration:300})}},[t,q,le,ce,be,Se,C,p]);n.useEffect(()=>{var ee;if(!ft){G.current=!1;return}if(G.current){G.current=!1;return}const x=[],U=[];if(re)for(const X of re.features)((ee=X.properties)==null?void 0:ee.mode)==="directional-point"?x.push(X):U.push(X);ce({type:"FeatureCollection",features:U}),be(x)},[re,ce,be,ft]),n.useEffect(()=>{const x=C.current;if(!x||!I||!L||!re||re.features.length===0)return;const U="geojson-editor-disabled",ee="geojson-editor-disabled-fill",X="geojson-editor-disabled-line",ne="geojson-editor-disabled-point-stroke",te="geojson-editor-disabled-point",Oe=()=>{if(x.getSource(U)){x.getSource(U).setData(re);return}x.addSource(U,{type:"geojson",data:re}),x.addLayer({id:ee,type:"fill",source:U,filter:["==","$type","Polygon"],paint:{"fill-color":J,"fill-opacity":Be}}),x.addLayer({id:X,type:"line",source:U,filter:["in","$type","LineString","Polygon"],paint:{"line-color":J,"line-width":4}}),x.addLayer({id:ne,type:"circle",source:U,filter:["==","$type","Point"],paint:{"circle-radius":9,"circle-color":ge}}),x.addLayer({id:te,type:"circle",source:U,filter:["==","$type","Point"],paint:{"circle-radius":6,"circle-color":J}})};return x.isStyleLoaded()?Oe():x.once("load",Oe),()=>{try{for(const ye of[te,ne,X,ee])x.getLayer(ye)&&x.removeLayer(ye);x.getSource(U)&&x.removeSource(U)}catch{}}},[C,I,L,re]);const ur=n.useRef(!1);return n.useEffect(()=>{const x=C.current;if(!x||!I||!re||!d||ur.current)return;const U=wt(re);if(!U)return;ur.current=!0;const ee=()=>{x.fitBounds(U,{padding:p,maxZoom:16,duration:300})};x.isStyleLoaded()?ee():x.once("load",ee)},[re,d,p,C,I]),n.useEffect(()=>{const x=C.current;if(!x||!I)return;const U=()=>{x.getSource(Me)||x.addSource(Me,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),x.getLayer(dt)||x.addLayer({id:dt,type:"symbol",source:Me,layout:{"text-field":["get","_label"],"text-size":16,"text-anchor":"left","text-offset":[1.2,0],"text-allow-overlap":!0,"text-optional":!1},paint:{"text-color":Kt,"text-halo-color":Ut,"text-halo-width":2}})};return x.isStyleLoaded()?U():x.once("load",U),()=>{try{x.getLayer(dt)&&x.removeLayer(dt),x.getSource(Me)&&x.removeSource(Me)}catch{}}},[C,I]),n.useEffect(()=>{Se(re)},[Se,re]),n.useEffect(()=>{const x=C.current;if(!x||!I||L||!T)return;let U=null;const ee=ne=>{var He,Re,Ge,Le;const te=f.current;if(te==="point"||te==="linestring"||te==="polygon"||te==="directional-point"){U!==null&&(U=null,R(null),K(null),(He=m.current)==null||He.call(m,null,null),x.getCanvas().style.cursor="");return}const ye=x.queryRenderedFeatures(ne.point).find(he=>{var _e;return((_e=he.properties)==null?void 0:_e.mode)&&he.properties.mode!=="select"});if(ye){const he=ye.id??((Re=ye.properties)==null?void 0:Re.id)??null;if(he!==U){U=he;const _e={type:"Feature",id:he??void 0,geometry:ye.geometry,properties:ye.properties};R(_e),(Ge=m.current)==null||Ge.call(m,_e,ne)}K({x:ne.point.x,y:ne.point.y}),x.getCanvas().style.cursor="pointer"}else U!==null&&(U=null,R(null),K(null),(Le=m.current)==null||Le.call(m,null,null)),x.getCanvas().style.cursor=""},X=()=>{var ne;U=null,R(null),K(null),(ne=m.current)==null||ne.call(m,null,null),x.getCanvas().style.cursor=""};return x.on("mousemove",ee),x.on("mouseout",X),()=>{x.off("mousemove",ee),x.off("mouseout",X),x.getCanvas().style.cursor=""}},[C,I,L,T]),l.jsx("div",{className:[ue.editorWrapper,g].filter(Boolean).join(" "),children:l.jsxs("div",{ref:j,className:Nt.mapContainer,children:[!L&&!_&&l.jsx(yn,{modes:r,activeMode:w,hasSelection:Ee,deletable:a,editable:s,onSetMode:Q,onDelete:Ce,onImport:Ft,onImportError:F}),u&&l.jsx(xt,{}),!L&&l.jsx(Tt,{mapRef:C,visible:O&&(w==="point"||w==="linestring"||w==="polygon"||w==="directional-point")}),T&&B&&z&&l.jsx(lr,{feature:B,position:z,hoverContent:k})]})})}function wn({value:e,onChange:t,error:r,disabled:s=!1,className:a,height:d,showCenterAction:p}){const u=n.useId(),{t:c}=Ve(),g=n.useRef(yt()),L=n.useRef((e==null?void 0:e.properties.direction)??0),T=n.useMemo(()=>{if(e)return{type:"FeatureCollection",features:[{type:"Feature",geometry:e.geometry,properties:{mode:"directional-point",direction:e.properties.direction,id:g.current}}]}},[e]),h=n.useCallback(C=>{var v,D;const I=C.features.find(W=>{var f;return((f=W.properties)==null?void 0:f.mode)==="directional-point"});if(I){(v=I.properties)!=null&&v.id&&(g.current=I.properties.id);const W=((D=I.properties)==null?void 0:D.direction)??L.current;L.current=W;const f={type:"Feature",geometry:I.geometry,properties:{direction:W}};t(f)}},[t]),[o,k]=n.useState((e==null?void 0:e.geometry.coordinates[1])??void 0),[b,F]=n.useState((e==null?void 0:e.geometry.coordinates[0])??void 0),[O,P]=n.useState((e==null?void 0:e.properties.direction)??void 0);n.useEffect(()=>{const C=e==null?void 0:e.geometry.coordinates;k(C?C[1]:void 0),F(C?C[0]:void 0),P((e==null?void 0:e.properties.direction)??void 0),(e==null?void 0:e.properties.direction)!=null&&(L.current=e.properties.direction)},[e]);const _=n.useCallback(C=>{t(C)},[t]),$=n.useCallback((C,I)=>{if(!(C==null&&I==null)&&C!=null&&I!=null){const v={type:"Feature",geometry:{type:"Point",coordinates:[qe(I),Ye(C)]},properties:{direction:(e==null?void 0:e.properties.direction)??0}};_(v)}},[e==null?void 0:e.properties.direction,_]),j=n.useCallback(C=>{if(!e)return;const I={type:"Feature",geometry:e.geometry,properties:{direction:C!=null?Math.round(Ue(C)):0}};_(I)},[e,_]);return l.jsxs(Z.Box,{gap:16,className:[a].filter(Boolean).join(" "),children:[l.jsx(pt,{singleFeature:!0,modes:["directional-point"],value:T,onChange:h,disabled:s,height:d,showCenterAction:p}),l.jsxs(Z.Box,{horizontal:!0,gap:16,children:[l.jsx(Z.NumberInput,{id:`${u}-lat`,inputMode:"decimal",label:c("fields.latitude"),value:o??null,disabled:s,placeholder:c("fields.latitudePlaceholder"),onChange:C=>k(C),onBlur:()=>$(o,b)}),l.jsx(Z.NumberInput,{id:`${u}-lon`,inputMode:"decimal",label:c("fields.longitude"),value:b??null,disabled:s,placeholder:c("fields.longitudePlaceholder"),onChange:C=>F(C),onBlur:()=>$(o,b)}),l.jsx(Z.NumberInput,{id:`${u}-dir`,inputMode:"decimal",label:c("fields.direction"),value:O??null,disabled:s,placeholder:c("fields.directionPlaceholder"),min:0,max:360,onChange:C=>P(C),onBlur:()=>j(O)})]}),r&&l.jsx(Z.ValidationMessage,{children:r})]})}function En({value:e,onChange:t,error:r,disabled:s=!1,className:a,height:d,showCenterAction:p}){const u=n.useId(),{t:c}=Ve(),g=n.useMemo(()=>{if(e)return{type:"FeatureCollection",features:[{type:"Feature",geometry:e.geometry,properties:{}}]}},[e]),L=n.useCallback(F=>{if(F.features.length>0){const P={type:"Feature",geometry:F.features[0].geometry};t(P)}},[t]),[T,h]=n.useState((e==null?void 0:e.geometry.coordinates[1])??void 0),[o,k]=n.useState((e==null?void 0:e.geometry.coordinates[0])??void 0);n.useEffect(()=>{const F=e==null?void 0:e.geometry.coordinates;h(F?F[1]:void 0),k(F?F[0]:void 0)},[e]);const b=n.useCallback((F,O)=>{if(!(F==null&&O==null)&&F!=null&&O!=null){const P={type:"Feature",geometry:{type:"Point",coordinates:[qe(O),Ye(F)]}};t(P)}},[t]);return l.jsxs(Z.Box,{gap:16,className:[a].filter(Boolean).join(" "),children:[l.jsx(pt,{singleFeature:!0,modes:["point"],value:g,onChange:L,disabled:s,height:d,showCenterAction:p}),l.jsxs(Z.Box,{horizontal:!0,gap:16,children:[l.jsx(Z.NumberInput,{id:`${u}-lat`,inputMode:"decimal",label:c("fields.latitude"),value:T??null,disabled:s,placeholder:c("fields.latitudePlaceholder"),onChange:F=>h(F),onBlur:()=>b(T,o)}),l.jsx(Z.NumberInput,{id:`${u}-lon`,inputMode:"decimal",label:c("fields.longitude"),value:o??null,disabled:s,placeholder:c("fields.longitudePlaceholder"),onChange:F=>k(F),onBlur:()=>b(T,o)})]}),r&&l.jsx(Z.ValidationMessage,{children:r})]})}function Cn({mapRef:e,layerIds:t,sourceId:r,enabled:s=!0,hoverable:a=!0,selectable:d=!0,onHover:p,onSelect:u}){const[c,g]=n.useState(null),[L,T]=n.useState([]),h=n.useRef(p);h.current=p;const o=n.useRef(u);o.current=u;const k=n.useRef(null),b=n.useCallback(_=>_.id!==void 0?_.id:JSON.stringify(_.properties),[]),F=n.useCallback((_,$)=>{const j=t.filter(I=>_.getLayer(I));return j.length===0?[]:_.queryRenderedFeatures($,{layers:j})},[t]),O=n.useCallback(()=>{var _;T([]),(_=o.current)==null||_.call(o,null)},[]),P=n.useCallback(_=>{var I;const $=e.current;if(!$)return;const C=$.querySourceFeatures(r).filter(v=>{const D=v.id??JSON.stringify(v.properties);return _.includes(D)});T(C),(I=o.current)==null||I.call(o,C.length>0?C:null)},[e,r]);return n.useEffect(()=>{const _=e.current;if(!_||!s)return;const $=I=>{var f;if(!a)return;const v=F(_,I.point),D=v.length>0?v[0]:null,W=D?b(D):null;W!==k.current&&(k.current=W,g(D),(f=h.current)==null||f.call(h,D,D?I:null),_.getCanvas().style.cursor=D?"pointer":"")},j=()=>{var I;a&&k.current!==null&&(k.current=null,g(null),(I=h.current)==null||I.call(h,null,null),_.getCanvas().style.cursor="")},C=I=>{var w;if(!d)return;const v=F(_,I.point);if(v.length===0){L.length>0&&(T([]),(w=o.current)==null||w.call(o,null));return}const D=v[0],W=b(D),f=I.originalEvent.ctrlKey||I.originalEvent.metaKey;T(E=>{let S;return f?E.some(B=>b(B)===W)?S=E.filter(B=>b(B)!==W):S=[...E,D]:E.length===1&&b(E[0])===W?S=[]:S=[D],setTimeout(()=>{var A;(A=o.current)==null||A.call(o,S.length>0?S:null)},0),S})};return _.on("mousemove",$),_.on("mouseout",j),_.on("click",C),()=>{_.off("mousemove",$),_.off("mouseout",j),_.off("click",C),_.getCanvas().style.cursor=""}},[e,s,a,d,t,F,b,L.length]),{hoveredFeature:c,selectedFeatures:L,hasSelection:L.length>0,clearSelection:O,selectByIds:P}}const Te="geojson-viewer-labels",jn=e=>{var t;return(t=e.properties)!=null&&t.nummer?`#${e.properties.nummer}`:void 0};function xn({data:e,fitBounds:t=!0,fitBoundsPadding:r=40,geoJsonStyle:s,showLayerToggle:a=!0,height:d,className:p,disabled:u,hoverable:c=!0,selectable:g=!0,onHover:L,onSelect:T,hoverContent:h,onCoordinateClick:o,showCenterAction:k,showZoomControls:b,getLabel:F=jn}){const O={...Rr,...s},P=n.useMemo(()=>ct(e),[e]),[_,$]=n.useState(!1),[j,C]=n.useState(null),[I,v]=n.useState(null),D=n.useCallback(m=>{o&&v(m)},[o]),{mapContainerRef:W,mapRef:f,mapReady:w,mapVersion:E}=St({disabled:u,height:d,onMapClick:o?D:void 0,showZoomControls:b}),S=n.useRef(o);S.current=o;const{result:A}=Lt({mapRef:f,coordinate:I,enabled:!!o});n.useEffect(()=>{var m;A&&((m=S.current)==null||m.call(S,A))},[A]);const B=n.useCallback((m,i)=>{L==null||L(m,i);const N=f.current;if(N&&_){const V=(m==null?void 0:m.id)??null;zr(N,V)}C(i&&m?{x:i.point.x,y:i.point.y}:null)},[L,f,_]),R=n.useCallback(m=>{T==null||T(m);const i=f.current;if(i&&_){const N=(m==null?void 0:m.map(V=>V.id).filter(V=>V!==void 0))??[];Zr(i,N)}},[T,f,_]),{hoveredFeature:z}=Cn({mapRef:f,layerIds:Ur,sourceId:oe,enabled:_&&!u,hoverable:c,selectable:g,onHover:B,onSelect:R});n.useEffect(()=>{const m=f.current;if(!m)return;const i=()=>{try{const N=m.getSource(oe);if(N?N.setData(P):m.addSource(oe,{type:"geojson",data:P}),m.getLayer(Qe)||m.addLayer({id:Qe,type:"fill",source:oe,layout:{visibility:"visible"},paint:{"fill-color":ve("fillColor",O.fillColor),"fill-opacity":ve("fillOpacity",O.fillOpacity)}}),m.getLayer(et)||m.addLayer({id:et,type:"line",source:oe,layout:{visibility:"visible"},paint:{"line-color":ve("lineColor",O.lineColor),"line-width":ve("lineWidth",O.lineWidth)}}),m.getLayer(Et)||m.addLayer({id:Et,type:"circle",source:oe,layout:{visibility:"visible"},paint:{"circle-radius":["+",ve("pointRadius",O.pointRadius),ve("pointStrokeWidth",O.pointStrokeWidth)],"circle-color":ve("pointStrokeColor",O.pointStrokeColor)}}),m.getLayer(tt)||m.addLayer({id:tt,type:"circle",source:oe,layout:{visibility:"visible"},paint:{"circle-radius":ve("pointRadius",O.pointRadius),"circle-color":ve("pointColor",O.pointColor)}}),qr(m,O),$(!0),t){const V=wt(P);V&&m.fitBounds(V,{padding:r,maxZoom:16,duration:300})}m.resize(),m.triggerRepaint()}catch{}};return m.isStyleLoaded()?i():m.once("load",i),()=>{m.off("load",i),$(!1),Yr(m)}},[P,E]);const K=n.useRef(F);return K.current=F,n.useEffect(()=>{const m=f.current;if(!m||!w)return;const i=()=>{m.getSource(Te)||m.addSource(Te,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),m.getLayer(lt)||m.addLayer({id:lt,type:"symbol",source:Te,layout:{"text-field":["get","_label"],"text-size":16,"text-anchor":"left","text-offset":[1.2,0],"text-allow-overlap":!0,"text-optional":!1},paint:{"text-color":Kt,"text-halo-color":Ut,"text-halo-width":2}})};return m.isStyleLoaded()?i():m.once("load",i),()=>{m.off("load",i);try{m.getLayer(lt)&&m.removeLayer(lt),m.getSource(Te)&&m.removeSource(Te)}catch{}}},[E]),n.useEffect(()=>{const m=f.current,i=K.current;if(!m||!w||!i)return;const N=P&&P.features.length>0?{type:"FeatureCollection",features:P.features.map(G=>({...G,properties:{...G.properties,_label:i(G)??""}}))}:{type:"FeatureCollection",features:[]},V=()=>{const G=m.getSource(Te);G&&G.setData(N)};m.isStyleLoaded()?V():m.once("load",V)},[E,P]),l.jsxs("div",{ref:W,className:[Nt.mapContainer,p].filter(Boolean).join(" "),children:[a&&l.jsx(xt,{}),!u&&l.jsx(Tt,{mapRef:f,visible:k}),c&&z&&j&&l.jsx(lr,{feature:z,position:j,hoverContent:h})]})}const cr=({data:e,onChange:t,annotations:r,getError:s=void 0})=>{const{getId:a}=Z.useIdProvider(),d=(u,c,g)=>{const L=[...e.features.slice(0,u),{...e.features[u],properties:{...e.features[u].properties,[c]:g}},...e.features.slice(u+1)];t({...e,features:L})},p=(u,c)=>s==null?void 0:s(`features[${u}].properties.${c}`);return e.features.map((u,c)=>l.jsx(Z.Box,{children:r.map(g=>{var L,T;return l.jsxs(Z.Box,{children:[l.jsxs(Z.Box,{horizontal:!0,width:"full",align:"center",gap:8,children:[l.jsxs("span",{children:["#",(L=u.properties)==null?void 0:L.nummer]}),l.jsx(Z.Box,{grow:!0,children:l.jsx(Z.TextInput,{id:a("features",c,"properties",g.name),value:(T=u.properties)==null?void 0:T[g.name],size:"full",onChange:h=>{d(c,g.name,h)}})})]}),p(c,g.name)&&l.jsx(Z.ValidationMessage,{children:p(c,g.name)},g.name)]},g.name)})},c))},Mn=(e,t,r=void 0,s=void 0,a=void 0)=>{const d=r??e.touchedState,p=s??e.validationErrors,u=a??e.showUntouchedValidationErrors;return!(d!=null&&d[t])&&!u||!(p!=null&&p[t])?null:p[t]},Tn=e=>t=>Mn(e,t);function Fn({label:e,description:t,required:r,optional:s,annotations:a,value:d,onChange:p,error:u,...c}){const g=Tn({touchedState:c.touchedState,validationErrors:c.validationErrors,showUntouchedValidationErrors:c.showUntouchedValidationErrors});return l.jsxs("div",{children:[e&&l.jsx(Z.Label,{children:l.jsx(Z.LabelContent,{text:e,required:r,optional:s})}),t&&l.jsx(Z.Field.Description,{children:t}),l.jsx(pt,{value:d,onChange:p,...c}),a&&d&&p&&l.jsx(cr,{data:d,onChange:p,annotations:a,getError:g}),u&&l.jsx(Z.ValidationMessage,{children:u})]})}function In({mapRef:e,currentValue:t,disabled:r=!1,onDirectionChange:s}){const a=n.useRef(null),d=n.useRef(null),p=n.useRef(null),u=n.useRef(null),c=n.useRef(!1),g=n.useRef(0),L=n.useRef(r),T=n.useRef(t);T.current=t;const h=n.useRef(s);h.current=s,n.useEffect(()=>{L.current=r},[r]);const o=n.useCallback(()=>{if(d.current)return d.current;if(typeof document>"u")return;const{container:b,compass:F,handle:O}=sr();p.current=F,u.current=O;const P=v=>{const D=e.current,W=T.current.coordinate;if(!D||!W)return 0;const f=D.project([W.longitude,W.latitude]),w=D.getContainer().getBoundingClientRect(),E=v.clientX-w.left,S=v.clientY-w.top,A=E-f.x,B=f.y-S;return Ue(Math.atan2(A,B)*180/Math.PI)},_=v=>{var f;if(L.current)return;c.current=!0,v.currentTarget.setPointerCapture(v.pointerId),v.stopPropagation(),v.preventDefault();const D=P(v),W=Math.round(D);(f=h.current)==null||f.call(h,{...T.current,direction:W})},$=v=>{var f;if(!c.current)return;const D=P(v),W=Math.round(D);(f=h.current)==null||f.call(h,{...T.current,direction:W})},j=v=>{c.current&&(c.current=!1,g.current=Date.now(),v.currentTarget.releasePointerCapture(v.pointerId),v.stopPropagation(),v.preventDefault())},C=v=>{v.stopPropagation()};for(const v of[F,O])v.addEventListener("pointerdown",_),v.addEventListener("pointermove",$),v.addEventListener("pointerup",j),v.addEventListener("mousedown",C),v.addEventListener("click",C);const I=T.current.direction??0;return ut(F,O,I),d.current=b,b},[e]);n.useEffect(()=>{const b=p.current,F=u.current;!b||!F||ut(b,F,t.direction??0)},[t.direction]),n.useEffect(()=>{const b=e.current;if(!b)return;const F=t.coordinate;if(!F){a.current&&(a.current.remove(),a.current=null);return}if(a.current)a.current.setLngLat([F.longitude,F.latitude]);else{const O=o();a.current=new Pe.Marker({element:O,anchor:"center"}).setLngLat([F.longitude,F.latitude]).addTo(b)}},[t.coordinate,o,e]);const k=n.useCallback(()=>c.current||Date.now()-g.current<200,[]);return{markerRef:a,wasRecentlyDragging:k}}function An({mapRef:e,coordinate:t,disabled:r=!1}){const s=n.useRef(null);return n.useEffect(()=>{var p;const a=e.current;if(!a)return;if(!t){(p=s.current)==null||p.remove(),s.current=null;return}const d=[t.longitude,t.latitude];s.current?s.current.setLngLat(d):s.current=new Pe.Marker().setLngLat(d).addTo(a)},[t,e]),n.useEffect(()=>{var d;const a=(d=s.current)==null?void 0:d.getElement();a&&(a.style.pointerEvents=r?"none":"")},[r]),n.useEffect(()=>()=>{var a;(a=s.current)==null||a.remove(),s.current=null},[]),{markerRef:s}}H.BUILT_IN_LAYERS=Wt,H.BaseLayersContext=Ze,H.BaseLayersProvider=wr,H.BuiltInLayersContext=Je,H.BuiltInLayersProvider=Ir,H.CoordinateDirectionField=wn,H.CoordinateField=En,H.CustomLayersContext=Xe,H.CustomLayersProvider=Or,H.DEFAULT_BOUNDS=ht,H.DEFAULT_CENTER=kt,H.DEFAULT_ZOOM=mt,H.EMPTY_STYLE=Dt,H.GeoJsonAnnotater=cr,H.GeoJsonEditor=pt,H.GeoJsonViewer=xn,H.KARTVERKET_TOPO_BASE_LAYER=Bt,H.LayerToggle=xt,H.MapCenterAction=Tt,H.MapField=Fn,H.STYRBORD_KART_TRANSLATIONS_NAMESPACE=jt,H.StyrbordKartTranslations=sn,H.ViewBoundsContext=vt,H.ViewBoundsProvider=Sr,H.WmsCatalogLayersContext=We,H.WmsCatalogLayersProvider=Wr,H.buildGetFeatureInfoUrl=Qt,H.clampDirection=Ue,H.clampLatitude=Ye,H.clampLongitude=qe,H.createSimpleLayer=Tr,H.isLayerIncluded=Jt,H.roundToDecimals=gt,H.useCompassMarker=In,H.useMapLayers=ar,H.useMaplibreMap=St,H.usePointMarker=An,H.useWmsFeatureInfo=Lt,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));
|
|
35
|
+
</svg>`}const tr=35,rr=12,nr=50;function ut(e,t,r){const s=r*Math.PI/180;e.style.transform=`rotate(${r}deg)`,t.style.left=`${nr+Math.sin(s)*tr-rr}px`,t.style.top=`${nr-Math.cos(s)*tr-rr}px`}function sr(){const e=document.createElement("div");e.style.width="100px",e.style.height="100px",e.style.pointerEvents="none";const t=document.createElement("div");t.innerHTML=Qr(),t.style.position="absolute",t.style.left="30px",t.style.top="30px",t.style.width="40px",t.style.height="40px",t.style.cursor="grab",t.style.pointerEvents="auto",e.appendChild(t);const r=document.createElement("img");return r.src=Xr,r.width=24,r.height=24,r.style.position="absolute",r.style.cursor="grab",r.style.userSelect="none",r.style.pointerEvents="auto",r.draggable=!1,e.appendChild(r),{container:e,compass:t,handle:r}}const en=`0 0 0 3px ${zt}`,tn="none";function Ct(e,t){const r=e.querySelector("div");r&&(r.style.outline=t?`2px solid ${Me}`:"none",r.style.outlineOffset=t?"2px":"",r.style.borderRadius=t?"50%":"",r.style.boxShadow=t?en:tn)}function rn({mapRef:e,mapReady:t,disabled:r,activeMode:s,singleFeature:a=!1,onChange:d,onSelect:p}){const u=n.useRef([]),c=n.useRef([]),[g,L]=n.useState(null),T=n.useRef(null),h=n.useRef(!1),o=n.useRef(s);o.current=s;const k=n.useRef(r);k.current=r;const b=n.useRef(d);b.current=d;const F=n.useRef(p);F.current=p,T.current=g;const O=n.useRef(a);O.current=a;const P=n.useCallback(f=>{const w=e.current;if(!w||typeof document>"u")return;const{container:E,compass:S,handle:A}=sr(),[B,R]=f.geometry.coordinates,z=f.properties.direction??0;ut(S,A,z);let K=!1,m=null,i=null,N=!1;const V=()=>u.current.find(Y=>Y.properties.id===f.properties.id),G=Y=>{const Q=V();if(!w||!Q)return 0;const[Ee,Ce]=Q.geometry.coordinates,ce=w.project([Ee,Ce]),re=w.getContainer().getBoundingClientRect(),be=Y.clientX-re.left,Ae=Y.clientY-re.top,Se=be-ce.x,Ft=ce.y-Ae;return Ue(Math.atan2(Se,Ft)*180/Math.PI)},fe=Y=>{if(k.current)return;N=!0,Y.currentTarget.setPointerCapture(Y.pointerId),Y.stopPropagation(),Y.preventDefault(),_(f.properties.id);const Q=Math.round(G(Y));$(f.properties.id,Q)},ke=Y=>{if(!N)return;const Q=Math.round(G(Y));$(f.properties.id,Q)},q=Y=>{var Q;N&&(N=!1,Y.currentTarget.releasePointerCapture(Y.pointerId),Y.stopPropagation(),Y.preventDefault(),(Q=b.current)==null||Q.call(b))},ie=Y=>{if(k.current)return;Y.stopPropagation(),Y.preventDefault(),_(f.properties.id),K=!0,Y.currentTarget.setPointerCapture(Y.pointerId);const Q=w.getContainer().getBoundingClientRect(),Ee=Y.clientX-Q.left,Ce=Y.clientY-Q.top;m=w.unproject([Ee,Ce]);const ce=V();ce&&(i=[ce.geometry.coordinates[0],ce.geometry.coordinates[1]]),w.dragPan.disable()},me=Y=>{if(!K||!m||!i)return;const Q=w.getContainer().getBoundingClientRect(),Ee=Y.clientX-Q.left,Ce=Y.clientY-Q.top,ce=w.unproject([Ee,Ce]),re=ce.lng-m.lng,be=ce.lat-m.lat,Ae=i[0]+re,Se=i[1]+be;j(f.properties.id,Ae,Se)},Fe=Y=>{var Q;K&&(K=!1,m=null,i=null,Y.currentTarget.releasePointerCapture(Y.pointerId),Y.stopPropagation(),Y.preventDefault(),w.dragPan.enable(),(Q=b.current)==null||Q.call(b))},Ie=Y=>{Y.stopPropagation()};A.addEventListener("pointerdown",fe),A.addEventListener("pointermove",ke),A.addEventListener("pointerup",q),A.addEventListener("mousedown",Ie),A.addEventListener("click",Ie),S.addEventListener("pointerdown",ie),S.addEventListener("pointermove",me),S.addEventListener("pointerup",Fe),S.addEventListener("mousedown",Ie),S.addEventListener("click",Ie);const ft=new Pe.Marker({element:E,anchor:"center"}).setLngLat([B,R]).addTo(w),le={featureId:f.properties.id,marker:ft,compass:S,handle:A,container:E};c.current.push(le)},[e]),_=n.useCallback(f=>{var A;const w=T.current;if(w){const B=c.current.find(R=>R.featureId===w);B&&Ct(B.container,!1)}L(f);const E=c.current.find(B=>B.featureId===f);E&&Ct(E.container,!0);const S=u.current.find(B=>B.properties.id===f);(A=F.current)==null||A.call(F,S??null)},[]),$=n.useCallback((f,w)=>{u.current=u.current.map(S=>S.properties.id===f?{...S,properties:{...S.properties,direction:w}}:S);const E=c.current.find(S=>S.featureId===f);E&&ut(E.compass,E.handle,w)},[]),j=n.useCallback((f,w,E)=>{u.current=u.current.map(A=>A.properties.id===f?{...A,geometry:{...A.geometry,coordinates:[w,E]}}:A);const S=c.current.find(A=>A.featureId===f);S&&S.marker.setLngLat([w,E])},[]);n.useEffect(()=>{const f=e.current;if(!f||!t||r)return;const w=E=>{var R;if(o.current!=="directional-point")return;h.current=!0;let S=0;if(O.current&&u.current.length>0){S=u.current[0].properties.direction;for(const z of c.current)z.marker.remove();c.current=[],u.current=[],L(null)}const A=yt(),B={type:"Feature",geometry:{type:"Point",coordinates:[E.lngLat.lng,E.lngLat.lat]},properties:{id:A,direction:O.current?S:0,mode:"directional-point"}};u.current=[...u.current,B],P(B),(R=b.current)==null||R.call(b)};return f.on("click",w),()=>{f.off("click",w)}},[e,t,r,P]);const C=n.useCallback(()=>{var w;const f=T.current;if(f){const E=c.current.find(S=>S.featureId===f);E&&Ct(E.container,!1)}L(null),(w=F.current)==null||w.call(F,null)},[]),I=n.useCallback(()=>{var E,S;const f=T.current;if(!f)return;const w=c.current.find(A=>A.featureId===f);w&&w.marker.remove(),c.current=c.current.filter(A=>A.featureId!==f),u.current=u.current.filter(A=>A.properties.id!==f),L(null),(E=F.current)==null||E.call(F,null),(S=b.current)==null||S.call(b)},[]),v=n.useCallback(()=>u.current,[]),D=n.useCallback(f=>{if(!h.current){h.current=!0,u.current=f;for(const w of f)c.current.some(E=>E.featureId===w.properties.id)||P(w)}},[P]),W=n.useCallback(f=>{for(const w of c.current)w.marker.remove();if(c.current=[],u.current=[],L(null),h.current=!1,f.length!==0){u.current=f,h.current=!0;for(const w of f)P(w)}},[P]);return n.useEffect(()=>()=>{for(const f of c.current)f.marker.remove();c.current=[]},[]),{hasSelection:g!==null,deleteSelected:I,getFeatures:v,loadFeatures:D,replaceFeatures:W,deselect:C}}const nn={"nb-NO":{drawMode:{directionalPoint:"Tegn retningspunkt",linestring:"Tegn linje",point:"Tegn punkt",polygon:"Tegn polygon"},fields:{direction:"Retning (grader)",directionPlaceholder:"0–360",latitude:"Breddegrad",latitudePlaceholder:"f.eks. 63.4305",longitude:"Lengdegrad",longitudePlaceholder:"f.eks. 10.3951"},layers:{backgroundMaps:"Bakgrunnskart",defaultCategory:"Lag",filterAriaLabel:"Filtrer kartlag",hide:"Skjul kartlag",noLayersAvailable:"Ingen kartlag tilgjengelig",noResults:"Ingen lag samsvarer med søket",searchPlaceholder:"Søk etter lag…",show:"Vis kartlag",toggleButtonLabel:"Kartlag"},mapCenterAction:{ariaLabel:"Velg i sentrum av kartet",buttonText:"Velg her"},toolbar:{delete:"Slett valgt",import:"Importer GeoJSON",select:"Velg/rediger"}},"nn-NO":{drawMode:{directionalPoint:"Teikn retningspunkt",linestring:"Teikn linje",point:"Teikn punkt",polygon:"Teikn polygon"},fields:{direction:"Retning (grader)",directionPlaceholder:"0–360",latitude:"Breiddegrad",latitudePlaceholder:"t.d. 63.4305",longitude:"Lengdegrad",longitudePlaceholder:"t.d. 10.3951"},layers:{backgroundMaps:"Bakgrunnskart",defaultCategory:"Lag",filterAriaLabel:"Filtrer kartlag",hide:"Skjul kartlag",noLayersAvailable:"Ingen kartlag tilgjengelege",noResults:"Ingen lag samsvarar med søket",searchPlaceholder:"Søk etter lag…",show:"Vis kartlag",toggleButtonLabel:"Kartlag"},mapCenterAction:{ariaLabel:"Vel i sentrum av kartet",buttonText:"Vel her"},toolbar:{delete:"Slett valt",import:"Importer GeoJSON",select:"Vel/rediger"}},"en-US":{drawMode:{directionalPoint:"Draw directional point",linestring:"Draw line",point:"Draw point",polygon:"Draw polygon"},fields:{direction:"Direction (degrees)",directionPlaceholder:"0–360",latitude:"Latitude",latitudePlaceholder:"e.g. 63.4305",longitude:"Longitude",longitudePlaceholder:"e.g. 10.3951"},layers:{backgroundMaps:"Background maps",defaultCategory:"Layers",filterAriaLabel:"Filter map layers",hide:"Hide map layers",noLayersAvailable:"No map layers available",noResults:"No layers match the search",searchPlaceholder:"Search for layers…",show:"Show map layers",toggleButtonLabel:"Map layers"},mapCenterAction:{ariaLabel:"Select at the center of the map",buttonText:"Select here"},toolbar:{delete:"Delete selected",import:"Import GeoJSON",select:"Select/edit"}}},jt="styrbord-kart",sn=e=>l.jsx(It.NamespaceProvider,{ns:jt,translations:nn,children:e.children}),Ve=It.useTranslation.bind(null,jt),on=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"M480-96Q323.03-227.11 245.51-339.55 168-452 168-549q0-134 89-224.5T480-864q12 0 24 .5t24 2.31V-788q-11-2-23-3t-25-1q-103 0-171.5 69T240-549q0 71 60.5 161T480-191q119-107 179.5-197T720-549v-13.5q0-6.75-1-13.5h72q1 7 1 13.67V-549q0 97-77 209T480-96Zm51-405.21q21-21.21 21-51T530.79-603q-21.21-21-51-21T429-602.79q-21 21.21-21 51T429.21-501q21.21 21 51 21T531-501.21ZM480-552Zm240-96h72v-120h120v-72H792v-120h-72v120H600v72h120v120Z"})}),an=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"M119.79-240Q90-240 69-261.21t-21-51Q48-342 69.04-363t50.59-21q5.37 0 9.87.5 4.5.5 9.5 1.5l200-199.52q-2-5.48-2.5-9.48t-.5-9.37q0-29.55 21.21-50.59 21.21-21.04 51-21.04T459-650.85q21 21.15 21 50.85 0 3-3 18l104.86 105q5.14-2 9-2.5 3.85-.5 9-.5 5.14 0 9.64.5 4.5.5 9.5 1.5l152-151.66q-2-5.34-2.5-9.34t-.5-9.37q0-29.55 21.21-50.59 21.21-21.04 51-21.04T891-698.79q21 21.21 21 51T890.96-597q-21.04 21-50.59 21-5.37 0-9.87-.5-4.5-.5-9.5-1.5L669-426.34q2 5.34 2.5 9.34t.5 9.37q0 29.55-21.21 50.59-21.21 21.04-51 21.04T549-357.04q-21-21.04-21-50.59 0-5.37.5-9.87.5-4.5 1.5-9.5L426.09-531q-5.09 2-9.09 2.5t-9 .5q-5 0-19-2L189-330.48q2 5.48 2.5 9.48t.5 9.37q0 29.55-21.21 50.59-21.21 21.04-51 21.04Z"})}),ln=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"M306-168h349l123-356-298-205-298 205 124 356Zm-52 72L96-552l384-264 384 264L706-96H254Zm226-353Z"})}),cn=()=>l.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:l.jsx("path",{d:"M5,3 L5,19 L10,15 L14,21 L16,20 L12,14 L18,14 Z"})}),un=()=>l.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("polyline",{points:"3,6 5,6 21,6"}),l.jsx("path",{d:"M6,6 L6,20 C6,21.1 6.9,22 8,22 L16,22 C17.1,22 18,21.1 18,20 L18,6"}),l.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),l.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"}),l.jsx("path",{d:"M9,6 L9,4 C9,3.4 9.4,3 10,3 L14,3 C14.6,3 15,3.4 15,4 L15,6"})]}),dn=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"m312-312 264-72 72-264-264 72-72 264Zm168-120q-20 1-34-13.5T432-480q0-20 14-34t34-14q20 0 34 14t14 34q0 20-14 34t-34 14Zm.28 336Q401-96 331-126t-122.5-82.5Q156-261 126-330.96t-30-149.5Q96-560 126-629.5q30-69.5 82.5-122T330.96-834q69.96-30 149.5-30t149.04 30q69.5 30 122 82.5T834-629.28q30 69.73 30 149Q864-401 834-331t-82.5 122.5Q699-156 629.28-126q-69.73 30-149 30Zm-.05-72Q610-168 701-259.23t91-221Q792-610 700.77-701t-221-91Q350-792 259-700.77t-91 221Q168-350 259.23-259t221 91ZM480-480Z"})}),pn=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",fill:"currentColor",children:l.jsx("path",{d:"M440-200h80v-167l64 64 56-57-160-160-160 160 57 56 63-63v167ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"})}),fn={point:on,linestring:an,polygon:ln,"directional-point":dn},or={point:"drawMode.point",linestring:"drawMode.linestring",polygon:"drawMode.polygon","directional-point":"drawMode.directionalPoint"};function gn(e){let t;try{t=JSON.parse(e)}catch(s){return{ok:!1,reason:"invalid-json",detail:s instanceof Error?s.message:String(s)}}if(typeof t!="object"||t===null)return{ok:!1,reason:"not-geojson",detail:`Expected a JSON object but got ${t===null?"null":typeof t}`};const r=t;if(r.type==="FeatureCollection"&&Array.isArray(r.features)){const s=r;return s.features.length===0?{ok:!1,reason:"empty-collection",detail:"FeatureCollection contains no features"}:{ok:!0,data:s}}return r.type==="Feature"&&r.geometry?{ok:!0,data:{type:"FeatureCollection",features:[r]}}:typeof r.type=="string"&&(r.coordinates||r.geometries)&&!r.features?{ok:!0,data:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:r}]}}:{ok:!1,reason:"not-geojson",detail:`Unrecognised GeoJSON type: ${typeof r.type=="string"?r.type:"(missing)"}`}}function yn({modes:e,activeMode:t,hasSelection:r,deletable:s,editable:a,onSetMode:d,onDelete:p,onImport:u,onImportError:c}){const{t:g}=Ve(),L=n.useRef(null),T=h=>{var b;const o=(b=h.target.files)==null?void 0:b[0];if(!o)return;const k=new FileReader;k.onload=()=>{const F=k.result;if(typeof F!="string")return;const O=gn(F);O.ok?u(O.data):(console.warn(`GeoJsonEditor: import failed (${O.reason}) — ${O.detail}`),c==null||c(O.reason,O.detail))},k.onerror=()=>{var O;const F=((O=k.error)==null?void 0:O.message)??"Unknown read error";console.warn(`GeoJsonEditor: failed to read file — ${F}`),c==null||c("invalid-json",F)},k.readAsText(o),h.target.value=""};return l.jsxs("div",{className:ue.toolbar,children:[l.jsx("input",{ref:L,type:"file",accept:".geojson,.json,application/geo+json,application/json",style:{display:"none"},onChange:T}),e.map(h=>{const o=fn[h],k=t===h;return l.jsx("button",{type:"button",title:g(or[h]),"aria-label":g(or[h]),"aria-pressed":k,className:[ue.toolbarButton,k&&ue.active].filter(Boolean).join(" "),onClick:()=>d(k?"static":h),children:l.jsx(o,{})},h)}),l.jsx("div",{className:ue.toolbarDivider}),l.jsx("button",{type:"button",title:g("toolbar.import"),"aria-label":g("toolbar.import"),className:ue.toolbarButton,onClick:()=>{var h;return(h=L.current)==null?void 0:h.click()},children:l.jsx(pn,{})}),a&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:ue.toolbarDivider}),l.jsx("button",{type:"button",title:g("toolbar.select"),"aria-label":g("toolbar.select"),"aria-pressed":t==="select",className:[ue.toolbarButton,t==="select"&&ue.active].filter(Boolean).join(" "),onClick:()=>d(t==="select"?"static":"select"),children:l.jsx(cn,{})})]}),s&&r&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:ue.toolbarDivider}),l.jsx("button",{type:"button",title:g("toolbar.delete"),"aria-label":g("toolbar.delete"),className:[ue.toolbarButton,ue.danger].join(" "),onClick:p,children:l.jsx(un,{})})]})]})}function ar(){const e=n.useContext(Ze),t=n.useContext(Je),r=n.useContext(Xe),s=n.useContext(We),a=n.useMemo(()=>new Set(t.availableLayers.map(o=>o.id)),[t.availableLayers]),d=n.useMemo(()=>new Set(r.layers.map(o=>o.id)),[r.layers]),p=n.useMemo(()=>new Set(s.layers.map(o=>o.id)),[s.layers]),u=n.useMemo(()=>{const o=[];for(const k of t.availableLayers)o.push({definition:k,visible:t.visibleLayerIds.has(k.id),origin:"built-in"});for(const k of r.layers)o.push({definition:k,visible:r.visibleLayerIds.has(k.id),origin:"custom"});for(const k of s.layers)o.push({definition:k,visible:s.visibleLayerIds.has(k.id),origin:"wms-catalog"});return o},[t.availableLayers,t.visibleLayerIds,r.layers,r.visibleLayerIds,s.layers,s.visibleLayerIds]),c=n.useMemo(()=>u.filter(o=>o.visible),[u]),g=o=>a.has(o)?(t.toggleLayer(o),!0):d.has(o)?(r.toggleLayer(o),!0):p.has(o)?(s.toggleLayer(o),!0):!1,L=o=>a.has(o)?(t.showLayer(o),!0):d.has(o)?(r.showLayer(o),!0):p.has(o)?(s.showLayer(o),!0):!1,T=o=>a.has(o)?(t.hideLayer(o),!0):d.has(o)?(r.hideLayer(o),!0):p.has(o)?(s.hideLayer(o),!0):!1,h=o=>a.has(o)?t.isVisible(o):d.has(o)?r.isVisible(o):p.has(o)?s.isVisible(o):!1;return{availableBaseLayers:e.availableBaseLayers,activeBaseLayerId:e.activeBaseLayerId,setActiveBaseLayer:e.setActiveBaseLayer,allLayers:u,visibleLayers:c,toggleLayer:g,showLayer:L,hideLayer:T,isVisible:h}}const ae={root:"_root_lgvrt_1",toggleButton:"_toggleButton_lgvrt_13",toggleButtonIcon:"_toggleButtonIcon_lgvrt_34",panel:"_panel_lgvrt_40",filterWrapper:"_filterWrapper_lgvrt_51",filterInput:"_filterInput_lgvrt_56",categoryHeading:"_categoryHeading_lgvrt_78",chevron:"_chevron_lgvrt_99",layerItem:"_layerItem_lgvrt_105",checkbox:"_checkbox_lgvrt_120",radio:"_radio_lgvrt_128",emptyMessage:"_emptyMessage_lgvrt_136"};function kn({className:e}){return l.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("polygon",{points:"12 2 2 7 12 12 22 7 12 2"}),l.jsx("polyline",{points:"2 17 12 22 22 17"}),l.jsx("polyline",{points:"2 12 12 17 22 12"})]})}function mn({expanded:e,className:t}){return l.jsx("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{transform:e?"rotate(90deg)":void 0,transition:"transform 150ms ease"},children:l.jsx("polyline",{points:"6 4 10 8 6 12"})})}function Mt({className:e,defaultOpen:t=!1}){const{t:r}=Ve(),[s,a]=n.useState(t),[d,p]=n.useState(""),[u,c]=n.useState(new Set),{allLayers:g,toggleLayer:L,availableBaseLayers:T,activeBaseLayerId:h,setActiveBaseLayer:o}=ar(),k=n.useRef(null),b=T.length>1,F=n.useCallback(v=>{c(D=>{const W=new Set(D);return W.has(v)?W.delete(v):W.add(v),W})},[]),O=d.trim().toLowerCase(),P=n.useMemo(()=>O?T.filter(v=>v.label.toLowerCase().includes(O)):T,[T,O]),_=n.useMemo(()=>{const v=new Map;for(const D of g){if(O&&!D.definition.label.toLowerCase().includes(O))continue;const W=D.definition.category??r("layers.defaultCategory"),f=v.get(W);f?f.push(D):v.set(W,[D])}return v},[g,O,r]),$=n.useCallback(v=>O?!0:u.has(v),[O,u]),j=[ae.root,e].filter(Boolean).join(" "),C=b&&P.length>0,I=_.size>0||C;return g.length===0&&!b?null:l.jsxs("div",{className:j,children:[l.jsxs("button",{type:"button",className:ae.toggleButton,onClick:()=>a(v=>!v),"aria-expanded":s,"aria-label":r(s?"layers.hide":"layers.show"),title:r(s?"layers.hide":"layers.show"),children:[l.jsx(kn,{className:ae.toggleButtonIcon}),r("layers.toggleButtonLabel")]}),s&&l.jsxs("div",{className:ae.panel,ref:k,role:"group",children:[l.jsx("div",{className:ae.filterWrapper,children:l.jsx("input",{type:"text",className:ae.filterInput,placeholder:r("layers.searchPlaceholder"),value:d,onChange:v=>p(v.target.value),"aria-label":r("layers.filterAriaLabel")})}),I?l.jsxs(l.Fragment,{children:[C&&l.jsxs("div",{children:[l.jsx("span",{className:ae.categoryHeading,children:r("layers.backgroundMaps")}),P.map(v=>l.jsxs("label",{className:ae.layerItem,children:[l.jsx("input",{type:"radio",className:ae.radio,name:"base-layer",checked:v.id===h,onChange:()=>o(v.id)}),v.label]},v.id))]}),Array.from(_.entries()).map(([v,D])=>{const W=_.size>1||C,f=$(v);return l.jsxs("div",{children:[W?l.jsxs("button",{type:"button",className:ae.categoryHeading,onClick:()=>F(v),"aria-expanded":f,children:[l.jsx(mn,{expanded:f,className:ae.chevron}),v]}):null,(!W||f)&&D.map(w=>l.jsxs("label",{className:ae.layerItem,children:[l.jsx("input",{type:"checkbox",className:ae.checkbox,checked:w.visible,onChange:()=>L(w.definition.id)}),w.definition.label]},w.definition.id))]},v)})]}):l.jsx("div",{className:ae.emptyMessage,children:r(O?"layers.noResults":"layers.noLayersAvailable")})]})]})}const hn=e=>e.reduce((t,r)=>{var a;const s=parseInt(String(((a=r.properties)==null?void 0:a.nummer)??0));return s>t?s:t},0),ir=e=>{let t=hn(e.features)+1;return{...e,features:e.features.filter(r=>{var s,a,d;return r.geometry.type==="Point"&&((s=r.geometry.coordinates)==null?void 0:s.length)>0||r.geometry.type==="Polygon"&&((a=r.geometry.coordinates[0][0])==null?void 0:a.length)>0||r.geometry.type==="LineString"&&((d=r.geometry.coordinates[0])==null?void 0:d.length)>0}).map(r=>{var d,p;const s=((d=r.properties)==null?void 0:d.nummer)??t++,a=((p=r.properties)==null?void 0:p.id)??yt();return{...r,properties:{...r.properties,id:a,nummer:s}}})}},$e={popup:"_popup_e7e0k_1",defaultContent:"_defaultContent_e7e0k_17",featureType:"_featureType_e7e0k_23",featureName:"_featureName_e7e0k_28"};function lr({feature:e,position:t,hoverContent:r}){var c;const s=((c=e.properties)==null?void 0:c.type)??"_",a=s?r==null?void 0:r[s]:void 0,d=a?a(e):l.jsx(vn,{feature:e});return l.jsx("div",{className:$e.popup,style:{left:t.x+12,top:t.y+12},role:"tooltip","aria-live":"polite",children:d})}function vn({feature:e}){var s,a,d;const t=(s=e.properties)==null?void 0:s.type,r=(a=e.properties)==null?void 0:a.name;return l.jsxs("div",{className:$e.defaultContent,children:[t&&l.jsx("span",{className:$e.featureType,children:String(t)}),r&&l.jsx("span",{className:$e.featureName,children:String(r)}),!t&&!r&&l.jsx("span",{className:$e.featureType,children:((d=e.geometry)==null?void 0:d.type)??"Feature"})]})}const xt={crosshair:"_crosshair_mxy17_1",crosshairSvg:"_crosshairSvg_mxy17_11",actionButton:"_actionButton_mxy17_18"};function _n(){return l.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none","aria-hidden":"true",className:xt.crosshairSvg,children:[l.jsx("line",{x1:"0",y1:"20",x2:"16",y2:"20",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("line",{x1:"24",y1:"20",x2:"40",y2:"20",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("line",{x1:"20",y1:"0",x2:"20",y2:"16",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("line",{x1:"20",y1:"24",x2:"20",y2:"40",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("circle",{cx:"20",cy:"20",r:"3",stroke:"currentColor",strokeWidth:"1.5",fill:"none"})]})}function bn(){return l.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("circle",{cx:"12",cy:"12",r:"6"}),l.jsx("circle",{cx:"12",cy:"12",r:"2"})]})}function Tt({mapRef:e,visible:t}){const[r,s]=n.useState(!1),{t:a}=Ve();if(n.useEffect(()=>{s(window.matchMedia("(pointer: coarse)").matches)},[]),!(t??r))return null;const p=()=>{const u=e.current;if(!u)return;const c=u.getCanvas(),g=c.getBoundingClientRect(),L=g.left+g.width/2,T=g.top+g.height/2,h={clientX:L,clientY:T,bubbles:!0,pointerId:1,isPrimary:!0,pointerType:"touch",button:0,buttons:1};c.dispatchEvent(new PointerEvent("pointermove",h)),c.dispatchEvent(new PointerEvent("pointerdown",h)),c.dispatchEvent(new PointerEvent("pointerup",{...h,buttons:0})),c.dispatchEvent(new MouseEvent("click",{clientX:L,clientY:T,bubbles:!0,button:0}))};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:xt.crosshair,children:l.jsx(_n,{})}),l.jsxs("button",{type:"button",className:xt.actionButton,onClick:p,"aria-label":a("mapCenterAction.ariaLabel"),children:[l.jsx(bn,{}),l.jsx("span",{children:a("mapCenterAction.buttonText")})]})]})}const Sn=["point","linestring","polygon"],Ln=e=>{var t;return(t=e.properties)!=null&&t.nummer?`#${e.properties.nummer}`:void 0},xe="geojson-editor-labels",dt="geojson-editor-label";function pt({value:e,onChange:t,modes:r=Sn,editable:s=!0,deletable:a=!0,fitBounds:d=!1,fitBoundsPadding:p=40,showLayerToggle:u=!0,height:c,className:g,disabled:L=!1,hoverable:T=!0,onHover:h,onSelect:o,hoverContent:k,onCoordinateClick:b,onImportError:F,showCenterAction:O,showZoomControls:P,singleFeature:_=!1,getLabel:$=Ln}){const{mapContainerRef:j,mapRef:C,mapReady:I,mapVersion:v}=St({disabled:L,height:c,showZoomControls:P}),[D,W]=n.useState(null),f=n.useRef("static"),[w,E]=n.useState(_?r[0]:"static"),S=n.useRef(b);S.current=b;const{result:A}=Lt({mapRef:C,coordinate:D,enabled:!!b});n.useEffect(()=>{var M;A&&((M=S.current)==null||M.call(S,A))},[A]),n.useEffect(()=>{const M=C.current;if(!M||!I||L||!S.current)return;const U=ee=>{const X=f.current;if(X==="point"||X==="linestring"||X==="polygon"||X==="directional-point")return;const{lng:ne,lat:te}=ee.lngLat;W({latitude:te,longitude:ne})};return M.on("click",U),()=>{M.off("click",U)}},[C,I,L]);const[B,R]=n.useState(null),[z,K]=n.useState(null),m=n.useRef(h);m.current=h;const i=n.useCallback(M=>{var U;(U=N.current)==null||U.deselect(),o==null||o(M)},[o]),N=n.useRef(null),V=n.useRef(()=>{}),G=n.useRef(!1),fe=r.filter(M=>M!=="directional-point").join(","),ke=n.useMemo(()=>fe.split(",").filter(Boolean),[fe]),q=Jr({mapRef:C,mapVersion:v,modes:ke,editable:s,deletable:a,disabled:L,singleFeature:_,onChange:M=>{V.current(M)},onSelect:i}),{activeMode:ie,setActiveMode:me,deleteSelected:Fe,hasSelection:Ie,isReady:ft}=q;f.current=w;const le=rn({mapRef:C,mapReady:I,disabled:L,activeMode:w,singleFeature:_,onChange:()=>{V.current()},onSelect:M=>{M&&(me("static"),o==null||o([M]))}});N.current=le;const Y=n.useCallback(M=>{if(!t)return;G.current=!0;const U=(M==null?void 0:M.features)??q.getSnapshot(),ee=le.getFeatures(),X={type:"FeatureCollection",features:[...U,...ee]};t(ir(X))},[t,q,le]);V.current=Y;const Q=n.useCallback(M=>{M==="directional-point"?me("static"):(le.deselect(),me(M)),E(M)},[me,le]);n.useEffect(()=>{E(M=>M==="directional-point"?M:ie)},[ie]);const Ee=Ie||le.hasSelection,Ce=n.useCallback(()=>{le.hasSelection?le.deleteSelected():Fe()},[le,Fe]),{replaceFeatures:ce}=q,re=n.useMemo(()=>e?ct(e):void 0,[e]),{replaceFeatures:be}=le,Ae=n.useRef($);Ae.current=$;const Se=n.useCallback(M=>{const U=C.current,ee=Ae.current;if(!U||!I||!ee)return;const X=M&&M.features.length>0?{type:"FeatureCollection",features:M.features.map(te=>({...te,properties:{...te.properties,_label:ee(te)??""}}))}:{type:"FeatureCollection",features:[]},ne=()=>{const te=U.getSource(xe);te&&te.setData(X)};U.isStyleLoaded()?ne():U.once("load",ne)},[C,I]),Ft=n.useCallback(M=>{var Ge;const U=q.getSnapshot(),ee=le.getFeatures(),X=[],ne=[];for(const Le of M.features){const he={...Le.properties};delete he.id,delete he.nummer;const _e={...Le,properties:he};((Ge=_e.properties)==null?void 0:Ge.mode)==="directional-point"?X.push(_e):ne.push(_e)}const te=[...U,...ne],Oe=[...ee,...X];ce({type:"FeatureCollection",features:te}),be(Oe);const ye={type:"FeatureCollection",features:[...te,...Oe]},He=ir(ye);t&&(G.current=!0,t(He)),Se(He);const Re=C.current;if(Re){const Le=wt(ye);Le&&Re.fitBounds(Le,{padding:p,maxZoom:16,duration:300})}},[t,q,le,ce,be,Se,C,p]);n.useEffect(()=>{var ee;if(!ft){G.current=!1;return}if(G.current){G.current=!1;return}const M=[],U=[];if(re)for(const X of re.features)((ee=X.properties)==null?void 0:ee.mode)==="directional-point"?M.push(X):U.push(X);ce({type:"FeatureCollection",features:U}),be(M)},[re,ce,be,ft]),n.useEffect(()=>{const M=C.current;if(!M||!I||!L||!re||re.features.length===0)return;const U="geojson-editor-disabled",ee="geojson-editor-disabled-fill",X="geojson-editor-disabled-line",ne="geojson-editor-disabled-point-stroke",te="geojson-editor-disabled-point",Oe=()=>{if(M.getSource(U)){M.getSource(U).setData(re);return}M.addSource(U,{type:"geojson",data:re}),M.addLayer({id:ee,type:"fill",source:U,filter:["==","$type","Polygon"],paint:{"fill-color":J,"fill-opacity":Be}}),M.addLayer({id:X,type:"line",source:U,filter:["in","$type","LineString","Polygon"],paint:{"line-color":J,"line-width":4}}),M.addLayer({id:ne,type:"circle",source:U,filter:["==","$type","Point"],paint:{"circle-radius":9,"circle-color":ge}}),M.addLayer({id:te,type:"circle",source:U,filter:["==","$type","Point"],paint:{"circle-radius":6,"circle-color":J}})};return M.isStyleLoaded()?Oe():M.once("load",Oe),()=>{try{for(const ye of[te,ne,X,ee])M.getLayer(ye)&&M.removeLayer(ye);M.getSource(U)&&M.removeSource(U)}catch{}}},[C,I,L,re]);const ur=n.useRef(!1);return n.useEffect(()=>{const M=C.current;if(!M||!I||!re||!d||ur.current)return;const U=wt(re);if(!U)return;ur.current=!0;const ee=()=>{M.fitBounds(U,{padding:p,maxZoom:16,duration:300})};M.isStyleLoaded()?ee():M.once("load",ee)},[re,d,p,C,I]),n.useEffect(()=>{const M=C.current;if(!M||!I)return;const U=()=>{M.getSource(xe)||M.addSource(xe,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),M.getLayer(dt)||M.addLayer({id:dt,type:"symbol",source:xe,layout:{"text-field":["get","_label"],"text-size":16,"text-anchor":"left","text-offset":[1.2,0],"text-allow-overlap":!0,"text-optional":!1},paint:{"text-color":Kt,"text-halo-color":Ut,"text-halo-width":2}})};return M.isStyleLoaded()?U():M.once("load",U),()=>{try{M.getLayer(dt)&&M.removeLayer(dt),M.getSource(xe)&&M.removeSource(xe)}catch{}}},[C,I]),n.useEffect(()=>{Se(re)},[Se,re]),n.useEffect(()=>{const M=C.current;if(!M||!I||L||!T)return;let U=null;const ee=ne=>{var He,Re,Ge,Le;const te=f.current;if(te==="point"||te==="linestring"||te==="polygon"||te==="directional-point"){U!==null&&(U=null,R(null),K(null),(He=m.current)==null||He.call(m,null,null),M.getCanvas().style.cursor="");return}const ye=M.queryRenderedFeatures(ne.point).find(he=>{var _e;return((_e=he.properties)==null?void 0:_e.mode)&&he.properties.mode!=="select"});if(ye){const he=ye.id??((Re=ye.properties)==null?void 0:Re.id)??null;if(he!==U){U=he;const _e={type:"Feature",id:he??void 0,geometry:ye.geometry,properties:ye.properties};R(_e),(Ge=m.current)==null||Ge.call(m,_e,ne)}K({x:ne.point.x,y:ne.point.y}),M.getCanvas().style.cursor="pointer"}else U!==null&&(U=null,R(null),K(null),(Le=m.current)==null||Le.call(m,null,null)),M.getCanvas().style.cursor=""},X=()=>{var ne;U=null,R(null),K(null),(ne=m.current)==null||ne.call(m,null,null),M.getCanvas().style.cursor=""};return M.on("mousemove",ee),M.on("mouseout",X),()=>{M.off("mousemove",ee),M.off("mouseout",X),M.getCanvas().style.cursor=""}},[C,I,L,T]),l.jsx("div",{className:[ue.editorWrapper,g].filter(Boolean).join(" "),children:l.jsxs("div",{ref:j,className:Nt.mapContainer,children:[!L&&!_&&l.jsx(yn,{modes:r,activeMode:w,hasSelection:Ee,deletable:a,editable:s,onSetMode:Q,onDelete:Ce,onImport:Ft,onImportError:F}),u&&l.jsx(Mt,{}),!L&&l.jsx(Tt,{mapRef:C,visible:O&&(w==="point"||w==="linestring"||w==="polygon"||w==="directional-point")}),T&&B&&z&&l.jsx(lr,{feature:B,position:z,hoverContent:k})]})})}function wn({value:e,onChange:t,error:r,disabled:s=!1,className:a,height:d,showCenterAction:p}){const u=n.useId(),{t:c}=Ve(),g=n.useRef(yt()),L=n.useRef((e==null?void 0:e.properties.direction)??0),T=n.useMemo(()=>{if(e)return{type:"FeatureCollection",features:[{type:"Feature",geometry:e.geometry,properties:{mode:"directional-point",direction:e.properties.direction,id:g.current}}]}},[e]),h=n.useCallback(C=>{var v,D;const I=C.features.find(W=>{var f;return((f=W.properties)==null?void 0:f.mode)==="directional-point"});if(I){(v=I.properties)!=null&&v.id&&(g.current=I.properties.id);const W=((D=I.properties)==null?void 0:D.direction)??L.current;L.current=W;const f={type:"Feature",geometry:I.geometry,properties:{direction:W}};t(f)}},[t]),[o,k]=n.useState((e==null?void 0:e.geometry.coordinates[1])??void 0),[b,F]=n.useState((e==null?void 0:e.geometry.coordinates[0])??void 0),[O,P]=n.useState((e==null?void 0:e.properties.direction)??void 0);n.useEffect(()=>{const C=e==null?void 0:e.geometry.coordinates;k(C?C[1]:void 0),F(C?C[0]:void 0),P((e==null?void 0:e.properties.direction)??void 0),(e==null?void 0:e.properties.direction)!=null&&(L.current=e.properties.direction)},[e]);const _=n.useCallback(C=>{t(C)},[t]),$=n.useCallback((C,I)=>{if(!(C==null&&I==null)&&C!=null&&I!=null){const v={type:"Feature",geometry:{type:"Point",coordinates:[qe(I),Ye(C)]},properties:{direction:(e==null?void 0:e.properties.direction)??0}};_(v)}},[e==null?void 0:e.properties.direction,_]),j=n.useCallback(C=>{if(!e)return;const I={type:"Feature",geometry:e.geometry,properties:{direction:C!=null?Math.round(Ue(C)):0}};_(I)},[e,_]);return l.jsxs(Z.Surface,{gap:4,className:[a].filter(Boolean).join(" "),children:[l.jsx(pt,{singleFeature:!0,modes:["directional-point"],value:T,onChange:h,disabled:s,height:d,showCenterAction:p}),l.jsxs(Z.Surface,{horizontal:!0,gap:4,children:[l.jsx(Z.NumberInput,{id:`${u}-lat`,inputMode:"decimal",label:c("fields.latitude"),value:o??null,disabled:s,placeholder:c("fields.latitudePlaceholder"),onChange:C=>k(C),onBlur:()=>$(o,b)}),l.jsx(Z.NumberInput,{id:`${u}-lon`,inputMode:"decimal",label:c("fields.longitude"),value:b??null,disabled:s,placeholder:c("fields.longitudePlaceholder"),onChange:C=>F(C),onBlur:()=>$(o,b)}),l.jsx(Z.NumberInput,{id:`${u}-dir`,inputMode:"decimal",label:c("fields.direction"),value:O??null,disabled:s,placeholder:c("fields.directionPlaceholder"),min:0,max:360,onChange:C=>P(C),onBlur:()=>j(O)})]}),r&&l.jsx(Z.ValidationMessage,{children:r})]})}function En({value:e,onChange:t,error:r,disabled:s=!1,className:a,height:d,showCenterAction:p}){const u=n.useId(),{t:c}=Ve(),g=n.useMemo(()=>{if(e)return{type:"FeatureCollection",features:[{type:"Feature",geometry:e.geometry,properties:{}}]}},[e]),L=n.useCallback(F=>{if(F.features.length>0){const P={type:"Feature",geometry:F.features[0].geometry};t(P)}},[t]),[T,h]=n.useState((e==null?void 0:e.geometry.coordinates[1])??void 0),[o,k]=n.useState((e==null?void 0:e.geometry.coordinates[0])??void 0);n.useEffect(()=>{const F=e==null?void 0:e.geometry.coordinates;h(F?F[1]:void 0),k(F?F[0]:void 0)},[e]);const b=n.useCallback((F,O)=>{if(!(F==null&&O==null)&&F!=null&&O!=null){const P={type:"Feature",geometry:{type:"Point",coordinates:[qe(O),Ye(F)]}};t(P)}},[t]);return l.jsxs(Z.Surface,{gap:4,className:[a].filter(Boolean).join(" "),children:[l.jsx(pt,{singleFeature:!0,modes:["point"],value:g,onChange:L,disabled:s,height:d,showCenterAction:p}),l.jsxs(Z.Surface,{horizontal:!0,gap:4,children:[l.jsx(Z.NumberInput,{id:`${u}-lat`,inputMode:"decimal",label:c("fields.latitude"),value:T??null,disabled:s,placeholder:c("fields.latitudePlaceholder"),onChange:F=>h(F),onBlur:()=>b(T,o)}),l.jsx(Z.NumberInput,{id:`${u}-lon`,inputMode:"decimal",label:c("fields.longitude"),value:o??null,disabled:s,placeholder:c("fields.longitudePlaceholder"),onChange:F=>k(F),onBlur:()=>b(T,o)})]}),r&&l.jsx(Z.ValidationMessage,{children:r})]})}function Cn({mapRef:e,layerIds:t,sourceId:r,enabled:s=!0,hoverable:a=!0,selectable:d=!0,onHover:p,onSelect:u}){const[c,g]=n.useState(null),[L,T]=n.useState([]),h=n.useRef(p);h.current=p;const o=n.useRef(u);o.current=u;const k=n.useRef(null),b=n.useCallback(_=>_.id!==void 0?_.id:JSON.stringify(_.properties),[]),F=n.useCallback((_,$)=>{const j=t.filter(I=>_.getLayer(I));return j.length===0?[]:_.queryRenderedFeatures($,{layers:j})},[t]),O=n.useCallback(()=>{var _;T([]),(_=o.current)==null||_.call(o,null)},[]),P=n.useCallback(_=>{var I;const $=e.current;if(!$)return;const C=$.querySourceFeatures(r).filter(v=>{const D=v.id??JSON.stringify(v.properties);return _.includes(D)});T(C),(I=o.current)==null||I.call(o,C.length>0?C:null)},[e,r]);return n.useEffect(()=>{const _=e.current;if(!_||!s)return;const $=I=>{var f;if(!a)return;const v=F(_,I.point),D=v.length>0?v[0]:null,W=D?b(D):null;W!==k.current&&(k.current=W,g(D),(f=h.current)==null||f.call(h,D,D?I:null),_.getCanvas().style.cursor=D?"pointer":"")},j=()=>{var I;a&&k.current!==null&&(k.current=null,g(null),(I=h.current)==null||I.call(h,null,null),_.getCanvas().style.cursor="")},C=I=>{var w;if(!d)return;const v=F(_,I.point);if(v.length===0){L.length>0&&(T([]),(w=o.current)==null||w.call(o,null));return}const D=v[0],W=b(D),f=I.originalEvent.ctrlKey||I.originalEvent.metaKey;T(E=>{let S;return f?E.some(B=>b(B)===W)?S=E.filter(B=>b(B)!==W):S=[...E,D]:E.length===1&&b(E[0])===W?S=[]:S=[D],setTimeout(()=>{var A;(A=o.current)==null||A.call(o,S.length>0?S:null)},0),S})};return _.on("mousemove",$),_.on("mouseout",j),_.on("click",C),()=>{_.off("mousemove",$),_.off("mouseout",j),_.off("click",C),_.getCanvas().style.cursor=""}},[e,s,a,d,t,F,b,L.length]),{hoveredFeature:c,selectedFeatures:L,hasSelection:L.length>0,clearSelection:O,selectByIds:P}}const Te="geojson-viewer-labels",jn=e=>{var t;return(t=e.properties)!=null&&t.nummer?`#${e.properties.nummer}`:void 0};function Mn({data:e,fitBounds:t=!0,fitBoundsPadding:r=40,geoJsonStyle:s,showLayerToggle:a=!0,height:d,className:p,disabled:u,hoverable:c=!0,selectable:g=!0,onHover:L,onSelect:T,hoverContent:h,onCoordinateClick:o,showCenterAction:k,showZoomControls:b,getLabel:F=jn}){const O={...Rr,...s},P=n.useMemo(()=>ct(e),[e]),[_,$]=n.useState(!1),[j,C]=n.useState(null),[I,v]=n.useState(null),D=n.useCallback(m=>{o&&v(m)},[o]),{mapContainerRef:W,mapRef:f,mapReady:w,mapVersion:E}=St({disabled:u,height:d,onMapClick:o?D:void 0,showZoomControls:b}),S=n.useRef(o);S.current=o;const{result:A}=Lt({mapRef:f,coordinate:I,enabled:!!o});n.useEffect(()=>{var m;A&&((m=S.current)==null||m.call(S,A))},[A]);const B=n.useCallback((m,i)=>{L==null||L(m,i);const N=f.current;if(N&&_){const V=(m==null?void 0:m.id)??null;zr(N,V)}C(i&&m?{x:i.point.x,y:i.point.y}:null)},[L,f,_]),R=n.useCallback(m=>{T==null||T(m);const i=f.current;if(i&&_){const N=(m==null?void 0:m.map(V=>V.id).filter(V=>V!==void 0))??[];Zr(i,N)}},[T,f,_]),{hoveredFeature:z}=Cn({mapRef:f,layerIds:Ur,sourceId:oe,enabled:_&&!u,hoverable:c,selectable:g,onHover:B,onSelect:R});n.useEffect(()=>{const m=f.current;if(!m)return;const i=()=>{try{const N=m.getSource(oe);if(N?N.setData(P):m.addSource(oe,{type:"geojson",data:P}),m.getLayer(Qe)||m.addLayer({id:Qe,type:"fill",source:oe,layout:{visibility:"visible"},paint:{"fill-color":ve("fillColor",O.fillColor),"fill-opacity":ve("fillOpacity",O.fillOpacity)}}),m.getLayer(et)||m.addLayer({id:et,type:"line",source:oe,layout:{visibility:"visible"},paint:{"line-color":ve("lineColor",O.lineColor),"line-width":ve("lineWidth",O.lineWidth)}}),m.getLayer(Et)||m.addLayer({id:Et,type:"circle",source:oe,layout:{visibility:"visible"},paint:{"circle-radius":["+",ve("pointRadius",O.pointRadius),ve("pointStrokeWidth",O.pointStrokeWidth)],"circle-color":ve("pointStrokeColor",O.pointStrokeColor)}}),m.getLayer(tt)||m.addLayer({id:tt,type:"circle",source:oe,layout:{visibility:"visible"},paint:{"circle-radius":ve("pointRadius",O.pointRadius),"circle-color":ve("pointColor",O.pointColor)}}),qr(m,O),$(!0),t){const V=wt(P);V&&m.fitBounds(V,{padding:r,maxZoom:16,duration:300})}m.resize(),m.triggerRepaint()}catch{}};return m.isStyleLoaded()?i():m.once("load",i),()=>{m.off("load",i),$(!1),Yr(m)}},[P,E]);const K=n.useRef(F);return K.current=F,n.useEffect(()=>{const m=f.current;if(!m||!w)return;const i=()=>{m.getSource(Te)||m.addSource(Te,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),m.getLayer(lt)||m.addLayer({id:lt,type:"symbol",source:Te,layout:{"text-field":["get","_label"],"text-size":16,"text-anchor":"left","text-offset":[1.2,0],"text-allow-overlap":!0,"text-optional":!1},paint:{"text-color":Kt,"text-halo-color":Ut,"text-halo-width":2}})};return m.isStyleLoaded()?i():m.once("load",i),()=>{m.off("load",i);try{m.getLayer(lt)&&m.removeLayer(lt),m.getSource(Te)&&m.removeSource(Te)}catch{}}},[E]),n.useEffect(()=>{const m=f.current,i=K.current;if(!m||!w||!i)return;const N=P&&P.features.length>0?{type:"FeatureCollection",features:P.features.map(G=>({...G,properties:{...G.properties,_label:i(G)??""}}))}:{type:"FeatureCollection",features:[]},V=()=>{const G=m.getSource(Te);G&&G.setData(N)};m.isStyleLoaded()?V():m.once("load",V)},[E,P]),l.jsxs("div",{ref:W,className:[Nt.mapContainer,p].filter(Boolean).join(" "),children:[a&&l.jsx(Mt,{}),!u&&l.jsx(Tt,{mapRef:f,visible:k}),c&&z&&j&&l.jsx(lr,{feature:z,position:j,hoverContent:h})]})}const cr=({data:e,onChange:t,annotations:r,getError:s=void 0})=>{const{getId:a}=Z.useIdProvider(),d=(u,c,g)=>{const L=[...e.features.slice(0,u),{...e.features[u],properties:{...e.features[u].properties,[c]:g}},...e.features.slice(u+1)];t({...e,features:L})},p=(u,c)=>s==null?void 0:s(`features[${u}].properties.${c}`);return e.features.map((u,c)=>l.jsx(Z.Surface,{children:r.map(g=>{var L,T;return l.jsxs(Z.Surface,{children:[l.jsxs(Z.Surface,{horizontal:!0,width:"full",align:"center",gap:2,children:[l.jsxs("span",{children:["#",(L=u.properties)==null?void 0:L.nummer]}),l.jsx(Z.Surface,{grow:!0,children:l.jsx(Z.TextInput,{id:a("features",c,"properties",g.name),value:(T=u.properties)==null?void 0:T[g.name],width:"full",onChange:h=>{d(c,g.name,h)}})})]}),p(c,g.name)&&l.jsx(Z.ValidationMessage,{children:p(c,g.name)},g.name)]},g.name)})},c))},xn=(e,t,r=void 0,s=void 0,a=void 0)=>{const d=r??e.touchedState,p=s??e.validationErrors,u=a??e.showUntouchedValidationErrors;return!(d!=null&&d[t])&&!u||!(p!=null&&p[t])?null:p[t]},Tn=e=>t=>xn(e,t);function Fn({label:e,description:t,required:r,optional:s,annotations:a,value:d,onChange:p,error:u,...c}){const g=Tn({touchedState:c.touchedState,validationErrors:c.validationErrors,showUntouchedValidationErrors:c.showUntouchedValidationErrors});return l.jsxs("div",{children:[e&&l.jsx(Z.Label,{children:l.jsx(Z.LabelContent,{text:e,required:r,optional:s})}),t&&l.jsx(Z.Field.Description,{children:t}),l.jsx(pt,{value:d,onChange:p,...c}),a&&d&&p&&l.jsx(cr,{data:d,onChange:p,annotations:a,getError:g}),u&&l.jsx(Z.ValidationMessage,{children:u})]})}function In({mapRef:e,currentValue:t,disabled:r=!1,onDirectionChange:s}){const a=n.useRef(null),d=n.useRef(null),p=n.useRef(null),u=n.useRef(null),c=n.useRef(!1),g=n.useRef(0),L=n.useRef(r),T=n.useRef(t);T.current=t;const h=n.useRef(s);h.current=s,n.useEffect(()=>{L.current=r},[r]);const o=n.useCallback(()=>{if(d.current)return d.current;if(typeof document>"u")return;const{container:b,compass:F,handle:O}=sr();p.current=F,u.current=O;const P=v=>{const D=e.current,W=T.current.coordinate;if(!D||!W)return 0;const f=D.project([W.longitude,W.latitude]),w=D.getContainer().getBoundingClientRect(),E=v.clientX-w.left,S=v.clientY-w.top,A=E-f.x,B=f.y-S;return Ue(Math.atan2(A,B)*180/Math.PI)},_=v=>{var f;if(L.current)return;c.current=!0,v.currentTarget.setPointerCapture(v.pointerId),v.stopPropagation(),v.preventDefault();const D=P(v),W=Math.round(D);(f=h.current)==null||f.call(h,{...T.current,direction:W})},$=v=>{var f;if(!c.current)return;const D=P(v),W=Math.round(D);(f=h.current)==null||f.call(h,{...T.current,direction:W})},j=v=>{c.current&&(c.current=!1,g.current=Date.now(),v.currentTarget.releasePointerCapture(v.pointerId),v.stopPropagation(),v.preventDefault())},C=v=>{v.stopPropagation()};for(const v of[F,O])v.addEventListener("pointerdown",_),v.addEventListener("pointermove",$),v.addEventListener("pointerup",j),v.addEventListener("mousedown",C),v.addEventListener("click",C);const I=T.current.direction??0;return ut(F,O,I),d.current=b,b},[e]);n.useEffect(()=>{const b=p.current,F=u.current;!b||!F||ut(b,F,t.direction??0)},[t.direction]),n.useEffect(()=>{const b=e.current;if(!b)return;const F=t.coordinate;if(!F){a.current&&(a.current.remove(),a.current=null);return}if(a.current)a.current.setLngLat([F.longitude,F.latitude]);else{const O=o();a.current=new Pe.Marker({element:O,anchor:"center"}).setLngLat([F.longitude,F.latitude]).addTo(b)}},[t.coordinate,o,e]);const k=n.useCallback(()=>c.current||Date.now()-g.current<200,[]);return{markerRef:a,wasRecentlyDragging:k}}function An({mapRef:e,coordinate:t,disabled:r=!1}){const s=n.useRef(null);return n.useEffect(()=>{var p;const a=e.current;if(!a)return;if(!t){(p=s.current)==null||p.remove(),s.current=null;return}const d=[t.longitude,t.latitude];s.current?s.current.setLngLat(d):s.current=new Pe.Marker().setLngLat(d).addTo(a)},[t,e]),n.useEffect(()=>{var d;const a=(d=s.current)==null?void 0:d.getElement();a&&(a.style.pointerEvents=r?"none":"")},[r]),n.useEffect(()=>()=>{var a;(a=s.current)==null||a.remove(),s.current=null},[]),{markerRef:s}}H.BUILT_IN_LAYERS=Wt,H.BaseLayersContext=Ze,H.BaseLayersProvider=wr,H.BuiltInLayersContext=Je,H.BuiltInLayersProvider=Ir,H.CoordinateDirectionField=wn,H.CoordinateField=En,H.CustomLayersContext=Xe,H.CustomLayersProvider=Or,H.DEFAULT_BOUNDS=ht,H.DEFAULT_CENTER=kt,H.DEFAULT_ZOOM=mt,H.EMPTY_STYLE=Dt,H.GeoJsonAnnotater=cr,H.GeoJsonEditor=pt,H.GeoJsonViewer=Mn,H.KARTVERKET_TOPO_BASE_LAYER=Bt,H.LayerToggle=Mt,H.MapCenterAction=Tt,H.MapField=Fn,H.STYRBORD_KART_TRANSLATIONS_NAMESPACE=jt,H.StyrbordKartTranslations=sn,H.ViewBoundsContext=vt,H.ViewBoundsProvider=Sr,H.WmsCatalogLayersContext=We,H.WmsCatalogLayersProvider=Wr,H.buildGetFeatureInfoUrl=Qt,H.clampDirection=Ue,H.clampLatitude=Ye,H.clampLongitude=qe,H.createSimpleLayer=Tr,H.isLayerIncluded=Jt,H.roundToDecimals=gt,H.useCompassMarker=In,H.useMapLayers=ar,H.useMaplibreMap=St,H.usePointMarker=An,H.useWmsFeatureInfo=Lt,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));
|