@hawkeyexl/manni 4.4.1 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +1 -1
  2. package/dist/batch-OZOACN4G.js +41 -0
  3. package/dist/build-Z5VOVADH.js +32 -0
  4. package/dist/calibrate-TZYT42DR.js +36 -0
  5. package/dist/capture-SL4MNDDP.js +34 -0
  6. package/dist/check-5OMA42Y6.js +26 -0
  7. package/dist/{check-HYNGXYJV.js → check-OAJWC3WD.js} +7 -5
  8. package/dist/{check-ASPIHA6B.js → check-PKY7KTQE.js} +13 -14
  9. package/dist/check-WB2QDHJQ.js +880 -0
  10. package/dist/check-WB2QDHJQ.js.map +1 -0
  11. package/dist/{chunk-MWJLZMBL.js → chunk-2JFPBZJK.js} +11 -11
  12. package/dist/{chunk-QQUKGCAJ.js → chunk-2KRB3EG7.js} +2 -2
  13. package/dist/{chunk-DXNZS72W.js → chunk-2M6DVNI5.js} +10 -6
  14. package/dist/{chunk-DXNZS72W.js.map → chunk-2M6DVNI5.js.map} +1 -1
  15. package/dist/{chunk-QZ6LRSNV.js → chunk-3NWX34ZI.js} +19 -19
  16. package/dist/{chunk-IDV6HJCB.js → chunk-5G53XATW.js} +4 -4
  17. package/dist/{chunk-M2JCK5F6.js → chunk-6KKZXB2O.js} +19 -6
  18. package/dist/chunk-6KKZXB2O.js.map +1 -0
  19. package/dist/{chunk-PNPQTHBT.js → chunk-733Y2STG.js} +2 -2
  20. package/dist/{chunk-WB3QM6PP.js → chunk-73TC4DYH.js} +332 -2522
  21. package/dist/chunk-73TC4DYH.js.map +1 -0
  22. package/dist/{chunk-EPH54CAY.js → chunk-7WRP5FFP.js} +4 -4
  23. package/dist/{chunk-NXV7WE2D.js → chunk-APKH2T6E.js} +29 -591
  24. package/dist/chunk-APKH2T6E.js.map +1 -0
  25. package/dist/{chunk-I2AH3CJJ.js → chunk-B3TS4WRM.js} +17 -15
  26. package/dist/{chunk-I2AH3CJJ.js.map → chunk-B3TS4WRM.js.map} +1 -1
  27. package/dist/chunk-BWCWTHYS.js +146 -0
  28. package/dist/chunk-BWCWTHYS.js.map +1 -0
  29. package/dist/{chunk-MMTSSTG7.js → chunk-C3B2VJNC.js} +2 -2
  30. package/dist/{chunk-PU6DFJMY.js → chunk-C73RSUIC.js} +4 -4
  31. package/dist/chunk-CU57HT2E.js +116 -0
  32. package/dist/chunk-CU57HT2E.js.map +1 -0
  33. package/dist/chunk-CWXZ2MRT.js +222 -0
  34. package/dist/chunk-CWXZ2MRT.js.map +1 -0
  35. package/dist/{chunk-GCQRPUSB.js → chunk-DC5DDJVE.js} +6 -6
  36. package/dist/{chunk-6OYEI2VV.js → chunk-ECVQNGTH.js} +3 -3
  37. package/dist/chunk-FLAO4ZS3.js +502 -0
  38. package/dist/chunk-FLAO4ZS3.js.map +1 -0
  39. package/dist/chunk-FQGLRJGX.js +174 -0
  40. package/dist/chunk-FQGLRJGX.js.map +1 -0
  41. package/dist/{chunk-7UKO3ASZ.js → chunk-GAJIJKET.js} +3 -3
  42. package/dist/{chunk-6JSSEWBG.js → chunk-GREQKO6M.js} +202 -54
  43. package/dist/chunk-GREQKO6M.js.map +1 -0
  44. package/dist/chunk-HX44GB4Z.js +30 -0
  45. package/dist/chunk-HX44GB4Z.js.map +1 -0
  46. package/dist/{chunk-4IUC2MNL.js → chunk-IY7NYNPZ.js} +9 -11
  47. package/dist/{chunk-4IUC2MNL.js.map → chunk-IY7NYNPZ.js.map} +1 -1
  48. package/dist/{chunk-57NEQRVO.js → chunk-KCOFEWV5.js} +8 -6
  49. package/dist/{chunk-57NEQRVO.js.map → chunk-KCOFEWV5.js.map} +1 -1
  50. package/dist/chunk-M2RLHZ4J.js +849 -0
  51. package/dist/chunk-M2RLHZ4J.js.map +1 -0
  52. package/dist/{chunk-NLXTXE5Y.js → chunk-M6GSS72T.js} +185 -33
  53. package/dist/chunk-M6GSS72T.js.map +1 -0
  54. package/dist/{chunk-YTURO7SI.js → chunk-MHM4QEBV.js} +4 -4
  55. package/dist/{chunk-RL5XWQOL.js → chunk-MOWMCEOJ.js} +143 -54
  56. package/dist/chunk-MOWMCEOJ.js.map +1 -0
  57. package/dist/{chunk-C4SQM22E.js → chunk-MWBJ3KTF.js} +13 -11
  58. package/dist/chunk-MWBJ3KTF.js.map +1 -0
  59. package/dist/chunk-N7JSEDSC.js +233 -0
  60. package/dist/chunk-N7JSEDSC.js.map +1 -0
  61. package/dist/{chunk-JCDXE76J.js → chunk-NBMPHD4I.js} +2 -2
  62. package/dist/{chunk-37LP5HMZ.js → chunk-NHHOPZRA.js} +12 -10
  63. package/dist/{chunk-37LP5HMZ.js.map → chunk-NHHOPZRA.js.map} +1 -1
  64. package/dist/{chunk-YB4IBW3M.js → chunk-NTWW7J76.js} +2 -2
  65. package/dist/{chunk-UJCVAWP7.js → chunk-PCFG7E6B.js} +3 -3
  66. package/dist/{chunk-UJCVAWP7.js.map → chunk-PCFG7E6B.js.map} +1 -1
  67. package/dist/{chunk-FBEQCK47.js → chunk-PL4UAF4S.js} +73 -1304
  68. package/dist/chunk-PL4UAF4S.js.map +1 -0
  69. package/dist/chunk-QCHVR4ZM.js +286 -0
  70. package/dist/chunk-QCHVR4ZM.js.map +1 -0
  71. package/dist/{chunk-PIKOVN6W.js → chunk-QW77LCOU.js} +10 -10
  72. package/dist/{chunk-2B7ZNTPV.js → chunk-SM6NOMJS.js} +2 -2
  73. package/dist/chunk-SWSTHZBI.js +2464 -0
  74. package/dist/chunk-SWSTHZBI.js.map +1 -0
  75. package/dist/{chunk-JXLTXMJ7.js → chunk-T6SYGLWR.js} +3 -3
  76. package/dist/{chunk-CK7SKVHR.js → chunk-TBAMBLF3.js} +3 -12
  77. package/dist/chunk-TBAMBLF3.js.map +1 -0
  78. package/dist/chunk-TH4JVQPF.js +133 -0
  79. package/dist/chunk-TH4JVQPF.js.map +1 -0
  80. package/dist/{chunk-QRWGPQKO.js → chunk-TLXE7LYK.js} +4 -4
  81. package/dist/{chunk-M3W7J6MU.js → chunk-TUAAR3MM.js} +3280 -283
  82. package/dist/chunk-TUAAR3MM.js.map +1 -0
  83. package/dist/{chunk-SKSDRUUK.js → chunk-UAKNZVCD.js} +4 -4
  84. package/dist/{chunk-YJOGUXGP.js → chunk-UJSGS2Y5.js} +8 -6
  85. package/dist/{chunk-YJOGUXGP.js.map → chunk-UJSGS2Y5.js.map} +1 -1
  86. package/dist/{chunk-UQISLDAV.js → chunk-UWQ2UVHE.js} +8 -6
  87. package/dist/{chunk-UQISLDAV.js.map → chunk-UWQ2UVHE.js.map} +1 -1
  88. package/dist/chunk-WQWKYAAK.js +86 -0
  89. package/dist/chunk-WQWKYAAK.js.map +1 -0
  90. package/dist/{chunk-LJ2RDH3F.js → chunk-XG6PVB5S.js} +1 -23
  91. package/dist/chunk-XG6PVB5S.js.map +1 -0
  92. package/dist/{chunk-Q35YIDBV.js → chunk-XKBEHKWO.js} +29 -264
  93. package/dist/chunk-XKBEHKWO.js.map +1 -0
  94. package/dist/chunk-XPEWUK7J.js +532 -0
  95. package/dist/chunk-XPEWUK7J.js.map +1 -0
  96. package/dist/{chunk-MYMBCTDE.js → chunk-XXDXIIQ4.js} +2 -2
  97. package/dist/chunk-YGFIQ6Y5.js +17 -0
  98. package/dist/chunk-YGFIQ6Y5.js.map +1 -0
  99. package/dist/chunk-YLK2J5YK.js +610 -0
  100. package/dist/chunk-YLK2J5YK.js.map +1 -0
  101. package/dist/{chunk-3VK37OR2.js → chunk-Z4IZGEM3.js} +16 -12
  102. package/dist/{chunk-3VK37OR2.js.map → chunk-Z4IZGEM3.js.map} +1 -1
  103. package/dist/{cli-6HIDIFVT.js → cli-6EWVMEN6.js} +5 -3
  104. package/dist/{cli-6HIDIFVT.js.map → cli-6EWVMEN6.js.map} +1 -1
  105. package/dist/{cli-VI7VHWNZ.js → cli-6H7HVDMQ.js} +113 -20
  106. package/dist/{cli-VI7VHWNZ.js.map → cli-6H7HVDMQ.js.map} +1 -1
  107. package/dist/{cli-RPM5PELX.js → cli-EPVZHAZS.js} +24 -20
  108. package/dist/cli-EPVZHAZS.js.map +1 -0
  109. package/dist/{cli-MN7PYMBI.js → cli-LUCSGTVI.js} +17 -19
  110. package/dist/{cli-MN7PYMBI.js.map → cli-LUCSGTVI.js.map} +1 -1
  111. package/dist/{cli-LFP5ZGYS.js → cli-NIG4N3XM.js} +16 -15
  112. package/dist/{cli-LFP5ZGYS.js.map → cli-NIG4N3XM.js.map} +1 -1
  113. package/dist/{cli-PYPX6O6E.js → cli-PSKNB66T.js} +225 -58
  114. package/dist/cli-PSKNB66T.js.map +1 -0
  115. package/dist/{cli-3BIBYHFK.js → cli-UO4NHIB3.js} +17 -17
  116. package/dist/{cli-6UB5N6CU.js → cli-UQ7A3YA2.js} +17 -18
  117. package/dist/{cli-6UB5N6CU.js.map → cli-UQ7A3YA2.js.map} +1 -1
  118. package/dist/{cli-673OTRGE.js → cli-YHYDLQAF.js} +10 -10
  119. package/dist/cli.js +11 -11
  120. package/dist/config-P4HDNTYD.js +26 -0
  121. package/dist/conformance-ZFCMKM6M.js +18 -0
  122. package/dist/docmeta.js +9 -9
  123. package/dist/github-7ZCH5PSO.js +26 -0
  124. package/dist/github-POT6724K.js +31 -0
  125. package/dist/host-6GURH5HE.js +23 -0
  126. package/dist/index.d.ts +102 -12
  127. package/dist/index.js +185 -171
  128. package/dist/index.js.map +1 -1
  129. package/dist/{json-SY7KLNC7.js → json-KT2K62L5.js} +12 -13
  130. package/dist/lint-5AQ5C2BV.js +29 -0
  131. package/dist/list-5JZKX2NK.js +28 -0
  132. package/dist/list-SWPFXQMU.js +30 -0
  133. package/dist/{page-KSGV5RD4.js → page-UPSXRP75.js} +11 -12
  134. package/dist/prepare-6GNEWCNH.js +155 -0
  135. package/dist/prepare-6GNEWCNH.js.map +1 -0
  136. package/dist/{pretty-CXSDXNAS.js → pretty-Q6FQAOK4.js} +13 -14
  137. package/dist/{pretty-A5EGTN35.js → pretty-SQRPFPSQ.js} +12 -13
  138. package/dist/provider-AMGRDY6V.js +34 -0
  139. package/dist/release-IECYCLTD.js +36 -0
  140. package/dist/release-IECYCLTD.js.map +1 -0
  141. package/dist/{reporters-HUY7UXFS.js → reporters-45MMC2ID.js} +13 -13
  142. package/dist/{reporters-K2VUKSAK.js → reporters-XUV4MM64.js} +7 -5
  143. package/dist/reporters-XUV4MM64.js.map +1 -0
  144. package/dist/run-KMWY2IAN.js +32 -0
  145. package/dist/run-KMWY2IAN.js.map +1 -0
  146. package/dist/{term-BIQUPMOR.js → term-PCJUCWNF.js} +16 -17
  147. package/dist/{term-BIQUPMOR.js.map → term-PCJUCWNF.js.map} +1 -1
  148. package/dist/validate-IMNCZNWG.js +17 -0
  149. package/dist/validate-IMNCZNWG.js.map +1 -0
  150. package/package.json +2 -2
  151. package/plugin/manni/.claude-plugin/plugin.json +1 -1
  152. package/plugin/manni/hooks/hooks.json +47 -0
  153. package/dist/batch-GFNLTGOH.js +0 -36
  154. package/dist/build-COYIQ25L.js +0 -31
  155. package/dist/calibrate-MDBLJKEE.js +0 -31
  156. package/dist/capture-LRML2PKV.js +0 -32
  157. package/dist/check-EDLBYL5N.js +0 -27
  158. package/dist/chunk-6JSSEWBG.js.map +0 -1
  159. package/dist/chunk-A5ULMVHQ.js +0 -164
  160. package/dist/chunk-A5ULMVHQ.js.map +0 -1
  161. package/dist/chunk-C4SQM22E.js.map +0 -1
  162. package/dist/chunk-CK7SKVHR.js.map +0 -1
  163. package/dist/chunk-FBEQCK47.js.map +0 -1
  164. package/dist/chunk-LJ2RDH3F.js.map +0 -1
  165. package/dist/chunk-M2JCK5F6.js.map +0 -1
  166. package/dist/chunk-M3W7J6MU.js.map +0 -1
  167. package/dist/chunk-NLXTXE5Y.js.map +0 -1
  168. package/dist/chunk-NXV7WE2D.js.map +0 -1
  169. package/dist/chunk-Q35YIDBV.js.map +0 -1
  170. package/dist/chunk-RL5XWQOL.js.map +0 -1
  171. package/dist/chunk-TK3FC4RF.js +0 -3090
  172. package/dist/chunk-TK3FC4RF.js.map +0 -1
  173. package/dist/chunk-TU2WUBVZ.js +0 -2
  174. package/dist/chunk-WB3QM6PP.js.map +0 -1
  175. package/dist/cli-PYPX6O6E.js.map +0 -1
  176. package/dist/cli-RPM5PELX.js.map +0 -1
  177. package/dist/github-6QMYOHC3.js +0 -27
  178. package/dist/github-SXPGP5DB.js +0 -32
  179. package/dist/lint-ASMJLLPA.js +0 -28
  180. package/dist/list-KZNVTNVC.js +0 -31
  181. package/dist/list-Q57YTFUQ.js +0 -29
  182. package/dist/run-3DYJNRIG.js +0 -33
  183. package/dist/validate-53RKM2XG.js +0 -16
  184. /package/dist/{batch-GFNLTGOH.js.map → batch-OZOACN4G.js.map} +0 -0
  185. /package/dist/{build-COYIQ25L.js.map → build-Z5VOVADH.js.map} +0 -0
  186. /package/dist/{calibrate-MDBLJKEE.js.map → calibrate-TZYT42DR.js.map} +0 -0
  187. /package/dist/{capture-LRML2PKV.js.map → capture-SL4MNDDP.js.map} +0 -0
  188. /package/dist/{check-ASPIHA6B.js.map → check-5OMA42Y6.js.map} +0 -0
  189. /package/dist/{check-EDLBYL5N.js.map → check-OAJWC3WD.js.map} +0 -0
  190. /package/dist/{check-HYNGXYJV.js.map → check-PKY7KTQE.js.map} +0 -0
  191. /package/dist/{chunk-MWJLZMBL.js.map → chunk-2JFPBZJK.js.map} +0 -0
  192. /package/dist/{chunk-QQUKGCAJ.js.map → chunk-2KRB3EG7.js.map} +0 -0
  193. /package/dist/{chunk-QZ6LRSNV.js.map → chunk-3NWX34ZI.js.map} +0 -0
  194. /package/dist/{chunk-IDV6HJCB.js.map → chunk-5G53XATW.js.map} +0 -0
  195. /package/dist/{chunk-PNPQTHBT.js.map → chunk-733Y2STG.js.map} +0 -0
  196. /package/dist/{chunk-EPH54CAY.js.map → chunk-7WRP5FFP.js.map} +0 -0
  197. /package/dist/{chunk-MMTSSTG7.js.map → chunk-C3B2VJNC.js.map} +0 -0
  198. /package/dist/{chunk-PU6DFJMY.js.map → chunk-C73RSUIC.js.map} +0 -0
  199. /package/dist/{chunk-GCQRPUSB.js.map → chunk-DC5DDJVE.js.map} +0 -0
  200. /package/dist/{chunk-6OYEI2VV.js.map → chunk-ECVQNGTH.js.map} +0 -0
  201. /package/dist/{chunk-7UKO3ASZ.js.map → chunk-GAJIJKET.js.map} +0 -0
  202. /package/dist/{chunk-YTURO7SI.js.map → chunk-MHM4QEBV.js.map} +0 -0
  203. /package/dist/{chunk-JCDXE76J.js.map → chunk-NBMPHD4I.js.map} +0 -0
  204. /package/dist/{chunk-YB4IBW3M.js.map → chunk-NTWW7J76.js.map} +0 -0
  205. /package/dist/{chunk-PIKOVN6W.js.map → chunk-QW77LCOU.js.map} +0 -0
  206. /package/dist/{chunk-2B7ZNTPV.js.map → chunk-SM6NOMJS.js.map} +0 -0
  207. /package/dist/{chunk-JXLTXMJ7.js.map → chunk-T6SYGLWR.js.map} +0 -0
  208. /package/dist/{chunk-QRWGPQKO.js.map → chunk-TLXE7LYK.js.map} +0 -0
  209. /package/dist/{chunk-SKSDRUUK.js.map → chunk-UAKNZVCD.js.map} +0 -0
  210. /package/dist/{chunk-MYMBCTDE.js.map → chunk-XXDXIIQ4.js.map} +0 -0
  211. /package/dist/{cli-3BIBYHFK.js.map → cli-UO4NHIB3.js.map} +0 -0
  212. /package/dist/{chunk-TU2WUBVZ.js.map → cli-YHYDLQAF.js.map} +0 -0
  213. /package/dist/{cli-673OTRGE.js.map → config-P4HDNTYD.js.map} +0 -0
  214. /package/dist/{github-6QMYOHC3.js.map → conformance-ZFCMKM6M.js.map} +0 -0
  215. /package/dist/{github-SXPGP5DB.js.map → github-7ZCH5PSO.js.map} +0 -0
  216. /package/dist/{json-SY7KLNC7.js.map → github-POT6724K.js.map} +0 -0
  217. /package/dist/{lint-ASMJLLPA.js.map → host-6GURH5HE.js.map} +0 -0
  218. /package/dist/{list-KZNVTNVC.js.map → json-KT2K62L5.js.map} +0 -0
  219. /package/dist/{list-Q57YTFUQ.js.map → lint-5AQ5C2BV.js.map} +0 -0
  220. /package/dist/{page-KSGV5RD4.js.map → list-5JZKX2NK.js.map} +0 -0
  221. /package/dist/{pretty-A5EGTN35.js.map → list-SWPFXQMU.js.map} +0 -0
  222. /package/dist/{pretty-CXSDXNAS.js.map → page-UPSXRP75.js.map} +0 -0
  223. /package/dist/{reporters-HUY7UXFS.js.map → pretty-Q6FQAOK4.js.map} +0 -0
  224. /package/dist/{reporters-K2VUKSAK.js.map → pretty-SQRPFPSQ.js.map} +0 -0
  225. /package/dist/{run-3DYJNRIG.js.map → provider-AMGRDY6V.js.map} +0 -0
  226. /package/dist/{validate-53RKM2XG.js.map → reporters-45MMC2ID.js.map} +0 -0
