@hybridcore/ui 1.1.0 → 1.1.2

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.
Files changed (48) hide show
  1. package/dist/{ButtonBase-B6WYZgVU.js → ButtonBase-BYmh3G5j.js} +3 -3
  2. package/dist/{Checkbox-CxbQ9tJ5.js → Checkbox-DostZSwR.js} +1 -1
  3. package/dist/{Button-BZR43NHz.js → DialogContent-2aPOjKE7.js} +1252 -1252
  4. package/dist/{FormControl-C4PmH1vh.js → FormControl-BiAFm76F.js} +1 -1
  5. package/dist/{IconButton-CKHPuOyh.js → IconButton-CQJ8wZE8.js} +1 -1
  6. package/dist/{Input-CH_JyT5B.js → Input-Bf5G3tFN.js} +2 -2
  7. package/dist/{OutlinedInput-gnp48tDo.js → OutlinedInput-BEVE8VZQ.js} +2 -2
  8. package/dist/{Select-DOyHt8I_.js → Select-DxpxZbJp.js} +8 -8
  9. package/dist/{Source-Bo1Eq6y-.js → Source-CnCcu5UP.js} +275 -275
  10. package/dist/{Text-DVP2PrYM.js → Text-BT5kPHOo.js} +1156 -1156
  11. package/dist/assets/index.css +1 -1
  12. package/dist/assets/index2.css +1 -1
  13. package/dist/components/confirm/dialog.js +1 -1
  14. package/dist/components/context-menu/index.js +642 -642
  15. package/dist/components/data-management/instance-form/components/composite-list/index.js +1 -1
  16. package/dist/components/data-management/instance-form/components/variable/index.js +4 -4
  17. package/dist/components/data-management/instance-form/components/variables/index.js +1 -1
  18. package/dist/components/geometry-picker/coordinate/index.js +1 -1
  19. package/dist/components/geometry-picker/edit/index.js +3 -3
  20. package/dist/components/geometry-picker/geometry/index.js +1 -1
  21. package/dist/components/geometry-picker/index.js +2 -2
  22. package/dist/components/geometry-picker/kml/index.js +7 -7
  23. package/dist/components/geometry-picker/map/index.js +1 -1
  24. package/dist/components/geometry-picker/map/logic.js +4 -4
  25. package/dist/components/geometry-picker/map/style.js +1 -1
  26. package/dist/components/icon-button/index.js +1 -1
  27. package/dist/components/map/helpers/mapbox.js +1 -1
  28. package/dist/components/map/helpers/ol.js +4 -4
  29. package/dist/components/map/index.js +6 -28
  30. package/dist/components/map/logic.js +62 -62
  31. package/dist/components/map/styled.js +2 -2
  32. package/dist/components/phone-input/index.js +1 -1
  33. package/dist/components/search-input/index.js +3 -3
  34. package/dist/components/tree-select/index.js +3 -3
  35. package/dist/components/treeview-filter/index.js +4 -4
  36. package/dist/components/treeview-filter/item/index.js +1 -1
  37. package/dist/components/treeview-filter/item-label/index.js +1 -1
  38. package/dist/{Object-DBPgar-D.js → has-9_asnBxn.js} +108 -108
  39. package/dist/{index-DHFb1Qpn.js → index-Bw_m9ult.js} +7 -7
  40. package/dist/index-IvOfmM1F.js +34 -0
  41. package/dist/{index-BQE8B4sc.js → index-wW2D1aTG.js} +2 -2
  42. package/dist/{List-BX_5LP1i.js → listItemTextClasses-BvXFz-Oc.js} +16 -16
  43. package/dist/main.d.ts +677 -6
  44. package/dist/main.js +41 -2
  45. package/dist/{ol-CMEkXXLJ.js → ol-DXmSLlWv.js} +8 -8
  46. package/dist/{styled-B22KrhDR.js → styled-C43K9x7T.js} +1 -1
  47. package/dist/{utils-C13eMoWa.js → utils-DLpkeyhZ.js} +1 -1
  48. package/package.json +1 -1
@@ -1,225 +1,4 @@
1
- import { d as m, f as w, b as v, W as j, h as ae, c as le, i as N, I as he, u as ce, E as O, j as oe, g as ue } from "./Object-DBPgar-D.js";
2
- const _ = {
3
- IDLE: 0,
4
- LOADING: 1,
5
- LOADED: 2,
6
- ERROR: 3,
7
- EMPTY: 4
8
- };
9
- function Me(i) {
10
- return i[0] > 0 && i[1] > 0;
11
- }
12
- function x(i, e) {
13
- return Array.isArray(i) ? i : (e === void 0 ? e = [i, i] : (e[0] = i, e[1] = i), e);
14
- }
15
- class E {
16
- /**
17
- * @param {Options} options Options.
18
- */
19
- constructor(e) {
20
- this.opacity_ = e.opacity, this.rotateWithView_ = e.rotateWithView, this.rotation_ = e.rotation, this.scale_ = e.scale, this.scaleArray_ = x(e.scale), this.displacement_ = e.displacement, this.declutterMode_ = e.declutterMode;
21
- }
22
- /**
23
- * Clones the style.
24
- * @return {ImageStyle} The cloned style.
25
- * @api
26
- */
27
- clone() {
28
- const e = this.getScale();
29
- return new E({
30
- opacity: this.getOpacity(),
31
- scale: Array.isArray(e) ? e.slice() : e,
32
- rotation: this.getRotation(),
33
- rotateWithView: this.getRotateWithView(),
34
- displacement: this.getDisplacement().slice(),
35
- declutterMode: this.getDeclutterMode()
36
- });
37
- }
38
- /**
39
- * Get the symbolizer opacity.
40
- * @return {number} Opacity.
41
- * @api
42
- */
43
- getOpacity() {
44
- return this.opacity_;
45
- }
46
- /**
47
- * Determine whether the symbolizer rotates with the map.
48
- * @return {boolean} Rotate with map.
49
- * @api
50
- */
51
- getRotateWithView() {
52
- return this.rotateWithView_;
53
- }
54
- /**
55
- * Get the symoblizer rotation.
56
- * @return {number} Rotation.
57
- * @api
58
- */
59
- getRotation() {
60
- return this.rotation_;
61
- }
62
- /**
63
- * Get the symbolizer scale.
64
- * @return {number|import("../size.js").Size} Scale.
65
- * @api
66
- */
67
- getScale() {
68
- return this.scale_;
69
- }
70
- /**
71
- * Get the symbolizer scale array.
72
- * @return {import("../size.js").Size} Scale array.
73
- */
74
- getScaleArray() {
75
- return this.scaleArray_;
76
- }
77
- /**
78
- * Get the displacement of the shape
79
- * @return {Array<number>} Shape's center displacement
80
- * @api
81
- */
82
- getDisplacement() {
83
- return this.displacement_;
84
- }
85
- /**
86
- * Get the declutter mode of the shape
87
- * @return {"declutter"|"obstacle"|"none"|undefined} Shape's declutter mode
88
- * @api
89
- */
90
- getDeclutterMode() {
91
- return this.declutterMode_;
92
- }
93
- /**
94
- * Get the anchor point in pixels. The anchor determines the center point for the
95
- * symbolizer.
96
- * @abstract
97
- * @return {Array<number>} Anchor.
98
- */
99
- getAnchor() {
100
- return m();
101
- }
102
- /**
103
- * Get the image element for the symbolizer.
104
- * @abstract
105
- * @param {number} pixelRatio Pixel ratio.
106
- * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
107
- */
108
- getImage(e) {
109
- return m();
110
- }
111
- /**
112
- * @abstract
113
- * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
114
- */
115
- getHitDetectionImage() {
116
- return m();
117
- }
118
- /**
119
- * Get the image pixel ratio.
120
- * @param {number} pixelRatio Pixel ratio.
121
- * @return {number} Pixel ratio.
122
- */
123
- getPixelRatio(e) {
124
- return 1;
125
- }
126
- /**
127
- * @abstract
128
- * @return {import("../ImageState.js").default} Image state.
129
- */
130
- getImageState() {
131
- return m();
132
- }
133
- /**
134
- * @abstract
135
- * @return {import("../size.js").Size} Image size.
136
- */
137
- getImageSize() {
138
- return m();
139
- }
140
- /**
141
- * Get the origin of the symbolizer.
142
- * @abstract
143
- * @return {Array<number>} Origin.
144
- */
145
- getOrigin() {
146
- return m();
147
- }
148
- /**
149
- * Get the size of the symbolizer (in pixels).
150
- * @abstract
151
- * @return {import("../size.js").Size} Size.
152
- */
153
- getSize() {
154
- return m();
155
- }
156
- /**
157
- * Set the displacement.
158
- *
159
- * @param {Array<number>} displacement Displacement.
160
- * @api
161
- */
162
- setDisplacement(e) {
163
- this.displacement_ = e;
164
- }
165
- /**
166
- * Set the opacity.
167
- *
168
- * @param {number} opacity Opacity.
169
- * @api
170
- */
171
- setOpacity(e) {
172
- this.opacity_ = e;
173
- }
174
- /**
175
- * Set whether to rotate the style with the view.
176
- *
177
- * @param {boolean} rotateWithView Rotate with map.
178
- * @api
179
- */
180
- setRotateWithView(e) {
181
- this.rotateWithView_ = e;
182
- }
183
- /**
184
- * Set the rotation.
185
- *
186
- * @param {number} rotation Rotation.
187
- * @api
188
- */
189
- setRotation(e) {
190
- this.rotation_ = e;
191
- }
192
- /**
193
- * Set the scale.
194
- *
195
- * @param {number|import("../size.js").Size} scale Scale.
196
- * @api
197
- */
198
- setScale(e) {
199
- this.scale_ = e, this.scaleArray_ = x(e);
200
- }
201
- /**
202
- * @abstract
203
- * @param {function(import("../events/Event.js").default): void} listener Listener function.
204
- */
205
- listenImageChange(e) {
206
- m();
207
- }
208
- /**
209
- * Load not yet loaded URI.
210
- * @abstract
211
- */
212
- load() {
213
- m();
214
- }
215
- /**
216
- * @abstract
217
- * @param {function(import("../events/Event.js").default): void} listener Listener function.
218
- */
219
- unlistenImageChange(e) {
220
- m();
221
- }
222
- }
1
+ import { d as w, b as v, W as j, f as ae, c as le, h as N, I as he, u as ce, E as O, i as m, j as oe, g as ue } from "./has-9_asnBxn.js";
223
2
  const ge = /^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i, fe = /^([a-z]*)$|^hsla?\(.*\)$/i;
