@bendyline/squisq 1.4.0 → 1.5.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 (782) hide show
  1. package/dist/{Doc-BeSeH2iX.d.ts → Doc-BsMkmzH8.d.ts} +838 -268
  2. package/dist/{ImageEditDoc-BTIvw0oq.d.ts → ImageEditDoc-DvoeHMP9.d.ts} +11 -4
  3. package/dist/{chunk-ZTX4PFFT.js → chunk-2OIBZYKP.js} +75 -2
  4. package/dist/chunk-2OIBZYKP.js.map +1 -0
  5. package/dist/chunk-2UQOHYE2.js +45 -0
  6. package/dist/chunk-2UQOHYE2.js.map +1 -0
  7. package/dist/{chunk-B4EEON3N.js → chunk-4AKUQPEE.js} +536 -103
  8. package/dist/chunk-4AKUQPEE.js.map +1 -0
  9. package/dist/chunk-4ZFRZBU2.js +6582 -0
  10. package/dist/chunk-4ZFRZBU2.js.map +1 -0
  11. package/dist/{chunk-57CVQCFX.js → chunk-7MQGNR76.js} +79 -3
  12. package/dist/chunk-7MQGNR76.js.map +1 -0
  13. package/dist/{chunk-5WFRKURX.js → chunk-DLXZMS5K.js} +4 -2
  14. package/dist/chunk-DLXZMS5K.js.map +1 -0
  15. package/dist/{chunk-MYIH7FWD.js → chunk-FBKP5CAO.js} +1 -1
  16. package/dist/chunk-FBKP5CAO.js.map +1 -0
  17. package/dist/chunk-KZNXZ5SM.js +333 -0
  18. package/dist/chunk-KZNXZ5SM.js.map +1 -0
  19. package/dist/{chunk-WMOI7FN3.js → chunk-LRCV7N7F.js} +12 -2
  20. package/dist/{chunk-WMOI7FN3.js.map → chunk-LRCV7N7F.js.map} +1 -1
  21. package/dist/{chunk-3K5OG6KI.js → chunk-OH43RPTP.js} +403 -187
  22. package/dist/chunk-OH43RPTP.js.map +1 -0
  23. package/dist/{chunk-H3AXU4MJ.js → chunk-OKJOQXK4.js} +149 -2
  24. package/dist/chunk-OKJOQXK4.js.map +1 -0
  25. package/dist/chunk-PGGGKYWG.js +1 -0
  26. package/dist/chunk-PGGGKYWG.js.map +1 -0
  27. package/dist/{chunk-7UDSRZKG.js → chunk-Q3ROPT5H.js} +35 -14
  28. package/dist/chunk-Q3ROPT5H.js.map +1 -0
  29. package/dist/chunk-QE7TWGVT.js +178 -0
  30. package/dist/chunk-QE7TWGVT.js.map +1 -0
  31. package/dist/chunk-RUDYOTA6.js +345 -0
  32. package/dist/chunk-RUDYOTA6.js.map +1 -0
  33. package/dist/chunk-TVSGLUID.js +596 -0
  34. package/dist/chunk-TVSGLUID.js.map +1 -0
  35. package/dist/chunk-ZLQKNOZQ.js +1 -0
  36. package/dist/chunk-ZLQKNOZQ.js.map +1 -0
  37. package/dist/doc/index.d.ts +5 -10
  38. package/dist/doc/index.js +263 -7
  39. package/dist/doc/index.js.map +1 -1
  40. package/dist/generate/index.d.ts +106 -7
  41. package/dist/generate/index.js +16 -3
  42. package/dist/generate/index.js.map +1 -1
  43. package/dist/icons/index.d.ts +62 -10
  44. package/dist/icons/index.js +29 -9
  45. package/dist/icons/index.js.map +1 -1
  46. package/dist/icons/inlineIconMarker.d.ts +1 -0
  47. package/dist/icons/inlineIconMarker.js +15 -0
  48. package/dist/icons/inlineIconMarker.js.map +1 -0
  49. package/dist/imageEdit/index.d.ts +219 -11
  50. package/dist/imageEdit/index.js +56 -21
  51. package/dist/imageEdit/index.js.map +1 -1
  52. package/dist/index.d.ts +24 -13
  53. package/dist/index.js +680 -12
  54. package/dist/index.js.map +1 -1
  55. package/dist/inlineIconMarker-CiE8Hlvz.d.ts +59 -0
  56. package/dist/jsonForm/index.d.ts +189 -12
  57. package/dist/jsonForm/index.js +26 -11
  58. package/dist/jsonForm/index.js.map +1 -1
  59. package/dist/markdown/index.d.ts +474 -19
  60. package/dist/markdown/index.js +72 -33
  61. package/dist/markdown/index.js.map +1 -1
  62. package/dist/random/index.d.ts +51 -2
  63. package/dist/random/index.js +9 -1
  64. package/dist/random/index.js.map +1 -1
  65. package/dist/recommend/index.d.ts +39 -13
  66. package/dist/recommend/index.js +10 -14
  67. package/dist/recommend/index.js.map +1 -1
  68. package/dist/schemas/index.d.ts +208 -15
  69. package/dist/schemas/index.js +150 -11
  70. package/dist/schemas/index.js.map +1 -1
  71. package/dist/spatial/index.d.ts +116 -3
  72. package/dist/spatial/index.js +24 -2
  73. package/dist/spatial/index.js.map +1 -1
  74. package/dist/storage/index.d.ts +159 -10
  75. package/dist/storage/index.js +20 -6
  76. package/dist/storage/index.js.map +1 -1
  77. package/dist/story/index.d.ts +906 -40
  78. package/dist/story/index.js +124 -6
  79. package/dist/{themeLibrary-BHjJ0Qx6.d.ts → themeLibrary-DQQKuRMx.d.ts} +1 -1
  80. package/dist/timing/index.d.ts +109 -4
  81. package/dist/timing/index.js +23 -2
  82. package/dist/timing/index.js.map +1 -1
  83. package/dist/transform/index.d.ts +213 -6
  84. package/dist/transform/index.js +26 -3
  85. package/dist/transform/index.js.map +1 -1
  86. package/dist/{types-BdZkdJ3z.d.ts → types-DlAZ7MW4.d.ts} +115 -1
  87. package/dist/versions/index.d.ts +123 -24
  88. package/dist/versions/index.js +34 -27
  89. package/dist/versions/index.js.map +1 -1
  90. package/package.json +6 -1
  91. package/src/__tests__/animationUtils.test.ts +40 -0
  92. package/src/__tests__/annotationCoercion.test.ts +243 -0
  93. package/src/__tests__/applyRenderStyle.test.ts +146 -0
  94. package/src/__tests__/atmosphereLayers.test.ts +108 -0
  95. package/src/__tests__/attrTokens.test.ts +162 -0
  96. package/src/__tests__/customTemplateSample.test.ts +83 -0
  97. package/src/__tests__/customTemplatesFrontmatter.test.ts +205 -0
  98. package/src/__tests__/customThemesFrontmatter.test.ts +118 -0
  99. package/src/__tests__/diagramBlock.test.ts +122 -0
  100. package/src/__tests__/diagramLayout.test.ts +134 -0
  101. package/src/__tests__/drawing.test.ts +109 -0
  102. package/src/__tests__/drawingBlock.test.ts +124 -0
  103. package/src/__tests__/drawingLayout.test.ts +171 -0
  104. package/src/__tests__/geohash.test.ts +6 -5
  105. package/src/__tests__/getLayers.test.ts +6 -2
  106. package/src/__tests__/getLayersFallback.test.ts +103 -0
  107. package/src/__tests__/imageEditExportSvg.test.ts +70 -0
  108. package/src/__tests__/imageEditVersions.test.ts +72 -0
  109. package/src/__tests__/inlineIconMarker.test.ts +36 -0
  110. package/src/__tests__/layoutBlock.test.ts +83 -0
  111. package/src/__tests__/layoutLayout.test.ts +169 -0
  112. package/src/__tests__/markdown.test.ts +23 -0
  113. package/src/__tests__/markdownSanitize.test.ts +64 -0
  114. package/src/__tests__/markdownToDoc.test.ts +223 -2
  115. package/src/__tests__/mediaAnnotations.test.ts +64 -0
  116. package/src/__tests__/mediaSchedule.test.ts +118 -0
  117. package/src/__tests__/pandocAttrParse.test.ts +187 -0
  118. package/src/__tests__/resolveDocTheme.test.ts +55 -0
  119. package/src/__tests__/rootExports.test.ts +43 -0
  120. package/src/__tests__/shapeGeometry.test.ts +89 -0
  121. package/src/__tests__/shapeVocabulary.test.ts +133 -0
  122. package/src/__tests__/structuredData.test.ts +179 -0
  123. package/src/__tests__/templateAnnotationParse.test.ts +108 -0
  124. package/src/__tests__/templateMetadata.test.ts +21 -0
  125. package/src/__tests__/templates.test.ts +145 -4
  126. package/src/__tests__/themeCompile.test.ts +42 -0
  127. package/src/__tests__/themeValidator.test.ts +6 -0
  128. package/src/__tests__/transformV2.test.ts +137 -0
  129. package/src/__tests__/transitionNormalize.test.ts +61 -0
  130. package/src/__tests__/validateDoc.test.ts +100 -0
  131. package/src/doc/customTemplatesFrontmatter.ts +308 -0
  132. package/src/doc/customThemesFrontmatter.ts +90 -0
  133. package/src/doc/docToMarkdown.ts +73 -4
  134. package/src/doc/getLayers.ts +40 -17
  135. package/src/doc/index.ts +35 -1
  136. package/src/doc/markdownToDoc.ts +333 -12
  137. package/src/doc/mediaAnnotations.ts +118 -0
  138. package/src/doc/resolveDocTheme.ts +55 -0
  139. package/src/doc/structuredData.ts +230 -0
  140. package/src/doc/templateInputs.ts +240 -0
  141. package/src/doc/templates/__tests__/customTemplate.test.ts +151 -0
  142. package/src/doc/templates/__tests__/customTemplateRegistry.test.ts +110 -0
  143. package/src/doc/templates/accentImage.ts +30 -6
  144. package/src/doc/templates/captionUtils.ts +23 -0
  145. package/src/doc/templates/comparisonBar.ts +26 -18
  146. package/src/doc/templates/coverBlock.ts +7 -4
  147. package/src/doc/templates/customTemplate.ts +45 -0
  148. package/src/doc/templates/dataTable.ts +37 -19
  149. package/src/doc/templates/dateEvent.ts +41 -20
  150. package/src/doc/templates/definitionCard.ts +26 -18
  151. package/src/doc/templates/diagramBlock.ts +204 -0
  152. package/src/doc/templates/diagramLayout.ts +159 -0
  153. package/src/doc/templates/drawingBlock.ts +325 -0
  154. package/src/doc/templates/drawingLayout.ts +539 -0
  155. package/src/doc/templates/factCard.ts +51 -25
  156. package/src/doc/templates/fallbackBlock.ts +123 -0
  157. package/src/doc/templates/featureBlock.ts +20 -13
  158. package/src/doc/templates/fullBleedQuote.ts +18 -8
  159. package/src/doc/templates/imageWithCaption.ts +22 -9
  160. package/src/doc/templates/index.ts +215 -46
  161. package/src/doc/templates/layoutBlock.ts +43 -0
  162. package/src/doc/templates/layoutLayout.ts +243 -0
  163. package/src/doc/templates/listBlock.ts +56 -30
  164. package/src/doc/templates/mapBlock.ts +15 -12
  165. package/src/doc/templates/metadata.ts +120 -0
  166. package/src/doc/templates/persistentLayers.ts +129 -11
  167. package/src/doc/templates/photoGrid.ts +23 -12
  168. package/src/doc/templates/pullQuote.ts +30 -12
  169. package/src/doc/templates/quoteBlock.ts +54 -29
  170. package/src/doc/templates/sectionHeader.ts +25 -11
  171. package/src/doc/templates/statHighlight.ts +39 -22
  172. package/src/doc/templates/titleBlock.ts +59 -21
  173. package/src/doc/templates/tokens/__tests__/resolveTokens.test.ts +221 -0
  174. package/src/doc/templates/tokens/resolveTokens.ts +0 -0
  175. package/src/doc/templates/twoColumn.ts +48 -30
  176. package/src/doc/templates/videoPullQuote.ts +22 -12
  177. package/src/doc/templates/videoWithCaption.ts +13 -8
  178. package/src/doc/utils/animationUtils.ts +267 -3
  179. package/src/doc/utils/applyRenderStyle.ts +113 -0
  180. package/src/doc/utils/imageTreatment.ts +70 -0
  181. package/src/doc/utils/shapeGeometry.ts +464 -0
  182. package/src/doc/utils/themeUtils.ts +75 -1
  183. package/src/doc/validate.ts +476 -0
  184. package/src/generate/slideshowGenerator.ts +7 -0
  185. package/src/icons/index.ts +8 -0
  186. package/src/icons/inlineIconMarker.ts +73 -0
  187. package/src/imageEdit/export.ts +85 -2
  188. package/src/imageEdit/index.ts +1 -0
  189. package/src/imageEdit/persistence.ts +51 -0
  190. package/src/index.ts +2 -0
  191. package/src/markdown/annotationCoercion.ts +295 -0
  192. package/src/markdown/attrTokens.ts +222 -0
  193. package/src/markdown/convert.ts +229 -26
  194. package/src/markdown/index.ts +36 -0
  195. package/src/markdown/sanitize.ts +298 -0
  196. package/src/markdown/stringify.ts +84 -3
  197. package/src/markdown/types.ts +66 -0
  198. package/src/markdown/utils.ts +49 -1
  199. package/src/recommend/templates.ts +24 -0
  200. package/src/schemas/BlockTemplates.ts +133 -4
  201. package/src/schemas/CustomTemplates.ts +74 -0
  202. package/src/schemas/Doc.ts +353 -29
  203. package/src/schemas/ImageEditDoc.ts +11 -4
  204. package/src/schemas/Media.ts +169 -0
  205. package/src/schemas/Theme.ts +23 -1
  206. package/src/schemas/Transitions.ts +224 -0
  207. package/src/schemas/colorUtils.ts +33 -0
  208. package/src/schemas/fontStacks.ts +5 -2
  209. package/src/schemas/index.ts +3 -0
  210. package/src/schemas/themeCompile.ts +23 -4
  211. package/src/schemas/themeValidator.ts +49 -11
  212. package/src/schemas/themes/cinematic.json +69 -12
  213. package/src/schemas/themes/documentary.json +58 -11
  214. package/src/schemas/themes/gezellig.json +60 -11
  215. package/src/schemas/themes/magazine.json +54 -9
  216. package/src/schemas/themes/morning-light.json +52 -9
  217. package/src/schemas/themes/standard-dark.json +48 -13
  218. package/src/schemas/themes/standard.json +44 -12
  219. package/src/schemas/themes/tech-dark.json +65 -12
  220. package/src/spatial/Geohash.ts +52 -21
  221. package/src/transform/applyTransform.ts +43 -4
  222. package/src/transform/index.ts +1 -0
  223. package/src/transform/registry.ts +44 -13
  224. package/src/transform/styles/dataDriven.ts +2 -1
  225. package/src/transform/styles/documentary.ts +2 -1
  226. package/src/transform/styles/magazine.ts +3 -1
  227. package/src/transform/styles/minimal.ts +2 -1
  228. package/src/transform/styles/narrative.ts +3 -1
  229. package/src/transform/templateSelector.ts +87 -11
  230. package/src/transform/types.ts +35 -2
  231. package/dist/__tests__/animationUtils.test.d.ts +0 -2
  232. package/dist/__tests__/animationUtils.test.d.ts.map +0 -1
  233. package/dist/__tests__/animationUtils.test.js +0 -60
  234. package/dist/__tests__/animationUtils.test.js.map +0 -1
  235. package/dist/__tests__/colorUtils.test.d.ts +0 -2
  236. package/dist/__tests__/colorUtils.test.d.ts.map +0 -1
  237. package/dist/__tests__/colorUtils.test.js +0 -94
  238. package/dist/__tests__/colorUtils.test.js.map +0 -1
  239. package/dist/__tests__/contentContainer.test.d.ts +0 -2
  240. package/dist/__tests__/contentContainer.test.d.ts.map +0 -1
  241. package/dist/__tests__/contentContainer.test.js +0 -234
  242. package/dist/__tests__/contentContainer.test.js.map +0 -1
  243. package/dist/__tests__/contentExtractor.test.d.ts +0 -2
  244. package/dist/__tests__/contentExtractor.test.d.ts.map +0 -1
  245. package/dist/__tests__/contentExtractor.test.js +0 -151
  246. package/dist/__tests__/contentExtractor.test.js.map +0 -1
  247. package/dist/__tests__/coverBlock.test.d.ts +0 -2
  248. package/dist/__tests__/coverBlock.test.d.ts.map +0 -1
  249. package/dist/__tests__/coverBlock.test.js +0 -197
  250. package/dist/__tests__/coverBlock.test.js.map +0 -1
  251. package/dist/__tests__/dataTable.test.d.ts +0 -2
  252. package/dist/__tests__/dataTable.test.d.ts.map +0 -1
  253. package/dist/__tests__/dataTable.test.js +0 -110
  254. package/dist/__tests__/dataTable.test.js.map +0 -1
  255. package/dist/__tests__/geohash.test.d.ts +0 -2
  256. package/dist/__tests__/geohash.test.d.ts.map +0 -1
  257. package/dist/__tests__/geohash.test.js +0 -87
  258. package/dist/__tests__/geohash.test.js.map +0 -1
  259. package/dist/__tests__/getLayers.test.d.ts +0 -2
  260. package/dist/__tests__/getLayers.test.d.ts.map +0 -1
  261. package/dist/__tests__/getLayers.test.js +0 -191
  262. package/dist/__tests__/getLayers.test.js.map +0 -1
  263. package/dist/__tests__/haversine.test.d.ts +0 -2
  264. package/dist/__tests__/haversine.test.d.ts.map +0 -1
  265. package/dist/__tests__/haversine.test.js +0 -56
  266. package/dist/__tests__/haversine.test.js.map +0 -1
  267. package/dist/__tests__/iconResolve.test.d.ts +0 -2
  268. package/dist/__tests__/iconResolve.test.d.ts.map +0 -1
  269. package/dist/__tests__/iconResolve.test.js +0 -99
  270. package/dist/__tests__/iconResolve.test.js.map +0 -1
  271. package/dist/__tests__/imageEditState.test.d.ts +0 -2
  272. package/dist/__tests__/imageEditState.test.d.ts.map +0 -1
  273. package/dist/__tests__/imageEditState.test.js +0 -61
  274. package/dist/__tests__/imageEditState.test.js.map +0 -1
  275. package/dist/__tests__/imageEditVersions.test.d.ts +0 -2
  276. package/dist/__tests__/imageEditVersions.test.d.ts.map +0 -1
  277. package/dist/__tests__/imageEditVersions.test.js +0 -141
  278. package/dist/__tests__/imageEditVersions.test.js.map +0 -1
  279. package/dist/__tests__/inferDocumentTitle.test.d.ts +0 -2
  280. package/dist/__tests__/inferDocumentTitle.test.d.ts.map +0 -1
  281. package/dist/__tests__/inferDocumentTitle.test.js +0 -42
  282. package/dist/__tests__/inferDocumentTitle.test.js.map +0 -1
  283. package/dist/__tests__/jsonForm.chooseControl.test.d.ts +0 -2
  284. package/dist/__tests__/jsonForm.chooseControl.test.d.ts.map +0 -1
  285. package/dist/__tests__/jsonForm.chooseControl.test.js +0 -74
  286. package/dist/__tests__/jsonForm.chooseControl.test.js.map +0 -1
  287. package/dist/__tests__/jsonForm.evaluateWhen.test.d.ts +0 -2
  288. package/dist/__tests__/jsonForm.evaluateWhen.test.d.ts.map +0 -1
  289. package/dist/__tests__/jsonForm.evaluateWhen.test.js +0 -51
  290. package/dist/__tests__/jsonForm.evaluateWhen.test.js.map +0 -1
  291. package/dist/__tests__/jsonForm.inferSchema.test.d.ts +0 -2
  292. package/dist/__tests__/jsonForm.inferSchema.test.d.ts.map +0 -1
  293. package/dist/__tests__/jsonForm.inferSchema.test.js +0 -23
  294. package/dist/__tests__/jsonForm.inferSchema.test.js.map +0 -1
  295. package/dist/__tests__/jsonForm.pointer.test.d.ts +0 -2
  296. package/dist/__tests__/jsonForm.pointer.test.d.ts.map +0 -1
  297. package/dist/__tests__/jsonForm.pointer.test.js +0 -94
  298. package/dist/__tests__/jsonForm.pointer.test.js.map +0 -1
  299. package/dist/__tests__/localForageAdapter.test.d.ts +0 -8
  300. package/dist/__tests__/localForageAdapter.test.d.ts.map +0 -1
  301. package/dist/__tests__/localForageAdapter.test.js +0 -130
  302. package/dist/__tests__/localForageAdapter.test.js.map +0 -1
  303. package/dist/__tests__/markdown.test.d.ts +0 -2
  304. package/dist/__tests__/markdown.test.d.ts.map +0 -1
  305. package/dist/__tests__/markdown.test.js +0 -715
  306. package/dist/__tests__/markdown.test.js.map +0 -1
  307. package/dist/__tests__/markdownIcons.test.d.ts +0 -2
  308. package/dist/__tests__/markdownIcons.test.d.ts.map +0 -1
  309. package/dist/__tests__/markdownIcons.test.js +0 -93
  310. package/dist/__tests__/markdownIcons.test.js.map +0 -1
  311. package/dist/__tests__/markdownToDoc.test.d.ts +0 -2
  312. package/dist/__tests__/markdownToDoc.test.d.ts.map +0 -1
  313. package/dist/__tests__/markdownToDoc.test.js +0 -458
  314. package/dist/__tests__/markdownToDoc.test.js.map +0 -1
  315. package/dist/__tests__/recommendTemplates.test.d.ts +0 -2
  316. package/dist/__tests__/recommendTemplates.test.d.ts.map +0 -1
  317. package/dist/__tests__/recommendTemplates.test.js +0 -158
  318. package/dist/__tests__/recommendTemplates.test.js.map +0 -1
  319. package/dist/__tests__/scopedContentContainer.test.d.ts +0 -2
  320. package/dist/__tests__/scopedContentContainer.test.d.ts.map +0 -1
  321. package/dist/__tests__/scopedContentContainer.test.js +0 -74
  322. package/dist/__tests__/scopedContentContainer.test.js.map +0 -1
  323. package/dist/__tests__/seededRandom.test.d.ts +0 -2
  324. package/dist/__tests__/seededRandom.test.d.ts.map +0 -1
  325. package/dist/__tests__/seededRandom.test.js +0 -125
  326. package/dist/__tests__/seededRandom.test.js.map +0 -1
  327. package/dist/__tests__/slideshowGenerator.test.d.ts +0 -2
  328. package/dist/__tests__/slideshowGenerator.test.d.ts.map +0 -1
  329. package/dist/__tests__/slideshowGenerator.test.js +0 -114
  330. package/dist/__tests__/slideshowGenerator.test.js.map +0 -1
  331. package/dist/__tests__/storage.test.d.ts +0 -2
  332. package/dist/__tests__/storage.test.d.ts.map +0 -1
  333. package/dist/__tests__/storage.test.js +0 -51
  334. package/dist/__tests__/storage.test.js.map +0 -1
  335. package/dist/__tests__/surface.test.d.ts +0 -2
  336. package/dist/__tests__/surface.test.d.ts.map +0 -1
  337. package/dist/__tests__/surface.test.js +0 -57
  338. package/dist/__tests__/surface.test.js.map +0 -1
  339. package/dist/__tests__/templateAnnotationParse.test.d.ts +0 -2
  340. package/dist/__tests__/templateAnnotationParse.test.d.ts.map +0 -1
  341. package/dist/__tests__/templateAnnotationParse.test.js +0 -42
  342. package/dist/__tests__/templateAnnotationParse.test.js.map +0 -1
  343. package/dist/__tests__/templates.test.d.ts +0 -2
  344. package/dist/__tests__/templates.test.d.ts.map +0 -1
  345. package/dist/__tests__/templates.test.js +0 -298
  346. package/dist/__tests__/templates.test.js.map +0 -1
  347. package/dist/__tests__/themeCompile.test.d.ts +0 -2
  348. package/dist/__tests__/themeCompile.test.d.ts.map +0 -1
  349. package/dist/__tests__/themeCompile.test.js +0 -134
  350. package/dist/__tests__/themeCompile.test.js.map +0 -1
  351. package/dist/__tests__/themeValidator.test.d.ts +0 -2
  352. package/dist/__tests__/themeValidator.test.d.ts.map +0 -1
  353. package/dist/__tests__/themeValidator.test.js +0 -107
  354. package/dist/__tests__/themeValidator.test.js.map +0 -1
  355. package/dist/__tests__/timing.test.d.ts +0 -2
  356. package/dist/__tests__/timing.test.d.ts.map +0 -1
  357. package/dist/__tests__/timing.test.js +0 -131
  358. package/dist/__tests__/timing.test.js.map +0 -1
  359. package/dist/__tests__/versions.test.d.ts +0 -2
  360. package/dist/__tests__/versions.test.d.ts.map +0 -1
  361. package/dist/__tests__/versions.test.js +0 -339
  362. package/dist/__tests__/versions.test.js.map +0 -1
  363. package/dist/chunk-3K5OG6KI.js.map +0 -1
  364. package/dist/chunk-57CVQCFX.js.map +0 -1
  365. package/dist/chunk-5WFRKURX.js.map +0 -1
  366. package/dist/chunk-7UDSRZKG.js.map +0 -1
  367. package/dist/chunk-B4EEON3N.js.map +0 -1
  368. package/dist/chunk-H3AXU4MJ.js.map +0 -1
  369. package/dist/chunk-KSWJR66U.js +0 -3706
  370. package/dist/chunk-KSWJR66U.js.map +0 -1
  371. package/dist/chunk-MYIH7FWD.js.map +0 -1
  372. package/dist/chunk-ZTX4PFFT.js.map +0 -1
  373. package/dist/doc/audioMapping.d.ts +0 -36
  374. package/dist/doc/audioMapping.d.ts.map +0 -1
  375. package/dist/doc/audioMapping.js +0 -350
  376. package/dist/doc/audioMapping.js.map +0 -1
  377. package/dist/doc/docToMarkdown.d.ts +0 -41
  378. package/dist/doc/docToMarkdown.d.ts.map +0 -1
  379. package/dist/doc/docToMarkdown.js +0 -88
  380. package/dist/doc/docToMarkdown.js.map +0 -1
  381. package/dist/doc/getLayers.d.ts +0 -65
  382. package/dist/doc/getLayers.d.ts.map +0 -1
  383. package/dist/doc/getLayers.js +0 -114
  384. package/dist/doc/getLayers.js.map +0 -1
  385. package/dist/doc/index.d.ts.map +0 -1
  386. package/dist/doc/markdownToDoc.d.ts +0 -75
  387. package/dist/doc/markdownToDoc.d.ts.map +0 -1
  388. package/dist/doc/markdownToDoc.js +0 -432
  389. package/dist/doc/markdownToDoc.js.map +0 -1
  390. package/dist/doc/templates/accentImage.d.ts +0 -59
  391. package/dist/doc/templates/accentImage.d.ts.map +0 -1
  392. package/dist/doc/templates/accentImage.js +0 -275
  393. package/dist/doc/templates/accentImage.js.map +0 -1
  394. package/dist/doc/templates/captionUtils.d.ts +0 -20
  395. package/dist/doc/templates/captionUtils.d.ts.map +0 -1
  396. package/dist/doc/templates/captionUtils.js +0 -29
  397. package/dist/doc/templates/captionUtils.js.map +0 -1
  398. package/dist/doc/templates/comparisonBar.d.ts +0 -13
  399. package/dist/doc/templates/comparisonBar.d.ts.map +0 -1
  400. package/dist/doc/templates/comparisonBar.js +0 -145
  401. package/dist/doc/templates/comparisonBar.js.map +0 -1
  402. package/dist/doc/templates/coverBlock.d.ts +0 -51
  403. package/dist/doc/templates/coverBlock.d.ts.map +0 -1
  404. package/dist/doc/templates/coverBlock.js +0 -153
  405. package/dist/doc/templates/coverBlock.js.map +0 -1
  406. package/dist/doc/templates/dataTable.d.ts +0 -14
  407. package/dist/doc/templates/dataTable.d.ts.map +0 -1
  408. package/dist/doc/templates/dataTable.js +0 -73
  409. package/dist/doc/templates/dataTable.js.map +0 -1
  410. package/dist/doc/templates/dateEvent.d.ts +0 -15
  411. package/dist/doc/templates/dateEvent.d.ts.map +0 -1
  412. package/dist/doc/templates/dateEvent.js +0 -114
  413. package/dist/doc/templates/dateEvent.js.map +0 -1
  414. package/dist/doc/templates/definitionCard.d.ts +0 -13
  415. package/dist/doc/templates/definitionCard.d.ts.map +0 -1
  416. package/dist/doc/templates/definitionCard.js +0 -117
  417. package/dist/doc/templates/definitionCard.js.map +0 -1
  418. package/dist/doc/templates/factCard.d.ts +0 -15
  419. package/dist/doc/templates/factCard.d.ts.map +0 -1
  420. package/dist/doc/templates/factCard.js +0 -104
  421. package/dist/doc/templates/factCard.js.map +0 -1
  422. package/dist/doc/templates/featureBlock.d.ts +0 -18
  423. package/dist/doc/templates/featureBlock.d.ts.map +0 -1
  424. package/dist/doc/templates/featureBlock.js +0 -180
  425. package/dist/doc/templates/featureBlock.js.map +0 -1
  426. package/dist/doc/templates/fullBleedQuote.d.ts +0 -25
  427. package/dist/doc/templates/fullBleedQuote.d.ts.map +0 -1
  428. package/dist/doc/templates/fullBleedQuote.js +0 -67
  429. package/dist/doc/templates/fullBleedQuote.js.map +0 -1
  430. package/dist/doc/templates/imageWithCaption.d.ts +0 -13
  431. package/dist/doc/templates/imageWithCaption.d.ts.map +0 -1
  432. package/dist/doc/templates/imageWithCaption.js +0 -146
  433. package/dist/doc/templates/imageWithCaption.js.map +0 -1
  434. package/dist/doc/templates/index.d.ts +0 -129
  435. package/dist/doc/templates/index.d.ts.map +0 -1
  436. package/dist/doc/templates/index.js +0 -478
  437. package/dist/doc/templates/index.js.map +0 -1
  438. package/dist/doc/templates/listBlock.d.ts +0 -13
  439. package/dist/doc/templates/listBlock.d.ts.map +0 -1
  440. package/dist/doc/templates/listBlock.js +0 -109
  441. package/dist/doc/templates/listBlock.js.map +0 -1
  442. package/dist/doc/templates/mapBlock.d.ts +0 -17
  443. package/dist/doc/templates/mapBlock.d.ts.map +0 -1
  444. package/dist/doc/templates/mapBlock.js +0 -115
  445. package/dist/doc/templates/mapBlock.js.map +0 -1
  446. package/dist/doc/templates/persistentLayers.d.ts +0 -39
  447. package/dist/doc/templates/persistentLayers.d.ts.map +0 -1
  448. package/dist/doc/templates/persistentLayers.js +0 -447
  449. package/dist/doc/templates/persistentLayers.js.map +0 -1
  450. package/dist/doc/templates/photoGrid.d.ts +0 -20
  451. package/dist/doc/templates/photoGrid.d.ts.map +0 -1
  452. package/dist/doc/templates/photoGrid.js +0 -175
  453. package/dist/doc/templates/photoGrid.js.map +0 -1
  454. package/dist/doc/templates/pullQuote.d.ts +0 -13
  455. package/dist/doc/templates/pullQuote.d.ts.map +0 -1
  456. package/dist/doc/templates/pullQuote.js +0 -113
  457. package/dist/doc/templates/pullQuote.js.map +0 -1
  458. package/dist/doc/templates/quoteBlock.d.ts +0 -15
  459. package/dist/doc/templates/quoteBlock.d.ts.map +0 -1
  460. package/dist/doc/templates/quoteBlock.js +0 -101
  461. package/dist/doc/templates/quoteBlock.js.map +0 -1
  462. package/dist/doc/templates/sectionHeader.d.ts +0 -14
  463. package/dist/doc/templates/sectionHeader.d.ts.map +0 -1
  464. package/dist/doc/templates/sectionHeader.js +0 -97
  465. package/dist/doc/templates/sectionHeader.js.map +0 -1
  466. package/dist/doc/templates/statHighlight.d.ts +0 -27
  467. package/dist/doc/templates/statHighlight.d.ts.map +0 -1
  468. package/dist/doc/templates/statHighlight.js +0 -114
  469. package/dist/doc/templates/statHighlight.js.map +0 -1
  470. package/dist/doc/templates/titleBlock.d.ts +0 -24
  471. package/dist/doc/templates/titleBlock.d.ts.map +0 -1
  472. package/dist/doc/templates/titleBlock.js +0 -103
  473. package/dist/doc/templates/titleBlock.js.map +0 -1
  474. package/dist/doc/templates/twoColumn.d.ts +0 -15
  475. package/dist/doc/templates/twoColumn.d.ts.map +0 -1
  476. package/dist/doc/templates/twoColumn.js +0 -225
  477. package/dist/doc/templates/twoColumn.js.map +0 -1
  478. package/dist/doc/templates/videoPullQuote.d.ts +0 -20
  479. package/dist/doc/templates/videoPullQuote.d.ts.map +0 -1
  480. package/dist/doc/templates/videoPullQuote.js +0 -122
  481. package/dist/doc/templates/videoPullQuote.js.map +0 -1
  482. package/dist/doc/templates/videoWithCaption.d.ts +0 -20
  483. package/dist/doc/templates/videoWithCaption.d.ts.map +0 -1
  484. package/dist/doc/templates/videoWithCaption.js +0 -107
  485. package/dist/doc/templates/videoWithCaption.js.map +0 -1
  486. package/dist/doc/utils/animationUtils.d.ts +0 -34
  487. package/dist/doc/utils/animationUtils.d.ts.map +0 -1
  488. package/dist/doc/utils/animationUtils.js +0 -110
  489. package/dist/doc/utils/animationUtils.js.map +0 -1
  490. package/dist/doc/utils/themeUtils.d.ts +0 -64
  491. package/dist/doc/utils/themeUtils.d.ts.map +0 -1
  492. package/dist/doc/utils/themeUtils.js +0 -136
  493. package/dist/doc/utils/themeUtils.js.map +0 -1
  494. package/dist/generate/contentExtractor.d.ts +0 -112
  495. package/dist/generate/contentExtractor.d.ts.map +0 -1
  496. package/dist/generate/contentExtractor.js +0 -638
  497. package/dist/generate/contentExtractor.js.map +0 -1
  498. package/dist/generate/index.d.ts.map +0 -1
  499. package/dist/generate/slideshowGenerator.d.ts +0 -72
  500. package/dist/generate/slideshowGenerator.d.ts.map +0 -1
  501. package/dist/generate/slideshowGenerator.js +0 -159
  502. package/dist/generate/slideshowGenerator.js.map +0 -1
  503. package/dist/generate/templateMapper.d.ts +0 -23
  504. package/dist/generate/templateMapper.d.ts.map +0 -1
  505. package/dist/generate/templateMapper.js +0 -114
  506. package/dist/generate/templateMapper.js.map +0 -1
  507. package/dist/icons/iconData.d.ts +0 -26
  508. package/dist/icons/iconData.d.ts.map +0 -1
  509. package/dist/icons/iconData.js +0 -12
  510. package/dist/icons/iconData.js.map +0 -1
  511. package/dist/icons/index.d.ts.map +0 -1
  512. package/dist/icons/resolve.d.ts +0 -61
  513. package/dist/icons/resolve.d.ts.map +0 -1
  514. package/dist/icons/resolve.js +0 -130
  515. package/dist/icons/resolve.js.map +0 -1
  516. package/dist/imageEdit/ImageEditVersionManager.d.ts +0 -31
  517. package/dist/imageEdit/ImageEditVersionManager.d.ts.map +0 -1
  518. package/dist/imageEdit/ImageEditVersionManager.js +0 -39
  519. package/dist/imageEdit/ImageEditVersionManager.js.map +0 -1
  520. package/dist/imageEdit/export.d.ts +0 -33
  521. package/dist/imageEdit/export.d.ts.map +0 -1
  522. package/dist/imageEdit/export.js +0 -253
  523. package/dist/imageEdit/export.js.map +0 -1
  524. package/dist/imageEdit/index.d.ts.map +0 -1
  525. package/dist/imageEdit/persistence.d.ts +0 -15
  526. package/dist/imageEdit/persistence.d.ts.map +0 -1
  527. package/dist/imageEdit/persistence.js +0 -49
  528. package/dist/imageEdit/persistence.js.map +0 -1
  529. package/dist/imageEdit/state.d.ts +0 -42
  530. package/dist/imageEdit/state.d.ts.map +0 -1
  531. package/dist/imageEdit/state.js +0 -98
  532. package/dist/imageEdit/state.js.map +0 -1
  533. package/dist/imageEdit/versionPaths.d.ts +0 -27
  534. package/dist/imageEdit/versionPaths.d.ts.map +0 -1
  535. package/dist/imageEdit/versionPaths.js +0 -57
  536. package/dist/imageEdit/versionPaths.js.map +0 -1
  537. package/dist/imageEdit/versions.d.ts +0 -67
  538. package/dist/imageEdit/versions.d.ts.map +0 -1
  539. package/dist/imageEdit/versions.js +0 -161
  540. package/dist/imageEdit/versions.js.map +0 -1
  541. package/dist/index.d.ts.map +0 -1
  542. package/dist/jsonForm/chooseControl.d.ts +0 -20
  543. package/dist/jsonForm/chooseControl.d.ts.map +0 -1
  544. package/dist/jsonForm/chooseControl.js +0 -82
  545. package/dist/jsonForm/chooseControl.js.map +0 -1
  546. package/dist/jsonForm/evaluateWhen.d.ts +0 -12
  547. package/dist/jsonForm/evaluateWhen.d.ts.map +0 -1
  548. package/dist/jsonForm/evaluateWhen.js +0 -65
  549. package/dist/jsonForm/evaluateWhen.js.map +0 -1
  550. package/dist/jsonForm/index.d.ts.map +0 -1
  551. package/dist/jsonForm/inferSchema.d.ts +0 -12
  552. package/dist/jsonForm/inferSchema.d.ts.map +0 -1
  553. package/dist/jsonForm/inferSchema.js +0 -15
  554. package/dist/jsonForm/inferSchema.js.map +0 -1
  555. package/dist/jsonForm/pointer.d.ts +0 -26
  556. package/dist/jsonForm/pointer.d.ts.map +0 -1
  557. package/dist/jsonForm/pointer.js +0 -102
  558. package/dist/jsonForm/pointer.js.map +0 -1
  559. package/dist/jsonForm/types.d.ts +0 -120
  560. package/dist/jsonForm/types.d.ts.map +0 -1
  561. package/dist/jsonForm/types.js +0 -10
  562. package/dist/jsonForm/types.js.map +0 -1
  563. package/dist/markdown/convert.d.ts +0 -81
  564. package/dist/markdown/convert.d.ts.map +0 -1
  565. package/dist/markdown/convert.js +0 -975
  566. package/dist/markdown/convert.js.map +0 -1
  567. package/dist/markdown/htmlParse.d.ts +0 -26
  568. package/dist/markdown/htmlParse.d.ts.map +0 -1
  569. package/dist/markdown/htmlParse.js +0 -195
  570. package/dist/markdown/htmlParse.js.map +0 -1
  571. package/dist/markdown/index.d.ts.map +0 -1
  572. package/dist/markdown/parse.d.ts +0 -27
  573. package/dist/markdown/parse.d.ts.map +0 -1
  574. package/dist/markdown/parse.js +0 -90
  575. package/dist/markdown/parse.js.map +0 -1
  576. package/dist/markdown/stringify.d.ts +0 -32
  577. package/dist/markdown/stringify.d.ts.map +0 -1
  578. package/dist/markdown/stringify.js +0 -108
  579. package/dist/markdown/stringify.js.map +0 -1
  580. package/dist/markdown/types.d.ts +0 -531
  581. package/dist/markdown/types.d.ts.map +0 -1
  582. package/dist/markdown/types.js +0 -17
  583. package/dist/markdown/types.js.map +0 -1
  584. package/dist/markdown/utils.d.ts +0 -118
  585. package/dist/markdown/utils.d.ts.map +0 -1
  586. package/dist/markdown/utils.js +0 -308
  587. package/dist/markdown/utils.js.map +0 -1
  588. package/dist/random/SeededRandom.d.ts +0 -50
  589. package/dist/random/SeededRandom.d.ts.map +0 -1
  590. package/dist/random/SeededRandom.js +0 -115
  591. package/dist/random/SeededRandom.js.map +0 -1
  592. package/dist/random/index.d.ts.map +0 -1
  593. package/dist/recommend/index.d.ts.map +0 -1
  594. package/dist/recommend/templates.d.ts +0 -39
  595. package/dist/recommend/templates.d.ts.map +0 -1
  596. package/dist/recommend/templates.js +0 -235
  597. package/dist/recommend/templates.js.map +0 -1
  598. package/dist/schemas/BlockTemplates.d.ts +0 -638
  599. package/dist/schemas/BlockTemplates.d.ts.map +0 -1
  600. package/dist/schemas/BlockTemplates.js +0 -72
  601. package/dist/schemas/BlockTemplates.js.map +0 -1
  602. package/dist/schemas/Doc.d.ts +0 -503
  603. package/dist/schemas/Doc.d.ts.map +0 -1
  604. package/dist/schemas/Doc.js +0 -90
  605. package/dist/schemas/Doc.js.map +0 -1
  606. package/dist/schemas/ImageEditDoc.d.ts +0 -81
  607. package/dist/schemas/ImageEditDoc.d.ts.map +0 -1
  608. package/dist/schemas/ImageEditDoc.js +0 -20
  609. package/dist/schemas/ImageEditDoc.js.map +0 -1
  610. package/dist/schemas/LayoutStrategy.d.ts +0 -84
  611. package/dist/schemas/LayoutStrategy.d.ts.map +0 -1
  612. package/dist/schemas/LayoutStrategy.js +0 -123
  613. package/dist/schemas/LayoutStrategy.js.map +0 -1
  614. package/dist/schemas/MediaProvider.d.ts +0 -65
  615. package/dist/schemas/MediaProvider.d.ts.map +0 -1
  616. package/dist/schemas/MediaProvider.js +0 -13
  617. package/dist/schemas/MediaProvider.js.map +0 -1
  618. package/dist/schemas/Theme.d.ts +0 -233
  619. package/dist/schemas/Theme.d.ts.map +0 -1
  620. package/dist/schemas/Theme.js +0 -129
  621. package/dist/schemas/Theme.js.map +0 -1
  622. package/dist/schemas/Types.d.ts +0 -14
  623. package/dist/schemas/Types.d.ts.map +0 -1
  624. package/dist/schemas/Types.js +0 -5
  625. package/dist/schemas/Types.js.map +0 -1
  626. package/dist/schemas/Viewport.d.ts +0 -74
  627. package/dist/schemas/Viewport.d.ts.map +0 -1
  628. package/dist/schemas/Viewport.js +0 -63
  629. package/dist/schemas/Viewport.js.map +0 -1
  630. package/dist/schemas/colorUtils.d.ts +0 -51
  631. package/dist/schemas/colorUtils.d.ts.map +0 -1
  632. package/dist/schemas/colorUtils.js +0 -154
  633. package/dist/schemas/colorUtils.js.map +0 -1
  634. package/dist/schemas/fontStacks.d.ts +0 -57
  635. package/dist/schemas/fontStacks.d.ts.map +0 -1
  636. package/dist/schemas/fontStacks.js +0 -227
  637. package/dist/schemas/fontStacks.js.map +0 -1
  638. package/dist/schemas/index.d.ts.map +0 -1
  639. package/dist/schemas/themeCompile.d.ts +0 -45
  640. package/dist/schemas/themeCompile.d.ts.map +0 -1
  641. package/dist/schemas/themeCompile.js +0 -160
  642. package/dist/schemas/themeCompile.js.map +0 -1
  643. package/dist/schemas/themeLibrary.d.ts +0 -37
  644. package/dist/schemas/themeLibrary.d.ts.map +0 -1
  645. package/dist/schemas/themeLibrary.js +0 -49
  646. package/dist/schemas/themeLibrary.js.map +0 -1
  647. package/dist/schemas/themeValidator.d.ts +0 -26
  648. package/dist/schemas/themeValidator.d.ts.map +0 -1
  649. package/dist/schemas/themeValidator.js +0 -352
  650. package/dist/schemas/themeValidator.js.map +0 -1
  651. package/dist/schemas/themes/bold.json +0 -48
  652. package/dist/schemas/themes/cinematic.json +0 -54
  653. package/dist/schemas/themes/documentary.json +0 -49
  654. package/dist/schemas/themes/gezellig.json +0 -44
  655. package/dist/schemas/themes/index.d.ts +0 -26
  656. package/dist/schemas/themes/index.d.ts.map +0 -1
  657. package/dist/schemas/themes/index.js +0 -49
  658. package/dist/schemas/themes/index.js.map +0 -1
  659. package/dist/schemas/themes/magazine.json +0 -44
  660. package/dist/schemas/themes/minimalist.json +0 -45
  661. package/dist/schemas/themes/morning-light.json +0 -42
  662. package/dist/schemas/themes/standard-dark.json +0 -50
  663. package/dist/schemas/themes/standard.json +0 -42
  664. package/dist/schemas/themes/tech-dark.json +0 -48
  665. package/dist/schemas/themes/warm-earth.json +0 -50
  666. package/dist/spatial/Geohash.d.ts +0 -85
  667. package/dist/spatial/Geohash.d.ts.map +0 -1
  668. package/dist/spatial/Geohash.js +0 -142
  669. package/dist/spatial/Geohash.js.map +0 -1
  670. package/dist/spatial/Haversine.d.ts +0 -24
  671. package/dist/spatial/Haversine.d.ts.map +0 -1
  672. package/dist/spatial/Haversine.js +0 -48
  673. package/dist/spatial/Haversine.js.map +0 -1
  674. package/dist/spatial/index.d.ts.map +0 -1
  675. package/dist/storage/ContentContainer.d.ts +0 -87
  676. package/dist/storage/ContentContainer.d.ts.map +0 -1
  677. package/dist/storage/ContentContainer.js +0 -131
  678. package/dist/storage/ContentContainer.js.map +0 -1
  679. package/dist/storage/LocalForageAdapter.d.ts +0 -36
  680. package/dist/storage/LocalForageAdapter.d.ts.map +0 -1
  681. package/dist/storage/LocalForageAdapter.js +0 -82
  682. package/dist/storage/LocalForageAdapter.js.map +0 -1
  683. package/dist/storage/LocalStorageAdapter.d.ts +0 -16
  684. package/dist/storage/LocalStorageAdapter.d.ts.map +0 -1
  685. package/dist/storage/LocalStorageAdapter.js +0 -50
  686. package/dist/storage/LocalStorageAdapter.js.map +0 -1
  687. package/dist/storage/MediaProviderFromContainer.d.ts +0 -21
  688. package/dist/storage/MediaProviderFromContainer.d.ts.map +0 -1
  689. package/dist/storage/MediaProviderFromContainer.js +0 -79
  690. package/dist/storage/MediaProviderFromContainer.js.map +0 -1
  691. package/dist/storage/MemoryStorageAdapter.d.ts +0 -15
  692. package/dist/storage/MemoryStorageAdapter.d.ts.map +0 -1
  693. package/dist/storage/MemoryStorageAdapter.js +0 -34
  694. package/dist/storage/MemoryStorageAdapter.js.map +0 -1
  695. package/dist/storage/ScopedContentContainer.d.ts +0 -44
  696. package/dist/storage/ScopedContentContainer.d.ts.map +0 -1
  697. package/dist/storage/ScopedContentContainer.js +0 -94
  698. package/dist/storage/ScopedContentContainer.js.map +0 -1
  699. package/dist/storage/Storage.d.ts +0 -23
  700. package/dist/storage/Storage.d.ts.map +0 -1
  701. package/dist/storage/Storage.js +0 -9
  702. package/dist/storage/Storage.js.map +0 -1
  703. package/dist/storage/index.d.ts.map +0 -1
  704. package/dist/timing/index.d.ts.map +0 -1
  705. package/dist/timing/narrationTiming.d.ts +0 -54
  706. package/dist/timing/narrationTiming.d.ts.map +0 -1
  707. package/dist/timing/narrationTiming.js +0 -190
  708. package/dist/timing/narrationTiming.js.map +0 -1
  709. package/dist/timing/readingTime.d.ts +0 -54
  710. package/dist/timing/readingTime.d.ts.map +0 -1
  711. package/dist/timing/readingTime.js +0 -49
  712. package/dist/timing/readingTime.js.map +0 -1
  713. package/dist/transform/applyTransform.d.ts +0 -22
  714. package/dist/transform/applyTransform.d.ts.map +0 -1
  715. package/dist/transform/applyTransform.js +0 -68
  716. package/dist/transform/applyTransform.js.map +0 -1
  717. package/dist/transform/blockAnalyzer.d.ts +0 -48
  718. package/dist/transform/blockAnalyzer.d.ts.map +0 -1
  719. package/dist/transform/blockAnalyzer.js +0 -135
  720. package/dist/transform/blockAnalyzer.js.map +0 -1
  721. package/dist/transform/index.d.ts.map +0 -1
  722. package/dist/transform/registry.d.ts +0 -19
  723. package/dist/transform/registry.d.ts.map +0 -1
  724. package/dist/transform/registry.js +0 -41
  725. package/dist/transform/registry.js.map +0 -1
  726. package/dist/transform/styles/dataDriven.d.ts +0 -4
  727. package/dist/transform/styles/dataDriven.d.ts.map +0 -1
  728. package/dist/transform/styles/dataDriven.js +0 -15
  729. package/dist/transform/styles/dataDriven.js.map +0 -1
  730. package/dist/transform/styles/documentary.d.ts +0 -4
  731. package/dist/transform/styles/documentary.d.ts.map +0 -1
  732. package/dist/transform/styles/documentary.js +0 -15
  733. package/dist/transform/styles/documentary.js.map +0 -1
  734. package/dist/transform/styles/index.d.ts +0 -6
  735. package/dist/transform/styles/index.d.ts.map +0 -1
  736. package/dist/transform/styles/index.js +0 -6
  737. package/dist/transform/styles/index.js.map +0 -1
  738. package/dist/transform/styles/magazine.d.ts +0 -4
  739. package/dist/transform/styles/magazine.d.ts.map +0 -1
  740. package/dist/transform/styles/magazine.js +0 -15
  741. package/dist/transform/styles/magazine.js.map +0 -1
  742. package/dist/transform/styles/minimal.d.ts +0 -4
  743. package/dist/transform/styles/minimal.d.ts.map +0 -1
  744. package/dist/transform/styles/minimal.js +0 -15
  745. package/dist/transform/styles/minimal.js.map +0 -1
  746. package/dist/transform/styles/narrative.d.ts +0 -4
  747. package/dist/transform/styles/narrative.d.ts.map +0 -1
  748. package/dist/transform/styles/narrative.js +0 -15
  749. package/dist/transform/styles/narrative.js.map +0 -1
  750. package/dist/transform/templateSelector.d.ts +0 -30
  751. package/dist/transform/templateSelector.d.ts.map +0 -1
  752. package/dist/transform/templateSelector.js +0 -218
  753. package/dist/transform/templateSelector.js.map +0 -1
  754. package/dist/transform/timingAllocator.d.ts +0 -21
  755. package/dist/transform/timingAllocator.d.ts.map +0 -1
  756. package/dist/transform/timingAllocator.js +0 -111
  757. package/dist/transform/timingAllocator.js.map +0 -1
  758. package/dist/transform/types.d.ts +0 -86
  759. package/dist/transform/types.d.ts.map +0 -1
  760. package/dist/transform/types.js +0 -9
  761. package/dist/transform/types.js.map +0 -1
  762. package/dist/versions/DocumentVersionManager.d.ts +0 -31
  763. package/dist/versions/DocumentVersionManager.d.ts.map +0 -1
  764. package/dist/versions/DocumentVersionManager.js +0 -33
  765. package/dist/versions/DocumentVersionManager.js.map +0 -1
  766. package/dist/versions/index.d.ts.map +0 -1
  767. package/dist/versions/operations.d.ts +0 -44
  768. package/dist/versions/operations.d.ts.map +0 -1
  769. package/dist/versions/operations.js +0 -190
  770. package/dist/versions/operations.js.map +0 -1
  771. package/dist/versions/paths.d.ts +0 -29
  772. package/dist/versions/paths.d.ts.map +0 -1
  773. package/dist/versions/paths.js +0 -66
  774. package/dist/versions/paths.js.map +0 -1
  775. package/dist/versions/timestamp.d.ts +0 -22
  776. package/dist/versions/timestamp.d.ts.map +0 -1
  777. package/dist/versions/timestamp.js +0 -44
  778. package/dist/versions/timestamp.js.map +0 -1
  779. package/dist/versions/types.d.ts +0 -92
  780. package/dist/versions/types.d.ts.map +0 -1
  781. package/dist/versions/types.js +0 -11
  782. package/dist/versions/types.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/markdown/annotationCoercion.ts","../src/markdown/attrTokens.ts","../src/markdown/convert.ts","../src/markdown/parse.ts"],"sourcesContent":["/**\n * Heading-attribute value coercion.\n *\n * The Pandoc-style heading attribute block `{#id .class key=value}` parses\n * to a flat `Record<string, string>` of `key → raw value`. This module\n * coerces a known subset of keys to typed values (numbers, time-in-seconds,\n * `BlockConnection[]`) so downstream consumers don't have to re-parse them.\n *\n * Unknown keys are returned in `metadata` as raw strings. Malformed known-key\n * values are dropped from the typed result and reported via `warnings` (the\n * raw string is preserved in `params` upstream for lossless round-tripping —\n * coercion failures do not corrupt the source).\n */\n\nimport type { BlockConnection } from './types.js';\nimport type { TransitionDirection, TransitionType } from '../schemas/Transitions.js';\nimport {\n normalizeTransitionDirection,\n normalizeTransitionType,\n TRANSITION_TYPES,\n TRANSITION_DIRECTIONS,\n} from '../schemas/Transitions.js';\n\n/**\n * Registry of known block-meta keys and their coercion strategies.\n *\n * Adding a new typed key: add an entry here, add the typed field to\n * `HeadingAttributes.blockMeta` in `types.ts`, and apply the coerced value\n * in `markdownToDoc.ts`.\n */\nexport const KNOWN_BLOCK_META_KEYS = {\n x: 'number',\n y: 'number',\n startTime: 'time',\n duration: 'time',\n connectsTo: 'connectionList',\n transition: 'transition',\n transitionDuration: 'time',\n transitionDirection: 'transitionDirection',\n} as const;\n\nexport type KnownBlockMetaKey = keyof typeof KNOWN_BLOCK_META_KEYS;\n\n/**\n * Editor-facing description of a known block-meta key: what it does, and\n * either its closed set of valid values or a free-form format hint. This is\n * the single source the markdown editor's `{[name key=value]}` attribute\n * autocomplete reads from, so the suggestion list stays in lockstep with\n * `KNOWN_BLOCK_META_KEYS` and the transition vocabulary rather than drifting\n * in a hand-maintained copy. `values`/`valueHint` are mutually exclusive: a\n * key has a closed enum (`values`) or a format hint (`valueHint`), not both.\n */\nexport interface BlockMetaKeyDescriptor {\n key: KnownBlockMetaKey;\n /** One-line description, shown as the completion item's detail. */\n description: string;\n /** Closed set of valid values, for keys backed by an enum. */\n values?: readonly string[];\n /** Format hint shown when the value is free-form (no closed set). */\n valueHint?: string;\n}\n\n/**\n * Ordered descriptors for every key in `KNOWN_BLOCK_META_KEYS`. Order is the\n * suggestion display order: the transition family first (the most common\n * authoring case), then timeline timing, then diagram geometry/links.\n */\nexport const BLOCK_META_KEY_DESCRIPTORS: readonly BlockMetaKeyDescriptor[] = [\n {\n key: 'transition',\n description: 'Block-to-block transition effect',\n values: TRANSITION_TYPES,\n },\n {\n key: 'transitionDuration',\n description: 'How long the transition lasts',\n valueHint: 'seconds — e.g. 0.7, 700ms',\n },\n {\n key: 'transitionDirection',\n description: 'Directional variant for the transition',\n values: TRANSITION_DIRECTIONS,\n },\n {\n key: 'startTime',\n description: 'Timeline start time of this block',\n valueHint: 'mm:ss or seconds — e.g. 01:30, 5, 1500ms',\n },\n {\n key: 'duration',\n description: 'How long this block lasts',\n valueHint: 'mm:ss or seconds — e.g. 45, 1500ms',\n },\n {\n key: 'x',\n description: 'Horizontal position on the diagram canvas',\n valueHint: 'number — e.g. 600',\n },\n {\n key: 'y',\n description: 'Vertical position on the diagram canvas',\n valueHint: 'number — e.g. 300',\n },\n {\n key: 'connectsTo',\n description: 'Diagram connections to other blocks',\n valueHint: 'comma-separated target or target:type — e.g. foo,bar:flow',\n },\n];\n\n/**\n * The shape of the typed values produced by coercion. Mirrors\n * `HeadingAttributes.blockMeta` in `types.ts`.\n */\nexport interface CoercedBlockMeta {\n x?: number;\n y?: number;\n startTime?: number;\n duration?: number;\n connectsTo?: BlockConnection[];\n transition?: {\n type: TransitionType;\n duration?: number;\n direction?: TransitionDirection;\n };\n}\n\nexport interface CoerceResult {\n /** Typed values for known keys whose coercion succeeded. */\n blockMeta: CoercedBlockMeta;\n /** Raw string values for keys not in the known-key registry. */\n metadata: Record<string, string>;\n /** Human-readable diagnostics — currently emitted for coercion failures. */\n warnings: string[];\n}\n\n/**\n * Coerce a flat `key → raw string` map into typed block-meta + an\n * untyped metadata bag, per the `KNOWN_BLOCK_META_KEYS` registry.\n */\nexport function coerceAnnotationValues(params: Record<string, string>): CoerceResult {\n const blockMeta: CoercedBlockMeta = {};\n const metadata: Record<string, string> = {};\n const warnings: string[] = [];\n let transitionType: TransitionType | null = null;\n let transitionDuration: number | undefined;\n let transitionDirection: TransitionDirection | undefined;\n\n for (const [key, raw] of Object.entries(params)) {\n const kind = (KNOWN_BLOCK_META_KEYS as Record<string, string>)[key];\n if (!kind) {\n metadata[key] = raw;\n continue;\n }\n if (kind === 'number') {\n const n = parseNumber(raw);\n if (n == null) {\n warnings.push(`Invalid number for \"${key}\": ${JSON.stringify(raw)}`);\n } else {\n (blockMeta as Record<string, unknown>)[key] = n;\n }\n } else if (kind === 'time') {\n const s = parseTimeSeconds(raw);\n if (s == null) {\n warnings.push(`Invalid time for \"${key}\": ${JSON.stringify(raw)}`);\n } else if (key === 'transitionDuration') {\n transitionDuration = s;\n } else {\n (blockMeta as Record<string, unknown>)[key] = s;\n }\n } else if (kind === 'connectionList') {\n const { list, warning } = parseConnectionList(raw);\n if (warning) warnings.push(`\"${key}\": ${warning}`);\n blockMeta.connectsTo = list;\n } else if (kind === 'transition') {\n const transition = normalizeTransitionType(raw);\n if (transition == null) {\n warnings.push(`Invalid transition for \"${key}\": ${JSON.stringify(raw)}`);\n } else {\n transitionType = transition;\n }\n } else if (kind === 'transitionDirection') {\n const direction = normalizeTransitionDirection(raw);\n if (direction == null) {\n warnings.push(`Invalid transition direction for \"${key}\": ${JSON.stringify(raw)}`);\n } else {\n transitionDirection = direction;\n }\n }\n }\n\n if (transitionType) {\n blockMeta.transition = {\n type: transitionType,\n ...(transitionDuration !== undefined ? { duration: transitionDuration } : {}),\n ...(transitionDirection !== undefined ? { direction: transitionDirection } : {}),\n };\n }\n\n return { blockMeta, metadata, warnings };\n}\n\n// ============================================\n// Coercers\n// ============================================\n\n/** Parse a finite number from a string. Returns null on failure. */\nfunction parseNumber(raw: string): number | null {\n if (raw.trim() === '') return null;\n const n = Number(raw);\n return Number.isFinite(n) ? n : null;\n}\n\nconst TIME_BARE_RE = /^\\d+(?:\\.\\d+)?$/;\nconst TIME_MS_RE = /^(\\d+(?:\\.\\d+)?)ms$/;\nconst TIME_MMSS_RE = /^(\\d+):(\\d{1,2})(?:\\.(\\d+))?$/;\n\n/**\n * Parse a time value to seconds. Accepts:\n * - bare number: `5` → 5, `5.5` → 5.5\n * - `mm:ss`: `01:30` → 90\n * - `mm:ss.ms`: `01:30.500` → 90.5\n * - `1500ms` → 1.5\n *\n * Returns null on malformed input.\n */\nexport function parseTimeSeconds(raw: string): number | null {\n const trimmed = raw.trim();\n if (!trimmed) return null;\n\n if (TIME_BARE_RE.test(trimmed)) {\n const n = Number(trimmed);\n return Number.isFinite(n) ? n : null;\n }\n\n const msMatch = trimmed.match(TIME_MS_RE);\n if (msMatch) {\n const n = Number(msMatch[1]);\n return Number.isFinite(n) ? n / 1000 : null;\n }\n\n const mmssMatch = trimmed.match(TIME_MMSS_RE);\n if (mmssMatch) {\n const mins = Number(mmssMatch[1]);\n const secs = Number(mmssMatch[2]);\n const frac = mmssMatch[3] ? Number(`0.${mmssMatch[3]}`) : 0;\n if (!Number.isFinite(mins) || !Number.isFinite(secs) || !Number.isFinite(frac)) {\n return null;\n }\n if (secs >= 60) return null;\n return mins * 60 + secs + frac;\n }\n\n return null;\n}\n\n/**\n * Parse a comma-separated connection list. Each entry is `target` or\n * `target:type`. Empty entries (`a,,b`) are filtered with a warning; an\n * entirely empty input yields an empty list with no warning.\n */\nexport function parseConnectionList(raw: string): {\n list: BlockConnection[];\n warning: string | null;\n} {\n const trimmed = raw.trim();\n if (!trimmed) return { list: [], warning: null };\n\n const list: BlockConnection[] = [];\n let droppedEmpty = false;\n for (const part of trimmed.split(',')) {\n const entry = part.trim();\n if (!entry) {\n droppedEmpty = true;\n continue;\n }\n const colonIdx = entry.indexOf(':');\n if (colonIdx < 0) {\n list.push({ target: entry });\n } else {\n const target = entry.slice(0, colonIdx).trim();\n const type = entry.slice(colonIdx + 1).trim();\n if (!target) {\n droppedEmpty = true;\n continue;\n }\n list.push(type ? { target, type } : { target });\n }\n }\n\n return {\n list,\n warning: droppedEmpty ? 'dropped empty connection entries' : null,\n };\n}\n","/**\n * Shared key=value attribute machinery for the two heading annotation forms:\n * the squisq-native `{[templateName key=value …]}` template annotation and\n * the Pandoc-style `{#id .class key=value}` attribute block.\n *\n * Both forms share one interior grammar — whitespace-separated tokens whose\n * values may be quoted (double or single) to include spaces, brackets, or\n * quote characters. This module is the single implementation of that\n * grammar: one tokenizer, one value un/escaper, one quoting rule. The\n * trailing-annotation recognizers live here too so the editor bridge\n * (packages/editor-react/src/tiptapBridge.ts) stays in sync by importing\n * them rather than copying regexes.\n *\n * Value syntax:\n * - Unquoted: no whitespace, quotes, or `[ ] { }` (those would collide with\n * the surrounding annotation delimiters), e.g. `columns=3`, `name=O'Brien`\n * (a quote *inside* an unquoted value is literal).\n * - Quoted: `key=\"value with spaces\"` or `key='…'`. Inside a quoted run,\n * `\\` escapes the active quote character and itself; any other `\\` is\n * literal. Quoted values may contain `]` and `}`.\n * - Serialization emits double quotes, switching to single quotes when the\n * value contains a double quote (markdown character-escape resolution\n * makes backslash-escaped quotes fragile in `.md` source, so picking the\n * other quote character is preferred over escaping). A value containing\n * BOTH quote characters falls back to double quotes with `\\\"` escapes —\n * that survives the API path but is best avoided in markdown source.\n */\n\n// ============================================\n// Trailing-annotation recognizers\n// ============================================\n\n/** Regex source for a double-quoted run with `\\\"` / `\\\\` escapes. */\nconst DQ_RUN = `\"(?:[^\"\\\\\\\\]|\\\\\\\\.)*\"`;\n/** Regex source for a single-quoted run with `\\'` / `\\\\` escapes. */\nconst SQ_RUN = `'(?:[^'\\\\\\\\]|\\\\\\\\.)*'`;\n\n/**\n * Quote-aware match for a trailing `{[…]}` annotation: the interior is any\n * mix of quoted runs and characters other than `]` and quotes, so quoted\n * values may contain `]`. The trailing `[\\s\\]}]*` tolerates an accidental\n * doubled `]}` that users sometimes type when learning the syntax.\n */\nconst TEMPLATE_STRICT_RE = new RegExp(\n `\\\\s*\\\\{\\\\[((?:[^\\\\]\"']|${DQ_RUN}|${SQ_RUN})+)\\\\]\\\\}[\\\\s\\\\]}]*$`,\n);\n\n/**\n * Legacy fallback matching the pre-quote-aware grammar (`[^\\]]+` interior).\n * Tried after the strict form so inputs with unbalanced quotes keep parsing\n * exactly as they did before quote support landed.\n */\nconst TEMPLATE_LEGACY_RE = /\\s*\\{\\[([^\\]]+)\\]\\}[\\s\\]}]*$/;\n\n/**\n * Quote-aware match for a trailing Pandoc `{…}` block. The negative\n * lookahead `(?!\\[)` keeps it from colliding with the `{[…]}` template\n * form. Quoted values may contain `}`.\n */\nconst PANDOC_STRICT_RE = new RegExp(`\\\\s*\\\\{(?!\\\\[)((?:[^}\"']|${DQ_RUN}|${SQ_RUN})*)\\\\}\\\\s*$`);\n\n/** Legacy fallback for the Pandoc block (`[^}]*` interior). */\nconst PANDOC_LEGACY_RE = /\\s*\\{(?!\\[)([^}]*)\\}\\s*$/;\n\n/** Result of matching a trailing annotation against a text run. */\nexport interface TrailingAnnotationMatch {\n /** Interior of the brace block (between `{[`/`{` and `]}`/`}`), untrimmed. */\n inner: string;\n /** Offset of the match start (including leading whitespace) in the input. */\n index: number;\n}\n\nfunction matchTrailing(\n text: string,\n strict: RegExp,\n legacy: RegExp,\n): TrailingAnnotationMatch | null {\n const m = strict.exec(text) ?? legacy.exec(text);\n return m ? { inner: m[1], index: m.index } : null;\n}\n\n/**\n * Match a trailing `{[templateName key=value …]}` annotation. Quote-aware\n * (values may contain `]` when quoted), with a legacy fallback so inputs\n * the old `[^\\]]+` grammar accepted still match.\n */\nexport function matchTrailingTemplateAnnotation(text: string): TrailingAnnotationMatch | null {\n return matchTrailing(text, TEMPLATE_STRICT_RE, TEMPLATE_LEGACY_RE);\n}\n\n/**\n * Match a trailing Pandoc `{#id .class key=value}` block. Quote-aware\n * (values may contain `}` when quoted), with a legacy fallback.\n */\nexport function matchTrailingPandocAttr(text: string): TrailingAnnotationMatch | null {\n return matchTrailing(text, PANDOC_STRICT_RE, PANDOC_LEGACY_RE);\n}\n\n// ============================================\n// Tokenizer\n// ============================================\n\nconst WHITESPACE_RE = /\\s/;\n\n/**\n * Quote-aware whitespace tokenizer for the interior of either annotation\n * form.\n *\n * A quote run starts only at the beginning of a token or immediately after\n * `=` — a quote elsewhere (e.g. `name=O'Brien`) is a literal character.\n * Inside a run, `\\` escapes the active quote character and itself; the\n * escape pair is preserved in the returned token (callers strip and\n * unescape via {@link splitKeyValueToken} / {@link unquoteAttrValue}).\n * An unbalanced opening quote is tolerated: the run extends to the end of\n * the input.\n */\nexport function tokenizeAttrTokens(input: string): string[] {\n const tokens: string[] = [];\n let i = 0;\n const n = input.length;\n while (i < n) {\n while (i < n && WHITESPACE_RE.test(input[i])) i++;\n if (i >= n) break;\n\n let token = '';\n while (i < n && !WHITESPACE_RE.test(input[i])) {\n const ch = input[i];\n const atValueStart = token === '' || token.endsWith('=');\n if ((ch === '\"' || ch === \"'\") && atValueStart) {\n token += ch;\n i++;\n while (i < n && input[i] !== ch) {\n if (input[i] === '\\\\' && i + 1 < n && (input[i + 1] === ch || input[i + 1] === '\\\\')) {\n token += input[i] + input[i + 1];\n i += 2;\n } else {\n token += input[i];\n i++;\n }\n }\n if (i < n && input[i] === ch) {\n token += ch;\n i++;\n }\n } else {\n token += ch;\n i++;\n }\n }\n if (token) tokens.push(token);\n }\n return tokens;\n}\n\n// ============================================\n// Value un/escaping\n// ============================================\n\nconst DQ_UNESCAPE_RE = /\\\\([\\\\\"])/g;\nconst SQ_UNESCAPE_RE = /\\\\([\\\\'])/g;\n\n/**\n * Strip surrounding quotes from a raw token value and unescape the active\n * quote character and backslash. Values not wrapped in matching quotes are\n * returned verbatim (including any interior quotes or backslashes).\n */\nexport function unquoteAttrValue(raw: string): string {\n if (raw.length >= 2) {\n const q = raw[0];\n if ((q === '\"' || q === \"'\") && raw.endsWith(q)) {\n const body = raw.slice(1, -1);\n return body.replace(q === '\"' ? DQ_UNESCAPE_RE : SQ_UNESCAPE_RE, '$1');\n }\n }\n return raw;\n}\n\n/**\n * Split a `key=value` token into its parts, unquoting/unescaping the value.\n * Returns null for tokens with no `=` past the first character (bare words,\n * `#id`, `.class`, or a leading `=`).\n */\nexport function splitKeyValueToken(token: string): { key: string; value: string } | null {\n const eqIdx = token.indexOf('=');\n if (eqIdx <= 0) return null;\n return { key: token.slice(0, eqIdx), value: unquoteAttrValue(token.slice(eqIdx + 1)) };\n}\n\n// ============================================\n// Serialization\n// ============================================\n\nconst NEEDS_QUOTING_RE = /[\\s\"'[\\]{}]/;\nconst DQ_ESCAPE_RE = /[\\\\\"]/g;\nconst SQ_ESCAPE_RE = /[\\\\']/g;\n\n/**\n * Whether a value must be quoted to survive tokenization and the outer\n * annotation regexes: any whitespace, quote character, bracket, or brace —\n * or an empty value, which would otherwise serialize as a bare `key=`.\n */\nexport function needsQuoting(value: string): boolean {\n return value === '' || NEEDS_QUOTING_RE.test(value);\n}\n\n/**\n * Serialize an attribute value, quoting when {@link needsQuoting} says the\n * bare form would not round-trip.\n *\n * Double quotes are canonical; a value containing a double quote (but no\n * single quote) is single-quoted instead, because markdown resolves\n * backslash escapes in text runs before our parser sees them — switching\n * the quote character round-trips through `.md` source where `\\\"` would\n * not. Backslashes and the active quote character are escaped.\n */\nexport function quoteAttrValue(value: string): string {\n if (!needsQuoting(value)) return value;\n if (value.includes('\"') && !value.includes(\"'\")) {\n return `'${value.replace(SQ_ESCAPE_RE, (ch) => `\\\\${ch}`)}'`;\n }\n return `\"${value.replace(DQ_ESCAPE_RE, (ch) => `\\\\${ch}`)}\"`;\n}\n","/**\n * mdast ↔ Squisq Markdown Node Conversion\n *\n * Converts between the remark/mdast AST format and the squisq\n * MarkdownDocument JSON format. This is the bridge layer that allows\n * us to use the battle-tested unified/remark ecosystem for parsing\n * and serialization while exposing our own clean, well-typed interfaces.\n *\n * The conversion is designed for perfect round-tripping:\n * toMdast(fromMdast(tree)) should produce an equivalent mdast tree.\n */\n\nimport type {\n MarkdownDocument,\n MarkdownBlockNode,\n MarkdownInlineNode,\n MarkdownListItem,\n MarkdownTableRow,\n MarkdownTableCell,\n MarkdownSourcePosition,\n HeadingTemplateAnnotation,\n HeadingAttributes,\n MarkdownHeading,\n MarkdownInlineIcon,\n} from './types.js';\nimport { parseHtmlToNodes } from './htmlParse.js';\nimport { resolveIcon } from '../icons/resolve.js';\nimport { coerceAnnotationValues } from './annotationCoercion.js';\nimport {\n matchTrailingTemplateAnnotation,\n matchTrailingPandocAttr,\n tokenizeAttrTokens,\n splitKeyValueToken,\n quoteAttrValue,\n} from './attrTokens.js';\n\n// ============================================\n// Generic mdast node shape\n// ============================================\n\n/**\n * Minimal interface for mdast/unist nodes.\n * Using a generic shape avoids hard dependency on @types/mdast\n * and handles extension nodes (GFM, math, directive) uniformly.\n */\ninterface MdastPosition {\n start: { line: number; column: number; offset?: number };\n end: { line: number; column: number; offset?: number };\n}\n\ninterface MdastNode {\n type: string;\n position?: MdastPosition;\n children?: MdastNode[];\n value?: string;\n depth?: number;\n ordered?: boolean | null;\n start?: number | null;\n spread?: boolean | null;\n checked?: boolean | null;\n lang?: string | null;\n meta?: string | null;\n url?: string;\n title?: string | null;\n alt?: string;\n identifier?: string;\n label?: string;\n referenceType?: string;\n align?: (string | null)[];\n name?: string;\n attributes?: Record<string, string>;\n data?: Record<string, unknown>;\n}\n\n// ============================================\n// Position conversion\n// ============================================\n\nfunction convertPosition(pos?: MdastPosition): MarkdownSourcePosition | undefined {\n if (!pos) return undefined;\n return {\n start: {\n line: pos.start.line,\n column: pos.start.column,\n ...(pos.start.offset != null ? { offset: pos.start.offset } : {}),\n },\n end: {\n line: pos.end.line,\n column: pos.end.column,\n ...(pos.end.offset != null ? { offset: pos.end.offset } : {}),\n },\n };\n}\n\nfunction toMdastPosition(pos: MarkdownSourcePosition): MdastPosition {\n return {\n start: {\n line: pos.start.line,\n column: pos.start.column,\n ...(pos.start.offset != null ? { offset: pos.start.offset } : {}),\n },\n end: {\n line: pos.end.line,\n column: pos.end.column,\n ...(pos.end.offset != null ? { offset: pos.end.offset } : {}),\n },\n };\n}\n\n/** Conditionally include position in node. */\nfunction posField(\n pos?: MarkdownSourcePosition,\n): { position: MarkdownSourcePosition } | Record<string, never> {\n return pos ? { position: pos } : {};\n}\n\nfunction mdastPosField(\n pos?: MarkdownSourcePosition,\n): { position: MdastPosition } | Record<string, never> {\n return pos ? { position: toMdastPosition(pos) } : {};\n}\n\n// ============================================\n// mdast → Squisq (fromMdast)\n// ============================================\n\n/**\n * Extract plain text content from an mdast node tree.\n * Used for directive labels.\n */\nfunction extractText(node: MdastNode): string {\n if (node.value != null) return node.value;\n if (node.children) {\n return node.children.map(extractText).join('');\n }\n return '';\n}\n\n// ============================================\n// Template annotation helpers\n// ============================================\n\n/**\n * Extract a `{[templateName key=value …]}` annotation from a heading's\n * inline children. Mutates the children array in-place: strips the\n * annotation text from the last text node (or removes the node entirely).\n *\n * Matching is delegated to {@link matchTrailingTemplateAnnotation}: a\n * quote-aware grammar (values may contain `]` when quoted) with a legacy\n * fallback, plus tolerance for an accidental doubled trailing `]}`. A\n * non-trailing annotation like `## The {[chart]} section` doesn't match.\n *\n * @returns The parsed annotation, or null if none found.\n */\nfunction extractTemplateAnnotation(\n children: MarkdownInlineNode[],\n): HeadingTemplateAnnotation | null {\n // Walk backwards to find the last text node\n for (let i = children.length - 1; i >= 0; i--) {\n const child = children[i];\n if (child.type === 'text') {\n const match = matchTrailingTemplateAnnotation(child.value);\n if (match) {\n const inner = match.inner.trim();\n const annotation = parseAnnotationTokens(inner);\n\n // Strip the matched portion from the text\n const stripped = child.value.slice(0, match.index).replace(/\\s+$/, '');\n if (stripped) {\n (child as { value: string }).value = stripped;\n } else {\n // Remove the now-empty text node\n children.splice(i, 1);\n }\n return annotation;\n }\n // Only check the last text node (trailing position)\n break;\n }\n // If the last child isn't a text node, there's no annotation\n break;\n }\n return null;\n}\n\n/**\n * Parse the inner content of a `{[…]}` annotation into template + params.\n *\n * Input: `\"chart colorScheme=blue caption=\\\"Sales by region\\\"\"`\n * Output: `{ template: 'chart', params: { colorScheme: 'blue', caption: 'Sales by region' } }`\n *\n * Tokenization is shared with the Pandoc attribute parser\n * ({@link tokenizeAttrTokens}), so quoting and escaping behave\n * identically in both annotation forms.\n */\nfunction parseAnnotationTokens(inner: string): HeadingTemplateAnnotation {\n const tokens = tokenizeAttrTokens(inner);\n const params: Record<string, string> = {};\n\n // If the first token contains '=', there's no template name —\n // the annotation is purely key-value (e.g., `{[audio=intro.mp3]}`).\n const firstIsParam = tokens.length > 0 && tokens[0].indexOf('=') > 0;\n const template = firstIsParam || tokens.length === 0 ? undefined : tokens[0];\n const startIdx = firstIsParam ? 0 : 1;\n\n for (let i = startIdx; i < tokens.length; i++) {\n const kv = splitKeyValueToken(tokens[i]);\n if (kv) {\n params[kv.key] = kv.value;\n }\n }\n\n const result: HeadingTemplateAnnotation = {};\n if (template) {\n result.template = template;\n }\n if (Object.keys(params).length > 0) {\n result.params = params;\n }\n return result;\n}\n\n// ============================================\n// Pandoc-style heading attribute helpers\n// ============================================\n\n/**\n * Extract a trailing Pandoc-style `{…}` attribute block from a heading's\n * inline children. Matching is delegated to {@link matchTrailingPandocAttr}\n * (quote-aware — values may contain `}` when quoted — with a legacy\n * fallback; a `(?!\\[)` lookahead keeps it from colliding with the\n * squisq-native `{[…]}` template annotation).\n *\n * Unlike `extractTemplateAnnotation()`, this walks backward through both\n * text nodes AND bare `textDirective` nodes. remark-directive may have\n * fragmented a `{key=val:type,…}` attribute block at colon-prefixed\n * segments like `:type` that look like text directives but are really\n * attribute-value fragments. We virtually re-stitch the trailing run as a\n * single string, match against it, and only physically modify the children\n * array if a match is found — so a heading that legitimately contains a\n * non-bare `:directive` is left alone.\n *\n * Returns the parsed `HeadingAttributes`, or null if no match.\n */\nfunction extractPandocAttributes(children: MarkdownInlineNode[]): HeadingAttributes | null {\n // Collect the trailing run of [text | bare textDirective] children.\n const trail: { val: string; idx: number; len: number }[] = [];\n for (let i = children.length - 1; i >= 0; i--) {\n const c = children[i];\n if (c.type === 'text') {\n trail.unshift({ val: c.value, idx: i, len: c.value.length });\n } else if (c.type === 'textDirective') {\n const td = c as {\n name?: string;\n children?: unknown[];\n attributes?: Record<string, string>;\n };\n const isBare =\n (!td.children || td.children.length === 0) &&\n (!td.attributes || Object.keys(td.attributes).length === 0);\n if (!isBare) break;\n const synthesized = ':' + (td.name ?? '');\n trail.unshift({ val: synthesized, idx: i, len: synthesized.length });\n } else {\n break;\n }\n }\n if (trail.length === 0) return null;\n\n const joined = trail.map((t) => t.val).join('');\n const match = matchTrailingPandocAttr(joined);\n if (!match) return null;\n\n const inner = match.inner.trim();\n const attrs = parsePandocAttrTokens(inner);\n\n // Strip the matched portion. `match.index` is an offset into `joined`.\n // Walk forward through `trail` until we find the child that straddles\n // the match boundary; trim that child (if text) or drop it (if directive),\n // and remove everything after it from `children`.\n const matchStart = match.index;\n let scannedLen = 0;\n for (let ti = 0; ti < trail.length; ti++) {\n const t = trail[ti];\n if (scannedLen + t.len <= matchStart) {\n scannedLen += t.len;\n continue;\n }\n const firstNode = children[t.idx];\n const keepLen = matchStart - scannedLen;\n if (firstNode.type === 'text') {\n const trimmed = firstNode.value.slice(0, keepLen).replace(/\\s+$/, '');\n if (trimmed) {\n (firstNode as { value: string }).value = trimmed;\n children.splice(t.idx + 1);\n } else {\n children.splice(t.idx);\n }\n } else {\n // Match boundary fell inside a textDirective's synthesized \":name\"\n // string — drop the directive and everything after.\n children.splice(t.idx);\n }\n return attrs;\n }\n // Match consumes the entire trail.\n children.splice(trail[0].idx);\n return attrs;\n}\n\n/**\n * Parse the inner content of a Pandoc-style `{…}` block. Tokens are\n * whitespace-separated, with quoted runs (single or double) treated as\n * single tokens — tokenization is shared with the `{[…]}` template\n * annotation parser via {@link tokenizeAttrTokens}.\n *\n * - `#id` → `attributes.id`\n * - `.class` → push onto `attributes.classes`\n * - `key=value` or `key=\"quoted value\"` → `attributes.params[key] = value`\n *\n * Empty `{}` yields `{}` (preserved as an annotation marker for round-tripping).\n * Duplicate ids and keys: last wins, silent.\n */\nexport function parsePandocAttrTokens(inner: string): HeadingAttributes {\n const tokens = tokenizeAttrTokens(inner);\n const attrs: HeadingAttributes = {};\n const params: Record<string, string> = {};\n const classes: string[] = [];\n\n for (const token of tokens) {\n if (token.startsWith('#') && !token.includes('=')) {\n attrs.id = token.slice(1);\n } else if (token.startsWith('.') && !token.includes('=')) {\n const cls = token.slice(1);\n if (cls) classes.push(cls);\n } else {\n const kv = splitKeyValueToken(token);\n if (kv) {\n params[kv.key] = kv.value;\n }\n }\n }\n\n if (classes.length > 0) attrs.classes = classes;\n if (Object.keys(params).length > 0) {\n attrs.params = params;\n const { blockMeta, metadata } = coerceAnnotationValues(params);\n if (Object.keys(blockMeta).length > 0) attrs.blockMeta = blockMeta;\n if (Object.keys(metadata).length > 0) attrs.metadata = metadata;\n }\n return attrs;\n}\n\n/**\n * Serialize a HeadingAttributes object back to a Pandoc `{#id .class key=value}` string.\n * Returns null when the attributes object is entirely empty (nothing to emit).\n *\n * Canonical key order: `#id`, then `.classes` (in original order), then\n * params in their original insertion order. Values are quoted via the\n * shared {@link quoteAttrValue} rule (same as `{[…]}` serialization).\n */\nexport function serializePandocAttributes(attrs: HeadingAttributes): string | null {\n const parts: string[] = [];\n if (attrs.id) parts.push(`#${attrs.id}`);\n if (attrs.classes) {\n for (const cls of attrs.classes) parts.push(`.${cls}`);\n }\n if (attrs.params) {\n for (const [key, value] of Object.entries(attrs.params)) {\n parts.push(`${key}=${quoteAttrValue(value)}`);\n }\n }\n // Preserve an empty `{}` annotation marker if it was authored deliberately\n // (e.g., reserved for downstream tooling). Caller decides whether to emit.\n if (parts.length === 0) return '{}';\n return `{${parts.join(' ')}}`;\n}\n\n/**\n * Serialize a HeadingTemplateAnnotation back to `{[templateName key=value …]}` text.\n * Values are quoted via the shared {@link quoteAttrValue} rule (same as\n * Pandoc attribute serialization).\n */\nfunction serializeTemplateAnnotation(annotation: HeadingTemplateAnnotation): string {\n const parts: string[] = [];\n if (annotation.template) {\n parts.push(annotation.template);\n }\n if (annotation.params) {\n for (const [key, value] of Object.entries(annotation.params)) {\n parts.push(`${key}=${quoteAttrValue(value)}`);\n }\n }\n return `{[${parts.join(' ')}]}`;\n}\n\n/**\n * Convert an mdast Root node to a MarkdownDocument.\n *\n * @param root - The mdast root node (from remark-parse)\n * @param options - Conversion options\n * @returns A MarkdownDocument\n */\nexport function fromMdast(root: MdastNode, options?: { parseHtml?: boolean }): MarkdownDocument {\n const doParseHtml = options?.parseHtml !== false;\n return {\n type: 'document',\n children: convertBlockChildren(root.children ?? [], doParseHtml),\n ...posField(convertPosition(root.position)),\n };\n}\n\nfunction convertBlockChildren(children: MdastNode[], parseHtml: boolean): MarkdownBlockNode[] {\n const result: MarkdownBlockNode[] = [];\n for (const child of children) {\n const node = convertBlockNode(child, parseHtml);\n if (node) result.push(node);\n }\n return result;\n}\n\nfunction convertInlineChildren(\n children: MdastNode[],\n parseHtml: boolean,\n /** When false, skip the inline-icon split. Headings opt out so the\n * `extractTemplateAnnotation` pass still sees the trailing\n * `{[…]}` in raw text form; the caller runs `splitInlineIcons`\n * itself afterward on the remaining children. */\n applyIconSplit: boolean = true,\n): MarkdownInlineNode[] {\n const result: MarkdownInlineNode[] = [];\n for (const child of children) {\n const node = convertInlineNode(child, parseHtml);\n if (node) result.push(node);\n }\n const mentioned = coalesceMentions(result);\n return applyIconSplit ? splitInlineIcons(mentioned) : mentioned;\n}\n\n/**\n * Walk an inline-children list and split each text node on `{[token]}`\n * occurrences whose tokens resolve to known FontAwesome icons. Returns\n * a new array — unresolved tokens are left as literal text so authors\n * can write `{[notathing]}` verbatim if they really mean to.\n *\n * Exposed for the heading code path, which first strips the trailing\n * template annotation and then runs this on what remains.\n */\nexport function splitInlineIcons(nodes: MarkdownInlineNode[]): MarkdownInlineNode[] {\n // First pass: reassemble `text + textDirective + text` patterns\n // formed when a qualified token like `{[fa-solid:user]}` was split\n // by remark-directive's colon recognition. We collapse those triples\n // back into a single text node containing the original token so the\n // regex below can match.\n const recombined = recombineDirectiveTokens(nodes);\n\n const out: MarkdownInlineNode[] = [];\n for (const node of recombined) {\n if (node.type !== 'text') {\n out.push(node);\n continue;\n }\n out.push(...splitTextOnIcons(node.value, node.position));\n }\n return out;\n}\n\n/**\n * When the user types `{[fa-solid:user]}`, remark's directive plugin\n * sees `:user` and emits a `textDirective` node. The result is a\n * three-node sequence `text(\"…{[fa-solid\") + textDirective(\"user\") +\n * text(\"]}…\")`. This helper detects that shape and stitches the three\n * back into one text node so downstream icon detection works on the\n * authored token.\n */\nfunction recombineDirectiveTokens(nodes: MarkdownInlineNode[]): MarkdownInlineNode[] {\n const out: MarkdownInlineNode[] = [];\n for (let i = 0; i < nodes.length; i++) {\n const cur = nodes[i];\n const next = nodes[i + 1];\n const after = nodes[i + 2];\n if (\n cur?.type === 'text' &&\n next?.type === 'textDirective' &&\n after?.type === 'text' &&\n /\\{\\[[a-zA-Z0-9_-]+$/.test(cur.value) &&\n /^\\]\\}/.test(after.value)\n ) {\n const directive = next as unknown as { name?: string };\n const directiveName = directive.name ?? '';\n const merged: MarkdownInlineNode = {\n type: 'text',\n value: cur.value + ':' + directiveName + after.value,\n ...(cur.position ? { position: cur.position } : {}),\n };\n out.push(merged);\n i += 2;\n continue;\n }\n out.push(cur);\n }\n return out;\n}\n\nconst ICON_TOKEN_RE = /\\{\\[([a-zA-Z0-9_:-]+)\\]\\}/g;\n\nfunction splitTextOnIcons(value: string, position?: MarkdownSourcePosition): MarkdownInlineNode[] {\n if (!value) return [];\n ICON_TOKEN_RE.lastIndex = 0;\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n const out: MarkdownInlineNode[] = [];\n while ((match = ICON_TOKEN_RE.exec(value)) !== null) {\n const token = match[1];\n const icon = resolveIcon(token);\n if (!icon) continue; // leave the literal `{[…]}` in place\n if (match.index > lastIndex) {\n out.push({\n type: 'text',\n value: value.slice(lastIndex, match.index),\n ...(position ? { position } : {}),\n });\n }\n const iconNode: MarkdownInlineIcon = {\n type: 'inlineIcon',\n token,\n family: icon.family,\n name: icon.name,\n ...(position ? { position } : {}),\n };\n out.push(iconNode);\n lastIndex = match.index + match[0].length;\n }\n if (lastIndex === 0) {\n // No matches — return the original text node unchanged.\n return [{ type: 'text', value, ...(position ? { position } : {}) }];\n }\n if (lastIndex < value.length) {\n out.push({\n type: 'text',\n value: value.slice(lastIndex),\n ...(position ? { position } : {}),\n });\n }\n return out;\n}\n\n/**\n * Post-process an inline-children list to collapse `text('@') + link(scheme:id)`\n * pairs into a single `mention` node. The wire format `@[Display](scheme:id)`\n * comes back from remark as two adjacent nodes — we merge them so consumers\n * see a single atomic mention. A plain link whose URL doesn't have `scheme:id`\n * shape, or that isn't immediately preceded by `@`, is left alone so ordinary\n * links keep working.\n */\nfunction coalesceMentions(inlines: MarkdownInlineNode[]): MarkdownInlineNode[] {\n const out: MarkdownInlineNode[] = [];\n for (const cur of inlines) {\n const prev = out[out.length - 1];\n if (\n cur.type === 'link' &&\n typeof cur.url === 'string' &&\n prev &&\n prev.type === 'text' &&\n prev.value.endsWith('@')\n ) {\n const schemeMatch = cur.url.match(/^([a-z][a-z0-9+.-]*):(.+)$/i);\n if (schemeMatch && schemeMatch[1] && schemeMatch[2]) {\n const targetKind = schemeMatch[1];\n const targetId = schemeMatch[2];\n const displayName = extractInlineText(cur.children);\n if (prev.value === '@') {\n out.pop();\n } else {\n prev.value = prev.value.slice(0, -1);\n }\n out.push({\n type: 'mention',\n targetKind,\n targetId,\n displayName,\n ...(cur.position ? { position: cur.position } : {}),\n });\n continue;\n }\n }\n out.push(cur);\n }\n return out;\n}\n\n/** Plain-text of an inline children list — used to pull the display name\n * out of a mention link's children. */\nfunction extractInlineText(nodes: MarkdownInlineNode[]): string {\n let out = '';\n for (const n of nodes) {\n if (n.type === 'text' || n.type === 'inlineCode') out += n.value;\n else if ('children' in n && Array.isArray(n.children)) {\n out += extractInlineText(n.children as MarkdownInlineNode[]);\n }\n }\n return out;\n}\n\nfunction convertBlockNode(node: MdastNode, parseHtml: boolean): MarkdownBlockNode | null {\n const pos = convertPosition(node.position);\n\n switch (node.type) {\n case 'heading': {\n // Defer icon splitting so `extractTemplateAnnotation` sees the\n // trailing `{[name]}` as plain text and can decide whether it's\n // a template annotation. Anything that's NOT the template still\n // needs to become an icon node, so we run `splitInlineIcons` on\n // what's left after the template extraction.\n //\n // Both annotation forms ({[…]} and Pandoc {#…}) may appear at the\n // end of the heading in either order. Extract them in a loop so\n // we catch the second-from-last one too. A small bounded retry\n // (max 4) is plenty — authors don't stack more than two trailing\n // brace-blocks in practice.\n const headingChildren = convertInlineChildren(node.children ?? [], parseHtml, false);\n let annotation: HeadingTemplateAnnotation | null = null;\n let attrs: HeadingAttributes | null = null;\n for (let pass = 0; pass < 4; pass++) {\n let matched = false;\n if (!annotation) {\n const t = extractTemplateAnnotation(headingChildren);\n if (t) {\n annotation = t;\n matched = true;\n }\n }\n if (!attrs) {\n const a = extractPandocAttributes(headingChildren);\n if (a) {\n attrs = a;\n matched = true;\n }\n }\n if (!matched) break;\n }\n const finalChildren = splitInlineIcons(headingChildren);\n const result: MarkdownHeading = {\n type: 'heading',\n depth: (node.depth ?? 1) as 1 | 2 | 3 | 4 | 5 | 6,\n children: finalChildren,\n ...posField(pos),\n };\n if (annotation) {\n result.templateAnnotation = annotation;\n }\n if (attrs) {\n result.attributes = attrs;\n }\n return result;\n }\n\n case 'paragraph':\n return {\n type: 'paragraph',\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'blockquote':\n return {\n type: 'blockquote',\n children: convertBlockChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'list':\n return {\n type: 'list',\n ordered: node.ordered ?? false,\n ...(node.start != null ? { start: node.start } : {}),\n ...(node.spread != null ? { spread: node.spread } : {}),\n children: (node.children ?? []).map((item) => convertListItem(item, parseHtml)),\n ...posField(pos),\n };\n\n case 'code':\n return {\n type: 'code',\n ...(node.lang != null ? { lang: node.lang } : {}),\n ...(node.meta != null ? { meta: node.meta } : {}),\n value: node.value ?? '',\n ...posField(pos),\n };\n\n case 'thematicBreak':\n return {\n type: 'thematicBreak',\n ...posField(pos),\n };\n\n case 'table':\n return {\n type: 'table',\n ...(node.align\n ? { align: node.align.map((a) => a as 'left' | 'right' | 'center' | null) }\n : {}),\n children: (node.children ?? []).map((row, i) => convertTableRow(row, i === 0, parseHtml)),\n ...posField(pos),\n };\n\n case 'html':\n return {\n type: 'htmlBlock',\n rawHtml: node.value ?? '',\n htmlChildren: parseHtml ? parseHtmlToNodes(node.value ?? '') : [],\n ...posField(pos),\n };\n\n case 'math':\n return {\n type: 'math',\n value: node.value ?? '',\n ...(node.meta != null ? { meta: node.meta } : {}),\n ...posField(pos),\n };\n\n case 'definition':\n return {\n type: 'definition',\n identifier: node.identifier ?? '',\n ...(node.label != null ? { label: node.label } : {}),\n url: node.url ?? '',\n ...(node.title != null ? { title: node.title } : {}),\n ...posField(pos),\n };\n\n case 'footnoteDefinition':\n return {\n type: 'footnoteDefinition',\n identifier: node.identifier ?? '',\n ...(node.label != null ? { label: node.label } : {}),\n children: convertBlockChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'containerDirective': {\n const allChildren = node.children ?? [];\n let label: string | undefined;\n let contentChildren = allChildren;\n\n // Extract directive label (first paragraph with directiveLabel flag)\n if (\n allChildren.length > 0 &&\n allChildren[0].type === 'paragraph' &&\n allChildren[0].data?.directiveLabel === true\n ) {\n label = extractText(allChildren[0]);\n contentChildren = allChildren.slice(1);\n }\n\n return {\n type: 'containerDirective',\n name: node.name ?? '',\n ...(label ? { label } : {}),\n ...(node.attributes && Object.keys(node.attributes).length > 0\n ? { attributes: node.attributes }\n : {}),\n children: convertBlockChildren(contentChildren, parseHtml),\n ...posField(pos),\n };\n }\n\n case 'leafDirective':\n return {\n type: 'leafDirective',\n name: node.name ?? '',\n ...(node.attributes && Object.keys(node.attributes).length > 0\n ? { attributes: node.attributes }\n : {}),\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'yaml':\n // YAML frontmatter nodes are handled separately in parse.ts — skip silently\n return null;\n\n default:\n // Unknown block node — skip with a warning\n if (typeof console !== 'undefined') {\n console.warn(`[squisq/markdown] Unknown mdast block node type: \"${node.type}\"`);\n }\n return null;\n }\n}\n\nfunction convertListItem(node: MdastNode, parseHtml: boolean): MarkdownListItem {\n const pos = convertPosition(node.position);\n return {\n type: 'listItem',\n ...(node.checked != null ? { checked: node.checked } : {}),\n ...(node.spread != null ? { spread: node.spread } : {}),\n children: convertBlockChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n}\n\nfunction convertTableRow(node: MdastNode, isHeader: boolean, parseHtml: boolean): MarkdownTableRow {\n const pos = convertPosition(node.position);\n return {\n type: 'tableRow',\n children: (node.children ?? []).map((cell) => convertTableCell(cell, isHeader, parseHtml)),\n ...posField(pos),\n };\n}\n\nfunction convertTableCell(\n node: MdastNode,\n isHeader: boolean,\n parseHtml: boolean,\n): MarkdownTableCell {\n const pos = convertPosition(node.position);\n return {\n type: 'tableCell',\n ...(isHeader ? { isHeader: true } : {}),\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n}\n\nfunction convertInlineNode(node: MdastNode, parseHtml: boolean): MarkdownInlineNode | null {\n const pos = convertPosition(node.position);\n\n switch (node.type) {\n case 'text':\n return {\n type: 'text',\n value: node.value ?? '',\n ...posField(pos),\n };\n\n case 'emphasis':\n return {\n type: 'emphasis',\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'strong':\n return {\n type: 'strong',\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'delete':\n return {\n type: 'delete',\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'inlineCode':\n return {\n type: 'inlineCode',\n value: node.value ?? '',\n ...posField(pos),\n };\n\n case 'link':\n return {\n type: 'link',\n url: node.url ?? '',\n ...(node.title != null ? { title: node.title } : {}),\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'image':\n return {\n type: 'image',\n url: node.url ?? '',\n ...(node.alt != null ? { alt: node.alt } : {}),\n ...(node.title != null ? { title: node.title } : {}),\n ...posField(pos),\n };\n\n case 'break':\n return {\n type: 'break',\n ...posField(pos),\n };\n\n case 'html':\n return {\n type: 'htmlInline',\n rawHtml: node.value ?? '',\n htmlChildren: parseHtml ? parseHtmlToNodes(node.value ?? '') : [],\n ...posField(pos),\n };\n\n case 'inlineMath':\n return {\n type: 'inlineMath',\n value: node.value ?? '',\n ...posField(pos),\n };\n\n case 'footnoteReference':\n return {\n type: 'footnoteReference',\n identifier: node.identifier ?? '',\n ...(node.label != null ? { label: node.label } : {}),\n ...posField(pos),\n };\n\n case 'linkReference':\n return {\n type: 'linkReference',\n identifier: node.identifier ?? '',\n ...(node.label != null ? { label: node.label } : {}),\n referenceType: (node.referenceType ?? 'full') as 'full' | 'collapsed' | 'shortcut',\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n case 'imageReference':\n return {\n type: 'imageReference',\n identifier: node.identifier ?? '',\n ...(node.label != null ? { label: node.label } : {}),\n referenceType: (node.referenceType ?? 'full') as 'full' | 'collapsed' | 'shortcut',\n ...(node.alt != null ? { alt: node.alt } : {}),\n ...posField(pos),\n };\n\n case 'textDirective':\n return {\n type: 'textDirective',\n name: node.name ?? '',\n ...(node.attributes && Object.keys(node.attributes).length > 0\n ? { attributes: node.attributes }\n : {}),\n children: convertInlineChildren(node.children ?? [], parseHtml),\n ...posField(pos),\n };\n\n default:\n if (typeof console !== 'undefined') {\n console.warn(`[squisq/markdown] Unknown mdast inline node type: \"${node.type}\"`);\n }\n return null;\n }\n}\n\n// ============================================\n// Squisq → mdast (toMdast)\n// ============================================\n\n/**\n * Convert a MarkdownDocument back to an mdast Root node.\n *\n * @param doc - A MarkdownDocument\n * @returns An mdast Root node suitable for remark-stringify\n */\nexport function toMdast(doc: MarkdownDocument): MdastNode {\n return {\n type: 'root',\n children: doc.children.map((n) => blockToMdast(n)),\n ...mdastPosField(doc.position),\n };\n}\n\nfunction blockToMdast(node: MarkdownBlockNode): MdastNode {\n switch (node.type) {\n case 'heading': {\n const mdastChildren = inlineChildrenToMdast(node.children);\n // Canonical trailing order: Pandoc attrs first, then template annotation.\n // Author-supplied order is not preserved across round-trips by design —\n // canonicalization gives stable diffs.\n const suffixes: string[] = [];\n if (node.attributes) {\n const pandoc = serializePandocAttributes(node.attributes);\n if (pandoc != null) suffixes.push(pandoc);\n }\n if (node.templateAnnotation) {\n suffixes.push(serializeTemplateAnnotation(node.templateAnnotation));\n }\n if (suffixes.length > 0) {\n const suffix = suffixes.join(' ');\n const lastChild = mdastChildren[mdastChildren.length - 1];\n if (lastChild && lastChild.type === 'text') {\n lastChild.value = (lastChild.value ?? '') + ' ' + suffix;\n } else {\n mdastChildren.push({ type: 'text', value: ' ' + suffix });\n }\n }\n return {\n type: 'heading',\n depth: node.depth,\n children: mdastChildren,\n ...mdastPosField(node.position),\n };\n }\n\n case 'paragraph':\n return {\n type: 'paragraph',\n children: inlineChildrenToMdast(node.children),\n ...mdastPosField(node.position),\n };\n\n case 'blockquote':\n return {\n type: 'blockquote',\n children: node.children.map(blockToMdast),\n ...mdastPosField(node.position),\n };\n\n case 'list':\n return {\n type: 'list',\n ordered: node.ordered,\n ...(node.start != null ? { start: node.start } : {}),\n ...(node.spread != null ? { spread: node.spread } : {}),\n children: node.children.map(listItemToMdast),\n ...mdastPosField(node.position),\n };\n\n case 'code':\n return {\n type: 'code',\n ...(node.lang != null ? { lang: node.lang } : {}),\n ...(node.meta != null ? { meta: node.meta } : {}),\n value: node.value,\n ...mdastPosField(node.position),\n };\n\n case 'thematicBreak':\n return {\n type: 'thematicBreak',\n ...mdastPosField(node.position),\n };\n\n case 'table':\n return {\n type: 'table',\n ...(node.align ? { align: node.align } : {}),\n children: node.children.map(tableRowToMdast),\n ...mdastPosField(node.position),\n };\n\n case 'htmlBlock':\n return {\n type: 'html',\n value: node.rawHtml,\n ...mdastPosField(node.position),\n };\n\n case 'math':\n return {\n type: 'math',\n value: node.value,\n ...(node.meta != null ? { meta: node.meta } : {}),\n ...mdastPosField(node.position),\n };\n\n case 'definition':\n return {\n type: 'definition',\n identifier: node.identifier,\n ...(node.label != null ? { label: node.label } : {}),\n url: node.url,\n ...(node.title != null ? { title: node.title } : {}),\n ...mdastPosField(node.position),\n };\n\n case 'footnoteDefinition':\n return {\n type: 'footnoteDefinition',\n identifier: node.identifier,\n ...(node.label != null ? { label: node.label } : {}),\n children: node.children.map(blockToMdast),\n ...mdastPosField(node.position),\n };\n\n case 'containerDirective': {\n const children: MdastNode[] = [];\n\n // Reinject label as first paragraph with directiveLabel flag\n if (node.label) {\n children.push({\n type: 'paragraph',\n data: { directiveLabel: true },\n children: [{ type: 'text', value: node.label }],\n });\n }\n\n children.push(...node.children.map(blockToMdast));\n\n return {\n type: 'containerDirective',\n name: node.name,\n ...(node.attributes ? { attributes: node.attributes } : {}),\n children,\n ...mdastPosField(node.position),\n };\n }\n\n case 'leafDirective':\n return {\n type: 'leafDirective',\n name: node.name,\n ...(node.attributes ? { attributes: node.attributes } : {}),\n children: inlineChildrenToMdast(node.children),\n ...mdastPosField(node.position),\n };\n\n case 'definitionList':\n // Definition lists don't map to standard mdast.\n // Convert to HTML as fallback.\n return {\n type: 'html',\n value: definitionListToHtml(node),\n ...mdastPosField(node.position),\n };\n\n default:\n return { type: 'html', value: '' };\n }\n}\n\nfunction listItemToMdast(item: MarkdownListItem): MdastNode {\n return {\n type: 'listItem',\n ...(item.checked != null ? { checked: item.checked } : {}),\n ...(item.spread != null ? { spread: item.spread } : {}),\n children: item.children.map(blockToMdast),\n ...mdastPosField(item.position),\n };\n}\n\nfunction tableRowToMdast(row: MarkdownTableRow): MdastNode {\n return {\n type: 'tableRow',\n children: row.children.map(tableCellToMdast),\n ...mdastPosField(row.position),\n };\n}\n\nfunction tableCellToMdast(cell: MarkdownTableCell): MdastNode {\n return {\n type: 'tableCell',\n children: inlineChildrenToMdast(cell.children),\n ...mdastPosField(cell.position),\n };\n}\n\n/**\n * Serialize an array of inline nodes to mdast, flat-mapping the result so\n * a single `mention` expands to two mdast nodes (`text('@')` + `link`).\n * Use in place of `.map(inlineToMdast)` wherever we walk a children array.\n */\nfunction inlineChildrenToMdast(nodes: MarkdownInlineNode[]): MdastNode[] {\n const out: MdastNode[] = [];\n for (const n of nodes) {\n if (n.type === 'mention') {\n out.push({ type: 'text', value: '@' });\n out.push({\n type: 'link',\n url: `${n.targetKind}:${n.targetId}`,\n children: [{ type: 'text', value: n.displayName }],\n ...mdastPosField(n.position),\n });\n } else {\n out.push(inlineToMdast(n));\n }\n }\n return out;\n}\n\nfunction inlineToMdast(node: MarkdownInlineNode): MdastNode {\n switch (node.type) {\n case 'text':\n return {\n type: 'text',\n value: node.value,\n ...mdastPosField(node.position),\n };\n\n case 'emphasis':\n return {\n type: 'emphasis',\n children: inlineChildrenToMdast(node.children),\n ...mdastPosField(node.position),\n };\n\n case 'strong':\n return {\n type: 'strong',\n children: inlineChildrenToMdast(node.children),\n ...mdastPosField(node.position),\n };\n\n case 'delete':\n return {\n type: 'delete',\n children: inlineChildrenToMdast(node.children),\n ...mdastPosField(node.position),\n };\n\n case 'inlineCode':\n return {\n type: 'inlineCode',\n value: node.value,\n ...mdastPosField(node.position),\n };\n\n case 'link':\n return {\n type: 'link',\n url: node.url,\n ...(node.title != null ? { title: node.title } : {}),\n children: inlineChildrenToMdast(node.children),\n ...mdastPosField(node.position),\n };\n\n case 'image':\n return {\n type: 'image',\n url: node.url,\n ...(node.alt != null ? { alt: node.alt } : {}),\n ...(node.title != null ? { title: node.title } : {}),\n ...mdastPosField(node.position),\n };\n\n case 'break':\n return {\n type: 'break',\n ...mdastPosField(node.position),\n };\n\n case 'htmlInline':\n return {\n type: 'html',\n value: node.rawHtml,\n ...mdastPosField(node.position),\n };\n\n case 'inlineMath':\n return {\n type: 'inlineMath',\n value: node.value,\n ...mdastPosField(node.position),\n };\n\n case 'footnoteReference':\n return {\n type: 'footnoteReference',\n identifier: node.identifier,\n ...(node.label != null ? { label: node.label } : {}),\n ...mdastPosField(node.position),\n };\n\n case 'linkReference':\n return {\n type: 'linkReference',\n identifier: node.identifier,\n ...(node.label != null ? { label: node.label } : {}),\n referenceType: node.referenceType,\n children: inlineChildrenToMdast(node.children),\n ...mdastPosField(node.position),\n };\n\n case 'imageReference':\n return {\n type: 'imageReference',\n identifier: node.identifier,\n ...(node.label != null ? { label: node.label } : {}),\n referenceType: node.referenceType,\n ...(node.alt != null ? { alt: node.alt } : {}),\n ...mdastPosField(node.position),\n };\n\n case 'textDirective':\n return {\n type: 'textDirective',\n name: node.name,\n ...(node.attributes ? { attributes: node.attributes } : {}),\n children: inlineChildrenToMdast(node.children),\n ...mdastPosField(node.position),\n };\n\n case 'mention':\n // Fallback: when `inlineToMdast` is called directly (not via\n // `inlineChildrenToMdast`), collapse the mention to just the link\n // form. The `@` prefix is lost, but the id+name still round-trip.\n // Normal call sites go through `inlineChildrenToMdast` and get\n // the proper text('@') + link pair.\n return {\n type: 'link',\n url: `${node.targetKind}:${node.targetId}`,\n children: [{ type: 'text', value: node.displayName }],\n ...mdastPosField(node.position),\n };\n\n case 'inlineIcon':\n // Serialize back to the authored token so source round-trips\n // byte-stable. The token already carries the qualified form when\n // required (the parser preserved it verbatim).\n return {\n type: 'text',\n value: `{[${node.token}]}`,\n ...mdastPosField(node.position),\n };\n\n default:\n return { type: 'text', value: '' };\n }\n}\n\n// ============================================\n// Helpers\n// ============================================\n\n/**\n * Convert a MarkdownDefinitionList to an HTML <dl> string.\n * Fallback for serialization since mdast doesn't support definition lists.\n */\nfunction definitionListToHtml(list: {\n children: Array<{ type: string; children?: unknown[] }>;\n}): string {\n let html = '<dl>\\n';\n for (const child of list.children) {\n if (child.type === 'definitionTerm') {\n // Extract plain text from inline children\n const text = (child.children as Array<{ value?: string; children?: unknown[] }>)\n .map((c) => c.value ?? '')\n .join('');\n html += ` <dt>${text}</dt>\\n`;\n } else if (child.type === 'definitionDescription') {\n html += ` <dd>...</dd>\\n`;\n }\n }\n html += '</dl>';\n return html;\n}\n","/**\n * Markdown → JSON Parser\n *\n * Parses a markdown string into a MarkdownDocument JSON structure\n * using the unified/remark ecosystem with GFM, math, and directive extensions.\n */\n\nimport { unified } from 'unified';\nimport remarkParse from 'remark-parse';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport remarkDirective from 'remark-directive';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport type { MarkdownDocument, ParseOptions } from './types.js';\nimport { fromMdast } from './convert.js';\nimport { parseFrontmatter } from './utils.js';\n\n// Cache the default processor (all extensions enabled) to avoid rebuilding on every call.\nlet defaultProcessor: any;\n\n/**\n * Parse a markdown string into a MarkdownDocument.\n *\n * All extensions (GFM, math, directives) are enabled by default.\n * Use the `options` parameter to disable specific extensions.\n *\n * @param markdown - The markdown source text\n * @param options - Parser options (extensions, HTML parsing)\n * @returns A MarkdownDocument representing the parsed markdown\n *\n * @example\n * ```ts\n * const doc = parseMarkdown('# Hello\\n\\nWorld **bold** and *italic*');\n * // doc.type === 'document'\n * // doc.children[0].type === 'heading'\n * // doc.children[1].type === 'paragraph'\n * ```\n */\nexport function parseMarkdown(markdown: string, options?: ParseOptions): MarkdownDocument {\n // Use cached default processor when all extensions are enabled (the common case).\n const useDefaults =\n !options ||\n (options.gfm !== false &&\n options.math !== false &&\n options.directive !== false &&\n options.frontmatter !== false);\n\n let processor: any;\n\n if (useDefaults) {\n if (!defaultProcessor) {\n defaultProcessor = unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkMath)\n .use(remarkDirective)\n .use(remarkFrontmatter, ['yaml']);\n }\n processor = defaultProcessor;\n } else {\n // Build a custom processor with requested extensions.\n // unified's .use() chaining changes the generic signature each time,\n // making strict typing impractical — use a widened Processor type.\n processor = unified().use(remarkParse);\n\n if (options?.gfm !== false) {\n processor = processor.use(remarkGfm);\n }\n if (options?.math !== false) {\n processor = processor.use(remarkMath);\n }\n if (options?.directive !== false) {\n processor = processor.use(remarkDirective);\n }\n if (options?.frontmatter !== false) {\n processor = processor.use(remarkFrontmatter, ['yaml']);\n }\n }\n\n // Parse markdown → mdast tree (result is an mdast Root node)\n const mdastTree = processor.parse(markdown) as {\n type: string;\n children?: Array<{ type: string; value?: string }>;\n };\n\n // Convert mdast → MarkdownDocument\n const doc = fromMdast(mdastTree as Parameters<typeof fromMdast>[0], {\n parseHtml: options?.parseHtml,\n });\n\n // Extract YAML frontmatter if present\n if (options?.frontmatter !== false) {\n const yamlNode = mdastTree.children?.find((n) => n.type === 'yaml');\n if (yamlNode?.value) {\n const fm = parseFrontmatter(yamlNode.value);\n if (fm && Object.keys(fm).length > 0) {\n doc.frontmatter = fm;\n }\n }\n }\n\n return doc;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8BO,IAAM,wBAAwB;AAAA,EACnC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,qBAAqB;AACvB;AA4BO,IAAM,6BAAgE;AAAA,EAC3E;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,QAAQ;AAAA,EACV;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AACF;AAgCO,SAAS,uBAAuB,QAA8C;AACnF,QAAM,YAA8B,CAAC;AACrC,QAAM,WAAmC,CAAC;AAC1C,QAAM,WAAqB,CAAC;AAC5B,MAAI,iBAAwC;AAC5C,MAAI;AACJ,MAAI;AAE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@
