@treeviz/gedcom-parser 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- export { ao as Common, az as CommonDate, aQ as CommonName, aS as CommonNote, an as CustomTags, am as Existed, aC as Fam, aj as FamType, aE as Families, aL as FamilySearchMatch, aM as FamilySearchSource, aF as GedCom, ak as GedComType, a3 as GenealogyMember, aa as GenerationIndiType, a9 as GenerationSpouseType, aK as Indi, a5 as IndiGenealogy, ab as IndiGenealogyGenerations, ac as IndiGenealogyResult, a6 as IndiMarker, a4 as IndiTree, a1 as IndiType, aO as Individuals, aP as List, a8 as MemberMain, a7 as MemberSide, ad as NonNullIndiGenealogyResult, aU as Obje, al as ObjeType, aW as Objects, af as Path, ae as PathItem, Z as ProxyOriginal, ai as Queue, ah as QueueItem, ag as ReducedPath, aX as Repo, $ as RepoType, aZ as Repositories, a_ as Sour, _ as SourType, b0 as Sources, b1 as Subm, a0 as SubmType, b3 as Submitters, a2 as TreeMember, aq as createCommon, aA as createCommonDate, aR as createCommonName, aT as createCommonNote, aD as createFam, aG as createGedCom, aN as createIndi, aV as createObje, ap as createProxy, aY as createRepo, a$ as createSour, b2 as createSubm, av as getListTag, aw as getValidKey, at as getValidKeys, au as getValidTag, ay as idGetter, aB as isCommonDate, aH as isGedcomString, ax as isId, ar as isOnlyMainProp, as as isValidKey, aJ as mergeGedcoms, aI as validateGedcomContent } from '../index-DOapi7nN.js';
1
+ export { ao as Common, az as CommonDate, aR as CommonName, aT as CommonNote, an as CustomTags, am as Existed, aC as Fam, aj as FamType, aE as Families, aL as FamilySearchMatch, aM as FamilySearchSource, aF as GedCom, ak as GedComType, a3 as GenealogyMember, aa as GenerationIndiType, a9 as GenerationSpouseType, aK as Indi, a5 as IndiGenealogy, ab as IndiGenealogyGenerations, ac as IndiGenealogyResult, a6 as IndiMarker, a4 as IndiTree, a1 as IndiType, aP as Individuals, aQ as List, a8 as MemberMain, a7 as MemberSide, ad as NonNullIndiGenealogyResult, aV as Obje, al as ObjeType, aX as Objects, af as Path, ae as PathItem, aN as ProfilePicture, Z as ProxyOriginal, ai as Queue, ah as QueueItem, ag as ReducedPath, aY as Repo, $ as RepoType, a_ as Repositories, a$ as Sour, _ as SourType, b1 as Sources, b2 as Subm, a0 as SubmType, b4 as Submitters, a2 as TreeMember, aq as createCommon, aA as createCommonDate, aS as createCommonName, aU as createCommonNote, aD as createFam, aG as createGedCom, aO as createIndi, aW as createObje, ap as createProxy, aZ as createRepo, b0 as createSour, b3 as createSubm, av as getListTag, aw as getValidKey, at as getValidKeys, au as getValidTag, ay as idGetter, aB as isCommonDate, aH as isGedcomString, ax as isId, ar as isOnlyMainProp, as as isValidKey, aJ as mergeGedcoms, aI as validateGedcomContent } from '../index-BPEVN_DY.js';
2
2
  import 'date-fns';
@@ -3158,6 +3158,27 @@ var getPlaces = (common, type = ["ALL" /* All */], maxLevel = 1, level = 0, main
3158
3158
  };
3159
3159
  var implemented = (type, ...args) => {
3160
3160
  };
3161
+
3162
+ // src/utils/media-utils.ts
3163
+ var getFileExtension = (filename) => {
3164
+ const match = filename.match(/\.([^.]+)$/);
3165
+ return match ? match[1] : "";
3166
+ };
3167
+ var isImageFormat = (format2) => {
3168
+ if (!format2) return false;
3169
+ const imageFormats = [
3170
+ "jpg",
3171
+ "jpeg",
3172
+ "png",
3173
+ "gif",
3174
+ "bmp",
3175
+ "webp",
3176
+ "svg",
3177
+ "tiff",
3178
+ "tif"
3179
+ ];
3180
+ return imageFormats.includes(format2.toLowerCase());
3181
+ };
3161
3182
  var uniqueItemsCache = /* @__PURE__ */ new WeakMap();
