zod-args-parser 1.2.8 → 2.0.0-beta.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 (510) hide show
  1. package/README.md +525 -588
  2. package/lib/cjs/autocomplete-scripts/bash-autocomplete-script.cjs +2 -0
  3. package/lib/cjs/autocomplete-scripts/bash-autocomplete-script.cjs.map +1 -0
  4. package/lib/cjs/autocomplete-scripts/powershell-autocomplete-script.cjs +2 -0
  5. package/lib/cjs/autocomplete-scripts/powershell-autocomplete-script.cjs.map +1 -0
  6. package/lib/cjs/autocomplete-scripts/zsh-autocomplete-script.cjs +42 -0
  7. package/lib/cjs/autocomplete-scripts/zsh-autocomplete-script.cjs.map +1 -0
  8. package/lib/cjs/coerce/coerce-methods.cjs +2 -0
  9. package/lib/cjs/coerce/coerce-methods.cjs.map +1 -0
  10. package/lib/cjs/coerce/string-to-array.cjs +2 -0
  11. package/lib/cjs/coerce/string-to-array.cjs.map +1 -0
  12. package/lib/cjs/coerce/string-to-primitive.cjs +2 -0
  13. package/lib/cjs/coerce/string-to-primitive.cjs.map +1 -0
  14. package/lib/cjs/coerce/string-to-set.cjs +2 -0
  15. package/lib/cjs/coerce/string-to-set.cjs.map +1 -0
  16. package/lib/cjs/definitions/define-arguments.cjs +2 -0
  17. package/lib/cjs/definitions/define-arguments.cjs.map +1 -0
  18. package/lib/cjs/definitions/define-cli.cjs +2 -0
  19. package/lib/cjs/definitions/define-cli.cjs.map +1 -0
  20. package/lib/cjs/definitions/define-options.cjs +2 -0
  21. package/lib/cjs/definitions/define-options.cjs.map +1 -0
  22. package/lib/cjs/definitions/define-subcommand.cjs +2 -0
  23. package/lib/cjs/definitions/define-subcommand.cjs.map +1 -0
  24. package/lib/cjs/definitions/validate-cli-definition.cjs +2 -0
  25. package/lib/cjs/definitions/validate-cli-definition.cjs.map +1 -0
  26. package/lib/cjs/help-message/format-arguments.cjs +2 -0
  27. package/lib/cjs/help-message/format-arguments.cjs.map +1 -0
  28. package/lib/cjs/help-message/format-options.cjs +2 -0
  29. package/lib/cjs/help-message/format-options.cjs.map +1 -0
  30. package/lib/cjs/help-message/format-subcommands.cjs +2 -0
  31. package/lib/cjs/help-message/format-subcommands.cjs.map +1 -0
  32. package/lib/cjs/help-message/generate-for-cli.cjs +2 -0
  33. package/lib/cjs/help-message/generate-for-cli.cjs.map +1 -0
  34. package/lib/cjs/help-message/generate-for-subcommand.cjs +2 -0
  35. package/lib/cjs/help-message/generate-for-subcommand.cjs.map +1 -0
  36. package/lib/cjs/help-message/print-help.cjs +2 -0
  37. package/lib/cjs/help-message/print-help.cjs.map +1 -0
  38. package/lib/cjs/help-message/set-defaults.cjs +2 -0
  39. package/lib/cjs/help-message/set-defaults.cjs.map +1 -0
  40. package/lib/cjs/help-message/styles.cjs +2 -0
  41. package/lib/cjs/help-message/styles.cjs.map +1 -0
  42. package/lib/cjs/help-message/terminal-markdown.cjs +2 -0
  43. package/lib/cjs/help-message/terminal-markdown.cjs.map +1 -0
  44. package/lib/cjs/index.cjs +2 -0
  45. package/lib/cjs/index.cjs.map +1 -0
  46. package/lib/cjs/markdown/generate-markdown.cjs +2 -0
  47. package/lib/cjs/markdown/generate-markdown.cjs.map +1 -0
  48. package/lib/cjs/metadata/arguments-metadata.cjs +2 -0
  49. package/lib/cjs/metadata/arguments-metadata.cjs.map +1 -0
  50. package/lib/cjs/metadata/cli-metadata.cjs +2 -0
  51. package/lib/cjs/metadata/cli-metadata.cjs.map +1 -0
  52. package/lib/cjs/metadata/options-metadata.cjs +2 -0
  53. package/lib/cjs/metadata/options-metadata.cjs.map +1 -0
  54. package/lib/cjs/metadata/subcommands-metadata.cjs +2 -0
  55. package/lib/cjs/metadata/subcommands-metadata.cjs.map +1 -0
  56. package/lib/cjs/parse/context/cli-context-builder.cjs +2 -0
  57. package/lib/cjs/parse/context/cli-context-builder.cjs.map +1 -0
  58. package/lib/cjs/parse/context/object-context-builder.cjs +2 -0
  59. package/lib/cjs/parse/context/object-context-builder.cjs.map +1 -0
  60. package/lib/cjs/parse/parser-utilities.cjs +2 -0
  61. package/lib/cjs/parse/parser-utilities.cjs.map +1 -0
  62. package/lib/cjs/parse/safe-parse.cjs +2 -0
  63. package/lib/cjs/parse/safe-parse.cjs.map +1 -0
  64. package/lib/cjs/parse/validation/validate-context.cjs +2 -0
  65. package/lib/cjs/parse/validation/validate-context.cjs.map +1 -0
  66. package/lib/cjs/parse/validation/validators/arguments.cjs +2 -0
  67. package/lib/cjs/parse/validation/validators/arguments.cjs.map +1 -0
  68. package/lib/cjs/parse/validation/validators/conflict.cjs +2 -0
  69. package/lib/cjs/parse/validation/validators/conflict.cjs.map +1 -0
  70. package/lib/cjs/parse/validation/validators/exclusive.cjs +2 -0
  71. package/lib/cjs/parse/validation/validators/exclusive.cjs.map +1 -0
  72. package/lib/cjs/parse/validation/validators/explicitly-passed.cjs +2 -0
  73. package/lib/cjs/parse/validation/validators/explicitly-passed.cjs.map +1 -0
  74. package/lib/cjs/parse/validation/validators/options.cjs +2 -0
  75. package/lib/cjs/parse/validation/validators/options.cjs.map +1 -0
  76. package/lib/cjs/parse/validation/validators/requires.cjs +2 -0
  77. package/lib/cjs/parse/validation/validators/requires.cjs.map +1 -0
  78. package/lib/cjs/utilities.cjs +2 -0
  79. package/lib/cjs/utilities.cjs.map +1 -0
  80. package/lib/esm/autocomplete-scripts/bash-autocomplete-script.js +2 -0
  81. package/lib/esm/autocomplete-scripts/bash-autocomplete-script.js.map +1 -0
  82. package/lib/esm/autocomplete-scripts/powershell-autocomplete-script.js +2 -0
  83. package/lib/esm/autocomplete-scripts/powershell-autocomplete-script.js.map +1 -0
  84. package/lib/esm/autocomplete-scripts/zsh-autocomplete-script.js +42 -0
  85. package/lib/esm/autocomplete-scripts/zsh-autocomplete-script.js.map +1 -0
  86. package/lib/esm/coerce/coerce-methods.js +2 -0
  87. package/lib/esm/coerce/coerce-methods.js.map +1 -0
  88. package/lib/esm/coerce/string-to-array.js +2 -0
  89. package/lib/esm/coerce/string-to-array.js.map +1 -0
  90. package/lib/esm/coerce/string-to-primitive.js +2 -0
  91. package/lib/esm/coerce/string-to-primitive.js.map +1 -0
  92. package/lib/esm/coerce/string-to-set.js +2 -0
  93. package/lib/esm/coerce/string-to-set.js.map +1 -0
  94. package/lib/esm/definitions/define-arguments.js +2 -0
  95. package/lib/esm/definitions/define-arguments.js.map +1 -0
  96. package/lib/esm/definitions/define-cli.js +2 -0
  97. package/lib/esm/definitions/define-cli.js.map +1 -0
  98. package/lib/esm/definitions/define-options.js +2 -0
  99. package/lib/esm/definitions/define-options.js.map +1 -0
  100. package/lib/esm/definitions/define-subcommand.js +2 -0
  101. package/lib/esm/definitions/define-subcommand.js.map +1 -0
  102. package/lib/esm/definitions/validate-cli-definition.js +2 -0
  103. package/lib/esm/definitions/validate-cli-definition.js.map +1 -0
  104. package/lib/esm/help-message/format-arguments.js +2 -0
  105. package/lib/esm/help-message/format-arguments.js.map +1 -0
  106. package/lib/esm/help-message/format-options.js +2 -0
  107. package/lib/esm/help-message/format-options.js.map +1 -0
  108. package/lib/esm/help-message/format-subcommands.js +2 -0
  109. package/lib/esm/help-message/format-subcommands.js.map +1 -0
  110. package/lib/esm/help-message/generate-for-cli.js +2 -0
  111. package/lib/esm/help-message/generate-for-cli.js.map +1 -0
  112. package/lib/esm/help-message/generate-for-subcommand.js +2 -0
  113. package/lib/esm/help-message/generate-for-subcommand.js.map +1 -0
  114. package/lib/esm/help-message/print-help.js +2 -0
  115. package/lib/esm/help-message/print-help.js.map +1 -0
  116. package/lib/esm/help-message/set-defaults.js +2 -0
  117. package/lib/esm/help-message/set-defaults.js.map +1 -0
  118. package/lib/esm/help-message/styles.js +2 -0
  119. package/lib/esm/help-message/styles.js.map +1 -0
  120. package/lib/esm/help-message/terminal-markdown.js +2 -0
  121. package/lib/esm/help-message/terminal-markdown.js.map +1 -0
  122. package/lib/esm/index.js +2 -0
  123. package/lib/esm/index.js.map +1 -0
  124. package/lib/esm/markdown/generate-markdown.js +2 -0
  125. package/lib/esm/markdown/generate-markdown.js.map +1 -0
  126. package/lib/esm/metadata/arguments-metadata.js +2 -0
  127. package/lib/esm/metadata/arguments-metadata.js.map +1 -0
  128. package/lib/esm/metadata/cli-metadata.js +2 -0
  129. package/lib/esm/metadata/cli-metadata.js.map +1 -0
  130. package/lib/esm/metadata/options-metadata.js +2 -0
  131. package/lib/esm/metadata/options-metadata.js.map +1 -0
  132. package/lib/esm/metadata/subcommands-metadata.js +2 -0
  133. package/lib/esm/metadata/subcommands-metadata.js.map +1 -0
  134. package/lib/esm/parse/context/cli-context-builder.js +2 -0
  135. package/lib/esm/parse/context/cli-context-builder.js.map +1 -0
  136. package/lib/esm/parse/context/object-context-builder.js +2 -0
  137. package/lib/esm/parse/context/object-context-builder.js.map +1 -0
  138. package/lib/esm/parse/parser-utilities.js +2 -0
  139. package/lib/esm/parse/parser-utilities.js.map +1 -0
  140. package/lib/esm/parse/safe-parse.js +2 -0
  141. package/lib/esm/parse/safe-parse.js.map +1 -0
  142. package/lib/esm/parse/validation/validate-context.js +2 -0
  143. package/lib/esm/parse/validation/validate-context.js.map +1 -0
  144. package/lib/esm/parse/validation/validators/arguments.js +2 -0
  145. package/lib/esm/parse/validation/validators/arguments.js.map +1 -0
  146. package/lib/esm/parse/validation/validators/conflict.js +2 -0
  147. package/lib/esm/parse/validation/validators/conflict.js.map +1 -0
  148. package/lib/esm/parse/validation/validators/exclusive.js +2 -0
  149. package/lib/esm/parse/validation/validators/exclusive.js.map +1 -0
  150. package/lib/esm/parse/validation/validators/explicitly-passed.js +2 -0
  151. package/lib/esm/parse/validation/validators/explicitly-passed.js.map +1 -0
  152. package/lib/esm/parse/validation/validators/options.js +2 -0
  153. package/lib/esm/parse/validation/validators/options.js.map +1 -0
  154. package/lib/esm/parse/validation/validators/requires.js +2 -0
  155. package/lib/esm/parse/validation/validators/requires.js.map +1 -0
  156. package/lib/esm/utilities.js +2 -0
  157. package/lib/esm/utilities.js.map +1 -0
  158. package/lib/iife/index.js +2 -0
  159. package/lib/iife/index.js.map +1 -0
  160. package/lib/mjs/autocomplete-scripts/bash-autocomplete-script.mjs +2 -0
  161. package/lib/mjs/autocomplete-scripts/bash-autocomplete-script.mjs.map +1 -0
  162. package/lib/mjs/autocomplete-scripts/powershell-autocomplete-script.mjs +2 -0
  163. package/lib/mjs/autocomplete-scripts/powershell-autocomplete-script.mjs.map +1 -0
  164. package/lib/mjs/autocomplete-scripts/zsh-autocomplete-script.mjs +42 -0
  165. package/lib/mjs/autocomplete-scripts/zsh-autocomplete-script.mjs.map +1 -0
  166. package/lib/mjs/coerce/coerce-methods.mjs +2 -0
  167. package/lib/mjs/coerce/coerce-methods.mjs.map +1 -0
  168. package/lib/mjs/coerce/string-to-array.mjs +2 -0
  169. package/lib/mjs/coerce/string-to-array.mjs.map +1 -0
  170. package/lib/mjs/coerce/string-to-primitive.mjs +2 -0
  171. package/lib/mjs/coerce/string-to-primitive.mjs.map +1 -0
  172. package/lib/mjs/coerce/string-to-set.mjs +2 -0
  173. package/lib/mjs/coerce/string-to-set.mjs.map +1 -0
  174. package/lib/mjs/definitions/define-arguments.mjs +2 -0
  175. package/lib/mjs/definitions/define-arguments.mjs.map +1 -0
  176. package/lib/mjs/definitions/define-cli.mjs +2 -0
  177. package/lib/mjs/definitions/define-cli.mjs.map +1 -0
  178. package/lib/mjs/definitions/define-options.mjs +2 -0
  179. package/lib/mjs/definitions/define-options.mjs.map +1 -0
  180. package/lib/mjs/definitions/define-subcommand.mjs +2 -0
  181. package/lib/mjs/definitions/define-subcommand.mjs.map +1 -0
  182. package/lib/mjs/definitions/validate-cli-definition.mjs +2 -0
  183. package/lib/mjs/definitions/validate-cli-definition.mjs.map +1 -0
  184. package/lib/mjs/help-message/format-arguments.mjs +2 -0
  185. package/lib/mjs/help-message/format-arguments.mjs.map +1 -0
  186. package/lib/mjs/help-message/format-options.mjs +2 -0
  187. package/lib/mjs/help-message/format-options.mjs.map +1 -0
  188. package/lib/mjs/help-message/format-subcommands.mjs +2 -0
  189. package/lib/mjs/help-message/format-subcommands.mjs.map +1 -0
  190. package/lib/mjs/help-message/generate-for-cli.mjs +2 -0
  191. package/lib/mjs/help-message/generate-for-cli.mjs.map +1 -0
  192. package/lib/mjs/help-message/generate-for-subcommand.mjs +2 -0
  193. package/lib/mjs/help-message/generate-for-subcommand.mjs.map +1 -0
  194. package/lib/mjs/help-message/print-help.mjs +2 -0
  195. package/lib/mjs/help-message/print-help.mjs.map +1 -0
  196. package/lib/mjs/help-message/set-defaults.mjs +2 -0
  197. package/lib/mjs/help-message/set-defaults.mjs.map +1 -0
  198. package/lib/mjs/help-message/styles.mjs +2 -0
  199. package/lib/mjs/help-message/styles.mjs.map +1 -0
  200. package/lib/mjs/help-message/terminal-markdown.mjs +2 -0
  201. package/lib/mjs/help-message/terminal-markdown.mjs.map +1 -0
  202. package/lib/mjs/index.mjs +2 -0
  203. package/lib/mjs/index.mjs.map +1 -0
  204. package/lib/mjs/markdown/generate-markdown.mjs +2 -0
  205. package/lib/mjs/markdown/generate-markdown.mjs.map +1 -0
  206. package/lib/mjs/metadata/arguments-metadata.mjs +2 -0
  207. package/lib/mjs/metadata/arguments-metadata.mjs.map +1 -0
  208. package/lib/mjs/metadata/cli-metadata.mjs +2 -0
  209. package/lib/mjs/metadata/cli-metadata.mjs.map +1 -0
  210. package/lib/mjs/metadata/options-metadata.mjs +2 -0
  211. package/lib/mjs/metadata/options-metadata.mjs.map +1 -0
  212. package/lib/mjs/metadata/subcommands-metadata.mjs +2 -0
  213. package/lib/mjs/metadata/subcommands-metadata.mjs.map +1 -0
  214. package/lib/mjs/parse/context/cli-context-builder.mjs +2 -0
  215. package/lib/mjs/parse/context/cli-context-builder.mjs.map +1 -0
  216. package/lib/mjs/parse/context/object-context-builder.mjs +2 -0
  217. package/lib/mjs/parse/context/object-context-builder.mjs.map +1 -0
  218. package/lib/mjs/parse/parser-utilities.mjs +2 -0
  219. package/lib/mjs/parse/parser-utilities.mjs.map +1 -0
  220. package/lib/mjs/parse/safe-parse.mjs +2 -0
  221. package/lib/mjs/parse/safe-parse.mjs.map +1 -0
  222. package/lib/mjs/parse/validation/validate-context.mjs +2 -0
  223. package/lib/mjs/parse/validation/validate-context.mjs.map +1 -0
  224. package/lib/mjs/parse/validation/validators/arguments.mjs +2 -0
  225. package/lib/mjs/parse/validation/validators/arguments.mjs.map +1 -0
  226. package/lib/mjs/parse/validation/validators/conflict.mjs +2 -0
  227. package/lib/mjs/parse/validation/validators/conflict.mjs.map +1 -0
  228. package/lib/mjs/parse/validation/validators/exclusive.mjs +2 -0
  229. package/lib/mjs/parse/validation/validators/exclusive.mjs.map +1 -0
  230. package/lib/mjs/parse/validation/validators/explicitly-passed.mjs +2 -0
  231. package/lib/mjs/parse/validation/validators/explicitly-passed.mjs.map +1 -0
  232. package/lib/mjs/parse/validation/validators/options.mjs +2 -0
  233. package/lib/mjs/parse/validation/validators/options.mjs.map +1 -0
  234. package/lib/mjs/parse/validation/validators/requires.mjs +2 -0
  235. package/lib/mjs/parse/validation/validators/requires.mjs.map +1 -0
  236. package/lib/mjs/utilities.mjs +2 -0
  237. package/lib/mjs/utilities.mjs.map +1 -0
  238. package/lib/typescript/autocomplete-scripts/bash-autocomplete-script.d.ts +2 -2
  239. package/lib/typescript/autocomplete-scripts/bash-autocomplete-script.d.ts.map +1 -1
  240. package/lib/typescript/autocomplete-scripts/powershell-autocomplete-script.d.ts +2 -2
  241. package/lib/typescript/autocomplete-scripts/powershell-autocomplete-script.d.ts.map +1 -1
  242. package/lib/typescript/autocomplete-scripts/zsh-autocomplete-script.d.ts +2 -2
  243. package/lib/typescript/autocomplete-scripts/zsh-autocomplete-script.d.ts.map +1 -1
  244. package/lib/typescript/coerce/coerce-methods.d.ts +20 -0
  245. package/lib/typescript/coerce/coerce-methods.d.ts.map +1 -0
  246. package/lib/typescript/coerce/string-to-array.d.ts +6 -0
  247. package/lib/typescript/coerce/string-to-array.d.ts.map +1 -0
  248. package/lib/typescript/coerce/string-to-primitive.d.ts +5 -0
  249. package/lib/typescript/coerce/string-to-primitive.d.ts.map +1 -0
  250. package/lib/typescript/coerce/string-to-set.d.ts +6 -0
  251. package/lib/typescript/coerce/string-to-set.d.ts.map +1 -0
  252. package/lib/typescript/definitions/define-arguments.d.ts +7 -0
  253. package/lib/typescript/definitions/define-arguments.d.ts.map +1 -0
  254. package/lib/typescript/definitions/define-cli.d.ts +24 -0
  255. package/lib/typescript/definitions/define-cli.d.ts.map +1 -0
  256. package/lib/typescript/definitions/define-options.d.ts +7 -0
  257. package/lib/typescript/definitions/define-options.d.ts.map +1 -0
  258. package/lib/typescript/definitions/define-subcommand.d.ts +17 -0
  259. package/lib/typescript/definitions/define-subcommand.d.ts.map +1 -0
  260. package/lib/typescript/definitions/validate-cli-definition.d.ts +4 -0
  261. package/lib/typescript/definitions/validate-cli-definition.d.ts.map +1 -0
  262. package/lib/typescript/help-message/format-arguments.d.ts +3 -3
  263. package/lib/typescript/help-message/format-arguments.d.ts.map +1 -1
  264. package/lib/typescript/help-message/format-options.d.ts +3 -3
  265. package/lib/typescript/help-message/format-options.d.ts.map +1 -1
  266. package/lib/typescript/help-message/format-subcommands.d.ts +3 -3
  267. package/lib/typescript/help-message/format-subcommands.d.ts.map +1 -1
  268. package/lib/typescript/help-message/generate-for-cli.d.ts +8 -0
  269. package/lib/typescript/help-message/generate-for-cli.d.ts.map +1 -0
  270. package/lib/typescript/help-message/generate-for-subcommand.d.ts +4 -0
  271. package/lib/typescript/help-message/generate-for-subcommand.d.ts.map +1 -0
  272. package/lib/typescript/help-message/print-help.d.ts +5 -0
  273. package/lib/typescript/help-message/print-help.d.ts.map +1 -0
  274. package/lib/typescript/help-message/set-defaults.d.ts +4 -0
  275. package/lib/typescript/help-message/set-defaults.d.ts.map +1 -0
  276. package/lib/typescript/help-message/styles.d.ts +30 -106
  277. package/lib/typescript/help-message/styles.d.ts.map +1 -1
  278. package/lib/typescript/help-message/terminal-markdown.d.ts +3 -0
  279. package/lib/typescript/help-message/terminal-markdown.d.ts.map +1 -0
  280. package/lib/typescript/index.d.ts +23 -35
  281. package/lib/typescript/index.d.ts.map +1 -1
  282. package/lib/typescript/markdown/generate-markdown.d.ts +2 -2
  283. package/lib/typescript/markdown/generate-markdown.d.ts.map +1 -1
  284. package/lib/typescript/metadata/arguments-metadata.d.ts +4 -0
  285. package/lib/typescript/metadata/arguments-metadata.d.ts.map +1 -0
  286. package/lib/typescript/metadata/cli-metadata.d.ts +4 -0
  287. package/lib/typescript/metadata/cli-metadata.d.ts.map +1 -0
  288. package/lib/typescript/metadata/options-metadata.d.ts +4 -0
  289. package/lib/typescript/metadata/options-metadata.d.ts.map +1 -0
  290. package/lib/typescript/metadata/subcommands-metadata.d.ts +4 -0
  291. package/lib/typescript/metadata/subcommands-metadata.d.ts.map +1 -0
  292. package/lib/typescript/parse/context/cli-context-builder.d.ts +9 -0
  293. package/lib/typescript/parse/context/cli-context-builder.d.ts.map +1 -0
  294. package/lib/typescript/parse/context/object-context-builder.d.ts +6 -0
  295. package/lib/typescript/parse/context/object-context-builder.d.ts.map +1 -0
  296. package/lib/typescript/{parser/parse/parser-helpers.d.ts → parse/parser-utilities.d.ts} +18 -9
  297. package/lib/typescript/parse/parser-utilities.d.ts.map +1 -0
  298. package/lib/typescript/parse/safe-parse.d.ts +5 -0
  299. package/lib/typescript/parse/safe-parse.d.ts.map +1 -0
  300. package/lib/typescript/parse/validation/validate-context.d.ts +6 -0
  301. package/lib/typescript/parse/validation/validate-context.d.ts.map +1 -0
  302. package/lib/typescript/parse/validation/validators/arguments.d.ts +12 -0
  303. package/lib/typescript/parse/validation/validators/arguments.d.ts.map +1 -0
  304. package/lib/typescript/parse/validation/validators/conflict.d.ts +16 -0
  305. package/lib/typescript/parse/validation/validators/conflict.d.ts.map +1 -0
  306. package/lib/typescript/parse/validation/validators/exclusive.d.ts +16 -0
  307. package/lib/typescript/parse/validation/validators/exclusive.d.ts.map +1 -0
  308. package/lib/typescript/parse/validation/validators/explicitly-passed.d.ts +5 -0
  309. package/lib/typescript/parse/validation/validators/explicitly-passed.d.ts.map +1 -0
  310. package/lib/typescript/parse/validation/validators/options.d.ts +12 -0
  311. package/lib/typescript/parse/validation/validators/options.d.ts.map +1 -0
  312. package/lib/typescript/parse/validation/validators/requires.d.ts +18 -0
  313. package/lib/typescript/parse/validation/validators/requires.d.ts.map +1 -0
  314. package/lib/typescript/types/context-types.d.ts +135 -0
  315. package/lib/typescript/types/context-types.d.ts.map +1 -0
  316. package/lib/typescript/types/definitions-types.d.ts +294 -0
  317. package/lib/typescript/types/definitions-types.d.ts.map +1 -0
  318. package/lib/typescript/types/help-message-types.d.ts +134 -0
  319. package/lib/typescript/types/help-message-types.d.ts.map +1 -0
  320. package/lib/typescript/types/io-types.d.ts +96 -0
  321. package/lib/typescript/types/io-types.d.ts.map +1 -0
  322. package/lib/typescript/types/metadata-types.d.ts +75 -0
  323. package/lib/typescript/types/metadata-types.d.ts.map +1 -0
  324. package/lib/typescript/types/schema-types.d.ts +6 -0
  325. package/lib/typescript/types/schema-types.d.ts.map +1 -0
  326. package/lib/typescript/types/types.d.ts +61 -0
  327. package/lib/typescript/types/types.d.ts.map +1 -0
  328. package/lib/typescript/types/utilities-types.d.ts +17 -0
  329. package/lib/typescript/types/utilities-types.d.ts.map +1 -0
  330. package/lib/typescript/utilities.d.ts +24 -10
  331. package/lib/typescript/utilities.d.ts.map +1 -1
  332. package/package.json +29 -26
  333. package/src/autocomplete-scripts/bash-autocomplete-script.ts +13 -9
  334. package/src/autocomplete-scripts/powershell-autocomplete-script.ts +21 -13
  335. package/src/autocomplete-scripts/zsh-autocomplete-script.ts +27 -23
  336. package/src/coerce/coerce-methods.ts +75 -0
  337. package/src/coerce/string-to-array.ts +18 -0
  338. package/src/coerce/string-to-primitive.ts +31 -0
  339. package/src/coerce/string-to-set.ts +15 -0
  340. package/src/definitions/define-arguments.ts +10 -0
  341. package/src/definitions/define-cli.ts +105 -0
  342. package/src/definitions/define-options.ts +12 -0
  343. package/src/definitions/define-subcommand.ts +57 -0
  344. package/src/definitions/validate-cli-definition.ts +331 -0
  345. package/src/help-message/format-arguments.ts +57 -33
  346. package/src/help-message/format-options.ts +59 -34
  347. package/src/help-message/format-subcommands.ts +43 -21
  348. package/src/help-message/generate-for-cli.ts +114 -0
  349. package/src/help-message/generate-for-subcommand.ts +32 -0
  350. package/src/help-message/print-help.ts +13 -0
  351. package/src/help-message/set-defaults.ts +34 -0
  352. package/src/help-message/styles.ts +148 -103
  353. package/src/help-message/terminal-markdown.ts +147 -0
  354. package/src/index.ts +28 -97
  355. package/src/markdown/generate-markdown.ts +47 -58
  356. package/src/metadata/arguments-metadata.ts +28 -0
  357. package/src/metadata/cli-metadata.ts +26 -0
  358. package/src/metadata/options-metadata.ts +38 -0
  359. package/src/metadata/subcommands-metadata.ts +35 -0
  360. package/src/parse/context/cli-context-builder.ts +246 -0
  361. package/src/parse/context/object-context-builder.ts +63 -0
  362. package/src/{parser/parse/parser-helpers.ts → parse/parser-utilities.ts} +46 -25
  363. package/src/parse/safe-parse.ts +76 -0
  364. package/src/parse/validation/validate-context.ts +23 -0
  365. package/src/parse/validation/validators/arguments.ts +59 -0
  366. package/src/parse/validation/validators/conflict.ts +68 -0
  367. package/src/parse/validation/validators/exclusive.ts +70 -0
  368. package/src/parse/validation/validators/explicitly-passed.ts +15 -0
  369. package/src/parse/validation/validators/options.ts +59 -0
  370. package/src/parse/validation/validators/requires.ts +82 -0
  371. package/src/types/context-types.ts +171 -0
  372. package/src/types/definitions-types.ts +340 -0
  373. package/src/types/help-message-types.ts +153 -0
  374. package/src/types/io-types.ts +131 -0
  375. package/src/types/metadata-types.ts +104 -0
  376. package/src/types/schema-types.ts +9 -0
  377. package/src/types/types.ts +72 -0
  378. package/src/types/utilities-types.ts +26 -0
  379. package/src/utilities.ts +200 -23
  380. package/lib/commonjs/autocomplete-scripts/bash-autocomplete-script.cjs +0 -42
  381. package/lib/commonjs/autocomplete-scripts/bash-autocomplete-script.cjs.map +0 -1
  382. package/lib/commonjs/autocomplete-scripts/powershell-autocomplete-script.cjs +0 -31
  383. package/lib/commonjs/autocomplete-scripts/powershell-autocomplete-script.cjs.map +0 -1
  384. package/lib/commonjs/autocomplete-scripts/zsh-autocomplete-script.cjs +0 -41
  385. package/lib/commonjs/autocomplete-scripts/zsh-autocomplete-script.cjs.map +0 -1
  386. package/lib/commonjs/help-message/format-arguments.cjs +0 -1
  387. package/lib/commonjs/help-message/format-arguments.cjs.map +0 -1
  388. package/lib/commonjs/help-message/format-cli.cjs +0 -1
  389. package/lib/commonjs/help-message/format-cli.cjs.map +0 -1
  390. package/lib/commonjs/help-message/format-options.cjs +0 -1
  391. package/lib/commonjs/help-message/format-options.cjs.map +0 -1
  392. package/lib/commonjs/help-message/format-subcommands.cjs +0 -1
  393. package/lib/commonjs/help-message/format-subcommands.cjs.map +0 -1
  394. package/lib/commonjs/help-message/styles.cjs +0 -1
  395. package/lib/commonjs/help-message/styles.cjs.map +0 -1
  396. package/lib/commonjs/index.cjs +0 -1
  397. package/lib/commonjs/index.cjs.map +0 -1
  398. package/lib/commonjs/markdown/generate-markdown.cjs +0 -1
  399. package/lib/commonjs/markdown/generate-markdown.cjs.map +0 -1
  400. package/lib/commonjs/metadata/get-arguments-metadata.cjs +0 -1
  401. package/lib/commonjs/metadata/get-arguments-metadata.cjs.map +0 -1
  402. package/lib/commonjs/metadata/get-cli-metadata.cjs +0 -1
  403. package/lib/commonjs/metadata/get-cli-metadata.cjs.map +0 -1
  404. package/lib/commonjs/metadata/get-options-metadata.cjs +0 -1
  405. package/lib/commonjs/metadata/get-options-metadata.cjs.map +0 -1
  406. package/lib/commonjs/metadata/get-subcommands-metadata.cjs +0 -1
  407. package/lib/commonjs/metadata/get-subcommands-metadata.cjs.map +0 -1
  408. package/lib/commonjs/parser/parse/parse.cjs +0 -1
  409. package/lib/commonjs/parser/parse/parse.cjs.map +0 -1
  410. package/lib/commonjs/parser/parse/parser-helpers.cjs +0 -1
  411. package/lib/commonjs/parser/parse/parser-helpers.cjs.map +0 -1
  412. package/lib/commonjs/parser/safe-parse.cjs +0 -1
  413. package/lib/commonjs/parser/safe-parse.cjs.map +0 -1
  414. package/lib/commonjs/parser/unsafe-parse.cjs +0 -1
  415. package/lib/commonjs/parser/unsafe-parse.cjs.map +0 -1
  416. package/lib/commonjs/parser/validate/validate-type.cjs +0 -1
  417. package/lib/commonjs/parser/validate/validate-type.cjs.map +0 -1
  418. package/lib/commonjs/parser/validate/validate.cjs +0 -1
  419. package/lib/commonjs/parser/validate/validate.cjs.map +0 -1
  420. package/lib/commonjs/utilities.cjs +0 -1
  421. package/lib/commonjs/utilities.cjs.map +0 -1
  422. package/lib/commonjs/zod-utilities.cjs +0 -1
  423. package/lib/commonjs/zod-utilities.cjs.map +0 -1
  424. package/lib/module/autocomplete-scripts/bash-autocomplete-script.mjs +0 -42
  425. package/lib/module/autocomplete-scripts/bash-autocomplete-script.mjs.map +0 -1
  426. package/lib/module/autocomplete-scripts/powershell-autocomplete-script.mjs +0 -31
  427. package/lib/module/autocomplete-scripts/powershell-autocomplete-script.mjs.map +0 -1
  428. package/lib/module/autocomplete-scripts/zsh-autocomplete-script.mjs +0 -41
  429. package/lib/module/autocomplete-scripts/zsh-autocomplete-script.mjs.map +0 -1
  430. package/lib/module/help-message/format-arguments.mjs +0 -1
  431. package/lib/module/help-message/format-arguments.mjs.map +0 -1
  432. package/lib/module/help-message/format-cli.mjs +0 -1
  433. package/lib/module/help-message/format-cli.mjs.map +0 -1
  434. package/lib/module/help-message/format-options.mjs +0 -1
  435. package/lib/module/help-message/format-options.mjs.map +0 -1
  436. package/lib/module/help-message/format-subcommands.mjs +0 -1
  437. package/lib/module/help-message/format-subcommands.mjs.map +0 -1
  438. package/lib/module/help-message/styles.mjs +0 -1
  439. package/lib/module/help-message/styles.mjs.map +0 -1
  440. package/lib/module/index.mjs +0 -1
  441. package/lib/module/index.mjs.map +0 -1
  442. package/lib/module/markdown/generate-markdown.mjs +0 -1
  443. package/lib/module/markdown/generate-markdown.mjs.map +0 -1
  444. package/lib/module/metadata/get-arguments-metadata.mjs +0 -1
  445. package/lib/module/metadata/get-arguments-metadata.mjs.map +0 -1
  446. package/lib/module/metadata/get-cli-metadata.mjs +0 -1
  447. package/lib/module/metadata/get-cli-metadata.mjs.map +0 -1
  448. package/lib/module/metadata/get-options-metadata.mjs +0 -1
  449. package/lib/module/metadata/get-options-metadata.mjs.map +0 -1
  450. package/lib/module/metadata/get-subcommands-metadata.mjs +0 -1
  451. package/lib/module/metadata/get-subcommands-metadata.mjs.map +0 -1
  452. package/lib/module/parser/parse/parse.mjs +0 -1
  453. package/lib/module/parser/parse/parse.mjs.map +0 -1
  454. package/lib/module/parser/parse/parser-helpers.mjs +0 -1
  455. package/lib/module/parser/parse/parser-helpers.mjs.map +0 -1
  456. package/lib/module/parser/safe-parse.mjs +0 -1
  457. package/lib/module/parser/safe-parse.mjs.map +0 -1
  458. package/lib/module/parser/unsafe-parse.mjs +0 -1
  459. package/lib/module/parser/unsafe-parse.mjs.map +0 -1
  460. package/lib/module/parser/validate/validate-type.mjs +0 -1
  461. package/lib/module/parser/validate/validate-type.mjs.map +0 -1
  462. package/lib/module/parser/validate/validate.mjs +0 -1
  463. package/lib/module/parser/validate/validate.mjs.map +0 -1
  464. package/lib/module/utilities.mjs +0 -1
  465. package/lib/module/utilities.mjs.map +0 -1
  466. package/lib/module/zod-utilities.mjs +0 -1
  467. package/lib/module/zod-utilities.mjs.map +0 -1
  468. package/lib/typescript/help-message/format-cli.d.ts +0 -6
  469. package/lib/typescript/help-message/format-cli.d.ts.map +0 -1
  470. package/lib/typescript/metadata/get-arguments-metadata.d.ts +0 -4
  471. package/lib/typescript/metadata/get-arguments-metadata.d.ts.map +0 -1
  472. package/lib/typescript/metadata/get-cli-metadata.d.ts +0 -4
  473. package/lib/typescript/metadata/get-cli-metadata.d.ts.map +0 -1
  474. package/lib/typescript/metadata/get-options-metadata.d.ts +0 -4
  475. package/lib/typescript/metadata/get-options-metadata.d.ts.map +0 -1
  476. package/lib/typescript/metadata/get-subcommands-metadata.d.ts +0 -4
  477. package/lib/typescript/metadata/get-subcommands-metadata.d.ts.map +0 -1
  478. package/lib/typescript/metadata/metadata-types.d.ts +0 -80
  479. package/lib/typescript/metadata/metadata-types.d.ts.map +0 -1
  480. package/lib/typescript/parser/parse/parse-types.d.ts +0 -85
  481. package/lib/typescript/parser/parse/parse-types.d.ts.map +0 -1
  482. package/lib/typescript/parser/parse/parse.d.ts +0 -4
  483. package/lib/typescript/parser/parse/parse.d.ts.map +0 -1
  484. package/lib/typescript/parser/parse/parser-helpers.d.ts.map +0 -1
  485. package/lib/typescript/parser/safe-parse.d.ts +0 -4
  486. package/lib/typescript/parser/safe-parse.d.ts.map +0 -1
  487. package/lib/typescript/parser/unsafe-parse.d.ts +0 -4
  488. package/lib/typescript/parser/unsafe-parse.d.ts.map +0 -1
  489. package/lib/typescript/parser/validate/validate-type.d.ts +0 -22
  490. package/lib/typescript/parser/validate/validate-type.d.ts.map +0 -1
  491. package/lib/typescript/parser/validate/validate.d.ts +0 -11
  492. package/lib/typescript/parser/validate/validate.d.ts.map +0 -1
  493. package/lib/typescript/types.d.ts +0 -294
  494. package/lib/typescript/types.d.ts.map +0 -1
  495. package/lib/typescript/zod-utilities.d.ts +0 -28
  496. package/lib/typescript/zod-utilities.d.ts.map +0 -1
  497. package/src/help-message/format-cli.ts +0 -141
  498. package/src/metadata/get-arguments-metadata.ts +0 -25
  499. package/src/metadata/get-cli-metadata.ts +0 -23
  500. package/src/metadata/get-options-metadata.ts +0 -35
  501. package/src/metadata/get-subcommands-metadata.ts +0 -32
  502. package/src/metadata/metadata-types.ts +0 -114
  503. package/src/parser/parse/parse-types.ts +0 -89
  504. package/src/parser/parse/parse.ts +0 -230
  505. package/src/parser/safe-parse.ts +0 -103
  506. package/src/parser/unsafe-parse.ts +0 -98
  507. package/src/parser/validate/validate-type.ts +0 -21
  508. package/src/parser/validate/validate.ts +0 -66
  509. package/src/types.ts +0 -365
  510. package/src/zod-utilities.ts +0 -214