@@ -6,10 +6,10 @@ import {
6
6
  shortPin,
7
7
  shortSrc,
8
8
  spellAt
9
- } from "./chunk-SKSDRUUK.js";
9
+ } from "./chunk-UAKNZVCD.js";
10
10
  import {
11
11
  parseSrc
12
- } from "./chunk-YTURO7SI.js";
12
+ } from "./chunk-MHM4QEBV.js";
13
13
  import {
14
14
  palette
15
15
  } from "./chunk-RNVYGWIC.js";
@@ -452,4 +452,4 @@ export {
452
452
  removalLine,
453
453
  renderRemovePretty
454
454
  };
455
- //# sourceMappingURL=chunk-JXLTXMJ7.js.map
455
+ //# sourceMappingURL=chunk-T6SYGLWR.js.map
@@ -1,15 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- ToolError
4
- } from "./chunk-G3T47CFV.js";
5
-
6
- // src/lint/types.ts
7
- var LintError = class extends ToolError {
8
- constructor(message) {
9
- super(message);
10
- this.name = "LintError";
11
- }
12
- };
3
+ LintError
4
+ } from "./chunk-YGFIQ6Y5.js";
13
5
 
14
6
  // src/lint/rules/paragraphs.ts
15
7
  function checkParagraphsIn(content, rule, ctx) {
@@ -1025,7 +1017,6 @@ function matchSections(sections, rules, options = {}) {
1025
1017
  }
1026
1018
 
1027
1019
  export {
1028
- LintError,
1029
1020
  checkHeading,
1030
1021
  checkSequence,
1031
1022
  checkSequenceIn,
@@ -1039,4 +1030,4 @@ export {
1039
1030
  headingMatches,
1040
1031
  matchSections
1041
1032
  };
1042
- //# sourceMappingURL=chunk-CK7SKVHR.js.map
1033
+ //# sourceMappingURL=chunk-TBAMBLF3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lint/rules/paragraphs.ts","../src/lint/rules/code-blocks.ts","../src/lint/rules/tables.ts","../src/lint/rules/admonitions.ts","../src/lint/rules/images.ts","../src/lint/rules/blockquotes.ts","../src/lint/rules/definition-lists.ts","../src/lint/rules/sequence.ts","../src/lint/rules/elements.ts","../src/lint/rules/contains.ts","../src/lint/rules/lists.ts","../src/lint/rules/index.ts","../src/lint/rules/heading.ts","../src/lint/core/template.ts","../src/lint/core/match.ts"],"sourcesContent":["/**\n * `paragraphs:` - paragraph counts and a per-paragraph pattern.\n *\n * v1 took a cycling `patterns: string[]`; v2 simplifies to one `pattern`\n * every paragraph in the run must match, per proposal 0061's block-rule\n * vocabulary.\n */\n\nimport type { ContentNode, Finding, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n compilePattern,\n paragraphsOf,\n sectionContext,\n type ParagraphsRule,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the paragraphs a section holds directly. */\nexport function checkParagraphs(\n section: SectionNode,\n rule: ParagraphsRule | undefined,\n): Finding[] {\n return checkParagraphsIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks the paragraphs in any ordered content list.\n *\n * Used for a section's own content, for a list item's `children`, and for one\n * run of a `sequence`. `ctx` says where count findings land and what heading\n * they carry.\n */\nexport function checkParagraphsIn(\n content: ContentNode[],\n rule: ParagraphsRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const paragraphs = paragraphsOf(content);\n const findings = checkCount(\n paragraphs.length,\n rule,\n \"paragraph\",\n \"paragraphs_count_error\",\n ctx,\n );\n\n const pattern = rule.pattern;\n if (pattern) {\n const regex = compilePattern(pattern);\n paragraphs.forEach((paragraph, index) => {\n if (!regex.test(paragraph.text)) {\n findings.push({\n type: \"paragraphs_pattern_error\",\n heading: ctx.heading,\n message: `Paragraph ${index + 1} does not match /${pattern}/`,\n position: paragraph.position,\n severity: \"error\",\n });\n }\n });\n }\n\n return findings;\n}\n","/**\n * `codeBlocks:` - code block counts, the language(s) every block must\n * declare, and a `fenceInfo` filter over the info-string tail.\n *\n * `language` reports per offending block (every code block must declare one\n * of the accepted languages), the same way v1 reported nothing about\n * language at all - this is new in v2. `fenceInfo` has no message form of its\n * own in proposal 0061's table, so it narrows which blocks count toward\n * `min`/`max` instead, the way `elements.tag` does.\n */\n\nimport type { CodeNode, ContentNode, Finding, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n codeBlocksOf,\n compilePattern,\n sectionContext,\n type CodeBlocksRule,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the code blocks a section holds directly. */\nexport function checkCodeBlocks(\n section: SectionNode,\n rule: CodeBlocksRule | undefined,\n): Finding[] {\n return checkCodeBlocksIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks the code blocks in any ordered content list -\n * a section's content, a list item's `children`, or one run of a `sequence`.\n */\nexport function checkCodeBlocksIn(\n content: ContentNode[],\n rule: CodeBlocksRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const codeBlocks = codeBlocksOf(content);\n const counted = rule.fenceInfo\n ? codeBlocks.filter((block) => matchesFenceInfo(block, rule.fenceInfo as string))\n : codeBlocks;\n\n const findings = checkCount(\n counted.length,\n rule,\n \"code block\",\n \"code_blocks_count_error\",\n ctx,\n );\n\n if (rule.language) {\n findings.push(...checkLanguages(codeBlocks, rule.language, ctx));\n }\n\n return findings;\n}\n\nfunction matchesFenceInfo(block: CodeNode, pattern: string): boolean {\n return compilePattern(pattern).test(block.fenceInfo ?? \"\");\n}\n\n/** Every code block in the run must declare one of the accepted languages. */\nfunction checkLanguages(\n codeBlocks: CodeNode[],\n language: string | string[],\n ctx: RuleContext,\n): Finding[] {\n const languages = Array.isArray(language) ? language : [language];\n const only = languages[0];\n if (languages.length === 0 || only === undefined) return [];\n\n const label =\n languages.length === 1\n ? `\"${only}\"`\n : `one of ${languages.map((lang) => `\"${lang}\"`).join(\", \")}`;\n\n const findings: Finding[] = [];\n codeBlocks.forEach((block, index) => {\n if (block.language !== undefined && languages.includes(block.language)) return;\n\n const found = block.language ? `but found \"${block.language}\"` : \"but found no language\";\n findings.push({\n type: \"code_blocks_language_error\",\n heading: ctx.heading,\n message: `Expected code block ${index + 1} to declare ${label}, ${found}`,\n position: block.position,\n severity: \"error\",\n });\n });\n\n return findings;\n}\n","/**\n * `tables:` - table counts and the header cells every table must carry.\n *\n * `columns` is diagnostic, not a count filter: every table in the run counts\n * toward `min`/`max` whether or not its columns match, and a mismatch is\n * reported once per offending table (the same treatment `codeBlocks.language`\n * and `admonitions.variant` get, and unlike `codeBlocks.fenceInfo`, which has\n * no message form and narrows the count instead).\n */\n\nimport type { ContentNode, Finding, SectionNode, TableNode } from \"../types.js\";\nimport {\n checkCount,\n quoteList,\n sectionContext,\n tablesOf,\n type RuleContext,\n type TablesRule,\n} from \"./index.js\";\n\n/** Checks the tables a section holds directly. */\nexport function checkTables(\n section: SectionNode,\n rule: TablesRule | undefined,\n): Finding[] {\n return checkTablesIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the tables in any ordered content list. */\nexport function checkTablesIn(\n content: ContentNode[],\n rule: TablesRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const tables = tablesOf(content);\n const findings = checkCount(tables.length, rule, \"table\", \"tables_count_error\", ctx);\n\n if (rule.columns) {\n for (const table of tables) {\n const actual = headerCells(table);\n if (!sameColumns(actual, rule.columns)) {\n findings.push({\n type: \"tables_columns_error\",\n heading: ctx.heading,\n message: `Expected table columns ${quoteList(rule.columns)}, but found ${quoteList(actual)}`,\n position: table.position,\n severity: \"error\",\n });\n }\n }\n }\n\n return findings;\n}\n\nfunction headerCells(table: TableNode): string[] {\n const header = table.children.find((row) => row.header);\n return header ? header.children.map((cell) => cell.text) : [];\n}\n\nfunction sameColumns(actual: string[], expected: string[]): boolean {\n return actual.length === expected.length && actual.every((cell, index) => cell === expected[index]);\n}\n","/**\n * `admonitions:` - admonition counts and the variant every admonition must\n * carry.\n *\n * `variant` is diagnostic, not a count filter, for the same reason\n * `tables.columns` is: every admonition counts toward `min`/`max` regardless,\n * and a mismatch is reported once per offending admonition.\n */\n\nimport type { AdmonitionNode, ContentNode, Finding, SectionNode } from \"../types.js\";\nimport {\n admonitionsOf,\n checkCount,\n sectionContext,\n type AdmonitionsRule,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the admonitions a section holds directly. */\nexport function checkAdmonitions(\n section: SectionNode,\n rule: AdmonitionsRule | undefined,\n): Finding[] {\n return checkAdmonitionsIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the admonitions in any ordered content list. */\nexport function checkAdmonitionsIn(\n content: ContentNode[],\n rule: AdmonitionsRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const admonitions = admonitionsOf(content);\n const findings = checkCount(\n admonitions.length,\n rule,\n \"admonition\",\n \"admonitions_count_error\",\n ctx,\n );\n\n if (rule.variant) {\n findings.push(...checkVariant(admonitions, rule.variant, ctx));\n }\n\n return findings;\n}\n\nfunction checkVariant(\n admonitions: AdmonitionNode[],\n variant: NonNullable<AdmonitionsRule[\"variant\"]>,\n ctx: RuleContext,\n): Finding[] {\n const findings: Finding[] = [];\n for (const admonition of admonitions) {\n if (admonition.variant !== variant) {\n // A format may name a flavor this vocabulary does not have, or none at\n // all: reStructuredText's `hint`, a bare HTML `<aside>`. The node then\n // carries no variant, and saying \"found a undefined\" would be worse\n // than saying what is true.\n const found = admonition.variant\n ? `but found a ${admonition.variant}`\n : \"but found one with no type\";\n findings.push({\n type: \"admonitions_variant_error\",\n heading: ctx.heading,\n message: `Expected a ${variant} admonition, ${found}`,\n position: admonition.position,\n severity: \"error\",\n });\n }\n }\n return findings;\n}\n","/**\n * `images:` - how many images, filtered by `url`, `alt`, and `attributes`.\n *\n * All three narrow the counted set rather than reporting their own finding -\n * proposal 0061's message table gives `images` only `images_count_error`, no\n * per-field diagnostic the way `elements.attributes` gets one. `attributes`\n * in particular can never match: `ImageNode` carries no `attributes` of its\n * own (the node model gave that field to `element` only), so any non-empty\n * `attributes` requirement here excludes every image, same as an image whose\n * `url` or `alt` does not match.\n */\n\nimport type { ContentNode, Finding, ImageNode, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n imagesOf,\n sectionContext,\n type ImagesRule,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the images a section holds directly. */\nexport function checkImages(\n section: SectionNode,\n rule: ImagesRule | undefined,\n): Finding[] {\n return checkImagesIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the images in any ordered content list. */\nexport function checkImagesIn(\n content: ContentNode[],\n rule: ImagesRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const matching = imagesOf(content).filter((image) => matches(image, rule));\n return checkCount(matching.length, rule, \"image\", \"images_count_error\", ctx);\n}\n\nfunction matches(image: ImageNode, rule: ImagesRule): boolean {\n if (rule.url !== undefined && image.url !== rule.url) return false;\n if (rule.alt !== undefined && image.alt !== rule.alt) return false;\n if (rule.attributes && Object.keys(rule.attributes).length > 0) return false;\n return true;\n}\n","/** `blockquotes:` - a plain count, the schema's `counted` shape. */\n\nimport type { ContentNode, Finding, SectionNode } from \"../types.js\";\nimport { blockquotesOf, checkCount, sectionContext, type Occurrences, type RuleContext } from \"./index.js\";\n\n/** Checks the blockquotes a section holds directly. */\nexport function checkBlockquotes(\n section: SectionNode,\n rule: Occurrences | undefined,\n): Finding[] {\n return checkBlockquotesIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the blockquotes in any ordered content list. */\nexport function checkBlockquotesIn(\n content: ContentNode[],\n rule: Occurrences | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n return checkCount(blockquotesOf(content).length, rule, \"blockquote\", \"blockquotes_count_error\", ctx);\n}\n","/** `definitionLists:` - a plain count, the schema's `counted` shape. */\n\nimport type { ContentNode, Finding, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n definitionListsOf,\n sectionContext,\n type Occurrences,\n type RuleContext,\n} from \"./index.js\";\n\n/** Checks the definition lists a section holds directly. */\nexport function checkDefinitionLists(\n section: SectionNode,\n rule: Occurrences | undefined,\n): Finding[] {\n return checkDefinitionListsIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the definition lists in any ordered content list. */\nexport function checkDefinitionListsIn(\n content: ContentNode[],\n rule: Occurrences | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n return checkCount(\n definitionListsOf(content).length,\n rule,\n \"definition list\",\n \"definition_lists_count_error\",\n ctx,\n );\n}\n","/**\n * `sequence:` - the ordered runs of content a section (or an element's or\n * list item's own content) must hold.\n *\n * Content arrives flat and in document order, so consecutive nodes of the\n * same kind are first grouped into runs: `[p, p, code, table]` becomes three\n * runs (paragraph, codeBlock, table). Those runs are then matched\n * positionally against the template's sequence, and each run is handed to\n * `checkContainsIn` for its one set key.\n *\n * v1 reported a length mismatch and an order mismatch as two finding types,\n * `sequence_length_error` and `sequence_order_error`. v2 collapses both into\n * one `content_order_error`: the message states the full expected and actual\n * kind lists, which communicates a length difference as plainly as an order\n * one, and a template widening from three kinds to nine does not need a\n * matching widening of finding types. The bail-on-mismatch behavior stays -\n * once the runs are the wrong shape, per-run findings are noise about\n * content the author has not arranged yet.\n */\n\nimport type { ContentKind, ContentNode, Finding, Position, SectionNode } from \"../types.js\";\nimport { BLOCK_KINDS, sectionContext, type BlockKind, type BlockRule, type RuleContext } from \"./index.js\";\nimport { checkContainsIn } from \"./contains.js\";\n\n/** A maximal stretch of consecutive content nodes sharing one kind. */\nexport interface ContentRun {\n kind: ContentKind;\n nodes: ContentNode[];\n /** First node's start through last node's end. */\n position: Position;\n}\n\n/** Groups consecutive same-kind nodes into runs, preserving document order. */\nexport function groupRuns(content: ContentNode[]): ContentRun[] {\n const runs: ContentRun[] = [];\n\n for (const node of content) {\n const current = runs[runs.length - 1];\n if (current && current.kind === node.kind) {\n current.nodes.push(node);\n current.position = {\n start: current.position.start,\n end: node.position.end,\n };\n } else {\n runs.push({\n kind: node.kind,\n nodes: [node],\n position: { start: node.position.start, end: node.position.end },\n });\n }\n }\n\n return runs;\n}\n\n/** The content kind a block-rule key names, e.g. `codeBlocks` -> `codeBlock`. */\nconst KIND_OF_BLOCK: Record<BlockKind, ContentKind> = {\n paragraphs: \"paragraph\",\n codeBlocks: \"codeBlock\",\n lists: \"list\",\n tables: \"table\",\n admonitions: \"admonition\",\n images: \"image\",\n blockquotes: \"blockquote\",\n definitionLists: \"definitionList\",\n elements: \"element\",\n};\n\n/** The short noun a `content_order_error` message uses for one kind. */\nfunction sequenceLabel(kind: ContentKind): string {\n switch (kind) {\n case \"paragraph\":\n return \"paragraph\";\n case \"codeBlock\":\n return \"code\";\n case \"list\":\n return \"list\";\n case \"table\":\n return \"table\";\n case \"admonition\":\n return \"admonition\";\n case \"image\":\n return \"image\";\n case \"blockquote\":\n return \"blockquote\";\n case \"definitionList\":\n return \"definition list\";\n case \"element\":\n return \"element\";\n default:\n // tableRow/tableCell/definitionItem/listItem never appear as a top-level\n // ContentNode.kind; groupRuns only ever sees the nine kinds above.\n return kind;\n }\n}\n\n/** The one key set on a `sequence:` entry, or `null` for a malformed one. */\nfunction keyOf(entry: BlockRule): BlockKind | null {\n for (const kind of BLOCK_KINDS) {\n if (entry[kind] !== undefined) return kind;\n }\n return null;\n}\n\n/** Checks a section's own content against a `sequence:` rule. */\nexport function checkSequence(\n section: SectionNode,\n rule: BlockRule[] | undefined,\n): Finding[] {\n return checkSequenceIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks any ordered content list against a `sequence:`\n * rule - a section's content, a list item's `children`, or an element's own\n * `children`.\n */\nexport function checkSequenceIn(\n content: ContentNode[],\n rule: BlockRule[] | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const runs = groupRuns(content);\n const expectedKinds = rule.map((entry) => {\n const key = keyOf(entry);\n return key ? KIND_OF_BLOCK[key] : null;\n });\n const actualKinds = runs.map((run) => run.kind);\n\n const matches =\n expectedKinds.length === actualKinds.length &&\n expectedKinds.every((kind, index) => kind === actualKinds[index]);\n\n if (!matches) {\n const expected = expectedKinds.map((kind) => (kind ? sequenceLabel(kind) : \"?\"));\n const found = actualKinds.length > 0 ? actualKinds.map(sequenceLabel) : [\"nothing\"];\n return [\n {\n type: \"content_order_error\",\n heading: ctx.heading,\n message: `Expected ${expected.join(\" then \")}, but found ${found.join(\" then \")}`,\n position: ctx.position,\n severity: \"error\",\n },\n ];\n }\n\n const findings: Finding[] = [];\n runs.forEach((run, index) => {\n const entry = rule[index];\n if (!entry) return;\n const runCtx: RuleContext = { heading: ctx.heading, position: run.position };\n // A run holds one kind, so `checkContainsIn` sees exactly the nodes in\n // this stretch, not the section's other content of the same kind - the\n // entry has only that one key set, so every other dispatch is a no-op.\n findings.push(...checkContainsIn(run.nodes, entry, runCtx));\n });\n\n return findings;\n}\n","/**\n * `elements:` - named-wrapper counts, filtered and labeled by `tag`, the\n * literal `attributes` a matched element must carry, and what it holds via\n * `sequence` | `contains` recursing into the element's own `children` -\n * never the enclosing section's, per proposal 0065 stress test 4.\n *\n * `tag` narrows the counted set the way `codeBlocks.fenceInfo` and\n * `images.url`/`alt` do, and also names the noun in count messages: `elements:\n * { tag: \"Steps\", min: 1 }` reports `Expected at least 1 \"Steps\" element, but\n * found 0`, not the generic `\"element\"`. `attributes` is diagnostic instead,\n * checked per matched element and reported once per offending attribute.\n */\n\nimport type { ContentNode, ElementNode, Finding, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n elementsOf,\n sectionContext,\n type AttributesRule,\n type ElementsRule,\n type RuleContext,\n} from \"./index.js\";\nimport { checkContainsIn } from \"./contains.js\";\nimport { checkSequenceIn } from \"./sequence.js\";\n\n/** Checks the elements a section holds directly. */\nexport function checkElements(\n section: SectionNode,\n rule: ElementsRule | undefined,\n): Finding[] {\n return checkElementsIn(section.children, rule, sectionContext(section));\n}\n\n/** The reusable core: checks the elements in any ordered content list. */\nexport function checkElementsIn(\n content: ContentNode[],\n rule: ElementsRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const tags = rule.tag === undefined ? undefined : Array.isArray(rule.tag) ? rule.tag : [rule.tag];\n const matching = tags ? elementsOf(content).filter((element) => tags.includes(element.name)) : elementsOf(content);\n\n // \"or\", not a comma list: the count applies to one combined label, so\n // `\"Note\", \"Tip\" element` reads as two nouns with a singular verb where\n // `\"Note\" or \"Tip\" element` reads as the one thing being counted.\n const noun = tags\n ? `${tags.map((tag) => `\"${tag}\"`).join(\" or \")} element`\n : \"element\";\n const findings = checkCount(matching.length, rule, noun, \"elements_count_error\", ctx);\n\n if (rule.attributes) {\n for (const element of matching) {\n findings.push(...checkAttributes(element, rule.attributes, ctx));\n }\n }\n\n // Both, unconditionally, as `validator.ts` runs them against a section. Each\n // no-ops on an absent rule, and the schema refuses a rule that writes both\n // (`oneOfSequenceOrContains`), so only one can ever fire. Writing it as a\n // choice made this file's behaviour depend on a constraint declared in\n // another, which reads like a silent drop whether or not it is one.\n if (rule.sequence || rule.contains) {\n for (const element of matching) {\n const elementCtx: RuleContext = { heading: ctx.heading, position: element.position };\n findings.push(...checkSequenceIn(element.children, rule.sequence, elementCtx));\n findings.push(...checkContainsIn(element.children, rule.contains, elementCtx));\n }\n }\n\n return findings;\n}\n\n/**\n * `true` requires presence (any value); `false` requires absence; a string\n * is the required literal value. An element's own `attributes` map values a\n * dynamic (JSX-expression) attribute as `true` too, since its literal value\n * cannot be known statically - `checkOne` tells that apart from \"absent\" by\n * checking membership before comparing values.\n */\nfunction checkAttributes(\n element: ElementNode,\n rule: AttributesRule,\n ctx: RuleContext,\n): Finding[] {\n const findings: Finding[] = [];\n for (const [key, expected] of Object.entries(rule)) {\n const finding = checkOne(element, key, expected, ctx);\n if (finding) findings.push(finding);\n }\n return findings;\n}\n\nfunction checkOne(\n element: ElementNode,\n key: string,\n expected: string | boolean,\n ctx: RuleContext,\n): Finding | null {\n const attributes = element.attributes ?? {};\n const present = key in attributes;\n const actual = attributes[key];\n\n const fail = (want: string, detail: string): Finding => ({\n type: \"elements_attribute_error\",\n heading: ctx.heading,\n message: `Expected the \"${element.name}\" element ${want}, but ${detail}`,\n position: element.position,\n severity: \"error\",\n });\n\n if (expected === false) {\n if (!present) return null;\n const found = actual === true ? `an expression` : `${key}=\"${String(actual)}\"`;\n return fail(`not to carry ${key}`, `found ${found}`);\n }\n\n if (!present) return fail(attributeWant(key, expected), `it carries no ${key}`);\n if (expected === true) return null;\n if (actual === true) return fail(attributeWant(key, expected), `its ${key} is an expression`);\n if (actual !== expected) return fail(attributeWant(key, expected), `found ${key}=\"${String(actual)}\"`);\n return null;\n}\n\nfunction attributeWant(key: string, expected: string | true): string {\n return expected === true ? `to carry ${key}` : `to carry ${key}=\"${expected}\"`;\n}\n","/**\n * `contains:` - what a section (or an element's or list item's own content)\n * holds, in any order. Each listed kind dispatches to that kind's own check.\n */\n\nimport type { ContentNode, Finding, SectionNode } from \"../types.js\";\nimport { BLOCK_KINDS, sectionContext, type BlockRule, type RuleContext } from \"./index.js\";\nimport { checkParagraphsIn } from \"./paragraphs.js\";\nimport { checkCodeBlocksIn } from \"./code-blocks.js\";\nimport { checkListsIn } from \"./lists.js\";\nimport { checkTablesIn } from \"./tables.js\";\nimport { checkAdmonitionsIn } from \"./admonitions.js\";\nimport { checkImagesIn } from \"./images.js\";\nimport { checkBlockquotesIn } from \"./blockquotes.js\";\nimport { checkDefinitionListsIn } from \"./definition-lists.js\";\nimport { checkElementsIn } from \"./elements.js\";\n\n/** Checks a section's own content against a `contains:` rule. */\nexport function checkContains(\n section: SectionNode,\n rule: BlockRule | undefined,\n): Finding[] {\n return checkContainsIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks any ordered content list against a `contains:`\n * rule - a section's content, a list item's `children`, an element's own\n * `children`, or one run of a `sequence` (which carries exactly one key).\n *\n * `BLOCK_KINDS` drives the dispatch so a ninth kind is one line here, not a\n * rewritten `if` chain.\n */\nexport function checkContainsIn(\n content: ContentNode[],\n rule: BlockRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const findings: Finding[] = [];\n for (const kind of BLOCK_KINDS) {\n switch (kind) {\n case \"paragraphs\":\n findings.push(...checkParagraphsIn(content, rule.paragraphs, ctx));\n break;\n case \"codeBlocks\":\n findings.push(...checkCodeBlocksIn(content, rule.codeBlocks, ctx));\n break;\n case \"lists\":\n findings.push(...checkListsIn(content, rule.lists, ctx));\n break;\n case \"tables\":\n findings.push(...checkTablesIn(content, rule.tables, ctx));\n break;\n case \"admonitions\":\n findings.push(...checkAdmonitionsIn(content, rule.admonitions, ctx));\n break;\n case \"images\":\n findings.push(...checkImagesIn(content, rule.images, ctx));\n break;\n case \"blockquotes\":\n findings.push(...checkBlockquotesIn(content, rule.blockquotes, ctx));\n break;\n case \"definitionLists\":\n findings.push(...checkDefinitionListsIn(content, rule.definitionLists, ctx));\n break;\n case \"elements\":\n findings.push(...checkElementsIn(content, rule.elements, ctx));\n break;\n }\n }\n return findings;\n}\n","/**\n * `lists:` - list counts, whether they are ordered, item counts, and what\n * each item holds.\n *\n * v1's `items` took its own flat `paragraphs`/`code_blocks`/`lists` keys. v2\n * replaces that split with the same `sequence` | `contains` every other\n * container uses (proposal 0061), so item-level rules recurse through the\n * same two functions as everything else instead of a third, list-shaped one.\n */\n\nimport type { ContentNode, Finding, ListNode, SectionNode } from \"../types.js\";\nimport {\n checkCount,\n listsOf,\n sectionContext,\n type ListsRule,\n type RuleContext,\n} from \"./index.js\";\nimport { checkContainsIn } from \"./contains.js\";\nimport { checkSequenceIn } from \"./sequence.js\";\n\n/** Checks the lists a section holds directly. */\nexport function checkLists(\n section: SectionNode,\n rule: ListsRule | undefined,\n): Finding[] {\n return checkListsIn(section.children, rule, sectionContext(section));\n}\n\n/**\n * The reusable core: checks the lists in any ordered content list.\n *\n * `rule.items` recurses - a list item's children are a `ContentNode[]` like\n * any other, so item-level `sequence`/`contains` rules run through the same\n * functions, arbitrarily deep.\n */\nexport function checkListsIn(\n content: ContentNode[],\n rule: ListsRule | undefined,\n ctx: RuleContext,\n): Finding[] {\n if (!rule) return [];\n\n const lists = listsOf(content);\n const findings = checkCount(lists.length, rule, \"list\", \"lists_count_error\", ctx);\n\n if (rule.ordered !== undefined) {\n findings.push(...checkOrdered(lists, rule.ordered, ctx));\n }\n\n const items = rule.items;\n if (!items) return findings;\n\n findings.push(...checkItemCounts(lists, items, ctx));\n\n if (!items.sequence && !items.contains) return findings;\n\n for (const list of lists) {\n for (const item of list.items) {\n const itemCtx: RuleContext = { heading: ctx.heading, position: item.position };\n if (items.sequence) {\n findings.push(...checkSequenceIn(item.children, items.sequence, itemCtx));\n } else if (items.contains) {\n findings.push(...checkContainsIn(item.children, items.contains, itemCtx));\n }\n }\n }\n\n return findings;\n}\n\nfunction checkOrdered(lists: ListNode[], ordered: boolean, ctx: RuleContext): Finding[] {\n const findings: Finding[] = [];\n for (const list of lists) {\n if (list.ordered !== ordered) {\n findings.push({\n type: \"lists_ordered_error\",\n heading: ctx.heading,\n message: ordered\n ? \"Expected a numbered list, but found a bulleted list\"\n : \"Expected a bulleted list, but found a numbered list\",\n position: list.position,\n severity: \"error\",\n });\n }\n }\n return findings;\n}\n\n/**\n * Item counts report once per bound, anchored at the first list that breaks\n * it. `min` defaults to 1 like every other count, which is a harmless no-op\n * here: a list always has at least one item structurally, so only an\n * explicit `min` above 1 (or a rule that also forbids via `max`) ever fires.\n */\nfunction checkItemCounts(\n lists: ListNode[],\n items: { min?: number; max?: number },\n ctx: RuleContext,\n): Finding[] {\n const findings: Finding[] = [];\n const min = items.min ?? (items.max === 0 ? 0 : 1);\n const max = items.max ?? null;\n\n if (max !== null) {\n const offender = lists.find((list) => list.items.length > max);\n if (offender) {\n findings.push({\n type: \"lists_items_count_error\",\n heading: ctx.heading,\n message: `Expected at most ${max} items in a list, but found ${offender.items.length}`,\n position: offender.position,\n severity: \"error\",\n });\n }\n }\n\n if (min > 0) {\n const offender = lists.find((list) => list.items.length < min);\n if (offender) {\n findings.push({\n type: \"lists_items_count_error\",\n heading: ctx.heading,\n message: `Expected at least ${min} items in a list, but found ${offender.items.length}`,\n position: offender.position,\n severity: \"error\",\n });\n }\n }\n\n return findings;\n}\n","/**\n * Content rules: the checks that run against a single section's own content.\n *\n * A rule is a pure, synchronous function of one `SectionNode` (or one ordered\n * `ContentNode[]` slice of it) and its slice of a template, returning\n * `Finding[]`. Rules never touch a parser AST and never await anything.\n *\n * The content model is format-neutral and flat: a section carries one ordered\n * `children: ContentNode[]`, and the per-kind \"buckets\" every rule needs are\n * queries over it (`paragraphsOf`, `codeBlocksOf`, ...) rather than separately\n * maintained arrays. The same queries work unchanged on a list item's\n * `children` or an element's own `children`, which is why `lists.items` and\n * `elements` can recurse.\n *\n * This module is deliberately independent of `../core/template.ts`. That file\n * is the DSL the v2 loader and schema agree on; this one is the DSL the rules\n * are written against. Where the two diverge - see `CodeBlocksRule.language`\n * and `ElementsRule.tag` below, which this chunk's task widened to `string |\n * string[]` while `core/template.ts` still types them as a bare `string` -\n * the validator chunk that wires the two together needs to reconcile it. That\n * mirrors the v1 shape of this file, whose own rule interfaces mirrored\n * `template-v1.ts` rather than importing it.\n */\n\nimport { LintError } from \"../types.js\";\nimport type {\n AdmonitionNode,\n BlockquoteNode,\n CodeNode,\n ContentNode,\n DefinitionListNode,\n ElementNode,\n Finding,\n ImageNode,\n ListNode,\n ParagraphNode,\n Position,\n SectionNode,\n TableNode,\n} from \"../types.js\";\n\n/* -------------------------------------------------------------------------- *\n * Template rule shapes\n *\n * These mirror the v2 template DSL's block-rule vocabulary (proposal 0065 /\n * 0061): a block rule is keyed by a plural content kind and carries `min`\n * (default 1), `max` (absent unbounded, `0` forbids), plus per-kind keys.\n * -------------------------------------------------------------------------- */\n\n/** Shared by every counted rule: how many of the thing there must be. */\nexport interface Occurrences {\n /** Fewest occurrences. Absent means one - see `checkCount` for the one\n * exception, where an explicit `max: 0` with no `min` defaults `min` to 0\n * too, so \"forbid this kind\" is satisfiable by finding none of it. */\n min?: number;\n /** Most occurrences. Absent is unbounded; `0` forbids. */\n max?: number;\n}\n\n/**\n * What a rule's `heading` may say.\n *\n * `undefined` (the key absent) matches any heading or none. A string is exact\n * text, a list is one-of, `{ pattern }` is an unanchored regular expression,\n * and `false` means the section has no heading of its own.\n */\nexport type HeadingRule = string | string[] | { pattern: string } | false;\n\n/** Attributes a node must carry. `true` requires presence; `false` requires absence. */\nexport type AttributesRule = Record<string, string | boolean>;\n\n/** `paragraphs:` - how many paragraphs, and what they must look like. */\nexport interface ParagraphsRule extends Occurrences {\n /** Unanchored regular expression every paragraph in the run must match. */\n pattern?: string;\n}\n\n/** `codeBlocks:` - how many code blocks, and how they are tagged. */\nexport interface CodeBlocksRule extends Occurrences {\n /** Language(s) every code block must declare one of. */\n language?: string | string[];\n /** Info-string tail after the language; narrows which blocks count. */\n fenceInfo?: string;\n}\n\n/** `lists.items:` - how many items per list, and what each item holds. */\nexport interface ListItemsRule extends Occurrences {\n sequence?: BlockRule[];\n contains?: BlockRule;\n}\n\n/** `lists:` - how many lists, whether they are ordered, and item rules. */\nexport interface ListsRule extends Occurrences {\n ordered?: boolean;\n items?: ListItemsRule;\n}\n\n/** `tables:` - how many tables, and the header cells in order. */\nexport interface TablesRule extends Occurrences {\n columns?: string[];\n}\n\n/** `admonitions:` - how many, and of which variant. */\nexport interface AdmonitionsRule extends Occurrences {\n variant?: \"note\" | \"tip\" | \"important\" | \"caution\" | \"warning\" | \"danger\";\n}\n\n/** `images:` - how many, and what they point at. */\nexport interface ImagesRule extends Occurrences {\n /** Narrows which images count: only images at this url are counted. */\n url?: string;\n /** Narrows which images count: only images with this alt text are counted. */\n alt?: string;\n /**\n * Narrows which images count. `ImageNode` carries no `attributes` of its\n * own (the node model gave that field to `element` only), so any non-empty\n * requirement here matches no image - see `images.ts`.\n */\n attributes?: AttributesRule;\n}\n\n/** `elements:` - how many named wrappers, and what they hold. */\nexport interface ElementsRule extends Occurrences {\n /** Narrows which elements count, and names the noun in count messages. */\n tag?: string | string[];\n attributes?: AttributesRule;\n sequence?: BlockRule[];\n contains?: BlockRule;\n}\n\n/**\n * What a section (or an element's or list item's own content) holds, keyed by\n * content kind.\n *\n * One of these is a whole `contains:`. As an entry of `sequence:` exactly one\n * key is set, and it names the kind expected at that position.\n */\nexport interface BlockRule {\n paragraphs?: ParagraphsRule;\n codeBlocks?: CodeBlocksRule;\n lists?: ListsRule;\n tables?: TablesRule;\n admonitions?: AdmonitionsRule;\n images?: ImagesRule;\n blockquotes?: Occurrences;\n definitionLists?: Occurrences;\n elements?: ElementsRule;\n}\n\n/** `sequence:` - the ordered runs of content a section must contain. */\nexport type SequenceRule = BlockRule[];\n\n/** One block-rule key: a content kind, spelled plural. */\nexport type BlockKind = keyof BlockRule;\n\n/** Every block-rule key, in the order the schema declares them. */\nexport const BLOCK_KINDS: readonly BlockKind[] = [\n \"paragraphs\",\n \"codeBlocks\",\n \"lists\",\n \"tables\",\n \"admonitions\",\n \"images\",\n \"blockquotes\",\n \"definitionLists\",\n \"elements\",\n];\n\n/* -------------------------------------------------------------------------- *\n * Finding anchoring\n * -------------------------------------------------------------------------- */\n\n/**\n * Where findings land when a rule runs over content that is not a whole\n * section - a list item's `children`, an element's `children`, or one run\n * inside a `sequence`.\n */\nexport interface RuleContext {\n /** Stamped onto every finding as `Finding.heading`. */\n heading: string | null;\n /** Used when the offending thing is a count rather than a single node. */\n position: Position;\n}\n\n/**\n * The context for rules run against a section's own content.\n *\n * The heading is normalised to `null` when there is none, as `match.ts` and\n * `validator.ts` both do. A headless section carries `title: \"\"`, and the JSON\n * reporter's `heading` is a wire key `manni docevals` parses rather than\n * validates, so `\"\"` and `null` would reach it as two spellings of one fact.\n */\nexport function sectionContext(section: SectionNode): RuleContext {\n return { heading: section.title || null, position: section.position };\n}\n\n/* -------------------------------------------------------------------------- *\n * Content queries\n *\n * The single place the flat content array is bucketed by kind. Rules call\n * these; they never filter inline.\n * -------------------------------------------------------------------------- */\n\nexport function paragraphsOf(content: ContentNode[]): ParagraphNode[] {\n return content.filter((node): node is ParagraphNode => node.kind === \"paragraph\");\n}\n\nexport function codeBlocksOf(content: ContentNode[]): CodeNode[] {\n return content.filter((node): node is CodeNode => node.kind === \"codeBlock\");\n}\n\nexport function listsOf(content: ContentNode[]): ListNode[] {\n return content.filter((node): node is ListNode => node.kind === \"list\");\n}\n\nexport function tablesOf(content: ContentNode[]): TableNode[] {\n return content.filter((node): node is TableNode => node.kind === \"table\");\n}\n\nexport function admonitionsOf(content: ContentNode[]): AdmonitionNode[] {\n return content.filter((node): node is AdmonitionNode => node.kind === \"admonition\");\n}\n\nexport function imagesOf(content: ContentNode[]): ImageNode[] {\n return content.filter((node): node is ImageNode => node.kind === \"image\");\n}\n\nexport function blockquotesOf(content: ContentNode[]): BlockquoteNode[] {\n return content.filter((node): node is BlockquoteNode => node.kind === \"blockquote\");\n}\n\nexport function definitionListsOf(content: ContentNode[]): DefinitionListNode[] {\n return content.filter((node): node is DefinitionListNode => node.kind === \"definitionList\");\n}\n\nexport function elementsOf(content: ContentNode[]): ElementNode[] {\n return content.filter((node): node is ElementNode => node.kind === \"element\");\n}\n\n/* -------------------------------------------------------------------------- *\n * Shared message helpers\n * -------------------------------------------------------------------------- */\n\n/** `\"paragraph\"`/1 -> `\"paragraph\"`; `\"paragraph\"`/2 -> `\"paragraphs\"`. */\nfunction plural(noun: string, count: number): string {\n return count === 1 ? noun : `${noun}s`;\n}\n\n/** `[\"Field\", \"Type\"]` -> `\"Field\", \"Type\"`. */\nexport function quoteList(items: string[]): string {\n return items.map((item) => `\"${item}\"`).join(\", \");\n}\n\n/**\n * The count half of every block rule: `min` (default 1) and `max` (default\n * unbounded), against one already-computed count.\n *\n * One default is not the naive `rule.min ?? 1`. The schema documents `max: 0`\n * as how a template forbids a kind outright, and that has to be satisfiable\n * by a section that truly has none of it. A blanket \"min defaults to 1\" would\n * make `{ max: 0 }` alone unsatisfiable - it would demand at least one and\n * permit at most zero. So `min` defaults to 0 exactly when `max` is written\n * as `0` and `min` itself is not, and to 1 otherwise. `min: 0` and `max: 0`\n * are each still tested explicitly; this is what makes both mean something\n * at once.\n */\nexport function checkCount(\n count: number,\n rule: Occurrences,\n noun: string,\n type: string,\n ctx: RuleContext,\n): Finding[] {\n const findings: Finding[] = [];\n const min = rule.min ?? (rule.max === 0 ? 0 : 1);\n const max = rule.max ?? null;\n\n if (count < min) {\n findings.push({\n type,\n heading: ctx.heading,\n message: `Expected at least ${min} ${plural(noun, min)}, but found ${count}`,\n position: ctx.position,\n severity: \"error\",\n });\n }\n\n if (max !== null && count > max) {\n findings.push({\n type,\n heading: ctx.heading,\n message: `Expected at most ${max} ${plural(noun, max)}, but found ${count}`,\n position: ctx.position,\n severity: \"error\",\n });\n }\n\n return findings;\n}\n\n/* -------------------------------------------------------------------------- *\n * The rules\n * -------------------------------------------------------------------------- */\n\nexport { checkHeading } from \"./heading.js\";\nexport { checkParagraphs, checkParagraphsIn } from \"./paragraphs.js\";\nexport { checkCodeBlocks, checkCodeBlocksIn } from \"./code-blocks.js\";\nexport { checkLists, checkListsIn } from \"./lists.js\";\nexport { checkTables, checkTablesIn } from \"./tables.js\";\nexport { checkAdmonitions, checkAdmonitionsIn } from \"./admonitions.js\";\nexport { checkImages, checkImagesIn } from \"./images.js\";\nexport { checkBlockquotes, checkBlockquotesIn } from \"./blockquotes.js\";\nexport { checkDefinitionLists, checkDefinitionListsIn } from \"./definition-lists.js\";\nexport { checkElements, checkElementsIn } from \"./elements.js\";\nexport { checkContains, checkContainsIn } from \"./contains.js\";\nexport { checkSequence, checkSequenceIn, groupRuns } from \"./sequence.js\";\nexport type { ContentRun } from \"./sequence.js\";\n\n/**\n * Compile an author-supplied pattern, or say which one is broken.\n *\n * A pattern comes from a template, so a bad one is a broken template rather\n * than a lint finding - and the raw `SyntaxError` names the regex but not the\n * template, the section, or the file. Every caller must route the result\n * through the same containment a template load failure gets, or one bad\n * pattern takes the whole run down with it.\n *\n * ## A pattern that compiles can still hang\n *\n * This checks syntax, and syntax is all it checks. `(a+)+b$` is a valid regex\n * that backtracks catastrophically against a heading it cannot match, and\n * `loadTemplateFile` will fetch a template over HTTP, so an untrusted template\n * can supply one.\n *\n * Capping the input length is not the answer, however cheap it looks. The\n * blow-up is exponential in the length of the input, so a cap generous enough\n * for a real heading is already far past the point of hanging: `(a+)+b$` needs\n * on the order of 2^n steps, and n of 64 is out of reach. Any cap that\n * actually bounded the work would reject headings people legitimately write.\n *\n * The boundary that does hold is the one proposal 0015 drew for schemas: a\n * template from a URL is a trust decision made when the URL is configured, not\n * something this function can take back. Validating patterns for backtracking\n * safety at load time is the fix if that decision is ever delegated, and it is\n * a dependency and a proposal rather than a line here.\n */\nconst compiled = new Map<string, RegExp>();\n\nexport function compilePattern(pattern: string): RegExp {\n // Memoized because heading matching is quadratic by nature: the matcher asks\n // every rule about every section, so a template with ten pattern rules against\n // a twenty-section page compiled the same ten regexes two hundred times.\n //\n // Safe to share one instance: these are built with no flags, and `lastIndex`\n // is only carried between calls by `g` and `y`. Adding either to this\n // construction would make the cached regex stateful across sections.\n const hit = compiled.get(pattern);\n if (hit) return hit;\n try {\n const regex = new RegExp(pattern);\n compiled.set(pattern, regex);\n return regex;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new LintError(`Invalid pattern \"${pattern}\": ${reason}`);\n }\n}\n\n/** Drop the compiled-pattern memo. See `clearCaches` in the package root. */\nexport function clearPatternCache(): void {\n compiled.clear();\n}\n","/**\n * `heading:` - the section's title against a string, a one-of list, a\n * `{ pattern }`, or `false` for \"no heading of its own\".\n *\n * One finding type, `heading_error`, covers all four forms; the message\n * names which form failed. v1 split this into `heading_const_error` and\n * `heading_pattern_error`, each of which could fire independently for the\n * same section. v2's `heading:` is one value, so it fires at most once.\n */\n\nimport type { Finding, SectionNode } from \"../types.js\";\nimport { compilePattern, type HeadingRule } from \"./index.js\";\n\n/**\n * A section's own title, in the vocabulary `heading:` speaks: `null` when the\n * section has no heading of its own (the implicit lead section), the title\n * text otherwise.\n *\n * `SectionNode.title` is `\"\"` rather than `null` for that section - `null` is\n * reserved for \"no heading\" so `headingMatches`-style checks elsewhere don't\n * have to special-case the empty string. This bridges the two.\n */\nfunction ownTitle(section: SectionNode): string | null {\n return section.titlePosition === null ? null : section.title;\n}\n\n/** Checks a section's title against the template's `heading:` rule. */\nexport function checkHeading(\n section: SectionNode,\n rule: HeadingRule | undefined,\n): Finding[] {\n if (rule === undefined) return [];\n\n // The heading itself is the offending node when it has a span of its own;\n // the implicit lead section has none, so fall back to the section.\n const position = section.titlePosition ?? section.position;\n const title = ownTitle(section);\n const found = title === null ? \"no heading\" : `\"${title}\"`;\n\n const fail = (message: string): Finding[] => [\n {\n type: \"heading_error\",\n // `|| null`, as `sectionContext` and `match.ts`'s `anchor` both do. A\n // headless section's title is `\"\"`, and the JSON reporter's `heading` is\n // a wire key `manni docevals` parses rather than validates, so two\n // spellings of \"no heading\" would reach it as two different facts.\n heading: section.title || null,\n message,\n position,\n severity: \"error\",\n },\n ];\n\n if (rule === false) {\n return title === null ? [] : fail(`Expected no heading of its own, but found ${found}`);\n }\n\n if (typeof rule === \"string\") {\n return title === rule ? [] : fail(`Expected title \"${rule}\", but found ${found}`);\n }\n\n if (Array.isArray(rule)) {\n if (title !== null && rule.includes(title)) return [];\n return fail(`Expected one of ${rule.map((option) => `\"${option}\"`).join(\", \")}, but found ${found}`);\n }\n\n // { pattern }\n if (title !== null && compilePattern(rule.pattern).test(title)) return [];\n return fail(`Expected title matching /${rule.pattern}/, but found ${found}`);\n}\n","/**\n * The template DSL, as TypeScript. `schemas/lint/template.json` is the\n * authority that user input is validated against; this is the shape the rest of\n * the code reads once that validation has passed.\n *\n * Two things are worth knowing before reading it.\n *\n * A template *is* a rule. It describes the page, so it takes every rule key,\n * plus `title`, `types` and `extends`. It may not take `min` or `max`, because\n * a page is one page, and the loader refuses those two by hand.\n *\n * A rule's children are a **list**, not a map. The v1 format keyed section\n * rules by name and let YAML key order carry the grammar, which made the order\n * invisible to the schema and unspeakable in `extends`. A rule names itself\n * with `id` instead, and that is what `extends` targets.\n *\n * The block-rule keys are plural where the node model is singular. That is\n * deliberate: the node model names one node (`codeBlock`), while a template key\n * carries a count (`codeBlocks: { min: 1 }`).\n */\nimport type { ContentKind } from \"../types.js\";\nimport { compilePattern } from \"../rules/index.js\";\n\n/** Shared by every counted rule: how many of the thing there must be. */\nexport interface Occurrences {\n /** Fewest occurrences. Absent means one. */\n min?: number;\n /** Most occurrences. Absent is unbounded; `0` forbids. */\n max?: number;\n}\n\n/**\n * What a rule's `heading` may say.\n *\n * `undefined` (the key absent) matches any heading or none. A string is exact\n * text, a list is one-of, `{ pattern }` is an unanchored regular expression,\n * and `false` means the section has no heading of its own.\n */\nexport type HeadingRule = string | string[] | { pattern: string } | false;\n\n/**\n * Attributes a node must carry. A string is the required value, `true`\n * requires the attribute's presence, and `false` requires its absence.\n */\nexport type AttributesRule = Record<string, string | boolean>;\n\n/** `paragraphs:` - how many paragraphs, and what each must look like. */\nexport interface ParagraphsRule extends Occurrences {\n /** Unanchored regular expression every paragraph in the run must match. */\n pattern?: string;\n}\n\n/** `codeBlocks:` - how many code blocks, and how they are tagged. */\nexport interface CodeBlocksRule extends Occurrences {\n /** Language, or languages, every code block must declare one of. */\n language?: string | string[];\n /** Info-string tail after the language; narrows which blocks count. */\n fenceInfo?: string;\n}\n\n/** `lists.items:` - how many items per list, and what each item holds. */\nexport interface ListItemsRule extends Occurrences {\n sequence?: BlockRule[];\n contains?: BlockRule;\n}\n\n/** `lists:` - how many lists, whether they are ordered, and item rules. */\nexport interface ListsRule extends Occurrences {\n ordered?: boolean;\n items?: ListItemsRule;\n}\n\n/** `tables:` - how many tables, and the header cells in order. */\nexport interface TablesRule extends Occurrences {\n columns?: string[];\n}\n\n/** `admonitions:` - how many, and of which variant. */\nexport interface AdmonitionsRule extends Occurrences {\n variant?: \"note\" | \"tip\" | \"important\" | \"caution\" | \"warning\" | \"danger\";\n}\n\n/** `images:` - how many, and what they point at. */\nexport interface ImagesRule extends Occurrences {\n url?: string;\n alt?: string;\n attributes?: AttributesRule;\n}\n\n/** `elements:` - how many named wrappers, and what they hold. */\nexport interface ElementsRule extends Occurrences {\n /** Name, or names, an element must carry to be counted by this rule. */\n tag?: string | string[];\n attributes?: AttributesRule;\n sequence?: BlockRule[];\n contains?: BlockRule;\n}\n\n/**\n * What a section holds, keyed by content kind.\n *\n * One of these is a whole `contains:`. As an entry of `sequence:` exactly one\n * key is set, and it names the kind expected at that position.\n */\nexport interface BlockRule {\n paragraphs?: ParagraphsRule;\n codeBlocks?: CodeBlocksRule;\n lists?: ListsRule;\n tables?: TablesRule;\n admonitions?: AdmonitionsRule;\n images?: ImagesRule;\n blockquotes?: Occurrences;\n definitionLists?: Occurrences;\n elements?: ElementsRule;\n}\n\n/** One block-rule key: a content kind, spelled plural. */\nexport type BlockKind = keyof BlockRule;\n\n/** Every block-rule key, in the order the schema declares them. */\nexport const BLOCK_KINDS: readonly BlockKind[] = [\n \"paragraphs\",\n \"codeBlocks\",\n \"lists\",\n \"tables\",\n \"admonitions\",\n \"images\",\n \"blockquotes\",\n \"definitionLists\",\n \"elements\",\n];\n\n/**\n * The node a block-rule key counts: `codeBlocks` counts `codeBlock` nodes.\n *\n * It is what lets the validator ask a parser whether a rule can run at all -\n * a parser declares the kinds it emits, and a rule about a kind absent from\n * that list is reported rather than silently passing.\n *\n * `rules/sequence.ts` holds the same map, written against the rules' own copy\n * of the DSL. The duplication is the one this file's header describes: the two\n * vocabularies are kept apart deliberately, and this is the copy the loader and\n * the validator read.\n */\nexport const BLOCK_KIND_NODE: Record<BlockKind, ContentKind> = {\n paragraphs: \"paragraph\",\n codeBlocks: \"codeBlock\",\n lists: \"list\",\n tables: \"table\",\n admonitions: \"admonition\",\n images: \"image\",\n blockquotes: \"blockquote\",\n definitionLists: \"definitionList\",\n elements: \"element\",\n};\n\n/** One rule: a section of the page, or a repeated run of sections. */\nexport interface Rule extends Occurrences {\n /** Handle, unique among siblings. `extends` targets it. */\n id?: string;\n /** Prose description of what the rule is for. Never checked. */\n description?: string;\n heading?: HeadingRule;\n /** Rules matched in order as one unit, repeated by this rule's `min`/`max`. */\n repeat?: Rule[];\n /** What the section holds, in order. Not combinable with `contains`. */\n sequence?: BlockRule[];\n /** What the section holds, in any order. Not combinable with `sequence`. */\n contains?: BlockRule;\n /** Rules for the subsections, in document order. */\n sections?: Rule[];\n}\n\n/** One doctype template: the rule that describes a whole page. */\nexport interface Template extends Rule {\n /** Human-readable name, shown by `manni lint templates`. */\n title?: string;\n /** Doctypes this template serves, matched against a page's `type`. */\n types?: string[];\n /** Built-in id, path, or URL to inherit from. */\n extends?: string;\n}\n\n/** A template file: named templates plus reusable `$ref` targets. */\nexport interface TemplateFile {\n /** Published schema URL, for editors. Ignored by the linter. */\n $schema?: string;\n templates?: Record<string, Template>;\n components?: Record<string, unknown>;\n info?: Record<string, unknown>;\n}\n\n/**\n * A rule is a wildcard when it says nothing about its heading.\n *\n * It then matches any heading, and matches a section with none. `heading:\n * false` is not a wildcard: it states that the section has no heading of its\n * own, which is as specific as naming one.\n */\nexport function isWildcard(rule: Rule): boolean {\n return rule.heading === undefined;\n}\n\n/**\n * How many sections a rule claims: `min` defaulting to one, and `max` as\n * written, with `null` for unbounded.\n *\n * The defaults live here rather than in the schema. A default written into the\n * data by Ajv is indistinguishable from a value the author typed, so it wins\n * the `extends` merge against the parent's real value.\n *\n * One default is not the naive `min ?? 1`. `max: 0` is how the format forbids\n * a thing outright, and a bare `max: 0` has to be satisfiable by a page that\n * truly has none of it. A blanket \"min defaults to 1\" makes it unsatisfiable -\n * at least one demanded, at most zero permitted - so `min` defaults to 0\n * exactly when `max` is written as `0` and `min` itself is not, and to 1\n * otherwise. `checkCount` in `rules/index.ts` states the same rule for the\n * content counts; the two agree deliberately.\n */\nexport function occurrenceRange(rule: Occurrences): {\n min: number;\n max: number | null;\n} {\n return { min: rule.min ?? (rule.max === 0 ? 0 : 1), max: rule.max ?? null };\n}\n\n/** Whether a section's title satisfies a rule's `heading`. */\nexport function headingMatches(\n heading: HeadingRule | undefined,\n title: string | null,\n): boolean {\n if (heading === undefined) return true;\n if (heading === false) return title === null;\n if (title === null) return false;\n if (typeof heading === \"string\") return title === heading;\n if (Array.isArray(heading)) return heading.includes(title);\n return compilePattern(heading.pattern).test(title);\n}\n","/**\n * Decide which rule describes which section, by alignment.\n *\n * A rule list is a regular expression over section predicates, and a document's\n * sibling sections are the string. The matcher compiles the first and aligns\n * the second against it at minimum cost:\n *\n * 1. Each rule contributes one predicate on a heading. `min`/`max` is counted\n * repetition, and `repeat:` is a parenthesised subexpression.\n * 2. Bounded counts expand into copies; an absent `max` becomes a self-loop.\n * 3. Four edits close the gap between rules and sections: a *match* (the\n * predicate holds), a *coercion* (a rule claiming one section takes a\n * section its heading rejects), a *skipped rule* (a required occurrence\n * consumes nothing) and a *skipped section* (no rule consumes it).\n * 4. Viterbi over a (sections + 1) x states lattice finds the cheapest edit\n * sequence. Deletions can form zero-consuming cycles, so each column is\n * closed with Dijkstra rather than a topological sweep; all weights are\n * non-negative.\n * 5. Skipped rules become `missing_section` (or one `missing_group` for a\n * `repeat` copy that is absent whole), skipped sections become\n * `unexpected_section`, and every match is handed to the content rules.\n *\n * The predecessor of this file walked the rules left to right with no\n * backtracking, and each of its eight hand-written behaviours is now a\n * consequence of a weight or a tie-break instead of a special case. The two it\n * could not express are what forced the change: a rule list with counted\n * repetition is not a sequence of one-shot decisions, and a greedy walk has to\n * guess which of two rules wants a section before it has seen the rest.\n *\n * Heading mismatches are deliberately not reported here. This module pairs; the\n * content rules report `heading_error` on the pair it produced. `validator.ts`\n * explains why the two are separate.\n */\nimport { LintError } from \"../types.js\";\nimport type { Finding, Position, SectionNode } from \"../types.js\";\nimport { headingMatches, isWildcard, occurrenceRange } from \"./template.js\";\nimport type { Rule } from \"./template.js\";\n\n/* -------------------------------------------------------------------------- *\n * The cost model, which is interface\n * -------------------------------------------------------------------------- */\n\n/**\n * What each edit costs, in the units the alignment minimises.\n *\n * These weights are **interface, not implementation**. They decide which\n * findings a document produces, so changing one changes the report for\n * documents nobody edited - the same class of change as renaming a flag.\n * `test/lint/unit/match.test.ts` pins them, and the templates reference prints\n * them.\n *\n * Skipping an occurrence at or above its rule's `min` is free; only a required\n * occurrence pays `skipRule`.\n *\n * Coercion is open only to a *required* occurrence of a rule whose `max` is 1.\n * Both halves of that earn their place. Without the `max: 1` half a repeating\n * rule adopts any stray section for 1 rather than letting it report as\n * unexpected for 2. Without the \"required\" half an optional rule does the same\n * thing for the same reason, and there it is plainly wrong: standing aside\n * costs an optional rule nothing, so coercing trades a clean report for a\n * heading error about a section the template never insisted on.\n */\nexport const ALIGNMENT_COSTS = {\n match: 0,\n coerce: 1,\n skipRule: 2,\n skipSection: 2,\n} as const;\n\n/**\n * How equal-cost alignments are settled, in order, after the total cost.\n *\n * Also interface: two of these decide real reports, and all three are stated in\n * words so the docs page and the code cannot drift apart.\n */\nexport const TIE_BREAKS = [\n \"a rule that names its heading beats a wildcard taking the same section\",\n \"a repeating rule prefers its sections adjacent\",\n \"earliest rule, then the smallest edit sequence under match < coerce < skip-rule < skip-section\",\n] as const;\n\n/**\n * Most states a compiled rule list may expand to.\n *\n * Counted repetition is expanded into copies, so `max: 100000` on a rule with\n * five subsections is a hundred thousand copies of five states and a lattice\n * nobody asked for. The cap turns that into a template error naming the file,\n * rather than a lint run that appears to hang.\n */\nexport const STATE_LIMIT = 2000;\n\n/* -------------------------------------------------------------------------- *\n * What the matcher hands on\n * -------------------------------------------------------------------------- */\n\n/** One rule paired with the section it claimed. */\nexport interface Match {\n /** The rule itself - a `repeat` group's member, never the group. */\n rule: Rule;\n section: SectionNode;\n /**\n * True when the rule was paired with a section whose heading does not\n * satisfy it, because nothing else could claim that section. Keeps the\n * precise \"Expected title X, but found Y\" report for the common one-for-one\n * case instead of degrading it into missing + unexpected.\n */\n coerced: boolean;\n}\n\nexport interface MatchResult {\n matches: Match[];\n findings: Finding[];\n}\n\nexport interface MatchOptions {\n /** Section these are the subsections of, for anchoring a trailing gap. */\n parent?: SectionNode | null;\n /** File the rules came from. Used only to name the state-cap failure. */\n source?: string;\n /** Template within that file. Used only to name the state-cap failure. */\n template?: string;\n}\n\n/* -------------------------------------------------------------------------- *\n * Compilation\n * -------------------------------------------------------------------------- */\n\n/**\n * One copy of a `repeat` group, and every leaf occurrence inside it.\n *\n * It exists so an absent copy can report once for the group. A copy whose\n * leaves were *all* skipped is a group that is not there at all, which reads\n * as one finding; a copy that matched some of them is a group that is there and\n * incomplete, whose absent members read better one by one.\n */\ninterface GroupCopy {\n rule: Rule;\n members: Occurrence[];\n}\n\n/** One occurrence of one rule: the chance to consume exactly one section. */\ninterface Occurrence {\n rule: Rule;\n /** Below the rule's `min`, so skipping it costs rather than being free. */\n required: boolean;\n /** Required and `max: 1`, so it may take a section its heading rejects. */\n coercible: boolean;\n /** Says nothing about its heading, so it loses ties to a rule that does. */\n wildcard: boolean;\n /** Enclosing `repeat` copies, outermost first. */\n groups: GroupCopy[];\n}\n\ninterface Eps {\n from: number;\n to: number;\n cost: number;\n rank: number;\n /** Set when this edge is a rule being skipped rather than structure. */\n occ: Occurrence | null;\n}\n\ninterface Automaton {\n states: number;\n start: number;\n accept: number;\n /** The occurrence a state may consume a section through, if any. */\n consume: (Occurrence | null)[];\n /** Where that consumption lands. */\n consumeTo: number[];\n epsOut: Eps[][];\n epsIn: Eps[][];\n /** States strictly inside a repetition, where a skipped section breaks a run. */\n inRepeat: boolean[];\n}\n\n/**\n * Edit ranks, used only to settle a tie the costs and the two structural\n * tie-breaks left open. Structural epsilons - entering, repeating and leaving a\n * self-loop - rank with `match`, because they are not edits at all and a path\n * must be free to leave a loop before it starts skipping the rules inside it.\n */\nconst RANK = {\n match: 0,\n structure: 0,\n coerce: 1,\n skipRule: 2,\n skipSection: 3,\n} as const;\n\nconst NO_EPS: Eps[] = [];\n\n/**\n * States the rule list expands to, counted without building anything.\n *\n * Checked before compilation so a template with an absurd `max` fails on its\n * own terms rather than by exhausting memory. The two extra states per\n * unbounded rule are its self-loop's entry and exit.\n */\nfunction expandedStates(rules: Rule[]): number {\n let total = 1;\n for (const rule of rules) total += ruleStates(rule);\n return total;\n}\n\nfunction ruleStates(rule: Rule): number {\n let unit = 1;\n if (rule.repeat) {\n unit = 0;\n for (const member of rule.repeat) unit += ruleStates(member);\n }\n const { min, max } = occurrenceRange(rule);\n if (max === null) return unit * (Math.max(min, 0) + 1) + 2;\n return unit * Math.max(0, max);\n}\n\nfunction listAt<T>(lists: T[][], index: number): T[] {\n const list = lists[index];\n if (list) return list;\n const created: T[] = [];\n lists[index] = created;\n return created;\n}\n\n/**\n * Compile a rule list into an automaton over section predicates.\n *\n * Bounded repetition is unrolled: `min: 1, max: 3` is three copies, the first\n * required and the rest free to skip. An unbounded `max` is a self-loop after\n * the required copies, which is the only construct here that can consume\n * nothing and return to where it started - hence the Dijkstra in the alignment.\n */\nfunction compile(rules: Rule[]): Automaton {\n const consume: (Occurrence | null)[] = [];\n const consumeTo: number[] = [];\n const epsOut: Eps[][] = [];\n const epsIn: Eps[][] = [];\n const inRepeat: boolean[] = [];\n\n const newState = (): number => {\n consume.push(null);\n consumeTo.push(-1);\n epsOut.push([]);\n epsIn.push([]);\n inRepeat.push(false);\n return consume.length - 1;\n };\n\n const eps = (\n from: number,\n to: number,\n cost: number,\n rank: number,\n occ: Occurrence | null,\n ): void => {\n const edge: Eps = { from, to, cost, rank, occ };\n listAt(epsOut, from).push(edge);\n listAt(epsIn, to).push(edge);\n };\n\n const leaf = (from: number, occ: Occurrence): number => {\n const to = newState();\n consume[from] = occ;\n consumeTo[from] = to;\n // Skipping the occurrence: free when the rule can do without it.\n eps(from, to, occ.required ? ALIGNMENT_COSTS.skipRule : 0, RANK.skipRule, occ);\n return to;\n };\n\n /** One copy of a rule's unit: its members, or the rule's own occurrence. */\n const buildCopy = (\n rule: Rule,\n from: number,\n groups: GroupCopy[],\n required: boolean,\n ): number => {\n if (rule.repeat) {\n const copy: GroupCopy = { rule, members: [] };\n const nested = [...groups, copy];\n let cursor = from;\n for (const member of rule.repeat) {\n cursor = buildRule(member, cursor, nested, required);\n }\n return cursor;\n }\n const { max } = occurrenceRange(rule);\n const occ: Occurrence = {\n rule,\n required,\n coercible: required && max === 1,\n wildcard: isWildcard(rule),\n groups,\n };\n for (const group of groups) group.members.push(occ);\n return leaf(from, occ);\n };\n\n function buildRule(\n rule: Rule,\n from: number,\n groups: GroupCopy[],\n context: boolean,\n ): number {\n const { min, max } = occurrenceRange(rule);\n // `max` below `min` is refused by the loader where both are written; a bare\n // `max: 0` still reaches here against the default `min: 1`, and means none.\n const floor = max === null ? Math.max(min, 0) : Math.min(Math.max(min, 0), max);\n const copies = max === null ? floor : Math.max(0, max);\n const first = consume.length;\n\n let cursor = from;\n for (let copy = 0; copy < copies; copy++) {\n cursor = buildCopy(rule, cursor, groups, context && copy < floor);\n }\n\n let end = cursor;\n if (max === null) {\n const loop = newState();\n eps(cursor, loop, 0, RANK.structure, null);\n const back = buildCopy(rule, loop, groups, false);\n eps(back, loop, 0, RANK.structure, null);\n end = newState();\n eps(loop, end, 0, RANK.structure, null);\n }\n\n // A skipped section inside a repetition breaks the run it is inside, which\n // tie-break 2 charges for. The repetition's own boundaries are not inside\n // it: a section skipped before the first copy or after the last one sits\n // beside the run rather than in the middle of it.\n if (copies > 1 || max === null) {\n for (let state = first; state < consume.length; state++) {\n if (state !== end) inRepeat[state] = true;\n }\n }\n return end;\n }\n\n const start = newState();\n let cursor = start;\n for (const rule of rules) cursor = buildRule(rule, cursor, [], true);\n\n return {\n states: consume.length,\n start,\n accept: cursor,\n consume,\n consumeTo,\n epsOut,\n epsIn,\n inRepeat,\n };\n}\n\n/**\n * Compiled rule lists, keyed by the array the template holds.\n *\n * A template is loaded once and applied to every page of its doctype, and every\n * level of every page re-enters this module. The automaton is immutable once\n * built, so one compilation serves them all.\n */\nconst compiled = new WeakMap<Rule[], Automaton>();\n\nfunction automatonFor(rules: Rule[], options: MatchOptions): Automaton {\n const hit = compiled.get(rules);\n if (hit) return hit;\n\n const states = expandedStates(rules);\n if (states > STATE_LIMIT) {\n const source = options.source ?? \"template\";\n // A template is referred to as `./templates.yaml#how-to` everywhere else,\n // so a named template fragment joins the source the same way here. Absent\n // a name - the file failed to compile a rule list outside any named\n // template - there is nothing to put after a `#`, so the sentence falls\n // back to its old, colon-joined phrasing.\n const label =\n options.template != null ? `${source}#${options.template}` : `${source}: the rule list`;\n throw new LintError(\n `${label} expands to ${states} states; the limit is ${STATE_LIMIT}. ` +\n `Cap a max, or split the template.`,\n );\n }\n\n const built = compile(rules);\n compiled.set(rules, built);\n return built;\n}\n\n/* -------------------------------------------------------------------------- *\n * Alignment\n * -------------------------------------------------------------------------- */\n\ntype StepKind = \"match\" | \"coerce\" | \"skip-rule\" | \"skip-section\";\n\n/** One candidate edge out of a lattice node, during the forward walk. */\ninterface Move {\n kind: StepKind;\n /** State it lands in. */\n to: number;\n /** Section index it lands in - the same one unless a section was consumed. */\n column: number;\n occ: Occurrence | null;\n /** This edge plus the cheapest completion from where it lands. */\n total: number;\n rank: number;\n}\n\ninterface Step {\n kind: StepKind;\n /** Section consumed, or where the cursor stood when a rule was skipped. */\n index: number;\n occ: Occurrence | null;\n}\n\n/** A section's heading, or `null` when it has none of its own. */\nfunction titleOf(section: SectionNode): string | null {\n return section.titlePosition === null ? null : section.title;\n}\n\n/** Binary heap over (cost, state), smallest cost first. */\nclass Heap {\n private readonly costs: number[] = [];\n private readonly items: number[] = [];\n\n get size(): number {\n return this.items.length;\n }\n\n /*\n * Every `?? 0` in this class is unreachable, and is here only because\n * `noUncheckedIndexedAccess` cannot see the bounds the arithmetic already\n * guarantees. `costs` and `items` are pushed and popped together and so\n * always have the same length; `child` is the index just pushed, and\n * `parent = (child - 1) >> 1` is in bounds whenever `child > 0`; `left` and\n * `right` are compared against `length` before they are read.\n *\n * Worth stating rather than leaving to inference: were an index ever out of\n * bounds, the fallback would read as cost 0, quietly inverting the heap\n * order rather than throwing. It is a type-checker concession, not a\n * defensive default.\n */\n push(cost: number, item: number): void {\n this.costs.push(cost);\n this.items.push(item);\n let child = this.items.length - 1;\n while (child > 0) {\n const parent = (child - 1) >> 1;\n if ((this.costs[parent] ?? 0) <= (this.costs[child] ?? 0)) break;\n this.swap(parent, child);\n child = parent;\n }\n }\n\n pop(): { cost: number; item: number } {\n const cost = this.costs[0] ?? 0;\n const item = this.items[0] ?? 0;\n const lastCost = this.costs.pop();\n const lastItem = this.items.pop();\n if (this.items.length > 0 && lastCost !== undefined && lastItem !== undefined) {\n this.costs[0] = lastCost;\n this.items[0] = lastItem;\n let parent = 0;\n for (;;) {\n const left = parent * 2 + 1;\n const right = left + 1;\n let smallest = parent;\n if (left < this.items.length && (this.costs[left] ?? 0) < (this.costs[smallest] ?? 0)) {\n smallest = left;\n }\n if (right < this.items.length && (this.costs[right] ?? 0) < (this.costs[smallest] ?? 0)) {\n smallest = right;\n }\n if (smallest === parent) break;\n this.swap(parent, smallest);\n parent = smallest;\n }\n }\n return { cost, item };\n }\n\n private swap(a: number, b: number): void {\n const cost = this.costs[a] ?? 0;\n const item = this.items[a] ?? 0;\n this.costs[a] = this.costs[b] ?? 0;\n this.items[a] = this.items[b] ?? 0;\n this.costs[b] = cost;\n this.items[b] = item;\n }\n}\n\n/**\n * The cheapest edit sequence turning the rule list into the section list.\n *\n * Costs are packed into one integer so the lattice can be a typed array:\n * `((primary * radix) + wildcards) * radix + brokenRuns`, compared as one\n * number, which is lexicographic because no component can reach the radix.\n *\n * The lattice is filled backwards, from the end of the document to the start,\n * and the path is then walked forwards. That order is what makes tie-break 3\n * expressible: with the cost of every remaining suffix already known, the walk\n * can take the lowest-ranked optimal edit at each step, which is exactly\n * \"earliest rule, then the smallest edit sequence\".\n */\nfunction align(sections: SectionNode[], nfa: Automaton): Step[] {\n const n = sections.length;\n const states = nfa.states;\n const radix = 2 * (n + states) + 2;\n const weigh = (primary: number, wildcards: number, brokenRuns: number): number =>\n (primary * radix + wildcards) * radix + brokenRuns;\n\n const SKIP_SECTION = weigh(ALIGNMENT_COSTS.skipSection, 0, 0);\n const SKIP_SECTION_IN_RUN = weigh(ALIGNMENT_COSTS.skipSection, 0, 1);\n const MATCH = weigh(ALIGNMENT_COSTS.match, 0, 0);\n const MATCH_WILDCARD = weigh(ALIGNMENT_COSTS.match, 1, 0);\n const COERCE = weigh(ALIGNMENT_COSTS.coerce, 0, 0);\n\n /** What a state's consuming edge costs against one section, or null. */\n const consumeCost = (\n state: number,\n index: number,\n ): { cost: number; rank: number; to: number; occ: Occurrence } | null => {\n const occ = nfa.consume[state];\n const section = sections[index];\n const to = nfa.consumeTo[state];\n if (!occ || !section || to === undefined || to < 0) return null;\n if (headingMatches(occ.rule.heading, titleOf(section))) {\n const cost = occ.wildcard ? MATCH_WILDCARD : MATCH;\n return { cost, rank: RANK.match, to, occ };\n }\n if (occ.coercible) return { cost: COERCE, rank: RANK.coerce, to, occ };\n return null;\n };\n\n const skipSectionCost = (state: number): number =>\n nfa.inRepeat[state] === true ? SKIP_SECTION_IN_RUN : SKIP_SECTION;\n\n // dist[i * states + s]: cheapest way from (section i, state s) to the end.\n const dist = new Float64Array((n + 1) * states).fill(Infinity);\n const distAt = (slot: number): number => dist[slot] ?? Infinity;\n\n for (let index = n; index >= 0; index--) {\n const base = index * states;\n const next = base + states;\n const heap = new Heap();\n\n for (let state = 0; state < states; state++) {\n let best = Infinity;\n if (index === n) {\n if (state === nfa.accept) best = 0;\n } else {\n const step = consumeCost(state, index);\n if (step) best = step.cost + distAt(next + step.to);\n const skipped = skipSectionCost(state) + distAt(next + state);\n if (skipped < best) best = skipped;\n }\n dist[base + state] = best;\n if (best < Infinity) heap.push(best, state);\n }\n\n // Close the column under epsilon edges. They can form zero-consuming\n // cycles - a `repeat` with `min: 0` and no `max` - so this is Dijkstra on\n // the reversed epsilon graph rather than a sweep in state order.\n const done = new Uint8Array(states);\n while (heap.size > 0) {\n const { cost, item } = heap.pop();\n if (done[item] === 1 || cost > distAt(base + item)) continue;\n done[item] = 1;\n for (const edge of nfa.epsIn[item] ?? NO_EPS) {\n const candidate = cost + edge.cost;\n if (candidate < distAt(base + edge.from)) {\n dist[base + edge.from] = candidate;\n heap.push(candidate, edge.from);\n }\n }\n }\n }\n\n if (distAt(nfa.start) === Infinity) {\n // Every state has a skip-section edge and every occurrence a skip edge, so\n // the accept state is always reachable. Reaching this would be a\n // construction bug, not a template the user can fix.\n throw new LintError(\"internal: no alignment exists for this rule list.\");\n }\n\n const steps: Step[] = [];\n let index = 0;\n let state = nfa.start;\n let seen = new Set<number>([state]);\n\n while (!(index === n && state === nfa.accept)) {\n const moves: Move[] = [];\n\n const offer = (\n cost: number,\n rank: number,\n to: number,\n column: number,\n kind: StepKind,\n occ: Occurrence | null,\n ): void => {\n const total = cost + distAt(column * states + to);\n if (total === Infinity) return;\n moves.push({ kind, to, column, occ, total, rank });\n };\n\n if (index < n) {\n const step = consumeCost(state, index);\n if (step) {\n offer(\n step.cost,\n step.rank,\n step.to,\n index + 1,\n step.rank === RANK.coerce ? \"coerce\" : \"match\",\n step.occ,\n );\n }\n offer(skipSectionCost(state), RANK.skipSection, state, index + 1, \"skip-section\", null);\n }\n for (const edge of nfa.epsOut[state] ?? NO_EPS) {\n if (seen.has(edge.to)) continue;\n offer(edge.cost, edge.rank, edge.to, index, \"skip-rule\", edge.occ);\n }\n\n // Cheapest first; then the lowest-ranked edit, which is tie-break 3; then\n // the earliest state, so the walk is reproducible to the edge.\n let move: Move | undefined;\n for (const candidate of moves) {\n if (\n move === undefined ||\n candidate.total < move.total ||\n (candidate.total === move.total && candidate.rank < move.rank) ||\n (candidate.total === move.total &&\n candidate.rank === move.rank &&\n candidate.to < move.to)\n ) {\n move = candidate;\n }\n }\n if (move === undefined) {\n throw new LintError(\"internal: the alignment could not be reconstructed.\");\n }\n\n if (move.kind !== \"skip-rule\" || move.occ !== null) {\n steps.push({ kind: move.kind, index, occ: move.occ });\n }\n if (move.column !== index) {\n index = move.column;\n seen = new Set<number>();\n }\n state = move.to;\n seen.add(state);\n }\n\n return steps;\n}\n\n/* -------------------------------------------------------------------------- *\n * Findings\n * -------------------------------------------------------------------------- */\n\nfunction collapse(point: Position[\"end\"]): Position {\n return { start: { ...point }, end: { ...point } };\n}\n\n/**\n * Where a finding about the cursor position lands.\n *\n * A gap in the middle of a document anchors on the section standing where the\n * missing one should be. A gap at the *end* has no such section, and anchoring\n * on the parent - which is what the previous matcher did - spans the parent's\n * whole subtree, so the finding starts at the parent's heading and sorts to the\n * top of a report about the bottom of the file. It anchors at the parent's end\n * instead, which is where the section would have gone.\n */\nfunction anchor(\n index: number,\n sections: SectionNode[],\n parent: SectionNode | null,\n): { heading: string | null; position: Position } {\n const section = sections[index];\n if (section) {\n return { heading: section.title || null, position: section.position };\n }\n if (parent) {\n return { heading: parent.title || null, position: collapse(parent.position.end) };\n }\n const last = sections[sections.length - 1];\n if (last) return { heading: null, position: collapse(last.position.end) };\n return { heading: null, position: collapse({ line: 1, column: 1, offset: 0 }) };\n}\n\n/** How a rule's heading reads inside a longer sentence. */\nfunction describeHeading(rule: Rule): string {\n const heading = rule.heading;\n if (typeof heading === \"string\") return `\"${heading}\"`;\n if (Array.isArray(heading)) return heading.map((text) => `\"${text}\"`).join(\", \");\n if (heading === false) return \"a section with no heading\";\n if (heading !== undefined) return `/${heading.pattern}/`;\n return rule.id === undefined ? \"any section\" : `\"${rule.id}\"`;\n}\n\n/**\n * What an absent occurrence is called.\n *\n * A rule names itself by its heading where it has one, because that is the text\n * the reader will type into the document. A wildcard has only its `id`, which\n * is why one is worth writing.\n */\nfunction missingMessage(rule: Rule): string {\n const heading = rule.heading;\n if (typeof heading === \"string\") return `Missing section \"${heading}\"`;\n if (Array.isArray(heading)) {\n return `Missing one of ${heading.map((text) => `\"${text}\"`).join(\", \")}`;\n }\n if (heading === false) return \"Missing section without a heading\";\n if (heading !== undefined) return `Missing section matching /${heading.pattern}/`;\n return rule.id === undefined ? \"Missing section\" : `Missing section \"${rule.id}\"`;\n}\n\nfunction missingGroupMessage(copy: GroupCopy): string {\n const members = (copy.rule.repeat ?? []).map(describeHeading).join(\" followed by \");\n const name = copy.rule.id === undefined ? \"\" : ` \"${copy.rule.id}\"`;\n return `Missing group${name}: expected ${members}`;\n}\n\nfunction unexpectedMessage(section: SectionNode): string {\n const what =\n section.titlePosition === null\n ? \"Unexpected section without a heading\"\n : `Unexpected section \"${section.title}\"`;\n return `${what}. Add a trailing rule with min: 0 to allow sections the template does not describe.`;\n}\n\n/* -------------------------------------------------------------------------- *\n * The entry point\n * -------------------------------------------------------------------------- */\n\n/**\n * Align `sections` against `rules` and say what is missing, what is extra, and\n * which rule describes which section.\n *\n * `rules` being absent means the template says nothing about this level, which\n * is silence rather than \"no sections allowed\". An empty list is the other\n * thing: a rule list that describes no sections, so every section is\n * unexpected.\n */\nexport function matchSections(\n sections: SectionNode[],\n rules: Rule[] | undefined,\n options: MatchOptions = {},\n): MatchResult {\n const matches: Match[] = [];\n const findings: Finding[] = [];\n if (!rules) return { matches, findings };\n\n const parent = options.parent ?? null;\n const nfa = automatonFor(rules, options);\n const steps = align(sections, nfa);\n\n const taken = new Set<Occurrence>();\n for (const step of steps) {\n if ((step.kind === \"match\" || step.kind === \"coerce\") && step.occ) {\n taken.add(step.occ);\n }\n }\n\n /** The outermost enclosing `repeat` copy that is absent whole, if any. */\n const absentGroup = (occ: Occurrence): GroupCopy | null => {\n for (const group of occ.groups) {\n if (group.members.every((member) => !taken.has(member))) return group;\n }\n return null;\n };\n\n const reported = new Set<GroupCopy>();\n\n for (const step of steps) {\n const section = sections[step.index];\n if ((step.kind === \"match\" || step.kind === \"coerce\") && step.occ && section) {\n matches.push({\n rule: step.occ.rule,\n section,\n coerced: step.kind === \"coerce\",\n });\n continue;\n }\n\n if (step.kind === \"skip-section\" && section) {\n findings.push({\n type: \"unexpected_section\",\n heading: section.title || null,\n message: unexpectedMessage(section),\n position: section.position,\n severity: \"error\",\n });\n continue;\n }\n\n if (step.kind !== \"skip-rule\" || !step.occ || !step.occ.required) continue;\n\n const where = anchor(step.index, sections, parent);\n const group = absentGroup(step.occ);\n if (group) {\n if (reported.has(group)) continue;\n reported.add(group);\n findings.push({\n type: \"missing_group\",\n heading: where.heading,\n message: missingGroupMessage(group),\n position: where.position,\n severity: \"error\",\n });\n continue;\n }\n\n findings.push({\n type: \"missing_section\",\n heading: where.heading,\n message: missingMessage(step.occ.rule),\n position: where.position,\n severity: \"error\",\n });\n }\n\n return { matches, findings };\n}\n"],"mappings":";;;;;;AAiCO,SAAS,kBACd,SACA,MACA,KACW;AACX,MAAI,CAAC,KAAM,QAAO,CAAC;AAEnB,QAAM,aAAa,aAAa,OAAO;AACvC,QAAM,WAAW;AAAA,IACf,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,UAAU,KAAK;AACrB,MAAI,SAAS;AACX,UAAM,QAAQ,eAAe,OAAO;AACpC,eAAW,QAAQ,CAAC,WAAW,UAAU;AACvC,UAAI,CAAC,MAAM,KAAK,UAAU,IAAI,GAAG;AAC/B,iBAAS,KAAK;AAAA,UACZ,MAAM;AAAA,UACN,SAAS,IAAI;AAAA,UACb,SAAS,aAAa,QAAQ,CAAC,oBAAoB,OAAO;AAAA,UAC1D,UAAU,UAAU;AAAA,UACpB,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;;;ACjCO,SAAS,kBACd,SACA,MACA,KACW;AACX,MAAI,CAAC,KAAM,QAAO,CAAC;AAEnB,QAAM,a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f,SAAS,oBAAoB,KAAK;AAAA,QAClC,UAAU,MAAM;AAAA,QAChB,UAAU;AAAA,MACZ,CAAC;AACD;AAAA,IACF;AAEA,aAAS,KAAK;AAAA,MACZ,MAAM;AAAA,MACN,SAAS,MAAM;AAAA,MACf,SAAS,eAAe,KAAK,IAAI,IAAI;AAAA,MACrC,UAAU,MAAM;AAAA,MAChB,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,SAAAA,UAAS,SAAS;AAC7B;","names":["matches","BLOCK_KINDS","cursor","compiled","state","index","matches"]}
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ palette
4
+ } from "./chunk-RNVYGWIC.js";
5
+
6
+ // src/tracevals/rules/local.ts
7
+ import {
8
+ ensureModel,
9
+ fits,
10
+ modelState,
11
+ nodeLlamaCppStatus
12
+ } from "@hawkeyexl/inference";
13
+ function libraryLocalModels(connections) {
14
+ const modelsDir = connections["llama-cpp"]?.modelsDir;
15
+ const options = modelsDir === void 0 ? {} : { modelsDirectory: modelsDir };
16
+ return {
17
+ runtimePresent: async () => (await nodeLlamaCppStatus()).state === "present",
18
+ state: (model) => modelState(model, options),
19
+ fits: (model) => fits(model, options),
20
+ ensure: (model) => ensureModel(model, options)
21
+ };
22
+ }
23
+ var GB = 1024 ** 3;
24
+
25
+ // src/tracevals/reporters/conformance.ts
26
+ var count = (n, one, many) => `${String(n)} ${n === 1 ? one : many}`;
27
+ function renderCheck(report, opts = {}) {
28
+ const pc = palette(opts.color === true);
29
+ const lines = [];
30
+ for (const source of report.sources) {
31
+ const findings = report.findings.filter((f) => f.source === source.path);
32
+ if (findings.length === 0) continue;
33
+ lines.push(source.path);
34
+ for (const f of findings) {
35
+ const mark = f.outcome === "fail" ? pc.red("\u2716") : pc.yellow("?");
36
+ lines.push(` ${mark} ${f.rule} ${f.text}`);
37
+ lines.push(` ${pc.dim(`${f.observed} (${f.confidence.toFixed(2)})`)}`);
38
+ }
39
+ }
40
+ lines.push(...sessionSoFar(report));
41
+ for (const warning of report.warnings) lines.push(`${pc.yellow("!")} ${warning}`);
42
+ if (lines.length > 0) lines.push("");
43
+ lines.push(closing(report));
44
+ return lines.join("\n");
45
+ }
46
+ function sessionSoFar(report) {
47
+ const rules = report.session?.rules ?? [];
48
+ if (rules.length === 0) return [];
49
+ const flagged = rules.filter((r) => r.broken > 0 || r.needsReview > 0);
50
+ const lines = flagged.map((r) => {
51
+ const counts = [
52
+ ["broken", r.broken],
53
+ ["repaired", r.repaired],
54
+ ["needs review", r.needsReview],
55
+ ["followed", r.followed]
56
+ ];
57
+ const said = counts.filter(([, n]) => n > 0).map(([word, n]) => `${word} ${String(n)}`);
58
+ return ` ${r.source}#${r.rule} ${said.join(", ")}`;
59
+ });
60
+ const held = rules.length - flagged.length;
61
+ if (held > 0) {
62
+ lines.push(` ${count(held, "rule", "rules")} held every turn ${held === 1 ? "it" : "they"} applied to.`);
63
+ }
64
+ return ["Session so far", ...lines];
65
+ }
66
+ function closing(report) {
67
+ const head = `Last turn of ${report.sessionId.slice(0, 8)}:`;
68
+ const { summary } = report;
69
+ const scope = `${count(summary.rules, "rule", "rules")} from ${count(summary.sources, "source", "sources")}`;
70
+ switch (report.skipped) {
71
+ case "empty-turn":
72
+ return `${head} nothing happened after the last prompt.`;
73
+ case "no-sources":
74
+ return `${head} no rule sources governed it.`;
75
+ case "not-applicable":
76
+ return `${head} ${scope}, none apply to this turn.`;
77
+ case null: {
78
+ const broken = summary.fail > 0 ? `${String(summary.fail)} broken` : "None broken";
79
+ const review = summary.needsReview > 0 ? `, ${String(summary.needsReview)} needs review` : "";
80
+ return `${head} ${scope}. ${broken}${review}.`;
81
+ }
82
+ }
83
+ }
84
+ var NOT_SET_UP = "tracevals conformance is not set up; nothing to prepare.";
85
+ function renderPrepare(report) {
86
+ const lines = [];
87
+ const said = /* @__PURE__ */ new Set();
88
+ for (const m of report.models) {
89
+ if (m.state === "hosted" || said.has(m.model)) continue;
90
+ said.add(m.model);
91
+ const name = `${m.model} (${m.provider})`;
92
+ lines.push(
93
+ m.state === "downloaded" ? `${name} downloaded, ${((m.bytes ?? 0) / GB).toFixed(2)} GB.` : `${name} is ${m.state}.`
94
+ );
95
+ }
96
+ const ex = report.extraction;
97
+ if (ex !== null) {
98
+ const files = (n) => `${count(n, "file", "files")} that ${n === 1 ? "applies" : "apply"} to every session`;
99
+ if (ex.extracted > 0) {
100
+ lines.push(
101
+ `Extracted ${count(ex.rules, "rule", "rules")} from ${files(ex.extracted)}.` + (ex.cached > 0 ? ` ${String(ex.cached)} more ${ex.cached === 1 ? "was" : "were"} cached.` : "")
102
+ );
103
+ } else if (ex.cached > 0) {
104
+ lines.push(`${files(ex.cached)} ${ex.cached === 1 ? "is" : "are"} cached. Nothing to extract.`);
105
+ } else {
106
+ lines.push("No file applies to every session. Nothing to extract.");
107
+ }
108
+ }
109
+ for (const warning of report.warnings) lines.push(warning);
110
+ return lines.join("\n");
111
+ }
112
+ var NO_HOST = "No model host is running.";
113
+ function renderRelease(report) {
114
+ if (!report.hostStopped && report.released.length === 0 && report.unloaded.length === 0) {
115
+ return NO_HOST;
116
+ }
117
+ const unloaded = report.unloaded.length > 0 ? `Unloaded ${report.unloaded.join(", ")}` : "";
118
+ const stopped = report.hostStopped ? "stopped the model host" : "";
119
+ const action = [unloaded, stopped].filter((s) => s !== "").join(" and ");
120
+ const held = count(report.released.length, "session", "sessions");
121
+ return `${action === "" ? "Released the lease" : action}. ${held} held it.`;
122
+ }
123
+
124
+ export {
125
+ libraryLocalModels,
126
+ GB,
127
+ renderCheck,
128
+ NOT_SET_UP,
129
+ renderPrepare,
130
+ NO_HOST,
131
+ renderRelease
132
+ };
133
+ //# sourceMappingURL=chunk-TH4JVQPF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tracevals/rules/local.ts","../src/tracevals/reporters/conformance.ts"],"sourcesContent":["/**\n * What tracevals asks of a local model without loading it (proposal 0079,\n * gates 5, 8 and 9, and `prepare`). The inference library owns every answer;\n * this is the one seam, so a test can say \"downloading\" without a runtime.\n */\nimport {\n ensureModel,\n fits,\n modelState,\n nodeLlamaCppStatus,\n type EnsureModelResult,\n type FitsResult,\n type LlamaModelState,\n} from \"@hawkeyexl/inference\";\nimport type { ProviderConnections } from \"../../shared/providers.js\";\n\nexport interface LocalModels {\n /** Whether the llama.cpp binding is importable now, installing nothing. */\n runtimePresent(): Promise<boolean>;\n /** `ready`, `downloading` or `missing`, read without loading or fetching. */\n state(model: string): Promise<LlamaModelState>;\n /** The memory probe `auto` tiering uses. */\n fits(model: string): Promise<FitsResult>;\n /** Fetch the runtime and the weights, without loading either. */\n ensure(model: string): Promise<EnsureModelResult>;\n}\n\n/** The library's lifecycle calls, pointed at the family's models directory. */\nexport function libraryLocalModels(connections: ProviderConnections): LocalModels {\n const modelsDir = connections[\"llama-cpp\"]?.modelsDir;\n const options = modelsDir === undefined ? {} : { modelsDirectory: modelsDir };\n return {\n runtimePresent: async () => (await nodeLlamaCppStatus()).state === \"present\",\n state: (model) => modelState(model, options),\n fits: (model) => fits(model, options),\n ensure: (model) => ensureModel(model, options),\n };\n}\n\n/** Bytes in a gigabyte as the messages count them. */\nexport const GB = 1024 ** 3;\n","/**\n * Pretty output for `check`, `prepare` and `release` (proposal 0079). JSON is\n * each report as it stands, so only prose lives here. Colour is the caller's\n * decision, made once by `colorFor`.\n */\nimport { palette } from \"../../shared/color.js\";\nimport type { CheckReport } from \"../commands/check.js\";\nimport type { PrepareReport } from \"../commands/prepare.js\";\nimport type { ReleaseReport } from \"../commands/release.js\";\nimport { GB } from \"../rules/local.js\";\n\nconst count = (n: number, one: string, many: string): string =>\n `${String(n)} ${n === 1 ? one : many}`;\n\n/** Findings grouped under their source, then the closing line. */\nexport function renderCheck(report: CheckReport, opts: { color?: boolean } = {}): string {\n const pc = palette(opts.color === true);\n const lines: string[] = [];\n for (const source of report.sources) {\n const findings = report.findings.filter((f) => f.source === source.path);\n if (findings.length === 0) continue;\n lines.push(source.path);\n for (const f of findings) {\n const mark = f.outcome === \"fail\" ? pc.red(\"✖\") : pc.yellow(\"?\");\n lines.push(` ${mark} ${f.rule} ${f.text}`);\n lines.push(` ${pc.dim(`${f.observed} (${f.confidence.toFixed(2)})`)}`);\n }\n }\n lines.push(...sessionSoFar(report));\n for (const warning of report.warnings) lines.push(`${pc.yellow(\"!\")} ${warning}`);\n if (lines.length > 0) lines.push(\"\");\n lines.push(closing(report));\n return lines.join(\"\\n\");\n}\n\n/** The ledger's rules that were ever broken or sent to review, and a count of the rest. */\nfunction sessionSoFar(report: CheckReport): string[] {\n const rules = report.session?.rules ?? [];\n if (rules.length === 0) return [];\n const flagged = rules.filter((r) => r.broken > 0 || r.needsReview > 0);\n const lines = flagged.map((r) => {\n const counts = [\n [\"broken\", r.broken],\n [\"repaired\", r.repaired],\n [\"needs review\", r.needsReview],\n [\"followed\", r.followed],\n ] as const;\n const said = counts.filter(([, n]) => n > 0).map(([word, n]) => `${word} ${String(n)}`);\n return ` ${r.source}#${r.rule} ${said.join(\", \")}`;\n });\n const held = rules.length - flagged.length;\n if (held > 0) {\n lines.push(` ${count(held, \"rule\", \"rules\")} held every turn ${held === 1 ? \"it\" : \"they\"} applied to.`);\n }\n return [\"Session so far\", ...lines];\n}\n\nfunction closing(report: CheckReport): string {\n const head = `Last turn of ${report.sessionId.slice(0, 8)}:`;\n const { summary } = report;\n // \"sources\", because a typed prompt is not a file (proposal 0080).\n const scope = `${count(summary.rules, \"rule\", \"rules\")} from ${count(summary.sources, \"source\", \"sources\")}`;\n switch (report.skipped) {\n case \"empty-turn\":\n return `${head} nothing happened after the last prompt.`;\n case \"no-sources\":\n return `${head} no rule sources governed it.`;\n case \"not-applicable\":\n return `${head} ${scope}, none apply to this turn.`;\n case null: {\n const broken = summary.fail > 0 ? `${String(summary.fail)} broken` : \"None broken\";\n const review = summary.needsReview > 0 ? `, ${String(summary.needsReview)} needs review` : \"\";\n return `${head} ${scope}. ${broken}${review}.`;\n }\n }\n}\n\nexport const NOT_SET_UP = \"tracevals conformance is not set up; nothing to prepare.\";\n\nexport function renderPrepare(report: PrepareReport): string {\n const lines: string[] = [];\n const said = new Set<string>();\n for (const m of report.models) {\n if (m.state === \"hosted\" || said.has(m.model)) continue;\n said.add(m.model);\n const name = `${m.model} (${m.provider})`;\n lines.push(\n m.state === \"downloaded\"\n ? `${name} downloaded, ${((m.bytes ?? 0) / GB).toFixed(2)} GB.`\n : `${name} is ${m.state}.`,\n );\n }\n const ex = report.extraction;\n if (ex !== null) {\n const files = (n: number): string =>\n `${count(n, \"file\", \"files\")} that ${n === 1 ? \"applies\" : \"apply\"} to every session`;\n if (ex.extracted > 0) {\n lines.push(\n `Extracted ${count(ex.rules, \"rule\", \"rules\")} from ${files(ex.extracted)}.` +\n (ex.cached > 0 ? ` ${String(ex.cached)} more ${ex.cached === 1 ? \"was\" : \"were\"} cached.` : \"\"),\n );\n } else if (ex.cached > 0) {\n lines.push(`${files(ex.cached)} ${ex.cached === 1 ? \"is\" : \"are\"} cached. Nothing to extract.`);\n } else {\n lines.push(\"No file applies to every session. Nothing to extract.\");\n }\n }\n for (const warning of report.warnings) lines.push(warning);\n return lines.join(\"\\n\");\n}\n\nexport const NO_HOST = \"No model host is running.\";\n\nexport function renderRelease(report: ReleaseReport): string {\n if (!report.hostStopped && report.released.length === 0 && report.unloaded.length === 0) {\n return NO_HOST;\n }\n const unloaded = report.unloaded.length > 0 ? `Unloaded ${report.unloaded.join(\", \")}` : \"\";\n const stopped = report.hostStopped ? \"stopped the model host\" : \"\";\n const action = [unloaded, stopped].filter((s) => s !== \"\").join(\" and \");\n const held = count(report.released.length, \"session\", \"sessions\");\n return `${action === \"\" ? \"Released the lease\" : action}. ${held} held it.`;\n}\n"],"mappings":";;;;;;AAKA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAeA,SAAS,mBAAmB,aAA+C;AAChF,QAAM,YAAY,YAAY,WAAW,GAAG;AAC5C,QAAM,UAAU,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AG,WAAW,IAAI,OAAO,KAAK,8BAA8B;AAAA,IAChG,OAAO;AACL,YAAM,KAAK,uDAAuD;AAAA,IACpE;AAAA,EACF;AACA,aAAW,WAAW,OAAO,SAAU,OAAM,KAAK,OAAO;AACzD,SAAO,MAAM,KAAK,IAAI;AACxB;AAEO,IAAM,UAAU;AAEhB,SAAS,cAAc,QAA+B;AAC3D,MAAI,CAAC,OAAO,eAAe,OAAO,SAAS,WAAW,KAAK,OAAO,SAAS,WAAW,GAAG;AACvF,WAAO;AAAA,EACT;AACA,QAAM,WAAW,OAAO,SAAS,SAAS,IAAI,YAAY,OAAO,SAAS,KAAK,IAAI,CAAC,KAAK;AACzF,QAAM,UAAU,OAAO,cAAc,2BAA2B;AAChE,QAAM,SAAS,CAAC,UAAU,OAAO,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,EAAE,KAAK,OAAO;AACvE,QAAM,OAAO,MAAM,OAAO,SAAS,QAAQ,WAAW,UAAU;AAChE,SAAO,GAAG,WAAW,KAAK,uBAAuB,MAAM,KAAK,IAAI;AAClE;","names":[]}
@@ -10,7 +10,7 @@ import {
10
10
  pageMarks,
11
11
  pageSchemaSet,
12
12
  withValueAt
13
- } from "./chunk-M3W7J6MU.js";
13
+ } from "./chunk-TUAAR3MM.js";
14
14
  import {
15
15
  DocmetaError,
16
16
  escapePointerSegment,
@@ -20,12 +20,12 @@ import {
20
20
  rebaseConfigSchemaRefs,
21
21
  schemaTrustRoot,
22
22
  supportedExtensions
23
- } from "./chunk-57NEQRVO.js";
23
+ } from "./chunk-KCOFEWV5.js";
24
24
  import {
25
25
  decryptValue,
26
26
  encryptValue,
27
27
  isEncryptedValue
28
- } from "./chunk-Q35YIDBV.js";
28
+ } from "./chunk-XKBEHKWO.js";
29
29
  import {
30
30
  errorMessage
31
31
  } from "./chunk-G3T47CFV.js";
@@ -195,4 +195,4 @@ export {
195
195
  metaPageView,
196
196
  declaredAt
197
197
  };
198
- //# sourceMappingURL=chunk-QRWGPQKO.js.map
198
+ //# sourceMappingURL=chunk-TLXE7LYK.js.map