@pubid/pubid 0.1.71 → 0.1.73

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 (444) hide show
  1. package/README.md +22 -4
  2. package/artifact/corpus.json.gz +0 -0
  3. package/dist/flavors/ansi/generated/substrate.d.ts +78 -0
  4. package/dist/flavors/ansi/generated/substrate.js +105 -0
  5. package/dist/flavors/ansi/implementation.d.ts +5 -0
  6. package/dist/flavors/ansi/implementation.js +125 -0
  7. package/dist/flavors/ansi/index.js +14 -117
  8. package/dist/flavors/api/generated/substrate.d.ts +78 -0
  9. package/dist/flavors/api/generated/substrate.js +105 -0
  10. package/dist/flavors/api/grammar.worker.d.ts +6 -0
  11. package/dist/flavors/api/{grammar.js → grammar.worker.js} +60 -16
  12. package/dist/flavors/api/implementation.d.ts +11 -0
  13. package/dist/flavors/api/implementation.js +106 -0
  14. package/dist/flavors/api/index.d.ts +1 -3
  15. package/dist/flavors/api/index.js +14 -98
  16. package/dist/flavors/arxiv/generated/substrate.d.ts +75 -0
  17. package/dist/flavors/arxiv/generated/substrate.js +102 -0
  18. package/dist/flavors/arxiv/index.js +17 -11
  19. package/dist/flavors/ashrae/generated/substrate.d.ts +78 -0
  20. package/dist/flavors/ashrae/generated/substrate.js +105 -0
  21. package/dist/flavors/ashrae/grammar.worker.d.ts +6 -0
  22. package/dist/flavors/ashrae/{grammar.js → grammar.worker.js} +76 -39
  23. package/dist/flavors/ashrae/implementation.d.ts +7 -0
  24. package/dist/flavors/ashrae/implementation.js +316 -0
  25. package/dist/flavors/ashrae/index.d.ts +1 -3
  26. package/dist/flavors/ashrae/index.js +14 -304
  27. package/dist/flavors/asme/generated/substrate.d.ts +78 -0
  28. package/dist/flavors/asme/generated/substrate.js +105 -0
  29. package/dist/flavors/asme/grammar.worker.d.ts +6 -0
  30. package/dist/flavors/asme/{grammar.js → grammar.worker.js} +41 -2
  31. package/dist/flavors/asme/implementation.d.ts +7 -0
  32. package/dist/flavors/asme/implementation.js +152 -0
  33. package/dist/flavors/asme/index.d.ts +1 -3
  34. package/dist/flavors/asme/index.js +14 -136
  35. package/dist/flavors/astm/generated/substrate.d.ts +78 -0
  36. package/dist/flavors/astm/generated/substrate.js +105 -0
  37. package/dist/flavors/astm/grammar.worker.d.ts +6 -0
  38. package/dist/flavors/astm/{grammar.js → grammar.worker.js} +39 -5
  39. package/dist/flavors/astm/implementation.d.ts +6 -0
  40. package/dist/flavors/astm/implementation.js +135 -0
  41. package/dist/flavors/astm/index.js +14 -125
  42. package/dist/flavors/bipm/generated/substrate.d.ts +78 -0
  43. package/dist/flavors/bipm/generated/substrate.js +105 -0
  44. package/dist/flavors/bipm/grammar.worker.d.ts +6 -0
  45. package/dist/flavors/bipm/grammar.worker.js +180 -0
  46. package/dist/flavors/bipm/implementation.d.ts +6 -0
  47. package/dist/flavors/bipm/implementation.js +244 -0
  48. package/dist/flavors/bipm/index.d.ts +1 -28
  49. package/dist/flavors/bipm/index.js +16 -650
  50. package/dist/flavors/bipm/model.d.ts +80 -0
  51. package/dist/flavors/bipm/model.js +271 -0
  52. package/dist/flavors/bipm/worker.d.ts +2 -0
  53. package/dist/flavors/bipm/worker.js +19 -0
  54. package/dist/flavors/bsi/generated/substrate.d.ts +78 -0
  55. package/dist/flavors/bsi/generated/substrate.js +105 -0
  56. package/dist/flavors/bsi/grammar.worker.d.ts +6 -0
  57. package/dist/flavors/bsi/{grammar.js → grammar.worker.js} +36 -7
  58. package/dist/flavors/bsi/implementation.d.ts +12 -0
  59. package/dist/flavors/bsi/implementation.js +967 -0
  60. package/dist/flavors/bsi/index.d.ts +1 -3
  61. package/dist/flavors/bsi/index.js +15 -940
  62. package/dist/flavors/bsi/model.js +16 -0
  63. package/dist/flavors/bsi/worker.js +11 -4
  64. package/dist/flavors/bsi_pfs/index.d.ts +25 -0
  65. package/dist/flavors/bsi_pfs/index.js +73 -10
  66. package/dist/flavors/calconnect/generated/substrate.d.ts +75 -0
  67. package/dist/flavors/calconnect/generated/substrate.js +102 -0
  68. package/dist/flavors/calconnect/grammar.worker.d.ts +6 -0
  69. package/dist/flavors/calconnect/grammar.worker.js +60 -0
  70. package/dist/flavors/calconnect/implementation.d.ts +6 -0
  71. package/dist/flavors/calconnect/implementation.js +69 -0
  72. package/dist/flavors/calconnect/index.d.ts +1 -19
  73. package/dist/flavors/calconnect/index.js +15 -111
  74. package/dist/flavors/calconnect/model.d.ts +26 -0
  75. package/dist/flavors/calconnect/model.js +52 -0
  76. package/dist/flavors/ccsds/generated/substrate.d.ts +75 -0
  77. package/dist/flavors/ccsds/generated/substrate.js +102 -0
  78. package/dist/flavors/ccsds/implementation.d.ts +5 -0
  79. package/dist/flavors/ccsds/implementation.js +67 -0
  80. package/dist/flavors/ccsds/index.js +13 -57
  81. package/dist/flavors/cen_cenelec/generated/substrate.d.ts +78 -0
  82. package/dist/flavors/cen_cenelec/generated/substrate.js +105 -0
  83. package/dist/flavors/cen_cenelec/grammar.worker.d.ts +6 -0
  84. package/dist/flavors/cen_cenelec/{grammar.js → grammar.worker.js} +41 -13
  85. package/dist/flavors/cen_cenelec/implementation.d.ts +15 -0
  86. package/dist/flavors/cen_cenelec/implementation.js +322 -0
  87. package/dist/flavors/cen_cenelec/index.d.ts +2 -4
  88. package/dist/flavors/cen_cenelec/index.js +16 -286
  89. package/dist/flavors/cen_cenelec/model.js +16 -1
  90. package/dist/flavors/cen_cenelec/worker.js +10 -4
  91. package/dist/flavors/cen_pfs/index.d.ts +5 -0
  92. package/dist/flavors/cen_pfs/index.js +28 -2
  93. package/dist/flavors/cie/generated/substrate.d.ts +78 -0
  94. package/dist/flavors/cie/generated/substrate.js +105 -0
  95. package/dist/flavors/cie/grammar.worker.d.ts +6 -0
  96. package/dist/flavors/cie/{grammar.js → grammar.worker.js} +71 -18
  97. package/dist/flavors/cie/implementation.d.ts +9 -0
  98. package/dist/flavors/cie/implementation.js +331 -0
  99. package/dist/flavors/cie/index.js +14 -309
  100. package/dist/flavors/csa/generated/substrate.d.ts +78 -0
  101. package/dist/flavors/csa/generated/substrate.js +105 -0
  102. package/dist/flavors/csa/grammar.worker.d.ts +12 -0
  103. package/dist/flavors/csa/{grammar.js → grammar.worker.js} +143 -27
  104. package/dist/flavors/csa/implementation.d.ts +9 -0
  105. package/dist/flavors/csa/implementation.js +661 -0
  106. package/dist/flavors/csa/index.js +14 -631
  107. package/dist/flavors/csa/worker.js +10 -4
  108. package/dist/flavors/easc/generated/substrate.d.ts +75 -0
  109. package/dist/flavors/easc/generated/substrate.js +102 -0
  110. package/dist/flavors/easc/grammar.worker.d.ts +6 -0
  111. package/dist/flavors/easc/grammar.worker.js +66 -0
  112. package/dist/flavors/easc/implementation.d.ts +6 -0
  113. package/dist/flavors/easc/implementation.js +58 -0
  114. package/dist/flavors/easc/index.d.ts +1 -2
  115. package/dist/flavors/easc/index.js +15 -105
  116. package/dist/flavors/easc/model.d.ts +10 -0
  117. package/dist/flavors/easc/model.js +43 -0
  118. package/dist/flavors/ecma/generated/substrate.d.ts +75 -0
  119. package/dist/flavors/ecma/generated/substrate.js +102 -0
  120. package/dist/flavors/ecma/grammar.worker.d.ts +6 -0
  121. package/dist/flavors/ecma/grammar.worker.js +63 -0
  122. package/dist/flavors/ecma/implementation.d.ts +6 -0
  123. package/dist/flavors/ecma/implementation.js +95 -0
  124. package/dist/flavors/ecma/index.d.ts +1 -2
  125. package/dist/flavors/ecma/index.js +15 -152
  126. package/dist/flavors/ecma/model.d.ts +10 -0
  127. package/dist/flavors/ecma/model.js +61 -0
  128. package/dist/flavors/etsi/generated/substrate.d.ts +75 -0
  129. package/dist/flavors/etsi/generated/substrate.js +102 -0
  130. package/dist/flavors/etsi/grammar.worker.d.ts +6 -0
  131. package/dist/flavors/etsi/grammar.worker.js +86 -0
  132. package/dist/flavors/etsi/implementation.d.ts +6 -0
  133. package/dist/flavors/etsi/implementation.js +110 -0
  134. package/dist/flavors/etsi/index.d.ts +2 -12
  135. package/dist/flavors/etsi/index.js +16 -305
  136. package/dist/flavors/etsi/model.d.ts +37 -0
  137. package/dist/flavors/etsi/model.js +169 -0
  138. package/dist/flavors/eu/generated/substrate.d.ts +75 -0
  139. package/dist/flavors/eu/generated/substrate.js +102 -0
  140. package/dist/flavors/eu/implementation.d.ts +7 -0
  141. package/dist/flavors/eu/implementation.js +150 -0
  142. package/dist/flavors/eu/index.js +14 -141
  143. package/dist/flavors/evs/generated/substrate.d.ts +78 -0
  144. package/dist/flavors/evs/generated/substrate.js +105 -0
  145. package/dist/flavors/evs/grammar.worker.d.ts +6 -0
  146. package/dist/flavors/evs/grammar.worker.js +98 -0
  147. package/dist/flavors/evs/implementation.d.ts +7 -0
  148. package/dist/flavors/evs/implementation.js +114 -0
  149. package/dist/flavors/evs/index.d.ts +1 -1
  150. package/dist/flavors/evs/index.js +14 -89
  151. package/dist/flavors/evs/worker.js +10 -4
  152. package/dist/flavors/gb/generated/substrate.d.ts +75 -0
  153. package/dist/flavors/gb/generated/substrate.js +102 -0
  154. package/dist/flavors/gb/grammar.worker.d.ts +6 -0
  155. package/dist/flavors/gb/grammar.worker.js +73 -0
  156. package/dist/flavors/gb/implementation.d.ts +6 -0
  157. package/dist/flavors/gb/implementation.js +87 -0
  158. package/dist/flavors/gb/index.d.ts +1 -29
  159. package/dist/flavors/gb/index.js +15 -157
  160. package/dist/flavors/gb/model.d.ts +36 -0
  161. package/dist/flavors/gb/model.js +79 -0
  162. package/dist/flavors/gost/generated/substrate.d.ts +78 -0
  163. package/dist/flavors/gost/generated/substrate.js +105 -0
  164. package/dist/flavors/gost/grammar.worker.d.ts +6 -0
  165. package/dist/flavors/gost/grammar.worker.js +82 -0
  166. package/dist/flavors/gost/implementation.d.ts +7 -0
  167. package/dist/flavors/gost/implementation.js +177 -0
  168. package/dist/flavors/gost/index.js +14 -162
  169. package/dist/flavors/gost/worker.js +12 -5
  170. package/dist/flavors/iala/generated/substrate.d.ts +78 -0
  171. package/dist/flavors/iala/generated/substrate.js +105 -0
  172. package/dist/flavors/iala/grammar.worker.d.ts +6 -0
  173. package/dist/flavors/iala/grammar.worker.js +127 -0
  174. package/dist/flavors/iala/implementation.d.ts +6 -0
  175. package/dist/flavors/iala/implementation.js +250 -0
  176. package/dist/flavors/iala/index.d.ts +1 -56
  177. package/dist/flavors/iala/index.js +17 -484
  178. package/dist/flavors/iala/model.d.ts +93 -0
  179. package/dist/flavors/iala/model.js +194 -0
  180. package/dist/flavors/iana/generated/substrate.d.ts +75 -0
  181. package/dist/flavors/iana/generated/substrate.js +102 -0
  182. package/dist/flavors/iana/grammar.worker.d.ts +6 -0
  183. package/dist/flavors/iana/grammar.worker.js +51 -0
  184. package/dist/flavors/iana/implementation.d.ts +6 -0
  185. package/dist/flavors/iana/implementation.js +47 -0
  186. package/dist/flavors/iana/index.d.ts +1 -17
  187. package/dist/flavors/iana/index.js +15 -69
  188. package/dist/flavors/iana/model.d.ts +22 -0
  189. package/dist/flavors/iana/model.js +33 -0
  190. package/dist/flavors/idf/generated/substrate.d.ts +78 -0
  191. package/dist/flavors/idf/generated/substrate.js +105 -0
  192. package/dist/flavors/idf/grammar.worker.d.ts +6 -0
  193. package/dist/flavors/idf/{grammar.js → grammar.worker.js} +58 -2
  194. package/dist/flavors/idf/implementation.d.ts +6 -0
  195. package/dist/flavors/idf/implementation.js +129 -0
  196. package/dist/flavors/idf/index.js +14 -98
  197. package/dist/flavors/iec/generated/substrate.d.ts +78 -0
  198. package/dist/flavors/iec/generated/substrate.js +105 -0
  199. package/dist/flavors/iec/grammar.worker.d.ts +6 -0
  200. package/dist/flavors/iec/grammar.worker.js +231 -0
  201. package/dist/flavors/iec/implementation.d.ts +15 -0
  202. package/dist/flavors/iec/implementation.js +956 -0
  203. package/dist/flavors/iec/index.d.ts +1 -2
  204. package/dist/flavors/iec/index.js +16 -869
  205. package/dist/flavors/iec/model.js +13 -1
  206. package/dist/flavors/iec/worker.d.ts +2 -0
  207. package/dist/flavors/iec/worker.js +19 -0
  208. package/dist/flavors/ieee/generated/substrate.d.ts +78 -0
  209. package/dist/flavors/ieee/generated/substrate.js +105 -0
  210. package/dist/flavors/ieee/implementation.d.ts +4 -0
  211. package/dist/flavors/ieee/implementation.js +48 -10
  212. package/dist/flavors/ieee/index.d.ts +3 -2
  213. package/dist/flavors/ieee/index.js +30 -12
  214. package/dist/flavors/ieee/model.js +17 -4
  215. package/dist/flavors/ieee/preprocessor.js +11 -10
  216. package/dist/flavors/ieee/worker.js +33 -11
  217. package/dist/flavors/ietf/generated/substrate.d.ts +75 -0
  218. package/dist/flavors/ietf/generated/substrate.js +102 -0
  219. package/dist/flavors/ietf/grammar.worker.d.ts +6 -0
  220. package/dist/flavors/ietf/grammar.worker.js +63 -0
  221. package/dist/flavors/ietf/implementation.d.ts +6 -0
  222. package/dist/flavors/ietf/implementation.js +60 -0
  223. package/dist/flavors/ietf/index.d.ts +1 -28
  224. package/dist/flavors/ietf/index.js +15 -149
  225. package/dist/flavors/ietf/model.d.ts +47 -0
  226. package/dist/flavors/ietf/model.js +92 -0
  227. package/dist/flavors/iho/generated/substrate.d.ts +78 -0
  228. package/dist/flavors/iho/generated/substrate.js +105 -0
  229. package/dist/flavors/iho/grammar.worker.d.ts +6 -0
  230. package/dist/flavors/iho/grammar.worker.js +150 -0
  231. package/dist/flavors/iho/implementation.d.ts +6 -0
  232. package/dist/flavors/iho/implementation.js +221 -0
  233. package/dist/flavors/iho/index.d.ts +1 -2
  234. package/dist/flavors/iho/index.js +15 -619
  235. package/dist/flavors/iho/model.d.ts +11 -0
  236. package/dist/flavors/iho/model.js +315 -0
  237. package/dist/flavors/index.js +3 -0
  238. package/dist/flavors/iso/generated/substrate.d.ts +93 -0
  239. package/dist/flavors/iso/generated/substrate.js +133 -0
  240. package/dist/flavors/iso/grammar.worker.d.ts +7 -0
  241. package/dist/flavors/iso/grammar.worker.js +406 -0
  242. package/dist/flavors/iso/implementation.d.ts +4 -0
  243. package/dist/flavors/iso/implementation.js +880 -0
  244. package/dist/flavors/iso/index.js +16 -706
  245. package/dist/flavors/iso/model.js +21 -2
  246. package/dist/flavors/iso/worker.d.ts +2 -0
  247. package/dist/flavors/iso/worker.js +19 -0
  248. package/dist/flavors/itu/generated/substrate.d.ts +78 -0
  249. package/dist/flavors/itu/generated/substrate.js +105 -0
  250. package/dist/flavors/itu/grammar.worker.d.ts +6 -0
  251. package/dist/flavors/itu/grammar.worker.js +306 -0
  252. package/dist/flavors/itu/implementation.d.ts +10 -0
  253. package/dist/flavors/itu/implementation.js +285 -0
  254. package/dist/flavors/itu/index.js +15 -246
  255. package/dist/flavors/itu/worker.d.ts +2 -0
  256. package/dist/flavors/itu/worker.js +19 -0
  257. package/dist/flavors/jcgm/generated/substrate.d.ts +78 -0
  258. package/dist/flavors/jcgm/generated/substrate.js +105 -0
  259. package/dist/flavors/jcgm/grammar.worker.d.ts +6 -0
  260. package/dist/flavors/jcgm/grammar.worker.js +98 -0
  261. package/dist/flavors/jcgm/implementation.d.ts +6 -0
  262. package/dist/flavors/jcgm/implementation.js +187 -0
  263. package/dist/flavors/jcgm/index.d.ts +1 -5
  264. package/dist/flavors/jcgm/index.js +16 -364
  265. package/dist/flavors/jcgm/model.d.ts +43 -0
  266. package/dist/flavors/jcgm/model.js +168 -0
  267. package/dist/flavors/jis/generated/substrate.d.ts +78 -0
  268. package/dist/flavors/jis/generated/substrate.js +105 -0
  269. package/dist/flavors/jis/grammar.worker.d.ts +6 -0
  270. package/dist/flavors/jis/grammar.worker.js +132 -0
  271. package/dist/flavors/jis/implementation.d.ts +6 -0
  272. package/dist/flavors/jis/implementation.js +129 -0
  273. package/dist/flavors/jis/index.d.ts +0 -2
  274. package/dist/flavors/jis/index.js +15 -390
  275. package/dist/flavors/jis/model.d.ts +30 -0
  276. package/dist/flavors/jis/model.js +205 -0
  277. package/dist/flavors/jis/worker.d.ts +2 -0
  278. package/dist/flavors/jis/worker.js +19 -0
  279. package/dist/flavors/nist/generated/substrate.d.ts +78 -0
  280. package/dist/flavors/nist/generated/substrate.js +105 -0
  281. package/dist/flavors/nist/index.js +18 -11
  282. package/dist/flavors/nist/worker.js +8 -4
  283. package/dist/flavors/oasis/generated/substrate.d.ts +75 -0
  284. package/dist/flavors/oasis/generated/substrate.js +102 -0
  285. package/dist/flavors/oasis/grammar.worker.d.ts +6 -0
  286. package/dist/flavors/oasis/grammar.worker.js +50 -0
  287. package/dist/flavors/oasis/implementation.d.ts +6 -0
  288. package/dist/flavors/oasis/implementation.js +80 -0
  289. package/dist/flavors/oasis/index.d.ts +1 -21
  290. package/dist/flavors/oasis/index.js +16 -108
  291. package/dist/flavors/oasis/model.d.ts +27 -0
  292. package/dist/flavors/oasis/model.js +34 -0
  293. package/dist/flavors/ogc/generated/substrate.d.ts +75 -0
  294. package/dist/flavors/ogc/generated/substrate.js +102 -0
  295. package/dist/flavors/ogc/grammar.worker.d.ts +6 -0
  296. package/dist/flavors/ogc/grammar.worker.js +55 -0
  297. package/dist/flavors/ogc/implementation.d.ts +6 -0
  298. package/dist/flavors/ogc/implementation.js +49 -0
  299. package/dist/flavors/ogc/index.d.ts +1 -18
  300. package/dist/flavors/ogc/index.js +15 -73
  301. package/dist/flavors/ogc/model.d.ts +23 -0
  302. package/dist/flavors/ogc/model.js +32 -0
  303. package/dist/flavors/oiml/generated/substrate.d.ts +78 -0
  304. package/dist/flavors/oiml/generated/substrate.js +105 -0
  305. package/dist/flavors/oiml/grammar.worker.d.ts +6 -0
  306. package/dist/flavors/oiml/grammar.worker.js +239 -0
  307. package/dist/flavors/oiml/implementation.d.ts +2 -1
  308. package/dist/flavors/oiml/implementation.js +16 -7
  309. package/dist/flavors/oiml/index.js +15 -6
  310. package/dist/flavors/oiml/model.js +19 -19
  311. package/dist/flavors/oiml/worker.js +14 -6
  312. package/dist/flavors/omg/generated/substrate.d.ts +78 -0
  313. package/dist/flavors/omg/generated/substrate.js +105 -0
  314. package/dist/flavors/omg/grammar.worker.d.ts +6 -0
  315. package/dist/flavors/omg/grammar.worker.js +64 -0
  316. package/dist/flavors/omg/implementation.d.ts +7 -0
  317. package/dist/flavors/omg/implementation.js +33 -0
  318. package/dist/flavors/omg/index.d.ts +1 -12
  319. package/dist/flavors/omg/index.js +15 -71
  320. package/dist/flavors/omg/model.d.ts +16 -0
  321. package/dist/flavors/omg/model.js +26 -0
  322. package/dist/flavors/plateau/generated/substrate.d.ts +78 -0
  323. package/dist/flavors/plateau/generated/substrate.js +105 -0
  324. package/dist/flavors/plateau/grammar.worker.d.ts +6 -0
  325. package/dist/flavors/plateau/grammar.worker.js +78 -0
  326. package/dist/flavors/plateau/implementation.d.ts +6 -0
  327. package/dist/flavors/plateau/implementation.js +74 -0
  328. package/dist/flavors/plateau/index.d.ts +1 -2
  329. package/dist/flavors/plateau/index.js +18 -114
  330. package/dist/flavors/plateau/model.d.ts +11 -0
  331. package/dist/flavors/plateau/model.js +51 -0
  332. package/dist/flavors/register-types.d.ts +20 -19
  333. package/dist/flavors/register-types.js +44 -19
  334. package/dist/flavors/sae/generated/substrate.d.ts +75 -0
  335. package/dist/flavors/sae/generated/substrate.js +102 -0
  336. package/dist/flavors/sae/grammar.worker.d.ts +6 -0
  337. package/dist/flavors/sae/grammar.worker.js +84 -0
  338. package/dist/flavors/sae/implementation.d.ts +11 -0
  339. package/dist/flavors/sae/implementation.js +109 -0
  340. package/dist/flavors/sae/index.d.ts +3 -0
  341. package/dist/flavors/sae/index.js +19 -0
  342. package/dist/flavors/sae/model.d.ts +86 -0
  343. package/dist/flavors/sae/model.js +185 -0
  344. package/dist/flavors/tgpp/generated/substrate.d.ts +78 -0
  345. package/dist/flavors/tgpp/generated/substrate.js +105 -0
  346. package/dist/flavors/tgpp/grammar.worker.d.ts +6 -0
  347. package/dist/flavors/tgpp/grammar.worker.js +69 -0
  348. package/dist/flavors/tgpp/implementation.d.ts +8 -0
  349. package/dist/flavors/tgpp/implementation.js +56 -0
  350. package/dist/flavors/tgpp/index.d.ts +1 -2
  351. package/dist/flavors/tgpp/index.js +15 -120
  352. package/dist/flavors/tgpp/model.d.ts +13 -0
  353. package/dist/flavors/tgpp/model.js +52 -0
  354. package/dist/flavors/w3c/generated/substrate.d.ts +78 -0
  355. package/dist/flavors/w3c/generated/substrate.js +105 -0
  356. package/dist/flavors/w3c/grammar.worker.d.ts +6 -0
  357. package/dist/flavors/w3c/grammar.worker.js +55 -0
  358. package/dist/flavors/w3c/implementation.d.ts +7 -0
  359. package/dist/flavors/w3c/implementation.js +49 -0
  360. package/dist/flavors/w3c/index.d.ts +1 -12
  361. package/dist/flavors/w3c/index.js +15 -146
  362. package/dist/flavors/w3c/model.d.ts +15 -0
  363. package/dist/flavors/w3c/model.js +103 -0
  364. package/dist/flavors/wmo/generated/substrate.d.ts +78 -0
  365. package/dist/flavors/wmo/generated/substrate.js +105 -0
  366. package/dist/flavors/wmo/implementation.d.ts +5 -0
  367. package/dist/flavors/wmo/implementation.js +79 -0
  368. package/dist/flavors/wmo/index.js +14 -68
  369. package/dist/flavors/worker-registry.js +246 -68
  370. package/dist/flavors/xsf/generated/substrate.d.ts +75 -0
  371. package/dist/flavors/xsf/generated/substrate.js +102 -0
  372. package/dist/flavors/xsf/grammar.worker.d.ts +6 -0
  373. package/dist/flavors/xsf/grammar.worker.js +53 -0
  374. package/dist/flavors/xsf/implementation.d.ts +6 -0
  375. package/dist/flavors/xsf/implementation.js +34 -0
  376. package/dist/flavors/xsf/index.d.ts +1 -16
  377. package/dist/flavors/xsf/index.js +16 -63
  378. package/dist/flavors/xsf/model.d.ts +20 -0
  379. package/dist/flavors/xsf/model.js +26 -0
  380. package/dist/index.d.ts +2 -2
  381. package/dist/index.js +1 -1
  382. package/dist/lane-keys.d.ts +68 -0
  383. package/dist/lane-keys.js +113 -0
  384. package/dist/model/identifier.d.ts +13 -1
  385. package/dist/model/identifier.js +76 -13
  386. package/dist/model/relation.d.ts +36 -0
  387. package/dist/model/relation.js +93 -0
  388. package/dist/parg/artifacts/ieee.d.ts +1 -1
  389. package/dist/parg/artifacts/ieee.js +1 -1
  390. package/dist/parg/worker.d.ts +4 -2
  391. package/dist/parg/worker.js +5 -3
  392. package/dist/parse-surface.d.ts +3 -31
  393. package/dist/parse-surface.js +6 -69
  394. package/dist/pubid-urn/decoder.d.ts +8 -0
  395. package/dist/pubid-urn/decoder.js +43 -0
  396. package/dist/pubid-urn/encoder.js +31 -0
  397. package/dist/pubid-urn/schema.d.ts +1 -1
  398. package/dist/pubid-urn/schema.js +1 -1
  399. package/dist/pubid-urn/schemas/bsi.js +1 -0
  400. package/dist/pubid-urn/schemas/bsi_pfs.js +9 -7
  401. package/dist/pubid-urn/schemas/cen_pfs.js +1 -0
  402. package/dist/pubid-urn/schemas/cencenelec.js +1 -0
  403. package/dist/pubid-urn/schemas/iec.js +1 -0
  404. package/dist/pubid-urn/schemas/ieee.js +1 -0
  405. package/dist/pubid-urn/schemas/iso.js +1 -0
  406. package/package.json +1 -1
  407. package/vendor/parg/bsi_pfs.json +1 -1
  408. package/vendor/parg/calconnect_pfs.json +1 -1
  409. package/vendor/parg/cen_pfs.json +1 -1
  410. package/vendor/parg/doi_pfs.json +1 -1
  411. package/vendor/parg/etsi_pfs.json +1 -1
  412. package/vendor/parg/ieee.json +1 -1
  413. package/vendor/parg/iho.json +1 -1
  414. package/vendor/parg/plateau.json +1 -1
  415. package/dist/flavors/api/grammar.d.ts +0 -4
  416. package/dist/flavors/ashrae/grammar.d.ts +0 -2
  417. package/dist/flavors/asme/grammar.d.ts +0 -2
  418. package/dist/flavors/astm/grammar.d.ts +0 -2
  419. package/dist/flavors/bsi/grammar.d.ts +0 -4
  420. package/dist/flavors/cen_cenelec/grammar.d.ts +0 -4
  421. package/dist/flavors/cie/grammar.d.ts +0 -5
  422. package/dist/flavors/csa/grammar.d.ts +0 -6
  423. package/dist/flavors/evs/grammar.d.ts +0 -2
  424. package/dist/flavors/evs/grammar.js +0 -68
  425. package/dist/flavors/gost/grammar.d.ts +0 -2
  426. package/dist/flavors/gost/grammar.js +0 -46
  427. package/dist/flavors/idf/grammar.d.ts +0 -2
  428. package/dist/flavors/iec/grammar.d.ts +0 -3
  429. package/dist/flavors/iec/grammar.js +0 -234
  430. package/dist/flavors/ieee/grammar.d.ts +0 -2
  431. package/dist/flavors/ieee/grammar.js +0 -777
  432. package/dist/flavors/iso/grammar.d.ts +0 -7
  433. package/dist/flavors/iso/grammar.js +0 -282
  434. package/dist/flavors/itu/grammar.d.ts +0 -4
  435. package/dist/flavors/itu/grammar.js +0 -276
  436. package/dist/flavors/nist/grammar.d.ts +0 -2
  437. package/dist/flavors/nist/grammar.js +0 -342
  438. package/dist/flavors/oiml/grammar.d.ts +0 -2
  439. package/dist/flavors/oiml/grammar.js +0 -206
  440. package/vendor/parg/csv.json +0 -1
  441. package/vendor/parg/ini.json +0 -1
  442. package/vendor/parg/json.json +0 -1
  443. package/vendor/parg/lua.json +0 -1
  444. package/vendor/parg/toml.json +0 -1
