refraction almost completed
This commit is contained in:
@@ -3,6 +3,23 @@
|
||||
"use strict";
|
||||
|
||||
const alphabetGematriaUi = window.AlphabetGematriaUi || {};
|
||||
const alphabetKabbalahUi = window.AlphabetKabbalahUi || {};
|
||||
const alphabetReferenceBuilders = window.AlphabetReferenceBuilders || {};
|
||||
const alphabetDetailUi = window.AlphabetDetailUi || {};
|
||||
|
||||
if (
|
||||
typeof alphabetKabbalahUi.buildCubePlacementButton !== "function"
|
||||
|| typeof alphabetKabbalahUi.buildFourWorldLayersFromDataset !== "function"
|
||||
|| typeof alphabetKabbalahUi.createEmptyCubeRefs !== "function"
|
||||
|| typeof alphabetKabbalahUi.getCubePlacementForHebrewLetter !== "function"
|
||||
|| typeof alphabetKabbalahUi.getCubePlacementForPlanet !== "function"
|
||||
|| typeof alphabetKabbalahUi.getCubePlacementForSign !== "function"
|
||||
|| typeof alphabetKabbalahUi.normalizeId !== "function"
|
||||
|| typeof alphabetKabbalahUi.normalizeLetterId !== "function"
|
||||
|| typeof alphabetKabbalahUi.titleCase !== "function"
|
||||
) {
|
||||
throw new Error("AlphabetKabbalahUi module must load before ui-alphabet.js");
|
||||
}
|
||||
|
||||
const state = {
|
||||
initialized: false,
|
||||
@@ -15,7 +32,6 @@
|
||||
},
|
||||
fourWorldLayers: [],
|
||||
monthRefsByHebrewId: new Map(),
|
||||
const alphabetReferenceBuilders = window.AlphabetReferenceBuilders || {};
|
||||
cubeRefs: {
|
||||
hebrewPlacementById: new Map(),
|
||||
signPlacementById: new Map(),
|
||||
@@ -24,7 +40,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
const alphabetDetailUi = window.AlphabetDetailUi || {};
|
||||
// ── Arabic display name table ─────────────────────────────────────────
|
||||
const ARABIC_DISPLAY_NAMES = {
|
||||
alif: "Alif", ba: "Ba", jeem: "Jeem", dal: "Dal", ha: "H\u0101",
|
||||
@@ -437,84 +452,19 @@
|
||||
};
|
||||
|
||||
function normalizeId(value) {
|
||||
return String(value || "").trim().toLowerCase();
|
||||
return alphabetKabbalahUi.normalizeId(value);
|
||||
}
|
||||
|
||||
function normalizeSoulId(value) {
|
||||
return String(value || "")
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z]/g, "");
|
||||
function normalizeLetterId(value) {
|
||||
return alphabetKabbalahUi.normalizeLetterId(value);
|
||||
}
|
||||
|
||||
function titleCase(value) {
|
||||
return alphabetKabbalahUi.titleCase(value);
|
||||
}
|
||||
|
||||
function buildFourWorldLayersFromDataset(magickDataset) {
|
||||
const worlds = magickDataset?.grouped?.kabbalah?.fourWorlds;
|
||||
const souls = magickDataset?.grouped?.kabbalah?.souls;
|
||||
const paths = Array.isArray(magickDataset?.grouped?.kabbalah?.["kabbalah-tree"]?.paths)
|
||||
? magickDataset.grouped.kabbalah["kabbalah-tree"].paths
|
||||
: [];
|
||||
|
||||
if (!worlds || typeof worlds !== "object") {
|
||||
return [];
|
||||
}
|
||||
|
||||
const soulAliases = {
|
||||
chiah: "chaya",
|
||||
chaya: "chaya",
|
||||
neshamah: "neshama",
|
||||
neshama: "neshama",
|
||||
ruach: "ruach",
|
||||
nephesh: "nephesh"
|
||||
};
|
||||
|
||||
const pathByLetterId = new Map();
|
||||
paths.forEach((path) => {
|
||||
const letterId = normalizeLetterId(path?.hebrewLetter?.transliteration || path?.hebrewLetter?.char);
|
||||
const pathNo = Number(path?.pathNumber);
|
||||
if (!letterId || !Number.isFinite(pathNo) || pathByLetterId.has(letterId)) {
|
||||
return;
|
||||
}
|
||||
pathByLetterId.set(letterId, pathNo);
|
||||
});
|
||||
|
||||
const worldOrder = ["atzilut", "briah", "yetzirah", "assiah"];
|
||||
|
||||
return worldOrder
|
||||
.map((worldId) => {
|
||||
const world = worlds?.[worldId];
|
||||
if (!world || typeof world !== "object") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tetragrammaton = world?.tetragrammaton && typeof world.tetragrammaton === "object"
|
||||
? world.tetragrammaton
|
||||
: {};
|
||||
|
||||
const letterId = normalizeLetterId(tetragrammaton?.hebrewLetterId);
|
||||
const rawSoulId = normalizeSoulId(world?.soulId);
|
||||
const soulId = soulAliases[rawSoulId] || rawSoulId;
|
||||
const soul = souls?.[soulId] && typeof souls[soulId] === "object"
|
||||
? souls[soulId]
|
||||
: null;
|
||||
|
||||
const slot = tetragrammaton?.isFinal
|
||||
? `${String(tetragrammaton?.slot || "Heh")} (final)`
|
||||
: String(tetragrammaton?.slot || "");
|
||||
|
||||
return {
|
||||
slot,
|
||||
letterChar: String(tetragrammaton?.letterChar || ""),
|
||||
hebrewLetterId: letterId,
|
||||
world: String(world?.name?.roman || titleCase(worldId)),
|
||||
worldLayer: String(world?.worldLayer?.en || world?.desc?.en || ""),
|
||||
worldDescription: String(world?.worldDescription?.en || ""),
|
||||
soulLayer: String(soul?.name?.roman || titleCase(rawSoulId || soulId)),
|
||||
soulTitle: String(soul?.title?.en || titleCase(soul?.name?.en || "")),
|
||||
soulDescription: String(soul?.desc?.en || ""),
|
||||
pathNumber: pathByLetterId.get(letterId) || null
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
return alphabetKabbalahUi.buildFourWorldLayersFromDataset(magickDataset);
|
||||
}
|
||||
|
||||
function buildMonthReferencesByHebrew(referenceData, alphabets) {
|
||||
@@ -526,12 +476,7 @@
|
||||
}
|
||||
|
||||
function createEmptyCubeRefs() {
|
||||
return {
|
||||
hebrewPlacementById: new Map(),
|
||||
signPlacementById: new Map(),
|
||||
planetPlacementById: new Map(),
|
||||
pathPlacementByNo: new Map()
|
||||
};
|
||||
return alphabetKabbalahUi.createEmptyCubeRefs();
|
||||
}
|
||||
|
||||
function buildCubeReferences(magickDataset) {
|
||||
@@ -543,54 +488,19 @@
|
||||
}
|
||||
|
||||
function getCubePlacementForHebrewLetter(hebrewLetterId, pathNo = null) {
|
||||
const normalizedLetterId = normalizeId(hebrewLetterId);
|
||||
if (normalizedLetterId && state.cubeRefs.hebrewPlacementById.has(normalizedLetterId)) {
|
||||
return state.cubeRefs.hebrewPlacementById.get(normalizedLetterId);
|
||||
}
|
||||
|
||||
const numericPath = Number(pathNo);
|
||||
if (Number.isFinite(numericPath) && state.cubeRefs.pathPlacementByNo.has(numericPath)) {
|
||||
return state.cubeRefs.pathPlacementByNo.get(numericPath);
|
||||
}
|
||||
|
||||
return null;
|
||||
return alphabetKabbalahUi.getCubePlacementForHebrewLetter(state.cubeRefs, hebrewLetterId, pathNo);
|
||||
}
|
||||
|
||||
function getCubePlacementForPlanet(planetId) {
|
||||
const normalizedPlanetId = normalizeId(planetId);
|
||||
return normalizedPlanetId ? state.cubeRefs.planetPlacementById.get(normalizedPlanetId) || null : null;
|
||||
return alphabetKabbalahUi.getCubePlacementForPlanet(state.cubeRefs, planetId);
|
||||
}
|
||||
|
||||
function getCubePlacementForSign(signId) {
|
||||
const normalizedSignId = normalizeId(signId);
|
||||
return normalizedSignId ? state.cubeRefs.signPlacementById.get(normalizedSignId) || null : null;
|
||||
}
|
||||
|
||||
function cubePlacementLabel(placement) {
|
||||
const wallName = placement?.wallName || "Wall";
|
||||
const edgeName = placement?.edgeName || "Direction";
|
||||
return `Cube: ${wallName} Wall - ${edgeName}`;
|
||||
return alphabetKabbalahUi.getCubePlacementForSign(state.cubeRefs, signId);
|
||||
}
|
||||
|
||||
function cubePlacementBtn(placement, fallbackDetail = null) {
|
||||
if (!placement) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const detail = {
|
||||
"wall-id": placement.wallId,
|
||||
"edge-id": placement.edgeId
|
||||
};
|
||||
|
||||
if (fallbackDetail && typeof fallbackDetail === "object") {
|
||||
Object.entries(fallbackDetail).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null && value !== "") {
|
||||
detail[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return navBtn(cubePlacementLabel(placement), "nav:cube", detail);
|
||||
return alphabetKabbalahUi.buildCubePlacementButton(placement, navBtn, fallbackDetail);
|
||||
}
|
||||
|
||||
function cap(s) { return s ? s.charAt(0).toUpperCase() + s.slice(1) : ""; }
|
||||
|
||||
Reference in New Issue
Block a user