@archivist-gg/dnd5e 0.3.19 → 0.3.24

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 (440) hide show
  1. package/LICENSE +48 -21
  2. package/README.md +26 -48
  3. package/dist/armor/armor.codec.d.ts +0 -7
  4. package/dist/armor/armor.codec.js +1 -9
  5. package/dist/armor/armor.parser.js +1 -8
  6. package/dist/armor/armor.schema.js +1 -7
  7. package/dist/armor/armor.types.d.ts +0 -3
  8. package/dist/background/background.codec.d.ts +0 -6
  9. package/dist/background/background.codec.js +1 -12
  10. package/dist/background/background.parser.js +1 -11
  11. package/dist/background/background.schema.js +1 -12
  12. package/dist/background/background.types.d.ts +0 -5
  13. package/dist/chunk-2EOGK6R6.js +1 -0
  14. package/dist/chunk-2HRRH3WL.js +1 -0
  15. package/dist/chunk-2LCGKNVM.js +1 -0
  16. package/dist/chunk-2NUDWOFG.js +1 -0
  17. package/dist/chunk-334WLI7V.js +1 -0
  18. package/dist/chunk-3LWOVRLA.js +1 -0
  19. package/dist/chunk-3QQOATV3.js +1 -0
  20. package/dist/chunk-4E2GIWJE.js +1 -0
  21. package/dist/chunk-4GN3GYMP.js +1 -0
  22. package/dist/chunk-4IAMSRHD.js +1 -0
  23. package/dist/chunk-4JEF3CET.js +1 -0
  24. package/dist/chunk-4KVVAENP.js +1 -0
  25. package/dist/chunk-56JK6VCL.js +1 -0
  26. package/dist/chunk-5FEXHY4U.js +1 -0
  27. package/dist/chunk-63YJPWTM.js +1 -0
  28. package/dist/chunk-6ASJ3MVB.js +1 -0
  29. package/dist/chunk-6IC53O3Q.js +1 -0
  30. package/dist/chunk-6LCNV26D.js +1 -0
  31. package/dist/chunk-6W253VHH.js +1 -0
  32. package/dist/chunk-7AKJBRBD.js +1 -0
  33. package/dist/chunk-7EL3GWWJ.js +1 -0
  34. package/dist/chunk-7FPQJDFD.js +1 -0
  35. package/dist/chunk-7J5BNH2D.js +1 -0
  36. package/dist/chunk-7LPKI27J.js +1 -0
  37. package/dist/chunk-7UPYRKMF.js +1 -0
  38. package/dist/chunk-A7H6LX47.js +1 -0
  39. package/dist/chunk-AINRPPLH.js +1 -0
  40. package/dist/chunk-BC52J4LA.js +1 -0
  41. package/dist/chunk-BCXGB4HP.js +1 -0
  42. package/dist/chunk-BGX36NPE.js +1 -0
  43. package/dist/chunk-BPKG6RZ7.js +1 -0
  44. package/dist/chunk-BREHZNTL.js +1 -0
  45. package/dist/chunk-BZ6BGGZS.js +1 -0
  46. package/dist/chunk-CAPYNIGK.js +1 -0
  47. package/dist/chunk-CCFIINBA.js +1 -0
  48. package/dist/chunk-CMIEZQL4.js +1 -0
  49. package/dist/chunk-DVUXUIPV.js +1 -0
  50. package/dist/chunk-DY6FVAGA.js +1 -0
  51. package/dist/chunk-DZITM5AG.js +1 -0
  52. package/dist/chunk-DZKSXSJF.js +1 -0
  53. package/dist/chunk-EAARMPCW.js +1 -0
  54. package/dist/chunk-EVT7MGAC.js +1 -0
  55. package/dist/chunk-FOLHTMSC.js +1 -0
  56. package/dist/chunk-GCYUCIDN.js +1 -0
  57. package/dist/chunk-GIOV6JW7.js +1 -0
  58. package/dist/chunk-HCK6IUB3.js +1 -0
  59. package/dist/chunk-HR5MKCP2.js +1 -0
  60. package/dist/chunk-I26FHSI6.js +1 -0
  61. package/dist/chunk-I4O2FIDT.js +1 -0
  62. package/dist/chunk-IGVRLGLM.js +1 -0
  63. package/dist/chunk-IHPLT2ZT.js +1 -0
  64. package/dist/chunk-IOCJIWCV.js +1 -0
  65. package/dist/chunk-JXDX2DKF.js +1 -0
  66. package/dist/chunk-KBFSJ5WE.js +1 -0
  67. package/dist/chunk-KM75CC6Q.js +1 -0
  68. package/dist/chunk-KZDDFG4O.js +1 -0
  69. package/dist/chunk-LJNT3PJP.js +1 -0
  70. package/dist/chunk-LR6UMA5V.js +1 -0
  71. package/dist/chunk-M6RPOLKS.js +1 -0
  72. package/dist/chunk-MC6PLWRZ.js +1 -0
  73. package/dist/chunk-MGGKZGLG.js +1 -0
  74. package/dist/chunk-N3RYJ7RE.js +1 -0
  75. package/dist/chunk-NEMX7QGG.js +1 -0
  76. package/dist/chunk-NI364WV7.js +1 -0
  77. package/dist/chunk-O2QZ73GA.js +1 -0
  78. package/dist/chunk-O776WL7O.js +1 -0
  79. package/dist/chunk-OTFNINUY.js +1 -0
  80. package/dist/chunk-PQAVMK3T.js +1 -0
  81. package/dist/chunk-PZ3ZZ5H5.js +1 -0
  82. package/dist/chunk-PZ4L2EEG.js +1 -0
  83. package/dist/chunk-PZUPZBTN.js +1 -0
  84. package/dist/chunk-QBA757AU.js +1 -0
  85. package/dist/chunk-QFIGPOFW.js +1 -0
  86. package/dist/chunk-QMEKQTUT.js +1 -0
  87. package/dist/chunk-QVWT67WA.js +1 -0
  88. package/dist/chunk-RDXQAZBA.js +1 -0
  89. package/dist/chunk-RE5Z5RNK.js +1 -0
  90. package/dist/chunk-RL4VY2AL.js +1 -0
  91. package/dist/chunk-RQGTBHJW.js +1 -0
  92. package/dist/chunk-RQZCGXUZ.js +1 -0
  93. package/dist/chunk-S5UCI27C.js +1 -0
  94. package/dist/chunk-SEOASDO4.js +1 -0
  95. package/dist/chunk-SU4MEZ5P.js +1 -0
  96. package/dist/chunk-T55DELVL.js +1 -0
  97. package/dist/chunk-TKIEPC6F.js +1 -0
  98. package/dist/chunk-TLXFGGWH.js +1 -0
  99. package/dist/chunk-UBUKCRZ3.js +1 -0
  100. package/dist/chunk-V6NQ547U.js +1 -0
  101. package/dist/chunk-VA3ZWV7C.js +1 -0
  102. package/dist/chunk-VIP3FH2O.js +1 -0
  103. package/dist/chunk-VTQ4RWEG.js +1 -0
  104. package/dist/chunk-WUHTSLG4.js +1 -0
  105. package/dist/chunk-X22SISGM.js +1 -0
  106. package/dist/chunk-XKJXT2PN.js +1 -0
  107. package/dist/chunk-XQMKH4R4.js +1 -0
  108. package/dist/chunk-YGH7S5ZF.js +1 -0
  109. package/dist/chunk-ZE46ADXS.js +1 -0
  110. package/dist/chunk-ZI3FEUX3.js +1 -0
  111. package/dist/class/class.codec.d.ts +0 -7
  112. package/dist/class/class.codec.js +1 -18
  113. package/dist/class/class.parser.js +1 -17
  114. package/dist/class/class.schema.d.ts +2 -1
  115. package/dist/class/class.schema.js +1 -15
  116. package/dist/class/class.slug.d.ts +0 -11
  117. package/dist/class/class.slug.js +1 -8
  118. package/dist/class/class.standard-array.d.ts +0 -7
  119. package/dist/class/class.standard-array.js +1 -20
  120. package/dist/class/class.types.d.ts +0 -20
  121. package/dist/condition/condition.codec.d.ts +0 -6
  122. package/dist/condition/condition.parser.d.ts +0 -10
  123. package/dist/condition/condition.parser.js +1 -7
  124. package/dist/condition/condition.schema.d.ts +0 -16
  125. package/dist/condition/condition.types.d.ts +0 -3
  126. package/dist/data-srd/index.generated.js +1 -146
  127. package/dist/dnd/amount-text.d.ts +3 -30
  128. package/dist/dnd/amount-text.js +1 -15
  129. package/dist/dnd/constants.d.ts +0 -18
  130. package/dist/dnd/constants.js +1 -42
  131. package/dist/dnd/formula-tags.d.ts +0 -2
  132. package/dist/dnd/formula-tags.js +1 -119
  133. package/dist/dnd/math.d.ts +0 -26
  134. package/dist/dnd/math.js +1 -45
  135. package/dist/dnd/prose-tags.d.ts +1 -15
  136. package/dist/dnd/prose-tags.js +1 -18
  137. package/dist/dnd/resource-die.d.ts +0 -4
  138. package/dist/dnd/resource-die.js +1 -17
  139. package/dist/dnd/resource-formula.d.ts +0 -43
  140. package/dist/dnd/resource-formula.js +1 -14
  141. package/dist/dnd/resource-words.d.ts +0 -2
  142. package/dist/dnd/resource-words.js +1 -30
  143. package/dist/dnd/srd-tag-converter.d.ts +0 -21
  144. package/dist/dnd/srd-tag-converter.js +1 -12
  145. package/dist/dnd/tag-grammar.js +1 -12
  146. package/dist/dnd/warn-once.js +1 -8
  147. package/dist/encounter/encounter.ai-schema.js +1 -8
  148. package/dist/entities/base-item-resolver.d.ts +0 -26
  149. package/dist/entities/base-item-resolver.js +1 -11
  150. package/dist/entities/registry-revision.d.ts +0 -15
  151. package/dist/entities/registry-revision.js +1 -10
  152. package/dist/entities/slug.d.ts +1 -31
  153. package/dist/entities/slug.js +1 -12
  154. package/dist/entities/wikilink-display.d.ts +0 -2
  155. package/dist/entities/wikilink-display.js +1 -10
  156. package/dist/feat/feat.category-codes.d.ts +1 -26
  157. package/dist/feat/feat.category-codes.js +1 -14
  158. package/dist/feat/feat.codec.d.ts +0 -6
  159. package/dist/feat/feat.codec.js +1 -12
  160. package/dist/feat/feat.parser.js +1 -11
  161. package/dist/feat/feat.schema.d.ts +22 -1
  162. package/dist/feat/feat.schema.js +1 -10
  163. package/dist/feat/feat.types.d.ts +0 -6
  164. package/dist/index.js +45 -141495
  165. package/dist/inline-tag-parser.js +1 -6
  166. package/dist/item/item.actions-map.d.ts +4 -63
  167. package/dist/item/item.actions-map.js +1 -10
  168. package/dist/item/item.ai-schema.js +1 -6
  169. package/dist/item/item.attunement.d.ts +0 -14
  170. package/dist/item/item.attunement.js +1 -6
  171. package/dist/item/item.bonuses.js +1 -10
  172. package/dist/item/item.codec.js +1 -9
  173. package/dist/item/item.conditions.d.ts +0 -7
  174. package/dist/item/item.conditions.js +1 -11
  175. package/dist/item/item.conditions.types.d.ts +0 -2
  176. package/dist/item/item.cost.js +1 -29
  177. package/dist/item/item.enrichment.js +1 -9
  178. package/dist/item/item.icon.d.ts +0 -8
  179. package/dist/item/item.icon.js +1 -211
  180. package/dist/item/item.parser.js +1 -8
  181. package/dist/item/item.schema.d.ts +2 -0
  182. package/dist/item/item.schema.js +1 -11
  183. package/dist/item/item.types.d.ts +2 -28
  184. package/dist/monster/monster.ai-schema.js +1 -6
  185. package/dist/monster/monster.codec.d.ts +0 -10
  186. package/dist/monster/monster.enrichment.js +1 -19
  187. package/dist/monster/monster.format.d.ts +0 -69
  188. package/dist/monster/monster.format.js +1 -78
  189. package/dist/monster/monster.parser.d.ts +0 -4
  190. package/dist/monster/monster.parser.js +1 -15
  191. package/dist/monster/monster.resolve.d.ts +0 -4
  192. package/dist/monster/monster.schema.d.ts +0 -9
  193. package/dist/monster/monster.schema.js +1 -34
  194. package/dist/monster/monster.types.d.ts +0 -3
  195. package/dist/monster/monster.types.js +1 -1
  196. package/dist/optional-feature/optional-feature.codec.d.ts +0 -11
  197. package/dist/optional-feature/optional-feature.codec.js +1 -13
  198. package/dist/optional-feature/optional-feature.parser.js +1 -12
  199. package/dist/optional-feature/optional-feature.schema.d.ts +21 -1
  200. package/dist/optional-feature/optional-feature.schema.js +1 -15
  201. package/dist/pack.d.ts +0 -9
  202. package/dist/pc/conditions.constants.js +1 -6
  203. package/dist/pc/decision-recognizer.js +1 -8
  204. package/dist/pc/pc.additional-spells.d.ts +0 -24
  205. package/dist/pc/pc.additional-spells.js +1 -26
  206. package/dist/pc/pc.amount-bindings.d.ts +0 -25
  207. package/dist/pc/pc.amount-bindings.js +1 -28
  208. package/dist/pc/pc.asi-flatten.d.ts +0 -59
  209. package/dist/pc/pc.asi-flatten.js +1 -16
  210. package/dist/pc/pc.conditions.d.ts +1 -0
  211. package/dist/pc/pc.conditions.js +1 -6
  212. package/dist/pc/pc.containment.d.ts +0 -5
  213. package/dist/pc/pc.containment.js +1 -24
  214. package/dist/pc/pc.decision-engine.d.ts +0 -145
  215. package/dist/pc/pc.decision-engine.js +1 -55
  216. package/dist/pc/pc.defense-normalize.d.ts +0 -10
  217. package/dist/pc/pc.defense-normalize.js +1 -6
  218. package/dist/pc/pc.entry-overrides.d.ts +0 -58
  219. package/dist/pc/pc.entry-overrides.js +1 -41
  220. package/dist/pc/pc.equipment.d.ts +2 -22
  221. package/dist/pc/pc.equipment.js +1 -34
  222. package/dist/pc/pc.feature-effects.d.ts +22 -281
  223. package/dist/pc/pc.feature-effects.js +1 -39
  224. package/dist/pc/pc.formula-context.js +1 -11
  225. package/dist/pc/pc.infusions.d.ts +0 -65
  226. package/dist/pc/pc.infusions.js +1 -65
  227. package/dist/pc/pc.item-effects.d.ts +18 -0
  228. package/dist/pc/pc.member-choices.d.ts +3 -66
  229. package/dist/pc/pc.member-choices.js +1 -39
  230. package/dist/pc/pc.parser.js +1 -58
  231. package/dist/pc/pc.pools.d.ts +7 -10
  232. package/dist/pc/pc.pools.js +1 -27
  233. package/dist/pc/pc.proficiencies.d.ts +0 -40
  234. package/dist/pc/pc.proficiencies.js +1 -156
  235. package/dist/pc/pc.proficiency-grants.d.ts +0 -26
  236. package/dist/pc/pc.proficiency-normalize.d.ts +0 -35
  237. package/dist/pc/pc.proficiency-normalize.js +1 -18
  238. package/dist/pc/pc.proficiency-query.d.ts +0 -13
  239. package/dist/pc/pc.proficiency-query.js +1 -27
  240. package/dist/pc/pc.recalc.d.ts +7 -131
  241. package/dist/pc/pc.recalc.js +1 -1042
  242. package/dist/pc/pc.resolver.d.ts +0 -107
  243. package/dist/pc/pc.resolver.js +1 -60
  244. package/dist/pc/pc.resource-seed.d.ts +0 -8
  245. package/dist/pc/pc.resource-seed.js +1 -42
  246. package/dist/pc/pc.resources.d.ts +1 -59
  247. package/dist/pc/pc.resources.js +1 -23
  248. package/dist/pc/pc.rest.d.ts +1 -20
  249. package/dist/pc/pc.rest.js +1 -231
  250. package/dist/pc/pc.schema.d.ts +0 -2
  251. package/dist/pc/pc.schema.js +1 -9
  252. package/dist/pc/pc.slotting.d.ts +0 -29
  253. package/dist/pc/pc.slotting.js +1 -28
  254. package/dist/pc/pc.speeds.d.ts +19 -0
  255. package/dist/pc/pc.spell-scope.d.ts +0 -16
  256. package/dist/pc/pc.spellcasting.d.ts +0 -70
  257. package/dist/pc/pc.spellcasting.js +1 -28
  258. package/dist/pc/pc.table-column.d.ts +0 -22
  259. package/dist/pc/pc.table-column.js +1 -18
  260. package/dist/pc/pc.tool-picks.d.ts +0 -27
  261. package/dist/pc/pc.tool-picks.js +1 -18
  262. package/dist/pc/pc.types.d.ts +54 -374
  263. package/dist/pc/pc.weapon-grant.d.ts +0 -6
  264. package/dist/pc/pool-layout.d.ts +0 -39
  265. package/dist/pc/pool-layout.js +1 -18
  266. package/dist/pc/resource-equivalents.d.ts +2 -40
  267. package/dist/pc/roll-scope.js +1 -8
  268. package/dist/pc/roll-tag-labels.d.ts +0 -32
  269. package/dist/pc/roll-tag-labels.js +1 -17
  270. package/dist/pc/spell-source.d.ts +0 -11
  271. package/dist/pc/spell-source.js +1 -8
  272. package/dist/race/race.codec.d.ts +0 -6
  273. package/dist/race/race.codec.js +1 -15
  274. package/dist/race/race.parser.js +1 -14
  275. package/dist/race/race.schema.d.ts +0 -8
  276. package/dist/race/race.schema.js +1 -14
  277. package/dist/race/race.structural.d.ts +0 -6
  278. package/dist/race/race.structural.js +1 -6
  279. package/dist/race/race.types.d.ts +0 -8
  280. package/dist/schemas/attack-schema.d.ts +5 -0
  281. package/dist/schemas/caster-type-schema.d.ts +1 -6
  282. package/dist/schemas/caster-type-schema.js +1 -6
  283. package/dist/schemas/choice-schema.js +1 -7
  284. package/dist/schemas/duration-schema.d.ts +0 -2
  285. package/dist/schemas/duration-schema.js +1 -6
  286. package/dist/schemas/entity-extras-schema.d.ts +0 -30
  287. package/dist/schemas/entity-extras-schema.js +1 -10
  288. package/dist/schemas/equipment-grant-schema.d.ts +0 -2
  289. package/dist/schemas/equipment-grant-schema.js +1 -12
  290. package/dist/schemas/feature-alias.d.ts +0 -27
  291. package/dist/schemas/feature-effect-schema.d.ts +21 -1
  292. package/dist/schemas/feature-effect-schema.js +1 -6
  293. package/dist/schemas/feature-schema.d.ts +0 -6
  294. package/dist/schemas/feature-schema.js +1 -12
  295. package/dist/schemas/resource-schema.d.ts +1 -34
  296. package/dist/schemas/resource-schema.js +1 -12
  297. package/dist/schemas/selection-pool-schema.js +1 -10
  298. package/dist/spell/casting-time.d.ts +0 -15
  299. package/dist/spell/casting-time.js +1 -6
  300. package/dist/spell/spell.access.d.ts +0 -6
  301. package/dist/spell/spell.access.js +1 -45
  302. package/dist/spell/spell.ai-schema.js +1 -6
  303. package/dist/spell/spell.codec.js +1 -9
  304. package/dist/spell/spell.enrichment.js +1 -9
  305. package/dist/spell/spell.filter.d.ts +0 -5
  306. package/dist/spell/spell.filter.js +1 -75
  307. package/dist/spell/spell.parser.d.ts +0 -31
  308. package/dist/spell/spell.parser.js +1 -16
  309. package/dist/spell/spell.scaling.d.ts +0 -46
  310. package/dist/spell/spell.scaling.js +1 -79
  311. package/dist/spell/spell.schema.js +1 -7
  312. package/dist/spell/spell.types.d.ts +0 -7
  313. package/dist/srd/retired-items.d.ts +0 -4
  314. package/dist/srd/retired-items.js +1 -11
  315. package/dist/srd-store.d.ts +0 -33
  316. package/dist/subclass/subclass.codec.d.ts +0 -8
  317. package/dist/subclass/subclass.codec.js +1 -17
  318. package/dist/subclass/subclass.parser.js +1 -16
  319. package/dist/subclass/subclass.schema.d.ts +2 -1
  320. package/dist/subclass/subclass.schema.js +1 -14
  321. package/dist/subclass/subclass.types.d.ts +0 -3
  322. package/dist/types/attack.d.ts +2 -0
  323. package/dist/types/casting-option.d.ts +0 -4
  324. package/dist/types/choice.d.ts +1 -72
  325. package/dist/types/choice.js +1 -24
  326. package/dist/types/edition.d.ts +0 -3
  327. package/dist/types/equipment-grant.d.ts +1 -27
  328. package/dist/types/equipment-grant.js +1 -12
  329. package/dist/types/feature-effect.d.ts +4 -22
  330. package/dist/types/feature.d.ts +0 -22
  331. package/dist/types/optional-feature.types.d.ts +1 -31
  332. package/dist/types/resource.d.ts +1 -21
  333. package/dist/types/selection-pool.d.ts +0 -24
  334. package/dist/weapon/weapon-mastery.d.ts +0 -1
  335. package/dist/weapon/weapon.classify.d.ts +0 -11
  336. package/dist/weapon/weapon.classify.js +1 -7
  337. package/dist/weapon/weapon.codec.d.ts +0 -9
  338. package/dist/weapon/weapon.codec.js +1 -9
  339. package/dist/weapon/weapon.parser.js +1 -8
  340. package/dist/weapon/weapon.schema.js +1 -7
  341. package/dist/weapon/weapon.types.d.ts +0 -3
  342. package/package.json +3 -3
  343. package/src/data-srd/ATTRIBUTION.md +1 -1
  344. package/dist/chunk-2FRUSVZS.js +0 -489
  345. package/dist/chunk-2LULMQTF.js +0 -14
  346. package/dist/chunk-3LWMFYKS.js +0 -57
  347. package/dist/chunk-3SFGWFVQ.js +0 -19
  348. package/dist/chunk-3SIUAFDQ.js +0 -18
  349. package/dist/chunk-3TM34RSJ.js +0 -23
  350. package/dist/chunk-4J6DS3EJ.js +0 -30
  351. package/dist/chunk-4U55VNC7.js +0 -22
  352. package/dist/chunk-5GKJAUMX.js +0 -59
  353. package/dist/chunk-5JXFJ5AU.js +0 -26
  354. package/dist/chunk-64VNLMSG.js +0 -375
  355. package/dist/chunk-656QCX4U.js +0 -22
  356. package/dist/chunk-6GNXYAYP.js +0 -25
  357. package/dist/chunk-6PXTNCBP.js +0 -133
  358. package/dist/chunk-6X2NV665.js +0 -33
  359. package/dist/chunk-7Q2VPKCD.js +0 -181
  360. package/dist/chunk-7XJHI5H5.js +0 -709
  361. package/dist/chunk-A54HHCWW.js +0 -67
  362. package/dist/chunk-B2QHP6UF.js +0 -159
  363. package/dist/chunk-B3DP42OM.js +0 -55
  364. package/dist/chunk-BJGOSM76.js +0 -18
  365. package/dist/chunk-BJWSOQUC.js +0 -133
  366. package/dist/chunk-CJYCVNW2.js +0 -7
  367. package/dist/chunk-CM5CWO4K.js +0 -735
  368. package/dist/chunk-DEEHHLAP.js +0 -271
  369. package/dist/chunk-DPUJDOKV.js +0 -365
  370. package/dist/chunk-EJD47JHL.js +0 -1838
  371. package/dist/chunk-EJP263OP.js +0 -186
  372. package/dist/chunk-EVMUJYUD.js +0 -195
  373. package/dist/chunk-EYX4JMAU.js +0 -101
  374. package/dist/chunk-FC4IGH5Y.js +0 -18
  375. package/dist/chunk-FJYBLXV7.js +0 -89
  376. package/dist/chunk-FMUD3LDV.js +0 -19
  377. package/dist/chunk-FMYWORTP.js +0 -93
  378. package/dist/chunk-FVXLP7P3.js +0 -18
  379. package/dist/chunk-G6MHJDVT.js +0 -41
  380. package/dist/chunk-GVWEFECG.js +0 -18
  381. package/dist/chunk-HHBD4SQ6.js +0 -24
  382. package/dist/chunk-HS6FIOLP.js +0 -52
  383. package/dist/chunk-HY2SRSVM.js +0 -23
  384. package/dist/chunk-IHE6KVC3.js +0 -13
  385. package/dist/chunk-IN4M4X7P.js +0 -34
  386. package/dist/chunk-IUAAXXNO.js +0 -58
  387. package/dist/chunk-JXWNXIIZ.js +0 -219
  388. package/dist/chunk-K5NJBTE2.js +0 -18
  389. package/dist/chunk-KR6JF3BF.js +0 -14
  390. package/dist/chunk-KSTV7J2U.js +0 -112
  391. package/dist/chunk-KU3YLF6D.js +0 -106
  392. package/dist/chunk-LBEXLN6I.js +0 -91
  393. package/dist/chunk-LHZXYFBU.js +0 -94
  394. package/dist/chunk-LICYHPI3.js +0 -237
  395. package/dist/chunk-LNT64X7C.js +0 -81
  396. package/dist/chunk-LSLSG67V.js +0 -31
  397. package/dist/chunk-LVQLWRCU.js +0 -15
  398. package/dist/chunk-MYY2C5MB.js +0 -233
  399. package/dist/chunk-NKZMQV2C.js +0 -19
  400. package/dist/chunk-NTU2DXNG.js +0 -355
  401. package/dist/chunk-NXUY5XQN.js +0 -1062
  402. package/dist/chunk-NZO7M5GV.js +0 -18
  403. package/dist/chunk-OOL4KMG2.js +0 -71
  404. package/dist/chunk-OOSRUJBI.js +0 -19
  405. package/dist/chunk-PDJSUH24.js +0 -110
  406. package/dist/chunk-PTXBIDG7.js +0 -63
  407. package/dist/chunk-PVCEA4HZ.js +0 -6
  408. package/dist/chunk-QA3YCOML.js +0 -101
  409. package/dist/chunk-QFWQKS3M.js +0 -110
  410. package/dist/chunk-QS5L5YTJ.js +0 -24
  411. package/dist/chunk-QYZV2MQA.js +0 -97
  412. package/dist/chunk-RD2MID3M.js +0 -292
  413. package/dist/chunk-S3YUXDSC.js +0 -278
  414. package/dist/chunk-S7REMWW4.js +0 -21
  415. package/dist/chunk-TOM66P2P.js +0 -38
  416. package/dist/chunk-TRBGC4ZG.js +0 -112
  417. package/dist/chunk-UA5KS2PL.js +0 -26
  418. package/dist/chunk-UJCK5IW4.js +0 -187
  419. package/dist/chunk-UNYR5GLI.js +0 -23
  420. package/dist/chunk-UZXG6QSY.js +0 -58
  421. package/dist/chunk-VN5DLURA.js +0 -158
  422. package/dist/chunk-VP5TIXDK.js +0 -178
  423. package/dist/chunk-VPYBK2MG.js +0 -18
  424. package/dist/chunk-VTTA2ALZ.js +0 -16
  425. package/dist/chunk-W6GC6OKK.js +0 -16
  426. package/dist/chunk-WELIKLZF.js +0 -256
  427. package/dist/chunk-WOHX7YTH.js +0 -165
  428. package/dist/chunk-WSVMLNTO.js +0 -31
  429. package/dist/chunk-WYGD2UGN.js +0 -14
  430. package/dist/chunk-XCFC7LGF.js +0 -122
  431. package/dist/chunk-XJ2F2WO6.js +0 -8
  432. package/dist/chunk-XTEFPUSN.js +0 -23
  433. package/dist/chunk-YBLDE5CG.js +0 -42
  434. package/dist/chunk-YDGMBMYI.js +0 -25
  435. package/dist/chunk-YHYTW5QA.js +0 -20
  436. package/dist/chunk-ZCTUYGNV.js +0 -26
  437. package/dist/chunk-ZDAEGJH4.js +0 -102
  438. package/dist/chunk-ZJXSXVFP.js +0 -58
  439. package/dist/chunk-ZOWKWMD2.js +0 -18
  440. package/dist/chunk-ZUQW5VBZ.js +0 -89
