@nika-js/onlymap 0.8.3 → 0.8.4

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,6 +1,6 @@
1
- let $t = null, Z = null;
2
- function we(r) {
3
- $t = r;
1
+ let kt = null, Z = null;
2
+ function ye(r) {
3
+ kt = r;
4
4
  }
5
5
  function Ze() {
6
6
  return B !== null;
@@ -9,8 +9,8 @@ let B = null;
9
9
  function H() {
10
10
  return B;
11
11
  }
12
- function ve() {
13
- return B ? Promise.resolve(B) : Z || ($t ? (Z = Promise.resolve($t()).then((r) => (B = r, B)).catch((r) => {
12
+ function we() {
13
+ return B ? Promise.resolve(B) : Z || (kt ? (Z = Promise.resolve(kt()).then((r) => (B = r, B)).catch((r) => {
14
14
  throw Z = null, r;
15
15
  }), Z) : Promise.reject(
16
16
  new Error(
@@ -21,14 +21,14 @@ function ve() {
21
21
  const Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22
22
  __proto__: null,
23
23
  isCoreLoaded: Ze,
24
- loadCore: ve,
24
+ loadCore: we,
25
25
  peekCore: H,
26
- setCoreLoader: we
26
+ setCoreLoader: ye
27
27
  }, Symbol.toStringTag, { value: "Module" }));
28
- function zt(r) {
28
+ function Ut(r) {
29
29
  return { scale: r / 96, pxPerMm: r / 25.4 };
30
30
  }
31
- function pt(r) {
31
+ function gt(r) {
32
32
  return typeof r?.paintCartograph == "function";
33
33
  }
34
34
  const q = (r, t) => {
@@ -47,7 +47,7 @@ function C(r) {
47
47
  z: q(r, "z")
48
48
  };
49
49
  }
50
- function Et(r, t = 0) {
50
+ function $t(r, t = 0) {
51
51
  if (!r) return t;
52
52
  const e = Number.parseFloat(r);
53
53
  return Number.isFinite(e) ? e : t;
@@ -57,7 +57,7 @@ function F(r) {
57
57
  const t = r.trim().toLowerCase();
58
58
  return t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "none" ? null : r;
59
59
  }
60
- const W = 96 / 25.4, Dt = {
60
+ const W = 96 / 25.4, zt = {
61
61
  A0: { widthMm: 841, heightMm: 1189 },
62
62
  A1: { widthMm: 594, heightMm: 841 },
63
63
  A2: { widthMm: 420, heightMm: 594 },
@@ -66,11 +66,11 @@ const W = 96 / 25.4, Dt = {
66
66
  A5: { widthMm: 148, heightMm: 210 },
67
67
  Letter: { widthMm: 215.9, heightMm: 279.4 },
68
68
  Legal: { widthMm: 215.9, heightMm: 355.6 }
69
- }, jt = "A4";
69
+ }, Dt = "A4";
70
70
  function ut(r, t, e, n) {
71
71
  const i = t != null ? Number(t) : NaN, s = e != null ? Number(e) : NaN;
72
72
  if (Number.isFinite(i) && i > 0 && Number.isFinite(s) && s > 0) return { widthMm: i, heightMm: s };
73
- const o = Dt[r ?? jt] ?? Dt[jt];
73
+ const o = zt[r ?? Dt] ?? zt[Dt];
74
74
  return n === "landscape" ? { widthMm: o.heightMm, heightMm: o.widthMm } : { ...o };
75
75
  }
76
76
  let et = null;
@@ -109,17 +109,17 @@ async function rr(r, t = /* @__PURE__ */ new Date()) {
109
109
  const c = new DataView(new ArrayBuffer(22));
110
110
  return c.setUint32(0, 101010256, !0), c.setUint16(4, 0, !0), c.setUint16(6, 0, !0), c.setUint16(8, o.length, !0), c.setUint16(10, o.length, !0), c.setUint32(12, a - l, !0), c.setUint32(16, l, !0), c.setUint16(20, 0, !0), s.push(new Uint8Array(c.buffer)), new Blob(s, { type: "application/zip" });
111
111
  }
112
- const ft = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Me = {
112
+ const ft = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], ve = {
113
113
  protan: "protanopia",
114
114
  deutan: "deuteranopia",
115
115
  tritan: "tritanopia",
116
116
  achroma: "achromatopsia"
117
117
  };
118
- function Rt(r) {
118
+ function It(r) {
119
119
  const t = r?.trim().toLowerCase();
120
- return !t || t === "none" ? null : ft.includes(t) ? t : Me[t] ?? null;
120
+ return !t || t === "none" ? null : ft.includes(t) ? t : ve[t] ?? null;
121
121
  }
122
- const nr = ["none", ...ft, ...Object.keys(Me)], Ot = {
122
+ const nr = ["none", ...ft, ...Object.keys(ve)], Rt = {
123
123
  protanopia: [0.11238, 0.88762, 0, 0.11238, 0.88762, 0, 401e-5, -401e-5, 1],
124
124
  deuteranopia: [0.29275, 0.70725, 0, 0.29275, 0.70725, 0, -0.02234, 0.02234, 1],
125
125
  tritanopia: [1, 0.14461, -0.14461, 0, 0.85659, 0.14341, 0, 0.85659, 0.14341],
@@ -140,29 +140,29 @@ function ir(r) {
140
140
  const n = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(t);
141
141
  return n ? { r: Number(n[1]), g: Number(n[2]), b: Number(n[3]) } : null;
142
142
  }
143
- function Gt(r, t) {
144
- const e = Ot[t], [n, i, s] = [j(r.r), j(r.g), j(r.b)];
143
+ function jt(r, t) {
144
+ const e = Rt[t], [n, i, s] = [j(r.r), j(r.g), j(r.b)];
145
145
  return {
146
146
  r: lt(e[0] * n + e[1] * i + e[2] * s),
147
147
  g: lt(e[3] * n + e[4] * i + e[5] * s),
148
148
  b: lt(e[6] * n + e[7] * i + e[8] * s)
149
149
  };
150
150
  }
151
- function qt({ r, g: t, b: e }) {
151
+ function Gt({ r, g: t, b: e }) {
152
152
  const [n, i, s] = [j(r), j(t), j(e)], o = (n * 0.4124564 + i * 0.3575761 + s * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + s * 0.072175, l = (n * 0.0193339 + i * 0.119192 + s * 0.9503041) / 1.08883, c = (m) => m > 216 / 24389 ? Math.cbrt(m) : 841 / 108 * m + 4 / 29, [u, h, d] = [c(o), c(a), c(l)];
153
153
  return [116 * h - 16, 500 * (u - h), 200 * (h - d)];
154
154
  }
155
- function Wt(r, t) {
156
- const [e, n, i] = qt(r), [s, o, a] = qt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(o, a)) / 2, h = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, m] = [n * (1 + h), o * (1 + h)], [f, p] = [Math.hypot(d, i), Math.hypot(m, a)], g = (U, tt) => {
155
+ function qt(r, t) {
156
+ const [e, n, i] = Gt(r), [s, o, a] = Gt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(o, a)) / 2, h = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, m] = [n * (1 + h), o * (1 + h)], [f, g] = [Math.hypot(d, i), Math.hypot(m, a)], p = (U, tt) => {
157
157
  if (U === 0 && tt === 0) return 0;
158
158
  const J = Math.atan2(tt, U) * c;
159
159
  return J >= 0 ? J : J + 360;
160
- }, [b, w] = [g(d, i), g(m, a)], y = s - e, M = p - f;
160
+ }, [b, w] = [p(d, i), p(m, a)], y = s - e, M = g - f;
161
161
  let v = 0;
162
- f * p !== 0 && (v = w - b, v > 180 ? v -= 360 : v < -180 && (v += 360));
163
- const N = 2 * Math.sqrt(f * p) * Math.sin(v * l / 2), O = (e + s) / 2, k = (f + p) / 2;
162
+ f * g !== 0 && (v = w - b, v > 180 ? v -= 360 : v < -180 && (v += 360));
163
+ const N = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), O = (e + s) / 2, k = (f + g) / 2;
164
164
  let P = b + w;
165
- f * p !== 0 && (Math.abs(b - w) > 180 && (P += b + w < 360 ? 360 : -360), P /= 2);
165
+ f * g !== 0 && (Math.abs(b - w) > 180 && (P += b + w < 360 ? 360 : -360), P /= 2);
166
166
  const L = 1 - 0.17 * Math.cos((P - 30) * l) + 0.24 * Math.cos(2 * P * l) + 0.32 * Math.cos((3 * P + 6) * l) - 0.2 * Math.cos((4 * P - 63) * l), A = 1 + 0.015 * (O - 50) ** 2 / Math.sqrt(20 + (O - 50) ** 2), S = 1 + 0.045 * k, $ = 1 + 0.015 * k * L, E = -2 * Math.sqrt(k ** 7 / (k ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((P - 275) / 25) ** 2)) * l);
167
167
  return Math.sqrt((y / A) ** 2 + (M / S) ** 2 + (N / $) ** 2 + E * (M / S) * (N / $));
168
168
  }
@@ -180,8 +180,8 @@ function sr(r, t = or) {
180
180
  for (const l of e.values())
181
181
  for (let c = 0; c < l.length; c++)
182
182
  for (let u = c + 1; u < l.length; u++) {
183
- if (Wt(l[c].rgb, l[u].rgb) < t) continue;
184
- const d = Wt(Gt(l[c].rgb, a), Gt(l[u].rgb, a));
183
+ if (qt(l[c].rgb, l[u].rgb) < t) continue;
184
+ const d = qt(jt(l[c].rgb, a), jt(l[u].rgb, a));
185
185
  d < t && (n.push({ type: a, a: l[c].entry, b: l[u].entry, distance: d }), i.set(a, (i.get(a) ?? 0) + 1));
186
186
  }
187
187
  let s = null, o = 0;
@@ -204,29 +204,29 @@ function ar(r, t, e, n) {
204
204
  const l = (h) => {
205
205
  const d = Math.min(1, Math.max(0, h)) * o, m = Math.floor(d);
206
206
  return m >= o ? a[o] : a[m] + (a[m + 1] - a[m]) * (d - m);
207
- }, c = Ot[n], u = i.data;
207
+ }, c = Rt[n], u = i.data;
208
208
  for (let h = 0; h < u.length; h += 4) {
209
209
  const d = s[u[h]], m = s[u[h + 1]], f = s[u[h + 2]];
210
210
  u[h] = l(c[0] * d + c[1] * m + c[2] * f), u[h + 1] = l(c[3] * d + c[4] * m + c[5] * f), u[h + 2] = l(c[6] * d + c[7] * m + c[8] * f);
211
211
  }
212
212
  return r.putImageData(i, 0, 0), !0;
213
213
  }
214
- const Ae = (r) => `om-carto-cvd-${r}`;
214
+ const Me = (r) => `om-carto-cvd-${r}`;
215
215
  function lr(r) {
216
216
  if (r.getElementById("om-carto-cvd-filters")) return;
217
217
  const t = r.createElementNS("http://www.w3.org/2000/svg", "svg");
218
218
  t.id = "om-carto-cvd-filters", t.setAttribute("aria-hidden", "true"), t.setAttribute("width", "0"), t.setAttribute("height", "0"), t.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;";
219
219
  for (const e of ft) {
220
220
  const n = r.createElementNS("http://www.w3.org/2000/svg", "filter");
221
- n.id = Ae(e), n.setAttribute("color-interpolation-filters", "linearRGB");
221
+ n.id = Me(e), n.setAttribute("color-interpolation-filters", "linearRGB");
222
222
  const i = r.createElementNS("http://www.w3.org/2000/svg", "feColorMatrix");
223
223
  i.setAttribute("type", "matrix");
224
- const s = Ot[e];
224
+ const s = Rt[e];
225
225
  i.setAttribute("values", [s[0], s[1], s[2], 0, 0, s[3], s[4], s[5], 0, 0, s[6], s[7], s[8], 0, 0, 0, 0, 0, 1, 0].join(" ")), n.appendChild(i), t.appendChild(n);
226
226
  }
227
227
  r.body.appendChild(t);
228
228
  }
229
- const Se = 16384, Ce = 134217728;
229
+ const Ae = 16384, Se = 134217728;
230
230
  async function cr(r) {
231
231
  const t = [], e = [...r.querySelectorAll("img")];
232
232
  return await Promise.all(
@@ -245,7 +245,7 @@ function ur(r) {
245
245
  (t) => !t.hasAttribute("hidden") && !t.hasAttribute("data-om-carto-marks") && !t.hasAttribute("data-om-carto-flattened") && t.tagName.toLowerCase() !== "style" && t.tagName.toLowerCase() !== "script"
246
246
  ).map((t, e) => ({ el: t, index: e, z: C(t).z ?? 0 })).sort((t, e) => t.z - e.z || t.index - e.index).map((t) => t.el);
247
247
  }
248
- async function _t(r, t = {}) {
248
+ async function Ot(r, t = {}) {
249
249
  const e = r ?? document.querySelector("om-cartograph");
250
250
  if (!e) throw new Error("[onlymapjs/cartograph] renderCartograph: no <om-cartograph> to render.");
251
251
  const n = [], i = t.dpi ?? (Number(e.getAttribute("dpi")) || 300);
@@ -255,15 +255,15 @@ async function _t(r, t = {}) {
255
255
  e.getAttribute("width"),
256
256
  e.getAttribute("height"),
257
257
  e.getAttribute("orientation")
258
- ), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = s + a * 2, c = o + a * 2, u = t.maxDimension ?? Se, h = t.maxArea ?? Ce;
258
+ ), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = s + a * 2, c = o + a * 2, u = t.maxDimension ?? Ae, h = t.maxArea ?? Se;
259
259
  let d = i;
260
- const m = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(h / (l / 25.4 * (c / 25.4))), p = Math.min(m, f);
261
- d > p && (d = Math.floor(p), n.push(`Requested ${i} dpi exceeds this browser's canvas budget for a ${l.toFixed(0)}×${c.toFixed(0)}mm page; rendered at ${d} dpi instead.`)), n.push(...await cr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
262
- const g = zt(d), b = Math.max(1, Math.round(l * g.pxPerMm)), w = Math.max(1, Math.round(c * g.pxPerMm)), y = ur(e);
260
+ const m = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(h / (l / 25.4 * (c / 25.4))), g = Math.min(m, f);
261
+ d > g && (d = Math.floor(g), n.push(`Requested ${i} dpi exceeds this browser's canvas budget for a ${l.toFixed(0)}×${c.toFixed(0)}mm page; rendered at ${d} dpi instead.`)), n.push(...await cr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
262
+ const p = Ut(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y = ur(e);
263
263
  for (const A of y)
264
- if (!(!pt(A) || !A.prepareCartograph))
264
+ if (!(!gt(A) || !A.prepareCartograph))
265
265
  try {
266
- await A.prepareCartograph(zt(d));
266
+ await A.prepareCartograph(Ut(d));
267
267
  } catch (S) {
268
268
  A.discardCartograph?.(), n.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} could not be captured: ${S.message}`);
269
269
  }
@@ -274,14 +274,14 @@ async function _t(r, t = {}) {
274
274
  const N = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
275
275
  v.fillStyle = F(N?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
276
276
  for (const A of y) {
277
- if (!pt(A)) continue;
277
+ if (!gt(A)) continue;
278
278
  const S = C(A);
279
- if (v.save(), v.translate((S.x + a) * g.pxPerMm, (S.y + a) * g.pxPerMm), S.rotation) {
280
- const $ = S.w / 2 * g.pxPerMm, E = S.h / 2 * g.pxPerMm;
279
+ if (v.save(), v.translate((S.x + a) * p.pxPerMm, (S.y + a) * p.pxPerMm), S.rotation) {
280
+ const $ = S.w / 2 * p.pxPerMm, E = S.h / 2 * p.pxPerMm;
281
281
  v.translate($, E), v.rotate(S.rotation * Math.PI / 180), v.translate(-$, -E);
282
282
  }
283
283
  try {
284
- A.paintCartograph(v, g);
284
+ A.paintCartograph(v, p);
285
285
  } catch ($) {
286
286
  n.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} failed to render: ${$.message}`);
287
287
  }
@@ -290,18 +290,18 @@ async function _t(r, t = {}) {
290
290
  const O = e.querySelector(":scope > [data-om-carto-marks]");
291
291
  for (const A of O?.querySelectorAll("line") ?? []) {
292
292
  const S = Number(A.getAttribute("x1")), $ = Number(A.getAttribute("y1")), E = Number(A.getAttribute("x2")), U = Number(A.getAttribute("y2"));
293
- [S, $, E, U].every(Number.isFinite) && (v.save(), v.strokeStyle = A.getAttribute("stroke") || "#000000", v.lineWidth = (Number(A.getAttribute("stroke-width")) || 0.2) * g.pxPerMm, v.beginPath(), v.moveTo((S + a) * g.pxPerMm, ($ + a) * g.pxPerMm), v.lineTo((E + a) * g.pxPerMm, (U + a) * g.pxPerMm), v.stroke(), v.restore());
293
+ [S, $, E, U].every(Number.isFinite) && (v.save(), v.strokeStyle = A.getAttribute("stroke") || "#000000", v.lineWidth = (Number(A.getAttribute("stroke-width")) || 0.2) * p.pxPerMm, v.beginPath(), v.moveTo((S + a) * p.pxPerMm, ($ + a) * p.pxPerMm), v.lineTo((E + a) * p.pxPerMm, (U + a) * p.pxPerMm), v.stroke(), v.restore());
294
294
  }
295
- const k = Rt(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
295
+ const k = It(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
296
296
  k && !ar(v, b, w, k) && n.push("Colour-vision simulation was skipped: a cross-origin image on the page makes the export canvas unreadable.");
297
- for (const A of y) pt(A) && A.discardCartograph?.();
297
+ for (const A of y) gt(A) && A.discardCartograph?.();
298
298
  const P = t.format === "jpeg" ? "image/jpeg" : "image/png";
299
299
  P === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
300
300
  const L = await new Promise((A) => M.toBlob(A, P, t.quality));
301
301
  if (!L) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
302
302
  return { blob: L, widthPx: b, heightPx: w, dpi: d, warnings: n };
303
303
  }
304
- async function xe(r, t = {}) {
304
+ async function Ce(r, t = {}) {
305
305
  const e = r ?? document.querySelector("om-cartograph");
306
306
  if (!e) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: no <om-cartograph> to render.");
307
307
  const n = e.querySelector("om-atlas") ?? null;
@@ -317,14 +317,14 @@ async function xe(r, t = {}) {
317
317
  if (!Number.isInteger(h) || h < 0 || h >= i)
318
318
  throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: page ${t.page} is out of range (this atlas has ${i}).`);
319
319
  n.seek(h);
320
- const d = await Bt(e, t, a);
320
+ const d = await Wt(e, t, a);
321
321
  return { blob: d.blob, filenames: [o[h]], pages: 1, dpi: d.dpi, warnings: a };
322
322
  }
323
323
  const c = [];
324
324
  let u = t.dpi ?? 300;
325
325
  for (let h = 0; h < i; h++) {
326
326
  n.seek(h);
327
- const d = await Bt(e, t, a);
327
+ const d = await Wt(e, t, a);
328
328
  u = d.dpi, c.push({ name: o[h], data: d.blob }), t.onPage?.(h + 1, i);
329
329
  }
330
330
  return { blob: await rr(c), filenames: o, pages: i, dpi: u, warnings: a };
@@ -332,27 +332,27 @@ async function xe(r, t = {}) {
332
332
  n.seek(l);
333
333
  }
334
334
  }
335
- async function Bt(r, t, e) {
335
+ async function Wt(r, t, e) {
336
336
  for (const i of r.querySelectorAll("om-frame"))
337
337
  await i.mapElement?.whenSettled?.({ timeout: 2e4 });
338
- const n = await _t(r, t);
338
+ const n = await Ot(r, t);
339
339
  return e.push(...n.warnings), n;
340
340
  }
341
341
  const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
342
342
  __proto__: null,
343
- MAX_CANVAS_AREA: Ce,
344
- MAX_CANVAS_DIMENSION: Se,
345
- renderCartograph: _t,
346
- renderCartographAtlas: xe
343
+ MAX_CANVAS_AREA: Se,
344
+ MAX_CANVAS_DIMENSION: Ae,
345
+ renderCartograph: Ot,
346
+ renderCartographAtlas: Ce
347
347
  }, Symbol.toStringTag, { value: "Module" }));
348
- function Vt(r, t, e = {}) {
348
+ function Bt(r, t, e = {}) {
349
349
  const n = URL.createObjectURL(r), i = document.createElement("a");
350
350
  i.href = n, i.download = t, document.body.appendChild(i), i.click(), i.remove();
351
351
  const s = e.revokeAfterMs ?? 0;
352
352
  s > 0 ? setTimeout(() => URL.revokeObjectURL(n), s) : URL.revokeObjectURL(n);
353
353
  }
354
354
  const mr = 3e4;
355
- async function Ht(r, t = mr) {
355
+ async function Vt(r, t = mr) {
356
356
  let e = !1;
357
357
  const n = new Promise(
358
358
  (s) => setTimeout(() => {
@@ -380,7 +380,7 @@ async function dr(r, t = {}) {
380
380
  i && r.setAttribute("cvd", i);
381
381
  const s = n.get("export");
382
382
  if (s) {
383
- await Ht(r, t.timeoutMs);
383
+ await Vt(r, t.timeoutMs);
384
384
  const o = s === "jpeg" ? "jpeg" : "png", a = Number(n.get("dpi")) || void 0, l = r.getAttribute("cartograph-id") || "cartograph", c = n.get("page");
385
385
  if (c != null) {
386
386
  const h = r.querySelector("om-atlas");
@@ -388,15 +388,15 @@ async function dr(r, t = {}) {
388
388
  const d = Number(c);
389
389
  if (!Number.isInteger(d) || d < 1) throw new Error(`?page=${c} is not a page number (they start at 1).`);
390
390
  h.refresh?.();
391
- const m = await xe(r, { dpi: a, format: o, page: d - 1 });
391
+ const m = await Ce(r, { dpi: a, format: o, page: d - 1 });
392
392
  for (const f of m.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
393
- return Vt(m.blob, m.filenames[0] ?? `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
393
+ return Bt(m.blob, m.filenames[0] ?? `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
394
394
  }
395
- const u = await _t(r, { dpi: a, format: o });
395
+ const u = await Ot(r, { dpi: a, format: o });
396
396
  for (const h of u.warnings) console.warn(`[onlymapjs/cartograph] ${h}`);
397
- return Vt(u.blob, `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
397
+ return Bt(u.blob, `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
398
398
  }
399
- return n.get("print") === "1" ? (await Ht(r, t.timeoutMs), typeof r.print == "function" ? await r.print({ dpi: Number(n.get("dpi")) || void 0 }) : typeof window < "u" && window.print(), "print") : i ? "cvd" : null;
399
+ return n.get("print") === "1" ? (await Vt(r, t.timeoutMs), typeof r.print == "function" ? await r.print({ dpi: Number(n.get("dpi")) || void 0 }) : typeof window < "u" && window.print(), "print") : i ? "cvd" : null;
400
400
  }
401
401
  function fr() {
402
402
  if (typeof document > "u") return;
@@ -406,19 +406,19 @@ function fr() {
406
406
  };
407
407
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", r, { once: !0 }) : r();
408
408
  }
409
- const ke = typeof window < "u" && typeof document < "u" && typeof customElements < "u", pr = ke ? HTMLElement : class {
409
+ const xe = typeof window < "u" && typeof document < "u" && typeof customElements < "u", gr = xe ? HTMLElement : class {
410
410
  };
411
411
  function x(r, t) {
412
- ke && (customElements.get(r) || customElements.define(r, t));
412
+ xe && (customElements.get(r) || customElements.define(r, t));
413
413
  }
414
- function gr(r) {
414
+ function pr(r) {
415
415
  if (typeof DOMParser > "u")
416
416
  throw new Error(
417
417
  "[onlymapjs] Parsing a manifest string needs a DOM implementation (DOMParser). In node, run under a DOM test environment — e.g. vitest with `environment: 'happy-dom'` (or jsdom) — or pass an already-parsed Element instead of a string."
418
418
  );
419
419
  return new DOMParser().parseFromString(r, "text/html");
420
420
  }
421
- class R extends pr {
421
+ class R extends gr {
422
422
  renderQueued = !1;
423
423
  connectedCallback() {
424
424
  this.scheduleRender();
@@ -450,10 +450,10 @@ class R extends pr {
450
450
  a != null && Number.isInteger(a) ? this.style.zIndex = String(a) : this.style.removeProperty("z-index");
451
451
  }
452
452
  }
453
- const gt = "cartograph/2", Vn = ["default", "dark", "sepia", "blueprint", "minimal"], Kt = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], br = /* @__PURE__ */ new Map([
453
+ const pt = "cartograph/2", Hn = ["default", "dark", "sepia", "blueprint", "minimal"], Ht = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], br = /* @__PURE__ */ new Map([
454
454
  ["projection", "live frames render Web Mercator (EPSG:3857) only — Globe support is design-only; use a static frame for other projections"]
455
455
  ]), z = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], T = {
456
- "om-cartograph": ["cartograph-id", "format", "size", "width", "height", "orientation", "theme", "title", "attribution", "notes", "cvd", "bleed", "crop-marks", "safe-zone", "dpi", "flatten", "color-profile", "allow-url-actions"],
456
+ "om-cartograph": ["cartograph-id", "format", "size", "width", "height", "orientation", "theme", "title", "attribution", "notes", "cvd", "bleed", "crop-marks", "safe-zone", "dpi", "flatten", "color-profile", "allow-url-actions", "keep-badge"],
457
457
  "om-frame": [...z, "src", "mode", "center", "zoom", "bearing", "pitch", "dpi", "crs", "corners", "crs-def", "overview-of", "overview-stroke", "atlas-fit", "atlas-margin", "frame-stroke", "frame-bg"],
458
458
  "om-legend": [...z, "for", "title", "columns", "derived"],
459
459
  "om-legend-row": ["layer", "match", "label", "hide", "order", "color", "shape"],
@@ -472,12 +472,12 @@ const gt = "cartograph/2", Vn = ["default", "dark", "sepia", "blueprint", "minim
472
472
  function Ar(r) {
473
473
  return r != null && yr.includes(r) ? r : null;
474
474
  }
475
- function $e(r) {
475
+ function ke(r) {
476
476
  if (!isFinite(r) || r <= 0) return 0;
477
477
  const t = Math.pow(10, Math.floor(Math.log10(r))), e = r / t;
478
478
  return (e >= 5 ? 5 : e >= 2 ? 2 : 1) * t;
479
479
  }
480
- const Yt = {
480
+ const Kt = {
481
481
  // Finest first; the largest tier whose snapped length is ≥ 1 unit wins.
482
482
  metric: [
483
483
  { metersPerUnit: 1, label: "m" },
@@ -489,21 +489,21 @@ const Yt = {
489
489
  ],
490
490
  nautical: [{ metersPerUnit: Mr, label: "nmi" }]
491
491
  };
492
- function Ee({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
492
+ function $e({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
493
493
  if (!Number.isFinite(r) || r <= 0 || !Number.isFinite(t) || t <= 0) return null;
494
- const s = Number.isInteger(e) && e > 0 ? e : 4, o = Yt[n] ?? Yt.metric, a = t / s * r;
494
+ const s = Number.isInteger(e) && e > 0 ? e : 4, o = Kt[n] ?? Kt.metric, a = t / s * r;
495
495
  let l, c;
496
496
  if (i != null && Number.isFinite(i) && i > 0)
497
- l = i, c = Xt(o, l);
497
+ l = i, c = Yt(o, l);
498
498
  else {
499
- c = Xt(o, a);
500
- const f = $e(a / c.metersPerUnit);
499
+ c = Yt(o, a);
500
+ const f = ke(a / c.metersPerUnit);
501
501
  if (f <= 0) return null;
502
502
  l = f * c.metersPerUnit;
503
503
  }
504
504
  const u = l / r;
505
505
  if (!Number.isFinite(u) || u <= 0) return null;
506
- const h = l / c.metersPerUnit, d = h < 1 ? 2 : h < 10 && !Number.isInteger(h) ? 1 : 0, m = Array.from({ length: s + 1 }, (f, p) => (p * h).toFixed(d));
506
+ const h = l / c.metersPerUnit, d = h < 1 ? 2 : h < 10 && !Number.isInteger(h) ? 1 : 0, m = Array.from({ length: s + 1 }, (f, g) => (g * h).toFixed(d));
507
507
  return {
508
508
  segmentMeters: l,
509
509
  segmentMm: u,
@@ -519,8 +519,8 @@ function Ee({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "
519
519
  function Sr(r, t, e) {
520
520
  const n = Math.min(2.6, Math.max(1.6, e * 0.34)), i = 0.2, s = n * 1.25, o = Math.max(0.6, Math.min(2.2, e - s - 0.4)), a = 0, l = r.segmentMm, c = [], u = [];
521
521
  if (t === "single" || t === "double") {
522
- const g = t === "double" ? 2 : 1, b = o / g;
523
- for (let w = 0; w < g; w++)
522
+ const p = t === "double" ? 2 : 1, b = o / p;
523
+ for (let w = 0; w < p; w++)
524
524
  for (let y = 0; y < r.segments; y++)
525
525
  c.push({
526
526
  x: y * l,
@@ -532,33 +532,33 @@ function Sr(r, t, e) {
532
532
  });
533
533
  } else {
534
534
  u.push({ x1: 0, y1: a + o, x2: r.totalMm, y2: a + o });
535
- const g = t === "ticks" ? r.segments : 1;
536
- for (let b = 0; b <= g; b++) {
537
- const w = b / g * r.totalMm;
535
+ const p = t === "ticks" ? r.segments : 1;
536
+ for (let b = 0; b <= p; b++) {
537
+ const w = b / p * r.totalMm;
538
538
  u.push({ x1: w, y1: a, x2: w, y2: a + o });
539
539
  }
540
540
  }
541
- const h = r.labels.length - 1, d = r.labels.map((g, b) => ({
541
+ const h = r.labels.length - 1, d = r.labels.map((p, b) => ({
542
542
  // The end label carries the unit so the bar reads "0 2 4 6 8 km".
543
- text: b === h ? `${g} ${r.unitLabel}` : g,
543
+ text: b === h ? `${p} ${r.unitLabel}` : p,
544
544
  // Keep the end label inside the drawn width rather than hanging off it.
545
545
  x: b === h ? r.totalMm : b * l,
546
546
  y: a + o + n,
547
547
  anchor: b === 0 ? "start" : b === h ? "end" : "middle",
548
548
  index: b
549
- })), m = (g) => g.length * n * 0.62, f = [];
550
- let p = -1 / 0;
551
- for (const g of d) {
552
- const b = m(g.text) / 2, w = g.anchor === "start" ? g.x : g.anchor === "end" ? g.x - b * 2 : g.x - b, y = w + m(g.text);
553
- if (!(!(g.index === 0 || g.index === h) && w < p + n * 0.4)) {
554
- if (g.index === h && w < p + n * 0.4)
549
+ })), m = (p) => p.length * n * 0.62, f = [];
550
+ let g = -1 / 0;
551
+ for (const p of d) {
552
+ const b = m(p.text) / 2, w = p.anchor === "start" ? p.x : p.anchor === "end" ? p.x - b * 2 : p.x - b, y = w + m(p.text);
553
+ if (!(!(p.index === 0 || p.index === h) && w < g + n * 0.4)) {
554
+ if (p.index === h && w < g + n * 0.4)
555
555
  for (; f.length > 1 && f[f.length - 1].x + m(f[f.length - 1].text) / 2 > w - n * 0.4; ) f.pop();
556
- f.push({ text: g.text, x: g.x, y: g.y, anchor: g.anchor }), p = y;
556
+ f.push({ text: p.text, x: p.x, y: p.y, anchor: p.anchor }), g = y;
557
557
  }
558
558
  }
559
559
  return { bars: c, strokes: u, labels: f, fontMm: n, strokeMm: i, segmentMeters: r.segmentMeters, unitLabel: r.unitLabel, scaleDenominator: r.scaleDenominator };
560
560
  }
561
- function Xt(r, t) {
561
+ function Yt(r, t) {
562
562
  let e = r[0];
563
563
  for (const n of r)
564
564
  t / n.metersPerUnit >= 1 && (e = n);
@@ -568,7 +568,7 @@ const Cr = " ";
568
568
  function xr(r) {
569
569
  return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g, Cr);
570
570
  }
571
- const Ne = /\{\{\s*([\w.]+)\s*\}\}/g;
571
+ const Ee = /\{\{\s*([\w.]+)\s*\}\}/g;
572
572
  function kr(r, t) {
573
573
  if (r.startsWith("atlas.")) return t.atlas?.[r.slice(6)];
574
574
  if (r.startsWith("frame.")) {
@@ -581,17 +581,17 @@ function kr(r, t) {
581
581
  }
582
582
  return t.page[r];
583
583
  }
584
- function Pe(r, t) {
584
+ function Ne(r, t) {
585
585
  const e = [];
586
- return { text: r.replace(Ne, (i, s) => {
586
+ return { text: r.replace(Ee, (i, s) => {
587
587
  const o = kr(s, t);
588
588
  return o === void 0 ? (e.push(s), i) : o;
589
589
  }), unresolved: e };
590
590
  }
591
591
  function $r(r) {
592
- return [...r.matchAll(Ne)].map((t) => t[1]);
592
+ return [...r.matchAll(Ee)].map((t) => t[1]);
593
593
  }
594
- const Jt = /* @__PURE__ */ new WeakMap();
594
+ const Xt = /* @__PURE__ */ new WeakMap();
595
595
  function Er(r, t) {
596
596
  const e = [], n = r.ownerDocument ?? (typeof document < "u" ? document : null);
597
597
  if (!n) return e;
@@ -602,12 +602,12 @@ function Er(r, t) {
602
602
  ), s = [];
603
603
  for (let o = i.nextNode(); o; o = i.nextNode()) s.push(o);
604
604
  for (const o of s) {
605
- let a = Jt.get(o);
605
+ let a = Xt.get(o);
606
606
  if (a === void 0) {
607
607
  if (a = o.data, !a.includes("{{")) continue;
608
- Jt.set(o, a);
608
+ Xt.set(o, a);
609
609
  }
610
- const l = Pe(a, t);
610
+ const l = Ne(a, t);
611
611
  o.data !== l.text && (o.data = l.text), e.push(...l.unresolved);
612
612
  }
613
613
  return e;
@@ -615,43 +615,43 @@ function Er(r, t) {
615
615
  function Nr(r = /* @__PURE__ */ new Date()) {
616
616
  return `${r.getFullYear()}-${String(r.getMonth() + 1).padStart(2, "0")}-${String(r.getDate()).padStart(2, "0")}`;
617
617
  }
618
- const Nt = "data-om-carto-unlinked";
619
- function Te(r) {
618
+ const Et = "data-om-carto-unlinked";
619
+ function Pe(r) {
620
620
  return r.closest("om-cartograph");
621
621
  }
622
- function Le(r, t) {
623
- const e = Te(r);
622
+ function Te(r, t) {
623
+ const e = Pe(r);
624
624
  if (!e || !t) return null;
625
625
  for (const n of e.querySelectorAll("om-frame"))
626
626
  if (n.id === t) return n;
627
627
  return null;
628
628
  }
629
- function Fe(r) {
629
+ function Le(r) {
630
630
  return [...r.querySelectorAll("om-frame")];
631
631
  }
632
632
  function Pr(r) {
633
- const t = Te(r);
633
+ const t = Pe(r);
634
634
  if (!t) return null;
635
- const e = Fe(t);
635
+ const e = Le(t);
636
636
  return e.length === 1 ? e[0] : null;
637
637
  }
638
638
  function _(r) {
639
639
  const t = r.getAttribute("for");
640
- return t ? Le(r, t) : Pr(r);
640
+ return t ? Te(r, t) : Pr(r);
641
641
  }
642
642
  function G(r, t) {
643
- let e = r.querySelector(`:scope > [${Nt}]`);
643
+ let e = r.querySelector(`:scope > [${Et}]`);
644
644
  if (!e) {
645
645
  for (const n of [...r.children])
646
646
  n.tagName.toLowerCase() !== "om-legend-row" && n.remove();
647
- e = r.ownerDocument.createElement("div"), e.setAttribute(Nt, ""), e.style.cssText = "font:italic 2.6mm/1.3 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.7;", r.appendChild(e);
647
+ e = r.ownerDocument.createElement("div"), e.setAttribute(Et, ""), e.style.cssText = "font:italic 2.6mm/1.3 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.7;", r.appendChild(e);
648
648
  }
649
649
  e.textContent !== t && (e.textContent = t);
650
650
  }
651
651
  function Tr(r) {
652
- r.querySelector(`:scope > [${Nt}]`)?.remove();
652
+ r.querySelector(`:scope > [${Et}]`)?.remove();
653
653
  }
654
- const Zt = "data-om-carto-page", Qt = "data-om-carto-marks", yt = "data-om-carto-credit", wt = "Built with OnlyMap by NIKA · free for non-commercial use", rt = 2, te = 1.2, vt = 2.4, ee = 1.5, Mt = 1.2, re = 0.3, ne = 0.8, At = "http://www.w3.org/2000/svg", Lr = 6e4;
654
+ const Jt = "data-om-carto-page", Zt = "data-om-carto-marks", yt = "data-om-carto-credit", Fe = "Built with OnlyMap by NIKA", Lr = `${Fe} · free for non-commercial use`, rt = 2, Qt = 1.2, wt = 2.4, te = 1.5, vt = 1.2, ee = 0.3, re = 0.8, Mt = "http://www.w3.org/2000/svg", Fr = 6e4;
655
655
  class Ie extends R {
656
656
  static observedAttributes = [...T["om-cartograph"]];
657
657
  frameListenerBound = !1;
@@ -693,25 +693,38 @@ class Ie extends R {
693
693
  renderCredit() {
694
694
  const t = H();
695
695
  t && !this.unsubscribeLicense && typeof t.subscribeLicense == "function" && (this.unsubscribeLicense = t.subscribeLicense(() => this.renderCredit()));
696
- const e = t ? t.getEntitlements().hideBadge : !1, n = [...this.querySelectorAll("om-text")].some((o) => /onlymap/i.test(o.textContent ?? "")), i = this.querySelector(`:scope > [${yt}]`);
697
- if (e || n) {
696
+ const e = this.creditMode(t, this.hasAttribute("keep-badge")), n = [...this.querySelectorAll("om-text")].some((a) => /onlymap/i.test(a.textContent ?? "")), i = this.querySelector(`:scope > [${yt}]`);
697
+ if (e === "hidden" || n) {
698
698
  i?.remove();
699
699
  return;
700
700
  }
701
+ const s = e === "voluntary" ? Fe : Lr;
701
702
  if (i) {
702
- this.armCreditPainter(i);
703
+ i.textContent !== s && (i.textContent = s), this.armCreditPainter(i);
703
704
  return;
704
705
  }
705
- const s = this.ownerDocument.createElement("div");
706
- s.setAttribute(yt, ""), s.setAttribute("z", "2147483644"), s.textContent = wt, s.style.cssText = `position:absolute;left:${rt}mm;bottom:${te}mm;z-index:2147483644;font:${vt}mm/${ee} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${re}mm ${Mt}mm;border-radius:${ne}mm;pointer-events:none;`, this.armCreditPainter(s), this.appendChild(s);
706
+ const o = this.ownerDocument.createElement("div");
707
+ o.setAttribute(yt, ""), o.setAttribute("z", "2147483644"), o.textContent = s, o.style.cssText = `position:absolute;left:${rt}mm;bottom:${Qt}mm;z-index:2147483644;font:${wt}mm/${te} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${ee}mm ${vt}mm;border-radius:${re}mm;pointer-events:none;`, this.armCreditPainter(o), this.appendChild(o);
708
+ }
709
+ /**
710
+ * Which credit this sheet carries, from the core's own predicate so the
711
+ * license decision is never re-implemented here — only the print wording
712
+ * is local.
713
+ */
714
+ creditMode(t, e) {
715
+ if (!t) return "obligation";
716
+ if (typeof t.badgeMode != "function")
717
+ return t.getEntitlements().hideBadge && !e ? "hidden" : "obligation";
718
+ const n = t.badgeMode({ keepBadge: e });
719
+ return n === "pending" ? "obligation" : n;
707
720
  }
708
721
  /** Give the runtime-owned DOM credit the same canvas paint contract as authored furniture. */
709
722
  armCreditPainter(t) {
710
723
  t.paintCartograph = (e, n) => {
711
- const i = (c) => c * n.pxPerMm, o = vt * ee + re * 2, a = this.pageSize.heightMm - te - o;
712
- e.save(), e.font = `${i(vt)}px system-ui, sans-serif`;
713
- const l = e.measureText(wt).width / n.pxPerMm + Mt * 2;
714
- e.fillStyle = "rgba(255,255,255,.72)", e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(i(rt), i(a), i(l), i(o), i(ne)) : e.rect(i(rt), i(a), i(l), i(o)), e.fill(), e.fillStyle = "#374151", e.textAlign = "left", e.textBaseline = "middle", e.fillText(wt, i(rt + Mt), i(a + o / 2)), e.restore();
724
+ const i = (u) => u * n.pxPerMm, s = t.textContent ?? "", a = wt * te + ee * 2, l = this.pageSize.heightMm - Qt - a;
725
+ e.save(), e.font = `${i(wt)}px system-ui, sans-serif`;
726
+ const c = e.measureText(s).width / n.pxPerMm + vt * 2;
727
+ e.fillStyle = "rgba(255,255,255,.72)", e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(i(rt), i(l), i(c), i(a), i(re)) : e.rect(i(rt), i(l), i(c), i(a)), e.fill(), e.fillStyle = "#374151", e.textAlign = "left", e.textBaseline = "middle", e.fillText(s, i(rt + vt), i(l + a / 2)), e.restore();
715
728
  };
716
729
  }
717
730
  /**
@@ -740,7 +753,7 @@ class Ie extends R {
740
753
  try {
741
754
  window.print();
742
755
  } finally {
743
- s || setTimeout(o, Lr);
756
+ s || setTimeout(o, Fr);
744
757
  }
745
758
  }
746
759
  /** Render the whole page to one image, for `flatten`. */
@@ -766,7 +779,7 @@ class Ie extends R {
766
779
  }
767
780
  /** Values every `{{token}}` on this page resolves against. */
768
781
  tokenContext() {
769
- const t = /* @__PURE__ */ new Map(), e = Fe(this);
782
+ const t = /* @__PURE__ */ new Map(), e = Le(this);
770
783
  for (const s of e) {
771
784
  const o = s.georef, a = o?.groundMetersPerMm() ?? 0;
772
785
  t.set(s.id, {
@@ -774,7 +787,7 @@ class Ie extends R {
774
787
  crs: o?.crs
775
788
  });
776
789
  }
777
- const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (s) => Pe(this.getAttribute(s) ?? "", n).text;
790
+ const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (s) => Ne(this.getAttribute(s) ?? "", n).text;
778
791
  return {
779
792
  page: {
780
793
  title: i("title"),
@@ -797,8 +810,8 @@ class Ie extends R {
797
810
  renderNow() {
798
811
  const { widthMm: t, heightMm: e } = this.pageSize, n = this.bleedMm;
799
812
  this.style.display = "block", this.style.position = "relative", this.style.width = `${t}mm`, this.style.height = `${e}mm`, this.style.margin = n > 0 ? `${n}mm` : "", this.style.overflow = n > 0 ? "visible" : "hidden";
800
- let i = this.querySelector(`style[${Zt}]`);
801
- i || (i = document.createElement("style"), i.setAttribute(Zt, ""), this.prepend(i));
813
+ let i = this.querySelector(`style[${Jt}]`);
814
+ i || (i = document.createElement("style"), i.setAttribute(Jt, ""), this.prepend(i));
802
815
  const s = t + n * 2, o = e + n * 2;
803
816
  i.textContent = `@page { size: ${s}mm ${o}mm; margin: 0; }
804
817
  @media print { html, body { margin: 0; padding: 0; } om-cartograph { break-after: page; } }`, this.renderPrintMarks(t, e, n), this.applyCvd(), this.refreshTokens(), this.renderCredit();
@@ -813,26 +826,26 @@ class Ie extends R {
813
826
  * worse than no guide.
814
827
  */
815
828
  renderPrintMarks(t, e, n) {
816
- const i = this.hasAttribute("crop-marks") && n > 0, s = Number(this.getAttribute("safe-zone")), o = Number.isFinite(s) && s > 0, a = this.querySelector(`:scope > [${Qt}]`);
829
+ const i = this.hasAttribute("crop-marks") && n > 0, s = Number(this.getAttribute("safe-zone")), o = Number.isFinite(s) && s > 0, a = this.querySelector(`:scope > [${Zt}]`);
817
830
  if (!i && !o) {
818
831
  a?.remove();
819
832
  return;
820
833
  }
821
- const l = this.ownerDocument, c = a ?? l.createElementNS(At, "svg");
822
- if (c.setAttribute(Qt, ""), c.setAttribute("viewBox", `${-n} ${-n} ${t + n * 2} ${e + n * 2}`), c.setAttribute("width", `${t + n * 2}mm`), c.setAttribute("height", `${e + n * 2}mm`), c.style.cssText = `position:absolute;left:${-n}mm;top:${-n}mm;pointer-events:none;z-index:2147483646;`, c.replaceChildren(), i) {
834
+ const l = this.ownerDocument, c = a ?? l.createElementNS(Mt, "svg");
835
+ if (c.setAttribute(Zt, ""), c.setAttribute("viewBox", `${-n} ${-n} ${t + n * 2} ${e + n * 2}`), c.setAttribute("width", `${t + n * 2}mm`), c.setAttribute("height", `${e + n * 2}mm`), c.style.cssText = `position:absolute;left:${-n}mm;top:${-n}mm;pointer-events:none;z-index:2147483646;`, c.replaceChildren(), i) {
823
836
  const u = Math.min(n, 4), h = Math.min(n * 0.35, 1.5), d = [];
824
837
  for (const m of [0, t])
825
838
  for (const f of [0, e]) {
826
- const p = m === 0 ? -1 : 1, g = f === 0 ? -1 : 1;
827
- d.push([m + p * h, f, m + p * (h + u), f]), d.push([m, f + g * h, m, f + g * (h + u)]);
839
+ const g = m === 0 ? -1 : 1, p = f === 0 ? -1 : 1;
840
+ d.push([m + g * h, f, m + g * (h + u), f]), d.push([m, f + p * h, m, f + p * (h + u)]);
828
841
  }
829
- for (const [m, f, p, g] of d) {
830
- const b = l.createElementNS(At, "line");
831
- b.setAttribute("x1", String(m)), b.setAttribute("y1", String(f)), b.setAttribute("x2", String(p)), b.setAttribute("y2", String(g)), b.setAttribute("stroke", "#000"), b.setAttribute("stroke-width", "0.15"), c.appendChild(b);
842
+ for (const [m, f, g, p] of d) {
843
+ const b = l.createElementNS(Mt, "line");
844
+ b.setAttribute("x1", String(m)), b.setAttribute("y1", String(f)), b.setAttribute("x2", String(g)), b.setAttribute("y2", String(p)), b.setAttribute("stroke", "#000"), b.setAttribute("stroke-width", "0.15"), c.appendChild(b);
832
845
  }
833
846
  }
834
847
  if (o) {
835
- const u = l.createElementNS(At, "rect");
848
+ const u = l.createElementNS(Mt, "rect");
836
849
  u.setAttribute("x", String(s)), u.setAttribute("y", String(s)), u.setAttribute("width", String(Math.max(0, t - s * 2))), u.setAttribute("height", String(Math.max(0, e - s * 2))), u.setAttribute("fill", "none"), u.setAttribute("stroke", "#22aaff"), u.setAttribute("stroke-width", "0.2"), u.setAttribute("stroke-dasharray", "2 1.5"), u.setAttribute("data-om-carto-screen-only", ""), c.appendChild(u);
837
850
  }
838
851
  a || this.appendChild(c);
@@ -846,16 +859,16 @@ class Ie extends R {
846
859
  * injected only when a page actually asks for one.
847
860
  */
848
861
  applyCvd() {
849
- const t = Rt(this.getAttribute("cvd"));
862
+ const t = It(this.getAttribute("cvd"));
850
863
  if (!t) {
851
864
  this.style.removeProperty("filter");
852
865
  return;
853
866
  }
854
- lr(this.ownerDocument), this.style.filter = `url(#${Ae(t)})`;
867
+ lr(this.ownerDocument), this.style.filter = `url(#${Me(t)})`;
855
868
  }
856
869
  }
857
870
  x("om-cartograph", Ie);
858
- function Fr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
871
+ function Ir({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
859
872
  const s = n > 0 ? n : e * 1.2, o = [];
860
873
  for (const c of r.split(/\r?\n/)) {
861
874
  const u = c.split(/\s+/).filter((m) => m !== "");
@@ -866,9 +879,9 @@ function Fr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
866
879
  const h = (m) => {
867
880
  let f = m;
868
881
  for (; i(f) > t && f.length > 1; ) {
869
- let p = f.length - 1;
870
- for (; p > 1 && i(f.slice(0, p)) > t; ) p--;
871
- o.push({ text: f.slice(0, p), baselineY: 0, width: i(f.slice(0, p)) }), f = f.slice(p);
882
+ let g = f.length - 1;
883
+ for (; g > 1 && i(f.slice(0, g)) > t; ) g--;
884
+ o.push({ text: f.slice(0, g), baselineY: 0, width: i(f.slice(0, g)) }), f = f.slice(g);
872
885
  }
873
886
  return f;
874
887
  };
@@ -885,12 +898,12 @@ function Fr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
885
898
  c.baselineY = a + u * s, c.width > l && (l = c.width);
886
899
  }), { lines: o, lineHeight: s, maxWidth: l };
887
900
  }
888
- function Hn(r) {
901
+ function Kn(r) {
889
902
  if (typeof document > "u") return null;
890
903
  const e = document.createElement("canvas").getContext("2d");
891
904
  return e ? (e.font = r, (n) => e.measureText(n).width) : null;
892
905
  }
893
- function Ir(r, t, e) {
906
+ function Rr(r, t, e) {
894
907
  return r === "center" ? (t - e) / 2 : r === "end" || r === "right" ? t - e : 0;
895
908
  }
896
909
  class Re extends R {
@@ -922,45 +935,45 @@ class Re extends R {
922
935
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
923
936
  const c = (this.textContent ?? "").trim();
924
937
  if (c === "") return;
925
- const u = Et(a?.fontSize, 12), h = a?.lineHeight === "normal" ? u * 1.4 : Et(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", m = a?.fontWeight || "400", f = u * e.scale, p = h * e.scale, g = `${m} ${f}px ${d}`;
926
- t.save(), t.font = g, t.fillStyle = F(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
927
- const b = Fr({
938
+ const u = $t(a?.fontSize, 12), h = a?.lineHeight === "normal" ? u * 1.4 : $t(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", m = a?.fontWeight || "400", f = u * e.scale, g = h * e.scale, p = `${m} ${f}px ${d}`;
939
+ t.save(), t.font = p, t.fillStyle = F(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
940
+ const b = Ir({
928
941
  text: c,
929
942
  maxWidth: s,
930
943
  fontSizePx: f,
931
- lineHeightPx: p,
944
+ lineHeightPx: g,
932
945
  measure: (y) => t.measureText(y).width
933
946
  }), w = a?.textAlign || "start";
934
947
  for (const y of b.lines) {
935
- if (y.baselineY > o + p) break;
936
- t.fillText(y.text, Ir(w, s, y.width), y.baselineY);
948
+ if (y.baselineY > o + g) break;
949
+ t.fillText(y.text, Rr(w, s, y.width), y.baselineY);
937
950
  }
938
951
  t.restore();
939
952
  }
940
953
  }
941
954
  x("om-text", Re);
942
- const Rr = 63710087714e-4;
943
- let Or = Rr;
955
+ const Or = 63710087714e-4;
956
+ let _r = Or;
944
957
  const nt = Math.PI / 180;
945
- function _r(r, t, e = Or) {
958
+ function Ur(r, t, e = _r) {
946
959
  const n = (t[1] - r[1]) * nt, i = (t[0] - r[0]) * nt, s = r[1] * nt, o = t[1] * nt, a = Math.sin(n / 2) ** 2 + Math.cos(s) * Math.cos(o) * Math.sin(i / 2) ** 2;
947
960
  return 2 * e * Math.asin(Math.min(1, Math.sqrt(a)));
948
961
  }
949
- const K = 6378137, ht = Math.PI / 180, Pt = 180 / Math.PI, ie = 85.0511287798066;
950
- function Ur([r, t]) {
951
- const e = Math.max(-ie, Math.min(ie, t));
962
+ const K = 6378137, ht = Math.PI / 180, Nt = 180 / Math.PI, ne = 85.0511287798066;
963
+ function zr([r, t]) {
964
+ const e = Math.max(-ne, Math.min(ne, t));
952
965
  return [K * r * ht, K * Math.log(Math.tan(Math.PI / 4 + e * ht / 2))];
953
966
  }
954
- const oe = 89.9;
955
- function zr([r, t]) {
956
- const e = Math.max(-oe, Math.min(oe, t));
967
+ const ie = 89.9;
968
+ function Dr([r, t]) {
969
+ const e = Math.max(-ie, Math.min(ie, t));
957
970
  return [K * r * ht, K * Math.log(Math.tan(Math.PI / 4 + e * ht / 2))];
958
971
  }
959
- const Dr = { code: "EPSG:3857", forward: zr, inverse: Oe };
972
+ const jr = { code: "EPSG:3857", forward: Dr, inverse: Oe };
960
973
  function Oe([r, t]) {
961
- return [r / K * Pt, (2 * Math.atan(Math.exp(t / K)) - Math.PI / 2) * Pt];
974
+ return [r / K * Nt, (2 * Math.atan(Math.exp(t / K)) - Math.PI / 2) * Nt];
962
975
  }
963
- const _e = { code: "EPSG:3857", forward: Ur, inverse: Oe }, jr = { code: "EPSG:4326", forward: ([r, t]) => [r, t], inverse: ([r, t]) => [r, t] };
976
+ const _e = { code: "EPSG:3857", forward: zr, inverse: Oe }, Gr = { code: "EPSG:4326", forward: ([r, t]) => [r, t], inverse: ([r, t]) => [r, t] };
964
977
  function Y(r) {
965
978
  if (r == null) return null;
966
979
  const t = r.trim();
@@ -970,12 +983,12 @@ function Y(r) {
970
983
  }
971
984
  function X(r) {
972
985
  const t = Y(r) ?? "EPSG:3857";
973
- return t === "EPSG:3857" || t === "EPSG:900913" ? _e : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? jr : null;
986
+ return t === "EPSG:3857" || t === "EPSG:900913" ? _e : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? Gr : null;
974
987
  }
975
988
  async function Ue(r, t) {
976
989
  const e = X(r);
977
990
  if (e && !t) return e;
978
- const n = Y(r) ?? "EPSG:3857", i = t?.trim() || await Gr(n);
991
+ const n = Y(r) ?? "EPSG:3857", i = t?.trim() || await qr(n);
979
992
  if (!i) return null;
980
993
  const s = (await import("./index-CcLC9jE5.js")).default, a = s(i, "+proj=longlat +datum=WGS84 +no_defs");
981
994
  return {
@@ -984,18 +997,18 @@ async function Ue(r, t) {
984
997
  inverse: (l) => a.forward(l)
985
998
  };
986
999
  }
987
- function se(r, t) {
1000
+ function oe(r, t) {
988
1001
  return !Number.isInteger(r) || r < 1 || r > 60 ? null : `+proj=utm +zone=${r}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
989
1002
  }
990
- async function Gr(r) {
1003
+ async function qr(r) {
991
1004
  const t = Number(/^EPSG:(\d+)$/.exec(r)?.[1]);
992
1005
  if (!Number.isFinite(t)) return null;
993
- if (t >= 32601 && t <= 32660) return se(t - 32600, "N");
994
- if (t >= 32701 && t <= 32760) return se(t - 32700, "S");
1006
+ if (t >= 32601 && t <= 32660) return oe(t - 32600, "N");
1007
+ if (t >= 32701 && t <= 32760) return oe(t - 32700, "S");
995
1008
  const { CRS_DEFS: e } = await import("./crs-DsDQ4Q4i.js");
996
1009
  return e[t]?.def ?? null;
997
1010
  }
998
- function qr(r, t) {
1011
+ function Wr(r, t) {
999
1012
  const e = t.length, n = r.map((i, s) => [...i, t[s]]);
1000
1013
  for (let i = 0; i < e; i++) {
1001
1014
  let s = i;
@@ -1011,23 +1024,23 @@ function qr(r, t) {
1011
1024
  }
1012
1025
  return n.map((i, s) => i[e] / i[s]);
1013
1026
  }
1014
- function Wr(r, t) {
1027
+ function Br(r, t) {
1015
1028
  if (r.length !== 4 || t.length !== 4) return null;
1016
1029
  const e = r.reduce((h, d) => h + d[0], 0) / 4, n = r.reduce((h, d) => h + d[1], 0) / 4, i = r.reduce((h, d) => h + Math.hypot(d[0] - e, d[1] - n), 0) / 4, s = i > 1e-12 ? Math.SQRT2 / i : 1, o = (h) => [(h[0] - e) * s, (h[1] - n) * s], a = [], l = [];
1017
1030
  for (let h = 0; h < 4; h++) {
1018
- const [d, m] = o(r[h]), [f, p] = t[h];
1019
- a.push([d, m, 1, 0, 0, 0, -d * f, -m * f]), l.push(f), a.push([0, 0, 0, d, m, 1, -d * p, -m * p]), l.push(p);
1031
+ const [d, m] = o(r[h]), [f, g] = t[h];
1032
+ a.push([d, m, 1, 0, 0, 0, -d * f, -m * f]), l.push(f), a.push([0, 0, 0, d, m, 1, -d * g, -m * g]), l.push(g);
1020
1033
  }
1021
- const c = qr(a, l);
1034
+ const c = Wr(a, l);
1022
1035
  if (!c || c.some((h) => !Number.isFinite(h))) return null;
1023
1036
  const u = (h) => [h[0] / s + e, h[1] / s + n];
1024
1037
  return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: o, denormalize: u };
1025
1038
  }
1026
- function ae(r, [t, e]) {
1039
+ function se(r, [t, e]) {
1027
1040
  const n = r[6] * t + r[7] * e + r[8];
1028
1041
  return Math.abs(n) < 1e-12 ? null : [(r[0] * t + r[1] * e + r[2]) / n, (r[3] * t + r[4] * e + r[5]) / n];
1029
1042
  }
1030
- function Br(r) {
1043
+ function Vr(r) {
1031
1044
  const [t, e, n, i, s, o, a, l, c] = r, u = t * (s * c - o * l) - e * (i * c - o * a) + n * (i * l - s * a);
1032
1045
  return !Number.isFinite(u) || Math.abs(u) < 1e-15 ? null : [
1033
1046
  (s * c - o * l) / u,
@@ -1041,7 +1054,7 @@ function Br(r) {
1041
1054
  (t * s - e * i) / u
1042
1055
  ];
1043
1056
  }
1044
- function Vr(r, t) {
1057
+ function Hr(r, t) {
1045
1058
  let e = r;
1046
1059
  for (; e - t > 180; ) e -= 360;
1047
1060
  for (; t - e > 180; ) e += 360;
@@ -1052,21 +1065,21 @@ const ze = (r) => {
1052
1065
  return t === -180 && (t = 180), t;
1053
1066
  };
1054
1067
  function mt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i = !1 }) {
1055
- const s = n ?? (i ? Dr : _e), o = r[0][0], a = (b) => i ? b : Vr(b, o), l = (b) => i ? b : ze(b), c = r.map(([b, w]) => [a(b), w]), u = c.map((b) => s.forward(b)), h = [
1068
+ const s = n ?? (i ? jr : _e), o = r[0][0], a = (b) => i ? b : Hr(b, o), l = (b) => i ? b : ze(b), c = r.map(([b, w]) => [a(b), w]), u = c.map((b) => s.forward(b)), h = [
1056
1069
  [0, 0],
1057
1070
  [t, 0],
1058
1071
  [t, e],
1059
1072
  [0, e]
1060
- ], d = t > 0 && e > 0 ? Wr(u, h) : null, m = d ? Br(d.matrix) : null, f = !d || !m, p = (b, w = i ? 16 : 1) => {
1061
- let y = 0, M = g.unproject(0, b);
1073
+ ], d = t > 0 && e > 0 ? Br(u, h) : null, m = d ? Vr(d.matrix) : null, f = !d || !m, g = (b, w = i ? 16 : 1) => {
1074
+ let y = 0, M = p.unproject(0, b);
1062
1075
  if (!M) return null;
1063
1076
  for (let v = 1; v <= w; v++) {
1064
- const N = g.unproject(t * v / w, b);
1077
+ const N = p.unproject(t * v / w, b);
1065
1078
  if (!N) return null;
1066
- y += _r(M, N), M = N;
1079
+ y += Ur(M, N), M = N;
1067
1080
  }
1068
1081
  return y;
1069
- }, g = {
1082
+ }, p = {
1070
1083
  crs: s.code,
1071
1084
  corners: c,
1072
1085
  widthMm: t,
@@ -1075,24 +1088,24 @@ function mt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i
1075
1088
  continuous: i,
1076
1089
  project(b) {
1077
1090
  if (!d) return null;
1078
- const w = s.forward([a(b[0]), b[1]]), y = ae(d.matrix, d.normalize(w));
1091
+ const w = s.forward([a(b[0]), b[1]]), y = se(d.matrix, d.normalize(w));
1079
1092
  return y && Number.isFinite(y[0]) && Number.isFinite(y[1]) ? { xMm: y[0], yMm: y[1] } : null;
1080
1093
  },
1081
1094
  unproject(b, w) {
1082
1095
  if (!d || !m) return null;
1083
- const y = ae(m, [b, w]);
1096
+ const y = se(m, [b, w]);
1084
1097
  if (!y) return null;
1085
1098
  const M = s.inverse(d.denormalize(y));
1086
1099
  return Number.isFinite(M[0]) && Number.isFinite(M[1]) ? [l(M[0]), M[1]] : null;
1087
1100
  },
1088
1101
  groundMetersPerMm() {
1089
1102
  if (f || t <= 0) return 0;
1090
- const b = p(e / 2);
1103
+ const b = g(e / 2);
1091
1104
  return b == null ? 0 : b / t;
1092
1105
  },
1093
- rowGroundMeters: p
1106
+ rowGroundMeters: g
1094
1107
  };
1095
- return g;
1108
+ return p;
1096
1109
  }
1097
1110
  function dt(r) {
1098
1111
  if (r == null || r.trim() === "") return null;
@@ -1129,16 +1142,16 @@ function dt(r) {
1129
1142
  }
1130
1143
  return e;
1131
1144
  }
1132
- function Hr(r) {
1145
+ function Kr(r) {
1133
1146
  if (r.degenerate) return null;
1134
1147
  const t = r.unproject(r.widthMm / 2, r.heightMm / 2);
1135
1148
  if (!t) return null;
1136
1149
  const n = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = r.project(t), s = r.project(n);
1137
1150
  if (!i || !s) return null;
1138
1151
  const o = s.xMm - i.xMm, a = s.yMm - i.yMm;
1139
- return Math.abs(o) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(o, -a) * Pt % 360 + 360) % 360;
1152
+ return Math.abs(o) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(o, -a) * Nt % 360 + 360) % 360;
1140
1153
  }
1141
- function Kr(r) {
1154
+ function Yr(r) {
1142
1155
  if (r.degenerate) return null;
1143
1156
  const { widthMm: t, heightMm: e } = r, n = [];
1144
1157
  for (const o of [0.02, 0.5, 0.98]) {
@@ -1149,7 +1162,7 @@ function Kr(r) {
1149
1162
  const i = Math.min(...n), s = Math.max(...n);
1150
1163
  return i > 0 ? (s - i) / i : null;
1151
1164
  }
1152
- function Kn(r, t, e, n) {
1165
+ function Yn(r, t, e, n) {
1153
1166
  return [
1154
1167
  [r, n],
1155
1168
  [e, n],
@@ -1157,8 +1170,8 @@ function Kn(r, t, e, n) {
1157
1170
  [r, t]
1158
1171
  ];
1159
1172
  }
1160
- const Yr = (r) => r.toLowerCase().startsWith("on");
1161
- function Xr(r, t) {
1173
+ const Xr = (r) => r.toLowerCase().startsWith("on");
1174
+ function Jr(r, t) {
1162
1175
  const e = (n) => {
1163
1176
  const i = n.tagName.toLowerCase();
1164
1177
  if (i === "script") {
@@ -1169,7 +1182,7 @@ function Xr(r, t) {
1169
1182
  if (i === "style" || i === "link" || i === "iframe" || i === "object" || i === "embed") return null;
1170
1183
  const s = t.createElement(i);
1171
1184
  for (const o of n.attributes)
1172
- Yr(o.name) || /^\s*javascript:/i.test(o.value) || s.setAttribute(o.name, o.value);
1185
+ Xr(o.name) || /^\s*javascript:/i.test(o.value) || s.setAttribute(o.name, o.value);
1173
1186
  for (const o of n.childNodes)
1174
1187
  if (o.nodeType === 3) s.appendChild(t.createTextNode(o.textContent ?? ""));
1175
1188
  else if (o.nodeType === 1) {
@@ -1180,12 +1193,12 @@ function Xr(r, t) {
1180
1193
  };
1181
1194
  return e(r);
1182
1195
  }
1183
- async function Jr(r, t = document) {
1196
+ async function Zr(r, t = document) {
1184
1197
  const e = await fetch(r, { credentials: "same-origin" });
1185
1198
  if (!e.ok) throw new Error(`fetching ${r} failed with HTTP ${e.status}`);
1186
1199
  const n = await e.text(), s = new DOMParser().parseFromString(n, "text/html").querySelector("om-map");
1187
1200
  if (!s) throw new Error(`${r} contains no <om-map>`);
1188
- const o = Xr(s, t);
1201
+ const o = Jr(s, t);
1189
1202
  if (!o) throw new Error(`${r} could not be adopted`);
1190
1203
  return o;
1191
1204
  }
@@ -1210,8 +1223,8 @@ function ct(r) {
1210
1223
  pitch: Number(r.getAttribute("pitch")) || 0
1211
1224
  };
1212
1225
  }
1213
- function Yn(r, t, e, n, i = 60) {
1214
- const s = (l) => Tt(r, { ...t, pitch: l }, e, n) !== null;
1226
+ function Xn(r, t, e, n, i = 60) {
1227
+ const s = (l) => Pt(r, { ...t, pitch: l }, e, n) !== null;
1215
1228
  if (s(i)) return i;
1216
1229
  if (!s(0)) return 0;
1217
1230
  let o = 0, a = i;
@@ -1221,7 +1234,7 @@ function Yn(r, t, e, n, i = 60) {
1221
1234
  }
1222
1235
  return o;
1223
1236
  }
1224
- function Tt(r, t, e, n) {
1237
+ function Pt(r, t, e, n) {
1225
1238
  if (!(e > 0) || !(n > 0)) return null;
1226
1239
  const i = new r.WebMercatorViewport({
1227
1240
  width: e,
@@ -1244,22 +1257,22 @@ function Tt(r, t, e, n) {
1244
1257
  }
1245
1258
  return o;
1246
1259
  }
1247
- async function Zr(r) {
1248
- const t = await ve(), e = r.querySelector(":scope > om-map");
1260
+ async function Qr(r) {
1261
+ const t = await we(), e = r.querySelector(":scope > om-map");
1249
1262
  if (e) return { core: t, map: e };
1250
1263
  const n = r.getAttribute("src");
1251
1264
  if (!n) throw new Error("a live frame needs src= or an inline <om-map> child");
1252
- const i = await Jr(n, r.ownerDocument);
1265
+ const i = await Zr(n, r.ownerDocument);
1253
1266
  return { core: t, map: i };
1254
1267
  }
1255
- function St(r, t) {
1256
- r.setAttribute("center", JSON.stringify(t.center)), r.setAttribute("zoom", String(t.zoom)), r.setAttribute("bearing", String(t.bearing)), r.setAttribute("pitch", String(t.pitch)), Qr(r, t);
1268
+ function At(r, t) {
1269
+ r.setAttribute("center", JSON.stringify(t.center)), r.setAttribute("zoom", String(t.zoom)), r.setAttribute("bearing", String(t.bearing)), r.setAttribute("pitch", String(t.pitch)), tn(r, t);
1257
1270
  }
1258
- function Qr(r, t) {
1271
+ function tn(r, t) {
1259
1272
  const e = r;
1260
1273
  typeof e.setViewInternal == "function" ? e.setViewInternal({ longitude: t.center[0], latitude: t.center[1], zoom: t.zoom, pitch: t.pitch, bearing: t.bearing }) : typeof e.flyTo == "function" && e.flyTo(t.center, t.zoom, { duration: 0 });
1261
1274
  }
1262
- const Ct = "data-om-carto-placeholder", xt = "data-om-carto-overview", le = "http://www.w3.org/2000/svg", ce = 24, ue = 0.25;
1275
+ const St = "data-om-carto-placeholder", Ct = "data-om-carto-overview", ae = "http://www.w3.org/2000/svg", le = 24, ce = 0.25;
1263
1276
  class De extends R {
1264
1277
  static observedAttributes = [...T["om-frame"]];
1265
1278
  /** Resolved non-builtin CRS planes, so a re-render does not re-await proj4. */
@@ -1342,7 +1355,7 @@ class De extends R {
1342
1355
  renderNow() {
1343
1356
  this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden", this.style.boxSizing = "border-box";
1344
1357
  const t = this.getAttribute("frame-stroke");
1345
- this.style.border = "0", this.style.boxShadow = `inset 0 0 0 ${ue}mm ${t || "var(--om-carto-frame-stroke)"}`;
1358
+ this.style.border = "0", this.style.boxShadow = `inset 0 0 0 ${ce}mm ${t || "var(--om-carto-frame-stroke)"}`;
1346
1359
  const e = this.getAttribute("frame-bg");
1347
1360
  this.style.background = e || "var(--om-carto-frame-bg)", this.mode === "static" ? (this.suspendLiveMode(), this.renderStatic()) : this.renderLive(), this.renderOverview();
1348
1361
  }
@@ -1396,7 +1409,7 @@ class De extends R {
1396
1409
  if (this.mountedSource !== s)
1397
1410
  this.releaseLiveMap();
1398
1411
  else {
1399
- St(this.liveMap, e), this.sizeLiveMap();
1412
+ At(this.liveMap, e), this.sizeLiveMap();
1400
1413
  return;
1401
1414
  }
1402
1415
  if (this.mounting) {
@@ -1438,22 +1451,22 @@ class De extends R {
1438
1451
  if (!t) return;
1439
1452
  const e = H();
1440
1453
  if (!e) return;
1441
- const { w: n, h: i } = C(this), s = Tt(e, t, n * W, i * W), o = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
1454
+ const { w: n, h: i } = C(this), s = Pt(e, t, n * W, i * W), o = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
1442
1455
  this.liveCorners = s, o && this.liveMap && this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } })), s ? this.lastError === "degenerate-view" && this.clearPlaceholder() : this.showPlaceholder("degenerate-view", "This frame's box cannot be georeferenced — give it a positive width and height.");
1443
1456
  }
1444
1457
  async mountLive(t) {
1445
1458
  const e = ++this.mountToken;
1446
1459
  this.mounting = !0, this.mountingSource = t;
1447
1460
  try {
1448
- const { core: n, map: i } = await Zr(this);
1461
+ const { core: n, map: i } = await Qr(this);
1449
1462
  if (e !== this.mountToken || !this.isConnected || this.mode !== "live" || this.liveSource() !== t) return;
1450
1463
  const s = ct(this);
1451
1464
  if (!s) return;
1452
- this.appliedCameraKey = JSON.stringify(s), St(i, s);
1465
+ this.appliedCameraKey = JSON.stringify(s), At(i, s);
1453
1466
  const o = i;
1454
1467
  o.style.position = "absolute", o.style.inset = "0", o.style.display = "block", this.liveMapOwned = i.parentElement !== this, this.liveMapOwned && this.appendChild(i), i.setAttribute("data-om-carto-frame", ""), this.liveMap = o, o.addEventListener("om-view-changed", this.onLiveViewSettled), this.mountedSource = t, this.sizeLiveMap(), this.clearPlaceholder();
1455
1468
  const { w: a, h: l } = C(this);
1456
- if (this.liveCorners = Tt(n, s, a * W, l * W), await o.ready, e !== this.mountToken || (St(i, s), await o.whenSettled?.({ timeout: 2e4 }), e !== this.mountToken)) return;
1469
+ if (this.liveCorners = Pt(n, s, a * W, l * W), await o.ready, e !== this.mountToken || (At(i, s), await o.whenSettled?.({ timeout: 2e4 }), e !== this.mountToken)) return;
1457
1470
  this.signalReady();
1458
1471
  } catch (n) {
1459
1472
  if (e !== this.mountToken) return;
@@ -1485,12 +1498,12 @@ class De extends R {
1485
1498
  * segments would visibly cut the corners on a wide-extent inset.
1486
1499
  */
1487
1500
  renderOverview() {
1488
- const t = this.getAttribute("overview-of"), e = this.querySelector(`:scope > [${xt}]`);
1501
+ const t = this.getAttribute("overview-of"), e = this.querySelector(`:scope > [${Ct}]`);
1489
1502
  if (!t) {
1490
1503
  e?.remove();
1491
1504
  return;
1492
1505
  }
1493
- const n = Le(this, t), i = this.georef, s = n?.georef;
1506
+ const n = Te(this, t), i = this.georef, s = n?.georef;
1494
1507
  if (!n || !i || !s) {
1495
1508
  e?.remove();
1496
1509
  return;
@@ -1502,18 +1515,18 @@ class De extends R {
1502
1515
  [d, c]
1503
1516
  ];
1504
1517
  for (const [b, w] of m)
1505
- for (let y = 0; y < ce; y++) {
1506
- const M = y / ce, v = [b[0] + (w[0] - b[0]) * M, b[1] + (w[1] - b[1]) * M], N = i.project(v);
1518
+ for (let y = 0; y < le; y++) {
1519
+ const M = y / le, v = [b[0] + (w[0] - b[0]) * M, b[1] + (w[1] - b[1]) * M], N = i.project(v);
1507
1520
  N && l.push(`${N.xMm.toFixed(3)},${N.yMm.toFixed(3)}`);
1508
1521
  }
1509
1522
  if (l.length < 3) {
1510
1523
  e?.remove();
1511
1524
  return;
1512
1525
  }
1513
- const f = this.ownerDocument, p = e ?? f.createElementNS(le, "svg");
1514
- p.setAttribute(xt, ""), p.setAttribute("width", `${o}mm`), p.setAttribute("height", `${a}mm`), p.setAttribute("viewBox", `0 0 ${o} ${a}`), p.style.cssText = "position:absolute;inset:0;pointer-events:none;", p.replaceChildren();
1515
- const g = f.createElementNS(le, "polygon");
1516
- g.setAttribute("points", l.join(" ")), g.setAttribute("fill", "none"), g.setAttribute("stroke", this.getAttribute("overview-stroke") || "#e63946"), g.setAttribute("stroke-width", "0.4"), p.appendChild(g), e || this.appendChild(p);
1526
+ const f = this.ownerDocument, g = e ?? f.createElementNS(ae, "svg");
1527
+ g.setAttribute(Ct, ""), g.setAttribute("width", `${o}mm`), g.setAttribute("height", `${a}mm`), g.setAttribute("viewBox", `0 0 ${o} ${a}`), g.style.cssText = "position:absolute;inset:0;pointer-events:none;", g.replaceChildren();
1528
+ const p = f.createElementNS(ae, "polygon");
1529
+ p.setAttribute("points", l.join(" ")), p.setAttribute("fill", "none"), p.setAttribute("stroke", this.getAttribute("overview-stroke") || "#e63946"), p.setAttribute("stroke-width", "0.4"), g.appendChild(p), e || this.appendChild(g);
1517
1530
  }
1518
1531
  // -------------------------------------------------------------------------
1519
1532
  // Readiness and errors
@@ -1533,11 +1546,11 @@ class De extends R {
1533
1546
  * the worst outcome — it looks like a design choice.
1534
1547
  */
1535
1548
  showPlaceholder(t, e) {
1536
- let n = this.querySelector(`:scope > [${Ct}]`);
1537
- n || (n = document.createElement("div"), n.setAttribute(Ct, ""), n.style.cssText = "position:absolute;inset:0;display:grid;place-content:center;padding:4mm;text-align:center;font:italic 3mm/1.4 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.75;", this.appendChild(n)), n.textContent !== e && (n.textContent = e), this.lastError !== t && (this.lastError = t, this.settleReady(), this.dispatchEvent(new CustomEvent("om-frame-error", { bubbles: !0, detail: { id: this.id, reason: t, message: e } })));
1549
+ let n = this.querySelector(`:scope > [${St}]`);
1550
+ n || (n = document.createElement("div"), n.setAttribute(St, ""), n.style.cssText = "position:absolute;inset:0;display:grid;place-content:center;padding:4mm;text-align:center;font:italic 3mm/1.4 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.75;", this.appendChild(n)), n.textContent !== e && (n.textContent = e), this.lastError !== t && (this.lastError = t, this.settleReady(), this.dispatchEvent(new CustomEvent("om-frame-error", { bubbles: !0, detail: { id: this.id, reason: t, message: e } })));
1538
1551
  }
1539
1552
  clearPlaceholder() {
1540
- this.querySelector(`:scope > [${Ct}]`)?.remove(), this.lastError = null;
1553
+ this.querySelector(`:scope > [${St}]`)?.remove(), this.lastError = null;
1541
1554
  }
1542
1555
  // -------------------------------------------------------------------------
1543
1556
  // Capture, export and print
@@ -1600,11 +1613,11 @@ class De extends R {
1600
1613
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
1601
1614
  const c = this.mode === "static" ? this.raster : this.captureImage;
1602
1615
  c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, s, o), this.paintOverview(t, e);
1603
- const u = this.getAttribute("frame-stroke") || F(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", h = ue * e.pxPerMm;
1616
+ const u = this.getAttribute("frame-stroke") || F(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", h = ce * e.pxPerMm;
1604
1617
  h > 0 && (t.strokeStyle = u, t.lineWidth = h, t.strokeRect(h / 2, h / 2, s - h, o - h));
1605
1618
  }
1606
1619
  paintOverview(t, e) {
1607
- const n = this.querySelector(`:scope > [${xt}] polygon`), i = n?.getAttribute("points");
1620
+ const n = this.querySelector(`:scope > [${Ct}] polygon`), i = n?.getAttribute("points");
1608
1621
  i && (t.save(), t.strokeStyle = n.getAttribute("stroke") || "#e63946", t.lineWidth = Number(n.getAttribute("stroke-width") || 0.4) * e.pxPerMm, t.beginPath(), i.split(/\s+/).forEach((s, o) => {
1609
1622
  const [a, l] = s.split(",").map(Number);
1610
1623
  !Number.isFinite(a) || !Number.isFinite(l) || (o === 0 ? t.moveTo(a * e.pxPerMm, l * e.pxPerMm) : t.lineTo(a * e.pxPerMm, l * e.pxPerMm));
@@ -1612,14 +1625,14 @@ class De extends R {
1612
1625
  }
1613
1626
  }
1614
1627
  x("om-frame", De);
1615
- const it = "http://www.w3.org/2000/svg", tn = ["single", "double", "line", "ticks"];
1628
+ const it = "http://www.w3.org/2000/svg", en = ["single", "double", "line", "ticks"];
1616
1629
  class je extends R {
1617
1630
  static observedAttributes = [...T["om-scalebar"]];
1618
1631
  /** The geometry currently drawn — reused by the canvas exporter. */
1619
1632
  get drawing() {
1620
1633
  const e = _(this)?.georef;
1621
1634
  if (!e) return null;
1622
- const { w: n, h: i } = C(this), s = Ee({
1635
+ const { w: n, h: i } = C(this), s = $e({
1623
1636
  groundMetersPerMm: e.groundMetersPerMm(),
1624
1637
  maxWidthMm: n,
1625
1638
  segments: Number(this.getAttribute("segments")) || void 0,
@@ -1630,7 +1643,7 @@ class je extends R {
1630
1643
  }
1631
1644
  get barStyle() {
1632
1645
  const t = this.getAttribute("kind");
1633
- return tn.includes(t) ? t : "single";
1646
+ return en.includes(t) ? t : "single";
1634
1647
  }
1635
1648
  get unitSystem() {
1636
1649
  return Ar(this.getAttribute("units")) ?? "metric";
@@ -1690,7 +1703,7 @@ class Ge extends R {
1690
1703
  /** Degrees clockwise from the page's "up", or null when unknowable. */
1691
1704
  get bearing() {
1692
1705
  const t = _(this)?.georef;
1693
- return t ? Hr(t) : null;
1706
+ return t ? Kr(t) : null;
1694
1707
  }
1695
1708
  get indicatorKind() {
1696
1709
  return this.getAttribute("kind") === "rose" ? "rose" : "arrow";
@@ -1716,8 +1729,8 @@ class Ge extends R {
1716
1729
  buildGeometry(t, e, n) {
1717
1730
  const i = "var(--om-carto-compass-ink)", s = [], o = e / 2, a = Math.min(3, n * 0.24), l = n - a * 1.2;
1718
1731
  if (this.indicatorKind === "rose") {
1719
- const f = Math.min(e, l) / 2, p = t.createElementNS(Q, "circle");
1720
- p.setAttribute("cx", String(o)), p.setAttribute("cy", String(l / 2)), p.setAttribute("r", String(f)), p.setAttribute("fill", "none"), p.setAttribute("stroke", i), p.setAttribute("stroke-width", "0.2"), s.push(p);
1732
+ const f = Math.min(e, l) / 2, g = t.createElementNS(Q, "circle");
1733
+ g.setAttribute("cx", String(o)), g.setAttribute("cy", String(l / 2)), g.setAttribute("r", String(f)), g.setAttribute("fill", "none"), g.setAttribute("stroke", i), g.setAttribute("stroke-width", "0.2"), s.push(g);
1721
1734
  }
1722
1735
  const c = 0, u = l, h = Math.min(e * 0.3, 4), d = t.createElementNS(Q, "path");
1723
1736
  d.setAttribute("d", `M ${o} ${c} L ${o + h} ${u} L ${o} ${u - h * 0.55} L ${o - h} ${u} Z`), d.setAttribute("fill", i), s.push(d);
@@ -1732,12 +1745,12 @@ class Ge extends R {
1732
1745
  }
1733
1746
  }
1734
1747
  x("om-north", Ge);
1735
- const ot = "http://www.w3.org/2000/svg", en = ["rect", "ellipse", "line", "arrow"];
1748
+ const ot = "http://www.w3.org/2000/svg", rn = ["rect", "ellipse", "line", "arrow"];
1736
1749
  class qe extends R {
1737
1750
  static observedAttributes = [...T["om-shape"]];
1738
1751
  get kind() {
1739
1752
  const t = this.getAttribute("kind");
1740
- return en.includes(t) ? t : "rect";
1753
+ return rn.includes(t) ? t : "rect";
1741
1754
  }
1742
1755
  get fill() {
1743
1756
  return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
@@ -1795,12 +1808,12 @@ class qe extends R {
1795
1808
  }
1796
1809
  }
1797
1810
  x("om-shape", qe);
1798
- const he = "data-om-carto-owned", rn = ["contain", "cover", "fill"];
1811
+ const ue = "data-om-carto-owned", nn = ["contain", "cover", "fill"];
1799
1812
  class We extends R {
1800
1813
  static observedAttributes = [...T["om-image"]];
1801
1814
  get fit() {
1802
1815
  const t = this.getAttribute("fit");
1803
- return rn.includes(t ?? "") ? t : "contain";
1816
+ return nn.includes(t ?? "") ? t : "contain";
1804
1817
  }
1805
1818
  get image() {
1806
1819
  return this.querySelector(":scope > img");
@@ -1809,7 +1822,7 @@ class We extends R {
1809
1822
  this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden";
1810
1823
  const t = this.getAttribute("src");
1811
1824
  let e = this.image;
1812
- !e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(he, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(he) && e.getAttribute("src") !== t && e.setAttribute("src", t), e.style.width = "100%", e.style.height = "100%", e.style.objectFit = this.fit, e.style.display = "block");
1825
+ !e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(ue, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(ue) && e.getAttribute("src") !== t && e.setAttribute("src", t), e.style.width = "100%", e.style.height = "100%", e.style.objectFit = this.fit, e.style.display = "block");
1813
1826
  }
1814
1827
  paintCartograph(t, e) {
1815
1828
  const n = this.image;
@@ -1826,12 +1839,12 @@ class We extends R {
1826
1839
  }
1827
1840
  }
1828
1841
  x("om-image", We);
1829
- const nn = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), on = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), sn = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
1830
- function an(r) {
1842
+ const on = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), sn = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), an = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
1843
+ function ln(r) {
1831
1844
  const t = r.type ?? "";
1832
- if (sn.has(t)) return "ramp";
1833
- if (nn.has(t)) return "line";
1834
- if (on.has(t)) return "point";
1845
+ if (an.has(t)) return "ramp";
1846
+ if (on.has(t)) return "line";
1847
+ if (sn.has(t)) return "point";
1835
1848
  if (t === "GeoJsonLayer") {
1836
1849
  const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
1837
1850
  if (n && !i) return "polygon";
@@ -1839,24 +1852,24 @@ function an(r) {
1839
1852
  }
1840
1853
  return "polygon";
1841
1854
  }
1842
- function ln(r) {
1855
+ function cn(r) {
1843
1856
  const t = r.meta?.legend;
1844
1857
  return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
1845
1858
  }
1846
- const kt = 12;
1847
- function cn(r, t = []) {
1859
+ const xt = 12;
1860
+ function un(r, t = []) {
1848
1861
  const e = [];
1849
1862
  for (const n of r) {
1850
1863
  if (n.props?.visible === !1) continue;
1851
1864
  const i = t.filter((a) => a.layer === n.id), s = i.find((a) => a.match == null);
1852
1865
  if (s?.hide) continue;
1853
- const o = un(n.meta?.legend);
1866
+ const o = hn(n.meta?.legend);
1854
1867
  e.push({
1855
1868
  layerId: n.id,
1856
1869
  label: s?.label ?? n.meta?.label ?? n.id,
1857
- color: s?.color ?? ln(n),
1858
- shape: s?.shape ?? an(n),
1859
- legend: hn(o, i),
1870
+ color: s?.color ?? cn(n),
1871
+ shape: s?.shape ?? ln(n),
1872
+ legend: mn(o, i),
1860
1873
  order: s?.order
1861
1874
  });
1862
1875
  }
@@ -1865,15 +1878,15 @@ function cn(r, t = []) {
1865
1878
  return s - o || n.index - i.index;
1866
1879
  }).map((n) => n.row);
1867
1880
  }
1868
- function un(r) {
1869
- if (!r || r.kind !== "categories" || r.entries.length <= kt) return r;
1870
- const t = r.entries.slice(0, kt), e = r.entries.length - kt;
1881
+ function hn(r) {
1882
+ if (!r || r.kind !== "categories" || r.entries.length <= xt) return r;
1883
+ const t = r.entries.slice(0, xt), e = r.entries.length - xt;
1871
1884
  return {
1872
1885
  ...r,
1873
1886
  entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
1874
1887
  };
1875
1888
  }
1876
- function hn(r, t) {
1889
+ function mn(r, t) {
1877
1890
  const e = t.filter((i) => i.match != null);
1878
1891
  if (!r || r.kind === "ramp" || e.length === 0) return r;
1879
1892
  const n = [];
@@ -1883,7 +1896,7 @@ function hn(r, t) {
1883
1896
  }
1884
1897
  return { ...r, entries: n };
1885
1898
  }
1886
- function mn(r) {
1899
+ function dn(r) {
1887
1900
  const t = [];
1888
1901
  for (const e of r.querySelectorAll(":scope > om-legend-row")) {
1889
1902
  const n = e.getAttribute("layer");
@@ -1916,7 +1929,7 @@ function Be(r) {
1916
1929
  }
1917
1930
  return t.sort((e, n) => (e.order ?? Number.POSITIVE_INFINITY) - (n.order ?? Number.POSITIVE_INFINITY));
1918
1931
  }
1919
- const me = "data-om-carto-legend-rows";
1932
+ const he = "data-om-carto-legend-rows";
1920
1933
  class Ve extends R {
1921
1934
  static observedAttributes = [...T["om-legend"]];
1922
1935
  get derived() {
@@ -1926,7 +1939,7 @@ class Ve extends R {
1926
1939
  get rows() {
1927
1940
  if (!this.derived) return Be(this);
1928
1941
  const n = _(this)?.mapElement?.getLayers?.();
1929
- return n ? cn(n, mn(this)) : [];
1942
+ return n ? un(n, dn(this)) : [];
1930
1943
  }
1931
1944
  renderNow() {
1932
1945
  if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !_(this)) {
@@ -1943,9 +1956,9 @@ class Ve extends R {
1943
1956
  }
1944
1957
  renderRows(t) {
1945
1958
  const e = this.ownerDocument;
1946
- this.querySelector(`:scope > [${me}]`)?.remove(), Tr(this);
1959
+ this.querySelector(`:scope > [${he}]`)?.remove(), Tr(this);
1947
1960
  const n = e.createElement("div");
1948
- n.setAttribute(me, ""), n.style.cssText = "padding:2mm;font-size:2.6mm;line-height:1.35;";
1961
+ n.setAttribute(he, ""), n.style.cssText = "padding:2mm;font-size:2.6mm;line-height:1.35;";
1949
1962
  const i = this.getAttribute("title");
1950
1963
  if (i) {
1951
1964
  const o = e.createElement("div");
@@ -1993,16 +2006,16 @@ class Ve extends R {
1993
2006
  if (s <= 0 || o <= 0) return;
1994
2007
  const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
1995
2008
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
1996
- const c = F(a?.borderTopColor), u = Et(a?.borderTopWidth) * e.scale;
2009
+ const c = F(a?.borderTopColor), u = $t(a?.borderTopWidth) * e.scale;
1997
2010
  c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, s - u, o - u));
1998
2011
  const h = F(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", m = (P) => P * e.pxPerMm;
1999
2012
  let f = m(2);
2000
- const p = this.getAttribute("title");
2001
- p && (t.fillStyle = h, t.font = `600 ${m(2.6)}px ${d}`, t.textBaseline = "top", t.fillText(p, m(2), f), f += m(4));
2002
- const g = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(g.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(g.length / w)), M = 3, v = Math.max(1, (n - 4 - M * (w - 1)) / w), N = f;
2013
+ const g = this.getAttribute("title");
2014
+ g && (t.fillStyle = h, t.font = `600 ${m(2.6)}px ${d}`, t.textBaseline = "top", t.fillText(g, m(2), f), f += m(4));
2015
+ const p = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(p.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(p.length / w)), M = 3, v = Math.max(1, (n - 4 - M * (w - 1)) / w), N = f;
2003
2016
  let O = -1, k = 2;
2004
2017
  t.font = `${m(2.6)}px ${d}`;
2005
- for (const [P, L] of g.entries()) {
2018
+ for (const [P, L] of p.entries()) {
2006
2019
  const A = Math.min(w - 1, Math.floor(P / y));
2007
2020
  if (A !== O && (O = A, k = 2 + O * (v + M), f = O === 0 ? N : m(2)), f > o || (t.fillStyle = L.color, L.shape === "line" ? t.fillRect(m(k), f + m(1.2), m(3.2), m(0.9)) : L.shape === "point" ? (t.beginPath(), t.arc(m(k + 1.6), f + m(1.6), m(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(m(k), f, m(3.2), m(3.2)), t.fillStyle = h, t.textBaseline = "top", t.fillText(L.label, m(k + 4.7), f + m(0.3)), f += m(4.2), !L.legend)) continue;
2008
2021
  const S = L.legend;
@@ -2029,55 +2042,55 @@ const st = (r, t) => {
2029
2042
  return e.textContent = t, e;
2030
2043
  };
2031
2044
  x("om-legend", Ve);
2032
- const de = 48, Lt = {
2045
+ const me = 48, Tt = {
2033
2046
  toLngLat: (r, t) => [r, t],
2034
2047
  fromLngLat: (r) => [r[0], r[1]]
2035
2048
  };
2036
- function fe(r, t = 5) {
2037
- return !Number.isFinite(r) || r <= 0 ? 0 : $e(r / Math.max(1, t));
2049
+ function de(r, t = 5) {
2050
+ return !Number.isFinite(r) || r <= 0 ? 0 : ke(r / Math.max(1, t));
2038
2051
  }
2039
- function dn({ georef: r, plane: t = Lt, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
2052
+ function fn({ georef: r, plane: t = Tt, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
2040
2053
  if (r.degenerate) return null;
2041
2054
  const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
2042
2055
  if (l.some((y) => !Number.isFinite(y)) || c.some((y) => !Number.isFinite(y))) return null;
2043
- const u = Math.min(...l), h = Math.max(...l), d = Math.min(...c), m = Math.max(...c), f = pe(n ?? e, fe(h - u)), p = pe(i ?? e, fe(m - d));
2044
- if (f <= 0 || p <= 0 || (h - u) / f > 500 || (m - d) / p > 500) return null;
2045
- const g = [], b = [], w = o ?? pn;
2056
+ const u = Math.min(...l), h = Math.max(...l), d = Math.min(...c), m = Math.max(...c), f = fe(n ?? e, de(h - u)), g = fe(i ?? e, de(m - d));
2057
+ if (f <= 0 || g <= 0 || (h - u) / f > 500 || (m - d) / g > 500) return null;
2058
+ const p = [], b = [], w = o ?? pn;
2046
2059
  for (let y = Math.ceil(u / f) * f; y <= h + 1e-9; y += f) {
2047
2060
  const M = ge(r, t, y, d, m, "x");
2048
2061
  if (M) {
2049
- g.push(M);
2050
- const v = t === Lt ? ze(y) : y;
2051
- s !== "none" && ye(b, M, r, w(v, "x"), "x", s);
2062
+ p.push(M);
2063
+ const v = t === Tt ? ze(y) : y;
2064
+ s !== "none" && be(b, M, r, w(v, "x"), "x", s);
2052
2065
  }
2053
2066
  }
2054
- for (let y = Math.ceil(d / p) * p; y <= m + 1e-9; y += p) {
2067
+ for (let y = Math.ceil(d / g) * g; y <= m + 1e-9; y += g) {
2055
2068
  const M = ge(r, t, y, u, h, "y");
2056
- M && (g.push(M), s !== "none" && ye(b, M, r, w(y, "y"), "y", s));
2069
+ M && (p.push(M), s !== "none" && be(b, M, r, w(y, "y"), "y", s));
2057
2070
  }
2058
- return { lines: g, labels: b, intervalX: f, intervalY: p };
2071
+ return { lines: p, labels: b, intervalX: f, intervalY: g };
2059
2072
  }
2060
- const pe = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
2073
+ const fe = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
2061
2074
  function ge(r, t, e, n, i, s) {
2062
2075
  const o = [];
2063
- for (let l = 0; l <= de; l++) {
2064
- const c = n + (i - n) * l / de, u = s === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
2076
+ for (let l = 0; l <= me; l++) {
2077
+ const c = n + (i - n) * l / me, u = s === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
2065
2078
  if (!Number.isFinite(u[0]) || !Number.isFinite(u[1])) continue;
2066
2079
  const h = r.project(u);
2067
2080
  h && o.push(h);
2068
2081
  }
2069
- const a = fn(o, r.widthMm, r.heightMm);
2082
+ const a = gn(o, r.widthMm, r.heightMm);
2070
2083
  return a.length >= 2 ? { points: a, value: e, axis: s } : null;
2071
2084
  }
2072
- function fn(r, t, e) {
2085
+ function gn(r, t, e) {
2073
2086
  const n = (a) => a.xMm >= -0.01 && a.xMm <= t + 0.01 && a.yMm >= -0.01 && a.yMm <= e + 0.01, i = r.findIndex(n);
2074
2087
  if (i === -1) return [];
2075
2088
  let s = r.length - 1;
2076
2089
  for (; s > i && !n(r[s]); ) s--;
2077
- return r.slice(Math.max(0, i - 1), Math.min(r.length, s + 2)).map((a) => ({ xMm: be(a.xMm, 0, t), yMm: be(a.yMm, 0, e) }));
2090
+ return r.slice(Math.max(0, i - 1), Math.min(r.length, s + 2)).map((a) => ({ xMm: pe(a.xMm, 0, t), yMm: pe(a.yMm, 0, e) }));
2078
2091
  }
2079
- const be = (r, t, e) => Math.min(e, Math.max(t, r));
2080
- function ye(r, t, e, n, i, s) {
2092
+ const pe = (r, t, e) => Math.min(e, Math.max(t, r));
2093
+ function be(r, t, e, n, i, s) {
2081
2094
  if (i === "x") {
2082
2095
  const o = t.points.reduce((a, l) => l.yMm > a.yMm ? l : a);
2083
2096
  if (Math.abs(o.yMm - e.heightMm) > 0.5) return;
@@ -2093,11 +2106,11 @@ function pn(r, t) {
2093
2106
  const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
2094
2107
  return `${Number(r.toFixed(e))}°`;
2095
2108
  }
2096
- function gn(r, t) {
2109
+ function bn(r, t) {
2097
2110
  const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), s = (n - i) * 60, o = Math.floor(s), a = Math.round((s - o) * 60), l = a === 60 ? o + 1 : o, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, h = a === 60 ? 0 : a;
2098
2111
  return `${c}°${String(u).padStart(2, "0")}′${String(h).padStart(2, "0")}″${e}`;
2099
2112
  }
2100
- const at = "http://www.w3.org/2000/svg", bn = ["solid", "cross", "markers"], D = 1.4;
2113
+ const at = "http://www.w3.org/2000/svg", yn = ["solid", "cross", "markers"], D = 1.4;
2101
2114
  class He extends R {
2102
2115
  static observedAttributes = [...T["om-graticule"]];
2103
2116
  resolvedPlane = null;
@@ -2105,7 +2118,7 @@ class He extends R {
2105
2118
  resolveToken = 0;
2106
2119
  get kind() {
2107
2120
  const t = this.getAttribute("kind");
2108
- return bn.includes(t) ? t : "solid";
2121
+ return yn.includes(t) ? t : "solid";
2109
2122
  }
2110
2123
  get labelPlacement() {
2111
2124
  const t = this.getAttribute("labels");
@@ -2121,14 +2134,14 @@ class He extends R {
2121
2134
  const s = Number(this.getAttribute(i));
2122
2135
  return Number.isFinite(s) && s > 0 ? s : null;
2123
2136
  };
2124
- return dn({
2137
+ return fn({
2125
2138
  georef: t,
2126
2139
  plane: e,
2127
2140
  interval: n("interval"),
2128
2141
  intervalX: n("interval-x"),
2129
2142
  intervalY: n("interval-y"),
2130
2143
  labels: this.labelPlacement,
2131
- format: this.getAttribute("format") === "dms" ? gn : void 0
2144
+ format: this.getAttribute("format") === "dms" ? bn : void 0
2132
2145
  });
2133
2146
  }
2134
2147
  /**
@@ -2138,7 +2151,7 @@ class He extends R {
2138
2151
  */
2139
2152
  gridPlane() {
2140
2153
  const t = Y(this.getAttribute("crs"));
2141
- if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return Lt;
2154
+ if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return Tt;
2142
2155
  const e = `${t}|${this.getAttribute("crs-def") ?? ""}`;
2143
2156
  if (this.resolvedPlaneKey === e) return this.resolvedPlane;
2144
2157
  const n = X(t);
@@ -2189,7 +2202,7 @@ class He extends R {
2189
2202
  if (e === "markers") return [t.points[0], t.points[t.points.length - 1]];
2190
2203
  const i = n.lines.filter((o) => o.axis !== t.axis), s = [];
2191
2204
  for (const o of i) {
2192
- const a = yn(t.points, o.points);
2205
+ const a = wn(t.points, o.points);
2193
2206
  a && s.push(a);
2194
2207
  }
2195
2208
  return s;
@@ -2211,7 +2224,7 @@ class He extends R {
2211
2224
  t.restore();
2212
2225
  }
2213
2226
  }
2214
- function yn(r, t) {
2227
+ function wn(r, t) {
2215
2228
  let e = null, n = Number.POSITIVE_INFINITY;
2216
2229
  for (const i of r)
2217
2230
  for (const s of t) {
@@ -2221,27 +2234,27 @@ function yn(r, t) {
2221
2234
  return n <= 1 ? e : null;
2222
2235
  }
2223
2236
  x("om-graticule", He);
2224
- function wn(r, t) {
2237
+ function vn(r, t) {
2225
2238
  if (r == null || typeof r != "object") return;
2226
2239
  const e = r.properties;
2227
2240
  return e && t in e ? e[t] : r[t];
2228
2241
  }
2229
- function Ft(r, t) {
2242
+ function Lt(r, t) {
2230
2243
  if (Array.isArray(r)) {
2231
2244
  if (typeof r[0] == "number") {
2232
2245
  t.push([r[0], r[1]]);
2233
2246
  return;
2234
2247
  }
2235
- for (const e of r) Ft(e, t);
2248
+ for (const e of r) Lt(e, t);
2236
2249
  }
2237
2250
  }
2238
- function vn(r) {
2251
+ function Mn(r) {
2239
2252
  return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
2240
2253
  }
2241
2254
  function I(r, t) {
2242
- return wn(r, t);
2255
+ return vn(r, t);
2243
2256
  }
2244
- function It(r) {
2257
+ function Ft(r) {
2245
2258
  const t = {}, e = (i) => {
2246
2259
  for (const [s, o] of Object.entries(i))
2247
2260
  o == null || typeof o == "object" || (t[s] = String(o));
@@ -2250,11 +2263,11 @@ function It(r) {
2250
2263
  const n = r.properties;
2251
2264
  return n && typeof n == "object" && e(n), t;
2252
2265
  }
2253
- function Mn(r) {
2266
+ function An(r) {
2254
2267
  let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
2255
2268
  const s = [], o = r.geometry;
2256
- if (o?.coordinates != null) Ft(o.coordinates, s);
2257
- else if (Array.isArray(r.coordinates)) Ft(r.coordinates, s);
2269
+ if (o?.coordinates != null) Lt(o.coordinates, s);
2270
+ else if (Array.isArray(r.coordinates)) Lt(r.coordinates, s);
2258
2271
  else {
2259
2272
  const a = Number(I(r, "lng") ?? I(r, "longitude") ?? I(r, "lon") ?? I(r, "x")), l = Number(I(r, "lat") ?? I(r, "latitude") ?? I(r, "y"));
2260
2273
  Number.isFinite(a) && Number.isFinite(l) && s.push([a, l]);
@@ -2263,47 +2276,47 @@ function Mn(r) {
2263
2276
  !Number.isFinite(a) || !Number.isFinite(l) || (t = Math.min(t, a), n = Math.max(n, a), e = Math.min(e, l), i = Math.max(i, l));
2264
2277
  return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
2265
2278
  }
2266
- function An(r, t) {
2279
+ function Sn(r, t) {
2267
2280
  const [e, n, i, s] = r, o = Math.max(i - e, 1e-4), a = Math.max(s - n, 1e-4), l = o * t, c = a * t;
2268
2281
  return [e - l, n - c, i + l, s + c];
2269
2282
  }
2270
- const Xn = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
2271
- function Sn({ features: r, filter: t, sort: e }) {
2272
- let n = t ? r.filter((s) => Cn(t, s)) : [...r];
2273
- const i = xn(e);
2283
+ const Jn = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
2284
+ function Cn({ features: r, filter: t, sort: e }) {
2285
+ let n = t ? r.filter((s) => xn(t, s)) : [...r];
2286
+ const i = kn(e);
2274
2287
  return i.length > 0 && (n = [...n].sort((s, o) => {
2275
2288
  for (const { field: a, descending: l } of i) {
2276
2289
  const c = I(s, a), u = I(o, a);
2277
2290
  if (c == null && u == null) continue;
2278
2291
  if (c == null) return 1;
2279
2292
  if (u == null) return -1;
2280
- const h = kn(c, u);
2293
+ const h = $n(c, u);
2281
2294
  if (h !== 0) return l ? -h : h;
2282
2295
  }
2283
2296
  return 0;
2284
2297
  })), n;
2285
2298
  }
2286
- function Cn(r, t) {
2299
+ function xn(r, t) {
2287
2300
  try {
2288
2301
  return !!r(t);
2289
2302
  } catch {
2290
2303
  return !1;
2291
2304
  }
2292
2305
  }
2293
- function xn(r) {
2306
+ function kn(r) {
2294
2307
  return r ? r.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
2295
2308
  }
2296
- function kn(r, t) {
2309
+ function $n(r, t) {
2297
2310
  return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
2298
2311
  }
2299
- function $n(r) {
2312
+ function En(r) {
2300
2313
  const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
2301
2314
  return t === "" ? "page" : t;
2302
2315
  }
2303
- function En(r, t, e) {
2316
+ function Nn(r, t, e) {
2304
2317
  const n = /* @__PURE__ */ new Map();
2305
2318
  return t.map((i, s) => {
2306
- const o = It(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, h) => h === "index" ? String(s + 1) : h === "count" ? String(t.length) : o[h] ?? u), l = $n(a), c = n.get(l) ?? 0;
2319
+ const o = Ft(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, h) => h === "index" ? String(s + 1) : h === "count" ? String(t.length) : o[h] ?? u), l = En(a), c = n.get(l) ?? 0;
2307
2320
  return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
2308
2321
  });
2309
2322
  }
@@ -2336,13 +2349,13 @@ class Ke extends R {
2336
2349
  }
2337
2350
  /** Export filenames, one per page, already de-duplicated. */
2338
2351
  filenames(t = "png") {
2339
- return En(this.getAttribute("filename"), this.ensurePages(), t);
2352
+ return Nn(this.getAttribute("filename"), this.ensurePages(), t);
2340
2353
  }
2341
2354
  /** Human page labels, for an editor's stepper and PDF bookmarks. */
2342
2355
  pageName(t) {
2343
2356
  const e = this.ensurePages()[t];
2344
2357
  if (!e) return `Page ${t + 1}`;
2345
- const n = It(e), i = this.getAttribute("page-name");
2358
+ const n = Ft(e), i = this.getAttribute("page-name");
2346
2359
  return i ? i.replace(
2347
2360
  /\{\{\s*atlas\.([\w]+)\s*\}\}/g,
2348
2361
  (s, o) => o === "index" ? String(t + 1) : o === "count" ? String(this.count) : n[o] ?? s
@@ -2360,11 +2373,11 @@ class Ke extends R {
2360
2373
  }
2361
2374
  ensurePages() {
2362
2375
  if (this.pages) return this.pages;
2363
- const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? vn(i) : null;
2376
+ const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? Mn(i) : null;
2364
2377
  if (!e || s)
2365
2378
  return this.rejection = e ? s : null, this.pages = [];
2366
2379
  const o = this.materialize(i);
2367
- return this.pages = Sn({ features: o, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
2380
+ return this.pages = Cn({ features: o, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
2368
2381
  }
2369
2382
  /**
2370
2383
  * Rows from the layer, with the layer's OWN declarative filters applied —
@@ -2415,12 +2428,12 @@ class Ke extends R {
2415
2428
  const e = this.closest("om-cartograph");
2416
2429
  for (const n of e?.querySelectorAll("om-frame") ?? []) {
2417
2430
  if (n.getAttribute("atlas-fit") !== "feature") continue;
2418
- const i = Mn(t);
2431
+ const i = An(t);
2419
2432
  if (!i) continue;
2420
- const s = Number(n.getAttribute("atlas-margin")), o = An(i, Number.isFinite(s) && s > 0 ? s : 0.15);
2433
+ const s = Number(n.getAttribute("atlas-margin")), o = Sn(i, Number.isFinite(s) && s > 0 ? s : 0.15);
2421
2434
  n.fitBounds?.(o);
2422
2435
  }
2423
- e?.setAtlasFields({ ...It(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2436
+ e?.setAtlasFields({ ...Ft(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2424
2437
  new CustomEvent("om-atlas-page", {
2425
2438
  bubbles: !0,
2426
2439
  detail: { index: this.currentIndex, count: this.count, name: this.pageName(this.currentIndex), feature: t }
@@ -2432,7 +2445,7 @@ class Ke extends R {
2432
2445
  }
2433
2446
  }
2434
2447
  x("om-atlas", Ke);
2435
- const Nn = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), Pn = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), Tn = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], Ln = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), Fn = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), In = 0.02, Rn = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
2448
+ const Pn = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), Tn = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), Ln = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], Fn = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), In = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), Rn = 0.02, On = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
2436
2449
  function Ye(r) {
2437
2450
  const t = r.tagName.toLowerCase();
2438
2451
  return r.id ? `${t}#${r.id}` : t;
@@ -2443,10 +2456,10 @@ function V(r, t) {
2443
2456
  const n = Number(e);
2444
2457
  return Number.isFinite(n) ? n : null;
2445
2458
  }
2446
- function On(r, t) {
2459
+ function _n(r, t) {
2447
2460
  return r.x < t.x + t.w && t.x < r.x + r.w && r.y < t.y + t.h && t.y < r.y + r.h;
2448
2461
  }
2449
- function _n(r, t) {
2462
+ function Un(r, t) {
2450
2463
  const e = r.getAttribute("style");
2451
2464
  if (!e) return null;
2452
2465
  const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
@@ -2458,67 +2471,67 @@ function Xe(r) {
2458
2471
  }, n = [...r.querySelectorAll("om-cartograph")];
2459
2472
  if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
2460
2473
  return { valid: !0, errors: [], warnings: [] };
2461
- for (const o of n) Un(o, e);
2474
+ for (const o of n) zn(o, e);
2462
2475
  const i = t.filter((o) => o.severity === "error"), s = t.filter((o) => o.severity === "warning");
2463
2476
  return { valid: i.length === 0, errors: i, warnings: s };
2464
2477
  }
2465
- function Un(r, t) {
2478
+ function zn(r, t) {
2466
2479
  const e = r.getAttribute("size"), n = V(r, "width") != null && V(r, "height") != null;
2467
- e && !Kt.includes(e) && !n && t(
2480
+ e && !Ht.includes(e) && !n && t(
2468
2481
  "error",
2469
2482
  r,
2470
2483
  `Unknown page size "${e}" and no width/height to fall back on.`,
2471
- `Use one of ${Kt.join(", ")}, or give width= and height= in millimetres.`,
2484
+ `Use one of ${Ht.join(", ")}, or give width= and height= in millimetres.`,
2472
2485
  "size"
2473
2486
  );
2474
2487
  const i = r.getAttribute("cvd");
2475
- i && i.trim().toLowerCase() !== "none" && !Rt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${nr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && Rn(r) <= 0 && t("warning", r, "crop-marks needs bleed to draw into — trim marks sit outside the page box.", 'Add bleed="3" (mm), or drop crop-marks.', "crop-marks");
2488
+ i && i.trim().toLowerCase() !== "none" && !It(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${nr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && On(r) <= 0 && t("warning", r, "crop-marks needs bleed to draw into — trim marks sit outside the page box.", 'Add bleed="3" (mm), or drop crop-marks.', "crop-marks");
2476
2489
  const s = V(r, "safe-zone");
2477
2490
  if (s != null && s > 0) {
2478
2491
  const m = ut(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
2479
2492
  s * 2 >= Math.min(m.widthMm, m.heightMm) && t("warning", r, `safe-zone=${s}mm leaves no usable area on a ${m.widthMm} × ${m.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
2480
2493
  }
2481
2494
  const o = r.getAttribute("format");
2482
- o == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${gt}" so future runtimes can migrate this document.`, "format") : o !== gt && t("warning", r, `Unrecognised document format "${o}".`, `This build understands "${gt}".`, "format");
2495
+ o == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${pt}" so future runtimes can migrate this document.`, "format") : o !== pt && t("warning", r, `Unrecognised document format "${o}".`, `This build understands "${pt}".`, "format");
2483
2496
  const { widthMm: a, heightMm: l } = ut(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, V(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), h = [...r.querySelectorAll("om-frame")];
2484
2497
  for (const m of h)
2485
2498
  m.id ? u.add(m.id) : t("error", m, "Frame has no id.", "Give every frame an id so furniture can reference it with for=.", "id");
2486
2499
  for (const m of r.children) {
2487
- if (Tn.some((p) => m.hasAttribute(p))) continue;
2500
+ if (Ln.some((g) => m.hasAttribute(g))) continue;
2488
2501
  const f = m.tagName.toLowerCase();
2489
- !bt.includes(f) && !Pn.has(f) && t("error", m, `<${f}> is not a cartograph element.`, `Use one of ${bt.join(", ")}, or move this content inside an <om-text>.`);
2502
+ !bt.includes(f) && !Tn.has(f) && t("error", m, `<${f}> is not a cartograph element.`, `Use one of ${bt.join(", ")}, or move this content inside an <om-text>.`);
2490
2503
  }
2491
2504
  const d = [];
2492
2505
  for (const m of [r, ...r.querySelectorAll("*")]) {
2493
2506
  const f = m.tagName.toLowerCase();
2494
2507
  if (bt.includes(f) && !m.closest("om-map")) {
2495
- if (zn(m, f, t), Fn.has(f)) {
2496
- const p = C(m);
2497
- Dn(m, p, a, l, c, t), Ln.has(f) && !m.hasAttribute("hidden") && d.push({ el: m, box: p });
2508
+ if (Dn(m, f, t), In.has(f)) {
2509
+ const g = C(m);
2510
+ jn(m, g, a, l, c, t), Fn.has(f) && !m.hasAttribute("hidden") && d.push({ el: m, box: g });
2498
2511
  }
2499
- f === "om-frame" && jn(m, t), f === "om-legend" && Gn(m, h, t), f === "om-atlas" && qn(m, h, t), f === "om-scalebar" && Wn(m, h, t), f === "om-text" && Bn(m, h, t);
2500
- for (const p of ["for", "overview-of"]) {
2501
- const g = m.getAttribute(p);
2502
- g && !u.has(g) && t("error", m, `${p}="${g}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, p);
2512
+ f === "om-frame" && Gn(m, t), f === "om-legend" && qn(m, h, t), f === "om-atlas" && Wn(m, h, t), f === "om-scalebar" && Bn(m, h, t), f === "om-text" && Vn(m, h, t);
2513
+ for (const g of ["for", "overview-of"]) {
2514
+ const p = m.getAttribute(g);
2515
+ p && !u.has(p) && t("error", m, `${g}="${p}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, g);
2503
2516
  }
2504
2517
  }
2505
2518
  }
2506
2519
  for (let m = 0; m < d.length; m++)
2507
2520
  for (let f = m + 1; f < d.length; f++) {
2508
- const p = d[m], g = d[f];
2509
- p.box.w <= 0 || p.box.h <= 0 || g.box.w <= 0 || g.box.h <= 0 || On(p.box, g.box) && t(
2521
+ const g = d[m], p = d[f];
2522
+ g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || _n(g.box, p.box) && t(
2510
2523
  "warning",
2511
- p.el,
2512
- `Overlaps ${Ye(g.el)} on the page.`,
2524
+ g.el,
2525
+ `Overlaps ${Ye(p.el)} on the page.`,
2513
2526
  "Move one of them — furniture overlapping furniture usually means a stale layout (frames may sit under anything)."
2514
2527
  );
2515
2528
  }
2516
2529
  }
2517
- function zn(r, t, e) {
2530
+ function Dn(r, t, e) {
2518
2531
  const n = new Set(T[t] ?? []);
2519
2532
  for (const i of r.attributes) {
2520
2533
  const s = i.name.toLowerCase();
2521
- if (n.has(s) || Nn.has(s) || s.startsWith("data-") || s.startsWith("aria-")) continue;
2534
+ if (n.has(s) || Pn.has(s) || s.startsWith("data-") || s.startsWith("aria-")) continue;
2522
2535
  const o = br.get(s);
2523
2536
  if (o) {
2524
2537
  e("warning", r, `Attribute "${s}" has no effect: ${o}`, "Remove it, or use the documented alternative.", s);
@@ -2527,7 +2540,7 @@ function zn(r, t, e) {
2527
2540
  e("warning", r, `Unknown attribute "${s}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, s);
2528
2541
  }
2529
2542
  }
2530
- function Dn(r, t, e, n, i, s) {
2543
+ function jn(r, t, e, n, i, s) {
2531
2544
  if (t.w <= 0 || t.h <= 0) {
2532
2545
  s("error", r, `Element has no size (w=${t.w}, h=${t.h}).`, "Give w= and h= in millimetres — both greater than zero.", t.w <= 0 ? "w" : "h");
2533
2546
  return;
@@ -2546,7 +2559,7 @@ function Dn(r, t, e, n, i, s) {
2546
2559
  ["height", t.h]
2547
2560
  ];
2548
2561
  for (const [u, h] of c) {
2549
- const d = _n(r, u);
2562
+ const d = Un(r, u);
2550
2563
  d != null && Math.abs(d - h) > 0.01 && s(
2551
2564
  "error",
2552
2565
  r,
@@ -2556,7 +2569,7 @@ function Dn(r, t, e, n, i, s) {
2556
2569
  );
2557
2570
  }
2558
2571
  }
2559
- function jn(r, t) {
2572
+ function Gn(r, t) {
2560
2573
  if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
2561
2574
  const n = r.getAttribute("corners"), i = dt(n);
2562
2575
  i || t(
@@ -2572,8 +2585,8 @@ function jn(r, t) {
2572
2585
  if (a.degenerate)
2573
2586
  t("error", r, "Frame corners are degenerate (collinear or coincident) — nothing can be placed on this frame.", "Check the corner order: tl, tr, br, bl.", "corners");
2574
2587
  else {
2575
- const l = Kr(a);
2576
- l != null && l > In && t(
2588
+ const l = Yr(a);
2589
+ l != null && l > Rn && t(
2577
2590
  "warning",
2578
2591
  r,
2579
2592
  `Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
@@ -2601,12 +2614,12 @@ function jn(r, t) {
2601
2614
  n && n !== "EPSG:3857" && t("error", r, `Live frame declares ${n}, but live frames render EPSG:3857.`, 'Use mode="static" with a georeferenced raster for other projections.', "crs");
2602
2615
  }
2603
2616
  }
2604
- function Ut(r, t) {
2617
+ function _t(r, t) {
2605
2618
  const e = r.getAttribute("for");
2606
2619
  return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
2607
2620
  }
2608
- function Gn(r, t, e) {
2609
- const n = r.getAttribute("derived") !== "false", i = Ut(r, t);
2621
+ function qn(r, t, e) {
2622
+ const n = r.getAttribute("derived") !== "false", i = _t(r, t);
2610
2623
  n && i?.getAttribute("mode") === "static" && e(
2611
2624
  "warning",
2612
2625
  r,
@@ -2627,10 +2640,10 @@ function Gn(r, t, e) {
2627
2640
  );
2628
2641
  }
2629
2642
  }
2630
- function qn(r, t, e) {
2643
+ function Wn(r, t, e) {
2631
2644
  const n = r.getAttribute("layer");
2632
2645
  n || e("error", r, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
2633
- const i = r.getAttribute("for"), s = Ut(r, t);
2646
+ const i = r.getAttribute("for"), s = _t(r, t);
2634
2647
  if (!s) {
2635
2648
  !i && t.length !== 1 && e("error", r, `Atlas does not say which frame drives it, and the page has ${t.length} frames.`, 'Add for="<frame id>".', "for");
2636
2649
  return;
@@ -2662,14 +2675,14 @@ function qn(r, t, e) {
2662
2675
  );
2663
2676
  }
2664
2677
  }
2665
- function Wn(r, t, e) {
2678
+ function Bn(r, t, e) {
2666
2679
  const n = V(r, "segment-length");
2667
2680
  if (n == null) return;
2668
- const i = Ut(r, t);
2681
+ const i = _t(r, t);
2669
2682
  if (!i) return;
2670
2683
  const s = dt(i.getAttribute("corners")), o = X(i.getAttribute("crs")), a = C(i);
2671
2684
  if (!s || !o || a.w <= 0 || a.h <= 0) return;
2672
- const l = mt({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = C(r), u = Ee({
2685
+ const l = mt({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = C(r), u = $e({
2673
2686
  groundMetersPerMm: l.groundMetersPerMm(),
2674
2687
  maxWidthMm: c.w,
2675
2688
  segments: V(r, "segments") ?? void 0,
@@ -2683,7 +2696,7 @@ function Wn(r, t, e) {
2683
2696
  "segment-length"
2684
2697
  );
2685
2698
  }
2686
- function Bn(r, t, e) {
2699
+ function Vn(r, t, e) {
2687
2700
  const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), s = new Set(t.map((o) => o.id).filter(Boolean));
2688
2701
  for (const o of $r(n))
2689
2702
  if (!o.startsWith("atlas.")) {
@@ -2704,10 +2717,10 @@ function Bn(r, t, e) {
2704
2717
  i.has(o) || e("warning", r, `Unknown token {{${o}}} — it will render literally.`, `Known tokens: ${[...i].join(", ")}, frame.<id>.scale, frame.<id>.crs, atlas.<field>.`);
2705
2718
  }
2706
2719
  }
2707
- function Jn(r) {
2708
- return Xe(gr(r));
2720
+ function Zn(r) {
2721
+ return Xe(pr(r));
2709
2722
  }
2710
- async function Zn(r) {
2723
+ async function Qn(r) {
2711
2724
  const t = Xe(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
2712
2725
  if (e.length === 0) return t;
2713
2726
  const { loadCore: n } = await Promise.resolve().then(() => Qe), i = await n(), s = [...t.errors], o = [...t.warnings];
@@ -2718,25 +2731,25 @@ async function Zn(r) {
2718
2731
  }
2719
2732
  return { valid: s.length === 0, errors: s, warnings: o };
2720
2733
  }
2721
- function Qn() {
2734
+ function ti() {
2722
2735
  x("om-cartograph", Ie), x("om-text", Re), x("om-frame", De), x("om-scalebar", je), x("om-north", Ge), x("om-shape", qe), x("om-image", We), x("om-legend", Ve), x("om-graticule", He), x("om-atlas", Ke);
2723
2736
  }
2724
- we(() => import("@nika-js/onlymap"));
2737
+ ye(() => import("@nika-js/onlymap"));
2725
2738
  fr();
2726
2739
  export {
2727
2740
  T as CARTOGRAPH_ELEMENT_ATTRS,
2728
- gt as CARTOGRAPH_FORMAT,
2741
+ pt as CARTOGRAPH_FORMAT,
2729
2742
  bt as CARTOGRAPH_TAG_NAMES,
2730
- Vn as CARTOGRAPH_THEMES,
2743
+ Hn as CARTOGRAPH_THEMES,
2731
2744
  or as COLLAPSE_THRESHOLD,
2732
- Ot as CVD_MATRICES,
2745
+ Rt as CVD_MATRICES,
2733
2746
  ft as CVD_TYPES,
2734
2747
  nr as CVD_VALUES,
2735
- Lt as GEOGRAPHIC_PLANE,
2748
+ Tt as GEOGRAPHIC_PLANE,
2736
2749
  br as INERT_RESERVED_CARTOGRAPH_ATTRS,
2737
- Ce as MAX_CANVAS_AREA,
2738
- Se as MAX_CANVAS_DIMENSION,
2739
- kt as MAX_CATEGORY_ENTRIES,
2750
+ Se as MAX_CANVAS_AREA,
2751
+ Ae as MAX_CANVAS_DIMENSION,
2752
+ xt as MAX_CATEGORY_ENTRIES,
2740
2753
  Ke as OmAtlasElement,
2741
2754
  Ie as OmCartographElement,
2742
2755
  De as OmFrameElement,
@@ -2747,84 +2760,84 @@ export {
2747
2760
  je as OmScalebarElement,
2748
2761
  qe as OmShapeElement,
2749
2762
  Re as OmTextElement,
2750
- Dt as PAGE_PRESETS,
2751
- Kt as PAGE_SIZE_NAMES,
2763
+ zt as PAGE_PRESETS,
2764
+ Ht as PAGE_SIZE_NAMES,
2752
2765
  z as PLACED_ATTR_NAMES,
2753
2766
  W as PX_PER_MM,
2754
2767
  Cr as SCALE_GROUP_SEPARATOR,
2755
2768
  mr as URL_ACTION_TIMEOUT_MS,
2756
- Ir as alignOffset,
2757
- Fe as allFrames,
2769
+ Rr as alignOffset,
2770
+ Le as allFrames,
2758
2771
  ar as applyCvdToCanvas,
2759
2772
  Er as applyTokens,
2760
2773
  dr as applyUrlActions,
2761
- It as atlasFields,
2762
- Xn as boundsArea,
2774
+ Ft as atlasFields,
2775
+ Jn as boundsArea,
2763
2776
  C as boxMm,
2764
- dn as buildGraticule,
2765
- Sn as buildPages,
2766
- Ee as buildScalebar,
2777
+ fn as buildGraticule,
2778
+ Cn as buildPages,
2779
+ $e as buildScalebar,
2767
2780
  Sr as buildScalebarDrawing,
2768
2781
  X as builtinCrsForward,
2769
- Hn as canvasMeasurer,
2782
+ Kn as canvasMeasurer,
2770
2783
  Tr as clearUnlinked,
2771
- Kn as cornersFromBounds,
2772
- Tt as cornersFromCamera,
2784
+ Yn as cornersFromBounds,
2785
+ Pt as cornersFromCamera,
2773
2786
  mt as createFrameGeoref,
2774
2787
  rr as createZip,
2775
- Qn as defineCartographElements,
2776
- Wt as deltaE00,
2777
- cn as deriveLegendRows,
2788
+ ti as defineCartographElements,
2789
+ qt as deltaE00,
2790
+ un as deriveLegendRows,
2778
2791
  lr as ensureCvdFilters,
2779
- Mn as featureBounds,
2792
+ An as featureBounds,
2780
2793
  I as fieldOf,
2781
- Le as findFrame,
2782
- gn as formatDms,
2794
+ Te as findFrame,
2795
+ bn as formatDms,
2783
2796
  xr as formatScaleDenominator,
2784
2797
  fr as installUrlActions,
2785
2798
  Ze as isCoreLoaded,
2786
2799
  Nr as isoDate,
2787
- Fr as layoutText,
2800
+ Ir as layoutText,
2788
2801
  sr as lintLegendColours,
2789
- ve as loadCore,
2790
- Yn as maxGeoreferenceablePitch,
2791
- Ur as mercatorForward,
2802
+ we as loadCore,
2803
+ Xn as maxGeoreferenceablePitch,
2804
+ zr as mercatorForward,
2792
2805
  Oe as mercatorInverse,
2793
- fe as niceInterval,
2794
- $e as niceNumberBelow,
2806
+ de as niceInterval,
2807
+ ke as niceNumberBelow,
2795
2808
  Y as normalizeCrs,
2796
- Hr as northBearingDegrees,
2797
- Te as ownerCartograph,
2798
- An as padBounds,
2799
- zt as paintEnvForDpi,
2809
+ Kr as northBearingDegrees,
2810
+ Pe as ownerCartograph,
2811
+ Sn as padBounds,
2812
+ Ut as paintEnvForDpi,
2800
2813
  ir as parseColor,
2801
2814
  dt as parseCorners,
2802
- xn as parseSort,
2815
+ kn as parseSort,
2803
2816
  H as peekCore,
2804
2817
  ct as readCamera,
2805
2818
  Be as readLiteralRows,
2806
- mn as readOverrides,
2819
+ dn as readOverrides,
2807
2820
  _ as referencedFrame,
2808
- vn as rejectionFor,
2809
- _t as renderCartograph,
2810
- xe as renderCartographAtlas,
2821
+ Mn as rejectionFor,
2822
+ Ot as renderCartograph,
2823
+ Ce as renderCartographAtlas,
2811
2824
  Ue as resolveCrsForward,
2812
- Rt as resolveCvdType,
2813
- En as resolveFilenames,
2825
+ It as resolveCvdType,
2826
+ Nn as resolveFilenames,
2814
2827
  ut as resolvePageSize,
2815
2828
  kr as resolveToken,
2816
- Pe as resolveTokens,
2817
- ln as rowColorFor,
2818
- Xr as sanitizeAdoptedMap,
2819
- $n as sanitizeFilename,
2820
- Kr as scaleVariation,
2821
- we as setCoreLoader,
2822
- Gt as simulate,
2823
- an as swatchShapeFor,
2829
+ Ne as resolveTokens,
2830
+ cn as rowColorFor,
2831
+ Jr as sanitizeAdoptedMap,
2832
+ En as sanitizeFilename,
2833
+ Yr as scaleVariation,
2834
+ ye as setCoreLoader,
2835
+ jt as simulate,
2836
+ ln as swatchShapeFor,
2824
2837
  $r as tokensIn,
2825
- se as utmDef,
2838
+ oe as utmDef,
2826
2839
  Xe as validateCartograph,
2827
- Zn as validateCartographDeep,
2828
- Jn as validateCartographString,
2829
- Ht as whenPageReady
2840
+ Qn as validateCartographDeep,
2841
+ Zn as validateCartographString,
2842
+ Vt as whenPageReady
2830
2843
  };