@nika-js/onlymap 0.8.2 → 0.8.3

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,16 +1,16 @@
1
- let kt = null, Z = null;
2
- function ye(r) {
3
- kt = r;
1
+ let $t = null, Z = null;
2
+ function we(r) {
3
+ $t = r;
4
4
  }
5
5
  function Ze() {
6
- return V !== null;
6
+ return B !== null;
7
7
  }
8
- let V = null;
9
- function G() {
10
- return V;
8
+ let B = null;
9
+ function H() {
10
+ return B;
11
11
  }
12
- function we() {
13
- return V ? Promise.resolve(V) : Z || (kt ? (Z = Promise.resolve(kt()).then((r) => (V = r, V)).catch((r) => {
12
+ function ve() {
13
+ return B ? Promise.resolve(B) : Z || ($t ? (Z = Promise.resolve($t()).then((r) => (B = r, B)).catch((r) => {
14
14
  throw Z = null, r;
15
15
  }), Z) : Promise.reject(
16
16
  new Error(
@@ -18,46 +18,46 @@ function we() {
18
18
  )
19
19
  ));
20
20
  }
21
- const Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
21
+ const Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22
22
  __proto__: null,
23
23
  isCoreLoaded: Ze,
24
- loadCore: we,
25
- peekCore: G,
26
- setCoreLoader: ye
24
+ loadCore: ve,
25
+ peekCore: H,
26
+ setCoreLoader: we
27
27
  }, Symbol.toStringTag, { value: "Module" }));
28
- function Ot(r) {
28
+ function zt(r) {
29
29
  return { scale: r / 96, pxPerMm: r / 25.4 };
30
30
  }
31
- function ft(r) {
31
+ function pt(r) {
32
32
  return typeof r?.paintCartograph == "function";
33
33
  }
34
- const B = (r, t) => {
34
+ const q = (r, t) => {
35
35
  const e = r.getAttribute(t);
36
36
  if (e == null || e.trim() === "") return null;
37
37
  const n = Number(e);
38
38
  return Number.isFinite(n) ? n : null;
39
39
  };
40
- function S(r) {
40
+ function C(r) {
41
41
  return {
42
- x: B(r, "x") ?? 0,
43
- y: B(r, "y") ?? 0,
44
- w: B(r, "w") ?? 0,
45
- h: B(r, "h") ?? 0,
46
- rotation: B(r, "rotation") ?? 0,
47
- z: B(r, "z")
42
+ x: q(r, "x") ?? 0,
43
+ y: q(r, "y") ?? 0,
44
+ w: q(r, "w") ?? 0,
45
+ h: q(r, "h") ?? 0,
46
+ rotation: q(r, "rotation") ?? 0,
47
+ z: q(r, "z")
48
48
  };
49
49
  }
50
- function $t(r, t = 0) {
50
+ function Et(r, t = 0) {
51
51
  if (!r) return t;
52
52
  const e = Number.parseFloat(r);
53
53
  return Number.isFinite(e) ? e : t;
54
54
  }
55
- function L(r) {
55
+ function F(r) {
56
56
  if (!r) return null;
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 z = 96 / 25.4, Ut = {
60
+ const W = 96 / 25.4, Dt = {
61
61
  A0: { widthMm: 841, heightMm: 1189 },
62
62
  A1: { widthMm: 594, heightMm: 841 },
63
63
  A2: { widthMm: 420, heightMm: 594 },
@@ -66,15 +66,15 @@ const z = 96 / 25.4, Ut = {
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
- }, zt = "A4";
70
- function ct(r, t, e, n) {
69
+ }, jt = "A4";
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 = Ut[r ?? zt] ?? Ut[zt];
73
+ const o = Dt[r ?? jt] ?? Dt[jt];
74
74
  return n === "landscape" ? { widthMm: o.heightMm, heightMm: o.widthMm } : { ...o };
75
75
  }
76
76
  let et = null;
77
- function Qe(r) {
77
+ function tr(r) {
78
78
  if (!et) {
79
79
  et = new Uint32Array(256);
80
80
  for (let e = 0; e < 256; e++) {
@@ -87,51 +87,51 @@ function Qe(r) {
87
87
  for (let e = 0; e < r.length; e++) t = et[(t ^ r[e]) & 255] ^ t >>> 8;
88
88
  return (t ^ 4294967295) >>> 0;
89
89
  }
90
- function tr(r) {
90
+ function er(r) {
91
91
  const t = Math.max(1980, r.getFullYear());
92
92
  return {
93
93
  time: r.getHours() << 11 | r.getMinutes() << 5 | Math.floor(r.getSeconds() / 2),
94
94
  date: t - 1980 << 9 | r.getMonth() + 1 << 5 | r.getDate()
95
95
  };
96
96
  }
97
- async function er(r, t = /* @__PURE__ */ new Date()) {
98
- const e = new TextEncoder(), { time: n, date: i } = tr(t), s = [], o = [];
97
+ async function rr(r, t = /* @__PURE__ */ new Date()) {
98
+ const e = new TextEncoder(), { time: n, date: i } = er(t), s = [], o = [];
99
99
  let a = 0;
100
100
  for (const u of r) {
101
- const m = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), h = Qe(m), f = new DataView(new ArrayBuffer(30));
102
- f.setUint32(0, 67324752, !0), f.setUint16(4, 20, !0), f.setUint16(6, 2048, !0), f.setUint16(8, 0, !0), f.setUint16(10, n, !0), f.setUint16(12, i, !0), f.setUint32(14, h, !0), f.setUint32(18, m.length, !0), f.setUint32(22, m.length, !0), f.setUint16(26, d.length, !0), f.setUint16(28, 0, !0), s.push(new Uint8Array(f.buffer), d, m), o.push({ name: u.name, bytes: m, crc: h, offset: a }), a += 30 + d.length + m.length;
101
+ const h = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), m = tr(h), f = new DataView(new ArrayBuffer(30));
102
+ f.setUint32(0, 67324752, !0), f.setUint16(4, 20, !0), f.setUint16(6, 2048, !0), f.setUint16(8, 0, !0), f.setUint16(10, n, !0), f.setUint16(12, i, !0), f.setUint32(14, m, !0), f.setUint32(18, h.length, !0), f.setUint32(22, h.length, !0), f.setUint16(26, d.length, !0), f.setUint16(28, 0, !0), s.push(new Uint8Array(f.buffer), d, h), o.push({ name: u.name, bytes: h, crc: m, offset: a }), a += 30 + d.length + h.length;
103
103
  }
104
104
  const l = a;
105
105
  for (const u of o) {
106
- const m = e.encode(u.name), d = new DataView(new ArrayBuffer(46));
107
- d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, 2048, !0), d.setUint16(10, 0, !0), d.setUint16(12, n, !0), d.setUint16(14, i, !0), d.setUint32(16, u.crc, !0), d.setUint32(20, u.bytes.length, !0), d.setUint32(24, u.bytes.length, !0), d.setUint16(28, m.length, !0), d.setUint16(30, 0, !0), d.setUint16(32, 0, !0), d.setUint16(34, 0, !0), d.setUint16(36, 0, !0), d.setUint32(38, 0, !0), d.setUint32(42, u.offset, !0), s.push(new Uint8Array(d.buffer), m), a += 46 + m.length;
106
+ const h = e.encode(u.name), d = new DataView(new ArrayBuffer(46));
107
+ d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, 2048, !0), d.setUint16(10, 0, !0), d.setUint16(12, n, !0), d.setUint16(14, i, !0), d.setUint32(16, u.crc, !0), d.setUint32(20, u.bytes.length, !0), d.setUint32(24, u.bytes.length, !0), d.setUint16(28, h.length, !0), d.setUint16(30, 0, !0), d.setUint16(32, 0, !0), d.setUint16(34, 0, !0), d.setUint16(36, 0, !0), d.setUint32(38, 0, !0), d.setUint32(42, u.offset, !0), s.push(new Uint8Array(d.buffer), h), a += 46 + h.length;
108
108
  }
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 dt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], ve = {
112
+ const ft = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Me = {
113
113
  protan: "protanopia",
114
114
  deutan: "deuteranopia",
115
115
  tritan: "tritanopia",
116
116
  achroma: "achromatopsia"
117
117
  };
118
- function Ft(r) {
118
+ function Rt(r) {
119
119
  const t = r?.trim().toLowerCase();
120
- return !t || t === "none" ? null : dt.includes(t) ? t : ve[t] ?? null;
120
+ return !t || t === "none" ? null : ft.includes(t) ? t : Me[t] ?? null;
121
121
  }
122
- const rr = ["none", ...dt, ...Object.keys(ve)], It = {
122
+ const nr = ["none", ...ft, ...Object.keys(Me)], Ot = {
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],
126
126
  achromatopsia: [0.2126, 0.7152, 0.0722, 0.2126, 0.7152, 0.0722, 0.2126, 0.7152, 0.0722]
127
- }, q = (r) => {
127
+ }, j = (r) => {
128
128
  const t = r / 255;
129
129
  return t <= 0.04045 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4;
130
130
  }, lt = (r) => {
131
131
  const t = Math.min(1, Math.max(0, r));
132
132
  return 255 * (t <= 31308e-7 ? t * 12.92 : 1.055 * t ** (1 / 2.4) - 0.055);
133
133
  };
134
- function nr(r) {
134
+ function ir(r) {
135
135
  const t = r.trim().toLowerCase(), e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);
136
136
  if (e) {
137
137
  const i = e[1], s = (o) => parseInt(o.length === 1 ? o + o : o, 16);
@@ -140,48 +140,48 @@ function nr(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 jt(r, t) {
144
- const e = It[t], [n, i, s] = [q(r.r), q(r.g), q(r.b)];
143
+ function Gt(r, t) {
144
+ const e = Ot[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 Dt({ r, g: t, b: e }) {
152
- const [n, i, s] = [q(r), q(t), q(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 = (h) => h > 216 / 24389 ? Math.cbrt(h) : 841 / 108 * h + 4 / 29, [u, m, d] = [c(o), c(a), c(l)];
153
- return [116 * m - 16, 500 * (u - m), 200 * (m - d)];
151
+ function qt({ r, g: t, b: e }) {
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
+ return [116 * h - 16, 500 * (u - h), 200 * (h - d)];
154
154
  }
155
- function Gt(r, t) {
156
- const [e, n, i] = Dt(r), [s, o, a] = Dt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(o, a)) / 2, m = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, h] = [n * (1 + m), o * (1 + m)], [f, p] = [Math.hypot(d, i), Math.hypot(h, a)], g = (U, tt) => {
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) => {
157
157
  if (U === 0 && tt === 0) return 0;
158
- const X = Math.atan2(tt, U) * c;
159
- return X >= 0 ? X : X + 360;
160
- }, [b, w] = [g(d, i), g(h, a)], y = s - e, C = p - f;
158
+ const J = Math.atan2(tt, U) * c;
159
+ return J >= 0 ? J : J + 360;
160
+ }, [b, w] = [g(d, i), g(m, a)], y = s - e, M = p - f;
161
161
  let v = 0;
162
162
  f * p !== 0 && (v = w - b, v > 180 ? v -= 360 : v < -180 && (v += 360));
163
- const F = 2 * Math.sqrt(f * p) * Math.sin(v * l / 2), _ = (e + s) / 2, k = (f + p) / 2;
164
- let N = b + w;
165
- f * p !== 0 && (Math.abs(b - w) > 180 && (N += b + w < 360 ? 360 : -360), N /= 2);
166
- const T = 1 - 0.17 * Math.cos((N - 30) * l) + 0.24 * Math.cos(2 * N * l) + 0.32 * Math.cos((3 * N + 6) * l) - 0.2 * Math.cos((4 * N - 63) * l), M = 1 + 0.015 * (_ - 50) ** 2 / Math.sqrt(20 + (_ - 50) ** 2), A = 1 + 0.045 * k, $ = 1 + 0.015 * k * T, E = -2 * Math.sqrt(k ** 7 / (k ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((N - 275) / 25) ** 2)) * l);
167
- return Math.sqrt((y / M) ** 2 + (C / A) ** 2 + (F / $) ** 2 + E * (C / A) * (F / $));
168
- }
169
- const ir = 10;
170
- function or(r, t = ir) {
163
+ const N = 2 * Math.sqrt(f * p) * Math.sin(v * l / 2), O = (e + s) / 2, k = (f + p) / 2;
164
+ let P = b + w;
165
+ f * p !== 0 && (Math.abs(b - w) > 180 && (P += b + w < 360 ? 360 : -360), P /= 2);
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
+ return Math.sqrt((y / A) ** 2 + (M / S) ** 2 + (N / $) ** 2 + E * (M / S) * (N / $));
168
+ }
169
+ const or = 10;
170
+ function sr(r, t = or) {
171
171
  const e = /* @__PURE__ */ new Map();
172
172
  for (const a of r) {
173
- const l = nr(a.color);
173
+ const l = ir(a.color);
174
174
  if (!l) continue;
175
175
  const c = a.layer ?? "", u = e.get(c);
176
176
  u ? u.push({ entry: a, rgb: l }) : e.set(c, [{ entry: a, rgb: l }]);
177
177
  }
178
178
  const n = [], i = /* @__PURE__ */ new Map();
179
- for (const a of dt)
179
+ for (const a of ft)
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 (Gt(l[c].rgb, l[u].rgb) < t) continue;
184
- const d = Gt(jt(l[c].rgb, a), jt(l[u].rgb, a));
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));
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;
@@ -189,7 +189,7 @@ function or(r, t = ir) {
189
189
  l > o && (o = l, s = a);
190
190
  return { collapses: n, worstType: s };
191
191
  }
192
- function sr(r, t, e, n) {
192
+ function ar(r, t, e, n) {
193
193
  if (t <= 0 || e <= 0) return !0;
194
194
  let i;
195
195
  try {
@@ -198,36 +198,36 @@ function sr(r, t, e, n) {
198
198
  return !1;
199
199
  }
200
200
  const s = new Float64Array(256);
201
- for (let m = 0; m < 256; m++) s[m] = q(m);
201
+ for (let h = 0; h < 256; h++) s[h] = j(h);
202
202
  const o = 1024, a = new Float64Array(o + 1);
203
- for (let m = 0; m <= o; m++) a[m] = lt(m / o);
204
- const l = (m) => {
205
- const d = Math.min(1, Math.max(0, m)) * o, h = Math.floor(d);
206
- return h >= o ? a[o] : a[h] + (a[h + 1] - a[h]) * (d - h);
207
- }, c = It[n], u = i.data;
208
- for (let m = 0; m < u.length; m += 4) {
209
- const d = s[u[m]], h = s[u[m + 1]], f = s[u[m + 2]];
210
- u[m] = l(c[0] * d + c[1] * h + c[2] * f), u[m + 1] = l(c[3] * d + c[4] * h + c[5] * f), u[m + 2] = l(c[6] * d + c[7] * h + c[8] * f);
203
+ for (let h = 0; h <= o; h++) a[h] = lt(h / o);
204
+ const l = (h) => {
205
+ const d = Math.min(1, Math.max(0, h)) * o, m = Math.floor(d);
206
+ return m >= o ? a[o] : a[m] + (a[m + 1] - a[m]) * (d - m);
207
+ }, c = Ot[n], u = i.data;
208
+ for (let h = 0; h < u.length; h += 4) {
209
+ const d = s[u[h]], m = s[u[h + 1]], f = s[u[h + 2]];
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 Me = (r) => `om-carto-cvd-${r}`;
215
- function ar(r) {
214
+ const Ae = (r) => `om-carto-cvd-${r}`;
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
- for (const e of dt) {
219
+ for (const e of ft) {
220
220
  const n = r.createElementNS("http://www.w3.org/2000/svg", "filter");
221
- n.id = Me(e), n.setAttribute("color-interpolation-filters", "linearRGB");
221
+ n.id = Ae(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 = It[e];
224
+ const s = Ot[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 Ae = 16384, Se = 134217728;
230
- async function lr(r) {
229
+ const Se = 16384, Ce = 134217728;
230
+ async function cr(r) {
231
231
  const t = [], e = [...r.querySelectorAll("img")];
232
232
  return await Promise.all(
233
233
  e.map(async (n) => {
@@ -240,68 +240,68 @@ async function lr(r) {
240
240
  })
241
241
  ), t;
242
242
  }
243
- function cr(r) {
243
+ function ur(r) {
244
244
  return [...r.children].filter(
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
- ).map((t, e) => ({ el: t, index: e, z: S(t).z ?? 0 })).sort((t, e) => t.z - e.z || t.index - e.index).map((t) => t.el);
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 Rt(r, t = {}) {
248
+ async function _t(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);
252
252
  if (!Number.isFinite(i) || i <= 0) throw new Error(`[onlymapjs/cartograph] renderCartograph: invalid dpi ${t.dpi}.`);
253
- const { widthMm: s, heightMm: o } = ct(
253
+ const { widthMm: s, heightMm: o } = ut(
254
254
  e.getAttribute("size"),
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 ?? Ae, m = t.maxArea ?? Se;
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;
259
259
  let d = i;
260
- const h = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(m / (l / 25.4 * (c / 25.4))), p = Math.min(h, 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 lr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
262
- const g = Ot(d), b = Math.max(1, Math.round(l * g.pxPerMm)), w = Math.max(1, Math.round(c * g.pxPerMm)), y = cr(e);
263
- for (const M of y)
264
- if (!(!ft(M) || !M.prepareCartograph))
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);
263
+ for (const A of y)
264
+ if (!(!pt(A) || !A.prepareCartograph))
265
265
  try {
266
- await M.prepareCartograph(Ot(d));
267
- } catch (A) {
268
- M.discardCartograph?.(), n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} could not be captured: ${A.message}`);
266
+ await A.prepareCartograph(zt(d));
267
+ } catch (S) {
268
+ A.discardCartograph?.(), n.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} could not be captured: ${S.message}`);
269
269
  }
270
- const C = document.createElement("canvas");
271
- C.width = b, C.height = w;
272
- const v = C.getContext("2d");
270
+ const M = document.createElement("canvas");
271
+ M.width = b, M.height = w;
272
+ const v = M.getContext("2d");
273
273
  if (!v) throw new Error("[onlymapjs/cartograph] renderCartograph: could not get a 2D canvas context.");
274
- const F = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
275
- v.fillStyle = L(F?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
276
- for (const M of y) {
277
- if (!ft(M)) continue;
278
- const A = S(M);
279
- if (v.save(), v.translate((A.x + a) * g.pxPerMm, (A.y + a) * g.pxPerMm), A.rotation) {
280
- const $ = A.w / 2 * g.pxPerMm, E = A.h / 2 * g.pxPerMm;
281
- v.translate($, E), v.rotate(A.rotation * Math.PI / 180), v.translate(-$, -E);
274
+ const N = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
275
+ v.fillStyle = F(N?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
276
+ for (const A of y) {
277
+ if (!pt(A)) continue;
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;
281
+ v.translate($, E), v.rotate(S.rotation * Math.PI / 180), v.translate(-$, -E);
282
282
  }
283
283
  try {
284
- M.paintCartograph(v, g);
284
+ A.paintCartograph(v, g);
285
285
  } catch ($) {
286
- n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} failed to render: ${$.message}`);
286
+ n.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} failed to render: ${$.message}`);
287
287
  }
288
288
  v.restore();
289
289
  }
290
- const _ = e.querySelector(":scope > [data-om-carto-marks]");
291
- for (const M of _?.querySelectorAll("line") ?? []) {
292
- const A = Number(M.getAttribute("x1")), $ = Number(M.getAttribute("y1")), E = Number(M.getAttribute("x2")), U = Number(M.getAttribute("y2"));
293
- [A, $, E, U].every(Number.isFinite) && (v.save(), v.strokeStyle = M.getAttribute("stroke") || "#000000", v.lineWidth = (Number(M.getAttribute("stroke-width")) || 0.2) * g.pxPerMm, v.beginPath(), v.moveTo((A + a) * g.pxPerMm, ($ + a) * g.pxPerMm), v.lineTo((E + a) * g.pxPerMm, (U + a) * g.pxPerMm), v.stroke(), v.restore());
294
- }
295
- const k = Ft(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
296
- k && !sr(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 M of y) ft(M) && M.discardCartograph?.();
298
- const N = t.format === "jpeg" ? "image/jpeg" : "image/png";
299
- N === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
300
- const T = await new Promise((M) => C.toBlob(M, N, t.quality));
301
- if (!T) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
302
- return { blob: T, widthPx: b, heightPx: w, dpi: d, warnings: n };
303
- }
304
- async function Ce(r, t = {}) {
290
+ const O = e.querySelector(":scope > [data-om-carto-marks]");
291
+ for (const A of O?.querySelectorAll("line") ?? []) {
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());
294
+ }
295
+ const k = Rt(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
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?.();
298
+ const P = t.format === "jpeg" ? "image/jpeg" : "image/png";
299
+ P === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
300
+ const L = await new Promise((A) => M.toBlob(A, P, t.quality));
301
+ if (!L) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
302
+ return { blob: L, widthPx: b, heightPx: w, dpi: d, warnings: n };
303
+ }
304
+ async function xe(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;
@@ -313,46 +313,46 @@ async function Ce(r, t = {}) {
313
313
  const s = t.format === "jpeg" ? "jpg" : "png", o = n.filenames(s), a = [], l = n.index;
314
314
  try {
315
315
  if (t.page != null) {
316
- const m = Math.trunc(t.page);
317
- if (!Number.isInteger(m) || m < 0 || m >= i)
316
+ const h = Math.trunc(t.page);
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
- n.seek(m);
320
- const d = await qt(e, t, a);
321
- return { blob: d.blob, filenames: [o[m]], pages: 1, dpi: d.dpi, warnings: a };
319
+ n.seek(h);
320
+ const d = await Bt(e, t, a);
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
- for (let m = 0; m < i; m++) {
326
- n.seek(m);
327
- const d = await qt(e, t, a);
328
- u = d.dpi, c.push({ name: o[m], data: d.blob }), t.onPage?.(m + 1, i);
325
+ for (let h = 0; h < i; h++) {
326
+ n.seek(h);
327
+ const d = await Bt(e, t, a);
328
+ u = d.dpi, c.push({ name: o[h], data: d.blob }), t.onPage?.(h + 1, i);
329
329
  }
330
- return { blob: await er(c), filenames: o, pages: i, dpi: u, warnings: a };
330
+ return { blob: await rr(c), filenames: o, pages: i, dpi: u, warnings: a };
331
331
  } finally {
332
332
  n.seek(l);
333
333
  }
334
334
  }
335
- async function qt(r, t, e) {
335
+ async function Bt(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 Rt(r, t);
338
+ const n = await _t(r, t);
339
339
  return e.push(...n.warnings), n;
340
340
  }
341
- const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
341
+ const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
342
342
  __proto__: null,
343
- MAX_CANVAS_AREA: Se,
344
- MAX_CANVAS_DIMENSION: Ae,
345
- renderCartograph: Rt,
346
- renderCartographAtlas: Ce
343
+ MAX_CANVAS_AREA: Ce,
344
+ MAX_CANVAS_DIMENSION: Se,
345
+ renderCartograph: _t,
346
+ renderCartographAtlas: xe
347
347
  }, Symbol.toStringTag, { value: "Module" }));
348
- function Wt(r, t, e = {}) {
348
+ function Vt(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
- const hr = 3e4;
355
- async function Bt(r, t = hr) {
354
+ const mr = 3e4;
355
+ async function Ht(r, t = mr) {
356
356
  let e = !1;
357
357
  const n = new Promise(
358
358
  (s) => setTimeout(() => {
@@ -372,7 +372,7 @@ async function Bt(r, t = hr) {
372
372
  })();
373
373
  return await Promise.race([i, n]), { timedOut: e };
374
374
  }
375
- async function mr(r, t = {}) {
375
+ async function dr(r, t = {}) {
376
376
  if (!r.hasAttribute("allow-url-actions") || typeof document < "u" && document.documentElement?.dataset?.omHost === "editor") return null;
377
377
  const e = t.search ?? (typeof location < "u" ? location.search : "");
378
378
  if (!e) return null;
@@ -380,45 +380,45 @@ async function mr(r, t = {}) {
380
380
  i && r.setAttribute("cvd", i);
381
381
  const s = n.get("export");
382
382
  if (s) {
383
- await Bt(r, t.timeoutMs);
383
+ await Ht(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
- const m = r.querySelector("om-atlas");
387
- if (!m) throw new Error(`?page=${c} needs an <om-atlas>; this cartograph is a single sheet.`);
386
+ const h = r.querySelector("om-atlas");
387
+ if (!h) throw new Error(`?page=${c} needs an <om-atlas>; this cartograph is a single sheet.`);
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
- m.refresh?.();
391
- const h = await Ce(r, { dpi: a, format: o, page: d - 1 });
392
- for (const f of h.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
393
- return Wt(h.blob, h.filenames[0] ?? `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
390
+ h.refresh?.();
391
+ const m = await xe(r, { dpi: a, format: o, page: d - 1 });
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";
394
394
  }
395
- const u = await Rt(r, { dpi: a, format: o });
396
- for (const m of u.warnings) console.warn(`[onlymapjs/cartograph] ${m}`);
397
- return Wt(u.blob, `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
395
+ const u = await _t(r, { dpi: a, format: o });
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";
398
398
  }
399
- return n.get("print") === "1" ? (await Bt(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 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;
400
400
  }
401
- function dr() {
401
+ function fr() {
402
402
  if (typeof document > "u") return;
403
403
  const r = () => {
404
404
  for (const t of document.querySelectorAll("om-cartograph[allow-url-actions]"))
405
- mr(t).catch((e) => console.warn(`[onlymapjs/cartograph] URL action failed: ${e.message}`));
405
+ dr(t).catch((e) => console.warn(`[onlymapjs/cartograph] URL action failed: ${e.message}`));
406
406
  };
407
407
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", r, { once: !0 }) : r();
408
408
  }
409
- const xe = typeof window < "u" && typeof document < "u" && typeof customElements < "u", fr = xe ? HTMLElement : class {
409
+ const ke = typeof window < "u" && typeof document < "u" && typeof customElements < "u", pr = ke ? HTMLElement : class {
410
410
  };
411
411
  function x(r, t) {
412
- xe && (customElements.get(r) || customElements.define(r, t));
412
+ ke && (customElements.get(r) || customElements.define(r, t));
413
413
  }
414
- function pr(r) {
414
+ function gr(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 fr {
421
+ class R extends pr {
422
422
  renderQueued = !1;
423
423
  connectedCallback() {
424
424
  this.scheduleRender();
@@ -450,73 +450,73 @@ class R extends fr {
450
450
  a != null && Number.isInteger(a) ? this.style.zIndex = String(a) : this.style.removeProperty("z-index");
451
451
  }
452
452
  }
453
- const pt = "cartograph/2", Wn = ["default", "dark", "sepia", "blueprint", "minimal"], Vt = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], gr = /* @__PURE__ */ new Map([
453
+ const gt = "cartograph/2", Vn = ["default", "dark", "sepia", "blueprint", "minimal"], Kt = ["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
- ]), j = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], P = {
455
+ ]), z = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], T = {
456
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"],
457
- "om-frame": [...j, "src", "mode", "center", "zoom", "bearing", "pitch", "dpi", "crs", "corners", "crs-def", "overview-of", "overview-stroke", "atlas-fit", "atlas-margin", "frame-stroke", "frame-bg"],
458
- "om-legend": [...j, "for", "title", "columns", "derived"],
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
+ "om-legend": [...z, "for", "title", "columns", "derived"],
459
459
  "om-legend-row": ["layer", "match", "label", "hide", "order", "color", "shape"],
460
460
  // NOTE: the discriminator on furniture is `kind`, never `style` — `style` is
461
461
  // the global HTML attribute the runtime itself writes for mm placement, so
462
462
  // `style="double"` would be erased on the first render. `kind` also matches
463
463
  // om-text/om-shape, so the whole vocabulary has ONE discriminator word.
464
- "om-scalebar": [...j, "for", "units", "segments", "segment-length", "kind"],
465
- "om-north": [...j, "for", "kind"],
466
- "om-graticule": [...j, "for", "crs", "crs-def", "interval", "interval-x", "interval-y", "kind", "labels", "format"],
467
- "om-text": [...j, "kind", "font-size", "weight", "align", "font", "color", "bg"],
468
- "om-shape": [...j, "kind", "fill", "fill-opacity", "stroke", "stroke-width", "radius"],
469
- "om-image": [...j, "src", "fit"],
464
+ "om-scalebar": [...z, "for", "units", "segments", "segment-length", "kind"],
465
+ "om-north": [...z, "for", "kind"],
466
+ "om-graticule": [...z, "for", "crs", "crs-def", "interval", "interval-x", "interval-y", "kind", "labels", "format"],
467
+ "om-text": [...z, "kind", "font-size", "weight", "align", "font", "color", "bg"],
468
+ "om-shape": [...z, "kind", "fill", "fill-opacity", "stroke", "stroke-width", "radius"],
469
+ "om-image": [...z, "src", "fit"],
470
470
  "om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name"]
471
- }, gt = Object.keys(P), br = ["metric", "imperial", "nautical"], yr = 0.3048, wr = 1609.344, vr = 1852;
472
- function Mr(r) {
473
- return r != null && br.includes(r) ? r : null;
471
+ }, bt = Object.keys(T), yr = ["metric", "imperial", "nautical"], wr = 0.3048, vr = 1609.344, Mr = 1852;
472
+ function Ar(r) {
473
+ return r != null && yr.includes(r) ? r : null;
474
474
  }
475
- function ke(r) {
475
+ function $e(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 Ht = {
480
+ const Yt = {
481
481
  // Finest first; the largest tier whose snapped length is ≥ 1 unit wins.
482
482
  metric: [
483
483
  { metersPerUnit: 1, label: "m" },
484
484
  { metersPerUnit: 1e3, label: "km" }
485
485
  ],
486
486
  imperial: [
487
- { metersPerUnit: yr, label: "ft" },
488
- { metersPerUnit: wr, label: "mi" }
487
+ { metersPerUnit: wr, label: "ft" },
488
+ { metersPerUnit: vr, label: "mi" }
489
489
  ],
490
- nautical: [{ metersPerUnit: vr, label: "nmi" }]
490
+ nautical: [{ metersPerUnit: Mr, label: "nmi" }]
491
491
  };
492
- function $e({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
492
+ function Ee({ 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 = Ht[n] ?? Ht.metric, a = t / s * r;
494
+ const s = Number.isInteger(e) && e > 0 ? e : 4, o = Yt[n] ?? Yt.metric, a = t / s * r;
495
495
  let l, c;
496
496
  if (i != null && Number.isFinite(i) && i > 0)
497
- l = i, c = Yt(o, l);
497
+ l = i, c = Xt(o, l);
498
498
  else {
499
- c = Yt(o, a);
500
- const f = ke(a / c.metersPerUnit);
499
+ c = Xt(o, a);
500
+ const f = $e(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 m = l / c.metersPerUnit, d = m < 1 ? 2 : m < 10 && !Number.isInteger(m) ? 1 : 0, h = Array.from({ length: s + 1 }, (f, p) => (p * m).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, p) => (p * h).toFixed(d));
507
507
  return {
508
508
  segmentMeters: l,
509
509
  segmentMm: u,
510
510
  segments: s,
511
511
  totalMm: u * s,
512
- labels: h,
512
+ labels: m,
513
513
  unitLabel: c.label,
514
514
  // 1 mm on the page is groundMetersPerMm metres on the ground; the RF is
515
515
  // that ratio in consistent units (mm : mm).
516
516
  scaleDenominator: r * 1e3
517
517
  };
518
518
  }
519
- function Ar(r, t, e) {
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
522
  const g = t === "double" ? 2 : 1, b = o / g;
@@ -538,38 +538,38 @@ function Ar(r, t, e) {
538
538
  u.push({ x1: w, y1: a, x2: w, y2: a + o });
539
539
  }
540
540
  }
541
- const m = r.labels.length - 1, d = r.labels.map((g, b) => ({
541
+ const h = r.labels.length - 1, d = r.labels.map((g, b) => ({
542
542
  // The end label carries the unit so the bar reads "0 2 4 6 8 km".
543
- text: b === m ? `${g} ${r.unitLabel}` : g,
543
+ text: b === h ? `${g} ${r.unitLabel}` : g,
544
544
  // Keep the end label inside the drawn width rather than hanging off it.
545
- x: b === m ? r.totalMm : b * l,
545
+ x: b === h ? r.totalMm : b * l,
546
546
  y: a + o + n,
547
- anchor: b === 0 ? "start" : b === m ? "end" : "middle",
547
+ anchor: b === 0 ? "start" : b === h ? "end" : "middle",
548
548
  index: b
549
- })), h = (g) => g.length * n * 0.62, f = [];
549
+ })), m = (g) => g.length * n * 0.62, f = [];
550
550
  let p = -1 / 0;
551
551
  for (const g of d) {
552
- const b = h(g.text) / 2, w = g.anchor === "start" ? g.x : g.anchor === "end" ? g.x - b * 2 : g.x - b, y = w + h(g.text);
553
- if (!(!(g.index === 0 || g.index === m) && w < p + n * 0.4)) {
554
- if (g.index === m && w < p + n * 0.4)
555
- for (; f.length > 1 && f[f.length - 1].x + h(f[f.length - 1].text) / 2 > w - n * 0.4; ) f.pop();
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)
555
+ for (; f.length > 1 && f[f.length - 1].x + m(f[f.length - 1].text) / 2 > w - n * 0.4; ) f.pop();
556
556
  f.push({ text: g.text, x: g.x, y: g.y, anchor: g.anchor }), p = 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 Yt(r, t) {
561
+ function Xt(r, t) {
562
562
  let e = r[0];
563
563
  for (const n of r)
564
564
  t / n.metersPerUnit >= 1 && (e = n);
565
565
  return e;
566
566
  }
567
- const Sr = " ";
568
- function Cr(r) {
569
- return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g, Sr);
567
+ const Cr = " ";
568
+ function xr(r) {
569
+ return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g, Cr);
570
570
  }
571
- const Ee = /\{\{\s*([\w.]+)\s*\}\}/g;
572
- function xr(r, t) {
571
+ const Ne = /\{\{\s*([\w.]+)\s*\}\}/g;
572
+ function kr(r, t) {
573
573
  if (r.startsWith("atlas.")) return t.atlas?.[r.slice(6)];
574
574
  if (r.startsWith("frame.")) {
575
575
  const e = r.slice(6), n = e.lastIndexOf(".");
@@ -581,18 +581,18 @@ function xr(r, t) {
581
581
  }
582
582
  return t.page[r];
583
583
  }
584
- function Ne(r, t) {
584
+ function Pe(r, t) {
585
585
  const e = [];
586
- return { text: r.replace(Ee, (i, s) => {
587
- const o = xr(s, t);
586
+ return { text: r.replace(Ne, (i, s) => {
587
+ const o = kr(s, t);
588
588
  return o === void 0 ? (e.push(s), i) : o;
589
589
  }), unresolved: e };
590
590
  }
591
- function kr(r) {
592
- return [...r.matchAll(Ee)].map((t) => t[1]);
591
+ function $r(r) {
592
+ return [...r.matchAll(Ne)].map((t) => t[1]);
593
593
  }
594
- const Kt = /* @__PURE__ */ new WeakMap();
595
- function $r(r, t) {
594
+ const Jt = /* @__PURE__ */ new WeakMap();
595
+ function Er(r, t) {
596
596
  const e = [], n = r.ownerDocument ?? (typeof document < "u" ? document : null);
597
597
  if (!n) return e;
598
598
  const i = n.createTreeWalker(
@@ -602,58 +602,58 @@ function $r(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 = Kt.get(o);
605
+ let a = Jt.get(o);
606
606
  if (a === void 0) {
607
607
  if (a = o.data, !a.includes("{{")) continue;
608
- Kt.set(o, a);
608
+ Jt.set(o, a);
609
609
  }
610
- const l = Ne(a, t);
610
+ const l = Pe(a, t);
611
611
  o.data !== l.text && (o.data = l.text), e.push(...l.unresolved);
612
612
  }
613
613
  return e;
614
614
  }
615
- function Er(r = /* @__PURE__ */ new Date()) {
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 Et = "data-om-carto-unlinked";
619
- function Pe(r) {
618
+ const Nt = "data-om-carto-unlinked";
619
+ function Te(r) {
620
620
  return r.closest("om-cartograph");
621
621
  }
622
- function Te(r, t) {
623
- const e = Pe(r);
622
+ function Le(r, t) {
623
+ const e = Te(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 Le(r) {
629
+ function Fe(r) {
630
630
  return [...r.querySelectorAll("om-frame")];
631
631
  }
632
- function Nr(r) {
633
- const t = Pe(r);
632
+ function Pr(r) {
633
+ const t = Te(r);
634
634
  if (!t) return null;
635
- const e = Le(t);
635
+ const e = Fe(t);
636
636
  return e.length === 1 ? e[0] : null;
637
637
  }
638
- function O(r) {
638
+ function _(r) {
639
639
  const t = r.getAttribute("for");
640
- return t ? Te(r, t) : Nr(r);
640
+ return t ? Le(r, t) : Pr(r);
641
641
  }
642
- function W(r, t) {
643
- let e = r.querySelector(`:scope > [${Et}]`);
642
+ function G(r, t) {
643
+ let e = r.querySelector(`:scope > [${Nt}]`);
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(Et, ""), 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(Nt, ""), 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
- function Pr(r) {
652
- r.querySelector(`:scope > [${Et}]`)?.remove();
651
+ function Tr(r) {
652
+ r.querySelector(`:scope > [${Nt}]`)?.remove();
653
653
  }
654
- const Xt = "data-om-carto-page", Zt = "data-om-carto-marks", bt = "data-om-carto-credit", yt = "Built with OnlyMap by NIKA · free for non-commercial use", rt = 2, Jt = 1.2, wt = 2.4, Qt = 1.5, vt = 1.2, te = 0.3, ee = 0.8, Mt = "http://www.w3.org/2000/svg", Tr = 6e4;
655
- class Fe extends R {
656
- static observedAttributes = [...P["om-cartograph"]];
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;
655
+ class Ie extends R {
656
+ static observedAttributes = [...T["om-cartograph"]];
657
657
  frameListenerBound = !1;
658
658
  /** Fields of the atlas page currently displayed, for {{atlas.<field>}}. */
659
659
  atlasFields;
@@ -661,7 +661,7 @@ class Fe extends R {
661
661
  unsubscribeLicense = null;
662
662
  /** The resolved page box, mm — furniture and export read this, never the attributes. */
663
663
  get pageSize() {
664
- return ct(this.getAttribute("size"), this.getAttribute("width"), this.getAttribute("height"), this.getAttribute("orientation"));
664
+ return ut(this.getAttribute("size"), this.getAttribute("width"), this.getAttribute("height"), this.getAttribute("orientation"));
665
665
  }
666
666
  /** Bleed in mm (0 when unset) — extends the printed sheet past the trim. */
667
667
  get bleedMm() {
@@ -671,8 +671,10 @@ class Fe extends R {
671
671
  connectedCallback() {
672
672
  super.connectedCallback(), this.frameListenerBound || (this.frameListenerBound = !0, this.addEventListener("om-frame-ready", () => {
673
673
  this.atlas?.refresh(), this.refreshTokens(), this.refreshFurniture(), this.renderCredit();
674
+ }), this.addEventListener("om-frame-view", () => {
675
+ this.refreshTokens(), this.refreshFurniture();
674
676
  })), !this.creditObserver && typeof MutationObserver < "u" && (this.creditObserver = new MutationObserver(() => {
675
- this.querySelector(`:scope > [${bt}]`) || this.renderCredit();
677
+ this.querySelector(`:scope > [${yt}]`) || this.renderCredit();
676
678
  }), this.creditObserver.observe(this, { childList: !0 }));
677
679
  }
678
680
  disconnectedCallback() {
@@ -689,9 +691,9 @@ class Fe extends R {
689
691
  * runtime's job (issue #41 §9: the om-map carries the key).
690
692
  */
691
693
  renderCredit() {
692
- const t = G();
694
+ const t = H();
693
695
  t && !this.unsubscribeLicense && typeof t.subscribeLicense == "function" && (this.unsubscribeLicense = t.subscribeLicense(() => this.renderCredit()));
694
- const e = t ? t.getEntitlements().hideBadge : !1, n = [...this.querySelectorAll("om-text")].some((o) => /onlymap/i.test(o.textContent ?? "")), i = this.querySelector(`:scope > [${bt}]`);
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}]`);
695
697
  if (e || n) {
696
698
  i?.remove();
697
699
  return;
@@ -701,15 +703,15 @@ class Fe extends R {
701
703
  return;
702
704
  }
703
705
  const s = this.ownerDocument.createElement("div");
704
- s.setAttribute(bt, ""), s.setAttribute("z", "2147483644"), s.textContent = yt, s.style.cssText = `position:absolute;left:${rt}mm;bottom:${Jt}mm;z-index:2147483644;font:${wt}mm/${Qt} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${te}mm ${vt}mm;border-radius:${ee}mm;pointer-events:none;`, this.armCreditPainter(s), this.appendChild(s);
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);
705
707
  }
706
708
  /** Give the runtime-owned DOM credit the same canvas paint contract as authored furniture. */
707
709
  armCreditPainter(t) {
708
710
  t.paintCartograph = (e, n) => {
709
- const i = (c) => c * n.pxPerMm, o = wt * Qt + te * 2, a = this.pageSize.heightMm - Jt - o;
710
- e.save(), e.font = `${i(wt)}px system-ui, sans-serif`;
711
- const l = e.measureText(yt).width / n.pxPerMm + vt * 2;
712
- e.fillStyle = "rgba(255,255,255,.72)", e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(i(rt), i(a), i(l), i(o), i(ee)) : e.rect(i(rt), i(a), i(l), i(o)), e.fill(), e.fillStyle = "#374151", e.textAlign = "left", e.textBaseline = "middle", e.fillText(yt, i(rt + vt), i(a + o / 2)), e.restore();
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();
713
715
  };
714
716
  }
715
717
  /**
@@ -738,12 +740,12 @@ class Fe extends R {
738
740
  try {
739
741
  window.print();
740
742
  } finally {
741
- s || setTimeout(o, Tr);
743
+ s || setTimeout(o, Lr);
742
744
  }
743
745
  }
744
746
  /** Render the whole page to one image, for `flatten`. */
745
747
  async buildFlattenedImage(t) {
746
- const { renderCartograph: e } = await Promise.resolve().then(() => ur), { blob: n } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
748
+ const { renderCartograph: e } = await Promise.resolve().then(() => hr), { blob: n } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
747
749
  i.src = URL.createObjectURL(n), i.setAttribute("data-om-carto-flattened", "");
748
750
  const s = this.bleedMm;
749
751
  return i.style.cssText = `position:absolute;left:${-s}mm;top:${-s}mm;width:calc(100% + ${s * 2}mm);height:calc(100% + ${s * 2}mm);z-index:2147483645;`, await i.decode().catch(() => {
@@ -764,20 +766,20 @@ class Fe extends R {
764
766
  }
765
767
  /** Values every `{{token}}` on this page resolves against. */
766
768
  tokenContext() {
767
- const t = /* @__PURE__ */ new Map(), e = Le(this);
769
+ const t = /* @__PURE__ */ new Map(), e = Fe(this);
768
770
  for (const s of e) {
769
771
  const o = s.georef, a = o?.groundMetersPerMm() ?? 0;
770
772
  t.set(s.id, {
771
- scale: a > 0 ? Cr(a * 1e3) : void 0,
773
+ scale: a > 0 ? xr(a * 1e3) : void 0,
772
774
  crs: o?.crs
773
775
  });
774
776
  }
775
- const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (s) => Ne(this.getAttribute(s) ?? "", n).text;
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;
776
778
  return {
777
779
  page: {
778
780
  title: i("title"),
779
781
  attribution: i("attribution"),
780
- date: Er(),
782
+ date: Nr(),
781
783
  notes: i("notes")
782
784
  },
783
785
  frames: t,
@@ -795,8 +797,8 @@ class Fe extends R {
795
797
  renderNow() {
796
798
  const { widthMm: t, heightMm: e } = this.pageSize, n = this.bleedMm;
797
799
  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";
798
- let i = this.querySelector(`style[${Xt}]`);
799
- i || (i = document.createElement("style"), i.setAttribute(Xt, ""), this.prepend(i));
800
+ let i = this.querySelector(`style[${Zt}]`);
801
+ i || (i = document.createElement("style"), i.setAttribute(Zt, ""), this.prepend(i));
800
802
  const s = t + n * 2, o = e + n * 2;
801
803
  i.textContent = `@page { size: ${s}mm ${o}mm; margin: 0; }
802
804
  @media print { html, body { margin: 0; padding: 0; } om-cartograph { break-after: page; } }`, this.renderPrintMarks(t, e, n), this.applyCvd(), this.refreshTokens(), this.renderCredit();
@@ -811,26 +813,26 @@ class Fe extends R {
811
813
  * worse than no guide.
812
814
  */
813
815
  renderPrintMarks(t, e, n) {
814
- 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}]`);
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}]`);
815
817
  if (!i && !o) {
816
818
  a?.remove();
817
819
  return;
818
820
  }
819
- const l = this.ownerDocument, c = a ?? l.createElementNS(Mt, "svg");
820
- 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) {
821
- const u = Math.min(n, 4), m = Math.min(n * 0.35, 1.5), d = [];
822
- for (const h of [0, t])
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) {
823
+ const u = Math.min(n, 4), h = Math.min(n * 0.35, 1.5), d = [];
824
+ for (const m of [0, t])
823
825
  for (const f of [0, e]) {
824
- const p = h === 0 ? -1 : 1, g = f === 0 ? -1 : 1;
825
- d.push([h + p * m, f, h + p * (m + u), f]), d.push([h, f + g * m, h, f + g * (m + u)]);
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)]);
826
828
  }
827
- for (const [h, f, p, g] of d) {
828
- const b = l.createElementNS(Mt, "line");
829
- b.setAttribute("x1", String(h)), 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);
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);
830
832
  }
831
833
  }
832
834
  if (o) {
833
- const u = l.createElementNS(Mt, "rect");
835
+ const u = l.createElementNS(At, "rect");
834
836
  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);
835
837
  }
836
838
  a || this.appendChild(c);
@@ -844,25 +846,25 @@ class Fe extends R {
844
846
  * injected only when a page actually asks for one.
845
847
  */
846
848
  applyCvd() {
847
- const t = Ft(this.getAttribute("cvd"));
849
+ const t = Rt(this.getAttribute("cvd"));
848
850
  if (!t) {
849
851
  this.style.removeProperty("filter");
850
852
  return;
851
853
  }
852
- ar(this.ownerDocument), this.style.filter = `url(#${Me(t)})`;
854
+ lr(this.ownerDocument), this.style.filter = `url(#${Ae(t)})`;
853
855
  }
854
856
  }
855
- x("om-cartograph", Fe);
856
- function Lr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
857
+ x("om-cartograph", Ie);
858
+ function Fr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
857
859
  const s = n > 0 ? n : e * 1.2, o = [];
858
860
  for (const c of r.split(/\r?\n/)) {
859
- const u = c.split(/\s+/).filter((h) => h !== "");
861
+ const u = c.split(/\s+/).filter((m) => m !== "");
860
862
  if (u.length === 0) {
861
863
  o.push({ text: "", baselineY: 0, width: 0 });
862
864
  continue;
863
865
  }
864
- const m = (h) => {
865
- let f = h;
866
+ const h = (m) => {
867
+ let f = m;
866
868
  for (; i(f) > t && f.length > 1; ) {
867
869
  let p = f.length - 1;
868
870
  for (; p > 1 && i(f.slice(0, p)) > t; ) p--;
@@ -871,9 +873,9 @@ function Lr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
871
873
  return f;
872
874
  };
873
875
  let d = "";
874
- for (const h of u) {
875
- const f = d === "" ? h : `${d} ${h}`;
876
- d === "" ? d = m(h) : i(f) > t ? (o.push({ text: d, baselineY: 0, width: i(d) }), d = m(h)) : d = f;
876
+ for (const m of u) {
877
+ const f = d === "" ? m : `${d} ${m}`;
878
+ d === "" ? d = h(m) : i(f) > t ? (o.push({ text: d, baselineY: 0, width: i(d) }), d = h(m)) : d = f;
877
879
  }
878
880
  o.push({ text: d, baselineY: 0, width: i(d) });
879
881
  }
@@ -883,16 +885,16 @@ function Lr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
883
885
  c.baselineY = a + u * s, c.width > l && (l = c.width);
884
886
  }), { lines: o, lineHeight: s, maxWidth: l };
885
887
  }
886
- function Bn(r) {
888
+ function Hn(r) {
887
889
  if (typeof document > "u") return null;
888
890
  const e = document.createElement("canvas").getContext("2d");
889
891
  return e ? (e.font = r, (n) => e.measureText(n).width) : null;
890
892
  }
891
- function Fr(r, t, e) {
893
+ function Ir(r, t, e) {
892
894
  return r === "center" ? (t - e) / 2 : r === "end" || r === "right" ? t - e : 0;
893
895
  }
894
- class Ie extends R {
895
- static observedAttributes = [...P["om-text"]];
896
+ class Re extends R {
897
+ static observedAttributes = [...T["om-text"]];
896
898
  renderNow() {
897
899
  this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden";
898
900
  const t = this.getAttribute("font-size");
@@ -911,18 +913,18 @@ class Ie extends R {
911
913
  /** Re-run token substitution from the authored templates. */
912
914
  resolveTokens() {
913
915
  const t = this.closest("om-cartograph");
914
- t && typeof t.tokenContext == "function" && $r(this, t.tokenContext());
916
+ t && typeof t.tokenContext == "function" && Er(this, t.tokenContext());
915
917
  }
916
918
  paintCartograph(t, e) {
917
- const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
919
+ const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
918
920
  if (s <= 0 || o <= 0) return;
919
- const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = L(a?.backgroundColor);
921
+ const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
920
922
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
921
923
  const c = (this.textContent ?? "").trim();
922
924
  if (c === "") return;
923
- const u = $t(a?.fontSize, 12), m = a?.lineHeight === "normal" ? u * 1.4 : $t(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", h = a?.fontWeight || "400", f = u * e.scale, p = m * e.scale, g = `${h} ${f}px ${d}`;
924
- t.save(), t.font = g, t.fillStyle = L(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
925
- const b = Lr({
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({
926
928
  text: c,
927
929
  maxWidth: s,
928
930
  fontSizePx: f,
@@ -931,28 +933,34 @@ class Ie extends R {
931
933
  }), w = a?.textAlign || "start";
932
934
  for (const y of b.lines) {
933
935
  if (y.baselineY > o + p) break;
934
- t.fillText(y.text, Fr(w, s, y.width), y.baselineY);
936
+ t.fillText(y.text, Ir(w, s, y.width), y.baselineY);
935
937
  }
936
938
  t.restore();
937
939
  }
938
940
  }
939
- x("om-text", Ie);
940
- const Ir = 63710087714e-4;
941
- let Rr = Ir;
941
+ x("om-text", Re);
942
+ const Rr = 63710087714e-4;
943
+ let Or = Rr;
942
944
  const nt = Math.PI / 180;
943
- function Re(r, t, e = Rr) {
945
+ function _r(r, t, e = Or) {
944
946
  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;
945
947
  return 2 * e * Math.asin(Math.min(1, Math.sqrt(a)));
946
948
  }
947
- const ut = 6378137, re = Math.PI / 180, Nt = 180 / Math.PI, ne = 85.0511287798066;
948
- function _r([r, t]) {
949
- const e = Math.max(-ne, Math.min(ne, t));
950
- return [ut * r * re, ut * Math.log(Math.tan(Math.PI / 4 + e * re / 2))];
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));
952
+ return [K * r * ht, K * Math.log(Math.tan(Math.PI / 4 + e * ht / 2))];
951
953
  }
952
- function Or([r, t]) {
953
- return [r / ut * Nt, (2 * Math.atan(Math.exp(t / ut)) - Math.PI / 2) * Nt];
954
+ const oe = 89.9;
955
+ function zr([r, t]) {
956
+ const e = Math.max(-oe, Math.min(oe, t));
957
+ return [K * r * ht, K * Math.log(Math.tan(Math.PI / 4 + e * ht / 2))];
954
958
  }
955
- const _e = { code: "EPSG:3857", forward: _r, inverse: Or }, Ur = { code: "EPSG:4326", forward: ([r, t]) => [r, t], inverse: ([r, t]) => [r, t] };
959
+ const Dr = { code: "EPSG:3857", forward: zr, inverse: Oe };
960
+ function Oe([r, t]) {
961
+ return [r / K * Pt, (2 * Math.atan(Math.exp(t / K)) - Math.PI / 2) * Pt];
962
+ }
963
+ const _e = { code: "EPSG:3857", forward: Ur, inverse: Oe }, jr = { code: "EPSG:4326", forward: ([r, t]) => [r, t], inverse: ([r, t]) => [r, t] };
956
964
  function Y(r) {
957
965
  if (r == null) return null;
958
966
  const t = r.trim();
@@ -960,14 +968,14 @@ function Y(r) {
960
968
  const e = /^(?:epsg:{1,2})?(\d{4,6})$/i.exec(t);
961
969
  return e ? `EPSG:${e[1]}` : t.toUpperCase();
962
970
  }
963
- function K(r) {
971
+ function X(r) {
964
972
  const t = Y(r) ?? "EPSG:3857";
965
- return t === "EPSG:3857" || t === "EPSG:900913" ? _e : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? Ur : null;
973
+ return t === "EPSG:3857" || t === "EPSG:900913" ? _e : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? jr : null;
966
974
  }
967
- async function Oe(r, t) {
968
- const e = K(r);
975
+ async function Ue(r, t) {
976
+ const e = X(r);
969
977
  if (e && !t) return e;
970
- const n = Y(r) ?? "EPSG:3857", i = t?.trim() || await zr(n);
978
+ const n = Y(r) ?? "EPSG:3857", i = t?.trim() || await Gr(n);
971
979
  if (!i) return null;
972
980
  const s = (await import("./index-CcLC9jE5.js")).default, a = s(i, "+proj=longlat +datum=WGS84 +no_defs");
973
981
  return {
@@ -976,18 +984,18 @@ async function Oe(r, t) {
976
984
  inverse: (l) => a.forward(l)
977
985
  };
978
986
  }
979
- function ie(r, t) {
987
+ function se(r, t) {
980
988
  return !Number.isInteger(r) || r < 1 || r > 60 ? null : `+proj=utm +zone=${r}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
981
989
  }
982
- async function zr(r) {
990
+ async function Gr(r) {
983
991
  const t = Number(/^EPSG:(\d+)$/.exec(r)?.[1]);
984
992
  if (!Number.isFinite(t)) return null;
985
- if (t >= 32601 && t <= 32660) return ie(t - 32600, "N");
986
- if (t >= 32701 && t <= 32760) return ie(t - 32700, "S");
993
+ if (t >= 32601 && t <= 32660) return se(t - 32600, "N");
994
+ if (t >= 32701 && t <= 32760) return se(t - 32700, "S");
987
995
  const { CRS_DEFS: e } = await import("./crs-DsDQ4Q4i.js");
988
996
  return e[t]?.def ?? null;
989
997
  }
990
- function jr(r, t) {
998
+ function qr(r, t) {
991
999
  const e = t.length, n = r.map((i, s) => [...i, t[s]]);
992
1000
  for (let i = 0; i < e; i++) {
993
1001
  let s = i;
@@ -1003,23 +1011,23 @@ function jr(r, t) {
1003
1011
  }
1004
1012
  return n.map((i, s) => i[e] / i[s]);
1005
1013
  }
1006
- function Dr(r, t) {
1014
+ function Wr(r, t) {
1007
1015
  if (r.length !== 4 || t.length !== 4) return null;
1008
- const e = r.reduce((m, d) => m + d[0], 0) / 4, n = r.reduce((m, d) => m + d[1], 0) / 4, i = r.reduce((m, d) => m + Math.hypot(d[0] - e, d[1] - n), 0) / 4, s = i > 1e-12 ? Math.SQRT2 / i : 1, o = (m) => [(m[0] - e) * s, (m[1] - n) * s], a = [], l = [];
1009
- for (let m = 0; m < 4; m++) {
1010
- const [d, h] = o(r[m]), [f, p] = t[m];
1011
- a.push([d, h, 1, 0, 0, 0, -d * f, -h * f]), l.push(f), a.push([0, 0, 0, d, h, 1, -d * p, -h * p]), l.push(p);
1012
- }
1013
- const c = jr(a, l);
1014
- if (!c || c.some((m) => !Number.isFinite(m))) return null;
1015
- const u = (m) => [m[0] / s + e, m[1] / s + n];
1016
+ 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
+ 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);
1020
+ }
1021
+ const c = qr(a, l);
1022
+ if (!c || c.some((h) => !Number.isFinite(h))) return null;
1023
+ const u = (h) => [h[0] / s + e, h[1] / s + n];
1016
1024
  return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: o, denormalize: u };
1017
1025
  }
1018
- function oe(r, [t, e]) {
1026
+ function ae(r, [t, e]) {
1019
1027
  const n = r[6] * t + r[7] * e + r[8];
1020
1028
  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];
1021
1029
  }
1022
- function Gr(r) {
1030
+ function Br(r) {
1023
1031
  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);
1024
1032
  return !Number.isFinite(u) || Math.abs(u) < 1e-15 ? null : [
1025
1033
  (s * c - o * l) / u,
@@ -1033,49 +1041,60 @@ function Gr(r) {
1033
1041
  (t * s - e * i) / u
1034
1042
  ];
1035
1043
  }
1036
- function se(r, t) {
1044
+ function Vr(r, t) {
1037
1045
  let e = r;
1038
1046
  for (; e - t > 180; ) e -= 360;
1039
1047
  for (; t - e > 180; ) e += 360;
1040
1048
  return e;
1041
1049
  }
1042
- const qr = (r) => {
1050
+ const ze = (r) => {
1043
1051
  let t = ((r + 180) % 360 + 360) % 360 - 180;
1044
1052
  return t === -180 && (t = 180), t;
1045
1053
  };
1046
- function ht({ corners: r, widthMm: t, heightMm: e, crsForward: n }) {
1047
- const i = n ?? _e, s = r[0][0], o = r.map(([h, f]) => [se(h, s), f]), a = o.map((h) => i.forward(h)), l = [
1054
+ 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 = [
1048
1056
  [0, 0],
1049
1057
  [t, 0],
1050
1058
  [t, e],
1051
1059
  [0, e]
1052
- ], c = t > 0 && e > 0 ? Dr(a, l) : null, u = c ? Gr(c.matrix) : null, m = !c || !u, d = {
1053
- crs: i.code,
1054
- corners: o,
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);
1062
+ if (!M) return null;
1063
+ for (let v = 1; v <= w; v++) {
1064
+ const N = g.unproject(t * v / w, b);
1065
+ if (!N) return null;
1066
+ y += _r(M, N), M = N;
1067
+ }
1068
+ return y;
1069
+ }, g = {
1070
+ crs: s.code,
1071
+ corners: c,
1055
1072
  widthMm: t,
1056
1073
  heightMm: e,
1057
- degenerate: m,
1058
- project(h) {
1059
- if (!c) return null;
1060
- const f = i.forward([se(h[0], s), h[1]]), p = oe(c.matrix, c.normalize(f));
1061
- return p && Number.isFinite(p[0]) && Number.isFinite(p[1]) ? { xMm: p[0], yMm: p[1] } : null;
1074
+ degenerate: f,
1075
+ continuous: i,
1076
+ project(b) {
1077
+ if (!d) return null;
1078
+ const w = s.forward([a(b[0]), b[1]]), y = ae(d.matrix, d.normalize(w));
1079
+ return y && Number.isFinite(y[0]) && Number.isFinite(y[1]) ? { xMm: y[0], yMm: y[1] } : null;
1062
1080
  },
1063
- unproject(h, f) {
1064
- if (!c || !u) return null;
1065
- const p = oe(u, [h, f]);
1066
- if (!p) return null;
1067
- const g = i.inverse(c.denormalize(p));
1068
- return Number.isFinite(g[0]) && Number.isFinite(g[1]) ? [qr(g[0]), g[1]] : null;
1081
+ unproject(b, w) {
1082
+ if (!d || !m) return null;
1083
+ const y = ae(m, [b, w]);
1084
+ if (!y) return null;
1085
+ const M = s.inverse(d.denormalize(y));
1086
+ return Number.isFinite(M[0]) && Number.isFinite(M[1]) ? [l(M[0]), M[1]] : null;
1069
1087
  },
1070
1088
  groundMetersPerMm() {
1071
- if (m || t <= 0) return 0;
1072
- const h = d.unproject(0, e / 2), f = d.unproject(t, e / 2);
1073
- return !h || !f ? 0 : Re(h, f) / t;
1074
- }
1089
+ if (f || t <= 0) return 0;
1090
+ const b = p(e / 2);
1091
+ return b == null ? 0 : b / t;
1092
+ },
1093
+ rowGroundMeters: p
1075
1094
  };
1076
- return d;
1095
+ return g;
1077
1096
  }
1078
- function mt(r) {
1097
+ function dt(r) {
1079
1098
  if (r == null || r.trim() === "") return null;
1080
1099
  let t;
1081
1100
  try {
@@ -1110,27 +1129,27 @@ function mt(r) {
1110
1129
  }
1111
1130
  return e;
1112
1131
  }
1113
- function Wr(r) {
1132
+ function Hr(r) {
1114
1133
  if (r.degenerate) return null;
1115
1134
  const t = r.unproject(r.widthMm / 2, r.heightMm / 2);
1116
1135
  if (!t) return null;
1117
1136
  const n = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = r.project(t), s = r.project(n);
1118
1137
  if (!i || !s) return null;
1119
1138
  const o = s.xMm - i.xMm, a = s.yMm - i.yMm;
1120
- return Math.abs(o) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(o, -a) * Nt % 360 + 360) % 360;
1139
+ return Math.abs(o) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(o, -a) * Pt % 360 + 360) % 360;
1121
1140
  }
1122
- function Br(r) {
1141
+ function Kr(r) {
1123
1142
  if (r.degenerate) return null;
1124
1143
  const { widthMm: t, heightMm: e } = r, n = [];
1125
1144
  for (const o of [0.02, 0.5, 0.98]) {
1126
- const a = r.unproject(0, e * o), l = r.unproject(t, e * o);
1127
- if (!a || !l) return null;
1128
- n.push(Re(a, l) / t);
1145
+ const a = r.rowGroundMeters(e * o);
1146
+ if (a == null || !(a > 0)) return null;
1147
+ n.push(a / t);
1129
1148
  }
1130
1149
  const i = Math.min(...n), s = Math.max(...n);
1131
1150
  return i > 0 ? (s - i) / i : null;
1132
1151
  }
1133
- function Vn(r, t, e, n) {
1152
+ function Kn(r, t, e, n) {
1134
1153
  return [
1135
1154
  [r, n],
1136
1155
  [e, n],
@@ -1138,8 +1157,8 @@ function Vn(r, t, e, n) {
1138
1157
  [r, t]
1139
1158
  ];
1140
1159
  }
1141
- const Vr = (r) => r.toLowerCase().startsWith("on");
1142
- function Hr(r, t) {
1160
+ const Yr = (r) => r.toLowerCase().startsWith("on");
1161
+ function Xr(r, t) {
1143
1162
  const e = (n) => {
1144
1163
  const i = n.tagName.toLowerCase();
1145
1164
  if (i === "script") {
@@ -1150,7 +1169,7 @@ function Hr(r, t) {
1150
1169
  if (i === "style" || i === "link" || i === "iframe" || i === "object" || i === "embed") return null;
1151
1170
  const s = t.createElement(i);
1152
1171
  for (const o of n.attributes)
1153
- Vr(o.name) || /^\s*javascript:/i.test(o.value) || s.setAttribute(o.name, o.value);
1172
+ Yr(o.name) || /^\s*javascript:/i.test(o.value) || s.setAttribute(o.name, o.value);
1154
1173
  for (const o of n.childNodes)
1155
1174
  if (o.nodeType === 3) s.appendChild(t.createTextNode(o.textContent ?? ""));
1156
1175
  else if (o.nodeType === 1) {
@@ -1161,16 +1180,16 @@ function Hr(r, t) {
1161
1180
  };
1162
1181
  return e(r);
1163
1182
  }
1164
- async function Yr(r, t = document) {
1183
+ async function Jr(r, t = document) {
1165
1184
  const e = await fetch(r, { credentials: "same-origin" });
1166
1185
  if (!e.ok) throw new Error(`fetching ${r} failed with HTTP ${e.status}`);
1167
1186
  const n = await e.text(), s = new DOMParser().parseFromString(n, "text/html").querySelector("om-map");
1168
1187
  if (!s) throw new Error(`${r} contains no <om-map>`);
1169
- const o = Hr(s, t);
1188
+ const o = Xr(s, t);
1170
1189
  if (!o) throw new Error(`${r} could not be adopted`);
1171
1190
  return o;
1172
1191
  }
1173
- function Q(r) {
1192
+ function ct(r) {
1174
1193
  const t = r.getAttribute("center"), e = r.getAttribute("zoom");
1175
1194
  if (!t || e == null || e.trim() === "") return null;
1176
1195
  const n = Number(e);
@@ -1191,8 +1210,8 @@ function Q(r) {
1191
1210
  pitch: Number(r.getAttribute("pitch")) || 0
1192
1211
  };
1193
1212
  }
1194
- function Kr(r, t, e, n, i = 60) {
1195
- const s = (l) => Pt(r, { ...t, pitch: l }, e, n) !== null;
1213
+ function Yn(r, t, e, n, i = 60) {
1214
+ const s = (l) => Tt(r, { ...t, pitch: l }, e, n) !== null;
1196
1215
  if (s(i)) return i;
1197
1216
  if (!s(0)) return 0;
1198
1217
  let o = 0, a = i;
@@ -1202,7 +1221,7 @@ function Kr(r, t, e, n, i = 60) {
1202
1221
  }
1203
1222
  return o;
1204
1223
  }
1205
- function Pt(r, t, e, n) {
1224
+ function Tt(r, t, e, n) {
1206
1225
  if (!(e > 0) || !(n > 0)) return null;
1207
1226
  const i = new r.WebMercatorViewport({
1208
1227
  width: e,
@@ -1220,29 +1239,29 @@ function Pt(r, t, e, n) {
1220
1239
  ], o = [];
1221
1240
  for (const a of s) {
1222
1241
  const l = i.unproject(a);
1223
- if (!l || !Number.isFinite(l[0]) || !Number.isFinite(l[1]) || Math.abs(l[1]) > 85.06) return null;
1242
+ if (!l || !Number.isFinite(l[0]) || !Number.isFinite(l[1])) return null;
1224
1243
  o.push([l[0], l[1]]);
1225
1244
  }
1226
1245
  return o;
1227
1246
  }
1228
- async function Xr(r) {
1229
- const t = await we(), e = r.querySelector(":scope > om-map");
1247
+ async function Zr(r) {
1248
+ const t = await ve(), e = r.querySelector(":scope > om-map");
1230
1249
  if (e) return { core: t, map: e };
1231
1250
  const n = r.getAttribute("src");
1232
1251
  if (!n) throw new Error("a live frame needs src= or an inline <om-map> child");
1233
- const i = await Yr(n, r.ownerDocument);
1252
+ const i = await Jr(n, r.ownerDocument);
1234
1253
  return { core: t, map: i };
1235
1254
  }
1236
- function At(r, t) {
1237
- 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)), Zr(r, t);
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);
1238
1257
  }
1239
- function Zr(r, t) {
1258
+ function Qr(r, t) {
1240
1259
  const e = r;
1241
1260
  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 });
1242
1261
  }
1243
- const St = "data-om-carto-placeholder", Ct = "data-om-carto-overview", ae = "http://www.w3.org/2000/svg", le = 24, ce = 0.25;
1244
- class Ue extends R {
1245
- static observedAttributes = [...P["om-frame"]];
1262
+ const Ct = "data-om-carto-placeholder", xt = "data-om-carto-overview", le = "http://www.w3.org/2000/svg", ce = 24, ue = 0.25;
1263
+ class De extends R {
1264
+ static observedAttributes = [...T["om-frame"]];
1246
1265
  /** Resolved non-builtin CRS planes, so a re-render does not re-await proj4. */
1247
1266
  resolvedForward = null;
1248
1267
  resolvedForwardKey = null;
@@ -1277,6 +1296,8 @@ class Ue extends R {
1277
1296
  liveMapOwned = !1;
1278
1297
  /** A capture standing in for the live map during export/print. */
1279
1298
  captureImage = null;
1299
+ /** The authored camera last driven into the map, so a re-render can tell an edit from a repaint. */
1300
+ appliedCameraKey = null;
1280
1301
  printing = !1;
1281
1302
  get mode() {
1282
1303
  return this.getAttribute("mode") === "static" ? "static" : "live";
@@ -1292,15 +1313,15 @@ class Ue extends R {
1292
1313
  * than caching it correctly.
1293
1314
  */
1294
1315
  get georef() {
1295
- const { w: t, h: e } = S(this);
1316
+ const { w: t, h: e } = C(this);
1296
1317
  if (t <= 0 || e <= 0) return null;
1297
1318
  if (this.mode === "live")
1298
- return this.liveCorners ? ht({ corners: this.liveCorners, widthMm: t, heightMm: e }) : null;
1299
- const n = mt(this.getAttribute("corners"));
1319
+ return this.liveCorners ? mt({ corners: this.liveCorners, widthMm: t, heightMm: e, continuous: !0 }) : null;
1320
+ const n = dt(this.getAttribute("corners"));
1300
1321
  if (!n) return null;
1301
1322
  const i = Y(this.getAttribute("crs")) ?? "EPSG:3857", s = this.getAttribute("crs-def");
1302
- let o = s ? null : K(i);
1303
- return !o && this.resolvedForwardKey === `${i}|${s ?? ""}` && (o = this.resolvedForward), o ? ht({ corners: n, widthMm: t, heightMm: e, crsForward: o }) : null;
1323
+ let o = s ? null : X(i);
1324
+ return !o && this.resolvedForwardKey === `${i}|${s ?? ""}` && (o = this.resolvedForward), o ? mt({ corners: n, widthMm: t, heightMm: e, crsForward: o }) : null;
1304
1325
  }
1305
1326
  /** The raster a static frame draws — its first <img> child, if any. */
1306
1327
  get raster() {
@@ -1321,7 +1342,7 @@ class Ue extends R {
1321
1342
  renderNow() {
1322
1343
  this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden", this.style.boxSizing = "border-box";
1323
1344
  const t = this.getAttribute("frame-stroke");
1324
- this.style.border = "0", this.style.boxShadow = `inset 0 0 0 ${ce}mm ${t || "var(--om-carto-frame-stroke)"}`;
1345
+ this.style.border = "0", this.style.boxShadow = `inset 0 0 0 ${ue}mm ${t || "var(--om-carto-frame-stroke)"}`;
1325
1346
  const e = this.getAttribute("frame-bg");
1326
1347
  this.style.background = e || "var(--om-carto-frame-bg)", this.mode === "static" ? (this.suspendLiveMode(), this.renderStatic()) : this.renderLive(), this.renderOverview();
1327
1348
  }
@@ -1336,9 +1357,9 @@ class Ue extends R {
1336
1357
  }
1337
1358
  t.style.position = "absolute", t.style.inset = "0", t.style.width = "100%", t.style.height = "100%", t.style.objectFit = "fill", t.style.display = "block";
1338
1359
  const e = Y(this.getAttribute("crs")) ?? "EPSG:3857", n = this.getAttribute("crs-def"), i = `${e}|${n ?? ""}`;
1339
- if ((n != null || K(e) == null) && this.resolvedForwardKey !== i) {
1360
+ if ((n != null || X(e) == null) && this.resolvedForwardKey !== i) {
1340
1361
  const o = ++this.resolveToken;
1341
- this.resolvedForward = null, this.resolvedForwardKey = null, Oe(e, n).then((a) => {
1362
+ this.resolvedForward = null, this.resolvedForwardKey = null, Ue(e, n).then((a) => {
1342
1363
  if (o === this.resolveToken) {
1343
1364
  if (!a) {
1344
1365
  this.showPlaceholder("unknown-crs", `Unknown CRS "${e}" — supply crs-def="+proj=…".`);
@@ -1351,7 +1372,7 @@ class Ue extends R {
1351
1372
  });
1352
1373
  return;
1353
1374
  }
1354
- if (!mt(this.getAttribute("corners"))) {
1375
+ if (!dt(this.getAttribute("corners"))) {
1355
1376
  this.showPlaceholder("bad-corners", 'Static frame needs corners="[[lng,lat] × 4]" (tl, tr, br, bl).');
1356
1377
  return;
1357
1378
  }
@@ -1363,25 +1384,26 @@ class Ue extends R {
1363
1384
  renderLive() {
1364
1385
  const t = this.raster;
1365
1386
  t && (t.style.display = "none");
1366
- const e = Q(this);
1387
+ const e = ct(this);
1367
1388
  if (!e) {
1368
1389
  this.showPlaceholder("no-camera", 'Live frame needs its own camera — center="[lng, lat]" and zoom=.');
1369
1390
  return;
1370
1391
  }
1371
- this.updateLiveCorners(e);
1372
- const n = this.liveSource();
1392
+ const n = JSON.stringify(e), i = n !== this.appliedCameraKey;
1393
+ this.appliedCameraKey = n, this.updateLiveCorners(i ? e : this.liveCamera() ?? e);
1394
+ const s = this.liveSource();
1373
1395
  if (this.liveMap)
1374
- if (this.mountedSource !== n)
1396
+ if (this.mountedSource !== s)
1375
1397
  this.releaseLiveMap();
1376
1398
  else {
1377
- At(this.liveMap, e), this.sizeLiveMap();
1399
+ St(this.liveMap, e), this.sizeLiveMap();
1378
1400
  return;
1379
1401
  }
1380
1402
  if (this.mounting) {
1381
- if (this.mountingSource === n) return;
1403
+ if (this.mountingSource === s) return;
1382
1404
  this.abandonMount();
1383
1405
  }
1384
- this.mountLive(n);
1406
+ this.mountLive(s);
1385
1407
  }
1386
1408
  /** Inline maps are identified by node identity; fetched maps by their src=. */
1387
1409
  liveSource() {
@@ -1394,31 +1416,44 @@ class Ue extends R {
1394
1416
  this.mounting && this.abandonMount(), this.captureImage = null, this.liveMap && (this.liveMapOwned ? this.releaseLiveMap() : this.liveMap.hidden = !0);
1395
1417
  }
1396
1418
  releaseLiveMap() {
1397
- this.liveMap?.removeEventListener("om-view-changed", this.onLiveViewChanged), this.liveMapOwned ? this.liveMap?.remove() : this.liveMap && (this.liveMap.hidden = !0), this.liveMap = null, this.liveMapOwned = !1, this.mountedSource = null, this.liveCorners = null, this.captureImage = null;
1419
+ this.liveMap?.removeEventListener("om-view-changed", this.onLiveViewSettled), this.liveMapOwned ? this.liveMap?.remove() : this.liveMap && (this.liveMap.hidden = !0), this.liveMap = null, this.liveMapOwned = !1, this.mountedSource = null, this.liveCorners = null, this.captureImage = null;
1420
+ }
1421
+ /** The mounted map's own camera, or null before it can report one. */
1422
+ liveCamera() {
1423
+ const t = this.liveMap?.getViewStateInternal?.();
1424
+ return t ? { center: [t.longitude, t.latitude], zoom: t.zoom, bearing: t.bearing, pitch: t.pitch } : null;
1398
1425
  }
1399
- updateLiveCorners(t = Q(this)) {
1426
+ /**
1427
+ * The map settled somewhere new. Re-derive the georeference from where it
1428
+ * actually is, and tell the page — its north arrow, scale bar, graticule,
1429
+ * locator inset and {{scale}} tokens all describe THIS view now. A frozen
1430
+ * frame captures these corners too, so a freeze after a rotate places the
1431
+ * raster by the view that was captured, not the one that was authored.
1432
+ */
1433
+ onLiveViewSettled = () => {
1434
+ const t = this.liveCamera();
1435
+ t && this.updateLiveCorners(t);
1436
+ };
1437
+ updateLiveCorners(t = ct(this)) {
1400
1438
  if (!t) return;
1401
- const e = G();
1439
+ const e = H();
1402
1440
  if (!e) return;
1403
- const { w: n, h: i } = S(this), s = Pt(e, t, n * z, i * z);
1404
- this.liveCorners = s, s ? this.lastError === "degenerate-view" && this.clearPlaceholder() : this.showPlaceholder(
1405
- "degenerate-view",
1406
- "This camera cannot be georeferenced — the frame's top edge reaches the horizon. Reduce pitch below ~60°."
1407
- );
1441
+ const { w: n, h: i } = C(this), s = Tt(e, t, n * W, i * W), o = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
1442
+ 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.");
1408
1443
  }
1409
1444
  async mountLive(t) {
1410
1445
  const e = ++this.mountToken;
1411
1446
  this.mounting = !0, this.mountingSource = t;
1412
1447
  try {
1413
- const { core: n, map: i } = await Xr(this);
1448
+ const { core: n, map: i } = await Zr(this);
1414
1449
  if (e !== this.mountToken || !this.isConnected || this.mode !== "live" || this.liveSource() !== t) return;
1415
- const s = Q(this);
1450
+ const s = ct(this);
1416
1451
  if (!s) return;
1417
- At(i, s);
1452
+ this.appliedCameraKey = JSON.stringify(s), St(i, s);
1418
1453
  const o = i;
1419
- 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.onLiveViewChanged), this.mountedSource = t, this.sizeLiveMap(), this.clearPlaceholder();
1420
- const { w: a, h: l } = S(this);
1421
- if (this.liveCorners = Pt(n, s, a * z, l * z), await o.ready, e !== this.mountToken || (At(i, s), await o.whenSettled?.({ timeout: 2e4 }), e !== this.mountToken)) return;
1454
+ 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
+ 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;
1422
1457
  this.signalReady();
1423
1458
  } catch (n) {
1424
1459
  if (e !== this.mountToken) return;
@@ -1429,7 +1464,7 @@ class Ue extends R {
1429
1464
  }
1430
1465
  }
1431
1466
  sizeLiveMap() {
1432
- this.liveMap && (this.liveMap.style.width = "100%", this.liveMap.style.height = "100%", this.liveMap.hidden = this.printing, this.capMapPitch());
1467
+ this.liveMap && (this.liveMap.style.width = "100%", this.liveMap.style.height = "100%", this.liveMap.hidden = this.printing);
1433
1468
  }
1434
1469
  /**
1435
1470
  * Stop the adopted map tilting past what this frame can georeference.
@@ -1440,24 +1475,6 @@ class Ue extends R {
1440
1475
  * is the frame's own, recomputed whenever its box changes, because it
1441
1476
  * depends on the box's aspect and the current zoom.
1442
1477
  */
1443
- capMapPitch() {
1444
- const t = G();
1445
- if (!t || !this.liveMap) return;
1446
- const e = this.liveMap.getViewStateInternal?.(), n = e ? { center: [e.longitude, e.latitude], zoom: e.zoom, bearing: e.bearing, pitch: e.pitch } : Q(this);
1447
- if (!n) return;
1448
- const { w: i, h: s } = S(this), o = Kr(t, n, i * z, s * z), a = o >= 60 ? null : String(o);
1449
- a !== this.liveMap.getAttribute("max-pitch") && (a === null ? this.liveMap.removeAttribute("max-pitch") : this.liveMap.setAttribute("max-pitch", a));
1450
- }
1451
- /**
1452
- * The ceiling follows the camera, so a zoom changes it.
1453
- *
1454
- * Bound once so add/remove pair up. Cheap enough to run on every reported
1455
- * view: a probe is four unprojections and the attribute is only written when
1456
- * the whole-degree answer actually moves.
1457
- */
1458
- onLiveViewChanged = () => {
1459
- this.capMapPitch();
1460
- };
1461
1478
  // -------------------------------------------------------------------------
1462
1479
  // Locator inset (overview-of)
1463
1480
  // -------------------------------------------------------------------------
@@ -1468,34 +1485,34 @@ class Ue extends R {
1468
1485
  * segments would visibly cut the corners on a wide-extent inset.
1469
1486
  */
1470
1487
  renderOverview() {
1471
- const t = this.getAttribute("overview-of"), e = this.querySelector(`:scope > [${Ct}]`);
1488
+ const t = this.getAttribute("overview-of"), e = this.querySelector(`:scope > [${xt}]`);
1472
1489
  if (!t) {
1473
1490
  e?.remove();
1474
1491
  return;
1475
1492
  }
1476
- const n = Te(this, t), i = this.georef, s = n?.georef;
1493
+ const n = Le(this, t), i = this.georef, s = n?.georef;
1477
1494
  if (!n || !i || !s) {
1478
1495
  e?.remove();
1479
1496
  return;
1480
1497
  }
1481
- const { w: o, h: a } = S(this), l = [], [c, u, m, d] = s.corners, h = [
1498
+ const { w: o, h: a } = C(this), l = [], [c, u, h, d] = s.corners, m = [
1482
1499
  [c, u],
1483
- [u, m],
1484
- [m, d],
1500
+ [u, h],
1501
+ [h, d],
1485
1502
  [d, c]
1486
1503
  ];
1487
- for (const [b, w] of h)
1488
- for (let y = 0; y < le; y++) {
1489
- const C = y / le, v = [b[0] + (w[0] - b[0]) * C, b[1] + (w[1] - b[1]) * C], F = i.project(v);
1490
- F && l.push(`${F.xMm.toFixed(3)},${F.yMm.toFixed(3)}`);
1504
+ 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);
1507
+ N && l.push(`${N.xMm.toFixed(3)},${N.yMm.toFixed(3)}`);
1491
1508
  }
1492
1509
  if (l.length < 3) {
1493
1510
  e?.remove();
1494
1511
  return;
1495
1512
  }
1496
- const f = this.ownerDocument, p = e ?? f.createElementNS(ae, "svg");
1497
- p.setAttribute(Ct, ""), 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();
1498
- const g = f.createElementNS(ae, "polygon");
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");
1499
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);
1500
1517
  }
1501
1518
  // -------------------------------------------------------------------------
@@ -1516,11 +1533,11 @@ class Ue extends R {
1516
1533
  * the worst outcome — it looks like a design choice.
1517
1534
  */
1518
1535
  showPlaceholder(t, e) {
1519
- let n = this.querySelector(`:scope > [${St}]`);
1520
- 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 } })));
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 } })));
1521
1538
  }
1522
1539
  clearPlaceholder() {
1523
- this.querySelector(`:scope > [${St}]`)?.remove(), this.lastError = null;
1540
+ this.querySelector(`:scope > [${Ct}]`)?.remove(), this.lastError = null;
1524
1541
  }
1525
1542
  // -------------------------------------------------------------------------
1526
1543
  // Capture, export and print
@@ -1544,11 +1561,11 @@ class Ue extends R {
1544
1561
  * follows from the same source as any authored camera.
1545
1562
  */
1546
1563
  fitBounds(t) {
1547
- const [e, n, i, s] = t, { w: o, h: a } = S(this);
1564
+ const [e, n, i, s] = t, { w: o, h: a } = C(this);
1548
1565
  if (o <= 0 || a <= 0) return;
1549
- const l = G();
1566
+ const l = H();
1550
1567
  if (!l) return;
1551
- const c = new l.WebMercatorViewport({ width: o * z, height: a * z, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
1568
+ const c = new l.WebMercatorViewport({ width: o * W, height: a * W, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
1552
1569
  [e, n],
1553
1570
  [i, s]
1554
1571
  ]);
@@ -1577,62 +1594,62 @@ class Ue extends R {
1577
1594
  this.printing = !1, this.querySelector(":scope > img[data-om-carto-print]")?.remove(), this.liveMap && (this.liveMap.hidden = !1);
1578
1595
  }
1579
1596
  paintCartograph(t, e) {
1580
- const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1597
+ const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1581
1598
  if (s <= 0 || o <= 0) return;
1582
- const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = L(a?.backgroundColor);
1599
+ const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
1583
1600
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
1584
1601
  const c = this.mode === "static" ? this.raster : this.captureImage;
1585
1602
  c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, s, o), this.paintOverview(t, e);
1586
- const u = this.getAttribute("frame-stroke") || L(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", m = ce * e.pxPerMm;
1587
- m > 0 && (t.strokeStyle = u, t.lineWidth = m, t.strokeRect(m / 2, m / 2, s - m, o - m));
1603
+ const u = this.getAttribute("frame-stroke") || F(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", h = ue * e.pxPerMm;
1604
+ h > 0 && (t.strokeStyle = u, t.lineWidth = h, t.strokeRect(h / 2, h / 2, s - h, o - h));
1588
1605
  }
1589
1606
  paintOverview(t, e) {
1590
- const n = this.querySelector(`:scope > [${Ct}] polygon`), i = n?.getAttribute("points");
1607
+ const n = this.querySelector(`:scope > [${xt}] polygon`), i = n?.getAttribute("points");
1591
1608
  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) => {
1592
1609
  const [a, l] = s.split(",").map(Number);
1593
1610
  !Number.isFinite(a) || !Number.isFinite(l) || (o === 0 ? t.moveTo(a * e.pxPerMm, l * e.pxPerMm) : t.lineTo(a * e.pxPerMm, l * e.pxPerMm));
1594
1611
  }), t.closePath(), t.stroke(), t.restore());
1595
1612
  }
1596
1613
  }
1597
- x("om-frame", Ue);
1598
- const it = "http://www.w3.org/2000/svg", Jr = ["single", "double", "line", "ticks"];
1599
- class ze extends R {
1600
- static observedAttributes = [...P["om-scalebar"]];
1614
+ x("om-frame", De);
1615
+ const it = "http://www.w3.org/2000/svg", tn = ["single", "double", "line", "ticks"];
1616
+ class je extends R {
1617
+ static observedAttributes = [...T["om-scalebar"]];
1601
1618
  /** The geometry currently drawn — reused by the canvas exporter. */
1602
1619
  get drawing() {
1603
- const e = O(this)?.georef;
1620
+ const e = _(this)?.georef;
1604
1621
  if (!e) return null;
1605
- const { w: n, h: i } = S(this), s = $e({
1622
+ const { w: n, h: i } = C(this), s = Ee({
1606
1623
  groundMetersPerMm: e.groundMetersPerMm(),
1607
1624
  maxWidthMm: n,
1608
1625
  segments: Number(this.getAttribute("segments")) || void 0,
1609
1626
  units: this.unitSystem,
1610
1627
  segmentLengthMeters: this.getAttribute("segment-length") ? Number(this.getAttribute("segment-length")) : null
1611
1628
  });
1612
- return s ? Ar(s, this.barStyle, i) : null;
1629
+ return s ? Sr(s, this.barStyle, i) : null;
1613
1630
  }
1614
1631
  get barStyle() {
1615
1632
  const t = this.getAttribute("kind");
1616
- return Jr.includes(t) ? t : "single";
1633
+ return tn.includes(t) ? t : "single";
1617
1634
  }
1618
1635
  get unitSystem() {
1619
- return Mr(this.getAttribute("units")) ?? "metric";
1636
+ return Ar(this.getAttribute("units")) ?? "metric";
1620
1637
  }
1621
1638
  renderNow() {
1622
- if (this.applyPlacement(), this.style.display = "block", !O(this)) {
1639
+ if (this.applyPlacement(), this.style.display = "block", !_(this)) {
1623
1640
  const n = this.getAttribute("for");
1624
- W(this, n ? `Scale bar references no frame with id "${n}".` : "Scale bar has no frame to measure (set for=).");
1641
+ G(this, n ? `Scale bar references no frame with id "${n}".` : "Scale bar has no frame to measure (set for=).");
1625
1642
  return;
1626
1643
  }
1627
1644
  const e = this.drawing;
1628
1645
  if (!e) {
1629
- W(this, "Scale bar cannot derive a scale from this frame yet.");
1646
+ G(this, "Scale bar cannot derive a scale from this frame yet.");
1630
1647
  return;
1631
1648
  }
1632
1649
  this.renderSvg(e);
1633
1650
  }
1634
1651
  renderSvg(t) {
1635
- const { w: e, h: n } = S(this), i = this.ownerDocument, s = i.createElementNS(it, "svg");
1652
+ const { w: e, h: n } = C(this), i = this.ownerDocument, s = i.createElementNS(it, "svg");
1636
1653
  s.setAttribute("width", `${e}mm`), s.setAttribute("height", `${n}mm`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), s.setAttribute("part", "scalebar"), s.style.display = "block", s.style.overflow = "visible";
1637
1654
  const o = "var(--om-carto-scalebar-ink)";
1638
1655
  for (const a of t.bars) {
@@ -1652,7 +1669,7 @@ class ze extends R {
1652
1669
  paintCartograph(t, e) {
1653
1670
  const n = this.drawing;
1654
1671
  if (!n) return;
1655
- const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = L(i?.color) ?? "#000", o = (l) => l * e.pxPerMm;
1672
+ const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = F(i?.color) ?? "#000", o = (l) => l * e.pxPerMm;
1656
1673
  t.strokeStyle = s, t.fillStyle = s, t.lineWidth = o(n.strokeMm);
1657
1674
  for (const l of n.bars)
1658
1675
  l.filled && t.fillRect(o(l.x), o(l.y), o(l.w), o(l.h)), t.strokeRect(o(l.x), o(l.y), o(l.w), o(l.h));
@@ -1666,32 +1683,32 @@ class ze extends R {
1666
1683
  t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text, o(l.x), o(l.y));
1667
1684
  }
1668
1685
  }
1669
- x("om-scalebar", ze);
1670
- const J = "http://www.w3.org/2000/svg";
1671
- class je extends R {
1672
- static observedAttributes = [...P["om-north"]];
1686
+ x("om-scalebar", je);
1687
+ const Q = "http://www.w3.org/2000/svg";
1688
+ class Ge extends R {
1689
+ static observedAttributes = [...T["om-north"]];
1673
1690
  /** Degrees clockwise from the page's "up", or null when unknowable. */
1674
1691
  get bearing() {
1675
- const t = O(this)?.georef;
1676
- return t ? Wr(t) : null;
1692
+ const t = _(this)?.georef;
1693
+ return t ? Hr(t) : null;
1677
1694
  }
1678
1695
  get indicatorKind() {
1679
1696
  return this.getAttribute("kind") === "rose" ? "rose" : "arrow";
1680
1697
  }
1681
1698
  renderNow() {
1682
- if (this.applyPlacement(), this.style.display = "block", !O(this)) {
1699
+ if (this.applyPlacement(), this.style.display = "block", !_(this)) {
1683
1700
  const l = this.getAttribute("for");
1684
- W(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
1701
+ G(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
1685
1702
  return;
1686
1703
  }
1687
1704
  const e = this.bearing;
1688
1705
  if (e == null) {
1689
- W(this, "North indicator cannot derive a direction from this frame yet.");
1706
+ G(this, "North indicator cannot derive a direction from this frame yet.");
1690
1707
  return;
1691
1708
  }
1692
- const { w: n, h: i } = S(this), s = this.ownerDocument, o = s.createElementNS(J, "svg");
1709
+ const { w: n, h: i } = C(this), s = this.ownerDocument, o = s.createElementNS(Q, "svg");
1693
1710
  o.setAttribute("width", `${n}mm`), o.setAttribute("height", `${i}mm`), o.setAttribute("viewBox", `0 0 ${n} ${i}`), o.style.display = "block";
1694
- const a = s.createElementNS(J, "g");
1711
+ const a = s.createElementNS(Q, "g");
1695
1712
  a.setAttribute("transform", `rotate(${e.toFixed(3)} ${n / 2} ${i / 2})`);
1696
1713
  for (const l of this.buildGeometry(s, n, i)) a.appendChild(l);
1697
1714
  o.appendChild(a), this.replaceChildren(o);
@@ -1699,28 +1716,28 @@ class je extends R {
1699
1716
  buildGeometry(t, e, n) {
1700
1717
  const i = "var(--om-carto-compass-ink)", s = [], o = e / 2, a = Math.min(3, n * 0.24), l = n - a * 1.2;
1701
1718
  if (this.indicatorKind === "rose") {
1702
- const f = Math.min(e, l) / 2, p = t.createElementNS(J, "circle");
1719
+ const f = Math.min(e, l) / 2, p = t.createElementNS(Q, "circle");
1703
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);
1704
1721
  }
1705
- const c = 0, u = l, m = Math.min(e * 0.3, 4), d = t.createElementNS(J, "path");
1706
- d.setAttribute("d", `M ${o} ${c} L ${o + m} ${u} L ${o} ${u - m * 0.55} L ${o - m} ${u} Z`), d.setAttribute("fill", i), s.push(d);
1707
- const h = t.createElementNS(J, "text");
1708
- return h.setAttribute("x", String(o)), h.setAttribute("y", String(n)), h.setAttribute("font-size", String(a)), h.setAttribute("text-anchor", "middle"), h.setAttribute("fill", i), h.setAttribute("font-family", "var(--om-carto-font)"), h.textContent = "N", s.push(h), s;
1722
+ const c = 0, u = l, h = Math.min(e * 0.3, 4), d = t.createElementNS(Q, "path");
1723
+ 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);
1724
+ const m = t.createElementNS(Q, "text");
1725
+ return m.setAttribute("x", String(o)), m.setAttribute("y", String(n)), m.setAttribute("font-size", String(a)), m.setAttribute("text-anchor", "middle"), m.setAttribute("fill", i), m.setAttribute("font-family", "var(--om-carto-font)"), m.textContent = "N", s.push(m), s;
1709
1726
  }
1710
1727
  paintCartograph(t, e) {
1711
1728
  const n = this.bearing;
1712
1729
  if (n == null) return;
1713
- const { w: i, h: s } = S(this), o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = L(o?.color) ?? "#000", l = (h) => h * e.pxPerMm, c = Math.min(3, s * 0.24), u = s - c * 1.2, m = i / 2, d = Math.min(i * 0.3, 4);
1714
- t.save(), t.translate(l(m), l(s / 2)), t.rotate(n * Math.PI / 180), t.translate(-l(m), -l(s / 2)), t.fillStyle = a, t.strokeStyle = a, this.indicatorKind === "rose" && (t.lineWidth = l(0.2), t.beginPath(), t.arc(l(m), l(u / 2), l(Math.min(i, u) / 2), 0, Math.PI * 2), t.stroke()), t.beginPath(), t.moveTo(l(m), 0), t.lineTo(l(m + d), l(u)), t.lineTo(l(m), l(u - d * 0.55)), t.lineTo(l(m - d), l(u)), t.closePath(), t.fill(), t.font = `${l(c)}px ${o?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(m), l(s)), t.restore();
1730
+ const { w: i, h: s } = C(this), o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = F(o?.color) ?? "#000", l = (m) => m * e.pxPerMm, c = Math.min(3, s * 0.24), u = s - c * 1.2, h = i / 2, d = Math.min(i * 0.3, 4);
1731
+ t.save(), t.translate(l(h), l(s / 2)), t.rotate(n * Math.PI / 180), t.translate(-l(h), -l(s / 2)), t.fillStyle = a, t.strokeStyle = a, this.indicatorKind === "rose" && (t.lineWidth = l(0.2), t.beginPath(), t.arc(l(h), l(u / 2), l(Math.min(i, u) / 2), 0, Math.PI * 2), t.stroke()), t.beginPath(), t.moveTo(l(h), 0), t.lineTo(l(h + d), l(u)), t.lineTo(l(h), l(u - d * 0.55)), t.lineTo(l(h - d), l(u)), t.closePath(), t.fill(), t.font = `${l(c)}px ${o?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(h), l(s)), t.restore();
1715
1732
  }
1716
1733
  }
1717
- x("om-north", je);
1718
- const ot = "http://www.w3.org/2000/svg", Qr = ["rect", "ellipse", "line", "arrow"];
1719
- class De extends R {
1720
- static observedAttributes = [...P["om-shape"]];
1734
+ x("om-north", Ge);
1735
+ const ot = "http://www.w3.org/2000/svg", en = ["rect", "ellipse", "line", "arrow"];
1736
+ class qe extends R {
1737
+ static observedAttributes = [...T["om-shape"]];
1721
1738
  get kind() {
1722
1739
  const t = this.getAttribute("kind");
1723
- return Qr.includes(t) ? t : "rect";
1740
+ return en.includes(t) ? t : "rect";
1724
1741
  }
1725
1742
  get fill() {
1726
1743
  return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
@@ -1746,7 +1763,7 @@ class De extends R {
1746
1763
  }
1747
1764
  renderNow() {
1748
1765
  this.applyPlacement(), this.style.display = "block";
1749
- const { w: t, h: e } = S(this), n = this.ownerDocument, i = n.createElementNS(ot, "svg");
1766
+ const { w: t, h: e } = C(this), n = this.ownerDocument, i = n.createElementNS(ot, "svg");
1750
1767
  i.setAttribute("width", `${t}mm`), i.setAttribute("height", `${e}mm`), i.setAttribute("viewBox", `0 0 ${t} ${e}`), i.style.display = "block", i.style.overflow = "visible";
1751
1768
  const s = this.strokeWidthMm / 2, o = this.kind;
1752
1769
  let a;
@@ -1760,15 +1777,15 @@ class De extends R {
1760
1777
  return `M 0 0 L ${s} ${o} M ${s} ${o} L ${a.x} ${a.y} L ${l.x} ${l.y} Z`;
1761
1778
  }
1762
1779
  paintCartograph(t, e) {
1763
- const { w: n, h: i } = S(this);
1780
+ const { w: n, h: i } = C(this);
1764
1781
  if (n <= 0 || i <= 0) return;
1765
- const s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || s?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || s?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = o(this.strokeWidthMm), u = c / 2, m = this.kind;
1766
- if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, m === "ellipse")
1782
+ const s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || s?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || s?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = o(this.strokeWidthMm), u = c / 2, h = this.kind;
1783
+ if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, h === "ellipse")
1767
1784
  t.beginPath(), t.ellipse(o(n / 2), o(i / 2), Math.max(0, o(n / 2) - u), Math.max(0, o(i / 2) - u), 0, 0, Math.PI * 2), t.fill(), t.globalAlpha = 1, c > 0 && t.stroke();
1768
- else if (m === "line" || m === "arrow") {
1769
- if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(o(n), o(i)), c > 0 && t.stroke(), m === "arrow") {
1770
- const d = Math.min(o(n), o(i)) * 0.28, h = Math.atan2(o(i), o(n));
1771
- t.beginPath(), t.moveTo(o(n), o(i)), t.lineTo(o(n) - d * Math.cos(h - 0.4), o(i) - d * Math.sin(h - 0.4)), t.lineTo(o(n) - d * Math.cos(h + 0.4), o(i) - d * Math.sin(h + 0.4)), t.closePath(), t.fillStyle = l, t.fill();
1785
+ else if (h === "line" || h === "arrow") {
1786
+ if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(o(n), o(i)), c > 0 && t.stroke(), h === "arrow") {
1787
+ const d = Math.min(o(n), o(i)) * 0.28, m = Math.atan2(o(i), o(n));
1788
+ t.beginPath(), t.moveTo(o(n), o(i)), t.lineTo(o(n) - d * Math.cos(m - 0.4), o(i) - d * Math.sin(m - 0.4)), t.lineTo(o(n) - d * Math.cos(m + 0.4), o(i) - d * Math.sin(m + 0.4)), t.closePath(), t.fillStyle = l, t.fill();
1772
1789
  }
1773
1790
  } else {
1774
1791
  const d = o(this.radiusMm);
@@ -1777,13 +1794,13 @@ class De extends R {
1777
1794
  t.restore();
1778
1795
  }
1779
1796
  }
1780
- x("om-shape", De);
1781
- const ue = "data-om-carto-owned", tn = ["contain", "cover", "fill"];
1782
- class Ge extends R {
1783
- static observedAttributes = [...P["om-image"]];
1797
+ x("om-shape", qe);
1798
+ const he = "data-om-carto-owned", rn = ["contain", "cover", "fill"];
1799
+ class We extends R {
1800
+ static observedAttributes = [...T["om-image"]];
1784
1801
  get fit() {
1785
1802
  const t = this.getAttribute("fit");
1786
- return tn.includes(t ?? "") ? t : "contain";
1803
+ return rn.includes(t ?? "") ? t : "contain";
1787
1804
  }
1788
1805
  get image() {
1789
1806
  return this.querySelector(":scope > img");
@@ -1792,29 +1809,29 @@ class Ge extends R {
1792
1809
  this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden";
1793
1810
  const t = this.getAttribute("src");
1794
1811
  let e = this.image;
1795
- !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");
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");
1796
1813
  }
1797
1814
  paintCartograph(t, e) {
1798
1815
  const n = this.image;
1799
1816
  if (!n || !n.complete || n.naturalWidth === 0) return;
1800
- const { w: i, h: s } = S(this), o = i * e.pxPerMm, a = s * e.pxPerMm;
1817
+ const { w: i, h: s } = C(this), o = i * e.pxPerMm, a = s * e.pxPerMm;
1801
1818
  if (o <= 0 || a <= 0) return;
1802
1819
  const l = this.fit;
1803
1820
  if (l === "fill") {
1804
1821
  t.drawImage(n, 0, 0, o, a);
1805
1822
  return;
1806
1823
  }
1807
- const c = n.naturalWidth / n.naturalHeight, u = o / a, m = l === "contain" ? c > u : c < u, d = m ? o : a * c, h = m ? o / c : a;
1808
- l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0, o, a), t.clip()), t.drawImage(n, (o - d) / 2, (a - h) / 2, d, h), l === "cover" && t.restore();
1824
+ const c = n.naturalWidth / n.naturalHeight, u = o / a, h = l === "contain" ? c > u : c < u, d = h ? o : a * c, m = h ? o / c : a;
1825
+ l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0, o, a), t.clip()), t.drawImage(n, (o - d) / 2, (a - m) / 2, d, m), l === "cover" && t.restore();
1809
1826
  }
1810
1827
  }
1811
- x("om-image", Ge);
1812
- const en = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), rn = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), nn = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
1813
- function on(r) {
1828
+ 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) {
1814
1831
  const t = r.type ?? "";
1815
- if (nn.has(t)) return "ramp";
1816
- if (en.has(t)) return "line";
1817
- if (rn.has(t)) return "point";
1832
+ if (sn.has(t)) return "ramp";
1833
+ if (nn.has(t)) return "line";
1834
+ if (on.has(t)) return "point";
1818
1835
  if (t === "GeoJsonLayer") {
1819
1836
  const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
1820
1837
  if (n && !i) return "polygon";
@@ -1822,24 +1839,24 @@ function on(r) {
1822
1839
  }
1823
1840
  return "polygon";
1824
1841
  }
1825
- function sn(r) {
1842
+ function ln(r) {
1826
1843
  const t = r.meta?.legend;
1827
1844
  return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
1828
1845
  }
1829
- const xt = 12;
1830
- function an(r, t = []) {
1846
+ const kt = 12;
1847
+ function cn(r, t = []) {
1831
1848
  const e = [];
1832
1849
  for (const n of r) {
1833
1850
  if (n.props?.visible === !1) continue;
1834
1851
  const i = t.filter((a) => a.layer === n.id), s = i.find((a) => a.match == null);
1835
1852
  if (s?.hide) continue;
1836
- const o = ln(n.meta?.legend);
1853
+ const o = un(n.meta?.legend);
1837
1854
  e.push({
1838
1855
  layerId: n.id,
1839
1856
  label: s?.label ?? n.meta?.label ?? n.id,
1840
- color: s?.color ?? sn(n),
1841
- shape: s?.shape ?? on(n),
1842
- legend: cn(o, i),
1857
+ color: s?.color ?? ln(n),
1858
+ shape: s?.shape ?? an(n),
1859
+ legend: hn(o, i),
1843
1860
  order: s?.order
1844
1861
  });
1845
1862
  }
@@ -1848,15 +1865,15 @@ function an(r, t = []) {
1848
1865
  return s - o || n.index - i.index;
1849
1866
  }).map((n) => n.row);
1850
1867
  }
1851
- function ln(r) {
1852
- if (!r || r.kind !== "categories" || r.entries.length <= xt) return r;
1853
- const t = r.entries.slice(0, xt), e = r.entries.length - xt;
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;
1854
1871
  return {
1855
1872
  ...r,
1856
1873
  entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
1857
1874
  };
1858
1875
  }
1859
- function cn(r, t) {
1876
+ function hn(r, t) {
1860
1877
  const e = t.filter((i) => i.match != null);
1861
1878
  if (!r || r.kind === "ramp" || e.length === 0) return r;
1862
1879
  const n = [];
@@ -1866,7 +1883,7 @@ function cn(r, t) {
1866
1883
  }
1867
1884
  return { ...r, entries: n };
1868
1885
  }
1869
- function un(r) {
1886
+ function mn(r) {
1870
1887
  const t = [];
1871
1888
  for (const e of r.querySelectorAll(":scope > om-legend-row")) {
1872
1889
  const n = e.getAttribute("layer");
@@ -1884,7 +1901,7 @@ function un(r) {
1884
1901
  }
1885
1902
  return t;
1886
1903
  }
1887
- function qe(r) {
1904
+ function Be(r) {
1888
1905
  const t = [];
1889
1906
  for (const e of r.querySelectorAll(":scope > om-legend-row")) {
1890
1907
  if (e.hasAttribute("hide")) continue;
@@ -1899,36 +1916,36 @@ function qe(r) {
1899
1916
  }
1900
1917
  return t.sort((e, n) => (e.order ?? Number.POSITIVE_INFINITY) - (n.order ?? Number.POSITIVE_INFINITY));
1901
1918
  }
1902
- const he = "data-om-carto-legend-rows";
1903
- class We extends R {
1904
- static observedAttributes = [...P["om-legend"]];
1919
+ const me = "data-om-carto-legend-rows";
1920
+ class Ve extends R {
1921
+ static observedAttributes = [...T["om-legend"]];
1905
1922
  get derived() {
1906
1923
  return this.getAttribute("derived") !== "false";
1907
1924
  }
1908
1925
  /** The rows this legend currently shows — recomputed on demand, never stored. */
1909
1926
  get rows() {
1910
- if (!this.derived) return qe(this);
1911
- const n = O(this)?.mapElement?.getLayers?.();
1912
- return n ? an(n, un(this)) : [];
1927
+ if (!this.derived) return Be(this);
1928
+ const n = _(this)?.mapElement?.getLayers?.();
1929
+ return n ? cn(n, mn(this)) : [];
1913
1930
  }
1914
1931
  renderNow() {
1915
- if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !O(this)) {
1932
+ if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !_(this)) {
1916
1933
  const e = this.getAttribute("for");
1917
- W(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
1934
+ G(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
1918
1935
  return;
1919
1936
  }
1920
1937
  const t = this.rows;
1921
1938
  if (t.length === 0 && this.derived) {
1922
- W(this, "Legend is waiting for its frame's layers.");
1939
+ G(this, "Legend is waiting for its frame's layers.");
1923
1940
  return;
1924
1941
  }
1925
1942
  this.renderRows(t);
1926
1943
  }
1927
1944
  renderRows(t) {
1928
1945
  const e = this.ownerDocument;
1929
- this.querySelector(`:scope > [${he}]`)?.remove(), Pr(this);
1946
+ this.querySelector(`:scope > [${me}]`)?.remove(), Tr(this);
1930
1947
  const n = e.createElement("div");
1931
- n.setAttribute(he, ""), n.style.cssText = "padding:2mm;font-size:2.6mm;line-height:1.35;";
1948
+ n.setAttribute(me, ""), n.style.cssText = "padding:2mm;font-size:2.6mm;line-height:1.35;";
1932
1949
  const i = this.getAttribute("title");
1933
1950
  if (i) {
1934
1951
  const o = e.createElement("div");
@@ -1972,38 +1989,38 @@ class We extends R {
1972
1989
  return n;
1973
1990
  }
1974
1991
  paintCartograph(t, e) {
1975
- const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1992
+ const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1976
1993
  if (s <= 0 || o <= 0) return;
1977
- const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = L(a?.backgroundColor);
1994
+ const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
1978
1995
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
1979
- const c = L(a?.borderTopColor), u = $t(a?.borderTopWidth) * e.scale;
1996
+ const c = F(a?.borderTopColor), u = Et(a?.borderTopWidth) * e.scale;
1980
1997
  c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, s - u, o - u));
1981
- const m = L(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", h = (N) => N * e.pxPerMm;
1982
- let f = h(2);
1998
+ const h = F(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", m = (P) => P * e.pxPerMm;
1999
+ let f = m(2);
1983
2000
  const p = this.getAttribute("title");
1984
- p && (t.fillStyle = m, t.font = `600 ${h(2.6)}px ${d}`, t.textBaseline = "top", t.fillText(p, h(2), f), f += h(4));
1985
- 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)), C = 3, v = Math.max(1, (n - 4 - C * (w - 1)) / w), F = f;
1986
- let _ = -1, k = 2;
1987
- t.font = `${h(2.6)}px ${d}`;
1988
- for (const [N, T] of g.entries()) {
1989
- const M = Math.min(w - 1, Math.floor(N / y));
1990
- if (M !== _ && (_ = M, k = 2 + _ * (v + C), f = _ === 0 ? F : h(2)), f > o || (t.fillStyle = T.color, T.shape === "line" ? t.fillRect(h(k), f + h(1.2), h(3.2), h(0.9)) : T.shape === "point" ? (t.beginPath(), t.arc(h(k + 1.6), f + h(1.6), h(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(h(k), f, h(3.2), h(3.2)), t.fillStyle = m, t.textBaseline = "top", t.fillText(T.label, h(k + 4.7), f + h(0.3)), f += h(4.2), !T.legend)) continue;
1991
- const A = T.legend;
1992
- if (t.save(), t.font = `${h(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(A.field, h(k + 2.7), f), t.globalAlpha = 1, f += h(2.8), A.kind === "ramp") {
1993
- const $ = Math.min(24, Math.max(1, v - 2.7)), E = k + 2.7, U = t.createLinearGradient(h(E), 0, h(E + $), 0);
1994
- A.colors.forEach((X, Xe) => U.addColorStop(A.colors.length === 1 ? 0 : Xe / (A.colors.length - 1), X)), t.fillStyle = U, t.fillRect(h(E), f, h($), h(2.4)), f += h(3.4), t.fillStyle = m, t.font = `${h(2.1)}px ${d}`, t.fillText(A.domain[0].toLocaleString("en-US"), h(E), f);
1995
- const tt = A.domain[1].toLocaleString("en-US");
1996
- t.textAlign = "right", t.fillText(tt, h(E + $), f), t.textAlign = "left", f += h(3.2);
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;
2003
+ let O = -1, k = 2;
2004
+ t.font = `${m(2.6)}px ${d}`;
2005
+ for (const [P, L] of g.entries()) {
2006
+ const A = Math.min(w - 1, Math.floor(P / y));
2007
+ 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
+ const S = L.legend;
2009
+ if (t.save(), t.font = `${m(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(S.field, m(k + 2.7), f), t.globalAlpha = 1, f += m(2.8), S.kind === "ramp") {
2010
+ const $ = Math.min(24, Math.max(1, v - 2.7)), E = k + 2.7, U = t.createLinearGradient(m(E), 0, m(E + $), 0);
2011
+ S.colors.forEach((J, Je) => U.addColorStop(S.colors.length === 1 ? 0 : Je / (S.colors.length - 1), J)), t.fillStyle = U, t.fillRect(m(E), f, m($), m(2.4)), f += m(3.4), t.fillStyle = h, t.font = `${m(2.1)}px ${d}`, t.fillText(S.domain[0].toLocaleString("en-US"), m(E), f);
2012
+ const tt = S.domain[1].toLocaleString("en-US");
2013
+ t.textAlign = "right", t.fillText(tt, m(E + $), f), t.textAlign = "left", f += m(3.2);
1997
2014
  } else {
1998
- const $ = [...A.entries];
1999
- A.kind === "categories" && A.defaultColor && $.push({ color: A.defaultColor, label: "other" }), t.font = `${h(2.3)}px ${d}`;
2015
+ const $ = [...S.entries];
2016
+ S.kind === "categories" && S.defaultColor && $.push({ color: S.defaultColor, label: "other" }), t.font = `${m(2.3)}px ${d}`;
2000
2017
  for (const E of $) {
2001
2018
  if (f > o) break;
2002
- t.fillStyle = E.color, t.fillRect(h(k + 2.7), f, h(2.6), h(2.6)), t.fillStyle = m, t.fillText(E.label, h(k + 6.3), f + h(0.2)), f += h(3.2);
2019
+ t.fillStyle = E.color, t.fillRect(m(k + 2.7), f, m(2.6), m(2.6)), t.fillStyle = h, t.fillText(E.label, m(k + 6.3), f + m(0.2)), f += m(3.2);
2003
2020
  }
2004
- f += h(1);
2021
+ f += m(1);
2005
2022
  }
2006
- t.restore(), t.font = `${h(2.6)}px ${d}`;
2023
+ t.restore(), t.font = `${m(2.6)}px ${d}`;
2007
2024
  }
2008
2025
  }
2009
2026
  }
@@ -2011,52 +2028,56 @@ const st = (r, t) => {
2011
2028
  const e = r.createElement("span");
2012
2029
  return e.textContent = t, e;
2013
2030
  };
2014
- x("om-legend", We);
2015
- const me = 48, Be = {
2031
+ x("om-legend", Ve);
2032
+ const de = 48, Lt = {
2016
2033
  toLngLat: (r, t) => [r, t],
2017
2034
  fromLngLat: (r) => [r[0], r[1]]
2018
2035
  };
2019
- function de(r, t = 5) {
2020
- return !Number.isFinite(r) || r <= 0 ? 0 : ke(r / Math.max(1, t));
2036
+ function fe(r, t = 5) {
2037
+ return !Number.isFinite(r) || r <= 0 ? 0 : $e(r / Math.max(1, t));
2021
2038
  }
2022
- function hn({ georef: r, plane: t = Be, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
2039
+ function dn({ georef: r, plane: t = Lt, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
2023
2040
  if (r.degenerate) return null;
2024
2041
  const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
2025
2042
  if (l.some((y) => !Number.isFinite(y)) || c.some((y) => !Number.isFinite(y))) return null;
2026
- const u = Math.min(...l), m = Math.max(...l), d = Math.min(...c), h = Math.max(...c), f = fe(n ?? e, de(m - u)), p = fe(i ?? e, de(h - d));
2027
- if (f <= 0 || p <= 0 || (m - u) / f > 500 || (h - d) / p > 500) return null;
2028
- const g = [], b = [], w = o ?? dn;
2029
- for (let y = Math.ceil(u / f) * f; y <= m + 1e-9; y += f) {
2030
- const C = pe(r, t, y, d, h, "x");
2031
- C && (g.push(C), s !== "none" && be(b, C, r, w(y, "x"), "x", s));
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;
2046
+ for (let y = Math.ceil(u / f) * f; y <= h + 1e-9; y += f) {
2047
+ const M = ge(r, t, y, d, m, "x");
2048
+ 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);
2052
+ }
2032
2053
  }
2033
- for (let y = Math.ceil(d / p) * p; y <= h + 1e-9; y += p) {
2034
- const C = pe(r, t, y, u, m, "y");
2035
- C && (g.push(C), s !== "none" && be(b, C, r, w(y, "y"), "y", s));
2054
+ for (let y = Math.ceil(d / p) * p; y <= m + 1e-9; y += p) {
2055
+ 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));
2036
2057
  }
2037
2058
  return { lines: g, labels: b, intervalX: f, intervalY: p };
2038
2059
  }
2039
- const fe = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
2040
- function pe(r, t, e, n, i, s) {
2060
+ const pe = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
2061
+ function ge(r, t, e, n, i, s) {
2041
2062
  const o = [];
2042
- for (let l = 0; l <= me; l++) {
2043
- const c = n + (i - n) * l / me, u = s === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
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);
2044
2065
  if (!Number.isFinite(u[0]) || !Number.isFinite(u[1])) continue;
2045
- const m = r.project(u);
2046
- m && o.push(m);
2066
+ const h = r.project(u);
2067
+ h && o.push(h);
2047
2068
  }
2048
- const a = mn(o, r.widthMm, r.heightMm);
2069
+ const a = fn(o, r.widthMm, r.heightMm);
2049
2070
  return a.length >= 2 ? { points: a, value: e, axis: s } : null;
2050
2071
  }
2051
- function mn(r, t, e) {
2072
+ function fn(r, t, e) {
2052
2073
  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);
2053
2074
  if (i === -1) return [];
2054
2075
  let s = r.length - 1;
2055
2076
  for (; s > i && !n(r[s]); ) s--;
2056
- return r.slice(Math.max(0, i - 1), Math.min(r.length, s + 2)).map((a) => ({ xMm: ge(a.xMm, 0, t), yMm: ge(a.yMm, 0, e) }));
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) }));
2057
2078
  }
2058
- const ge = (r, t, e) => Math.min(e, Math.max(t, r));
2059
- function be(r, t, e, n, i, s) {
2079
+ const be = (r, t, e) => Math.min(e, Math.max(t, r));
2080
+ function ye(r, t, e, n, i, s) {
2060
2081
  if (i === "x") {
2061
2082
  const o = t.points.reduce((a, l) => l.yMm > a.yMm ? l : a);
2062
2083
  if (Math.abs(o.yMm - e.heightMm) > 0.5) return;
@@ -2067,24 +2088,24 @@ function be(r, t, e, n, i, s) {
2067
2088
  r.push({ text: n, xMm: s === "outside" ? -1.2 : 1.2, yMm: o.yMm, edge: "left", axis: i });
2068
2089
  }
2069
2090
  }
2070
- function dn(r, t) {
2091
+ function pn(r, t) {
2071
2092
  if (Math.abs(r) >= 1e3) return Math.round(r).toLocaleString("en-US");
2072
2093
  const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
2073
2094
  return `${Number(r.toFixed(e))}°`;
2074
2095
  }
2075
- function fn(r, t) {
2076
- 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, m = a === 60 ? 0 : a;
2077
- return `${c}°${String(u).padStart(2, "0")}′${String(m).padStart(2, "0")}″${e}`;
2096
+ function gn(r, t) {
2097
+ 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
+ return `${c}°${String(u).padStart(2, "0")}′${String(h).padStart(2, "0")}″${e}`;
2078
2099
  }
2079
- const at = "http://www.w3.org/2000/svg", pn = ["solid", "cross", "markers"], D = 1.4;
2080
- class Ve extends R {
2081
- static observedAttributes = [...P["om-graticule"]];
2100
+ const at = "http://www.w3.org/2000/svg", bn = ["solid", "cross", "markers"], D = 1.4;
2101
+ class He extends R {
2102
+ static observedAttributes = [...T["om-graticule"]];
2082
2103
  resolvedPlane = null;
2083
2104
  resolvedPlaneKey = null;
2084
2105
  resolveToken = 0;
2085
2106
  get kind() {
2086
2107
  const t = this.getAttribute("kind");
2087
- return pn.includes(t) ? t : "solid";
2108
+ return bn.includes(t) ? t : "solid";
2088
2109
  }
2089
2110
  get labelPlacement() {
2090
2111
  const t = this.getAttribute("labels");
@@ -2092,7 +2113,7 @@ class Ve extends R {
2092
2113
  }
2093
2114
  /** The grid this element currently draws, or null when it cannot yet. */
2094
2115
  get graticule() {
2095
- const t = O(this)?.georef;
2116
+ const t = _(this)?.georef;
2096
2117
  if (!t) return null;
2097
2118
  const e = this.gridPlane();
2098
2119
  if (!e) return null;
@@ -2100,14 +2121,14 @@ class Ve extends R {
2100
2121
  const s = Number(this.getAttribute(i));
2101
2122
  return Number.isFinite(s) && s > 0 ? s : null;
2102
2123
  };
2103
- return hn({
2124
+ return dn({
2104
2125
  georef: t,
2105
2126
  plane: e,
2106
2127
  interval: n("interval"),
2107
2128
  intervalX: n("interval-x"),
2108
2129
  intervalY: n("interval-y"),
2109
2130
  labels: this.labelPlacement,
2110
- format: this.getAttribute("format") === "dms" ? fn : void 0
2131
+ format: this.getAttribute("format") === "dms" ? gn : void 0
2111
2132
  });
2112
2133
  }
2113
2134
  /**
@@ -2117,24 +2138,24 @@ class Ve extends R {
2117
2138
  */
2118
2139
  gridPlane() {
2119
2140
  const t = Y(this.getAttribute("crs"));
2120
- if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return Be;
2141
+ if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return Lt;
2121
2142
  const e = `${t}|${this.getAttribute("crs-def") ?? ""}`;
2122
2143
  if (this.resolvedPlaneKey === e) return this.resolvedPlane;
2123
- const n = K(t);
2144
+ const n = X(t);
2124
2145
  if (n) {
2125
2146
  const s = { toLngLat: (o, a) => n.inverse([o, a]), fromLngLat: (o) => n.forward(o) };
2126
2147
  return this.resolvedPlane = s, this.resolvedPlaneKey = e, s;
2127
2148
  }
2128
2149
  const i = ++this.resolveToken;
2129
- return Oe(t, this.getAttribute("crs-def")).then((s) => {
2150
+ return Ue(t, this.getAttribute("crs-def")).then((s) => {
2130
2151
  i !== this.resolveToken || !s || (this.resolvedPlane = { toLngLat: (o, a) => s.inverse([o, a]), fromLngLat: (o) => s.forward(o) }, this.resolvedPlaneKey = e, this.scheduleRender());
2131
2152
  }).catch(() => {
2132
2153
  }), null;
2133
2154
  }
2134
2155
  renderNow() {
2135
- if (this.applyPlacement(), this.style.display = "block", this.style.pointerEvents = "none", !O(this)) {
2156
+ if (this.applyPlacement(), this.style.display = "block", this.style.pointerEvents = "none", !_(this)) {
2136
2157
  const n = this.getAttribute("for");
2137
- W(this, n ? `Graticule references no frame with id "${n}".` : "Graticule has no frame to cover (set for=).");
2158
+ G(this, n ? `Graticule references no frame with id "${n}".` : "Graticule has no frame to cover (set for=).");
2138
2159
  return;
2139
2160
  }
2140
2161
  const e = this.graticule;
@@ -2145,7 +2166,7 @@ class Ve extends R {
2145
2166
  this.renderSvg(e);
2146
2167
  }
2147
2168
  renderSvg(t) {
2148
- const { w: e, h: n } = S(this), i = this.ownerDocument, s = i.createElementNS(at, "svg");
2169
+ const { w: e, h: n } = C(this), i = this.ownerDocument, s = i.createElementNS(at, "svg");
2149
2170
  s.setAttribute("width", `${e}mm`), s.setAttribute("height", `${n}mm`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), s.style.cssText = "display:block;overflow:visible;";
2150
2171
  const o = "var(--om-carto-graticule-ink)", a = this.kind;
2151
2172
  for (const l of t.lines)
@@ -2168,7 +2189,7 @@ class Ve extends R {
2168
2189
  if (e === "markers") return [t.points[0], t.points[t.points.length - 1]];
2169
2190
  const i = n.lines.filter((o) => o.axis !== t.axis), s = [];
2170
2191
  for (const o of i) {
2171
- const a = gn(t.points, o.points);
2192
+ const a = yn(t.points, o.points);
2172
2193
  a && s.push(a);
2173
2194
  }
2174
2195
  return s;
@@ -2176,7 +2197,7 @@ class Ve extends R {
2176
2197
  paintCartograph(t, e) {
2177
2198
  const n = this.graticule;
2178
2199
  if (!n) return;
2179
- const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = L(i?.color) ?? "#ffffff", o = (l) => l * e.pxPerMm, a = this.kind;
2200
+ const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = F(i?.color) ?? "#ffffff", o = (l) => l * e.pxPerMm, a = this.kind;
2180
2201
  t.save(), t.strokeStyle = s, t.fillStyle = s, t.lineWidth = o(0.15);
2181
2202
  for (const l of n.lines)
2182
2203
  if (a === "solid")
@@ -2190,7 +2211,7 @@ class Ve extends R {
2190
2211
  t.restore();
2191
2212
  }
2192
2213
  }
2193
- function gn(r, t) {
2214
+ function yn(r, t) {
2194
2215
  let e = null, n = Number.POSITIVE_INFINITY;
2195
2216
  for (const i of r)
2196
2217
  for (const s of t) {
@@ -2199,28 +2220,28 @@ function gn(r, t) {
2199
2220
  }
2200
2221
  return n <= 1 ? e : null;
2201
2222
  }
2202
- x("om-graticule", Ve);
2203
- function bn(r, t) {
2223
+ x("om-graticule", He);
2224
+ function wn(r, t) {
2204
2225
  if (r == null || typeof r != "object") return;
2205
2226
  const e = r.properties;
2206
2227
  return e && t in e ? e[t] : r[t];
2207
2228
  }
2208
- function Tt(r, t) {
2229
+ function Ft(r, t) {
2209
2230
  if (Array.isArray(r)) {
2210
2231
  if (typeof r[0] == "number") {
2211
2232
  t.push([r[0], r[1]]);
2212
2233
  return;
2213
2234
  }
2214
- for (const e of r) Tt(e, t);
2235
+ for (const e of r) Ft(e, t);
2215
2236
  }
2216
2237
  }
2217
- function yn(r) {
2238
+ function vn(r) {
2218
2239
  return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
2219
2240
  }
2220
2241
  function I(r, t) {
2221
- return bn(r, t);
2242
+ return wn(r, t);
2222
2243
  }
2223
- function Lt(r) {
2244
+ function It(r) {
2224
2245
  const t = {}, e = (i) => {
2225
2246
  for (const [s, o] of Object.entries(i))
2226
2247
  o == null || typeof o == "object" || (t[s] = String(o));
@@ -2229,11 +2250,11 @@ function Lt(r) {
2229
2250
  const n = r.properties;
2230
2251
  return n && typeof n == "object" && e(n), t;
2231
2252
  }
2232
- function wn(r) {
2253
+ function Mn(r) {
2233
2254
  let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
2234
2255
  const s = [], o = r.geometry;
2235
- if (o?.coordinates != null) Tt(o.coordinates, s);
2236
- else if (Array.isArray(r.coordinates)) Tt(r.coordinates, s);
2256
+ if (o?.coordinates != null) Ft(o.coordinates, s);
2257
+ else if (Array.isArray(r.coordinates)) Ft(r.coordinates, s);
2237
2258
  else {
2238
2259
  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"));
2239
2260
  Number.isFinite(a) && Number.isFinite(l) && s.push([a, l]);
@@ -2242,52 +2263,52 @@ function wn(r) {
2242
2263
  !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));
2243
2264
  return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
2244
2265
  }
2245
- function vn(r, t) {
2266
+ function An(r, t) {
2246
2267
  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;
2247
2268
  return [e - l, n - c, i + l, s + c];
2248
2269
  }
2249
- const Hn = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
2250
- function Mn({ features: r, filter: t, sort: e }) {
2251
- let n = t ? r.filter((s) => An(t, s)) : [...r];
2252
- const i = Sn(e);
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);
2253
2274
  return i.length > 0 && (n = [...n].sort((s, o) => {
2254
2275
  for (const { field: a, descending: l } of i) {
2255
2276
  const c = I(s, a), u = I(o, a);
2256
2277
  if (c == null && u == null) continue;
2257
2278
  if (c == null) return 1;
2258
2279
  if (u == null) return -1;
2259
- const m = Cn(c, u);
2260
- if (m !== 0) return l ? -m : m;
2280
+ const h = kn(c, u);
2281
+ if (h !== 0) return l ? -h : h;
2261
2282
  }
2262
2283
  return 0;
2263
2284
  })), n;
2264
2285
  }
2265
- function An(r, t) {
2286
+ function Cn(r, t) {
2266
2287
  try {
2267
2288
  return !!r(t);
2268
2289
  } catch {
2269
2290
  return !1;
2270
2291
  }
2271
2292
  }
2272
- function Sn(r) {
2293
+ function xn(r) {
2273
2294
  return r ? r.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
2274
2295
  }
2275
- function Cn(r, t) {
2296
+ function kn(r, t) {
2276
2297
  return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
2277
2298
  }
2278
- function xn(r) {
2299
+ function $n(r) {
2279
2300
  const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
2280
2301
  return t === "" ? "page" : t;
2281
2302
  }
2282
- function kn(r, t, e) {
2303
+ function En(r, t, e) {
2283
2304
  const n = /* @__PURE__ */ new Map();
2284
2305
  return t.map((i, s) => {
2285
- const o = Lt(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, m) => m === "index" ? String(s + 1) : m === "count" ? String(t.length) : o[m] ?? u), l = xn(a), c = n.get(l) ?? 0;
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;
2286
2307
  return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
2287
2308
  });
2288
2309
  }
2289
- class He extends R {
2290
- static observedAttributes = [...P["om-atlas"]];
2310
+ class Ke extends R {
2311
+ static observedAttributes = [...T["om-atlas"]];
2291
2312
  /**
2292
2313
  * Pages are SNAPSHOTTED when iteration first starts. A streaming or polling
2293
2314
  * layer would otherwise change the page count halfway through an export,
@@ -2298,7 +2319,7 @@ class He extends R {
2298
2319
  rejection = null;
2299
2320
  /** The frame whose layer drives the iteration — the same `for=` rule every furniture element follows. */
2300
2321
  get frame() {
2301
- return O(this);
2322
+ return _(this);
2302
2323
  }
2303
2324
  get count() {
2304
2325
  return this.ensurePages().length;
@@ -2315,13 +2336,13 @@ class He extends R {
2315
2336
  }
2316
2337
  /** Export filenames, one per page, already de-duplicated. */
2317
2338
  filenames(t = "png") {
2318
- return kn(this.getAttribute("filename"), this.ensurePages(), t);
2339
+ return En(this.getAttribute("filename"), this.ensurePages(), t);
2319
2340
  }
2320
2341
  /** Human page labels, for an editor's stepper and PDF bookmarks. */
2321
2342
  pageName(t) {
2322
2343
  const e = this.ensurePages()[t];
2323
2344
  if (!e) return `Page ${t + 1}`;
2324
- const n = Lt(e), i = this.getAttribute("page-name");
2345
+ const n = It(e), i = this.getAttribute("page-name");
2325
2346
  return i ? i.replace(
2326
2347
  /\{\{\s*atlas\.([\w]+)\s*\}\}/g,
2327
2348
  (s, o) => o === "index" ? String(t + 1) : o === "count" ? String(this.count) : n[o] ?? s
@@ -2339,11 +2360,11 @@ class He extends R {
2339
2360
  }
2340
2361
  ensurePages() {
2341
2362
  if (this.pages) return this.pages;
2342
- const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? yn(i) : null;
2363
+ const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? vn(i) : null;
2343
2364
  if (!e || s)
2344
2365
  return this.rejection = e ? s : null, this.pages = [];
2345
2366
  const o = this.materialize(i);
2346
- return this.pages = Mn({ features: o, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
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;
2347
2368
  }
2348
2369
  /**
2349
2370
  * Rows from the layer, with the layer's OWN declarative filters applied —
@@ -2351,7 +2372,7 @@ class He extends R {
2351
2372
  * sheets for features the map itself is hiding.
2352
2373
  */
2353
2374
  materialize(t) {
2354
- const e = G(), n = t.data;
2375
+ const e = H(), n = t.data;
2355
2376
  if (!n) return [];
2356
2377
  const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [], s = [t.filter, t.categoryFilter].filter(Boolean);
2357
2378
  return s.length === 0 ? i : i.filter(
@@ -2370,7 +2391,7 @@ class He extends R {
2370
2391
  compileFilter() {
2371
2392
  const t = this.getAttribute("filter");
2372
2393
  if (!t) return;
2373
- const e = G();
2394
+ const e = H();
2374
2395
  if (e?.compileExpression)
2375
2396
  try {
2376
2397
  const n = e.compileExpression(t, { shape: "geojson", paramName: "d" });
@@ -2394,12 +2415,12 @@ class He extends R {
2394
2415
  const e = this.closest("om-cartograph");
2395
2416
  for (const n of e?.querySelectorAll("om-frame") ?? []) {
2396
2417
  if (n.getAttribute("atlas-fit") !== "feature") continue;
2397
- const i = wn(t);
2418
+ const i = Mn(t);
2398
2419
  if (!i) continue;
2399
- const s = Number(n.getAttribute("atlas-margin")), o = vn(i, Number.isFinite(s) && s > 0 ? s : 0.15);
2420
+ const s = Number(n.getAttribute("atlas-margin")), o = An(i, Number.isFinite(s) && s > 0 ? s : 0.15);
2400
2421
  n.fitBounds?.(o);
2401
2422
  }
2402
- e?.setAtlasFields({ ...Lt(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2423
+ e?.setAtlasFields({ ...It(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2403
2424
  new CustomEvent("om-atlas-page", {
2404
2425
  bubbles: !0,
2405
2426
  detail: { index: this.currentIndex, count: this.count, name: this.pageName(this.currentIndex), feature: t }
@@ -2410,82 +2431,82 @@ class He extends R {
2410
2431
  this.style.display = "none", this.refresh();
2411
2432
  }
2412
2433
  }
2413
- x("om-atlas", He);
2414
- const $n = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), En = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), Nn = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], Pn = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), Tn = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), Ln = 0.02, Fn = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
2434
+ 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);
2415
2436
  function Ye(r) {
2416
2437
  const t = r.tagName.toLowerCase();
2417
2438
  return r.id ? `${t}#${r.id}` : t;
2418
2439
  }
2419
- function H(r, t) {
2440
+ function V(r, t) {
2420
2441
  const e = r.getAttribute(t);
2421
2442
  if (e == null || e.trim() === "") return null;
2422
2443
  const n = Number(e);
2423
2444
  return Number.isFinite(n) ? n : null;
2424
2445
  }
2425
- function In(r, t) {
2446
+ function On(r, t) {
2426
2447
  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;
2427
2448
  }
2428
- function Rn(r, t) {
2449
+ function _n(r, t) {
2429
2450
  const e = r.getAttribute("style");
2430
2451
  if (!e) return null;
2431
2452
  const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
2432
2453
  return n ? Number(n[1]) : null;
2433
2454
  }
2434
- function Ke(r) {
2455
+ function Xe(r) {
2435
2456
  const t = [], e = (o, a, l, c, u) => {
2436
2457
  t.push({ severity: o, element: Ye(a), ...u ? { attribute: u } : {}, message: l, fix: c });
2437
2458
  }, n = [...r.querySelectorAll("om-cartograph")];
2438
2459
  if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
2439
2460
  return { valid: !0, errors: [], warnings: [] };
2440
- for (const o of n) _n(o, e);
2461
+ for (const o of n) Un(o, e);
2441
2462
  const i = t.filter((o) => o.severity === "error"), s = t.filter((o) => o.severity === "warning");
2442
2463
  return { valid: i.length === 0, errors: i, warnings: s };
2443
2464
  }
2444
- function _n(r, t) {
2445
- const e = r.getAttribute("size"), n = H(r, "width") != null && H(r, "height") != null;
2446
- e && !Vt.includes(e) && !n && t(
2465
+ function Un(r, t) {
2466
+ const e = r.getAttribute("size"), n = V(r, "width") != null && V(r, "height") != null;
2467
+ e && !Kt.includes(e) && !n && t(
2447
2468
  "error",
2448
2469
  r,
2449
2470
  `Unknown page size "${e}" and no width/height to fall back on.`,
2450
- `Use one of ${Vt.join(", ")}, or give width= and height= in millimetres.`,
2471
+ `Use one of ${Kt.join(", ")}, or give width= and height= in millimetres.`,
2451
2472
  "size"
2452
2473
  );
2453
2474
  const i = r.getAttribute("cvd");
2454
- i && i.trim().toLowerCase() !== "none" && !Ft(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${rr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && Fn(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");
2455
- const s = H(r, "safe-zone");
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");
2476
+ const s = V(r, "safe-zone");
2456
2477
  if (s != null && s > 0) {
2457
- const h = ct(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
2458
- s * 2 >= Math.min(h.widthMm, h.heightMm) && t("warning", r, `safe-zone=${s}mm leaves no usable area on a ${h.widthMm} × ${h.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
2478
+ const m = ut(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
2479
+ 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");
2459
2480
  }
2460
2481
  const o = r.getAttribute("format");
2461
- 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");
2462
- const { widthMm: a, heightMm: l } = ct(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, H(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), m = [...r.querySelectorAll("om-frame")];
2463
- for (const h of m)
2464
- h.id ? u.add(h.id) : t("error", h, "Frame has no id.", "Give every frame an id so furniture can reference it with for=.", "id");
2465
- for (const h of r.children) {
2466
- if (Nn.some((p) => h.hasAttribute(p))) continue;
2467
- const f = h.tagName.toLowerCase();
2468
- !gt.includes(f) && !En.has(f) && t("error", h, `<${f}> is not a cartograph element.`, `Use one of ${gt.join(", ")}, or move this content inside an <om-text>.`);
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");
2483
+ 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
+ for (const m of h)
2485
+ 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
+ for (const m of r.children) {
2487
+ if (Tn.some((p) => m.hasAttribute(p))) continue;
2488
+ 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>.`);
2469
2490
  }
2470
2491
  const d = [];
2471
- for (const h of [r, ...r.querySelectorAll("*")]) {
2472
- const f = h.tagName.toLowerCase();
2473
- if (gt.includes(f) && !h.closest("om-map")) {
2474
- if (On(h, f, t), Tn.has(f)) {
2475
- const p = S(h);
2476
- Un(h, p, a, l, c, t), Pn.has(f) && !h.hasAttribute("hidden") && d.push({ el: h, box: p });
2492
+ for (const m of [r, ...r.querySelectorAll("*")]) {
2493
+ const f = m.tagName.toLowerCase();
2494
+ 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 });
2477
2498
  }
2478
- f === "om-frame" && zn(h, t), f === "om-legend" && jn(h, m, t), f === "om-atlas" && Dn(h, m, t), f === "om-scalebar" && Gn(h, m, t), f === "om-text" && qn(h, m, t);
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);
2479
2500
  for (const p of ["for", "overview-of"]) {
2480
- const g = h.getAttribute(p);
2481
- g && !u.has(g) && t("error", h, `${p}="${g}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, p);
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);
2482
2503
  }
2483
2504
  }
2484
2505
  }
2485
- for (let h = 0; h < d.length; h++)
2486
- for (let f = h + 1; f < d.length; f++) {
2487
- const p = d[h], g = d[f];
2488
- p.box.w <= 0 || p.box.h <= 0 || g.box.w <= 0 || g.box.h <= 0 || In(p.box, g.box) && t(
2506
+ for (let m = 0; m < d.length; m++)
2507
+ 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(
2489
2510
  "warning",
2490
2511
  p.el,
2491
2512
  `Overlaps ${Ye(g.el)} on the page.`,
@@ -2493,12 +2514,12 @@ function _n(r, t) {
2493
2514
  );
2494
2515
  }
2495
2516
  }
2496
- function On(r, t, e) {
2497
- const n = new Set(P[t] ?? []);
2517
+ function zn(r, t, e) {
2518
+ const n = new Set(T[t] ?? []);
2498
2519
  for (const i of r.attributes) {
2499
2520
  const s = i.name.toLowerCase();
2500
- if (n.has(s) || $n.has(s) || s.startsWith("data-") || s.startsWith("aria-")) continue;
2501
- const o = gr.get(s);
2521
+ if (n.has(s) || Nn.has(s) || s.startsWith("data-") || s.startsWith("aria-")) continue;
2522
+ const o = br.get(s);
2502
2523
  if (o) {
2503
2524
  e("warning", r, `Attribute "${s}" has no effect: ${o}`, "Remove it, or use the documented alternative.", s);
2504
2525
  continue;
@@ -2506,7 +2527,7 @@ function On(r, t, e) {
2506
2527
  e("warning", r, `Unknown attribute "${s}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, s);
2507
2528
  }
2508
2529
  }
2509
- function Un(r, t, e, n, i, s) {
2530
+ function Dn(r, t, e, n, i, s) {
2510
2531
  if (t.w <= 0 || t.h <= 0) {
2511
2532
  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");
2512
2533
  return;
@@ -2524,20 +2545,20 @@ function Un(r, t, e, n, i, s) {
2524
2545
  ["width", t.w],
2525
2546
  ["height", t.h]
2526
2547
  ];
2527
- for (const [u, m] of c) {
2528
- const d = Rn(r, u);
2529
- d != null && Math.abs(d - m) > 0.01 && s(
2548
+ for (const [u, h] of c) {
2549
+ const d = _n(r, u);
2550
+ d != null && Math.abs(d - h) > 0.01 && s(
2530
2551
  "error",
2531
2552
  r,
2532
- `Inline style ${u}:${d}mm disagrees with the placement attribute (${m}mm).`,
2553
+ `Inline style ${u}:${d}mm disagrees with the placement attribute (${h}mm).`,
2533
2554
  "The attributes are authoritative — make the inline style match, or drop it and let the runtime write it.",
2534
2555
  "style"
2535
2556
  );
2536
2557
  }
2537
2558
  }
2538
- function zn(r, t) {
2559
+ function jn(r, t) {
2539
2560
  if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
2540
- const n = r.getAttribute("corners"), i = mt(n);
2561
+ const n = r.getAttribute("corners"), i = dt(n);
2541
2562
  i || t(
2542
2563
  "error",
2543
2564
  r,
@@ -2545,14 +2566,14 @@ function zn(r, t) {
2545
2566
  'Give four lon/lat pairs in tl, tr, br, bl order — corners="[[lng,lat],[lng,lat],[lng,lat],[lng,lat]]".',
2546
2567
  "corners"
2547
2568
  ), r.querySelector(":scope > img") || t("error", r, "Static frame has no <img> child to place.", "Add the georeferenced raster as an <img> child — it is also what renders with JavaScript disabled.");
2548
- const s = S(r), o = K(r.getAttribute("crs"));
2569
+ const s = C(r), o = X(r.getAttribute("crs"));
2549
2570
  if (i && o && s.w > 0 && s.h > 0) {
2550
- const a = ht({ corners: i, widthMm: s.w, heightMm: s.h, crsForward: o });
2571
+ const a = mt({ corners: i, widthMm: s.w, heightMm: s.h, crsForward: o });
2551
2572
  if (a.degenerate)
2552
2573
  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");
2553
2574
  else {
2554
- const l = Br(a);
2555
- l != null && l > Ln && t(
2575
+ const l = Kr(a);
2576
+ l != null && l > In && t(
2556
2577
  "warning",
2557
2578
  r,
2558
2579
  `Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
@@ -2561,7 +2582,7 @@ function zn(r, t) {
2561
2582
  }
2562
2583
  }
2563
2584
  } else {
2564
- Q(r) || t(
2585
+ ct(r) || t(
2565
2586
  "error",
2566
2587
  r,
2567
2588
  "Live frame has no valid camera.",
@@ -2580,12 +2601,12 @@ function zn(r, t) {
2580
2601
  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");
2581
2602
  }
2582
2603
  }
2583
- function _t(r, t) {
2604
+ function Ut(r, t) {
2584
2605
  const e = r.getAttribute("for");
2585
2606
  return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
2586
2607
  }
2587
- function jn(r, t, e) {
2588
- const n = r.getAttribute("derived") !== "false", i = _t(r, t);
2608
+ function Gn(r, t, e) {
2609
+ const n = r.getAttribute("derived") !== "false", i = Ut(r, t);
2589
2610
  n && i?.getAttribute("mode") === "static" && e(
2590
2611
  "warning",
2591
2612
  r,
@@ -2593,9 +2614,9 @@ function jn(r, t, e) {
2593
2614
  'Write the rows as <om-legend-row color= label= shape=> children and set derived="false".',
2594
2615
  "derived"
2595
2616
  );
2596
- const s = qe(r);
2617
+ const s = Be(r);
2597
2618
  if (s.length < 2) return;
2598
- const o = or(s.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
2619
+ const o = sr(s.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
2599
2620
  if (o.collapses.length > 0 && o.worstType) {
2600
2621
  const a = o.collapses.filter((c) => c.type === o.worstType), l = a.slice(0, 3).map((c) => `"${c.a.label}"/"${c.b.label}"`).join(", ");
2601
2622
  e(
@@ -2606,10 +2627,10 @@ function jn(r, t, e) {
2606
2627
  );
2607
2628
  }
2608
2629
  }
2609
- function Dn(r, t, e) {
2630
+ function qn(r, t, e) {
2610
2631
  const n = r.getAttribute("layer");
2611
2632
  n || e("error", r, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
2612
- const i = r.getAttribute("for"), s = _t(r, t);
2633
+ const i = r.getAttribute("for"), s = Ut(r, t);
2613
2634
  if (!s) {
2614
2635
  !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");
2615
2636
  return;
@@ -2641,17 +2662,17 @@ function Dn(r, t, e) {
2641
2662
  );
2642
2663
  }
2643
2664
  }
2644
- function Gn(r, t, e) {
2645
- const n = H(r, "segment-length");
2665
+ function Wn(r, t, e) {
2666
+ const n = V(r, "segment-length");
2646
2667
  if (n == null) return;
2647
- const i = _t(r, t);
2668
+ const i = Ut(r, t);
2648
2669
  if (!i) return;
2649
- const s = mt(i.getAttribute("corners")), o = K(i.getAttribute("crs")), a = S(i);
2670
+ const s = dt(i.getAttribute("corners")), o = X(i.getAttribute("crs")), a = C(i);
2650
2671
  if (!s || !o || a.w <= 0 || a.h <= 0) return;
2651
- const l = ht({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = S(r), u = $e({
2672
+ const l = mt({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = C(r), u = Ee({
2652
2673
  groundMetersPerMm: l.groundMetersPerMm(),
2653
2674
  maxWidthMm: c.w,
2654
- segments: H(r, "segments") ?? void 0,
2675
+ segments: V(r, "segments") ?? void 0,
2655
2676
  segmentLengthMeters: n
2656
2677
  });
2657
2678
  u && u.totalMm > c.w + 1e-6 && e(
@@ -2662,9 +2683,9 @@ function Gn(r, t, e) {
2662
2683
  "segment-length"
2663
2684
  );
2664
2685
  }
2665
- function qn(r, t, e) {
2686
+ function Bn(r, t, e) {
2666
2687
  const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), s = new Set(t.map((o) => o.id).filter(Boolean));
2667
- for (const o of kr(n))
2688
+ for (const o of $r(n))
2668
2689
  if (!o.startsWith("atlas.")) {
2669
2690
  if (o.startsWith("frame.")) {
2670
2691
  const a = o.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
@@ -2683,13 +2704,13 @@ function qn(r, t, e) {
2683
2704
  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>.`);
2684
2705
  }
2685
2706
  }
2686
- function Yn(r) {
2687
- return Ke(pr(r));
2707
+ function Jn(r) {
2708
+ return Xe(gr(r));
2688
2709
  }
2689
- async function Kn(r) {
2690
- const t = Ke(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
2710
+ async function Zn(r) {
2711
+ const t = Xe(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
2691
2712
  if (e.length === 0) return t;
2692
- const { loadCore: n } = await Promise.resolve().then(() => Je), i = await n(), s = [...t.errors], o = [...t.warnings];
2713
+ const { loadCore: n } = await Promise.resolve().then(() => Qe), i = await n(), s = [...t.errors], o = [...t.warnings];
2693
2714
  for (const a of e) {
2694
2715
  const l = a.id ? `om-frame#${a.id}` : "om-frame", c = i.validateManifest(a);
2695
2716
  for (const u of c.errors) s.push({ ...u, element: `${l} > ${u.element}` });
@@ -2697,113 +2718,113 @@ async function Kn(r) {
2697
2718
  }
2698
2719
  return { valid: s.length === 0, errors: s, warnings: o };
2699
2720
  }
2700
- function Xn() {
2701
- x("om-cartograph", Fe), x("om-text", Ie), x("om-frame", Ue), x("om-scalebar", ze), x("om-north", je), x("om-shape", De), x("om-image", Ge), x("om-legend", We), x("om-graticule", Ve), x("om-atlas", He);
2721
+ function Qn() {
2722
+ 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);
2702
2723
  }
2703
- ye(() => import("@nika-js/onlymap"));
2704
- dr();
2724
+ we(() => import("@nika-js/onlymap"));
2725
+ fr();
2705
2726
  export {
2706
- P as CARTOGRAPH_ELEMENT_ATTRS,
2707
- pt as CARTOGRAPH_FORMAT,
2708
- gt as CARTOGRAPH_TAG_NAMES,
2709
- Wn as CARTOGRAPH_THEMES,
2710
- ir as COLLAPSE_THRESHOLD,
2711
- It as CVD_MATRICES,
2712
- dt as CVD_TYPES,
2713
- rr as CVD_VALUES,
2714
- Be as GEOGRAPHIC_PLANE,
2715
- gr as INERT_RESERVED_CARTOGRAPH_ATTRS,
2716
- Se as MAX_CANVAS_AREA,
2717
- Ae as MAX_CANVAS_DIMENSION,
2718
- xt as MAX_CATEGORY_ENTRIES,
2719
- He as OmAtlasElement,
2720
- Fe as OmCartographElement,
2721
- Ue as OmFrameElement,
2722
- Ve as OmGraticuleElement,
2723
- Ge as OmImageElement,
2724
- We as OmLegendElement,
2725
- je as OmNorthElement,
2726
- ze as OmScalebarElement,
2727
- De as OmShapeElement,
2728
- Ie as OmTextElement,
2729
- Ut as PAGE_PRESETS,
2730
- Vt as PAGE_SIZE_NAMES,
2731
- j as PLACED_ATTR_NAMES,
2732
- z as PX_PER_MM,
2733
- Sr as SCALE_GROUP_SEPARATOR,
2734
- hr as URL_ACTION_TIMEOUT_MS,
2735
- Fr as alignOffset,
2736
- Le as allFrames,
2737
- sr as applyCvdToCanvas,
2738
- $r as applyTokens,
2739
- mr as applyUrlActions,
2740
- Lt as atlasFields,
2741
- Hn as boundsArea,
2742
- S as boxMm,
2743
- hn as buildGraticule,
2744
- Mn as buildPages,
2745
- $e as buildScalebar,
2746
- Ar as buildScalebarDrawing,
2747
- K as builtinCrsForward,
2748
- Bn as canvasMeasurer,
2749
- Pr as clearUnlinked,
2750
- Vn as cornersFromBounds,
2751
- Pt as cornersFromCamera,
2752
- ht as createFrameGeoref,
2753
- er as createZip,
2754
- Xn as defineCartographElements,
2755
- Gt as deltaE00,
2756
- an as deriveLegendRows,
2757
- ar as ensureCvdFilters,
2758
- wn as featureBounds,
2727
+ T as CARTOGRAPH_ELEMENT_ATTRS,
2728
+ gt as CARTOGRAPH_FORMAT,
2729
+ bt as CARTOGRAPH_TAG_NAMES,
2730
+ Vn as CARTOGRAPH_THEMES,
2731
+ or as COLLAPSE_THRESHOLD,
2732
+ Ot as CVD_MATRICES,
2733
+ ft as CVD_TYPES,
2734
+ nr as CVD_VALUES,
2735
+ Lt as GEOGRAPHIC_PLANE,
2736
+ br as INERT_RESERVED_CARTOGRAPH_ATTRS,
2737
+ Ce as MAX_CANVAS_AREA,
2738
+ Se as MAX_CANVAS_DIMENSION,
2739
+ kt as MAX_CATEGORY_ENTRIES,
2740
+ Ke as OmAtlasElement,
2741
+ Ie as OmCartographElement,
2742
+ De as OmFrameElement,
2743
+ He as OmGraticuleElement,
2744
+ We as OmImageElement,
2745
+ Ve as OmLegendElement,
2746
+ Ge as OmNorthElement,
2747
+ je as OmScalebarElement,
2748
+ qe as OmShapeElement,
2749
+ Re as OmTextElement,
2750
+ Dt as PAGE_PRESETS,
2751
+ Kt as PAGE_SIZE_NAMES,
2752
+ z as PLACED_ATTR_NAMES,
2753
+ W as PX_PER_MM,
2754
+ Cr as SCALE_GROUP_SEPARATOR,
2755
+ mr as URL_ACTION_TIMEOUT_MS,
2756
+ Ir as alignOffset,
2757
+ Fe as allFrames,
2758
+ ar as applyCvdToCanvas,
2759
+ Er as applyTokens,
2760
+ dr as applyUrlActions,
2761
+ It as atlasFields,
2762
+ Xn as boundsArea,
2763
+ C as boxMm,
2764
+ dn as buildGraticule,
2765
+ Sn as buildPages,
2766
+ Ee as buildScalebar,
2767
+ Sr as buildScalebarDrawing,
2768
+ X as builtinCrsForward,
2769
+ Hn as canvasMeasurer,
2770
+ Tr as clearUnlinked,
2771
+ Kn as cornersFromBounds,
2772
+ Tt as cornersFromCamera,
2773
+ mt as createFrameGeoref,
2774
+ rr as createZip,
2775
+ Qn as defineCartographElements,
2776
+ Wt as deltaE00,
2777
+ cn as deriveLegendRows,
2778
+ lr as ensureCvdFilters,
2779
+ Mn as featureBounds,
2759
2780
  I as fieldOf,
2760
- Te as findFrame,
2761
- fn as formatDms,
2762
- Cr as formatScaleDenominator,
2763
- dr as installUrlActions,
2781
+ Le as findFrame,
2782
+ gn as formatDms,
2783
+ xr as formatScaleDenominator,
2784
+ fr as installUrlActions,
2764
2785
  Ze as isCoreLoaded,
2765
- Er as isoDate,
2766
- Lr as layoutText,
2767
- or as lintLegendColours,
2768
- we as loadCore,
2769
- Kr as maxGeoreferenceablePitch,
2770
- _r as mercatorForward,
2771
- Or as mercatorInverse,
2772
- de as niceInterval,
2773
- ke as niceNumberBelow,
2786
+ Nr as isoDate,
2787
+ Fr as layoutText,
2788
+ sr as lintLegendColours,
2789
+ ve as loadCore,
2790
+ Yn as maxGeoreferenceablePitch,
2791
+ Ur as mercatorForward,
2792
+ Oe as mercatorInverse,
2793
+ fe as niceInterval,
2794
+ $e as niceNumberBelow,
2774
2795
  Y as normalizeCrs,
2775
- Wr as northBearingDegrees,
2776
- Pe as ownerCartograph,
2777
- vn as padBounds,
2778
- Ot as paintEnvForDpi,
2779
- nr as parseColor,
2780
- mt as parseCorners,
2781
- Sn as parseSort,
2782
- G as peekCore,
2783
- Q as readCamera,
2784
- qe as readLiteralRows,
2785
- un as readOverrides,
2786
- O as referencedFrame,
2787
- yn as rejectionFor,
2788
- Rt as renderCartograph,
2789
- Ce as renderCartographAtlas,
2790
- Oe as resolveCrsForward,
2791
- Ft as resolveCvdType,
2792
- kn as resolveFilenames,
2793
- ct as resolvePageSize,
2794
- xr as resolveToken,
2795
- Ne as resolveTokens,
2796
- sn as rowColorFor,
2797
- Hr as sanitizeAdoptedMap,
2798
- xn as sanitizeFilename,
2799
- Br as scaleVariation,
2800
- ye as setCoreLoader,
2801
- jt as simulate,
2802
- on as swatchShapeFor,
2803
- kr as tokensIn,
2804
- ie as utmDef,
2805
- Ke as validateCartograph,
2806
- Kn as validateCartographDeep,
2807
- Yn as validateCartographString,
2808
- Bt as whenPageReady
2796
+ Hr as northBearingDegrees,
2797
+ Te as ownerCartograph,
2798
+ An as padBounds,
2799
+ zt as paintEnvForDpi,
2800
+ ir as parseColor,
2801
+ dt as parseCorners,
2802
+ xn as parseSort,
2803
+ H as peekCore,
2804
+ ct as readCamera,
2805
+ Be as readLiteralRows,
2806
+ mn as readOverrides,
2807
+ _ as referencedFrame,
2808
+ vn as rejectionFor,
2809
+ _t as renderCartograph,
2810
+ xe as renderCartographAtlas,
2811
+ Ue as resolveCrsForward,
2812
+ Rt as resolveCvdType,
2813
+ En as resolveFilenames,
2814
+ ut as resolvePageSize,
2815
+ 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,
2824
+ $r as tokensIn,
2825
+ se as utmDef,
2826
+ Xe as validateCartograph,
2827
+ Zn as validateCartographDeep,
2828
+ Jn as validateCartographString,
2829
+ Ht as whenPageReady
2809
2830
  };