ol-contextmenu 5.2.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,721 +1,134 @@
1
1
 
2
2
  /*!
3
- * ol-contextmenu - v5.2.1
3
+ * ol-contextmenu - v5.3.0
4
4
  * https://github.com/jonataswalker/ol-contextmenu
5
- * Built: Fri Mar 31 2023 20:27:32 GMT-0300 (Brasilia Standard Time)
5
+ * Built: Fri Sep 22 2023 13:13:39 GMT-0300 (Brasilia Standard Time)
6
6
  */
7
7
 
8
- var U = Object.defineProperty;
9
- var z = (s, e, t) => e in s ? U(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
10
- var h = (s, e, t) => (z(s, typeof e != "symbol" ? e + "" : e, t), t);
11
- class B {
12
- /**
13
- * @param {string} type Type.
14
- */
15
- constructor(e) {
16
- this.propagationStopped, this.defaultPrevented, this.type = e, this.target = null;
17
- }
18
- /**
19
- * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
20
- * will be fired.
21
- * @api
22
- */
23
- preventDefault() {
24
- this.defaultPrevented = !0;
25
- }
26
- /**
27
- * Stop event propagation.
28
- * @api
29
- */
30
- stopPropagation() {
31
- this.propagationStopped = !0;
32
- }
33
- }
34
- const w = B, F = {
35
- /**
36
- * Triggered when a property is changed.
37
- * @event module:ol/Object.ObjectEvent#propertychange
38
- * @api
39
- */
40
- PROPERTYCHANGE: "propertychange"
41
- };
42
- class V {
43
- constructor() {
44
- this.disposed = !1;
45
- }
46
- /**
47
- * Clean up.
48
- */
49
- dispose() {
50
- this.disposed || (this.disposed = !0, this.disposeInternal());
51
- }
52
- /**
53
- * Extension point for disposable objects.
54
- * @protected
55
- */
56
- disposeInternal() {
57
- }
58
- }
59
- const j = V;
8
+ var k = Object.defineProperty;
9
+ var I = (n, t, e) => t in n ? k(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
10
+ var a = (n, t, e) => (I(n, typeof t != "symbol" ? t + "" : t, e), e);
11
+ import O from "ol/control/Control";
12
+ import D from "ol/MapBrowserEvent";
13
+ var S = { exports: {} };
60
14
  function x() {
61
15
  }
62
- function I(s) {
63
- for (const e in s)
64
- delete s[e];
65
- }
66
- function Y(s) {
67
- let e;
68
- for (e in s)
69
- return !1;
70
- return !e;
71
- }
72
- class G extends j {
73
- /**
74
- * @param {*} [target] Default event target for dispatched events.
75
- */
76
- constructor(e) {
77
- super(), this.eventTarget_ = e, this.pendingRemovals_ = null, this.dispatching_ = null, this.listeners_ = null;
78
- }
79
- /**
80
- * @param {string} type Type.
81
- * @param {import("../events.js").Listener} listener Listener.
82
- */
83
- addEventListener(e, t) {
84
- if (!e || !t)
85
- return;
86
- const n = this.listeners_ || (this.listeners_ = {}), r = n[e] || (n[e] = []);
87
- r.includes(t) || r.push(t);
88
- }
89
- /**
90
- * Dispatches an event and calls all listeners listening for events
91
- * of this type. The event parameter can either be a string or an
92
- * Object with a `type` property.
93
- *
94
- * @param {import("./Event.js").default|string} event Event object.
95
- * @return {boolean|undefined} `false` if anyone called preventDefault on the
96
- * event object or if any of the listeners returned false.
97
- * @api
98
- */
99
- dispatchEvent(e) {
100
- const t = typeof e == "string", n = t ? e : e.type, r = this.listeners_ && this.listeners_[n];
101
- if (!r)
102
- return;
103
- const i = t ? new w(e) : (
104
- /** @type {Event} */
105
- e
106
- );
107
- i.target || (i.target = this.eventTarget_ || this);
108
- const o = this.dispatching_ || (this.dispatching_ = {}), l = this.pendingRemovals_ || (this.pendingRemovals_ = {});
109
- n in o || (o[n] = 0, l[n] = 0), ++o[n];
110
- let u;
111
- for (let c = 0, E = r.length; c < E; ++c)
112
- if ("handleEvent" in r[c] ? u = /** @type {import("../events.js").ListenerObject} */
113
- r[c].handleEvent(i) : u = /** @type {import("../events.js").ListenerFunction} */
114
- r[c].call(this, i), u === !1 || i.propagationStopped) {
115
- u = !1;
116
- break;
117
- }
118
- if (--o[n] === 0) {
119
- let c = l[n];
120
- for (delete l[n]; c--; )
121
- this.removeEventListener(n, x);
122
- delete o[n];
123
- }
124
- return u;
125
- }
126
- /**
127
- * Clean up.
128
- */
129
- disposeInternal() {
130
- this.listeners_ && I(this.listeners_);
131
- }
132
- /**
133
- * Get the listeners for a specified event type. Listeners are returned in the
134
- * order that they will be called in.
135
- *
136
- * @param {string} type Type.
137
- * @return {Array<import("../events.js").Listener>|undefined} Listeners.
138
- */
139
- getListeners(e) {
140
- return this.listeners_ && this.listeners_[e] || void 0;
141
- }
142
- /**
143
- * @param {string} [type] Type. If not provided,
144
- * `true` will be returned if this event target has any listeners.
145
- * @return {boolean} Has listeners.
146
- */
147
- hasListener(e) {
148
- return this.listeners_ ? e ? e in this.listeners_ : Object.keys(this.listeners_).length > 0 : !1;
149
- }
150
- /**
151
- * @param {string} type Type.
152
- * @param {import("../events.js").Listener} listener Listener.
153
- */
154
- removeEventListener(e, t) {
155
- const n = this.listeners_ && this.listeners_[e];
156
- if (n) {
157
- const r = n.indexOf(t);
158
- r !== -1 && (this.pendingRemovals_ && e in this.pendingRemovals_ ? (n[r] = x, ++this.pendingRemovals_[e]) : (n.splice(r, 1), n.length === 0 && delete this.listeners_[e]));
159
- }
160
- }
161
- }
162
- const Z = G, W = {
163
- /**
164
- * Generic change event. Triggered when the revision counter is increased.
165
- * @event module:ol/events/Event~BaseEvent#change
166
- * @api
167
- */
168
- CHANGE: "change",
169
- /**
170
- * Generic error event. Triggered when an error occurs.
171
- * @event module:ol/events/Event~BaseEvent#error
172
- * @api
173
- */
174
- ERROR: "error",
175
- BLUR: "blur",
176
- CLEAR: "clear",
177
- CONTEXTMENU: "contextmenu",
178
- CLICK: "click",
179
- DBLCLICK: "dblclick",
180
- DRAGENTER: "dragenter",
181
- DRAGOVER: "dragover",
182
- DROP: "drop",
183
- FOCUS: "focus",
184
- KEYDOWN: "keydown",
185
- KEYPRESS: "keypress",
186
- LOAD: "load",
187
- RESIZE: "resize",
188
- TOUCHMOVE: "touchmove",
189
- WHEEL: "wheel"
190
- };
191
- function g(s, e, t, n, r) {
192
- if (n && n !== s && (t = t.bind(n)), r) {
193
- const o = t;
194
- t = function() {
195
- s.removeEventListener(e, t), o.apply(this, arguments);
196
- };
197
- }
198
- const i = {
199
- target: s,
200
- type: e,
201
- listener: t
202
- };
203
- return s.addEventListener(e, t), i;
204
- }
205
- function S(s, e, t, n) {
206
- return g(s, e, t, n, !0);
207
- }
208
- function M(s) {
209
- s && s.target && (s.target.removeEventListener(s.type, s.listener), I(s));
210
- }
211
- class y extends Z {
212
- constructor() {
213
- super(), this.on = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
214
- this.onInternal, this.once = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
215
- this.onceInternal, this.un = /** @type {ObservableOnSignature<void>} */
216
- this.unInternal, this.revision_ = 0;
217
- }
218
- /**
219
- * Increases the revision counter and dispatches a 'change' event.
220
- * @api
221
- */
222
- changed() {
223
- ++this.revision_, this.dispatchEvent(W.CHANGE);
224
- }
225
- /**
226
- * Get the version number for this object. Each time the object is modified,
227
- * its version number will be incremented.
228
- * @return {number} Revision.
229
- * @api
230
- */
231
- getRevision() {
232
- return this.revision_;
233
- }
234
- /**
235
- * @param {string|Array<string>} type Type.
236
- * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
237
- * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
238
- * @protected
239
- */
240
- onInternal(e, t) {
241
- if (Array.isArray(e)) {
242
- const n = e.length, r = new Array(n);
243
- for (let i = 0; i < n; ++i)
244
- r[i] = g(this, e[i], t);
245
- return r;
246
- }
247
- return g(
248
- this,
249
- /** @type {string} */
250
- e,
251
- t
252
- );
253
- }
254
- /**
255
- * @param {string|Array<string>} type Type.
256
- * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
257
- * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
258
- * @protected
259
- */
260
- onceInternal(e, t) {
261
- let n;
262
- if (Array.isArray(e)) {
263
- const r = e.length;
264
- n = new Array(r);
265
- for (let i = 0; i < r; ++i)
266
- n[i] = S(this, e[i], t);
267
- } else
268
- n = S(
269
- this,
270
- /** @type {string} */
271
- e,
272
- t
273
- );
274
- return t.ol_key = n, n;
275
- }
276
- /**
277
- * Unlisten for a certain type of event.
278
- * @param {string|Array<string>} type Type.
279
- * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
280
- * @protected
281
- */
282
- unInternal(e, t) {
283
- const n = (
284
- /** @type {Object} */
285
- t.ol_key
286
- );
287
- if (n)
288
- X(n);
289
- else if (Array.isArray(e))
290
- for (let r = 0, i = e.length; r < i; ++r)
291
- this.removeEventListener(e[r], t);
292
- else
293
- this.removeEventListener(e, t);
294
- }
295
- }
296
- y.prototype.on;
297
- y.prototype.once;
298
- y.prototype.un;
299
- function X(s) {
300
- if (Array.isArray(s))
301
- for (let e = 0, t = s.length; e < t; ++e)
302
- M(s[e]);
303
- else
304
- M(
305
- /** @type {import("./events.js").EventsKey} */
306
- s
307
- );
308
- }
309
- const q = y;
310
- let J = 0;
311
- function Q(s) {
312
- return s.ol_uid || (s.ol_uid = String(++J));
313
- }
314
- class T extends w {
315
- /**
316
- * @param {string} type The event type.
317
- * @param {string} key The property name.
318
- * @param {*} oldValue The old value for `key`.
319
- */
320
- constructor(e, t, n) {
321
- super(e), this.key = t, this.oldValue = n;
322
- }
323
- }
324
- class ee extends q {
325
- /**
326
- * @param {Object<string, *>} [values] An object with key-value pairs.
327
- */
328
- constructor(e) {
329
- super(), this.on, this.once, this.un, Q(this), this.values_ = null, e !== void 0 && this.setProperties(e);
330
- }
331
- /**
332
- * Gets a value.
333
- * @param {string} key Key name.
334
- * @return {*} Value.
335
- * @api
336
- */
337
- get(e) {
338
- let t;
339
- return this.values_ && this.values_.hasOwnProperty(e) && (t = this.values_[e]), t;
340
- }
341
- /**
342
- * Get a list of object property names.
343
- * @return {Array<string>} List of property names.
344
- * @api
345
- */
346
- getKeys() {
347
- return this.values_ && Object.keys(this.values_) || [];
348
- }
349
- /**
350
- * Get an object of all property names and values.
351
- * @return {Object<string, *>} Object.
352
- * @api
353
- */
354
- getProperties() {
355
- return this.values_ && Object.assign({}, this.values_) || {};
356
- }
357
- /**
358
- * @return {boolean} The object has properties.
359
- */
360
- hasProperties() {
361
- return !!this.values_;
362
- }
363
- /**
364
- * @param {string} key Key name.
365
- * @param {*} oldValue Old value.
366
- */
367
- notify(e, t) {
368
- let n;
369
- n = `change:${e}`, this.hasListener(n) && this.dispatchEvent(new T(n, e, t)), n = F.PROPERTYCHANGE, this.hasListener(n) && this.dispatchEvent(new T(n, e, t));
370
- }
371
- /**
372
- * @param {string} key Key name.
373
- * @param {import("./events.js").Listener} listener Listener.
374
- */
375
- addChangeListener(e, t) {
376
- this.addEventListener(`change:${e}`, t);
377
- }
378
- /**
379
- * @param {string} key Key name.
380
- * @param {import("./events.js").Listener} listener Listener.
381
- */
382
- removeChangeListener(e, t) {
383
- this.removeEventListener(`change:${e}`, t);
384
- }
385
- /**
386
- * Sets a value.
387
- * @param {string} key Key name.
388
- * @param {*} value Value.
389
- * @param {boolean} [silent] Update without triggering an event.
390
- * @api
391
- */
392
- set(e, t, n) {
393
- const r = this.values_ || (this.values_ = {});
394
- if (n)
395
- r[e] = t;
396
- else {
397
- const i = r[e];
398
- r[e] = t, i !== t && this.notify(e, i);
399
- }
400
- }
401
- /**
402
- * Sets a collection of key-value pairs. Note that this changes any existing
403
- * properties and adds new ones (it does not remove any existing properties).
404
- * @param {Object<string, *>} values Values.
405
- * @param {boolean} [silent] Update without triggering an event.
406
- * @api
407
- */
408
- setProperties(e, t) {
409
- for (const n in e)
410
- this.set(n, e[n], t);
411
- }
412
- /**
413
- * Apply any properties from another object without triggering events.
414
- * @param {BaseObject} source The source object.
415
- * @protected
416
- */
417
- applyProperties(e) {
418
- e.values_ && Object.assign(this.values_ || (this.values_ = {}), e.values_);
419
- }
420
- /**
421
- * Unsets a property.
422
- * @param {string} key Key name.
423
- * @param {boolean} [silent] Unset without triggering an event.
424
- * @api
425
- */
426
- unset(e, t) {
427
- if (this.values_ && e in this.values_) {
428
- const n = this.values_[e];
429
- delete this.values_[e], Y(this.values_) && (this.values_ = null), t || this.notify(e, n);
430
- }
431
- }
432
- }
433
- const te = ee, ne = {
434
- /**
435
- * Triggered after a map frame is rendered.
436
- * @event module:ol/MapEvent~MapEvent#postrender
437
- * @api
438
- */
439
- POSTRENDER: "postrender",
440
- /**
441
- * Triggered when the map starts moving.
442
- * @event module:ol/MapEvent~MapEvent#movestart
443
- * @api
444
- */
445
- MOVESTART: "movestart",
446
- /**
447
- * Triggered after the map is moved.
448
- * @event module:ol/MapEvent~MapEvent#moveend
449
- * @api
450
- */
451
- MOVEEND: "moveend",
452
- /**
453
- * Triggered when loading of additional map data (tiles, images, features) starts.
454
- * @event module:ol/MapEvent~MapEvent#loadstart
455
- * @api
456
- */
457
- LOADSTART: "loadstart",
458
- /**
459
- * Triggered when loading of additional map data has completed.
460
- * @event module:ol/MapEvent~MapEvent#loadend
461
- * @api
462
- */
463
- LOADEND: "loadend"
464
- };
465
- function D(s) {
466
- return s && s.parentNode ? s.parentNode.removeChild(s) : null;
467
- }
468
- class se extends te {
469
- /**
470
- * @param {Options} options Control options.
471
- */
472
- constructor(e) {
473
- super();
474
- const t = e.element;
475
- t && !e.target && !t.style.pointerEvents && (t.style.pointerEvents = "auto"), this.element = t || null, this.target_ = null, this.map_ = null, this.listenerKeys = [], e.render && (this.render = e.render), e.target && this.setTarget(e.target);
476
- }
477
- /**
478
- * Clean up.
479
- */
480
- disposeInternal() {
481
- D(this.element), super.disposeInternal();
482
- }
483
- /**
484
- * Get the map associated with this control.
485
- * @return {import("../Map.js").default|null} Map.
486
- * @api
487
- */
488
- getMap() {
489
- return this.map_;
490
- }
491
- /**
492
- * Remove the control from its current map and attach it to the new map.
493
- * Pass `null` to just remove the control from the current map.
494
- * Subclasses may set up event handlers to get notified about changes to
495
- * the map here.
496
- * @param {import("../Map.js").default|null} map Map.
497
- * @api
498
- */
499
- setMap(e) {
500
- this.map_ && D(this.element);
501
- for (let t = 0, n = this.listenerKeys.length; t < n; ++t)
502
- M(this.listenerKeys[t]);
503
- this.listenerKeys.length = 0, this.map_ = e, e && ((this.target_ ? this.target_ : e.getOverlayContainerStopEvent()).appendChild(this.element), this.render !== x && this.listenerKeys.push(
504
- g(e, ne.POSTRENDER, this.render, this)
505
- ), e.render());
506
- }
507
- /**
508
- * Renders the control.
509
- * @param {import("../MapEvent.js").default} mapEvent Map event.
510
- * @api
511
- */
512
- render(e) {
513
- }
514
- /**
515
- * This function is used to set a target element for the control. It has no
516
- * effect if it is called after the control has been added to the map (i.e.
517
- * after `setMap` is called on the control). If no `target` is set in the
518
- * options passed to the control constructor and if `setTarget` is not called
519
- * then the control is added to the map's overlay container.
520
- * @param {HTMLElement|string} target Target.
521
- * @api
522
- */
523
- setTarget(e) {
524
- this.target_ = typeof e == "string" ? document.getElementById(e) : e;
525
- }
526
- }
527
- const ie = se;
528
- var C = {}, re = {
529
- get exports() {
530
- return C;
531
- },
532
- set exports(s) {
533
- C = s;
534
- }
535
- };
536
- function A() {
537
- }
538
- A.prototype = {
539
- on: function(s, e, t) {
540
- var n = this.e || (this.e = {});
541
- return (n[s] || (n[s] = [])).push({
542
- fn: e,
543
- ctx: t
16
+ x.prototype = {
17
+ on: function(n, t, e) {
18
+ var s = this.e || (this.e = {});
19
+ return (s[n] || (s[n] = [])).push({
20
+ fn: t,
21
+ ctx: e
544
22
  }), this;
545
23
  },
546
- once: function(s, e, t) {
547
- var n = this;
548
- function r() {
549
- n.off(s, r), e.apply(t, arguments);
24
+ once: function(n, t, e) {
25
+ var s = this;
26
+ function o() {
27
+ s.off(n, o), t.apply(e, arguments);
550
28
  }
551
- return r._ = e, this.on(s, r, t);
29
+ return o._ = t, this.on(n, o, e);
552
30
  },
553
- emit: function(s) {
554
- var e = [].slice.call(arguments, 1), t = ((this.e || (this.e = {}))[s] || []).slice(), n = 0, r = t.length;
555
- for (n; n < r; n++)
556
- t[n].fn.apply(t[n].ctx, e);
31
+ emit: function(n) {
32
+ var t = [].slice.call(arguments, 1), e = ((this.e || (this.e = {}))[n] || []).slice(), s = 0, o = e.length;
33
+ for (s; s < o; s++)
34
+ e[s].fn.apply(e[s].ctx, t);
557
35
  return this;
558
36
  },
559
- off: function(s, e) {
560
- var t = this.e || (this.e = {}), n = t[s], r = [];
561
- if (n && e)
562
- for (var i = 0, o = n.length; i < o; i++)
563
- n[i].fn !== e && n[i].fn._ !== e && r.push(n[i]);
564
- return r.length ? t[s] = r : delete t[s], this;
37
+ off: function(n, t) {
38
+ var e = this.e || (this.e = {}), s = e[n], o = [];
39
+ if (s && t)
40
+ for (var i = 0, l = s.length; i < l; i++)
41
+ s[i].fn !== t && s[i].fn._ !== t && o.push(s[i]);
42
+ return o.length ? e[n] = o : delete e[n], this;
565
43
  }
566
44
  };
567
- re.exports = A;
568
- var oe = C.TinyEmitter = A;
569
- class ae extends w {
570
- /**
571
- * @param {string} type Event type.
572
- * @param {import("./Map.js").default} map Map.
573
- * @param {?import("./Map.js").FrameState} [frameState] Frame state.
574
- */
575
- constructor(e, t, n) {
576
- super(e), this.map = t, this.frameState = n !== void 0 ? n : null;
577
- }
578
- }
579
- const le = ae;
580
- class he extends le {
581
- /**
582
- * @param {string} type Event type.
583
- * @param {import("./Map.js").default} map Map.
584
- * @param {EVENT} originalEvent Original event.
585
- * @param {boolean} [dragging] Is the map currently being dragged?
586
- * @param {import("./Map.js").FrameState} [frameState] Frame state.
587
- * @param {Array<PointerEvent>} [activePointers] Active pointers.
588
- */
589
- constructor(e, t, n, r, i, o) {
590
- super(e, t, i), this.originalEvent = n, this.pixel_ = null, this.coordinate_ = null, this.dragging = r !== void 0 ? r : !1, this.activePointers = o;
591
- }
592
- /**
593
- * The map pixel relative to the viewport corresponding to the original event.
594
- * @type {import("./pixel.js").Pixel}
595
- * @api
596
- */
597
- get pixel() {
598
- return this.pixel_ || (this.pixel_ = this.map.getEventPixel(this.originalEvent)), this.pixel_;
599
- }
600
- set pixel(e) {
601
- this.pixel_ = e;
602
- }
603
- /**
604
- * The coordinate corresponding to the original browser event. This will be in the user
605
- * projection if one is set. Otherwise it will be in the view projection.
606
- * @type {import("./coordinate.js").Coordinate}
607
- * @api
608
- */
609
- get coordinate() {
610
- return this.coordinate_ || (this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel)), this.coordinate_;
611
- }
612
- set coordinate(e) {
613
- this.coordinate_ = e;
614
- }
615
- /**
616
- * Prevents the default browser action.
617
- * See https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault.
618
- * @api
619
- */
620
- preventDefault() {
621
- super.preventDefault(), "preventDefault" in this.originalEvent && this.originalEvent.preventDefault();
622
- }
623
- /**
624
- * Prevents further propagation of the current event.
625
- * See https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation.
626
- * @api
627
- */
628
- stopPropagation() {
629
- super.stopPropagation(), "stopPropagation" in this.originalEvent && this.originalEvent.stopPropagation();
630
- }
631
- }
632
- const ce = he;
633
- var N = /* @__PURE__ */ ((s) => (s.CONTEXTMENU = "contextmenu", s.CLICK = "click", s.DBLCLICK = "dblclick", s))(N || {}), m = /* @__PURE__ */ ((s) => (s.BEFOREOPEN = "beforeopen", s.OPEN = "open", s.CLOSE = "close", s.ADD_MENU_ENTRY = "add-menu-entry", s))(m || {});
634
- class R extends ce {
635
- constructor(e) {
636
- super(e.type, e.map, e.originalEvent);
45
+ S.exports = x;
46
+ var _ = S.exports.TinyEmitter = x, L = /* @__PURE__ */ ((n) => (n.CONTEXTMENU = "contextmenu", n.CLICK = "click", n.DBLCLICK = "dblclick", n))(L || {}), p = /* @__PURE__ */ ((n) => (n.BEFOREOPEN = "beforeopen", n.OPEN = "open", n.CLOSE = "close", n.ADD_MENU_ENTRY = "add-menu-entry", n))(p || {});
47
+ class w extends D {
48
+ constructor(t) {
49
+ super(t.type, t.map, t.originalEvent);
637
50
  }
638
51
  }
639
- const ue = {
52
+ const z = {
640
53
  width: 150,
641
54
  scrollAt: 4,
642
- eventType: N.CONTEXTMENU,
55
+ eventType: L.CONTEXTMENU,
643
56
  defaultItems: !0,
644
57
  items: []
645
- }, f = "ol-ctx-menu", a = {
646
- namespace: f,
647
- container: `${f}-container`,
648
- separator: `${f}-separator`,
649
- submenu: `${f}-submenu`,
650
- hidden: `${f}-hidden`,
651
- icon: `${f}-icon`,
652
- zoomIn: `${f}-zoom-in`,
653
- zoomOut: `${f}-zoom-out`,
58
+ }, d = "ol-ctx-menu", r = {
59
+ namespace: d,
60
+ container: `${d}-container`,
61
+ separator: `${d}-separator`,
62
+ submenu: `${d}-submenu`,
63
+ hidden: `${d}-hidden`,
64
+ icon: `${d}-icon`,
65
+ zoomIn: `${d}-zoom-in`,
66
+ zoomOut: `${d}-zoom-out`,
654
67
  unselectable: "ol-unselectable"
655
- }, P = [
68
+ }, C = [
656
69
  {
657
70
  text: "Zoom In",
658
- classname: `${a.zoomIn} ${a.icon}`,
659
- callback: (s, e) => {
660
- const t = e.getView();
661
- t.animate({
662
- zoom: Number(t.getZoom()) + 1,
71
+ classname: `${r.zoomIn} ${r.icon}`,
72
+ callback: (n, t) => {
73
+ const e = t.getView();
74
+ e.animate({
75
+ zoom: Number(e.getZoom()) + 1,
663
76
  duration: 700,
664
- center: s.coordinate
77
+ center: n.coordinate
665
78
  });
666
79
  }
667
80
  },
668
81
  {
669
82
  text: "Zoom Out",
670
- classname: `${a.zoomOut} ${a.icon}`,
671
- callback: (s, e) => {
672
- const t = e.getView();
673
- t.animate({
674
- zoom: Number(t.getZoom()) - 1,
83
+ classname: `${r.zoomOut} ${r.icon}`,
84
+ callback: (n, t) => {
85
+ const e = t.getView();
86
+ e.animate({
87
+ zoom: Number(e.getZoom()) - 1,
675
88
  duration: 700,
676
- center: s.coordinate
89
+ center: n.coordinate
677
90
  });
678
91
  }
679
92
  }
680
93
  ];
681
- function _(s) {
682
- const e = document.createDocumentFragment(), t = document.createElement("div");
683
- for (t.innerHTML = s; t.firstChild; )
684
- e.append(t.firstChild);
685
- return e;
94
+ function y(n) {
95
+ const t = document.createDocumentFragment(), e = document.createElement("div");
96
+ for (e.innerHTML = n; e.firstChild; )
97
+ t.append(e.firstChild);
98
+ return t;
686
99
  }
687
- function de(s) {
688
- const e = document.importNode(s), t = s.offsetWidth;
689
- e.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${t}px`;
690
- const n = _("<span>Foo</span>"), r = _("<span>Foo</span>"), i = document.createElement("li"), o = document.createElement("li");
691
- i.append(n), o.append(r), e.append(i), e.append(o), s.parentNode?.append(e);
692
- const l = e.offsetHeight / 2;
693
- return s.parentNode?.removeChild(e), l;
100
+ function P(n) {
101
+ const t = document.importNode(n), e = n.offsetWidth;
102
+ t.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;
103
+ const s = y("<span>Foo</span>"), o = y("<span>Foo</span>"), i = document.createElement("li"), l = document.createElement("li");
104
+ i.append(s), l.append(o), t.append(i), t.append(l), n.parentNode?.append(t);
105
+ const c = t.offsetHeight / 2;
106
+ return n.parentNode?.removeChild(t), c;
694
107
  }
695
- function $({
696
- parentNode: s,
697
- item: e,
698
- isSubmenu: t = !1,
699
- isInsideSubmenu: n = !1,
700
- emitter: r
108
+ function N({
109
+ parentNode: n,
110
+ item: t,
111
+ isSubmenu: e = !1,
112
+ isInsideSubmenu: s = !1,
113
+ emitter: o
701
114
  }) {
702
115
  const i = `_${Math.random().toString(36).slice(2, 11)}`;
703
- if (typeof e != "string" && "text" in e) {
704
- const E = `<span>${e.text}</span>`, v = _(E), p = document.createElement("li");
705
- e.classname = e.classname || "", e.icon && (e.classname === "" ? e.classname = a.icon : e.classname.includes(a.icon) === !1 && (e.classname += ` ${a.icon}`), p.setAttribute("style", `background-image:url(${e.icon})`)), p.id = i, p.className = e.classname, p.append(v), s.append(p);
706
- const b = {
116
+ if (typeof t != "string" && "text" in t) {
117
+ const E = `<span>${t.text}</span>`, m = y(E), u = document.createElement("li");
118
+ t.classname = t.classname || "", t.icon && (t.classname === "" ? t.classname = r.icon : t.classname.includes(r.icon) === !1 && (t.classname += ` ${r.icon}`), u.setAttribute("style", `background-image:url(${t.icon})`)), u.id = i, u.className = t.classname, u.append(m), n.append(u);
119
+ const v = {
707
120
  id: i,
708
- isSubmenu: t,
709
- isInsideSubmenu: n,
121
+ isSubmenu: e,
122
+ isInsideSubmenu: s,
710
123
  isSeparator: !1,
711
- callback: "callback" in e ? e.callback : null,
712
- data: "data" in e ? e.data : null
124
+ callback: "callback" in t ? t.callback : null,
125
+ data: "data" in t ? t.data : null
713
126
  };
714
- return r.emit(m.ADD_MENU_ENTRY, b, p), p;
127
+ return o.emit(p.ADD_MENU_ENTRY, v, u), u;
715
128
  }
716
- const o = `<li id="${i}" class="${a.separator}"><hr></li>`, l = _(o);
717
- s.append(l);
718
- const u = s.lastChild, c = {
129
+ const l = `<li id="${i}" class="${r.separator}"><hr></li>`, c = y(l);
130
+ n.append(c);
131
+ const f = n.lastChild, g = {
719
132
  id: i,
720
133
  isSubmenu: !1,
721
134
  isInsideSubmenu: !1,
@@ -723,67 +136,67 @@ function $({
723
136
  callback: null,
724
137
  data: null
725
138
  };
726
- return r.emit(m.ADD_MENU_ENTRY, c, u), u;
139
+ return o.emit(p.ADD_MENU_ENTRY, g, f), f;
727
140
  }
728
- function O({
729
- container: s,
730
- items: e,
731
- menuWidth: t,
732
- isInsideSubmenu: n,
733
- emitter: r
141
+ function M({
142
+ container: n,
143
+ items: t,
144
+ menuWidth: e,
145
+ isInsideSubmenu: s,
146
+ emitter: o
734
147
  }) {
735
- e.forEach((i) => {
148
+ t.forEach((i) => {
736
149
  if (typeof i != "string" && "items" in i && Array.isArray(i.items)) {
737
- const o = $({ parentNode: s, item: i, isSubmenu: !0, emitter: r });
738
- o.classList.add(a.submenu);
739
- const l = document.createElement("ul");
740
- l.classList.add(a.container), l.style.width = `${t}px`, o.append(l), O({
741
- emitter: r,
742
- menuWidth: t,
743
- container: l,
150
+ const l = N({ parentNode: n, item: i, isSubmenu: !0, emitter: o });
151
+ l.classList.add(r.submenu);
152
+ const c = document.createElement("ul");
153
+ c.classList.add(r.container), c.style.width = `${e}px`, l.append(c), M({
154
+ emitter: o,
155
+ menuWidth: e,
156
+ container: c,
744
157
  items: i.items,
745
158
  isInsideSubmenu: !0
746
159
  });
747
160
  } else
748
- $({
749
- parentNode: s,
161
+ N({
162
+ parentNode: n,
750
163
  item: i,
751
164
  isSubmenu: !1,
752
- isInsideSubmenu: n,
753
- emitter: r
165
+ isInsideSubmenu: s,
166
+ emitter: o
754
167
  });
755
168
  });
756
169
  }
757
- function L(s, e) {
758
- if (!s)
759
- throw new Error(e);
170
+ function b(n, t) {
171
+ if (!n)
172
+ throw new Error(t);
760
173
  }
761
- class fe extends ie {
762
- constructor(t = {}) {
763
- L(typeof t == "object", "@param `opts` should be object type!");
764
- const n = document.createElement("div");
765
- super({ element: n });
766
- h(this, "map");
767
- h(this, "emitter", new oe());
768
- h(this, "container");
769
- h(this, "coordinate", []);
770
- h(this, "pixel", []);
771
- h(this, "contextMenuEventListener");
772
- h(this, "entryCallbackEventListener");
773
- h(this, "mapMoveListener");
774
- h(this, "lineHeight", 0);
775
- h(this, "disabled");
776
- h(this, "opened");
777
- h(this, "items", []);
778
- h(this, "menuEntries", /* @__PURE__ */ new Map());
779
- h(this, "options");
780
- this.options = { ...ue, ...t };
781
- const r = document.createElement("ul");
782
- n.append(r), n.style.width = `${this.options.width}px`, n.classList.add(
783
- a.container,
784
- a.unselectable,
785
- a.hidden
786
- ), this.container = n, this.contextMenuEventListener = (i) => {
174
+ class R extends O {
175
+ constructor(e = {}) {
176
+ b(typeof e == "object", "@param `opts` should be object type!");
177
+ const s = document.createElement("div");
178
+ super({ element: s });
179
+ a(this, "map");
180
+ a(this, "emitter", new _());
181
+ a(this, "container");
182
+ a(this, "coordinate", []);
183
+ a(this, "pixel", []);
184
+ a(this, "contextMenuEventListener");
185
+ a(this, "entryCallbackEventListener");
186
+ a(this, "mapMoveListener");
187
+ a(this, "lineHeight", 0);
188
+ a(this, "disabled");
189
+ a(this, "opened");
190
+ a(this, "items", []);
191
+ a(this, "menuEntries", /* @__PURE__ */ new Map());
192
+ a(this, "options");
193
+ this.options = { ...z, ...e };
194
+ const o = document.createElement("ul");
195
+ s.append(o), s.style.width = `${this.options.width}px`, s.classList.add(
196
+ r.container,
197
+ r.unselectable,
198
+ r.hidden
199
+ ), this.container = s, this.contextMenuEventListener = (i) => {
787
200
  this.handleContextMenu(i);
788
201
  }, this.entryCallbackEventListener = (i) => {
789
202
  this.handleEntryCallback(i);
@@ -798,8 +211,8 @@ class fe extends ie {
798
211
  );
799
212
  }
800
213
  clear() {
801
- for (const t of this.menuEntries.keys())
802
- this.removeMenuEntry(t);
214
+ for (const e of this.menuEntries.keys())
215
+ this.removeMenuEntry(e);
803
216
  this.container.replaceChildren(), this.container.append(document.createElement("ul"));
804
217
  }
805
218
  enable() {
@@ -809,147 +222,147 @@ class fe extends ie {
809
222
  this.disabled = !0;
810
223
  }
811
224
  getDefaultItems() {
812
- return P;
225
+ return C;
813
226
  }
814
227
  countItems() {
815
228
  return this.menuEntries.size;
816
229
  }
817
- extend(t) {
818
- L(Array.isArray(t), "@param `items` should be an Array."), O({
819
- items: t,
230
+ extend(e) {
231
+ b(Array.isArray(e), "@param `items` should be an Array."), M({
232
+ items: e,
820
233
  emitter: this.emitter,
821
234
  menuWidth: this.options.width,
822
235
  container: this.container.firstElementChild
823
236
  });
824
237
  }
825
238
  closeMenu() {
826
- this.opened = !1, this.container.classList.add(a.hidden), this.dispatchEvent(m.CLOSE);
239
+ this.opened = !1, this.container.classList.add(r.hidden), this.dispatchEvent(p.CLOSE);
827
240
  }
828
241
  isOpen() {
829
242
  return this.opened;
830
243
  }
831
- updatePosition(t) {
832
- L(Array.isArray(t), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = t, this.positionContainer());
244
+ updatePosition(e) {
245
+ b(Array.isArray(e), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = e, this.positionContainer());
833
246
  }
834
247
  pop() {
835
- const t = Array.from(this.menuEntries.keys()).pop();
836
- t && this.removeMenuEntry(t);
248
+ const e = Array.from(this.menuEntries.keys()).pop();
249
+ e && this.removeMenuEntry(e);
837
250
  }
838
251
  shift() {
839
- const t = Array.from(this.menuEntries.keys()).shift();
840
- t && this.removeMenuEntry(t);
252
+ const e = Array.from(this.menuEntries.keys()).shift();
253
+ e && this.removeMenuEntry(e);
841
254
  }
842
- push(t) {
843
- t && this.extend([t]);
255
+ push(e) {
256
+ e && this.extend([e]);
844
257
  }
845
- setMap(t) {
846
- if (super.setMap(t), t) {
847
- this.map = t, t.getViewport().addEventListener(
258
+ setMap(e) {
259
+ if (super.setMap(e), e) {
260
+ this.map = e, e.getViewport().addEventListener(
848
261
  this.options.eventType,
849
262
  this.contextMenuEventListener,
850
263
  !1
851
- ), t.on("movestart", () => {
264
+ ), e.on("movestart", () => {
852
265
  this.handleMapMove();
853
266
  }), this.emitter.on(
854
- m.ADD_MENU_ENTRY,
855
- (r, i) => {
856
- this.handleAddMenuEntry(r, i);
267
+ p.ADD_MENU_ENTRY,
268
+ (o, i) => {
269
+ this.handleAddMenuEntry(o, i);
857
270
  },
858
271
  this
859
- ), this.items = this.options.defaultItems ? this.options.items.concat(P) : this.options.items, O({
272
+ ), this.items = this.options.defaultItems ? this.options.items.concat(C) : this.options.items, M({
860
273
  items: this.items,
861
274
  emitter: this.emitter,
862
275
  menuWidth: this.options.width,
863
276
  container: this.container.firstElementChild
864
277
  });
865
- const n = this.getMenuEntriesLength();
866
- this.lineHeight = n > 0 ? this.container.offsetHeight / n : de(this.container);
278
+ const s = this.getMenuEntriesLength();
279
+ this.lineHeight = s > 0 ? this.container.offsetHeight / s : P(this.container);
867
280
  } else
868
281
  this.removeListeners(), this.clear();
869
282
  }
870
283
  removeListeners() {
871
- this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.emitter.off(m.ADD_MENU_ENTRY);
284
+ this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.emitter.off(p.ADD_MENU_ENTRY);
872
285
  }
873
- removeMenuEntry(t) {
874
- let n = document.getElementById(t);
875
- n?.remove(), n = null, this.menuEntries.delete(t);
286
+ removeMenuEntry(e) {
287
+ let s = document.getElementById(e);
288
+ s?.remove(), s = null, this.menuEntries.delete(e);
876
289
  }
877
- handleContextMenu(t) {
878
- this.coordinate = this.map.getEventCoordinate(t), this.pixel = this.map.getEventPixel(t), this.dispatchEvent(
879
- new R({
290
+ handleContextMenu(e) {
291
+ this.coordinate = this.map.getEventCoordinate(e), this.pixel = this.map.getEventPixel(e), this.dispatchEvent(
292
+ new w({
880
293
  map: this.map,
881
- originalEvent: t,
882
- type: m.BEFOREOPEN
294
+ originalEvent: e,
295
+ type: p.BEFOREOPEN
883
296
  })
884
- ), !this.disabled && (this.options.eventType === N.CONTEXTMENU && (t.stopPropagation(), t.preventDefault()), setTimeout(() => {
885
- this.openMenu(t);
886
- }), t.target?.addEventListener(
297
+ ), !this.disabled && (this.options.eventType === L.CONTEXTMENU && (e.stopPropagation(), e.preventDefault()), setTimeout(() => {
298
+ this.openMenu(e);
299
+ }), e.target?.addEventListener(
887
300
  "pointerdown",
888
- (n) => {
889
- this.opened && (n.stopPropagation(), this.closeMenu());
301
+ (s) => {
302
+ this.opened && (s.stopPropagation(), this.closeMenu());
890
303
  },
891
304
  { once: !0 }
892
305
  ));
893
306
  }
894
- openMenu(t) {
895
- this.opened = !0, this.positionContainer(), this.container.classList.remove(a.hidden), this.dispatchEvent(
896
- new R({
307
+ openMenu(e) {
308
+ this.opened = !0, this.positionContainer(), this.container.classList.remove(r.hidden), this.dispatchEvent(
309
+ new w({
897
310
  map: this.map,
898
- originalEvent: t,
899
- type: m.OPEN
311
+ originalEvent: e,
312
+ type: p.OPEN
900
313
  })
901
314
  );
902
315
  }
903
316
  getMenuEntriesLength() {
904
317
  return Array.from(this.menuEntries).filter(
905
- ([, t]) => t.isSeparator === !1 && t.isSubmenu === !1 && t.isInsideSubmenu === !1
318
+ ([, e]) => e.isSeparator === !1 && e.isSubmenu === !1 && e.isInsideSubmenu === !1
906
319
  ).length;
907
320
  }
908
321
  positionContainer() {
909
- const t = this.map.getSize() || [0, 0], n = {
910
- w: t[0] - this.pixel[0],
911
- h: t[1] - this.pixel[1]
912
- }, r = this.getMenuEntriesLength(), i = {
322
+ const e = this.map.getSize() || [0, 0], s = {
323
+ w: e[0] - this.pixel[0],
324
+ h: e[1] - this.pixel[1]
325
+ }, o = this.getMenuEntriesLength(), i = {
913
326
  w: this.container.offsetWidth,
914
327
  // a cheap way to recalculate container height
915
328
  // since offsetHeight is like cached
916
- h: Math.round(this.lineHeight * r)
917
- }, o = n.w >= i.w ? this.pixel[0] + 5 : this.pixel[0] - i.w;
918
- this.container.style.left = `${o}px`, this.container.style.top = n.h >= i.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - i.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", n.w -= i.w;
919
- const l = (E) => Array.from(E.children).filter(
920
- (v) => v.tagName === "LI" && v.classList.contains(a.submenu)
329
+ h: Math.round(this.lineHeight * o)
330
+ }, l = s.w >= i.w ? this.pixel[0] + 5 : this.pixel[0] - i.w;
331
+ this.container.style.left = `${l}px`, this.container.style.top = s.h >= i.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - i.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", s.w -= i.w;
332
+ const c = (E) => Array.from(E.children).filter(
333
+ (m) => m.tagName === "LI" && m.classList.contains(r.submenu)
921
334
  );
922
- let u = 0;
923
- const c = (E, v) => {
924
- u += 1, l(E).forEach((b) => {
925
- const H = v >= i.w ? i.w - 8 : (i.w + 8) * -1, d = b.querySelector(
926
- `ul.${a.container}`
927
- ), k = Math.round(
928
- this.lineHeight * Array.from(d.children).filter((K) => K.tagName === "LI").length
335
+ let f = 0;
336
+ const g = (E, m) => {
337
+ f += 1, c(E).forEach((v) => {
338
+ const A = m >= i.w ? i.w - 8 : (i.w + 8) * -1, h = v.querySelector(
339
+ `ul.${r.container}`
340
+ ), $ = Math.round(
341
+ this.lineHeight * Array.from(h.children).filter((T) => T.tagName === "LI").length
929
342
  );
930
- d.style.left = `${H}px`, d.style.right = "auto", d.style.top = n.h >= k + i.h ? "0" : `-${d.offsetHeight - 25}px`, d.style.bottom = "auto", d.style.zIndex = String(u), l(d).length > 0 && c(d, v - i.w);
343
+ h.style.left = `${A}px`, h.style.right = "auto", h.style.top = s.h >= $ + i.h ? "0" : `-${h.offsetHeight - 25}px`, h.style.bottom = "auto", h.style.zIndex = String(f), c(h).length > 0 && g(h, m - i.w);
931
344
  });
932
345
  };
933
- c(this.container.firstElementChild, n.w);
346
+ g(this.container.firstElementChild, s.w);
934
347
  }
935
348
  handleMapMove() {
936
349
  this.closeMenu();
937
350
  }
938
- handleEntryCallback(t) {
939
- t.preventDefault(), t.stopPropagation();
940
- const n = t.currentTarget, r = this.menuEntries.get(n.id);
941
- if (!r)
351
+ handleEntryCallback(e) {
352
+ e.preventDefault(), e.stopPropagation();
353
+ const s = e.currentTarget, o = this.menuEntries.get(s.id);
354
+ if (!o)
942
355
  return;
943
356
  const i = {
944
- data: r.data,
357
+ data: o.data,
945
358
  coordinate: this.coordinate
946
359
  };
947
- this.closeMenu(), r.callback?.(i, this.map);
360
+ this.closeMenu(), o.callback?.(i, this.map);
948
361
  }
949
- handleAddMenuEntry(t, n) {
950
- this.menuEntries.set(t.id, t), this.positionContainer(), "callback" in t && typeof t.callback == "function" && n.addEventListener("click", this.entryCallbackEventListener, !1);
362
+ handleAddMenuEntry(e, s) {
363
+ this.menuEntries.set(e.id, e), this.positionContainer(), "callback" in e && typeof e.callback == "function" && s.addEventListener("click", this.entryCallbackEventListener, !1);
951
364
  }
952
365
  }
953
366
  export {
954
- fe as default
367
+ R as default
955
368
  };