kaabalah 5.6.0 → 6.1.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 +72 -0
- package/dist/astrology/index.d.mts +16 -1
- package/dist/astrology/index.d.ts +16 -1
- package/dist/astrology/index.js +55 -51
- package/dist/astrology/index.mjs +1 -1
- package/dist/{chunk-HGEWHDIX.js → chunk-3JSPGVX3.js} +176 -10
- package/dist/chunk-3JSPGVX3.js.map +1 -0
- package/dist/{chunk-3SFBJHP2.mjs → chunk-G76K6OVQ.mjs} +3 -3
- package/dist/{chunk-3SFBJHP2.mjs.map → chunk-G76K6OVQ.mjs.map} +1 -1
- package/dist/{chunk-U3JFWP24.mjs → chunk-GJB3CZPN.mjs} +1080 -5
- package/dist/chunk-GJB3CZPN.mjs.map +1 -0
- package/dist/{chunk-3HYK4Q4B.js → chunk-HAMDOCS5.js} +273 -2
- package/dist/chunk-HAMDOCS5.js.map +1 -0
- package/dist/chunk-JL7CWPRG.js +850 -0
- package/dist/chunk-JL7CWPRG.js.map +1 -0
- package/dist/chunk-L6M533N6.mjs +843 -0
- package/dist/chunk-L6M533N6.mjs.map +1 -0
- package/dist/{chunk-4NMXTZX4.mjs → chunk-NBP75BAH.mjs} +3 -3
- package/dist/{chunk-4NMXTZX4.mjs.map → chunk-NBP75BAH.mjs.map} +1 -1
- package/dist/{chunk-OGWTKRJK.js → chunk-NPCXF6RV.js} +1089 -10
- package/dist/chunk-NPCXF6RV.js.map +1 -0
- package/dist/{chunk-EVQ432JA.js → chunk-O3ZBG566.js} +23 -23
- package/dist/{chunk-EVQ432JA.js.map → chunk-O3ZBG566.js.map} +1 -1
- package/dist/{chunk-IHQPXEB7.mjs → chunk-RZBVUDBM.mjs} +273 -2
- package/dist/chunk-RZBVUDBM.mjs.map +1 -0
- package/dist/{chunk-S6BFRUJQ.mjs → chunk-S4EJ3ZY7.mjs} +3 -3
- package/dist/{chunk-S6BFRUJQ.mjs.map → chunk-S4EJ3ZY7.mjs.map} +1 -1
- package/dist/{chunk-XB6PXEKO.js → chunk-TMN4PYVG.js} +9 -9
- package/dist/{chunk-XB6PXEKO.js.map → chunk-TMN4PYVG.js.map} +1 -1
- package/dist/{chunk-T6Y4DLMA.mjs → chunk-TZJU6SRX.mjs} +176 -11
- package/dist/chunk-TZJU6SRX.mjs.map +1 -0
- package/dist/{chunk-XTVGQXCL.js → chunk-Y4PTMABP.js} +4 -4
- package/dist/{chunk-XTVGQXCL.js.map → chunk-Y4PTMABP.js.map} +1 -1
- package/dist/cli.js +1213 -52
- package/dist/cli.js.map +1 -1
- package/dist/{constants-DbFwuCjR.d.mts → constants-C0XjrYIG.d.mts} +2 -0
- package/dist/{constants-DbFwuCjR.d.ts → constants-C0XjrYIG.d.ts} +2 -0
- package/dist/core/index.d.mts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +43 -43
- package/dist/core/index.mjs +2 -2
- package/dist/{correspondence-model-D8c42J4c.d.mts → correspondence-model-BrtIu5tW.d.mts} +1 -1
- package/dist/{correspondence-model-DhmBYoMf.d.ts → correspondence-model-CpFOWeBr.d.ts} +1 -1
- package/dist/gematria/index.d.mts +2 -2
- package/dist/gematria/index.d.ts +2 -2
- package/dist/gematria/index.js +5 -5
- package/dist/gematria/index.mjs +2 -2
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +169 -124
- package/dist/index.mjs +7 -6
- package/dist/numerology/index.js +18 -18
- package/dist/numerology/index.mjs +3 -3
- package/dist/semantic/index.d.mts +83 -0
- package/dist/semantic/index.d.ts +83 -0
- package/dist/semantic/index.js +36 -0
- package/dist/semantic/index.js.map +1 -0
- package/dist/semantic/index.mjs +7 -0
- package/dist/semantic/index.mjs.map +1 -0
- package/dist/tarot/index.d.mts +95 -2
- package/dist/tarot/index.d.ts +95 -2
- package/dist/tarot/index.js +28 -12
- package/dist/tarot/index.mjs +3 -3
- package/package.json +6 -1
- package/dist/chunk-3HYK4Q4B.js.map +0 -1
- package/dist/chunk-HGEWHDIX.js.map +0 -1
- package/dist/chunk-IHQPXEB7.mjs.map +0 -1
- package/dist/chunk-OGWTKRJK.js.map +0 -1
- package/dist/chunk-T6Y4DLMA.mjs.map +0 -1
- package/dist/chunk-U3JFWP24.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkTMN4PYVG_js = require('./chunk-TMN4PYVG.js');
|
|
4
|
+
var chunkHAMDOCS5_js = require('./chunk-HAMDOCS5.js');
|
|
5
5
|
|
|
6
6
|
// src/tarot/index.ts
|
|
7
7
|
var majorArcana = [
|
|
@@ -919,7 +919,7 @@ function toAstrologyCorrespondence(node) {
|
|
|
919
919
|
return {
|
|
920
920
|
type: node.type,
|
|
921
921
|
id: node.id,
|
|
922
|
-
label:
|
|
922
|
+
label: chunkHAMDOCS5_js.parseId(node.id)
|
|
923
923
|
};
|
|
924
924
|
}
|
|
925
925
|
function buildDescriptionsByDeck(tarotArkAnnu) {
|
|
@@ -940,12 +940,12 @@ function getTarotArchetypeCache() {
|
|
|
940
940
|
if (tarotArchetypeCache) {
|
|
941
941
|
return tarotArchetypeCache;
|
|
942
942
|
}
|
|
943
|
-
const tree =
|
|
943
|
+
const tree = chunkTMN4PYVG_js.getCanonicalTree({
|
|
944
944
|
system: "kaabalah",
|
|
945
945
|
parts: ["westernAstrology", "tarot"]
|
|
946
946
|
});
|
|
947
947
|
const archetypes = MAJOR_ARCANA_CARDS.map((card) => {
|
|
948
|
-
const pathId =
|
|
948
|
+
const pathId = chunkHAMDOCS5_js.id("path" /* PATH */, card.number);
|
|
949
949
|
const path = tree.getNode(pathId);
|
|
950
950
|
const hebrewLetter = tree.getCorrespondences(pathId, {
|
|
951
951
|
type: "hebrewLetter" /* HEBREW_LETTER */,
|
|
@@ -977,13 +977,13 @@ function getTarotArchetypeCache() {
|
|
|
977
977
|
kind: "major",
|
|
978
978
|
pathId,
|
|
979
979
|
pathNumber: card.number,
|
|
980
|
-
pathSlug:
|
|
980
|
+
pathSlug: chunkHAMDOCS5_js.parseId(hebrewLetter.id).toLowerCase(),
|
|
981
981
|
hebrewLetterId: hebrewLetter.id,
|
|
982
|
-
hebrewLetter:
|
|
982
|
+
hebrewLetter: chunkHAMDOCS5_js.parseId(hebrewLetter.id),
|
|
983
983
|
pathMeaning: path.data?.meaning,
|
|
984
984
|
tarotArkAnnuId: tarotArkAnnu.id,
|
|
985
985
|
tarotCardNumber: card.number,
|
|
986
|
-
tarotCardName:
|
|
986
|
+
tarotCardName: chunkHAMDOCS5_js.parseId(tarotArkAnnu.id),
|
|
987
987
|
tarotCardFilename: card.tarotCardFilename,
|
|
988
988
|
tarotMeaning: descriptionsByDeck.papus_pt?.meaning ?? card.meaning,
|
|
989
989
|
astrology,
|
|
@@ -1057,15 +1057,1094 @@ function getTarotRepresentation(lookup, deckId) {
|
|
|
1057
1057
|
function resolveTarotImageUrl(lookup, deckId) {
|
|
1058
1058
|
return getTarotRepresentation(lookup, deckId)?.imageUrl;
|
|
1059
1059
|
}
|
|
1060
|
+
var TAROT_SPREAD_MINOR_RANKS = [
|
|
1061
|
+
"ace",
|
|
1062
|
+
"2",
|
|
1063
|
+
"3",
|
|
1064
|
+
"4",
|
|
1065
|
+
"5",
|
|
1066
|
+
"6",
|
|
1067
|
+
"7",
|
|
1068
|
+
"8",
|
|
1069
|
+
"9",
|
|
1070
|
+
"10"
|
|
1071
|
+
];
|
|
1072
|
+
var EVENT_INNER_SLOT_KEYS = [
|
|
1073
|
+
"inner-1",
|
|
1074
|
+
"inner-2",
|
|
1075
|
+
"inner-3",
|
|
1076
|
+
"inner-4",
|
|
1077
|
+
"inner-5",
|
|
1078
|
+
"inner-6",
|
|
1079
|
+
"inner-7"
|
|
1080
|
+
];
|
|
1081
|
+
var TAROT_CARD_BY_NUMBER = new Map(
|
|
1082
|
+
ARKANNUS.map((card) => [card.number, card])
|
|
1083
|
+
);
|
|
1084
|
+
function createEventOuterSlot(index, temporalPhase) {
|
|
1085
|
+
return {
|
|
1086
|
+
slotKey: `outer-${index}`,
|
|
1087
|
+
label: String(index),
|
|
1088
|
+
order: index,
|
|
1089
|
+
minCards: 1,
|
|
1090
|
+
maxCards: 1,
|
|
1091
|
+
validationRules: {
|
|
1092
|
+
allowedTypes: ["minor", "daat+royalship"]
|
|
1093
|
+
},
|
|
1094
|
+
manualSelectionRules: {
|
|
1095
|
+
allowedTypes: ["minor", "daat+royalship"]
|
|
1096
|
+
},
|
|
1097
|
+
drawRules: {
|
|
1098
|
+
allowedTypes: ["minor", "daat+royalship"]
|
|
1099
|
+
},
|
|
1100
|
+
metadata: {
|
|
1101
|
+
displayLabel: String(index),
|
|
1102
|
+
groupKey: "outer",
|
|
1103
|
+
temporalPhase
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
function createEventInnerSlot(index, label, note) {
|
|
1108
|
+
return {
|
|
1109
|
+
slotKey: `inner-${index}`,
|
|
1110
|
+
label,
|
|
1111
|
+
order: 100 + index,
|
|
1112
|
+
minCards: 1,
|
|
1113
|
+
maxCards: 1,
|
|
1114
|
+
validationRules: {
|
|
1115
|
+
allowedTypes: ["major"]
|
|
1116
|
+
},
|
|
1117
|
+
manualSelectionRules: {
|
|
1118
|
+
allowedTypes: ["major"],
|
|
1119
|
+
excludedCardFilenames: [
|
|
1120
|
+
"01_the_magician",
|
|
1121
|
+
"02_the_high_priestess"
|
|
1122
|
+
]
|
|
1123
|
+
},
|
|
1124
|
+
drawRules: {
|
|
1125
|
+
allowedTypes: ["major"]
|
|
1126
|
+
},
|
|
1127
|
+
metadata: {
|
|
1128
|
+
displayLabel: `${index}.`,
|
|
1129
|
+
groupKey: "inner",
|
|
1130
|
+
note
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
var TAROT_SPREADS = [
|
|
1135
|
+
{
|
|
1136
|
+
spreadId: "quick-insight",
|
|
1137
|
+
label: "Quick Insight",
|
|
1138
|
+
description: "A single-card reading for immediate insight.",
|
|
1139
|
+
slots: [
|
|
1140
|
+
{
|
|
1141
|
+
slotKey: "quick-insight",
|
|
1142
|
+
label: "Quick Insight",
|
|
1143
|
+
order: 1,
|
|
1144
|
+
minCards: 1,
|
|
1145
|
+
maxCards: 1
|
|
1146
|
+
}
|
|
1147
|
+
]
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
spreadId: "conscious-reading",
|
|
1151
|
+
label: "Conscious Reading",
|
|
1152
|
+
description: "Three-card spread for conscious, unconscious, and subconscious layers.",
|
|
1153
|
+
slots: [
|
|
1154
|
+
{
|
|
1155
|
+
slotKey: "conscious",
|
|
1156
|
+
label: "Conscious",
|
|
1157
|
+
order: 1,
|
|
1158
|
+
minCards: 1,
|
|
1159
|
+
maxCards: 1,
|
|
1160
|
+
validationRules: {
|
|
1161
|
+
allowedTypes: ["major"]
|
|
1162
|
+
},
|
|
1163
|
+
manualSelectionRules: {
|
|
1164
|
+
allowedTypes: ["major"]
|
|
1165
|
+
},
|
|
1166
|
+
drawRules: {
|
|
1167
|
+
allowedTypes: ["major"]
|
|
1168
|
+
}
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
slotKey: "unconscious",
|
|
1172
|
+
label: "Unconscious",
|
|
1173
|
+
order: 2,
|
|
1174
|
+
minCards: 1,
|
|
1175
|
+
maxCards: 1,
|
|
1176
|
+
validationRules: {
|
|
1177
|
+
allowedTypes: ["daat+royalship"]
|
|
1178
|
+
},
|
|
1179
|
+
manualSelectionRules: {
|
|
1180
|
+
allowedTypes: ["daat+royalship"]
|
|
1181
|
+
},
|
|
1182
|
+
drawRules: {
|
|
1183
|
+
allowedTypes: ["daat+royalship"]
|
|
1184
|
+
}
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
slotKey: "subconscious",
|
|
1188
|
+
label: "Subconscious",
|
|
1189
|
+
order: 3,
|
|
1190
|
+
minCards: 1,
|
|
1191
|
+
maxCards: 1,
|
|
1192
|
+
validationRules: {
|
|
1193
|
+
allowedTypes: ["minor"]
|
|
1194
|
+
},
|
|
1195
|
+
manualSelectionRules: {
|
|
1196
|
+
allowedTypes: ["minor"]
|
|
1197
|
+
},
|
|
1198
|
+
drawRules: {
|
|
1199
|
+
allowedTypes: ["minor"]
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
]
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
spreadId: "time-reading",
|
|
1206
|
+
label: "Time Reading",
|
|
1207
|
+
description: "Three major arcana cards for past, present, and future.",
|
|
1208
|
+
slots: [
|
|
1209
|
+
{
|
|
1210
|
+
slotKey: "past",
|
|
1211
|
+
label: "Past",
|
|
1212
|
+
order: 1,
|
|
1213
|
+
minCards: 1,
|
|
1214
|
+
maxCards: 1,
|
|
1215
|
+
validationRules: {
|
|
1216
|
+
allowedTypes: ["major"]
|
|
1217
|
+
},
|
|
1218
|
+
manualSelectionRules: {
|
|
1219
|
+
allowedTypes: ["major"]
|
|
1220
|
+
},
|
|
1221
|
+
drawRules: {
|
|
1222
|
+
allowedTypes: ["major"]
|
|
1223
|
+
}
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
slotKey: "present",
|
|
1227
|
+
label: "Present",
|
|
1228
|
+
order: 2,
|
|
1229
|
+
minCards: 1,
|
|
1230
|
+
maxCards: 1,
|
|
1231
|
+
validationRules: {
|
|
1232
|
+
allowedTypes: ["major"]
|
|
1233
|
+
},
|
|
1234
|
+
manualSelectionRules: {
|
|
1235
|
+
allowedTypes: ["major"]
|
|
1236
|
+
},
|
|
1237
|
+
drawRules: {
|
|
1238
|
+
allowedTypes: ["major"]
|
|
1239
|
+
}
|
|
1240
|
+
},
|
|
1241
|
+
{
|
|
1242
|
+
slotKey: "future",
|
|
1243
|
+
label: "Future",
|
|
1244
|
+
order: 3,
|
|
1245
|
+
minCards: 1,
|
|
1246
|
+
maxCards: 1,
|
|
1247
|
+
validationRules: {
|
|
1248
|
+
allowedTypes: ["major"]
|
|
1249
|
+
},
|
|
1250
|
+
manualSelectionRules: {
|
|
1251
|
+
allowedTypes: ["major"]
|
|
1252
|
+
},
|
|
1253
|
+
drawRules: {
|
|
1254
|
+
allowedTypes: ["major"]
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
]
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
spreadId: "dialectic-reading",
|
|
1261
|
+
label: "Dialectic Reading",
|
|
1262
|
+
description: "Three major arcana cards for thesis, antithesis, and synthesis.",
|
|
1263
|
+
slots: [
|
|
1264
|
+
{
|
|
1265
|
+
slotKey: "thesis",
|
|
1266
|
+
label: "Thesis",
|
|
1267
|
+
order: 1,
|
|
1268
|
+
minCards: 1,
|
|
1269
|
+
maxCards: 1,
|
|
1270
|
+
validationRules: {
|
|
1271
|
+
allowedTypes: ["major"]
|
|
1272
|
+
},
|
|
1273
|
+
manualSelectionRules: {
|
|
1274
|
+
allowedTypes: ["major"]
|
|
1275
|
+
},
|
|
1276
|
+
drawRules: {
|
|
1277
|
+
allowedTypes: ["major"]
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
slotKey: "antithesis",
|
|
1282
|
+
label: "Antithesis",
|
|
1283
|
+
order: 2,
|
|
1284
|
+
minCards: 1,
|
|
1285
|
+
maxCards: 1,
|
|
1286
|
+
validationRules: {
|
|
1287
|
+
allowedTypes: ["major"]
|
|
1288
|
+
},
|
|
1289
|
+
manualSelectionRules: {
|
|
1290
|
+
allowedTypes: ["major"]
|
|
1291
|
+
},
|
|
1292
|
+
drawRules: {
|
|
1293
|
+
allowedTypes: ["major"]
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
slotKey: "synthesis",
|
|
1298
|
+
label: "Synthesis",
|
|
1299
|
+
order: 3,
|
|
1300
|
+
minCards: 1,
|
|
1301
|
+
maxCards: 1,
|
|
1302
|
+
validationRules: {
|
|
1303
|
+
allowedTypes: ["major"]
|
|
1304
|
+
},
|
|
1305
|
+
manualSelectionRules: {
|
|
1306
|
+
allowedTypes: ["major"]
|
|
1307
|
+
},
|
|
1308
|
+
drawRules: {
|
|
1309
|
+
allowedTypes: ["major"]
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
]
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
spreadId: "tree-of-life-reading",
|
|
1316
|
+
label: "Tree of Life Reading",
|
|
1317
|
+
description: "Ten numbered minor arcana slots mapped to the spheres plus four Daath court cards.",
|
|
1318
|
+
slots: [
|
|
1319
|
+
{
|
|
1320
|
+
slotKey: "kether",
|
|
1321
|
+
label: "Kether",
|
|
1322
|
+
order: 1,
|
|
1323
|
+
minCards: 1,
|
|
1324
|
+
maxCards: 1,
|
|
1325
|
+
validationRules: {
|
|
1326
|
+
allowedTypes: ["minor"],
|
|
1327
|
+
requiredRank: "ace"
|
|
1328
|
+
},
|
|
1329
|
+
manualSelectionRules: {
|
|
1330
|
+
allowedTypes: ["minor"],
|
|
1331
|
+
requiredRank: "ace"
|
|
1332
|
+
},
|
|
1333
|
+
drawRules: {
|
|
1334
|
+
allowedTypes: ["minor"],
|
|
1335
|
+
requiredRank: "ace"
|
|
1336
|
+
}
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
slotKey: "chokhmah",
|
|
1340
|
+
label: "Chokhmah",
|
|
1341
|
+
order: 2,
|
|
1342
|
+
minCards: 1,
|
|
1343
|
+
maxCards: 1,
|
|
1344
|
+
validationRules: {
|
|
1345
|
+
allowedTypes: ["minor"],
|
|
1346
|
+
requiredRank: "2"
|
|
1347
|
+
},
|
|
1348
|
+
manualSelectionRules: {
|
|
1349
|
+
allowedTypes: ["minor"],
|
|
1350
|
+
requiredRank: "2"
|
|
1351
|
+
},
|
|
1352
|
+
drawRules: {
|
|
1353
|
+
allowedTypes: ["minor"],
|
|
1354
|
+
requiredRank: "2"
|
|
1355
|
+
}
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
slotKey: "binah",
|
|
1359
|
+
label: "Binah",
|
|
1360
|
+
order: 3,
|
|
1361
|
+
minCards: 1,
|
|
1362
|
+
maxCards: 1,
|
|
1363
|
+
validationRules: {
|
|
1364
|
+
allowedTypes: ["minor"],
|
|
1365
|
+
requiredRank: "3"
|
|
1366
|
+
},
|
|
1367
|
+
manualSelectionRules: {
|
|
1368
|
+
allowedTypes: ["minor"],
|
|
1369
|
+
requiredRank: "3"
|
|
1370
|
+
},
|
|
1371
|
+
drawRules: {
|
|
1372
|
+
allowedTypes: ["minor"],
|
|
1373
|
+
requiredRank: "3"
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
slotKey: "chesed",
|
|
1378
|
+
label: "Chesed",
|
|
1379
|
+
order: 4,
|
|
1380
|
+
minCards: 1,
|
|
1381
|
+
maxCards: 1,
|
|
1382
|
+
validationRules: {
|
|
1383
|
+
allowedTypes: ["minor"],
|
|
1384
|
+
requiredRank: "4"
|
|
1385
|
+
},
|
|
1386
|
+
manualSelectionRules: {
|
|
1387
|
+
allowedTypes: ["minor"],
|
|
1388
|
+
requiredRank: "4"
|
|
1389
|
+
},
|
|
1390
|
+
drawRules: {
|
|
1391
|
+
allowedTypes: ["minor"],
|
|
1392
|
+
requiredRank: "4"
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
slotKey: "geburah",
|
|
1397
|
+
label: "Geburah",
|
|
1398
|
+
order: 5,
|
|
1399
|
+
minCards: 1,
|
|
1400
|
+
maxCards: 1,
|
|
1401
|
+
validationRules: {
|
|
1402
|
+
allowedTypes: ["minor"],
|
|
1403
|
+
requiredRank: "5"
|
|
1404
|
+
},
|
|
1405
|
+
manualSelectionRules: {
|
|
1406
|
+
allowedTypes: ["minor"],
|
|
1407
|
+
requiredRank: "5"
|
|
1408
|
+
},
|
|
1409
|
+
drawRules: {
|
|
1410
|
+
allowedTypes: ["minor"],
|
|
1411
|
+
requiredRank: "5"
|
|
1412
|
+
}
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
slotKey: "tiphareth",
|
|
1416
|
+
label: "Tiphareth",
|
|
1417
|
+
order: 6,
|
|
1418
|
+
minCards: 1,
|
|
1419
|
+
maxCards: 1,
|
|
1420
|
+
validationRules: {
|
|
1421
|
+
allowedTypes: ["minor"],
|
|
1422
|
+
requiredRank: "6"
|
|
1423
|
+
},
|
|
1424
|
+
manualSelectionRules: {
|
|
1425
|
+
allowedTypes: ["minor"],
|
|
1426
|
+
requiredRank: "6"
|
|
1427
|
+
},
|
|
1428
|
+
drawRules: {
|
|
1429
|
+
allowedTypes: ["minor"],
|
|
1430
|
+
requiredRank: "6"
|
|
1431
|
+
}
|
|
1432
|
+
},
|
|
1433
|
+
{
|
|
1434
|
+
slotKey: "netzach",
|
|
1435
|
+
label: "Netzach",
|
|
1436
|
+
order: 7,
|
|
1437
|
+
minCards: 1,
|
|
1438
|
+
maxCards: 1,
|
|
1439
|
+
validationRules: {
|
|
1440
|
+
allowedTypes: ["minor"],
|
|
1441
|
+
requiredRank: "7"
|
|
1442
|
+
},
|
|
1443
|
+
manualSelectionRules: {
|
|
1444
|
+
allowedTypes: ["minor"],
|
|
1445
|
+
requiredRank: "7"
|
|
1446
|
+
},
|
|
1447
|
+
drawRules: {
|
|
1448
|
+
allowedTypes: ["minor"],
|
|
1449
|
+
requiredRank: "7"
|
|
1450
|
+
}
|
|
1451
|
+
},
|
|
1452
|
+
{
|
|
1453
|
+
slotKey: "hod",
|
|
1454
|
+
label: "Hod",
|
|
1455
|
+
order: 8,
|
|
1456
|
+
minCards: 1,
|
|
1457
|
+
maxCards: 1,
|
|
1458
|
+
validationRules: {
|
|
1459
|
+
allowedTypes: ["minor"],
|
|
1460
|
+
requiredRank: "8"
|
|
1461
|
+
},
|
|
1462
|
+
manualSelectionRules: {
|
|
1463
|
+
allowedTypes: ["minor"],
|
|
1464
|
+
requiredRank: "8"
|
|
1465
|
+
},
|
|
1466
|
+
drawRules: {
|
|
1467
|
+
allowedTypes: ["minor"],
|
|
1468
|
+
requiredRank: "8"
|
|
1469
|
+
}
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
slotKey: "yesod",
|
|
1473
|
+
label: "Yesod",
|
|
1474
|
+
order: 9,
|
|
1475
|
+
minCards: 1,
|
|
1476
|
+
maxCards: 1,
|
|
1477
|
+
validationRules: {
|
|
1478
|
+
allowedTypes: ["minor"],
|
|
1479
|
+
requiredRank: "9"
|
|
1480
|
+
},
|
|
1481
|
+
manualSelectionRules: {
|
|
1482
|
+
allowedTypes: ["minor"],
|
|
1483
|
+
requiredRank: "9"
|
|
1484
|
+
},
|
|
1485
|
+
drawRules: {
|
|
1486
|
+
allowedTypes: ["minor"],
|
|
1487
|
+
requiredRank: "9"
|
|
1488
|
+
}
|
|
1489
|
+
},
|
|
1490
|
+
{
|
|
1491
|
+
slotKey: "malkuth",
|
|
1492
|
+
label: "Malkuth",
|
|
1493
|
+
order: 10,
|
|
1494
|
+
minCards: 1,
|
|
1495
|
+
maxCards: 1,
|
|
1496
|
+
validationRules: {
|
|
1497
|
+
allowedTypes: ["minor"],
|
|
1498
|
+
requiredRank: "10"
|
|
1499
|
+
},
|
|
1500
|
+
manualSelectionRules: {
|
|
1501
|
+
allowedTypes: ["minor"],
|
|
1502
|
+
requiredRank: "10"
|
|
1503
|
+
},
|
|
1504
|
+
drawRules: {
|
|
1505
|
+
allowedTypes: ["minor"],
|
|
1506
|
+
requiredRank: "10"
|
|
1507
|
+
}
|
|
1508
|
+
},
|
|
1509
|
+
{
|
|
1510
|
+
slotKey: "daath",
|
|
1511
|
+
label: "Daath",
|
|
1512
|
+
order: 11,
|
|
1513
|
+
minCards: 4,
|
|
1514
|
+
maxCards: 4,
|
|
1515
|
+
validationRules: {
|
|
1516
|
+
allowedTypes: ["daat+royalship"]
|
|
1517
|
+
},
|
|
1518
|
+
manualSelectionRules: {
|
|
1519
|
+
allowedTypes: ["daat+royalship"]
|
|
1520
|
+
},
|
|
1521
|
+
drawRules: {
|
|
1522
|
+
allowedTypes: ["daat+royalship"]
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
]
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
spreadId: "celtic-cross",
|
|
1529
|
+
label: "Celtic Cross",
|
|
1530
|
+
description: "Classic ten-card Celtic Cross spread.",
|
|
1531
|
+
slots: [
|
|
1532
|
+
{
|
|
1533
|
+
slotKey: "present",
|
|
1534
|
+
label: "The Present",
|
|
1535
|
+
order: 1,
|
|
1536
|
+
minCards: 1,
|
|
1537
|
+
maxCards: 1,
|
|
1538
|
+
metadata: {
|
|
1539
|
+
displayLabel: "1."
|
|
1540
|
+
}
|
|
1541
|
+
},
|
|
1542
|
+
{
|
|
1543
|
+
slotKey: "challenge",
|
|
1544
|
+
label: "The Challenge",
|
|
1545
|
+
order: 2,
|
|
1546
|
+
minCards: 1,
|
|
1547
|
+
maxCards: 1,
|
|
1548
|
+
metadata: {
|
|
1549
|
+
displayLabel: "2.",
|
|
1550
|
+
orientation: "sideways"
|
|
1551
|
+
}
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
slotKey: "above",
|
|
1555
|
+
label: "Above",
|
|
1556
|
+
order: 3,
|
|
1557
|
+
minCards: 1,
|
|
1558
|
+
maxCards: 1,
|
|
1559
|
+
metadata: {
|
|
1560
|
+
displayLabel: "3."
|
|
1561
|
+
}
|
|
1562
|
+
},
|
|
1563
|
+
{
|
|
1564
|
+
slotKey: "below",
|
|
1565
|
+
label: "Below",
|
|
1566
|
+
order: 4,
|
|
1567
|
+
minCards: 1,
|
|
1568
|
+
maxCards: 1,
|
|
1569
|
+
metadata: {
|
|
1570
|
+
displayLabel: "4."
|
|
1571
|
+
}
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
slotKey: "behind",
|
|
1575
|
+
label: "Behind",
|
|
1576
|
+
order: 5,
|
|
1577
|
+
minCards: 1,
|
|
1578
|
+
maxCards: 1,
|
|
1579
|
+
metadata: {
|
|
1580
|
+
displayLabel: "5."
|
|
1581
|
+
}
|
|
1582
|
+
},
|
|
1583
|
+
{
|
|
1584
|
+
slotKey: "before",
|
|
1585
|
+
label: "Before",
|
|
1586
|
+
order: 6,
|
|
1587
|
+
minCards: 1,
|
|
1588
|
+
maxCards: 1,
|
|
1589
|
+
metadata: {
|
|
1590
|
+
displayLabel: "6."
|
|
1591
|
+
}
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
slotKey: "self",
|
|
1595
|
+
label: "Self",
|
|
1596
|
+
order: 7,
|
|
1597
|
+
minCards: 1,
|
|
1598
|
+
maxCards: 1,
|
|
1599
|
+
metadata: {
|
|
1600
|
+
displayLabel: "7."
|
|
1601
|
+
}
|
|
1602
|
+
},
|
|
1603
|
+
{
|
|
1604
|
+
slotKey: "environment",
|
|
1605
|
+
label: "Environment",
|
|
1606
|
+
order: 8,
|
|
1607
|
+
minCards: 1,
|
|
1608
|
+
maxCards: 1,
|
|
1609
|
+
metadata: {
|
|
1610
|
+
displayLabel: "8."
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
{
|
|
1614
|
+
slotKey: "hopes-fears",
|
|
1615
|
+
label: "Hopes/Fears",
|
|
1616
|
+
order: 9,
|
|
1617
|
+
minCards: 1,
|
|
1618
|
+
maxCards: 1,
|
|
1619
|
+
metadata: {
|
|
1620
|
+
displayLabel: "9."
|
|
1621
|
+
}
|
|
1622
|
+
},
|
|
1623
|
+
{
|
|
1624
|
+
slotKey: "outcome",
|
|
1625
|
+
label: "Outcome",
|
|
1626
|
+
order: 10,
|
|
1627
|
+
minCards: 1,
|
|
1628
|
+
maxCards: 1,
|
|
1629
|
+
metadata: {
|
|
1630
|
+
displayLabel: "10."
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
]
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
spreadId: "event-reading",
|
|
1637
|
+
label: "Event Reading",
|
|
1638
|
+
description: "Papus-style event spread with outer minor/court cards, seven major cards, and an inquirer card.",
|
|
1639
|
+
contextRequirements: ["inquirerGender"],
|
|
1640
|
+
slots: [
|
|
1641
|
+
createEventOuterSlot(1, "past"),
|
|
1642
|
+
createEventOuterSlot(2, "past"),
|
|
1643
|
+
createEventOuterSlot(3, "past"),
|
|
1644
|
+
createEventOuterSlot(4, "past"),
|
|
1645
|
+
createEventOuterSlot(5, "present"),
|
|
1646
|
+
createEventOuterSlot(6, "present"),
|
|
1647
|
+
createEventOuterSlot(7, "present"),
|
|
1648
|
+
createEventOuterSlot(8, "present"),
|
|
1649
|
+
createEventOuterSlot(9, "future"),
|
|
1650
|
+
createEventOuterSlot(10, "future"),
|
|
1651
|
+
createEventOuterSlot(11, "future"),
|
|
1652
|
+
createEventOuterSlot(12, "future"),
|
|
1653
|
+
createEventInnerSlot(
|
|
1654
|
+
1,
|
|
1655
|
+
"Commencement",
|
|
1656
|
+
"Character of the beginning phase."
|
|
1657
|
+
),
|
|
1658
|
+
createEventInnerSlot(2, "Apogee", "Peak or zenith of the event."),
|
|
1659
|
+
createEventInnerSlot(
|
|
1660
|
+
3,
|
|
1661
|
+
"Decline/Obstacle",
|
|
1662
|
+
"Challenges, obstacles, or decline."
|
|
1663
|
+
),
|
|
1664
|
+
createEventInnerSlot(4, "Fall", "Conclusion or end phase."),
|
|
1665
|
+
createEventInnerSlot(
|
|
1666
|
+
5,
|
|
1667
|
+
"The Past",
|
|
1668
|
+
"Special character or influence in the past."
|
|
1669
|
+
),
|
|
1670
|
+
createEventInnerSlot(
|
|
1671
|
+
6,
|
|
1672
|
+
"The Present",
|
|
1673
|
+
"Special character or influence in the present."
|
|
1674
|
+
),
|
|
1675
|
+
createEventInnerSlot(
|
|
1676
|
+
7,
|
|
1677
|
+
"The Future",
|
|
1678
|
+
"Special character or influence to come."
|
|
1679
|
+
),
|
|
1680
|
+
{
|
|
1681
|
+
slotKey: "inquirer",
|
|
1682
|
+
label: "Inquirer",
|
|
1683
|
+
order: 200,
|
|
1684
|
+
minCards: 1,
|
|
1685
|
+
maxCards: 1,
|
|
1686
|
+
validationRules: {
|
|
1687
|
+
allowedTypes: ["major"]
|
|
1688
|
+
},
|
|
1689
|
+
manualSelectionRules: {
|
|
1690
|
+
allowedTypes: ["major"],
|
|
1691
|
+
allowedCardFilenames: [
|
|
1692
|
+
"01_the_magician",
|
|
1693
|
+
"02_the_high_priestess"
|
|
1694
|
+
]
|
|
1695
|
+
},
|
|
1696
|
+
drawRules: {
|
|
1697
|
+
allowedTypes: ["major"]
|
|
1698
|
+
},
|
|
1699
|
+
metadata: {
|
|
1700
|
+
displayLabel: "Inquirer",
|
|
1701
|
+
groupKey: "center",
|
|
1702
|
+
note: "The querent's energy in this reading."
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
],
|
|
1706
|
+
specialRules: {
|
|
1707
|
+
inquirerCard: {
|
|
1708
|
+
slotKey: "inquirer",
|
|
1709
|
+
sourceSlotKeys: [...EVENT_INNER_SLOT_KEYS],
|
|
1710
|
+
cardNumbersByGender: {
|
|
1711
|
+
man: 1,
|
|
1712
|
+
woman: 2
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
];
|
|
1718
|
+
var TAROT_SPREAD_BY_ID = new Map(
|
|
1719
|
+
TAROT_SPREADS.map((spread) => [spread.spreadId, spread])
|
|
1720
|
+
);
|
|
1721
|
+
function cloneCardConstraint(constraint) {
|
|
1722
|
+
if (!constraint) {
|
|
1723
|
+
return void 0;
|
|
1724
|
+
}
|
|
1725
|
+
return {
|
|
1726
|
+
allowedTypes: constraint.allowedTypes ? [...constraint.allowedTypes] : void 0,
|
|
1727
|
+
requiredRank: constraint.requiredRank,
|
|
1728
|
+
allowedCardFilenames: constraint.allowedCardFilenames ? [...constraint.allowedCardFilenames] : void 0,
|
|
1729
|
+
excludedCardFilenames: constraint.excludedCardFilenames ? [...constraint.excludedCardFilenames] : void 0
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
function cloneSlotDefinition(slot) {
|
|
1733
|
+
return {
|
|
1734
|
+
...slot,
|
|
1735
|
+
validationRules: cloneCardConstraint(slot.validationRules),
|
|
1736
|
+
manualSelectionRules: cloneCardConstraint(slot.manualSelectionRules),
|
|
1737
|
+
drawRules: cloneCardConstraint(slot.drawRules),
|
|
1738
|
+
metadata: slot.metadata ? { ...slot.metadata } : void 0
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
function cloneSpreadDefinition(spread) {
|
|
1742
|
+
return {
|
|
1743
|
+
...spread,
|
|
1744
|
+
contextRequirements: spread.contextRequirements ? [...spread.contextRequirements] : void 0,
|
|
1745
|
+
slots: spread.slots.map(cloneSlotDefinition),
|
|
1746
|
+
specialRules: spread.specialRules?.inquirerCard ? {
|
|
1747
|
+
inquirerCard: {
|
|
1748
|
+
slotKey: spread.specialRules.inquirerCard.slotKey,
|
|
1749
|
+
sourceSlotKeys: [...spread.specialRules.inquirerCard.sourceSlotKeys],
|
|
1750
|
+
cardNumbersByGender: {
|
|
1751
|
+
...spread.specialRules.inquirerCard.cardNumbersByGender
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
} : void 0
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
function getTarotCardByNumber(cardNumber) {
|
|
1758
|
+
return TAROT_CARD_BY_NUMBER.get(cardNumber);
|
|
1759
|
+
}
|
|
1760
|
+
function getTarotSpreadRuleForValidation(slot) {
|
|
1761
|
+
return slot.validationRules ?? slot.drawRules ?? slot.manualSelectionRules;
|
|
1762
|
+
}
|
|
1763
|
+
function getTarotSpreadRuleForDraw(slot) {
|
|
1764
|
+
return slot.drawRules ?? slot.validationRules ?? slot.manualSelectionRules;
|
|
1765
|
+
}
|
|
1766
|
+
function getTarotMinorRank(card) {
|
|
1767
|
+
if (card.type !== "minor") {
|
|
1768
|
+
return void 0;
|
|
1769
|
+
}
|
|
1770
|
+
const rank = card.tarotCardFilename.split("_")[0];
|
|
1771
|
+
return TAROT_SPREAD_MINOR_RANKS.includes(rank) ? rank : void 0;
|
|
1772
|
+
}
|
|
1773
|
+
function matchesTarotSpreadConstraint(card, constraint) {
|
|
1774
|
+
if (!constraint) {
|
|
1775
|
+
return true;
|
|
1776
|
+
}
|
|
1777
|
+
if (constraint.allowedTypes && !constraint.allowedTypes.includes(card.type)) {
|
|
1778
|
+
return false;
|
|
1779
|
+
}
|
|
1780
|
+
if (constraint.allowedCardFilenames && !constraint.allowedCardFilenames.includes(card.tarotCardFilename)) {
|
|
1781
|
+
return false;
|
|
1782
|
+
}
|
|
1783
|
+
if (constraint.excludedCardFilenames && constraint.excludedCardFilenames.includes(card.tarotCardFilename)) {
|
|
1784
|
+
return false;
|
|
1785
|
+
}
|
|
1786
|
+
if (constraint.requiredRank) {
|
|
1787
|
+
return getTarotMinorRank(card) === constraint.requiredRank;
|
|
1788
|
+
}
|
|
1789
|
+
return true;
|
|
1790
|
+
}
|
|
1791
|
+
function randomIndex(length, rng) {
|
|
1792
|
+
if (length <= 0) {
|
|
1793
|
+
throw new Error("Cannot draw from an empty pool.");
|
|
1794
|
+
}
|
|
1795
|
+
const raw = rng();
|
|
1796
|
+
if (!Number.isFinite(raw)) {
|
|
1797
|
+
throw new Error("Tarot spread RNG must return a finite number.");
|
|
1798
|
+
}
|
|
1799
|
+
const normalized = Math.min(Math.max(raw, 0), 1 - Number.EPSILON);
|
|
1800
|
+
return Math.floor(normalized * length);
|
|
1801
|
+
}
|
|
1802
|
+
function withSpreadCardOrientation(card, includeInverted, rng) {
|
|
1803
|
+
return {
|
|
1804
|
+
...card,
|
|
1805
|
+
isInverted: includeInverted ? rng() < 0.5 : false
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
function resolveTarotSpreadSelectionCard(card, slot, tarotCard) {
|
|
1809
|
+
return {
|
|
1810
|
+
...card,
|
|
1811
|
+
slot,
|
|
1812
|
+
card: {
|
|
1813
|
+
...tarotCard,
|
|
1814
|
+
isInverted: card.isInverted ?? false
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
function sortResolvedTarotSpreadCards(resolvedCards) {
|
|
1819
|
+
return [...resolvedCards].sort((left, right) => {
|
|
1820
|
+
if (left.slot.order !== right.slot.order) {
|
|
1821
|
+
return left.slot.order - right.slot.order;
|
|
1822
|
+
}
|
|
1823
|
+
return left.card.number - right.card.number;
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
function validateEventInquirerCard(spread, resolvedCards, context, errors) {
|
|
1827
|
+
const inquirerRule = spread.specialRules?.inquirerCard;
|
|
1828
|
+
if (!inquirerRule) {
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
if (!context?.inquirerGender) {
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
const inquirerCardNumber = inquirerRule.cardNumbersByGender[context.inquirerGender];
|
|
1835
|
+
const sourceCards = resolvedCards.filter(
|
|
1836
|
+
(card) => inquirerRule.sourceSlotKeys.includes(card.slotKey)
|
|
1837
|
+
);
|
|
1838
|
+
const inquirerCards = resolvedCards.filter(
|
|
1839
|
+
(card) => card.slotKey === inquirerRule.slotKey
|
|
1840
|
+
);
|
|
1841
|
+
if (inquirerCards.length !== 1) {
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
const sourceContainsGenderCard = sourceCards.some(
|
|
1845
|
+
(card) => card.card.number === inquirerCardNumber
|
|
1846
|
+
);
|
|
1847
|
+
const totalGenderCardCount = [...sourceCards, ...inquirerCards].filter(
|
|
1848
|
+
(card) => card.card.number === inquirerCardNumber
|
|
1849
|
+
).length;
|
|
1850
|
+
if (totalGenderCardCount !== 1) {
|
|
1851
|
+
errors.push({
|
|
1852
|
+
code: "INVALID_INQUIRER_CARD",
|
|
1853
|
+
slotKey: inquirerRule.slotKey,
|
|
1854
|
+
cardNumber: inquirerCardNumber,
|
|
1855
|
+
message: "Event Reading must contain the gendered inquirer card exactly once across the major arcana band and inquirer slot."
|
|
1856
|
+
});
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
if (!sourceContainsGenderCard && inquirerCards[0].card.number !== inquirerCardNumber) {
|
|
1860
|
+
errors.push({
|
|
1861
|
+
code: "INVALID_INQUIRER_CARD",
|
|
1862
|
+
slotKey: inquirerRule.slotKey,
|
|
1863
|
+
cardNumber: inquirerCards[0].card.number,
|
|
1864
|
+
message: "When the inquirer card was not drawn in the seven major slots, it must occupy the Inquirer slot."
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
function pickTarotCardFromPool(pool, constraint, rng) {
|
|
1869
|
+
const candidateIndexes = pool.reduce((indexes, card, index) => {
|
|
1870
|
+
if (matchesTarotSpreadConstraint(card, constraint)) {
|
|
1871
|
+
indexes.push(index);
|
|
1872
|
+
}
|
|
1873
|
+
return indexes;
|
|
1874
|
+
}, []);
|
|
1875
|
+
if (candidateIndexes.length === 0) {
|
|
1876
|
+
throw new Error("Unable to draw a tarot card that satisfies the spread rule.");
|
|
1877
|
+
}
|
|
1878
|
+
const pickedIndex = candidateIndexes[randomIndex(candidateIndexes.length, rng)];
|
|
1879
|
+
const [pickedCard] = pool.splice(pickedIndex, 1);
|
|
1880
|
+
return pickedCard;
|
|
1881
|
+
}
|
|
1882
|
+
function buildResolvedDrawnCard(slot, card, includeInverted, rng) {
|
|
1883
|
+
const drawnCard = withSpreadCardOrientation(card, includeInverted, rng);
|
|
1884
|
+
return {
|
|
1885
|
+
slotKey: slot.slotKey,
|
|
1886
|
+
cardNumber: drawnCard.number,
|
|
1887
|
+
isInverted: drawnCard.isInverted ?? false,
|
|
1888
|
+
slot,
|
|
1889
|
+
card: drawnCard
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
function drawDefaultTarotSpread(spread, includeInverted, rng) {
|
|
1893
|
+
const deckPool = [...ARKANNUS];
|
|
1894
|
+
const drawnCards = [];
|
|
1895
|
+
for (const slot of spread.slots.slice().sort((left, right) => left.order - right.order)) {
|
|
1896
|
+
const drawRule = getTarotSpreadRuleForDraw(slot);
|
|
1897
|
+
for (let index = 0; index < slot.maxCards; index += 1) {
|
|
1898
|
+
const card = pickTarotCardFromPool(deckPool, drawRule, rng);
|
|
1899
|
+
drawnCards.push(
|
|
1900
|
+
buildResolvedDrawnCard(slot, card, includeInverted, rng)
|
|
1901
|
+
);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
return drawnCards;
|
|
1905
|
+
}
|
|
1906
|
+
function drawEventReadingSpread(spread, includeInverted, rng, context) {
|
|
1907
|
+
const inquirerRule = spread.specialRules?.inquirerCard;
|
|
1908
|
+
if (!inquirerRule || !context?.inquirerGender) {
|
|
1909
|
+
throw new Error(
|
|
1910
|
+
"Event Reading draw requires `context.inquirerGender`."
|
|
1911
|
+
);
|
|
1912
|
+
}
|
|
1913
|
+
const slotsByKey = new Map(
|
|
1914
|
+
spread.slots.map((slot) => [slot.slotKey, slot])
|
|
1915
|
+
);
|
|
1916
|
+
const outerPool = ARKANNUS.filter(
|
|
1917
|
+
(card) => card.type === "minor" || card.type === "daat+royalship"
|
|
1918
|
+
);
|
|
1919
|
+
const majorPool = ARKANNUS.filter((card) => card.type === "major");
|
|
1920
|
+
const drawnCards = [];
|
|
1921
|
+
for (const slot of spread.slots.filter((candidate) => candidate.metadata?.groupKey === "outer").sort((left, right) => left.order - right.order)) {
|
|
1922
|
+
const card = pickTarotCardFromPool(outerPool, getTarotSpreadRuleForDraw(slot), rng);
|
|
1923
|
+
drawnCards.push(buildResolvedDrawnCard(slot, card, includeInverted, rng));
|
|
1924
|
+
}
|
|
1925
|
+
for (const slotKey of inquirerRule.sourceSlotKeys) {
|
|
1926
|
+
const slot = slotsByKey.get(slotKey);
|
|
1927
|
+
if (!slot) {
|
|
1928
|
+
throw new Error(`Missing Event Reading slot definition for ${slotKey}.`);
|
|
1929
|
+
}
|
|
1930
|
+
const card = pickTarotCardFromPool(majorPool, getTarotSpreadRuleForDraw(slot), rng);
|
|
1931
|
+
drawnCards.push(buildResolvedDrawnCard(slot, card, includeInverted, rng));
|
|
1932
|
+
}
|
|
1933
|
+
const genderedInquirerCardNumber = inquirerRule.cardNumbersByGender[context.inquirerGender];
|
|
1934
|
+
const sourceContainsGenderedCard = drawnCards.some(
|
|
1935
|
+
(card) => inquirerRule.sourceSlotKeys.includes(card.slotKey) && card.card.number === genderedInquirerCardNumber
|
|
1936
|
+
);
|
|
1937
|
+
const inquirerSlot = slotsByKey.get(inquirerRule.slotKey);
|
|
1938
|
+
if (!inquirerSlot) {
|
|
1939
|
+
throw new Error(
|
|
1940
|
+
`Missing Event Reading slot definition for ${inquirerRule.slotKey}.`
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1943
|
+
if (!sourceContainsGenderedCard) {
|
|
1944
|
+
const genderedCardIndex = majorPool.findIndex(
|
|
1945
|
+
(card) => card.number === genderedInquirerCardNumber
|
|
1946
|
+
);
|
|
1947
|
+
if (genderedCardIndex < 0) {
|
|
1948
|
+
throw new Error(
|
|
1949
|
+
"Unable to assign the Event Reading inquirer card from the remaining major arcana."
|
|
1950
|
+
);
|
|
1951
|
+
}
|
|
1952
|
+
const [genderedCard] = majorPool.splice(genderedCardIndex, 1);
|
|
1953
|
+
drawnCards.push(
|
|
1954
|
+
buildResolvedDrawnCard(inquirerSlot, genderedCard, includeInverted, rng)
|
|
1955
|
+
);
|
|
1956
|
+
} else {
|
|
1957
|
+
const replacement = pickTarotCardFromPool(
|
|
1958
|
+
majorPool,
|
|
1959
|
+
getTarotSpreadRuleForDraw(inquirerSlot),
|
|
1960
|
+
rng
|
|
1961
|
+
);
|
|
1962
|
+
drawnCards.push(
|
|
1963
|
+
buildResolvedDrawnCard(inquirerSlot, replacement, includeInverted, rng)
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
return drawnCards;
|
|
1967
|
+
}
|
|
1968
|
+
function listTarotSpreads() {
|
|
1969
|
+
return TAROT_SPREADS.map(cloneSpreadDefinition);
|
|
1970
|
+
}
|
|
1971
|
+
function getTarotSpread(spreadId) {
|
|
1972
|
+
const spread = TAROT_SPREAD_BY_ID.get(spreadId);
|
|
1973
|
+
return spread ? cloneSpreadDefinition(spread) : void 0;
|
|
1974
|
+
}
|
|
1975
|
+
function validateTarotSpreadSelection(input) {
|
|
1976
|
+
const spread = TAROT_SPREAD_BY_ID.get(input.spreadId);
|
|
1977
|
+
const errors = [];
|
|
1978
|
+
if (!spread) {
|
|
1979
|
+
return {
|
|
1980
|
+
ok: false,
|
|
1981
|
+
isComplete: false,
|
|
1982
|
+
errors: [
|
|
1983
|
+
{
|
|
1984
|
+
code: "UNKNOWN_SPREAD",
|
|
1985
|
+
message: `Unknown tarot spread: ${input.spreadId}.`
|
|
1986
|
+
}
|
|
1987
|
+
],
|
|
1988
|
+
resolvedCards: []
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
const slotsByKey = new Map(
|
|
1992
|
+
spread.slots.map((slot) => [slot.slotKey, slot])
|
|
1993
|
+
);
|
|
1994
|
+
const seenCardNumbers = /* @__PURE__ */ new Set();
|
|
1995
|
+
const resolvedCards = [];
|
|
1996
|
+
for (const selectedCard of input.cards) {
|
|
1997
|
+
const slot = slotsByKey.get(selectedCard.slotKey);
|
|
1998
|
+
if (!slot) {
|
|
1999
|
+
errors.push({
|
|
2000
|
+
code: "UNKNOWN_SLOT",
|
|
2001
|
+
slotKey: selectedCard.slotKey,
|
|
2002
|
+
message: `Unknown slot for ${spread.label}: ${selectedCard.slotKey}.`
|
|
2003
|
+
});
|
|
2004
|
+
continue;
|
|
2005
|
+
}
|
|
2006
|
+
const tarotCard = getTarotCardByNumber(selectedCard.cardNumber);
|
|
2007
|
+
if (!tarotCard) {
|
|
2008
|
+
errors.push({
|
|
2009
|
+
code: "CARD_NOT_FOUND",
|
|
2010
|
+
slotKey: selectedCard.slotKey,
|
|
2011
|
+
cardNumber: selectedCard.cardNumber,
|
|
2012
|
+
message: `Unknown tarot card number: ${selectedCard.cardNumber}.`
|
|
2013
|
+
});
|
|
2014
|
+
continue;
|
|
2015
|
+
}
|
|
2016
|
+
if (seenCardNumbers.has(tarotCard.number)) {
|
|
2017
|
+
errors.push({
|
|
2018
|
+
code: "DUPLICATE_CARD",
|
|
2019
|
+
slotKey: selectedCard.slotKey,
|
|
2020
|
+
cardNumber: tarotCard.number,
|
|
2021
|
+
message: `Tarot card ${tarotCard.number} is duplicated across the spread.`
|
|
2022
|
+
});
|
|
2023
|
+
continue;
|
|
2024
|
+
}
|
|
2025
|
+
seenCardNumbers.add(tarotCard.number);
|
|
2026
|
+
resolvedCards.push(
|
|
2027
|
+
resolveTarotSpreadSelectionCard(selectedCard, slot, tarotCard)
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
let isComplete = true;
|
|
2031
|
+
for (const slot of spread.slots) {
|
|
2032
|
+
const slotCards = resolvedCards.filter(
|
|
2033
|
+
(selectedCard) => selectedCard.slotKey === slot.slotKey
|
|
2034
|
+
);
|
|
2035
|
+
if (slotCards.length < slot.minCards) {
|
|
2036
|
+
isComplete = false;
|
|
2037
|
+
if (!input.allowPartial) {
|
|
2038
|
+
errors.push({
|
|
2039
|
+
code: "MISSING_REQUIRED_CARDS",
|
|
2040
|
+
slotKey: slot.slotKey,
|
|
2041
|
+
message: `${spread.label} requires ${slot.minCards} card(s) for ${slot.label}.`
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
if (slotCards.length > slot.maxCards) {
|
|
2046
|
+
isComplete = false;
|
|
2047
|
+
errors.push({
|
|
2048
|
+
code: "TOO_MANY_CARDS",
|
|
2049
|
+
slotKey: slot.slotKey,
|
|
2050
|
+
message: `${spread.label} allows at most ${slot.maxCards} card(s) for ${slot.label}.`
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
const validationRule = getTarotSpreadRuleForValidation(slot);
|
|
2054
|
+
for (const slotCard of slotCards) {
|
|
2055
|
+
if (validationRule?.allowedTypes && !validationRule.allowedTypes.includes(slotCard.card.type)) {
|
|
2056
|
+
errors.push({
|
|
2057
|
+
code: "INVALID_CARD_TYPE",
|
|
2058
|
+
slotKey: slot.slotKey,
|
|
2059
|
+
cardNumber: slotCard.card.number,
|
|
2060
|
+
message: `${slot.label} does not accept ${slotCard.card.type} cards.`
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
if (validationRule?.requiredRank && getTarotMinorRank(slotCard.card) !== validationRule.requiredRank) {
|
|
2064
|
+
errors.push({
|
|
2065
|
+
code: "INVALID_CARD_RANK",
|
|
2066
|
+
slotKey: slot.slotKey,
|
|
2067
|
+
cardNumber: slotCard.card.number,
|
|
2068
|
+
message: `${slot.label} requires a ${validationRule.requiredRank} minor arcana card.`
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
if (validationRule?.allowedCardFilenames && !validationRule.allowedCardFilenames.includes(slotCard.card.tarotCardFilename)) {
|
|
2072
|
+
errors.push({
|
|
2073
|
+
code: "DISALLOWED_CARD",
|
|
2074
|
+
slotKey: slot.slotKey,
|
|
2075
|
+
cardNumber: slotCard.card.number,
|
|
2076
|
+
message: `${slotCard.card.tarotCard} is not allowed in ${slot.label}.`
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
if (validationRule?.excludedCardFilenames && validationRule.excludedCardFilenames.includes(slotCard.card.tarotCardFilename)) {
|
|
2080
|
+
errors.push({
|
|
2081
|
+
code: "DISALLOWED_CARD",
|
|
2082
|
+
slotKey: slot.slotKey,
|
|
2083
|
+
cardNumber: slotCard.card.number,
|
|
2084
|
+
message: `${slotCard.card.tarotCard} is excluded from ${slot.label}.`
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
if (spread.contextRequirements?.includes("inquirerGender") && !input.context?.inquirerGender) {
|
|
2090
|
+
isComplete = false;
|
|
2091
|
+
errors.push({
|
|
2092
|
+
code: "MISSING_CONTEXT",
|
|
2093
|
+
message: `${spread.label} requires \`context.inquirerGender\`.`
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
validateEventInquirerCard(spread, resolvedCards, input.context, errors);
|
|
2097
|
+
const sortedResolvedCards = sortResolvedTarotSpreadCards(resolvedCards);
|
|
2098
|
+
return {
|
|
2099
|
+
ok: errors.length === 0,
|
|
2100
|
+
isComplete,
|
|
2101
|
+
spread: cloneSpreadDefinition(spread),
|
|
2102
|
+
resolvedCards: sortedResolvedCards,
|
|
2103
|
+
errors
|
|
2104
|
+
};
|
|
2105
|
+
}
|
|
2106
|
+
function drawTarotSpread(options) {
|
|
2107
|
+
const spread = TAROT_SPREAD_BY_ID.get(options.spreadId);
|
|
2108
|
+
if (!spread) {
|
|
2109
|
+
throw new Error(`Unknown tarot spread: ${options.spreadId}.`);
|
|
2110
|
+
}
|
|
2111
|
+
const rng = options.rng ?? Math.random;
|
|
2112
|
+
const includeInverted = options.includeInverted ?? false;
|
|
2113
|
+
const drawnCards = spread.spreadId === "event-reading" ? drawEventReadingSpread(spread, includeInverted, rng, options.context) : drawDefaultTarotSpread(spread, includeInverted, rng);
|
|
2114
|
+
const validation = validateTarotSpreadSelection({
|
|
2115
|
+
spreadId: spread.spreadId,
|
|
2116
|
+
cards: drawnCards.map((card) => ({
|
|
2117
|
+
slotKey: card.slotKey,
|
|
2118
|
+
cardNumber: card.cardNumber,
|
|
2119
|
+
isInverted: card.isInverted
|
|
2120
|
+
})),
|
|
2121
|
+
context: options.context
|
|
2122
|
+
});
|
|
2123
|
+
if (!validation.ok) {
|
|
2124
|
+
throw new Error(
|
|
2125
|
+
`Generated an invalid tarot spread selection for ${spread.label}: ${validation.errors.map((error) => error.message).join(" ")}`
|
|
2126
|
+
);
|
|
2127
|
+
}
|
|
2128
|
+
return {
|
|
2129
|
+
spread: cloneSpreadDefinition(spread),
|
|
2130
|
+
deckId: options.deckId ?? "rider-waite",
|
|
2131
|
+
context: options.context,
|
|
2132
|
+
cards: sortResolvedTarotSpreadCards(drawnCards)
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
1060
2135
|
|
|
1061
2136
|
exports.ARKANNUS = ARKANNUS;
|
|
1062
2137
|
exports.TAROT_IMAGE_BASE_URL = TAROT_IMAGE_BASE_URL;
|
|
2138
|
+
exports.drawTarotSpread = drawTarotSpread;
|
|
1063
2139
|
exports.getTarotArchetype = getTarotArchetype;
|
|
1064
2140
|
exports.getTarotRepresentation = getTarotRepresentation;
|
|
1065
2141
|
exports.getTarotRepresentations = getTarotRepresentations;
|
|
2142
|
+
exports.getTarotSpread = getTarotSpread;
|
|
1066
2143
|
exports.listTarotDecks = listTarotDecks;
|
|
2144
|
+
exports.listTarotSpreads = listTarotSpreads;
|
|
1067
2145
|
exports.majorArcana = majorArcana;
|
|
1068
2146
|
exports.resolveTarotImageUrl = resolveTarotImageUrl;
|
|
1069
2147
|
exports.shuffleTarotDeck = shuffleTarotDeck;
|
|
1070
|
-
|
|
1071
|
-
//# sourceMappingURL=chunk-
|
|
2148
|
+
exports.validateTarotSpreadSelection = validateTarotSpreadSelection;
|
|
2149
|
+
//# sourceMappingURL=chunk-NPCXF6RV.js.map
|
|
2150
|
+
//# sourceMappingURL=chunk-NPCXF6RV.js.map
|