@archivist-gg/dnd5e 0.3.19 → 0.3.26

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 (441) 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-2NUDWOFG.js +1 -0
  16. package/dist/chunk-3LWOVRLA.js +1 -0
  17. package/dist/chunk-3QQOATV3.js +1 -0
  18. package/dist/chunk-4E2GIWJE.js +1 -0
  19. package/dist/chunk-4GN3GYMP.js +1 -0
  20. package/dist/chunk-4IAMSRHD.js +1 -0
  21. package/dist/chunk-4JEF3CET.js +1 -0
  22. package/dist/chunk-4KVVAENP.js +1 -0
  23. package/dist/chunk-4SYAKWY4.js +1 -0
  24. package/dist/chunk-56JK6VCL.js +1 -0
  25. package/dist/chunk-5XDCM6YK.js +1 -0
  26. package/dist/chunk-63YJPWTM.js +1 -0
  27. package/dist/chunk-6R46KYGU.js +1 -0
  28. package/dist/chunk-6W253VHH.js +1 -0
  29. package/dist/chunk-72PRMZRD.js +1 -0
  30. package/dist/chunk-757KM22B.js +1 -0
  31. package/dist/chunk-7EL3GWWJ.js +1 -0
  32. package/dist/chunk-7FPQJDFD.js +1 -0
  33. package/dist/chunk-AINRPPLH.js +1 -0
  34. package/dist/chunk-BC52J4LA.js +1 -0
  35. package/dist/chunk-BCXGB4HP.js +1 -0
  36. package/dist/chunk-BREHZNTL.js +1 -0
  37. package/dist/chunk-BZ6BGGZS.js +1 -0
  38. package/dist/chunk-CAPYNIGK.js +1 -0
  39. package/dist/chunk-CCAVZANF.js +1 -0
  40. package/dist/chunk-CCFIINBA.js +1 -0
  41. package/dist/chunk-CEHL7PPC.js +1 -0
  42. package/dist/chunk-CMIEZQL4.js +1 -0
  43. package/dist/chunk-CNMHADNV.js +1 -0
  44. package/dist/chunk-CSTAQQGX.js +1 -0
  45. package/dist/chunk-DTB7YBMZ.js +1 -0
  46. package/dist/chunk-DVUXUIPV.js +1 -0
  47. package/dist/chunk-DZITM5AG.js +1 -0
  48. package/dist/chunk-E3MS4M3N.js +1 -0
  49. package/dist/chunk-E7KFJLDR.js +1 -0
  50. package/dist/chunk-EAARMPCW.js +1 -0
  51. package/dist/chunk-EPA24PVZ.js +1 -0
  52. package/dist/chunk-ETDMOGFO.js +1 -0
  53. package/dist/chunk-EVT7MGAC.js +1 -0
  54. package/dist/chunk-FOLHTMSC.js +1 -0
  55. package/dist/chunk-GCYUCIDN.js +1 -0
  56. package/dist/chunk-GD7WRCNH.js +1 -0
  57. package/dist/chunk-GGQDQSIF.js +1 -0
  58. package/dist/chunk-GIQLIBC7.js +1 -0
  59. package/dist/chunk-HX7WBOKR.js +1 -0
  60. package/dist/chunk-I26FHSI6.js +1 -0
  61. package/dist/chunk-IHPLT2ZT.js +1 -0
  62. package/dist/chunk-J3RP5C7L.js +1 -0
  63. package/dist/chunk-J5GL6FLP.js +1 -0
  64. package/dist/chunk-JXDX2DKF.js +1 -0
  65. package/dist/chunk-KEXSF3CH.js +1 -0
  66. package/dist/chunk-KM75CC6Q.js +1 -0
  67. package/dist/chunk-L2DXF7YS.js +1 -0
  68. package/dist/chunk-LHH5XSEA.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-MGGKZGLG.js +1 -0
  73. package/dist/chunk-NEMX7QGG.js +1 -0
  74. package/dist/chunk-NIWLD33X.js +1 -0
  75. package/dist/chunk-NU2Z7MTS.js +1 -0
  76. package/dist/chunk-NYPH7RQN.js +1 -0
  77. package/dist/chunk-NYTR6NJS.js +1 -0
  78. package/dist/chunk-O2QZ73GA.js +1 -0
  79. package/dist/chunk-O776WL7O.js +1 -0
  80. package/dist/chunk-ONCXJMJM.js +1 -0
  81. package/dist/chunk-OTRH62HY.js +1 -0
  82. package/dist/chunk-PFQPP77Q.js +1 -0
  83. package/dist/chunk-PKIMOVQG.js +1 -0
  84. package/dist/chunk-PZ3ZZ5H5.js +1 -0
  85. package/dist/chunk-PZ4L2EEG.js +1 -0
  86. package/dist/chunk-QMEKQTUT.js +1 -0
  87. package/dist/chunk-QVWT67WA.js +1 -0
  88. package/dist/chunk-RE5Z5RNK.js +1 -0
  89. package/dist/chunk-RHIEOYDX.js +1 -0
  90. package/dist/chunk-RQZCGXUZ.js +1 -0
  91. package/dist/chunk-S5UCI27C.js +1 -0
  92. package/dist/chunk-SEOASDO4.js +1 -0
  93. package/dist/chunk-SFK57JAA.js +1 -0
  94. package/dist/chunk-SU4MEZ5P.js +1 -0
  95. package/dist/chunk-T55DELVL.js +1 -0
  96. package/dist/chunk-TKIEPC6F.js +1 -0
  97. package/dist/chunk-UBUKCRZ3.js +1 -0
  98. package/dist/chunk-VA3ZWV7C.js +1 -0
  99. package/dist/chunk-VIP3FH2O.js +1 -0
  100. package/dist/chunk-VTQ4RWEG.js +1 -0
  101. package/dist/chunk-VVJXZZ4Z.js +1 -0
  102. package/dist/chunk-WAUNLUFQ.js +1 -0
  103. package/dist/chunk-X22SISGM.js +1 -0
  104. package/dist/chunk-XKJXT2PN.js +1 -0
  105. package/dist/chunk-XPF53K54.js +1 -0
  106. package/dist/chunk-YGH7S5ZF.js +1 -0
  107. package/dist/chunk-ZE46ADXS.js +1 -0
  108. package/dist/chunk-ZI3FEUX3.js +1 -0
  109. package/dist/chunk-ZS5BMNXC.js +1 -0
  110. package/dist/chunk-ZVL5FXXO.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 +4 -3
  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 +46 -4
  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 +5 -0
  182. package/dist/item/item.schema.js +1 -11
  183. package/dist/item/item.types.d.ts +5 -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 +44 -3
  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 +3 -28
  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 +6 -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 +19 -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 +27 -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 +19 -0
  228. package/dist/pc/pc.item-effects.js +1 -0
  229. package/dist/pc/pc.member-choices.d.ts +3 -66
  230. package/dist/pc/pc.member-choices.js +1 -39
  231. package/dist/pc/pc.parser.js +1 -58
  232. package/dist/pc/pc.pools.d.ts +7 -10
  233. package/dist/pc/pc.pools.js +1 -27
  234. package/dist/pc/pc.proficiencies.d.ts +0 -40
  235. package/dist/pc/pc.proficiencies.js +1 -156
  236. package/dist/pc/pc.proficiency-grants.d.ts +3 -27
  237. package/dist/pc/pc.proficiency-normalize.d.ts +0 -35
  238. package/dist/pc/pc.proficiency-normalize.js +1 -18
  239. package/dist/pc/pc.proficiency-query.d.ts +0 -13
  240. package/dist/pc/pc.proficiency-query.js +1 -27
  241. package/dist/pc/pc.recalc.d.ts +8 -131
  242. package/dist/pc/pc.recalc.js +1 -1042
  243. package/dist/pc/pc.resolver.d.ts +9 -107
  244. package/dist/pc/pc.resolver.js +1 -60
  245. package/dist/pc/pc.resource-seed.d.ts +0 -8
  246. package/dist/pc/pc.resource-seed.js +1 -42
  247. package/dist/pc/pc.resources.d.ts +1 -59
  248. package/dist/pc/pc.resources.js +1 -23
  249. package/dist/pc/pc.rest.d.ts +1 -20
  250. package/dist/pc/pc.rest.js +1 -231
  251. package/dist/pc/pc.schema.d.ts +20 -2
  252. package/dist/pc/pc.schema.js +1 -9
  253. package/dist/pc/pc.slotting.d.ts +0 -29
  254. package/dist/pc/pc.slotting.js +1 -28
  255. package/dist/pc/pc.speeds.d.ts +36 -0
  256. package/dist/pc/pc.spell-scope.d.ts +0 -16
  257. package/dist/pc/pc.spellcasting.d.ts +0 -70
  258. package/dist/pc/pc.spellcasting.js +1 -28
  259. package/dist/pc/pc.table-column.d.ts +3 -22
  260. package/dist/pc/pc.table-column.js +1 -18
  261. package/dist/pc/pc.tool-picks.d.ts +0 -27
  262. package/dist/pc/pc.tool-picks.js +1 -18
  263. package/dist/pc/pc.types.d.ts +59 -374
  264. package/dist/pc/pc.weapon-grant.d.ts +0 -6
  265. package/dist/pc/pool-layout.d.ts +0 -39
  266. package/dist/pc/pool-layout.js +1 -18
  267. package/dist/pc/resource-equivalents.d.ts +2 -40
  268. package/dist/pc/roll-scope.js +1 -8
  269. package/dist/pc/roll-tag-labels.d.ts +0 -32
  270. package/dist/pc/roll-tag-labels.js +1 -17
  271. package/dist/pc/spell-source.d.ts +0 -11
  272. package/dist/pc/spell-source.js +1 -8
  273. package/dist/race/race.codec.d.ts +0 -6
  274. package/dist/race/race.codec.js +1 -15
  275. package/dist/race/race.parser.js +1 -14
  276. package/dist/race/race.schema.d.ts +0 -8
  277. package/dist/race/race.schema.js +1 -14
  278. package/dist/race/race.structural.d.ts +0 -6
  279. package/dist/race/race.structural.js +1 -6
  280. package/dist/race/race.types.d.ts +0 -8
  281. package/dist/schemas/attack-schema.d.ts +5 -0
  282. package/dist/schemas/caster-type-schema.d.ts +1 -6
  283. package/dist/schemas/caster-type-schema.js +1 -6
  284. package/dist/schemas/choice-schema.js +1 -7
  285. package/dist/schemas/duration-schema.d.ts +0 -2
  286. package/dist/schemas/duration-schema.js +1 -6
  287. package/dist/schemas/entity-extras-schema.d.ts +0 -30
  288. package/dist/schemas/entity-extras-schema.js +1 -10
  289. package/dist/schemas/equipment-grant-schema.d.ts +0 -2
  290. package/dist/schemas/equipment-grant-schema.js +1 -12
  291. package/dist/schemas/feature-alias.d.ts +0 -27
  292. package/dist/schemas/feature-effect-schema.d.ts +44 -3
  293. package/dist/schemas/feature-effect-schema.js +1 -6
  294. package/dist/schemas/feature-schema.d.ts +0 -6
  295. package/dist/schemas/feature-schema.js +1 -12
  296. package/dist/schemas/resource-schema.d.ts +1 -34
  297. package/dist/schemas/resource-schema.js +1 -12
  298. package/dist/schemas/selection-pool-schema.js +1 -10
  299. package/dist/spell/casting-time.d.ts +0 -15
  300. package/dist/spell/casting-time.js +1 -6
  301. package/dist/spell/spell.access.d.ts +0 -6
  302. package/dist/spell/spell.access.js +1 -45
  303. package/dist/spell/spell.ai-schema.js +1 -6
  304. package/dist/spell/spell.codec.js +1 -9
  305. package/dist/spell/spell.enrichment.js +1 -9
  306. package/dist/spell/spell.filter.d.ts +0 -5
  307. package/dist/spell/spell.filter.js +1 -75
  308. package/dist/spell/spell.parser.d.ts +0 -31
  309. package/dist/spell/spell.parser.js +1 -16
  310. package/dist/spell/spell.scaling.d.ts +0 -46
  311. package/dist/spell/spell.scaling.js +1 -79
  312. package/dist/spell/spell.schema.js +1 -7
  313. package/dist/spell/spell.types.d.ts +0 -7
  314. package/dist/srd/retired-items.d.ts +0 -4
  315. package/dist/srd/retired-items.js +1 -11
  316. package/dist/srd-store.d.ts +0 -33
  317. package/dist/subclass/subclass.codec.d.ts +0 -8
  318. package/dist/subclass/subclass.codec.js +1 -17
  319. package/dist/subclass/subclass.parser.js +1 -16
  320. package/dist/subclass/subclass.schema.d.ts +2 -1
  321. package/dist/subclass/subclass.schema.js +1 -14
  322. package/dist/subclass/subclass.types.d.ts +0 -3
  323. package/dist/types/attack.d.ts +2 -0
  324. package/dist/types/casting-option.d.ts +0 -4
  325. package/dist/types/choice.d.ts +1 -72
  326. package/dist/types/choice.js +1 -24
  327. package/dist/types/edition.d.ts +0 -3
  328. package/dist/types/equipment-grant.d.ts +1 -27
  329. package/dist/types/equipment-grant.js +1 -12
  330. package/dist/types/feature-effect.d.ts +11 -23
  331. package/dist/types/feature.d.ts +0 -22
  332. package/dist/types/optional-feature.types.d.ts +1 -31
  333. package/dist/types/resource.d.ts +1 -21
  334. package/dist/types/selection-pool.d.ts +0 -24
  335. package/dist/weapon/weapon-mastery.d.ts +0 -1
  336. package/dist/weapon/weapon.classify.d.ts +0 -11
  337. package/dist/weapon/weapon.classify.js +1 -7
  338. package/dist/weapon/weapon.codec.d.ts +0 -9
  339. package/dist/weapon/weapon.codec.js +1 -9
  340. package/dist/weapon/weapon.parser.js +1 -8
  341. package/dist/weapon/weapon.schema.js +1 -7
  342. package/dist/weapon/weapon.types.d.ts +0 -3
  343. package/package.json +3 -3
  344. package/src/data-srd/ATTRIBUTION.md +1 -1
  345. package/dist/chunk-2FRUSVZS.js +0 -489
  346. package/dist/chunk-2LULMQTF.js +0 -14
  347. package/dist/chunk-3LWMFYKS.js +0 -57
  348. package/dist/chunk-3SFGWFVQ.js +0 -19
  349. package/dist/chunk-3SIUAFDQ.js +0 -18
  350. package/dist/chunk-3TM34RSJ.js +0 -23
  351. package/dist/chunk-4J6DS3EJ.js +0 -30
  352. package/dist/chunk-4U55VNC7.js +0 -22
  353. package/dist/chunk-5GKJAUMX.js +0 -59
  354. package/dist/chunk-5JXFJ5AU.js +0 -26
  355. package/dist/chunk-64VNLMSG.js +0 -375
  356. package/dist/chunk-656QCX4U.js +0 -22
  357. package/dist/chunk-6GNXYAYP.js +0 -25
  358. package/dist/chunk-6PXTNCBP.js +0 -133
  359. package/dist/chunk-6X2NV665.js +0 -33
  360. package/dist/chunk-7Q2VPKCD.js +0 -181
  361. package/dist/chunk-7XJHI5H5.js +0 -709
  362. package/dist/chunk-A54HHCWW.js +0 -67
  363. package/dist/chunk-B2QHP6UF.js +0 -159
  364. package/dist/chunk-B3DP42OM.js +0 -55
  365. package/dist/chunk-BJGOSM76.js +0 -18
  366. package/dist/chunk-BJWSOQUC.js +0 -133
  367. package/dist/chunk-CJYCVNW2.js +0 -7
  368. package/dist/chunk-CM5CWO4K.js +0 -735
  369. package/dist/chunk-DEEHHLAP.js +0 -271
  370. package/dist/chunk-DPUJDOKV.js +0 -365
  371. package/dist/chunk-EJD47JHL.js +0 -1838
  372. package/dist/chunk-EJP263OP.js +0 -186
  373. package/dist/chunk-EVMUJYUD.js +0 -195
  374. package/dist/chunk-EYX4JMAU.js +0 -101
  375. package/dist/chunk-FC4IGH5Y.js +0 -18
  376. package/dist/chunk-FJYBLXV7.js +0 -89
  377. package/dist/chunk-FMUD3LDV.js +0 -19
  378. package/dist/chunk-FMYWORTP.js +0 -93
  379. package/dist/chunk-FVXLP7P3.js +0 -18
  380. package/dist/chunk-G6MHJDVT.js +0 -41
  381. package/dist/chunk-GVWEFECG.js +0 -18
  382. package/dist/chunk-HHBD4SQ6.js +0 -24
  383. package/dist/chunk-HS6FIOLP.js +0 -52
  384. package/dist/chunk-HY2SRSVM.js +0 -23
  385. package/dist/chunk-IHE6KVC3.js +0 -13
  386. package/dist/chunk-IN4M4X7P.js +0 -34
  387. package/dist/chunk-IUAAXXNO.js +0 -58
  388. package/dist/chunk-JXWNXIIZ.js +0 -219
  389. package/dist/chunk-K5NJBTE2.js +0 -18
  390. package/dist/chunk-KR6JF3BF.js +0 -14
  391. package/dist/chunk-KSTV7J2U.js +0 -112
  392. package/dist/chunk-KU3YLF6D.js +0 -106
  393. package/dist/chunk-LBEXLN6I.js +0 -91
  394. package/dist/chunk-LHZXYFBU.js +0 -94
  395. package/dist/chunk-LICYHPI3.js +0 -237
  396. package/dist/chunk-LNT64X7C.js +0 -81
  397. package/dist/chunk-LSLSG67V.js +0 -31
  398. package/dist/chunk-LVQLWRCU.js +0 -15
  399. package/dist/chunk-MYY2C5MB.js +0 -233
  400. package/dist/chunk-NKZMQV2C.js +0 -19
  401. package/dist/chunk-NTU2DXNG.js +0 -355
  402. package/dist/chunk-NXUY5XQN.js +0 -1062
  403. package/dist/chunk-NZO7M5GV.js +0 -18
  404. package/dist/chunk-OOL4KMG2.js +0 -71
  405. package/dist/chunk-OOSRUJBI.js +0 -19
  406. package/dist/chunk-PDJSUH24.js +0 -110
  407. package/dist/chunk-PTXBIDG7.js +0 -63
  408. package/dist/chunk-PVCEA4HZ.js +0 -6
  409. package/dist/chunk-QA3YCOML.js +0 -101
  410. package/dist/chunk-QFWQKS3M.js +0 -110
  411. package/dist/chunk-QS5L5YTJ.js +0 -24
  412. package/dist/chunk-QYZV2MQA.js +0 -97
  413. package/dist/chunk-RD2MID3M.js +0 -292
  414. package/dist/chunk-S3YUXDSC.js +0 -278
  415. package/dist/chunk-S7REMWW4.js +0 -21
  416. package/dist/chunk-TOM66P2P.js +0 -38
  417. package/dist/chunk-TRBGC4ZG.js +0 -112
  418. package/dist/chunk-UA5KS2PL.js +0 -26
  419. package/dist/chunk-UJCK5IW4.js +0 -187
  420. package/dist/chunk-UNYR5GLI.js +0 -23
  421. package/dist/chunk-UZXG6QSY.js +0 -58
  422. package/dist/chunk-VN5DLURA.js +0 -158
  423. package/dist/chunk-VP5TIXDK.js +0 -178
  424. package/dist/chunk-VPYBK2MG.js +0 -18
  425. package/dist/chunk-VTTA2ALZ.js +0 -16
  426. package/dist/chunk-W6GC6OKK.js +0 -16
  427. package/dist/chunk-WELIKLZF.js +0 -256
  428. package/dist/chunk-WOHX7YTH.js +0 -165
  429. package/dist/chunk-WSVMLNTO.js +0 -31
  430. package/dist/chunk-WYGD2UGN.js +0 -14
  431. package/dist/chunk-XCFC7LGF.js +0 -122
  432. package/dist/chunk-XJ2F2WO6.js +0 -8
  433. package/dist/chunk-XTEFPUSN.js +0 -23
  434. package/dist/chunk-YBLDE5CG.js +0 -42
  435. package/dist/chunk-YDGMBMYI.js +0 -25
  436. package/dist/chunk-YHYTW5QA.js +0 -20
  437. package/dist/chunk-ZCTUYGNV.js +0 -26
  438. package/dist/chunk-ZDAEGJH4.js +0 -102
  439. package/dist/chunk-ZJXSXVFP.js +0 -58
  440. package/dist/chunk-ZOWKWMD2.js +0 -18
  441. package/dist/chunk-ZUQW5VBZ.js +0 -89