224
3
  function $(i) {
225
4
  return typeof i == "string" ? i : ee(i);
@@ -284,49 +63,70 @@ function ee(i) {
284
63
  const s = i[3] === void 0 ? 1 : Math.round(i[3] * 100) / 100;
285
64
  return "rgba(" + e + "," + t + "," + n + "," + s + ")";
286
65
  }
287
- function X(i) {
288
- return Array.isArray(i) ? ee(i) : i;
289
- }
290
- function L(i, e, t, n) {
291
- let s;
292
- return t && t.length ? s = t.shift() : j ? s = new OffscreenCanvas(i || 300, e || 300) : s = document.createElement("canvas"), i && (s.width = i), e && (s.height = e), /** @type {CanvasRenderingContext2D} */
293
- s.getContext("2d", n);
294
- }
295
- function Ee(i) {
296
- const e = i.canvas;
297
- e.width = 1, e.height = 1, i.clearRect(0, 0, 1, 1);
298
- }
299
- function Re(i, e) {
300
- const t = e.parentNode;
301
- t && t.replaceChild(i, e);
302
- }
303
- function be(i) {
304
- return i && i.parentNode ? i.parentNode.removeChild(i) : null;
305
- }
306
- function Fe(i) {
307
- for (; i.lastChild; )
308
- i.removeChild(i.lastChild);
309
- }
310
- function We(i, e) {
311
- const t = i.childNodes;
312
- for (let n = 0; ; ++n) {
313
- const s = t[n], r = e[n];
314
- if (!s && !r)
315
- break;
316
- if (s !== r) {
317
- if (!s) {
318
- i.appendChild(r);
319
- continue;
320
- }
321
- if (!r) {
322
- i.removeChild(s), --n;
323
- continue;
324
- }
325
- i.insertBefore(r, s);
326
- }
66
+ class ye {
67
+ constructor() {
68
+ this.cache_ = {}, this.cacheSize_ = 0, this.maxCacheSize_ = 32;
69
+ }
70
+ /**
71
+ * FIXME empty description for jsdoc
72
+ */
73
+ clear() {
74
+ this.cache_ = {}, this.cacheSize_ = 0;
75
+ }
76
+ /**
77
+ * @return {boolean} Can expire cache.
78
+ */
79
+ canExpireCache() {
80
+ return this.cacheSize_ > this.maxCacheSize_;
81
+ }
82
+ /**
83
+ * FIXME empty description for jsdoc
84
+ */
85
+ expire() {
86
+ if (this.canExpireCache()) {
87
+ let e = 0;
88
+ for (const t in this.cache_) {
89
+ const n = this.cache_[t];
90
+ !(e++ & 3) && !n.hasListener() && (delete this.cache_[t], --this.cacheSize_);
91
+ }
92
+ }
93
+ }
94
+ /**
95
+ * @param {string} src Src.
96
+ * @param {?string} crossOrigin Cross origin.
97
+ * @param {import("../color.js").Color} color Color.
98
+ * @return {import("./IconImage.js").default} Icon image.
99
+ */
100
+ get(e, t, n) {
101
+ const s = X(e, t, n);
102
+ return s in this.cache_ ? this.cache_[s] : null;
103
+ }
104
+ /**
105
+ * @param {string} src Src.
106
+ * @param {?string} crossOrigin Cross origin.
107
+ * @param {import("../color.js").Color} color Color.
108
+ * @param {import("./IconImage.js").default} iconImage Icon image.
109
+ */
110
+ set(e, t, n, s) {
111
+ const r = X(e, t, n);
112
+ this.cache_[r] = s, ++this.cacheSize_;
113
+ }
114
+ /**
115
+ * Set the cache size of the icon cache. Default is `32`. Change this value when
116
+ * your map uses more than 32 different icon images and you are not caching icon
117
+ * styles on the application level.
118
+ * @param {number} maxCacheSize Cache max size.
119
+ * @api
120
+ */
121
+ setSize(e) {
122
+ this.maxCacheSize_ = e, this.expire();
327
123
  }
328
124
  }
329
- const Te = "ol-hidden", Pe = "ol-unselectable", Ve = "ol-control", He = "ol-collapsed", ye = new RegExp(
125
+ function X(i, e, t) {
126
+ const n = t ? $(t) : "null";
127
+ return e + ":" + i + ":" + n;
128
+ }
129
+ const U = new ye(), Me = "ol-hidden", Ee = "ol-unselectable", Re = "ol-control", be = "ol-collapsed", Se = new RegExp(
330
130
  [
331
131
  "^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)",
332
132
  "(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)",
@@ -337,7 +137,7 @@ const Te = "ol-hidden", Pe = "ol-unselectable", Ve = "ol-control", He = "ol-coll
337
137
  `?\\s*([-,\\"\\'\\sa-z]+?)\\s*$`
338
138
  ].join(""),
339
139
  "i"
340
- ), U = [
140
+ ), Y = [
341
141
  "style",
342
142
  "variant",
343
143
  "weight",
@@ -345,7 +145,7 @@ const Te = "ol-hidden", Pe = "ol-unselectable", Ve = "ol-control", He = "ol-coll
345
145
  "lineHeight",
346
146
  "family"
347
147
  ], te = function(i) {
348
- const e = i.match(ye);
148
+ const e = i.match(Se);
349
149
  if (!e)
350
150
  return null;
351
151
  const t = (
@@ -358,25 +158,65 @@ const Te = "ol-hidden", Pe = "ol-unselectable", Ve = "ol-control", He = "ol-coll
358
158
  variant: "normal"
359
159
  }
360
160
  );
361
- for (let n = 0, s = U.length; n < s; ++n) {
161
+ for (let n = 0, s = Y.length; n < s; ++n) {
362
162
  const r = e[n + 1];
363
- r !== void 0 && (t[U[n]] = r);
163
+ r !== void 0 && (t[Y[n]] = r);
364
164
  }
365
165
  return t.families = t.family.split(/,\s?/), t;
366
- }, Be = "10px sans-serif", Y = "#000", Ne = "round", Je = [], Xe = 0, G = "round", Se = 10, Ie = "#000", Ue = "center", Ye = "middle", Ge = [0, 0, 0, 0], De = 1, y = new ae();
166
+ };
167
+ function L(i, e, t, n) {
168
+ let s;
169
+ return t && t.length ? s = t.shift() : j ? s = new OffscreenCanvas(i || 300, e || 300) : s = document.createElement("canvas"), i && (s.width = i), e && (s.height = e), /** @type {CanvasRenderingContext2D} */
170
+ s.getContext("2d", n);
171
+ }
172
+ function Fe(i) {
173
+ const e = i.canvas;
174
+ e.width = 1, e.height = 1, i.clearRect(0, 0, 1, 1);
175
+ }
176
+ function We(i, e) {
177
+ const t = e.parentNode;
178
+ t && t.replaceChild(i, e);
179
+ }
180
+ function Te(i) {
181
+ return i && i.parentNode ? i.parentNode.removeChild(i) : null;
182
+ }
183
+ function Pe(i) {
184
+ for (; i.lastChild; )
185
+ i.removeChild(i.lastChild);
186
+ }
187
+ function Ve(i, e) {
188
+ const t = i.childNodes;
189
+ for (let n = 0; ; ++n) {
190
+ const s = t[n], r = e[n];
191
+ if (!s && !r)
192
+ break;
193
+ if (s !== r) {
194
+ if (!s) {
195
+ i.appendChild(r);
196
+ continue;
197
+ }
198
+ if (!r) {
199
+ i.removeChild(s), --n;
200
+ continue;
201
+ }
202
+ i.insertBefore(r, s);
203
+ }
204
+ }
205
+ }
206
+ const He = "10px sans-serif", G = "#000", Be = "round", Ne = [], Je = 0, p = "round", Ie = 10, De = "#000", Xe = "center", Ue = "middle", Ye = [0, 0, 0, 0], we = 1, y = new ae();
367
207
  let D = null, T;
368
- const P = {}, pe = function() {
208
+ const P = {}, Ge = function() {
369
209
  const e = "32px ", t = ["monospace", "serif"], n = t.length, s = "wmytzilWMYTZIL@#/&?$%10";
370
210
  let r, a;
371
211
  function l(c, h, u) {
372
212
  let f = !0;
373
213
  for (let g = 0; g < n; ++g) {
374
214
  const d = t[g];
375
- if (a = M(
215
+ if (a = x(
376
216
  c + " " + h + " " + e + d,
377
217
  s
378
218
  ), u != d) {
379
- const I = M(
219
+ const I = x(
380
220
  c + " " + h + " " + e + u + "," + d,
381
221
  s
382
222
  );
@@ -407,7 +247,7 @@ const P = {}, pe = function() {
407
247
  y.get(I) === void 0 && (y.set(I, 100, !0), l(h.style, h.weight, d) || (y.set(I, 0, !0), r === void 0 && (r = setInterval(o, 32))));
408
248
  }
409
249
  };
410
- }(), we = /* @__PURE__ */ function() {
250
+ }(), Ae = /* @__PURE__ */ function() {
411
251
  let i;
412
252
  return function(e) {
413
253
  let t = P[e];
@@ -425,17 +265,17 @@ const P = {}, pe = function() {
425
265
  function ie(i, e) {
426
266
  return D || (D = L(1, 1)), i != T && (D.font = i, T = D.font), D.measureText(e);
427
267
  }
428
- function M(i, e) {
268
+ function x(i, e) {
429
269
  return ie(i, e).width;
430
270
  }
431
- function qe(i, e, t) {
271
+ function pe(i, e, t) {
432
272
  if (e in t)
433
273
  return t[e];
434
274
  const n = e.split(`
435
- `).reduce((s, r) => Math.max(s, M(i, r)), 0);
275
+ `).reduce((s, r) => Math.max(s, x(i, r)), 0);
436
276
  return t[e] = n, n;
437
277
  }
438
- function Ze(i, e) {
278
+ function qe(i, e) {
439
279
  const t = [], n = [], s = [];
440
280
  let r = 0, a = 0, l = 0, o = 0;
441
281
  for (let c = 0, h = e.length; c <= h; c += 2) {
@@ -445,16 +285,16 @@ function Ze(i, e) {
445
285
  r = Math.max(r, a), s.push(a), a = 0, l += o;
446
286
  continue;
447
287
  }
448
- const f = e[c + 1] || i.font, g = M(f, u);
288
+ const f = e[c + 1] || i.font, g = x(f, u);
449
289
  t.push(g), a += g;
450
- const d = we(f);
290
+ const d = Ae(f);
451
291
  n.push(d), o = Math.max(o, d);
452
292
  }
453
293
  return { width: r, height: l, widths: t, heights: n, lineWidths: s };
454
294
  }
455
- function Ke(i, e, t, n, s, r, a, l, o, c, h) {
295
+ function Ze(i, e, t, n, s, r, a, l, o, c, h) {
456
296
  i.save(), t !== 1 && (i.globalAlpha *= t), e && i.setTransform.apply(i, e), /** @type {*} */
457
- n.contextInstructions ? (i.translate(o, c), i.scale(h[0], h[1]), Ae(
297
+ n.contextInstructions ? (i.translate(o, c), i.scale(h[0], h[1]), Ce(
458
298
  /** @type {Label} */
459
299
  n,
460
300
  i
@@ -482,7 +322,7 @@ function Ke(i, e, t, n, s, r, a, l, o, c, h) {
482
322
  l * h[1]
483
323
  ), i.restore();
484
324
  }
485
- function Ae(i, e) {
325
+ function Ce(i, e) {
486
326
  const t = i.contextInstructions;
487
327
  for (let n = 0, s = t.length; n < s; n += 2)
488
328
  Array.isArray(t[n + 1]) ? e[t[n]].apply(
@@ -490,438 +330,739 @@ function Ae(i, e) {
490
330
  t[n + 1]
491
331
  ) : e[t[n]] = t[n + 1];
492
332
  }
493
- class V extends E {
333
+ function Ke(i) {
334
+ return i[0] > 0 && i[1] > 0;
335
+ }
336
+ function M(i, e) {
337
+ return Array.isArray(i) ? i : (e === void 0 ? e = [i, i] : (e[0] = i, e[1] = i), e);
338
+ }
339
+ const _ = {
340
+ IDLE: 0,
341
+ LOADING: 1,
342
+ LOADED: 2,
343
+ ERROR: 3,
344
+ EMPTY: 4
345
+ };
346
+ function ke(i, e, t) {
347
+ const n = (
348
+ /** @type {HTMLImageElement} */
349
+ i
350
+ );
351
+ let s = !0, r = !1, a = !1;
352
+ const l = [
353
+ N(n, O.LOAD, function() {
354
+ a = !0, r || e();
355
+ })
356
+ ];
357
+ return n.src && he ? (r = !0, n.decode().then(function() {
358
+ s && e();
359
+ }).catch(function(o) {
360
+ s && (a ? e() : t());
361
+ })) : l.push(N(n, O.ERROR, t)), function() {
362
+ s = !1, l.forEach(ce);
363
+ };
364
+ }
365
+ class C {
494
366
  /**
495
- * @param {Options} options Options.
367
+ * @param {Options} [options] Options.
496
368
  */
497
369
  constructor(e) {
498
- const t = e.rotateWithView !== void 0 ? e.rotateWithView : !1;
499
- super({
500
- opacity: 1,
501
- rotateWithView: t,
502
- rotation: e.rotation !== void 0 ? e.rotation : 0,
503
- scale: e.scale !== void 0 ? e.scale : 1,
504
- displacement: e.displacement !== void 0 ? e.displacement : [0, 0],
505
- declutterMode: e.declutterMode
506
- }), this.canvas_ = void 0, this.hitDetectionCanvas_ = null, this.fill_ = e.fill !== void 0 ? e.fill : null, this.origin_ = [0, 0], this.points_ = e.points, this.radius_ = e.radius !== void 0 ? e.radius : e.radius1, this.radius2_ = e.radius2, this.angle_ = e.angle !== void 0 ? e.angle : 0, this.stroke_ = e.stroke !== void 0 ? e.stroke : null, this.size_ = null, this.renderOptions_ = null, this.render();
370
+ e = e || {}, this.color_ = e.color !== void 0 ? e.color : null;
507
371
  }
508
372
  /**
509
- * Clones the style.
510
- * @return {RegularShape} The cloned style.
373
+ * Clones the style. The color is not cloned if it is an {@link module:ol/colorlike~ColorLike}.
374
+ * @return {Fill} The cloned style.
511
375
  * @api
512
376
  */
513
377
  clone() {
514
- const e = this.getScale(), t = new V({
515
- fill: this.getFill() ? this.getFill().clone() : void 0,
516
- points: this.getPoints(),
517
- radius: this.getRadius(),
518
- radius2: this.getRadius2(),
519
- angle: this.getAngle(),
520
- stroke: this.getStroke() ? this.getStroke().clone() : void 0,
521
- rotation: this.getRotation(),
522
- rotateWithView: this.getRotateWithView(),
523
- scale: Array.isArray(e) ? e.slice() : e,
524
- displacement: this.getDisplacement().slice(),
525
- declutterMode: this.getDeclutterMode()
378
+ const e = this.getColor();
379
+ return new C({
380
+ color: Array.isArray(e) ? e.slice() : e || void 0
526
381
  });
527
- return t.setOpacity(this.getOpacity()), t;
528
382
  }
529
383
  /**
530
- * Get the anchor point in pixels. The anchor determines the center point for the
531
- * symbolizer.
532
- * @return {Array<number>} Anchor.
384
+ * Get the fill color.
385
+ * @return {import("../color.js").Color|import("../colorlike.js").ColorLike|null} Color.
533
386
  * @api
534
387
  */
535
- getAnchor() {
536
- const e = this.size_;
537
- if (!e)
538
- return null;
539
- const t = this.getDisplacement(), n = this.getScaleArray();
540
- return [
541
- e[0] / 2 - t[0] / n[0],
542
- e[1] / 2 + t[1] / n[1]
543
- ];
388
+ getColor() {
389
+ return this.color_;
544
390
  }
545
391
  /**
546
- * Get the angle used in generating the shape.
547
- * @return {number} Shape's rotation in radians.
392
+ * Set the color.
393
+ *
394
+ * @param {import("../color.js").Color|import("../colorlike.js").ColorLike|null} color Color.
548
395
  * @api
549
396
  */
550
- getAngle() {
551
- return this.angle_;
397
+ setColor(e) {
398
+ this.color_ = e;
552
399
  }
400
+ }
401
+ class E {
553
402
  /**
554
- * Get the fill style for the shape.
555
- * @return {import("./Fill.js").default} Fill style.
556
- * @api
403
+ * @param {Options} options Options.
557
404
  */
558
- getFill() {
559
- return this.fill_;
405
+ constructor(e) {
406
+ this.opacity_ = e.opacity, this.rotateWithView_ = e.rotateWithView, this.rotation_ = e.rotation, this.scale_ = e.scale, this.scaleArray_ = M(e.scale), this.displacement_ = e.displacement, this.declutterMode_ = e.declutterMode;
560
407
  }
561
408
  /**
562
- * Set the fill style.
563
- * @param {import("./Fill.js").default} fill Fill style.
409
+ * Clones the style.
410
+ * @return {ImageStyle} The cloned style.
564
411
  * @api
565
412
  */
566
- setFill(e) {
567
- this.fill_ = e, this.render();
413
+ clone() {
414
+ const e = this.getScale();
415
+ return new E({
416
+ opacity: this.getOpacity(),
417
+ scale: Array.isArray(e) ? e.slice() : e,
418
+ rotation: this.getRotation(),
419
+ rotateWithView: this.getRotateWithView(),
420
+ displacement: this.getDisplacement().slice(),
421
+ declutterMode: this.getDeclutterMode()
422
+ });
568
423
  }
569
424
  /**
570
- * @return {HTMLCanvasElement} Image element.
425
+ * Get the symbolizer opacity.
426
+ * @return {number} Opacity.
427
+ * @api
571
428
  */
572
- getHitDetectionImage() {
573
- return this.hitDetectionCanvas_ || this.createHitDetectionCanvas_(this.renderOptions_), this.hitDetectionCanvas_;
429
+ getOpacity() {
430
+ return this.opacity_;
574
431
  }
575
432
  /**
576
- * Get the image icon.
577
- * @param {number} pixelRatio Pixel ratio.
578
- * @return {HTMLCanvasElement} Image or Canvas element.
433
+ * Determine whether the symbolizer rotates with the map.
434
+ * @return {boolean} Rotate with map.
579
435
  * @api
580
436
  */
581
- getImage(e) {
582
- let t = this.canvas_[e];
583
- if (!t) {
584
- const n = this.renderOptions_, s = L(
585
- n.size * e,
586
- n.size * e
587
- );
588
- this.draw_(n, s, e), t = s.canvas, this.canvas_[e] = t;
589
- }
590
- return t;
437
+ getRotateWithView() {
438
+ return this.rotateWithView_;
591
439
  }
592
440
  /**
593
- * Get the image pixel ratio.
594
- * @param {number} pixelRatio Pixel ratio.
595
- * @return {number} Pixel ratio.
441
+ * Get the symoblizer rotation.
442
+ * @return {number} Rotation.
443
+ * @api
596
444
  */
597
- getPixelRatio(e) {
598
- return e;
445
+ getRotation() {
446
+ return this.rotation_;
599
447
  }
600
448
  /**
601
- * @return {import("../size.js").Size} Image size.
449
+ * Get the symbolizer scale.
450
+ * @return {number|import("../size.js").Size} Scale.
451
+ * @api
602
452
  */
603
- getImageSize() {
604
- return this.size_;
453
+ getScale() {
454
+ return this.scale_;
605
455
  }
606
456
  /**
607
- * @return {import("../ImageState.js").default} Image state.
457
+ * Get the symbolizer scale array.
458
+ * @return {import("../size.js").Size} Scale array.
608
459
  */
609
- getImageState() {
610
- return _.LOADED;
460
+ getScaleArray() {
461
+ return this.scaleArray_;
462
+ }
463
+ /**
464
+ * Get the displacement of the shape
465
+ * @return {Array<number>} Shape's center displacement
466
+ * @api
467
+ */
468
+ getDisplacement() {
469
+ return this.displacement_;
470
+ }
471
+ /**
472
+ * Get the declutter mode of the shape
473
+ * @return {"declutter"|"obstacle"|"none"|undefined} Shape's declutter mode
474
+ * @api
475
+ */
476
+ getDeclutterMode() {
477
+ return this.declutterMode_;
478
+ }
479
+ /**
480
+ * Get the anchor point in pixels. The anchor determines the center point for the
481
+ * symbolizer.
482
+ * @abstract
483
+ * @return {Array<number>} Anchor.
484
+ */
485
+ getAnchor() {
486
+ return m();
487
+ }
488
+ /**
489
+ * Get the image element for the symbolizer.
490
+ * @abstract
491
+ * @param {number} pixelRatio Pixel ratio.
492
+ * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
493
+ */
494
+ getImage(e) {
495
+ return m();
496
+ }
497
+ /**
498
+ * @abstract
499
+ * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
500
+ */
501
+ getHitDetectionImage() {
502
+ return m();
503
+ }
504
+ /**
505
+ * Get the image pixel ratio.
506
+ * @param {number} pixelRatio Pixel ratio.
507
+ * @return {number} Pixel ratio.
508
+ */
509
+ getPixelRatio(e) {
510
+ return 1;
511
+ }
512
+ /**
513
+ * @abstract
514
+ * @return {import("../ImageState.js").default} Image state.
515
+ */
516
+ getImageState() {
517
+ return m();
518
+ }
519
+ /**
520
+ * @abstract
521
+ * @return {import("../size.js").Size} Image size.
522
+ */
523
+ getImageSize() {
524
+ return m();
611
525
  }
612
526
  /**
613
527
  * Get the origin of the symbolizer.
528
+ * @abstract
614
529
  * @return {Array<number>} Origin.
615
- * @api
616
530
  */
617
531
  getOrigin() {
618
- return this.origin_;
532
+ return m();
619
533
  }
620
534
  /**
621
- * Get the number of points for generating the shape.
622
- * @return {number} Number of points for stars and regular polygons.
623
- * @api
535
+ * Get the size of the symbolizer (in pixels).
536
+ * @abstract
537
+ * @return {import("../size.js").Size} Size.
624
538
  */
625
- getPoints() {
626
- return this.points_;
539
+ getSize() {
540
+ return m();
627
541
  }
628
542
  /**
629
- * Get the (primary) radius for the shape.
630
- * @return {number} Radius.
543
+ * Set the displacement.
544
+ *
545
+ * @param {Array<number>} displacement Displacement.
631
546
  * @api
632
547
  */
633
- getRadius() {
634
- return this.radius_;
548
+ setDisplacement(e) {
549
+ this.displacement_ = e;
635
550
  }
636
551
  /**
637
- * Get the secondary radius for the shape.
638
- * @return {number|undefined} Radius2.
552
+ * Set the opacity.
553
+ *
554
+ * @param {number} opacity Opacity.
639
555
  * @api
640
556
  */
641
- getRadius2() {
642
- return this.radius2_;
557
+ setOpacity(e) {
558
+ this.opacity_ = e;
643
559
  }
644
560
  /**
645
- * Get the size of the symbolizer (in pixels).
646
- * @return {import("../size.js").Size} Size.
561
+ * Set whether to rotate the style with the view.
562
+ *
563
+ * @param {boolean} rotateWithView Rotate with map.
647
564
  * @api
648
565
  */
649
- getSize() {
650
- return this.size_;
566
+ setRotateWithView(e) {
567
+ this.rotateWithView_ = e;
651
568
  }
652
569
  /**
653
- * Get the stroke style for the shape.
654
- * @return {import("./Stroke.js").default} Stroke style.
570
+ * Set the rotation.
571
+ *
572
+ * @param {number} rotation Rotation.
655
573
  * @api
656
574
  */
657
- getStroke() {
658
- return this.stroke_;
575
+ setRotation(e) {
576
+ this.rotation_ = e;
659
577
  }
660
578
  /**
661
- * Set the stroke style.
662
- * @param {import("./Stroke.js").default} stroke Stroke style.
579
+ * Set the scale.
580
+ *
581
+ * @param {number|import("../size.js").Size} scale Scale.
663
582
  * @api
664
583
  */
665
- setStroke(e) {
666
- this.stroke_ = e, this.render();
584
+ setScale(e) {
585
+ this.scale_ = e, this.scaleArray_ = M(e);
667
586
  }
668
587
  /**
588
+ * @abstract
669
589
  * @param {function(import("../events/Event.js").default): void} listener Listener function.
670
590
  */
671
591
  listenImageChange(e) {
592
+ m();
672
593
  }
673
594
  /**
674
595
  * Load not yet loaded URI.
596
+ * @abstract
675
597
  */
676
598
  load() {
599
+ m();
677
600
  }
678
601
  /**
602
+ * @abstract
679
603
  * @param {function(import("../events/Event.js").default): void} listener Listener function.
680
604
  */
681
605
  unlistenImageChange(e) {
606
+ m();
682
607
  }
608
+ }
609
+ let z = null;
610
+ class ze extends oe {
683
611
  /**
684
- * Calculate additional canvas size needed for the miter.
685
- * @param {string} lineJoin Line join
686
- * @param {number} strokeWidth Stroke width
687
- * @param {number} miterLimit Miter limit
688
- * @return {number} Additional canvas size needed
689
- * @private
690
- */
691
- calculateLineJoinSize_(e, t, n) {
692
- if (t === 0 || this.points_ === 1 / 0 || e !== "bevel" && e !== "miter")
693
- return t;
694
- let s = this.radius_, r = this.radius2_ === void 0 ? s : this.radius2_;
695
- if (s < r) {
696
- const F = s;
697
- s = r, r = F;
698
- }
699
- const a = this.radius2_ === void 0 ? this.points_ : this.points_ * 2, l = 2 * Math.PI / a, o = r * Math.sin(l), c = Math.sqrt(r * r - o * o), h = s - c, u = Math.sqrt(o * o + h * h), f = u / o;
700
- if (e === "miter" && f <= n)
701
- return f * t;
702
- const g = t / 2 / f, d = t / 2 * (h / u), b = Math.sqrt((s + g) * (s + g) + d * d) - s;
703
- if (this.radius2_ === void 0 || e === "bevel")
704
- return b * 2;
705
- const k = s * Math.sin(l), re = Math.sqrt(s * s - k * k), H = r - re, B = Math.sqrt(k * k + H * H) / k;
706
- if (B <= n) {
707
- const F = B * t / 2 - r - s;
708
- return 2 * Math.max(b, F);
709
- }
710
- return b * 2;
711
- }
712
- /**
713
- * @return {RenderOptions} The render options
714
- * @protected
612
+ * @param {HTMLImageElement|HTMLCanvasElement} image Image.
613
+ * @param {string|undefined} src Src.
614
+ * @param {import("../size.js").Size} size Size.
615
+ * @param {?string} crossOrigin Cross origin.
616
+ * @param {import("../ImageState.js").default} imageState Image state.
617
+ * @param {import("../color.js").Color} color Color.
715
618
  */
716
- createRenderOptions() {
717
- let e = G, t = 0, n = null, s = 0, r, a = 0;
718
- this.stroke_ && (r = this.stroke_.getColor(), r === null && (r = Ie), r = X(r), a = this.stroke_.getWidth(), a === void 0 && (a = De), n = this.stroke_.getLineDash(), s = this.stroke_.getLineDashOffset(), e = this.stroke_.getLineJoin(), e === void 0 && (e = G), t = this.stroke_.getMiterLimit(), t === void 0 && (t = Se));
719
- const l = this.calculateLineJoinSize_(e, a, t), o = Math.max(this.radius_, this.radius2_ || 0), c = Math.ceil(2 * o + l);
720
- return {
721
- strokeStyle: r,
722
- strokeWidth: a,
723
- size: c,
724
- lineDash: n,
725
- lineDashOffset: s,
726
- lineJoin: e,
727
- miterLimit: t
728
- };
619
+ constructor(e, t, n, s, r, a) {
620
+ super(), this.hitDetectionImage_ = null, this.image_ = e, this.crossOrigin_ = s, this.canvas_ = {}, this.color_ = a, this.unlisten_ = null, this.imageState_ = r, this.size_ = n, this.src_ = t, this.tainted_;
729
621
  }
730
622
  /**
731
- * @protected
623
+ * @private
732
624
  */
733
- render() {
734
- this.renderOptions_ = this.createRenderOptions();
735
- const e = this.renderOptions_.size;
736
- this.canvas_ = {}, this.size_ = [e, e];
625
+ initializeImage_() {
626
+ this.image_ = new Image(), this.crossOrigin_ !== null && (this.image_.crossOrigin = this.crossOrigin_);
737
627
  }
738
628
  /**
739
629
  * @private
740
- * @param {RenderOptions} renderOptions Render options.
741
- * @param {CanvasRenderingContext2D} context The rendering context.
742
- * @param {number} pixelRatio The pixel ratio.
630
+ * @return {boolean} The image canvas is tainted.
743
631
  */
744
- draw_(e, t, n) {
745
- if (t.scale(n, n), t.translate(e.size / 2, e.size / 2), this.createPath_(t), this.fill_) {
746
- let s = this.fill_.getColor();
747
- s === null && (s = Y), t.fillStyle = X(s), t.fill();
632
+ isTainted_() {
633
+ if (this.tainted_ === void 0 && this.imageState_ === _.LOADED) {
634
+ z || (z = L(1, 1, void 0, {
635
+ willReadFrequently: !0
636
+ })), z.drawImage(this.image_, 0, 0);
637
+ try {
638
+ z.getImageData(0, 0, 1, 1), this.tainted_ = !1;
639
+ } catch {
640
+ z = null, this.tainted_ = !0;
641
+ }
748
642
  }
749
- this.stroke_ && (t.strokeStyle = e.strokeStyle, t.lineWidth = e.strokeWidth, e.lineDash && (t.setLineDash(e.lineDash), t.lineDashOffset = e.lineDashOffset), t.lineJoin = e.lineJoin, t.miterLimit = e.miterLimit, t.stroke());
643
+ return this.tainted_ === !0;
750
644
  }
751
645
  /**
752
646
  * @private
753
- * @param {RenderOptions} renderOptions Render options.
754
647
  */
755
- createHitDetectionCanvas_(e) {
756
- if (this.fill_) {
757
- let t = this.fill_.getColor(), n = 0;
758
- if (typeof t == "string" && (t = Q(t)), t === null ? n = 1 : Array.isArray(t) && (n = t.length === 4 ? t[3] : 1), n === 0) {
759
- const s = L(
760
- e.size,
761
- e.size
762
- );
763
- this.hitDetectionCanvas_ = s.canvas, this.drawHitDetectionCanvas_(e, s);
764
- }
765
- }
766
- this.hitDetectionCanvas_ || (this.hitDetectionCanvas_ = this.getImage(1));
648
+ dispatchChangeEvent_() {
649
+ this.dispatchEvent(O.CHANGE);
767
650
  }
768
651
  /**
769
652
  * @private
770
- * @param {CanvasRenderingContext2D} context The context to draw in.
771
653
  */
772
- createPath_(e) {
773
- let t = this.points_;
774
- const n = this.radius_;
775
- if (t === 1 / 0)
776
- e.arc(0, 0, n, 0, 2 * Math.PI);
777
- else {
778
- const s = this.radius2_ === void 0 ? n : this.radius2_;
779
- this.radius2_ !== void 0 && (t *= 2);
780
- const r = this.angle_ - Math.PI / 2, a = 2 * Math.PI / t;
781
- for (let l = 0; l < t; l++) {
782
- const o = r + l * a, c = l % 2 === 0 ? n : s;
783
- e.lineTo(c * Math.cos(o), c * Math.sin(o));
784
- }
785
- e.closePath();
786
- }
654
+ handleImageError_() {
655
+ this.imageState_ = _.ERROR, this.unlistenImage_(), this.dispatchChangeEvent_();
787
656
  }
788
657
  /**
789
658
  * @private
790
- * @param {RenderOptions} renderOptions Render options.
791
- * @param {CanvasRenderingContext2D} context The context.
792
659
  */
793
- drawHitDetectionCanvas_(e, t) {
794
- t.translate(e.size / 2, e.size / 2), this.createPath_(t), t.fillStyle = Y, t.fill(), this.stroke_ && (t.strokeStyle = e.strokeStyle, t.lineWidth = e.strokeWidth, e.lineDash && (t.setLineDash(e.lineDash), t.lineDashOffset = e.lineDashOffset), t.lineJoin = e.lineJoin, t.miterLimit = e.miterLimit, t.stroke());
660
+ handleImageLoad_() {
661
+ this.imageState_ = _.LOADED, this.size_ ? (this.image_.width = this.size_[0], this.image_.height = this.size_[1]) : this.size_ = [this.image_.width, this.image_.height], this.unlistenImage_(), this.dispatchChangeEvent_();
795
662
  }
796
- }
797
- class R extends V {
798
663
  /**
799
- * @param {Options} [options] Options.
664
+ * @param {number} pixelRatio Pixel ratio.
665
+ * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
800
666
  */
801
- constructor(e) {
802
- e = e || { radius: 5 }, super({
803
- points: 1 / 0,
804
- fill: e.fill,
805
- radius: e.radius,
806
- stroke: e.stroke,
807
- scale: e.scale !== void 0 ? e.scale : 1,
808
- rotation: e.rotation !== void 0 ? e.rotation : 0,
809
- rotateWithView: e.rotateWithView !== void 0 ? e.rotateWithView : !1,
810
- displacement: e.displacement !== void 0 ? e.displacement : [0, 0],
811
- declutterMode: e.declutterMode
812
- });
667
+ getImage(e) {
668
+ return this.image_ || this.initializeImage_(), this.replaceColor_(e), this.canvas_[e] ? this.canvas_[e] : this.image_;
813
669
  }
814
670
  /**
815
- * Clones the style.
816
- * @return {CircleStyle} The cloned style.
817
- * @api
671
+ * @param {number} pixelRatio Pixel ratio.
672
+ * @return {number} Image or Canvas element.
818
673
  */
819
- clone() {
820
- const e = this.getScale(), t = new R({
821
- fill: this.getFill() ? this.getFill().clone() : void 0,
822
- stroke: this.getStroke() ? this.getStroke().clone() : void 0,
823
- radius: this.getRadius(),
824
- scale: Array.isArray(e) ? e.slice() : e,
825
- rotation: this.getRotation(),
826
- rotateWithView: this.getRotateWithView(),
827
- displacement: this.getDisplacement().slice(),
828
- declutterMode: this.getDeclutterMode()
829
- });
830
- return t.setOpacity(this.getOpacity()), t;
674
+ getPixelRatio(e) {
675
+ return this.replaceColor_(e), this.canvas_[e] ? e : 1;
831
676
  }
832
677
  /**
833
- * Set the circle radius.
834
- *
835
- * @param {number} radius Circle radius.
836
- * @api
678
+ * @return {import("../ImageState.js").default} Image state.
837
679
  */
838
- setRadius(e) {
839
- this.radius_ = e, this.render();
680
+ getImageState() {
681
+ return this.imageState_;
840
682
  }
841
- }
842
- class C {
843
683
  /**
844
- * @param {Options} [options] Options.
684
+ * @return {HTMLImageElement|HTMLCanvasElement} Image element.
845
685
  */
846
- constructor(e) {
847
- e = e || {}, this.color_ = e.color !== void 0 ? e.color : null;
686
+ getHitDetectionImage() {
687
+ if (this.image_ || this.initializeImage_(), !this.hitDetectionImage_)
688
+ if (this.isTainted_()) {
689
+ const e = this.size_[0], t = this.size_[1], n = L(e, t);
690
+ n.fillRect(0, 0, e, t), this.hitDetectionImage_ = n.canvas;
691
+ } else
692
+ this.hitDetectionImage_ = this.image_;
693
+ return this.hitDetectionImage_;
848
694
  }
849
695
  /**
850
- * Clones the style. The color is not cloned if it is an {@link module:ol/colorlike~ColorLike}.
851
- * @return {Fill} The cloned style.
852
- * @api
696
+ * Get the size of the icon (in pixels).
697
+ * @return {import("../size.js").Size} Image size.
853
698
  */
854
- clone() {
855
- const e = this.getColor();
856
- return new C({
857
- color: Array.isArray(e) ? e.slice() : e || void 0
858
- });
699
+ getSize() {
700
+ return this.size_;
859
701
  }
860
702
  /**
861
- * Get the fill color.
862
- * @return {import("../color.js").Color|import("../colorlike.js").ColorLike|null} Color.
863
- * @api
703
+ * @return {string|undefined} Image src.
864
704
  */
865
- getColor() {
866
- return this.color_;
705
+ getSrc() {
706
+ return this.src_;
867
707
  }
868
708
  /**
869
- * Set the color.
709
+ * Load not yet loaded URI.
710
+ */
711
+ load() {
712
+ if (this.imageState_ === _.IDLE) {
713
+ this.image_ || this.initializeImage_(), this.imageState_ = _.LOADING;
714
+ try {
715
+ this.image_.src = this.src_;
716
+ } catch {
717
+ this.handleImageError_();
718
+ }
719
+ this.unlisten_ = ke(
720
+ this.image_,
721
+ this.handleImageLoad_.bind(this),
722
+ this.handleImageError_.bind(this)
723
+ );
724
+ }
725
+ }
726
+ /**
727
+ * @param {number} pixelRatio Pixel ratio.
728
+ * @private
729
+ */
730
+ replaceColor_(e) {
731
+ if (!this.color_ || this.canvas_[e] || this.imageState_ !== _.LOADED)
732
+ return;
733
+ const t = this.image_, n = document.createElement("canvas");
734
+ n.width = Math.ceil(t.width * e), n.height = Math.ceil(t.height * e);
735
+ const s = n.getContext("2d");
736
+ s.scale(e, e), s.drawImage(t, 0, 0), s.globalCompositeOperation = "multiply", s.fillStyle = $(this.color_), s.fillRect(0, 0, n.width / e, n.height / e), s.globalCompositeOperation = "destination-in", s.drawImage(t, 0, 0), this.canvas_[e] = n;
737
+ }
738
+ /**
739
+ * Discards event handlers which listen for load completion or errors.
870
740
  *
871
- * @param {import("../color.js").Color|import("../colorlike.js").ColorLike|null} color Color.
872
- * @api
741
+ * @private
873
742
  */
874
- setColor(e) {
875
- this.color_ = e;
743
+ unlistenImage_() {
744
+ this.unlisten_ && (this.unlisten_(), this.unlisten_ = null);
876
745
  }
877
746
  }
878
- class A {
747
+ function Oe(i, e, t, n, s, r) {
748
+ let a = U.get(e, n, r);
749
+ return a || (a = new ze(i, e, t, n, s, r), U.set(e, n, r, a)), a;
750
+ }
751
+ function q(i, e, t, n) {
752
+ return t !== void 0 && n !== void 0 ? [t / i, n / e] : t !== void 0 ? t / i : n !== void 0 ? n / e : 1;
753
+ }
754
+ class ne extends E {
879
755
  /**
880
756
  * @param {Options} [options] Options.
881
757
  */
882
758
  constructor(e) {
883
- e = e || {}, this.color_ = e.color !== void 0 ? e.color : null, this.lineCap_ = e.lineCap, this.lineDash_ = e.lineDash !== void 0 ? e.lineDash : null, this.lineDashOffset_ = e.lineDashOffset, this.lineJoin_ = e.lineJoin, this.miterLimit_ = e.miterLimit, this.width_ = e.width;
759
+ e = e || {};
760
+ const t = e.opacity !== void 0 ? e.opacity : 1, n = e.rotation !== void 0 ? e.rotation : 0, s = e.scale !== void 0 ? e.scale : 1, r = e.rotateWithView !== void 0 ? e.rotateWithView : !1;
761
+ super({
762
+ opacity: t,
763
+ rotation: n,
764
+ scale: s,
765
+ displacement: e.displacement !== void 0 ? e.displacement : [0, 0],
766
+ rotateWithView: r,
767
+ declutterMode: e.declutterMode
768
+ }), this.anchor_ = e.anchor !== void 0 ? e.anchor : [0.5, 0.5], this.normalizedAnchor_ = null, this.anchorOrigin_ = e.anchorOrigin !== void 0 ? e.anchorOrigin : "top-left", this.anchorXUnits_ = e.anchorXUnits !== void 0 ? e.anchorXUnits : "fraction", this.anchorYUnits_ = e.anchorYUnits !== void 0 ? e.anchorYUnits : "fraction", this.crossOrigin_ = e.crossOrigin !== void 0 ? e.crossOrigin : null;
769
+ const a = e.img !== void 0 ? e.img : null;
770
+ this.imgSize_ = e.imgSize;
771
+ let l = e.src;
772
+ w(!(l !== void 0 && a), 4), w(!a || a && this.imgSize_, 5), (l === void 0 || l.length === 0) && a && (l = /** @type {HTMLImageElement} */
773
+ a.src || ue(a)), w(l !== void 0 && l.length > 0, 6), w(
774
+ !((e.width !== void 0 || e.height !== void 0) && e.scale !== void 0),
775
+ 69
776
+ );
777
+ const o = e.src !== void 0 ? _.IDLE : _.LOADED;
778
+ if (this.color_ = e.color !== void 0 ? Q(e.color) : null, this.iconImage_ = Oe(
779
+ a,
780
+ /** @type {string} */
781
+ l,
782
+ this.imgSize_ !== void 0 ? this.imgSize_ : null,
783
+ this.crossOrigin_,
784
+ o,
785
+ this.color_
786
+ ), this.offset_ = e.offset !== void 0 ? e.offset : [0, 0], this.offsetOrigin_ = e.offsetOrigin !== void 0 ? e.offsetOrigin : "top-left", this.origin_ = null, this.size_ = e.size !== void 0 ? e.size : null, e.width !== void 0 || e.height !== void 0) {
787
+ let c, h;
788
+ if (e.size)
789
+ [c, h] = e.size;
790
+ else {
791
+ const u = this.getImage(1);
792
+ if (u instanceof HTMLCanvasElement || u.src && u.complete)
793
+ c = u.width, h = u.height;
794
+ else {
795
+ this.initialOptions_ = e;
796
+ const f = () => {
797
+ if (this.unlistenImageChange(f), !this.initialOptions_)
798
+ return;
799
+ const g = this.iconImage_.getSize();
800
+ this.setScale(
801
+ q(
802
+ g[0],
803
+ g[1],
804
+ e.width,
805
+ e.height
806
+ )
807
+ );
808
+ };
809
+ this.listenImageChange(f);
810
+ return;
811
+ }
812
+ }
813
+ c !== void 0 && this.setScale(
814
+ q(c, h, e.width, e.height)
815
+ );
816
+ }
884
817
  }
885
818
  /**
886
- * Clones the style.
887
- * @return {Stroke} The cloned style.
819
+ * Clones the style. The underlying Image/HTMLCanvasElement is not cloned.
820
+ * @return {Icon} The cloned style.
888
821
  * @api
889
822
  */
890
823
  clone() {
891
- const e = this.getColor();
892
- return new A({
893
- color: Array.isArray(e) ? e.slice() : e || void 0,
894
- lineCap: this.getLineCap(),
895
- lineDash: this.getLineDash() ? this.getLineDash().slice() : void 0,
896
- lineDashOffset: this.getLineDashOffset(),
897
- lineJoin: this.getLineJoin(),
898
- miterLimit: this.getMiterLimit(),
899
- width: this.getWidth()
824
+ let e, t, n;
825
+ return this.initialOptions_ ? (t = this.initialOptions_.width, n = this.initialOptions_.height) : (e = this.getScale(), e = Array.isArray(e) ? e.slice() : e), new ne({
826
+ anchor: this.anchor_.slice(),
827
+ anchorOrigin: this.anchorOrigin_,
828
+ anchorXUnits: this.anchorXUnits_,
829
+ anchorYUnits: this.anchorYUnits_,
830
+ color: this.color_ && this.color_.slice ? this.color_.slice() : this.color_ || void 0,
831
+ crossOrigin: this.crossOrigin_,
832
+ imgSize: this.imgSize_,
833
+ offset: this.offset_.slice(),
834
+ offsetOrigin: this.offsetOrigin_,
835
+ opacity: this.getOpacity(),
836
+ rotateWithView: this.getRotateWithView(),
837
+ rotation: this.getRotation(),
838
+ scale: e,
839
+ width: t,
840
+ height: n,
841
+ size: this.size_ !== null ? this.size_.slice() : void 0,
842
+ src: this.getSrc(),
843
+ displacement: this.getDisplacement().slice(),
844
+ declutterMode: this.getDeclutterMode()
900
845
  });
901
846
  }
902
847
  /**
903
- * Get the stroke color.
904
- * @return {import("../color.js").Color|import("../colorlike.js").ColorLike} Color.
848
+ * Get the anchor point in pixels. The anchor determines the center point for the
849
+ * symbolizer.
850
+ * @return {Array<number>} Anchor.
905
851
  * @api
906
852
  */
907
- getColor() {
908
- return this.color_;
853
+ getAnchor() {
854
+ let e = this.normalizedAnchor_;
855
+ if (!e) {
856
+ e = this.anchor_;
857
+ const s = this.getSize();
858
+ if (this.anchorXUnits_ == "fraction" || this.anchorYUnits_ == "fraction") {
859
+ if (!s)
860
+ return null;
861
+ e = this.anchor_.slice(), this.anchorXUnits_ == "fraction" && (e[0] *= s[0]), this.anchorYUnits_ == "fraction" && (e[1] *= s[1]);
862
+ }
863
+ if (this.anchorOrigin_ != "top-left") {
864
+ if (!s)
865
+ return null;
866
+ e === this.anchor_ && (e = this.anchor_.slice()), (this.anchorOrigin_ == "top-right" || this.anchorOrigin_ == "bottom-right") && (e[0] = -e[0] + s[0]), (this.anchorOrigin_ == "bottom-left" || this.anchorOrigin_ == "bottom-right") && (e[1] = -e[1] + s[1]);
867
+ }
868
+ this.normalizedAnchor_ = e;
869
+ }
870
+ const t = this.getDisplacement(), n = this.getScaleArray();
871
+ return [
872
+ e[0] - t[0] / n[0],
873
+ e[1] + t[1] / n[1]
874
+ ];
909
875
  }
910
876
  /**
911
- * Get the line cap type for the stroke.
912
- * @return {CanvasLineCap|undefined} Line cap.
877
+ * Set the anchor point. The anchor determines the center point for the
878
+ * symbolizer.
879
+ *
880
+ * @param {Array<number>} anchor Anchor.
913
881
  * @api
914
882
  */
915
- getLineCap() {
916
- return this.lineCap_;
883
+ setAnchor(e) {
884
+ this.anchor_ = e, this.normalizedAnchor_ = null;
917
885
  }
918
886
  /**
919
- * Get the line dash style for the stroke.
920
- * @return {Array<number>|null} Line dash.
887
+ * Get the icon color.
888
+ * @return {import("../color.js").Color} Color.
921
889
  * @api
922
890
  */
923
- getLineDash() {
924
- return this.lineDash_;
891
+ getColor() {
892
+ return this.color_;
893
+ }
894
+ /**
895
+ * Get the image icon.
896
+ * @param {number} pixelRatio Pixel ratio.
897
+ * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
898
+ * @api
899
+ */
900
+ getImage(e) {
901
+ return this.iconImage_.getImage(e);
902
+ }
903
+ /**
904
+ * Get the pixel ratio.
905
+ * @param {number} pixelRatio Pixel ratio.
906
+ * @return {number} The pixel ratio of the image.
907
+ * @api
908
+ */
909
+ getPixelRatio(e) {
910
+ return this.iconImage_.getPixelRatio(e);
911
+ }
912
+ /**
913
+ * @return {import("../size.js").Size} Image size.
914
+ */
915
+ getImageSize() {
916
+ return this.iconImage_.getSize();
917
+ }
918
+ /**
919
+ * @return {import("../ImageState.js").default} Image state.
920
+ */
921
+ getImageState() {
922
+ return this.iconImage_.getImageState();
923
+ }
924
+ /**
925
+ * @return {HTMLImageElement|HTMLCanvasElement} Image element.
926
+ */
927
+ getHitDetectionImage() {
928
+ return this.iconImage_.getHitDetectionImage();
929
+ }
930
+ /**
931
+ * Get the origin of the symbolizer.
932
+ * @return {Array<number>} Origin.
933
+ * @api
934
+ */
935
+ getOrigin() {
936
+ if (this.origin_)
937
+ return this.origin_;
938
+ let e = this.offset_;
939
+ if (this.offsetOrigin_ != "top-left") {
940
+ const t = this.getSize(), n = this.iconImage_.getSize();
941
+ if (!t || !n)
942
+ return null;
943
+ e = e.slice(), (this.offsetOrigin_ == "top-right" || this.offsetOrigin_ == "bottom-right") && (e[0] = n[0] - t[0] - e[0]), (this.offsetOrigin_ == "bottom-left" || this.offsetOrigin_ == "bottom-right") && (e[1] = n[1] - t[1] - e[1]);
944
+ }
945
+ return this.origin_ = e, this.origin_;
946
+ }
947
+ /**
948
+ * Get the image URL.
949
+ * @return {string|undefined} Image src.
950
+ * @api
951
+ */
952
+ getSrc() {
953
+ return this.iconImage_.getSrc();
954
+ }
955
+ /**
956
+ * Get the size of the icon (in pixels).
957
+ * @return {import("../size.js").Size} Image size.
958
+ * @api
959
+ */
960
+ getSize() {
961
+ return this.size_ ? this.size_ : this.iconImage_.getSize();
962
+ }
963
+ /**
964
+ * Get the width of the icon (in pixels). Will return undefined when the icon image is not yet loaded.
965
+ * @return {number} Icon width (in pixels).
966
+ * @api
967
+ */
968
+ getWidth() {
969
+ const e = this.getScaleArray();
970
+ if (this.size_)
971
+ return this.size_[0] * e[0];
972
+ if (this.iconImage_.getImageState() == _.LOADED)
973
+ return this.iconImage_.getSize()[0] * e[0];
974
+ }
975
+ /**
976
+ * Get the height of the icon (in pixels). Will return undefined when the icon image is not yet loaded.
977
+ * @return {number} Icon height (in pixels).
978
+ * @api
979
+ */
980
+ getHeight() {
981
+ const e = this.getScaleArray();
982
+ if (this.size_)
983
+ return this.size_[1] * e[1];
984
+ if (this.iconImage_.getImageState() == _.LOADED)
985
+ return this.iconImage_.getSize()[1] * e[1];
986
+ }
987
+ /**
988
+ * Set the scale.
989
+ *
990
+ * @param {number|import("../size.js").Size} scale Scale.
991
+ * @api
992
+ */
993
+ setScale(e) {
994
+ delete this.initialOptions_, super.setScale(e);
995
+ }
996
+ /**
997
+ * @param {function(import("../events/Event.js").default): void} listener Listener function.
998
+ */
999
+ listenImageChange(e) {
1000
+ this.iconImage_.addEventListener(O.CHANGE, e);
1001
+ }
1002
+ /**
1003
+ * Load not yet loaded URI.
1004
+ * When rendering a feature with an icon style, the vector renderer will
1005
+ * automatically call this method. However, you might want to call this
1006
+ * method yourself for preloading or other purposes.
1007
+ * @api
1008
+ */
1009
+ load() {
1010
+ this.iconImage_.load();
1011
+ }
1012
+ /**
1013
+ * @param {function(import("../events/Event.js").default): void} listener Listener function.
1014
+ */
1015
+ unlistenImageChange(e) {
1016
+ this.iconImage_.removeEventListener(O.CHANGE, e);
1017
+ }
1018
+ }
1019
+ class A {
1020
+ /**
1021
+ * @param {Options} [options] Options.
1022
+ */
1023
+ constructor(e) {
1024
+ e = e || {}, this.color_ = e.color !== void 0 ? e.color : null, this.lineCap_ = e.lineCap, this.lineDash_ = e.lineDash !== void 0 ? e.lineDash : null, this.lineDashOffset_ = e.lineDashOffset, this.lineJoin_ = e.lineJoin, this.miterLimit_ = e.miterLimit, this.width_ = e.width;
1025
+ }
1026
+ /**
1027
+ * Clones the style.
1028
+ * @return {Stroke} The cloned style.
1029
+ * @api
1030
+ */
1031
+ clone() {
1032
+ const e = this.getColor();
1033
+ return new A({
1034
+ color: Array.isArray(e) ? e.slice() : e || void 0,
1035
+ lineCap: this.getLineCap(),
1036
+ lineDash: this.getLineDash() ? this.getLineDash().slice() : void 0,
1037
+ lineDashOffset: this.getLineDashOffset(),
1038
+ lineJoin: this.getLineJoin(),
1039
+ miterLimit: this.getMiterLimit(),
1040
+ width: this.getWidth()
1041
+ });
1042
+ }
1043
+ /**
1044
+ * Get the stroke color.
1045
+ * @return {import("../color.js").Color|import("../colorlike.js").ColorLike} Color.
1046
+ * @api
1047
+ */
1048
+ getColor() {
1049
+ return this.color_;
1050
+ }
1051
+ /**
1052
+ * Get the line cap type for the stroke.
1053
+ * @return {CanvasLineCap|undefined} Line cap.
1054
+ * @api
1055
+ */
1056
+ getLineCap() {
1057
+ return this.lineCap_;
1058
+ }
1059
+ /**
1060
+ * Get the line dash style for the stroke.
1061
+ * @return {Array<number>|null} Line dash.
1062
+ * @api
1063
+ */
1064
+ getLineDash() {
1065
+ return this.lineDash_;
925
1066
  }
926
1067
  /**
927
1068
  * Get the line dash offset for the stroke.
@@ -1019,763 +1160,622 @@ class A {
1019
1160
  this.width_ = e;
1020
1161
  }
1021
1162
  }
1022
- class S {
1163
+ function Z(i) {
1164
+ return Array.isArray(i) ? ee(i) : i;
1165
+ }
1166
+ class V extends E {
1023
1167
  /**
1024
- * @param {Options} [options] Style options.
1168
+ * @param {Options} options Options.
1025
1169
  */
1026
1170
  constructor(e) {
1027
- e = e || {}, this.geometry_ = null, this.geometryFunction_ = p, e.geometry !== void 0 && this.setGeometry(e.geometry), this.fill_ = e.fill !== void 0 ? e.fill : null, this.image_ = e.image !== void 0 ? e.image : null, this.renderer_ = e.renderer !== void 0 ? e.renderer : null, this.hitDetectionRenderer_ = e.hitDetectionRenderer !== void 0 ? e.hitDetectionRenderer : null, this.stroke_ = e.stroke !== void 0 ? e.stroke : null, this.text_ = e.text !== void 0 ? e.text : null, this.zIndex_ = e.zIndex;
1171
+ const t = e.rotateWithView !== void 0 ? e.rotateWithView : !1;
1172
+ super({
1173
+ opacity: 1,
1174
+ rotateWithView: t,
1175
+ rotation: e.rotation !== void 0 ? e.rotation : 0,
1176
+ scale: e.scale !== void 0 ? e.scale : 1,
1177
+ displacement: e.displacement !== void 0 ? e.displacement : [0, 0],
1178
+ declutterMode: e.declutterMode
1179
+ }), this.canvas_ = void 0, this.hitDetectionCanvas_ = null, this.fill_ = e.fill !== void 0 ? e.fill : null, this.origin_ = [0, 0], this.points_ = e.points, this.radius_ = e.radius !== void 0 ? e.radius : e.radius1, this.radius2_ = e.radius2, this.angle_ = e.angle !== void 0 ? e.angle : 0, this.stroke_ = e.stroke !== void 0 ? e.stroke : null, this.size_ = null, this.renderOptions_ = null, this.render();
1028
1180
  }
1029
1181
  /**
1030
1182
  * Clones the style.
1031
- * @return {Style} The cloned style.
1183
+ * @return {RegularShape} The cloned style.
1032
1184
  * @api
1033
1185
  */
1034
1186
  clone() {
1035
- let e = this.getGeometry();
1036
- return e && typeof e == "object" && (e = /** @type {import("../geom/Geometry.js").default} */
1037
- e.clone()), new S({
1038
- geometry: e,
1187
+ const e = this.getScale(), t = new V({
1039
1188
  fill: this.getFill() ? this.getFill().clone() : void 0,
1040
- image: this.getImage() ? this.getImage().clone() : void 0,
1041
- renderer: this.getRenderer(),
1189
+ points: this.getPoints(),
1190
+ radius: this.getRadius(),
1191
+ radius2: this.getRadius2(),
1192
+ angle: this.getAngle(),
1042
1193
  stroke: this.getStroke() ? this.getStroke().clone() : void 0,
1043
- text: this.getText() ? this.getText().clone() : void 0,
1044
- zIndex: this.getZIndex()
1194
+ rotation: this.getRotation(),
1195
+ rotateWithView: this.getRotateWithView(),
1196
+ scale: Array.isArray(e) ? e.slice() : e,
1197
+ displacement: this.getDisplacement().slice(),
1198
+ declutterMode: this.getDeclutterMode()
1045
1199
  });
1200
+ return t.setOpacity(this.getOpacity()), t;
1046
1201
  }
1047
1202
  /**
1048
- * Get the custom renderer function that was configured with
1049
- * {@link #setRenderer} or the `renderer` constructor option.
1050
- * @return {RenderFunction|null} Custom renderer function.
1203
+ * Get the anchor point in pixels. The anchor determines the center point for the
1204
+ * symbolizer.
1205
+ * @return {Array<number>} Anchor.
1051
1206
  * @api
1052
1207
  */
1053
- getRenderer() {
1054
- return this.renderer_;
1208
+ getAnchor() {
1209
+ const e = this.size_;
1210
+ if (!e)
1211
+ return null;
1212
+ const t = this.getDisplacement(), n = this.getScaleArray();
1213
+ return [
1214
+ e[0] / 2 - t[0] / n[0],
1215
+ e[1] / 2 + t[1] / n[1]
1216
+ ];
1055
1217
  }
1056
1218
  /**
1057
- * Sets a custom renderer function for this style. When set, `fill`, `stroke`
1058
- * and `image` options of the style will be ignored.
1059
- * @param {RenderFunction|null} renderer Custom renderer function.
1219
+ * Get the angle used in generating the shape.
1220
+ * @return {number} Shape's rotation in radians.
1060
1221
  * @api
1061
1222
  */
1062
- setRenderer(e) {
1063
- this.renderer_ = e;
1223
+ getAngle() {
1224
+ return this.angle_;
1064
1225
  }
1065
1226
  /**
1066
- * Sets a custom renderer function for this style used
1067
- * in hit detection.
1068
- * @param {RenderFunction|null} renderer Custom renderer function.
1227
+ * Get the fill style for the shape.
1228
+ * @return {import("./Fill.js").default} Fill style.
1069
1229
  * @api
1070
1230
  */
1071
- setHitDetectionRenderer(e) {
1072
- this.hitDetectionRenderer_ = e;
1231
+ getFill() {
1232
+ return this.fill_;
1073
1233
  }
1074
1234
  /**
1075
- * Get the custom renderer function that was configured with
1076
- * {@link #setHitDetectionRenderer} or the `hitDetectionRenderer` constructor option.
1077
- * @return {RenderFunction|null} Custom renderer function.
1235
+ * Set the fill style.
1236
+ * @param {import("./Fill.js").default} fill Fill style.
1078
1237
  * @api
1079
1238
  */
1080
- getHitDetectionRenderer() {
1081
- return this.hitDetectionRenderer_;
1239
+ setFill(e) {
1240
+ this.fill_ = e, this.render();
1082
1241
  }
1083
1242
  /**
1084
- * Get the geometry to be rendered.
1085
- * @return {string|import("../geom/Geometry.js").default|GeometryFunction}
1086
- * Feature property or geometry or function that returns the geometry that will
1087
- * be rendered with this style.
1088
- * @api
1243
+ * @return {HTMLCanvasElement} Image element.
1089
1244
  */
1090
- getGeometry() {
1091
- return this.geometry_;
1245
+ getHitDetectionImage() {
1246
+ return this.hitDetectionCanvas_ || this.createHitDetectionCanvas_(this.renderOptions_), this.hitDetectionCanvas_;
1092
1247
  }
1093
1248
  /**
1094
- * Get the function used to generate a geometry for rendering.
1095
- * @return {!GeometryFunction} Function that is called with a feature
1096
- * and returns the geometry to render instead of the feature's geometry.
1249
+ * Get the image icon.
1250
+ * @param {number} pixelRatio Pixel ratio.
1251
+ * @return {HTMLCanvasElement} Image or Canvas element.
1097
1252
  * @api
1098
1253
  */
1099
- getGeometryFunction() {
1100
- return this.geometryFunction_;
1254
+ getImage(e) {
1255
+ let t = this.canvas_[e];
1256
+ if (!t) {
1257
+ const n = this.renderOptions_, s = L(
1258
+ n.size * e,
1259
+ n.size * e
1260
+ );
1261
+ this.draw_(n, s, e), t = s.canvas, this.canvas_[e] = t;
1262
+ }
1263
+ return t;
1101
1264
  }
1102
1265
  /**
1103
- * Get the fill style.
1104
- * @return {import("./Fill.js").default} Fill style.
1105
- * @api
1266
+ * Get the image pixel ratio.
1267
+ * @param {number} pixelRatio Pixel ratio.
1268
+ * @return {number} Pixel ratio.
1106
1269
  */
1107
- getFill() {
1108
- return this.fill_;
1270
+ getPixelRatio(e) {
1271
+ return e;
1109
1272
  }
1110
1273
  /**
1111
- * Set the fill style.
1112
- * @param {import("./Fill.js").default} fill Fill style.
1113
- * @api
1274
+ * @return {import("../size.js").Size} Image size.
1114
1275
  */
1115
- setFill(e) {
1116
- this.fill_ = e;
1276
+ getImageSize() {
1277
+ return this.size_;
1117
1278
  }
1118
1279
  /**
1119
- * Get the image style.
1120
- * @return {import("./Image.js").default} Image style.
1121
- * @api
1280
+ * @return {import("../ImageState.js").default} Image state.
1122
1281
  */
1123
- getImage() {
1124
- return this.image_;
1282
+ getImageState() {
1283
+ return _.LOADED;
1125
1284
  }
1126
1285
  /**
1127
- * Set the image style.
1128
- * @param {import("./Image.js").default} image Image style.
1286
+ * Get the origin of the symbolizer.
1287
+ * @return {Array<number>} Origin.
1129
1288
  * @api
1130
1289
  */
1131
- setImage(e) {
1132
- this.image_ = e;
1290
+ getOrigin() {
1291
+ return this.origin_;
1133
1292
  }
1134
1293
  /**
1135
- * Get the stroke style.
1136
- * @return {import("./Stroke.js").default} Stroke style.
1294
+ * Get the number of points for generating the shape.
1295
+ * @return {number} Number of points for stars and regular polygons.
1137
1296
  * @api
1138
1297
  */
1139
- getStroke() {
1140
- return this.stroke_;
1298
+ getPoints() {
1299
+ return this.points_;
1141
1300
  }
1142
1301
  /**
1143
- * Set the stroke style.
1144
- * @param {import("./Stroke.js").default} stroke Stroke style.
1302
+ * Get the (primary) radius for the shape.
1303
+ * @return {number} Radius.
1145
1304
  * @api
1146
1305
  */
1147
- setStroke(e) {
1148
- this.stroke_ = e;
1306
+ getRadius() {
1307
+ return this.radius_;
1149
1308
  }
1150
1309
  /**
1151
- * Get the text style.
1152
- * @return {import("./Text.js").default} Text style.
1310
+ * Get the secondary radius for the shape.
1311
+ * @return {number|undefined} Radius2.
1153
1312
  * @api
1154
1313
  */
1155
- getText() {
1156
- return this.text_;
1314
+ getRadius2() {
1315
+ return this.radius2_;
1157
1316
  }
1158
1317
  /**
1159
- * Set the text style.
1160
- * @param {import("./Text.js").default} text Text style.
1318
+ * Get the size of the symbolizer (in pixels).
1319
+ * @return {import("../size.js").Size} Size.
1161
1320
  * @api
1162
1321
  */
1163
- setText(e) {
1164
- this.text_ = e;
1322
+ getSize() {
1323
+ return this.size_;
1165
1324
  }
1166
1325
  /**
1167
- * Get the z-index for the style.
1168
- * @return {number|undefined} ZIndex.
1326
+ * Get the stroke style for the shape.
1327
+ * @return {import("./Stroke.js").default} Stroke style.
1169
1328
  * @api
1170
1329
  */
1171
- getZIndex() {
1172
- return this.zIndex_;
1330
+ getStroke() {
1331
+ return this.stroke_;
1173
1332
  }
1174
1333
  /**
1175
- * Set a geometry that is rendered instead of the feature's geometry.
1176
- *
1177
- * @param {string|import("../geom/Geometry.js").default|GeometryFunction} geometry
1178
- * Feature property or geometry or function returning a geometry to render
1179
- * for this style.
1334
+ * Set the stroke style.
1335
+ * @param {import("./Stroke.js").default} stroke Stroke style.
1180
1336
  * @api
1181
1337
  */
1182
- setGeometry(e) {
1183
- typeof e == "function" ? this.geometryFunction_ = e : typeof e == "string" ? this.geometryFunction_ = function(t) {
1184
- return (
1185
- /** @type {import("../geom/Geometry.js").default} */
1186
- t.get(e)
1187
- );
1188
- } : e ? e !== void 0 && (this.geometryFunction_ = function() {
1189
- return (
1190
- /** @type {import("../geom/Geometry.js").default} */
1191
- e
1192
- );
1193
- }) : this.geometryFunction_ = p, this.geometry_ = e;
1338
+ setStroke(e) {
1339
+ this.stroke_ = e, this.render();
1194
1340
  }
1195
1341
  /**
1196
- * Set the z-index.
1197
- *
1198
- * @param {number|undefined} zIndex ZIndex.
1199
- * @api
1342
+ * @param {function(import("../events/Event.js").default): void} listener Listener function.
1200
1343
  */
1201
- setZIndex(e) {
1202
- this.zIndex_ = e;
1203
- }
1204
- }
1205
- function je(i) {
1206
- let e;
1207
- if (typeof i == "function")
1208
- e = i;
1209
- else {
1210
- let t;
1211
- Array.isArray(i) ? t = i : (w(typeof /** @type {?} */
1212
- i.getZIndex == "function", 41), t = [
1213
- /** @type {Style} */
1214
- i
1215
- ]), e = function() {
1216
- return t;
1217
- };
1218
- }
1219
- return e;
1220
- }
1221
- let W = null;
1222
- function $e(i, e) {
1223
- if (!W) {
1224
- const t = new C({
1225
- color: "rgba(255,255,255,0.4)"
1226
- }), n = new A({
1227
- color: "#3399CC",
1228
- width: 1.25
1229
- });
1230
- W = [
1231
- new S({
1232
- image: new R({
1233
- fill: t,
1234
- stroke: n,
1235
- radius: 5
1236
- }),
1237
- fill: t,
1238
- stroke: n
1239
- })
1240
- ];
1241
- }
1242
- return W;
1243
- }
1244
- function Qe() {
1245
- const i = {}, e = [255, 255, 255, 1], t = [0, 153, 255, 1], n = 3;
1246
- return i.Polygon = [
1247
- new S({
1248
- fill: new C({
1249
- color: [255, 255, 255, 0.5]
1250
- })
1251
- })
1252
- ], i.MultiPolygon = i.Polygon, i.LineString = [
1253
- new S({
1254
- stroke: new A({
1255
- color: e,
1256
- width: n + 2
1257
- })
1258
- }),
1259
- new S({
1260
- stroke: new A({
1261
- color: t,
1262
- width: n
1263
- })
1264
- })
1265
- ], i.MultiLineString = i.LineString, i.Circle = i.Polygon.concat(i.LineString), i.Point = [
1266
- new S({
1267
- image: new R({
1268
- radius: n * 2,
1269
- fill: new C({
1270
- color: t
1271
- }),
1272
- stroke: new A({
1273
- color: e,
1274
- width: n / 2
1275
- })
1276
- }),
1277
- zIndex: 1 / 0
1278
- })
1279
- ], i.MultiPoint = i.Point, i.GeometryCollection = i.Polygon.concat(
1280
- i.LineString,
1281
- i.Point
1282
- ), i;
1283
- }
1284
- function p(i) {
1285
- return i.getGeometry();
1286
- }
1287
- class Ce {
1288
- constructor() {
1289
- this.cache_ = {}, this.cacheSize_ = 0, this.maxCacheSize_ = 32;
1344
+ listenImageChange(e) {
1290
1345
  }
1291
1346
  /**
1292
- * FIXME empty description for jsdoc
1347
+ * Load not yet loaded URI.
1293
1348
  */
1294
- clear() {
1295
- this.cache_ = {}, this.cacheSize_ = 0;
1349
+ load() {
1296
1350
  }
1297
1351
  /**
1298
- * @return {boolean} Can expire cache.
1352
+ * @param {function(import("../events/Event.js").default): void} listener Listener function.
1299
1353
  */
1300
- canExpireCache() {
1301
- return this.cacheSize_ > this.maxCacheSize_;
1354
+ unlistenImageChange(e) {
1302
1355
  }
1303
1356
  /**
1304
- * FIXME empty description for jsdoc
1357
+ * Calculate additional canvas size needed for the miter.
1358
+ * @param {string} lineJoin Line join
1359
+ * @param {number} strokeWidth Stroke width
1360
+ * @param {number} miterLimit Miter limit
1361
+ * @return {number} Additional canvas size needed
1362
+ * @private
1305
1363
  */
1306
- expire() {
1307
- if (this.canExpireCache()) {
1308
- let e = 0;
1309
- for (const t in this.cache_) {
1310
- const n = this.cache_[t];
1311
- !(e++ & 3) && !n.hasListener() && (delete this.cache_[t], --this.cacheSize_);
1312
- }
1364
+ calculateLineJoinSize_(e, t, n) {
1365
+ if (t === 0 || this.points_ === 1 / 0 || e !== "bevel" && e !== "miter")
1366
+ return t;
1367
+ let s = this.radius_, r = this.radius2_ === void 0 ? s : this.radius2_;
1368
+ if (s < r) {
1369
+ const F = s;
1370
+ s = r, r = F;
1371
+ }
1372
+ const a = this.radius2_ === void 0 ? this.points_ : this.points_ * 2, l = 2 * Math.PI / a, o = r * Math.sin(l), c = Math.sqrt(r * r - o * o), h = s - c, u = Math.sqrt(o * o + h * h), f = u / o;
1373
+ if (e === "miter" && f <= n)
1374
+ return f * t;
1375
+ const g = t / 2 / f, d = t / 2 * (h / u), b = Math.sqrt((s + g) * (s + g) + d * d) - s;
1376
+ if (this.radius2_ === void 0 || e === "bevel")
1377
+ return b * 2;
1378
+ const k = s * Math.sin(l), re = Math.sqrt(s * s - k * k), H = r - re, B = Math.sqrt(k * k + H * H) / k;
1379
+ if (B <= n) {
1380
+ const F = B * t / 2 - r - s;
1381
+ return 2 * Math.max(b, F);
1313
1382
  }
1383
+ return b * 2;
1314
1384
  }
1315
1385
  /**
1316
- * @param {string} src Src.
1317
- * @param {?string} crossOrigin Cross origin.
1318
- * @param {import("../color.js").Color} color Color.
1319
- * @return {import("./IconImage.js").default} Icon image.
1320
- */
1321
- get(e, t, n) {
1322
- const s = q(e, t, n);
1323
- return s in this.cache_ ? this.cache_[s] : null;
1324
- }
1325
- /**
1326
- * @param {string} src Src.
1327
- * @param {?string} crossOrigin Cross origin.
1328
- * @param {import("../color.js").Color} color Color.
1329
- * @param {import("./IconImage.js").default} iconImage Icon image.
1330
- */
1331
- set(e, t, n, s) {
1332
- const r = q(e, t, n);
1333
- this.cache_[r] = s, ++this.cacheSize_;
1334
- }
1335
- /**
1336
- * Set the cache size of the icon cache. Default is `32`. Change this value when
1337
- * your map uses more than 32 different icon images and you are not caching icon
1338
- * styles on the application level.
1339
- * @param {number} maxCacheSize Cache max size.
1340
- * @api
1386
+ * @return {RenderOptions} The render options
1387
+ * @protected
1341
1388
  */
1342
- setSize(e) {
1343
- this.maxCacheSize_ = e, this.expire();
1389
+ createRenderOptions() {
1390
+ let e = p, t = 0, n = null, s = 0, r, a = 0;
1391
+ this.stroke_ && (r = this.stroke_.getColor(), r === null && (r = De), r = Z(r), a = this.stroke_.getWidth(), a === void 0 && (a = we), n = this.stroke_.getLineDash(), s = this.stroke_.getLineDashOffset(), e = this.stroke_.getLineJoin(), e === void 0 && (e = p), t = this.stroke_.getMiterLimit(), t === void 0 && (t = Ie));
1392
+ const l = this.calculateLineJoinSize_(e, a, t), o = Math.max(this.radius_, this.radius2_ || 0), c = Math.ceil(2 * o + l);
1393
+ return {
1394
+ strokeStyle: r,
1395
+ strokeWidth: a,
1396
+ size: c,
1397
+ lineDash: n,
1398
+ lineDashOffset: s,
1399
+ lineJoin: e,
1400
+ miterLimit: t
1401
+ };
1344
1402
  }
1345
- }
1346
- function q(i, e, t) {
1347
- const n = t ? $(t) : "null";
1348
- return e + ":" + i + ":" + n;
1349
- }
1350
- const Z = new Ce();
1351
- function ke(i, e, t) {
1352
- const n = (
1353
- /** @type {HTMLImageElement} */
1354
- i
1355
- );
1356
- let s = !0, r = !1, a = !1;
1357
- const l = [
1358
- N(n, O.LOAD, function() {
1359
- a = !0, r || e();
1360
- })
1361
- ];
1362
- return n.src && he ? (r = !0, n.decode().then(function() {
1363
- s && e();
1364
- }).catch(function(o) {
1365
- s && (a ? e() : t());
1366
- })) : l.push(N(n, O.ERROR, t)), function() {
1367
- s = !1, l.forEach(ce);
1368
- };
1369
- }
1370
- let z = null;
1371
- class ze extends oe {
1372
1403
  /**
1373
- * @param {HTMLImageElement|HTMLCanvasElement} image Image.
1374
- * @param {string|undefined} src Src.
1375
- * @param {import("../size.js").Size} size Size.
1376
- * @param {?string} crossOrigin Cross origin.
1377
- * @param {import("../ImageState.js").default} imageState Image state.
1378
- * @param {import("../color.js").Color} color Color.
1404
+ * @protected
1379
1405
  */
1380
- constructor(e, t, n, s, r, a) {
1381
- super(), this.hitDetectionImage_ = null, this.image_ = e, this.crossOrigin_ = s, this.canvas_ = {}, this.color_ = a, this.unlisten_ = null, this.imageState_ = r, this.size_ = n, this.src_ = t, this.tainted_;
1406
+ render() {
1407
+ this.renderOptions_ = this.createRenderOptions();
1408
+ const e = this.renderOptions_.size;
1409
+ this.canvas_ = {}, this.size_ = [e, e];
1382
1410
  }
1383
1411
  /**
1384
1412
  * @private
1413
+ * @param {RenderOptions} renderOptions Render options.
1414
+ * @param {CanvasRenderingContext2D} context The rendering context.
1415
+ * @param {number} pixelRatio The pixel ratio.
1385
1416
  */
1386
- initializeImage_() {
1387
- this.image_ = new Image(), this.crossOrigin_ !== null && (this.image_.crossOrigin = this.crossOrigin_);
1417
+ draw_(e, t, n) {
1418
+ if (t.scale(n, n), t.translate(e.size / 2, e.size / 2), this.createPath_(t), this.fill_) {
1419
+ let s = this.fill_.getColor();
1420
+ s === null && (s = G), t.fillStyle = Z(s), t.fill();
1421
+ }
1422
+ this.stroke_ && (t.strokeStyle = e.strokeStyle, t.lineWidth = e.strokeWidth, e.lineDash && (t.setLineDash(e.lineDash), t.lineDashOffset = e.lineDashOffset), t.lineJoin = e.lineJoin, t.miterLimit = e.miterLimit, t.stroke());
1388
1423
  }
1389
1424
  /**
1390
1425
  * @private
1391
- * @return {boolean} The image canvas is tainted.
1426
+ * @param {RenderOptions} renderOptions Render options.
1392
1427
  */
1393
- isTainted_() {
1394
- if (this.tainted_ === void 0 && this.imageState_ === _.LOADED) {
1395
- z || (z = L(1, 1, void 0, {
1396
- willReadFrequently: !0
1397
- })), z.drawImage(this.image_, 0, 0);
1398
- try {
1399
- z.getImageData(0, 0, 1, 1), this.tainted_ = !1;
1400
- } catch {
1401
- z = null, this.tainted_ = !0;
1428
+ createHitDetectionCanvas_(e) {
1429
+ if (this.fill_) {
1430
+ let t = this.fill_.getColor(), n = 0;
1431
+ if (typeof t == "string" && (t = Q(t)), t === null ? n = 1 : Array.isArray(t) && (n = t.length === 4 ? t[3] : 1), n === 0) {
1432
+ const s = L(
1433
+ e.size,
1434
+ e.size
1435
+ );
1436
+ this.hitDetectionCanvas_ = s.canvas, this.drawHitDetectionCanvas_(e, s);
1402
1437
  }
1403
1438
  }
1404
- return this.tainted_ === !0;
1405
- }
1406
- /**
1407
- * @private
1408
- */
1409
- dispatchChangeEvent_() {
1410
- this.dispatchEvent(O.CHANGE);
1411
- }
1412
- /**
1413
- * @private
1414
- */
1415
- handleImageError_() {
1416
- this.imageState_ = _.ERROR, this.unlistenImage_(), this.dispatchChangeEvent_();
1439
+ this.hitDetectionCanvas_ || (this.hitDetectionCanvas_ = this.getImage(1));
1417
1440
  }
1418
1441
  /**
1419
1442
  * @private
1443
+ * @param {CanvasRenderingContext2D} context The context to draw in.
1420
1444
  */
1421
- handleImageLoad_() {
1422
- this.imageState_ = _.LOADED, this.size_ ? (this.image_.width = this.size_[0], this.image_.height = this.size_[1]) : this.size_ = [this.image_.width, this.image_.height], this.unlistenImage_(), this.dispatchChangeEvent_();
1423
- }
1424
- /**
1425
- * @param {number} pixelRatio Pixel ratio.
1426
- * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
1427
- */
1428
- getImage(e) {
1429
- return this.image_ || this.initializeImage_(), this.replaceColor_(e), this.canvas_[e] ? this.canvas_[e] : this.image_;
1430
- }
1431
- /**
1432
- * @param {number} pixelRatio Pixel ratio.
1433
- * @return {number} Image or Canvas element.
1434
- */
1435
- getPixelRatio(e) {
1436
- return this.replaceColor_(e), this.canvas_[e] ? e : 1;
1437
- }
1438
- /**
1439
- * @return {import("../ImageState.js").default} Image state.
1440
- */
1441
- getImageState() {
1442
- return this.imageState_;
1443
- }
1444
- /**
1445
- * @return {HTMLImageElement|HTMLCanvasElement} Image element.
1446
- */
1447
- getHitDetectionImage() {
1448
- if (this.image_ || this.initializeImage_(), !this.hitDetectionImage_)
1449
- if (this.isTainted_()) {
1450
- const e = this.size_[0], t = this.size_[1], n = L(e, t);
1451
- n.fillRect(0, 0, e, t), this.hitDetectionImage_ = n.canvas;
1452
- } else
1453
- this.hitDetectionImage_ = this.image_;
1454
- return this.hitDetectionImage_;
1455
- }
1456
- /**
1457
- * Get the size of the icon (in pixels).
1458
- * @return {import("../size.js").Size} Image size.
1459
- */
1460
- getSize() {
1461
- return this.size_;
1462
- }
1463
- /**
1464
- * @return {string|undefined} Image src.
1465
- */
1466
- getSrc() {
1467
- return this.src_;
1468
- }
1469
- /**
1470
- * Load not yet loaded URI.
1471
- */
1472
- load() {
1473
- if (this.imageState_ === _.IDLE) {
1474
- this.image_ || this.initializeImage_(), this.imageState_ = _.LOADING;
1475
- try {
1476
- this.image_.src = this.src_;
1477
- } catch {
1478
- this.handleImageError_();
1445
+ createPath_(e) {
1446
+ let t = this.points_;
1447
+ const n = this.radius_;
1448
+ if (t === 1 / 0)
1449
+ e.arc(0, 0, n, 0, 2 * Math.PI);
1450
+ else {
1451
+ const s = this.radius2_ === void 0 ? n : this.radius2_;
1452
+ this.radius2_ !== void 0 && (t *= 2);
1453
+ const r = this.angle_ - Math.PI / 2, a = 2 * Math.PI / t;
1454
+ for (let l = 0; l < t; l++) {
1455
+ const o = r + l * a, c = l % 2 === 0 ? n : s;
1456
+ e.lineTo(c * Math.cos(o), c * Math.sin(o));
1479
1457
  }
1480
- this.unlisten_ = ke(
1481
- this.image_,
1482
- this.handleImageLoad_.bind(this),
1483
- this.handleImageError_.bind(this)
1484
- );
1458
+ e.closePath();
1485
1459
  }
1486
1460
  }
1487
1461
  /**
1488
- * @param {number} pixelRatio Pixel ratio.
1489
- * @private
1490
- */
1491
- replaceColor_(e) {
1492
- if (!this.color_ || this.canvas_[e] || this.imageState_ !== _.LOADED)
1493
- return;
1494
- const t = this.image_, n = document.createElement("canvas");
1495
- n.width = Math.ceil(t.width * e), n.height = Math.ceil(t.height * e);
1496
- const s = n.getContext("2d");
1497
- s.scale(e, e), s.drawImage(t, 0, 0), s.globalCompositeOperation = "multiply", s.fillStyle = $(this.color_), s.fillRect(0, 0, n.width / e, n.height / e), s.globalCompositeOperation = "destination-in", s.drawImage(t, 0, 0), this.canvas_[e] = n;
1498
- }
1499
- /**
1500
- * Discards event handlers which listen for load completion or errors.
1501
- *
1502
1462
  * @private
1463
+ * @param {RenderOptions} renderOptions Render options.
1464
+ * @param {CanvasRenderingContext2D} context The context.
1503
1465
  */
1504
- unlistenImage_() {
1505
- this.unlisten_ && (this.unlisten_(), this.unlisten_ = null);
1466
+ drawHitDetectionCanvas_(e, t) {
1467
+ t.translate(e.size / 2, e.size / 2), this.createPath_(t), t.fillStyle = G, t.fill(), this.stroke_ && (t.strokeStyle = e.strokeStyle, t.lineWidth = e.strokeWidth, e.lineDash && (t.setLineDash(e.lineDash), t.lineDashOffset = e.lineDashOffset), t.lineJoin = e.lineJoin, t.miterLimit = e.miterLimit, t.stroke());
1506
1468
  }
1507
1469
  }
1508
- function Oe(i, e, t, n, s, r) {
1509
- let a = Z.get(e, n, r);
1510
- return a || (a = new ze(i, e, t, n, s, r), Z.set(e, n, r, a)), a;
1511
- }
1512
- function K(i, e, t, n) {
1513
- return t !== void 0 && n !== void 0 ? [t / i, n / e] : t !== void 0 ? t / i : n !== void 0 ? n / e : 1;
1514
- }
1515
- class ne extends E {
1470
+ class R extends V {
1516
1471
  /**
1517
1472
  * @param {Options} [options] Options.
1518
1473
  */
1519
1474
  constructor(e) {
1520
- e = e || {};
1521
- const t = e.opacity !== void 0 ? e.opacity : 1, n = e.rotation !== void 0 ? e.rotation : 0, s = e.scale !== void 0 ? e.scale : 1, r = e.rotateWithView !== void 0 ? e.rotateWithView : !1;
1522
- super({
1523
- opacity: t,
1524
- rotation: n,
1525
- scale: s,
1475
+ e = e || { radius: 5 }, super({
1476
+ points: 1 / 0,
1477
+ fill: e.fill,
1478
+ radius: e.radius,
1479
+ stroke: e.stroke,
1480
+ scale: e.scale !== void 0 ? e.scale : 1,
1481
+ rotation: e.rotation !== void 0 ? e.rotation : 0,
1482
+ rotateWithView: e.rotateWithView !== void 0 ? e.rotateWithView : !1,
1526
1483
  displacement: e.displacement !== void 0 ? e.displacement : [0, 0],
1527
- rotateWithView: r,
1528
1484
  declutterMode: e.declutterMode
1529
- }), this.anchor_ = e.anchor !== void 0 ? e.anchor : [0.5, 0.5], this.normalizedAnchor_ = null, this.anchorOrigin_ = e.anchorOrigin !== void 0 ? e.anchorOrigin : "top-left", this.anchorXUnits_ = e.anchorXUnits !== void 0 ? e.anchorXUnits : "fraction", this.anchorYUnits_ = e.anchorYUnits !== void 0 ? e.anchorYUnits : "fraction", this.crossOrigin_ = e.crossOrigin !== void 0 ? e.crossOrigin : null;
1530
- const a = e.img !== void 0 ? e.img : null;
1531
- this.imgSize_ = e.imgSize;
1532
- let l = e.src;
1533
- w(!(l !== void 0 && a), 4), w(!a || a && this.imgSize_, 5), (l === void 0 || l.length === 0) && a && (l = /** @type {HTMLImageElement} */
1534
- a.src || ue(a)), w(l !== void 0 && l.length > 0, 6), w(
1535
- !((e.width !== void 0 || e.height !== void 0) && e.scale !== void 0),
1536
- 69
1537
- );
1538
- const o = e.src !== void 0 ? _.IDLE : _.LOADED;
1539
- if (this.color_ = e.color !== void 0 ? Q(e.color) : null, this.iconImage_ = Oe(
1540
- a,
1541
- /** @type {string} */
1542
- l,
1543
- this.imgSize_ !== void 0 ? this.imgSize_ : null,
1544
- this.crossOrigin_,
1545
- o,
1546
- this.color_
1547
- ), this.offset_ = e.offset !== void 0 ? e.offset : [0, 0], this.offsetOrigin_ = e.offsetOrigin !== void 0 ? e.offsetOrigin : "top-left", this.origin_ = null, this.size_ = e.size !== void 0 ? e.size : null, e.width !== void 0 || e.height !== void 0) {
1548
- let c, h;
1549
- if (e.size)
1550
- [c, h] = e.size;
1551
- else {
1552
- const u = this.getImage(1);
1553
- if (u instanceof HTMLCanvasElement || u.src && u.complete)
1554
- c = u.width, h = u.height;
1555
- else {
1556
- this.initialOptions_ = e;
1557
- const f = () => {
1558
- if (this.unlistenImageChange(f), !this.initialOptions_)
1559
- return;
1560
- const g = this.iconImage_.getSize();
1561
- this.setScale(
1562
- K(
1563
- g[0],
1564
- g[1],
1565
- e.width,
1566
- e.height
1567
- )
1568
- );
1569
- };
1570
- this.listenImageChange(f);
1571
- return;
1572
- }
1573
- }
1574
- c !== void 0 && this.setScale(
1575
- K(c, h, e.width, e.height)
1576
- );
1577
- }
1485
+ });
1578
1486
  }
1579
1487
  /**
1580
- * Clones the style. The underlying Image/HTMLCanvasElement is not cloned.
1581
- * @return {Icon} The cloned style.
1488
+ * Clones the style.
1489
+ * @return {CircleStyle} The cloned style.
1582
1490
  * @api
1583
1491
  */
1584
1492
  clone() {
1585
- let e, t, n;
1586
- return this.initialOptions_ ? (t = this.initialOptions_.width, n = this.initialOptions_.height) : (e = this.getScale(), e = Array.isArray(e) ? e.slice() : e), new ne({
1587
- anchor: this.anchor_.slice(),
1588
- anchorOrigin: this.anchorOrigin_,
1589
- anchorXUnits: this.anchorXUnits_,
1590
- anchorYUnits: this.anchorYUnits_,
1591
- color: this.color_ && this.color_.slice ? this.color_.slice() : this.color_ || void 0,
1592
- crossOrigin: this.crossOrigin_,
1593
- imgSize: this.imgSize_,
1594
- offset: this.offset_.slice(),
1595
- offsetOrigin: this.offsetOrigin_,
1596
- opacity: this.getOpacity(),
1597
- rotateWithView: this.getRotateWithView(),
1493
+ const e = this.getScale(), t = new R({
1494
+ fill: this.getFill() ? this.getFill().clone() : void 0,
1495
+ stroke: this.getStroke() ? this.getStroke().clone() : void 0,
1496
+ radius: this.getRadius(),
1497
+ scale: Array.isArray(e) ? e.slice() : e,
1598
1498
  rotation: this.getRotation(),
1599
- scale: e,
1600
- width: t,
1601
- height: n,
1602
- size: this.size_ !== null ? this.size_.slice() : void 0,
1603
- src: this.getSrc(),
1499
+ rotateWithView: this.getRotateWithView(),
1604
1500
  displacement: this.getDisplacement().slice(),
1605
1501
  declutterMode: this.getDeclutterMode()
1606
1502
  });
1503
+ return t.setOpacity(this.getOpacity()), t;
1607
1504
  }
1608
1505
  /**
1609
- * Get the anchor point in pixels. The anchor determines the center point for the
1610
- * symbolizer.
1611
- * @return {Array<number>} Anchor.
1506
+ * Set the circle radius.
1507
+ *
1508
+ * @param {number} radius Circle radius.
1612
1509
  * @api
1613
1510
  */
1614
- getAnchor() {
1615
- let e = this.normalizedAnchor_;
1616
- if (!e) {
1617
- e = this.anchor_;
1618
- const s = this.getSize();
1619
- if (this.anchorXUnits_ == "fraction" || this.anchorYUnits_ == "fraction") {
1620
- if (!s)
1621
- return null;
1622
- e = this.anchor_.slice(), this.anchorXUnits_ == "fraction" && (e[0] *= s[0]), this.anchorYUnits_ == "fraction" && (e[1] *= s[1]);
1623
- }
1624
- if (this.anchorOrigin_ != "top-left") {
1625
- if (!s)
1626
- return null;
1627
- e === this.anchor_ && (e = this.anchor_.slice()), (this.anchorOrigin_ == "top-right" || this.anchorOrigin_ == "bottom-right") && (e[0] = -e[0] + s[0]), (this.anchorOrigin_ == "bottom-left" || this.anchorOrigin_ == "bottom-right") && (e[1] = -e[1] + s[1]);
1628
- }
1629
- this.normalizedAnchor_ = e;
1630
- }
1631
- const t = this.getDisplacement(), n = this.getScaleArray();
1632
- return [
1633
- e[0] - t[0] / n[0],
1634
- e[1] + t[1] / n[1]
1635
- ];
1511
+ setRadius(e) {
1512
+ this.radius_ = e, this.render();
1513
+ }
1514
+ }
1515
+ class S {
1516
+ /**
1517
+ * @param {Options} [options] Style options.
1518
+ */
1519
+ constructor(e) {
1520
+ e = e || {}, this.geometry_ = null, this.geometryFunction_ = K, e.geometry !== void 0 && this.setGeometry(e.geometry), this.fill_ = e.fill !== void 0 ? e.fill : null, this.image_ = e.image !== void 0 ? e.image : null, this.renderer_ = e.renderer !== void 0 ? e.renderer : null, this.hitDetectionRenderer_ = e.hitDetectionRenderer !== void 0 ? e.hitDetectionRenderer : null, this.stroke_ = e.stroke !== void 0 ? e.stroke : null, this.text_ = e.text !== void 0 ? e.text : null, this.zIndex_ = e.zIndex;
1521
+ }
1522
+ /**
1523
+ * Clones the style.
1524
+ * @return {Style} The cloned style.
1525
+ * @api
1526
+ */
1527
+ clone() {
1528
+ let e = this.getGeometry();
1529
+ return e && typeof e == "object" && (e = /** @type {import("../geom/Geometry.js").default} */
1530
+ e.clone()), new S({
1531
+ geometry: e,
1532
+ fill: this.getFill() ? this.getFill().clone() : void 0,
1533
+ image: this.getImage() ? this.getImage().clone() : void 0,
1534
+ renderer: this.getRenderer(),
1535
+ stroke: this.getStroke() ? this.getStroke().clone() : void 0,
1536
+ text: this.getText() ? this.getText().clone() : void 0,
1537
+ zIndex: this.getZIndex()
1538
+ });
1539
+ }
1540
+ /**
1541
+ * Get the custom renderer function that was configured with
1542
+ * {@link #setRenderer} or the `renderer` constructor option.
1543
+ * @return {RenderFunction|null} Custom renderer function.
1544
+ * @api
1545
+ */
1546
+ getRenderer() {
1547
+ return this.renderer_;
1636
1548
  }
1637
1549
  /**
1638
- * Set the anchor point. The anchor determines the center point for the
1639
- * symbolizer.
1640
- *
1641
- * @param {Array<number>} anchor Anchor.
1550
+ * Sets a custom renderer function for this style. When set, `fill`, `stroke`
1551
+ * and `image` options of the style will be ignored.
1552
+ * @param {RenderFunction|null} renderer Custom renderer function.
1642
1553
  * @api
1643
1554
  */
1644
- setAnchor(e) {
1645
- this.anchor_ = e, this.normalizedAnchor_ = null;
1555
+ setRenderer(e) {
1556
+ this.renderer_ = e;
1646
1557
  }
1647
1558
  /**
1648
- * Get the icon color.
1649
- * @return {import("../color.js").Color} Color.
1559
+ * Sets a custom renderer function for this style used
1560
+ * in hit detection.
1561
+ * @param {RenderFunction|null} renderer Custom renderer function.
1650
1562
  * @api
1651
1563
  */
1652
- getColor() {
1653
- return this.color_;
1564
+ setHitDetectionRenderer(e) {
1565
+ this.hitDetectionRenderer_ = e;
1654
1566
  }
1655
1567
  /**
1656
- * Get the image icon.
1657
- * @param {number} pixelRatio Pixel ratio.
1658
- * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
1568
+ * Get the custom renderer function that was configured with
1569
+ * {@link #setHitDetectionRenderer} or the `hitDetectionRenderer` constructor option.
1570
+ * @return {RenderFunction|null} Custom renderer function.
1659
1571
  * @api
1660
1572
  */
1661
- getImage(e) {
1662
- return this.iconImage_.getImage(e);
1573
+ getHitDetectionRenderer() {
1574
+ return this.hitDetectionRenderer_;
1663
1575
  }
1664
1576
  /**
1665
- * Get the pixel ratio.
1666
- * @param {number} pixelRatio Pixel ratio.
1667
- * @return {number} The pixel ratio of the image.
1577
+ * Get the geometry to be rendered.
1578
+ * @return {string|import("../geom/Geometry.js").default|GeometryFunction}
1579
+ * Feature property or geometry or function that returns the geometry that will
1580
+ * be rendered with this style.
1668
1581
  * @api
1669
1582
  */
1670
- getPixelRatio(e) {
1671
- return this.iconImage_.getPixelRatio(e);
1583
+ getGeometry() {
1584
+ return this.geometry_;
1672
1585
  }
1673
1586
  /**
1674
- * @return {import("../size.js").Size} Image size.
1587
+ * Get the function used to generate a geometry for rendering.
1588
+ * @return {!GeometryFunction} Function that is called with a feature
1589
+ * and returns the geometry to render instead of the feature's geometry.
1590
+ * @api
1675
1591
  */
1676
- getImageSize() {
1677
- return this.iconImage_.getSize();
1592
+ getGeometryFunction() {
1593
+ return this.geometryFunction_;
1678
1594
  }
1679
1595
  /**
1680
- * @return {import("../ImageState.js").default} Image state.
1596
+ * Get the fill style.
1597
+ * @return {import("./Fill.js").default} Fill style.
1598
+ * @api
1681
1599
  */
1682
- getImageState() {
1683
- return this.iconImage_.getImageState();
1600
+ getFill() {
1601
+ return this.fill_;
1684
1602
  }
1685
1603
  /**
1686
- * @return {HTMLImageElement|HTMLCanvasElement} Image element.
1604
+ * Set the fill style.
1605
+ * @param {import("./Fill.js").default} fill Fill style.
1606
+ * @api
1687
1607
  */
1688
- getHitDetectionImage() {
1689
- return this.iconImage_.getHitDetectionImage();
1608
+ setFill(e) {
1609
+ this.fill_ = e;
1690
1610
  }
1691
1611
  /**
1692
- * Get the origin of the symbolizer.
1693
- * @return {Array<number>} Origin.
1612
+ * Get the image style.
1613
+ * @return {import("./Image.js").default} Image style.
1694
1614
  * @api
1695
1615
  */
1696
- getOrigin() {
1697
- if (this.origin_)
1698
- return this.origin_;
1699
- let e = this.offset_;
1700
- if (this.offsetOrigin_ != "top-left") {
1701
- const t = this.getSize(), n = this.iconImage_.getSize();
1702
- if (!t || !n)
1703
- return null;
1704
- e = e.slice(), (this.offsetOrigin_ == "top-right" || this.offsetOrigin_ == "bottom-right") && (e[0] = n[0] - t[0] - e[0]), (this.offsetOrigin_ == "bottom-left" || this.offsetOrigin_ == "bottom-right") && (e[1] = n[1] - t[1] - e[1]);
1705
- }
1706
- return this.origin_ = e, this.origin_;
1616
+ getImage() {
1617
+ return this.image_;
1707
1618
  }
1708
1619
  /**
1709
- * Get the image URL.
1710
- * @return {string|undefined} Image src.
1620
+ * Set the image style.
1621
+ * @param {import("./Image.js").default} image Image style.
1711
1622
  * @api
1712
1623
  */
1713
- getSrc() {
1714
- return this.iconImage_.getSrc();
1624
+ setImage(e) {
1625
+ this.image_ = e;
1715
1626
  }
1716
1627
  /**
1717
- * Get the size of the icon (in pixels).
1718
- * @return {import("../size.js").Size} Image size.
1628
+ * Get the stroke style.
1629
+ * @return {import("./Stroke.js").default} Stroke style.
1719
1630
  * @api
1720
1631
  */
1721
- getSize() {
1722
- return this.size_ ? this.size_ : this.iconImage_.getSize();
1632
+ getStroke() {
1633
+ return this.stroke_;
1723
1634
  }
1724
1635
  /**
1725
- * Get the width of the icon (in pixels). Will return undefined when the icon image is not yet loaded.
1726
- * @return {number} Icon width (in pixels).
1636
+ * Set the stroke style.
1637
+ * @param {import("./Stroke.js").default} stroke Stroke style.
1727
1638
  * @api
1728
1639
  */
1729
- getWidth() {
1730
- const e = this.getScaleArray();
1731
- if (this.size_)
1732
- return this.size_[0] * e[0];
1733
- if (this.iconImage_.getImageState() == _.LOADED)
1734
- return this.iconImage_.getSize()[0] * e[0];
1640
+ setStroke(e) {
1641
+ this.stroke_ = e;
1735
1642
  }
1736
1643
  /**
1737
- * Get the height of the icon (in pixels). Will return undefined when the icon image is not yet loaded.
1738
- * @return {number} Icon height (in pixels).
1644
+ * Get the text style.
1645
+ * @return {import("./Text.js").default} Text style.
1739
1646
  * @api
1740
1647
  */
1741
- getHeight() {
1742
- const e = this.getScaleArray();
1743
- if (this.size_)
1744
- return this.size_[1] * e[1];
1745
- if (this.iconImage_.getImageState() == _.LOADED)
1746
- return this.iconImage_.getSize()[1] * e[1];
1648
+ getText() {
1649
+ return this.text_;
1747
1650
  }
1748
1651
  /**
1749
- * Set the scale.
1750
- *
1751
- * @param {number|import("../size.js").Size} scale Scale.
1652
+ * Set the text style.
1653
+ * @param {import("./Text.js").default} text Text style.
1752
1654
  * @api
1753
1655
  */
1754
- setScale(e) {
1755
- delete this.initialOptions_, super.setScale(e);
1656
+ setText(e) {
1657
+ this.text_ = e;
1756
1658
  }
1757
1659
  /**
1758
- * @param {function(import("../events/Event.js").default): void} listener Listener function.
1660
+ * Get the z-index for the style.
1661
+ * @return {number|undefined} ZIndex.
1662
+ * @api
1759
1663
  */
1760
- listenImageChange(e) {
1761
- this.iconImage_.addEventListener(O.CHANGE, e);
1664
+ getZIndex() {
1665
+ return this.zIndex_;
1762
1666
  }
1763
1667
  /**
1764
- * Load not yet loaded URI.
1765
- * When rendering a feature with an icon style, the vector renderer will
1766
- * automatically call this method. However, you might want to call this
1767
- * method yourself for preloading or other purposes.
1668
+ * Set a geometry that is rendered instead of the feature's geometry.
1669
+ *
1670
+ * @param {string|import("../geom/Geometry.js").default|GeometryFunction} geometry
1671
+ * Feature property or geometry or function returning a geometry to render
1672
+ * for this style.
1768
1673
  * @api
1769
1674
  */
1770
- load() {
1771
- this.iconImage_.load();
1675
+ setGeometry(e) {
1676
+ typeof e == "function" ? this.geometryFunction_ = e : typeof e == "string" ? this.geometryFunction_ = function(t) {
1677
+ return (
1678
+ /** @type {import("../geom/Geometry.js").default} */
1679
+ t.get(e)
1680
+ );
1681
+ } : e ? e !== void 0 && (this.geometryFunction_ = function() {
1682
+ return (
1683
+ /** @type {import("../geom/Geometry.js").default} */
1684
+ e
1685
+ );
1686
+ }) : this.geometryFunction_ = K, this.geometry_ = e;
1772
1687
  }
1773
1688
  /**
1774
- * @param {function(import("../events/Event.js").default): void} listener Listener function.
1689
+ * Set the z-index.
1690
+ *
1691
+ * @param {number|undefined} zIndex ZIndex.
1692
+ * @api
1775
1693
  */
1776
- unlistenImageChange(e) {
1777
- this.iconImage_.removeEventListener(O.CHANGE, e);
1694
+ setZIndex(e) {
1695
+ this.zIndex_ = e;
1696
+ }
1697
+ }
1698
+ function je(i) {
1699
+ let e;
1700
+ if (typeof i == "function")
1701
+ e = i;
1702
+ else {
1703
+ let t;
1704
+ Array.isArray(i) ? t = i : (w(typeof /** @type {?} */
1705
+ i.getZIndex == "function", 41), t = [
1706
+ /** @type {Style} */
1707
+ i
1708
+ ]), e = function() {
1709
+ return t;
1710
+ };
1711
+ }
1712
+ return e;
1713
+ }
1714
+ let W = null;
1715
+ function $e(i, e) {
1716
+ if (!W) {
1717
+ const t = new C({
1718
+ color: "rgba(255,255,255,0.4)"
1719
+ }), n = new A({
1720
+ color: "#3399CC",
1721
+ width: 1.25
1722
+ });
1723
+ W = [
1724
+ new S({
1725
+ image: new R({
1726
+ fill: t,
1727
+ stroke: n,
1728
+ radius: 5
1729
+ }),
1730
+ fill: t,
1731
+ stroke: n
1732
+ })
1733
+ ];
1778
1734
  }
1735
+ return W;
1736
+ }
1737
+ function Qe() {
1738
+ const i = {}, e = [255, 255, 255, 1], t = [0, 153, 255, 1], n = 3;
1739
+ return i.Polygon = [
1740
+ new S({
1741
+ fill: new C({
1742
+ color: [255, 255, 255, 0.5]
1743
+ })
1744
+ })
1745
+ ], i.MultiPolygon = i.Polygon, i.LineString = [
1746
+ new S({
1747
+ stroke: new A({
1748
+ color: e,
1749
+ width: n + 2
1750
+ })
1751
+ }),
1752
+ new S({
1753
+ stroke: new A({
1754
+ color: t,
1755
+ width: n
1756
+ })
1757
+ })
1758
+ ], i.MultiLineString = i.LineString, i.Circle = i.Polygon.concat(i.LineString), i.Point = [
1759
+ new S({
1760
+ image: new R({
1761
+ radius: n * 2,
1762
+ fill: new C({
1763
+ color: t
1764
+ }),
1765
+ stroke: new A({
1766
+ color: e,
1767
+ width: n / 2
1768
+ })
1769
+ }),
1770
+ zIndex: 1 / 0
1771
+ })
1772
+ ], i.MultiPoint = i.Point, i.GeometryCollection = i.Polygon.concat(
1773
+ i.LineString,
1774
+ i.Point
1775
+ ), i;
1776
+ }
1777
+ function K(i) {
1778
+ return i.getGeometry();
1779
1779
  }
1780
1780
  const Le = "#333";
1781
1781
  class se {
@@ -1783,7 +1783,7 @@ class se {
1783
1783
  * @param {Options} [options] Options.
1784
1784
  */
1785
1785
  constructor(e) {
1786
- e = e || {}, this.font_ = e.font, this.rotation_ = e.rotation, this.rotateWithView_ = e.rotateWithView, this.scale_ = e.scale, this.scaleArray_ = x(e.scale !== void 0 ? e.scale : 1), this.text_ = e.text, this.textAlign_ = e.textAlign, this.justify_ = e.justify, this.repeat_ = e.repeat, this.textBaseline_ = e.textBaseline, this.fill_ = e.fill !== void 0 ? e.fill : new C({ color: Le }), this.maxAngle_ = e.maxAngle !== void 0 ? e.maxAngle : Math.PI / 4, this.placement_ = e.placement !== void 0 ? e.placement : "point", this.overflow_ = !!e.overflow, this.stroke_ = e.stroke !== void 0 ? e.stroke : null, this.offsetX_ = e.offsetX !== void 0 ? e.offsetX : 0, this.offsetY_ = e.offsetY !== void 0 ? e.offsetY : 0, this.backgroundFill_ = e.backgroundFill ? e.backgroundFill : null, this.backgroundStroke_ = e.backgroundStroke ? e.backgroundStroke : null, this.padding_ = e.padding === void 0 ? null : e.padding;
1786
+ e = e || {}, this.font_ = e.font, this.rotation_ = e.rotation, this.rotateWithView_ = e.rotateWithView, this.scale_ = e.scale, this.scaleArray_ = M(e.scale !== void 0 ? e.scale : 1), this.text_ = e.text, this.textAlign_ = e.textAlign, this.justify_ = e.justify, this.repeat_ = e.repeat, this.textBaseline_ = e.textBaseline, this.fill_ = e.fill !== void 0 ? e.fill : new C({ color: Le }), this.maxAngle_ = e.maxAngle !== void 0 ? e.maxAngle : Math.PI / 4, this.placement_ = e.placement !== void 0 ? e.placement : "point", this.overflow_ = !!e.overflow, this.stroke_ = e.stroke !== void 0 ? e.stroke : null, this.offsetX_ = e.offsetX !== void 0 ? e.offsetX : 0, this.offsetY_ = e.offsetY !== void 0 ? e.offsetY : 0, this.backgroundFill_ = e.backgroundFill ? e.backgroundFill : null, this.backgroundStroke_ = e.backgroundStroke ? e.backgroundStroke : null, this.padding_ = e.padding === void 0 ? null : e.padding;
1787
1787
  }
1788
1788
  /**
1789
1789
  * Clones the style.
@@ -2069,7 +2069,7 @@ class se {
2069
2069
  * @api
2070
2070
  */
2071
2071
  setScale(e) {
2072
- this.scale_ = e, this.scaleArray_ = x(e !== void 0 ? e : 1);
2072
+ this.scale_ = e, this.scaleArray_ = M(e !== void 0 ? e : 1);
2073
2073
  }
2074
2074
  /**
2075
2075
  * Set the stroke.
@@ -2145,48 +2145,48 @@ class se {
2145
2145
  }
2146
2146
  }
2147
2147
  export {
2148
- Xe as A,
2149
- G as B,
2148
+ Je as A,
2149
+ p as B,
2150
2150
  R as C,
2151
- De as D,
2152
- Se as E,
2151
+ we as D,
2152
+ Ie as E,
2153
2153
  C as F,
2154
- Ge as G,
2155
- Ue as H,
2154
+ Ye as G,
2155
+ Xe as H,
2156
2156
  ne as I,
2157
- Ye as J,
2158
- Be as K,
2159
- pe as L,
2160
- Ze as M,
2161
- Ke as N,
2162
- qe as O,
2157
+ Ue as J,
2158
+ He as K,
2159
+ Ge as L,
2160
+ qe as M,
2161
+ Ze as N,
2162
+ pe as O,
2163
2163
  V as R,
2164
2164
  S,
2165
2165
  se as T,
2166
2166
  A as a,
2167
2167
  y as b,
2168
2168
  Qe as c,
2169
- Pe as d,
2170
- be as e,
2171
- Ve as f,
2172
- He as g,
2173
- Fe as h,
2174
- Re as i,
2175
- Te as j,
2176
- Me as k,
2169
+ Ee as d,
2170
+ Te as e,
2171
+ Re as f,
2172
+ be as g,
2173
+ Pe as h,
2174
+ We as i,
2175
+ Me as j,
2176
+ Ke as k,
2177
2177
  _ as l,
2178
2178
  Q as m,
2179
2179
  L as n,
2180
2180
  ke as o,
2181
- Ee as p,
2181
+ Fe as p,
2182
2182
  je as q,
2183
- We as r,
2184
- Z as s,
2185
- x as t,
2183
+ Ve as r,
2184
+ U as s,
2185
+ M as t,
2186
2186
  $e as u,
2187
- X as v,
2188
- Y as w,
2189
- Ie as x,
2190
- Ne as y,
2191
- Je as z
2187
+ Z as v,
2188
+ G as w,
2189
+ De as x,
2190
+ Be as y,
2191
+ Ne as z
2192
2192
  };