adb-shared 7.0.15 → 22.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,900 +1,2309 @@
1
- import * as i1$1 from '@angular/common';
2
- import { CommonModule } from '@angular/common';
3
- import * as i0 from '@angular/core';
4
- import { forwardRef, ChangeDetectionStrategy, Component, InjectionToken, Inject, Injectable, Input, signal, effect, NgModule } from '@angular/core';
5
- import * as i4 from '@angular/forms';
6
- import { NG_VALUE_ACCESSOR, FormControl, FormGroup, FormArray, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
7
- import * as Leaflet from 'leaflet';
8
- import Leaflet__default from 'leaflet';
9
- import '@geoman-io/leaflet-geoman-free';
10
- import { Subscription, combineLatest, map, debounceTime } from 'rxjs';
11
- import * as i1 from '@ngx-translate/core';
12
- import { TranslatePipe } from '@ngx-translate/core';
13
- import * as i1$2 from '@angular/router';
14
- import { RouterModule } from '@angular/router';
15
- import { finalize } from 'rxjs/operators';
16
- import * as i3 from '@angular/common/http';
17
- import * as i5 from 'adb-shared';
18
- import { AdbDatePickerModule, AdbPipesModule, AdbFilterSectionModule, AdbPickerModule } from 'adb-shared';
19
- import { addYears, startOfYear, endOfYear, startOfDay, endOfDay, parseISO } from 'date-fns';
20
-
21
- class AdbMapUtils {
22
- static INITIAL_CENTER_LAT = 62;
23
- static INITIAL_CENTER_LNG = 17;
24
- static OverlayMaps = {
25
- 'Altitude': new Leaflet.TileLayer.WMS("https://maps.sgu.se/lmv/hojdmodell/v1.1?SERVICE=WMS", { layers: "terrangskuggning", format: "image/png", transparent: true, opacity: 0.3, maxZoom: 16, version: "1.3.0" }),
26
- 'Fjällkarta': new Leaflet.TileLayer.WMS('api/maps/mountain', {
27
- minZoom: 6,
28
- maxZoom: 18,
29
- maxNativeZoom: 14,
30
- attribution: '© <a href="https://www.lantmateriet.se/">Fjällkart</a>',
31
- wms: true
32
- }),
33
- 'Kommuner': new Leaflet.TileLayer.WMS('https://sosgeo.artdata.slu.se/geoserver/GeoRegion/wms?', {
34
- layers: 'GeoRegion:Municipality',
35
- version: '1.1.0',
36
- transparent: true,
37
- format: 'image/png'
38
- }),
39
- 'Län': new Leaflet.TileLayer.WMS('https://sosgeo.artdata.slu.se/geoserver/GeoRegion/wms?', {
40
- layers: 'GeoRegion:County',
41
- version: '1.1.0',
42
- transparent: true,
43
- format: 'image/png'
44
- }),
45
- 'Ortnamn': new Leaflet.TileLayer.WMS("https://maps.sgu.se/lmv/topowebb-skikt/v1.1?SERVICE=WMS", {
46
- layers: "text",
47
- format: "image/png",
48
- transparent: true,
49
- version: "1.3.0",
50
- }),
51
- 'Ekonomisk zon': new Leaflet.TileLayer.WMS("https://sosgeo.artdata.slu.se/geoserver/it.geosolutions/wms?", {
52
- layers: "it.geosolutions:Ekonomiska_zonens_yttre_avgränsningslinjer_linje",
53
- format: "image/png",
54
- transparent: true,
55
- version: "1.1.0"
56
- })
57
- };
58
- static Providers = [
59
- {
60
- name: 'Open Streetmap',
61
- id: 3,
62
- url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
63
- minZoom: 0,
64
- maxZoom: 18,
65
- params: {
66
- maxNativeZoom: 18,
67
- attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
68
- },
69
- wms: false
70
- },
71
- {
72
- name: 'Sveriges gränser',
73
- id: 7,
74
- url: 'https://sosgeo.artdata.slu.se/geoserver/it.geosolutions/wms',
75
- minZoom: 6,
76
- maxZoom: 18,
77
- params: {
78
- maxNativeZoom: 14,
79
- attribution: '© <a href="https://www.lantmateriet.se/">Sveriges gränser</a>',
80
- layers: 'it.geosolutions:Sverige_epsg5845', styles: 'municipality_name_yellow',
81
- epsg: 5845
82
- },
83
- wms: true
84
- }
85
- ];
86
- //NOTE: Will be move
87
- static redListMapper2 = {
88
- 'VU': '228',
89
- 'EN': '229',
90
- 'CR': '230',
91
- 'RE': '231',
92
- 'DD': '232',
93
- 'NT': '233'
94
- };
95
- static createMap(elementId, options = {}) {
96
- const map = Leaflet.map(elementId, {
97
- zoomAnimation: false,
98
- fadeAnimation: false,
99
- markerZoomAnimation: false,
100
- inertia: false,
101
- scrollWheelZoom: options.scrollZoom ?? true,
102
- zoomControl: options.zoom ?? true,
103
- dragging: options.zoom ?? true,
104
- minZoom: -1,
105
- zoomDelta: 1
106
- });
107
- map.setView([62, 17], 5);
108
- Leaflet.control.scale().addTo(map);
109
- if (options.providers !== false) {
110
- this.addProviders(map);
111
- }
112
- return map;
113
- }
114
- static addProviders(map) {
115
- const backgroundMaps = {};
116
- for (const value of Object.values(AdbMapUtils.Providers)) {
117
- backgroundMaps[value.name] = value.wms
118
- ? Leaflet.tileLayer.wms(value.url, value.params)
119
- : Leaflet.tileLayer(value.url, value.params);
120
- }
121
- if (backgroundMaps['Open Streetmap']) {
122
- map.addLayer(backgroundMaps['Open Streetmap']);
123
- }
124
- Leaflet.control.layers(backgroundMaps, AdbMapUtils.OverlayMaps).addTo(map);
125
- }
126
- }
127
-
128
- class PolygonDrawerInput {
129
- subscriptions = new Subscription();
130
- mapId = "" + Math.floor(Math.random() * Date.now());
131
- map;
132
- polygonDraw = false;
133
- shapeLayer;
134
- geoJson;
135
- ngAfterViewInit() {
136
- this.map = AdbMapUtils.createMap(this.mapId, {
137
- zoom: true,
138
- scrollZoom: true,
139
- providers: true
140
- });
141
- this.map.whenReady(() => {
142
- this.initDraw();
143
- this.renderInitialShape();
144
- });
145
- }
146
- ngOnInit() { }
147
- ngOnDestroy() {
148
- this.subscriptions.unsubscribe();
149
- }
150
- initDraw() {
151
- this.map.pm.removeControls();
152
- this.map.pm.enableDraw('Polygon', {
153
- tooltips: false,
154
- finishOn: 'snap',
155
- snapDistance: 30,
156
- snapMiddle: false
157
- });
158
- this.map.on("pm:create", (e) => {
159
- if (e.shape !== 'Polygon' && e.shape !== 'Circle')
160
- return;
161
- this.polygonDraw = false;
162
- this.map.pm.disableDraw();
163
- this.clearShape();
164
- this.shapeLayer = e.layer;
165
- if (this.shapeLayer instanceof Leaflet__default.Path) {
166
- this.shapeLayer.setStyle({ fillOpacity: 0.5 });
167
- }
168
- this.shapeLayer.interactive = false;
169
- this.map.fitBounds(this.shapeLayer.getBounds());
170
- const geo = this.shapeLayer.toGeoJSON();
171
- if (this.shapeLayer instanceof Leaflet__default.Circle) {
172
- geo.properties = {
173
- ...geo.properties,
174
- radius: Math.ceil(this.shapeLayer.getRadius())
175
- };
176
- }
177
- this.onChange(geo);
178
- });
179
- }
180
- renderInitialShape() {
181
- if (this.geoJson?.type === "Feature") {
182
- this.shapeLayer = Leaflet__default.geoJSON(this.geoJson, {
183
- interactive: false
184
- });
185
- this.map.addLayer(this.shapeLayer);
186
- this.map.fitBounds(this.shapeLayer.getBounds());
187
- }
188
- else {
189
- this.map.setView([AdbMapUtils.INITIAL_CENTER_LAT, AdbMapUtils.INITIAL_CENTER_LNG], 5);
190
- }
191
- }
192
- clearShape() {
193
- if (this.shapeLayer) {
194
- this.map.removeLayer(this.shapeLayer);
195
- this.shapeLayer = null;
196
- }
197
- }
198
- onDrawPolygon() {
199
- this.polygonDraw = true;
200
- this.map.pm.enableDraw("Polygon", {
201
- allowSelfIntersection: false,
202
- snappable: false
203
- });
204
- }
205
- onDrawCircle() {
206
- this.polygonDraw = true;
207
- this.map.pm.enableDraw("Circle", {
208
- allowSelfIntersection: false,
209
- snappable: false
210
- });
211
- }
212
- onUndoStep() {
213
- const draw = this.map.pm.Draw?.Polygon;
214
- draw?._removeLastVertex();
215
- }
216
- onDeleteShape() {
217
- this.clearShape();
218
- this.map.pm.disableDraw();
219
- this.polygonDraw = false;
220
- this.onChange(null);
221
- this.map.setView([62, 17], 5);
222
- }
223
- // ControlValueAccessor
224
- onChange = () => { };
225
- onTouched = () => { };
226
- writeValue(geoJson) {
227
- this.geoJson = geoJson;
228
- }
229
- registerOnChange(fn) {
230
- this.onChange = fn;
231
- }
232
- registerOnTouched(fn) {
233
- this.onTouched = fn;
234
- }
235
- setDisabledState(isDisabled) { }
236
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: PolygonDrawerInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
237
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: PolygonDrawerInput, isStandalone: false, selector: "adb-polygon-drawer", providers: [
238
- {
239
- provide: NG_VALUE_ACCESSOR,
240
- useExisting: forwardRef(() => PolygonDrawerInput),
241
- multi: true
242
- }
243
- ], ngImport: i0, template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\r\n <span class=\"bi bi-pentagon\"></span> {{'OBSERVATION.DRAW'|translate}}\r\n </button>\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer\" (click)=\"onDrawCircle()\" title=\"Circle\">\r\n <span class=\"bi bi-circle\"></span> {{'OBSERVATION.DRAW_CIRCLE'|translate}}\r\n </button>\r\n @if (shapeLayer) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\r\n <span class=\"bi bi-x\"></span>\r\n </button>\r\n }\r\n @if (polygonDraw) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onUndoStep()\" title=\"\u00C5ngra\">\r\n <span class=\"bi bi-arrow-counterclockwise\"></span>\r\n </button>\r\n }\r\n</div>\r\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>", dependencies: [{ kind: "pipe", type: i1.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
244
- }
245
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: PolygonDrawerInput, decorators: [{
246
- type: Component,
247
- args: [{ selector: "adb-polygon-drawer", standalone: false, changeDetection: ChangeDetectionStrategy.Eager, providers: [
248
- {
249
- provide: NG_VALUE_ACCESSOR,
250
- useExisting: forwardRef(() => PolygonDrawerInput),
251
- multi: true
252
- }
253
- ], template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\r\n <span class=\"bi bi-pentagon\"></span> {{'OBSERVATION.DRAW'|translate}}\r\n </button>\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer\" (click)=\"onDrawCircle()\" title=\"Circle\">\r\n <span class=\"bi bi-circle\"></span> {{'OBSERVATION.DRAW_CIRCLE'|translate}}\r\n </button>\r\n @if (shapeLayer) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\r\n <span class=\"bi bi-x\"></span>\r\n </button>\r\n }\r\n @if (polygonDraw) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onUndoStep()\" title=\"\u00C5ngra\">\r\n <span class=\"bi bi-arrow-counterclockwise\"></span>\r\n </button>\r\n }\r\n</div>\r\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>" }]
254
- }] });
255
-
256
- var AdbMapFilterType;
257
- (function (AdbMapFilterType) {
258
- AdbMapFilterType["Taxon"] = "taxon";
259
- AdbMapFilterType["Area"] = "area";
260
- AdbMapFilterType["OwnArea"] = "ownArea";
261
- AdbMapFilterType["Time"] = "time";
262
- AdbMapFilterType["RedList"] = "redlist";
263
- AdbMapFilterType["RiskList"] = "risklist";
264
- AdbMapFilterType["TaxaLists"] = "taxonLists";
265
- AdbMapFilterType["Datasources"] = "datasources";
266
- })(AdbMapFilterType || (AdbMapFilterType = {}));
267
- class VisibleFilters {
268
- showTaxon;
269
- showTime;
270
- showArea;
271
- showOwnArea;
272
- showTaxaLists;
273
- showDatasets;
274
- }
275
- const ADB_MAP_CONFIG = new InjectionToken('ADB_MAP_CONFIG');
276
- class AdbMapConfigService {
277
- log;
278
- artfaktaTaxonLists;
279
- observationFeatures;
280
- taxaListsApi;
281
- filters;
282
- observationPage;
283
- dynamic;
284
- constructor(config) {
285
- this.log = config.log ?? false;
286
- this.dynamic = config.dynamic ?? false;
287
- this.artfaktaTaxonLists = config.artfaktaTaxonLists ?? 'https://artfakta.se/metadata/listor';
288
- this.taxaListsApi = config.api + '/taxalists';
289
- this.observationFeatures = config.api + '/observation-features';
290
- this.observationPage = config.observationPage ?? 'https://mobil.artportalen.se/observationer';
291
- this.filters = {
292
- showTaxon: this.hasFilter(AdbMapFilterType.Taxon, config.filters),
293
- showTime: this.hasFilter(AdbMapFilterType.Time, config.filters),
294
- showArea: this.hasFilter(AdbMapFilterType.Area, config.filters),
295
- showOwnArea: this.hasFilter(AdbMapFilterType.OwnArea, config.filters),
296
- showTaxaLists: this.hasFilter(AdbMapFilterType.TaxaLists, config.filters),
297
- showDatasets: this.hasFilter(AdbMapFilterType.Datasources, config.filters)
298
- };
299
- }
300
- hasFilter(f, filters) {
301
- return filters?.includes(f) ?? true;
302
- }
303
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapConfigService, deps: [{ token: ADB_MAP_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
304
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapConfigService });
305
- }
306
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapConfigService, decorators: [{
307
- type: Injectable
308
- }], ctorParameters: () => [{ type: undefined, decorators: [{
309
- type: Inject,
310
- args: [ADB_MAP_CONFIG]
311
- }] }] });
312
-
313
- class TreeviewComponent {
314
- nodes = [];
315
- selectedIds = [];
316
- onChange = () => { };
317
- onTouched = () => { };
318
- writeValue(ids) {
319
- this.selectedIds = ids ?? [];
320
- this.applySelection(this.nodes);
321
- }
322
- registerOnChange(fn) {
323
- this.onChange = fn;
324
- }
325
- registerOnTouched(fn) {
326
- this.onTouched = fn;
327
- }
328
- setDisabledState(isDisabled) {
329
- this.setReadOnly(this.nodes, isDisabled);
330
- }
331
- onLeafToggle(node) {
332
- if (node._readOnly)
333
- return;
334
- node._selected = !node._selected;
335
- this.selectedIds = TreeviewComponent.collectSelectedLeafIds(this.nodes);
336
- this.onChange(this.selectedIds);
337
- this.onTouched();
338
- }
339
- applySelection(nodes) {
340
- for (const node of nodes) {
341
- if (node.children?.length) {
342
- this.applySelection(node.children);
343
- }
344
- else {
345
- node._selected = this.selectedIds.includes(node.id);
346
- }
347
- }
348
- }
349
- setReadOnly(nodes, readOnly) {
350
- for (const node of nodes) {
351
- node._readOnly = readOnly;
352
- if (node.children?.length) {
353
- this.setReadOnly(node.children, readOnly);
354
- }
355
- }
356
- }
357
- static collectSelectedLeafIds(nodes) {
358
- const ids = [];
359
- for (const node of nodes) {
360
- if (node.children?.length) {
361
- ids.push(...this.collectSelectedLeafIds(node.children));
362
- }
363
- else if (node._selected) {
364
- ids.push(node.id);
365
- }
366
- }
367
- return ids;
368
- }
369
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: TreeviewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
370
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: TreeviewComponent, isStandalone: false, selector: "app-treeview", inputs: { nodes: "nodes" }, providers: [
371
- {
372
- provide: NG_VALUE_ACCESSOR,
373
- useExisting: forwardRef(() => TreeviewComponent),
374
- multi: true
375
- }
376
- ], ngImport: i0, template: "<ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: nodes }\">\r\n</ng-container>\r\n<ng-template #nodeTpl let-nodes>\r\n @for (node of nodes; track node) {\r\n <div class=\"ms-3\">\r\n @if(!node.children || node.children.length === 0){\r\n <div class=\"d-flex align-items-center gap-2\">\r\n <input id=\"{{node.id}}\" type=\"checkbox\" class=\"form-check-input m-0\" [checked]=\"node._selected\" [disabled]=\"node._readOnly\" (change)=\"onLeafToggle(node)\" />\r\n <label for=\"{{node.id}}\">{{ node.name }}</label>\r\n </div>\r\n }\r\n @else {\r\n {{ node.name }}\r\n <div>\r\n <ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: node.children }\">\r\n </ng-container>\r\n </div>\r\n }\r\n </div>\r\n}\r\n</ng-template>", dependencies: [{ kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
377
- }
378
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: TreeviewComponent, decorators: [{
379
- type: Component,
380
- args: [{ selector: 'app-treeview', standalone: false, changeDetection: ChangeDetectionStrategy.Eager, providers: [
381
- {
382
- provide: NG_VALUE_ACCESSOR,
383
- useExisting: forwardRef(() => TreeviewComponent),
384
- multi: true
385
- }
386
- ], template: "<ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: nodes }\">\r\n</ng-container>\r\n<ng-template #nodeTpl let-nodes>\r\n @for (node of nodes; track node) {\r\n <div class=\"ms-3\">\r\n @if(!node.children || node.children.length === 0){\r\n <div class=\"d-flex align-items-center gap-2\">\r\n <input id=\"{{node.id}}\" type=\"checkbox\" class=\"form-check-input m-0\" [checked]=\"node._selected\" [disabled]=\"node._readOnly\" (change)=\"onLeafToggle(node)\" />\r\n <label for=\"{{node.id}}\">{{ node.name }}</label>\r\n </div>\r\n }\r\n @else {\r\n {{ node.name }}\r\n <div>\r\n <ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: node.children }\">\r\n </ng-container>\r\n </div>\r\n }\r\n </div>\r\n}\r\n</ng-template>" }]
387
- }], propDecorators: { nodes: [{
388
- type: Input
389
- }] } });
390
-
391
- class AdbObsMapComponent {
392
- activatedRoute;
393
- config;
394
- router;
395
- http;
396
- subscriptions = new Subscription();
397
- error;
398
- mapLoading = signal(false, ...(ngDevMode ? [{ debugName: "mapLoading" }] : /* istanbul ignore next */ []));
399
- siteLayer;
400
- hasBox;
401
- count;
402
- mapId = '' + Math.floor(Math.random() * Date.now());
403
- map = Leaflet.map;
404
- //Lock start
405
- mapReady = signal(false, ...(ngDevMode ? [{ debugName: "mapReady" }] : /* istanbul ignore next */ []));
406
- hasQueryParams = false;
407
- hasUrlParams = false;
408
- queryParams;
409
- urlParams;
410
- //Lock end
411
- constructor(activatedRoute, config, router, http) {
412
- this.activatedRoute = activatedRoute;
413
- this.config = config;
414
- this.router = router;
415
- this.http = http;
416
- effect(() => {
417
- // This will re-run whenever mapReady() changes
418
- if (this.mapReady() && this.hasQueryParams && this.hasUrlParams) {
419
- this.tryLoad();
420
- }
421
- });
422
- }
423
- ngAfterViewInit() {
424
- this.map = AdbMapUtils.createMap(this.mapId, {
425
- zoom: true,
426
- scrollZoom: false,
427
- providers: true
428
- });
429
- this.map.whenReady(() => {
430
- this.mapReady.set(true);
431
- if (this.config.dynamic) {
432
- this.attachUserListeners();
433
- }
434
- });
435
- }
436
- // Loads data only after:
437
- // - the Leaflet map is ready
438
- // - Angular has emitted query params (may be empty)
439
- // - Angular has emitted route params (may be empty)
440
- tryLoad() {
441
- if (!this.mapReady() || !this.hasQueryParams || !this.hasUrlParams) {
442
- return;
443
- }
444
- const params = { ...this.queryParams };
445
- this.hasBox = params['bbox'] ? true : false;
446
- if (this.urlParams.has('taxonId')) {
447
- params['taxonId'] = this.urlParams.get('taxonId');
448
- }
449
- this.loadFeature(params);
450
- }
451
- ngOnInit() {
452
- this.subscriptions.add(this.activatedRoute.queryParams.subscribe(q => {
453
- this.queryParams = q ?? {};
454
- this.hasQueryParams = true;
455
- this.tryLoad();
456
- }));
457
- this.subscriptions.add(this.activatedRoute.paramMap.subscribe(p => {
458
- this.urlParams = p;
459
- this.hasUrlParams = true;
460
- this.tryLoad();
461
- }));
462
- }
463
- attachUserListeners() {
464
- const container = this.map.getContainer();
465
- const zoomIn = container.querySelector('.leaflet-control-zoom-in');
466
- const zoomOut = container.querySelector('.leaflet-control-zoom-out');
467
- zoomIn?.addEventListener('click', () => { this.onUserInputRoute(); });
468
- zoomOut?.addEventListener('click', () => { this.onUserInputRoute(); });
469
- this.map.on('dragend', () => {
470
- this.onUserInputRoute();
471
- });
472
- }
473
- onUserInputRoute() {
474
- const bounds = this.map.getBounds();
475
- const bbox = this.getMapBoundsToBbox(bounds).join(',');
476
- this.router.navigate([], {
477
- relativeTo: this.activatedRoute,
478
- queryParams: { bbox },
479
- queryParamsHandling: 'merge'
480
- });
481
- }
482
- loadFeature(qParams) {
483
- if (this.siteLayer) {
484
- this.map.removeLayer(this.siteLayer);
485
- this.siteLayer = undefined;
486
- }
487
- this.mapLoading.set(true);
488
- this.error = null;
489
- const url = this.config.observationFeatures;
490
- this.subscriptions.add(this.http.get(url, { observe: 'response', params: qParams }).
491
- pipe(finalize(() => {
492
- this.mapLoading.set(false);
493
- })).
494
- subscribe({
495
- next: (response) => {
496
- if (!response.body) {
497
- throw new Error('No GeoJson body');
498
- }
499
- const geo = response.body;
500
- geo.properties = { count: response.headers.get('X-Observations-TotalCount') };
501
- this.buildMap(geo);
502
- }, error: err => {
503
- this.error = err;
504
- }
505
- }));
506
- }
507
- buildMap(geojson) {
508
- if (this.siteLayer) {
509
- this.map.removeLayer(this.siteLayer);
510
- }
511
- this.count = geojson?.properties?.count;
512
- this.siteLayer = Leaflet.geoJson(geojson, {
513
- style: (feature) => this.getPolygonStyle(feature.properties),
514
- pointToLayer: (feature, latlng) => {
515
- const marker = Leaflet.marker(latlng, {
516
- interactive: this.config.dynamic,
517
- icon: Leaflet.divIcon({
518
- className: '',
519
- html: '<div class="adb-map-marker"></div>',
520
- iconAnchor: [3, 3]
521
- })
522
- });
523
- if (feature.properties && feature.properties['Occurrence.OccurrenceId']) {
524
- marker.on('click', () => {
525
- window.location.href = this.config.observationPage + '/' + feature.properties['Occurrence.OccurrenceId'];
526
- });
527
- }
528
- return marker;
529
- }, onEachFeature: (feature, layer) => {
530
- if (feature.geometry.type === "Polygon" ||
531
- feature.geometry.type === "MultiPolygon") {
532
- if (feature.properties.ObservationsCount > 0) {
533
- if (this.config.dynamic) {
534
- layer.on('click', () => {
535
- const boundBox = JSON.stringify(this.getMapBoundsToBbox(layer.getBounds()));
536
- this.router.navigate([], { queryParams: { bbox: boundBox }, queryParamsHandling: 'merge' });
537
- });
538
- layer.on('mouseover', () => {
539
- layer.setStyle({ className: 'svg cursor-pointer' });
540
- });
541
- layer.on('mouseout', () => {
542
- layer.setStyle({ className: 'svg' });
543
- });
544
- }
545
- }
546
- if (!this.config.dynamic) {
547
- layer.setStyle({ interactive: false });
548
- }
549
- else if (feature.properties.FeatureType) { //area
550
- layer.setStyle({ interactive: false });
551
- }
552
- }
553
- }
554
- });
555
- const circleLayer = Leaflet.featureGroup();
556
- circleLayer.addTo(this.siteLayer);
557
- this.map.addLayer(this.siteLayer);
558
- if (geojson.bbox) {
559
- const [minLon, minLat, maxLon, maxLat] = geojson.bbox;
560
- const bounds = Leaflet.latLngBounds([[minLat, minLon], [maxLat, maxLon]]);
561
- if (bounds.isValid()) {
562
- // Safari sometimes needs extra time after layer adds
563
- setTimeout(() => {
564
- this.map.invalidateSize({ animate: false });
565
- this.map.fitBounds(bounds, { animate: false });
566
- }, 50); // 30–50ms works best in Safari
567
- }
568
- }
569
- }
570
- getMapBoundsToBbox(bounds) {
571
- return [
572
- bounds.getWest(),
573
- bounds.getSouth(),
574
- bounds.getEast(),
575
- bounds.getNorth()
576
- ];
577
- }
578
- getPolygonStyle(props) {
579
- if (props.location) {
580
- //Its locations
581
- return {
582
- weight: 2,
583
- color: '#005e67',
584
- fill: false
585
- };
586
- }
587
- else if (props.FeatureId) {
588
- // featurearea
589
- return {
590
- weight: 2,
591
- fill: true,
592
- fillOpacity: 0.1,
593
- color: '#005e67',
594
- fillColor: '#007681'
595
- };
596
- }
597
- else {
598
- //its heatmaps
599
- const base = {
600
- weight: 1,
601
- fill: true,
602
- fillOpacity: 0.8
603
- };
604
- if (props.FeatureType) {
605
- return { ...base, color: '#249ca3', fillColor: '#2FB3BB' };
606
- }
607
- if (props.ObservationsCount < 10) {
608
- return { ...base, color: '#249ca3', fillColor: '#2FB3BB' };
609
- }
610
- if (props.ObservationsCount < 500) {
611
- return { ...base, color: '#005e67', fillColor: '#007681' };
612
- }
613
- return { ...base, color: '#00393D', fillColor: '#00393D' };
614
- }
615
- }
616
- ngOnDestroy() {
617
- this.subscriptions.unsubscribe();
618
- }
619
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbObsMapComponent, deps: [{ token: i1$2.ActivatedRoute }, { token: AdbMapConfigService }, { token: i1$2.Router }, { token: i3.HttpClient }], target: i0.ɵɵFactoryTarget.Component });
620
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: AdbObsMapComponent, isStandalone: false, selector: "adb-obs-map", ngImport: i0, template: "@if(hasBox&&!mapLoading()){\r\n<div class=\"mb-1 d-flex justify-content-between flex-wrap\">\r\n <a [routerLink]=\"[]\" [queryParams]=\"{bbox:null,z:null}\" queryParamsHandling=\"merge\" class=\"d-flex gap-1 align-items-baseline\">\r\n <span class=\"bi bi-chevron-left\"></span>\r\n Tillbaka upp\r\n </a>\r\n</div>\r\n}\r\n@if(error){\r\n<div class=\"alert alert-danger\">\r\n {{'ERROR.SERVER_ERROR'|translate}}\r\n</div>\r\n}\r\n<div [class.loading]=\"mapLoading()\">\r\n <div [id]=\"mapId\" class=\"mb-1 map-container\"></div>\r\n</div>\r\n<div class=\"mb-1 d-flex gap-3 justify-content-between flex-wrap\">\r\n @if (!mapLoading()&&count) {\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-low\"></div>\r\n &lt;10\r\n </div>\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-medium\"></div>\r\n 10 - 500\r\n </div>\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-high\"></div>\r\n &gt;500\r\n </div>\r\n <div class=\"ms-auto\">\r\n {{count|adbSpacing}} {{'OBSERVATION.OBSERVATIONS'|translate}}\r\n </div>\r\n }\r\n</div>", dependencies: [{ kind: "directive", type: i1$2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "pipe", type: i5.NumberSpacingPipe, name: "adbSpacing" }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
621
- }
622
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbObsMapComponent, decorators: [{
623
- type: Component,
624
- args: [{ selector: 'adb-obs-map', changeDetection: ChangeDetectionStrategy.Eager, standalone: false, template: "@if(hasBox&&!mapLoading()){\r\n<div class=\"mb-1 d-flex justify-content-between flex-wrap\">\r\n <a [routerLink]=\"[]\" [queryParams]=\"{bbox:null,z:null}\" queryParamsHandling=\"merge\" class=\"d-flex gap-1 align-items-baseline\">\r\n <span class=\"bi bi-chevron-left\"></span>\r\n Tillbaka upp\r\n </a>\r\n</div>\r\n}\r\n@if(error){\r\n<div class=\"alert alert-danger\">\r\n {{'ERROR.SERVER_ERROR'|translate}}\r\n</div>\r\n}\r\n<div [class.loading]=\"mapLoading()\">\r\n <div [id]=\"mapId\" class=\"mb-1 map-container\"></div>\r\n</div>\r\n<div class=\"mb-1 d-flex gap-3 justify-content-between flex-wrap\">\r\n @if (!mapLoading()&&count) {\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-low\"></div>\r\n &lt;10\r\n </div>\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-medium\"></div>\r\n 10 - 500\r\n </div>\r\n <div class=\"d-flex align-items-center gap-1\">\r\n <div class=\"legend map-heat-high\"></div>\r\n &gt;500\r\n </div>\r\n <div class=\"ms-auto\">\r\n {{count|adbSpacing}} {{'OBSERVATION.OBSERVATIONS'|translate}}\r\n </div>\r\n }\r\n</div>" }]
625
- }], ctorParameters: () => [{ type: i1$2.ActivatedRoute }, { type: AdbMapConfigService }, { type: i1$2.Router }, { type: i3.HttpClient }] });
626
-
1
+ import * as i1$2 from "@angular/common";
2
+ import { CommonModule } from "@angular/common";
3
+ import * as i0 from "@angular/core";
4
+ import { ChangeDetectionStrategy, Component, ElementRef, Inject, Injectable, InjectionToken, Input, NgModule, afterRenderEffect, computed, effect, forwardRef, inject, input, output, signal } from "@angular/core";
5
+ import * as i4 from "@angular/forms";
6
+ import { FormArray, FormControl, FormGroup, FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule, Validators } from "@angular/forms";
7
+ import GeoJSON from "ol/format/GeoJSON.js";
8
+ import Draw from "ol/interaction/Draw.js";
9
+ import VectorLayer from "ol/layer/Vector.js";
10
+ import VectorSource from "ol/source/Vector.js";
11
+ import CircleGeometry from "ol/geom/Circle.js";
12
+ import Polygon, { circular } from "ol/geom/Polygon.js";
13
+ import { fromLonLat, toLonLat, transformExtent } from "ol/proj.js";
14
+ import { getDistance } from "ol/sphere.js";
15
+ import Map from "ol/Map.js";
16
+ import View from "ol/View.js";
17
+ import TileLayer from "ol/layer/Tile.js";
18
+ import TileWMS from "ol/source/TileWMS.js";
19
+ import XYZ from "ol/source/XYZ.js";
20
+ import Control from "ol/control/Control.js";
21
+ import ScaleLine from "ol/control/ScaleLine.js";
22
+ import { defaults } from "ol/control/defaults.js";
23
+ import { defaults as defaults$1 } from "ol/interaction/defaults.js";
24
+ import { Circle, Fill, RegularShape, Stroke, Style, Text } from "ol/style.js";
25
+ import * as i1$3 from "@ngx-translate/core";
26
+ import { TranslatePipe } from "@ngx-translate/core";
27
+ import * as i1 from "@angular/router";
28
+ import { NavigationEnd, RouterModule } from "@angular/router";
29
+ import Feature from "ol/Feature.js";
30
+ import { extend, getCenter, getForViewAndSize, isEmpty } from "ol/extent.js";
31
+ import { finalize } from "rxjs/operators";
32
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
33
+ import * as i3 from "@angular/common/http";
34
+ import LineString from "ol/geom/LineString.js";
35
+ import MultiPolygon from "ol/geom/MultiPolygon.js";
36
+ import * as i1$1 from "adb-shared";
37
+ import { AdbButtonsModule, AdbDatePickerModule, AdbDirectivesModule, AdbFilterSectionModule, AdbPickerModule, AdbPipesModule } from "adb-shared";
38
+ import { addYears, endOfDay, endOfYear, parseISO, startOfDay, startOfYear } from "date-fns";
39
+ import { Subscription, combineLatest, debounceTime, map } from "rxjs";
627
40
  const DateTypes = {
628
- THIS_YEAR: '1',
629
- LAST_YEAR: '2',
630
- ALL_YEAR: '3',
631
- LAST_5_YEAR: '4',
632
- LAST_25_YEAR: '5',
633
- CUSTOM: '6',
41
+ THIS_YEAR: "1",
42
+ LAST_YEAR: "2",
43
+ ALL_YEAR: "3",
44
+ LAST_5_YEAR: "4",
45
+ LAST_25_YEAR: "5",
46
+ CUSTOM: "6"
634
47
  };