3162
3183
  var setNestedGroup = (obj, key, value, uniqueCounting = true) => {
3163
3184
  const parts = Array.isArray(key) ? key : key.split(/,\s*/);
@@ -4340,54 +4361,62 @@ var Indi = class extends Common {
4340
4361
  }
4341
4362
  async ancestryMedia(namespace) {
4342
4363
  const list = {};
4343
- const objIds = this.get("OBJE")?.toValueList().keys() ?? [];
4364
+ const objeList = this.get("OBJE")?.toList();
4344
4365
  const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
4345
4366
  const tree = this.getAncestryTreeId();
4346
- await Promise.all(
4347
- objIds.map(async (objId) => {
4348
- const key = objId;
4349
- const obje = this._gedcom?.obje(key)?.standardizeMedia(namespace, true, (ns, iId) => {
4350
- return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
4351
- });
4352
- const media = obje?.RIN?.value;
4353
- const clone = obje?.get("_CLON._OID")?.toValue();
4354
- const mser = obje?.get("_MSER._LKID")?.toValue();
4355
- let url = obje?.get("FILE")?.toValue();
4356
- const title = obje?.get("TITL")?.toValue() ?? "";
4357
- const type = obje?.get("FORM")?.toValue() ?? "raw";
4358
- const imgId = clone || mser;
4359
- if (!www || !tree || !this.id) {
4360
- return;
4361
- }
4362
- if (!namespace && !url) {
4363
- try {
4364
- const mediaDetailsResponse = await fetch(
4365
- `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
4366
- );
4367
- const mediaDetails = await mediaDetailsResponse.json();
4368
- if (mediaDetails.url) {
4369
- url = `${mediaDetails.url}&imageQuality=hq`;
4367
+ if (objeList) {
4368
+ await Promise.all(
4369
+ objeList.map(async (objeRef) => {
4370
+ const key = objeRef?.id;
4371
+ const obje = objeRef?.standardizeMedia(
4372
+ namespace,
4373
+ true,
4374
+ (ns, iId) => {
4375
+ return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
4370
4376
  }
4371
- } catch (_e) {
4377
+ );
4378
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
4379
+ const media = obje?.RIN?.value;
4380
+ const clone = obje?.get("_CLON._OID")?.toValue();
4381
+ const mser = obje?.get("_MSER._LKID")?.toValue();
4382
+ let url = obje?.get("FILE")?.toValue();
4383
+ const title = obje?.get("TITL")?.toValue() ?? "";
4384
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
4385
+ const imgId = clone || mser;
4386
+ if (!www || !tree || !this.id) {
4387
+ return;
4372
4388
  }
4373
- url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
4374
- }
4375
- if (url && imgId) {
4376
- const id = `${tree}-${this.id}-${imgId}`;
4377
- list[id] = {
4378
- key,
4379
- id,
4380
- tree,
4381
- imgId,
4382
- person: this.id,
4383
- title,
4384
- url,
4385
- contentType: type,
4386
- downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4387
- };
4388
- }
4389
- })
4390
- );
4389
+ if (!namespace && !url) {
4390
+ try {
4391
+ const mediaDetailsResponse = await fetch(
4392
+ `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
4393
+ );
4394
+ const mediaDetails = await mediaDetailsResponse.json();
4395
+ if (mediaDetails.url) {
4396
+ url = `${mediaDetails.url}&imageQuality=hq`;
4397
+ }
4398
+ } catch (_e) {
4399
+ }
4400
+ url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
4401
+ }
4402
+ if (url && imgId) {
4403
+ const id = `${tree}-${this.id}-${imgId}`;
4404
+ list[id] = {
4405
+ key,
4406
+ isPrimary,
4407
+ id,
4408
+ tree,
4409
+ imgId,
4410
+ person: this.id,
4411
+ title,
4412
+ url,
4413
+ contentType: type,
4414
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
4415
+ };
4416
+ }
4417
+ })
4418
+ );
4419
+ }
4391
4420
  return list;
4392
4421
  }
