@nika-js/onlymap 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +50 -3
  3. package/dist/{LercDecode.es-BMcxSLhD.js → LercDecode.es-IEPCRZOv.js} +1 -1
  4. package/dist/{basemap-m98j2wxG.js → basemap-9lXclX9H.js} +3882 -3980
  5. package/dist/cartograph/elements/om-frame.d.ts +67 -1
  6. package/dist/cartograph/georef.d.ts +18 -4
  7. package/dist/cartograph/schema.d.ts +11 -0
  8. package/dist/cartograph.js +1480 -1311
  9. package/dist/cartograph.standalone.js +1808 -1615
  10. package/dist/{cityjson-D_V5GY8b.js → cityjson-k-z1r6c0.js} +1 -1
  11. package/dist/{crs-DsDQ4Q4i.js → crs-BzE_KP4M.js} +25 -2
  12. package/dist/{crs-Ciu7Xs7a.js → crs-ChglCB3O.js} +39 -16
  13. package/dist/dem-decode.d.ts +58 -0
  14. package/dist/elements/om-map.d.ts +12 -0
  15. package/dist/{geoparquet-XOwOmChh.js → geoparquet-DFDZDBun.js} +10 -10
  16. package/dist/globe-view-D9wjfL0T.js +104 -0
  17. package/dist/hillshade-C2BQr6pd.js +298 -0
  18. package/dist/hillshade-apron-Bem3DWyJ.js +40 -0
  19. package/dist/hillshade-apron.d.ts +54 -0
  20. package/dist/hillshade-shader-DI2uLSNU.js +165 -0
  21. package/dist/hillshade-shader.d.ts +168 -0
  22. package/dist/hillshade.d.ts +163 -0
  23. package/dist/html-data.d.ts +1 -1
  24. package/dist/{ifc-Dc-TdSJr.js → ifc-DXwePQRv.js} +131 -131
  25. package/dist/{index-DzOvV-O7.js → index-4Tvlt0iO.js} +57 -57
  26. package/dist/{index-HZWdgtm4.js → index-Bn66l3KG.js} +1 -1
  27. package/dist/index-BuXrMq5D.js +322 -0
  28. package/dist/index-CNRbZHkK.js +459 -0
  29. package/dist/{index-DDNElBTs.js → index-CkovmN47.js} +1 -1
  30. package/dist/index-CmuOizAF.js +641 -0
  31. package/dist/index-CvT5QHBS.js +65 -0
  32. package/dist/{index-BMbpftvm.js → index-DnVHKI61.js} +1 -1
  33. package/dist/{index-BSAY6CWm.js → index-JjyDEqAS.js} +18911 -17456
  34. package/dist/index.d.ts +4 -0
  35. package/dist/layer-registry.d.ts +27 -0
  36. package/dist/lerc-C1mQ_Kqq.js +22 -0
  37. package/dist/onlymap.standalone.js +49075 -45717
  38. package/dist/onlymapjs.js +73 -70
  39. package/dist/parse-manifest.d.ts +6 -0
  40. package/dist/plane-camera.d.ts +59 -0
  41. package/dist/plane-layers.d.ts +56 -0
  42. package/dist/plane-tiles.d.ts +99 -0
  43. package/dist/plane-tileset.d.ts +31 -0
  44. package/dist/plane-warp.d.ts +91 -0
  45. package/dist/post-process-effect-DfslKPM6.js +197 -0
  46. package/dist/programmatic.d.ts +16 -1
  47. package/dist/projection.d.ts +118 -0
  48. package/dist/{raster-Dg5p_99H.js → raster-D2NzdjZE.js} +609 -499
  49. package/dist/raster-hillshade.d.ts +119 -0
  50. package/dist/{raster-pipeline-DhjkqDYd.js → raster-pipeline-qnD1icOv.js} +511 -484
  51. package/dist/raster-pipeline.d.ts +10 -0
  52. package/dist/raster.d.ts +5 -0
  53. package/dist/runtime-core.d.ts +140 -1
  54. package/dist/serialize/clip.d.ts +50 -0
  55. package/dist/serialize/declutter.d.ts +44 -0
  56. package/dist/serialize/emit.d.ts +60 -0
  57. package/dist/serialize/index.d.ts +64 -0
  58. package/dist/serialize/strategy.d.ts +30 -0
  59. package/dist/serialize/style.d.ts +77 -0
  60. package/dist/snapshot.d.ts +46 -0
  61. package/dist/surface-anchor.d.ts +6 -0
  62. package/dist/terrain-heightfield.d.ts +0 -16
  63. package/dist/terrain-sample.d.ts +0 -13
  64. package/dist/text-on-path-Dm7vtNqt.js +146 -0
  65. package/dist/text-on-path.d.ts +157 -0
  66. package/dist/transform/buffer.d.ts +63 -0
  67. package/dist/transform/contour.d.ts +37 -0
  68. package/dist/transform/dot-density.d.ts +19 -0
  69. package/dist/transform/field.d.ts +80 -0
  70. package/dist/transform/geometry.d.ts +20 -0
  71. package/dist/transform/index.d.ts +29 -0
  72. package/dist/transform/simplify.d.ts +10 -0
  73. package/dist/transform/smooth.d.ts +12 -0
  74. package/dist/transform-stage.d.ts +92 -0
  75. package/dist/version.d.ts +1 -1
  76. package/dist/volumetrics.d.ts +7 -0
  77. package/dist/{zarr-D3CzK1Zm.js → zarr-D5e5agMG.js} +2 -2
  78. package/docs/cartograph.md +12 -4
  79. package/docs/cartography.md +328 -0
  80. package/docs/design/arrows.md +182 -0
  81. package/docs/design/carto-substrate.md +1055 -0
  82. package/docs/design/extensions.md +250 -0
  83. package/docs/design/hillshade.md +290 -0
  84. package/docs/effects.md +11 -0
  85. package/docs/hillshade.md +203 -0
  86. package/llms.txt +4 -2
  87. package/onlymapjs.attributes.json +45 -2
  88. package/onlymapjs.html-data.json +213 -25
  89. package/package.json +13 -9
  90. package/skills/onlymapjs/SKILL.md +7 -2
  91. package/skills/onlymapjs/references/syntax.md +31 -3
  92. package/dist/index-CfPbQUqO.js +0 -511
  93. package/dist/lerc-qK-nhCaB.js +0 -30