48
+ const MapConstants = {
49
+ INITIAL_METERS_PER_PIXEL: 200,
50
+ LOCATION_MARKER_BACKGROUND_COLOR: "#f3db60",
51
+ LOCATION_MARKER_BORDER_COLOR: "#665500",
52
+ OBSERVATION_MARKER_BACKGROUND_COLOR: "#007c91",
53
+ CLUSTER_MARKER_BACKGROUND_COLOR: "#1e90ff",
54
+ CLUSTER_MARKER_BORDER_COLOR: "#000",
55
+ SELECTED_MARKER_BORDER_COLOR: "#000",
56
+ LOCATION_POLYGON_BORDER_COLOR: "#005e67",
57
+ GENERALIZED_POLYGON_BORDER_COLOR: "#b3261e",
58
+ GENERALIZED_POLYGON_BACKGROUND_COLOR: "rgba(179, 38, 30, 0.15)",
59
+ SELECTED_COLOR: "#ff00ff",
60
+ UNCERTAINTY_BORDER_COLOR: "#777",
61
+ SEARCH_AREA_BORDER_COLOR: "#1e90ff",
62
+ AFTER_CUTOFF_YEAR_COLOR: "#3366cc",
63
+ BEFORE_CUTOFF_YEAR_COLOR: "#8a3fd0",
64
+ MARKER_RADIUS: 6,
65
+ CLUSTER_MARKER_RADIUS: 8,
66
+ HOVER_RADIUS: 10
67
+ };
68
+ var AdbMapUtils = class AdbMapUtils {
69
+ static locationSymbol(feature, selected = false, hovered = false) {
70
+ const props = feature.getProperties();
71
+ const cluster = props["groupingType"] === "pixelCluster" || props["isCluster"];
72
+ const point = ["Point", "MultiPoint"].includes(feature.getGeometry()?.getType());
73
+ const text = point && !cluster && props["observationCount"] === 1 && (props["locations"]?.count === 1 || !!props["location"]) ? new Text({
74
+ text: "1",
75
+ offsetY: 2,
76
+ font: "bold 10px sans-serif",
77
+ fill: new Fill({ color: "#000" }),
78
+ stroke: new Stroke({
79
+ color: "#fff",
80
+ width: 2
81
+ })
82
+ }) : null;
83
+ if (selected) return new Style({
84
+ text,
85
+ image: new Circle({
86
+ radius: hovered ? MapConstants.HOVER_RADIUS : cluster ? MapConstants.CLUSTER_MARKER_RADIUS : MapConstants.MARKER_RADIUS,
87
+ fill: new Fill({ color: MapConstants.SELECTED_COLOR }),
88
+ stroke: new Stroke({
89
+ color: MapConstants.SELECTED_MARKER_BORDER_COLOR,
90
+ width: 2
91
+ })
92
+ }),
93
+ stroke: new Stroke({
94
+ color: MapConstants.SELECTED_COLOR,
95
+ width: 3
96
+ }),
97
+ fill: new Fill({ color: "transparent" })
98
+ });
99
+ if (point) return new Style({
100
+ text,
101
+ image: new Circle({
102
+ radius: hovered ? MapConstants.HOVER_RADIUS : cluster ? MapConstants.CLUSTER_MARKER_RADIUS : MapConstants.MARKER_RADIUS,
103
+ fill: new Fill({ color: cluster ? MapConstants.CLUSTER_MARKER_BACKGROUND_COLOR : MapConstants.LOCATION_MARKER_BACKGROUND_COLOR }),
104
+ stroke: new Stroke({
105
+ color: cluster ? MapConstants.CLUSTER_MARKER_BORDER_COLOR : MapConstants.LOCATION_MARKER_BORDER_COLOR,
106
+ width: cluster ? 2 : 1
107
+ })
108
+ })
109
+ });
110
+ return new Style({
111
+ fill: new Fill({ color: "transparent" }),
112
+ stroke: new Stroke({
113
+ color: MapConstants.LOCATION_POLYGON_BORDER_COLOR,
114
+ width: hovered ? 4 : 2
115
+ })
116
+ });
117
+ }
118
+ static isNotRecovered(presentation) {
119
+ return presentation?.status === "NotRecovered";
120
+ }
121
+ static aggregatedSymbol(style, presentation, cutoffYear, selected, geometryType = null) {
122
+ if (!selected && presentation?.generalized && ["Polygon", "MultiPolygon"].includes(geometryType)) {
123
+ style.setStroke(new Stroke({
124
+ color: MapConstants.GENERALIZED_POLYGON_BORDER_COLOR,
125
+ width: style.getStroke().getWidth()
126
+ }));
127
+ style.setFill(new Fill({ color: MapConstants.GENERALIZED_POLYGON_BACKGROUND_COLOR }));
128
+ return style;
129
+ }
130
+ let symbol = style;
131
+ const notRecovered = this.isNotRecovered(presentation);
132
+ const notPresent = presentation?.status === "NotPresent";
133
+ if (notRecovered || notPresent) {
134
+ style.setText(null);
135
+ symbol = [style, new Style({ image: new RegularShape({
136
+ points: notRecovered ? 4 : 2,
137
+ radius: 5,
138
+ radius2: 0,
139
+ angle: notRecovered ? Math.PI / 4 : Math.PI / 2,
140
+ stroke: new Stroke({
141
+ color: "#000",
142
+ width: 1.5,
143
+ lineJoin: "round"
144
+ })
145
+ }) })];
146
+ }
147
+ if (selected || !cutoffYear) return symbol;
148
+ const status = presentation?.cutoffYearStatus;
149
+ if (status !== "Until" && status !== "After") return symbol;
150
+ const before = status === "Until";
151
+ const color = before ? MapConstants.BEFORE_CUTOFF_YEAR_COLOR : MapConstants.AFTER_CUTOFF_YEAR_COLOR;
152
+ const image = style.getImage();
153
+ if (image instanceof Circle) {
154
+ image.setFill(before ? null : new Fill({ color }));
155
+ image.setStroke(new Stroke({
156
+ color: before ? color : "#000",
157
+ width: before ? 2 : image.getStroke().getWidth()
158
+ }));
159
+ } else style.setStroke(new Stroke({
160
+ color,
161
+ width: style.getStroke().getWidth()
162
+ }));
163
+ return symbol;
164
+ }
165
+ static createUncertaintyCircle(center, radius) {
166
+ const latitude = toLonLat(center)[1];
167
+ return new CircleGeometry(center, radius / Math.cos(latitude * Math.PI / 180));
168
+ }
169
+ static INITIAL_METERS_PER_PIXEL = 500;
170
+ static INITIAL_CENTER_LAT = 62;
171
+ static INITIAL_CENTER_LNG = 17;
172
+ static gridLevels(result) {
173
+ const counts = (result?.features ?? []).map((feature) => feature.properties?.ObservationsCount).filter((count) => typeof count === "number");
174
+ if (!counts.length) return [];
175
+ const max = Math.max(...counts);
176
+ const first = Math.ceil(max / 3);
177
+ const second = Math.ceil(2 * max / 3);
178
+ return [
179
+ {
180
+ min: max === 0 ? 0 : 1,
181
+ max: first,
182
+ color: "#2fb3bb"
183
+ },
184
+ {
185
+ min: first + 1,
186
+ max: second,
187
+ color: "#005e67"
188
+ },
189
+ {
190
+ min: second + 1,
191
+ max,
192
+ color: "#00393d"
193
+ }
194
+ ].filter((level) => level.min <= level.max);
195
+ }
196
+ static getMetersPerPixel(bbox, mapWidth) {
197
+ if (bbox && mapWidth > 0) {
198
+ const [minLon, minLat, maxLon, maxLat] = bbox.split(",").map(Number);
199
+ const centerLat = (minLat + maxLat) / 2;
200
+ return getDistance([minLon, centerLat], [maxLon, centerLat]) / mapWidth;
201
+ }
202
+ return AdbMapUtils.INITIAL_METERS_PER_PIXEL;
203
+ }
204
+ static OverlayMaps = {
205
+ "Altitude": AdbMapUtils.wms("https://maps.sgu.se/lmv/hojdmodell/v1.1?SERVICE=WMS", {
206
+ layers: "terrangskuggning",
207
+ format: "image/png",
208
+ transparent: true,
209
+ opacity: .3,
210
+ maxZoom: 16,
211
+ version: "1.3.0"
212
+ }),
213
+ "Fjällkarta": AdbMapUtils.wms("api/maps/mountain", {
214
+ minZoom: 6,
215
+ maxZoom: 18,
216
+ maxNativeZoom: 14,
217
+ attribution: "© <a href=\"https://www.lantmateriet.se/\">Fjällkart</a>",
218
+ wms: true
219
+ }),
220
+ "Kommuner": AdbMapUtils.wms("https://sosgeo.artdata.slu.se/geoserver/GeoRegion/wms?", {
221
+ layers: "GeoRegion:Municipality",
222
+ version: "1.1.0",
223
+ transparent: true,
224
+ format: "image/png"
225
+ }),
226
+ "Län": AdbMapUtils.wms("https://sosgeo.artdata.slu.se/geoserver/GeoRegion/wms?", {
227
+ layers: "GeoRegion:County",
228
+ version: "1.1.0",
229
+ transparent: true,
230
+ format: "image/png"
231
+ }),
232
+ "Ortnamn": AdbMapUtils.wms("https://maps.sgu.se/lmv/topowebb-skikt/v1.1?SERVICE=WMS", {
233
+ layers: "text",
234
+ format: "image/png",
235
+ transparent: true,
236
+ version: "1.3.0"
237
+ }),
238
+ "Ekonomisk zon": AdbMapUtils.wms("https://sosgeo.artdata.slu.se/geoserver/it.geosolutions/wms?", {
239
+ layers: "it.geosolutions:Ekonomiska_zonens_yttre_avgränsningslinjer_linje",
240
+ format: "image/png",
241
+ transparent: true,
242
+ version: "1.1.0"
243
+ })
244
+ };
245
+ static Providers = [{
246
+ name: "Open Streetmap",
247
+ id: 3,
248
+ url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
249
+ minZoom: 0,
250
+ maxZoom: 18,
251
+ params: {
252
+ maxNativeZoom: 18,
253
+ attribution: "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"
254
+ },
255
+ wms: false
256
+ }, {
257
+ name: "Sveriges gränser",
258
+ id: 7,
259
+ url: "https://sosgeo.artdata.slu.se/geoserver/it.geosolutions/wms",
260
+ minZoom: 6,
261
+ maxZoom: 18,
262
+ params: {
263
+ maxNativeZoom: 14,
264
+ attribution: "© <a href=\"https://www.lantmateriet.se/\">Sveriges gränser</a>",
265
+ layers: "it.geosolutions:Sverige_epsg5845",
266
+ styles: "municipality_name_yellow",
267
+ epsg: 5845
268
+ },
269
+ wms: true
270
+ }];
271
+ static wms(url, options) {
272
+ const { opacity = 1, attribution, minZoom, maxZoom, maxNativeZoom, epsg, wms, ...parameters } = options;
273
+ const params = Object.fromEntries(Object.entries(parameters).map(([key, value]) => [key.toUpperCase(), value]));
274
+ return new TileLayer({
275
+ opacity,
276
+ minZoom,
277
+ maxZoom,
278
+ source: new TileWMS({
279
+ url,
280
+ params,
281
+ attributions: attribution
282
+ })
283
+ });
284
+ }
285
+ static createMap(elementId, options = {}) {
286
+ const map = new Map({
287
+ target: elementId,
288
+ view: new View({
289
+ center: fromLonLat([AdbMapUtils.INITIAL_CENTER_LNG, AdbMapUtils.INITIAL_CENTER_LAT]),
290
+ zoom: 5,
291
+ minZoom: 0,
292
+ maxZoom: 20
293
+ }),
294
+ controls: defaults({ zoom: options.zoom ?? true }).extend([new ScaleLine()]),
295
+ interactions: defaults$1({
296
+ mouseWheelZoom: options.scrollZoom ?? true,
297
+ dragPan: options.zoom ?? true
298
+ })
299
+ });
300
+ if (options.providers !== false) this.addProviders(map);
301
+ return map;
302
+ }
303
+ static addProviders(map) {
304
+ const element = document.createElement("details");
305
+ element.className = "ol-control adb-map-layers";
306
+ const summary = document.createElement("summary");
307
+ summary.textContent = "Kartlager";
308
+ element.append(summary);
309
+ const backgrounds = this.Providers.map((provider) => {
310
+ const layer = provider.wms ? this.wms(provider.url, provider.params) : new TileLayer({ source: new XYZ({
311
+ url: provider.url.replace("{s}", "{a-c}"),
312
+ attributions: provider.params.attribution,
313
+ maxZoom: provider.params.maxNativeZoom
314
+ }) });
315
+ return {
316
+ name: provider.name,
317
+ layer
318
+ };
319
+ });
320
+ const overlays = Object.entries(this.OverlayMaps).map(([name, original]) => ({
321
+ name,
322
+ layer: new TileLayer({
323
+ source: new TileWMS({
324
+ url: original.getSource().getUrls()[0],
325
+ params: original.getSource().getParams(),
326
+ attributions: original.getSource().getAttributions()
327
+ }),
328
+ opacity: original.getOpacity(),
329
+ minZoom: original.getMinZoom(),
330
+ maxZoom: original.getMaxZoom()
331
+ })
332
+ }));
333
+ for (const [index, entry] of [...backgrounds, ...overlays].entries()) {
334
+ const background = index < backgrounds.length;
335
+ entry.layer.setVisible(index === 0);
336
+ map.addLayer(entry.layer);
337
+ const label = document.createElement("label");
338
+ const input = document.createElement("input");
339
+ input.type = background ? "radio" : "checkbox";
340
+ input.name = `background-${map.getTarget()}`;
341
+ input.checked = entry.layer.getVisible();
342
+ input.addEventListener("change", () => {
343
+ if (background) backgrounds.forEach((item) => item.layer.setVisible(item === entry));
344
+ else entry.layer.setVisible(input.checked);
345
+ });
346
+ label.append(input, document.createTextNode(entry.name));
347
+ element.append(label);
348
+ if (index === 0) element.append(document.createElement("hr"));
349
+ }
350
+ map.addControl(new Control({ element }));
351
+ }
352
+ static createFile(source, fileName = "map-download") {
353
+ const link = document.createElement("a");
354
+ link.href = URL.createObjectURL(source);
355
+ link.download = fileName;
356
+ document.body.appendChild(link);
357
+ link.click();
358
+ document.body.removeChild(link);
359
+ URL.revokeObjectURL(link.href);
360
+ return true;
361
+ }
362
+ };
363
+ var PolygonDrawerInput = class PolygonDrawerInput {
364
+ mapId = "draw-" + Math.floor(Math.random() * Date.now());
365
+ map;
366
+ polygonDraw = false;
367
+ disabled = false;
368
+ shapeLayer = false;
369
+ source = new VectorSource();
370
+ format = new GeoJSON();
371
+ draw;
372
+ geoJson;
373
+ resizeObserver;
374
+ pendingFit = false;
375
+ onChange = (value) => {};
376
+ onTouched = () => {};
377
+ ngAfterViewInit() {
378
+ this.map = AdbMapUtils.createMap(this.mapId, {
379
+ zoom: true,
380
+ scrollZoom: true,
381
+ providers: true
382
+ });
383
+ this.map.addLayer(new VectorLayer({ source: this.source }));
384
+ this.resizeObserver = new ResizeObserver(() => {
385
+ this.map.updateSize();
386
+ this.fitShape();
387
+ });
388
+ this.resizeObserver.observe(this.map.getTargetElement());
389
+ this.renderValue();
390
+ }
391
+ onDrawPolygon() {
392
+ this.startDraw("Polygon");
393
+ }
394
+ onDrawCircle() {
395
+ this.startDraw("Circle");
396
+ }
397
+ startDraw(type) {
398
+ if (this.disabled) return;
399
+ this.stopDraw();
400
+ this.polygonDraw = true;
401
+ this.draw = new Draw({
402
+ source: this.source,
403
+ type
404
+ });
405
+ this.map.addInteraction(this.draw);
406
+ this.draw.on("drawend", (event) => {
407
+ this.source.clear();
408
+ const geometry = event.feature.getGeometry();
409
+ const options = { featureProjection: this.map.getView().getProjection() };
410
+ let geo;
411
+ if (geometry instanceof CircleGeometry) {
412
+ const center = toLonLat(geometry.getCenter());
413
+ const edge = toLonLat([geometry.getCenter()[0] + geometry.getRadius(), geometry.getCenter()[1]]);
414
+ const radius = Math.ceil(getDistance(center, edge));
415
+ geo = {
416
+ type: "Feature",
417
+ geometry: this.format.writeGeometryObject(circular(center, radius, 64)),
418
+ properties: { radius }
419
+ };
420
+ } else geo = this.format.writeFeatureObject(event.feature, options);
421
+ this.geoJson = geo;
422
+ this.shapeLayer = true;
423
+ this.onChange(geo);
424
+ this.onTouched();
425
+ this.stopDraw();
426
+ });
427
+ }
428
+ stopDraw() {
429
+ if (this.draw) this.map.removeInteraction(this.draw);
430
+ this.draw = void 0;
431
+ this.polygonDraw = false;
432
+ }
433
+ onUndoStep() {
434
+ this.draw?.removeLastPoint();
435
+ }
436
+ onDeleteShape() {
437
+ if (this.disabled) return;
438
+ this.stopDraw();
439
+ this.source.clear();
440
+ this.pendingFit = false;
441
+ this.shapeLayer = false;
442
+ this.geoJson = null;
443
+ this.onChange(null);
444
+ this.onTouched();
445
+ this.map.getView().setCenter(fromLonLat([AdbMapUtils.INITIAL_CENTER_LNG, AdbMapUtils.INITIAL_CENTER_LAT]));
446
+ this.map.getView().setZoom(5);
447
+ }
448
+ renderValue() {
449
+ if (!this.map) return;
450
+ this.source.clear();
451
+ this.pendingFit = false;
452
+ this.shapeLayer = false;
453
+ if (this.geoJson?.type !== "Feature") return;
454
+ const feature = this.format.readFeatures(this.geoJson, { featureProjection: this.map.getView().getProjection() })[0];
455
+ if (this.geoJson.geometry.type === "Point" && this.geoJson.properties?.radius) {
456
+ const latitude = this.geoJson.geometry.coordinates[1];
457
+ feature.setGeometry(new CircleGeometry(fromLonLat(this.geoJson.geometry.coordinates), this.geoJson.properties.radius / Math.cos(latitude * Math.PI / 180)));
458
+ }
459
+ this.source.addFeature(feature);
460
+ this.shapeLayer = true;
461
+ this.pendingFit = true;
462
+ this.fitShape();
463
+ }
464
+ fitShape() {
465
+ const size = this.map.getSize();
466
+ if (!this.pendingFit || !size?.[0] || !size[1]) return;
467
+ this.map.getView().fit(this.source.getExtent(), {
468
+ padding: [
469
+ 20,
470
+ 20,
471
+ 20,
472
+ 20
473
+ ],
474
+ maxZoom: 18
475
+ });
476
+ this.pendingFit = false;
477
+ }
478
+ writeValue(value) {
479
+ this.geoJson = value;
480
+ this.renderValue();
481
+ }
482
+ registerOnChange(fn) {
483
+ this.onChange = fn;
484
+ }
485
+ registerOnTouched(fn) {
486
+ this.onTouched = fn;
487
+ }
488
+ setDisabledState(disabled) {
489
+ this.disabled = disabled;
490
+ if (disabled && this.map) this.stopDraw();
491
+ }
492
+ ngOnDestroy() {
493
+ this.resizeObserver?.disconnect();
494
+ this.map?.dispose();
495
+ }
496
+ static ɵfac = i0.ɵɵngDeclareFactory({
497
+ minVersion: "12.0.0",
498
+ version: "22.2.4",
499
+ ngImport: i0,
500
+ type: PolygonDrawerInput,
501
+ deps: [],
502
+ target: i0.ɵɵFactoryTarget.Component
503
+ });
504
+ static ɵcmp = i0.ɵɵngDeclareComponent({
505
+ minVersion: "17.0.0",
506
+ version: "22.2.4",
507
+ type: PolygonDrawerInput,
508
+ isStandalone: false,
509
+ selector: "adb-polygon-drawer",
510
+ providers: [{
511
+ provide: NG_VALUE_ACCESSOR,
512
+ useExisting: forwardRef(() => PolygonDrawerInput),
513
+ multi: true
514
+ }],
515
+ ngImport: i0,
516
+ template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled || shapeLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\n <span class=\"bi bi-pentagon\"></span> {{'OBSERVATION.DRAW'|translate}}\n </button>\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled || shapeLayer\" (click)=\"onDrawCircle()\" title=\"Circle\">\n <span class=\"bi bi-circle\"></span> {{'OBSERVATION.DRAW_CIRCLE'|translate}}\n </button>\n @if (shapeLayer) {\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\n <span class=\"bi bi-x\"></span>\n </button>\n }\n @if (polygonDraw) {\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled\" (click)=\"onUndoStep()\" title=\"Ångra\">\n <span class=\"bi bi-arrow-counterclockwise\"></span>\n </button>\n }\n</div>\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>",
517
+ dependencies: [{
518
+ kind: "pipe",
519
+ type: i1$3.TranslatePipe,
520
+ name: "translate"
521
+ }],
522
+ changeDetection: i0.ChangeDetectionStrategy.Eager
523
+ });
524
+ };
525
+ i0.ɵɵngDeclareClassMetadata({
526
+ minVersion: "12.0.0",
527
+ version: "22.2.4",
528
+ ngImport: i0,
529
+ type: PolygonDrawerInput,
530
+ decorators: [{
531
+ type: Component,
532
+ args: [{
533
+ selector: "adb-polygon-drawer",
534
+ standalone: false,
535
+ changeDetection: ChangeDetectionStrategy.Eager,
536
+ providers: [{
537
+ provide: NG_VALUE_ACCESSOR,
538
+ useExisting: forwardRef(() => PolygonDrawerInput),
539
+ multi: true
540
+ }],
541
+ template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled || shapeLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\n <span class=\"bi bi-pentagon\"></span> {{'OBSERVATION.DRAW'|translate}}\n </button>\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled || shapeLayer\" (click)=\"onDrawCircle()\" title=\"Circle\">\n <span class=\"bi bi-circle\"></span> {{'OBSERVATION.DRAW_CIRCLE'|translate}}\n </button>\n @if (shapeLayer) {\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\n <span class=\"bi bi-x\"></span>\n </button>\n }\n @if (polygonDraw) {\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"disabled\" (click)=\"onUndoStep()\" title=\"Ångra\">\n <span class=\"bi bi-arrow-counterclockwise\"></span>\n </button>\n }\n</div>\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>"
542
+ }]
543
+ }]
544
+ });
545
+ const ADB_MAP_CONFIG = new InjectionToken("ADB_MAP_CONFIG");
546
+ var AdbMapConfigService = class AdbMapConfigService {
547
+ artfaktaTaxonLists;
548
+ observationFeatures;
549
+ taxaListsApi;
550
+ dynamic;
551
+ gridOnly;
552
+ enableClusterSelection;
553
+ dataProviderIds;
554
+ constructor(config) {
555
+ this.dynamic = config.dynamic ?? false;
556
+ this.gridOnly = config.gridOnly ?? false;
557
+ this.dataProviderIds = config.dataProviderIds === void 0 ? void 0 : Object.freeze([...config.dataProviderIds]);
558
+ this.enableClusterSelection = config.enableClusterSelection ?? false;
559
+ this.artfaktaTaxonLists = config.artfaktaTaxonLists ?? "https://artfakta.se/metadata/listor";
560
+ this.taxaListsApi = config.api + "/taxalists";
561
+ this.observationFeatures = "https://sos-search-st.wt.artdata.slu.se/observations/internal/adaptivesearchlocations";
562
+ }
563
+ static ɵfac = i0.ɵɵngDeclareFactory({
564
+ minVersion: "12.0.0",
565
+ version: "22.2.4",
566
+ ngImport: i0,
567
+ type: AdbMapConfigService,
568
+ deps: [{ token: ADB_MAP_CONFIG }],
569
+ target: i0.ɵɵFactoryTarget.Injectable
570
+ });
571
+ static ɵprov = i0.ɵɵngDeclareInjectable({
572
+ minVersion: "12.0.0",
573
+ version: "22.2.4",
574
+ ngImport: i0,
575
+ type: AdbMapConfigService
576
+ });
577
+ };
578
+ i0.ɵɵngDeclareClassMetadata({
579
+ minVersion: "12.0.0",
580
+ version: "22.2.4",
581
+ ngImport: i0,
582
+ type: AdbMapConfigService,
583
+ decorators: [{ type: Injectable }],
584
+ ctorParameters: () => [{
585
+ type: void 0,
586
+ decorators: [{
587
+ type: Inject,
588
+ args: [ADB_MAP_CONFIG]
589
+ }]
590
+ }]
591
+ });
592
+ var TreeviewComponent = class TreeviewComponent {
593
+ nodes = [];
594
+ selectedIds = [];
595
+ onChange = () => {};
596
+ onTouched = () => {};
597
+ writeValue(ids) {
598
+ this.selectedIds = ids ?? [];
599
+ this.applySelection(this.nodes);
600
+ }
601
+ registerOnChange(fn) {
602
+ this.onChange = fn;
603
+ }
604
+ registerOnTouched(fn) {
605
+ this.onTouched = fn;
606
+ }
607
+ setDisabledState(isDisabled) {
608
+ this.setReadOnly(this.nodes, isDisabled);
609
+ }
610
+ onLeafToggle(node) {
611
+ if (node._readOnly) return;
612
+ node._selected = !node._selected;
613
+ this.selectedIds = TreeviewComponent.collectSelectedLeafIds(this.nodes);
614
+ this.onChange(this.selectedIds);
615
+ this.onTouched();
616
+ }
617
+ applySelection(nodes) {
618
+ for (const node of nodes) if (node.children?.length) this.applySelection(node.children);
619
+ else node._selected = this.selectedIds.includes(node.id);
620
+ }
621
+ setReadOnly(nodes, readOnly) {
622
+ for (const node of nodes) {
623
+ node._readOnly = readOnly;
624
+ if (node.children?.length) this.setReadOnly(node.children, readOnly);
625
+ }
626
+ }
627
+ static collectSelectedLeafIds(nodes) {
628
+ const ids = [];
629
+ for (const node of nodes) if (node.children?.length) ids.push(...this.collectSelectedLeafIds(node.children));
630
+ else if (node._selected) ids.push(node.id);
631
+ return ids;
632
+ }
633
+ static ɵfac = i0.ɵɵngDeclareFactory({
634
+ minVersion: "12.0.0",
635
+ version: "22.2.4",
636
+ ngImport: i0,
637
+ type: TreeviewComponent,
638
+ deps: [],
639
+ target: i0.ɵɵFactoryTarget.Component
640
+ });
641
+ static ɵcmp = i0.ɵɵngDeclareComponent({
642
+ minVersion: "17.0.0",
643
+ version: "22.2.4",
644
+ type: TreeviewComponent,
645
+ isStandalone: false,
646
+ selector: "app-treeview",
647
+ inputs: { nodes: "nodes" },
648
+ providers: [{
649
+ provide: NG_VALUE_ACCESSOR,
650
+ useExisting: forwardRef(() => TreeviewComponent),
651
+ multi: true
652
+ }],
653
+ ngImport: i0,
654
+ template: "<ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: nodes }\">\n</ng-container>\n<ng-template #nodeTpl let-nodes>\n @for (node of nodes; track node) {\n <div class=\"ms-3\">\n @if(!node.children || node.children.length === 0){\n <div class=\"d-flex align-items-center gap-2\">\n <input id=\"{{node.id}}\" type=\"checkbox\" class=\"form-check-input m-0\" [checked]=\"node._selected\" [disabled]=\"node._readOnly\" (change)=\"onLeafToggle(node)\" />\n <label for=\"{{node.id}}\">{{ node.name }}</label>\n </div>\n }\n @else {\n {{ node.name }}\n <div>\n <ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: node.children }\">\n </ng-container>\n </div>\n }\n </div>\n}\n</ng-template>",
655
+ dependencies: [{
656
+ kind: "directive",
657
+ type: i1$2.NgTemplateOutlet,
658
+ selector: "[ngTemplateOutlet]",
659
+ inputs: [
660
+ "ngTemplateOutletContext",
661
+ "ngTemplateOutlet",
662
+ "ngTemplateOutletInjector"
663
+ ]
664
+ }],
665
+ changeDetection: i0.ChangeDetectionStrategy.Eager
666
+ });
667
+ };
668
+ i0.ɵɵngDeclareClassMetadata({
669
+ minVersion: "12.0.0",
670
+ version: "22.2.4",
671
+ ngImport: i0,
672
+ type: TreeviewComponent,
673
+ decorators: [{
674
+ type: Component,
675
+ args: [{
676
+ selector: "app-treeview",
677
+ standalone: false,
678
+ changeDetection: ChangeDetectionStrategy.Eager,
679
+ providers: [{
680
+ provide: NG_VALUE_ACCESSOR,
681
+ useExisting: forwardRef(() => TreeviewComponent),
682
+ multi: true
683
+ }],
684
+ template: "<ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: nodes }\">\n</ng-container>\n<ng-template #nodeTpl let-nodes>\n @for (node of nodes; track node) {\n <div class=\"ms-3\">\n @if(!node.children || node.children.length === 0){\n <div class=\"d-flex align-items-center gap-2\">\n <input id=\"{{node.id}}\" type=\"checkbox\" class=\"form-check-input m-0\" [checked]=\"node._selected\" [disabled]=\"node._readOnly\" (change)=\"onLeafToggle(node)\" />\n <label for=\"{{node.id}}\">{{ node.name }}</label>\n </div>\n }\n @else {\n {{ node.name }}\n <div>\n <ng-container *ngTemplateOutlet=\"nodeTpl; context: { $implicit: node.children }\">\n </ng-container>\n </div>\n }\n </div>\n}\n</ng-template>"
685
+ }]
686
+ }],
687
+ propDecorators: { nodes: [{ type: Input }] }
688
+ });
689
+ var TempUtils = class {
690
+ static euRegulation = 5;
691
+ static createQParams(qParams, mpp) {
692
+ const params = {
693
+ returnInputBBox: true,
694
+ cluster: true,
695
+ createPolygons: "WhenNeeded",
696
+ useCache: true,
697
+ maxGridCells: 1e3,
698
+ maxZoom: 19,
699
+ clusterRadiusPx: 20,
700
+ minLocationCountBeforeClustering: 0,
701
+ disablePixelClusteringAtMetersPerPixel: 2,
702
+ detailClusterRadiusPx: 10,
703
+ metersPerPixel: mpp,
704
+ adaptiveSearchStrategy: "Auto",
705
+ locationAggregationLimit: 1e3,
706
+ observationsLimit: 5e3,
707
+ includeFilterAreasInResult: true
708
+ };
709
+ if (qParams.cutoff) params.cutoffYear = qParams.cutoff;
710
+ if (qParams.bbox) params.bbox = qParams.bbox;
711
+ return params;
712
+ }
713
+ static createObservationsBody(queryParams) {
714
+ const params = queryParams;
715
+ const body = { geographics: {} };
716
+ const startDate = params.startAt ?? params.startDate;
717
+ const endDate = params.endAt ?? params.endDate;
718
+ if (startDate) body.date = {
719
+ startDate,
720
+ ...endDate && { endDate }
721
+ };
722
+ if (params.taxonId) body.taxon = {
723
+ Ids: [+params.taxonId],
724
+ includeUnderlyingTaxa: true
725
+ };
726
+ const taxonListIds = this.getTaxonListIds(params);
727
+ if (taxonListIds.length) {
728
+ body.taxon ??= {};
729
+ body.taxon.taxonListIds = taxonListIds;
730
+ body.taxon.taxonListOperator = "Filter";
731
+ }
732
+ if (params.area) body.geographics = { areas: (Array.isArray(params.area) ? params.area : [params.area]).map((area) => {
733
+ const [areaType, featureId] = area.split("-");
734
+ return {
735
+ areaType,
736
+ featureId
737
+ };
738
+ }) };
739
+ if (params.geo) body.geographics.geometries = [{
740
+ type: "Polygon",
741
+ coordinates: [JSON.parse(params.geo)]
742
+ }];
743
+ if (params.locationId) body.geographics.locationIds = Array.isArray(params.locationId) ? params.locationId : [params.locationId];
744
+ if (params.ds) body.dataProvider = { ids: this.toNumberArray(params.ds) };
745
+ return {
746
+ occurrenceStatus: params.noted === "true" ? "Present" : "BothPresentAndAbsent",
747
+ notRecoveredFilter: "NoFilter",
748
+ determinationFilter: "NotUnsureDetermination",
749
+ extendedFilter: {
750
+ notPresentFilter: "DontIncludeNotPresent",
751
+ ...params.activities && { activityIds: JSON.parse(params.activities).map(Number) }
752
+ },
753
+ ...body
754
+ };
755
+ }
756
+ static getTaxonListIds(params) {
757
+ return [
758
+ ...this.toNumberArray(params.rc),
759
+ ...this.toNumberArray(params.rlc),
760
+ ...this.toNumberArray(params.list),
761
+ ...params.eu ? [this.euRegulation] : []
762
+ ];
763
+ }
764
+ static toNumberArray(value) {
765
+ if (!value) return [];
766
+ return (Array.isArray(value) ? value : [value]).map(Number);
767
+ }
768
+ };
769
+ var MapFeaturePickerComponent = class MapFeaturePickerComponent {
770
+ locationOptions = input.required(...ngDevMode ? [{ debugName: "locationOptions" }] : /* istanbul ignore next */ []);
771
+ featureChosen = output();
772
+ dismissed = output();
773
+ position = signal({
774
+ left: 0,
775
+ top: 0
776
+ }, ...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
777
+ host = inject(ElementRef);
778
+ features = computed(() => {
779
+ const { features, extent } = this.locationOptions();
780
+ const hits = features.filter((feature) => !["FilterArea.Area", "FilterArea.OwnPolygon"].includes(feature.get("FeatureType")));
781
+ const point = hits.find((feature) => ["Point", "MultiPoint"].includes(feature.getGeometry().getType()));
782
+ return point ? [point] : hits.filter((feature) => !feature.get("locations") || this.hasVisibleEdge(feature, extent));
783
+ }, ...ngDevMode ? [{ debugName: "features" }] : /* istanbul ignore next */ []);
784
+ choices = computed(() => {
785
+ const choices = [];
786
+ const ids = /* @__PURE__ */ new Set();
787
+ for (const feature of this.features()) {
788
+ if (feature.get("groupingType") === "pixelCluster" || feature.get("isCluster")) continue;
789
+ for (const item of feature.get("locations")?.items ?? []) {
790
+ if (ids.has(item.locationId)) continue;
791
+ ids.add(item.locationId);
792
+ choices.push({
793
+ feature,
794
+ item
795
+ });
796
+ }
797
+ }
798
+ return choices;
799
+ }, ...ngDevMode ? [{ debugName: "choices" }] : /* istanbul ignore next */ []);
800
+ constructor() {
801
+ effect(() => {
802
+ const choices = this.choices();
803
+ if (choices.length > 1) return;
804
+ if (choices.length === 1) this.choose(choices[0], false);
805
+ else if (this.features().length) this.pick(this.features()[0]);
806
+ else this.dismissed.emit(false);
807
+ });
808
+ afterRenderEffect(() => {
809
+ if (this.choices().length < 2) return;
810
+ const { pixel } = this.locationOptions();
811
+ const host = this.host.nativeElement;
812
+ const panel = host.querySelector("section");
813
+ if (!panel) return;
814
+ this.position.set({
815
+ left: Math.max(0, Math.min(pixel[0], host.clientWidth - panel.offsetWidth)),
816
+ top: Math.max(0, Math.min(pixel[1], host.clientHeight - panel.offsetHeight))
817
+ });
818
+ panel.querySelector(".list-group-item-action")?.focus({ preventScroll: true });
819
+ });
820
+ }
821
+ choose(choice, restoreFocus = true) {
822
+ const properties = choice.feature.getProperties();
823
+ delete properties["geometry"];
824
+ properties["locations"] = {
825
+ ...properties["locations"],
826
+ count: 1,
827
+ ids: [choice.item.locationId],
828
+ items: [choice.item]
829
+ };
830
+ this.featureChosen.emit({
831
+ feature: choice.feature,
832
+ properties,
833
+ selectMode: this.locationOptions().selectMode,
834
+ restoreFocus
835
+ });
836
+ }
837
+ pick(feature) {
838
+ const properties = feature.getProperties();
839
+ delete properties["geometry"];
840
+ this.featureChosen.emit({
841
+ feature,
842
+ properties,
843
+ selectMode: this.locationOptions().selectMode,
844
+ restoreFocus: false
845
+ });
846
+ }
847
+ hasVisibleEdge(feature, extent) {
848
+ const geometry = feature.getGeometry();
849
+ const polygons = geometry instanceof MultiPolygon ? geometry.getPolygons() : geometry instanceof Polygon ? [geometry] : null;
850
+ if (!polygons) return true;
851
+ return polygons.some((polygon) => polygon.getLinearRings().some((ring) => new LineString(ring.getCoordinates()).intersectsExtent(extent)));
852
+ }
853
+ static ɵfac = i0.ɵɵngDeclareFactory({
854
+ minVersion: "12.0.0",
855
+ version: "22.2.4",
856
+ ngImport: i0,
857
+ type: MapFeaturePickerComponent,
858
+ deps: [],
859
+ target: i0.ɵɵFactoryTarget.Component
860
+ });
861
+ static ɵcmp = i0.ɵɵngDeclareComponent({
862
+ minVersion: "17.0.0",
863
+ version: "22.2.4",
864
+ type: MapFeaturePickerComponent,
865
+ isStandalone: false,
866
+ selector: "adb-map-feature-picker",
867
+ inputs: { locationOptions: {
868
+ classPropertyName: "locationOptions",
869
+ publicName: "locationOptions",
870
+ isSignal: true,
871
+ isRequired: true,
872
+ transformFunction: null
873
+ } },
874
+ outputs: {
875
+ featureChosen: "featureChosen",
876
+ dismissed: "dismissed"
877
+ },
878
+ host: { classAttribute: "adb-map-feature-picker" },
879
+ ngImport: i0,
880
+ template: "@if (choices().length > 1) {\n<section class=\"adb-plate-primary shadow adb-map-feature-picker-panel\" [style.left.px]=\"position().left\" [style.top.px]=\"position().top\" [attr.aria-label]=\"'MAP.FEATURE_PICKER.TITLE' | translate\"\n (adbClickOutside)=\"dismissed.emit(false)\"\n (keydown.escape)=\"$event.stopPropagation(); dismissed.emit(true)\">\n <div class=\"d-flex align-items-center justify-content-between gap-3 mb-2\">\n <h2 class=\"h6 mb-0\">{{'MAP.FEATURE_PICKER.TITLE' | translate}}</h2>\n <button type=\"button\" class=\"btn-close\" [attr.aria-label]=\"'MAP.FEATURE_PICKER.CLOSE' | translate\" (click)=\"dismissed.emit(true)\"></button>\n </div>\n <ul class=\"list-group list-group-flush\">\n @for (choice of choices(); track choice.item.locationId) {\n <li class=\"list-group-item p-0\">\n <button type=\"button\" class=\"list-group-item list-group-item-action border-0 text-break\" (click)=\"choose(choice)\">\n @if (choice.item.locality) {\n {{choice.item.locality}}\n @if (choice.item.municipality) {, {{choice.item.municipality}}}\n } @else if (choice.item.municipality) {\n {{choice.item.municipality}}\n }\n ({{choice.item.locationId}})\n </button>\n </li>\n }\n </ul>\n</section>\n}\n",
881
+ dependencies: [{
882
+ kind: "directive",
883
+ type: i1$1.ClickOutsideDirective,
884
+ selector: "[adbClickOutside]",
885
+ outputs: ["adbClickOutside"]
886
+ }, {
887
+ kind: "pipe",
888
+ type: i1$3.TranslatePipe,
889
+ name: "translate"
890
+ }],
891
+ changeDetection: i0.ChangeDetectionStrategy.Eager
892
+ });
893
+ };
894
+ i0.ɵɵngDeclareClassMetadata({
895
+ minVersion: "12.0.0",
896
+ version: "22.2.4",
897
+ ngImport: i0,
898
+ type: MapFeaturePickerComponent,
899
+ decorators: [{
900
+ type: Component,
901
+ args: [{
902
+ selector: "adb-map-feature-picker",
903
+ host: { class: "adb-map-feature-picker" },
904
+ changeDetection: ChangeDetectionStrategy.Eager,
905
+ standalone: false,
906
+ template: "@if (choices().length > 1) {\n<section class=\"adb-plate-primary shadow adb-map-feature-picker-panel\" [style.left.px]=\"position().left\" [style.top.px]=\"position().top\" [attr.aria-label]=\"'MAP.FEATURE_PICKER.TITLE' | translate\"\n (adbClickOutside)=\"dismissed.emit(false)\"\n (keydown.escape)=\"$event.stopPropagation(); dismissed.emit(true)\">\n <div class=\"d-flex align-items-center justify-content-between gap-3 mb-2\">\n <h2 class=\"h6 mb-0\">{{'MAP.FEATURE_PICKER.TITLE' | translate}}</h2>\n <button type=\"button\" class=\"btn-close\" [attr.aria-label]=\"'MAP.FEATURE_PICKER.CLOSE' | translate\" (click)=\"dismissed.emit(true)\"></button>\n </div>\n <ul class=\"list-group list-group-flush\">\n @for (choice of choices(); track choice.item.locationId) {\n <li class=\"list-group-item p-0\">\n <button type=\"button\" class=\"list-group-item list-group-item-action border-0 text-break\" (click)=\"choose(choice)\">\n @if (choice.item.locality) {\n {{choice.item.locality}}\n @if (choice.item.municipality) {, {{choice.item.municipality}}}\n } @else if (choice.item.municipality) {\n {{choice.item.municipality}}\n }\n ({{choice.item.locationId}})\n </button>\n </li>\n }\n </ul>\n</section>\n}\n"
907
+ }]
908
+ }],
909
+ ctorParameters: () => [],
910
+ propDecorators: {
911
+ locationOptions: [{
912
+ type: i0.Input,
913
+ args: [{
914
+ isSignal: true,
915
+ alias: "locationOptions",
916
+ required: true
917
+ }]
918
+ }],
919
+ featureChosen: [{
920
+ type: i0.Output,
921
+ args: ["featureChosen"]
922
+ }],
923
+ dismissed: [{
924
+ type: i0.Output,
925
+ args: ["dismissed"]
926
+ }]
927
+ }
928
+ });
929
+ var MapLegendComponent = class MapLegendComponent {
930
+ generalizedBackgroundColor = MapConstants.GENERALIZED_POLYGON_BACKGROUND_COLOR;
931
+ result = input(null, ...ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []);
932
+ cutoffYear = input(null, ...ngDevMode ? [{ debugName: "cutoffYear" }] : /* istanbul ignore next */ []);
933
+ loading = input(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
934
+ showObservationStatus = input(false, ...ngDevMode ? [{ debugName: "showObservationStatus" }] : /* istanbul ignore next */ []);
935
+ gridLevels = computed(() => AdbMapUtils.gridLevels(this.result()), ...ngDevMode ? [{ debugName: "gridLevels" }] : /* istanbul ignore next */ []);
936
+ features = computed(() => (this.result()?.features ?? []).filter((feature) => feature.properties?.FeatureType !== "FilterArea.Area"), ...ngDevMode ? [{ debugName: "features" }] : /* istanbul ignore next */ []);
937
+ hasNotRecovered = computed(() => this.showObservationStatus() && this.features().some((feature) => AdbMapUtils.isNotRecovered(feature.properties?.presentation)), ...ngDevMode ? [{ debugName: "hasNotRecovered" }] : /* istanbul ignore next */ []);
938
+ hasNotPresent = computed(() => this.showObservationStatus() && this.features().some((feature) => feature.properties?.presentation?.status === "NotPresent"), ...ngDevMode ? [{ debugName: "hasNotPresent" }] : /* istanbul ignore next */ []);
939
+ hasGeneralizedPolygons = computed(() => this.showObservationStatus() && this.features().some((feature) => feature.properties?.presentation?.generalized && ["Polygon", "MultiPolygon"].includes(feature.geometry?.type)), ...ngDevMode ? [{ debugName: "hasGeneralizedPolygons" }] : /* istanbul ignore next */ []);
940
+ hasCutoff = computed(() => this.cutoffYear() !== null && this.features().some((feature) => ["Until", "After"].includes(feature.properties?.presentation?.cutoffYearStatus)), ...ngDevMode ? [{ debugName: "hasCutoff" }] : /* istanbul ignore next */ []);
941
+ hasLocations = computed(() => this.features().some((feature) => feature.properties?.groupingType !== "pixelCluster" && !feature.properties?.isCluster && (feature.properties?.locations || feature.properties?.location || ["Point", "MultiPoint"].includes(feature.geometry?.type))), ...ngDevMode ? [{ debugName: "hasLocations" }] : /* istanbul ignore next */ []);
942
+ hasClusters = computed(() => this.features().some((feature) => feature.properties?.groupingType === "pixelCluster" || feature.properties?.isCluster), ...ngDevMode ? [{ debugName: "hasClusters" }] : /* istanbul ignore next */ []);
943
+ static ɵfac = i0.ɵɵngDeclareFactory({
944
+ minVersion: "12.0.0",
945
+ version: "22.2.4",
946
+ ngImport: i0,
947
+ type: MapLegendComponent,
948
+ deps: [],
949
+ target: i0.ɵɵFactoryTarget.Component
950
+ });
951
+ static ɵcmp = i0.ɵɵngDeclareComponent({
952
+ minVersion: "17.0.0",
953
+ version: "22.2.4",
954
+ type: MapLegendComponent,
955
+ isStandalone: false,
956
+ selector: "adb-map-legend",
957
+ inputs: {
958
+ result: {
959
+ classPropertyName: "result",
960
+ publicName: "result",
961
+ isSignal: true,
962
+ isRequired: false,
963
+ transformFunction: null
964
+ },
965
+ cutoffYear: {
966
+ classPropertyName: "cutoffYear",
967
+ publicName: "cutoffYear",
968
+ isSignal: true,
969
+ isRequired: false,
970
+ transformFunction: null
971
+ },
972
+ loading: {
973
+ classPropertyName: "loading",
974
+ publicName: "loading",
975
+ isSignal: true,
976
+ isRequired: false,
977
+ transformFunction: null
978
+ },
979
+ showObservationStatus: {
980
+ classPropertyName: "showObservationStatus",
981
+ publicName: "showObservationStatus",
982
+ isSignal: true,
983
+ isRequired: false,
984
+ transformFunction: null
985
+ }
986
+ },
987
+ ngImport: i0,
988
+ template: "<div class=\"bg-light border p-1 d-flex column-gap-1 align-items-center flex-wrap\">\n @if (hasLocations() || hasClusters()) {\n <div class=\"d-flex align-items-start gap-2 w-100\">\n <ul class=\"list-unstyled mb-0 d-flex flex-grow-1 flex-wrap column-gap-3 row-gap-1\">\n @if (hasCutoff()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-before\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.BEFORE' | translate}} {{cutoffYear()}}\n </li>\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-after\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.FROM' | translate}} {{cutoffYear()}}\n </li>\n } @else if (hasLocations()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle map-symbol-bg-5\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.LOCATION' | translate}}\n </li>\n }\n @if (hasClusters() && !hasCutoff()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-cluster\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.CLUSTER' | translate}}\n </li>\n }\n @if (hasNotRecovered()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle-x map-symbol-bg-5\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.NOT_RECOVERED' | translate}}\n </li>\n }\n @if (hasNotPresent()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle map-symbol-bg-5 d-inline-flex align-items-center justify-content-center\" aria-hidden=\"true\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" focusable=\"false\">\n <line x1=\"2\" y1=\"6\" x2=\"10\" y2=\"6\" stroke=\"currentColor\" stroke-width=\"1.5\" />\n </svg>\n </span>\n {{'MAP.LEGEND.NOT_PRESENT' | translate}}\n </li>\n }\n @if (hasGeneralizedPolygons()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend border border-2 border-danger\"\n [style.background-color]=\"generalizedBackgroundColor\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.GENERALIZED_LOCATION' | translate}}\n </li>\n }\n </ul>\n <adb-help-button class=\"ms-auto flex-shrink-0\">\n <dl>\n <dt>{{'MAP.LEGEND.LOCATION' | translate}}</dt>\n <dd>{{'MAP.LEGEND.LOCATION_HELP' | translate}}</dd>\n <dt>{{'MAP.LEGEND.CLUSTER' | translate}}</dt>\n <dd>{{'MAP.LEGEND.CLUSTER_HELP' | translate}}</dd>\n </dl>\n </adb-help-button>\n </div>\n @if (hasCutoff() && hasClusters()) {\n <small class=\"d-block w-100\">{{'MAP.LEGEND.CLUSTER_SIZE' | translate}}</small>\n }\n }\n @if (!loading()) {\n @for (level of gridLevels(); track $index) {\n <div class=\"d-flex align-items-center gap-1\">\n <span class=\"legend border border-dark\" [style.background-color]=\"level.color\" aria-hidden=\"true\"></span>\n <small>\n @if ($first) {\n &lt; {{level.max + 1 | adbSpacing}}\n } @else if ($last) {\n &gt; {{level.min - 1 | adbSpacing}}\n } @else {\n {{level.min | adbSpacing}}–{{level.max | adbSpacing}}\n }\n </small>\n </div>\n }\n }\n</div>\n",
989
+ dependencies: [
990
+ {
991
+ kind: "component",
992
+ type: i1$1.AdbHelpButtonComponent,
993
+ selector: "adb-help-button",
994
+ inputs: ["buttonClass", "label"]
995
+ },
996
+ {
997
+ kind: "pipe",
998
+ type: i1$1.NumberSpacingPipe,
999
+ name: "adbSpacing"
1000
+ },
1001
+ {
1002
+ kind: "pipe",
1003
+ type: i1$3.TranslatePipe,
1004
+ name: "translate"
1005
+ }
1006
+ ],
1007
+ changeDetection: i0.ChangeDetectionStrategy.Eager
1008
+ });
1009
+ };
1010
+ i0.ɵɵngDeclareClassMetadata({
1011
+ minVersion: "12.0.0",
1012
+ version: "22.2.4",
1013
+ ngImport: i0,
1014
+ type: MapLegendComponent,
1015
+ decorators: [{
1016
+ type: Component,
1017
+ args: [{
1018
+ selector: "adb-map-legend",
1019
+ changeDetection: ChangeDetectionStrategy.Eager,
1020
+ standalone: false,
1021
+ template: "<div class=\"bg-light border p-1 d-flex column-gap-1 align-items-center flex-wrap\">\n @if (hasLocations() || hasClusters()) {\n <div class=\"d-flex align-items-start gap-2 w-100\">\n <ul class=\"list-unstyled mb-0 d-flex flex-grow-1 flex-wrap column-gap-3 row-gap-1\">\n @if (hasCutoff()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-before\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.BEFORE' | translate}} {{cutoffYear()}}\n </li>\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-after\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.FROM' | translate}} {{cutoffYear()}}\n </li>\n } @else if (hasLocations()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle map-symbol-bg-5\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.LOCATION' | translate}}\n </li>\n }\n @if (hasClusters() && !hasCutoff()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend legend-cluster\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.CLUSTER' | translate}}\n </li>\n }\n @if (hasNotRecovered()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle-x map-symbol-bg-5\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.NOT_RECOVERED' | translate}}\n </li>\n }\n @if (hasNotPresent()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"map-symbol-circle map-symbol-bg-5 d-inline-flex align-items-center justify-content-center\" aria-hidden=\"true\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" focusable=\"false\">\n <line x1=\"2\" y1=\"6\" x2=\"10\" y2=\"6\" stroke=\"currentColor\" stroke-width=\"1.5\" />\n </svg>\n </span>\n {{'MAP.LEGEND.NOT_PRESENT' | translate}}\n </li>\n }\n @if (hasGeneralizedPolygons()) {\n <li class=\"d-flex align-items-center gap-1\">\n <span class=\"legend border border-2 border-danger\"\n [style.background-color]=\"generalizedBackgroundColor\" aria-hidden=\"true\"></span>\n {{'MAP.LEGEND.GENERALIZED_LOCATION' | translate}}\n </li>\n }\n </ul>\n <adb-help-button class=\"ms-auto flex-shrink-0\">\n <dl>\n <dt>{{'MAP.LEGEND.LOCATION' | translate}}</dt>\n <dd>{{'MAP.LEGEND.LOCATION_HELP' | translate}}</dd>\n <dt>{{'MAP.LEGEND.CLUSTER' | translate}}</dt>\n <dd>{{'MAP.LEGEND.CLUSTER_HELP' | translate}}</dd>\n </dl>\n </adb-help-button>\n </div>\n @if (hasCutoff() && hasClusters()) {\n <small class=\"d-block w-100\">{{'MAP.LEGEND.CLUSTER_SIZE' | translate}}</small>\n }\n }\n @if (!loading()) {\n @for (level of gridLevels(); track $index) {\n <div class=\"d-flex align-items-center gap-1\">\n <span class=\"legend border border-dark\" [style.background-color]=\"level.color\" aria-hidden=\"true\"></span>\n <small>\n @if ($first) {\n &lt; {{level.max + 1 | adbSpacing}}\n } @else if ($last) {\n &gt; {{level.min - 1 | adbSpacing}}\n } @else {\n {{level.min | adbSpacing}}–{{level.max | adbSpacing}}\n }\n </small>\n </div>\n }\n }\n</div>\n"
1022
+ }]
1023
+ }],
1024
+ propDecorators: {
1025
+ result: [{
1026
+ type: i0.Input,
1027
+ args: [{
1028
+ isSignal: true,
1029
+ alias: "result",
1030
+ required: false
1031
+ }]
1032
+ }],
1033
+ cutoffYear: [{
1034
+ type: i0.Input,
1035
+ args: [{
1036
+ isSignal: true,
1037
+ alias: "cutoffYear",
1038
+ required: false
1039
+ }]
1040
+ }],
1041
+ loading: [{
1042
+ type: i0.Input,
1043
+ args: [{
1044
+ isSignal: true,
1045
+ alias: "loading",
1046
+ required: false
1047
+ }]
1048
+ }],
1049
+ showObservationStatus: [{
1050
+ type: i0.Input,
1051
+ args: [{
1052
+ isSignal: true,
1053
+ alias: "showObservationStatus",
1054
+ required: false
1055
+ }]
1056
+ }]
1057
+ }
1058
+ });
1059
+ var AdbMapComponent = class AdbMapComponent {
1060
+ activatedRoute;
1061
+ config;
1062
+ router;
1063
+ http;
1064
+ showLegend = input(true, ...ngDevMode ? [{ debugName: "showLegend" }] : /* istanbul ignore next */ []);
1065
+ showHeader = input(true, ...ngDevMode ? [{ debugName: "showHeader" }] : /* istanbul ignore next */ []);
1066
+ allowPresentationMode = input(false, ...ngDevMode ? [{ debugName: "allowPresentationMode" }] : /* istanbul ignore next */ []);
1067
+ presentationMode = input("locations", ...ngDevMode ? [{ debugName: "presentationMode" }] : /* istanbul ignore next */ []);
1068
+ route = signal(null, ...ngDevMode ? [{ debugName: "route" }] : /* istanbul ignore next */ []);
1069
+ activePresentationMode = computed(() => {
1070
+ const mode = this.route()?.queryParams["presentationMode"];
1071
+ if (this.allowPresentationMode() && (mode === "locations" || mode === "observations")) return mode;
1072
+ return this.presentationMode();
1073
+ }, ...ngDevMode ? [{ debugName: "activePresentationMode" }] : /* istanbul ignore next */ []);
1074
+ requestedParams = "";
1075
+ settingsOpen = signal(false, ...ngDevMode ? [{ debugName: "settingsOpen" }] : /* istanbul ignore next */ []);
1076
+ savingSettings = signal(false, ...ngDevMode ? [{ debugName: "savingSettings" }] : /* istanbul ignore next */ []);
1077
+ settingsError = signal(false, ...ngDevMode ? [{ debugName: "settingsError" }] : /* istanbul ignore next */ []);
1078
+ settingsForm = new FormGroup({
1079
+ presentationMode: new FormControl("locations"),
1080
+ uncertain: new FormControl(false),
1081
+ cutoff: new FormControl("", Validators.pattern(/^[1-9]\d*$/))
1082
+ });
1083
+ preserveViewOnNextLoad = false;
1084
+ error;
1085
+ mapLoading = signal(false, ...ngDevMode ? [{ debugName: "mapLoading" }] : /* istanbul ignore next */ []);
1086
+ locationSelected = output();
1087
+ clusterSelected = output();
1088
+ siteSource = new VectorSource();
1089
+ uncertaintySource = new VectorSource();
1090
+ siteLayer = new VectorLayer({
1091
+ source: this.siteSource,
1092
+ style: (feature) => this.featureStyle(feature)
1093
+ });
1094
+ format = new GeoJSON();
1095
+ resizeObserver;
1096
+ requestSubscription;
1097
+ hoveredFeature;
1098
+ selectedFeature = null;
1099
+ locationOptions = signal(null, ...ngDevMode ? [{ debugName: "locationOptions" }] : /* istanbul ignore next */ []);
1100
+ fittedView = "";
1101
+ pendingExtent;
1102
+ mapResult = signal(null, ...ngDevMode ? [{ debugName: "mapResult" }] : /* istanbul ignore next */ []);
1103
+ cutoffYear = computed(() => this.activePresentationMode() === "observations" ? this.route()?.queryParams["cutoff"] ?? null : null, ...ngDevMode ? [{ debugName: "cutoffYear" }] : /* istanbul ignore next */ []);
1104
+ gridLevels = computed(() => AdbMapUtils.gridLevels(this.mapResult()), ...ngDevMode ? [{ debugName: "gridLevels" }] : /* istanbul ignore next */ []);
1105
+ mapId = "" + Math.floor(Math.random() * Date.now());
1106
+ map;
1107
+ mapReady = signal(false, ...ngDevMode ? [{ debugName: "mapReady" }] : /* istanbul ignore next */ []);
1108
+ queryParams = {};
1109
+ constructor(activatedRoute, config, router, http) {
1110
+ this.activatedRoute = activatedRoute;
1111
+ this.config = config;
1112
+ this.router = router;
1113
+ this.http = http;
1114
+ this.route.set(this.activatedRoute.snapshot);
1115
+ this.settingsForm.controls.presentationMode.valueChanges.pipe(takeUntilDestroyed()).subscribe((mode) => {
1116
+ const cutoff = this.settingsForm.controls.cutoff;
1117
+ if (this.allowPresentationMode() && mode === "observations") cutoff.enable();
1118
+ else cutoff.disable();
1119
+ });
1120
+ this.router.events.pipe(takeUntilDestroyed()).subscribe((event) => {
1121
+ if (event instanceof NavigationEnd) this.route.set(this.activatedRoute.snapshot);
1122
+ });
1123
+ effect(() => {
1124
+ if (!this.mapReady()) return;
1125
+ const snapshot = this.route();
1126
+ this.queryParams = snapshot.queryParams;
1127
+ this.siteLayer.changed();
1128
+ const params = { ...snapshot.queryParams };
1129
+ delete params["presentationMode"];
1130
+ if (this.activePresentationMode() === "locations") delete params["cutoff"];
1131
+ if (snapshot.paramMap.has("taxonId")) params["taxonId"] = snapshot.paramMap.get("taxonId");
1132
+ const requestKey = JSON.stringify(params);
1133
+ if (requestKey === this.requestedParams) {
1134
+ this.preserveViewOnNextLoad = false;
1135
+ return;
1136
+ }
1137
+ this.requestedParams = requestKey;
1138
+ this.loadFeature(params);
1139
+ });
1140
+ }
1141
+ ngAfterViewInit() {
1142
+ this.map = AdbMapUtils.createMap(this.mapId, {
1143
+ zoom: true,
1144
+ scrollZoom: false,
1145
+ providers: true
1146
+ });
1147
+ this.map.addLayer(new VectorLayer({
1148
+ source: this.uncertaintySource,
1149
+ style: new Style({ stroke: new Stroke({
1150
+ color: MapConstants.UNCERTAINTY_BORDER_COLOR,
1151
+ width: 1
1152
+ }) })
1153
+ }));
1154
+ this.map.addLayer(this.siteLayer);
1155
+ this.resizeObserver = new ResizeObserver(() => {
1156
+ this.closeLocationPicker(false);
1157
+ this.map.updateSize();
1158
+ const size = this.map.getSize();
1159
+ if (size?.[0] && size[1]) this.mapReady.set(true);
1160
+ this.fitPendingExtent();
1161
+ });
1162
+ this.resizeObserver.observe(this.map.getTargetElement());
1163
+ this.fittedView = this.viewKey();
1164
+ const size = this.map.getSize();
1165
+ if (size?.[0] && size[1]) this.mapReady.set(true);
1166
+ this.attachUserListeners();
1167
+ }
1168
+ openSettings() {
1169
+ this.settingsForm.reset({
1170
+ presentationMode: this.activePresentationMode(),
1171
+ uncertain: this.queryParams["uncertain"] === "true",
1172
+ cutoff: {
1173
+ value: this.queryParams["cutoff"] ?? "",
1174
+ disabled: !this.allowPresentationMode() || this.activePresentationMode() !== "observations"
1175
+ }
1176
+ });
1177
+ this.settingsError.set(false);
1178
+ this.closeLocationPicker(false);
1179
+ this.settingsOpen.set(true);
1180
+ }
1181
+ cancelSettings(button) {
1182
+ this.settingsForm.reset();
1183
+ this.settingsOpen.set(false);
1184
+ button.focus({ preventScroll: true });
1185
+ }
1186
+ async saveSettings(button) {
1187
+ if (this.settingsForm.invalid || this.savingSettings()) return;
1188
+ this.savingSettings.set(true);
1189
+ this.settingsError.set(false);
1190
+ this.preserveViewOnNextLoad = true;
1191
+ try {
1192
+ if (await this.router.navigate([], {
1193
+ relativeTo: this.activatedRoute,
1194
+ queryParams: {
1195
+ uncertain: this.settingsForm.value.uncertain || null,
1196
+ presentationMode: this.allowPresentationMode() ? this.settingsForm.value.presentationMode : null,
1197
+ cutoff: this.allowPresentationMode() ? this.settingsForm.value.cutoff || null : null
1198
+ },
1199
+ queryParamsHandling: "merge"
1200
+ })) this.cancelSettings(button);
1201
+ else this.settingsError.set(true);
1202
+ } catch {
1203
+ this.settingsError.set(true);
1204
+ } finally {
1205
+ if (this.settingsError()) this.preserveViewOnNextLoad = false;
1206
+ this.savingSettings.set(false);
1207
+ }
1208
+ }
1209
+ onExport() {
1210
+ const json = this.format.writeFeatures(this.siteSource.getFeatures(), {
1211
+ featureProjection: this.map.getView().getProjection(),
1212
+ dataProjection: "EPSG:4326"
1213
+ });
1214
+ AdbMapUtils.createFile(new Blob([json], { type: "application/geo+json" }), "sites.geojson");
1215
+ }
1216
+ attachUserListeners() {
1217
+ this.map.on("moveend", () => {
1218
+ this.closeLocationPicker(false);
1219
+ if (this.viewKey() === this.fittedView) return;
1220
+ if (this.config.dynamic) {
1221
+ const bbox = this.currentBbox();
1222
+ if (bbox !== this.queryParams?.["bbox"]) this.router.navigate([], {
1223
+ relativeTo: this.activatedRoute,
1224
+ queryParams: { bbox },
1225
+ queryParamsHandling: "merge"
1226
+ });
1227
+ }
1228
+ });
1229
+ this.map.on("pointermove", (event) => {
1230
+ const feature = this.config.dynamic ? this.map.forEachFeatureAtPixel(event.pixel, (feature) => ["FilterArea.Area", "FilterArea.OwnPolygon"].includes(feature.get("FeatureType")) ? null : feature, { layerFilter: (layer) => layer === this.siteLayer }) : void 0;
1231
+ this.map.getTargetElement().style.cursor = feature ? "pointer" : "";
1232
+ if (this.hoveredFeature !== feature) {
1233
+ this.hoveredFeature = feature;
1234
+ this.siteLayer.changed();
1235
+ }
1236
+ });
1237
+ this.map.on("singleclick", (event) => {
1238
+ if (!this.config.dynamic) return;
1239
+ this.locationOptions.set({
1240
+ features: this.map.getFeaturesAtPixel(event.pixel, { layerFilter: (layer) => layer === this.siteLayer }),
1241
+ pixel: event.pixel,
1242
+ extent: this.map.getView().calculateExtent(this.map.getSize()),
1243
+ selectMode: this.config.enableClusterSelection && (event.originalEvent.ctrlKey || event.originalEvent.metaKey)
1244
+ });
1245
+ });
1246
+ }
1247
+ closeLocationPicker(restoreFocus = true) {
1248
+ this.locationOptions.set(null);
1249
+ this.hoveredFeature = null;
1250
+ this.siteLayer.changed();
1251
+ if (restoreFocus) this.map.getTargetElement().focus({ preventScroll: true });
1252
+ }
1253
+ onFeatureChosen(selection) {
1254
+ this.closeLocationPicker(selection.restoreFocus);
1255
+ const { feature, properties: props } = selection;
1256
+ const cluster = props["groupingType"] === "pixelCluster" || props["isCluster"];
1257
+ const location = !cluster && !!(props["location"] || props["observationCount"]);
1258
+ if ((cluster || location) && this.config.enableClusterSelection && selection.selectMode) {
1259
+ this.selectedFeature = feature;
1260
+ this.siteLayer.changed();
1261
+ delete props["geometry"];
1262
+ if (cluster) this.clusterSelected.emit(props);
1263
+ else this.locationSelected.emit(props);
1264
+ return;
1265
+ }
1266
+ if (location) {
1267
+ delete props["geometry"];
1268
+ this.locationSelected.emit(props);
1269
+ } else if (cluster || props["ObservationsCount"] > 0) {
1270
+ let extent = feature.getGeometry().getExtent();
1271
+ if (cluster) {
1272
+ const projectedCenter = getCenter(extent);
1273
+ const center = toLonLat(projectedCenter);
1274
+ const radius = props["cluster"].radiusMeters;
1275
+ extent = new CircleGeometry(projectedCenter, radius / Math.cos(center[1] * Math.PI / 180)).getExtent();
1276
+ const view = this.map.getView();
1277
+ const size = this.map.getSize();
1278
+ const fitSize = [size[0] - 40, size[1] - 40];
1279
+ if (view.getResolutionForExtent(extent, fitSize) >= view.getResolution()) extent = getForViewAndSize(projectedCenter, view.getResolution() / 2, 0, fitSize);
1280
+ }
1281
+ const bbox = transformExtent(extent, this.map.getView().getProjection(), "EPSG:4326").join(",");
1282
+ this.router.navigate([], {
1283
+ relativeTo: this.activatedRoute,
1284
+ queryParams: { bbox },
1285
+ queryParamsHandling: "merge"
1286
+ });
1287
+ }
1288
+ }
1289
+ currentBbox() {
1290
+ return transformExtent(this.map.getView().calculateExtent(this.map.getSize()), this.map.getView().getProjection(), "EPSG:4326").join(",");
1291
+ }
1292
+ loadFeature(qParams) {
1293
+ this.requestSubscription?.unsubscribe();
1294
+ this.mapLoading.set(true);
1295
+ this.error = null;
1296
+ const fitView = !this.preserveViewOnNextLoad && (!qParams["bbox"] || qParams["bbox"] !== this.currentBbox());
1297
+ this.preserveViewOnNextLoad = false;
1298
+ const requestedView = this.viewKey();
1299
+ const body = TempUtils.createObservationsBody(qParams);
1300
+ const allowedIds = this.config.dataProviderIds;
1301
+ if (allowedIds?.length) body.dataProvider = { ids: [...allowedIds] };
1302
+ qParams = TempUtils.createQParams(qParams, this.getMetersPerPixel(qParams));
1303
+ if (this.config.gridOnly) {
1304
+ qParams["adaptiveSearchStrategy"] = "ObservationsThenGrid";
1305
+ qParams["observationsLimit"] = 0;
1306
+ qParams["cluster"] = false;
1307
+ }
1308
+ const url = this.config.observationFeatures;
1309
+ this.requestSubscription = this.http.request("POST", url, {
1310
+ observe: "response",
1311
+ body,
1312
+ params: qParams
1313
+ }).pipe(finalize(() => {
1314
+ this.mapLoading.set(false);
1315
+ })).subscribe({
1316
+ next: (response) => {
1317
+ if (!response.body) throw new Error("No GeoJson body");
1318
+ const geo = response.body;
1319
+ geo.properties = {
1320
+ ...geo.properties,
1321
+ count: response.headers.get("X-Observations-TotalCount") ?? geo.properties?.count
1322
+ };
1323
+ this.buildMap(geo, fitView && requestedView === this.viewKey());
1324
+ },
1325
+ error: (err) => {
1326
+ this.requestedParams = "";
1327
+ this.error = err;
1328
+ }
1329
+ });
1330
+ }
1331
+ getMetersPerPixel(qParams) {
1332
+ return qParams.bbox ? AdbMapUtils.getMetersPerPixel(qParams.bbox, this.map.getSize()?.[0]) : MapConstants.INITIAL_METERS_PER_PIXEL;
1333
+ }
1334
+ buildMap(geojson, fitView) {
1335
+ this.mapResult.set(geojson);
1336
+ const features = this.format.readFeatures(geojson, { featureProjection: this.map.getView().getProjection() });
1337
+ this.closeLocationPicker(false);
1338
+ this.selectedFeature = null;
1339
+ this.siteSource.clear();
1340
+ this.uncertaintySource.clear();
1341
+ this.siteSource.addFeatures(features);
1342
+ if (this.queryParams?.["uncertain"] === "true") for (const feature of features) {
1343
+ const props = feature.getProperties();
1344
+ if (props["groupingType"] !== "singleLocation") continue;
1345
+ const location = props["locations"]?.items?.[0];
1346
+ const radius = location?.coordinateUncertaintyInMeters;
1347
+ const geometry = feature.getGeometry();
1348
+ if (geometry.getType() === "Point" && location?.type === "Point" && radius > 0) {
1349
+ const center = geometry.getExtent().slice(0, 2);
1350
+ this.uncertaintySource.addFeature(new Feature(AdbMapUtils.createUncertaintyCircle(center, radius)));
1351
+ }
1352
+ }
1353
+ this.pendingExtent = void 0;
1354
+ if (!fitView) return;
1355
+ const extent = geojson.bbox ? transformExtent(geojson.bbox, "EPSG:4326", this.map.getView().getProjection()) : extend(this.siteSource.getExtent(), this.uncertaintySource.getExtent());
1356
+ if (!isEmpty(extent)) {
1357
+ this.pendingExtent = extent;
1358
+ this.fitPendingExtent();
1359
+ }
1360
+ }
1361
+ viewKey() {
1362
+ return [...this.map.getView().getCenter(), this.map.getView().getResolution()].join(",");
1363
+ }
1364
+ fitPendingExtent() {
1365
+ const size = this.map.getSize();
1366
+ if (!this.pendingExtent || !size?.[0] || !size[1]) return;
1367
+ this.map.getView().fit(this.pendingExtent, {
1368
+ padding: [
1369
+ 20,
1370
+ 20,
1371
+ 20,
1372
+ 20
1373
+ ],
1374
+ maxZoom: 18
1375
+ });
1376
+ this.fittedView = this.viewKey();
1377
+ this.pendingExtent = void 0;
1378
+ }
1379
+ featureStyle(feature) {
1380
+ const props = feature.getProperties();
1381
+ if (["FilterArea.Area", "FilterArea.OwnPolygon"].includes(props["FeatureType"])) return new Style({
1382
+ stroke: new Stroke({
1383
+ color: MapConstants.SEARCH_AREA_BORDER_COLOR,
1384
+ width: 2
1385
+ }),
1386
+ fill: new Fill({ color: "transparent" })
1387
+ });
1388
+ const cluster = props["groupingType"] === "pixelCluster" || props["isCluster"];
1389
+ const location = props["locations"] || props["location"];
1390
+ const point = ["Point", "MultiPoint"].includes(feature.getGeometry()?.getType());
1391
+ if (cluster || location || point) return this.activePresentationMode() === "observations" ? this.aggregatedSymbol(feature) : this.locationSymbol(feature);
1392
+ if (props["FeatureId"]) return new Style({
1393
+ stroke: new Stroke({
1394
+ color: "#005e67",
1395
+ width: 2
1396
+ }),
1397
+ fill: new Fill({ color: "rgba(0,118,129,0.1)" })
1398
+ });
1399
+ const color = this.gridLevels().find((level) => props["ObservationsCount"] <= level.max)?.color ?? "#2FB3BB";
1400
+ return new Style({
1401
+ stroke: new Stroke({
1402
+ color: "#212529",
1403
+ width: 1
1404
+ }),
1405
+ fill: new Fill({ color })
1406
+ });
1407
+ }
1408
+ locationSymbol(feature) {
1409
+ return AdbMapUtils.locationSymbol(feature, feature === this.selectedFeature, feature === this.hoveredFeature);
1410
+ }
1411
+ aggregatedSymbol(feature) {
1412
+ return AdbMapUtils.aggregatedSymbol(this.locationSymbol(feature), feature.get("presentation"), this.cutoffYear(), feature === this.selectedFeature, feature.getGeometry()?.getType());
1413
+ }
1414
+ ngOnDestroy() {
1415
+ this.requestSubscription?.unsubscribe();
1416
+ this.resizeObserver?.disconnect();
1417
+ this.map?.dispose();
1418
+ }
1419
+ static ɵfac = i0.ɵɵngDeclareFactory({
1420
+ minVersion: "12.0.0",
1421
+ version: "22.2.4",
1422
+ ngImport: i0,
1423
+ type: AdbMapComponent,
1424
+ deps: [
1425
+ { token: i1.ActivatedRoute },
1426
+ { token: AdbMapConfigService },
1427
+ { token: i1.Router },
1428
+ { token: i3.HttpClient }
1429
+ ],
1430
+ target: i0.ɵɵFactoryTarget.Component
1431
+ });
1432
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1433
+ minVersion: "17.0.0",
1434
+ version: "22.2.4",
1435
+ type: AdbMapComponent,
1436
+ isStandalone: false,
1437
+ selector: "adb-map",
1438
+ inputs: {
1439
+ showLegend: {
1440
+ classPropertyName: "showLegend",
1441
+ publicName: "showLegend",
1442
+ isSignal: true,
1443
+ isRequired: false,
1444
+ transformFunction: null
1445
+ },
1446
+ showHeader: {
1447
+ classPropertyName: "showHeader",
1448
+ publicName: "showHeader",
1449
+ isSignal: true,
1450
+ isRequired: false,
1451
+ transformFunction: null
1452
+ },
1453
+ allowPresentationMode: {
1454
+ classPropertyName: "allowPresentationMode",
1455
+ publicName: "allowPresentationMode",
1456
+ isSignal: true,
1457
+ isRequired: false,
1458
+ transformFunction: null
1459
+ },
1460
+ presentationMode: {
1461
+ classPropertyName: "presentationMode",
1462
+ publicName: "presentationMode",
1463
+ isSignal: true,
1464
+ isRequired: false,
1465
+ transformFunction: null
1466
+ }
1467
+ },
1468
+ outputs: {
1469
+ locationSelected: "locationSelected",
1470
+ clusterSelected: "clusterSelected"
1471
+ },
1472
+ ngImport: i0,
1473
+ template: "@if(error){\n<div class=\"d-flex align-items-baseline gap-2 p-2 mb-3\" role=\"alert\">\n <span class=\"bi bi-circle-fill text-danger\" aria-hidden=\"true\"></span>\n <span>{{'ERROR.SERVER_ERROR'|translate}}</span>\n</div>\n}\n<div [class.loading]=\"mapLoading()\">\n <div class=\"d-flex align-items-center justify-content-end flex-wrap gap-1 border p-1\" [class.d-none]=\"!showHeader()\">\n @if (!mapLoading() && mapResult()?.properties?.count != null) {\n <span class=\"me-auto\">{{mapResult().properties.count | adbSpacing}} {{'MAP.OBSERVATIONS' | translate}}</span>\n }\n <button type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.FULLSCREEN' | translate\" [title]=\"'MAP.FULLSCREEN' | translate\" [disabled]=\"settingsOpen()\">\n <span class=\"bi bi-fullscreen\" aria-hidden=\"true\"></span>\n </button>\n <button type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.EXPORT' | translate\" [title]=\"'MAP.EXPORT' | translate\" [disabled]=\"settingsOpen()\" (click)=\"onExport()\">\n <span class=\"bi bi-download\" aria-hidden=\"true\"></span>\n </button>\n <button #settingsButton type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.SETTINGS.TITLE' | translate\"\n [title]=\"'MAP.SETTINGS.TITLE' | translate\" [attr.aria-expanded]=\"settingsOpen()\" [attr.aria-controls]=\"mapId + '-settings'\"\n (click)=\"settingsOpen() ? cancelSettings(settingsButton) : openSettings()\">\n <span class=\"bi bi-gear\" aria-hidden=\"true\"></span>\n </button>\n </div>\n <div class=\"position-relative\">\n <div [id]=\"mapId\" tabindex=\"0\" class=\"border-start border-end adb-map\" [class.invisible]=\"settingsOpen()\" [attr.inert]=\"settingsOpen() ? '' : null\"></div>\n @if (locationOptions(); as options) {\n <adb-map-feature-picker [locationOptions]=\"options\" (featureChosen)=\"onFeatureChosen($event)\" (dismissed)=\"closeLocationPicker($event)\" />\n }\n @if (settingsOpen()) {\n <form [id]=\"mapId + '-settings'\" [formGroup]=\"settingsForm\" (ngSubmit)=\"saveSettings(settingsButton)\"\n class=\"form p-3 position-absolute top-0 start-0 w-100 h-100 overflow-auto m-0\"\n [class.loading]=\"savingSettings()\" [attr.aria-labelledby]=\"mapId + '-settings-title'\" [attr.aria-busy]=\"savingSettings()\"\n (keydown.escape)=\"cancelSettings(settingsButton); $event.stopPropagation()\">\n <h2 [id]=\"mapId + '-settings-title'\" class=\"h5\">{{'MAP.SETTINGS.TITLE' | translate}}</h2>\n <div class=\"form-check mb-3\">\n <input [id]=\"mapId + '-uncertain'\" type=\"checkbox\" formControlName=\"uncertain\" class=\"form-check-input\">\n <label [for]=\"mapId + '-uncertain'\" class=\"form-check-label\">{{'MAP.SETTINGS.UNCERTAINTY' | translate}}</label>\n </div>\n @if (allowPresentationMode()) {\n <div class=\"mb-3\">\n <label [for]=\"mapId + '-presentation-mode'\">{{'MAP.SETTINGS.PRESENTATION_MODE' | translate}}</label>\n <select [id]=\"mapId + '-presentation-mode'\" formControlName=\"presentationMode\" class=\"form-select\">\n <option value=\"locations\">{{'MAP.SETTINGS.LOCATIONS_MODE' | translate}}</option>\n <option value=\"observations\">{{'MAP.SETTINGS.OBSERVATIONS_MODE' | translate}}</option>\n </select>\n </div>\n @if (settingsForm.controls.presentationMode.value === 'observations') {\n <div class=\"mb-3\">\n <label [for]=\"mapId + '-cutoff'\">{{'MAP.SETTINGS.CUTOFF' | translate}}</label>\n <input [id]=\"mapId + '-cutoff'\" type=\"text\" inputmode=\"numeric\" formControlName=\"cutoff\" class=\"form-control\"\n [attr.aria-invalid]=\"settingsForm.controls.cutoff.invalid\" [attr.aria-describedby]=\"mapId + '-cutoff-error'\">\n @if (settingsForm.controls.cutoff.invalid) {\n <div [id]=\"mapId + '-cutoff-error'\" class=\"invalid-feedback\">{{'MAP.SETTINGS.INVALID_CUTOFF' | translate}}</div>\n }\n </div>\n }\n }\n @if (settingsError()) {\n <div class=\"d-flex align-items-baseline gap-2 p-2 mb-3\" role=\"alert\">\n <span class=\"bi bi-circle-fill text-danger\" aria-hidden=\"true\"></span>\n <span>{{'MAP.SETTINGS.SAVE_ERROR' | translate}}</span>\n </div>\n }\n <div class=\"d-flex justify-content-end gap-2\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"cancelSettings(settingsButton)\">{{'MAP.SETTINGS.CANCEL' | translate}}</button>\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"settingsForm.invalid || settingsForm.pristine\">{{'MAP.SETTINGS.SAVE' | translate}}</button>\n </div>\n </form>\n }\n </div>\n</div>\n@if (showLegend() && !settingsOpen()) {\n <adb-map-legend [result]=\"mapResult()\" [cutoffYear]=\"cutoffYear()\" [loading]=\"mapLoading()\"\n [showObservationStatus]=\"activePresentationMode() === 'observations'\" />\n}\n",
1474
+ dependencies: [
1475
+ {
1476
+ kind: "directive",
1477
+ type: i4.ɵNgNoValidate,
1478
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
1479
+ },
1480
+ {
1481
+ kind: "directive",
1482
+ type: i4.NgSelectOption,
1483
+ selector: "option",
1484
+ inputs: ["ngValue", "value"]
1485
+ },
1486
+ {
1487
+ kind: "directive",
1488
+ type: i4.ɵNgSelectMultipleOption,
1489
+ selector: "option",
1490
+ inputs: ["ngValue", "value"]
1491
+ },
1492
+ {
1493
+ kind: "directive",
1494
+ type: i4.DefaultValueAccessor,
1495
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
1496
+ },
1497
+ {
1498
+ kind: "directive",
1499
+ type: i4.CheckboxControlValueAccessor,
1500
+ selector: "input[type=checkbox]:not([ngNoCva])[formControlName],input[type=checkbox]:not([ngNoCva])[formControl],input[type=checkbox]:not([ngNoCva])[ngModel]"
1501
+ },
1502
+ {
1503
+ kind: "directive",
1504
+ type: i4.SelectControlValueAccessor,
1505
+ selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]",
1506
+ inputs: ["compareWith"]
1507
+ },
1508
+ {
1509
+ kind: "directive",
1510
+ type: i4.NgControlStatus,
1511
+ selector: "[formControlName],[ngModel],[formControl]"
1512
+ },
1513
+ {
1514
+ kind: "directive",
1515
+ type: i4.NgControlStatusGroup,
1516
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
1517
+ },
1518
+ {
1519
+ kind: "directive",
1520
+ type: i4.FormGroupDirective,
1521
+ selector: "[formGroup]",
1522
+ inputs: ["formGroup"],
1523
+ outputs: ["ngSubmit"],
1524
+ exportAs: ["ngForm"]
1525
+ },
1526
+ {
1527
+ kind: "directive",
1528
+ type: i4.FormControlName,
1529
+ selector: "[formControlName]",
1530
+ inputs: [
1531
+ "formControlName",
1532
+ "disabled",
1533
+ "ngModel"
1534
+ ],
1535
+ outputs: ["ngModelChange"]
1536
+ },
1537
+ {
1538
+ kind: "component",
1539
+ type: MapFeaturePickerComponent,
1540
+ selector: "adb-map-feature-picker",
1541
+ inputs: ["locationOptions"],
1542
+ outputs: ["featureChosen", "dismissed"]
1543
+ },
1544
+ {
1545
+ kind: "component",
1546
+ type: MapLegendComponent,
1547
+ selector: "adb-map-legend",
1548
+ inputs: [
1549
+ "result",
1550
+ "cutoffYear",
1551
+ "loading",
1552
+ "showObservationStatus"
1553
+ ]
1554
+ },
1555
+ {
1556
+ kind: "pipe",
1557
+ type: i1$1.NumberSpacingPipe,
1558
+ name: "adbSpacing"
1559
+ },
1560
+ {
1561
+ kind: "pipe",
1562
+ type: i1$3.TranslatePipe,
1563
+ name: "translate"
1564
+ }
1565
+ ],
1566
+ changeDetection: i0.ChangeDetectionStrategy.Eager
1567
+ });
1568
+ };
1569
+ i0.ɵɵngDeclareClassMetadata({
1570
+ minVersion: "12.0.0",
1571
+ version: "22.2.4",
1572
+ ngImport: i0,
1573
+ type: AdbMapComponent,
1574
+ decorators: [{
1575
+ type: Component,
1576
+ args: [{
1577
+ selector: "adb-map",
1578
+ changeDetection: ChangeDetectionStrategy.Eager,
1579
+ standalone: false,
1580
+ template: "@if(error){\n<div class=\"d-flex align-items-baseline gap-2 p-2 mb-3\" role=\"alert\">\n <span class=\"bi bi-circle-fill text-danger\" aria-hidden=\"true\"></span>\n <span>{{'ERROR.SERVER_ERROR'|translate}}</span>\n</div>\n}\n<div [class.loading]=\"mapLoading()\">\n <div class=\"d-flex align-items-center justify-content-end flex-wrap gap-1 border p-1\" [class.d-none]=\"!showHeader()\">\n @if (!mapLoading() && mapResult()?.properties?.count != null) {\n <span class=\"me-auto\">{{mapResult().properties.count | adbSpacing}} {{'MAP.OBSERVATIONS' | translate}}</span>\n }\n <button type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.FULLSCREEN' | translate\" [title]=\"'MAP.FULLSCREEN' | translate\" [disabled]=\"settingsOpen()\">\n <span class=\"bi bi-fullscreen\" aria-hidden=\"true\"></span>\n </button>\n <button type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.EXPORT' | translate\" [title]=\"'MAP.EXPORT' | translate\" [disabled]=\"settingsOpen()\" (click)=\"onExport()\">\n <span class=\"bi bi-download\" aria-hidden=\"true\"></span>\n </button>\n <button #settingsButton type=\"button\" class=\"btn btn-sm btn-secondary\" [attr.aria-label]=\"'MAP.SETTINGS.TITLE' | translate\"\n [title]=\"'MAP.SETTINGS.TITLE' | translate\" [attr.aria-expanded]=\"settingsOpen()\" [attr.aria-controls]=\"mapId + '-settings'\"\n (click)=\"settingsOpen() ? cancelSettings(settingsButton) : openSettings()\">\n <span class=\"bi bi-gear\" aria-hidden=\"true\"></span>\n </button>\n </div>\n <div class=\"position-relative\">\n <div [id]=\"mapId\" tabindex=\"0\" class=\"border-start border-end adb-map\" [class.invisible]=\"settingsOpen()\" [attr.inert]=\"settingsOpen() ? '' : null\"></div>\n @if (locationOptions(); as options) {\n <adb-map-feature-picker [locationOptions]=\"options\" (featureChosen)=\"onFeatureChosen($event)\" (dismissed)=\"closeLocationPicker($event)\" />\n }\n @if (settingsOpen()) {\n <form [id]=\"mapId + '-settings'\" [formGroup]=\"settingsForm\" (ngSubmit)=\"saveSettings(settingsButton)\"\n class=\"form p-3 position-absolute top-0 start-0 w-100 h-100 overflow-auto m-0\"\n [class.loading]=\"savingSettings()\" [attr.aria-labelledby]=\"mapId + '-settings-title'\" [attr.aria-busy]=\"savingSettings()\"\n (keydown.escape)=\"cancelSettings(settingsButton); $event.stopPropagation()\">\n <h2 [id]=\"mapId + '-settings-title'\" class=\"h5\">{{'MAP.SETTINGS.TITLE' | translate}}</h2>\n <div class=\"form-check mb-3\">\n <input [id]=\"mapId + '-uncertain'\" type=\"checkbox\" formControlName=\"uncertain\" class=\"form-check-input\">\n <label [for]=\"mapId + '-uncertain'\" class=\"form-check-label\">{{'MAP.SETTINGS.UNCERTAINTY' | translate}}</label>\n </div>\n @if (allowPresentationMode()) {\n <div class=\"mb-3\">\n <label [for]=\"mapId + '-presentation-mode'\">{{'MAP.SETTINGS.PRESENTATION_MODE' | translate}}</label>\n <select [id]=\"mapId + '-presentation-mode'\" formControlName=\"presentationMode\" class=\"form-select\">\n <option value=\"locations\">{{'MAP.SETTINGS.LOCATIONS_MODE' | translate}}</option>\n <option value=\"observations\">{{'MAP.SETTINGS.OBSERVATIONS_MODE' | translate}}</option>\n </select>\n </div>\n @if (settingsForm.controls.presentationMode.value === 'observations') {\n <div class=\"mb-3\">\n <label [for]=\"mapId + '-cutoff'\">{{'MAP.SETTINGS.CUTOFF' | translate}}</label>\n <input [id]=\"mapId + '-cutoff'\" type=\"text\" inputmode=\"numeric\" formControlName=\"cutoff\" class=\"form-control\"\n [attr.aria-invalid]=\"settingsForm.controls.cutoff.invalid\" [attr.aria-describedby]=\"mapId + '-cutoff-error'\">\n @if (settingsForm.controls.cutoff.invalid) {\n <div [id]=\"mapId + '-cutoff-error'\" class=\"invalid-feedback\">{{'MAP.SETTINGS.INVALID_CUTOFF' | translate}}</div>\n }\n </div>\n }\n }\n @if (settingsError()) {\n <div class=\"d-flex align-items-baseline gap-2 p-2 mb-3\" role=\"alert\">\n <span class=\"bi bi-circle-fill text-danger\" aria-hidden=\"true\"></span>\n <span>{{'MAP.SETTINGS.SAVE_ERROR' | translate}}</span>\n </div>\n }\n <div class=\"d-flex justify-content-end gap-2\">\n <button type=\"button\" class=\"btn btn-secondary\" (click)=\"cancelSettings(settingsButton)\">{{'MAP.SETTINGS.CANCEL' | translate}}</button>\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"settingsForm.invalid || settingsForm.pristine\">{{'MAP.SETTINGS.SAVE' | translate}}</button>\n </div>\n </form>\n }\n </div>\n</div>\n@if (showLegend() && !settingsOpen()) {\n <adb-map-legend [result]=\"mapResult()\" [cutoffYear]=\"cutoffYear()\" [loading]=\"mapLoading()\"\n [showObservationStatus]=\"activePresentationMode() === 'observations'\" />\n}\n"
1581
+ }]
1582
+ }],
1583
+ ctorParameters: () => [
1584
+ { type: i1.ActivatedRoute },
1585
+ { type: AdbMapConfigService },
1586
+ { type: i1.Router },
1587
+ { type: i3.HttpClient }
1588
+ ],
1589
+ propDecorators: {
1590
+ showLegend: [{
1591
+ type: i0.Input,
1592
+ args: [{
1593
+ isSignal: true,
1594
+ alias: "showLegend",
1595
+ required: false
1596
+ }]
1597
+ }],
1598
+ showHeader: [{
1599
+ type: i0.Input,
1600
+ args: [{
1601
+ isSignal: true,
1602
+ alias: "showHeader",
1603
+ required: false
1604
+ }]
1605
+ }],
1606
+ allowPresentationMode: [{
1607
+ type: i0.Input,
1608
+ args: [{
1609
+ isSignal: true,
1610
+ alias: "allowPresentationMode",
1611
+ required: false
1612
+ }]
1613
+ }],
1614
+ presentationMode: [{
1615
+ type: i0.Input,
1616
+ args: [{
1617
+ isSignal: true,
1618
+ alias: "presentationMode",
1619
+ required: false
1620
+ }]
1621
+ }],
1622
+ locationSelected: [{
1623
+ type: i0.Output,
1624
+ args: ["locationSelected"]
1625
+ }],
1626
+ clusterSelected: [{
1627
+ type: i0.Output,
1628
+ args: ["clusterSelected"]
1629
+ }]
1630
+ }
1631
+ });
1632
+ var AdbLocationMapComponent = class AdbLocationMapComponent {
1633
+ geoJson = input.required(...ngDevMode ? [{ debugName: "geoJson" }] : /* istanbul ignore next */ []);
1634
+ mapId = "location-map-" + Math.floor(Math.random() * Date.now());
1635
+ map;
1636
+ resizeObserver;
1637
+ pendingExtent = null;
1638
+ source = new VectorSource();
1639
+ uncertaintySource = new VectorSource();
1640
+ format = new GeoJSON();
1641
+ ngAfterViewInit() {
1642
+ this.map = AdbMapUtils.createMap(this.mapId, { scrollZoom: false });
1643
+ this.map.addLayer(new VectorLayer({
1644
+ source: this.uncertaintySource,
1645
+ style: new Style({ stroke: new Stroke({
1646
+ color: MapConstants.UNCERTAINTY_BORDER_COLOR,
1647
+ width: 1
1648
+ }) })
1649
+ }));
1650
+ this.map.addLayer(new VectorLayer({
1651
+ source: this.source,
1652
+ style: new Style({
1653
+ image: new Circle({
1654
+ radius: MapConstants.MARKER_RADIUS,
1655
+ fill: new Fill({ color: MapConstants.LOCATION_MARKER_BACKGROUND_COLOR }),
1656
+ stroke: new Stroke({
1657
+ color: MapConstants.LOCATION_MARKER_BORDER_COLOR,
1658
+ width: 1
1659
+ })
1660
+ }),
1661
+ stroke: new Stroke({
1662
+ color: MapConstants.LOCATION_POLYGON_BORDER_COLOR,
1663
+ width: 2
1664
+ }),
1665
+ fill: new Fill({ color: "transparent" })
1666
+ })
1667
+ }));
1668
+ this.resizeObserver = new ResizeObserver(() => {
1669
+ this.map.updateSize();
1670
+ this.fitPendingExtent();
1671
+ });
1672
+ this.resizeObserver.observe(this.map.getTargetElement());
1673
+ this.renderMap();
1674
+ }
1675
+ ngOnChanges() {
1676
+ this.renderMap();
1677
+ }
1678
+ renderMap() {
1679
+ if (!this.map) return;
1680
+ this.source.clear();
1681
+ this.uncertaintySource.clear();
1682
+ this.pendingExtent = null;
1683
+ const geo = this.geoJson();
1684
+ if (!geo) return;
1685
+ const features = this.format.readFeatures(geo, { featureProjection: this.map.getView().getProjection() });
1686
+ this.source.addFeatures(features);
1687
+ for (const feature of features) {
1688
+ const geometry = feature.getGeometry();
1689
+ const properties = feature.getProperties();
1690
+ const radius = properties["location"]?.coordinateUncertaintyInMeters ?? properties["locations"]?.items?.[0]?.coordinateUncertaintyInMeters;
1691
+ if (geometry?.getType() === "Point" && radius > 0) {
1692
+ const center = geometry.getExtent().slice(0, 2);
1693
+ this.uncertaintySource.addFeature(new Feature(AdbMapUtils.createUncertaintyCircle(center, radius)));
1694
+ }
1695
+ }
1696
+ const extent = extend(this.source.getExtent(), this.uncertaintySource.getExtent());
1697
+ if (!isEmpty(extent)) {
1698
+ this.pendingExtent = extent;
1699
+ this.fitPendingExtent();
1700
+ }
1701
+ }
1702
+ fitPendingExtent() {
1703
+ const size = this.map.getSize();
1704
+ if (!this.pendingExtent || !size?.[0] || !size[1]) return;
1705
+ this.map.getView().fit(this.pendingExtent, {
1706
+ padding: [
1707
+ 20,
1708
+ 20,
1709
+ 20,
1710
+ 20
1711
+ ],
1712
+ maxZoom: 18
1713
+ });
1714
+ this.pendingExtent = null;
1715
+ }
1716
+ ngOnDestroy() {
1717
+ this.resizeObserver?.disconnect();
1718
+ this.map?.dispose();
1719
+ }
1720
+ static ɵfac = i0.ɵɵngDeclareFactory({
1721
+ minVersion: "12.0.0",
1722
+ version: "22.2.4",
1723
+ ngImport: i0,
1724
+ type: AdbLocationMapComponent,
1725
+ deps: [],
1726
+ target: i0.ɵɵFactoryTarget.Component
1727
+ });
1728
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1729
+ minVersion: "17.1.0",
1730
+ version: "22.2.4",
1731
+ type: AdbLocationMapComponent,
1732
+ isStandalone: false,
1733
+ selector: "adb-location-map",
1734
+ inputs: { geoJson: {
1735
+ classPropertyName: "geoJson",
1736
+ publicName: "geoJson",
1737
+ isSignal: true,
1738
+ isRequired: true,
1739
+ transformFunction: null
1740
+ } },
1741
+ usesOnChanges: true,
1742
+ ngImport: i0,
1743
+ template: "<div [id]=\"mapId\" tabindex=\"0\" class=\"border adb-map\"></div>\n",
1744
+ changeDetection: i0.ChangeDetectionStrategy.Eager
1745
+ });
1746
+ };
1747
+ i0.ɵɵngDeclareClassMetadata({
1748
+ minVersion: "12.0.0",
1749
+ version: "22.2.4",
1750
+ ngImport: i0,
1751
+ type: AdbLocationMapComponent,
1752
+ decorators: [{
1753
+ type: Component,
1754
+ args: [{
1755
+ selector: "adb-location-map",
1756
+ changeDetection: ChangeDetectionStrategy.Eager,
1757
+ standalone: false,
1758
+ template: "<div [id]=\"mapId\" tabindex=\"0\" class=\"border adb-map\"></div>\n"
1759
+ }]
1760
+ }],
1761
+ propDecorators: { geoJson: [{
1762
+ type: i0.Input,
1763
+ args: [{
1764
+ isSignal: true,
1765
+ alias: "geoJson",
1766
+ required: true
1767
+ }]
1768
+ }] }
1769
+ });
1770
+ var AdbMapFilters = class AdbMapFilters {
1771
+ cdr;
1772
+ config;
1773
+ http;
1774
+ router;
1775
+ activatedRoute;
1776
+ inline = false;
1777
+ hiddenFilters = input([], ...ngDevMode ? [{ debugName: "hiddenFilters" }] : /* istanbul ignore next */ []);
1778
+ visibleFilters = computed(() => ({
1779
+ taxon: !this.hiddenFilters().includes("taxon"),
1780
+ time: !this.hiddenFilters().includes("time"),
1781
+ area: !this.hiddenFilters().includes("area"),
1782
+ ownArea: !this.hiddenFilters().includes("ownArea"),
1783
+ taxaLists: !this.hiddenFilters().includes("taxonLists"),
1784
+ datasources: !this.hiddenFilters().includes("datasources")
1785
+ }), ...ngDevMode ? [{ debugName: "visibleFilters" }] : /* istanbul ignore next */ []);
1786
+ static datasets = [
1787
+ "1",
1788
+ "3",
1789
+ "5",
1790
+ "6",
1791
+ "4",
1792
+ "8"
1793
+ ];
1794
+ subscriptions = new Subscription();
1795
+ form;
1796
+ thisYear = /* @__PURE__ */ new Date();
1797
+ lastYear = addYears(/* @__PURE__ */ new Date(), -1);
1798
+ queryParamsMap;
1799
+ hasOwnArea;
1800
+ geo;
1801
+ area;
1802
+ areasArray;
1803
+ dataSetCount;
1804
+ taxonListCount;
1805
+ riskListCount;
1806
+ redListCount;
1807
+ areaCount;
1808
+ periodCount;
1809
+ listsError;
1810
+ taxaLists;
1811
+ hasTaxonInUrlParameter;
1812
+ dsControls;
1813
+ dateStartConfig;
1814
+ dateEndConfig;
1815
+ artfakta;
1816
+ constructor(cdr, config, http, router, activatedRoute) {
1817
+ this.cdr = cdr;
1818
+ this.config = config;
1819
+ this.http = http;
1820
+ this.router = router;
1821
+ this.activatedRoute = activatedRoute;
1822
+ this.artfakta = this.config.artfaktaTaxonLists;
1823
+ }
1824
+ ngOnInit() {
1825
+ const lists$ = this.http.get(this.config.taxaListsApi, { params: { limit: -1 } });
1826
+ const combined$ = combineLatest([
1827
+ this.activatedRoute.paramMap,
1828
+ this.activatedRoute.queryParamMap,
1829
+ lists$
1830
+ ]).pipe(map((results) => ({
1831
+ params: results[0],
1832
+ qParams: results[1],
1833
+ lists: results[2]
1834
+ })), debounceTime(0));
1835
+ this.subscriptions.add(combined$.subscribe((result) => {
1836
+ this.form = this.createForm(result.params, result.qParams, result.lists);
1837
+ this.cdr.markForCheck();
1838
+ }));
1839
+ }
1840
+ removeArea(index) {
1841
+ this.form.get("areas").removeAt(index);
1842
+ this.form.markAsDirty();
1843
+ }
1844
+ addArea() {
1845
+ this.form.get("areas").push(new FormControl(null));
1846
+ this.form.updateValueAndValidity();
1847
+ this.form.markAsDirty();
1848
+ }
1849
+ onSubmit() {
1850
+ const data = this.form.value;
1851
+ let params = {};
1852
+ params.p = data.period ?? null;
1853
+ if (data.period === DateTypes.THIS_YEAR) {
1854
+ params.startAt = startOfYear(this.thisYear).toISOString();
1855
+ params.endAt = null;
1856
+ } else if (data.period === DateTypes.LAST_YEAR) {
1857
+ params.startAt = startOfYear(this.lastYear).toISOString();
1858
+ params.endAt = endOfYear(this.lastYear).toISOString();
1859
+ } else if (data.period === DateTypes.ALL_YEAR) {
1860
+ params.startAt = null;
1861
+ params.endAt = null;
1862
+ params.p = null;
1863
+ } else if (data.period === DateTypes.LAST_5_YEAR) {
1864
+ params.startAt = startOfYear(addYears(/* @__PURE__ */ new Date(), -5)).toISOString();
1865
+ params.endAt = null;
1866
+ } else if (data.period === DateTypes.LAST_25_YEAR) {
1867
+ params.startAt = startOfYear(addYears(/* @__PURE__ */ new Date(), -25)).toISOString();
1868
+ params.endAt = null;
1869
+ } else if (data.period === DateTypes.CUSTOM) {
1870
+ params.startAt = startOfDay(data.startAt).toISOString();
1871
+ params.endAt = endOfDay(data.endAt).toISOString();
1872
+ }
1873
+ if (this.hasOwnArea && data.geo) params.geo = JSON.stringify(data.geo.geometry?.coordinates[0]);
1874
+ const cleaned = data.areas?.filter((v) => v != null && v !== "");
1875
+ if (cleaned.length > 0) params.area = cleaned;
1876
+ if (this.activatedRoute.snapshot.paramMap.has("taxonId")) params.taxonId = this.activatedRoute.snapshot.paramMap.get("taxonId");
1877
+ else params.taxonId = data.taxonId ?? null;
1878
+ if (data.list?.length > 0) params.list = data.list;
1879
+ if (data.ds?.length > 0) {
1880
+ const selected = data.ds.filter((f) => f.selected).map((m) => m.id);
1881
+ params.ds = selected.length ? selected : null;
1882
+ }
1883
+ const locationIds = this.activatedRoute.snapshot.queryParamMap.getAll("locationId");
1884
+ if (locationIds.length) params.locationId = locationIds;
1885
+ this.router.navigate([], {
1886
+ queryParams: params,
1887
+ relativeTo: this.activatedRoute
1888
+ });
1889
+ }
1890
+ createForm(params, qMap, lists) {
1891
+ this.hasTaxonInUrlParameter = params["taxonId"];
1892
+ this.hasOwnArea = qMap.has("geo") && this.visibleFilters().ownArea;
1893
+ const areas = qMap.getAll("area").filter((a) => a != null && a.trim() !== "" && a.includes("-"));
1894
+ const form = new FormGroup({
1895
+ period: new FormControl(qMap.has("p") ? qMap.get("p") : "3"),
1896
+ areas: new FormArray((Array.isArray(areas) && areas.length ? areas : [null]).map((a) => new FormControl(a))),
1897
+ geo: new FormControl(qMap.has("geo") ? {
1898
+ type: "Feature",
1899
+ geometry: {
1900
+ type: "Polygon",
1901
+ coordinates: [JSON.parse(qMap.get("geo"))]
1902
+ }
1903
+ } : null)
1904
+ });
1905
+ this.areasArray = form.get("areas");
1906
+ this.periodCount = qMap.has("p") && qMap.get("p") !== "3" ? 1 : 0;
1907
+ this.areaCount = areas.length + (this.hasOwnArea ? 1 : 0);
1908
+ if (!this.hasTaxonInUrlParameter) {
1909
+ form.addControl("taxonId", new FormControl(qMap.get("taxonId") ?? null));
1910
+ const selectedTaxonList = qMap.has("list") ? qMap.getAll("list").map((val) => Number(val)).filter((val) => !isNaN(val)) : null;
1911
+ this.taxaLists = lists;
1912
+ this.taxonListCount = selectedTaxonList?.length;
1913
+ form.addControl("list", new FormControl(selectedTaxonList));
1914
+ let datasets = qMap.has("ds") ? Array.isArray(qMap.getAll("ds")) ? qMap.getAll("ds") : [qMap.get("ds")] : null;
1915
+ this.dataSetCount = datasets?.length;
1916
+ form.addControl("ds", new FormArray(AdbMapFilters.datasets.map((id) => new FormGroup({
1917
+ id: new FormControl(id),
1918
+ selected: new FormControl(datasets?.includes(id))
1919
+ }))));
1920
+ this.dsControls = form.get("ds").controls;
1921
+ }
1922
+ this.updateCustomDate(form, qMap.get("p"), qMap);
1923
+ this.subscriptions.add(form.get("period").valueChanges.subscribe((period) => {
1924
+ this.updateCustomDate(form, period, qMap);
1925
+ }));
1926
+ return form;
1927
+ }
1928
+ updateCustomDate(form, period, qMap) {
1929
+ if (form.contains("startAt")) form.removeControl("startAt");
1930
+ if (form.contains("endAt")) form.removeControl("endAt");
1931
+ if (period === DateTypes.CUSTOM) {
1932
+ let start = qMap.has("startAt") ? parseISO(qMap.get("startAt")) : null;
1933
+ let end = qMap.has("endAt") ? parseISO(qMap.get("endAt")) : null;
1934
+ if (qMap.get("p") !== DateTypes.CUSTOM) {
1935
+ start = /* @__PURE__ */ new Date();
1936
+ end = /* @__PURE__ */ new Date();
1937
+ }
1938
+ this.dateStartConfig = { maxDate: end ?? /* @__PURE__ */ new Date() };
1939
+ this.dateEndConfig = {
1940
+ minDate: start ?? null,
1941
+ maxDate: /* @__PURE__ */ new Date()
1942
+ };
1943
+ const startControl = new FormControl(start, Validators.required);
1944
+ const endControl = new FormControl(end, Validators.required);
1945
+ form.addControl("startAt", startControl);
1946
+ form.addControl("endAt", endControl);
1947
+ this.subscriptions.add(startControl.valueChanges.subscribe((startAt) => {
1948
+ this.dateEndConfig = {
1949
+ minDate: startAt ?? null,
1950
+ maxDate: /* @__PURE__ */ new Date()
1951
+ };
1952
+ }));
1953
+ this.subscriptions.add(endControl.valueChanges.subscribe((endAt) => {
1954
+ this.dateStartConfig = { maxDate: endAt ?? /* @__PURE__ */ new Date() };
1955
+ }));
1956
+ }
1957
+ }
1958
+ ngOnDestroy() {
1959
+ this.subscriptions.unsubscribe();
1960
+ }
1961
+ static ɵfac = i0.ɵɵngDeclareFactory({
1962
+ minVersion: "12.0.0",
1963
+ version: "22.2.4",
1964
+ ngImport: i0,
1965
+ type: AdbMapFilters,
1966
+ deps: [
1967
+ { token: i0.ChangeDetectorRef },
1968
+ { token: AdbMapConfigService },
1969
+ { token: i3.HttpClient },
1970
+ { token: i1.Router },
1971
+ { token: i1.ActivatedRoute }
1972
+ ],
1973
+ target: i0.ɵɵFactoryTarget.Component
1974
+ });
1975
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1976
+ minVersion: "17.0.0",
1977
+ version: "22.2.4",
1978
+ type: AdbMapFilters,
1979
+ isStandalone: false,
1980
+ selector: "adb-map-filters",
1981
+ inputs: {
1982
+ inline: {
1983
+ classPropertyName: "inline",
1984
+ publicName: "inline",
1985
+ isSignal: false,
1986
+ isRequired: false,
1987
+ transformFunction: null
1988
+ },
1989
+ hiddenFilters: {
1990
+ classPropertyName: "hiddenFilters",
1991
+ publicName: "hiddenFilters",
1992
+ isSignal: true,
1993
+ isRequired: false,
1994
+ transformFunction: null
1995
+ }
1996
+ },
1997
+ ngImport: i0,
1998
+ template: "@if(form){\n<form [formGroup]=\"form\" class=\"form mb-3\" (ngSubmit)=\"onSubmit()\">\n <div class=\"mb-3\">\n @if(visibleFilters().taxon){\n <adb-filter-section titleResource=\"TAXON.TAXA\" [expanded]=\"true\">\n @if(!hasTaxonInUrlParameter){\n <div class=\"mb-3\">\n <label for=\"species\">{{'TAXON.TAXON'|translate}}</label>\n <adb-taxon-picker formControlName=\"taxonId\" id=\"species\"></adb-taxon-picker>\n </div>\n }\n </adb-filter-section>\n }\n @if(visibleFilters().time){\n <adb-filter-section [count]=\"periodCount\" titleResource=\"OBSERVATION.PERIOD\">\n <div class=\"mb-1\">\n <select class=\"form-select\" formControlName=\"period\" id=\"period\">\n <option value=\"1\">{{thisYear|date:'yyyy'}}</option>\n <option value=\"2\">{{lastYear|date:'yyyy'}}</option>\n <option value=\"3\">{{'OBSERVATION.ALL_YEAR'|translate}}</option>\n <option value=\"4\">{{'OBSERVATION.LAST_5_YEAR'|translate}}</option>\n <option value=\"5\">{{'OBSERVATION.LAST_25_YEAR'|translate}}</option>\n <option value=\"6\">{{'OBSERVATION.CUSTOMIZED'|translate}}</option>\n </select>\n </div>\n @if (form.value?.period==='6') {\n <div class=\"mb-2\">\n <label for=\"startAt\">{{'FROM' |translate}}</label>\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"startAt\" formControlName=\"startAt\" [settings]=\"dateStartConfig\">\n </div>\n <div class=\"mb-2\">\n <label for=\"endAt\">{{'TO' |translate}}</label>\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"endAt\" formControlName=\"endAt\" [settings]=\"dateEndConfig\">\n </div>\n }\n </adb-filter-section>\n }\n @if(visibleFilters().area){\n <adb-filter-section [count]=\"areaCount\" titleResource=\"GEOGRAPHY\" [lazy]=\"true\">\n <ng-template>\n @if(visibleFilters().ownArea){\n <div role=\"tablist\" aria-label=\"{{'AREA'|translate}}\" class=\"d-flex gap-2 justify-content-end\">\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"!hasOwnArea\" (click)=\"hasOwnArea=false\" role=\"tab\" id=\"tab-select\" aria-selected=\"{{!hasOwnArea}}\" aria-controls=\"panel-select\">\n {{'CHOOSE'|translate}}\n </button>\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"hasOwnArea\" (click)=\"hasOwnArea=true\" role=\"tab\" id=\"tab-draw\" aria-selected=\"false\" aria-controls=\"panel-draw\">\n {{'OWN_AREA'|translate}}\n </button>\n </div>\n }\n <div class=\"mb-2\">\n @if(hasOwnArea&&visibleFilters().ownArea){\n <div class=\"pt-1\" role=\"tabpanel\" id=\"area-draw\" aria-labelledby=\"tab-draw\">\n <div>\n <adb-polygon-drawer formControlName=\"geo\"></adb-polygon-drawer>\n </div>\n </div>\n }@else{\n <div role=\"tabpanel\" id=\"area-select\" aria-labelledby=\"tab-select\">\n <div formArrayName=\"areas\">\n <div class=\"d-flex align-items-end mb-1\">\n <label>{{'AREAS'|translate}}</label>\n <button class=\"ms-auto text-dark btn btn-sm btn-secondary\" attr.aria-label=\"{{'OBSERVATION.ADD_AREA'|translate}}\" title=\"{{'OBSERVATION.ADD_AREA'|translate}}\" type=\"button\" (click)=\"addArea()\">\n <span class=\"bi bi-plus\"></span>\n </button>\n </div>\n @for (ctrl of areasArray.controls; track ctrl; let i = $index; let last = $last) {\n <div class=\"d-flex mb-2\">\n <adb-area-picker id=\"area-{{i}}\" [formControlName]=\"i\"></adb-area-picker>\n @if(areasArray.length>1){\n <button class=\"btn btn-secondary ms-1\" attr.aria-label=\"{{'DELETE'|translate}}\" title=\"{{'DELETE'|translate}}\" type=\"button\" (click)=\"removeArea(i)\">\n <span class=\"bi bi-trash\"></span>\n </button>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n </ng-template>\n </adb-filter-section>\n }\n @if(form.get('taxonId')){\n @if(visibleFilters().taxaLists){\n <adb-filter-section [count]=\"taxonListCount\" titleResource=\"LISTS.NATURE_CONSERVATION_LISTS\">\n <div class=\"mb-3\">\n <app-treeview formControlName=\"list\" [nodes]=\"taxaLists\"></app-treeview>\n </div>\n {{'LISTS.READ_MORE'|translate}}\n <a [href]=\"artfakta\">{{'LISTS.LIST_CONTENT'|translate}}</a>\n </adb-filter-section>\n }\n @if(visibleFilters().datasources){\n <adb-filter-section [count]=\"dataSetCount\" titleResource=\"DATASET.DATASETS\">\n @if (form.get('ds')) {\n <div formArrayName=\"ds\">\n @for (item of dsControls; track item; let i = $index) {\n <div [formGroupName]=\"i\" class=\"form-check\">\n <input type=\"checkbox\" formControlName=\"selected\" [id]=\"'ds-' + item.value.id\" class=\"form-check-input\">\n <label [for]=\"'ds-' + item.value.id\" class=\"form-check-label\">{{ 'PROVIDERS.'+item.value.id |translate }}</label>\n </div>\n }\n </div>\n }\n </adb-filter-section>\n }\n }\n </div>\n <div class=\"d-flex justify-content-end gap-2\">\n @if (inline) {\n <a class=\"btn btn-secondary\" [routerLink]=\"[]\">\n {{'CANCEL'|translate}}\n </a>\n }\n <a [routerLink]=\"[]\" class=\"btn btn-secondary\" [queryParams]=\"null\">\n {{'CLEAR'|translate}}\n </a>\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"form.invalid||form.pristine\">{{'FILTER'|translate}}</button>\n </div>\n</form>\n}\n",
1999
+ dependencies: [
2000
+ {
2001
+ kind: "directive",
2002
+ type: i4.ɵNgNoValidate,
2003
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
2004
+ },
2005
+ {
2006
+ kind: "directive",
2007
+ type: i4.NgSelectOption,
2008
+ selector: "option",
2009
+ inputs: ["ngValue", "value"]
2010
+ },
2011
+ {
2012
+ kind: "directive",
2013
+ type: i4.ɵNgSelectMultipleOption,
2014
+ selector: "option",
2015
+ inputs: ["ngValue", "value"]
2016
+ },
2017
+ {
2018
+ kind: "directive",
2019
+ type: i4.DefaultValueAccessor,
2020
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
2021
+ },
2022
+ {
2023
+ kind: "directive",
2024
+ type: i4.CheckboxControlValueAccessor,
2025
+ selector: "input[type=checkbox]:not([ngNoCva])[formControlName],input[type=checkbox]:not([ngNoCva])[formControl],input[type=checkbox]:not([ngNoCva])[ngModel]"
2026
+ },
2027
+ {
2028
+ kind: "directive",
2029
+ type: i4.SelectControlValueAccessor,
2030
+ selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]",
2031
+ inputs: ["compareWith"]
2032
+ },
2033
+ {
2034
+ kind: "directive",
2035
+ type: i4.NgControlStatus,
2036
+ selector: "[formControlName],[ngModel],[formControl]"
2037
+ },
2038
+ {
2039
+ kind: "directive",
2040
+ type: i4.NgControlStatusGroup,
2041
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
2042
+ },
2043
+ {
2044
+ kind: "directive",
2045
+ type: i1.RouterLink,
2046
+ selector: "[routerLink]",
2047
+ inputs: [
2048
+ "target",
2049
+ "queryParams",
2050
+ "fragment",
2051
+ "queryParamsHandling",
2052
+ "state",
2053
+ "info",
2054
+ "relativeTo",
2055
+ "preserveFragment",
2056
+ "skipLocationChange",
2057
+ "replaceUrl",
2058
+ "browserUrl",
2059
+ "routerLink"
2060
+ ]
2061
+ },
2062
+ {
2063
+ kind: "directive",
2064
+ type: i4.FormGroupDirective,
2065
+ selector: "[formGroup]",
2066
+ inputs: ["formGroup"],
2067
+ outputs: ["ngSubmit"],
2068
+ exportAs: ["ngForm"]
2069
+ },
2070
+ {
2071
+ kind: "directive",
2072
+ type: i4.FormControlName,
2073
+ selector: "[formControlName]",
2074
+ inputs: [
2075
+ "formControlName",
2076
+ "disabled",
2077
+ "ngModel"
2078
+ ],
2079
+ outputs: ["ngModelChange"]
2080
+ },
2081
+ {
2082
+ kind: "directive",
2083
+ type: i4.FormGroupName,
2084
+ selector: "[formGroupName]",
2085
+ inputs: ["formGroupName"]
2086
+ },
2087
+ {
2088
+ kind: "directive",
2089
+ type: i4.FormArrayName,
2090
+ selector: "[formArrayName]",
2091
+ inputs: ["formArrayName"]
2092
+ },
2093
+ {
2094
+ kind: "directive",
2095
+ type: i1$1.AdbDatePickerDirective,
2096
+ selector: "input[adbDatepicker]",
2097
+ inputs: [
2098
+ "format",
2099
+ "toLeft",
2100
+ "settings"
2101
+ ],
2102
+ outputs: ["adbBlur"]
2103
+ },
2104
+ {
2105
+ kind: "component",
2106
+ type: i1$1.FilterSectionComponent,
2107
+ selector: "adb-filter-section",
2108
+ inputs: [
2109
+ "count",
2110
+ "titleResource",
2111
+ "helpResource",
2112
+ "lazy",
2113
+ "expanded"
2114
+ ],
2115
+ outputs: ["expandedChange"]
2116
+ },
2117
+ {
2118
+ kind: "component",
2119
+ type: i1$1.AdbAreaPickerComponent,
2120
+ selector: "adb-area-picker",
2121
+ inputs: [
2122
+ "placeholder",
2123
+ "useObject",
2124
+ "prefill"
2125
+ ]
2126
+ },
2127
+ {
2128
+ kind: "component",
2129
+ type: i1$1.AdbTaxonPickerComponent,
2130
+ selector: "adb-taxon-picker",
2131
+ inputs: [
2132
+ "placeholder",
2133
+ "useObject",
2134
+ "prefill"
2135
+ ]
2136
+ },
2137
+ {
2138
+ kind: "component",
2139
+ type: PolygonDrawerInput,
2140
+ selector: "adb-polygon-drawer"
2141
+ },
2142
+ {
2143
+ kind: "component",
2144
+ type: TreeviewComponent,
2145
+ selector: "app-treeview",
2146
+ inputs: ["nodes"]
2147
+ },
2148
+ {
2149
+ kind: "pipe",
2150
+ type: i1$2.DatePipe,
2151
+ name: "date"
2152
+ },
2153
+ {
2154
+ kind: "pipe",
2155
+ type: i1$3.TranslatePipe,
2156
+ name: "translate"
2157
+ }
2158
+ ],
2159
+ changeDetection: i0.ChangeDetectionStrategy.Eager
2160
+ });
2161
+ };
2162
+ i0.ɵɵngDeclareClassMetadata({
2163
+ minVersion: "12.0.0",
2164
+ version: "22.2.4",
2165
+ ngImport: i0,
2166
+ type: AdbMapFilters,
2167
+ decorators: [{
2168
+ type: Component,
2169
+ args: [{
2170
+ selector: "adb-map-filters",
2171
+ changeDetection: ChangeDetectionStrategy.Eager,
2172
+ standalone: false,
2173
+ template: "@if(form){\n<form [formGroup]=\"form\" class=\"form mb-3\" (ngSubmit)=\"onSubmit()\">\n <div class=\"mb-3\">\n @if(visibleFilters().taxon){\n <adb-filter-section titleResource=\"TAXON.TAXA\" [expanded]=\"true\">\n @if(!hasTaxonInUrlParameter){\n <div class=\"mb-3\">\n <label for=\"species\">{{'TAXON.TAXON'|translate}}</label>\n <adb-taxon-picker formControlName=\"taxonId\" id=\"species\"></adb-taxon-picker>\n </div>\n }\n </adb-filter-section>\n }\n @if(visibleFilters().time){\n <adb-filter-section [count]=\"periodCount\" titleResource=\"OBSERVATION.PERIOD\">\n <div class=\"mb-1\">\n <select class=\"form-select\" formControlName=\"period\" id=\"period\">\n <option value=\"1\">{{thisYear|date:'yyyy'}}</option>\n <option value=\"2\">{{lastYear|date:'yyyy'}}</option>\n <option value=\"3\">{{'OBSERVATION.ALL_YEAR'|translate}}</option>\n <option value=\"4\">{{'OBSERVATION.LAST_5_YEAR'|translate}}</option>\n <option value=\"5\">{{'OBSERVATION.LAST_25_YEAR'|translate}}</option>\n <option value=\"6\">{{'OBSERVATION.CUSTOMIZED'|translate}}</option>\n </select>\n </div>\n @if (form.value?.period==='6') {\n <div class=\"mb-2\">\n <label for=\"startAt\">{{'FROM' |translate}}</label>\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"startAt\" formControlName=\"startAt\" [settings]=\"dateStartConfig\">\n </div>\n <div class=\"mb-2\">\n <label for=\"endAt\">{{'TO' |translate}}</label>\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"endAt\" formControlName=\"endAt\" [settings]=\"dateEndConfig\">\n </div>\n }\n </adb-filter-section>\n }\n @if(visibleFilters().area){\n <adb-filter-section [count]=\"areaCount\" titleResource=\"GEOGRAPHY\" [lazy]=\"true\">\n <ng-template>\n @if(visibleFilters().ownArea){\n <div role=\"tablist\" aria-label=\"{{'AREA'|translate}}\" class=\"d-flex gap-2 justify-content-end\">\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"!hasOwnArea\" (click)=\"hasOwnArea=false\" role=\"tab\" id=\"tab-select\" aria-selected=\"{{!hasOwnArea}}\" aria-controls=\"panel-select\">\n {{'CHOOSE'|translate}}\n </button>\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"hasOwnArea\" (click)=\"hasOwnArea=true\" role=\"tab\" id=\"tab-draw\" aria-selected=\"false\" aria-controls=\"panel-draw\">\n {{'OWN_AREA'|translate}}\n </button>\n </div>\n }\n <div class=\"mb-2\">\n @if(hasOwnArea&&visibleFilters().ownArea){\n <div class=\"pt-1\" role=\"tabpanel\" id=\"area-draw\" aria-labelledby=\"tab-draw\">\n <div>\n <adb-polygon-drawer formControlName=\"geo\"></adb-polygon-drawer>\n </div>\n </div>\n }@else{\n <div role=\"tabpanel\" id=\"area-select\" aria-labelledby=\"tab-select\">\n <div formArrayName=\"areas\">\n <div class=\"d-flex align-items-end mb-1\">\n <label>{{'AREAS'|translate}}</label>\n <button class=\"ms-auto text-dark btn btn-sm btn-secondary\" attr.aria-label=\"{{'OBSERVATION.ADD_AREA'|translate}}\" title=\"{{'OBSERVATION.ADD_AREA'|translate}}\" type=\"button\" (click)=\"addArea()\">\n <span class=\"bi bi-plus\"></span>\n </button>\n </div>\n @for (ctrl of areasArray.controls; track ctrl; let i = $index; let last = $last) {\n <div class=\"d-flex mb-2\">\n <adb-area-picker id=\"area-{{i}}\" [formControlName]=\"i\"></adb-area-picker>\n @if(areasArray.length>1){\n <button class=\"btn btn-secondary ms-1\" attr.aria-label=\"{{'DELETE'|translate}}\" title=\"{{'DELETE'|translate}}\" type=\"button\" (click)=\"removeArea(i)\">\n <span class=\"bi bi-trash\"></span>\n </button>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n </ng-template>\n </adb-filter-section>\n }\n @if(form.get('taxonId')){\n @if(visibleFilters().taxaLists){\n <adb-filter-section [count]=\"taxonListCount\" titleResource=\"LISTS.NATURE_CONSERVATION_LISTS\">\n <div class=\"mb-3\">\n <app-treeview formControlName=\"list\" [nodes]=\"taxaLists\"></app-treeview>\n </div>\n {{'LISTS.READ_MORE'|translate}}\n <a [href]=\"artfakta\">{{'LISTS.LIST_CONTENT'|translate}}</a>\n </adb-filter-section>\n }\n @if(visibleFilters().datasources){\n <adb-filter-section [count]=\"dataSetCount\" titleResource=\"DATASET.DATASETS\">\n @if (form.get('ds')) {\n <div formArrayName=\"ds\">\n @for (item of dsControls; track item; let i = $index) {\n <div [formGroupName]=\"i\" class=\"form-check\">\n <input type=\"checkbox\" formControlName=\"selected\" [id]=\"'ds-' + item.value.id\" class=\"form-check-input\">\n <label [for]=\"'ds-' + item.value.id\" class=\"form-check-label\">{{ 'PROVIDERS.'+item.value.id |translate }}</label>\n </div>\n }\n </div>\n }\n </adb-filter-section>\n }\n }\n </div>\n <div class=\"d-flex justify-content-end gap-2\">\n @if (inline) {\n <a class=\"btn btn-secondary\" [routerLink]=\"[]\">\n {{'CANCEL'|translate}}\n </a>\n }\n <a [routerLink]=\"[]\" class=\"btn btn-secondary\" [queryParams]=\"null\">\n {{'CLEAR'|translate}}\n </a>\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"form.invalid||form.pristine\">{{'FILTER'|translate}}</button>\n </div>\n</form>\n}\n"
2174
+ }]
2175
+ }],
2176
+ ctorParameters: () => [
2177
+ { type: i0.ChangeDetectorRef },
2178
+ { type: AdbMapConfigService },
2179
+ { type: i3.HttpClient },
2180
+ { type: i1.Router },
2181
+ { type: i1.ActivatedRoute }
2182
+ ],
2183
+ propDecorators: {
2184
+ inline: [{ type: Input }],
2185
+ hiddenFilters: [{
2186
+ type: i0.Input,
2187
+ args: [{
2188
+ isSignal: true,
2189
+ alias: "hiddenFilters",
2190
+ required: false
2191
+ }]
2192
+ }]
2193
+ }
2194
+ });
2195
+ var AdbMapModule = class AdbMapModule {
2196
+ static forRoot(config) {
2197
+ return {
2198
+ ngModule: AdbMapModule,
2199
+ providers: [{
2200
+ provide: ADB_MAP_CONFIG,
2201
+ useValue: config
2202
+ }]
2203
+ };
2204
+ }
2205
+ static ɵfac = i0.ɵɵngDeclareFactory({
2206
+ minVersion: "12.0.0",
2207
+ version: "22.2.4",
2208
+ ngImport: i0,
2209
+ type: AdbMapModule,
2210
+ deps: [],
2211
+ target: i0.ɵɵFactoryTarget.NgModule
2212
+ });
2213
+ static ɵmod = i0.ɵɵngDeclareNgModule({
2214
+ minVersion: "14.0.0",
2215
+ version: "22.2.4",
2216
+ ngImport: i0,
2217
+ type: AdbMapModule,
2218
+ declarations: [
2219
+ AdbLocationMapComponent,
2220
+ MapFeaturePickerComponent,
2221
+ MapLegendComponent,
2222
+ AdbMapComponent,
2223
+ PolygonDrawerInput,
2224
+ AdbMapFilters,
2225
+ TreeviewComponent
2226
+ ],
2227
+ imports: [
2228
+ CommonModule,
2229
+ AdbButtonsModule,
2230
+ AdbDirectivesModule,
2231
+ FormsModule,
2232
+ RouterModule,
2233
+ ReactiveFormsModule,
2234
+ AdbDatePickerModule,
2235
+ AdbPipesModule,
2236
+ AdbFilterSectionModule,
2237
+ AdbPickerModule,
2238
+ TranslatePipe
2239
+ ],
2240
+ exports: [
2241
+ AdbLocationMapComponent,
2242
+ AdbMapComponent,
2243
+ PolygonDrawerInput,
2244
+ AdbMapFilters
2245
+ ]
2246
+ });
2247
+ static ɵinj = i0.ɵɵngDeclareInjector({
2248
+ minVersion: "12.0.0",
2249
+ version: "22.2.4",
2250
+ ngImport: i0,
2251
+ type: AdbMapModule,
2252
+ providers: [AdbMapConfigService],
2253
+ imports: [
2254
+ CommonModule,
2255
+ AdbButtonsModule,
2256
+ AdbDirectivesModule,
2257
+ FormsModule,
2258
+ RouterModule,
2259
+ ReactiveFormsModule,
2260
+ AdbDatePickerModule,
2261
+ AdbPipesModule,
2262
+ AdbFilterSectionModule,
2263
+ AdbPickerModule
2264
+ ]
2265
+ });
2266
+ };
2267
+ i0.ɵɵngDeclareClassMetadata({
2268
+ minVersion: "12.0.0",
2269
+ version: "22.2.4",
2270
+ ngImport: i0,
2271
+ type: AdbMapModule,
2272
+ decorators: [{
2273
+ type: NgModule,
2274
+ args: [{
2275
+ imports: [
2276
+ CommonModule,
2277
+ AdbButtonsModule,
2278
+ AdbDirectivesModule,
2279
+ FormsModule,
2280
+ RouterModule,
2281
+ ReactiveFormsModule,
2282
+ AdbDatePickerModule,
2283
+ AdbPipesModule,
2284
+ AdbFilterSectionModule,
2285
+ AdbPickerModule,
2286
+ TranslatePipe
2287
+ ],
2288
+ declarations: [
2289
+ AdbLocationMapComponent,
2290
+ MapFeaturePickerComponent,
2291
+ MapLegendComponent,
2292
+ AdbMapComponent,
2293
+ PolygonDrawerInput,
2294
+ AdbMapFilters,
2295
+ TreeviewComponent
2296
+ ],
2297
+ exports: [
2298
+ AdbLocationMapComponent,
2299
+ AdbMapComponent,
2300
+ PolygonDrawerInput,
2301
+ AdbMapFilters
2302
+ ],
2303
+ providers: [AdbMapConfigService]
2304
+ }]
2305
+ }]
2306
+ });
2307
+ export { ADB_MAP_CONFIG, AdbLocationMapComponent, AdbMapComponent, AdbMapConfigService, AdbMapFilters, AdbMapModule, AdbMapUtils, PolygonDrawerInput };
635
2308
 