@@ -1,1062 +0,0 @@
1
- import {
2
- parseCastingTime
3
- } from "./chunk-W6GC6OKK.js";
4
- import {
5
- derivePoolLayout
6
- } from "./chunk-B3DP42OM.js";
7
- import {
8
- readTableColumn
9
- } from "./chunk-IUAAXXNO.js";
10
- import {
11
- findItemAction,
12
- resolveItemAction
13
- } from "./chunk-ZUQW5VBZ.js";
14
- import {
15
- requiresAttunement
16
- } from "./chunk-IHE6KVC3.js";
17
- import {
18
- defaultSlotForType,
19
- effectiveArmor,
20
- isItemEntity,
21
- isShieldArmor,
22
- resolveEntityForEntry,
23
- slotAcTerms
24
- } from "./chunk-LHZXYFBU.js";
25
- import {
26
- warnOnce
27
- } from "./chunk-LVQLWRCU.js";
28
- import {
29
- keptSlugFor,
30
- resolveBaseItem
31
- } from "./chunk-CM5CWO4K.js";
32
- import {
33
- bucketOf,
34
- memoByRevision
35
- } from "./chunk-4J6DS3EJ.js";
36
- import {
37
- bareEntitySlug,
38
- slugify,
39
- wikilinkTailSlug
40
- } from "./chunk-ZCTUYGNV.js";
41
- import {
42
- parseInlineTag
43
- } from "./chunk-3TM34RSJ.js";
44
- import {
45
- isCanonicalDamageType
46
- } from "./chunk-PDJSUH24.js";
47
-
48
- // src/pc/resource-equivalents.ts
49
- var RESOURCE_EQUIVALENTS = [
50
- { name: "Superiority Dice", ids: ["fighter:superiority-dice", "fighter-2024:superiority-dice"] },
51
- { name: "Sorcery Points", ids: ["sorcerer:sorcery-point", "sorcerer:sorcery-points", "sorcerer-2024:sorcery-point"] },
52
- { name: "Ki / Focus Points", ids: ["monk:ki", "monk:ki-points", "monk:focus-point", "monk:focus-points"] },
53
- { name: "Channel Divinity (Cleric)", ids: ["cleric:channel-divinity", "cleric-2024:channel-divinity", "channel-divinity"] },
54
- { name: "Channel Divinity (Paladin)", ids: ["paladin:channel-divinity", "paladin-2024:channel-divinity", "channel-divinity"] },
55
- { name: "Bardic Inspiration", ids: ["bard:bardic-inspiration", "bard:bardic-die"] },
56
- { name: "Rage", ids: ["barbarian:rage", "barbarian:rages", "barbarian-2024:rages"] },
57
- { name: "Wild Shape", ids: ["druid:wild-shape", "druid-2024:wild-shape"] },
58
- { name: "Soul Trinkets", ids: ["rogue:soul-trinket", "rogue-2024:soul-trinket"] }
59
- ];
60
- function equivalentResourceIds(id, groups = RESOURCE_EQUIVALENTS) {
61
- const out = [];
62
- for (const g of groups) {
63
- if (!g.ids.includes(id)) continue;
64
- for (const other of g.ids) if (other !== id && !out.includes(other)) out.push(other);
65
- }
66
- return out;
67
- }
68
- function ownedByClass(res, rc) {
69
- var _a, _b;
70
- const s = (_a = res == null ? void 0 : res.owner) == null ? void 0 : _a.source;
71
- if (!s) return false;
72
- if (s.kind === "class") return s.slug === ((_b = rc.entity) == null ? void 0 : _b.slug);
73
- if (s.kind === "subclass") return !!rc.subclass && s.slug === rc.subclass.slug;
74
- return false;
75
- }
76
- function payingResourceId(id, index, owner, groups = RESOURCE_EQUIVALENTS) {
77
- const candidates = [id, ...equivalentResourceIds(id, groups)].filter((c) => index.has(c));
78
- if (candidates.length === 0) return void 0;
79
- if (owner) {
80
- const own = candidates.find((c) => ownedByClass(index.get(c), owner));
81
- if (own) return own;
82
- }
83
- return candidates[0];
84
- }
85
- function classOfSource(source, classes) {
86
- var _a, _b;
87
- if (source.kind === "class") return (_a = classes.find((c) => {
88
- var _a2;
89
- return ((_a2 = c.entity) == null ? void 0 : _a2.slug) === source.slug;
90
- })) != null ? _a : null;
91
- if (source.kind === "subclass") return (_b = classes.find((c) => {
92
- var _a2;
93
- return ((_a2 = c.subclass) == null ? void 0 : _a2.slug) === source.slug;
94
- })) != null ? _b : null;
95
- return null;
96
- }
97
- function bindFeatureConsumers(features, index, classes) {
98
- return features.map((rf) => {
99
- const consumes = rf.feature.consumes;
100
- const id = consumes == null ? void 0 : consumes.resource;
101
- if (!consumes || typeof id !== "string" || id.length === 0) return rf;
102
- const payer = payingResourceId(id, index, classOfSource(rf.source, classes));
103
- if (payer === void 0 || payer === id) return rf;
104
- return { ...rf, feature: { ...rf.feature, consumes: { ...consumes, resource: payer } } };
105
- });
106
- }
107
-
108
- // src/pc/pc.pools.ts
109
- var SORTED_OPTIONAL_FEATURES = /* @__PURE__ */ new WeakMap();
110
- function sortedOptionalFeatures(registry) {
111
- return memoByRevision(SORTED_OPTIONAL_FEATURES, registry, () => bucketOf(registry, "optional-feature").slice().sort((a, b) => a.name.localeCompare(b.name) || a.slug.localeCompare(b.slug)));
112
- }
113
- var SRD_OWNER_PREFIXES = /* @__PURE__ */ new Set(["srd-5e", "srd-2024"]);
114
- function levelPrereqMax(d) {
115
- var _a;
116
- return ((_a = d.prerequisites) != null ? _a : []).filter((p) => p.kind === "level").reduce((m, p) => Math.max(m, p.min), 0);
117
- }
118
- function poolAnchorLevel(entity, pool) {
119
- let anchorLevel = 1;
120
- let columnSeen = false;
121
- for (let l = 1; l <= 20; l++) {
122
- const c = readTableColumn(entity.table, l, [pool.count.column]);
123
- if (c != null) columnSeen = true;
124
- if (c != null && c >= 1) {
125
- anchorLevel = l;
126
- break;
127
- }
128
- }
129
- return { anchorLevel, columnSeen };
130
- }
131
- function resolvePool(rc, classIndex, pool, registry, index, edition) {
132
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
133
- const entity = rc.entity;
134
- const level = rc.level;
135
- const ownerBare = bareEntitySlug(entity.slug);
136
- const ownerPrefix = entity.slug.split("_")[0];
137
- const ownEdition = SRD_OWNER_PREFIXES.has(ownerPrefix) ? entity.edition : void 0;
138
- const col = pool.count.column;
139
- const count = (_a = readTableColumn(entity.table, level, [col])) != null ? _a : 0;
140
- const { anchorLevel, columnSeen } = poolAnchorLevel(entity, pool);
141
- if (!columnSeen) {
142
- warnOnce(
143
- `pool-column:${pool.id}`,
144
- `Archivist: pool "${pool.id}" declares count column "${col}", which "${entity.slug}"'s class table carries at no level; the pool resolves count 0 at anchor level 1`
145
- );
146
- }
147
- const ft = pool.source.where.feature_type;
148
- const all = sortedOptionalFeatures(registry);
149
- const entryOf = (slug, entity2, compendium) => ({ slug, entity: entity2, ...compendium ? { compendium } : {}, key: slug, param: null, itemBound: isItemBound(entity2) });
150
- const byBare = /* @__PURE__ */ new Map();
151
- const candidates = /* @__PURE__ */ new Map();
152
- for (const e of all) {
153
- const d = e.data;
154
- const entry = entryOf(e.slug, d, e.compendium);
155
- const bare = bareEntitySlug(e.slug);
156
- byBare.set(bare, entry);
157
- if (d.feature_type !== ft) continue;
158
- if (!((_b = d.available_to) != null ? _b : []).some((l) => wikilinkTailSlug(l) === ownerBare)) continue;
159
- if (levelPrereqMax(d) > level) continue;
160
- if (ownEdition && d.edition && d.edition !== ownEdition) continue;
161
- const group = candidates.get(bare);
162
- if (group) group.push(entry);
163
- else candidates.set(bare, [entry]);
164
- }
165
- const collapsed = [];
166
- for (const [bare, group] of candidates) {
167
- if (group.length === 1) {
168
- collapsed.push(group[0]);
169
- continue;
170
- }
171
- const owned = group.find((e) => e.slug.split("_")[0] === ownerPrefix);
172
- if (!owned) {
173
- warnOnce(
174
- `pool-collapse:${bare}`,
175
- `Archivist: pool "${pool.id}" holds ${group.length} cross-edition entries for "${bare}" and none shares the owner's compendium prefix "${ownerPrefix}"; keeping "${group[0].slug}"`
176
- );
177
- }
178
- collapsed.push(owned != null ? owned : group[0]);
179
- }
180
- const grantDecls = [
181
- ...(_d = (_c = rc.entity) == null ? void 0 : _c.pool_grants) != null ? _d : [],
182
- ...(_f = (_e = rc.subclass) == null ? void 0 : _e.pool_grants) != null ? _f : []
183
- ];
184
- const grantsRaw = grantDecls.filter((g) => g.pool === pool.id).flatMap((g) => g.grants).filter((g) => g.at_level <= level).map((g) => byBare.get(wikilinkTailSlug(g.feature))).filter((e) => e != null);
185
- const grantedBare = /* @__PURE__ */ new Set();
186
- const grants = grantsRaw.filter((e) => {
187
- const key = bareEntitySlug(e.slug);
188
- if (grantedBare.has(key)) return false;
189
- grantedBare.add(key);
190
- return true;
191
- });
192
- const available = collapsed.filter((e) => !grantedBare.has(bareEntitySlug(e.slug)));
193
- const bySlugAvailable = new Map(available.map((e) => [e.slug, e]));
194
- const byBareAvailable = new Map(available.map((e) => [bareEntitySlug(e.slug), e]));
195
- const resolveStored = (s) => {
196
- const exact = bySlugAvailable.get(s);
197
- if (exact) return exact;
198
- const survivor = byBareAvailable.get(bareEntitySlug(s));
199
- if (survivor) return survivor;
200
- const full = registry.getByTypeAndSlug("optional-feature", s);
201
- if (full) return entryOf(full.slug, full.data, full.compendium);
202
- return byBare.get(bareEntitySlug(s));
203
- };
204
- const raw = (_g = rc.choices[anchorLevel]) == null ? void 0 : _g[pool.id];
205
- const selectedSlugs = Array.isArray(raw) ? raw : typeof raw === "string" ? [raw] : [];
206
- const selected = [];
207
- const seenKeys = /* @__PURE__ */ new Set();
208
- for (const s of selectedSlugs) {
209
- const { slugPart, param } = parsePickKey(s);
210
- const entry = resolveStored(slugPart);
211
- if (!entry) continue;
212
- const repeatable = entry.entity.repeatable === true;
213
- if (!repeatable && param !== null) {
214
- warnOnce(`pick-param:${pool.id}:${s}`, `Archivist: pool "${pool.id}" pick "${s}" names a parameter, but "${entry.slug}" is not repeatable; the parameter is ignored`);
215
- }
216
- const nkey = normalizedPickKey(s, repeatable);
217
- if (grantedBare.has(bareEntitySlug(entry.slug)) || seenKeys.has(nkey)) continue;
218
- seenKeys.add(nkey);
219
- selected.push({
220
- ...entry,
221
- key: repeatable || param !== null ? s : entry.slug,
222
- param: repeatable ? param : null,
223
- ...repeatable ? { option: resolveCopyOption(entry.entity, param, { classLevel: level, registry, edition }) } : {}
224
- });
225
- }
226
- const members = [...available, ...grants];
227
- const layout = derivePoolLayout(members);
228
- const votes = /* @__PURE__ */ new Map();
229
- for (const e of members) {
230
- const id = (_h = e.entity.consumes) == null ? void 0 : _h.resource;
231
- const payer = id ? payingResourceId(id, index, rc) : void 0;
232
- if (!payer) continue;
233
- votes.set(payer, ((_i = votes.get(payer)) != null ? _i : 0) + 1);
234
- }
235
- let resource;
236
- let bestN = 0;
237
- for (const [id, n] of votes) if (n > bestN) {
238
- resource = id;
239
- bestN = n;
240
- }
241
- const bind = poolRebinder(rc, pool.id, resource, index);
242
- return {
243
- id: pool.id,
244
- label: pool.label,
245
- classIndex,
246
- count,
247
- anchorLevel,
248
- selected: selected.map(bind),
249
- available: available.map(bind),
250
- grants: grants.map(bind),
251
- ...layout ? { layout } : {},
252
- ...resource ? { resource } : {},
253
- ...pool.count.label ? { countLabel: pool.count.label } : {},
254
- ...pool.active ? { active: pool.active } : {},
255
- ...pool.head_resource ? { headResource: pool.head_resource } : {}
256
- };
257
- }
258
- function poolRebinder(rc, poolId, vote, index) {
259
- const declared = declaredResourceIds(rc);
260
- const copies = /* @__PURE__ */ new Map();
261
- return (e) => {
262
- const consumes = e.entity.consumes;
263
- const id = consumes == null ? void 0 : consumes.resource;
264
- if (!consumes || typeof id !== "string" || id.length === 0) return e;
265
- const payer = payingResourceId(id, index, rc);
266
- if (payer === id) return e;
267
- const target = payer != null ? payer : vote !== void 0 && !declared.has(id) ? vote : void 0;
268
- if (target === void 0) return e;
269
- const done = copies.get(e.key);
270
- if (done) return done;
271
- if (payer === void 0) {
272
- warnOnce(
273
- `pool-rebind:${poolId}:${id}`,
274
- `Archivist: pool "${poolId}" members consume "${id}", which this character does not own; bound to the pool's resource "${target}"`
275
- );
276
- }
277
- const copy = { ...e, entity: { ...e.entity, consumes: { ...consumes, resource: target } } };
278
- copies.set(e.key, copy);
279
- return copy;
280
- };
281
- }
282
- function declaredResourceIds(rc) {
283
- var _a;
284
- const out = /* @__PURE__ */ new Set();
285
- const add = (list) => {
286
- for (const r of list != null ? list : []) if (typeof (r == null ? void 0 : r.id) === "string") out.add(r.id);
287
- };
288
- for (const owner of [rc.entity, rc.subclass]) {
289
- if (!owner) continue;
290
- add(owner.resources);
291
- for (const features of Object.values((_a = owner.features_by_level) != null ? _a : {})) for (const f of features != null ? features : []) add(f.resources);
292
- }
293
- return out;
294
- }
295
- function resolveAllPools(resolved, registry, index) {
296
- const out = [];
297
- resolved.classes.forEach((rc, classIndex) => {
298
- var _a, _b, _c, _d;
299
- if (!rc.entity) return;
300
- const decls = [...(_a = rc.entity.selection_pools) != null ? _a : [], ...(_c = (_b = rc.subclass) == null ? void 0 : _b.selection_pools) != null ? _c : []];
301
- const seen = /* @__PURE__ */ new Set();
302
- for (const pool of decls) {
303
- if (seen.has(pool.id)) continue;
304
- seen.add(pool.id);
305
- out.push(resolvePool(rc, classIndex, pool, registry, index, (_d = resolved.definition) == null ? void 0 : _d.edition));
306
- }
307
- });
308
- return out;
309
- }
310
- function strandedPicks(pool) {
311
- const inAvailable = new Set(pool.available.map((e) => e.slug));
312
- return pool.selected.filter((e) => !inAvailable.has(e.slug));
313
- }
314
-
315
- // src/pc/pc.infusions.ts
316
- function poolCountLabel(pool) {
317
- var _a;
318
- return (_a = pool.countLabel) != null ? _a : "Known";
319
- }
320
- function poolActiveWords(pool) {
321
- var _a, _b, _c;
322
- const a = pool.active;
323
- if (!a) return null;
324
- return {
325
- column: a.column,
326
- label: a.label,
327
- verb: a.verb,
328
- counterLabel: (_a = a.counter_label) != null ? _a : a.label,
329
- createLabel: (_b = a.create_label) != null ? _b : "Created",
330
- createVerb: (_c = a.create_verb) != null ? _c : "Create"
331
- };
332
- }
333
- function parsePickKey(stored) {
334
- const i = stored.indexOf("#");
335
- return i === -1 ? { slugPart: stored, param: null } : { slugPart: stored.slice(0, i), param: stored.slice(i + 1) };
336
- }
337
- function normalizedPickKey(stored, repeatable) {
338
- const { slugPart, param } = parsePickKey(stored);
339
- return repeatable ? `${bareEntitySlug(slugPart)}#${param != null ? param : ""}` : bareEntitySlug(slugPart);
340
- }
341
- function markerKey(by) {
342
- const { slugPart, param } = parsePickKey(by);
343
- return param === null ? bareEntitySlug(slugPart) : `${bareEntitySlug(slugPart)}#${param}`;
344
- }
345
- function isItemBound(note) {
346
- var _a;
347
- return !!note.infuse || note.repeatable === true && !!((_a = note.options) == null ? void 0 : _a.some((r) => !!r.creates));
348
- }
349
- var SRD_BOOKS = /* @__PURE__ */ new Set(["SRD 2024", "SRD 5e"]);
350
- var lc = (v) => String(v != null ? v : "").trim().toLowerCase();
351
- var linkSlug = (link) => link.replace(/^\[\[/, "").replace(/\]\]$/, "").split("|")[0];
352
- var itemsOf = (registry) => registry.search("", "item", Number.POSITIVE_INFINITY);
353
- function matchesFilter(data, f) {
354
- var _a;
355
- const type = lc(data.type);
356
- if (!f.rarity.map(lc).includes(lc(data.rarity))) return false;
357
- if (f.types && !f.types.map(lc).includes(type)) return false;
358
- if ((_a = f.exclude_types) == null ? void 0 : _a.map(lc).includes(type)) return false;
359
- return !(f.cursed === false && data.cursed === true);
360
- }
361
- function rowMatches(row, it) {
362
- const c = row.creates;
363
- if (c.item) return lc(it.name) === lc(row.name) || it.slug === linkSlug(c.item);
364
- if (c.variant) return c.variant.candidates.some((l) => bareEntitySlug(linkSlug(l)) === bareEntitySlug(it.slug));
365
- return !!c.filter && matchesFilter(it.data, c.filter);
366
- }
367
- function buildItemIndex(items) {
368
- const lcType = [], lcRarity = [];
369
- const byLcName = /* @__PURE__ */ new Map(), bySlug = /* @__PURE__ */ new Map(), byBare = /* @__PURE__ */ new Map();
370
- const push = (m, k, i) => {
371
- const l = m.get(k);
372
- if (l) l.push(i);
373
- else m.set(k, [i]);
374
- };
375
- items.forEach((it, i) => {
376
- const data = it.data;
377
- lcType.push(lc(data.type));
378
- lcRarity.push(lc(data.rarity));
379
- push(byLcName, lc(it.name), i);
380
- if (!bySlug.has(it.slug)) bySlug.set(it.slug, i);
381
- push(byBare, bareEntitySlug(it.slug), i);
382
- });
383
- return { items, lcType, lcRarity, byLcName, bySlug, byBare };
384
- }
385
- var ITEM_INDEX = /* @__PURE__ */ new WeakMap();
386
- var itemIndexOf = (registry) => memoByRevision(ITEM_INDEX, registry, () => buildItemIndex(itemsOf(registry)));
387
- var inBucketOrder = (ix, hits) => [...hits].sort((a, b) => a - b).map((i) => ix.items[i]);
388
- function rowInstalledIn(row, ix) {
389
- var _a, _b, _c;
390
- const c = row.creates;
391
- if (c.item) {
392
- const hits = new Set((_a = ix.byLcName.get(lc(row.name))) != null ? _a : []);
393
- const own = ix.bySlug.get(linkSlug(c.item));
394
- if (own !== void 0) hits.add(own);
395
- return inBucketOrder(ix, hits);
396
- }
397
- if (c.variant) {
398
- const hits = /* @__PURE__ */ new Set();
399
- for (const l of c.variant.candidates) for (const i of (_b = ix.byBare.get(bareEntitySlug(linkSlug(l)))) != null ? _b : []) hits.add(i);
400
- return inBucketOrder(ix, hits);
401
- }
402
- const f = c.filter;
403
- if (!f) return [];
404
- const rarities = new Set(f.rarity.map(lc));
405
- const types = f.types ? new Set(f.types.map(lc)) : null;
406
- const excluded = new Set(((_c = f.exclude_types) != null ? _c : []).map(lc));
407
- return ix.items.filter((it, i) => rarities.has(ix.lcRarity[i]) && (!types || types.has(ix.lcType[i])) && !excluded.has(ix.lcType[i]) && !(f.cursed === false && it.data.cursed === true));
408
- }
409
- var rowInstalled = (row, registry) => rowInstalledIn(row, itemIndexOf(registry));
410
- function candidateOrder(edition) {
411
- return (a, b) => {
412
- const ea = edition && lc(a.data.edition) === edition ? 0 : 1;
413
- const eb = edition && lc(b.data.edition) === edition ? 0 : 1;
414
- if (ea !== eb) return ea - eb;
415
- const sa = SRD_BOOKS.has(a.compendium) ? 0 : 1, sb = SRD_BOOKS.has(b.compendium) ? 0 : 1;
416
- if (sa !== sb) return sa - sb;
417
- return a.slug < b.slug ? -1 : a.slug > b.slug ? 1 : 0;
418
- };
419
- }
420
- function optionCandidates(row, registry, opts = {}) {
421
- return candidatesFrom(rowInstalled(row, registry), registry, opts);
422
- }
423
- function candidatesFrom(installed, registry, opts) {
424
- var _a, _b;
425
- const visible = (_a = opts.isEntityVisible) != null ? _a : (() => true);
426
- const excluded = ((_b = opts.exclude) != null ? _b : []).map((s) => {
427
- var _a2;
428
- return registry.getByTypeAndSlug("item", (_a2 = keptSlugFor(s)) != null ? _a2 : s);
429
- }).filter((e) => !!e);
430
- const exNames = new Set(excluded.map((e) => lc(e.name))), exBares = new Set(excluded.map((e) => bareEntitySlug(e.slug)));
431
- const seen = /* @__PURE__ */ new Set(), out = [];
432
- for (const e of installed.filter(visible).sort(candidateOrder(opts.edition))) {
433
- const bare = bareEntitySlug(e.slug);
434
- if (seen.has(bare)) continue;
435
- seen.add(bare);
436
- if (exNames.has(lc(e.name)) || exBares.has(bare)) continue;
437
- out.push(e.slug);
438
- }
439
- return out;
440
- }
441
- function resolveOptionRows(note, registry, opts = {}) {
442
- var _a;
443
- const ix = itemIndexOf(registry);
444
- return ((_a = note.options) != null ? _a : []).map((row) => {
445
- var _a2;
446
- const rowItems = rowInstalledIn(row, ix);
447
- const candidates = candidatesFrom(rowItems, registry, opts);
448
- const anyVisible = candidates.length > 0 || candidatesFrom(rowItems, registry, { ...opts, exclude: [] }).length > 0;
449
- const installed = rowItems.length > 0;
450
- return {
451
- key: row.key,
452
- name: row.name,
453
- minLevel: row.min_level,
454
- ...row.attunement !== void 0 ? { attunement: row.attunement } : {},
455
- arm: row.creates.item ? "item" : row.creates.variant ? "variant" : "filter",
456
- candidates,
457
- availability: anyVisible ? "installed" : installed ? "hidden-only" : "not-installed",
458
- ...rowItemWords(row, candidates[0] ? ix.items[(_a2 = ix.bySlug.get(candidates[0])) != null ? _a2 : -1] : rowItems[0])
459
- };
460
- });
461
- }
462
- function rowItemWords(row, item) {
463
- var _a, _b, _c, _d;
464
- const f = row.creates.filter;
465
- if (f) return { type: ((_a = f.types) == null ? void 0 : _a[0]) ? lc(f.types[0]) : null, rarity: f.rarity[0] ? lc(f.rarity[0]) : null, charges: null };
466
- const data = (_b = item == null ? void 0 : item.data) != null ? _b : {};
467
- const max = (_c = data.charges) == null ? void 0 : _c.max;
468
- return {
469
- type: lc(data.type) || null,
470
- rarity: lc(data.rarity) || null,
471
- charges: typeof max === "number" && max > 0 ? { max, ...typeof ((_d = data.charges) == null ? void 0 : _d.recharge) === "string" ? { recharge: data.charges.recharge } : {} } : null
472
- };
473
- }
474
- function resolveCopyOption(note, param, ctx) {
475
- var _a, _b, _c;
476
- const rows = (_a = note.options) != null ? _a : [];
477
- if (param === null || param === "") return { row: null, status: "needs-choice" };
478
- if (note.item_choice === "create") {
479
- const row = rows.find((r) => r.key === param);
480
- if (!row) return { row: null, status: "invalid" };
481
- const installed = rowInstalled(row, ctx.registry).sort(candidateOrder(ctx.edition));
482
- if (installed.length === 0) return { row, status: "not-installed" };
483
- const own = row.creates.item ? linkSlug(row.creates.item) : void 0;
484
- const item = row.creates.item ? ((_b = installed.find((e) => e.slug === own)) != null ? _b : installed[0]).slug : void 0;
485
- return { row, ...item ? { item } : {}, status: row.min_level <= ctx.classLevel ? "ok" : "level" };
486
- }
487
- const slug = (_c = keptSlugFor(param)) != null ? _c : param;
488
- const it = ctx.registry.getByTypeAndSlug("item", slug);
489
- if (!it) return { row: null, item: slug, status: "not-installed" };
490
- const matching = rows.filter((r) => rowMatches(r, it)).sort((a, b) => a.min_level - b.min_level);
491
- if (matching.length === 0) return { row: null, item: slug, status: "invalid" };
492
- return { row: matching[0], item: slug, status: matching[0].min_level <= ctx.classLevel ? "ok" : "level" };
493
- }
494
- var MUNDANE = /* @__PURE__ */ new Set(["", "none", "mundane"]);
495
- var isMagic = (data) => {
496
- const r = data == null ? void 0 : data.rarity;
497
- return typeof r === "string" && !MUNDANE.has(r.trim().toLowerCase());
498
- };
499
- var plainText = (item) => item.replace(/^\[\[/, "").replace(/\]\]$/, "").split("|").pop().split("/").pop();
500
- function scaledInfuseItem(infuse, classLevel) {
501
- var _a, _b;
502
- let item = { ...(_a = infuse.item) != null ? _a : {} };
503
- const rows = [...(_b = infuse.scales_at) != null ? _b : []].sort((a, b) => a.level - b.level);
504
- for (const row of rows) if (row.level <= classLevel) item = { ...item, ...row.item };
505
- return item;
506
- }
507
- function wrapInfused(entry, note, classLevel, registry) {
508
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
509
- const infuse = note.infuse;
510
- const item = scaledInfuseItem(infuse, classLevel);
511
- const resist = [...(_a = item.resist) != null ? _a : [], ...((_b = infuse.choice) == null ? void 0 : _b.kind) === "damage-type" && ((_c = entry.infusion) == null ? void 0 : _c.choice) ? [entry.infusion.choice] : []];
512
- const overlay = {
513
- ...item.bonuses ? { bonuses: item.bonuses } : {},
514
- resist,
515
- ...item.charges ? { charges: item.charges } : {},
516
- ...item.action ? { action: item.action } : {},
517
- ...item.range ? { range: item.range } : {},
518
- ...infuse.attunement ? { attunement: { required: true } } : {}
519
- };
520
- const base = resolveBaseItem(entry.item, registry);
521
- const data = (_d = base == null ? void 0 : base.data) != null ? _d : null;
522
- if (base && isMagic(data)) {
523
- const b = data;
524
- const bonuses = { ...(_e = b.bonuses) != null ? _e : {} };
525
- for (const [k, v] of Object.entries((_f = item.bonuses) != null ? _f : {})) if (typeof v === "number") bonuses[k] = (typeof bonuses[k] === "number" ? bonuses[k] : 0) + v;
526
- return { entity: {
527
- ...b,
528
- bonuses,
529
- resist: [.../* @__PURE__ */ new Set([...(_g = b.resist) != null ? _g : [], ...resist])],
530
- attunement: { required: requiresAttunement(b) || !!infuse.attunement }
531
- }, magicBase: true };
532
- }
533
- const rarity = (_h = infuse.rarity) != null ? _h : "unknown";
534
- if (!base) {
535
- const text = plainText(entry.item);
536
- return { entity: { slug: `infused:${slugify(text)}`, name: text, type: "wondrous item", rarity, ...overlay, description: "" }, magicBase: false };
537
- }
538
- const name = String((_i = data == null ? void 0 : data.name) != null ? _i : base.name), description = String((_j = data == null ? void 0 : data.description) != null ? _j : "");
539
- const slotted = base.entityType === "armor" || base.entityType === "weapon" ? base : typeof (data == null ? void 0 : data.base_item) === "string" ? resolveBaseItem(data.base_item, registry) : null;
540
- if (slotted && (slotted.entityType === "armor" || slotted.entityType === "weapon")) {
541
- const type = slotted.entityType === "weapon" ? "weapon" : isShieldArmor(slotted.data) ? "shield" : "armor";
542
- return { entity: { slug: base.slug, name, type, rarity, base_item: `[[${slotted.slug}]]`, ...overlay, description }, magicBase: false };
543
- }
544
- return { entity: { slug: base.slug, name, type: String((_k = data == null ? void 0 : data.type) != null ? _k : "adventuring gear"), rarity, ...overlay, description }, magicBase: false };
545
- }
546
- function resolveEntryEntity(entry, index, registry, infusions) {
547
- const view = !infusions ? void 0 : "views" in infusions ? infusions.views.get(index) : infusions.index === index ? infusions : void 0;
548
- if (view) return { entity: view.entity, entityType: view.entityType };
549
- return resolveEntityForEntry(entry.item, registry);
550
- }
551
- function buildInfusionContext(character, resolved, registry) {
552
- var _a, _b, _c, _d, _e;
553
- const equipment = (_a = character.equipment) != null ? _a : [];
554
- const pools = ((_b = resolved.pools) != null ? _b : []).filter((p) => !!p.active || p.selected.some((e) => e.itemBound));
555
- if (pools.length === 0 && !equipment.some((e) => !!e.infusion)) return void 0;
556
- const owners = /* @__PURE__ */ new Map();
557
- for (const pool of pools) for (const entry of pool.selected) if (entry.itemBound) owners.set(normalizedPickKey(entry.key, entry.entity.repeatable === true), { pool, entry });
558
- const views = /* @__PURE__ */ new Map(), flags = [];
559
- const newest = /* @__PURE__ */ new Map();
560
- equipment.forEach((e, i) => {
561
- if (!e.infusion) return;
562
- const k = markerKey(e.infusion.by);
563
- const j = newest.get(k);
564
- if (j === void 0 || equipment[j].infusion.seq < e.infusion.seq) newest.set(k, i);
565
- });
566
- equipment.forEach((e, i) => {
567
- var _a2, _b2, _c2;
568
- const m = e.infusion;
569
- if (!m) return;
570
- const owner = owners.get(markerKey(m.by));
571
- const nullView = () => {
572
- var _a3, _b3, _c3, _d2, _e2;
573
- return {
574
- index: i,
575
- kind: m.kind,
576
- entity: null,
577
- entityType: null,
578
- key: m.by,
579
- seq: m.seq,
580
- poolId: (_a3 = owner == null ? void 0 : owner.pool.id) != null ? _a3 : "",
581
- classIndex: (_b3 = owner == null ? void 0 : owner.pool.classIndex) != null ? _b3 : -1,
582
- noteSlug: (_c3 = owner == null ? void 0 : owner.entry.slug) != null ? _c3 : "",
583
- noteName: (_d2 = owner == null ? void 0 : owner.entry.entity.name) != null ? _d2 : "",
584
- sourceLabel: (_e2 = owner == null ? void 0 : owner.entry.entity.name) != null ? _e2 : ""
585
- };
586
- };
587
- if (!owner) {
588
- flags.push({ index: i, reason: "orphan" });
589
- if (m.kind === "created") views.set(i, nullView());
590
- return;
591
- }
592
- if (newest.get(markerKey(m.by)) !== i) {
593
- flags.push({ index: i, reason: "duplicate" });
594
- if (m.kind === "created") views.set(i, nullView());
595
- return;
596
- }
597
- if (((_a2 = e.qty) != null ? _a2 : 1) > 1) flags.push({ index: i, reason: "stack" });
598
- const classLevel = (_c2 = (_b2 = resolved.classes[owner.pool.classIndex]) == null ? void 0 : _b2.level) != null ? _c2 : 0;
599
- const base = {
600
- index: i,
601
- kind: m.kind,
602
- key: m.by,
603
- seq: m.seq,
604
- poolId: owner.pool.id,
605
- classIndex: owner.pool.classIndex,
606
- noteSlug: owner.entry.slug,
607
- noteName: owner.entry.entity.name,
608
- sourceLabel: owner.entry.entity.name
609
- };
610
- if (m.kind === "created") {
611
- const own = resolveEntityForEntry(e.item, registry);
612
- const it = resolveBaseItem(e.item, registry);
613
- const opt = owner.entry.option;
614
- const fits = !!it && !!(opt == null ? void 0 : opt.row) && (opt.item === it.slug || rowMatches(opt.row, it));
615
- if (!fits) flags.push({ index: i, reason: "mismatch" });
616
- views.set(i, { ...base, entity: own.entity, entityType: own.entityType });
617
- return;
618
- }
619
- if (!owner.entry.entity.infuse) {
620
- flags.push({ index: i, reason: "orphan" });
621
- return;
622
- }
623
- const w = wrapInfused(e, owner.entry.entity, classLevel, registry);
624
- if (w.magicBase) flags.push({ index: i, reason: "magic-base" });
625
- views.set(i, { ...base, entity: w.entity, entityType: "item" });
626
- });
627
- const counters = /* @__PURE__ */ new Map();
628
- for (const pool of pools) {
629
- const words = poolActiveWords(pool);
630
- if (!words) continue;
631
- const rc = resolved.classes[pool.classIndex];
632
- const max = (_e = readTableColumn((_c = rc == null ? void 0 : rc.entity) == null ? void 0 : _c.table, (_d = rc == null ? void 0 : rc.level) != null ? _d : 0, [words.column])) != null ? _e : 0;
633
- const used = [...views.values()].filter((v) => v.poolId === pool.id && v.entity !== null).length;
634
- counters.set(pool.id, { label: words.counterLabel, used, max, over: used > max });
635
- }
636
- return { views, counters, flags };
637
- }
638
- function entryCharges(entry, view, registry) {
639
- return effectiveItemCharges(entry, registry, view);
640
- }
641
- function withEntryCharges(entry, view, current, registry) {
642
- var _a, _b, _c, _d, _e, _f;
643
- const overlayMax = (view == null ? void 0 : view.kind) === "infused" ? itemChargesMax(view.entity) : void 0;
644
- if (overlayMax !== void 0 && entry.infusion) return { ...entry, infusion: { ...entry.infusion, charges: { current: Math.max(0, Math.min(current, overlayMax)) } } };
645
- const max = (_e = (_d = (_b = (_a = entry.state) == null ? void 0 : _a.charges) == null ? void 0 : _b.max) != null ? _d : (_c = effectiveItemCharges(entry, registry, view)) == null ? void 0 : _c.max) != null ? _e : Math.max(0, current);
646
- return { ...entry, state: { ...(_f = entry.state) != null ? _f : {}, charges: { current: Math.max(0, Math.min(current, max)), max } } };
647
- }
648
- function isMarkedEntry(entry) {
649
- return !!entry.infusion;
650
- }
651
- function splitOne(equipment, index) {
652
- var _a, _b;
653
- const src = equipment[index];
654
- if (!src || ((_a = src.qty) != null ? _a : 1) <= 1) return [...equipment];
655
- const one = { item: src.item, qty: 1, ...src.in !== void 0 ? { in: src.in } : {}, ...src.overrides ? { overrides: src.overrides } : {} };
656
- return [...equipment.slice(0, index), { ...src, qty: ((_b = src.qty) != null ? _b : 1) - 1 }, one, ...equipment.slice(index + 1)];
657
- }
658
- var refuse = (reason) => ({ ok: false, reason });
659
- function endInfusion(equipment, index, registry) {
660
- const entry = equipment[index];
661
- if (!(entry == null ? void 0 : entry.infusion)) return { equipment: [...equipment], ended: [] };
662
- const { kind, by } = entry.infusion;
663
- if (kind === "infused") {
664
- const { infusion: _m, ...rest } = entry;
665
- const keep = requiresAttunement(resolveEntryEntity(rest, index, registry).entity);
666
- const next = keep ? rest : (({ attuned: _a, ...r }) => r)(rest);
667
- return { equipment: equipment.map((e, i) => i === index ? next : e), ended: [{ index, key: by, kind, item: entry.item }] };
668
- }
669
- const moved = equipment.map((e, i) => {
670
- if (i === index || entry.id === void 0 || e.in !== entry.id) return e;
671
- if (entry.in === void 0) {
672
- const { in: _in, ...r } = e;
673
- return r;
674
- }
675
- return { ...e, in: entry.in };
676
- });
677
- return { equipment: moved.filter((_, i) => i !== index), ended: [{ index: -1, key: by, kind, item: entry.item }] };
678
- }
679
- var pickKeyOf = (e) => normalizedPickKey(e.key, e.entity.repeatable === true);
680
- var nextSeq = (equipment) => equipment.reduce((m, e) => {
681
- var _a, _b;
682
- return Math.max(m, (_b = (_a = e.infusion) == null ? void 0 : _a.seq) != null ? _b : 0);
683
- }, 0) + 1;
684
- function ownedPick(resolved, key) {
685
- var _a, _b;
686
- const k = markerKey(key);
687
- for (const pool of (_a = resolved.pools) != null ? _a : []) {
688
- const entry = pool.selected.find((e) => e.itemBound && pickKeyOf(e) === k);
689
- if (entry) return { pool, entry, stranded: strandedPicks(pool).includes(entry) || ((_b = entry.option) == null ? void 0 : _b.status) === "level" };
690
- }
691
- return null;
692
- }
693
- var wordsOf = (...texts) => texts.map(lc).join(" ").split(/[^a-z]+/).filter((w) => w !== "");
694
- function shapeOf(found, text, registry) {
695
- var _a, _b, _c;
696
- if (!found) return { kind: "gear", words: wordsOf(text) };
697
- const data = (_a = found.data) != null ? _a : {};
698
- const words = wordsOf((_b = data.name) != null ? _b : text, data.type);
699
- const slotted = found.entityType === "armor" || found.entityType === "weapon" ? found : typeof data.base_item === "string" ? resolveBaseItem(data.base_item, registry) : null;
700
- if ((slotted == null ? void 0 : slotted.entityType) === "armor") {
701
- const armor = slotted.data;
702
- return { kind: isShieldArmor(armor) ? "shield" : "armor", words, category: lc(armor.category) };
703
- }
704
- if ((slotted == null ? void 0 : slotted.entityType) === "weapon") {
705
- const w = slotted.data;
706
- return { kind: "weapon", words, category: lc(w.category), properties: ((_c = w.properties) != null ? _c : []).filter((p) => typeof p === "string").map(lc) };
707
- }
708
- return { kind: "gear", words };
709
- }
710
- function admits(t, s) {
711
- var _a, _b, _c, _d;
712
- if (t.kind !== s.kind) return false;
713
- if (((_a = t.category) == null ? void 0 : _a.length) && !t.category.map(lc).includes(((_b = s.category) != null ? _b : "").split("-")[0])) return false;
714
- if (t.property && !((_c = s.properties) != null ? _c : []).includes(lc(t.property))) return false;
715
- if (((_d = t.name_any) == null ? void 0 : _d.length) && !t.name_any.some((n) => {
716
- const w = wordsOf(n);
717
- return w.length > 0 && w.every((x) => s.words.includes(x));
718
- })) return false;
719
- return true;
720
- }
721
- function targetVerdict(entry, infuse, registry) {
722
- const found = resolveBaseItem(entry.item, registry);
723
- if (!infuse.targets.some((t) => admits(t, shapeOf(found, plainText(entry.item), registry)))) return "target-kind";
724
- return found && isMagic(found.data) ? "magic-base" : "ok";
725
- }
726
- function newObjectEntry(name, infuse, registry, visible) {
727
- const want = lc(name);
728
- const found = [];
729
- for (const type of ["armor", "weapon", "item"]) {
730
- for (const e of registry.search(name, type, Number.POSITIVE_INFINITY)) {
731
- if (lc(e.name) === want && !isMagic(e.data) && visible(e) && infuse.targets.some((t) => admits(t, shapeOf(e, e.name, registry)))) found.push(e);
732
- }
733
- }
734
- const first = found.sort(candidateOrder(void 0))[0];
735
- return first ? { item: `[[${first.slug}]]`, qty: 1 } : { item: name, qty: 1 };
736
- }
737
- function endBySeqs(equipment, seqs, registry) {
738
- let eq = [...equipment];
739
- let slots = eq.map((_, i) => i);
740
- const rows = [];
741
- for (const { seq, by } of seqs) {
742
- const i = eq.findIndex((e) => {
743
- var _a;
744
- return ((_a = e.infusion) == null ? void 0 : _a.seq) === seq && e.infusion.by === by;
745
- });
746
- if (i === -1) continue;
747
- const w = endInfusion(eq, i, registry);
748
- for (const row of w.ended) rows.push({ row, slot: slots[i] });
749
- if (eq[i].infusion.kind === "created") slots = slots.filter((_, j) => j !== i);
750
- eq = w.equipment;
751
- }
752
- return { equipment: eq, ended: rows.map(({ row, slot }) => row.kind === "infused" ? { ...row, index: slots.indexOf(slot) } : row) };
753
- }
754
- function displaced(equipment, resolved, pool, key) {
755
- var _a;
756
- const k = markerKey(key);
757
- const out = equipment.filter((e) => !!e.infusion && markerKey(e.infusion.by) === k).map((e) => ({ seq: e.infusion.seq, by: e.infusion.by }));
758
- const counter = (_a = resolved.infusions) == null ? void 0 : _a.counters.get(pool.id);
759
- if (!counter) return out;
760
- const live = [...resolved.infusions.views.values()].filter((v) => v.poolId === pool.id && v.classIndex === pool.classIndex && v.entity !== null && markerKey(v.key) !== k).sort((a, b) => a.seq - b.seq);
761
- let used = live.length;
762
- for (const v of live) {
763
- if (used + 1 <= counter.max) break;
764
- out.push({ seq: v.seq, by: v.key });
765
- used--;
766
- }
767
- return out;
768
- }
769
- function infuseEntry(character, resolved, registry, req) {
770
- var _a, _b, _c, _d, _e, _f, _g;
771
- const owned = ownedPick(resolved, req.key);
772
- if (!owned) return refuse("not-owned");
773
- const infuse = owned.entry.entity.infuse;
774
- if (!infuse) return refuse("not-infusing");
775
- if (owned.stranded) return refuse("stranded");
776
- const wantsChoice = ((_a = infuse.choice) == null ? void 0 : _a.kind) === "damage-type";
777
- const choice = lc(req.choice);
778
- if (wantsChoice && choice === "") return refuse("choice-required");
779
- if (wantsChoice && !isCanonicalDamageType(choice)) return refuse("bad-choice");
780
- if (wantsChoice && ((_b = infuse.choice) == null ? void 0 : _b.options) && !infuse.choice.options.some((o) => lc(o) === choice)) return refuse("bad-choice");
781
- const equipment = (_c = character.equipment) != null ? _c : [];
782
- const charges = scaledInfuseItem(infuse, (_e = (_d = resolved.classes[owned.pool.classIndex]) == null ? void 0 : _d.level) != null ? _e : 0).charges;
783
- const marker = {
784
- kind: "infused",
785
- by: owned.entry.key,
786
- seq: nextSeq(equipment),
787
- ...wantsChoice ? { choice } : {},
788
- ...charges ? { charges: { current: charges.max } } : {}
789
- };
790
- let placed;
791
- if (typeof req.target === "number") {
792
- const target = equipment[req.target];
793
- if (!target) return refuse("no-target");
794
- if (target.infusion) return refuse("marked");
795
- const verdict = targetVerdict(target, infuse, registry);
796
- if (verdict !== "ok") return refuse(verdict);
797
- const split = ((_f = target.qty) != null ? _f : 1) > 1;
798
- placed = split ? splitOne(equipment, req.target) : [...equipment];
799
- const i = split ? req.target + 1 : req.target;
800
- placed[i] = { ...placed[i], infusion: marker };
801
- } else {
802
- const name = req.target.newObject.trim();
803
- if (name === "") return refuse("no-target");
804
- placed = [...equipment, { ...newObjectEntry(name, infuse, registry, (_g = req.isEntityVisible) != null ? _g : (() => true)), infusion: marker }];
805
- }
806
- return { ok: true, ...endBySeqs(placed, displaced(equipment, resolved, owned.pool, owned.entry.key), registry) };
807
- }
808
- function createEntry(character, resolved, registry, req) {
809
- var _a, _b;
810
- const owned = ownedPick(resolved, req.key);
811
- if (!owned) return refuse("not-owned");
812
- const note = owned.entry.entity;
813
- if (!(note.repeatable === true && !!((_a = note.options) == null ? void 0 : _a.some((r) => !!r.creates)))) return refuse("not-creating");
814
- if (owned.stranded) return refuse("stranded");
815
- const opt = owned.entry.option;
816
- if (!(opt == null ? void 0 : opt.row) || opt.status !== "ok") return refuse("invalid-item");
817
- const it = registry.getByTypeAndSlug("item", linkSlug(req.item.trim()));
818
- if (!it || !(opt.item === it.slug || rowMatches(opt.row, it))) return refuse("invalid-item");
819
- const equipment = (_b = character.equipment) != null ? _b : [];
820
- const placed = [...equipment, { item: `[[${it.slug}]]`, qty: 1, infusion: { kind: "created", by: owned.entry.key, seq: nextSeq(equipment) } }];
821
- return { ok: true, ...endBySeqs(placed, displaced(equipment, resolved, owned.pool, owned.entry.key), registry) };
822
- }
823
- function markersWhere(equipment, pick) {
824
- const out = [];
825
- equipment.forEach((e, index) => {
826
- const m = e.infusion;
827
- if (m && pick(m)) out.push({ index, key: m.by, kind: m.kind, item: e.item, seq: m.seq, by: m.by });
828
- });
829
- return out;
830
- }
831
- var asRows = (list) => list.map(({ index, key, kind, item }) => ({ index, key, kind, item }));
832
- var storedKeys = (v) => typeof v === "string" ? [v] : Array.isArray(v) ? v : [];
833
- function choiceEnds(character, resolved, req) {
834
- var _a, _b, _c, _d, _e, _f;
835
- const pool = ((_a = resolved.pools) != null ? _a : []).find((p) => p.classIndex === req.classIndex && p.id === req.choiceKey);
836
- if (!pool || !(pool.active || pool.selected.some((e) => e.itemBound))) return [];
837
- const choices = (_c = (_b = character.class[req.classIndex]) == null ? void 0 : _b.choices) != null ? _c : {};
838
- const kept = new Set(req.next.map(markerKey));
839
- for (const lvl of Object.keys(choices)) if (Number(lvl) !== req.level) for (const s of storedKeys((_d = choices[Number(lvl)]) == null ? void 0 : _d[req.choiceKey])) kept.add(markerKey(s));
840
- const removed = new Set(storedKeys((_e = choices[req.level]) == null ? void 0 : _e[req.choiceKey]).map(markerKey).filter((k) => !kept.has(k)));
841
- return markersWhere((_f = character.equipment) != null ? _f : [], (m) => removed.has(markerKey(m.by)));
842
- }
843
- function infusionsEndedByChoice(character, resolved, _registry, req) {
844
- return asRows(choiceEnds(character, resolved, req));
845
- }
846
- function reconcileChoiceEdit(character, resolved, registry, req) {
847
- var _a;
848
- const list = choiceEnds(character, resolved, req);
849
- return list.length === 0 ? null : endBySeqs((_a = character.equipment) != null ? _a : [], list, registry);
850
- }
851
- function classEnds(character, resolved, req) {
852
- var _a, _b, _c, _d, _e;
853
- let pools = ((_a = resolved.pools) != null ? _a : []).filter((p) => p.classIndex === req.classIndex);
854
- if (!("remove" in req)) {
855
- const old = (_c = (_b = resolved.classes[req.classIndex]) == null ? void 0 : _b.subclass) != null ? _c : null;
856
- if (!old || req.subclass !== null && bareEntitySlug(linkSlug(req.subclass.trim())) === bareEntitySlug(old.slug)) return [];
857
- const ids = new Set(((_d = old.selection_pools) != null ? _d : []).map((p) => p.id));
858
- pools = pools.filter((p) => ids.has(p.id));
859
- }
860
- const owned = /* @__PURE__ */ new Set();
861
- for (const pool of pools) for (const e of pool.selected) if (e.itemBound) owned.add(pickKeyOf(e));
862
- return markersWhere((_e = character.equipment) != null ? _e : [], (m) => owned.has(markerKey(m.by)));
863
- }
864
- function infusionsEndedByClassEdit(character, resolved, _registry, req) {
865
- return asRows(classEnds(character, resolved, req));
866
- }
867
- function reconcileClassEdit(character, resolved, registry, req) {
868
- var _a;
869
- const list = classEnds(character, resolved, req);
870
- return list.length === 0 ? null : endBySeqs((_a = character.equipment) != null ? _a : [], list, registry);
871
- }
872
- function eligibleTargets(character, resolved, registry, key) {
873
- var _a, _b;
874
- const infuse = (_a = ownedPick(resolved, key)) == null ? void 0 : _a.entry.entity.infuse;
875
- if (!infuse) return [];
876
- const out = [];
877
- ((_b = character.equipment) != null ? _b : []).forEach((e, index) => {
878
- var _a2;
879
- if (!e.infusion && targetVerdict(e, infuse, registry) === "ok") out.push({ index, stack: ((_a2 = e.qty) != null ? _a2 : 1) > 1 });
880
- });
881
- return out;
882
- }
883
-
884
- // src/pc/pc.entry-overrides.ts
885
- var WEAPON_DEFAULT_ACTION_COST = "action";
886
- var linkOf = (item) => {
887
- var _a, _b;
888
- return (_b = (_a = item.match(/^\[\[(.+)\]\]$/)) == null ? void 0 : _a[1]) != null ? _b : null;
889
- };
890
- var ruleOf = (entry, registry, view) => resolveEntryEntity(entry, view ? view.index : -1, registry, view != null ? view : null);
891
- function isWeaponLikeEntry(entry, registry, view) {
892
- if (!registry) return false;
893
- const r = ruleOf(entry, registry, view);
894
- return defaultSlotForType(r.entityType, r.entity, registry) === "mainhand";
895
- }
896
- function itemsRowBranch(entry, registry, view) {
897
- var _a, _b;
898
- const link = linkOf(entry.item);
899
- if (!link || !registry) return false;
900
- const t = view ? view.entityType : (_b = (_a = registry.getBySlug(link)) == null ? void 0 : _a.entityType) != null ? _b : null;
901
- return t !== "weapon" && t !== "armor" && !isWeaponLikeEntry(entry, registry, view);
902
- }
903
- function customizableOverrideKeys(entry, registry) {
904
- const keys = new Set(isConsumedOnUse(entry, registry) ? ["name"] : ["name", "charges", "recovery"]);
905
- if (!registry) return keys;
906
- const r = ruleOf(entry, registry);
907
- const slot = defaultSlotForType(r.entityType, r.entity, registry);
908
- const weaponLike = slot === "mainhand";
909
- const itemsRow = itemsRowBranch(entry, registry);
910
- if (weaponLike) {
911
- keys.add("bonus");
912
- keys.add("damage_bonus");
913
- keys.add("extra_damage");
914
- }
915
- if (slot === "armor" || slot === "shield") keys.add("ac_bonus");
916
- if (weaponLike || itemsRow) keys.add("action");
917
- if (itemsRow) keys.add("range");
918
- if (r.entityType === "item") keys.add("resist");
919
- return keys;
920
- }
921
- function defaultActionCost(entry, registry, view) {
922
- var _a, _b, _c, _d, _e;
923
- if (isWeaponLikeEntry(entry, registry, view)) return WEAPON_DEFAULT_ACTION_COST;
924
- const link = linkOf(entry.item);
925
- if (!link || !registry || !itemsRowBranch(entry, registry, view)) return null;
926
- const withoutOverrides = { ...entry, overrides: void 0 };
927
- const type = view ? (_a = view.entity) == null ? void 0 : _a.type : (_c = (_b = registry.getBySlug(link)) == null ? void 0 : _b.data) == null ? void 0 : _c.type;
928
- return (_e = (_d = resolveItemAction(link, withoutOverrides, type, { view, spellCost: scrollSpellCost(entry, registry) })) == null ? void 0 : _d.cost) != null ? _e : null;
929
- }
930
- var SPELL_COST = { action: "action", bonus: "bonus-action", reaction: "reaction" };
931
- function scrollSpellCost(entry, registry) {
932
- var _a, _b, _c, _d, _e;
933
- const ref = (_a = entry.overrides) == null ? void 0 : _a.spell;
934
- if (!ref || !registry) return void 0;
935
- const castingTime = (_d = (_c = registry.getByTypeAndSlug("spell", (_b = linkOf(ref)) != null ? _b : ref)) == null ? void 0 : _c.data) == null ? void 0 : _d.casting_time;
936
- const kind = typeof castingTime === "string" ? (_e = parseCastingTime(castingTime)) == null ? void 0 : _e.kind : void 0;
937
- return kind ? SPELL_COST[kind] : void 0;
938
- }
939
- var chargesOf = (e) => e == null ? void 0 : e.charges;
940
- function itemChargesMax(entity) {
941
- const c = chargesOf(entity);
942
- if (typeof c === "number") return c > 0 ? c : void 0;
943
- const m = c == null ? void 0 : c.max;
944
- return typeof m === "number" && m > 0 ? m : void 0;
945
- }
946
- var RESET_OF = (r) => {
947
- const s = String(r != null ? r : "").toLowerCase();
948
- return s.includes("dawn") ? "dawn" : s.includes("short") ? "short" : s.includes("long") ? "long" : "special";
949
- };
950
- function rechargeAmount(c) {
951
- var _a, _b;
952
- const raw = [c.recharge_amount, c.dice].find((v) => typeof v === "string" && v.trim() !== "");
953
- if (!raw) return "1";
954
- const bare = raw.trim().replace(/^`+|`+$/g, "");
955
- return ((_b = (_a = parseInlineTag(bare)) == null ? void 0 : _a.content) != null ? _b : bare).replace(/\s+/g, "");
956
- }
957
- var recoveryOf = (c, needRecharge) => !c || typeof c === "number" || needRecharge && (typeof c.recharge !== "string" || c.recharge.trim() === "") ? void 0 : { amount: rechargeAmount(c), reset: RESET_OF(c.recharge) };
958
- function effectiveItemRecovery(entry, registry, view) {
959
- var _a, _b;
960
- if (isConsumedOnUse(entry, registry, view)) return void 0;
961
- if (view && view.entity === null) return void 0;
962
- if ((view == null ? void 0 : view.kind) === "infused" && itemChargesMax(view.entity) !== void 0) return recoveryOf(chargesOf(view.entity), false);
963
- if ((_a = entry.state) == null ? void 0 : _a.recovery) return entry.state.recovery;
964
- const own = registry ? recoveryOf(chargesOf(ruleOf(entry, registry, view).entity), true) : void 0;
965
- if (own) return own;
966
- const link = linkOf(entry.item);
967
- return link ? (_b = findItemAction(link)) == null ? void 0 : _b.recovery : void 0;
968
- }
969
- function isConsumedOnUse(entry, registry, view) {
970
- var _a;
971
- const link = linkOf(entry.item);
972
- if (!link) return false;
973
- if ((_a = findItemAction(link)) == null ? void 0 : _a.consumed) return true;
974
- const entity = entityOf(entry, registry, view);
975
- return (entity == null ? void 0 : entity.type) === "potion" || isScrollEntity(entity);
976
- }
977
- function isScrollEntity(entity) {
978
- if (!entity || typeof entity !== "object") return false;
979
- return entity.type === "scroll" || isCastableScroll(entity);
980
- }
981
- function isCastableScroll(entity) {
982
- return !!entity && typeof entity === "object" && entity.scroll_level != null;
983
- }
984
- function entityOf(entry, registry, view) {
985
- if (!registry || !linkOf(entry.item)) return null;
986
- return ruleOf(entry, registry, view).entity;
987
- }
988
- function effectiveItemCharges(entry, registry, view) {
989
- var _a, _b, _c, _d, _e, _f;
990
- if (isConsumedOnUse(entry, registry, view)) return void 0;
991
- if (view && view.entity === null) return void 0;
992
- const infused = (view == null ? void 0 : view.kind) === "infused" ? itemChargesMax(view.entity) : void 0;
993
- if (infused !== void 0) return { current: Math.max(0, Math.min((_c = (_b = (_a = entry.infusion) == null ? void 0 : _a.charges) == null ? void 0 : _b.current) != null ? _c : infused, infused)), max: infused };
994
- const stored = (_d = entry.state) == null ? void 0 : _d.charges;
995
- if (stored) return stored;
996
- const own = registry ? itemChargesMax(ruleOf(entry, registry, view).entity) : void 0;
997
- if (own !== void 0) return { current: own, max: own };
998
- const link = linkOf(entry.item);
999
- const max = link ? (_f = (_e = findItemAction(link)) == null ? void 0 : _e.max_charges) != null ? _f : 0 : 0;
1000
- return max > 0 ? { current: max, max } : void 0;
1001
- }
1002
- function effectiveItemArmorClass(entry, registry, view) {
1003
- var _a;
1004
- if (!registry) return null;
1005
- const { entity } = ruleOf(entry, registry, view);
1006
- const armor = effectiveArmor(entity, registry);
1007
- if (!armor) return null;
1008
- const shield = isShieldArmor(armor);
1009
- const bonus = isItemEntity(entity) && typeof ((_a = entity.bonuses) == null ? void 0 : _a.ac) === "number" ? entity.bonuses.ac : 0;
1010
- const terms = slotAcTerms(armor, entry);
1011
- return {
1012
- value: terms.armor + terms.override + bonus,
1013
- shield,
1014
- // raw vault data may omit the key (the armour type's `flat` note applies to it too): absent reads as no Dex
1015
- addDex: !shield && armor.ac.add_dex === true
1016
- };
1017
- }
1018
-
1019
- export {
1020
- WEAPON_DEFAULT_ACTION_COST,
1021
- isWeaponLikeEntry,
1022
- customizableOverrideKeys,
1023
- defaultActionCost,
1024
- scrollSpellCost,
1025
- itemChargesMax,
1026
- effectiveItemRecovery,
1027
- isConsumedOnUse,
1028
- isScrollEntity,
1029
- isCastableScroll,
1030
- effectiveItemCharges,
1031
- effectiveItemArmorClass,
1032
- poolCountLabel,
1033
- poolActiveWords,
1034
- parsePickKey,
1035
- normalizedPickKey,
1036
- markerKey,
1037
- isItemBound,
1038
- optionCandidates,
1039
- resolveOptionRows,
1040
- resolveCopyOption,
1041
- scaledInfuseItem,
1042
- resolveEntryEntity,
1043
- buildInfusionContext,
1044
- entryCharges,
1045
- withEntryCharges,
1046
- isMarkedEntry,
1047
- splitOne,
1048
- endInfusion,
1049
- infuseEntry,
1050
- createEntry,
1051
- infusionsEndedByChoice,
1052
- reconcileChoiceEdit,
1053
- infusionsEndedByClassEdit,
1054
- reconcileClassEdit,
1055
- eligibleTargets,
1056
- bindFeatureConsumers,
1057
- levelPrereqMax,
1058
- poolAnchorLevel,
1059
- resolvePool,
1060
- resolveAllPools,
1061
- strandedPicks
1062
- };