@devgateway/dvz-ui-react 1.9.6 → 1.9.8

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,164 +1,163 @@
1
- var X = Object.defineProperty;
2
- var q = (w, F, e) => F in w ? X(w, F, { enumerable: !0, configurable: !0, writable: !0, value: e }) : w[F] = e;
3
- var H = (w, F, e) => q(w, typeof F != "symbol" ? F + "" : F, e);
4
- import { jsx as b, jsxs as M, Fragment as R } from "react/jsx-runtime";
5
- import { injectIntl as Y, FormattedMessage as K } from "react-intl";
6
- import * as g from "d3";
7
- import { Container as U, Segment as Q, Dimmer as ee, Loader as te, Message as N, Icon as E, Popup as se, Grid as S } from "semantic-ui-react";
8
- import V from "react";
9
- import * as ie from "topojson-client";
10
- import oe from "./legend.js";
1
+ import { jsxs as b, Fragment as Ke, jsx as p } from "react/jsx-runtime";
2
+ import { injectIntl as nr, FormattedMessage as ar } from "react-intl";
3
+ import * as c from "d3";
4
+ import { Icon as te, Popup as or, Message as xe, Container as Qe, Segment as sr, Dimmer as ir, Loader as cr, Grid as Fe } from "semantic-ui-react";
5
+ import { useState as re, useRef as L, useEffect as et } from "react";
6
+ import ur from "./legend.js";
11
7
  import { formatContent as k } from "../common/MapTooltip.js";
