allyhub 0.16.0 → 0.17.1

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 (277) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/commands/inspect/index.js +1 -1
  3. package/dist/commands/inspect/uses.js +3 -0
  4. package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
  5. package/dist/node_modules/@allyhub/audio/dist/index.js +1 -1
  6. package/dist/node_modules/@allyhub/audio/dist/place.js +2 -0
  7. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  8. package/dist/node_modules/@allyhub/browser/package.json +1 -1
  9. package/dist/node_modules/@allyhub/build/dist/content.d.ts +7 -0
  10. package/dist/node_modules/@allyhub/build/dist/imports.d.ts +17 -0
  11. package/dist/node_modules/@allyhub/build/dist/imports.js +2 -0
  12. package/dist/node_modules/@allyhub/build/dist/index.d.ts +2 -1
  13. package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
  14. package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +19 -3
  15. package/dist/node_modules/@allyhub/build/dist/prepare.js +3 -3
  16. package/dist/node_modules/@allyhub/build/dist/uses.d.ts +27 -6
  17. package/dist/node_modules/@allyhub/build/dist/uses.js +1 -1
  18. package/dist/node_modules/@allyhub/build/package.json +1 -1
  19. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  20. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  21. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  22. package/dist/node_modules/@allyhub/check/package.json +1 -1
  23. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  24. package/dist/node_modules/@allyhub/components/package.json +1 -1
  25. package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
  26. package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
  27. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  28. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  29. package/dist/node_modules/@allyhub/doc/dist/docx.js +4 -4
  30. package/dist/node_modules/@allyhub/doc/dist/html.js +40 -40
  31. package/dist/node_modules/@allyhub/doc/dist/index.js +1 -1
  32. package/dist/node_modules/@allyhub/doc/dist/markdown.js +1 -1
  33. package/dist/node_modules/@allyhub/doc/dist/parse.js +4 -4
  34. package/dist/node_modules/@allyhub/doc/dist/table.js +1 -1
  35. package/dist/node_modules/@allyhub/doc/dist/write.js +26 -26
  36. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  37. package/dist/node_modules/@allyhub/doc-extension/dist/build.js +2 -2
  38. package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
  39. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  40. package/dist/node_modules/@allyhub/export/dist/export.js +1 -1
  41. package/dist/node_modules/@allyhub/export/package.json +1 -1
  42. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  43. package/dist/node_modules/@allyhub/extension-host/dist/points.js +1 -1
  44. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  45. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +15 -3
  46. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  47. package/dist/node_modules/@allyhub/formats/dist/items.d.ts +40 -7
  48. package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
  49. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +4 -0
  50. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  51. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  52. package/dist/node_modules/@allyhub/image-draw/dist/stage.js +1 -1
  53. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  54. package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
  55. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  56. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  57. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  58. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  59. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  60. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  61. package/dist/node_modules/@allyhub/linkedin-extension/package.json +3 -1
  62. package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
  63. package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
  64. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  65. package/dist/node_modules/@allyhub/media/package.json +1 -1
  66. package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
  67. package/dist/node_modules/@allyhub/model/package.json +1 -1
  68. package/dist/node_modules/@allyhub/office-extension/package.json +1 -1
  69. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  70. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +15 -0
  71. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -0
  72. package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
  73. package/dist/node_modules/@allyhub/piece/dist/page/runtimes.d.ts +9 -0
  74. package/dist/node_modules/@allyhub/piece/dist/page/runtimes.js +2 -0
  75. package/dist/node_modules/@allyhub/piece/dist/source.d.ts +51 -10
  76. package/dist/node_modules/@allyhub/piece/dist/source.js +1 -1
  77. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  78. package/dist/node_modules/@allyhub/project/dist/digest.js +1 -1
  79. package/dist/node_modules/@allyhub/project/dist/part-keys.js +1 -1
  80. package/dist/node_modules/@allyhub/project/package.json +1 -1
  81. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +0 -6
  82. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  83. package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +39 -0
  84. package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
  85. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +3 -0
  86. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  87. package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +30 -0
  88. package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
  89. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +6 -0
  90. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  91. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  92. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  93. package/dist/node_modules/@allyhub/render/package.json +1 -1
  94. package/dist/node_modules/@allyhub/runtime/dist/compose.js +1 -1
  95. package/dist/node_modules/@allyhub/runtime/dist/embed.js +1 -1
  96. package/dist/node_modules/@allyhub/runtime/dist/film.js +1 -1
  97. package/dist/node_modules/@allyhub/runtime/dist/piece.js +2 -2
  98. package/dist/node_modules/@allyhub/runtime/dist/player/player.js +1 -1
  99. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  100. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  101. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  102. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  103. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  104. package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
  105. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
  106. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
  107. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
  108. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/dynamic.js +1 -1
  109. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
  110. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/logical.js +1 -1
  111. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
  112. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
  113. package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
  114. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  115. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  116. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  117. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  118. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  119. package/dist/node_modules/@allyhub/sheet-extension/dist/build.js +1 -1
  120. package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
  121. package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
  122. package/dist/node_modules/@allyhub/slides-core/dist/api.js +1 -1
  123. package/dist/node_modules/@allyhub/slides-core/dist/components.js +1 -1
  124. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  125. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  126. package/dist/node_modules/@allyhub/slides-extension/dist/build.js +2 -1
  127. package/dist/node_modules/@allyhub/slides-extension/dist/deck-pptx.js +1 -1
  128. package/dist/node_modules/@allyhub/slides-extension/dist/evaluate.js +2 -2
  129. package/dist/node_modules/@allyhub/slides-extension/dist/export.js +1 -1
  130. package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
  131. package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
  132. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  133. package/dist/node_modules/@allyhub/slides-runtime/dist/component.js +1 -1
  134. package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
  135. package/dist/node_modules/@allyhub/slides-runtime/dist/item.js +2 -0
  136. package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
  137. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  138. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  139. package/dist/node_modules/@allyhub/stage-page/dist/install.js +1 -1
  140. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  141. package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +19 -19
  142. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  143. package/dist/node_modules/@allyhub/telemetry/package.json +1 -1
  144. package/dist/node_modules/@allyhub/text-extension/package.json +1 -1
  145. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  146. package/dist/node_modules/@allyhub/video-extension/dist/build.js +1 -1
  147. package/dist/node_modules/@allyhub/video-extension/package.json +1 -1
  148. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  149. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  150. package/dist/node_modules/@allyhub/website/package.json +1 -1
  151. package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
  152. package/dist/node_modules/@allyhub/x-extension/package.json +3 -1
  153. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  154. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  155. package/dist/package.json +13 -13
  156. package/dist/works.js +1 -1
  157. package/editor-web/assets/{abnfDiagram-WEYOIA3C-B1AxOB-Y.js → abnfDiagram-WEYOIA3C-CHNpVSPv.js} +1 -1
  158. package/editor-web/assets/{architecture-WOLXFQ4H-C-7xKJ2Z.js → architecture-WOLXFQ4H-gPsJqQwV.js} +1 -1
  159. package/editor-web/assets/{architectureDiagram-ZHVYKT53-CyWb8_iD.js → architectureDiagram-ZHVYKT53-CEIDcC6r.js} +1 -1
  160. package/editor-web/assets/{article-qt4W_BKH.js → article-BHTjq0_Y.js} +1 -1
  161. package/editor-web/assets/{article-CTKW7Eo0.js → article-DfELjJ2o.js} +1 -1
  162. package/editor-web/assets/{blockDiagram-RJAE7QA3-uii4-7Ix.js → blockDiagram-RJAE7QA3-CUzEGVet.js} +1 -1
  163. package/editor-web/assets/{c4Diagram-XDPPPE54-BtL5Z-wF.js → c4Diagram-XDPPPE54-CB94NR9s.js} +1 -1
  164. package/editor-web/assets/calc-worker-BdHh5LXM.js +45 -0
  165. package/editor-web/assets/channel-DCDCx5Es.js +1 -0
  166. package/editor-web/assets/{chart-file-HE-uXGmJ.js → chart-file-CfbWK9l1.js} +1 -1
  167. package/editor-web/assets/{chunk-2E7WHVMD-BJjuZYBs.js → chunk-2E7WHVMD-DFYo_Boi.js} +1 -1
  168. package/editor-web/assets/{chunk-4EMNKR2T-nzPdUHaI.js → chunk-4EMNKR2T-CLLjmweX.js} +1 -1
  169. package/editor-web/assets/{chunk-55XCU76K-CH52E3Nl.js → chunk-55XCU76K-CkwQ_3m1.js} +1 -1
  170. package/editor-web/assets/{chunk-7S6XSTFO-Ba4LNKCV.js → chunk-7S6XSTFO-V-AvHpAB.js} +1 -1
  171. package/editor-web/assets/{chunk-AQDTSKZB-Co9SmoqD.js → chunk-AQDTSKZB-PjHyYpb8.js} +1 -1
  172. package/editor-web/assets/{chunk-DSNLSHJZ-BHRvxRGi.js → chunk-DSNLSHJZ-QaczBS3J.js} +1 -1
  173. package/editor-web/assets/{chunk-HAGFOTED-F5Wd8ETY.js → chunk-HAGFOTED-aLaQB5Xu.js} +1 -1
  174. package/editor-web/assets/{chunk-HNE4Q36P-C_E0__p9.js → chunk-HNE4Q36P-De3ftDQR.js} +1 -1
  175. package/editor-web/assets/{chunk-NQOKRVIF-BvrtbbWm.js → chunk-NQOKRVIF-CrhVQyvP.js} +1 -1
  176. package/editor-web/assets/{chunk-UHW7PFBP-D0HTPXRF.js → chunk-UHW7PFBP-BFmZ5ZLn.js} +1 -1
  177. package/editor-web/assets/{chunk-VQ5W62QI-B9hF2YMk.js → chunk-VQ5W62QI-CzppUHLA.js} +1 -1
  178. package/editor-web/assets/{chunk-WQQL4CDK-D7N3o-Ub.js → chunk-WQQL4CDK-BrAU7V6v.js} +1 -1
  179. package/editor-web/assets/{chunk-YZO67HFG-XaLSrI_W.js → chunk-YZO67HFG-BSiF71qj.js} +1 -1
  180. package/editor-web/assets/{chunk-ZAUX2LTX-sXc6qmw-.js → chunk-ZAUX2LTX-BJc4r5b1.js} +1 -1
  181. package/editor-web/assets/{chunk-ZCHMQSOR-B0X6sNMX.js → chunk-ZCHMQSOR-CkGTuehB.js} +1 -1
  182. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-CjXVvOUp.js → classDiagram-v2-4MYWR3UA-Byxc7J88.js} +1 -1
  183. package/editor-web/assets/{cynefin-EF2NZ3EQ-PQ9VyM9v.js → cynefin-EF2NZ3EQ-BSxkVbdf.js} +1 -1
  184. package/editor-web/assets/{cynefinDiagram-WF24UDRP-KXuXFAhX.js → cynefinDiagram-WF24UDRP-IkCgARNs.js} +1 -1
  185. package/editor-web/assets/{dagre-NK4GIZVX-CBTyfYD5.js → dagre-NK4GIZVX-9PgeH6nY.js} +1 -1
  186. package/editor-web/assets/deck-tTzKONci.js +1 -0
  187. package/editor-web/assets/{diagram-CBK3MWTC-CsVO64Bf.js → diagram-CBK3MWTC-DRzeg3Ds.js} +1 -1
  188. package/editor-web/assets/{diagram-I5XIIV2D-fzbUm1St.js → diagram-I5XIIV2D-B_zeKMN6.js} +1 -1
  189. package/editor-web/assets/{diagram-ODIL2UCW-up6ihgN5.js → diagram-ODIL2UCW-FFm0O8SN.js} +1 -1
  190. package/editor-web/assets/{diagram-PFBEJUXE-T6hVBoCD.js → diagram-PFBEJUXE-DrtCT8OA.js} +1 -1
  191. package/editor-web/assets/{diagram-RJA3I4VV-BDntFeuR.js → diagram-RJA3I4VV-DtxJ3V0q.js} +1 -1
  192. package/editor-web/assets/{diagram-TYUNFSNR-Dv1-mqbf.js → diagram-TYUNFSNR-DmxF_8H_.js} +1 -1
  193. package/editor-web/assets/dist-BEpzsYn_.js +6 -0
  194. package/editor-web/assets/dist-BUD4ywMB.js +18 -0
  195. package/editor-web/assets/{dist-aTV6Rwon.js → dist-C21CkR7Z.js} +132 -131
  196. package/editor-web/assets/{dist-DhMagA-B.js → dist-C56mWAec.js} +1 -1
  197. package/editor-web/assets/{dist-B-lYrbqX.js → dist-CAb3W9_P.js} +1 -1
  198. package/editor-web/assets/{dist-Bfs4cZI_.js → dist-CEknsRDd.js} +1 -1
  199. package/editor-web/assets/{dist-C66KgS8g.js → dist-CbZAznNW.js} +2 -2
  200. package/editor-web/assets/{dist-Ba5Kv4A-.js → dist-DDzjbKIg.js} +1 -1
  201. package/editor-web/assets/{dist-CWXGbcPB.js → dist-DaEbElXI.js} +1 -1
  202. package/editor-web/assets/{dist-_ooK0TT9.js → dist-Dr3o4vee.js} +1 -1
  203. package/editor-web/assets/{dist-mrWPE-br.js → dist-JLyDtl9X.js} +1 -1
  204. package/editor-web/assets/{dist-BW8IR8bR.js → dist-PBbWAsrV.js} +3 -3
  205. package/editor-web/assets/{dist-CBeeIAlh.js → dist-ZZlQa66J.js} +1 -1
  206. package/editor-web/assets/{dist-CHKVUdcE.js → dist-bQKpw3Zz.js} +5 -5
  207. package/editor-web/assets/dist-d4dayaWE.js +17 -0
  208. package/editor-web/assets/{docx-draw-CeiLkccT.js → docx-draw-9Q_fArBC.js} +1 -1
  209. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-CZzljBYN.js → ebnfDiagram-V4P3TTPT-DSX1Aoty.js} +1 -1
  210. package/editor-web/assets/{elk-QONTBCTQ-6vNb82av.js → elk-QONTBCTQ-C7gy9q56.js} +1 -1
  211. package/editor-web/assets/{erDiagram-KYQIGQAA-B8smxURG.js → erDiagram-KYQIGQAA-CKx_HoY4.js} +1 -1
  212. package/editor-web/assets/esm-BZb5QMQf.js +21 -0
  213. package/editor-web/assets/{eventmodeling-K75KTNOO-CngIhoUF.js → eventmodeling-K75KTNOO-DL4HvSrd.js} +1 -1
  214. package/editor-web/assets/flowDiagram-IUGLLWBU-BUnRtJ8q.js +1 -0
  215. package/editor-web/assets/{ganttDiagram-R7GPNTJY-BtzqHUiP.js → ganttDiagram-R7GPNTJY-N-AP4slN.js} +1 -1
  216. package/editor-web/assets/{gitGraph-VSP46ZUC-DOOpoQDh.js → gitGraph-VSP46ZUC-BKRGJKWm.js} +1 -1
  217. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-Cu4T8UUo.js → gitGraphDiagram-PDYL7XHY-ClwL7w2_.js} +1 -1
  218. package/editor-web/assets/index-BedbINE5.css +2 -0
  219. package/editor-web/assets/index-DG2nHq4D.js +28 -0
  220. package/editor-web/assets/{info-OHQRW6UA-CiNozx0c.js → info-OHQRW6UA-DpcY8t23.js} +1 -1
  221. package/editor-web/assets/{infoDiagram-MVDRKAX5-A3mxzTmc.js → infoDiagram-MVDRKAX5-ChtmtWni.js} +1 -1
  222. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-CIbVgY0Z.js → ishikawaDiagram-HPEHV2GE-BZNTuG_F.js} +1 -1
  223. package/editor-web/assets/{journeyDiagram-BOSHW7O7-BwPXFmyS.js → journeyDiagram-BOSHW7O7-C3uVmZbL.js} +1 -1
  224. package/editor-web/assets/{kanban-definition-FNSA4HC5-biRlEeb1.js → kanban-definition-FNSA4HC5-puEhftGG.js} +1 -1
  225. package/editor-web/assets/{mermaid-parser.core-ikwPmNne.js → mermaid-parser.core-Bw8re-WE.js} +3 -3
  226. package/editor-web/assets/{mermaid.core-B4GR7QVa.js → mermaid.core-Cc2GIqBr.js} +4 -4
  227. package/editor-web/assets/{mindmap-definition-6OY57UG3-BN8aiUmO.js → mindmap-definition-6OY57UG3-C6MUl_S_.js} +1 -1
  228. package/editor-web/assets/{packet-JDAUHWVQ-DWesZv6p.js → packet-JDAUHWVQ-C75RnvC5.js} +1 -1
  229. package/editor-web/assets/{pegDiagram-ECIUJNBX-Bh3QEAL_.js → pegDiagram-ECIUJNBX-ChjmsdV4.js} +1 -1
  230. package/editor-web/assets/{pie-XZMESJXO-DT1ANL51.js → pie-XZMESJXO-BaKxJQpj.js} +1 -1
  231. package/editor-web/assets/{pieDiagram-GNMPY74T-xXxgiv6O.js → pieDiagram-GNMPY74T-CT2ez8pr.js} +1 -1
  232. package/editor-web/assets/{props-form-BwZY8ZWd.js → props-form-D5oKHfpk.js} +1 -1
  233. package/editor-web/assets/{quadrantDiagram-D57K4MC3-BGzRd8iZ.js → quadrantDiagram-D57K4MC3-BJItlTfk.js} +1 -1
  234. package/editor-web/assets/{radar-ABXABTNO-C-rmMB0D.js → radar-ABXABTNO-DnLzBlTo.js} +1 -1
  235. package/editor-web/assets/{railroad-I3PHUGI6-CvLOq2i8.js → railroad-I3PHUGI6-D5hj6Yv3.js} +1 -1
  236. package/editor-web/assets/{railroad-abnf-LNEFI6M7-DMsb025s.js → railroad-abnf-LNEFI6M7-DUZlZoPu.js} +1 -1
  237. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-5bvVcIvh.js → railroad-ebnf-DWYD2UWJ-CDyyDC6d.js} +1 -1
  238. package/editor-web/assets/{railroad-peg-JR7BVNR7-LKZ9-9ja.js → railroad-peg-JR7BVNR7-CC3ImNnT.js} +1 -1
  239. package/editor-web/assets/{railroadDiagram-Y72NRBL7-DVBhzkmC.js → railroadDiagram-Y72NRBL7-Bjw-8Se5.js} +1 -1
  240. package/editor-web/assets/{requirementDiagram-EQYSW5RA-B5RyzWna.js → requirementDiagram-EQYSW5RA-CDFnuEIO.js} +1 -1
  241. package/editor-web/assets/{sankeyDiagram-SY24JHO5-BvOJG-gB.js → sankeyDiagram-SY24JHO5-CQPVLY1w.js} +1 -1
  242. package/editor-web/assets/{schemas-BmdNnDyt.js → schemas-moE_A7Nj.js} +1 -1
  243. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-BI7-Daqy.js → sequenceDiagram-BLEHNHQU-BQzuLmBX.js} +1 -1
  244. package/editor-web/assets/{session-D8E3nUwU.js → session-s1I85rox.js} +1 -1
  245. package/editor-web/assets/{slides-bj0WJT_G.js → slides-oQ_C0SVJ.js} +1 -1
  246. package/editor-web/assets/snapshots-BPJKywuN.js +1 -0
  247. package/editor-web/assets/{split-BrF9ECYb.js → split-7CVjIkSU.js} +1 -1
  248. package/editor-web/assets/square-arrow-out-up-right-DF5dvsSp.js +1 -0
  249. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-C01p8WHX.js → stateDiagram-v2-A6IESKWZ-DOuageUf.js} +1 -1
  250. package/editor-web/assets/{swimlanes-B3ENRKFQ-B00P2SqG.js → swimlanes-B3ENRKFQ-CXKkok7X.js} +1 -1
  251. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-C3Car2M0.js +8 -0
  252. package/editor-web/assets/{tabs-CloHB5Z4.js → tabs-CiF1N-pL.js} +1 -1
  253. package/editor-web/assets/{timeline-definition-JXYKGLGB-BIBoOYJY.js → timeline-definition-JXYKGLGB-DgAjAeZp.js} +1 -1
  254. package/editor-web/assets/{treeView-D4JQ5SDB-CL6DL8V0.js → treeView-D4JQ5SDB-C0Xvnhck.js} +1 -1
  255. package/editor-web/assets/{treemap-SAJKECNS-CPLGr0WY.js → treemap-SAJKECNS-aXfKAeSX.js} +1 -1
  256. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-L03lK2bO.js → usecaseDiagram-WPOLBNNX-CvUlBa-L.js} +1 -1
  257. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-B5tKKP_-.js → vennDiagram-Q3Y3IDCW-qMJ1iCxs.js} +1 -1
  258. package/editor-web/assets/{video-BWUznyLR.js → video-DQrjo1TI.js} +1 -1
  259. package/editor-web/assets/{wardley-7MLQ67FV-vsBpXT56.js → wardley-7MLQ67FV-DEdnH0by.js} +1 -1
  260. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-CMCnVUgh.js → wardleyDiagram-IVAIDKWA-Bt-B2hQ5.js} +1 -1
  261. package/editor-web/assets/workbook-FSSUiIp9.js +45 -0
  262. package/editor-web/assets/{xychartDiagram-4URNHDU4-C9XkBiEO.js → xychartDiagram-4URNHDU4-DV4bSzTb.js} +1 -1
  263. package/editor-web/index.html +3 -3
  264. package/package.json +2 -2
  265. package/editor-web/assets/calc-worker-jImBXoeb.js +0 -45
  266. package/editor-web/assets/channel-dEO-yacZ.js +0 -1
  267. package/editor-web/assets/deck-C-p17098.js +0 -1
  268. package/editor-web/assets/dist-B94TkgAP.js +0 -18
  269. package/editor-web/assets/dist-DxcrMrCR.js +0 -6
  270. package/editor-web/assets/dist-DzjSp2i2.js +0 -17
  271. package/editor-web/assets/esm-CNi9O1ya.js +0 -21
  272. package/editor-web/assets/flowDiagram-IUGLLWBU-CL0AVU4Y.js +0 -1
  273. package/editor-web/assets/index-BCjGdcPh.js +0 -28
  274. package/editor-web/assets/index-D9ng69En.css +0 -2
  275. package/editor-web/assets/snapshots-CuflsO8Q.js +0 -1
  276. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-ChmNuO4G.js +0 -8
  277. package/editor-web/assets/workbook-C1QR6Cts.js +0 -45