@@ -1,63 +1,63 @@
1
- let kt = null, Z = null;
2
- function ye(r) {
3
- kt = r;
1
+ let xt = null, X = null;
2
+ function $e(n) {
3
+ xt = n;
4
4
  }
5
- function Ze() {
5
+ function sr() {
6
6
  return B !== null;
7
7
  }
8
8
  let B = null;
9
9
  function H() {
10
10
  return B;
11
11
  }
12
- function we() {
13
- return B ? Promise.resolve(B) : Z || (kt ? (Z = Promise.resolve(kt()).then((r) => (B = r, B)).catch((r) => {
14
- throw Z = null, r;
15
- }), Z) : Promise.reject(
12
+ function ke() {
13
+ return B ? Promise.resolve(B) : X || (xt ? (X = Promise.resolve(xt()).then((n) => (B = n, B)).catch((n) => {
14
+ throw X = null, n;
15
+ }), X) : Promise.reject(
16
16
  new Error(
17
17
  '[onlymapjs/cartograph] No map runtime loader is configured. Import the cartograph entry ("@nika-js/onlymap/cartograph" or its standalone build) rather than a submodule — the entry installs it.'
18
18
  )
19
19
  ));
20
20
  }
21
- const Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
21
+ const or = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22
22
  __proto__: null,
23
- isCoreLoaded: Ze,
24
- loadCore: we,
23
+ isCoreLoaded: sr,
24
+ loadCore: ke,
25
25
  peekCore: H,
26
- setCoreLoader: ye
26
+ setCoreLoader: $e
27
27
  }, Symbol.toStringTag, { value: "Module" }));
28
- function Ut(r) {
29
- return { scale: r / 96, pxPerMm: r / 25.4 };
28
+ function qt(n) {
29
+ return { scale: n / 96, pxPerMm: n / 25.4 };
30
30
  }
31
- function gt(r) {
32
- return typeof r?.paintCartograph == "function";
31
+ function ft(n) {
32
+ return typeof n?.paintCartograph == "function";
33
33
  }
34
- const q = (r, t) => {
35
- const e = r.getAttribute(t);
34
+ const W = (n, t) => {
35
+ const e = n.getAttribute(t);
36
36
  if (e == null || e.trim() === "") return null;
37
- const n = Number(e);
38
- return Number.isFinite(n) ? n : null;
37
+ const r = Number(e);
38
+ return Number.isFinite(r) ? r : null;
39
39
  };
40
- function C(r) {
40
+ function C(n) {
41
41
  return {
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")
42
+ x: W(n, "x") ?? 0,
43
+ y: W(n, "y") ?? 0,
44
+ w: W(n, "w") ?? 0,
45
+ h: W(n, "h") ?? 0,
46
+ rotation: W(n, "rotation") ?? 0,
47
+ z: W(n, "z")
48
48
  };
49
49
  }
50
- function $t(r, t = 0) {
51
- if (!r) return t;
52
- const e = Number.parseFloat(r);
50
+ function $t(n, t = 0) {
51
+ if (!n) return t;
52
+ const e = Number.parseFloat(n);
53
53
  return Number.isFinite(e) ? e : t;
54
54
  }
55
- function F(r) {
56
- if (!r) return null;
57
- const t = r.trim().toLowerCase();
58
- return t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "none" ? null : r;
55
+ function F(n) {
56
+ if (!n) return null;
57
+ const t = n.trim().toLowerCase();
58
+ return t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "none" ? null : n;
59
59
  }
60
- const W = 96 / 25.4, zt = {
60
+ const D = 96 / 25.4, Wt = {
61
61
  A0: { widthMm: 841, heightMm: 1189 },
62
62
  A1: { widthMm: 594, heightMm: 841 },
63
63
  A2: { widthMm: 420, heightMm: 594 },
@@ -66,206 +66,206 @@ const W = 96 / 25.4, zt = {
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
- }, Dt = "A4";
70
- function ut(r, t, e, n) {
71
- const i = t != null ? Number(t) : NaN, s = e != null ? Number(e) : NaN;
72
- if (Number.isFinite(i) && i > 0 && Number.isFinite(s) && s > 0) return { widthMm: i, heightMm: s };
73
- const o = zt[r ?? Dt] ?? zt[Dt];
74
- return n === "landscape" ? { widthMm: o.heightMm, heightMm: o.widthMm } : { ...o };
69
+ }, Bt = "A4";
70
+ function ut(n, t, e, r) {
71
+ const i = t != null ? Number(t) : NaN, o = e != null ? Number(e) : NaN;
72
+ if (Number.isFinite(i) && i > 0 && Number.isFinite(o) && o > 0) return { widthMm: i, heightMm: o };
73
+ const s = Wt[n ?? Bt] ?? Wt[Bt];
74
+ return r === "landscape" ? { widthMm: s.heightMm, heightMm: s.widthMm } : { ...s };
75
75
  }
76
76
  let et = null;
77
- function tr(r) {
77
+ function ar(n) {
78
78
  if (!et) {
79
79
  et = new Uint32Array(256);
80
80
  for (let e = 0; e < 256; e++) {
81
- let n = e;
82
- for (let i = 0; i < 8; i++) n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
83
- et[e] = n >>> 0;
81
+ let r = e;
82
+ for (let i = 0; i < 8; i++) r = r & 1 ? 3988292384 ^ r >>> 1 : r >>> 1;
83
+ et[e] = r >>> 0;
84
84
  }
85
85
  }
86
86
  let t = 4294967295;
87
- for (let e = 0; e < r.length; e++) t = et[(t ^ r[e]) & 255] ^ t >>> 8;
87
+ for (let e = 0; e < n.length; e++) t = et[(t ^ n[e]) & 255] ^ t >>> 8;
88
88
  return (t ^ 4294967295) >>> 0;
89
89
  }
90
- function er(r) {
91
- const t = Math.max(1980, r.getFullYear());
90
+ function lr(n) {
91
+ const t = Math.max(1980, n.getFullYear());
92
92
  return {
93
- time: r.getHours() << 11 | r.getMinutes() << 5 | Math.floor(r.getSeconds() / 2),
94
- date: t - 1980 << 9 | r.getMonth() + 1 << 5 | r.getDate()
93
+ time: n.getHours() << 11 | n.getMinutes() << 5 | Math.floor(n.getSeconds() / 2),
94
+ date: t - 1980 << 9 | n.getMonth() + 1 << 5 | n.getDate()
95
95
  };
96
96
  }
97
- async function rr(r, t = /* @__PURE__ */ new Date()) {
98
- const e = new TextEncoder(), { time: n, date: i } = er(t), s = [], o = [];
97
+ async function cr(n, t = /* @__PURE__ */ new Date()) {
98
+ const e = new TextEncoder(), { time: r, date: i } = lr(t), o = [], s = [];
99
99
  let a = 0;
100
- for (const u of r) {
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;
100
+ for (const u of n) {
101
+ const h = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), m = ar(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, r, !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), o.push(new Uint8Array(f.buffer), d, h), s.push({ name: u.name, bytes: h, crc: m, offset: a }), a += 30 + d.length + h.length;
103
103
  }
104
104
  const l = a;
105
- for (const u of o) {
105
+ for (const u of s) {
106
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;
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, r, !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), o.push(new Uint8Array(d.buffer), h), a += 46 + h.length;
108
108
  }
109
109
  const c = new DataView(new ArrayBuffer(22));
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" });
110
+ return c.setUint32(0, 101010256, !0), c.setUint16(4, 0, !0), c.setUint16(6, 0, !0), c.setUint16(8, s.length, !0), c.setUint16(10, s.length, !0), c.setUint32(12, a - l, !0), c.setUint32(16, l, !0), c.setUint16(20, 0, !0), o.push(new Uint8Array(c.buffer)), new Blob(o, { type: "application/zip" });
111
111
  }
112
- const ft = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], ve = {
112
+ const mt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Ee = {
113
113
  protan: "protanopia",
114
114
  deutan: "deuteranopia",
115
115
  tritan: "tritanopia",
116
116
  achroma: "achromatopsia"
117
117
  };
118
- function It(r) {
119
- const t = r?.trim().toLowerCase();
120
- return !t || t === "none" ? null : ft.includes(t) ? t : ve[t] ?? null;
118
+ function Ot(n) {
119
+ const t = n?.trim().toLowerCase();
120
+ return !t || t === "none" ? null : mt.includes(t) ? t : Ee[t] ?? null;
121
121
  }
122
- const nr = ["none", ...ft, ...Object.keys(ve)], Rt = {
122
+ const ur = ["none", ...mt, ...Object.keys(Ee)], Ut = {
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
- }, j = (r) => {
128
- const t = r / 255;
127
+ }, G = (n) => {
128
+ const t = n / 255;
129
129
  return t <= 0.04045 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4;
130
- }, lt = (r) => {
131
- const t = Math.min(1, Math.max(0, r));
130
+ }, lt = (n) => {
131
+ const t = Math.min(1, Math.max(0, n));
132
132
  return 255 * (t <= 31308e-7 ? t * 12.92 : 1.055 * t ** (1 / 2.4) - 0.055);
133
133
  };
134
- function ir(r) {
135
- const t = r.trim().toLowerCase(), e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);
134
+ function hr(n) {
135
+ const t = n.trim().toLowerCase(), e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);
136
136
  if (e) {
137
- const i = e[1], s = (o) => parseInt(o.length === 1 ? o + o : o, 16);
138
- return i.length === 3 ? { r: s(i[0]), g: s(i[1]), b: s(i[2]) } : { r: s(i.slice(0, 2)), g: s(i.slice(2, 4)), b: s(i.slice(4, 6)) };
137
+ const i = e[1], o = (s) => parseInt(s.length === 1 ? s + s : s, 16);
138
+ return i.length === 3 ? { r: o(i[0]), g: o(i[1]), b: o(i[2]) } : { r: o(i.slice(0, 2)), g: o(i.slice(2, 4)), b: o(i.slice(4, 6)) };
139
139
  }
140
- const n = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(t);
141
- return n ? { r: Number(n[1]), g: Number(n[2]), b: Number(n[3]) } : null;
140
+ const r = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(t);
141
+ return r ? { r: Number(r[1]), g: Number(r[2]), b: Number(r[3]) } : null;
142
142
  }
143
- function jt(r, t) {
144
- const e = Rt[t], [n, i, s] = [j(r.r), j(r.g), j(r.b)];
143
+ function Vt(n, t) {
144
+ const e = Ut[t], [r, i, o] = [G(n.r), G(n.g), G(n.b)];
145
145
  return {
146
- r: lt(e[0] * n + e[1] * i + e[2] * s),
147
- g: lt(e[3] * n + e[4] * i + e[5] * s),
148
- b: lt(e[6] * n + e[7] * i + e[8] * s)
146
+ r: lt(e[0] * r + e[1] * i + e[2] * o),
147
+ g: lt(e[3] * r + e[4] * i + e[5] * o),
148
+ b: lt(e[6] * r + e[7] * i + e[8] * o)
149
149
  };
150
150
  }
151
- function Gt({ 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)];
151
+ function Kt({ r: n, g: t, b: e }) {
152
+ const [r, i, o] = [G(n), G(t), G(e)], s = (r * 0.4124564 + i * 0.3575761 + o * 0.1804375) / 0.95047, a = r * 0.2126729 + i * 0.7151522 + o * 0.072175, l = (r * 0.0193339 + i * 0.119192 + o * 0.9503041) / 1.08883, c = (m) => m > 216 / 24389 ? Math.cbrt(m) : 841 / 108 * m + 4 / 29, [u, h, d] = [c(s), c(a), c(l)];
153
153
  return [116 * h - 16, 500 * (u - h), 200 * (h - d)];
154
154
  }
155
- function qt(r, t) {
156
- const [e, n, i] = Gt(r), [s, o, a] = Gt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(o, a)) / 2, h = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, m] = [n * (1 + h), o * (1 + h)], [f, g] = [Math.hypot(d, i), Math.hypot(m, a)], p = (U, tt) => {
155
+ function Ht(n, t) {
156
+ const [e, r, i] = Kt(n), [o, s, a] = Kt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(r, i) + Math.hypot(s, a)) / 2, h = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, m] = [r * (1 + h), s * (1 + h)], [f, g] = [Math.hypot(d, i), Math.hypot(m, a)], p = (U, tt) => {
157
157
  if (U === 0 && tt === 0) return 0;
158
- const J = Math.atan2(tt, U) * c;
159
- return J >= 0 ? J : J + 360;
160
- }, [b, w] = [p(d, i), p(m, a)], y = s - e, M = g - f;
158
+ const Y = Math.atan2(tt, U) * c;
159
+ return Y >= 0 ? Y : Y + 360;
160
+ }, [b, w] = [p(d, i), p(m, a)], y = o - e, M = g - f;
161
161
  let v = 0;
162
162
  f * g !== 0 && (v = w - b, v > 180 ? v -= 360 : v < -180 && (v += 360));
163
- const N = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), O = (e + s) / 2, k = (f + g) / 2;
163
+ const N = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), _ = (e + o) / 2, $ = (f + g) / 2;
164
164
  let P = b + w;
165
165
  f * g !== 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 / $));
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 * (_ - 50) ** 2 / Math.sqrt(20 + (_ - 50) ** 2), S = 1 + 0.045 * $, k = 1 + 0.015 * $ * L, E = -2 * Math.sqrt($ ** 7 / ($ ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((P - 275) / 25) ** 2)) * l);
167
+ return Math.sqrt((y / A) ** 2 + (M / S) ** 2 + (N / k) ** 2 + E * (M / S) * (N / k));
168
168
  }
169
- const or = 10;
170
- function sr(r, t = or) {
169
+ const mr = 10;
170
+ function dr(n, t = mr) {
171
171
  const e = /* @__PURE__ */ new Map();
172
- for (const a of r) {
173
- const l = ir(a.color);
172
+ for (const a of n) {
173
+ const l = hr(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
- const n = [], i = /* @__PURE__ */ new Map();
179
- for (const a of ft)
178
+ const r = [], i = /* @__PURE__ */ new Map();
179
+ for (const a of mt)
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 (qt(l[c].rgb, l[u].rgb) < t) continue;
184
- const d = qt(jt(l[c].rgb, a), jt(l[u].rgb, a));
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));
183
+ if (Ht(l[c].rgb, l[u].rgb) < t) continue;
184
+ const d = Ht(Vt(l[c].rgb, a), Vt(l[u].rgb, a));
185
+ d < t && (r.push({ type: a, a: l[c].entry, b: l[u].entry, distance: d }), i.set(a, (i.get(a) ?? 0) + 1));
186
186
  }
187
- let s = null, o = 0;
187
+ let o = null, s = 0;
188
188
  for (const [a, l] of i)
189
- l > o && (o = l, s = a);
190
- return { collapses: n, worstType: s };
189
+ l > s && (s = l, o = a);
190
+ return { collapses: r, worstType: o };
191
191
  }
192
- function ar(r, t, e, n) {
192
+ function fr(n, t, e, r) {
193
193
  if (t <= 0 || e <= 0) return !0;
194
194
  let i;
195
195
  try {
196
- i = r.getImageData(0, 0, t, e);
196
+ i = n.getImageData(0, 0, t, e);
197
197
  } catch {
198
198
  return !1;
199
199
  }
200
- const s = new Float64Array(256);
201
- for (let h = 0; h < 256; h++) s[h] = j(h);
202
- const o = 1024, a = new Float64Array(o + 1);
203
- for (let h = 0; h <= o; h++) a[h] = lt(h / o);
200
+ const o = new Float64Array(256);
201
+ for (let h = 0; h < 256; h++) o[h] = G(h);
202
+ const s = 1024, a = new Float64Array(s + 1);
203
+ for (let h = 0; h <= s; h++) a[h] = lt(h / s);
204
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 = Rt[n], u = i.data;
205
+ const d = Math.min(1, Math.max(0, h)) * s, m = Math.floor(d);
206
+ return m >= s ? a[s] : a[m] + (a[m + 1] - a[m]) * (d - m);
207
+ }, c = Ut[r], u = i.data;
208
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]];
209
+ const d = o[u[h]], m = o[u[h + 1]], f = o[u[h + 2]];
210
210
  u[h] = l(c[0] * d + c[1] * m + c[2] * f), u[h + 1] = l(c[3] * d + c[4] * m + c[5] * f), u[h + 2] = l(c[6] * d + c[7] * m + c[8] * f);
211
211
  }
212
- return r.putImageData(i, 0, 0), !0;
212
+ return n.putImageData(i, 0, 0), !0;
213
213
  }
214
- const Me = (r) => `om-carto-cvd-${r}`;
215
- function lr(r) {
216
- if (r.getElementById("om-carto-cvd-filters")) return;
217
- const t = r.createElementNS("http://www.w3.org/2000/svg", "svg");
214
+ const Ne = (n) => `om-carto-cvd-${n}`;
215
+ function gr(n) {
216
+ if (n.getElementById("om-carto-cvd-filters")) return;
217
+ const t = n.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 ft) {
220
- const n = r.createElementNS("http://www.w3.org/2000/svg", "filter");
221
- n.id = Me(e), n.setAttribute("color-interpolation-filters", "linearRGB");
222
- const i = r.createElementNS("http://www.w3.org/2000/svg", "feColorMatrix");
219
+ for (const e of mt) {
220
+ const r = n.createElementNS("http://www.w3.org/2000/svg", "filter");
221
+ r.id = Ne(e), r.setAttribute("color-interpolation-filters", "linearRGB");
222
+ const i = n.createElementNS("http://www.w3.org/2000/svg", "feColorMatrix");
223
223
  i.setAttribute("type", "matrix");
224
- const s = Rt[e];
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);
224
+ const o = Ut[e];
225
+ i.setAttribute("values", [o[0], o[1], o[2], 0, 0, o[3], o[4], o[5], 0, 0, o[6], o[7], o[8], 0, 0, 0, 0, 0, 1, 0].join(" ")), r.appendChild(i), t.appendChild(r);
226
226
  }
227
- r.body.appendChild(t);
227
+ n.body.appendChild(t);
228
228
  }
229
- const Ae = 16384, Se = 134217728;
230
- async function cr(r) {
231
- const t = [], e = [...r.querySelectorAll("img")];
229
+ const Pe = 16384, Te = 134217728;
230
+ async function pr(n) {
231
+ const t = [], e = [...n.querySelectorAll("img")];
232
232
  return await Promise.all(
233
- e.map(async (n) => {
234
- if (!(n.complete && n.naturalWidth > 0))
233
+ e.map(async (r) => {
234
+ if (!(r.complete && r.naturalWidth > 0))
235
235
  try {
236
- await n.decode();
236
+ await r.decode();
237
237
  } catch {
238
- t.push(`Image did not load and was skipped: ${n.getAttribute("src") ?? "(no src)"}`);
238
+ t.push(`Image did not load and was skipped: ${r.getAttribute("src") ?? "(no src)"}`);
239
239
  }
240
240
  })
241
241
  ), t;
242
242
  }
243
- function ur(r) {
244
- return [...r.children].filter(
243
+ function br(n) {
244
+ return [...n.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
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 Ot(r, t = {}) {
249
- const e = r ?? document.querySelector("om-cartograph");
248
+ async function Dt(n, t = {}) {
249
+ const e = n ?? document.querySelector("om-cartograph");
250
250
  if (!e) throw new Error("[onlymapjs/cartograph] renderCartograph: no <om-cartograph> to render.");
251
- const n = [], i = t.dpi ?? (Number(e.getAttribute("dpi")) || 300);
251
+ const r = [], 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 } = ut(
253
+ const { widthMm: o, heightMm: s } = 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, h = t.maxArea ?? Se;
258
+ ), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = o + a * 2, c = s + a * 2, u = t.maxDimension ?? Pe, h = t.maxArea ?? Te;
259
259
  let d = i;
260
260
  const m = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(h / (l / 25.4 * (c / 25.4))), g = Math.min(m, f);
261
- d > g && (d = Math.floor(g), n.push(`Requested ${i} dpi exceeds this browser's canvas budget for a ${l.toFixed(0)}×${c.toFixed(0)}mm page; rendered at ${d} dpi instead.`)), n.push(...await cr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
262
- const p = Ut(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y = ur(e);
261
+ d > g && (d = Math.floor(g), r.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.`)), r.push(...await pr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
262
+ const p = qt(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y = br(e);
263
263
  for (const A of y)
264
- if (!(!gt(A) || !A.prepareCartograph))
264
+ if (!(!ft(A) || !A.prepareCartograph))
265
265
  try {
266
- await A.prepareCartograph(Ut(d));
266
+ await A.prepareCartograph(qt(d));
267
267
  } catch (S) {
268
- A.discardCartograph?.(), n.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} could not be captured: ${S.message}`);
268
+ A.discardCartograph?.(), r.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} could not be captured: ${S.message}`);
269
269
  }
270
270
  const M = document.createElement("canvas");
271
271
  M.width = b, M.height = w;
@@ -274,151 +274,151 @@ async function Ot(r, t = {}) {
274
274
  const N = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
275
275
  v.fillStyle = F(N?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
276
276
  for (const A of y) {
277
- if (!gt(A)) continue;
277
+ if (!ft(A)) continue;
278
278
  const S = C(A);
279
279
  if (v.save(), v.translate((S.x + a) * p.pxPerMm, (S.y + a) * p.pxPerMm), S.rotation) {
280
- const $ = S.w / 2 * p.pxPerMm, E = S.h / 2 * p.pxPerMm;
281
- v.translate($, E), v.rotate(S.rotation * Math.PI / 180), v.translate(-$, -E);
280
+ const k = S.w / 2 * p.pxPerMm, E = S.h / 2 * p.pxPerMm;
281
+ v.translate(k, E), v.rotate(S.rotation * Math.PI / 180), v.translate(-k, -E);
282
282
  }
283
283
  try {
284
284
  A.paintCartograph(v, p);
285
- } catch ($) {
286
- n.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} failed to render: ${$.message}`);
285
+ } catch (k) {
286
+ r.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} failed to render: ${k.message}`);
287
287
  }
288
288
  v.restore();
289
289
  }
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) * p.pxPerMm, v.beginPath(), v.moveTo((S + a) * p.pxPerMm, ($ + a) * p.pxPerMm), v.lineTo((E + a) * p.pxPerMm, (U + a) * p.pxPerMm), v.stroke(), v.restore());
290
+ const _ = e.querySelector(":scope > [data-om-carto-marks]");
291
+ for (const A of _?.querySelectorAll("line") ?? []) {
292
+ const S = Number(A.getAttribute("x1")), k = Number(A.getAttribute("y1")), E = Number(A.getAttribute("x2")), U = Number(A.getAttribute("y2"));
293
+ [S, k, E, U].every(Number.isFinite) && (v.save(), v.strokeStyle = A.getAttribute("stroke") || "#000000", v.lineWidth = (Number(A.getAttribute("stroke-width")) || 0.2) * p.pxPerMm, v.beginPath(), v.moveTo((S + a) * p.pxPerMm, (k + a) * p.pxPerMm), v.lineTo((E + a) * p.pxPerMm, (U + a) * p.pxPerMm), v.stroke(), v.restore());
294
294
  }
295
- const k = It(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) gt(A) && A.discardCartograph?.();
295
+ const $ = Ot(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
296
+ $ && !fr(v, b, w, $) && r.push("Colour-vision simulation was skipped: a cross-origin image on the page makes the export canvas unreadable.");
297
+ for (const A of y) ft(A) && A.discardCartograph?.();
298
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.");
299
+ P === "image/jpeg" && e.querySelector("om-text") && r.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
300
300
  const L = await new Promise((A) => M.toBlob(A, P, t.quality));
301
301
  if (!L) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
302
- return { blob: L, widthPx: b, heightPx: w, dpi: d, warnings: n };
302
+ return { blob: L, widthPx: b, heightPx: w, dpi: d, warnings: r };
303
303
  }
304
- async function Ce(r, t = {}) {
305
- const e = r ?? document.querySelector("om-cartograph");
304
+ async function Le(n, t = {}) {
305
+ const e = n ?? document.querySelector("om-cartograph");
306
306
  if (!e) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: no <om-cartograph> to render.");
307
- const n = e.querySelector("om-atlas") ?? null;
308
- if (!n) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: this cartograph has no <om-atlas>.");
309
- if (n.problem)
310
- throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: the atlas layer cannot drive pages (${n.problem}).`);
311
- const i = n.count;
307
+ const r = e.querySelector("om-atlas") ?? null;
308
+ if (!r) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: this cartograph has no <om-atlas>.");
309
+ if (r.problem)
310
+ throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: the atlas layer cannot drive pages (${r.problem}).`);
311
+ const i = r.count;
312
312
  if (i === 0) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: the atlas layer produced no features.");
313
- const s = t.format === "jpeg" ? "jpg" : "png", o = n.filenames(s), a = [], l = n.index;
313
+ const o = t.format === "jpeg" ? "jpg" : "png", s = r.filenames(o), a = [], l = r.index;
314
314
  try {
315
315
  if (t.page != null) {
316
316
  const h = Math.trunc(t.page);
317
317
  if (!Number.isInteger(h) || h < 0 || h >= i)
318
318
  throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: page ${t.page} is out of range (this atlas has ${i}).`);
319
- n.seek(h);
320
- const d = await Wt(e, t, a);
321
- return { blob: d.blob, filenames: [o[h]], pages: 1, dpi: d.dpi, warnings: a };
319
+ r.seek(h);
320
+ const d = await Yt(e, t, a);
321
+ return { blob: d.blob, filenames: [s[h]], pages: 1, dpi: d.dpi, warnings: a };
322
322
  }
323
323
  const c = [];
324
324
  let u = t.dpi ?? 300;
325
325
  for (let h = 0; h < i; h++) {
326
- n.seek(h);
327
- const d = await Wt(e, t, a);
328
- u = d.dpi, c.push({ name: o[h], data: d.blob }), t.onPage?.(h + 1, i);
326
+ r.seek(h);
327
+ const d = await Yt(e, t, a);
328
+ u = d.dpi, c.push({ name: s[h], data: d.blob }), t.onPage?.(h + 1, i);
329
329
  }
330
- return { blob: await rr(c), filenames: o, pages: i, dpi: u, warnings: a };
330
+ return { blob: await cr(c), filenames: s, pages: i, dpi: u, warnings: a };
331
331
  } finally {
332
- n.seek(l);
332
+ r.seek(l);
333
333
  }
334
334
  }
335
- async function Wt(r, t, e) {
336
- for (const i of r.querySelectorAll("om-frame"))
335
+ async function Yt(n, t, e) {
336
+ for (const i of n.querySelectorAll("om-frame"))
337
337
  await i.mapElement?.whenSettled?.({ timeout: 2e4 });
338
- const n = await Ot(r, t);
339
- return e.push(...n.warnings), n;
338
+ const r = await Dt(n, t);
339
+ return e.push(...r.warnings), r;
340
340
  }
341
- const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
341
+ const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
342
342
  __proto__: null,
343
- MAX_CANVAS_AREA: Se,
344
- MAX_CANVAS_DIMENSION: Ae,
345
- renderCartograph: Ot,
346
- renderCartographAtlas: Ce
343
+ MAX_CANVAS_AREA: Te,
344
+ MAX_CANVAS_DIMENSION: Pe,
345
+ renderCartograph: Dt,
346
+ renderCartographAtlas: Le
347
347
  }, Symbol.toStringTag, { value: "Module" }));
348
- function Bt(r, t, e = {}) {
349
- const n = URL.createObjectURL(r), i = document.createElement("a");
350
- i.href = n, i.download = t, document.body.appendChild(i), i.click(), i.remove();
351
- const s = e.revokeAfterMs ?? 0;
352
- s > 0 ? setTimeout(() => URL.revokeObjectURL(n), s) : URL.revokeObjectURL(n);
353
- }
354
- const mr = 3e4;
355
- async function Vt(r, t = mr) {
348
+ function Xt(n, t, e = {}) {
349
+ const r = URL.createObjectURL(n), i = document.createElement("a");
350
+ i.href = r, i.download = t, document.body.appendChild(i), i.click(), i.remove();
351
+ const o = e.revokeAfterMs ?? 0;
352
+ o > 0 ? setTimeout(() => URL.revokeObjectURL(r), o) : URL.revokeObjectURL(r);
353
+ }
354
+ const wr = 3e4;
355
+ async function Jt(n, t = wr) {
356
356
  let e = !1;
357
- const n = new Promise(
358
- (s) => setTimeout(() => {
359
- e = !0, s();
357
+ const r = new Promise(
358
+ (o) => setTimeout(() => {
359
+ e = !0, o();
360
360
  }, t)
361
361
  ), i = (async () => {
362
- const s = [...r.querySelectorAll("om-frame")];
363
- await Promise.all(s.map((a) => a.ready ?? Promise.resolve()));
364
- const o = [...r.querySelectorAll("img")];
362
+ const o = [...n.querySelectorAll("om-frame")];
363
+ await Promise.all(o.map((a) => a.ready ?? Promise.resolve()));
364
+ const s = [...n.querySelectorAll("img")];
365
365
  await Promise.all(
366
- o.map(async (a) => {
366
+ s.map(async (a) => {
367
367
  a.complete || await new Promise((l) => {
368
368
  a.addEventListener("load", () => l(), { once: !0 }), a.addEventListener("error", () => l(), { once: !0 });
369
369
  });
370
370
  })
371
371
  ), typeof document < "u" && document.fonts?.ready && document.fonts.status !== "loaded" && await document.fonts.ready;
372
372
  })();
373
- return await Promise.race([i, n]), { timedOut: e };
373
+ return await Promise.race([i, r]), { timedOut: e };
374
374
  }
375
- async function dr(r, t = {}) {
376
- if (!r.hasAttribute("allow-url-actions") || typeof document < "u" && document.documentElement?.dataset?.omHost === "editor") return null;
375
+ async function vr(n, t = {}) {
376
+ if (!n.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;
379
- const n = new URLSearchParams(e), i = n.get("cvd");
380
- i && r.setAttribute("cvd", i);
381
- const s = n.get("export");
382
- if (s) {
383
- await Vt(r, t.timeoutMs);
384
- const o = s === "jpeg" ? "jpeg" : "png", a = Number(n.get("dpi")) || void 0, l = r.getAttribute("cartograph-id") || "cartograph", c = n.get("page");
379
+ const r = new URLSearchParams(e), i = r.get("cvd");
380
+ i && n.setAttribute("cvd", i);
381
+ const o = r.get("export");
382
+ if (o) {
383
+ await Jt(n, t.timeoutMs);
384
+ const s = o === "jpeg" ? "jpeg" : "png", a = Number(r.get("dpi")) || void 0, l = n.getAttribute("cartograph-id") || "cartograph", c = r.get("page");
385
385
  if (c != null) {
386
- const h = r.querySelector("om-atlas");
386
+ const h = n.querySelector("om-atlas");
387
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
390
  h.refresh?.();
391
- const m = await Ce(r, { dpi: a, format: o, page: d - 1 });
391
+ const m = await Le(n, { dpi: a, format: s, page: d - 1 });
392
392
  for (const f of m.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
393
- return Bt(m.blob, m.filenames[0] ?? `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
393
+ return Xt(m.blob, m.filenames[0] ?? `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
394
394
  }
395
- const u = await Ot(r, { dpi: a, format: o });
395
+ const u = await Dt(n, { dpi: a, format: s });
396
396
  for (const h of u.warnings) console.warn(`[onlymapjs/cartograph] ${h}`);
397
- return Bt(u.blob, `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
397
+ return Xt(u.blob, `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
398
398
  }
399
- return n.get("print") === "1" ? (await Vt(r, t.timeoutMs), typeof r.print == "function" ? await r.print({ dpi: Number(n.get("dpi")) || void 0 }) : typeof window < "u" && window.print(), "print") : i ? "cvd" : null;
399
+ return r.get("print") === "1" ? (await Jt(n, t.timeoutMs), typeof n.print == "function" ? await n.print({ dpi: Number(r.get("dpi")) || void 0 }) : typeof window < "u" && window.print(), "print") : i ? "cvd" : null;
400
400
  }
401
- function fr() {
401
+ function Mr() {
402
402
  if (typeof document > "u") return;
403
- const r = () => {
403
+ const n = () => {
404
404
  for (const t of document.querySelectorAll("om-cartograph[allow-url-actions]"))
405
- dr(t).catch((e) => console.warn(`[onlymapjs/cartograph] URL action failed: ${e.message}`));
405
+ vr(t).catch((e) => console.warn(`[onlymapjs/cartograph] URL action failed: ${e.message}`));
406
406
  };
407
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", r, { once: !0 }) : r();
407
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", n, { once: !0 }) : n();
408
408
  }
409
- const xe = typeof window < "u" && typeof document < "u" && typeof customElements < "u", gr = xe ? HTMLElement : class {
409
+ const Fe = typeof window < "u" && typeof document < "u" && typeof customElements < "u", Ar = Fe ? HTMLElement : class {
410
410
  };
411
- function x(r, t) {
412
- xe && (customElements.get(r) || customElements.define(r, t));
411
+ function x(n, t) {
412
+ Fe && (customElements.get(n) || customElements.define(n, t));
413
413
  }
414
- function pr(r) {
414
+ function Sr(n) {
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
- return new DOMParser().parseFromString(r, "text/html");
419
+ return new DOMParser().parseFromString(n, "text/html");
420
420
  }
421
- class R extends gr {
421
+ class I extends Ar {
422
422
  renderQueued = !1;
423
423
  connectedCallback() {
424
424
  this.scheduleRender();
@@ -442,15 +442,15 @@ class R extends gr {
442
442
  if (c == null || c === "") return null;
443
443
  const u = Number(c);
444
444
  return Number.isFinite(u) ? u : null;
445
- }, e = t("x"), n = t("y"), i = t("w"), s = t("h");
446
- this.style.position = "absolute", e != null && (this.style.left = `${e}mm`), n != null && (this.style.top = `${n}mm`), i != null && (this.style.width = `${i}mm`), s != null && (this.style.height = `${s}mm`);
447
- const o = t("rotation");
448
- o != null && o !== 0 ? (this.style.transform = `rotate(${o}deg)`, this.style.transformOrigin = "center") : this.style.removeProperty("transform");
445
+ }, e = t("x"), r = t("y"), i = t("w"), o = t("h");
446
+ this.style.position = "absolute", e != null && (this.style.left = `${e}mm`), r != null && (this.style.top = `${r}mm`), i != null && (this.style.width = `${i}mm`), o != null && (this.style.height = `${o}mm`);
447
+ const s = t("rotation");
448
+ s != null && s !== 0 ? (this.style.transform = `rotate(${s}deg)`, this.style.transformOrigin = "center") : this.style.removeProperty("transform");
449
449
  const a = t("z");
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", Hn = ["default", "dark", "sepia", "blueprint", "minimal"], Ht = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], br = /* @__PURE__ */ new Map([
453
+ const gt = "cartograph/2", si = ["default", "dark", "sepia", "blueprint", "minimal"], Zt = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], Cr = /* @__PURE__ */ new Map([
454
454
  ["projection", "live frames render Web Mercator (EPSG:3857) only — Globe support is design-only; use a static frame for other projections"]
455
455
  ]), z = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], T = {
456
456
  "om-cartograph": ["cartograph-id", "format", "size", "width", "height", "orientation", "theme", "title", "attribution", "notes", "cvd", "bleed", "crop-marks", "safe-zone", "dpi", "flatten", "color-profile", "allow-url-actions", "keep-badge"],
@@ -468,60 +468,60 @@ const pt = "cartograph/2", Hn = ["default", "dark", "sepia", "blueprint", "minim
468
468
  "om-shape": [...z, "kind", "fill", "fill-opacity", "stroke", "stroke-width", "radius"],
469
469
  "om-image": [...z, "src", "fit"],
470
470
  "om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name"]
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;
471
+ }, pt = Object.keys(T), kt = "data-om-carto-vector", xr = ["metric", "imperial", "nautical"], $r = 0.3048, kr = 1609.344, Er = 1852;
472
+ function Nr(n) {
473
+ return n != null && xr.includes(n) ? n : null;
474
474
  }
475
- function ke(r) {
476
- if (!isFinite(r) || r <= 0) return 0;
477
- const t = Math.pow(10, Math.floor(Math.log10(r))), e = r / t;
475
+ function Re(n) {
476
+ if (!isFinite(n) || n <= 0) return 0;
477
+ const t = Math.pow(10, Math.floor(Math.log10(n))), e = n / t;
478
478
  return (e >= 5 ? 5 : e >= 2 ? 2 : 1) * t;
479
479
  }
480
- const Kt = {
480
+ const Qt = {
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: wr, label: "ft" },
488
- { metersPerUnit: vr, label: "mi" }
487
+ { metersPerUnit: $r, label: "ft" },
488
+ { metersPerUnit: kr, label: "mi" }
489
489
  ],
490
- nautical: [{ metersPerUnit: Mr, label: "nmi" }]
490
+ nautical: [{ metersPerUnit: Er, label: "nmi" }]
491
491
  };
492
- function $e({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
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 = Kt[n] ?? Kt.metric, a = t / s * r;
492
+ function Ie({ groundMetersPerMm: n, maxWidthMm: t, segments: e = 4, units: r = "metric", segmentLengthMeters: i }) {
493
+ if (!Number.isFinite(n) || n <= 0 || !Number.isFinite(t) || t <= 0) return null;
494
+ const o = Number.isInteger(e) && e > 0 ? e : 4, s = Qt[r] ?? Qt.metric, a = t / o * n;
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 = te(s, l);
498
498
  else {
499
- c = Yt(o, a);
500
- const f = ke(a / c.metersPerUnit);
499
+ c = te(s, a);
500
+ const f = Re(a / c.metersPerUnit);
501
501
  if (f <= 0) return null;
502
502
  l = f * c.metersPerUnit;
503
503
  }
504
- const u = l / r;
504
+ const u = l / n;
505
505
  if (!Number.isFinite(u) || u <= 0) return null;
506
- const h = l / c.metersPerUnit, d = h < 1 ? 2 : h < 10 && !Number.isInteger(h) ? 1 : 0, m = Array.from({ length: s + 1 }, (f, g) => (g * h).toFixed(d));
506
+ const h = l / c.metersPerUnit, d = h < 1 ? 2 : h < 10 && !Number.isInteger(h) ? 1 : 0, m = Array.from({ length: o + 1 }, (f, g) => (g * h).toFixed(d));
507
507
  return {
508
508
  segmentMeters: l,
509
509
  segmentMm: u,
510
- segments: s,
511
- totalMm: u * s,
510
+ segments: o,
511
+ totalMm: u * o,
512
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
- scaleDenominator: r * 1e3
516
+ scaleDenominator: n * 1e3
517
517
  };
518
518
  }
519
- function Sr(r, t, e) {
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 = [];
519
+ function Pr(n, t, e) {
520
+ const r = Math.min(2.6, Math.max(1.6, e * 0.34)), i = 0.2, o = r * 1.25, s = Math.max(0.6, Math.min(2.2, e - o - 0.4)), a = 0, l = n.segmentMm, c = [], u = [];
521
521
  if (t === "single" || t === "double") {
522
- const p = t === "double" ? 2 : 1, b = o / p;
522
+ const p = t === "double" ? 2 : 1, b = s / p;
523
523
  for (let w = 0; w < p; w++)
524
- for (let y = 0; y < r.segments; y++)
524
+ for (let y = 0; y < n.segments; y++)
525
525
  c.push({
526
526
  x: y * l,
527
527
  y: a + w * b,
@@ -531,128 +531,128 @@ function Sr(r, t, e) {
531
531
  filled: (y + w) % 2 === 0
532
532
  });
533
533
  } else {
534
- u.push({ x1: 0, y1: a + o, x2: r.totalMm, y2: a + o });
535
- const p = t === "ticks" ? r.segments : 1;
534
+ u.push({ x1: 0, y1: a + s, x2: n.totalMm, y2: a + s });
535
+ const p = t === "ticks" ? n.segments : 1;
536
536
  for (let b = 0; b <= p; b++) {
537
- const w = b / p * r.totalMm;
538
- u.push({ x1: w, y1: a, x2: w, y2: a + o });
537
+ const w = b / p * n.totalMm;
538
+ u.push({ x1: w, y1: a, x2: w, y2: a + s });
539
539
  }
540
540
  }
541
- const h = r.labels.length - 1, d = r.labels.map((p, b) => ({
541
+ const h = n.labels.length - 1, d = n.labels.map((p, b) => ({
542
542
  // The end label carries the unit so the bar reads "0 2 4 6 8 km".
543
- text: b === h ? `${p} ${r.unitLabel}` : p,
543
+ text: b === h ? `${p} ${n.unitLabel}` : p,
544
544
  // Keep the end label inside the drawn width rather than hanging off it.
545
- x: b === h ? r.totalMm : b * l,
546
- y: a + o + n,
545
+ x: b === h ? n.totalMm : b * l,
546
+ y: a + s + r,
547
547
  anchor: b === 0 ? "start" : b === h ? "end" : "middle",
548
548
  index: b
549
- })), m = (p) => p.length * n * 0.62, f = [];
549
+ })), m = (p) => p.length * r * 0.62, f = [];
550
550
  let g = -1 / 0;
551
551
  for (const p of d) {
552
552
  const b = m(p.text) / 2, w = p.anchor === "start" ? p.x : p.anchor === "end" ? p.x - b * 2 : p.x - b, y = w + m(p.text);
553
- if (!(!(p.index === 0 || p.index === h) && w < g + n * 0.4)) {
554
- if (p.index === h && w < g + n * 0.4)
555
- for (; f.length > 1 && f[f.length - 1].x + m(f[f.length - 1].text) / 2 > w - n * 0.4; ) f.pop();
553
+ if (!(!(p.index === 0 || p.index === h) && w < g + r * 0.4)) {
554
+ if (p.index === h && w < g + r * 0.4)
555
+ for (; f.length > 1 && f[f.length - 1].x + m(f[f.length - 1].text) / 2 > w - r * 0.4; ) f.pop();
556
556
  f.push({ text: p.text, x: p.x, y: p.y, anchor: p.anchor }), g = y;
557
557
  }
558
558
  }
559
- return { bars: c, strokes: u, labels: f, fontMm: n, strokeMm: i, segmentMeters: r.segmentMeters, unitLabel: r.unitLabel, scaleDenominator: r.scaleDenominator };
559
+ return { bars: c, strokes: u, labels: f, fontMm: r, strokeMm: i, segmentMeters: n.segmentMeters, unitLabel: n.unitLabel, scaleDenominator: n.scaleDenominator };
560
560
  }
561
- function Yt(r, t) {
562
- let e = r[0];
563
- for (const n of r)
564
- t / n.metersPerUnit >= 1 && (e = n);
561
+ function te(n, t) {
562
+ let e = n[0];
563
+ for (const r of n)
564
+ t / r.metersPerUnit >= 1 && (e = r);
565
565
  return e;
566
566
  }
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);
567
+ const Tr = " ";
568
+ function Lr(n) {
569
+ return !Number.isFinite(n) || n <= 0 ? "" : Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, Tr);
570
570
  }
571
- const Ee = /\{\{\s*([\w.]+)\s*\}\}/g;
572
- function kr(r, t) {
573
- if (r.startsWith("atlas.")) return t.atlas?.[r.slice(6)];
574
- if (r.startsWith("frame.")) {
575
- const e = r.slice(6), n = e.lastIndexOf(".");
576
- return n <= 0 ? void 0 : t.frames?.get(e.slice(0, n))?.[e.slice(n + 1)];
571
+ const _e = /\{\{\s*([\w.]+)\s*\}\}/g;
572
+ function Fr(n, t) {
573
+ if (n.startsWith("atlas.")) return t.atlas?.[n.slice(6)];
574
+ if (n.startsWith("frame.")) {
575
+ const e = n.slice(6), r = e.lastIndexOf(".");
576
+ return r <= 0 ? void 0 : t.frames?.get(e.slice(0, r))?.[e.slice(r + 1)];
577
577
  }
578
- if ((r === "scale" || r === "crs") && t.soleFrameId) {
579
- const n = t.frames?.get(t.soleFrameId)?.[r];
580
- if (n !== void 0) return n;
578
+ if ((n === "scale" || n === "crs") && t.soleFrameId) {
579
+ const r = t.frames?.get(t.soleFrameId)?.[n];
580
+ if (r !== void 0) return r;
581
581
  }
582
- return t.page[r];
582
+ return t.page[n];
583
583
  }
584
- function Ne(r, t) {
584
+ function Oe(n, t) {
585
585
  const e = [];
586
- return { text: r.replace(Ee, (i, s) => {
587
- const o = kr(s, t);
588
- return o === void 0 ? (e.push(s), i) : o;
586
+ return { text: n.replace(_e, (i, o) => {
587
+ const s = Fr(o, t);
588
+ return s === void 0 ? (e.push(o), i) : s;
589
589
  }), unresolved: e };
590
590
  }
591
- function $r(r) {
592
- return [...r.matchAll(Ee)].map((t) => t[1]);
591
+ function Rr(n) {
592
+ return [...n.matchAll(_e)].map((t) => t[1]);
593
593
  }
594
- const Xt = /* @__PURE__ */ new WeakMap();
595
- function Er(r, t) {
596
- const e = [], n = r.ownerDocument ?? (typeof document < "u" ? document : null);
597
- if (!n) return e;
598
- const i = n.createTreeWalker(
599
- r,
594
+ const ee = /* @__PURE__ */ new WeakMap();
595
+ function Ir(n, t) {
596
+ const e = [], r = n.ownerDocument ?? (typeof document < "u" ? document : null);
597
+ if (!r) return e;
598
+ const i = r.createTreeWalker(
599
+ n,
600
600
  4
601
601
  /* NodeFilter.SHOW_TEXT */
602
- ), s = [];
603
- for (let o = i.nextNode(); o; o = i.nextNode()) s.push(o);
604
- for (const o of s) {
605
- let a = Xt.get(o);
602
+ ), o = [];
603
+ for (let s = i.nextNode(); s; s = i.nextNode()) o.push(s);
604
+ for (const s of o) {
605
+ let a = ee.get(s);
606
606
  if (a === void 0) {
607
- if (a = o.data, !a.includes("{{")) continue;
608
- Xt.set(o, a);
607
+ if (a = s.data, !a.includes("{{")) continue;
608
+ ee.set(s, a);
609
609
  }
610
- const l = Ne(a, t);
611
- o.data !== l.text && (o.data = l.text), e.push(...l.unresolved);
610
+ const l = Oe(a, t);
611
+ s.data !== l.text && (s.data = l.text), e.push(...l.unresolved);
612
612
  }
613
613
  return e;
614
614
  }
615
- function Nr(r = /* @__PURE__ */ new Date()) {
616
- return `${r.getFullYear()}-${String(r.getMonth() + 1).padStart(2, "0")}-${String(r.getDate()).padStart(2, "0")}`;
615
+ function _r(n = /* @__PURE__ */ new Date()) {
616
+ return `${n.getFullYear()}-${String(n.getMonth() + 1).padStart(2, "0")}-${String(n.getDate()).padStart(2, "0")}`;
617
617
  }
618
618
  const Et = "data-om-carto-unlinked";
619
- function Pe(r) {
620
- return r.closest("om-cartograph");
619
+ function Ue(n) {
620
+ return n.closest("om-cartograph");
621
621
  }
622
- function Te(r, t) {
623
- const e = Pe(r);
622
+ function De(n, t) {
623
+ const e = Ue(n);
624
624
  if (!e || !t) return null;
625
- for (const n of e.querySelectorAll("om-frame"))
626
- if (n.id === t) return n;
625
+ for (const r of e.querySelectorAll("om-frame"))
626
+ if (r.id === t) return r;
627
627
  return null;
628
628
  }
629
- function Le(r) {
630
- return [...r.querySelectorAll("om-frame")];
629
+ function ze(n) {
630
+ return [...n.querySelectorAll("om-frame")];
631
631
  }
632
- function Pr(r) {
633
- const t = Pe(r);
632
+ function Or(n) {
633
+ const t = Ue(n);
634
634
  if (!t) return null;
635
- const e = Le(t);
635
+ const e = ze(t);
636
636
  return e.length === 1 ? e[0] : null;
637
637
  }
638
- function _(r) {
639
- const t = r.getAttribute("for");
640
- return t ? Te(r, t) : Pr(r);
638
+ function O(n) {
639
+ const t = n.getAttribute("for");
640
+ return t ? De(n, t) : Or(n);
641
641
  }
642
- function G(r, t) {
643
- let e = r.querySelector(`:scope > [${Et}]`);
642
+ function q(n, t) {
643
+ let e = n.querySelector(`:scope > [${Et}]`);
644
644
  if (!e) {
645
- for (const n of [...r.children])
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);
645
+ for (const r of [...n.children])
646
+ r.tagName.toLowerCase() !== "om-legend-row" && r.remove();
647
+ e = n.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;", n.appendChild(e);
648
648
  }
649
649
  e.textContent !== t && (e.textContent = t);
650
650
  }
651
- function Tr(r) {
652
- r.querySelector(`:scope > [${Et}]`)?.remove();
651
+ function Ur(n) {
652
+ n.querySelector(`:scope > [${Et}]`)?.remove();
653
653
  }
654
- const Jt = "data-om-carto-page", Zt = "data-om-carto-marks", yt = "data-om-carto-credit", Fe = "Built with OnlyMap by NIKA", Lr = `${Fe} · free for non-commercial use`, rt = 2, Qt = 1.2, wt = 2.4, te = 1.5, vt = 1.2, ee = 0.3, re = 0.8, Mt = "http://www.w3.org/2000/svg", Fr = 6e4;
655
- class Ie extends R {
654
+ const re = "data-om-carto-page", ne = "data-om-carto-marks", bt = "data-om-carto-credit", je = "Built with OnlyMap by NIKA", Dr = `${je} · free for non-commercial use`, rt = 2, ie = 1.2, yt = 2.4, se = 1.5, wt = 1.2, oe = 0.3, ae = 0.8, vt = "http://www.w3.org/2000/svg", zr = 6e4;
655
+ class Ge extends I {
656
656
  static observedAttributes = [...T["om-cartograph"]];
657
657
  frameListenerBound = !1;
658
658
  /** Fields of the atlas page currently displayed, for {{atlas.<field>}}. */
@@ -674,7 +674,7 @@ class Ie extends R {
674
674
  }), this.addEventListener("om-frame-view", () => {
675
675
  this.refreshTokens(), this.refreshFurniture();
676
676
  })), !this.creditObserver && typeof MutationObserver < "u" && (this.creditObserver = new MutationObserver(() => {
677
- this.querySelector(`:scope > [${yt}]`) || this.renderCredit();
677
+ this.querySelector(`:scope > [${bt}]`) || this.renderCredit();
678
678
  }), this.creditObserver.observe(this, { childList: !0 }));
679
679
  }
680
680
  disconnectedCallback() {
@@ -693,18 +693,18 @@ class Ie extends R {
693
693
  renderCredit() {
694
694
  const t = H();
695
695
  t && !this.unsubscribeLicense && typeof t.subscribeLicense == "function" && (this.unsubscribeLicense = t.subscribeLicense(() => this.renderCredit()));
696
- const e = this.creditMode(t, this.hasAttribute("keep-badge")), n = [...this.querySelectorAll("om-text")].some((a) => /onlymap/i.test(a.textContent ?? "")), i = this.querySelector(`:scope > [${yt}]`);
697
- if (e === "hidden" || n) {
696
+ const e = this.creditMode(t, this.hasAttribute("keep-badge")), r = [...this.querySelectorAll("om-text")].some((a) => /onlymap/i.test(a.textContent ?? "")), i = this.querySelector(`:scope > [${bt}]`);
697
+ if (e === "hidden" || r) {
698
698
  i?.remove();
699
699
  return;
700
700
  }
701
- const s = e === "voluntary" ? Fe : Lr;
701
+ const o = e === "voluntary" ? je : Dr;
702
702
  if (i) {
703
- i.textContent !== s && (i.textContent = s), this.armCreditPainter(i);
703
+ i.textContent !== o && (i.textContent = o), this.armCreditPainter(i);
704
704
  return;
705
705
  }
706
- const o = this.ownerDocument.createElement("div");
707
- o.setAttribute(yt, ""), o.setAttribute("z", "2147483644"), o.textContent = s, o.style.cssText = `position:absolute;left:${rt}mm;bottom:${Qt}mm;z-index:2147483644;font:${wt}mm/${te} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${ee}mm ${vt}mm;border-radius:${re}mm;pointer-events:none;`, this.armCreditPainter(o), this.appendChild(o);
706
+ const s = this.ownerDocument.createElement("div");
707
+ s.setAttribute(bt, ""), s.setAttribute("z", "2147483644"), s.textContent = o, s.style.cssText = `position:absolute;left:${rt}mm;bottom:${ie}mm;z-index:2147483644;font:${yt}mm/${se} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${oe}mm ${wt}mm;border-radius:${ae}mm;pointer-events:none;`, this.armCreditPainter(s), this.appendChild(s);
708
708
  }
709
709
  /**
710
710
  * Which credit this sheet carries, from the core's own predicate so the
@@ -715,16 +715,16 @@ class Ie extends R {
715
715
  if (!t) return "obligation";
716
716
  if (typeof t.badgeMode != "function")
717
717
  return t.getEntitlements().hideBadge && !e ? "hidden" : "obligation";
718
- const n = t.badgeMode({ keepBadge: e });
719
- return n === "pending" ? "obligation" : n;
718
+ const r = t.badgeMode({ keepBadge: e });
719
+ return r === "pending" ? "obligation" : r;
720
720
  }
721
721
  /** Give the runtime-owned DOM credit the same canvas paint contract as authored furniture. */
722
722
  armCreditPainter(t) {
723
- t.paintCartograph = (e, n) => {
724
- const i = (u) => u * n.pxPerMm, s = t.textContent ?? "", a = wt * te + ee * 2, l = this.pageSize.heightMm - Qt - a;
725
- e.save(), e.font = `${i(wt)}px system-ui, sans-serif`;
726
- const c = e.measureText(s).width / n.pxPerMm + vt * 2;
727
- e.fillStyle = "rgba(255,255,255,.72)", e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(i(rt), i(l), i(c), i(a), i(re)) : e.rect(i(rt), i(l), i(c), i(a)), e.fill(), e.fillStyle = "#374151", e.textAlign = "left", e.textBaseline = "middle", e.fillText(s, i(rt + vt), i(l + a / 2)), e.restore();
723
+ t.paintCartograph = (e, r) => {
724
+ const i = (u) => u * r.pxPerMm, o = t.textContent ?? "", a = yt * se + oe * 2, l = this.pageSize.heightMm - ie - a;
725
+ e.save(), e.font = `${i(yt)}px system-ui, sans-serif`;
726
+ const c = e.measureText(o).width / r.pxPerMm + wt * 2;
727
+ e.fillStyle = "rgba(255,255,255,.72)", e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(i(rt), i(l), i(c), i(a), i(ae)) : e.rect(i(rt), i(l), i(c), i(a)), e.fill(), e.fillStyle = "#374151", e.textAlign = "left", e.textBaseline = "middle", e.fillText(o, i(rt + wt), i(l + a / 2)), e.restore();
728
728
  };
729
729
  }
730
730
  /**
@@ -738,30 +738,30 @@ class Ie extends R {
738
738
  * synchronously and captures are asynchronous.
739
739
  */
740
740
  async print(t = {}) {
741
- const e = t.dpi ?? (Number(this.getAttribute("dpi")) || 300), n = [...this.querySelectorAll("om-frame")];
741
+ const e = t.dpi ?? (Number(this.getAttribute("dpi")) || 300), r = [...this.querySelectorAll("om-frame")];
742
742
  let i = null;
743
- if (this.hasAttribute("flatten") && (i = await this.buildFlattenedImage(e).catch(() => null), i && this.appendChild(i)), !i) for (const a of n) await a.enterPrintMode?.(e);
744
- let s = !1;
745
- const o = () => {
746
- if (!s) {
747
- s = !0, i && URL.revokeObjectURL(i.src), i?.remove(), i = null;
748
- for (const a of n) a.exitPrintMode?.();
749
- window.removeEventListener("afterprint", o);
743
+ if (this.hasAttribute("flatten") && (i = await this.buildFlattenedImage(e).catch(() => null), i && this.appendChild(i)), !i) for (const a of r) await a.enterPrintMode?.(e);
744
+ let o = !1;
745
+ const s = () => {
746
+ if (!o) {
747
+ o = !0, i && URL.revokeObjectURL(i.src), i?.remove(), i = null;
748
+ for (const a of r) a.exitPrintMode?.();
749
+ window.removeEventListener("afterprint", s);
750
750
  }
751
751
  };
752
- window.addEventListener("afterprint", o);
752
+ window.addEventListener("afterprint", s);
753
753
  try {
754
754
  window.print();
755
755
  } finally {
756
- s || setTimeout(o, Fr);
756
+ o || setTimeout(s, zr);
757
757
  }
758
758
  }
759
759
  /** Render the whole page to one image, for `flatten`. */
760
760
  async buildFlattenedImage(t) {
761
- const { renderCartograph: e } = await Promise.resolve().then(() => hr), { blob: n } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
762
- i.src = URL.createObjectURL(n), i.setAttribute("data-om-carto-flattened", "");
763
- const s = this.bleedMm;
764
- 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(() => {
761
+ const { renderCartograph: e } = await Promise.resolve().then(() => yr), { blob: r } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
762
+ i.src = URL.createObjectURL(r), i.setAttribute("data-om-carto-flattened", "");
763
+ const o = this.bleedMm;
764
+ return i.style.cssText = `position:absolute;left:${-o}mm;top:${-o}mm;width:calc(100% + ${o * 2}mm);height:calc(100% + ${o * 2}mm);z-index:2147483645;`, await i.decode().catch(() => {
765
765
  }), i;
766
766
  }
767
767
  /** The page's atlas controller, if it has one. */
@@ -779,20 +779,20 @@ class Ie extends R {
779
779
  }
780
780
  /** Values every `{{token}}` on this page resolves against. */
781
781
  tokenContext() {
782
- const t = /* @__PURE__ */ new Map(), e = Le(this);
783
- for (const s of e) {
784
- const o = s.georef, a = o?.groundMetersPerMm() ?? 0;
785
- t.set(s.id, {
786
- scale: a > 0 ? xr(a * 1e3) : void 0,
787
- crs: o?.crs
782
+ const t = /* @__PURE__ */ new Map(), e = ze(this);
783
+ for (const o of e) {
784
+ const s = o.georef, a = s?.groundMetersPerMm() ?? 0;
785
+ t.set(o.id, {
786
+ scale: a > 0 ? Lr(a * 1e3) : void 0,
787
+ crs: s?.crs
788
788
  });
789
789
  }
790
- const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (s) => Ne(this.getAttribute(s) ?? "", n).text;
790
+ const r = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (o) => Oe(this.getAttribute(o) ?? "", r).text;
791
791
  return {
792
792
  page: {
793
793
  title: i("title"),
794
794
  attribution: i("attribution"),
795
- date: Nr(),
795
+ date: _r(),
796
796
  notes: i("notes")
797
797
  },
798
798
  frames: t,
@@ -808,13 +808,13 @@ class Ie extends R {
808
808
  t.resolveTokens?.();
809
809
  }
810
810
  renderNow() {
811
- const { widthMm: t, heightMm: e } = this.pageSize, n = this.bleedMm;
812
- this.style.display = "block", this.style.position = "relative", this.style.width = `${t}mm`, this.style.height = `${e}mm`, this.style.margin = n > 0 ? `${n}mm` : "", this.style.overflow = n > 0 ? "visible" : "hidden";
813
- let i = this.querySelector(`style[${Jt}]`);
814
- i || (i = document.createElement("style"), i.setAttribute(Jt, ""), this.prepend(i));
815
- const s = t + n * 2, o = e + n * 2;
816
- i.textContent = `@page { size: ${s}mm ${o}mm; margin: 0; }
817
- @media print { html, body { margin: 0; padding: 0; } om-cartograph { break-after: page; } }`, this.renderPrintMarks(t, e, n), this.applyCvd(), this.refreshTokens(), this.renderCredit();
811
+ const { widthMm: t, heightMm: e } = this.pageSize, r = this.bleedMm;
812
+ this.style.display = "block", this.style.position = "relative", this.style.width = `${t}mm`, this.style.height = `${e}mm`, this.style.margin = r > 0 ? `${r}mm` : "", this.style.overflow = r > 0 ? "visible" : "hidden";
813
+ let i = this.querySelector(`style[${re}]`);
814
+ i || (i = document.createElement("style"), i.setAttribute(re, ""), this.prepend(i));
815
+ const o = t + r * 2, s = e + r * 2;
816
+ i.textContent = `@page { size: ${o}mm ${s}mm; margin: 0; }
817
+ @media print { html, body { margin: 0; padding: 0; } om-cartograph { break-after: page; } }`, this.renderPrintMarks(t, e, r), this.applyCvd(), this.refreshTokens(), this.renderCredit();
818
818
  }
819
819
  /**
820
820
  * Crop marks and the safe-zone guide.
@@ -825,28 +825,28 @@ class Ie extends R {
825
825
  * reach paper or an exported image — a guide printed on the deliverable is
826
826
  * worse than no guide.
827
827
  */
828
- renderPrintMarks(t, e, n) {
829
- const i = this.hasAttribute("crop-marks") && n > 0, s = Number(this.getAttribute("safe-zone")), o = Number.isFinite(s) && s > 0, a = this.querySelector(`:scope > [${Zt}]`);
830
- if (!i && !o) {
828
+ renderPrintMarks(t, e, r) {
829
+ const i = this.hasAttribute("crop-marks") && r > 0, o = Number(this.getAttribute("safe-zone")), s = Number.isFinite(o) && o > 0, a = this.querySelector(`:scope > [${ne}]`);
830
+ if (!i && !s) {
831
831
  a?.remove();
832
832
  return;
833
833
  }
834
- const l = this.ownerDocument, c = a ?? l.createElementNS(Mt, "svg");
835
- if (c.setAttribute(Zt, ""), c.setAttribute("viewBox", `${-n} ${-n} ${t + n * 2} ${e + n * 2}`), c.setAttribute("width", `${t + n * 2}mm`), c.setAttribute("height", `${e + n * 2}mm`), c.style.cssText = `position:absolute;left:${-n}mm;top:${-n}mm;pointer-events:none;z-index:2147483646;`, c.replaceChildren(), i) {
836
- const u = Math.min(n, 4), h = Math.min(n * 0.35, 1.5), d = [];
834
+ const l = this.ownerDocument, c = a ?? l.createElementNS(vt, "svg");
835
+ if (c.setAttribute(ne, ""), c.setAttribute("viewBox", `${-r} ${-r} ${t + r * 2} ${e + r * 2}`), c.setAttribute("width", `${t + r * 2}mm`), c.setAttribute("height", `${e + r * 2}mm`), c.style.cssText = `position:absolute;left:${-r}mm;top:${-r}mm;pointer-events:none;z-index:2147483646;`, c.replaceChildren(), i) {
836
+ const u = Math.min(r, 4), h = Math.min(r * 0.35, 1.5), d = [];
837
837
  for (const m of [0, t])
838
838
  for (const f of [0, e]) {
839
839
  const g = m === 0 ? -1 : 1, p = f === 0 ? -1 : 1;
840
840
  d.push([m + g * h, f, m + g * (h + u), f]), d.push([m, f + p * h, m, f + p * (h + u)]);
841
841
  }
842
842
  for (const [m, f, g, p] of d) {
843
- const b = l.createElementNS(Mt, "line");
843
+ const b = l.createElementNS(vt, "line");
844
844
  b.setAttribute("x1", String(m)), b.setAttribute("y1", String(f)), b.setAttribute("x2", String(g)), b.setAttribute("y2", String(p)), b.setAttribute("stroke", "#000"), b.setAttribute("stroke-width", "0.15"), c.appendChild(b);
845
845
  }
846
846
  }
847
- if (o) {
848
- const u = l.createElementNS(Mt, "rect");
849
- u.setAttribute("x", String(s)), u.setAttribute("y", String(s)), u.setAttribute("width", String(Math.max(0, t - s * 2))), u.setAttribute("height", String(Math.max(0, e - s * 2))), u.setAttribute("fill", "none"), u.setAttribute("stroke", "#22aaff"), u.setAttribute("stroke-width", "0.2"), u.setAttribute("stroke-dasharray", "2 1.5"), u.setAttribute("data-om-carto-screen-only", ""), c.appendChild(u);
847
+ if (s) {
848
+ const u = l.createElementNS(vt, "rect");
849
+ u.setAttribute("x", String(o)), u.setAttribute("y", String(o)), u.setAttribute("width", String(Math.max(0, t - o * 2))), u.setAttribute("height", String(Math.max(0, e - o * 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);
850
850
  }
851
851
  a || this.appendChild(c);
852
852
  }
@@ -859,21 +859,21 @@ class Ie extends R {
859
859
  * injected only when a page actually asks for one.
860
860
  */
861
861
  applyCvd() {
862
- const t = It(this.getAttribute("cvd"));
862
+ const t = Ot(this.getAttribute("cvd"));
863
863
  if (!t) {
864
864
  this.style.removeProperty("filter");
865
865
  return;
866
866
  }
867
- lr(this.ownerDocument), this.style.filter = `url(#${Me(t)})`;
867
+ gr(this.ownerDocument), this.style.filter = `url(#${Ne(t)})`;
868
868
  }
869
869
  }
870
- x("om-cartograph", Ie);
871
- function Ir({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
872
- const s = n > 0 ? n : e * 1.2, o = [];
873
- for (const c of r.split(/\r?\n/)) {
870
+ x("om-cartograph", Ge);
871
+ function jr({ text: n, maxWidth: t, fontSizePx: e, lineHeightPx: r, measure: i }) {
872
+ const o = r > 0 ? r : e * 1.2, s = [];
873
+ for (const c of n.split(/\r?\n/)) {
874
874
  const u = c.split(/\s+/).filter((m) => m !== "");
875
875
  if (u.length === 0) {
876
- o.push({ text: "", baselineY: 0, width: 0 });
876
+ s.push({ text: "", baselineY: 0, width: 0 });
877
877
  continue;
878
878
  }
879
879
  const h = (m) => {
@@ -881,32 +881,32 @@ function Ir({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
881
881
  for (; i(f) > t && f.length > 1; ) {
882
882
  let g = f.length - 1;
883
883
  for (; g > 1 && i(f.slice(0, g)) > t; ) g--;
884
- o.push({ text: f.slice(0, g), baselineY: 0, width: i(f.slice(0, g)) }), f = f.slice(g);
884
+ s.push({ text: f.slice(0, g), baselineY: 0, width: i(f.slice(0, g)) }), f = f.slice(g);
885
885
  }
886
886
  return f;
887
887
  };
888
888
  let d = "";
889
889
  for (const m of u) {
890
890
  const f = d === "" ? m : `${d} ${m}`;
891
- d === "" ? d = h(m) : i(f) > t ? (o.push({ text: d, baselineY: 0, width: i(d) }), d = h(m)) : d = f;
891
+ d === "" ? d = h(m) : i(f) > t ? (s.push({ text: d, baselineY: 0, width: i(d) }), d = h(m)) : d = f;
892
892
  }
893
- o.push({ text: d, baselineY: 0, width: i(d) });
893
+ s.push({ text: d, baselineY: 0, width: i(d) });
894
894
  }
895
895
  const a = e * 0.8;
896
896
  let l = 0;
897
- return o.forEach((c, u) => {
898
- c.baselineY = a + u * s, c.width > l && (l = c.width);
899
- }), { lines: o, lineHeight: s, maxWidth: l };
897
+ return s.forEach((c, u) => {
898
+ c.baselineY = a + u * o, c.width > l && (l = c.width);
899
+ }), { lines: s, lineHeight: o, maxWidth: l };
900
900
  }
901
- function Kn(r) {
901
+ function oi(n) {
902
902
  if (typeof document > "u") return null;
903
903
  const e = document.createElement("canvas").getContext("2d");
904
- return e ? (e.font = r, (n) => e.measureText(n).width) : null;
904
+ return e ? (e.font = n, (r) => e.measureText(r).width) : null;
905
905
  }
906
- function Rr(r, t, e) {
907
- return r === "center" ? (t - e) / 2 : r === "end" || r === "right" ? t - e : 0;
906
+ function Gr(n, t, e) {
907
+ return n === "center" ? (t - e) / 2 : n === "end" || n === "right" ? t - e : 0;
908
908
  }
909
- class Re extends R {
909
+ class qe extends I {
910
910
  static observedAttributes = [...T["om-text"]];
911
911
  renderNow() {
912
912
  this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden";
@@ -914,173 +914,207 @@ class Re extends R {
914
914
  t != null && Number.isFinite(Number(t)) && Number(t) > 0 ? this.style.fontSize = `${Number(t)}pt` : this.style.removeProperty("font-size");
915
915
  const e = this.getAttribute("weight");
916
916
  e ? this.style.fontWeight = e : this.style.removeProperty("font-weight");
917
- const n = this.getAttribute("align");
918
- n === "start" || n === "center" || n === "end" ? this.style.textAlign = n : this.style.removeProperty("text-align");
917
+ const r = this.getAttribute("align");
918
+ r === "start" || r === "center" || r === "end" ? this.style.textAlign = r : this.style.removeProperty("text-align");
919
919
  const i = this.getAttribute("font");
920
920
  i ? this.style.fontFamily = i : this.style.removeProperty("font-family");
921
- const s = this.getAttribute("color");
922
- s ? this.style.color = s : this.style.removeProperty("color");
923
- const o = this.getAttribute("bg");
924
- o ? this.style.background = o : this.style.removeProperty("background"), this.resolveTokens();
921
+ const o = this.getAttribute("color");
922
+ o ? this.style.color = o : this.style.removeProperty("color");
923
+ const s = this.getAttribute("bg");
924
+ s ? this.style.background = s : this.style.removeProperty("background"), this.resolveTokens();
925
925
  }
926
926
  /** Re-run token substitution from the authored templates. */
927
927
  resolveTokens() {
928
928
  const t = this.closest("om-cartograph");
929
- t && typeof t.tokenContext == "function" && Er(this, t.tokenContext());
929
+ t && typeof t.tokenContext == "function" && Ir(this, t.tokenContext());
930
930
  }
931
931
  paintCartograph(t, e) {
932
- const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
933
- if (s <= 0 || o <= 0) return;
932
+ const { w: r, h: i } = C(this), o = r * e.pxPerMm, s = i * e.pxPerMm;
933
+ if (o <= 0 || s <= 0) return;
934
934
  const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
935
- l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
935
+ l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
936
936
  const c = (this.textContent ?? "").trim();
937
937
  if (c === "") return;
938
938
  const u = $t(a?.fontSize, 12), h = a?.lineHeight === "normal" ? u * 1.4 : $t(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", m = a?.fontWeight || "400", f = u * e.scale, g = h * e.scale, p = `${m} ${f}px ${d}`;
939
939
  t.save(), t.font = p, t.fillStyle = F(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
940
- const b = Ir({
940
+ const b = jr({
941
941
  text: c,
942
- maxWidth: s,
942
+ maxWidth: o,
943
943
  fontSizePx: f,
944
944
  lineHeightPx: g,
945
945
  measure: (y) => t.measureText(y).width
946
946
  }), w = a?.textAlign || "start";
947
947
  for (const y of b.lines) {
948
- if (y.baselineY > o + g) break;
949
- t.fillText(y.text, Rr(w, s, y.width), y.baselineY);
948
+ if (y.baselineY > s + g) break;
949
+ t.fillText(y.text, Gr(w, o, y.width), y.baselineY);
950
950
  }
951
951
  t.restore();
952
952
  }
953
953
  }
954
- x("om-text", Re);
955
- const Or = 63710087714e-4;
956
- let _r = Or;
954
+ x("om-text", qe);
955
+ const qr = 63710087714e-4;
956
+ let Wr = qr;
957
957
  const nt = Math.PI / 180;
958
- function Ur(r, t, e = _r) {
959
- const n = (t[1] - r[1]) * nt, i = (t[0] - r[0]) * nt, s = r[1] * nt, o = t[1] * nt, a = Math.sin(n / 2) ** 2 + Math.cos(s) * Math.cos(o) * Math.sin(i / 2) ** 2;
958
+ function Br(n, t, e = Wr) {
959
+ const r = (t[1] - n[1]) * nt, i = (t[0] - n[0]) * nt, o = n[1] * nt, s = t[1] * nt, a = Math.sin(r / 2) ** 2 + Math.cos(o) * Math.cos(s) * Math.sin(i / 2) ** 2;
960
960
  return 2 * e * Math.asin(Math.min(1, Math.sqrt(a)));
961
961
  }
962
- const K = 6378137, ht = Math.PI / 180, Nt = 180 / Math.PI, ne = 85.0511287798066;
963
- function zr([r, t]) {
964
- const e = Math.max(-ne, Math.min(ne, t));
965
- return [K * r * ht, K * Math.log(Math.tan(Math.PI / 4 + e * ht / 2))];
966
- }
967
- const ie = 89.9;
968
- function Dr([r, t]) {
969
- const e = Math.max(-ie, Math.min(ie, t));
970
- return [K * r * ht, K * Math.log(Math.tan(Math.PI / 4 + e * ht / 2))];
971
- }
972
- const jr = { code: "EPSG:3857", forward: Dr, inverse: Oe };
973
- function Oe([r, t]) {
974
- return [r / K * Nt, (2 * Math.atan(Math.exp(t / K)) - Math.PI / 2) * Nt];
975
- }
976
- const _e = { code: "EPSG:3857", forward: zr, inverse: Oe }, Gr = { code: "EPSG:4326", forward: ([r, t]) => [r, t], inverse: ([r, t]) => [r, t] };
977
- function Y(r) {
978
- if (r == null) return null;
979
- const t = r.trim();
962
+ const Q = 6378137, le = Math.PI / 180, ce = 180 / Math.PI, ue = 85.0511287798066, Nt = 2 * Math.PI * Q / 360;
963
+ function zt([n, t]) {
964
+ const e = Math.max(-ue, Math.min(ue, t));
965
+ return [Q * n * le, Q * Math.log(Math.tan(Math.PI / 4 + e * le / 2))];
966
+ }
967
+ function dt([n, t]) {
968
+ return [n / Q * ce, (2 * Math.atan(Math.exp(t / Q)) - Math.PI / 2) * ce];
969
+ }
970
+ const Vr = {
971
+ code: "EPSG:3857",
972
+ units: "linear",
973
+ metresPerUnit: 1,
974
+ forward: zt,
975
+ inverse: dt
976
+ }, Kr = {
977
+ code: "EPSG:4326",
978
+ units: "degree",
979
+ metresPerUnit: Nt,
980
+ forward: ([n, t]) => [n, t],
981
+ inverse: ([n, t]) => [n, t]
982
+ };
983
+ function jt(n) {
984
+ if (n == null) return null;
985
+ const t = n.trim();
980
986
  if (t === "") return null;
981
987
  const e = /^(?:epsg:{1,2})?(\d{4,6})$/i.exec(t);
982
988
  return e ? `EPSG:${e[1]}` : t.toUpperCase();
983
989
  }
984
- function X(r) {
985
- const t = Y(r) ?? "EPSG:3857";
986
- return t === "EPSG:3857" || t === "EPSG:900913" ? _e : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? Gr : null;
987
- }
988
- async function Ue(r, t) {
989
- const e = X(r);
990
- if (e && !t) return e;
991
- const n = Y(r) ?? "EPSG:3857", i = t?.trim() || await qr(n);
990
+ function We(n) {
991
+ const t = jt(n) ?? "EPSG:3857";
992
+ return t === "EPSG:3857" || t === "EPSG:900913" ? Vr : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? Kr : null;
993
+ }
994
+ const Be = /* @__PURE__ */ new Map();
995
+ function Pt(n, t) {
996
+ return !Number.isInteger(n) || n < 1 || n > 60 ? null : `+proj=utm +zone=${n}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
997
+ }
998
+ async function Hr(n) {
999
+ const t = Be.get(n);
1000
+ if (typeof t == "string") return t;
1001
+ const e = Number(/^EPSG:(\d+)$/.exec(n)?.[1]);
1002
+ if (!Number.isFinite(e)) return null;
1003
+ if (e >= 32601 && e <= 32660) return Pt(e - 32600, "N");
1004
+ if (e >= 32701 && e <= 32760) return Pt(e - 32700, "S");
1005
+ const { CRS_DEFS: r } = await import("./crs-BzE_KP4M.js");
1006
+ return r[e]?.def ?? null;
1007
+ }
1008
+ function Yr(n) {
1009
+ if (n.projName === "longlat") return { units: "degree", metresPerUnit: Nt };
1010
+ if (typeof n.to_meter == "number" && n.to_meter > 0) return { units: "linear", metresPerUnit: n.to_meter };
1011
+ const t = (n.units ?? "m").toLowerCase();
1012
+ return t.startsWith("deg") ? { units: "degree", metresPerUnit: Nt } : t.includes("ft") || t.includes("foot") ? { units: "linear", metresPerUnit: 0.3048 } : { units: "linear", metresPerUnit: 1 };
1013
+ }
1014
+ async function Xr(n, t) {
1015
+ const e = jt(n) ?? "EPSG:3857", r = Be.get(e);
1016
+ if (r && typeof r != "string") return r;
1017
+ if (!t) {
1018
+ const u = We(e);
1019
+ if (u) return u;
1020
+ }
1021
+ const i = t?.trim() || await Hr(e);
992
1022
  if (!i) return null;
993
- const s = (await import("./index-CcLC9jE5.js")).default, a = s(i, "+proj=longlat +datum=WGS84 +no_defs");
1023
+ const o = (await import("./index-CcLC9jE5.js")).default, a = o(i, "+proj=longlat +datum=WGS84 +no_defs"), { units: l, metresPerUnit: c } = Yr(new o.Proj(i));
994
1024
  return {
995
- code: n,
996
- forward: (l) => a.inverse(l),
997
- inverse: (l) => a.forward(l)
1025
+ code: e,
1026
+ units: l,
1027
+ metresPerUnit: c,
1028
+ forward: (u) => a.inverse(u),
1029
+ inverse: (u) => a.forward(u)
998
1030
  };
999
1031
  }
1000
- function oe(r, t) {
1001
- return !Number.isInteger(r) || r < 1 || r > 60 ? null : `+proj=utm +zone=${r}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
1032
+ const he = Math.PI / 180, Jr = 180 / Math.PI, Zr = { code: "EPSG:3857", forward: zt, inverse: dt }, ai = zt, li = dt, me = 6378137, de = 89.9;
1033
+ function Qr([n, t]) {
1034
+ const e = Math.max(-de, Math.min(de, t));
1035
+ return [me * n * he, me * Math.log(Math.tan(Math.PI / 4 + e * he / 2))];
1036
+ }
1037
+ const tn = { code: "EPSG:3857", forward: Qr, inverse: dt }, Tt = jt;
1038
+ function K(n) {
1039
+ return We(n);
1002
1040
  }
1003
- async function qr(r) {
1004
- const t = Number(/^EPSG:(\d+)$/.exec(r)?.[1]);
1005
- if (!Number.isFinite(t)) return null;
1006
- if (t >= 32601 && t <= 32660) return oe(t - 32600, "N");
1007
- if (t >= 32701 && t <= 32760) return oe(t - 32700, "S");
1008
- const { CRS_DEFS: e } = await import("./crs-DsDQ4Q4i.js");
1009
- return e[t]?.def ?? null;
1041
+ async function Lt(n, t) {
1042
+ return Xr(n, t);
1010
1043
  }
1011
- function Wr(r, t) {
1012
- const e = t.length, n = r.map((i, s) => [...i, t[s]]);
1044
+ const ci = Pt;
1045
+ function en(n, t) {
1046
+ const e = t.length, r = n.map((i, o) => [...i, t[o]]);
1013
1047
  for (let i = 0; i < e; i++) {
1014
- let s = i;
1015
- for (let o = i + 1; o < e; o++) Math.abs(n[o][i]) > Math.abs(n[s][i]) && (s = o);
1016
- if (Math.abs(n[s][i]) < 1e-12) return null;
1017
- [n[i], n[s]] = [n[s], n[i]];
1018
- for (let o = 0; o < e; o++) {
1019
- if (o === i) continue;
1020
- const a = n[o][i] / n[i][i];
1048
+ let o = i;
1049
+ for (let s = i + 1; s < e; s++) Math.abs(r[s][i]) > Math.abs(r[o][i]) && (o = s);
1050
+ if (Math.abs(r[o][i]) < 1e-12) return null;
1051
+ [r[i], r[o]] = [r[o], r[i]];
1052
+ for (let s = 0; s < e; s++) {
1053
+ if (s === i) continue;
1054
+ const a = r[s][i] / r[i][i];
1021
1055
  if (a !== 0)
1022
- for (let l = i; l <= e; l++) n[o][l] -= a * n[i][l];
1056
+ for (let l = i; l <= e; l++) r[s][l] -= a * r[i][l];
1023
1057
  }
1024
1058
  }
1025
- return n.map((i, s) => i[e] / i[s]);
1059
+ return r.map((i, o) => i[e] / i[o]);
1026
1060
  }
1027
- function Br(r, t) {
1028
- if (r.length !== 4 || t.length !== 4) return null;
1029
- const e = r.reduce((h, d) => h + d[0], 0) / 4, n = r.reduce((h, d) => h + d[1], 0) / 4, i = r.reduce((h, d) => h + Math.hypot(d[0] - e, d[1] - n), 0) / 4, s = i > 1e-12 ? Math.SQRT2 / i : 1, o = (h) => [(h[0] - e) * s, (h[1] - n) * s], a = [], l = [];
1061
+ function rn(n, t) {
1062
+ if (n.length !== 4 || t.length !== 4) return null;
1063
+ const e = n.reduce((h, d) => h + d[0], 0) / 4, r = n.reduce((h, d) => h + d[1], 0) / 4, i = n.reduce((h, d) => h + Math.hypot(d[0] - e, d[1] - r), 0) / 4, o = i > 1e-12 ? Math.SQRT2 / i : 1, s = (h) => [(h[0] - e) * o, (h[1] - r) * o], a = [], l = [];
1030
1064
  for (let h = 0; h < 4; h++) {
1031
- const [d, m] = o(r[h]), [f, g] = t[h];
1065
+ const [d, m] = s(n[h]), [f, g] = t[h];
1032
1066
  a.push([d, m, 1, 0, 0, 0, -d * f, -m * f]), l.push(f), a.push([0, 0, 0, d, m, 1, -d * g, -m * g]), l.push(g);
1033
1067
  }
1034
- const c = Wr(a, l);
1068
+ const c = en(a, l);
1035
1069
  if (!c || c.some((h) => !Number.isFinite(h))) return null;
1036
- const u = (h) => [h[0] / s + e, h[1] / s + n];
1037
- return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: o, denormalize: u };
1070
+ const u = (h) => [h[0] / o + e, h[1] / o + r];
1071
+ return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: s, denormalize: u };
1038
1072
  }
1039
- function se(r, [t, e]) {
1040
- const n = r[6] * t + r[7] * e + r[8];
1041
- return Math.abs(n) < 1e-12 ? null : [(r[0] * t + r[1] * e + r[2]) / n, (r[3] * t + r[4] * e + r[5]) / n];
1073
+ function fe(n, [t, e]) {
1074
+ const r = n[6] * t + n[7] * e + n[8];
1075
+ return Math.abs(r) < 1e-12 ? null : [(n[0] * t + n[1] * e + n[2]) / r, (n[3] * t + n[4] * e + n[5]) / r];
1042
1076
  }
1043
- function Vr(r) {
1044
- const [t, e, n, i, s, o, a, l, c] = r, u = t * (s * c - o * l) - e * (i * c - o * a) + n * (i * l - s * a);
1077
+ function nn(n) {
1078
+ const [t, e, r, i, o, s, a, l, c] = n, u = t * (o * c - s * l) - e * (i * c - s * a) + r * (i * l - o * a);
1045
1079
  return !Number.isFinite(u) || Math.abs(u) < 1e-15 ? null : [
1046
- (s * c - o * l) / u,
1047
- (n * l - e * c) / u,
1048
- (e * o - n * s) / u,
1049
- (o * a - i * c) / u,
1050
- (t * c - n * a) / u,
1051
- (n * i - t * o) / u,
1052
- (i * l - s * a) / u,
1080
+ (o * c - s * l) / u,
1081
+ (r * l - e * c) / u,
1082
+ (e * s - r * o) / u,
1083
+ (s * a - i * c) / u,
1084
+ (t * c - r * a) / u,
1085
+ (r * i - t * s) / u,
1086
+ (i * l - o * a) / u,
1053
1087
  (e * a - t * l) / u,
1054
- (t * s - e * i) / u
1088
+ (t * o - e * i) / u
1055
1089
  ];
1056
1090
  }
1057
- function Hr(r, t) {
1058
- let e = r;
1091
+ function sn(n, t) {
1092
+ let e = n;
1059
1093
  for (; e - t > 180; ) e -= 360;
1060
1094
  for (; t - e > 180; ) e += 360;
1061
1095
  return e;
1062
1096
  }
1063
- const ze = (r) => {
1064
- let t = ((r + 180) % 360 + 360) % 360 - 180;
1097
+ const Ve = (n) => {
1098
+ let t = ((n + 180) % 360 + 360) % 360 - 180;
1065
1099
  return t === -180 && (t = 180), t;
1066
1100
  };
1067
- function mt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i = !1 }) {
1068
- const s = n ?? (i ? jr : _e), o = r[0][0], a = (b) => i ? b : Hr(b, o), l = (b) => i ? b : ze(b), c = r.map(([b, w]) => [a(b), w]), u = c.map((b) => s.forward(b)), h = [
1101
+ function Z({ corners: n, widthMm: t, heightMm: e, crsForward: r, continuous: i = !1 }) {
1102
+ const o = r ?? (i ? tn : Zr), s = n[0][0], a = (b) => i ? b : sn(b, s), l = (b) => i ? b : Ve(b), c = n.map(([b, w]) => [a(b), w]), u = c.map((b) => o.forward(b)), h = [
1069
1103
  [0, 0],
1070
1104
  [t, 0],
1071
1105
  [t, e],
1072
1106
  [0, e]
1073
- ], d = t > 0 && e > 0 ? Br(u, h) : null, m = d ? Vr(d.matrix) : null, f = !d || !m, g = (b, w = i ? 16 : 1) => {
1107
+ ], d = t > 0 && e > 0 ? rn(u, h) : null, m = d ? nn(d.matrix) : null, f = !d || !m, g = (b, w = i ? 16 : 1) => {
1074
1108
  let y = 0, M = p.unproject(0, b);
1075
1109
  if (!M) return null;
1076
1110
  for (let v = 1; v <= w; v++) {
1077
1111
  const N = p.unproject(t * v / w, b);
1078
1112
  if (!N) return null;
1079
- y += Ur(M, N), M = N;
1113
+ y += Br(M, N), M = N;
1080
1114
  }
1081
1115
  return y;
1082
1116
  }, p = {
1083
- crs: s.code,
1117
+ crs: o.code,
1084
1118
  corners: c,
1085
1119
  widthMm: t,
1086
1120
  heightMm: e,
@@ -1088,14 +1122,14 @@ function mt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i
1088
1122
  continuous: i,
1089
1123
  project(b) {
1090
1124
  if (!d) return null;
1091
- const w = s.forward([a(b[0]), b[1]]), y = se(d.matrix, d.normalize(w));
1125
+ const w = o.forward([a(b[0]), b[1]]), y = fe(d.matrix, d.normalize(w));
1092
1126
  return y && Number.isFinite(y[0]) && Number.isFinite(y[1]) ? { xMm: y[0], yMm: y[1] } : null;
1093
1127
  },
1094
1128
  unproject(b, w) {
1095
1129
  if (!d || !m) return null;
1096
- const y = se(m, [b, w]);
1130
+ const y = fe(m, [b, w]);
1097
1131
  if (!y) return null;
1098
- const M = s.inverse(d.denormalize(y));
1132
+ const M = o.inverse(d.denormalize(y));
1099
1133
  return Number.isFinite(M[0]) && Number.isFinite(M[1]) ? [l(M[0]), M[1]] : null;
1100
1134
  },
1101
1135
  groundMetersPerMm() {
@@ -1107,106 +1141,106 @@ function mt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i
1107
1141
  };
1108
1142
  return p;
1109
1143
  }
1110
- function dt(r) {
1111
- if (r == null || r.trim() === "") return null;
1144
+ function ht(n) {
1145
+ if (n == null || n.trim() === "") return null;
1112
1146
  let t;
1113
1147
  try {
1114
- t = JSON.parse(r);
1148
+ t = JSON.parse(n);
1115
1149
  } catch {
1116
- const n = r.trim().split(/[\s,]+/).map(Number);
1117
- if (n.length !== 8 || n.some((i) => !Number.isFinite(i))) return null;
1150
+ const r = n.trim().split(/[\s,]+/).map(Number);
1151
+ if (r.length !== 8 || r.some((i) => !Number.isFinite(i))) return null;
1118
1152
  t = [
1119
- [n[0], n[1]],
1120
- [n[2], n[3]],
1121
- [n[4], n[5]],
1122
- [n[6], n[7]]
1153
+ [r[0], r[1]],
1154
+ [r[2], r[3]],
1155
+ [r[4], r[5]],
1156
+ [r[6], r[7]]
1123
1157
  ];
1124
1158
  }
1125
1159
  if (!Array.isArray(t)) return null;
1126
- if (t.length === 8 && t.every((n) => typeof n == "number" && Number.isFinite(n))) {
1127
- const n = t;
1128
- return [n[1], n[3], n[5], n[7]].some((i) => i < -90 || i > 90) ? null : [
1129
- [n[0], n[1]],
1130
- [n[2], n[3]],
1131
- [n[4], n[5]],
1132
- [n[6], n[7]]
1160
+ if (t.length === 8 && t.every((r) => typeof r == "number" && Number.isFinite(r))) {
1161
+ const r = t;
1162
+ return [r[1], r[3], r[5], r[7]].some((i) => i < -90 || i > 90) ? null : [
1163
+ [r[0], r[1]],
1164
+ [r[2], r[3]],
1165
+ [r[4], r[5]],
1166
+ [r[6], r[7]]
1133
1167
  ];
1134
1168
  }
1135
1169
  if (t.length !== 4) return null;
1136
1170
  const e = [];
1137
- for (const n of t) {
1138
- if (!Array.isArray(n) || n.length < 2) return null;
1139
- const [i, s] = n;
1140
- if (typeof i != "number" || typeof s != "number" || !Number.isFinite(i) || !Number.isFinite(s) || s < -90 || s > 90) return null;
1141
- e.push([i, s]);
1171
+ for (const r of t) {
1172
+ if (!Array.isArray(r) || r.length < 2) return null;
1173
+ const [i, o] = r;
1174
+ if (typeof i != "number" || typeof o != "number" || !Number.isFinite(i) || !Number.isFinite(o) || o < -90 || o > 90) return null;
1175
+ e.push([i, o]);
1142
1176
  }
1143
1177
  return e;
1144
1178
  }
1145
- function Kr(r) {
1146
- if (r.degenerate) return null;
1147
- const t = r.unproject(r.widthMm / 2, r.heightMm / 2);
1179
+ function on(n) {
1180
+ if (n.degenerate) return null;
1181
+ const t = n.unproject(n.widthMm / 2, n.heightMm / 2);
1148
1182
  if (!t) return null;
1149
- const n = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = r.project(t), s = r.project(n);
1150
- if (!i || !s) return null;
1151
- const o = s.xMm - i.xMm, a = s.yMm - i.yMm;
1152
- return Math.abs(o) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(o, -a) * Nt % 360 + 360) % 360;
1153
- }
1154
- function Yr(r) {
1155
- if (r.degenerate) return null;
1156
- const { widthMm: t, heightMm: e } = r, n = [];
1157
- for (const o of [0.02, 0.5, 0.98]) {
1158
- const a = r.rowGroundMeters(e * o);
1183
+ const r = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = n.project(t), o = n.project(r);
1184
+ if (!i || !o) return null;
1185
+ const s = o.xMm - i.xMm, a = o.yMm - i.yMm;
1186
+ return Math.abs(s) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(s, -a) * Jr % 360 + 360) % 360;
1187
+ }
1188
+ function an(n) {
1189
+ if (n.degenerate) return null;
1190
+ const { widthMm: t, heightMm: e } = n, r = [];
1191
+ for (const s of [0.02, 0.5, 0.98]) {
1192
+ const a = n.rowGroundMeters(e * s);
1159
1193
  if (a == null || !(a > 0)) return null;
1160
- n.push(a / t);
1194
+ r.push(a / t);
1161
1195
  }
1162
- const i = Math.min(...n), s = Math.max(...n);
1163
- return i > 0 ? (s - i) / i : null;
1196
+ const i = Math.min(...r), o = Math.max(...r);
1197
+ return i > 0 ? (o - i) / i : null;
1164
1198
  }
1165
- function Yn(r, t, e, n) {
1199
+ function ui(n, t, e, r) {
1166
1200
  return [
1167
- [r, n],
1168
- [e, n],
1201
+ [n, r],
1202
+ [e, r],
1169
1203
  [e, t],
1170
- [r, t]
1204
+ [n, t]
1171
1205
  ];
1172
1206
  }
1173
- const Xr = (r) => r.toLowerCase().startsWith("on");
1174
- function Jr(r, t) {
1175
- const e = (n) => {
1176
- const i = n.tagName.toLowerCase();
1207
+ const ln = (n) => n.toLowerCase().startsWith("on");
1208
+ function cn(n, t) {
1209
+ const e = (r) => {
1210
+ const i = r.tagName.toLowerCase();
1177
1211
  if (i === "script") {
1178
- if ((n.getAttribute("type") ?? "").toLowerCase() !== "application/json") return null;
1212
+ if ((r.getAttribute("type") ?? "").toLowerCase() !== "application/json") return null;
1179
1213
  const a = t.createElement("script");
1180
- return a.setAttribute("type", "application/json"), a.textContent = n.textContent, a;
1214
+ return a.setAttribute("type", "application/json"), a.textContent = r.textContent, a;
1181
1215
  }
1182
1216
  if (i === "style" || i === "link" || i === "iframe" || i === "object" || i === "embed") return null;
1183
- const s = t.createElement(i);
1184
- for (const o of n.attributes)
1185
- Xr(o.name) || /^\s*javascript:/i.test(o.value) || s.setAttribute(o.name, o.value);
1186
- for (const o of n.childNodes)
1187
- if (o.nodeType === 3) s.appendChild(t.createTextNode(o.textContent ?? ""));
1188
- else if (o.nodeType === 1) {
1189
- const a = e(o);
1190
- a && s.appendChild(a);
1217
+ const o = t.createElement(i);
1218
+ for (const s of r.attributes)
1219
+ ln(s.name) || /^\s*javascript:/i.test(s.value) || o.setAttribute(s.name, s.value);
1220
+ for (const s of r.childNodes)
1221
+ if (s.nodeType === 3) o.appendChild(t.createTextNode(s.textContent ?? ""));
1222
+ else if (s.nodeType === 1) {
1223
+ const a = e(s);
1224
+ a && o.appendChild(a);
1191
1225
  }
1192
- return s;
1226
+ return o;
1193
1227
  };
1194
- return e(r);
1195
- }
1196
- async function Zr(r, t = document) {
1197
- const e = await fetch(r, { credentials: "same-origin" });
1198
- if (!e.ok) throw new Error(`fetching ${r} failed with HTTP ${e.status}`);
1199
- const n = await e.text(), s = new DOMParser().parseFromString(n, "text/html").querySelector("om-map");
1200
- if (!s) throw new Error(`${r} contains no <om-map>`);
1201
- const o = Jr(s, t);
1202
- if (!o) throw new Error(`${r} could not be adopted`);
1203
- return o;
1204
- }
1205
- function ct(r) {
1206
- const t = r.getAttribute("center"), e = r.getAttribute("zoom");
1228
+ return e(n);
1229
+ }
1230
+ async function un(n, t = document) {
1231
+ const e = await fetch(n, { credentials: "same-origin" });
1232
+ if (!e.ok) throw new Error(`fetching ${n} failed with HTTP ${e.status}`);
1233
+ const r = await e.text(), o = new DOMParser().parseFromString(r, "text/html").querySelector("om-map");
1234
+ if (!o) throw new Error(`${n} contains no <om-map>`);
1235
+ const s = cn(o, t);
1236
+ if (!s) throw new Error(`${n} could not be adopted`);
1237
+ return s;
1238
+ }
1239
+ function ct(n) {
1240
+ const t = n.getAttribute("center"), e = n.getAttribute("zoom");
1207
1241
  if (!t || e == null || e.trim() === "") return null;
1208
- const n = Number(e);
1209
- if (!Number.isFinite(n)) return null;
1242
+ const r = Number(e);
1243
+ if (!Number.isFinite(r)) return null;
1210
1244
  let i;
1211
1245
  try {
1212
1246
  i = JSON.parse(t);
@@ -1215,65 +1249,77 @@ function ct(r) {
1215
1249
  i = a.length === 2 ? a : null;
1216
1250
  }
1217
1251
  if (!Array.isArray(i) || i.length < 2) return null;
1218
- const [s, o] = i;
1219
- return !Number.isFinite(s) || !Number.isFinite(o) ? null : {
1220
- center: [s, o],
1221
- zoom: n,
1222
- bearing: Number(r.getAttribute("bearing")) || 0,
1223
- pitch: Number(r.getAttribute("pitch")) || 0
1252
+ const [o, s] = i;
1253
+ return !Number.isFinite(o) || !Number.isFinite(s) ? null : {
1254
+ center: [o, s],
1255
+ zoom: r,
1256
+ bearing: Number(n.getAttribute("bearing")) || 0,
1257
+ pitch: Number(n.getAttribute("pitch")) || 0
1224
1258
  };
1225
1259
  }
1226
- function Xn(r, t, e, n, i = 60) {
1227
- const s = (l) => Pt(r, { ...t, pitch: l }, e, n) !== null;
1228
- if (s(i)) return i;
1229
- if (!s(0)) return 0;
1230
- let o = 0, a = i;
1231
- for (; a - o > 1; ) {
1232
- const l = Math.floor((o + a) / 2);
1233
- s(l) ? o = l : a = l;
1260
+ function hi(n, t, e, r, i = 60) {
1261
+ const o = (l) => Ft(n, { ...t, pitch: l }, e, r) !== null;
1262
+ if (o(i)) return i;
1263
+ if (!o(0)) return 0;
1264
+ let s = 0, a = i;
1265
+ for (; a - s > 1; ) {
1266
+ const l = Math.floor((s + a) / 2);
1267
+ o(l) ? s = l : a = l;
1234
1268
  }
1235
- return o;
1269
+ return s;
1236
1270
  }
1237
- function Pt(r, t, e, n) {
1238
- if (!(e > 0) || !(n > 0)) return null;
1239
- const i = new r.WebMercatorViewport({
1271
+ function Ft(n, t, e, r) {
1272
+ if (!(e > 0) || !(r > 0)) return null;
1273
+ const i = new n.WebMercatorViewport({
1240
1274
  width: e,
1241
- height: n,
1275
+ height: r,
1242
1276
  longitude: t.center[0],
1243
1277
  latitude: t.center[1],
1244
1278
  zoom: t.zoom,
1245
1279
  bearing: t.bearing,
1246
1280
  pitch: t.pitch
1247
- }), s = [
1281
+ }), o = [
1248
1282
  [0, 0],
1249
1283
  [e, 0],
1250
- [e, n],
1251
- [0, n]
1252
- ], o = [];
1253
- for (const a of s) {
1284
+ [e, r],
1285
+ [0, r]
1286
+ ], s = [];
1287
+ for (const a of o) {
1254
1288
  const l = i.unproject(a);
1255
1289
  if (!l || !Number.isFinite(l[0]) || !Number.isFinite(l[1])) return null;
1256
- o.push([l[0], l[1]]);
1290
+ s.push([l[0], l[1]]);
1257
1291
  }
1258
- return o;
1292
+ return s;
1259
1293
  }
1260
- async function Qr(r) {
1261
- const t = await we(), e = r.querySelector(":scope > om-map");
1294
+ async function hn(n) {
1295
+ const t = await ke(), e = n.querySelector(":scope > om-map");
1262
1296
  if (e) return { core: t, map: e };
1263
- const n = r.getAttribute("src");
1264
- if (!n) throw new Error("a live frame needs src= or an inline <om-map> child");
1265
- const i = await Zr(n, r.ownerDocument);
1297
+ const r = n.getAttribute("src");
1298
+ if (!r) throw new Error("a live frame needs src= or an inline <om-map> child");
1299
+ const i = await un(r, n.ownerDocument);
1266
1300
  return { core: t, map: i };
1267
1301
  }
1268
- function At(r, t) {
1269
- r.setAttribute("center", JSON.stringify(t.center)), r.setAttribute("zoom", String(t.zoom)), r.setAttribute("bearing", String(t.bearing)), r.setAttribute("pitch", String(t.pitch)), tn(r, t);
1302
+ function Mt(n, t) {
1303
+ n.setAttribute("center", JSON.stringify(t.center)), n.setAttribute("zoom", String(t.zoom)), n.setAttribute("bearing", String(t.bearing)), n.setAttribute("pitch", String(t.pitch)), mn(n, t);
1270
1304
  }
1271
- function tn(r, t) {
1272
- const e = r;
1305
+ function mn(n, t) {
1306
+ const e = n;
1273
1307
  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 });
1274
1308
  }
1275
- const St = "data-om-carto-placeholder", Ct = "data-om-carto-overview", ae = "http://www.w3.org/2000/svg", le = 24, ce = 0.25;
1276
- class De extends R {
1309
+ async function dn(n, t, e) {
1310
+ const r = Math.max(1, Math.round(t.w * e)), i = Math.max(1, Math.round(t.h * e)), o = n.cloneNode(!0);
1311
+ o.removeAttribute("style"), o.setAttribute("width", String(r)), o.setAttribute("height", String(i)), o.setAttribute("preserveAspectRatio", "none");
1312
+ const s = new XMLSerializer().serializeToString(o), a = new Image();
1313
+ a.decoding = "sync", a.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`;
1314
+ try {
1315
+ await a.decode();
1316
+ } catch {
1317
+ return null;
1318
+ }
1319
+ return a;
1320
+ }
1321
+ const At = "data-om-carto-placeholder", St = "data-om-carto-overview", ge = "http://www.w3.org/2000/svg", pe = 24, be = 0.25;
1322
+ class Ke extends I {
1277
1323
  static observedAttributes = [...T["om-frame"]];
1278
1324
  /** Resolved non-builtin CRS planes, so a re-render does not re-await proj4. */
1279
1325
  resolvedForward = null;
@@ -1302,6 +1348,8 @@ class De extends R {
1302
1348
  /** Live-mode state. */
1303
1349
  liveMap = null;
1304
1350
  liveCorners = null;
1351
+ /** In-flight live-map CRS resolve, so a render storm does not queue several. */
1352
+ pendingLiveCrs = null;
1305
1353
  mountToken = 0;
1306
1354
  mounting = !1;
1307
1355
  mountingSource = null;
@@ -1328,18 +1376,64 @@ class De extends R {
1328
1376
  get georef() {
1329
1377
  const { w: t, h: e } = C(this);
1330
1378
  if (t <= 0 || e <= 0) return null;
1331
- if (this.mode === "live")
1332
- return this.liveCorners ? mt({ corners: this.liveCorners, widthMm: t, heightMm: e, continuous: !0 }) : null;
1333
- const n = dt(this.getAttribute("corners"));
1334
- if (!n) return null;
1335
- const i = Y(this.getAttribute("crs")) ?? "EPSG:3857", s = this.getAttribute("crs-def");
1336
- let o = s ? null : X(i);
1337
- return !o && this.resolvedForwardKey === `${i}|${s ?? ""}` && (o = this.resolvedForward), o ? mt({ corners: n, widthMm: t, heightMm: e, crsForward: o }) : null;
1379
+ if (this.mode === "live") {
1380
+ if (!this.liveCorners) return null;
1381
+ const a = this.liveMap?.projectedCrs?.() ?? null;
1382
+ if (a) {
1383
+ const l = this.resolvedForwardKey === `${a}|` ? this.resolvedForward : K(a);
1384
+ return l ? Z({ corners: this.liveCorners, widthMm: t, heightMm: e, crsForward: l }) : (this.ensureLiveCrsForward(a), null);
1385
+ }
1386
+ return Z({ corners: this.liveCorners, widthMm: t, heightMm: e, continuous: !0 });
1387
+ }
1388
+ const r = ht(this.getAttribute("corners"));
1389
+ if (!r) return null;
1390
+ const i = Tt(this.getAttribute("crs")) ?? "EPSG:3857", o = this.getAttribute("crs-def");
1391
+ let s = o ? null : K(i);
1392
+ return !s && this.resolvedForwardKey === `${i}|${o ?? ""}` && (s = this.resolvedForward), s ? Z({ corners: r, widthMm: t, heightMm: e, crsForward: s }) : null;
1393
+ }
1394
+ /**
1395
+ * Resolve a live map's CRS through the core's lazy proj4, into the same
1396
+ * cache the static path uses. Until it lands the frame reports no
1397
+ * georeference, which is the existing contract for "a CRS still resolving" —
1398
+ * furniture waits rather than being placed through the wrong plane.
1399
+ */
1400
+ ensureLiveCrsForward(t) {
1401
+ const e = `${t}|`;
1402
+ if (this.resolvedForwardKey === e || this.pendingLiveCrs === e) return;
1403
+ this.pendingLiveCrs = e;
1404
+ const r = ++this.resolveToken;
1405
+ Lt(t, null).then((i) => {
1406
+ if (r === this.resolveToken) {
1407
+ if (this.pendingLiveCrs = null, !i) {
1408
+ this.showPlaceholder("unknown-crs", `The map in this frame is projected to "${t}", which could not be resolved.`);
1409
+ return;
1410
+ }
1411
+ this.resolvedForward = i, this.resolvedForwardKey = e, this.scheduleRender();
1412
+ }
1413
+ }).catch(() => {
1414
+ r === this.resolveToken && (this.pendingLiveCrs = null, this.showPlaceholder("unknown-crs", `Could not resolve the projection "${t}" the map in this frame declares.`));
1415
+ });
1338
1416
  }
1339
1417
  /** The raster a static frame draws — its first <img> child, if any. */
1340
1418
  get raster() {
1341
1419
  return this.querySelector(":scope > img");
1342
1420
  }
1421
+ /**
1422
+ * The frozen VECTOR picture a static frame draws, if it has one
1423
+ * (docs/design/carto-substrate.md §7).
1424
+ *
1425
+ * Marked rather than found by tag: the locator inset draws its footprint in
1426
+ * an `<svg>` of its own, and a bare `:scope > svg` would pick whichever came
1427
+ * first in the DOM. Two pictures, one selector, and the bug would be a frame
1428
+ * showing its own overview polygon instead of the map.
1429
+ */
1430
+ get vector() {
1431
+ return this.querySelector(`:scope > svg[${kt}]`);
1432
+ }
1433
+ /** What a static frame actually shows — vector first, because a frozen sheet that has both was frozen twice and the newer one is the vector. */
1434
+ get staticSource() {
1435
+ return this.vector ?? this.raster;
1436
+ }
1343
1437
  disconnectedCallback() {
1344
1438
  this.abandonMount();
1345
1439
  }
@@ -1355,7 +1449,7 @@ class De extends R {
1355
1449
  renderNow() {
1356
1450
  this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden", this.style.boxSizing = "border-box";
1357
1451
  const t = this.getAttribute("frame-stroke");
1358
- this.style.border = "0", this.style.boxShadow = `inset 0 0 0 ${ce}mm ${t || "var(--om-carto-frame-stroke)"}`;
1452
+ this.style.border = "0", this.style.boxShadow = `inset 0 0 0 ${be}mm ${t || "var(--om-carto-frame-stroke)"}`;
1359
1453
  const e = this.getAttribute("frame-bg");
1360
1454
  this.style.background = e || "var(--om-carto-frame-bg)", this.mode === "static" ? (this.suspendLiveMode(), this.renderStatic()) : this.renderLive(), this.renderOverview();
1361
1455
  }
@@ -1363,29 +1457,30 @@ class De extends R {
1363
1457
  // Static
1364
1458
  // -------------------------------------------------------------------------
1365
1459
  renderStatic() {
1366
- const t = this.raster;
1460
+ const t = this.staticSource;
1367
1461
  if (!t) {
1368
- this.showPlaceholder("no-raster", "Static frame has no <img> child to place.");
1462
+ this.showPlaceholder("no-raster", "Static frame has no <img> or inline <svg> child to place.");
1369
1463
  return;
1370
1464
  }
1371
- t.style.position = "absolute", t.style.inset = "0", t.style.width = "100%", t.style.height = "100%", t.style.objectFit = "fill", t.style.display = "block";
1372
- const e = Y(this.getAttribute("crs")) ?? "EPSG:3857", n = this.getAttribute("crs-def"), i = `${e}|${n ?? ""}`;
1373
- if ((n != null || X(e) == null) && this.resolvedForwardKey !== i) {
1374
- const o = ++this.resolveToken;
1375
- this.resolvedForward = null, this.resolvedForwardKey = null, Ue(e, n).then((a) => {
1376
- if (o === this.resolveToken) {
1377
- if (!a) {
1378
- this.showPlaceholder("unknown-crs", `Unknown CRS "${e}" — supply crs-def="+proj=…".`);
1465
+ const e = t.style;
1466
+ e.position = "absolute", e.inset = "0", e.width = "100%", e.height = "100%", e.display = "block", t instanceof SVGSVGElement ? t.setAttribute("preserveAspectRatio", "none") : e.objectFit = "fill";
1467
+ const r = Tt(this.getAttribute("crs")) ?? "EPSG:3857", i = this.getAttribute("crs-def"), o = `${r}|${i ?? ""}`;
1468
+ if ((i != null || K(r) == null) && this.resolvedForwardKey !== o) {
1469
+ const a = ++this.resolveToken;
1470
+ this.resolvedForward = null, this.resolvedForwardKey = null, Lt(r, i).then((l) => {
1471
+ if (a === this.resolveToken) {
1472
+ if (!l) {
1473
+ this.showPlaceholder("unknown-crs", `Unknown CRS "${r}" — supply crs-def="+proj=…".`);
1379
1474
  return;
1380
1475
  }
1381
- this.resolvedForward = a, this.resolvedForwardKey = i, this.scheduleRender();
1476
+ this.resolvedForward = l, this.resolvedForwardKey = o, this.scheduleRender();
1382
1477
  }
1383
1478
  }).catch(() => {
1384
- o === this.resolveToken && this.showPlaceholder("unknown-crs", `Could not resolve CRS "${e}".`);
1479
+ a === this.resolveToken && this.showPlaceholder("unknown-crs", `Could not resolve CRS "${r}".`);
1385
1480
  });
1386
1481
  return;
1387
1482
  }
1388
- if (!dt(this.getAttribute("corners"))) {
1483
+ if (!ht(this.getAttribute("corners"))) {
1389
1484
  this.showPlaceholder("bad-corners", 'Static frame needs corners="[[lng,lat] × 4]" (tl, tr, br, bl).');
1390
1485
  return;
1391
1486
  }
@@ -1395,28 +1490,28 @@ class De extends R {
1395
1490
  // Live
1396
1491
  // -------------------------------------------------------------------------
1397
1492
  renderLive() {
1398
- const t = this.raster;
1493
+ const t = this.staticSource;
1399
1494
  t && (t.style.display = "none");
1400
1495
  const e = ct(this);
1401
1496
  if (!e) {
1402
1497
  this.showPlaceholder("no-camera", 'Live frame needs its own camera — center="[lng, lat]" and zoom=.');
1403
1498
  return;
1404
1499
  }
1405
- const n = JSON.stringify(e), i = n !== this.appliedCameraKey;
1406
- this.appliedCameraKey = n, this.updateLiveCorners(i ? e : this.liveCamera() ?? e);
1407
- const s = this.liveSource();
1500
+ const r = JSON.stringify(e), i = r !== this.appliedCameraKey;
1501
+ this.appliedCameraKey = r, this.updateLiveCorners(i ? e : this.liveCamera() ?? e);
1502
+ const o = this.liveSource();
1408
1503
  if (this.liveMap)
1409
- if (this.mountedSource !== s)
1504
+ if (this.mountedSource !== o)
1410
1505
  this.releaseLiveMap();
1411
1506
  else {
1412
- At(this.liveMap, e), this.sizeLiveMap();
1507
+ Mt(this.liveMap, e), this.sizeLiveMap();
1413
1508
  return;
1414
1509
  }
1415
1510
  if (this.mounting) {
1416
- if (this.mountingSource === s) return;
1511
+ if (this.mountingSource === o) return;
1417
1512
  this.abandonMount();
1418
1513
  }
1419
- this.mountLive(s);
1514
+ this.mountLive(o);
1420
1515
  }
1421
1516
  /** Inline maps are identified by node identity; fetched maps by their src=. */
1422
1517
  liveSource() {
@@ -1447,30 +1542,45 @@ class De extends R {
1447
1542
  const t = this.liveCamera();
1448
1543
  t && this.updateLiveCorners(t);
1449
1544
  };
1545
+ /**
1546
+ * Write this frame's ground scale onto the map it mounts, so millimetre
1547
+ * transforms resolve against the sheet they are actually on.
1548
+ *
1549
+ * Only while the georef is real: a degenerate or still-resolving frame has
1550
+ * no scale to state, and writing a wrong one is worse than writing none —
1551
+ * the transform would run at a tolerance nobody chose.
1552
+ */
1553
+ applyReferenceScale() {
1554
+ if (!this.liveMap) return;
1555
+ const t = this.georef?.groundMetersPerMm();
1556
+ if (!t || !Number.isFinite(t) || t <= 0) return;
1557
+ const e = `${Number(t.toFixed(6))}m`;
1558
+ this.liveMap.getAttribute("reference-scale") !== e && this.liveMap.setAttribute("reference-scale", e);
1559
+ }
1450
1560
  updateLiveCorners(t = ct(this)) {
1451
1561
  if (!t) return;
1452
1562
  const e = H();
1453
1563
  if (!e) return;
1454
- const { w: n, h: i } = C(this), s = Pt(e, t, n * W, i * W), o = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
1455
- this.liveCorners = s, o && this.liveMap && this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } })), s ? this.lastError === "degenerate-view" && this.clearPlaceholder() : this.showPlaceholder("degenerate-view", "This frame's box cannot be georeferenced — give it a positive width and height.");
1564
+ const { w: r, h: i } = C(this), s = this.liveMap?.groundCorners?.(r * D, i * D) ?? Ft(e, t, r * D, i * D), a = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
1565
+ this.liveCorners = s, a && this.liveMap && this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } })), this.applyReferenceScale(), 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.");
1456
1566
  }
1457
1567
  async mountLive(t) {
1458
1568
  const e = ++this.mountToken;
1459
1569
  this.mounting = !0, this.mountingSource = t;
1460
1570
  try {
1461
- const { core: n, map: i } = await Qr(this);
1571
+ const { core: r, map: i } = await hn(this);
1462
1572
  if (e !== this.mountToken || !this.isConnected || this.mode !== "live" || this.liveSource() !== t) return;
1463
- const s = ct(this);
1464
- if (!s) return;
1465
- this.appliedCameraKey = JSON.stringify(s), At(i, s);
1466
- const o = i;
1467
- o.style.position = "absolute", o.style.inset = "0", o.style.display = "block", this.liveMapOwned = i.parentElement !== this, this.liveMapOwned && this.appendChild(i), i.setAttribute("data-om-carto-frame", ""), this.liveMap = o, o.addEventListener("om-view-changed", this.onLiveViewSettled), this.mountedSource = t, this.sizeLiveMap(), this.clearPlaceholder();
1573
+ const o = ct(this);
1574
+ if (!o) return;
1575
+ this.appliedCameraKey = JSON.stringify(o), Mt(i, o);
1576
+ const s = i;
1577
+ s.style.position = "absolute", s.style.inset = "0", s.style.display = "block", this.liveMapOwned = i.parentElement !== this, this.liveMapOwned && this.appendChild(i), i.setAttribute("data-om-carto-frame", ""), this.liveMap = s, s.addEventListener("om-view-changed", this.onLiveViewSettled), this.mountedSource = t, this.sizeLiveMap(), this.clearPlaceholder();
1468
1578
  const { w: a, h: l } = C(this);
1469
- if (this.liveCorners = Pt(n, s, a * W, l * W), await o.ready, e !== this.mountToken || (At(i, s), await o.whenSettled?.({ timeout: 2e4 }), e !== this.mountToken)) return;
1579
+ if (this.liveCorners = Ft(r, o, a * D, l * D), this.applyReferenceScale(), await s.ready, e !== this.mountToken || (Mt(i, o), await s.whenSettled?.({ timeout: 2e4 }), e !== this.mountToken)) return;
1470
1580
  this.signalReady();
1471
- } catch (n) {
1581
+ } catch (r) {
1472
1582
  if (e !== this.mountToken) return;
1473
- const i = n.message ?? String(n);
1583
+ const i = r.message ?? String(r);
1474
1584
  this.showPlaceholder(i.includes("src=") || i.includes("no <om-map>") ? "no-source" : "load-failed", `Live frame could not load: ${i}`);
1475
1585
  } finally {
1476
1586
  e === this.mountToken && (this.mounting = !1, this.mountingSource = null);
@@ -1498,45 +1608,48 @@ class De extends R {
1498
1608
  * segments would visibly cut the corners on a wide-extent inset.
1499
1609
  */
1500
1610
  renderOverview() {
1501
- const t = this.getAttribute("overview-of"), e = this.querySelector(`:scope > [${Ct}]`);
1611
+ const t = this.getAttribute("overview-of"), e = this.querySelector(`:scope > [${St}]`);
1502
1612
  if (!t) {
1503
1613
  e?.remove();
1504
1614
  return;
1505
1615
  }
1506
- const n = Te(this, t), i = this.georef, s = n?.georef;
1507
- if (!n || !i || !s) {
1616
+ const r = De(this, t), i = this.georef, o = r?.georef;
1617
+ if (!r || !i || !o) {
1508
1618
  e?.remove();
1509
1619
  return;
1510
1620
  }
1511
- const { w: o, h: a } = C(this), l = [], [c, u, h, d] = s.corners, m = [
1621
+ const { w: s, h: a } = C(this), l = [], [c, u, h, d] = o.corners, m = [
1512
1622
  [c, u],
1513
1623
  [u, h],
1514
1624
  [h, d],
1515
1625
  [d, c]
1516
1626
  ];
1517
1627
  for (const [b, w] of m)
1518
- for (let y = 0; y < le; y++) {
1519
- const M = y / le, v = [b[0] + (w[0] - b[0]) * M, b[1] + (w[1] - b[1]) * M], N = i.project(v);
1628
+ for (let y = 0; y < pe; y++) {
1629
+ const M = y / pe, v = [b[0] + (w[0] - b[0]) * M, b[1] + (w[1] - b[1]) * M], N = i.project(v);
1520
1630
  N && l.push(`${N.xMm.toFixed(3)},${N.yMm.toFixed(3)}`);
1521
1631
  }
1522
1632
  if (l.length < 3) {
1523
1633
  e?.remove();
1524
1634
  return;
1525
1635
  }
1526
- const f = this.ownerDocument, g = e ?? f.createElementNS(ae, "svg");
1527
- g.setAttribute(Ct, ""), g.setAttribute("width", `${o}mm`), g.setAttribute("height", `${a}mm`), g.setAttribute("viewBox", `0 0 ${o} ${a}`), g.style.cssText = "position:absolute;inset:0;pointer-events:none;", g.replaceChildren();
1528
- const p = f.createElementNS(ae, "polygon");
1636
+ const f = this.ownerDocument, g = e ?? f.createElementNS(ge, "svg");
1637
+ g.setAttribute(St, ""), g.setAttribute("width", `${s}mm`), g.setAttribute("height", `${a}mm`), g.setAttribute("viewBox", `0 0 ${s} ${a}`), g.style.cssText = "position:absolute;inset:0;pointer-events:none;", g.replaceChildren();
1638
+ const p = f.createElementNS(ge, "polygon");
1529
1639
  p.setAttribute("points", l.join(" ")), p.setAttribute("fill", "none"), p.setAttribute("stroke", this.getAttribute("overview-stroke") || "#e63946"), p.setAttribute("stroke-width", "0.4"), g.appendChild(p), e || this.appendChild(g);
1530
1640
  }
1531
1641
  // -------------------------------------------------------------------------
1532
1642
  // Readiness and errors
1533
1643
  // -------------------------------------------------------------------------
1534
1644
  signalStaticReady(t) {
1535
- this.readyFired || (t.complete && t.naturalWidth > 0 ? this.signalReady() : (t.addEventListener("load", () => this.signalReady(), { once: !0 }), t.addEventListener(
1645
+ if (this.readyFired) return;
1646
+ if (t instanceof SVGSVGElement) return this.signalReady();
1647
+ const e = t;
1648
+ e.complete && e.naturalWidth > 0 ? this.signalReady() : (e.addEventListener("load", () => this.signalReady(), { once: !0 }), e.addEventListener(
1536
1649
  "error",
1537
- () => this.showPlaceholder("raster-decode", `Could not load the frame's raster (${t.getAttribute("src") ?? "no src"}).`),
1650
+ () => this.showPlaceholder("raster-decode", `Could not load the frame's raster (${e.getAttribute("src") ?? "no src"}).`),
1538
1651
  { once: !0 }
1539
- )));
1652
+ ));
1540
1653
  }
1541
1654
  signalReady() {
1542
1655
  this.readyFired || (this.readyFired = !0, this.settleReady(), this.dispatchEvent(new CustomEvent("om-frame-ready", { bubbles: !0, detail: { id: this.id, mode: this.mode } })));
@@ -1546,11 +1659,11 @@ class De extends R {
1546
1659
  * the worst outcome — it looks like a design choice.
1547
1660
  */
1548
1661
  showPlaceholder(t, e) {
1549
- let n = this.querySelector(`:scope > [${St}]`);
1550
- n || (n = document.createElement("div"), n.setAttribute(St, ""), n.style.cssText = "position:absolute;inset:0;display:grid;place-content:center;padding:4mm;text-align:center;font:italic 3mm/1.4 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.75;", this.appendChild(n)), n.textContent !== e && (n.textContent = e), this.lastError !== t && (this.lastError = t, this.settleReady(), this.dispatchEvent(new CustomEvent("om-frame-error", { bubbles: !0, detail: { id: this.id, reason: t, message: e } })));
1662
+ let r = this.querySelector(`:scope > [${At}]`);
1663
+ r || (r = document.createElement("div"), r.setAttribute(At, ""), r.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(r)), r.textContent !== e && (r.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 } })));
1551
1664
  }
1552
1665
  clearPlaceholder() {
1553
- this.querySelector(`:scope > [${St}]`)?.remove(), this.lastError = null;
1666
+ this.querySelector(`:scope > [${At}]`)?.remove(), this.lastError = null;
1554
1667
  }
1555
1668
  // -------------------------------------------------------------------------
1556
1669
  // Capture, export and print
@@ -1562,9 +1675,47 @@ class De extends R {
1562
1675
  */
1563
1676
  async captureAt(t) {
1564
1677
  if (this.mode !== "live" || !this.liveMap) return null;
1565
- const e = await this.liveMap.snapshot({ scale: t }), n = new Image();
1566
- return n.decoding = "sync", n.src = e, await n.decode().catch(() => {
1567
- }), n;
1678
+ const e = await this.liveMap.snapshot({ scale: t }), r = new Image();
1679
+ return r.decoding = "sync", r.src = e, await r.decode().catch(() => {
1680
+ }), r;
1681
+ }
1682
+ /**
1683
+ * Freeze this live frame into a static one (docs/design/carto-substrate.md §7).
1684
+ *
1685
+ * `format: "svg"` stores an inline `<svg>` — editable linework with the
1686
+ * raster bands embedded inside it — and `"raster"` stores the `<img>` this
1687
+ * has always produced. Either way the frame becomes `mode="static"` placed by
1688
+ * the SAME `crs` + `corners` it already reported, because the georef model
1689
+ * does not change: a frozen frame is a picture plus four corners, and that
1690
+ * was true before vector and stays true after.
1691
+ *
1692
+ * The corners are read from `this.georef` BEFORE the mode flips. A live
1693
+ * frame derives them from its camera, and a static one from the attribute —
1694
+ * so reading after the flip would read an attribute that has not been
1695
+ * written yet, and the sheet would land at the previous freeze's position.
1696
+ *
1697
+ * Returns false, and freezes NOTHING, when the frame has no georeference to
1698
+ * freeze at. The case that matters is a projected frame whose CRS is still
1699
+ * resolving proj4: its corners are not merely unknown, they are about to
1700
+ * change, and a sheet placed by them would be placed wrong and look right.
1701
+ * Call it again once `ready` has settled.
1702
+ */
1703
+ async freeze(t = {}) {
1704
+ if (this.mode !== "live" || !this.liveMap) return !1;
1705
+ const r = this.georef?.corners;
1706
+ if (!r) return !1;
1707
+ const i = t.format ?? "svg", o = this.liveMap.projectedCrs?.() ?? null;
1708
+ if (i === "svg") {
1709
+ const s = await this.liveMap.snapshot({ format: "svg", effectDpi: t.effectDpi }), l = new DOMParser().parseFromString(s, "image/svg+xml").documentElement;
1710
+ if (l.nodeName !== "svg") return !1;
1711
+ const c = document.importNode(l, !0);
1712
+ c.setAttribute(kt, ""), this.vector?.remove(), this.raster?.remove(), this.appendChild(c);
1713
+ } else {
1714
+ const s = await this.captureAt(t.scale ?? 3.125);
1715
+ if (!s) return !1;
1716
+ this.vector?.remove(), this.raster?.remove(), this.appendChild(s);
1717
+ }
1718
+ return this.setAttribute("corners", JSON.stringify(r.map(([s, a]) => [Number(s.toFixed(8)), Number(a.toFixed(8))]))), o && o !== "EPSG:3857" ? this.setAttribute("crs", o) : this.removeAttribute("crs"), this.setAttribute("mode", "static"), this.scheduleRender(), !0;
1568
1719
  }
1569
1720
  /**
1570
1721
  * Point this frame's camera at a lon/lat box — the atlas's per-page refit.
@@ -1574,19 +1725,34 @@ class De extends R {
1574
1725
  * follows from the same source as any authored camera.
1575
1726
  */
1576
1727
  fitBounds(t) {
1577
- const [e, n, i, s] = t, { w: o, h: a } = C(this);
1578
- if (o <= 0 || a <= 0) return;
1728
+ const [e, r, i, o] = t, { w: s, h: a } = C(this);
1729
+ if (s <= 0 || a <= 0) return;
1579
1730
  const l = H();
1580
1731
  if (!l) return;
1581
- const c = new l.WebMercatorViewport({ width: o * W, height: a * W, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
1582
- [e, n],
1583
- [i, s]
1732
+ const c = new l.WebMercatorViewport({ width: s * D, height: a * D, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
1733
+ [e, r],
1734
+ [i, o]
1584
1735
  ]);
1585
1736
  [c.longitude, c.latitude, c.zoom].every(Number.isFinite) && (this.setAttribute("center", JSON.stringify([Number(c.longitude.toFixed(8)), Number(c.latitude.toFixed(8))])), this.setAttribute("zoom", String(Number(c.zoom.toFixed(4)))), this.updateLiveCorners());
1586
1737
  }
1587
- /** Export hook: capture before the page paints (see render.ts). */
1738
+ /**
1739
+ * Export hook: capture before the page paints (see render.ts).
1740
+ *
1741
+ * A live frame re-renders at the target resolution. A frozen VECTOR frame
1742
+ * has to be rasterised too — not because it should be, but because the
1743
+ * canvas exporter draws pixels, and `drawImage` cannot take an inline
1744
+ * `<svg>` element. It is rasterised at the export's own resolution from its
1745
+ * own markup, so a 300 dpi plate gets 300 dpi linework rather than an
1746
+ * upscaled screen rendering. The PRINT path does not go through here at all
1747
+ * — a browser prints inline vector natively, which is the point of §7.
1748
+ */
1588
1749
  async prepareCartograph(t) {
1589
- this.mode === "live" && (this.captureImage = await this.captureAt(t.scale));
1750
+ if (this.mode === "live") {
1751
+ this.captureImage = await this.captureAt(t.scale);
1752
+ return;
1753
+ }
1754
+ const e = this.vector;
1755
+ e && (this.captureImage = await dn(e, C(this), t.pxPerMm));
1590
1756
  }
1591
1757
  /** Export hook: forget the capture, so a failed pre-pass never reuses it. */
1592
1758
  discardCartograph() {
@@ -1607,150 +1773,150 @@ class De extends R {
1607
1773
  this.printing = !1, this.querySelector(":scope > img[data-om-carto-print]")?.remove(), this.liveMap && (this.liveMap.hidden = !1);
1608
1774
  }
1609
1775
  paintCartograph(t, e) {
1610
- const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1611
- if (s <= 0 || o <= 0) return;
1776
+ const { w: r, h: i } = C(this), o = r * e.pxPerMm, s = i * e.pxPerMm;
1777
+ if (o <= 0 || s <= 0) return;
1612
1778
  const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
1613
- l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
1614
- const c = this.mode === "static" ? this.raster : this.captureImage;
1615
- c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, s, o), this.paintOverview(t, e);
1616
- const u = this.getAttribute("frame-stroke") || F(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", h = ce * e.pxPerMm;
1617
- h > 0 && (t.strokeStyle = u, t.lineWidth = h, t.strokeRect(h / 2, h / 2, s - h, o - h));
1779
+ l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
1780
+ const c = this.mode === "static" ? this.vector ? this.captureImage : this.raster : this.captureImage;
1781
+ c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, o, s), this.paintOverview(t, e);
1782
+ const u = this.getAttribute("frame-stroke") || F(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", h = be * e.pxPerMm;
1783
+ h > 0 && (t.strokeStyle = u, t.lineWidth = h, t.strokeRect(h / 2, h / 2, o - h, s - h));
1618
1784
  }
1619
1785
  paintOverview(t, e) {
1620
- const n = this.querySelector(`:scope > [${Ct}] polygon`), i = n?.getAttribute("points");
1621
- i && (t.save(), t.strokeStyle = n.getAttribute("stroke") || "#e63946", t.lineWidth = Number(n.getAttribute("stroke-width") || 0.4) * e.pxPerMm, t.beginPath(), i.split(/\s+/).forEach((s, o) => {
1622
- const [a, l] = s.split(",").map(Number);
1623
- !Number.isFinite(a) || !Number.isFinite(l) || (o === 0 ? t.moveTo(a * e.pxPerMm, l * e.pxPerMm) : t.lineTo(a * e.pxPerMm, l * e.pxPerMm));
1786
+ const r = this.querySelector(`:scope > [${St}] polygon`), i = r?.getAttribute("points");
1787
+ i && (t.save(), t.strokeStyle = r.getAttribute("stroke") || "#e63946", t.lineWidth = Number(r.getAttribute("stroke-width") || 0.4) * e.pxPerMm, t.beginPath(), i.split(/\s+/).forEach((o, s) => {
1788
+ const [a, l] = o.split(",").map(Number);
1789
+ !Number.isFinite(a) || !Number.isFinite(l) || (s === 0 ? t.moveTo(a * e.pxPerMm, l * e.pxPerMm) : t.lineTo(a * e.pxPerMm, l * e.pxPerMm));
1624
1790
  }), t.closePath(), t.stroke(), t.restore());
1625
1791
  }
1626
1792
  }
1627
- x("om-frame", De);
1628
- const it = "http://www.w3.org/2000/svg", en = ["single", "double", "line", "ticks"];
1629
- class je extends R {
1793
+ x("om-frame", Ke);
1794
+ const it = "http://www.w3.org/2000/svg", fn = ["single", "double", "line", "ticks"];
1795
+ class He extends I {
1630
1796
  static observedAttributes = [...T["om-scalebar"]];
1631
1797
  /** The geometry currently drawn — reused by the canvas exporter. */
1632
1798
  get drawing() {
1633
- const e = _(this)?.georef;
1799
+ const e = O(this)?.georef;
1634
1800
  if (!e) return null;
1635
- const { w: n, h: i } = C(this), s = $e({
1801
+ const { w: r, h: i } = C(this), o = Ie({
1636
1802
  groundMetersPerMm: e.groundMetersPerMm(),
1637
- maxWidthMm: n,
1803
+ maxWidthMm: r,
1638
1804
  segments: Number(this.getAttribute("segments")) || void 0,
1639
1805
  units: this.unitSystem,
1640
1806
  segmentLengthMeters: this.getAttribute("segment-length") ? Number(this.getAttribute("segment-length")) : null
1641
1807
  });
1642
- return s ? Sr(s, this.barStyle, i) : null;
1808
+ return o ? Pr(o, this.barStyle, i) : null;
1643
1809
  }
1644
1810
  get barStyle() {
1645
1811
  const t = this.getAttribute("kind");
1646
- return en.includes(t) ? t : "single";
1812
+ return fn.includes(t) ? t : "single";
1647
1813
  }
1648
1814
  get unitSystem() {
1649
- return Ar(this.getAttribute("units")) ?? "metric";
1815
+ return Nr(this.getAttribute("units")) ?? "metric";
1650
1816
  }
1651
1817
  renderNow() {
1652
- if (this.applyPlacement(), this.style.display = "block", !_(this)) {
1653
- const n = this.getAttribute("for");
1654
- G(this, n ? `Scale bar references no frame with id "${n}".` : "Scale bar has no frame to measure (set for=).");
1818
+ if (this.applyPlacement(), this.style.display = "block", !O(this)) {
1819
+ const r = this.getAttribute("for");
1820
+ q(this, r ? `Scale bar references no frame with id "${r}".` : "Scale bar has no frame to measure (set for=).");
1655
1821
  return;
1656
1822
  }
1657
1823
  const e = this.drawing;
1658
1824
  if (!e) {
1659
- G(this, "Scale bar cannot derive a scale from this frame yet.");
1825
+ q(this, "Scale bar cannot derive a scale from this frame yet.");
1660
1826
  return;
1661
1827
  }
1662
1828
  this.renderSvg(e);
1663
1829
  }
1664
1830
  renderSvg(t) {
1665
- const { w: e, h: n } = C(this), i = this.ownerDocument, s = i.createElementNS(it, "svg");
1666
- 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";
1667
- const o = "var(--om-carto-scalebar-ink)";
1831
+ const { w: e, h: r } = C(this), i = this.ownerDocument, o = i.createElementNS(it, "svg");
1832
+ o.setAttribute("width", `${e}mm`), o.setAttribute("height", `${r}mm`), o.setAttribute("viewBox", `0 0 ${e} ${r}`), o.setAttribute("part", "scalebar"), o.style.display = "block", o.style.overflow = "visible";
1833
+ const s = "var(--om-carto-scalebar-ink)";
1668
1834
  for (const a of t.bars) {
1669
1835
  const l = i.createElementNS(it, "rect");
1670
- l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("width", String(a.w)), l.setAttribute("height", String(a.h)), l.setAttribute("fill", a.filled ? o : "none"), l.setAttribute("stroke", o), l.setAttribute("stroke-width", String(t.strokeMm)), s.appendChild(l);
1836
+ l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("width", String(a.w)), l.setAttribute("height", String(a.h)), l.setAttribute("fill", a.filled ? s : "none"), l.setAttribute("stroke", s), l.setAttribute("stroke-width", String(t.strokeMm)), o.appendChild(l);
1671
1837
  }
1672
1838
  for (const a of t.strokes) {
1673
1839
  const l = i.createElementNS(it, "line");
1674
- l.setAttribute("x1", String(a.x1)), l.setAttribute("y1", String(a.y1)), l.setAttribute("x2", String(a.x2)), l.setAttribute("y2", String(a.y2)), l.setAttribute("stroke", o), l.setAttribute("stroke-width", String(t.strokeMm)), s.appendChild(l);
1840
+ l.setAttribute("x1", String(a.x1)), l.setAttribute("y1", String(a.y1)), l.setAttribute("x2", String(a.x2)), l.setAttribute("y2", String(a.y2)), l.setAttribute("stroke", s), l.setAttribute("stroke-width", String(t.strokeMm)), o.appendChild(l);
1675
1841
  }
1676
1842
  for (const a of t.labels) {
1677
1843
  const l = i.createElementNS(it, "text");
1678
- l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("font-size", String(t.fontMm)), l.setAttribute("fill", o), l.setAttribute("text-anchor", a.anchor), l.setAttribute("font-family", "var(--om-carto-font)"), l.textContent = a.text, s.appendChild(l);
1844
+ l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("font-size", String(t.fontMm)), l.setAttribute("fill", s), l.setAttribute("text-anchor", a.anchor), l.setAttribute("font-family", "var(--om-carto-font)"), l.textContent = a.text, o.appendChild(l);
1679
1845
  }
1680
- this.replaceChildren(s);
1846
+ this.replaceChildren(o);
1681
1847
  }
1682
1848
  paintCartograph(t, e) {
1683
- const n = this.drawing;
1684
- if (!n) return;
1685
- const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = F(i?.color) ?? "#000", o = (l) => l * e.pxPerMm;
1686
- t.strokeStyle = s, t.fillStyle = s, t.lineWidth = o(n.strokeMm);
1687
- for (const l of n.bars)
1688
- 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));
1849
+ const r = this.drawing;
1850
+ if (!r) return;
1851
+ const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = F(i?.color) ?? "#000", s = (l) => l * e.pxPerMm;
1852
+ t.strokeStyle = o, t.fillStyle = o, t.lineWidth = s(r.strokeMm);
1853
+ for (const l of r.bars)
1854
+ l.filled && t.fillRect(s(l.x), s(l.y), s(l.w), s(l.h)), t.strokeRect(s(l.x), s(l.y), s(l.w), s(l.h));
1689
1855
  t.beginPath();
1690
- for (const l of n.strokes)
1691
- t.moveTo(o(l.x1), o(l.y1)), t.lineTo(o(l.x2), o(l.y2));
1856
+ for (const l of r.strokes)
1857
+ t.moveTo(s(l.x1), s(l.y1)), t.lineTo(s(l.x2), s(l.y2));
1692
1858
  t.stroke();
1693
1859
  const a = i?.fontFamily || "system-ui, sans-serif";
1694
- t.font = `${o(n.fontMm)}px ${a}`, t.textBaseline = "alphabetic";
1695
- for (const l of n.labels)
1696
- t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text, o(l.x), o(l.y));
1860
+ t.font = `${s(r.fontMm)}px ${a}`, t.textBaseline = "alphabetic";
1861
+ for (const l of r.labels)
1862
+ t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text, s(l.x), s(l.y));
1697
1863
  }
1698
1864
  }
1699
- x("om-scalebar", je);
1700
- const Q = "http://www.w3.org/2000/svg";
1701
- class Ge extends R {
1865
+ x("om-scalebar", He);
1866
+ const J = "http://www.w3.org/2000/svg";
1867
+ class Ye extends I {
1702
1868
  static observedAttributes = [...T["om-north"]];
1703
1869
  /** Degrees clockwise from the page's "up", or null when unknowable. */
1704
1870
  get bearing() {
1705
- const t = _(this)?.georef;
1706
- return t ? Kr(t) : null;
1871
+ const t = O(this)?.georef;
1872
+ return t ? on(t) : null;
1707
1873
  }
1708
1874
  get indicatorKind() {
1709
1875
  return this.getAttribute("kind") === "rose" ? "rose" : "arrow";
1710
1876
  }
1711
1877
  renderNow() {
1712
- if (this.applyPlacement(), this.style.display = "block", !_(this)) {
1878
+ if (this.applyPlacement(), this.style.display = "block", !O(this)) {
1713
1879
  const l = this.getAttribute("for");
1714
- G(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
1880
+ q(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
1715
1881
  return;
1716
1882
  }
1717
1883
  const e = this.bearing;
1718
1884
  if (e == null) {
1719
- G(this, "North indicator cannot derive a direction from this frame yet.");
1885
+ q(this, "North indicator cannot derive a direction from this frame yet.");
1720
1886
  return;
1721
1887
  }
1722
- const { w: n, h: i } = C(this), s = this.ownerDocument, o = s.createElementNS(Q, "svg");
1723
- o.setAttribute("width", `${n}mm`), o.setAttribute("height", `${i}mm`), o.setAttribute("viewBox", `0 0 ${n} ${i}`), o.style.display = "block";
1724
- const a = s.createElementNS(Q, "g");
1725
- a.setAttribute("transform", `rotate(${e.toFixed(3)} ${n / 2} ${i / 2})`);
1726
- for (const l of this.buildGeometry(s, n, i)) a.appendChild(l);
1727
- o.appendChild(a), this.replaceChildren(o);
1888
+ const { w: r, h: i } = C(this), o = this.ownerDocument, s = o.createElementNS(J, "svg");
1889
+ s.setAttribute("width", `${r}mm`), s.setAttribute("height", `${i}mm`), s.setAttribute("viewBox", `0 0 ${r} ${i}`), s.style.display = "block";
1890
+ const a = o.createElementNS(J, "g");
1891
+ a.setAttribute("transform", `rotate(${e.toFixed(3)} ${r / 2} ${i / 2})`);
1892
+ for (const l of this.buildGeometry(o, r, i)) a.appendChild(l);
1893
+ s.appendChild(a), this.replaceChildren(s);
1728
1894
  }
1729
- buildGeometry(t, e, n) {
1730
- const i = "var(--om-carto-compass-ink)", s = [], o = e / 2, a = Math.min(3, n * 0.24), l = n - a * 1.2;
1895
+ buildGeometry(t, e, r) {
1896
+ const i = "var(--om-carto-compass-ink)", o = [], s = e / 2, a = Math.min(3, r * 0.24), l = r - a * 1.2;
1731
1897
  if (this.indicatorKind === "rose") {
1732
- const f = Math.min(e, l) / 2, g = t.createElementNS(Q, "circle");
1733
- g.setAttribute("cx", String(o)), g.setAttribute("cy", String(l / 2)), g.setAttribute("r", String(f)), g.setAttribute("fill", "none"), g.setAttribute("stroke", i), g.setAttribute("stroke-width", "0.2"), s.push(g);
1898
+ const f = Math.min(e, l) / 2, g = t.createElementNS(J, "circle");
1899
+ g.setAttribute("cx", String(s)), g.setAttribute("cy", String(l / 2)), g.setAttribute("r", String(f)), g.setAttribute("fill", "none"), g.setAttribute("stroke", i), g.setAttribute("stroke-width", "0.2"), o.push(g);
1734
1900
  }
1735
- const c = 0, u = l, h = Math.min(e * 0.3, 4), d = t.createElementNS(Q, "path");
1736
- d.setAttribute("d", `M ${o} ${c} L ${o + h} ${u} L ${o} ${u - h * 0.55} L ${o - h} ${u} Z`), d.setAttribute("fill", i), s.push(d);
1737
- const m = t.createElementNS(Q, "text");
1738
- 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;
1901
+ const c = 0, u = l, h = Math.min(e * 0.3, 4), d = t.createElementNS(J, "path");
1902
+ d.setAttribute("d", `M ${s} ${c} L ${s + h} ${u} L ${s} ${u - h * 0.55} L ${s - h} ${u} Z`), d.setAttribute("fill", i), o.push(d);
1903
+ const m = t.createElementNS(J, "text");
1904
+ return m.setAttribute("x", String(s)), m.setAttribute("y", String(r)), 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", o.push(m), o;
1739
1905
  }
1740
1906
  paintCartograph(t, e) {
1741
- const n = this.bearing;
1742
- if (n == null) return;
1743
- 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);
1744
- 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();
1907
+ const r = this.bearing;
1908
+ if (r == null) return;
1909
+ const { w: i, h: o } = C(this), s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = F(s?.color) ?? "#000", l = (m) => m * e.pxPerMm, c = Math.min(3, o * 0.24), u = o - c * 1.2, h = i / 2, d = Math.min(i * 0.3, 4);
1910
+ t.save(), t.translate(l(h), l(o / 2)), t.rotate(r * Math.PI / 180), t.translate(-l(h), -l(o / 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 ${s?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(h), l(o)), t.restore();
1745
1911
  }
1746
1912
  }
1747
- x("om-north", Ge);
1748
- const ot = "http://www.w3.org/2000/svg", rn = ["rect", "ellipse", "line", "arrow"];
1749
- class qe extends R {
1913
+ x("om-north", Ye);
1914
+ const st = "http://www.w3.org/2000/svg", gn = ["rect", "ellipse", "line", "arrow"];
1915
+ class Xe extends I {
1750
1916
  static observedAttributes = [...T["om-shape"]];
1751
1917
  get kind() {
1752
1918
  const t = this.getAttribute("kind");
1753
- return rn.includes(t) ? t : "rect";
1919
+ return gn.includes(t) ? t : "rect";
1754
1920
  }
1755
1921
  get fill() {
1756
1922
  return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
@@ -1776,44 +1942,44 @@ class qe extends R {
1776
1942
  }
1777
1943
  renderNow() {
1778
1944
  this.applyPlacement(), this.style.display = "block";
1779
- const { w: t, h: e } = C(this), n = this.ownerDocument, i = n.createElementNS(ot, "svg");
1945
+ const { w: t, h: e } = C(this), r = this.ownerDocument, i = r.createElementNS(st, "svg");
1780
1946
  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";
1781
- const s = this.strokeWidthMm / 2, o = this.kind;
1947
+ const o = this.strokeWidthMm / 2, s = this.kind;
1782
1948
  let a;
1783
- o === "ellipse" ? (a = n.createElementNS(ot, "ellipse"), a.setAttribute("cx", String(t / 2)), a.setAttribute("cy", String(e / 2)), a.setAttribute("rx", String(Math.max(0, t / 2 - s))), a.setAttribute("ry", String(Math.max(0, e / 2 - s)))) : o === "line" || o === "arrow" ? (a = n.createElementNS(ot, "path"), a.setAttribute("d", o === "arrow" ? this.arrowPath(t, e) : `M 0 0 L ${t} ${e}`)) : (a = n.createElementNS(ot, "rect"), a.setAttribute("x", String(s)), a.setAttribute("y", String(s)), a.setAttribute("width", String(Math.max(0, t - this.strokeWidthMm))), a.setAttribute("height", String(Math.max(0, e - this.strokeWidthMm))), this.radiusMm > 0 && a.setAttribute("rx", String(this.radiusMm)));
1784
- const l = o === "rect" || o === "ellipse" || o === "arrow";
1949
+ s === "ellipse" ? (a = r.createElementNS(st, "ellipse"), a.setAttribute("cx", String(t / 2)), a.setAttribute("cy", String(e / 2)), a.setAttribute("rx", String(Math.max(0, t / 2 - o))), a.setAttribute("ry", String(Math.max(0, e / 2 - o)))) : s === "line" || s === "arrow" ? (a = r.createElementNS(st, "path"), a.setAttribute("d", s === "arrow" ? this.arrowPath(t, e) : `M 0 0 L ${t} ${e}`)) : (a = r.createElementNS(st, "rect"), a.setAttribute("x", String(o)), a.setAttribute("y", String(o)), a.setAttribute("width", String(Math.max(0, t - this.strokeWidthMm))), a.setAttribute("height", String(Math.max(0, e - this.strokeWidthMm))), this.radiusMm > 0 && a.setAttribute("rx", String(this.radiusMm)));
1950
+ const l = s === "rect" || s === "ellipse" || s === "arrow";
1785
1951
  a.setAttribute("fill", l ? this.fill : "none"), l && a.setAttribute("fill-opacity", String(this.fillOpacity)), a.setAttribute("stroke", this.stroke), a.setAttribute("stroke-width", String(this.strokeWidthMm)), i.appendChild(a), this.replaceChildren(i);
1786
1952
  }
1787
1953
  /** A line from the box's top-left to its bottom-right, with a solid head. */
1788
1954
  arrowPath(t, e) {
1789
- const n = Math.min(t, e) * 0.28, i = Math.atan2(e, t), s = t, o = e, a = { x: s - n * Math.cos(i - 0.4), y: o - n * Math.sin(i - 0.4) }, l = { x: s - n * Math.cos(i + 0.4), y: o - n * Math.sin(i + 0.4) };
1790
- return `M 0 0 L ${s} ${o} M ${s} ${o} L ${a.x} ${a.y} L ${l.x} ${l.y} Z`;
1955
+ const r = Math.min(t, e) * 0.28, i = Math.atan2(e, t), o = t, s = e, a = { x: o - r * Math.cos(i - 0.4), y: s - r * Math.sin(i - 0.4) }, l = { x: o - r * Math.cos(i + 0.4), y: s - r * Math.sin(i + 0.4) };
1956
+ return `M 0 0 L ${o} ${s} M ${o} ${s} L ${a.x} ${a.y} L ${l.x} ${l.y} Z`;
1791
1957
  }
1792
1958
  paintCartograph(t, e) {
1793
- const { w: n, h: i } = C(this);
1794
- if (n <= 0 || i <= 0) return;
1795
- 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;
1959
+ const { w: r, h: i } = C(this);
1960
+ if (r <= 0 || i <= 0) return;
1961
+ const o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || o?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || o?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = s(this.strokeWidthMm), u = c / 2, h = this.kind;
1796
1962
  if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, h === "ellipse")
1797
- 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();
1963
+ t.beginPath(), t.ellipse(s(r / 2), s(i / 2), Math.max(0, s(r / 2) - u), Math.max(0, s(i / 2) - u), 0, 0, Math.PI * 2), t.fill(), t.globalAlpha = 1, c > 0 && t.stroke();
1798
1964
  else if (h === "line" || h === "arrow") {
1799
- if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(o(n), o(i)), c > 0 && t.stroke(), h === "arrow") {
1800
- const d = Math.min(o(n), o(i)) * 0.28, m = Math.atan2(o(i), o(n));
1801
- 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();
1965
+ if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(s(r), s(i)), c > 0 && t.stroke(), h === "arrow") {
1966
+ const d = Math.min(s(r), s(i)) * 0.28, m = Math.atan2(s(i), s(r));
1967
+ t.beginPath(), t.moveTo(s(r), s(i)), t.lineTo(s(r) - d * Math.cos(m - 0.4), s(i) - d * Math.sin(m - 0.4)), t.lineTo(s(r) - d * Math.cos(m + 0.4), s(i) - d * Math.sin(m + 0.4)), t.closePath(), t.fillStyle = l, t.fill();
1802
1968
  }
1803
1969
  } else {
1804
- const d = o(this.radiusMm);
1805
- t.beginPath(), d > 0 && typeof t.roundRect == "function" ? t.roundRect(u, u, o(n) - c, o(i) - c, d) : t.rect(u, u, o(n) - c, o(i) - c), t.fill(), t.globalAlpha = 1, c > 0 && t.stroke();
1970
+ const d = s(this.radiusMm);
1971
+ t.beginPath(), d > 0 && typeof t.roundRect == "function" ? t.roundRect(u, u, s(r) - c, s(i) - c, d) : t.rect(u, u, s(r) - c, s(i) - c), t.fill(), t.globalAlpha = 1, c > 0 && t.stroke();
1806
1972
  }
1807
1973
  t.restore();
1808
1974
  }
1809
1975
  }
1810
- x("om-shape", qe);
1811
- const ue = "data-om-carto-owned", nn = ["contain", "cover", "fill"];
1812
- class We extends R {
1976
+ x("om-shape", Xe);
1977
+ const ye = "data-om-carto-owned", pn = ["contain", "cover", "fill"];
1978
+ class Je extends I {
1813
1979
  static observedAttributes = [...T["om-image"]];
1814
1980
  get fit() {
1815
1981
  const t = this.getAttribute("fit");
1816
- return nn.includes(t ?? "") ? t : "contain";
1982
+ return pn.includes(t ?? "") ? t : "contain";
1817
1983
  }
1818
1984
  get image() {
1819
1985
  return this.querySelector(":scope > img");
@@ -1822,103 +1988,103 @@ class We extends R {
1822
1988
  this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden";
1823
1989
  const t = this.getAttribute("src");
1824
1990
  let e = this.image;
1825
- !e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(ue, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(ue) && e.getAttribute("src") !== t && e.setAttribute("src", t), e.style.width = "100%", e.style.height = "100%", e.style.objectFit = this.fit, e.style.display = "block");
1991
+ !e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(ye, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(ye) && 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");
1826
1992
  }
1827
1993
  paintCartograph(t, e) {
1828
- const n = this.image;
1829
- if (!n || !n.complete || n.naturalWidth === 0) return;
1830
- const { w: i, h: s } = C(this), o = i * e.pxPerMm, a = s * e.pxPerMm;
1831
- if (o <= 0 || a <= 0) return;
1994
+ const r = this.image;
1995
+ if (!r || !r.complete || r.naturalWidth === 0) return;
1996
+ const { w: i, h: o } = C(this), s = i * e.pxPerMm, a = o * e.pxPerMm;
1997
+ if (s <= 0 || a <= 0) return;
1832
1998
  const l = this.fit;
1833
1999
  if (l === "fill") {
1834
- t.drawImage(n, 0, 0, o, a);
2000
+ t.drawImage(r, 0, 0, s, a);
1835
2001
  return;
1836
2002
  }
1837
- 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;
1838
- 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();
2003
+ const c = r.naturalWidth / r.naturalHeight, u = s / a, h = l === "contain" ? c > u : c < u, d = h ? s : a * c, m = h ? s / c : a;
2004
+ l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0, s, a), t.clip()), t.drawImage(r, (s - d) / 2, (a - m) / 2, d, m), l === "cover" && t.restore();
1839
2005
  }
1840
2006
  }
1841
- x("om-image", We);
1842
- const on = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), sn = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), an = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
1843
- function ln(r) {
1844
- const t = r.type ?? "";
1845
- if (an.has(t)) return "ramp";
1846
- if (on.has(t)) return "line";
1847
- if (sn.has(t)) return "point";
2007
+ x("om-image", Je);
2008
+ const bn = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), yn = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), wn = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
2009
+ function vn(n) {
2010
+ const t = n.type ?? "";
2011
+ if (wn.has(t)) return "ramp";
2012
+ if (bn.has(t)) return "line";
2013
+ if (yn.has(t)) return "point";
1848
2014
  if (t === "GeoJsonLayer") {
1849
- const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
1850
- if (n && !i) return "polygon";
1851
- if (i && !n || e.filled === !1 && e.stroked !== !1) return "line";
2015
+ const e = n.props ?? {}, r = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
2016
+ if (r && !i) return "polygon";
2017
+ if (i && !r || e.filled === !1 && e.stroked !== !1) return "line";
1852
2018
  }
1853
2019
  return "polygon";
1854
2020
  }
1855
- function cn(r) {
1856
- const t = r.meta?.legend;
1857
- return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
2021
+ function Mn(n) {
2022
+ const t = n.meta?.legend;
2023
+ return n.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
1858
2024
  }
1859
- const xt = 12;
1860
- function un(r, t = []) {
2025
+ const Ct = 12;
2026
+ function An(n, t = []) {
1861
2027
  const e = [];
1862
- for (const n of r) {
1863
- if (n.props?.visible === !1) continue;
1864
- const i = t.filter((a) => a.layer === n.id), s = i.find((a) => a.match == null);
1865
- if (s?.hide) continue;
1866
- const o = hn(n.meta?.legend);
2028
+ for (const r of n) {
2029
+ if (r.props?.visible === !1) continue;
2030
+ const i = t.filter((a) => a.layer === r.id), o = i.find((a) => a.match == null);
2031
+ if (o?.hide) continue;
2032
+ const s = Sn(r.meta?.legend);
1867
2033
  e.push({
1868
- layerId: n.id,
1869
- label: s?.label ?? n.meta?.label ?? n.id,
1870
- color: s?.color ?? cn(n),
1871
- shape: s?.shape ?? ln(n),
1872
- legend: mn(o, i),
1873
- order: s?.order
2034
+ layerId: r.id,
2035
+ label: o?.label ?? r.meta?.label ?? r.id,
2036
+ color: o?.color ?? Mn(r),
2037
+ shape: o?.shape ?? vn(r),
2038
+ legend: Cn(s, i),
2039
+ order: o?.order
1874
2040
  });
1875
2041
  }
1876
- return e.map((n, i) => ({ row: n, index: i })).sort((n, i) => {
1877
- const s = n.row.order ?? Number.POSITIVE_INFINITY, o = i.row.order ?? Number.POSITIVE_INFINITY;
1878
- return s - o || n.index - i.index;
1879
- }).map((n) => n.row);
2042
+ return e.map((r, i) => ({ row: r, index: i })).sort((r, i) => {
2043
+ const o = r.row.order ?? Number.POSITIVE_INFINITY, s = i.row.order ?? Number.POSITIVE_INFINITY;
2044
+ return o - s || r.index - i.index;
2045
+ }).map((r) => r.row);
1880
2046
  }
1881
- function hn(r) {
1882
- if (!r || r.kind !== "categories" || r.entries.length <= xt) return r;
1883
- const t = r.entries.slice(0, xt), e = r.entries.length - xt;
2047
+ function Sn(n) {
2048
+ if (!n || n.kind !== "categories" || n.entries.length <= Ct) return n;
2049
+ const t = n.entries.slice(0, Ct), e = n.entries.length - Ct;
1884
2050
  return {
1885
- ...r,
1886
- entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
2051
+ ...n,
2052
+ entries: [...t, { color: n.defaultColor ?? "#999", label: `+${e} more` }]
1887
2053
  };
1888
2054
  }
1889
- function mn(r, t) {
2055
+ function Cn(n, t) {
1890
2056
  const e = t.filter((i) => i.match != null);
1891
- if (!r || r.kind === "ramp" || e.length === 0) return r;
1892
- const n = [];
1893
- for (const i of r.entries) {
1894
- const s = e.find((o) => o.match === i.label);
1895
- s?.hide || n.push({ color: s?.color ?? i.color, label: s?.label ?? i.label });
2057
+ if (!n || n.kind === "ramp" || e.length === 0) return n;
2058
+ const r = [];
2059
+ for (const i of n.entries) {
2060
+ const o = e.find((s) => s.match === i.label);
2061
+ o?.hide || r.push({ color: o?.color ?? i.color, label: o?.label ?? i.label });
1896
2062
  }
1897
- return { ...r, entries: n };
2063
+ return { ...n, entries: r };
1898
2064
  }
1899
- function dn(r) {
2065
+ function xn(n) {
1900
2066
  const t = [];
1901
- for (const e of r.querySelectorAll(":scope > om-legend-row")) {
1902
- const n = e.getAttribute("layer");
1903
- if (!n) continue;
1904
- const i = e.getAttribute("order"), s = i == null || i.trim() === "" ? void 0 : Number(i);
2067
+ for (const e of n.querySelectorAll(":scope > om-legend-row")) {
2068
+ const r = e.getAttribute("layer");
2069
+ if (!r) continue;
2070
+ const i = e.getAttribute("order"), o = i == null || i.trim() === "" ? void 0 : Number(i);
1905
2071
  t.push({
1906
- layer: n,
2072
+ layer: r,
1907
2073
  match: e.getAttribute("match") ?? void 0,
1908
2074
  label: e.getAttribute("label") ?? void 0,
1909
2075
  hide: e.hasAttribute("hide"),
1910
- order: s != null && Number.isFinite(s) ? s : void 0,
2076
+ order: o != null && Number.isFinite(o) ? o : void 0,
1911
2077
  color: e.getAttribute("color") ?? void 0,
1912
2078
  shape: e.getAttribute("shape") ?? void 0
1913
2079
  });
1914
2080
  }
1915
2081
  return t;
1916
2082
  }
1917
- function Be(r) {
2083
+ function Ze(n) {
1918
2084
  const t = [];
1919
- for (const e of r.querySelectorAll(":scope > om-legend-row")) {
2085
+ for (const e of n.querySelectorAll(":scope > om-legend-row")) {
1920
2086
  if (e.hasAttribute("hide")) continue;
1921
- const n = e.getAttribute("order"), i = n == null || n.trim() === "" ? void 0 : Number(n);
2087
+ const r = e.getAttribute("order"), i = r == null || r.trim() === "" ? void 0 : Number(r);
1922
2088
  t.push({
1923
2089
  layerId: e.getAttribute("layer") ?? "",
1924
2090
  label: e.getAttribute("label") ?? e.getAttribute("layer") ?? "",
@@ -1927,109 +2093,109 @@ function Be(r) {
1927
2093
  order: i != null && Number.isFinite(i) ? i : void 0
1928
2094
  });
1929
2095
  }
1930
- return t.sort((e, n) => (e.order ?? Number.POSITIVE_INFINITY) - (n.order ?? Number.POSITIVE_INFINITY));
2096
+ return t.sort((e, r) => (e.order ?? Number.POSITIVE_INFINITY) - (r.order ?? Number.POSITIVE_INFINITY));
1931
2097
  }
1932
- const he = "data-om-carto-legend-rows";
1933
- class Ve extends R {
2098
+ const we = "data-om-carto-legend-rows";
2099
+ class Qe extends I {
1934
2100
  static observedAttributes = [...T["om-legend"]];
1935
2101
  get derived() {
1936
2102
  return this.getAttribute("derived") !== "false";
1937
2103
  }
1938
2104
  /** The rows this legend currently shows — recomputed on demand, never stored. */
1939
2105
  get rows() {
1940
- if (!this.derived) return Be(this);
1941
- const n = _(this)?.mapElement?.getLayers?.();
1942
- return n ? un(n, dn(this)) : [];
2106
+ if (!this.derived) return Ze(this);
2107
+ const r = O(this)?.mapElement?.getLayers?.();
2108
+ return r ? An(r, xn(this)) : [];
1943
2109
  }
1944
2110
  renderNow() {
1945
- if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !_(this)) {
2111
+ if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !O(this)) {
1946
2112
  const e = this.getAttribute("for");
1947
- G(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
2113
+ q(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
1948
2114
  return;
1949
2115
  }
1950
2116
  const t = this.rows;
1951
2117
  if (t.length === 0 && this.derived) {
1952
- G(this, "Legend is waiting for its frame's layers.");
2118
+ q(this, "Legend is waiting for its frame's layers.");
1953
2119
  return;
1954
2120
  }
1955
2121
  this.renderRows(t);
1956
2122
  }
1957
2123
  renderRows(t) {
1958
2124
  const e = this.ownerDocument;
1959
- this.querySelector(`:scope > [${he}]`)?.remove(), Tr(this);
1960
- const n = e.createElement("div");
1961
- n.setAttribute(he, ""), n.style.cssText = "padding:2mm;font-size:2.6mm;line-height:1.35;";
2125
+ this.querySelector(`:scope > [${we}]`)?.remove(), Ur(this);
2126
+ const r = e.createElement("div");
2127
+ r.setAttribute(we, ""), r.style.cssText = "padding:2mm;font-size:2.6mm;line-height:1.35;";
1962
2128
  const i = this.getAttribute("title");
1963
2129
  if (i) {
1964
- const o = e.createElement("div");
1965
- o.textContent = i, o.style.cssText = "font-weight:600;margin-bottom:1.2mm;color:var(--om-carto-legend-title-ink);", n.appendChild(o);
2130
+ const s = e.createElement("div");
2131
+ s.textContent = i, s.style.cssText = "font-weight:600;margin-bottom:1.2mm;color:var(--om-carto-legend-title-ink);", r.appendChild(s);
1966
2132
  }
1967
- const s = Number(this.getAttribute("columns"));
1968
- Number.isFinite(s) && s > 1 && (n.style.columnCount = String(Math.floor(s)), n.style.columnGap = "3mm");
1969
- for (const o of t)
1970
- n.appendChild(this.buildRow(e, o)), o.legend && n.appendChild(this.buildSymbology(e, o));
1971
- this.appendChild(n);
2133
+ const o = Number(this.getAttribute("columns"));
2134
+ Number.isFinite(o) && o > 1 && (r.style.columnCount = String(Math.floor(o)), r.style.columnGap = "3mm");
2135
+ for (const s of t)
2136
+ r.appendChild(this.buildRow(e, s)), s.legend && r.appendChild(this.buildSymbology(e, s));
2137
+ this.appendChild(r);
1972
2138
  }
1973
2139
  buildRow(t, e) {
1974
- const n = t.createElement("div");
1975
- n.style.cssText = "display:flex;align-items:center;gap:1.5mm;margin:0.6mm 0;break-inside:avoid;", n.appendChild(this.buildSwatch(t, e.color, e.shape));
2140
+ const r = t.createElement("div");
2141
+ r.style.cssText = "display:flex;align-items:center;gap:1.5mm;margin:0.6mm 0;break-inside:avoid;", r.appendChild(this.buildSwatch(t, e.color, e.shape));
1976
2142
  const i = t.createElement("span");
1977
- return i.textContent = e.label, n.appendChild(i), n;
2143
+ return i.textContent = e.label, r.appendChild(i), r;
1978
2144
  }
1979
2145
  /** The swatch geometry carries meaning: an area, a line and a point read differently. */
1980
- buildSwatch(t, e, n) {
1981
- const i = t.createElement("span"), s = "display:inline-block;flex:none;width:3.2mm;height:3.2mm;";
1982
- return n === "line" ? i.style.cssText = `${s}height:0.9mm;background:${e};` : n === "point" ? i.style.cssText = `${s}border-radius:50%;background:${e};` : n === "ramp" ? i.style.cssText = `${s}width:6mm;background:linear-gradient(to right, ${e}, transparent);` : i.style.cssText = `${s}background:${e};border:0.15mm solid rgba(0,0,0,.35);`, i;
2146
+ buildSwatch(t, e, r) {
2147
+ const i = t.createElement("span"), o = "display:inline-block;flex:none;width:3.2mm;height:3.2mm;";
2148
+ return r === "line" ? i.style.cssText = `${o}height:0.9mm;background:${e};` : r === "point" ? i.style.cssText = `${o}border-radius:50%;background:${e};` : r === "ramp" ? i.style.cssText = `${o}width:6mm;background:linear-gradient(to right, ${e}, transparent);` : i.style.cssText = `${o}background:${e};border:0.15mm solid rgba(0,0,0,.35);`, i;
1983
2149
  }
1984
2150
  buildSymbology(t, e) {
1985
- const n = t.createElement("div");
1986
- n.style.cssText = "margin:0.4mm 0 1.6mm 4.7mm;break-inside:avoid;";
1987
- const i = e.legend, s = t.createElement("div");
1988
- if (s.textContent = i.field, s.style.cssText = "font-size:2.1mm;opacity:.7;margin-bottom:0.5mm;", n.appendChild(s), i.kind === "ramp") {
1989
- const o = t.createElement("div");
1990
- o.style.cssText = `height:2.4mm;background:linear-gradient(to right, ${i.colors.join(", ")});border:0.15mm solid rgba(0,0,0,.25);`, n.appendChild(o);
2151
+ const r = t.createElement("div");
2152
+ r.style.cssText = "margin:0.4mm 0 1.6mm 4.7mm;break-inside:avoid;";
2153
+ const i = e.legend, o = t.createElement("div");
2154
+ if (o.textContent = i.field, o.style.cssText = "font-size:2.1mm;opacity:.7;margin-bottom:0.5mm;", r.appendChild(o), i.kind === "ramp") {
2155
+ const s = t.createElement("div");
2156
+ s.style.cssText = `height:2.4mm;background:linear-gradient(to right, ${i.colors.join(", ")});border:0.15mm solid rgba(0,0,0,.25);`, r.appendChild(s);
1991
2157
  const a = t.createElement("div");
1992
- return a.style.cssText = "display:flex;justify-content:space-between;font-size:2.1mm;opacity:.75;", a.append(st(t, i.domain[0].toLocaleString("en-US")), st(t, i.domain[1].toLocaleString("en-US"))), n.appendChild(a), n;
2158
+ return a.style.cssText = "display:flex;justify-content:space-between;font-size:2.1mm;opacity:.75;", a.append(ot(t, i.domain[0].toLocaleString("en-US")), ot(t, i.domain[1].toLocaleString("en-US"))), r.appendChild(a), r;
1993
2159
  }
1994
- for (const o of i.entries) {
2160
+ for (const s of i.entries) {
1995
2161
  const a = t.createElement("div");
1996
- a.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", a.appendChild(this.buildSwatch(t, o.color, "polygon")), a.appendChild(st(t, o.label)), n.appendChild(a);
2162
+ a.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", a.appendChild(this.buildSwatch(t, s.color, "polygon")), a.appendChild(ot(t, s.label)), r.appendChild(a);
1997
2163
  }
1998
2164
  if (i.kind === "categories" && i.defaultColor) {
1999
- const o = t.createElement("div");
2000
- o.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", o.appendChild(this.buildSwatch(t, i.defaultColor, "polygon")), o.appendChild(st(t, "other")), n.appendChild(o);
2165
+ const s = t.createElement("div");
2166
+ s.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", s.appendChild(this.buildSwatch(t, i.defaultColor, "polygon")), s.appendChild(ot(t, "other")), r.appendChild(s);
2001
2167
  }
2002
- return n;
2168
+ return r;
2003
2169
  }
2004
2170
  paintCartograph(t, e) {
2005
- const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
2006
- if (s <= 0 || o <= 0) return;
2171
+ const { w: r, h: i } = C(this), o = r * e.pxPerMm, s = i * e.pxPerMm;
2172
+ if (o <= 0 || s <= 0) return;
2007
2173
  const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
2008
- l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
2174
+ l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
2009
2175
  const c = F(a?.borderTopColor), u = $t(a?.borderTopWidth) * e.scale;
2010
- c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, s - u, o - u));
2176
+ c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, o - u, s - u));
2011
2177
  const h = F(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", m = (P) => P * e.pxPerMm;
2012
2178
  let f = m(2);
2013
2179
  const g = this.getAttribute("title");
2014
2180
  g && (t.fillStyle = h, t.font = `600 ${m(2.6)}px ${d}`, t.textBaseline = "top", t.fillText(g, m(2), f), f += m(4));
2015
- const p = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(p.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(p.length / w)), M = 3, v = Math.max(1, (n - 4 - M * (w - 1)) / w), N = f;
2016
- let O = -1, k = 2;
2181
+ const p = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(p.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(p.length / w)), M = 3, v = Math.max(1, (r - 4 - M * (w - 1)) / w), N = f;
2182
+ let _ = -1, $ = 2;
2017
2183
  t.font = `${m(2.6)}px ${d}`;
2018
2184
  for (const [P, L] of p.entries()) {
2019
2185
  const A = Math.min(w - 1, Math.floor(P / y));
2020
- if (A !== O && (O = A, k = 2 + O * (v + M), f = O === 0 ? N : m(2)), f > o || (t.fillStyle = L.color, L.shape === "line" ? t.fillRect(m(k), f + m(1.2), m(3.2), m(0.9)) : L.shape === "point" ? (t.beginPath(), t.arc(m(k + 1.6), f + m(1.6), m(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(m(k), f, m(3.2), m(3.2)), t.fillStyle = h, t.textBaseline = "top", t.fillText(L.label, m(k + 4.7), f + m(0.3)), f += m(4.2), !L.legend)) continue;
2186
+ if (A !== _ && (_ = A, $ = 2 + _ * (v + M), f = _ === 0 ? N : m(2)), f > s || (t.fillStyle = L.color, L.shape === "line" ? t.fillRect(m($), f + m(1.2), m(3.2), m(0.9)) : L.shape === "point" ? (t.beginPath(), t.arc(m($ + 1.6), f + m(1.6), m(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(m($), f, m(3.2), m(3.2)), t.fillStyle = h, t.textBaseline = "top", t.fillText(L.label, m($ + 4.7), f + m(0.3)), f += m(4.2), !L.legend)) continue;
2021
2187
  const S = L.legend;
2022
- 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") {
2023
- const $ = Math.min(24, Math.max(1, v - 2.7)), E = k + 2.7, U = t.createLinearGradient(m(E), 0, m(E + $), 0);
2024
- 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);
2188
+ if (t.save(), t.font = `${m(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(S.field, m($ + 2.7), f), t.globalAlpha = 1, f += m(2.8), S.kind === "ramp") {
2189
+ const k = Math.min(24, Math.max(1, v - 2.7)), E = $ + 2.7, U = t.createLinearGradient(m(E), 0, m(E + k), 0);
2190
+ S.colors.forEach((Y, ir) => U.addColorStop(S.colors.length === 1 ? 0 : ir / (S.colors.length - 1), Y)), t.fillStyle = U, t.fillRect(m(E), f, m(k), 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);
2025
2191
  const tt = S.domain[1].toLocaleString("en-US");
2026
- t.textAlign = "right", t.fillText(tt, m(E + $), f), t.textAlign = "left", f += m(3.2);
2192
+ t.textAlign = "right", t.fillText(tt, m(E + k), f), t.textAlign = "left", f += m(3.2);
2027
2193
  } else {
2028
- const $ = [...S.entries];
2029
- S.kind === "categories" && S.defaultColor && $.push({ color: S.defaultColor, label: "other" }), t.font = `${m(2.3)}px ${d}`;
2030
- for (const E of $) {
2031
- if (f > o) break;
2032
- 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);
2194
+ const k = [...S.entries];
2195
+ S.kind === "categories" && S.defaultColor && k.push({ color: S.defaultColor, label: "other" }), t.font = `${m(2.3)}px ${d}`;
2196
+ for (const E of k) {
2197
+ if (f > s) break;
2198
+ t.fillStyle = E.color, t.fillRect(m($ + 2.7), f, m(2.6), m(2.6)), t.fillStyle = h, t.fillText(E.label, m($ + 6.3), f + m(0.2)), f += m(3.2);
2033
2199
  }
2034
2200
  f += m(1);
2035
2201
  }
@@ -2037,88 +2203,88 @@ class Ve extends R {
2037
2203
  }
2038
2204
  }
2039
2205
  }
2040
- const st = (r, t) => {
2041
- const e = r.createElement("span");
2206
+ const ot = (n, t) => {
2207
+ const e = n.createElement("span");
2042
2208
  return e.textContent = t, e;
2043
2209
  };
2044
- x("om-legend", Ve);
2045
- const me = 48, Tt = {
2046
- toLngLat: (r, t) => [r, t],
2047
- fromLngLat: (r) => [r[0], r[1]]
2210
+ x("om-legend", Qe);
2211
+ const ve = 48, Rt = {
2212
+ toLngLat: (n, t) => [n, t],
2213
+ fromLngLat: (n) => [n[0], n[1]]
2048
2214
  };
2049
- function de(r, t = 5) {
2050
- return !Number.isFinite(r) || r <= 0 ? 0 : ke(r / Math.max(1, t));
2215
+ function Me(n, t = 5) {
2216
+ return !Number.isFinite(n) || n <= 0 ? 0 : Re(n / Math.max(1, t));
2051
2217
  }
2052
- function fn({ georef: r, plane: t = Tt, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
2053
- if (r.degenerate) return null;
2054
- const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
2218
+ function $n({ georef: n, plane: t = Rt, interval: e, intervalX: r, intervalY: i, labels: o = "outside", format: s }) {
2219
+ if (n.degenerate) return null;
2220
+ const a = n.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
2055
2221
  if (l.some((y) => !Number.isFinite(y)) || c.some((y) => !Number.isFinite(y))) return null;
2056
- const u = Math.min(...l), h = Math.max(...l), d = Math.min(...c), m = Math.max(...c), f = fe(n ?? e, de(h - u)), g = fe(i ?? e, de(m - d));
2222
+ const u = Math.min(...l), h = Math.max(...l), d = Math.min(...c), m = Math.max(...c), f = Ae(r ?? e, Me(h - u)), g = Ae(i ?? e, Me(m - d));
2057
2223
  if (f <= 0 || g <= 0 || (h - u) / f > 500 || (m - d) / g > 500) return null;
2058
- const p = [], b = [], w = o ?? pn;
2224
+ const p = [], b = [], w = s ?? En;
2059
2225
  for (let y = Math.ceil(u / f) * f; y <= h + 1e-9; y += f) {
2060
- const M = ge(r, t, y, d, m, "x");
2226
+ const M = Se(n, t, y, d, m, "x");
2061
2227
  if (M) {
2062
2228
  p.push(M);
2063
- const v = t === Tt ? ze(y) : y;
2064
- s !== "none" && be(b, M, r, w(v, "x"), "x", s);
2229
+ const v = t === Rt ? Ve(y) : y;
2230
+ o !== "none" && xe(b, M, n, w(v, "x"), "x", o);
2065
2231
  }
2066
2232
  }
2067
2233
  for (let y = Math.ceil(d / g) * g; y <= m + 1e-9; y += g) {
2068
- const M = ge(r, t, y, u, h, "y");
2069
- M && (p.push(M), s !== "none" && be(b, M, r, w(y, "y"), "y", s));
2234
+ const M = Se(n, t, y, u, h, "y");
2235
+ M && (p.push(M), o !== "none" && xe(b, M, n, w(y, "y"), "y", o));
2070
2236
  }
2071
2237
  return { lines: p, labels: b, intervalX: f, intervalY: g };
2072
2238
  }
2073
- const fe = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
2074
- function ge(r, t, e, n, i, s) {
2075
- const o = [];
2076
- for (let l = 0; l <= me; l++) {
2077
- const c = n + (i - n) * l / me, u = s === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
2239
+ const Ae = (n, t) => n != null && Number.isFinite(n) && n > 0 ? n : t;
2240
+ function Se(n, t, e, r, i, o) {
2241
+ const s = [];
2242
+ for (let l = 0; l <= ve; l++) {
2243
+ const c = r + (i - r) * l / ve, u = o === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
2078
2244
  if (!Number.isFinite(u[0]) || !Number.isFinite(u[1])) continue;
2079
- const h = r.project(u);
2080
- h && o.push(h);
2245
+ const h = n.project(u);
2246
+ h && s.push(h);
2081
2247
  }
2082
- const a = gn(o, r.widthMm, r.heightMm);
2083
- return a.length >= 2 ? { points: a, value: e, axis: s } : null;
2248
+ const a = kn(s, n.widthMm, n.heightMm);
2249
+ return a.length >= 2 ? { points: a, value: e, axis: o } : null;
2084
2250
  }
2085
- function gn(r, t, e) {
2086
- const n = (a) => a.xMm >= -0.01 && a.xMm <= t + 0.01 && a.yMm >= -0.01 && a.yMm <= e + 0.01, i = r.findIndex(n);
2251
+ function kn(n, t, e) {
2252
+ const r = (a) => a.xMm >= -0.01 && a.xMm <= t + 0.01 && a.yMm >= -0.01 && a.yMm <= e + 0.01, i = n.findIndex(r);
2087
2253
  if (i === -1) return [];
2088
- let s = r.length - 1;
2089
- for (; s > i && !n(r[s]); ) s--;
2090
- return r.slice(Math.max(0, i - 1), Math.min(r.length, s + 2)).map((a) => ({ xMm: pe(a.xMm, 0, t), yMm: pe(a.yMm, 0, e) }));
2254
+ let o = n.length - 1;
2255
+ for (; o > i && !r(n[o]); ) o--;
2256
+ return n.slice(Math.max(0, i - 1), Math.min(n.length, o + 2)).map((a) => ({ xMm: Ce(a.xMm, 0, t), yMm: Ce(a.yMm, 0, e) }));
2091
2257
  }
2092
- const pe = (r, t, e) => Math.min(e, Math.max(t, r));
2093
- function be(r, t, e, n, i, s) {
2258
+ const Ce = (n, t, e) => Math.min(e, Math.max(t, n));
2259
+ function xe(n, t, e, r, i, o) {
2094
2260
  if (i === "x") {
2095
- const o = t.points.reduce((a, l) => l.yMm > a.yMm ? l : a);
2096
- if (Math.abs(o.yMm - e.heightMm) > 0.5) return;
2097
- r.push({ text: n, xMm: o.xMm, yMm: e.heightMm + (s === "outside" ? 3 : -1), edge: "bottom", axis: i });
2261
+ const s = t.points.reduce((a, l) => l.yMm > a.yMm ? l : a);
2262
+ if (Math.abs(s.yMm - e.heightMm) > 0.5) return;
2263
+ n.push({ text: r, xMm: s.xMm, yMm: e.heightMm + (o === "outside" ? 3 : -1), edge: "bottom", axis: i });
2098
2264
  } else {
2099
- const o = t.points.reduce((a, l) => l.xMm < a.xMm ? l : a);
2100
- if (Math.abs(o.xMm) > 0.5) return;
2101
- r.push({ text: n, xMm: s === "outside" ? -1.2 : 1.2, yMm: o.yMm, edge: "left", axis: i });
2265
+ const s = t.points.reduce((a, l) => l.xMm < a.xMm ? l : a);
2266
+ if (Math.abs(s.xMm) > 0.5) return;
2267
+ n.push({ text: r, xMm: o === "outside" ? -1.2 : 1.2, yMm: s.yMm, edge: "left", axis: i });
2102
2268
  }
2103
2269
  }
2104
- function pn(r, t) {
2105
- if (Math.abs(r) >= 1e3) return Math.round(r).toLocaleString("en-US");
2106
- const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
2107
- return `${Number(r.toFixed(e))}°`;
2270
+ function En(n, t) {
2271
+ if (Math.abs(n) >= 1e3) return Math.round(n).toLocaleString("en-US");
2272
+ const e = Math.abs(n) < 1 ? 3 : Math.abs(n) < 10 ? 2 : 1;
2273
+ return `${Number(n.toFixed(e))}°`;
2108
2274
  }
2109
- function bn(r, t) {
2110
- const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), s = (n - i) * 60, o = Math.floor(s), a = Math.round((s - o) * 60), l = a === 60 ? o + 1 : o, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, h = a === 60 ? 0 : a;
2275
+ function Nn(n, t) {
2276
+ const e = t === "x" ? n < 0 ? "W" : "E" : n < 0 ? "S" : "N", r = Math.abs(n), i = Math.floor(r), o = (r - i) * 60, s = Math.floor(o), a = Math.round((o - s) * 60), l = a === 60 ? s + 1 : s, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, h = a === 60 ? 0 : a;
2111
2277
  return `${c}°${String(u).padStart(2, "0")}′${String(h).padStart(2, "0")}″${e}`;
2112
2278
  }
2113
- const at = "http://www.w3.org/2000/svg", yn = ["solid", "cross", "markers"], D = 1.4;
2114
- class He extends R {
2279
+ const at = "http://www.w3.org/2000/svg", Pn = ["solid", "cross", "markers"], j = 1.4;
2280
+ class tr extends I {
2115
2281
  static observedAttributes = [...T["om-graticule"]];
2116
2282
  resolvedPlane = null;
2117
2283
  resolvedPlaneKey = null;
2118
2284
  resolveToken = 0;
2119
2285
  get kind() {
2120
2286
  const t = this.getAttribute("kind");
2121
- return yn.includes(t) ? t : "solid";
2287
+ return Pn.includes(t) ? t : "solid";
2122
2288
  }
2123
2289
  get labelPlacement() {
2124
2290
  const t = this.getAttribute("labels");
@@ -2126,22 +2292,22 @@ class He extends R {
2126
2292
  }
2127
2293
  /** The grid this element currently draws, or null when it cannot yet. */
2128
2294
  get graticule() {
2129
- const t = _(this)?.georef;
2295
+ const t = O(this)?.georef;
2130
2296
  if (!t) return null;
2131
2297
  const e = this.gridPlane();
2132
2298
  if (!e) return null;
2133
- const n = (i) => {
2134
- const s = Number(this.getAttribute(i));
2135
- return Number.isFinite(s) && s > 0 ? s : null;
2299
+ const r = (i) => {
2300
+ const o = Number(this.getAttribute(i));
2301
+ return Number.isFinite(o) && o > 0 ? o : null;
2136
2302
  };
2137
- return fn({
2303
+ return $n({
2138
2304
  georef: t,
2139
2305
  plane: e,
2140
- interval: n("interval"),
2141
- intervalX: n("interval-x"),
2142
- intervalY: n("interval-y"),
2306
+ interval: r("interval"),
2307
+ intervalX: r("interval-x"),
2308
+ intervalY: r("interval-y"),
2143
2309
  labels: this.labelPlacement,
2144
- format: this.getAttribute("format") === "dms" ? bn : void 0
2310
+ format: this.getAttribute("format") === "dms" ? Nn : void 0
2145
2311
  });
2146
2312
  }
2147
2313
  /**
@@ -2150,25 +2316,25 @@ class He extends R {
2150
2316
  * a re-render when it lands.
2151
2317
  */
2152
2318
  gridPlane() {
2153
- const t = Y(this.getAttribute("crs"));
2154
- if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return Tt;
2319
+ const t = Tt(this.getAttribute("crs"));
2320
+ if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return Rt;
2155
2321
  const e = `${t}|${this.getAttribute("crs-def") ?? ""}`;
2156
2322
  if (this.resolvedPlaneKey === e) return this.resolvedPlane;
2157
- const n = X(t);
2158
- if (n) {
2159
- const s = { toLngLat: (o, a) => n.inverse([o, a]), fromLngLat: (o) => n.forward(o) };
2160
- return this.resolvedPlane = s, this.resolvedPlaneKey = e, s;
2323
+ const r = K(t);
2324
+ if (r) {
2325
+ const o = { toLngLat: (s, a) => r.inverse([s, a]), fromLngLat: (s) => r.forward(s) };
2326
+ return this.resolvedPlane = o, this.resolvedPlaneKey = e, o;
2161
2327
  }
2162
2328
  const i = ++this.resolveToken;
2163
- return Ue(t, this.getAttribute("crs-def")).then((s) => {
2164
- i !== this.resolveToken || !s || (this.resolvedPlane = { toLngLat: (o, a) => s.inverse([o, a]), fromLngLat: (o) => s.forward(o) }, this.resolvedPlaneKey = e, this.scheduleRender());
2329
+ return Lt(t, this.getAttribute("crs-def")).then((o) => {
2330
+ i !== this.resolveToken || !o || (this.resolvedPlane = { toLngLat: (s, a) => o.inverse([s, a]), fromLngLat: (s) => o.forward(s) }, this.resolvedPlaneKey = e, this.scheduleRender());
2165
2331
  }).catch(() => {
2166
2332
  }), null;
2167
2333
  }
2168
2334
  renderNow() {
2169
- if (this.applyPlacement(), this.style.display = "block", this.style.pointerEvents = "none", !_(this)) {
2170
- const n = this.getAttribute("for");
2171
- G(this, n ? `Graticule references no frame with id "${n}".` : "Graticule has no frame to cover (set for=).");
2335
+ if (this.applyPlacement(), this.style.display = "block", this.style.pointerEvents = "none", !O(this)) {
2336
+ const r = this.getAttribute("for");
2337
+ q(this, r ? `Graticule references no frame with id "${r}".` : "Graticule has no frame to cover (set for=).");
2172
2338
  return;
2173
2339
  }
2174
2340
  const e = this.graticule;
@@ -2179,148 +2345,148 @@ class He extends R {
2179
2345
  this.renderSvg(e);
2180
2346
  }
2181
2347
  renderSvg(t) {
2182
- const { w: e, h: n } = C(this), i = this.ownerDocument, s = i.createElementNS(at, "svg");
2183
- s.setAttribute("width", `${e}mm`), s.setAttribute("height", `${n}mm`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), s.style.cssText = "display:block;overflow:visible;";
2184
- const o = "var(--om-carto-graticule-ink)", a = this.kind;
2348
+ const { w: e, h: r } = C(this), i = this.ownerDocument, o = i.createElementNS(at, "svg");
2349
+ o.setAttribute("width", `${e}mm`), o.setAttribute("height", `${r}mm`), o.setAttribute("viewBox", `0 0 ${e} ${r}`), o.style.cssText = "display:block;overflow:visible;";
2350
+ const s = "var(--om-carto-graticule-ink)", a = this.kind;
2185
2351
  for (const l of t.lines)
2186
2352
  if (a === "solid") {
2187
2353
  const c = i.createElementNS(at, "polyline");
2188
- c.setAttribute("points", l.points.map((u) => `${u.xMm.toFixed(3)},${u.yMm.toFixed(3)}`).join(" ")), c.setAttribute("fill", "none"), c.setAttribute("stroke", o), c.setAttribute("stroke-width", "0.15"), s.appendChild(c);
2354
+ c.setAttribute("points", l.points.map((u) => `${u.xMm.toFixed(3)},${u.yMm.toFixed(3)}`).join(" ")), c.setAttribute("fill", "none"), c.setAttribute("stroke", s), c.setAttribute("stroke-width", "0.15"), o.appendChild(c);
2189
2355
  } else
2190
2356
  for (const c of this.tickPoints(l, a, t)) {
2191
2357
  const u = i.createElementNS(at, "path");
2192
- u.setAttribute("d", `M ${c.xMm - D} ${c.yMm} H ${c.xMm + D} M ${c.xMm} ${c.yMm - D} V ${c.yMm + D}`), u.setAttribute("stroke", o), u.setAttribute("stroke-width", "0.15"), s.appendChild(u);
2358
+ u.setAttribute("d", `M ${c.xMm - j} ${c.yMm} H ${c.xMm + j} M ${c.xMm} ${c.yMm - j} V ${c.yMm + j}`), u.setAttribute("stroke", s), u.setAttribute("stroke-width", "0.15"), o.appendChild(u);
2193
2359
  }
2194
2360
  for (const l of t.labels) {
2195
2361
  const c = i.createElementNS(at, "text");
2196
- c.setAttribute("x", String(l.xMm)), c.setAttribute("y", String(l.yMm)), c.setAttribute("font-size", "2.2"), c.setAttribute("fill", o), c.setAttribute("font-family", "var(--om-carto-font)"), c.setAttribute("text-anchor", l.edge === "left" ? "end" : "middle"), c.textContent = l.text, s.appendChild(c);
2362
+ c.setAttribute("x", String(l.xMm)), c.setAttribute("y", String(l.yMm)), c.setAttribute("font-size", "2.2"), c.setAttribute("fill", s), c.setAttribute("font-family", "var(--om-carto-font)"), c.setAttribute("text-anchor", l.edge === "left" ? "end" : "middle"), c.textContent = l.text, o.appendChild(c);
2197
2363
  }
2198
- this.replaceChildren(s);
2364
+ this.replaceChildren(o);
2199
2365
  }
2200
2366
  /** Intersections of this line with the perpendicular family. */
2201
- tickPoints(t, e, n) {
2367
+ tickPoints(t, e, r) {
2202
2368
  if (e === "markers") return [t.points[0], t.points[t.points.length - 1]];
2203
- const i = n.lines.filter((o) => o.axis !== t.axis), s = [];
2204
- for (const o of i) {
2205
- const a = wn(t.points, o.points);
2206
- a && s.push(a);
2369
+ const i = r.lines.filter((s) => s.axis !== t.axis), o = [];
2370
+ for (const s of i) {
2371
+ const a = Tn(t.points, s.points);
2372
+ a && o.push(a);
2207
2373
  }
2208
- return s;
2374
+ return o;
2209
2375
  }
2210
2376
  paintCartograph(t, e) {
2211
- const n = this.graticule;
2212
- if (!n) return;
2213
- const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = F(i?.color) ?? "#ffffff", o = (l) => l * e.pxPerMm, a = this.kind;
2214
- t.save(), t.strokeStyle = s, t.fillStyle = s, t.lineWidth = o(0.15);
2215
- for (const l of n.lines)
2377
+ const r = this.graticule;
2378
+ if (!r) return;
2379
+ const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = F(i?.color) ?? "#ffffff", s = (l) => l * e.pxPerMm, a = this.kind;
2380
+ t.save(), t.strokeStyle = o, t.fillStyle = o, t.lineWidth = s(0.15);
2381
+ for (const l of r.lines)
2216
2382
  if (a === "solid")
2217
- t.beginPath(), l.points.forEach((c, u) => u === 0 ? t.moveTo(o(c.xMm), o(c.yMm)) : t.lineTo(o(c.xMm), o(c.yMm))), t.stroke();
2383
+ t.beginPath(), l.points.forEach((c, u) => u === 0 ? t.moveTo(s(c.xMm), s(c.yMm)) : t.lineTo(s(c.xMm), s(c.yMm))), t.stroke();
2218
2384
  else
2219
- for (const c of this.tickPoints(l, a, n))
2220
- t.beginPath(), t.moveTo(o(c.xMm - D), o(c.yMm)), t.lineTo(o(c.xMm + D), o(c.yMm)), t.moveTo(o(c.xMm), o(c.yMm - D)), t.lineTo(o(c.xMm), o(c.yMm + D)), t.stroke();
2221
- t.font = `${o(2.2)}px ${i?.fontFamily || "system-ui, sans-serif"}`, t.textBaseline = "alphabetic";
2222
- for (const l of n.labels)
2223
- t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text, o(l.xMm), o(l.yMm));
2385
+ for (const c of this.tickPoints(l, a, r))
2386
+ t.beginPath(), t.moveTo(s(c.xMm - j), s(c.yMm)), t.lineTo(s(c.xMm + j), s(c.yMm)), t.moveTo(s(c.xMm), s(c.yMm - j)), t.lineTo(s(c.xMm), s(c.yMm + j)), t.stroke();
2387
+ t.font = `${s(2.2)}px ${i?.fontFamily || "system-ui, sans-serif"}`, t.textBaseline = "alphabetic";
2388
+ for (const l of r.labels)
2389
+ t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text, s(l.xMm), s(l.yMm));
2224
2390
  t.restore();
2225
2391
  }
2226
2392
  }
2227
- function wn(r, t) {
2228
- let e = null, n = Number.POSITIVE_INFINITY;
2229
- for (const i of r)
2230
- for (const s of t) {
2231
- const o = (i.xMm - s.xMm) ** 2 + (i.yMm - s.yMm) ** 2;
2232
- o < n && (n = o, e = i);
2393
+ function Tn(n, t) {
2394
+ let e = null, r = Number.POSITIVE_INFINITY;
2395
+ for (const i of n)
2396
+ for (const o of t) {
2397
+ const s = (i.xMm - o.xMm) ** 2 + (i.yMm - o.yMm) ** 2;
2398
+ s < r && (r = s, e = i);
2233
2399
  }
2234
- return n <= 1 ? e : null;
2400
+ return r <= 1 ? e : null;
2235
2401
  }
2236
- x("om-graticule", He);
2237
- function vn(r, t) {
2238
- if (r == null || typeof r != "object") return;
2239
- const e = r.properties;
2240
- return e && t in e ? e[t] : r[t];
2402
+ x("om-graticule", tr);
2403
+ function Ln(n, t) {
2404
+ if (n == null || typeof n != "object") return;
2405
+ const e = n.properties;
2406
+ return e && t in e ? e[t] : n[t];
2241
2407
  }
2242
- function Lt(r, t) {
2243
- if (Array.isArray(r)) {
2244
- if (typeof r[0] == "number") {
2245
- t.push([r[0], r[1]]);
2408
+ function It(n, t) {
2409
+ if (Array.isArray(n)) {
2410
+ if (typeof n[0] == "number") {
2411
+ t.push([n[0], n[1]]);
2246
2412
  return;
2247
2413
  }
2248
- for (const e of r) Lt(e, t);
2414
+ for (const e of n) It(e, t);
2249
2415
  }
2250
2416
  }
2251
- function Mn(r) {
2252
- return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
2417
+ function Fn(n) {
2418
+ return n ? n.tileData != null ? "tiled" : n.asset != null ? "asset" : null : "empty";
2253
2419
  }
2254
- function I(r, t) {
2255
- return vn(r, t);
2420
+ function R(n, t) {
2421
+ return Ln(n, t);
2256
2422
  }
2257
- function Ft(r) {
2423
+ function _t(n) {
2258
2424
  const t = {}, e = (i) => {
2259
- for (const [s, o] of Object.entries(i))
2260
- o == null || typeof o == "object" || (t[s] = String(o));
2425
+ for (const [o, s] of Object.entries(i))
2426
+ s == null || typeof s == "object" || (t[o] = String(s));
2261
2427
  };
2262
- e(r);
2263
- const n = r.properties;
2264
- return n && typeof n == "object" && e(n), t;
2265
- }
2266
- function An(r) {
2267
- let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
2268
- const s = [], o = r.geometry;
2269
- if (o?.coordinates != null) Lt(o.coordinates, s);
2270
- else if (Array.isArray(r.coordinates)) Lt(r.coordinates, s);
2428
+ e(n);
2429
+ const r = n.properties;
2430
+ return r && typeof r == "object" && e(r), t;
2431
+ }
2432
+ function Rn(n) {
2433
+ let t = 1 / 0, e = 1 / 0, r = -1 / 0, i = -1 / 0;
2434
+ const o = [], s = n.geometry;
2435
+ if (s?.coordinates != null) It(s.coordinates, o);
2436
+ else if (Array.isArray(n.coordinates)) It(n.coordinates, o);
2271
2437
  else {
2272
- const a = Number(I(r, "lng") ?? I(r, "longitude") ?? I(r, "lon") ?? I(r, "x")), l = Number(I(r, "lat") ?? I(r, "latitude") ?? I(r, "y"));
2273
- Number.isFinite(a) && Number.isFinite(l) && s.push([a, l]);
2274
- }
2275
- for (const [a, l] of s)
2276
- !Number.isFinite(a) || !Number.isFinite(l) || (t = Math.min(t, a), n = Math.max(n, a), e = Math.min(e, l), i = Math.max(i, l));
2277
- return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
2278
- }
2279
- function Sn(r, t) {
2280
- const [e, n, i, s] = r, o = Math.max(i - e, 1e-4), a = Math.max(s - n, 1e-4), l = o * t, c = a * t;
2281
- return [e - l, n - c, i + l, s + c];
2282
- }
2283
- const Jn = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
2284
- function Cn({ features: r, filter: t, sort: e }) {
2285
- let n = t ? r.filter((s) => xn(t, s)) : [...r];
2286
- const i = kn(e);
2287
- return i.length > 0 && (n = [...n].sort((s, o) => {
2438
+ const a = Number(R(n, "lng") ?? R(n, "longitude") ?? R(n, "lon") ?? R(n, "x")), l = Number(R(n, "lat") ?? R(n, "latitude") ?? R(n, "y"));
2439
+ Number.isFinite(a) && Number.isFinite(l) && o.push([a, l]);
2440
+ }
2441
+ for (const [a, l] of o)
2442
+ !Number.isFinite(a) || !Number.isFinite(l) || (t = Math.min(t, a), r = Math.max(r, a), e = Math.min(e, l), i = Math.max(i, l));
2443
+ return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, r, i];
2444
+ }
2445
+ function In(n, t) {
2446
+ const [e, r, i, o] = n, s = Math.max(i - e, 1e-4), a = Math.max(o - r, 1e-4), l = s * t, c = a * t;
2447
+ return [e - l, r - c, i + l, o + c];
2448
+ }
2449
+ const mi = ([n, t, e, r]) => Math.max(0, e - n) * Math.max(0, r - t);
2450
+ function _n({ features: n, filter: t, sort: e }) {
2451
+ let r = t ? n.filter((o) => On(t, o)) : [...n];
2452
+ const i = Un(e);
2453
+ return i.length > 0 && (r = [...r].sort((o, s) => {
2288
2454
  for (const { field: a, descending: l } of i) {
2289
- const c = I(s, a), u = I(o, a);
2455
+ const c = R(o, a), u = R(s, a);
2290
2456
  if (c == null && u == null) continue;
2291
2457
  if (c == null) return 1;
2292
2458
  if (u == null) return -1;
2293
- const h = $n(c, u);
2459
+ const h = Dn(c, u);
2294
2460
  if (h !== 0) return l ? -h : h;
2295
2461
  }
2296
2462
  return 0;
2297
- })), n;
2463
+ })), r;
2298
2464
  }
2299
- function xn(r, t) {
2465
+ function On(n, t) {
2300
2466
  try {
2301
- return !!r(t);
2467
+ return !!n(t);
2302
2468
  } catch {
2303
2469
  return !1;
2304
2470
  }
2305
2471
  }
2306
- function kn(r) {
2307
- return r ? r.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
2472
+ function Un(n) {
2473
+ return n ? n.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
2308
2474
  }
2309
- function $n(r, t) {
2310
- return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
2475
+ function Dn(n, t) {
2476
+ return typeof n == "number" && typeof t == "number" ? n - t : String(n).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
2311
2477
  }
2312
- function En(r) {
2313
- const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
2478
+ function zn(n) {
2479
+ const t = n.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
2314
2480
  return t === "" ? "page" : t;
2315
2481
  }
2316
- function Nn(r, t, e) {
2317
- const n = /* @__PURE__ */ new Map();
2318
- return t.map((i, s) => {
2319
- const o = Ft(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, h) => h === "index" ? String(s + 1) : h === "count" ? String(t.length) : o[h] ?? u), l = En(a), c = n.get(l) ?? 0;
2320
- return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
2482
+ function jn(n, t, e) {
2483
+ const r = /* @__PURE__ */ new Map();
2484
+ return t.map((i, o) => {
2485
+ const s = _t(i), a = (n ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, h) => h === "index" ? String(o + 1) : h === "count" ? String(t.length) : s[h] ?? u), l = zn(a), c = r.get(l) ?? 0;
2486
+ return r.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
2321
2487
  });
2322
2488
  }
2323
- class Ke extends R {
2489
+ class er extends I {
2324
2490
  static observedAttributes = [...T["om-atlas"]];
2325
2491
  /**
2326
2492
  * Pages are SNAPSHOTTED when iteration first starts. A streaming or polling
@@ -2332,7 +2498,7 @@ class Ke extends R {
2332
2498
  rejection = null;
2333
2499
  /** The frame whose layer drives the iteration — the same `for=` rule every furniture element follows. */
2334
2500
  get frame() {
2335
- return _(this);
2501
+ return O(this);
2336
2502
  }
2337
2503
  get count() {
2338
2504
  return this.ensurePages().length;
@@ -2349,17 +2515,17 @@ class Ke extends R {
2349
2515
  }
2350
2516
  /** Export filenames, one per page, already de-duplicated. */
2351
2517
  filenames(t = "png") {
2352
- return Nn(this.getAttribute("filename"), this.ensurePages(), t);
2518
+ return jn(this.getAttribute("filename"), this.ensurePages(), t);
2353
2519
  }
2354
2520
  /** Human page labels, for an editor's stepper and PDF bookmarks. */
2355
2521
  pageName(t) {
2356
2522
  const e = this.ensurePages()[t];
2357
2523
  if (!e) return `Page ${t + 1}`;
2358
- const n = Ft(e), i = this.getAttribute("page-name");
2524
+ const r = _t(e), i = this.getAttribute("page-name");
2359
2525
  return i ? i.replace(
2360
2526
  /\{\{\s*atlas\.([\w]+)\s*\}\}/g,
2361
- (s, o) => o === "index" ? String(t + 1) : o === "count" ? String(this.count) : n[o] ?? s
2362
- ) : n.name ?? n.title ?? `Page ${t + 1}`;
2527
+ (o, s) => s === "index" ? String(t + 1) : s === "count" ? String(this.count) : r[s] ?? o
2528
+ ) : r.name ?? r.title ?? `Page ${t + 1}`;
2363
2529
  }
2364
2530
  /**
2365
2531
  * Recompute the page list from the layer as it stands now, and apply the
@@ -2373,11 +2539,11 @@ class Ke extends R {
2373
2539
  }
2374
2540
  ensurePages() {
2375
2541
  if (this.pages) return this.pages;
2376
- const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? Mn(i) : null;
2377
- if (!e || s)
2378
- return this.rejection = e ? s : null, this.pages = [];
2379
- const o = this.materialize(i);
2380
- return this.pages = Cn({ features: o, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
2542
+ const e = this.frame?.mapElement?.getLayers?.(), r = this.getAttribute("layer"), i = e?.find((a) => a.id === r), o = e ? Fn(i) : null;
2543
+ if (!e || o)
2544
+ return this.rejection = e ? o : null, this.pages = [];
2545
+ const s = this.materialize(i);
2546
+ return this.pages = _n({ features: s, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
2381
2547
  }
2382
2548
  /**
2383
2549
  * Rows from the layer, with the layer's OWN declarative filters applied —
@@ -2385,13 +2551,13 @@ class Ke extends R {
2385
2551
  * sheets for features the map itself is hiding.
2386
2552
  */
2387
2553
  materialize(t) {
2388
- const e = H(), n = t.data;
2389
- if (!n) return [];
2390
- const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [], s = [t.filter, t.categoryFilter].filter(Boolean);
2391
- return s.length === 0 ? i : i.filter(
2392
- (o) => s.every((a) => {
2554
+ const e = H(), r = t.data;
2555
+ if (!r) return [];
2556
+ const i = e?.asRows ? e.asRows(r) : Array.isArray(r) ? r : [], o = [t.filter, t.categoryFilter].filter(Boolean);
2557
+ return o.length === 0 ? i : i.filter(
2558
+ (s) => o.every((a) => {
2393
2559
  if (!a.field) return !0;
2394
- const l = I(o, a.field);
2560
+ const l = R(s, a.field);
2395
2561
  if (a.range) {
2396
2562
  const c = Number(l);
2397
2563
  return Number.isFinite(c) && c >= a.range[0] && c <= a.range[1];
@@ -2407,10 +2573,10 @@ class Ke extends R {
2407
2573
  const e = H();
2408
2574
  if (e?.compileExpression)
2409
2575
  try {
2410
- const n = e.compileExpression(t, { shape: "geojson", paramName: "d" });
2411
- return (i) => !!n.fn(i);
2412
- } catch (n) {
2413
- console.warn(`[onlymapjs/cartograph] <om-atlas filter="${t}"> did not compile: ${n.message}`);
2576
+ const r = e.compileExpression(t, { shape: "geojson", paramName: "d" });
2577
+ return (i) => !!r.fn(i);
2578
+ } catch (r) {
2579
+ console.warn(`[onlymapjs/cartograph] <om-atlas filter="${t}"> did not compile: ${r.message}`);
2414
2580
  return;
2415
2581
  }
2416
2582
  }
@@ -2426,14 +2592,14 @@ class Ke extends R {
2426
2592
  const t = this.current;
2427
2593
  if (!t) return;
2428
2594
  const e = this.closest("om-cartograph");
2429
- for (const n of e?.querySelectorAll("om-frame") ?? []) {
2430
- if (n.getAttribute("atlas-fit") !== "feature") continue;
2431
- const i = An(t);
2595
+ for (const r of e?.querySelectorAll("om-frame") ?? []) {
2596
+ if (r.getAttribute("atlas-fit") !== "feature") continue;
2597
+ const i = Rn(t);
2432
2598
  if (!i) continue;
2433
- const s = Number(n.getAttribute("atlas-margin")), o = Sn(i, Number.isFinite(s) && s > 0 ? s : 0.15);
2434
- n.fitBounds?.(o);
2599
+ const o = Number(r.getAttribute("atlas-margin")), s = In(i, Number.isFinite(o) && o > 0 ? o : 0.15);
2600
+ r.fitBounds?.(s);
2435
2601
  }
2436
- e?.setAtlasFields({ ...Ft(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2602
+ e?.setAtlasFields({ ..._t(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2437
2603
  new CustomEvent("om-atlas-page", {
2438
2604
  bubbles: !0,
2439
2605
  detail: { index: this.currentIndex, count: this.count, name: this.pageName(this.currentIndex), feature: t }
@@ -2444,72 +2610,72 @@ class Ke extends R {
2444
2610
  this.style.display = "none", this.refresh();
2445
2611
  }
2446
2612
  }
2447
- x("om-atlas", Ke);
2448
- const Pn = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), Tn = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), Ln = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], Fn = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), In = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), Rn = 0.02, On = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
2449
- function Ye(r) {
2450
- const t = r.tagName.toLowerCase();
2451
- return r.id ? `${t}#${r.id}` : t;
2613
+ x("om-atlas", er);
2614
+ const Gn = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), qn = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), Wn = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], Bn = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), Vn = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), Kn = 0.02, Hn = (n) => Math.max(0, Number(n.getAttribute("bleed")) || 0);
2615
+ function rr(n) {
2616
+ const t = n.tagName.toLowerCase();
2617
+ return n.id ? `${t}#${n.id}` : t;
2452
2618
  }
2453
- function V(r, t) {
2454
- const e = r.getAttribute(t);
2619
+ function V(n, t) {
2620
+ const e = n.getAttribute(t);
2455
2621
  if (e == null || e.trim() === "") return null;
2456
- const n = Number(e);
2457
- return Number.isFinite(n) ? n : null;
2622
+ const r = Number(e);
2623
+ return Number.isFinite(r) ? r : null;
2458
2624
  }
2459
- function _n(r, t) {
2460
- return r.x < t.x + t.w && t.x < r.x + r.w && r.y < t.y + t.h && t.y < r.y + r.h;
2625
+ function Yn(n, t) {
2626
+ return n.x < t.x + t.w && t.x < n.x + n.w && n.y < t.y + t.h && t.y < n.y + n.h;
2461
2627
  }
2462
- function Un(r, t) {
2463
- const e = r.getAttribute("style");
2628
+ function Xn(n, t) {
2629
+ const e = n.getAttribute("style");
2464
2630
  if (!e) return null;
2465
- const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
2466
- return n ? Number(n[1]) : null;
2467
- }
2468
- function Xe(r) {
2469
- const t = [], e = (o, a, l, c, u) => {
2470
- t.push({ severity: o, element: Ye(a), ...u ? { attribute: u } : {}, message: l, fix: c });
2471
- }, n = [...r.querySelectorAll("om-cartograph")];
2472
- if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
2631
+ const r = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
2632
+ return r ? Number(r[1]) : null;
2633
+ }
2634
+ function nr(n) {
2635
+ const t = [], e = (s, a, l, c, u) => {
2636
+ t.push({ severity: s, element: rr(a), ...u ? { attribute: u } : {}, message: l, fix: c });
2637
+ }, r = [...n.querySelectorAll("om-cartograph")];
2638
+ if (r.length === 0 && n.tagName?.toLowerCase() === "om-cartograph" && r.push(n), r.length === 0)
2473
2639
  return { valid: !0, errors: [], warnings: [] };
2474
- for (const o of n) zn(o, e);
2475
- const i = t.filter((o) => o.severity === "error"), s = t.filter((o) => o.severity === "warning");
2476
- return { valid: i.length === 0, errors: i, warnings: s };
2640
+ for (const s of r) Jn(s, e);
2641
+ const i = t.filter((s) => s.severity === "error"), o = t.filter((s) => s.severity === "warning");
2642
+ return { valid: i.length === 0, errors: i, warnings: o };
2477
2643
  }
2478
- function zn(r, t) {
2479
- const e = r.getAttribute("size"), n = V(r, "width") != null && V(r, "height") != null;
2480
- e && !Ht.includes(e) && !n && t(
2644
+ function Jn(n, t) {
2645
+ const e = n.getAttribute("size"), r = V(n, "width") != null && V(n, "height") != null;
2646
+ e && !Zt.includes(e) && !r && t(
2481
2647
  "error",
2482
- r,
2648
+ n,
2483
2649
  `Unknown page size "${e}" and no width/height to fall back on.`,
2484
- `Use one of ${Ht.join(", ")}, or give width= and height= in millimetres.`,
2650
+ `Use one of ${Zt.join(", ")}, or give width= and height= in millimetres.`,
2485
2651
  "size"
2486
2652
  );
2487
- const i = r.getAttribute("cvd");
2488
- i && i.trim().toLowerCase() !== "none" && !It(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${nr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && On(r) <= 0 && t("warning", r, "crop-marks needs bleed to draw into — trim marks sit outside the page box.", 'Add bleed="3" (mm), or drop crop-marks.', "crop-marks");
2489
- const s = V(r, "safe-zone");
2490
- if (s != null && s > 0) {
2491
- const m = ut(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
2492
- s * 2 >= Math.min(m.widthMm, m.heightMm) && t("warning", r, `safe-zone=${s}mm leaves no usable area on a ${m.widthMm} × ${m.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
2493
- }
2494
- const o = r.getAttribute("format");
2495
- o == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${pt}" so future runtimes can migrate this document.`, "format") : o !== pt && t("warning", r, `Unrecognised document format "${o}".`, `This build understands "${pt}".`, "format");
2496
- const { widthMm: a, heightMm: l } = ut(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, V(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), h = [...r.querySelectorAll("om-frame")];
2653
+ const i = n.getAttribute("cvd");
2654
+ i && i.trim().toLowerCase() !== "none" && !Ot(i) && t("warning", n, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${ur.join(", ")}.`, "cvd"), n.hasAttribute("crop-marks") && Hn(n) <= 0 && t("warning", n, "crop-marks needs bleed to draw into — trim marks sit outside the page box.", 'Add bleed="3" (mm), or drop crop-marks.', "crop-marks");
2655
+ const o = V(n, "safe-zone");
2656
+ if (o != null && o > 0) {
2657
+ const m = ut(n.getAttribute("size"), n.getAttribute("width"), n.getAttribute("height"), n.getAttribute("orientation"));
2658
+ o * 2 >= Math.min(m.widthMm, m.heightMm) && t("warning", n, `safe-zone=${o}mm leaves no usable area on a ${m.widthMm} × ${m.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
2659
+ }
2660
+ const s = n.getAttribute("format");
2661
+ s == null ? t("warning", n, "No format= on the cartograph root.", `Add format="${gt}" so future runtimes can migrate this document.`, "format") : s !== gt && t("warning", n, `Unrecognised document format "${s}".`, `This build understands "${gt}".`, "format");
2662
+ const { widthMm: a, heightMm: l } = ut(e, n.getAttribute("width"), n.getAttribute("height"), n.getAttribute("orientation")), c = Math.max(0, V(n, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), h = [...n.querySelectorAll("om-frame")];
2497
2663
  for (const m of h)
2498
2664
  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");
2499
- for (const m of r.children) {
2500
- if (Ln.some((g) => m.hasAttribute(g))) continue;
2665
+ for (const m of n.children) {
2666
+ if (Wn.some((g) => m.hasAttribute(g))) continue;
2501
2667
  const f = m.tagName.toLowerCase();
2502
- !bt.includes(f) && !Tn.has(f) && t("error", m, `<${f}> is not a cartograph element.`, `Use one of ${bt.join(", ")}, or move this content inside an <om-text>.`);
2668
+ !pt.includes(f) && !qn.has(f) && t("error", m, `<${f}> is not a cartograph element.`, `Use one of ${pt.join(", ")}, or move this content inside an <om-text>.`);
2503
2669
  }
2504
2670
  const d = [];
2505
- for (const m of [r, ...r.querySelectorAll("*")]) {
2671
+ for (const m of [n, ...n.querySelectorAll("*")]) {
2506
2672
  const f = m.tagName.toLowerCase();
2507
- if (bt.includes(f) && !m.closest("om-map")) {
2508
- if (Dn(m, f, t), In.has(f)) {
2673
+ if (pt.includes(f) && !m.closest("om-map")) {
2674
+ if (Zn(m, f, t), Vn.has(f)) {
2509
2675
  const g = C(m);
2510
- jn(m, g, a, l, c, t), Fn.has(f) && !m.hasAttribute("hidden") && d.push({ el: m, box: g });
2676
+ Qn(m, g, a, l, c, t), Bn.has(f) && !m.hasAttribute("hidden") && d.push({ el: m, box: g });
2511
2677
  }
2512
- f === "om-frame" && Gn(m, t), f === "om-legend" && qn(m, h, t), f === "om-atlas" && Wn(m, h, t), f === "om-scalebar" && Bn(m, h, t), f === "om-text" && Vn(m, h, t);
2678
+ f === "om-frame" && ti(m, t), f === "om-legend" && ei(m, h, t), f === "om-atlas" && ri(m, h, t), f === "om-scalebar" && ni(m, h, t), f === "om-text" && ii(m, h, t);
2513
2679
  for (const g of ["for", "overview-of"]) {
2514
2680
  const p = m.getAttribute(g);
2515
2681
  p && !u.has(p) && t("error", m, `${g}="${p}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, g);
@@ -2519,37 +2685,37 @@ function zn(r, t) {
2519
2685
  for (let m = 0; m < d.length; m++)
2520
2686
  for (let f = m + 1; f < d.length; f++) {
2521
2687
  const g = d[m], p = d[f];
2522
- g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || _n(g.box, p.box) && t(
2688
+ g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || Yn(g.box, p.box) && t(
2523
2689
  "warning",
2524
2690
  g.el,
2525
- `Overlaps ${Ye(p.el)} on the page.`,
2691
+ `Overlaps ${rr(p.el)} on the page.`,
2526
2692
  "Move one of them — furniture overlapping furniture usually means a stale layout (frames may sit under anything)."
2527
2693
  );
2528
2694
  }
2529
2695
  }
2530
- function Dn(r, t, e) {
2531
- const n = new Set(T[t] ?? []);
2532
- for (const i of r.attributes) {
2533
- const s = i.name.toLowerCase();
2534
- if (n.has(s) || Pn.has(s) || s.startsWith("data-") || s.startsWith("aria-")) continue;
2535
- const o = br.get(s);
2536
- if (o) {
2537
- e("warning", r, `Attribute "${s}" has no effect: ${o}`, "Remove it, or use the documented alternative.", s);
2696
+ function Zn(n, t, e) {
2697
+ const r = new Set(T[t] ?? []);
2698
+ for (const i of n.attributes) {
2699
+ const o = i.name.toLowerCase();
2700
+ if (r.has(o) || Gn.has(o) || o.startsWith("data-") || o.startsWith("aria-")) continue;
2701
+ const s = Cr.get(o);
2702
+ if (s) {
2703
+ e("warning", n, `Attribute "${o}" has no effect: ${s}`, "Remove it, or use the documented alternative.", o);
2538
2704
  continue;
2539
2705
  }
2540
- e("warning", r, `Unknown attribute "${s}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, s);
2706
+ e("warning", n, `Unknown attribute "${o}" on <${t}> — likely a typo.`, `Valid attributes: ${[...r].join(", ")}.`, o);
2541
2707
  }
2542
2708
  }
2543
- function jn(r, t, e, n, i, s) {
2709
+ function Qn(n, t, e, r, i, o) {
2544
2710
  if (t.w <= 0 || t.h <= 0) {
2545
- s("error", r, `Element has no size (w=${t.w}, h=${t.h}).`, "Give w= and h= in millimetres — both greater than zero.", t.w <= 0 ? "w" : "h");
2711
+ o("error", n, `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");
2546
2712
  return;
2547
2713
  }
2548
- const o = -i, a = e + i, l = n + i;
2549
- (t.x < o || t.y < o || t.x + t.w > a + 1e-6 || t.y + t.h > l + 1e-6) && s(
2714
+ const s = -i, a = e + i, l = r + i;
2715
+ (t.x < s || t.y < s || t.x + t.w > a + 1e-6 || t.y + t.h > l + 1e-6) && o(
2550
2716
  "error",
2551
- r,
2552
- `Element box (${t.x}, ${t.y}, ${t.w} × ${t.h} mm) falls outside the ${e} × ${n} mm page${i ? ` (+${i}mm bleed)` : ""}.`,
2717
+ n,
2718
+ `Element box (${t.x}, ${t.y}, ${t.w} × ${t.h} mm) falls outside the ${e} × ${r} mm page${i ? ` (+${i}mm bleed)` : ""}.`,
2553
2719
  "Move or resize it so the whole box sits on the sheet."
2554
2720
  );
2555
2721
  const c = [
@@ -2559,285 +2725,288 @@ function jn(r, t, e, n, i, s) {
2559
2725
  ["height", t.h]
2560
2726
  ];
2561
2727
  for (const [u, h] of c) {
2562
- const d = Un(r, u);
2563
- d != null && Math.abs(d - h) > 0.01 && s(
2728
+ const d = Xn(n, u);
2729
+ d != null && Math.abs(d - h) > 0.01 && o(
2564
2730
  "error",
2565
- r,
2731
+ n,
2566
2732
  `Inline style ${u}:${d}mm disagrees with the placement attribute (${h}mm).`,
2567
2733
  "The attributes are authoritative — make the inline style match, or drop it and let the runtime write it.",
2568
2734
  "style"
2569
2735
  );
2570
2736
  }
2571
2737
  }
2572
- function Gn(r, t) {
2573
- if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
2574
- const n = r.getAttribute("corners"), i = dt(n);
2738
+ function ti(n, t) {
2739
+ if ((n.getAttribute("mode") === "static" ? "static" : "live") === "static") {
2740
+ const r = n.getAttribute("corners"), i = ht(r);
2575
2741
  i || t(
2576
2742
  "error",
2577
- r,
2578
- n == null ? "Static frame has no corners=." : `Static frame has malformed corners= ("${n}").`,
2743
+ n,
2744
+ r == null ? "Static frame has no corners=." : `Static frame has malformed corners= ("${r}").`,
2579
2745
  'Give four lon/lat pairs in tl, tr, br, bl order — corners="[[lng,lat],[lng,lat],[lng,lat],[lng,lat]]".',
2580
2746
  "corners"
2581
- ), 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.");
2582
- const s = C(r), o = X(r.getAttribute("crs"));
2583
- if (i && o && s.w > 0 && s.h > 0) {
2584
- const a = mt({ corners: i, widthMm: s.w, heightMm: s.h, crsForward: o });
2747
+ ), !n.querySelector(":scope > img") && !n.querySelector(`:scope > svg[${kt}]`) && t(
2748
+ "error",
2749
+ n,
2750
+ "Static frame has no <img> or inline <svg> child to place.",
2751
+ 'Add the georeferenced picture as a child — an <img> raster, or the inline <svg> that snapshot({format: "svg"}) produces.'
2752
+ );
2753
+ const o = C(n), s = K(n.getAttribute("crs"));
2754
+ if (i && s && o.w > 0 && o.h > 0) {
2755
+ const a = Z({ corners: i, widthMm: o.w, heightMm: o.h, crsForward: s });
2585
2756
  if (a.degenerate)
2586
- t("error", r, "Frame corners are degenerate (collinear or coincident) — nothing can be placed on this frame.", "Check the corner order: tl, tr, br, bl.", "corners");
2757
+ t("error", n, "Frame corners are degenerate (collinear or coincident) — nothing can be placed on this frame.", "Check the corner order: tl, tr, br, bl.", "corners");
2587
2758
  else {
2588
- const l = Yr(a);
2589
- l != null && l > Rn && t(
2759
+ const l = an(a);
2760
+ l != null && l > Kn && t(
2590
2761
  "warning",
2591
- r,
2762
+ n,
2592
2763
  `Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
2593
2764
  "Shrink the frame's latitude span, or drop the scale bar in favour of a stated representative fraction."
2594
2765
  );
2595
2766
  }
2596
2767
  }
2597
2768
  } else {
2598
- ct(r) || t(
2769
+ ct(n) || t(
2599
2770
  "error",
2600
- r,
2771
+ n,
2601
2772
  "Live frame has no valid camera.",
2602
2773
  'Give it center="[lng,lat]" and an explicit numeric zoom= (zoom 0 is valid).',
2603
- r.hasAttribute("center") ? "zoom" : "center"
2604
- ), !r.getAttribute("src") && !r.querySelector(":scope > om-map") && t("error", r, "Live frame has no map source.", "Give it src= or add an inline <om-map> child.", "src");
2605
- for (const i of ["crs", "corners"])
2606
- r.hasAttribute(i) && t(
2774
+ n.hasAttribute("center") ? "zoom" : "center"
2775
+ ), !n.getAttribute("src") && !n.querySelector(":scope > om-map") && t("error", n, "Live frame has no map source.", "Give it src= or add an inline <om-map> child.", "src");
2776
+ for (const r of ["crs", "corners"])
2777
+ n.hasAttribute(r) && t(
2607
2778
  "warning",
2608
- r,
2609
- `${i}= is ignored on a live frame — live frames are always EPSG:3857 and derive their corners from the camera.`,
2610
- 'Remove it, or set mode="static" if this frame is a georeferenced raster.',
2611
- i
2779
+ n,
2780
+ `${r}= is ignored on a live frame — a live frame takes its projection from the <om-map> it mounts and its corners from that map's camera.`,
2781
+ r === "crs" ? `Put crs= on the frame's <om-map> instead, or set mode="static" for a georeferenced picture placed by corners.` : 'Remove it, or set mode="static" if this frame is a georeferenced picture.',
2782
+ r
2612
2783
  );
2613
- const n = Y(r.getAttribute("crs"));
2614
- n && n !== "EPSG:3857" && t("error", r, `Live frame declares ${n}, but live frames render EPSG:3857.`, 'Use mode="static" with a georeferenced raster for other projections.', "crs");
2615
2784
  }
2616
2785
  }
2617
- function _t(r, t) {
2618
- const e = r.getAttribute("for");
2619
- return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
2786
+ function Gt(n, t) {
2787
+ const e = n.getAttribute("for");
2788
+ return e ? t.find((r) => r.id === e) : t.length === 1 ? t[0] : void 0;
2620
2789
  }
2621
- function qn(r, t, e) {
2622
- const n = r.getAttribute("derived") !== "false", i = _t(r, t);
2623
- n && i?.getAttribute("mode") === "static" && e(
2790
+ function ei(n, t, e) {
2791
+ const r = n.getAttribute("derived") !== "false", i = Gt(n, t);
2792
+ r && i?.getAttribute("mode") === "static" && e(
2624
2793
  "warning",
2625
- r,
2794
+ n,
2626
2795
  "This legend derives from a static frame, which has no layers to derive from.",
2627
2796
  'Write the rows as <om-legend-row color= label= shape=> children and set derived="false".',
2628
2797
  "derived"
2629
2798
  );
2630
- const s = Be(r);
2631
- if (s.length < 2) return;
2632
- const o = sr(s.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
2633
- if (o.collapses.length > 0 && o.worstType) {
2634
- const a = o.collapses.filter((c) => c.type === o.worstType), l = a.slice(0, 3).map((c) => `"${c.a.label}"/"${c.b.label}"`).join(", ");
2799
+ const o = Ze(n);
2800
+ if (o.length < 2) return;
2801
+ const s = dr(o.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
2802
+ if (s.collapses.length > 0 && s.worstType) {
2803
+ const a = s.collapses.filter((c) => c.type === s.worstType), l = a.slice(0, 3).map((c) => `"${c.a.label}"/"${c.b.label}"`).join(", ");
2635
2804
  e(
2636
2805
  "warning",
2637
- r,
2638
- `Under ${o.worstType}, ${a.length === 1 ? "one legend pair becomes" : `${a.length} legend pairs become`} indistinguishable: ${l}.`,
2806
+ n,
2807
+ `Under ${s.worstType}, ${a.length === 1 ? "one legend pair becomes" : `${a.length} legend pairs become`} indistinguishable: ${l}.`,
2639
2808
  "Pick colours that differ in lightness as well as hue, or add a pattern or label to separate them."
2640
2809
  );
2641
2810
  }
2642
2811
  }
2643
- function Wn(r, t, e) {
2644
- const n = r.getAttribute("layer");
2645
- n || e("error", r, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
2646
- const i = r.getAttribute("for"), s = _t(r, t);
2647
- if (!s) {
2648
- !i && t.length !== 1 && e("error", r, `Atlas does not say which frame drives it, and the page has ${t.length} frames.`, 'Add for="<frame id>".', "for");
2812
+ function ri(n, t, e) {
2813
+ const r = n.getAttribute("layer");
2814
+ r || e("error", n, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
2815
+ const i = n.getAttribute("for"), o = Gt(n, t);
2816
+ if (!o) {
2817
+ !i && t.length !== 1 && e("error", n, `Atlas does not say which frame drives it, and the page has ${t.length} frames.`, 'Add for="<frame id>".', "for");
2649
2818
  return;
2650
2819
  }
2651
- if (s.getAttribute("mode") === "static") {
2820
+ if (o.getAttribute("mode") === "static") {
2652
2821
  e(
2653
2822
  "error",
2654
- r,
2823
+ n,
2655
2824
  "An atlas cannot iterate a static frame — a raster has no features.",
2656
2825
  "Point the atlas at a live frame whose map carries the layer.",
2657
2826
  "for"
2658
2827
  );
2659
2828
  return;
2660
2829
  }
2661
- const o = s.querySelector(":scope > om-map");
2662
- if (o && n) {
2663
- const a = [...o.querySelectorAll("om-layer")].find((c) => c.id === n);
2830
+ const s = o.querySelector(":scope > om-map");
2831
+ if (s && r) {
2832
+ const a = [...s.querySelectorAll("om-layer")].find((c) => c.id === r);
2664
2833
  if (!a) {
2665
- e("error", r, `Atlas layer "${n}" is not in frame #${s.id}'s map.`, "Check the layer id, or point the atlas at the frame that has it.", "layer");
2834
+ e("error", n, `Atlas layer "${r}" is not in frame #${o.id}'s map.`, "Check the layer id, or point the atlas at the frame that has it.", "layer");
2666
2835
  return;
2667
2836
  }
2668
2837
  const l = a.getAttribute("data") ?? "";
2669
2838
  /\{z\}|\{x\}|\{y\}/.test(l) && e(
2670
2839
  "error",
2671
- r,
2672
- `Atlas layer "${n}" is tiled, so its features live on a server rather than in this document.`,
2840
+ n,
2841
+ `Atlas layer "${r}" is tiled, so its features live on a server rather than in this document.`,
2673
2842
  "Iterate a layer whose data is loaded locally (GeoJSON, CSV, inline JSON).",
2674
2843
  "layer"
2675
2844
  );
2676
2845
  }
2677
2846
  }
2678
- function Bn(r, t, e) {
2679
- const n = V(r, "segment-length");
2680
- if (n == null) return;
2681
- const i = _t(r, t);
2847
+ function ni(n, t, e) {
2848
+ const r = V(n, "segment-length");
2849
+ if (r == null) return;
2850
+ const i = Gt(n, t);
2682
2851
  if (!i) return;
2683
- const s = dt(i.getAttribute("corners")), o = X(i.getAttribute("crs")), a = C(i);
2684
- if (!s || !o || a.w <= 0 || a.h <= 0) return;
2685
- const l = mt({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = C(r), u = $e({
2852
+ const o = ht(i.getAttribute("corners")), s = K(i.getAttribute("crs")), a = C(i);
2853
+ if (!o || !s || a.w <= 0 || a.h <= 0) return;
2854
+ const l = Z({ corners: o, widthMm: a.w, heightMm: a.h, crsForward: s }), c = C(n), u = Ie({
2686
2855
  groundMetersPerMm: l.groundMetersPerMm(),
2687
2856
  maxWidthMm: c.w,
2688
- segments: V(r, "segments") ?? void 0,
2689
- segmentLengthMeters: n
2857
+ segments: V(n, "segments") ?? void 0,
2858
+ segmentLengthMeters: r
2690
2859
  });
2691
2860
  u && u.totalMm > c.w + 1e-6 && e(
2692
2861
  "warning",
2693
- r,
2694
- `segment-length=${n}m makes the bar ${u.totalMm.toFixed(1)}mm wide, wider than its ${c.w}mm box.`,
2862
+ n,
2863
+ `segment-length=${r}m makes the bar ${u.totalMm.toFixed(1)}mm wide, wider than its ${c.w}mm box.`,
2695
2864
  "Widen the bar's box, use fewer segments, or drop segment-length and let it snap to a 1-2-5 length that fits.",
2696
2865
  "segment-length"
2697
2866
  );
2698
2867
  }
2699
- function Vn(r, t, e) {
2700
- const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), s = new Set(t.map((o) => o.id).filter(Boolean));
2701
- for (const o of $r(n))
2702
- if (!o.startsWith("atlas.")) {
2703
- if (o.startsWith("frame.")) {
2704
- const a = o.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
2705
- s.has(c) ? u !== "scale" && u !== "crs" && e("warning", r, `{{${o}}} — frames provide scale and crs.`, `Use {{frame.${c}.scale}} or {{frame.${c}.crs}}.`) : e("warning", r, `{{${o}}} references no frame with id "${c}".`, `Frames on this page: ${[...s].join(", ") || "(none)"}.`);
2868
+ function ii(n, t, e) {
2869
+ const r = n.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), o = new Set(t.map((s) => s.id).filter(Boolean));
2870
+ for (const s of Rr(r))
2871
+ if (!s.startsWith("atlas.")) {
2872
+ if (s.startsWith("frame.")) {
2873
+ const a = s.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
2874
+ o.has(c) ? u !== "scale" && u !== "crs" && e("warning", n, `{{${s}}} — frames provide scale and crs.`, `Use {{frame.${c}.scale}} or {{frame.${c}.crs}}.`) : e("warning", n, `{{${s}}} references no frame with id "${c}".`, `Frames on this page: ${[...o].join(", ") || "(none)"}.`);
2706
2875
  continue;
2707
2876
  }
2708
- if ((o === "scale" || o === "crs") && t.length !== 1) {
2877
+ if ((s === "scale" || s === "crs") && t.length !== 1) {
2709
2878
  e(
2710
2879
  "warning",
2711
- r,
2712
- `{{${o}}} is ambiguous with ${t.length} frames on the page.`,
2713
- `Name the frame: {{frame.<id>.${o}}}.`
2880
+ n,
2881
+ `{{${s}}} is ambiguous with ${t.length} frames on the page.`,
2882
+ `Name the frame: {{frame.<id>.${s}}}.`
2714
2883
  );
2715
2884
  continue;
2716
2885
  }
2717
- i.has(o) || e("warning", r, `Unknown token {{${o}}} — it will render literally.`, `Known tokens: ${[...i].join(", ")}, frame.<id>.scale, frame.<id>.crs, atlas.<field>.`);
2886
+ i.has(s) || e("warning", n, `Unknown token {{${s}}} — it will render literally.`, `Known tokens: ${[...i].join(", ")}, frame.<id>.scale, frame.<id>.crs, atlas.<field>.`);
2718
2887
  }
2719
2888
  }
2720
- function Zn(r) {
2721
- return Xe(pr(r));
2889
+ function di(n) {
2890
+ return nr(Sr(n));
2722
2891
  }
2723
- async function Qn(r) {
2724
- const t = Xe(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
2892
+ async function fi(n) {
2893
+ const t = nr(n), e = [...n.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
2725
2894
  if (e.length === 0) return t;
2726
- const { loadCore: n } = await Promise.resolve().then(() => Qe), i = await n(), s = [...t.errors], o = [...t.warnings];
2895
+ const { loadCore: r } = await Promise.resolve().then(() => or), i = await r(), o = [...t.errors], s = [...t.warnings];
2727
2896
  for (const a of e) {
2728
2897
  const l = a.id ? `om-frame#${a.id}` : "om-frame", c = i.validateManifest(a);
2729
- for (const u of c.errors) s.push({ ...u, element: `${l} > ${u.element}` });
2730
- for (const u of c.warnings) o.push({ ...u, element: `${l} > ${u.element}` });
2898
+ for (const u of c.errors) o.push({ ...u, element: `${l} > ${u.element}` });
2899
+ for (const u of c.warnings) s.push({ ...u, element: `${l} > ${u.element}` });
2731
2900
  }
2732
- return { valid: s.length === 0, errors: s, warnings: o };
2901
+ return { valid: o.length === 0, errors: o, warnings: s };
2733
2902
  }
2734
- function ti() {
2735
- x("om-cartograph", Ie), x("om-text", Re), x("om-frame", De), x("om-scalebar", je), x("om-north", Ge), x("om-shape", qe), x("om-image", We), x("om-legend", Ve), x("om-graticule", He), x("om-atlas", Ke);
2903
+ function gi() {
2904
+ x("om-cartograph", Ge), x("om-text", qe), x("om-frame", Ke), x("om-scalebar", He), x("om-north", Ye), x("om-shape", Xe), x("om-image", Je), x("om-legend", Qe), x("om-graticule", tr), x("om-atlas", er);
2736
2905
  }
2737
- ye(() => import("@nika-js/onlymap"));
2738
- fr();
2906
+ $e(() => import("@nika-js/onlymap"));
2907
+ Mr();
2739
2908
  export {
2740
2909
  T as CARTOGRAPH_ELEMENT_ATTRS,
2741
- pt as CARTOGRAPH_FORMAT,
2742
- bt as CARTOGRAPH_TAG_NAMES,
2743
- Hn as CARTOGRAPH_THEMES,
2744
- or as COLLAPSE_THRESHOLD,
2745
- Rt as CVD_MATRICES,
2746
- ft as CVD_TYPES,
2747
- nr as CVD_VALUES,
2748
- Tt as GEOGRAPHIC_PLANE,
2749
- br as INERT_RESERVED_CARTOGRAPH_ATTRS,
2750
- Se as MAX_CANVAS_AREA,
2751
- Ae as MAX_CANVAS_DIMENSION,
2752
- xt as MAX_CATEGORY_ENTRIES,
2753
- Ke as OmAtlasElement,
2754
- Ie as OmCartographElement,
2755
- De as OmFrameElement,
2756
- He as OmGraticuleElement,
2757
- We as OmImageElement,
2758
- Ve as OmLegendElement,
2759
- Ge as OmNorthElement,
2760
- je as OmScalebarElement,
2761
- qe as OmShapeElement,
2762
- Re as OmTextElement,
2763
- zt as PAGE_PRESETS,
2764
- Ht as PAGE_SIZE_NAMES,
2910
+ gt as CARTOGRAPH_FORMAT,
2911
+ pt as CARTOGRAPH_TAG_NAMES,
2912
+ si as CARTOGRAPH_THEMES,
2913
+ mr as COLLAPSE_THRESHOLD,
2914
+ Ut as CVD_MATRICES,
2915
+ mt as CVD_TYPES,
2916
+ ur as CVD_VALUES,
2917
+ Rt as GEOGRAPHIC_PLANE,
2918
+ Cr as INERT_RESERVED_CARTOGRAPH_ATTRS,
2919
+ Te as MAX_CANVAS_AREA,
2920
+ Pe as MAX_CANVAS_DIMENSION,
2921
+ Ct as MAX_CATEGORY_ENTRIES,
2922
+ er as OmAtlasElement,
2923
+ Ge as OmCartographElement,
2924
+ Ke as OmFrameElement,
2925
+ tr as OmGraticuleElement,
2926
+ Je as OmImageElement,
2927
+ Qe as OmLegendElement,
2928
+ Ye as OmNorthElement,
2929
+ He as OmScalebarElement,
2930
+ Xe as OmShapeElement,
2931
+ qe as OmTextElement,
2932
+ Wt as PAGE_PRESETS,
2933
+ Zt as PAGE_SIZE_NAMES,
2765
2934
  z as PLACED_ATTR_NAMES,
2766
- W as PX_PER_MM,
2767
- Cr as SCALE_GROUP_SEPARATOR,
2768
- mr as URL_ACTION_TIMEOUT_MS,
2769
- Rr as alignOffset,
2770
- Le as allFrames,
2771
- ar as applyCvdToCanvas,
2772
- Er as applyTokens,
2773
- dr as applyUrlActions,
2774
- Ft as atlasFields,
2775
- Jn as boundsArea,
2935
+ D as PX_PER_MM,
2936
+ Tr as SCALE_GROUP_SEPARATOR,
2937
+ wr as URL_ACTION_TIMEOUT_MS,
2938
+ Gr as alignOffset,
2939
+ ze as allFrames,
2940
+ fr as applyCvdToCanvas,
2941
+ Ir as applyTokens,
2942
+ vr as applyUrlActions,
2943
+ _t as atlasFields,
2944
+ mi as boundsArea,
2776
2945
  C as boxMm,
2777
- fn as buildGraticule,
2778
- Cn as buildPages,
2779
- $e as buildScalebar,
2780
- Sr as buildScalebarDrawing,
2781
- X as builtinCrsForward,
2782
- Kn as canvasMeasurer,
2783
- Tr as clearUnlinked,
2784
- Yn as cornersFromBounds,
2785
- Pt as cornersFromCamera,
2786
- mt as createFrameGeoref,
2787
- rr as createZip,
2788
- ti as defineCartographElements,
2789
- qt as deltaE00,
2790
- un as deriveLegendRows,
2791
- lr as ensureCvdFilters,
2792
- An as featureBounds,
2793
- I as fieldOf,
2794
- Te as findFrame,
2795
- bn as formatDms,
2796
- xr as formatScaleDenominator,
2797
- fr as installUrlActions,
2798
- Ze as isCoreLoaded,
2799
- Nr as isoDate,
2800
- Ir as layoutText,
2801
- sr as lintLegendColours,
2802
- we as loadCore,
2803
- Xn as maxGeoreferenceablePitch,
2804
- zr as mercatorForward,
2805
- Oe as mercatorInverse,
2806
- de as niceInterval,
2807
- ke as niceNumberBelow,
2808
- Y as normalizeCrs,
2809
- Kr as northBearingDegrees,
2810
- Pe as ownerCartograph,
2811
- Sn as padBounds,
2812
- Ut as paintEnvForDpi,
2813
- ir as parseColor,
2814
- dt as parseCorners,
2815
- kn as parseSort,
2946
+ $n as buildGraticule,
2947
+ _n as buildPages,
2948
+ Ie as buildScalebar,
2949
+ Pr as buildScalebarDrawing,
2950
+ K as builtinCrsForward,
2951
+ oi as canvasMeasurer,
2952
+ Ur as clearUnlinked,
2953
+ ui as cornersFromBounds,
2954
+ Ft as cornersFromCamera,
2955
+ Z as createFrameGeoref,
2956
+ cr as createZip,
2957
+ gi as defineCartographElements,
2958
+ Ht as deltaE00,
2959
+ An as deriveLegendRows,
2960
+ gr as ensureCvdFilters,
2961
+ Rn as featureBounds,
2962
+ R as fieldOf,
2963
+ De as findFrame,
2964
+ Nn as formatDms,
2965
+ Lr as formatScaleDenominator,
2966
+ Mr as installUrlActions,
2967
+ sr as isCoreLoaded,
2968
+ _r as isoDate,
2969
+ jr as layoutText,
2970
+ dr as lintLegendColours,
2971
+ ke as loadCore,
2972
+ hi as maxGeoreferenceablePitch,
2973
+ ai as mercatorForward,
2974
+ li as mercatorInverse,
2975
+ Me as niceInterval,
2976
+ Re as niceNumberBelow,
2977
+ Tt as normalizeCrs,
2978
+ on as northBearingDegrees,
2979
+ Ue as ownerCartograph,
2980
+ In as padBounds,
2981
+ qt as paintEnvForDpi,
2982
+ hr as parseColor,
2983
+ ht as parseCorners,
2984
+ Un as parseSort,
2816
2985
  H as peekCore,
2817
2986
  ct as readCamera,
2818
- Be as readLiteralRows,
2819
- dn as readOverrides,
2820
- _ as referencedFrame,
2821
- Mn as rejectionFor,
2822
- Ot as renderCartograph,
2823
- Ce as renderCartographAtlas,
2824
- Ue as resolveCrsForward,
2825
- It as resolveCvdType,
2826
- Nn as resolveFilenames,
2987
+ Ze as readLiteralRows,
2988
+ xn as readOverrides,
2989
+ O as referencedFrame,
2990
+ Fn as rejectionFor,
2991
+ Dt as renderCartograph,
2992
+ Le as renderCartographAtlas,
2993
+ Lt as resolveCrsForward,
2994
+ Ot as resolveCvdType,
2995
+ jn as resolveFilenames,
2827
2996
  ut as resolvePageSize,
2828
- kr as resolveToken,
2829
- Ne as resolveTokens,
2830
- cn as rowColorFor,
2831
- Jr as sanitizeAdoptedMap,
2832
- En as sanitizeFilename,
2833
- Yr as scaleVariation,
2834
- ye as setCoreLoader,
2835
- jt as simulate,
2836
- ln as swatchShapeFor,
2837
- $r as tokensIn,
2838
- oe as utmDef,
2839
- Xe as validateCartograph,
2840
- Qn as validateCartographDeep,
2841
- Zn as validateCartographString,
2842
- Vt as whenPageReady
2997
+ Fr as resolveToken,
2998
+ Oe as resolveTokens,
2999
+ Mn as rowColorFor,
3000
+ cn as sanitizeAdoptedMap,
3001
+ zn as sanitizeFilename,
3002
+ an as scaleVariation,
3003
+ $e as setCoreLoader,
3004
+ Vt as simulate,
3005
+ vn as swatchShapeFor,
3006
+ Rr as tokensIn,
3007
+ ci as utmDef,
3008
+ nr as validateCartograph,
3009
+ fi as validateCartographDeep,
3010
+ di as validateCartographString,
3011
+ Jt as whenPageReady
2843
3012
  };