@treeviz/gedcom-parser 1.0.13 → 1.0.15

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 (367) hide show
  1. package/dist/classes/index.d.ts +2 -28
  2. package/dist/classes/index.js +6713 -21
  3. package/dist/classes/index.js.map +1 -0
  4. package/dist/cli/index.d.ts +0 -2
  5. package/dist/cli/index.js +7826 -24
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/constants/index.d.ts +49 -4
  8. package/dist/constants/index.js +5797 -4
  9. package/dist/constants/index.js.map +1 -0
  10. package/dist/factories/index.d.ts +202 -13
  11. package/dist/factories/index.js +5782 -8
  12. package/dist/factories/index.js.map +1 -0
  13. package/dist/index-BvW-KWJP.d.ts +1654 -0
  14. package/dist/index.d.ts +9 -28
  15. package/dist/index.js +7380 -35
  16. package/dist/index.js.map +1 -0
  17. package/dist/interfaces/index.d.ts +2 -12
  18. package/dist/interfaces/index.js +3 -1
  19. package/dist/interfaces/index.js.map +1 -0
  20. package/dist/kinship-translator/index.d.ts +146 -11
  21. package/dist/kinship-translator/index.js +5727 -9
  22. package/dist/kinship-translator/index.js.map +1 -0
  23. package/dist/place-parser-RlXCXZ8F.d.ts +37 -0
  24. package/dist/structures/index.d.ts +25 -27
  25. package/dist/structures/index.js +3 -1
  26. package/dist/structures/index.js.map +1 -0
  27. package/dist/types/index.d.ts +69 -8
  28. package/dist/types/index.js +31 -6
  29. package/dist/types/index.js.map +1 -0
  30. package/dist/utils/index.d.ts +91 -18
  31. package/dist/utils/index.js +6953 -17
  32. package/dist/utils/index.js.map +1 -0
  33. package/package.json +4 -3
  34. package/dist/classes/common.d.ts +0 -91
  35. package/dist/classes/common.d.ts.map +0 -1
  36. package/dist/classes/common.js +0 -488
  37. package/dist/classes/date.d.ts +0 -27
  38. package/dist/classes/date.d.ts.map +0 -1
  39. package/dist/classes/date.js +0 -178
  40. package/dist/classes/fam.d.ts +0 -19
  41. package/dist/classes/fam.d.ts.map +0 -1
  42. package/dist/classes/fam.js +0 -38
  43. package/dist/classes/fams.d.ts +0 -16
  44. package/dist/classes/fams.d.ts.map +0 -1
  45. package/dist/classes/fams.js +0 -41
  46. package/dist/classes/gedcom.d.ts +0 -139
  47. package/dist/classes/gedcom.d.ts.map +0 -1
  48. package/dist/classes/gedcom.js +0 -910
  49. package/dist/classes/index.d.ts.map +0 -1
  50. package/dist/classes/indi.d.ts +0 -323
  51. package/dist/classes/indi.d.ts.map +0 -1
  52. package/dist/classes/indi.js +0 -2131
  53. package/dist/classes/indis.d.ts +0 -55
  54. package/dist/classes/indis.d.ts.map +0 -1
  55. package/dist/classes/indis.js +0 -457
  56. package/dist/classes/list.d.ts +0 -55
  57. package/dist/classes/list.d.ts.map +0 -1
  58. package/dist/classes/list.js +0 -440
  59. package/dist/classes/name.d.ts +0 -20
  60. package/dist/classes/name.d.ts.map +0 -1
  61. package/dist/classes/name.js +0 -48
  62. package/dist/classes/note.d.ts +0 -12
  63. package/dist/classes/note.d.ts.map +0 -1
  64. package/dist/classes/note.js +0 -46
  65. package/dist/classes/obje.d.ts +0 -12
  66. package/dist/classes/obje.d.ts.map +0 -1
  67. package/dist/classes/obje.js +0 -81
  68. package/dist/classes/objes.d.ts +0 -8
  69. package/dist/classes/objes.d.ts.map +0 -1
  70. package/dist/classes/objes.js +0 -13
  71. package/dist/classes/repo.d.ts +0 -11
  72. package/dist/classes/repo.d.ts.map +0 -1
  73. package/dist/classes/repo.js +0 -6
  74. package/dist/classes/repos.d.ts +0 -8
  75. package/dist/classes/repos.d.ts.map +0 -1
  76. package/dist/classes/repos.js +0 -13
  77. package/dist/classes/sour.d.ts +0 -11
  78. package/dist/classes/sour.d.ts.map +0 -1
  79. package/dist/classes/sour.js +0 -6
  80. package/dist/classes/sours.d.ts +0 -8
  81. package/dist/classes/sours.d.ts.map +0 -1
  82. package/dist/classes/sours.js +0 -13
  83. package/dist/classes/subm.d.ts +0 -10
  84. package/dist/classes/subm.d.ts.map +0 -1
  85. package/dist/classes/subm.js +0 -6
  86. package/dist/classes/subms.d.ts +0 -8
  87. package/dist/classes/subms.d.ts.map +0 -1
  88. package/dist/classes/subms.js +0 -13
  89. package/dist/cli/commands/convert.d.ts +0 -3
  90. package/dist/cli/commands/convert.d.ts.map +0 -1
  91. package/dist/cli/commands/convert.js +0 -83
  92. package/dist/cli/commands/extract.d.ts +0 -3
  93. package/dist/cli/commands/extract.d.ts.map +0 -1
  94. package/dist/cli/commands/extract.js +0 -85
  95. package/dist/cli/commands/find.d.ts +0 -3
  96. package/dist/cli/commands/find.d.ts.map +0 -1
  97. package/dist/cli/commands/find.js +0 -97
  98. package/dist/cli/commands/info.d.ts +0 -3
  99. package/dist/cli/commands/info.d.ts.map +0 -1
  100. package/dist/cli/commands/info.js +0 -80
  101. package/dist/cli/commands/merge.d.ts +0 -3
  102. package/dist/cli/commands/merge.d.ts.map +0 -1
  103. package/dist/cli/commands/merge.js +0 -61
  104. package/dist/cli/commands/relatives.d.ts +0 -3
  105. package/dist/cli/commands/relatives.d.ts.map +0 -1
  106. package/dist/cli/commands/relatives.js +0 -107
  107. package/dist/cli/commands/show.d.ts +0 -3
  108. package/dist/cli/commands/show.d.ts.map +0 -1
  109. package/dist/cli/commands/show.js +0 -176
  110. package/dist/cli/commands/stats.d.ts +0 -3
  111. package/dist/cli/commands/stats.d.ts.map +0 -1
  112. package/dist/cli/commands/stats.js +0 -59
  113. package/dist/cli/commands/validate.d.ts +0 -3
  114. package/dist/cli/commands/validate.d.ts.map +0 -1
  115. package/dist/cli/commands/validate.js +0 -148
  116. package/dist/cli/index.d.ts.map +0 -1
  117. package/dist/cli/utils/formatters.d.ts +0 -69
  118. package/dist/cli/utils/formatters.d.ts.map +0 -1
  119. package/dist/cli/utils/formatters.js +0 -125
  120. package/dist/cli/utils/helpers.d.ts +0 -21
  121. package/dist/cli/utils/helpers.d.ts.map +0 -1
  122. package/dist/cli/utils/helpers.js +0 -58
  123. package/dist/constants/constants.d.ts +0 -14
  124. package/dist/constants/constants.d.ts.map +0 -1
  125. package/dist/constants/constants.js +0 -13
  126. package/dist/constants/filters.d.ts +0 -18
  127. package/dist/constants/filters.d.ts.map +0 -1
  128. package/dist/constants/filters.js +0 -44
  129. package/dist/constants/index.d.ts.map +0 -1
  130. package/dist/constants/orders.d.ts +0 -17
  131. package/dist/constants/orders.d.ts.map +0 -1
  132. package/dist/constants/orders.js +0 -240
  133. package/dist/factories/cache-factory.d.ts +0 -30
  134. package/dist/factories/cache-factory.d.ts.map +0 -1
  135. package/dist/factories/cache-factory.js +0 -43
  136. package/dist/factories/date-locale-factory.d.ts +0 -30
  137. package/dist/factories/date-locale-factory.d.ts.map +0 -1
  138. package/dist/factories/date-locale-factory.js +0 -34
  139. package/dist/factories/i18n-factory.d.ts +0 -40
  140. package/dist/factories/i18n-factory.d.ts.map +0 -1
  141. package/dist/factories/i18n-factory.js +0 -44
  142. package/dist/factories/index.d.ts.map +0 -1
  143. package/dist/factories/kinship-factory.d.ts +0 -38
  144. package/dist/factories/kinship-factory.d.ts.map +0 -1
  145. package/dist/factories/kinship-factory.js +0 -35
  146. package/dist/factories/place-parser-provider.d.ts +0 -32
  147. package/dist/factories/place-parser-provider.d.ts.map +0 -1
  148. package/dist/factories/place-parser-provider.js +0 -35
  149. package/dist/factories/place-translator-provider.d.ts +0 -32
  150. package/dist/factories/place-translator-provider.d.ts.map +0 -1
  151. package/dist/factories/place-translator-provider.js +0 -35
  152. package/dist/index.d.ts.map +0 -1
  153. package/dist/interfaces/common.d.ts +0 -43
  154. package/dist/interfaces/common.d.ts.map +0 -1
  155. package/dist/interfaces/common.js +0 -1
  156. package/dist/interfaces/fam.d.ts +0 -11
  157. package/dist/interfaces/fam.d.ts.map +0 -1
  158. package/dist/interfaces/fam.js +0 -1
  159. package/dist/interfaces/fams.d.ts +0 -9
  160. package/dist/interfaces/fams.d.ts.map +0 -1
  161. package/dist/interfaces/fams.js +0 -1
  162. package/dist/interfaces/gedcom.d.ts +0 -30
  163. package/dist/interfaces/gedcom.d.ts.map +0 -1
  164. package/dist/interfaces/gedcom.js +0 -1
  165. package/dist/interfaces/index.d.ts.map +0 -1
  166. package/dist/interfaces/indi.d.ts +0 -113
  167. package/dist/interfaces/indi.d.ts.map +0 -1
  168. package/dist/interfaces/indi.js +0 -1
  169. package/dist/interfaces/indis.d.ts +0 -31
  170. package/dist/interfaces/indis.d.ts.map +0 -1
  171. package/dist/interfaces/indis.js +0 -1
  172. package/dist/interfaces/list.d.ts +0 -52
  173. package/dist/interfaces/list.d.ts.map +0 -1
  174. package/dist/interfaces/list.js +0 -1
  175. package/dist/interfaces/obje.d.ts +0 -7
  176. package/dist/interfaces/obje.d.ts.map +0 -1
  177. package/dist/interfaces/obje.js +0 -1
  178. package/dist/interfaces/repo.d.ts +0 -7
  179. package/dist/interfaces/repo.d.ts.map +0 -1
  180. package/dist/interfaces/repo.js +0 -1
  181. package/dist/interfaces/sour.d.ts +0 -7
  182. package/dist/interfaces/sour.d.ts.map +0 -1
  183. package/dist/interfaces/sour.js +0 -1
  184. package/dist/interfaces/subm.d.ts +0 -6
  185. package/dist/interfaces/subm.d.ts.map +0 -1
  186. package/dist/interfaces/subm.js +0 -1
  187. package/dist/kinship-translator/index.d.ts.map +0 -1
  188. package/dist/kinship-translator/kinship-translator.basic.d.ts +0 -30
  189. package/dist/kinship-translator/kinship-translator.basic.d.ts.map +0 -1
  190. package/dist/kinship-translator/kinship-translator.basic.js +0 -74
  191. package/dist/kinship-translator/kinship-translator.d.ts +0 -26
  192. package/dist/kinship-translator/kinship-translator.d.ts.map +0 -1
  193. package/dist/kinship-translator/kinship-translator.de.d.ts +0 -18
  194. package/dist/kinship-translator/kinship-translator.de.d.ts.map +0 -1
  195. package/dist/kinship-translator/kinship-translator.de.js +0 -180
  196. package/dist/kinship-translator/kinship-translator.en.d.ts +0 -18
  197. package/dist/kinship-translator/kinship-translator.en.d.ts.map +0 -1
  198. package/dist/kinship-translator/kinship-translator.en.js +0 -182
  199. package/dist/kinship-translator/kinship-translator.es.d.ts +0 -18
  200. package/dist/kinship-translator/kinship-translator.es.d.ts.map +0 -1
  201. package/dist/kinship-translator/kinship-translator.es.js +0 -181
  202. package/dist/kinship-translator/kinship-translator.fr.d.ts +0 -18
  203. package/dist/kinship-translator/kinship-translator.fr.d.ts.map +0 -1
  204. package/dist/kinship-translator/kinship-translator.fr.js +0 -181
  205. package/dist/kinship-translator/kinship-translator.hu.d.ts +0 -19
  206. package/dist/kinship-translator/kinship-translator.hu.d.ts.map +0 -1
  207. package/dist/kinship-translator/kinship-translator.hu.js +0 -226
  208. package/dist/kinship-translator/kinship-translator.interface.d.ts +0 -19
  209. package/dist/kinship-translator/kinship-translator.interface.d.ts.map +0 -1
  210. package/dist/kinship-translator/kinship-translator.interface.js +0 -1
  211. package/dist/kinship-translator/kinship-translator.js +0 -103
  212. package/dist/kinship-translator/patterns.de.d.ts +0 -2
  213. package/dist/kinship-translator/patterns.de.d.ts.map +0 -1
  214. package/dist/kinship-translator/patterns.de.js +0 -14
  215. package/dist/kinship-translator/patterns.en.d.ts +0 -2
  216. package/dist/kinship-translator/patterns.en.d.ts.map +0 -1
  217. package/dist/kinship-translator/patterns.en.js +0 -14
  218. package/dist/kinship-translator/patterns.es.d.ts +0 -2
  219. package/dist/kinship-translator/patterns.es.d.ts.map +0 -1
  220. package/dist/kinship-translator/patterns.es.js +0 -14
  221. package/dist/kinship-translator/patterns.fr.d.ts +0 -2
  222. package/dist/kinship-translator/patterns.fr.d.ts.map +0 -1
  223. package/dist/kinship-translator/patterns.fr.js +0 -14
  224. package/dist/kinship-translator/patterns.hu.d.ts +0 -6
  225. package/dist/kinship-translator/patterns.hu.d.ts.map +0 -1
  226. package/dist/kinship-translator/patterns.hu.js +0 -97
  227. package/dist/kinship-translator/translators.d.ts +0 -6
  228. package/dist/kinship-translator/translators.d.ts.map +0 -1
  229. package/dist/kinship-translator/translators.js +0 -5
  230. package/dist/kinship-translator/types.d.ts +0 -9
  231. package/dist/kinship-translator/types.d.ts.map +0 -1
  232. package/dist/kinship-translator/types.js +0 -1
  233. package/dist/structures/address.d.ts +0 -14
  234. package/dist/structures/address.d.ts.map +0 -1
  235. package/dist/structures/address.js +0 -1
  236. package/dist/structures/association.d.ts +0 -13
  237. package/dist/structures/association.d.ts.map +0 -1
  238. package/dist/structures/association.js +0 -1
  239. package/dist/structures/change-date.d.ts +0 -8
  240. package/dist/structures/change-date.d.ts.map +0 -1
  241. package/dist/structures/change-date.js +0 -1
  242. package/dist/structures/creation-date.d.ts +0 -7
  243. package/dist/structures/creation-date.d.ts.map +0 -1
  244. package/dist/structures/creation-date.js +0 -1
  245. package/dist/structures/date.d.ts +0 -9
  246. package/dist/structures/date.d.ts.map +0 -1
  247. package/dist/structures/date.js +0 -1
  248. package/dist/structures/event-detail-structure.d.ts +0 -25
  249. package/dist/structures/event-detail-structure.d.ts.map +0 -1
  250. package/dist/structures/event-detail-structure.js +0 -1
  251. package/dist/structures/family.d.ts +0 -34
  252. package/dist/structures/family.d.ts.map +0 -1
  253. package/dist/structures/family.js +0 -1
  254. package/dist/structures/gedcom.d.ts +0 -59
  255. package/dist/structures/gedcom.d.ts.map +0 -1
  256. package/dist/structures/gedcom.js +0 -1
  257. package/dist/structures/index.d.ts.map +0 -1
  258. package/dist/structures/individual-event-detail-structure.d.ts +0 -9
  259. package/dist/structures/individual-event-detail-structure.d.ts.map +0 -1
  260. package/dist/structures/individual-event-detail-structure.js +0 -1
  261. package/dist/structures/individual-event-structure.d.ts +0 -83
  262. package/dist/structures/individual-event-structure.d.ts.map +0 -1
  263. package/dist/structures/individual-event-structure.js +0 -1
  264. package/dist/structures/individual.d.ts +0 -40
  265. package/dist/structures/individual.d.ts.map +0 -1
  266. package/dist/structures/individual.js +0 -1
  267. package/dist/structures/lds-ordinance-detail.d.ts +0 -17
  268. package/dist/structures/lds-ordinance-detail.d.ts.map +0 -1
  269. package/dist/structures/lds-ordinance-detail.js +0 -1
  270. package/dist/structures/lds-spouse-sealing.d.ts +0 -7
  271. package/dist/structures/lds-spouse-sealing.d.ts.map +0 -1
  272. package/dist/structures/lds-spouse-sealing.js +0 -1
  273. package/dist/structures/marriage-date.d.ts +0 -11
  274. package/dist/structures/marriage-date.d.ts.map +0 -1
  275. package/dist/structures/marriage-date.js +0 -1
  276. package/dist/structures/multimedia-link.d.ts +0 -16
  277. package/dist/structures/multimedia-link.d.ts.map +0 -1
  278. package/dist/structures/multimedia-link.js +0 -1
  279. package/dist/structures/non-event.d.ts +0 -12
  280. package/dist/structures/non-event.d.ts.map +0 -1
  281. package/dist/structures/non-event.js +0 -1
  282. package/dist/structures/note.d.ts +0 -16
  283. package/dist/structures/note.d.ts.map +0 -1
  284. package/dist/structures/note.js +0 -1
  285. package/dist/structures/personal-name-pieces.d.ts +0 -11
  286. package/dist/structures/personal-name-pieces.d.ts.map +0 -1
  287. package/dist/structures/personal-name-pieces.js +0 -1
  288. package/dist/structures/personal-name.d.ts +0 -16
  289. package/dist/structures/personal-name.d.ts.map +0 -1
  290. package/dist/structures/personal-name.js +0 -1
  291. package/dist/structures/place.d.ts +0 -20
  292. package/dist/structures/place.d.ts.map +0 -1
  293. package/dist/structures/place.js +0 -1
  294. package/dist/structures/repository.d.ts +0 -6
  295. package/dist/structures/repository.d.ts.map +0 -1
  296. package/dist/structures/repository.js +0 -1
  297. package/dist/structures/source-citation.d.ts +0 -27
  298. package/dist/structures/source-citation.d.ts.map +0 -1
  299. package/dist/structures/source-citation.js +0 -1
  300. package/dist/structures/source-repository-citation.d.ts +0 -13
  301. package/dist/structures/source-repository-citation.d.ts.map +0 -1
  302. package/dist/structures/source-repository-citation.js +0 -1
  303. package/dist/structures/source.d.ts +0 -28
  304. package/dist/structures/source.d.ts.map +0 -1
  305. package/dist/structures/source.js +0 -1
  306. package/dist/types/ancestry-media.d.ts +0 -65
  307. package/dist/types/ancestry-media.d.ts.map +0 -1
  308. package/dist/types/ancestry-media.js +0 -1
  309. package/dist/types/index.d.ts.map +0 -1
  310. package/dist/types/settings.d.ts +0 -12
  311. package/dist/types/settings.d.ts.map +0 -1
  312. package/dist/types/settings.js +0 -1
  313. package/dist/types/types.d.ts +0 -225
  314. package/dist/types/types.d.ts.map +0 -1
  315. package/dist/types/types.js +0 -26
  316. package/dist/utils/cache.d.ts +0 -22
  317. package/dist/utils/cache.d.ts.map +0 -1
  318. package/dist/utils/cache.js +0 -57
  319. package/dist/utils/common-creator.d.ts +0 -13
  320. package/dist/utils/common-creator.d.ts.map +0 -1
  321. package/dist/utils/common-creator.js +0 -72
  322. package/dist/utils/date-formatter.d.ts +0 -35
  323. package/dist/utils/date-formatter.d.ts.map +0 -1
  324. package/dist/utils/date-formatter.js +0 -207
  325. package/dist/utils/get-all-prop.d.ts +0 -4
  326. package/dist/utils/get-all-prop.d.ts.map +0 -1
  327. package/dist/utils/get-all-prop.js +0 -5
  328. package/dist/utils/get-family-with.d.ts +0 -5
  329. package/dist/utils/get-family-with.d.ts.map +0 -1
  330. package/dist/utils/get-family-with.js +0 -11
  331. package/dist/utils/get-places.d.ts +0 -21
  332. package/dist/utils/get-places.d.ts.map +0 -1
  333. package/dist/utils/get-places.js +0 -77
  334. package/dist/utils/get-product-details.d.ts +0 -4
  335. package/dist/utils/get-product-details.d.ts.map +0 -1
  336. package/dist/utils/get-product-details.js +0 -6
  337. package/dist/utils/get-raw-size.d.ts +0 -2
  338. package/dist/utils/get-raw-size.d.ts.map +0 -1
  339. package/dist/utils/get-raw-size.js +0 -3
  340. package/dist/utils/index.d.ts.map +0 -1
  341. package/dist/utils/logger.d.ts +0 -3
  342. package/dist/utils/logger.d.ts.map +0 -1
  343. package/dist/utils/logger.js +0 -11
  344. package/dist/utils/name-formatter.d.ts +0 -10
  345. package/dist/utils/name-formatter.d.ts.map +0 -1
  346. package/dist/utils/name-formatter.js +0 -45
  347. package/dist/utils/nested-group.d.ts +0 -4
  348. package/dist/utils/nested-group.d.ts.map +0 -1
  349. package/dist/utils/nested-group.js +0 -34
  350. package/dist/utils/ordinalize.d.ts +0 -3
  351. package/dist/utils/ordinalize.d.ts.map +0 -1
  352. package/dist/utils/ordinalize.js +0 -104
  353. package/dist/utils/parser.d.ts +0 -17
  354. package/dist/utils/parser.d.ts.map +0 -1
  355. package/dist/utils/parser.js +0 -321
  356. package/dist/utils/place-parser.d.ts +0 -16
  357. package/dist/utils/place-parser.d.ts.map +0 -1
  358. package/dist/utils/place-parser.js +0 -46
  359. package/dist/utils/place-translator.d.ts +0 -6
  360. package/dist/utils/place-translator.d.ts.map +0 -1
  361. package/dist/utils/place-translator.js +0 -8
  362. package/dist/utils/place-types.d.ts +0 -27
  363. package/dist/utils/place-types.d.ts.map +0 -1
  364. package/dist/utils/place-types.js +0 -14
  365. package/dist/utils/range.d.ts +0 -19
  366. package/dist/utils/range.d.ts.map +0 -1
  367. package/dist/utils/range.js +0 -265
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeviz/gedcom-parser",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Lightweight, pluggable GEDCOM parser for JavaScript/TypeScript with optional caching and place matching. Zero browser dependencies.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -101,8 +101,8 @@
101
101
  "LICENSE"
