bravais 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bravais.js CHANGED
@@ -1,15 +1,29 @@
1
- import { ACESFilmicToneMapping as e, AlwaysStencilFunc as t, AmbientLight as n, Box3 as r, BoxGeometry as i, BufferGeometry as a, CanvasTexture as o, Color as s, ConeGeometry as c, Controls as l, CylinderGeometry as u, DataTexture as d, DirectionalLight as f, DoubleSide as p, EqualStencilFunc as m, Float32BufferAttribute as h, FloatType as g, Fog as ee, Group as _, InstancedMesh as v, LineBasicMaterial as y, LineSegments as b, LinearFilter as x, LinearMipmapLinearFilter as te, MOUSE as S, MathUtils as ne, Matrix4 as C, Mesh as w, MeshStandardMaterial as T, NearestFilter as E, NotEqualStencilFunc as D, Object3D as O, OrthographicCamera as k, PlaneGeometry as re, Quaternion as A, RGBAFormat as ie, ReplaceStencilOp as ae, SRGBColorSpace as oe, Scene as se, SphereGeometry as ce, Sprite as le, SpriteMaterial as ue, Vector2 as j, Vector3 as M, WebGLRenderer as N } from "three";
2
- //#region src/cif/tokenizer.ts
3
- var P = class extends Error {
1
+ import { ACESFilmicToneMapping as e, AlwaysStencilFunc as t, AmbientLight as n, Box3 as r, BoxGeometry as i, BufferGeometry as a, CanvasTexture as o, Color as s, ConeGeometry as c, Controls as l, CylinderGeometry as u, DataTexture as d, DirectionalLight as f, DoubleSide as p, EqualStencilFunc as m, Float32BufferAttribute as h, FloatType as g, Fog as ee, Group as _, InstancedMesh as v, LineBasicMaterial as y, LineSegments as te, LinearFilter as ne, LinearMipmapLinearFilter as re, MOUSE as b, MathUtils as ie, Matrix4 as ae, Mesh as x, MeshStandardMaterial as S, NearestFilter as C, NotEqualStencilFunc as oe, Object3D as w, OrthographicCamera as T, PlaneGeometry as se, Quaternion as E, RGBAFormat as ce, ReplaceStencilOp as le, SRGBColorSpace as ue, Scene as de, SphereGeometry as fe, Sprite as pe, SpriteMaterial as me, Vector2 as D, Vector3 as O, WebGLRenderer as he } from "three";
2
+ //#region src/structure/errors.ts
3
+ var k = class extends Error {
4
+ constructor(e) {
5
+ super(e), this.name = "StructureError";
6
+ }
7
+ }, A = class extends k {
8
+ constructor(e) {
9
+ super(e), this.name = "StructureDataError";
10
+ }
11
+ }, j = class extends Error {
4
12
  line;
5
13
  constructor(e, t) {
6
14
  super(`CIF line ${t}: ${e}`), this.name = "CifSyntaxError", this.line = t;
7
15
  }
16
+ }, M = class extends k {
17
+ constructor(e) {
18
+ super(e), this.name = "CifStructureError";
19
+ }
8
20
  };
9
- function F(e) {
21
+ //#endregion
22
+ //#region src/cif/tokenizer.ts
23
+ function ge(e) {
10
24
  return e === " " || e === " " || e === "\r" || e === "\n";
11
25
  }
12
- function de(e, t) {
26
+ function _e(e, t) {
13
27
  let n = e.toLowerCase();
14
28
  return e.startsWith("_") ? {
15
29
  kind: "tag",
@@ -37,7 +51,7 @@ function de(e, t) {
37
51
  line: t
38
52
  };
39
53
  }
40
- function fe(e) {
54
+ function ve(e) {
41
55
  let t = [], n = e.split(/\r\n|\r|\n/), r = 0;
42
56
  for (; r < n.length;) {
43
57
  let e = n[r] ?? "", i = r + 1;
@@ -54,7 +68,7 @@ function fe(e) {
54
68
  }
55
69
  a.push(e), r += 1;
56
70
  }
57
- if (!o) throw new P("unterminated text field", i);
71
+ if (!o) throw new j("unterminated text field", i);
58
72
  t.push({
59
73
  kind: "value",
60
74
  text: a.join("\n"),
@@ -65,7 +79,7 @@ function fe(e) {
65
79
  let a = 0;
66
80
  for (; a < e.length;) {
67
81
  let n = e.charAt(a);
68
- if (F(n)) {
82
+ if (ge(n)) {
69
83
  a += 1;
70
84
  continue;
71
85
  }
@@ -74,15 +88,15 @@ function fe(e) {
74
88
  let r = a + 1;
75
89
  for (; r < e.length;) {
76
90
  let t = e.indexOf(n, r);
77
- if (t === -1) throw new P("unterminated quoted string", i);
91
+ if (t === -1) throw new j("unterminated quoted string", i);
78
92
  let a = e.charAt(t + 1);
79
- if (t + 1 >= e.length || F(a)) {
93
+ if (t + 1 >= e.length || ge(a)) {
80
94
  r = t;
81
95
  break;
82
96
  }
83
97
  r = t + 1;
84
98
  }
85
- if (r >= e.length) throw new P("unterminated quoted string", i);
99
+ if (r >= e.length) throw new j("unterminated quoted string", i);
86
100
  t.push({
87
101
  kind: "value",
88
102
  text: e.slice(a + 1, r),
@@ -91,8 +105,8 @@ function fe(e) {
91
105
  continue;
92
106
  }
93
107
  let r = a;
94
- for (; r < e.length && !F(e.charAt(r));) r += 1;
95
- t.push(de(e.slice(a, r), i)), a = r;
108
+ for (; r < e.length && !ge(e.charAt(r));) r += 1;
109
+ t.push(_e(e.slice(a, r), i)), a = r;
96
110
  }
97
111
  r += 1;
98
112
  }
@@ -100,10 +114,10 @@ function fe(e) {
100
114
  }
101
115
  //#endregion
102
116
  //#region src/cif/parser.ts
103
- function pe(e) {
117
+ function ye(e) {
104
118
  return typeof e == "string" ? [e] : e;
105
119
  }
106
- var me = class {
120
+ var be = class {
107
121
  name;
108
122
  items = /* @__PURE__ */ new Map();
109
123
  loops = [];
@@ -111,41 +125,41 @@ var me = class {
111
125
  this.name = e;
112
126
  }
113
127
  get(e) {
114
- for (let t of pe(e)) {
128
+ for (let t of ye(e)) {
115
129
  let e = this.items.get(t.toLowerCase());
116
130
  if (e !== void 0) return e;
117
131
  }
118
132
  return null;
119
133
  }
120
134
  findLoop(e) {
121
- for (let t of pe(e)) {
135
+ for (let t of ye(e)) {
122
136
  let e = t.toLowerCase(), n = this.loops.find((t) => t.tags.includes(e));
123
137
  if (n) return n;
124
138
  }
125
139
  return null;
126
140
  }
127
141
  };
128
- function I(e, t) {
129
- for (let n of pe(t)) {
142
+ function N(e, t) {
143
+ for (let n of ye(t)) {
130
144
  let t = e.tags.indexOf(n.toLowerCase());
131
145
  if (t !== -1) return e.rows.map((e) => e[t] ?? "?");
132
146
  }
133
147
  return null;
134
148
  }
135
- function L(e) {
149
+ function P(e) {
136
150
  return e === "?" || e === ".";
137
151
  }
138
- function R(e) {
139
- if (e == null || L(e)) return null;
152
+ function F(e) {
153
+ if (e == null || P(e)) return null;
140
154
  let t = e.replace(/\(\d+\)$/, "").trim();
141
155
  return /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(t) ? Number(t) : null;
142
156
  }
143
- function he(e) {
157
+ function xe(e) {
144
158
  return e === void 0 || e.kind !== "value";
145
159
  }
146
- function ge(e) {
147
- let t = fe(e), n = [], r = null, i = 0, a = 0, o = (e) => {
148
- if (r || (r = new me(""), n.push(r)), a > 0) throw new P(`unexpected ${e.kind} inside a save frame`, e.line);
160
+ function Se(e) {
161
+ let t = ve(e), n = [], r = null, i = 0, a = 0, o = (e) => {
162
+ if (r || (r = new be(""), n.push(r)), a > 0) throw new j(`unexpected ${e.kind} inside a save frame`, e.line);
149
163
  return r;
150
164
  };
151
165
  for (; i < t.length;) {
@@ -153,7 +167,7 @@ function ge(e) {
153
167
  if (!e) break;
154
168
  switch (e.kind) {
155
169
  case "data":
156
- r = new me(e.text), n.push(r), a = 0, i += 1;
170
+ r = new be(e.text), n.push(r), a = 0, i += 1;
157
171
  break;
158
172
  case "save":
159
173
  a = e.text === "" ? Math.max(0, a - 1) : a + 1, i += 1;
@@ -167,18 +181,18 @@ function ge(e) {
167
181
  break;
168
182
  }
169
183
  let n = o(e), r = t[i + 1];
170
- if (!r || r.kind !== "value") throw new P(`tag ${e.text} has no value`, e.line);
184
+ if (!r || r.kind !== "value") throw new j(`tag ${e.text} has no value`, e.line);
171
185
  n.items.set(e.text.toLowerCase(), r.text), i += 2;
172
186
  break;
173
187
  }
174
188
  case "loop": {
175
189
  let n = [];
176
190
  for (i += 1; t[i]?.kind === "tag";) n.push(t[i].text.toLowerCase()), i += 1;
177
- if (n.length === 0) throw new P("loop_ without tags", e.line);
191
+ if (n.length === 0) throw new j("loop_ without tags", e.line);
178
192
  let r = [];
179
- for (; !he(t[i]);) r.push(t[i].text), i += 1;
193
+ for (; !xe(t[i]);) r.push(t[i].text), i += 1;
180
194
  if (a > 0) break;
181
- if (r.length % n.length !== 0) throw new P(`loop with ${n.length} tags has ${r.length} values`, e.line);
195
+ if (r.length % n.length !== 0) throw new j(`loop with ${n.length} tags has ${r.length} values`, e.line);
182
196
  let s = [];
183
197
  for (let e = 0; e < r.length; e += n.length) s.push(r.slice(e, e + n.length));
184
198
  o(e).loops.push({
@@ -187,103 +201,39 @@ function ge(e) {
187
201
  });
188
202
  break;
189
203
  }
190
- case "value": throw new P(`unexpected value ${JSON.stringify(e.text)}`, e.line);
204
+ case "value": throw new j(`unexpected value ${JSON.stringify(e.text)}`, e.line);
191
205
  }
192
206
  }
193
207
  return { blocks: n };
194
208
  }
195
209
  //#endregion
196
210
  //#region src/structure/elements.ts
197
- var _e = /* @__PURE__ */ "H.He.Li.Be.B.C.N.O.F.Ne.Na.Mg.Al.Si.P.S.Cl.Ar.K.Ca.Sc.Ti.V.Cr.Mn.Fe.Co.Ni.Cu.Zn.Ga.Ge.As.Se.Br.Kr.Rb.Sr.Y.Zr.Nb.Mo.Tc.Ru.Rh.Pd.Ag.Cd.In.Sn.Sb.Te.I.Xe.Cs.Ba.La.Ce.Pr.Nd.Pm.Sm.Eu.Gd.Tb.Dy.Ho.Er.Tm.Yb.Lu.Hf.Ta.W.Re.Os.Ir.Pt.Au.Hg.Tl.Pb.Bi.Po.At.Rn.Fr.Ra.Ac.Th.Pa.U.Np.Pu.Am.Cm.Bk.Cf.Es.Fm.Md.No.Lr.Rf.Db.Sg.Bh.Hs.Mt.Ds.Rg.Cn.Nh.Fl.Mc.Lv.Ts.Og".split("."), ve = new Set(_e);
198
- function ye(e) {
199
- return ve.has(e) || e === "D";
211
+ var Ce = /* @__PURE__ */ "H.He.Li.Be.B.C.N.O.F.Ne.Na.Mg.Al.Si.P.S.Cl.Ar.K.Ca.Sc.Ti.V.Cr.Mn.Fe.Co.Ni.Cu.Zn.Ga.Ge.As.Se.Br.Kr.Rb.Sr.Y.Zr.Nb.Mo.Tc.Ru.Rh.Pd.Ag.Cd.In.Sn.Sb.Te.I.Xe.Cs.Ba.La.Ce.Pr.Nd.Pm.Sm.Eu.Gd.Tb.Dy.Ho.Er.Tm.Yb.Lu.Hf.Ta.W.Re.Os.Ir.Pt.Au.Hg.Tl.Pb.Bi.Po.At.Rn.Fr.Ra.Ac.Th.Pa.U.Np.Pu.Am.Cm.Bk.Cf.Es.Fm.Md.No.Lr.Rf.Db.Sg.Bh.Hs.Mt.Ds.Rg.Cn.Nh.Fl.Mc.Lv.Ts.Og".split("."), we = new Set(Ce), Te = "D";
212
+ function Ee(e) {
213
+ return we.has(e) || e === Te;
200
214
  }
201
- function be(e) {
215
+ function De(e) {
202
216
  return e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
203
217
  }
204
- function xe(e) {
218
+ function Oe(e) {
205
219
  let t = e.match(/^[A-Za-z]{1,2}/)?.[0];
206
220
  if (!t) return null;
207
- let n = be(t);
208
- if (t.length === 2 && ye(n)) return n;
221
+ let n = De(t);
222
+ if (t.length === 2 && Ee(n)) return n;
209
223
  let r = t.charAt(0).toUpperCase();
210
- return ye(r) ? r : null;
211
- }
212
- function Se(e) {
213
- return e === "D" ? "H" : e;
214
- }
215
- //#endregion
216
- //#region src/structure/fractional.ts
217
- var Ce = .001, we = 1e-9;
218
- function z(e, t = we) {
219
- let n = e - Math.floor(e);
220
- return n >= 1 - t ? 0 : n;
221
- }
222
- function Te(e) {
223
- return [
224
- z(e[0]),
225
- z(e[1]),
226
- z(e[2])
227
- ];
228
- }
229
- function Ee(e, t, n) {
230
- for (let r = 0; r < 3; r += 1) {
231
- let i = Math.abs(e[r] - t[r]);
232
- if (i -= Math.round(i), Math.abs(i) > n) return !1;
233
- }
234
- return !0;
235
- }
236
- var B = 100;
237
- function De(e) {
238
- return Math.floor(z(e) * B) % B;
239
- }
240
- function Oe(e, t, n) {
241
- return (e * B + t) * B + n;
224
+ return Ee(r) ? r : null;
242
225
  }
243
- var ke = class {
244
- tolerance;
245
- buckets = /* @__PURE__ */ new Map();
246
- positions = [];
247
- constructor(e) {
248
- this.tolerance = e;
249
- }
250
- add(e) {
251
- let t = this.positions.length;
252
- this.positions.push(e);
253
- let n = Oe(De(e[0]), De(e[1]), De(e[2])), r = this.buckets.get(n);
254
- return r ? r.push(t) : this.buckets.set(n, [t]), t;
255
- }
256
- near(e) {
257
- let t = Te(e), [n, r, i] = t.map(De), a = [];
258
- for (let e = -1; e <= 1; e += 1) {
259
- let o = (n + e + B) % B;
260
- for (let e = -1; e <= 1; e += 1) {
261
- let n = (r + e + B) % B;
262
- for (let e = -1; e <= 1; e += 1) {
263
- let r = (i + e + B) % B;
264
- for (let e of this.buckets.get(Oe(o, n, r)) ?? []) Ee(this.positions[e], t, this.tolerance) && a.push(e);
265
- }
266
- }
267
- }
268
- return a.sort((e, t) => e - t);
269
- }
270
- };
271
- function Ae(e, t) {
272
- let n = e.rotation, [r, i, a] = t, o = e.translation;
273
- return [
274
- (n[0] ?? 0) * r + (n[1] ?? 0) * i + (n[2] ?? 0) * a + o[0],
275
- (n[3] ?? 0) * r + (n[4] ?? 0) * i + (n[5] ?? 0) * a + o[1],
276
- (n[6] ?? 0) * r + (n[7] ?? 0) * i + (n[8] ?? 0) * a + o[2]
277
- ];
226
+ function ke(e) {
227
+ return e === Te ? "H" : e;
278
228
  }
279
229
  //#endregion
280
230
  //#region src/structure/lattice.ts
281
- var V = Math.PI / 180;
231
+ var Ae = Math.PI / 180;
282
232
  function je(e, t, n) {
283
233
  return Math.min(n, Math.max(t, e));
284
234
  }
285
235
  function Me(e) {
286
- let { a: t, b: n, c: r } = e, i = e.alpha * V, a = e.beta * V, o = e.gamma * V, s = Math.cos(i), c = Math.cos(a), l = Math.cos(o), u = Math.sin(i), d = Math.sin(a), f = Math.acos(je((s * c - l) / (u * d), -1, 1)), p = [
236
+ let { a: t, b: n, c: r } = e, i = e.alpha * Ae, a = e.beta * Ae, o = e.gamma * Ae, s = Math.cos(i), c = Math.cos(a), l = Math.cos(o), u = Math.sin(i), d = Math.sin(a), f = Math.acos(je((s * c - l) / (u * d), -1, 1)), p = [
287
237
  t * d,
288
238
  0,
289
239
  t * c
@@ -306,7 +256,7 @@ function Me(e) {
306
256
  };
307
257
  }
308
258
  function Ne(e) {
309
- let [t, n, r] = e, i = (e) => Math.hypot(e[0], e[1], e[2]), a = (e, t) => Math.acos(je((e[0] * t[0] + e[1] * t[1] + e[2] * t[2]) / (i(e) * i(t)), -1, 1)) / V;
259
+ let [t, n, r] = e, i = (e) => Math.hypot(e[0], e[1], e[2]), a = (e, t) => Math.acos(je((e[0] * t[0] + e[1] * t[1] + e[2] * t[2]) / (i(e) * i(t)), -1, 1)) / Ae;
310
260
  return {
311
261
  a: i(t),
312
262
  b: i(n),
@@ -330,44 +280,139 @@ function Fe(e, t) {
330
280
  return Math.sqrt(n * n + r * r + i * i);
331
281
  }
332
282
  //#endregion
333
- //#region src/cif/errors.ts
334
- var H = class extends Error {
283
+ //#region src/structure/fractional.ts
284
+ var Ie = .001, Le = 1e-9;
285
+ function I(e, t = Le) {
286
+ let n = e - Math.floor(e);
287
+ return n >= 1 - t ? 0 : n;
288
+ }
289
+ function Re(e) {
290
+ return [
291
+ I(e[0]),
292
+ I(e[1]),
293
+ I(e[2])
294
+ ];
295
+ }
296
+ function ze(e, t, n) {
297
+ for (let r = 0; r < 3; r += 1) {
298
+ let i = Math.abs(e[r] - t[r]);
299
+ if (i -= Math.round(i), Math.abs(i) > n) return !1;
300
+ }
301
+ return !0;
302
+ }
303
+ var L = 100;
304
+ function Be(e) {
305
+ return Math.floor(I(e) * L) % L;
306
+ }
307
+ function Ve(e, t, n) {
308
+ return (e * L + t) * L + n;
309
+ }
310
+ var He = class {
311
+ tolerance;
312
+ buckets = /* @__PURE__ */ new Map();
313
+ positions = [];
335
314
  constructor(e) {
336
- super(e), this.name = "CifStructureError";
315
+ this.tolerance = e;
316
+ }
317
+ add(e) {
318
+ let t = this.positions.length;
319
+ this.positions.push(e);
320
+ let n = Ve(Be(e[0]), Be(e[1]), Be(e[2])), r = this.buckets.get(n);
321
+ return r ? r.push(t) : this.buckets.set(n, [t]), t;
322
+ }
323
+ near(e) {
324
+ let t = Re(e), [n, r, i] = t.map(Be), a = [];
325
+ for (let e = -1; e <= 1; e += 1) {
326
+ let o = (n + e + L) % L;
327
+ for (let e = -1; e <= 1; e += 1) {
328
+ let n = (r + e + L) % L;
329
+ for (let e = -1; e <= 1; e += 1) {
330
+ let r = (i + e + L) % L;
331
+ for (let e of this.buckets.get(Ve(o, n, r)) ?? []) ze(this.positions[e], t, this.tolerance) && a.push(e);
332
+ }
333
+ }
334
+ }
335
+ return a.sort((e, t) => e - t);
336
+ }
337
+ };
338
+ function Ue(e, t) {
339
+ let n = e.rotation, [r, i, a] = t, o = e.translation;
340
+ return [
341
+ (n[0] ?? 0) * r + (n[1] ?? 0) * i + (n[2] ?? 0) * a + o[0],
342
+ (n[3] ?? 0) * r + (n[4] ?? 0) * i + (n[5] ?? 0) * a + o[1],
343
+ (n[6] ?? 0) * r + (n[7] ?? 0) * i + (n[8] ?? 0) * a + o[2]
344
+ ];
345
+ }
346
+ //#endregion
347
+ //#region src/structure/sites.ts
348
+ var We = 1e-4;
349
+ function Ge(e, t, n) {
350
+ let r = e.find((e) => e.element === t);
351
+ r ? r.occupancy += n : e.push({
352
+ element: t,
353
+ occupancy: n
354
+ }), e.sort((e, t) => t.occupancy - e.occupancy);
355
+ }
356
+ function Ke(e) {
357
+ for (let t of e) {
358
+ let e = t.species.reduce((e, t) => e + t.occupancy, 0);
359
+ if (e > 1.000001) for (let n of t.species) n.occupancy /= e;
360
+ }
361
+ }
362
+ function qe(e) {
363
+ let t = [], n = new He(We);
364
+ for (let r of e) {
365
+ let e = [
366
+ I(r.fractional[0]),
367
+ I(r.fractional[1]),
368
+ I(r.fractional[2])
369
+ ], [i] = n.near(e);
370
+ i === void 0 ? (n.add(e), t.push({
371
+ label: r.label,
372
+ species: [{
373
+ element: r.element,
374
+ occupancy: r.occupancy
375
+ }],
376
+ fractional: e
377
+ })) : Ge(t[i].species, r.element, r.occupancy);
337
378
  }
338
- }, Ie = [
379
+ return Ke(t), t;
380
+ }
381
+ //#endregion
382
+ //#region src/cif/symmetry-operations.ts
383
+ var Je = [
339
384
  "x",
340
385
  "y",
341
386
  "z"
342
387
  ];
343
- function Le(e) {
388
+ function Ye(e) {
344
389
  if (e === "" || e === "+") return 1;
345
390
  if (e === "-") return -1;
346
391
  let t = e.match(/^([+-]?\d+)\/(\d+)$/), n = t ? Number(t[1]) / Number(t[2]) : Number(e);
347
- if (!Number.isFinite(n)) throw new H(`Cannot read the number ${JSON.stringify(e)} in a symmetry operator.`);
392
+ if (!Number.isFinite(n)) throw new M(`Cannot read the number ${JSON.stringify(e)} in a symmetry operation.`);
348
393
  return n;
349
394
  }
350
- function Re(e) {
395
+ function Xe(e) {
351
396
  let t = e.split(",").map((e) => e.toLowerCase().replace(/[^xyz0-9./+-]/g, ""));
352
- if (t.length !== 3) throw new H(`A symmetry operator needs three components: ${JSON.stringify(e)}.`);
397
+ if (t.length !== 3) throw new M(`A symmetry operation needs three components: ${JSON.stringify(e)}.`);
353
398
  let n = [], r = [];
354
399
  for (let i of t) {
355
400
  let t = i.match(/[+-]?[^+-]+/g);
356
- if (!t || t.join("") !== i) throw new H(`Cannot read the symmetry operator ${JSON.stringify(e)}.`);
401
+ if (!t || t.join("") !== i) throw new M(`Cannot read the symmetry operation ${JSON.stringify(e)}.`);
357
402
  let a = [
358
403
  0,
359
404
  0,
360
405
  0
361
406
  ], o = 0;
362
407
  for (let e of t) {
363
- let t = Ie.findIndex((t) => e.includes(t));
364
- if (t === -1) o += Le(e);
408
+ let t = Je.findIndex((t) => e.includes(t));
409
+ if (t === -1) o += Ye(e);
365
410
  else {
366
- let n = Le(e.replace(Ie[t], "").replace(/\*$/, ""));
411
+ let n = Ye(e.replace(Je[t], "").replace(/\*$/, ""));
367
412
  a[t] = (a[t] ?? 0) + n;
368
413
  }
369
414
  }
370
- n.push(...a), r.push(z(o));
415
+ n.push(...a), r.push(I(o));
371
416
  }
372
417
  return {
373
418
  rotation: n,
@@ -376,99 +421,85 @@ function Re(e) {
376
421
  }
377
422
  //#endregion
378
423
  //#region src/cif/structure.ts
379
- var ze = 1e-4, Be = ["_space_group_symop_operation_xyz", "_symmetry_equiv_pos_as_xyz"], Ve = ["_space_group_it_number", "_symmetry_int_tables_number"], He = [
424
+ var Ze = ["_space_group_symop_operation_xyz", "_symmetry_equiv_pos_as_xyz"], Qe = ["_space_group_it_number", "_symmetry_int_tables_number"], $e = [
380
425
  "_space_group_name_h-m_alt",
381
426
  "_symmetry_space_group_name_h-m",
382
427
  "_space_group_name_h-m_full"
383
- ], Ue = ["_space_group_name_hall", "_symmetry_space_group_name_hall"];
384
- function U(e, t) {
385
- let n = R(e.get(t));
386
- if (n === null) throw new H(`${e.name || "The CIF"} has no usable ${t}.`);
428
+ ], et = ["_space_group_name_hall", "_symmetry_space_group_name_hall"];
429
+ function R(e, t) {
430
+ let n = F(e.get(t));
431
+ if (n === null) throw new M(`${e.name || "The CIF"} has no usable ${t}.`);
387
432
  return n;
388
433
  }
389
- function We(e, t, n) {
390
- let r = e.find((e) => e.element === t);
391
- r ? r.occupancy += n : e.push({
392
- element: t,
393
- occupancy: n
394
- }), e.sort((e, t) => t.occupancy - e.occupancy);
395
- }
396
- function Ge(e) {
397
- for (let t of e) {
398
- let e = t.species.reduce((e, t) => e + t.occupancy, 0);
399
- if (e > 1.000001) for (let n of t.species) n.occupancy /= e;
400
- }
401
- }
402
- function Ke(e) {
434
+ function tt(e) {
403
435
  let t = e.findLoop("_atom_site_fract_x");
404
- if (!t) throw new H(`${e.name || "The CIF"} has no atom sites.`);
405
- let n = I(t, "_atom_site_fract_x") ?? [], r = I(t, "_atom_site_fract_y") ?? [], i = I(t, "_atom_site_fract_z") ?? [], a = I(t, "_atom_site_label"), o = I(t, "_atom_site_type_symbol"), s = I(t, "_atom_site_occupancy"), c = [], l = new ke(ze);
436
+ if (!t) throw new M(`${e.name || "The CIF"} has no atom sites.`);
437
+ let n = N(t, "_atom_site_fract_x") ?? [], r = N(t, "_atom_site_fract_y") ?? [], i = N(t, "_atom_site_fract_z") ?? [], a = N(t, "_atom_site_label"), o = N(t, "_atom_site_type_symbol"), s = N(t, "_atom_site_occupancy"), c = [];
406
438
  for (let e = 0; e < t.rows.length; e += 1) {
407
- let t = R(n[e]), u = R(r[e]), d = R(i[e]);
408
- if (t === null || u === null || d === null) continue;
409
- let f = a?.[e] ?? o?.[e] ?? `site${e + 1}`, p = o?.[e], m = (p && !L(p) ? xe(p) : null) ?? xe(f);
410
- if (!m) throw new H(`Atom site ${JSON.stringify(f)} names no element (type symbol ${JSON.stringify(p ?? "")}).`);
411
- let h = R(s?.[e]) ?? 1, g = [
412
- z(t),
413
- z(u),
414
- z(d)
415
- ], [ee] = l.near(g);
416
- ee === void 0 ? (l.add(g), c.push({
417
- label: f,
418
- species: [{
419
- element: m,
420
- occupancy: h
421
- }],
422
- fractional: g
423
- })) : We(c[ee].species, m, h);
439
+ let t = F(n[e]), l = F(r[e]), u = F(i[e]);
440
+ if (t === null || l === null || u === null) continue;
441
+ let d = a?.[e] ?? o?.[e] ?? `site${e + 1}`, f = o?.[e], p = (f && !P(f) ? Oe(f) : null) ?? Oe(d);
442
+ if (!p) throw new M(`Atom site ${JSON.stringify(d)} names no element (type symbol ${JSON.stringify(f ?? "")}).`);
443
+ let m = F(s?.[e]) ?? 1;
444
+ c.push({
445
+ label: d,
446
+ element: p,
447
+ occupancy: m,
448
+ fractional: [
449
+ t,
450
+ l,
451
+ u
452
+ ]
453
+ });
424
454
  }
425
- if (c.length === 0) throw new H(`${e.name || "The CIF"} has no atom sites with coordinates.`);
426
- return Ge(c), c;
455
+ let l = qe(c);
456
+ if (l.length === 0) throw new M(`${e.name || "The CIF"} has no atom sites with coordinates.`);
457
+ return l;
427
458
  }
428
- function qe(e) {
429
- let t = e.findLoop(Be);
459
+ function nt(e) {
460
+ let t = e.findLoop(Ze);
430
461
  if (!t) {
431
- let t = e.get(Be);
432
- return t === null ? null : [Re(t)];
462
+ let t = e.get(Ze);
463
+ return t === null ? null : [Xe(t)];
433
464
  }
434
- let n = (I(t, Be) ?? []).filter((e) => !L(e)).map(Re);
465
+ let n = (N(t, Ze) ?? []).filter((e) => !P(e)).map(Xe);
435
466
  return n.length > 0 ? n : null;
436
467
  }
437
- function Je(e) {
438
- let t = e.get(Ve), n = t === null ? null : R(t), r = e.get(He), i = e.get(Ue);
468
+ function rt(e) {
469
+ let t = F(e.get(Qe)), n = e.get($e), r = e.get(et);
439
470
  return {
440
- number: n !== null && Number.isInteger(n) && n >= 1 && n <= 230 ? n : null,
441
- symbol: r !== null && !L(r) ? r.trim() : null,
442
- hallSymbol: i !== null && !L(i) ? i.trim() : null
471
+ number: t !== null && Number.isInteger(t) && t >= 1 && t <= 230 ? t : null,
472
+ symbol: n !== null && !P(n) ? n.trim() : null,
473
+ hallSymbol: r !== null && !P(r) ? r.trim() : null
443
474
  };
444
475
  }
445
- function Ye(e) {
476
+ function it(e) {
446
477
  return e.findLoop("_atom_site_fract_x") !== null;
447
478
  }
448
- function Xe(e) {
479
+ function at(e) {
449
480
  return {
450
481
  lattice: Me({
451
- a: U(e, "_cell_length_a"),
452
- b: U(e, "_cell_length_b"),
453
- c: U(e, "_cell_length_c"),
454
- alpha: U(e, "_cell_angle_alpha"),
455
- beta: U(e, "_cell_angle_beta"),
456
- gamma: U(e, "_cell_angle_gamma")
482
+ a: R(e, "_cell_length_a"),
483
+ b: R(e, "_cell_length_b"),
484
+ c: R(e, "_cell_length_c"),
485
+ alpha: R(e, "_cell_angle_alpha"),
486
+ beta: R(e, "_cell_angle_beta"),
487
+ gamma: R(e, "_cell_angle_gamma")
457
488
  }),
458
- sites: Ke(e),
459
- operations: qe(e),
460
- spaceGroup: Je(e)
489
+ sites: tt(e),
490
+ operations: nt(e),
491
+ spaceGroup: rt(e)
461
492
  };
462
493
  }
463
494
  //#endregion
464
495
  //#region src/structure/closure.ts
465
- function Ze(e, t) {
466
- let n = new ke(Ce);
496
+ function ot(e, t) {
497
+ let n = new He(Ie);
467
498
  for (let t of e) n.add(t.fractional);
468
499
  let r = !1, i = !0;
469
500
  return e.forEach((e, a) => {
470
501
  for (let o of t) {
471
- let t = n.near(Ae(o, e.fractional));
502
+ let t = n.near(Ue(o, e.fractional));
472
503
  t.some((e) => e !== a) && (r = !0), t.length === 0 && (i = !1);
473
504
  }
474
505
  }), {
@@ -478,7 +509,7 @@ function Ze(e, t) {
478
509
  }
479
510
  //#endregion
480
511
  //#region src/structure/types.ts
481
- var Qe = {
512
+ var st = {
482
513
  rotation: [
483
514
  1,
484
515
  0,
@@ -495,29 +526,29 @@ var Qe = {
495
526
  0,
496
527
  0
497
528
  ]
498
- }, $e = null, et = null;
499
- function tt() {
500
- return et ||= import("./moyo-wasm.js").then(async (e) => {
501
- await e.instantiate(), $e = e;
529
+ }, ct = null, lt = null;
530
+ function ut() {
531
+ return lt ||= import("./moyo-wasm.js").then(async (e) => {
532
+ await e.instantiate(), ct = e;
502
533
  }).catch((e) => {
503
- throw et = null, e;
504
- }), et;
534
+ throw lt = null, e;
535
+ }), lt;
505
536
  }
506
- function W() {
507
- if (!$e) throw Error("moyo is not loaded yet; await ensureMoyo() first.");
508
- return $e;
537
+ function dt() {
538
+ if (!ct) throw Error("moyo is not loaded yet; await ensureMoyo() first.");
539
+ return ct;
509
540
  }
510
541
  //#endregion
511
542
  //#region src/symmetry/moyo.ts
512
- var nt = class extends Error {
543
+ var ft = class extends Error {
513
544
  constructor(e) {
514
545
  super(e), this.name = "SpaceGroupLookupError";
515
546
  }
516
- }, G = null;
517
- function rt() {
518
- return tt();
547
+ }, z = null;
548
+ function pt() {
549
+ return ut();
519
550
  }
520
- function it(e) {
551
+ function mt(e) {
521
552
  let t = e.rotation;
522
553
  return {
523
554
  rotation: [
@@ -538,119 +569,282 @@ function it(e) {
538
569
  ]
539
570
  };
540
571
  }
541
- function at() {
542
- if (!G) {
543
- G = [];
544
- for (let e = 1; e <= 230; e += 1) G.push(...W().hall_symbol_entries_from_number(e));
572
+ function ht() {
573
+ if (!z) {
574
+ z = [];
575
+ for (let e = 1; e <= 230; e += 1) z.push(...dt().hall_symbol_entries_from_number(e));
545
576
  }
546
- return G;
577
+ return z;
547
578
  }
548
- function K(e) {
579
+ function B(e) {
549
580
  return e.replace(/[\s_]/g, "").toLowerCase();
550
581
  }
551
- function ot(e) {
582
+ function gt(e) {
552
583
  let t = e.trim(), n = t.match(/^(.*?)\s*:\s*(\S+)$/);
553
584
  if (n && n[1] && n[2]) return {
554
- base: K(n[1]),
585
+ base: B(n[1]),
555
586
  setting: n[2].toLowerCase()
556
587
  };
557
588
  let r = t.match(/^(.*\S)\s+([HRhr])$/);
558
589
  return r && r[1] && r[2] ? {
559
- base: K(r[1]),
590
+ base: B(r[1]),
560
591
  setting: r[2].toLowerCase()
561
592
  } : {
562
- base: K(t),
593
+ base: B(t),
563
594
  setting: null
564
595
  };
565
596
  }
566
- function st(e) {
597
+ function _t(e) {
567
598
  let t = e[0];
568
599
  if (!t) return e;
569
- let n = W().space_group_type(t.number).hall_number;
600
+ let n = dt().space_group_type(t.number).hall_number;
570
601
  return [...e].sort((e, t) => Number(t.hall_number === n) - Number(e.hall_number === n));
571
602
  }
572
- function ct(e) {
573
- let t = at().filter((t) => e.number === null || t.number === e.number);
603
+ function vt(e) {
604
+ let t = ht().filter((t) => e.number === null || t.number === e.number);
574
605
  if (e.hallSymbol) {
575
- let n = K(e.hallSymbol), r = t.filter((e) => K(e.hall_symbol) === n);
606
+ let n = B(e.hallSymbol), r = t.filter((e) => B(e.hall_symbol) === n);
576
607
  if (r.length > 0) return r;
577
608
  }
578
609
  if (e.symbol) {
579
- let { base: n, setting: r } = ot(e.symbol), i = t.filter((e) => K(e.hm_short) === n || K(e.hm_full) === n);
610
+ let { base: n, setting: r } = gt(e.symbol), i = t.filter((e) => B(e.hm_short) === n || B(e.hm_full) === n);
580
611
  if (r) {
581
612
  let e = i.filter((e) => e.setting.toLowerCase() === r);
582
613
  if (e.length > 0) return e;
583
614
  }
584
- return st(i);
615
+ return _t(i);
585
616
  }
586
617
  return [];
587
618
  }
588
- function lt(e) {
619
+ function yt(e) {
589
620
  return [
590
621
  e.hallSymbol,
591
622
  e.symbol,
592
623
  e.number
593
624
  ].filter((e) => e !== null).join(" / ");
594
625
  }
595
- async function ut(e) {
596
- await rt();
597
- let { operations_from_number: t } = W();
626
+ async function bt(e) {
627
+ await pt();
628
+ let { operations_from_number: t } = dt();
598
629
  if (e.hallSymbol || e.symbol) {
599
- let n = ct(e);
600
- if (n.length === 0) throw new nt(`Space group ${lt(e)} is not in the symmetry table.`);
630
+ let n = vt(e);
631
+ if (n.length === 0) throw new ft(`Space group ${yt(e)} is not in the symmetry table.`);
601
632
  return n.map((e) => ({
602
633
  setting: e.setting,
603
634
  operations: t(e.number, {
604
635
  type: "HallNumber",
605
636
  value: e.hall_number
606
- }, !1).map(it)
637
+ }, !1).map(mt)
607
638
  }));
608
639
  }
609
- if (e.number === null) throw new nt("The CIF names no space group.");
640
+ if (e.number === null) throw new ft("No space group is named.");
610
641
  return [{
611
642
  setting: "",
612
- operations: t(e.number, { type: "Spglib" }, !1).map(it)
643
+ operations: t(e.number, { type: "Spglib" }, !1).map(mt)
613
644
  }];
614
645
  }
615
- async function dt(e) {
616
- let [t] = await ut(e);
646
+ async function xt(e) {
647
+ let [t] = await bt(e);
617
648
  return t.operations;
618
649
  }
619
650
  //#endregion
620
651
  //#region src/symmetry/resolve.ts
621
- var ft = .001, pt = .01;
622
- function mt() {
623
- return new H("The symmetry does not fit the listed atoms: they are already expanded, yet the operations generate positions the file does not list.");
652
+ var St = .001, Ct = .01;
653
+ function wt(e) {
654
+ return new e("The symmetry does not fit the listed atoms: they are already expanded, yet the operations generate positions that are not listed.");
624
655
  }
625
- function ht(e, t) {
626
- let n = Ze(e, t);
627
- if (n.preExpanded && !n.closed) throw mt();
656
+ function Tt(e, t, n) {
657
+ let r = ot(e, t);
658
+ if (r.preExpanded && !r.closed) throw wt(n);
628
659
  }
629
- function gt({ a: e, b: t, c: n, alpha: r, beta: i, gamma: a }) {
630
- let o = (e, t) => Math.abs(e - t) <= ft * Math.max(e, t), s = (e, t) => Math.abs(e - t) <= pt;
660
+ function Et({ a: e, b: t, c: n, alpha: r, beta: i, gamma: a }) {
661
+ let o = (e, t) => Math.abs(e - t) <= St * Math.max(e, t), s = (e, t) => Math.abs(e - t) <= Ct;
631
662
  return o(e, t) && o(t, n) && s(r, i) && s(i, a) && !s(r, 90) ? "R" : o(e, t) && s(r, 90) && s(i, 90) && s(a, 120) ? "H" : null;
632
663
  }
633
- async function _t(e) {
634
- if (e.operations) return ht(e.sites, e.operations), e.operations;
635
- let { spaceGroup: t } = e;
636
- if (t.hallSymbol === null && t.symbol === null && t.number === null) return [Qe];
637
- let n = await ut(t);
638
- if (n.length === 1) {
639
- let [t] = n;
640
- return ht(e.sites, t.operations), t.operations;
641
- }
642
- let r = n.map((t) => Ze(e.sites, t.operations)), i = n.find((e, t) => r[t].preExpanded && r[t].closed);
643
- if (i) return i.operations;
644
- if (r.some((e) => e.preExpanded)) throw mt();
645
- let a = gt(e.lattice);
646
- return ((a === null ? void 0 : n.find((e) => e.setting.toUpperCase() === a)) ?? n[0]).operations;
664
+ async function Dt(e, t) {
665
+ if (e.operations) return Tt(e.sites, e.operations, t), e.operations;
666
+ let { spaceGroup: n } = e;
667
+ if (n.hallSymbol === null && n.symbol === null && n.number === null) return [st];
668
+ let r = await bt(n);
669
+ if (r.length === 1) {
670
+ let [n] = r;
671
+ return Tt(e.sites, n.operations, t), n.operations;
672
+ }
673
+ let i = r.map((t) => ot(e.sites, t.operations)), a = r.find((e, t) => i[t].preExpanded && i[t].closed);
674
+ if (a) return a.operations;
675
+ if (i.some((e) => e.preExpanded)) throw wt(t);
676
+ let o = Et(e.lattice);
677
+ return ((o === null ? void 0 : r.find((e) => e.setting.toUpperCase() === o)) ?? r[0]).operations;
678
+ }
679
+ //#endregion
680
+ //#region src/structure/from-data.ts
681
+ var Ot = 1e-9, kt = 1e-6;
682
+ function V(e) {
683
+ throw new A(e);
684
+ }
685
+ function H(e) {
686
+ return typeof e == "object" && !!e && !Array.isArray(e);
687
+ }
688
+ function U(e) {
689
+ return e === void 0 ? "undefined" : typeof e == "object" && e ? Array.isArray(e) ? "an array" : "an object" : JSON.stringify(e) ?? String(e);
690
+ }
691
+ function W(e, t) {
692
+ return (typeof e != "number" || !Number.isFinite(e)) && V(`${t} must be a finite number, not ${U(e)}.`), e;
693
+ }
694
+ function G(e, t) {
695
+ let n = W(e, t);
696
+ return n <= 0 && V(`${t} must be positive, not ${n}.`), n;
697
+ }
698
+ function K(e, t) {
699
+ let n = Array.isArray(e) || ArrayBuffer.isView(e) ? Array.from(e) : null;
700
+ return (n === null || n.length !== 3) && V(`${t} must hold three numbers, not ${U(e)}.`), [
701
+ W(n[0], `${t}[0]`),
702
+ W(n[1], `${t}[1]`),
703
+ W(n[2], `${t}[2]`)
704
+ ];
705
+ }
706
+ function At([e, t, n]) {
707
+ return e[0] * (t[1] * n[2] - t[2] * n[1]) - e[1] * (t[0] * n[2] - t[2] * n[0]) + e[2] * (t[0] * n[1] - t[1] * n[0]);
708
+ }
709
+ function jt(e) {
710
+ if (H(e) || V("lattice must be an object with a, b, c, alpha, beta and gamma, or with vectors."), e.vectors !== void 0 && e.vectors !== null) {
711
+ let t = e.vectors;
712
+ (!Array.isArray(t) || t.length !== 3) && V(`lattice.vectors must be three vectors, not ${U(t)}.`);
713
+ let n = [
714
+ K(t[0], "lattice.vectors[0]"),
715
+ K(t[1], "lattice.vectors[1]"),
716
+ K(t[2], "lattice.vectors[2]")
717
+ ];
718
+ return Math.abs(At(n)) < kt && V("lattice.vectors lie in one plane: the cell has no volume."), Ne(n);
719
+ }
720
+ let t = {
721
+ a: G(e.a, "lattice.a"),
722
+ b: G(e.b, "lattice.b"),
723
+ c: G(e.c, "lattice.c"),
724
+ alpha: G(e.alpha, "lattice.alpha"),
725
+ beta: G(e.beta, "lattice.beta"),
726
+ gamma: G(e.gamma, "lattice.gamma")
727
+ }, n = Me(t);
728
+ return Math.abs(At(n.vectors)) >= kt || V(`lattice angles ${t.alpha}, ${t.beta} and ${t.gamma} degrees do not form a cell.`), n;
729
+ }
730
+ function Mt(e) {
731
+ (!Array.isArray(e) || e.length === 0) && V(`sites must be a non-empty array, not ${U(e)}.`);
732
+ let t = [];
733
+ return e.forEach((e, n) => {
734
+ let r = `sites[${n}]`;
735
+ H(e) || V(`${r} must be an object, not ${U(e)}.`);
736
+ let i = e.label;
737
+ i != null && typeof i != "string" && V(`${r}.label must be a string, not ${U(i)}.`);
738
+ let a = i ?? `site${n + 1}`, o = K(e.fractional, `${r}.fractional`), s = e.species;
739
+ (!Array.isArray(s) || s.length === 0) && V(`${r}.species must be a non-empty array, not ${U(s)}.`), s.forEach((e, n) => {
740
+ let i = `${r}.species[${n}]`;
741
+ H(e) || V(`${i} must be an object, not ${U(e)}.`);
742
+ let s = e.element;
743
+ (typeof s != "string" || !Ee(s)) && V(`${i}.element must be an element symbol such as "Fe", or "D", not ${U(s)}.`);
744
+ let c = e.occupancy, l = c == null ? 1 : W(c, `${i}.occupancy`);
745
+ l < 0 && V(`${i}.occupancy must not be negative, not ${l}.`), t.push({
746
+ label: a,
747
+ element: s,
748
+ occupancy: l,
749
+ fractional: o
750
+ });
751
+ });
752
+ }), t;
753
+ }
754
+ function Nt(e) {
755
+ return Math.abs(e - Math.round(e)) <= Ot;
756
+ }
757
+ function Pt(e) {
758
+ return e.rotation.every((e, t) => Math.abs(e - +(t % 4 == 0)) <= Ot) && e.translation.every((e) => Nt(e));
759
+ }
760
+ function Ft(e, t) {
761
+ let n = Array.isArray(e) || ArrayBuffer.isView(e) ? Array.from(e) : null;
762
+ (n === null || n.length !== 9) && V(`${t} must hold nine numbers, row by row, not ${U(e)}.`);
763
+ let r = n.map((e, n) => W(e, `${t}[${n}]`));
764
+ r.every(Nt) || V(`${t} must hold whole numbers.`);
765
+ let i = [
766
+ [
767
+ r[0],
768
+ r[1],
769
+ r[2]
770
+ ],
771
+ [
772
+ r[3],
773
+ r[4],
774
+ r[5]
775
+ ],
776
+ [
777
+ r[6],
778
+ r[7],
779
+ r[8]
780
+ ]
781
+ ];
782
+ return Math.abs(Math.abs(At(i)) - 1) > Ot && V(`${t} must have determinant 1 or -1.`), r.map(Math.round);
783
+ }
784
+ function It(e, t) {
785
+ if (typeof e == "string") {
786
+ let n;
787
+ try {
788
+ n = Xe(e);
789
+ } catch (e) {
790
+ V(`${t}: ${e instanceof Error ? e.message : String(e)}`);
791
+ }
792
+ return {
793
+ rotation: Ft(n.rotation, `${t} (${e})`),
794
+ translation: n.translation
795
+ };
796
+ }
797
+ return H(e) || V(`${t} must be a string such as "x, y, z" or an object with rotation and translation, not ${U(e)}.`), {
798
+ rotation: Ft(e.rotation, `${t}.rotation`),
799
+ translation: Re(K(e.translation, `${t}.translation`))
800
+ };
801
+ }
802
+ function Lt(e) {
803
+ if (e == null) return null;
804
+ (!Array.isArray(e) || e.length === 0) && V(`operations must be a non-empty array, or absent, not ${U(e)}.`);
805
+ let t = e.map((e, t) => It(e, `operations[${t}]`));
806
+ return t.some(Pt) || V("operations must include the identity, x, y, z."), t;
807
+ }
808
+ function Rt(e) {
809
+ if (e == null) return {
810
+ number: null,
811
+ symbol: null,
812
+ hallSymbol: null
813
+ };
814
+ H(e) || V(`spaceGroup must be an object with number, symbol or hallSymbol, not ${U(e)}.`);
815
+ let t = e.number;
816
+ t != null && !(typeof t == "number" && Number.isInteger(t) && t >= 1 && t <= 230) && V(`spaceGroup.number must be a whole number from 1 to 230, not ${U(t)}.`);
817
+ let n = (t) => {
818
+ let n = e[t];
819
+ return n == null ? null : ((typeof n != "string" || n.trim() === "") && V(`spaceGroup.${t} must be a non-empty string, not ${U(n)}.`), n.trim());
820
+ };
821
+ return {
822
+ number: t ?? null,
823
+ symbol: n("symbol"),
824
+ hallSymbol: n("hallSymbol")
825
+ };
826
+ }
827
+ async function zt(e) {
828
+ H(e) || V(`Structure data must be an object, not ${U(e)}.`);
829
+ let t = jt(e.lattice), n = qe(Mt(e.sites)), r = Rt(e.spaceGroup);
830
+ return {
831
+ lattice: t,
832
+ sites: n,
833
+ operations: await Dt({
834
+ lattice: t,
835
+ sites: n,
836
+ operations: Lt(e.operations),
837
+ spaceGroup: r
838
+ }, A),
839
+ spaceGroup: r
840
+ };
647
841
  }
648
842
  //#endregion
649
843
  //#region src/structure/expand.ts
650
- function vt(e) {
651
- let t = [], n = new ke(Ce);
844
+ function Bt(e) {
845
+ let t = [], n = new He(Ie);
652
846
  for (let r of e.sites) for (let i of e.operations) {
653
- let e = Te(Ae(i, r.fractional));
847
+ let e = Re(Ue(i, r.fractional));
654
848
  n.near(e).length === 0 && (n.add(e), t.push({
655
849
  label: r.label,
656
850
  species: r.species,
@@ -660,17 +854,17 @@ function vt(e) {
660
854
  return {
661
855
  ...e,
662
856
  sites: t,
663
- operations: [Qe]
857
+ operations: [st]
664
858
  };
665
859
  }
666
860
  //#endregion
667
861
  //#region src/symmetry/dataset.ts
668
- var yt = .01, bt = class extends Error {
862
+ var Vt = .01, Ht = class extends Error {
669
863
  constructor(e) {
670
864
  super(e), this.name = "SymmetryAnalysisError";
671
865
  }
672
866
  };
673
- function xt(e) {
867
+ function Ut(e) {
674
868
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
675
869
  return {
676
870
  numbers: e.map((e) => {
@@ -680,7 +874,7 @@ function xt(e) {
680
874
  speciesByLabel: n
681
875
  };
682
876
  }
683
- function St(e, t, n) {
877
+ function Wt(e, t, n) {
684
878
  let r = e.std_cell.lattice.basis, i = [
685
879
  [
686
880
  r[0],
@@ -702,13 +896,13 @@ function St(e, t, n) {
702
896
  return a.set(s, c), {
703
897
  label: `${s}${c}`,
704
898
  species: o,
705
- fractional: Te(n)
899
+ fractional: Re(n)
706
900
  };
707
901
  });
708
902
  return {
709
903
  lattice: Ne(i),
710
904
  sites: o,
711
- operations: [Qe],
905
+ operations: [st],
712
906
  spaceGroup: {
713
907
  number: e.number,
714
908
  symbol: e.hm_symbol,
@@ -716,9 +910,9 @@ function St(e, t, n) {
716
910
  }
717
911
  };
718
912
  }
719
- async function Ct(e, t = {}) {
720
- await rt();
721
- let { analyze_cell: n, hall_symbol_entry: r, space_group_type: i } = W(), a = vt(e), { numbers: o, speciesByLabel: s } = xt(a.sites), [c, l, u] = a.lattice.vectors, d = {
913
+ async function Gt(e, t = {}) {
914
+ await pt();
915
+ let { analyze_cell: n, hall_symbol_entry: r, space_group_type: i } = dt(), a = Bt(e), { numbers: o, speciesByLabel: s } = Ut(a.sites), [c, l, u] = a.lattice.vectors, d = {
722
916
  lattice: { basis: [
723
917
  ...c,
724
918
  ...l,
@@ -728,11 +922,11 @@ async function Ct(e, t = {}) {
728
922
  numbers: o
729
923
  }, f;
730
924
  try {
731
- f = n(JSON.stringify(d), t.symprec ?? yt, "Standard");
925
+ f = n(JSON.stringify(d), t.symprec ?? Vt, "Standard");
732
926
  } catch (e) {
733
- throw new bt(`moyo could not analyse the structure: ${e instanceof Error ? e.message : String(e)}`);
927
+ throw new Ht(`moyo could not analyse the structure: ${e instanceof Error ? e.message : String(e)}`);
734
928
  }
735
- let p = r(f.hall_number), m = i(f.number), h = St(f, s, p);
929
+ let p = r(f.hall_number), m = i(f.number), h = Wt(f, s, p);
736
930
  return {
737
931
  number: f.number,
738
932
  symbol: f.hm_symbol,
@@ -741,7 +935,7 @@ async function Ct(e, t = {}) {
741
935
  hallNumber: f.hall_number,
742
936
  setting: p.setting,
743
937
  crystalSystem: m.crystal_system,
744
- operations: f.operations.map(it),
938
+ operations: f.operations.map(mt),
745
939
  wyckoffs: f.wyckoffs,
746
940
  siteSymmetries: f.site_symmetry_symbols,
747
941
  structure: a,
@@ -750,34 +944,34 @@ async function Ct(e, t = {}) {
750
944
  }
751
945
  //#endregion
752
946
  //#region src/symmetry/symbol.ts
753
- var wt = "₀₁₂₃₄₅₆₇₈₉", Tt = "̅";
754
- function Et(e) {
755
- return wt[Number(e)] ?? e;
947
+ var Kt = "₀₁₂₃₄₅₆₇₈₉", qt = "̅";
948
+ function Jt(e) {
949
+ return Kt[Number(e)] ?? e;
756
950
  }
757
- function Dt(e) {
951
+ function Yt(e) {
758
952
  let t = e.trim(), n = t.indexOf(":"), r = n === -1 ? t : t.slice(0, n).trim(), i = n === -1 ? "" : ` ${t.slice(n)}`, a = r.split(/\s+/);
759
- return a.map((e) => a.length > 1 ? e.replace(/^([2346])([1-5])(?=$|\/)/, (e, t, n) => Number(n) < Number(t) ? t + Et(n) : e) : e).join("").replace(/(\d)_(\d)/g, (e, t, n) => t + Et(n)).replace(/-(\d)/g, (e, t) => t + Tt) + i;
953
+ return a.map((e) => a.length > 1 ? e.replace(/^([2346])([1-5])(?=$|\/)/, (e, t, n) => Number(n) < Number(t) ? t + Jt(n) : e) : e).join("").replace(/(\d)_(\d)/g, (e, t, n) => t + Jt(n)).replace(/-(\d)/g, (e, t) => t + qt) + i;
760
954
  }
761
955
  //#endregion
762
956
  //#region src/structure/bonds.ts
763
- var Ot = {
957
+ var Xt = {
764
958
  source: "VESTA bond-search cutoffs (K. Momma and F. Izumi), as distributed in pymatgen's vesta_cutoffs.yaml (MIT). Where VESTA lists a pair twice (H-O, D-O), the shorter cutoff is kept.",
765
959
  pairs: /* @__PURE__ */ JSON.parse("{\"Ac-Br\":3.22726,\"Ac-Cl\":3.08646,\"Ac-F\":2.58646,\"Ac-O\":2.7326,\"Ag-As\":2.45642,\"Ag-Br\":2.37642,\"Ag-Cl\":3.05939,\"Ag-F\":2.76939,\"Ag-H\":1.65642,\"Ag-I\":2.53642,\"Ag-N\":2.00642,\"Ag-O\":2.81139,\"Ag-P\":2.37642,\"Ag-S\":3.08839,\"Ag-Se\":2.41642,\"Ag-Te\":2.66642,\"Al-As\":2.75646,\"Al-Br\":2.65646,\"Al-Cl\":2.48846,\"Al-F\":2.00146,\"Al-H\":1.90646,\"Al-I\":2.86646,\"Al-N\":2.24646,\"Al-O\":2.1074,\"Al-P\":2.69646,\"Al-S\":2.66646,\"Al-Se\":2.72646,\"Al-Te\":2.93646,\"Am-Br\":3.22944,\"Am-Cl\":3.08945,\"Am-F\":2.61945,\"Am-O\":2.71649,\"As-Au\":2.26998,\"As-B\":2.42646,\"As-Ba\":3.69,\"As-Be\":2.60649,\"As-Bi\":2.87642,\"As-Br\":2.80646,\"As-C\":2.38646,\"As-Ca\":3.48295,\"As-Cd\":3.29295,\"As-Ce\":3.08644,\"As-Cl\":2.61646,\"As-Co\":2.43642,\"As-Cr\":2.49642,\"As-Cs\":4.15942,\"As-Cu\":2.71895,\"As-Dy\":3.14,\"As-Er\":3.18,\"As-Eu\":2.93898,\"As-F\":2.15646,\"As-Fe\":2.50642,\"As-Ga\":2.38998,\"As-Gd\":3.18,\"As-Ge\":2.47998,\"As-Hf\":2.71642,\"As-Hg\":2.65642,\"As-Ho\":2.87898,\"As-I\":3.03646,\"As-In\":2.66642,\"As-Ir\":2.58998,\"As-K\":3.94942,\"As-La\":3.51293,\"As-Lu\":3.19649,\"As-Mg\":3.09293,\"As-Mn\":2.51642,\"As-Mo\":2.62701,\"As-Na\":3.64942,\"As-Nb\":2.69642,\"As-Ni\":2.28998,\"As-O\":2.24546,\"As-P\":2.29998,\"As-Pb\":3.02644,\"As-Pd\":2.34998,\"As-Pr\":3.35649,\"As-Pt\":2.30998,\"As-Rb\":4.04645,\"As-Re\":2.61998,\"As-Rh\":2.41998,\"As-Ru\":2.40998,\"As-S\":2.84649,\"As-Sb\":2.64998,\"As-Sc\":3.04291,\"As-Se\":2.98649,\"As-Si\":2.66002,\"As-Sm\":3.30649,\"As-Sn\":2.77642,\"As-Sr\":3.62295,\"As-Ta\":2.70642,\"As-Tb\":3.26649,\"As-Te\":3.10646,\"As-Th\":3.40649,\"As-Ti\":2.87642,\"As-Tl\":3.09644,\"As-Tm\":3.22649,\"As-U\":3.02644,\"As-V\":2.54642,\"As-W\":2.58998,\"As-Y\":3.24649,\"As-Yb\":3.19649,\"As-Zn\":2.95293,\"As-Zr\":3.07004,\"Au-Br\":2.77646,\"Au-Cl\":2.88295,\"Au-F\":2.34646,\"Au-H\":1.41998,\"Au-I\":3.21295,\"Au-N\":2.3826,\"Au-O\":2.34646,\"Au-P\":2.18998,\"Au-S\":2.8326,\"Au-Se\":2.22998,\"Au-Te\":2.45998,\"B-B\":1.85846,\"B-Br\":2.33646,\"B-Cl\":2.19646,\"B-F\":1.76646,\"B-H\":1.59646,\"B-I\":2.55646,\"B-N\":1.93846,\"B-O\":1.82746,\"B-P\":2.37646,\"B-S\":2.27646,\"B-Se\":2.40646,\"B-Te\":2.65646,\"Ba-Br\":3.74295,\"Ba-Cl\":3.55295,\"Ba-F\":3.05095,\"Ba-H\":3.08295,\"Ba-I\":3.99295,\"Ba-N\":3.33295,\"Ba-O\":3.14795,\"Ba-P\":3.48295,\"Ba-S\":3.66195,\"Ba-Se\":3.74295,\"Ba-Te\":3.94295,\"Be-Br\":2.50649,\"Be-Cl\":2.36649,\"Be-F\":1.88749,\"Be-H\":1.71649,\"Be-I\":2.70649,\"Be-N\":2.10649,\"Be-O\":1.98749,\"Be-P\":2.55649,\"Be-S\":2.43649,\"Be-Se\":2.57649,\"Be-Te\":2.81649,\"Bi-Br\":3.17993,\"Bi-Cl\":3.04291,\"Bi-F\":2.55291,\"Bi-H\":2.12642,\"Bi-I\":3.38291,\"Bi-N\":2.56329,\"Bi-O\":2.6608,\"Bi-P\":2.78642,\"Bi-S\":3.13291,\"Bi-Se\":3.24329,\"Bi-Te\":3.02642,\"Bk-Br\":3.15233,\"Bk-Cl\":3.02291,\"Bk-F\":2.54233,\"Bk-O\":2.64329,\"Br-C\":2.26002,\"Br-Ca\":3.36995,\"Br-Cd\":3.21295,\"Br-Ce\":3.40452,\"Br-Cf\":3.14233,\"Br-Cl\":2.33296,\"Br-Co\":2.33642,\"Br-Cr\":2.97293,\"Br-Cs\":4.06942,\"Br-Cu\":2.89295,\"Br-Dy\":3.16945,\"Br-Er\":3.14945,\"Br-Eu\":3.46549,\"Br-F\":2.20646,\"Br-Fe\":2.8952,\"Br-Ga\":2.6426,\"Br-Gd\":3.19945,\"Br-Ge\":2.34998,\"Br-Hf\":2.62642,\"Br-Hg\":3.09293,\"Br-Ho\":3.20159,\"Br-In\":3.05329,\"Br-Ir\":2.49998,\"Br-K\":3.8513,\"Br-La\":3.43293,\"Br-Li\":3.11654,\"Br-Lu\":3.11945,\"Br-Mg\":2.99293,\"Br-Mn\":3.05293,\"Br-Mo\":2.8535,\"Br-Na\":3.57715,\"Br-Nb\":3.07646,\"Br-Nd\":3.37293,\"Br-Ni\":2.80649,\"Br-Np\":3.21233,\"Br-O\":2.35646,\"Br-Os\":2.72002,\"Br-P\":2.44293,\"Br-Pa\":3.18437,\"Br-Pb\":3.62451,\"Br-Pd\":2.80649,\"Br-Pm\":3.18233,\"Br-Pr\":3.27649,\"Br-Pt\":2.94191,\"Br-Pu\":3.19233,\"Br-Rb\":4.05498,\"Br-Re\":2.70002,\"Br-Rh\":2.7126,\"Br-Ru\":2.30998,\"Br-S\":2.21998,\"Br-Sb\":2.96646,\"Br-Sc\":2.94291,\"Br-Se\":2.78002,\"Br-Si\":2.55002,\"Br-Sm\":3.26649,\"Br-Sn\":3.2152,\"Br-Sr\":3.54295,\"Br-Ta\":2.60642,\"Br-Tb\":3.18649,\"Br-Te\":2.90002,\"Br-Th\":3.31945,\"Br-Ti\":3.20293,\"Br-Tl\":3.80942,\"Br-Tm\":3.13945,\"Br-U\":3.39452,\"Br-V\":2.87329,\"Br-W\":2.49998,\"Br-Y\":3.15649,\"Br-Yb\":3.12945,\"Br-Zn\":2.86293,\"Br-Zr\":2.98004,\"C-C\":1.89002,\"C-Cl\":2.11002,\"C-Co\":2.19691,\"C-Cu\":2.32649,\"C-F\":1.76002,\"C-Fe\":2.25191,\"C-H\":1.2,\"C-I\":2.16998,\"C-N\":1.79202,\"C-O\":1.97249,\"C-P\":1.93998,\"C-Pd\":2.33649,\"C-Pt\":2.36649,\"C-S\":2.15002,\"C-Se\":2.01998,\"C-Si\":2.23302,\"C-Te\":2.25998,\"Ca-Cl\":3.23295,\"Ca-F\":2.70495,\"Ca-H\":2.69295,\"Ca-I\":3.58295,\"Ca-N\":3.00295,\"Ca-O\":2.83062,\"Ca-P\":3.41295,\"Ca-S\":3.31295,\"Ca-Se\":3.42295,\"Ca-Te\":3.62295,\"Cd-Cl\":3.09295,\"Cd-F\":2.67395,\"Cd-H\":2.52295,\"Cd-I\":3.46295,\"Cd-N\":2.82295,\"Cd-O\":2.76695,\"Cd-P\":3.20295,\"Cd-S\":3.16695,\"Cd-Se\":3.26295,\"Cd-Te\":3.45295,\"Ce-Cl\":3.25293,\"Ce-F\":2.75452,\"Ce-H\":2.34644,\"Ce-I\":3.62452,\"Ce-N\":2.78549,\"Ce-O\":2.86393,\"Ce-P\":3.00644,\"Ce-S\":3.36293,\"Ce-Se\":3.04644,\"Ce-Te\":3.22644,\"Cf-Cl\":3.01291,\"Cf-F\":2.53233,\"Cf-O\":2.63291,\"Cl-Cl\":2.14296,\"Cl-Cm\":3.18291,\"Cl-Co\":2.74593,\"Cl-Cr\":2.80293,\"Cl-Cs\":3.91042,\"Cl-Cu\":2.75295,\"Cl-D\":1.5,\"Cl-Dy\":3.01945,\"Cl-Er\":2.99944,\"Cl-Eu\":3.32549,\"Cl-F\":2.14646,\"Cl-Fe\":2.86293,\"Cl-Ga\":2.52646,\"Cl-Gd\":3.06349,\"Cl-Ge\":2.49002,\"Cl-H\":1.5,\"Cl-Hf\":2.75646,\"Cl-Hg\":3.24939,\"Cl-Ho\":3.05159,\"Cl-I\":3.33295,\"Cl-In\":3.52939,\"Cl-Ir\":2.56746,\"Cl-K\":3.65976,\"Cl-La\":3.33452,\"Cl-Li\":2.91814,\"Cl-Lu\":2.96944,\"Cl-Mg\":2.79293,\"Cl-Mn\":2.84593,\"Cl-Mo\":2.80447,\"Cl-N\":2.20646,\"Cl-NH\":3.48195,\"Cl-Na\":3.39412,\"Cl-Nb\":2.76291,\"Cl-Nd\":3.22493,\"Cl-Ni\":2.62649,\"Cl-Np\":3.07233,\"Cl-O\":2.16646,\"Cl-Os\":2.54002,\"Cl-P\":2.28746,\"Cl-Pa\":3.01437,\"Cl-Pb\":3.39295,\"Cl-Pd\":2.65649,\"Cl-Pm\":3.41233,\"Cl-Pr\":3.12749,\"Cl-Pt\":2.75646,\"Cl-Pu\":3.05233,\"Cl-Rb\":3.86664,\"Cl-Re\":3.44712,\"Cl-Rh\":2.62646,\"Cl-Ru\":2.70646,\"Cl-S\":2.37002,\"Cl-Sb\":2.80646,\"Cl-Sc\":2.92291,\"Cl-Se\":2.57002,\"Cl-Si\":2.38002,\"Cl-Sm\":3.08749,\"Cl-Sn\":3.13111,\"Cl-Sr\":3.37295,\"Cl-Ta\":2.6739,\"Cl-Tb\":3.04349,\"Cl-Tc\":2.56002,\"Cl-Te\":2.73906,\"Cl-Th\":3.15945,\"Cl-Ti\":3.02293,\"Cl-Tl\":3.72942,\"Cl-Tm\":2.98944,\"Cl-U\":3.24452,\"Cl-V\":3.15293,\"Cl-W\":2.47,\"Cl-Y\":3.00649,\"Cl-Yb\":2.98249,\"Cl-Zn\":2.72293,\"Cl-Zr\":3.33651,\"Cm-F\":2.68291,\"Cm-O\":2.79291,\"Co-F\":2.35293,\"Co-H\":1.9278,\"Co-I\":2.52878,\"Co-In\":3.13629,\"Co-N\":2.36293,\"Co-O\":2.40493,\"Co-P\":2.36642,\"Co-S\":2.65293,\"Co-Se\":2.39642,\"Co-Te\":2.61642,\"Cr-F\":2.45293,\"Cr-H\":1.67642,\"Cr-I\":3.19293,\"Cr-N\":2.5152,\"Cr-O\":2.44293,\"Cr-P\":2.42642,\"Cr-S\":2.72491,\"Cr-Se\":2.44642,\"Cr-Te\":2.67642,\"Cs-F\":3.49942,\"Cs-H\":3.55942,\"Cs-I\":4.40942,\"Cs-N\":3.94942,\"Cs-O\":3.53642,\"Cs-P\":3.64194,\"Cs-S\":4.24942,\"Cs-Se\":4.21655,\"Cs-Te\":4.4631,\"Cu-F\":2.46295,\"Cu-H\":1.81649,\"Cu-I\":3.01795,\"Cu-N\":2.49295,\"Cu-O\":2.47295,\"Cu-P\":2.65649,\"Cu-S\":2.76095,\"Cu-Se\":2.76295,\"Cu-Te\":2.87649,\"D-F\":1.1,\"D-N\":1.2,\"D-O\":1.2,\"Dy-F\":2.52944,\"Dy-H\":2.09,\"Dy-I\":3.39945,\"Dy-N\":2.38,\"Dy-O\":2.65651,\"Dy-P\":2.77,\"Dy-S\":2.823,\"Dy-Se\":2.81,\"Dy-Te\":3.22,\"Er-F\":2.51049,\"Er-H\":2.06,\"Er-I\":3.38945,\"Er-N\":2.36,\"Er-O\":2.63651,\"Er-P\":2.75,\"Er-S\":3.27651,\"Er-Se\":3.18649,\"Er-Te\":3.22,\"Es-O\":2.70139,\"Eu-F\":2.83549,\"Eu-H\":2.18898,\"Eu-I\":3.69549,\"Eu-N\":2.95549,\"Eu-O\":2.94249,\"Eu-P\":2.85898,\"Eu-S\":3.37949,\"Eu-Se\":2.89898,\"Eu-Te\":3.08898,\"F-Fe\":2.36293,\"F-Ga\":2.14646,\"F-Gd\":3.15651,\"F-Ge\":2.01002,\"F-H\":1.1,\"F-Hf\":3.18291,\"F-Hg\":2.88293,\"F-Ho\":2.56159,\"F-I\":3.18295,\"F-In\":2.35491,\"F-Ir\":2.15002,\"F-K\":3.11142,\"F-Kr\":2.67549,\"F-La\":2.79293,\"F-Li\":2.34276,\"F-Lu\":2.48249,\"F-Mg\":2.29093,\"F-Mn\":2.41093,\"F-Mo\":2.2998,\"F-N\":1.82646,\"F-NH\":2.99195,\"F-Na\":2.80398,\"F-Nb\":2.35646,\"F-Nd\":2.73452,\"F-Ni\":2.20249,\"F-Np\":2.59233,\"F-Os\":2.07746,\"F-P\":2.01002,\"F-Pa\":2.54437,\"F-Pb\":2.92045,\"F-Pd\":2.34649,\"F-Pm\":2.55233,\"F-Po\":2.83646,\"F-Pr\":2.62945,\"F-Pt\":2.54002,\"F-Pu\":2.58233,\"F-Rb\":3.37645,\"F-Re\":2.16002,\"F-Rh\":2.16646,\"F-Ru\":2.57646,\"F-S\":1.95002,\"F-Sb\":2.35646,\"F-Sc\":2.32291,\"F-Se\":2.08002,\"F-Si\":1.93002,\"F-Sm\":2.60649,\"F-Sn\":2.63793,\"F-Sr\":2.88195,\"F-Ta\":2.2539,\"F-Tb\":2.54249,\"F-Tc\":2.24219,\"F-Te\":2.22002,\"F-Th\":2.68945,\"F-Ti\":2.86293,\"F-Tl\":3.26942,\"F-Tm\":2.51649,\"F-U\":2.80293,\"F-V\":2.87293,\"F-W\":2.03,\"F-Xe\":2.62649,\"F-Y\":2.51049,\"F-Yb\":2.50649,\"F-Zn\":2.38293,\"F-Zr\":2.99651,\"Fe-H\":1.68642,\"Fe-I\":3.1552,\"Fe-N\":2.48193,\"Fe-O\":2.44693,\"Fe-P\":2.42642,\"Fe-S\":2.83793,\"Fe-Se\":2.43642,\"Fe-Te\":2.68642,\"Ga-H\":1.55998,\"Ga-I\":2.91646,\"Ga-N\":1.96,\"Ga-O\":2.18646,\"Ga-P\":2.46998,\"Ga-S\":2.61946,\"Ga-Se\":3.41295,\"Ga-Te\":2.58998,\"Gd-H\":2.13,\"Gd-I\":3.41945,\"Gd-N\":2.42,\"Gd-O\":2.76651,\"Gd-P\":2.81,\"Gd-S\":3.13649,\"Gd-Se\":2.85,\"Gd-Te\":3.24,\"Ge-Ge\":2.6,\"Ge-H\":1.59998,\"Ge-I\":2.54998,\"Ge-N\":1.92998,\"Ge-O\":2.09802,\"Ge-P\":2.36998,\"Ge-S\":2.56702,\"Ge-Se\":2.70002,\"Ge-Te\":2.60998,\"H-Hf\":1.93642,\"H-Hg\":1.86642,\"H-Ho\":2.11898,\"H-In\":1.87642,\"H-Ir\":1.80998,\"H-K\":3.21942,\"H-La\":2.77293,\"H-Lu\":2.42649,\"H-Mg\":2.24293,\"H-Mn\":1.70642,\"H-Mo\":1.83701,\"H-N\":1.2,\"H-Na\":2.79942,\"H-Nb\":1.90642,\"H-Ni\":1.44998,\"H-O\":1.2,\"H-P\":1.45998,\"H-Pb\":2.27644,\"H-Pd\":1.51998,\"H-Pr\":2.62649,\"H-Pt\":1.44998,\"H-Rb\":3.43645,\"H-Re\":1.79998,\"H-Rh\":1.59998,\"H-Ru\":1.65998,\"H-S\":1.42998,\"H-Sb\":2.81998,\"H-Sc\":2.24291,\"H-Se\":1.58998,\"H-Si\":1.82002,\"H-Sm\":2.56649,\"H-Sn\":2.00642,\"H-Sr\":2.87295,\"H-Ta\":1.91642,\"H-Tb\":2.51649,\"H-Te\":1.87998,\"H-Th\":2.67649,\"H-Ti\":1.76642,\"H-Tl\":2.35644,\"H-Tm\":2.45649,\"H-U\":2.27644,\"H-V\":1.73642,\"H-W\":1.80998,\"H-Y\":2.46649,\"H-Yb\":2.42649,\"H-Zn\":2.13293,\"H-Zr\":2.29004,\"Hf-I\":2.83642,\"Hf-N\":2.24642,\"Hf-O\":2.37946,\"Hf-P\":2.63642,\"Hf-S\":2.64642,\"Hf-Se\":2.67642,\"Hf-Te\":2.87642,\"Hg-Hg\":3.1952,\"Hg-I\":3.33293,\"Hg-N\":2.17642,\"Hg-O\":2.86939,\"Hg-P\":2.57642,\"Hg-S\":3.42093,\"Hg-Se\":2.82642,\"Hg-Te\":2.76642,\"Ho-I\":3.44159,\"Ho-N\":2.41898,\"Ho-O\":2.67047,\"Ho-P\":2.79898,\"Ho-S\":3.13547,\"Ho-Se\":2.84898,\"Ho-Te\":3.03898,\"I-I\":2.4,\"I-In\":3.19291,\"I-Ir\":2.70998,\"I-K\":4.11717,\"I-La\":3.64293,\"I-Li\":3.37676,\"I-Lu\":3.36945,\"I-Mg\":3.17293,\"I-Mn\":3.23293,\"I-Mo\":2.74701,\"I-Na\":3.88251,\"I-Nb\":3.1439,\"I-Nd\":3.59452,\"I-Ni\":3.00649,\"I-Np\":3.44233,\"I-O\":2.47646,\"I-P\":2.44998,\"I-Pb\":3.69562,\"I-Pd\":2.96649,\"I-Pr\":3.49649,\"I-Pt\":2.41998,\"I-Pu\":3.43233,\"I-Rb\":4.33462,\"I-Re\":2.65998,\"I-Rh\":2.52998,\"I-Ru\":2.52998,\"I-S\":2.40998,\"I-Sb\":3.21646,\"I-Sc\":3.15291,\"I-Se\":2.58998,\"I-Si\":2.76002,\"I-Sm\":3.44649,\"I-Sn\":3.52293,\"I-Sr\":3.74295,\"I-Ta\":2.81642,\"I-Tb\":3.40945,\"I-Te\":3.13702,\"I-Th\":3.56649,\"I-Ti\":3.08291,\"I-Tl\":3.94142,\"I-Tm\":3.37945,\"I-U\":3.62452,\"I-V\":2.66642,\"I-W\":2.70998,\"I-Y\":3.37649,\"I-Yb\":3.37945,\"I-Zn\":3.07293,\"I-Zr\":3.19004,\"In-Mn\":3.14729,\"In-N\":2.18642,\"In-O\":2.46491,\"In-P\":2.68642,\"In-S\":2.93291,\"In-Se\":2.62642,\"In-Te\":2.84642,\"Ir-N\":2.10998,\"Ir-O\":2.27746,\"Ir-P\":2.50998,\"Ir-S\":2.42998,\"Ir-Se\":2.55998,\"Ir-Te\":2.75998,\"K-N\":3.41942,\"K-O\":3.25142,\"K-P\":3.44942,\"K-S\":3.79285,\"K-Se\":4.00186,\"K-Te\":4.23284,\"La-N\":3.05293,\"La-O\":2.90983,\"La-P\":3.32293,\"La-S\":3.35593,\"La-Se\":3.45293,\"La-Te\":3.65293,\"Li-N\":2.66213,\"Li-O\":2.60087,\"Li-S\":3.02481,\"Li-Se\":3.2433,\"Li-Te\":3.42496,\"Lu-N\":2.71649,\"Lu-O\":2.57749,\"Lu-P\":3.11649,\"Lu-S\":3.03649,\"Lu-Se\":3.16649,\"Lu-Te\":3.35649,\"Mg-N\":2.56293,\"Mg-O\":2.41824,\"Mg-P\":3.00293,\"Mg-S\":2.89293,\"Mg-Se\":3.03293,\"Mg-Te\":3.24293,\"Mn-N\":2.56193,\"Mn-O\":2.51652,\"Mn-P\":2.39642,\"Mn-S\":2.93293,\"Mn-Se\":2.47642,\"Mn-Te\":2.70642,\"Mo-N\":2.4735,\"Mo-O\":2.3475,\"Mo-P\":2.54701,\"Mo-S\":2.80067,\"Mo-Se\":2.59701,\"Mo-Te\":2.79701,\"N-N\":1.8826,\"N-Na\":3.12942,\"N-Nb\":2.46046,\"N-Nd\":3.01293,\"N-Ni\":2.30649,\"N-O\":1.81746,\"N-P\":1.97146,\"N-Pb\":3.0967,\"N-Pd\":2.40451,\"N-Pr\":2.90649,\"N-Pt\":2.41649,\"N-Rb\":3.79645,\"N-Re\":2.10998,\"N-Rh\":2.2626,\"N-Ru\":2.2626,\"N-S\":2.28849,\"N-Sb\":2.56446,\"N-Sc\":2.54291,\"N-Se\":2.1,\"N-Si\":2.12002,\"N-Sm\":3.02351,\"N-Sn\":2.7152,\"N-Sr\":3.09295,\"N-Ta\":2.16642,\"N-Tb\":2.80649,\"N-Te\":2.16998,\"N-Th\":2.94649,\"N-Ti\":2.08642,\"N-Tl\":2.59644,\"N-Tm\":2.74649,\"N-U\":2.78649,\"N-V\":2.38329,\"N-W\":2.10998,\"N-Y\":2.77649,\"N-Yb\":2.84851,\"N-Zn\":2.43293,\"N-Zr\":2.65004,\"NH-O\":3.08895,\"Na-O\":2.95693,\"Na-P\":3.47942,\"Na-S\":3.57685,\"Na-Se\":3.71593,\"Na-Te\":3.95459,\"Nb-O\":2.45329,\"Nb-P\":2.61642,\"Nb-S\":2.74,\"Nb-Se\":2.66642,\"Nb-Te\":2.85642,\"Nd-O\":2.8587,\"Nd-S\":3.42712,\"Nd-Se\":3.42293,\"Nd-Te\":3.60293,\"Ni-O\":2.28149,\"Ni-P\":2.31998,\"Ni-S\":2.58649,\"Ni-Se\":2.18998,\"Ni-Te\":2.47998,\"Np-O\":2.63646,\"Np-S\":3.2,\"O-O\":1.7,\"O-Os\":2.23,\"O-P\":2.08646,\"O-Pa\":2.63383,\"O-Pb\":3.04096,\"O-Pd\":2.39849,\"O-Po\":2.64646,\"O-Pr\":2.74449,\"O-Pt\":2.40649,\"O-Pu\":2.68329,\"O-Rb\":3.43945,\"O-Re\":2.3426,\"O-Rh\":2.24946,\"O-Ru\":2.22646,\"O-S\":1.8,\"O-Sb\":2.45237,\"O-Sc\":2.42029,\"O-Se\":2.16102,\"O-Si\":1.99002,\"O-Sm\":2.88251,\"O-Sn\":2.82146,\"O-Sr\":2.98095,\"O-Ta\":2.74646,\"O-Tb\":2.65549,\"O-Tc\":2.22446,\"O-Te\":2.3334,\"O-Th\":2.77349,\"O-Ti\":2.35391,\"O-Tl\":3.36945,\"O-Tm\":2.60649,\"O-U\":2.94295,\"O-V\":2.84939,\"O-W\":2.20102,\"O-Xe\":2.63451,\"O-Y\":2.62549,\"O-Yb\":2.74551,\"O-Zn\":2.41693,\"O-Zr\":3.09651,\"Os-S\":2.56002,\"P-P\":2.48381,\"P-Pb\":2.94644,\"P-Pd\":2.46998,\"P-Pr\":3.28649,\"P-Pt\":2.23998,\"P-Rb\":3.50645,\"P-Re\":2.50998,\"P-Rh\":2.43998,\"P-Ru\":2.33998,\"P-S\":2.57646,\"P-Sb\":2.56998,\"P-Sc\":2.96291,\"P-Se\":2.69646,\"P-Si\":2.58002,\"P-Sm\":3.23649,\"P-Sn\":2.60642,\"P-Sr\":3.43295,\"P-Ta\":2.62642,\"P-Tb\":3.19649,\"P-Te\":2.56998,\"P-Th\":3.33649,\"P-Ti\":2.51642,\"P-Tl\":3.01644,\"P-Tm\":3.13649,\"P-U\":2.94644,\"P-V\":2.46642,\"P-W\":2.50998,\"P-Y\":3.17649,\"P-Yb\":3.13649,\"P-Zn\":2.86293,\"P-Zr\":3.02004,\"Pb-S\":3.40395,\"Pb-Se\":3.55295,\"Pb-Te\":3.14644,\"Pd-S\":2.69649,\"Pd-Se\":2.26998,\"Pd-Te\":2.52998,\"Pr-S\":3.20649,\"Pr-Se\":3.32649,\"Pr-Te\":3.50649,\"Pt-S\":2.76649,\"Pt-Se\":2.23998,\"Pt-Te\":2.49998,\"Pu-S\":3.3,\"Rb-S\":3.97645,\"Rb-Se\":4.13773,\"Rb-Te\":4.28802,\"Re-S\":2.61998,\"Re-Se\":2.54998,\"Re-Te\":2.74998,\"Rh-S\":2.19998,\"Rh-Se\":2.37998,\"Rh-Te\":2.59998,\"Ru-S\":2.6426,\"Ru-Se\":2.69451,\"Ru-Te\":2.58998,\"S-S\":2.2,\"S-Sb\":3.05,\"S-Sc\":2.88391,\"S-Se\":2.81649,\"S-Si\":2.47602,\"S-Sm\":3.15649,\"S-Sn\":3.15293,\"S-Sr\":3.51295,\"S-Ta\":2.8439,\"S-Tb\":3.11649,\"S-Te\":2.79002,\"S-Th\":3.24649,\"S-Ti\":2.74646,\"S-Tl\":3.66442,\"S-Tm\":3.05649,\"S-U\":3.25293,\"S-V\":2.82293,\"S-W\":2.43998,\"S-Y\":3.08649,\"S-Yb\":3.03649,\"S-Zn\":2.80293,\"S-Zr\":2.91004,\"Sb-Se\":3.05646,\"Sb-Te\":2.82998,\"Sc-Se\":3.00291,\"Sc-Te\":3.20291,\"Se-Se\":2.93649,\"Se-Si\":2.61002,\"Se-Sm\":3.27649,\"Se-Sn\":2.96646,\"Se-Sr\":3.58295,\"Se-Ta\":2.66642,\"Se-Tb\":3.23649,\"Se-Te\":2.57998,\"Se-Th\":3.36649,\"Se-Ti\":2.53642,\"Se-Tl\":3.00644,\"Se-Tm\":3.18649,\"Se-U\":3.00644,\"Se-V\":2.48642,\"Se-W\":2.55998,\"Se-Y\":3.21649,\"Se-Yb\":3.16649,\"Se-Zn\":2.93293,\"Se-Zr\":3.03004,\"Si-Si\":2.6,\"Si-Te\":2.84002,\"Sm-Te\":3.46649,\"Sn-Te\":2.91642,\"Sr-Te\":3.73295,\"Ta-Te\":2.85642,\"Tb-Te\":3.42649,\"Te-Te\":2.80998,\"Te-Th\":3.54649,\"Te-Ti\":2.95642,\"Te-Tl\":3.23644,\"Te-Tm\":3.37649,\"Te-U\":3.16644,\"Te-V\":2.72642,\"Te-W\":2.75998,\"Te-Y\":3.40649,\"Te-Yb\":3.36649,\"Te-Zn\":3.16293,\"Te-Zr\":3.17004}")
766
- }.pairs, kt = .4;
767
- function At(e, t) {
768
- return Ot[e < t ? `${e}-${t}` : `${t}-${e}`] ?? null;
960
+ }.pairs, Zt = .4;
961
+ function Qt(e, t) {
962
+ return Xt[e < t ? `${e}-${t}` : `${t}-${e}`] ?? null;
769
963
  }
770
- function jt(e) {
964
+ function $t(e) {
771
965
  let t = /* @__PURE__ */ new Map(), n = e.map((e) => {
772
966
  let n = t.get(e.element);
773
967
  return n === void 0 && (n = t.size, t.set(e.element, n)), n;
774
968
  }), r = [...t.keys()], i = new Float64Array(r.length * r.length), a = 0;
775
969
  if (r.forEach((e, t) => {
776
970
  r.forEach((n, o) => {
777
- let s = At(e, n) ?? 0;
971
+ let s = Qt(e, n) ?? 0;
778
972
  i[t * r.length + o] = s, a = Math.max(a, s);
779
973
  });
780
- }), a < kt) return [];
974
+ }), a < Zt) return [];
781
975
  let o = e.map((e) => e.position.map((e) => Math.floor(e / a) | 0)), s = [
782
976
  Infinity,
783
977
  Infinity,
@@ -799,9 +993,9 @@ function jt(e) {
799
993
  m.length = 0;
800
994
  for (let r = -1; r <= 1; r += 1) for (let o = -1; o <= 1; o += 1) for (let p = -1; p <= 1; p += 1) for (let h of f.get(d(s + r, c + o, l + p)) ?? []) {
801
995
  let r = i[u + n[h]];
802
- if (h <= a || r < kt) continue;
996
+ if (h <= a || r < Zt) continue;
803
997
  let o = Fe(t.position, e[h].position);
804
- o >= kt && o <= r && m.push({
998
+ o >= Zt && o <= r && m.push({
805
999
  start: a,
806
1000
  end: h,
807
1001
  length: o
@@ -812,11 +1006,11 @@ function jt(e) {
812
1006
  }
813
1007
  //#endregion
814
1008
  //#region src/structure/images.ts
815
- var Mt = 1e-4;
816
- function Nt(e, t) {
1009
+ var en = 1e-4;
1010
+ function tn(e, t) {
817
1011
  let n = [];
818
1012
  return e.forEach((e, r) => {
819
- let i = e.fractional.map((e) => z(e, Mt));
1013
+ let i = e.fractional.map((e) => I(e, en));
820
1014
  if (n.push({
821
1015
  siteIndex: r,
822
1016
  fractional: i,
@@ -826,7 +1020,7 @@ function Nt(e, t) {
826
1020
  0,
827
1021
  1,
828
1022
  2
829
- ].filter((e) => i[e] < Mt), o = 1 << a.length;
1023
+ ].filter((e) => i[e] < en), o = 1 << a.length;
830
1024
  for (let e = 1; e < o; e += 1) {
831
1025
  let t = [
832
1026
  i[0],
@@ -845,19 +1039,17 @@ function Nt(e, t) {
845
1039
  }
846
1040
  //#endregion
847
1041
  //#region src/scene/build.ts
848
- function Pt(e) {
1042
+ function nn(e) {
849
1043
  let t = [];
850
1044
  for (let n of e.sites) for (let e of n.species) {
851
- let n = Se(e.element);
1045
+ let n = ke(e.element);
852
1046
  t.includes(n) || t.push(n);
853
1047
  }
854
1048
  return t;
855
1049
  }
856
- function Ft(e, t = {}) {
857
- let n = Nt(e.sites, t.imageAtoms ?? !0).map((t) => {
858
- let n = e.sites[t.siteIndex];
859
- if (!n) throw Error(`Site ${t.siteIndex} is missing.`);
860
- let r = n.species[0];
1050
+ function rn(e, t = {}) {
1051
+ let n = tn(e.sites, t.imageAtoms ?? !0).map((t) => {
1052
+ let n = e.sites[t.siteIndex], r = n.species[0];
861
1053
  if (!r) throw Error(`Site ${n.label} has no species.`);
862
1054
  return {
863
1055
  siteIndex: t.siteIndex,
@@ -871,20 +1063,20 @@ function Ft(e, t = {}) {
871
1063
  return {
872
1064
  cell: e.lattice.vectors,
873
1065
  atoms: n,
874
- bonds: jt(n),
875
- elements: Pt(e)
1066
+ bonds: $t(n),
1067
+ elements: nn(e)
876
1068
  };
877
1069
  }
878
1070
  //#endregion
879
1071
  //#region node_modules/three/examples/jsm/controls/TrackballControls.js
880
- var It = { type: "change" }, Lt = { type: "start" }, Rt = { type: "end" }, zt = 1e-6, q = {
1072
+ var an = { type: "change" }, on = { type: "start" }, sn = { type: "end" }, cn = 1e-6, q = {
881
1073
  NONE: -1,
882
1074
  ROTATE: 0,
883
1075
  ZOOM: 1,
884
1076
  PAN: 2,
885
1077
  TOUCH_ROTATE: 3,
886
1078
  TOUCH_ZOOM_PAN: 4
887
- }, Bt = new j(), J = new j(), Vt = new M(), Ht = new M(), Ut = new M(), Y = new A(), Wt = new M(), Gt = new M(), Kt = new M(), qt = new M(), Jt = class extends l {
1079
+ }, ln = new D(), J = new D(), un = new O(), dn = new O(), fn = new O(), Y = new E(), pn = new O(), mn = new O(), hn = new O(), X = new O(), gn = class extends l {
888
1080
  constructor(e, t = null) {
889
1081
  super(e, t), this.screen = {
890
1082
  left: 0,
@@ -896,10 +1088,10 @@ var It = { type: "change" }, Lt = { type: "start" }, Rt = { type: "end" }, zt =
896
1088
  "KeyS",
897
1089
  "KeyD"
898
1090
  ], this.mouseButtons = {
899
- LEFT: S.ROTATE,
900
- MIDDLE: S.DOLLY,
901
- RIGHT: S.PAN
902
- }, this.target = new M(), this.state = q.NONE, this.keyState = q.NONE, this._lastPosition = new M(), this._lastUp = new M(), this._lastZoom = 1, this._touchZoomDistanceStart = 0, this._touchZoomDistanceEnd = 0, this._touchRollAngle = 0, this._touchRollPointerIds = "", this._lastAngle = 0, this._lastRollAngle = 0, this._eye = new M(), this._movePrev = new j(), this._moveCurr = new j(), this._lastAxis = new M(), this._zoomStart = new j(), this._zoomEnd = new j(), this._panStart = new j(), this._panEnd = new j(), this._pointers = [], this._pointerPositions = {}, this._onPointerMove = Xt.bind(this), this._onPointerDown = Yt.bind(this), this._onPointerUp = Zt.bind(this), this._onPointerCancel = Qt.bind(this), this._onContextMenu = on.bind(this), this._onMouseWheel = an.bind(this), this._onKeyDown = en.bind(this), this._onKeyUp = $t.bind(this), this._onTouchStart = sn.bind(this), this._onTouchMove = cn.bind(this), this._onTouchEnd = ln.bind(this), this._onMouseDown = tn.bind(this), this._onMouseMove = nn.bind(this), this._onMouseUp = rn.bind(this), this._target0 = this.target.clone(), this._position0 = this.object.position.clone(), this._up0 = this.object.up.clone(), this._zoom0 = this.object.zoom, t !== null && (this.connect(t), this.handleResize()), this.update();
1091
+ LEFT: b.ROTATE,
1092
+ MIDDLE: b.DOLLY,
1093
+ RIGHT: b.PAN
1094
+ }, this.target = new O(), this.state = q.NONE, this.keyState = q.NONE, this._lastPosition = new O(), this._lastUp = new O(), this._lastZoom = 1, this._touchZoomDistanceStart = 0, this._touchZoomDistanceEnd = 0, this._touchRollAngle = 0, this._touchRollPointerIds = "", this._lastAngle = 0, this._lastRollAngle = 0, this._eye = new O(), this._movePrev = new D(), this._moveCurr = new D(), this._lastAxis = new O(), this._zoomStart = new D(), this._zoomEnd = new D(), this._panStart = new D(), this._panEnd = new D(), this._pointers = [], this._pointerPositions = {}, this._onPointerMove = vn.bind(this), this._onPointerDown = _n.bind(this), this._onPointerUp = yn.bind(this), this._onPointerCancel = bn.bind(this), this._onContextMenu = Dn.bind(this), this._onMouseWheel = En.bind(this), this._onKeyDown = Sn.bind(this), this._onKeyUp = xn.bind(this), this._onTouchStart = On.bind(this), this._onTouchMove = kn.bind(this), this._onTouchEnd = An.bind(this), this._onMouseDown = Cn.bind(this), this._onMouseMove = wn.bind(this), this._onMouseUp = Tn.bind(this), this._target0 = this.target.clone(), this._position0 = this.object.position.clone(), this._up0 = this.object.up.clone(), this._zoom0 = this.object.zoom, t !== null && (this.connect(t), this.handleResize()), this.update();
903
1095
  }
904
1096
  connect(e) {
905
1097
  super.connect(e), window.addEventListener("keydown", this._onKeyDown), window.addEventListener("keyup", this._onKeyUp), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerCancel), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.style.touchAction = "none";
@@ -917,16 +1109,16 @@ var It = { type: "change" }, Lt = { type: "start" }, Rt = { type: "end" }, zt =
917
1109
  update() {
918
1110
  if (this._eye.subVectors(this.object.position, this.target), this.noRotate || (this._rotateCamera(), this.multiTouchRoll === !0 && this._rollCamera()), this.noZoom || this._zoomCamera(), this.noPan || this._panCamera(), this.object.position.addVectors(this.target, this._eye), this.object.isPerspectiveCamera) {
919
1111
  this._checkDistances(), this.object.lookAt(this.target);
920
- let e = this._lastPosition.distanceToSquared(this.object.position) > zt, t = this._lastUp.distanceToSquared(this.object.up) > zt;
921
- (e || t) && (this.dispatchEvent(It), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up));
1112
+ let e = this._lastPosition.distanceToSquared(this.object.position) > cn, t = this._lastUp.distanceToSquared(this.object.up) > cn;
1113
+ (e || t) && (this.dispatchEvent(an), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up));
922
1114
  } else if (this.object.isOrthographicCamera) {
923
1115
  this.object.lookAt(this.target);
924
- let e = this._lastPosition.distanceToSquared(this.object.position) > zt, t = this._lastUp.distanceToSquared(this.object.up) > zt, n = this._lastZoom !== this.object.zoom;
925
- (e || t || n) && (this.dispatchEvent(It), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up), this._lastZoom = this.object.zoom);
1116
+ let e = this._lastPosition.distanceToSquared(this.object.position) > cn, t = this._lastUp.distanceToSquared(this.object.up) > cn, n = this._lastZoom !== this.object.zoom;
1117
+ (e || t || n) && (this.dispatchEvent(an), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up), this._lastZoom = this.object.zoom);
926
1118
  } else console.warn("THREE.TrackballControls: Unsupported camera type.");
927
1119
  }
928
1120
  reset() {
929
- this.state = q.NONE, this.keyState = q.NONE, this.target.copy(this._target0), this.object.position.copy(this._position0), this.object.up.copy(this._up0), this.object.zoom = this._zoom0, this.object.updateProjectionMatrix(), this._eye.subVectors(this.object.position, this.target), this.object.lookAt(this.target), this.dispatchEvent(It), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up), this._lastZoom = this.object.zoom;
1121
+ this.state = q.NONE, this.keyState = q.NONE, this.target.copy(this._target0), this.object.position.copy(this._position0), this.object.up.copy(this._up0), this.object.zoom = this._zoom0, this.object.updateProjectionMatrix(), this._eye.subVectors(this.object.position, this.target), this.object.lookAt(this.target), this.dispatchEvent(an), this._lastPosition.copy(this.object.position), this._lastUp.copy(this.object.up), this._lastZoom = this.object.zoom;
930
1122
  }
931
1123
  _panCamera() {
932
1124
  if (J.copy(this._panEnd).sub(this._panStart), J.lengthSq()) {
@@ -934,20 +1126,20 @@ var It = { type: "change" }, Lt = { type: "start" }, Rt = { type: "end" }, zt =
934
1126
  let e = (this.object.right - this.object.left) / this.object.zoom / this.domElement.clientWidth, t = (this.object.top - this.object.bottom) / this.object.zoom / this.domElement.clientWidth;
935
1127
  J.x *= e, J.y *= t;
936
1128
  }
937
- J.multiplyScalar(this._eye.length() * this.panSpeed), Ht.copy(this._eye).cross(this.object.up).setLength(J.x), Ht.add(Vt.copy(this.object.up).setLength(J.y)), this.object.position.add(Ht), this.target.add(Ht), this.staticMoving ? this._panStart.copy(this._panEnd) : this._panStart.add(J.subVectors(this._panEnd, this._panStart).multiplyScalar(this.dynamicDampingFactor));
1129
+ J.multiplyScalar(this._eye.length() * this.panSpeed), dn.copy(this._eye).cross(this.object.up).setLength(J.x), dn.add(un.copy(this.object.up).setLength(J.y)), this.object.position.add(dn), this.target.add(dn), this.staticMoving ? this._panStart.copy(this._panEnd) : this._panStart.add(J.subVectors(this._panEnd, this._panStart).multiplyScalar(this.dynamicDampingFactor));
938
1130
  }
939
1131
  }
940
1132
  _rotateCamera() {
941
- qt.set(this._moveCurr.x - this._movePrev.x, this._moveCurr.y - this._movePrev.y, 0);
942
- let e = qt.length();
943
- e ? (this._eye.copy(this.object.position).sub(this.target), Wt.copy(this._eye).normalize(), Gt.copy(this.object.up).normalize(), Kt.crossVectors(Gt, Wt).normalize(), Gt.setLength(this._moveCurr.y - this._movePrev.y), Kt.setLength(this._moveCurr.x - this._movePrev.x), qt.copy(Gt.add(Kt)), Ut.crossVectors(qt, this._eye).normalize(), e *= this.rotateSpeed, Y.setFromAxisAngle(Ut, e), this._eye.applyQuaternion(Y), this.object.up.applyQuaternion(Y), this._lastAxis.copy(Ut), this._lastAngle = e) : !this.staticMoving && this._lastAngle && (this._lastAngle *= Math.sqrt(1 - this.dynamicDampingFactor), this._eye.copy(this.object.position).sub(this.target), Y.setFromAxisAngle(this._lastAxis, this._lastAngle), this._eye.applyQuaternion(Y), this.object.up.applyQuaternion(Y)), this._movePrev.copy(this._moveCurr);
1133
+ X.set(this._moveCurr.x - this._movePrev.x, this._moveCurr.y - this._movePrev.y, 0);
1134
+ let e = X.length();
1135
+ e ? (this._eye.copy(this.object.position).sub(this.target), pn.copy(this._eye).normalize(), mn.copy(this.object.up).normalize(), hn.crossVectors(mn, pn).normalize(), mn.setLength(this._moveCurr.y - this._movePrev.y), hn.setLength(this._moveCurr.x - this._movePrev.x), X.copy(mn.add(hn)), fn.crossVectors(X, this._eye).normalize(), e *= this.rotateSpeed, Y.setFromAxisAngle(fn, e), this._eye.applyQuaternion(Y), this.object.up.applyQuaternion(Y), this._lastAxis.copy(fn), this._lastAngle = e) : !this.staticMoving && this._lastAngle && (this._lastAngle *= Math.sqrt(1 - this.dynamicDampingFactor), this._eye.copy(this.object.position).sub(this.target), Y.setFromAxisAngle(this._lastAxis, this._lastAngle), this._eye.applyQuaternion(Y), this.object.up.applyQuaternion(Y)), this._movePrev.copy(this._moveCurr);
944
1136
  }
945
1137
  _rollCamera() {
946
1138
  let e = this._getTouchRollAngle();
947
1139
  if (e) this._lastRollAngle = e * this.rollSpeed;
948
1140
  else if (!this.staticMoving && this._lastRollAngle) this._lastRollAngle *= Math.sqrt(1 - this.dynamicDampingFactor);
949
1141
  else return;
950
- Wt.copy(this._eye).normalize(), Y.setFromAxisAngle(Wt, this._lastRollAngle), this.object.up.applyQuaternion(Y);
1142
+ pn.copy(this._eye).normalize(), Y.setFromAxisAngle(pn, this._lastRollAngle), this.object.up.applyQuaternion(Y);
951
1143
  }
952
1144
  _getTouchRollAngle() {
953
1145
  let e = this._pointers[0], t = this._pointers[1];
@@ -959,13 +1151,13 @@ var It = { type: "change" }, Lt = { type: "start" }, Rt = { type: "end" }, zt =
959
1151
  }
960
1152
  _zoomCamera() {
961
1153
  let e;
962
- this.state === q.TOUCH_ZOOM_PAN ? (e = this._touchZoomDistanceStart / this._touchZoomDistanceEnd, this._touchZoomDistanceStart = this._touchZoomDistanceEnd, this.object.isPerspectiveCamera ? this._eye.multiplyScalar(e) : this.object.isOrthographicCamera ? (this.object.zoom = ne.clamp(this.object.zoom / e, this.minZoom, this.maxZoom), this._lastZoom !== this.object.zoom && this.object.updateProjectionMatrix()) : console.warn("THREE.TrackballControls: Unsupported camera type")) : (e = 1 + (this._zoomEnd.y - this._zoomStart.y) * this.zoomSpeed, e !== 1 && e > 0 && (this.object.isPerspectiveCamera ? this._eye.multiplyScalar(e) : this.object.isOrthographicCamera ? (this.object.zoom = ne.clamp(this.object.zoom / e, this.minZoom, this.maxZoom), this._lastZoom !== this.object.zoom && this.object.updateProjectionMatrix()) : console.warn("THREE.TrackballControls: Unsupported camera type")), this.staticMoving ? this._zoomStart.copy(this._zoomEnd) : this._zoomStart.y += (this._zoomEnd.y - this._zoomStart.y) * this.dynamicDampingFactor);
1154
+ this.state === q.TOUCH_ZOOM_PAN ? (e = this._touchZoomDistanceStart / this._touchZoomDistanceEnd, this._touchZoomDistanceStart = this._touchZoomDistanceEnd, this.object.isPerspectiveCamera ? this._eye.multiplyScalar(e) : this.object.isOrthographicCamera ? (this.object.zoom = ie.clamp(this.object.zoom / e, this.minZoom, this.maxZoom), this._lastZoom !== this.object.zoom && this.object.updateProjectionMatrix()) : console.warn("THREE.TrackballControls: Unsupported camera type")) : (e = 1 + (this._zoomEnd.y - this._zoomStart.y) * this.zoomSpeed, e !== 1 && e > 0 && (this.object.isPerspectiveCamera ? this._eye.multiplyScalar(e) : this.object.isOrthographicCamera ? (this.object.zoom = ie.clamp(this.object.zoom / e, this.minZoom, this.maxZoom), this._lastZoom !== this.object.zoom && this.object.updateProjectionMatrix()) : console.warn("THREE.TrackballControls: Unsupported camera type")), this.staticMoving ? this._zoomStart.copy(this._zoomEnd) : this._zoomStart.y += (this._zoomEnd.y - this._zoomStart.y) * this.dynamicDampingFactor);
963
1155
  }
964
1156
  _getMouseOnScreen(e, t) {
965
- return Bt.set((e - this.screen.left) / this.screen.width, (t - this.screen.top) / this.screen.height), Bt;
1157
+ return ln.set((e - this.screen.left) / this.screen.width, (t - this.screen.top) / this.screen.height), ln;
966
1158
  }
967
1159
  _getMouseOnCircle(e, t) {
968
- return Bt.set((e - this.screen.width * .5 - this.screen.left) / (this.screen.width * .5), (this.screen.height + 2 * (this.screen.top - t)) / this.screen.width), Bt;
1160
+ return ln.set((e - this.screen.width * .5 - this.screen.left) / (this.screen.width * .5), (this.screen.height + 2 * (this.screen.top - t)) / this.screen.width), ln;
969
1161
  }
970
1162
  _addPointer(e) {
971
1163
  this._pointers.push(e);
@@ -979,7 +1171,7 @@ var It = { type: "change" }, Lt = { type: "start" }, Rt = { type: "end" }, zt =
979
1171
  }
980
1172
  _trackPointer(e) {
981
1173
  let t = this._pointerPositions[e.pointerId];
982
- t === void 0 && (t = new j(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
1174
+ t === void 0 && (t = new D(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
983
1175
  }
984
1176
  _getSecondPointerPosition(e) {
985
1177
  let t = e.pointerId === this._pointers[0].pointerId ? this._pointers[1] : this._pointers[0];
@@ -989,25 +1181,25 @@ var It = { type: "change" }, Lt = { type: "start" }, Rt = { type: "end" }, zt =
989
1181
  (!this.noZoom || !this.noPan) && (this._eye.lengthSq() > this.maxDistance * this.maxDistance && (this.object.position.addVectors(this.target, this._eye.setLength(this.maxDistance)), this._zoomStart.copy(this._zoomEnd)), this._eye.lengthSq() < this.minDistance * this.minDistance && (this.object.position.addVectors(this.target, this._eye.setLength(this.minDistance)), this._zoomStart.copy(this._zoomEnd)));
990
1182
  }
991
1183
  };
992
- function Yt(e) {
1184
+ function _n(e) {
993
1185
  this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(e.pointerId), this.domElement.ownerDocument.addEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.addEventListener("pointerup", this._onPointerUp)), this._addPointer(e), e.pointerType === "touch" ? this._onTouchStart(e) : this._onMouseDown(e));
994
1186
  }
995
- function Xt(e) {
1187
+ function vn(e) {
996
1188
  this.enabled !== !1 && (e.pointerType === "touch" ? this._onTouchMove(e) : this._onMouseMove(e));
997
1189
  }
998
- function Zt(e) {
1190
+ function yn(e) {
999
1191
  this.enabled !== !1 && (e.pointerType === "touch" ? this._onTouchEnd(e) : this._onMouseUp(), this._removePointer(e), this._pointers.length === 0 && (this.domElement.releasePointerCapture(e.pointerId), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp)));
1000
1192
  }
1001
- function Qt(e) {
1193
+ function bn(e) {
1002
1194
  this._removePointer(e);
1003
1195
  }
1004
- function $t() {
1196
+ function xn() {
1005
1197
  this.enabled !== !1 && (this.keyState = q.NONE, window.addEventListener("keydown", this._onKeyDown));
1006
1198
  }
1007
- function en(e) {
1199
+ function Sn(e) {
1008
1200
  this.enabled !== !1 && (window.removeEventListener("keydown", this._onKeyDown), this.keyState === q.NONE && (e.code === this.keys[q.ROTATE] && !this.noRotate ? this.keyState = q.ROTATE : e.code === this.keys[q.ZOOM] && !this.noZoom ? this.keyState = q.ZOOM : e.code === this.keys[q.PAN] && !this.noPan && (this.keyState = q.PAN)));
1009
1201
  }
1010
- function tn(e) {
1202
+ function Cn(e) {
1011
1203
  let t;
1012
1204
  switch (e.button) {
1013
1205
  case 0:
@@ -1022,28 +1214,28 @@ function tn(e) {
1022
1214
  default: t = -1;
1023
1215
  }
1024
1216
  switch (t) {
1025
- case S.DOLLY:
1217
+ case b.DOLLY:
1026
1218
  this.state = q.ZOOM;
1027
1219
  break;
1028
- case S.ROTATE:
1220
+ case b.ROTATE:
1029
1221
  this.state = q.ROTATE;
1030
1222
  break;
1031
- case S.PAN:
1223
+ case b.PAN:
1032
1224
  this.state = q.PAN;
1033
1225
  break;
1034
1226
  default: this.state = q.NONE;
1035
1227
  }
1036
1228
  let n = this.keyState === q.NONE ? this.state : this.keyState;
1037
- n === q.ROTATE && !this.noRotate ? (this._moveCurr.copy(this._getMouseOnCircle(e.pageX, e.pageY)), this._movePrev.copy(this._moveCurr)) : n === q.ZOOM && !this.noZoom ? (this._zoomStart.copy(this._getMouseOnScreen(e.pageX, e.pageY)), this._zoomEnd.copy(this._zoomStart)) : n === q.PAN && !this.noPan && (this._panStart.copy(this._getMouseOnScreen(e.pageX, e.pageY)), this._panEnd.copy(this._panStart)), this.dispatchEvent(Lt);
1229
+ n === q.ROTATE && !this.noRotate ? (this._moveCurr.copy(this._getMouseOnCircle(e.pageX, e.pageY)), this._movePrev.copy(this._moveCurr)) : n === q.ZOOM && !this.noZoom ? (this._zoomStart.copy(this._getMouseOnScreen(e.pageX, e.pageY)), this._zoomEnd.copy(this._zoomStart)) : n === q.PAN && !this.noPan && (this._panStart.copy(this._getMouseOnScreen(e.pageX, e.pageY)), this._panEnd.copy(this._panStart)), this.dispatchEvent(on);
1038
1230
  }
1039
- function nn(e) {
1231
+ function wn(e) {
1040
1232
  let t = this.keyState === q.NONE ? this.state : this.keyState;
1041
1233
  t === q.ROTATE && !this.noRotate ? this._moveCurr.copy(this._getMouseOnCircle(e.pageX, e.pageY)) : t === q.ZOOM && !this.noZoom ? this._zoomEnd.copy(this._getMouseOnScreen(e.pageX, e.pageY)) : t === q.PAN && !this.noPan && this._panEnd.copy(this._getMouseOnScreen(e.pageX, e.pageY));
1042
1234
  }
1043
- function rn() {
1044
- this.state = q.NONE, this.dispatchEvent(Rt);
1235
+ function Tn() {
1236
+ this.state = q.NONE, this.dispatchEvent(sn);
1045
1237
  }
1046
- function an(e) {
1238
+ function En(e) {
1047
1239
  if (this.enabled !== !1 && this.noZoom !== !0) {
1048
1240
  switch (e.preventDefault(), e.deltaMode) {
1049
1241
  case 2:
@@ -1054,13 +1246,13 @@ function an(e) {
1054
1246
  break;
1055
1247
  default: this._zoomStart.y -= e.deltaY * 25e-5;
1056
1248
  }
1057
- this.dispatchEvent(Lt), this.dispatchEvent(Rt);
1249
+ this.dispatchEvent(on), this.dispatchEvent(sn);
1058
1250
  }
1059
1251
  }
1060
- function on(e) {
1252
+ function Dn(e) {
1061
1253
  this.enabled !== !1 && e.preventDefault();
1062
1254
  }
1063
- function sn(e) {
1255
+ function On(e) {
1064
1256
  switch (this._trackPointer(e), this._pointers.length) {
1065
1257
  case 1:
1066
1258
  this.state = q.TOUCH_ROTATE, this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX, this._pointers[0].pageY)), this._movePrev.copy(this._moveCurr);
@@ -1072,9 +1264,9 @@ function sn(e) {
1072
1264
  let n = (this._pointers[0].pageX + this._pointers[1].pageX) / 2, r = (this._pointers[0].pageY + this._pointers[1].pageY) / 2;
1073
1265
  this._panStart.copy(this._getMouseOnScreen(n, r)), this._panEnd.copy(this._panStart);
1074
1266
  }
1075
- this.dispatchEvent(Lt);
1267
+ this.dispatchEvent(on);
1076
1268
  }
1077
- function cn(e) {
1269
+ function kn(e) {
1078
1270
  switch (this._trackPointer(e), this._pointers.length) {
1079
1271
  case 1:
1080
1272
  this._moveCurr.copy(this._getMouseOnCircle(e.pageX, e.pageY));
@@ -1086,7 +1278,7 @@ function cn(e) {
1086
1278
  this._panEnd.copy(this._getMouseOnScreen(i, a));
1087
1279
  }
1088
1280
  }
1089
- function ln(e) {
1281
+ function An(e) {
1090
1282
  switch (this._pointers.length) {
1091
1283
  case 0:
1092
1284
  this.state = q.NONE;
@@ -1102,43 +1294,43 @@ function ln(e) {
1102
1294
  break;
1103
1295
  }
1104
1296
  }
1105
- this.dispatchEvent(Rt);
1297
+ this.dispatchEvent(sn);
1106
1298
  }
1107
1299
  //#endregion
1108
1300
  //#region src/render/camera.ts
1109
- var un = 1 / 3, dn = 1 / 6, fn = 2, pn = 1e-12, mn = new M(0, 0, -1), hn = new M(0, 1, 0);
1110
- function gn(e, t) {
1301
+ var jn = 1 / 3, Mn = 1 / 6, Nn = 2, Pn = 1e-12, Fn = new O(0, 0, -1), In = new O(0, 1, 0);
1302
+ function Ln(e, t) {
1111
1303
  let n = e.clone().sub(t.clone().multiplyScalar(e.dot(t)));
1112
- return n.lengthSq() < pn ? null : n.normalize();
1304
+ return n.lengthSq() < Pn ? null : n.normalize();
1113
1305
  }
1114
- function _n(e) {
1306
+ function Rn(e) {
1115
1307
  for (let t of [
1116
- new M(0, 0, 1),
1117
- new M(0, 1, 0),
1118
- new M(1, 0, 0)
1308
+ new O(0, 0, 1),
1309
+ new O(0, 1, 0),
1310
+ new O(1, 0, 0)
1119
1311
  ]) {
1120
- let n = gn(t, e);
1312
+ let n = Ln(t, e);
1121
1313
  if (n) return n;
1122
1314
  }
1123
- return new M(0, 1, 0);
1315
+ return new O(0, 1, 0);
1124
1316
  }
1125
- function vn(e) {
1126
- let t = new M(...e[0]), n = new M(...e[1]), r = new M(...e[2]).normalize(), i = gn(t, r) ?? gn(n, r) ?? _n(r), a = r.clone().cross(i).normalize(), o = i.clone().add(a.multiplyScalar(un)).add(r.clone().multiplyScalar(dn)).normalize();
1317
+ function zn(e) {
1318
+ let t = new O(...e[0]), n = new O(...e[1]), r = new O(...e[2]).normalize(), i = Ln(t, r) ?? Ln(n, r) ?? Rn(r), a = r.clone().cross(i).normalize(), o = i.clone().add(a.multiplyScalar(jn)).add(r.clone().multiplyScalar(Mn)).normalize();
1127
1319
  return {
1128
1320
  outward: o,
1129
- up: gn(r, o) ?? _n(o)
1321
+ up: Ln(r, o) ?? Rn(o)
1130
1322
  };
1131
1323
  }
1132
- function yn(e) {
1324
+ function Bn(e) {
1133
1325
  return Math.max(4, e * 4);
1134
1326
  }
1135
- function bn(e) {
1136
- let { outward: t, up: n } = vn(e), r = n.clone().cross(t).normalize(), i = t.clone().cross(r).normalize(), a = new C().makeBasis(r, i, t);
1137
- return new A().setFromRotationMatrix(a).normalize();
1327
+ function Vn(e) {
1328
+ let { outward: t, up: n } = zn(e), r = n.clone().cross(t).normalize(), i = t.clone().cross(r).normalize(), a = new ae().makeBasis(r, i, t);
1329
+ return new E().setFromRotationMatrix(a).normalize();
1138
1330
  }
1139
- function xn(e) {
1331
+ function Hn(e) {
1140
1332
  return {
1141
- quaternion: Cn(bn(e)),
1333
+ quaternion: Wn(Vn(e)),
1142
1334
  target: [
1143
1335
  0,
1144
1336
  0,
@@ -1147,11 +1339,11 @@ function xn(e) {
1147
1339
  scale: 1
1148
1340
  };
1149
1341
  }
1150
- function Sn(e, t, n, r) {
1151
- let i = new A(...t.quaternion).normalize(), a = new M(...t.target), o = mn.clone().applyQuaternion(i);
1152
- e.position.copy(a).sub(o.multiplyScalar(n)), e.up.copy(hn.clone().applyQuaternion(i)), e.quaternion.copy(i), e.near = .01, e.far = Math.max(1e3, n + r * 8), e.updateProjectionMatrix();
1342
+ function Un(e, t, n, r) {
1343
+ let i = new E(...t.quaternion).normalize(), a = new O(...t.target), o = Fn.clone().applyQuaternion(i);
1344
+ e.position.copy(a).sub(o.multiplyScalar(n)), e.up.copy(In.clone().applyQuaternion(i)), e.quaternion.copy(i), e.near = .01, e.far = Math.max(1e3, n + r * 8), e.updateProjectionMatrix();
1153
1345
  }
1154
- function Cn(e) {
1346
+ function Wn(e) {
1155
1347
  return [
1156
1348
  e.x,
1157
1349
  e.y,
@@ -1159,10 +1351,10 @@ function Cn(e) {
1159
1351
  e.w
1160
1352
  ];
1161
1353
  }
1162
- function wn(e, t) {
1163
- let n = new M(1, 0, 0).applyQuaternion(t), r = new M(0, 1, 0).applyQuaternion(t), i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
1354
+ function Gn(e, t) {
1355
+ let n = new O(1, 0, 0).applyQuaternion(t), r = new O(0, 1, 0).applyQuaternion(t), i = Infinity, a = -Infinity, o = Infinity, s = -Infinity;
1164
1356
  for (let t of [e.min.x, e.max.x]) for (let c of [e.min.y, e.max.y]) for (let l of [e.min.z, e.max.z]) {
1165
- let e = new M(t, c, l), u = e.dot(n), d = e.dot(r);
1357
+ let e = new O(t, c, l), u = e.dot(n), d = e.dot(r);
1166
1358
  i = Math.min(i, u), a = Math.max(a, u), o = Math.min(o, d), s = Math.max(s, d);
1167
1359
  }
1168
1360
  return {
@@ -1170,31 +1362,31 @@ function wn(e, t) {
1170
1362
  height: Math.max(1, s - o)
1171
1363
  };
1172
1364
  }
1173
- function Tn(e, t, n, r) {
1174
- let i = wn(e, t), a = Math.sqrt(Math.max(1, n) * Math.max(1, r)), o = Math.sqrt(i.width * i.height);
1175
- return Math.max(.01, a / (o * fn));
1365
+ function Kn(e, t, n, r) {
1366
+ let i = Gn(e, t), a = Math.sqrt(Math.max(1, n) * Math.max(1, r)), o = Math.sqrt(i.width * i.height);
1367
+ return Math.max(.01, a / (o * Nn));
1176
1368
  }
1177
- function En(e, t, n) {
1369
+ function qn(e, t, n) {
1178
1370
  e.left = -t / 2, e.right = t / 2, e.top = n / 2, e.bottom = -n / 2, e.updateProjectionMatrix();
1179
1371
  }
1180
1372
  //#endregion
1181
1373
  //#region src/render/materials.ts
1182
- var Dn = .1, On = .6, kn = .8, An = 2.2, jn = [
1374
+ var Jn = .1, Yn = .6, Xn = .8, Zn = 2.2, Qn = [
1183
1375
  .3,
1184
1376
  .2,
1185
1377
  0
1186
- ], Mn = "#fafafa", Nn = "#444444", Pn = "#f2f2f2", Fn = .3, In = "6.28318530718";
1187
- function Ln(e, t) {
1378
+ ], $n = "#fafafa", er = "#444444", tr = "#f2f2f2", nr = .3, rr = "6.28318530718";
1379
+ function ir(e, t) {
1188
1380
  return t.reduce((e, [t, n]) => {
1189
1381
  if (!e.includes(t)) throw Error(`bravais cannot draw with this three.js: its shader has no ${t}.`);
1190
1382
  return e.replace(t, n);
1191
1383
  }, e);
1192
1384
  }
1193
- function Rn(e) {
1194
- return Ln(e, [["#include <common>", "#include <common>\nflat varying int vSectorSite;\nflat varying vec3 vSphereCenter;\nflat varying float vSphereRadius;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vSpherePoint;"], ["#include <project_vertex>", "mat4 sphereMatrix = modelViewMatrix * instanceMatrix;\nvSphereCenter = sphereMatrix[3].xyz;\nvSphereRadius = length(sphereMatrix[0].xyz);\nvSpherePoint = vSphereCenter + vec3(position.xy * vSphereRadius, 0.0);\nvDepthCoefficients = vec2(projectionMatrix[2][2], projectionMatrix[3][2]);\nvSectorSite = gl_InstanceID;\nvec4 mvPosition = vec4(vSpherePoint, 1.0);\ngl_Position = projectionMatrix * mvPosition;"]]);
1385
+ function ar(e) {
1386
+ return ir(e, [["#include <common>", "#include <common>\nflat varying int vSectorSite;\nflat varying vec3 vSphereCenter;\nflat varying float vSphereRadius;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vSpherePoint;"], ["#include <project_vertex>", "mat4 sphereMatrix = modelViewMatrix * instanceMatrix;\nvSphereCenter = sphereMatrix[3].xyz;\nvSphereRadius = length(sphereMatrix[0].xyz);\nvSpherePoint = vSphereCenter + vec3(position.xy * vSphereRadius, 0.0);\nvDepthCoefficients = vec2(projectionMatrix[2][2], projectionMatrix[3][2]);\nvSectorSite = gl_InstanceID;\nvec4 mvPosition = vec4(vSpherePoint, 1.0);\ngl_Position = projectionMatrix * mvPosition;"]]);
1195
1387
  }
1196
- function zn(e) {
1197
- return Ln(e, [
1388
+ function or(e) {
1389
+ return ir(e, [
1198
1390
  ["#include <common>", "#include <common>\nuniform sampler2D sectorTexture;\nuniform float vacancyOpacity;\nflat varying int vSectorSite;\nflat varying vec3 vSphereCenter;\nflat varying float vSphereRadius;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vSpherePoint;"],
1199
1391
  ["#include <clipping_planes_fragment>", "// Where the view ray meets the sphere. The outline is smoothed over one\n// pixel through the alpha: sample coverage, or blending in a see-through layer.\nvec2 sphereOffset = vSpherePoint.xy - vSphereCenter.xy;\nfloat sphereDistance = length(sphereOffset);\nfloat sphereCoverage = clamp(\n (vSphereRadius - sphereDistance) / max(fwidth(sphereDistance), 1e-6) + 0.5,\n 0.0,\n 1.0\n);\nif (sphereCoverage <= 0.0) {\n discard;\n}\nfloat sphereHeight = sqrt(\n max(0.0, vSphereRadius * vSphereRadius - dot(sphereOffset, sphereOffset))\n);\nvec3 sphereNormal = vec3(sphereOffset, sphereHeight) / vSphereRadius;\nfloat sphereZ = vSphereCenter.z + sphereHeight;\ngl_FragDepth = (vDepthCoefficients.x * sphereZ + vDepthCoefficients.y) * 0.5 + 0.5;\n#include <clipping_planes_fragment>"],
1200
1392
  ["#include <color_fragment>", `#include <color_fragment>
@@ -1202,7 +1394,7 @@ function zn(e) {
1202
1394
  // A pie chart facing the viewer, like VESTA's occupancy pies: the instance
1203
1395
  // colour fills the first sector from 12 o'clock clockwise, then each
1204
1396
  // texel's colour from its stop on.
1205
- float sectorAngle = fract(atan(sphereOffset.x, sphereOffset.y) / ${In});
1397
+ float sectorAngle = fract(atan(sphereOffset.x, sphereOffset.y) / ${rr});
1206
1398
  vec3 sectorColor = vColor.rgb;
1207
1399
  float sectorOpacity = 1.0;
1208
1400
  int sectorRow = vSectorSite / 256;
@@ -1222,53 +1414,53 @@ function zn(e) {
1222
1414
  ["#include <normal_fragment_begin>", "#include <normal_fragment_begin>\nnormal = sphereNormal;\nnonPerturbedNormal = normal;"]
1223
1415
  ]);
1224
1416
  }
1225
- function Bn(e, t, n) {
1226
- let r = e < 1 || n, i = new T({
1417
+ function sr(e, t, n) {
1418
+ let r = e < 1 || n, i = new S({
1227
1419
  color: "#ffffff",
1228
- metalness: Dn,
1229
- roughness: On,
1420
+ metalness: Jn,
1421
+ roughness: Yn,
1230
1422
  opacity: e,
1231
1423
  transparent: r,
1232
1424
  alphaToCoverage: !r
1233
1425
  });
1234
1426
  return i.onBeforeCompile = (e) => {
1235
- e.uniforms.sectorTexture = { value: t }, e.uniforms.vacancyOpacity = { value: Fn }, e.vertexShader = Rn(e.vertexShader), e.fragmentShader = zn(e.fragmentShader);
1427
+ e.uniforms.sectorTexture = { value: t }, e.uniforms.vacancyOpacity = { value: nr }, e.vertexShader = ar(e.vertexShader), e.fragmentShader = or(e.fragmentShader);
1236
1428
  }, i.customProgramCacheKey = () => "bravais-atom-spheres", i;
1237
1429
  }
1238
- function Vn(e) {
1239
- return Ln(e, [["#include <common>", "#include <common>\nuniform float capRadius;\nflat varying vec3 vTubeCenter;\nflat varying vec3 vTubeAxis;\nflat varying vec3 vAtomCenter;\nflat varying float vTubeRadius;\nflat varying float vTubeHalfLength;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vBoxPoint;"], ["#include <project_vertex>", "mat4 tubeMatrix = modelViewMatrix * instanceMatrix;\nfloat tubeLength = max(length(tubeMatrix[1].xyz), 1e-6);\nvTubeRadius = length(tubeMatrix[0].xyz);\nvTubeHalfLength = tubeLength * 0.5;\nvTubeCenter = tubeMatrix[3].xyz;\nvTubeAxis = tubeMatrix[1].xyz / tubeLength;\nfloat rim = sqrt(max(0.0, capRadius * capRadius - vTubeRadius * vTubeRadius));\nvAtomCenter = vTubeCenter - vTubeAxis * (rim + vTubeHalfLength);\nvDepthCoefficients = vec2(projectionMatrix[2][2], projectionMatrix[3][2]);\nvec4 mvPosition = tubeMatrix * vec4(position, 1.0);\nvBoxPoint = mvPosition.xyz;\ngl_Position = projectionMatrix * mvPosition;"]]);
1430
+ function cr(e) {
1431
+ return ir(e, [["#include <common>", "#include <common>\nuniform float capRadius;\nflat varying vec3 vTubeCenter;\nflat varying vec3 vTubeAxis;\nflat varying vec3 vAtomCenter;\nflat varying float vTubeRadius;\nflat varying float vTubeHalfLength;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vBoxPoint;"], ["#include <project_vertex>", "mat4 tubeMatrix = modelViewMatrix * instanceMatrix;\nfloat tubeLength = max(length(tubeMatrix[1].xyz), 1e-6);\nvTubeRadius = length(tubeMatrix[0].xyz);\nvTubeHalfLength = tubeLength * 0.5;\nvTubeCenter = tubeMatrix[3].xyz;\nvTubeAxis = tubeMatrix[1].xyz / tubeLength;\nfloat rim = sqrt(max(0.0, capRadius * capRadius - vTubeRadius * vTubeRadius));\nvAtomCenter = vTubeCenter - vTubeAxis * (rim + vTubeHalfLength);\nvDepthCoefficients = vec2(projectionMatrix[2][2], projectionMatrix[3][2]);\nvec4 mvPosition = tubeMatrix * vec4(position, 1.0);\nvBoxPoint = mvPosition.xyz;\ngl_Position = projectionMatrix * mvPosition;"]]);
1240
1432
  }
1241
- function Hn(e) {
1242
- return Ln(e, [
1433
+ function lr(e) {
1434
+ return ir(e, [
1243
1435
  ["#include <common>", "#include <common>\nuniform float capRadius;\nflat varying vec3 vTubeCenter;\nflat varying vec3 vTubeAxis;\nflat varying vec3 vAtomCenter;\nflat varying float vTubeRadius;\nflat varying float vTubeHalfLength;\nflat varying vec2 vDepthCoefficients;\nvarying vec3 vBoxPoint;"],
1244
1436
  ["#include <clipping_planes_fragment>", "// The view ray through this pixel runs down view z. The tube's surface is\n// the nearest of: the wall outside the atom's sphere, the sphere's far side\n// inside the tube (the cut face) and the midpoint disc. Along the ray,\n// q(z) = p(z) - centre has q.a = k + (z - cz) a.z and |q|^2 = u + (z - cz)^2.\nvec2 tubePixel = vBoxPoint.xy;\nvec2 tubeOffset = tubePixel - vTubeCenter.xy;\nfloat tubeK = dot(tubeOffset, vTubeAxis.xy);\nfloat tubeU = dot(tubeOffset, tubeOffset);\nfloat axisZ = vTubeAxis.z;\nfloat quadA = 1.0 - axisZ * axisZ;\nfloat quadB = -2.0 * tubeK * axisZ;\nfloat quadC = tubeU - tubeK * tubeK - vTubeRadius * vTubeRadius;\nfloat tubeRadius2 = vTubeRadius * vTubeRadius;\n// The ray's closest approach to the axis, for the outline's coverage.\nfloat axisDistance2 = tubeU - tubeK * tubeK;\nif (quadA > 1e-6) {\n axisDistance2 -= quadB * quadB / (4.0 * quadA);\n}\nfloat axisDistance = sqrt(max(0.0, axisDistance2));\nfloat tubeCoverage = clamp(\n (vTubeRadius - axisDistance) / max(fwidth(axisDistance), 1e-6) + 0.5,\n 0.0,\n 1.0\n);\nif (tubeCoverage <= 0.0) {\n discard;\n}\nfloat tubeHitZ = -1e30;\nvec3 tubeNormal = vec3(0.0, 0.0, 1.0);\nif (quadA > 1e-6) {\n float discriminant = quadB * quadB - 4.0 * quadA * quadC;\n if (discriminant >= 0.0) {\n float z = vTubeCenter.z + (-quadB + sqrt(discriminant)) / (2.0 * quadA);\n vec3 d = vec3(tubePixel, z) - vTubeCenter;\n float s = dot(d, vTubeAxis);\n if (abs(s) <= vTubeHalfLength && distance(vec3(tubePixel, z), vAtomCenter) >= capRadius) {\n tubeHitZ = z;\n tubeNormal = (d - s * vTubeAxis) / vTubeRadius;\n }\n }\n}\nif (axisZ > 1e-6) {\n float z = vTubeCenter.z + (vTubeHalfLength - tubeK) / axisZ;\n vec3 d = vec3(tubePixel, z) - vTubeCenter;\n if (dot(d, d) - vTubeHalfLength * vTubeHalfLength <= tubeRadius2 && z > tubeHitZ &&\n distance(vec3(tubePixel, z), vAtomCenter) >= capRadius) {\n tubeHitZ = z;\n tubeNormal = vTubeAxis;\n }\n}\n{\n vec2 m = tubePixel - vAtomCenter.xy;\n float inside = capRadius * capRadius - dot(m, m);\n if (inside >= 0.0) {\n float z = vAtomCenter.z - sqrt(inside);\n vec3 d = vec3(tubePixel, z) - vTubeCenter;\n float s = dot(d, vTubeAxis);\n if (abs(s) <= vTubeHalfLength && dot(d, d) - s * s <= tubeRadius2 && z > tubeHitZ) {\n tubeHitZ = z;\n tubeNormal = (vAtomCenter - vec3(tubePixel, z)) / capRadius;\n }\n }\n}\nif (tubeHitZ < -1e29) {\n discard;\n}\ngl_FragDepth = (vDepthCoefficients.x * tubeHitZ + vDepthCoefficients.y) * 0.5 + 0.5;\n#include <clipping_planes_fragment>"],
1245
1437
  ["#include <color_fragment>", "#include <color_fragment>\ndiffuseColor.a *= tubeCoverage;"],
1246
1438
  ["#include <normal_fragment_begin>", "#include <normal_fragment_begin>\nnormal = tubeNormal;\nnonPerturbedNormal = normal;"]
1247
1439
  ]);
1248
1440
  }
1249
- function Un(e, t) {
1250
- let n = e < 1, r = new T({
1441
+ function ur(e, t) {
1442
+ let n = e < 1, r = new S({
1251
1443
  color: "#ffffff",
1252
- metalness: Dn,
1253
- roughness: On,
1444
+ metalness: Jn,
1445
+ roughness: Yn,
1254
1446
  opacity: e,
1255
1447
  transparent: n,
1256
1448
  alphaToCoverage: !n
1257
1449
  });
1258
1450
  return r.onBeforeCompile = (e) => {
1259
- e.uniforms.capRadius = { value: t }, e.vertexShader = Vn(e.vertexShader), e.fragmentShader = Hn(e.fragmentShader);
1451
+ e.uniforms.capRadius = { value: t }, e.vertexShader = cr(e.vertexShader), e.fragmentShader = lr(e.fragmentShader);
1260
1452
  }, r.customProgramCacheKey = () => "bravais-bond-tubes", r;
1261
1453
  }
1262
- function Wn(e) {
1454
+ function dr(e) {
1263
1455
  return new y({
1264
- color: Nn,
1456
+ color: er,
1265
1457
  opacity: e,
1266
1458
  transparent: !0,
1267
1459
  fog: !1
1268
1460
  });
1269
1461
  }
1270
- function Gn(e, n) {
1271
- return new T({
1462
+ function fr(e, n) {
1463
+ return new S({
1272
1464
  color: e,
1273
1465
  metalness: 0,
1274
1466
  roughness: .8,
@@ -1276,35 +1468,32 @@ function Gn(e, n) {
1276
1468
  stencilWrite: !0,
1277
1469
  stencilRef: n,
1278
1470
  stencilFunc: t,
1279
- stencilZPass: ae
1471
+ stencilZPass: le
1280
1472
  });
1281
1473
  }
1282
1474
  //#endregion
1283
1475
  //#region src/render/gizmo.ts
1284
- var Kn = {
1476
+ var pr = {
1285
1477
  a: "#d27686",
1286
1478
  b: "#80c393",
1287
1479
  c: "#75a4dd"
1288
- }, qn = .82, Jn = .055, Yn = .24, Xn = .13, Zn = .13, Qn = 1.3, $n = .5, er = 128, tr = "#2a2a2a", nr = "#ffffff", rr = 3.2, ir = new M(0, 1, 0);
1289
- function ar(e, t) {
1480
+ }, mr = .82, hr = .055, gr = .24, _r = .13, vr = .13, yr = 1.3, br = .5, xr = 128, Sr = "#2a2a2a", Cr = "#ffffff", wr = 3.2, Tr = new O(0, 1, 0);
1481
+ function Er(e, t) {
1290
1482
  let n = document.createElement("canvas");
1291
- n.width = er, n.height = er;
1483
+ n.width = xr, n.height = xr;
1292
1484
  let r = n.getContext("2d");
1293
- if (r) {
1294
- let i = er * .68;
1295
- r.clearRect(0, 0, n.width, n.height), r.font = `italic 600 ${i}px ${t}`, r.textAlign = "center", r.textBaseline = "middle", r.fillStyle = "#ffffff", r.fillText(e, n.width / 2, n.height / 2);
1296
- }
1485
+ r && (r.font = `italic 600 ${xr * .68}px ${t}`, r.textAlign = "center", r.textBaseline = "middle", r.fillStyle = "#ffffff", r.fillText(e, n.width / 2, n.height / 2));
1297
1486
  let i = new o(n);
1298
- return i.colorSpace = oe, i.premultiplyAlpha = !0, i.magFilter = x, i.minFilter = te, i;
1487
+ return i.colorSpace = ue, i.premultiplyAlpha = !0, i.magFilter = ne, i.minFilter = re, i;
1299
1488
  }
1300
- function or(e, t, n) {
1301
- let r = new _(), i = Gn(e, 1), a = new w(new u(Jn, Jn, qn, 24), i);
1302
- a.position.y = qn / 2;
1303
- let o = new w(new c(Xn, Yn, 32), i);
1489
+ function Dr(e, t, n) {
1490
+ let r = new _(), i = fr(e, 1), a = new x(new u(hr, hr, mr, 24), i);
1491
+ a.position.y = mr / 2;
1492
+ let o = new x(new c(_r, gr, 32), i);
1304
1493
  o.position.y = .94, r.add(a, o);
1305
- let s = ar(t, n), l = [[tr, D], [nr, m]];
1494
+ let s = Er(t, n), l = [[Sr, oe], [Cr, m]];
1306
1495
  for (let [e, t] of l) {
1307
- let n = new le(new ue({
1496
+ let n = new pe(new me({
1308
1497
  map: s,
1309
1498
  color: e,
1310
1499
  depthTest: !1,
@@ -1314,49 +1503,46 @@ function or(e, t, n) {
1314
1503
  stencilRef: 1,
1315
1504
  stencilFunc: t
1316
1505
  }));
1317
- n.scale.set($n, $n, 1), n.position.y = Qn, n.renderOrder = 10, r.add(n);
1506
+ n.scale.set(br, br, 1), n.position.y = yr, n.renderOrder = 10, r.add(n);
1318
1507
  }
1319
1508
  return r;
1320
1509
  }
1321
- var sr = class {
1322
- scene = new se();
1323
- camera = new k(-1, 1, 1, -1, .1, 20);
1510
+ var Or = class {
1511
+ scene = new de();
1512
+ camera = new T(-3.2 / 2, wr / 2, wr / 2, -3.2 / 2, .1, 20);
1324
1513
  axes = new _();
1325
1514
  arrows;
1326
1515
  headlight = new f("#ffffff", 1.78);
1327
- inverse = new A();
1328
- direction = new M();
1516
+ direction = new O();
1329
1517
  constructor(e) {
1330
1518
  this.camera.position.set(0, 0, 5), this.camera.lookAt(0, 0, 0), this.scene.add(new n("#ffffff", .68)), this.headlight.position.set(1.6, 1.1, 5), this.scene.add(this.headlight), this.arrows = [
1331
1519
  "a",
1332
1520
  "b",
1333
1521
  "c"
1334
- ].map((t) => or(Kn[t], t, e));
1335
- let t = new w(new ce(Zn, 32, 16), Gn("#f3f2ee", 0));
1522
+ ].map((t) => Dr(pr[t], t, e));
1523
+ let t = new x(new fe(vr, 32, 16), fr("#f3f2ee", 0));
1336
1524
  this.axes.add(...this.arrows, t), this.scene.add(this.axes);
1337
1525
  }
1338
1526
  setCell(e) {
1339
1527
  this.arrows.forEach((t, n) => {
1340
- t.quaternion.setFromUnitVectors(ir, this.direction.set(...e[n]).normalize());
1528
+ t.quaternion.setFromUnitVectors(Tr, this.direction.set(...e[n]).normalize());
1341
1529
  });
1342
1530
  }
1343
1531
  render(e, t, n) {
1344
- this.axes.quaternion.copy(this.inverse.copy(t).invert());
1345
- let r = rr / 2;
1346
- this.camera.left = -1.6, this.camera.right = r, this.camera.top = r, this.camera.bottom = -1.6, this.camera.updateProjectionMatrix();
1347
- let i = e.autoClear;
1348
- e.autoClear = !1, e.setViewport(0, 0, n, n), e.setScissor(0, 0, n, n), e.setScissorTest(!0), e.clear(!1, !0, !0), e.render(this.scene, this.camera), e.setScissorTest(!1), e.autoClear = i;
1532
+ this.axes.quaternion.copy(t).invert();
1533
+ let r = e.autoClear;
1534
+ e.autoClear = !1, e.setViewport(0, 0, n, n), e.setScissor(0, 0, n, n), e.setScissorTest(!0), e.clear(!1, !0, !0), e.render(this.scene, this.camera), e.setScissorTest(!1), e.autoClear = r;
1349
1535
  }
1350
1536
  dispose() {
1351
1537
  this.axes.traverse((e) => {
1352
- if (e instanceof w || e instanceof le) {
1538
+ if (e instanceof x || e instanceof pe) {
1353
1539
  e.geometry.dispose();
1354
1540
  let t = e.material;
1355
1541
  "map" in t && t.map && t.map.dispose(), t.dispose();
1356
1542
  }
1357
1543
  }), this.axes.clear();
1358
1544
  }
1359
- }, cr = {
1545
+ }, kr = {
1360
1546
  source: "VESTA's element colours, softened.",
1361
1547
  elements: {
1362
1548
  H: "#f2c0c0",
@@ -1460,21 +1646,21 @@ var sr = class {
1460
1646
  };
1461
1647
  //#endregion
1462
1648
  //#region src/render/oklab.ts
1463
- function lr(e) {
1649
+ function Ar(e) {
1464
1650
  return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
1465
1651
  }
1466
- function ur(e) {
1652
+ function jr(e) {
1467
1653
  return e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
1468
1654
  }
1469
- function dr(e) {
1470
- let t = Number.parseInt(e.slice(1), 16), n = lr((t >> 16 & 255) / 255), r = lr((t >> 8 & 255) / 255), i = lr((t & 255) / 255), a = Math.cbrt(.4122214708 * n + .5363325363 * r + .0514459929 * i), o = Math.cbrt(.2119034982 * n + .6806995451 * r + .1073969566 * i), s = Math.cbrt(.0883024619 * n + .2817188376 * r + .6299787005 * i);
1655
+ function Mr(e) {
1656
+ let t = Number.parseInt(e.slice(1), 16), n = Ar((t >> 16 & 255) / 255), r = Ar((t >> 8 & 255) / 255), i = Ar((t & 255) / 255), a = Math.cbrt(.4122214708 * n + .5363325363 * r + .0514459929 * i), o = Math.cbrt(.2119034982 * n + .6806995451 * r + .1073969566 * i), s = Math.cbrt(.0883024619 * n + .2817188376 * r + .6299787005 * i);
1471
1657
  return {
1472
1658
  L: .2104542553 * a + .793617785 * o - .0040720468 * s,
1473
1659
  a: 1.9779984951 * a - 2.428592205 * o + .4505937099 * s,
1474
1660
  b: .0259040371 * a + .7827717662 * o - .808675766 * s
1475
1661
  };
1476
1662
  }
1477
- function fr(e) {
1663
+ function Nr(e) {
1478
1664
  let t = (e.L + .3963377774 * e.a + .2158037573 * e.b) ** 3, n = (e.L - .1055613458 * e.a - .0638541728 * e.b) ** 3, r = (e.L - .0894841775 * e.a - 1.291485548 * e.b) ** 3;
1479
1665
  return [
1480
1666
  4.0767416621 * t - 3.3077115913 * n + .2309699292 * r,
@@ -1482,16 +1668,16 @@ function fr(e) {
1482
1668
  -.0041960863 * t - .7034186147 * n + 1.707614701 * r
1483
1669
  ];
1484
1670
  }
1485
- function pr(e) {
1486
- return fr(e).every((e) => e >= -1e-4 && e <= 1.0001);
1671
+ function Pr(e) {
1672
+ return Nr(e).every((e) => e >= -1e-4 && e <= 1.0001);
1487
1673
  }
1488
- function mr(e) {
1489
- return `#${fr(e).map((e) => {
1490
- let t = ur(Math.min(1, Math.max(0, e)));
1674
+ function Fr(e) {
1675
+ return `#${Nr(e).map((e) => {
1676
+ let t = jr(Math.min(1, Math.max(0, e)));
1491
1677
  return Math.round(t * 255).toString(16).padStart(2, "0");
1492
1678
  }).join("")}`;
1493
1679
  }
1494
- function hr(e) {
1680
+ function Ir(e) {
1495
1681
  let t = Math.hypot(e.a, e.b), n = (Math.atan2(e.b, e.a) * 180 / Math.PI + 360) % 360;
1496
1682
  return {
1497
1683
  L: e.L,
@@ -1499,7 +1685,7 @@ function hr(e) {
1499
1685
  h: n
1500
1686
  };
1501
1687
  }
1502
- function gr(e) {
1688
+ function Lr(e) {
1503
1689
  let t = e.h * Math.PI / 180;
1504
1690
  return {
1505
1691
  L: e.L,
@@ -1507,12 +1693,12 @@ function gr(e) {
1507
1693
  b: e.C * Math.sin(t)
1508
1694
  };
1509
1695
  }
1510
- function _r(e) {
1511
- if (pr(gr(e))) return e;
1696
+ function Rr(e) {
1697
+ if (Pr(Lr(e))) return e;
1512
1698
  let t = 0, n = e.C;
1513
1699
  for (let r = 0; r < 24; r += 1) {
1514
1700
  let r = (t + n) / 2;
1515
- pr(gr({
1701
+ Pr(Lr({
1516
1702
  ...e,
1517
1703
  C: r
1518
1704
  })) ? t = r : n = r;
@@ -1524,15 +1710,15 @@ function _r(e) {
1524
1710
  }
1525
1711
  //#endregion
1526
1712
  //#region src/render/palette.ts
1527
- var vr = cr.elements, yr = {
1713
+ var zr = kr.elements, Br = {
1528
1714
  Cr: "#6d87c9",
1529
1715
  V: "#bf4b62",
1530
1716
  F: "#9bd7d0"
1531
- }, br = /* @__PURE__ */ "O.Li.Na.K.Mg.Ca.Sr.Ba.Al.Si.Ti.Mn.Fe.Co.Ni.Cu.Zn.V.Cr.Ga.Ge.Y.Zr.Nb.Mo.Ru.Ag.Cd.In.Sn.Sb.La.Ce.Nd.Sm.Gd.Ta.W.Pt.Au.Pb.Bi.H.C.N.F.P.S.Cl.Se.Te.I.Br.B.Sc.Rb.Cs.Hf.Re.Ir.Pd.Rh.Os.Pr.Eu.Tb.Dy.Ho.Er.Tm.Yb.Lu.Th.U".split("."), xr = new Map(br.map((e, t) => [e, t])), Sr = .1, Cr = .7, X = {
1717
+ }, Vr = /* @__PURE__ */ "O.Li.Na.K.Mg.Ca.Sr.Ba.Al.Si.Ti.Mn.Fe.Co.Ni.Cu.Zn.V.Cr.Ga.Ge.Y.Zr.Nb.Mo.Ru.Ag.Cd.In.Sn.Sb.La.Ce.Nd.Sm.Gd.Ta.W.Pt.Au.Pb.Bi.H.C.N.F.P.S.Cl.Se.Te.I.Br.B.Sc.Rb.Cs.Hf.Re.Ir.Pd.Rh.Os.Pr.Eu.Tb.Dy.Ho.Er.Tm.Yb.Lu.Th.U".split("."), Hr = new Map(Vr.map((e, t) => [e, t])), Ur = .1, Wr = .7, Z = {
1532
1718
  minL: .45,
1533
1719
  maxL: .88,
1534
1720
  maxC: .2
1535
- }, wr = .025, Tr = .09, Er = .1, Dr = [
1721
+ }, Gr = .025, Kr = .09, qr = .1, Jr = [
1536
1722
  0,
1537
1723
  10,
1538
1724
  -10,
@@ -1553,7 +1739,7 @@ var vr = cr.elements, yr = {
1553
1739
  150,
1554
1740
  -150,
1555
1741
  180
1556
- ], Or = [
1742
+ ], Yr = [
1557
1743
  0,
1558
1744
  -.05,
1559
1745
  .05,
@@ -1563,12 +1749,12 @@ var vr = cr.elements, yr = {
1563
1749
  .15,
1564
1750
  -.2,
1565
1751
  .2
1566
- ], kr = [
1752
+ ], Xr = [
1567
1753
  0,
1568
1754
  .15,
1569
1755
  -.15,
1570
1756
  .3
1571
- ], Ar = [
1757
+ ], Zr = [
1572
1758
  0,
1573
1759
  30,
1574
1760
  60,
@@ -1581,78 +1767,76 @@ var vr = cr.elements, yr = {
1581
1767
  270,
1582
1768
  300,
1583
1769
  330
1584
- ], jr = 30, Mr = .08, Nr = .15, Pr = 1.5, Fr = 2;
1585
- function Ir(e, t) {
1586
- let n = (e.L - t.L) * Cr;
1770
+ ], Qr = 30, $r = .08, ei = .15, ti = 1.5, ni = 2;
1771
+ function ri(e, t) {
1772
+ let n = (e.L - t.L) * Wr;
1587
1773
  return Math.hypot(n, e.a - t.a, e.b - t.b);
1588
1774
  }
1589
- function Lr(e) {
1775
+ function ii(e) {
1590
1776
  let t = 2166136261;
1591
1777
  for (let n = 0; n < e.length; n += 1) t = Math.imul(t ^ e.charCodeAt(n), 16777619) >>> 0;
1592
1778
  return t;
1593
1779
  }
1594
- function Rr(e) {
1595
- return yr[e] ?? vr[e] ?? null;
1780
+ function ai(e) {
1781
+ return Br[e] ?? zr[e] ?? null;
1596
1782
  }
1597
- function zr(e) {
1598
- let t = Rr(e);
1599
- if (t) return hr(dr(t));
1600
- let n = _e.indexOf(e) + 1;
1783
+ function oi(e) {
1784
+ let t = ai(e);
1785
+ if (t) return Ir(Mr(t));
1786
+ let n = Ce.indexOf(e) + 1;
1601
1787
  return {
1602
1788
  L: .68,
1603
1789
  C: .12,
1604
- h: (n > 0 ? n : Lr(e)) * 137.508 % 360
1790
+ h: (n > 0 ? n : ii(e)) * 137.508 % 360
1605
1791
  };
1606
1792
  }
1607
- function Br(e) {
1608
- let t = xr.get(e);
1793
+ function si(e) {
1794
+ let t = Hr.get(e);
1609
1795
  if (t !== void 0) return t;
1610
- let n = _e.indexOf(e);
1611
- return br.length + (n >= 0 ? n : _e.length);
1796
+ let n = Ce.indexOf(e);
1797
+ return Vr.length + (n >= 0 ? n : Ce.length);
1612
1798
  }
1613
- function Vr(e) {
1614
- return _r({
1615
- L: Math.min(X.maxL, Math.max(X.minL, e.L)),
1616
- C: Math.min(X.maxC, Math.max(0, e.C)),
1799
+ function ci(e) {
1800
+ return Rr({
1801
+ L: Math.min(Z.maxL, Math.max(Z.minL, e.L)),
1802
+ C: Math.min(Z.maxC, Math.max(0, e.C)),
1617
1803
  h: (e.h % 360 + 360) % 360
1618
1804
  });
1619
1805
  }
1620
- function Hr(e, t) {
1621
- return _r({
1806
+ function li(e, t) {
1807
+ return Rr({
1622
1808
  L: e,
1623
1809
  C: .5,
1624
1810
  h: t
1625
1811
  }).C;
1626
1812
  }
1627
- function Ur(e, t) {
1628
- let n = Vr(e);
1813
+ function ui(e, t) {
1629
1814
  return {
1630
- lch: n,
1631
- lab: gr(n),
1815
+ lab: Lr(ci(e)),
1632
1816
  cost: t
1633
1817
  };
1634
1818
  }
1635
- function Wr(e) {
1819
+ function di(e) {
1636
1820
  let t = [];
1637
- if (e.C < wr) {
1638
- for (let n of Or) {
1639
- let r = Math.abs(n) / Mr * (n > 0 ? Pr : 1);
1640
- t.push(Ur({
1821
+ if (e.C < Gr) {
1822
+ for (let n of Yr) {
1823
+ let r = Math.abs(n) / $r * (n > 0 ? ti : 1);
1824
+ t.push(ui({
1641
1825
  ...e,
1642
1826
  L: e.L + n
1643
1827
  }, r));
1644
- for (let i of Ar) t.push(Ur({
1645
- L: e.L - Er + n,
1646
- C: Tr,
1828
+ for (let i of Zr) t.push(ui({
1829
+ L: e.L - qr + n,
1830
+ C: Kr,
1647
1831
  h: i
1648
- }, Fr + r + i / 3600));
1832
+ }, ni + r + i / 3600));
1649
1833
  }
1650
1834
  return t.sort((e, t) => e.cost - t.cost);
1651
1835
  }
1652
- let n = e.C / Math.max(1e-6, Hr(e.L, e.h));
1653
- for (let r of Dr) for (let i of Or) for (let a of kr) {
1654
- let o = Math.min(X.maxL, Math.max(X.minL, e.L + i)), s = e.h + r, c = Math.min(1, Math.max(.1, n + a)) * Hr(o, s), l = Math.abs(r) / jr + Math.abs(i) / Mr + Math.abs(a) / Nr;
1655
- t.push(Ur({
1836
+ let n = e.C / Math.max(1e-6, li(e.L, e.h));
1837
+ for (let r of Jr) for (let i of Yr) for (let a of Xr) {
1838
+ let o = Math.min(Z.maxL, Math.max(Z.minL, e.L + i)), s = e.h + r, c = Math.min(1, Math.max(.1, n + a)) * li(o, s), l = Math.abs(r) / Qr + Math.abs(i) / $r + Math.abs(a) / ei;
1839
+ t.push(ui({
1656
1840
  L: o,
1657
1841
  C: c,
1658
1842
  h: s
@@ -1660,56 +1844,55 @@ function Wr(e) {
1660
1844
  }
1661
1845
  return t.sort((e, t) => e.cost - t.cost);
1662
1846
  }
1663
- var Z = /* @__PURE__ */ new Map();
1664
- function Gr(e, t) {
1665
- let n = [...Z.values()].map((e) => e.lab), r = (e) => n.reduce((t, n) => Math.min(t, Ir(e, n)), Infinity), i = gr(t);
1666
- if (r(i) >= Sr) return {
1667
- hex: e ?? mr(i),
1847
+ var Q = /* @__PURE__ */ new Map();
1848
+ function fi(e, t) {
1849
+ let n = [...Q.values()].map((e) => e.lab), r = (e) => n.reduce((t, n) => Math.min(t, ri(e, n)), Infinity), i = Lr(t);
1850
+ if (r(i) >= Ur) return {
1851
+ hex: e ?? Fr(i),
1668
1852
  lab: i
1669
1853
  };
1670
1854
  let a = null, o = -Infinity, s = Infinity, c = null, l = -Infinity;
1671
- for (let e of Wr(t)) {
1855
+ for (let e of di(t)) {
1672
1856
  let t = r(e.lab);
1673
- if (t >= Sr) {
1857
+ if (t >= Ur) {
1674
1858
  if ((e.cost < s - 1e-9 || Math.abs(e.cost - s) <= 1e-9 && t > o) && (a = e, s = e.cost, o = t), e.cost > s + 1e-9) break;
1675
1859
  } else t > l && (c = e, l = t);
1676
1860
  }
1677
1861
  let u = a ?? c ?? {
1678
1862
  lab: i,
1679
- lch: t,
1680
1863
  cost: 0
1681
1864
  };
1682
1865
  return {
1683
- hex: mr(u.lab),
1866
+ hex: Fr(u.lab),
1684
1867
  lab: u.lab
1685
1868
  };
1686
1869
  }
1687
- function Kr(e) {
1688
- let t = [...new Set(e)].filter((e) => !Z.has(e)).sort((e, t) => Br(e) - Br(t));
1689
- for (let e of t) Z.set(e, Gr(Rr(e), zr(e)));
1870
+ function pi(e) {
1871
+ let t = [...new Set(e)].filter((e) => !Q.has(e)).sort((e, t) => si(e) - si(t));
1872
+ for (let e of t) Q.set(e, fi(ai(e), oi(e)));
1690
1873
  }
1691
- function qr(e) {
1692
- let t = Z.get(e);
1693
- return t ? t.hex : (Kr([e]), Z.get(e).hex);
1874
+ function mi(e) {
1875
+ let t = Q.get(e);
1876
+ return t ? t.hex : (pi([e]), Q.get(e).hex);
1694
1877
  }
1695
- function Jr() {
1696
- return [...Z].map(([e, t]) => [e, t.hex]);
1878
+ function hi() {
1879
+ return [...Q].map(([e, t]) => [e, t.hex]);
1697
1880
  }
1698
- function Yr() {
1699
- Z.clear();
1881
+ function gi() {
1882
+ Q.clear();
1700
1883
  }
1701
1884
  //#endregion
1702
1885
  //#region src/render/legend.ts
1703
- var Xr = "bravais-styles", Zr = "\n.bravais-viewer {\n position: relative;\n overflow: hidden;\n}\n.bravais-canvas {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n display: block;\n touch-action: none;\n}\n.bravais-legend {\n position: absolute;\n left: 50%;\n bottom: 20px;\n transform: translateX(-50%);\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 8px 16px;\n max-width: calc(100% - 32px);\n padding: 8px 16px;\n border: 1px solid rgba(40, 40, 40, 0.1);\n border-radius: 999px;\n background: rgba(255, 255, 255, 0.72);\n backdrop-filter: blur(24px) saturate(150%);\n box-shadow: 0 10px 15px -3px rgba(40, 40, 40, 0.1);\n font-family: inherit;\n font-size: 0.95rem;\n line-height: 1;\n color: #282828;\n pointer-events: none;\n}\n.bravais-legend[hidden] {\n display: none;\n}\n.bravais-legend-item {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.bravais-legend-swatch {\n width: 18px;\n height: 18px;\n border-radius: 50%;\n border: 1px solid rgba(40, 40, 40, 0.1);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);\n}\n";
1704
- function Qr(e) {
1705
- if (e.getElementById(Xr)) return;
1886
+ var _i = "bravais-styles", vi = "\n.bravais-viewer {\n position: relative;\n overflow: hidden;\n}\n.bravais-canvas {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n display: block;\n touch-action: none;\n}\n.bravais-legend {\n position: absolute;\n left: 50%;\n bottom: 20px;\n transform: translateX(-50%);\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 8px 16px;\n max-width: calc(100% - 32px);\n padding: 8px 16px;\n border: 1px solid rgba(40, 40, 40, 0.1);\n border-radius: 999px;\n background: rgba(255, 255, 255, 0.72);\n backdrop-filter: blur(24px) saturate(150%);\n box-shadow: 0 10px 15px -3px rgba(40, 40, 40, 0.1);\n font-family: inherit;\n font-size: 0.95rem;\n line-height: 1;\n color: #282828;\n pointer-events: none;\n}\n.bravais-legend[hidden] {\n display: none;\n}\n.bravais-legend-item {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.bravais-legend-swatch {\n width: 18px;\n height: 18px;\n border-radius: 50%;\n border: 1px solid rgba(40, 40, 40, 0.1);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);\n}\n";
1887
+ function yi(e) {
1888
+ if (e.getElementById(_i)) return;
1706
1889
  let t = e.createElement("style");
1707
- t.id = Xr, t.textContent = Zr, e.head.appendChild(t);
1890
+ t.id = _i, t.textContent = vi, e.head.appendChild(t);
1708
1891
  }
1709
- function $r(e) {
1892
+ function bi(e) {
1710
1893
  return `linear-gradient(135deg, rgba(255, 255, 255, 0.38) 0 14%, rgba(255, 255, 255, 0) 42%), ${e}`;
1711
1894
  }
1712
- var ei = class {
1895
+ var xi = class {
1713
1896
  element;
1714
1897
  constructor(e) {
1715
1898
  this.element = e.createElement("div"), this.element.className = "bravais-legend", this.element.hidden = !0;
@@ -1720,17 +1903,17 @@ var ei = class {
1720
1903
  let e = this.element.ownerDocument.createElement("span");
1721
1904
  e.className = "bravais-legend-item";
1722
1905
  let n = this.element.ownerDocument.createElement("span");
1723
- n.className = "bravais-legend-swatch", n.style.background = $r(qr(t));
1906
+ n.className = "bravais-legend-swatch", n.style.background = bi(mi(t));
1724
1907
  let r = this.element.ownerDocument.createElement("span");
1725
1908
  r.textContent = t, e.append(n, r), this.element.appendChild(e);
1726
1909
  }
1727
1910
  this.element.hidden = e.length === 0;
1728
1911
  }
1729
- }, Q = .4, $ = .1, ti = .398, ni = Math.sqrt(ti * ti - $ * $), ri = new M(0, 1, 0);
1730
- function ii(e) {
1731
- let [t, n, r] = e.map((e) => new M(...e));
1912
+ }, $ = .4, Si = .1, Ci = .398, wi = Math.sqrt(Ci * Ci - Si * Si), Ti = new O(0, 1, 0);
1913
+ function Ei(e) {
1914
+ let [t, n, r] = e.map((e) => new O(...e));
1732
1915
  return [
1733
- new M(),
1916
+ new O(),
1734
1917
  t.clone(),
1735
1918
  n.clone(),
1736
1919
  r.clone(),
@@ -1740,7 +1923,7 @@ function ii(e) {
1740
1923
  t.clone().add(n).add(r)
1741
1924
  ];
1742
1925
  }
1743
- function ai(e) {
1926
+ function Di(e) {
1744
1927
  let [t, n, r] = e;
1745
1928
  return [
1746
1929
  (t[0] + n[0] + r[0]) / 2,
@@ -1748,7 +1931,7 @@ function ai(e) {
1748
1931
  (t[2] + n[2] + r[2]) / 2
1749
1932
  ];
1750
1933
  }
1751
- var oi = [
1934
+ var Oi = [
1752
1935
  [0, 1],
1753
1936
  [0, 2],
1754
1937
  [0, 3],
@@ -1762,107 +1945,106 @@ var oi = [
1762
1945
  [5, 7],
1763
1946
  [6, 7]
1764
1947
  ];
1765
- function si(e, t) {
1766
- let n = ii(e), r = [];
1767
- for (let [e, t] of oi) {
1948
+ function ki(e, t) {
1949
+ let n = Ei(e), r = [];
1950
+ for (let [e, t] of Oi) {
1768
1951
  let i = n[e], a = n[t];
1769
1952
  r.push(i.x, i.y, i.z, a.x, a.y, a.z);
1770
1953
  }
1771
1954
  let i = new a();
1772
- return i.setAttribute("position", new h(r, 3)), new b(i, Wn(t));
1955
+ return i.setAttribute("position", new h(r, 3)), new te(i, dr(t));
1773
1956
  }
1774
- function ci(e) {
1775
- let t = 2048, n = Math.max(1, Math.ceil(e.length / 256)), r = new Float32Array(t * n * 4).fill(1), i = new s(Pn), a = new s(), o = !1;
1957
+ function Ai(e) {
1958
+ let t = 2048, n = Math.max(1, Math.ceil(e.length / 256)), r = new Float32Array(t * n * 4).fill(1), i = new s(tr), a = new s(), o = !1;
1776
1959
  e.forEach((e, n) => {
1777
1960
  let s = Math.floor(n / 256), c = n % 256 * 8, l = (s * t + c) * 4, u = 0, d = Math.min(1, e.species[0]?.occupancy ?? 1);
1778
- for (let t of e.species.slice(1)) u < 7 && (a.set(qr(t.element)).toArray(r, l), r[l + 3] = d, l += 4, u += 1), d = Math.min(1, d + t.occupancy);
1961
+ for (let t of e.species.slice(1)) u < 7 && (a.set(mi(t.element)).toArray(r, l), r[l + 3] = d, l += 4, u += 1), d = Math.min(1, d + t.occupancy);
1779
1962
  d < 1 - 1e-6 && (i.toArray(r, l), r[l + 3] = d + 2, o = !0);
1780
1963
  });
1781
- let c = new d(r, t, n, ie, g);
1782
- return c.magFilter = E, c.minFilter = E, c.generateMipmaps = !1, c.needsUpdate = !0, {
1964
+ let c = new d(r, t, n, ce, g);
1965
+ return c.magFilter = C, c.minFilter = C, c.generateMipmaps = !1, c.needsUpdate = !0, {
1783
1966
  texture: c,
1784
1967
  hasVacancies: o
1785
1968
  };
1786
1969
  }
1787
- function li() {
1970
+ function ji() {
1788
1971
  let e = /* @__PURE__ */ new Map();
1789
1972
  return (t) => {
1790
1973
  let n = e.get(t);
1791
- return n || (n = new s(qr(t)), e.set(t, n)), n;
1974
+ return n || (n = new s(mi(t)), e.set(t, n)), n;
1792
1975
  };
1793
1976
  }
1794
- function ui(e, t, n = li()) {
1795
- let r = new re(2, 2), i = ci(e), a = new v(r, Bn(t, i.texture, i.hasVacancies), e.length), o = new C();
1977
+ function Mi(e, t, n = ji()) {
1978
+ let r = new se(2, 2), i = Ai(e), a = new v(r, sr(t, i.texture, i.hasVacancies), e.length), o = new ae();
1796
1979
  return e.forEach((e, t) => {
1797
- o.makeScale(Q, Q, Q), o.setPosition(e.position[0], e.position[1], e.position[2]), a.setMatrixAt(t, o), a.setColorAt(t, n(e.element));
1980
+ o.makeScale($, $, $), o.setPosition(e.position[0], e.position[1], e.position[2]), a.setMatrixAt(t, o), a.setColorAt(t, n(e.element));
1798
1981
  }), a.instanceMatrix.needsUpdate = !0, a.instanceColor && (a.instanceColor.needsUpdate = !0), a.userData.sectorTexture = i.texture, a;
1799
1982
  }
1800
- function di(e, t, n = li()) {
1983
+ function Ni(e, t, n = ji()) {
1801
1984
  if (e.bonds.length === 0) return null;
1802
- let r = new i(2, 1, 2), a = new v(r, Un(t, ti), e.bonds.length * 2), o = new O(), s = new M(), c = new M(), l = new M(), u = new A();
1985
+ let r = new i(2, 1, 2), a = new v(r, ur(t, Ci), e.bonds.length * 2), o = new w(), s = new O(), c = new O(), l = new O(), u = new E();
1803
1986
  return e.bonds.forEach((t, r) => {
1804
1987
  let i = e.atoms[t.start], d = e.atoms[t.end];
1805
1988
  s.set(...i.position), c.set(...d.position), l.subVectors(c, s);
1806
1989
  let f = l.length() / 2;
1807
- l.normalize(), u.setFromUnitVectors(ri, l);
1990
+ l.normalize(), u.setFromUnitVectors(Ti, l);
1808
1991
  let p = [[
1809
1992
  0,
1810
1993
  i,
1811
- ni,
1994
+ wi,
1812
1995
  f
1813
1996
  ], [
1814
1997
  1,
1815
1998
  d,
1816
1999
  f,
1817
- 2 * f - ni
2000
+ 2 * f - wi
1818
2001
  ]];
1819
2002
  for (let [e, t, i, c] of p) {
1820
2003
  let d = Math.max(0, c - i);
1821
- o.position.copy(s).addScaledVector(l, i + d / 2), o.quaternion.copy(u), o.scale.set($, d, $), o.updateMatrix(), a.setMatrixAt(r * 2 + e, o.matrix), a.setColorAt(r * 2 + e, n(t.element));
2004
+ o.position.copy(s).addScaledVector(l, i + d / 2), o.quaternion.copy(u), o.scale.set(Si, d, Si), o.updateMatrix(), a.setMatrixAt(r * 2 + e, o.matrix), a.setColorAt(r * 2 + e, n(t.element));
1822
2005
  }
1823
2006
  }), a.instanceMatrix.needsUpdate = !0, a.instanceColor && (a.instanceColor.needsUpdate = !0), a;
1824
2007
  }
1825
- function fi(e) {
2008
+ function Pi(e) {
1826
2009
  let t = e[0];
1827
2010
  if (!t) throw Error("A scene model needs at least one layer.");
1828
- Kr(e.flatMap((e) => [...e.scene.elements, ...e.scene.atoms.map((e) => e.element)]));
1829
- let n = ai(t.scene.cell), i = new _();
2011
+ pi(e.flatMap((e) => [...e.scene.elements, ...e.scene.atoms.map((e) => e.element)]));
2012
+ let n = Di(t.scene.cell), i = new _();
1830
2013
  i.position.set(-n[0], -n[1], -n[2]);
1831
- let a = new r(), o = [], s = 1, c = [], l = new M(...n), u = new M(), d = new M();
2014
+ let a = new r(), o = [], s = 1, c = [], l = new O(...n), u = new O(), d = new O();
1832
2015
  for (let t of e) {
1833
- for (let e of ii(t.scene.cell)) a.expandByPoint(e.sub(l));
1834
- for (let e of t.scene.atoms) u.set(...e.position).sub(l), a.expandByPoint(d.copy(u).addScalar(Q)), a.expandByPoint(d.copy(u).subScalar(Q));
2016
+ for (let e of Ei(t.scene.cell)) a.expandByPoint(e.sub(l));
2017
+ for (let e of t.scene.atoms) u.set(...e.position).sub(l), a.expandByPoint(d.copy(u).addScalar($)), a.expandByPoint(d.copy(u).subScalar($));
1835
2018
  for (let e of t.scene.cell) s = Math.max(s, Math.hypot(...e));
1836
2019
  let e = t.opacity ?? 1;
1837
2020
  if (e <= 0) continue;
1838
- let n = ui(t.scene.atoms, e);
2021
+ let n = Mi(t.scene.atoms, e);
1839
2022
  i.add(n), c.push(n);
1840
- let r = di(t.scene, e);
2023
+ let r = Ni(t.scene, e);
1841
2024
  r && (i.add(r), c.push(r));
1842
- let f = si(t.scene.cell, e);
2025
+ let f = ki(t.scene.cell, e);
1843
2026
  i.add(f), c.push(f);
1844
2027
  for (let e of t.scene.elements) o.includes(e) || o.push(e);
1845
2028
  }
1846
2029
  return {
1847
2030
  group: i,
1848
2031
  cell: t.scene.cell,
1849
- center: n,
1850
2032
  bounds: a,
1851
2033
  span: s,
1852
2034
  elements: o,
1853
2035
  dispose() {
1854
- pi(c), i.clear();
2036
+ Fi(c), i.clear();
1855
2037
  }
1856
2038
  };
1857
2039
  }
1858
- function pi(e) {
2040
+ function Fi(e) {
1859
2041
  for (let t of e) {
1860
2042
  t.geometry.dispose();
1861
2043
  let e = t.userData.sectorTexture;
1862
2044
  e instanceof d && e.dispose();
1863
2045
  }
1864
2046
  }
1865
- var mi = {
2047
+ var Ii = {
1866
2048
  cell: [
1867
2049
  [
1868
2050
  1,
@@ -1906,124 +2088,124 @@ var mi = {
1906
2088
  }],
1907
2089
  elements: []
1908
2090
  };
1909
- function hi() {
2091
+ function Li() {
1910
2092
  let e = new s("#ffffff"), t = [];
1911
- for (let n of [1, .5]) t.push(ui(mi.atoms, n, () => e), di(mi, n, () => e));
1912
- t.push(si(mi.cell, 1));
2093
+ for (let n of [1, .5]) t.push(Mi(Ii.atoms, n, () => e), Ni(Ii, n, () => e));
2094
+ t.push(ki(Ii.cell, 1));
1913
2095
  let n = new _();
1914
2096
  return n.add(...t), {
1915
2097
  group: n,
1916
- dispose: () => pi(t)
2098
+ dispose: () => Fi(t)
1917
2099
  };
1918
2100
  }
1919
2101
  //#endregion
1920
2102
  //#region src/render/stage.ts
1921
- function gi(t = {}) {
1922
- let r = new N({
2103
+ function Ri(t = {}) {
2104
+ let r = new he({
1923
2105
  antialias: !0,
1924
2106
  alpha: !0,
1925
2107
  stencil: t.stencil ?? !1
1926
2108
  });
1927
- r.setClearColor(Mn, 1), r.toneMapping = e;
1928
- let i = new se(), a = new k(-1, 1, 1, -1, .01, 1e3), o = new f("#ffffff", An);
1929
- i.add(new n("#ffffff", kn), o, o.target);
1930
- let s = new M();
2109
+ r.setClearColor($n, 1), r.toneMapping = e;
2110
+ let i = new de(), a = new T(-1, 1, 1, -1, .01, 1e3), o = new f("#ffffff", Zn);
2111
+ i.add(new n("#ffffff", Xn), o, o.target);
2112
+ let s = new O();
1931
2113
  return {
1932
2114
  renderer: r,
1933
2115
  scene: i,
1934
2116
  camera: a,
1935
2117
  updateHeadlight() {
1936
2118
  let e = Math.max(a.position.length(), 4);
1937
- s.set(...jn).multiplyScalar(e).applyQuaternion(a.quaternion), o.position.copy(a.position).add(s);
2119
+ s.set(...Qn).multiplyScalar(e).applyQuaternion(a.quaternion), o.position.copy(a.position).add(s);
1938
2120
  }
1939
2121
  };
1940
2122
  }
1941
2123
  //#endregion
1942
2124
  //#region src/render/viewer.ts
1943
- var _i = .4, vi = .4, yi = .4, bi = 2, xi = 1.2, Si = .2, Ci = 1500, wi = .2, Ti = 5, Ei = 3, Di = 1e-5, Oi = 4, ki = .35, Ai = 110, ji = 180;
1944
- function Mi(e, t, n) {
1945
- let r = new M(0, 0, 1).applyQuaternion(n), i = 0, a = 0, o = new M();
2125
+ var zi = .4, Bi = .4, Vi = .4, Hi = 2, Ui = 1.2, Wi = .2, Gi = 1500, Ki = .2, qi = 5, Ji = 3, Yi = 1e-5, Xi = 4, Zi = .35, Qi = 110, $i = 180;
2126
+ function ea(e, t, n) {
2127
+ let r = new O(0, 0, 1).applyQuaternion(n), i = 0, a = 0, o = new O();
1946
2128
  for (let t of [e.bounds.min.x, e.bounds.max.x]) for (let n of [e.bounds.min.y, e.bounds.max.y]) for (let s of [e.bounds.min.z, e.bounds.max.z]) {
1947
2129
  let e = o.set(t, n, s).dot(r);
1948
2130
  i = Math.max(i, e), a = Math.min(a, e);
1949
2131
  }
1950
- let s = Math.max(1, e.span), c = Math.max(.01 * s, -a), l = Math.min(c, -i), u = s * yi, d = l - u, f = t + (d + (Math.max(d, c - u) - d) * vi), p = f + (t + c - f) / _i;
1951
- return new ee(Mn, f, p);
2132
+ let s = Math.max(1, e.span), c = Math.max(.01 * s, -a), l = Math.min(c, -i), u = s * Vi, d = l - u, f = t + (d + (Math.max(d, c - u) - d) * Bi), p = f + (t + c - f) / zi;
2133
+ return new ee($n, f, p);
1952
2134
  }
1953
- function Ni(e, t = {}) {
2135
+ function ta(e, t = {}) {
1954
2136
  let n = e.ownerDocument;
1955
- Qr(n), e.classList.add("bravais-viewer");
1956
- let { renderer: r, scene: i, camera: a, updateHeadlight: o } = gi({ stencil: !0 });
2137
+ yi(n), e.classList.add("bravais-viewer");
2138
+ let { renderer: r, scene: i, camera: a, updateHeadlight: o } = Ri({ stencil: !0 });
1957
2139
  r.setPixelRatio(n.defaultView?.devicePixelRatio ?? 1), r.domElement.className = "bravais-canvas", e.appendChild(r.domElement);
1958
- let s = t.legend === !1 ? null : new ei(n);
2140
+ let s = t.legend === !1 ? null : new xi(n);
1959
2141
  s && e.appendChild(s.element);
1960
- let c = n.defaultView?.getComputedStyle(e).fontFamily ?? "sans-serif", l = t.gizmo === !1 ? null : new sr(c), u = new Jt(a, r.domElement);
1961
- u.rotateSpeed = bi, u.zoomSpeed = xi, u.dynamicDampingFactor = Si, u.staticMoving = !1, u.noPan = !0, u.mouseButtons.LEFT = S.ROTATE, u.mouseButtons.MIDDLE = S.DOLLY, u.mouseButtons.RIGHT = null;
1962
- let d = null, f = null, p = 4, m = 1, h = 1, g = 1, _ = null, v = !1, y = 0, b = !1, x = 0, te = !1, ne = new j(), C = new A(), w = 0, T = new M(), E = /* @__PURE__ */ new Set();
1963
- function D() {
1964
- x = 0, te = !1;
1965
- for (let e of E) e();
1966
- }
1967
- function O() {
2142
+ let c = n.defaultView?.getComputedStyle(e).fontFamily ?? "sans-serif", l = t.gizmo === !1 ? null : new Or(c), u = new gn(a, r.domElement);
2143
+ u.rotateSpeed = Hi, u.zoomSpeed = Ui, u.dynamicDampingFactor = Wi, u.staticMoving = !1, u.noPan = !0, u.mouseButtons.LEFT = b.ROTATE, u.mouseButtons.MIDDLE = b.DOLLY, u.mouseButtons.RIGHT = null;
2144
+ let d = null, f = null, p = 4, m = 1, h = 1, g = 1, _ = null, v = !1, y = 0, te = !1, ne = 0, re = !1, ie = new D(), ae = new E(), x = 0, S = new O(), C = /* @__PURE__ */ new Set();
2145
+ function oe() {
2146
+ ne = 0, re = !1;
2147
+ for (let e of C) e();
2148
+ }
2149
+ function w() {
1968
2150
  if (!f && (o(), r.setViewport(0, 0, h, g), r.render(i, a), l && d)) {
1969
- let e = Math.round(Math.min(ji, Math.max(Ai, Math.min(h, g) * ki)));
2151
+ let e = Math.round(Math.min($i, Math.max(Qi, Math.min(h, g) * Zi)));
1970
2152
  l.render(r, a.quaternion, e);
1971
2153
  }
1972
2154
  }
1973
- function k() {
2155
+ function T() {
1974
2156
  let t = e.getBoundingClientRect();
1975
2157
  h = Math.max(1, Math.round(t.width)), g = Math.max(1, Math.round(t.height));
1976
- let n = r.getSize(ne);
1977
- (n.x !== h || n.y !== g) && r.setSize(h, g, !1), En(a, h, g), u.handleResize(), u.rotateSpeed = h / Ci * bi;
2158
+ let n = r.getSize(ie);
2159
+ (n.x !== h || n.y !== g) && r.setSize(h, g, !1), qn(a, h, g), u.handleResize(), u.rotateSpeed = h / Gi * Hi;
1978
2160
  }
1979
- function re(e) {
1980
- d && (m = Tn(d.bounds, e, h, g), u.minZoom = m * wi, u.maxZoom = m * Ti);
2161
+ function se(e) {
2162
+ d && (m = Kn(d.bounds, e, h, g), u.minZoom = m * Ki, u.maxZoom = m * qi);
1981
2163
  }
1982
- function ie() {
1983
- let e = C.angleTo(a.quaternion) > Di || Math.abs(w - a.zoom) > Di * m || T.distanceToSquared(u.target) > Di;
1984
- return C.copy(a.quaternion), w = a.zoom, T.copy(u.target), e;
2164
+ function ce() {
2165
+ let e = ae.angleTo(a.quaternion) > Yi || Math.abs(x - a.zoom) > Yi * m || S.distanceToSquared(u.target) > Yi;
2166
+ return ae.copy(a.quaternion), x = a.zoom, S.copy(u.target), e;
1985
2167
  }
1986
- function ae() {
1987
- _ = null, u.update(), ie() ? (y = 0, O(), x += 1, te = !0, x >= Oi && D()) : y += 1, b || y < Ei ? _ = requestAnimationFrame(ae) : (v = !1, te && D());
2168
+ function le() {
2169
+ _ = null, u.update(), ce() ? (y = 0, w(), ne += 1, re = !0, ne >= Xi && oe()) : y += 1, te || y < Ji ? _ = requestAnimationFrame(le) : (v = !1, re && oe());
1988
2170
  }
1989
- function oe() {
1990
- y = 0, v || (v = !0, _ = requestAnimationFrame(ae));
2171
+ function ue() {
2172
+ y = 0, v || (v = !0, _ = requestAnimationFrame(le));
1991
2173
  }
1992
- function se() {
2174
+ function de() {
1993
2175
  _ !== null && (cancelAnimationFrame(_), _ = null), v = !1;
1994
2176
  }
1995
2177
  u.addEventListener("start", () => {
1996
- b = !0, oe();
2178
+ te = !0, ue();
1997
2179
  }), u.addEventListener("end", () => {
1998
- b = !1, oe();
1999
- }), u.addEventListener("change", oe);
2000
- function ce() {
2180
+ te = !1, ue();
2181
+ }), u.addEventListener("change", ue);
2182
+ function fe() {
2001
2183
  let e = m > 0 ? a.zoom / m : 1;
2002
- k(), re(a.quaternion), a.zoom = m * e, a.updateProjectionMatrix(), O();
2003
- }
2004
- let le = typeof ResizeObserver > "u" ? null : new ResizeObserver(ce);
2005
- le?.observe(e), k();
2006
- let ue = hi();
2007
- i.add(ue.group), i.fog = new ee(Mn, 1, 2);
2008
- let N = Promise.all([r.compileAsync(i, a), l && r.compileAsync(l.scene, l.camera)]);
2009
- i.remove(ue.group), i.fog = null, ue.dispose(), f = N;
2010
- let P = () => {
2011
- f === N && (f = null, O());
2184
+ T(), se(a.quaternion), a.zoom = m * e, a.updateProjectionMatrix(), w();
2185
+ }
2186
+ let pe = typeof ResizeObserver > "u" ? null : new ResizeObserver(fe);
2187
+ pe?.observe(e), T();
2188
+ let me = Li();
2189
+ i.add(me.group), i.fog = new ee($n, 1, 2);
2190
+ let he = Promise.all([r.compileAsync(i, a), l && r.compileAsync(l.scene, l.camera)]);
2191
+ i.remove(me.group), i.fog = null, me.dispose(), f = he;
2192
+ let k = () => {
2193
+ f === he && (f = null, w());
2012
2194
  };
2013
- N.then(P, P);
2014
- function F(e) {
2015
- d && (Sn(a, e, p, d.span), u.target.set(...e.target), re(a.quaternion), a.zoom = m * e.scale, a.updateProjectionMatrix(), u.update(), ie());
2195
+ he.then(k, k);
2196
+ function A(e) {
2197
+ d && (Un(a, e, p, d.span), u.target.set(...e.target), se(a.quaternion), a.zoom = m * e.scale, a.updateProjectionMatrix(), u.update(), ce());
2016
2198
  }
2017
- let de = {
2199
+ let j = {
2018
2200
  setLayers(e, t = null) {
2019
- de.clear(), e.length !== 0 && (d = fi(e), i.add(d.group), p = yn(d.span), i.fog = Mi(d, p, bn(d.cell)), s?.setElements(d.elements), l?.setCell(d.cell), k(), F(t ?? xn(d.cell)), O());
2201
+ j.clear(), e.length !== 0 && (d = Pi(e), i.add(d.group), p = Bn(d.span), i.fog = ea(d, p, Vn(d.cell)), s?.setElements(d.elements), l?.setCell(d.cell), T(), A(t ?? Hn(d.cell)), w());
2020
2202
  },
2021
2203
  clear() {
2022
- se(), d &&= (i.remove(d.group), d.dispose(), null), i.fog = null, s?.setElements([]), r.setViewport(0, 0, h, g), r.clear();
2204
+ de(), d &&= (i.remove(d.group), d.dispose(), null), i.fog = null, s?.setElements([]), r.setViewport(0, 0, h, g), r.clear();
2023
2205
  },
2024
2206
  getView() {
2025
2207
  return d ? {
2026
- quaternion: Cn(a.quaternion),
2208
+ quaternion: Wn(a.quaternion),
2027
2209
  target: [
2028
2210
  u.target.x,
2029
2211
  u.target.y,
@@ -2033,32 +2215,32 @@ function Ni(e, t = {}) {
2033
2215
  } : null;
2034
2216
  },
2035
2217
  setView(e) {
2036
- F(e), O();
2218
+ A(e), w();
2037
2219
  },
2038
2220
  resetView() {
2039
- d && F(xn(d.cell)), O(), D();
2221
+ d && A(Hn(d.cell)), w(), oe();
2040
2222
  },
2041
- resize: ce,
2042
- render: O,
2223
+ resize: fe,
2224
+ render: w,
2043
2225
  onInteraction(e) {
2044
- return E.add(e), () => E.delete(e);
2226
+ return C.add(e), () => C.delete(e);
2045
2227
  },
2046
2228
  dispose() {
2047
- de.clear(), f = null, b = !1, le?.disconnect(), u.dispose(), l?.dispose(), r.dispose(), r.domElement.remove(), s?.element.remove(), e.classList.remove("bravais-viewer");
2229
+ j.clear(), f = null, pe?.disconnect(), u.dispose(), l?.dispose(), r.dispose(), r.domElement.remove(), s?.element.remove(), e.classList.remove("bravais-viewer");
2048
2230
  }
2049
2231
  };
2050
- return de;
2232
+ return j;
2051
2233
  }
2052
2234
  //#endregion
2053
2235
  //#region src/render/thumbnails.ts
2054
- function Pi() {
2055
- let { renderer: e, scene: t, camera: n, updateHeadlight: r } = gi(), i = /* @__PURE__ */ new Map(), a = hi();
2236
+ function na() {
2237
+ let { renderer: e, scene: t, camera: n, updateHeadlight: r } = Ri(), i = /* @__PURE__ */ new Map(), a = Li();
2056
2238
  t.add(a.group), e.compile(t, n), t.remove(a.group), a.dispose();
2057
2239
  function o(e, t) {
2058
2240
  let n = i.get(e);
2059
2241
  if (n && n.layers === t) return n.model;
2060
2242
  n?.model.dispose();
2061
- let r = fi(t);
2243
+ let r = Pi(t);
2062
2244
  return i.set(e, {
2063
2245
  layers: t,
2064
2246
  model: r
@@ -2069,9 +2251,9 @@ function Pi() {
2069
2251
  let l = c.getContext("2d");
2070
2252
  if (!l || a.length === 0) return;
2071
2253
  let u = o(i, a), d = Math.max(1, c.width), f = Math.max(1, c.height);
2072
- (e.domElement.width !== d || e.domElement.height !== f) && e.setSize(d, f, !1), En(n, d, f);
2073
- let p = yn(u.span), m = s ?? xn(u.cell);
2074
- Sn(n, m, p, u.span), n.zoom = Tn(u.bounds, new A(...m.quaternion), d, f) * m.scale, n.updateProjectionMatrix(), r(), t.add(u.group), e.render(t, n), t.remove(u.group), l.clearRect(0, 0, d, f), l.drawImage(e.domElement, 0, 0, d, f);
2254
+ (e.domElement.width !== d || e.domElement.height !== f) && e.setSize(d, f, !1), qn(n, d, f);
2255
+ let p = Bn(u.span), m = s ?? Hn(u.cell);
2256
+ Un(n, m, p, u.span), n.zoom = Kn(u.bounds, new E(...m.quaternion), d, f) * m.scale, n.updateProjectionMatrix(), r(), t.add(u.group), e.render(t, n), t.remove(u.group), l.clearRect(0, 0, d, f), l.drawImage(e.domElement, 0, 0, d, f);
2075
2257
  },
2076
2258
  release(e) {
2077
2259
  i.get(e)?.model.dispose(), i.delete(e);
@@ -2084,18 +2266,18 @@ function Pi() {
2084
2266
  }
2085
2267
  //#endregion
2086
2268
  //#region src/index.ts
2087
- async function Fi(e) {
2088
- let t = ge(e), n = t.blocks.find(Ye) ?? t.blocks[0];
2089
- if (!n) throw new H("The CIF has no data block.");
2090
- let r = Xe(n);
2269
+ async function ra(e) {
2270
+ let t = Se(e), n = t.blocks.find(it) ?? t.blocks[0];
2271
+ if (!n) throw new M("The CIF has no data block.");
2272
+ let r = at(n);
2091
2273
  return {
2092
2274
  lattice: r.lattice,
2093
2275
  sites: r.sites,
2094
- operations: await _t(r),
2276
+ operations: await Dt(r, M),
2095
2277
  spaceGroup: r.spaceGroup
2096
2278
  };
2097
2279
  }
2098
2280
  //#endregion
2099
- export { H as CifStructureError, P as CifSyntaxError, nt as SpaceGroupLookupError, bt as SymmetryAnalysisError, Ft as buildScene, Pi as createThumbnailRenderer, Ni as createViewer, qr as elementColor, Jr as elementColorAssignments, Kr as ensureElementColors, rt as ensureMoyo, vt as expandStructure, Me as latticeFromParameters, Ne as latticeFromVectors, dt as operationsForSpaceGroup, ge as parseCif, Xe as parseCifStructure, Re as parseSymmetryOperator, Fi as readCif, Yr as resetElementColors, Pt as structureElements, Ct as symmetryDataset, Dt as typesetSymbol };
2281
+ export { M as CifStructureError, j as CifSyntaxError, ft as SpaceGroupLookupError, A as StructureDataError, k as StructureError, Ht as SymmetryAnalysisError, rn as buildScene, na as createThumbnailRenderer, ta as createViewer, mi as elementColor, hi as elementColorAssignments, pi as ensureElementColors, pt as ensureMoyo, Bt as expandStructure, Me as latticeFromParameters, Ne as latticeFromVectors, xt as operationsForSpaceGroup, Se as parseCif, at as parseCifStructure, Xe as parseSymmetryOperation, ra as readCif, zt as readStructure, gi as resetElementColors, nn as structureElements, Gt as symmetryDataset, Yt as typesetSymbol };
2100
2282
 
2101
2283
  //# sourceMappingURL=bravais.js.map