gedcom-ts 1.1.0 → 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.
Files changed (42) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +228 -35
  3. package/dist/commons/Act.d.ts +38 -5
  4. package/dist/commons/ActsByYears.d.ts +10 -0
  5. package/dist/commons/DateAct.d.ts +24 -5
  6. package/dist/commons/MultimediaFile.d.ts +14 -0
  7. package/dist/commons/Note.d.ts +18 -0
  8. package/dist/commons/Person.d.ts +44 -0
  9. package/dist/commons/Place.d.ts +7 -9
  10. package/dist/export/GEDCOM.d.ts +46 -37
  11. package/dist/import/LoadFile.d.ts +2 -0
  12. package/dist/import/ReadGed.d.ts +17 -17
  13. package/dist/import/SplitedInformations.d.ts +13 -0
  14. package/dist/index.cjs +1 -0
  15. package/dist/index.d.ts +12 -4
  16. package/dist/index.mjs +1 -0
  17. package/dist/services/CitySearch.d.ts +2 -0
  18. package/dist/utils/acts-helper/acts-helper.d.ts +2 -0
  19. package/dist/utils/gedcom/formatNoteForExport.d.ts +12 -0
  20. package/dist/utils/gedcom/parseGedcomLine.d.ts +13 -0
  21. package/dist/utils/indi/indi.d.ts +2 -0
  22. package/dist/utils/multimedia/nextAvailableRelativeMediaPath.d.ts +9 -0
  23. package/dist/utils/sosa/calculate-sosa.d.ts +2 -0
  24. package/package.json +52 -14
  25. package/CHANGELOG.md +0 -58
  26. package/dist/commons/Act.js +0 -19
  27. package/dist/commons/DateAct.js +0 -128
  28. package/dist/commons/Identificator.enum.js +0 -134
  29. package/dist/commons/People.d.ts +0 -29
  30. package/dist/commons/People.js +0 -80
  31. package/dist/commons/Place.js +0 -20
  32. package/dist/commons/Separators.js +0 -6
  33. package/dist/commons/Utils-Date.d.ts +0 -6
  34. package/dist/commons/Utils-Date.js +0 -43
  35. package/dist/commons/Utils-People.d.ts +0 -2
  36. package/dist/commons/Utils-People.js +0 -11
  37. package/dist/commons/Utils.d.ts +0 -2
  38. package/dist/commons/Utils.js +0 -5
  39. package/dist/export/GEDCOM.js +0 -191
  40. package/dist/import/ReadGed.js +0 -93
  41. package/dist/index.js +0 -14
  42. package/webpack.config.ts +0 -28
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var TypeDateAct;
4
- (function (TypeDateAct) {
5
- TypeDateAct["BEF"] = "BEF";
6
- TypeDateAct["ABT"] = "ABT";
7
- TypeDateAct["NULL"] = "NULL";
8
- })(TypeDateAct = exports.TypeDateAct || (exports.TypeDateAct = {}));
9
- class DateAct {
10
- constructor(dateLine) {
11
- if (dateLine && dateLine !== 'inconnue') {
12
- const dateParts = dateLine.split(' ');
13
- switch (dateParts.length) {
14
- case 1:
15
- if (dateParts[0].includes('/')) {
16
- const [month, year] = dateParts[0].split('/');
17
- this.month = this.convertMonth(month);
18
- this.year = year;
19
- }
20
- else {
21
- this.year = dateParts[0];
22
- }
23
- break;
24
- case 2:
25
- if (dateParts[0] === TypeDateAct.BEF || dateParts[0] === TypeDateAct.ABT) {
26
- this.typeDateAct = dateParts[0];
27
- if (dateParts[1].includes('/')) {
28
- const [month, year] = dateParts[1].split('/');
29
- this.month = this.convertMonth(month);
30
- this.year = year;
31
- }
32
- else {
33
- this.month = '';
34
- this.year = dateParts[1];
35
- }
36
- }
37
- else if (dateParts[0].includes('/')) {
38
- const [month, year] = dateParts[0].split('/');
39
- this.month = this.convertMonth(month);
40
- this.year = year;
41
- }
42
- else {
43
- this.month = dateParts[0];
44
- this.year = dateParts[1];
45
- }
46
- break;
47
- case 3:
48
- if (dateParts[0] === TypeDateAct.BEF || dateParts[0] === TypeDateAct.ABT) {
49
- this.typeDateAct = dateParts[0];
50
- this.month = dateParts[1];
51
- this.year = dateParts[2];
52
- }
53
- else if (dateParts[1].includes('/')) {
54
- const [month, year] = dateParts[1].split('/');
55
- this.month = this.convertMonth(month);
56
- this.year = year;
57
- }
58
- else {
59
- this.day = dateParts[0];
60
- this.month = dateParts[1];
61
- this.year = dateParts[2];
62
- }
63
- break;
64
- }
65
- this.date = this.parseDate();
66
- }
67
- }
68
- convertMonth(month) {
69
- const monthMap = {
70
- '1': 'JAN',
71
- '2': 'FEB',
72
- '3': 'MAR',
73
- '4': 'APR',
74
- '5': 'MAY',
75
- '6': 'JUN',
76
- '7': 'JUL',
77
- '8': 'AUG',
78
- '9': 'SEP',
79
- '10': 'OCT',
80
- '11': 'NOV',
81
- '12': 'DEC',
82
- };
83
- if (monthMap[month]) {
84
- return monthMap[month];
85
- }
86
- return month.toUpperCase();
87
- }
88
- parseDate() {
89
- const months = {
90
- JAN: 0,
91
- FEB: 1,
92
- MAR: 2,
93
- APR: 3,
94
- MAY: 4,
95
- JUN: 5,
96
- JUL: 6,
97
- AUG: 7,
98
- SEP: 8,
99
- OCT: 9,
100
- NOV: 10,
101
- DEC: 11,
102
- };
103
- if (!this.year) {
104
- return null; // Année manquante, la date ne peut pas être analysée
105
- }
106
- let day = 1;
107
- if (this.day) {
108
- day = parseInt(this.day, 10);
109
- if (isNaN(day)) {
110
- return null; // Jour invalide
111
- }
112
- }
113
- let month = 0;
114
- if (this.month) {
115
- const monthKey = this.month.toUpperCase();
116
- month = months[monthKey];
117
- if (month === undefined) {
118
- return null; // Mois invalide
119
- }
120
- }
121
- let year = parseInt(this.year, 10);
122
- if (isNaN(year)) {
123
- return null; // Année invalide
124
- }
125
- return new Date(year, month, day);
126
- }
127
- }
128
- exports.DateAct = DateAct;
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var Identificator;
4
- (function (Identificator) {
5
- Identificator["ABBR"] = "ABBR";
6
- Identificator["ADDR"] = "ADDR";
7
- Identificator["ADR1"] = "ADDR1";
8
- Identificator["ADR2"] = "ADDR2";
9
- Identificator["ADOP"] = "ADOP";
10
- Identificator["AFN"] = "AFN";
11
- Identificator["AGE"] = "AGE";
12
- Identificator["AGNC"] = "AGNC";
13
- Identificator["ALIA"] = "ALIA";
14
- Identificator["ANCE"] = "ANCE";
15
- Identificator["ANCI"] = "ANCI";
16
- Identificator["ANUL"] = "ANUL";
17
- Identificator["ASSO"] = "ASSO";
18
- Identificator["AUTH"] = "AUTH";
19
- Identificator["BAPL"] = "BAPL";
20
- Identificator["BAPM"] = "BAPM";
21
- Identificator["BARM"] = "BARM";
22
- Identificator["BASM"] = "BASM";
23
- Identificator["BIRT"] = "BIRT";
24
- Identificator["BLES"] = "BLES";
25
- Identificator["BLOB"] = "BLOB";
26
- Identificator["BURI"] = "BURI";
27
- Identificator["CALN"] = "CALN";
28
- Identificator["CAST"] = "CAST";
29
- Identificator["CAUS"] = "CAUS";
30
- Identificator["CENS"] = "CENS";
31
- Identificator["CHAN"] = "CHAN";
32
- Identificator["CHAR"] = "CHAR";
33
- Identificator["CHIL"] = "CHIL";
34
- Identificator["CHR"] = "CHR";
35
- Identificator["CHRA"] = "CHRA";
36
- Identificator["CITY"] = "CITY";
37
- Identificator["CONC"] = "CONC";
38
- Identificator["CONF"] = "CONF";
39
- Identificator["CONL"] = "CONL";
40
- Identificator["CONT"] = "CONT";
41
- Identificator["COPR"] = "COPR";
42
- Identificator["CORP"] = "CORP";
43
- Identificator["CREM"] = "CREM";
44
- Identificator["CTRY"] = "CTRY";
45
- Identificator["DATA"] = "DATA";
46
- Identificator["DATE"] = "DATE";
47
- Identificator["DEAT"] = "DEAT";
48
- Identificator["DESC"] = "DESC";
49
- Identificator["DESI"] = "DESI";
50
- Identificator["DEST"] = "DEST";
51
- Identificator["DIV"] = "DIV";
52
- Identificator["DIVF"] = "DIVF";
53
- Identificator["DSCR"] = "DSCR";
54
- Identificator["EDUC"] = "EDUC";
55
- Identificator["EMIG"] = "EMIG";
56
- Identificator["ENDL"] = "ENDL";
57
- Identificator["ENGA"] = "ENGA";
58
- Identificator["EVEN"] = "EVEN";
59
- Identificator["FAM"] = "FAM";
60
- Identificator["FAMC"] = "FAMC";
61
- Identificator["FAMF"] = "FAMF";
62
- Identificator["FAMS"] = "FAMS";
63
- Identificator["FCOM"] = "FCOM";
64
- Identificator["FILE"] = "FILE";
65
- Identificator["FORM"] = "FORM";
66
- Identificator["GEDC"] = "GEDC";
67
- Identificator["GIVN"] = "GIVN";
68
- Identificator["GRAD"] = "GRAD";
69
- Identificator["HEAD"] = "HEAD";
70
- Identificator["HUSB"] = "HUSB";
71
- Identificator["IDNO"] = "IDNO";
72
- Identificator["IMMI"] = "IMMI";
73
- Identificator["INDI"] = "INDI";
74
- Identificator["LANG"] = "LANG";
75
- Identificator["LEGA"] = "LEGA";
76
- Identificator["MARB"] = "MARB";
77
- Identificator["MARC"] = "MARC";
78
- Identificator["MARL"] = "MARL";
79
- Identificator["MARR"] = "MARR";
80
- Identificator["MARS"] = "MARS";
81
- Identificator["MEDI"] = "MEDI";
82
- Identificator["NAME"] = "NAME";
83
- Identificator["NATI"] = "NATI";
84
- Identificator["NATU"] = "NATU";
85
- Identificator["NCHI"] = "NCHI";
86
- Identificator["NICK"] = "NICK";
87
- Identificator["NMR"] = "NMR";
88
- Identificator["NOTE"] = "NOTE";
89
- Identificator["NPFX"] = "NPFX";
90
- Identificator["NSFX"] = "NSFX";
91
- Identificator["OBJE"] = "OBJE";
92
- Identificator["OCCU"] = "OCCU";
93
- Identificator["ORDI"] = "ORDI";
94
- Identificator["ORDN"] = "ORDN";
95
- Identificator["PAGE"] = "PAGE";
96
- Identificator["PEDI"] = "PEDI";
97
- Identificator["PHON"] = "PHON";
98
- Identificator["PLAC"] = "PLAC";
99
- Identificator["POST"] = "POST";
100
- Identificator["PROB"] = "PROB";
101
- Identificator["PROP"] = "PROP";
102
- Identificator["PUBL"] = "PUBL";
103
- Identificator["QUAY"] = "QUAY";
104
- Identificator["REFN"] = "REFN";
105
- Identificator["RELA"] = "RELA";
106
- Identificator["RELI"] = "RELI";
107
- Identificator["REPO"] = "REPO";
108
- Identificator["RESI"] = "RESI";
109
- Identificator["RESN"] = "RESN";
110
- Identificator["RETI"] = "RETI";
111
- Identificator["RFN"] = "RFN";
112
- Identificator["RIN"] = "RIN";
113
- Identificator["ROLE"] = "ROLE";
114
- Identificator["SEX"] = "SEX";
115
- Identificator["SLGC"] = "SLGC";
116
- Identificator["SLGS"] = "SLGS";
117
- Identificator["SOUR"] = "SOUR";
118
- Identificator["SPFX"] = "SPFX";
119
- Identificator["SSN"] = "SSN";
120
- Identificator["STAE"] = "STAE";
121
- Identificator["STAT"] = "STAT";
122
- Identificator["SUBM"] = "SUBM";
123
- Identificator["SUBN"] = "SUBN";
124
- Identificator["SURN"] = "SURN";
125
- Identificator["TEMP"] = "TEMP";
126
- Identificator["TEXT"] = "TEXT";
127
- Identificator["TIME"] = "TIME";
128
- Identificator["TITL"] = "TITL";
129
- Identificator["TRLR"] = "TRLR";
130
- Identificator["TYPE"] = "TYPE";
131
- Identificator["VERS"] = "VERS";
132
- Identificator["WIFE"] = "WIFE";
133
- Identificator["WILL"] = "WILL";
134
- })(Identificator = exports.Identificator || (exports.Identificator = {}));
@@ -1,29 +0,0 @@
1
- import { Act } from './Act';
2
- export declare enum Sex {
3
- M = "M",
4
- F = "F"
5
- }
6
- export declare class People {
7
- sosa: number;
8
- sex: Sex;
9
- firstnames: Array<string>;
10
- lastname: string;
11
- birth: Act;
12
- marriage: Act;
13
- death: Act;
14
- FAMC: number;
15
- FAMS: number[];
16
- photo: string;
17
- constructor(sosa?: number, sex?: Sex, firstnames?: Array<string>, lastname?: string, birth?: Act, marriage?: Act, death?: Act, FAMC?: number, FAMS?: number[], photo?: string);
18
- createPeopleJson(peopleLines: string[]): void;
19
- private createFirstnamesAndLastnameJson;
20
- private createSex;
21
- private createFAM;
22
- private createPhoto;
23
- private createBirthDeathAct;
24
- }
25
- export declare class TreePeople extends People {
26
- parents: People[];
27
- childrens: People[];
28
- constructor(people: People, parents: People[], childrens: People[], currentSosa: number);
29
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Act_1 = require("./Act");
4
- const Identificator_enum_1 = require("./Identificator.enum");
5
- const Utils_People_1 = require("./Utils-People");
6
- const DateAct_1 = require("./DateAct");
7
- var Sex;
8
- (function (Sex) {
9
- Sex["M"] = "M";
10
- Sex["F"] = "F";
11
- })(Sex = exports.Sex || (exports.Sex = {}));
12
- class People {
13
- constructor(sosa, sex, firstnames, lastname, birth, marriage, death, FAMC, FAMS, photo) {
14
- this.sosa = sosa;
15
- this.sex = sex;
16
- this.firstnames = firstnames;
17
- this.lastname = lastname;
18
- this.photo = photo;
19
- this.birth = birth;
20
- this.marriage = marriage;
21
- this.death = death;
22
- this.FAMC = FAMC;
23
- this.FAMS = FAMS;
24
- }
25
- createPeopleJson(peopleLines) {
26
- const peoplesLinesWithoutCarriage = peopleLines.map(people => people.replace(/[\n\r]+/g, ''));
27
- this.createFirstnamesAndLastnameJson(peoplesLinesWithoutCarriage);
28
- this.createSex(peoplesLinesWithoutCarriage);
29
- this.createFAM(peoplesLinesWithoutCarriage);
30
- this.createPhoto(peoplesLinesWithoutCarriage);
31
- this.birth = this.createBirthDeathAct(peoplesLinesWithoutCarriage, Identificator_enum_1.Identificator.BIRT);
32
- this.death = this.createBirthDeathAct(peoplesLinesWithoutCarriage, Identificator_enum_1.Identificator.DEAT);
33
- }
34
- createFirstnamesAndLastnameJson(peopleLines) {
35
- let lineName = peopleLines.find((information) => information ? information.startsWith('1 NAME') : false);
36
- lineName = lineName ? lineName.replace('1 NAME', '').trim() : null;
37
- const regex = /\/(.*?)\//;
38
- const execLastName = regex.exec(lineName);
39
- this.lastname = execLastName ? execLastName[1].trim().toUpperCase() : null;
40
- lineName = execLastName && execLastName[0] ? lineName.replace(execLastName[0], '').trim() : lineName;
41
- this.firstnames = lineName ? lineName.replace(new RegExp('"', 'g'), '').trim().split(' ') : null;
42
- }
43
- createSex(peopleLines) {
44
- this.sex = Utils_People_1.findValueInLine(peopleLines, '1 SEX ') === Sex.M ? Sex.M : Sex.F;
45
- }
46
- // Enfant issu de la Famille (union de 2 parents)
47
- createFAM(peopleLines) {
48
- const numberPattern = /\d+/g;
49
- const famc = Utils_People_1.findValueInLine(peopleLines, '1 FAMC ');
50
- if (famc) {
51
- this.FAMC = Number(famc.match(numberPattern));
52
- }
53
- const fams = Utils_People_1.findLinesConcernedByKeyword(peopleLines, '1 FAMS ').map(line => Number(line.match(numberPattern)));
54
- if ((fams === null || fams === void 0 ? void 0 : fams.length) > 0) {
55
- this.FAMS = (fams === null || fams === void 0 ? void 0 : fams.length) > 0 ? fams : [];
56
- }
57
- }
58
- createPhoto(peopleLines) {
59
- const photoUrl = Utils_People_1.findValueInLine(peopleLines, '2 FILE ');
60
- if (photoUrl) {
61
- this.photo = photoUrl;
62
- }
63
- }
64
- createBirthDeathAct(peopleLines, identificator) {
65
- const idxBegin = peopleLines.findIndex((lineInformation) => lineInformation.startsWith(`1 ${identificator}`));
66
- const startArray = peopleLines.slice(idxBegin + 1);
67
- const idxEnd = startArray.findIndex((lineInformation) => lineInformation.startsWith('1 '));
68
- const finalArray = idxEnd >= 0 ? startArray.slice(0, idxEnd) : startArray;
69
- return new Act_1.Act(new DateAct_1.DateAct(Utils_People_1.findValueInLine(finalArray, '2 DATE ')), Utils_People_1.findValueInLine(finalArray, '2 PLAC '));
70
- }
71
- }
72
- exports.People = People;
73
- class TreePeople extends People {
74
- constructor(people, parents, childrens, currentSosa) {
75
- super(currentSosa, people.sex, people.firstnames, people.lastname, people.birth, people.marriage, people.death, people.FAMC, people.FAMS);
76
- this.parents = parents;
77
- this.childrens = childrens;
78
- }
79
- }
80
- exports.TreePeople = TreePeople;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Place {
4
- constructor(city, zip, county, region, country, coordinate) {
5
- this.city = city;
6
- this.zip = zip;
7
- this.county = county;
8
- this.region = region;
9
- this.country = country.toUpperCase();
10
- this.coordinate = coordinate;
11
- }
12
- }
13
- exports.Place = Place;
14
- class CoordinateGPS {
15
- constructor(latitude, longitude) {
16
- this.latitude = latitude;
17
- this.longitude = longitude;
18
- }
19
- }
20
- exports.CoordinateGPS = CoordinateGPS;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var Separators;
4
- (function (Separators) {
5
- Separators["CARRIAGE_RETURN"] = "\n";
6
- })(Separators = exports.Separators || (exports.Separators = {}));
@@ -1,6 +0,0 @@
1
- export declare class ConvertStringToDate {
2
- private monthMapping;
3
- private dateString;
4
- constructor(dateString: string);
5
- get toDate(): Date | undefined;
6
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ConvertStringToDate {
4
- constructor(dateString) {
5
- this.monthMapping = {
6
- JAN: 0,
7
- FEB: 1,
8
- MAR: 2,
9
- APR: 3,
10
- MAY: 4,
11
- JUN: 5,
12
- JUL: 6,
13
- AUG: 7,
14
- SEP: 8,
15
- OCT: 9,
16
- NOV: 10,
17
- DEC: 11
18
- };
19
- this.dateString = dateString;
20
- }
21
- get toDate() {
22
- const regex = /^(\w+\s)?(\d{1,2})?\s?([A-Za-z]+)?\s?(\d{4})?$/;
23
- const match = this.dateString.match(regex);
24
- if (match) {
25
- const prefix = match[1];
26
- const day = match[1];
27
- const monthStr = match[3];
28
- const year = match[4];
29
- console.log(match);
30
- if (year) {
31
- if (monthStr) {
32
- if (day) {
33
- return new Date(parseInt(year), this.monthMapping[monthStr], parseInt(day));
34
- }
35
- return new Date(parseInt(year), this.monthMapping[monthStr], 1);
36
- }
37
- return new Date(parseInt(year), 0, 1);
38
- }
39
- }
40
- return undefined;
41
- }
42
- }
43
- exports.ConvertStringToDate = ConvertStringToDate;
@@ -1,2 +0,0 @@
1
- export declare const findValueInLine: (lines: string[], keyword: any) => string;
2
- export declare const findLinesConcernedByKeyword: (lines: string[], keyword: any) => string[];
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findValueInLine = (lines, keyword) => {
4
- const line = lines.find((lineInformation) => lineInformation.startsWith(keyword));
5
- return line ? line.replace(keyword, '') : null;
6
- };
7
- exports.findLinesConcernedByKeyword = (lines, keyword) => {
8
- return [...lines]
9
- .filter(line => line.startsWith(keyword))
10
- .map(line => line.replace(keyword, ''));
11
- };
@@ -1,2 +0,0 @@
1
- export declare class Utils {
2
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Utils {
4
- }
5
- exports.Utils = Utils;
@@ -1,191 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Separators_1 = require("../commons/Separators");
4
- const People_1 = require("../commons/People");
5
- const Identificator_enum_1 = require("../commons/Identificator.enum");
6
- class ExportFormatFile {
7
- constructor(title) {
8
- this.title = title;
9
- }
10
- export(data) {
11
- const link = document.createElement('a');
12
- link.setAttribute('href', data);
13
- link.setAttribute('download', `${this.title}${this.extension}`);
14
- link.click();
15
- }
16
- }
17
- exports.ExportFormatFile = ExportFormatFile;
18
- class GEDCOM extends ExportFormatFile {
19
- constructor(title, peoples) {
20
- super(title);
21
- this.extension = '.ged';
22
- this.peoples = peoples;
23
- }
24
- get beginGedcom() {
25
- const cr = Separators_1.Separators.CARRIAGE_RETURN;
26
- const date = new Date();
27
- const options = { day: '2-digit', month: '2-digit', year: 'numeric' };
28
- const formattedTime = date.toLocaleTimeString('fr-FR');
29
- return ('0 HEAD' +
30
- cr +
31
- '1 SOUR generated by gedcom-ts' +
32
- cr +
33
- `1 DATE ${date.toLocaleDateString('fr-FR', options)}` +
34
- cr +
35
- `2 TIME ${date.toLocaleTimeString('fr-FR')}` +
36
- cr +
37
- `1 FILE ${this.title}` +
38
- cr +
39
- '1 GEDC' +
40
- cr +
41
- '2 VERS 5.5.1' +
42
- cr +
43
- '2 FORM LINEAGE-LINKED' +
44
- cr +
45
- '1 CHAR UTF-8' +
46
- cr);
47
- }
48
- get contentGedcom() {
49
- let content = '';
50
- const cr = Separators_1.Separators.CARRIAGE_RETURN;
51
- if (this.peoples && this.peoples.length > 0) {
52
- this.peoples.forEach((people) => {
53
- var _a, _b, _c, _d, _e;
54
- const firstnames = (_a = people.firstnames) !== null && _a !== void 0 ? _a : [];
55
- const peopleLine = new PeopleLine(people.sosa, [...firstnames], people.lastname, people.FAMS, people.FAMC);
56
- // sosa
57
- content += peopleLine.indi;
58
- if (peopleLine.famsLine) {
59
- content += peopleLine.famsLine;
60
- }
61
- if (peopleLine.famcLine) {
62
- content += peopleLine.famcLine;
63
- }
64
- // prénom et nom
65
- content += peopleLine.firstnamesAndNames;
66
- // sex
67
- content += peopleLine.sex;
68
- // birth
69
- if (people.birth && (((_b = people.birth.dateAct) === null || _b === void 0 ? void 0 : _b.date) || people.birth.place)) {
70
- const actLine = new ActLine(Identificator_enum_1.Identificator.BIRT, people.birth);
71
- content += actLine.typeLine;
72
- if ((_c = people.birth.dateAct) === null || _c === void 0 ? void 0 : _c.date) {
73
- content += actLine.dateLine;
74
- }
75
- if (people.birth.place) {
76
- content += actLine.placeLine;
77
- }
78
- }
79
- if (people.death && (((_d = people.death.dateAct) === null || _d === void 0 ? void 0 : _d.date) || people.death.place)) {
80
- const actLine = new ActLine(Identificator_enum_1.Identificator.DEAT, people.death);
81
- content += actLine.typeLine;
82
- if ((_e = people.death.dateAct) === null || _e === void 0 ? void 0 : _e.date) {
83
- content += actLine.dateLine;
84
- }
85
- if (people.death.place) {
86
- content += actLine.placeLine;
87
- }
88
- }
89
- });
90
- // content += 'toto' + cr;
91
- }
92
- return content;
93
- }
94
- download() {
95
- const ged = `data:text/ged;charset=utf-8,${this.beginGedcom}${this.contentGedcom}${Identificator_enum_1.Identificator.TRLR}`;
96
- const data = encodeURI(ged);
97
- this.export(data);
98
- }
99
- }
100
- exports.GEDCOM = GEDCOM;
101
- class LineGedcom {
102
- constructor() {
103
- this.cr = Separators_1.Separators.CARRIAGE_RETURN;
104
- }
105
- }
106
- exports.LineGedcom = LineGedcom;
107
- class PeopleLine extends LineGedcom {
108
- constructor(sosa, firstnames, lastnames, fams, famc) {
109
- super();
110
- this.sosa = sosa;
111
- this.firstnames = firstnames;
112
- this.lastnames = lastnames !== null && lastnames !== void 0 ? lastnames : '';
113
- this.fams = (fams === null || fams === void 0 ? void 0 : fams.length) > 0 ? fams : [];
114
- if (famc) {
115
- this.famc = famc;
116
- }
117
- }
118
- get indi() {
119
- if (this.sosa) {
120
- return `0 @I${this.sosa}@ INDI${this.cr}`;
121
- }
122
- return '';
123
- }
124
- get famsLine() {
125
- return this.fams.reduce((pre, curr) => {
126
- if (curr >= 0) {
127
- pre += `1 FAMS @${curr}@${this.cr}`;
128
- }
129
- return pre;
130
- }, '');
131
- }
132
- get famcLine() {
133
- if (this.famc) {
134
- return `1 FAMC @${this.famc}@${this.cr}`;
135
- }
136
- return null;
137
- }
138
- get firstnamesAndNames() {
139
- if (this.firstnames || this.lastnames) {
140
- let content = '1 NAME';
141
- if (this.firstnames && this.firstnames.length > 0) {
142
- this.firstnames[0] = `"${this.firstnames[0]}"`;
143
- content += ` ${this.firstnames.join(' ')}`;
144
- }
145
- if (this.lastnames && this.lastnames.length > 0) {
146
- content += ` /${this.lastnames}/`;
147
- }
148
- return content + this.cr;
149
- }
150
- return '';
151
- }
152
- get sex() {
153
- if (this.sosa) {
154
- return `1 SEX ${this.sosa === 1 || this.sosa % 2 ? People_1.Sex.F : People_1.Sex.M}${this.cr}`;
155
- }
156
- return '';
157
- }
158
- }
159
- exports.PeopleLine = PeopleLine;
160
- class ActLine extends LineGedcom {
161
- constructor(type, act) {
162
- super();
163
- this.type = type;
164
- this.act = act;
165
- }
166
- get typeLine() {
167
- return `1 ${this.type}${this.cr}`;
168
- }
169
- get dateLine() {
170
- var _a, _b;
171
- if ((_b = (_a = this.act) === null || _a === void 0 ? void 0 : _a.dateAct) === null || _b === void 0 ? void 0 : _b.date) {
172
- const options = { day: '2-digit', month: 'short', year: 'numeric' };
173
- return `2 ${Identificator_enum_1.Identificator.DATE} ${this.formatDate(this.act.dateAct)}${this.cr}`;
174
- }
175
- return '';
176
- }
177
- get placeLine() {
178
- var _a, _b;
179
- if (((_b = (_a = this.act) === null || _a === void 0 ? void 0 : _a.place) === null || _b === void 0 ? void 0 : _b.length) > 0) {
180
- return `2 ${Identificator_enum_1.Identificator.PLAC} ${this.act.place}${this.cr}`;
181
- }
182
- return '';
183
- }
184
- formatDate(dateAct) {
185
- if (dateAct.date) {
186
- return `${dateAct.day ? `${dateAct.day} ` : ''}${dateAct.month ? `${dateAct.month} ` : ''}${dateAct.year ? `${dateAct.year}` : ''}`;
187
- }
188
- return '';
189
- }
190
- }
191
- exports.ActLine = ActLine;