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