kaabalah 6.4.4 → 6.6.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.
@@ -1,598 +0,0 @@
1
- import { id, createTree } from './chunk-EFZUZI22.mjs';
2
-
3
- // src/visual/tree-svg.ts
4
- var TREE_SVG_DEFAULT_VIEWBOX = {
5
- minX: 0,
6
- minY: 0,
7
- width: 286,
8
- height: 561
9
- };
10
- var TREE_SPHERE_NAMES = [
11
- "Kether",
12
- "Chokhmah",
13
- "Binah",
14
- "Daath",
15
- "Chesed",
16
- "Geburah",
17
- "Tiphareth",
18
- "Netzach",
19
- "Hod",
20
- "Yesod",
21
- "Malkuth"
22
- ];
23
- var TREE_PATH_NUMBERS = Array.from({ length: 22 }, (_, index) => index + 1);
24
- var CANONICAL_X_PERCENTAGES = { left: 13.25, mid: 49.94, right: 86.66 };
25
- var CANONICAL_ROW_Y_PERCENTAGES = [
26
- 6.83,
27
- 17.68,
28
- 28.42,
29
- 39.26,
30
- 50.06,
31
- 60.85,
32
- 71.68,
33
- 93.2
34
- ];
35
- var DEFAULT_SPHERE_RADIUS = 30;
36
- var DEFAULT_PATH_EDGE_WIDTH = 26;
37
- var DEFAULT_PATH_MAIN_WIDTH = 22;
38
- var DEFAULT_PATH_HIGHLIGHT_WIDTH = 8;
39
- var sphereId = (name) => id("sphere" /* SPHERE */, name);
40
- var pathId = (pathNumber) => id("path" /* PATH */, String(pathNumber));
41
- var TREE_SPHERE_IDS = TREE_SPHERE_NAMES.map(
42
- (name) => sphereId(name)
43
- );
44
- var TREE_PATH_IDS = TREE_PATH_NUMBERS.map(
45
- (pathNumber) => pathId(pathNumber)
46
- );
47
- var CANONICAL_SPHERE_PERCENTAGES = {
48
- [sphereId("Kether")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[0] },
49
- [sphereId("Chokhmah")]: { x: CANONICAL_X_PERCENTAGES.right, y: CANONICAL_ROW_Y_PERCENTAGES[1] },
50
- [sphereId("Binah")]: { x: CANONICAL_X_PERCENTAGES.left, y: CANONICAL_ROW_Y_PERCENTAGES[1] },
51
- [sphereId("Daath")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[2] },
52
- [sphereId("Chesed")]: { x: CANONICAL_X_PERCENTAGES.right, y: CANONICAL_ROW_Y_PERCENTAGES[3] },
53
- [sphereId("Geburah")]: { x: CANONICAL_X_PERCENTAGES.left, y: CANONICAL_ROW_Y_PERCENTAGES[3] },
54
- [sphereId("Tiphareth")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[4] },
55
- [sphereId("Netzach")]: { x: CANONICAL_X_PERCENTAGES.right, y: CANONICAL_ROW_Y_PERCENTAGES[5] },
56
- [sphereId("Hod")]: { x: CANONICAL_X_PERCENTAGES.left, y: CANONICAL_ROW_Y_PERCENTAGES[5] },
57
- [sphereId("Yesod")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[6] },
58
- [sphereId("Malkuth")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[7] }
59
- };
60
- function getTreeLayout(system = "kaabalah") {
61
- const tree = createTree({ system });
62
- const percentages = buildLayoutMap(tree, CANONICAL_SPHERE_PERCENTAGES);
63
- const viewBoxUnits = buildLayoutMap(
64
- tree,
65
- scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, TREE_SVG_DEFAULT_VIEWBOX)
66
- );
67
- return {
68
- system,
69
- viewBox: { ...TREE_SVG_DEFAULT_VIEWBOX },
70
- sphereOrder: [...TREE_SPHERE_IDS],
71
- pathOrder: [...TREE_PATH_IDS],
72
- percentages,
73
- viewBoxUnits
74
- };
75
- }
76
- function generateTreeSvg(options = {}) {
77
- const system = options.system ?? "kaabalah";
78
- const daathLayer = options.daathLayer ?? "front";
79
- const tree = createTree({ system, parts: ["colors"] });
80
- const viewBox = normalizeViewBox(options.viewBox);
81
- const palette = resolvePalette(options.palette);
82
- const highlights = resolveHighlights(options.highlights);
83
- const spherePositions = scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, viewBox);
84
- const layout = buildLayoutMap(tree, spherePositions);
85
- const scale = Math.min(
86
- viewBox.width / TREE_SVG_DEFAULT_VIEWBOX.width,
87
- viewBox.height / TREE_SVG_DEFAULT_VIEWBOX.height
88
- );
89
- const radius = round(DEFAULT_SPHERE_RADIUS * scale);
90
- const pathEdgeWidth = round(DEFAULT_PATH_EDGE_WIDTH * scale);
91
- const pathMainWidth = round(DEFAULT_PATH_MAIN_WIDTH * scale);
92
- const pathHighlightWidth = round(DEFAULT_PATH_HIGHLIGHT_WIDTH * scale);
93
- const sphereStrokeWidth = palette.sphereStrokeWidth ? round(palette.sphereStrokeWidth * scale) : void 0;
94
- const lines = [];
95
- const push = (line) => lines.push(line);
96
- const svgAttributes = [
97
- `xmlns="http://www.w3.org/2000/svg"`,
98
- options.width !== void 0 ? `width="${escapeAttr(String(options.width))}"` : "",
99
- options.height !== void 0 ? `height="${escapeAttr(String(options.height))}"` : "",
100
- `viewBox="${viewBox.minX} ${viewBox.minY} ${viewBox.width} ${viewBox.height}"`,
101
- `preserveAspectRatio="xMidYMid meet"`
102
- ].filter(Boolean);
103
- push(`<svg ${svgAttributes.join(" ")}>`);
104
- push(`<defs>`);
105
- push(`<filter id="pathDarken">
106
- <feComponentTransfer>
107
- <feFuncR type="linear" slope="0.65"/>
108
- <feFuncG type="linear" slope="0.65"/>
109
- <feFuncB type="linear" slope="0.65"/>
110
- </feComponentTransfer>
111
- </filter>`);
112
- for (const sphereName of TREE_SPHERE_NAMES) {
113
- const currentSphereId = sphereId(sphereName);
114
- const slug = sphereName.toLowerCase();
115
- const point = spherePositions[currentSphereId];
116
- if (!point) {
117
- continue;
118
- }
119
- push(`<radialGradient id="spec-${slug}" cx="30%" cy="25%" r="55%" fx="30%" fy="25%">
120
- <stop offset="0%" stop-color="white" stop-opacity="0.95"/>
121
- <stop offset="25%" stop-color="white" stop-opacity="0.45"/>
122
- <stop offset="50%" stop-color="white" stop-opacity="0.08"/>
123
- <stop offset="100%" stop-color="white" stop-opacity="0"/>
124
- </radialGradient>`);
125
- push(`<radialGradient id="shad-${slug}" cx="78%" cy="80%" r="55%" fx="78%" fy="80%">
126
- <stop offset="0%" stop-color="black" stop-opacity="0.32"/>
127
- <stop offset="40%" stop-color="black" stop-opacity="0.12"/>
128
- <stop offset="100%" stop-color="black" stop-opacity="0"/>
129
- </radialGradient>`);
130
- push(
131
- `<clipPath id="clip-${slug}"><circle cx="${point.x}" cy="${point.y}" r="${radius}"/></clipPath>`
132
- );
133
- }
134
- push(`<radialGradient id="kether-glow" cx="50%" cy="50%" r="50%">
135
- <stop offset="0%" stop-color="white" stop-opacity="0.95"/>
136
- <stop offset="45%" stop-color="white" stop-opacity="0.6"/>
137
- <stop offset="80%" stop-color="white" stop-opacity="0.15"/>
138
- <stop offset="100%" stop-color="white" stop-opacity="0"/>
139
- </radialGradient>`);
140
- push(`<linearGradient id="kether-facet" x1="0" y1="0" x2="0" y2="1">
141
- <stop offset="0%" stop-color="white" stop-opacity="0.9"/>
142
- <stop offset="50%" stop-color="white" stop-opacity="0.5"/>
143
- <stop offset="100%" stop-color="white" stop-opacity="0.1"/>
144
- </linearGradient>`);
145
- push(`<radialGradient id="kether-rim" cx="50%" cy="50%" r="75%">
146
- <stop offset="60%" stop-color="black" stop-opacity="0"/>
147
- <stop offset="100%" stop-color="black" stop-opacity="0.18"/>
148
- </radialGradient>`);
149
- push(`</defs>`);
150
- const background = options.background ?? "white";
151
- if (background !== "transparent") {
152
- push(
153
- `<rect x="${viewBox.minX}" y="${viewBox.minY}" width="${viewBox.width}" height="${viewBox.height}" fill="${escapeAttr(background)}"/>`
154
- );
155
- }
156
- if (daathLayer === "back") {
157
- push(`<g id="spheres-behind-paths">`);
158
- renderSphere(push, {
159
- highlights,
160
- tree,
161
- palette,
162
- radius,
163
- sphereStrokeWidth,
164
- spherePositions,
165
- sphereName: "Daath"
166
- });
167
- push(`</g>`);
168
- }
169
- push(`<g id="paths">`);
170
- for (const currentPathId of TREE_PATH_IDS) {
171
- const path = layout.paths[currentPathId];
172
- const color = resolvePathColor({
173
- highlights,
174
- palette,
175
- tree,
176
- pathId: currentPathId
177
- });
178
- const edgeColor = resolvePathEdgeColor({
179
- palette,
180
- pathColor: color
181
- });
182
- push(
183
- `<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(edgeColor)}" stroke-width="${pathEdgeWidth}" stroke-linecap="round"${palette.pathEdgeUseFilter ? ` filter="url(#pathDarken)"` : ""}/>`
184
- );
185
- push(
186
- `<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(color)}" stroke-width="${pathMainWidth}" stroke-linecap="round"/>`
187
- );
188
- push(
189
- `<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(palette.pathHighlightColor)}" stroke-opacity="${palette.pathHighlightOpacity}" stroke-width="${pathHighlightWidth}" stroke-linecap="round"/>`
190
- );
191
- }
192
- push(`</g>`);
193
- const frontSphereNames = daathLayer === "back" ? TREE_SPHERE_NAMES.filter((name) => name !== "Daath") : TREE_SPHERE_NAMES;
194
- push(`<g id="spheres">`);
195
- for (const sphereName of frontSphereNames) {
196
- renderSphere(push, {
197
- highlights,
198
- tree,
199
- palette,
200
- radius,
201
- sphereStrokeWidth,
202
- spherePositions,
203
- sphereName
204
- });
205
- }
206
- push(`</g>`);
207
- if (daathLayer === "back") {
208
- const daathPoint = spherePositions[sphereId("Daath")];
209
- push(
210
- `<circle id="sphere-daath-hit-area" data-node-id="sphere:Daath" cx="${daathPoint.x}" cy="${daathPoint.y}" r="${radius}" fill="transparent" pointer-events="all"/>`
211
- );
212
- }
213
- push(`</svg>`);
214
- return lines.join("\n");
215
- }
216
- function renderSphere(push, params) {
217
- const currentSphereId = sphereId(params.sphereName);
218
- const point = params.spherePositions[currentSphereId];
219
- const slug = params.sphereName.toLowerCase();
220
- const colorData = params.tree.relatedFirst(currentSphereId, "color" /* COLOR */)?.data?.colorHexCodes ?? [];
221
- const sphereFill = resolveSphereFill({
222
- palette: params.palette,
223
- sphereId: currentSphereId,
224
- defaultColors: colorData
225
- });
226
- const highlightFill = params.highlights.sphereFills[currentSphereId];
227
- const activeFill = highlightFill ?? sphereFill;
228
- const preserveSpecialRenderer = params.palette.specialSphereMode === "preserve" && (highlightFill === void 0 || params.highlights.specialSphereMode === "preserve");
229
- push(`<g id="sphere-${slug}" clip-path="url(#clip-${slug})">`);
230
- if (preserveSpecialRenderer) {
231
- if (params.sphereName === "Kether") {
232
- renderKether(
233
- push,
234
- point,
235
- params.radius,
236
- highlightFill ? toPrimaryFill(highlightFill, "#e0e0e0") : void 0
237
- );
238
- } else if (params.sphereName === "Chokhmah") {
239
- renderIridescent(push, point, params.radius);
240
- if (highlightFill) {
241
- renderSphereTintOverlay(push, point, params.radius, highlightFill, 0.62);
242
- }
243
- } else if (params.sphereName === "Daath") {
244
- renderYinYang(push, point, params.radius, highlightFill);
245
- } else if (params.sphereName === "Malkuth" && colorData.length >= 4) {
246
- const slicedColors = resolveMalkuthColors({
247
- highlightFill,
248
- paletteFill: sphereFill,
249
- defaultColors: colorData.slice(0, 4)
250
- });
251
- renderSlicedSphere(push, point, params.radius, slicedColors, -135);
252
- } else {
253
- push(
254
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}"/>`
255
- );
256
- }
257
- } else {
258
- push(
259
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}"/>`
260
- );
261
- }
262
- push(
263
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="url(#spec-${slug})"/>`
264
- );
265
- if (!preserveSpecialRenderer || params.sphereName !== "Kether" && params.sphereName !== "Chokhmah") {
266
- push(
267
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="url(#shad-${slug})"/>`
268
- );
269
- }
270
- push(`</g>`);
271
- if (params.palette.sphereStrokeColor && params.sphereStrokeWidth) {
272
- push(
273
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="none" stroke="${escapeAttr(params.palette.sphereStrokeColor)}" stroke-width="${params.sphereStrokeWidth}"/>`
274
- );
275
- }
276
- }
277
- function buildLayoutMap(tree, spherePositions) {
278
- const paths = {};
279
- for (const currentPathId of TREE_PATH_IDS) {
280
- const path = tree.getNode(currentPathId);
281
- const fromId = path?.data?.from;
282
- const toId = path?.data?.to;
283
- if (!fromId || !toId) {
284
- throw new Error(`Tree path ${currentPathId} is missing endpoints.`);
285
- }
286
- const from = spherePositions[fromId];
287
- const to = spherePositions[toId];
288
- if (!from || !to) {
289
- throw new Error(
290
- `Tree path ${currentPathId} references unknown layout spheres: ${fromId}, ${toId}.`
291
- );
292
- }
293
- paths[currentPathId] = {
294
- fromId,
295
- toId,
296
- from: { ...from },
297
- to: { ...to }
298
- };
299
- }
300
- return {
301
- spheres: cloneCoordinateMap(spherePositions),
302
- paths
303
- };
304
- }
305
- function cloneCoordinateMap(coordinates) {
306
- const clone = {};
307
- for (const currentSphereId of TREE_SPHERE_IDS) {
308
- const point = coordinates[currentSphereId];
309
- clone[currentSphereId] = { ...point };
310
- }
311
- return clone;
312
- }
313
- function scaleCoordinates(coordinates, viewBox) {
314
- const scaled = {};
315
- for (const currentSphereId of TREE_SPHERE_IDS) {
316
- const point = coordinates[currentSphereId];
317
- scaled[currentSphereId] = {
318
- x: round(viewBox.minX + point.x / 100 * viewBox.width),
319
- y: round(viewBox.minY + point.y / 100 * viewBox.height)
320
- };
321
- }
322
- return scaled;
323
- }
324
- function normalizeViewBox(viewBox) {
325
- return {
326
- minX: viewBox?.minX ?? TREE_SVG_DEFAULT_VIEWBOX.minX,
327
- minY: viewBox?.minY ?? TREE_SVG_DEFAULT_VIEWBOX.minY,
328
- width: viewBox?.width ?? TREE_SVG_DEFAULT_VIEWBOX.width,
329
- height: viewBox?.height ?? TREE_SVG_DEFAULT_VIEWBOX.height
330
- };
331
- }
332
- function resolvePalette(palette) {
333
- if (palette === void 0 || palette === "color") {
334
- return {
335
- mode: "color",
336
- defaultSphereFill: "#888888",
337
- defaultPathColor: "#888888",
338
- sphereFills: {},
339
- pathColors: {},
340
- pathEdgeColor: "#888888",
341
- pathEdgeUseFilter: true,
342
- pathHighlightColor: "white",
343
- pathHighlightOpacity: 0.25,
344
- specialSphereMode: "preserve"
345
- };
346
- }
347
- if (palette === "monochrome") {
348
- return {
349
- mode: "monochrome",
350
- defaultSphereFill: "#e6ddd0",
351
- defaultPathColor: "#e0d7ca",
352
- sphereFills: {},
353
- pathColors: {},
354
- pathEdgeColor: "#2f271e",
355
- pathEdgeUseFilter: false,
356
- sphereStrokeColor: "#2f271e",
357
- sphereStrokeWidth: 2.4,
358
- pathHighlightColor: "white",
359
- pathHighlightOpacity: 0.2,
360
- specialSphereMode: "plain"
361
- };
362
- }
363
- return {
364
- mode: "custom",
365
- defaultSphereFill: palette.defaultSphereFill ?? "#111111",
366
- defaultPathColor: palette.defaultPathColor ?? "#111111",
367
- sphereFills: palette.sphereFills ?? {},
368
- pathColors: palette.pathColors ?? {},
369
- pathEdgeColor: palette.pathEdgeColor ?? (palette.defaultPathColor ?? "#111111"),
370
- pathEdgeUseFilter: false,
371
- sphereStrokeColor: palette.sphereStrokeColor,
372
- sphereStrokeWidth: palette.sphereStrokeWidth,
373
- pathHighlightColor: palette.pathHighlightColor ?? "white",
374
- pathHighlightOpacity: palette.pathHighlightOpacity ?? 0.18,
375
- specialSphereMode: palette.specialSphereMode ?? "plain"
376
- };
377
- }
378
- function resolveHighlights(highlights) {
379
- return {
380
- pathColors: highlights?.paths ?? {},
381
- sphereFills: highlights?.spheres ?? {},
382
- specialSphereMode: highlights?.specialSphereMode ?? "preserve"
383
- };
384
- }
385
- function resolvePathColor(params) {
386
- const highlightOverride = params.highlights.pathColors[params.pathId];
387
- if (highlightOverride) {
388
- return highlightOverride;
389
- }
390
- const override = params.palette.pathColors[params.pathId];
391
- if (override) {
392
- return override;
393
- }
394
- if (params.palette.mode === "monochrome" || params.palette.mode === "custom") {
395
- return params.palette.defaultPathColor;
396
- }
397
- const treeColor = params.tree.relatedFirst(params.pathId, "color" /* COLOR */)?.data?.colorHexCodes?.[0];
398
- return treeColor ?? params.palette.defaultPathColor;
399
- }
400
- function resolvePathEdgeColor(params) {
401
- if (params.palette.mode === "color") {
402
- return params.pathColor;
403
- }
404
- return params.palette.pathEdgeColor;
405
- }
406
- function resolveSphereFill(params) {
407
- const override = params.palette.sphereFills[params.sphereId];
408
- if (override) {
409
- return override;
410
- }
411
- if (params.palette.mode === "monochrome" || params.palette.mode === "custom") {
412
- return params.palette.defaultSphereFill;
413
- }
414
- if (params.defaultColors.length > 0) {
415
- return params.defaultColors;
416
- }
417
- return params.palette.defaultSphereFill;
418
- }
419
- function toPrimaryFill(fill, fallback) {
420
- if (Array.isArray(fill)) {
421
- return fill[0] ?? fallback;
422
- }
423
- return fill;
424
- }
425
- function resolveMalkuthColors(params) {
426
- if (params.highlightFill) {
427
- return expandColors(
428
- params.highlightFill,
429
- params.defaultColors.length,
430
- params.defaultColors
431
- );
432
- }
433
- if (Array.isArray(params.paletteFill)) {
434
- return expandColors(
435
- params.paletteFill,
436
- params.defaultColors.length,
437
- params.defaultColors
438
- );
439
- }
440
- return params.defaultColors;
441
- }
442
- function expandColors(fill, count, fallbackColors) {
443
- if (Array.isArray(fill)) {
444
- if (fill.length === 0) {
445
- return fallbackColors.slice(0, count);
446
- }
447
- return Array.from({ length: count }, (_, index) => {
448
- return fill[index] ?? fill[fill.length - 1];
449
- });
450
- }
451
- return Array.from({ length: count }, () => fill);
452
- }
453
- function round(value) {
454
- return Math.round(value * 100) / 100;
455
- }
456
- function polarToCartesian(cx, cy, radius, degrees) {
457
- const radians = Math.PI / 180 * degrees;
458
- return {
459
- x: round(cx + radius * Math.cos(radians)),
460
- y: round(cy + radius * Math.sin(radians))
461
- };
462
- }
463
- function arcPath(cx, cy, radius, startDegrees, endDegrees) {
464
- const start = polarToCartesian(cx, cy, radius, startDegrees);
465
- const end = polarToCartesian(cx, cy, radius, endDegrees);
466
- const largeArc = endDegrees - startDegrees <= 180 ? 0 : 1;
467
- return `M ${cx} ${cy} L ${start.x} ${start.y} A ${radius} ${radius} 0 ${largeArc} 1 ${end.x} ${end.y} Z`;
468
- }
469
- function renderKether(push, point, radius, baseFill = "#e0e0e0") {
470
- push(
471
- `<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="${escapeAttr(baseFill)}"/>`
472
- );
473
- push(`<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="url(#kether-glow)"/>`);
474
- const spokes = 16;
475
- const innerRadius = round(radius * 0.18);
476
- const outerRadius = round(radius * 0.92);
477
- const innerWidth = round(radius * 0.04);
478
- const angleStep = 360 / spokes;
479
- push(`<g opacity="0.85">`);
480
- for (let index = 0; index < spokes; index++) {
481
- const angle = index * angleStep;
482
- push(`<g transform="rotate(${angle} ${point.x} ${point.y})">`);
483
- const x0 = round(point.x - innerWidth);
484
- const y0 = round(point.y - innerRadius);
485
- const x1 = point.x;
486
- const y1 = round(point.y - outerRadius);
487
- const x2 = round(point.x + innerWidth);
488
- const y2 = round(point.y - innerRadius);
489
- push(
490
- `<polygon points="${x0},${y0} ${x1},${y1} ${x2},${y2} ${point.x},${point.y}" fill="url(#kether-facet)"/>`
491
- );
492
- push(`</g>`);
493
- }
494
- push(`</g>`);
495
- push(`<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="url(#kether-rim)"/>`);
496
- }
497
- function renderSlicedSphere(push, point, radius, colors, startAngle) {
498
- const segmentCount = colors.length;
499
- const step = 360 / segmentCount;
500
- let currentAngle = startAngle;
501
- for (let index = 0; index < segmentCount; index++) {
502
- const path = arcPath(point.x, point.y, radius * 0.96, currentAngle, currentAngle + step);
503
- push(`<path d="${path}" fill="${escapeAttr(colors[index])}" stroke="none"/>`);
504
- currentAngle += step;
505
- }
506
- }
507
- function renderIridescent(push, point, radius) {
508
- const stops = [
509
- [0, "#F0E8EE"],
510
- [0.1, "#ffa3e6"],
511
- [0.22, "#a7e0ff"],
512
- [0.34, "#baff9a"],
513
- [0.46, "#ffe28a"],
514
- [0.58, "#c6a4ff"],
515
- [0.7, "#9ad6ff"],
516
- [0.82, "#ffa3e6"],
517
- [1, "#F0E8EE"]
518
- ];
519
- const slices = 72;
520
- const sphereRadius = round(radius * 0.96);
521
- for (let index = 0; index < slices; index++) {
522
- const t = index / slices;
523
- const color = interpolateColorStops(stops, t);
524
- const startDegrees = t * 360 - 90;
525
- const endDegrees = startDegrees + 360 / slices + 0.5;
526
- const path = arcPath(point.x, point.y, sphereRadius, startDegrees, endDegrees);
527
- push(`<path d="${path}" fill="${color}" stroke="none"/>`);
528
- }
529
- }
530
- function interpolateColorStops(stops, t) {
531
- let lower = stops[0];
532
- let upper = stops[stops.length - 1];
533
- for (let index = 0; index < stops.length - 1; index++) {
534
- if (t >= stops[index][0] && t <= stops[index + 1][0]) {
535
- lower = stops[index];
536
- upper = stops[index + 1];
537
- break;
538
- }
539
- }
540
- const range = upper[0] - lower[0] || 1;
541
- return interpolateColor(lower[1], upper[1], (t - lower[0]) / range);
542
- }
543
- function interpolateColor(start, end, factor) {
544
- const parse = (hex) => {
545
- const match = hex.match(/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);
546
- return match ? [
547
- Number.parseInt(match[1], 16),
548
- Number.parseInt(match[2], 16),
549
- Number.parseInt(match[3], 16)
550
- ] : [0, 0, 0];
551
- };
552
- const [r1, g1, b1] = parse(start);
553
- const [r2, g2, b2] = parse(end);
554
- const mix = (left, right) => Math.round(left + (right - left) * factor);
555
- return `#${mix(r1, r2).toString(16).padStart(2, "0")}${mix(g1, g2).toString(16).padStart(2, "0")}${mix(b1, b2).toString(16).padStart(2, "0")}`;
556
- }
557
- function renderYinYang(push, point, radius, fill) {
558
- const scale = radius / 50;
559
- const circleRadius = round(48 * scale);
560
- const halfRadius = round(24 * scale);
561
- const dotRadius = round(6 * scale);
562
- const [lightFill, darkFill] = resolveDualToneFill(fill);
563
- push(`<g transform="rotate(180 ${point.x} ${point.y})">`);
564
- push(
565
- `<circle cx="${point.x}" cy="${point.y}" r="${circleRadius}" fill="${escapeAttr(lightFill)}"/>`
566
- );
567
- push(
568
- `<path d="M${point.x},${round(point.y - circleRadius)} A${circleRadius},${circleRadius} 0 1,1 ${point.x},${round(point.y + circleRadius)} A${halfRadius},${halfRadius} 0 1,0 ${point.x},${point.y} A${halfRadius},${halfRadius} 0 1,1 ${point.x},${round(point.y - circleRadius)}" fill="${escapeAttr(darkFill)}"/>`
569
- );
570
- push(
571
- `<circle cx="${point.x}" cy="${round(point.y - halfRadius)}" r="${dotRadius}" fill="${escapeAttr(lightFill)}"/>`
572
- );
573
- push(
574
- `<circle cx="${point.x}" cy="${round(point.y + halfRadius)}" r="${dotRadius}" fill="${escapeAttr(darkFill)}"/>`
575
- );
576
- push(`</g>`);
577
- }
578
- function renderSphereTintOverlay(push, point, radius, fill, opacity) {
579
- push(
580
- `<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="${escapeAttr(toPrimaryFill(fill, "#ffffff"))}" fill-opacity="${opacity}"/>`
581
- );
582
- }
583
- function resolveDualToneFill(fill) {
584
- if (Array.isArray(fill)) {
585
- return [fill[0] ?? "white", fill[1] ?? "black"];
586
- }
587
- if (fill) {
588
- return [fill, "black"];
589
- }
590
- return ["white", "black"];
591
- }
592
- function escapeAttr(value) {
593
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
594
- }
595
-
596
- export { TREE_PATH_IDS, TREE_SPHERE_IDS, TREE_SPHERE_NAMES, TREE_SVG_DEFAULT_VIEWBOX, generateTreeSvg, getTreeLayout };
597
- //# sourceMappingURL=chunk-EVH4J5E2.mjs.map
598
- //# sourceMappingURL=chunk-EVH4J5E2.mjs.map