@@ -0,0 +1,967 @@
1
+ //! The bsi semantic delta over the generated substrate
2
+ //! (pubid/pubid-grammar#162): the builder — dispatch, attribute
3
+ //! extraction, the specialized build paths, the adopted-identifier
4
+ //! routing, and the supplement/consolidated wrapping — plus the
5
+ //! parser.rb input normalization. Pure — no `node:*` module, no engine
6
+ //! import — so both entries (the node barrel over the wasm artifact
7
+ //! runtime, the worker entry over the pure-TS worker engine) run the
8
+ //! same delta.
9
+ //!
10
+ //! The parse function is injected: the entry binds it to
11
+ //! `substrate.boundToWire(substrate.parseBound(body))` (node) or the
12
+ //! worker engine's equivalent (worker), both producing the artifact's
13
+ //! declared wire — the hand grammar.ts's captures spell it unchanged
14
+ //! (the 92-capture surface matched the artifact's bindings row for
15
+ //! row), so this delta reads one shape on both engines without
16
+ //! re-spelling.
17
+ import { PubidDate, Publisher } from "../../model/component.js";
18
+ import { AdoptedEuropeanNormClass as CenAdoptedEuropeanNormClass } from "../cen_cenelec/model.js";
19
+ import { AddendumDocumentClass, AdoptedEuropeanNormClass, AdoptedInternationalStandardClass, AerospaceStandardClass, Amendment, BsiCode, BsiIdentifier, BundledIdentifierClass, BritishStandardClass, CommitteeDocumentClass, ConsolidatedIdentifierClass, Corrigendum, DetailedSpecificationClass, DiscClass, ExpertCommentaryClass, ExplanatorySupplementClass, FlexClass, IndexClass, MethodClass, NationalAnnexClass, SectionClass, SetClass, StandaloneAmendmentClass, SupplementDocumentClass, SupplementaryIndexClass, TestMethodClass, ValueAddedPublicationClass, locateStage, DEFAULT_TYPED_STAGE, TYPE_CLASSES, } from "./model.js";
20
+ /** Parser.parse normalization (parser.rb self.parse): the BSI Flex
21
+ * spelling keeps its prefix, every other "BSI " rides as "BS ". A peel
22
+ * is a judgment about inputs — the CODEGEN-SPEC section 3 residue. */
23
+ export function preprocessBsi(input) {
24
+ return input.startsWith("BSI Flex")
25
+ ? input
26
+ : input.replaceAll(/\bBSI\s+/g, "BS ");
27
+ }
28
+ const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
29
+ // Parse-tree numbers arrive as {number: "1000"} (the rule's own .as).
30
+ const numv = (v) => {
31
+ if (isObj(v))
32
+ return strv(v["number"]);
33
+ return strv(v);
34
+ };
35
+ const strv = (v) => {
36
+ if (v === undefined || v === null)
37
+ return undefined;
38
+ if (Array.isArray(v)) {
39
+ if (v.length === 0)
40
+ return undefined;
41
+ const joined = v.flat(Infinity).map(String).join("");
42
+ return joined.length > 0 ? joined : undefined;
43
+ }
44
+ const s = String(v).trim();
45
+ return s.length > 0 ? s : undefined;
46
+ };
47
+ function flatten(data) {
48
+ return Array.isArray(data) ? Object.assign({}, ...data) : data;
49
+ }
50
+ const ctor = (klass) => klass;
51
+ function pub(body) {
52
+ return new Publisher({ body });
53
+ }
54
+ // The adopted routing mirrors the gem: a routed branch that fails to
55
+ // parse RAISES through (build_adopted_identifier calls the foreign
56
+ // parser directly), which is what rejects e.g. "BS HD 629.1 S3:2019".
57
+ function tryForeign(flavor, raw, resolveForeign) {
58
+ const impl = resolveForeign(flavor);
59
+ if (impl === undefined)
60
+ return undefined;
61
+ return impl.parse(raw);
62
+ }
63
+ function extractSupplementsFromArray(supps) {
64
+ return supps.map((s) => {
65
+ const supp = isObj(s) && s["supplement"] !== undefined ? s["supplement"] : (isObj(s) ? s : {});
66
+ const separator = supp["amd_sep_slash"] !== undefined ? "/" : "+";
67
+ return {
68
+ type: supp["amd_number"] !== undefined ? "amendment" : "corrigendum",
69
+ number: strv(supp["amd_number"] ?? supp["cor_number"]),
70
+ year: strv(supp["amd_year"] ?? supp["cor_year"]),
71
+ separator,
72
+ amd_suffix_form: supp["amd_sep_plus"] === undefined && supp["amd_sep_slash"] === undefined,
73
+ };
74
+ });
75
+ }
76
+ function extractSupplements(data) {
77
+ const raw = data["supplements"];
78
+ if (raw === undefined)
79
+ return [];
80
+ const arr = (Array.isArray(raw) ? raw.flat(Infinity) : [raw])
81
+ .filter((x) => isObj(x) || (Array.isArray(x) && x.length > 0));
82
+ if (arr.length === 0)
83
+ return [];
84
+ return extractSupplementsFromArray(arr);
85
+ }
86
+ function expandYear(yearVal) {
87
+ if (yearVal === undefined)
88
+ return undefined;
89
+ if (yearVal.length === 2)
90
+ return String(2000 + Number(yearVal));
91
+ return yearVal;
92
+ }
93
+ function wrapWithConsolidated(base, supplementsData) {
94
+ const supplementIds = supplementsData.map((supp) => {
95
+ const yearVal = expandYear(supp.year);
96
+ if (supp.type === "amendment") {
97
+ return new Amendment({
98
+ base,
99
+ number: supp.number,
100
+ year: yearVal,
101
+ separator: supp.separator,
102
+ amd_suffix_form: supp.amd_suffix_form ? true : false,
103
+ });
104
+ }
105
+ return new Corrigendum({
106
+ base,
107
+ number: supp.number,
108
+ year: yearVal,
109
+ separator: supp.separator,
110
+ });
111
+ });
112
+ const wrapper = new (ctor(ConsolidatedIdentifierClass))({
113
+ identifiers: [base, ...supplementIds],
114
+ });
115
+ // The gem serializes the FIRST member's typed stage onto the
116
+ // consolidated wrapper itself.
117
+ wrapper["typedStage"] =
118
+ base["typedStage"];
119
+ return wrapper;
120
+ }
121
+ function wrapWithExpertCommentary(baseId, original) {
122
+ // The grammar nests the topic/full flags under an "expert_commentary"
123
+ // subtree.
124
+ const ec = isObj(original["expert_commentary"]) ? original["expert_commentary"] : {};
125
+ const flags = { ...ec, ...original };
126
+ let format = "abbr";
127
+ if (flags["expert_commentary_full"] !== undefined)
128
+ format = "full";
129
+ else if (flags["expert_commentary_topic"] !== undefined)
130
+ format = "abbr_with_topic";
131
+ const topic = strv(flags["expert_commentary_topic"]);
132
+ return new (ctor(ExpertCommentaryClass))({ base: baseId, format, topic });
133
+ }
134
+ // --- Attribute extraction ------------------------------------------------------------
135
+ function partsToAttrs(partsVal) {
136
+ const arr = Array.isArray(partsVal) ? partsVal.flat(Infinity) : partsVal !== undefined ? [partsVal] : [];
137
+ if (arr.length === 0)
138
+ return {};
139
+ const first = isObj(arr[0]) ? arr[0] : undefined;
140
+ if (first === undefined)
141
+ return {};
142
+ const partStr = strv(first["part"]) ?? "";
143
+ if (first["subpart"] !== undefined) {
144
+ return { part: partStr, subpart: strv(first["subpart"]) };
145
+ }
146
+ const components = partStr.split("-");
147
+ if (components.length > 1) {
148
+ return { part: components[0], subpart: components[1] };
149
+ }
150
+ return { part: partStr };
151
+ }
152
+ function locateKlass(parsedHash) {
153
+ if (parsedHash["flex_type"] !== undefined)
154
+ return FlexClass;
155
+ if (parsedHash["na_prefix"] !== undefined)
156
+ return NationalAnnexClass;
157
+ if (parsedHash["prefix"] !== undefined)
158
+ return AerospaceStandardClass;
159
+ const adopted = strv(parsedHash["adopted_string"]);
160
+ if (adopted !== undefined && /^EN\s+\d/.test(adopted))
161
+ return AdoptedEuropeanNormClass;
162
+ if (adopted !== undefined)
163
+ return AdoptedInternationalStandardClass;
164
+ const typeStr = strv(parsedHash["type"]) ?? strv(parsedHash["stage"]) ?? "";
165
+ // Unknown abbreviations fall back to the DEFAULT_TYPED_STAGE (a
166
+ // published British Standard).
167
+ const stage = locateStage(typeStr.toUpperCase()) ?? DEFAULT_TYPED_STAGE;
168
+ return TYPE_CLASSES[stage.typeCode] ?? BritishStandardClass;
169
+ }
170
+ /** The registry entry the parse selected (stashed on the instance;
171
+ * the wire serializes it for non-default typed stages). */
172
+ function selectedStage(parsedHash) {
173
+ const typeStr = strv(parsedHash["type"]) ?? strv(parsedHash["stage"]) ?? "";
174
+ return locateStage(typeStr.toUpperCase()) ?? DEFAULT_TYPED_STAGE;
175
+ }
176
+ function assignAttributes(data) {
177
+ const attrs = {};
178
+ if (data["publisher"] !== undefined)
179
+ attrs["publisher"] = pub(strv(data["publisher"]) ?? "BS");
180
+ if (data["prefix"] !== undefined)
181
+ attrs["prefix"] = strv(data["prefix"]);
182
+ if (data["flex_prefix"] !== undefined)
183
+ attrs["flex_prefix"] = strv(data["flex_prefix"]);
184
+ if (data["number"] !== undefined)
185
+ attrs["number"] = strv(data["number"]);
186
+ if (data["iteration"] !== undefined) {
187
+ const iterationObj = isObj(data["iteration"]) ? data["iteration"] : undefined;
188
+ const iterationVal = iterationObj !== undefined ? strv(iterationObj["iteration"]) : strv(data["iteration"]);
189
+ if (iterationVal !== undefined && iterationVal !== "")
190
+ attrs["iteration"] = iterationVal;
191
+ }
192
+ const partsAttr = partsToAttrs(data["parts"]);
193
+ if (partsAttr.part !== undefined)
194
+ attrs["part"] = partsAttr.part;
195
+ if (partsAttr.subpart !== undefined)
196
+ attrs["subpart"] = partsAttr.subpart;
197
+ if (data["year"] !== undefined) {
198
+ attrs["date"] = new PubidDate({ year: String(Number(strv(data["year"]))) });
199
+ }
200
+ if (data["month"] !== undefined)
201
+ attrs["month"] = Number(strv(data["month"]));
202
+ if (data["edition"] !== undefined)
203
+ attrs["edition"] = strv(data["edition"]);
204
+ if (data["second_number"] !== undefined) {
205
+ attrs["second_number"] = new BsiCode({ value: strv(data["second_number"]) ?? "" });
206
+ }
207
+ if (data["translation_lang"] !== undefined) {
208
+ const lang = strv(data["translation_lang"]) ?? "";
209
+ attrs["translation_lang"] = lang.charAt(0).toUpperCase() + lang.slice(1).toLowerCase();
210
+ }
211
+ if (data["translation_upper"] !== undefined) {
212
+ const lang = strv(data["translation_upper"]) ?? "";
213
+ attrs["translation_upper"] = lang.charAt(0).toUpperCase() + lang.slice(1).toLowerCase();
214
+ }
215
+ return attrs;
216
+ }
217
+ // --- The builder ---------------------------------------------------------------------
218
+ export function buildBsiIdentifier(tree, resolveForeign, parseWire) {
219
+ return buildTree(flatten(tree), resolveForeign, parseWire);
220
+ }
221
+ function buildTree(data, resolveForeign, parseWire) {
222
+ const original = { ...data };
223
+ if (data["standalone_amendment"] !== undefined || data["parenthesized_amd"] !== undefined) {
224
+ return buildStandaloneAmendment(data);
225
+ }
226
+ if (data["committee_document"] !== undefined) {
227
+ return buildCommitteeDocument(flatten(data["committee_document"]));
228
+ }
229
+ if (data["index_identifier"] !== undefined) {
230
+ return buildIndex(flatten(data["index_identifier"]));
231
+ }
232
+ if (data["supplementary_index_identifier"] !== undefined) {
233
+ return buildSupplementaryIndex(flatten(data["supplementary_index_identifier"]));
234
+ }
235
+ if (data["explanatory_supplement_identifier"] !== undefined) {
236
+ return buildExplanatorySupplement(flatten(data["explanatory_supplement_identifier"]));
237
+ }
238
+ if (data["method_identifier"] !== undefined) {
239
+ return buildMethod(flatten(data["method_identifier"]));
240
+ }
241
+ if (data["test_method_identifier"] !== undefined) {
242
+ return buildTestMethod(flatten(data["test_method_identifier"]));
243
+ }
244
+ if (data["section_identifier"] !== undefined) {
245
+ return buildSection(flatten(data["section_identifier"]));
246
+ }
247
+ if (data["detailed_specification"] !== undefined) {
248
+ return buildDetailedSpecification(flatten(data["detailed_specification"]));
249
+ }
250
+ if (data["disc_identifier"] !== undefined) {
251
+ return buildDisc(flatten(data["disc_identifier"]));
252
+ }
253
+ if (data["aerospace_identifier"] !== undefined) {
254
+ return buildAerospaceIdentifier(flatten(data["aerospace_identifier"]));
255
+ }
256
+ if (data["supplement_document"] !== undefined) {
257
+ return buildSupplementDocument(flatten(data["supplement_document"]), resolveForeign, parseWire);
258
+ }
259
+ if (data["addendum_document"] !== undefined) {
260
+ return buildAddendumDocument(flatten(data["addendum_document"]), resolveForeign, parseWire);
261
+ }
262
+ if (data["bundled_parts"] !== undefined || data["bundled_list"] !== undefined) {
263
+ return buildBundledIdentifier(data, resolveForeign);
264
+ }
265
+ if (data["set"] !== undefined) {
266
+ return buildSetData(data["set"], resolveForeign, parseWire);
267
+ }
268
+ const supplementsData = extractSupplements(data);
269
+ if (data["pdf_format"] !== undefined || data["tc_format"] !== undefined || data["book_format"] !== undefined) {
270
+ return buildValueAddedPublication(data, supplementsData, resolveForeign, parseWire);
271
+ }
272
+ if (data["na_prefix"] !== undefined) {
273
+ return buildNationalAnnex(data, supplementsData, resolveForeign, parseWire);
274
+ }
275
+ if (data["adopted_string"] !== undefined) {
276
+ const adopted = buildAdoptedIdentifier(data, original, resolveForeign);
277
+ if (adopted !== undefined)
278
+ return adopted;
279
+ }
280
+ const stageEntry = selectedStage(data);
281
+ let identifier = new (ctor(locateKlass(data)))(assignAttributes(data));
282
+ identifier["typedStage"] = stageEntry;
283
+ void identifier;
284
+ if (supplementsData.length > 0) {
285
+ identifier = wrapWithConsolidated(identifier, supplementsData);
286
+ }
287
+ if (data["expert_commentary"] !== undefined || data["expert_commentary_full"] !== undefined) {
288
+ identifier = wrapWithExpertCommentary(identifier, original);
289
+ }
290
+ return identifier;
291
+ }
292
+ // --- Specialized builders ------------------------------------------------------------
293
+ function yearDate(v) {
294
+ const s = strv(v);
295
+ if (s === undefined)
296
+ return undefined;
297
+ return new PubidDate({ year: String(Number(s)) });
298
+ }
299
+ function buildIndex(data) {
300
+ const attrs = {
301
+ number: strv(data["number"]),
302
+ };
303
+ const suffix = isObj(data["index_suffix"]) ? data["index_suffix"] : {};
304
+ let format = "space";
305
+ let issueNumber;
306
+ if (suffix["colon_sep"] !== undefined)
307
+ format = "colon";
308
+ else if (suffix["issue_number"] !== undefined)
309
+ issueNumber = strv(suffix["issue_number"]);
310
+ attrs["issue_number"] = issueNumber;
311
+ attrs["index_format"] = format;
312
+ const date = yearDate(data["year"]);
313
+ if (date !== undefined)
314
+ attrs["date"] = date;
315
+ return new (ctor(IndexClass))(attrs);
316
+ }
317
+ function buildSupplementaryIndex(data) {
318
+ const attrs = { number: strv(data["number"]) };
319
+ const date = yearDate(data["year"]);
320
+ if (date !== undefined)
321
+ attrs["date"] = date;
322
+ return new (ctor(SupplementaryIndexClass))(attrs);
323
+ }
324
+ function buildExplanatorySupplement(data) {
325
+ const attrs = { number: strv(data["number"]) };
326
+ const parts = partsToAttrs(data["parts"]);
327
+ if (parts.part !== undefined)
328
+ attrs["part"] = parts.part;
329
+ const date = yearDate(data["year"]);
330
+ if (date !== undefined)
331
+ attrs["date"] = date;
332
+ return new (ctor(ExplanatorySupplementClass))(attrs);
333
+ }
334
+ function buildMethod(data) {
335
+ const suffix = isObj(data["method_suffix"]) ? data["method_suffix"] : {};
336
+ const methodTo = strv(suffix["method_to"]);
337
+ const methodAnd = strv(suffix["method_and"]);
338
+ const attrs = {
339
+ number: strv(data["number"]),
340
+ method_code: strv(suffix["method_code"]),
341
+ method_to: methodTo,
342
+ method_and: methodAnd,
343
+ is_plural: methodTo !== undefined || methodAnd !== undefined,
344
+ };
345
+ const parts = partsToAttrs(data["parts"]);
346
+ if (parts.part !== undefined)
347
+ attrs["part"] = parts.part;
348
+ const date = yearDate(data["year"]);
349
+ if (date !== undefined)
350
+ attrs["date"] = date;
351
+ return new (ctor(MethodClass))(attrs);
352
+ }
353
+ function buildTestMethod(data) {
354
+ const suffix = isObj(data["test_method_suffix"]) ? data["test_method_suffix"] : {};
355
+ const attrs = {
356
+ number: strv(data["number"]),
357
+ test_series: strv(suffix["test_series"]),
358
+ test_id: strv(suffix["test_id"]),
359
+ };
360
+ if (data["publisher"] !== undefined)
361
+ attrs["publisher"] = pub(strv(data["publisher"]) ?? "BS");
362
+ const date = yearDate(data["year"]);
363
+ if (date !== undefined)
364
+ attrs["date"] = date;
365
+ return new (ctor(TestMethodClass))(attrs);
366
+ }
367
+ function buildSection(data) {
368
+ const suffix = isObj(data["section_suffix"]) ? data["section_suffix"] : {};
369
+ const publisherVal = strv(data["publisher"]) ?? strv(data["type"]);
370
+ const attrs = {
371
+ number: strv(data["number"]),
372
+ section_id: strv(suffix["section_id"]),
373
+ section_format: suffix["colon_sep"] !== undefined ? "colon" : "space",
374
+ };
375
+ if (publisherVal !== undefined)
376
+ attrs["publisher"] = pub(publisherVal);
377
+ const date = yearDate(data["year"]);
378
+ if (date !== undefined)
379
+ attrs["date"] = date;
380
+ return new (ctor(SectionClass))(attrs);
381
+ }
382
+ function buildDetailedSpecification(data) {
383
+ const suffix = isObj(data["detailed_spec_suffix"]) ? data["detailed_spec_suffix"] : {};
384
+ const attrs = { number: strv(data["number"]) };
385
+ const specCode = strv(suffix["spec_code"]);
386
+ if (specCode !== undefined)
387
+ attrs["spec_code"] = new BsiCode({ value: specCode });
388
+ if (data["publisher"] !== undefined)
389
+ attrs["publisher"] = pub(strv(data["publisher"]) ?? "BS");
390
+ const date = yearDate(data["year"]);
391
+ if (date !== undefined)
392
+ attrs["date"] = date;
393
+ return new (ctor(DetailedSpecificationClass))(attrs);
394
+ }
395
+ function buildDisc(data) {
396
+ const attrs = { number: strv(data["number"]) };
397
+ const parts = partsToAttrs(data["parts"]);
398
+ if (parts.part !== undefined)
399
+ attrs["part"] = parts.part;
400
+ attrs["publisher"] = pub("DISC");
401
+ const date = yearDate(data["year"]);
402
+ if (date !== undefined)
403
+ attrs["date"] = date;
404
+ return new (ctor(DiscClass))(attrs);
405
+ }
406
+ function buildAerospaceIdentifier(data) {
407
+ const prefixRaw = data["prefix"];
408
+ const prefixVal = isObj(prefixRaw) ? strv(prefixRaw["prefix"]) : strv(prefixRaw);
409
+ const attrs = {
410
+ prefix: prefixVal,
411
+ number: numv(data["number"]),
412
+ publisher: pub("BS"),
413
+ };
414
+ // The part captures land flat at the aerospace_identifier level when
415
+ // the engine flattens embedded subrule labels (data[:part], with an
416
+ // optional sibling letter_edition).
417
+ if (data["part"] !== undefined) {
418
+ const partDirect = isObj(data["part"])
419
+ ? strv(data["part"]["part"])
420
+ : strv(data["part"]);
421
+ if (partDirect !== undefined)
422
+ attrs["part"] = partDirect;
423
+ const partLetter = isObj(data["part"])
424
+ ? strv(data["part"]["letter_edition"])
425
+ : undefined;
426
+ if (partLetter === undefined && data["letter_edition"] !== undefined) {
427
+ attrs["edition"] = isObj(data["letter_edition"])
428
+ ? strv(data["letter_edition"]["letter_edition"])
429
+ : strv(data["letter_edition"]);
430
+ }
431
+ if (partLetter !== undefined)
432
+ attrs["edition"] = partLetter;
433
+ }
434
+ const letterEditionPart = isObj(data["part_with_letter_edition"])
435
+ ? data["part_with_letter_edition"]
436
+ : undefined;
437
+ if (letterEditionPart !== undefined) {
438
+ const partVal = strv(letterEditionPart["part"]);
439
+ if (partVal !== undefined)
440
+ attrs["part"] = partVal;
441
+ const letterEdition = strv(letterEditionPart["letter_edition"]);
442
+ if (letterEdition !== undefined)
443
+ attrs["edition"] = letterEdition;
444
+ }
445
+ else {
446
+ const parts = partsToAttrs(data["parts"]);
447
+ if (parts.part !== undefined)
448
+ attrs["part"] = parts.part;
449
+ if (parts.subpart !== undefined)
450
+ attrs["subpart"] = parts.subpart;
451
+ }
452
+ if (attrs["edition"] === undefined && data["letter_edition"] !== undefined) {
453
+ const editionVal = isObj(data["letter_edition"])
454
+ ? strv(data["letter_edition"]["letter_edition"])
455
+ : strv(data["letter_edition"]);
456
+ if (editionVal !== undefined)
457
+ attrs["edition"] = editionVal;
458
+ }
459
+ const date = yearDate(data["year"]);
460
+ if (date !== undefined)
461
+ attrs["date"] = date;
462
+ return new (ctor(AerospaceStandardClass))(attrs);
463
+ }
464
+ function buildStandaloneAmendment(data) {
465
+ const amdRaw = data["standalone_amendment"] ?? data["parenthesized_amd"];
466
+ const amdData = flatten(amdRaw);
467
+ return new (ctor(StandaloneAmendmentClass))({
468
+ number: strv(amdData["amendment_number"]),
469
+ corrigendum: amdData["corrigendum"] !== undefined,
470
+ parenthesized: data["parenthesized_amd"] !== undefined,
471
+ });
472
+ }
473
+ function buildCommitteeDocument(data) {
474
+ const yearVal = strv(data["year"]);
475
+ const fullYear = yearVal !== undefined ? `20${yearVal}` : undefined;
476
+ const attrs = {
477
+ number: strv(data["document_number"]),
478
+ };
479
+ if (fullYear !== undefined)
480
+ attrs["date"] = new PubidDate({ year: String(Number(fullYear)) });
481
+ return new (ctor(CommitteeDocumentClass))(attrs);
482
+ }
483
+ function buildValueAddedPublication(data, _supplements, resolveForeign, parseWire) {
484
+ const format = data["pdf_format"] !== undefined
485
+ ? "PDF"
486
+ : data["tc_format"] !== undefined
487
+ ? "TC"
488
+ : data["book_format"] !== undefined
489
+ ? "BOOK"
490
+ : undefined;
491
+ const baseData = { ...data };
492
+ delete baseData["pdf_format"];
493
+ delete baseData["tc_format"];
494
+ delete baseData["book_format"];
495
+ const baseId = buildTree(baseData, resolveForeign, parseWire);
496
+ return new (ctor(ValueAddedPublicationClass))({
497
+ base: baseId,
498
+ format,
499
+ });
500
+ }
501
+ function buildNationalAnnex(data, _supplements, resolveForeign, parseWire) {
502
+ const baseData = { ...data };
503
+ delete baseData["na_prefix"];
504
+ delete baseData["na_supplements"];
505
+ const baseId = buildTree(baseData, resolveForeign, parseWire);
506
+ const naPrefix = isObj(data["na_prefix"]) ? data["na_prefix"] : undefined;
507
+ const naSuppRaw = naPrefix !== undefined && naPrefix["na_supplements"] !== undefined
508
+ ? naPrefix["na_supplements"]
509
+ : data["na_supplements"];
510
+ const naSuppData = naSuppRaw !== undefined
511
+ ? extractSupplementsFromArray(Array.isArray(naSuppRaw) ? naSuppRaw.flat(Infinity) : [naSuppRaw])
512
+ : [];
513
+ const naSupps = naSuppData.map((supp) => {
514
+ const yearVal = expandYear(supp.year);
515
+ if (supp.type === "amendment") {
516
+ return new Amendment({
517
+ number: supp.number,
518
+ year: yearVal,
519
+ separator: supp.separator,
520
+ });
521
+ }
522
+ return new Corrigendum({
523
+ number: supp.number,
524
+ year: yearVal,
525
+ separator: supp.separator,
526
+ });
527
+ });
528
+ return new (ctor(NationalAnnexClass))({
529
+ na_supplements: naSupps,
530
+ base: baseId,
531
+ });
532
+ }
533
+ function iterationOf(v) {
534
+ if (v === undefined)
535
+ return undefined;
536
+ const flat = (Array.isArray(v) ? v.flat(Infinity) : [v]);
537
+ for (const item of flat) {
538
+ if (isObj(item)) {
539
+ const raw = item["iteration"];
540
+ const inner = Array.isArray(raw)
541
+ ? iterationOf(raw)
542
+ : strv(raw);
543
+ if (inner !== undefined && inner !== "")
544
+ return inner;
545
+ }
546
+ }
547
+ return undefined;
548
+ }
549
+ function buildSupplementDocument(data, resolveForeign, parseWire) {
550
+ const publisherVal = strv(data["publisher"]);
551
+ // The grammar nests the parts under a "parts" key inside the parts
552
+ // subtree; unwrap before extracting part/subpart.
553
+ const suppPartsRaw = data["parts"];
554
+ const suppPartsVal = isObj(suppPartsRaw) && suppPartsRaw["parts"] !== undefined
555
+ ? suppPartsRaw["parts"]
556
+ : suppPartsRaw;
557
+ const baseData = {
558
+ ...(publisherVal !== undefined ? { publisher: publisherVal } : {}),
559
+ number: numv(data["number"]),
560
+ ...(iterationOf(data["iteration"]) !== undefined ? { iteration: iterationOf(data["iteration"]) } : {}),
561
+ ...(suppPartsVal !== undefined ? { parts: suppPartsVal } : {}),
562
+ ...(data["flex_prefix"] !== undefined ? { flex_prefix: strv(data["flex_prefix"]) } : {}),
563
+ };
564
+ const reverseFormat = data["supplement_number"] !== undefined
565
+ && data["supplement_year"] !== undefined
566
+ && data["publisher"] !== undefined
567
+ && data["number"] !== undefined
568
+ && data["base_year"] !== undefined;
569
+ if (reverseFormat) {
570
+ baseData["year"] = data["base_year"];
571
+ }
572
+ else if (data["year"] !== undefined) {
573
+ baseData["year"] = data["year"];
574
+ }
575
+ const baseId = buildTree(baseData, resolveForeign, parseWire);
576
+ const suppType = strv(data["supp_no_prefix"]) === "No."
577
+ ? "No."
578
+ : strv(data["supp_no_prefix"]) !== undefined
579
+ ? strv(data["supp_no_prefix"])
580
+ : "";
581
+ return new (ctor(SupplementDocumentClass))({
582
+ base: baseId,
583
+ supplement_number: strv(data["supplement_number"]),
584
+ supplement_year: data["supplement_year"] !== undefined ? Number(strv(data["supplement_year"])) : undefined,
585
+ supplement_type: suppType,
586
+ reverse_format: reverseFormat,
587
+ separator: strv(data["supp_sep"]) ?? ":",
588
+ });
589
+ }
590
+ function buildAddendumDocument(data, resolveForeign, parseWire) {
591
+ const publisherVal = strv(data["publisher"]);
592
+ // The grammar nests the parts under a "parts" key inside the
593
+ // "parts" subtree; unwrap before extracting part/subpart.
594
+ const partsRaw = data["parts"];
595
+ const partsVal = isObj(partsRaw) && partsRaw["parts"] !== undefined
596
+ ? partsRaw["parts"]
597
+ : partsRaw;
598
+ const baseData = {
599
+ ...(publisherVal !== undefined ? { publisher: publisherVal } : {}),
600
+ number: numv(data["number"]),
601
+ ...(iterationOf(data["iteration"]) !== undefined ? { iteration: iterationOf(data["iteration"]) } : {}),
602
+ ...(partsVal !== undefined ? { parts: partsVal } : {}),
603
+ ...(data["flex_prefix"] !== undefined ? { flex_prefix: strv(data["flex_prefix"]) } : {}),
604
+ };
605
+ if (data["base_year"] !== undefined)
606
+ baseData["year"] = data["base_year"];
607
+ const baseId = buildTree(baseData, resolveForeign, parseWire);
608
+ const addType = strv(data["add_no_prefix"]) === "No."
609
+ ? "No."
610
+ : strv(data["add_no_prefix"]) !== undefined
611
+ ? strv(data["add_no_prefix"])
612
+ : "";
613
+ // strv() trims, so a captured space separator must be read raw.
614
+ const sepRaw = data["add_sep"];
615
+ const separator = sepRaw === " " ? " " : strv(sepRaw) ?? ":";
616
+ return new (ctor(AddendumDocumentClass))({
617
+ base: baseId,
618
+ addendum_number: strv(data["addendum_number"]),
619
+ addendum_year: data["addendum_year"] !== undefined ? Number(strv(data["addendum_year"])) : undefined,
620
+ addendum_type: addType,
621
+ separator,
622
+ });
623
+ }
624
+ function buildBundleItem(itemData, defaultPublisher, defaultPrefix, resolveForeign) {
625
+ if (isObj(itemData)) {
626
+ const d = itemData;
627
+ const hasExplicitPublisher = d["publisher"] !== undefined;
628
+ const hasExplicitPrefix = d["prefix"] !== undefined;
629
+ const publisherVal = strv(d["publisher"]) ?? defaultPublisher;
630
+ const prefixVal = strv(d["prefix"]) ?? defaultPrefix;
631
+ const id = new BsiIdentifier({
632
+ ...(publisherVal !== undefined ? { publisher: pub(publisherVal) } : {}),
633
+ ...(prefixVal !== undefined && prefixVal !== "" ? { prefix: prefixVal } : {}),
634
+ ...(strv(d["number"]) !== undefined ? { number: strv(d["number"]) } : {}),
635
+ });
636
+ const self = id;
637
+ self["explicit_prefix"] = hasExplicitPublisher || hasExplicitPrefix;
638
+ self["explicit_publisher"] = hasExplicitPublisher;
639
+ const partsVal = d["parts"];
640
+ if (isObj(partsVal) && Array.isArray(partsVal["parts"])) {
641
+ const partsArray = partsVal["parts"];
642
+ const partStr = strv(partsArray[0]?.["part"]);
643
+ if (partStr !== undefined)
644
+ self["part"] = partStr;
645
+ }
646
+ else if (d["part"] !== undefined) {
647
+ self["part"] = strv(d["part"]);
648
+ self["space_separated_part"] = true;
649
+ }
650
+ return id;
651
+ }
652
+ // Simple string (alphanumeric like "N001")
653
+ return new BsiIdentifier({ number: strv(itemData) });
654
+ }
655
+ function buildBundledIdentifier(data, resolveForeign) {
656
+ if (data["bundled_parts"] !== undefined) {
657
+ const partsData = flatten(data["bundled_parts"]);
658
+ const baseNumber = strv(partsData["number"]) ?? "";
659
+ const bundleType = strv(partsData["bundle_type"]) ?? "";
660
+ const part1 = strv(partsData["part1"]) ?? "";
661
+ const part2 = strv(partsData["part2"]) ?? "";
662
+ const yearVal = strv(partsData["year"]);
663
+ const baseId = new BsiIdentifier({ publisher: pub("BS"), number: baseNumber });
664
+ const id1 = new BsiIdentifier({ publisher: pub("BS"), number: baseNumber, part: part1 });
665
+ const id2 = new BsiIdentifier({ publisher: pub("BS"), number: baseNumber, part: part2 });
666
+ return new (ctor(BundledIdentifierClass))({
667
+ identifiers: [baseId, id1, id2],
668
+ bundle_type: bundleType,
669
+ common_year: yearVal !== undefined ? new PubidDate({ year: String(Number(yearVal)) }) : undefined,
670
+ });
671
+ }
672
+ const listArray = (Array.isArray(data["bundled_list"]) ? data["bundled_list"] : [data["bundled_list"]]);
673
+ const firstElem = flatten(listArray[0]);
674
+ const publisherVal = strv(firstElem["publisher"]) ?? "BS";
675
+ const prefixVal = strv(firstElem["prefix"]);
676
+ const items = [];
677
+ const separators = [];
678
+ if (firstElem["bundle_item"] !== undefined) {
679
+ items.push(buildBundleItem(firstElem["bundle_item"], publisherVal, prefixVal, resolveForeign));
680
+ }
681
+ for (const rawElem of listArray.slice(1)) {
682
+ const elem = flatten(rawElem);
683
+ if (elem["year"] !== undefined)
684
+ continue;
685
+ if (elem["bundle_item"] !== undefined) {
686
+ let sep = " and ";
687
+ if (elem["sep_and"] !== undefined)
688
+ sep = " and ";
689
+ else if (elem["sep_to"] !== undefined) {
690
+ const toCase = strv(elem["sep_to"]?.["to_case"]);
691
+ sep = toCase === "TO" ? " TO " : " to ";
692
+ }
693
+ else if (elem["sep_ampersand"] !== undefined)
694
+ sep = " & ";
695
+ else if (elem["sep_semicolon"] !== undefined)
696
+ sep = "; ";
697
+ else if (elem["sep_comma"] !== undefined)
698
+ sep = ",";
699
+ separators.push(sep);
700
+ items.push(buildBundleItem(elem["bundle_item"], publisherVal, prefixVal, resolveForeign));
701
+ }
702
+ }
703
+ const yearElem = listArray.map((e) => flatten(e)).find((e) => e["year"] !== undefined);
704
+ const yearVal = yearElem !== undefined ? strv(yearElem["year"]) : undefined;
705
+ return new (ctor(BundledIdentifierClass))({
706
+ identifiers: items,
707
+ separators,
708
+ common_year: yearVal !== undefined ? new PubidDate({ year: String(Number(yearVal)) }) : undefined,
709
+ });
710
+ }
711
+ function buildSetData(setRaw, resolveForeign, parseWire) {
712
+ // The artifact's set wire nests twice (set.set[items]): the declared
713
+ // binding wraps the rule's own as("set") array.
714
+ const setList = isObj(setRaw) && Array.isArray(setRaw["set"])
715
+ ? setRaw["set"]
716
+ : setRaw;
717
+ const itemsArray = Array.isArray(setList) ? setList.flat(Infinity) : [setList];
718
+ const identifiers = [];
719
+ for (const item of itemsArray) {
720
+ const itemData = isObj(item) && item["set_item"] !== undefined
721
+ ? (flatten(item["set_item"]))
722
+ : (isObj(item) ? item : {});
723
+ let idStr = "";
724
+ if (itemData["publisher"] !== undefined)
725
+ idStr += `${strv(itemData["publisher"])} `;
726
+ if (itemData["adopted_org"] !== undefined)
727
+ idStr += `${strv(itemData["adopted_org"])} `;
728
+ const numberVal = isObj(itemData["number"])
729
+ ? strv(itemData["number"]["number"])
730
+ : strv(itemData["number"]);
731
+ if (numberVal !== undefined)
732
+ idStr += numberVal;
733
+ if (isObj(itemData["parts"])) {
734
+ const partsInner = itemData["parts"]["parts"];
735
+ if (Array.isArray(partsInner) && partsInner.length > 0) {
736
+ const partVal = strv(partsInner[0]["part"]);
737
+ if (partVal !== undefined)
738
+ idStr += `-${partVal}`;
739
+ }
740
+ }
741
+ if (itemData["year"] !== undefined)
742
+ idStr += `:${strv(itemData["year"])}`;
743
+ if (idStr.trim() === "")
744
+ continue;
745
+ const parsed = parseBsi(idStr, resolveForeign, parseWire);
746
+ if (parsed !== undefined)
747
+ identifiers.push(parsed);
748
+ }
749
+ return new (ctor(SetClass))({
750
+ identifiers,
751
+ separators: Array.from({ length: Math.max(0, identifiers.length - 1) }, () => " + "),
752
+ });
753
+ }
754
+ // --- Adopted identifiers ---------------------------------------------------------------
755
+ function buildAdoptedIdentifier(dataIn, originalIn, resolveForeign) {
756
+ const data = dataIn;
757
+ const original = originalIn;
758
+ const adoptedRaw = data["adopted_string"];
759
+ let adoptedStr = isObj(adoptedRaw)
760
+ ? strv(adoptedRaw["adopted_string"]) ?? strv(adoptedRaw["adopted_string_no_expert"])
761
+ : strv(adoptedRaw);
762
+ if (adoptedStr === undefined || adoptedStr === "")
763
+ return undefined;
764
+ adoptedStr = adoptedStr.trim();
765
+ const isBare = data["publisher"] === undefined && data["type"] === undefined
766
+ && data["na_prefix"] === undefined && data["flex_type"] === undefined && data["stage"] === undefined;
767
+ // Extract Expert Commentary suffixes (case-insensitive).
768
+ const setExComm = (topic) => {
769
+ data["expert_commentary_full"] = topic === undefined ? "Expert Commentary" : undefined;
770
+ if (topic === undefined && data["expert_commentary"] === undefined)
771
+ data["expert_commentary"] = true;
772
+ if (topic !== undefined) {
773
+ data["expert_commentary_topic"] = topic;
774
+ if (data["expert_commentary"] === undefined)
775
+ data["expert_commentary"] = true;
776
+ }
777
+ if (topic === undefined) {
778
+ original["expert_commentary_full"] = "Expert Commentary";
779
+ if (original["expert_commentary"] === undefined)
780
+ original["expert_commentary"] = true;
781
+ }
782
+ else {
783
+ original["expert_commentary_topic"] = topic;
784
+ if (original["expert_commentary"] === undefined)
785
+ original["expert_commentary"] = true;
786
+ }
787
+ };
788
+ if (/expert commentary$/i.test(adoptedStr)) {
789
+ adoptedStr = adoptedStr.replace(/expert commentary$/i, "");
790
+ setExComm();
791
+ }
792
+ else if (/excomm \($/i.test(adoptedStr)) {
793
+ adoptedStr = adoptedStr.replace(/excomm \(.*\)$/i, "");
794
+ setExComm();
795
+ }
796
+ else if (/excomm \(/i.test(adoptedStr)) {
797
+ const topicMatch = adoptedStr.match(/excomm\s*\(([^)]+)\)/i);
798
+ adoptedStr = adoptedStr.replace(/excomm\s*\(.*\)$/i, "");
799
+ setExComm(topicMatch?.[1]);
800
+ }
801
+ else if (/excomm\s*$/i.test(adoptedStr)) {
802
+ adoptedStr = adoptedStr.replace(/excomm\s*$/i, "");
803
+ if (data["expert_commentary"] === undefined)
804
+ data["expert_commentary"] = true;
805
+ if (original["expert_commentary"] === undefined)
806
+ original["expert_commentary"] = true;
807
+ }
808
+ // Extract translation suffixes.
809
+ const parenMatch = adoptedStr.match(/\s*\(([A-Za-z]+)(?:\s+(Translation|version))?\)\s*$/);
810
+ if (parenMatch !== null) {
811
+ data["translation_lang"] = parenMatch[1];
812
+ if (parenMatch[2] !== undefined)
813
+ data["translation_suffix_type"] = parenMatch[2];
814
+ adoptedStr = adoptedStr.replace(/\s*\([A-Za-z]+(?:\s+(?:Translation|version))?\)\s*$/, "");
815
+ }
816
+ else {
817
+ const upperMatch = adoptedStr.match(/\s+(SPANISH|FRENCH|GERMAN|ITALIAN)\s+TRANSLATION\s*$/);
818
+ if (upperMatch !== null) {
819
+ data["translation_upper"] = upperMatch[1];
820
+ data["translation_suffix_type"] = "Translation";
821
+ adoptedStr = adoptedStr.replace(/\s+(SPANISH|FRENCH|GERMAN|ITALIAN)\s+TRANSLATION\s*$/, "");
822
+ }
823
+ }
824
+ // Extract edition (only when NOT bare).
825
+ const editionMatch = isBare ? null : adoptedStr.match(/\s+ED(\d+)\s*$/);
826
+ const extractedEdition = editionMatch !== null ? editionMatch[1] : undefined;
827
+ if (editionMatch !== null) {
828
+ adoptedStr = adoptedStr.replace(/\s+ED\d+\s*$/, "");
829
+ }
830
+ const finalEdition = strv(data["edition"]) ?? extractedEdition;
831
+ // Extract reaffirmation "(R2004)".
832
+ const reaffirmationMatch = adoptedStr.match(/\s+\(R(\d{4})\)\s*$/);
833
+ if (reaffirmationMatch !== null) {
834
+ data["reaffirmation_year"] = reaffirmationMatch[1];
835
+ adoptedStr = adoptedStr.replace(/\s+\(R\d{4}\)\s*$/, "");
836
+ }
837
+ // Extract BSI-style supplements from the adopted string.
838
+ const extractedSupplements = [];
839
+ adoptedStr = adoptedStr.replace(/([+])(A(\d+)|AMD(\d+)|C(\d+)|COR(\d+))(?::(\d{4}))?(?:\s|$)/g, (match, sep, typeCode, _a, _amd, _c, _cor, year) => {
840
+ const suppType = typeCode.startsWith("A") ? "amendment" : "corrigendum";
841
+ const suppNumber = typeCode.startsWith("AMD")
842
+ ? typeCode.slice(3)
843
+ : typeCode.replace(/^[AC]/, "");
844
+ extractedSupplements.push({
845
+ type: suppType,
846
+ number: suppNumber,
847
+ year: year !== undefined ? year : undefined,
848
+ separator: sep,
849
+ amd_suffix_form: false,
850
+ });
851
+ return "";
852
+ }).trim();
853
+ adoptedStr = adoptedStr.replace(/\s+AMD\s*(AA|\d+)(?:\s|$)/gi, (match) => {
854
+ const amdNumber = match.trim().replace(/^AMD\s*/i, "");
855
+ extractedSupplements.push({
856
+ type: "amendment",
857
+ number: amdNumber,
858
+ year: undefined,
859
+ separator: undefined,
860
+ amd_suffix_form: true,
861
+ });
862
+ return "";
863
+ }).trim();
864
+ const bsiPrefix = strv(data["type"]) ?? strv(data["publisher"]) ?? "BS";
865
+ let adoptedId;
866
+ if (/^EN\s+(ISO\/IEC|IEC|ISO)/.test(adoptedStr)) {
867
+ const isoIecStr = adoptedStr.replace(/^EN\s+/, "");
868
+ let parsed;
869
+ if (isoIecStr.startsWith("ISO/IEC") || isoIecStr.includes("ISO/IEC")) {
870
+ parsed = tryForeign("iso", isoIecStr, resolveForeign);
871
+ }
872
+ else if (isoIecStr.startsWith("ISO")) {
873
+ parsed = tryForeign("iso", isoIecStr, resolveForeign);
874
+ }
875
+ else if (isoIecStr.startsWith("IEC")) {
876
+ parsed = tryForeign("iec", isoIecStr, resolveForeign);
877
+ }
878
+ // Wrap the ISO/IEC identifier in a CEN EN adoption.
879
+ if (parsed !== undefined) {
880
+ adoptedId = new CenAdoptedEuropeanNormClass({
881
+ publisher: "EN",
882
+ adopted: parsed,
883
+ });
884
+ }
885
+ else {
886
+ adoptedId = tryForeign("cen_cenelec", adoptedStr, resolveForeign);
887
+ }
888
+ }
889
+ else if (adoptedStr.startsWith("ISO/IEC") || adoptedStr.includes("ISO/IEC")) {
890
+ adoptedId = tryForeign("iso", adoptedStr, resolveForeign);
891
+ }
892
+ else if (adoptedStr.startsWith("ISO")) {
893
+ adoptedId = tryForeign("iso", adoptedStr, resolveForeign);
894
+ }
895
+ else if (adoptedStr.startsWith("IEC")) {
896
+ adoptedId = tryForeign("iec", adoptedStr, resolveForeign);
897
+ }
898
+ else if (/^(EN|CEN|CLC|CR|ES|ENV|HD|CWA)/.test(adoptedStr)) {
899
+ adoptedId = tryForeign("cen_cenelec", adoptedStr, resolveForeign);
900
+ }
901
+ else if (adoptedStr.startsWith("CISPR")) {
902
+ adoptedId = tryForeign("iec", adoptedStr, resolveForeign);
903
+ }
904
+ if (isBare && adoptedId !== undefined)
905
+ return adoptedId;
906
+ if (adoptedId !== undefined) {
907
+ // AdoptedEuropeanNorm for CEN documents, else AdoptedInternational.
908
+ const adoptedWire = adoptedId.toHash();
909
+ const adoptedTypeStr = String(adoptedWire["_type"] ?? "");
910
+ const wrapperCtor = adoptedTypeStr.startsWith("pubid:cencenelec")
911
+ ? AdoptedEuropeanNormClass
912
+ : AdoptedInternationalStandardClass;
913
+ let identifier = new (ctor(wrapperCtor))({
914
+ publisher: pub(bsiPrefix),
915
+ base: adoptedId,
916
+ ...(finalEdition !== undefined ? { edition: finalEdition } : {}),
917
+ ...(strv(data["translation_lang"]) !== undefined ? { translation_lang: strv(data["translation_lang"]) } : {}),
918
+ ...(strv(data["translation_upper"]) !== undefined ? { translation_upper: strv(data["translation_upper"]) } : {}),
919
+ ...(strv(data["translation_suffix_type"]) !== undefined ? { translation_suffix_type: strv(data["translation_suffix_type"]) } : {}),
920
+ ...(strv(data["reaffirmation_year"]) !== undefined ? { reaffirmation_year: strv(data["reaffirmation_year"]) } : {}),
921
+ });
922
+ if (extractedSupplements.length > 0) {
923
+ identifier = wrapWithConsolidated(identifier, extractedSupplements);
924
+ }
925
+ if (data["expert_commentary"] !== undefined || data["expert_commentary_full"] !== undefined) {
926
+ identifier = wrapWithExpertCommentary(identifier, original);
927
+ }
928
+ return identifier;
929
+ }
930
+ return undefined;
931
+ }
932
+ // --- The parse entry -------------------------------------------------------------------
933
+ function parseBsi(input, resolveForeign, parseWire) {
934
+ const cleaned = preprocessBsi(input);
935
+ try {
936
+ const tree = parseWire(cleaned);
937
+ return buildBsiIdentifier(tree, resolveForeign, parseWire);
938
+ }
939
+ catch {
940
+ return undefined;
941
+ }
942
+ }
943
+ /** The bound → wire lane is injected so the node entry (the generated
944
+ * substrate over the wasm artifact runtime) and the worker entry (the
945
+ * pure-TS worker engine) share this delta byte for byte. */
946
+ export function makeBsiGrammarImplementation(parseWire, resolveForeign) {
947
+ return {
948
+ parse(input) {
949
+ // Delegate to IEC for bare IEC identifiers with VAP suffixes or
950
+ // consolidated supplements (single_identifier.rb .parse).
951
+ if (/\bIEC\b/.test(input)
952
+ && (/\s+(CSV|CMV|RLV|SER|EXV|PAC|PRV)\b/.test(input)
953
+ || /\+AMD\d+:/.test(input)
954
+ || /\+COR\d+:/.test(input))) {
955
+ const iec = resolveForeign("iec");
956
+ if (iec === undefined)
957
+ throw new Error("iec implementation unavailable");
958
+ return iec.parse(input);
959
+ }
960
+ const parsed = parseBsi(input, resolveForeign, parseWire);
961
+ if (parsed === undefined) {
962
+ throw new Error("Failed to parse BSI identifier");
963
+ }
964
+ return parsed;
965
+ },
966
+ };
967
+ }