@treeviz/gedcom-parser 1.0.22 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1109,11 +1109,30 @@ var Common = class _Common {
1109
1109
  const sour = get(head, "SOUR.value");
1110
1110
  return !!sour?.toLowerCase()?.startsWith("myheritage");
1111
1111
  }
1112
+ /**
1113
+ * Get the source type as a string (for prefixing tree IDs and names)
1114
+ * Returns the detected source type or undefined if unknown
1115
+ */
1116
+ getSourceType() {
1117
+ if (this.isAncestry()) return "Ancestry";
1118
+ if (this.isMyHeritage()) return "MyHeritage";
1119
+ if (this.isFamilySearch()) return "FamilySearch";
1120
+ if (this.isGNO2GED()) return "GNO2GED";
1121
+ if (this.isGenoPro()) return "GenoPro";
1122
+ if (this.isAhnenblatt()) return "Ahnenblatt";
1123
+ if (this.isGeni()) return "Geni";
1124
+ return void 0;
1125
+ }
1112
1126
  isFamilySearch() {
1113
1127
  const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
1114
1128
  const sourName = get(head, "SOUR.NAME.value");
1115
1129
  return sourName === "FamilySearch API";
1116
1130
  }
1131
+ isGNO2GED() {
1132
+ const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
1133
+ const sour = get(head, "SOUR.value");
1134
+ return sour === "GNO2GED";
1135
+ }
1117
1136
  getAncestryTreeId() {
1118
1137
  const path = "HEAD.SOUR._TREE.RIN.value";
1119
1138
  return get(this, path) || get(this.getGedcom(), path);
@@ -1124,11 +1143,34 @@ var Common = class _Common {
1124
1143
  }
1125
1144
  getTreeId() {
1126
1145
  if (this?.isAncestry()) {
1127
- return this.getAncestryTreeId();
1146
+ const id = this.getAncestryTreeId();
1147
+ if (id !== void 0) return id;
1128
1148
  }
1129
1149
  if (this?.isMyHeritage()) {
1130
- return this.getMyHeritageTreeId();
1150
+ const id = this.getMyHeritageTreeId();
1151
+ if (id !== void 0) return id;
1152
+ }
1153
+ if (this?.isFamilySearch()) {
1154
+ const id = this.getFamilySearchTreeId();
1155
+ if (id !== void 0) return id;
1131
1156
  }
1157
+ if (this?.isGNO2GED()) {
1158
+ const id = this.getGNO2GEDTreeId();
1159
+ if (id !== void 0) return id;
1160
+ }
1161
+ if (this?.isAhnenblatt()) {
1162
+ const id = this.getAhnenblattTreeId();
1163
+ if (id !== void 0) return id;
1164
+ }
1165
+ if (this?.isGeni()) {
1166
+ const id = this.getGeniTreeId();
1167
+ if (id !== void 0) return id;
1168
+ }
1169
+ if (this?.isGenoPro()) {
1170
+ const id = this.getGenoProTreeId();
1171
+ if (id !== void 0) return id;
1172
+ }
1173
+ return this.getUniversalTreeId();
1132
1174
  }
1133
1175
  getAncestryTreeName() {
1134
1176
  const path = "HEAD.SOUR._TREE.value";
@@ -1141,13 +1183,146 @@ var Common = class _Common {
1141
1183
  /Exported by MyHeritage.com from (?<tree>.+) in.+$/
1142
1184
  )?.groups?.tree;
1143
1185
  }
1186
+ getFamilySearchTreeId() {
1187
+ const rin = get(this, "HEAD.SOUR._TREE.RIN.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.RIN.value");
1188
+ if (rin) {
1189
+ return rin;
1190
+ }
1191
+ return "familysearch";
1192
+ }
1193
+ getFamilySearchTreeName() {
1194
+ const treeName = get(this, "HEAD.SOUR._TREE.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.value");
1195
+ if (treeName) {
1196
+ return treeName;
1197
+ }
1198
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1199
+ return fileName || "FamilySearch Import";
1200
+ }
1201
+ getAhnenblattTreeId() {
1202
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1203
+ if (fileName) {
1204
+ const idMatch = fileName.match(/_(\d+)/);
1205
+ if (idMatch) {
1206
+ return idMatch[1];
1207
+ }
1208
+ }
1209
+ return void 0;
1210
+ }
1211
+ getAhnenblattTreeName() {
1212
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1213
+ return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
1214
+ }
1215
+ getGeniTreeId() {
1216
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1217
+ if (fileName) {
1218
+ const idMatch = fileName.match(/_(\d+)/);
1219
+ if (idMatch) {
1220
+ return idMatch[1];
1221
+ }
1222
+ }
1223
+ return void 0;
1224
+ }
1225
+ getGeniTreeName() {
1226
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1227
+ return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
1228
+ }
1229
+ getGenoProTreeId() {
1230
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1231
+ if (fileName) {
1232
+ const idMatch = fileName.match(/_(\d+)/);
1233
+ if (idMatch) {
1234
+ return idMatch[1];
1235
+ }
1236
+ }
1237
+ return void 0;
1238
+ }
1239
+ getGenoProTreeName() {
1240
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1241
+ return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
1242
+ }
1243
+ getGNO2GEDTreeId() {
1244
+ const rin = get(this, "HEAD._TREE.RIN.value") || get(this.getGedcom(), "HEAD._TREE.RIN.value");
1245
+ if (rin) {
1246
+ return rin;
1247
+ }
1248
+ return `gno_${this._gedcom?.refcount || "unknown"}`;
1249
+ }
1250
+ getGNO2GEDTreeName() {
1251
+ const treeName = get(this, "HEAD._TREE.value") || get(this.getGedcom(), "HEAD._TREE.value");
1252
+ if (treeName) {
1253
+ return treeName;
1254
+ }
1255
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1256
+ return fileName || "GNO2GED Export";
1257
+ }
1258
+ /**
1259
+ * Universal tree ID getter for unknown/unrecognized GEDCOM sources
1260
+ * Tries to extract an ID from various common locations
1261
+ */
1262
+ getUniversalTreeId() {
1263
+ const sourceType = this.getSourceType();
1264
+ const prefix = sourceType ? sourceType.toLowerCase() : "tree";
1265
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1266
+ if (fileName) {
1267
+ const idMatch = fileName.match(/_(\d+)/);
1268
+ if (idMatch) {
1269
+ return `${prefix}_${idMatch[1]}`;
1270
+ }
1271
+ }
1272
+ return `${prefix}_${this._gedcom?.refcount || "unknown"}`;
1273
+ }
1274
+ /**
1275
+ * Universal tree name getter for unknown/unrecognized GEDCOM sources
1276
+ * Tries to extract a name from various common locations
1277
+ */
1278
+ getUniversalTreeName() {
1279
+ const sourceType = this.getSourceType();
1280
+ const prefix = sourceType ? `${sourceType}-` : "";
1281
+ const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
1282
+ if (fileName) {
1283
+ const cleanName = fileName.replace(/\.ged$/i, "").replace(/_/g, " ");
1284
+ return `${prefix}${cleanName}`;
1285
+ }
1286
+ const sourName = get(this, "HEAD.SOUR.NAME.value") || get(this.getGedcom(), "HEAD.SOUR.NAME.value");
1287
+ if (sourName) {
1288
+ return `${prefix}${sourName}`;
1289
+ }
1290
+ const sourValue = get(this, "HEAD.SOUR.value") || get(this.getGedcom(), "HEAD.SOUR.value");
1291
+ if (sourValue) {
1292
+ return `${prefix}${sourValue}`;
1293
+ }
1294
+ return `${prefix}Unknown Tree`;
1295
+ }
1144
1296
  getTreeName() {
1145
1297
  if (this?.isAncestry()) {
1146
- return this.getAncestryTreeName();
1298
+ const name = this.getAncestryTreeName();
1299
+ if (name) return name;
1147
1300
  }
1148
1301
  if (this?.isMyHeritage()) {
1149
- return this.getMyHeritageTreeName();
1302
+ const name = this.getMyHeritageTreeName();
1303
+ if (name) return name;
1304
+ }
1305
+ if (this?.isFamilySearch()) {
1306
+ const name = this.getFamilySearchTreeName();
1307
+ if (name) return name;
1308
+ }
1309
+ if (this?.isGNO2GED()) {
1310
+ const name = this.getGNO2GEDTreeName();
1311
+ if (name) return name;
1312
+ }
1313
+ if (this?.isAhnenblatt()) {
1314
+ const name = this.getAhnenblattTreeName();
1315
+ if (name) return name;
1150
1316
  }
1317
+ if (this?.isGeni()) {
1318
+ const name = this.getGeniTreeName();
1319
+ if (name) return name;
1320
+ }
1321
+ if (this?.isGenoPro()) {
1322
+ const name = this.getGenoProTreeName();
1323
+ if (name) return name;
1324
+ }
1325
+ return this.getUniversalTreeName();
1151
1326
  }
1152
1327
  };