@@ -0,0 +1 @@
1
+ {"version":3,"names":["findSubcommandDefinition","subcommandName","cliDefinition","subcommands","find","c","name","aliases","includes","findOption","optionArgument","options","validVariableNames","optionArgumentToVariableNames","isNegated","startsWith","Object","entries","optionName","option","has","isBool","_preparedType","coerceTo","negateOption","some","a","map","alias","decoupleFlags","arguments_","flagsRe","result","argument","test","push","decoupledArray","slice","split","Error","toLowerCase","results","Set","camelCase","replace","m","toUpperCase","add","snake_case","g","isFlagArgument","isLongArgument","isOptionArgument","transformOptionToArgument","length","match","index"],"sources":["../../../src/parse/parser-utilities.ts"],"sourcesContent":["import type { Cli, Option, Subcommand } from \"../types/definitions-types.ts\";\n\n/**\n * Retrieves a subcommand object from an array of subcommands by matching the provided subcommand name against the\n * subcommand's name or its aliases.\n *\n * @param subcommandName - The name or alias of the subcommand to search for.\n * @param subcommandArr - An array of `Subcommand` objects to search within.\n * @returns The matching `Subcommand` object if found; otherwise, `undefined`.\n */\nexport function findSubcommandDefinition(\n subcommandName: string | undefined,\n cliDefinition: Cli,\n): Subcommand | Cli | undefined {\n if (subcommandName === undefined) {\n return cliDefinition;\n }\n\n if (!cliDefinition.subcommands) {\n return;\n }\n\n return cliDefinition.subcommands.find(c => {\n // match for undefined too\n if (c.name === subcommandName) {\n return true;\n }\n\n // match for aliases\n return subcommandName && c.aliases && c.aliases.includes(subcommandName);\n });\n}\n\n/**\n * Finds and returns an `Option` object from the provided list that matches the given argument string.\n *\n * The function supports matching by option name, aliases, and their negated forms (e.g., `--no-` prefix).\n *\n * @param optionArgument - The argument string to match (e.g., `--foo`, `--no-bar`, `-f`).\n * @param options - An array of `Option` objects to search through.\n * @returns The matching `Option` object if found; otherwise, `undefined`.\n */\nexport function findOption(optionArgument: string, options: Record<string, Option>): [string, Option] | undefined {\n const validVariableNames = optionArgumentToVariableNames(optionArgument);\n const isNegated = optionArgument.startsWith(\"--no-\");\n\n const option = Object.entries(options).find(([optionName, option]) => {\n if (validVariableNames.has(optionName)) {\n return true;\n }\n\n const isBool = option._preparedType && option._preparedType.coerceTo === \"boolean\";\n\n if (isNegated && isBool && validVariableNames.has(negateOption(optionName))) {\n return true;\n }\n\n if (!option.aliases) {\n return false;\n }\n\n if (option.aliases.some(a => validVariableNames.has(a))) {\n return true;\n }\n\n if (isNegated && isBool && option.aliases.map(alias => negateOption(alias)).some(a => validVariableNames.has(a))) {\n return true;\n }\n\n return false;\n });\n\n return option;\n}\n\n/** - Decouple flags E.g. `-rf` -> `-r, -f` */\nexport function decoupleFlags(arguments_: string[]): string[] {\n const flagsRe = /^-[a-z0-9]{2,}$/i;\n\n const result = [];\n for (const argument of arguments_) {\n const isCoupled = flagsRe.test(argument);\n\n if (!isCoupled) {\n result.push(argument);\n continue;\n }\n\n const decoupledArray = argument\n .slice(1)\n .split(\"\")\n .map(c => \"-\" + c);\n\n result.push(...decoupledArray);\n }\n\n return result;\n}\n\n/**\n * Transforms an option name to a set of variants: `camelCase`, `PascalCase`, `snake_case`, `SCREAMING_SNAKE_CASE`.\n *\n * **Example** for `--input-dir`\n *\n * - CamelCase: `inputDir`\n * - PascalCase: `InputDir`\n * - Snake_case: `input_dir`\n * - SCREAMING_SNAKE_CASE: `INPUT_DIR`\n *\n * @param name - Should start with `'--'` or `'-'`\n */\nexport function optionArgumentToVariableNames(name: string): Set<string> {\n if (!name.startsWith(\"-\")) {\n throw new Error(`invalid option name: ${name}`);\n }\n\n name = name.startsWith(\"--\") ? name.slice(2) : name.slice(1); // remove prefix\n name = name.toLowerCase(); // lowercase\n\n const results = new Set<string>();\n\n // camelCase\n const camelCase = name.replace(/-(.)/g, m => m[1].toUpperCase());\n results.add(camelCase);\n\n // PascalCase (UpperCamelCase)\n results.add(camelCase.replace(/^(.)/, m => m.toUpperCase()));\n\n // snake_case\n const snake_case = name.replace(/-(.)/g, g => \"_\" + g[1]);\n results.add(snake_case);\n\n // SCREAMING_SNAKE_CASE\n results.add(snake_case.toUpperCase());\n\n return results;\n}\n\n/** - Check if an arg string is a short arg. E.g. `-i` -> `true` */\nexport function isFlagArgument(name: string): boolean {\n return /^-[A-Za-z]$/.test(name);\n}\n\n/** - Check if an arg string is a long arg. E.g. `--input-dir` -> `true` */\nfunction isLongArgument(name: string): boolean {\n return /^--[A-Za-z-]+[A-Za-z0-9]$/.test(name);\n}\n\n/** - Check if an arg string is an options arg. E.g. `--input-dir` -> `true` , `-i` -> `true` */\nexport function isOptionArgument(name: string | boolean): boolean {\n if (typeof name !== \"string\") {\n return false;\n }\n\n return isFlagArgument(name) || isLongArgument(name);\n}\n\n/**\n * Transform option name to no name.\n *\n * - `verbose` -> `noVerbose`\n * - `v` -> `noV`\n */\nexport function negateOption(name: string): string {\n return \"no\" + name.replace(/^[a-z]/, g => g.toUpperCase());\n}\n\n/** - Reverse of `transformArg`. E.g. `InputDir` -> `--input-dir` , `i` -> `-i` */\nexport function transformOptionToArgument(name: string): string {\n // single letter option name\n if (name.length === 1) {\n return `-${name.toLowerCase()}`;\n }\n\n // snake_case, SCREAMING_SNAKE_CASE\n if (/^[a-z_]+$/.test(name) || /^[A-Z_]+$/.test(name)) {\n name = name.replace(/_/g, \"-\");\n return `--${name.toLowerCase()}`;\n }\n\n // camelCase, PascalCase\n\n // add \"-\" before camel case letters except for the first letter\n name = name.replace(/[A-Z]/g, (match, index: number) => (index > 0 ? \"-\" + match : match));\n\n return `--${name.toLowerCase()}`;\n}\n"],"mappings":"AAUO,SAASA,yBACdC,EACAC,GAEA,YAAuB,IAAnBD,EACKC,EAGJA,EAAcC,YAIZD,EAAcC,YAAYC,KAAKC,GAEhCA,EAAEC,OAASL,GAKRA,GAAkBI,EAAEE,SAAWF,EAAEE,QAAQC,SAASP,SAX3D,CAaF,CAWO,SAASQ,WAAWC,EAAwBC,GACjD,MAAMC,EAAqBC,8BAA8BH,GACnDI,EAAYJ,EAAeK,WAAW,SA4B5C,OA1BeC,OAAOC,QAAQN,GAASP,KAAK,EAAEc,EAAYC,MACxD,GAAIP,EAAmBQ,IAAIF,GACzB,OAAO,EAGT,MAAMG,EAASF,EAAOG,eAAmD,YAAlCH,EAAOG,cAAcC,SAE5D,SAAIT,GAAaO,GAAUT,EAAmBQ,IAAII,aAAaN,QAI1DC,EAAOZ,YAIRY,EAAOZ,QAAQkB,KAAKC,GAAKd,EAAmBQ,IAAIM,QAIhDZ,GAAaO,GAAUF,EAAOZ,QAAQoB,IAAIC,GAASJ,aAAaI,IAAQH,KAAKC,GAAKd,EAAmBQ,IAAIM,OAQjH,CAGO,SAASG,cAAcC,GAC5B,MAAMC,EAAU,mBAEVC,EAAS,GACf,UAAWC,KAAYH,EAAY,CAGjC,IAFkBC,EAAQG,KAAKD,GAEf,CACdD,EAAOG,KAAKF,GACZ,QACF,CAEA,MAAMG,EAAiBH,EACpBI,MAAM,GACNC,MAAM,IACNX,IAAItB,GAAK,IAAMA,GAElB2B,EAAOG,QAAQC,EACjB,CAEA,OAAOJ,CACT,CAcO,SAASnB,8BAA8BP,GAC5C,IAAKA,EAAKS,WAAW,KACnB,MAAM,IAAIwB,MAAM,wBAAwBjC,KAI1CA,GADAA,EAAOA,EAAKS,WAAW,MAAQT,EAAK+B,MAAM,GAAK/B,EAAK+B,MAAM,IAC9CG,cAEZ,MAAMC,EAAU,IAAIC,IAGdC,EAAYrC,EAAKsC,QAAQ,QAASC,GAAKA,EAAE,GAAGC,eAClDL,EAAQM,IAAIJ,GAGZF,EAAQM,IAAIJ,EAAUC,QAAQ,OAAQC,GAAKA,EAAEC,gBAG7C,MAAME,EAAa1C,EAAKsC,QAAQ,QAASK,GAAK,IAAMA,EAAE,IAMtD,OALAR,EAAQM,IAAIC,GAGZP,EAAQM,IAAIC,EAAWF,eAEhBL,CACT,CAGO,SAASS,eAAe5C,GAC7B,MAAO,cAAc4B,KAAK5B,EAC5B,CAGA,SAAS6C,eAAe7C,GACtB,MAAO,4BAA4B4B,KAAK5B,EAC1C,CAGO,SAAS8C,iBAAiB9C,GAC/B,MAAoB,iBAATA,IAIJ4C,eAAe5C,IAAS6C,eAAe7C,GAChD,CAQO,SAASkB,aAAalB,GAC3B,MAAO,KAAOA,EAAKsC,QAAQ,SAAUK,GAAKA,EAAEH,cAC9C,CAGO,SAASO,0BAA0B/C,GAExC,OAAoB,IAAhBA,EAAKgD,OACA,IAAIhD,EAAKkC,gBAId,YAAYN,KAAK5B,IAAS,YAAY4B,KAAK5B,GAEtC,MADPA,EAAOA,EAAKsC,QAAQ,KAAM,MACTJ,gBAQZ,MAFPlC,EAAOA,EAAKsC,QAAQ,SAAU,CAACW,EAAOC,IAAmBA,EAAQ,EAAI,IAAMD,EAAQA,IAElEf,eACnB,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{validateCliDefinition}from"../definitions/validate-cli-definition.js";import{parseArgv}from"../utilities.js";import{buildCliContext}from"./context/cli-context-builder.js";import{findSubcommandDefinition}from"./parser-utilities.js";import{validate}from"./validation/validate-context.js";function safeParse(r,e){const t=safeParseCore(r,e);if(t.error)return{error:t.error};const{validateResult:o,subcommandObject:i}=t;if(i._onExecute)for(const r of i._onExecute)r(o);return{error:void 0,value:o}}async function safeParseAsync(r,e){const t=safeParseCore(r,e);if(t.error)return{error:t.error};const{validateResult:o,subcommandObject:i}=t;if(i._onExecute)for(const r of i._onExecute)await r(o);return{error:void 0,value:o}}function safeParseCore(r,e){const t="string"==typeof r?parseArgv(r):r;try{validateCliDefinition(e)}catch(r){return{error:r}}let o;try{o=buildCliContext(t,e)}catch(r){return{error:r}}const i=findSubcommandDefinition(o.subcommand,e);if(!i){return{error:new Error(`Subcommand "${o.subcommand}" does not exist`)}}let n;try{n=validate(o,i)}catch(r){return{error:r}}return{error:void 0,validateResult:n,subcommandObject:i}}export{safeParse,safeParseAsync};
2
+ //# sourceMappingURL=safe-parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateCliDefinition","parseArgv","buildCliContext","findSubcommandDefinition","validate","safeParse","stringOrArgv","cliDefinition","core","safeParseCore","error","validateResult","subcommandObject","_onExecute","handler","value","async","safeParseAsync","argv","cliContext","subcommand","Error"],"sources":["../../../src/parse/safe-parse.ts"],"sourcesContent":["import { validateCliDefinition } from \"../definitions/validate-cli-definition.ts\";\nimport { parseArgv } from \"../utilities.ts\";\nimport { buildCliContext } from \"./context/cli-context-builder.ts\";\nimport { findSubcommandDefinition } from \"./parser-utilities.ts\";\nimport { validate } from \"./validation/validate-context.ts\";\n\nimport type { Cli } from \"../types/definitions-types.ts\";\nimport type { CliParseResultWide } from \"../types/types.ts\";\n\nexport function safeParse(stringOrArgv: string | string[], cliDefinition: Cli): CliParseResultWide {\n const core = safeParseCore(stringOrArgv, cliDefinition);\n if (core.error) return { error: core.error };\n\n const { validateResult, subcommandObject } = core;\n\n // Fire action (throw errors caused by the usage of the action hook)\n if (subcommandObject._onExecute) {\n for (const handler of subcommandObject._onExecute) {\n handler(validateResult);\n }\n }\n\n return { error: undefined, value: validateResult };\n}\n\nexport async function safeParseAsync(stringOrArgv: string | string[], cliDefinition: Cli): Promise<CliParseResultWide> {\n const core = safeParseCore(stringOrArgv, cliDefinition);\n if (core.error) return { error: core.error };\n\n const { validateResult, subcommandObject } = core;\n\n // Fire action (throw errors caused by the usage of the action hook)\n if (subcommandObject._onExecute) {\n for (const handler of subcommandObject._onExecute) {\n // eslint-disable-next-line @typescript-eslint/await-thenable\n await handler(validateResult);\n }\n }\n\n return { error: undefined, value: validateResult };\n}\n\nfunction safeParseCore(stringOrArgv: string | string[], cliDefinition: Cli) {\n const argv = typeof stringOrArgv === \"string\" ? parseArgv(stringOrArgv) : stringOrArgv;\n\n // validate cli definition\n try {\n validateCliDefinition(cliDefinition);\n } catch (error) {\n return { error: error as Error };\n }\n\n // Parse\n let cliContext;\n try {\n cliContext = buildCliContext(argv, cliDefinition);\n } catch (error) {\n return { error: error as Error };\n }\n\n const subcommandObject = findSubcommandDefinition(cliContext.subcommand, cliDefinition);\n if (!subcommandObject) {\n const error = new Error(`Subcommand \"${cliContext.subcommand}\" does not exist`);\n return { error };\n }\n\n // Validate context\n let validateResult;\n try {\n validateResult = validate(cliContext, subcommandObject);\n } catch (error) {\n return { error: error as Error };\n }\n\n return { error: undefined, validateResult, subcommandObject };\n}\n"],"mappings":"OAASA,0BAA6B,mDAC7BC,cAAiB,yBACjBC,oBAAuB,0CACvBC,6BAAgC,+BAChCC,aAAgB,mCAKlB,SAASC,UAAUC,EAAiCC,GACzD,MAAMC,EAAOC,cAAcH,EAAcC,GACzC,GAAIC,EAAKE,MAAO,MAAO,CAAEA,MAAOF,EAAKE,OAErC,MAAMC,eAAEA,EAAAC,iBAAgBA,GAAqBJ,EAG7C,GAAII,EAAiBC,WACnB,UAAWC,KAAWF,EAAiBC,WACrCC,EAAQH,GAIZ,MAAO,CAAED,WAAO,EAAWK,MAAOJ,EACpC,CAEAK,eAAsBC,eAAeX,EAAiCC,GACpE,MAAMC,EAAOC,cAAcH,EAAcC,GACzC,GAAIC,EAAKE,MAAO,MAAO,CAAEA,MAAOF,EAAKE,OAErC,MAAMC,eAAEA,EAAAC,iBAAgBA,GAAqBJ,EAG7C,GAAII,EAAiBC,WACnB,UAAWC,KAAWF,EAAiBC,iBAE/BC,EAAQH,GAIlB,MAAO,CAAED,WAAO,EAAWK,MAAOJ,EACpC,CAEA,SAASF,cAAcH,EAAiCC,GACtD,MAAMW,EAA+B,iBAAjBZ,EAA4BL,UAAUK,GAAgBA,EAG1E,IACEN,sBAAsBO,EACxB,OAASG,GACP,MAAO,CAAEA,QACX,CAGA,IAAIS,EACJ,IACEA,EAAajB,gBAAgBgB,EAAMX,EACrC,OAASG,GACP,MAAO,CAAEA,QACX,CAEA,MAAME,EAAmBT,yBAAyBgB,EAAWC,WAAYb,GACzE,IAAKK,EAAkB,CAErB,MAAO,CAAEF,MADK,IAAIW,MAAM,eAAeF,EAAWC,8BAEpD,CAGA,IAAIT,EACJ,IACEA,EAAiBP,SAASe,EAAYP,EACxC,OAASF,GACP,MAAO,CAAEA,QACX,CAEA,MAAO,CAAEA,WAAO,EAAWC,iBAAgBC,mBAC7C,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{validateArguments}from"./validators/arguments.js";import{validateOptions}from"./validators/options.js";function validate(t,o){const i={subcommand:t.subcommand,positionals:t.positionals,context:t};return validateOptions({commandDefinition:o,context:t,output:i}),validateArguments({commandDefinition:o,context:t,output:i}),i}export{validate};
2
+ //# sourceMappingURL=validate-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateArguments","validateOptions","validate","context","commandDefinition","output","subcommand","positionals"],"sources":["../../../../src/parse/validation/validate-context.ts"],"sourcesContent":["import { validateArguments } from \"./validators/arguments.ts\";\nimport { validateOptions } from \"./validators/options.ts\";\n\nimport type { ContextWide } from \"../../types/context-types.ts\";\nimport type { Cli, Subcommand } from \"../../types/definitions-types.ts\";\nimport type { OutputTypeWide } from \"../../types/io-types.ts\";\n\n/** @throws {Error} */\nexport function validate(context: ContextWide, commandDefinition: Subcommand | Cli) {\n const output: OutputTypeWide = {\n subcommand: context.subcommand,\n positionals: context.positionals,\n context: context,\n };\n\n // validate options\n validateOptions({ commandDefinition, context, output });\n\n // validate arguments\n validateArguments({ commandDefinition, context, output });\n\n return output;\n}\n"],"mappings":"OAASA,sBAAyB,mCACzBC,oBAAuB,0BAOzB,SAASC,SAASC,EAAsBC,GAC7C,MAAMC,EAAyB,CAC7BC,WAAYH,EAAQG,WACpBC,YAAaJ,EAAQI,YACrBJ,WASF,OALAF,gBAAgB,CAAEG,oBAAmBD,UAASE,WAG9CL,kBAAkB,CAAEI,oBAAmBD,UAASE,WAEzCA,CACT,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{validateSync}from"../../../utilities.js";import{validateConflictWith}from"./conflict.js";import{validateExclusive}from"./exclusive.js";import{validateRequires}from"./requires.js";function validateArguments({commandDefinition:e,context:t,output:r}){if(!t.arguments)return;r.arguments??(r.arguments={});const n=e.arguments;if(!n)throw new Error(`Subcommand "${t.subcommand}" does not have arguments`);for(const[r,o]of Object.entries(n))validateRequires({name:r,commandDefinition:e,optionOrArgument:o,context:t,type:"option"}),validateExclusive({name:r,optionOrArgument:o,context:t,type:"option"}),validateConflictWith({name:r,optionOrArgument:o,context:t,type:"option"});const o=Object.entries(t.arguments);for(const[e,{passedValue:i,stringValue:a,source:s,schema:m}]of o){const o="programmatic"===s,u=n[e];if(!u)throw new Error(`Subcommand "${t.subcommand}" does not have the argument "${e}"`);if(!u._preparedType)throw new Error(`internal error: missing prepared type for the argument "${e}"`);const c=o?validateSync(m,i):u._preparedType.validate(a);if(c.issues)throw new Error(`The argument ${e} argument ${o?"":`"${a}"`} is invalid: ${c.issues.map(e=>e.message).join(", ")}`);r.arguments[e]=c.value}}export{validateArguments};
2
+ //# sourceMappingURL=arguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateSync","validateConflictWith","validateExclusive","validateRequires","validateArguments","commandDefinition","context","output","arguments","argumentsDefinition","Error","subcommand","argumentName","argument","Object","entries","name","optionOrArgument","type","argumentContextEntries","passedValue","stringValue","source","schema","isProgrammatic","_preparedType","safeParseResult","validate","issues","map","issue","message","join","value"],"sources":["../../../../../src/parse/validation/validators/arguments.ts"],"sourcesContent":["import { validateSync } from \"../../../utilities.ts\";\nimport { validateConflictWith } from \"./conflict.ts\";\nimport { validateExclusive } from \"./exclusive.ts\";\nimport { validateRequires } from \"./requires.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Cli, Subcommand } from \"../../../types/definitions-types.ts\";\nimport type { OutputTypeWide } from \"../../../types/io-types.ts\";\n\ninterface ValidateArgument {\n commandDefinition: Subcommand | Cli;\n context: ContextWide;\n output: OutputTypeWide;\n}\n\n/** @throws {Error} */\nexport function validateArguments({ commandDefinition, context, output }: ValidateArgument) {\n if (!context.arguments) return;\n\n output.arguments ??= {};\n\n const argumentsDefinition = commandDefinition.arguments;\n if (!argumentsDefinition) {\n throw new Error(`Subcommand \"${context.subcommand}\" does not have arguments`);\n }\n\n for (const [argumentName, argument] of Object.entries(argumentsDefinition)) {\n validateRequires({ name: argumentName, commandDefinition, optionOrArgument: argument, context, type: \"option\" });\n validateExclusive({ name: argumentName, optionOrArgument: argument, context, type: \"option\" });\n validateConflictWith({ name: argumentName, optionOrArgument: argument, context, type: \"option\" });\n }\n\n const argumentContextEntries = Object.entries(context.arguments);\n\n for (const [name, { passedValue, stringValue, source, schema }] of argumentContextEntries) {\n const isProgrammatic = source === \"programmatic\";\n\n const argument = argumentsDefinition[name];\n if (!argument) {\n throw new Error(`Subcommand \"${context.subcommand}\" does not have the argument \"${name}\"`);\n }\n\n if (!argument._preparedType) {\n throw new Error(`internal error: missing prepared type for the argument \"${name}\"`);\n }\n\n const safeParseResult = isProgrammatic\n ? validateSync(schema, passedValue)\n : argument._preparedType.validate(stringValue);\n\n if (safeParseResult.issues) {\n throw new Error(\n `The argument ${name} argument ${isProgrammatic ? \"\" : `\"${stringValue}\"`} is invalid: ${safeParseResult.issues.map(issue => issue.message).join(\", \")}`,\n );\n }\n\n output.arguments[name] = safeParseResult.value;\n }\n}\n"],"mappings":"OAASA,iBAAoB,+BACpBC,yBAA4B,uBAC5BC,sBAAyB,wBACzBC,qBAAwB,gBAa1B,SAASC,mBAAkBC,kBAAEA,EAAAC,QAAmBA,EAAAC,OAASA,IAC9D,IAAKD,EAAQE,UAAW,OAExBD,EAAOC,YAAPD,EAAOC,UAAc,CAAC,GAEtB,MAAMC,EAAsBJ,EAAkBG,UAC9C,IAAKC,EACH,MAAM,IAAIC,MAAM,eAAeJ,EAAQK,uCAGzC,UAAYC,EAAcC,KAAaC,OAAOC,QAAQN,GACpDN,iBAAiB,CAAEa,KAAMJ,EAAcP,oBAAmBY,iBAAkBJ,EAAUP,UAASY,KAAM,WACrGhB,kBAAkB,CAAEc,KAAMJ,EAAcK,iBAAkBJ,EAAUP,UAASY,KAAM,WACnFjB,qBAAqB,CAAEe,KAAMJ,EAAcK,iBAAkBJ,EAAUP,UAASY,KAAM,WAGxF,MAAMC,EAAyBL,OAAOC,QAAQT,EAAQE,WAEtD,UAAYQ,GAAMI,YAAEA,EAAAC,YAAaA,EAAAC,OAAaA,EAAAC,OAAQA,MAAaJ,EAAwB,CACzF,MAAMK,EAA4B,iBAAXF,EAEjBT,EAAWJ,EAAoBO,GACrC,IAAKH,EACH,MAAM,IAAIH,MAAM,eAAeJ,EAAQK,2CAA2CK,MAGpF,IAAKH,EAASY,cACZ,MAAM,IAAIf,MAAM,2DAA2DM,MAG7E,MAAMU,EAAkBF,EACpBxB,aAAauB,EAAQH,GACrBP,EAASY,cAAcE,SAASN,GAEpC,GAAIK,EAAgBE,OAClB,MAAM,IAAIlB,MACR,gBAAgBM,cAAiBQ,EAAiB,GAAK,IAAIH,oBAA8BK,EAAgBE,OAAOC,IAAIC,GAASA,EAAMC,SAASC,KAAK,SAIrJzB,EAAOC,UAAUQ,GAAQU,EAAgBO,KAC3C,CACF,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{isOptionOrArgumentExplicitlyPassed}from"./explicitly-passed.js";function validateConflictWith({name:t,optionOrArgument:e,context:n,type:i}){const o=e.conflictWith;if(!o||0===o.length)return;if(!isOptionOrArgumentExplicitlyPassed(t,n))return;const s=[],r=[];if(n.options)for(const[e,i]of Object.entries(n.options))e!==t&&o.includes(e)&&"default"!==i.source&&s.push(e);if(n.arguments)for(const[e,i]of Object.entries(n.arguments))e!==t&&o.includes(e)&&"default"!==i.source&&r.push(e);if(0===s.length&&0===r.length)return;const c=[];if(s.length>0){const t=s.map(t=>`"${t}"`).join(", "),e=s.length>1?"s":"";c.push(`option${e} ${t}`)}if(r.length>0){const t=r.map(t=>`"${t}"`).join(", "),e=r.length>1?"s":"";c.push(`argument${e} ${t}`)}const l=c.join(" and ");throw new Error(`${i} "${t}" cannot be used with the ${l} because they are mutually exclusive.`)}export{validateConflictWith};
2
+ //# sourceMappingURL=conflict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isOptionOrArgumentExplicitlyPassed","validateConflictWith","name","optionOrArgument","context","type","conflictWith","length","conflictedOptions","conflictedArguments","options","optionName","optionContext","Object","entries","includes","source","push","arguments","argumentName","argumentContext","parts","formatted","map","o","join","s","a","joinedParts","Error"],"sources":["../../../../../src/parse/validation/validators/conflict.ts"],"sourcesContent":["import { isOptionOrArgumentExplicitlyPassed } from \"./explicitly-passed.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Argument, Option } from \"../../../types/definitions-types.ts\";\n\ninterface ValidateConflictOptions {\n /** The option or argument name to check its `requires` */\n name: string;\n\n /** The option or argument to check */\n optionOrArgument: Option | Argument;\n\n /** The parsed context */\n context: ContextWide;\n\n /** What we're checking */\n type: \"option\" | \"argument\";\n}\n\n/** @throws {Error} */\nexport function validateConflictWith({ name, optionOrArgument, context, type }: ValidateConflictOptions) {\n const conflictWith = optionOrArgument.conflictWith;\n if (!conflictWith || conflictWith.length === 0) return;\n\n // Check if the options/argument is passed\n if (!isOptionOrArgumentExplicitlyPassed(name, context)) return;\n\n const conflictedOptions: string[] = [];\n const conflictedArguments: string[] = [];\n\n if (context.options) {\n for (const [optionName, optionContext] of Object.entries(context.options)) {\n if (optionName === name) continue; // don't check self\n if (!conflictWith.includes(optionName)) continue; // not a conflict\n if (optionContext.source === \"default\") continue; // not explicitly passed\n conflictedOptions.push(optionName);\n }\n }\n\n if (context.arguments) {\n for (const [argumentName, argumentContext] of Object.entries(context.arguments)) {\n if (argumentName === name) continue; // don't check self\n if (!conflictWith.includes(argumentName)) continue; // not a conflict\n if (argumentContext.source === \"default\") continue; // not explicitly passed\n conflictedArguments.push(argumentName);\n }\n }\n\n if (conflictedOptions.length === 0 && conflictedArguments.length === 0) return; // OK\n\n const parts: string[] = [];\n\n if (conflictedOptions.length > 0) {\n const formatted = conflictedOptions.map(o => `\"${o}\"`).join(\", \");\n const s = conflictedOptions.length > 1 ? \"s\" : \"\";\n parts.push(`option${s} ${formatted}`);\n }\n\n if (conflictedArguments.length > 0) {\n const formatted = conflictedArguments.map(a => `\"${a}\"`).join(\", \");\n const s = conflictedArguments.length > 1 ? \"s\" : \"\";\n parts.push(`argument${s} ${formatted}`);\n }\n\n const joinedParts = parts.join(\" and \");\n\n throw new Error(`${type} \"${name}\" cannot be used with the ${joinedParts} because they are mutually exclusive.`);\n}\n"],"mappings":"OAASA,uCAA0C,yBAoB5C,SAASC,sBAAqBC,KAAEA,EAAAC,iBAAMA,EAAAC,QAAkBA,EAAAC,KAASA,IACtE,MAAMC,EAAeH,EAAiBG,aACtC,IAAKA,GAAwC,IAAxBA,EAAaC,OAAc,OAGhD,IAAKP,mCAAmCE,EAAME,GAAU,OAExD,MAAMI,EAA8B,GAC9BC,EAAgC,GAEtC,GAAIL,EAAQM,QACV,UAAYC,EAAYC,KAAkBC,OAAOC,QAAQV,EAAQM,SAC3DC,IAAeT,GACdI,EAAaS,SAASJ,IACE,YAAzBC,EAAcI,QAClBR,EAAkBS,KAAKN,GAI3B,GAAIP,EAAQc,UACV,UAAYC,EAAcC,KAAoBP,OAAOC,QAAQV,EAAQc,WAC/DC,IAAiBjB,GAChBI,EAAaS,SAASI,IACI,YAA3BC,EAAgBJ,QACpBP,EAAoBQ,KAAKE,GAI7B,GAAiC,IAA7BX,EAAkBD,QAA+C,IAA/BE,EAAoBF,OAAc,OAExE,MAAMc,EAAkB,GAExB,GAAIb,EAAkBD,OAAS,EAAG,CAChC,MAAMe,EAAYd,EAAkBe,IAAIC,GAAK,IAAIA,MAAMC,KAAK,MACtDC,EAAIlB,EAAkBD,OAAS,EAAI,IAAM,GAC/Cc,EAAMJ,KAAK,SAASS,KAAKJ,IAC3B,CAEA,GAAIb,EAAoBF,OAAS,EAAG,CAClC,MAAMe,EAAYb,EAAoBc,IAAII,GAAK,IAAIA,MAAMF,KAAK,MACxDC,EAAIjB,EAAoBF,OAAS,EAAI,IAAM,GACjDc,EAAMJ,KAAK,WAAWS,KAAKJ,IAC7B,CAEA,MAAMM,EAAcP,EAAMI,KAAK,SAE/B,MAAM,IAAII,MAAM,GAAGxB,MAASH,8BAAiC0B,yCAC/D,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{isOptionOrArgumentExplicitlyPassed}from"./explicitly-passed.js";function validateExclusive({name:e,optionOrArgument:t,context:n,type:s}){if(!t.exclusive)return;if(!isOptionOrArgumentExplicitlyPassed(e,n))return;const i=t.requires??[],o=[],r=[];if(n.options)for(const[t,s]of Object.entries(n.options))t!==e&&(i.includes(t)||"default"!==s.source&&o.push(t));if(n.arguments)for(const[t,s]of Object.entries(n.arguments))t!==e&&(i.includes(t)||"default"!==s.source&&r.push(t));if(0===o.length&&0===r.length)return;const u=[];if(o.length>0){const e=o.map(e=>`"${e}"`).join(", "),t=o.length>1?"s":"";u.push(`option${t} ${e}`)}if(r.length>0){const e=r.map(e=>`"${e}"`).join(", "),t=r.length>1?"s":"";u.push(`argument${t} ${e}`)}const c=u.join(" and ");throw new Error(`${s} "${e}" cannot be used with the ${c} because they are mutually exclusive.`)}export{validateExclusive};
2
+ //# sourceMappingURL=exclusive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isOptionOrArgumentExplicitlyPassed","validateExclusive","name","optionOrArgument","context","type","exclusive","requires","mutuallyExclusiveOptions","mutuallyExclusiveArguments","options","optionName","optionContext","Object","entries","includes","source","push","arguments","argumentName","argumentContext","length","parts","formatted","map","o","join","s","a","joinedParts","Error"],"sources":["../../../../../src/parse/validation/validators/exclusive.ts"],"sourcesContent":["import { isOptionOrArgumentExplicitlyPassed } from \"./explicitly-passed.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Argument, Option } from \"../../../types/definitions-types.ts\";\n\ninterface ValidateExclusiveOptions {\n /** The option or argument name to check its `requires` */\n name: string;\n\n /** The option or argument to check */\n optionOrArgument: Option | Argument;\n\n /** The parsed context */\n context: ContextWide;\n\n /** What we're checking */\n type: \"option\" | \"argument\";\n}\n\n/** @throws {Error} */\nexport function validateExclusive({ name, optionOrArgument, context, type }: ValidateExclusiveOptions) {\n const exclusive = optionOrArgument.exclusive;\n if (!exclusive) return;\n\n // Check if the options/argument is passed\n if (!isOptionOrArgumentExplicitlyPassed(name, context)) return;\n\n const requires = optionOrArgument.requires ?? [];\n\n const mutuallyExclusiveOptions: string[] = [];\n const mutuallyExclusiveArguments: string[] = [];\n\n if (context.options) {\n for (const [optionName, optionContext] of Object.entries(context.options)) {\n if (optionName === name) continue; // don't check self\n if (requires.includes(optionName)) continue; // allow required options\n if (optionContext.source === \"default\") continue; // not explicitly passed\n mutuallyExclusiveOptions.push(optionName);\n }\n }\n\n if (context.arguments) {\n for (const [argumentName, argumentContext] of Object.entries(context.arguments)) {\n if (argumentName === name) continue; // don't check self\n if (requires.includes(argumentName)) continue; // allow required arguments\n if (argumentContext.source === \"default\") continue; // not explicitly passed\n mutuallyExclusiveArguments.push(argumentName);\n }\n }\n\n if (mutuallyExclusiveOptions.length === 0 && mutuallyExclusiveArguments.length === 0) return;\n\n const parts: string[] = [];\n\n if (mutuallyExclusiveOptions.length > 0) {\n const formatted = mutuallyExclusiveOptions.map(o => `\"${o}\"`).join(\", \");\n const s = mutuallyExclusiveOptions.length > 1 ? \"s\" : \"\";\n parts.push(`option${s} ${formatted}`);\n }\n\n if (mutuallyExclusiveArguments.length > 0) {\n const formatted = mutuallyExclusiveArguments.map(a => `\"${a}\"`).join(\", \");\n const s = mutuallyExclusiveArguments.length > 1 ? \"s\" : \"\";\n parts.push(`argument${s} ${formatted}`);\n }\n\n const joinedParts = parts.join(\" and \");\n\n throw new Error(`${type} \"${name}\" cannot be used with the ${joinedParts} because they are mutually exclusive.`);\n}\n"],"mappings":"OAASA,uCAA0C,yBAoB5C,SAASC,mBAAkBC,KAAEA,EAAAC,iBAAMA,EAAAC,QAAkBA,EAAAC,KAASA,IAEnE,IADkBF,EAAiBG,UACnB,OAGhB,IAAKN,mCAAmCE,EAAME,GAAU,OAExD,MAAMG,EAAWJ,EAAiBI,UAAY,GAExCC,EAAqC,GACrCC,EAAuC,GAE7C,GAAIL,EAAQM,QACV,UAAYC,EAAYC,KAAkBC,OAAOC,QAAQV,EAAQM,SAC3DC,IAAeT,IACfK,EAASQ,SAASJ,IACO,YAAzBC,EAAcI,QAClBR,EAAyBS,KAAKN,IAIlC,GAAIP,EAAQc,UACV,UAAYC,EAAcC,KAAoBP,OAAOC,QAAQV,EAAQc,WAC/DC,IAAiBjB,IACjBK,EAASQ,SAASI,IACS,YAA3BC,EAAgBJ,QACpBP,EAA2BQ,KAAKE,IAIpC,GAAwC,IAApCX,EAAyBa,QAAsD,IAAtCZ,EAA2BY,OAAc,OAEtF,MAAMC,EAAkB,GAExB,GAAId,EAAyBa,OAAS,EAAG,CACvC,MAAME,EAAYf,EAAyBgB,IAAIC,GAAK,IAAIA,MAAMC,KAAK,MAC7DC,EAAInB,EAAyBa,OAAS,EAAI,IAAM,GACtDC,EAAML,KAAK,SAASU,KAAKJ,IAC3B,CAEA,GAAId,EAA2BY,OAAS,EAAG,CACzC,MAAME,EAAYd,EAA2Be,IAAII,GAAK,IAAIA,MAAMF,KAAK,MAC/DC,EAAIlB,EAA2BY,OAAS,EAAI,IAAM,GACxDC,EAAML,KAAK,WAAWU,KAAKJ,IAC7B,CAEA,MAAMM,EAAcP,EAAMI,KAAK,SAE/B,MAAM,IAAII,MAAM,GAAGzB,MAASH,8BAAiC2B,yCAC/D,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ function isArgumentExplicitlyPassed(i,t){return!!t.arguments&&(i in t.arguments&&"default"!==t.arguments[i].source)}function isOptionExplicitlyPassed(i,t){return!!t.options&&(i in t.options&&"default"!==t.options[i].source)}function isOptionOrArgumentExplicitlyPassed(i,t){return isOptionExplicitlyPassed(i,t)||isArgumentExplicitlyPassed(i,t)}export{isArgumentExplicitlyPassed,isOptionExplicitlyPassed,isOptionOrArgumentExplicitlyPassed};
2
+ //# sourceMappingURL=explicitly-passed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isArgumentExplicitlyPassed","name","context","arguments","source","isOptionExplicitlyPassed","options","isOptionOrArgumentExplicitlyPassed"],"sources":["../../../../../src/parse/validation/validators/explicitly-passed.ts"],"sourcesContent":["import type { ContextWide } from \"../../../types/context-types.ts\";\n\nexport function isArgumentExplicitlyPassed(name: string, context: ContextWide) {\n if (!context.arguments) return false;\n return name in context.arguments && context.arguments[name].source !== \"default\";\n}\n\nexport function isOptionExplicitlyPassed(name: string, context: ContextWide) {\n if (!context.options) return false;\n return name in context.options && context.options[name].source !== \"default\";\n}\n\nexport function isOptionOrArgumentExplicitlyPassed(name: string, context: ContextWide) {\n return isOptionExplicitlyPassed(name, context) || isArgumentExplicitlyPassed(name, context);\n}\n"],"mappings":"AAEO,SAASA,2BAA2BC,EAAcC,GACvD,QAAKA,EAAQC,YACNF,KAAQC,EAAQC,WAAgD,YAAnCD,EAAQC,UAAUF,GAAMG,OAC9D,CAEO,SAASC,yBAAyBJ,EAAcC,GACrD,QAAKA,EAAQI,UACNL,KAAQC,EAAQI,SAA4C,YAAjCJ,EAAQI,QAAQL,GAAMG,OAC1D,CAEO,SAASG,mCAAmCN,EAAcC,GAC/D,OAAOG,yBAAyBJ,EAAMC,IAAYF,2BAA2BC,EAAMC,EACrF,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{validateSync}from"../../../utilities.js";import{validateConflictWith}from"./conflict.js";import{validateExclusive}from"./exclusive.js";import{validateRequires}from"./requires.js";function validateOptions({commandDefinition:o,context:t,output:e}){if(!t.options)return;e.options??(e.options={});const i=o.options;if(!i)throw new Error(`subcommand "${t.subcommand}" does not have options`);for(const[e,n]of Object.entries(i))validateRequires({name:e,commandDefinition:o,optionOrArgument:n,context:t,type:"option"}),validateExclusive({name:e,optionOrArgument:n,context:t,type:"option"}),validateConflictWith({name:e,optionOrArgument:n,context:t,type:"option"});const n=Object.entries(t.options);for(const[o,{passedValue:r,stringValue:a,flag:s,source:p,schema:m}]of n){const n=i[o];if(!n)throw new Error(`subcommand "${t.subcommand}" does not have option "${o}"`);if(!n._preparedType)throw new Error(`internal error: missing prepared type for option "${o}"`);const c="programmatic"===p,l=c?validateSync(m,r):n._preparedType.validate(a);if(l.issues)throw new Error(`invalid value ${c?"":`"${a}"`} for "${c?o:s}": ${l.issues.map(o=>o.message).join(", ")}`);e.options[o]=l.value}}export{validateOptions};
2
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateSync","validateConflictWith","validateExclusive","validateRequires","validateOptions","commandDefinition","context","output","options","optionsDefinition","Error","subcommand","optionName","option","Object","entries","name","optionOrArgument","type","optionContextEntries","passedValue","stringValue","flag","source","schema","_preparedType","isProgrammatic","safeParseResult","validate","issues","map","issue","message","join","value"],"sources":["../../../../../src/parse/validation/validators/options.ts"],"sourcesContent":["import { validateSync } from \"../../../utilities.ts\";\nimport { validateConflictWith } from \"./conflict.ts\";\nimport { validateExclusive } from \"./exclusive.ts\";\nimport { validateRequires } from \"./requires.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Cli, Subcommand } from \"../../../types/definitions-types.ts\";\nimport type { OutputTypeWide } from \"../../../types/io-types.ts\";\n\ninterface ValidateOptions {\n commandDefinition: Subcommand | Cli;\n context: ContextWide;\n output: OutputTypeWide;\n}\n\n/** @throws {Error} */\nexport function validateOptions({ commandDefinition, context, output }: ValidateOptions) {\n if (!context.options) return;\n\n output.options ??= {};\n\n const optionsDefinition = commandDefinition.options;\n if (!optionsDefinition) {\n throw new Error(`subcommand \"${context.subcommand}\" does not have options`);\n }\n\n for (const [optionName, option] of Object.entries(optionsDefinition)) {\n validateRequires({ name: optionName, commandDefinition, optionOrArgument: option, context, type: \"option\" });\n validateExclusive({ name: optionName, optionOrArgument: option, context, type: \"option\" });\n validateConflictWith({ name: optionName, optionOrArgument: option, context, type: \"option\" });\n }\n\n const optionContextEntries = Object.entries(context.options);\n\n for (const [optionName, { passedValue, stringValue, flag, source, schema }] of optionContextEntries) {\n const option = optionsDefinition[optionName];\n if (!option) {\n throw new Error(`subcommand \"${context.subcommand}\" does not have option \"${optionName}\"`);\n }\n\n if (!option._preparedType) {\n throw new Error(`internal error: missing prepared type for option \"${optionName}\"`);\n }\n\n const isProgrammatic = source === \"programmatic\";\n\n const safeParseResult = isProgrammatic\n ? validateSync(schema, passedValue)\n : option._preparedType.validate(stringValue);\n\n if (safeParseResult.issues) {\n throw new Error(\n `invalid value ${isProgrammatic ? \"\" : `\"${stringValue}\"`} for \"${isProgrammatic ? optionName : flag}\": ${safeParseResult.issues.map(issue => issue.message).join(\", \")}`,\n );\n }\n\n output.options[optionName] = safeParseResult.value;\n }\n}\n"],"mappings":"OAASA,iBAAoB,+BACpBC,yBAA4B,uBAC5BC,sBAAyB,wBACzBC,qBAAwB,gBAa1B,SAASC,iBAAgBC,kBAAEA,EAAAC,QAAmBA,EAAAC,OAASA,IAC5D,IAAKD,EAAQE,QAAS,OAEtBD,EAAOC,UAAPD,EAAOC,QAAY,CAAC,GAEpB,MAAMC,EAAoBJ,EAAkBG,QAC5C,IAAKC,EACH,MAAM,IAAIC,MAAM,eAAeJ,EAAQK,qCAGzC,UAAYC,EAAYC,KAAWC,OAAOC,QAAQN,GAChDN,iBAAiB,CAAEa,KAAMJ,EAAYP,oBAAmBY,iBAAkBJ,EAAQP,UAASY,KAAM,WACjGhB,kBAAkB,CAAEc,KAAMJ,EAAYK,iBAAkBJ,EAAQP,UAASY,KAAM,WAC/EjB,qBAAqB,CAAEe,KAAMJ,EAAYK,iBAAkBJ,EAAQP,UAASY,KAAM,WAGpF,MAAMC,EAAuBL,OAAOC,QAAQT,EAAQE,SAEpD,UAAYI,GAAYQ,YAAEA,EAAAC,YAAaA,EAAAC,KAAaA,EAAAC,OAAMA,EAAAC,OAAQA,MAAaL,EAAsB,CACnG,MAAMN,EAASJ,EAAkBG,GACjC,IAAKC,EACH,MAAM,IAAIH,MAAM,eAAeJ,EAAQK,qCAAqCC,MAG9E,IAAKC,EAAOY,cACV,MAAM,IAAIf,MAAM,qDAAqDE,MAGvE,MAAMc,EAA4B,iBAAXH,EAEjBI,EAAkBD,EACpB1B,aAAawB,EAAQJ,GACrBP,EAAOY,cAAcG,SAASP,GAElC,GAAIM,EAAgBE,OAClB,MAAM,IAAInB,MACR,iBAAiBgB,EAAiB,GAAK,IAAIL,aAAuBK,EAAiBd,EAAaU,OAAUK,EAAgBE,OAAOC,IAAIC,GAASA,EAAMC,SAASC,KAAK,SAItK1B,EAAOC,QAAQI,GAAce,EAAgBO,KAC/C,CACF,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import{isArgumentExplicitlyPassed,isOptionExplicitlyPassed,isOptionOrArgumentExplicitlyPassed}from"./explicitly-passed.js";function validateRequires({name:t,commandDefinition:i,optionOrArgument:n,context:e,type:s}){const o=n.requires;if(!o||0===o.length)return;if(!isOptionOrArgumentExplicitlyPassed(t,e))return;const r=i.options??{},p=[],l=[];for(const t of o){const i=t in r;(i?isOptionExplicitlyPassed(t,e):isArgumentExplicitlyPassed(t,e))||(i?p.push(t):l.push(t))}if(0===p.length&&0===l.length)return;const u=[];if(p.length>0){const t=p.map(t=>`"${t}"`).join(", "),i=p.length>1?"s":"";u.push(`option${i} ${t}`)}if(l.length>0){const t=l.map(t=>`"${t}"`).join(", "),i=l.length>1?"s":"";u.push(`argument${i} ${t}`)}const c=u.join(" and ");throw new Error(`${s} "${t}" cannot be used without the required ${c}.`)}export{validateRequires};
2
+ //# sourceMappingURL=requires.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isArgumentExplicitlyPassed","isOptionExplicitlyPassed","isOptionOrArgumentExplicitlyPassed","validateRequires","name","commandDefinition","optionOrArgument","context","type","requires","length","optionsDefinition","options","missingOptions","missingArguments","requiredName","isOption","push","parts","formatted","map","o","join","s","a","joinedParts","Error"],"sources":["../../../../../src/parse/validation/validators/requires.ts"],"sourcesContent":["import {\n isArgumentExplicitlyPassed,\n isOptionExplicitlyPassed,\n isOptionOrArgumentExplicitlyPassed,\n} from \"./explicitly-passed.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Argument, Cli, Option, Subcommand } from \"../../../types/definitions-types.ts\";\n\ninterface ValidateRequiresOptions {\n /** The option or argument name to check its `requires` */\n name: string;\n\n /** The subcommand or cli configuration */\n commandDefinition: Subcommand | Cli;\n\n /** The option or argument to check */\n optionOrArgument: Option | Argument;\n\n /** The parsed context */\n context: ContextWide;\n\n /** What we're checking */\n type: \"option\" | \"argument\";\n}\n\n/** @throws {Error} */\nexport function validateRequires({\n name,\n commandDefinition,\n optionOrArgument,\n context,\n type,\n}: ValidateRequiresOptions) {\n const requires = optionOrArgument.requires;\n if (!requires || requires.length === 0) return;\n\n // Check if the options/argument is passed\n if (!isOptionOrArgumentExplicitlyPassed(name, context)) return;\n\n const optionsDefinition = commandDefinition.options ?? {};\n\n const missingOptions: string[] = [];\n const missingArguments: string[] = [];\n\n for (const requiredName of requires) {\n const isOption = requiredName in optionsDefinition;\n\n const provided = isOption\n ? isOptionExplicitlyPassed(requiredName, context)\n : isArgumentExplicitlyPassed(requiredName, context);\n\n if (provided) continue;\n\n if (isOption) {\n missingOptions.push(requiredName);\n continue;\n }\n\n missingArguments.push(requiredName);\n }\n\n if (missingOptions.length === 0 && missingArguments.length === 0) return; // OK\n\n const parts: string[] = [];\n\n if (missingOptions.length > 0) {\n const formatted = missingOptions.map(o => `\"${o}\"`).join(\", \");\n const s = missingOptions.length > 1 ? \"s\" : \"\";\n parts.push(`option${s} ${formatted}`);\n }\n\n if (missingArguments.length > 0) {\n const formatted = missingArguments.map(a => `\"${a}\"`).join(\", \");\n const s = missingArguments.length > 1 ? \"s\" : \"\";\n parts.push(`argument${s} ${formatted}`);\n }\n\n const joinedParts = parts.join(\" and \");\n\n throw new Error(`${type} \"${name}\" cannot be used without the required ${joinedParts}.`);\n}\n"],"mappings":"OACEA,2BACAC,yBACAC,uCACK,yBAuBA,SAASC,kBAAiBC,KAC/BA,EAAAC,kBACAA,EAAAC,iBACAA,EAAAC,QACAA,EAAAC,KACAA,IAEA,MAAMC,EAAWH,EAAiBG,SAClC,IAAKA,GAAgC,IAApBA,EAASC,OAAc,OAGxC,IAAKR,mCAAmCE,EAAMG,GAAU,OAExD,MAAMI,EAAoBN,EAAkBO,SAAW,CAAC,EAElDC,EAA2B,GAC3BC,EAA6B,GAEnC,UAAWC,KAAgBN,EAAU,CACnC,MAAMO,EAAWD,KAAgBJ,GAEhBK,EACbf,yBAAyBc,EAAcR,GACvCP,2BAA2Be,EAAcR,MAIzCS,EACFH,EAAeI,KAAKF,GAItBD,EAAiBG,KAAKF,GACxB,CAEA,GAA8B,IAA1BF,EAAeH,QAA4C,IAA5BI,EAAiBJ,OAAc,OAElE,MAAMQ,EAAkB,GAExB,GAAIL,EAAeH,OAAS,EAAG,CAC7B,MAAMS,EAAYN,EAAeO,IAAIC,GAAK,IAAIA,MAAMC,KAAK,MACnDC,EAAIV,EAAeH,OAAS,EAAI,IAAM,GAC5CQ,EAAMD,KAAK,SAASM,KAAKJ,IAC3B,CAEA,GAAIL,EAAiBJ,OAAS,EAAG,CAC/B,MAAMS,EAAYL,EAAiBM,IAAII,GAAK,IAAIA,MAAMF,KAAK,MACrDC,EAAIT,EAAiBJ,OAAS,EAAI,IAAM,GAC9CQ,EAAMD,KAAK,WAAWM,KAAKJ,IAC7B,CAEA,MAAMM,EAAcP,EAAMI,KAAK,SAE/B,MAAM,IAAII,MAAM,GAAGlB,MAASJ,0CAA6CqB,KAC3E,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ function validateSync(e,n){const t=e["~standard"].validate(n);if(t instanceof Promise)throw new TypeError("async schema validation not supported");return t}function defaultValueAndIsOptional(e){const n=validateSync(e);return n.issues?{defaultValue:void 0,optional:!1}:{defaultValue:n.value,optional:!0}}function PrepareType(e,n){const{optional:t,defaultValue:i}=defaultValueAndIsOptional(e);return{schema:e,optional:t,defaultValue:i,coerceTo:n.type,validate:t=>validateSync(e,t&&n(t))}}function prepareDefinitionTypes(e){if(e)for(const n of Object.values(e))n.coerce||(n.coerce=e=>e),n._preparedType||(n._preparedType=PrepareType(n.schema,n.coerce))}function toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function generateOrdinalSuffix(e){if(e<0)return"";const n=e+1,t=n%100;let i="th";if(t<11||t>13)switch(n%10){case 1:i="st";break;case 2:i="nd";break;case 3:i="rd"}return`${n}${i}`}function ln(e){return"\n".repeat(e)}function indent(e){return e<=0?"":" ".repeat(e)}function indentLines(e,n){return e.replace(/\n/g,"\n"+indent(n))}function stringifyValue(e){return e instanceof Set?"new Set(["+Array.from(e).map(e=>stringifyValue(e)).join(", ")+"])":JSON.stringify(e)}function insertAtEndOfFirstLine(e,n){const t=e.split("\n");return t[0]+=(t[0]?" ":"")+n,t.join("\n")}function subcommandPlaceholder(e){let n=e.placeholder;return n||(e.options.length>0&&(n+=(n?" ":"")+"[options]"),e.arguments.length>0&&(n+=(n?" ":"")+"<arguments>"),e.allowPositionals&&(n+=(n?" ":"")+"<positionals>"),n||(n=" "),n)}function parseArgv(e){const n=[];let t,i;for(let r=0;r<e.length;r++){const a=e[r],o=e[r-1],s=e[r+1],u=r===e.length-1;if('"'!==a&&"'"!==a||"\\"===o)if("\\"!==a||"\n"!==s){if(void 0!==i&&void 0===t){if(" "===a){n.push(i),i=void 0;continue}if(u){i+=a,n.push(i),i=void 0;continue}}" "===a&&void 0===t||("\\"!==a||"'"!==s&&'"'!==s)&&(i??(i=""),i+=a)}else r++;else{if(t===a){t=void 0;continue}if(void 0===t){t=a;continue}if(void 0!==t&&a!==t){i+=a;continue}}}return void 0!==i&&n.push(i),n}function escapeHtmlTags(e){const n={"&":"&amp;","<":"&lt;",">":"&gt;"};return e.replace(/(```[\s\S]*?```|`[^`]*`)|(<!--[\s\S]*?-->)|(<[^>]+>)/g,(e,t,i,r)=>t||(i||(r?r.replace(/[&<>]/g,e=>n[e]):e)))}function ansiRegex({onlyFirst:e=!1}={}){const n=String.raw`(?:\u0007|\u001B\u005C|\u009C)`,t=String.raw`(?:\u001B\][\s\S]*?${n})`,i=String.raw`[\u001B\u009B][[\]()#;?]*(?:\d{1,4}(?:[;:]\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]`;return new RegExp(`${t}|${i}`,e?void 0:"g")}var regex=ansiRegex();function stripAnsi(e){return e.replace(regex,"")}function findDuplicateStrings(e){const n=new Set,t=new Set;for(const i of e)n.has(i)?t.add(i):n.add(i);return Array.from(t)}export{PrepareType,defaultValueAndIsOptional,escapeHtmlTags,findDuplicateStrings,generateOrdinalSuffix,indent,indentLines,insertAtEndOfFirstLine,ln,parseArgv,prepareDefinitionTypes,stringifyValue,stripAnsi,subcommandPlaceholder,toKebabCase,validateSync};
2
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateSync","schema","value","results","validate","Promise","TypeError","defaultValueAndIsOptional","issues","defaultValue","optional","PrepareType","coerceHandler","coerceTo","type","prepareDefinitionTypes","definition","object","Object","values","coerce","_preparedType","toKebabCase","input","replace","toLowerCase","generateOrdinalSuffix","index","number","lastTwoDigits","suffix","ln","count","repeat","indent","indentLines","text","spaces","stringifyValue","Set","Array","from","map","element","join","JSON","stringify","insertAtEndOfFirstLine","string","insert","lines","split","subcommandPlaceholder","metadata","placeholder","options","length","arguments","allowPositionals","parseArgv","argv","currentQuote","currentArgument","char","previousChar","nextChar","end","push","escapeHtmlTags","markdown","escapeMap","fullMatch","code","comment","tag","ch","ansiRegex","onlyFirst","ST","String","raw","osc","csi","RegExp","regex","stripAnsi","findDuplicateStrings","seen","duplicates","has","add"],"sources":["../../src/utilities.ts"],"sourcesContent":["import type { Argument, Option, PreparedType } from \"./types/definitions-types.ts\";\nimport type { SubcommandMetadata } from \"./types/metadata-types.ts\";\nimport type { SchemaResult, SchemaType } from \"./types/schema-types.ts\";\nimport type { CoerceMethod } from \"./types/types.ts\";\n\n/** @throws */\nexport function validateSync(schema: SchemaType, value?: unknown): SchemaResult {\n const results = schema[\"~standard\"].validate(value);\n if (results instanceof Promise) {\n throw new TypeError(\"async schema validation not supported\");\n }\n\n return results;\n}\n\nexport function defaultValueAndIsOptional(schema: SchemaType): { defaultValue: unknown; optional: boolean } {\n const results = validateSync(schema);\n\n if (results.issues) {\n return { defaultValue: undefined, optional: false };\n }\n\n return { defaultValue: results.value, optional: true };\n}\n\nexport function PrepareType(schema: SchemaType, coerceHandler: CoerceMethod<unknown>): PreparedType {\n const { optional, defaultValue } = defaultValueAndIsOptional(schema);\n\n return {\n schema,\n optional,\n defaultValue,\n coerceTo: coerceHandler.type,\n validate: (value?: string) => validateSync(schema, value && coerceHandler(value)),\n };\n}\n\nexport function prepareDefinitionTypes(definition: Record<string, Argument> | Record<string, Option> | undefined) {\n if (!definition) return;\n\n for (const object of Object.values<Argument | Option>(definition)) {\n if (!object.coerce) {\n object.coerce = (value: string) => value;\n }\n\n if (!object._preparedType) {\n object._preparedType = PrepareType(object.schema, object.coerce);\n }\n }\n}\n\nexport function toKebabCase(input: string): string {\n return input.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\n/**\n * Converts a zero-based index into its human-readable ordinal form.\n *\n * Examples: 0 → \"1st\" 1 → \"2nd\" 2 → \"3rd\" 3 → \"4th\" 10 → \"11th\"\n *\n * Handles special cases for 11, 12, and 13.\n *\n * @param index - The zero-based index to convert.\n * @returns The ordinal string (e.g., \"1st\", \"2nd\", \"3rd\", \"4th\", ...).\n */\nexport function generateOrdinalSuffix(index: number): string {\n if (index < 0) return \"\";\n\n const number = index + 1;\n const lastDigit = number % 10;\n const lastTwoDigits = number % 100;\n\n let suffix = \"th\";\n\n if (lastTwoDigits < 11 || lastTwoDigits > 13) {\n switch (lastDigit) {\n case 1: {\n suffix = \"st\";\n break;\n }\n case 2: {\n suffix = \"nd\";\n break;\n }\n case 3: {\n suffix = \"rd\";\n break;\n }\n }\n }\n\n return `${number}${suffix}`;\n}\n\n/** New line */\nexport function ln(count: number) {\n return \"\\n\".repeat(count);\n}\n\n/** Space */\nexport function indent(count: number) {\n if (count <= 0) return \"\";\n return \" \".repeat(count);\n}\n\n/** Indents every line in the given text by the provided number of spaces. Empty lines are preserved. */\nexport function indentLines(text: string, spaces: number): string {\n return text.replace(/\\n/g, \"\\n\" + indent(spaces));\n}\n\nexport function stringifyValue(value: unknown): string {\n // Set\n if (value instanceof Set) {\n return (\n \"new Set([\" +\n Array.from(value)\n .map(element => stringifyValue(element))\n .join(\", \") +\n \"])\"\n );\n }\n\n // unknown\n return JSON.stringify(value);\n}\n\n/** Insert text at the end of the first line */\nexport function insertAtEndOfFirstLine(string: string, insert: string) {\n const lines = string.split(\"\\n\");\n lines[0] += (lines[0] ? \" \" : \"\") + insert;\n return lines.join(\"\\n\");\n}\n\n/** Get the placeholder for a subcommand */\nexport function subcommandPlaceholder(metadata: SubcommandMetadata): string {\n let placeholder = metadata.placeholder;\n\n if (placeholder) {\n return placeholder;\n }\n\n if (metadata.options.length > 0) {\n placeholder += (placeholder ? \" \" : \"\") + \"[options]\";\n }\n\n if (metadata.arguments.length > 0) {\n placeholder += (placeholder ? \" \" : \"\") + \"<arguments>\";\n }\n\n if (metadata.allowPositionals) {\n placeholder += (placeholder ? \" \" : \"\") + \"<positionals>\";\n }\n\n if (!placeholder) {\n placeholder = \" \";\n }\n\n return placeholder;\n}\n\n/** Parse a string into an argv (array of arguments) */\nexport function parseArgv(input: string): string[] {\n const argv = [];\n\n let currentQuote: string | undefined = undefined;\n let currentArgument: string | undefined = undefined;\n\n for (let index = 0; index < input.length; index++) {\n const char = input[index];\n const previousChar = input[index - 1];\n const nextChar = input[index + 1];\n const end = index === input.length - 1;\n\n // entering/leaving quote\n if ((char === '\"' || char === \"'\") && previousChar !== \"\\\\\") {\n // leaving quote\n if (currentQuote === char) {\n currentQuote = undefined;\n continue;\n }\n\n // entering quote\n if (currentQuote === undefined) {\n currentQuote = char;\n continue;\n }\n\n // quote inside quote\n if (currentQuote !== undefined && char !== currentQuote) {\n currentArgument += char;\n continue;\n }\n continue;\n }\n\n // new line\n if (char === \"\\\\\" && nextChar === \"\\n\") {\n index++;\n continue;\n }\n\n // Add to argv\n if (currentArgument !== undefined && currentQuote === undefined) {\n if (char === \" \") {\n argv.push(currentArgument);\n currentArgument = undefined;\n continue;\n }\n\n if (end) {\n currentArgument += char;\n argv.push(currentArgument);\n currentArgument = undefined;\n continue;\n }\n }\n\n // Ignore spaces outside of quotes\n if (char === \" \" && currentQuote === undefined) {\n continue;\n }\n\n // Ignore escaped characters\n if (char === \"\\\\\" && (nextChar === \"'\" || nextChar === '\"')) {\n continue;\n }\n\n currentArgument ??= \"\";\n currentArgument += char;\n }\n\n // Add last argument\n if (currentArgument !== undefined) {\n argv.push(currentArgument);\n }\n\n return argv;\n}\n\n/**\n * Escape HTML characters inside HTML tags in a Markdown string, but leave code blocks, inline code, and HTML comments\n * unchanged.\n */\nexport function escapeHtmlTags(markdown: string): string {\n const escapeMap: Record<string, string> = { \"&\": \"&amp;\", \"<\": \"&lt;\", \">\": \"&gt;\" };\n\n // Captures:\n // 1) fenced code blocks or inline code\n // 2) HTML comments <!-- ... -->\n // 3) other HTML tags like <b>, <div attr=\"x\">, etc.\n const re = /(```[\\s\\S]*?```|`[^`]*`)|(<!--[\\s\\S]*?-->)|(<[^>]+>)/g;\n\n return markdown.replace(re, (fullMatch: string, code?: string, comment?: string, tag?: string) => {\n if (code) return code;\n if (comment) return comment;\n if (!tag) return fullMatch;\n\n return tag.replace(/[&<>]/g, ch => escapeMap[ch]);\n });\n}\n\n/** Credits: https://github.com/chalk/ansi-regex */\nfunction ansiRegex({ onlyFirst = false } = {}) {\n // Valid string terminator sequences are BEL, ESC\\, and 0x9c\n const ST = String.raw`(?:\\u0007|\\u001B\\u005C|\\u009C)`;\n\n // OSC sequences only: ESC ] ... ST (non-greedy until the first ST)\n const osc = String.raw`(?:\\u001B\\][\\s\\S]*?${ST})`;\n\n // CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte\n const csi = String.raw`[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`;\n\n const pattern = `${osc}|${csi}`;\n\n return new RegExp(pattern, onlyFirst ? undefined : \"g\");\n}\n\nconst regex = ansiRegex();\n\nexport function stripAnsi(string: string): string {\n return string.replace(regex, \"\");\n}\n\nexport function findDuplicateStrings(values: readonly string[]): string[] {\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n\n for (const value of values) {\n if (seen.has(value)) {\n duplicates.add(value);\n continue;\n }\n\n seen.add(value);\n }\n\n return Array.from(duplicates);\n}\n"],"mappings":"AAMO,SAASA,aAAaC,EAAoBC,GAC/C,MAAMC,EAAUF,EAAO,aAAaG,SAASF,GAC7C,GAAIC,aAAmBE,QACrB,MAAM,IAAIC,UAAU,yCAGtB,OAAOH,CACT,CAEO,SAASI,0BAA0BN,GACxC,MAAME,EAAUH,aAAaC,GAE7B,OAAIE,EAAQK,OACH,CAAEC,kBAAc,EAAWC,UAAU,GAGvC,CAAED,aAAcN,EAAQD,MAAOQ,UAAU,EAClD,CAEO,SAASC,YAAYV,EAAoBW,GAC9C,MAAMF,SAAEA,EAAAD,aAAUA,GAAiBF,0BAA0BN,GAE7D,MAAO,CACLA,SACAS,WACAD,eACAI,SAAUD,EAAcE,KACxBV,SAAWF,GAAmBF,aAAaC,EAAQC,GAASU,EAAcV,IAE9E,CAEO,SAASa,uBAAuBC,GACrC,GAAKA,EAEL,UAAWC,KAAUC,OAAOC,OAA0BH,GAC/CC,EAAOG,SACVH,EAAOG,OAAUlB,GAAkBA,GAGhCe,EAAOI,gBACVJ,EAAOI,cAAgBV,YAAYM,EAAOhB,OAAQgB,EAAOG,QAG/D,CAEO,SAASE,YAAYC,GAC1B,OAAOA,EAAMC,QAAQ,kBAAmB,SAASC,aACnD,CAYO,SAASC,sBAAsBC,GACpC,GAAIA,EAAQ,EAAG,MAAO,GAEtB,MAAMC,EAASD,EAAQ,EAEjBE,EAAgBD,EAAS,IAE/B,IAAIE,EAAS,KAEb,GAAID,EAAgB,IAAMA,EAAgB,GACxC,OANgBD,EAAS,IAOvB,KAAK,EACHE,EAAS,KACT,MAEF,KAAK,EACHA,EAAS,KACT,MAEF,KAAK,EACHA,EAAS,KAMf,MAAO,GAAGF,IAASE,GACrB,CAGO,SAASC,GAAGC,GACjB,MAAO,KAAKC,OAAOD,EACrB,CAGO,SAASE,OAAOF,GACrB,OAAIA,GAAS,EAAU,GAChB,IAAIC,OAAOD,EACpB,CAGO,SAASG,YAAYC,EAAcC,GACxC,OAAOD,EAAKZ,QAAQ,MAAO,KAAOU,OAAOG,GAC3C,CAEO,SAASC,eAAepC,GAE7B,OAAIA,aAAiBqC,IAEjB,YACAC,MAAMC,KAAKvC,GACRwC,IAAIC,GAAWL,eAAeK,IAC9BC,KAAK,MACR,KAKGC,KAAKC,UAAU5C,EACxB,CAGO,SAAS6C,uBAAuBC,EAAgBC,GACrD,MAAMC,EAAQF,EAAOG,MAAM,MAE3B,OADAD,EAAM,KAAOA,EAAM,GAAK,IAAM,IAAMD,EAC7BC,EAAMN,KAAK,KACpB,CAGO,SAASQ,sBAAsBC,GACpC,IAAIC,EAAcD,EAASC,YAE3B,OAAIA,IAIAD,EAASE,QAAQC,OAAS,IAC5BF,IAAgBA,EAAc,IAAM,IAAM,aAGxCD,EAASI,UAAUD,OAAS,IAC9BF,IAAgBA,EAAc,IAAM,IAAM,eAGxCD,EAASK,mBACXJ,IAAgBA,EAAc,IAAM,IAAM,iBAGvCA,IACHA,EAAc,KAGTA,EACT,CAGO,SAASK,UAAUpC,GACxB,MAAMqC,EAAO,GAEb,IAAIC,EACAC,EAEJ,QAASnC,EAAQ,EAAGA,EAAQJ,EAAMiC,OAAQ7B,IAAS,CACjD,MAAMoC,EAAOxC,EAAMI,GACbqC,EAAezC,EAAMI,EAAQ,GAC7BsC,EAAW1C,EAAMI,EAAQ,GACzBuC,EAAMvC,IAAUJ,EAAMiC,OAAS,EAGrC,GAAc,MAATO,GAAyB,MAATA,GAAkC,OAAjBC,EAsBtC,GAAa,OAATD,GAA8B,OAAbE,EAArB,CAMA,QAAwB,IAApBH,QAAkD,IAAjBD,EAA4B,CAC/D,GAAa,MAATE,EAAc,CAChBH,EAAKO,KAAKL,GACVA,OAAkB,EAClB,QACF,CAEA,GAAII,EAAK,CACPJ,GAAmBC,EACnBH,EAAKO,KAAKL,GACVA,OAAkB,EAClB,QACF,CACF,CAGa,MAATC,QAAiC,IAAjBF,IAKP,OAATE,GAA+B,MAAbE,GAAiC,MAAbA,KAI1CH,MAAoB,IACpBA,GAAmBC,EA7BnB,MAFEpC,QAvBF,CAEE,GAAIkC,IAAiBE,EAAM,CACzBF,OAAe,EACf,QACF,CAGA,QAAqB,IAAjBA,EAA4B,CAC9BA,EAAeE,EACf,QACF,CAGA,QAAqB,IAAjBF,GAA8BE,IAASF,EAAc,CACvDC,GAAmBC,EACnB,QACF,CAEF,CAoCF,CAOA,YAJwB,IAApBD,GACFF,EAAKO,KAAKL,GAGLF,CACT,CAMO,SAASQ,eAAeC,GAC7B,MAAMC,EAAoC,CAAE,IAAK,QAAS,IAAK,OAAQ,IAAK,QAQ5E,OAAOD,EAAS7C,QAFL,wDAEiB,CAAC+C,EAAmBC,EAAeC,EAAkBC,IAC3EF,IACAC,IACCC,EAEEA,EAAIlD,QAAQ,SAAUmD,GAAML,EAAUK,IAF5BJ,IAIrB,CAGA,SAASK,WAAUC,UAAEA,GAAY,GAAU,CAAC,GAE1C,MAAMC,EAAKC,OAAOC,GAAA,iCAGZC,EAAMF,OAAOC,GAAA,sBAAyBF,KAGtCI,EAAMH,OAAOC,GAAA,+EAInB,OAAO,IAAIG,OAFK,GAAGF,KAAOC,IAECL,OAAY,EAAY,IACrD,CAEA,IAAMO,MAAQR,YAEP,SAASS,UAAUrC,GACxB,OAAOA,EAAOxB,QAAQ4D,MAAO,GAC/B,CAEO,SAASE,qBAAqBnE,GACnC,MAAMoE,EAAO,IAAIhD,IACXiD,EAAa,IAAIjD,IAEvB,UAAWrC,KAASiB,EACdoE,EAAKE,IAAIvF,GACXsF,EAAWE,IAAIxF,GAIjBqF,EAAKG,IAAIxF,GAGX,OAAOsC,MAAMC,KAAK+C,EACpB,Q","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";(()=>{var e=Object.defineProperty,t=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);!function({onlyFirst:e=!1}={}){const t=String.raw`(?:\u0007|\u001B\u005C|\u009C)`,n=String.raw`(?:\u001B\][\s\S]*?${t})`,r=String.raw`[\u001B\u009B][[\]()#;?]*(?:\d{1,4}(?:[;:]\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]`;new RegExp(`${n}|${r}`,e?void 0:"g")}();var n=(e=0)=>t=>`[${t+e}m`,r=(e=0)=>t=>`[${38+e};5;${t}m`,s=(e=0)=>(t,n,r)=>`[${38+e};2;${t};${n};${r}m`,i={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(i.modifier),Object.keys(i.color),Object.keys(i.bgColor);var l=function(){const e=new Map;for(const[t,n]of Object.entries(i)){for(const[t,r]of Object.entries(n))i[t]={open:`[${r[0]}m`,close:`[${r[1]}m`},n[t]=i[t],e.set(r[0],r[1]);Object.defineProperty(i,t,{value:n,enumerable:!1})}return Object.defineProperty(i,"codes",{value:e,enumerable:!1}),i.color.close="",i.bgColor.close="",i.color.ansi=n(),i.color.ansi256=r(),i.color.ansi16m=s(),i.bgColor.ansi=n(10),i.bgColor.ansi256=r(10),i.bgColor.ansi16m=s(10),Object.defineProperties(i,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;3===n.length&&(n=[...n].map(e=>e+e).join(""));const r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},enumerable:!1},hexToAnsi256:{value:e=>i.rgbToAnsi256(...i.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,n,r;if(e>=232)t=(10*(e-232)+8)/255,n=t,r=t;else{const s=(e-=16)%36;t=Math.floor(e/36)/5,n=Math.floor(s/6)/5,r=s%6/5}const s=2*Math.max(t,n,r);if(0===s)return 30;let i=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return 2===s&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>i.ansi256ToAnsi(i.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>i.ansi256ToAnsi(i.hexToAnsi256(e)),enumerable:!1}}),i}(),a=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),o=0!==a&&{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3},c={stdout:o,stderr:o};function h(e,t,n){let r=e.indexOf(t);if(-1===r)return e;const s=t.length;let i=0,l="";do{l+=e.slice(i,r)+t+n,i=r+s,r=e.indexOf(t,i)}while(-1!==r);return l+=e.slice(i),l}var{stdout:p,stderr:u}=c,g=Symbol("GENERATOR"),d=Symbol("STYLER"),k=Symbol("IS_EMPTY"),x=["ansi","ansi","ansi256","ansi16m"],f=Object.create(null),b=e=>{const t=(...e)=>e.join(" ");return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const n=p?p.level:0;e.level=void 0===t.level?n:t.level})(t,e),Object.setPrototypeOf(t,m.prototype),t};function m(e){return b(e)}Object.setPrototypeOf(m.prototype,Function.prototype);for(const[e,t]of Object.entries(l))f[e]={get(){const n=A(this,$(t.open,t.close,this[d]),this[k]);return Object.defineProperty(this,e,{value:n}),n}};f.visible={get(){const e=A(this,this[d],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var w=(e,t,n,...r)=>"rgb"===e?"ansi16m"===t?l[n].ansi16m(...r):"ansi256"===t?l[n].ansi256(l.rgbToAnsi256(...r)):l[n].ansi(l.rgbToAnsi(...r)):"hex"===e?w("rgb",t,n,...l.hexToRgb(...r)):l[n][e](...r);for(const e of["rgb","hex","ansi256"]){f[e]={get(){const{level:t}=this;return function(...n){const r=$(w(e,x[t],"color",...n),l.color.close,this[d]);return A(this,r,this[k])}}};f["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...n){const r=$(w(e,x[t],"bgColor",...n),l.bgColor.close,this[d]);return A(this,r,this[k])}}}}var y=Object.defineProperties(()=>{},{...f,level:{enumerable:!0,get(){return this[g].level},set(e){this[g].level=e}}}),$=(e,t,n)=>{let r,s;return void 0===n?(r=e,s=t):(r=n.openAll+e,s=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:s,parent:n}},A=(e,t,n)=>{const r=(...e)=>T(r,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(r,y),r[g]=e,r[d]=t,r[k]=n,r},T=(e,t)=>{if(e.level<=0||!t)return e[k]?"":t;let n=e[d];if(void 0===n)return t;const{openAll:r,closeAll:s}=n;if(t.includes(""))for(;void 0!==n;)t=h(t,n.close,n.open),n=n.parent;const i=t.indexOf("\n");return-1!==i&&(t=function(e,t,n,r){let s=0,i="";do{const l="\r"===e[r-1];i+=e.slice(s,l?r-1:r)+t+(l?"\r\n":"\n")+n,s=r+1,r=e.indexOf("\n",s)}while(-1!==r);return i+=e.slice(s),i}(t,s,r,i)),r+t+s};Object.defineProperties(m.prototype,f);var S=m(),R=(m({level:u?u.level:0}),S);function B(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var C={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function v(e){C=e}var z={exec:()=>null};function E(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(_.caret,"$1"),n=n.replace(e,s),r},getRegex:()=>new RegExp(n,t)};return r}var P=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),_={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},j=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,I=/(?:[*+-]|\d{1,9}[.)])/,F=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,O=E(F).replace(/bull/g,I).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),L=E(F).replace(/bull/g,I).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),D=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,q=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,M=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",q).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Z=E(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,I).getRegex(),N="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",G=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,H=E("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",G).replace("tag",N).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Q=E(D).replace("hr",j).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",N).getRegex(),W={blockquote:E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Q).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:M,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:j,html:H,lheading:O,list:Z,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Q,table:z,text:/^[^\n]+/},X=E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",j).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",N).getRegex(),U={...W,lheading:L,table:X,paragraph:E(D).replace("hr",j).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",X).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",N).getRegex()},Y={...W,html:E("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",G).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:z,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(D).replace("hr",j).replace("heading"," *#{1,6} *[^\n]").replace("lheading",O).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},J=/^( {2,}|\\)\n(?!\s*$)/,K=/[\p{P}\p{S}]/u,V=/[\s\p{P}\p{S}]/u,ee=/[^\s\p{P}\p{S}]/u,te=E(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,V).getRegex(),ne=/(?!~)[\p{P}\p{S}]/u,re=E(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",P?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),se=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ie=E(se,"u").replace(/punct/g,K).getRegex(),le=E(se,"u").replace(/punct/g,ne).getRegex(),ae="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oe=E(ae,"gu").replace(/notPunctSpace/g,ee).replace(/punctSpace/g,V).replace(/punct/g,K).getRegex(),ce=E(ae,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,ne).getRegex(),he=E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ee).replace(/punctSpace/g,V).replace(/punct/g,K).getRegex(),pe=E(/\\(punct)/,"gu").replace(/punct/g,K).getRegex(),ue=E(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ge=E(G).replace("(?:--\x3e|$)","--\x3e").getRegex(),de=E("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ge).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ke=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,xe=E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",ke).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),fe=E(/^!?\[(label)\]\[(ref)\]/).replace("label",ke).replace("ref",q).getRegex(),be=E(/^!?\[(ref)\](?:\[\])?/).replace("ref",q).getRegex(),me=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,we={_backpedal:z,anyPunctuation:pe,autolink:ue,blockSkip:re,br:J,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:z,emStrongLDelim:ie,emStrongRDelimAst:oe,emStrongRDelimUnd:he,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:xe,nolink:be,punctuation:te,reflink:fe,reflinkSearch:E("reflink|nolink(?!\\()","g").replace("reflink",fe).replace("nolink",be).getRegex(),tag:de,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:z},ye={...we,link:E(/^!?\[(label)\]\((.*?)\)/).replace("label",ke).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ke).getRegex()},$e={...we,emStrongRDelimAst:ce,emStrongLDelim:le,url:E(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",me).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:E(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",me).getRegex()},Ae={...$e,br:E(J).replace("{2,}","*").getRegex(),text:E($e.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Te={normal:W,gfm:U,pedantic:Y},Se={normal:we,gfm:$e,breaks:Ae,pedantic:ye},Re={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Be=e=>Re[e];function Ce(e,t){if(t){if(_.escapeTest.test(e))return e.replace(_.escapeReplace,Be)}else if(_.escapeTestNoEncode.test(e))return e.replace(_.escapeReplaceNoEncode,Be);return e}function ve(e){try{e=encodeURI(e).replace(_.percentDecode,"%")}catch{return null}return e}function ze(e,t){let n=e.replace(_.findPipe,(e,t,n)=>{let r=!1,s=t;for(;--s>=0&&"\\"===n[s];)r=!r;return r?"|":" |"}).split(_.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(_.slashPipe,"|");return n}function Ee(e,t,n){let r=e.length;if(0===r)return"";let s=0;for(;s<r;){let i=e.charAt(r-s-1);if(i!==t||n){if(i===t||!n)break;s++}else s++}return e.slice(0,r-s)}function Pe(e,t,n,r,s){let i=t.href,l=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let o={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:i,title:l,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,o}var _e,je=class{constructor(e){t(this,"options"),t(this,"rules"),t(this,"lexer"),this.options=e||C}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Ee(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let s=r[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Ee(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ee(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Ee(t[0],"\n").split("\n"),n="",r="",s=[];for(;e.length>0;){let t,i=!1,l=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))l.push(e[t]),i=!0;else{if(i)break;l.push(e[t])}e=e.slice(t);let a=l.join("\n"),o=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,r=r?`${r}\n${o}`:o;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(o,s,!0),this.lexer.state.top=c,0===e.length)break;let h=s.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,i=t.raw+"\n"+e.join("\n"),l=this.blockquote(i);s[s.length-1]=l,n=n.substring(0,n.length-t.raw.length)+l.raw,r=r.substring(0,r.length-t.text.length)+l.text;break}if("list"===h?.type){let t=h,i=t.raw+"\n"+e.join("\n"),l=this.list(i);s[s.length-1]=l,n=n.substring(0,n.length-h.raw.length)+l.raw,r=r.substring(0,r.length-t.raw.length)+l.raw,e=i.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),l=!1;for(;e;){let n=!1,r="",a="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let o=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],h=!o.trim(),p=0;if(this.options.pedantic?(p=2,a=o.trimStart()):h?p=t[1].length+1:(p=t[2].search(this.rules.other.nonSpaceChar),p=p>4?1:p,a=o.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),s=this.rules.other.fencesBeginRegex(p),i=this.rules.other.headingBeginRegex(p),l=this.rules.other.htmlBeginRegex(p);for(;e;){let u,g=e.split("\n",1)[0];if(c=g,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||i.test(c)||l.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=p||!c.trim())a+="\n"+u.slice(p);else{if(h||o.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(o)||i.test(o)||n.test(o))break;a+="\n"+c}!h&&!c.trim()&&(h=!0),r+=g+"\n",e=e.substring(g.length+1),o=u.slice(p)}}s.loose||(l?s.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(l=!0));let u=null;this.options.gfm&&(u=this.rules.other.listIsTask.exec(a),u&&(a=a.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:r,task:!!u,loose:!1,text:a,tokens:[]}),s.raw+=r}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));s.loose=n}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ze(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?i.align.push("right"):this.rules.other.tableAlignCenter.test(e)?i.align.push("center"):this.rules.other.tableAlignLeft.test(e)?i.align.push("left"):i.align.push(null);for(let e=0;e<n.length;e++)i.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:i.align[e]});for(let e of s)i.rows.push(ze(e,i.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:i.align[t]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Ee(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Pe(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Pe(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){let n,s,i=[...r[0]].length-1,l=i,a=0,o="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(o.lastIndex=0,t=t.slice(-1*e.length+i);null!=(r=o.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(s=[...n].length,r[3]||r[4]){l+=s;continue}if((r[5]||r[6])&&i%3&&!((i+s)%3)){a+=s;continue}if(l-=s,l>0)continue;s=Math.min(s,s+l+a);let t=[...r[0]][0].length,o=e.slice(0,i+r.index+t+s);if(Math.min(i,s)%2){let e=o.slice(1,-1);return{type:"em",raw:o,text:e,tokens:this.lexer.inlineTokens(e)}}let c=o.slice(2,-2);return{type:"strong",raw:o,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},Ie=class e{constructor(e){t(this,"tokens"),t(this,"options"),t(this,"state"),t(this,"tokenizer"),t(this,"inlineQueue"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||C,this.options.tokenizer=this.options.tokenizer||new je,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:_,block:Te.normal,inline:Se.normal};this.options.pedantic?(n.block=Te.pedantic,n.inline=Se.pedantic):this.options.gfm&&(n.block=Te.gfm,this.options.breaks?n.inline=Se.breaks:n.inline=Se.gfm),this.tokenizer.rules=n}static get rules(){return{block:Te,inline:Se}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(_.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(_.tabCharGlobal," ").replace(_.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0)))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let s=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){let i=t.at(-1);n&&"paragraph"===i?.type?(i.raw+=(i.raw.endsWith("\n")?"":"\n")+r.raw,i.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):t.push(r),n=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r=e,s=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(r));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.anyPunctuation.exec(r));)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(r));)n=s[2]?s[2].length:0,r=r.slice(0,s.index+n)+"["+"a".repeat(s[0].length-n-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,l="";for(;e;){let n;if(i||(l=""),i=!1,this.options.extensions?.inline?.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let r=t.at(-1);"text"===n.type&&"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,r,l)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(s)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(l=n.raw.slice(-1)),i=!0;let r=t.at(-1);"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},Fe=class{constructor(e){t(this,"options"),t(this,"parser"),this.options=e||C}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(_.notSpaceStart)?.[0],s=e.replace(_.endingNewline,"")+"\n";return r?'<pre><code class="language-'+Ce(r)+'">'+(n?s:Ce(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:Ce(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,r="";for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+r+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r="";for(let t=0;t<e.rows.length;t++){let s=e.rows[t];n="";for(let e=0;e<s.length;e++)n+=this.tablecell(s[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ce(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),s=ve(e);if(null===s)return r;let i='<a href="'+(e=s)+'"';return t&&(i+=' title="'+Ce(t)+'"'),i+=">"+r+"</a>",i}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=ve(e);if(null===s)return Ce(n);let i=`<img src="${e=s}" alt="${n}"`;return t&&(i+=` title="${Ce(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ce(e.text)}},Oe=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Le=class e{constructor(e){t(this,"options"),t(this,"renderer"),t(this,"textRenderer"),this.options=e||C,this.options.renderer=this.options.renderer||new Fe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Oe}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=r;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let i=s;switch(i.type){case"escape":case"text":n+=t.text(i);break;case"html":n+=t.html(i);break;case"link":n+=t.link(i);break;case"image":n+=t.image(i);break;case"checkbox":n+=t.checkbox(i);break;case"strong":n+=t.strong(i);break;case"em":n+=t.em(i);break;case"codespan":n+=t.codespan(i);break;case"br":n+=t.br(i);break;case"del":n+=t.del(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},De=(_e=class{constructor(e){t(this,"options"),t(this,"block"),this.options=e||C}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ie.lex:Ie.lexInline}provideParser(){return this.block?Le.parse:Le.parseInline}},t(_e,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),t(_e,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),_e),qe=class{constructor(...e){t(this,"defaults",{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}),t(this,"options",this.setOptions),t(this,"parse",this.parseMarkdown(!0)),t(this,"parseInline",this.parseMarkdown(!1)),t(this,"Parser",Le),t(this,"Renderer",Fe),t(this,"TextRenderer",Oe),t(this,"Lexer",Ie),t(this,"Tokenizer",je),t(this,"Hooks",De),this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let s=e[r].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Fe(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,s=e.renderer[r],i=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=i.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new je(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,s=e.tokenizer[r],i=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new De;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,s=e.hooks[r],i=t[r];De.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&De.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return i.call(t,n)})();let r=s.call(t,e);return i.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await i.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=i.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ie.lex(e,t??this.defaults)}parser(e,t){return Le.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===r.async)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return i(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer():e?Ie.lex:Ie.lexInline)(n,s),i=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(i,s.walkTokens));let l=await(s.hooks?await s.hooks.provideParser():e?Le.parse:Le.parseInline)(i,s);return s.hooks?await s.hooks.postprocess(l):l})().catch(i);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer():e?Ie.lex:Ie.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let r=(s.hooks?s.hooks.provideParser():e?Le.parse:Le.parseInline)(n,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(e){return i(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+Ce(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Me=new qe;function Ze(e,t){return Me.parse(e,t)}Ze.options=Ze.setOptions=function(e){return Me.setOptions(e),Ze.defaults=Me.defaults,v(Ze.defaults),Ze},Ze.getDefaults=B,Ze.defaults=C,Ze.use=function(...e){return Me.use(...e),Ze.defaults=Me.defaults,v(Ze.defaults),Ze},Ze.walkTokens=function(e,t){return Me.walkTokens(e,t)},Ze.parseInline=Me.parseInline,Ze.Parser=Le,Ze.parser=Le.parse,Ze.Renderer=Fe,Ze.TextRenderer=Oe,Ze.Lexer=Ie,Ze.lexer=Ie.lex,Ze.Tokenizer=je,Ze.Hooks=De,Ze.parse=Ze;Ze.options,Ze.setOptions,Ze.use,Ze.walkTokens,Ze.parseInline,Le.parse,Ie.lex;var Ne={bold:R.bold,italic:R.italic,boldItalic:R.bold.italic,code:(...e)=>R.bgHex("#333333").whiteBright(` ${e.join(" ")} `),strikethrough:R.strikethrough,link:R.underline,listBullet:R.whiteBright,hr:R.dim,blockquote:(...e)=>R.dim.bold("┃ ")+R.dim(e.join("").replace(/\s\s\n/g," \n"+R.bold("┃ ")))};var Ge=["•","◦","▪"],He={list(e){let t=0,n=e;for(;n.parent;)t++,n=n.parent;const r=e.ordered&&e.start?e.start:void 0;return"\n"+e.items.map(n=>this.listitem(Object.assign(n,{depth:t,parent:e,start:r}))).join("\n")},listitem(e){let t="";const n=e;for(const r of e.tokens)"list"===r.type&&(t+=this.parser.parse([Object.assign(r,{parent:n.parent})])),"tokens"in r&&Array.isArray(r.tokens)&&(t+=this.parser.parseInline(r.tokens));let r=" ".repeat(2*n.depth);if(n.task)return r+=n.checked?"☑ ":"☐ ",Ne.listBullet(r)+t;if(void 0!==n.start){const e=n.parent.items.indexOf(n);return r+=n.start+e+". ",Ne.listBullet(r)+t}return r+=Ge[n.depth%Ge.length]+" ",Ne.listBullet(r)+t},link:e=>Ne.link(e.text+" <"+e.href+">"),checkbox:({checked:e})=>e.toString(),code:e=>function(e){const t=e.split("\n"),n=Math.max(...t.map(e=>e.length)),r="┌"+"─".repeat(n+2)+"┐",s="└"+"─".repeat(n+2)+"┘",i=t.map(e=>R.dim("│ ")+R.dim(e).padEnd(n)+R.dim(" │")).join("\n");return[R.dim(r),i,R.dim(s)].join("\n")}(e.text),codespan:({text:e})=>Ne.code(e),def:({raw:e})=>e,del:({text:e})=>Ne.strikethrough(e),paragraph({tokens:e}){return this.parser.parseInline(e)},blockquote:({text:e})=>Ne.blockquote(e),strong({tokens:e}){return Ne.bold(this.parser.parseInline(e))},em({tokens:e}){return Ne.italic(this.parser.parseInline(e))},heading:({text:e})=>Ne.bold(e)+"\n",text:e=>e.raw,space:e=>e.raw.replace(/\n+/g,"\n"),hr:()=>Ne.hr("─".repeat(80)),br:()=>"\n"},Qe=new qe;Qe.use({renderer:He});var We=class e{constructor(n,r){t(this,"title",e.noColor),t(this,"description",e.noColor),t(this,"default",e.noColor),t(this,"optional",e.noColor),t(this,"exampleTitle",e.noColor),t(this,"example",e.noColor),t(this,"command",e.noColor),t(this,"option",e.noColor),t(this,"argument",e.noColor),t(this,"placeholder",e.noColor),t(this,"punctuation",e.noColor),r&&Object.assign(this,r),Object.assign(this,n)}};t(We,"noColor",(...e)=>e.join(" "));var Xe=We;Object.freeze({default:new Xe({title:R.bold.blue,description:R.white,default:R.dim.italic,optional:R.dim.italic,exampleTitle:R.yellow,example:R.dim,command:R.yellow,option:R.cyan,argument:R.green,placeholder:R.hex("#FF9800"),punctuation:R.white.dim}),dracula:new Xe({title:R.bold.hex("#BD93F9"),description:R.hex("#F8F8F2"),default:R.italic.hex("#6272A4"),optional:R.italic.hex("#6272A4"),exampleTitle:R.hex("#FFB86C"),example:R.hex("#6272A4"),command:R.hex("#50FA7B"),option:R.hex("#8BE9FD"),argument:R.hex("#FF79C6"),placeholder:R.hex("#F1FA8C"),punctuation:R.hex("#6272A4")}),solarizedDark:new Xe({title:R.bold.hex("#268BD2"),description:R.hex("#93A1A1"),default:R.italic.hex("#586E75"),optional:R.italic.hex("#586E75"),exampleTitle:R.hex("#B58900"),example:R.hex("#586E75"),command:R.hex("#2AA198"),option:R.hex("#268BD2"),argument:R.hex("#859900"),placeholder:R.hex("#CB4B16"),punctuation:R.hex("#657B83")}),nord:new Xe({title:R.bold.hex("#81A1C1"),description:R.hex("#D8DEE9"),default:R.italic.hex("#4C566A"),optional:R.italic.hex("#4C566A"),exampleTitle:R.hex("#EBCB8B"),example:R.hex("#4C566A"),command:R.hex("#A3BE8C"),option:R.hex("#88C0D0"),argument:R.hex("#BF616A"),placeholder:R.hex("#D08770"),punctuation:R.hex("#4C566A")}),html:new Xe({title:(...e)=>`<span style="color: #89dceb; font-weight: bold;">${Ue(e.join(" "))}</span>`,description:(...e)=>`<span style="color: #cdd6e8;">${Ue(e.join(" "))}</span>`,default:(...e)=>`<span style="color: #6c7086; font-style: italic;">${Ue(e.join(" "))}</span>`,optional:(...e)=>`<span style="color: #6c7086; font-style: italic;">${Ue(e.join(" "))}</span>`,exampleTitle:(...e)=>`<span style="color: #f9e2af;">${Ue(e.join(" "))}</span>`,example:(...e)=>`<span style="color: #6c7086;">${Ue(e.join(" "))}</span>`,command:(...e)=>`<span style="color: #f9e2af;">${Ue(e.join(" "))}</span>`,option:(...e)=>`<span style="color: #17b85d;">${Ue(e.join(" "))}</span>`,argument:(...e)=>`<span style="color: #00ff00;">${Ue(e.join(" "))}</span>`,placeholder:(...e)=>`<span style="color: #db9518;">${Ue(e.join(" "))}</span>`,punctuation:(...e)=>`<span style="color: #6c7086;">${Ue(e.join(" "))}</span>`}),gruvboxDark:new Xe({title:R.bold.hex("#FABD2F"),description:R.hex("#EBDBB2"),default:R.italic.hex("#928374"),optional:R.italic.hex("#928374"),exampleTitle:R.hex("#FE8019"),example:R.hex("#928374"),command:R.hex("#B8BB26"),option:R.hex("#83A598"),argument:R.hex("#D3869B"),placeholder:R.hex("#FB4934"),punctuation:R.hex("#928374")}),monokai:new Xe({title:R.bold.hex("#AE81FF"),description:R.hex("#F8F8F2"),default:R.italic.hex("#75715E"),optional:R.italic.hex("#75715E"),exampleTitle:R.hex("#FD971F"),example:R.hex("#75715E"),command:R.hex("#A6E22E"),option:R.hex("#66D9EF"),argument:R.hex("#F92672"),placeholder:R.hex("#E6DB74"),punctuation:R.hex("#75715E")}),oneDark:new Xe({title:R.bold.hex("#61AFEF"),description:R.hex("#ABB2BF"),default:R.italic.hex("#5C6370"),optional:R.italic.hex("#5C6370"),exampleTitle:R.hex("#E5C07B"),example:R.hex("#5C6370"),command:R.hex("#98C379"),option:R.hex("#56B6C2"),argument:R.hex("#E06C75"),placeholder:R.hex("#C678DD"),punctuation:R.hex("#5C6370")}),catppuccin:new Xe({title:R.bold.hex("#89B4FA"),description:R.hex("#CDD6F4"),default:R.italic.hex("#6C7086"),optional:R.italic.hex("#6C7086"),exampleTitle:R.hex("#F9E2AF"),example:R.hex("#6C7086"),command:R.hex("#A6E3A1"),option:R.hex("#94E2D5"),argument:R.hex("#F38BA8"),placeholder:R.hex("#FAB387"),punctuation:R.hex("#585B70")}),noColors:new Xe({})});function Ue(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ye(e){if("true"===e.toLowerCase())return!0;if("false"===e.toLowerCase())return!1;throw new TypeError(`Invalid boolean value: ${e}`)}function Je(e){const t=e.trim();if(""===t||"+"===t||"-"===t)throw new TypeError(`Invalid number: "${e}"`);const n=Number(t);if(!Number.isFinite(n))throw new TypeError(`Invalid number: "${e}"`);return n}var Ke=e=>e;Ke.type="string";var Ve=e=>Ye(e);Ve.type="boolean";var et=e=>Je(e);et.type="number"})();
2
+ //# sourceMappingURL=index.js.map