1
+ // src/markdown/htmlParse.ts
2
+ import { fromHtml } from "hast-util-from-html";
3
+ var HAST_PROP_TO_ATTR = {
4
+ className: "class",
5
+ htmlFor: "for",
6
+ httpEquiv: "http-equiv",
7
+ acceptCharset: "accept-charset"
8
+ };
9
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
10
+ "area",
11
+ "base",
12
+ "br",
13
+ "col",
14
+ "embed",
15
+ "hr",
16
+ "img",
17
+ "input",
18
+ "link",
19
+ "meta",
20
+ "param",
21
+ "source",
22
+ "track",
23
+ "wbr"
24
+ ]);
25
+ function propertyToAttribute(prop) {
26
+ if (HAST_PROP_TO_ATTR[prop]) return HAST_PROP_TO_ATTR[prop];
27
+ if (prop.length > 4 && prop.startsWith("data") && prop[4] >= "A" && prop[4] <= "Z") {
28
+ return "data-" + prop.slice(4).replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^-/, "");
29
+ }
30
+ if (prop.length > 4 && prop.startsWith("aria") && prop[4] >= "A" && prop[4] <= "Z") {
31
+ return "aria-" + prop.slice(4).replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()).replace(/^-/, "");
32
+ }
33
+ return prop.toLowerCase();
34
+ }
35
+ function convertHastProperties(properties) {
36
+ const attrs = {};
37
+ for (const [key, value] of Object.entries(properties)) {
38
+ if (value === false || value === void 0 || value === null) continue;
39
+ const attrName = propertyToAttribute(key);
40
+ if (value === true) {
41
+ attrs[attrName] = "";
42
+ } else if (Array.isArray(value)) {
43
+ attrs[attrName] = value.join(" ");
44
+ } else {
45
+ attrs[attrName] = String(value);
46
+ }
47
+ }
48
+ return attrs;
49
+ }
50
+ function hastChildrenToNodes(children) {
51
+ const result = [];
52
+ for (const child of children) {
53
+ const node = hastNodeToHtmlNode(child);
54
+ if (node) result.push(node);
55
+ }
56
+ return result;
57
+ }
58
+ function hastNodeToHtmlNode(node) {
59
+ switch (node.type) {
60
+ case "element": {
61
+ const tagName = node.tagName;
62
+ const properties = node.properties ?? {};
63
+ const children = node.children ?? [];
64
+ return {
65
+ type: "htmlElement",
66
+ tagName,
67
+ attributes: convertHastProperties(properties),
68
+ children: hastChildrenToNodes(children),
69
+ selfClosing: VOID_ELEMENTS.has(tagName) && children.length === 0
70
+ };
71
+ }
72
+ case "text":
73
+ return {
74
+ type: "htmlText",
75
+ value: node.value
76
+ };
77
+ case "comment":
78
+ return {
79
+ type: "htmlComment",
80
+ value: node.value
81
+ };
82
+ case "doctype":
83
+ return null;
84
+ default:
85
+ return null;
86
+ }
87
+ }
88
+ function parseHtmlToNodes(html) {
89
+ if (!html || !html.trim()) return [];
90
+ try {
91
+ const tree = fromHtml(html, { fragment: true });
92
+ return hastChildrenToNodes(tree.children);
93
+ } catch {
94
+ return [{ type: "htmlText", value: html }];
95
+ }
96
+ }
97
+ function escapeHtmlAttr(value) {
98
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
99
+ }
100
+ function stringifyNode(node) {
101
+ switch (node.type) {
102
+ case "htmlElement": {
103
+ const attrs = Object.entries(node.attributes).map(([k, v]) => v === "" ? k : `${k}="${escapeHtmlAttr(v)}"`).join(" ");
104
+ const open = attrs ? `<${node.tagName} ${attrs}>` : `<${node.tagName}>`;
105
+ if (node.selfClosing) return open;
106
+ const inner = node.children.map(stringifyNode).join("");
107
+ return `${open}${inner}</${node.tagName}>`;
108
+ }
109
+ case "htmlText":
110
+ return node.value;
111
+ case "htmlComment":
112
+ return `<!--${node.value}-->`;
113
+ }
114
+ }
115
+ function stringifyHtmlNodes(nodes) {
116
+ return nodes.map(stringifyNode).join("");
117
+ }
118
+
1
119
  // src/markdown/utils.ts