1153
1328
  var createProxy = (target) => {
@@ -1562,66 +1737,125 @@ var getMarriageAscAndChildBirth = (person) => (itemA, keyA, itemB, keyB) => {
1562
1737
  const childB = familyB?.getChildren().orderBy(BIRTH_ASC).index(0);
1563
1738
  return getBirthAsc(childA, keyA, childB);
1564
1739
  };
1740
+ var getGedcomId = (gedcom) => {
1741
+ if (!gedcom) {
1742
+ return "unknown";
1743
+ }
1744
+ const treeId = gedcom.getTreeId?.() || "";
1745
+ const treeName = gedcom.getTreeName?.() || "";
1746
+ const sanitizedName = treeName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
1747
+ if (treeId && sanitizedName) {
1748
+ return `${treeId}_${sanitizedName}`;
1749
+ } else if (treeId) {
1750
+ return treeId;
1751
+ } else if (sanitizedName) {
1752
+ return sanitizedName;
1753
+ }
1754
+ return `gedcom_${gedcom.refcount}`;
1755
+ };
1565
1756
  var caches = {
1566
1757
  pathCache: {},
1567
1758
  relativesOnDegreeCache: {},
1568
- relativesOnLevelCache: {}
1759
+ relativesOnLevelCache: {},
1760
+ profilePictureCache: {}
1569
1761
  };
1570
- var getInstance = getCacheManagerFactory();
1571
- var cacheDbs = {
1572
- pathCache: getInstance("ftv", "Main", "path", true),
1573
- relativesOnDegreeCache: getInstance(
1574
- "ftv",
1575
- "Main",
1576
- "path",
1577
- true
1578
- ),
1579
- relativesOnLevelCache: getInstance(
1580
- "ftv",
1581
- "Main",
1582
- "path",
1583
- true
1584
- )
1762
+ var cacheDbs;
1763
+ var getCacheDbs = () => {
1764
+ if (!cacheDbs) {
1765
+ const getInstance = getCacheManagerFactory();
1766
+ cacheDbs = {
1767
+ pathCache: getInstance(
1768
+ "ftv",
1769
+ "Main",
1770
+ "path",
1771
+ true
1772
+ ),
1773
+ relativesOnDegreeCache: getInstance("ftv", "Main", "path", true),
1774
+ relativesOnLevelCache: getInstance(
1775
+ "ftv",
1776
+ "Main",
1777
+ "path",
1778
+ true
1779
+ ),
1780
+ profilePictureCache: getInstance(
1781
+ "ftv",
1782
+ "Main",
1783
+ "images",
1784
+ false
1785
+ )
1786
+ };
1787
+ }
1788
+ return cacheDbs;
1585
1789
  };
1586
- ({
1790
+ var storeCache = {
1791
+ // NOTE: pathCache, relativesOnLevelCache, and relativesOnDegreeCache are intentionally
1792
+ // kept in memory only. These debounced functions exist to satisfy the type system
1793
+ // but are never called.
1587
1794
  pathCache: debounce((value) => {
1588
1795
  if (value) {
1589
- cacheDbs.pathCache.setItem(value);
1796
+ getCacheDbs().pathCache.setItem(value);
1590
1797
  }
1591
1798
  }, 50),
1592
1799
  relativesOnLevelCache: debounce((value) => {
1593
1800
  if (value) {
1594
- cacheDbs.relativesOnLevelCache.setItem(value);
1801
+ getCacheDbs().relativesOnLevelCache.setItem(value);
1595
1802
  }
1596
1803
  }, 50),
1597
1804
  relativesOnDegreeCache: debounce((value) => {
1598
1805
  if (value) {
1599
- cacheDbs.relativesOnDegreeCache.setItem(value);
1806
+ getCacheDbs().relativesOnDegreeCache.setItem(value);
1600
1807
  }
1601
- }, 50)
1602
- });
1603
- var relativesCache = (cacheKey) => (key, subKey, value) => {
1604
- if (!caches[cacheKey]) {
1808
+ }, 50),
1809
+ // profilePictureCache IS persisted to IndexedDB
1810
+ profilePictureCache: debounce((value) => {
1811
+ if (value) {
1812
+ getCacheDbs().profilePictureCache.setItem(value);
1813
+ }
1814
+ }, 100)
1815
+ };
1816
+ var relativesCache = (cacheKey) => (gedcom, key, subKey, value) => {
1817
+ const gedcomId = getGedcomId(gedcom);
1818
+ const fullKey = `${gedcomId}:${key}`;
1819
+ const cache = caches[cacheKey];
1820
+ if (!cache) {
1605
1821
  caches[cacheKey] = {};
1606
1822
  }
1607
- if (value && caches[cacheKey]) {
1608
- if (!caches[cacheKey][key]) {
1609
- caches[cacheKey][key] = {};
1823
+ if (value) {
1824
+ const typedCache2 = caches[cacheKey];
1825
+ if (!typedCache2[fullKey]) {
1826
+ typedCache2[fullKey] = {};
1610
1827
  }
1611
- caches[cacheKey][key][subKey] = value;
1612
- return caches[cacheKey][key][subKey];
1828
+ typedCache2[fullKey][subKey] = value;
1829
+ return typedCache2[fullKey][subKey];
1613
1830
  }
1614
- return caches[cacheKey]?.[key]?.[subKey];
1831
+ const typedCache = caches[cacheKey];
1832
+ return typedCache?.[fullKey]?.[subKey];
1615
1833
  };
1616
- var pathCache = (key, value) => {
1834
+ var pathCache = (gedcom, key, value) => {
1835
+ const gedcomId = getGedcomId(gedcom);
1836
+ const fullKey = `${gedcomId}:${key}`;
1617
1837
  if (!caches.pathCache) {
1618
1838
  caches.pathCache = {};
1619
1839
  }
1620
1840
  if (value && caches.pathCache) {
1621
- caches.pathCache[key] = value;
1622
- return caches.pathCache[key];
1841
+ caches.pathCache[fullKey] = value;
1842
+ return caches.pathCache[fullKey];
1623
1843
  }
1624
- return caches.pathCache?.[key];
1844
+ return caches.pathCache?.[fullKey];
1845
+ };
1846
+ var profilePictureCache = (gedcom, key, value) => {
1847
+ const gedcomId = getGedcomId(gedcom);
1848
+ const fullKey = `${gedcomId}:${key}`;
1849
+ if (!caches.profilePictureCache) {
1850
+ caches.profilePictureCache = {};
1851
+ }
1852
+ if (value && caches.profilePictureCache) {
1853
+ caches.profilePictureCache[fullKey] = value;
1854
+ storeCache.profilePictureCache(caches.profilePictureCache);
1855
+ return caches.profilePictureCache[fullKey];
1856
+ }
1857
+ const cached = caches.profilePictureCache?.[fullKey];
1858
+ return cached;
1625
1859
  };
1626
1860
 
1627
1861
  // src/utils/get-places.ts
@@ -2949,7 +3183,7 @@ var Indi = class extends Common {
2949
3183
  }
2950
3184
  async ancestryMedia(namespace) {
2951
3185
  const list = {};
2952
- const objeList = this.get("OBJE")?.toList();
3186
+ const objeList = this.get("OBJE")?.toList().copy();
2953
3187
  const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
2954
3188
  const tree = this.getAncestryTreeId();
2955
3189
  if (objeList) {
@@ -3023,11 +3257,12 @@ var Indi = class extends Common {
3023
3257
  if (!tree) {
3024
3258
  return;
3025
3259
  }
3026
- const objeList = this.get("OBJE")?.toList();
3027
- const birthObj = this.get("BIRT.OBJE")?.toList();
3028
- const deathObj = this.get("DEAT.OBJE")?.toList();
3260
+ const objeList = this.get("OBJE")?.toList().copy();
3261
+ const birthObj = this.get("BIRT.OBJE")?.toList().copy();
3262
+ const deathObj = this.get("DEAT.OBJE")?.toList().copy();
3263
+ objeList?.merge(birthObj).merge(deathObj);
3029
3264
  (this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).forEach((fam) => {
3030
- objeList?.merge(birthObj).merge(deathObj).merge(fam?.get("MARR.OBJE"));
3265
+ objeList.merge(fam?.get("MARR.OBJE"));
3031
3266
  });
3032
3267
  objeList?.forEach((o, index) => {
3033
3268
  if (!o) {
@@ -3145,6 +3380,88 @@ var Indi = class extends Common {
3145
3380
  };
3146
3381
  });
3147
3382
  }
3383
+ geniMedia() {
3384
+ const list = {};
3385
+ const objeList = this.get("OBJE")?.toList().copy();
3386
+ const sourList = this.get("SOUR")?.toList().copy();
3387
+ sourList?.forEach((sour) => {
3388
+ const sourObje = sour?.get("OBJE")?.toList();
3389
+ objeList.merge(sourObje);
3390
+ });
3391
+ if (!objeList || objeList.length === 0) {
3392
+ return void 0;
3393
+ }
3394
+ const rfn = this.get("RFN")?.toValue();
3395
+ const geniId = rfn?.replace(/^geni:/, "") || "unknown";
3396
+ objeList.forEach((obje, index) => {
3397
+ if (!obje) {
3398
+ return;
3399
+ }
3400
+ const key = `@O${index}@`;
3401
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
3402
+ const url = obje?.get("FILE")?.toValue();
3403
+ const title = obje?.get("TITL")?.toValue() ?? "";
3404
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
3405
+ if (url) {
3406
+ const urlMatch = url.match(/\/([^/]+)\?hash=/);
3407
+ const imgId = urlMatch?.[1] || `img-${index}-${Date.now().toString(36)}`;
3408
+ const id = `geni-${geniId}-${imgId}`;
3409
+ list[id] = {
3410
+ isPrimary,
3411
+ key,
3412
+ id,
3413
+ tree: geniId,
3414
+ imgId,
3415
+ person: this.id,
3416
+ title,
3417
+ url,
3418
+ contentType: type,
3419
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
3420
+ };
3421
+ }
3422
+ });
3423
+ return list;
3424
+ }
3425
+ universalMedia() {
3426
+ const list = {};
3427
+ if (!this.id) {
3428
+ return list;
3429
+ }
3430
+ const objeList = this.get("OBJE")?.toList().copy();
3431
+ if (!objeList || objeList.length === 0) {
3432
+ return list;
3433
+ }
3434
+ const rfn = this.get("RFN")?.toValue();
3435
+ const treeId = rfn || "universal";
3436
+ objeList.forEach((obje, index) => {
3437
+ if (!obje) {
3438
+ return;
3439
+ }
3440
+ const key = `@O${index}@`;
3441
+ obje.standardizeMedia();
3442
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
3443
+ const url = obje?.get("FILE")?.toValue();
3444
+ const title = obje?.get("TITL")?.toValue() ?? "";
3445
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
3446
+ if (url) {
3447
+ const imgId = `media-${index}-${url.split("/").pop()?.split("?")[0]?.substring(0, 20) || Date.now().toString(36)}`;
3448
+ const id = `${treeId}-${this.id}-${imgId}`;
3449
+ list[id] = {
3450
+ isPrimary,
3451
+ key,
3452
+ id,
3453
+ tree: treeId,
3454
+ imgId,
3455
+ person: this.id,
3456
+ title,
3457
+ url,
3458
+ contentType: type,
3459
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
3460
+ };
3461
+ }
3462
+ });
3463
+ return list;
3464
+ }
3148
3465
  async multimedia(namespace) {
3149
3466
  if (this?.isAncestry()) {
3150
3467
  return await this.ancestryMedia(namespace);
@@ -3152,11 +3469,30 @@ var Indi = class extends Common {
3152
3469
  if (this?.isMyHeritage()) {
3153
3470
  return this.myheritageMedia();
3154
3471
  }
3155
- return void 0;
3472
+ if (this?.isGeni()) {
3473
+ return this.geniMedia();
3474
+ }
3475
+ return this.universalMedia();
3156
3476
  }
3157
- async getProfilePicture(namespace) {
3477
+ async getProfilePicture(namespace, onlyPrimary = true) {
3478
+ if (!this.id) {
3479
+ return void 0;
3480
+ }
3481
+ const cacheKey = this.id;
3482
+ const cached = profilePictureCache(
3483
+ this._gedcom,
3484
+ cacheKey
3485
+ );
3486
+ if (cached !== void 0) {
3487
+ return cached;
3488
+ }
3158
3489
  const mediaList = await this.multimedia(namespace);
3159
3490
  if (!mediaList) {
3491
+ profilePictureCache(
3492
+ this._gedcom,
3493
+ cacheKey,
3494
+ void 0
3495
+ );
3160
3496
  return void 0;
3161
3497
  }
3162
3498
  const mediaArray = Object.values(mediaList);
@@ -3164,24 +3500,41 @@ var Indi = class extends Common {
3164
3500
  (media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
3165
3501
  );
3166
3502
  if (primaryMedia) {
3167
- return {
3503
+ const result = {
3168
3504
  file: primaryMedia.url,
3169
3505
  form: primaryMedia.contentType,
3170
3506
  title: primaryMedia.title,
3171
3507
  isPrimary: true
3172
3508
  };
3509
+ profilePictureCache(this._gedcom, cacheKey, result);
3510
+ return result;
3511
+ }
3512
+ if (onlyPrimary) {
3513
+ profilePictureCache(
3514
+ this._gedcom,
3515
+ cacheKey,
3516
+ void 0
3517
+ );
3518
+ return void 0;
3173
3519
  }
3174
3520
  const secondaryMedia = mediaArray.find(
3175
3521
  (media) => isImageFormat(media.contentType || getFileExtension(media.url))
3176
3522
  );
3177
3523
  if (secondaryMedia) {
3178
- return {
3524
+ const result = {
3179
3525
  file: secondaryMedia.url,
3180
3526
  form: secondaryMedia.contentType,
3181
3527
  title: secondaryMedia.title,
3182
3528
  isPrimary: false
3183
3529
  };
3530
+ profilePictureCache(this._gedcom, cacheKey, result);
3531
+ return result;
3184
3532
  }
3533
+ profilePictureCache(
3534
+ this._gedcom,
3535
+ cacheKey,
3536
+ void 0
3537
+ );
3185
3538
  return void 0;
3186
3539
  }
3187
3540
  link(poolId) {
@@ -3549,7 +3902,7 @@ var Indi = class extends Common {
3549
3902
  return;
3550
3903
  }
3551
3904
  const cacheKey = `${this.id}|${usedIndi.id}`;
3552
- const cache = pathCache(cacheKey);
3905
+ const cache = pathCache(this._gedcom, cacheKey);
3553
3906
  if (cache) {
3554
3907
  return cache;
3555
3908
  }
@@ -3594,7 +3947,7 @@ var Indi = class extends Common {
3594
3947
  if (breakOnNext) {
3595
3948
  return void 0;
3596
3949
  }
3597
- pathCache(cacheKey, path2);
3950
+ pathCache(this._gedcom, cacheKey, path2);
3598
3951
  return path2;
3599
3952
  }
3600
3953
  visited.append(indi);
@@ -3764,7 +4117,7 @@ var Indi = class extends Common {
3764
4117
  }
3765
4118
  getRelativesOnDegree(degree = 0) {
3766
4119
  this.id = this.id || `@I${Math.random()}@`;
3767
- const cache = relativesOnDegreeCache(this.id, degree);
4120
+ const cache = relativesOnDegreeCache(this._gedcom, this.id, degree);
3768
4121
  if (cache) {
3769
4122
  return cache;
3770
4123
  }
@@ -3772,6 +4125,7 @@ var Indi = class extends Common {
3772
4125
  const excludes = persons;
3773
4126
  if (!Math.abs(degree)) {
3774
4127
  return relativesOnDegreeCache(
4128
+ this._gedcom,
3775
4129
  this.id,
3776
4130
  degree,
3777
4131
  persons.except(this)
@@ -3782,11 +4136,11 @@ var Indi = class extends Common {
3782
4136
  excludes.merge(persons);
3783
4137
  persons = this.getRelativesOnLevel(validDegree).getRelativesOnDegree(-validDegree).copy().exclude(excludes);
3784
4138
  }
3785
- return relativesOnDegreeCache(this.id, degree, persons);
4139
+ return relativesOnDegreeCache(this._gedcom, this.id, degree, persons);
3786
4140
  }
3787
4141
  getRelativesOnLevel(level = 0, filter) {
3788
4142
  this.id = this.id || `@I${Math.random()}@`;
3789
- const cache = relativesOnLevelCache(this.id, level);
4143
+ const cache = relativesOnLevelCache(this._gedcom, this.id, level);
3790
4144
  if (cache) {
3791
4145
  return cache;
3792
4146
  }
@@ -3797,7 +4151,7 @@ var Indi = class extends Common {
3797
4151
  };
3798
4152
  let families = this.get(config.key)?.toValueList();
3799
4153
  if (!families) {
3800
- return relativesOnLevelCache(this.id, level, persons);
4154
+ return relativesOnLevelCache(this._gedcom, this.id, level, persons);
3801
4155
  }
3802
4156
  if (filter) {
3803
4157
  families = families.filter(filter);
@@ -3808,7 +4162,12 @@ var Indi = class extends Common {
3808
4162
  persons = this.toFamilies(families).getParents();
3809
4163
  }
3810
4164
  if (level >= -1 && level <= 1) {
3811
- return relativesOnLevelCache(this.id, level, persons.except(this));
4165
+ return relativesOnLevelCache(
4166
+ this._gedcom,
4167
+ this.id,
4168
+ level,
4169
+ persons.except(this)
4170
+ );
3812
4171
  }
3813
4172
  for (let i = 1; i < Math.abs(level); i++) {
3814
4173
  if (config.isAscendant) {
@@ -3817,7 +4176,12 @@ var Indi = class extends Common {
3817
4176
  persons = persons.getParents();
3818
4177
  }
3819
4178
  }
3820
- return relativesOnLevelCache(this.id, level, persons.except(this));
4179
+ return relativesOnLevelCache(
4180
+ this._gedcom,
4181
+ this.id,
4182
+ level,
4183
+ persons.except(this)
4184
+ );
3821
4185
  }
3822
4186
  getAscendants(level = 0, filter) {
3823
4187
  if (!level) {
@@ -3856,7 +4220,12 @@ var Indi = class extends Common {
3856
4220
  }
3857
4221
  currentGen++;
3858
4222
  generations[currentGen] = descentants;
3859
- relativesOnLevelCache(this.id, -currentGen, descentants);
4223
+ relativesOnLevelCache(
4224
+ this._gedcom,
4225
+ this.id,
4226
+ -currentGen,
4227
+ descentants
4228
+ );
3860
4229
  descentants && relatives.merge(descentants);
3861
4230
  }
3862
4231
  return { relatives, generations };
@@ -3889,7 +4258,7 @@ var Indi = class extends Common {
3889
4258
  }
3890
4259
  currentGen++;
3891
4260
  generations[currentGen] = parents;
3892
- relativesOnLevelCache(this.id, currentGen, parents);
4261
+ relativesOnLevelCache(this._gedcom, this.id, currentGen, parents);
3893
4262
  parents && relatives.merge(parents);
3894
4263
  }
3895
4264
  return { relatives, generations };