12
- import T from "../../utils/deviceType.js";
13
- import ae from "geostats";
14
- import { Config as re } from "../../conf/index.js";
15
- function O(w, F, e) {
16
- var l;
17
- if (!(w != null && w.length)) return F;
18
- const s = ((l = w[0]) == null ? void 0 : l.items) ?? [], i = (r) => (r == null ? void 0 : r.trim().toLowerCase()) ?? "", o = i(F), t = i(e).toUpperCase(), a = s.find(
19
- (r) => i(r.value) === o || r.code.trim().toLowerCase() === o
20
- ) ?? null;
21
- if (!a) return F;
22
- const n = t && a.labels && a.labels[t] ? a.labels[t] : a.value;
23
- return (n == null ? void 0 : n.trim()) || a.value.trim();
24
- }
25
- const le = "_Color_", G = "location", j = "showAll", B = "ifUnitHasData", ne = 10, pe = {
26
- mobile: 4,
27
- tablet: 4,
28
- midTablet: 2,
29
- laptop: 2,
30
- desktop: 2,
31
- wide: 2
32
- }, ce = {
33
- mobile: 330,
34
- tablet: 250,
35
- midTablet: 250,
36
- laptop: 200,
37
- desktop: 100,
38
- wide: 100
39
- }, Z = {
40
- mobile: 250,
41
- tablet: 250,
42
- midTablet: 250,
43
- laptop: 0,
44
- desktop: 0,
45
- wide: 0
46
- }, he = {
47
- greens: [
48
- "#ccffdd",
49
- "#b3ffcc",
50
- "#99ffbb",
51
- "#80ffaa",
52
- "#66ff99",
53
- "#4dff88",
54
- "#33ff77",
55
- "#1aff66",
56
- "#00ff55",
57
- "#00e64d"
58
- ],
59
- greys: [
60
- "#f2f2f2",
61
- "#e6e6e6",
62
- "#d9d9d9",
63
- "#cccccc",
64
- "#bfbfbf",
65
- "#b3b3b3",
66
- "#a6a6a6",
67
- "#999999",
68
- "#8c8c8c",
69
- "#808080"
70
- ],
71
- oranges: [
72
- "#fff0e6",
73
- "#ffe0cc",
74
- "#ffd1b3",
75
- "#ffc299",
76
- "#ffb380",
77
- "#ffa366",
78
- "#ff944d",
79
- "#ff8533",
80
- "#ff751a",
81
- "#ff6600"
82
- ],
83
- purples: [
84
- "#ffe6ff",
85
- "#ffccff",
86
- "#ffb3ff",
87
- "#ff99ff",
88
- "#ff80ff",
89
- "#ff66ff",
90
- "#ff4dff",
91
- "#ff33ff",
92
- "#ff1aff",
93
- "#ff00ff"
94
- ],
95
- reds: [
96
- "#ffe6e6",
97
- "#ffcccc",
98
- "#ffb3b3",
99
- "#ff9999",
100
- "#ff8080",
101
- "#ff6666",
102
- "#ff4d4d",
103
- "#ff3333",
104
- "#ff1a1a",
105
- "#ff0000"
106
- ],
107
- blues: [
108
- "#e6eeff",
109
- "#ccddff",
110
- "#b3ccff",
111
- "#99bbff",
112
- "#80aaff",
113
- "#6699ff",
114
- "#4d88ff",
115
- "#3377ff",
116
- "#1a66ff",
117
- "#0055ff"
118
- ]
119
- }, de = ["mobile", "tablet", "midTablet"].includes(
120
- T()
121
- ), $ = ["mobile", "tablet"].includes(T());
122
- class ue extends V.Component {
123
- constructor(e) {
124
- var s;
125
- super(e);
126
- H(this, "handleScroll", () => {
127
- let e = null;
128
- clearTimeout(e), e = setTimeout(() => {
129
- g.select(this.getMapId()).selectAll(".map-labels-container").size() > 0 || this.updateFeatures(this.getFeatures(), !1);
130
- }, 300);
131
- });
132
- this.mapContainer = V.createRef(), this.state = { mainLayer: null, layers: null }, this.classColor = this.classColor.bind(this), this.featuresZoom = this.featuresZoom.bind(this), this.fullView = this.fullView.bind(this), this.onZoomIn = this.onZoomIn.bind(this), this.onZoomOut = this.onZoomOut.bind(this), this.onReset = this.onReset.bind(this), this.onClick = this.onClick.bind(this), this.showTooltip = this.showTooltip.bind(this), this.mousemove = this.mousemove.bind(this), this.mouseout = this.mouseout.bind(this), this.updateFeatures = this.updateFeatures.bind(this), this.d3Map = this.d3Map.bind(this), this.getFeatures = this.getFeatures.bind(this), this.boundingExtent = this.boundingExtent.bind(this), this.getMapId = this.getMapId.bind(this), this.zoomed = this.zoomed.bind(this), this.zoomEnd = this.zoomEnd.bind(this), this.drawPoints = this.drawPoints.bind(this), this.extractFeatures = this.extractFeatures.bind(this), this.getLayers = this.getLayers.bind(this), this.onPointClick = this.onPointClick.bind(this), this.onPolygonClick = this.onPolygonClick.bind(this), this.getCenter = this.getCenter.bind(this), this.mapPosition = null, this.zooming = !1, this.translateValue = pe[T()], this.projection = g.geoMercator().scale(e.scale).center(e.center).translate([this.getWidth() / this.translateValue, this.getHeight() / 2]), this.path = g.geoPath().projection(this.projection), this.zoom = g.zoom().scaleExtent([1, 16]).on("zoom", this.zoomed).on("end", this.zoomEnd), this.centered = null, this.state = {
133
- selectedMeasure: e.transformedData && e.transformedData.measures && e.transformedData.measures.length > 1 ? e.transformedData.measures[0] : null,
134
- generatedBreaks: [],
135
- selectedPolygon: null,
136
- layersLoading: !1
137
- }, this.metadataTypes = ((s = e.transformedData) == null ? void 0 : s.types) || [];
138
- }
139
- componentDidMount() {
140
- window.addEventListener("scroll", this.handleScroll, { passive: !0 }), window.addEventListener("touchmove", this.handleScroll, { passive: !0 }), this.loadLayers(), this.tooltip = g.select("body").append("div").style("position", "absolute").style("visibility", "hidden").style("pointer-events", "none"), console.log("Map props", this.metadataTypes);
8
+ import N from "../../utils/deviceType.js";
9
+ import { deviceTranslateMap as pr, getFilters as we, deviceMapHeight as dr, deviceMapWidth as tt, getHighlightedLocationColor as mr, getTranslatedItemLabel as fr, SHOW_ALL as rt, SHOW_IF_HAS_DATA as lt, LOCATION as nt, generateBreaks as gr, fillColor as hr, classColor as yr, getTranslatedLocationName as Ae, getLabelBoxWidth as vr, getLabelBoxHeight as br, createLabel as Lr, extractFeatures as xr } from "./mapHelpers.js";
10
+ import { Config as Fr } from "../../conf/index.js";
11
+ const wr = ["mobile", "tablet", "midTablet"].includes(
12
+ N()
13
+ ), at = ["mobile", "tablet"].includes(N());
14
+ function Ar(O) {
15
+ const {
16
+ unique: Me,
17
+ editing: j,
18
+ source: Te,
19
+ center: le,
20
+ scale: ke,
21
+ height: Ne,
22
+ width: ot,
23
+ topoJSONField: st,
24
+ mappingField: y,
25
+ transformedData: u,
26
+ legendBreaks: Ee,
27
+ mapLabelField: x,
28
+ mapLabelShowValue: ne,
29
+ showOverallValue: ze,
30
+ measureSelectorLabel: Ie,
31
+ valueFormat: Ce,
32
+ autoGenerateBreaks: De,
33
+ showNoDataLabel: Pe,
34
+ numberOfBreaks: it,
35
+ colorScheme: ct,
36
+ symbols: Se,
37
+ tooltipTheme: ut,
38
+ labelFontSize: K,
39
+ labelFontColor: Oe,
40
+ labelFontWeight: pt,
41
+ legendFontSize: dt,
42
+ customTooltips: mt,
43
+ tooltipFontSize: ft,
44
+ showAdminUnitLabel: ae,
45
+ mapNoDataColor: We,
46
+ mapBoundaryColor: gt,
47
+ mapFocusBoundaryColor: ht,
48
+ highlightedLocation: C,
49
+ tooltipFormat: Re,
50
+ showNoDataTooltip: yt,
51
+ fields: vt,
52
+ mapContainerBgColor: bt,
53
+ mapPosition: h,
54
+ mainLayerId: W,
55
+ enabledLayers: D,
56
+ pointLabelColor: Lt,
57
+ pointLabelFormat: xt,
58
+ highlightedLocLabelFormat: Ft,
59
+ mapType: H,
60
+ defaultPointColor: Be,
61
+ zoomOnFilter: wt,
62
+ zoomOnFilterField: P,
63
+ noDataText: At,
64
+ labelsExclusionList: oe,
65
+ showShadingLayerLabels: _e,
66
+ appliedFilters: m,
67
+ intl: F,
68
+ legendTitle: Mt,
69
+ nationalAverageLabel: Tt,
70
+ zoomEnabled: se,
71
+ showTooltip: ie
72
+ } = O;
73
+ console.log("Map props:", O);
74
+ const [R, kt] = re(
75
+ () => u && u.measures && u.measures.length > 1 ? u.measures[0] : null
76
+ ), [$, Nt] = re(null), [je, ce] = re(!1), [B, ue] = re(null), pe = L(null), w = L(null), v = L(null), U = L(null), A = L(null), He = L(null), E = L(null), $e = L(!1), de = L(null), me = L(null), M = L({}), fe = L(null), J = (u == null ? void 0 : u.types) || [];
77
+ function ge() {
78
+ return pe.current ? pe.current.offsetWidth : ot;
79
+ }
80
+ function he() {
81
+ return Ne;
82
+ }
83
+ A.current === null && (A.current = c.zoom().scaleExtent([1, 16]).on("zoom", (e) => M.current.zoomed(e)).on("end", (e) => M.current.zoomEnd(e))), v.current === null && (He.current = pr[N()], v.current = c.geoMercator().scale(ke).center(le).translate([ge() / He.current, he() / 2]), U.current = c.geoPath().projection(v.current));
84
+ function g() {
85
+ return ".map.wrapper." + Me;
86
+ }
87
+ function z() {
88
+ let e = R;
89
+ return !e && u && u.measures && u.measures.length > 1 && (e = u.measures[0]), e;
90
+ }
91
+ function Ue() {
92
+ return B && B.length > 0 ? B.map((t) => {
93
+ const o = D.find((n) => n.id == t.id);
94
+ return t.index = o ? o.index : 0, t;
95
+ }).sort((t, o) => parseInt(t.index) < parseInt(o.index) ? 1 : parseInt(t.index) > parseInt(o.index) ? -1 : 0) : [];
96
+ }
97
+ function Et() {
98
+ const e = Ue();
99
+ let t;
100
+ return e && (t = e.filter((o) => o.id == W || o.id == null)[0] || e[0]), t ? t.data : null;
141
101
  }
142
- componentDidCatch(e, s) {
143
- console.log(e);
102
+ function Ve(e) {
103
+ return xr(e, st);
144
104
  }
145
- componentWillUnmount() {
146
- window.removeEventListener("scroll", this.handleScroll);
105
+ function X() {
106
+ const e = Et(), t = Ue();
107
+ if (e) {
108
+ let o = [];
109
+ try {
110
+ o = Ve(e), o.map((l) => {
111
+ l.properties.layerId = W;
112
+ const r = t.find(
113
+ (a) => String(a.id) === String(W)
114
+ );
115
+ return r && (l.properties.layerMappingField = r.layerMappingField, l.properties.layerDatasource = r.layerDatasource, l.properties.layerApiField = r.layerApiField, l.properties.layerLocale = r.layerLocale, l.properties.displayLayerLabels = r.displayLayerLabels), D.forEach((a) => {
116
+ String(a.id) == W && Object.keys(a || {}).forEach((s) => {
117
+ l.properties[s] = a[s];
118
+ });
119
+ }), l;
120
+ }), t && t.forEach((l) => {
121
+ if (l.id != W) {
122
+ let r = Ve(l.data);
123
+ r = r.map((a) => (a.properties.layerId = l.id, a.properties.layerMappingField = l.layerMappingField, a.properties.layerDatasource = l.layerDatasource, a.properties.layerApiField = l.layerApiField, a.properties.layerLocale = l.layerLocale, a.properties.displayLayerLabels = l.displayLayerLabels, a)), o = [...r, ...o];
124
+ }
125
+ });
126
+ } catch (l) {
127
+ console.log("error updating features .." + l);
128
+ }
129
+ const n = o.filter((l) => l.properties != null);
130
+ let i = u.locationsData;
131
+ return u.measures && u.measures.length > 1 && (i = u.locationsData.filter(
132
+ (l) => l.measure === z()
133
+ )), n.map((l) => {
134
+ if (i) {
135
+ const r = i.find((a) => {
136
+ const s = a.label ? ("" + a.label).toLowerCase() : "", d = l.properties[y] ? l.properties[y].toLowerCase() : "";
137
+ return s === d;
138
+ });
139
+ if (r) {
140
+ let a = r.measure;
141
+ u.measureLabelMap && r.measure && u.measureLabelMap[r.measure] && (a = u.measureLabelMap[r.measure]), l.properties.value = r.value, l.properties.measure = r.measure, l.properties.measureLabel = a, l.properties.children = r.children, l.properties.variables = r.variables, l.properties.hasDataRow = !0, Object.keys(r).forEach((s) => {
142
+ l.properties[s] = r[s];
143
+ });
144
+ } else
145
+ l.properties.value = null, l.properties.measure = null, l.properties.children = null, l.properties.measureLabel = null, l.properties.hasDataRow = !1;
146
+ }
147
+ }), n;
148
+ }
149
+ return [];
147
150
  }
148
- loadLayers() {
149
- const { source: e, mainLayerId: s, enabledLayers: i } = this.props;
150
- if (this.setState({
151
- layers: [],
152
- layersLoading: !0
153
- }), i && i.length > 0) {
154
- const o = [];
155
- i.forEach((t) => {
156
- o.push(
157
- new Promise((a, n) => {
158
- g.json(re.REACT_APP_WP_API + "/wp/v2/media/" + t.id).then((l) => {
159
- a({
151
+ function Ge() {
152
+ if (ue([]), ce(!0), D && D.length > 0) {
153
+ const e = [];
154
+ D.forEach((t) => {
155
+ e.push(
156
+ new Promise((o) => {
157
+ c.json(Fr.REACT_APP_WP_API + "/wp/v2/media/" + t.id).then((n) => {
158
+ o({
160
159
  id: t.id,
161
- url: l.source_url,
160
+ url: n.source_url,
162
161
  index: t.index,
163
162
  layerMappingField: t.layerMappingField,
164
163
  layerDatasource: t.datasource,
@@ -166,8 +165,8 @@ class ue extends V.Component {
166
165
  layerLocale: t.locale,
167
166
  displayLayerLabels: t.displayLayerLabels
168
167
  });
169
- }).catch(function(l) {
170
- a({
168
+ }).catch(function() {
169
+ o({
171
170
  id: t.id,
172
171
  url: null,
173
172
  index: t.index,
@@ -180,15 +179,15 @@ class ue extends V.Component {
180
179
  });
181
180
  })
182
181
  );
183
- }), Promise.all(o).then((t) => {
184
- const a = [];
182
+ }), Promise.all(e).then((t) => {
183
+ const o = [];
185
184
  t.forEach((n) => {
186
- n.url && a.push(
187
- new Promise((l, r) => {
188
- g.json(n.url).then((h) => {
189
- l({
185
+ n.url && o.push(
186
+ new Promise((i) => {
187
+ c.json(n.url).then((l) => {
188
+ i({
190
189
  id: n.id,
191
- data: h,
190
+ data: l,
192
191
  index: n.index,
193
192
  layerMappingField: n.layerMappingField,
194
193
  layerDatasource: n.layerDatasource,
@@ -199,855 +198,540 @@ class ue extends V.Component {
199
198
  });
200
199
  })
201
200
  );
202
- }), Promise.all(a).then((n) => {
203
- this.setState({
204
- layers: n,
205
- layersLoading: !1
206
- });
201
+ }), Promise.all(o).then((n) => {
202
+ ue(n), ce(!1);
207
203
  });
208
204
  });
209
205
  } else
210
- g.json(e).then((o) => {
211
- this.setState({
212
- layers: [
213
- {
214
- id: null,
215
- url: e,
216
- data: o,
217
- index: 0,
218
- layerMappingField: null,
219
- layerDatasource: null,
220
- layerApiField: null,
221
- layerLocale: null,
222
- displayLayerLabels: !1
223
- }
224
- ],
225
- layersLoading: !1
226
- });
206
+ c.json(Te).then((e) => {
207
+ ue([
208
+ {
209
+ id: null,
210
+ url: Te,
211
+ data: e,
212
+ index: 0,
213
+ layerMappingField: null,
214
+ layerDatasource: null,
215
+ layerApiField: null,
216
+ layerLocale: null,
217
+ displayLayerLabels: !1
218
+ }
219
+ ]), ce(!1);
227
220
  });
228
221
  }
229
- getMainLayer() {
230
- const e = this.getLayers(), { mainLayerId: s, enabledLayers: i } = this.props;
231
- let o;
232
- return e && (o = e.filter(
233
- (t) => t.id == s || t.id == null
234
- )[0] || e[0]), o ? o.data : null;
222
+ function zt(e) {
223
+ c.select(g()).select("svg").selectAll("circle").attr("r", e.k > 1 ? 6 / e.k : 6);
235
224
  }
236
- componentDidUpdate(e, s, i) {
237
- const { selectedMeasure: o, layers: t, selectedPolygon: a } = this.state, n = this.getMainLayer(), { transformedData: l, intl: r, zoomOnFilterField: h, appliedFilters: p } = this.props, { appliedFilters: d } = e;
238
- if (h) {
239
- const v = [], c = [];
240
- d && Object.keys(d).forEach((f) => {
241
- d[f] != null && d[f] instanceof Array && v.push(
242
- ...d[f].filter(
243
- (y) => y != Number.MIN_SAFE_INTEGER
244
- )
245
- );
246
- }), p && Object.keys(p).forEach((f) => {
247
- p[f] != null && p[f] instanceof Array && c.push(
248
- ...p[f].filter((y) => y != Number.MIN_SAFE_INTEGER)
249
- );
250
- }), v.length > 0 && c.length == 0 && this.onReset();
251
- }
252
- this.tooltip.style("visibility", "hidden"), e.enabledLayers.length != this.props.enabledLayers.length && this.loadLayers();
253
- const u = this.getFeatures();
254
- e.center !== this.props.center && (this.mapPosition = null, this.projection.scale(this.props.scale).center(this.props.center).translate([this.getWidth() / 2, this.getHeight() / 2]));
255
- const m = this.filterUpdated(e, s);
256
- this.d3Map(u, m), t && l && (l != e.transformedData || t != s.layers || o != s.selectedMeasure || a != s.selectedPolygon || n != s.mainLayer || e.mainLayerId !== this.props.mainLayerId || JSON.stringify(e.enabledLayers) != JSON.stringify(this.props.enabledLayers)) && this.updateFeatures(this.getFeatures(), m);
257
- }
258
- getHeight() {
259
- return this.props.height;
260
- }
261
- getWidth() {
262
- return this.mapContainer.current ? this.mapContainer.current.offsetWidth : this.props.width;
263
- }
264
- boundingExtent(e) {
265
- let s, i, o, t;
266
- for (const a in e) {
267
- const [[n, l], [r, h]] = this.path.bounds(e[a]);
268
- (n < s || s == null) && (s = n), (r > i || i == null) && (i = r), (l < o || o == null) && (o = l), (h > t || t == null) && (t = h);
269
- }
270
- return [
271
- [s, o],
272
- [i, t]
273
- ];
225
+ function _(e) {
226
+ return vr(e, x);
274
227
  }
275
- onReset() {
276
- this.mapPosition = null, this.tooltip.style("visibility", "hidden"), this.fullView();
228
+ function Q() {
229
+ return br(ne);
277
230
  }
278
- resizeLabels(e) {
279
- const { labelFontSize: s, mapLabelField: i } = this.props;
280
- g.select(this.getMapId()).selectAll(".map-labels-container").each((o, t, a) => {
281
- const n = g.select(a[t]), l = n.select("div"), r = e.k > 1 ? e.k : 1, h = s / r;
282
- l.style("font-size", `${h}px`);
283
- const p = this.getLabelPosition(o), d = this.getLabelBoxWidth(o) / r, u = p[0] - d / 2, m = e.k > 1 ? 10 / e.k : 10, v = p[1] - m;
284
- n.attr("x", u).attr("y", v).attr("width", this.getLabelBoxWidth(o) / r).attr("height", this.getLabelBoxHeight(o) / r);
231
+ function ye(e) {
232
+ return e.properties.LABEL_LATITUDE && e.properties.LABEL_LONGITUDE ? v.current([
233
+ e.properties.LABEL_LONGITUDE,
234
+ e.properties.LABEL_LATITUDE
235
+ ]) : U.current.centroid(e);
236
+ }
237
+ function It(e) {
238
+ c.select(g()).selectAll(".map-labels-container").each((t, o, n) => {
239
+ const i = c.select(n[o]), l = i.select("div"), r = e.k > 1 ? e.k : 1, a = K / r;
240
+ l.style("font-size", `${a}px`);
241
+ const s = ye(t), d = _(t) / r, f = s[0] - d / 2, T = e.k > 1 ? 10 / e.k : 10, S = s[1] - T;
242
+ i.attr("x", f).attr("y", S).attr("width", _(t) / r).attr("height", Q() / r);
285
243
  });
286
244
  }
287
- resizePointLabels(e) {
288
- const { labelFontSize: s } = this.props;
289
- g.select(this.getMapId()).selectAll(".point-labels-container").each((i, o, t) => {
290
- const a = g.select(t[o]), n = a.select("div"), l = e.k > 1 ? e.k : 1, r = s / l;
291
- n.style("font-size", `${r}px`);
292
- const h = this.projection([
293
- i.geometry.coordinates[1],
294
- i.geometry.coordinates[0]
295
- ]), p = (this.getLabelBoxWidth(i) + 20) / l, d = this.getLabelBoxHeight(i) / l, u = h[0] - p / 2, m = h[1] - d / 2;
296
- a.attr("x", u).attr("y", m).attr("width", p).attr("height", d);
245
+ function Ct(e) {
246
+ c.select(g()).selectAll(".point-labels-container").each((t, o, n) => {
247
+ const i = c.select(n[o]), l = i.select("div"), r = e.k > 1 ? e.k : 1, a = K / r;
248
+ l.style("font-size", `${a}px`);
249
+ const s = v.current([
250
+ t.geometry.coordinates[1],
251
+ t.geometry.coordinates[0]
252
+ ]), d = (_(t) + 20) / r, f = Q() / r, T = s[0] - d / 2, S = s[1] - f / 2;
253
+ i.attr("x", T).attr("y", S).attr("width", d).attr("height", f);
297
254
  });
298
255
  }
299
- resizeCircles(e) {
300
- g.select(this.getMapId()).select("svg").selectAll("circle").attr("r", e.k > 1 ? 6 / e.k : 6);
301
- }
302
- zoomed(e) {
303
- this.tooltip.style("visibility", "hidden");
304
- const s = e.transform;
305
- g.select(this.getMapId()).select("svg").select("g").attr("transform", s), this.resizeCircles(s), this.resizeLabels(s), this.resizePointLabels(s);
256
+ function Dt(e) {
257
+ w.current.style("visibility", "hidden");
258
+ const t = e.transform;
259
+ c.select(g()).select("svg").select("g").attr("transform", t), zt(t), It(t), Ct(t);
306
260
  }
307
- zoomEnd(e) {
308
- const { editing: s } = this.props, i = e.transform;
309
- this.mapPosition = { k: i.k, x: i.x, y: i.y }, s && window.parent.postMessage(
310
- { type: "map", value: JSON.stringify(this.mapPosition) },
261
+ function Pt(e) {
262
+ const t = e.transform;
263
+ E.current = { k: t.k, x: t.x, y: t.y }, j && window.parent.postMessage(
264
+ { type: "map", value: JSON.stringify(E.current) },
311
265
  "*"
312
266
  );
313
267
  }
314
- classColor(e) {
315
- let { zoomEnabled: s } = this.props;
316
- return s || (s = !!["mobile", "tablet", "midTablet"].includes(
317
- T()
318
- )), s ? "active zoom-enabled" : "active";
268
+ function St() {
269
+ const e = c.select(g()).select("svg");
270
+ e.select("g").selectAll(".active").attr("class", function() {
271
+ return c.select(this).attr("class").replace(/background/gi, "");
272
+ });
273
+ let o = c.zoomIdentity;
274
+ h && !j ? o = o.translate(h.x, h.y).scale(h.k) : o = o.translate(0, 0).scale(1), e.transition().duration(300).call(A.current.transform, o);
319
275
  }
320
- generateBreaks(e) {
321
- const { autoGenerateBreaks: s, numberOfBreaks: i, colorScheme: o } = this.props, t = [];
322
- if (s && e && e.length > 0) {
323
- const a = e.filter((r) => r.properties && r.properties.value != null).map((r) => r.properties.value.toFixed(2)), n = [];
324
- a.forEach((r) => {
325
- if (r > 0) {
326
- const h = r * 0.99, p = r * 1.01;
327
- n.indexOf(h) === -1 && n.push(h), n.indexOf(p) === -1 && n.push(p);
328
- }
329
- });
330
- const l = he[o];
331
- if (n.length > 0) {
332
- const r = new ae(n);
333
- r.setPrecision(2);
334
- const h = n.length > 1 ? n.length - 1 : n.length;
335
- return r.getJenks(Math.min(i, h)), r.ranges.forEach((p, d) => {
336
- const u = {};
337
- u.min = parseFloat(p.substr(0, p.indexOf("-") - 1)) + (d > 0 ? 0.01 : 0), u.max = parseFloat(
338
- p.substr(p.indexOf("-") + 2, p.length)
339
- ), u.color = l[d], t.push(u);
340
- }), t;
341
- }
342
- }
343
- return t;
276
+ function Je() {
277
+ E.current = null, w.current.style("visibility", "hidden"), St();
344
278
  }
345
- getBreaks() {
346
- const { legendBreaks: e, autoGenerateBreaks: s } = this.props;
347
- if (s) {
348
- const i = this.getFeatures();
349
- return this.generateBreaks(i);
279
+ function Ot() {
280
+ c.select(g()).select("svg").transition().call(A.current.scaleBy, 1.5);
281
+ }
282
+ function Wt() {
283
+ c.select(g()).select("svg").transition().call(A.current.scaleBy, 0.6667);
284
+ }
285
+ function Z() {
286
+ if (De) {
287
+ const e = X();
288
+ return gr(e, {
289
+ autoGenerateBreaks: De,
290
+ numberOfBreaks: it,
291
+ colorScheme: ct
292
+ });
350
293
  } else {
351
- let i = e;
352
- return this.getSelectedMeasure() && (i = e.filter((o) => o.measure === this.getSelectedMeasure()).filter((o) => {
353
- if (o.filters && o.filters.length > 0 && this.props.appliedFilters && JSON.stringify(this.props.appliedFilters) !== "{}") {
354
- const a = Object.keys(this.props.appliedFilters);
355
- return o.filters.filter((l) => {
356
- if (a.indexOf(l.field) != -1) {
357
- const r = this.props.appliedFilters[l.field], h = l.values;
358
- return r.join(",").indexOf(h) != -1;
294
+ let e = Ee;
295
+ return z() && (e = Ee.filter((t) => t.measure === z()).filter((t) => {
296
+ if (t.filters && t.filters.length > 0 && m && JSON.stringify(m) !== "{}") {
297
+ const n = Object.keys(m);
298
+ return t.filters.filter((l) => {
299
+ if (n.indexOf(l.field) != -1) {
300
+ const r = m[l.field], a = l.values;
301
+ return r.join(",").indexOf(a) != -1;
359
302
  }
360
303
  return !1;
361
304
  }).length > 0;
362
305
  }
363
306
  return !0;
364
- })), i;
307
+ })), e;
365
308
  }
366
309
  }
367
- fillColor(e, s) {
368
- const { mapNoDataColor: i, mainLayerId: o } = this.props;
369
- let t;
370
- if (e.properties && e.properties.variables && this.state.selectedMeasure && e.properties.value != null) {
371
- const n = le + this.state.selectedMeasure;
372
- if (t = e.properties.variables[n.trim()], t)
373
- return t;
374
- }
375
- if (e.properties.value != null && (o && e.properties.layerId === o || !o)) {
376
- const n = s.find((l) => {
377
- if (l.min != null && l.max != null)
378
- return e.properties.value >= l.min && e.properties.value <= l.max;
379
- if (l.min != null)
380
- return e.properties.value >= l.min;
381
- if (l.max != null)
382
- return e.properties.value <= l.max;
383
- });
384
- return n && n.color ? n.color : i;
385
- }
386
- const a = this.props.enabledLayers.filter(
387
- (n) => n.id === e.properties.layerId
388
- )[0];
389
- return a && a.bgColor && a.bgColor != "undefined" ? a.bgColor : i;
390
- }
391
- setValues() {
392
- const e = this.getFeatures();
393
- g.select(this.getMapId()).select("svg").select("g").selectAll("path").data(e).join("path").attr("d", this.path);
310
+ function ve(e, t) {
311
+ return hr(e, t, {
312
+ mapNoDataColor: We,
313
+ mainLayerId: W,
314
+ enabledLayers: D,
315
+ selectedMeasure: R
316
+ });
394
317
  }
395
- getLabelPosition(e) {
396
- return e.properties.LABEL_LATITUDE && e.properties.LABEL_LONGITUDE ? this.projection([
397
- e.properties.LABEL_LONGITUDE,
398
- e.properties.LABEL_LATITUDE
399
- ]) : this.path.centroid(e);
318
+ function Rt(e) {
319
+ return Lr(
320
+ e,
321
+ {
322
+ mapLabelField: x,
323
+ mapLabelShowValue: ne,
324
+ intl: F,
325
+ valueFormat: Ce,
326
+ showNoDataLabel: Pe,
327
+ showAdminUnitLabel: ae,
328
+ noDataText: At,
329
+ selectedMeasure: z()
330
+ },
331
+ J,
332
+ k
333
+ );
400
334
  }
401
- updateFeatures(e, s) {
402
- const { mapLabelField: i, symbols: o, highlightedLocation: t } = this.props, a = [
403
- ...e.filter((n) => t != n.properties[i]),
404
- ...e.filter((n) => t == n.properties[i])
335
+ function Xe(e, t) {
336
+ const o = [
337
+ ...e.filter((n) => C != n.properties[x]),
338
+ ...e.filter((n) => C == n.properties[x])
405
339
  ];
406
- this.drawPolygons(a), this.drawLabels(a), this.drawPoints(a, s), o.length > 0 && this.addSymbols(o, a);
340
+ _t(o), Bt(o), jt(o, t), Se.length > 0 && Ht(Se, o);
407
341
  }
408
- drawLabels(e) {
409
- const {
410
- mapLabelField: s,
411
- mapLabelShowValue: i,
412
- intl: o,
413
- valueFormat: t,
414
- showNoDataLabel: a,
415
- labelFontColor: n,
416
- labelFontWeight: l,
417
- labelFontSize: r,
418
- showAdminUnitLabel: h,
419
- mapType: p,
420
- noDataText: d,
421
- labelsExclusionList: u
422
- } = this.props, m = g.select(this.getMapId()).select("svg").select("g");
423
- if (m.selectAll(".map-labels-container").size() > 0) {
342
+ function Bt(e) {
343
+ const t = c.select(g()).select("svg").select("g");
344
+ if (t.selectAll(".map-labels-container").size() > 0) {
424
345
  console.log("Labels already exist, skipping redraw...");
425
346
  return;
426
347
  }
427
- m.selectAll(".map-labels").data(
428
- e.filter((c) => u && u.length > 0 ? !u.includes(c.properties[s]) : !0)
429
- ).enter().append("foreignObject").attr("class", "map-labels-container").attr("x", (c) => {
430
- const f = this.getLabelPosition(c);
431
- if (c.properties[s]) {
432
- const y = this.getLabelBoxWidth(c);
433
- return f[0] - y / 2;
348
+ t.selectAll(".map-labels").data(
349
+ e.filter((n) => oe && oe.length > 0 ? !oe.includes(n.properties[x]) : !0)
350
+ ).enter().append("foreignObject").attr("class", "map-labels-container").attr("x", (n) => {
351
+ const i = ye(n);
352
+ if (n.properties[x]) {
353
+ const l = _(n);
354
+ return i[0] - l / 2;
434
355
  }
435
- return f[0];
436
- }).attr("y", (c) => this.getLabelPosition(c)[1] - 10).attr("width", (c) => this.getLabelBoxWidth(c)).attr("height", (c) => this.getLabelBoxHeight(c)).attr("font-size", (c, f) => `${r}px`).attr("overflow", "visible").attr("opacity", 1).style("display", (c) => h === j || h === B && c.properties.hasDataRow || c.properties.displayLayerLabels ? "block" : "none").attr("pointer-events", p == "POINTS_MAP" ? "none" : "all").on("mouseover", this.showTooltip).on("mousemove", this.mousemove).on("mouseout", this.mouseout).append("xhtml:div").style("font-size", (c) => `${r}px`).style("color", (c, f) => n).style("font-weight", (c) => l).style("background-color", (c) => c.properties.hasDataRow && i && (c.properties.value != null || c.properties.value == null && a) ? "#fff6e1" : "none").style("border-radius", (c) => "4px").style("line-height", "95%").style("text-align", "center").html((c, f) => this.createLabel(c));
356
+ return i[0];
357
+ }).attr("y", (n) => ye(n)[1] - 10).attr("width", (n) => _(n)).attr("height", (n) => Q()).attr("font-size", () => `${K}px`).attr("overflow", "visible").attr("opacity", 1).style("display", (n) => ae === rt || ae === lt && n.properties.hasDataRow || n.properties.displayLayerLabels ? "block" : "none").attr("pointer-events", H == "POINTS_MAP" ? "none" : "all").on("mouseover", V).on("mousemove", Y).on("mouseout", G).append("xhtml:div").style("font-size", () => `${K}px`).style("color", () => Oe).style("font-weight", () => pt).style("background-color", (n) => n.properties.hasDataRow && ne && (n.properties.value != null || n.properties.value == null && Pe) ? "#fff6e1" : "none").style("border-radius", () => "4px").style("line-height", "95%").style("text-align", "center").html((n) => Rt(n));
437
358
  }
438
- getTranslatedLocationName(e, s, i) {
439
- if (e.properties.displayLayerLabels && e.properties.layerLocale) {
440
- const o = e.properties.layerMappingField || s, t = e.properties[o];
441
- return O(this.metadataTypes, t, e.properties.layerLocale);
442
- }
443
- return e.properties[s];
444
- }
445
- createLabel(e) {
446
- const {
447
- mapLabelField: s,
448
- mapLabelShowValue: i,
449
- intl: o,
450
- valueFormat: t,
451
- showNoDataLabel: a,
452
- showAdminUnitLabel: n,
453
- noDataText: l
454
- } = this.props;
455
- let r = "";
456
- if (n == j || n == B && e.properties.hasDataRow || e.properties.displayLayerLabels) {
457
- const h = e.properties.displayLayerLabels && e.properties.layerMappingField ? e.properties.layerMappingField : s, p = e.properties[h], d = e.properties.layerLocale || (o == null ? void 0 : o.locale);
458
- r = O(this.metadataTypes, p, d);
459
- const u = e.properties.abbrev;
460
- if (r && r.length > ne && u && (r = u), i)
461
- if (e.properties.value != null) {
462
- const m = e.properties.variables || {};
463
- r += "<br><span class='map-label-value'>" + k(
464
- t,
465
- {
466
- value: e.properties.value,
467
- measure: this.getSelectedMeasure(),
468
- ...m
469
- },
470
- o
471
- ) + "</span>";
472
- } else
473
- a == !0 && e.properties.value == null && e.properties.hasDataRow && (r += "<br><span class='map-label-value'>" + l + "</span>");
474
- }
475
- return r;
476
- }
477
- drawPolygons(e) {
478
- const {
479
- mapLabelField: s,
480
- mapBoundaryColor: i,
481
- mapFocusBoundaryColor: o,
482
- highlightedLocation: t
483
- } = this.props, a = this.getBreaks(), n = g.select(this.getMapId()).select("svg").select("g"), l = e.filter(
484
- (r) => r.geometry && r.geometry && (r.geometry.type == "Polygon" || r.geometry.type == "MultiPolygon")
359
+ function _t(e) {
360
+ const t = Z(), o = c.select(g()).select("svg").select("g"), n = e.filter(
361
+ (i) => i.geometry && i.geometry && (i.geometry.type == "Polygon" || i.geometry.type == "MultiPolygon")
485
362
  );
486
- l.length > 0 && n.selectAll("path").data(l).join("path").attr("d", this.path).attr("fill", (r) => this.fillColor(r, a)).attr("stroke-width", (r) => t == r.properties[s] ? 1.2 : 0.4).attr("stroke", (r) => t == r.properties[s] ? o : i).on("click", this.onPolygonClick);
487
- }
488
- drawPoints(e, s) {
489
- const {
490
- intl: i,
491
- pointLabelColor: o,
492
- pointLabelFormat: t,
493
- transformedData: a,
494
- defaultPointColor: n,
495
- appliedFilters: l,
496
- zoomOnFilterField: r,
497
- noDataText: h,
498
- showShadingLayerLabels: p
499
- } = this.props, d = g.select(this.getMapId()).select("svg").select("g");
500
- let u = [];
501
- if (a.pointsData) {
502
- let c = this.state.selectedPolygon;
503
- s && l && l[r] && (c = l[r]), u = a.pointsData.filter((f) => f.lat && f.lng && f.label == c).map((f) => ({
363
+ n.length > 0 && o.selectAll("path").data(n).join("path").attr("d", U.current).attr("fill", (i) => ve(i, t)).attr("stroke-width", (i) => C == i.properties[x] ? 1.2 : 0.4).attr("stroke", (i) => C == i.properties[x] ? ht : gt).on("click", Ut);
364
+ }
365
+ function jt(e, t) {
366
+ const o = c.select(g()).select("svg").select("g");
367
+ let n = [];
368
+ if (u.pointsData) {
369
+ let r = $;
370
+ t && m && m[P] && (r = m[P]), n = u.pointsData.filter((a) => a.lat && a.lng && a.label == r).map((a) => ({
504
371
  properties: {
505
- label: f.label,
506
- lat: f.lat,
507
- lng: f.lng,
508
- value: f.value,
509
- variables: f.variables
372
+ label: a.label,
373
+ lat: a.lat,
374
+ lng: a.lng,
375
+ value: a.value,
376
+ variables: a.variables
510
377
  }
511
- })), d.selectAll(".circle").data(u).enter().append("circle").attr("id", (f, y) => "circle" + y).attr("cx", (f) => this.projection([
512
- f.properties.lng,
513
- f.properties.lat
514
- ])[0]).attr("cy", (f) => this.projection([
515
- f.properties.lng,
516
- f.properties.lat
517
- ])[1]).attr("r", (f, y) => 2).style("stroke-width", 0.5).style("fill", (f, y) => n).on("mouseover", (f, y) => this.onPointClick(f, y)).on("mouseout", this.mouseout);
378
+ })), o.selectAll(".circle").data(n).enter().append("circle").attr("id", (a, s) => "circle" + s).attr("cx", (a) => v.current([a.properties.lng, a.properties.lat])[0]).attr("cy", (a) => v.current([a.properties.lng, a.properties.lat])[1]).attr("r", () => 2).style("stroke-width", 0.5).style("fill", () => Be).on("mouseover", (a, s) => $t(a, s)).on("mouseout", G);
518
379
  }
519
- const m = this.getBreaks();
520
- let v = [];
521
- p == j ? v = e.filter(
522
- (c) => c.geometry && c.geometry.type == "Point"
523
- ) : p == B && (v = e.filter(
524
- (c) => c.geometry && c.geometry.type == "Point" && c.properties.hasDataRow
525
- )), v.length > 0 && d.selectAll(".point-labels").data(v).enter().append("foreignObject").attr("id", (c, f) => "point-label" + f).attr("class", "point-labels-container").attr("x", (c) => {
526
- const f = this.getLabelBoxWidth(c) + 20;
527
- return this.projection([
528
- c.geometry.coordinates[1],
529
- c.geometry.coordinates[0]
530
- ])[0] - f / 2;
531
- }).attr("y", (c) => this.projection([
532
- c.geometry.coordinates[1],
533
- c.geometry.coordinates[0]
534
- ])[1] - this.getLabelBoxHeight(c) / 2).attr("width", (c) => this.getLabelBoxWidth(c) + 20).attr("height", (c) => "1px").attr("overflow", "visible").attr("font-size", "12px").style("opacity", 1).append("xhtml:div").style("color", (c, f) => o).style("font-weight", (c) => "bold").style("background-color", (c) => this.fillColor(c, m)).style("padding", (c) => "5px 3px 5px 3px").style("border-radius", (c) => "4px").style("line-height", "100%").style("text-align", "center").html((c, f) => k(
535
- t,
536
- {
537
- value: c.properties.value,
538
- locationName: c.properties[this.props.mapLabelField]
539
- },
540
- i
541
- )).on("mouseover", (c, f, y) => {
542
- g.select(this.getMapId()).select("svg").select("g").select("#point-label" + y).raise(), this.showTooltip(c, f);
543
- }).on("mousemove", this.mousemove).on("mouseout", this.mouseout);
544
- }
545
- addSymbols(e, s) {
546
- const { mappingField: i } = this.props, o = g.select(this.getMapId()).select("svg").select("g");
547
- e.forEach((t) => {
548
- if (t.field && t.image && t.values) {
549
- const a = s.filter((l) => {
550
- const r = G == t.field ? i : "value", h = (l.properties[r] || (l.properties.variables ? l.properties.variables[r] : "")) + "", d = (t.values + "").split(",");
551
- return l.properties.LATITUDE && l.properties.LONGITUDE && d.filter(
552
- (u) => u.trim().toLowerCase() == h.trim().toLowerCase()
380
+ const i = Z();
381
+ let l = [];
382
+ _e == rt ? l = e.filter((r) => r.geometry && r.geometry.type == "Point") : _e == lt && (l = e.filter(
383
+ (r) => r.geometry && r.geometry.type == "Point" && r.properties.hasDataRow
384
+ )), l.length > 0 && o.selectAll(".point-labels").data(l).enter().append("foreignObject").attr("id", (r, a) => "point-label" + a).attr("class", "point-labels-container").attr("x", (r) => {
385
+ const a = _(r) + 20;
386
+ return v.current([
387
+ r.geometry.coordinates[1],
388
+ r.geometry.coordinates[0]
389
+ ])[0] - a / 2;
390
+ }).attr("y", (r) => v.current([
391
+ r.geometry.coordinates[1],
392
+ r.geometry.coordinates[0]
393
+ ])[1] - Q() / 2).attr("width", (r) => _(r) + 20).attr("height", () => "1px").attr("overflow", "visible").attr("font-size", "12px").style("opacity", 1).append("xhtml:div").style("color", () => Lt).style("font-weight", () => "bold").style("background-color", (r) => ve(r, i)).style("padding", () => "5px 3px 5px 3px").style("border-radius", () => "4px").style("line-height", "100%").style("text-align", "center").html(
394
+ (r) => k(
395
+ xt,
396
+ {
397
+ value: r.properties.value,
398
+ locationName: r.properties[x]
399
+ },
400
+ F
401
+ )
402
+ ).on("mouseover", (r, a, s) => {
403
+ c.select(g()).select("svg").select("g").select("#point-label" + s).raise(), V(r, a);
404
+ }).on("mousemove", Y).on("mouseout", G);
405
+ }
406
+ function Ht(e, t) {
407
+ const o = c.select(g()).select("svg").select("g");
408
+ e.forEach((n) => {
409
+ if (n.field && n.image && n.values) {
410
+ const i = t.filter((r) => {
411
+ const a = nt == n.field ? y : "value", s = (r.properties[a] || (r.properties.variables ? r.properties.variables[a] : "")) + "", f = (n.values + "").split(",");
412
+ return r.properties.LATITUDE && r.properties.LONGITUDE && f.filter(
413
+ (T) => T.trim().toLowerCase() == s.trim().toLowerCase()
553
414
  ).length > 0;
554
- }), n = s.filter((l) => {
555
- const r = G == t.field ? i : "value", h = (l.properties[r] || (l.properties.variables ? l.properties.variables[r] : "")) + "", d = (t.values + "").split(",");
556
- return !l.properties.LATITUDE && !l.properties.LONGITUDE && d.filter(
557
- (u) => u.trim().toLowerCase() == h.trim().toLowerCase()
415
+ }), l = t.filter((r) => {
416
+ const a = nt == n.field ? y : "value", s = (r.properties[a] || (r.properties.variables ? r.properties.variables[a] : "")) + "", f = (n.values + "").split(",");
417
+ return !r.properties.LATITUDE && !r.properties.LONGITUDE && f.filter(
418
+ (T) => T.trim().toLowerCase() == s.trim().toLowerCase()
558
419
  ).length > 0;
559
420
  });
560
- o.selectAll("image").data(a).enter().append("image").attr("width", 40).attr("height", 40).attr("class", "map-symbol").attr("xlink:href", "/" + t.image).attr("transform", (l) => "translate(" + this.projection([l.properties.LONGITUDE, l.properties.LATITUDE]) + ")").on("mouseover", this.showTooltip).on("mousemove", this.mousemove).on("mouseout", this.mouseout), o.selectAll("image").data(n).enter().append("image").attr("width", 40).attr("height", 40).attr("class", "map-symbol").attr("xlink:href", "/" + t.image).attr("x", (l) => this.path.centroid(l)[0] - 20).attr("y", (l) => this.path.centroid(l)[1]).on("mouseover", this.showTooltip).on("mousemove", this.mousemove).on("mouseout", this.mouseout);
421
+ o.selectAll("image").data(i).enter().append("image").attr("width", 40).attr("height", 40).attr("class", "map-symbol").attr("xlink:href", "/" + n.image).attr(
422
+ "transform",
423
+ (r) => "translate(" + v.current([r.properties.LONGITUDE, r.properties.LATITUDE]) + ")"
424
+ ).on("mouseover", V).on("mousemove", Y).on("mouseout", G), o.selectAll("image").data(l).enter().append("image").attr("width", 40).attr("height", 40).attr("class", "map-symbol").attr("xlink:href", "/" + n.image).attr("x", (r) => U.current.centroid(r)[0] - 20).attr("y", (r) => U.current.centroid(r)[1]).on("mouseover", V).on("mousemove", Y).on("mouseout", G);
561
425
  }
562
426
  });
563
427
  }
564
- getLabelBoxHeight() {
565
- const { mapLabelShowValue: e } = this.props;
566
- return e ? 30 : 25;
567
- }
568
- getLabelBoxWidth(e) {
569
- const { mapLabelField: s } = this.props, i = 80;
570
- if (e.properties[s]) {
571
- const o = e.properties[s].length;
572
- return o < 10 ? i : o * 8;
573
- }
574
- return 0;
575
- }
576
- featuresZoom(e, s, i) {
577
- const o = g.select(this.getMapId()).select("svg"), t = this.boundingExtent(e), [[a, n], [l, r]] = t, h = this.getWidth(), p = this.getHeight(), d = Math.min(
578
- 8,
579
- 0.9 / Math.max((l - a) / h, (r - n) / p)
580
- ), u = [h / 2 - (a + l) / 2, p / 2 - (n + r) / 2];
581
- s ? o.call(
582
- this.zoom.transform,
583
- g.zoomIdentity.translate(u[0], u[1]).scale(d)
584
- ) : o.transition().duration(450).call(
585
- this.zoom.transform,
586
- g.zoomIdentity.translate(u[0], u[1]).scale(d)
587
- ).on("end", i);
588
- }
589
- fullView() {
590
- const { mapPosition: e, editing: s } = this.props, i = g.select(this.getMapId()).select("svg");
591
- i.select("g").selectAll(".active").attr("class", function() {
592
- return g.select(this).attr("class").replace(/background/gi, "");
593
- });
594
- let t = g.zoomIdentity;
595
- e && !s ? t = t.translate(e.x, e.y).scale(e.k) : t = t.translate(0, 0).scale(1), i.transition().duration(300).call(this.zoom.transform, t);
596
- }
597
- showTooltip(e, s) {
598
- let {
599
- showTooltip: i,
600
- zoomEnabled: o,
601
- tooltipTheme: t,
602
- customTooltips: a,
603
- tooltipFontSize: n,
604
- tooltipFormat: l,
605
- intl: r,
606
- mappingField: h,
607
- showNoDataTooltip: p,
608
- fields: d,
609
- mapType: u,
610
- noDataText: m
611
- } = this.props;
612
- if (o = !!["mobile", "tablet", "midTablet"].includes(
613
- T()
614
- ), i && s.properties.value != null || i && p) {
615
- g.select(this.getMapId()).select("svg").select("g").selectAll(".active").attr("class", (A) => A.properties[h] === s.properties[h] ? "focus" + (o ? " zoom-enabled" : "") : "active" + (o ? " zoom-enabled" : ""));
616
- const f = l || `{locationName} %({value},2)
617
- {label}: %({value},2)`, y = s.properties.variables || {}, I = {
618
- ...s.properties,
619
- value: s.properties.value,
620
- measure: this.getSelectedMeasure(),
621
- measureLabel: s.properties.measureLabel,
622
- locationName: this.getTranslatedLocationName(s, h, r),
623
- label: this.getTranslatedLocationName(s, h, r),
624
- ...y
428
+ function V(e, t) {
429
+ console.log("Showing tooltip for data:", t);
430
+ const o = ["mobile", "tablet", "midTablet"].includes(
431
+ N()
432
+ );
433
+ if (ie && t.properties.value !== null || ie && yt) {
434
+ c.select(g()).select("svg").select("g").selectAll(".active").attr("class", (s) => s.properties[y] === t.properties[y] ? "focus" + (o ? " zoom-enabled" : "") : "active" + (o ? " zoom-enabled" : ""));
435
+ const l = Re || `{locationName} %({value},2)
436
+ {label}: %({value},2)`, r = t.properties.variables || {}, a = {
437
+ ...t.properties,
438
+ value: t.properties.value,
439
+ measure: z(),
440
+ measureLabel: t.properties.measureLabel,
441
+ locationName: Ae(t, y, J),
442
+ label: Ae(t, y, J),
443
+ ...r,
444
+ ...we(m)
445
+ // expose applied filter params (e.g. {year}) to the tooltip
625
446
  };
626
- this.tooltip.attr("class", t).style("position", "absolute").style("visibility", "hidden").style("visibility", "visible").html((A) => {
627
- let L = `<div style='font-size:${n}px;' class='tooltip-content' >`;
628
- if (s.properties.value != null) {
629
- const x = f.split(`
630
- `), D = x[0], W = x.length > 1 ? x[1] : null;
631
- let z = 1, P;
632
- d.length > 1 && u != "POINTS_MAP" ? (z = x.length > 2 ? 2 : 1, P = x[z]) : P = null, D && (L += k(D, I, r)), W && (L.endsWith("<hr>") || (L += "<hr>"), L += k(W, I, r)), P && s.properties.children && s.properties.children.forEach((C, _) => {
633
- const J = {
634
- value: C.value,
635
- label: C.label,
636
- measure: this.getSelectedMeasure(),
637
- measureLabel: s.properties.measureLabel,
638
- ...y
447
+ w.current.attr("class", ut).style("position", "absolute").style("visibility", "hidden").style("visibility", "visible").html(() => {
448
+ let s = `<div style='font-size:${ft}px;' class='tooltip-content' >`;
449
+ if (t.properties.value != null) {
450
+ const d = l.split(`
451
+ `), f = d[0], T = d.length > 1 ? d[1] : null;
452
+ let S = 1, ee;
453
+ vt.length > 1 && H != "POINTS_MAP" ? (S = d.length > 2 ? 2 : 1, ee = d[S]) : ee = null, f && (s += k(f, a, F)), T && (s.endsWith("<hr>") || (s += "<hr>"), s += k(T, a, F)), ee && t.properties.children && t.properties.children.forEach((I) => {
454
+ const Le = {
455
+ value: I.value,
456
+ label: I.label,
457
+ measure: z(),
458
+ measureLabel: t.properties.measureLabel,
459
+ ...r,
460
+ ...I.variables,
461
+ ...we(m)
639
462
  };
640
- L.endsWith("<hr>") || (L += "<hr>"), L += k(
641
- P,
642
- J,
643
- r
644
- );
645
- }), x.length > z + 1 && (L.endsWith("<hr>") || (L += "<hr>"), x.forEach((C, _) => {
646
- _ > z && (L.endsWith("<hr>") || (L += "<hr>"), L += k(C, I, r));
647
- })), a.filter(
648
- (C) => C.location === s.properties[h]
649
- ).forEach((C) => {
650
- L.endsWith("<hr>") || (L += "<hr>"), L += C.tooltip;
463
+ s.endsWith("<hr>") || (s += "<hr>"), s += k(ee, Le, F);
464
+ }), d.length > S + 1 && (s.endsWith("<hr>") || (s += "<hr>"), d.forEach((I, Le) => {
465
+ Le > S && (s.endsWith("<hr>") || (s += "<hr>"), s += k(I, a, F));
466
+ })), mt.filter(
467
+ (I) => I.location === t.properties[y]
468
+ ).forEach((I) => {
469
+ s.endsWith("<hr>") || (s += "<hr>"), s += I.tooltip;
651
470
  });
652
471
  } else {
653
- const x = l || `{locationName} %({value},2)
654
- {label}: %({value},2)`, D = {
472
+ const d = Re || `{locationName} %({value},2)
473
+ {label}: %({value},2)`, f = {
655
474
  value: null,
656
- measure: this.getSelectedMeasure(),
657
- measureLabel: s.properties.measureLabel,
658
- locationName: this.getTranslatedLocationName(s, h, r),
659
- ...y
475
+ measure: z(),
476
+ measureLabel: t.properties.measureLabel,
477
+ locationName: Ae(t, y, J),
478
+ ...r
660
479
  };
661
- L += k(x, D, r), L += "</div>";
480
+ s += k(d, f, F), s += "</div>";
662
481
  }
663
- return L;
482
+ return s;
664
483
  });
665
484
  }
666
485
  }
667
- positionTooltip(e) {
668
- const i = this.tooltip.node(), o = i ? i.offsetWidth : 0, t = window.scrollX + document.documentElement.clientWidth;
669
- let a = e.pageX;
670
- o && a + o > t && (a = e.pageX - o, a < window.scrollX && (a = window.scrollX)), this.tooltip.style("top", e.pageY + "px").style("left", a + "px").style("margin-left", "8px");
671
- }
672
- mousemove(e, s) {
673
- this.positionTooltip(e);
674
- }
675
- mouseout(e, s) {
676
- const { showTooltip: i } = this.props;
677
- i && (g.select(this.getMapId()).select("svg").select("g").selectAll(".focus").attr("class", "active"), this.tooltip.style("visibility", "hidden"));
678
- }
679
- onClick(e, s) {
680
- s.properties && (this.tooltip.style("visibility", "visible"), this.positionTooltip(e)), e.stopPropagation(), e.preventDefault();
486
+ function Ze(e) {
487
+ const o = w.current.node(), n = o ? o.offsetWidth : 0, i = window.scrollX + document.documentElement.clientWidth;
488
+ let l = e.pageX;
489
+ n && l + n > i && (l = e.pageX - n, l < window.scrollX && (l = window.scrollX)), w.current.style("top", e.pageY + "px").style("left", l + "px").style("margin-left", "8px");
681
490
  }
682
- onPointClick(e, s, i) {
683
- this.showTooltip(e, s), this.tooltip.style("visibility", "visible"), this.positionTooltip(e);
684
- const o = g.select(this.getMapId()).select("svg").select("g");
685
- o.selectAll("circle").style("fill", this.props.defaultPointColor).style("stroke", "none"), o.select("#circle" + i).raise().style("fill", "#fff");
491
+ function Y(e) {
492
+ Ze(e);
686
493
  }
687
- onPolygonClick(e, s) {
688
- const { mappingField: i } = this.props;
689
- this.state.selectedPolygon !== s.properties[i] && s.properties.value !== null && this.setState({ selectedPolygon: s.properties[i] });
494
+ function G() {
495
+ ie && (c.select(g()).select("svg").select("g").selectAll(".focus").attr("class", "active"), w.current.style("visibility", "hidden"));
690
496
  }
691
- onZoomIn(e) {
692
- g.select(this.getMapId()).select("svg").transition().call(this.zoom.scaleBy, 1.5);
693
- }
694
- onZoomOut() {
695
- g.select(this.getMapId()).select("svg").transition().call(this.zoom.scaleBy, 0.6667);
696
- }
697
- getSelectedMeasure() {
698
- let e = this.state.selectedMeasure;
699
- return !e && this.props.transformedData && this.props.transformedData.measures && this.props.transformedData.measures.length > 1 && (e = this.props.transformedData.measures[0]), e;
700
- }
701
- getCollectionField(e) {
702
- const { topoJSONField: s } = this.props;
703
- if (e && e.objects) {
704
- const i = Object.keys(e.objects);
705
- for (const o in i) {
706
- const t = i[o];
707
- if (e.objects[t].type == "GeometryCollection")
708
- return t;
709
- }
710
- }
711
- return s;
712
- }
713
- extractFeatures(e) {
714
- const s = this.getCollectionField(e);
715
- return e && e.objects && e.objects[s] ? ie.feature(e, e.objects[s]).features : e && e.features ? e.features : [];
716
- }
717
- getLayers() {
718
- const { layers: e } = this.state, { enabledLayers: s } = this.props;
719
- return e && e.length > 0 ? e.map((o) => {
720
- const t = s.find((a) => a.id == o.id);
721
- return o.index = t ? t.index : 0, o;
722
- }).sort((o, t) => parseInt(o.index) < parseInt(t.index) ? 1 : parseInt(o.index) > parseInt(t.index) ? -1 : 0) : [];
723
- }
724
- getFeatures() {
725
- const e = this.getMainLayer(), s = this.getLayers();
726
- if (e) {
727
- const { transformedData: i, mappingField: o, app: t, mainLayerId: a, enabledLayers: n } = this.props;
728
- let l = [];
729
- try {
730
- l = this.extractFeatures(e), l.map((p) => {
731
- p.properties.layerId = a;
732
- const d = s.find((u) => String(u.id) === String(a));
733
- return d && (p.properties.layerMappingField = d.layerMappingField, p.properties.layerDatasource = d.layerDatasource, p.properties.layerApiField = d.layerApiField, p.properties.layerLocale = d.layerLocale, p.properties.displayLayerLabels = d.displayLayerLabels), n.forEach((u) => {
734
- String(u.id) == a && Object.keys(u || {}).forEach((m) => {
735
- p.properties[m] = u[m];
736
- });
737
- }), p;
738
- }), s && s.forEach((p) => {
739
- if (p.id != a) {
740
- let d = this.extractFeatures(p.data);
741
- d = d.map((u) => (u.properties.layerId = p.id, u.properties.layerMappingField = p.layerMappingField, u.properties.layerDatasource = p.layerDatasource, u.properties.layerApiField = p.layerApiField, u.properties.layerLocale = p.layerLocale, u.properties.displayLayerLabels = p.displayLayerLabels, u)), l = [...d, ...l];
742
- }
743
- });
744
- } catch (p) {
745
- console.log("error updating features .." + p);
746
- }
747
- const r = l.filter((p) => p.properties != null);
748
- let h = i.locationsData;
749
- return i.measures && i.measures.length > 1 && (h = i.locationsData.filter(
750
- (p) => p.measure === this.getSelectedMeasure()
751
- )), r.map((p) => {
752
- if (h) {
753
- const d = h.find((u) => {
754
- const m = u.label ? ("" + u.label).toLowerCase() : "", v = p.properties[o] ? p.properties[o].toLowerCase() : "";
755
- return m === v;
756
- });
757
- if (d) {
758
- let u = d.measure;
759
- i.measureLabelMap && d.measure && i.measureLabelMap[d.measure] && (u = i.measureLabelMap[d.measure]), p.properties.value = d.value, p.properties.measure = d.measure, p.properties.measureLabel = u, p.properties.children = d.children, p.properties.variables = d.variables, p.properties.hasDataRow = !0, Object.keys(d).forEach((m) => {
760
- p.properties[m] = d[m];
761
- });
762
- } else
763
- p.properties.value = null, p.properties.measure = null, p.properties.children = null, p.properties.measureLabel = null, p.properties.hasDataRow = !1;
764
- }
765
- }), r;
766
- }
767
- return [];
497
+ function $t(e, t, o) {
498
+ V(e, t), w.current.style("visibility", "visible"), Ze(e);
499
+ const n = c.select(g()).select("svg").select("g");
500
+ n.selectAll("circle").style("fill", Be).style("stroke", "none"), n.select("#circle" + o).raise().style("fill", "#fff");
768
501
  }
769
- getMapId() {
770
- const { unique: e } = this.props;
771
- return ".map.wrapper." + e;
502
+ function Ut(e, t) {
503
+ $ !== t.properties[y] && t.properties.value !== null && Nt(t.properties[y]);
772
504
  }
773
- filterUpdated(e, s) {
774
- const { zoomOnFilterField: i } = this.props, o = e && e.appliedFilters || {}, t = this.props.appliedFilters || {};
775
- let a = !1;
776
- return o[i] != t[i] && (a = !0), a;
505
+ function Vt(e) {
506
+ const t = e && e.appliedFilters || {}, o = m || {};
507
+ return t[P] != o[P];
777
508
  }
778
- getCenter(e, s) {
779
- const { zoomOnFilter: i, zoomOnFilterField: o, mappingField: t, appliedFilters: a } = this.props;
780
- let n = null;
781
- if (i && o) {
782
- let l = this.state.selectedPolygon;
783
- s && a && a[o] && (l = a[o]);
784
- const r = e.filter(
785
- (h) => h.properties != null && h.properties[t] == l
509
+ function Gt(e, t) {
510
+ let o = null;
511
+ if (wt && P) {
512
+ let n = $;
513
+ t && m && m[P] && (n = m[P]);
514
+ const i = e.filter(
515
+ (l) => l.properties != null && l.properties[y] == n
786
516
  )[0];
787
- r && r.properties != null && r.properties.value && (n = r);
517
+ i && i.properties != null && i.properties.value && (o = i);
788
518
  }
789
- return n;
790
- }
791
- area(e) {
792
- let s = 0;
793
- const i = e.coordinates.length > 1 ? e.coordinates[0][0] : e.coordinates[0];
794
- for (let o = 0; o < i.length - 1; o++)
795
- s += i[o][0] * i[o + 1][1] - i[o + 1][0] * i[o][1];
796
- return 0.5 * s;
797
- }
798
- centroid(e) {
799
- const s = [0, 0], i = e.coordinates.length > 1 ? e.coordinates[0][0] : e.coordinates[0];
800
- for (let t = 0; t < i.length - 1; t++)
801
- s[0] += (i[t][0] + i[t + 1][0]) * (i[t][0] * i[t + 1][1] - i[t + 1][0] * i[t][1]), s[1] += (i[t][1] + i[t + 1][1]) * (i[t][0] * i[t + 1][1] - i[t + 1][0] * i[t][1]);
802
- const o = this.area(e);
803
- return s[0] /= o * 6, s[1] /= o * 6, s;
804
- }
805
- d3Map(e, s) {
806
- let { zoomEnabled: i, mapContainerBgColor: o, mapPosition: t, editing: a, mapType: n } = this.props;
807
- i || (i = !!["mobile", "tablet"].includes(T()));
808
- const l = this.getBreaks(), r = g.select(this.getMapId());
809
- let h = r.select("svg"), p = this.getWidth();
810
- p === 0 ? p = window.innerWidth + Z[T()] : p += Z[T()];
811
- const d = this.getHeight() - 100;
812
- if (h.empty() ? h = r.append("svg") : h.selectAll("*").remove(), h.attr("style", `background-color:${o};`).attr("viewBox", `0 0 ${p} ${d}`).attr("preserveAspectRatio", "xMidYMid meet"), h.append("g").selectAll("path").data(e).enter().append("path").attr("fill", (m) => this.fillColor(m, l)).attr("d", g.geoPath().projection(this.projection)).attr("class", (m) => this.classColor(m)).on("mouseover", n !== "POINTS_MAP" ? this.showTooltip : null).on("mousemove", n !== "POINTS_MAP" ? this.mousemove : null).on("mouseout", n !== "POINTS_MAP" ? this.mouseout : null), this.mapPosition && h.transition().duration(300).call(
813
- this.zoom.transform,
814
- g.zoomIdentity.translate(this.mapPosition.x, this.mapPosition.y).scale(this.mapPosition.k)
815
- ), !this.mapPosition && t && t.x && t.y && t.k && (h.transition().duration(300).call(
816
- this.zoom.transform,
817
- g.zoomIdentity.translate(t.x, t.y).scale(t.k)
818
- ), n === "POINTS_MAP")) {
819
- const v = {
519
+ return o;
520
+ }
521
+ function Jt() {
522
+ return yr(se);
523
+ }
524
+ function Xt(e, t) {
525
+ let o = se;
526
+ o || (o = ["mobile", "tablet"].includes(N()));
527
+ const n = Z(), i = c.select(g());
528
+ let l = i.select("svg"), r = ge();
529
+ r === 0 ? r = window.innerWidth + tt[N()] : r += tt[N()];
530
+ const a = he() - 100;
531
+ if (l.empty() ? l = i.append("svg") : l.selectAll("*").remove(), l.attr("style", `background-color:${bt};`).attr("viewBox", `0 0 ${r} ${a}`).attr("preserveAspectRatio", "xMidYMid meet"), l.append("g").selectAll("path").data(e).enter().append("path").attr("fill", (d) => ve(d, n)).attr("d", c.geoPath().projection(v.current)).attr("class", () => Jt()).on("mouseover", H !== "POINTS_MAP" ? V : null).on("mousemove", H !== "POINTS_MAP" ? Y : null).on("mouseout", H !== "POINTS_MAP" ? G : null), E.current && l.transition().duration(300).call(
532
+ A.current.transform,
533
+ c.zoomIdentity.translate(E.current.x, E.current.y).scale(E.current.k)
534
+ ), !E.current && h && h.x && h.y && h.k && (l.transition().duration(300).call(
535
+ A.current.transform,
536
+ c.zoomIdentity.translate(h.x, h.y).scale(h.k)
537
+ ), H === "POINTS_MAP")) {
538
+ const f = {
820
539
  mobile: 100,
821
540
  tablet: 0,
822
541
  midTablet: 0,
823
542
  desktop: 0,
824
543
  laptop: 0,
825
544
  wide: 0
826
- }[T()];
827
- h.transition().duration(300).call(
828
- this.zoom.transform,
829
- g.zoomIdentity.translate(t.x + v, t.y).scale(t.k)
545
+ }[N()];
546
+ l.transition().duration(300).call(
547
+ A.current.transform,
548
+ c.zoomIdentity.translate(h.x + f, h.y).scale(h.k)
830
549
  );
831
550
  }
832
- i || a ? h.call(this.zoom) : h.on("dblclick.zoom", null);
833
- const u = this.getCenter(e, s);
834
- if (u) {
835
- const m = this.path.bounds(u), v = [
836
- (m[0][0] + m[1][0]) / 2,
837
- (m[0][1] + m[1][1]) / 2
551
+ o || j ? l.call(A.current) : l.on("dblclick.zoom", null);
552
+ const s = Gt(e, t);
553
+ if (s) {
554
+ const d = U.current.bounds(s), f = [
555
+ (d[0][0] + d[1][0]) / 2,
556
+ (d[0][1] + d[1][1]) / 2
838
557
  ];
839
- h.transition().duration(750).call(
840
- this.zoom.transform,
841
- g.zoomIdentity.translate(p / 2, d / 2).scale(12).translate(-v[0], -v[1])
558
+ l.transition().duration(750).call(
559
+ A.current.transform,
560
+ c.zoomIdentity.translate(r / 2, a / 2).scale(12).translate(-f[0], -f[1])
842
561
  );
843
562
  }
844
563
  }
845
- getAvg() {
846
- const { transformedData: e } = this.props;
847
- return e.nationalData.value;
848
- }
849
- selectedMeasureChanged(e) {
850
- this.state.selectedMeasure != e && this.setState({ selectedMeasure: e });
564
+ function Zt() {
565
+ return u.nationalData.value;
851
566
  }
852
- getFilters() {
853
- const { appliedFilters: e } = this.props, s = {};
854
- return e && Object.keys(e).forEach((o) => {
855
- const t = e[o];
856
- t && (s[o] = Array.isArray(t) ? t.join(" ,") : t);
857
- }), s;
567
+ function Yt(e) {
568
+ R != e && kt(e);
858
569
  }
859
- getHighlightedLocationData() {
860
- const { highlightedLocation: e, transformedData: s } = this.props;
861
- let i = s.locationsData;
862
- return s.measures && s.measures.length > 1 && (i = s.locationsData.filter(
863
- (t) => t.measure === this.getSelectedMeasure()
864
- )), i.find(
865
- (t) => t.label === e
866
- );
570
+ function qt() {
571
+ let e = u.locationsData;
572
+ return u.measures && u.measures.length > 1 && (e = u.locationsData.filter(
573
+ (t) => t.measure === z()
574
+ )), e.find((t) => t.label === C);
867
575
  }
868
- getTranslatedHighlightedLocationName() {
869
- const { highlightedLocation: e, mapLabelField: s, intl: i } = this.props;
870
- if (!e)
576
+ function Kt() {
577
+ if (!C)
871
578
  return null;
872
- const t = this.getFeatures().find(
873
- (a) => a.properties[s] === e
579
+ const t = X().find(
580
+ (o) => o.properties[x] === C
874
581
  );
875
582
  if (t && t.properties.displayLayerLabels && t.properties.layerLocale) {
876
- const a = t.properties.layerMappingField || s, n = t.properties[a];
877
- return O(this.metadataTypes, n, t.properties.layerLocale);
583
+ const o = t.properties.layerMappingField || x, n = t.properties[o];
584
+ return fr(
585
+ J,
586
+ n,
587
+ t.properties.layerLocale
588
+ );
878
589
  }
879
- return e;
590
+ return C;
880
591
  }
881
- getHighlightedLocationColor(e) {
882
- const s = this.getBreaks(), { mapNoDataColor: i } = this.props, o = e ? e.value : null;
883
- if (o != null) {
884
- const t = s.find((a) => {
885
- if (a.min != null && a.max != null)
886
- return o >= a.min && o <= a.max;
887
- if (a.min != null)
888
- return o >= a.min;
889
- if (a.max != null)
890
- return o <= a.max;
891
- });
892
- return t && t.color ? t.color : i;
893
- }
894
- return i;
592
+ function Qt(e) {
593
+ return mr(e, Z(), We);
895
594
  }
896
- renderLoader() {
897
- return /* @__PURE__ */ b(U, { className: "loading", children: /* @__PURE__ */ b(
898
- Q,
899
- {
900
- basic: !0,
901
- padded: !0,
902
- textAlign: "center",
903
- style: { margin: "30px" },
904
- children: /* @__PURE__ */ b(ee, { active: !0, inverted: !0, children: /* @__PURE__ */ b(te, { size: "medium" }) })
905
- }
906
- ) });
595
+ function er() {
596
+ return /* @__PURE__ */ p(Qe, { className: "loading", children: /* @__PURE__ */ p(sr, { basic: !0, padded: !0, textAlign: "center", style: { margin: "30px" }, children: /* @__PURE__ */ p(ir, { active: !0, inverted: !0, children: /* @__PURE__ */ p(cr, { size: "medium" }) }) }) });
907
597
  }
908
- noMapSelected() {
909
- return /* @__PURE__ */ M(N, { icon: !0, warning: !0, children: [
910
- /* @__PURE__ */ b(E, { name: "map outline" }),
911
- /* @__PURE__ */ M(N.Content, { children: [
912
- /* @__PURE__ */ b(N.Header, { children: "No map selected" }),
598
+ function tr() {
599
+ return /* @__PURE__ */ b(xe, { icon: !0, warning: !0, children: [
600
+ /* @__PURE__ */ p(te, { name: "map outline" }),
601
+ /* @__PURE__ */ b(xe.Content, { children: [
602
+ /* @__PURE__ */ p(xe.Header, { children: "No map selected" }),
913
603
  "Pick one from the list in the ",
914
- /* @__PURE__ */ b("strong", { children: "Map Layers" }),
604
+ /* @__PURE__ */ p("strong", { children: "Map Layers" }),
915
605
  " section."
916
606
  ] })
917
607
  ] });
918
608
  }
919
- render() {
920
- let {
921
- app: e,
922
- legendTitle: s,
923
- nationalAverageLabel: i,
924
- intl: o,
925
- zoomEnabled: t,
926
- transformedData: a,
927
- measureSelectorLabel: n,
928
- valueFormat: l,
929
- showOverallValue: r,
930
- unique: h,
931
- highlightedLocation: p,
932
- labelFontColor: d,
933
- legendFontSize: u,
934
- editing: m,
935
- highlightedLocLabelFormat: v,
936
- noDataText: c
937
- } = this.props;
938
- t || (t = !!["mobile", "tablet", "midTablet"].includes(
939
- T()
940
- ));
941
- const f = this.getAvg(), y = this.getFilters(), I = this.getHighlightedLocationData(), A = {
942
- backgroundColor: this.getHighlightedLocationColor(I),
943
- color: d,
944
- fontSize: u + "px"
609
+ M.current.zoomed = Dt, M.current.zoomEnd = Pt, M.current.getFeatures = X, M.current.updateFeatures = Xe, M.current.getMapId = g, fe.current || (fe.current = () => {
610
+ let e = null;
611
+ clearTimeout(e), e = setTimeout(() => {
612
+ c.select(M.current.getMapId()).selectAll(".map-labels-container").size() > 0 || M.current.updateFeatures(M.current.getFeatures(), !1);
613
+ }, 300);
614
+ }), et(() => {
615
+ const e = fe.current;
616
+ return window.addEventListener("scroll", e, { passive: !0 }), window.addEventListener("touchmove", e, { passive: !0 }), Ge(), w.current = c.select("body").append("div").style("position", "absolute").style("visibility", "hidden").style("pointer-events", "none"), () => {
617
+ var t;
618
+ window.removeEventListener("scroll", e), window.removeEventListener("touchmove", e), (t = w.current) == null || t.remove();
945
619
  };
946
- m && (A.marginTop = "25px");
947
- const L = () => /* @__PURE__ */ M(U, { fluid: !0, className: "footnote ", children: [
948
- /* @__PURE__ */ M(S, { columns: 2, children: [
949
- e !== "csv" && r && /* @__PURE__ */ b(S.Column, { textAlign: "left", width: 4, children: /* @__PURE__ */ M("div", { className: "national-average-div", children: [
950
- /* @__PURE__ */ b("span", { className: "national-avg-label", children: i }),
951
- /* @__PURE__ */ b("span", { className: "national-avg-value", children: k(
952
- l,
953
- { value: f },
954
- o
955
- ) })
956
- ] }) }),
957
- /* @__PURE__ */ b(
958
- S.Column,
959
- {
960
- textAlign: "right",
961
- width: e !== "csv" && r ? 12 : 16,
962
- children: /* @__PURE__ */ b(
963
- oe,
964
- {
965
- filteredBreaks: this.getBreaks(),
966
- formattedLegendTitle: k(
967
- s,
968
- { ...y },
969
- o
970
- ),
971
- selectedMeasure: this.state.selectedMeasure,
972
- ...this.props
973
- }
974
- )
975
- }
976
- )
977
- ] }),
978
- /* @__PURE__ */ b("div", { className: "measure-selector", children: /* @__PURE__ */ M("ul", { children: [
979
- n && /* @__PURE__ */ b("li", { children: /* @__PURE__ */ b("span", { className: "label", children: n }) }),
980
- a && a.measures && a.measures.length > 1 && a.measures.map((x) => /* @__PURE__ */ M("li", { onClick: this.selectedMeasureChanged.bind(this, x), children: [
981
- /* @__PURE__ */ b(
982
- "input",
620
+ }, []), et(() => {
621
+ if (!$e.current) {
622
+ $e.current = !0, de.current = O, me.current = { selectedMeasure: R, layers: B, selectedPolygon: $ };
623
+ return;
624
+ }
625
+ const e = de.current, t = me.current;
626
+ if (P) {
627
+ const i = [], l = [], r = e.appliedFilters;
628
+ r && Object.keys(r).forEach((a) => {
629
+ r[a] != null && r[a] instanceof Array && i.push(
630
+ ...r[a].filter((s) => s != Number.MIN_SAFE_INTEGER)
631
+ );
632
+ }), m && Object.keys(m).forEach((a) => {
633
+ m[a] != null && m[a] instanceof Array && l.push(
634
+ ...m[a].filter((s) => s != Number.MIN_SAFE_INTEGER)
635
+ );
636
+ }), i.length > 0 && l.length == 0 && Je();
637
+ }
638
+ w.current.style("visibility", "hidden"), e.enabledLayers.length != D.length && Ge();
639
+ const o = X();
640
+ e.center !== le && (E.current = null, v.current.scale(ke).center(le).translate([ge() / 2, he() / 2]));
641
+ const n = Vt(e);
642
+ Xt(o, n), B && u && (u != e.transformedData || B != t.layers || R != t.selectedMeasure || $ != t.selectedPolygon || e.mainLayerId !== W || JSON.stringify(e.enabledLayers) != JSON.stringify(D)) && Xe(X(), n), de.current = O, me.current = { selectedMeasure: R, layers: B, selectedPolygon: $ };
643
+ });
644
+ let be = se;
645
+ be || (be = !!["mobile", "tablet", "midTablet"].includes(
646
+ N()
647
+ ));
648
+ const rr = Zt(), lr = we(m), q = qt(), Ye = {
649
+ backgroundColor: Qt(q),
650
+ color: Oe,
651
+ fontSize: dt + "px"
652
+ };
653
+ j && (Ye.marginTop = "25px");
654
+ const qe = () => /* @__PURE__ */ b(Qe, { fluid: !0, className: "footnote ", children: [
655
+ /* @__PURE__ */ b(Fe, { columns: 2, children: [
656
+ O.app !== "csv" && ze && /* @__PURE__ */ p(Fe.Column, { textAlign: "left", width: 4, children: /* @__PURE__ */ b("div", { className: "national-average-div", children: [
657
+ /* @__PURE__ */ p("span", { className: "national-avg-label", children: Tt }),
658
+ /* @__PURE__ */ p("span", { className: "national-avg-value", children: k(Ce, { value: rr }, F) })
659
+ ] }) }),
660
+ /* @__PURE__ */ p(
661
+ Fe.Column,
662
+ {
663
+ textAlign: "right",
664
+ width: O.app !== "csv" && ze ? 12 : 16,
665
+ children: /* @__PURE__ */ p(
666
+ ur,
983
667
  {
984
- checked: this.getSelectedMeasure() === x,
985
- type: "radio",
986
- value: x
668
+ filteredBreaks: Z(),
669
+ formattedLegendTitle: k(Mt, { ...lr }, F),
670
+ selectedMeasure: R,
671
+ ...O
987
672
  }
988
- ),
989
- /* @__PURE__ */ b("label", { children: a.measureLabelMap[x] || x })
990
- ] }))
991
- ] }) })
992
- ] });
993
- return /* @__PURE__ */ M("div", { className: "map component wp-data-viz-map", ref: this.mapContainer, children: [
994
- this.state.layersLoading && (m ? this.noMapSelected() : this.renderLoader()),
995
- !this.state.layersLoading && /* @__PURE__ */ M(R, { children: [
996
- !$ && /* @__PURE__ */ b(L, {}),
997
- /* @__PURE__ */ M(
998
- "div",
673
+ )
674
+ }
675
+ )
676
+ ] }),
677
+ /* @__PURE__ */ p("div", { className: "measure-selector", children: /* @__PURE__ */ b("ul", { children: [
678
+ Ie && /* @__PURE__ */ p("li", { children: /* @__PURE__ */ p("span", { className: "label", children: Ie }) }),
679
+ u && u.measures && u.measures.length > 1 && u.measures.map((e) => /* @__PURE__ */ b("li", { onClick: () => Yt(e), children: [
680
+ /* @__PURE__ */ p(
681
+ "input",
999
682
  {
1000
- className: "map wrapper scaling-svg-container " + h,
1001
- style: {
1002
- height: this.props.height - ce[T()] + "px"
1003
- },
1004
- children: [
1005
- I ? /* @__PURE__ */ b(
1006
- "div",
1007
- {
1008
- className: "highlighted-loc-info",
1009
- style: A,
1010
- children: /* @__PURE__ */ M("span", { children: [
1011
- " ",
1012
- k(
1013
- v,
1014
- {
1015
- value: I.value,
1016
- locationName: this.getTranslatedHighlightedLocationName() || I.label,
1017
- measureName: I.measure
1018
- },
1019
- o
1020
- )
1021
- ] })
1022
- }
1023
- ) : /* @__PURE__ */ b(R, { children: " " }),
1024
- (m || t) && !de && /* @__PURE__ */ M("div", { className: "control panel ignore", children: [
1025
- /* @__PURE__ */ b("div", { className: "zoom plus", onClick: this.onZoomIn, children: /* @__PURE__ */ b(E, { name: "plus", size: "large" }) }),
1026
- /* @__PURE__ */ b("div", { className: "zoom minus", onClick: this.onZoomOut, children: /* @__PURE__ */ b(E, { name: "minus", size: "large" }) }),
1027
- /* @__PURE__ */ b(
1028
- se,
1029
- {
1030
- content: /* @__PURE__ */ b(
1031
- K,
1032
- {
1033
- id: "map.reset.tooltip",
1034
- defaultMessage: "Reset zoom"
1035
- }
1036
- ),
1037
- trigger: /* @__PURE__ */ b("div", { className: "reset", onClick: this.onReset, children: /* @__PURE__ */ b(E, { name: "repeat", size: "large" }) })
1038
- }
1039
- )
1040
- ] })
1041
- ]
683
+ checked: z() === e,
684
+ type: "radio",
685
+ value: e,
686
+ readOnly: !0
1042
687
  }
1043
688
  ),
1044
- $ && /* @__PURE__ */ b(L, {})
1045
- ] })
1046
- ] });
1047
- }
689
+ /* @__PURE__ */ p("label", { children: u.measureLabelMap[e] || e })
690
+ ] }, e))
691
+ ] }) })
692
+ ] });
693
+ return /* @__PURE__ */ b("div", { className: "map component wp-data-viz-map", ref: pe, children: [
694
+ je && (j ? tr() : er()),
695
+ !je && /* @__PURE__ */ b(Ke, { children: [
696
+ !at && /* @__PURE__ */ p(qe, {}),
697
+ /* @__PURE__ */ b(
698
+ "div",
699
+ {
700
+ className: "map wrapper scaling-svg-container " + Me,
701
+ style: { height: Ne - dr[N()] + "px" },
702
+ children: [
703
+ q ? /* @__PURE__ */ p("div", { className: "highlighted-loc-info", style: Ye, children: /* @__PURE__ */ b("span", { children: [
704
+ " ",
705
+ k(
706
+ Ft,
707
+ {
708
+ value: q.value,
709
+ locationName: Kt() || q.label,
710
+ measureName: q.measure
711
+ },
712
+ F
713
+ )
714
+ ] }) }) : /* @__PURE__ */ p(Ke, { children: " " }),
715
+ (j || be) && !wr && /* @__PURE__ */ b("div", { className: "control panel ignore", children: [
716
+ /* @__PURE__ */ p("div", { className: "zoom plus", onClick: Ot, children: /* @__PURE__ */ p(te, { name: "plus", size: "large" }) }),
717
+ /* @__PURE__ */ p("div", { className: "zoom minus", onClick: Wt, children: /* @__PURE__ */ p(te, { name: "minus", size: "large" }) }),
718
+ /* @__PURE__ */ p(
719
+ or,
720
+ {
721
+ content: /* @__PURE__ */ p(ar, { id: "map.reset.tooltip", defaultMessage: "Reset zoom" }),
722
+ trigger: /* @__PURE__ */ p("div", { className: "reset", onClick: Je, children: /* @__PURE__ */ p(te, { name: "repeat", size: "large" }) })
723
+ }
724
+ )
725
+ ] })
726
+ ]
727
+ }
728
+ ),
729
+ at && /* @__PURE__ */ p(qe, {})
730
+ ] })
731
+ ] });
1048
732
  }
1049
- const Te = Y(ue);
733
+ const Sr = nr(Ar);
1050
734
  export {
1051
- Te as default,
1052
- O as getTranslatedItemLabel
735
+ Sr as default,
736
+ fr as getTranslatedItemLabel
1053
737
  };