@@ -1,5 +1,5 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{chartBook as Qe,embeddedChartXml as Je}from"@allyhub/chart";import{chartFrame as et,chartWords as tt,docChart as nt}from"./chart.js";import{BACKGROUNDS as Ie,TEXT_COLORS as Se,hex as ee}from"./color.js";import{columnWidths as it}from"./columns.js";import{COMPONENT_WIDTH as rt,componentName as ot}from"./component.js";import{blockId as $e,captionNumbers as st,contentsTitle as at,numberedCaption as Oe,writtenInChinese as dt,withoutTitle as ct}from"./captions.js";import{sourceList as lt,withSources as ht}from"./cite.js";import{HEADING_RULE_SPACE as ut,cardKept as pt,columnsKept as ft,docParts as gt,headingAnchors as mt,pageAccent as wt,trendSvg as yt}from"./html.js";import{effectiveLook as Fe,LIST_STEP as At,lineHeightPt as Tt,resolvePage as Et,sizePt as He}from"./page.js";import{splitTitle as Rt}from"./title.js";import{markdownOf as St}from"./markdown.js";import{charsAcross as Xe,columnShares as zt,emptyHead as Lt,numberColumns as Mt}from"./table.js";import{DRAWN_CODE as ve}from"./math.js";import{PAPER as te,TONE_COLORS as Ue,tagColors as Ct}from"./paper.js";import{COVER_ASPECT as Nt,everyBlock as ze,firstNoteMarks as bt,noteNumbers as xt,statTone as Dt}from"./model.js";const ue=15,It=1440/25.4,Y=n=>Math.round(n*It),Ge="ListParagraph",Be="bullets",Ot=1.8,pe=At*20,We={sans:{latin:"Calibri"},serif:{latin:"Cambria"},mono:{latin:"Courier New"},times:{latin:"Times New Roman"},song:{latin:"Times New Roman",eastAsia:"宋体"},hei:{latin:"Arial",eastAsia:"黑体"},fangsong:{latin:"Times New Roman",eastAsia:"仿宋"},kai:{latin:"Times New Roman",eastAsia:"楷体"},xiaobiaosong:{latin:"Times New Roman",eastAsia:"方正小标宋简体"}},Pe="Courier New",W=n=>n.slice(1).toUpperCase(),le=W(te.ink),fe=W(te.lead),vt=Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=","base64"),Le=W(te.rule),ge=W(te.ruleStrong),Me=W(te.ruleMid),Ce=W(te.stone),Pt=W(te.stone3),de=W(te.leadSoft),je="ALLYHUB-CHART-";function _t(n){return/[\u3040-\u30ff]/u.test(n)?"Yu Gothic":/[\uac00-\ud7af]/u.test(n)?"Malgun Gothic":"Microsoft YaHei"}const $t=/^(https?:|mailto:)/i,Ne=n=>({indent:0,level:0,room:n,frame:rt}),Ke=n=>({...n,indent:n.indent+pe,level:Math.min(n.level+1,8)}),Ft=400,Ht=n=>n.type==="bullet"||n.type==="numbered"||n.type==="check";function Xt(n,u,w){const l=w/ue,S=Math.floor(Math.min(u??n.width,l));return{width:S,height:Math.round(S*n.height/n.width)}}const qe="TOCHeading";function Ut(n,u,w,l,S,z,r){const{AlignmentType:m,BorderStyle:y,ExternalHyperlink:c,ImageRun:x,Paragraph:h,ShadingType:Z,Table:F,TableCell:_,TableLayoutType:H,TableRow:G,TextRun:M,WidthType:p}=n,N=e=>{const t=e.filter(i=>!(i instanceof n.TableOfContents));return t.at(-1)instanceof h?t:[...t,Q(0)]},X={ascii:Pe,hAnsi:Pe,cs:Pe,eastAsia:w},$=new Set([1]);let ne=0;const k=[],B=e=>({type:Z.CLEAR,color:"auto",fill:e}),he=(e,t,i=4)=>({style:e,color:t,size:i,space:4}),o=r.page.spacing,E=e=>Math.round(e*20),Q=e=>new h({spacing:{before:0,after:E(e),line:14,lineRule:n.LineRuleType.EXACT}}),J=()=>o.after>0?[Q(o.after)]:[],j=e=>e==="center"?m.CENTER:e==="right"?m.RIGHT:e==="justify"?m.JUSTIFIED:void 0,ie=(e,t,i,f={})=>{if(t.tag!==void 0){const s=Ct(t.tag),R={...f,color:W(s.fg),size:Math.round((i.size??r.page.size*2)*.85),shading:B(W(s.bg)),...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{}};return[new M({...R,text:` ${e.replace(/\n/gu," ")} `})]}const g=ee(t.color,Se)??i.color,a=ee(t.background,Ie),d={...f,...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{},...t.underline?{underline:{}}:{},...t.strike?{strike:!0}:{},...g===void 0?{}:{color:g},...i.size===void 0?{}:{size:i.size},...t.code?{font:X,shading:B(a??Ce)}:a===void 0?{}:{shading:B(a)}};return e.split(`
3
- `).map((s,R)=>new M({...d,text:s,...R>0?{break:1}:{}}))},U=(e,t={})=>e.flatMap(i=>i.note!==void 0?S.has(i.note.toLowerCase())?z.has(i)?[new n.FootnoteReferenceRun(S.get(i.note.toLowerCase())??1)]:[new M({text:String(S.get(i.note.toLowerCase())??1),style:"FootnoteReference"})]:[]:i.text===""&&i.href?.startsWith("#")===!0?xe(i.href.slice(1),i.styles,t):i.href!==void 0&&$t.test(i.href)?[new c({link:i.href,children:ie(i.text,i.styles,t,{style:"Hyperlink"})})]:ie(i.text,i.styles,t)),xe=(e,t,i)=>{const f=decodeURIComponent(e),g=r.refs.get(f)??"",a=r.bookmarks.get(f);return g===""?[]:a===void 0?ie(g,t,i):[new n.InternalHyperlink({anchor:a,children:ie(g,t,i,{style:"Hyperlink"})})]},T=(e,t)=>{const i=e===void 0?void 0:r.bookmarks.get(e);return i===void 0?t:[new n.Bookmark({id:i,children:t})]},D=e=>{const t=j(e?.align),i=ee(e?.background,Ie);return{...t===void 0?{}:{alignment:t},...i===void 0?{}:{shading:B(i)}}},L=e=>e.indent===0?{}:{indent:{left:e.indent}},re=e=>{const t={style:y.SINGLE,color:e,size:4};return{top:t,bottom:t,left:t,right:t}},me=(e,t)=>{const i=ee(e.look?.background,Ie)??Ce,f=ee(e.look?.color,Se),g=t.room-t.indent,a=e.icon===void 0?0:E(r.page.size*Ot)+E(o.box.side),d=g-a,s=(R,C)=>({top:E(o.box.top),bottom:E(Math.max(o.box.top-o.after,0)),left:R,right:C,marginUnitType:p.DXA});return new F({layout:H.FIXED,width:{size:g,type:p.DXA},columnWidths:a===0?[d]:[a,d],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:[...e.icon===void 0?[]:[new _({width:{size:a,type:p.DXA},shading:B(i),borders:re(i),margins:s(E(o.box.side),0),children:[new h({children:[new M({text:e.icon})]})]})],new _({width:{size:d,type:p.DXA},shading:B(i),borders:re(i),margins:s(a===0?E(o.box.side):0,E(o.box.side)),children:[new h({children:U(e.content,{color:f})}),...N(V(e.children??[],Ne(d-E(o.box.side))))]})]})]})},we=(e,t)=>{const i=t.room-t.indent,f=E(o.card.side),g=[...e.title===void 0?[]:[new h({spacing:{after:e.subtitle===void 0?E(o.after):0},children:U([{text:e.title,styles:{bold:!0}}])})],...e.subtitle===void 0?[]:[new h({spacing:{after:E(o.after)},children:[new M({text:e.subtitle,color:fe,size:o.small*2})]})]];return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:[i],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:pt(e,r.page),children:[new _({width:{size:i,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(Math.max(o.card.top-o.after,0)),left:f,right:f,marginUnitType:p.DXA},children:N([...g,...V(e.children??[],Ne(i-2*f))])})]})]})},oe=(e,t)=>{const i=t.room-t.indent,f=E(o.gap),g=e.stats.length,a=Math.floor((i-f*(g-1))/g),d=e.stats.flatMap((b,P)=>P===0?[a]:[f,a]),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s},C=E(o.card.side),A=o.small*2,v=e.stats.flatMap((b,P)=>{const q=Dt(b),ce=[...b.delta===void 0?[]:[new M({text:b.delta,color:W(Ue[q]),size:A})],...b.note===void 0?[]:[new M({text:`${b.delta===void 0?"":" "}${b.note}`,color:fe,size:A})]],Ae=a-2*C,Te=b.trend===void 0?[]:[new h({spacing:{before:60,after:0,line:240},children:[new x({type:"svg",data:Buffer.from(yt(b.trend,Ue[q]).replace("<svg ",`<svg xmlns="http://www.w3.org/2000/svg" width="${String(Math.round(Ae/15))}" height="24" `)),fallback:{type:"png",data:vt},transformation:{width:Math.round(Ae/15),height:24}})]})],I=new _({width:{size:a,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(o.card.top),left:C,right:C,marginUnitType:p.DXA},children:[new h({spacing:{after:0},children:[new M({text:b.label,color:fe,size:A})]}),new h({spacing:{after:0,line:240,lineRule:n.LineRuleType.AUTO},children:U([{text:b.value,styles:{bold:!0}}],{size:o.figure*2})}),...ce.length===0?[]:[new h({spacing:{after:0},children:ce})],...Te]}),O=new _({width:{size:f,type:p.DXA},borders:R,children:[new h({children:[]})]});return P===0?[I]:[O,I]});return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:d,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:v})]})},se=(e,t)=>{const i=t.room-t.indent,f=Math.max(1,...e.rows.map(I=>I.length)),g=Array.from({length:f},(I,O)=>e.widths?.[O]?(e.widths[O]??0)*ue:void 0),a=g.reduce((I,O)=>I+(O??0),0),d=zt(e,{across:Xe(Math.max(i-a,0)/ue,o.small),margins:Xe(2*o.cell.side*96/72,o.small)}),s=g.reduce((I,O,_e)=>I+(O===void 0?d[_e]??1:0),0)||1,R=Math.max(i-a,0),C=g.map((I,O)=>I??R*(d[O]??1)/s),A=C.reduce((I,O)=>I+O,0)||1,v=Math.min(1,i/A),b=C.map(I=>Math.round(I*v)),P=Lt(e),q=(e.head===void 0||e.head==="both")&&!P,ce=e.head==="column"||e.head==="both",Ae=Mt(e),Te=P?e.rows.slice(1):e.rows;return new F({layout:H.FIXED,width:{size:b.reduce((I,O)=>I+O,0),type:p.DXA},columnWidths:b,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:Te.map((I,O)=>new G({tableHeader:q&&O===0,cantSplit:!0,children:Array.from({length:f},(_e,Ee)=>{const Re=q&&O===0,ke=ce&&Ee===0&&!Re;return new _({width:{size:b[Ee]??0,type:p.DXA},...Re?{shading:B(Pt)}:{},borders:{top:O===0?{style:y.SINGLE,size:8,color:ge}:{style:y.NONE,size:0,color:"auto"},left:{style:y.NONE,size:0,color:"auto"},right:{style:y.NONE,size:0,color:"auto"},bottom:O===Te.length-1?{style:y.SINGLE,size:8,color:ge}:Re?{style:y.SINGLE,size:6,color:ge}:{style:y.SINGLE,size:4,color:Me}},margins:{top:E(o.cell.top),bottom:E(o.cell.top),left:E(o.cell.side),right:E(o.cell.side),marginUnitType:p.DXA},children:[new h({spacing:{after:0},...Ae.has(Ee)?{alignment:m.RIGHT}:{},children:U(I[Ee]??[],{bold:ke||Re,size:o.small*2})})]})})}))})},ae=(e,t,i,f,g,a)=>{const d=j(e.align),s={...L(t),...d===void 0?{}:{alignment:d}},R=i===void 0?void 0:e.caption,C=R!==void 0,A=[new h({...s,keepNext:C,...i?{spacing:{line:240,lineRule:n.LineRuleType.AUTO,...C?{after:E(o.caption)}:{}}}:{},children:i?[new x({type:i.type,data:i.data,transformation:Xt(i,e.width,t.room-t.indent),altText:{name:e.alt??"",title:e.caption??e.alt??"",description:e.alt??""}})]:[new M({text:f,color:de})]})];return R!==void 0&&A.push(new h({...s,style:"Caption",children:T(a,[new M({text:Oe(R,g)})])})),A},ye=(e,t)=>{const i=t.room-t.indent,f=e.columns.map(A=>A.width??1),g=f.reduce((A,v)=>A+v,0)||1,a=f.map(A=>Math.round(i*A/g)),d=it(e,t.frame),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s,insideHorizontal:s,insideVertical:s},C=Ft/2;return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:a,borders:R,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:ft(e,r.page),children:e.columns.map((A,v)=>{const b=a[v]??0,P=v===0?0:C,q=v===e.columns.length-1?0:C,ce=N(V(A.blocks,{indent:0,level:0,room:b-P-q,frame:d[v]??t.frame}));return new _({width:{size:b,type:p.DXA},borders:R,margins:{top:0,bottom:0,left:P,right:q,marginUnitType:p.DXA},children:ce})})})]})},K=(e,t,i)=>{const f=ee(e.look?.color,Se),g=V(e.children??[],Ke(t)),a=D(e.look),d=Ge;return e.type==="check"?[new h({...a,...L(t),style:d,children:[new M({text:e.checked?"☑ ":"☐ "}),...U(e.content,{color:f})]}),...g]:[new h({...a,style:d,numbering:e.type==="bullet"?{reference:Be,level:t.level}:{reference:`start-${String(i.start)}`,level:t.level,instance:i.id},children:U(e.content,{color:f})}),...g]},De=(e,t)=>{const i="look"in e?e.look:void 0,f=ee(i?.color,Se),g=D(i),a=()=>"children"in e?V(e.children??[],Ke(t)):[];switch(e.type){case"paragraph":case"toggle":return[new h({...r.sets.align&&e.look?.align===void 0?{alignment:m.JUSTIFIED}:{},...g,...r.sets.indent&&e.type==="paragraph"?{indent:{left:t.indent,firstLine:Math.round(r.page.textIndent*r.page.size*20)}}:L(t),children:U(e.content,{color:f})}),...a()];case"heading":return[new h({...g,...L(t),...e===r.title?{heading:n.HeadingLevel.TITLE}:{heading:n.HeadingLevel[`HEADING_${String(e.level)}`]},children:T(r.anchors.get(e),U(e.content,{color:f}))}),...a()];case"quote":return[new h({...g,indent:{left:t.indent+E(o.quote)},border:{left:{style:y.SINGLE,color:l??ge,size:l?12:6,space:Math.floor(o.quote-(l?1.5:.75))}},children:U(e.content,{color:f??fe})}),...a()];case"callout":return[me(e,t),...J()];case"card":return[we(e,t),...J()];case"stats":return[oe(e,t),...J()];case"code":{if(e.language===ve.math||e.language===ve.mermaid){const R=u.drawn?.(e);if(R)return ae({...e.language===ve.math?{}:{align:"center"}},t,R,"")}const d=R=>({style:y.SINGLE,color:Ce,size:4,space:R}),s=E(o.box.side+.5);return[new h({indent:{left:t.indent+s,right:s},shading:B(Ce),border:{top:d(o.box.top),bottom:d(o.box.top),left:d(o.box.side),right:d(o.box.side)},keepLines:!0,children:e.code.split(`
4
- `).map((R,C)=>new M({text:R,font:X,size:o.small*2,...C>0?{break:1}:{}}))})]}case"columns":return[ye(e,t)];case"chart":{const d=r.numbers.get(e),s=d===void 0?void 0:e.title,{chart:R,problems:C}=nt(s===void 0?e:ct(e),u),A=he(y.DASHED,Me);if(!R)return[new h({...L(t),alignment:m.CENTER,border:{top:A,bottom:A,left:A,right:A},children:[new M({text:[e.title??"Chart",...C].join(": "),color:de})]})];const v=et(e,t.frame),b=(t.room-t.indent)/ue,P=Math.min(1,b/v.width);return k.push({chart:R,width:Math.round(v.width*P),height:Math.round(v.height*P),words:tt(e,R)}),[new h({...L(t),alignment:m.CENTER,keepNext:s!==void 0,spacing:{line:240,lineRule:n.LineRuleType.AUTO},children:[new M({text:`${je}${String(k.length)}`})]}),...s===void 0?[]:[new h({...L(t),alignment:m.CENTER,style:"Caption",children:T(e.id,[new M({text:Oe(s,d)})])})]]}case"image":return ae(e,t,u.picture?.(e.src),e.alt??e.caption??e.src,r.numbers.get(e),e.id);case"component":{const d=u.component?.(e);if(d)return ae(e,t,d,"",r.numbers.get(e),e.id);const s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:ot(e),color:de})]})]}case"table":return[...e.caption===void 0?[]:[new h({...L(t),style:"Caption",keepNext:!0,spacing:{after:E(o.caption)},children:T(e.id,[new M({text:Oe(e.caption,r.numbers.get(e))})])})],se(e,t),...J()];case"pagebreak":return[new h({spacing:{before:0,after:0,line:20,lineRule:n.LineRuleType.EXACT},children:[new n.PageBreak]})];case"bibliography":{const{page:d}=r,s=d.textIndent>0?Math.round(d.textIndent*d.size*20):480;return r.sources.map(R=>new h({...L(t),alignment:m.LEFT,indent:{left:t.indent+s,hanging:s},spacing:{after:E(o.after)},children:R.pieces.map(C=>{const A=C.italic?{italics:!0}:{};return new M({text:C.text,...A})})}))}case"toc":{const d=e.levels??3,s=r.headings.filter(A=>A.level<=d).map(A=>{const v=r.anchors.get(A)??"",b=u.headingPage?.(v),P=r.bookmarks.get(v);return{title:A.content.map(q=>q.text).join(""),level:A.level,...b===void 0?{}:{page:b},...P===void 0?{}:{href:P}}}),R=Math.min(...s.map(A=>A.level)),C=at(e,r.chinese);return[...C===""?[]:[new h({style:qe,text:C})],new n.TableOfContents(void 0,{hyperlink:!0,headingStyleRange:`1-${String(d)}`,beginDirty:!1,cachedEntries:s.map(A=>({...A,level:A.level-R+1}))})]}case"note":return[];case"divider":return[new h({...L(t),spacing:{before:E(o.divider),after:E(o.divider),line:20,lineRule:n.LineRuleType.EXACT},border:{bottom:{style:y.SINGLE,color:Le,size:4,space:0}}})];case"embed":{const d=/^<\s*([A-Za-z][\w.]*)/.exec(e.source.trim())?.[1],s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:d??"",color:de})]})]}case"source":return[];case"bullet":case"numbered":case"check":return[]}};function V(e,t){const i=[];let f,g;for(const a of e){if(!Ht(a)){f=void 0,g=void 0,i.push(...De(a,t));continue}if(f===void 0||g===void 0||g.type==="numbered"!=(a.type==="numbered")){const d=a.type==="numbered"?a.start??1:1;$.add(d),f={id:++ne,start:d}}g=a,i.push(...K(a,t,f))}return i.flatMap((a,d)=>a instanceof F&&i[d+1]instanceof F?[a,Q(0)]:[a])}return{charts:k,body:(e,t)=>V(e,Ne(t)),footnotes:e=>Object.fromEntries([...ze(e)].flatMap(t=>{if(t.type!=="note")return[];const i=S.get(t.label.toLowerCase());if(i===void 0)return[];const f=V(t.children??[],Ne(Y(r.page.width)-Y(r.page.margins.left+r.page.margins.right))).filter(g=>g instanceof h);return[[String(i),{children:[new h({spacing:{after:40},children:U(t.content,{size:18,color:fe})}),...f]}]]})),numbering:()=>[{reference:Be,levels:Array.from({length:9},(e,t)=>({level:t,format:n.LevelFormat.BULLET,text:["•","◦","▪"][t%3]??"•",alignment:m.LEFT,style:{paragraph:{indent:{left:(t+1)*pe,hanging:pe}}}}))},...[...$].sort((e,t)=>e-t).map(e=>({reference:`start-${String(e)}`,levels:Array.from({length:9},(t,i)=>({level:i,format:[n.LevelFormat.DECIMAL,n.LevelFormat.LOWER_LETTER,n.LevelFormat.LOWER_ROMAN][i%3]??n.LevelFormat.DECIMAL,text:`%${String(i+1)}.`,alignment:m.LEFT,...i===0?{start:e}:{},style:{paragraph:{indent:{left:(i+1)*pe,hanging:pe}}}}))}))]}}const Gt="1980-01-01T00:00:00Z",Ye=9525,Ve="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Bt=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Wt(n,u,w,l,S){return n.forEach((z,r)=>{const m=String(r+1),y=`rIdChart${m}`,c=`Microsoft_Excel_Worksheet${m}.xlsx`;S(`word/charts/chart${m}.xml`,Je(z.chart,{width:z.width*.75,height:z.height*.75},"rId1",{frameless:!0})),S(`word/charts/_rels/chart${m}.xml.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${Ve}/package" Target="../embeddings/${c}"/></Relationships>`),S(`word/embeddings/${c}`,Qe(z.chart)),w=w.replace("</Relationships>",`<Relationship Id="${y}" Type="${Ve}/chart" Target="charts/chart${m}.xml"/></Relationships>`),l=l.replace("</Types>",`<Override ContentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml" PartName="/word/charts/chart${m}.xml"/></Types>`);const x=String(z.width*Ye),h=String(z.height*Ye),Z=`<w:r><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${x}" cy="${h}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="0" name="Chart ${m}" descr="${Bt(z.words)}"/><wp:cNvGraphicFramePr/><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" r:id="${y}"/></a:graphicData></a:graphic></wp:inline></w:drawing></w:r>`;u=u.replace(new RegExp(`<w:r>(?:(?!<w:r>).)*?<w:t[^>]*>${je}${m}</w:t></w:r>`,"su"),Z)}),n.length>0&&!l.includes('Extension="xlsx"')&&(l=l.replace("</Types>",'<Default ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Extension="xlsx"/></Types>')),{document:u,rels:w,types:l}}function jt(n,u,w){const l=u.unzipSync(n),S=p=>{const N=l[p];return N&&new TextDecoder().decode(N)},z=(p,N)=>{l[p]=typeof N=="string"?new TextEncoder().encode(N):N},r="word/document.xml",m="word/_rels/document.xml.rels",y="[Content_Types].xml",c=Wt(w,S(r)??"",S(m)??"",S(y)??"",z);z(y,c.types);let x=c.document,h=c.rels;[...new Set([...x.matchAll(/w:hyperlink [^>]*r:id="([^"]+)"/g)].map(p=>p[1]??""))].forEach((p,N)=>{const X=`rIdLink${String(N+1)}`;x=x.split(`"${p}"`).join(`"${X}"`),h=h.split(`"${p}"`).join(`"${X}"`)});let F=0;x=x.replace(/<wp:docPr id="\d+"/g,()=>`<wp:docPr id="${String(++F)}"`);const _=new Map;x=x.replace(/<w:bookmarkStart w:name="([^"]*)" w:id="(\d+)"/g,(p,N,X)=>{const $=String(_.size+1);return _.set(X,$),`<w:bookmarkStart w:name="${N}" w:id="${$}"`}),x=x.replace(/<w:bookmarkEnd w:id="(\d+)"/g,(p,N)=>{const X=_.get(N);return X===void 0?p:`<w:bookmarkEnd w:id="${X}"`}),z(r,x),z(m,h);const H="docProps/core.xml",G=S(H);G!==void 0&&z(H,G.replace(/(<dcterms:(?:created|modified)[^>]*>)[^<]*/g,`$1${Gt}`));const M=Object.fromEntries(Object.entries(l).sort(([p],[N])=>p<N?-1:1));return u.zipSync(M,{mtime:new Date(1980,0,1)})}const be=(n,u)=>{const w=We[n];return{ascii:w.latin,hAnsi:w.latin,cs:w.latin,eastAsia:w.eastAsia??u}};function Kt(n,u,w){const l={left:[],center:[],right:[]};u.left!==void 0&&l.left.push(u.left),u.center!==void 0&&l.center.push(u.center),u.right!==void 0&&l.right.push(u.right),u.outside!==void 0&&l[w.odd?"right":"left"].push(u.outside),u.inside!==void 0&&l[w.odd?"left":"right"].push(u.inside);const S={size:Math.round(w.size*2),color:w.color,font:be(w.face,w.eastAsia)},z=r=>r.split(/(\{title\}|\{section\}|\{page\}|\{pages\})/u).filter(m=>m!=="").map(m=>m==="{page}"?new n.TextRun({...S,children:[n.PageNumber.CURRENT]}):m==="{pages}"?new n.TextRun({...S,children:[n.PageNumber.TOTAL_PAGES]}):m==="{section}"?new n.SimpleField(`STYLEREF "heading ${String(w.section)}"`,""):new n.TextRun({...S,text:m==="{title}"?w.title:m}));return new n.Paragraph({style:w.style,tabStops:[{type:n.TabStopType.CENTER,position:Math.round(w.width/2)},{type:n.TabStopType.RIGHT,position:w.width}],children:[...z(l.left.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(l.center.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(l.right.join(" "))]})}const Ze=(n,u,w,l)=>({run:{...u?.font===void 0?{}:{font:be(n.font,w)},...u?.size===void 0?{}:{size:Math.round(n.size*2)},...u?.weight===void 0?{}:{bold:n.weight==="bold"},...u?.italic===void 0?{}:{italics:n.italic}},paragraph:u?.align===void 0?{}:{alignment:n.align==="center"?l.AlignmentType.CENTER:n.align==="right"?l.AlignmentType.RIGHT:l.AlignmentType.LEFT}});function qt(n){const u=new Map,w=new Set;return n.forEach((l,S)=>{const z=l.replace(/[^A-Za-z0-9_]/gu,"_").replace(/^[^A-Za-z]+/u,"");let r=`b_${z}`.slice(0,32);(w.has(r)||z==="")&&(r=`b_${String(S)}_${z}`.slice(0,40)),w.add(r),u.set(l,r)}),u}export async function docxOf(n,u,w,l={}){const S=l.page??{},z=Fe(S).citationStyle??"apa",r=ht(w,l.sources??[],z,"block"),m=lt(w,l.sources??[],z),y=Fe(S),c=Et(S),x=We[c.font].eastAsia??_t(St(r)),h=be(c.font,x),Z=ee(wt(l.page),{}),F=mt(r),_=st(r,S),H=new Map;for(const T of ze(r)){const D=$e(T),L=_.get(T);D!==void 0&&L!==void 0&&H.set(D,L.label)}for(const[T,D]of F)T.type==="heading"&&H.set(D,T.content.map(L=>L.text).join(""));const{title:G}=Rt(r),M=[...ze(r)].filter(T=>T.type==="heading"&&T!==G),p=qt([...F.values(),...[...ze(r)].flatMap(T=>{const D=$e(T);return D===void 0?[]:[D]})]),N=Ut(n,l,x,Z,xt(r),bt(r),{page:c,sets:{indent:y.textIndent!==void 0&&y.textIndent>0,align:y.textAlign==="justify"},numbers:_,refs:H,bookmarks:p,anchors:F,title:G,headings:M,chinese:dt(r),sources:m}),X=gt(r),$={width:Y(c.width),height:Y(c.height)},ne={top:Y(c.margins.top),bottom:Y(c.margins.bottom),left:Y(c.margins.left),right:Y(c.margins.right)},k=l.cover,B=[c.header,c.footer].some(T=>T!==void 0&&(T.outside!==void 0||T.inside!==void 0)),he=X.map((T,D)=>{const L=T.landscape?$.height:$.width,re=L-ne.left-ne.right,me=N.body(T.blocks,re);if(D===0&&k){const K=Math.round(L/ue);me.unshift(new n.Paragraph({spacing:{before:0,after:0},children:[new n.ImageRun({type:k.type,data:k.data,transformation:{width:K,height:Math.round(K*Nt)},floating:{horizontalPosition:{relative:n.HorizontalPositionRelativeFrom.PAGE,offset:0},verticalPosition:{relative:n.VerticalPositionRelativeFrom.PAGE,offset:0},allowOverlap:!1,margins:{bottom:324e3},wrap:{type:n.TextWrappingType.TOP_AND_BOTTOM}},altText:{name:"Cover",title:"Cover",description:""}})]}))}const we=(K,De,V)=>{if(K===void 0)return;const e=t=>Kt(n,K,{style:V,odd:t,width:re,title:l.title??"",section:Math.min(...M.map(i=>i.level),6),face:K.font??c.font,eastAsia:x,size:K.size===void 0?Math.max(7.5,c.size*.75):He(K.size),color:De?de:le});return{default:e(!0),...B?{even:e(!1)}:{}}},oe=we(c.header,y.header===void 0,"Header"),se=we(c.footer,y.footer===void 0,"Footer"),ae=D===0&&k!==void 0&&oe!==void 0,ye=y.grid===void 0?void 0:{type:n.DocumentGridType.LINES_AND_CHARS,linePitch:Math.round(Tt(c)*20),charSpace:Math.round(c.textWidth/25.4*72/y.grid.chars-c.size)*4096};return{properties:{page:{size:{width:Math.min($.width,$.height),height:Math.max($.width,$.height),...T.landscape||$.width>$.height?{orientation:n.PageOrientation.LANDSCAPE}:{}},margin:{...ne,header:Math.max(0,ne.top-Y(7)-Math.round(c.size*20*1.2)),footer:Math.max(0,ne.bottom-Y(7)-Math.round(c.size*20*1.2))}},...ye===void 0?{}:{grid:ye},...ae?{titlePage:!0}:{}},...oe===void 0?{}:{headers:{default:new n.Header({children:[oe.default]}),...oe.even?{even:new n.Header({children:[oe.even]})}:{},...ae?{first:new n.Header({children:[]})}:{}}},...se===void 0?{}:{footers:{default:new n.Footer({children:[se.default]}),...se.even?{even:new n.Footer({children:[se.even]})}:{},...ae?{first:new n.Footer({children:[se.default]})}:{}}},children:me}}),o=c.lineHeight,E={spacing:{after:Math.round(c.paragraphSpacing*c.size*20),..."pt"in o?{line:Math.round(o.pt*20),lineRule:n.LineRuleType.EXACT}:{line:Math.round(o.multiple*240),lineRule:n.LineRuleType.AUTO}}},Q=c.spacing,J=T=>Math.round(T*20),j=T=>{const D=y.headings?.[T],L=Ze(c.headings[T],D,x,n);return{run:{size:Math.round(c.headings[T].size*2),bold:!0,font:h,color:le,...L.run},paragraph:{spacing:{before:J(Q.heading.before),after:J(Q.heading.after)},keepNext:!0,keepLines:!0,...c.headings[T].rule?{border:{bottom:{style:n.BorderStyle.SINGLE,size:4,color:Le,space:ut}}}:{},...L.paragraph}}},ie=Ze(c.title,y.title,x,n),U=new n.Document({creator:"AllyHub",lastModifiedBy:"AllyHub",...l.title===void 0?{}:{title:l.title},...B?{evenAndOddHeaderAndFooters:!0}:{},numbering:{config:N.numbering()},styles:{default:{document:{run:{font:h,size:Math.round(c.size*2),color:le},paragraph:E},hyperlink:{run:{color:Z??le,underline:{color:Z??ge}}},title:{run:{size:Math.round(c.title.size*2),bold:!0,font:h,color:le,...ie.run},paragraph:{spacing:{before:0,after:J(Q.title)},keepNext:!0,...ie.paragraph}},heading1:j(1),heading2:j(2),heading3:j(3),heading4:j(4),heading5:j(5),heading6:j(6)},paragraphStyles:[{id:qe,name:"TOC Heading",basedOn:"Normal",next:"Normal",quickFormat:!0,...j(1)},{id:"Caption",name:"caption",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:Q.small*2,color:de},paragraph:{spacing:{before:0}}},{id:Ge,name:"List Paragraph",basedOn:"Normal",quickFormat:!0,paragraph:{contextualSpacing:!0}},...[["Header",c.header,y.header===void 0],["Footer",c.footer,y.footer===void 0]].flatMap(([T,D,L])=>D===void 0?[]:[{id:T,name:T.toLowerCase(),basedOn:"Normal",run:{size:Math.round((D.size===void 0?Math.max(7.5,c.size*.75):He(D.size))*2),color:L?de:le,font:be(D.font??c.font,x)},paragraph:{spacing:{before:0,after:0,line:240}}}])]},sections:he,footnotes:N.footnotes(r)}),xe=await n.Packer.toBuffer(U);return jt(new Uint8Array(xe),u,N.charts)}
2
+ import{chartBook as Qe,embeddedChartXml as Je}from"@allyhub/chart";import{chartFrame as et,chartWords as tt,docChart as nt}from"./chart.js";import{BACKGROUNDS as Ie,TEXT_COLORS as Se,hex as ee}from"./color.js";import{columnWidths as it}from"./columns.js";import{COMPONENT_WIDTH as rt,componentName as ot}from"./component.js";import{blockId as $e,captionNumbers as st,contentsTitle as at,numberedCaption as Oe,writtenInChinese as dt,withoutTitle as ct}from"./captions.js";import{sourceList as lt,withSources as ht}from"./cite.js";import{HEADING_RULE_SPACE as ut,cardKept as pt,columnsKept as ft,docParts as gt,headingAnchors as mt,pageAccent as wt,trendSvg as yt}from"./html.js";import{effectiveLook as Fe,LIST_STEP as At,lineHeightPt as Tt,resolvePage as Et,sizePt as He}from"./page.js";import{splitTitle as Rt}from"./title.js";import{markdownOf as St}from"./markdown.js";import{charsAcross as Xe,columnShares as zt,emptyHead as Lt,numberColumns as Mt,withTableData as Ct}from"./table.js";import{DRAWN_CODE as ve}from"./math.js";import{PAPER as te,TONE_COLORS as Ue,tagColors as Nt}from"./paper.js";import{COVER_ASPECT as bt,everyBlock as ze,firstNoteMarks as xt,noteNumbers as Dt,statTone as It}from"./model.js";const ue=15,Ot=1440/25.4,Y=n=>Math.round(n*Ot),Ge="ListParagraph",Be="bullets",vt=1.8,pe=At*20,We={sans:{latin:"Calibri"},serif:{latin:"Cambria"},mono:{latin:"Courier New"},times:{latin:"Times New Roman"},song:{latin:"Times New Roman",eastAsia:"宋体"},hei:{latin:"Arial",eastAsia:"黑体"},fangsong:{latin:"Times New Roman",eastAsia:"仿宋"},kai:{latin:"Times New Roman",eastAsia:"楷体"},xiaobiaosong:{latin:"Times New Roman",eastAsia:"方正小标宋简体"}},Pe="Courier New",W=n=>n.slice(1).toUpperCase(),le=W(te.ink),fe=W(te.lead),Pt=Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=","base64"),Le=W(te.rule),ge=W(te.ruleStrong),Me=W(te.ruleMid),Ce=W(te.stone),_t=W(te.stone3),de=W(te.leadSoft),je="ALLYHUB-CHART-";function $t(n){return/[\u3040-\u30ff]/u.test(n)?"Yu Gothic":/[\uac00-\ud7af]/u.test(n)?"Malgun Gothic":"Microsoft YaHei"}const Ft=/^(https?:|mailto:)/i,Ne=n=>({indent:0,level:0,room:n,frame:rt}),Ke=n=>({...n,indent:n.indent+pe,level:Math.min(n.level+1,8)}),Ht=400,Xt=n=>n.type==="bullet"||n.type==="numbered"||n.type==="check";function Ut(n,u,w){const c=w/ue,S=Math.floor(Math.min(u??n.width,c));return{width:S,height:Math.round(S*n.height/n.width)}}const qe="TOCHeading";function Gt(n,u,w,c,S,z,r){const{AlignmentType:m,BorderStyle:y,ExternalHyperlink:l,ImageRun:x,Paragraph:h,ShadingType:Z,Table:F,TableCell:_,TableLayoutType:H,TableRow:G,TextRun:M,WidthType:p}=n,N=e=>{const t=e.filter(i=>!(i instanceof n.TableOfContents));return t.at(-1)instanceof h?t:[...t,Q(0)]},X={ascii:Pe,hAnsi:Pe,cs:Pe,eastAsia:w},$=new Set([1]);let ne=0;const k=[],B=e=>({type:Z.CLEAR,color:"auto",fill:e}),he=(e,t,i=4)=>({style:e,color:t,size:i,space:4}),o=r.page.spacing,E=e=>Math.round(e*20),Q=e=>new h({spacing:{before:0,after:E(e),line:14,lineRule:n.LineRuleType.EXACT}}),J=()=>o.after>0?[Q(o.after)]:[],j=e=>e==="center"?m.CENTER:e==="right"?m.RIGHT:e==="justify"?m.JUSTIFIED:void 0,ie=(e,t,i,f={})=>{if(t.tag!==void 0){const s=Nt(t.tag),R={...f,color:W(s.fg),size:Math.round((i.size??r.page.size*2)*.85),shading:B(W(s.bg)),...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{}};return[new M({...R,text:` ${e.replace(/\n/gu," ")} `})]}const g=ee(t.color,Se)??i.color,a=ee(t.background,Ie),d={...f,...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{},...t.underline?{underline:{}}:{},...t.strike?{strike:!0}:{},...g===void 0?{}:{color:g},...i.size===void 0?{}:{size:i.size},...t.code?{font:X,shading:B(a??Ce)}:a===void 0?{}:{shading:B(a)}};return e.split(`
3
+ `).map((s,R)=>new M({...d,text:s,...R>0?{break:1}:{}}))},U=(e,t={})=>e.flatMap(i=>i.note!==void 0?S.has(i.note.toLowerCase())?z.has(i)?[new n.FootnoteReferenceRun(S.get(i.note.toLowerCase())??1)]:[new M({text:String(S.get(i.note.toLowerCase())??1),style:"FootnoteReference"})]:[]:i.text===""&&i.href?.startsWith("#")===!0?xe(i.href.slice(1),i.styles,t):i.href!==void 0&&Ft.test(i.href)?[new l({link:i.href,children:ie(i.text,i.styles,t,{style:"Hyperlink"})})]:ie(i.text,i.styles,t)),xe=(e,t,i)=>{const f=decodeURIComponent(e),g=r.refs.get(f)??"",a=r.bookmarks.get(f);return g===""?[]:a===void 0?ie(g,t,i):[new n.InternalHyperlink({anchor:a,children:ie(g,t,i,{style:"Hyperlink"})})]},T=(e,t)=>{const i=e===void 0?void 0:r.bookmarks.get(e);return i===void 0?t:[new n.Bookmark({id:i,children:t})]},D=e=>{const t=j(e?.align),i=ee(e?.background,Ie);return{...t===void 0?{}:{alignment:t},...i===void 0?{}:{shading:B(i)}}},L=e=>e.indent===0?{}:{indent:{left:e.indent}},re=e=>{const t={style:y.SINGLE,color:e,size:4};return{top:t,bottom:t,left:t,right:t}},me=(e,t)=>{const i=ee(e.look?.background,Ie)??Ce,f=ee(e.look?.color,Se),g=t.room-t.indent,a=e.icon===void 0?0:E(r.page.size*vt)+E(o.box.side),d=g-a,s=(R,C)=>({top:E(o.box.top),bottom:E(Math.max(o.box.top-o.after,0)),left:R,right:C,marginUnitType:p.DXA});return new F({layout:H.FIXED,width:{size:g,type:p.DXA},columnWidths:a===0?[d]:[a,d],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:[...e.icon===void 0?[]:[new _({width:{size:a,type:p.DXA},shading:B(i),borders:re(i),margins:s(E(o.box.side),0),children:[new h({children:[new M({text:e.icon})]})]})],new _({width:{size:d,type:p.DXA},shading:B(i),borders:re(i),margins:s(a===0?E(o.box.side):0,E(o.box.side)),children:[new h({children:U(e.content,{color:f})}),...N(V(e.children??[],Ne(d-E(o.box.side))))]})]})]})},we=(e,t)=>{const i=t.room-t.indent,f=E(o.card.side),g=[...e.title===void 0?[]:[new h({spacing:{after:e.subtitle===void 0?E(o.after):0},children:U([{text:e.title,styles:{bold:!0}}])})],...e.subtitle===void 0?[]:[new h({spacing:{after:E(o.after)},children:[new M({text:e.subtitle,color:fe,size:o.small*2})]})]];return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:[i],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:pt(e,r.page),children:[new _({width:{size:i,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(Math.max(o.card.top-o.after,0)),left:f,right:f,marginUnitType:p.DXA},children:N([...g,...V(e.children??[],Ne(i-2*f))])})]})]})},oe=(e,t)=>{const i=t.room-t.indent,f=E(o.gap),g=e.stats.length,a=Math.floor((i-f*(g-1))/g),d=e.stats.flatMap((b,P)=>P===0?[a]:[f,a]),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s},C=E(o.card.side),A=o.small*2,v=e.stats.flatMap((b,P)=>{const q=It(b),ce=[...b.delta===void 0?[]:[new M({text:b.delta,color:W(Ue[q]),size:A})],...b.note===void 0?[]:[new M({text:`${b.delta===void 0?"":" "}${b.note}`,color:fe,size:A})]],Ae=a-2*C,Te=b.trend===void 0?[]:[new h({spacing:{before:60,after:0,line:240},children:[new x({type:"svg",data:Buffer.from(yt(b.trend,Ue[q]).replace("<svg ",`<svg xmlns="http://www.w3.org/2000/svg" width="${String(Math.round(Ae/15))}" height="24" `)),fallback:{type:"png",data:Pt},transformation:{width:Math.round(Ae/15),height:24}})]})],I=new _({width:{size:a,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(o.card.top),left:C,right:C,marginUnitType:p.DXA},children:[new h({spacing:{after:0},children:[new M({text:b.label,color:fe,size:A})]}),new h({spacing:{after:0,line:240,lineRule:n.LineRuleType.AUTO},children:U([{text:b.value,styles:{bold:!0}}],{size:o.figure*2})}),...ce.length===0?[]:[new h({spacing:{after:0},children:ce})],...Te]}),O=new _({width:{size:f,type:p.DXA},borders:R,children:[new h({children:[]})]});return P===0?[I]:[O,I]});return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:d,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:v})]})},se=(e,t)=>{const i=t.room-t.indent,f=Math.max(1,...e.rows.map(I=>I.length)),g=Array.from({length:f},(I,O)=>e.widths?.[O]?(e.widths[O]??0)*ue:void 0),a=g.reduce((I,O)=>I+(O??0),0),d=zt(e,{across:Xe(Math.max(i-a,0)/ue,o.small),margins:Xe(2*o.cell.side*96/72,o.small)}),s=g.reduce((I,O,_e)=>I+(O===void 0?d[_e]??1:0),0)||1,R=Math.max(i-a,0),C=g.map((I,O)=>I??R*(d[O]??1)/s),A=C.reduce((I,O)=>I+O,0)||1,v=Math.min(1,i/A),b=C.map(I=>Math.round(I*v)),P=Lt(e),q=(e.head===void 0||e.head==="both")&&!P,ce=e.head==="column"||e.head==="both",Ae=Mt(e),Te=P?e.rows.slice(1):e.rows;return new F({layout:H.FIXED,width:{size:b.reduce((I,O)=>I+O,0),type:p.DXA},columnWidths:b,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:Te.map((I,O)=>new G({tableHeader:q&&O===0,cantSplit:!0,children:Array.from({length:f},(_e,Ee)=>{const Re=q&&O===0,ke=ce&&Ee===0&&!Re;return new _({width:{size:b[Ee]??0,type:p.DXA},...Re?{shading:B(_t)}:{},borders:{top:O===0?{style:y.SINGLE,size:8,color:ge}:{style:y.NONE,size:0,color:"auto"},left:{style:y.NONE,size:0,color:"auto"},right:{style:y.NONE,size:0,color:"auto"},bottom:O===Te.length-1?{style:y.SINGLE,size:8,color:ge}:Re?{style:y.SINGLE,size:6,color:ge}:{style:y.SINGLE,size:4,color:Me}},margins:{top:E(o.cell.top),bottom:E(o.cell.top),left:E(o.cell.side),right:E(o.cell.side),marginUnitType:p.DXA},children:[new h({spacing:{after:0},...Ae.has(Ee)?{alignment:m.RIGHT}:{},children:U(I[Ee]??[],{bold:ke||Re,size:o.small*2})})]})})}))})},ae=(e,t,i,f,g,a)=>{const d=j(e.align),s={...L(t),...d===void 0?{}:{alignment:d}},R=i===void 0?void 0:e.caption,C=R!==void 0,A=[new h({...s,keepNext:C,...i?{spacing:{line:240,lineRule:n.LineRuleType.AUTO,...C?{after:E(o.caption)}:{}}}:{},children:i?[new x({type:i.type,data:i.data,transformation:Ut(i,e.width,t.room-t.indent),altText:{name:e.alt??"",title:e.caption??e.alt??"",description:e.alt??""}})]:[new M({text:f,color:de})]})];return R!==void 0&&A.push(new h({...s,style:"Caption",children:T(a,[new M({text:Oe(R,g)})])})),A},ye=(e,t)=>{const i=t.room-t.indent,f=e.columns.map(A=>A.width??1),g=f.reduce((A,v)=>A+v,0)||1,a=f.map(A=>Math.round(i*A/g)),d=it(e,t.frame),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s,insideHorizontal:s,insideVertical:s},C=Ht/2;return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:a,borders:R,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:ft(e,r.page),children:e.columns.map((A,v)=>{const b=a[v]??0,P=v===0?0:C,q=v===e.columns.length-1?0:C,ce=N(V(A.blocks,{indent:0,level:0,room:b-P-q,frame:d[v]??t.frame}));return new _({width:{size:b,type:p.DXA},borders:R,margins:{top:0,bottom:0,left:P,right:q,marginUnitType:p.DXA},children:ce})})})]})},K=(e,t,i)=>{const f=ee(e.look?.color,Se),g=V(e.children??[],Ke(t)),a=D(e.look),d=Ge;return e.type==="check"?[new h({...a,...L(t),style:d,children:[new M({text:e.checked?"☑ ":"☐ "}),...U(e.content,{color:f})]}),...g]:[new h({...a,style:d,numbering:e.type==="bullet"?{reference:Be,level:t.level}:{reference:`start-${String(i.start)}`,level:t.level,instance:i.id},children:U(e.content,{color:f})}),...g]},De=(e,t)=>{const i="look"in e?e.look:void 0,f=ee(i?.color,Se),g=D(i),a=()=>"children"in e?V(e.children??[],Ke(t)):[];switch(e.type){case"paragraph":case"toggle":return[new h({...r.sets.align&&e.look?.align===void 0?{alignment:m.JUSTIFIED}:{},...g,...r.sets.indent&&e.type==="paragraph"?{indent:{left:t.indent,firstLine:Math.round(r.page.textIndent*r.page.size*20)}}:L(t),children:U(e.content,{color:f})}),...a()];case"heading":return[new h({...g,...L(t),...e===r.title?{heading:n.HeadingLevel.TITLE}:{heading:n.HeadingLevel[`HEADING_${String(e.level)}`]},children:T(r.anchors.get(e),U(e.content,{color:f}))}),...a()];case"quote":return[new h({...g,indent:{left:t.indent+E(o.quote)},border:{left:{style:y.SINGLE,color:c??ge,size:c?12:6,space:Math.floor(o.quote-(c?1.5:.75))}},children:U(e.content,{color:f??fe})}),...a()];case"callout":return[me(e,t),...J()];case"card":return[we(e,t),...J()];case"stats":return[oe(e,t),...J()];case"code":{if(e.language===ve.math||e.language===ve.mermaid){const R=u.drawn?.(e);if(R)return ae({...e.language===ve.math?{}:{align:"center"}},t,R,"")}const d=R=>({style:y.SINGLE,color:Ce,size:4,space:R}),s=E(o.box.side+.5);return[new h({indent:{left:t.indent+s,right:s},shading:B(Ce),border:{top:d(o.box.top),bottom:d(o.box.top),left:d(o.box.side),right:d(o.box.side)},keepLines:!0,children:e.code.split(`
4
+ `).map((R,C)=>new M({text:R,font:X,size:o.small*2,...C>0?{break:1}:{}}))})]}case"columns":return[ye(e,t)];case"chart":{const d=r.numbers.get(e),s=d===void 0?void 0:e.title,{chart:R,problems:C}=nt(s===void 0?e:ct(e),u),A=he(y.DASHED,Me);if(!R)return[new h({...L(t),alignment:m.CENTER,border:{top:A,bottom:A,left:A,right:A},children:[new M({text:[e.title??"Chart",...C].join(": "),color:de})]})];const v=et(e,t.frame),b=(t.room-t.indent)/ue,P=Math.min(1,b/v.width);return k.push({chart:R,width:Math.round(v.width*P),height:Math.round(v.height*P),words:tt(e,R)}),[new h({...L(t),alignment:m.CENTER,keepNext:s!==void 0,spacing:{line:240,lineRule:n.LineRuleType.AUTO},children:[new M({text:`${je}${String(k.length)}`})]}),...s===void 0?[]:[new h({...L(t),alignment:m.CENTER,style:"Caption",children:T(e.id,[new M({text:Oe(s,d)})])})]]}case"image":return ae(e,t,u.picture?.(e.src),e.alt??e.caption??e.src,r.numbers.get(e),e.id);case"component":{const d=u.component?.(e);if(d)return ae(e,t,d,"",r.numbers.get(e),e.id);const s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:ot(e),color:de})]})]}case"table":return[...e.caption===void 0?[]:[new h({...L(t),style:"Caption",keepNext:!0,spacing:{after:E(o.caption)},children:T(e.id,[new M({text:Oe(e.caption,r.numbers.get(e))})])})],se(e,t),...J()];case"pagebreak":return[new h({spacing:{before:0,after:0,line:20,lineRule:n.LineRuleType.EXACT},children:[new n.PageBreak]})];case"bibliography":{const{page:d}=r,s=d.textIndent>0?Math.round(d.textIndent*d.size*20):480;return r.sources.map(R=>new h({...L(t),alignment:m.LEFT,indent:{left:t.indent+s,hanging:s},spacing:{after:E(o.after)},children:R.pieces.map(C=>{const A=C.italic?{italics:!0}:{};return new M({text:C.text,...A})})}))}case"toc":{const d=e.levels??3,s=r.headings.filter(A=>A.level<=d).map(A=>{const v=r.anchors.get(A)??"",b=u.headingPage?.(v),P=r.bookmarks.get(v);return{title:A.content.map(q=>q.text).join(""),level:A.level,...b===void 0?{}:{page:b},...P===void 0?{}:{href:P}}}),R=Math.min(...s.map(A=>A.level)),C=at(e,r.chinese);return[...C===""?[]:[new h({style:qe,text:C})],new n.TableOfContents(void 0,{hyperlink:!0,headingStyleRange:`1-${String(d)}`,beginDirty:!1,cachedEntries:s.map(A=>({...A,level:A.level-R+1}))})]}case"note":return[];case"divider":return[new h({...L(t),spacing:{before:E(o.divider),after:E(o.divider),line:20,lineRule:n.LineRuleType.EXACT},border:{bottom:{style:y.SINGLE,color:Le,size:4,space:0}}})];case"embed":{const d=/^<\s*([A-Za-z][\w.]*)/.exec(e.source.trim())?.[1],s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:d??"",color:de})]})]}case"source":return[];case"bullet":case"numbered":case"check":return[]}};function V(e,t){const i=[];let f,g;for(const a of e){if(!Xt(a)){f=void 0,g=void 0,i.push(...De(a,t));continue}if(f===void 0||g===void 0||g.type==="numbered"!=(a.type==="numbered")){const d=a.type==="numbered"?a.start??1:1;$.add(d),f={id:++ne,start:d}}g=a,i.push(...K(a,t,f))}return i.flatMap((a,d)=>a instanceof F&&i[d+1]instanceof F?[a,Q(0)]:[a])}return{charts:k,body:(e,t)=>V(e,Ne(t)),footnotes:e=>Object.fromEntries([...ze(e)].flatMap(t=>{if(t.type!=="note")return[];const i=S.get(t.label.toLowerCase());if(i===void 0)return[];const f=V(t.children??[],Ne(Y(r.page.width)-Y(r.page.margins.left+r.page.margins.right))).filter(g=>g instanceof h);return[[String(i),{children:[new h({spacing:{after:40},children:U(t.content,{size:18,color:fe})}),...f]}]]})),numbering:()=>[{reference:Be,levels:Array.from({length:9},(e,t)=>({level:t,format:n.LevelFormat.BULLET,text:["•","◦","▪"][t%3]??"•",alignment:m.LEFT,style:{paragraph:{indent:{left:(t+1)*pe,hanging:pe}}}}))},...[...$].sort((e,t)=>e-t).map(e=>({reference:`start-${String(e)}`,levels:Array.from({length:9},(t,i)=>({level:i,format:[n.LevelFormat.DECIMAL,n.LevelFormat.LOWER_LETTER,n.LevelFormat.LOWER_ROMAN][i%3]??n.LevelFormat.DECIMAL,text:`%${String(i+1)}.`,alignment:m.LEFT,...i===0?{start:e}:{},style:{paragraph:{indent:{left:(i+1)*pe,hanging:pe}}}}))}))]}}const Bt="1980-01-01T00:00:00Z",Ye=9525,Ve="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Wt=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function jt(n,u,w,c,S){return n.forEach((z,r)=>{const m=String(r+1),y=`rIdChart${m}`,l=`Microsoft_Excel_Worksheet${m}.xlsx`;S(`word/charts/chart${m}.xml`,Je(z.chart,{width:z.width*.75,height:z.height*.75},"rId1",{frameless:!0})),S(`word/charts/_rels/chart${m}.xml.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${Ve}/package" Target="../embeddings/${l}"/></Relationships>`),S(`word/embeddings/${l}`,Qe(z.chart)),w=w.replace("</Relationships>",`<Relationship Id="${y}" Type="${Ve}/chart" Target="charts/chart${m}.xml"/></Relationships>`),c=c.replace("</Types>",`<Override ContentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml" PartName="/word/charts/chart${m}.xml"/></Types>`);const x=String(z.width*Ye),h=String(z.height*Ye),Z=`<w:r><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${x}" cy="${h}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="0" name="Chart ${m}" descr="${Wt(z.words)}"/><wp:cNvGraphicFramePr/><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" r:id="${y}"/></a:graphicData></a:graphic></wp:inline></w:drawing></w:r>`;u=u.replace(new RegExp(`<w:r>(?:(?!<w:r>).)*?<w:t[^>]*>${je}${m}</w:t></w:r>`,"su"),Z)}),n.length>0&&!c.includes('Extension="xlsx"')&&(c=c.replace("</Types>",'<Default ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Extension="xlsx"/></Types>')),{document:u,rels:w,types:c}}function Kt(n,u,w){const c=u.unzipSync(n),S=p=>{const N=c[p];return N&&new TextDecoder().decode(N)},z=(p,N)=>{c[p]=typeof N=="string"?new TextEncoder().encode(N):N},r="word/document.xml",m="word/_rels/document.xml.rels",y="[Content_Types].xml",l=jt(w,S(r)??"",S(m)??"",S(y)??"",z);z(y,l.types);let x=l.document,h=l.rels;[...new Set([...x.matchAll(/w:hyperlink [^>]*r:id="([^"]+)"/g)].map(p=>p[1]??""))].forEach((p,N)=>{const X=`rIdLink${String(N+1)}`;x=x.split(`"${p}"`).join(`"${X}"`),h=h.split(`"${p}"`).join(`"${X}"`)});let F=0;x=x.replace(/<wp:docPr id="\d+"/g,()=>`<wp:docPr id="${String(++F)}"`);const _=new Map;x=x.replace(/<w:bookmarkStart w:name="([^"]*)" w:id="(\d+)"/g,(p,N,X)=>{const $=String(_.size+1);return _.set(X,$),`<w:bookmarkStart w:name="${N}" w:id="${$}"`}),x=x.replace(/<w:bookmarkEnd w:id="(\d+)"/g,(p,N)=>{const X=_.get(N);return X===void 0?p:`<w:bookmarkEnd w:id="${X}"`}),z(r,x),z(m,h);const H="docProps/core.xml",G=S(H);G!==void 0&&z(H,G.replace(/(<dcterms:(?:created|modified)[^>]*>)[^<]*/g,`$1${Bt}`));const M=Object.fromEntries(Object.entries(c).sort(([p],[N])=>p<N?-1:1));return u.zipSync(M,{mtime:new Date(1980,0,1)})}const be=(n,u)=>{const w=We[n];return{ascii:w.latin,hAnsi:w.latin,cs:w.latin,eastAsia:w.eastAsia??u}};function qt(n,u,w){const c={left:[],center:[],right:[]};u.left!==void 0&&c.left.push(u.left),u.center!==void 0&&c.center.push(u.center),u.right!==void 0&&c.right.push(u.right),u.outside!==void 0&&c[w.odd?"right":"left"].push(u.outside),u.inside!==void 0&&c[w.odd?"left":"right"].push(u.inside);const S={size:Math.round(w.size*2),color:w.color,font:be(w.face,w.eastAsia)},z=r=>r.split(/(\{title\}|\{section\}|\{page\}|\{pages\})/u).filter(m=>m!=="").map(m=>m==="{page}"?new n.TextRun({...S,children:[n.PageNumber.CURRENT]}):m==="{pages}"?new n.TextRun({...S,children:[n.PageNumber.TOTAL_PAGES]}):m==="{section}"?new n.SimpleField(`STYLEREF "heading ${String(w.section)}"`,""):new n.TextRun({...S,text:m==="{title}"?w.title:m}));return new n.Paragraph({style:w.style,tabStops:[{type:n.TabStopType.CENTER,position:Math.round(w.width/2)},{type:n.TabStopType.RIGHT,position:w.width}],children:[...z(c.left.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(c.center.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(c.right.join(" "))]})}const Ze=(n,u,w,c)=>({run:{...u?.font===void 0?{}:{font:be(n.font,w)},...u?.size===void 0?{}:{size:Math.round(n.size*2)},...u?.weight===void 0?{}:{bold:n.weight==="bold"},...u?.italic===void 0?{}:{italics:n.italic}},paragraph:u?.align===void 0?{}:{alignment:n.align==="center"?c.AlignmentType.CENTER:n.align==="right"?c.AlignmentType.RIGHT:c.AlignmentType.LEFT}});function Yt(n){const u=new Map,w=new Set;return n.forEach((c,S)=>{const z=c.replace(/[^A-Za-z0-9_]/gu,"_").replace(/^[^A-Za-z]+/u,"");let r=`b_${z}`.slice(0,32);(w.has(r)||z==="")&&(r=`b_${String(S)}_${z}`.slice(0,40)),w.add(r),u.set(c,r)}),u}export async function docxOf(n,u,w,c={}){const S=c.page??{},z=Fe(S).citationStyle??"apa",r=ht(Ct(w,c),c.sources??[],z,"block"),m=lt(w,c.sources??[],z),y=Fe(S),l=Et(S),x=We[l.font].eastAsia??$t(St(r)),h=be(l.font,x),Z=ee(wt(c.page),{}),F=mt(r),_=st(r,S),H=new Map;for(const T of ze(r)){const D=$e(T),L=_.get(T);D!==void 0&&L!==void 0&&H.set(D,L.label)}for(const[T,D]of F)T.type==="heading"&&H.set(D,T.content.map(L=>L.text).join(""));const{title:G}=Rt(r),M=[...ze(r)].filter(T=>T.type==="heading"&&T!==G),p=Yt([...F.values(),...[...ze(r)].flatMap(T=>{const D=$e(T);return D===void 0?[]:[D]})]),N=Gt(n,c,x,Z,Dt(r),xt(r),{page:l,sets:{indent:y.textIndent!==void 0&&y.textIndent>0,align:y.textAlign==="justify"},numbers:_,refs:H,bookmarks:p,anchors:F,title:G,headings:M,chinese:dt(r),sources:m}),X=gt(r),$={width:Y(l.width),height:Y(l.height)},ne={top:Y(l.margins.top),bottom:Y(l.margins.bottom),left:Y(l.margins.left),right:Y(l.margins.right)},k=c.cover,B=[l.header,l.footer].some(T=>T!==void 0&&(T.outside!==void 0||T.inside!==void 0)),he=X.map((T,D)=>{const L=T.landscape?$.height:$.width,re=L-ne.left-ne.right,me=N.body(T.blocks,re);if(D===0&&k){const K=Math.round(L/ue);me.unshift(new n.Paragraph({spacing:{before:0,after:0},children:[new n.ImageRun({type:k.type,data:k.data,transformation:{width:K,height:Math.round(K*bt)},floating:{horizontalPosition:{relative:n.HorizontalPositionRelativeFrom.PAGE,offset:0},verticalPosition:{relative:n.VerticalPositionRelativeFrom.PAGE,offset:0},allowOverlap:!1,margins:{bottom:324e3},wrap:{type:n.TextWrappingType.TOP_AND_BOTTOM}},altText:{name:"Cover",title:"Cover",description:""}})]}))}const we=(K,De,V)=>{if(K===void 0)return;const e=t=>qt(n,K,{style:V,odd:t,width:re,title:c.title??"",section:Math.min(...M.map(i=>i.level),6),face:K.font??l.font,eastAsia:x,size:K.size===void 0?Math.max(7.5,l.size*.75):He(K.size),color:De?de:le});return{default:e(!0),...B?{even:e(!1)}:{}}},oe=we(l.header,y.header===void 0,"Header"),se=we(l.footer,y.footer===void 0,"Footer"),ae=D===0&&k!==void 0&&oe!==void 0,ye=y.grid===void 0?void 0:{type:n.DocumentGridType.LINES_AND_CHARS,linePitch:Math.round(Tt(l)*20),charSpace:Math.round(l.textWidth/25.4*72/y.grid.chars-l.size)*4096};return{properties:{page:{size:{width:Math.min($.width,$.height),height:Math.max($.width,$.height),...T.landscape||$.width>$.height?{orientation:n.PageOrientation.LANDSCAPE}:{}},margin:{...ne,header:Math.max(0,ne.top-Y(7)-Math.round(l.size*20*1.2)),footer:Math.max(0,ne.bottom-Y(7)-Math.round(l.size*20*1.2))}},...ye===void 0?{}:{grid:ye},...ae?{titlePage:!0}:{}},...oe===void 0?{}:{headers:{default:new n.Header({children:[oe.default]}),...oe.even?{even:new n.Header({children:[oe.even]})}:{},...ae?{first:new n.Header({children:[]})}:{}}},...se===void 0?{}:{footers:{default:new n.Footer({children:[se.default]}),...se.even?{even:new n.Footer({children:[se.even]})}:{},...ae?{first:new n.Footer({children:[se.default]})}:{}}},children:me}}),o=l.lineHeight,E={spacing:{after:Math.round(l.paragraphSpacing*l.size*20),..."pt"in o?{line:Math.round(o.pt*20),lineRule:n.LineRuleType.EXACT}:{line:Math.round(o.multiple*240),lineRule:n.LineRuleType.AUTO}}},Q=l.spacing,J=T=>Math.round(T*20),j=T=>{const D=y.headings?.[T],L=Ze(l.headings[T],D,x,n);return{run:{size:Math.round(l.headings[T].size*2),bold:!0,font:h,color:le,...L.run},paragraph:{spacing:{before:J(Q.heading.before),after:J(Q.heading.after)},keepNext:!0,keepLines:!0,...l.headings[T].rule?{border:{bottom:{style:n.BorderStyle.SINGLE,size:4,color:Le,space:ut}}}:{},...L.paragraph}}},ie=Ze(l.title,y.title,x,n),U=new n.Document({creator:"AllyHub",lastModifiedBy:"AllyHub",...c.title===void 0?{}:{title:c.title},...B?{evenAndOddHeaderAndFooters:!0}:{},numbering:{config:N.numbering()},styles:{default:{document:{run:{font:h,size:Math.round(l.size*2),color:le},paragraph:E},hyperlink:{run:{color:Z??le,underline:{color:Z??ge}}},title:{run:{size:Math.round(l.title.size*2),bold:!0,font:h,color:le,...ie.run},paragraph:{spacing:{before:0,after:J(Q.title)},keepNext:!0,...ie.paragraph}},heading1:j(1),heading2:j(2),heading3:j(3),heading4:j(4),heading5:j(5),heading6:j(6)},paragraphStyles:[{id:qe,name:"TOC Heading",basedOn:"Normal",next:"Normal",quickFormat:!0,...j(1)},{id:"Caption",name:"caption",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:Q.small*2,color:de},paragraph:{spacing:{before:0}}},{id:Ge,name:"List Paragraph",basedOn:"Normal",quickFormat:!0,paragraph:{contextualSpacing:!0}},...[["Header",l.header,y.header===void 0],["Footer",l.footer,y.footer===void 0]].flatMap(([T,D,L])=>D===void 0?[]:[{id:T,name:T.toLowerCase(),basedOn:"Normal",run:{size:Math.round((D.size===void 0?Math.max(7.5,l.size*.75):He(D.size))*2),color:L?de:le,font:be(D.font??l.font,x)},paragraph:{spacing:{before:0,after:0,line:240}}}])]},sections:he,footnotes:N.footnotes(r)}),xe=await n.Packer.toBuffer(U);return Kt(new Uint8Array(xe),u,N.charts)}
@@ -1,13 +1,13 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{chartColor as te,chartFrame as ne,docChartSvg as ie}from"./chart.js";import{emojiPicturesScript as oe}from"@allyhub/browser/emoji";export{EMOJI_PATTERN}from"@allyhub/browser/emoji";import{BACKGROUNDS as B,TEXT_COLORS as D}from"./color.js";import{columnWidths as ae,COLUMN_GAP as se}from"./columns.js";import{COMPONENT_WIDTH as U,componentName as re}from"./component.js";import{citationText as de,citedOf as le,sourceList as ce}from"./cite.js";import{blockId as pe,captionNumbers as fe,contentsTitle as he,numberedCaption as R,writtenInChinese as ge,withoutTitle as ue}from"./captions.js";import{DRAWN_CODE as K,mathHtml as me}from"./math.js";import{charsAcross as X,columnShares as $e,emptyHead as be,numberColumns as ke}from"./table.js";import{splitTitle as xe}from"./title.js";import{PAPER as c,TONE_COLORS as Z,tagColors as we}from"./paper.js";import{COVER_HEIGHT_MM as ye,everyBlock as q,innerBlocks as Se,noteNumbers as ve,statTone as Ce}from"./model.js";import{effectiveLook as H,lineMultiple as ze,resolvePage as j,SINGLE_LINE as I}from"./page.js";export const PAGE_FACES={sans:'Carlito, Calibri, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif',serif:'Caladea, Cambria, "Noto Serif SC", "Songti SC", Georgia, serif',times:'Tinos, "Times New Roman", Times, "Noto Serif SC", serif',mono:'Cousine, "Courier New", "Noto Sans SC", monospace',song:'"Noto Serif SC", "Songti SC", SimSun, "宋体", serif',hei:'"Noto Sans SC", "PingFang SC", SimHei, "黑体", sans-serif',fangsong:'FangSong, STFangsong, "仿宋", "FangSong_GB2312", "Noto Serif SC", serif',kai:'"LXGW WenKai", KaiTi, STKaiti, "楷体", "Noto Serif SC", serif',xiaobiaosong:'"FZXiaoBiaoSong-B05S", "方正小标宋简体", "Noto Serif SC", "Songti SC", serif'};export function pageFaces(i={}){const n=H(i).font??"sans";return{text:PAGE_FACES[n],heading:PAGE_FACES[n],mono:PAGE_FACES.mono}}export const pageAccent=(i={})=>i.accent===void 0?void 0:te(i.accent);export{BACKGROUNDS,TEXT_COLORS}from"./color.js";export function blockNumbers(i){const n=new Map;for(const e of q(i))n.set(e,n.size);return n}const p=i=>i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),O=(i,n)=>n[i]??(/^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl)a?\([\d\s.,%/]+\))$/i.test(i)?i:void 0),h=(i,n)=>{const e=n.ids?.get(i);return e===void 0?"":` data-b="${String(e)}"`};export function headingAnchors(i){const n=new Map,e=new Map;for(const a of q(i)){if(a.type!=="heading")continue;const s=a.content.map(r=>r.text).join("").trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s/gu,"-"),t=s===""?"section":s,o=e.get(t)??0;e.set(t,o+1),n.set(a,o===0?t:`${t}-${String(o)}`)}return n}function x(i,n){return i.map(e=>{if(e.cite!==void 0){const{items:d,numbers:l,style:f}=n.sources,g=le(e.cite).keys[0],w=p(de(e.cite,d,l,f));return g!==void 0&&l.has(g)?`<a class="cite" href="#source-${p(g)}">${w}</a>`:`<span class="cite">${w}</span>`}if(e.note!==void 0){const d=n.notes.get(e.note.toLowerCase());return d===void 0?`<sup class="fn">[${p(e.note)}]</sup>`:`<sup class="fn"><a href="#note-${String(d)}">${String(d)}</a></sup>`}const a=e.text===""&&e.href?.startsWith("#")===!0?n.refs.get(decodeURIComponent(e.href.slice(1)))??"":e.text;let s=p(a).replace(/\n/g,"<br>");const t=e.styles;t.code&&(s=`<code>${s}</code>`),t.strike&&(s=`<s>${s}</s>`),t.italic&&(s=`<em>${s}</em>`),t.bold&&(s=`<strong>${s}</strong>`),t.underline&&(s=`<u>${s}</u>`);const o=t.color===void 0?void 0:O(t.color,D),r=t.background===void 0?void 0:O(t.background,B);if((o!==void 0||r!==void 0)&&(s=`<span style="${o===void 0?"":`color:${o};`}${r===void 0?"":`background:${r};`}">${s}</span>`),t.tag!==void 0){const d=we(t.tag);s=`<span class="tag" style="background:${d.bg};color:${d.fg}">${s}</span>`}return e.href!==void 0&&/^(https?:|mailto:|#|\/|\.)/i.test(e.href)&&(s=`<a href="${p(e.href)}">${s}</a>`),s}).join("")}function N(i,n=!1){if(!i)return"";const e=i.color===void 0?void 0:O(i.color,D),a=i.background===void 0?void 0:O(i.background,B),s=[i.align===void 0?"":`text-align:${i.align};`,e===void 0?"":`color:${e};`,a===void 0?"":n?`background:${a};`:`background:${a};padding:0.15em 0.4em;border-radius:3px;`].join("");return s===""?"":` style="${s}"`}const Y=i=>i.type==="bullet"||i.type==="numbered"||i.type==="check";function y(i,n,e){const a=[];let s=0;for(;s<i.length;){const t=i[s];if(t===void 0)break;if(Y(t)){const o=t.type==="numbered";let r=s;const d=[];for(;r<i.length;){const f=i[r];if(!f||!Y(f)||f.type==="numbered"!==o)break;const g=f.type==="check"?`<span class="box${f.checked?" done":""}"></span>`:"";d.push(`<li${h(f,e)}${f.type==="check"?` class="task${f.checked?" done":""}"`:""}${N(f.look)}>${g}<span class="words">${x(f.content,e)}</span>${y(f.children??[],n,e)}</li>`),r++}const l=t.type==="numbered"&&t.start!==void 0?` start="${String(t.start)}"`:"";a.push(o?`<ol${l}>${d.join("")}</ol>`:`<ul>${d.join("")}</ul>`),s=r;continue}switch(s++,t.type){case"paragraph":a.push(`<p${h(t,e)}${N(t.look)}>${x(t.content,e)||"&nbsp;"}</p>${W(t.children,n,e)}`);break;case"heading":{const o=`h${String(t.level)}`;a.push(`<${o} id="${p(e.anchors.get(t)??"")}"${h(t,e)}${N(t.look)}>${x(t.content,e)}</${o}>${W(t.children,n,e)}`);break}case"toggle":a.push(`<p${h(t,e)}${N(t.look)}>${x(t.content,e)}</p>${W(t.children,n,e)}`);break;case"quote":a.push(`<blockquote${h(t,e)}${N(t.look)}><p>${x(t.content,e)}</p>${y(t.children??[],n,e)}</blockquote>`);break;case"callout":a.push(`<div class="callout"${h(t,e)}${N(t.look,!0)}>${t.icon===void 0?"":`<span class="callout-icon">${p(t.icon)}</span>`}<div><p>${x(t.content,e)}</p>${y(t.children??[],n,e)}</div></div>`);break;case"card":a.push(`<div class="card${cardKept(t,j(n.page))?" kept":""}"${h(t,e)}>${t.title===void 0&&t.subtitle===void 0?"":`<div class="card-head">${t.title===void 0?"":`<p class="card-title">${p(t.title)}</p>`}${t.subtitle===void 0?"":`<p class="card-subtitle">${p(t.subtitle)}</p>`}</div>`}${y(t.children??[],{...n,room:(n.room??U)-2*Te},e)}</div>`);break;case"stats":a.push(`<div class="stats"${h(t,e)} style="grid-template-columns:repeat(${String(t.stats.length)},minmax(0,1fr))">${t.stats.map(o=>{const r=Ce(o),d=o.delta===void 0&&o.note===void 0?"":`<p class="stat-foot">${o.delta===void 0?"":`<span class="stat-delta" style="color:${Z[r]}">${p(o.delta)}</span>`}${o.delta!==void 0&&o.note!==void 0?" ":""}${o.note===void 0?"":p(o.note)}</p>`,l=o.trend===void 0?"":trendSvg(o.trend,Z[r==="flat"?"flat":r]);return`<div class="stat"><p class="stat-label">${p(o.label)}</p><p class="stat-value">${p(o.value)}</p>${d}${l}</div>`}).join("")}</div>`);break;case"code":a.push(Ne(t,n,h(t,e)));break;case"columns":{const o=t.columns.map(d=>`${String(d.width??1)}fr`).join(" "),r=ae(t,n.room);a.push(`<div class="columns${columnsKept(t,j(n.page))?" kept":""}"${h(t,e)} style="grid-template-columns:${o}">${t.columns.map((d,l)=>`<div class="column">${y(d.blocks,{...n,room:r[l]??U},e)}</div>`).join("")}</div>`);break}case"chart":{const o=e.numbers.get(t),r=o===void 0?t:ue(t),{svg:d,problems:l}=ie(r,{...n,font:pageFaces(n.page).text}),{width:f}=ne(t,n.room),g=o===void 0||t.title===void 0?"":`<figcaption>${p(R(t.title,o))}</figcaption>`;a.push(d===void 0?`<div class="embed"${h(t,e)} data-chart>${p(t.title??"Chart")}<br><small>${p(l.join("; "))}</small></div>`:`<figure class="chart"${L(t.id)}${h(t,e)} style="max-width:${String(f)}px">${d}${g}</figure>`);break}case"image":{const o=n.image?.(t.src)??t.src;a.push(`<figure${L(t.id)}${h(t,e)}${t.align===void 0?"":` style="text-align:${t.align}"`}><img src="${p(o)}" alt="${p(t.alt??"")}"${t.width===void 0?"":` width="${String(t.width)}"`}>${t.caption===void 0?"":`<figcaption>${p(R(t.caption,e.numbers.get(t)))}</figcaption>`}</figure>`);break}case"table":{const o=t.head===void 0||t.head==="both",r=t.head==="column"||t.head==="both",d=ke(t),l=be(t),f=(m,b,T)=>`<tr${e.ids===void 0?"":` data-row="${String(T)}"`}>${m.map((_,F)=>{const G=b||r&&F===0?"th":"td",ee=d.has(F)?' class="num"':"";return`<${G}${ee}>${x(_,e)}</${G}>`}).join("")}</tr>`,g=j(n.page),w=(t.widths??[]).reduce((m,b)=>m+(b??0),0),M=n.room??g.textWidth*96/25.4,C=$e(t,{across:X(Math.max(M-w,0),g.spacing.small),margins:X(2*g.spacing.cell.side*96/72,g.spacing.small)}),z=C.reduce((m,b,T)=>m+(t.widths?.[T]?0:b),0)||1,P=`<colgroup>${C.map((m,b)=>{const T=t.widths?.[b],_=$(m/z*100);return T?`<col style="width:${String(T)}px">`:w===0?`<col style="width:${_}%">`:`<col style="width:calc((100% - ${String(w)}px) * ${$(m/z)})">`}).join("")}</colgroup>`,[E,...A]=t.rows,u=o&&E!==void 0&&!l?`<thead>${f(E,!0,0)}</thead>`:"",S=(o?A:t.rows).map((m,b)=>f(m,!1,o?b+1:b)).join(""),v=t.caption===void 0?"":`<caption>${p(R(t.caption,e.numbers.get(t)))}</caption>`;a.push(`<table${L(t.id)}${h(t,e)}>${v}${P}${u}<tbody>${S}</tbody></table>`);break}case"divider":a.push(`<hr${h(t,e)}>`);break;case"pagebreak":a.push(`<div class="page-break"${h(t,e)}></div>`);break;case"toc":a.push(Ee(t,e));break;case"bibliography":e.listed||(e.listed=!0,a.push(J(e,h(t,e))));break;case"note":break;case"component":{const o=n.component?.(t),r=t.align===void 0?"":` style="text-align:${t.align}"`;a.push(o===void 0?`<div class="embed"${h(t,e)} data-component>${p(re(t))}</div>`:`<figure${L(t.id)}${h(t,e)}${r}><img src="${p(o)}" alt="${p(t.alt??"")}"${t.width===void 0?"":` width="${String(t.width)}"`}>${t.caption===void 0?"":`<figcaption>${p(R(t.caption,e.numbers.get(t)))}</figcaption>`}</figure>`);break}case"embed":{const o=n.embed?.(t.source,e.embeds);e.embeds++;const r=/^<\s*([A-Za-z][\w.]*)/.exec(t.source.trim())?.[1];a.push(o===void 0?`<div class="embed"${h(t,e)} data-embed>${p(r??"")}</div>`:`<div${h(t,e)}>${o}</div>`);break}case"source":break}}return a.join(`
3
- `)}function J(i,n=""){const{list:e,style:a}=i.sources;return e.length===0?"":`<section class="sources" data-style="${a}"${n}><ol>${e.map(s=>`<li id="source-${p(s.item.id)}">${s.pieces.map(t=>t.italic?`<i>${p(t.text)}</i>`:p(t.text)).join("")}</li>`).join("")}</ol></section>`}const L=i=>i===void 0?"":` id="${p(i)}"`;function Ee(i,n){const e=i.levels??3,a=n.headings.filter(r=>r.block.level<=e),s=Math.min(...a.map(r=>r.block.level)),t=a.map(({block:r,anchor:d})=>{const l=n.headingPage?.(d);return`<li style="padding-left:${String(r.level-s)}em"><a href="#${p(d)}"><span class="toc-words">${x(r.content,n)}</span>${l===void 0?"":`<span class="toc-fill"></span><span class="toc-page">${String(l)}</span>`}</a></li>`}),o=he(i,n.chinese);return`<nav class="toc"${h(i,n)}>${o===""?"":`<p class="toc-title">${p(o)}</p>`}<ol>${t.join("")}</ol></nav>`}export function keptWhole(i,n,e=0){const a=.35277777777777775,s="pt"in n.lineHeight?n.lineHeight.pt:n.lineHeight.multiple*(I[n.font]??1.22)*n.size,t=Math.max(20,(n.textWidth/a-30)/(n.size*.5)),o=r=>r.reduce((d,l)=>{if(l.type==="table")return d+l.rows.length*1.6+1;if(l.type==="chart"||l.type==="image"||l.type==="component")return d+18;if(l.type==="card")return d+2+o(l.children??[]);const f="content"in l?Math.max(1,Math.ceil(l.content.map(g=>g.text).join("").length/t))+.5:2;return d+f+o(Se(l))},0);return(e+o(i))*s<n.textHeight/a*.6}export const cardKept=(i,n)=>keptWhole(i.children??[],n,2),columnsKept=(i,n)=>i.columns.every(e=>keptWhole(e.blocks,n));const Te=15;export function trendSvg(i,n){const s=Math.min(...i),o=Math.max(...i)-s||1,d=i.map((l,f)=>[f/Math.max(1,i.length-1)*100,22-(l-s)/o*20]).map(([l,f],g)=>`${g===0?"M":"L"}${(l??0).toFixed(1)} ${(f??0).toFixed(1)}`).join(" ");return`<svg class="stat-trend" viewBox="0 0 ${String(100)} ${String(24)}" preserveAspectRatio="none" aria-hidden="true"><path d="${d}" fill="none" stroke="${n}" stroke-width="1.5" vector-effect="non-scaling-stroke" stroke-linejoin="round" stroke-linecap="round"/></svg>`}function Ne(i,n,e=""){if(i.language===K.math)return`<div class="math"${e}>${me(i.code).html}</div>`;if(i.language===K.mermaid){const a=n.diagram?.(i.code);if(a?.svg!==void 0)return`<figure class="diagram"${e}>${a.svg}</figure>`;if(a?.error!==void 0)return`<pre${e}><code>${p(i.code)}</code></pre><p class="drawn-error">Mermaid: ${p(a.error)}</p>`}return`<pre${e}><code>${je(i.code)}</code></pre>`}const je=i=>i.split(`
4
- `).map(n=>`<span class="line">${p(n)}</span>`).join(""),W=(i,n,e)=>i?.length?`<div class="under">${y(i,n,e)}</div>`:"";export const DOC_CSS=`
2
+ import{chartColor as te,chartFrame as ne,docChartSvg as ie}from"./chart.js";import{emojiPicturesScript as oe}from"@allyhub/browser/emoji";export{EMOJI_PATTERN}from"@allyhub/browser/emoji";import{BACKGROUNDS as B,TEXT_COLORS as D}from"./color.js";import{columnWidths as ae,COLUMN_GAP as se}from"./columns.js";import{COMPONENT_WIDTH as U,componentName as re}from"./component.js";import{citationText as de,citedOf as le,sourceList as ce}from"./cite.js";import{blockId as pe,captionNumbers as fe,contentsTitle as he,numberedCaption as R,writtenInChinese as ge,withoutTitle as ue}from"./captions.js";import{DRAWN_CODE as K,mathHtml as me}from"./math.js";import{charsAcross as X,columnShares as $e,emptyHead as be,numberColumns as ke,withTableData as xe}from"./table.js";import{splitTitle as we}from"./title.js";import{PAPER as l,TONE_COLORS as Z,tagColors as ye}from"./paper.js";import{COVER_HEIGHT_MM as Se,everyBlock as q,innerBlocks as ve,noteNumbers as Ce,statTone as ze}from"./model.js";import{effectiveLook as H,lineMultiple as Ee,resolvePage as j,SINGLE_LINE as I}from"./page.js";export const PAGE_FACES={sans:'Carlito, Calibri, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif',serif:'Caladea, Cambria, "Noto Serif SC", "Songti SC", Georgia, serif',times:'Tinos, "Times New Roman", Times, "Noto Serif SC", serif',mono:'Cousine, "Courier New", "Noto Sans SC", monospace',song:'"Noto Serif SC", "Songti SC", SimSun, "宋体", serif',hei:'"Noto Sans SC", "PingFang SC", SimHei, "黑体", sans-serif',fangsong:'FangSong, STFangsong, "仿宋", "FangSong_GB2312", "Noto Serif SC", serif',kai:'"LXGW WenKai", KaiTi, STKaiti, "楷体", "Noto Serif SC", serif',xiaobiaosong:'"FZXiaoBiaoSong-B05S", "方正小标宋简体", "Noto Serif SC", "Songti SC", serif'};export function pageFaces(i={}){const n=H(i).font??"sans";return{text:PAGE_FACES[n],heading:PAGE_FACES[n],mono:PAGE_FACES.mono}}export const pageAccent=(i={})=>i.accent===void 0?void 0:te(i.accent);export{BACKGROUNDS,TEXT_COLORS}from"./color.js";export function blockNumbers(i){const n=new Map;for(const e of q(i))n.set(e,n.size);return n}const p=i=>i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),O=(i,n)=>n[i]??(/^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl)a?\([\d\s.,%/]+\))$/i.test(i)?i:void 0),h=(i,n)=>{const e=n.ids?.get(i);return e===void 0?"":` data-b="${String(e)}"`};export function headingAnchors(i){const n=new Map,e=new Map;for(const a of q(i)){if(a.type!=="heading")continue;const s=a.content.map(r=>r.text).join("").trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s/gu,"-"),t=s===""?"section":s,o=e.get(t)??0;e.set(t,o+1),n.set(a,o===0?t:`${t}-${String(o)}`)}return n}function x(i,n){return i.map(e=>{if(e.cite!==void 0){const{items:d,numbers:c,style:f}=n.sources,g=le(e.cite).keys[0],w=p(de(e.cite,d,c,f));return g!==void 0&&c.has(g)?`<a class="cite" href="#source-${p(g)}">${w}</a>`:`<span class="cite">${w}</span>`}if(e.note!==void 0){const d=n.notes.get(e.note.toLowerCase());return d===void 0?`<sup class="fn">[${p(e.note)}]</sup>`:`<sup class="fn"><a href="#note-${String(d)}">${String(d)}</a></sup>`}const a=e.text===""&&e.href?.startsWith("#")===!0?n.refs.get(decodeURIComponent(e.href.slice(1)))??"":e.text;let s=p(a).replace(/\n/g,"<br>");const t=e.styles;t.code&&(s=`<code>${s}</code>`),t.strike&&(s=`<s>${s}</s>`),t.italic&&(s=`<em>${s}</em>`),t.bold&&(s=`<strong>${s}</strong>`),t.underline&&(s=`<u>${s}</u>`);const o=t.color===void 0?void 0:O(t.color,D),r=t.background===void 0?void 0:O(t.background,B);if((o!==void 0||r!==void 0)&&(s=`<span style="${o===void 0?"":`color:${o};`}${r===void 0?"":`background:${r};`}">${s}</span>`),t.tag!==void 0){const d=ye(t.tag);s=`<span class="tag" style="background:${d.bg};color:${d.fg}">${s}</span>`}return e.href!==void 0&&/^(https?:|mailto:|#|\/|\.)/i.test(e.href)&&(s=`<a href="${p(e.href)}">${s}</a>`),s}).join("")}function z(i,n=!1){if(!i)return"";const e=i.color===void 0?void 0:O(i.color,D),a=i.background===void 0?void 0:O(i.background,B),s=[i.align===void 0?"":`text-align:${i.align};`,e===void 0?"":`color:${e};`,a===void 0?"":n?`background:${a};`:`background:${a};padding:0.15em 0.4em;border-radius:3px;`].join("");return s===""?"":` style="${s}"`}const Y=i=>i.type==="bullet"||i.type==="numbered"||i.type==="check";function S(i,n,e){const a=[];let s=0;for(;s<i.length;){const t=i[s];if(t===void 0)break;if(Y(t)){const o=t.type==="numbered";let r=s;const d=[];for(;r<i.length;){const f=i[r];if(!f||!Y(f)||f.type==="numbered"!==o)break;const g=f.type==="check"?`<span class="box${f.checked?" done":""}"></span>`:"";d.push(`<li${h(f,e)}${f.type==="check"?` class="task${f.checked?" done":""}"`:""}${z(f.look)}>${g}<span class="words">${x(f.content,e)}</span>${S(f.children??[],n,e)}</li>`),r++}const c=t.type==="numbered"&&t.start!==void 0?` start="${String(t.start)}"`:"";a.push(o?`<ol${c}>${d.join("")}</ol>`:`<ul>${d.join("")}</ul>`),s=r;continue}switch(s++,t.type){case"paragraph":a.push(`<p${h(t,e)}${z(t.look)}>${x(t.content,e)||"&nbsp;"}</p>${W(t.children,n,e)}`);break;case"heading":{const o=`h${String(t.level)}`;a.push(`<${o} id="${p(e.anchors.get(t)??"")}"${h(t,e)}${z(t.look)}>${x(t.content,e)}</${o}>${W(t.children,n,e)}`);break}case"toggle":a.push(`<p${h(t,e)}${z(t.look)}>${x(t.content,e)}</p>${W(t.children,n,e)}`);break;case"quote":a.push(`<blockquote${h(t,e)}${z(t.look)}><p>${x(t.content,e)}</p>${S(t.children??[],n,e)}</blockquote>`);break;case"callout":a.push(`<div class="callout"${h(t,e)}${z(t.look,!0)}>${t.icon===void 0?"":`<span class="callout-icon">${p(t.icon)}</span>`}<div><p>${x(t.content,e)}</p>${S(t.children??[],n,e)}</div></div>`);break;case"card":a.push(`<div class="card${cardKept(t,j(n.page))?" kept":""}"${h(t,e)}>${t.title===void 0&&t.subtitle===void 0?"":`<div class="card-head">${t.title===void 0?"":`<p class="card-title">${p(t.title)}</p>`}${t.subtitle===void 0?"":`<p class="card-subtitle">${p(t.subtitle)}</p>`}</div>`}${S(t.children??[],{...n,room:(n.room??U)-2*Ne},e)}</div>`);break;case"stats":a.push(`<div class="stats"${h(t,e)} style="grid-template-columns:repeat(${String(t.stats.length)},minmax(0,1fr))">${t.stats.map(o=>{const r=ze(o),d=o.delta===void 0&&o.note===void 0?"":`<p class="stat-foot">${o.delta===void 0?"":`<span class="stat-delta" style="color:${Z[r]}">${p(o.delta)}</span>`}${o.delta!==void 0&&o.note!==void 0?" ":""}${o.note===void 0?"":p(o.note)}</p>`,c=o.trend===void 0?"":trendSvg(o.trend,Z[r==="flat"?"flat":r]);return`<div class="stat"><p class="stat-label">${p(o.label)}</p><p class="stat-value">${p(o.value)}</p>${d}${c}</div>`}).join("")}</div>`);break;case"code":a.push(je(t,n,h(t,e)));break;case"columns":{const o=t.columns.map(d=>`${String(d.width??1)}fr`).join(" "),r=ae(t,n.room);a.push(`<div class="columns${columnsKept(t,j(n.page))?" kept":""}"${h(t,e)} style="grid-template-columns:${o}">${t.columns.map((d,c)=>`<div class="column">${S(d.blocks,{...n,room:r[c]??U},e)}</div>`).join("")}</div>`);break}case"chart":{const o=e.numbers.get(t),r=o===void 0?t:ue(t),{svg:d,problems:c}=ie(r,{...n,font:pageFaces(n.page).text}),{width:f}=ne(t,n.room),g=o===void 0||t.title===void 0?"":`<figcaption>${p(R(t.title,o))}</figcaption>`;a.push(d===void 0?`<div class="embed"${h(t,e)} data-chart>${p(t.title??"Chart")}<br><small>${p(c.join("; "))}</small></div>`:`<figure class="chart"${L(t.id)}${h(t,e)} style="max-width:${String(f)}px">${d}${g}</figure>`);break}case"image":{const o=n.image?.(t.src)??t.src;a.push(`<figure${L(t.id)}${h(t,e)}${t.align===void 0?"":` style="text-align:${t.align}"`}><img src="${p(o)}" alt="${p(t.alt??"")}"${t.width===void 0?"":` width="${String(t.width)}"`}>${t.caption===void 0?"":`<figcaption>${p(R(t.caption,e.numbers.get(t)))}</figcaption>`}</figure>`);break}case"table":{const o=t.head===void 0||t.head==="both",r=t.head==="column"||t.head==="both",d=ke(t),c=be(t),f=(m,$,y)=>`<tr${e.ids===void 0?"":` data-row="${String(y)}"`}>${m.map((_,F)=>{const G=$||r&&F===0?"th":"td",ee=d.has(F)?' class="num"':"";return`<${G}${ee}>${x(_,e)}</${G}>`}).join("")}</tr>`,g=j(n.page),w=(t.widths??[]).reduce((m,$)=>m+($??0),0),P=n.room??g.textWidth*96/25.4,E=$e(t,{across:X(Math.max(P-w,0),g.spacing.small),margins:X(2*g.spacing.cell.side*96/72,g.spacing.small)}),C=E.reduce((m,$,y)=>m+(t.widths?.[y]?0:$),0)||1,T=`<colgroup>${E.map((m,$)=>{const y=t.widths?.[$],_=b(m/C*100);return y?`<col style="width:${String(y)}px">`:w===0?`<col style="width:${_}%">`:`<col style="width:calc((100% - ${String(w)}px) * ${b(m/C)})">`}).join("")}</colgroup>`,[M,...N]=t.rows,A=o&&M!==void 0&&!c?`<thead>${f(M,!0,0)}</thead>`:"",u=(o?N:t.rows).map((m,$)=>f(m,!1,o?$+1:$)).join(""),v=t.caption===void 0?"":`<caption>${p(R(t.caption,e.numbers.get(t)))}</caption>`;a.push(`<table${L(t.id)}${h(t,e)}>${v}${T}${A}<tbody>${u}</tbody></table>`);break}case"divider":a.push(`<hr${h(t,e)}>`);break;case"pagebreak":a.push(`<div class="page-break"${h(t,e)}></div>`);break;case"toc":a.push(Te(t,e));break;case"bibliography":e.listed||(e.listed=!0,a.push(J(e,h(t,e))));break;case"note":break;case"component":{const o=n.component?.(t),r=t.align===void 0?"":` style="text-align:${t.align}"`;a.push(o===void 0?`<div class="embed"${h(t,e)} data-component>${p(re(t))}</div>`:`<figure${L(t.id)}${h(t,e)}${r}><img src="${p(o)}" alt="${p(t.alt??"")}"${t.width===void 0?"":` width="${String(t.width)}"`}>${t.caption===void 0?"":`<figcaption>${p(R(t.caption,e.numbers.get(t)))}</figcaption>`}</figure>`);break}case"embed":{const o=n.embed?.(t.source,e.embeds);e.embeds++;const r=/^<\s*([A-Za-z][\w.]*)/.exec(t.source.trim())?.[1];a.push(o===void 0?`<div class="embed"${h(t,e)} data-embed>${p(r??"")}</div>`:`<div${h(t,e)}>${o}</div>`);break}case"source":break}}return a.join(`
3
+ `)}function J(i,n=""){const{list:e,style:a}=i.sources;return e.length===0?"":`<section class="sources" data-style="${a}"${n}><ol>${e.map(s=>`<li id="source-${p(s.item.id)}">${s.pieces.map(t=>t.italic?`<i>${p(t.text)}</i>`:p(t.text)).join("")}</li>`).join("")}</ol></section>`}const L=i=>i===void 0?"":` id="${p(i)}"`;function Te(i,n){const e=i.levels??3,a=n.headings.filter(r=>r.block.level<=e),s=Math.min(...a.map(r=>r.block.level)),t=a.map(({block:r,anchor:d})=>{const c=n.headingPage?.(d);return`<li style="padding-left:${String(r.level-s)}em"><a href="#${p(d)}"><span class="toc-words">${x(r.content,n)}</span>${c===void 0?"":`<span class="toc-fill"></span><span class="toc-page">${String(c)}</span>`}</a></li>`}),o=he(i,n.chinese);return`<nav class="toc"${h(i,n)}>${o===""?"":`<p class="toc-title">${p(o)}</p>`}<ol>${t.join("")}</ol></nav>`}export function keptWhole(i,n,e=0){const a=.35277777777777775,s="pt"in n.lineHeight?n.lineHeight.pt:n.lineHeight.multiple*(I[n.font]??1.22)*n.size,t=Math.max(20,(n.textWidth/a-30)/(n.size*.5)),o=r=>r.reduce((d,c)=>{if(c.type==="table")return d+c.rows.length*1.6+1;if(c.type==="chart"||c.type==="image"||c.type==="component")return d+18;if(c.type==="card")return d+2+o(c.children??[]);const f="content"in c?Math.max(1,Math.ceil(c.content.map(g=>g.text).join("").length/t))+.5:2;return d+f+o(ve(c))},0);return(e+o(i))*s<n.textHeight/a*.6}export const cardKept=(i,n)=>keptWhole(i.children??[],n,2),columnsKept=(i,n)=>i.columns.every(e=>keptWhole(e.blocks,n));const Ne=15;export function trendSvg(i,n){const s=Math.min(...i),o=Math.max(...i)-s||1,d=i.map((c,f)=>[f/Math.max(1,i.length-1)*100,22-(c-s)/o*20]).map(([c,f],g)=>`${g===0?"M":"L"}${(c??0).toFixed(1)} ${(f??0).toFixed(1)}`).join(" ");return`<svg class="stat-trend" viewBox="0 0 ${String(100)} ${String(24)}" preserveAspectRatio="none" aria-hidden="true"><path d="${d}" fill="none" stroke="${n}" stroke-width="1.5" vector-effect="non-scaling-stroke" stroke-linejoin="round" stroke-linecap="round"/></svg>`}function je(i,n,e=""){if(i.language===K.math)return`<div class="math"${e}>${me(i.code).html}</div>`;if(i.language===K.mermaid){const a=n.diagram?.(i.code);if(a?.svg!==void 0)return`<figure class="diagram"${e}>${a.svg}</figure>`;if(a?.error!==void 0)return`<pre${e}><code>${p(i.code)}</code></pre><p class="drawn-error">Mermaid: ${p(a.error)}</p>`}return`<pre${e}><code>${Me(i.code)}</code></pre>`}const Me=i=>i.split(`
4
+ `).map(n=>`<span class="line">${p(n)}</span>`).join(""),W=(i,n,e)=>i?.length?`<div class="under">${S(i,n,e)}</div>`:"";export const DOC_CSS=`
5
5
  /* The page's side margins are the text column's own padding, so a cover
6
6
  can reach the page's edges. The default page is Letter (PAGE_DEFAULTS). */
7
7
  @page { size: 215.9mm 279.4mm; margin: 18mm 0; }
8
8
  * { box-sizing: border-box; }
9
9
  html { font-size: 11pt; }
10
- body { margin: 0; color: ${c.ink}; font-family: Carlito, Calibri, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; line-height: 1.4; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
10
+ body { margin: 0; color: ${l.ink}; font-family: Carlito, Calibri, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; line-height: 1.4; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
11
11
  main { max-width: 215.9mm; margin: 0 auto; padding: 0 20mm; overflow-x: clip; }
12
12
  /* Every block's space and step in is the page's (pageCss, from BlockSpacing). */
13
13
  h1, h2, h3, h4, h5, h6 { line-height: inherit; margin: 0; break-after: avoid; }
@@ -19,18 +19,18 @@ h2 { font-size: 1.45em; }
19
19
  .toc-title { font-weight: bold; line-height: inherit; break-after: avoid; }
20
20
  h3 { font-size: 1.15em; }
21
21
  h4, h5, h6 { font-size: 1em; }
22
- h5 { color: ${c.lead}; }
23
- h6 { color: ${c.leadSoft}; font-weight: 500; }
22
+ h5 { color: ${l.lead}; }
23
+ h6 { color: ${l.leadSoft}; font-weight: 500; }
24
24
  p, ul, ol, li { margin: 0; }
25
25
  ul, ol { padding-left: 0; }
26
26
  /* A task as the editor draws it: a box, ticked and the words struck when done. */
27
27
  li.task { list-style: none; }
28
- li.task .box { display: inline-block; width: 0.95em; height: 0.95em; margin-right: 0.55em; border: 1.5px solid ${c.ruleStrong}; border-radius: 3px; vertical-align: -0.14em; }
29
- li.task .box.done { border-color: ${c.ink}; background: ${c.ink} url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-4.9' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 85% no-repeat; }
30
- li.task.done > .words { color: ${c.leadSoft}; text-decoration: line-through; text-decoration-color: ${c.ruleStrong}; }
31
- blockquote { margin: 0; border-left: var(--quote-rule, 1px) solid ${c.ruleStrong}; color: ${c.lead}; }
32
- code { font-family: Cousine, "Courier New", monospace; font-size: 0.88em; background: ${c.stone2}; border-radius: 3px; padding: 0.12em 0.34em; }
33
- pre { margin: 0; font-family: Cousine, "Courier New", monospace; background: ${c.stone}; border: 0.5pt solid ${c.stone}; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; break-inside: avoid; }
28
+ li.task .box { display: inline-block; width: 0.95em; height: 0.95em; margin-right: 0.55em; border: 1.5px solid ${l.ruleStrong}; border-radius: 3px; vertical-align: -0.14em; }
29
+ li.task .box.done { border-color: ${l.ink}; background: ${l.ink} url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-4.9' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 85% no-repeat; }
30
+ li.task.done > .words { color: ${l.leadSoft}; text-decoration: line-through; text-decoration-color: ${l.ruleStrong}; }
31
+ blockquote { margin: 0; border-left: var(--quote-rule, 1px) solid ${l.ruleStrong}; color: ${l.lead}; }
32
+ code { font-family: Cousine, "Courier New", monospace; font-size: 0.88em; background: ${l.stone2}; border-radius: 3px; padding: 0.12em 0.34em; }
33
+ pre { margin: 0; font-family: Cousine, "Courier New", monospace; background: ${l.stone}; border: 0.5pt solid ${l.stone}; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; break-inside: avoid; }
34
34
  pre code { background: none; padding: 0; }
35
35
  pre .line { display: block; min-height: 1lh; padding-left: 2ch; text-indent: -2ch; }
36
36
  /* Tables as the editor sets them, a report's three rules (booktabs): a
@@ -38,56 +38,56 @@ pre .line { display: block; min-height: 1lh; padding-left: 2ch; text-indent: -2c
38
38
  by lines, no lines between columns; laid
39
39
  out as Word lays them, each column as wide as it is set, the rest shared. */
40
40
  table { border-collapse: collapse; width: 100%; table-layout: fixed; }
41
- th, td { border: 0; border-bottom: 0.5pt solid ${c.ruleMid}; text-align: left; vertical-align: top; }
42
- table > thead > tr:first-child > *, table:not(:has(> thead)) > tbody > tr:first-child > * { border-top: 1pt solid ${c.ruleStrong}; }
43
- table > tbody > tr:last-child > * { border-bottom: 1pt solid ${c.ruleStrong}; }
41
+ th, td { border: 0; border-bottom: 0.5pt solid ${l.ruleMid}; text-align: left; vertical-align: top; }
42
+ table > thead > tr:first-child > *, table:not(:has(> thead)) > tbody > tr:first-child > * { border-top: 1pt solid ${l.ruleStrong}; }
43
+ table > tbody > tr:last-child > * { border-bottom: 1pt solid ${l.ruleStrong}; }
44
44
  th { font-weight: 600; }
45
- thead th { border-bottom: 0.75pt solid ${c.ruleStrong}; background: ${c.stone3}; }
45
+ thead th { border-bottom: 0.75pt solid ${l.ruleStrong}; background: ${l.stone3}; }
46
46
  th.num, td.num { text-align: right; }
47
47
  figure { break-inside: avoid; }
48
48
  img { max-width: 100%; }
49
- figcaption { color: ${c.leadSoft}; }
50
- hr { box-sizing: content-box; border: 0; border-bottom: 0.5pt solid ${c.rule}; }
51
- a { color: inherit; text-decoration: underline; text-decoration-color: ${c.ruleStrong}; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
49
+ figcaption { color: ${l.leadSoft}; }
50
+ hr { box-sizing: content-box; border: 0; border-bottom: 0.5pt solid ${l.rule}; }
51
+ a { color: inherit; text-decoration: underline; text-decoration-color: ${l.ruleStrong}; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
52
52
  /* A callout's sign in a column of its own, as wide as Word's cell for it. */
53
53
  /* A card: blocks in a hairline border under a title and a quieter line. */
54
- .card { border: 0.5pt solid ${c.rule}; border-radius: 8px; background: ${c.sheet}; }
54
+ .card { border: 0.5pt solid ${l.rule}; border-radius: 8px; background: ${l.sheet}; }
55
55
  .card.kept, .columns.kept { break-inside: avoid; }
56
56
  .card-head p { margin: 0; }
57
57
  .card-title { font-weight: 700; }
58
- .card-subtitle { color: ${c.lead}; }
58
+ .card-subtitle { color: ${l.lead}; }
59
59
  /* Figures side by side: each a label over its value, how it moved under it. */
60
60
  .stats { display: grid; break-inside: avoid; }
61
- .stat { border: 0.5pt solid ${c.rule}; border-radius: 8px; background: ${c.sheet}; }
61
+ .stat { border: 0.5pt solid ${l.rule}; border-radius: 8px; background: ${l.sheet}; }
62
62
  .stat p { margin: 0; }
63
- .stat-label, .stat-foot { color: ${c.lead}; }
64
- .stat-value { font-weight: 700; color: ${c.ink}; }
63
+ .stat-label, .stat-foot { color: ${l.lead}; }
64
+ .stat-value { font-weight: 700; color: ${l.ink}; }
65
65
  .stat-trend { display: block; width: 100%; height: 18pt; margin-top: 3pt; }
66
66
  /* A tag: a word or two in a pill of its colour. */
67
67
  .tag { border-radius: 999px; padding: 0 0.4em; font-size: 0.85em; }
68
- .callout { display: flex; border-radius: 6px; background: ${c.stone}; break-inside: avoid; }
68
+ .callout { display: flex; border-radius: 6px; background: ${l.stone}; break-inside: avoid; }
69
69
  .callout-icon { flex: none; width: 1.8em; }
70
70
  .callout > div { flex: 1; min-width: 0; }
71
- .embed { border: 1px dashed ${c.ruleMid}; border-radius: 6px; padding: 1.5em; text-align: center; color: ${c.leadSoft}; break-inside: avoid; }
71
+ .embed { border: 1px dashed ${l.ruleMid}; border-radius: 6px; padding: 1.5em; text-align: center; color: ${l.leadSoft}; break-inside: avoid; }
72
72
  /* A cover: a band of a picture across the top of the first page, edge to
73
73
  edge (Notion's). */
74
- .cover { height: ${String(ye)}mm; margin: 0 -20mm 2.4em; overflow: hidden; break-inside: avoid; }
74
+ .cover { height: ${String(Se)}mm; margin: 0 -20mm 2.4em; overflow: hidden; break-inside: avoid; }
75
75
  .cover img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; }
76
76
  /* A footnote's mark, and the notes at the end under a short rule. */
77
77
  sup.fn { font-size: 0.72em; line-height: 0; margin-left: 0.02em; font-variant-numeric: tabular-nums; }
78
- sup.fn a { text-decoration: none; color: ${c.lead}; }
79
- .notes { margin-top: 2.5em; padding-top: 0.8em; border-top: 1px solid ${c.rule}; width: 100%; font-size: 0.85em; color: ${c.lead}; }
78
+ sup.fn a { text-decoration: none; color: ${l.lead}; }
79
+ .notes { margin-top: 2.5em; padding-top: 0.8em; border-top: 1px solid ${l.rule}; width: 100%; font-size: 0.85em; color: ${l.lead}; }
80
80
  .notes ol { padding-left: 1.6em; margin: 0; }
81
81
  .notes li { margin: 0.25em 0; }
82
82
  .notes li p { margin: 0; }
83
83
  .page-break { break-after: page; height: 0; }
84
84
  /* A mark set half wide at a line's end, as Word squeezes it (GRID_SQUEEZE). */
85
85
  .squeezed { letter-spacing: -0.5em; }
86
- caption { caption-side: top; text-align: left; color: ${c.leadSoft}; }
86
+ caption { caption-side: top; text-align: left; color: ${l.leadSoft}; }
87
87
  /* The contents: each heading a link, its page after a line of dots. */
88
88
  .toc ol { list-style: none; padding: 0; }
89
89
  .toc a { display: flex; align-items: baseline; gap: 0.4em; color: inherit; text-decoration: none; }
90
- .toc-fill { flex: 1; min-width: 1em; border-bottom: 1px dotted ${c.ruleMid}; }
90
+ .toc-fill { flex: 1; min-width: 1em; border-bottom: 1px dotted ${l.ruleMid}; }
91
91
  .toc-page { font-variant-numeric: tabular-nums; }
92
92
  /* Citations and the list of sources: numbered with a hanging number (GB/T 7714), or by author with a hanging line (APA, MLA) as deep as a paragraph's first line is set in (--hang). */
93
93
  a.cite { color: inherit; text-decoration: none; }
@@ -110,10 +110,10 @@ figure.chart svg, figure.diagram svg { display: inline-block; max-width: 100%; h
110
110
  a row never split, a table's head again on each page. */
111
111
  p, li { orphans: 2; widows: 2; }
112
112
  tr { break-inside: avoid; }
113
- `;function Me(i,n,e){const a=[...q(i)].filter(o=>o.type==="note");return a.length===0?"":`<section class="notes"><ol>${a.map(o=>({note:o,n:e.notes.get(o.label.toLowerCase())})).sort((o,r)=>(o.n??1/0)-(r.n??1/0)).map(({note:o,n:r})=>`<li${h(o,e)}${r===void 0?"":` id="note-${String(r)}" value="${String(r)}"`}><p>${x(o.content,e)}</p>${y(o.children??[],n,e)}</li>`).join("")}</ol></section>`}const Q="body > h1:first-child, main > h1:first-child, article > h1:first-child, main > .cover + h1",k=i=>`${String(Math.round(i*100)/100)}mm`,$=i=>String(Math.round(i*1e3)/1e3);function Ae(i){const n=i.spacing,e=o=>`${$(o)}pt`,a=e(n.after),s=e(n.step),t="pt"in i.lineHeight?e(i.lineHeight.pt):$(i.lineHeight.multiple*(I.mono??1));return[`p, ul, ol, blockquote, pre, table, figure, .math, .callout, .card, .stats, .embed, .sources li { margin: 0 0 ${a}; }`,`h1, h2, h3, h4, h5, h6 { margin: ${e(n.heading.before)} 0 ${e(n.heading.after)}; }`,`.toc-title { margin: ${e(n.heading.before)} 0 ${e(n.heading.after)}; }`,`${Q} { margin-top: 0; margin-bottom: ${e(n.title)}; }`,`ul, ol { padding-left: ${s}; } li ul, li ol { margin-bottom: 0; } li.task { margin-left: -${s}; } .under { margin-left: ${s}; }`,`:is(ul, ol) + :is(ul, ol) { margin-top: -${a}; }`,`blockquote { padding-left: calc(${e(n.quote)} - var(--quote-rule, 1px)); }`,`pre { padding: ${e(n.box.top)} ${e(n.box.side)}; font-size: ${e(n.small)}; line-height: ${t}; } pre code { font-size: inherit; }`,`.callout { padding: ${e(n.box.top)} ${e(n.box.side)} ${e(Math.max(n.box.top-n.after,0))}; }`,`.card { padding: ${e(n.card.top)} ${e(n.card.side)} ${e(Math.max(n.card.top-n.after,0))}; } .card-head { margin-bottom: ${a}; } .card-subtitle { font-size: ${e(n.small)}; }`,`.stats { gap: ${e(n.gap)}; } .stat { padding: ${e(n.card.top)} ${e(n.card.side)}; } .stat-label, .stat-foot { font-size: ${e(n.small)}; } .stat-value { font-size: ${e(n.figure)}; line-height: ${$(I[i.font]??I.sans??1.22)}; }`,`table { font-size: ${e(n.small)}; } th, td { padding: ${e(n.cell.top)} ${e(n.cell.side)}; }`,`caption { font-size: ${e(n.small)}; padding-bottom: ${e(n.caption)}; }`,`figcaption { font-size: ${e(n.small)}; margin-top: ${e(n.caption)}; }`,`hr { height: 1pt; margin: ${e(n.divider)} 0; }`,`.toc ol { margin: 0; } .toc li { margin: 0 0 ${e(n.contents)}; } .sources ol { margin: 0; }`]}function V(i,n,e){if(n===void 0)return;const a=[n.font===void 0?"":`font-family: ${PAGE_FACES[e.font]};`,n.size===void 0?"":`font-size: ${$(e.size)}pt;`,e.font==="xiaobiaosong"?"font-weight: 700;":n.weight===void 0?"":`font-weight: ${e.weight==="bold"?"700":"400"};`,n.align===void 0?"":`text-align: ${e.align};`,n.italic===void 0?"":`font-style: ${e.italic?"italic":"normal"};`,e.rule?`border-bottom: 0.5pt solid ${c.rule}; padding-bottom: ${$(HEADING_RULE_SPACE)}pt;`:""].join(" ");return a.trim()===""?void 0:`${i} { ${a.trim()} }`}export const HEADING_RULE_SPACE=3;export function pageCss(i={}){const n=H(i),e=j(i),a=pageFaces(i),s=pageAccent(n),t=[];if(n.paper!==void 0||n.orientation!==void 0||n.margins!==void 0){const{top:r,right:d,bottom:l,left:f}=e.margins;t.push(`@page { size: ${k(e.width)} ${k(e.height)}; margin: ${k(r)} 0 ${k(l)}; }`,`main { max-width: ${k(e.width)}; padding: 0 ${k(d)} 0 ${k(f)}; }`,`.cover { margin-left: -${k(f)}; margin-right: -${k(d)}; }`)}n.font!==void 0&&n.font!=="sans"&&t.push(`body { font-family: ${a.text}; }`,`h1, h2, h3, h4, h5, h6 { font-family: ${a.heading}; }`,`.toc-title { font-family: ${a.heading}; }`),(n.size!==void 0||n.grid!==void 0)&&t.push(`html { font-size: ${$(e.size)}pt; }`),t.push(`body { line-height: ${"pt"in e.lineHeight?`${$(e.lineHeight.pt)}pt`:$(ze(e)??1)}; }`),t.push(...Ae(e)),e.letterSpacing!==0&&t.push(`body { letter-spacing: ${$(e.letterSpacing)}em; }`),n.textIndent!==void 0&&n.textIndent>0&&t.push(`.sources { --hang: ${$(n.textIndent)}em; }`,`p { text-indent: ${$(n.textIndent)}em; }`,"blockquote p, .callout p, .notes p, .toc p { text-indent: 0; }"),n.textAlign==="justify"&&t.push("p, li { text-align: justify; }");const o=V(Q,n.title,e.title);o!==void 0&&t.push(o);for(const r of[1,2,3,4,5,6]){const d=V(r===1?"h1, .toc-title":`h${String(r)}`,n.headings?.[r],e.headings[r]);d!==void 0&&t.push(d)}return s!==void 0&&t.push(`a { color: ${s}; text-decoration-color: color-mix(in oklab, ${s} 45%, transparent); }`,`blockquote { --quote-rule: 2px; border-left-color: ${s}; }`),t.join(`
114
- `)}export function docParts(i){const n=[];let e=[],a=!1;for(const s of i)s.type==="pagebreak"&&s.orientation!==void 0?(n.push({blocks:e,landscape:a}),e=[],a=s.orientation==="landscape"):e.push(s);return n.push({blocks:e,landscape:a}),n}const Re=`<script>
113
+ `;function Ae(i,n,e){const a=[...q(i)].filter(o=>o.type==="note");return a.length===0?"":`<section class="notes"><ol>${a.map(o=>({note:o,n:e.notes.get(o.label.toLowerCase())})).sort((o,r)=>(o.n??1/0)-(r.n??1/0)).map(({note:o,n:r})=>`<li${h(o,e)}${r===void 0?"":` id="note-${String(r)}" value="${String(r)}"`}><p>${x(o.content,e)}</p>${S(o.children??[],n,e)}</li>`).join("")}</ol></section>`}const Q="body > h1:first-child, main > h1:first-child, article > h1:first-child, main > .cover + h1",k=i=>`${String(Math.round(i*100)/100)}mm`,b=i=>String(Math.round(i*1e3)/1e3);function Re(i){const n=i.spacing,e=o=>`${b(o)}pt`,a=e(n.after),s=e(n.step),t="pt"in i.lineHeight?e(i.lineHeight.pt):b(i.lineHeight.multiple*(I.mono??1));return[`p, ul, ol, blockquote, pre, table, figure, .math, .callout, .card, .stats, .embed, .sources li { margin: 0 0 ${a}; }`,`h1, h2, h3, h4, h5, h6 { margin: ${e(n.heading.before)} 0 ${e(n.heading.after)}; }`,`.toc-title { margin: ${e(n.heading.before)} 0 ${e(n.heading.after)}; }`,`${Q} { margin-top: 0; margin-bottom: ${e(n.title)}; }`,`ul, ol { padding-left: ${s}; } li ul, li ol { margin-bottom: 0; } li.task { margin-left: -${s}; } .under { margin-left: ${s}; }`,`:is(ul, ol) + :is(ul, ol) { margin-top: -${a}; }`,`blockquote { padding-left: calc(${e(n.quote)} - var(--quote-rule, 1px)); }`,`pre { padding: ${e(n.box.top)} ${e(n.box.side)}; font-size: ${e(n.small)}; line-height: ${t}; } pre code { font-size: inherit; }`,`.callout { padding: ${e(n.box.top)} ${e(n.box.side)} ${e(Math.max(n.box.top-n.after,0))}; }`,`.card { padding: ${e(n.card.top)} ${e(n.card.side)} ${e(Math.max(n.card.top-n.after,0))}; } .card-head { margin-bottom: ${a}; } .card-subtitle { font-size: ${e(n.small)}; }`,`.stats { gap: ${e(n.gap)}; } .stat { padding: ${e(n.card.top)} ${e(n.card.side)}; } .stat-label, .stat-foot { font-size: ${e(n.small)}; } .stat-value { font-size: ${e(n.figure)}; line-height: ${b(I[i.font]??I.sans??1.22)}; }`,`table { font-size: ${e(n.small)}; } th, td { padding: ${e(n.cell.top)} ${e(n.cell.side)}; }`,`caption { font-size: ${e(n.small)}; padding-bottom: ${e(n.caption)}; }`,`figcaption { font-size: ${e(n.small)}; margin-top: ${e(n.caption)}; }`,`hr { height: 1pt; margin: ${e(n.divider)} 0; }`,`.toc ol { margin: 0; } .toc li { margin: 0 0 ${e(n.contents)}; } .sources ol { margin: 0; }`]}function V(i,n,e){if(n===void 0)return;const a=[n.font===void 0?"":`font-family: ${PAGE_FACES[e.font]};`,n.size===void 0?"":`font-size: ${b(e.size)}pt;`,e.font==="xiaobiaosong"?"font-weight: 700;":n.weight===void 0?"":`font-weight: ${e.weight==="bold"?"700":"400"};`,n.align===void 0?"":`text-align: ${e.align};`,n.italic===void 0?"":`font-style: ${e.italic?"italic":"normal"};`,e.rule?`border-bottom: 0.5pt solid ${l.rule}; padding-bottom: ${b(HEADING_RULE_SPACE)}pt;`:""].join(" ");return a.trim()===""?void 0:`${i} { ${a.trim()} }`}export const HEADING_RULE_SPACE=3;export function pageCss(i={}){const n=H(i),e=j(i),a=pageFaces(i),s=pageAccent(n),t=[];if(n.paper!==void 0||n.orientation!==void 0||n.margins!==void 0){const{top:r,right:d,bottom:c,left:f}=e.margins;t.push(`@page { size: ${k(e.width)} ${k(e.height)}; margin: ${k(r)} 0 ${k(c)}; }`,`main { max-width: ${k(e.width)}; padding: 0 ${k(d)} 0 ${k(f)}; }`,`.cover { margin-left: -${k(f)}; margin-right: -${k(d)}; }`)}n.font!==void 0&&n.font!=="sans"&&t.push(`body { font-family: ${a.text}; }`,`h1, h2, h3, h4, h5, h6 { font-family: ${a.heading}; }`,`.toc-title { font-family: ${a.heading}; }`),(n.size!==void 0||n.grid!==void 0)&&t.push(`html { font-size: ${b(e.size)}pt; }`),t.push(`body { line-height: ${"pt"in e.lineHeight?`${b(e.lineHeight.pt)}pt`:b(Ee(e)??1)}; }`),t.push(...Re(e)),e.letterSpacing!==0&&t.push(`body { letter-spacing: ${b(e.letterSpacing)}em; }`),n.textIndent!==void 0&&n.textIndent>0&&t.push(`.sources { --hang: ${b(n.textIndent)}em; }`,`p { text-indent: ${b(n.textIndent)}em; }`,"blockquote p, .callout p, .notes p, .toc p { text-indent: 0; }"),n.textAlign==="justify"&&t.push("p, li { text-align: justify; }");const o=V(Q,n.title,e.title);o!==void 0&&t.push(o);for(const r of[1,2,3,4,5,6]){const d=V(r===1?"h1, .toc-title":`h${String(r)}`,n.headings?.[r],e.headings[r]);d!==void 0&&t.push(d)}return s!==void 0&&t.push(`a { color: ${s}; text-decoration-color: color-mix(in oklab, ${s} 45%, transparent); }`,`blockquote { --quote-rule: 2px; border-left-color: ${s}; }`),t.join(`
114
+ `)}export function docParts(i){const n=[];let e=[],a=!1;for(const s of i)s.type==="pagebreak"&&s.orientation!==void 0?(n.push({blocks:e,landscape:a}),e=[],a=s.orientation==="landscape"):e.push(s);return n.push({blocks:e,landscape:a}),n}const qe=`<script>
115
115
  window.allyhubReady = ${oe({scope:"main",face:"Noto Color Emoji"})};
116
- <\/script>`,qe=`<script>
116
+ <\/script>`,He=`<script>
117
117
  window.allyhubReady = (async (before) => {
118
118
  await before;
119
119
  await document.fonts.ready;
@@ -129,7 +129,7 @@ window.allyhubReady = (async (before) => {
129
129
  if (el.matches("p") || el.children.length === el.querySelectorAll(":scope > .words, :scope > .box").length)
130
130
  if (lines(el) < 4) el.style.breakInside = "avoid";
131
131
  })(window.allyhubReady);
132
- <\/script>`,He=`<script>
132
+ <\/script>`,Ie=`<script>
133
133
  window.allyhubReady = (async (before) => {
134
134
  await before;
135
135
  await document.fonts.ready;
@@ -214,8 +214,8 @@ window.allyhubReady = (async (before) => {
214
214
  }
215
215
  }
216
216
  })(window.allyhubReady);
217
- <\/script>`;export function docHtml(i,n={}){const e=headingAnchors(i),a=fe(i,n.page),{title:s}=xe(i),t=new Map,o=[];for(const u of q(i)){const S=pe(u),v=a.get(u);if(S!==void 0&&v!==void 0&&t.set(S,v.label),u.type==="heading"){const m=e.get(u)??"";t.set(m,u.content.map(b=>b.text).join("")),u!==s&&o.push({block:u,anchor:m})}}const r={embeds:0,notes:ve(i),anchors:e,ids:n.ids?blockNumbers(i):void 0,numbers:a,refs:t,headings:o,headingPage:n.headingPage,chinese:ge(i),sources:(()=>{const u=H(n.page??{}).citationStyle??"apa",S=n.sources??[],v=ce(i,S,u);return{items:S,style:u,numbers:new Map(v.map(m=>[m.item.id,m.n])),list:v}})(),listed:!1},d=docParts(i),l=n.part,f=l===void 0?void 0:d[l],g=f===void 0?d.flatMap(u=>u.blocks):f.blocks,w=l===void 0||l===0,M=l===void 0||l===d.length-1,C=w?n.page?.cover:void 0,z=C===void 0?void 0:n.image?.(C)??C,P=`${z===void 0?"":`<figure class="cover"><img src="${p(z)}" alt="" style="object-position:50% ${String(n.page?.coverY??50)}%"></figure>
218
- `}${y(g,n,r)}${M&&!r.listed?J(r):""}${M?Me(i,n,r):""}`,E=j(n.page),A=[pageCss(n.page),...f?.landscape===!0?[`@page { size: ${k(E.height)} ${k(E.width)}; }`,`main { max-width: ${k(E.height)}; }`]:[],...z===void 0?[]:["@page :first { margin-top: 0; }"]].filter(u=>u!=="").join(`
217
+ <\/script>`;export function docHtml(i,n={}){const e=xe(i,n),a=headingAnchors(e),s=fe(e,n.page),{title:t}=we(e),o=new Map,r=[];for(const u of q(e)){const v=pe(u),m=s.get(u);if(v!==void 0&&m!==void 0&&o.set(v,m.label),u.type==="heading"){const $=a.get(u)??"";o.set($,u.content.map(y=>y.text).join("")),u!==t&&r.push({block:u,anchor:$})}}const d={embeds:0,notes:Ce(e),anchors:a,ids:n.ids?blockNumbers(e):void 0,numbers:s,refs:o,headings:r,headingPage:n.headingPage,chinese:ge(e),sources:(()=>{const u=H(n.page??{}).citationStyle??"apa",v=n.sources??[],m=ce(e,v,u);return{items:v,style:u,numbers:new Map(m.map($=>[$.item.id,$.n])),list:m}})(),listed:!1},c=docParts(e),f=n.part,g=f===void 0?void 0:c[f],w=g===void 0?c.flatMap(u=>u.blocks):g.blocks,P=f===void 0||f===0,E=f===void 0||f===c.length-1,C=P?n.page?.cover:void 0,T=C===void 0?void 0:n.image?.(C)??C,M=`${T===void 0?"":`<figure class="cover"><img src="${p(T)}" alt="" style="object-position:50% ${String(n.page?.coverY??50)}%"></figure>
218
+ `}${S(w,n,d)}${E&&!d.listed?J(d):""}${E?Ae(e,n,d):""}`,N=j(n.page),A=[pageCss(n.page),...g?.landscape===!0?[`@page { size: ${k(N.height)} ${k(N.width)}; }`,`main { max-width: ${k(N.height)}; }`]:[],...T===void 0?[]:["@page :first { margin-top: 0; }"]].filter(u=>u!=="").join(`
219
219
  `);return`<!doctype html>
220
220
  <html>
221
221
  <head>
@@ -227,11 +227,11 @@ ${A}`}</style>
227
227
  </head>
228
228
  <body>
229
229
  <main>
230
- ${P}
230
+ ${M}
231
231
  </main>
232
- ${Re}
233
- ${H(n.page??{}).grid===void 0?"":He}
234
232
  ${qe}
233
+ ${H(n.page??{}).grid===void 0?"":Ie}
234
+ ${He}
235
235
  </body>
236
236
  </html>
237
237
  `}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export{DOC_CSS,EMOJI_PATTERN,PAGE_FACES,blockNumbers,docHtml,docParts,headingAnchors,pageAccent,pageCss,pageFaces,trendSvg}from"./html.js";export{CHART_BARS,ROUND_FRAME,CHART_PALETTE,CHART_SECOND_TONE,CHART_TEXT,SMOOTHED,chartColor,chartFrame,chartTheme,chartWords,docChart,docChartSvg}from"./chart.js";export{COMPONENT_ASPECT,COMPONENT_WIDTH,componentAt,componentDrawing,componentDrawingKey,componentDraws,componentName}from"./component.js";export{COLUMN_GAP,columnWidths}from"./columns.js";export{numberColumns}from"./table.js";export{CITATION_STYLES,citationText,citedKeys,citedOf,readSources,sourceList,sourceText,sourcePieces,withSources}from"./cite.js";export{blockId,captionNumbers,captionOf,captionWords,contentsTitle,numberedCaption,writtenInChinese}from"./captions.js";export{DRAWN_CODE,mathHtml}from"./math.js";export{DIAGRAM_TEXT_PX,PAPER,TONE_COLORS,diagramConfig,tagColors,tint}from"./paper.js";export{markdownOf,plainBlocks}from"./markdown.js";export*from"./model.js";export{CHINESE_SIZES,PAGE_DEFAULTS,PAGE_KEYS,PAGE_PRESETS,PAPERS,RUNNING_PLACES,effectiveLook,lineHeightPt,lineMultiple,SINGLE_LINE,marginBox,paperSize,presetLook,resolvePage,sizePt}from"./page.js";export{BLOCK_TAG,CALLOUT_TAG,CARD_TAG,STAT_ATTRIBUTES,STAT_TAG,STATS_TAG,TAG_TAG,CHART_ATTRIBUTES,CHART_TAG,COLUMN_TAG,COLUMNS_TAG,PAGE_BREAK_TAG,BIBLIOGRAPHY_TAG,TOC_TAG,COMPONENT_ATTRIBUTES,COMPONENT_TAG,TABLE_TAG,parseDoc}from"./parse.js";export{patchDoc}from"./patch.js";export{isTitle,retitle,splitTitle,titleText,withTitle}from"./title.js";export{frontMatterOf,withPage,writeBlocks}from"./write.js";export{COVER_NAMES,COVER_WORDS,coverFileName,coverSvg}from"./covers.js";
2
+ export{DOC_CSS,EMOJI_PATTERN,PAGE_FACES,blockNumbers,docHtml,docParts,headingAnchors,pageAccent,pageCss,pageFaces,trendSvg}from"./html.js";export{CHART_BARS,ROUND_FRAME,CHART_PALETTE,CHART_SECOND_TONE,CHART_TEXT,SMOOTHED,chartColor,chartFrame,chartTheme,chartWords,docChart,docChartSvg}from"./chart.js";export{COMPONENT_ASPECT,COMPONENT_WIDTH,componentAt,componentDrawing,componentDrawingKey,componentDraws,componentName}from"./component.js";export{COLUMN_GAP,columnWidths}from"./columns.js";export{numberColumns,tableRowsOf,withTableData}from"./table.js";export{CITATION_STYLES,citationText,citedKeys,citedOf,readSources,sourceList,sourceText,sourcePieces,withSources}from"./cite.js";export{blockId,captionNumbers,captionOf,captionWords,contentsTitle,numberedCaption,writtenInChinese}from"./captions.js";export{DRAWN_CODE,mathHtml}from"./math.js";export{DIAGRAM_TEXT_PX,PAPER,TONE_COLORS,diagramConfig,tagColors,tint}from"./paper.js";export{markdownOf,plainBlocks}from"./markdown.js";export*from"./model.js";export{CHINESE_SIZES,PAGE_DEFAULTS,PAGE_KEYS,PAGE_PRESETS,PAPERS,RUNNING_PLACES,effectiveLook,lineHeightPt,lineMultiple,SINGLE_LINE,marginBox,paperSize,presetLook,resolvePage,sizePt}from"./page.js";export{BLOCK_TAG,CALLOUT_TAG,CARD_TAG,STAT_ATTRIBUTES,STAT_TAG,STATS_TAG,TAG_TAG,CHART_ATTRIBUTES,CHART_TAG,COLUMN_TAG,COLUMNS_TAG,PAGE_BREAK_TAG,BIBLIOGRAPHY_TAG,TOC_TAG,COMPONENT_ATTRIBUTES,COMPONENT_TAG,ITEM_TAG,TABLE_TAG,parseDoc}from"./parse.js";export{patchDoc}from"./patch.js";export{isTitle,retitle,splitTitle,titleText,withTitle}from"./title.js";export{frontMatterOf,withPage,writeBlocks}from"./write.js";export{COVER_NAMES,COVER_WORDS,coverFileName,coverSvg}from"./covers.js";
@@ -1,3 +1,3 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{withSources as f}from"./cite.js";import{docChart as h}from"./chart.js";import{writeBlocks as y}from"./write.js";function u(e){const t={};return e.bold&&(t.bold=!0),e.italic&&(t.italic=!0),e.strike&&(t.strike=!0),e.code&&(t.code=!0),t}const p=e=>e.map(t=>t.note!==void 0?{text:t.text,styles:{},note:t.note}:t.href===void 0?{text:t.text,styles:u(t.styles)}:{text:t.text,href:t.href,styles:u(t.styles)});function g(e,t){switch(e.type){case"embed":case"source":return[];case"component":{const n=t.component?.(e);return n===void 0?[]:[{type:"image",src:n,...e.alt===void 0?{}:{alt:e.alt},...e.caption===void 0?{}:{caption:e.caption}}]}case"code":case"divider":return[e];case"pagebreak":case"toc":return[];case"bibliography":return[];case"columns":return e.columns.flatMap(n=>plainBlocks(n.blocks,t));case"card":{const n=[...e.title===void 0?[]:[{text:e.title,styles:{bold:!0}}],...e.subtitle===void 0?[]:[{text:`${e.title===void 0?"":" — "}${e.subtitle}`,styles:{}}]];return[...n.length>0?[{type:"paragraph",content:n}]:[],...plainBlocks(e.children??[],t)]}case"stats":return e.stats.map(n=>({type:"bullet",content:[{text:n.value,styles:{bold:!0}},{text:` ${n.label}`,styles:{}},...n.delta===void 0&&n.note===void 0?[]:[{text:` (${[n.delta,n.note].filter(s=>s!==void 0).join(" ")})`,styles:{}}]]}));case"chart":{const n=i=>i===""?[]:[{text:i,styles:{}}],s=e.table===void 0?h(e,t).chart:void 0,c=e.table??(s&&s.categories.length>0?[[e.categories??"",...s.series.map(i=>i.name)],...s.categories.map((i,l)=>[i,...s.series.map(o=>{const d=o.values[l];return d==null?"":String(d)})])]:void 0);return c===void 0?[]:[...e.title===void 0?[]:[{type:"paragraph",content:[{text:e.title,styles:{bold:!0}}]}],{type:"table",rows:c.map(i=>i.map(n))}]}case"image":return[{type:"image",src:e.src,...e.alt===void 0?{}:{alt:e.alt},...e.caption===void 0?{}:{caption:e.caption}}];case"table":return[...e.caption===void 0?[]:[{type:"paragraph",content:[{text:e.caption,styles:{bold:!0}}]}],{type:"table",rows:e.rows.map(n=>n.map(p))}];default:break}const a=p(e.content),r=plainBlocks(e.children??[],t);switch(e.type){case"bullet":case"numbered":case"check":case"note":case"quote":{const n={...e};return delete n.look,delete n.children,[{...n,content:a,...r.length?{children:r}:{}}]}case"callout":return[{type:"quote",content:[...e.icon===void 0?[]:[{text:`${e.icon} `,styles:{}}],...a],...r.length?{children:r}:{}}];case"heading":return[{type:"heading",level:e.level,content:a},...r];case"toggle":case"paragraph":return[{type:"paragraph",content:a},...r]}}export function plainBlocks(e,t={}){return e.flatMap(a=>g(a,t))}export function markdownOf(e,t={}){const a=t.page?.cover,r=a===void 0?[]:[{type:"image",src:a}],n=f(e,t.sources??[],t.page?.citationStyle??"apa");return`${y([...r,...plainBlocks(n,t)])}
2
+ import{withSources as f}from"./cite.js";import{docChart as h}from"./chart.js";import{withTableData as m}from"./table.js";import{writeBlocks as y}from"./write.js";function u(e){const t={};return e.bold&&(t.bold=!0),e.italic&&(t.italic=!0),e.strike&&(t.strike=!0),e.code&&(t.code=!0),t}const l=e=>e.map(t=>t.note!==void 0?{text:t.text,styles:{},note:t.note}:t.href===void 0?{text:t.text,styles:u(t.styles)}:{text:t.text,href:t.href,styles:u(t.styles)});function g(e,t){switch(e.type){case"embed":case"source":return[];case"component":{const n=t.component?.(e);return n===void 0?[]:[{type:"image",src:n,...e.alt===void 0?{}:{alt:e.alt},...e.caption===void 0?{}:{caption:e.caption}}]}case"code":case"divider":return[e];case"pagebreak":case"toc":return[];case"bibliography":return[];case"columns":return e.columns.flatMap(n=>plainBlocks(n.blocks,t));case"card":{const n=[...e.title===void 0?[]:[{text:e.title,styles:{bold:!0}}],...e.subtitle===void 0?[]:[{text:`${e.title===void 0?"":" — "}${e.subtitle}`,styles:{}}]];return[...n.length>0?[{type:"paragraph",content:n}]:[],...plainBlocks(e.children??[],t)]}case"stats":return e.stats.map(n=>({type:"bullet",content:[{text:n.value,styles:{bold:!0}},{text:` ${n.label}`,styles:{}},...n.delta===void 0&&n.note===void 0?[]:[{text:` (${[n.delta,n.note].filter(s=>s!==void 0).join(" ")})`,styles:{}}]]}));case"chart":{const n=i=>i===""?[]:[{text:i,styles:{}}],s=e.table===void 0?h(e,t).chart:void 0,c=e.table??(s&&s.categories.length>0?[[e.categories??"",...s.series.map(i=>i.name)],...s.categories.map((i,p)=>[i,...s.series.map(o=>{const d=o.values[p];return d==null?"":String(d)})])]:void 0);return c===void 0?[]:[...e.title===void 0?[]:[{type:"paragraph",content:[{text:e.title,styles:{bold:!0}}]}],{type:"table",rows:c.map(i=>i.map(n))}]}case"image":return[{type:"image",src:e.src,...e.alt===void 0?{}:{alt:e.alt},...e.caption===void 0?{}:{caption:e.caption}}];case"table":return[...e.caption===void 0?[]:[{type:"paragraph",content:[{text:e.caption,styles:{bold:!0}}]}],{type:"table",rows:e.rows.map(n=>n.map(l))}];default:break}const a=l(e.content),r=plainBlocks(e.children??[],t);switch(e.type){case"bullet":case"numbered":case"check":case"note":case"quote":{const n={...e};return delete n.look,delete n.children,[{...n,content:a,...r.length?{children:r}:{}}]}case"callout":return[{type:"quote",content:[...e.icon===void 0?[]:[{text:`${e.icon} `,styles:{}}],...a],...r.length?{children:r}:{}}];case"heading":return[{type:"heading",level:e.level,content:a},...r];case"toggle":case"paragraph":return[{type:"paragraph",content:a},...r]}}export function plainBlocks(e,t={}){return e.flatMap(a=>g(a,t))}export function markdownOf(e,t={}){const a=t.page?.cover,r=a===void 0?[]:[{type:"image",src:a}],n=f(m(e,t),t.sources??[],t.page?.citationStyle??"apa");return`${y([...r,...plainBlocks(n,t)])}
3
3
  `}
@@ -1,5 +1,5 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{CHART_LEGEND_POSITIONS as D,SHEET_CHART_TYPES as j}from"@allyhub/formats";import{fromMarkdown as Y}from"mdast-util-from-markdown";import{frontmatterFromMarkdown as q}from"mdast-util-frontmatter";import{gfmFootnoteFromMarkdown as K}from"mdast-util-gfm-footnote";import{gfmStrikethroughFromMarkdown as W}from"mdast-util-gfm-strikethrough";import{gfmTableFromMarkdown as z}from"mdast-util-gfm-table";import{gfmTaskListItemFromMarkdown as X}from"mdast-util-gfm-task-list-item";import{mdxFromMarkdown as Q}from"mdast-util-mdx";import{cjkFriendlyExtension as V}from"micromark-extension-cjk-friendly";import{frontmatter as Z}from"micromark-extension-frontmatter";import{gfmFootnote as x}from"micromark-extension-gfm-footnote";import{gfmStrikethrough as ee}from"micromark-extension-gfm-strikethrough";import{gfmTable as te}from"micromark-extension-gfm-table";import{gfmTaskListItem as ne}from"micromark-extension-gfm-task-list-item";import{mdxjs as re}from"micromark-extension-mdxjs";import{parse as ie}from"yaml";import{citedOf as oe}from"./cite.js";import{PAGE_KEYS as se,readPageLook as ae}from"./page.js";import{CHART_LABELS as P}from"./model.js";export const BLOCK_TAG="Block",CALLOUT_TAG="Callout",TABLE_TAG="Table",COMPONENT_TAG="Component",COMPONENT_ATTRIBUTES=["of","width","height","at","alt","title","align","id"],PAGE_BREAK_TAG="PageBreak",CARD_TAG="Card",STATS_TAG="Stats",STAT_TAG="Stat",STAT_ATTRIBUTES=["label","value","delta","note","down-is-good","trend"],TAG_TAG="Tag",COLUMNS_TAG="Columns",COLUMN_TAG="Column",CHART_TAG="Chart",CHART_ATTRIBUTES=["type","title","data","categories","series","legend","labels","format","min","max","colors","smooth","width","height","alt","id"],BIBLIOGRAPHY_TAG="Bibliography",TOC_TAG="TableOfContents";const v=t=>t.split(",").map(e=>e.trim()).filter(e=>e!==""),J=new Set(["center","right","justify"]),k=(t,e)=>{const n=e.position?.start.offset,r=e.position?.end.offset;return n===void 0||r===void 0?"":t.source.slice(n,r)};function l(t,e,n){const r=e.position?.start;t.problems.push({message:n,...r?{line:r.line,column:r.column}:{}})}const le=(t,e)=>t.bold===e.bold&&t.italic===e.italic&&t.underline===e.underline&&t.strike===e.strike&&t.code===e.code&&t.color===e.color&&t.background===e.background&&t.tag===e.tag;function y(t,e,n,r){if(e==="")return;const i=t.at(-1);if(i&&i.note===void 0&&i.cite===void 0&&i.href===r&&le(i.styles,n)){i.text+=e;return}t.push({text:e,styles:{...n},...r===void 0?{}:{href:r}})}function h(t,e,n){const r=new Map;for(const i of e.attributes){if(i.type!=="mdxJsxAttribute"||!n.includes(i.name)){l(t,e,`<${e.name??""}> takes ${n.join(", ")}: ${i.type==="mdxJsxAttribute"?i.name:"{…}"} is not one of them`);continue}i.value===null||i.value===void 0?r.set(i.name,""):typeof i.value=="string"?r.set(i.name,i.value):l(t,e,`${i.name} of <${e.name??""}> is a plain string`)}return r}function ue(t,e,n){switch(e.name){case"u":return{...n,underline:!0};case"strong":case"b":return{...n,bold:!0};case"em":case"i":return{...n,italic:!0};case"del":case"s":return{...n,strike:!0};case"code":return{...n,code:!0};case TAG_TAG:{const r=h(t,e,["color"]).get("color");return{...n,tag:r===void 0||r===""?"gray":r}}case"span":{const r=h(t,e,["color","bg"]),i=r.get("color"),o=r.get("bg");return{...n,...i?{color:i}:{},...o?{background:o}:{}}}default:return}}function N(t,e,n,r,i){for(const o of e)switch(o.type){case"text":for(const[,s]of o.value.matchAll(/\[\^([^\]\s]+)\]/gu))l(t,o,`the footnote [^${s??""}] has no note: write [^${s??""}]: … on a line of its own`);for(const s of o.value.replace(/\r?\n/g," ").split(/(\[-?@[^\]]+\])/u)){if(s==="")continue;const d=/^\[(-?@[^\]]+)\]$/u.exec(s)?.[1];d!==void 0&&oe(d).keys.length>0?i.push({text:s,styles:{...n},cite:d}):y(i,s,n,r)}break;case"strong":N(t,o.children,{...n,bold:!0},r,i);break;case"emphasis":N(t,o.children,{...n,italic:!0},r,i);break;case"delete":N(t,o.children,{...n,strike:!0},r,i);break;case"inlineCode":y(i,o.value,{...n,code:!0},r);break;case"break":y(i,`
3
- `,n,r);break;case"link":o.children.length===0?i.push({text:"",styles:{...n},href:o.url}):N(t,o.children,n,o.url,i);break;case"footnoteReference":{const s=o.label??o.identifier;i.push({text:s,styles:{...n},...r===void 0?{}:{href:r},note:s});break}case"mdxJsxTextElement":{if(o.name==="br"){y(i,`
4
- `,n,r);break}const s=ue(t,o,n);if(s){N(t,o.children,s,r,i);break}l(t,o,`<${o.name??""}> inside a line is not drawn: a tag the doc's code draws goes on lines of its own`),y(i,k(t,o),n,r);break}case"mdxTextExpression":l(t,o,"{…} in a line is not drawn: write \\{ for a brace"),y(i,k(t,o),n,r);break;default:l(t,o,`${o.type} is not drawn in a doc`),y(i,k(t,o),n,r)}}function _(t,e){const n=[];return N(t,e,{},void 0,n),n}const H=t=>t?.type==="mdxJsxFlowElement"&&t.name==="br"&&t.children.length===0;function M(t,e){const[n,...r]=e;if(n?.type==="paragraph"){const i=_(t,n.children);return{content:i.length===1&&i[0]?.text===`
5
- `&&Object.keys(i[0].styles).length===0?[]:i,under:T(t,r)}}return H(n)?{content:[],under:T(t,r)}:{content:[],under:T(t,e)}}const w=(t,e)=>e.length>0?{...t,children:e}:t;function ce(t,e,n,r){const{content:i,under:o}=M(t,e.children);return typeof e.checked=="boolean"?w({type:"check",checked:e.checked,content:i},o):w(n?{type:"numbered",...r===void 0||r===1?{}:{start:r},content:i}:{type:"bullet",content:i},o)}function de(t,e){return e.children.map(n=>_(t,n.children))}function m(t,e){return e?{[t]:e}:{}}function fe(t,e){const n=h(t,e,["align","color","bg","toggle"]),r=T(t,e.children),[i,...o]=r;if(i===void 0)return l(t,e,`<${BLOCK_TAG}> holds a block: this one is empty`),[];if(i.type==="embed"||i.type==="source")return l(t,e,`<${BLOCK_TAG}> holds a block of the doc's own, not a tag or an import`),r;const s=n.get("align");s!==void 0&&!J.has(s)&&l(t,e,`align is center, right or justify, not "${s}"`);const d={...s!==void 0&&J.has(s)?{align:s}:{},...m("color",n.get("color")),...m("background",n.get("bg"))};let a=i;if(n.has("toggle")&&(a.type==="heading"?a={...a,toggle:!0}:a.type==="paragraph"?a={type:"toggle",content:a.content}:l(t,e,"toggle is for a heading or a line of text")),Object.keys(d).length>0&&("content"in a?a={...a,look:d}:l(t,e,`a ${a.type} has no look to set`)),o.length>0)if("content"in a)a={...a,children:[...a.children??[],...o]};else return l(t,e,`a ${a.type} holds no blocks under it`),[a,...o];return[a]}function me(t,e){const n=h(t,e,["icon","color","bg"]),{content:r,under:i}=M(t,e.children),o={...m("color",n.get("color")),...m("background",n.get("bg"))};return[w({type:"callout",...m("icon",n.get("icon")),...Object.keys(o).length>0?{look:o}:{},content:r},i)]}function ge(t,e){const n=h(t,e,["title","subtitle"]),r=T(t,e.children);return[w({type:"card",...m("title",n.get("title")),...m("subtitle",n.get("subtitle"))},r)]}function he(t,e){h(t,e,[]);const n=[];for(const r of e.children){if(r.type!=="mdxJsxFlowElement"||r.name!==STAT_TAG||r.children.length>0)return l(t,r,`<${STATS_TAG}> holds <${STAT_TAG} label="…" value="…" />s, one to a line`),[];const i=h(t,r,STAT_ATTRIBUTES),o=i.get("label"),s=i.get("value");if(s===void 0||o===void 0)return l(t,r,`a <${STAT_TAG}> has a label and a value`),[];const d=i.get("trend"),a=d?.split(",").map(c=>Number(c.trim()));if(a!==void 0&&!a.every(c=>Number.isFinite(c)))return l(t,r,`a stat's trend is numbers, oldest first, comma-separated ("12,15,14,19"), not "${d??""}"`),[];n.push({label:o,value:s,...m("delta",i.get("delta")),...m("note",i.get("note")),...i.has("down-is-good")&&i.get("down-is-good")!=="false"?{downIsGood:!0}:{},...a===void 0||a.length<2?{}:{trend:a}})}return n.length===0?(l(t,e,`<${STATS_TAG}> holds one <${STAT_TAG} /> or more`),[]):[{type:"stats",stats:n}]}function pe(t,e){const n=h(t,e,["src","alt","title","width","align","id"]),r=n.get("src");if(!r)return l(t,e,"<img> names its picture: src is missing"),[];const i=Number(n.get("width")),o=n.get("align");return o!==void 0&&o!=="center"&&o!=="right"&&l(t,e,`a picture's align is center or right, not "${o}"`),[{type:"image",src:r,...m("alt",n.get("alt")),...m("caption",n.get("title")),...Number.isFinite(i)&&i>0?{width:Math.round(i)}:{},...o==="center"||o==="right"?{align:o}:{},...m("id",n.get("id"))}]}function be(t,e){if(e.children.length>0)return l(t,e,`<${COMPONENT_TAG}> holds nothing: its props are its attributes`),[];const n=new Map,r={};for(const u of e.attributes){if(u.type!=="mdxJsxAttribute"){l(t,e,`<${COMPONENT_TAG}>'s attributes are plain strings, not {…}`);continue}const f=u.value===null||u.value===void 0?"":typeof u.value=="string"?u.value:void 0;if(f===void 0){l(t,e,`${u.name} of <${COMPONENT_TAG}> is a plain string`);continue}COMPONENT_ATTRIBUTES.includes(u.name)?n.set(u.name,f):r[u.name]=f}const i=n.get("of")??"";if(i.trim()==="")return l(t,e,`<${COMPONENT_TAG}> names its component: of is missing (of="../ui.ts#Dialog")`),[];const o=u=>{const f=n.get(u);if(f===void 0)return;const b=Number(f);if(Number.isFinite(b)&&b>0)return Math.round(b);l(t,e,`${u} of <${COMPONENT_TAG}> is a number of pixels, not "${f}"`)},s=o("width"),d=o("height"),a=n.get("at"),c=a===void 0?void 0:Number(a);c!==void 0&&!(Number.isFinite(c)&&c>=0)&&l(t,e,`at of <${COMPONENT_TAG}> is seconds, 0 or more, not "${a??""}"`);const g=n.get("align");return g!==void 0&&g!=="center"&&g!=="right"&&l(t,e,`a component's align is center or right, not "${g}"`),[{type:"component",of:i,...s===void 0?{}:{width:s},...d===void 0?{}:{height:d},...c!==void 0&&Number.isFinite(c)&&c>=0?{at:c}:{},...m("alt",n.get("alt")),...m("caption",n.get("title")),...g==="center"||g==="right"?{align:g}:{},...m("id",n.get("id")),props:r}]}function ke(t,e){const n=h(t,e,CHART_ATTRIBUTES),r=p=>{l(t,e,p)},i=n.get("type");if(i===void 0||i==="")return r(`<${CHART_TAG}> says what it is drawn as: type is missing (${j.join(", ")})`),[];if(!j.includes(i))return r(`a chart's type is ${j.join(", ")}, not "${i}"`),[];const o=e.children,[s,...d]=o;if(d.length>0||s!==void 0&&s.type!=="table")return r(`<${CHART_TAG}> holds one table: its numbers`),[];const a=s?.type==="table"?s.children.map(p=>p.children.map($=>_(t,$.children).map(E=>E.text).join("").trim())):void 0,c=n.get("data"),g=n.get("categories"),u=n.get("series");if(a!==void 0&&c!==void 0)return r("a chart's numbers are its table or the file data names, not both"),[];if(a===void 0&&(c===void 0||c===""))return r(`<${CHART_TAG}> has numbers: a table inside it, or data="…" naming a file of them`),[];if(a!==void 0){(g!==void 0||u!==void 0)&&r("categories and series name a file's columns: a chart's own table has its series in its head row and its categories in its first column");const p=Math.min(...a.map($=>$.length));(a.length<2||p<2)&&r("a chart's table has a head row and a row of numbers, a column of categories and a column of numbers")}else(g===void 0||g==="")&&r("with data, categories names the column of the categories"),(u===void 0||v(u).length===0)&&r('with data, series names the columns of the numbers (series="revenue,cost")');const f=n.get("legend"),b=[...D,"none"];f!==void 0&&!b.includes(f)&&r(`a chart's legend is ${b.join(", ")}, not "${f}"`);const A=n.get("labels"),S=A===void 0?void 0:A===""?["value"]:v(A),G=S?.filter(p=>!P.includes(p));G?.length&&r(`a chart's labels are ${P.join(", ")}, not ${G.map(p=>`"${p}"`).join(", ")}`);const F=(p,$)=>{const E=n.get(p);if(E===void 0)return;const C=Number(E);if(E.trim()!==""&&Number.isFinite(C)&&(!$||C>0))return $?Math.round(C):C;r(`${p} of <${CHART_TAG}> is ${$?"a number of pixels":"a number"}, not "${E}"`)},L=F("min",!1),B=F("max",!1),I=F("width",!0),R=F("height",!0),O=n.get("colors");return[{type:"chart",kind:i,...m("title",n.get("title")),...a===void 0?{}:{table:a},...c===void 0||c===""?{}:{data:c},...a===void 0?m("categories",g):{},...a===void 0&&u!==void 0&&v(u).length>0?{series:v(u)}:{},...f!==void 0&&b.includes(f)?{legend:f}:{},...S!==void 0&&!G?.length?{labels:S}:{},...m("format",n.get("format")),...L===void 0?{}:{min:L},...B===void 0?{}:{max:B},...O!==void 0&&v(O).length>0?{colors:v(O)}:{},...n.has("smooth")&&n.get("smooth")!=="false"?{smooth:!0}:{},...I===void 0?{}:{width:I},...R===void 0?{}:{height:R},...m("alt",n.get("alt")),...m("id",n.get("id"))}]}function $e(t,e){h(t,e,[]);const n=[];for(const r of e.children){if(r.type!=="mdxJsxFlowElement"||r.name!==COLUMN_TAG)return l(t,r,`<${COLUMNS_TAG}> holds <${COLUMN_TAG}>s, each around its blocks`),[];const o=h(t,r,["width"]).get("width"),s=o===void 0?void 0:Number(o);o!==void 0&&!(Number.isFinite(s)&&(s??0)>0)&&l(t,r,`a column's width is a share against the others' (1, 2, 0.5), not "${o}"`);const d=T(t,r.children);if(d.some(a=>a.type==="columns"))return l(t,r,`a <${COLUMN_TAG}> holds no <${COLUMNS_TAG}>`),[];n.push({...s!==void 0&&Number.isFinite(s)&&s>0&&s!==1?{width:s}:{},blocks:d})}return n.length<2?(l(t,e,`<${COLUMNS_TAG}> holds two or more <${COLUMN_TAG}>s`),[]):[{type:"columns",columns:n}]}function ye(t,e){const n=h(t,e,["widths","head","caption","id"]),r=T(t,e.children),[i,...o]=r;if(i?.type!=="table"||o.length>0)return l(t,e,`<${TABLE_TAG}> holds one table`),r;const s=n.get("head");s!==void 0&&!["none","column","both","row"].includes(s)&&l(t,e,`a table's head is none, row, column or both, not "${s}"`);const d=n.get("widths")?.split(",").map(a=>{const c=Number(a.trim());return a.trim()!==""&&Number.isFinite(c)&&c>0?Math.round(c):null});return[{...i,...s==="none"||s==="column"||s==="both"?{head:s}:{},...d?.some(a=>a!==null)?{widths:d}:{},...m("caption",n.get("caption")),...m("id",n.get("id"))}]}function we(t,e){switch(e.type){case"paragraph":{const n=e.children.length===1?e.children[0]:void 0;if(n?.type==="image")return[{type:"image",src:n.url,...n.alt?{alt:n.alt}:{},...n.title?{caption:n.title}:{}}];const r=_(t,e.children),i=r.map(o=>o.text).join("").trim();return i.startsWith("$$")&&i.endsWith("$$")&&i.length>4&&l(t,e,"$$ is not drawn in a doc: an equation is a ```math code block"),[{type:"paragraph",content:r}]}case"heading":return[{type:"heading",level:e.depth,content:_(t,e.children)}];case"list":{const n=e.ordered===!0;return e.children.map((r,i)=>ce(t,r,n,i===0&&n?e.start??void 0:void 0))}case"blockquote":{const{content:n,under:r}=M(t,e.children);return[w({type:"quote",content:n},r)]}case"code":return[{type:"code",...e.lang?{language:e.lang}:{},code:e.value}];case"table":return[{type:"table",rows:e.children.map(n=>de(t,n))}];case"thematicBreak":return[{type:"divider"}];case"mdxJsxFlowElement":{const n=r=>r.length>0?r:[{type:"embed",source:k(t,e)}];if(e.name===BLOCK_TAG)return n(fe(t,e));if(e.name===TABLE_TAG)return ye(t,e);if(e.name===CALLOUT_TAG)return me(t,e);if(e.name===COMPONENT_TAG)return n(be(t,e));if(e.name===CHART_TAG)return n(ke(t,e));if(e.name===COLUMNS_TAG)return n($e(t,e));if(e.name===CARD_TAG)return n(ge(t,e));if(e.name===STATS_TAG)return n(he(t,e));if(e.name===STAT_TAG)return l(t,e,`a <${STAT_TAG} /> stands inside <${STATS_TAG}>`),n([]);if(e.name===PAGE_BREAK_TAG){const i=h(t,e,["orientation"]).get("orientation");return e.children.length>0?(l(t,e,`<${PAGE_BREAK_TAG} /> holds nothing`),n([])):i!==void 0&&i!=="portrait"&&i!=="landscape"?(l(t,e,`a page break's orientation is portrait or landscape, not "${i}"`),n([])):[{type:"pagebreak",...i===void 0?{}:{orientation:i}}]}if(e.name===BIBLIOGRAPHY_TAG)return e.attributes.length>0||e.children.length>0?(l(t,e,`<${BIBLIOGRAPHY_TAG} /> takes nothing`),n([])):[{type:"bibliography"}];if(e.name===TOC_TAG){const r=h(t,e,["levels","title"]),i=r.get("levels"),o=r.get("title"),s=i===void 0?void 0:Number(i);return e.children.length>0||s!==void 0&&!(Number.isInteger(s)&&s>=1&&s<=6)?(l(t,e,`<${TOC_TAG} /> holds nothing, and its levels are 1 to 6 (the deepest heading it lists)`),n([])):[{type:"toc",...s===void 0?{}:{levels:s},...o===void 0?{}:{title:o}}]}return e.name===COLUMN_TAG?(l(t,e,`a <${COLUMN_TAG}> stands inside <${COLUMNS_TAG}>`),n([])):e.name==="img"&&e.children.length===0?n(pe(t,e)):H(e)?[{type:"paragraph",content:[]}]:[{type:"embed",source:k(t,e)}]}case"footnoteDefinition":{const{content:n,under:r}=M(t,e.children);return[w({type:"note",label:e.label??e.identifier,content:n},r)]}case"mdxjsEsm":case"definition":return[{type:"source",source:k(t,e)}];case"mdxFlowExpression":return l(t,e,"{…} on its own is not drawn in a doc"),[{type:"source",source:k(t,e)}];default:return l(t,e,`${e.type} is not drawn in a doc`),[{type:"source",source:k(t,e)}]}}function U(t,e){return e.map((n,r)=>{const i=we(t,n),o=e[r-1],s=i[0];return n.type==="list"&&n.ordered===!0&&o?.type==="list"&&o.ordered===!0&&s?.type==="numbered"&&s.start===void 0&&(i[0]={...s,start:n.start??1}),i})}function T(t,e){return U(t,e).flat()}export function parseDoc(t){const e={source:t,problems:[]};let n;try{n=Y(t,{extensions:[Z(),re(),x(),te(),ee(),ne(),V()],mdastExtensions:[q(),Q(),K(),z(),W(),X()]})}catch(u){const f=u;return{source:t,blocks:[],segments:[],page:{},problems:[{message:f.reason??f.message??"The file is not MDX",...typeof f.line=="number"?{line:f.line}:{},...typeof f.column=="number"?{column:f.column}:{}}]}}const[r]=n.children,i=r?.type==="yaml"?r:void 0,o=i?n.children.slice(1):n.children,s=i?Te(e,i):{},d=[],a=U(e,o);o.forEach((u,f)=>{const b=u.position?.start.offset,A=u.position?.end.offset;b===void 0||A===void 0||d.push({start:b,end:A,blocks:a[f]??[]})});const c=i?.position?.start.offset,g=i?.position?.end.offset;return{source:t,blocks:d.flatMap(u=>u.blocks),segments:d,problems:e.problems,page:s,...c===void 0||g===void 0?{}:{frontMatter:{start:c,end:g}}}}function Te(t,e){let n;try{n=ie(e.value)}catch(r){return l(t,e,`the front matter is not YAML: ${r instanceof Error?r.message:String(r)}`),{}}return n==null?{}:typeof n!="object"||Array.isArray(n)?(l(t,e,`the front matter holds keys: ${se.join(", ")}`),{}):ae(n,r=>{l(t,e,r)})}
2
+ import{CHART_LEGEND_POSITIONS as Y,SHEET_CHART_TYPES as j}from"@allyhub/formats";import{fromMarkdown as q}from"mdast-util-from-markdown";import{frontmatterFromMarkdown as K}from"mdast-util-frontmatter";import{gfmFootnoteFromMarkdown as W}from"mdast-util-gfm-footnote";import{gfmStrikethroughFromMarkdown as z}from"mdast-util-gfm-strikethrough";import{gfmTableFromMarkdown as X}from"mdast-util-gfm-table";import{gfmTaskListItemFromMarkdown as Q}from"mdast-util-gfm-task-list-item";import{mdxFromMarkdown as V}from"mdast-util-mdx";import{cjkFriendlyExtension as Z}from"micromark-extension-cjk-friendly";import{frontmatter as x}from"micromark-extension-frontmatter";import{gfmFootnote as ee}from"micromark-extension-gfm-footnote";import{gfmStrikethrough as te}from"micromark-extension-gfm-strikethrough";import{gfmTable as ne}from"micromark-extension-gfm-table";import{gfmTaskListItem as ie}from"micromark-extension-gfm-task-list-item";import{mdxjs as re}from"micromark-extension-mdxjs";import{parse as oe}from"yaml";import{citedOf as se}from"./cite.js";import{PAGE_KEYS as ae,readPageLook as le}from"./page.js";import{CHART_LABELS as P}from"./model.js";export const BLOCK_TAG="Block",CALLOUT_TAG="Callout",TABLE_TAG="Table",COMPONENT_TAG="Component",ITEM_TAG="Item",COMPONENT_ATTRIBUTES=["of","width","height","at","alt","title","align","id"],PAGE_BREAK_TAG="PageBreak",CARD_TAG="Card",STATS_TAG="Stats",STAT_TAG="Stat",STAT_ATTRIBUTES=["label","value","delta","note","down-is-good","trend"],TAG_TAG="Tag",COLUMNS_TAG="Columns",COLUMN_TAG="Column",CHART_TAG="Chart",CHART_ATTRIBUTES=["type","title","data","categories","series","legend","labels","format","min","max","colors","smooth","width","height","alt","id"],BIBLIOGRAPHY_TAG="Bibliography",TOC_TAG="TableOfContents";const N=t=>t.split(",").map(e=>e.trim()).filter(e=>e!==""),J=new Set(["center","right","justify"]),k=(t,e)=>{const n=e.position?.start.offset,i=e.position?.end.offset;return n===void 0||i===void 0?"":t.source.slice(n,i)};function l(t,e,n){const i=e.position?.start;t.problems.push({message:n,...i?{line:i.line,column:i.column}:{}})}const ue=(t,e)=>t.bold===e.bold&&t.italic===e.italic&&t.underline===e.underline&&t.strike===e.strike&&t.code===e.code&&t.color===e.color&&t.background===e.background&&t.tag===e.tag;function T(t,e,n,i){if(e==="")return;const r=t.at(-1);if(r&&r.note===void 0&&r.cite===void 0&&r.href===i&&ue(r.styles,n)){r.text+=e;return}t.push({text:e,styles:{...n},...i===void 0?{}:{href:i}})}function b(t,e,n){const i=new Map;for(const r of e.attributes){if(r.type!=="mdxJsxAttribute"||!n.includes(r.name)){l(t,e,`<${e.name??""}> takes ${n.join(", ")}: ${r.type==="mdxJsxAttribute"?r.name:"{…}"} is not one of them`);continue}r.value===null||r.value===void 0?i.set(r.name,""):typeof r.value=="string"?i.set(r.name,r.value):l(t,e,`${r.name} of <${e.name??""}> is a plain string`)}return i}function ce(t,e,n){switch(e.name){case"u":return{...n,underline:!0};case"strong":case"b":return{...n,bold:!0};case"em":case"i":return{...n,italic:!0};case"del":case"s":return{...n,strike:!0};case"code":return{...n,code:!0};case TAG_TAG:{const i=b(t,e,["color"]).get("color");return{...n,tag:i===void 0||i===""?"gray":i}}case"span":{const i=b(t,e,["color","bg"]),r=i.get("color"),o=i.get("bg");return{...n,...r?{color:r}:{},...o?{background:o}:{}}}default:return}}function _(t,e,n,i,r){for(const o of e)switch(o.type){case"text":for(const[,s]of o.value.matchAll(/\[\^([^\]\s]+)\]/gu))l(t,o,`the footnote [^${s??""}] has no note: write [^${s??""}]: … on a line of its own`);for(const s of o.value.replace(/\r?\n/g," ").split(/(\[-?@[^\]]+\])/u)){if(s==="")continue;const c=/^\[(-?@[^\]]+)\]$/u.exec(s)?.[1];c!==void 0&&se(c).keys.length>0?r.push({text:s,styles:{...n},cite:c}):T(r,s,n,i)}break;case"strong":_(t,o.children,{...n,bold:!0},i,r);break;case"emphasis":_(t,o.children,{...n,italic:!0},i,r);break;case"delete":_(t,o.children,{...n,strike:!0},i,r);break;case"inlineCode":T(r,o.value,{...n,code:!0},i);break;case"break":T(r,`
3
+ `,n,i);break;case"link":o.children.length===0?r.push({text:"",styles:{...n},href:o.url}):_(t,o.children,n,o.url,r);break;case"footnoteReference":{const s=o.label??o.identifier;r.push({text:s,styles:{...n},...i===void 0?{}:{href:i},note:s});break}case"mdxJsxTextElement":{if(o.name==="br"){T(r,`
4
+ `,n,i);break}const s=ce(t,o,n);if(s){_(t,o.children,s,i,r);break}l(t,o,`<${o.name??""}> inside a line is not drawn: a tag the doc's code draws goes on lines of its own`),T(r,k(t,o),n,i);break}case"mdxTextExpression":l(t,o,"{…} in a line is not drawn: write \\{ for a brace"),T(r,k(t,o),n,i);break;default:l(t,o,`${o.type} is not drawn in a doc`),T(r,k(t,o),n,i)}}function F(t,e){const n=[];return _(t,e,{},void 0,n),n}const H=t=>t?.type==="mdxJsxFlowElement"&&t.name==="br"&&t.children.length===0;function G(t,e){const[n,...i]=e;if(n?.type==="paragraph"){const r=F(t,n.children);return{content:r.length===1&&r[0]?.text===`
5
+ `&&Object.keys(r[0].styles).length===0?[]:r,under:E(t,i)}}return H(n)?{content:[],under:E(t,i)}:{content:[],under:E(t,e)}}const A=(t,e)=>e.length>0?{...t,children:e}:t;function de(t,e,n,i){const{content:r,under:o}=G(t,e.children);return typeof e.checked=="boolean"?A({type:"check",checked:e.checked,content:r},o):A(n?{type:"numbered",...i===void 0||i===1?{}:{start:i},content:r}:{type:"bullet",content:r},o)}function fe(t,e){return e.children.map(n=>F(t,n.children))}function f(t,e){return e?{[t]:e}:{}}function me(t,e){const n=b(t,e,["align","color","bg","toggle"]),i=E(t,e.children),[r,...o]=i;if(r===void 0)return l(t,e,`<${BLOCK_TAG}> holds a block: this one is empty`),[];if(r.type==="embed"||r.type==="source")return l(t,e,`<${BLOCK_TAG}> holds a block of the doc's own, not a tag or an import`),i;const s=n.get("align");s!==void 0&&!J.has(s)&&l(t,e,`align is center, right or justify, not "${s}"`);const c={...s!==void 0&&J.has(s)?{align:s}:{},...f("color",n.get("color")),...f("background",n.get("bg"))};let a=r;if(n.has("toggle")&&(a.type==="heading"?a={...a,toggle:!0}:a.type==="paragraph"?a={type:"toggle",content:a.content}:l(t,e,"toggle is for a heading or a line of text")),Object.keys(c).length>0&&("content"in a?a={...a,look:c}:l(t,e,`a ${a.type} has no look to set`)),o.length>0)if("content"in a)a={...a,children:[...a.children??[],...o]};else return l(t,e,`a ${a.type} holds no blocks under it`),[a,...o];return[a]}function he(t,e){const n=b(t,e,["icon","color","bg"]),{content:i,under:r}=G(t,e.children),o={...f("color",n.get("color")),...f("background",n.get("bg"))};return[A({type:"callout",...f("icon",n.get("icon")),...Object.keys(o).length>0?{look:o}:{},content:i},r)]}function ge(t,e){const n=b(t,e,["title","subtitle"]),i=E(t,e.children);return[A({type:"card",...f("title",n.get("title")),...f("subtitle",n.get("subtitle"))},i)]}function pe(t,e){b(t,e,[]);const n=[];for(const i of e.children){if(i.type!=="mdxJsxFlowElement"||i.name!==STAT_TAG||i.children.length>0)return l(t,i,`<${STATS_TAG}> holds <${STAT_TAG} label="…" value="…" />s, one to a line`),[];const r=b(t,i,STAT_ATTRIBUTES),o=r.get("label"),s=r.get("value");if(s===void 0||o===void 0)return l(t,i,`a <${STAT_TAG}> has a label and a value`),[];const c=r.get("trend"),a=c?.split(",").map(g=>Number(g.trim()));if(a!==void 0&&!a.every(g=>Number.isFinite(g)))return l(t,i,`a stat's trend is numbers, oldest first, comma-separated ("12,15,14,19"), not "${c??""}"`),[];n.push({label:o,value:s,...f("delta",r.get("delta")),...f("note",r.get("note")),...r.has("down-is-good")&&r.get("down-is-good")!=="false"?{downIsGood:!0}:{},...a===void 0||a.length<2?{}:{trend:a}})}return n.length===0?(l(t,e,`<${STATS_TAG}> holds one <${STAT_TAG} /> or more`),[]):[{type:"stats",stats:n}]}function be(t,e){const n=b(t,e,["src","alt","title","width","align","id"]),i=n.get("src");if(!i)return l(t,e,"<img> names its picture: src is missing"),[];const r=Number(n.get("width")),o=n.get("align");return o!==void 0&&o!=="center"&&o!=="right"&&l(t,e,`a picture's align is center or right, not "${o}"`),[{type:"image",src:i,...f("alt",n.get("alt")),...f("caption",n.get("title")),...Number.isFinite(r)&&r>0?{width:Math.round(r)}:{},...o==="center"||o==="right"?{align:o}:{},...f("id",n.get("id"))}]}function U(t,e,n=COMPONENT_TAG){const i=n===ITEM_TAG;if(e.children.length>0)return l(t,e,i?`<${ITEM_TAG}> holds nothing: what it shows is its attributes`:`<${n}> holds nothing: its props are its attributes`),[];const r=new Map,o={};for(const h of e.attributes){if(h.type!=="mdxJsxAttribute"){l(t,e,`<${n}>'s attributes are plain strings, not {…}`);continue}const p=h.value===null||h.value===void 0?"":typeof h.value=="string"?h.value:void 0;if(p===void 0){l(t,e,`${h.name} of <${n}> is a plain string`);continue}COMPONENT_ATTRIBUTES.includes(h.name)?r.set(h.name,p):i?l(t,e,`<${ITEM_TAG}> has no ${h.name}: it takes of, at, width, height, alt, title, align and id`):o[h.name]=p}const s=r.get("of")??"";if(s.trim()==="")return l(t,e,i?`<${ITEM_TAG}> names the item it shows: of is missing (of="../deck/q3.ts#pricing")`:`<${n}> names its component: of is missing (of="../ui.ts#Dialog")`),[];const c=h=>{const p=r.get(h);if(p===void 0)return;const w=Number(p);if(Number.isFinite(w)&&w>0)return Math.round(w);l(t,e,`${h} of <${n}> is a number of pixels, not "${p}"`)},a=c("width"),g=c("height"),m=r.get("at"),u=m===void 0?void 0:Number(m);u!==void 0&&!(Number.isFinite(u)&&u>=0)&&l(t,e,`at of <${n}> is seconds, 0 or more, not "${m??""}"`);const d=r.get("align");return d!==void 0&&d!=="center"&&d!=="right"&&l(t,e,`a component's align is center or right, not "${d}"`),[{type:"component",of:s,...a===void 0?{}:{width:a},...g===void 0?{}:{height:g},...u!==void 0&&Number.isFinite(u)&&u>=0?{at:u}:{},...f("alt",r.get("alt")),...f("caption",r.get("title")),...d==="center"||d==="right"?{align:d}:{},...f("id",r.get("id")),props:o,...i?{item:!0}:{}}]}function $e(t,e){const n=b(t,e,CHART_ATTRIBUTES),i=$=>{l(t,e,$)},r=n.get("type");if(r===void 0||r==="")return i(`<${CHART_TAG}> says what it is drawn as: type is missing (${j.join(", ")})`),[];if(!j.includes(r))return i(`a chart's type is ${j.join(", ")}, not "${r}"`),[];const o=e.children,[s,...c]=o;if(c.length>0||s!==void 0&&s.type!=="table")return i(`<${CHART_TAG}> holds one table: its numbers`),[];const a=s?.type==="table"?s.children.map($=>$.children.map(y=>F(t,y.children).map(v=>v.text).join("").trim())):void 0,g=n.get("data"),m=n.get("categories"),u=n.get("series");if(a!==void 0&&g!==void 0)return i("a chart's numbers are its table or the file data names, not both"),[];if(a===void 0&&(g===void 0||g===""))return i(`<${CHART_TAG}> has numbers: a table inside it, or data="…" naming a file of them`),[];if(a!==void 0){(m!==void 0||u!==void 0)&&i("categories and series name a file's columns: a chart's own table has its series in its head row and its categories in its first column");const $=Math.min(...a.map(y=>y.length));(a.length<2||$<2)&&i("a chart's table has a head row and a row of numbers, a column of categories and a column of numbers")}else(m===void 0||m==="")&&i("with data, categories names the column of the categories"),(u===void 0||N(u).length===0)&&i('with data, series names the columns of the numbers (series="revenue,cost")');const d=n.get("legend"),h=[...Y,"none"];d!==void 0&&!h.includes(d)&&i(`a chart's legend is ${h.join(", ")}, not "${d}"`);const p=n.get("labels"),w=p===void 0?void 0:p===""?["value"]:N(p),S=w?.filter($=>!P.includes($));S?.length&&i(`a chart's labels are ${P.join(", ")}, not ${S.map($=>`"${$}"`).join(", ")}`);const M=($,y)=>{const v=n.get($);if(v===void 0)return;const C=Number(v);if(v.trim()!==""&&Number.isFinite(C)&&(!y||C>0))return y?Math.round(C):C;i(`${$} of <${CHART_TAG}> is ${y?"a number of pixels":"a number"}, not "${v}"`)},L=M("min",!1),B=M("max",!1),I=M("width",!0),R=M("height",!0),O=n.get("colors");return[{type:"chart",kind:r,...f("title",n.get("title")),...a===void 0?{}:{table:a},...g===void 0||g===""?{}:{data:g},...a===void 0?f("categories",m):{},...a===void 0&&u!==void 0&&N(u).length>0?{series:N(u)}:{},...d!==void 0&&h.includes(d)?{legend:d}:{},...w!==void 0&&!S?.length?{labels:w}:{},...f("format",n.get("format")),...L===void 0?{}:{min:L},...B===void 0?{}:{max:B},...O!==void 0&&N(O).length>0?{colors:N(O)}:{},...n.has("smooth")&&n.get("smooth")!=="false"?{smooth:!0}:{},...I===void 0?{}:{width:I},...R===void 0?{}:{height:R},...f("alt",n.get("alt")),...f("id",n.get("id"))}]}function ke(t,e){b(t,e,[]);const n=[];for(const i of e.children){if(i.type!=="mdxJsxFlowElement"||i.name!==COLUMN_TAG)return l(t,i,`<${COLUMNS_TAG}> holds <${COLUMN_TAG}>s, each around its blocks`),[];const o=b(t,i,["width"]).get("width"),s=o===void 0?void 0:Number(o);o!==void 0&&!(Number.isFinite(s)&&(s??0)>0)&&l(t,i,`a column's width is a share against the others' (1, 2, 0.5), not "${o}"`);const c=E(t,i.children);if(c.some(a=>a.type==="columns"))return l(t,i,`a <${COLUMN_TAG}> holds no <${COLUMNS_TAG}>`),[];n.push({...s!==void 0&&Number.isFinite(s)&&s>0&&s!==1?{width:s}:{},blocks:c})}return n.length<2?(l(t,e,`<${COLUMNS_TAG}> holds two or more <${COLUMN_TAG}>s`),[]):[{type:"columns",columns:n}]}function we(t,e){const n=b(t,e,["widths","head","caption","id","data","fields"]),i=E(t,e.children),r=n.get("data"),o=n.get("fields")?.split(",").map(m=>m.trim()).filter(m=>m!=="");if(r===void 0&&o!==void 0&&l(t,e,"fields say which columns a table shows of its data: give it data"),r!==void 0&&i.length>0)return l(t,e,`<${TABLE_TAG} data> reads its rows: it holds no table`),i;const[s,...c]=r===void 0?i:[{type:"table",rows:[]}];if(s?.type!=="table"||c.length>0)return l(t,e,`<${TABLE_TAG}> holds one table`),i;const a=n.get("head");a!==void 0&&!["none","column","both","row"].includes(a)&&l(t,e,`a table's head is none, row, column or both, not "${a}"`);const g=n.get("widths")?.split(",").map(m=>{const u=Number(m.trim());return m.trim()!==""&&Number.isFinite(u)&&u>0?Math.round(u):null});return[{...s,...a==="none"||a==="column"||a==="both"?{head:a}:{},...g?.some(m=>m!==null)?{widths:g}:{},...f("caption",n.get("caption")),...f("id",n.get("id")),...r===void 0?{}:{data:r},...r===void 0||o===void 0||o.length===0?{}:{fields:o}}]}function ye(t,e){switch(e.type){case"paragraph":{const n=e.children.length===1?e.children[0]:void 0;if(n?.type==="image")return[{type:"image",src:n.url,...n.alt?{alt:n.alt}:{},...n.title?{caption:n.title}:{}}];const i=F(t,e.children),r=i.map(o=>o.text).join("").trim();return r.startsWith("$$")&&r.endsWith("$$")&&r.length>4&&l(t,e,"$$ is not drawn in a doc: an equation is a ```math code block"),[{type:"paragraph",content:i}]}case"heading":return[{type:"heading",level:e.depth,content:F(t,e.children)}];case"list":{const n=e.ordered===!0;return e.children.map((i,r)=>de(t,i,n,r===0&&n?e.start??void 0:void 0))}case"blockquote":{const{content:n,under:i}=G(t,e.children);return[A({type:"quote",content:n},i)]}case"code":return[{type:"code",...e.lang?{language:e.lang}:{},code:e.value}];case"table":return[{type:"table",rows:e.children.map(n=>fe(t,n))}];case"thematicBreak":return[{type:"divider"}];case"mdxJsxFlowElement":{const n=i=>i.length>0?i:[{type:"embed",source:k(t,e)}];if(e.name===BLOCK_TAG)return n(me(t,e));if(e.name===TABLE_TAG)return we(t,e);if(e.name===CALLOUT_TAG)return he(t,e);if(e.name===COMPONENT_TAG)return n(U(t,e));if(e.name===ITEM_TAG)return n(U(t,e,ITEM_TAG));if(e.name===CHART_TAG)return n($e(t,e));if(e.name===COLUMNS_TAG)return n(ke(t,e));if(e.name===CARD_TAG)return n(ge(t,e));if(e.name===STATS_TAG)return n(pe(t,e));if(e.name===STAT_TAG)return l(t,e,`a <${STAT_TAG} /> stands inside <${STATS_TAG}>`),n([]);if(e.name===PAGE_BREAK_TAG){const r=b(t,e,["orientation"]).get("orientation");return e.children.length>0?(l(t,e,`<${PAGE_BREAK_TAG} /> holds nothing`),n([])):r!==void 0&&r!=="portrait"&&r!=="landscape"?(l(t,e,`a page break's orientation is portrait or landscape, not "${r}"`),n([])):[{type:"pagebreak",...r===void 0?{}:{orientation:r}}]}if(e.name===BIBLIOGRAPHY_TAG)return e.attributes.length>0||e.children.length>0?(l(t,e,`<${BIBLIOGRAPHY_TAG} /> takes nothing`),n([])):[{type:"bibliography"}];if(e.name===TOC_TAG){const i=b(t,e,["levels","title"]),r=i.get("levels"),o=i.get("title"),s=r===void 0?void 0:Number(r);return e.children.length>0||s!==void 0&&!(Number.isInteger(s)&&s>=1&&s<=6)?(l(t,e,`<${TOC_TAG} /> holds nothing, and its levels are 1 to 6 (the deepest heading it lists)`),n([])):[{type:"toc",...s===void 0?{}:{levels:s},...o===void 0?{}:{title:o}}]}return e.name===COLUMN_TAG?(l(t,e,`a <${COLUMN_TAG}> stands inside <${COLUMNS_TAG}>`),n([])):e.name==="img"&&e.children.length===0?n(be(t,e)):H(e)?[{type:"paragraph",content:[]}]:[{type:"embed",source:k(t,e)}]}case"footnoteDefinition":{const{content:n,under:i}=G(t,e.children);return[A({type:"note",label:e.label??e.identifier,content:n},i)]}case"mdxjsEsm":case"definition":return[{type:"source",source:k(t,e)}];case"mdxFlowExpression":return l(t,e,"{…} on its own is not drawn in a doc"),[{type:"source",source:k(t,e)}];default:return l(t,e,`${e.type} is not drawn in a doc`),[{type:"source",source:k(t,e)}]}}function D(t,e){return e.map((n,i)=>{const r=ye(t,n),o=e[i-1],s=r[0];return n.type==="list"&&n.ordered===!0&&o?.type==="list"&&o.ordered===!0&&s?.type==="numbered"&&s.start===void 0&&(r[0]={...s,start:n.start??1}),r})}function E(t,e){return D(t,e).flat()}export function parseDoc(t){const e={source:t,problems:[]};let n;try{n=q(t,{extensions:[x(),re(),ee(),ne(),te(),ie(),Z()],mdastExtensions:[K(),V(),W(),X(),z(),Q()]})}catch(u){const d=u;return{source:t,blocks:[],segments:[],page:{},problems:[{message:d.reason??d.message??"The file is not MDX",...typeof d.line=="number"?{line:d.line}:{},...typeof d.column=="number"?{column:d.column}:{}}]}}const[i]=n.children,r=i?.type==="yaml"?i:void 0,o=r?n.children.slice(1):n.children,s=r?Te(e,r):{},c=[],a=D(e,o);o.forEach((u,d)=>{const h=u.position?.start.offset,p=u.position?.end.offset;h===void 0||p===void 0||c.push({start:h,end:p,blocks:a[d]??[]})});const g=r?.position?.start.offset,m=r?.position?.end.offset;return{source:t,blocks:c.flatMap(u=>u.blocks),segments:c,problems:e.problems,page:s,...g===void 0||m===void 0?{}:{frontMatter:{start:g,end:m}}}}function Te(t,e){let n;try{n=oe(e.value)}catch(i){return l(t,e,`the front matter is not YAML: ${i instanceof Error?i.message:String(i)}`),{}}return n==null?{}:typeof n!="object"||Array.isArray(n)?(l(t,e,`the front matter holds keys: ${ae.join(", ")}`),{}):le(n,i=>{l(t,e,i)})}