2
120
  function getChildren(node) {
3
121
  if ("children" in node && Array.isArray(node.children)) {
@@ -66,6 +184,7 @@ function parseFrontmatter(yaml) {
66
184
  var FRONTMATTER_BLOCK_RE = /^---\r?\n([\s\S]*?)\r?\n---(\r?\n)?/;
67
185
  function formatFrontmatterValue(value) {
68
186
  if (typeof value === "boolean" || typeof value === "number") return String(value);
187
+ if (/^[{[]/.test(value) && !/[\r\n]/.test(value)) return value;
69
188
  const needsQuote = /^\s|\s$/.test(value) || /^[!&*?|>%@`]/.test(value) || /[:#]/.test(value) || value === "" || value === "true" || value === "false" || /^-?\d+(\.\d+)?$/.test(value);
70
189
  if (!needsQuote) return value;
71
190
  const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
@@ -163,8 +282,35 @@ function readFrontmatterThemeId(frontmatter) {
163
282
  }
164
283
  return void 0;
165
284
  }
285
+ function plainTextFromInlineHtml(html) {
286
+ const BLOCK = /* @__PURE__ */ new Set([
287
+ "p",
288
+ "div",
289
+ "h1",
290
+ "h2",
291
+ "h3",
292
+ "h4",
293
+ "h5",
294
+ "h6",
295
+ "li",
296
+ "blockquote",
297
+ "pre"
298
+ ]);
299
+ const walk = (nodes) => nodes.map((n) => {
300
+ if (n.type === "htmlText") return n.value;
301
+ if (n.type !== "htmlElement") return "";
302
+ const tag = n.tagName.toLowerCase();
303
+ if (tag === "br") return "\n";
304
+ const inner = walk(n.children);
305
+ return BLOCK.has(tag) ? `${inner}
306
+ ` : inner;
307
+ }).join("");
308
+ return walk(parseHtmlToNodes(html)).replace(/\u00A0/g, " ").replace(/\n{3,}/g, "\n\n").trim();
309
+ }
166
310
 
167
311
  export {
312
+ parseHtmlToNodes,
313
+ stringifyHtmlNodes,
168
314
  getChildren,
169
315
  walkMarkdownTree,
170
316
  findNodesByType,
@@ -174,6 +320,7 @@ export {
174
320
  setFrontmatterValues,
175
321
  createDocument,
176
322
  inferDocumentTitle,
177
- readFrontmatterThemeId
323
+ readFrontmatterThemeId,
324
+ plainTextFromInlineHtml
178
325
  };
179
- //# sourceMappingURL=chunk-H3AXU4MJ.js.map
326
+ //# sourceMappingURL=chunk-OKJOQXK4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/markdown/htmlParse.ts","../src/markdown/utils.ts"],"sourcesContent":["/**\n * HTML ↔ HtmlNode Conversion\n *\n * Parses raw HTML strings into the squisq HtmlNode tree representation\n * using hast-util-from-html (parse5-backed), and serializes HtmlNode trees\n * back to HTML strings with a lightweight custom serializer.\n */\n\nimport { fromHtml } from 'hast-util-from-html';\nimport type { HtmlNode } from './types.js';\n\n// ============================================\n// Hast → HtmlNode conversion\n// ============================================\n\n/**\n * Mapping from hast DOM-style property names to HTML attribute names.\n * Only includes names where the property and attribute differ.\n */\nconst HAST_PROP_TO_ATTR: Record<string, string> = {\n className: 'class',\n htmlFor: 'for',\n httpEquiv: 'http-equiv',\n acceptCharset: 'accept-charset',\n};\n\n/** HTML void elements that are self-closing. */\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Convert a hast property name to an HTML attribute name.\n */\nfunction propertyToAttribute(prop: string): string {\n if (HAST_PROP_TO_ATTR[prop]) return HAST_PROP_TO_ATTR[prop];\n\n // data-* attributes: dataFooBar → data-foo-bar\n if (prop.length > 4 && prop.startsWith('data') && prop[4] >= 'A' && prop[4] <= 'Z') {\n return (\n 'data-' +\n prop\n .slice(4)\n .replace(/[A-Z]/g, (m) => '-' + m.toLowerCase())\n .replace(/^-/, '')\n );\n }\n\n // aria-* attributes: ariaLabel → aria-label\n if (prop.length > 4 && prop.startsWith('aria') && prop[4] >= 'A' && prop[4] <= 'Z') {\n return (\n 'aria-' +\n prop\n .slice(4)\n .replace(/[A-Z]/g, (m) => '-' + m.toLowerCase())\n .replace(/^-/, '')\n );\n }\n\n // Most HTML attributes are lowercase (tabIndex → tabindex, readOnly → readonly, etc.)\n return prop.toLowerCase();\n}\n\n/**\n * Convert hast element properties to a flat HTML attribute map.\n */\nfunction convertHastProperties(properties: Record<string, unknown>): Record<string, string> {\n const attrs: Record<string, string> = {};\n for (const [key, value] of Object.entries(properties)) {\n if (value === false || value === undefined || value === null) continue;\n\n const attrName = propertyToAttribute(key);\n\n if (value === true) {\n attrs[attrName] = '';\n } else if (Array.isArray(value)) {\n attrs[attrName] = value.join(' ');\n } else {\n attrs[attrName] = String(value);\n }\n }\n return attrs;\n}\n\n/**\n * Recursively convert hast child nodes to HtmlNode[].\n */\nfunction hastChildrenToNodes(children: unknown[]): HtmlNode[] {\n const result: HtmlNode[] = [];\n for (const child of children) {\n const node = hastNodeToHtmlNode(child as Record<string, unknown>);\n if (node) result.push(node);\n }\n return result;\n}\n\n/**\n * Convert a single hast node to an HtmlNode.\n */\nfunction hastNodeToHtmlNode(node: Record<string, unknown>): HtmlNode | null {\n switch (node.type) {\n case 'element': {\n const tagName = node.tagName as string;\n const properties = (node.properties ?? {}) as Record<string, unknown>;\n const children = (node.children ?? []) as unknown[];\n return {\n type: 'htmlElement',\n tagName,\n attributes: convertHastProperties(properties),\n children: hastChildrenToNodes(children),\n selfClosing: VOID_ELEMENTS.has(tagName) && children.length === 0,\n };\n }\n case 'text':\n return {\n type: 'htmlText',\n value: node.value as string,\n };\n case 'comment':\n return {\n type: 'htmlComment',\n value: node.value as string,\n };\n case 'doctype':\n // Doctype nodes are rare in markdown HTML; skip them\n return null;\n default:\n return null;\n }\n}\n\n// ============================================\n// Public API\n// ============================================\n\n/**\n * Parse a raw HTML string into an HtmlNode[] tree.\n *\n * Uses the HTML5 parsing algorithm (via parse5) for correct handling of\n * self-closing tags, optional end tags, entity decoding, etc.\n *\n * @param html - Raw HTML string to parse\n * @returns Array of top-level HtmlNode elements\n */\nexport function parseHtmlToNodes(html: string): HtmlNode[] {\n if (!html || !html.trim()) return [];\n\n try {\n const tree = fromHtml(html, { fragment: true });\n return hastChildrenToNodes(tree.children as unknown[]);\n } catch {\n // If parsing fails, return the raw text as a single text node\n return [{ type: 'htmlText', value: html }];\n }\n}\n\n/**\n * Escape special characters in HTML attribute values.\n */\nfunction escapeHtmlAttr(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;');\n}\n\n/**\n * Serialize an HtmlNode back to an HTML string.\n */\nfunction stringifyNode(node: HtmlNode): string {\n switch (node.type) {\n case 'htmlElement': {\n const attrs = Object.entries(node.attributes)\n .map(([k, v]) => (v === '' ? k : `${k}=\"${escapeHtmlAttr(v)}\"`))\n .join(' ');\n const open = attrs ? `<${node.tagName} ${attrs}>` : `<${node.tagName}>`;\n\n if (node.selfClosing) return open;\n\n const inner = node.children.map(stringifyNode).join('');\n return `${open}${inner}</${node.tagName}>`;\n }\n case 'htmlText':\n return node.value;\n case 'htmlComment':\n return `<!--${node.value}-->`;\n }\n}\n\n/**\n * Serialize an HtmlNode[] tree back to an HTML string.\n *\n * @param nodes - Array of HtmlNode elements to serialize\n * @returns HTML string\n */\nexport function stringifyHtmlNodes(nodes: HtmlNode[]): string {\n return nodes.map(stringifyNode).join('');\n}\n","/**\n * Markdown Tree Utilities\n *\n * Helper functions for traversing and querying the MarkdownDocument tree.\n * All functions are pure and operate on the JSON node interfaces.\n */\n\nimport type { MarkdownNode, MarkdownDocument, HtmlNode } from './types.js';\nimport { parseHtmlToNodes } from './htmlParse.js';\n\n/**\n * Get the children of any markdown node, if it has children.\n * Returns an empty array for leaf nodes (text, code, break, etc.).\n *\n * This is useful for generic tree walking where you don't want to\n * check the specific node type.\n */\nexport function getChildren(node: MarkdownNode): MarkdownNode[] {\n if ('children' in node && Array.isArray(node.children)) {\n return node.children as MarkdownNode[];\n }\n return [];\n}\n\n/**\n * Walk the markdown tree depth-first, calling the visitor for each node.\n *\n * The visitor receives the current node and its parent. Return `true`\n * from the visitor to skip the node's children (prune).\n *\n * @param node - The root node to start walking from\n * @param visitor - Called for each node; return true to skip children\n * @param parent - (internal) Parent node\n */\nexport function walkMarkdownTree(\n node: MarkdownNode,\n visitor: (node: MarkdownNode, parent?: MarkdownNode) => void | boolean,\n parent?: MarkdownNode,\n): void {\n const skip = visitor(node, parent);\n if (skip === true) return;\n\n const children = getChildren(node);\n for (const child of children) {\n walkMarkdownTree(child, visitor, node);\n }\n}\n\n/**\n * Find all nodes of a specific type in the tree.\n *\n * @param root - The document or node to search within\n * @param type - The node type to find (e.g., 'heading', 'link', 'text')\n * @returns Array of matching nodes\n *\n * @example\n * ```ts\n * const headings = findNodesByType(doc, 'heading');\n * const links = findNodesByType(doc, 'link');\n * ```\n */\nexport function findNodesByType<T extends MarkdownNode>(root: MarkdownNode, type: T['type']): T[] {\n const results: T[] = [];\n walkMarkdownTree(root, (node) => {\n if (node.type === type) {\n results.push(node as T);\n }\n });\n return results;\n}\n\n/**\n * Extract all plain text content from a node and its descendants.\n * Concatenates text values, ignoring formatting, links, etc.\n *\n * @param node - The node to extract text from\n * @returns Plain text content\n *\n * @example\n * ```ts\n * const heading = doc.children[0]; // { type: 'heading', children: [{ type: 'text', value: 'Hello' }] }\n * extractPlainText(heading); // 'Hello'\n * ```\n */\nexport function extractPlainText(node: MarkdownNode): string {\n if ('value' in node && typeof node.value === 'string') {\n return node.value;\n }\n\n const children = getChildren(node);\n // Preserve boundaries between block-level elements (list items, paragraphs\n // inside list items, blockquotes) so downstream consumers like caption\n // splitting can treat each item as a separate phrase.\n const separator = node.type === 'list' || node.type === 'listItem' ? '\\n' : '';\n return children.map(extractPlainText).join(separator);\n}\n\n/**\n * Count the total number of nodes in the tree.\n *\n * @param node - The root node\n * @returns Total node count (including the root)\n */\nexport function countNodes(node: MarkdownNode): number {\n let count = 1;\n const children = getChildren(node);\n for (const child of children) {\n count += countNodes(child);\n }\n return count;\n}\n\n/**\n * Parse a YAML frontmatter string into a key-value record.\n *\n * Handles simple `key: value` pairs common in markdown frontmatter.\n * Values are trimmed; quoted strings have their quotes removed.\n * Returns `null` if parsing fails or the input is empty.\n *\n * @param yaml - The raw YAML string (without the `---` delimiters)\n * @returns A record of string keys to parsed values, or null\n */\nexport function parseFrontmatter(yaml: string): Record<string, unknown> | null {\n if (!yaml || !yaml.trim()) return null;\n\n const result: Record<string, unknown> = {};\n\n for (const line of yaml.split('\\n')) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) continue;\n\n const colonIdx = trimmed.indexOf(':');\n if (colonIdx < 1) continue;\n\n const key = trimmed.slice(0, colonIdx).trim();\n let value: string | boolean | number = trimmed.slice(colonIdx + 1).trim();\n\n // Remove surrounding quotes\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n\n // Parse booleans and numbers\n if (value === 'true') {\n result[key] = true;\n } else if (value === 'false') {\n result[key] = false;\n } else if (value !== '' && !isNaN(Number(value))) {\n result[key] = Number(value);\n } else {\n result[key] = value;\n }\n }\n\n return Object.keys(result).length > 0 ? result : null;\n}\n\nconst FRONTMATTER_BLOCK_RE = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---(\\r?\\n)?/;\n\n/** Quote a frontmatter scalar so it round-trips cleanly through `parseFrontmatter`. */\nfunction formatFrontmatterValue(value: string | number | boolean): string {\n if (typeof value === 'boolean' || typeof value === 'number') return String(value);\n // A single-line JSON object/array literal round-trips verbatim through\n // the line-based `parseFrontmatter` (no leading quote to strip, no\n // newline to split on), so write it unquoted to keep it human-readable\n // — matching how `stringifyMarkdown` emits string values. Used by the\n // compact custom-layouts payload.\n if (/^[{[]/.test(value) && !/[\\r\\n]/.test(value)) return value;\n // Quote when needed: leading/trailing whitespace, leading punctuation that\n // could trigger YAML modes, or values that look like reserved literals.\n const needsQuote =\n /^\\s|\\s$/.test(value) ||\n /^[!&*?|>%@`]/.test(value) ||\n /[:#]/.test(value) ||\n value === '' ||\n value === 'true' ||\n value === 'false' ||\n /^-?\\d+(\\.\\d+)?$/.test(value);\n if (!needsQuote) return value;\n // Prefer double quotes; escape any embedded double-quote / backslash.\n const escaped = value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n return `\"${escaped}\"`;\n}\n\n/**\n * Update a markdown source string's YAML frontmatter block, applying the\n * given key/value updates. A `null` or `undefined` value removes the key.\n * If no frontmatter block exists and any non-null update is supplied, a\n * new block is prepended; if every update is a removal and no block\n * exists, the source is returned unchanged.\n *\n * Existing key order is preserved; new keys are appended in the order\n * they appear in `updates`. The simple parser used here handles plain\n * `key: value` pairs only — comments, multi-line scalars, and nested\n * structures are left untouched (we only rewrite lines whose key matches\n * one in `updates`).\n *\n * @param source - The markdown source string.\n * @param updates - Map of key → new value (or null/undefined to remove).\n * @returns The updated markdown source string.\n */\nexport function setFrontmatterValues(\n source: string,\n updates: Record<string, string | number | boolean | null | undefined>,\n): string {\n const updateKeys = Object.keys(updates);\n if (updateKeys.length === 0) return source;\n\n const match = source.match(FRONTMATTER_BLOCK_RE);\n const handled = new Set<string>();\n\n // Existing frontmatter block — rewrite line-by-line, preserving order.\n if (match) {\n const inner = match[1];\n const lines = inner.split(/\\r?\\n/);\n const newLines: string[] = [];\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) {\n newLines.push(line);\n continue;\n }\n const colonIdx = trimmed.indexOf(':');\n if (colonIdx < 1) {\n newLines.push(line);\n continue;\n }\n const key = trimmed.slice(0, colonIdx).trim();\n if (!Object.prototype.hasOwnProperty.call(updates, key)) {\n newLines.push(line);\n continue;\n }\n handled.add(key);\n const next = updates[key];\n if (next === null || next === undefined) continue; // remove\n newLines.push(`${key}: ${formatFrontmatterValue(next)}`);\n }\n\n // Append any keys that weren't already present.\n for (const key of updateKeys) {\n if (handled.has(key)) continue;\n const next = updates[key];\n if (next === null || next === undefined) continue;\n newLines.push(`${key}: ${formatFrontmatterValue(next)}`);\n }\n\n // If every line got removed, drop the block entirely.\n const nonEmpty = newLines.filter((l) => l.trim().length > 0);\n const rest = source.slice(match[0].length);\n if (nonEmpty.length === 0) return rest;\n return `---\\n${newLines.join('\\n')}\\n---\\n${rest}`;\n }\n\n // No existing block — only create one if there's at least one non-null\n // value to write.\n const fresh: string[] = [];\n for (const key of updateKeys) {\n const next = updates[key];\n if (next === null || next === undefined) continue;\n fresh.push(`${key}: ${formatFrontmatterValue(next)}`);\n }\n if (fresh.length === 0) return source;\n return `---\\n${fresh.join('\\n')}\\n---\\n${source}`;\n}\n\n/**\n * Create a minimal MarkdownDocument from a list of block nodes.\n * Convenience function for programmatic document construction.\n */\nexport function createDocument(...children: MarkdownDocument['children']): MarkdownDocument {\n return {\n type: 'document',\n children,\n };\n}\n\n/**\n * Infer a human-readable title for a markdown document.\n *\n * Resolution order:\n * 1. `title:` value in YAML frontmatter (when present and non-empty)\n * 2. Text of the first heading found, walking top-level depth (H1, then\n * H2, etc.) — the shallowest heading wins regardless of source order\n *\n * Returns `undefined` when no usable title is found.\n */\nexport function inferDocumentTitle(doc: MarkdownDocument): string | undefined {\n const fmTitle = doc.frontmatter?.title;\n if (typeof fmTitle === 'string') {\n const trimmed = fmTitle.trim();\n if (trimmed) return trimmed;\n }\n\n let best: { depth: number; text: string } | null = null;\n for (const node of doc.children) {\n if (node.type !== 'heading') continue;\n const text = extractPlainText(node).trim();\n if (!text) continue;\n if (best === null || node.depth < best.depth) {\n best = { depth: node.depth, text };\n if (best.depth === 1) break;\n }\n }\n\n return best?.text;\n}\n\n/**\n * Read a theme id from a markdown document's frontmatter.\n *\n * Checks the editor's canonical `squisq-theme` key first, then the\n * shorter legacy aliases (`themeId`, `theme`). Returns `undefined`\n * when none of them carry a non-empty string. Centralizing the lookup\n * keeps the export pipelines (DOCX, PPTX, HTML, plain-HTML bundle) in\n * sync with whatever the editor writes — adding a new frontmatter\n * spelling later is a one-file change.\n */\nexport function readFrontmatterThemeId(\n frontmatter: Record<string, unknown> | undefined,\n): string | undefined {\n if (!frontmatter) return undefined;\n const keys = ['squisq-theme', 'themeId', 'theme'] as const;\n for (const key of keys) {\n const raw = frontmatter[key];\n if (typeof raw === 'string') {\n const trimmed = raw.trim();\n if (trimmed) return trimmed;\n }\n }\n return undefined;\n}\n\n/**\n * Project an inline-HTML string (as stored on `TextLayer.content.html`) down\n * to plain text — the value mirrored into `content.text` for plain consumers\n * (PDF/markdown export, search, accessibility) and the SVG `<text>` fallback.\n *\n * `<br>` and block-level tags (`p`, `div`, `h1`–`h6`, `li`, `blockquote`,\n * `pre`) become line breaks so multi-line rich content reads sensibly. Entity\n * decoding is handled by {@link parseHtmlToNodes} (parse5-backed), so this is\n * more correct than a regex tag-stripper.\n */\nexport function plainTextFromInlineHtml(html: string): string {\n const BLOCK = new Set([\n 'p',\n 'div',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'li',\n 'blockquote',\n 'pre',\n ]);\n const walk = (nodes: HtmlNode[]): string =>\n nodes\n .map((n) => {\n if (n.type === 'htmlText') return n.value;\n if (n.type !== 'htmlElement') return '';\n const tag = n.tagName.toLowerCase();\n if (tag === 'br') return '\\n';\n const inner = walk(n.children);\n return BLOCK.has(tag) ? `${inner}\\n` : inner;\n })\n .join('');\n return walk(parseHtmlToNodes(html))\n .replace(/\\u00A0/g, ' ')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim();\n}\n"],"mappings":";AAQA,SAAS,gBAAgB;AAWzB,IAAM,oBAA4C;AAAA,EAChD,WAAW;AAAA,EACX,SAAS;AAAA,EACT,WAAW;AAAA,EACX,eAAe;AACjB;AAGA,IAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAKD,SAAS,oBAAoB,MAAsB;AACjD,MAAI,kBAAkB,IAAI,EAAG,QAAO,kBAAkB,IAAI;AAG1D,MAAI,KAAK,SAAS,KAAK,KAAK,WAAW,MAAM,KAAK,KAAK,CAAC,KAAK,OAAO,KAAK,CAAC,KAAK,KAAK;AAClF,WACE,UACA,KACG,MAAM,CAAC,EACP,QAAQ,UAAU,CAAC,MAAM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wB,MAAsB;AAC5D,QAAM,QAAQ,oBAAI,IAAI;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,OAAO,CAAC,UACZ,MACG,IAAI,CAAC,MAAM;AACV,QAAI,EAAE,SAAS,WAAY,QAAO,EAAE;AACpC,QAAI,EAAE,SAAS,cAAe,QAAO;AACrC,UAAM,MAAM,EAAE,QAAQ,YAAY;AAClC,QAAI,QAAQ,KAAM,QAAO;AACzB,UAAM,QAAQ,KAAK,EAAE,QAAQ;AAC7B,WAAO,MAAM,IAAI,GAAG,IAAI,GAAG,KAAK;AAAA,IAAO;AAAA,EACzC,CAAC,EACA,KAAK,EAAE;AACZ,SAAO,KAAK,iBAAiB,IAAI,CAAC,EAC/B,QAAQ,WAAW,GAAG,EACtB,QAAQ,WAAW,MAAM,EACzB,KAAK;AACV;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-PGGGKYWG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -38,9 +38,7 @@ function getNeighbors(hash) {
38
38
  return ngeohash.neighbors(hash);
39
39
  }
40
40
  function getGeohash4Neighbors(geohash4) {
41
- if (geohash4.length !== 4) {
42
- throw new Error(`getGeohash4Neighbors requires 4-char geohash, got: ${geohash4}`);
43
- }
41
+ if (geohash4.length !== 4) return [];
44
42
  const neighbors = getNeighbors(geohash4);
45
43
  return [geohash4, ...neighbors];
46
44
  }
@@ -48,9 +46,7 @@ function getGeohashPrefix(geohash, precision) {
48
46
  return geohash.slice(0, precision);
49
47
  }
50
48
  function geohashToHierarchicalPath(geohash4) {
51
- if (geohash4.length !== 4) {
52
- throw new Error(`geohashToHierarchicalPath requires 4-char geohash, got: ${geohash4}`);
53
- }
49
+ if (geohash4.length !== 4) return "";
54
50
  const [c1, c2, c3, c4] = geohash4.split("");
55
51
  return `${c1}/${c2}/${c3}/${c4}`;
56
52
  }
@@ -58,19 +54,44 @@ function getGeohashPath(from, to, precision = 4) {
58
54
  if (from === to) return [];
59
55
  const fromCenter = decodeGeohash(from);
60
56
  const toCenter = decodeGeohash(to);
61
- const dLat = Math.abs(toCenter.lat - fromCenter.lat);
62
- const dLng = Math.abs(toCenter.lng - fromCenter.lng);
63
- const midLatRad = (fromCenter.lat + toCenter.lat) / 2 * (Math.PI / 180);
64
- const approxKm = Math.sqrt((dLat * 111) ** 2 + (dLng * 111 * Math.cos(midLatRad)) ** 2);
65
- const steps = Math.max(2, Math.ceil(approxKm / 15));
57
+ const distKm = haversineDistance(
58
+ { lat: fromCenter.lat, lng: fromCenter.lng },
59
+ { lat: toCenter.lat, lng: toCenter.lng }
60
+ );
61
+ const steps = Math.max(2, Math.ceil(distKm / 15));
62
+ const \u03C61 = fromCenter.lat * Math.PI / 180;
63
+ const \u03BB1 = fromCenter.lng * Math.PI / 180;
64
+ const \u03C62 = toCenter.lat * Math.PI / 180;
65
+ const \u03BB2 = toCenter.lng * Math.PI / 180;
66
+ const x1 = Math.cos(\u03C61) * Math.cos(\u03BB1);
67
+ const y1 = Math.cos(\u03C61) * Math.sin(\u03BB1);
68
+ const z1 = Math.sin(\u03C61);
69
+ const x2 = Math.cos(\u03C62) * Math.cos(\u03BB2);
70
+ const y2 = Math.cos(\u03C62) * Math.sin(\u03BB2);
71
+ const z2 = Math.sin(\u03C62);
72
+ const dot = Math.max(-1, Math.min(1, x1 * x2 + y1 * y2 + z1 * z2));
73
+ const d = Math.acos(dot);
74
+ const useLinear = Math.abs(Math.sin(d)) < 1e-10;
66
75
  const seen = /* @__PURE__ */ new Set();
67
76
  seen.add(from);
68
77
  seen.add(to);
69
78
  const path = [];
70
79
  for (let i = 1; i < steps; i++) {
71
80
  const t = i / steps;
72
- const lat = fromCenter.lat + t * (toCenter.lat - fromCenter.lat);
73
- const lng = fromCenter.lng + t * (toCenter.lng - fromCenter.lng);
81
+ let lat;
82
+ let lng;
83
+ if (useLinear) {
84
+ lat = fromCenter.lat + t * (toCenter.lat - fromCenter.lat);
85
+ lng = fromCenter.lng + t * (toCenter.lng - fromCenter.lng);
86
+ } else {
87
+ const A = Math.sin((1 - t) * d) / Math.sin(d);
88
+ const B = Math.sin(t * d) / Math.sin(d);
89
+ const x = A * x1 + B * x2;
90
+ const y = A * y1 + B * y2;
91
+ const z = A * z1 + B * z2;
92
+ lat = Math.atan2(z, Math.sqrt(x * x + y * y)) * 180 / Math.PI;
93
+ lng = Math.atan2(y, x) * 180 / Math.PI;
94
+ }
74
95
  const hash = encodeGeohash(lat, lng, precision);
75
96
  if (!seen.has(hash)) {
76
97
  seen.add(hash);
@@ -100,4 +121,4 @@ export {
100
121
  getGeohashPath,
101
122
  geohashOverlapsBounds
102
123
  };
103
- //# sourceMappingURL=chunk-7UDSRZKG.js.map
124
+ //# sourceMappingURL=chunk-Q3ROPT5H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spatial/Haversine.ts","../src/spatial/Geohash.ts"],"sourcesContent":["/**\n * Haversine Distance Calculation\n *\n * Provides accurate distance calculation between two geographic coordinates\n * using the Haversine formula, which accounts for Earth's curvature.\n */\n\nimport type { Coordinates } from '../schemas/Types.js';\n\n/**\n * Calculate distance between two coordinates using Haversine formula.\n *\n * @param from Start coordinates\n * @param to End coordinates\n * @returns Distance in kilometers\n */\nexport function haversineDistance(from: Coordinates, to: Coordinates): number {\n const R = 6371; // Earth's radius in kilometers\n\n const dLat = toRadians(to.lat - from.lat);\n const dLng = toRadians(to.lng - from.lng);\n\n const a =\n Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(toRadians(from.lat)) *\n Math.cos(toRadians(to.lat)) *\n Math.sin(dLng / 2) *\n Math.sin(dLng / 2);\n\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\n return R * c;\n}\n\n/**\n * Calculate bearing from one coordinate to another.\n *\n * @param from Start coordinates\n * @param to End coordinates\n * @returns Bearing in degrees (0-360, where 0 = north, 90 = east)\n */\nexport function calculateBearing(from: Coordinates, to: Coordinates): number {\n const dLng = toRadians(to.lng - from.lng);\n const lat1 = toRadians(from.lat);\n const lat2 = toRadians(to.lat);\n\n const x = Math.sin(dLng) * Math.cos(lat2);\n const y = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLng);\n\n const bearing = Math.atan2(x, y);\n return ((bearing * 180) / Math.PI + 360) % 360;\n}\n\n/**\n * Convert degrees to radians.\n */\nfunction toRadians(degrees: number): number {\n return (degrees * Math.PI) / 180;\n}\n","/**\n * Geohash Utilities\n *\n * Provides geohash encoding/decoding and spatial utilities using the standard\n * ngeohash library for core operations, plus custom utilities for overlap checking\n * and distance calculation.\n *\n * Geohashes are a hierarchical spatial indexing system that divides the world\n * into a grid of cells. Each additional character narrows the area by ~1/32.\n *\n * Precision guide:\n * - 4 chars: ~39km x 19km (used for tile indexing)\n * - 5 chars: ~5km x 5km\n * - 6 chars: ~1.2km x 0.6km\n */\n\nimport ngeohash from 'ngeohash';\nimport { haversineDistance } from './Haversine.js';\n\n/**\n * Encode latitude/longitude to a geohash string.\n * Uses the standard ngeohash library.\n */\nexport function encodeGeohash(lat: number, lng: number, precision = 9): string {\n return ngeohash.encode(lat, lng, precision);\n}\n\n/**\n * Decode a geohash to latitude/longitude center with error bounds.\n * Uses the standard ngeohash library.\n */\nexport function decodeGeohash(hash: string): {\n lat: number;\n lng: number;\n latErr: number;\n lngErr: number;\n} {\n const result = ngeohash.decode(hash);\n return {\n lat: result.latitude,\n lng: result.longitude,\n latErr: result.error.latitude,\n lngErr: result.error.longitude,\n };\n}\n\n/**\n * Get the 8 neighboring geohash cells.\n * Returns up to 8 neighbors (fewer at poles or antimeridian).\n * Uses the standard ngeohash library.\n */\nexport function getNeighbors(hash: string): string[] {\n return ngeohash.neighbors(hash);\n}\n\n/**\n * Get a 3x3 grid of geohash4 cells (center + 8 neighbors).\n * Used for landing bonus expansions in Fly mode.\n *\n * @param geohash4 - Center geohash4 cell\n * @returns Array of 9 geohash4 cells (center first, then neighbors)\n *\n * @example\n * getGeohash4Neighbors('c23n')\n * // => ['c23n', 'c23p', 'c23q', 'c23j', 'c23m', 'c23k', 'c23h', 'c23e', 'c23s']\n */\nexport function getGeohash4Neighbors(geohash4: string): string[] {\n if (geohash4.length !== 4) return [];\n const neighbors = getNeighbors(geohash4);\n return [geohash4, ...neighbors];\n}\n\n/**\n * Get the prefix of a geohash at a given precision.\n * Simple helper for extracting geohash prefixes for directory organization.\n */\nexport function getGeohashPrefix(geohash: string, precision: number): string {\n return geohash.slice(0, precision);\n}\n\n/**\n * Convert a geohash prefix to a hierarchical path.\n *\n * Examples:\n * \"9mud\" -> \"9/m/u/d\"\n * \"9q8y\" -> \"9/q/8/y\"\n * \"c24k\" -> \"c/2/4/k\"\n *\n * This is used for organizing files in hierarchical directories to avoid\n * thousands of folders in a single directory, which causes filesystem\n * performance issues.\n */\nexport function geohashToHierarchicalPath(geohash4: string): string {\n if (geohash4.length !== 4) return '';\n const [c1, c2, c3, c4] = geohash4.split('');\n return `${c1}/${c2}/${c3}/${c4}`;\n}\n\n/**\n * Compute all geohash cells along the great-circle path between two geohash cells.\n * Samples points along the spherical arc from `from` to `to`, encoding each to a\n * geohash at the given precision, and returns the deduplicated list of intermediate\n * cells (excluding `from` and `to`).\n *\n * Uses spherical linear interpolation (SLERP) via 3D unit vectors, which correctly\n * handles antimeridian crossings and polar paths — both of which flat lat/lng\n * interpolation gets wrong.\n */\nexport function getGeohashPath(from: string, to: string, precision = 4): string[] {\n if (from === to) return [];\n\n const fromCenter = decodeGeohash(from);\n const toCenter = decodeGeohash(to);\n\n // Use haversine for accurate great-circle distance (step sizing)\n const distKm = haversineDistance(\n { lat: fromCenter.lat, lng: fromCenter.lng },\n { lat: toCenter.lat, lng: toCenter.lng },\n );\n\n // Step every ~15km to avoid skipping any geohash4 cell (~39x19km)\n const steps = Math.max(2, Math.ceil(distKm / 15));\n\n // Convert endpoints to unit Cartesian vectors for SLERP\n const φ1 = (fromCenter.lat * Math.PI) / 180;\n const λ1 = (fromCenter.lng * Math.PI) / 180;\n const φ2 = (toCenter.lat * Math.PI) / 180;\n const λ2 = (toCenter.lng * Math.PI) / 180;\n\n const x1 = Math.cos(φ1) * Math.cos(λ1);\n const y1 = Math.cos(φ1) * Math.sin(λ1);\n const z1 = Math.sin(φ1);\n const x2 = Math.cos(φ2) * Math.cos(λ2);\n const y2 = Math.cos(φ2) * Math.sin(λ2);\n const z2 = Math.sin(φ2);\n\n // Central angle between the two points\n const dot = Math.max(-1, Math.min(1, x1 * x2 + y1 * y2 + z1 * z2));\n const d = Math.acos(dot);\n // Near-antipodal fallback: sin(d)≈0 means the great circle is undefined.\n // Extremely unlikely for geohash path use; fall back to linear lat/lng.\n const useLinear = Math.abs(Math.sin(d)) < 1e-10;\n\n const seen = new Set<string>();\n seen.add(from);\n seen.add(to);\n\n const path: string[] = [];\n for (let i = 1; i < steps; i++) {\n const t = i / steps;\n let lat: number;\n let lng: number;\n if (useLinear) {\n lat = fromCenter.lat + t * (toCenter.lat - fromCenter.lat);\n lng = fromCenter.lng + t * (toCenter.lng - fromCenter.lng);\n } else {\n const A = Math.sin((1 - t) * d) / Math.sin(d);\n const B = Math.sin(t * d) / Math.sin(d);\n const x = A * x1 + B * x2;\n const y = A * y1 + B * y2;\n const z = A * z1 + B * z2;\n lat = (Math.atan2(z, Math.sqrt(x * x + y * y)) * 180) / Math.PI;\n lng = (Math.atan2(y, x) * 180) / Math.PI;\n }\n const hash = encodeGeohash(lat, lng, precision);\n if (!seen.has(hash)) {\n seen.add(hash);\n path.push(hash);\n }\n }\n\n return path;\n}\n\n/**\n * Check if a geohash cell overlaps with a bounding box.\n * Custom implementation (not available in ngeohash).\n */\nexport function geohashOverlapsBounds(\n hash: string,\n bounds: { north: number; south: number; east: number; west: number },\n): boolean {\n const { lat, lng, latErr, lngErr } = decodeGeohash(hash);\n\n const hashNorth = lat + latErr;\n const hashSouth = lat - latErr;\n const hashEast = lng + lngErr;\n const hashWest = lng - lngErr;\n\n return !(\n hashNorth < bounds.south ||\n hashSouth > bounds.north ||\n hashEast < bounds.west ||\n hashWest > bounds.east\n );\n}\n\n// Re-export for backwards compatibility with existing imports.\nexport { haversineDistance };\n"],"mappings":";AAgBO,SAAS,kBAAkB,MAAmB,IAAyB;AAC5E,QAAM,IAAI;AAEV,QAAM,OAAO,UAAU,GAAG,MAAM,KAAK,GAAG;AACxC,QAAM,OAAO,UAAU,GAAG,MAAM,KAAK,GAAG;AAExC,QAAM,IACJ,KAAK,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,IACtC,KAAK,IAAI,UAAU,KAAK,GAAG,CAAC,IAC1B,KAAK,IAAI,UAAU,GAAG,GAAG,CAAC,IAC1B,KAAK,IAAI,OAAO,CAAC,IACjB,KAAK,IAAI,OAAO,CAAC;AAErB,QAAM,IAAI,IAAI,KAAK,MAAM,KAAK,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC;AAEvD,SAAO,IAAI;AACb;AASO,SAAS,iBAAiB,MAAmB,IAAyB;AAC3E,QAAM,OAAO,UAAU,GAAG,MAAM,KAAK,GAAG;AACxC,QAAM,OAAO,UAAU,KAAK,GAAG;AAC/B,QAAM,OAAO,UAAU,GAAG,GAAG;AAE7B,QAAM,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI;AACxC,QAAM,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI;AAE3F,QAAM,UAAU,KAAK,MAAM,GAAG,CAAC;AAC/B,UAAS,UAAU,MAAO,KAAK,KAAK,OAAO;AAC7C;AAKA,SAAS,UAAU,SAAyB;AAC1C,SAAQ,UAAU,KAAK,KAAM;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