4393
4422
  myheritageLink(poolId = 0) {
@@ -4406,18 +4435,20 @@ var Indi = class extends Common {
4406
4435
  if (!tree) {
4407
4436
  return;
4408
4437
  }
4409
- const birthObj = this.get("BIRT.OBJE")?.toList().values();
4410
- const deathObj = this.get("DEAT.OBJE")?.toValueList().values();
4411
- const familiesObj = (this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).map((fam) => {
4412
- return fam?.get("MARR.OBJE");
4438
+ const objeList = this.get("OBJE")?.toList();
4439
+ const birthObj = this.get("BIRT.OBJE")?.toList();
4440
+ const deathObj = this.get("DEAT.OBJE")?.toList();
4441
+ (this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).forEach((fam) => {
4442
+ objeList?.merge(birthObj).merge(deathObj).merge(fam?.get("MARR.OBJE"));
4413
4443
  });
4414
- (birthObj ?? []).concat(deathObj ?? []).concat(familiesObj ?? []).forEach((o, index) => {
4444
+ objeList?.forEach((o, index) => {
4415
4445
  if (!o) {
4416
4446
  return;
4417
4447
  }
4418
4448
  const obje = o;
4419
4449
  const key = `@O${index}@`;
4420
4450
  obje.standardizeMedia();
4451
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
4421
4452
  const url = obje?.get("FILE")?.toValue();
4422
4453
  const title = obje?.get("NOTE")?.toValue() ?? "";
4423
4454
  const type = obje?.get("FORM")?.toValue() ?? "raw";
@@ -4425,6 +4456,7 @@ var Indi = class extends Common {
4425
4456
  if (url && imgId) {
4426
4457
  const id = `${tree}-${this.id}-${imgId}`;
4427
4458
  list[id] = {
4459
+ isPrimary,
4428
4460
  key,
4429
4461
  id,
4430
4462
  tree,
@@ -4534,6 +4566,36 @@ var Indi = class extends Common {
4534
4566
  }
4535
4567
  return void 0;
4536
4568
  }
4569
+ async getProfilePicture(namespace) {
4570
+ const mediaList = await this.multimedia(namespace);
4571
+ if (!mediaList) {
4572
+ return void 0;
4573
+ }
4574
+ const mediaArray = Object.values(mediaList);
4575
+ const primaryMedia = mediaArray.find(
4576
+ (media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
4577
+ );
4578
+ if (primaryMedia) {
4579
+ return {
4580
+ file: primaryMedia.url,
4581
+ form: primaryMedia.contentType,
4582
+ title: primaryMedia.title,
4583
+ isPrimary: true
4584
+ };
4585
+ }
4586
+ const secondaryMedia = mediaArray.find(
4587
+ (media) => isImageFormat(media.contentType || getFileExtension(media.url))
4588
+ );
4589
+ if (secondaryMedia) {
4590
+ return {
4591
+ file: secondaryMedia.url,
4592
+ form: secondaryMedia.contentType,
4593
+ title: secondaryMedia.title,
4594
+ isPrimary: false
4595
+ };
4596
+ }
4597
+ return void 0;
4598
+ }
4537
4599
  link(poolId) {
4538
4600
  if (this?.isAncestry()) {
4539
4601
  return this.ancestryLink();
@@ -5823,7 +5885,7 @@ var createIndi = (gedcom, id, main, parent) => {
5823
5885
 
5824
5886
  // package.json
5825
5887
  var package_default = {
5826
- version: "1.0.20"};
5888
+ version: "1.0.22"};
5827
5889
 
5828
5890
  // src/utils/get-product-details.ts
5829
5891
  var getVersion = () => package_default.version;
package/dist/cli/index.js CHANGED
@@ -1287,6 +1287,27 @@ var getPlaces = (common, type = ["ALL" /* All */], maxLevel = 1, level = 0, main
1287
1287
  var implemented = (type, ...args) => {
1288
1288
  };
1289
1289
 
1290
+ // src/utils/media-utils.ts
1291
+ var getFileExtension = (filename) => {
1292
+ const match = filename.match(/\.([^.]+)$/);
1293
+ return match ? match[1] : "";
1294
+ };
1295
+ var isImageFormat = (format2) => {
1296
+ if (!format2) return false;
1297
+ const imageFormats = [
1298
+ "jpg",
1299
+ "jpeg",
1300
+ "png",
1301
+ "gif",
1302
+ "bmp",
1303
+ "webp",
1304
+ "svg",
1305
+ "tiff",
1306
+ "tif"
1307
+ ];
1308
+ return imageFormats.includes(format2.toLowerCase());
1309
+ };
1310
+
1290
1311
  // src/classes/name.ts
1291
1312
  var CommonName = class extends Common {
1292
1313
  constructor(gedcom, id, main, parent) {
@@ -1906,54 +1927,62 @@ var Indi = class extends Common {
1906
1927
  }
1907
1928
  async ancestryMedia(namespace) {
1908
1929
  const list = {};
1909
- const objIds = this.get("OBJE")?.toValueList().keys() ?? [];
1930
+ const objeList = this.get("OBJE")?.toList();
1910
1931
  const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
1911
1932
  const tree = this.getAncestryTreeId();
1912
- await Promise.all(
1913
- objIds.map(async (objId) => {
1914
- const key = objId;
1915
- const obje = this._gedcom?.obje(key)?.standardizeMedia(namespace, true, (ns, iId) => {
1916
- return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
1917
- });
1918
- const media = obje?.RIN?.value;
1919
- const clone = obje?.get("_CLON._OID")?.toValue();
1920
- const mser = obje?.get("_MSER._LKID")?.toValue();
1921
- let url = obje?.get("FILE")?.toValue();
1922
- const title = obje?.get("TITL")?.toValue() ?? "";
1923
- const type = obje?.get("FORM")?.toValue() ?? "raw";
1924
- const imgId = clone || mser;
1925
- if (!www || !tree || !this.id) {
1926
- return;
1927
- }
1928
- if (!namespace && !url) {
1929
- try {
1930
- const mediaDetailsResponse = await fetch(
1931
- `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
1932
- );
1933
- const mediaDetails = await mediaDetailsResponse.json();
1934
- if (mediaDetails.url) {
1935
- url = `${mediaDetails.url}&imageQuality=hq`;
1933
+ if (objeList) {
1934
+ await Promise.all(
1935
+ objeList.map(async (objeRef) => {
1936
+ const key = objeRef?.id;
1937
+ const obje = objeRef?.standardizeMedia(
1938
+ namespace,
1939
+ true,
1940
+ (ns, iId) => {
1941
+ return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
1936
1942
  }
1937
- } catch (_e) {
1943
+ );
1944
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
1945
+ const media = obje?.RIN?.value;
1946
+ const clone = obje?.get("_CLON._OID")?.toValue();
1947
+ const mser = obje?.get("_MSER._LKID")?.toValue();
1948
+ let url = obje?.get("FILE")?.toValue();
1949
+ const title = obje?.get("TITL")?.toValue() ?? "";
1950
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
1951
+ const imgId = clone || mser;
1952
+ if (!www || !tree || !this.id) {
1953
+ return;
1938
1954
  }
1939
- url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
1940
- }
1941
- if (url && imgId) {
1942
- const id = `${tree}-${this.id}-${imgId}`;
1943
- list[id] = {
1944
- key,
1945
- id,
1946
- tree,
1947
- imgId,
1948
- person: this.id,
1949
- title,
1950
- url,
1951
- contentType: type,
1952
- downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
1953
- };
1954
- }
1955
- })
1956
- );
1955
+ if (!namespace && !url) {
1956
+ try {
1957
+ const mediaDetailsResponse = await fetch(
1958
+ `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
1959
+ );
1960
+ const mediaDetails = await mediaDetailsResponse.json();
1961
+ if (mediaDetails.url) {
1962
+ url = `${mediaDetails.url}&imageQuality=hq`;
1963
+ }
1964
+ } catch (_e) {
1965
+ }
1966
+ url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
1967
+ }
1968
+ if (url && imgId) {
1969
+ const id = `${tree}-${this.id}-${imgId}`;
1970
+ list[id] = {
1971
+ key,
1972
+ isPrimary,
1973
+ id,
1974
+ tree,
1975
+ imgId,
1976
+ person: this.id,
1977
+ title,
1978
+ url,
1979
+ contentType: type,
1980
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
1981
+ };
1982
+ }
1983
+ })
1984
+ );
1985
+ }
1957
1986
  return list;
1958
1987
  }
1959
1988
  myheritageLink(poolId = 0) {
@@ -1972,18 +2001,20 @@ var Indi = class extends Common {
1972
2001
  if (!tree) {
1973
2002
  return;
1974
2003
  }
1975
- const birthObj = this.get("BIRT.OBJE")?.toList().values();
1976
- const deathObj = this.get("DEAT.OBJE")?.toValueList().values();
1977
- const familiesObj = (this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).map((fam) => {
1978
- return fam?.get("MARR.OBJE");
2004
+ const objeList = this.get("OBJE")?.toList();
2005
+ const birthObj = this.get("BIRT.OBJE")?.toList();
2006
+ const deathObj = this.get("DEAT.OBJE")?.toList();
2007
+ (this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).forEach((fam) => {
2008
+ objeList?.merge(birthObj).merge(deathObj).merge(fam?.get("MARR.OBJE"));
1979
2009
  });
1980
- (birthObj ?? []).concat(deathObj ?? []).concat(familiesObj ?? []).forEach((o, index) => {
2010
+ objeList?.forEach((o, index) => {
1981
2011
  if (!o) {
1982
2012
  return;
1983
2013
  }
1984
2014
  const obje = o;
1985
2015
  const key = `@O${index}@`;
1986
2016
  obje.standardizeMedia();
2017
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
1987
2018
  const url = obje?.get("FILE")?.toValue();
1988
2019
  const title = obje?.get("NOTE")?.toValue() ?? "";
1989
2020
  const type = obje?.get("FORM")?.toValue() ?? "raw";
@@ -1991,6 +2022,7 @@ var Indi = class extends Common {
1991
2022
  if (url && imgId) {
1992
2023
  const id = `${tree}-${this.id}-${imgId}`;
1993
2024
  list[id] = {
2025
+ isPrimary,
1994
2026
  key,
1995
2027
  id,
1996
2028
  tree,
@@ -2100,6 +2132,36 @@ var Indi = class extends Common {
2100
2132
  }
2101
2133
  return void 0;
2102
2134
  }
2135
+ async getProfilePicture(namespace) {
2136
+ const mediaList = await this.multimedia(namespace);
2137
+ if (!mediaList) {
2138
+ return void 0;
2139
+ }
2140
+ const mediaArray = Object.values(mediaList);
2141
+ const primaryMedia = mediaArray.find(
2142
+ (media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
2143
+ );
2144
+ if (primaryMedia) {
2145
+ return {
2146
+ file: primaryMedia.url,
2147
+ form: primaryMedia.contentType,
2148
+ title: primaryMedia.title,
2149
+ isPrimary: true
2150
+ };
2151
+ }
2152
+ const secondaryMedia = mediaArray.find(
2153
+ (media) => isImageFormat(media.contentType || getFileExtension(media.url))
2154
+ );
2155
+ if (secondaryMedia) {
2156
+ return {
2157
+ file: secondaryMedia.url,
2158
+ form: secondaryMedia.contentType,
2159
+ title: secondaryMedia.title,
2160
+ isPrimary: false
2161
+ };
2162
+ }
2163
+ return void 0;
2164
+ }
2103
2165
  link(poolId) {
2104
2166
  if (this?.isAncestry()) {
2105
2167
  return this.ancestryLink();
@@ -5816,7 +5878,7 @@ var Families = class _Families extends List {
5816
5878
 
5817
5879
  // package.json
5818
5880
  var package_default = {
5819
- version: "1.0.20"};
5881
+ version: "1.0.22"};
5820
5882
 
5821
5883
  // src/utils/get-product-details.ts
5822
5884
  var isDevelopment = () => {
@@ -1,4 +1,4 @@
1
- import { x as Filter, y as RequiredFilter, W as RelationType, X as PartnerType, A as Order, K as NameOrder, B as OrderIterator, a1 as IndiType, n as IndiKey } from '../index-DOapi7nN.js';
1
+ import { x as Filter, y as RequiredFilter, W as RelationType, X as PartnerType, A as Order, K as NameOrder, B as OrderIterator, a1 as IndiType, n as IndiKey } from '../index-BPEVN_DY.js';
2
2
  import 'date-fns';
3
3
 
4
4
  /**
@@ -1291,6 +1291,27 @@ var getPlaces = (common, type = ["ALL" /* All */], maxLevel = 1, level = 0, main
1291
1291
  };
1292
1292
  var implemented = (type, ...args) => {
1293
1293
  };
1294
+
1295
+ // src/utils/media-utils.ts
1296
+ var getFileExtension = (filename) => {
1297
+ const match = filename.match(/\.([^.]+)$/);
1298
+ return match ? match[1] : "";
1299
+ };
1300
+ var isImageFormat = (format2) => {
1301
+ if (!format2) return false;
1302
+ const imageFormats = [
1303
+ "jpg",
1304
+ "jpeg",
1305
+ "png",
1306
+ "gif",
1307
+ "bmp",
1308
+ "webp",
1309
+ "svg",
1310
+ "tiff",
1311
+ "tif"
1312
+ ];
1313
+ return imageFormats.includes(format2.toLowerCase());
1314
+ };
1294
1315
  var uniqueItemsCache = /* @__PURE__ */ new WeakMap();
1295
1316
  var setNestedGroup = (obj, key, value, uniqueCounting = true) => {
1296
1317
  const parts = Array.isArray(key) ? key : key.split(/,\s*/);
@@ -2501,54 +2522,62 @@ var Indi = class extends Common {
2501
2522
  }
2502
2523
  async ancestryMedia(namespace) {
2503
2524
  const list = {};
2504
- const objIds = this.get("OBJE")?.toValueList().keys() ?? [];
2525
+ const objeList = this.get("OBJE")?.toList();
2505
2526
  const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
2506
2527
  const tree = this.getAncestryTreeId();
2507
- await Promise.all(
2508
- objIds.map(async (objId) => {
2509
- const key = objId;
2510
- const obje = this._gedcom?.obje(key)?.standardizeMedia(namespace, true, (ns, iId) => {
2511
- return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
2512
- });
2513
- const media = obje?.RIN?.value;
2514
- const clone = obje?.get("_CLON._OID")?.toValue();
2515
- const mser = obje?.get("_MSER._LKID")?.toValue();
2516
- let url = obje?.get("FILE")?.toValue();
2517
- const title = obje?.get("TITL")?.toValue() ?? "";
2518
- const type = obje?.get("FORM")?.toValue() ?? "raw";
2519
- const imgId = clone || mser;
2520
- if (!www || !tree || !this.id) {
2521
- return;
2522
- }
2523
- if (!namespace && !url) {
2524
- try {
2525
- const mediaDetailsResponse = await fetch(
2526
- `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
2527
- );
2528
- const mediaDetails = await mediaDetailsResponse.json();
2529
- if (mediaDetails.url) {
2530
- url = `${mediaDetails.url}&imageQuality=hq`;
2528
+ if (objeList) {
2529
+ await Promise.all(
2530
+ objeList.map(async (objeRef) => {
2531
+ const key = objeRef?.id;
2532
+ const obje = objeRef?.standardizeMedia(
2533
+ namespace,
2534
+ true,
2535
+ (ns, iId) => {
2536
+ return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
2531
2537
  }
2532
- } catch (_e) {
2538
+ );
2539
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
2540
+ const media = obje?.RIN?.value;
2541
+ const clone = obje?.get("_CLON._OID")?.toValue();
2542
+ const mser = obje?.get("_MSER._LKID")?.toValue();
2543
+ let url = obje?.get("FILE")?.toValue();
2544
+ const title = obje?.get("TITL")?.toValue() ?? "";
2545
+ const type = obje?.get("FORM")?.toValue() ?? "raw";
2546
+ const imgId = clone || mser;
2547
+ if (!www || !tree || !this.id) {
2548
+ return;
2533
2549
  }
2534
- url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
2535
- }
2536
- if (url && imgId) {
2537
- const id = `${tree}-${this.id}-${imgId}`;
2538
- list[id] = {
2539
- key,
2540
- id,
2541
- tree,
2542
- imgId,
2543
- person: this.id,
2544
- title,
2545
- url,
2546
- contentType: type,
2547
- downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
2548
- };
2549
- }
2550
- })
2551
- );
2550
+ if (!namespace && !url) {
2551
+ try {
2552
+ const mediaDetailsResponse = await fetch(
2553
+ `https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
2554
+ );
2555
+ const mediaDetails = await mediaDetailsResponse.json();
2556
+ if (mediaDetails.url) {
2557
+ url = `${mediaDetails.url}&imageQuality=hq`;
2558
+ }
2559
+ } catch (_e) {
2560
+ }
2561
+ url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
2562
+ }
2563
+ if (url && imgId) {
2564
+ const id = `${tree}-${this.id}-${imgId}`;
2565
+ list[id] = {
2566
+ key,
2567
+ isPrimary,
2568
+ id,
2569
+ tree,
2570
+ imgId,
2571
+ person: this.id,
2572
+ title,
2573
+ url,
2574
+ contentType: type,
2575
+ downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
2576
+ };
2577
+ }
2578
+ })
2579
+ );
2580
+ }
2552
2581
  return list;
2553
2582
  }
2554
2583
  myheritageLink(poolId = 0) {
@@ -2567,18 +2596,20 @@ var Indi = class extends Common {
2567
2596
  if (!tree) {
2568
2597
  return;
2569
2598
  }
2570
- const birthObj = this.get("BIRT.OBJE")?.toList().values();
2571
- const deathObj = this.get("DEAT.OBJE")?.toValueList().values();
2572
- const familiesObj = (this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).map((fam) => {
2573
- return fam?.get("MARR.OBJE");
2599
+ const objeList = this.get("OBJE")?.toList();
2600
+ const birthObj = this.get("BIRT.OBJE")?.toList();
2601
+ const deathObj = this.get("DEAT.OBJE")?.toList();
2602
+ (this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).forEach((fam) => {
2603
+ objeList?.merge(birthObj).merge(deathObj).merge(fam?.get("MARR.OBJE"));
2574
2604
  });
2575
- (birthObj ?? []).concat(deathObj ?? []).concat(familiesObj ?? []).forEach((o, index) => {
2605
+ objeList?.forEach((o, index) => {
2576
2606
  if (!o) {
2577
2607
  return;
2578
2608
  }
2579
2609
  const obje = o;
2580
2610
  const key = `@O${index}@`;
2581
2611
  obje.standardizeMedia();
2612
+ const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
2582
2613
  const url = obje?.get("FILE")?.toValue();
2583
2614
  const title = obje?.get("NOTE")?.toValue() ?? "";
2584
2615
  const type = obje?.get("FORM")?.toValue() ?? "raw";
@@ -2586,6 +2617,7 @@ var Indi = class extends Common {
2586
2617
  if (url && imgId) {
2587
2618
  const id = `${tree}-${this.id}-${imgId}`;
2588
2619
  list[id] = {
2620
+ isPrimary,
2589
2621
  key,
2590
2622
  id,
2591
2623
  tree,
@@ -2695,6 +2727,36 @@ var Indi = class extends Common {
2695
2727
  }
2696
2728
  return void 0;
2697
2729
  }
2730
+ async getProfilePicture(namespace) {
2731
+ const mediaList = await this.multimedia(namespace);
2732
+ if (!mediaList) {
2733
+ return void 0;
2734
+ }
2735
+ const mediaArray = Object.values(mediaList);
2736
+ const primaryMedia = mediaArray.find(
2737
+ (media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
2738
+ );
2739
+ if (primaryMedia) {
2740
+ return {
2741
+ file: primaryMedia.url,
2742
+ form: primaryMedia.contentType,
2743
+ title: primaryMedia.title,
2744
+ isPrimary: true
2745
+ };
2746
+ }
2747
+ const secondaryMedia = mediaArray.find(
2748
+ (media) => isImageFormat(media.contentType || getFileExtension(media.url))
2749
+ );
2750
+ if (secondaryMedia) {
2751
+ return {
2752
+ file: secondaryMedia.url,
2753
+ form: secondaryMedia.contentType,
2754
+ title: secondaryMedia.title,
2755
+ isPrimary: false
2756
+ };
2757
+ }
2758
+ return void 0;
2759
+ }
2698
2760
  link(poolId) {
2699
2761
  if (this?.isAncestry()) {
2700
2762
  return this.ancestryLink();
@@ -1,6 +1,6 @@
1
- import { I as ICacheManager, P as PlaceParts } from '../place-parser-CIplmmDd.js';
1
+ import { I as ICacheManager, P as PlaceParts } from '../place-parser-CM0TJFj8.js';
2
2
  import { Locale } from 'date-fns';
3
- import { a1 as IndiType, n as IndiKey, L as Language } from '../index-DOapi7nN.js';
3
+ import { a1 as IndiType, n as IndiKey, L as Language } from '../index-BPEVN_DY.js';
4
4
 
5
5
  /**
6
6
  * Factory function type for creating cache manager instances.