@@ -1,1838 +0,0 @@
1
- import {
2
- equipmentCategoryKey,
3
- isCategoryGrant
4
- } from "./chunk-2LULMQTF.js";
5
- import {
6
- TOOL_CATEGORIES,
7
- backgroundToolPicks,
8
- categoryWords,
9
- classToolPicks,
10
- expandToolPool,
11
- toolCategoriesOf
12
- } from "./chunk-QA3YCOML.js";
13
- import {
14
- assembleEffectFeatures,
15
- collectProficiencyEffectGrants
16
- } from "./chunk-64VNLMSG.js";
17
- import {
18
- ALL_LANGUAGES,
19
- ALL_SKILL_SLUGS,
20
- ALL_TOOLS
21
- } from "./chunk-KU3YLF6D.js";
22
- import {
23
- humanizeProficiency,
24
- proficiencyLabel,
25
- toProfSlug
26
- } from "./chunk-5JXFJ5AU.js";
27
- import {
28
- featOfSite,
29
- featPickSites,
30
- isTargetChoice,
31
- memberChoices,
32
- poolMemberSites,
33
- poolMemberSitesOf,
34
- raceFeatSites
35
- } from "./chunk-RD2MID3M.js";
36
- import {
37
- collectAdditionalSpells
38
- } from "./chunk-LICYHPI3.js";
39
- import {
40
- resolveFeatureResources,
41
- resolveResourceIndex
42
- } from "./chunk-KSTV7J2U.js";
43
- import {
44
- attributeUnclassedSpell,
45
- effectiveSpellcastingAbility,
46
- normalizeKnownSpell,
47
- resolveSpellcasting
48
- } from "./chunk-DPUJDOKV.js";
49
- import {
50
- convertibleLegacyAsi,
51
- flattenAsiOrFeat,
52
- resolveLegacyAsiFeat
53
- } from "./chunk-LBEXLN6I.js";
54
- import {
55
- bindFeatureConsumers,
56
- buildInfusionContext,
57
- resolveAllPools,
58
- resolveOptionRows,
59
- strandedPicks
60
- } from "./chunk-NXUY5XQN.js";
61
- import {
62
- countColumnsFor,
63
- readTableColumn
64
- } from "./chunk-IUAAXXNO.js";
65
- import {
66
- recognizeDecision
67
- } from "./chunk-YHYTW5QA.js";
68
- import {
69
- isItemEntity,
70
- resolveEntityForEntry
71
- } from "./chunk-LHZXYFBU.js";
72
- import {
73
- FEATURE_TYPE_FOR_CATEGORY,
74
- featProgressionCategory
75
- } from "./chunk-YBLDE5CG.js";
76
- import {
77
- warnOnce
78
- } from "./chunk-LVQLWRCU.js";
79
- import {
80
- bucketOf
81
- } from "./chunk-4J6DS3EJ.js";
82
- import {
83
- isValidMaxFormula
84
- } from "./chunk-EVMUJYUD.js";
85
- import {
86
- bareEntitySlug,
87
- wikilinkTailSlug
88
- } from "./chunk-ZCTUYGNV.js";
89
- import {
90
- mirrorSpellShapes
91
- } from "./chunk-7Q2VPKCD.js";
92
- import {
93
- ABILITY_KEYS
94
- } from "./chunk-WELIKLZF.js";
95
- import {
96
- withResolvedActionCost
97
- } from "./chunk-4U55VNC7.js";
98
-
99
- // src/pc/pc.proficiency-grants.ts
100
- var UNKNOWN_SOURCE = "Unknown";
101
- function collectProficiencyGrants(resolved) {
102
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
103
- const classArmor = [];
104
- const classWeaponFixed = [];
105
- const classWeaponCategories = [];
106
- const classToolFixed = [];
107
- for (const c of resolved.classes) {
108
- const prof = (_a = c.entity) == null ? void 0 : _a.proficiencies;
109
- if (!prof) continue;
110
- const source = (_c = (_b = c.entity) == null ? void 0 : _b.name) != null ? _c : UNKNOWN_SOURCE;
111
- for (const a of (_d = prof.armor) != null ? _d : []) classArmor.push({ value: a, source });
112
- for (const w of (_f = (_e = prof.weapons) == null ? void 0 : _e.fixed) != null ? _f : []) classWeaponFixed.push({ value: w, source });
113
- for (const w of (_h = (_g = prof.weapons) == null ? void 0 : _g.categories) != null ? _h : []) classWeaponCategories.push({ value: w, source });
114
- for (const t of (_j = (_i = prof.tools) == null ? void 0 : _i.fixed) != null ? _j : []) classToolFixed.push({ value: t, source });
115
- for (const t of classToolPicks(c.entity).grants) classToolFixed.push({ value: t, source });
116
- }
117
- const raceSource = (_l = (_k = resolved.race) == null ? void 0 : _k.name) != null ? _l : UNKNOWN_SOURCE;
118
- const raceLangFixed = ((_o = (_n = (_m = resolved.race) == null ? void 0 : _m.languages) == null ? void 0 : _n.fixed) != null ? _o : []).map(
119
- (l) => ({ value: l, source: raceSource })
120
- );
121
- const bgToolFixed = [];
122
- const bgLangFixed = [];
123
- const bg = resolved.background;
124
- if (bg) {
125
- const source = (_p = bg.name) != null ? _p : UNKNOWN_SOURCE;
126
- for (const entry of (_q = bg.tool_proficiencies) != null ? _q : []) {
127
- if (entry.kind === "fixed") {
128
- for (const t of entry.items) bgToolFixed.push({ value: t, source });
129
- }
130
- }
131
- for (const t of backgroundToolPicks(bg).grants) bgToolFixed.push({ value: t, source });
132
- for (const entry of (_r = bg.language_proficiencies) != null ? _r : []) {
133
- if (entry.kind === "fixed") {
134
- for (const l of entry.languages) bgLangFixed.push({ value: l, source });
135
- }
136
- }
137
- }
138
- const featArmor = [];
139
- const featWeapons = [];
140
- const featTools = [];
141
- const featLanguages = [];
142
- for (const f of (_s = resolved.feats) != null ? _s : []) {
143
- const featView = f;
144
- const grants = featView.proficiencies;
145
- if (!grants) continue;
146
- const source = (_t = f.name) != null ? _t : UNKNOWN_SOURCE;
147
- for (const a of (_u = grants.armor) != null ? _u : []) featArmor.push({ value: a, source });
148
- for (const w of (_v = grants.weapons) != null ? _v : []) featWeapons.push({ value: w, source });
149
- for (const t of (_w = grants.tools) != null ? _w : []) featTools.push({ value: t, source });
150
- for (const l of (_x = grants.languages) != null ? _x : []) featLanguages.push({ value: l, source });
151
- }
152
- const { features: effectFeatures, activeBuffs } = assembleEffectFeatures(resolved);
153
- const fx = collectProficiencyEffectGrants(effectFeatures, activeBuffs);
154
- const nameFor = (kind, slug) => {
155
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2;
156
- switch (kind) {
157
- case "class":
158
- return (_d2 = (_c2 = (_b2 = (_a2 = resolved.classes) == null ? void 0 : _a2.find((c) => {
159
- var _a3;
160
- return ((_a3 = c.entity) == null ? void 0 : _a3.slug) === slug;
161
- })) == null ? void 0 : _b2.entity) == null ? void 0 : _c2.name) != null ? _d2 : UNKNOWN_SOURCE;
162
- case "subclass":
163
- return (_h2 = (_g2 = (_f2 = (_e2 = resolved.classes) == null ? void 0 : _e2.find((c) => {
164
- var _a3;
165
- return ((_a3 = c.subclass) == null ? void 0 : _a3.slug) === slug;
166
- })) == null ? void 0 : _f2.subclass) == null ? void 0 : _g2.name) != null ? _h2 : UNKNOWN_SOURCE;
167
- case "race":
168
- return (_j2 = (_i2 = resolved.race) == null ? void 0 : _i2.name) != null ? _j2 : UNKNOWN_SOURCE;
169
- case "background":
170
- return (_l2 = (_k2 = resolved.background) == null ? void 0 : _k2.name) != null ? _l2 : UNKNOWN_SOURCE;
171
- case "feat":
172
- return (_o2 = (_n2 = (_m2 = resolved.feats) == null ? void 0 : _m2.find((f) => f.slug === slug)) == null ? void 0 : _n2.name) != null ? _o2 : UNKNOWN_SOURCE;
173
- default:
174
- return UNKNOWN_SOURCE;
175
- }
176
- };
177
- const toGrants = (list, useRaw) => list.map((g) => ({ value: useRaw ? g.raw : g.value, source: nameFor(g.sourceKind, g.sourceSlug), ...g.expertise ? { expertise: true } : {} }));
178
- const effectArmor = toGrants(fx.armor, true);
179
- const effectWeapons = toGrants(fx.weapons, true);
180
- const effectTools = toGrants(fx.tools, false);
181
- const effectLanguages = toGrants(fx.languages, false);
182
- return {
183
- classArmor,
184
- classWeaponFixed,
185
- classWeaponCategories,
186
- classToolFixed,
187
- raceLangFixed,
188
- bgToolFixed,
189
- bgLangFixed,
190
- featArmor,
191
- featWeapons,
192
- featTools,
193
- featLanguages,
194
- effectArmor,
195
- effectWeapons,
196
- effectTools,
197
- effectLanguages
198
- };
199
- }
200
-
201
- // src/pc/pc.decision-engine.ts
202
- var warnedDegradedEquipment = /* @__PURE__ */ new Set();
203
- var warnedAmbiguousBare = /* @__PURE__ */ new Set();
204
- var foldedTypeMemo = /* @__PURE__ */ new Map();
205
- function foldedType(s) {
206
- let v = foldedTypeMemo.get(s);
207
- if (v === void 0) {
208
- v = categoryWords(s).join(" ");
209
- foldedTypeMemo.set(s, v);
210
- }
211
- return v;
212
- }
213
- function matchesFilter(e, where, ownerBare) {
214
- var _a, _b, _c, _d, _e;
215
- const d = e.data;
216
- if (where.feature_type && d.feature_type !== where.feature_type) return false;
217
- if (where.category && d.category !== where.category) return false;
218
- if (where.list && !((_a = d.classes) != null ? _a : []).includes(where.list)) return false;
219
- if (where.level !== void 0 && ((_b = d.level) != null ? _b : 0) !== where.level) return false;
220
- if (where.edition && d.edition !== where.edition) return false;
221
- if (where.ritual && d.ritual !== true) return false;
222
- if (where.weapon_category) {
223
- const cat = ((_c = d.category) != null ? _c : "").toLowerCase();
224
- if (!cat.startsWith(`${where.weapon_category}-`) && cat !== where.weapon_category) return false;
225
- }
226
- if (where.armor_category) {
227
- if (((_d = d.category) != null ? _d : "").toLowerCase() !== where.armor_category) return false;
228
- }
229
- if (where.item_type) {
230
- const t = foldedType(typeof d.type === "string" ? d.type : "");
231
- if (!t || !where.item_type.some((x) => foldedType(x) === t)) return false;
232
- }
233
- if (where.mundane) {
234
- const r = typeof d.rarity === "string" ? d.rarity.trim().toLowerCase() : "";
235
- if (r && r !== "none" && r !== "mundane") return false;
236
- }
237
- if (where.parent_class === "self") {
238
- if (!d.parent_class || wikilinkTailSlug(d.parent_class) !== ownerBare) return false;
239
- }
240
- if (where.available_to === "self") {
241
- const list = (_e = d.available_to) != null ? _e : [];
242
- if (!list.some((l) => wikilinkTailSlug(l) === ownerBare)) return false;
243
- }
244
- return true;
245
- }
246
- var __matchesFilterForTest = matchesFilter;
247
- function parseEquipmentCategory(category) {
248
- const tools = toolCategoriesOf(category);
249
- if (tools) return { kind: "tool", tools };
250
- const words = categoryWords(category).filter((w) => w !== "any");
251
- const has = (w) => words.includes(w);
252
- const only = (allowed) => words.every((w) => allowed.includes(w));
253
- if (words.length === 1 && has("shield")) return { kind: "shield" };
254
- if (has("armor") && only(["armor", "light", "medium", "heavy"]) && words.length <= 2) {
255
- const armor = ["light", "medium", "heavy"].find((k) => has(k));
256
- return { kind: "armor", armor };
257
- }
258
- if (has("weapon") && only(["weapon", "simple", "martial", "melee", "ranged"])) {
259
- const klass = ["simple", "martial"].filter((k) => has(k));
260
- const range = ["melee", "ranged"].filter((k) => has(k));
261
- if (klass.length === 1 && range.length <= 1 && words.length === 2 + range.length) {
262
- return { kind: "weapon", weapon: klass[0], range: range[0] };
263
- }
264
- }
265
- return void 0;
266
- }
267
- function categoryToEntitySelect(category, id) {
268
- const spec = parseEquipmentCategory(category);
269
- const pick = { kind: "select-entity", id, count: 1 };
270
- switch (spec == null ? void 0 : spec.kind) {
271
- case "shield":
272
- return { ...pick, label: "Choose a shield", entity_type: "armor", where: { armor_category: "shield" } };
273
- case "armor":
274
- return spec.armor ? { ...pick, label: `Choose ${spec.armor} armor`, entity_type: "armor", where: { armor_category: spec.armor } } : { ...pick, label: "Choose armor", entity_type: "armor" };
275
- case "weapon":
276
- return {
277
- ...pick,
278
- label: `Choose a ${spec.weapon}${spec.range ? ` ${spec.range}` : ""} weapon`,
279
- entity_type: "weapon",
280
- where: { weapon_category: spec.weapon }
281
- };
282
- case "tool":
283
- return {
284
- ...pick,
285
- label: `Choose ${spec.tools.map((t) => TOOL_CATEGORIES[t].label).join(" or ")}`,
286
- entity_type: "item",
287
- where: { item_type: spec.tools.map((t) => TOOL_CATEGORIES[t].itemType), mundane: true }
288
- };
289
- default:
290
- warnOnce(
291
- `equipment-category:${category}`,
292
- `Archivist: starting-equipment category "${category}" is not a known item category; its pick offers no options.`
293
- );
294
- return { ...pick, label: `Choose a ${category.replace(/[-_]+/g, " ")}`, entity_type: "item", from: [] };
295
- }
296
- }
297
- var __categoryToEntitySelectForTest = categoryToEntitySelect;
298
- function equipmentDecisions(entries, ownerSlug) {
299
- const out = [];
300
- let degraded = false;
301
- (entries != null ? entries : []).forEach((eq, i) => {
302
- var _a;
303
- if ((eq == null ? void 0 : eq.kind) !== "choice") return;
304
- const options = (_a = eq.options) != null ? _a : [];
305
- out.push({
306
- kind: "select-inline",
307
- id: `equipment-${i}`,
308
- label: "Starting Equipment",
309
- count: 1,
310
- options: options.map((opt, j) => {
311
- var _a2;
312
- const label = typeof opt === "string" ? opt : (_a2 = opt == null ? void 0 : opt.label) != null ? _a2 : "";
313
- const wellFormed = !!opt && typeof opt === "object" && Array.isArray(opt.grants);
314
- if (!wellFormed) degraded = true;
315
- const grants = wellFormed ? opt.grants : [];
316
- return {
317
- value: `option-${j}`,
318
- label,
319
- choices: grants.flatMap((g, k) => isCategoryGrant(g) ? [categoryToEntitySelect(g.category, equipmentCategoryKey(i, j, k))] : [])
320
- };
321
- })
322
- });
323
- });
324
- if (degraded && !warnedDegradedEquipment.has(ownerSlug)) {
325
- warnedDegradedEquipment.add(ownerSlug);
326
- console.warn(
327
- `[archivist] Starting equipment for "${ownerSlug}" is in an outdated/unstructured format; its nested picks and seeding are skipped. Re-sync the compendium (delete _compendium.md and reload) to fix.`
328
- );
329
- }
330
- return out;
331
- }
332
- function authoredProficiencyPool(choice) {
333
- if (!choice.from) return void 0;
334
- return choice.domain === "tool" ? expandToolPool(choice.from) : choice.from;
335
- }
336
- function enumerateOptions(choice, ctx, ownerBare) {
337
- var _a, _b;
338
- switch (choice.kind) {
339
- case "select-inline":
340
- return choice.options.map((o) => ({ value: o.value, label: o.label, description: o.description }));
341
- case "select-entity": {
342
- if (choice.from) {
343
- let byBare;
344
- const bareIndex = () => {
345
- var _a2, _b2, _c, _d;
346
- if (byBare) return byBare;
347
- const built = /* @__PURE__ */ new Map();
348
- const pool = ctx.registry.search("", choice.entity_type, Number.POSITIVE_INFINITY).slice().sort((a, b) => a.name.localeCompare(b.name) || a.slug.localeCompare(b.slug));
349
- const seed = (e) => {
350
- const bare = bareEntitySlug(e.slug);
351
- if (built.has(bare)) {
352
- if (!warnedAmbiguousBare.has(bare)) {
353
- warnedAmbiguousBare.add(bare);
354
- console.warn(`Archivist: bare slug "${bare}" matches multiple ${choice.entity_type} entities; using "${built.get(bare).slug}"`);
355
- }
356
- return;
357
- }
358
- built.set(bare, e);
359
- };
360
- for (const e of pool) if ((_b2 = (_a2 = ctx.isEntityVisible) == null ? void 0 : _a2.call(ctx, e)) != null ? _b2 : true) seed(e);
361
- for (const e of pool) if (!((_d = (_c = ctx.isEntityVisible) == null ? void 0 : _c.call(ctx, e)) != null ? _d : true)) seed(e);
362
- byBare = built;
363
- return built;
364
- };
365
- return choice.from.map((slug) => {
366
- var _a2;
367
- const e = (_a2 = ctx.registry.getByTypeAndSlug(choice.entity_type, slug)) != null ? _a2 : bareIndex().get(slug);
368
- return e ? { value: e.slug, label: e.name, entity: e } : { value: slug, label: slug, missing: true };
369
- });
370
- }
371
- const all = ctx.registry.search("", choice.entity_type, Number.POSITIVE_INFINITY);
372
- const filtered = choice.where ? all.filter((e) => matchesFilter(e, choice.where, ownerBare)) : all;
373
- return filtered.map((e) => ({ value: e.slug, label: e.name, entity: e }));
374
- }
375
- case "select-proficiency": {
376
- const pool = (_a = authoredProficiencyPool(choice)) != null ? _a : choice.domain === "skill" ? [...ALL_SKILL_SLUGS] : choice.domain === "language" ? [...ALL_LANGUAGES] : choice.domain === "tool" ? [...ALL_TOOLS] : [];
377
- return pool.map((v) => ({ value: v, label: humanizeProficiency(v) }));
378
- }
379
- case "ability-points": {
380
- const pool = (_b = choice.pool) != null ? _b : ["str", "dex", "con", "int", "wis", "cha"];
381
- return pool.map((a) => ({ value: a, label: a.toUpperCase() }));
382
- }
383
- }
384
- }
385
- function selectionCount(choice, selected) {
386
- if (selected === void 0) return 0;
387
- if (choice.kind === "ability-points") {
388
- if (typeof selected !== "object" || Array.isArray(selected)) return 0;
389
- return Object.values(selected).reduce((s, v) => s + (typeof v === "number" ? v : 0), 0);
390
- }
391
- if (Array.isArray(selected)) return selected.length;
392
- return typeof selected === "string" && selected.length > 0 ? 1 : 0;
393
- }
394
- function requiredCount(choice) {
395
- var _a;
396
- if (choice.kind === "ability-points") return choice.points;
397
- if (choice.kind === "select-proficiency") return choice.count;
398
- return (_a = choice.count) != null ? _a : 1;
399
- }
400
- function capAtCount(choice, value) {
401
- const folds = choice.kind === "select-proficiency" || choice.kind === "select-entity" && choice.entity_type === "weapon" && choice.id !== "weapon-mastery";
402
- if (!folds || !Array.isArray(value)) return value;
403
- const n = requiredCount(choice);
404
- return value.length > n ? value.slice(0, n) : value;
405
- }
406
- function statusOf(choice, selected, satisfied) {
407
- const n = selectionCount(choice, selected);
408
- const need = requiredCount(choice);
409
- if (satisfied) return "resolved";
410
- if (n === 0) return "unresolved";
411
- return n >= need ? "resolved" : "partial";
412
- }
413
- var matchPool = (v, pool) => pool.find((p) => toProfSlug(p) === toProfSlug(v));
414
- var canonicalizeSelection = (value, pool) => {
415
- var _a;
416
- if (typeof value === "string") return (_a = matchPool(value, pool)) != null ? _a : value;
417
- if (Array.isArray(value)) return value.map((v) => {
418
- var _a2;
419
- return (_a2 = matchPool(v, pool)) != null ? _a2 : v;
420
- });
421
- return value;
422
- };
423
- function resolveEntityRef(ctx, entityType, value) {
424
- if (typeof value !== "string" || value.length === 0) return void 0;
425
- const raw = value.replace(/^\[\[/, "").replace(/\]\]$/, "");
426
- const direct = ctx.registry.getByTypeAndSlug(entityType, raw);
427
- if (direct) return direct;
428
- for (const e of ctx.registry.search("", entityType, Number.POSITIVE_INFINITY)) {
429
- if (e.slug === raw || bareEntitySlug(e.slug) === raw) return e;
430
- }
431
- return void 0;
432
- }
433
- function buildItem(inputChoice, source, level, featureName, readValue, ctx, ownerBare, effective, opts) {
434
- var _a, _b, _c, _d;
435
- const choice = flattenAsiOrFeat(inputChoice);
436
- const keyPrefix = (_a = opts == null ? void 0 : opts.keyPrefix) != null ? _a : "";
437
- const expandFeatChildren = (_b = opts == null ? void 0 : opts.expandFeatChildren) != null ? _b : true;
438
- const key = keyPrefix + choice.id;
439
- const raw = capAtCount(choice, readValue(key));
440
- const preExclusionOptions = enumerateOptions(choice, ctx, ownerBare);
441
- let options = preExclusionOptions;
442
- const mine = new Set(
443
- (Array.isArray(raw) ? raw : raw === void 0 ? [] : [raw]).map((v) => toProfSlug(String(v)))
444
- );
445
- if (choice.kind === "select-proficiency" && choice.domain === "skill" && choice.from_proficient) {
446
- options = options.filter((o) => effective.skill.has(toProfSlug(o.value)) || mine.has(toProfSlug(o.value)));
447
- }
448
- const postInclusionOptions = options;
449
- const excludes = choice.kind === "select-proficiency" && (choice.domain === "language" || choice.domain === "tool" || choice.domain === "skill" && choice.expertise === true);
450
- if (excludes && choice.kind === "select-proficiency") {
451
- const known = choice.domain === "skill" ? effective.skillExpertise : effective[choice.domain];
452
- options = options.filter((o) => !known.has(toProfSlug(o.value)) || mine.has(toProfSlug(o.value)));
453
- }
454
- const satisfied = excludes && postInclusionOptions.length > 0 && options.length === 0;
455
- const selected = choice.kind === "select-proficiency" ? canonicalizeSelection(raw, options.map((o) => o.value)) : raw;
456
- const item = {
457
- key,
458
- source,
459
- level,
460
- featureName,
461
- choice,
462
- description: opts == null ? void 0 : opts.description,
463
- options,
464
- selected,
465
- status: statusOf(choice, selected, satisfied),
466
- satisfied
467
- };
468
- if (choice.kind === "select-inline" && typeof selected === "string") {
469
- const branch = choice.options.find((o) => o.value === selected);
470
- if ((_c = branch == null ? void 0 : branch.choices) == null ? void 0 : _c.length) {
471
- item.children = branch.choices.map((c) => buildItem(
472
- c,
473
- source,
474
- level,
475
- featureName,
476
- readValue,
477
- ctx,
478
- ownerBare,
479
- effective,
480
- { keyPrefix, expandFeatChildren }
481
- ));
482
- if (item.status === "resolved" && item.children.some((c) => c.status !== "resolved")) {
483
- item.status = "partial";
484
- }
485
- }
486
- }
487
- if (choice.kind === "select-entity" && choice.entity_type === "feat" && expandFeatChildren && typeof selected === "string") {
488
- const entity = resolveEntityRef(ctx, "feat", selected);
489
- const rawChoices = (_d = entity == null ? void 0 : entity.data) == null ? void 0 : _d.choices;
490
- const featChoices = Array.isArray(rawChoices) ? rawChoices : [];
491
- if (featChoices.length) {
492
- const childPrefix = `${keyPrefix}feat:`;
493
- item.children = featChoices.map((c) => buildItem(
494
- c,
495
- source,
496
- level,
497
- featureName,
498
- readValue,
499
- ctx,
500
- ownerBare,
501
- effective,
502
- { keyPrefix: childPrefix, expandFeatChildren: false }
503
- ));
504
- if (item.status === "resolved" && item.children.some((c) => c.status !== "resolved")) {
505
- item.status = "partial";
506
- }
507
- }
508
- }
509
- return item;
510
- }
511
- function buildSubclassItem(choice, source, level, featureName, c, ctx, ownerBare, description) {
512
- const selected = c.subclass ? c.subclass.slug : void 0;
513
- return {
514
- key: "subclass",
515
- source,
516
- level,
517
- featureName,
518
- description,
519
- choice,
520
- options: enumerateOptions(choice, ctx, ownerBare),
521
- selected,
522
- status: selected ? "resolved" : "unresolved",
523
- // A subclass pick is a select-entity, never a proficiency choice, so no
524
- // exclusion can empty its pool.
525
- satisfied: false
526
- };
527
- }
528
- function visitProficiencyChoices(resolved, visit) {
529
- var _a, _b, _c, _d, _e;
530
- const walk = (choices, read) => {
531
- for (const ch of choices != null ? choices : []) {
532
- visit(ch, read(ch.id));
533
- if (ch.kind === "select-inline") {
534
- const sel = read(ch.id);
535
- const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
536
- if (branch == null ? void 0 : branch.choices) walk(branch.choices, read);
537
- }
538
- }
539
- };
540
- const oc = (_a = resolved.definition.origin_choices) != null ? _a : {};
541
- const originRead = (ns) => (id) => oc[`${ns}:${id}`];
542
- const stripRef = (ref) => ref.replace(/^\[\[/, "").replace(/\]\]$/, "");
543
- const featBySlug = new Map(((_b = resolved.feats) != null ? _b : []).map((f) => [f.slug, f]));
544
- const memberSites = poolMemberSitesOf(resolved);
545
- const featSites = featPickSites(resolved.classes, memberSites, (ci) => {
546
- var _a2, _b2, _c2, _d2;
547
- return (_d2 = (_c2 = (_b2 = (_a2 = resolved.classes) == null ? void 0 : _a2[ci]) == null ? void 0 : _b2.entity) == null ? void 0 : _c2.slug) != null ? _d2 : null;
548
- });
549
- resolved.classes.forEach((c, i) => {
550
- var _a2, _b2, _c2, _d2, _e2;
551
- if (!c.entity) return;
552
- const entity = c.entity;
553
- const readAt = (lvl) => (id) => {
554
- var _a3;
555
- return (_a3 = c.choices[lvl]) == null ? void 0 : _a3[id];
556
- };
557
- if (i === 0 && ((_b2 = (_a2 = entity.skill_choices) == null ? void 0 : _a2.from) == null ? void 0 : _b2.length)) {
558
- visit({
559
- kind: "select-proficiency",
560
- id: "skills",
561
- count: entity.skill_choices.count,
562
- domain: "skill",
563
- from: entity.skill_choices.from
564
- }, readAt(1)("skills"));
565
- }
566
- if (i === 0) walk(entity.choices, readAt(1));
567
- if (i === 0) walk(classToolPicks(entity).decisions, readAt(1));
568
- for (const rf of resolved.features) {
569
- if (rf.source.kind !== "class" && rf.source.kind !== "subclass") continue;
570
- const belongs = rf.source.kind === "class" ? rf.source.slug === entity.slug : c.subclass != null && rf.source.slug === c.subclass.slug;
571
- if (!belongs) continue;
572
- for (const copy of (_c2 = rf.foldedFrom) != null ? _c2 : []) walk(copy.choices, readAt(copy.level));
573
- walk(rf.feature.choices, readAt(rf.source.level));
574
- }
575
- for (const site of featSites) {
576
- if (site.classIndex !== i) continue;
577
- const feat = (_e2 = featBySlug.get(stripRef(site.slug))) != null ? _e2 : featOfSite(site, (_d2 = resolved.feats) != null ? _d2 : []);
578
- if (!feat) continue;
579
- walk(feat.choices, site.read);
580
- }
581
- for (const site of memberSites) if (site.classIndex === i) walk(site.choices, site.read);
582
- });
583
- if (resolved.race) {
584
- walk(resolved.race.choices, originRead("race"));
585
- for (const t of (_c = resolved.race.traits) != null ? _c : []) walk(t.choices, originRead("race"));
586
- }
587
- if (resolved.background) {
588
- walk(resolved.background.choices, originRead("background"));
589
- walk(backgroundToolPicks(resolved.background).decisions, originRead("background"));
590
- if (resolved.background.feature) {
591
- const feature = resolved.background.feature;
592
- walk(feature.choices, originRead("background"));
593
- }
594
- }
595
- if (resolved.originFeatSlug) {
596
- const of = featBySlug.get(resolved.originFeatSlug);
597
- if (of) walk(of.choices, (id) => oc[`background:feat:${id}`]);
598
- }
599
- for (const site of raceFeatSites(resolved.race, oc)) {
600
- const rf = (_e = featBySlug.get(stripRef(site.slug))) != null ? _e : ((_d = resolved.feats) != null ? _d : []).find((f) => bareEntitySlug(f.slug) === bareEntitySlug(site.slug));
601
- if (rf) walk(rf.choices, site.read);
602
- }
603
- }
604
- var filterToPool = (vals, pool) => pool ? vals.map((v) => matchPool(v, pool)).filter((v) => !!v) : vals;
605
- function collectChosenProficiencies(resolved) {
606
- const out = { skills: [], expertise: [], languages: [], tools: [], weapons: [], saves: [] };
607
- const isAbility = (v) => ABILITY_KEYS.includes(v);
608
- visitProficiencyChoices(resolved, (choice, stored) => {
609
- const selected = capAtCount(choice, stored);
610
- const vals = Array.isArray(selected) ? selected : typeof selected === "string" ? [selected] : [];
611
- if (choice.kind === "select-entity" && choice.entity_type === "weapon") {
612
- if (choice.id === "weapon-mastery") return;
613
- for (const v of vals) {
614
- const bare = bareEntitySlug(String(v));
615
- if (bare && !out.weapons.includes(bare)) out.weapons.push(bare);
616
- }
617
- return;
618
- }
619
- if (choice.kind !== "select-proficiency") return;
620
- const valid = filterToPool(vals, authoredProficiencyPool(choice));
621
- if (choice.domain === "save") {
622
- for (const v of valid) if (isAbility(v) && !out.saves.includes(v)) out.saves.push(v);
623
- return;
624
- }
625
- const bucket = choice.domain === "skill" ? choice.expertise ? out.expertise : out.skills : choice.domain === "language" ? out.languages : choice.domain === "tool" ? out.tools : null;
626
- if (bucket) {
627
- for (const v of valid) if (!bucket.includes(v)) bucket.push(v);
628
- }
629
- });
630
- return out;
631
- }
632
- function proficiencyEntryFor(raw, vocab, origin, sources, expertise) {
633
- const hit = matchPool(raw, vocab);
634
- const value = hit ? toProfSlug(hit) : raw;
635
- const label = hit ? humanizeProficiency(value) : origin === "custom" ? raw : proficiencyLabel(raw);
636
- return { value, label, sources, origin, ...expertise ? { expertise: true } : {} };
637
- }
638
- function computeEffectiveProficiencies(resolved) {
639
- const c = composeLanguageToolProficiencies(resolved);
640
- return { languages: c.languages.kept, tools: c.tools.kept };
641
- }
642
- function computeSuppressedProficiencies(resolved) {
643
- const c = composeLanguageToolProficiencies(resolved);
644
- return { languages: c.languages.suppressed, tools: c.tools.suppressed };
645
- }
646
- function composeLanguageToolProficiencies(resolved) {
647
- const grants = collectProficiencyGrants(resolved);
648
- const chosen = collectChosenProficiencies(resolved);
649
- const build = (domain) => {
650
- var _a, _b, _c, _d, _e, _f, _g, _h;
651
- const vocab = domain === "languages" ? ALL_LANGUAGES : ALL_TOOLS;
652
- const ov = (_b = (_a = resolved.definition) == null ? void 0 : _a.overrides) == null ? void 0 : _b[domain];
653
- const adds = (_c = ov == null ? void 0 : ov.add) != null ? _c : [];
654
- const removes = (_d = ov == null ? void 0 : ov.remove) != null ? _d : [];
655
- const byValue = /* @__PURE__ */ new Map();
656
- const push = (raw, origin, source, expertise) => {
657
- const probe = proficiencyEntryFor(raw, vocab, origin, source ? [source] : [], expertise);
658
- const existing = byValue.get(probe.value);
659
- if (!existing) {
660
- byValue.set(probe.value, probe);
661
- return;
662
- }
663
- if (source && !existing.sources.includes(source)) existing.sources.push(source);
664
- if (expertise) existing.expertise = true;
665
- const rank = { grant: 0, pick: 1, manual: 2, custom: 3 };
666
- if (rank[origin] < rank[existing.origin]) existing.origin = origin;
667
- };
668
- const grantBuckets = domain === "languages" ? [grants.raceLangFixed, grants.bgLangFixed, grants.featLanguages, grants.effectLanguages] : [grants.classToolFixed, grants.bgToolFixed, grants.featTools, grants.effectTools];
669
- for (const b of grantBuckets) for (const g of b) push(g.value, "grant", g.source, g.expertise);
670
- for (const v of domain === "languages" ? chosen.languages : chosen.tools) push(v, "pick");
671
- for (const v of adds) push(v, matchPool(v, vocab) ? "manual" : "custom");
672
- const triSuppressed = /* @__PURE__ */ new Set();
673
- if (domain === "tools") {
674
- const tri = (_h = (_g = (_f = (_e = resolved.definition) == null ? void 0 : _e.overrides) == null ? void 0 : _f.tools) == null ? void 0 : _g.proficiency) != null ? _h : {};
675
- for (const [tool, state] of Object.entries(tri)) {
676
- const key = toProfSlug(tool);
677
- if (state === "none") {
678
- triSuppressed.add(key);
679
- continue;
680
- }
681
- let entry = [...byValue.values()].find((e) => toProfSlug(e.value) === key);
682
- if (!entry) {
683
- push(tool, matchPool(tool, vocab) ? "manual" : "custom");
684
- entry = [...byValue.values()].find((e) => toProfSlug(e.value) === key);
685
- }
686
- if (!entry) continue;
687
- if (state === "expertise") entry.expertise = true;
688
- else delete entry.expertise;
689
- }
690
- }
691
- const suppressed = /* @__PURE__ */ new Set([...removes.map((r) => toProfSlug(r)), ...triSuppressed]);
692
- const byLabel = (a, b) => a.label < b.label ? -1 : a.label > b.label ? 1 : 0;
693
- const kept = [...byValue.values()].filter((e) => !suppressed.has(toProfSlug(e.value))).sort(byLabel);
694
- return { kept, suppressed: [...byValue.values()].filter((e) => suppressed.has(toProfSlug(e.value))).sort(byLabel) };
695
- };
696
- return { languages: build("languages"), tools: build("tools") };
697
- }
698
- function collectChosenAbilityPoints(resolved) {
699
- var _a, _b, _c;
700
- const oc = (_a = resolved.definition.origin_choices) != null ? _a : {};
701
- const out = { race: {}, background: {} };
702
- const fold = (ns, choices) => {
703
- var _a2;
704
- for (const ch of choices != null ? choices : []) {
705
- if (ch.kind !== "ability-points") continue;
706
- const raw = oc[`${ns}:${ch.id}`];
707
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
708
- let left = ch.points;
709
- for (const ab of ABILITY_KEYS) {
710
- if (ch.pool && !ch.pool.includes(ab)) continue;
711
- const v = raw[ab];
712
- if (typeof v !== "number" || v <= 0 || left <= 0) continue;
713
- const take = Math.min(v, ch.max_per, left);
714
- out[ns][ab] = ((_a2 = out[ns][ab]) != null ? _a2 : 0) + take;
715
- left -= take;
716
- }
717
- }
718
- };
719
- const race = resolved.race;
720
- if (race) {
721
- fold("race", race.choices);
722
- for (const t of (_b = race.traits) != null ? _b : []) fold("race", t.choices);
723
- }
724
- const bg = resolved.background;
725
- if (bg) {
726
- fold("background", bg.choices);
727
- fold("background", (_c = bg.feature) == null ? void 0 : _c.choices);
728
- }
729
- return out;
730
- }
731
- function buildDecisionLedger(resolved, ctx) {
732
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
733
- const eff = computeEffectiveProficiencies(resolved);
734
- const chosen = collectChosenProficiencies(resolved);
735
- const { features, activeBuffs } = assembleEffectFeatures(resolved);
736
- const effectGrants = collectProficiencyEffectGrants(features, activeBuffs);
737
- const effective = {
738
- language: new Set(eff.languages.map((e) => toProfSlug(e.value))),
739
- tool: new Set(eff.tools.map((e) => toProfSlug(e.value))),
740
- // Same precedent as computeEffectiveProficiencies' `resolved.definition?.overrides?.[domain]`: the
741
- // type says `skills` is non-optional, but consumers build ResolvedCharacter by cast and `tests/` is
742
- // typechecked by nothing (the plugin's equipment-step fixtures pass a `definition` with no `skills`).
743
- skill: new Set([
744
- ...(_c = (_b = (_a = resolved.definition) == null ? void 0 : _a.skills) == null ? void 0 : _b.proficient) != null ? _c : [],
745
- ...(_e = (_d = resolved.background) == null ? void 0 : _d.skill_proficiencies) != null ? _e : [],
746
- ...chosen.skills,
747
- ...effectGrants.skills.map((g) => g.value)
748
- ].map(toProfSlug)),
749
- skillExpertise: new Set([
750
- ...(_h = (_g = (_f = resolved.definition) == null ? void 0 : _f.skills) == null ? void 0 : _g.expertise) != null ? _h : [],
751
- ...chosen.expertise,
752
- ...effectGrants.skills.filter((g) => g.expertise).map((g) => g.value)
753
- ].map(toProfSlug))
754
- };
755
- const classes = [];
756
- resolved.classes.forEach((c, classIndex) => {
757
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o;
758
- if (!c.entity) return;
759
- const entity = c.entity;
760
- const ownerBare = bareEntitySlug(entity.slug);
761
- const byLevel = /* @__PURE__ */ new Map();
762
- const push = (lvl, item) => {
763
- var _a3;
764
- const arr = (_a3 = byLevel.get(lvl)) != null ? _a3 : [];
765
- arr.push(item);
766
- byLevel.set(lvl, arr);
767
- };
768
- const readAt = (lvl) => (id) => {
769
- var _a3;
770
- return (_a3 = c.choices[lvl]) == null ? void 0 : _a3[id];
771
- };
772
- let legacyAsiFeat;
773
- const legacyAsiReader = (choice, lvl) => {
774
- const alloc = convertibleLegacyAsi(c.choices[lvl]);
775
- if (!alloc) return null;
776
- const flat = flattenAsiOrFeat(choice);
777
- if (flat.kind !== "select-entity" || flat.entity_type !== "feat" || flat.from || flat.where) return null;
778
- if (legacyAsiFeat === void 0) legacyAsiFeat = resolveLegacyAsiFeat(ctx.registry, entity);
779
- const asi = legacyAsiFeat;
780
- if (!asi) return null;
781
- const raw = readAt(lvl);
782
- const childKey = `feat:${asi.childId}`;
783
- return (id) => id === "feat" ? asi.slug : id === childKey ? alloc : raw(id);
784
- };
785
- const featProgressions = [...(_a2 = entity.feat_progression) != null ? _a2 : [], ...(_c2 = (_b2 = c.subclass) == null ? void 0 : _b2.feat_progression) != null ? _c2 : []];
786
- const suppressedFeatureTypes = /* @__PURE__ */ new Set();
787
- for (const decl of [...(_d2 = entity.selection_pools) != null ? _d2 : [], ...(_f2 = (_e2 = c.subclass) == null ? void 0 : _e2.selection_pools) != null ? _f2 : []]) {
788
- const rp = resolved.pools.find((p) => p.classIndex === classIndex && p.id === decl.id);
789
- if (rp && rp.count >= 1) suppressedFeatureTypes.add(decl.source.where.feature_type);
790
- }
791
- for (const entry of featProgressions) {
792
- const category = featProgressionCategory(entry.category);
793
- const ft = category ? FEATURE_TYPE_FOR_CATEGORY[category] : void 0;
794
- if (ft) suppressedFeatureTypes.add(ft);
795
- }
796
- if (classIndex === 0 && ((_h2 = (_g2 = entity.skill_choices) == null ? void 0 : _g2.from) == null ? void 0 : _h2.length)) {
797
- const skillChoice = {
798
- kind: "select-proficiency",
799
- id: "skills",
800
- label: "Skill Proficiencies",
801
- count: entity.skill_choices.count,
802
- domain: "skill",
803
- from: entity.skill_choices.from
804
- };
805
- push(1, buildItem(
806
- skillChoice,
807
- { kind: "class", slug: entity.slug, level: 1 },
808
- 1,
809
- "Proficiencies",
810
- readAt(1),
811
- ctx,
812
- ownerBare,
813
- effective
814
- ));
815
- }
816
- if (classIndex === 0) {
817
- for (const ch of [...(_i2 = entity.choices) != null ? _i2 : [], ...classToolPicks(entity).decisions]) {
818
- push(1, buildItem(
819
- ch,
820
- { kind: "class", slug: entity.slug, level: 1 },
821
- 1,
822
- "Proficiencies",
823
- readAt(1),
824
- ctx,
825
- ownerBare,
826
- effective
827
- ));
828
- }
829
- }
830
- if (classIndex === 0) {
831
- for (const ch of equipmentDecisions(entity.starting_equipment, entity.slug)) {
832
- push(1, buildItem(
833
- ch,
834
- { kind: "class", slug: entity.slug, level: 1 },
835
- 1,
836
- "Starting Equipment",
837
- readAt(1),
838
- ctx,
839
- ownerBare,
840
- effective
841
- ));
842
- }
843
- }
844
- let sawAuthoredSubclass = false;
845
- const staged = [];
846
- const authoredRank = (kind, level, feature) => {
847
- var _a3, _b3, _c3;
848
- const at = (_c3 = (_b3 = (_a3 = kind === "class" ? entity : c.subclass) == null ? void 0 : _a3.features_by_level) == null ? void 0 : _b3[level]) != null ? _c3 : [];
849
- const index = at.findIndex((f) => feature.id ? f.id === feature.id : f.name === feature.name);
850
- return (kind === "class" ? 0 : 1) * 1e6 + (index < 0 ? 999999 : index);
851
- };
852
- for (const rf of resolved.features) {
853
- const src = rf.source;
854
- if (src.kind !== "class" && src.kind !== "subclass") continue;
855
- const belongs = src.kind === "class" ? src.slug === entity.slug : c.subclass != null && src.slug === c.subclass.slug;
856
- if (!belongs) continue;
857
- const lvl = src.level;
858
- const stage = (atLvl, item) => {
859
- staged.push({ level: atLvl, item, rank: authoredRank(src.kind, atLvl, rf.feature), seq: staged.length });
860
- };
861
- const emitChoices = (list, atLvl, name, description) => {
862
- var _a3, _b3;
863
- for (const ch of list) {
864
- if (ch.kind === "select-entity" && ch.entity_type === "subclass") {
865
- sawAuthoredSubclass = true;
866
- stage(atLvl, buildSubclassItem(ch, src, atLvl, name, c, ctx, ownerBare, description));
867
- continue;
868
- }
869
- let emitted = ch;
870
- if (ch.kind === "select-entity") {
871
- const columns = countColumnsFor(ch.id);
872
- const fromTable = columns ? readTableColumn(entity.table, c.level, columns) : null;
873
- if (fromTable != null) emitted = { ...ch, count: Math.max((_a3 = ch.count) != null ? _a3 : 1, fromTable) };
874
- }
875
- stage(atLvl, buildItem(
876
- emitted,
877
- src,
878
- atLvl,
879
- name,
880
- (_b3 = legacyAsiReader(emitted, atLvl)) != null ? _b3 : readAt(atLvl),
881
- ctx,
882
- ownerBare,
883
- effective,
884
- { description }
885
- ));
886
- }
887
- };
888
- const informationalItem = (atLvl, name, description) => {
889
- var _a3, _b3;
890
- return {
891
- key: (_a3 = rf.feature.id) != null ? _a3 : name,
892
- source: src,
893
- level: atLvl,
894
- featureName: name,
895
- description,
896
- choice: { kind: "select-inline", id: (_b3 = rf.feature.id) != null ? _b3 : name, options: [{ value: "_", label: "_" }] },
897
- options: [],
898
- selected: void 0,
899
- status: "informational",
900
- satisfied: false
901
- };
902
- };
903
- const emitCopy = (copy) => {
904
- let list = copy.choices;
905
- if (!(list == null ? void 0 : list.length)) {
906
- const recognized = recognizeDecision({ id: rf.feature.id, name: copy.name, description: copy.description });
907
- if (recognized === "informational") {
908
- stage(copy.level, informationalItem(copy.level, copy.name, copy.prose));
909
- return;
910
- }
911
- list = recognized != null ? recognized : void 0;
912
- if (list == null ? void 0 : list.length) {
913
- list = list.filter((ch) => {
914
- var _a3;
915
- if (ch.kind !== "select-entity") return true;
916
- const ft = (_a3 = ch.where) == null ? void 0 : _a3.feature_type;
917
- return !(ft !== void 0 && suppressedFeatureTypes.has(ft));
918
- });
919
- }
920
- }
921
- if (!(list == null ? void 0 : list.length)) {
922
- if (copy.prose) stage(copy.level, informationalItem(copy.level, copy.name, copy.prose));
923
- return;
924
- }
925
- emitChoices(list, copy.level, copy.name, copy.description);
926
- };
927
- for (const copy of (_j2 = rf.foldedFrom) != null ? _j2 : []) emitCopy({ ...copy, prose: copy.description });
928
- emitCopy({
929
- level: lvl,
930
- name: rf.feature.name,
931
- description: rf.feature.description,
932
- // The card prose: the description, else the entries joined. `||`, not `??`, so an EMPTY description
933
- // falls through to the entries the way this branch's own guard always did.
934
- prose: rf.feature.description || (((_k2 = rf.feature.entries) == null ? void 0 : _k2.length) ? rf.feature.entries.join("\n\n") : void 0),
935
- choices: rf.feature.choices
936
- });
937
- }
938
- staged.sort((a, b) => a.rank - b.rank || a.seq - b.seq);
939
- for (const s of staged) push(s.level, s.item);
940
- const subclassLevel = (_l2 = entity.subclass_level) != null ? _l2 : null;
941
- if (subclassLevel != null && subclassLevel <= c.level && !sawAuthoredSubclass) {
942
- const featureName = (_m2 = entity.subclass_feature_name) != null ? _m2 : "Subclass";
943
- const synthChoice = {
944
- kind: "select-entity",
945
- id: "subclass",
946
- label: featureName,
947
- count: 1,
948
- entity_type: "subclass",
949
- where: { parent_class: "self" }
950
- };
951
- push(subclassLevel, buildSubclassItem(
952
- synthChoice,
953
- { kind: "class", slug: entity.slug, level: subclassLevel },
954
- subclassLevel,
955
- featureName,
956
- c,
957
- ctx,
958
- ownerBare
959
- ));
960
- }
961
- for (const pool of resolved.pools) {
962
- if (pool.classIndex !== classIndex || pool.count < 1) continue;
963
- const stranded = strandedPicks(pool);
964
- const strandedSlugs = new Set(stranded.map((e) => e.slug));
965
- const synth = {
966
- kind: "select-entity",
967
- id: pool.id,
968
- label: pool.label,
969
- count: pool.count,
970
- entity_type: "optional-feature",
971
- from: [...pool.available.map((e) => e.slug), ...stranded.map((e) => e.slug)]
972
- };
973
- const item = buildItem(
974
- synth,
975
- { kind: "class", slug: entity.slug, level: pool.anchorLevel },
976
- pool.anchorLevel,
977
- pool.label,
978
- () => pool.selected.map((e) => e.key),
979
- ctx,
980
- ownerBare,
981
- effective
982
- );
983
- item.pool = { id: pool.id, anchorLevel: pool.anchorLevel };
984
- const repeatables = pool.available.filter((e) => e.entity.repeatable === true);
985
- if (repeatables.length > 0) {
986
- item.repeatable = repeatables.map((e) => {
987
- var _a3, _b3;
988
- return {
989
- noteSlug: e.slug,
990
- itemChoice: (_a3 = e.entity.item_choice) != null ? _a3 : "learn",
991
- rows: resolveOptionRows(e.entity, ctx.registry, { edition: resolved.definition.edition, isEntityVisible: (_b3 = ctx.isEntityVisible) == null ? void 0 : _b3.bind(ctx) })
992
- };
993
- });
994
- }
995
- for (const o of item.options) if (strandedSlugs.has(o.value)) o.stranded = true;
996
- const memberChildren = [];
997
- for (const entry of pool.selected) {
998
- for (const ch of memberChoices(entry.entity)) {
999
- const child = buildItem(
1000
- ch,
1001
- { kind: "class", slug: entity.slug, level: pool.anchorLevel },
1002
- pool.anchorLevel,
1003
- entry.entity.name,
1004
- readAt(pool.anchorLevel),
1005
- ctx,
1006
- ownerBare,
1007
- effective,
1008
- { keyPrefix: `${pool.id}:${entry.key}:` }
1009
- );
1010
- child.parentLabel = entry.entity.name;
1011
- memberChildren.push(child);
1012
- }
1013
- }
1014
- if (memberChildren.length) {
1015
- item.children = memberChildren;
1016
- if (item.status === "resolved" && memberChildren.some((c2) => c2.status !== "resolved")) item.status = "partial";
1017
- }
1018
- push(pool.anchorLevel, item);
1019
- }
1020
- for (const entry of featProgressions) {
1021
- const category = featProgressionCategory(entry.category);
1022
- if (!category) {
1023
- warnOnce(
1024
- `feat-progression-category:${entity.slug}:${entry.name}`,
1025
- `Archivist: feat_progression "${entry.name}" on "${entity.slug}" carries no category this engine maps (${((_n2 = entry.category) != null ? _n2 : []).join(", ")}); no decision is offered`
1026
- );
1027
- continue;
1028
- }
1029
- const progression = entry.progression;
1030
- if (Array.isArray(progression)) continue;
1031
- for (const key of Object.keys(progression)) {
1032
- const lvl = Number.parseInt(key, 10);
1033
- if (!Number.isInteger(lvl) || String(lvl) !== key) continue;
1034
- if (lvl > c.level) continue;
1035
- if (((_o = byLevel.get(lvl)) != null ? _o : []).some((i) => i.key === "feat")) {
1036
- warnOnce(
1037
- `feat-progression-collision:${entity.slug}:${lvl}`,
1038
- `Archivist: "${entry.name}" on "${entity.slug}" would add a second feat pick at level ${lvl}, where one already exists; skipping`
1039
- );
1040
- continue;
1041
- }
1042
- const progressionChoice = {
1043
- kind: "select-entity",
1044
- id: "feat",
1045
- label: entry.name,
1046
- count: 1,
1047
- entity_type: "feat",
1048
- where: { category }
1049
- };
1050
- push(lvl, buildItem(
1051
- progressionChoice,
1052
- { kind: "class", slug: entity.slug, level: lvl },
1053
- lvl,
1054
- entry.name,
1055
- readAt(lvl),
1056
- ctx,
1057
- ownerBare,
1058
- effective
1059
- ));
1060
- }
1061
- }
1062
- const levels = [...byLevel.entries()].sort(([a], [b]) => a - b).map(([level, items]) => ({ level, items }));
1063
- classes.push({ classIndex, levels });
1064
- });
1065
- const origin = [];
1066
- const oc = (_i = resolved.definition.origin_choices) != null ? _i : {};
1067
- const originRead = (ns) => (id) => oc[`${ns}:${id}`];
1068
- const pushOrigin = (choices, ns, source, featureName, ownerBare, description) => {
1069
- for (const ch of choices != null ? choices : []) {
1070
- origin.push(buildItem(
1071
- ch,
1072
- source,
1073
- 0,
1074
- featureName,
1075
- originRead(ns),
1076
- ctx,
1077
- ownerBare,
1078
- effective,
1079
- { description }
1080
- ));
1081
- }
1082
- };
1083
- if (resolved.race) {
1084
- const bare = bareEntitySlug(resolved.race.slug);
1085
- pushOrigin(
1086
- resolved.race.choices,
1087
- "race",
1088
- { kind: "race", slug: resolved.race.slug },
1089
- (_j = resolved.race.name) != null ? _j : "Race",
1090
- bare,
1091
- resolved.race.description
1092
- );
1093
- for (const t of (_k = resolved.race.traits) != null ? _k : []) {
1094
- pushOrigin(
1095
- t.choices,
1096
- "race",
1097
- { kind: "race", slug: resolved.race.slug },
1098
- t.name,
1099
- bare,
1100
- t.description
1101
- );
1102
- }
1103
- }
1104
- if (resolved.background) {
1105
- const bare = bareEntitySlug(resolved.background.slug);
1106
- pushOrigin(
1107
- [...(_l = resolved.background.choices) != null ? _l : [], ...backgroundToolPicks(resolved.background).decisions],
1108
- "background",
1109
- { kind: "background", slug: resolved.background.slug },
1110
- (_m = resolved.background.name) != null ? _m : "Background",
1111
- bare,
1112
- resolved.background.description
1113
- );
1114
- if (resolved.background.feature) {
1115
- pushOrigin(
1116
- resolved.background.feature.choices,
1117
- "background",
1118
- { kind: "background", slug: resolved.background.slug },
1119
- resolved.background.feature.name,
1120
- bare,
1121
- resolved.background.feature.description
1122
- );
1123
- }
1124
- if (resolved.background.origin_feat) {
1125
- const originFeat = resolveOriginFeat(
1126
- ctx.registry,
1127
- resolved.background.origin_feat,
1128
- resolved.background.slug
1129
- );
1130
- if (originFeat) {
1131
- const featSource = { kind: "feat", slug: originFeat.feat.slug };
1132
- const featBare = bareEntitySlug(originFeat.feat.slug);
1133
- for (const ch of (_n = originFeat.feat.choices) != null ? _n : []) {
1134
- origin.push(buildItem(
1135
- ch,
1136
- featSource,
1137
- 0,
1138
- originFeat.display,
1139
- originRead("background"),
1140
- ctx,
1141
- featBare,
1142
- effective,
1143
- { keyPrefix: "feat:" }
1144
- ));
1145
- }
1146
- }
1147
- }
1148
- for (const ch of equipmentDecisions(resolved.background.equipment, resolved.background.slug)) {
1149
- origin.push(buildItem(
1150
- ch,
1151
- { kind: "background", slug: resolved.background.slug },
1152
- 0,
1153
- "Starting Equipment",
1154
- originRead("background"),
1155
- ctx,
1156
- bare,
1157
- effective
1158
- ));
1159
- }
1160
- }
1161
- return { classes, origin };
1162
- }
1163
-
1164
- // src/pc/pc.resolver.ts
1165
- var SLUG_RE = /^\[\[(.+?)\]\]$/;
1166
- function stripSlug(ref) {
1167
- if (!ref) return null;
1168
- const m = ref.match(SLUG_RE);
1169
- return m ? m[1] : ref;
1170
- }
1171
- function resolveOriginFeat(entities, originFeatRef, ownerSlug) {
1172
- var _a, _b, _c;
1173
- if (!originFeatRef) return null;
1174
- const slug = wikilinkTailSlug(originFeatRef);
1175
- const inner = originFeatRef.replace(/^\[\[/, "").replace(/\]\]$/, "").trim();
1176
- const rawTail = (_b = (_a = inner.split("/").pop()) == null ? void 0 : _a.trim()) != null ? _b : "";
1177
- const base = rawTail.replace(/\s*\([^()]*\)\s*$/, "").trim();
1178
- const baseSlug = base && base !== rawTail ? wikilinkTailSlug(`[[${base}]]`) : null;
1179
- const baseInner = baseSlug ? inner.slice(0, inner.length - rawTail.length) + base : null;
1180
- const prefix = (ownerSlug == null ? void 0 : ownerSlug.includes("_")) ? ownerSlug.slice(0, ownerSlug.indexOf("_")) : null;
1181
- const feats = bucketOf(entities, "feat");
1182
- const byPath = (p) => feats.find((f) => f.filePath === `${p}.md` || f.filePath.endsWith(`/${p}.md`));
1183
- const sameCompendiumTail = (s) => prefix ? feats.find((f) => f.slug.startsWith(`${prefix}_feat_`) && f.slug.endsWith(`_${s}`)) : void 0;
1184
- const anyTail = (s) => feats.find((f) => f.slug.endsWith(`_${s}`));
1185
- const tiers = [
1186
- () => {
1187
- var _a2;
1188
- return (_a2 = feats.find((f) => f.slug === inner)) != null ? _a2 : feats.find((f) => f.slug === slug);
1189
- },
1190
- // 1 exact slug
1191
- () => byPath(inner),
1192
- // 2 PATH
1193
- () => baseInner ? byPath(baseInner) : void 0,
1194
- // 3 PATH, parenthetical stripped
1195
- () => sameCompendiumTail(slug),
1196
- // 4 same-compendium tail
1197
- () => baseSlug ? sameCompendiumTail(baseSlug) : void 0,
1198
- // 5 same-compendium tail, stripped
1199
- () => anyTail(slug),
1200
- // 6 any tail
1201
- () => baseSlug ? anyTail(baseSlug) : void 0
1202
- // 7 any tail, stripped
1203
- ];
1204
- let reg;
1205
- let hitTier = 0;
1206
- for (let i = 0; i < tiers.length && !reg; i++) {
1207
- reg = tiers[i]();
1208
- hitTier = i + 1;
1209
- }
1210
- if (!reg) return null;
1211
- const variantName = baseSlug && (hitTier === 3 || hitTier === 5 || hitTier === 7) ? rawTail : void 0;
1212
- const data = reg.data;
1213
- const feat = data.slug == null ? { ...data, slug: reg.slug } : data;
1214
- return { feat, display: (_c = variantName != null ? variantName : feat.name) != null ? _c : slug };
1215
- }
1216
- var PCResolver = class {
1217
- constructor(entities) {
1218
- this.entities = entities;
1219
- }
1220
- /** Exposed so recalc() can apply equipment bonuses (Pass A / Pass B). */
1221
- get registry() {
1222
- return this.entities;
1223
- }
1224
- resolve(character) {
1225
- var _a, _b, _c, _d, _e, _f, _g, _h;
1226
- const warnings = [];
1227
- const lookup = (rawRef, type) => {
1228
- const slug = stripSlug(rawRef);
1229
- if (!slug) return null;
1230
- const reg = this.entities.getByTypeAndSlug(type, slug);
1231
- if (!reg) {
1232
- warnings.push(`Slug [[${slug}]] not found in compendium as ${type}.`);
1233
- return null;
1234
- }
1235
- const data = reg.data;
1236
- return data.slug == null ? { ...data, slug: reg.slug } : data;
1237
- };
1238
- const race = lookup(character.race, "race");
1239
- const background = lookup(character.background, "background");
1240
- const classes = character.class.map((c) => ({
1241
- entity: lookup(c.name, "class"),
1242
- level: c.level,
1243
- subclass: lookup(c.subclass, "subclass"),
1244
- choices: c.choices
1245
- }));
1246
- const memberSites = poolMemberSites(classes, this.entities);
1247
- const classSlugOf = (i) => {
1248
- var _a2, _b2, _c2, _d2, _e2;
1249
- return (_e2 = (_b2 = (_a2 = classes[i]) == null ? void 0 : _a2.entity) == null ? void 0 : _b2.slug) != null ? _e2 : stripSlug((_d2 = (_c2 = character.class[i]) == null ? void 0 : _c2.name) != null ? _d2 : null);
1250
- };
1251
- const featSites = featPickSites(character.class, memberSites, classSlugOf);
1252
- const feats = [];
1253
- const featVia = /* @__PURE__ */ new Map();
1254
- for (const site of featSites) {
1255
- const f = lookup(`[[${site.slug}]]`, "feat");
1256
- if (!f) continue;
1257
- if (!feats.some((x) => x.slug === f.slug)) feats.push(f);
1258
- if (site.via && !featVia.has(f.slug)) featVia.set(f.slug, site.via);
1259
- }
1260
- const originFeat = (background == null ? void 0 : background.origin_feat) ? resolveOriginFeat(this.entities, background.origin_feat, background.slug) : null;
1261
- const originFeatSlug = originFeat == null ? void 0 : originFeat.feat.slug;
1262
- if (originFeat && !feats.some((f) => f.slug === originFeat.feat.slug)) {
1263
- feats.push(originFeat.feat);
1264
- }
1265
- if (originFeat && background && !featVia.has(originFeat.feat.slug)) {
1266
- featVia.set(originFeat.feat.slug, { kind: "background", slug: background.slug });
1267
- }
1268
- const raceFeats = [];
1269
- for (const site of raceFeatSites(race, character.origin_choices)) {
1270
- const f = lookup(`[[${site.slug}]]`, "feat");
1271
- if (!f) continue;
1272
- raceFeats.push({ feat: f, read: site.read });
1273
- if (!feats.some((x) => x.slug === f.slug)) feats.push(f);
1274
- if (!featVia.has(f.slug)) featVia.set(f.slug, site.via);
1275
- }
1276
- const totalLevel = classes.reduce((sum, c) => sum + c.level, 0);
1277
- const features = collectResolvedFeatures(race, classes, background, feats, featVia);
1278
- const extraFeatures = collectChosenGrantedFeatures(character, classes, this.entities, race, background, memberSites);
1279
- features.push(...extraFeatures);
1280
- features.push(...collectAdditionalFeatures(character, this.entities, warnings));
1281
- const casters = [];
1282
- classes.forEach((c, i) => {
1283
- const profile = c.entity ? resolveSpellcasting(c) : null;
1284
- const classSlug = profile ? stripSlug(character.class[i].name) : null;
1285
- if (profile && classSlug != null) casters.push({ classSlug, spellList: profile.spellList });
1286
- });
1287
- const spells = [];
1288
- for (const raw of (_a = character.spells.known) != null ? _a : []) {
1289
- const n = normalizeKnownSpell(raw);
1290
- const reg = this.entities.getByTypeAndSlug("spell", n.slug);
1291
- if (!reg) {
1292
- warnings.push(`Spell [[${n.slug}]] not found in compendium.`);
1293
- continue;
1294
- }
1295
- const entity = mirrorSpellShapes(reg.data);
1296
- const isCantrip = ((_b = entity.level) != null ? _b : 0) === 0;
1297
- const classSlug = (_c = n.classSlug) != null ? _c : attributeUnclassedSpell(entity.classes, casters, this.entities);
1298
- const prep = isCantrip || n.alwaysPrepared ? true : (_d = n.preparedFlag) != null ? _d : false;
1299
- spells.push({ entity, slug: n.slug, classSlug, source: n.source, prepared: prep, alwaysPrepared: n.alwaysPrepared, persisted: true });
1300
- }
1301
- const oc = (_e = character.origin_choices) != null ? _e : {};
1302
- if (originFeat) {
1303
- const read = (childId) => oc[`background:feat:${childId}`];
1304
- spells.push(...collectFeatGrantedSpells(originFeat.feat, read, this.entities, warnings));
1305
- }
1306
- for (const rf of raceFeats) spells.push(...collectFeatGrantedSpells(rf.feat, rf.read, this.entities, warnings));
1307
- for (const site of featSites) {
1308
- const reg = this.entities.getByTypeAndSlug("feat", site.slug);
1309
- if (!reg) continue;
1310
- const feat = reg.data;
1311
- spells.push(...collectFeatGrantedSpells(feat, site.read, this.entities, warnings));
1312
- }
1313
- for (const site of memberSites) {
1314
- const classSlug = stripSlug((_g = (_f = character.class[site.classIndex]) == null ? void 0 : _f.name) != null ? _g : null);
1315
- for (const ch of site.choices) {
1316
- if (ch.kind !== "select-entity" || ch.entity_type !== "spell" || isTargetChoice(ch)) continue;
1317
- const v = site.read(ch.id);
1318
- for (const ref of Array.isArray(v) ? v : typeof v === "string" ? [v] : []) {
1319
- const slug = typeof ref === "string" ? stripSlug(ref) : null;
1320
- if (!slug) continue;
1321
- const reg = this.entities.getByTypeAndSlug("spell", slug);
1322
- if (!reg) {
1323
- warnings.push(`Spell [[${slug}]] not found in compendium.`);
1324
- continue;
1325
- }
1326
- const entity = mirrorSpellShapes(reg.data);
1327
- spells.push({ entity, slug, classSlug, source: "class", prepared: true, alwaysPrepared: true });
1328
- }
1329
- }
1330
- }
1331
- const ownSpellcastingAbility = (_h = classes.map((c) => {
1332
- if (!c.entity) return null;
1333
- const p = resolveSpellcasting(c);
1334
- return p ? effectiveSpellcastingAbility(c.entity.slug, p.ability, character.overrides) : null;
1335
- }).find((a) => a != null)) != null ? _h : null;
1336
- spells.push(...collectItemGrantedSpells(character, ownSpellcastingAbility, this.entities, warnings));
1337
- const chosenMasteries = collectChosenWeaponMasteries(character);
1338
- if (chosenMasteries.full.length > 0) {
1339
- const target = features.find(
1340
- (rf) => {
1341
- var _a2;
1342
- return rf.feature.id === "weapon-mastery" || ((_a2 = rf.feature.choices) == null ? void 0 : _a2.some(
1343
- (ch) => ch.kind === "select-entity" && ch.id === "weapon-mastery" && ch.entity_type === "weapon"
1344
- ));
1345
- }
1346
- );
1347
- if (target) {
1348
- const names = chosenMasteries.full.map(
1349
- (fullSlug) => {
1350
- var _a2, _b2;
1351
- return (_b2 = (_a2 = this.entities.getByTypeAndSlug("weapon", fullSlug)) == null ? void 0 : _a2.name) != null ? _b2 : fullSlug;
1352
- }
1353
- );
1354
- const entry = { label: "Mastered weapons", description: names.join(", ") };
1355
- target.chosenInline = target.chosenInline ? [...target.chosenInline, entry] : [entry];
1356
- }
1357
- }
1358
- const featureResources = resolveFeatureResources(features);
1359
- const resolvedCharacter = {
1360
- definition: character,
1361
- race,
1362
- classes,
1363
- background,
1364
- feats,
1365
- ...originFeatSlug ? { originFeatSlug } : {},
1366
- totalLevel,
1367
- features,
1368
- spells: [],
1369
- pools: [],
1370
- resources: featureResources,
1371
- weaponMasteries: chosenMasteries.bare,
1372
- state: character.state
1373
- };
1374
- resolvedCharacter.pools = resolveAllPools(resolvedCharacter, this.entities, featureResources);
1375
- spells.push(...collectAdditionalSpells({
1376
- race,
1377
- feats,
1378
- classes,
1379
- totalLevel,
1380
- ownAbility: ownSpellcastingAbility,
1381
- alreadyCollected: spells,
1382
- entities: this.entities,
1383
- warnings,
1384
- // SRD-G T4: the race's lineage and spellcasting-ability picks select and qualify its spell blocks.
1385
- raceChoice: (id) => oc[`race:${id}`],
1386
- pools: resolvedCharacter.pools
1387
- }));
1388
- resolvedCharacter.spells = dedupeResolvedSpells(spells);
1389
- resolvedCharacter.resources = resolveResourceIndex(resolvedCharacter);
1390
- resolvedCharacter.features = bindFeatureConsumers(resolvedCharacter.features, resolvedCharacter.resources, classes);
1391
- const infusions = buildInfusionContext(character, resolvedCharacter, this.entities);
1392
- if (infusions) resolvedCharacter.infusions = infusions;
1393
- return { character: resolvedCharacter, warnings };
1394
- }
1395
- };
1396
- function collectChosenWeaponMasteries(character) {
1397
- var _a, _b;
1398
- const full = /* @__PURE__ */ new Set();
1399
- for (const cls of (_a = character.class) != null ? _a : []) {
1400
- for (const lvl of Object.values((_b = cls.choices) != null ? _b : {})) {
1401
- const pick = lvl["weapon-mastery"];
1402
- if (Array.isArray(pick)) {
1403
- for (const s of pick) if (typeof s === "string") full.add(s);
1404
- }
1405
- }
1406
- }
1407
- return { full: [...full], bare: [...new Set([...full].map(bareEntitySlug))] };
1408
- }
1409
- function collectFeatPicks(character) {
1410
- const picks = /* @__PURE__ */ new Map();
1411
- for (const site of featPickSites(character.class, [], () => null)) {
1412
- if (!picks.has(site.slug)) picks.set(site.slug, { slug: site.slug, classIndex: site.classIndex, level: site.level });
1413
- }
1414
- return [...picks.values()];
1415
- }
1416
- function collectFeatGrantedSpells(feat, read, entities, warnings) {
1417
- var _a;
1418
- const ability = readChosenSpellAbility(read);
1419
- const slugs = [];
1420
- collectSpellPickSlugs(feat.choices, read, slugs);
1421
- const out = [];
1422
- for (const rawSlug of slugs) {
1423
- const slug = (_a = stripSlug(rawSlug)) != null ? _a : rawSlug;
1424
- const reg = entities.getByTypeAndSlug("spell", slug);
1425
- if (!reg) {
1426
- warnings.push(`Feat spell [[${slug}]] not found in compendium.`);
1427
- continue;
1428
- }
1429
- const entity = mirrorSpellShapes(reg.data);
1430
- out.push({ entity, slug, classSlug: null, source: "feat", prepared: true, alwaysPrepared: true, ability });
1431
- }
1432
- return out;
1433
- }
1434
- function collectItemGrantedSpells(character, ownAbility, entities, warnings) {
1435
- var _a;
1436
- const out = [];
1437
- ((_a = character.equipment) != null ? _a : []).forEach((entry, entryIndex) => {
1438
- var _a2, _b, _c, _d, _e, _f;
1439
- const spellRef = (_a2 = entry.overrides) == null ? void 0 : _a2.spell;
1440
- if (!spellRef) return;
1441
- const { entity: itemEntity } = resolveEntityForEntry(entry.item, entities);
1442
- const scrollLevel = isItemEntity(itemEntity) ? itemEntity.scroll_level : void 0;
1443
- if (scrollLevel == null) return;
1444
- const slug = (_b = stripSlug(spellRef)) != null ? _b : spellRef;
1445
- const reg = entities.getByTypeAndSlug("spell", slug);
1446
- if (!reg) {
1447
- warnings.push(`Scroll spell [[${slug}]] not found in compendium.`);
1448
- return;
1449
- }
1450
- const entity = mirrorSpellShapes(reg.data);
1451
- const ability = (_f = (_d = (_c = entry.overrides) == null ? void 0 : _c.spell_ability) != null ? _d : ownAbility) != null ? _f : (_e = character.overrides) == null ? void 0 : _e.spellcasting_ability;
1452
- out.push({ entity, slug, classSlug: null, source: "item", prepared: true, alwaysPrepared: true, ability, entryIndex });
1453
- });
1454
- return out;
1455
- }
1456
- function dedupeResolvedSpells(spells) {
1457
- const byKey = /* @__PURE__ */ new Map();
1458
- for (const s of spells) {
1459
- const key = s.source === "item" ? `${s.slug}#${s.entryIndex}` : s.atWill ? `${s.slug}#atwill` : s.slug;
1460
- const existing = byKey.get(key);
1461
- if (!existing) {
1462
- byKey.set(key, s);
1463
- continue;
1464
- }
1465
- if (existing.source === "feat" && s.source !== "feat") {
1466
- byKey.set(key, { ...s, alwaysPrepared: s.alwaysPrepared || existing.alwaysPrepared, prepared: s.prepared || existing.alwaysPrepared, ...existing.persisted || s.persisted ? { persisted: true } : {} });
1467
- } else if (s.alwaysPrepared && !existing.alwaysPrepared) {
1468
- byKey.set(key, { ...existing, alwaysPrepared: true, prepared: true });
1469
- }
1470
- }
1471
- return [...byKey.values()];
1472
- }
1473
- function readChosenSpellAbility(read) {
1474
- const pick = read("spellcasting-ability");
1475
- return typeof pick === "string" && ABILITY_KEYS.includes(pick) ? pick : null;
1476
- }
1477
- function collectSpellPickSlugs(choices, read, out) {
1478
- for (const ch of choices != null ? choices : []) {
1479
- if (ch.kind === "select-entity" && ch.entity_type === "spell") {
1480
- const sel = read(ch.id);
1481
- const picks = Array.isArray(sel) ? sel : typeof sel === "string" ? [sel] : [];
1482
- for (const p of picks) if (typeof p === "string" && p.length > 0) out.push(p);
1483
- } else if (ch.kind === "select-inline") {
1484
- const sel = read(ch.id);
1485
- const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
1486
- if (branch == null ? void 0 : branch.choices) collectSpellPickSlugs(branch.choices, read, out);
1487
- }
1488
- }
1489
- }
1490
- function collectChosenGrantedFeatures(character, classes, registry, race = null, background = null, memberSites = []) {
1491
- var _a, _b, _c, _d;
1492
- const out = [];
1493
- for (const site of memberSites) {
1494
- const classSlug = (_b = (_a = classes[site.classIndex]) == null ? void 0 : _a.entity) == null ? void 0 : _b.slug;
1495
- if (!classSlug) continue;
1496
- const at = {};
1497
- const grants = site.choices.filter((ch) => !isTargetChoice(ch));
1498
- for (const ch of grants) at[ch.id] = site.read(ch.id);
1499
- walkChoiceGrants(grants, at, (granted, suppress) => {
1500
- out.push({ feature: granted, source: { kind: "class", slug: classSlug, level: site.level }, ...suppress ? { renderSuppressed: true } : {} });
1501
- }, registry);
1502
- }
1503
- classes.forEach((c, i) => {
1504
- var _a2, _b2, _c2, _d2;
1505
- if (!c.entity) return;
1506
- const entity = c.entity;
1507
- const entry = character.class[i];
1508
- if (!entry) return;
1509
- for (const [lvlStr, atLevel] of Object.entries(entry.choices)) {
1510
- const lvl = Number(lvlStr);
1511
- if (!Number.isFinite(lvl) || lvl > entry.level) continue;
1512
- const features = (_b2 = ((_a2 = entity.features_by_level) != null ? _a2 : {})[lvl]) != null ? _b2 : [];
1513
- const subFeatures = c.subclass ? (_d2 = ((_c2 = c.subclass.features_by_level) != null ? _c2 : {})[lvl]) != null ? _d2 : [] : [];
1514
- for (const feature of [...features, ...subFeatures]) {
1515
- walkChoiceGrants(feature.choices, atLevel, (granted, suppress) => {
1516
- out.push({
1517
- feature: granted,
1518
- source: { kind: "class", slug: entity.slug, level: lvl },
1519
- ...suppress ? { renderSuppressed: true } : {}
1520
- });
1521
- }, registry);
1522
- }
1523
- }
1524
- });
1525
- const oc = (_c = character.origin_choices) != null ? _c : {};
1526
- const originAt = (ns) => {
1527
- const at = {};
1528
- for (const [key, val] of Object.entries(oc)) {
1529
- if (key.startsWith(`${ns}:`)) at[key.slice(ns.length + 1)] = val;
1530
- }
1531
- return at;
1532
- };
1533
- if (race) {
1534
- const atRace = originAt("race");
1535
- const emitRace = (granted, suppress) => {
1536
- out.push({
1537
- feature: granted,
1538
- source: { kind: "race", slug: race.slug },
1539
- ...suppress ? { renderSuppressed: true } : {}
1540
- });
1541
- };
1542
- walkChoiceGrants(race.choices, atRace, emitRace, registry);
1543
- for (const trait of (_d = race.traits) != null ? _d : []) {
1544
- walkChoiceGrants(trait.choices, atRace, emitRace, registry);
1545
- }
1546
- }
1547
- if (background) {
1548
- const atBg = originAt("background");
1549
- const emitBg = (granted, suppress) => {
1550
- out.push({
1551
- feature: granted,
1552
- source: { kind: "background", slug: background.slug },
1553
- ...suppress ? { renderSuppressed: true } : {}
1554
- });
1555
- };
1556
- walkChoiceGrants(background.choices, atBg, emitBg, registry);
1557
- if (background.feature) {
1558
- walkChoiceGrants(background.feature.choices, atBg, emitBg, registry);
1559
- }
1560
- }
1561
- return out;
1562
- }
1563
- function collectAdditionalFeatures(character, entities, warnings) {
1564
- var _a, _b, _c, _d, _e, _f, _g, _h;
1565
- const out = [];
1566
- for (const entry of (_a = character.additional_features) != null ? _a : []) {
1567
- const slug = (_b = stripSlug(entry)) != null ? _b : entry;
1568
- const reg = entities.getByTypeAndSlug("optional-feature", slug);
1569
- if (!reg) {
1570
- warnings.push(`Granted feature [[${slug}]] not found in compendium as optional-feature.`);
1571
- continue;
1572
- }
1573
- const d = reg.data;
1574
- const feature = {
1575
- id: (_c = d.slug) != null ? _c : slug,
1576
- name: (_d = d.name) != null ? _d : slug,
1577
- description: d.description,
1578
- ...((_e = d.effects) == null ? void 0 : _e.length) ? { effects: d.effects } : {},
1579
- ...d.action_cost ? { action: d.action_cost } : {},
1580
- ...d.passive !== void 0 ? { passive: d.passive } : {},
1581
- ...d.activatable !== void 0 ? { activatable: d.activatable } : {},
1582
- ...d.duration ? { duration: d.duration } : {},
1583
- ...d.consumes ? { consumes: d.consumes } : {}
1584
- };
1585
- const uses = d.uses;
1586
- if (uses) {
1587
- const maxFormula = String(uses.max);
1588
- if (isValidMaxFormula(maxFormula)) {
1589
- feature.resources = [{
1590
- id: (_f = d.slug) != null ? _f : slug,
1591
- name: (_g = d.name) != null ? _g : slug,
1592
- max_formula: maxFormula,
1593
- reset: uses.recharge,
1594
- ...((_h = uses.recovery) == null ? void 0 : _h.length) ? { recovery: uses.recovery } : {},
1595
- // Presentation rides the resource, so the band and the tab read one object.
1596
- ...d.rendering_hint ? { rendering_hint: d.rendering_hint } : {},
1597
- ...d.surface ? { surface: d.surface } : {}
1598
- }];
1599
- } else {
1600
- warnings.push(`Granted feature "${slug}" has a prose uses.max (${JSON.stringify(uses.max)}); no tracker.`);
1601
- }
1602
- }
1603
- out.push({ feature, source: { kind: "campaign", slug } });
1604
- }
1605
- return out;
1606
- }
1607
- function walkChoiceGrants(choices, atLevel, emit, registry) {
1608
- var _a, _b, _c, _d, _e;
1609
- for (const ch of choices != null ? choices : []) {
1610
- const sel = atLevel[ch.id];
1611
- if (ch.kind === "select-entity" && ch.entity_type === "optional-feature") {
1612
- const slugs = Array.isArray(sel) ? sel : typeof sel === "string" ? [sel] : [];
1613
- for (const slug of slugs) {
1614
- const reg = registry.getByTypeAndSlug("optional-feature", (_a = stripSlug(String(slug))) != null ? _a : String(slug));
1615
- if (!reg) continue;
1616
- const d = reg.data;
1617
- emit({
1618
- id: (_b = d.slug) != null ? _b : String(slug),
1619
- name: (_c = d.name) != null ? _c : String(slug),
1620
- description: d.description,
1621
- effects: d.effects,
1622
- ...d.action_cost ? { action: d.action_cost } : {}
1623
- });
1624
- }
1625
- }
1626
- if (ch.kind === "select-inline") {
1627
- const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
1628
- if ((_d = branch == null ? void 0 : branch.effects) == null ? void 0 : _d.length) {
1629
- const wc = (_e = branch.choices) == null ? void 0 : _e.find(
1630
- (c) => c.kind === "select-entity" && c.entity_type === "weapon"
1631
- );
1632
- const picked = wc ? atLevel == null ? void 0 : atLevel[wc.id] : void 0;
1633
- const effects = branch.effects.map(
1634
- (e) => e.kind === "weapon-ability" && e.weapons === "chosen" && typeof picked === "string" ? { ...e, weapons: [bareEntitySlug(picked)] } : e
1635
- );
1636
- emit({ id: `${ch.id}-${branch.value}`, name: branch.label, description: branch.description, effects }, true);
1637
- }
1638
- if (branch == null ? void 0 : branch.choices) walkChoiceGrants(branch.choices, atLevel, emit, registry);
1639
- }
1640
- }
1641
- }
1642
- function resolveChosenInline(feature, atLevel) {
1643
- var _a;
1644
- if (!atLevel) return void 0;
1645
- const picks = [];
1646
- for (const ch of (_a = feature.choices) != null ? _a : []) {
1647
- if (ch.kind !== "select-inline") continue;
1648
- const sel = atLevel[ch.id];
1649
- if (typeof sel !== "string") continue;
1650
- const opt = ch.options.find((o) => o.value === sel);
1651
- if (!opt) continue;
1652
- picks.push({ label: opt.label, description: opt.description });
1653
- }
1654
- return picks.length ? picks : void 0;
1655
- }
1656
- function isAsiSlotFeature(feature) {
1657
- var _a, _b, _c, _d;
1658
- return feature.id === "ability-score-improvement" && !((_a = feature.effects) != null ? _a : []).some((e) => !(e.kind === "ability-score-increase" && e.abilities === "chosen")) && !((_b = feature.resources) == null ? void 0 : _b.length) && !feature.action && !((_c = feature.sub_features) == null ? void 0 : _c.length) && !((_d = feature.attacks) == null ? void 0 : _d.length);
1659
- }
1660
- function foldRepeated(list) {
1661
- const byId = /* @__PURE__ */ new Map();
1662
- for (const rf of list) {
1663
- const id = rf.feature.id;
1664
- if (!id || rf.buildOnly) continue;
1665
- const arr = byId.get(id);
1666
- if (arr) arr.push(rf);
1667
- else byId.set(id, [rf]);
1668
- }
1669
- const out = [];
1670
- for (const rf of list) {
1671
- if (!rf.feature.id || rf.buildOnly) {
1672
- out.push(rf);
1673
- continue;
1674
- }
1675
- const arr = byId.get(rf.feature.id);
1676
- if (!arr || arr.length === 1) {
1677
- out.push(rf);
1678
- continue;
1679
- }
1680
- const sorted = [...arr].sort((a, b) => a.source.level - b.source.level);
1681
- const top = sorted[sorted.length - 1];
1682
- if (rf !== top) continue;
1683
- const effects = sorted.flatMap((c) => {
1684
- var _a;
1685
- return (_a = c.feature.effects) != null ? _a : [];
1686
- });
1687
- const seen = /* @__PURE__ */ new Set();
1688
- const resources = sorted.flatMap((c) => {
1689
- var _a;
1690
- return ((_a = c.feature.resources) != null ? _a : []).filter((r) => !seen.has(r.id) && seen.add(r.id));
1691
- });
1692
- const chosenInline = sorted.flatMap((c) => c.chosenInline ? [c.chosenInline] : []);
1693
- const cardProse = (f) => {
1694
- var _a, _b;
1695
- return (_b = f.description) != null ? _b : ((_a = f.entries) == null ? void 0 : _a.length) ? f.entries.join("\n\n") : void 0;
1696
- };
1697
- const foldedFrom = sorted.slice(0, -1).map((c) => {
1698
- var _a;
1699
- return {
1700
- level: c.source.level,
1701
- name: c.feature.name,
1702
- ...cardProse(c.feature) ? { description: cardProse(c.feature) } : {},
1703
- ...((_a = c.feature.choices) == null ? void 0 : _a.length) ? { choices: c.feature.choices } : {}
1704
- };
1705
- });
1706
- out.push({
1707
- ...top,
1708
- feature: { ...top.feature, ...effects.length ? { effects } : {}, ...resources.length ? { resources } : {} },
1709
- ...chosenInline.length ? { chosenInline: chosenInline.flat() } : {},
1710
- ...foldedFrom.length ? { foldedFrom } : {}
1711
- });
1712
- }
1713
- return out;
1714
- }
1715
- function collectResolvedFeatures(race, classes, background, feats, featVia = /* @__PURE__ */ new Map()) {
1716
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1717
- const out = [];
1718
- for (const c of classes) {
1719
- if (!c.entity) continue;
1720
- const slug = c.entity.slug;
1721
- const byLevel = (_a = c.entity.features_by_level) != null ? _a : {};
1722
- const classFeatures = [];
1723
- const subclassFeatures = [];
1724
- for (const [lvlStr, feats0] of Object.entries(byLevel)) {
1725
- const lvl = parseInt(lvlStr, 10);
1726
- if (Number.isNaN(lvl) || lvl > c.level) continue;
1727
- for (const feat of feats0) {
1728
- const chosenInline = resolveChosenInline(feat, (_b = c.choices) == null ? void 0 : _b[lvl]);
1729
- const feature = withResolvedActionCost(feat);
1730
- classFeatures.push({
1731
- feature,
1732
- source: { kind: "class", slug, level: lvl },
1733
- ...chosenInline ? { chosenInline } : {},
1734
- ...isAsiSlotFeature(feature) ? { buildOnly: true } : {}
1735
- });
1736
- }
1737
- }
1738
- if (c.subclass) {
1739
- const sSlug = c.subclass.slug;
1740
- const sByLevel = (_c = c.subclass.features_by_level) != null ? _c : {};
1741
- for (const [lvlStr, feats0] of Object.entries(sByLevel)) {
1742
- const lvl = parseInt(lvlStr, 10);
1743
- if (Number.isNaN(lvl) || lvl > c.level) continue;
1744
- for (const feat of feats0) {
1745
- const chosenInline = resolveChosenInline(feat, (_d = c.choices) == null ? void 0 : _d[lvl]);
1746
- const feature = withResolvedActionCost(feat);
1747
- subclassFeatures.push({
1748
- feature,
1749
- source: { kind: "subclass", slug: sSlug, level: lvl },
1750
- ...chosenInline ? { chosenInline } : {},
1751
- ...isAsiSlotFeature(feature) ? { buildOnly: true } : {}
1752
- });
1753
- }
1754
- }
1755
- }
1756
- const foldedClass = foldRepeated(classFeatures);
1757
- const foldedSubclass = foldRepeated(subclassFeatures);
1758
- out.push(...foldedClass);
1759
- if ((_e = c.entity.resources) == null ? void 0 : _e.length) {
1760
- out.push({
1761
- feature: { name: c.entity.name, resources: c.entity.resources },
1762
- source: { kind: "class", slug, level: 1 }
1763
- });
1764
- }
1765
- out.push(...foldedSubclass);
1766
- if ((_g = (_f = c.subclass) == null ? void 0 : _f.resources) == null ? void 0 : _g.length) {
1767
- out.push({
1768
- feature: { name: c.subclass.name, resources: c.subclass.resources },
1769
- source: { kind: "subclass", slug: c.subclass.slug, level: 1 }
1770
- });
1771
- }
1772
- }
1773
- if (race) {
1774
- const traits = (_h = race.traits) != null ? _h : [];
1775
- for (const feat of traits) {
1776
- out.push({ feature: withResolvedActionCost(feat), source: { kind: "race", slug: race.slug } });
1777
- }
1778
- }
1779
- if (background) {
1780
- const bgFeature = background.feature;
1781
- if (bgFeature) {
1782
- out.push({ feature: withResolvedActionCost(bgFeature), source: { kind: "background", slug: background.slug } });
1783
- }
1784
- }
1785
- for (const feat of feats) {
1786
- const via = featVia.get(feat.slug);
1787
- const featSource = { kind: "feat", slug: feat.slug, ...via ? { via } : {} };
1788
- const bundled = (_i = feat.features) != null ? _i : [];
1789
- const entityEffects = (_j = feat.effects) != null ? _j : [];
1790
- if (bundled.length > 0) {
1791
- bundled.forEach((f, i) => {
1792
- var _a2, _b2;
1793
- const feature = i === 0 ? { ...f, action: (_a2 = f.action) != null ? _a2 : feat.action_cost, ...entityEffects.length > 0 ? { effects: [...(_b2 = f.effects) != null ? _b2 : [], ...entityEffects] } : {} } : f;
1794
- out.push({ feature, source: featSource });
1795
- });
1796
- } else {
1797
- const name = (_k = feat.name) != null ? _k : feat.slug;
1798
- const foldedDesc = [feat.description, ...(_l = feat.benefits) != null ? _l : []].filter(Boolean).join("\n\n") || void 0;
1799
- const buildOnly = ((_m = feat.choices) != null ? _m : []).some((c) => c.kind === "ability-points" && c.points >= 2) && !((_n = feat.effects) == null ? void 0 : _n.length) && !((_o = feat.resources) == null ? void 0 : _o.length) && bundled.length === 0;
1800
- out.push({
1801
- feature: {
1802
- name,
1803
- ...foldedDesc ? { description: foldedDesc } : {},
1804
- ...feat.resources ? { resources: feat.resources } : {},
1805
- // R4-G3a §10.2.3: a feat's ENTITY-level action cost (SRD 2024 Boon of the Night Spirit)
1806
- // reaches the synthesized feature, so the row routes off Passive onto its own economy.
1807
- ...feat.action_cost ? { action: feat.action_cost } : {},
1808
- ...entityEffects.length > 0 ? { effects: entityEffects } : {}
1809
- },
1810
- source: featSource,
1811
- ...buildOnly ? { buildOnly: true } : {}
1812
- });
1813
- }
1814
- }
1815
- return out;
1816
- }
1817
-
1818
- export {
1819
- stripSlug,
1820
- resolveOriginFeat,
1821
- PCResolver,
1822
- collectChosenWeaponMasteries,
1823
- collectFeatPicks,
1824
- collectFeatGrantedSpells,
1825
- collectItemGrantedSpells,
1826
- dedupeResolvedSpells,
1827
- collectChosenGrantedFeatures,
1828
- collectAdditionalFeatures,
1829
- collectResolvedFeatures,
1830
- collectProficiencyGrants,
1831
- __matchesFilterForTest,
1832
- __categoryToEntitySelectForTest,
1833
- collectChosenProficiencies,
1834
- computeEffectiveProficiencies,
1835
- computeSuppressedProficiencies,
1836
- collectChosenAbilityPoints,
1837
- buildDecisionLedger
1838
- };