@processandtools/rp-article-designer 1.0.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/README.md +73 -0
- package/dist/contexts/article/ArticleContext.d.ts +7 -0
- package/dist/contexts/article-data/DataContext.d.ts +1 -0
- package/dist/contexts/descriptor/DescriptorContext.d.ts +3 -0
- package/dist/descriptor/helper/DescriptorEvaluator.d.ts +8 -0
- package/dist/descriptor/services/DescriptorManager.d.ts +23 -0
- package/dist/helpers/ExpressionResolver.d.ts +44 -0
- package/dist/helpers/LindivResolver.d.ts +59 -0
- package/dist/hooks/useArticle.d.ts +1 -0
- package/dist/hooks/useData.d.ts +1 -0
- package/dist/hooks/useDescriptor.d.ts +32 -0
- package/dist/hooks/useDescriptorManager.d.ts +3 -0
- package/dist/hooks/zoneDescriptor.d.ts +93 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +2571 -0
- package/dist/rp-article-designer.css +1 -0
- package/dist/types/divider.types.d.ts +82 -0
- package/dist/types/view.types.d.ts +5 -0
- package/dist/variables/VariableResolver.d.ts +28 -0
- package/dist/variables/useVariables.d.ts +11 -0
- package/dist/variables/variable.types.d.ts +20 -0
- package/dist/vite.svg +1 -0
- package/package.json +88 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2571 @@
|
|
|
1
|
+
var Be = Object.defineProperty;
|
|
2
|
+
var He = (e, t, r) => t in e ? Be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var C = (e, t, r) => He(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { jsx as f, jsxs as O, Fragment as pe } from "react/jsx-runtime";
|
|
5
|
+
import { createContext as le, useState as re, useCallback as Ie, useMemo as $, useEffect as Ue, useContext as V, Fragment as Ze } from "react";
|
|
6
|
+
import { Edges as Ke, Text as Ye } from "@react-three/drei";
|
|
7
|
+
const F = le(void 0);
|
|
8
|
+
function We({ data: e, children: t, names: r }) {
|
|
9
|
+
const i = e, [n, s] = re(i), [a, o] = re(null), [l, u] = re(null), h = Ie((S) => ({
|
|
10
|
+
anglElems: n.anglelem.filter((T) => T.NAME === S),
|
|
11
|
+
anglZones: n.anglzone.filter((T) => T.NAME === S),
|
|
12
|
+
anglPrims: n.anglprim.filter((T) => T.NAME === S),
|
|
13
|
+
anglClies: n.anglclie.filter((T) => T.NAME === S),
|
|
14
|
+
anglGrtxs: n.anglgrtx.filter((T) => T.NAME === S)
|
|
15
|
+
}), [n]), { anglElems: m, anglZones: p, anglPrims: E, anglClies: y, anglGrtxs: c } = $(() => r && r.length > 0 ? {
|
|
16
|
+
anglElems: n.anglelem.filter((S) => r.includes(S.NAME)),
|
|
17
|
+
anglZones: n.anglzone.filter((S) => r.includes(S.NAME)),
|
|
18
|
+
anglPrims: n.anglprim.filter((S) => r.includes(S.NAME)),
|
|
19
|
+
anglClies: n.anglclie.filter((S) => r.includes(S.NAME)),
|
|
20
|
+
anglGrtxs: n.anglgrtx.filter((S) => r.includes(S.NAME))
|
|
21
|
+
} : {
|
|
22
|
+
anglElems: n.anglelem,
|
|
23
|
+
anglZones: n.anglzone,
|
|
24
|
+
anglPrims: n.anglprim,
|
|
25
|
+
anglClies: n.anglclie,
|
|
26
|
+
anglGrtxs: n.anglgrtx
|
|
27
|
+
}, [n, r]), D = {
|
|
28
|
+
anglElems: m,
|
|
29
|
+
anglZones: p,
|
|
30
|
+
anglPrims: E,
|
|
31
|
+
anglClies: y,
|
|
32
|
+
anglGrtxs: c,
|
|
33
|
+
selectedElem: a,
|
|
34
|
+
setSelectedElem: o,
|
|
35
|
+
hoveredElem: l,
|
|
36
|
+
setHoveredElem: u,
|
|
37
|
+
updateAnglPrim: (S, T, _) => {
|
|
38
|
+
s((k) => ({
|
|
39
|
+
...k,
|
|
40
|
+
anglprim: k.anglprim.map(
|
|
41
|
+
(w) => w.NAME === S ? { ...w, [T]: _ } : w
|
|
42
|
+
)
|
|
43
|
+
}));
|
|
44
|
+
},
|
|
45
|
+
updateAnglElem: (S, T, _, k) => {
|
|
46
|
+
s((w) => ({
|
|
47
|
+
...w,
|
|
48
|
+
anglelem: w.anglelem.map(
|
|
49
|
+
(b) => b.TREEID === T && b.NAME === S ? { ...b, [_]: k } : b
|
|
50
|
+
)
|
|
51
|
+
}));
|
|
52
|
+
},
|
|
53
|
+
updateAnglZone: (S, T, _, k) => {
|
|
54
|
+
s((w) => ({
|
|
55
|
+
...w,
|
|
56
|
+
anglzone: w.anglzone.map(
|
|
57
|
+
(b) => b.TREEID === T && b.NAME === S ? { ...b, [_]: k } : b
|
|
58
|
+
)
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
updateAnglClie: (S, T, _, k, w) => {
|
|
62
|
+
s((b) => ({
|
|
63
|
+
...b,
|
|
64
|
+
anglclie: b.anglclie.map(
|
|
65
|
+
(L) => L.TREEID === T && L.TAGNAME === _ && L.DATATYPE === w && L.NAME === S ? {
|
|
66
|
+
...L,
|
|
67
|
+
TAGVALUE: k,
|
|
68
|
+
DATE_LASTCHANGE: (/* @__PURE__ */ new Date()).toISOString()
|
|
69
|
+
} : L
|
|
70
|
+
)
|
|
71
|
+
}));
|
|
72
|
+
},
|
|
73
|
+
updateAnglGrtx: (S, T, _, k) => {
|
|
74
|
+
s((w) => ({
|
|
75
|
+
...w,
|
|
76
|
+
anglgrtx: w.anglgrtx.map(
|
|
77
|
+
(b) => b.TREEID === T && b.NUM === _ && b.NAME === S ? {
|
|
78
|
+
...b,
|
|
79
|
+
TEXT: k,
|
|
80
|
+
DATE_LASTCHANGE: (/* @__PURE__ */ new Date()).toISOString()
|
|
81
|
+
} : b
|
|
82
|
+
)
|
|
83
|
+
}));
|
|
84
|
+
},
|
|
85
|
+
// Multi-article support
|
|
86
|
+
getArticleData: h,
|
|
87
|
+
allData: n
|
|
88
|
+
};
|
|
89
|
+
return /* @__PURE__ */ f(F.Provider, { value: D, children: t });
|
|
90
|
+
}
|
|
91
|
+
const _e = le(null);
|
|
92
|
+
function be({ children: e, articleName: t, dimensionOverrides: r }) {
|
|
93
|
+
const i = {
|
|
94
|
+
articleName: t,
|
|
95
|
+
dimensionOverrides: r
|
|
96
|
+
};
|
|
97
|
+
return /* @__PURE__ */ f(_e.Provider, { value: i, children: e });
|
|
98
|
+
}
|
|
99
|
+
const ke = le(void 0);
|
|
100
|
+
var P = /* @__PURE__ */ ((e) => (e[e.Surface = 3] = "Surface", e[e.Material = 4] = "Material", e[e.Numeric = 100] = "Numeric", e[e.Text = 120] = "Text", e))(P || {});
|
|
101
|
+
function me(e) {
|
|
102
|
+
return new Map(e.map((t) => [t.NAME, t]));
|
|
103
|
+
}
|
|
104
|
+
function ce(e, t, r = /* @__PURE__ */ new Set()) {
|
|
105
|
+
const i = t.get(e);
|
|
106
|
+
if (!i) return;
|
|
107
|
+
if (r.has(e)) {
|
|
108
|
+
console.error(`Circular dependency: ${[...r, e].join(" -> ")}`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const n = i.WERT;
|
|
112
|
+
if (n.startsWith("$") && i.TYP != P.Text) {
|
|
113
|
+
const a = n.slice(1);
|
|
114
|
+
return r.add(e), ce(a, t, r);
|
|
115
|
+
}
|
|
116
|
+
const s = Number(n);
|
|
117
|
+
return isNaN(s) ? n : s;
|
|
118
|
+
}
|
|
119
|
+
function Ae(e, t, r) {
|
|
120
|
+
const i = r.get(e);
|
|
121
|
+
if (!i)
|
|
122
|
+
return console.warn(`Variable ${e} not found`), r;
|
|
123
|
+
const n = new Map(r);
|
|
124
|
+
return n.set(e, { ...i, WERT: String(t) }), n;
|
|
125
|
+
}
|
|
126
|
+
function de(e, t) {
|
|
127
|
+
return e.replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g, (r, i) => {
|
|
128
|
+
const n = ce(i, t);
|
|
129
|
+
return n !== void 0 ? String(n) : r;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function ge(e) {
|
|
133
|
+
return /\$[A-Za-z_][A-Za-z0-9_]*/g.test(e);
|
|
134
|
+
}
|
|
135
|
+
function Xe(e) {
|
|
136
|
+
const t = e.matchAll(/\$([A-Za-z_][A-Za-z0-9_]*)/g);
|
|
137
|
+
return Array.from(t, (r) => r[1]);
|
|
138
|
+
}
|
|
139
|
+
const nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
140
|
+
__proto__: null,
|
|
141
|
+
createVariableTree: me,
|
|
142
|
+
extractVariableNames: Xe,
|
|
143
|
+
getValue: ce,
|
|
144
|
+
hasVariables: ge,
|
|
145
|
+
resolveString: de,
|
|
146
|
+
setValue: Ae
|
|
147
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
148
|
+
function je({ children: e, imosVariables: t }) {
|
|
149
|
+
const [r, i] = re(() => me(t));
|
|
150
|
+
Ue(() => {
|
|
151
|
+
i(me(t));
|
|
152
|
+
}, [t]);
|
|
153
|
+
const n = Ie((a, o) => {
|
|
154
|
+
i((l) => Ae(a, o, l));
|
|
155
|
+
}, []), s = { tree: r, setValue: n };
|
|
156
|
+
return /* @__PURE__ */ f(ke.Provider, { value: s, children: e });
|
|
157
|
+
}
|
|
158
|
+
const De = le(null), Ne = (e) => {
|
|
159
|
+
const t = Number(e);
|
|
160
|
+
return isNaN(t) ? null : t;
|
|
161
|
+
}, Y = (e) => e == null ? "" : String(e), z = (e, t, r) => {
|
|
162
|
+
const i = Ne(e), n = Ne(t);
|
|
163
|
+
return i === null || n === null ? !1 : r(i, n);
|
|
164
|
+
}, K = (e, t, r) => e == null || t == null ? !1 : r(Y(e), Y(t)), qe = {
|
|
165
|
+
// Equality
|
|
166
|
+
"=": (e, t) => e == null || t == null ? e === t : Y(e).trim() === Y(t).trim(),
|
|
167
|
+
"!=": (e, t) => e == null || t == null ? e !== t : Y(e).trim() !== Y(t).trim(),
|
|
168
|
+
// Numeric comparisons - all use compareNumbers helper
|
|
169
|
+
">": (e, t) => z(e, t, (r, i) => r > i),
|
|
170
|
+
"<": (e, t) => z(e, t, (r, i) => r < i),
|
|
171
|
+
">=": (e, t) => z(e, t, (r, i) => r >= i),
|
|
172
|
+
"<=": (e, t) => z(e, t, (r, i) => r <= i),
|
|
173
|
+
// HTML entity versions - reuse same logic
|
|
174
|
+
">": (e, t) => z(e, t, (r, i) => r > i),
|
|
175
|
+
">=": (e, t) => z(e, t, (r, i) => r >= i),
|
|
176
|
+
"<": (e, t) => z(e, t, (r, i) => r < i),
|
|
177
|
+
"<=": (e, t) => z(e, t, (r, i) => r <= i),
|
|
178
|
+
// String operations - all use compareStrings helper
|
|
179
|
+
B: (e, t) => K(e, t, (r, i) => r.startsWith(i)),
|
|
180
|
+
"!B": (e, t) => K(e, t, (r, i) => !r.startsWith(i)),
|
|
181
|
+
E: (e, t) => K(e, t, (r, i) => r.endsWith(i)),
|
|
182
|
+
"!E": (e, t) => K(e, t, (r, i) => !r.endsWith(i)),
|
|
183
|
+
C: (e, t) => K(e, t, (r, i) => r.includes(i)),
|
|
184
|
+
"!C": (e, t) => K(e, t, (r, i) => !r.includes(i))
|
|
185
|
+
}, Je = {
|
|
186
|
+
"Zusatzfilter 3": "filter3",
|
|
187
|
+
"Zusatzfilter 4": "filter4"
|
|
188
|
+
// Add more mappings as needed
|
|
189
|
+
};
|
|
190
|
+
function we(e, t = {}) {
|
|
191
|
+
const { variableTree: r, dataType: i, silent: n = !1, allowFunctions: s = !0 } = t, a = /^(.+?)\s*(mm|cm|m|in|ft|px|pt|%|deg|rad)$/i, o = {
|
|
192
|
+
value: void 0,
|
|
193
|
+
original: e,
|
|
194
|
+
resolved: e,
|
|
195
|
+
hadVariables: !1,
|
|
196
|
+
wasEvaluated: !1
|
|
197
|
+
};
|
|
198
|
+
try {
|
|
199
|
+
let l = e.trim(), u;
|
|
200
|
+
if (a.test(l)) {
|
|
201
|
+
const h = l.match(a);
|
|
202
|
+
h && (l = h[1].trim(), u = h[2]);
|
|
203
|
+
}
|
|
204
|
+
r && ge(l) && (o.hadVariables = !0, l = de(l, r), o.resolved = l), Ce(l) ? (o.wasEvaluated = !0, o.value = Le(l, s)) : Ee(l) ? (o.wasEvaluated = !0, o.value = Se(l, s)) : o.value = et(l, i);
|
|
205
|
+
} catch (l) {
|
|
206
|
+
o.error = l instanceof Error ? l.message : String(l), n || console.error(`[ExpressionResolver] Failed to resolve: "${e}"`, l), o.value = e;
|
|
207
|
+
}
|
|
208
|
+
return o;
|
|
209
|
+
}
|
|
210
|
+
function se(e, t = {}) {
|
|
211
|
+
return we(e, t).value;
|
|
212
|
+
}
|
|
213
|
+
function Ce(e) {
|
|
214
|
+
return !e || typeof e != "string" ? !1 : /^\s*IF\s*\(/i.test(e.trim());
|
|
215
|
+
}
|
|
216
|
+
function Le(e, t = !0) {
|
|
217
|
+
const i = e.trim().match(/^IF\s*\((.*)\)\s*$/i);
|
|
218
|
+
if (!i)
|
|
219
|
+
throw new Error(`Invalid IF statement: ${e}`);
|
|
220
|
+
const n = i[1], s = Qe(n);
|
|
221
|
+
if (s.length !== 3)
|
|
222
|
+
throw new Error(`IF statement must have exactly 3 parts: IF(condition, trueValue, falseValue). Got: ${s.length} parts`);
|
|
223
|
+
const [a, o, l] = s, h = ie(a.trim(), t) ? o.trim() : l.trim();
|
|
224
|
+
if (Ce(h))
|
|
225
|
+
return Le(h, t);
|
|
226
|
+
if (Ee(h))
|
|
227
|
+
return Se(h, t);
|
|
228
|
+
{
|
|
229
|
+
const m = Number(h);
|
|
230
|
+
return isNaN(m) ? h : m;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function Qe(e) {
|
|
234
|
+
const t = [];
|
|
235
|
+
let r = "", i = 0;
|
|
236
|
+
for (let n = 0; n < e.length; n++) {
|
|
237
|
+
const s = e[n];
|
|
238
|
+
s === "(" ? (i++, r += s) : s === ")" ? (i--, r += s) : s === "," && i === 0 ? (t.push(r), r = "") : r += s;
|
|
239
|
+
}
|
|
240
|
+
return r && t.push(r), t;
|
|
241
|
+
}
|
|
242
|
+
function ie(e, t) {
|
|
243
|
+
if (/\bAND\b/i.test(e))
|
|
244
|
+
return e.split(/\bAND\b/i).every((u) => ie(u.trim(), t));
|
|
245
|
+
if (/\bOR\b/i.test(e))
|
|
246
|
+
return e.split(/\bOR\b/i).some((u) => ie(u.trim(), t));
|
|
247
|
+
if (/^\s*NOT\s+/i.test(e)) {
|
|
248
|
+
const l = e.replace(/^\s*NOT\s+/i, "").trim();
|
|
249
|
+
return !ie(l, t);
|
|
250
|
+
}
|
|
251
|
+
const r = e.match(/(.+?)(<=|>=|!=|<>|=|<|>)(.+)/);
|
|
252
|
+
if (!r)
|
|
253
|
+
throw new Error(`Invalid condition: ${e}`);
|
|
254
|
+
const [, i, n, s] = r, a = Te(i.trim(), t), o = Te(s.trim(), t);
|
|
255
|
+
switch (n) {
|
|
256
|
+
case "=":
|
|
257
|
+
return a === o;
|
|
258
|
+
case "!=":
|
|
259
|
+
case "<>":
|
|
260
|
+
return a !== o;
|
|
261
|
+
case "<":
|
|
262
|
+
return a < o;
|
|
263
|
+
case ">":
|
|
264
|
+
return a > o;
|
|
265
|
+
case "<=":
|
|
266
|
+
return a <= o;
|
|
267
|
+
case ">=":
|
|
268
|
+
return a >= o;
|
|
269
|
+
default:
|
|
270
|
+
throw new Error(`Unknown operator: ${n}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function Te(e, t) {
|
|
274
|
+
if (e.startsWith('"') && e.endsWith('"') || e.startsWith("'") && e.endsWith("'"))
|
|
275
|
+
return e.slice(1, -1);
|
|
276
|
+
if (Ee(e))
|
|
277
|
+
return Se(e, t);
|
|
278
|
+
const r = Number(e);
|
|
279
|
+
return isNaN(r) ? e : r;
|
|
280
|
+
}
|
|
281
|
+
function Ee(e) {
|
|
282
|
+
if (!e || typeof e != "string") return !1;
|
|
283
|
+
const t = e.trim();
|
|
284
|
+
return /[+\-*/()]/.test(t) ? /^[\d\s+\-*/().,a-z]+$/i.test(t) : !1;
|
|
285
|
+
}
|
|
286
|
+
const he = /* @__PURE__ */ new Map();
|
|
287
|
+
function Se(e, t = !0) {
|
|
288
|
+
const r = e.trim(), i = `${r}:${t}`;
|
|
289
|
+
if (he.has(i))
|
|
290
|
+
return he.get(i);
|
|
291
|
+
let n = r.replace(/\s+/g, "");
|
|
292
|
+
if (t && (n = n.replace(/round\(/g, "Math.round(").replace(/floor\(/g, "Math.floor(").replace(/ceil\(/g, "Math.ceil(").replace(/abs\(/g, "Math.abs(").replace(/min\(/g, "Math.min(").replace(/max\(/g, "Math.max(").replace(/pow\(/g, "Math.pow(").replace(/sqrt\(/g, "Math.sqrt(")), !(t ? /^[\d+\-*/().,a-zA-Z]+$/ : /^[\d+\-*/().]+$/).test(n))
|
|
293
|
+
throw new Error(`Expression contains invalid characters: ${e}`);
|
|
294
|
+
if (!n)
|
|
295
|
+
throw new Error("Empty expression");
|
|
296
|
+
try {
|
|
297
|
+
const a = Function(`'use strict'; return (${n})`)();
|
|
298
|
+
if (typeof a != "number" || isNaN(a))
|
|
299
|
+
throw new Error(`Expression did not evaluate to a number: ${e}`);
|
|
300
|
+
return he.set(i, a), a;
|
|
301
|
+
} catch (a) {
|
|
302
|
+
throw new Error(`Failed to evaluate expression: ${e} - ${a}`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function et(e, t) {
|
|
306
|
+
if (!t) {
|
|
307
|
+
const r = Number(e);
|
|
308
|
+
return isNaN(r) ? e : r;
|
|
309
|
+
}
|
|
310
|
+
switch (t.toUpperCase()) {
|
|
311
|
+
case "FL":
|
|
312
|
+
return parseFloat(e);
|
|
313
|
+
case "IN":
|
|
314
|
+
return parseInt(e, 10);
|
|
315
|
+
case "CI":
|
|
316
|
+
case "CS":
|
|
317
|
+
case "ST":
|
|
318
|
+
return e;
|
|
319
|
+
case "DA":
|
|
320
|
+
return new Date(e).toISOString();
|
|
321
|
+
default:
|
|
322
|
+
const r = Number(e);
|
|
323
|
+
return isNaN(r) ? e : r;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const tt = (e) => Je[e] || e, W = class W {
|
|
327
|
+
};
|
|
328
|
+
C(W, "evaluateTree", (t, r, i) => t ? t.roots.every((n) => W.evaluateNode(n, r, i)) : !1), C(W, "evaluateNode", (t, r, i) => {
|
|
329
|
+
if (!t) return !1;
|
|
330
|
+
if (t.kind === "comparison") {
|
|
331
|
+
let n = t.data.LEFTVALUE;
|
|
332
|
+
const s = tt(t.data.LEFTVALUE);
|
|
333
|
+
r[s] !== void 0 ? n = r[s] : n = se(t.data.LEFTVALUE, { variableTree: i, dataType: t.data.DATATYPE, silent: !0 });
|
|
334
|
+
const a = se(t.data.RIGHTVALUE, { variableTree: i, dataType: t.data.DATATYPE, silent: !0 });
|
|
335
|
+
return qe[t.data.COMPARISONTYPE](n, a);
|
|
336
|
+
}
|
|
337
|
+
if (t.kind === "operation") {
|
|
338
|
+
const n = t.children.map((s) => W.evaluateNode(s, r, i));
|
|
339
|
+
switch (t.data.OPSTRING) {
|
|
340
|
+
case "AND":
|
|
341
|
+
return n.every(Boolean);
|
|
342
|
+
case "OR":
|
|
343
|
+
return n.some(Boolean);
|
|
344
|
+
case "NOT":
|
|
345
|
+
return !n.every(Boolean);
|
|
346
|
+
case "NOT OR":
|
|
347
|
+
return !n.some(Boolean);
|
|
348
|
+
default:
|
|
349
|
+
return !1;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return !1;
|
|
353
|
+
});
|
|
354
|
+
let ae = W;
|
|
355
|
+
class Me {
|
|
356
|
+
static evaluate(t, r, i) {
|
|
357
|
+
const n = t.nodes.find((s) => s.conditionId === 0 || s.conditionTree === null);
|
|
358
|
+
for (const s of t.nodes) {
|
|
359
|
+
if (s.conditionId === 0 || s.conditionTree === null) continue;
|
|
360
|
+
if (ae.evaluateTree(s.conditionTree, r, i))
|
|
361
|
+
return {
|
|
362
|
+
lindiv: s.lindiv,
|
|
363
|
+
nodeNum: s.nodeNum,
|
|
364
|
+
matched: !0,
|
|
365
|
+
isDefault: !1,
|
|
366
|
+
descriptorType: t.descriptor.DESC_TYPE
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
if (n)
|
|
370
|
+
return {
|
|
371
|
+
lindiv: n.lindiv,
|
|
372
|
+
nodeNum: n.nodeNum,
|
|
373
|
+
matched: !1,
|
|
374
|
+
isDefault: !0,
|
|
375
|
+
descriptorType: t.descriptor.DESC_TYPE
|
|
376
|
+
};
|
|
377
|
+
throw new Error("No matching node found and no default node exists");
|
|
378
|
+
}
|
|
379
|
+
static findAllNonDefaultMatches(t, r, i) {
|
|
380
|
+
const n = [];
|
|
381
|
+
for (const s of t.nodes) {
|
|
382
|
+
if (s.conditionId === 0 || s.conditionTree === null) continue;
|
|
383
|
+
ae.evaluateTree(s.conditionTree, r, i) && n.push(s);
|
|
384
|
+
}
|
|
385
|
+
return n;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
class rt {
|
|
389
|
+
constructor(t, r) {
|
|
390
|
+
C(this, "descriptors");
|
|
391
|
+
C(this, "variableTree");
|
|
392
|
+
this.descriptors = new Map(
|
|
393
|
+
t.map((i) => [i.descriptor.NAME, i])
|
|
394
|
+
), this.variableTree = r;
|
|
395
|
+
}
|
|
396
|
+
evaluate(t, r) {
|
|
397
|
+
const i = this.getDescriptor(t);
|
|
398
|
+
if (!i)
|
|
399
|
+
throw new Error(`Descriptor not found: ${t}`);
|
|
400
|
+
return Me.evaluate(i, r, this.variableTree);
|
|
401
|
+
}
|
|
402
|
+
getDescriptor(t) {
|
|
403
|
+
return this.descriptors.get(t);
|
|
404
|
+
}
|
|
405
|
+
hasDescriptor(t) {
|
|
406
|
+
return this.descriptors.has(t);
|
|
407
|
+
}
|
|
408
|
+
getDescriptorNames() {
|
|
409
|
+
return Array.from(this.descriptors.keys());
|
|
410
|
+
}
|
|
411
|
+
getDescriptorsByType(t) {
|
|
412
|
+
return Array.from(this.descriptors.values()).filter(
|
|
413
|
+
(r) => r.descriptor.DESC_TYPE === t
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
findAllMatches(t, r) {
|
|
417
|
+
const i = this.getDescriptor(t);
|
|
418
|
+
if (!i)
|
|
419
|
+
throw new Error(`Descriptor not found: ${t}`);
|
|
420
|
+
return Me.findAllNonDefaultMatches(i, r, this.variableTree);
|
|
421
|
+
}
|
|
422
|
+
getStats() {
|
|
423
|
+
const t = {};
|
|
424
|
+
for (const r of this.descriptors.values()) {
|
|
425
|
+
const i = r.descriptor.DESC_TYPE;
|
|
426
|
+
t[i] = (t[i] || 0) + 1;
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
total: this.descriptors.size,
|
|
430
|
+
byType: t,
|
|
431
|
+
names: this.getDescriptorNames()
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function j() {
|
|
436
|
+
const e = V(ke);
|
|
437
|
+
if (!e)
|
|
438
|
+
throw new Error("useVariables must be used within a VariableProvider");
|
|
439
|
+
const { tree: t, setValue: r } = e, i = $(() => (a) => ce(a, t), [t]), n = $(() => (a) => de(a, t), [t]), s = $(() => (a) => ge(a), []);
|
|
440
|
+
return {
|
|
441
|
+
tree: t,
|
|
442
|
+
// Variable tree
|
|
443
|
+
getValue: i,
|
|
444
|
+
// Get variable value
|
|
445
|
+
resolveString: n,
|
|
446
|
+
// Resolve string with variables
|
|
447
|
+
hasVariables: s,
|
|
448
|
+
// Check if string has variables
|
|
449
|
+
setValue: r
|
|
450
|
+
// Set variable value (updates tree state)
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
function it({ children: e, descriptorData: t }) {
|
|
454
|
+
const r = j(), i = $(() => new rt(
|
|
455
|
+
t,
|
|
456
|
+
r.tree
|
|
457
|
+
), [t, r]);
|
|
458
|
+
return /* @__PURE__ */ f(De.Provider, { value: i, children: e });
|
|
459
|
+
}
|
|
460
|
+
var x = /* @__PURE__ */ ((e) => (e._2D_TOP = "2D_TOP", e._2D_FRONT = "2D_FRONT", e._3D = "3D", e))(x || {});
|
|
461
|
+
const fe = 0, nt = 1, Oe = (e) => e + ".0", Pe = (e) => e + ".1", Ve = (e) => e + ".2", Re = (e) => e + ".3", ve = (e) => e.substring(0, e.lastIndexOf(".")), st = (e) => {
|
|
462
|
+
const t = ve(e), i = ($e(e) + 3) % 4;
|
|
463
|
+
return `${t}.${i}`;
|
|
464
|
+
}, at = (e) => {
|
|
465
|
+
const t = ve(e), i = ($e(e) + 1) % 4;
|
|
466
|
+
return `${t}.${i}`;
|
|
467
|
+
}, $e = (e) => parseInt(e.substring(e.lastIndexOf(".") + 1)), X = {
|
|
468
|
+
IAC_THICKNESS: "IAC_THICKNESS",
|
|
469
|
+
// sides and dividers (shelf / partitions)
|
|
470
|
+
IAC_BOTTOMSHELFTHICKNESS: "IAC_BOTTOMSHELFTHICKNESS",
|
|
471
|
+
// for bottom shelf
|
|
472
|
+
IAC_TOPSHELFTHICKNESS: "IAC_TOPSHELFTHICKNESS"
|
|
473
|
+
// for top shelf
|
|
474
|
+
}, v = 1;
|
|
475
|
+
function Q() {
|
|
476
|
+
const e = V(F);
|
|
477
|
+
if (e === void 0)
|
|
478
|
+
throw new Error("useData must be used within a DataProvider");
|
|
479
|
+
return e;
|
|
480
|
+
}
|
|
481
|
+
function ee() {
|
|
482
|
+
const e = V(_e);
|
|
483
|
+
if (!e)
|
|
484
|
+
throw new Error("useArticle must be used within an ArticleProvider");
|
|
485
|
+
return e;
|
|
486
|
+
}
|
|
487
|
+
function ne(e, t, r) {
|
|
488
|
+
const { getArticleData: i } = Q(), { articleName: n } = ee(), { anglClies: s } = i(n), a = s.find((l) => l.TREEID === e && l.DATATYPE === r && l.TAGNAME === t);
|
|
489
|
+
return a ? {
|
|
490
|
+
thickness: Number(a.TAGVALUE)
|
|
491
|
+
} : null;
|
|
492
|
+
}
|
|
493
|
+
function ot(e) {
|
|
494
|
+
const { getArticleData: t } = Q(), { resolveString: r } = j(), { articleName: i } = ee(), n = t(i).anglGrtxs;
|
|
495
|
+
if (!n) return null;
|
|
496
|
+
const s = n.filter((o) => o.TREEID === e), a = /* @__PURE__ */ new Map();
|
|
497
|
+
return s.map((o) => a.set(`AD zone info0${o.NUM + 1}`, r(o.TEXT))), {
|
|
498
|
+
zoneInfo: a
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function ue(e) {
|
|
502
|
+
const { getArticleData: t } = Q(), { articleName: r } = ee(), { anglZones: i } = t(r), n = i.find((a) => a.TREEID === e), s = i.filter((a) => a.TREEID.substring(0, a.TREEID.lastIndexOf(".")) === e);
|
|
503
|
+
return s.sort((a, o) => a.TREEID.localeCompare(o.TREEID, void 0, { numeric: !0 })), n ? {
|
|
504
|
+
// Zone data
|
|
505
|
+
currentZone: n,
|
|
506
|
+
children: s,
|
|
507
|
+
// Shelf properties
|
|
508
|
+
get topShelfCP() {
|
|
509
|
+
return n?.TOPSHELF;
|
|
510
|
+
},
|
|
511
|
+
get bottomShelfCP() {
|
|
512
|
+
return n?.BOTSHELF;
|
|
513
|
+
},
|
|
514
|
+
zoneInfo() {
|
|
515
|
+
return ot(e)?.zoneInfo;
|
|
516
|
+
},
|
|
517
|
+
// Thickness calculations
|
|
518
|
+
getClieThk(a, o) {
|
|
519
|
+
return this.topShelfCP === "" ? 0 : ne(a, o, nt)?.thickness || 0;
|
|
520
|
+
},
|
|
521
|
+
get topShelfThk() {
|
|
522
|
+
return this.getClieThk(e, X.IAC_TOPSHELFTHICKNESS);
|
|
523
|
+
},
|
|
524
|
+
get bottomShelfThk() {
|
|
525
|
+
return this.getClieThk(e, X.IAC_BOTTOMSHELFTHICKNESS);
|
|
526
|
+
},
|
|
527
|
+
get dividerThk() {
|
|
528
|
+
return this.getClieThk(e, X.IAC_THICKNESS);
|
|
529
|
+
}
|
|
530
|
+
} : null;
|
|
531
|
+
}
|
|
532
|
+
function te(e) {
|
|
533
|
+
const { getArticleData: t } = Q(), { articleName: r } = ee(), { resolveString: i } = j(), { anglElems: n } = t(r), s = n.find((M) => M.TREEID === e), a = ve(e), o = ue(a);
|
|
534
|
+
if (!s) return null;
|
|
535
|
+
const l = s.CPNAME === "" ? 0 : ne(e, X.IAC_THICKNESS, fe)?.thickness || 0, u = ne(at(e), X.IAC_THICKNESS, fe)?.thickness || 0, h = ne(st(e), X.IAC_THICKNESS, fe)?.thickness || 0, m = s.CPNAME === "" ? 0 : s.INSETFOR !== "" ? se(i(s.INSETFOR)) : Number(s.INSET), p = (typeof m == "string" ? 0 : m) || 0, E = s.MANINFO || "black", y = s.CPNAME, c = o?.topShelfThk || 0, d = o?.bottomShelfThk || 0, g = {
|
|
536
|
+
start: Number(s.STARTOFFS) || 0,
|
|
537
|
+
end: Number(s.ENDOFFS) || 0,
|
|
538
|
+
top: Number(s.TOPOFFS) || 0,
|
|
539
|
+
bottom: Number(s.BOTOFFS) || 0
|
|
540
|
+
}, I = {
|
|
541
|
+
start: s.STARTTRIM,
|
|
542
|
+
end: s.ENDTRIM,
|
|
543
|
+
top: s.TOPTRIM,
|
|
544
|
+
bottom: s.BOTTRIM
|
|
545
|
+
}, N = {
|
|
546
|
+
top: I.top === "S" ? c : 0,
|
|
547
|
+
bottom: I.bottom === "S" ? d : 0
|
|
548
|
+
};
|
|
549
|
+
return {
|
|
550
|
+
TREEID: e,
|
|
551
|
+
thk: l,
|
|
552
|
+
nxtThk: u,
|
|
553
|
+
prvThk: h,
|
|
554
|
+
inset: p,
|
|
555
|
+
color: E,
|
|
556
|
+
CPNAME: y,
|
|
557
|
+
topThk: c,
|
|
558
|
+
bottomThk: d,
|
|
559
|
+
oversize: g,
|
|
560
|
+
trim: I,
|
|
561
|
+
elmTrimThk: N
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
var A = class extends Error {
|
|
565
|
+
constructor(e) {
|
|
566
|
+
super(`Evaluation Error: ${e}`), this.name = "EvaluationError";
|
|
567
|
+
}
|
|
568
|
+
}, H, lt = (H = class {
|
|
569
|
+
constructor() {
|
|
570
|
+
C(this, "cache", /* @__PURE__ */ new Map());
|
|
571
|
+
C(this, "source", "");
|
|
572
|
+
C(this, "tokens", []);
|
|
573
|
+
C(this, "start", 0);
|
|
574
|
+
C(this, "current", 0);
|
|
575
|
+
C(this, "errors", []);
|
|
576
|
+
}
|
|
577
|
+
reportError(t) {
|
|
578
|
+
this.errors.push(t);
|
|
579
|
+
}
|
|
580
|
+
scan(t) {
|
|
581
|
+
if (this.cache.has(t)) {
|
|
582
|
+
const r = this.cache.get(t);
|
|
583
|
+
return this.cache.delete(t), this.cache.set(t, r), r;
|
|
584
|
+
}
|
|
585
|
+
try {
|
|
586
|
+
this.source = t;
|
|
587
|
+
const r = this.preformScan();
|
|
588
|
+
if (this.cache.set(this.source, r), this.cache.size > 3) {
|
|
589
|
+
const i = this.cache.keys().next().value;
|
|
590
|
+
this.cache.delete(i);
|
|
591
|
+
}
|
|
592
|
+
return r;
|
|
593
|
+
} catch (r) {
|
|
594
|
+
throw console.error(r), new Error(r instanceof Error ? r.message : String(r));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
preformScan() {
|
|
598
|
+
this.resetState();
|
|
599
|
+
try {
|
|
600
|
+
if (this.source.includes("<") || this.source.includes(">"))
|
|
601
|
+
throw new Error("Angle brackets are not allowed in the input string");
|
|
602
|
+
if (this.source.length === 0)
|
|
603
|
+
throw new Error("Empty input string");
|
|
604
|
+
for (this.start = 0, this.current = 0, this.tokens = [], this.start === 0 && this.addToken("LEFT_ANGLE_BRACKET", "<"); !this.isAtEnd(); ) {
|
|
605
|
+
this.start = this.current;
|
|
606
|
+
const t = this.peek();
|
|
607
|
+
switch (t) {
|
|
608
|
+
case ":":
|
|
609
|
+
this.addToken("RIGHT_ANGLE_BRACKET", ">"), this.addToken("LEFT_ANGLE_BRACKET", "<"), this.advance();
|
|
610
|
+
break;
|
|
611
|
+
case " ":
|
|
612
|
+
case "\r":
|
|
613
|
+
case " ":
|
|
614
|
+
case `
|
|
615
|
+
`:
|
|
616
|
+
this.advance();
|
|
617
|
+
break;
|
|
618
|
+
case "0":
|
|
619
|
+
case "1":
|
|
620
|
+
case "2":
|
|
621
|
+
case "3":
|
|
622
|
+
case "4":
|
|
623
|
+
case "5":
|
|
624
|
+
case "6":
|
|
625
|
+
case "7":
|
|
626
|
+
case "8":
|
|
627
|
+
case "9":
|
|
628
|
+
case ".":
|
|
629
|
+
this.scanNumber();
|
|
630
|
+
break;
|
|
631
|
+
case "$":
|
|
632
|
+
this.scanVariable();
|
|
633
|
+
break;
|
|
634
|
+
case "+":
|
|
635
|
+
case "-":
|
|
636
|
+
case "*":
|
|
637
|
+
case "/":
|
|
638
|
+
this.addToken("OPERATOR", t), this.advance();
|
|
639
|
+
break;
|
|
640
|
+
case "(":
|
|
641
|
+
this.addToken("PAREN_OPEN", "("), this.advance();
|
|
642
|
+
break;
|
|
643
|
+
case ")":
|
|
644
|
+
this.addToken("PAREN_CLOSE", ")"), this.advance();
|
|
645
|
+
break;
|
|
646
|
+
case "{":
|
|
647
|
+
this.current != 0 && this.tokens[this.tokens.length - 1].type != "OPERATOR" && this.addToken("OPERATOR", "*"), this.addToken("BRACE_OPEN", "{"), this.addToken("LEFT_ANGLE_BRACKET", "<"), this.advance();
|
|
648
|
+
break;
|
|
649
|
+
case "}":
|
|
650
|
+
this.addToken("RIGHT_ANGLE_BRACKET", ">"), this.addToken("BRACE_CLOSE", "}"), this.advance();
|
|
651
|
+
break;
|
|
652
|
+
case "[":
|
|
653
|
+
this.addToken("OPERATOR", "~"), this.addToken("BRACKET_OPEN", "["), this.advance();
|
|
654
|
+
break;
|
|
655
|
+
case "]":
|
|
656
|
+
this.addToken("BRACKET_CLOSE", "]"), this.advance();
|
|
657
|
+
break;
|
|
658
|
+
case "m":
|
|
659
|
+
this.peekNext() === "m" ? this.scanMm() : this.scanIdentifierOrFunction();
|
|
660
|
+
break;
|
|
661
|
+
default:
|
|
662
|
+
this.isAlpha(t) ? this.scanIdentifierOrFunction() : this.reportError(
|
|
663
|
+
`Unexpected character: ${t} at position: ${this.current}`
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (this.addToken("RIGHT_ANGLE_BRACKET", ">"), this.addToken("EOF", ""), this.errors.length > 0)
|
|
668
|
+
throw new Error(this.errors.join(`,
|
|
669
|
+
`));
|
|
670
|
+
return this.tokens;
|
|
671
|
+
} catch (t) {
|
|
672
|
+
throw new Error(t instanceof Error ? t.message : String(t));
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
isAtEnd() {
|
|
676
|
+
return this.current >= this.source.length;
|
|
677
|
+
}
|
|
678
|
+
advance() {
|
|
679
|
+
return this.source.charAt(this.current++);
|
|
680
|
+
}
|
|
681
|
+
peek() {
|
|
682
|
+
return this.isAtEnd() ? "\0" : this.source.charAt(this.current);
|
|
683
|
+
}
|
|
684
|
+
peekNext() {
|
|
685
|
+
return this.current + 1 >= this.source.length ? "\0" : this.source.charAt(this.current + 1);
|
|
686
|
+
}
|
|
687
|
+
addToken(t, r) {
|
|
688
|
+
this.tokens.push({
|
|
689
|
+
type: t,
|
|
690
|
+
lexeme: r || (t ? this.source.substring(this.start, this.current) : ""),
|
|
691
|
+
position: this.start
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
isDigit(t) {
|
|
695
|
+
return /^[0-9]$/.test(t);
|
|
696
|
+
}
|
|
697
|
+
isAlpha(t) {
|
|
698
|
+
return /^[a-zA-Z]$/.test(t);
|
|
699
|
+
}
|
|
700
|
+
scanNumber() {
|
|
701
|
+
for (; this.isDigit(this.peek()); )
|
|
702
|
+
this.advance();
|
|
703
|
+
if (this.peek() === ".")
|
|
704
|
+
for (this.advance(), this.isDigit(this.peek()) || this.reportError(
|
|
705
|
+
"Expected digit after decimal point at position: " + this.current
|
|
706
|
+
); this.isDigit(this.peek()); )
|
|
707
|
+
this.advance();
|
|
708
|
+
this.addToken(
|
|
709
|
+
"NUMBER"
|
|
710
|
+
/* NUMBER */
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
scanVariable() {
|
|
714
|
+
for (this.advance(); /[a-zA-Z0-9_]/.test(this.peek()); )
|
|
715
|
+
this.advance();
|
|
716
|
+
const t = this.source.substring(this.start + 1, this.current);
|
|
717
|
+
if (t.endsWith("mm")) {
|
|
718
|
+
const r = t.substring(0, t.length - 2);
|
|
719
|
+
r && r.length > 0 ? (this.addToken("VARIABLE", r), this.addToken("UNIT", "mm")) : this.reportError("Variable name cannot be empty or $mm");
|
|
720
|
+
} else
|
|
721
|
+
this.addToken("VARIABLE", t);
|
|
722
|
+
}
|
|
723
|
+
scanMm() {
|
|
724
|
+
this.advance(), this.advance(), this.addToken("UNIT", "mm");
|
|
725
|
+
}
|
|
726
|
+
scanIdentifierOrFunction() {
|
|
727
|
+
const t = ["X", "Y", "n"];
|
|
728
|
+
for (; this.isAlpha(this.peek()); )
|
|
729
|
+
this.advance();
|
|
730
|
+
const r = this.source.substring(this.start, this.current), i = H.MATHEMATICAL_FUNCTIONS[r.toLocaleLowerCase()];
|
|
731
|
+
i != null ? this.addToken(i, r) : t.includes(r) ? this.addToken("SPECIAL_VARIABLE", r) : this.reportError(
|
|
732
|
+
`Unknown identifier: ${r} at position: ${this.current}`
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
resetState() {
|
|
736
|
+
this.tokens = [], this.start = 0, this.current = 0, this.errors = [];
|
|
737
|
+
}
|
|
738
|
+
}, C(H, "MATHEMATICAL_FUNCTIONS", {
|
|
739
|
+
abs: "FUNCTION",
|
|
740
|
+
acos: "FUNCTION",
|
|
741
|
+
asin: "FUNCTION",
|
|
742
|
+
atan: "FUNCTION",
|
|
743
|
+
bog2deg: "FUNCTION",
|
|
744
|
+
cos: "FUNCTION",
|
|
745
|
+
deg2bog: "FUNCTION",
|
|
746
|
+
in2mm: "FUNCTION",
|
|
747
|
+
ln: "FUNCTION",
|
|
748
|
+
log: "FUNCTION",
|
|
749
|
+
log10: "FUNCTION",
|
|
750
|
+
max: "FUNCTION",
|
|
751
|
+
maxunder: "FUNCTION",
|
|
752
|
+
mm2in: "FUNCTION",
|
|
753
|
+
nextto: "FUNCTION",
|
|
754
|
+
pi: "FUNCTION",
|
|
755
|
+
pow: "FUNCTION",
|
|
756
|
+
round: "FUNCTION",
|
|
757
|
+
sin: "FUNCTION",
|
|
758
|
+
sqr: "FUNCTION",
|
|
759
|
+
tab: "FUNCTION",
|
|
760
|
+
tan: "FUNCTION"
|
|
761
|
+
/* FUNCTION */
|
|
762
|
+
}), H), ct = class {
|
|
763
|
+
constructor() {
|
|
764
|
+
C(this, "cache", /* @__PURE__ */ new Map());
|
|
765
|
+
C(this, "tokens", []);
|
|
766
|
+
C(this, "current", 0);
|
|
767
|
+
C(this, "resetCurrent", () => {
|
|
768
|
+
this.current = 0;
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
parse(e) {
|
|
772
|
+
if (this.cache.has(e)) {
|
|
773
|
+
const t = this.cache.get(e);
|
|
774
|
+
return this.cache.delete(e), this.cache.set(e, t), t;
|
|
775
|
+
}
|
|
776
|
+
try {
|
|
777
|
+
this.tokens = e;
|
|
778
|
+
const t = this.performParse(e);
|
|
779
|
+
if (this.cache.set(e, t), this.cache.size > 3) {
|
|
780
|
+
const r = this.cache.keys().next().value;
|
|
781
|
+
this.cache.delete(r);
|
|
782
|
+
}
|
|
783
|
+
return t;
|
|
784
|
+
} catch (t) {
|
|
785
|
+
throw new Error(t instanceof Error ? t.message : String(t));
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
performParse(e) {
|
|
789
|
+
if (this.resetCurrent(), this.tokens.length === 0)
|
|
790
|
+
throw new Error("No tokens to parse.");
|
|
791
|
+
try {
|
|
792
|
+
return this.expression();
|
|
793
|
+
} catch (t) {
|
|
794
|
+
throw new Error(t instanceof Error ? t.message : String(t));
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
checkMillimeterSuffix() {
|
|
798
|
+
if (this.isAtEnd()) return !1;
|
|
799
|
+
const e = this.peek();
|
|
800
|
+
return e.type === "UNIT" && e.lexeme === "mm";
|
|
801
|
+
}
|
|
802
|
+
consumeMillimeterSuffix() {
|
|
803
|
+
return this.checkMillimeterSuffix() ? (this.advance(), !0) : !1;
|
|
804
|
+
}
|
|
805
|
+
sections() {
|
|
806
|
+
const e = [];
|
|
807
|
+
if (!this.check(
|
|
808
|
+
"LEFT_ANGLE_BRACKET"
|
|
809
|
+
/* ANGLE_BRACKET_OPEN */
|
|
810
|
+
))
|
|
811
|
+
return this.expression();
|
|
812
|
+
for (; this.check(
|
|
813
|
+
"LEFT_ANGLE_BRACKET"
|
|
814
|
+
/* ANGLE_BRACKET_OPEN */
|
|
815
|
+
); ) {
|
|
816
|
+
this.advance();
|
|
817
|
+
let t = this.expression();
|
|
818
|
+
this.consume(
|
|
819
|
+
"RIGHT_ANGLE_BRACKET",
|
|
820
|
+
"Expected '>' after section expression."
|
|
821
|
+
), e.push({
|
|
822
|
+
type: "Section",
|
|
823
|
+
nodes: t,
|
|
824
|
+
hasMillimeterSuffix: this.consumeMillimeterSuffix()
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
if (e.length === 1) {
|
|
828
|
+
const t = e[0];
|
|
829
|
+
return t.type === "Section" && t.nodes.type === "Section" ? t.nodes : t;
|
|
830
|
+
}
|
|
831
|
+
return {
|
|
832
|
+
type: "Sections",
|
|
833
|
+
sections: e
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
expression() {
|
|
837
|
+
try {
|
|
838
|
+
let e = this.term();
|
|
839
|
+
for (; !this.isAtEnd() && this.check(
|
|
840
|
+
"OPERATOR"
|
|
841
|
+
/* OPERATOR */
|
|
842
|
+
) && ["+", "-"].includes(this.peek().lexeme); ) {
|
|
843
|
+
this.advance();
|
|
844
|
+
const t = this.previous().lexeme, r = this.term();
|
|
845
|
+
e = {
|
|
846
|
+
type: "BinaryExpression",
|
|
847
|
+
left: e,
|
|
848
|
+
operator: t,
|
|
849
|
+
right: r
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
return e;
|
|
853
|
+
} catch (e) {
|
|
854
|
+
throw new Error(
|
|
855
|
+
`Failed to parse expression: ${e.message}`
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
term() {
|
|
860
|
+
try {
|
|
861
|
+
let e = this.factor();
|
|
862
|
+
for (; !this.isAtEnd() && this.check(
|
|
863
|
+
"OPERATOR"
|
|
864
|
+
/* OPERATOR */
|
|
865
|
+
) && ["*", "/", "~"].includes(this.peek().lexeme); ) {
|
|
866
|
+
this.advance();
|
|
867
|
+
const t = this.previous().lexeme, r = this.factor();
|
|
868
|
+
if (r.type === "SpecialVariable" && r.name === "n")
|
|
869
|
+
throw new Error(
|
|
870
|
+
'Invalid usage: "n" cannot appear on the right-hand side of an operator'
|
|
871
|
+
);
|
|
872
|
+
e = {
|
|
873
|
+
type: "BinaryExpression",
|
|
874
|
+
left: e,
|
|
875
|
+
operator: t,
|
|
876
|
+
right: r
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
return e;
|
|
880
|
+
} catch (e) {
|
|
881
|
+
throw new Error(`Failed to parse term: ${e.message}`);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
factor() {
|
|
885
|
+
try {
|
|
886
|
+
if (this.check(
|
|
887
|
+
"OPERATOR"
|
|
888
|
+
/* OPERATOR */
|
|
889
|
+
) && ["-", "+"].includes(this.peek().lexeme)) {
|
|
890
|
+
this.advance();
|
|
891
|
+
const e = this.previous().lexeme, t = this.factor();
|
|
892
|
+
return {
|
|
893
|
+
type: "UnaryExpression",
|
|
894
|
+
operator: e,
|
|
895
|
+
right: t
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
return this.primary();
|
|
899
|
+
} catch (e) {
|
|
900
|
+
throw new Error(`Failed to parse factor: ${e.message}`);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
primary() {
|
|
904
|
+
try {
|
|
905
|
+
if (this.check(
|
|
906
|
+
"NUMBER"
|
|
907
|
+
/* NUMBER */
|
|
908
|
+
))
|
|
909
|
+
return this.advance(), {
|
|
910
|
+
type: "NumberLiteral",
|
|
911
|
+
value: parseFloat(this.previous().lexeme),
|
|
912
|
+
hasMillimeterSuffix: this.consumeMillimeterSuffix()
|
|
913
|
+
};
|
|
914
|
+
if (this.check(
|
|
915
|
+
"VARIABLE"
|
|
916
|
+
/* VARIABLE */
|
|
917
|
+
))
|
|
918
|
+
return this.advance(), {
|
|
919
|
+
type: "Variable",
|
|
920
|
+
name: this.previous().lexeme,
|
|
921
|
+
hasMillimeterSuffix: this.consumeMillimeterSuffix()
|
|
922
|
+
};
|
|
923
|
+
if (this.check(
|
|
924
|
+
"SPECIAL_VARIABLE"
|
|
925
|
+
/* SPECIAL_VARIABLE */
|
|
926
|
+
))
|
|
927
|
+
return this.advance(), {
|
|
928
|
+
type: "SpecialVariable",
|
|
929
|
+
name: this.previous().lexeme,
|
|
930
|
+
hasMillimeterSuffix: this.previous().lexeme === "n"
|
|
931
|
+
};
|
|
932
|
+
if (this.check(
|
|
933
|
+
"FUNCTION"
|
|
934
|
+
/* FUNCTION */
|
|
935
|
+
)) {
|
|
936
|
+
this.advance();
|
|
937
|
+
const e = this.previous().lexeme;
|
|
938
|
+
this.consume(
|
|
939
|
+
"PAREN_OPEN",
|
|
940
|
+
`Expected '(' after function name '${e}'.`
|
|
941
|
+
);
|
|
942
|
+
const t = this.expression();
|
|
943
|
+
return this.consume(
|
|
944
|
+
"PAREN_CLOSE",
|
|
945
|
+
"Expected ')' after function arguments."
|
|
946
|
+
), {
|
|
947
|
+
type: "FunctionCall",
|
|
948
|
+
name: e,
|
|
949
|
+
arg: t,
|
|
950
|
+
hasMillimeterSuffix: this.consumeMillimeterSuffix()
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
if (this.check(
|
|
954
|
+
"PAREN_OPEN"
|
|
955
|
+
/* PAREN_OPEN */
|
|
956
|
+
)) {
|
|
957
|
+
this.advance();
|
|
958
|
+
const e = this.expression();
|
|
959
|
+
if (!e)
|
|
960
|
+
throw new Error("Expected expression inside parentheses.");
|
|
961
|
+
return this.consume("PAREN_CLOSE", "Expected ')' after expression."), {
|
|
962
|
+
type: "Grouping",
|
|
963
|
+
expression: e,
|
|
964
|
+
hasMillimeterSuffix: this.consumeMillimeterSuffix()
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
if (this.check(
|
|
968
|
+
"PAREN_CLOSE"
|
|
969
|
+
/* PAREN_CLOSE */
|
|
970
|
+
))
|
|
971
|
+
throw new Error("Unexpected ')' without a matching '('.");
|
|
972
|
+
if (this.check(
|
|
973
|
+
"BRACE_OPEN"
|
|
974
|
+
/* BRACE_OPEN */
|
|
975
|
+
)) {
|
|
976
|
+
this.advance();
|
|
977
|
+
let e = this.sections();
|
|
978
|
+
return this.consume("BRACE_CLOSE", "Expected '}' after expression."), e.type === "Section" && e.nodes.type === "Section" && (e = e.nodes), {
|
|
979
|
+
type: "Repeated",
|
|
980
|
+
toRepeat: e,
|
|
981
|
+
hasMillimeterSuffix: this.consumeMillimeterSuffix()
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
if (this.check(
|
|
985
|
+
"LEFT_ANGLE_BRACKET"
|
|
986
|
+
/* ANGLE_BRACKET_OPEN */
|
|
987
|
+
))
|
|
988
|
+
return this.sections();
|
|
989
|
+
throw new Error(`Unexpected token: ${this.peek().lexeme}`);
|
|
990
|
+
} catch (e) {
|
|
991
|
+
throw new Error(`Failed to parse primary: ${e.message}`);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
check(e) {
|
|
995
|
+
return this.isAtEnd() ? !1 : this.peek().type === e;
|
|
996
|
+
}
|
|
997
|
+
advance() {
|
|
998
|
+
return this.isAtEnd() || this.current++, this.previous();
|
|
999
|
+
}
|
|
1000
|
+
consume(e, t) {
|
|
1001
|
+
if (this.check(e)) return this.advance();
|
|
1002
|
+
throw new Error(t);
|
|
1003
|
+
}
|
|
1004
|
+
isAtEnd() {
|
|
1005
|
+
return this.current >= this.tokens.length;
|
|
1006
|
+
}
|
|
1007
|
+
peek() {
|
|
1008
|
+
return this.tokens[this.current];
|
|
1009
|
+
}
|
|
1010
|
+
previous() {
|
|
1011
|
+
return this.tokens[this.current - 1];
|
|
1012
|
+
}
|
|
1013
|
+
}, xe = (e) => e.type === "SpecialVariable" && e.name === "n";
|
|
1014
|
+
function ut(e, t) {
|
|
1015
|
+
if (e.right.type === "SpecialVariable" && e.right.name === "n")
|
|
1016
|
+
return new A(
|
|
1017
|
+
"Cannot have n in the right side of an expression"
|
|
1018
|
+
);
|
|
1019
|
+
const r = xe(e.left) ? e.left : this.evaluate(e.left), i = xe(e.right) ? e.right : this.evaluate(e.right);
|
|
1020
|
+
if (r instanceof A) return r;
|
|
1021
|
+
if (i instanceof A) return i;
|
|
1022
|
+
const n = r.type === "NumberLiteral" && i.type === "NumberLiteral", s = n ? r.hasMillimeterSuffix === i.hasMillimeterSuffix : !1, a = (o) => o.type === "Repeated";
|
|
1023
|
+
switch (e.operator) {
|
|
1024
|
+
case "+":
|
|
1025
|
+
return n && s && t?.isInsideGroup == !1 ? {
|
|
1026
|
+
type: "NumberLiteral",
|
|
1027
|
+
value: r.value + i.value,
|
|
1028
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix === !0 || i.hasMillimeterSuffix === !0,
|
|
1029
|
+
spreadMm: r.spreadMm || i.spreadMm
|
|
1030
|
+
} : n && t?.isInsideGroup == !0 ? {
|
|
1031
|
+
type: "NumberLiteral",
|
|
1032
|
+
value: r.value + i.value,
|
|
1033
|
+
spreadMm: r.hasMillimeterSuffix || i.hasMillimeterSuffix
|
|
1034
|
+
} : {
|
|
1035
|
+
type: "BinaryExpression",
|
|
1036
|
+
operator: "+",
|
|
1037
|
+
left: r,
|
|
1038
|
+
right: i
|
|
1039
|
+
};
|
|
1040
|
+
case "*":
|
|
1041
|
+
return n && t?.isInsideGroup == !0 ? {
|
|
1042
|
+
type: "NumberLiteral",
|
|
1043
|
+
value: r.value * i.value,
|
|
1044
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix === !0 || i.hasMillimeterSuffix === !0,
|
|
1045
|
+
spreadMm: r.spreadMm || i.spreadMm
|
|
1046
|
+
} : a(i) && r.type === "NumberLiteral" ? {
|
|
1047
|
+
type: "Repeated",
|
|
1048
|
+
toRepeat: i.toRepeat,
|
|
1049
|
+
times: Math.round(r.value),
|
|
1050
|
+
hasMillimeterSuffix: i.type === "NumberLiteral" && i.hasMillimeterSuffix || !1
|
|
1051
|
+
} : t?.isInsideGroup == !1 && r.type !== "SpecialVariable" && r.name !== "n" ? new A("cannot have * outside of group") : r.type === "SpecialVariable" ? {
|
|
1052
|
+
type: "BinaryExpression",
|
|
1053
|
+
operator: "*",
|
|
1054
|
+
left: r,
|
|
1055
|
+
right: {
|
|
1056
|
+
type: "NumberLiteral",
|
|
1057
|
+
value: i.value,
|
|
1058
|
+
hasMillimeterSuffix: !0
|
|
1059
|
+
}
|
|
1060
|
+
} : {
|
|
1061
|
+
type: "BinaryExpression",
|
|
1062
|
+
operator: "*",
|
|
1063
|
+
left: r,
|
|
1064
|
+
right: i,
|
|
1065
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix || i.hasMillimeterSuffix
|
|
1066
|
+
};
|
|
1067
|
+
case "/":
|
|
1068
|
+
if (n && t?.isInsideGroup == !0)
|
|
1069
|
+
return {
|
|
1070
|
+
type: "NumberLiteral",
|
|
1071
|
+
value: r.value / i.value,
|
|
1072
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix === !0 || i.hasMillimeterSuffix === !0
|
|
1073
|
+
};
|
|
1074
|
+
if (t?.isInsideGroup == !1)
|
|
1075
|
+
return new A("cannot have / outside of group");
|
|
1076
|
+
case "-":
|
|
1077
|
+
return n && s && t?.isInsideGroup == !1 ? {
|
|
1078
|
+
type: "NumberLiteral",
|
|
1079
|
+
value: r.value - i.value,
|
|
1080
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix === !0 || i.hasMillimeterSuffix === !0,
|
|
1081
|
+
spreadMm: r.spreadMm || i.spreadMm
|
|
1082
|
+
} : n && t?.isInsideGroup == !0 ? {
|
|
1083
|
+
type: "NumberLiteral",
|
|
1084
|
+
value: r.value - i.value,
|
|
1085
|
+
spreadMm: r.hasMillimeterSuffix || i.hasMillimeterSuffix
|
|
1086
|
+
} : {
|
|
1087
|
+
type: "BinaryExpression",
|
|
1088
|
+
operator: "-",
|
|
1089
|
+
left: r,
|
|
1090
|
+
right: i
|
|
1091
|
+
};
|
|
1092
|
+
default:
|
|
1093
|
+
throw new A("Invalid Operator");
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
function ht(e, t) {
|
|
1097
|
+
const r = this.evaluate(e.arg);
|
|
1098
|
+
if (r instanceof A)
|
|
1099
|
+
throw new A("Error in function arguments");
|
|
1100
|
+
switch (e.name.toLowerCase()) {
|
|
1101
|
+
case "abs":
|
|
1102
|
+
return {
|
|
1103
|
+
type: "NumberLiteral",
|
|
1104
|
+
value: Math.abs(r.value),
|
|
1105
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1106
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1107
|
+
};
|
|
1108
|
+
case "acos":
|
|
1109
|
+
return {
|
|
1110
|
+
type: "NumberLiteral",
|
|
1111
|
+
value: Math.acos(r.value),
|
|
1112
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1113
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1114
|
+
};
|
|
1115
|
+
case "asin":
|
|
1116
|
+
return {
|
|
1117
|
+
type: "NumberLiteral",
|
|
1118
|
+
value: Math.asin(r.value),
|
|
1119
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1120
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1121
|
+
};
|
|
1122
|
+
case "atan":
|
|
1123
|
+
return {
|
|
1124
|
+
type: "NumberLiteral",
|
|
1125
|
+
value: Math.atan(r.value),
|
|
1126
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1127
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1128
|
+
};
|
|
1129
|
+
case "cos":
|
|
1130
|
+
return {
|
|
1131
|
+
type: "NumberLiteral",
|
|
1132
|
+
value: Math.cos(r.value),
|
|
1133
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1134
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1135
|
+
};
|
|
1136
|
+
case "sin":
|
|
1137
|
+
return {
|
|
1138
|
+
type: "NumberLiteral",
|
|
1139
|
+
value: Math.sin(r.value),
|
|
1140
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1141
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1142
|
+
};
|
|
1143
|
+
case "tan":
|
|
1144
|
+
return {
|
|
1145
|
+
type: "NumberLiteral",
|
|
1146
|
+
value: Math.tan(r.value),
|
|
1147
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1148
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1149
|
+
};
|
|
1150
|
+
case "round":
|
|
1151
|
+
return {
|
|
1152
|
+
type: "NumberLiteral",
|
|
1153
|
+
value: Math.round(r.value),
|
|
1154
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1155
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1156
|
+
};
|
|
1157
|
+
case "bog2deg":
|
|
1158
|
+
return {
|
|
1159
|
+
type: "NumberLiteral",
|
|
1160
|
+
value: r.value * (180 / Math.PI),
|
|
1161
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1162
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1163
|
+
};
|
|
1164
|
+
case "deg2bog":
|
|
1165
|
+
return {
|
|
1166
|
+
type: "NumberLiteral",
|
|
1167
|
+
value: r.value * (Math.PI / 180),
|
|
1168
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1169
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1170
|
+
};
|
|
1171
|
+
case "in2mm":
|
|
1172
|
+
return {
|
|
1173
|
+
type: "NumberLiteral",
|
|
1174
|
+
value: r.value * 25.4,
|
|
1175
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1176
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1177
|
+
};
|
|
1178
|
+
case "mm2in":
|
|
1179
|
+
return {
|
|
1180
|
+
type: "NumberLiteral",
|
|
1181
|
+
value: r.value / 25.4,
|
|
1182
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1183
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1184
|
+
};
|
|
1185
|
+
case "ln":
|
|
1186
|
+
return {
|
|
1187
|
+
type: "NumberLiteral",
|
|
1188
|
+
value: Math.log(r.value),
|
|
1189
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1190
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1191
|
+
};
|
|
1192
|
+
case "log10":
|
|
1193
|
+
return {
|
|
1194
|
+
type: "NumberLiteral",
|
|
1195
|
+
value: Math.log10(r.value),
|
|
1196
|
+
hasMillimeterSuffix: r.hasMillimeterSuffix,
|
|
1197
|
+
spreadMm: t?.isInsideGroup === !1
|
|
1198
|
+
};
|
|
1199
|
+
default:
|
|
1200
|
+
throw new A("Function not implemented");
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
function ft(e) {
|
|
1204
|
+
if (!this.variables || !(e.name in this.variables))
|
|
1205
|
+
throw new A(`Variable ${e.name} is not defined.`);
|
|
1206
|
+
return {
|
|
1207
|
+
type: "NumberLiteral",
|
|
1208
|
+
value: this.variables[e.name],
|
|
1209
|
+
hasMillimeterSuffix: e.hasMillimeterSuffix
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
var mt = class {
|
|
1213
|
+
constructor() {
|
|
1214
|
+
C(this, "nestingLevel", 0);
|
|
1215
|
+
C(this, "variables", {});
|
|
1216
|
+
// evaluate binary expression
|
|
1217
|
+
C(this, "evaluateBinaryExpression");
|
|
1218
|
+
C(this, "evaluateFunction");
|
|
1219
|
+
C(this, "evaluateVariable");
|
|
1220
|
+
this.evaluateBinaryExpression = ut.bind(this), this.evaluateFunction = ht.bind(this), this.evaluateVariable = ft.bind(this);
|
|
1221
|
+
}
|
|
1222
|
+
evaluate(e, t = { isInsideGroup: !1 }, r) {
|
|
1223
|
+
this.nestingLevel++;
|
|
1224
|
+
try {
|
|
1225
|
+
if (r && (this.variables = r), this.isSections(e))
|
|
1226
|
+
return this.evaluateSections(e, t);
|
|
1227
|
+
if (this.isSection(e)) {
|
|
1228
|
+
const i = this.evaluate(e.nodes, t);
|
|
1229
|
+
return i instanceof A ? new A(
|
|
1230
|
+
`Error in section ${JSON.stringify(e)}`
|
|
1231
|
+
) : { ...e, nodes: i };
|
|
1232
|
+
}
|
|
1233
|
+
if (this.isNumberLiteral(e))
|
|
1234
|
+
if (t.isInsideGroup) {
|
|
1235
|
+
if (e.hasMillimeterSuffix)
|
|
1236
|
+
return { ...e, spreadMm: !0 };
|
|
1237
|
+
} else
|
|
1238
|
+
return e;
|
|
1239
|
+
if (this.isGrouping(e)) {
|
|
1240
|
+
t = { ...t, isInsideGroup: !0 };
|
|
1241
|
+
const i = this.evaluate(e.expression, t);
|
|
1242
|
+
return i instanceof A ? i : {
|
|
1243
|
+
...i,
|
|
1244
|
+
hasMillimeterSuffix: e.hasMillimeterSuffix
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
if (this.isRepeated(e)) {
|
|
1248
|
+
const i = this.evaluate(e.toRepeat);
|
|
1249
|
+
return i instanceof A ? i : { ...e, toRepeat: i };
|
|
1250
|
+
}
|
|
1251
|
+
if (this.isBinaryExpression(e))
|
|
1252
|
+
return this.evaluateBinaryExpression(e, t);
|
|
1253
|
+
if (this.isUnaryExpression(e))
|
|
1254
|
+
return {
|
|
1255
|
+
type: "NumberLiteral",
|
|
1256
|
+
value: e.operator === "-" ? -1 * e.right.value : e.right.value,
|
|
1257
|
+
hasMillimeterSuffix: e.right.hasMillimeterSuffix
|
|
1258
|
+
};
|
|
1259
|
+
if (this.isFunctionCall(e))
|
|
1260
|
+
return this.evaluateFunction(e, t);
|
|
1261
|
+
if (this.isVariable(e)) {
|
|
1262
|
+
if (this.variables)
|
|
1263
|
+
return this.evaluateVariable(e);
|
|
1264
|
+
throw new A("No variables defined.");
|
|
1265
|
+
}
|
|
1266
|
+
throw new A(`unsupported node type: ${e.type}`);
|
|
1267
|
+
} catch (i) {
|
|
1268
|
+
throw new A(i.message);
|
|
1269
|
+
} finally {
|
|
1270
|
+
this.nestingLevel--;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
isUnaryExpression(e) {
|
|
1274
|
+
return e.type === "UnaryExpression";
|
|
1275
|
+
}
|
|
1276
|
+
isNumberLiteral(e) {
|
|
1277
|
+
return e.type === "NumberLiteral";
|
|
1278
|
+
}
|
|
1279
|
+
isVariable(e) {
|
|
1280
|
+
return e.type === "Variable" || e.type === "SpecialVariable";
|
|
1281
|
+
}
|
|
1282
|
+
isBinaryExpression(e) {
|
|
1283
|
+
return e.type === "BinaryExpression";
|
|
1284
|
+
}
|
|
1285
|
+
isFunctionCall(e) {
|
|
1286
|
+
return e.type === "FunctionCall";
|
|
1287
|
+
}
|
|
1288
|
+
isGrouping(e) {
|
|
1289
|
+
return e.type === "Grouping";
|
|
1290
|
+
}
|
|
1291
|
+
isRepeated(e) {
|
|
1292
|
+
return e.type === "Repeated";
|
|
1293
|
+
}
|
|
1294
|
+
isSections(e) {
|
|
1295
|
+
return e.type === "Sections";
|
|
1296
|
+
}
|
|
1297
|
+
isSection(e) {
|
|
1298
|
+
return e.type === "Section";
|
|
1299
|
+
}
|
|
1300
|
+
evaluateSections(e, t = { isInsideGroup: !1 }) {
|
|
1301
|
+
return { type: "Sections", sections: e.sections.map((i) => {
|
|
1302
|
+
const n = this.evaluate(i.nodes);
|
|
1303
|
+
if (n instanceof A) throw n;
|
|
1304
|
+
return { type: "Section", nodes: n };
|
|
1305
|
+
}) };
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
function G(e, t) {
|
|
1309
|
+
if (!e)
|
|
1310
|
+
throw new A(
|
|
1311
|
+
`unsupported node type to traverse: ${JSON.stringify(e)}`
|
|
1312
|
+
);
|
|
1313
|
+
t(e), e.type === "Sections" && Array.isArray(e.sections) ? e.sections.forEach((r) => G(r, t)) : e.type === "Section" && e.nodes ? G(e.nodes, t) : e.type;
|
|
1314
|
+
}
|
|
1315
|
+
var pt = class {
|
|
1316
|
+
accumulateIncorporatedThicknesses(e, t, r, i, n, s, a, o, l) {
|
|
1317
|
+
let u = 0;
|
|
1318
|
+
if (a === "M")
|
|
1319
|
+
for (let h = 1; h < e.sections.length - 1; h++)
|
|
1320
|
+
u += i;
|
|
1321
|
+
if (a === "O")
|
|
1322
|
+
for (let h = 1; h < e.sections.length - 1; h++)
|
|
1323
|
+
u += i * 2;
|
|
1324
|
+
return n === "M" && (u += t / 2), n === "O" && (u += t), s === "M" && (u += t / 2), s === "O" && (u += t), l === "M" && (u += r / 2), l === "O" && (u += r), o === "M" && (u += r / 2), o === "O" && (u += r), u;
|
|
1325
|
+
}
|
|
1326
|
+
}, dt = class {
|
|
1327
|
+
calculateSections(e, t = 500, r = 0, i) {
|
|
1328
|
+
try {
|
|
1329
|
+
if (e instanceof A)
|
|
1330
|
+
throw e;
|
|
1331
|
+
if (e.type !== "Sections" && e.type !== "Section")
|
|
1332
|
+
throw new A(
|
|
1333
|
+
`Expected Sections or Section, got ${JSON.stringify(e)}`
|
|
1334
|
+
);
|
|
1335
|
+
let n = { type: "Sections", sections: [] };
|
|
1336
|
+
if (e.type === "Sections")
|
|
1337
|
+
for (const c of e.sections)
|
|
1338
|
+
if (c.nodes.type === "Repeated" && c.nodes.times) {
|
|
1339
|
+
for (let d = 0; d < (c.nodes?.times ?? 0); d++)
|
|
1340
|
+
if (c.nodes.toRepeat.type === "Section")
|
|
1341
|
+
n.sections.push(
|
|
1342
|
+
c.nodes.toRepeat
|
|
1343
|
+
);
|
|
1344
|
+
else if (c.nodes.toRepeat.type === "Sections")
|
|
1345
|
+
for (const g of c.nodes.toRepeat.sections)
|
|
1346
|
+
n.sections.push(g);
|
|
1347
|
+
} else
|
|
1348
|
+
n.sections.push(c);
|
|
1349
|
+
else e.type === "Section" && n.sections.push(e);
|
|
1350
|
+
if (i) {
|
|
1351
|
+
const d = new pt().accumulateIncorporatedThicknesses(
|
|
1352
|
+
n,
|
|
1353
|
+
i.startPanelThk,
|
|
1354
|
+
i.endPanelThk,
|
|
1355
|
+
r,
|
|
1356
|
+
i.sizerefout1,
|
|
1357
|
+
i.sizerefedg1,
|
|
1358
|
+
i.sizerefmid,
|
|
1359
|
+
i.sizerefedg2,
|
|
1360
|
+
i.sizerefout2
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1363
|
+
n.sections.forEach((c) => {
|
|
1364
|
+
let d = !1;
|
|
1365
|
+
G(c, (g) => {
|
|
1366
|
+
g.type === "NumberLiteral" ? g?.spreadMm === !0 && (d = !0) : g.type === "BinaryExpression" && g.left.type === "NumberLiteral" && (g.left?.spreadMm === !0 && (d = !0), g.right?.spreadMm === !0 && (d = !0));
|
|
1367
|
+
}), d && G(c, (g) => {
|
|
1368
|
+
g.type === "NumberLiteral" ? g.hasMillimeterSuffix = !0 : g.type === "BinaryExpression" && (g.left.type === "NumberLiteral" && (g.left.hasMillimeterSuffix = !0), g.right.type === "NumberLiteral" && (g.right.hasMillimeterSuffix = !0));
|
|
1369
|
+
});
|
|
1370
|
+
});
|
|
1371
|
+
let s = 0;
|
|
1372
|
+
const a = (c) => {
|
|
1373
|
+
if (r && c.type === "Section" && (s += r), c.type === "NumberLiteral")
|
|
1374
|
+
c.hasMillimeterSuffix === !0 && (s += c.value);
|
|
1375
|
+
else if (c.type === "BinaryExpression") {
|
|
1376
|
+
const d = c;
|
|
1377
|
+
d.left.type === "NumberLiteral" && d.right.type === "NumberLiteral" && (d.left.hasMillimeterSuffix === !0 && (s += d.left.value), d.right.hasMillimeterSuffix === !0 && (s += d.right.value));
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
if (n.sections.forEach(
|
|
1381
|
+
(c) => G(c, a)
|
|
1382
|
+
), s > t)
|
|
1383
|
+
throw new A("Total length exceeded");
|
|
1384
|
+
let o = t - s + r, l = 0;
|
|
1385
|
+
const u = (c) => {
|
|
1386
|
+
if (c.type === "BinaryExpression") {
|
|
1387
|
+
const d = c;
|
|
1388
|
+
if (d.right.type === "NumberLiteral" && d.left.type === "SpecialVariable" && d.left.name === "n" && d.operator === "*") {
|
|
1389
|
+
l = Math.floor(
|
|
1390
|
+
o / (d.right.value + r)
|
|
1391
|
+
);
|
|
1392
|
+
const g = (l - 1) * r, I = l * d.right.value;
|
|
1393
|
+
o += -g - I;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
n.sections.forEach(
|
|
1398
|
+
(c) => G(c, u)
|
|
1399
|
+
);
|
|
1400
|
+
let h = 0;
|
|
1401
|
+
const m = (c) => {
|
|
1402
|
+
c.type === "BinaryExpression" && (c.left.type === "NumberLiteral" && c.left.hasMillimeterSuffix === !1 && (h += c.left.value), c.right.type === "NumberLiteral" && c.right.hasMillimeterSuffix === !1 && (h += c.right.value)), c.type === "NumberLiteral" && c.hasMillimeterSuffix === !1 && (h += c.value);
|
|
1403
|
+
};
|
|
1404
|
+
n.sections.forEach((c) => {
|
|
1405
|
+
G(c, m);
|
|
1406
|
+
});
|
|
1407
|
+
const p = o / h, E = [], y = (c) => {
|
|
1408
|
+
let d = 0, g = 0;
|
|
1409
|
+
if (c.type === "NumberLiteral")
|
|
1410
|
+
c.hasMillimeterSuffix === !1 && (d += c.value * p), c.hasMillimeterSuffix === !0 && (g += c.value), E.push(Number((d + g).toFixed(2)));
|
|
1411
|
+
else if (c.type === "BinaryExpression" && (c.left.type === "NumberLiteral" && c.right.type === "NumberLiteral" && (c.left.hasMillimeterSuffix === !1 && (d += c.left.value * p), c.left.hasMillimeterSuffix === !0 && (g += c.left.value), c.right.hasMillimeterSuffix === !1 && (d += c.right.value * p), c.right.hasMillimeterSuffix === !0 && (g += c.right.value), E.push(Number((d + g).toFixed(2)))), c.left.type === "SpecialVariable" && c.left.name === "n" && c.right.type === "NumberLiteral")) {
|
|
1412
|
+
g += c.right.value;
|
|
1413
|
+
for (let I = 0; I < l; I++)
|
|
1414
|
+
c.right.hasMillimeterSuffix === !0 && E.push(Number(g.toFixed(2)));
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
return n.sections.forEach((c) => {
|
|
1418
|
+
G(c, y);
|
|
1419
|
+
}), E;
|
|
1420
|
+
} catch {
|
|
1421
|
+
return new A("Error calculating sections");
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
}, gt = new lt(), Et = new ct(), St = new mt(), vt = (e, t, r, i) => {
|
|
1425
|
+
try {
|
|
1426
|
+
const n = gt.scan(e), s = Et.parse(n), a = St.evaluate(s, {}, i);
|
|
1427
|
+
if (a && !(a instanceof A)) {
|
|
1428
|
+
const l = new dt().calculateSections(a, t, r);
|
|
1429
|
+
if (l && l instanceof A) throw new Error(l.message);
|
|
1430
|
+
return l;
|
|
1431
|
+
}
|
|
1432
|
+
return a || new A("Unknown error during evaluation.");
|
|
1433
|
+
} catch (n) {
|
|
1434
|
+
return new A(n.message);
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
function Nt(e) {
|
|
1438
|
+
const t = /^(\d+)\*\{(\d+)\}$/, r = e.match(t);
|
|
1439
|
+
if (r) {
|
|
1440
|
+
const i = parseInt(r[1], 10), n = r[2];
|
|
1441
|
+
return i > 0 ? Array(i).fill(n).join(":") : "";
|
|
1442
|
+
}
|
|
1443
|
+
return e;
|
|
1444
|
+
}
|
|
1445
|
+
function Tt(e) {
|
|
1446
|
+
const t = e.trim().match(/^(\d+(?:\.\d+)?)\s*\*\s*\{.+\}$/);
|
|
1447
|
+
return t ? Number(t[1]) : e;
|
|
1448
|
+
}
|
|
1449
|
+
function Mt(e, t, r) {
|
|
1450
|
+
let i = 0;
|
|
1451
|
+
const { LINDIV1: n, DIVDIR: s, HORDEFTYPE: a, DIVELEM1: o } = e;
|
|
1452
|
+
let l = "width";
|
|
1453
|
+
if (n === "") return { divisionType: l, zone_dimensions: [], divided_length_list: [] };
|
|
1454
|
+
if (s === "H")
|
|
1455
|
+
if (a === "W")
|
|
1456
|
+
i = t.width, l = "width";
|
|
1457
|
+
else if (a === "D")
|
|
1458
|
+
i = t.depth, l = "depth";
|
|
1459
|
+
else if (a === "P")
|
|
1460
|
+
if (o === 0 || o === 2)
|
|
1461
|
+
i = t.width, l = "width";
|
|
1462
|
+
else if (o === 1 || o === 3)
|
|
1463
|
+
i = t.depth, l = "depth";
|
|
1464
|
+
else
|
|
1465
|
+
throw new Error("Unhandled case: DIVELEM1 = " + o);
|
|
1466
|
+
else
|
|
1467
|
+
throw new Error("Unhandled case: HORDEFTYPE = " + a);
|
|
1468
|
+
else if (s === "V")
|
|
1469
|
+
i = t.height, l = "height";
|
|
1470
|
+
else if (s === "A")
|
|
1471
|
+
i = t.width, l = "article";
|
|
1472
|
+
else if (s === "I")
|
|
1473
|
+
i = t.width, l = "independent";
|
|
1474
|
+
else
|
|
1475
|
+
throw new Error("Unhandled case: DIVDIR = " + s);
|
|
1476
|
+
let u = [];
|
|
1477
|
+
const h = Nt(n);
|
|
1478
|
+
if (l === "independent") {
|
|
1479
|
+
const p = Tt(n);
|
|
1480
|
+
u = Array(p).fill(i);
|
|
1481
|
+
} else l === "article" ? u = [i] : u = vt(h, i, r);
|
|
1482
|
+
return Array.isArray(u) ? (a === "P" && (o === 2 || o === 3) && (u = [...u].reverse()), {
|
|
1483
|
+
zone_dimensions: u.map((p) => {
|
|
1484
|
+
if (l === "width")
|
|
1485
|
+
return {
|
|
1486
|
+
width: p,
|
|
1487
|
+
height: t.height,
|
|
1488
|
+
depth: t.depth
|
|
1489
|
+
};
|
|
1490
|
+
if (l === "depth")
|
|
1491
|
+
return {
|
|
1492
|
+
width: t.width,
|
|
1493
|
+
height: t.height,
|
|
1494
|
+
depth: p
|
|
1495
|
+
};
|
|
1496
|
+
if (l === "height")
|
|
1497
|
+
return {
|
|
1498
|
+
width: t.width,
|
|
1499
|
+
height: p,
|
|
1500
|
+
depth: t.depth
|
|
1501
|
+
};
|
|
1502
|
+
if (l === "article" || l === "independent")
|
|
1503
|
+
return {
|
|
1504
|
+
width: t.width,
|
|
1505
|
+
height: t.height,
|
|
1506
|
+
depth: t.depth
|
|
1507
|
+
};
|
|
1508
|
+
throw new Error("Unhandled case: DIVDIR = " + s);
|
|
1509
|
+
}),
|
|
1510
|
+
divisionType: l,
|
|
1511
|
+
divided_length_list: u
|
|
1512
|
+
}) : { divisionType: l, zone_dimensions: [], divided_length_list: [] };
|
|
1513
|
+
}
|
|
1514
|
+
function xt({
|
|
1515
|
+
divisionType: e,
|
|
1516
|
+
parentDimensions: t,
|
|
1517
|
+
lengthList: r,
|
|
1518
|
+
childTREEIDs: i,
|
|
1519
|
+
dividerThk: n
|
|
1520
|
+
}) {
|
|
1521
|
+
const s = -t.width / 2, a = -t.depth / 2, o = -t.height / 2;
|
|
1522
|
+
return {
|
|
1523
|
+
childPositions: r.reduce((u, h, m) => {
|
|
1524
|
+
let p = 0, E = 0, y = 0, c;
|
|
1525
|
+
return e === "width" ? (p = s + u.cumulativeX + h / 2, E = 0, y = 0, c = {
|
|
1526
|
+
width: h,
|
|
1527
|
+
height: t.height,
|
|
1528
|
+
depth: t.depth
|
|
1529
|
+
}, u.cumulativeX += h + n) : e === "depth" ? (p = 0, E = a + u.cumulativeY + h / 2, y = 0, c = {
|
|
1530
|
+
width: t.width,
|
|
1531
|
+
height: t.height,
|
|
1532
|
+
depth: h
|
|
1533
|
+
}, u.cumulativeY += h + n) : e === "independent" || e === "article" ? (p = 0, E = 0, y = 0, c = {
|
|
1534
|
+
width: h,
|
|
1535
|
+
height: t.height,
|
|
1536
|
+
depth: t.depth
|
|
1537
|
+
}) : (p = 0, E = 0, y = o + u.cumulativeZ + h / 2, c = {
|
|
1538
|
+
width: t.width,
|
|
1539
|
+
height: h,
|
|
1540
|
+
depth: t.depth
|
|
1541
|
+
}, u.cumulativeZ += h + n), u.positions.push({
|
|
1542
|
+
x: p,
|
|
1543
|
+
y: E,
|
|
1544
|
+
z: y,
|
|
1545
|
+
zone_dims: c,
|
|
1546
|
+
TREEID: i[m]
|
|
1547
|
+
}), u;
|
|
1548
|
+
}, { cumulativeX: 0, cumulativeY: 0, cumulativeZ: 0, positions: [] }).positions,
|
|
1549
|
+
dividerType: e
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
function yt(e) {
|
|
1553
|
+
return {
|
|
1554
|
+
front: te(Oe(e)),
|
|
1555
|
+
left: te(Re(e)),
|
|
1556
|
+
right: te(Pe(e)),
|
|
1557
|
+
back: te(Ve(e))
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
function It(e, t, r) {
|
|
1561
|
+
return {
|
|
1562
|
+
front: e.front?.thk || 0,
|
|
1563
|
+
right: e.right?.thk || 0,
|
|
1564
|
+
back: e.back?.thk || 0,
|
|
1565
|
+
left: e.left?.thk || 0,
|
|
1566
|
+
top: t,
|
|
1567
|
+
bottom: r
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
function _t(e) {
|
|
1571
|
+
return {
|
|
1572
|
+
front: e.front?.inset || 0,
|
|
1573
|
+
right: e.right?.inset || 0,
|
|
1574
|
+
back: e.back?.inset || 0,
|
|
1575
|
+
left: e.left?.inset || 0
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
function bt(e, t) {
|
|
1579
|
+
return {
|
|
1580
|
+
dimensions: {
|
|
1581
|
+
width: e.width - t.left - t.right,
|
|
1582
|
+
height: e.height,
|
|
1583
|
+
depth: e.depth - t.front - t.back
|
|
1584
|
+
},
|
|
1585
|
+
position: {
|
|
1586
|
+
x: t.left / 2 - t.right / 2,
|
|
1587
|
+
y: t.front / 2 - t.back / 2,
|
|
1588
|
+
z: 0
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
function kt(e, t) {
|
|
1593
|
+
return {
|
|
1594
|
+
dimensions: {
|
|
1595
|
+
width: e.dimensions.width - t.left - t.right,
|
|
1596
|
+
height: e.dimensions.height - t.top - t.bottom,
|
|
1597
|
+
depth: e.dimensions.depth - t.front - t.back
|
|
1598
|
+
},
|
|
1599
|
+
position: {
|
|
1600
|
+
x: t.left / 2 - t.right / 2,
|
|
1601
|
+
y: t.front / 2 - t.back / 2,
|
|
1602
|
+
z: t.bottom / 2 - t.top / 2
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
function At(e, t, r, i) {
|
|
1607
|
+
return t.divisionType ? xt({
|
|
1608
|
+
divisionType: t.divisionType,
|
|
1609
|
+
parentDimensions: e,
|
|
1610
|
+
lengthList: t.divided_length_list,
|
|
1611
|
+
childTREEIDs: i,
|
|
1612
|
+
dividerThk: Number(r) || 0
|
|
1613
|
+
}) : { childPositions: [], dividerType: "height" };
|
|
1614
|
+
}
|
|
1615
|
+
function Dt(e, t, r, i) {
|
|
1616
|
+
if (!r)
|
|
1617
|
+
return { childPositions: [], dividerType: "height" };
|
|
1618
|
+
const n = Mt(r, e.dimensions, t);
|
|
1619
|
+
return At(
|
|
1620
|
+
e.dimensions,
|
|
1621
|
+
n,
|
|
1622
|
+
t,
|
|
1623
|
+
i
|
|
1624
|
+
);
|
|
1625
|
+
}
|
|
1626
|
+
function U({
|
|
1627
|
+
length: e,
|
|
1628
|
+
width: t,
|
|
1629
|
+
thk: r,
|
|
1630
|
+
material: i = "gray",
|
|
1631
|
+
opacity: n = 0.2,
|
|
1632
|
+
isSelected: s = !1,
|
|
1633
|
+
isHovered: a = !1,
|
|
1634
|
+
onClick: o,
|
|
1635
|
+
onPointerEnter: l,
|
|
1636
|
+
onPointerLeave: u
|
|
1637
|
+
}) {
|
|
1638
|
+
const h = s ? "#ff6b00" : a ? "#0066ff" : i, m = s ? 0.8 : a ? 0.6 : n;
|
|
1639
|
+
return /* @__PURE__ */ f("group", { children: /* @__PURE__ */ O(
|
|
1640
|
+
"mesh",
|
|
1641
|
+
{
|
|
1642
|
+
onClick: o,
|
|
1643
|
+
onPointerEnter: l,
|
|
1644
|
+
onPointerLeave: u,
|
|
1645
|
+
children: [
|
|
1646
|
+
/* @__PURE__ */ f("boxGeometry", { args: [e / v, t / v, r / v] }),
|
|
1647
|
+
/* @__PURE__ */ f(
|
|
1648
|
+
"meshStandardMaterial",
|
|
1649
|
+
{
|
|
1650
|
+
color: h,
|
|
1651
|
+
opacity: m,
|
|
1652
|
+
transparent: !0
|
|
1653
|
+
}
|
|
1654
|
+
),
|
|
1655
|
+
/* @__PURE__ */ f(Ke, { color: s ? "#ff6b00" : a ? "#0066ff" : "black" })
|
|
1656
|
+
]
|
|
1657
|
+
}
|
|
1658
|
+
) });
|
|
1659
|
+
}
|
|
1660
|
+
function wt(e, t, r = 0, i = 0) {
|
|
1661
|
+
const n = e / 2, s = t / 2, a = n, o = s;
|
|
1662
|
+
return `
|
|
1663
|
+
${a},${-o}
|
|
1664
|
+
${-a},${-o}
|
|
1665
|
+
${-a + r},${o}
|
|
1666
|
+
${a - i},${o}
|
|
1667
|
+
`.trim().replace(/\s+/g, " ");
|
|
1668
|
+
}
|
|
1669
|
+
function Z({
|
|
1670
|
+
dim_x: e,
|
|
1671
|
+
dim_y: t,
|
|
1672
|
+
fill: r = "lightgray",
|
|
1673
|
+
text: i = "",
|
|
1674
|
+
stroke_width: n = 2,
|
|
1675
|
+
rotate: s = 0,
|
|
1676
|
+
isSelected: a = !1,
|
|
1677
|
+
isHovered: o = !1,
|
|
1678
|
+
onClick: l,
|
|
1679
|
+
onMouseEnter: u,
|
|
1680
|
+
onMouseLeave: h,
|
|
1681
|
+
startPanelThk: m = 0,
|
|
1682
|
+
endPanelThk: p = 0
|
|
1683
|
+
}) {
|
|
1684
|
+
const E = wt(
|
|
1685
|
+
e,
|
|
1686
|
+
t,
|
|
1687
|
+
m,
|
|
1688
|
+
p
|
|
1689
|
+
), y = a ? "#ff6b00" : o ? "#0066ff" : "black", c = a ? n * 2 : o ? n * 1.5 : n, d = a ? 0.8 : o ? 0.7 : 0.5;
|
|
1690
|
+
return /* @__PURE__ */ O("g", { transform: `rotate(${s})`, children: [
|
|
1691
|
+
/* @__PURE__ */ f(
|
|
1692
|
+
"polygon",
|
|
1693
|
+
{
|
|
1694
|
+
points: E,
|
|
1695
|
+
stroke: y,
|
|
1696
|
+
strokeWidth: c,
|
|
1697
|
+
fill: r,
|
|
1698
|
+
strokeLinejoin: "bevel",
|
|
1699
|
+
strokeMiterlimit: "1",
|
|
1700
|
+
opacity: d,
|
|
1701
|
+
onClick: l,
|
|
1702
|
+
onMouseEnter: u,
|
|
1703
|
+
onMouseLeave: h,
|
|
1704
|
+
style: { cursor: l ? "pointer" : "default" }
|
|
1705
|
+
}
|
|
1706
|
+
),
|
|
1707
|
+
/* @__PURE__ */ f(
|
|
1708
|
+
"text",
|
|
1709
|
+
{
|
|
1710
|
+
transform: "scale(1,-1)",
|
|
1711
|
+
x: 0,
|
|
1712
|
+
y: 0,
|
|
1713
|
+
textAnchor: "middle",
|
|
1714
|
+
dominantBaseline: "middle",
|
|
1715
|
+
fontSize: 14,
|
|
1716
|
+
children: i
|
|
1717
|
+
}
|
|
1718
|
+
)
|
|
1719
|
+
] });
|
|
1720
|
+
}
|
|
1721
|
+
function Ct({ TREEID: e, dimension: t, view: r, helper: i }) {
|
|
1722
|
+
const n = i.front, s = V(F);
|
|
1723
|
+
if (!n || !s) return;
|
|
1724
|
+
const { selectedElem: a, setSelectedElem: o, hoveredElem: l, setHoveredElem: u } = s, { CPNAME: h } = n;
|
|
1725
|
+
if (!h) return null;
|
|
1726
|
+
const { elmTrimThk: m } = n, p = i.left?.thk, E = i.right?.thk, y = (n.trim.start === "S" ? p : 0) ?? 0, c = (n.trim.end === "S" ? E : 0) ?? 0, d = (n.trim.start === "M" ? p : 0) ?? 0, g = (n.trim.end === "M" ? E : 0) ?? 0, I = t.height - m.top - m.bottom + n.oversize.top + n.oversize.bottom, N = t.width - y - c + n.oversize.start + n.oversize.end, M = n.thk, D = -(n.oversize.start / 2 - n.oversize.end / 2 - y / 2 + c / 2), S = n.oversize.bottom / 2 - n.oversize.top / 2 + m.bottom / 2 - m.top / 2, T = -(t.depth / 2 - M / 2), _ = a === e, k = l === e, w = () => {
|
|
1727
|
+
console.log("handleClick", e), o(_ ? null : e);
|
|
1728
|
+
}, b = () => {
|
|
1729
|
+
u(e);
|
|
1730
|
+
}, L = () => {
|
|
1731
|
+
u(null);
|
|
1732
|
+
};
|
|
1733
|
+
return r === x._3D ? /* @__PURE__ */ f("group", { position: [D / v, T / v, S / v], rotation: [Math.PI / 2, 0, Math.PI / 2], children: /* @__PURE__ */ f(
|
|
1734
|
+
U,
|
|
1735
|
+
{
|
|
1736
|
+
length: I,
|
|
1737
|
+
width: N,
|
|
1738
|
+
thk: M,
|
|
1739
|
+
treeId: e,
|
|
1740
|
+
isSelected: _,
|
|
1741
|
+
isHovered: k,
|
|
1742
|
+
onClick: w,
|
|
1743
|
+
onPointerEnter: b,
|
|
1744
|
+
onPointerLeave: L
|
|
1745
|
+
}
|
|
1746
|
+
) }) : /* @__PURE__ */ f("g", { transform: `translate(${D},${r === x._2D_TOP ? T : S}) rotate(0)`, children: /* @__PURE__ */ f(
|
|
1747
|
+
Z,
|
|
1748
|
+
{
|
|
1749
|
+
dim_x: N,
|
|
1750
|
+
dim_y: r === x._2D_TOP ? M : I,
|
|
1751
|
+
text: "front " + I + " x " + N + " x " + M,
|
|
1752
|
+
treeId: e,
|
|
1753
|
+
isSelected: _,
|
|
1754
|
+
isHovered: k,
|
|
1755
|
+
onClick: w,
|
|
1756
|
+
onMouseEnter: b,
|
|
1757
|
+
onMouseLeave: L,
|
|
1758
|
+
startPanelThk: r === x._2D_TOP ? d : 0,
|
|
1759
|
+
endPanelThk: r === x._2D_TOP ? g : 0
|
|
1760
|
+
}
|
|
1761
|
+
) });
|
|
1762
|
+
}
|
|
1763
|
+
const J = ({ view: e = x._3D, position: t = [0, 0, 0], rotation: r = [0, 0, 0], children: i }) => {
|
|
1764
|
+
if (e === x._3D)
|
|
1765
|
+
return /* @__PURE__ */ f(
|
|
1766
|
+
"group",
|
|
1767
|
+
{
|
|
1768
|
+
position: [t[0] / v, t[1] / v, t[2] / v],
|
|
1769
|
+
rotation: r,
|
|
1770
|
+
children: i
|
|
1771
|
+
}
|
|
1772
|
+
);
|
|
1773
|
+
const n = t[0], s = e === x._2D_TOP ? t[1] : t[2], a = r[2] * (180 / Math.PI);
|
|
1774
|
+
return /* @__PURE__ */ f("g", { transform: `translate(${n},${s}) rotate(${a})`, children: i });
|
|
1775
|
+
};
|
|
1776
|
+
function Lt({ TREEID: e, dimension: t, view: r, helper: i }) {
|
|
1777
|
+
const n = i.left, s = V(F);
|
|
1778
|
+
if (!n || !s) return;
|
|
1779
|
+
const { selectedElem: a, setSelectedElem: o, hoveredElem: l, setHoveredElem: u } = s, { CPNAME: h } = n;
|
|
1780
|
+
if (!h) return null;
|
|
1781
|
+
const { elmTrimThk: m } = n, p = i.back?.thk, E = i.front?.thk, y = (n.trim.start === "S" ? p : 0) ?? 0, c = (n.trim.end === "S" ? E : 0) ?? 0, d = (n.trim.start === "M" ? p : 0) ?? 0, g = (n.trim.end === "M" ? E : 0) ?? 0, I = t.height - m.top - m.bottom + n.oversize.top + n.oversize.bottom, N = t.depth - y - c + n.oversize.start + n.oversize.end, M = n.thk, D = -(t.width / 2 - M / 2), S = n.oversize.start / 2 - n.oversize.end / 2 - y / 2 + c / 2, T = n.oversize.bottom / 2 - n.oversize.top / 2 + m.bottom / 2 - m.top / 2, _ = a === e, k = l === e, w = () => {
|
|
1782
|
+
o(_ ? null : e);
|
|
1783
|
+
}, b = () => {
|
|
1784
|
+
u(e);
|
|
1785
|
+
}, L = () => {
|
|
1786
|
+
u(null);
|
|
1787
|
+
};
|
|
1788
|
+
return r === x._3D ? /* @__PURE__ */ f("group", { position: [D / v, S / v, T / v], rotation: [0, Math.PI / 2, 0], children: /* @__PURE__ */ f(
|
|
1789
|
+
U,
|
|
1790
|
+
{
|
|
1791
|
+
length: I,
|
|
1792
|
+
width: N,
|
|
1793
|
+
thk: M,
|
|
1794
|
+
treeId: e,
|
|
1795
|
+
isSelected: _,
|
|
1796
|
+
isHovered: k,
|
|
1797
|
+
onClick: w,
|
|
1798
|
+
onPointerEnter: b,
|
|
1799
|
+
onPointerLeave: L
|
|
1800
|
+
}
|
|
1801
|
+
) }) : /* @__PURE__ */ f("g", { transform: `translate(${D},${r === x._2D_TOP ? S : T}) rotate(90)`, children: /* @__PURE__ */ f(
|
|
1802
|
+
Z,
|
|
1803
|
+
{
|
|
1804
|
+
dim_x: r === x._2D_TOP ? N : I,
|
|
1805
|
+
dim_y: M,
|
|
1806
|
+
text: "left " + I + " x " + N + " x " + M,
|
|
1807
|
+
treeId: e,
|
|
1808
|
+
rotate: 180,
|
|
1809
|
+
isSelected: _,
|
|
1810
|
+
isHovered: k,
|
|
1811
|
+
onClick: w,
|
|
1812
|
+
onMouseEnter: b,
|
|
1813
|
+
onMouseLeave: L,
|
|
1814
|
+
startPanelThk: r === x._2D_TOP ? d : 0,
|
|
1815
|
+
endPanelThk: r === x._2D_TOP ? g : 0
|
|
1816
|
+
}
|
|
1817
|
+
) });
|
|
1818
|
+
}
|
|
1819
|
+
function Ot({ TREEID: e, dimension: t, view: r, helper: i }) {
|
|
1820
|
+
const n = i.back, s = V(F);
|
|
1821
|
+
if (!n || !s) return;
|
|
1822
|
+
const { selectedElem: a, setSelectedElem: o, hoveredElem: l, setHoveredElem: u } = s, { CPNAME: h } = n;
|
|
1823
|
+
if (!h) return null;
|
|
1824
|
+
const { elmTrimThk: m } = n, p = i.right?.thk, E = i.left?.thk, y = (n.trim.start === "S" ? p : 0) ?? 0, c = (n.trim.end === "S" ? E : 0) ?? 0, d = (n.trim.start === "M" ? p : 0) ?? 0, g = (n.trim.end === "M" ? E : 0) ?? 0, I = t.height - m.top - m.bottom + n.oversize.top + n.oversize.bottom, N = t.width - y - c + n.oversize.start + n.oversize.end, M = n.thk, D = n.oversize.start / 2 - n.oversize.end / 2 - y / 2 + c / 2, S = t.depth / 2 - M / 2, T = n.oversize.bottom / 2 - n.oversize.top / 2 + m.bottom / 2 - m.top / 2, _ = a === e, k = l === e, w = () => {
|
|
1825
|
+
o(_ ? null : e);
|
|
1826
|
+
}, b = () => {
|
|
1827
|
+
u(e);
|
|
1828
|
+
}, L = () => {
|
|
1829
|
+
u(null);
|
|
1830
|
+
};
|
|
1831
|
+
return r === x._3D ? /* @__PURE__ */ O("group", { position: [D / v, S / v, T / v], rotation: [Math.PI / 2, 0, Math.PI / 2], children: [
|
|
1832
|
+
/* @__PURE__ */ f(
|
|
1833
|
+
U,
|
|
1834
|
+
{
|
|
1835
|
+
length: I,
|
|
1836
|
+
width: N,
|
|
1837
|
+
thk: M,
|
|
1838
|
+
treeId: e,
|
|
1839
|
+
isSelected: _,
|
|
1840
|
+
isHovered: k,
|
|
1841
|
+
onClick: w,
|
|
1842
|
+
onPointerEnter: b,
|
|
1843
|
+
onPointerLeave: L
|
|
1844
|
+
}
|
|
1845
|
+
),
|
|
1846
|
+
/* @__PURE__ */ f(Ye, { position: [0, 0, 0], color: "blue", fontSize: 20, children: e })
|
|
1847
|
+
] }) : /* @__PURE__ */ f("g", { transform: `translate(${D},${r === x._2D_TOP ? S : T}) rotate(0)`, children: /* @__PURE__ */ f(
|
|
1848
|
+
Z,
|
|
1849
|
+
{
|
|
1850
|
+
dim_x: N,
|
|
1851
|
+
dim_y: r === x._2D_TOP ? M : I,
|
|
1852
|
+
text: "Back " + I + " x " + N + " x " + M,
|
|
1853
|
+
treeId: e,
|
|
1854
|
+
isSelected: _,
|
|
1855
|
+
rotate: 180,
|
|
1856
|
+
isHovered: k,
|
|
1857
|
+
onClick: w,
|
|
1858
|
+
onMouseEnter: b,
|
|
1859
|
+
onMouseLeave: L,
|
|
1860
|
+
startPanelThk: r === x._2D_TOP ? d : 0,
|
|
1861
|
+
endPanelThk: r === x._2D_TOP ? g : 0
|
|
1862
|
+
}
|
|
1863
|
+
) });
|
|
1864
|
+
}
|
|
1865
|
+
function Pt({ TREEID: e, dimension: t, view: r, helper: i }) {
|
|
1866
|
+
const n = i.right, s = V(F);
|
|
1867
|
+
if (!n || !s) return;
|
|
1868
|
+
const { selectedElem: a, setSelectedElem: o, hoveredElem: l, setHoveredElem: u } = s, { CPNAME: h } = n;
|
|
1869
|
+
if (!h) return null;
|
|
1870
|
+
const { elmTrimThk: m } = n, p = i.front?.thk, E = i.back?.thk, y = (n.trim.start === "S" ? p : 0) ?? 0, c = (n.trim.end === "S" ? E : 0) ?? 0, d = (n.trim.start === "M" ? p : 0) ?? 0, g = (n.trim.end === "M" ? E : 0) ?? 0, I = t.height - m.top - m.bottom + n.oversize.top + n.oversize.bottom, N = t.depth - y - c + n.oversize.start + n.oversize.end, M = n.thk, D = t.width / 2 - M / 2, S = -(n.oversize.start / 2 - n.oversize.end / 2 - y / 2 + c / 2), T = n.oversize.bottom / 2 + n.oversize.top / 2 + m.bottom / 2 - m.top / 2, _ = a === e, k = l === e, w = () => {
|
|
1871
|
+
o(_ ? null : e);
|
|
1872
|
+
}, b = () => {
|
|
1873
|
+
u(e);
|
|
1874
|
+
}, L = () => {
|
|
1875
|
+
u(null);
|
|
1876
|
+
};
|
|
1877
|
+
return r === x._3D ? /* @__PURE__ */ f("group", { position: [D / v, S / v, T / v], rotation: [0, Math.PI / 2, 0], children: /* @__PURE__ */ f(
|
|
1878
|
+
U,
|
|
1879
|
+
{
|
|
1880
|
+
length: I,
|
|
1881
|
+
width: N,
|
|
1882
|
+
thk: M,
|
|
1883
|
+
treeId: e,
|
|
1884
|
+
isSelected: _,
|
|
1885
|
+
isHovered: k,
|
|
1886
|
+
onClick: w,
|
|
1887
|
+
onPointerEnter: b,
|
|
1888
|
+
onPointerLeave: L
|
|
1889
|
+
}
|
|
1890
|
+
) }) : /* @__PURE__ */ f("g", { transform: `translate(${D},${r === x._2D_TOP ? S : T}) rotate(90)`, children: /* @__PURE__ */ f(
|
|
1891
|
+
Z,
|
|
1892
|
+
{
|
|
1893
|
+
dim_x: r === x._2D_TOP ? N : I,
|
|
1894
|
+
dim_y: M,
|
|
1895
|
+
text: "right " + I + " x " + N + " x " + M,
|
|
1896
|
+
treeId: e,
|
|
1897
|
+
isSelected: _,
|
|
1898
|
+
isHovered: k,
|
|
1899
|
+
onClick: w,
|
|
1900
|
+
onMouseEnter: b,
|
|
1901
|
+
onMouseLeave: L,
|
|
1902
|
+
startPanelThk: r === x._2D_TOP ? d : 0,
|
|
1903
|
+
endPanelThk: r === x._2D_TOP ? g : 0
|
|
1904
|
+
}
|
|
1905
|
+
) });
|
|
1906
|
+
}
|
|
1907
|
+
function Vt({ TREEID: e, dimension: t, view: r, helper: i }) {
|
|
1908
|
+
const n = ue(e), s = V(F);
|
|
1909
|
+
if (!n || !s) return;
|
|
1910
|
+
const { selectedElem: a, setSelectedElem: o, hoveredElem: l, setHoveredElem: u } = s, { topShelfCP: h } = n;
|
|
1911
|
+
if (!h) return;
|
|
1912
|
+
const m = (i.front?.trim.top !== "S" ? i.front?.thk : 0) ?? 0, p = (i.back?.trim.top !== "S" ? i.back?.thk : 0) ?? 0, E = (i.left?.trim.top !== "S" ? i.left?.thk : 0) ?? 0, y = (i.right?.trim.top !== "S" ? i.right?.thk : 0) ?? 0, c = t.width - E - y, d = t.depth - p - m, g = n.topShelfThk, I = E / 2 - y / 2, N = -(p / 2 - m / 2), M = t.height / 2 - g / 2, D = a === e, S = l === e, T = () => {
|
|
1913
|
+
o(D ? null : e);
|
|
1914
|
+
}, _ = () => {
|
|
1915
|
+
u(e);
|
|
1916
|
+
}, k = () => {
|
|
1917
|
+
u(null);
|
|
1918
|
+
};
|
|
1919
|
+
return r === x._3D ? /* @__PURE__ */ f("group", { position: [I / v, N / v, M / v], rotation: [0, 0, 0], children: /* @__PURE__ */ f(
|
|
1920
|
+
U,
|
|
1921
|
+
{
|
|
1922
|
+
length: c,
|
|
1923
|
+
width: d,
|
|
1924
|
+
thk: g,
|
|
1925
|
+
opacity: 0.8,
|
|
1926
|
+
treeId: e,
|
|
1927
|
+
isSelected: D,
|
|
1928
|
+
isHovered: S,
|
|
1929
|
+
onClick: T,
|
|
1930
|
+
onPointerEnter: _,
|
|
1931
|
+
onPointerLeave: k
|
|
1932
|
+
}
|
|
1933
|
+
) }) : /* @__PURE__ */ f("g", { transform: `translate(${I},${r === x._2D_TOP ? N : M})`, children: /* @__PURE__ */ f(
|
|
1934
|
+
Z,
|
|
1935
|
+
{
|
|
1936
|
+
dim_x: c,
|
|
1937
|
+
dim_y: r === x._2D_TOP ? d : g,
|
|
1938
|
+
text: "Top " + e + " -- " + c + " x " + d + " x " + g,
|
|
1939
|
+
treeId: e,
|
|
1940
|
+
isSelected: D,
|
|
1941
|
+
isHovered: S,
|
|
1942
|
+
onClick: T,
|
|
1943
|
+
onMouseEnter: _,
|
|
1944
|
+
onMouseLeave: k
|
|
1945
|
+
}
|
|
1946
|
+
) });
|
|
1947
|
+
}
|
|
1948
|
+
function Rt({ TREEID: e, dimension: t, view: r, helper: i }) {
|
|
1949
|
+
const n = ue(e), s = V(F);
|
|
1950
|
+
if (!n || !s) return;
|
|
1951
|
+
const { selectedElem: a, setSelectedElem: o, hoveredElem: l, setHoveredElem: u } = s, { bottomShelfCP: h } = n;
|
|
1952
|
+
if (!h) return;
|
|
1953
|
+
const m = (i.front?.trim.bottom !== "S" ? i.front?.thk : 0) ?? 0, p = (i.back?.trim.bottom !== "S" ? i.back?.thk : 0) ?? 0, E = (i.left?.trim.bottom !== "S" ? i.left?.thk : 0) ?? 0, y = (i.right?.trim.bottom !== "S" ? i.right?.thk : 0) ?? 0, c = t.width - E - y, d = t.depth - p - m, g = n.bottomShelfThk, I = E / 2 - y / 2, N = -(p / 2 - m / 2), M = -(t.height / 2 - g / 2), D = a === e, S = l === e, T = () => {
|
|
1954
|
+
o(D ? null : e);
|
|
1955
|
+
}, _ = () => {
|
|
1956
|
+
u(e);
|
|
1957
|
+
}, k = () => {
|
|
1958
|
+
u(null);
|
|
1959
|
+
};
|
|
1960
|
+
return r === x._3D ? /* @__PURE__ */ f("group", { position: [I / v, N / v, M / v], rotation: [0, 0, 0], children: /* @__PURE__ */ f(
|
|
1961
|
+
U,
|
|
1962
|
+
{
|
|
1963
|
+
length: c,
|
|
1964
|
+
width: d,
|
|
1965
|
+
thk: g,
|
|
1966
|
+
opacity: 0.8,
|
|
1967
|
+
treeId: e,
|
|
1968
|
+
isSelected: D,
|
|
1969
|
+
isHovered: S,
|
|
1970
|
+
onClick: T,
|
|
1971
|
+
onPointerEnter: _,
|
|
1972
|
+
onPointerLeave: k
|
|
1973
|
+
}
|
|
1974
|
+
) }) : /* @__PURE__ */ f("g", { transform: `translate(${I},${r === x._2D_TOP ? N : M})`, children: /* @__PURE__ */ f(
|
|
1975
|
+
Z,
|
|
1976
|
+
{
|
|
1977
|
+
dim_x: c,
|
|
1978
|
+
dim_y: r === x._2D_TOP ? d : g,
|
|
1979
|
+
text: "Bot " + c + " x " + d + " x " + g,
|
|
1980
|
+
treeId: e,
|
|
1981
|
+
isSelected: D,
|
|
1982
|
+
isHovered: S,
|
|
1983
|
+
onClick: T,
|
|
1984
|
+
onMouseEnter: _,
|
|
1985
|
+
onMouseLeave: k
|
|
1986
|
+
}
|
|
1987
|
+
) });
|
|
1988
|
+
}
|
|
1989
|
+
function $t() {
|
|
1990
|
+
const e = V(De);
|
|
1991
|
+
if (!e)
|
|
1992
|
+
throw new Error(
|
|
1993
|
+
"useDescriptorManager must be used within a DescriptorProvider"
|
|
1994
|
+
);
|
|
1995
|
+
return e;
|
|
1996
|
+
}
|
|
1997
|
+
function Ft(e, t, r, i = {}) {
|
|
1998
|
+
const { throwOnError: n = !1 } = i;
|
|
1999
|
+
if (!e.hasDescriptor(t))
|
|
2000
|
+
throw new Error(`Descriptor ${t} not found`);
|
|
2001
|
+
return $(() => {
|
|
2002
|
+
try {
|
|
2003
|
+
return {
|
|
2004
|
+
result: e.evaluate(t, r),
|
|
2005
|
+
error: null,
|
|
2006
|
+
success: !0
|
|
2007
|
+
};
|
|
2008
|
+
} catch (s) {
|
|
2009
|
+
const a = s instanceof Error ? s.message : "Unknown error";
|
|
2010
|
+
if (n)
|
|
2011
|
+
throw s;
|
|
2012
|
+
return {
|
|
2013
|
+
result: null,
|
|
2014
|
+
error: a,
|
|
2015
|
+
success: !1
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
}, [e, t, r, n]);
|
|
2019
|
+
}
|
|
2020
|
+
function sr(e, t, r) {
|
|
2021
|
+
return $(() => {
|
|
2022
|
+
try {
|
|
2023
|
+
const i = e.findAllMatches(t, r);
|
|
2024
|
+
return {
|
|
2025
|
+
matches: i,
|
|
2026
|
+
error: null,
|
|
2027
|
+
count: i.length
|
|
2028
|
+
};
|
|
2029
|
+
} catch (i) {
|
|
2030
|
+
const n = i instanceof Error ? i.message : "Unknown error";
|
|
2031
|
+
return {
|
|
2032
|
+
matches: [],
|
|
2033
|
+
error: n,
|
|
2034
|
+
count: 0
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
}, [e, t, r]);
|
|
2038
|
+
}
|
|
2039
|
+
const R = {
|
|
2040
|
+
LINEAR_DIVISION: "linear-division",
|
|
2041
|
+
ARTICLE: "article"
|
|
2042
|
+
}, B = {
|
|
2043
|
+
STRING: "string",
|
|
2044
|
+
// Direct value
|
|
2045
|
+
DESCRIPTOR: "descriptor"
|
|
2046
|
+
// Value from descriptor evaluation
|
|
2047
|
+
}, ye = {
|
|
2048
|
+
// Check if divider is linear division (any source)
|
|
2049
|
+
linearDivision: (e) => e.type === R.LINEAR_DIVISION,
|
|
2050
|
+
// Check if divider is article (any source)
|
|
2051
|
+
article: (e) => e.type === R.ARTICLE
|
|
2052
|
+
}, zt = {
|
|
2053
|
+
// Check if linear division uses direct string formula
|
|
2054
|
+
string: (e) => e.type === R.LINEAR_DIVISION && e.valueSource === B.STRING,
|
|
2055
|
+
// Check if linear division uses descriptor
|
|
2056
|
+
descriptor: (e) => e.type === R.LINEAR_DIVISION && e.valueSource === B.DESCRIPTOR
|
|
2057
|
+
}, oe = {
|
|
2058
|
+
// Check if article uses direct string name
|
|
2059
|
+
string: (e) => e.type === R.ARTICLE && e.valueSource === B.STRING,
|
|
2060
|
+
// Check if article uses descriptor
|
|
2061
|
+
descriptor: (e) => e.type === R.ARTICLE && e.valueSource === B.DESCRIPTOR
|
|
2062
|
+
}, q = {
|
|
2063
|
+
// Create a linear division with string formula
|
|
2064
|
+
linearDivisionString(e, t, r, i, n, s, a, o) {
|
|
2065
|
+
return {
|
|
2066
|
+
TREEID: e,
|
|
2067
|
+
type: R.LINEAR_DIVISION,
|
|
2068
|
+
valueSource: B.STRING,
|
|
2069
|
+
DIVDIR: t,
|
|
2070
|
+
DIVTYPE: r,
|
|
2071
|
+
HORDEFTYPE: i,
|
|
2072
|
+
LINDIV1: n,
|
|
2073
|
+
DIVELEM1: s,
|
|
2074
|
+
DIVIDER: "",
|
|
2075
|
+
formula: a,
|
|
2076
|
+
thickness: o
|
|
2077
|
+
};
|
|
2078
|
+
},
|
|
2079
|
+
// Create a linear division with descriptor reference
|
|
2080
|
+
// Create linear division with descriptor reference
|
|
2081
|
+
linearDivisionDescriptor(e, t, r, i, n, s, a, o) {
|
|
2082
|
+
return {
|
|
2083
|
+
TREEID: e,
|
|
2084
|
+
type: R.LINEAR_DIVISION,
|
|
2085
|
+
valueSource: B.DESCRIPTOR,
|
|
2086
|
+
DIVDIR: t,
|
|
2087
|
+
DIVTYPE: r,
|
|
2088
|
+
HORDEFTYPE: i,
|
|
2089
|
+
LINDIV1: n,
|
|
2090
|
+
DIVELEM1: s,
|
|
2091
|
+
DIVIDER: "",
|
|
2092
|
+
descriptorName: a,
|
|
2093
|
+
thickness: o
|
|
2094
|
+
};
|
|
2095
|
+
},
|
|
2096
|
+
// Create an article divider
|
|
2097
|
+
// Create article with direct name string
|
|
2098
|
+
articleString(e, t, r, i, n, s, a) {
|
|
2099
|
+
return {
|
|
2100
|
+
TREEID: e,
|
|
2101
|
+
type: R.ARTICLE,
|
|
2102
|
+
valueSource: B.STRING,
|
|
2103
|
+
DIVDIR: t,
|
|
2104
|
+
DIVTYPE: r,
|
|
2105
|
+
HORDEFTYPE: i,
|
|
2106
|
+
LINDIV1: n,
|
|
2107
|
+
DIVELEM1: s,
|
|
2108
|
+
DIVIDER: a,
|
|
2109
|
+
articleName: a
|
|
2110
|
+
};
|
|
2111
|
+
},
|
|
2112
|
+
// Create article with descriptor reference
|
|
2113
|
+
articleDescriptor(e, t, r, i, n, s, a) {
|
|
2114
|
+
return {
|
|
2115
|
+
TREEID: e,
|
|
2116
|
+
type: R.ARTICLE,
|
|
2117
|
+
valueSource: B.DESCRIPTOR,
|
|
2118
|
+
DIVDIR: t,
|
|
2119
|
+
DIVTYPE: r,
|
|
2120
|
+
HORDEFTYPE: i,
|
|
2121
|
+
LINDIV1: n,
|
|
2122
|
+
DIVELEM1: s,
|
|
2123
|
+
DIVIDER: a,
|
|
2124
|
+
descriptorName: a
|
|
2125
|
+
};
|
|
2126
|
+
},
|
|
2127
|
+
// Smart factory: Automatically determines type and source
|
|
2128
|
+
fromZoneData(e, t) {
|
|
2129
|
+
const r = (i) => i.trim().startsWith("#");
|
|
2130
|
+
if (e.DIVDIR === "A") {
|
|
2131
|
+
if (r(e.DIVIDER)) {
|
|
2132
|
+
const i = e.DIVIDER.replace("#", "").trim();
|
|
2133
|
+
return q.articleDescriptor(
|
|
2134
|
+
e.TREEID,
|
|
2135
|
+
e.DIVDIR,
|
|
2136
|
+
e.DIVTYPE,
|
|
2137
|
+
e.HORDEFTYPE,
|
|
2138
|
+
e.LINDIV1,
|
|
2139
|
+
e.DIVELEM1,
|
|
2140
|
+
i
|
|
2141
|
+
);
|
|
2142
|
+
}
|
|
2143
|
+
return q.articleString(
|
|
2144
|
+
e.TREEID,
|
|
2145
|
+
e.DIVDIR,
|
|
2146
|
+
e.DIVTYPE,
|
|
2147
|
+
e.HORDEFTYPE,
|
|
2148
|
+
e.LINDIV1,
|
|
2149
|
+
e.DIVELEM1,
|
|
2150
|
+
e.DIVIDER
|
|
2151
|
+
);
|
|
2152
|
+
}
|
|
2153
|
+
if (r(e.LINDIV1)) {
|
|
2154
|
+
const i = e.LINDIV1.replace("#", "").trim();
|
|
2155
|
+
return q.linearDivisionDescriptor(
|
|
2156
|
+
e.TREEID,
|
|
2157
|
+
e.DIVDIR,
|
|
2158
|
+
e.DIVTYPE,
|
|
2159
|
+
e.HORDEFTYPE,
|
|
2160
|
+
e.LINDIV1,
|
|
2161
|
+
e.DIVELEM1,
|
|
2162
|
+
i,
|
|
2163
|
+
t
|
|
2164
|
+
);
|
|
2165
|
+
}
|
|
2166
|
+
return q.linearDivisionString(
|
|
2167
|
+
e.TREEID,
|
|
2168
|
+
e.DIVDIR,
|
|
2169
|
+
e.DIVTYPE,
|
|
2170
|
+
e.HORDEFTYPE,
|
|
2171
|
+
e.LINDIV1,
|
|
2172
|
+
e.DIVELEM1,
|
|
2173
|
+
e.LINDIV1,
|
|
2174
|
+
t
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2177
|
+
};
|
|
2178
|
+
function Gt(e) {
|
|
2179
|
+
if (!e) return "width";
|
|
2180
|
+
const t = {
|
|
2181
|
+
0: "width",
|
|
2182
|
+
1: "depth",
|
|
2183
|
+
2: "width",
|
|
2184
|
+
3: "depth"
|
|
2185
|
+
};
|
|
2186
|
+
return e.DIVDIR === "V" ? "height" : e.HORDEFTYPE === "W" ? "width" : e.HORDEFTYPE === "D" ? "depth" : e.HORDEFTYPE === "P" ? t[e.DIVELEM1] ?? "width" : "width";
|
|
2187
|
+
}
|
|
2188
|
+
function Bt(e, t) {
|
|
2189
|
+
return t ? t[e] : 0;
|
|
2190
|
+
}
|
|
2191
|
+
function Ht(e, t) {
|
|
2192
|
+
const r = e;
|
|
2193
|
+
if (Kt(e))
|
|
2194
|
+
return {
|
|
2195
|
+
value: e.startsWith("#") ? e.slice(1) : e,
|
|
2196
|
+
original: r,
|
|
2197
|
+
isReference: !0
|
|
2198
|
+
};
|
|
2199
|
+
if (/^\d+:\d+$/.test(e))
|
|
2200
|
+
return {
|
|
2201
|
+
value: e,
|
|
2202
|
+
original: r,
|
|
2203
|
+
isReference: !1
|
|
2204
|
+
};
|
|
2205
|
+
const { format: i, expression: n, suffix: s } = Zt(e);
|
|
2206
|
+
let a = n;
|
|
2207
|
+
a = a.replace(/^\((.+)\)$/, "$1");
|
|
2208
|
+
const l = we(a, {
|
|
2209
|
+
variableTree: t,
|
|
2210
|
+
allowFunctions: !0,
|
|
2211
|
+
// Enable round(), floor(), etc.
|
|
2212
|
+
dataType: "FL",
|
|
2213
|
+
silent: !0
|
|
2214
|
+
}).value ?? n;
|
|
2215
|
+
let u;
|
|
2216
|
+
switch (i) {
|
|
2217
|
+
case "expr:ratio":
|
|
2218
|
+
u = `${l}${s}`;
|
|
2219
|
+
break;
|
|
2220
|
+
case "ratio:expr":
|
|
2221
|
+
u = `${s}${l}`;
|
|
2222
|
+
break;
|
|
2223
|
+
case "expr*{ratio}":
|
|
2224
|
+
u = `${l}${s}`;
|
|
2225
|
+
break;
|
|
2226
|
+
case "simple":
|
|
2227
|
+
u = String(l);
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
return {
|
|
2231
|
+
value: u,
|
|
2232
|
+
original: r,
|
|
2233
|
+
isReference: !1
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
function Ut(e, t) {
|
|
2237
|
+
return Ht(e, t).value;
|
|
2238
|
+
}
|
|
2239
|
+
function Zt(e) {
|
|
2240
|
+
const r = e.trim().replace(/^\((.+)\)$/, "$1"), i = r.match(/^(\d+|n):(.+?)(mm|cm)?$/);
|
|
2241
|
+
if (i) {
|
|
2242
|
+
const [, a, o, l] = i;
|
|
2243
|
+
return {
|
|
2244
|
+
format: "ratio:expr",
|
|
2245
|
+
expression: o.trim(),
|
|
2246
|
+
suffix: l ? `${a}:${l}` : `${a}:`
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
const n = r.match(/^(.+?)(mm|cm)?:(\d+)$/);
|
|
2250
|
+
if (n) {
|
|
2251
|
+
const [, a, o, l] = n;
|
|
2252
|
+
return {
|
|
2253
|
+
format: "expr:ratio",
|
|
2254
|
+
expression: a.trim(),
|
|
2255
|
+
suffix: o ? `${o}:${l}` : `:${l}`
|
|
2256
|
+
};
|
|
2257
|
+
}
|
|
2258
|
+
const s = r.match(/^(.+?)(\*)?{(\d+)}$/);
|
|
2259
|
+
if (s) {
|
|
2260
|
+
const [, a, o, l] = s;
|
|
2261
|
+
return {
|
|
2262
|
+
format: "expr*{ratio}",
|
|
2263
|
+
expression: a.trim(),
|
|
2264
|
+
suffix: o ? `*{${l}}` : `{${l}}`
|
|
2265
|
+
};
|
|
2266
|
+
}
|
|
2267
|
+
return {
|
|
2268
|
+
format: "simple",
|
|
2269
|
+
expression: r,
|
|
2270
|
+
suffix: ""
|
|
2271
|
+
};
|
|
2272
|
+
}
|
|
2273
|
+
function Kt(e) {
|
|
2274
|
+
return e.startsWith("#") ? !0 : e.includes("(") || /[+\-*/]/.test(e) ? !1 : /^[A-Za-z0-9_-]+$/.test(e) ? !0 : !/^\d+:\d+$/.test(e);
|
|
2275
|
+
}
|
|
2276
|
+
function Yt({ divider: e, inputData: t }) {
|
|
2277
|
+
const r = $t(), { resolveString: i } = j(), { result: n, error: s } = Ft(r, e.descriptorName, t, { throwOnError: !1 }), a = $(() => e ? oe.string(e) ? e.articleName : oe.descriptor(e) && n?.lindiv ? n.lindiv : "" : "", [e, n]);
|
|
2278
|
+
return {
|
|
2279
|
+
updatedDivider: $(() => {
|
|
2280
|
+
if (e)
|
|
2281
|
+
return n?.lindiv != null ? {
|
|
2282
|
+
...e,
|
|
2283
|
+
LINDIV1: Ut(i(n.lindiv)),
|
|
2284
|
+
// Replace the descriptor reference with actual formula
|
|
2285
|
+
articleName: a
|
|
2286
|
+
} : { ...e, LINDIV1: i(e.LINDIV1) };
|
|
2287
|
+
}, [e, n, a, i])
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
const Wt = {
|
|
2291
|
+
width: {
|
|
2292
|
+
rotation: [0, Math.PI / 2, 0],
|
|
2293
|
+
get3D: (e, t) => ({ length: e.height, width: e.depth, thk: t }),
|
|
2294
|
+
get2DTop: (e, t) => ({ dim_x: e.depth, dim_y: t, rotate: 90 }),
|
|
2295
|
+
get2DFront: (e, t) => ({ dim_x: e.height, dim_y: t, rotate: 90 })
|
|
2296
|
+
},
|
|
2297
|
+
height: {
|
|
2298
|
+
rotation: [0, 0, 0],
|
|
2299
|
+
get3D: (e, t) => ({ length: e.width, width: e.depth, thk: t }),
|
|
2300
|
+
get2DTop: (e) => ({ dim_x: e.width, dim_y: e.depth }),
|
|
2301
|
+
get2DFront: (e, t) => ({ dim_x: e.width, dim_y: t })
|
|
2302
|
+
},
|
|
2303
|
+
depth: {
|
|
2304
|
+
rotation: [Math.PI / 2, 0, Math.PI / 2],
|
|
2305
|
+
get3D: (e, t) => ({ length: e.height, width: e.width, thk: t }),
|
|
2306
|
+
get2DTop: (e, t) => ({ dim_x: e.width, dim_y: t }),
|
|
2307
|
+
get2DFront: (e) => ({ dim_x: e.width, dim_y: e.height })
|
|
2308
|
+
},
|
|
2309
|
+
article: {
|
|
2310
|
+
rotation: [0, 0, 0],
|
|
2311
|
+
get3D: (e, t) => ({ length: e.width, width: e.depth, thk: t }),
|
|
2312
|
+
get2DTop: (e) => ({ dim_x: e.width, dim_y: e.depth }),
|
|
2313
|
+
get2DFront: (e, t) => ({ dim_x: e.width, dim_y: t })
|
|
2314
|
+
},
|
|
2315
|
+
independent: {
|
|
2316
|
+
rotation: [0, 0, 0],
|
|
2317
|
+
get3D: (e, t) => ({ length: e.width, width: e.depth, thk: t }),
|
|
2318
|
+
get2DTop: (e) => ({ dim_x: e.width, dim_y: e.depth }),
|
|
2319
|
+
get2DFront: (e, t) => ({ dim_x: e.width, dim_y: t })
|
|
2320
|
+
}
|
|
2321
|
+
}, Xt = (e, t, r) => ({
|
|
2322
|
+
x: e === "width" ? r.width / 2 + t / 2 : 0,
|
|
2323
|
+
y: e === "depth" ? r.depth / 2 + t / 2 : 0,
|
|
2324
|
+
z: e === "height" ? r.height / 2 + t / 2 : 0
|
|
2325
|
+
});
|
|
2326
|
+
function jt({ divider: e, view: t, childrenPositon: r, dividerThk: i }) {
|
|
2327
|
+
const n = V(F), s = r.dividerType, a = r.childPositions, o = Wt[s];
|
|
2328
|
+
if (!n) return null;
|
|
2329
|
+
const { selectedElem: l, setSelectedElem: u, hoveredElem: h, setHoveredElem: m } = n;
|
|
2330
|
+
return a.map((p, E) => {
|
|
2331
|
+
const c = !(E === a.length - 1) && i !== 0, d = Xt(s, i, p.zone_dims), g = o.get3D(p.zone_dims, i), I = t === x._2D_TOP ? o.get2DTop(p.zone_dims, i) : o.get2DFront(p.zone_dims, i), N = `${e.TREEID} divider`, M = l === N, D = h === N;
|
|
2332
|
+
return /* @__PURE__ */ f(Ze, { children: /* @__PURE__ */ O(J, { view: t, position: [p.x / v, p.y / v, p.z / v], children: [
|
|
2333
|
+
/* @__PURE__ */ f(J, { view: t, position: [d.x / v, d.y / v, d.z / v], rotation: o.rotation, children: c && /* @__PURE__ */ O(pe, { children: [
|
|
2334
|
+
/* @__PURE__ */ f("group", { children: /* @__PURE__ */ O("mesh", { children: [
|
|
2335
|
+
/* @__PURE__ */ f(
|
|
2336
|
+
"boxGeometry",
|
|
2337
|
+
{
|
|
2338
|
+
args: [g.length, g.width, g.thk]
|
|
2339
|
+
}
|
|
2340
|
+
),
|
|
2341
|
+
/* @__PURE__ */ f("meshStandardMaterial", { color: "blue", transparent: !0, opacity: 0.3 })
|
|
2342
|
+
] }) }),
|
|
2343
|
+
t === x._3D ? /* @__PURE__ */ f(
|
|
2344
|
+
U,
|
|
2345
|
+
{
|
|
2346
|
+
...g,
|
|
2347
|
+
opacity: 1,
|
|
2348
|
+
treeId: N,
|
|
2349
|
+
isSelected: M,
|
|
2350
|
+
isHovered: D,
|
|
2351
|
+
onClick: () => u(M ? null : N),
|
|
2352
|
+
onPointerEnter: () => m(N),
|
|
2353
|
+
onPointerLeave: () => m(null)
|
|
2354
|
+
}
|
|
2355
|
+
) : /* @__PURE__ */ f(
|
|
2356
|
+
Z,
|
|
2357
|
+
{
|
|
2358
|
+
...I,
|
|
2359
|
+
text: N,
|
|
2360
|
+
treeId: N,
|
|
2361
|
+
isSelected: M,
|
|
2362
|
+
isHovered: D,
|
|
2363
|
+
onClick: () => u(M ? null : N),
|
|
2364
|
+
onMouseEnter: () => m(N),
|
|
2365
|
+
onMouseLeave: () => m(null)
|
|
2366
|
+
}
|
|
2367
|
+
)
|
|
2368
|
+
] }) }),
|
|
2369
|
+
/* @__PURE__ */ f(ze, { TREEID: p.TREEID, dimension: p.zone_dims, view: t })
|
|
2370
|
+
] }) }, E);
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
function qt({ view: e, remainingZone: t, articleName: r }) {
|
|
2374
|
+
return /* @__PURE__ */ f(
|
|
2375
|
+
be,
|
|
2376
|
+
{
|
|
2377
|
+
articleName: r,
|
|
2378
|
+
dimensionOverrides: {
|
|
2379
|
+
width: t.dimensions.width,
|
|
2380
|
+
height: t.dimensions.height,
|
|
2381
|
+
depth: t.dimensions.depth
|
|
2382
|
+
},
|
|
2383
|
+
children: /* @__PURE__ */ f(
|
|
2384
|
+
J,
|
|
2385
|
+
{
|
|
2386
|
+
view: e,
|
|
2387
|
+
position: [
|
|
2388
|
+
t.position.x / v,
|
|
2389
|
+
t.position.y / v,
|
|
2390
|
+
t.position.z / v
|
|
2391
|
+
],
|
|
2392
|
+
children: /* @__PURE__ */ f(Ge, { view: e })
|
|
2393
|
+
}
|
|
2394
|
+
)
|
|
2395
|
+
}
|
|
2396
|
+
);
|
|
2397
|
+
}
|
|
2398
|
+
function Jt({ childrenPositon: e, dividerThk: t, divider: r, view: i, remainingZone: n }) {
|
|
2399
|
+
if (ye.linearDivision(r))
|
|
2400
|
+
return e ? /* @__PURE__ */ f(jt, { view: i, childrenPositon: e, dividerThk: t, divider: r, remainingZone: n }) : null;
|
|
2401
|
+
if (ye.article(r)) {
|
|
2402
|
+
const s = oe.string(r) ? r.articleName : r.LINDIV1;
|
|
2403
|
+
return !n || s === "" ? null : /* @__PURE__ */ f(qt, { view: i, articleName: s, remainingZone: n });
|
|
2404
|
+
}
|
|
2405
|
+
return null;
|
|
2406
|
+
}
|
|
2407
|
+
function Fe() {
|
|
2408
|
+
const { getArticleData: e } = Q(), { articleName: t, dimensionOverrides: r } = ee(), { resolveString: i } = j(), { anglPrims: n } = e(t);
|
|
2409
|
+
if (n.length === 0) throw new Error(`No prims found for article: ${t}`);
|
|
2410
|
+
const s = n[0], a = (l, u) => {
|
|
2411
|
+
const h = typeof l == "string" && l !== "" ? se(i(l)) : u;
|
|
2412
|
+
return parseFloat(String(h)) || 0;
|
|
2413
|
+
}, o = {
|
|
2414
|
+
width: r?.width ?? a(s.DIMCALCFX, s.SIZEX),
|
|
2415
|
+
height: r?.height ?? a(s.DIMCALCFZ, s.SIZEZ),
|
|
2416
|
+
depth: r?.depth ?? a(s.DIMCALCFY, s.SIZEY)
|
|
2417
|
+
};
|
|
2418
|
+
return {
|
|
2419
|
+
current_prim: s,
|
|
2420
|
+
prim_dims: o
|
|
2421
|
+
};
|
|
2422
|
+
}
|
|
2423
|
+
function ze({ TREEID: e, dimension: t, view: r = x._3D }) {
|
|
2424
|
+
console.log(`===================================== Zone Start ${e} =====================================`);
|
|
2425
|
+
const i = ue(e), n = i?.zoneInfo(), s = i?.dividerThk || 0, a = Fe(), o = yt(e), l = It(o, i?.topShelfThk || 0, i?.bottomShelfThk || 0), u = _t(o), h = bt(t, u), m = kt(h, l), p = $(() => {
|
|
2426
|
+
if (i)
|
|
2427
|
+
return q.fromZoneData(i.currentZone, s);
|
|
2428
|
+
}, [i, s]), E = n ? Object.fromEntries(n) : {}, y = Gt(p), c = Bt(y, m.dimensions);
|
|
2429
|
+
E["AD article width"] = a?.prim_dims.width.toString(), E["AD article height"] = a?.prim_dims.height.toString(), E["AD article depth"] = a?.prim_dims.depth.toString(), E[0] = "0", E.X = c.toString();
|
|
2430
|
+
const d = p ? zt.descriptor(p) : !1, g = p ? oe.descriptor(p) : !1, N = d || g ? Yt({ divider: p, inputData: E }).updatedDivider : p, M = Dt(m, s, N, i?.children.map((D) => D.TREEID) || []);
|
|
2431
|
+
return (e === "0" || e === "0") && (console.log("start dimensions ", t), console.log("border inset", u), console.log("border thk", l), console.log("zone dimensions ", h.dimensions), console.log("position => ", h.position), console.log("remaining dimensions ", m.dimensions), console.log("remaining position => ", m.position)), /* @__PURE__ */ f(pe, { children: /* @__PURE__ */ O(J, { view: r, position: [h.position.x / v, h.position.y / v, h.position.z / v], children: [
|
|
2432
|
+
o.front?.CPNAME && /* @__PURE__ */ f(Ct, { view: r, TREEID: Oe(e), dimension: h.dimensions, helper: o }),
|
|
2433
|
+
o.left?.CPNAME && /* @__PURE__ */ f(Lt, { view: r, TREEID: Re(e), dimension: h.dimensions, helper: o }),
|
|
2434
|
+
o.back?.CPNAME && /* @__PURE__ */ f(Ot, { view: r, TREEID: Ve(e), dimension: h.dimensions, helper: o }),
|
|
2435
|
+
o.right?.CPNAME && /* @__PURE__ */ f(Pt, { view: r, TREEID: Pe(e), dimension: h.dimensions, helper: o }),
|
|
2436
|
+
i?.topShelfCP && /* @__PURE__ */ f(Vt, { view: r, TREEID: e, dimension: h.dimensions, helper: o }),
|
|
2437
|
+
i?.bottomShelfCP && /* @__PURE__ */ f(Rt, { view: r, TREEID: e, dimension: h.dimensions, helper: o }),
|
|
2438
|
+
/* @__PURE__ */ f(J, { view: r, position: [m.position.x / v, m.position.y / v, m.position.z / v], children: N && /* @__PURE__ */ f(Jt, { remainingZone: m, divider: N, view: r, childrenPositon: M, dividerThk: s }) })
|
|
2439
|
+
] }) });
|
|
2440
|
+
}
|
|
2441
|
+
const Qt = "scale(1,-1)";
|
|
2442
|
+
function Ge({ view: e = x._3D }) {
|
|
2443
|
+
console.log("========================================================= Designer ===============================================================================================");
|
|
2444
|
+
const r = Fe().prim_dims, i = /* @__PURE__ */ f(ze, { TREEID: "0", view: e, dimension: r }), n = e === x._3D ? i : /* @__PURE__ */ f("g", { transform: Qt, children: i });
|
|
2445
|
+
return console.log(n), n;
|
|
2446
|
+
}
|
|
2447
|
+
function ar({ view: e, data: t, articleName: r }) {
|
|
2448
|
+
const i = t.descriptors, n = t.variables, s = t.anglprim.map((a) => a.NAME);
|
|
2449
|
+
return /* @__PURE__ */ f(pe, { children: /* @__PURE__ */ f(We, { names: s, data: t, children: /* @__PURE__ */ f(be, { articleName: r, children: /* @__PURE__ */ f(je, { imosVariables: n, children: /* @__PURE__ */ f(it, { descriptorData: i, children: /* @__PURE__ */ f(Ge, { view: e }) }) }) }) }) });
|
|
2450
|
+
}
|
|
2451
|
+
function or() {
|
|
2452
|
+
const { tree: e, getValue: t, setValue: r } = j(), i = (o, l) => {
|
|
2453
|
+
const u = Number(l);
|
|
2454
|
+
r(o, isNaN(u) ? l : u);
|
|
2455
|
+
}, s = (() => {
|
|
2456
|
+
const o = {
|
|
2457
|
+
[P.Numeric]: { type: P.Numeric, label: "Dimensions (Numeric)", variables: [] },
|
|
2458
|
+
[P.Surface]: { type: P.Surface, label: "Surfaces", variables: [] },
|
|
2459
|
+
[P.Material]: { type: P.Material, label: "Materials", variables: [] },
|
|
2460
|
+
[P.Text]: { type: P.Text, label: "Text", variables: [] }
|
|
2461
|
+
};
|
|
2462
|
+
return Array.from(e.entries()).forEach(([l, u]) => {
|
|
2463
|
+
const h = t(l), m = u.WERT.startsWith("$");
|
|
2464
|
+
o[u.TYP]?.variables.push({
|
|
2465
|
+
name: l,
|
|
2466
|
+
value: h ?? "undefined",
|
|
2467
|
+
reference: m ? u.WERT : void 0,
|
|
2468
|
+
rawType: u.TYP
|
|
2469
|
+
});
|
|
2470
|
+
}), Object.values(o).filter((l) => l.variables.length > 0);
|
|
2471
|
+
})(), a = (o) => {
|
|
2472
|
+
const l = o.rawType === P.Numeric, u = typeof o.value == "number" ? o.value : Number(o.value);
|
|
2473
|
+
return l && !isNaN(u) ? /* @__PURE__ */ O("div", { className: "var-controller__slider-container", children: [
|
|
2474
|
+
/* @__PURE__ */ f(
|
|
2475
|
+
"input",
|
|
2476
|
+
{
|
|
2477
|
+
type: "range",
|
|
2478
|
+
min: 0,
|
|
2479
|
+
max: 2e4,
|
|
2480
|
+
value: u,
|
|
2481
|
+
onChange: (h) => i(o.name, h.target.value),
|
|
2482
|
+
className: "var-controller__slider"
|
|
2483
|
+
}
|
|
2484
|
+
),
|
|
2485
|
+
/* @__PURE__ */ f(
|
|
2486
|
+
"input",
|
|
2487
|
+
{
|
|
2488
|
+
type: "number",
|
|
2489
|
+
value: u,
|
|
2490
|
+
onChange: (h) => i(o.name, h.target.value),
|
|
2491
|
+
onBlur: (h) => i(o.name, h.target.value),
|
|
2492
|
+
className: "var-controller__number-input",
|
|
2493
|
+
min: 0,
|
|
2494
|
+
max: 2e4
|
|
2495
|
+
}
|
|
2496
|
+
)
|
|
2497
|
+
] }) : /* @__PURE__ */ f(
|
|
2498
|
+
"input",
|
|
2499
|
+
{
|
|
2500
|
+
type: "text",
|
|
2501
|
+
value: o.value,
|
|
2502
|
+
onChange: (h) => i(o.name, h.target.value),
|
|
2503
|
+
onBlur: (h) => i(o.name, h.target.value),
|
|
2504
|
+
className: "var-controller__text-input"
|
|
2505
|
+
}
|
|
2506
|
+
);
|
|
2507
|
+
};
|
|
2508
|
+
return /* @__PURE__ */ O("div", { className: "var-controller", children: [
|
|
2509
|
+
/* @__PURE__ */ f("h2", { children: "Variable Controller" }),
|
|
2510
|
+
/* @__PURE__ */ O("p", { className: "var-controller__header", children: [
|
|
2511
|
+
"Total variables: ",
|
|
2512
|
+
e.size
|
|
2513
|
+
] }),
|
|
2514
|
+
s.map((o) => /* @__PURE__ */ O("section", { className: "var-controller__section", children: [
|
|
2515
|
+
/* @__PURE__ */ O("h3", { className: "var-controller__section-title", children: [
|
|
2516
|
+
o.label,
|
|
2517
|
+
" (",
|
|
2518
|
+
o.variables.length,
|
|
2519
|
+
")"
|
|
2520
|
+
] }),
|
|
2521
|
+
/* @__PURE__ */ O("table", { className: "var-controller__table", children: [
|
|
2522
|
+
/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ O("tr", { children: [
|
|
2523
|
+
/* @__PURE__ */ f("th", { style: { width: "25%" }, children: "Variable Name" }),
|
|
2524
|
+
/* @__PURE__ */ f("th", { style: { width: "35%" }, children: "Current Value" }),
|
|
2525
|
+
/* @__PURE__ */ f("th", { style: { width: "25%" }, children: "Reference" }),
|
|
2526
|
+
/* @__PURE__ */ f("th", { className: "center", style: { width: "15%" }, children: "Type" })
|
|
2527
|
+
] }) }),
|
|
2528
|
+
/* @__PURE__ */ f("tbody", { children: o.variables.map((l) => /* @__PURE__ */ O("tr", { children: [
|
|
2529
|
+
/* @__PURE__ */ f("td", { className: "var-controller__var-name", children: l.name }),
|
|
2530
|
+
/* @__PURE__ */ f("td", { children: a(l) }),
|
|
2531
|
+
/* @__PURE__ */ f("td", { className: "var-controller__reference", children: l.reference || "-" }),
|
|
2532
|
+
/* @__PURE__ */ f("td", { style: { textAlign: "center" }, children: /* @__PURE__ */ f("span", { className: "var-controller__type-badge", children: o.type }) })
|
|
2533
|
+
] }, l.name)) })
|
|
2534
|
+
] })
|
|
2535
|
+
] }, o.type)),
|
|
2536
|
+
/* @__PURE__ */ O("section", { className: "var-controller__stats", children: [
|
|
2537
|
+
/* @__PURE__ */ f("h4", { children: "Quick Stats" }),
|
|
2538
|
+
/* @__PURE__ */ f("ul", { children: s.map((o) => /* @__PURE__ */ O("li", { children: [
|
|
2539
|
+
o.label,
|
|
2540
|
+
": ",
|
|
2541
|
+
o.variables.length,
|
|
2542
|
+
" variables"
|
|
2543
|
+
] }, o.type)) })
|
|
2544
|
+
] })
|
|
2545
|
+
] });
|
|
2546
|
+
}
|
|
2547
|
+
const lr = "1.0.0";
|
|
2548
|
+
export {
|
|
2549
|
+
_e as ArticleContext,
|
|
2550
|
+
ar as ArticleDesigner,
|
|
2551
|
+
be as ArticleProvider,
|
|
2552
|
+
F as DataContext,
|
|
2553
|
+
We as DataProvider,
|
|
2554
|
+
De as DescriptorContext,
|
|
2555
|
+
it as DescriptorProvider,
|
|
2556
|
+
Ge as Designer,
|
|
2557
|
+
lr as VERSION,
|
|
2558
|
+
x as VIEW,
|
|
2559
|
+
or as VarController,
|
|
2560
|
+
ke as VariableContext,
|
|
2561
|
+
je as VariableProvider,
|
|
2562
|
+
nr as VariableResolver,
|
|
2563
|
+
ze as Zone,
|
|
2564
|
+
Yt as ZoneDescriptor,
|
|
2565
|
+
ee as useArticle,
|
|
2566
|
+
Q as useData,
|
|
2567
|
+
Ft as useDescriptorEvaluation,
|
|
2568
|
+
$t as useDescriptorManager,
|
|
2569
|
+
sr as useDescriptorMatches,
|
|
2570
|
+
j as useVariables
|
|
2571
|
+
};
|