qmap-forms 0.0.0-stage → 1.0.1

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.
@@ -0,0 +1,823 @@
1
+ import { At as e, Ct as t, J as n, M as r, N as i, P as a, St as o, Y as s, _t as c, d as l, ht as u, k as d, l as f, n as p, pt as m, t as h, u as g, ut as _, wt as v, xt as y } from "./QPopupProxy-DMCFxQQk.mjs";
2
+ import { computed as b, createBlock as x, createCommentVNode as S, createElementBlock as C, createElementVNode as w, createTextVNode as T, createVNode as E, defineComponent as D, getCurrentInstance as O, h as k, normalizeClass as A, normalizeStyle as j, onMounted as M, onUnmounted as N, openBlock as P, ref as F, toDisplayString as ee, unref as te, watch as I, withCtx as R, withDirectives as z, withModifiers as B } from "vue";
3
+ import "leaflet-editable";
4
+ import { Browser as V, Canvas as H, Circle as U, Control as W, DomEvent as G, DomUtil as K, FeatureGroup as ne, Handler as q, LatLngBounds as re, Map as ie, Path as J, Rectangle as ae, SVG as Y, TileLayer as oe, Util as X, featureGroup as se, geoJSON as Z, point as ce } from "leaflet";
5
+ //#region node_modules/quasar/src/components/circular-progress/circular-progress.js
6
+ var Q = {
7
+ ...o,
8
+ min: {
9
+ type: Number,
10
+ default: 0
11
+ },
12
+ max: {
13
+ type: Number,
14
+ default: 100
15
+ },
16
+ color: String,
17
+ centerColor: String,
18
+ trackColor: String,
19
+ fontSize: String,
20
+ rounded: Boolean,
21
+ thickness: {
22
+ type: Number,
23
+ default: .2,
24
+ validator: (e) => e >= 0 && e <= 1
25
+ },
26
+ angle: {
27
+ type: Number,
28
+ default: 0
29
+ },
30
+ showValue: Boolean,
31
+ reverse: Boolean,
32
+ instantFeedback: Boolean
33
+ }, $ = 50, le = 100, ue = le * Math.PI, de = Math.round(ue * 1e3) / 1e3, fe = /*#__PURE__*/ v({
34
+ name: "QCircularProgress",
35
+ props: {
36
+ ...Q,
37
+ value: {
38
+ type: Number,
39
+ default: 0
40
+ },
41
+ animationSpeed: {
42
+ type: [String, Number],
43
+ default: 600
44
+ },
45
+ indeterminate: Boolean
46
+ },
47
+ setup(t, { slots: n }) {
48
+ let r = e(), i = b(() => {
49
+ if (t.indeterminate) return null;
50
+ let e = (r.lang.rtl ? -1 : 1) * t.angle;
51
+ return { transform: t.reverse === (r.lang.rtl === !0) ? `rotate(${e - 90}deg)` : `scaleX(-1) rotate(${-90 - e}deg)` };
52
+ }), a = b(() => !t.instantFeedback && !t.indeterminate ? { transition: `stroke-dashoffset ${t.animationSpeed}ms ease 0s, stroke ${t.animationSpeed}ms ease` } : ""), o = b(() => le / (1 - t.thickness / 2)), s = b(() => `${o.value / 2} ${o.value / 2} ${o.value} ${o.value}`), l = b(() => g(t.value, t.min, t.max)), u = b(() => t.max - t.min), d = b(() => t.thickness / 2 * o.value), f = b(() => {
53
+ let e = (t.max - l.value) / u.value, n = t.rounded && l.value < t.max && e < .25 ? d.value / 2 * (1 - e / .25) : 0;
54
+ return ue * e + n;
55
+ });
56
+ function p({ thickness: e, offset: t, color: n, cls: r, rounded: i }) {
57
+ return k("circle", {
58
+ class: "q-circular-progress__" + r + (n === void 0 ? "" : ` text-${n}`),
59
+ style: a.value,
60
+ fill: "transparent",
61
+ stroke: "currentColor",
62
+ "stroke-width": e,
63
+ "stroke-dasharray": de,
64
+ "stroke-dashoffset": t,
65
+ "stroke-linecap": i,
66
+ cx: o.value,
67
+ cy: o.value,
68
+ r: $
69
+ });
70
+ }
71
+ return () => {
72
+ let e = [];
73
+ t.centerColor !== void 0 && t.centerColor !== "transparent" && e.push(k("circle", {
74
+ class: `q-circular-progress__center text-${t.centerColor}`,
75
+ fill: "currentColor",
76
+ r: $ - d.value / 2,
77
+ cx: o.value,
78
+ cy: o.value
79
+ })), t.trackColor !== void 0 && t.trackColor !== "transparent" && e.push(p({
80
+ cls: "track",
81
+ thickness: d.value,
82
+ offset: 0,
83
+ color: t.trackColor
84
+ })), e.push(p({
85
+ cls: "circle",
86
+ thickness: d.value,
87
+ offset: f.value,
88
+ color: t.color,
89
+ rounded: t.rounded ? "round" : void 0
90
+ }));
91
+ let r = [k("svg", {
92
+ class: "q-circular-progress__svg",
93
+ style: i.value,
94
+ viewBox: s.value,
95
+ "aria-hidden": "true"
96
+ }, e)];
97
+ return t.showValue && r.push(k("div", {
98
+ class: "q-circular-progress__text absolute-full row flex-center content-center",
99
+ style: { fontSize: t.fontSize }
100
+ }, n.default === void 0 ? [k("div", l.value)] : n.default())), k("div", {
101
+ class: `q-circular-progress q-circular-progress--${t.indeterminate ? "in" : ""}determinate`,
102
+ style: y(t.size),
103
+ role: "progressbar",
104
+ "aria-valuemin": t.min,
105
+ "aria-valuemax": t.max,
106
+ "aria-valuenow": t.indeterminate ? void 0 : l.value
107
+ }, c(n.internal, r));
108
+ };
109
+ }
110
+ }), pe = [
111
+ 34,
112
+ 37,
113
+ 40,
114
+ 33,
115
+ 39,
116
+ 38
117
+ ], me = Object.keys(Q), he = /*#__PURE__*/ v({
118
+ name: "QKnob",
119
+ props: {
120
+ ...r,
121
+ ...Q,
122
+ modelValue: {
123
+ type: Number,
124
+ required: !0
125
+ },
126
+ innerMin: Number,
127
+ innerMax: Number,
128
+ step: {
129
+ type: Number,
130
+ default: 1,
131
+ validator: (e) => e >= 0
132
+ },
133
+ tabindex: {
134
+ type: [Number, String],
135
+ default: 0
136
+ },
137
+ disable: Boolean,
138
+ readonly: Boolean
139
+ },
140
+ emits: [
141
+ "update:modelValue",
142
+ "change",
143
+ "dragValue"
144
+ ],
145
+ setup(t, { slots: n, emit: r }) {
146
+ let { proxy: i } = O(), a = e(), o = F(t.modelValue), s = F(!1), c = b(() => !Number.isFinite(t.innerMin) || t.innerMin < t.min ? t.min : t.innerMin), u = b(() => !Number.isFinite(t.innerMax) || t.innerMax > t.max ? t.max : t.innerMax), p, h = null, v = null;
147
+ function y() {
148
+ v === null && (v = o.value);
149
+ }
150
+ function x() {
151
+ h = null, o.value = t.modelValue === null ? c.value : g(t.modelValue, c.value, u.value), H(!1);
152
+ }
153
+ I(() => `${t.modelValue}|${c.value}|${u.value}`, x), x();
154
+ let S = b(() => !t.disable && !t.readonly), C = b(() => "q-knob non-selectable" + (S.value ? " q-knob--editable" : t.disable ? " disabled" : "")), w = b(() => (String(t.step).trim().split(".")[1] || "").length), T = b(() => t.step === 0 ? 1 : t.step), E = b(() => t.instantFeedback || s.value), D = b(() => S.value ? {
155
+ onMousedown: ee,
156
+ onClick: te,
157
+ onKeydown: R,
158
+ onKeyup: V
159
+ } : {}), A = b(() => S.value ? { tabindex: t.tabindex } : { [`aria-${t.disable ? "disabled" : "readonly"}`]: "true" }), j = b(() => {
160
+ let e = {};
161
+ return me.forEach((n) => {
162
+ e[n] = t[n];
163
+ }), e;
164
+ });
165
+ function M(e) {
166
+ if (e.isFinal) {
167
+ B(e.evt, !0), s.value = !1;
168
+ return;
169
+ }
170
+ e.isFirst && (y(), P(), s.value = !0), B(e.evt, !1);
171
+ }
172
+ let N = b(() => [[
173
+ f,
174
+ S.value ? M : void 0,
175
+ void 0,
176
+ {
177
+ prevent: !0,
178
+ stop: !0,
179
+ mouse: !0
180
+ }
181
+ ]]);
182
+ function P() {
183
+ let { top: e, left: t, width: n, height: r } = i.$el.getBoundingClientRect();
184
+ p = {
185
+ top: e + r / 2,
186
+ left: t + n / 2
187
+ };
188
+ }
189
+ function ee(e) {
190
+ y(), P(), B(e, !1);
191
+ }
192
+ function te(e) {
193
+ y(), P(), B(e, !0);
194
+ }
195
+ function R(e) {
196
+ if (!pe.includes(e.keyCode)) return;
197
+ m(e), y();
198
+ let t = ([34, 33].includes(e.keyCode) ? 10 : 1) * T.value, n = [
199
+ 34,
200
+ 37,
201
+ 40
202
+ ].includes(e.keyCode) ? -t : t;
203
+ o.value = g(Number.parseFloat((o.value + n).toFixed(w.value)), c.value, u.value), H(!1);
204
+ }
205
+ function B(e, n) {
206
+ let i = _(e), s = Math.abs(i.top - p.top), d = Math.hypot(s, i.left - p.left), f = Math.asin(s / d) * (180 / Math.PI);
207
+ f = i.top < p.top ? p.left < i.left ? 90 - f : 270 + f : p.left < i.left ? f + 90 : 270 - f, a.lang.rtl ? f = l(-f - t.angle, 0, 360) : t.angle && (f = l(f - t.angle, 0, 360)), t.reverse && (f = 360 - f);
208
+ let m = t.min + f / 360 * (t.max - t.min);
209
+ if (T.value !== 0) {
210
+ let e = m % T.value;
211
+ m = m - e + (Math.abs(e) >= T.value / 2 ? (e < 0 ? -1 : 1) * T.value : 0), m = Number.parseFloat(m.toFixed(w.value));
212
+ }
213
+ m = g(m, c.value, u.value), r("dragValue", m), o.value !== m && (o.value = m), H(n);
214
+ }
215
+ function V(e) {
216
+ pe.includes(e.keyCode) && H(!0);
217
+ }
218
+ function H(e) {
219
+ t.modelValue !== o.value && o.value !== h && (h = o.value, r("update:modelValue", o.value)), e && (v !== null && v !== o.value && r("change", o.value), v = null);
220
+ }
221
+ let U = d(t);
222
+ function W() {
223
+ return k("input", U());
224
+ }
225
+ return () => {
226
+ let e = {
227
+ class: C.value,
228
+ role: "slider",
229
+ "aria-valuemin": c.value,
230
+ "aria-valuemax": u.value,
231
+ "aria-valuenow": t.modelValue,
232
+ ...A.value,
233
+ ...j.value,
234
+ value: o.value,
235
+ instantFeedback: E.value,
236
+ ...D.value
237
+ }, r = { default: n.default };
238
+ return S.value && t.name !== void 0 && (r.internal = W), z(k(fe, e, r), N.value);
239
+ };
240
+ }
241
+ });
242
+ Y.include({
243
+ _resetTransformPath: function(e) {
244
+ e._path.setAttributeNS(null, "transform", "");
245
+ },
246
+ transformPath: function(e, t) {
247
+ e._path.setAttributeNS(null, "transform", "matrix(" + t.join(" ") + ")");
248
+ }
249
+ }), Y.include(V.vml ? {
250
+ _resetTransformPath: function(e) {
251
+ e._skew &&= (e._skew.on = !1, e._path.removeChild(e._skew), null);
252
+ },
253
+ transformPath: function(e, t) {
254
+ let n = e._skew;
255
+ n || (n = Y.create("skew"), e._path.appendChild(n), n.style.behavior = "url(#default#VML)", e._skew = n);
256
+ let r = t[0].toFixed(8) + " " + t[1].toFixed(8) + " " + t[2].toFixed(8) + " " + t[3].toFixed(8) + " 0 0", i = Math.floor(t[4]).toFixed() + ", " + Math.floor(t[5]).toFixed(), a = this._path.style, o = parseFloat(a.left), s = parseFloat(a.top), c = parseFloat(a.width), l = parseFloat(a.height);
257
+ isNaN(o) && (o = 0), isNaN(s) && (s = 0), (isNaN(c) || !c) && (c = 1), (isNaN(l) || !l) && (l = 1);
258
+ let u = (-o / c - .5).toFixed(8) + " " + (-s / l - .5).toFixed(8);
259
+ n.on = "f", n.matrix = r, n.origin = u, n.offset = i, n.on = !0;
260
+ }
261
+ } : {});
262
+ function ge() {
263
+ return !0;
264
+ }
265
+ H.include({
266
+ _resetTransformPath: function(e) {
267
+ this._containerCopy && (delete this._containerCopy, e._containsPoint_ && (e._containsPoint = e._containsPoint_, delete e._containsPoint_, this._requestRedraw(e)));
268
+ },
269
+ transformPath: function(e, t) {
270
+ let n = this._containerCopy, r = this._ctx, i, a = V.retina ? 2 : 1, o = this._bounds, s = o.getSize(), c = o.min;
271
+ n || (n = this._containerCopy = document.createElement("canvas"), i = n.getContext("2d"), n.width = a * s.x, n.height = a * s.y, this._removePath(e), this._redraw(), i.translate(a * o.min.x, a * o.min.y), i.drawImage(this._container, 0, 0), this._initPath(e), e._containsPoint_ = e._containsPoint, e._containsPoint = ge), r.save(), r.clearRect(c.x, c.y, s.x * a, s.y * a), r.setTransform(1, 0, 0, 1, 0, 0), r.restore(), r.save(), r.drawImage(this._containerCopy, 0, 0, s.x, s.y), r.transform.apply(r, t), this._drawing = !0, e._updatePath(), this._drawing = !1, r.restore();
272
+ }
273
+ }), J.include({
274
+ _transform: function(e) {
275
+ return this._renderer && (e ? this._renderer.transformPath(this, e) : (this._renderer._resetTransformPath(this), this._update())), this;
276
+ },
277
+ _onMouseClick: function(e) {
278
+ this.dragging && this.dragging.moved() || this._map.dragging && this._map.dragging.moved() || this._fireMouseEvent(e);
279
+ }
280
+ });
281
+ var _e = {
282
+ mousedown: "mouseup",
283
+ touchstart: "touchend",
284
+ pointerdown: "touchend",
285
+ MSPointerDown: "touchend"
286
+ }, ve = {
287
+ mousedown: "mousemove",
288
+ touchstart: "touchmove",
289
+ pointerdown: "touchmove",
290
+ MSPointerDown: "touchmove"
291
+ };
292
+ function ye(e, t) {
293
+ let n = e.x - t.x, r = e.y - t.y;
294
+ return Math.sqrt(n * n + r * r);
295
+ }
296
+ q.PathDrag = q.extend({
297
+ statics: { DRAGGING_CLS: "leaflet-path-draggable" },
298
+ initialize: function(e) {
299
+ this._path = e, this._matrix = null, this._startPoint = null, this._dragStartPoint = null, this._mapDraggingWasEnabled = !1, this._path._dragMoved = !1;
300
+ },
301
+ addHooks: function() {
302
+ this._path.on("mousedown", this._onDragStart, this), this._path.options.className = this._path.options.className ? this._path.options.className + " " + q.PathDrag.DRAGGING_CLS : q.PathDrag.DRAGGING_CLS, this._path._path && K.addClass(this._path._path, q.PathDrag.DRAGGING_CLS);
303
+ },
304
+ removeHooks: function() {
305
+ this._path.off("mousedown", this._onDragStart, this), this._path.options.className = this._path.options.className.replace(RegExp("\\s+" + q.PathDrag.DRAGGING_CLS), ""), this._path._path && K.removeClass(this._path._path, q.PathDrag.DRAGGING_CLS);
306
+ },
307
+ moved: function() {
308
+ return this._path._dragMoved;
309
+ },
310
+ _onDragStart: function(e) {
311
+ let t = e.originalEvent._simulated ? "touchstart" : e.originalEvent.type;
312
+ this._mapDraggingWasEnabled = !1, this._startPoint = e.containerPoint.clone(), this._dragStartPoint = e.containerPoint.clone(), this._matrix = [
313
+ 1,
314
+ 0,
315
+ 0,
316
+ 1,
317
+ 0,
318
+ 0
319
+ ], G.stop(e.originalEvent), K.addClass(this._path._renderer._container, "leaflet-interactive"), G.on(document, ve[t], this._onDrag, this).on(document, _e[t], this._onDragEnd, this), this._path._map.dragging.enabled() && (this._path._map.dragging.disable(), this._mapDraggingWasEnabled = !0), this._path._dragMoved = !1, this._path._popup && this._path._popup.close(), this._replaceCoordGetters(e);
320
+ },
321
+ _onDrag: function(e) {
322
+ G.stop(e);
323
+ let t = e.touches && e.touches.length >= 1 ? e.touches[0] : e, n = this._path._map.mouseEventToContainerPoint(t);
324
+ if (e.type === "touchmove" && !this._path._dragMoved && this._dragStartPoint.distanceTo(n) <= this._path._map.options.tapTolerance) return;
325
+ let r = n.x, i = n.y, a = r - this._startPoint.x, o = i - this._startPoint.y;
326
+ (a || o) && (this._path._dragMoved || (this._path._dragMoved = !0, this._path.options.interactive = !1, this._path._map.dragging._draggable._moved = !0, this._path.fire("dragstart", e), this._path.bringToFront()), this._matrix[4] += a, this._matrix[5] += o, this._startPoint.x = r, this._startPoint.y = i, this._path.fire("predrag", e), this._path._transform(this._matrix), this._path.fire("drag", e));
327
+ },
328
+ _onDragEnd: function(e) {
329
+ let t = this._path._map.mouseEventToContainerPoint(e), n = this.moved();
330
+ if (n && (this._transformPoints(this._matrix), this._path._updatePath(), this._path._project(), this._path._transform(null), G.stop(e)), G.off(document, "mousemove touchmove", this._onDrag, this), G.off(document, "mouseup touchend", this._onDragEnd, this), this._restoreCoordGetters(), n) {
331
+ this._path.fire("dragend", { distance: ye(this._dragStartPoint, t) });
332
+ let e = this._path._containsPoint;
333
+ this._path._containsPoint = X.falseFn, X.requestAnimFrame(function() {
334
+ this._path._dragMoved = !1, this._path.options.interactive = !0, this._path._containsPoint = e;
335
+ }, this);
336
+ }
337
+ this._mapDraggingWasEnabled && this._path._map.dragging.enable();
338
+ },
339
+ _transformPoints: function(e, t) {
340
+ let n = this._path, r = L.point(e[4], e[5]), i = n._map.options.crs, a = i.transformation, o = i.scale(n._map.getZoom()), s = i.projection, c = a.untransform(r, o).subtract(a.untransform(ce(0, 0), o)), l = !t;
341
+ if (n._bounds = new re(), n._point) t = s.unproject(s.project(n._latlng)._add(c)), l && (n._latlng = t, n._point._add(r));
342
+ else if (n._rings || n._parts) {
343
+ let e = n._rings || n._parts, i = n._latlngs;
344
+ t ||= i, X.isArray(i[0]) || (i = [i], t = [t]);
345
+ for (let a = 0, o = e.length; a < o; a++) {
346
+ t[a] = t[a] || [];
347
+ for (let o = 0, u = e[a].length; o < u; o++) {
348
+ let u = i[a][o];
349
+ t[a][o] = s.unproject(s.project(u)._add(c)), l && (n._bounds.extend(i[a][o]), e[a][o]._add(r));
350
+ }
351
+ }
352
+ }
353
+ return t;
354
+ },
355
+ _replaceCoordGetters: function() {
356
+ this._path.getLatLng ? (this._path.getLatLng_ = this._path.getLatLng, this._path.getLatLng = X.bind(function() {
357
+ return this.dragging._transformPoints(this.dragging._matrix, {});
358
+ }, this._path)) : this._path.getLatLngs && (this._path.getLatLngs_ = this._path.getLatLngs, this._path.getLatLngs = X.bind(function() {
359
+ return this.dragging._transformPoints(this.dragging._matrix, []);
360
+ }, this._path));
361
+ },
362
+ _restoreCoordGetters: function() {
363
+ this._path.getLatLng_ ? (this._path.getLatLng = this._path.getLatLng_, delete this._path.getLatLng_) : this._path.getLatLngs_ && (this._path.getLatLngs = this._path.getLatLngs_, delete this._path.getLatLngs_);
364
+ }
365
+ }), q.PathDrag.makeDraggable = function(e) {
366
+ return e.dragging = new q.PathDrag(e), e;
367
+ }, J.prototype.makeDraggable = function() {
368
+ return q.PathDrag.makeDraggable(this);
369
+ }, J.addInitHook(function() {
370
+ this.options.draggable ? (this.options.interactive = !0, this.dragging || q.PathDrag.makeDraggable(this), this.dragging.enable()) : this.dragging && this.dragging.disable();
371
+ });
372
+ var be = q.PathDrag;
373
+ //#endregion
374
+ //#region src/components/simple/geom.js
375
+ function xe(e, t, n = {}) {
376
+ let { pivot: r = "centroid", mutate: i = !1 } = n, a = t * Math.PI / 180, o = i ? e : JSON.parse(JSON.stringify(e));
377
+ function s(e, t) {
378
+ let [n, r, ...i] = e, o = t[0], s = t[1], c = n - o, l = r - s, u = Math.cos(a), d = Math.sin(a), f = o + u * c - d * l, p = s + d * c + u * l;
379
+ return i.length ? [
380
+ f,
381
+ p,
382
+ ...i
383
+ ] : [f, p];
384
+ }
385
+ function c(e) {
386
+ if (e.length === 0) return e;
387
+ let t = e[0], n = e[e.length - 1];
388
+ return l(t, n) || e.push([...t]), e;
389
+ }
390
+ function l(e, t) {
391
+ return !e || !t ? !1 : e[0] === t[0] && e[1] === t[1];
392
+ }
393
+ function u(e) {
394
+ let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
395
+ for (let a of e) {
396
+ let e = a[0], o = a[1];
397
+ e < t && (t = e), o < n && (n = o), e > r && (r = e), o > i && (i = o);
398
+ }
399
+ return isFinite(t) ? [(t + r) / 2, (n + i) / 2] : [0, 0];
400
+ }
401
+ function d(e) {
402
+ if (!e.length) return [0, 0];
403
+ let t = 0, n = 0;
404
+ for (let r of e) t += r[0], n += r[1];
405
+ return [t / e.length, n / e.length];
406
+ }
407
+ function f(e) {
408
+ let t = e.map((e) => l(e[0], e[e.length - 1]) ? e : [...e, e[0]]), n = 0, r = 0, i = 0;
409
+ for (let e of t) {
410
+ let t = 0, a = 0, o = 0;
411
+ for (let n = 0; n < e.length - 1; n++) {
412
+ let [r, i] = e[n], [s, c] = e[n + 1], l = r * c - s * i;
413
+ t += l, a += (r + s) * l, o += (i + c) * l;
414
+ }
415
+ n += t, r += a, i += o;
416
+ }
417
+ return n === 0 ? d(e.flat()) : [r / (3 * n), i / (3 * n)];
418
+ }
419
+ function p(e) {
420
+ let t = [], n = (e) => t.push(e), r = (e) => {
421
+ if (!e) return;
422
+ let t = e.type;
423
+ if (t === "Point") n(e.coordinates);
424
+ else if (t === "MultiPoint" || t === "LineString") for (let t of e.coordinates) n(t);
425
+ else if (t === "MultiLineString" || t === "Polygon") for (let t of e.coordinates) for (let e of t) n(e);
426
+ else if (t === "MultiPolygon") for (let t of e.coordinates) for (let e of t) for (let t of e) n(t);
427
+ else if (t === "GeometryCollection") for (let t of e.geometries) r(t);
428
+ };
429
+ return r(e), t;
430
+ }
431
+ function m(e) {
432
+ if (!e) return [0, 0];
433
+ let t = e.type;
434
+ if (r === "bbox") return u(p(e));
435
+ if (t === "Point") return [e.coordinates[0], e.coordinates[1]];
436
+ if (t === "MultiPoint" || t === "LineString") return d(e.coordinates);
437
+ if (t === "MultiLineString") return d(e.coordinates.flat());
438
+ if (t === "Polygon") return f(e.coordinates);
439
+ if (t === "MultiPolygon") {
440
+ let t = 0, n = 0, r = 0;
441
+ for (let i of e.coordinates) {
442
+ let e = f(i), a = 0;
443
+ for (let e of i) {
444
+ let t = l(e[0], e[e.length - 1]) ? e : [...e, e[0]];
445
+ for (let e = 0; e < t.length - 1; e++) {
446
+ let [n, r] = t[e], [i, o] = t[e + 1];
447
+ a += n * o - i * r;
448
+ }
449
+ }
450
+ a !== 0 && isFinite(e[0]) && isFinite(e[1]) && (t += a, n += e[0] * (3 * a), r += e[1] * (3 * a));
451
+ }
452
+ return t === 0 ? d(p(e)) : [n / (3 * t), r / (3 * t)];
453
+ }
454
+ return d(p(e));
455
+ }
456
+ function h(e, t) {
457
+ let n = e.type;
458
+ return n === "Point" ? e.coordinates = s(e.coordinates, t) : n === "MultiPoint" || n === "LineString" ? e.coordinates = e.coordinates.map((e) => s(e, t)) : n === "MultiLineString" ? e.coordinates = e.coordinates.map((e) => e.map((e) => s(e, t))) : n === "Polygon" ? e.coordinates = e.coordinates.map((e) => {
459
+ let n = c(e.slice()).map((e) => s(e, t));
460
+ return n[n.length - 1] = [...n[0]], n;
461
+ }) : n === "MultiPolygon" ? e.coordinates = e.coordinates.map((e) => e.map((e) => {
462
+ let n = c(e.slice()).map((e) => s(e, t));
463
+ return n[n.length - 1] = [...n[0]], n;
464
+ })) : n === "GeometryCollection" && (e.geometries = e.geometries.map((e) => h(e, t))), e;
465
+ }
466
+ if (o.type === "Feature") {
467
+ let e = m(o.geometry);
468
+ return o.geometry = h(o.geometry, e), o;
469
+ }
470
+ if (o.type === "FeatureCollection") {
471
+ let e = m({
472
+ type: "GeometryCollection",
473
+ geometries: o.features.map((e) => e.geometry).filter(Boolean)
474
+ });
475
+ return o.features = o.features.map((t) => (t.geometry &&= h(t.geometry, e), t)), o;
476
+ }
477
+ return h(o, m(o));
478
+ }
479
+ //#endregion
480
+ //#region src/components/simple/SimpleGeomEditor.vue?vue&type=script&setup=true&lang.ts
481
+ var Se = { class: "row justify-between items-center q-pa-sm" }, Ce = { class: "q-pa-sm" }, we = { class: "row" }, Te = { class: "column justify-center q-gutter-y-sm" }, Ee = {
482
+ class: "absolute-top-right q-ma-md text-h6",
483
+ style: { "z-index": "999" }
484
+ }, De = /* @__PURE__ */ D({
485
+ __name: "SimpleGeomEditor",
486
+ props: {
487
+ modelValue: {},
488
+ class: {},
489
+ required: { type: Boolean },
490
+ readOnly: { type: Boolean },
491
+ defaultColour: {},
492
+ title: {},
493
+ subtitle: {},
494
+ toolbar: {},
495
+ centre: {},
496
+ keys: {}
497
+ },
498
+ emits: ["update:model-value"],
499
+ setup(r, { emit: o }) {
500
+ let c = r, l = o, d = F(), f = F(0), m = F(), g = F(), _ = F(!1), v = F(!1), y = F(0), b = e(), D, O;
501
+ I(m, (e, t) => {
502
+ O.setStyle({
503
+ fillColor: void 0,
504
+ weight: 4
505
+ }), e && (g.value = e.options.color || c.defaultColour, e.setStyle && e.setStyle({
506
+ fillColor: "#6a1b9a",
507
+ weight: 4
508
+ }), e.enableEdit?.(D), e.dragging?.enable()), t && (t.disableEdit?.(D), t.dragging?.disable());
509
+ }), I(v, (e) => {
510
+ !e && Y && Y.removeFrom(D);
511
+ }), M(() => {
512
+ if (k(), c.modelValue && !c.readOnly) q(c.modelValue), D.flyToBounds(O.getBounds(), { animate: !1 });
513
+ else if (c.modelValue) {
514
+ let e = Z(c.modelValue);
515
+ D.addLayer(e), D.flyToBounds(e.getBounds());
516
+ }
517
+ f.value = O.getLayers().length;
518
+ }), N(() => {
519
+ D && D.remove();
520
+ });
521
+ function k() {
522
+ D && D.remove();
523
+ let e = new oe("https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v12/tiles/{z}/{x}/{y}?access_token=" + c.keys.mapbox, {
524
+ maxZoom: 18,
525
+ noWrap: !0
526
+ }).setZIndex(0);
527
+ if (c.readOnly) D = new ie(d.value).setView(c.centre ? [c.centre.lng, c.centre.lat] : [-25, 135], c.centre ? c.centre.zoom : 5);
528
+ else {
529
+ D = new ie(d.value, { editable: !0 }).setView(c.centre ? [c.centre.lng, c.centre.lat] : [-25, 135], c.centre ? c.centre.zoom : 5), D.on("click", (e) => {
530
+ let t = e.originalEvent.target, n = t.closest(".leaflet-overlay-pane"), r = t.closest(".leaflet-control");
531
+ !n && !r && !_.value && (m.value = void 0);
532
+ });
533
+ let e = W.extend({
534
+ options: {
535
+ position: "topleft",
536
+ callback: null,
537
+ kind: "",
538
+ html: ""
539
+ },
540
+ onAdd: function(e) {
541
+ var t = K.create("div", "leaflet-control leaflet-bar qmap-leaflet-button"), n = K.create("a", "", t);
542
+ let r = this.options;
543
+ return n.href = "#", n.title = "Create a new " + r.kind, n.innerHTML = this.options.html, G.on(n, "click", G.stop).on(n, "click", function() {
544
+ r.callback.call(e.editTools);
545
+ }, this), t;
546
+ }
547
+ }), t = e.extend({ options: {
548
+ position: "topleft",
549
+ callback: D.editTools.startPolyline,
550
+ kind: "line",
551
+ html: "<i class=\"fal fa-scribble\"/>"
552
+ } }), n = e.extend({ options: {
553
+ position: "topleft",
554
+ callback: D.editTools.startPolygon,
555
+ kind: "polygon",
556
+ html: "<i class=\"fal fa-draw-polygon\"/>"
557
+ } }), r = e.extend({ options: {
558
+ position: "topleft",
559
+ callback: D.editTools.startMarker,
560
+ kind: "marker",
561
+ html: "<i class=\"fal fa-map-pin\"/>"
562
+ } }), i = e.extend({ options: {
563
+ position: "topleft",
564
+ callback: D.editTools.startRectangle,
565
+ kind: "rectangle",
566
+ html: "<i class=\"fal fa-square\"/>"
567
+ } }), a = e.extend({ options: {
568
+ position: "topleft",
569
+ callback: D.editTools.startCircle,
570
+ kind: "rectangle",
571
+ html: "<i class=\"fal fa-circle\"/>"
572
+ } });
573
+ c.readOnly || (D.addControl(new r()), D.addControl(new t()), D.addControl(new n()), D.addControl(new i()), D.addControl(new a())), D.on("editable:edited", (e) => {
574
+ let t = e.layer;
575
+ O.hasLayer(t) || J(t), z();
576
+ });
577
+ }
578
+ if (localStorage.lastMapPos) {
579
+ let e = JSON.parse(localStorage.lastMapPos);
580
+ if (e?.ne && e.sw) {
581
+ let t = new re(e.ne, e.sw);
582
+ D.flyToBounds(t, { animate: !1 });
583
+ } else D.setView([-26, 132], 5);
584
+ } else D.setView([-26, 132], 5);
585
+ D.addLayer(e), D.on("moveend", (e) => {
586
+ let t = e.target.getBounds();
587
+ localStorage.lastMapPos = JSON.stringify({
588
+ ne: t.getNorthEast(),
589
+ sw: t.getSouthWest()
590
+ });
591
+ }), O = se().addTo(D);
592
+ }
593
+ function z() {
594
+ let e = O.getLayers().map((e) => {
595
+ function t(t) {
596
+ return Object.keys(e.options).filter((e) => [
597
+ "color",
598
+ "fill",
599
+ "fillColor",
600
+ "fillOpacity",
601
+ "stroke",
602
+ "weight",
603
+ "title"
604
+ ].indexOf(e) != -1).forEach((n) => t.properties[n] = e.options[n]), t;
605
+ }
606
+ if (e instanceof U) {
607
+ let n = e.toGeoJSON();
608
+ return n.properties = {
609
+ type: "circle",
610
+ radius: e.getRadius()
611
+ }, t(n);
612
+ }
613
+ if (e instanceof ae) {
614
+ let n = e.toGeoJSON();
615
+ return n.properties = { type: "rectangle" }, t(n);
616
+ }
617
+ return t(e.toGeoJSON());
618
+ });
619
+ l("update:model-value", {
620
+ features: e,
621
+ type: "FeatureCollection"
622
+ }), f.value = O.getLayers().length;
623
+ }
624
+ function V() {
625
+ O.removeLayer(m.value), z();
626
+ }
627
+ function H(e) {
628
+ m.value.setStyle({ color: g.value }), z(), e ? _.value = e : setTimeout(() => {
629
+ _.value = e;
630
+ }, 200);
631
+ }
632
+ function q(e) {
633
+ var t;
634
+ return Z(e, { onEachFeature: (e, n) => {
635
+ let r;
636
+ if (r = e.properties?.type == "circle" && e.properties?.radius ? new U(new ne([n]).getBounds().getCenter(), e.properties.radius) : e.properties?.type == "rectangle" ? new ae(new ne([n]).getBounds()) : n, e.properties) {
637
+ let t = {};
638
+ Object.keys(e.properties).filter((e) => [
639
+ "color",
640
+ "fill",
641
+ "fillOpacity",
642
+ "stroke",
643
+ "weight",
644
+ "title"
645
+ ].indexOf(e) != -1).forEach((n) => t[n] = e.properties[n]), r.setStyle && r.setStyle(t);
646
+ }
647
+ e.properties?.title && r.bindTooltip(e.properties.title, {
648
+ permanent: !0,
649
+ direction: "center",
650
+ className: "q-card",
651
+ opacity: 1
652
+ }), J(r), t = r;
653
+ } }), t;
654
+ }
655
+ function J(e) {
656
+ O.addLayer(e), be.makeDraggable(e), e.on("click", (t) => {
657
+ m.value = e;
658
+ });
659
+ }
660
+ var Y, X;
661
+ function ce(e) {
662
+ X = xe(m.value.toGeoJSON(), 360 - e), Y && Y.remove(), Y = Z(X), Y.setStyle({ color: "#999" }), Y.addTo(D);
663
+ }
664
+ function Q() {
665
+ if (Y) {
666
+ Y.removeFrom(D), Y = void 0, O.removeLayer(m.value);
667
+ let e = q(X);
668
+ e?.setStyle({ color: m.value?.options.color }), m.value = e, v.value = !1, z();
669
+ }
670
+ }
671
+ function $() {
672
+ b.dialog({
673
+ title: "Caption",
674
+ message: "Enter the text to display on this feature",
675
+ prompt: { model: m.value?.options?.title || "" },
676
+ ok: "Apply",
677
+ cancel: "Cancel"
678
+ }).onOk((e) => {
679
+ e ? (m.value.options.title = e, m.value?.bindTooltip(e, {
680
+ permanent: !0,
681
+ direction: "center",
682
+ className: "q-card",
683
+ opacity: 1
684
+ })) : (m.value.options.title = void 0, m.value?.closeTooltip()), z();
685
+ });
686
+ }
687
+ return (e, o) => (P(), C("div", {
688
+ ref_key: "mapDiv",
689
+ ref: d,
690
+ class: A(c.class)
691
+ }, [m.value ? (P(), x(n, {
692
+ key: 0,
693
+ class: "absolute-bottom-left q-ma-md bg-grey-1 column",
694
+ style: { "z-index": "999" },
695
+ onClick: o[5] ||= B(() => {}, ["stop"]),
696
+ flat: "",
697
+ bordered: ""
698
+ }, {
699
+ default: R(() => [
700
+ w("div", Se, [o[6] ||= T(" Selected Item ", -1), E(s, {
701
+ size: "xs",
702
+ round: "",
703
+ flat: "",
704
+ icon: "fa fa-times",
705
+ onClick: o[0] ||= (e) => m.value = void 0
706
+ })]),
707
+ E(t),
708
+ w("div", Ce, [
709
+ E(s, {
710
+ flat: "",
711
+ label: "Caption",
712
+ size: "sm",
713
+ "no-caps": "",
714
+ onClick: $
715
+ }, {
716
+ default: R(() => [E(u, {
717
+ name: "fas fa-font",
718
+ class: "q-ml-sm"
719
+ })]),
720
+ _: 1
721
+ }),
722
+ E(s, {
723
+ flat: "",
724
+ label: "Colour",
725
+ size: "sm",
726
+ "no-caps": ""
727
+ }, {
728
+ default: R(() => [E(u, {
729
+ name: "fas fa-circle",
730
+ class: "q-ml-sm",
731
+ style: j({ color: m.value.options.color || r.defaultColour })
732
+ }, null, 8, ["style"]), E(h, {
733
+ cover: "",
734
+ "transition-show": "scale",
735
+ "transition-hide": "scale",
736
+ "onUpdate:modelValue": H
737
+ }, {
738
+ default: R(() => [E(p, {
739
+ modelValue: g.value,
740
+ "onUpdate:modelValue": o[1] ||= (e) => g.value = e
741
+ }, null, 8, ["modelValue"])]),
742
+ _: 1
743
+ })]),
744
+ _: 1
745
+ }),
746
+ m.value instanceof te(U) ? S("", !0) : (P(), x(s, {
747
+ key: 0,
748
+ flat: "",
749
+ label: "Rotate",
750
+ size: "sm",
751
+ "no-caps": ""
752
+ }, {
753
+ default: R(() => [E(u, {
754
+ name: "fas fa-rotate",
755
+ class: "q-ml-sm"
756
+ }), E(h, {
757
+ cover: "",
758
+ "transition-show": "scale",
759
+ "transition-hide": "scale",
760
+ modelValue: v.value,
761
+ "onUpdate:modelValue": o[4] ||= (e) => v.value = e
762
+ }, {
763
+ default: R(() => [w("div", we, [E(he, {
764
+ "show-value": "",
765
+ class: "text-light-blue q-ma-md",
766
+ modelValue: y.value,
767
+ "onUpdate:modelValue": [o[2] ||= (e) => y.value = e, ce],
768
+ size: "50px",
769
+ max: 359,
770
+ color: "light-blue"
771
+ }, null, 8, ["modelValue"]), w("div", Te, [E(s, {
772
+ size: "xs",
773
+ label: "Apply",
774
+ color: "positive",
775
+ disable: y.value == 0,
776
+ onClick: Q
777
+ }, null, 8, ["disable"]), E(s, {
778
+ size: "xs",
779
+ label: "Cancel",
780
+ color: "negative",
781
+ onClick: o[3] ||= (e) => v.value = !1
782
+ })])])]),
783
+ _: 1
784
+ }, 8, ["modelValue"])]),
785
+ _: 1
786
+ })),
787
+ E(s, {
788
+ flat: "",
789
+ onClick: V,
790
+ label: "Delete",
791
+ size: "sm",
792
+ "no-caps": ""
793
+ }, {
794
+ default: R(() => [E(u, {
795
+ name: "fas fa-trash",
796
+ class: "q-ml-sm text-negative"
797
+ })]),
798
+ _: 1
799
+ })
800
+ ])
801
+ ]),
802
+ _: 1
803
+ })) : S("", !0), w("div", Ee, [
804
+ T(ee(r.title) + " ", 1),
805
+ E(i, { "q-map": {
806
+ id: "",
807
+ title: "",
808
+ subtitle: r.subtitle
809
+ } }, null, 8, ["q-map"]),
810
+ c.required ? (P(), x(u, {
811
+ key: 0,
812
+ name: "fas fa-asterisk",
813
+ color: !c.required || f.value ? "grey" : "negative"
814
+ }, null, 8, ["color"])) : S("", !0),
815
+ E(a, null, {
816
+ default: R(() => [...o[7] ||= [T("Required to have value", -1)]]),
817
+ _: 1
818
+ })
819
+ ])], 2));
820
+ }
821
+ });
822
+ //#endregion
823
+ export { De as default };