102
102
  ],
103
103
  "scripts": {
104
- "build": "tsc -p tsconfig.json && node scripts/fix-imports.mjs",
105
- "dev": "tsc -p tsconfig.json --watch",
104
+ "build": "NODE_OPTIONS='--max-old-space-size=4096' tsup",
105
+ "dev": "tsup --watch",
106
106
  "test": "vitest run",
107
107
  "test:watch": "vitest",
108
108
  "prepublishOnly": "npm run build"
@@ -153,6 +153,7 @@
153
153
  "@types/lodash": "^4.17.13",
154
154
  "@types/lodash-es": "^4.17.12",
155
155
  "@types/node": "^20.17.23",
156
+ "tsup": "^8.5.1",
156
157
  "typescript": "^5.6.3",
157
158
  "vitest": "^3.0.7"
158
159
  },
@@ -1,91 +0,0 @@
1
- import type { ConvertOptions } from "../interfaces/common";
2
- import type ICommon from "../interfaces/common";
3
- import type { IdType, MultiTag, ListTag } from "../types/types";
4
- import type { GedComType } from "./gedcom";
5
- import { List } from "./list";
6
- export declare class Common<T = string, I extends IdType = IdType> implements ICommon<T, I> {
7
- protected _gedcom?: GedComType;
8
- protected _value?: T;
9
- protected _id?: I;
10
- protected _main?: Common;
11
- protected _parent?: Common;
12
- protected _uniqueId?: string | undefined;
13
- protected _type?: MultiTag;
14
- protected _refs?: List;
15
- isListable: boolean;
16
- refType?: ListTag;
17
- cloneOf?: string;
18
- clonedBy?: string;
19
- constructor(gedcom?: GedComType, id?: I, main?: Common, parent?: Common);
20
- set type(type: MultiTag | undefined);
21
- get type(): MultiTag | undefined;
22
- initUniqueId(): void;
23
- set uniqueId(id: string | undefined);
24
- get uniqueId(): string | undefined;
25
- set id(id: I | undefined);
26
- get id(): I | undefined;
27
- set value(value: T | undefined);
28
- get value(): T | undefined;
29
- /**
30
- * Set the gedcom reference for this object
31
- * @param gedcom - The GedComType to set as the gedcom reference
32
- */
33
- setGedcom(gedcom: GedComType): void;
34
- get originalValue(): T;
35
- get ref(): Common<T, I> | undefined;
36
- get main(): Common<string, IdType>;
37
- get parent(): Common<string, IdType>;
38
- addRef(refNode: Common): void;
39
- getRefs(): List<IdType, Common<string, IdType>>;
40
- exportValue(): T;
41
- removeValue(): void;
42
- set<T extends Common | List = Common | List>(name: MultiTag, value: T | string): T | undefined;
43
- assign<T extends Common | List = Common | List>(name: MultiTag, value: T, unique?: boolean): T | undefined;
44
- get<T extends Common | List = Common | List>(name: MultiTag): T;
45
- remove(name: MultiTag): void;
46
- getGedcom(): GedComType;
47
- getIf<T extends Common | List = Common | List>(name: MultiTag, condition: string, name2: MultiTag): T;
48
- toString(): string;
49
- toValue(): T;
50
- toProp(tag: MultiTag): Common<T, I> | undefined;
51
- toList(): List<IdType, Common<string, IdType>>;
52
- toValueList(): List<IdType, Common<string, IdType>>;
53
- private standardizeObject;
54
- toJson(tag?: MultiTag, options?: ConvertOptions): string;
55
- toObject(tag?: MultiTag, options?: ConvertOptions): Record<string, string | ({
56
- value?: string;
57
- } & Record<string, unknown>) | (string | ({
58
- value?: string;
59
- } & Record<string, unknown>))[]>;
60
- merge(other: Common<T, I>, override?: boolean, avoidKeys?: MultiTag[]): this;
61
- clone(newId?: boolean, avoidKeys?: MultiTag[]): Common<T, I>;
62
- fromGedcom(_value: string): void;
63
- toGedcom(tag?: MultiTag, level?: number, options?: ConvertOptions): string;
64
- toGedcomLines(tag?: MultiTag, level?: number, options?: ConvertOptions): string[];
65
- isGenoPro(): boolean;
66
- isAhnenblatt(): boolean;
67
- isGeni(): boolean;
68
- isAncestry(): boolean;
69
- isMyHeritage(): boolean;
70
- isFamilySearch(): boolean;
71
- getAncestryTreeId(): string | undefined;
72
- getMyHeritageTreeId(): string | undefined;
73
- getTreeId(): string;
74
- getAncestryTreeName(): string | undefined;
75
- getMyHeritageTreeName(): string;
76
- getTreeName(): string;
77
- }
78
- export type ProxyOriginal<T extends Common> = T & {
79
- unwrapped: T;
80
- };
81
- export declare const createProxy: <T extends Common>(target: T) => T;
82
- export declare const createCommon: (gedcom?: GedComType, id?: IdType, main?: Common, parent?: Common) => ProxyOriginal<Common>;
83
- export declare const isOnlyMainProp: (key: string | symbol) => key is MultiTag | "_value" | "value";
84
- export declare const isValidKey: <T>(common: Common<T>, key: string | symbol) => key is MultiTag | "_value" | "value" | "id" | "_id";
85
- export declare const getValidKeys: <T>(common: Common<T>) => Array<MultiTag | "_value" | "value" | "id" | "_id">;
86
- export declare const getValidTag: (tag: string) => string;
87
- export declare const getListTag: (tag: string) => ListTag;
88
- export declare const getValidKey: (tag: string, id: string) => string;
89
- export declare const isId: (string: string) => string is IdType;
90
- export declare const idGetter: <T extends IdType>(id?: T) => T;
91
- //# sourceMappingURL=common.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/classes/common.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAs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EF,eAAO,MAAM,cAAc,GAC1B,KAAK,MAAM,GAAG,MAAM,KAClB,GAAG,IAAI,QAAQ,GAAG,QAAQ,GAAG,OAW/B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,CAAC,EAC3B,QAAQ,MAAM,CAAC,CAAC,CAAC,EACjB,KAAK,MAAM,GAAG,MAAM,KAClB,GAAG,IAAI,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,KAgBhD,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,QAAQ,MAAM,CAAC,CAAC,CAAC,KAG1C,KAAK,CAAC,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,KAAK,CACxD,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,WAEtC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAChB,OACrB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,IAAI,MAAM,WAElD,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,QAAQ,MAAM,KAAG,MAAM,IAAI,MAE/C,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,MAqBhD,CAAC"}
@@ -1,488 +0,0 @@
1
- import get from "lodash-es/get.js";
2
- import set from "lodash-es/set.js";
3
- import uniqBy from "lodash-es/uniqBy.js";
4
- import unset from "lodash-es/unset.js";
5
- import { ID_GETTER_REG, ID_REG } from "../constants/constants.js";
6
- import { List } from "./list.js";
7
- // import GedcomTree from "../../../utils/parser.js";
8
- export class Common {
9
- constructor(gedcom, id, main, parent) {
10
- this.isListable = true;
11
- this._gedcom = gedcom;
12
- this._main = main;
13
- this._parent = parent;
14
- this.initUniqueId();
15
- if (id) {
16
- this._id = id;
17
- }
18
- else {
19
- delete this._id;
20
- }
21
- }
22
- set type(type) {
23
- if (type) {
24
- this.uniqueId = this.uniqueId?.replace(/^[^:]+/, `~${type}`);
25
- }
26
- this._type = type;
27
- }
28
- get type() {
29
- return this._type;
30
- }
31
- initUniqueId() {
32
- if (this._gedcom) {
33
- this.uniqueId = `~Common:${this._gedcom.refcount++}`;
34
- }
35
- }
36
- set uniqueId(id) {
37
- const currentId = this._uniqueId;
38
- if (this._gedcom?.reflist && id) {
39
- this._uniqueId = id;
40
- if (currentId && this._gedcom.reflist[currentId]) {
41
- delete this._gedcom.reflist[currentId];
42
- }
43
- this._gedcom.reflist[id] = this;
44
- }
45
- }
46
- get uniqueId() {
47
- return this._uniqueId;
48
- }
49
- set id(id) {
50
- this._id = idGetter(id);
51
- }
52
- get id() {
53
- return idGetter(this._id);
54
- }
55
- set value(value) {
56
- this._value = value;
57
- }
58
- get value() {
59
- return this._value;
60
- }
61
- /**
62
- * Set the gedcom reference for this object
63
- * @param gedcom - The GedComType to set as the gedcom reference
64
- */
65
- setGedcom(gedcom) {
66
- this._gedcom = gedcom;
67
- }
68
- // avoid to override
69
- get originalValue() {
70
- return this._value;
71
- }
72
- get ref() {
73
- if (typeof this.value === "string" &&
74
- isId(this.value) &&
75
- this.refType) {
76
- return this._gedcom?.[getListTag(this.refType)]?.item(
77
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
- this.value);
79
- }
80
- return this;
81
- }
82
- get main() {
83
- return this._main;
84
- }
85
- get parent() {
86
- return this._parent;
87
- }
88
- addRef(refNode) {
89
- if (typeof refNode.value === "string" &&
90
- isId(refNode.value) &&
91
- refNode.refType) {
92
- if (!this._refs) {
93
- this._refs = new List();
94
- }
95
- this._refs.item(refNode.value, refNode);
96
- }
97
- }
98
- getRefs() {
99
- return this._refs;
100
- }
101
- exportValue() {
102
- return this.value;
103
- }
104
- removeValue() {
105
- delete this._value;
106
- }
107
- set(name, value) {
108
- if (typeof value === "string") {
109
- const usedValue = createCommon(this._gedcom, undefined, this.main);
110
- usedValue.value = value;
111
- set(this, name, usedValue);
112
- }
113
- else {
114
- set(this, name, value);
115
- }
116
- return get(this, name);
117
- }
118
- assign(name, value, unique = false) {
119
- let curValue = this.get(name);
120
- if (curValue?.isListable) {
121
- if (curValue instanceof Common) {
122
- curValue = new List().concat({ ...[curValue] });
123
- this.set(name, curValue);
124
- }
125
- const values = [
126
- ...curValue.values(),
127
- ...(value instanceof List ? value.values() : [value]),
128
- ];
129
- curValue.concat({
130
- ...(!unique
131
- ? values
132
- : uniqBy(values, (value) => value instanceof Common ? value?.value : undefined)),
133
- });
134
- }
135
- else {
136
- this.set(name, value);
137
- }
138
- return get(this, name);
139
- }
140
- get(name) {
141
- if (!name.includes(".")) {
142
- return get(this, name);
143
- }
144
- const nameParts = name.split(".");
145
- // eslint-disable-next-line @typescript-eslint/no-this-alias
146
- let last = this;
147
- for (const part of nameParts) {
148
- const indexPart = Number(part);
149
- const itemIndex = part.match(/items\[(?<itemIndex>\d+)\]/)?.groups
150
- ?.itemIndex;
151
- const itemId = part.match(/items\[(?<itemId>@[A-Z]+\d+@)\]/)?.groups
152
- ?.itemId;
153
- const usedPart = itemId || itemIndex;
154
- if (last instanceof List) {
155
- if (!isNaN(indexPart)) {
156
- last = last.index(indexPart);
157
- }
158
- else {
159
- if (usedPart) {
160
- last = last.item(usedPart);
161
- }
162
- else {
163
- last = last?.index(0)?.get(part);
164
- }
165
- }
166
- }
167
- else {
168
- const usedIndex = Number(itemIndex ?? indexPart);
169
- if (!isNaN(usedIndex)) {
170
- last = last?.toList().index(usedIndex);
171
- }
172
- else {
173
- last = last?.get((itemId ?? part));
174
- }
175
- }
176
- if (!last) {
177
- break;
178
- }
179
- }
180
- return last;
181
- }
182
- remove(name) {
183
- unset(this, name);
184
- }
185
- getGedcom() {
186
- return this._gedcom;
187
- }
188
- getIf(name, condition, name2) {
189
- const nameParts = name.split(".");
190
- const name2Parts = name2.split(".");
191
- if (nameParts.length !== name2Parts.length) {
192
- throw new Error("Tag pathes must be of the same depth");
193
- }
194
- if (nameParts.length > 1 && nameParts[0] !== name2Parts[0]) {
195
- throw new Error("Final tags must be siblings");
196
- }
197
- const valueCommon = this.get(name);
198
- if (valueCommon instanceof Common) {
199
- return valueCommon?.toValue() !== condition
200
- ? undefined
201
- : this.get(name2);
202
- }
203
- const valueCommon2 = this.get(name2)?.toList();
204
- const ifList = new List();
205
- valueCommon?.forEach((item, key) => {
206
- const pair = valueCommon2?.item(key);
207
- ifList.item(key, item?.toValue() !== condition ? undefined : pair);
208
- });
209
- return ifList;
210
- }
211
- toString() {
212
- return this.value?.toString() || "";
213
- }
214
- toValue() {
215
- return this.value;
216
- }
217
- toProp(tag) {
218
- const prop = this.get(tag);
219
- return prop;
220
- }
221
- toList() {
222
- return new List().concat(
223
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
224
- this.id ? { [this.id]: this } : { ...[this] });
225
- }
226
- toValueList() {
227
- return new List().concat(this.value
228
- ? { [this.value]: this }
229
- : // eslint-disable-next-line @typescript-eslint/no-explicit-any
230
- { ...[this] });
231
- }
232
- standardizeObject(tag, options) {
233
- if (tag === "OBJE" &&
234
- !options?.original &&
235
- options?.obje?.standardize &&
236
- options?.obje?.namespace &&
237
- "standardizeMedia" in this) {
238
- const standardize = this.standardizeMedia;
239
- return standardize.call(this, options.obje.namespace, options.obje.override);
240
- }
241
- }
242
- toJson(tag, options) {
243
- const json = this.toObject(tag, options);
244
- return JSON.stringify(json);
245
- }
246
- toObject(tag, options) {
247
- this.standardizeObject(tag, options);
248
- const validKeys = getValidKeys(this);
249
- let json = {};
250
- validKeys.forEach((key) => {
251
- if (key === "id" && this.id !== undefined) {
252
- json.id = this.id;
253
- }
254
- else if (key === "_id" && this._id !== undefined) {
255
- json.id = this._id;
256
- }
257
- else if (key === "value" && this.value !== undefined) {
258
- json.value = this.value;
259
- }
260
- else if (key === "_value" && this._value !== undefined) {
261
- json.value = this._value;
262
- }
263
- else {
264
- const validKey = key;
265
- const prop = this.get(validKey);
266
- if (typeof prop?.toObject === "function") {
267
- if (prop instanceof Common) {
268
- json[validKey] = prop.toObject(validKey, options);
269
- }
270
- else {
271
- json = {
272
- ...json,
273
- ...prop.toObject(validKey, options),
274
- };
275
- }
276
- }
277
- }
278
- });
279
- return json;
280
- }
281
- merge(other, override = false, avoidKeys = []) {
282
- if (!other) {
283
- return this;
284
- }
285
- const validKeys = getValidKeys(other);
286
- validKeys.forEach((validKey) => {
287
- if (avoidKeys.includes(validKey)) {
288
- return;
289
- }
290
- const current = this.get(validKey);
291
- const mergeValue = other.get(validKey);
292
- if (mergeValue) {
293
- if (current instanceof Common || current instanceof List) {
294
- this.assign(validKey, mergeValue, true);
295
- }
296
- else if (!current ||
297
- (override && validKey !== "id" && validKey !== "_id")) {
298
- this.set(validKey, mergeValue);
299
- }
300
- }
301
- });
302
- return this;
303
- }
304
- clone(newId = false, avoidKeys = []) {
305
- const ctor = this.constructor;
306
- const instance = new ctor(this._gedcom, this._id, this._main, this._parent);
307
- if (newId && this._id) {
308
- instance.id = `IFT${this._id.replace(/[^0-9]/g, "")}`;
309
- }
310
- const cloned = createProxy(instance);
311
- cloned.merge(this, true, avoidKeys);
312
- return cloned;
313
- }
314
- // fromGedcom<T = typeof this>(value: string) {
315
- fromGedcom(_value) {
316
- // Object.assign(this, GedcomTree.parse(value) as T);
317
- }
318
- toGedcom(tag, level = 0, options) {
319
- const gedcom = this.toGedcomLines(tag, level, options);
320
- return gedcom.join("\n");
321
- }
322
- toGedcomLines(tag, level = 0, options) {
323
- this.standardizeObject(tag, options);
324
- const validKeys = getValidKeys(this);
325
- const gedcom = [];
326
- validKeys.forEach((key) => {
327
- const validKey = key;
328
- const prop = this.get(validKey);
329
- if (typeof prop?.toGedcomLines === "function") {
330
- if (prop instanceof Common) {
331
- const value = prop.exportValue();
332
- gedcom.push(`${level} ${validKey}${value ? ` ${value}` : ""}`);
333
- gedcom.push(...prop.toGedcomLines(validKey, level + 1, options));
334
- }
335
- else {
336
- gedcom.push(...prop.toGedcomLines(validKey, level, options));
337
- }
338
- }
339
- });
340
- return gedcom;
341
- }
342
- isGenoPro() {
343
- const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
344
- const sour = get(head, "SOUR.value");
345
- return !!sour?.toLowerCase()?.startsWith("genopro");
346
- }
347
- isAhnenblatt() {
348
- const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
349
- const sour = get(head, "SOUR.value");
350
- return !!sour?.toLowerCase()?.startsWith("ahnenblatt");
351
- }
352
- isGeni() {
353
- const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
354
- const sour = get(head, "SOUR.value");
355
- return !!sour?.toLowerCase()?.startsWith("geni");
356
- }
357
- isAncestry() {
358
- const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
359
- const sour = get(head, "SOUR.value");
360
- return !!sour?.toLowerCase()?.startsWith("ancestry");
361
- }
362
- isMyHeritage() {
363
- const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
364
- const sour = get(head, "SOUR.value");
365
- return !!sour?.toLowerCase()?.startsWith("myheritage");
366
- }
367
- isFamilySearch() {
368
- const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
369
- const sourName = get(head, "SOUR.NAME.value");
370
- return sourName === "FamilySearch API";
371
- }
372
- getAncestryTreeId() {
373
- const path = "HEAD.SOUR._TREE.RIN.value";
374
- return (get(this, path) || get(this.getGedcom(), path));
375
- }
376
- getMyHeritageTreeId() {
377
- const path = "HEAD._EXPORTED_FROM_SITE_ID.value";
378
- return (get(this, path) || get(this.getGedcom(), path));
379
- }
380
- getTreeId() {
381
- if (this?.isAncestry()) {
382
- return this.getAncestryTreeId();
383
- }
384
- if (this?.isMyHeritage()) {
385
- return this.getMyHeritageTreeId();
386
- }
387
- }
388
- getAncestryTreeName() {
389
- const path = "HEAD.SOUR._TREE.value";
390
- return (get(this, path) || get(this.getGedcom(), path));
391
- }
392
- getMyHeritageTreeName() {
393
- const path = "HEAD.FILE.value";
394
- const treeDetails = (get(this, path) || get(this.getGedcom(), path));
395
- return treeDetails?.match(/Exported by MyHeritage.com from (?<tree>.+) in.+$/)?.groups?.tree;
396
- }
397
- getTreeName() {
398
- if (this?.isAncestry()) {
399
- return this.getAncestryTreeName();
400
- }
401
- if (this?.isMyHeritage()) {
402
- return this.getMyHeritageTreeName();
403
- }
404
- }
405
- }
406
- export const createProxy = (target) => {
407
- return new Proxy(target, {
408
- get(t, prop, receiver) {
409
- if (prop === "unwrapped") {
410
- return target;
411
- }
412
- if (prop in t) {
413
- return Reflect.get(t, prop, receiver);
414
- }
415
- if (!isOnlyMainProp(prop)) {
416
- const ref = t.ref;
417
- if (ref && prop in ref) {
418
- return Reflect.get(ref, prop, receiver);
419
- }
420
- }
421
- },
422
- });
423
- };
424
- export const createCommon = (gedcom, id, main, parent) => {
425
- return createProxy(new Common(gedcom, id, main, parent));
426
- };
427
- export const isOnlyMainProp = (key) => {
428
- return (key === "_gedcom" ||
429
- key === "_main" ||
430
- key === "_parent" ||
431
- key === "_uniqueId" ||
432
- key === "_type" ||
433
- key === "_refs" ||
434
- key === "id" ||
435
- key === "_id");
436
- };
437
- export const isValidKey = (common, key) => {
438
- const prop = get(common, key);
439
- return (key !== "_gedcom" &&
440
- key !== "_main" &&
441
- key !== "_parent" &&
442
- key !== "_uniqueId" &&
443
- key !== "_refs" &&
444
- key !== "_type" &&
445
- (key === "id" ||
446
- key === "_id" ||
447
- key === "value" ||
448
- key === "_value" ||
449
- prop instanceof Common ||
450
- prop instanceof List));
451
- };
452
- export const getValidKeys = (common) => {
453
- return Object.keys(common).filter((key) => {
454
- return isValidKey(common, key);
455
- });
456
- };
457
- export const getValidTag = (tag) => {
458
- return tag.replace(/^@@/, "");
459
- };
460
- export const getListTag = (tag) => {
461
- return `@@${tag}`;
462
- };
463
- export const getValidKey = (tag, id) => {
464
- return `${id} ${getValidTag(tag)}`;
465
- };
466
- export const isId = (string) => {
467
- return ID_REG.test(string);
468
- };
469
- export const idGetter = (id) => {
470
- if (id === undefined) {
471
- return undefined;
472
- }
473
- let newId = `${id}`;
474
- const parts = newId?.match(ID_GETTER_REG)?.groups;
475
- if (!parts?.at && !parts?.letter) {
476
- newId = `@U${newId}`;
477
- }
478
- else if (!parts.at) {
479
- newId = `@${newId}`;
480
- }
481
- else if (!parts.letter) {
482
- newId = newId.replace(/^@/, "@U");
483
- }
484
- if (!newId.endsWith("@")) {
485
- newId = `${newId}@`;
486
- }
487
- return newId;
488
- };
@@ -1,27 +0,0 @@
1
- import type { Locale } from "date-fns";
2
- import type { IdType, MultiTag } from "../types/types";
3
- import type { Range } from "../utils/range";
4
- import { Common } from "./common";
5
- import type { ProxyOriginal } from "./common";
6
- import type { GedComType } from "./gedcom";
7
- import type { List } from "./list";
8
- export declare class CommonDate extends Common<string> {
9
- private _date?;
10
- DAY?: Common;
11
- MONTH?: Common;
12
- YEAR?: Common;
13
- NOTE?: Common;
14
- constructor(gedcom?: GedComType, id?: IdType, main?: Common, parent?: Common);
15
- set value(value: string | undefined);
16
- get value(): string | undefined;
17
- get rawValue(): Date;
18
- assign<T extends Common | List = Common | List>(name: MultiTag, value: T, unique?: boolean): T;
19
- private isValidDateFormat;
20
- toNote(short?: boolean): string | undefined;
21
- toValue(dateFormat?: string, locale?: Locale | null): string | undefined;
22
- exportValue(): string;
23
- inRange(range: Range, trueIfNoYear?: boolean): boolean;
24
- }
25
- export declare const createCommonDate: (gedcom?: GedComType, id?: IdType, main?: Common, parent?: Common) => ProxyOriginal<CommonDate>;
26
- export declare const isCommonDate: (value?: unknown) => value is CommonDate;
27
- //# sourceMappingURL=date.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/classes/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIvC,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAA6B,MAAM,UAA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