636
- class AdbMapFilters {
637
- cdr;
638
- config;
639
- http;
640
- router;
641
- activatedRoute;
642
- inline = false;
643
- static datasets = ['1', '3', '5', '6', '4', '8'];
644
- subscriptions = new Subscription();
645
- form;
646
- thisYear = new Date();
647
- lastYear = addYears(new Date(), -1);
648
- queryParamsMap;
649
- hasOwnArea;
650
- geo;
651
- area;
652
- areasArray;
653
- dataSetCount;
654
- taxonListCount;
655
- riskListCount;
656
- redListCount;
657
- areaCount;
658
- periodCount;
659
- listsError;
660
- filters;
661
- taxaLists;
662
- hasTaxonInUrlParameter;
663
- dsControls;
664
- dateStartConfig;
665
- dateEndConfig;
666
- artfakta;
667
- constructor(cdr, config, http, router, activatedRoute) {
668
- this.cdr = cdr;
669
- this.config = config;
670
- this.http = http;
671
- this.router = router;
672
- this.activatedRoute = activatedRoute;
673
- this.filters = config.filters;
674
- this.artfakta = this.config.artfaktaTaxonLists;
675
- }
676
- ngOnInit() {
677
- const lists$ = this.http.get(this.config.taxaListsApi, { params: { limit: -1 } });
678
- const combined$ = combineLatest([this.activatedRoute.paramMap, this.activatedRoute.queryParamMap, lists$])
679
- .pipe(map(results => ({ params: results[0], qParams: results[1], lists: results[2] })), debounceTime(0));
680
- this.subscriptions.add(combined$.subscribe(result => {
681
- this.form = this.createForm(result.params, result.qParams, result.lists);
682
- this.cdr.markForCheck();
683
- }));
684
- }
685
- removeArea(index) {
686
- this.form.get('areas').removeAt(index);
687
- this.form.markAsDirty();
688
- }
689
- addArea() {
690
- const areas = this.form.get('areas');
691
- areas.push(new FormControl(null));
692
- this.form.updateValueAndValidity();
693
- this.form.markAsDirty();
694
- }
695
- onSubmit() {
696
- const data = this.form.value;
697
- let params = {};
698
- params.p = data.period ?? null;
699
- if (data.period === DateTypes.THIS_YEAR) {
700
- params.startAt = startOfYear(this.thisYear).toISOString();
701
- params.endAt = null;
702
- }
703
- else if (data.period === DateTypes.LAST_YEAR) {
704
- params.startAt = startOfYear(this.lastYear).toISOString();
705
- params.endAt = endOfYear(this.lastYear).toISOString();
706
- }
707
- else if (data.period === DateTypes.ALL_YEAR) {
708
- params.startAt = null;
709
- params.endAt = null;
710
- params.p = null;
711
- }
712
- else if (data.period === DateTypes.LAST_5_YEAR) {
713
- params.startAt = startOfYear(addYears(new Date(), -5)).toISOString();
714
- params.endAt = null;
715
- }
716
- else if (data.period === DateTypes.LAST_25_YEAR) {
717
- params.startAt = startOfYear(addYears(new Date(), -25)).toISOString();
718
- params.endAt = null;
719
- }
720
- else if (data.period === DateTypes.CUSTOM) {
721
- params.startAt = startOfDay(data.startAt).toISOString();
722
- params.endAt = endOfDay(data.endAt).toISOString();
723
- }
724
- if (this.hasOwnArea && data.geo) {
725
- params.geo = JSON.stringify(data.geo.geometry?.coordinates[0]);
726
- }
727
- const cleaned = data.areas?.filter(v => v != null && v !== '');
728
- if (cleaned.length > 0) {
729
- params.area = cleaned;
730
- }
731
- if (this.activatedRoute.snapshot.paramMap.has('taxonId')) {
732
- params.taxonId = this.activatedRoute.snapshot.paramMap.get('taxonId');
733
- }
734
- else {
735
- params.taxonId = data.taxonId ?? null;
736
- }
737
- if (data.list?.length > 0) {
738
- params.list = data.list;
739
- }
740
- if (data.ds?.length > 0) {
741
- const selected = data.ds.filter(f => f.selected).map(m => m.id);
742
- params.ds = selected.length ? selected : null;
743
- }
744
- this.router.navigate([], { queryParams: params, relativeTo: this.activatedRoute });
745
- }
746
- createForm(params, qMap, lists) {
747
- this.hasTaxonInUrlParameter = params['taxonId'];
748
- this.hasOwnArea = qMap.has('geo') && this.filters.showOwnArea;
749
- const areas = qMap.getAll('area').filter(a => a != null && a.trim() !== '' && a.includes('-'));
750
- const form = new FormGroup({
751
- period: new FormControl(qMap.has('p') ? qMap.get('p') : '3'),
752
- areas: new FormArray((Array.isArray(areas) && areas.length ? areas : [null]).map(a => new FormControl(a))),
753
- geo: new FormControl(qMap.has('geo') ? {
754
- type: 'Feature',
755
- geometry: { type: 'Polygon', coordinates: [JSON.parse(qMap.get('geo'))] }
756
- } : null)
757
- });
758
- this.areasArray = form.get('areas');
759
- this.periodCount = qMap.has('p') && qMap.get('p') !== '3' ? 1 : 0;
760
- this.areaCount = areas?.length;
761
- if (!this.hasTaxonInUrlParameter) {
762
- form.addControl('taxonId', new FormControl(qMap.get('taxonId') ?? null));
763
- const selectedTaxonList = qMap.has('list') ? qMap.getAll('list').map(val => Number(val)).filter(val => !isNaN(val)) : null;
764
- this.taxaLists = lists;
765
- this.taxonListCount = selectedTaxonList?.length;
766
- form.addControl('list', new FormControl(selectedTaxonList));
767
- let datasets = qMap.has('ds') ? (Array.isArray(qMap.getAll('ds')) ? qMap.getAll('ds') : [qMap.get('ds')]) : null;
768
- this.dataSetCount = datasets?.length;
769
- form.addControl('ds', new FormArray(AdbMapFilters.datasets.map(id => new FormGroup({
770
- id: new FormControl(id),
771
- selected: new FormControl(datasets?.includes(id))
772
- }))));
773
- this.dsControls = form.get('ds').controls;
774
- }
775
- this.updateCustomDate(form, qMap.get('p'), qMap);
776
- this.subscriptions.add(form.get('period').valueChanges.subscribe(period => {
777
- this.updateCustomDate(form, period, qMap);
778
- }));
779
- return form;
780
- }
781
- updateCustomDate(form, period, qMap) {
782
- if (form.contains('startAt')) {
783
- form.removeControl('startAt');
784
- }
785
- if (form.contains('endAt')) {
786
- form.removeControl('endAt');
787
- }
788
- if (period === DateTypes.CUSTOM) {
789
- let start = qMap.has('startAt') ? parseISO(qMap.get('startAt')) : null;
790
- let end = qMap.has('endAt') ? parseISO(qMap.get('endAt')) : null;
791
- if (qMap.get('p') !== DateTypes.CUSTOM) {
792
- start = new Date();
793
- end = new Date();
794
- }
795
- this.dateStartConfig = { maxDate: end ?? new Date() };
796
- this.dateEndConfig = { minDate: start ?? null, maxDate: new Date() };
797
- const startControl = new FormControl(start, Validators.required);
798
- const endControl = new FormControl(end, Validators.required);
799
- form.addControl('startAt', startControl);
800
- form.addControl('endAt', endControl);
801
- this.subscriptions.add(startControl.valueChanges.subscribe(startAt => {
802
- this.dateEndConfig = { minDate: startAt ?? null, maxDate: new Date() };
803
- }));
804
- this.subscriptions.add(endControl.valueChanges.subscribe(endAt => {
805
- this.dateStartConfig = { maxDate: endAt ?? new Date() };
806
- }));
807
- }
808
- }
809
- ngOnDestroy() {
810
- this.subscriptions.unsubscribe();
811
- }
812
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapFilters, deps: [{ token: i0.ChangeDetectorRef }, { token: AdbMapConfigService }, { token: i3.HttpClient }, { token: i1$2.Router }, { token: i1$2.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
813
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: AdbMapFilters, isStandalone: false, selector: "adb-map-filters", inputs: { inline: "inline" }, ngImport: i0, template: "@if(form){\r\n<form [formGroup]=\"form\" class=\"form mb-3\" (ngSubmit)=\"onSubmit()\">\r\n <div class=\"mb-3\">\r\n <adb-filter-section titleResource=\"TAXON.TAXA\" [expanded]=\"true\">\r\n @if(filters.showTaxon&&!hasTaxonInUrlParameter){\r\n <div class=\"mb-3\">\r\n <label for=\"species\">{{'TAXON.TAXON'|translate}}</label>\r\n <adb-taxon-picker formControlName=\"taxonId\" id=\"species\"></adb-taxon-picker>\r\n </div>\r\n }\r\n </adb-filter-section>\r\n @if(filters.showTime){\r\n <adb-filter-section [count]=\"periodCount\" titleResource=\"OBSERVATION.PERIOD\">\r\n <div class=\"mb-1\">\r\n <select class=\"form-select\" formControlName=\"period\" id=\"period\">\r\n <option value=\"1\">{{thisYear|date:'yyyy'}}</option>\r\n <option value=\"2\">{{lastYear|date:'yyyy'}}</option>\r\n <option value=\"3\">{{'OBSERVATION.ALL_YEAR'|translate}}</option>\r\n <option value=\"4\">{{'OBSERVATION.LAST_5_YEAR'|translate}}</option>\r\n <option value=\"5\">{{'OBSERVATION.LAST_25_YEAR'|translate}}</option>\r\n <option value=\"6\">{{'OBSERVATION.CUSTOMIZED'|translate}}</option>\r\n </select>\r\n </div>\r\n @if (form.value?.period==='6') {\r\n <div class=\"mb-2\">\r\n <label for=\"startAt\">{{'FROM' |translate}}</label>\r\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"startAt\" formControlName=\"startAt\" [settings]=\"dateStartConfig\">\r\n </div>\r\n <div class=\"mb-2\">\r\n <label for=\"endAt\">{{'TO' |translate}}</label>\r\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"endAt\" formControlName=\"endAt\" [settings]=\"dateEndConfig\">\r\n </div>\r\n }\r\n </adb-filter-section>\r\n }\r\n @if(filters.showArea){\r\n <adb-filter-section [count]=\"areaCount\" titleResource=\"GEOGRAPHY\" [lazy]=\"true\">\r\n <ng-template>\r\n @if(filters.showOwnArea){\r\n <div role=\"tablist\" aria-label=\"{{'AREA'|translate}}\" class=\"d-flex gap-2 justify-content-end\">\r\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"!hasOwnArea\" (click)=\"hasOwnArea=false\" role=\"tab\" id=\"tab-select\" aria-selected=\"{{!hasOwnArea}}\" aria-controls=\"panel-select\">\r\n {{'CHOOSE'|translate}}\r\n </button>\r\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"hasOwnArea\" (click)=\"hasOwnArea=true\" role=\"tab\" id=\"tab-draw\" aria-selected=\"false\" aria-controls=\"panel-draw\">\r\n {{'OWN_AREA'|translate}}\r\n </button>\r\n </div>\r\n }\r\n <div class=\"mb-2\">\r\n @if(hasOwnArea&&filters.showOwnArea){\r\n <div class=\"pt-1\" role=\"tabpanel\" id=\"area-draw\" aria-labelledby=\"tab-draw\">\r\n <div>\r\n <adb-polygon-drawer formControlName=\"geo\"></adb-polygon-drawer>\r\n </div>\r\n </div>\r\n }@else{\r\n <div role=\"tabpanel\" id=\"area-select\" aria-labelledby=\"tab-select\">\r\n <div formArrayName=\"areas\">\r\n <div class=\"d-flex align-items-end mb-1\">\r\n <label>{{'AREAS'|translate}}</label>\r\n <button class=\"ms-auto text-dark btn btn-sm btn-secondary\" attr.aria-label=\"{{'OBSERVATION.ADD_AREA'|translate}}\" title=\"{{'OBSERVATION.ADD_AREA'|translate}}\" type=\"button\" (click)=\"addArea()\">\r\n <span class=\"bi bi-plus\"></span>\r\n </button>\r\n </div>\r\n @for (ctrl of areasArray.controls; track ctrl; let i = $index; let last = $last) {\r\n <div class=\"d-flex mb-2\">\r\n <adb-area-picker id=\"area-{{i}}\" [formControlName]=\"i\"></adb-area-picker>\r\n @if(areasArray.length>1){\r\n <button class=\"btn btn-secondary ms-1\" attr.aria-label=\"{{'DELETE'|translate}}\" title=\"{{'DELETE'|translate}}\" type=\"button\" (click)=\"removeArea(i)\">\r\n <span class=\"bi bi-trash\"></span>\r\n </button>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n </ng-template>\r\n </adb-filter-section>\r\n }\r\n @if(form.get('taxonId')){\r\n @if(filters.showTaxaLists){\r\n <adb-filter-section [count]=\"taxonListCount\" titleResource=\"LISTS.NATURE_CONSERVATION_LISTS\">\r\n <div class=\"mb-3\">\r\n <app-treeview formControlName=\"list\" [nodes]=\"taxaLists\"></app-treeview>\r\n </div>\r\n {{'LISTS.READ_MORE'|translate}}\r\n <a [href]=\"artfakta\">{{'LISTS.LIST_CONTENT'|translate}}</a>\r\n </adb-filter-section>\r\n }\r\n @if(filters.showDatasets){\r\n <adb-filter-section [count]=\"dataSetCount\" titleResource=\"DATASET.DATASETS\">\r\n @if (form.get('ds')) {\r\n <div formArrayName=\"ds\">\r\n @for (item of dsControls; track item; let i = $index) {\r\n <div [formGroupName]=\"i\" class=\"form-check\">\r\n <input type=\"checkbox\" formControlName=\"selected\" [id]=\"'ds-' + item.value.id\" class=\"form-check-input\">\r\n <label [for]=\"'ds-' + item.value.id\" class=\"form-check-label\">{{ 'PROVIDERS.'+item.value.id |translate }}</label>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </adb-filter-section>\r\n }\r\n }\r\n </div>\r\n <div class=\"d-flex justify-content-end gap-2\">\r\n @if (inline) {\r\n <a class=\"btn btn-secondary\" [routerLink]=\"[]\">\r\n {{'CANCEL'|translate}}\r\n </a>\r\n }\r\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"form.invalid||form.pristine\">{{'FILTER'|translate}}</button>\r\n </div>\r\n</form>\r\n}", dependencies: [{ kind: "directive", type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i4.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i4.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i4.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i4.FormGroupName, selector: "[formGroupName]", inputs: ["formGroupName"] }, { kind: "directive", type: i4.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "directive", type: i5.AdbDatePickerDirective, selector: "input[adbDatepicker]", inputs: ["format", "toLeft", "settings"], outputs: ["adbBlur"] }, { kind: "component", type: i5.FilterSectionComponent, selector: "adb-filter-section", inputs: ["count", "titleResource", "helpResource", "lazy", "expanded"], outputs: ["expandedChange"] }, { kind: "component", type: i5.AdbAreaPickerComponent, selector: "adb-area-picker", inputs: ["placeholder", "useObject", "prefill"] }, { kind: "component", type: i5.AdbTaxonPickerComponent, selector: "adb-taxon-picker", inputs: ["placeholder", "useObject", "prefill"] }, { kind: "component", type: PolygonDrawerInput, selector: "adb-polygon-drawer" }, { kind: "component", type: TreeviewComponent, selector: "app-treeview", inputs: ["nodes"] }, { kind: "pipe", type: i1$1.DatePipe, name: "date" }, { kind: "pipe", type: i1.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
814
- }
815
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapFilters, decorators: [{
816
- type: Component,
817
- args: [{ selector: 'adb-map-filters', changeDetection: ChangeDetectionStrategy.Eager, standalone: false, template: "@if(form){\r\n<form [formGroup]=\"form\" class=\"form mb-3\" (ngSubmit)=\"onSubmit()\">\r\n <div class=\"mb-3\">\r\n <adb-filter-section titleResource=\"TAXON.TAXA\" [expanded]=\"true\">\r\n @if(filters.showTaxon&&!hasTaxonInUrlParameter){\r\n <div class=\"mb-3\">\r\n <label for=\"species\">{{'TAXON.TAXON'|translate}}</label>\r\n <adb-taxon-picker formControlName=\"taxonId\" id=\"species\"></adb-taxon-picker>\r\n </div>\r\n }\r\n </adb-filter-section>\r\n @if(filters.showTime){\r\n <adb-filter-section [count]=\"periodCount\" titleResource=\"OBSERVATION.PERIOD\">\r\n <div class=\"mb-1\">\r\n <select class=\"form-select\" formControlName=\"period\" id=\"period\">\r\n <option value=\"1\">{{thisYear|date:'yyyy'}}</option>\r\n <option value=\"2\">{{lastYear|date:'yyyy'}}</option>\r\n <option value=\"3\">{{'OBSERVATION.ALL_YEAR'|translate}}</option>\r\n <option value=\"4\">{{'OBSERVATION.LAST_5_YEAR'|translate}}</option>\r\n <option value=\"5\">{{'OBSERVATION.LAST_25_YEAR'|translate}}</option>\r\n <option value=\"6\">{{'OBSERVATION.CUSTOMIZED'|translate}}</option>\r\n </select>\r\n </div>\r\n @if (form.value?.period==='6') {\r\n <div class=\"mb-2\">\r\n <label for=\"startAt\">{{'FROM' |translate}}</label>\r\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"startAt\" formControlName=\"startAt\" [settings]=\"dateStartConfig\">\r\n </div>\r\n <div class=\"mb-2\">\r\n <label for=\"endAt\">{{'TO' |translate}}</label>\r\n <input adbDatepicker type=\"text\" class=\"form-control datepicker\" id=\"endAt\" formControlName=\"endAt\" [settings]=\"dateEndConfig\">\r\n </div>\r\n }\r\n </adb-filter-section>\r\n }\r\n @if(filters.showArea){\r\n <adb-filter-section [count]=\"areaCount\" titleResource=\"GEOGRAPHY\" [lazy]=\"true\">\r\n <ng-template>\r\n @if(filters.showOwnArea){\r\n <div role=\"tablist\" aria-label=\"{{'AREA'|translate}}\" class=\"d-flex gap-2 justify-content-end\">\r\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"!hasOwnArea\" (click)=\"hasOwnArea=false\" role=\"tab\" id=\"tab-select\" aria-selected=\"{{!hasOwnArea}}\" aria-controls=\"panel-select\">\r\n {{'CHOOSE'|translate}}\r\n </button>\r\n <button class=\"btn btn-link p-0\" [class.text-dark]=\"hasOwnArea\" (click)=\"hasOwnArea=true\" role=\"tab\" id=\"tab-draw\" aria-selected=\"false\" aria-controls=\"panel-draw\">\r\n {{'OWN_AREA'|translate}}\r\n </button>\r\n </div>\r\n }\r\n <div class=\"mb-2\">\r\n @if(hasOwnArea&&filters.showOwnArea){\r\n <div class=\"pt-1\" role=\"tabpanel\" id=\"area-draw\" aria-labelledby=\"tab-draw\">\r\n <div>\r\n <adb-polygon-drawer formControlName=\"geo\"></adb-polygon-drawer>\r\n </div>\r\n </div>\r\n }@else{\r\n <div role=\"tabpanel\" id=\"area-select\" aria-labelledby=\"tab-select\">\r\n <div formArrayName=\"areas\">\r\n <div class=\"d-flex align-items-end mb-1\">\r\n <label>{{'AREAS'|translate}}</label>\r\n <button class=\"ms-auto text-dark btn btn-sm btn-secondary\" attr.aria-label=\"{{'OBSERVATION.ADD_AREA'|translate}}\" title=\"{{'OBSERVATION.ADD_AREA'|translate}}\" type=\"button\" (click)=\"addArea()\">\r\n <span class=\"bi bi-plus\"></span>\r\n </button>\r\n </div>\r\n @for (ctrl of areasArray.controls; track ctrl; let i = $index; let last = $last) {\r\n <div class=\"d-flex mb-2\">\r\n <adb-area-picker id=\"area-{{i}}\" [formControlName]=\"i\"></adb-area-picker>\r\n @if(areasArray.length>1){\r\n <button class=\"btn btn-secondary ms-1\" attr.aria-label=\"{{'DELETE'|translate}}\" title=\"{{'DELETE'|translate}}\" type=\"button\" (click)=\"removeArea(i)\">\r\n <span class=\"bi bi-trash\"></span>\r\n </button>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n </ng-template>\r\n </adb-filter-section>\r\n }\r\n @if(form.get('taxonId')){\r\n @if(filters.showTaxaLists){\r\n <adb-filter-section [count]=\"taxonListCount\" titleResource=\"LISTS.NATURE_CONSERVATION_LISTS\">\r\n <div class=\"mb-3\">\r\n <app-treeview formControlName=\"list\" [nodes]=\"taxaLists\"></app-treeview>\r\n </div>\r\n {{'LISTS.READ_MORE'|translate}}\r\n <a [href]=\"artfakta\">{{'LISTS.LIST_CONTENT'|translate}}</a>\r\n </adb-filter-section>\r\n }\r\n @if(filters.showDatasets){\r\n <adb-filter-section [count]=\"dataSetCount\" titleResource=\"DATASET.DATASETS\">\r\n @if (form.get('ds')) {\r\n <div formArrayName=\"ds\">\r\n @for (item of dsControls; track item; let i = $index) {\r\n <div [formGroupName]=\"i\" class=\"form-check\">\r\n <input type=\"checkbox\" formControlName=\"selected\" [id]=\"'ds-' + item.value.id\" class=\"form-check-input\">\r\n <label [for]=\"'ds-' + item.value.id\" class=\"form-check-label\">{{ 'PROVIDERS.'+item.value.id |translate }}</label>\r\n </div>\r\n }\r\n </div>\r\n }\r\n </adb-filter-section>\r\n }\r\n }\r\n </div>\r\n <div class=\"d-flex justify-content-end gap-2\">\r\n @if (inline) {\r\n <a class=\"btn btn-secondary\" [routerLink]=\"[]\">\r\n {{'CANCEL'|translate}}\r\n </a>\r\n }\r\n <button type=\"submit\" class=\"btn btn-primary\" [disabled]=\"form.invalid||form.pristine\">{{'FILTER'|translate}}</button>\r\n </div>\r\n</form>\r\n}" }]
818
- }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: AdbMapConfigService }, { type: i3.HttpClient }, { type: i1$2.Router }, { type: i1$2.ActivatedRoute }], propDecorators: { inline: [{
819
- type: Input
820
- }] } });
821
-
822
- class AdbMapModule {
823
- static forRoot(config) {
824
- return {
825
- ngModule: AdbMapModule,
826
- providers: [
827
- {
828
- provide: ADB_MAP_CONFIG,
829
- useValue: config
830
- }
831
- ]
832
- };
833
- }
834
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
835
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.25", ngImport: i0, type: AdbMapModule, declarations: [AdbObsMapComponent,
836
- PolygonDrawerInput,
837
- AdbMapFilters,
838
- TreeviewComponent], imports: [CommonModule,
839
- FormsModule,
840
- RouterModule,
841
- ReactiveFormsModule,
842
- AdbDatePickerModule,
843
- AdbPipesModule,
844
- AdbFilterSectionModule,
845
- AdbPickerModule,
846
- TranslatePipe], exports: [AdbObsMapComponent,
847
- PolygonDrawerInput,
848
- AdbMapFilters] });
849
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapModule, providers: [
850
- AdbMapConfigService
851
- ], imports: [CommonModule,
852
- FormsModule,
853
- RouterModule,
854
- ReactiveFormsModule,
855
- AdbDatePickerModule,
856
- AdbPipesModule,
857
- AdbFilterSectionModule,
858
- AdbPickerModule] });
859
- }
860
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: AdbMapModule, decorators: [{
861
- type: NgModule,
862
- args: [{
863
- imports: [
864
- CommonModule,
865
- FormsModule,
866
- RouterModule,
867
- ReactiveFormsModule,
868
- AdbDatePickerModule,
869
- AdbPipesModule,
870
- AdbFilterSectionModule,
871
- AdbPickerModule,
872
- TranslatePipe
873
- ],
874
- declarations: [
875
- AdbObsMapComponent,
876
- PolygonDrawerInput,
877
- AdbMapFilters,
878
- TreeviewComponent,
879
- // Stats,
880
- // AdbGeojsonPolygonDirective
881
- ],
882
- exports: [
883
- AdbObsMapComponent,
884
- PolygonDrawerInput,
885
- AdbMapFilters,
886
- // Stats,
887
- // AdbGeojsonPolygonDirective
888
- ],
889
- providers: [
890
- AdbMapConfigService
891
- ]
892
- }]
893
- }] });
894
-
895
- /**
896
- * Generated bundle index. Do not edit.
897
- */
898
-
899
- export { ADB_MAP_CONFIG, AdbMapConfigService, AdbMapFilterType, AdbMapFilters, AdbMapModule, AdbMapUtils, AdbObsMapComponent, PolygonDrawerInput, VisibleFilters };
900
- //# sourceMappingURL=adb-shared-map.mjs.map
2309
+ //# sourceMappingURL=adb-shared-map.mjs.map