@biodiv-platform/naksha-maplibre-layers 5.0.4 → 5.0.6

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/esm/index.js CHANGED
@@ -1,2579 +1 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __pow = Math.pow;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
19
- };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __async = (__this, __arguments, generator) => {
22
- return new Promise((resolve, reject) => {
23
- var fulfilled = (value) => {
24
- try {
25
- step(generator.next(value));
26
- } catch (e) {
27
- reject(e);
28
- }
29
- };
30
- var rejected = (value) => {
31
- try {
32
- step(generator.throw(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
- step((generator = generator.apply(__this, __arguments)).next());
39
- });
40
- };
41
-
42
- // src/index.tsx
43
- import { TranslationProvider } from "@biodiv-platform/naksha-commons";
44
- import React14 from "react";
45
- import { MapProvider } from "react-map-gl/maplibre";
46
- import { setup } from "twind";
47
-
48
- // locales/en.json
49
- var en_default = {
50
- are_you_sure: "Are you sure?",
51
- base_style: "Base Style",
52
- clear: "Clear Selection",
53
- created_by: "Attribution",
54
- created_on: "Created On",
55
- delete: "Delete",
56
- download: "Download",
57
- find_layer_by_name: "Find layer by name",
58
- infobar: "Attributes at Clicked Location",
59
- information: "Information",
60
- layer_selection: "Layer Selection",
61
- layer_selection_all: "All Layers",
62
- layer_selection_top: "Top Layer Only",
63
- layers: "Layers",
64
- legend: "Legend",
65
- less: "Less",
66
- license: "License",
67
- list_layers: "List Layers",
68
- pending: "Pending",
69
- publish: "Publish",
70
- raster_style_not_found: "Style not available for the given layer",
71
- remove: "Remove",
72
- selected: "Selected",
73
- settings: "Settings",
74
- square: "Square",
75
- tags: "Tags",
76
- toggle: "Toggle Publishing",
77
- uploaded: "Uploaded",
78
- uploader: "Uploader",
79
- url: "URL",
80
- visiblity: "Visiblity"
81
- };
82
-
83
- // locales/fr.json
84
- var fr_default = {
85
- are_you_sure: "\xCAtes-vous s\xFBr?",
86
- base_style: "Style de base",
87
- clear: "Effacer la s\xE9lection",
88
- created_by: "Attribution",
89
- created_on: "Cr\xE9\xE9 sur",
90
- delete: "Effacer",
91
- download: "T\xE9l\xE9charger",
92
- find_layer_by_name: "Trouver la couche par nom",
93
- infobar: "Attributs \xE0 l'emplacement cliqu\xE9",
94
- information: "Informations",
95
- layer_selection_all: "Toutes les couches",
96
- layer_selection_top: "Couche sup\xE9rieure uniquement",
97
- layer_selection: "S\xE9lection de calque",
98
- layers: "Couches",
99
- legend: "L\xE9gende",
100
- less: "Moins",
101
- license: "Licence",
102
- list_layers: "Liste des couches",
103
- pending: "En attente",
104
- publish: "Publier",
105
- remove: "Supprimer",
106
- selected: "Choisie",
107
- settings: "Param\xE8tres",
108
- square: "Carr\xE9",
109
- toggle: "Basculer la publication",
110
- uploaded: "T\xE9l\xE9charg\xE9",
111
- url: "url"
112
- };
113
-
114
- // locales/hi.json
115
- var hi_default = {
116
- are_you_sure: "\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",
117
- base_style: "\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",
118
- clear: "\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",
119
- created_by: "\u0906\u0930\u094B\u092A\u0923",
120
- created_on: "\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",
121
- delete: "\u0939\u091F\u093E\u090F\u0902",
122
- download: "\u0921\u093E\u0909\u0928\u0932\u094B\u0921",
123
- find_layer_by_name: "\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",
124
- infobar: "\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",
125
- information: "\u091C\u093E\u0928\u0915\u093E\u0930\u0940",
126
- layer_selection_all: "\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",
127
- layer_selection_top: "\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",
128
- layer_selection: "\u092A\u0930\u0924 \u091A\u092F\u0928",
129
- layers: "\u092A\u0930\u0924\u0947\u0902",
130
- legend: "\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",
131
- less: "\u0915\u092E",
132
- license: "\u0932\u093E\u0907\u0938\u0947\u0902\u0938",
133
- list_layers: "\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",
134
- pending: "\u0932\u0902\u092C\u093F\u0924",
135
- publish: "\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",
136
- remove: "\u0939\u091F\u093E\u0928\u093E",
137
- selected: "\u091A\u092F\u0928\u093F\u0924",
138
- settings: "\u0938\u092E\u093E\u092F\u094B\u091C\u0928",
139
- square: "\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",
140
- tags: "\u091F\u0948\u0917",
141
- toggle: "\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",
142
- uploaded: "\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",
143
- url: "\u092F\u0942\u0906\u0930\u090F\u0932"
144
- };
145
-
146
- // locales/index.ts
147
- var locales_default = { en: en_default, fr: fr_default, hi: hi_default };
148
-
149
- // src/components/map/index.tsx
150
- import { defaultViewState as defaultViewState2 } from "@biodiv-platform/naksha-commons";
151
- import { useMemo as useMemo7, useState as useState10 } from "react";
152
- import MapGL, { NavigationControl } from "react-map-gl/maplibre";
153
- import { tw as tw20 } from "twind";
154
-
155
- // src/hooks/use-layers.tsx
156
- import { defaultMapStyles, useDebounce } from "@biodiv-platform/naksha-commons";
157
- import React, {
158
- createContext,
159
- useContext,
160
- useEffect,
161
- useMemo,
162
- useState
163
- } from "react";
164
- import { useMap } from "react-map-gl/maplibre";
165
-
166
- // src/services/naksha.ts
167
- import cb from "colorbrewer";
168
- import axios from "redaxios";
169
-
170
- // src/utils/grid.ts
171
- import BoundingBox from "boundingbox";
172
- import { GeoHash } from "geohash";
173
-
174
- // src/static/constants.tsx
175
- import { MapStyles, defaultViewState } from "@biodiv-platform/naksha-commons";
176
- var defaultNakshaProps = {
177
- defaultViewState,
178
- nakshaApiEndpoint: "/naksha-api/api",
179
- geoserver: { endpoint: "/geoserver", workspace: "biodiv", store: "ibp" },
180
- mapStyle: MapStyles.MAP_STREETS,
181
- layers: [],
182
- selectedLayers: []
183
- };
184
- var FALLBACK_THUMB = "data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E";
185
- var overflowStyle = {
186
- display: "-webkit-box",
187
- WebkitLineClamp: 1,
188
- WebkitBoxOrient: "vertical",
189
- overflow: "hidden",
190
- wordBreak: "break-word"
191
- };
192
- var overflowStyle2 = __spreadProps(__spreadValues({}, overflowStyle), {
193
- WebkitLineClamp: 2
194
- });
195
- var PROPERTY_ID = "ogc_fid";
196
- var LAYER_STATUS = {
197
- ACTIVE: "Active",
198
- PENDING: "Pending"
199
- };
200
- var SELECTION_STYLE = {
201
- TOP: "layer_selection_top",
202
- ALL: "layer_selection_all"
203
- };
204
-
205
- // src/utils/grid.ts
206
- var getZoomConfig = (zoom) => {
207
- if (zoom < 6)
208
- return [4, 1, 39.2];
209
- else if (zoom < 7)
210
- return [5, 0, 19.6];
211
- else if (zoom < 8)
212
- return [5, 1, 9.8];
213
- else if (zoom < 9)
214
- return [5, -1, 4.9];
215
- else if (zoom < 10)
216
- return [6, 0, 2.45];
217
- else if (zoom < 11)
218
- return [6, 1, 1.225];
219
- else if (zoom < 12)
220
- return [7, 0, 0.612];
221
- else if (zoom < 13)
222
- return [7, 1, 0.306];
223
- else if (zoom < 14)
224
- return [7, -1, 0.153];
225
- else if (zoom < 15)
226
- return [8, 0, 0.077];
227
- return [8, 1, 0.039];
228
- };
229
- var BASE32 = "0123456789bcdefghjkmnpqrstuvwxyz";
230
- var aggregateGeohashKey = (key, level, binSize) => {
231
- binSize = binSize || 16 / __pow(2, 1 - key.length & 1) / __pow(4, level);
232
- const keyExceptLast = key.slice(0, -1);
233
- const binnedCharAt = ~~(BASE32.indexOf(key.slice(-1)) / binSize);
234
- return [
235
- keyExceptLast + BASE32[binSize * binnedCharAt],
236
- keyExceptLast + BASE32[binSize * (binnedCharAt + 1) - 1]
237
- ];
238
- };
239
- var processRectangles = function(data, level) {
240
- var counts = /* @__PURE__ */ new Map();
241
- var bins = /* @__PURE__ */ new Map();
242
- const features = [];
243
- for (const [hash, count] of Object.entries(data)) {
244
- const [kStart, kEnd] = aggregateGeohashKey(hash, level);
245
- bins.set(kStart, kEnd);
246
- if (!counts.has(kStart)) {
247
- counts.set(kStart, 0);
248
- }
249
- counts.set(kStart, counts.get(kStart) + count);
250
- }
251
- counts.forEach((count, hash) => {
252
- const bboxStart = GeoHash.decodeGeoHash(hash);
253
- const bboxEnd = GeoHash.decodeGeoHash(bins.get(hash));
254
- const feature2 = new BoundingBox({
255
- minlat: bboxStart.latitude[0],
256
- minlon: bboxStart.longitude[0],
257
- maxlat: bboxEnd.latitude[1],
258
- maxlon: bboxEnd.longitude[1]
259
- }).toGeoJSON();
260
- features.push(__spreadProps(__spreadValues({}, feature2), { properties: { count, [PROPERTY_ID]: hash } }));
261
- });
262
- return features;
263
- };
264
- var processSquares = (data) => {
265
- const features = [];
266
- for (const [hash, count] of Object.entries(data)) {
267
- const bbox2 = GeoHash.decodeGeoHash(hash);
268
- const feature2 = new BoundingBox({
269
- minlat: bbox2.latitude[0],
270
- minlon: bbox2.longitude[0],
271
- maxlat: bbox2.latitude[1],
272
- maxlon: bbox2.longitude[1]
273
- }).toGeoJSON();
274
- features.push(__spreadProps(__spreadValues({}, feature2), { properties: { count, [PROPERTY_ID]: hash } }));
275
- }
276
- return features;
277
- };
278
- var geohashToJSON = (data, level) => ({
279
- type: "FeatureCollection",
280
- features: Object.keys(data).length === 0 ? [] : level === -1 ? processSquares(data) : processRectangles(data, level)
281
- });
282
- var getDataBins = (data, binCount) => {
283
- const sortedData = Object.values(data).sort((a, b) => a - b);
284
- const cutoff = Math.floor(sortedData.length / binCount);
285
- const tBins = new Array(binCount - 1).fill(0).map((_, index) => sortedData[cutoff * (index + 1)]);
286
- tBins.push(sortedData[sortedData.length - 1]);
287
- return tBins;
288
- };
289
-
290
- // src/utils/naksha.ts
291
- import produce from "immer";
292
- var parseGeoserverLayersXml = (layers, nakshaApiEndpoint, geoserver, selectedLayers) => __async(void 0, null, function* () {
293
- const parsedLayers = [];
294
- for (const l of layers) {
295
- const isAdded = selectedLayers.includes(l.name);
296
- const _l = __spreadProps(__spreadValues({}, l), {
297
- id: l.name,
298
- thumbnail: nakshaApiEndpoint + l.thumbnail,
299
- source: {
300
- type: l.layerType.toLowerCase() === "raster" ? "raster" : "vector",
301
- scheme: "tms",
302
- tiles: [
303
- `${geoserver.endpoint}/gwc/service/tms/1.0.0/${geoserver.workspace}:${l.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`
304
- ]
305
- },
306
- data: { styles: [] },
307
- isAdded
308
- });
309
- if (isAdded) {
310
- const _ld = yield getLayerStyle(_l, 0, nakshaApiEndpoint, geoserver);
311
- parsedLayers.push(__spreadProps(__spreadValues({}, _l), { data: _ld }));
312
- } else {
313
- parsedLayers.push(_l);
314
- }
315
- }
316
- return parsedLayers;
317
- });
318
- var getLayerStyle = (layer, styleIndex, nakshaApiEndpoint, geoserver) => __async(void 0, null, function* () {
319
- const nextSl = produce(layer.data, (_draft) => __async(void 0, null, function* () {
320
- var _a;
321
- if (_draft.styles.length === 0) {
322
- const { success, data } = yield axGetGeoserverLayerStyleList(
323
- layer.id,
324
- nakshaApiEndpoint
325
- );
326
- if (success) {
327
- _draft.layerName = data.layerName;
328
- _draft.styles = data.styles;
329
- _draft.summaryColumn = data.summaryColumn;
330
- _draft.titleColumn = data.titleColumn;
331
- _draft.propertyMap = Object.fromEntries(
332
- data.styles.map((o) => [o.styleName, o.styleTitle])
333
- );
334
- }
335
- }
336
- if (_draft.styles[styleIndex] && !((_a = _draft.styles[styleIndex]) == null ? void 0 : _a.colors)) {
337
- _draft.styles[styleIndex].colors = yield axGetGeoserverLayerStyle(
338
- layer.id,
339
- geoserver == null ? void 0 : geoserver.workspace,
340
- _draft.styles[styleIndex].styleName,
341
- nakshaApiEndpoint
342
- );
343
- }
344
- _draft.styleIndex = styleIndex;
345
- }));
346
- return nextSl;
347
- });
348
-
349
- // src/services/naksha.ts
350
- var axGetGeoserverLayers = (nakshaEndpointToken, nakshaApiEndpoint, geoserver, selectedLayers) => __async(void 0, null, function* () {
351
- try {
352
- const res = yield axios.get(`${nakshaApiEndpoint}/layer/all`, {
353
- headers: { Authorization: nakshaEndpointToken }
354
- });
355
- const finalLayers = yield parseGeoserverLayersXml(
356
- res.data,
357
- nakshaApiEndpoint,
358
- geoserver,
359
- selectedLayers
360
- );
361
- return finalLayers;
362
- } catch (e) {
363
- console.error(e);
364
- return [];
365
- }
366
- });
367
- var axGetGeoserverLayerStyleList = (id, endpoint) => __async(void 0, null, function* () {
368
- try {
369
- const { data } = yield axios.get(`${endpoint}/layer/onClick/${id}`);
370
- return { success: true, data };
371
- } catch (e) {
372
- console.error(e);
373
- return { success: false };
374
- }
375
- });
376
- var axGexGetRasterInfoWithLonLat = (endpoint, workspace, params) => __async(void 0, null, function* () {
377
- const RasterInfoParams = {
378
- service: "WMS",
379
- version: "1.1.1",
380
- request: "GetFeatureInfo",
381
- info_format: "application/json",
382
- width: 100,
383
- height: 100,
384
- x: 50,
385
- y: 50,
386
- srs: "EPSG:4326"
387
- };
388
- try {
389
- const res = yield axios.get(`${endpoint}/${workspace}/wms`, {
390
- params: __spreadValues(__spreadValues({}, params), RasterInfoParams)
391
- });
392
- return { success: true, data: res.data };
393
- } catch (e) {
394
- console.error(e);
395
- return { success: false, data: [] };
396
- }
397
- });
398
- var axToggleLayerPublishing = (nakshaEndpointToken, nakshaApiEndpoint, layerId, isActive) => __async(void 0, null, function* () {
399
- try {
400
- yield axios.put(
401
- `${nakshaApiEndpoint}/layer/${isActive ? "active" : "pending"}/${layerId}`,
402
- {},
403
- { headers: { Authorization: nakshaEndpointToken } }
404
- );
405
- return true;
406
- } catch (e) {
407
- console.error(e);
408
- return false;
409
- }
410
- });
411
- var axDeleteLayer = (nakshaEndpointToken, nakshaApiEndpoint, layerId) => __async(void 0, null, function* () {
412
- try {
413
- yield axios.delete(`${nakshaApiEndpoint}/layer/${layerId}`, {
414
- headers: { Authorization: nakshaEndpointToken }
415
- });
416
- return true;
417
- } catch (e) {
418
- console.error(e);
419
- return false;
420
- }
421
- });
422
- var axGetGeoserverLayerStyle = (layername, workspace, styleName, endpoint) => __async(void 0, null, function* () {
423
- var _a, _b;
424
- try {
425
- const res = yield axios.get(
426
- `${endpoint}/geoserver/workspaces/${workspace}/styles/${layername}_${styleName}.mbstyle`
427
- );
428
- return (_b = (_a = res.data) == null ? void 0 : _a.layers) == null ? void 0 : _b[0];
429
- } catch (e) {
430
- console.error(e);
431
- return {};
432
- }
433
- });
434
- var getGridLayerData = (fetcher, bounds, zoom, binCount = 6, colorScheme = "YlOrRd") => __async(void 0, null, function* () {
435
- try {
436
- const [geoAggegationPrecision, level, squareSize] = getZoomConfig(zoom);
437
- const { _ne, _sw } = bounds;
438
- const params = {
439
- top: _ne.lat,
440
- left: _sw.lng,
441
- bottom: _sw.lat,
442
- right: _ne.lng,
443
- geoAggegationPrecision
444
- };
445
- const data = yield fetcher(params);
446
- const geojson = geohashToJSON(data, level);
447
- const bins = getDataBins(data, binCount);
448
- const stops = bins.map((bin, index) => [
449
- bin,
450
- cb[colorScheme][binCount][index]
451
- ]);
452
- const paint2 = {
453
- "fill-color": {
454
- property: "count",
455
- default: "yellow",
456
- stops
457
- },
458
- "fill-outline-color": "rgba(0,0,0,0.2)",
459
- "fill-opacity": 0.7
460
- };
461
- return { success: true, geojson, paint: paint2, stops, squareSize };
462
- } catch (e) {
463
- console.error(e);
464
- return { success: false, geojson: {}, paint: {}, stops: [], squareSize: 0 };
465
- }
466
- });
467
- var axDownloadLayer = (endpoint, token, layerName, layerTitle) => __async(void 0, null, function* () {
468
- try {
469
- yield axios.post(
470
- `${endpoint}/layer/download`,
471
- { layerName, layerTitle, attributeList: [], filterArray: [] },
472
- { headers: { Authorization: token } }
473
- );
474
- } catch (e) {
475
- console.error(e);
476
- }
477
- });
478
-
479
- // src/hooks/use-layers.tsx
480
- import { jsx } from "react/jsx-runtime";
481
- var LayersContext = createContext(
482
- {}
483
- );
484
- var LayersProvider = ({ mp: _mp, children }) => {
485
- var _a, _b;
486
- const [mp, setMP] = useState(_mp);
487
- const { mapl } = useMap();
488
- const [queryTerm, setQueryTerm] = useState("");
489
- const queryTermDebounced = useDebounce(queryTerm, 500);
490
- const styles = mp.mapStyles && mp.mapStyles.length > 0 ? mp.mapStyles : defaultMapStyles;
491
- const [mapStyle, setMapStyle] = useState(
492
- (_a = styles[(mp == null ? void 0 : mp.mapStyle) || 0]) == null ? void 0 : _a.style
493
- );
494
- const [maxZoom, setMaxZoom] = useState(
495
- (_b = styles[(mp == null ? void 0 : mp.mapStyle) || 0]) == null ? void 0 : _b.maxZoom
496
- );
497
- const [selectionStyle, setSelectionStyle] = useState(
498
- SELECTION_STYLE.TOP
499
- );
500
- const [gridLegends, setGridLegends] = useState({});
501
- const [isInfoBarOpen, setIsInfoBarOpen] = useState(true);
502
- const [clickedLngLat, setClickedLngLat] = useState();
503
- const [layers, setLayers] = useState(_mp.layers || []);
504
- const [selectedLayerIds, setSelectedLayerIds] = useState(
505
- mp.selectedLayers || []
506
- );
507
- const [hoverFeatures, setHoverFeatures] = useState();
508
- const [selectedFeatures, setSelectedFeatures] = useState();
509
- const selectedFeaturesId = useMemo(() => {
510
- var _a2;
511
- const meta = {};
512
- for (const qr of selectedFeatures || []) {
513
- meta[qr.sourceLayer] = [
514
- ...meta[qr.sourceLayer] || [],
515
- (_a2 = qr == null ? void 0 : qr.properties) == null ? void 0 : _a2[PROPERTY_ID]
516
- ];
517
- }
518
- return Object.keys(meta).length ? meta : void 0;
519
- }, [selectedFeatures]);
520
- const selectedLayers = React.useMemo(() => {
521
- const unsortedLayers = layers.filter(
522
- (_layer) => selectedLayerIds.includes(_layer.id)
523
- );
524
- const sortedLayers = new Array(selectedLayerIds.length);
525
- for (const layerToSort of unsortedLayers) {
526
- const idx = selectedLayerIds.findIndex((l) => layerToSort.id === l);
527
- if (idx > -1) {
528
- sortedLayers[idx] = layerToSort;
529
- }
530
- }
531
- return sortedLayers;
532
- }, [layers, selectedLayerIds]);
533
- const getLayerIndexById = (layerId) => {
534
- return layers.findIndex((layer) => layer.id === layerId);
535
- };
536
- const updateLayerById = (layerId, updatedLayer) => {
537
- setLayers(
538
- (_layers) => _layers.map((l) => l.id === layerId ? __spreadValues(__spreadValues({}, l), updatedLayer) : l)
539
- );
540
- };
541
- const toggleVectorLayer = (layerIndex, styleIndex, focus) => __async(void 0, null, function* () {
542
- const layer = layers[layerIndex];
543
- const layerData = yield getLayerStyle(
544
- layer,
545
- styleIndex,
546
- mp.nakshaApiEndpoint,
547
- mp.geoserver
548
- );
549
- updateLayerById(layer.id, { data: layerData });
550
- focus && (mapl == null ? void 0 : mapl.fitBounds(layer.bbox, { padding: 40, duration: 1e3 }));
551
- });
552
- const updateLayerStyle = (layerId, styleIndex) => __async(void 0, null, function* () {
553
- const layerIndex = getLayerIndexById(layerId);
554
- toggleVectorLayer(layerIndex, styleIndex, false);
555
- });
556
- const onMapHover = (e) => __async(void 0, null, function* () {
557
- var _a2, _b2, _c, _d;
558
- if (!selectedLayerIds.length || !mapl)
559
- return;
560
- try {
561
- const lastLayerId = selectedLayerIds[0];
562
- const feats = mapl.queryRenderedFeatures(e.point, {
563
- layers: [lastLayerId]
564
- });
565
- if (feats.length) {
566
- const fId = ((_a2 = feats[0]) == null ? void 0 : _a2.id) || ((_c = (_b2 = feats[0]) == null ? void 0 : _b2.properties) == null ? void 0 : _c[PROPERTY_ID]);
567
- if (fId === (hoverFeatures == null ? void 0 : hoverFeatures.id))
568
- return;
569
- const layer = layers[getLayerIndexById(lastLayerId)];
570
- const hoverProperties = (_d = layer == null ? void 0 : layer.data) == null ? void 0 : _d.summaryColumn.map((sc) => {
571
- var _a3, _b3, _c2;
572
- return [
573
- ((_b3 = (_a3 = layer.data) == null ? void 0 : _a3.propertyMap) == null ? void 0 : _b3[sc]) || sc,
574
- (_c2 = feats[0].properties) == null ? void 0 : _c2[sc]
575
- ];
576
- });
577
- setHoverFeatures({
578
- id: fId,
579
- title: layer.title,
580
- data: hoverProperties
581
- });
582
- } else {
583
- setHoverFeatures(void 0);
584
- }
585
- } catch (e2) {
586
- }
587
- });
588
- const toggleLayer = (_0) => __async(void 0, [_0], function* ({
589
- layerId,
590
- add,
591
- styleIndex = 0,
592
- focus = true
593
- }) {
594
- var _a2, _b2;
595
- if (!add) {
596
- setSelectedLayerIds(
597
- selectedLayerIds.filter((_lyrId) => layerId !== _lyrId)
598
- );
599
- return;
600
- }
601
- const layerIndex = getLayerIndexById(layerId);
602
- const sourceType = (_a2 = layers[layerIndex]) == null ? void 0 : _a2.source.type;
603
- if (sourceType === "grid") {
604
- setSelectedLayerIds((_slIds) => [
605
- layerId,
606
- ..._slIds.filter((lid) => lid !== layerId)
607
- ]);
608
- if (focus && ((_b2 = layers[layerIndex]) == null ? void 0 : _b2.bbox)) {
609
- setTimeout(() => {
610
- mapl == null ? void 0 : mapl.fitBounds(layers[layerIndex].bbox, {
611
- padding: 40,
612
- duration: 1e3
613
- });
614
- }, 100);
615
- }
616
- } else {
617
- yield toggleVectorLayer(layerIndex, styleIndex, focus);
618
- setSelectedLayerIds((_slIds) => [
619
- layerId,
620
- ..._slIds.filter((lid) => lid !== layerId)
621
- ]);
622
- }
623
- });
624
- const clearAllLayers = () => __async(void 0, null, function* () {
625
- return setSelectedLayerIds([]);
626
- });
627
- const updateMP = (key, value) => {
628
- setMP(__spreadProps(__spreadValues({}, mp), { [key]: value }));
629
- };
630
- const toggleLayerPublishing = (layerId, layerStatus) => {
631
- const isActive = layerStatus === LAYER_STATUS.PENDING;
632
- axToggleLayerPublishing(
633
- mp.nakshaEndpointToken,
634
- mp.nakshaApiEndpoint,
635
- layerId,
636
- isActive
637
- );
638
- updateLayerById(layerId, {
639
- layerStatus: isActive ? LAYER_STATUS.ACTIVE : LAYER_STATUS.PENDING
640
- });
641
- };
642
- const deleteLayer = (layerId, message) => __async(void 0, null, function* () {
643
- if (confirm(message)) {
644
- axDeleteLayer(mp.nakshaEndpointToken, mp.nakshaApiEndpoint, layerId);
645
- setLayers(layers.filter((l) => l.id !== layerId));
646
- }
647
- });
648
- const zoomToExtent = (layerId) => {
649
- const layerIndex = getLayerIndexById(layerId);
650
- const layer = layers[layerIndex];
651
- mapl == null ? void 0 : mapl.fitBounds(layer.bbox, { padding: 40, duration: 1e3 });
652
- };
653
- const getBBoxFromLngLat = () => {
654
- return [
655
- clickedLngLat.lng,
656
- clickedLngLat.lat,
657
- clickedLngLat.lng + 0.1,
658
- clickedLngLat.lat + 0.1
659
- ];
660
- };
661
- const handleSelectStyle = (value) => {
662
- setSelectionStyle(value);
663
- if (value === SELECTION_STYLE.TOP) {
664
- featuresAtLatLng(value);
665
- }
666
- };
667
- const featuresAtLatLng = (value) => {
668
- if (!clickedLngLat)
669
- return;
670
- try {
671
- const finalXY = mapl == null ? void 0 : mapl.project([clickedLngLat.lng, clickedLngLat.lat]);
672
- let queryFeat = mapl == null ? void 0 : mapl.queryRenderedFeatures(finalXY, {
673
- layers: selectionStyle === SELECTION_STYLE.TOP ? [selectedLayerIds[0]] : selectedLayerIds
674
- });
675
- if ((value || selectionStyle) === SELECTION_STYLE.ALL) {
676
- const rasterLayerFeat = selectedLayers.filter((item) => item.layerType == "RASTER").map((item) => ({
677
- sourceLayer: item.id,
678
- layerType: "raster",
679
- bbox: getBBoxFromLngLat()
680
- }));
681
- queryFeat = [...queryFeat, ...rasterLayerFeat];
682
- }
683
- setSelectedFeatures(
684
- (selectedLayers == null ? void 0 : selectedLayers[0].layerType) === "RASTER" && selectionStyle !== SELECTION_STYLE.ALL ? selectedLayerIds.length && (queryFeat == null ? void 0 : queryFeat.length) ? queryFeat : [
685
- {
686
- sourceLayer: selectedLayerIds[0],
687
- layerType: "raster",
688
- bbox: getBBoxFromLngLat()
689
- }
690
- ] : queryFeat
691
- );
692
- } catch (e) {
693
- console.error(e);
694
- }
695
- };
696
- useEffect(() => {
697
- if (mp.onSelectedLayersChange) {
698
- mp.onSelectedLayersChange(selectedLayerIds);
699
- }
700
- }, [selectedLayerIds]);
701
- useEffect(() => {
702
- setTimeout(featuresAtLatLng, 300);
703
- }, [clickedLngLat, selectionStyle, selectedLayerIds]);
704
- return /* @__PURE__ */ jsx(LayersContext.Provider, {
705
- value: {
706
- mp,
707
- updateMP,
708
- layer: {
709
- mapStyle,
710
- featuresAtLatLng,
711
- setMapStyle,
712
- maxZoom,
713
- setMaxZoom,
714
- mapStyles: styles,
715
- all: layers,
716
- setAll: setLayers,
717
- selectedIds: selectedLayerIds,
718
- handleSelectStyle,
719
- setSelectedIds: setSelectedLayerIds,
720
- selectedLayers,
721
- clearAll: clearAllLayers,
722
- toggle: toggleLayer,
723
- updateStyle: updateLayerStyle,
724
- selectedFeatures,
725
- selectedFeaturesId,
726
- setSelectedFeatures,
727
- togglePublish: toggleLayerPublishing,
728
- delete: deleteLayer,
729
- selectionStyle,
730
- setSelectionStyle,
731
- zoomToExtent,
732
- gridLegends,
733
- setGridLegends
734
- },
735
- query: {
736
- term: queryTermDebounced,
737
- setTerm: setQueryTerm,
738
- clickedLngLat,
739
- setClickedLngLat
740
- },
741
- isInfoBarOpen,
742
- setIsInfoBarOpen,
743
- hover: {
744
- onHover: onMapHover,
745
- features: hoverFeatures
746
- }
747
- },
748
- children
749
- });
750
- };
751
- function useLayers() {
752
- return useContext(LayersContext);
753
- }
754
-
755
- // src/components/core/button.tsx
756
- import React2 from "react";
757
- import { tw as tw2 } from "twind";
758
-
759
- // src/components/core/icons.tsx
760
- import { tw } from "twind";
761
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
762
- var SearchIcon = () => /* @__PURE__ */ jsx2("svg", {
763
- fill: "none",
764
- className: tw`w-5 h-5 text-gray-400`,
765
- width: "24",
766
- height: "24",
767
- viewBox: "0 0 24 24",
768
- children: /* @__PURE__ */ jsx2("path", {
769
- stroke: "currentColor",
770
- strokeLinecap: "round",
771
- strokeLinejoin: "round",
772
- strokeWidth: "2",
773
- d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
774
- })
775
- });
776
- var LayersIcon = () => /* @__PURE__ */ jsxs("svg", {
777
- width: "18",
778
- height: "18",
779
- fill: "none",
780
- stroke: "currentColor",
781
- strokeLinecap: "round",
782
- strokeLinejoin: "round",
783
- strokeWidth: "2",
784
- viewBox: "0 0 24 24",
785
- children: [
786
- /* @__PURE__ */ jsx2("path", {
787
- d: "M12 2L2 7 12 12 22 7 12 2z"
788
- }),
789
- /* @__PURE__ */ jsx2("path", {
790
- d: "M2 17L12 22 22 17"
791
- }),
792
- /* @__PURE__ */ jsx2("path", {
793
- d: "M2 12L12 17 22 12"
794
- })
795
- ]
796
- });
797
- var InfoIcon = () => /* @__PURE__ */ jsxs("svg", {
798
- width: "16",
799
- height: "16",
800
- viewBox: "0 0 24 24",
801
- fill: "none",
802
- stroke: "currentColor",
803
- strokeWidth: "2",
804
- strokeLinecap: "round",
805
- strokeLinejoin: "round",
806
- children: [
807
- /* @__PURE__ */ jsx2("circle", {
808
- cx: "12",
809
- cy: "12",
810
- r: "10"
811
- }),
812
- /* @__PURE__ */ jsx2("line", {
813
- x1: "12",
814
- y1: "16",
815
- x2: "12",
816
- y2: "12"
817
- }),
818
- /* @__PURE__ */ jsx2("line", {
819
- x1: "12",
820
- y1: "8",
821
- x2: "12.01",
822
- y2: "8"
823
- })
824
- ]
825
- });
826
- var SlidersIcon = () => /* @__PURE__ */ jsxs("svg", {
827
- width: "18",
828
- height: "18",
829
- fill: "none",
830
- stroke: "currentColor",
831
- strokeLinecap: "round",
832
- strokeLinejoin: "round",
833
- strokeWidth: "2",
834
- viewBox: "0 0 24 24",
835
- children: [
836
- /* @__PURE__ */ jsx2("path", {
837
- d: "M4 21L4 14"
838
- }),
839
- /* @__PURE__ */ jsx2("path", {
840
- d: "M4 10L4 3"
841
- }),
842
- /* @__PURE__ */ jsx2("path", {
843
- d: "M12 21L12 12"
844
- }),
845
- /* @__PURE__ */ jsx2("path", {
846
- d: "M12 8L12 3"
847
- }),
848
- /* @__PURE__ */ jsx2("path", {
849
- d: "M20 21L20 16"
850
- }),
851
- /* @__PURE__ */ jsx2("path", {
852
- d: "M20 12L20 3"
853
- }),
854
- /* @__PURE__ */ jsx2("path", {
855
- d: "M1 14L7 14"
856
- }),
857
- /* @__PURE__ */ jsx2("path", {
858
- d: "M9 8L15 8"
859
- }),
860
- /* @__PURE__ */ jsx2("path", {
861
- d: "M17 16L23 16"
862
- })
863
- ]
864
- });
865
- function AttributionIcon() {
866
- return /* @__PURE__ */ jsx2("svg", {
867
- width: "14",
868
- height: "14",
869
- viewBox: "0 0 16 16",
870
- style: { display: "inline-block" },
871
- children: /* @__PURE__ */ jsx2("path", {
872
- fillRule: "evenodd",
873
- fill: "currentColor",
874
- d: "M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"
875
- })
876
- });
877
- }
878
- function TagIcon() {
879
- return /* @__PURE__ */ jsx2("svg", {
880
- width: "14",
881
- height: "14",
882
- viewBox: "0 0 16 16",
883
- style: { display: "inline-block" },
884
- children: /* @__PURE__ */ jsx2("path", {
885
- fillRule: "evenodd",
886
- fill: "currentColor",
887
- d: "M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"
888
- })
889
- });
890
- }
891
- function LicenseIcon() {
892
- return /* @__PURE__ */ jsx2("svg", {
893
- width: "14",
894
- height: "14",
895
- viewBox: "0 0 16 16",
896
- style: { display: "inline-block" },
897
- children: /* @__PURE__ */ jsx2("path", {
898
- fillRule: "evenodd",
899
- fill: "currentColor",
900
- d: "M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"
901
- })
902
- });
903
- }
904
- function EyeIcon() {
905
- return /* @__PURE__ */ jsx2("svg", {
906
- viewBox: "0 0 16 16",
907
- width: "14",
908
- height: "14",
909
- style: { display: "inline-block" },
910
- children: /* @__PURE__ */ jsx2("path", {
911
- fillRule: "evenodd",
912
- fill: "currentColor",
913
- d: "M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"
914
- })
915
- });
916
- }
917
- function ClockIcon() {
918
- return /* @__PURE__ */ jsx2("svg", {
919
- viewBox: "0 0 16 16",
920
- width: "14",
921
- height: "14",
922
- style: { display: "inline-block" },
923
- children: /* @__PURE__ */ jsx2("path", {
924
- fillRule: "evenodd",
925
- fill: "currentColor",
926
- d: "M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"
927
- })
928
- });
929
- }
930
- function DownloadIcon() {
931
- return /* @__PURE__ */ jsx2("svg", {
932
- viewBox: "0 0 16 16",
933
- width: "16",
934
- height: "16",
935
- style: { display: "inline-block" },
936
- children: /* @__PURE__ */ jsx2("path", {
937
- fillRule: "evenodd",
938
- fill: "currentColor",
939
- d: "M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"
940
- })
941
- });
942
- }
943
- function ZoomExtentIcon() {
944
- return /* @__PURE__ */ jsx2("svg", {
945
- viewBox: "0 0 24 24",
946
- width: "16",
947
- height: "16",
948
- fill: "none",
949
- stroke: "currentColor",
950
- strokeWidth: "2",
951
- strokeLinecap: "round",
952
- strokeLinejoin: "round",
953
- style: { display: "inline-block" },
954
- children: /* @__PURE__ */ jsx2("path", {
955
- d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"
956
- })
957
- });
958
- }
959
- function ShareIcon() {
960
- return /* @__PURE__ */ jsxs("svg", {
961
- viewBox: "0 0 24 24",
962
- width: "16",
963
- height: "16",
964
- fill: "none",
965
- stroke: "currentColor",
966
- strokeWidth: "2",
967
- strokeLinecap: "round",
968
- strokeLinejoin: "round",
969
- style: { display: "inline-block" },
970
- children: [
971
- /* @__PURE__ */ jsx2("circle", {
972
- cx: "18",
973
- cy: "5",
974
- r: "3"
975
- }),
976
- /* @__PURE__ */ jsx2("circle", {
977
- cx: "6",
978
- cy: "12",
979
- r: "3"
980
- }),
981
- /* @__PURE__ */ jsx2("circle", {
982
- cx: "18",
983
- cy: "19",
984
- r: "3"
985
- }),
986
- /* @__PURE__ */ jsx2("line", {
987
- x1: "8.59",
988
- y1: "13.51",
989
- x2: "15.42",
990
- y2: "17.49"
991
- }),
992
- /* @__PURE__ */ jsx2("line", {
993
- x1: "15.41",
994
- y1: "6.51",
995
- x2: "8.59",
996
- y2: "10.49"
997
- })
998
- ]
999
- });
1000
- }
1001
- function GrabberIcon() {
1002
- return /* @__PURE__ */ jsx2("svg", {
1003
- viewBox: "0 0 16 16",
1004
- width: "16",
1005
- height: "16",
1006
- style: { display: "inline-block" },
1007
- children: /* @__PURE__ */ jsx2("path", {
1008
- fillRule: "evenodd",
1009
- d: "M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"
1010
- })
1011
- });
1012
- }
1013
- function CrossHairIcon() {
1014
- return /* @__PURE__ */ jsxs("svg", {
1015
- style: { display: "inline-block" },
1016
- width: "18",
1017
- height: "18",
1018
- viewBox: "0 0 24 24",
1019
- fill: "none",
1020
- stroke: "currentColor",
1021
- strokeWidth: "2",
1022
- strokeLinecap: "round",
1023
- strokeLinejoin: "round",
1024
- children: [
1025
- /* @__PURE__ */ jsx2("circle", {
1026
- cx: "12",
1027
- cy: "12",
1028
- r: "10"
1029
- }),
1030
- /* @__PURE__ */ jsx2("line", {
1031
- x1: "22",
1032
- y1: "12",
1033
- x2: "18",
1034
- y2: "12"
1035
- }),
1036
- /* @__PURE__ */ jsx2("line", {
1037
- x1: "6",
1038
- y1: "12",
1039
- x2: "2",
1040
- y2: "12"
1041
- }),
1042
- /* @__PURE__ */ jsx2("line", {
1043
- x1: "12",
1044
- y1: "6",
1045
- x2: "12",
1046
- y2: "2"
1047
- }),
1048
- /* @__PURE__ */ jsx2("line", {
1049
- x1: "12",
1050
- y1: "22",
1051
- x2: "12",
1052
- y2: "18"
1053
- })
1054
- ]
1055
- });
1056
- }
1057
- function DownIcon() {
1058
- return /* @__PURE__ */ jsx2("svg", {
1059
- width: "18",
1060
- height: "18",
1061
- viewBox: "0 0 24 24",
1062
- fill: "none",
1063
- stroke: "currentColor",
1064
- strokeWidth: "2",
1065
- strokeLinecap: "round",
1066
- strokeLinejoin: "round",
1067
- style: { display: "inline-block" },
1068
- children: /* @__PURE__ */ jsx2("polyline", {
1069
- points: "6 9 12 15 18 9"
1070
- })
1071
- });
1072
- }
1073
- function UpIcon() {
1074
- return /* @__PURE__ */ jsx2("svg", {
1075
- width: "18",
1076
- height: "18",
1077
- viewBox: "0 0 24 24",
1078
- fill: "none",
1079
- stroke: "currentColor",
1080
- strokeWidth: "2",
1081
- strokeLinecap: "round",
1082
- strokeLinejoin: "round",
1083
- style: { display: "inline-block" },
1084
- children: /* @__PURE__ */ jsx2("polyline", {
1085
- points: "18 15 12 9 6 15"
1086
- })
1087
- });
1088
- }
1089
-
1090
- // src/components/core/button.tsx
1091
- import { jsx as jsx3 } from "react/jsx-runtime";
1092
- var Button = React2.forwardRef((props, ref) => /* @__PURE__ */ jsx3("button", __spreadValues({
1093
- ref,
1094
- type: "button",
1095
- className: tw2`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`
1096
- }, props)));
1097
- var CloseButton = (props) => /* @__PURE__ */ jsx3("button", __spreadValues({
1098
- className: tw2`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,
1099
- children: "\u2715"
1100
- }, props));
1101
- var LayersButton = (props) => /* @__PURE__ */ jsx3("button", __spreadProps(__spreadValues({
1102
- className: tw2`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`
1103
- }, props), {
1104
- children: /* @__PURE__ */ jsx3(LayersIcon, {})
1105
- }));
1106
- var InfobarButton = (props) => /* @__PURE__ */ jsx3("button", __spreadProps(__spreadValues({
1107
- className: tw2`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`
1108
- }, props), {
1109
- children: /* @__PURE__ */ jsx3(InfoIcon, {})
1110
- }));
1111
-
1112
- // src/components/core/input.tsx
1113
- import { tw as tw3 } from "twind";
1114
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
1115
- var SelectInput = (props) => /* @__PURE__ */ jsxs2("div", {
1116
- children: [
1117
- props.label && /* @__PURE__ */ jsx4("label", {
1118
- className: tw3`text-gray-700`,
1119
- htmlFor: props.name,
1120
- children: props.label
1121
- }),
1122
- /* @__PURE__ */ jsx4("select", __spreadValues({
1123
- id: props.name,
1124
- name: props.name,
1125
- className: tw3`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,
1126
- style: {
1127
- backgroundImage: `url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,
1128
- backgroundPosition: "right 0.75rem center",
1129
- backgroundSize: "16px 12px",
1130
- backgroundRepeat: "no-repeat"
1131
- }
1132
- }, props))
1133
- ]
1134
- });
1135
- var SearchInput = (props) => /* @__PURE__ */ jsxs2("div", {
1136
- className: "relative",
1137
- children: [
1138
- /* @__PURE__ */ jsx4("span", {
1139
- className: tw3`absolute inset-y-0 left-0 flex items-center pl-3`,
1140
- children: /* @__PURE__ */ jsx4(SearchIcon, {})
1141
- }),
1142
- /* @__PURE__ */ jsx4("input", __spreadValues({
1143
- type: "search",
1144
- className: tw3`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`
1145
- }, props))
1146
- ]
1147
- });
1148
- var CheckboxInput = (props) => props.isLoading ? /* @__PURE__ */ jsx4("svg", {
1149
- width: "20px",
1150
- height: "20px",
1151
- viewBox: "0 0 20 20",
1152
- version: "1.1",
1153
- className: tw3`inline text-gray-200 animate-spin dark:text-gray-600`,
1154
- children: /* @__PURE__ */ jsx4("g", {
1155
- stroke: "none",
1156
- strokeWidth: "1",
1157
- fill: "none",
1158
- fillRule: "evenodd",
1159
- children: /* @__PURE__ */ jsx4("g", {
1160
- fill: "#212121",
1161
- fillRule: "nonzero",
1162
- children: /* @__PURE__ */ jsx4("path", {
1163
- d: "M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"
1164
- })
1165
- })
1166
- })
1167
- }) : /* @__PURE__ */ jsx4("input", {
1168
- type: "checkbox",
1169
- className: tw3`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,
1170
- name: props.name,
1171
- checked: props.checked,
1172
- onChange: props.onChange
1173
- });
1174
-
1175
- // src/components/core/tabs.tsx
1176
- import { Tabs, usePanelState, useTabState } from "@bumaga/tabs";
1177
- import clsx from "clsx";
1178
- import { tw as tw4 } from "twind";
1179
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1180
- var IconTab = ({ children, icon }) => {
1181
- const { onClick, isActive } = useTabState();
1182
- const classes = clsx([
1183
- "flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",
1184
- {
1185
- "text-blue-600 border-blue-500": isActive,
1186
- "text-gray-700 border-gray-300 hover:border-gray-400": !isActive
1187
- }
1188
- ]);
1189
- return /* @__PURE__ */ jsxs3("button", {
1190
- className: tw4(classes),
1191
- onClick,
1192
- children: [
1193
- icon,
1194
- /* @__PURE__ */ jsx5("span", {
1195
- className: tw4`ml-2 text-base`,
1196
- children
1197
- })
1198
- ]
1199
- });
1200
- };
1201
- var Panel = ({ children }) => {
1202
- const isActive = usePanelState();
1203
- return isActive ? /* @__PURE__ */ jsx5("div", {
1204
- className: tw4`w-full flex flex-grow-1 overflow-auto`,
1205
- children
1206
- }) : null;
1207
- };
1208
- var TabHeader = ({ children }) => /* @__PURE__ */ jsx5("div", {
1209
- className: tw4`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,
1210
- children
1211
- });
1212
-
1213
- // src/components/infobar/content.tsx
1214
- import { useT as useT2 } from "@biodiv-platform/naksha-commons";
1215
- import { tw as tw6 } from "twind";
1216
-
1217
- // src/components/sidebar/settings/layer-selection.tsx
1218
- import { useT } from "@biodiv-platform/naksha-commons";
1219
- import { jsx as jsx6 } from "react/jsx-runtime";
1220
- function LayerSelection({ hideLabel }) {
1221
- const {
1222
- layer: { selectionStyle, handleSelectStyle }
1223
- } = useLayers();
1224
- const { t } = useT();
1225
- const handleOnSelectionStyleChange = (e) => {
1226
- handleSelectStyle(e.target.value);
1227
- };
1228
- return /* @__PURE__ */ jsx6(SelectInput, {
1229
- name: "layer_selection",
1230
- label: hideLabel ? null : t("layer_selection"),
1231
- defaultValue: selectionStyle,
1232
- onChange: handleOnSelectionStyleChange,
1233
- children: Object.values(SELECTION_STYLE).map((ss) => /* @__PURE__ */ jsx6("option", {
1234
- value: ss,
1235
- children: t(ss)
1236
- }, ss))
1237
- });
1238
- }
1239
-
1240
- // src/components/infobar/infobar-panel.tsx
1241
- import clsx2 from "clsx";
1242
- import { useEffect as useEffect2, useState as useState2 } from "react";
1243
- import { tw as tw5 } from "twind";
1244
- import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1245
- function InfoBarPanel({ data: payload }) {
1246
- const [isOpen, setIsOpen] = useState2(true);
1247
- const [layerInfo, setLayerInfo] = useState2({
1248
- title: payload.sourceLayer,
1249
- properties: []
1250
- });
1251
- const { layer, mp, query: { clickedLngLat } } = useLayers();
1252
- const getPropertyData = () => __async(this, null, function* () {
1253
- var _a, _b, _c, _d, _e, _f;
1254
- let properties;
1255
- const currentLayer = layer.selectedLayers.find(
1256
- (l) => l.id === (payload.sourceLayer || payload.source)
1257
- );
1258
- if (currentLayer.layerType.toLowerCase() === "raster") {
1259
- const { data } = yield axGexGetRasterInfoWithLonLat(
1260
- (_a = mp.geoserver) == null ? void 0 : _a.endpoint,
1261
- (_b = mp.geoserver) == null ? void 0 : _b.workspace,
1262
- {
1263
- bbox: payload.bbox.toString(),
1264
- query_layers: `${(_c = mp.geoserver) == null ? void 0 : _c.workspace}:${currentLayer.id}`,
1265
- layers: `${(_d = mp.geoserver) == null ? void 0 : _d.workspace}:${currentLayer.id}`
1266
- }
1267
- );
1268
- properties = (data == null ? void 0 : data.features[0]) ? Object.entries((_e = data.features[0]) == null ? void 0 : _e.properties).map(([v, k]) => [
1269
- k || "-"
1270
- ]) : [];
1271
- } else {
1272
- properties = Object.entries(((_f = currentLayer == null ? void 0 : currentLayer.data) == null ? void 0 : _f.propertyMap) || {}).map(
1273
- ([k, v]) => {
1274
- var _a2;
1275
- return [v, (_a2 = payload == null ? void 0 : payload.properties) == null ? void 0 : _a2[k]];
1276
- }
1277
- );
1278
- }
1279
- setLayerInfo({ title: currentLayer.title, properties });
1280
- });
1281
- useEffect2(() => {
1282
- getPropertyData();
1283
- }, [clickedLngLat]);
1284
- return /* @__PURE__ */ jsxs4("div", {
1285
- className: tw5`bg-gray-100 rounded-lg`,
1286
- children: [
1287
- /* @__PURE__ */ jsxs4("button", {
1288
- className: tw5(
1289
- clsx2([
1290
- `px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring`,
1291
- { "bg-gray-200 rounded-t-lg": isOpen, "rounded-lg": !isOpen }
1292
- ])
1293
- ),
1294
- onClick: () => setIsOpen(!isOpen),
1295
- children: [
1296
- layerInfo.title,
1297
- " ",
1298
- isOpen ? /* @__PURE__ */ jsx7(UpIcon, {}) : /* @__PURE__ */ jsx7(DownIcon, {})
1299
- ]
1300
- }),
1301
- isOpen && /* @__PURE__ */ jsx7("div", {
1302
- className: tw5`px-4 py-3 flex flex-col gap-3`,
1303
- children: layerInfo.properties.map(([k, v], index) => /* @__PURE__ */ jsxs4("div", {
1304
- children: [
1305
- /* @__PURE__ */ jsx7("div", {
1306
- className: tw5`text-gray-600`,
1307
- children: k
1308
- }),
1309
- /* @__PURE__ */ jsx7("div", {
1310
- children: v
1311
- })
1312
- ]
1313
- }, k + v + index))
1314
- })
1315
- ]
1316
- });
1317
- }
1318
-
1319
- // src/components/infobar/content.tsx
1320
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1321
- function InfoBarContent({ onClose }) {
1322
- var _a;
1323
- const {
1324
- layer: { selectedFeatures, selectedLayers, selectionStyle }
1325
- } = useLayers();
1326
- const { t } = useT2();
1327
- return /* @__PURE__ */ jsxs5("div", {
1328
- className: tw6`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,
1329
- children: [
1330
- /* @__PURE__ */ jsxs5("div", {
1331
- className: "flex w-full",
1332
- children: [
1333
- /* @__PURE__ */ jsxs5("div", {
1334
- className: tw6`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,
1335
- children: [
1336
- /* @__PURE__ */ jsx8(CrossHairIcon, {}),
1337
- " ",
1338
- t("infobar")
1339
- ]
1340
- }),
1341
- /* @__PURE__ */ jsx8(CloseButton, {
1342
- onClick: onClose
1343
- })
1344
- ]
1345
- }),
1346
- /* @__PURE__ */ jsx8("div", {
1347
- className: tw6`bg-gray-100 p-4 flex-shrink-0 rt`,
1348
- children: /* @__PURE__ */ jsx8(LayerSelection, {
1349
- hideLabel: true
1350
- })
1351
- }),
1352
- /* @__PURE__ */ jsx8("div", {
1353
- className: tw6`flex flex-col flex-grow overflow-auto gap-3 p-4`,
1354
- children: (_a = selectedFeatures.flat(1)) == null ? void 0 : _a.map((data) => {
1355
- var _a2;
1356
- return /* @__PURE__ */ jsx8(InfoBarPanel, {
1357
- data
1358
- }, ((_a2 = selectedLayers == null ? void 0 : selectedLayers[0]) == null ? void 0 : _a2.source.type) === "raster" || selectionStyle === SELECTION_STYLE.ALL ? data == null ? void 0 : data.sourceLayer : (data == null ? void 0 : data.sourceLayer) + (data == null ? void 0 : data.properties[PROPERTY_ID]));
1359
- })
1360
- })
1361
- ]
1362
- });
1363
- }
1364
-
1365
- // src/components/infobar/index.tsx
1366
- import { jsx as jsx9 } from "react/jsx-runtime";
1367
- function InfoBar() {
1368
- var _a;
1369
- const { layer, isInfoBarOpen, setIsInfoBarOpen } = useLayers();
1370
- if (!((_a = layer.selectedFeatures) == null ? void 0 : _a.length))
1371
- return null;
1372
- const toggleOpen = () => setIsInfoBarOpen(!isInfoBarOpen);
1373
- return isInfoBarOpen ? /* @__PURE__ */ jsx9(InfoBarContent, {
1374
- onClose: toggleOpen
1375
- }) : /* @__PURE__ */ jsx9(InfobarButton, {
1376
- onClick: toggleOpen
1377
- });
1378
- }
1379
-
1380
- // src/components/sidebar/index.tsx
1381
- import { useEffect as useEffect3, useState as useState8 } from "react";
1382
- import { useMap as useMap2 } from "react-map-gl/maplibre";
1383
-
1384
- // src/components/sidebar/tabs.tsx
1385
- import { useT as useT10 } from "@biodiv-platform/naksha-commons";
1386
- import { tw as tw18 } from "twind";
1387
-
1388
- // src/components/sidebar/layers/index.tsx
1389
- import { tw as tw15 } from "twind";
1390
-
1391
- // src/components/sidebar/layers/layer-list.tsx
1392
- import React8, { useMemo as useMemo4 } from "react";
1393
- import { useVirtual } from "react-virtual";
1394
- import AutoSizer from "react-virtualized-auto-sizer";
1395
- import { tw as tw13 } from "twind";
1396
-
1397
- // src/components/sidebar/common/layer-item.tsx
1398
- import { useT as useT6 } from "@biodiv-platform/naksha-commons";
1399
- import { useMemo as useMemo3, useState as useState6 } from "react";
1400
- import { SortableHandle } from "react-sortable-hoc";
1401
- import { RWebShare } from "react-web-share";
1402
- import { tw as tw12 } from "twind";
1403
-
1404
- // src/components/core/highlighter.tsx
1405
- import { Fragment, jsx as jsx10 } from "react/jsx-runtime";
1406
- var Highlighted = ({ text = "", highlight = "" }) => {
1407
- if (!highlight.trim()) {
1408
- return /* @__PURE__ */ jsx10(Fragment, {
1409
- children: text
1410
- });
1411
- }
1412
- const regex = new RegExp(`(${highlight})`, "gi");
1413
- const parts = text.split(regex);
1414
- return /* @__PURE__ */ jsx10(Fragment, {
1415
- children: parts.filter((part) => part).map(
1416
- (part, i) => regex.test(part) ? /* @__PURE__ */ jsx10("mark", {
1417
- children: part
1418
- }, i) : /* @__PURE__ */ jsx10("span", {
1419
- children: part
1420
- }, i)
1421
- )
1422
- });
1423
- };
1424
-
1425
- // src/components/sidebar/common/grid-legend.tsx
1426
- import { tw as tw8 } from "twind";
1427
-
1428
- // src/components/sidebar/common/moreless.tsx
1429
- import { useT as useT3 } from "@biodiv-platform/naksha-commons";
1430
- import { useState as useState3 } from "react";
1431
- import { tw as tw7 } from "twind";
1432
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1433
- function MoreLess({ children }) {
1434
- const [showMore, setShowMore] = useState3(false);
1435
- const { t } = useT3();
1436
- return /* @__PURE__ */ jsxs6("div", {
1437
- children: [
1438
- showMore && children,
1439
- /* @__PURE__ */ jsx11("button", {
1440
- onClick: () => setShowMore(!showMore),
1441
- className: tw7`text-blue-600 focus:outline-none focus:outline focus:ring`,
1442
- children: showMore ? t("less") : t("legend")
1443
- })
1444
- ]
1445
- });
1446
- }
1447
-
1448
- // src/components/sidebar/common/grid-legend.tsx
1449
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
1450
- function GridLegend({ item }) {
1451
- const { layer } = useLayers();
1452
- const legendInfo = layer.gridLegends[item.id];
1453
- if (!legendInfo)
1454
- return null;
1455
- return /* @__PURE__ */ jsx12(MoreLess, {
1456
- children: /* @__PURE__ */ jsxs7("ul", {
1457
- style: { margin: 0, padding: 0 },
1458
- children: [
1459
- legendInfo == null ? void 0 : legendInfo.stops.map(([stop, color], index, stopsArr) => {
1460
- const prevStop = (stopsArr[index - 1] || [0])[0];
1461
- if (prevStop === stop)
1462
- return /* @__PURE__ */ jsx12("div", {}, color);
1463
- return /* @__PURE__ */ jsxs7("li", {
1464
- className: tw8`flex gap-2 items-center mb-1`,
1465
- children: [
1466
- /* @__PURE__ */ jsx12("svg", {
1467
- viewBox: "0 0 24 24",
1468
- height: "14",
1469
- width: "14",
1470
- focusable: "false",
1471
- children: /* @__PURE__ */ jsx12("circle", {
1472
- cx: "12",
1473
- fill: color,
1474
- cy: "12",
1475
- r: "12",
1476
- stroke: "none"
1477
- })
1478
- }),
1479
- /* @__PURE__ */ jsxs7("div", {
1480
- children: [
1481
- prevStop,
1482
- " - ",
1483
- stop
1484
- ]
1485
- })
1486
- ]
1487
- }, color);
1488
- }),
1489
- /* @__PURE__ */ jsxs7("li", {
1490
- children: [
1491
- "1 Square = ",
1492
- legendInfo == null ? void 0 : legendInfo.squareSize,
1493
- " x ",
1494
- legendInfo == null ? void 0 : legendInfo.squareSize,
1495
- " km"
1496
- ]
1497
- })
1498
- ]
1499
- })
1500
- });
1501
- }
1502
-
1503
- // src/components/sidebar/common/info-popover.tsx
1504
- import { LICENSES, useT as useT4 } from "@biodiv-platform/naksha-commons";
1505
- import { useState as useState4 } from "react";
1506
- import { Popover } from "react-tiny-popover";
1507
- import { tw as tw9 } from "twind";
1508
- import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
1509
- var LayerInfoLine = ({
1510
- icon,
1511
- name,
1512
- title,
1513
- link,
1514
- children
1515
- }) => {
1516
- const content = /* @__PURE__ */ jsx13("span", {
1517
- children: children || "-"
1518
- });
1519
- return /* @__PURE__ */ jsxs8("div", {
1520
- className: tw9`flex gap-3 text-sm text-gray-600 break-all`,
1521
- title: name && title && `${name}: ${title}`,
1522
- children: [
1523
- /* @__PURE__ */ jsx13("div", {
1524
- children: icon
1525
- }),
1526
- link ? /* @__PURE__ */ jsx13("a", {
1527
- className: tw9`text-blue-700 focus:outline-none focus:ring`,
1528
- target: "_blank",
1529
- rel: "noopener",
1530
- href: link,
1531
- children: content
1532
- }) : content
1533
- ]
1534
- });
1535
- };
1536
- function InfoPopover({ item, containerStyle }) {
1537
- var _a;
1538
- const { t } = useT4();
1539
- const { layer, mp } = useLayers();
1540
- const license = item.license || "CC-BY";
1541
- const createdOn = (item == null ? void 0 : item.createdDate) && new Date(item.createdDate).toLocaleDateString();
1542
- const tags = (_a = item.tags) == null ? void 0 : _a.join(", ");
1543
- return /* @__PURE__ */ jsxs8("div", {
1544
- className: tw9`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,
1545
- style: containerStyle,
1546
- children: [
1547
- mp.managePublishing && item.layerStatus && /* @__PURE__ */ jsxs8(LayerInfoLine, {
1548
- icon: /* @__PURE__ */ jsx13(EyeIcon, {}),
1549
- name: t("visiblity"),
1550
- title: item.layerStatus,
1551
- children: [
1552
- item.layerStatus,
1553
- /* @__PURE__ */ jsx13("button", {
1554
- className: tw9`text-blue-600 focus:outline-none ml-4`,
1555
- onClick: () => layer.togglePublish(item.id, item == null ? void 0 : item.layerStatus),
1556
- children: t("toggle")
1557
- }),
1558
- /* @__PURE__ */ jsx13("button", {
1559
- className: tw9`text-red-600 focus:outline-none ml-4`,
1560
- onClick: () => layer.delete(item.id, t("are_you_sure")),
1561
- children: t("delete")
1562
- })
1563
- ]
1564
- }),
1565
- /* @__PURE__ */ jsx13(LayerInfoLine, {
1566
- icon: /* @__PURE__ */ jsx13(AttributionIcon, {}),
1567
- link: item.url,
1568
- name: t("uploader"),
1569
- title: item.createdBy,
1570
- children: item.createdBy
1571
- }),
1572
- /* @__PURE__ */ jsx13(LayerInfoLine, {
1573
- icon: /* @__PURE__ */ jsx13(AttributionIcon, {}),
1574
- link: item.url,
1575
- name: t("created_by"),
1576
- title: item.attribution,
1577
- children: item.attribution
1578
- }),
1579
- /* @__PURE__ */ jsx13(LayerInfoLine, {
1580
- icon: /* @__PURE__ */ jsx13(ClockIcon, {}),
1581
- name: t("created_on"),
1582
- title: createdOn,
1583
- children: createdOn
1584
- }),
1585
- /* @__PURE__ */ jsx13(LayerInfoLine, {
1586
- icon: /* @__PURE__ */ jsx13(TagIcon, {}),
1587
- name: t("tags"),
1588
- title: tags,
1589
- children: tags
1590
- }),
1591
- /* @__PURE__ */ jsx13(LayerInfoLine, {
1592
- name: t("license"),
1593
- title: license,
1594
- link: license && LICENSES[license],
1595
- icon: /* @__PURE__ */ jsx13(LicenseIcon, {}),
1596
- children: license
1597
- })
1598
- ]
1599
- });
1600
- }
1601
- var PopoverWrapper = ({ item }) => {
1602
- const [isPopoverOpen, setIsPopoverOpen] = useState4(false);
1603
- const togglePopover = () => setIsPopoverOpen(!isPopoverOpen);
1604
- return /* @__PURE__ */ jsx13(Popover, {
1605
- isOpen: isPopoverOpen,
1606
- padding: 10,
1607
- positions: ["right"],
1608
- containerStyle: { zIndex: 99 },
1609
- onClickOutside: togglePopover,
1610
- content: /* @__PURE__ */ jsx13(InfoPopover, {
1611
- item
1612
- }),
1613
- children: /* @__PURE__ */ jsx13(Button, {
1614
- onClick: togglePopover,
1615
- children: /* @__PURE__ */ jsx13(InfoIcon, {}),
1616
- title: "Information"
1617
- })
1618
- });
1619
- };
1620
-
1621
- // src/components/sidebar/common/layer-item-style.tsx
1622
- import { tw as tw11 } from "twind";
1623
-
1624
- // src/components/sidebar/common/style-legend.tsx
1625
- import { useMemo as useMemo2, useState as useState5 } from "react";
1626
- import { useT as useT5 } from "@biodiv-platform/naksha-commons";
1627
- import { tw as tw10 } from "twind";
1628
- import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
1629
- function StyleLegend({ item }) {
1630
- var _a;
1631
- const [showImage, setShowImage] = useState5(true);
1632
- const { mp } = useLayers();
1633
- const { t } = useT5();
1634
- const legendStyles = useMemo2(
1635
- () => {
1636
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1637
- return ((_f = (_e = (_d = (_c = (_b = (_a2 = item == null ? void 0 : item.data) == null ? void 0 : _a2.styles) == null ? void 0 : _b[item.data.styleIndex]) == null ? void 0 : _c.colors) == null ? void 0 : _d.paint) == null ? void 0 : _e["fill-color"]) == null ? void 0 : _f.stops) || ((_l = (_k = (_j = (_i = (_h = (_g = item == null ? void 0 : item.data) == null ? void 0 : _g.styles) == null ? void 0 : _h[item.data.styleIndex]) == null ? void 0 : _i.colors) == null ? void 0 : _j.paint) == null ? void 0 : _k["circle-color"]) == null ? void 0 : _l.stops) || [];
1638
- },
1639
- [item]
1640
- );
1641
- const vectorLegend = () => {
1642
- return legendStyles.map(([title, color]) => /* @__PURE__ */ jsxs9("li", {
1643
- className: tw10`flex gap-2 items-center mb-1`,
1644
- children: [
1645
- /* @__PURE__ */ jsx14("svg", {
1646
- viewBox: "0 0 24 24",
1647
- height: "14",
1648
- width: "14",
1649
- focusable: "false",
1650
- children: /* @__PURE__ */ jsx14("circle", {
1651
- cx: "12",
1652
- fill: color,
1653
- cy: "12",
1654
- r: "12",
1655
- stroke: "none"
1656
- })
1657
- }),
1658
- /* @__PURE__ */ jsx14("div", {
1659
- children: title
1660
- })
1661
- ]
1662
- }, color));
1663
- };
1664
- return /* @__PURE__ */ jsx14("ul", {
1665
- style: { margin: 0, padding: 0 },
1666
- children: item.layerType !== "RASTER" ? vectorLegend() : showImage ? /* @__PURE__ */ jsx14("li", {
1667
- children: /* @__PURE__ */ jsx14("img", {
1668
- style: { margin: "5px" },
1669
- onError: () => setShowImage(false),
1670
- src: `${(_a = mp == null ? void 0 : mp.geoserver) == null ? void 0 : _a.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${item.id}`
1671
- })
1672
- }) : /* @__PURE__ */ jsx14("div", {
1673
- children: t("raster_style_not_found")
1674
- })
1675
- });
1676
- }
1677
-
1678
- // src/components/sidebar/common/layer-item-style.tsx
1679
- import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
1680
- function LayerItemStyle({ item }) {
1681
- var _a, _b;
1682
- if (!((_a = item.data) == null ? void 0 : _a.styles))
1683
- return null;
1684
- const { layer } = useLayers();
1685
- const onStyleChange = (e) => {
1686
- layer.updateStyle(item.id, Number(e.target.value));
1687
- };
1688
- return /* @__PURE__ */ jsxs10("div", {
1689
- className: tw11`flex flex-col gap-4 pt-2`,
1690
- children: [
1691
- item.layerType !== "RASTER" && /* @__PURE__ */ jsx15(SelectInput, {
1692
- onChange: onStyleChange,
1693
- children: (_b = item.data) == null ? void 0 : _b.styles.map((opt, idx) => /* @__PURE__ */ jsx15("option", {
1694
- value: idx,
1695
- children: opt.styleTitle
1696
- }, idx))
1697
- }),
1698
- /* @__PURE__ */ jsx15(MoreLess, {
1699
- children: /* @__PURE__ */ jsx15(StyleLegend, {
1700
- item
1701
- })
1702
- })
1703
- ]
1704
- });
1705
- }
1706
-
1707
- // src/components/sidebar/common/layer-item.tsx
1708
- import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
1709
- var DragHandle = SortableHandle(() => /* @__PURE__ */ jsx16("div", {
1710
- className: tw12`mt-1 w-6 text-center cursor-move`,
1711
- children: /* @__PURE__ */ jsx16(GrabberIcon, {})
1712
- }));
1713
- function LayerItem({ item, extended }) {
1714
- const { t } = useT6();
1715
- const { layer, query, mp, query: { setClickedLngLat }, setIsInfoBarOpen } = useLayers();
1716
- const [isAdded, setIsAdded] = useState6(layer.selectedIds.includes(item.id));
1717
- const [isLoading, setIsLoading] = useState6(false);
1718
- const shareData = useMemo3(
1719
- () => mp.canLayerShare ? {
1720
- url: `${window.location.href.split("?")[0]}?layers=${item.id}`,
1721
- title: item.title
1722
- } : void 0,
1723
- [item.id]
1724
- );
1725
- const onToggleLayer = () => __async(this, null, function* () {
1726
- setIsLoading(true);
1727
- setIsInfoBarOpen(true);
1728
- layer.setSelectedFeatures([]);
1729
- setClickedLngLat(null);
1730
- yield layer.toggle({ layerId: item.id, add: !isAdded });
1731
- setIsAdded(!isAdded);
1732
- setIsLoading(false);
1733
- });
1734
- const onDownloadLayer = () => __async(this, null, function* () {
1735
- yield axDownloadLayer(
1736
- mp.nakshaApiEndpoint,
1737
- mp.nakshaEndpointToken,
1738
- item.id,
1739
- item.title
1740
- );
1741
- mp == null ? void 0 : mp.onLayerDownload(item.id);
1742
- });
1743
- const handleOnZoom = () => layer.zoomToExtent(item.id);
1744
- return /* @__PURE__ */ jsxs11("div", {
1745
- className: tw12`z-20 p-3 bg-white`,
1746
- style: { borderTop: "1px solid #e5e7eb" },
1747
- children: [
1748
- /* @__PURE__ */ jsxs11("div", {
1749
- className: tw12`flex gap-3`,
1750
- children: [
1751
- /* @__PURE__ */ jsxs11("div", {
1752
- className: tw12`flex-shrink-0`,
1753
- children: [
1754
- /* @__PURE__ */ jsx16(CheckboxInput, {
1755
- name: item.id,
1756
- checked: isAdded,
1757
- onChange: onToggleLayer,
1758
- isLoading
1759
- }),
1760
- extended && /* @__PURE__ */ jsx16(DragHandle, {})
1761
- ]
1762
- }),
1763
- /* @__PURE__ */ jsx16("img", {
1764
- className: tw12`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,
1765
- src: item.thumbnail || FALLBACK_THUMB
1766
- }),
1767
- /* @__PURE__ */ jsxs11("div", {
1768
- children: [
1769
- /* @__PURE__ */ jsx16("div", {
1770
- title: item.title,
1771
- className: tw12`mb-1 leading-tight`,
1772
- style: overflowStyle,
1773
- children: /* @__PURE__ */ jsx16(Highlighted, {
1774
- text: item.title,
1775
- highlight: query.term
1776
- })
1777
- }),
1778
- /* @__PURE__ */ jsx16("p", {
1779
- title: item.description,
1780
- className: tw12`text-gray-600 text-sm`,
1781
- style: overflowStyle2,
1782
- children: item.description
1783
- })
1784
- ]
1785
- })
1786
- ]
1787
- }),
1788
- /* @__PURE__ */ jsxs11("div", {
1789
- className: tw12`flex justify-between`,
1790
- children: [
1791
- /* @__PURE__ */ jsxs11(Button, {
1792
- onClick: onDownloadLayer,
1793
- disabled: !item.isDownloadable,
1794
- children: [
1795
- /* @__PURE__ */ jsx16(DownloadIcon, {}),
1796
- " ",
1797
- t("download")
1798
- ]
1799
- }),
1800
- /* @__PURE__ */ jsxs11("div", {
1801
- className: tw12`flex gap-3`,
1802
- children: [
1803
- shareData && /* @__PURE__ */ jsx16(RWebShare, {
1804
- data: shareData,
1805
- children: /* @__PURE__ */ jsx16(Button, {
1806
- title: "Share",
1807
- children: /* @__PURE__ */ jsx16(ShareIcon, {})
1808
- })
1809
- }),
1810
- extended && /* @__PURE__ */ jsx16(Button, {
1811
- onClick: handleOnZoom,
1812
- title: "Zoom To Extent",
1813
- children: /* @__PURE__ */ jsx16(ZoomExtentIcon, {})
1814
- }),
1815
- /* @__PURE__ */ jsx16(PopoverWrapper, {
1816
- item
1817
- })
1818
- ]
1819
- })
1820
- ]
1821
- }),
1822
- extended && /* @__PURE__ */ jsx16(LayerItemStyle, {
1823
- item
1824
- }),
1825
- extended && item.source.type === "grid" && /* @__PURE__ */ jsx16(GridLegend, {
1826
- item
1827
- })
1828
- ]
1829
- });
1830
- }
1831
-
1832
- // src/components/sidebar/layers/layer-list.tsx
1833
- import { jsx as jsx17 } from "react/jsx-runtime";
1834
- function LayerList() {
1835
- const { layer, query } = useLayers();
1836
- const filteredLayers = useMemo4(
1837
- () => query.term ? layer.all.filter(
1838
- (_l) => _l.title.toLowerCase().includes(query.term.toLowerCase())
1839
- ) : layer.all,
1840
- [layer.all, query.term]
1841
- );
1842
- const parentRef = React8.useRef();
1843
- const rowVirtualizer = useVirtual({
1844
- size: filteredLayers.length,
1845
- parentRef
1846
- });
1847
- return /* @__PURE__ */ jsx17("div", {
1848
- className: tw13`flex-grow-1 relative`,
1849
- children: /* @__PURE__ */ jsx17(AutoSizer, {
1850
- disableWidth: true,
1851
- children: (p) => /* @__PURE__ */ jsx17("div", {
1852
- ref: parentRef,
1853
- className: "List",
1854
- style: { height: p.height, overflow: "auto" },
1855
- children: /* @__PURE__ */ jsx17("div", {
1856
- style: {
1857
- height: rowVirtualizer.totalSize,
1858
- width: "100%",
1859
- position: "relative"
1860
- },
1861
- children: rowVirtualizer.virtualItems.map((virtualRow) => /* @__PURE__ */ jsx17("div", {
1862
- ref: virtualRow.measureRef,
1863
- className: tw13`absolute top-0 left-0 w-full`,
1864
- style: { transform: `translateY(${virtualRow.start}px)` },
1865
- children: /* @__PURE__ */ jsx17("div", {
1866
- style: { height: 146 },
1867
- children: /* @__PURE__ */ jsx17(LayerItem, {
1868
- item: filteredLayers[virtualRow.index]
1869
- })
1870
- })
1871
- }, virtualRow.index))
1872
- })
1873
- })
1874
- })
1875
- });
1876
- }
1877
-
1878
- // src/components/sidebar/layers/search.tsx
1879
- import { useT as useT7 } from "@biodiv-platform/naksha-commons";
1880
- import { tw as tw14 } from "twind";
1881
- import { jsx as jsx18 } from "react/jsx-runtime";
1882
- function LayerSearch() {
1883
- const { t } = useT7();
1884
- const { query } = useLayers();
1885
- const handleOnSearchChange = (e) => query.setTerm(e.target.value);
1886
- return /* @__PURE__ */ jsx18("div", {
1887
- className: tw14`flex-shrink-0 border-b-2 p-4`,
1888
- children: /* @__PURE__ */ jsx18(SearchInput, {
1889
- name: "lyr_search",
1890
- placeholder: t("find_layer_by_name"),
1891
- onChange: handleOnSearchChange
1892
- })
1893
- });
1894
- }
1895
-
1896
- // src/components/sidebar/layers/index.tsx
1897
- import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
1898
- function LayersTabPanel() {
1899
- return /* @__PURE__ */ jsxs12("div", {
1900
- className: tw15`flex flex-col w-full`,
1901
- children: [
1902
- /* @__PURE__ */ jsx19(LayerSearch, {}),
1903
- /* @__PURE__ */ jsx19(LayerList, {})
1904
- ]
1905
- });
1906
- }
1907
-
1908
- // src/utils/array-move.ts
1909
- function arrayMoveMutable(array, fromIndex, toIndex) {
1910
- const startIndex = fromIndex < 0 ? array.length + fromIndex : fromIndex;
1911
- if (startIndex >= 0 && startIndex < array.length) {
1912
- const endIndex = toIndex < 0 ? array.length + toIndex : toIndex;
1913
- const [item] = array.splice(fromIndex, 1);
1914
- array.splice(endIndex, 0, item);
1915
- }
1916
- }
1917
- function arrayMoveImmutable(array, fromIndex, toIndex) {
1918
- array = [...array];
1919
- arrayMoveMutable(array, fromIndex, toIndex);
1920
- return array;
1921
- }
1922
-
1923
- // src/components/sidebar/selected/selected-item-list.tsx
1924
- import { SortableContainer, SortableElement } from "react-sortable-hoc";
1925
- import { jsx as jsx20 } from "react/jsx-runtime";
1926
- var SelectedItem = SortableElement(({ item, extended }) => /* @__PURE__ */ jsx20(LayerItem, {
1927
- item,
1928
- extended
1929
- }));
1930
- var SelectedItemList = SortableContainer(({ layerList }) => /* @__PURE__ */ jsx20("div", {
1931
- children: layerList.map((item, index) => /* @__PURE__ */ jsx20(SelectedItem, {
1932
- index,
1933
- item,
1934
- extended: true
1935
- }, item.id))
1936
- }));
1937
-
1938
- // src/components/sidebar/selected/index.tsx
1939
- import { useT as useT8 } from "@biodiv-platform/naksha-commons";
1940
- import { tw as tw16 } from "twind";
1941
- import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
1942
- function SelectedTabPanel() {
1943
- const { layer } = useLayers();
1944
- const { t } = useT8();
1945
- const onSortEnd = ({ oldIndex, newIndex }) => {
1946
- layer.setSelectedIds(
1947
- arrayMoveImmutable(layer.selectedIds, oldIndex, newIndex)
1948
- );
1949
- };
1950
- return /* @__PURE__ */ jsxs13("div", {
1951
- className: tw16`flex flex-col gap-3 w-full`,
1952
- children: [
1953
- layer.selectedIds.length > 0 && /* @__PURE__ */ jsx21("div", {
1954
- className: tw16`p-3 pb-0`,
1955
- children: /* @__PURE__ */ jsxs13(Button, {
1956
- onClick: () => layer.clearAll(),
1957
- children: [
1958
- "\u2715 ",
1959
- t("clear")
1960
- ]
1961
- })
1962
- }),
1963
- /* @__PURE__ */ jsx21(SelectedItemList, {
1964
- layerList: layer.selectedLayers,
1965
- useDragHandle: true,
1966
- onSortEnd
1967
- })
1968
- ]
1969
- });
1970
- }
1971
-
1972
- // src/components/sidebar/settings/index.tsx
1973
- import { useT as useT9 } from "@biodiv-platform/naksha-commons";
1974
- import { tw as tw17 } from "twind";
1975
- import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
1976
- function SettingsTabPanel() {
1977
- const { layer } = useLayers();
1978
- const { t } = useT9();
1979
- const handleOnStyleChange = (e) => {
1980
- var _a;
1981
- layer.setMapStyle(e.target.value);
1982
- layer.setMaxZoom(
1983
- (_a = layer.mapStyles.find((ms) => ms.style === e.target.value)) == null ? void 0 : _a.maxZoom
1984
- );
1985
- };
1986
- return /* @__PURE__ */ jsxs14("div", {
1987
- className: tw17`w-full p-4 flex flex-col gap-4`,
1988
- children: [
1989
- /* @__PURE__ */ jsx22(SelectInput, {
1990
- name: "base_style",
1991
- label: t("base_style"),
1992
- defaultValue: layer.mapStyle,
1993
- onChange: handleOnStyleChange,
1994
- children: layer.mapStyles.map((ms) => /* @__PURE__ */ jsx22("option", {
1995
- value: ms.style,
1996
- children: ms.text
1997
- }, ms.key))
1998
- }),
1999
- /* @__PURE__ */ jsx22(LayerSelection, {})
2000
- ]
2001
- });
2002
- }
2003
-
2004
- // src/components/sidebar/tabs.tsx
2005
- import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
2006
- function SidebarTabs({ onClose }) {
2007
- const { t } = useT10();
2008
- return /* @__PURE__ */ jsxs15("div", {
2009
- className: tw18`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,
2010
- children: [
2011
- /* @__PURE__ */ jsx23(CloseButton, {
2012
- onClick: onClose
2013
- }),
2014
- /* @__PURE__ */ jsx23("div", {
2015
- className: tw18`flex flex-col h-full`,
2016
- children: /* @__PURE__ */ jsxs15(Tabs, {
2017
- children: [
2018
- /* @__PURE__ */ jsxs15(TabHeader, {
2019
- children: [
2020
- /* @__PURE__ */ jsx23(IconTab, {
2021
- icon: /* @__PURE__ */ jsx23(LayersIcon, {}),
2022
- children: t("layers")
2023
- }),
2024
- /* @__PURE__ */ jsx23(IconTab, {
2025
- icon: /* @__PURE__ */ jsx23(LayersIcon, {}),
2026
- children: t("selected")
2027
- }),
2028
- /* @__PURE__ */ jsx23(IconTab, {
2029
- icon: /* @__PURE__ */ jsx23(SlidersIcon, {}),
2030
- children: t("settings")
2031
- })
2032
- ]
2033
- }),
2034
- /* @__PURE__ */ jsx23(Panel, {
2035
- children: /* @__PURE__ */ jsx23(LayersTabPanel, {})
2036
- }),
2037
- /* @__PURE__ */ jsx23(Panel, {
2038
- children: /* @__PURE__ */ jsx23(SelectedTabPanel, {})
2039
- }),
2040
- /* @__PURE__ */ jsx23(Panel, {
2041
- children: /* @__PURE__ */ jsx23(SettingsTabPanel, {})
2042
- })
2043
- ]
2044
- })
2045
- })
2046
- ]
2047
- });
2048
- }
2049
-
2050
- // src/components/sidebar/index.tsx
2051
- import { jsx as jsx24 } from "react/jsx-runtime";
2052
- function Sidebar() {
2053
- const { mp, layer } = useLayers();
2054
- const [isOpen, setIsOpen] = useState8(mp.showToC);
2055
- const { mapl } = useMap2();
2056
- const toggleOpen = () => setIsOpen(!isOpen);
2057
- function loadToC() {
2058
- return __async(this, null, function* () {
2059
- const _layers = yield axGetGeoserverLayers(
2060
- mp.nakshaEndpointToken,
2061
- mp.nakshaApiEndpoint,
2062
- mp.geoserver,
2063
- mp.selectedLayers
2064
- );
2065
- const _newLayers = [...mp.layers || [], ..._layers];
2066
- layer.setAll(_newLayers);
2067
- if (layer.selectedIds.length) {
2068
- const _layer = _newLayers.find((l) => l.id === layer.selectedIds[0]);
2069
- (_layer == null ? void 0 : _layer.bbox) && (mapl == null ? void 0 : mapl.fitBounds(_layer.bbox, { padding: 40, duration: 1e3 }));
2070
- }
2071
- });
2072
- }
2073
- useEffect3(() => {
2074
- if (mapl && mp.loadToC) {
2075
- loadToC();
2076
- }
2077
- }, [mapl]);
2078
- return isOpen ? /* @__PURE__ */ jsx24(SidebarTabs, {
2079
- onClose: toggleOpen
2080
- }) : /* @__PURE__ */ jsx24(LayersButton, {
2081
- onClick: toggleOpen
2082
- });
2083
- }
2084
-
2085
- // src/components/map/layers/index.tsx
2086
- import { useMap as useMap4 } from "react-map-gl/maplibre";
2087
-
2088
- // ../../node_modules/@turf/helpers/dist/es/index.js
2089
- var earthRadius = 63710088e-1;
2090
- var factors = {
2091
- centimeters: earthRadius * 100,
2092
- centimetres: earthRadius * 100,
2093
- degrees: earthRadius / 111325,
2094
- feet: earthRadius * 3.28084,
2095
- inches: earthRadius * 39.37,
2096
- kilometers: earthRadius / 1e3,
2097
- kilometres: earthRadius / 1e3,
2098
- meters: earthRadius,
2099
- metres: earthRadius,
2100
- miles: earthRadius / 1609.344,
2101
- millimeters: earthRadius * 1e3,
2102
- millimetres: earthRadius * 1e3,
2103
- nauticalmiles: earthRadius / 1852,
2104
- radians: 1,
2105
- yards: earthRadius * 1.0936
2106
- };
2107
- var unitsFactors = {
2108
- centimeters: 100,
2109
- centimetres: 100,
2110
- degrees: 1 / 111325,
2111
- feet: 3.28084,
2112
- inches: 39.37,
2113
- kilometers: 1 / 1e3,
2114
- kilometres: 1 / 1e3,
2115
- meters: 1,
2116
- metres: 1,
2117
- miles: 1 / 1609.344,
2118
- millimeters: 1e3,
2119
- millimetres: 1e3,
2120
- nauticalmiles: 1 / 1852,
2121
- radians: 1 / earthRadius,
2122
- yards: 1.0936133
2123
- };
2124
-
2125
- // ../../node_modules/@turf/meta/dist/es/index.js
2126
- function coordEach(geojson, callback, excludeWrapCoord) {
2127
- if (geojson === null)
2128
- return;
2129
- var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
2130
- for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
2131
- geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
2132
- isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
2133
- stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
2134
- for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
2135
- var multiFeatureIndex = 0;
2136
- var geometryIndex = 0;
2137
- geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
2138
- if (geometry === null)
2139
- continue;
2140
- coords = geometry.coordinates;
2141
- var geomType = geometry.type;
2142
- wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
2143
- switch (geomType) {
2144
- case null:
2145
- break;
2146
- case "Point":
2147
- if (callback(
2148
- coords,
2149
- coordIndex,
2150
- featureIndex,
2151
- multiFeatureIndex,
2152
- geometryIndex
2153
- ) === false)
2154
- return false;
2155
- coordIndex++;
2156
- multiFeatureIndex++;
2157
- break;
2158
- case "LineString":
2159
- case "MultiPoint":
2160
- for (j = 0; j < coords.length; j++) {
2161
- if (callback(
2162
- coords[j],
2163
- coordIndex,
2164
- featureIndex,
2165
- multiFeatureIndex,
2166
- geometryIndex
2167
- ) === false)
2168
- return false;
2169
- coordIndex++;
2170
- if (geomType === "MultiPoint")
2171
- multiFeatureIndex++;
2172
- }
2173
- if (geomType === "LineString")
2174
- multiFeatureIndex++;
2175
- break;
2176
- case "Polygon":
2177
- case "MultiLineString":
2178
- for (j = 0; j < coords.length; j++) {
2179
- for (k = 0; k < coords[j].length - wrapShrink; k++) {
2180
- if (callback(
2181
- coords[j][k],
2182
- coordIndex,
2183
- featureIndex,
2184
- multiFeatureIndex,
2185
- geometryIndex
2186
- ) === false)
2187
- return false;
2188
- coordIndex++;
2189
- }
2190
- if (geomType === "MultiLineString")
2191
- multiFeatureIndex++;
2192
- if (geomType === "Polygon")
2193
- geometryIndex++;
2194
- }
2195
- if (geomType === "Polygon")
2196
- multiFeatureIndex++;
2197
- break;
2198
- case "MultiPolygon":
2199
- for (j = 0; j < coords.length; j++) {
2200
- geometryIndex = 0;
2201
- for (k = 0; k < coords[j].length; k++) {
2202
- for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
2203
- if (callback(
2204
- coords[j][k][l],
2205
- coordIndex,
2206
- featureIndex,
2207
- multiFeatureIndex,
2208
- geometryIndex
2209
- ) === false)
2210
- return false;
2211
- coordIndex++;
2212
- }
2213
- geometryIndex++;
2214
- }
2215
- multiFeatureIndex++;
2216
- }
2217
- break;
2218
- case "GeometryCollection":
2219
- for (j = 0; j < geometry.geometries.length; j++)
2220
- if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
2221
- return false;
2222
- break;
2223
- default:
2224
- throw new Error("Unknown Geometry Type");
2225
- }
2226
- }
2227
- }
2228
- }
2229
-
2230
- // ../../node_modules/@turf/bbox/dist/es/index.js
2231
- function bbox(geojson) {
2232
- var result = [Infinity, Infinity, -Infinity, -Infinity];
2233
- coordEach(geojson, function(coord) {
2234
- if (result[0] > coord[0]) {
2235
- result[0] = coord[0];
2236
- }
2237
- if (result[1] > coord[1]) {
2238
- result[1] = coord[1];
2239
- }
2240
- if (result[2] < coord[0]) {
2241
- result[2] = coord[0];
2242
- }
2243
- if (result[3] < coord[1]) {
2244
- result[3] = coord[1];
2245
- }
2246
- });
2247
- return result;
2248
- }
2249
- bbox["default"] = bbox;
2250
- var es_default = bbox;
2251
-
2252
- // src/components/map/layers/grid/index.tsx
2253
- import { useEffect as useEffect4, useState as useState9 } from "react";
2254
- import { Layer, Source, useMap as useMap3 } from "react-map-gl/maplibre";
2255
- import { jsx as jsx25 } from "react/jsx-runtime";
2256
- function GridLayer({
2257
- data,
2258
- beforeId
2259
- }) {
2260
- const { layer } = useLayers();
2261
- const { mapl } = useMap3();
2262
- const [layerData, setLayerData] = useState9({ geojson: {}, paint: {} });
2263
- const isSelected = layer.selectedIds.includes(data.id);
2264
- const isLastSelected = layer.selectedIds[0] === data.id;
2265
- const fetchGridData = (shouldFitBounds = false) => __async(this, null, function* () {
2266
- const { success, geojson, paint: paint2, stops, squareSize } = yield getGridLayerData(
2267
- data.source.fetcher,
2268
- mapl == null ? void 0 : mapl.getBounds(),
2269
- mapl == null ? void 0 : mapl.getZoom()
2270
- );
2271
- if (success) {
2272
- setLayerData({ geojson, paint: paint2 });
2273
- if (shouldFitBounds && isLastSelected && data.zoomToFit) {
2274
- try {
2275
- const [minLon, minLat, maxLon, maxLat] = es_default(geojson);
2276
- mapl == null ? void 0 : mapl.fitBounds(
2277
- [
2278
- [minLon, minLat],
2279
- [maxLon, maxLat]
2280
- ],
2281
- { padding: 40, animate: true }
2282
- );
2283
- } catch (e) {
2284
- console.warn("Failed to compute bbox", e);
2285
- }
2286
- }
2287
- layer.setGridLegends({
2288
- [data.id]: { stops, squareSize }
2289
- });
2290
- }
2291
- });
2292
- useEffect4(() => {
2293
- if (isSelected && isLastSelected) {
2294
- fetchGridData(true);
2295
- } else if (isSelected) {
2296
- fetchGridData(false);
2297
- }
2298
- }, [isSelected, isLastSelected]);
2299
- useEffect4(() => {
2300
- if (!isSelected || !mapl)
2301
- return;
2302
- const handleIdle = () => fetchGridData(false);
2303
- mapl.on("idle", handleIdle);
2304
- return () => {
2305
- mapl.off("idle", handleIdle);
2306
- };
2307
- }, [isSelected, mapl]);
2308
- useEffect4(() => {
2309
- return () => {
2310
- layer.setGridLegends((prev) => {
2311
- const newLegends = __spreadValues({}, prev);
2312
- delete newLegends[data.id];
2313
- return newLegends;
2314
- });
2315
- };
2316
- }, [data.id]);
2317
- return /* @__PURE__ */ jsx25(Source, {
2318
- id: data.id,
2319
- type: "geojson",
2320
- data: layerData.geojson,
2321
- children: /* @__PURE__ */ jsx25(Layer, {
2322
- beforeId,
2323
- id: data.id,
2324
- type: "fill",
2325
- paint: layerData.paint
2326
- })
2327
- });
2328
- }
2329
-
2330
- // src/components/map/layers/vector/index.tsx
2331
- import { useMemo as useMemo5 } from "react";
2332
- import { Layer as Layer2, Source as Source2 } from "react-map-gl/maplibre";
2333
- import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
2334
- var paint = {
2335
- fill: {
2336
- "line-color": "red",
2337
- "line-width": 2
2338
- },
2339
- circle: {
2340
- "circle-stroke-color": "red",
2341
- "circle-stroke-width": 2,
2342
- "circle-opacity": 0
2343
- }
2344
- };
2345
- function VectorLayer({ layer: data, beforeId }) {
2346
- var _a;
2347
- const { layer } = useLayers();
2348
- const layerProps = useMemo5(
2349
- () => {
2350
- var _a2, _b, _c, _d;
2351
- return (_d = (_c = (_a2 = data.data) == null ? void 0 : _a2.styles) == null ? void 0 : _c[(_b = data.data) == null ? void 0 : _b.styleIndex]) == null ? void 0 : _d.colors;
2352
- },
2353
- [data, layer.selectedFeatures]
2354
- );
2355
- const highlightData = (_a = layer.selectedFeaturesId) == null ? void 0 : _a[data.id];
2356
- return /* @__PURE__ */ jsxs16(Source2, __spreadProps(__spreadValues({}, data.source), {
2357
- children: [
2358
- layerProps && /* @__PURE__ */ jsx26(Layer2, __spreadValues({
2359
- beforeId
2360
- }, layerProps)),
2361
- highlightData && layerProps && /* @__PURE__ */ jsx26(Layer2, __spreadProps(__spreadValues({}, layerProps), {
2362
- beforeId,
2363
- id: `hl_${data.id}`,
2364
- filter: ["in", PROPERTY_ID, ...highlightData],
2365
- type: layerProps.type === "fill" ? "line" : layerProps.type,
2366
- paint: paint[layerProps.type]
2367
- }))
2368
- ]
2369
- }));
2370
- }
2371
-
2372
- // src/components/map/layers/raster/index.tsx
2373
- import { Layer as Layer3, Source as Source3 } from "react-map-gl/maplibre";
2374
- import { jsx as jsx27 } from "react/jsx-runtime";
2375
- function RasterLayer({
2376
- data,
2377
- beforeId
2378
- }) {
2379
- var _a;
2380
- const { mp } = useLayers();
2381
- return /* @__PURE__ */ jsx27(Source3, {
2382
- id: data.id,
2383
- type: "raster",
2384
- tiles: [
2385
- `${(_a = mp == null ? void 0 : mp.geoserver) == null ? void 0 : _a.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${data.id}`
2386
- ],
2387
- tileSize: 256,
2388
- children: /* @__PURE__ */ jsx27(Layer3, {
2389
- id: data.id,
2390
- beforeId,
2391
- type: "raster",
2392
- source: "biodiv",
2393
- layout: { visibility: "visible" },
2394
- paint: {}
2395
- })
2396
- });
2397
- }
2398
-
2399
- // src/components/map/layers/index.tsx
2400
- import { jsx as jsx28 } from "react/jsx-runtime";
2401
- function MapLayer({
2402
- layer,
2403
- beforeId
2404
- }) {
2405
- const { mapl } = useMap4();
2406
- if (!mapl) {
2407
- return null;
2408
- }
2409
- switch (layer.source.type) {
2410
- case "vector":
2411
- return /* @__PURE__ */ jsx28(VectorLayer, {
2412
- beforeId,
2413
- layer
2414
- });
2415
- case "grid":
2416
- return /* @__PURE__ */ jsx28(GridLayer, {
2417
- beforeId,
2418
- data: layer
2419
- });
2420
- case "raster":
2421
- return /* @__PURE__ */ jsx28(RasterLayer, {
2422
- beforeId,
2423
- data: layer
2424
- });
2425
- default:
2426
- return /* @__PURE__ */ jsx28(VectorLayer, {
2427
- beforeId,
2428
- layer
2429
- });
2430
- }
2431
- }
2432
-
2433
- // src/components/map/markers-list/index.tsx
2434
- import { useMemo as useMemo6 } from "react";
2435
- import { Marker } from "react-map-gl/maplibre";
2436
- import { Fragment as Fragment2, jsx as jsx29 } from "react/jsx-runtime";
2437
- var Marker1 = Marker;
2438
- var MarkersList = () => {
2439
- const { mp } = useLayers();
2440
- const markersMemoized = useMemo6(() => mp.markers, [mp.markers]);
2441
- return /* @__PURE__ */ jsx29(Fragment2, {
2442
- children: markersMemoized == null ? void 0 : markersMemoized.map(({ latitude, longitude, colorHex }, index) => /* @__PURE__ */ jsx29(Marker1, {
2443
- latitude,
2444
- longitude,
2445
- children: /* @__PURE__ */ jsx29("img", {
2446
- style: { cursor: "pointer" },
2447
- alt: "Marker",
2448
- src: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"
2449
- })
2450
- }, index))
2451
- });
2452
- };
2453
- var markers_list_default = MarkersList;
2454
-
2455
- // src/components/map/popup/index.tsx
2456
- import clsx3 from "clsx";
2457
- import { Popup } from "react-map-gl/maplibre";
2458
- import { tw as tw19 } from "twind";
2459
- import { jsx as jsx30, jsxs as jsxs17 } from "react/jsx-runtime";
2460
- var Pop = Popup;
2461
- function HoverPopup({ coordinates }) {
2462
- const { hover } = useLayers();
2463
- return (coordinates == null ? void 0 : coordinates.lat) && hover.features ? /* @__PURE__ */ jsx30(Pop, {
2464
- latitude: coordinates.lat,
2465
- longitude: coordinates.lng,
2466
- closeButton: false,
2467
- children: /* @__PURE__ */ jsxs17("table", {
2468
- className: tw19`table-auto border`,
2469
- children: [
2470
- /* @__PURE__ */ jsx30("thead", {
2471
- children: /* @__PURE__ */ jsx30("tr", {
2472
- children: /* @__PURE__ */ jsx30("th", {
2473
- className: tw19`bg-gray-200 py-1 px-2`,
2474
- colSpan: 2,
2475
- children: hover.features.title
2476
- })
2477
- })
2478
- }),
2479
- /* @__PURE__ */ jsx30("tbody", {
2480
- children: hover.features.data.map(([k, v], idx) => /* @__PURE__ */ jsxs17("tr", {
2481
- className: tw19(
2482
- clsx3({
2483
- "bg-gray-50": idx % 2 === 0,
2484
- "border-gray-100 border-t": 1
2485
- })
2486
- ),
2487
- children: [
2488
- /* @__PURE__ */ jsx30("td", {
2489
- className: tw19`py-1 px-2`,
2490
- children: k
2491
- }),
2492
- /* @__PURE__ */ jsx30("td", {
2493
- className: tw19`py-1 px-2 border-l border-gray-100`,
2494
- children: v
2495
- })
2496
- ]
2497
- }, k + v))
2498
- })
2499
- ]
2500
- })
2501
- }) : null;
2502
- }
2503
-
2504
- // src/components/map/index.tsx
2505
- import { jsx as jsx31, jsxs as jsxs18 } from "react/jsx-runtime";
2506
- var NavControl = NavigationControl;
2507
- function Map2() {
2508
- var _a;
2509
- const { mp, layer, hover, query } = useLayers();
2510
- const [coordinates, setCoordinates] = useState10();
2511
- const viewState = useMemo7(
2512
- () => mp.defaultViewState || defaultViewState2,
2513
- [mp.defaultViewState]
2514
- );
2515
- const onMapClick = (e) => query.setClickedLngLat(e.lngLat);
2516
- const handleOnMouseMove = (event) => {
2517
- setCoordinates(event.lngLat);
2518
- hover.onHover(event);
2519
- };
2520
- console.info("NakshaMaplibreLayers props");
2521
- return /* @__PURE__ */ jsxs18("div", {
2522
- className: tw20`h-full w-full relative bg-gray-100`,
2523
- children: [
2524
- mp.loadToC && /* @__PURE__ */ jsx31(Sidebar, {}),
2525
- ((_a = layer.selectedFeatures) == null ? void 0 : _a.length) > 0 && /* @__PURE__ */ jsx31(InfoBar, {}),
2526
- /* @__PURE__ */ jsxs18(MapGL, {
2527
- id: "mapl",
2528
- cursor: "default",
2529
- initialViewState: viewState,
2530
- style: { width: "100%", height: "100%" },
2531
- mapStyle: layer.mapStyle,
2532
- maxZoom: layer.maxZoom,
2533
- onClick: onMapClick,
2534
- onMouseMove: handleOnMouseMove,
2535
- children: [
2536
- /* @__PURE__ */ jsx31(NavControl, {
2537
- position: "bottom-right",
2538
- showZoom: true,
2539
- showCompass: true
2540
- }),
2541
- /* @__PURE__ */ jsx31(markers_list_default, {}),
2542
- layer.selectedLayers.map((_l, index) => {
2543
- const beforeId = index > 0 ? layer.selectedIds[index - 1] : void 0;
2544
- return /* @__PURE__ */ jsx31(MapLayer, {
2545
- layer: _l,
2546
- beforeId
2547
- }, _l.id);
2548
- }),
2549
- /* @__PURE__ */ jsx31(HoverPopup, {
2550
- coordinates
2551
- }, "popup")
2552
- ]
2553
- })
2554
- ]
2555
- });
2556
- }
2557
-
2558
- // src/index.tsx
2559
- import { jsx as jsx32 } from "react/jsx-runtime";
2560
- setup({ preflight: false });
2561
- var NakshaMaplibreLayers = (props) => {
2562
- const mp = React14.useMemo(
2563
- () => __spreadValues(__spreadValues({}, defaultNakshaProps), props),
2564
- [props]
2565
- );
2566
- return /* @__PURE__ */ jsx32(MapProvider, {
2567
- children: /* @__PURE__ */ jsx32(TranslationProvider, {
2568
- localeStrings: locales_default,
2569
- lang: mp.lang,
2570
- children: /* @__PURE__ */ jsx32(LayersProvider, {
2571
- mp,
2572
- children: /* @__PURE__ */ jsx32(Map2, {})
2573
- })
2574
- })
2575
- });
2576
- };
2577
- export {
2578
- NakshaMaplibreLayers
2579
- };
1
+ var eo=Object.defineProperty,to=Object.defineProperties;var ro=Object.getOwnPropertyDescriptors;var Pt=Object.getOwnPropertySymbols;var oo=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable;var De=Math.pow,Ct=(e,r,t)=>r in e?eo(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,m=(e,r)=>{for(var t in r||(r={}))oo.call(r,t)&&Ct(e,t,r[t]);if(Pt)for(var t of Pt(r))no.call(r,t)&&Ct(e,t,r[t]);return e},I=(e,r)=>to(e,ro(r));var v=(e,r,t)=>new Promise((o,n)=>{var a=i=>{try{c(t.next(i))}catch(l){n(l)}},s=i=>{try{c(t.throw(i))}catch(l){n(l)}},c=i=>i.done?o(i.value):Promise.resolve(i.value).then(a,s);c((t=t.apply(e,r)).next())});import{TranslationProvider as oa}from"@biodiv-platform/naksha-commons";import na from"react";import{MapProvider as aa}from"react-map-gl/maplibre";import{setup as sa}from"twind";var It={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var Mt={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var Et={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var Tt={en:It,fr:Mt,hi:Et};import{defaultViewState as Un}from"@biodiv-platform/naksha-commons";import{useMemo as Kn,useState as Xn}from"react";import Qn,{FullscreenControl as jn,NavigationControl as ea}from"react-map-gl/maplibre";import{tw as ta}from"twind";import{defaultMapStyles as go,useDebounce as ho}from"@biodiv-platform/naksha-commons";import vo,{createContext as bo,useContext as Lo,useEffect as Yt,useMemo as xo,useState as G}from"react";import{useMap as wo}from"react-map-gl/maplibre";import yo from"colorbrewer";import Y from"redaxios";import Bt from"boundingbox";import{GeoHash as Fe}from"geohash";import{MapStyles as lo,defaultViewState as co}from"@biodiv-platform/naksha-commons";var Nt={defaultViewState:co,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:lo.MAP_STREETS,layers:[],selectedLayers:[]},Rt="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E",ze={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},At=I(m({},ze),{WebkitLineClamp:2}),O="ogc_fid",be={ACTIVE:"Active",PENDING:"Pending"},D={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Gt=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],He="0123456789bcdefghjkmnpqrstuvwxyz",uo=(e,r,t)=>{t=t||16/De(2,1-e.length&1)/De(4,r);let o=e.slice(0,-1),n=~~(He.indexOf(e.slice(-1))/t);return[o+He[t*n],o+He[t*(n+1)-1]]},fo=function(e,r){var t=new Map,o=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[c,i]=uo(a,r);o.set(c,i),t.has(c)||t.set(c,0),t.set(c,t.get(c)+s)}return t.forEach((a,s)=>{let c=Fe.decodeGeoHash(s),i=Fe.decodeGeoHash(o.get(s)),l=new Bt({minlat:c.latitude[0],minlon:c.longitude[0],maxlat:i.latitude[1],maxlon:i.longitude[1]}).toGeoJSON();n.push(I(m({},l),{properties:{count:a,[O]:s}}))}),n},po=e=>{let r=[];for(let[t,o]of Object.entries(e)){let n=Fe.decodeGeoHash(t),a=new Bt({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();r.push(I(m({},a),{properties:{count:o,[O]:t}}))}return r},_t=(e,r)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:r===-1?po(e):fo(e,r)}),Ot=(e,r)=>{let t=Object.values(e).sort((a,s)=>a-s),o=Math.floor(t.length/r),n=new Array(r-1).fill(0).map((a,s)=>t[o*(s+1)]);return n.push(t[t.length-1]),n};import mo from"immer";var Dt=(e,r,t,o)=>v(void 0,null,function*(){let n=[];for(let a of e){let s=o.includes(a.name),c=I(m({},a),{id:a.name,thumbnail:r+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s});if(s){let i=yield qe(c,0,r,t);n.push(I(m({},c),{data:i}))}else n.push(c)}return n}),qe=(e,r,t,o)=>v(void 0,null,function*(){return mo(e.data,a=>v(void 0,null,function*(){var s;if(a.styles.length===0){let{success:c,data:i}=yield zt(e.id,t);c&&(a.layerName=i.layerName,a.styles=i.styles,a.summaryColumn=i.summaryColumn,a.titleColumn=i.titleColumn,a.propertyMap=Object.fromEntries(i.styles.map(l=>[l.styleName,l.styleTitle])))}a.styles[r]&&!((s=a.styles[r])!=null&&s.colors)&&(a.styles[r].colors=yield Ht(e.id,o==null?void 0:o.workspace,a.styles[r].styleName,t)),a.styleIndex=r}))});var Ft=(e,r,t,o)=>v(void 0,null,function*(){try{let n=yield Y.get(`${r}/layer/all`,{headers:{Authorization:e}});return yield Dt(n.data,r,t,o)}catch(n){return console.error(n),[]}}),zt=(e,r)=>v(void 0,null,function*(){try{let{data:t}=yield Y.get(`${r}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}}),qt=(e,r,t)=>v(void 0,null,function*(){let o={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(yield Y.get(`${e}/${r}/wms`,{params:m(m({},t),o)})).data}}catch(n){return console.error(n),{success:!1,data:[]}}}),$t=(e,r,t,o)=>v(void 0,null,function*(){try{return yield Y.put(`${r}/layer/${o?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}}),Vt=(e,r,t)=>v(void 0,null,function*(){try{return yield Y.delete(`${r}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}}),Ht=(e,r,t,o)=>v(void 0,null,function*(){var n,a;try{return(a=(n=(yield Y.get(`${o}/geoserver/workspaces/${r}/styles/${e}_${t}.mbstyle`)).data)==null?void 0:n.layers)==null?void 0:a[0]}catch(s){return console.error(s),{}}}),Wt=(e,r,t,o=6,n="YlOrRd")=>v(void 0,null,function*(){try{let[a,s,c]=Gt(t),{_ne:i,_sw:l}=r,p={top:i.lat,left:l.lng,bottom:l.lat,right:i.lng,geoAggegationPrecision:a},h=yield e(p),x=_t(h,s),P=Ot(h,o).map((T,L)=>[T,yo[n][o][L]]);return{success:!0,geojson:x,paint:{"fill-color":{property:"count",default:"yellow",stops:P},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:P,squareSize:c}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}}),Zt=(e,r,t,o)=>v(void 0,null,function*(){try{yield Y.post(`${e}/layer/download`,{layerName:t,layerTitle:o,attributeList:[],filterArray:[]},{headers:{Authorization:r}})}catch(n){console.error(n)}});import{jsx as So}from"react/jsx-runtime";var Jt=bo({}),Ut=({mp:e,children:r})=>{var Lt,xt;let[t,o]=G(e),{mapl:n}=wo(),[a,s]=G(""),c=ho(a,500),i=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:go,[l,p]=G((Lt=i[(t==null?void 0:t.mapStyle)||0])==null?void 0:Lt.style),[h,x]=G((xt=i[(t==null?void 0:t.mapStyle)||0])==null?void 0:xt.maxZoom),[w,P]=G(D.TOP),[E,T]=G({}),[L,B]=G(!0),[b,H]=G(),[S,Ge]=G(e.layers||[]),[N,ae]=G(t.selectedLayers||[]),[he,yt]=G(),[_e,gt]=G(),Vr=xo(()=>{var g;let d={};for(let y of _e||[])d[y.sourceLayer]=[...d[y.sourceLayer]||[],(g=y==null?void 0:y.properties)==null?void 0:g[O]];return Object.keys(d).length?d:void 0},[_e]),se=vo.useMemo(()=>{let d=S.filter(y=>N.includes(y.id)),g=new Array(N.length);for(let y of d){let C=N.findIndex(_=>y.id===_);C>-1&&(g[C]=y)}return g},[S,N]),ve=d=>S.findIndex(g=>g.id===d),ht=(d,g)=>{Ge(y=>y.map(C=>C.id===d?m(m({},C),g):C))},vt=(d,g,y)=>v(void 0,null,function*(){let C=S[d],_=yield qe(C,g,t.nakshaApiEndpoint,t.geoserver);ht(C.id,{data:_}),y&&(n==null||n.fitBounds(C.bbox,{padding:40,duration:1e3}))}),Wr=(d,g)=>v(void 0,null,function*(){let y=ve(d);vt(y,g,!1)}),Zr=d=>v(void 0,null,function*(){var g,y,C,_;if(!(!N.length||!n))try{let q=N[0],ie=n.queryRenderedFeatures(d.point,{layers:[q]});if(ie.length){let le=((g=ie[0])==null?void 0:g.id)||((C=(y=ie[0])==null?void 0:y.properties)==null?void 0:C[O]);if(le===(he==null?void 0:he.id))return;let $=S[ve(q)],W=(_=$==null?void 0:$.data)==null?void 0:_.summaryColumn.map(Z=>{var wt,St,kt;return[((St=(wt=$.data)==null?void 0:wt.propertyMap)==null?void 0:St[Z])||Z,(kt=ie[0].properties)==null?void 0:kt[Z]]});yt({id:le,title:$.title,data:W})}else yt(void 0)}catch(q){}}),Yr=_=>v(void 0,[_],function*({layerId:d,add:g,styleIndex:y=0,focus:C=!0}){var le,$;if(!g){ae(N.filter(W=>d!==W));return}let q=ve(d);((le=S[q])==null?void 0:le.source.type)==="grid"?(ae(W=>[d,...W.filter(Z=>Z!==d)]),C&&(($=S[q])==null?void 0:$.bbox)&&setTimeout(()=>{n==null||n.fitBounds(S[q].bbox,{padding:40,duration:1e3})},100)):(yield vt(q,y,C),ae(W=>[d,...W.filter(Z=>Z!==d)]))}),Jr=()=>v(void 0,null,function*(){return ae([])}),Ur=(d,g)=>{o(I(m({},t),{[d]:g}))},Kr=(d,g)=>{let y=g===be.PENDING;$t(t.nakshaEndpointToken,t.nakshaApiEndpoint,d,y),ht(d,{layerStatus:y?be.ACTIVE:be.PENDING})},Xr=(d,g)=>v(void 0,null,function*(){confirm(g)&&(Vt(t.nakshaEndpointToken,t.nakshaApiEndpoint,d),Ge(S.filter(y=>y.id!==d)))}),Qr=d=>{let g=ve(d),y=S[g];n==null||n.fitBounds(y.bbox,{padding:40,duration:1e3})},bt=()=>[b.lng,b.lat,b.lng+.1,b.lat+.1],jr=d=>{P(d),d===D.TOP&&Oe(d)},Oe=d=>{if(!!b)try{let g=n==null?void 0:n.project([b.lng,b.lat]),y=n==null?void 0:n.queryRenderedFeatures(g,{layers:w===D.TOP?[N[0]]:N});if((d||w)===D.ALL){let C=se.filter(_=>_.layerType=="RASTER").map(_=>({sourceLayer:_.id,layerType:"raster",bbox:bt()}));y=[...y,...C]}gt((se==null?void 0:se[0].layerType)==="RASTER"&&w!==D.ALL?N.length&&(y==null?void 0:y.length)?y:[{sourceLayer:N[0],layerType:"raster",bbox:bt()}]:y)}catch(g){console.error(g)}};return Yt(()=>{t.onSelectedLayersChange&&t.onSelectedLayersChange(N)},[N]),Yt(()=>{setTimeout(Oe,300)},[b,w,N]),So(Jt.Provider,{value:{mp:t,updateMP:Ur,layer:{mapStyle:l,featuresAtLatLng:Oe,setMapStyle:p,maxZoom:h,setMaxZoom:x,mapStyles:i,all:S,setAll:Ge,selectedIds:N,handleSelectStyle:jr,setSelectedIds:ae,selectedLayers:se,clearAll:Jr,toggle:Yr,updateStyle:Wr,selectedFeatures:_e,selectedFeaturesId:Vr,setSelectedFeatures:gt,togglePublish:Kr,delete:Xr,selectionStyle:w,setSelectionStyle:P,zoomToExtent:Qr,gridLegends:E,setGridLegends:T},query:{term:c,setTerm:s,clickedLngLat:b,setClickedLngLat:H},isInfoBarOpen:L,setIsInfoBarOpen:B,hover:{onHover:Zr,features:he}},children:r})};function f(){return Lo(Jt)}import Po from"react";import{tw as xe}from"twind";import{tw as ko}from"twind";import{jsx as u,jsxs as ue}from"react/jsx-runtime";var Kt=()=>u("svg",{fill:"none",className:ko`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:u("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ce=()=>ue("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[u("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),u("path",{d:"M2 17L12 22 22 17"}),u("path",{d:"M2 12L12 17 22 12"})]}),Le=()=>ue("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u("circle",{cx:"12",cy:"12",r:"10"}),u("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),u("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),Xt=()=>ue("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[u("path",{d:"M4 21L4 14"}),u("path",{d:"M4 10L4 3"}),u("path",{d:"M12 21L12 12"}),u("path",{d:"M12 8L12 3"}),u("path",{d:"M20 21L20 16"}),u("path",{d:"M20 12L20 3"}),u("path",{d:"M1 14L7 14"}),u("path",{d:"M9 8L15 8"}),u("path",{d:"M17 16L23 16"})]});function $e(){return u("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function Qt(){return u("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function jt(){return u("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function er(){return u("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function tr(){return u("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function rr(){return u("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function or(){return u("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:u("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function nr(){return ue("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[u("circle",{cx:"18",cy:"5",r:"3"}),u("circle",{cx:"6",cy:"12",r:"3"}),u("circle",{cx:"18",cy:"19",r:"3"}),u("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),u("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function ar(){return u("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function sr(){return ue("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u("circle",{cx:"12",cy:"12",r:"10"}),u("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),u("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),u("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),u("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function ir(){return u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:u("polyline",{points:"6 9 12 15 18 9"})})}function lr(){return u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:u("polyline",{points:"18 15 12 9 6 15"})})}import{jsx as j}from"react/jsx-runtime";var V=Po.forwardRef((e,r)=>j("button",m({ref:r,type:"button",className:xe`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`},e)));var we=e=>j("button",m({className:xe`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715"},e)),cr=e=>j("button",I(m({className:xe`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`},e),{children:j(ce,{})})),ur=e=>j("button",I(m({className:xe`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`},e),{children:j(Le,{})}));import{tw as ee}from"twind";import{jsx as z,jsxs as pr}from"react/jsx-runtime";var te=e=>pr("div",{children:[e.label&&z("label",{className:ee`text-gray-700`,htmlFor:e.name,children:e.label}),z("select",m({id:e.name,name:e.name,className:ee`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"}},e))]}),fr=e=>pr("div",{className:"relative",children:[z("span",{className:ee`absolute inset-y-0 left-0 flex items-center pl-3`,children:z(Kt,{})}),z("input",m({type:"search",className:ee`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`},e))]}),dr=e=>e.isLoading?z("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:ee`inline text-gray-200 animate-spin dark:text-gray-600`,children:z("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:z("g",{fill:"#212121",fillRule:"nonzero",children:z("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):z("input",{type:"checkbox",className:ee`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});import{Tabs as mr,usePanelState as Co,useTabState as Io}from"@bumaga/tabs";import Mo from"clsx";import{tw as Se}from"twind";import{jsx as Ve,jsxs as Eo}from"react/jsx-runtime";var ke=({children:e,icon:r})=>{let{onClick:t,isActive:o}=Io(),n=Mo(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":o,"text-gray-700 border-gray-300 hover:border-gray-400":!o}]);return Eo("button",{className:Se(n),onClick:t,children:[r,Ve("span",{className:Se`ml-2 text-base`,children:e})]})},Pe=({children:e})=>Co()?Ve("div",{className:Se`w-full flex flex-grow-1 overflow-auto`,children:e}):null,yr=({children:e})=>Ve("div",{className:Se`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{useT as Ao}from"@biodiv-platform/naksha-commons";import{tw as Ie}from"twind";import{useT as To}from"@biodiv-platform/naksha-commons";import{jsx as gr}from"react/jsx-runtime";function fe({hideLabel:e}){let{layer:{selectionStyle:r,handleSelectStyle:t}}=f(),{t:o}=To(),n=a=>{t(a.target.value)};return gr(te,{name:"layer_selection",label:e?null:o("layer_selection"),defaultValue:r,onChange:n,children:Object.values(D).map(a=>gr("option",{value:a,children:o(a)},a))})}import No from"clsx";import{useEffect as Ro,useState as hr}from"react";import{tw as Ce}from"twind";import{jsx as de,jsxs as We}from"react/jsx-runtime";function Ze({data:e}){let[r,t]=hr(!0),[o,n]=hr({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:c}}=f(),i=()=>v(this,null,function*(){var h,x,w,P,E,T;let l,p=a.selectedLayers.find(L=>L.id===(e.sourceLayer||e.source));if(p.layerType.toLowerCase()==="raster"){let{data:L}=yield qt((h=s.geoserver)==null?void 0:h.endpoint,(x=s.geoserver)==null?void 0:x.workspace,{bbox:e.bbox.toString(),query_layers:`${(w=s.geoserver)==null?void 0:w.workspace}:${p.id}`,layers:`${(P=s.geoserver)==null?void 0:P.workspace}:${p.id}`});l=L!=null&&L.features[0]?Object.entries((E=L.features[0])==null?void 0:E.properties).map(([B,b])=>[b||"-"]):[]}else l=Object.entries(((T=p==null?void 0:p.data)==null?void 0:T.propertyMap)||{}).map(([L,B])=>{var b;return[B,(b=e==null?void 0:e.properties)==null?void 0:b[L]]});n({title:p.title,properties:l})});return Ro(()=>{i()},[c]),We("div",{className:Ce`bg-gray-100 rounded-lg`,children:[We("button",{className:Ce(No(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":r,"rounded-lg":!r}])),onClick:()=>t(!r),children:[o.title," ",r?de(lr,{}):de(ir,{})]}),r&&de("div",{className:Ce`px-4 py-3 flex flex-col gap-3`,children:o.properties.map(([l,p],h)=>We("div",{children:[de("div",{className:Ce`text-gray-600`,children:l}),de("div",{children:p})]},l+p+h))})]})}import{jsx as re,jsxs as Ye}from"react/jsx-runtime";function Je({onClose:e}){var a;let{layer:{selectedFeatures:r,selectedLayers:t,selectionStyle:o}}=f(),{t:n}=Ao();return Ye("div",{className:Ie`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[Ye("div",{className:"flex w-full",children:[Ye("div",{className:Ie`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[re(sr,{})," ",n("infobar")]}),re(we,{onClick:e})]}),re("div",{className:Ie`bg-gray-100 p-4 flex-shrink-0 rt`,children:re(fe,{hideLabel:!0})}),re("div",{className:Ie`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:(a=r.flat(1))==null?void 0:a.map(s=>{var c;return re(Ze,{data:s},((c=t==null?void 0:t[0])==null?void 0:c.source.type)==="raster"||o===D.ALL?s==null?void 0:s.sourceLayer:(s==null?void 0:s.sourceLayer)+(s==null?void 0:s.properties[O]))})})]})}import{jsx as vr}from"react/jsx-runtime";function Ue(){var n;let{layer:e,isInfoBarOpen:r,setIsInfoBarOpen:t}=f();if(!((n=e.selectedFeatures)!=null&&n.length))return null;let o=()=>t(!r);return r?vr(Je,{onClose:o}):vr(ur,{onClick:o})}import{useEffect as In,useState as Mn}from"react";import{useMap as En}from"react-map-gl/maplibre";import{useT as Cn}from"@biodiv-platform/naksha-commons";import{tw as Ar}from"twind";import{tw as cn}from"twind";import rn,{useMemo as on}from"react";import{useVirtual as nn}from"react-virtual";import an from"react-virtualized-auto-sizer";import{tw as kr}from"twind";import{useT as Qo}from"@biodiv-platform/naksha-commons";import{useMemo as jo,useState as Sr}from"react";import{RWebShare as en}from"react-web-share";import{tw as F}from"twind";import{Fragment as br,jsx as Me}from"react/jsx-runtime";var Lr=({text:e="",highlight:r=""})=>{if(!r.trim())return Me(br,{children:e});let t=new RegExp(`(${r})`,"gi"),o=e.split(t);return Me(br,{children:o.filter(n=>n).map((n,a)=>t.test(n)?Me("mark",{children:n},a):Me("span",{children:n},a))})};import{tw as zo}from"twind";import{useT as Bo}from"@biodiv-platform/naksha-commons";import{useState as Go}from"react";import{tw as _o}from"twind";import{jsx as Oo,jsxs as Do}from"react/jsx-runtime";function pe({children:e}){let[r,t]=Go(!1),{t:o}=Bo();return Do("div",{children:[r&&e,Oo("button",{onClick:()=>t(!r),className:_o`text-blue-600 focus:outline-none focus:outline focus:ring`,children:o(r?"less":"legend")})]})}import{jsx as Ee,jsxs as Te}from"react/jsx-runtime";function Ke({item:e}){let{layer:r}=f(),t=r.gridLegends[e.id];return t?Ee(pe,{children:Te("ul",{style:{margin:0,padding:0},children:[t==null?void 0:t.stops.map(([o,n],a,s)=>{let c=(s[a-1]||[0])[0];return c===o?Ee("div",{},n):Te("li",{className:zo`flex gap-2 items-center mb-1`,children:[Ee("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:Ee("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),Te("div",{children:[c," - ",o]})]},n)}),Te("li",{children:["1 Square = ",t==null?void 0:t.squareSize," x ",t==null?void 0:t.squareSize," km"]})]})}):null}import{LICENSES as Ho,useT as Fo}from"@biodiv-platform/naksha-commons";import{useState as qo}from"react";import{Popover as $o}from"react-tiny-popover";import{tw as me}from"twind";import{jsx as k,jsxs as Xe}from"react/jsx-runtime";var oe=({icon:e,name:r,title:t,link:o,children:n})=>{let a=k("span",{children:n||"-"});return Xe("div",{className:me`flex gap-3 text-sm text-gray-600 break-all`,title:r&&t&&`${r}: ${t}`,children:[k("div",{children:e}),o?k("a",{className:me`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:o,children:a}):a]})};function Vo({item:e,containerStyle:r}){var i;let{t}=Fo(),{layer:o,mp:n}=f(),a=e.license||"CC-BY",s=(e==null?void 0:e.createdDate)&&new Date(e.createdDate).toLocaleDateString(),c=(i=e.tags)==null?void 0:i.join(", ");return Xe("div",{className:me`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:r,children:[n.managePublishing&&e.layerStatus&&Xe(oe,{icon:k(er,{}),name:t("visiblity"),title:e.layerStatus,children:[e.layerStatus,k("button",{className:me`text-blue-600 focus:outline-none ml-4`,onClick:()=>o.togglePublish(e.id,e==null?void 0:e.layerStatus),children:t("toggle")}),k("button",{className:me`text-red-600 focus:outline-none ml-4`,onClick:()=>o.delete(e.id,t("are_you_sure")),children:t("delete")})]}),k(oe,{icon:k($e,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),k(oe,{icon:k($e,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),k(oe,{icon:k(tr,{}),name:t("created_on"),title:s,children:s}),k(oe,{icon:k(Qt,{}),name:t("tags"),title:c,children:c}),k(oe,{name:t("license"),title:a,link:a&&Ho[a],icon:k(jt,{}),children:a})]})}var xr=({item:e})=>{let[r,t]=qo(!1),o=()=>t(!r);return k($o,{isOpen:r,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:o,content:k(Vo,{item:e}),children:k(V,{onClick:o,children:k(Le,{}),title:"Information"})})};import{tw as Ko}from"twind";import{useMemo as Wo,useState as Zo}from"react";import{useT as Yo}from"@biodiv-platform/naksha-commons";import{tw as Jo}from"twind";import{jsx as J,jsxs as Uo}from"react/jsx-runtime";function wr({item:e}){var c;let[r,t]=Zo(!0),{mp:o}=f(),{t:n}=Yo(),a=Wo(()=>{var i,l,p,h,x,w,P,E,T,L,B,b;return((w=(x=(h=(p=(l=(i=e==null?void 0:e.data)==null?void 0:i.styles)==null?void 0:l[e.data.styleIndex])==null?void 0:p.colors)==null?void 0:h.paint)==null?void 0:x["fill-color"])==null?void 0:w.stops)||((b=(B=(L=(T=(E=(P=e==null?void 0:e.data)==null?void 0:P.styles)==null?void 0:E[e.data.styleIndex])==null?void 0:T.colors)==null?void 0:L.paint)==null?void 0:B["circle-color"])==null?void 0:b.stops)||[]},[e]),s=()=>a.map(([i,l])=>Uo("li",{className:Jo`flex gap-2 items-center mb-1`,children:[J("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:J("circle",{cx:"12",fill:l,cy:"12",r:"12",stroke:"none"})}),J("div",{children:i})]},l));return J("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():r?J("li",{children:J("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${(c=o==null?void 0:o.geoserver)==null?void 0:c.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):J("div",{children:n("raster_style_not_found")})})}import{jsx as Ne,jsxs as Xo}from"react/jsx-runtime";function Qe({item:e}){var o,n;if(!((o=e.data)!=null&&o.styles))return null;let{layer:r}=f(),t=a=>{r.updateStyle(e.id,Number(a.target.value))};return Xo("div",{className:Ko`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&Ne(te,{onChange:t,children:(n=e.data)==null?void 0:n.styles.map((a,s)=>Ne("option",{value:s,children:a.styleTitle},s))}),Ne(pe,{children:Ne(wr,{item:e})})]})}import{jsx as M,jsxs as U}from"react/jsx-runtime";function tn({dragHandleProps:e}){return M("div",I(m({className:F`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"}},e),{children:M(ar,{})}))}function ye({item:e,extended:r,dragHandleProps:t}){let{t:o}=Qo(),{layer:n,query:a,mp:s,query:{setClickedLngLat:c},setIsInfoBarOpen:i}=f(),[l,p]=Sr(n.selectedIds.includes(e.id)),[h,x]=Sr(!1),w=jo(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),P=()=>v(this,null,function*(){x(!0),i(!0),n.setSelectedFeatures([]),c(null),yield n.toggle({layerId:e.id,add:!l}),p(!l),x(!1)}),E=()=>v(this,null,function*(){yield Zt(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s==null||s.onLayerDownload(e.id)}),T=()=>n.zoomToExtent(e.id);return U("div",{className:F`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[U("div",{className:F`flex gap-3`,children:[U("div",{className:F`flex-shrink-0`,children:[M(dr,{name:e.id,checked:l,onChange:P,isLoading:h}),r&&M(tn,{dragHandleProps:t})]}),M("img",{className:F`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||Rt}),U("div",{children:[M("div",{title:e.title,className:F`mb-1 leading-tight`,style:ze,children:M(Lr,{text:e.title,highlight:a.term})}),M("p",{title:e.description,className:F`text-gray-600 text-sm`,style:At,children:e.description})]})]}),U("div",{className:F`flex justify-between`,children:[U(V,{onClick:E,disabled:!e.isDownloadable,children:[M(rr,{})," ",o("download")]}),U("div",{className:F`flex gap-3`,children:[w&&M(en,{data:w,children:M(V,{title:"Share",children:M(nr,{})})}),r&&M(V,{onClick:T,title:"Zoom To Extent",children:M(or,{})}),M(xr,{item:e})]})]}),r&&M(Qe,{item:e}),r&&e.source.type==="grid"&&M(Ke,{item:e})]})}import{jsx as K}from"react/jsx-runtime";function Pr(){let{layer:e,query:r}=f(),t=on(()=>r.term?e.all.filter(a=>a.title.toLowerCase().includes(r.term.toLowerCase())):e.all,[e.all,r.term]),o=rn.useRef(),n=nn({size:t.length,parentRef:o});return K("div",{className:kr`flex-grow-1 relative`,children:K(an,{disableWidth:!0,children:a=>K("div",{ref:o,className:"List",style:{height:a.height,overflow:"auto"},children:K("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>K("div",{ref:s.measureRef,className:kr`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:K("div",{style:{height:146},children:K(ye,{item:t[s.index]})})},s.index))})})})})}import{useT as sn}from"@biodiv-platform/naksha-commons";import{tw as ln}from"twind";import{jsx as Cr}from"react/jsx-runtime";function je(){let{t:e}=sn(),{query:r}=f(),t=o=>r.setTerm(o.target.value);return Cr("div",{className:ln`flex-shrink-0 border-b-2 p-4`,children:Cr(fr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}import{jsx as Ir,jsxs as un}from"react/jsx-runtime";function et(){return un("div",{className:cn`flex flex-col w-full`,children:[Ir(je,{}),Ir(Pr,{})]})}function fn(e,r,t){let o=r<0?e.length+r:r;if(o>=0&&o<e.length){let n=t<0?e.length+t:t,[a]=e.splice(r,1);e.splice(n,0,a)}}function Mr(e,r,t){return e=[...e],fn(e,r,t),e}import{closestCenter as dn,DndContext as pn,PointerSensor as mn,useSensor as yn,useSensors as gn}from"@dnd-kit/core";import{SortableContext as hn,useSortable as vn,verticalListSortingStrategy as bn}from"@dnd-kit/sortable";import{CSS as Ln}from"@dnd-kit/utilities";import{jsx as ne}from"react/jsx-runtime";function xn({item:e,extended:r}){let{attributes:t,listeners:o,setNodeRef:n,transform:a,transition:s,isDragging:c}=vn({id:e.id}),i={transform:Ln.Transform.toString(a),transition:s,opacity:c?.5:1};return ne("div",{ref:n,style:i,children:ne(ye,{item:e,extended:r,dragHandleProps:m(m({},t),o)})})}var Er=({layerList:e,onSortEnd:r})=>{let t=gn(yn(mn,{activationConstraint:{distance:4}}));return ne(pn,{sensors:t,collisionDetection:dn,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let c=e.findIndex(l=>l.id===a.id),i=e.findIndex(l=>l.id===s.id);c!==-1&&i!==-1&&r({oldIndex:c,newIndex:i})}},children:ne(hn,{items:e.map(n=>n.id),strategy:bn,children:ne("div",{children:e.map(n=>ne(xn,{item:n,extended:!0},n.id))})})})};import{useT as wn}from"@biodiv-platform/naksha-commons";import{tw as Tr}from"twind";import{jsx as Rr,jsxs as Nr}from"react/jsx-runtime";function tt(){let{layer:e}=f(),{t:r}=wn(),t=({oldIndex:o,newIndex:n})=>{e.setSelectedIds(Mr(e.selectedIds,o,n))};return Nr("div",{className:Tr`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&Rr("div",{className:Tr`p-3 pb-0`,children:Nr(V,{onClick:()=>e.clearAll(),children:["\u2715 ",r("clear")]})}),Rr(Er,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}import{useT as Sn}from"@biodiv-platform/naksha-commons";import{tw as kn}from"twind";import{jsx as rt,jsxs as Pn}from"react/jsx-runtime";function ot(){let{layer:e}=f(),{t:r}=Sn(),t=o=>{var n;e.setMapStyle(o.target.value),e.setMaxZoom((n=e.mapStyles.find(a=>a.style===o.target.value))==null?void 0:n.maxZoom)};return Pn("div",{className:kn`w-full p-4 flex flex-col gap-4`,children:[rt(te,{name:"base_style",label:r("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(o=>rt("option",{value:o.style,children:o.text},o.key))}),rt(fe,{})]})}import{jsx as A,jsxs as nt}from"react/jsx-runtime";function at({onClose:e}){let{t:r}=Cn();return nt("div",{className:Ar`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[A(we,{onClick:e}),A("div",{className:Ar`flex flex-col h-full`,children:nt(mr,{children:[nt(yr,{children:[A(ke,{icon:A(ce,{}),children:r("layers")}),A(ke,{icon:A(ce,{}),children:r("selected")}),A(ke,{icon:A(Xt,{}),children:r("settings")})]}),A(Pe,{children:A(et,{})}),A(Pe,{children:A(tt,{})}),A(Pe,{children:A(ot,{})})]})})]})}import{jsx as Br}from"react/jsx-runtime";function st(){let{mp:e,layer:r}=f(),[t,o]=Mn(e.showToC),{mapl:n}=En(),a=()=>o(!t);function s(){return v(this,null,function*(){let c=yield Ft(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),i=[...e.layers||[],...c];if(r.setAll(i),r.selectedIds.length){let l=i.find(p=>p.id===r.selectedIds[0]);l!=null&&l.bbox&&(n==null||n.fitBounds(l.bbox,{padding:40,duration:1e3}))}})}return In(()=>{n&&e.loadToC&&s()},[n]),t?Br(at,{onClose:a}):Br(cr,{onClick:a})}import{useMap as Hn}from"react-map-gl/maplibre";var R=63710088e-1,Wl={centimeters:R*100,centimetres:R*100,degrees:R/111325,feet:R*3.28084,inches:R*39.37,kilometers:R/1e3,kilometres:R/1e3,meters:R,metres:R,miles:R/1609.344,millimeters:R*1e3,millimetres:R*1e3,nauticalmiles:R/1852,radians:1,yards:R*1.0936},Zl={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/R,yards:1.0936133};function it(e,r,t){if(e!==null)for(var o,n,a,s,c,i,l,p=0,h=0,x,w=e.type,P=w==="FeatureCollection",E=w==="Feature",T=P?e.features.length:1,L=0;L<T;L++){l=P?e.features[L].geometry:E?e.geometry:e,x=l?l.type==="GeometryCollection":!1,c=x?l.geometries.length:1;for(var B=0;B<c;B++){var b=0,H=0;if(s=x?l.geometries[B]:l,s!==null){i=s.coordinates;var S=s.type;switch(p=t&&(S==="Polygon"||S==="MultiPolygon")?1:0,S){case null:break;case"Point":if(r(i,h,L,b,H)===!1)return!1;h++,b++;break;case"LineString":case"MultiPoint":for(o=0;o<i.length;o++){if(r(i[o],h,L,b,H)===!1)return!1;h++,S==="MultiPoint"&&b++}S==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(o=0;o<i.length;o++){for(n=0;n<i[o].length-p;n++){if(r(i[o][n],h,L,b,H)===!1)return!1;h++}S==="MultiLineString"&&b++,S==="Polygon"&&H++}S==="Polygon"&&b++;break;case"MultiPolygon":for(o=0;o<i.length;o++){for(H=0,n=0;n<i[o].length;n++){for(a=0;a<i[o][n].length-p;a++){if(r(i[o][n][a],h,L,b,H)===!1)return!1;h++}H++}b++}break;case"GeometryCollection":for(o=0;o<s.geometries.length;o++)if(it(s.geometries[o],r,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function lt(e){var r=[1/0,1/0,-1/0,-1/0];return it(e,function(t){r[0]>t[0]&&(r[0]=t[0]),r[1]>t[1]&&(r[1]=t[1]),r[2]<t[0]&&(r[2]=t[0]),r[3]<t[1]&&(r[3]=t[1])}),r}lt.default=lt;var Gr=lt;import{useEffect as ct,useState as Tn}from"react";import{Layer as Nn,Source as Rn,useMap as An}from"react-map-gl/maplibre";import{jsx as _r}from"react/jsx-runtime";function ut({data:e,beforeId:r}){let{layer:t}=f(),{mapl:o}=An(),[n,a]=Tn({geojson:{},paint:{}}),s=t.selectedIds.includes(e.id),c=t.selectedIds[0]===e.id,i=(l=!1)=>v(this,null,function*(){let{success:p,geojson:h,paint:x,stops:w,squareSize:P}=yield Wt(e.source.fetcher,o==null?void 0:o.getBounds(),o==null?void 0:o.getZoom());if(p){if(a({geojson:h,paint:x}),l&&c&&e.zoomToFit)try{let[E,T,L,B]=Gr(h);o==null||o.fitBounds([[E,T],[L,B]],{padding:40,animate:!0})}catch(E){console.warn("Failed to compute bbox",E)}t.setGridLegends({[e.id]:{stops:w,squareSize:P}})}});return ct(()=>{s&&c?i(!0):s&&i(!1)},[s,c]),ct(()=>{if(!s||!o)return;let l=()=>i(!1);return o.on("idle",l),()=>{o.off("idle",l)}},[s,o]),ct(()=>()=>{t.setGridLegends(l=>{let p=m({},l);return delete p[e.id],p})},[e.id]),_r(Rn,{id:e.id,type:"geojson",data:n.geojson,children:_r(Nn,{beforeId:r,id:e.id,type:"fill",paint:n.paint})})}import{useMemo as Bn}from"react";import{Layer as Or,Source as Gn}from"react-map-gl/maplibre";import{jsx as Dr,jsxs as On}from"react/jsx-runtime";var _n={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function Re({layer:e,beforeId:r}){var a;let{layer:t}=f(),o=Bn(()=>{var s,c,i,l;return(l=(i=(s=e.data)==null?void 0:s.styles)==null?void 0:i[(c=e.data)==null?void 0:c.styleIndex])==null?void 0:l.colors},[e,t.selectedFeatures]),n=(a=t.selectedFeaturesId)==null?void 0:a[e.id];return On(Gn,I(m({},e.source),{children:[o&&Dr(Or,m({beforeId:r},o)),n&&o&&Dr(Or,I(m({},o),{beforeId:r,id:`hl_${e.id}`,filter:["in",O,...n],type:o.type==="fill"?"line":o.type,paint:_n[o.type]}))]}))}import{Layer as Dn,Source as zn}from"react-map-gl/maplibre";import{jsx as zr}from"react/jsx-runtime";function ft({data:e,beforeId:r}){var o;let{mp:t}=f();return zr(zn,{id:e.id,type:"raster",tiles:[`${(o=t==null?void 0:t.geoserver)==null?void 0:o.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:zr(Dn,{id:e.id,beforeId:r,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as Ae}from"react/jsx-runtime";function Hr({layer:e,beforeId:r}){let{mapl:t}=Hn();if(!t)return null;switch(e.source.type){case"vector":return Ae(Re,{beforeId:r,layer:e});case"grid":return Ae(ut,{beforeId:r,data:e});case"raster":return Ae(ft,{beforeId:r,data:e});default:return Ae(Re,{beforeId:r,layer:e})}}import{useMemo as Fn}from"react";import{Marker as qn}from"react-map-gl/maplibre";import{Fragment as Wn,jsx as dt}from"react/jsx-runtime";var $n=qn,Vn=()=>{let{mp:e}=f(),r=Fn(()=>e.markers,[e.markers]);return dt(Wn,{children:r==null?void 0:r.map(({latitude:t,longitude:o,colorHex:n},a)=>dt($n,{latitude:t,longitude:o,children:dt("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},Fr=Vn;import Zn from"clsx";import{Popup as Yn}from"react-map-gl/maplibre";import{tw as ge}from"twind";import{jsx as X,jsxs as qr}from"react/jsx-runtime";var Jn=Yn;function pt({coordinates:e}){let{hover:r}=f();return(e==null?void 0:e.lat)&&r.features?X(Jn,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:qr("table",{className:ge`table-auto border`,children:[X("thead",{children:X("tr",{children:X("th",{className:ge`bg-gray-200 py-1 px-2`,colSpan:2,children:r.features.title})})}),X("tbody",{children:r.features.data.map(([t,o],n)=>qr("tr",{className:ge(Zn({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[X("td",{className:ge`py-1 px-2`,children:t}),X("td",{className:ge`py-1 px-2 border-l border-gray-100`,children:o})]},t+o))})]})}):null}import{jsx as Q,jsxs as $r}from"react/jsx-runtime";var ra=ea;function mt(){var l;let{mp:e,layer:r,hover:t,query:o}=f(),[n,a]=Xn(),s=Kn(()=>e.defaultViewState||Un,[e.defaultViewState]),c=p=>o.setClickedLngLat(p.lngLat),i=p=>{a(p.lngLat),t.onHover(p)};return $r("div",{className:ta`h-full w-full relative bg-gray-100`,children:[e.loadToC&&Q(st,{}),((l=r.selectedFeatures)==null?void 0:l.length)>0&&Q(Ue,{}),$r(Qn,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:r.mapStyle,maxZoom:r.maxZoom,onClick:c,onMouseMove:i,children:[Q(ra,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&Q(jn,{position:"bottom-right"}),Q(Fr,{}),r.selectedLayers.map((p,h)=>{let x=h>0?r.selectedIds[h-1]:void 0;return Q(Hr,{layer:p,beforeId:x},p.id)}),Q(pt,{coordinates:n},"popup")]})]})}import{jsx as Be}from"react/jsx-runtime";sa({preflight:!1});var cu=e=>{let r=na.useMemo(()=>m(m({},Nt),e),[e]);return Be(aa,{children:Be(oa,{localeStrings:Tt,lang:r.lang,children:Be(Ut,{mp:r,children:Be(mt,{})})})})};export{cu as NakshaMaplibreLayers};