kaabalah 6.4.1 → 6.4.2

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.
@@ -79,6 +79,7 @@ function generateTreeSvg(options = {}) {
79
79
  const tree = createTree({ system, parts: ["colors"] });
80
80
  const viewBox = normalizeViewBox(options.viewBox);
81
81
  const palette = resolvePalette(options.palette);
82
+ const highlights = resolveHighlights(options.highlights);
82
83
  const spherePositions = scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, viewBox);
83
84
  const layout = buildLayoutMap(tree, spherePositions);
84
85
  const scale = Math.min(
@@ -155,6 +156,7 @@ function generateTreeSvg(options = {}) {
155
156
  if (daathLayer === "back") {
156
157
  push(`<g id="spheres-behind-paths">`);
157
158
  renderSphere(push, {
159
+ highlights,
158
160
  tree,
159
161
  palette,
160
162
  radius,
@@ -168,12 +170,17 @@ function generateTreeSvg(options = {}) {
168
170
  for (const currentPathId of TREE_PATH_IDS) {
169
171
  const path = layout.paths[currentPathId];
170
172
  const color = resolvePathColor({
173
+ highlights,
171
174
  palette,
172
175
  tree,
173
176
  pathId: currentPathId
174
177
  });
178
+ const edgeColor = resolvePathEdgeColor({
179
+ palette,
180
+ pathColor: color
181
+ });
175
182
  push(
176
- `<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(palette.pathEdgeColor)}" stroke-width="${pathEdgeWidth}" stroke-linecap="round"${palette.pathEdgeUseFilter ? ` filter="url(#pathDarken)"` : ""}/>`
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)"` : ""}/>`
177
184
  );
178
185
  push(
179
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,6 +194,7 @@ function generateTreeSvg(options = {}) {
187
194
  push(`<g id="spheres">`);
188
195
  for (const sphereName of frontSphereNames) {
189
196
  renderSphere(push, {
197
+ highlights,
190
198
  tree,
191
199
  palette,
192
200
  radius,
@@ -215,25 +223,39 @@ function renderSphere(push, params) {
215
223
  sphereId: currentSphereId,
216
224
  defaultColors: colorData
217
225
  });
226
+ const highlightFill = params.highlights.sphereFills[currentSphereId];
227
+ const activeFill = highlightFill ?? sphereFill;
218
228
  push(`<g id="sphere-${slug}" clip-path="url(#clip-${slug})">`);
219
229
  if (params.palette.specialSphereMode === "preserve") {
220
230
  if (params.sphereName === "Kether") {
221
- renderKether(push, point, params.radius);
231
+ renderKether(
232
+ push,
233
+ point,
234
+ params.radius,
235
+ highlightFill ? toPrimaryFill(highlightFill, "#e0e0e0") : void 0
236
+ );
222
237
  } else if (params.sphereName === "Chokhmah") {
223
238
  renderIridescent(push, point, params.radius);
239
+ if (highlightFill) {
240
+ renderSphereTintOverlay(push, point, params.radius, highlightFill, 0.62);
241
+ }
224
242
  } else if (params.sphereName === "Daath") {
225
- renderYinYang(push, point, params.radius);
243
+ renderYinYang(push, point, params.radius, highlightFill);
226
244
  } else if (params.sphereName === "Malkuth" && colorData.length >= 4) {
227
- const slicedColors = Array.isArray(sphereFill) ? sphereFill : colorData.slice(0, 4);
245
+ const slicedColors = resolveMalkuthColors({
246
+ highlightFill,
247
+ paletteFill: sphereFill,
248
+ defaultColors: colorData.slice(0, 4)
249
+ });
228
250
  renderSlicedSphere(push, point, params.radius, slicedColors, -135);
229
251
  } else {
230
252
  push(
231
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(sphereFill, params.palette.defaultSphereFill))}"/>`
253
+ `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}"/>`
232
254
  );
233
255
  }
234
256
  } else {
235
257
  push(
236
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(sphereFill, params.palette.defaultSphereFill))}"/>`
258
+ `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}"/>`
237
259
  );
238
260
  }
239
261
  push(
@@ -352,7 +374,17 @@ function resolvePalette(palette) {
352
374
  specialSphereMode: palette.specialSphereMode ?? "plain"
353
375
  };
354
376
  }
377
+ function resolveHighlights(highlights) {
378
+ return {
379
+ pathColors: highlights?.paths ?? {},
380
+ sphereFills: highlights?.spheres ?? {}
381
+ };
382
+ }
355
383
  function resolvePathColor(params) {
384
+ const highlightOverride = params.highlights.pathColors[params.pathId];
385
+ if (highlightOverride) {
386
+ return highlightOverride;
387
+ }
356
388
  const override = params.palette.pathColors[params.pathId];
357
389
  if (override) {
358
390
  return override;
@@ -363,6 +395,12 @@ function resolvePathColor(params) {
363
395
  const treeColor = params.tree.relatedFirst(params.pathId, "color" /* COLOR */)?.data?.colorHexCodes?.[0];
364
396
  return treeColor ?? params.palette.defaultPathColor;
365
397
  }
398
+ function resolvePathEdgeColor(params) {
399
+ if (params.palette.mode === "color") {
400
+ return params.pathColor;
401
+ }
402
+ return params.palette.pathEdgeColor;
403
+ }
366
404
  function resolveSphereFill(params) {
367
405
  const override = params.palette.sphereFills[params.sphereId];
368
406
  if (override) {
@@ -382,6 +420,34 @@ function toPrimaryFill(fill, fallback) {
382
420
  }
383
421
  return fill;
384
422
  }
423
+ function resolveMalkuthColors(params) {
424
+ if (params.highlightFill) {
425
+ return expandColors(
426
+ params.highlightFill,
427
+ params.defaultColors.length,
428
+ params.defaultColors
429
+ );
430
+ }
431
+ if (Array.isArray(params.paletteFill)) {
432
+ return expandColors(
433
+ params.paletteFill,
434
+ params.defaultColors.length,
435
+ params.defaultColors
436
+ );
437
+ }
438
+ return params.defaultColors;
439
+ }
440
+ function expandColors(fill, count, fallbackColors) {
441
+ if (Array.isArray(fill)) {
442
+ if (fill.length === 0) {
443
+ return fallbackColors.slice(0, count);
444
+ }
445
+ return Array.from({ length: count }, (_, index) => {
446
+ return fill[index] ?? fill[fill.length - 1];
447
+ });
448
+ }
449
+ return Array.from({ length: count }, () => fill);
450
+ }
385
451
  function round(value) {
386
452
  return Math.round(value * 100) / 100;
387
453
  }
@@ -398,8 +464,10 @@ function arcPath(cx, cy, radius, startDegrees, endDegrees) {
398
464
  const largeArc = endDegrees - startDegrees <= 180 ? 0 : 1;
399
465
  return `M ${cx} ${cy} L ${start.x} ${start.y} A ${radius} ${radius} 0 ${largeArc} 1 ${end.x} ${end.y} Z`;
400
466
  }
401
- function renderKether(push, point, radius) {
402
- push(`<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="#e0e0e0"/>`);
467
+ function renderKether(push, point, radius, baseFill = "#e0e0e0") {
468
+ push(
469
+ `<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="${escapeAttr(baseFill)}"/>`
470
+ );
403
471
  push(`<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="url(#kether-glow)"/>`);
404
472
  const spokes = 16;
405
473
  const innerRadius = round(radius * 0.18);
@@ -484,28 +552,45 @@ function interpolateColor(start, end, factor) {
484
552
  const mix = (left, right) => Math.round(left + (right - left) * factor);
485
553
  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")}`;
486
554
  }
487
- function renderYinYang(push, point, radius) {
555
+ function renderYinYang(push, point, radius, fill) {
488
556
  const scale = radius / 50;
489
557
  const circleRadius = round(48 * scale);
490
558
  const halfRadius = round(24 * scale);
491
559
  const dotRadius = round(6 * scale);
560
+ const [lightFill, darkFill] = resolveDualToneFill(fill);
492
561
  push(`<g transform="rotate(180 ${point.x} ${point.y})">`);
493
- push(`<circle cx="${point.x}" cy="${point.y}" r="${circleRadius}" fill="white"/>`);
494
562
  push(
495
- `<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="black"/>`
563
+ `<circle cx="${point.x}" cy="${point.y}" r="${circleRadius}" fill="${escapeAttr(lightFill)}"/>`
564
+ );
565
+ push(
566
+ `<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)}"/>`
496
567
  );
497
568
  push(
498
- `<circle cx="${point.x}" cy="${round(point.y - halfRadius)}" r="${dotRadius}" fill="white"/>`
569
+ `<circle cx="${point.x}" cy="${round(point.y - halfRadius)}" r="${dotRadius}" fill="${escapeAttr(lightFill)}"/>`
499
570
  );
500
571
  push(
501
- `<circle cx="${point.x}" cy="${round(point.y + halfRadius)}" r="${dotRadius}" fill="black"/>`
572
+ `<circle cx="${point.x}" cy="${round(point.y + halfRadius)}" r="${dotRadius}" fill="${escapeAttr(darkFill)}"/>`
502
573
  );
503
574
  push(`</g>`);
504
575
  }
576
+ function renderSphereTintOverlay(push, point, radius, fill, opacity) {
577
+ push(
578
+ `<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="${escapeAttr(toPrimaryFill(fill, "#ffffff"))}" fill-opacity="${opacity}"/>`
579
+ );
580
+ }
581
+ function resolveDualToneFill(fill) {
582
+ if (Array.isArray(fill)) {
583
+ return [fill[0] ?? "white", fill[1] ?? "black"];
584
+ }
585
+ if (fill) {
586
+ return [fill, "black"];
587
+ }
588
+ return ["white", "black"];
589
+ }
505
590
  function escapeAttr(value) {
506
591
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
507
592
  }
508
593
 
509
594
  export { TREE_PATH_IDS, TREE_SPHERE_IDS, TREE_SPHERE_NAMES, TREE_SVG_DEFAULT_VIEWBOX, generateTreeSvg, getTreeLayout };
510
- //# sourceMappingURL=chunk-EMMXVM35.mjs.map
511
- //# sourceMappingURL=chunk-EMMXVM35.mjs.map
595
+ //# sourceMappingURL=chunk-2WEGGWW4.mjs.map
596
+ //# sourceMappingURL=chunk-2WEGGWW4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/visual/tree-svg.ts"],"names":[],"mappings":";;;AA0FO,IAAM,wBAAqD,GAAA;AAAA,EAChE,IAAM,EAAA,CAAA;AAAA,EACN,IAAM,EAAA,CAAA;AAAA,EACN,KAAO,EAAA,GAAA;AAAA,EACP,MAAQ,EAAA;AACV;AAEO,IAAM,iBAAoB,GAAA;AAAA,EAC/B,QAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF;AAEA,IAAM,iBAAA,GAAoB,KAAM,CAAA,IAAA,CAAK,EAAE,MAAA,EAAQ,EAAG,EAAA,EAAG,CAAC,CAAA,EAAG,KAAU,KAAA,KAAA,GAAQ,CAAC,CAAA;AAC5E,IAAM,0BAA0B,EAAE,IAAA,EAAM,OAAO,GAAK,EAAA,KAAA,EAAO,OAAO,KAAM,EAAA;AACxE,IAAM,2BAA8B,GAAA;AAAA,EAClC,IAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,qBAAwB,GAAA,EAAA;AAC9B,IAAM,uBAA0B,GAAA,EAAA;AAChC,IAAM,uBAA0B,GAAA,EAAA;AAChC,IAAM,4BAA+B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,CAAe,YAAA,EAAA,KAAA,CAAM,CAAC,CAAA,MAAA,EAAS,MAAM,KAAM,CAAA,CAAA,GAAI,UAAU,CAAC,CAAQ,KAAA,EAAA,SAAS,CAAW,QAAA,EAAA,UAAA,CAAW,QAAQ,CAAC,CAAA,GAAA;AAAA,GAC5G;AACA,EAAA,IAAA,CAAK,CAAM,IAAA,CAAA,CAAA;AACb;AAEA,SAAS,uBACP,CAAA,IAAA,EACA,KACA,EAAA,MAAA,EACA,MACA,OACA,EAAA;AACA,EAAA,IAAA;AAAA,IACE,eAAe,KAAM,CAAA,CAAC,CAAS,MAAA,EAAA,KAAA,CAAM,CAAC,CAAQ,KAAA,EAAA,MAAM,CAAW,QAAA,EAAA,UAAA,CAAW,cAAc,IAAM,EAAA,SAAS,CAAC,CAAC,mBAAmB,OAAO,CAAA,GAAA;AAAA,GACrI;AACF;AAEA,SAAS,oBAAoB,IAAqC,EAAA;AAChE,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,IAAI,CAAG,EAAA;AACvB,IAAO,OAAA,CAAC,KAAK,CAAC,CAAA,IAAK,SAAS,IAAK,CAAA,CAAC,KAAK,OAAO,CAAA;AAAA;AAGhD,EAAA,IAAI,IAAM,EAAA;AACR,IAAO,OAAA,CAAC,MAAM,OAAO,CAAA;AAAA;AAGvB,EAAO,OAAA,CAAC,SAAS,OAAO,CAAA;AAC1B;AAEA,SAAS,WAAW,KAAe,EAAA;AACjC,EAAA,OAAO,KACJ,CAAA,OAAA,CAAQ,IAAM,EAAA,OAAO,EACrB,OAAQ,CAAA,IAAA,EAAM,MAAM,CAAA,CACpB,QAAQ,IAAM,EAAA,MAAM,CACpB,CAAA,OAAA,CAAQ,MAAM,QAAQ,CAAA;AAC3B","file":"chunk-2WEGGWW4.mjs","sourcesContent":["import {\n createTree,\n id,\n KaabalahTypes,\n MiscTypes,\n type NodeId,\n type SystemKey,\n} from \"../core\";\n\nexport interface TreeSvgViewBox {\n minX?: number;\n minY?: number;\n width: number;\n height: number;\n}\n\nexport interface TreeLayoutCoordinate {\n x: number;\n y: number;\n}\n\nexport type TreeSphereName =\n | \"Kether\"\n | \"Chokhmah\"\n | \"Binah\"\n | \"Daath\"\n | \"Chesed\"\n | \"Geburah\"\n | \"Tiphareth\"\n | \"Netzach\"\n | \"Hod\"\n | \"Yesod\"\n | \"Malkuth\";\n\nexport type TreeSphereId = NodeId<KaabalahTypes.SPHERE>;\nexport type TreePathId = NodeId<KaabalahTypes.PATH>;\n\nexport interface TreeLayoutPath {\n fromId: TreeSphereId;\n toId: TreeSphereId;\n from: TreeLayoutCoordinate;\n to: TreeLayoutCoordinate;\n}\n\nexport interface TreeLayoutMap {\n spheres: Record<TreeSphereId, TreeLayoutCoordinate>;\n paths: Record<TreePathId, TreeLayoutPath>;\n}\n\nexport interface TreeLayout {\n system: SystemKey;\n viewBox: Required<TreeSvgViewBox>;\n sphereOrder: TreeSphereId[];\n pathOrder: TreePathId[];\n percentages: TreeLayoutMap;\n viewBoxUnits: TreeLayoutMap;\n}\n\nexport interface TreeSvgCustomPalette {\n defaultSphereFill?: string;\n defaultPathColor?: string;\n sphereFills?: Partial<Record<TreeSphereId, string | string[]>>;\n pathColors?: Partial<Record<TreePathId, string>>;\n pathEdgeColor?: string;\n sphereStrokeColor?: string;\n sphereStrokeWidth?: number;\n pathHighlightColor?: string;\n pathHighlightOpacity?: number;\n specialSphereMode?: \"preserve\" | \"plain\";\n}\n\nexport type TreeSvgPalette = \"color\" | \"monochrome\" | TreeSvgCustomPalette;\nexport type TreeSvgDaathLayer = \"front\" | \"back\";\n\nexport interface TreeSvgHighlights {\n paths?: Partial<Record<TreePathId, string>>;\n spheres?: Partial<Record<TreeSphereId, string | string[]>>;\n}\n\nexport interface TreeSvgOptions {\n width?: number | string;\n height?: number | string;\n viewBox?: TreeSvgViewBox;\n background?: string | \"transparent\";\n palette?: TreeSvgPalette;\n system?: SystemKey;\n daathLayer?: TreeSvgDaathLayer;\n highlights?: TreeSvgHighlights;\n}\n\nexport const TREE_SVG_DEFAULT_VIEWBOX: Required<TreeSvgViewBox> = {\n minX: 0,\n minY: 0,\n width: 286,\n height: 561,\n};\n\nexport const TREE_SPHERE_NAMES = [\n \"Kether\",\n \"Chokhmah\",\n \"Binah\",\n \"Daath\",\n \"Chesed\",\n \"Geburah\",\n \"Tiphareth\",\n \"Netzach\",\n \"Hod\",\n \"Yesod\",\n \"Malkuth\",\n] as const satisfies readonly TreeSphereName[];\n\nconst TREE_PATH_NUMBERS = Array.from({ length: 22 }, (_, index) => index + 1);\nconst CANONICAL_X_PERCENTAGES = { left: 13.25, mid: 49.94, right: 86.66 } as const;\nconst CANONICAL_ROW_Y_PERCENTAGES = [\n 6.83,\n 17.68,\n 28.42,\n 39.26,\n 50.06,\n 60.85,\n 71.68,\n 93.2,\n] as const;\n\nconst DEFAULT_SPHERE_RADIUS = 30;\nconst DEFAULT_PATH_EDGE_WIDTH = 26;\nconst DEFAULT_PATH_MAIN_WIDTH = 22;\nconst DEFAULT_PATH_HIGHLIGHT_WIDTH = 8;\n\nconst sphereId = (name: TreeSphereName) =>\n id(KaabalahTypes.SPHERE, name) as TreeSphereId;\nconst pathId = (pathNumber: number) =>\n id(KaabalahTypes.PATH, String(pathNumber)) as TreePathId;\n\nexport const TREE_SPHERE_IDS = TREE_SPHERE_NAMES.map((name) =>\n sphereId(name)\n) as TreeSphereId[];\nexport const TREE_PATH_IDS = TREE_PATH_NUMBERS.map((pathNumber) =>\n pathId(pathNumber)\n) as TreePathId[];\n\nconst CANONICAL_SPHERE_PERCENTAGES = {\n [sphereId(\"Kether\")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[0] },\n [sphereId(\"Chokhmah\")]: { x: CANONICAL_X_PERCENTAGES.right, y: CANONICAL_ROW_Y_PERCENTAGES[1] },\n [sphereId(\"Binah\")]: { x: CANONICAL_X_PERCENTAGES.left, y: CANONICAL_ROW_Y_PERCENTAGES[1] },\n [sphereId(\"Daath\")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[2] },\n [sphereId(\"Chesed\")]: { x: CANONICAL_X_PERCENTAGES.right, y: CANONICAL_ROW_Y_PERCENTAGES[3] },\n [sphereId(\"Geburah\")]: { x: CANONICAL_X_PERCENTAGES.left, y: CANONICAL_ROW_Y_PERCENTAGES[3] },\n [sphereId(\"Tiphareth\")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[4] },\n [sphereId(\"Netzach\")]: { x: CANONICAL_X_PERCENTAGES.right, y: CANONICAL_ROW_Y_PERCENTAGES[5] },\n [sphereId(\"Hod\")]: { x: CANONICAL_X_PERCENTAGES.left, y: CANONICAL_ROW_Y_PERCENTAGES[5] },\n [sphereId(\"Yesod\")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[6] },\n [sphereId(\"Malkuth\")]: { x: CANONICAL_X_PERCENTAGES.mid, y: CANONICAL_ROW_Y_PERCENTAGES[7] },\n} as Record<TreeSphereId, TreeLayoutCoordinate>;\n\ninterface ResolvedPalette {\n mode: \"color\" | \"monochrome\" | \"custom\";\n defaultSphereFill: string;\n defaultPathColor: string;\n sphereFills: Partial<Record<TreeSphereId, string | string[]>>;\n pathColors: Partial<Record<TreePathId, string>>;\n pathEdgeColor: string;\n pathEdgeUseFilter: boolean;\n sphereStrokeColor?: string;\n sphereStrokeWidth?: number;\n pathHighlightColor: string;\n pathHighlightOpacity: number;\n specialSphereMode: \"preserve\" | \"plain\";\n}\n\ninterface ResolvedHighlights {\n pathColors: Partial<Record<TreePathId, string>>;\n sphereFills: Partial<Record<TreeSphereId, string | string[]>>;\n}\n\nexport function getTreeLayout(system: SystemKey = \"kaabalah\"): TreeLayout {\n const tree = createTree({ system });\n const percentages = buildLayoutMap(tree, CANONICAL_SPHERE_PERCENTAGES);\n const viewBoxUnits = buildLayoutMap(\n tree,\n scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, TREE_SVG_DEFAULT_VIEWBOX)\n );\n\n return {\n system,\n viewBox: { ...TREE_SVG_DEFAULT_VIEWBOX },\n sphereOrder: [...TREE_SPHERE_IDS],\n pathOrder: [...TREE_PATH_IDS],\n percentages,\n viewBoxUnits,\n };\n}\n\nexport function generateTreeSvg(options: TreeSvgOptions = {}): string {\n const system = options.system ?? \"kaabalah\";\n const daathLayer = options.daathLayer ?? \"front\";\n const tree = createTree({ system, parts: [\"colors\"] });\n const viewBox = normalizeViewBox(options.viewBox);\n const palette = resolvePalette(options.palette);\n const highlights = resolveHighlights(options.highlights);\n const spherePositions = scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, viewBox);\n const layout = buildLayoutMap(tree, spherePositions);\n const scale = Math.min(\n viewBox.width / TREE_SVG_DEFAULT_VIEWBOX.width,\n viewBox.height / TREE_SVG_DEFAULT_VIEWBOX.height\n );\n\n const radius = round(DEFAULT_SPHERE_RADIUS * scale);\n const pathEdgeWidth = round(DEFAULT_PATH_EDGE_WIDTH * scale);\n const pathMainWidth = round(DEFAULT_PATH_MAIN_WIDTH * scale);\n const pathHighlightWidth = round(DEFAULT_PATH_HIGHLIGHT_WIDTH * scale);\n const sphereStrokeWidth = palette.sphereStrokeWidth\n ? round(palette.sphereStrokeWidth * scale)\n : undefined;\n\n const lines: string[] = [];\n const push = (line: string) => lines.push(line);\n const svgAttributes = [\n `xmlns=\"http://www.w3.org/2000/svg\"`,\n options.width !== undefined ? `width=\"${escapeAttr(String(options.width))}\"` : \"\",\n options.height !== undefined ? `height=\"${escapeAttr(String(options.height))}\"` : \"\",\n `viewBox=\"${viewBox.minX} ${viewBox.minY} ${viewBox.width} ${viewBox.height}\"`,\n `preserveAspectRatio=\"xMidYMid meet\"`,\n ].filter(Boolean);\n\n push(`<svg ${svgAttributes.join(\" \")}>`);\n push(`<defs>`);\n push(`<filter id=\"pathDarken\">\n <feComponentTransfer>\n <feFuncR type=\"linear\" slope=\"0.65\"/>\n <feFuncG type=\"linear\" slope=\"0.65\"/>\n <feFuncB type=\"linear\" slope=\"0.65\"/>\n </feComponentTransfer>\n</filter>`);\n\n for (const sphereName of TREE_SPHERE_NAMES) {\n const currentSphereId = sphereId(sphereName);\n const slug = sphereName.toLowerCase();\n const point = spherePositions[currentSphereId];\n if (!point) {\n continue;\n }\n\n push(`<radialGradient id=\"spec-${slug}\" cx=\"30%\" cy=\"25%\" r=\"55%\" fx=\"30%\" fy=\"25%\">\n <stop offset=\"0%\" stop-color=\"white\" stop-opacity=\"0.95\"/>\n <stop offset=\"25%\" stop-color=\"white\" stop-opacity=\"0.45\"/>\n <stop offset=\"50%\" stop-color=\"white\" stop-opacity=\"0.08\"/>\n <stop offset=\"100%\" stop-color=\"white\" stop-opacity=\"0\"/>\n</radialGradient>`);\n\n push(`<radialGradient id=\"shad-${slug}\" cx=\"78%\" cy=\"80%\" r=\"55%\" fx=\"78%\" fy=\"80%\">\n <stop offset=\"0%\" stop-color=\"black\" stop-opacity=\"0.32\"/>\n <stop offset=\"40%\" stop-color=\"black\" stop-opacity=\"0.12\"/>\n <stop offset=\"100%\" stop-color=\"black\" stop-opacity=\"0\"/>\n</radialGradient>`);\n\n push(\n `<clipPath id=\"clip-${slug}\"><circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${radius}\"/></clipPath>`\n );\n }\n\n push(`<radialGradient id=\"kether-glow\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n <stop offset=\"0%\" stop-color=\"white\" stop-opacity=\"0.95\"/>\n <stop offset=\"45%\" stop-color=\"white\" stop-opacity=\"0.6\"/>\n <stop offset=\"80%\" stop-color=\"white\" stop-opacity=\"0.15\"/>\n <stop offset=\"100%\" stop-color=\"white\" stop-opacity=\"0\"/>\n</radialGradient>`);\n\n push(`<linearGradient id=\"kether-facet\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0%\" stop-color=\"white\" stop-opacity=\"0.9\"/>\n <stop offset=\"50%\" stop-color=\"white\" stop-opacity=\"0.5\"/>\n <stop offset=\"100%\" stop-color=\"white\" stop-opacity=\"0.1\"/>\n</linearGradient>`);\n\n push(`<radialGradient id=\"kether-rim\" cx=\"50%\" cy=\"50%\" r=\"75%\">\n <stop offset=\"60%\" stop-color=\"black\" stop-opacity=\"0\"/>\n <stop offset=\"100%\" stop-color=\"black\" stop-opacity=\"0.18\"/>\n</radialGradient>`);\n push(`</defs>`);\n\n const background = options.background ?? \"white\";\n if (background !== \"transparent\") {\n push(\n `<rect x=\"${viewBox.minX}\" y=\"${viewBox.minY}\" width=\"${viewBox.width}\" height=\"${viewBox.height}\" fill=\"${escapeAttr(background)}\"/>`\n );\n }\n\n if (daathLayer === \"back\") {\n push(`<g id=\"spheres-behind-paths\">`);\n renderSphere(push, {\n highlights,\n tree,\n palette,\n radius,\n sphereStrokeWidth,\n spherePositions,\n sphereName: \"Daath\",\n });\n push(`</g>`);\n }\n\n push(`<g id=\"paths\">`);\n for (const currentPathId of TREE_PATH_IDS) {\n const path = layout.paths[currentPathId];\n const color = resolvePathColor({\n highlights,\n palette,\n tree,\n pathId: currentPathId,\n });\n const edgeColor = resolvePathEdgeColor({\n palette,\n pathColor: color,\n });\n\n push(\n `<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)\"` : \"\"}/>`\n );\n push(\n `<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\"/>`\n );\n push(\n `<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\"/>`\n );\n }\n push(`</g>`);\n\n const frontSphereNames =\n daathLayer === \"back\"\n ? TREE_SPHERE_NAMES.filter((name): name is Exclude<TreeSphereName, \"Daath\"> => name !== \"Daath\")\n : TREE_SPHERE_NAMES;\n\n push(`<g id=\"spheres\">`);\n for (const sphereName of frontSphereNames) {\n renderSphere(push, {\n highlights,\n tree,\n palette,\n radius,\n sphereStrokeWidth,\n spherePositions,\n sphereName,\n });\n }\n push(`</g>`);\n if (daathLayer === \"back\") {\n const daathPoint = spherePositions[sphereId(\"Daath\")];\n push(\n `<circle id=\"sphere-daath-hit-area\" data-node-id=\"sphere:Daath\" cx=\"${daathPoint.x}\" cy=\"${daathPoint.y}\" r=\"${radius}\" fill=\"transparent\" pointer-events=\"all\"/>`\n );\n }\n push(`</svg>`);\n\n return lines.join(\"\\n\");\n}\n\nfunction renderSphere(\n push: (line: string) => void,\n params: {\n highlights: ResolvedHighlights;\n tree: ReturnType<typeof createTree>;\n palette: ResolvedPalette;\n radius: number;\n sphereStrokeWidth?: number;\n spherePositions: Record<TreeSphereId, TreeLayoutCoordinate>;\n sphereName: TreeSphereName;\n }\n) {\n const currentSphereId = sphereId(params.sphereName);\n const point = params.spherePositions[currentSphereId];\n const slug = params.sphereName.toLowerCase();\n const colorData =\n params.tree.relatedFirst(currentSphereId, MiscTypes.COLOR)?.data?.colorHexCodes ?? [];\n const sphereFill = resolveSphereFill({\n palette: params.palette,\n sphereId: currentSphereId,\n defaultColors: colorData,\n });\n const highlightFill = params.highlights.sphereFills[currentSphereId];\n const activeFill = highlightFill ?? sphereFill;\n\n push(`<g id=\"sphere-${slug}\" clip-path=\"url(#clip-${slug})\">`);\n if (params.palette.specialSphereMode === \"preserve\") {\n if (params.sphereName === \"Kether\") {\n renderKether(\n push,\n point,\n params.radius,\n highlightFill ? toPrimaryFill(highlightFill, \"#e0e0e0\") : undefined\n );\n } else if (params.sphereName === \"Chokhmah\") {\n renderIridescent(push, point, params.radius);\n if (highlightFill) {\n renderSphereTintOverlay(push, point, params.radius, highlightFill, 0.62);\n }\n } else if (params.sphereName === \"Daath\") {\n renderYinYang(push, point, params.radius, highlightFill);\n } else if (params.sphereName === \"Malkuth\" && colorData.length >= 4) {\n const slicedColors = resolveMalkuthColors({\n highlightFill,\n paletteFill: sphereFill,\n defaultColors: colorData.slice(0, 4),\n });\n renderSlicedSphere(push, point, params.radius, slicedColors, -135);\n } else {\n push(\n `<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${params.radius}\" fill=\"${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}\"/>`\n );\n }\n } else {\n push(\n `<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${params.radius}\" fill=\"${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}\"/>`\n );\n }\n\n push(\n `<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${params.radius}\" fill=\"url(#spec-${slug})\"/>`\n );\n if (\n params.palette.specialSphereMode !== \"preserve\" ||\n (params.sphereName !== \"Kether\" && params.sphereName !== \"Chokhmah\")\n ) {\n push(\n `<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${params.radius}\" fill=\"url(#shad-${slug})\"/>`\n );\n }\n push(`</g>`);\n if (params.palette.sphereStrokeColor && params.sphereStrokeWidth) {\n push(\n `<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${params.radius}\" fill=\"none\" stroke=\"${escapeAttr(params.palette.sphereStrokeColor)}\" stroke-width=\"${params.sphereStrokeWidth}\"/>`\n );\n }\n}\n\nfunction buildLayoutMap(\n tree: ReturnType<typeof createTree>,\n spherePositions: Record<TreeSphereId, TreeLayoutCoordinate>\n): TreeLayoutMap {\n const paths = {} as Record<TreePathId, TreeLayoutPath>;\n\n for (const currentPathId of TREE_PATH_IDS) {\n const path = tree.getNode(currentPathId);\n const fromId = path?.data?.from as TreeSphereId | undefined;\n const toId = path?.data?.to as TreeSphereId | undefined;\n\n if (!fromId || !toId) {\n throw new Error(`Tree path ${currentPathId} is missing endpoints.`);\n }\n\n const from = spherePositions[fromId];\n const to = spherePositions[toId];\n\n if (!from || !to) {\n throw new Error(\n `Tree path ${currentPathId} references unknown layout spheres: ${fromId}, ${toId}.`\n );\n }\n\n paths[currentPathId] = {\n fromId,\n toId,\n from: { ...from },\n to: { ...to },\n };\n }\n\n return {\n spheres: cloneCoordinateMap(spherePositions),\n paths,\n };\n}\n\nfunction cloneCoordinateMap(\n coordinates: Record<TreeSphereId, TreeLayoutCoordinate>\n): Record<TreeSphereId, TreeLayoutCoordinate> {\n const clone = {} as Record<TreeSphereId, TreeLayoutCoordinate>;\n for (const currentSphereId of TREE_SPHERE_IDS) {\n const point = coordinates[currentSphereId];\n clone[currentSphereId] = { ...point };\n }\n return clone;\n}\n\nfunction scaleCoordinates(\n coordinates: Record<TreeSphereId, TreeLayoutCoordinate>,\n viewBox: Required<TreeSvgViewBox>\n): Record<TreeSphereId, TreeLayoutCoordinate> {\n const scaled = {} as Record<TreeSphereId, TreeLayoutCoordinate>;\n\n for (const currentSphereId of TREE_SPHERE_IDS) {\n const point = coordinates[currentSphereId];\n scaled[currentSphereId] = {\n x: round(viewBox.minX + (point.x / 100) * viewBox.width),\n y: round(viewBox.minY + (point.y / 100) * viewBox.height),\n };\n }\n\n return scaled;\n}\n\nfunction normalizeViewBox(\n viewBox: TreeSvgViewBox | undefined\n): Required<TreeSvgViewBox> {\n return {\n minX: viewBox?.minX ?? TREE_SVG_DEFAULT_VIEWBOX.minX,\n minY: viewBox?.minY ?? TREE_SVG_DEFAULT_VIEWBOX.minY,\n width: viewBox?.width ?? TREE_SVG_DEFAULT_VIEWBOX.width,\n height: viewBox?.height ?? TREE_SVG_DEFAULT_VIEWBOX.height,\n };\n}\n\nfunction resolvePalette(palette: TreeSvgPalette | undefined): ResolvedPalette {\n if (palette === undefined || palette === \"color\") {\n return {\n mode: \"color\",\n defaultSphereFill: \"#888888\",\n defaultPathColor: \"#888888\",\n sphereFills: {},\n pathColors: {},\n pathEdgeColor: \"#888888\",\n pathEdgeUseFilter: true,\n pathHighlightColor: \"white\",\n pathHighlightOpacity: 0.25,\n specialSphereMode: \"preserve\",\n };\n }\n\n if (palette === \"monochrome\") {\n return {\n mode: \"monochrome\",\n defaultSphereFill: \"#e6ddd0\",\n defaultPathColor: \"#e0d7ca\",\n sphereFills: {},\n pathColors: {},\n pathEdgeColor: \"#2f271e\",\n pathEdgeUseFilter: false,\n sphereStrokeColor: \"#2f271e\",\n sphereStrokeWidth: 2.4,\n pathHighlightColor: \"white\",\n pathHighlightOpacity: 0.2,\n specialSphereMode: \"plain\",\n };\n }\n\n return {\n mode: \"custom\",\n defaultSphereFill: palette.defaultSphereFill ?? \"#111111\",\n defaultPathColor: palette.defaultPathColor ?? \"#111111\",\n sphereFills: palette.sphereFills ?? {},\n pathColors: palette.pathColors ?? {},\n pathEdgeColor: palette.pathEdgeColor ?? (palette.defaultPathColor ?? \"#111111\"),\n pathEdgeUseFilter: false,\n sphereStrokeColor: palette.sphereStrokeColor,\n sphereStrokeWidth: palette.sphereStrokeWidth,\n pathHighlightColor: palette.pathHighlightColor ?? \"white\",\n pathHighlightOpacity: palette.pathHighlightOpacity ?? 0.18,\n specialSphereMode: palette.specialSphereMode ?? \"plain\",\n };\n}\n\nfunction resolveHighlights(\n highlights: TreeSvgHighlights | undefined\n): ResolvedHighlights {\n return {\n pathColors: highlights?.paths ?? {},\n sphereFills: highlights?.spheres ?? {},\n };\n}\n\nfunction resolvePathColor(params: {\n highlights: ResolvedHighlights;\n palette: ResolvedPalette;\n tree: ReturnType<typeof createTree>;\n pathId: TreePathId;\n}) {\n const highlightOverride = params.highlights.pathColors[params.pathId];\n if (highlightOverride) {\n return highlightOverride;\n }\n\n const override = params.palette.pathColors[params.pathId];\n if (override) {\n return override;\n }\n\n if (params.palette.mode === \"monochrome\" || params.palette.mode === \"custom\") {\n return params.palette.defaultPathColor;\n }\n\n const treeColor =\n params.tree.relatedFirst(params.pathId, MiscTypes.COLOR)?.data?.colorHexCodes?.[0];\n\n return treeColor ?? params.palette.defaultPathColor;\n}\n\nfunction resolvePathEdgeColor(params: {\n palette: ResolvedPalette;\n pathColor: string;\n}) {\n if (params.palette.mode === \"color\") {\n return params.pathColor;\n }\n\n return params.palette.pathEdgeColor;\n}\n\nfunction resolveSphereFill(params: {\n palette: ResolvedPalette;\n sphereId: TreeSphereId;\n defaultColors: string[];\n}) {\n const override = params.palette.sphereFills[params.sphereId];\n if (override) {\n return override;\n }\n\n if (params.palette.mode === \"monochrome\" || params.palette.mode === \"custom\") {\n return params.palette.defaultSphereFill;\n }\n\n if (params.defaultColors.length > 0) {\n return params.defaultColors;\n }\n\n return params.palette.defaultSphereFill;\n}\n\nfunction toPrimaryFill(fill: string | string[], fallback: string) {\n if (Array.isArray(fill)) {\n return fill[0] ?? fallback;\n }\n\n return fill;\n}\n\nfunction resolveMalkuthColors(params: {\n highlightFill?: string | string[];\n paletteFill: string | string[];\n defaultColors: string[];\n}) {\n if (params.highlightFill) {\n return expandColors(\n params.highlightFill,\n params.defaultColors.length,\n params.defaultColors\n );\n }\n\n if (Array.isArray(params.paletteFill)) {\n return expandColors(\n params.paletteFill,\n params.defaultColors.length,\n params.defaultColors\n );\n }\n\n return params.defaultColors;\n}\n\nfunction expandColors(\n fill: string | string[],\n count: number,\n fallbackColors: string[]\n) {\n if (Array.isArray(fill)) {\n if (fill.length === 0) {\n return fallbackColors.slice(0, count);\n }\n\n return Array.from({ length: count }, (_, index) => {\n return fill[index] ?? fill[fill.length - 1];\n });\n }\n\n return Array.from({ length: count }, () => fill);\n}\n\nfunction round(value: number) {\n return Math.round(value * 100) / 100;\n}\n\nfunction polarToCartesian(\n cx: number,\n cy: number,\n radius: number,\n degrees: number\n) {\n const radians = (Math.PI / 180) * degrees;\n return {\n x: round(cx + radius * Math.cos(radians)),\n y: round(cy + radius * Math.sin(radians)),\n };\n}\n\nfunction arcPath(\n cx: number,\n cy: number,\n radius: number,\n startDegrees: number,\n endDegrees: number\n) {\n const start = polarToCartesian(cx, cy, radius, startDegrees);\n const end = polarToCartesian(cx, cy, radius, endDegrees);\n const largeArc = endDegrees - startDegrees <= 180 ? 0 : 1;\n return `M ${cx} ${cy} L ${start.x} ${start.y} A ${radius} ${radius} 0 ${largeArc} 1 ${end.x} ${end.y} Z`;\n}\n\nfunction renderKether(\n push: (line: string) => void,\n point: TreeLayoutCoordinate,\n radius: number,\n baseFill = \"#e0e0e0\"\n) {\n push(\n `<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${radius}\" fill=\"${escapeAttr(baseFill)}\"/>`\n );\n push(`<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${radius}\" fill=\"url(#kether-glow)\"/>`);\n\n const spokes = 16;\n const innerRadius = round(radius * 0.18);\n const outerRadius = round(radius * 0.92);\n const innerWidth = round(radius * 0.04);\n const angleStep = 360 / spokes;\n\n push(`<g opacity=\"0.85\">`);\n for (let index = 0; index < spokes; index++) {\n const angle = index * angleStep;\n push(`<g transform=\"rotate(${angle} ${point.x} ${point.y})\">`);\n const x0 = round(point.x - innerWidth);\n const y0 = round(point.y - innerRadius);\n const x1 = point.x;\n const y1 = round(point.y - outerRadius);\n const x2 = round(point.x + innerWidth);\n const y2 = round(point.y - innerRadius);\n push(\n `<polygon points=\"${x0},${y0} ${x1},${y1} ${x2},${y2} ${point.x},${point.y}\" fill=\"url(#kether-facet)\"/>`\n );\n push(`</g>`);\n }\n push(`</g>`);\n push(`<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${radius}\" fill=\"url(#kether-rim)\"/>`);\n}\n\nfunction renderSlicedSphere(\n push: (line: string) => void,\n point: TreeLayoutCoordinate,\n radius: number,\n colors: string[],\n startAngle: number\n) {\n const segmentCount = colors.length;\n const step = 360 / segmentCount;\n let currentAngle = startAngle;\n\n for (let index = 0; index < segmentCount; index++) {\n const path = arcPath(point.x, point.y, radius * 0.96, currentAngle, currentAngle + step);\n push(`<path d=\"${path}\" fill=\"${escapeAttr(colors[index])}\" stroke=\"none\"/>`);\n currentAngle += step;\n }\n}\n\nfunction renderIridescent(\n push: (line: string) => void,\n point: TreeLayoutCoordinate,\n radius: number\n) {\n const stops: [number, string][] = [\n [0.0, \"#F0E8EE\"],\n [0.1, \"#ffa3e6\"],\n [0.22, \"#a7e0ff\"],\n [0.34, \"#baff9a\"],\n [0.46, \"#ffe28a\"],\n [0.58, \"#c6a4ff\"],\n [0.7, \"#9ad6ff\"],\n [0.82, \"#ffa3e6\"],\n [1.0, \"#F0E8EE\"],\n ];\n\n const slices = 72;\n const sphereRadius = round(radius * 0.96);\n\n for (let index = 0; index < slices; index++) {\n const t = index / slices;\n const color = interpolateColorStops(stops, t);\n const startDegrees = t * 360 - 90;\n const endDegrees = startDegrees + 360 / slices + 0.5;\n const path = arcPath(point.x, point.y, sphereRadius, startDegrees, endDegrees);\n push(`<path d=\"${path}\" fill=\"${color}\" stroke=\"none\"/>`);\n }\n}\n\nfunction interpolateColorStops(stops: [number, string][], t: number): string {\n let lower = stops[0];\n let upper = stops[stops.length - 1];\n\n for (let index = 0; index < stops.length - 1; index++) {\n if (t >= stops[index][0] && t <= stops[index + 1][0]) {\n lower = stops[index];\n upper = stops[index + 1];\n break;\n }\n }\n\n const range = upper[0] - lower[0] || 1;\n return interpolateColor(lower[1], upper[1], (t - lower[0]) / range);\n}\n\nfunction interpolateColor(start: string, end: string, factor: number) {\n const parse = (hex: string) => {\n const match = hex.match(/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);\n return match\n ? [\n Number.parseInt(match[1], 16),\n Number.parseInt(match[2], 16),\n Number.parseInt(match[3], 16),\n ]\n : [0, 0, 0];\n };\n\n const [r1, g1, b1] = parse(start);\n const [r2, g2, b2] = parse(end);\n const mix = (left: number, right: number) =>\n Math.round(left + (right - left) * factor);\n\n return `#${mix(r1, r2).toString(16).padStart(2, \"0\")}${mix(g1, g2)\n .toString(16)\n .padStart(2, \"0\")}${mix(b1, b2).toString(16).padStart(2, \"0\")}`;\n}\n\nfunction renderYinYang(\n push: (line: string) => void,\n point: TreeLayoutCoordinate,\n radius: number,\n fill?: string | string[]\n) {\n const scale = radius / 50;\n const circleRadius = round(48 * scale);\n const halfRadius = round(24 * scale);\n const dotRadius = round(6 * scale);\n const [lightFill, darkFill] = resolveDualToneFill(fill);\n\n push(`<g transform=\"rotate(180 ${point.x} ${point.y})\">`);\n push(\n `<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${circleRadius}\" fill=\"${escapeAttr(lightFill)}\"/>`\n );\n push(\n `<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)}\"/>`\n );\n push(\n `<circle cx=\"${point.x}\" cy=\"${round(point.y - halfRadius)}\" r=\"${dotRadius}\" fill=\"${escapeAttr(lightFill)}\"/>`\n );\n push(\n `<circle cx=\"${point.x}\" cy=\"${round(point.y + halfRadius)}\" r=\"${dotRadius}\" fill=\"${escapeAttr(darkFill)}\"/>`\n );\n push(`</g>`);\n}\n\nfunction renderSphereTintOverlay(\n push: (line: string) => void,\n point: TreeLayoutCoordinate,\n radius: number,\n fill: string | string[],\n opacity: number\n) {\n push(\n `<circle cx=\"${point.x}\" cy=\"${point.y}\" r=\"${radius}\" fill=\"${escapeAttr(toPrimaryFill(fill, \"#ffffff\"))}\" fill-opacity=\"${opacity}\"/>`\n );\n}\n\nfunction resolveDualToneFill(fill: string | string[] | undefined) {\n if (Array.isArray(fill)) {\n return [fill[0] ?? \"white\", fill[1] ?? \"black\"] as const;\n }\n\n if (fill) {\n return [fill, \"black\"] as const;\n }\n\n return [\"white\", \"black\"] as const;\n}\n\nfunction escapeAttr(value: string) {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\n}\n"]}
@@ -81,6 +81,7 @@ function generateTreeSvg(options = {}) {
81
81
  const tree = chunkS6KNERP7_js.createTree({ system, parts: ["colors"] });
82
82
  const viewBox = normalizeViewBox(options.viewBox);
83
83
  const palette = resolvePalette(options.palette);
84
+ const highlights = resolveHighlights(options.highlights);
84
85
  const spherePositions = scaleCoordinates(CANONICAL_SPHERE_PERCENTAGES, viewBox);
85
86
  const layout = buildLayoutMap(tree, spherePositions);
86
87
  const scale = Math.min(
@@ -157,6 +158,7 @@ function generateTreeSvg(options = {}) {
157
158
  if (daathLayer === "back") {
158
159
  push(`<g id="spheres-behind-paths">`);
159
160
  renderSphere(push, {
161
+ highlights,
160
162
  tree,
161
163
  palette,
162
164
  radius,
@@ -170,12 +172,17 @@ function generateTreeSvg(options = {}) {
170
172
  for (const currentPathId of TREE_PATH_IDS) {
171
173
  const path = layout.paths[currentPathId];
172
174
  const color = resolvePathColor({
175
+ highlights,
173
176
  palette,
174
177
  tree,
175
178
  pathId: currentPathId
176
179
  });
180
+ const edgeColor = resolvePathEdgeColor({
181
+ palette,
182
+ pathColor: color
183
+ });
177
184
  push(
178
- `<line x1="${path.from.x}" y1="${path.from.y}" x2="${path.to.x}" y2="${path.to.y}" stroke="${escapeAttr(palette.pathEdgeColor)}" stroke-width="${pathEdgeWidth}" stroke-linecap="round"${palette.pathEdgeUseFilter ? ` filter="url(#pathDarken)"` : ""}/>`
185
+ `<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)"` : ""}/>`
179
186
  );
180
187
  push(
181
188
  `<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"/>`
@@ -189,6 +196,7 @@ function generateTreeSvg(options = {}) {
189
196
  push(`<g id="spheres">`);
190
197
  for (const sphereName of frontSphereNames) {
191
198
  renderSphere(push, {
199
+ highlights,
192
200
  tree,
193
201
  palette,
194
202
  radius,
@@ -217,25 +225,39 @@ function renderSphere(push, params) {
217
225
  sphereId: currentSphereId,
218
226
  defaultColors: colorData
219
227
  });
228
+ const highlightFill = params.highlights.sphereFills[currentSphereId];
229
+ const activeFill = highlightFill ?? sphereFill;
220
230
  push(`<g id="sphere-${slug}" clip-path="url(#clip-${slug})">`);
221
231
  if (params.palette.specialSphereMode === "preserve") {
222
232
  if (params.sphereName === "Kether") {
223
- renderKether(push, point, params.radius);
233
+ renderKether(
234
+ push,
235
+ point,
236
+ params.radius,
237
+ highlightFill ? toPrimaryFill(highlightFill, "#e0e0e0") : void 0
238
+ );
224
239
  } else if (params.sphereName === "Chokhmah") {
225
240
  renderIridescent(push, point, params.radius);
241
+ if (highlightFill) {
242
+ renderSphereTintOverlay(push, point, params.radius, highlightFill, 0.62);
243
+ }
226
244
  } else if (params.sphereName === "Daath") {
227
- renderYinYang(push, point, params.radius);
245
+ renderYinYang(push, point, params.radius, highlightFill);
228
246
  } else if (params.sphereName === "Malkuth" && colorData.length >= 4) {
229
- const slicedColors = Array.isArray(sphereFill) ? sphereFill : colorData.slice(0, 4);
247
+ const slicedColors = resolveMalkuthColors({
248
+ highlightFill,
249
+ paletteFill: sphereFill,
250
+ defaultColors: colorData.slice(0, 4)
251
+ });
230
252
  renderSlicedSphere(push, point, params.radius, slicedColors, -135);
231
253
  } else {
232
254
  push(
233
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(sphereFill, params.palette.defaultSphereFill))}"/>`
255
+ `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}"/>`
234
256
  );
235
257
  }
236
258
  } else {
237
259
  push(
238
- `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(sphereFill, params.palette.defaultSphereFill))}"/>`
260
+ `<circle cx="${point.x}" cy="${point.y}" r="${params.radius}" fill="${escapeAttr(toPrimaryFill(activeFill, params.palette.defaultSphereFill))}"/>`
239
261
  );
240
262
  }
241
263
  push(
@@ -354,7 +376,17 @@ function resolvePalette(palette) {
354
376
  specialSphereMode: palette.specialSphereMode ?? "plain"
355
377
  };
356
378
  }
379
+ function resolveHighlights(highlights) {
380
+ return {
381
+ pathColors: highlights?.paths ?? {},
382
+ sphereFills: highlights?.spheres ?? {}
383
+ };
384
+ }
357
385
  function resolvePathColor(params) {
386
+ const highlightOverride = params.highlights.pathColors[params.pathId];
387
+ if (highlightOverride) {
388
+ return highlightOverride;
389
+ }
358
390
  const override = params.palette.pathColors[params.pathId];
359
391
  if (override) {
360
392
  return override;
@@ -365,6 +397,12 @@ function resolvePathColor(params) {
365
397
  const treeColor = params.tree.relatedFirst(params.pathId, "color" /* COLOR */)?.data?.colorHexCodes?.[0];
366
398
  return treeColor ?? params.palette.defaultPathColor;
367
399
  }
400
+ function resolvePathEdgeColor(params) {
401
+ if (params.palette.mode === "color") {
402
+ return params.pathColor;
403
+ }
404
+ return params.palette.pathEdgeColor;
405
+ }
368
406
  function resolveSphereFill(params) {
369
407
  const override = params.palette.sphereFills[params.sphereId];
370
408
  if (override) {
@@ -384,6 +422,34 @@ function toPrimaryFill(fill, fallback) {
384
422
  }
385
423
  return fill;
386
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
+ }
387
453
  function round(value) {
388
454
  return Math.round(value * 100) / 100;
389
455
  }
@@ -400,8 +466,10 @@ function arcPath(cx, cy, radius, startDegrees, endDegrees) {
400
466
  const largeArc = endDegrees - startDegrees <= 180 ? 0 : 1;
401
467
  return `M ${cx} ${cy} L ${start.x} ${start.y} A ${radius} ${radius} 0 ${largeArc} 1 ${end.x} ${end.y} Z`;
402
468
  }
403
- function renderKether(push, point, radius) {
404
- push(`<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="#e0e0e0"/>`);
469
+ function renderKether(push, point, radius, baseFill = "#e0e0e0") {
470
+ push(
471
+ `<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="${escapeAttr(baseFill)}"/>`
472
+ );
405
473
  push(`<circle cx="${point.x}" cy="${point.y}" r="${radius}" fill="url(#kether-glow)"/>`);
406
474
  const spokes = 16;
407
475
  const innerRadius = round(radius * 0.18);
@@ -486,24 +554,41 @@ function interpolateColor(start, end, factor) {
486
554
  const mix = (left, right) => Math.round(left + (right - left) * factor);
487
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")}`;
488
556
  }
489
- function renderYinYang(push, point, radius) {
557
+ function renderYinYang(push, point, radius, fill) {
490
558
  const scale = radius / 50;
491
559
  const circleRadius = round(48 * scale);
492
560
  const halfRadius = round(24 * scale);
493
561
  const dotRadius = round(6 * scale);
562
+ const [lightFill, darkFill] = resolveDualToneFill(fill);
494
563
  push(`<g transform="rotate(180 ${point.x} ${point.y})">`);
495
- push(`<circle cx="${point.x}" cy="${point.y}" r="${circleRadius}" fill="white"/>`);
496
564
  push(
497
- `<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="black"/>`
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)}"/>`
498
569
  );
499
570
  push(
500
- `<circle cx="${point.x}" cy="${round(point.y - halfRadius)}" r="${dotRadius}" fill="white"/>`
571
+ `<circle cx="${point.x}" cy="${round(point.y - halfRadius)}" r="${dotRadius}" fill="${escapeAttr(lightFill)}"/>`
501
572
  );
502
573
  push(
503
- `<circle cx="${point.x}" cy="${round(point.y + halfRadius)}" r="${dotRadius}" fill="black"/>`
574
+ `<circle cx="${point.x}" cy="${round(point.y + halfRadius)}" r="${dotRadius}" fill="${escapeAttr(darkFill)}"/>`
504
575
  );
505
576
  push(`</g>`);
506
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
+ }
507
592
  function escapeAttr(value) {
508
593
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
509
594
  }
@@ -514,5 +599,5 @@ exports.TREE_SPHERE_NAMES = TREE_SPHERE_NAMES;
514
599
  exports.TREE_SVG_DEFAULT_VIEWBOX = TREE_SVG_DEFAULT_VIEWBOX;
515
600
  exports.generateTreeSvg = generateTreeSvg;
516
601
  exports.getTreeLayout = getTreeLayout;
517
- //# sourceMappingURL=chunk-WGYXJEG5.js.map
518
- //# sourceMappingURL=chunk-WGYXJEG5.js.map
602
+ //# sourceMappingURL=chunk-LQDSXXIL.js.map
603
+ //# sourceMappingURL=chunk-LQDSXXIL.js.map