@heycys/gallery 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (473) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/browser/editor/components/align.mjs +58 -0
  3. package/browser/editor/components/code/index.mjs +1 -1
  4. package/browser/editor/components/columns/page.mjs +4 -4
  5. package/browser/editor/components/embed/index.mjs +2 -2
  6. package/browser/editor/components/embed/page.mjs +1 -1
  7. package/browser/editor/components/file/page.mjs +4 -4
  8. package/browser/editor/components/flowchart/add.mjs +7 -6
  9. package/browser/editor/components/flowchart/page.mjs +1 -1
  10. package/browser/editor/components/heading/index.mjs +7 -6
  11. package/browser/editor/components/icons.mjs +11 -0
  12. package/browser/editor/components/image/crop.mjs +6 -9
  13. package/browser/editor/components/image/index.mjs +2 -0
  14. package/browser/editor/components/image/page.mjs +172 -90
  15. package/browser/editor/components/installed/index.mjs +15 -4
  16. package/browser/editor/components/installed/page.mjs +103 -25
  17. package/browser/editor/components/installed/served.mjs +6 -5
  18. package/browser/editor/components/instances.mjs +18 -0
  19. package/browser/editor/components/list/page.mjs +3 -6
  20. package/browser/editor/components/media/icons.mjs +13 -8
  21. package/browser/editor/components/media/page.mjs +5 -3
  22. package/browser/editor/components/media/toolbar.mjs +12 -3
  23. package/browser/editor/components/paragraph/index.mjs +4 -3
  24. package/browser/editor/components/registry.mjs +30 -9
  25. package/browser/editor/components/table/index.mjs +61 -2
  26. package/browser/editor/components/table/page.mjs +1 -1
  27. package/browser/editor/page/after/index.mjs +288 -0
  28. package/browser/editor/page/align.mjs +91 -0
  29. package/browser/editor/page/annotate/card.mjs +3 -6
  30. package/browser/editor/page/autosave.mjs +310 -37
  31. package/browser/editor/page/beside.mjs +5 -6
  32. package/browser/editor/page/block-menu/index.mjs +6 -3
  33. package/browser/editor/page/blocks.mjs +3 -1
  34. package/browser/editor/page/board/client.mjs +57 -0
  35. package/browser/editor/page/board/hint.mjs +182 -0
  36. package/browser/editor/page/board/history.mjs +119 -0
  37. package/browser/editor/page/board/index.mjs +1059 -0
  38. package/browser/editor/page/board/motion.mjs +177 -0
  39. package/browser/editor/page/board/settings.mjs +210 -0
  40. package/browser/editor/page/caret.mjs +1 -1
  41. package/browser/editor/page/changes/bar.mjs +6 -14
  42. package/browser/editor/page/changes/index.mjs +2 -2
  43. package/browser/editor/page/clipboard/import/html.mjs +29 -6
  44. package/browser/editor/page/clipboard/import/inline.mjs +32 -0
  45. package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
  46. package/browser/editor/page/clipboard/import/read.mjs +6 -1
  47. package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
  48. package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
  49. package/browser/editor/page/clipboard/index.mjs +133 -15
  50. package/browser/editor/page/clipboard/own/blocks.mjs +13 -14
  51. package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
  52. package/browser/editor/page/clipboard/own/describe.mjs +6 -2
  53. package/browser/editor/page/clipboard/own/selection.mjs +1 -1
  54. package/browser/editor/page/columns/index.mjs +48 -46
  55. package/browser/editor/page/commit.mjs +80 -22
  56. package/browser/editor/page/conflicts.mjs +7 -7
  57. package/browser/editor/page/core.mjs +34 -16
  58. package/browser/editor/page/custom-page.mjs +110 -0
  59. package/browser/editor/page/editor.mjs +71 -17
  60. package/browser/editor/page/emoji-picker/styles.mjs +7 -12
  61. package/browser/editor/page/emoji-picker/upload.mjs +2 -2
  62. package/browser/editor/page/handle/index.mjs +5 -8
  63. package/browser/editor/page/history.mjs +41 -6
  64. package/browser/editor/page/insert/index.mjs +20 -22
  65. package/browser/editor/page/links/index.mjs +5 -3
  66. package/browser/editor/page/links/pages.mjs +27 -9
  67. package/browser/editor/page/look.mjs +54 -3
  68. package/browser/editor/page/margin.mjs +18 -3
  69. package/browser/editor/page/media-menu/index.mjs +6 -7
  70. package/browser/editor/page/menu.mjs +33 -14
  71. package/browser/editor/page/notices.mjs +2 -2
  72. package/browser/editor/page/page-objects.mjs +9 -2
  73. package/browser/editor/page/panel.mjs +4 -9
  74. package/browser/editor/page/present-links.mjs +15 -5
  75. package/browser/editor/page/present-shell.mjs +63 -0
  76. package/browser/editor/page/resize/index.mjs +42 -29
  77. package/browser/editor/page/selection/index.mjs +10 -2
  78. package/browser/editor/page/served.mjs +14 -0
  79. package/browser/editor/page/session.mjs +48 -4
  80. package/browser/editor/page/slash-menu/index.mjs +3 -3
  81. package/browser/editor/page/table/binding.mjs +87 -0
  82. package/browser/editor/page/table/cells.mjs +102 -46
  83. package/browser/editor/page/table/index.mjs +24 -9
  84. package/browser/editor/page/table/pictures.mjs +299 -0
  85. package/browser/editor/page/table/views.mjs +103 -0
  86. package/browser/editor/page/table/widths.mjs +82 -10
  87. package/browser/editor/page/text-select/index.mjs +26 -12
  88. package/browser/editor/page/todo-writes.mjs +75 -0
  89. package/browser/editor/page/typing/index.mjs +97 -15
  90. package/browser/editor/page/typing/leave.mjs +19 -5
  91. package/browser/editor/page/ui.mjs +13 -0
  92. package/browser/shared/block-packs.mjs +419 -0
  93. package/browser/shared/board-places.mjs +224 -0
  94. package/browser/shared/card-size.mjs +59 -0
  95. package/browser/shared/colors.mjs +3 -2
  96. package/browser/shared/component-catalog.mjs +330 -46
  97. package/browser/shared/component-source.mjs +39 -0
  98. package/browser/shared/components/heading.mjs +2 -1
  99. package/browser/shared/components/index.mjs +12 -3
  100. package/browser/shared/components/installed.mjs +35 -3
  101. package/browser/shared/components/page.mjs +20 -8
  102. package/browser/shared/components/paragraph.mjs +8 -1
  103. package/browser/shared/components/state.mjs +5 -1
  104. package/browser/shared/components/table.mjs +1 -0
  105. package/browser/shared/document-look.mjs +10 -5
  106. package/browser/shared/drafts.mjs +432 -0
  107. package/browser/shared/emoji/line-icons.mjs +37 -0
  108. package/browser/shared/extension-sidebar.mjs +126 -0
  109. package/browser/shared/extensions.mjs +79 -0
  110. package/browser/shared/file-table.mjs +101 -0
  111. package/browser/shared/http.mjs +9 -0
  112. package/browser/shared/i18n/en.mjs +330 -27
  113. package/browser/shared/json-layout.mjs +47 -0
  114. package/browser/shared/net-cache.mjs +133 -0
  115. package/browser/shared/net-keys.mjs +32 -0
  116. package/browser/shared/net-policy.mjs +177 -0
  117. package/browser/shared/outline-shape.mjs +128 -0
  118. package/browser/shared/outline.mjs +359 -67
  119. package/browser/shared/pack-manifest.mjs +88 -0
  120. package/browser/shared/page-address.mjs +6 -3
  121. package/browser/shared/page-cards.mjs +308 -0
  122. package/browser/shared/page-links.mjs +69 -6
  123. package/browser/shared/pages.mjs +500 -0
  124. package/browser/shared/paths.mjs +6 -0
  125. package/browser/shared/pinyin.mjs +92 -0
  126. package/browser/shared/present-step.mjs +17 -0
  127. package/browser/shared/preview-server.mjs +3 -7
  128. package/browser/shared/session.mjs +8 -1
  129. package/browser/shared/shipped-blocks.mjs +299 -0
  130. package/browser/shared/sidebar-head.mjs +70 -0
  131. package/browser/shared/table-chart.mjs +33 -1
  132. package/browser/shared/todos.mjs +83 -0
  133. package/browser/shared/user-directory.mjs +24 -0
  134. package/browser/shared/versions.mjs +14 -0
  135. package/browser/shared/web-links.mjs +139 -0
  136. package/browser/shared/workspace-columns.mjs +120 -0
  137. package/browser/shared/workspace-name.mjs +154 -0
  138. package/browser/shared/workspace-query.mjs +125 -0
  139. package/browser/shared/workspace-registry.mjs +272 -0
  140. package/browser/shared/workspace.mjs +171 -20
  141. package/dist/chunk-2OHANJ6Q.mjs +2 -0
  142. package/dist/chunk-3MBRL2PM.mjs +16 -0
  143. package/dist/chunk-4OKWZY5E.mjs +2 -0
  144. package/dist/chunk-4OZWXZE5.mjs +5 -0
  145. package/dist/chunk-5K44HLTZ.mjs +2 -0
  146. package/dist/{chunk-5ZKJ3H4P.mjs → chunk-5XA2ZBAE.mjs} +3 -3
  147. package/dist/{chunk-4FS7Z7WR.mjs → chunk-67N2QJYT.mjs} +1 -1
  148. package/dist/chunk-6KBYRA2C.mjs +2 -0
  149. package/dist/chunk-6N3PX4XX.mjs +8 -0
  150. package/dist/{chunk-V5JTW2LH.mjs → chunk-6QBHU4DF.mjs} +1 -1
  151. package/dist/chunk-7JDX4E65.mjs +13 -0
  152. package/dist/chunk-7M2BQQGZ.mjs +2 -0
  153. package/dist/chunk-7OG26PGF.mjs +2 -0
  154. package/dist/chunk-AHN3NFKJ.mjs +3 -0
  155. package/dist/chunk-ALZ6ZENZ.mjs +3 -0
  156. package/dist/chunk-AR5D57ZD.mjs +170 -0
  157. package/dist/{chunk-W3BGBJQW.mjs → chunk-BFJGHSQN.mjs} +1 -1
  158. package/dist/{chunk-LS4F7JUM.mjs → chunk-BZ5RAF7L.mjs} +1 -1
  159. package/dist/chunk-CMA72MAG.mjs +2 -0
  160. package/dist/{chunk-LCTHTZIL.mjs → chunk-DAZL73VK.mjs} +91 -91
  161. package/dist/{chunk-Y6RLRPG3.mjs → chunk-DJISHPUL.mjs} +1 -1
  162. package/dist/chunk-DR73Y2UJ.mjs +3 -0
  163. package/dist/{chunk-FDLXYYG4.mjs → chunk-EAIFITAV.mjs} +1 -1
  164. package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
  165. package/dist/chunk-EP25HDAJ.mjs +2 -0
  166. package/dist/{chunk-GB5SOYQJ.mjs → chunk-ERLAIBOA.mjs} +2 -2
  167. package/dist/chunk-EURLTOTZ.mjs +4 -0
  168. package/dist/chunk-F4ZA6JRZ.mjs +3 -0
  169. package/dist/chunk-F6HVDZR4.mjs +2 -0
  170. package/dist/chunk-FDMAXMQA.mjs +2 -0
  171. package/dist/chunk-FETSREUN.mjs +5 -0
  172. package/dist/chunk-GHOYKMQ3.mjs +4 -0
  173. package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
  174. package/dist/chunk-HDWTZ763.mjs +12 -0
  175. package/dist/chunk-HPOI4ZX7.mjs +6 -0
  176. package/dist/{chunk-BGGDRNYQ.mjs → chunk-HXG7EOPJ.mjs} +1 -1
  177. package/dist/chunk-IA4PSIMD.mjs +2 -0
  178. package/dist/{chunk-E7LWZRXY.mjs → chunk-ITOH5EGO.mjs} +1 -1
  179. package/dist/chunk-IV64FFI4.mjs +2 -0
  180. package/dist/chunk-J43Z6LSS.mjs +2 -0
  181. package/dist/chunk-J5PUIV3Y.mjs +4 -0
  182. package/dist/chunk-JA7G53PC.mjs +2 -0
  183. package/dist/chunk-JEUK3ZO7.mjs +2 -0
  184. package/dist/chunk-JLTZF4LA.mjs +2 -0
  185. package/dist/chunk-JZT7I2OJ.mjs +2 -0
  186. package/dist/chunk-K5XATEOO.mjs +2 -0
  187. package/dist/chunk-L2SUIS5S.mjs +2 -0
  188. package/dist/chunk-L7UP52JO.mjs +2 -0
  189. package/dist/chunk-LM4XFQHZ.mjs +2 -0
  190. package/dist/chunk-MN7BZL4R.mjs +2 -0
  191. package/dist/chunk-MTYYHM2G.mjs +15 -0
  192. package/dist/chunk-MXUBKDRO.mjs +15 -0
  193. package/dist/chunk-NAMN3RAF.mjs +2 -0
  194. package/dist/{chunk-SYGN7GLU.mjs → chunk-OEXWRJME.mjs} +1 -1
  195. package/dist/chunk-OFHXGWOX.mjs +2 -0
  196. package/dist/chunk-ORID3AE7.mjs +166 -0
  197. package/dist/chunk-PAREWQGB.mjs +4 -0
  198. package/dist/chunk-PGDE24N5.mjs +2 -0
  199. package/dist/chunk-POTA2FV4.mjs +2 -0
  200. package/dist/chunk-PUOQ65NC.mjs +2 -0
  201. package/dist/chunk-Q4UEPUWF.mjs +2 -0
  202. package/dist/chunk-QE5RG76S.mjs +549 -0
  203. package/dist/chunk-R2ZDLJYT.mjs +10 -0
  204. package/dist/{chunk-7DTINW6U.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  205. package/dist/chunk-SWUTTZCN.mjs +2 -0
  206. package/dist/chunk-TANZRINB.mjs +2 -0
  207. package/dist/chunk-TR7TWGHB.mjs +2 -0
  208. package/dist/chunk-U5XL7D6A.mjs +3 -0
  209. package/dist/{chunk-XNROSH2T.mjs → chunk-U7NZI6N4.mjs} +2 -2
  210. package/dist/chunk-UGWMMEJ5.mjs +15 -0
  211. package/dist/chunk-UJQJKNGK.mjs +2 -0
  212. package/dist/chunk-UYVCQK3H.mjs +22 -0
  213. package/dist/chunk-VFX2KNHP.mjs +4 -0
  214. package/dist/chunk-VS7JIGJW.mjs +24 -0
  215. package/dist/chunk-W7665ZEC.mjs +6 -0
  216. package/dist/chunk-WQDQWCX5.mjs +2 -0
  217. package/dist/chunk-YI43RG4P.mjs +2 -0
  218. package/dist/chunk-YLPSMDIS.mjs +5 -0
  219. package/dist/chunk-YNAWBAYN.mjs +3 -0
  220. package/dist/chunk-YROX2O22.mjs +2 -0
  221. package/dist/chunk-ZDLPUOAG.mjs +6 -0
  222. package/dist/{chunk-IVDLMMBD.mjs → chunk-ZHEHPMBK.mjs} +1 -1
  223. package/dist/chunk-ZQS6H473.mjs +16 -0
  224. package/dist/chunk-ZTHICSSF.mjs +2 -0
  225. package/dist/chunk-ZWWC4KLF.mjs +20 -0
  226. package/dist/cli.mjs +1 -1
  227. package/dist/server.mjs +1 -1
  228. package/dist/{chunk-U6KNPJPR.mjs → update-fetch.mjs} +1 -1
  229. package/dist/worker.mjs +1 -1
  230. package/kit/board.css +95 -0
  231. package/kit/board.js +250 -0
  232. package/kit/charts.js +5 -71
  233. package/kit/code.js +17 -17
  234. package/kit/report.css +335 -18
  235. package/kit/runtime.js +1638 -125
  236. package/kit/state.js +10 -1
  237. package/kit/tables.js +130 -43
  238. package/kit/ui.js +79 -35
  239. package/package.json +2 -1
  240. package/packs/gallery/card/component.json +14 -0
  241. package/packs/gallery/card/example.html +10 -0
  242. package/packs/gallery/card/preview.svg +1 -0
  243. package/packs/gallery/card/style.css +6 -0
  244. package/packs/gallery/card/template.html +6 -0
  245. package/packs/gallery/card/writing.md +14 -0
  246. package/packs/gallery/chart-card/component.json +15 -0
  247. package/packs/gallery/chart-card/example.html +14 -0
  248. package/packs/gallery/chart-card/kit.js +130 -0
  249. package/packs/gallery/chart-card/preview.svg +1 -0
  250. package/packs/gallery/chart-card/style.css +42 -0
  251. package/packs/gallery/chart-card/template.html +13 -0
  252. package/packs/gallery/chart-card/writing.md +20 -0
  253. package/packs/gallery/chart-view/component.json +20 -0
  254. package/packs/gallery/chart-view/example.html +13 -0
  255. package/packs/gallery/chart-view/kit.js +355 -0
  256. package/packs/gallery/chart-view/preview.svg +1 -0
  257. package/packs/gallery/chart-view/style.css +94 -0
  258. package/packs/gallery/chart-view/template.html +3 -0
  259. package/packs/gallery/chart-view/writing.md +22 -0
  260. package/packs/gallery/countdown/component.json +18 -0
  261. package/packs/gallery/countdown/example.html +3 -0
  262. package/packs/gallery/countdown/kit.js +216 -0
  263. package/packs/gallery/countdown/preview.svg +1 -0
  264. package/packs/gallery/countdown/style.css +118 -0
  265. package/packs/gallery/countdown/template.html +3 -0
  266. package/packs/gallery/countdown/writing.md +22 -0
  267. package/packs/gallery/habit/component.json +14 -0
  268. package/packs/gallery/habit/example.html +3 -0
  269. package/packs/gallery/habit/kit.js +334 -0
  270. package/packs/gallery/habit/preview.svg +1 -0
  271. package/packs/gallery/habit/style.css +174 -0
  272. package/packs/gallery/habit/template.html +3 -0
  273. package/packs/gallery/habit/writing.md +21 -0
  274. package/packs/gallery/heatmap/component.json +18 -0
  275. package/packs/gallery/heatmap/example.html +3 -0
  276. package/packs/gallery/heatmap/kit.js +513 -0
  277. package/packs/gallery/heatmap/preview.svg +1 -0
  278. package/packs/gallery/heatmap/style.css +189 -0
  279. package/packs/gallery/heatmap/template.html +3 -0
  280. package/packs/gallery/heatmap/writing.md +21 -0
  281. package/packs/gallery/kanban/component.json +18 -0
  282. package/packs/gallery/kanban/example.html +12 -0
  283. package/packs/gallery/kanban/kit.js +540 -0
  284. package/packs/gallery/kanban/preview.svg +1 -0
  285. package/packs/gallery/kanban/style.css +212 -0
  286. package/packs/gallery/kanban/template.html +3 -0
  287. package/packs/gallery/kanban/writing.md +20 -0
  288. package/packs/gallery/metric/component.json +22 -0
  289. package/packs/gallery/metric/example.html +15 -0
  290. package/packs/gallery/metric/kit.js +248 -0
  291. package/packs/gallery/metric/preview.svg +1 -0
  292. package/packs/gallery/metric/style.css +92 -0
  293. package/packs/gallery/metric/template.html +3 -0
  294. package/packs/gallery/metric/writing.md +23 -0
  295. package/packs/gallery/note/component.json +14 -0
  296. package/packs/gallery/note/example.html +3 -0
  297. package/packs/gallery/note/kit.js +129 -0
  298. package/packs/gallery/note/preview.svg +1 -0
  299. package/packs/gallery/note/style.css +97 -0
  300. package/packs/gallery/note/template.html +3 -0
  301. package/packs/gallery/note/writing.md +18 -0
  302. package/packs/gallery/pack.json +8 -0
  303. package/packs/gallery/recent/component.json +13 -0
  304. package/packs/gallery/recent/example.html +1 -0
  305. package/packs/gallery/recent/kit.js +293 -0
  306. package/packs/gallery/recent/preview.svg +1 -0
  307. package/packs/gallery/recent/style.css +85 -0
  308. package/packs/gallery/recent/template.html +1 -0
  309. package/packs/gallery/recent/writing.md +15 -0
  310. package/packs/gallery/static/component.json +13 -0
  311. package/packs/gallery/static/example.html +11 -0
  312. package/packs/gallery/static/preview.svg +1 -0
  313. package/packs/gallery/static/style.css +171 -0
  314. package/packs/gallery/static/template.html +1 -0
  315. package/packs/gallery/static/writing.md +18 -0
  316. package/packs/gallery/stats/component.json +13 -0
  317. package/packs/gallery/stats/example.html +1 -0
  318. package/packs/gallery/stats/kit.js +347 -0
  319. package/packs/gallery/stats/preview.svg +1 -0
  320. package/packs/gallery/stats/style.css +73 -0
  321. package/packs/gallery/stats/template.html +1 -0
  322. package/packs/gallery/stats/writing.md +11 -0
  323. package/packs/gallery/today/component.json +12 -0
  324. package/packs/gallery/today/example.html +1 -0
  325. package/packs/gallery/today/kit.js +220 -0
  326. package/packs/gallery/today/preview.svg +1 -0
  327. package/packs/gallery/today/style.css +149 -0
  328. package/packs/gallery/today/template.html +1 -0
  329. package/packs/gallery/today/writing.md +14 -0
  330. package/packs/gallery/todos/component.json +19 -0
  331. package/packs/gallery/todos/example.html +3 -0
  332. package/packs/gallery/todos/kit.js +489 -0
  333. package/packs/gallery/todos/preview.svg +1 -0
  334. package/packs/gallery/todos/style.css +214 -0
  335. package/packs/gallery/todos/template.html +3 -0
  336. package/packs/gallery/todos/writing.md +30 -0
  337. package/packs/gallery/weather/component.json +19 -0
  338. package/packs/gallery/weather/example.html +3 -0
  339. package/packs/gallery/weather/kit.js +387 -0
  340. package/packs/gallery/weather/preview.svg +1 -0
  341. package/packs/gallery/weather/style.css +140 -0
  342. package/packs/gallery/weather/template.html +3 -0
  343. package/packs/gallery/weather/writing.md +26 -0
  344. package/packs/gallery-soft/countdown/component.json +18 -0
  345. package/packs/gallery-soft/countdown/example.html +3 -0
  346. package/packs/gallery-soft/countdown/kit.js +206 -0
  347. package/packs/gallery-soft/countdown/preview.svg +1 -0
  348. package/packs/gallery-soft/countdown/style.css +211 -0
  349. package/packs/gallery-soft/countdown/template.html +3 -0
  350. package/packs/gallery-soft/countdown/writing.md +24 -0
  351. package/packs/gallery-soft/habit/component.json +14 -0
  352. package/packs/gallery-soft/habit/example.html +3 -0
  353. package/packs/gallery-soft/habit/kit.js +366 -0
  354. package/packs/gallery-soft/habit/preview.svg +1 -0
  355. package/packs/gallery-soft/habit/style.css +251 -0
  356. package/packs/gallery-soft/habit/template.html +3 -0
  357. package/packs/gallery-soft/habit/writing.md +23 -0
  358. package/packs/gallery-soft/heatmap/component.json +18 -0
  359. package/packs/gallery-soft/heatmap/example.html +3 -0
  360. package/packs/gallery-soft/heatmap/kit.js +498 -0
  361. package/packs/gallery-soft/heatmap/preview.svg +1 -0
  362. package/packs/gallery-soft/heatmap/style.css +181 -0
  363. package/packs/gallery-soft/heatmap/template.html +3 -0
  364. package/packs/gallery-soft/heatmap/writing.md +23 -0
  365. package/packs/gallery-soft/note/component.json +14 -0
  366. package/packs/gallery-soft/note/example.html +3 -0
  367. package/packs/gallery-soft/note/kit.js +162 -0
  368. package/packs/gallery-soft/note/preview.svg +1 -0
  369. package/packs/gallery-soft/note/style.css +148 -0
  370. package/packs/gallery-soft/note/template.html +3 -0
  371. package/packs/gallery-soft/note/writing.md +20 -0
  372. package/packs/gallery-soft/pack.json +8 -0
  373. package/packs/gallery-soft/recent/component.json +13 -0
  374. package/packs/gallery-soft/recent/example.html +1 -0
  375. package/packs/gallery-soft/recent/kit.js +335 -0
  376. package/packs/gallery-soft/recent/preview.svg +1 -0
  377. package/packs/gallery-soft/recent/style.css +160 -0
  378. package/packs/gallery-soft/recent/template.html +1 -0
  379. package/packs/gallery-soft/recent/writing.md +17 -0
  380. package/packs/gallery-soft/static/component.json +13 -0
  381. package/packs/gallery-soft/static/example.html +12 -0
  382. package/packs/gallery-soft/static/preview.svg +1 -0
  383. package/packs/gallery-soft/static/style.css +186 -0
  384. package/packs/gallery-soft/static/template.html +1 -0
  385. package/packs/gallery-soft/static/writing.md +20 -0
  386. package/packs/gallery-soft/stats/component.json +13 -0
  387. package/packs/gallery-soft/stats/example.html +1 -0
  388. package/packs/gallery-soft/stats/kit.js +341 -0
  389. package/packs/gallery-soft/stats/preview.svg +1 -0
  390. package/packs/gallery-soft/stats/style.css +119 -0
  391. package/packs/gallery-soft/stats/template.html +1 -0
  392. package/packs/gallery-soft/stats/writing.md +13 -0
  393. package/packs/gallery-soft/today/component.json +12 -0
  394. package/packs/gallery-soft/today/example.html +1 -0
  395. package/packs/gallery-soft/today/kit.js +222 -0
  396. package/packs/gallery-soft/today/preview.svg +1 -0
  397. package/packs/gallery-soft/today/style.css +178 -0
  398. package/packs/gallery-soft/today/template.html +1 -0
  399. package/packs/gallery-soft/today/writing.md +16 -0
  400. package/packs/gallery-soft/todos/component.json +19 -0
  401. package/packs/gallery-soft/todos/example.html +3 -0
  402. package/packs/gallery-soft/todos/kit.js +527 -0
  403. package/packs/gallery-soft/todos/preview.svg +1 -0
  404. package/packs/gallery-soft/todos/style.css +212 -0
  405. package/packs/gallery-soft/todos/template.html +3 -0
  406. package/packs/gallery-soft/todos/writing.md +32 -0
  407. package/packs/gallery-soft/weather/component.json +19 -0
  408. package/packs/gallery-soft/weather/example.html +3 -0
  409. package/packs/gallery-soft/weather/kit.js +411 -0
  410. package/packs/gallery-soft/weather/preview.svg +1 -0
  411. package/packs/gallery-soft/weather/style.css +185 -0
  412. package/packs/gallery-soft/weather/template.html +3 -0
  413. package/packs/gallery-soft/weather/writing.md +28 -0
  414. package/release.json +12 -10
  415. package/sdk/doc-kit.d.ts +396 -5
  416. package/sdk/doc-state.d.ts +2 -0
  417. package/skill/SKILL.md +56 -23
  418. package/skill/references/block-script.md +140 -0
  419. package/skill/references/building-blocks.md +257 -0
  420. package/skill/references/extensions.md +59 -0
  421. package/skill/references/pages-and-data.md +225 -0
  422. package/skill/references/writing-html.md +8 -4
  423. package/skill/sdk/doc-kit.d.ts +396 -5
  424. package/skill/sdk/doc-state.d.ts +2 -0
  425. package/web/assets/index-BM_K-Auu.css +1 -0
  426. package/web/assets/index-DRslOBiv.js +15 -0
  427. package/web/index.html +2 -2
  428. package/dist/chunk-3HIRPVLU.mjs +0 -2
  429. package/dist/chunk-5MHMDLZD.mjs +0 -4
  430. package/dist/chunk-64K7IPLO.mjs +0 -255
  431. package/dist/chunk-6QXGZM36.mjs +0 -8
  432. package/dist/chunk-6RGJOMJP.mjs +0 -16
  433. package/dist/chunk-AJ73XJF3.mjs +0 -2
  434. package/dist/chunk-AUZGSZJH.mjs +0 -13
  435. package/dist/chunk-BFE45AKL.mjs +0 -2
  436. package/dist/chunk-BXO2ZY5P.mjs +0 -2
  437. package/dist/chunk-CEH4MRCC.mjs +0 -2
  438. package/dist/chunk-CY2FNNAB.mjs +0 -16
  439. package/dist/chunk-DFUDV4LX.mjs +0 -2
  440. package/dist/chunk-DKXG4XDG.mjs +0 -2
  441. package/dist/chunk-EZQ34M3F.mjs +0 -124
  442. package/dist/chunk-EZY3WC6Z.mjs +0 -15
  443. package/dist/chunk-FUKQNOQS.mjs +0 -9
  444. package/dist/chunk-JPOSLGOC.mjs +0 -6
  445. package/dist/chunk-JVHHHGEA.mjs +0 -3
  446. package/dist/chunk-L3QKH4OK.mjs +0 -26
  447. package/dist/chunk-LAE5NQ4B.mjs +0 -2
  448. package/dist/chunk-LEF6DRCK.mjs +0 -59
  449. package/dist/chunk-NO5NJCHO.mjs +0 -2
  450. package/dist/chunk-NQPVAU63.mjs +0 -2
  451. package/dist/chunk-NSKUTQ5J.mjs +0 -5
  452. package/dist/chunk-O35FIXRB.mjs +0 -2
  453. package/dist/chunk-P2CAZPDP.mjs +0 -3
  454. package/dist/chunk-PL6GHLGD.mjs +0 -15
  455. package/dist/chunk-QJIR2BLP.mjs +0 -6
  456. package/dist/chunk-QUPLVPB2.mjs +0 -7
  457. package/dist/chunk-R7BNENLY.mjs +0 -4
  458. package/dist/chunk-S6O4UHLC.mjs +0 -2
  459. package/dist/chunk-SGJWQKEI.mjs +0 -2
  460. package/dist/chunk-TX6JH7TR.mjs +0 -2
  461. package/dist/chunk-TYK6VNAB.mjs +0 -10
  462. package/dist/chunk-UALRNVSE.mjs +0 -4
  463. package/dist/chunk-V3HXVQEM.mjs +0 -2
  464. package/dist/chunk-V5VXUJKG.mjs +0 -2
  465. package/dist/chunk-VBXMADMP.mjs +0 -2
  466. package/dist/chunk-VNV55RUA.mjs +0 -2
  467. package/dist/chunk-VPD2PS35.mjs +0 -2
  468. package/dist/chunk-W4VKN3GF.mjs +0 -7
  469. package/dist/chunk-W5BXXPDJ.mjs +0 -3
  470. package/dist/chunk-XUNHRCOG.mjs +0 -6
  471. package/skill/references/building-components.md +0 -367
  472. package/web/assets/index-Bh74DfsV.css +0 -1
  473. package/web/assets/index-UW0RyFFt.js +0 -13
@@ -1,13 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as ge,b as X,c as Q,f as $e,g as z,h as we,i as be,l as ke,m as ye}from"./chunk-BGGDRNYQ.mjs";import{b as re,c as mt,e as K,f as ce,i as le,j as de,m as fe,n as he,o as ue,p as pe,q as me,r as gt}from"./chunk-6QXGZM36.mjs";import{a as ut}from"./chunk-UALRNVSE.mjs";import{a as Vt,b as Yt,c as qt,d as Xt,e as Qt,f as te,g as ee,h as oe,l as ne}from"./chunk-W3BGBJQW.mjs";import{b as pt,c as Kt,d as Gt,e as Jt,g as Zt}from"./chunk-JVHHHGEA.mjs";import{a as $,b as Wt,c as Ht}from"./chunk-HYMEEXKN.mjs";import{d as L,g as se,i as ie,j as ae}from"./chunk-W4VKN3GF.mjs";import{existsSync as mo,readFileSync as ai,readdirSync as ri}from"node:fs";import x from"node:fs/promises";import S from"node:path";function Ne(t){if(!t||!Array.isArray(t.lines))throw new Error("diff: lines must be an array.");t.lines.forEach(e=>{if(!e||!["added","removed","unchanged"].includes(e.type)||typeof e.content!="string"||/[\r\n]/.test(e.content))throw new Error("diff: each line needs a valid type and single-line content.");if(e.lineNumber!=null&&(!Number.isInteger(e.lineNumber)||e.lineNumber<1))throw new Error("diff: lineNumber must be a positive integer.")})}import{BODY as xe}from"../browser/shared/components/index.mjs";import{attr as I,elementsOf as G,hasClass as Ro,walk as Se}from"../browser/shared/html-tree.mjs";import{CHART_DATA as Do,CHART_SOURCE as tt,cellWords as ve,rowsReading as Oe,tableRows as _o}from"../browser/shared/table-chart.mjs";var Mo=t=>t.tagName==="script"&&(I(t,"type")??"").trim().toLowerCase()==="application/json",$t=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map($t).join("");function Po(t){let e=t;for(;e&&e.tagName!=="figure";)e=e.parentNode;let n=e?G(e).find(o=>/^h[2-4]$/.test(o.tagName)):null;return n?ve($t(n)):""}function Ee(t,e,n=$(t)){let o=[];return Se(n,s=>{let i=e(s);if(i===void 0||!s.sourceCodeLocation)return;let c=s.childNodes.find(Mo);o.push({type:i,line:s.sourceCodeLocation.startLine,text:c?c.childNodes.map(a=>a.value??"").join(""):null,source:I(s,Do),tag:s.tagName,holder:s.parentNode?.tagName,title:Po(s)})},xe),o}var Uo=t=>t.tagName==="ol"&&I(t,"data-doc-chart")==="flow",et=(t,e)=>Ee(t,n=>Uo(n)?void 0:I(n,"data-doc-chart"),e),Bo=t=>Ee(t,e=>Ro(e,"doc-diff")?"diff":void 0),C=t=>G(t).filter(e=>e.tagName==="td"||e.tagName==="th"),Wo=t=>["rowspan","colspan"].some(e=>{let n=Number.parseInt(I(t,e)??"1",10);return Number.isFinite(n)&&n!==1});function Ho(t){let e=G(t),n=a=>G(a).filter(l=>l.tagName==="tr"),o=e.find(a=>a.tagName==="thead"),s=o?n(o)[0]??null:null,i=e.filter(a=>a.tagName==="tbody").flatMap(n);!s&&i.length>0&&C(i[0]).length>0&&C(i[0]).every(a=>a.tagName==="th")&&([s,...i]=i);let c=a=>ve($t(a));return{names:s?C(s).map(c):null,types:s?C(s).map(a=>I(a,"data-sort-type")??null):null,rows:i.map(a=>C(a).map(l=>({words:c(l),sort:I(l,"data-sort-value")?.trim()??null}))),foot:e.filter(a=>a.tagName==="tfoot").flatMap(n).map(a=>C(a)[0]?c(C(a)[0]):""),merged:[s,...i].some(a=>a&&C(a).some(Wo))}}function wt(t){let e=new Map;return Se(t,n=>{let o=I(n,tt);if(o===void 0||!n.sourceCodeLocation)return;(e.get(o)??e.set(o,[]).get(o)).push({line:n.sourceCodeLocation.startLine,table:G(n).find(i=>i.tagName==="table")??null})},{...xe,inTemplates:!1}),e}function bt(t,e){let n=e.get(t)??[];if(n.length===0)return{error:`no table's frame carries ${tt}="${t}", so the chart has nothing to draw: put the table back, or delete the card`};if(n.length>1)return{error:`${n.length} tables carry ${tt}="${t}" (lines ${n.map(({line:a})=>a).join(", ")}): a key names one table (the chart draws the first); take it off the copies`};let[{line:o,table:s}]=n;if(!s)return{error:`the frame carrying ${tt}="${t}" (line ${o}) holds no table`};let i=Ho(s),c=_o(i);return c.error?{error:`its table (line ${o}) ${c.error}`}:{...c,line:o,cells:i}}function kt(t){let e=new Set([...t.matchAll(/DocCharts\.define\(\s*(["'`])([a-z][a-z0-9-]*)\1/g)].map(o=>o[2])),n=new Set([...t.matchAll(/DocCharts\.define\(\s*(["'`])([^"'`\n]*)\1/g)].map(o=>o[2]).filter(o=>!e.has(o)));return{defined:e,misnamed:n}}function yt(t){let e=$(t),n=[],{defined:o,misnamed:s}=kt(t),i=null;for(let{type:c,line:a,text:l,source:r,tag:d,holder:f}of et(t,e)){let h=`data-doc-chart="${c}" (line ${a})`;if(d==="table"){n.push(f==="figure"?`${h} is on a table inside a <figure>: the chart's card is a figure of its own, so write the table outside it, its <caption> the chart's title`:`${h} is on a table the tools leave as written (inside a whole block, an element with a class of the document's own, a cell): a chart is drawn from a table outside one`);continue}if(s.has(c)){n.push(`${h}: the document's script defines "${c}" with DocCharts.define, which refuses that name: a chart type's name is lowercase letters, digits and hyphens, a letter first ("interval", "ci-plot"); rename it in both places`);continue}if(!o.has(c)){n.push(`${h}: the document's script does not define "${c}": define it once in the document's <script> with DocCharts.define("${c}", ({ host, data, tokens, width, height }) => { \u2026 }) (references/writing-html.md, "Figures and charts")`);continue}if(r!==void 0){if(l!==null){n.push(`${h}: a chart drawn from a table takes its data from the table: take its <script type="application/json"> out`);continue}let u=bt(r,i??=wt(e));u.error&&n.push(`${h}: ${u.error}`);continue}if(l===null){n.push(`${h} needs its data in a <script type="application/json"> child`);continue}try{JSON.parse(l)}catch(u){n.push(`${h}: its data is not valid JSON (${u.message})`)}}for(let{line:c,text:a}of Bo(t)){if(a===null)continue;let l=`.doc-diff (line ${c})`;try{Ne(JSON.parse(a))}catch(r){n.push(`${l}: ${r instanceof SyntaxError?`its options are not valid JSON (${r.message})`:r.message}`)}}return n}function Te(t,{written:e=t}={}){let n=$(t),o=[],{defined:s}=kt(t),i=null,c=null;for(let{type:a,line:l,text:r,source:d,title:f,tag:h}of et(t,n)){if(d===void 0||h==="table"||r!==null||!s.has(a))continue;let u=`data-doc-chart="${a}" (line ${l})`;if(!f){c??=new Set(e===t?[]:et(e).map(w=>w.source).filter(w=>w!==void 0));let k=e!==t&&!c.has(d);o.push(`${u}: this chart card has no title: ${k?"write a <caption> on its table (the one with data-doc-chart), which becomes the card's h3":"write an h3 in the card's figure, before the chart"}`)}let p=bt(d,i??=wt(n));if(p.error)continue;let{blank:m,twice:b}=Oe(p.cells,p.data);m&&o.push(`${u}: its table's header (line ${p.line}) has a cell with no words, so that column's values are keyed "" in data: write the column's name there`),b.length>0&&o.push(`${u}: its table's header (line ${p.line}) names ${b.map(k=>`"${k}"`).join(", ")} twice, so data keeps the later column's value under it: give each column a name of its own`)}return o}function Le(t){let e=$(t),n=[],o=[],{defined:s}=kt(t),i=null,c=(a,l)=>`${a} ${l}${a===1?"":"s"}`;for(let{type:a,line:l,text:r,source:d,tag:f}of et(t,e)){if(d===void 0||f==="table"||r!==null||!s.has(a))continue;let h=bt(d,i??=wt(e));if(h.error)continue;let{rows:u,columns:p,foot:m,extra:b}=Oe(h.cells,h.data),k=`data-doc-chart="${a}" (line ${l})`,w=[c(u,"row")];for(let{name:N,numbers:v,words:E,empty:H}of p){let j=v+E+H,q=v===j&&j>0?"numbers":E===j&&j>0?"words":[v&&c(v,"number"),E&&`${E} as words`,H&&`${H} empty (null)`].filter(Boolean).join(", ")||"no rows";w.push(`"${N}": ${q}`),v>0&&E>0&&o.push(`${k}: its table's column "${N}" (line ${h.line}) reads as numbers in ${c(v,"row")} and as words in ${E}: write each of its cells as one number (an empty cell, "\u2014" or "n/a" for none: null in data), or, for a column of words, data-sort-type="text" on its header cell`)}m>0&&o.push(`${k}: its table's <tfoot> (line ${h.line}) holds ${c(m,"row")} the chart leaves out, and a table with a <tfoot> has no table tools in the preview: keep a total out of a table you chart and say it in the text`),b>0&&o.push(`${k}: ${c(b,"row")} of its table (line ${h.line}) ${b===1?"has":"have"} cells past the header, which the chart does not read: give each column a header cell`),n.push(`${a} (line ${l}) reads its table (line ${h.line}): ${w.join("; ")}`)}return{readings:n,notes:o}}import{BODY as ci,componentOf as li,matchesNode as go}from"../browser/shared/components/index.mjs";import{FLOW as di}from"../browser/shared/components/list.mjs";import{attr as O,elementsOf as $o,walk as _}from"../browser/shared/html-tree.mjs";import{GLYPH_SETS as fi,ICON_COLORS as wo,glyphOf as hi,glyphValue as ui,iconKind as Dt,iconMarkup as pi,iconValueOf as mi}from"../browser/shared/emoji/icon-value.mjs";import Ko from"node:vm";import{LINE_START as st,lineStart as Go}from"../browser/shared/code-lines.mjs";import{BODY as Re,COMPONENTS as Jo,FLOWS as Zo,instanceSlots as Vo,instancesOf as Yo,isInstance as R,isSlot as De,matchesNode as P,ownSlots as qo,partOf as vt,vocabulary as Xo}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as T,INSTANCE as Qo,PACKAGE_ID as it,SCHEMA as Nt,SLOT as A,schemaAhead as tn}from"../browser/shared/components/installed.mjs";import{packageScript as en}from"../browser/shared/export-wrap.mjs";import{asDocName as on,kitNamespace as nn}from"../browser/shared/old-names.mjs";import{shortSheets as sn}from"../browser/shared/components/sheets.mjs";import{attr as y,curlyQuoted as an,hasClass as rn,walk as J}from"../browser/shared/html-tree.mjs";var{authoring:nt,runtime:Ae}=Xo(),cn="input, select, textarea, button, details, table",at=t=>t.sourceCodeLocation?.startLine,g=t=>at(t)?` (line ${at(t)})`:"";function ze(t){let e=(o,s)=>{let i=Array.from({length:s.length+1},(c,a)=>a);for(let c=1;c<=o.length;c++){let a=i[0];i[0]=c;for(let l=1;l<=s.length;l++){let r=i[l];i[l]=Math.min(i[l]+1,i[l-1]+1,a+(o[c-1]===s[l-1]?0:1)),a=r}}return i[s.length]},[n]=[...nt.keys()].filter(o=>o.startsWith(t.slice(0,7))).map(o=>[o,e(t,o)]).sort((o,s)=>o[1]-s[1]);return n&&n[1]<=3?` (${n[0]}?)`:""}function ln(t,e,n){let{part:o,property:s,min:i}=t.shares,c=new RegExp(`(?:^|;)\\s*${s}\\s*:\\s*([^;]*)`),a=n.map(f=>c.exec(y(f,"style")??"")?.[1].trim()??null),l=a.filter(f=>f!==null);if(l.length===0)return[];let r=`${t.id}${g(e)}`;return l.length<a.length?[`${r}: ${s} on ${l.length} of its ${a.length} ${o}: write it on every one of them, or on none (equal widths)`]:l.map(Number).some(f=>!Number.isFinite(f)||f<i-1e-9||f>1)?[`${r}: ${s} is a share of the row, a number from ${Math.round(i*1e3)/1e3} to 1 (${l.join(", ")})`]:[]}var ot={"doc-dialog-header":'a detail card has no header: its content region (<div class="doc-dialog-content">) stands alone in its panel',"doc-dialog-title":"a detail card's title is an ordinary heading (<h3>), first in its content region","doc-dialog-close":"a detail card has no close button: Esc and a press outside it close it","data-doc-dialog-close":"a detail card has no close button: Esc and a press outside it close it","doc-section-header":"a section's title is a plain heading (<h2>) with an ordinary paragraph below it for the line that says what the section is: no <div> goes around them","doc-grid":'a card row is now columns: <div class="doc-columns"> holding one <div class="doc-column"> per card',"doc-grid-3":'a card row is now columns: <div class="doc-columns"> holding three <div class="doc-column">',"doc-lede":`write the line under the title as a paragraph of the header (an ordinary <p>), or as small text, <p class="doc-note"): the header's lines read as the body's paragraphs`,"doc-source":`write the line under the title as a plain paragraph of the header (an ordinary <p>), or as small text (<p class="doc-note">): the header's lines read as the body's paragraphs`,"doc-prose":"write the text straight in its flow (the page, a Sheet panel, a section, a panel, a column\u2026): it reads the same there","doc-prose-h1":"write an h1","doc-prose-h2":"write an h2","doc-prose-h3":"write an h3","doc-prose-h4":"write an h4","doc-state-grid":'put the groups side by side in columns (<div class="doc-columns">)',"doc-state-group":"write the group's title as a heading and its controls as blocks of their own in a column","doc-state-status":'write the line as small text, <p class="doc-note">',"doc-code-block":'a code block is <div class="doc-code"> holding its title (<div class="doc-code-title">) and the <pre><code>',"doc-code-card":'a code block is <div class="doc-code"> holding its title and its <pre>; a diff is <div class="doc-diff">',"doc-code-header":'write the title as <div class="doc-code-title">: the kit draws the rest of the header',"data-doc-diff":'a diff is <div class="doc-diff"> holding its title and its options as JSON (sdk/doc-code.d.ts)',"data-doc-diff-stats":"the kit shows a diff's counts in its header: remove it","doc-code--wrap":"a code block wraps its long lines by itself: remove it (doc-code--nowrap scrolls them instead)"},dn={[st]:'write it on its <div class="doc-code">',"data-start":`write ${st} on its <div class="doc-code">`,"data-line-numbers":'write it on its <div class="doc-code">',"data-folded-lines":'write it on its <div class="doc-code">',"data-title":'write the title in its <div class="doc-code-title">',"data-wrap":'for long lines that scroll, write class="doc-code doc-code--nowrap" on its <div class="doc-code">'};function fn(t){let e=[],n=t.tagName==="pre"?t.parentNode:t.tagName==="code"&&t.parentNode?.tagName==="pre"?t.parentNode.parentNode:null;if(n?.tagName&&P(n,".doc-code"))for(let[s,i]of Object.entries(dn))y(t,s)!==void 0&&e.push(`${s}${g(t)} on the <${t.tagName}> of a code block does nothing: ${i}`);let o=t.tagName==="div"&&P(t,".doc-code")?y(t,st):void 0;return o!==void 0&&Go(o)===null&&e.push(`${st}="${o}"${g(t)}: the number of a code block's first line is a whole number from 1`),e}var Ce=Zo.join(", "),hn=t=>P(t.parentNode,Ce)||t.parentNode?.tagName==="div"&&!y(t.parentNode,"class")&&P(t.parentNode.parentNode,Ce);function un(t,e){let n=[];J(e,s=>n.push(...an(t,s)));let o=s=>s.replace(/=(\s*)[“”]/,'=$1"').replace(/[“”]$/,'"');return n.map(({written:s,line:i},c)=>c===0?`line ${i}: attribute ${s} uses curly quotes (U+201C/U+201D), which HTML reads as part of the value: write straight quotes, ${o(s)}; an editor keeping a file's \u201C\u2026\u201D style may change them`:`line ${i}: attribute ${s} uses curly quotes too: write ${o(s)}`)}var Ie={details:"write a plain <details> without the class (its <summary>, then what it holds): the export makes it the kit's"},pn="write a <section> of no attribute straight in it for each tab, starting with its heading (<h2>\u2013<h4>), the tab's name, the rest its blocks, and nothing else: the export makes the kit's tabs",mn='a bookmark written the short way is a paragraph in a flow holding only <a class="doc-bookmark" href="https://\u2026">its title</a> (a title attribute its description, nothing else on it, words alone in it): the export makes the card';function _e(t){let e=[];return J(t,n=>{y(n,T)!==void 0&&e.push(n)},Re),e}var gn=t=>{let e=t.parentNode;for(;e&&!(R(e)||De(e));)e=e.parentNode;return e??null};function $n(t,e){let n=[];return J(t,o=>{let s=y(o,A);if(s===void 0)return;if(R(o))return void n.push(`${A}="${s}"${g(o)} on the instance itself: a slot is an element inside it`);if(!De(o))return void n.push(`${A}${g(o)} on a <${o.tagName}>: a slot is a block-level <div> or <section>`);let i=gn(o),c=i&&R(i)?e?.get(y(i,T)):null;if(!i||!R(i)||c&&Me(i,c,o))return void n.push(`${A}="${s}"${g(o)} stands outside any instance's own markup: a slot is a part of a component package's instance, written in its template`);y(o,"data-block-id")!==void 0&&n.push(`${A}="${s}"${g(o)}: a slot is no block: it carries no data-block-id`)}),n}var wn=(t,e)=>{for(let n=e.parentNode;n;n=n.parentNode)if(n===t)return!0;return!1},Me=(t,e,n)=>Object.values(e.parts??{}).filter(({edit:o})=>o==="text"||o==="data").some(({at:o})=>vt(t,o).some(s=>wn(s,n))),Fe=(t,e)=>qo(t).filter(n=>!Me(t,e,n)),bn=t=>t.flatMap(e=>R(e)?it.test(y(e,T))?[]:[`${T}="${y(e,T)}"${g(e)} names no package: write <scope>/<name>, a package of the workspace's components/ folder`]:[`${T}${g(e)} on a <${e.tagName}>: an instance of a component is a block-level <div> or <section>`]);function Pe(t){let e=_e(t).filter(o=>R(o)&&it.test(y(o,T))),n=e.length>0?L():null;return e.flatMap(o=>{let s=y(o,T),i=n.packages.get(s);if(i&&!tn(y(o,Nt),i.schema))return[];if(i)return[`line ${at(o)}: <${o.tagName} ${T}="${s}">: ${Nt}="${y(o,Nt)}" is past the ${i.schema??1} its package's manifest reads (schema): nothing can write it back, and the block shows read-only until the package reads it`];let c=n.problems.get(s)?.problem,a=c?`package ${s} does not load (${se("en",c)})`:`no package ${s} in this workspace (components/${s}/component.json)`;return[`line ${at(o)}: <${o.tagName} ${T}="${s}">: ${a}: the block shows what it holds, read-only, and moves, copies and deletes whole`]})}function xt(t,e){let n=[];for(let{name:o,value:s}of t.attrs){if(ot[o]&&!nt.has(o)){n.push(`${o}${g(t)} is gone: ${ot[o]}`);continue}if(o.startsWith("data-doc-")&&!nt.has(o)&&n.push(Ae.has(o)?`${o}${g(t)} is the kit's to set: remove it`:`${o}${g(t)} is no attribute of the kit's${ze(o)}`),o==="class"){for(let i of s.split(/\s+/).filter(e))if(!nt.has(i)){if(ot[i]){n.push(`class ${i}${g(t)} is gone: ${ot[i]}`);continue}n.push(Ae.has(i)?`class ${i}${g(t)} is the kit's to set: remove it`:`class ${i}${g(t)} is no class of the kit's${ze(on(i))}: give a class of the document's own a name of its own (not doc-\u2026)`)}}}return n}var je=t=>t.startsWith("doc-");function kn(t){try{return new Ko.Script(en(t),{filename:"kit.js"}),null}catch(e){let n=/^kit\.js:(\d+)/.exec(e.stack??"")?.[1];return{message:e.message,line:n?Number(n):null}}}var St=new Map;function yn(t){if(!t.files.includes("kit.js"))return null;if(St.get(t.folder)?.stamp!==t.stamp){let e=be(t,"kit.js"),n=e===null?null:kn(e),o=e===null?`${t.id}: its kit.js cannot be read`:n&&`${t.id}: its kit.js does not run: ${n.message}${n.line?` (line ${n.line})`:""}`;St.set(t.folder,{stamp:t.stamp,failure:o})}return St.get(t.folder).failure}function Ot(t,e=$(t),n=null){let o=un(t,e),s=_e(e);o.push(...bn(s));let i=s.length>0?n??L():null,c=i?[...i.packages.values()]:[];i&&o.push(...z(t,i,e).map(yn).filter(Boolean));for(let r of[...Jo,...c].filter(d=>d.match&&(d.parts||d.pairs)))for(let d of Yo(e,r)){if(r.empty&&!(d.childNodes??[]).some(u=>u.tagName||u.nodeName==="#text"&&u.value.trim()))continue;let f=r.id==="sheets"?sn(d):null;if(f){o.push(`${r.id}${g(d)} has no tabs and is no short form: ${f.why??"it stands where no block does (in a whole block or a figure)"}; ${pn}`);continue}if(Ie[r.id]&&Object.values(r.parts??{}).some(u=>vt(d,u.at).length<(u.optional?0:u.min??1))){o.push(`${r.id}${g(d)} carries the kit's class without the kit's parts: ${Ie[r.id]}`);continue}let h={};for(let[u,p]of Object.entries(r.parts??{})){if(p.edit==="flow"&&it.test(r.id)){let k=Fe(d,r).filter(w=>y(w,A)===u);k.length===0&&!p.optional&&o.push(`${r.id}${g(d)} has no ${u} (${A}="${u}")`);for(let w of k.slice(1))o.push(`${r.id}${g(w)}: slot "${u}" twice`);h[u]=k.slice(0,1);continue}h[u]=vt(d,p.at);let m=p.optional?0:p.min??1,b=p.max??1/0;h[u].length<m?o.push(`${r.id}${g(d)} has ${h[u].length===0?"no":`${h[u].length} of`} ${u} (${p.at.replace(":scope > ","")})${h[u].length>0?`, at least ${m}`:""}`):h[u].length>b&&o.push(`${r.id}${g(d)} has ${h[u].length} of ${u}, at most ${b}`)}if(r.only){let u=new Set(r.only.flatMap(p=>h[p]));for(let p of(d.childNodes??[]).filter(m=>m.tagName&&!u.has(m)))o.push(`${r.id}${g(d)} holds a <${p.tagName}>${g(p)}: only its ${r.only.join(", ")} (${r.only.map(m=>r.parts[m].at.replace(":scope > ","")).join(", ")}) go in it`)}if(r.shares&&o.push(...ln(r,d,h[r.shares.part])),it.test(r.id)){let u=Object.entries(r.parts??{}).filter(([,p])=>p.edit==="flow").map(([p])=>p);for(let p of Fe(d,r).filter(m=>!u.includes(y(m,A))))o.push(`${r.id}${g(p)}: slot "${y(p,A)}" is no part of its manifest edited as flow`)}for(let{a:u,attrA:p,b:m,attrB:b}of r.pairs??[]){let k=h[u].map(N=>y(N,p)),w=h[m].map(N=>y(N,b));for(let N of new Set(k.filter((v,E)=>k.indexOf(v)!==E)))o.push(`${r.id}${g(d)}: ${u} "${N}" twice`);for(let N of k.filter(v=>!w.includes(v)))o.push(`${r.id}${g(d)}: ${u.replace(/s$/,"")} "${N}" has no ${m.replace(/s$/,"")} (${b}="${N}")`);for(let N of w.filter(v=>!k.includes(v)))o.push(`${r.id}${g(d)}: ${m.replace(/s$/,"")} "${N}" has no ${u.replace(/s$/,"")} (${p}="${N}")`)}}o.push(...$n(e,i?.packages));let a=new Set,l=[];J(e,r=>{if(R(r)){let h=new Set(Vo(r));o.push(...xt(r,je)),J(r,u=>o.push(...xt(u,je)),{stop:u=>h.has(u)});return}r.tagName==="pre"&&hn(r)&&o.push(`<pre>${g(r)} straight in the text: a code block is <div class="doc-code"> holding its title (<div class="doc-code-title">) and the <pre>`),o.push(...fn(r)),r.tagName==="a"&&rn(r,"doc-bookmark")&&o.push(`<a class="doc-bookmark">${g(r)} is no bookmark: ${mn}`),o.push(...xt(r,nn));let d=y(r,"data-doc-bind");d!==void 0&&(d.trim()?P(r,cn)?r.tagName==="button"&&y(r,"value")===void 0?o.push(`data-doc-bind${g(r)} on a button without a value: give it the value a click chooses`):a.add(d.trim()):o.push(`data-doc-bind${g(r)} on a ${r.tagName}: only inputs, selects, textareas, buttons with a value, details and tables hold a key`):o.push(`data-doc-bind${g(r)} names no key`));let f=y(r,"data-doc-show");f!==void 0&&l.push([r,f])},Re);for(let[r,d]of l){let f=d.split(":")[0].trim();!f||!d.includes(":")?o.push(`data-doc-show="${d}"${g(r)}: write key:value`):a.has(f)||o.push(`data-doc-show="${d}"${g(r)}: nothing binds "${f}" (data-doc-bind="${f}")`)}return o.push(...En(t,e)),o}var Nn=/(?<![\\$])\$(?=[^\s$])([^$]*?[^\s$\\])\$(?![$\d])/g,xn=/(?:(?<![A-Za-z0-9_])[A-Za-z]|[)\]}])_[A-Za-z0-9{]/,Sn=t=>/[\\^]/.test(t)||!t.startsWith("{")&&xn.test(t),vn=new Set(["head","code","pre","kbd","samp","script","style","template","textarea","noscript","svg","math","title","iframe","object"]),On=`.doc-math-inline, .doc-math-block, .doc-code, .doc-diff, [data-doc-math-dollar], [data-doc-chart], ${Qo}`;function En(t,e){let n=[],o=s=>{for(let i of s.childNodes??[])if(i.nodeName==="#text"&&i.sourceCodeLocation&&i.value.includes("$")){let{startOffset:c,endOffset:a}=i.sourceCodeLocation;for(let l of t.slice(c,a).matchAll(Nn)){if(!Sn(l[1]))continue;let r=l[1].replace(/\s+/g," "),d=r.length>60?`${r.slice(0,59)}\u2026`:r;n.push(`line ${Ht(t,c+l.index)}: $${d}$ is not drawn as a formula (single dollars are off: they are money): write \\(${d}\\)`)}}else i.tagName&&!vn.has(i.tagName)&&!P(i,On)&&o(i)};return o(e),n}import Z from"node:fs";import B from"node:path";import{COLOR_NAMES as Dn}from"../browser/shared/colors.mjs";import{FOLD_DOTS as _n}from"../browser/shared/code-folds.mjs";import{kitPublicDirectory as Mn,kitSourceDirectory as Pn,release as Un}from"../browser/shared/paths.mjs";import{FLOW_LABEL as Na}from"../browser/shared/components/list.mjs";var Tn={"code-title":{zh:"\u4EE3\u7801\u5757",en:"Code"},"plain-text":{zh:"\u7EAF\u6587\u672C",en:"Plain text"},"fold-code":{zh:"\u6298\u53E0\u6216\u5C55\u5F00\u4EE3\u7801\u5757",en:"Collapse or expand the code block"},"copy-code":{zh:"\u590D\u5236\u4EE3\u7801",en:"Copy code"},copied:{zh:"\u5DF2\u590D\u5236",en:"Copied"},wrap:{zh:"\u81EA\u52A8\u6362\u884C",en:"Wrap lines"},"no-wrap":{zh:"\u53D6\u6D88\u81EA\u52A8\u6362\u884C",en:"Stop wrapping lines"},fold:{zh:"\u6298\u53E0",en:"Collapse"},unfold:{zh:"\u5C55\u5F00",en:"Expand"},line:{zh:"\u7B2C {0} \u884C",en:"Line {0}"},lines:{zh:"\u7B2C {0}\u2013{1} \u884C",en:"Lines {0}\u2013{1}"},"diff-counts":{zh:"\u65B0\u589E {0} \u884C\uFF0C\u5220\u9664 {1} \u884C",en:"Lines added: {0}, removed: {1}"}};var Ue="data-ge-language",Ln={"code-title":"--doc-word-code-title"};function An(t,e,n,...o){let s=t[n];if(!s)throw new Error(`The kit has no word "${n}" here (src/render/kit/words.js).`);let i=s[e]??s.zh;return o.length===0?i:i.replace(/\{(\d+)\}/g,(c,a)=>a<o.length?String(o[a]):c)}var zn=`:root[${Ue}="en"], :root:not([${Ue}])[lang|="en" i]`;function Be(){let t=e=>Object.entries(Ln).map(([n,o])=>`${o}: ${JSON.stringify(An(Tn,e,n))};`).join(" ");return`:root { ${t("zh")} }
3
- ${zn} { ${t("en")} }`}import{LOOK as Et,LOOK_ATTRIBUTES as Cn,SERIF_FONT as We,SIZE_FACTOR as In,SPACING as Fn,WIDTH as Tt}from"../browser/shared/document-look.mjs";var He=[["--doc-body-font-size","--doc-body-line-height"],["--doc-small-font-size","--doc-small-line-height"],["--doc-note-font-size","--doc-note-line-height"],["--doc-title-font-size","--doc-title-line-height"],["--doc-h1-font-size","--doc-h1-line-height"],["--doc-h2-font-size","--doc-h2-line-height"],["--doc-h3-font-size","--doc-h3-line-height"],["--doc-h4-font-size","--doc-h4-line-height"],["--doc-card-title-font-size","--doc-card-title-line-height"],["--doc-table-font-size","--doc-table-line-height"]],jn=["--doc-component-gap","--doc-block-gap","--doc-media-gap","--doc-paragraph-gap","--doc-group-gap","--doc-list-gap"],Lt="--doc-content-max-width";function Rn(t){let e=new Map;for(let[,n,o]of String(t).matchAll(/^\s*(--doc-[a-z0-9-]+):\s*([^;]+);/gm))e.has(n)||e.set(n,o.trim());return e}var rt=t=>`${Math.round(t)}px`;function ct(t,{size:e="default",spacing:n="default",width:o="default"}={}){let s=r=>{let d=/^(-?[0-9.]+)px$/.exec(t.get(r)??"");if(!d)throw new Error(`src/render/kit/styles/tokens.css: ${r} is no length in px (src/render/look-css.mjs reads it)`);return Number(d[1])},i=In[e],{leading:c,gaps:a}=Fn[n],l={};if(e!=="default"||n!=="default")for(let[r,d]of He){let f=s(r)*i;e!=="default"&&(l[r]=rt(f)),l[d]=rt(Math.round(f)+(s(d)-s(r))*i*c)}if(n!=="default"){for(let r of jn)l[r]=rt(s(r)*a);l["--doc-space"]=String(a)}if(o!=="default"){if(s(Lt)!==Tt.default)throw new Error(`src/render/kit/styles/tokens.css: ${Lt} is not \u9ED8\u8BA4 \u6B63\u6587\u5BBD\u5EA6's ${Tt.default}px (src/shared/document-look.mjs WIDTH)`);l[Lt]=rt(Tt[o])}return l}var U=(t,e)=>`${t} { ${Object.entries(e).map(([n,o])=>`${n}: ${o};`).join(" ")} }`,D=(t,e)=>`[${Cn[t]}="${e}"]`;function Ke(t){let e=Rn(t),n=e.get("--doc-font");if(!n)throw new Error("src/render/kit/styles/tokens.css: no --doc-font (src/render/look-css.mjs keeps it as --doc-sans-font)");let o=[U(`:root${D("font","serif")}`,{"--doc-sans-font":n,"--doc-font":We}),U(`:root${D("font","mixed")}`,{"--doc-heading-font":We})],[,...s]=Et.size,[,...i]=Et.spacing,[,...c]=Et.width;for(let a of s)o.push(U(`:root${D("size",a)}`,ct(e,{size:a})));for(let a of i)o.push(U(`:root${D("spacing",a)}`,ct(e,{spacing:a})));for(let a of c)o.push(U(`:root${D("width",a)}`,ct(e,{width:a})));for(let a of s)for(let l of i){let r=ct(e,{size:a,spacing:l});o.push(U(`:root${D("size",a)}${D("spacing",l)}`,Object.fromEntries(He.map(([,d])=>[d,r[d]]))))}return o.join(`
4
- `)}var Ge=Object.fromEntries(K.filter(t=>t.file).map(t=>[t.file,t.build])),ja=Object.keys(Ge),V=t=>B.join(Pn,t),Bn=(t,e,n)=>({entryPoints:[V(t)],bundle:!0,write:!1,format:"iife",platform:"browser",target:"es2022",...typeof e=="function"?e():e,...n}),Wn=t=>{let e=Ge[t];if(!e)throw new Error(`src/render/kit-build.mjs: no kit file "${t}"`);return e},lt=new Map;function Hn(t,e){let n=[...e.matchAll(/^@import\s+"\.\/([a-z0-9-]+\.css)";\s*$/gm)].map(i=>i[1]),o=Z.readdirSync(B.dirname(V(t))).filter(i=>i.endsWith(".css")&&i!==B.basename(t)),s=[...o.filter(i=>!n.includes(i)).map(i=>`${i} is not listed`),...n.filter((i,c)=>!o.includes(i)||n.indexOf(i)!==c).map(i=>`${i} is listed but missing, or listed twice`)];if(s.length>0)throw new Error(`src/render/kit/${t}: ${s.join("; ")}`);return n.map(i=>B.join(B.dirname(t),i))}var Kn=t=>t.replace(/@(text|highlight)-colors\b/g,(e,n)=>Dn.map(o=>`.doc-${n}-${o}`).join(", ")),Gn=t=>{let e=Kn(t.join(`
5
- `)).replaceAll("@fold-dots",_n).replace(/^@kit-words;$/m,()=>Be());return e.replace(/^@kit-look;$/m,()=>Ke(e))};function At(t,{fresh:e=!1}={}){let n=Wn(t);if(Un)return Z.promises.readFile(B.join(Mn,t),"utf8");if(n.read)return Z.promises.readFile(V(n.read),"utf8");if(n.styles)return Z.promises.readFile(V(n.styles),"utf8").then(o=>Promise.all(Hn(n.styles,o).map(s=>Z.promises.readFile(V(s),"utf8")))).then(Gn);if(e||!lt.has(t)){let o=re(Bn(n.bundle,n.options)).then(s=>s.outputFiles[0].text);o.catch(()=>lt.delete(t)),lt.set(t,o)}return lt.get(t)}import{kitNamespace as Jn}from"../browser/shared/old-names.mjs";import{attr as zt,hasClass as dt}from"../browser/shared/html-tree.mjs";var Je=t=>t.tagName==="section"&&dt(t,"doc-section"),Zn=new Set(["section","header","footer","nav","script","style","template","dialog","link","meta"]),Vn=t=>!Zn.has(t.tagName),Ct=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map(Ct).join("");function Ve(t,e=[]){for(let n of t.childNodes??[])n.tagName&&((n.tagName==="main"&&dt(n,"doc-page")||zt(n,"data-doc-sheet")!==void 0)&&e.push(n),Ve(n.tagName==="template"?n.content:n,e));return e}var Yn=/^(p|li|h[1-4]|blockquote|ul|ol)$/,Ye=["doc-summary","doc-panel","doc-note","doc-callout"],qn=t=>Yn.test(t.tagName)||Ye.some(e=>dt(t,e)),Xn=new Set(["none","auto","100%","inherit","initial","unset","revert"]),Ze=t=>[...t.matchAll(/(?:^|[;{\s])(?:max-)?width\s*:\s*([^;}]+)/gi)].some(([,e])=>!Xn.has(e.replace(/!important/i,"").trim().toLowerCase())),Qn=t=>{let e=t.trim().split(/\s*[\s>+~]\s*/).at(-1)??"",n=/^(p|li|h[1-4]|blockquote|ul|ol)\b/.test(e)||Ye.some(s=>e.includes(`.${s}`)),o=[...t.matchAll(/\.([\w-]+)/g)].some(([,s])=>!Jn(s))||t.includes("#");return n&&!o};function ts(t){let e=[],n=(o,s)=>{for(let i of o.childNodes??[]){if(!i.tagName)continue;let c=s||i.tagName==="main"&&dt(i,"doc-page");if(c&&qn(i)&&Ze(zt(i,"style")??"")&&e.push(`<${i.tagName}> with style="${zt(i,"style").trim()}"`),i.tagName==="style"){let a=Ct(i).replace(/\/\*[\s\S]*?\*\//g,"");for(let[,l,r]of a.matchAll(/([^{}]+)\{([^{}]*)\}/g))if(Ze(r))for(let d of l.split(","))Qn(d)&&e.push(`"${d.trim()}" in the document's style`)}n(i.tagName==="template"?i.content:i,c)}};return n(t,!1),e}function qe(t,{written:e=t}={}){let n=[],o=$(t),s=ts(o);s.length>0&&n.push(`body text given a width of its own (${s.slice(0,3).join("; ")}${s.length>3?`; ${s.length-3} more`:""}): its lines break before the reading column's edge, leaving an extra right margin; let body text fill the column`);for(let i of Ve(o)){let c=i.childNodes.filter(a=>a.tagName);c.forEach((a,l)=>{if(!Je(a))return;let r=l+1;for(;r<c.length&&Vn(c[r]);)r++;let d=c.slice(l+1,r);if(d.length===0||!Je(c[r]??{})||/^h[1-4]$/.test(d[0].tagName))return;let f=a.childNodes.map(h=>h.tagName?h:null).filter(Boolean).map(Ct).find(h=>h.trim())?.replace(/\s+/g," ").trim().slice(0,40)??"";n.push(`${d.length} block${d.length===1?"":"s"} of body text right after the section "${f}" stand outside it, between two sections, with no heading of their own: fine if meant, otherwise they belong inside that section`)})}return n.push(...Te(t,{written:e})),n}import{attr as Xe,hasClass as es}from"../browser/shared/html-tree.mjs";var Qe="Write instead where it came from, in words, or a path relative to materials/ (materials/data.csv)",os=new Set(["script","style","template","noscript","textarea","pre","code","kbd","samp","var"]),ns=["doc-math-inline","doc-math-block"],ss=/\\\([\s\S]*?\\\)|\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$/g,is=/(?<!\\)\$(?:\\[\s\S]|[^\\$])+\$/g,as=/[\s"'<>|()[\]{};,。;:、!?()《》「」『』“”‘’【】]/u,rs=/[^\s"'<>|()[\]{};,。;:、!?()《》「」『』“”‘’【】]+/gu,oo=/^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,cs=/\.[A-Za-z0-9]{1,8}$/,ls=[/(?<![A-Za-z0-9_\\])[A-Za-z]:[\\/]/g,/(?<![A-Za-z0-9_.~:/\\-])\/(?:Users|home|root|tmp|private|mnt|opt|Volumes|var\/folders)\/(?=\S)/g,/(?<![A-Za-z0-9_.~:/\\-])~\/(?=\S)/g,/(?<![A-Za-z0-9_$\\])\$(?:HOME|\{HOME\})\/(?=\S)/g,/(?<![A-Za-z0-9_:\\])\\\\[A-Za-z0-9][\w.$-]*\\(?=[^\s\\])/g,/%(?:TEMP|TMP|APPDATA|LOCALAPPDATA|USERPROFILE)%/gi],ds=/(?:^|[\\/])(?:AppData|scratchpad)(?=[\\/]|$)/i,fs=/^(?:[A-Za-z]:|[\\/]|%[A-Za-z]+%)[\s\S]*[\\/](?:temp|tmp)(?=[\\/])/i,hs=t=>t.includes("://")&&!/^file:/i.test(t),to=12;function eo(t,e){let n=e;for(;n<t.length&&!as.test(t[n])&&!(oo.test(t[n])&&cs.test(t.slice(e,n)));)n++;return t.slice(e,n).replace(/[.,;:!?]+$/,"")}function us(t,e=!1){let n=a=>a.replace(/[^\n]/g," "),o=t.replace(ss,n),s=e?o.replace(is,n):o,i=[],c=(a,l)=>i.some(r=>r.at<=a+l.length&&a<=r.at+r.path.length);for(let a of ls)for(let l of s.matchAll(a)){let r=eo(s,l.index);r.length>=l[0].length+2&&!c(l.index,r)&&i.push({at:l.index,path:r})}for(let a of s.matchAll(rs)){let l=a.index;for(;l<a.index+a[0].length&&oo.test(s[l]);)l++;let r=eo(s,l);/[\\/]/.test(r)&&(ds.test(r)||fs.test(r))&&!hs(r)&&!c(l,r)&&i.push({at:l,path:r})}return i.sort((a,l)=>a.at-l.at)}function no(t,e=$(t)){let n=[],o=(c,a)=>{for(let l of c.childNodes??[])if(l.nodeName==="#text"){if(!l.sourceCodeLocation)continue;for(let{at:r,path:d}of us(l.value,a))n.push({line:l.sourceCodeLocation.startLine+(l.value.slice(0,r).match(/\n/g)?.length??0),path:d})}else l.tagName&&!os.has(l.tagName)&&Xe(l,"hidden")===void 0&&!ns.some(r=>es(l,r))&&o(l,a||Xe(l,"data-doc-math-dollar")!==void 0)};o(e,!1);let s=n.slice(0,to).map(({line:c,path:a})=>`line ${c}: "${a.length>80?`${a.slice(0,77)}\u2026`:a}" is a path of this machine in the text a reader reads: a reader on another machine cannot open it. ${Qe}`),i=n.slice(to);return i.length>0&&s.push(`${i.length} more path${i.length===1?"":"s"} of this machine in the text a reader reads, on line${new Set(i.map(({line:c})=>c)).size===1?"":"s"} ${[...new Set(i.map(({line:c})=>c))].join(", ")}. ${Qe}`),s}import{MENTION as ps,MENTION_ICON as ms}from"../browser/shared/components/mention.mjs";import{escapeAttribute as gs}from"../browser/shared/escape.mjs";import{attr as so,elementsOf as $s,hasClass as io,walk as ws}from"../browser/shared/html-tree.mjs";import{addressOn as bs,decoded as ks,fromFile as ys,hosted as Ns,pageAddress as xs,workbenchHash as Ss}from"../browser/shared/page-address.mjs";function vs(t,e,n){let o=ys(t,e),s=bs(o,n);return s||Ns(t)?s:xs(o)??(Ss(o)===null?null:{slug:null,block:null})}function Os(t,e,n,o){let s=$(t),i=new Set,c=[];ws(s,r=>{let d=so(r,"data-block-id");d!==void 0&&i.add(d),r.tagName==="a"&&so(r,"href")!==void 0&&r.sourceCodeLocation?.startTag&&c.push(r)});let a=new Map,l=({startOffset:r,endOffset:d})=>a.set(r,[d,""]);for(let r of c){let{prefix:d,value:f}=r.attrs.find(({name:w})=>w==="href"),h=f.startsWith("#")?ks(f.slice(1)):null,u=h===null?f&&vs(f,e,o):i.has(h)?{slug:e,block:h}:null;if(!u)continue;let p=n(u,f);if(p===f)continue;let{attrs:m,startTag:b,endTag:k}=r.sourceCodeLocation;if(p===null)l(b),k&&l(k),io(r,ps)&&$s(r).filter(w=>io(w,ms)).forEach(w=>l(w.sourceCodeLocation));else{let w=d?`${d}:href`:"href";a.set(m[w].startOffset,[m[w].endOffset,`${w}="${gs(p)}"`])}}return[...a].sort(([r],[d])=>d-r).reduce((r,[d,[f,h]])=>`${r.slice(0,d)}${h}${r.slice(f)}`,t)}function ao(t,e,n,{blocks:o=!0,links:s}){return Os(t,e,({slug:i,block:c})=>{let a=n(i);if(a===null)return null;if(!c||!o)return i===e&&c?null:a;let l=`#${encodeURIComponent(c)}`;return i===e?l:`${a}${l}`},s)}import ft from"node:fs";import Es from"node:path";import{extensionOf as Ts,imageFile as Ls,mediaTypeOf as As}from"../browser/shared/media.mjs";var jt=1024*1024,zs=jt,co=2400,It=2e3,Cs=.25,Is=new Set(["png","gif"]),ro=.75;function Fs(t){if(t.length<16||t.toString("latin1",0,4)!=="RIFF"||t.toString("latin1",8,12)!=="WEBP")return!1;for(let e=12;e+8<=t.length;){let n=t.toString("latin1",e,e+4);if(n==="VP8L")return!0;if(n==="VP8 "||n==="ANMF")return!1;let o=t.readUInt32LE(e+4);e+=8+o+o%2}return!1}function js(t){let e=(n,o)=>n+o<=t.length;if(e(0,24)&&t.readUInt32BE(0)===2303741511&&t.toString("latin1",12,16)==="IHDR")return{width:t.readUInt32BE(16),height:t.readUInt32BE(20)};if(e(0,10)&&/^GIF8[79]a$/.test(t.toString("latin1",0,6)))return{width:t.readUInt16LE(6),height:t.readUInt16LE(8)};if(e(0,4)&&t[0]===255&&t[1]===216){for(let n=2;e(n,4);){if(t[n]!==255)return null;let o=t[n+1];if(o===255){n+=1;continue}if(o===216||o===1||o>=208&&o<=215){n+=2;continue}if(o>=192&&o<=207&&![196,200,204].includes(o))return e(n,9)?{width:t.readUInt16BE(n+7),height:t.readUInt16BE(n+5)}:null;if(o===217||o===218)return null;n+=2+t.readUInt16BE(n+2)}return null}if(e(0,30)&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){let n=t.toString("latin1",12,16);if(n==="VP8 ")return{width:t.readUInt16LE(26)&16383,height:t.readUInt16LE(28)&16383};if(n==="VP8L"){let o=t.readUInt32LE(21);return{width:(o&16383)+1,height:(o>>>14&16383)+1}}return n==="VP8X"?{width:t.readUIntLE(24,3)+1,height:t.readUIntLE(27,3)+1}:null}if(e(0,12)&&t.toString("latin1",4,8)==="ftyp"&&/avi[fs]/.test(t.toString("latin1",8,Math.min(t.length,t.readUInt32BE(0))))){let n=null;for(let o=t.indexOf("ispe",0,"latin1");o>=0&&e(o,16);o=t.indexOf("ispe",o+4,"latin1")){let s={width:t.readUInt32BE(o+8),height:t.readUInt32BE(o+12)};(!n||s.width*s.height>n.width*n.height)&&(n=s)}return n}return null}var Rs=jt;function Ds(t){let e;try{e=ft.openSync(t,"r");let{size:n}=ft.fstatSync(e),o=Buffer.alloc(Math.min(n,Rs));return ft.readSync(e,o,0,o.length,0),{length:n,head:o}}catch{return null}finally{e!==void 0&&ft.closeSync(e)}}var F=t=>`${Math.max(.1,t/jt).toFixed(1)} MB`;function _s({bytes:t,width:e,height:n,extension:o,lossless:s}){let i=Math.max(e,n),c=Math.min(1,It/i),a=Math.min(t,e*n*c*c*Cs);if(i>co){if(!s)return a<=t*ro?` \u2014 a ${It}px copy would be about ${F(a)}`:"";let l=t*c*c;return` \u2014 a ${It}px copy would be about ${F(l)}${o==="png"&&a<l/2?`, or ${F(a)} as a JPEG (for a photograph)`:""}`}return!s&&a<=t*ro?` \u2014 written again as a JPEG of quality about 82, it would be about ${F(a)}`:o==="png"&&a<t/2?` \u2014 as a JPEG (for a photograph) it would be about ${F(a)}`:""}var Ft=t=>t===2?"twice":`${t} times`;function lo({html:t,directory:e,tree:n=$(t)}){let{embedded:o,unserved:s}=oe({html:t,directory:e,tree:n}),i=new Map,c=(l,r,d,f=!1)=>{let h=i.get(l)??i.set(l,{at:[],shows:0,served:d}).get(l);h.at.push(r),f||(h.shows+=1)};for(let{file:l,line:r,icon:d}of o)Ls(l)&&c(l,r,!0,d);for(let{file:l,line:r}of s)As(l).startsWith("image/")&&c(l,r,!1);let a=[];for(let[l,{at:r,shows:d,served:f}]of[...i].sort(([,h],[,u])=>Math.min(...h.at)-Math.min(...u.at))){let h=Ds(Es.join(e,l));if(!h)continue;let{length:u,head:p}=h,m=js(p),b=m?Math.max(m.width,m.height):0,k=u>zs||b>co,w=f&&d>1;if(!k&&!w)continue;let N=[...new Set(r)],v=`line${N.length===1?"":"s"} ${N.length>1?`${N.slice(0,-1).join(", ")} and ${N.at(-1)}`:N[0]}`,E=w?`shown ${Ft(d)}: the export embeds it ${Ft(d)}; show it once and refer back to it in words`:"";if(!k){a.push(`${l} (${v}): ${E} (${F(Math.ceil(u/3)*4*d)} as data: URLs)`);continue}let H=r.length===1||!f?"":`, ${Ft(r.length)}`,j=f?r.length:1,q=`${F(Math.ceil(u/3)*4*j)} as ${j===1?"a data: URL":"data: URLs"}`,Fo=m?`, ${m.width}\xD7${m.height}px`:"",Ut=Ts(l),Bt=m?_s({bytes:u,...m,extension:Ut,lossless:Is.has(Ut)||Fs(p)}):"",jo=f?`the export embeds it as it is${H}, ${q}${Bt}`:`its name keeps it out of the preview and the export (the failure at its line says why); copied into assets/ under a name they take, the export embeds it as it is, ${q}${Bt}: copy it in at the size the page needs`;a.push(`${l} (${v}): ${F(u)}${Fo}; ${jo}${E?`; ${E}`:""}`)}return a}import{COMPONENTS as ti}from"../browser/shared/components/index.mjs";import{withLook as ei}from"../browser/shared/document-look.mjs";import{reportsDirectory as oi}from"../browser/shared/paths.mjs";import{documentLook as ni}from"../browser/shared/workspace-look.mjs";import fo from"node:fs";import{MENTION as ho,MENTION_ICON as uo}from"../browser/shared/components/mention.mjs";import{escapeAttribute as Ms,escapeText as Ps}from"../browser/shared/escape.mjs";import{iconUrl as Us,validIcon as Bs}from"../browser/shared/emoji/icon-value.mjs";import{attr as Ws,hasClass as Hs,walk as Ks}from"../browser/shared/html-tree.mjs";import{fromFile as Gs,isFileLink as Js,pageAddress as Zs}from"../browser/shared/page-address.mjs";import{reportsDirectory as Vs}from"../browser/shared/paths.mjs";import{documentDirectory as Ys,documentFiles as qs}from"../browser/shared/workspace.mjs";function Xs(t,e){let{html:n,json:o}=qs(Ys(t,e));if(!fo.existsSync(n))return null;try{let{title:s,icon:i}=JSON.parse(fo.readFileSync(o,"utf8"));return{title:s,icon:i}}catch{return{}}}function Qs(t,e,n,o){if(n==="words"||typeof t!="string"||!Bs(t))return null;if(n==="preview")return Us(t,e,{tab:!0});let s=Gt({value:t,slug:e,tab:!0,reportsDirectory:o});return s&&`data:${s.type};base64,${s.body.toString("base64")}`}function po(t,{slug:e,mode:n="export",reportsDirectory:o=Vs}){if(!t.includes(ho))return t;let s=new Map,i=a=>(s.has(a)||s.set(a,Xs(a,o)),s.get(a)),c=new Map;return Ks($(t),a=>{let l=a.tagName==="a"&&Hs(a,ho)?Ws(a,"href"):void 0,{startTag:r,endTag:d}=a.sourceCodeLocation??{};if(!l||!Js(l)||!r||!d)return;let f=Zs(Gs(l,e))?.slug;if(!f)return;let h=i(f);if(!h)c.set(r.endOffset-1,[r.endOffset-1," data-doc-gone"]);else if(h.title){let u=Qs(h.icon,f,n,o);c.set(r.endOffset,[d.startOffset,`${u?`<img class="${uo}" src="${Ms(u)}" alt="">`:`<span class="${uo}"></span>`}${Ps(h.title)}`])}}),[...c].sort(([a],[l])=>l-a).reduce((a,[l,[r,d]])=>`${a.slice(0,l)}${d}${a.slice(r)}`,t)}var si=/<script\b[^>]*\bdata-doc-kit="runtime"[^>]*><\/script>/;function ii(t,e,n){let o=ie(e).filter(({id:s})=>!n.some(i=>i.id===s)).map(ae).join(" ");return o?t.replace(si,s=>`${s}
6
- <script data-doc-dev>${o}</script>`):t}function Rt(t,{slug:e,mode:n="export",files:o=!0,reportsDirectory:s,kit:i}){let c=L(s),a=z(t,c),{html:l,removed:r,used:d}=le(t,[...ti,...a]),f={slug:e,mode:n,...s?{reportsDirectory:s}:{}},h=we(de(l,{used:d,...i?{href:i}:{}}),a),u=ei(h,ni(e,s??oi)),p=Jt(n==="preview"?ii(u,c,a):u,f),m=o?ne(Vt(qt(Qt(p,f),f),f),f):p;return{html:po(m,f),removed:r}}import{exportsDirectory as _t,generatedDirectory as Y,kitPublicDirectory as gi,release as $i,reportsDirectory as M,vendorDirectory as wi}from"../browser/shared/paths.mjs";import{referencedFile as bi}from"../browser/shared/media.mjs";import{decoded as ki,fromFile as yi,hashAddress as Ni,hosted as vo,pageAddress as xi,workbenchHash as Si}from"../browser/shared/page-address.mjs";import{pageLinks as vi}from"../browser/shared/page-links.mjs";import{documentLinks as Oi,listReportSlugs as Ei}from"../browser/shared/reports.mjs";import{documentDirectory as W,documentFiles as Pt}from"../browser/shared/workspace.mjs";import{sha256 as ht}from"../browser/shared/files.mjs";import{EXPORT_CSP as Ti,GENERATOR as Li,isolateUmd as Ai,packagesMeta as zi,sourceMeta as Ci}from"../browser/shared/export-wrap.mjs";var bo=/__REPORT_[A-Z_]+__/,ko=1e6,yo=t=>t.length>1?`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`:`${t[0]}`;function Ii(t){return t.map(({id:e,lines:n,columns:o})=>{let s=new Set(n).size<n.length,i=n.map((c,a)=>s?`${c}:${o[a]}`:`${c}`);return`data-block-id repeats: "${e}" on lines ${yo(i)}${s?" (line:column)":""}; each id names one block: remove it from the copy, which needs none (the later ${i.length>2?`ones, lines ${yo(i.slice(1))}`:`one, line ${i[1]}`}, unless the copy went before its original)`})}var Fi=({slug:t,htmlPath:e,metadataPath:n})=>{let o=e?{html:e,json:n??e.replace(/\.html$/,".json")}:Pt(W(t,M));return{htmlName:S.basename(o.html),jsonName:S.basename(o.json)}};function ji({slug:t,html:e,metadata:n,htmlPath:o,metadataPath:s,tree:i=$(e)}){let c=[],{htmlName:a,jsonName:l}=Fi({slug:t,htmlPath:o,metadataPath:s}),r=[[/<meta\s+name=["']viewport["']/i,"missing viewport metadata"],[/<title>[^<]+<\/title>/i,"missing document title"],[/<main(?:\s|>)/i,"missing semantic main element"],[/aria-label|aria-labelledby|<title>/i,"missing accessible labels"]];for(let[p,m]of r)p.test(e)||c.push(m);let d=Buffer.byteLength(e);d>ko&&c.push(`the document's editable source is ${d.toLocaleString("en-US")} bytes, over the ${ko.toLocaleString("en-US")}-byte limit: aggregate or sample the embedded data, or split the document`),bo.test(e)&&c.push(`${a} still contains a starter placeholder such as __REPORT_TITLE__`);for(let[p,m]of Object.entries(n))typeof m=="string"&&bo.test(m)&&c.push(`${l} "${p}" is still a starter placeholder such as __REPORT_TITLE__`);/<[a-z][^>]*\sdata-doc-placeholder\b/i.test(e)&&c.push("starter placeholder content ([data-doc-placeholder]) is still present; replace it with the document's content");let f=new Map;_(i,p=>{let m=O(p,"data-block-id"),b=p.sourceCodeLocation?.attrs?.["data-block-id"]??p.sourceCodeLocation;m!==void 0&&f.set(m,[...f.get(m)??[],{line:b?.startLine,column:b?.startCol}])});let h=[...f].filter(([,p])=>p.length>1);c.push(...Ii(h.map(([p,m])=>({id:p,lines:m.map(({line:b})=>b),columns:m.map(({column:b})=>b)}))));let u=null;if(_(i,p=>{!u&&p.tagName==="main"&&(u=p)},{inTemplates:!1}),u){let p=O(u,"data-doc-id");p===void 0?c.push(`main.doc-page needs data-doc-id="${t}"`):p!==t&&c.push(`main[data-doc-id] is "${p}": it must be the document's slug "${t}"`)}return c}var Oo=t=>$o($o(t).find(e=>e.tagName==="html")??{}).find(e=>e.tagName==="head")?.sourceCodeLocation?.startTag?.endOffset,Mt=new Set(["localStorage","sessionStorage"]);function Eo(t){let e=[],n=[];return _(t,o=>{o.tagName==="script"&&O(o,"src")!==void 0&&e.push(O(o,"src")),(o.tagName==="link"?(O(o,"rel")??"").toLowerCase().split(/\s+/):[]).includes("stylesheet")&&O(o,"href")!==void 0&&n.push(O(o,"href"))}),{scripts:e,styles:n}}function To({slug:t,html:e,directory:n=W(t,M),tree:o=$(e),uses:s=Q(e,X,{tree:o}),catalog:i}){let c=[];Oo(o)===void 0&&c.push("the page writes no <head> start tag, which an export puts its Content-Security-Policy right after: write <head> \u2026 </head> before <body>");let a=[];_(o,d=>{if(["script","link","img"].includes(d.tagName))for(let f of["src","href"]){let h=O(d,f)?.trim();h&&/^https?:\/\//i.test(h)&&a.push(h)}}),a.length>0&&c.push(`external resources are not portable: ${a.join(", ")}`);for(let{name:d,how:f,line:h,where:u}of s){if(!X.has(d))continue;let p={call:`calls ${d}(\u2026)`,new:`creates new ${d}(\u2026)`}[f]??`uses ${d}`;c.push(`line ${h}: ${u} ${p}: embed its data (inline JSON, DocState); the export blocks the network`)}let{scripts:l,styles:r}=Eo(o);for(let d of l)pe.has(d)||c.push(`unsupported script dependency ${d}`);for(let d of r)me.has(d)||c.push(`unsupported stylesheet dependency ${d}`);return c.push(...te({html:e,directory:n,tree:o}),...Xt({html:e,directory:n,tree:o}),...Yt({html:e,directory:n,tree:o}),...ee({html:e,directory:n,tree:o})),c.push(...ke(z(e,i,o))),[...new Set(c)]}var Ri=[[/\bDocSheets\.mount\s*\(/,"Sheet areas start on their own: remove DocSheets.mount (an area keeps its tab under its data-doc-sheets name)"],[/\bDocCode\.(?:View|DiffView|DiffStats|enhance)\b/,'code blocks are highlighted on their own, and a diff is declared as <div class="doc-diff"> holding { path, lines } as JSON (sdk/doc-code.d.ts)'],[/\bDocTables\.(?:enhance|enhanceAll|makeSortable)\b/,"tables start on their own: remove the call"],[/\bDocDialogs\.(?:enhance|enhanceAll)\b/,"detail cards start on their own: remove the call"]];function Di({html:t,tree:e=$(t),uses:n=Q(t,Mt,{tree:e})}){let o=ge(t,e),s=[...fe(t,e),...he(t,e)];for(let[i,c]of Ri)i.test(o)&&s.push(`${o.match(i)[0].replace(/\s*\($/,"")} is gone: ${c}`);for(let{name:i,line:c,where:a}of n)Mt.has(i)&&s.push(`line ${c}: ${a} uses ${i}: use DocState instead of direct browser storage`);return[...new Set(s)]}var _i=(t,e)=>e.childNodes.find(n=>n.tagName||n.nodeName==="#text"&&n.value.trim())===t,Mi=t=>go(t,li("highlight").match)||t.tagName==="li"&&go(t.parentNode,`ol.${di}`),Pi=`an icon is one of three kinds: an emoji, <div class="doc-icon">\u{1F3AF}</div>; an icon of Gallery's sets in one of ${wo.length} colors, <div class="doc-icon" data-icon="/icons/airplane_blue.svg"></div> (MingCute's names; Tabler's as /icons/tabler/plane_blue.svg; the colors ${wo.join(", ")}); or a picture of the document's folder, <div class="doc-icon"><img src="assets/logo.png" alt=""></div>`,Lo=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map(Lo).join("");function No(t,e,n){let o=e.sourceCodeLocation?.attrs?.[n],s=o?t.slice(o.startOffset,o.endOffset):`${n}="${O(e,n)??""}"`;return s.length>72?`${s.slice(0,71)}\u2026`:s}function Ui(t,e){let n=O(e,"data-icon");if(n!==void 0)return{held:No(t,e,"data-icon"),meant:Dt(n)==="glyph"?n:null};let o=null;if(_(e,i=>{o??=["img","svg"].includes(i.tagName)?i:null}),o?.tagName==="img"){let i=O(o,"src");return{held:`<img ${No(t,o,"src")}>`,meant:Dt(i)==="image"?i:null}}if(o)return{held:"an <svg>"};let s=Lo(e).replace(/\s+/g," ").trim();return{held:s?`"${s.slice(0,40)}"`:"nothing"}}function Bi({set:t,name:e,color:n}){let o=fi.find(c=>c!==t);if(pt(o).includes(e))return`; "${e}" is ${o==="tabler"?"Tabler":"MingCute"}'s: ${ui(o,e,n)}`;let s=e.split("-").filter(c=>c.length>=3),i=pt(t).filter(c=>c.split("-").some(a=>s.includes(a))).slice(0,6);return i.length>0?`; names of its set near it: ${i.join(", ")}`:""}function Wi({html:t,tree:e=$(t)}){let{all:n,own:o}=Zt(e),s=[],i=c=>c.sourceCodeLocation?.startLine;o.length>1&&s.push(`line ${i(o[1])}: ${o.length} page icons (.doc-icon) in the header (the first at line ${i(o[0])}): a document has one, right before its title`);for(let c of n){let a=i(c),l=c.parentNode;!o.includes(c)&&!(Mi(l)&&_i(c,l))&&s.push(`line ${a}: an icon (.doc-icon) stands only right before the document's title, first in a highlight block (.doc-panel, .doc-summary), or first in a flowchart's step (ol.doc-flow > li, in its number's place)`);let r=mi(Wt(t,c)),{held:d,meant:f}=r?{}:Ui(t,c);f?s.push(`line ${a}: an icon (.doc-icon) holds ${d}, an icon a page reads only in double quotes: write ${pi(f)}`):r?Dt(r)==="glyph"&&!Kt(r)&&s.push(`line ${a}: the icon ${r} is none of the icon sets' (MingCute: /icons/<name>_<color>.svg, Tabler: /icons/tabler/<name>_<color>.svg; src/shared/emoji/data/icons.json lists the names of each)${Bi(hi(r))}`):s.push(`line ${a}: an icon (.doc-icon) holds no icon (it holds ${d}): ${Pi}`)}return[...new Set(s)]}function Ao(t){let e=$(t.html),n={...t,tree:e,uses:Q(t.html,new Set([...X,...Mt]),{tree:e})};return[...ji(n),...Ot(t.html,e),...Di(n),...Wi(n),...To(n)]}function Hi(t){let e=new Map(t.map(s=>[s.slug,[...Ao(s),...yt(s.html)]])),n=new Map(t.map(s=>[S.resolve(s.htmlPath),s.slug])),o=new Map(t.map(s=>[S.resolve(s.htmlPath),s]));for(let s of t)s.scriptNotes=[];if(t.length>0)for(let{htmlPath:s,text:i,typeOnly:c,note:a}of $e(t)){if(c){o.get(s)?.scriptNotes.push(a);continue}let l=s?[n.get(s)]:[...e.keys()];for(let r of l)e.get(r).push(s?i:`${i} (shared SDK declaration)`)}for(let[s,i]of e)i.length===0&&e.delete(s);return e}async function cc(t=[],{prepare:e=null}={}){let{reports:n,failures:o}=await ut(t,{prepare:e});for(let s of n){let i=[...Ao(s),...yt(s.html)];i.length&&o.set(s.slug,i)}return o}async function Ki(t=[],{prepare:e=null}={}){let{reports:n,failures:o}=await ut(t,{prepare:e});for(let[s,i]of Hi(n))o.set(s,i);return{reports:n,failures:o}}async function Gi({fresh:t=!1,kit:e=gi,vendor:n=wi}={}){if($i)return;let o=K.map(c=>[c,c.file?At(c.file,{fresh:t}):gt(c)]);await x.mkdir(e,{recursive:!0});let s=S.join(n,"katex","fonts");await x.mkdir(s,{recursive:!0});let i=(await x.readdir(mt)).filter(c=>c.endsWith(".woff2"));await Promise.all(i.map(c=>x.copyFile(S.join(mt,c),S.join(s,c)))),await Promise.all(o.map(async([c,a])=>x.writeFile(c.file?S.join(e,c.file):S.join(n,...c.vendor.path.split("/").slice(2)),await a)))}async function Ji(t,e){let n=await x.readdir(t).catch(()=>[]);await Promise.all(n.filter(o=>o.endsWith(".html")&&!e.has(o.slice(0,-5))).map(o=>x.rm(S.join(t,o),{force:!0})))}async function Zi(t){let e=S.join(Y,"reports.json"),n=await x.readFile(e,"utf8").then(JSON.parse,()=>[]),o=new Map(Array.isArray(n)?n.map(i=>[i.slug,i]):[]);for(let{entry:i}of t)o.set(i.slug,i);let s=[];for(let[i,c]of[...o].sort(([a],[l])=>a.localeCompare(l))){let a=S.join(Y,`${i}.html`);await x.stat(a).then(()=>!0,()=>!1)&&s.push(c)}await x.writeFile(e,`${JSON.stringify(s,null,2)}
7
- `)}async function Vi(t=[],{prepare:e=null}={}){let{reports:n,failures:o}=await Ki(t,{prepare:e});await Gi(),await x.mkdir(Y,{recursive:!0}),await Ji(Y,new Set(await Ei()));let s=[];for(let i of n){let c=`${i.slug}.html`,a=S.join(Y,c);if(o.has(i.slug)){await x.rm(a,{force:!0});continue}let{html:l,removed:r}=Rt(i.html,{slug:i.slug});await x.writeFile(a,l),s.push({report:i,html:l,removed:r,entry:{slug:i.slug,...i.metadata,preview:`/generated/${c}`,sourceSha256:ht(i.html),outputSha256:ht(l)}})}return await Zi(s),{built:s,failures:o}}var Yi=t=>t.replace(/<\/script/gi,"<\\/script");async function zo(){return new Map(await Promise.all(K.map(async t=>{let e=await(t.file?At(t.file):gt(t,{inline:!0}));return ce(t).endsWith(".css")||(e=Yi(e)),[t.id,t.umd?Ai(e):e]})))}function qi(t,e,n=null,o=[]){let s=Oo($(e));if(s===void 0)throw new Error(`${t}: the page writes no <head> start tag, which the export's Content-Security-Policy goes right after`);let i=n?`
8
- ${Ci(n)}${o.length>0?`
9
- ${zi(o)}`:""}`:"";return`${e.slice(0,s)}
10
- <meta name="generator" content="${Li}">
11
- <meta http-equiv="Content-Security-Policy" content="${Ti}">${i}${e.slice(s)}`}function Co(t,e,n,o=null,s=L()){let i=z(e,s);e=ue(ye(qi(t,e,o,i),s),({id:l,element:r,attribute:d})=>{let f=n.get(l);if(typeof f!="string")throw new Error(`${t}: no inline source for the asset "${l}" (loadInlineSources in src/render/pipeline.mjs)`);return`<${r} ${d}="${l}-inline">${f}</${r}>`});let{scripts:c,styles:a}=Eo($(e));if(c.length+a.length>0)throw new Error(`${t}: export still contains a linked script or stylesheet`);return e}async function xo(t,e=M,{components:n=!0}={}){let o=W(t,e),s=await x.readFile(Pt(o).html),i=s.toString("utf8"),c=$(i),a=n?L(e):{packages:new Map},l=[...n?Ot(i,c,a):[],...To({slug:t,html:i,directory:o,tree:c,catalog:a})];if(l.length>0){let r=z(i,a,c).find(({id:d})=>l[0].startsWith(`${d}:`)||l[0].startsWith(`${d} (`))?.id;throw Object.assign(new Error(`${t}: ${l[0]}`),{reason:"check",slug:t,failures:l,...r?{component:r}:{}})}return{html:i,sha256:ht(s)}}async function lc({directory:t=M}={}){let e=await zo(),n=async(o,{files:s=!0}={})=>{let i=await xo(o,t);return Co(o,Rt(i.html,{slug:o,files:s,reportsDirectory:t}).html,e,i.sha256,L(t))};return n.check=async o=>{await xo(o,t,{components:!1})},n}async function dc(t=[],{prepare:e=null}={}){let{built:n,failures:o}=await Vi(t,{prepare:e}),s=await zo();await x.mkdir(_t,{recursive:!0});let i=new Set(n.map(({report:l})=>l.slug)),{links:c}=await Oi(),a=[];for(let{report:l,html:r}of n)try{let d=ao(r,l.slug,h=>i.has(h)?`${h}.html`:null,{links:c}),f=Co(l.slug,d,s,l.fileSha256);await x.writeFile(S.join(_t,`${l.slug}.html`),f),a.push({slug:l.slug,bytes:Buffer.byteLength(f),sha256:ht(f)})}catch(d){o.set(l.slug,[d.message])}return{built:n,exported:a,failures:o}}function So(t){let e=new Set;return _(t,n=>{for(let o of["id","data-block-id"])O(n,o)!==void 0&&e.add(O(n,o))}),e}function Xi(t,e,n){if(vo(t)||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(t)||bi(t))return!1;let{pathname:o}=new URL(e);return!o.startsWith(`/${n}/`)||o.endsWith(".html")}function Qi({slug:t,tree:e,directory:n}){let o=[],s=So(e),i=n===W(S.basename(n),M)?M:S.dirname(n),c=new Map([[t,s]]),a=d=>{if(!c.has(d)){let f=Pt(W(d,i));c.set(d,mo(f.html)?So($(ai(f.html,"utf8"))):null)}return c.get(d)},l=null,r=(d,f)=>f===null?xi(d):Ni(f,l??=vi((mo(i)?ri(i):[]).map(h=>({slug:h}))));return _(e,d=>{let f=d.tagName==="a"?O(d,"href"):void 0;if(!f||f==="#"||f==="#top")return;let h=d.sourceCodeLocation?.startLine;if(f.startsWith("#")){s.has(ki(f.slice(1)))||o.push(`the link to ${f} (line ${h}) names no block or element of this document`);return}let u=yi(f,t),p=Si(u),m=r(u,p);(m?!a(m.slug):p!==null)?vo(f)||o.push(`the link to ${f} (line ${h}) names a document that is not there: gallery list has the slugs`):m?.block&&!a(m.slug).has(m.block)?o.push(`the link to ${f} (line ${h}) names a block document ${m.slug} does not hold`):u&&!m&&Xi(f,u,t)&&o.push(`the link to ${f} (line ${h}) leads to no document: a link to one is ../<slug>/doc.html, gallery list has the slugs`)},ci),o}function Io({slug:t,html:e,directory:n=W(t,M),written:o=e,scriptNotes:s=[]}){let i=$(e),c=Le(e);return{fix:[...no(e,i),...lo({html:e,directory:n,tree:i})],notes:[...qe(e,{written:o}),...Pe(i),...Qi({slug:t,tree:i,directory:n}),...c.notes,...s],readings:c.readings}}function fc(t){let{fix:e,notes:n}=Io(t);return[...e,...n]}function hc(t){let e=t.map(n=>[n.slug,Io(n)]);for(let[n,{fix:o}]of e)for(let s of o)console.log(`fix ${n}: ${s}`);for(let[n,{notes:o}]of e)for(let s of o)console.log(`note ${n}: ${s}`);for(let[n,{readings:o}]of e)for(let s of o)console.log(`chart ${n}: ${s}`)}async function ta(t,{exportNote:e=!1}={}){for(let[n,o]of t){console.error(`
12
- FAIL ${n}: ${o.length} problem${o.length===1?"":"s"}`);for(let i of o)console.error(` - ${i}`);let s=S.join(_t,`${n}.html`);e&&await x.stat(s).then(()=>!0,()=>!1)&&console.error(` ${s} was not updated; it still holds an earlier export.`)}}function ea(t,{above:e=!1,allow:n=process.argv.includes("--allow-failures")}={}){t.size!==0&&(console.error(`
13
- ${t.size} document${t.size===1?"":"s"} failed: ${[...t.keys()].join(", ")}${e?" (the failures are listed first, above)":""}`),n||(process.exitCode=1))}async function uc(t,{exportNote:e=!1,allow:n}={}){await ta(t,{exportNote:e}),ea(t,{allow:n})}export{kn as a,Os as b,ao as c,po as d,Rt as e,Ii as f,To as g,Ao as h,Hi as i,cc as j,Ki as k,Gi as l,Vi as m,qi as n,lc as o,dc as p,Io as q,fc as r,hc as s,ta as t,ea as u,uc as v};
@@ -1,2 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{c as l,d as i}from"./chunk-5MHMDLZD.mjs";import{f as a}from"./chunk-NSKUTQ5J.mjs";import p from"node:fs/promises";import f from"node:path";import{reportsDirectory as h}from"../browser/shared/paths.mjs";import{sameDirectory as u}from"../browser/shared/preview-server.mjs";import{copyOldDocuments as d,ensureWorkspace as g,layoutOf as k}from"../browser/shared/workspace.mjs";var m=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function $(e,t,r){let{preferences:s}=k(r);return[e.copied.length?`Copied ${m(e.copied.length,"document")} from ${t}: ${e.copied.join(", ")}`:`Copied no documents from ${t}.`,...e.skipped.length?[`Skipped (the slug is taken here, or the folder's name is no slug): ${e.skipped.join(", ")}`]:[],...e.kept.length?[`Left behind (a name a workspace keeps for itself, for its component packages here, which no new document takes): ${e.kept.join(", ")}`]:[],...e.preferences==="copied"?[`\u5199\u4F5C\u504F\u597D\uFF1Acopied (${s})`]:e.preferences==="kept"?[`\u5199\u4F5C\u504F\u597D\uFF1Akept the workspace's (${s}); the old one was not copied`]:[],...e.outline?[`Sidebar order: ${e.outline}`]:[],...e.page?[`\u5199\u4F5C\u504F\u597D's page: ${e.page==="copied"?"copied":"kept the workspace's"}`]:[],...e.emoji?[`Emoji library: ${e.emoji} added`]:[],...e.history?[`Recent versions: ${m(e.history,"document")}`]:[],...e.packages.length?[`Component packages: ${e.packages.join(", ")}`]:[]]}async function C(e){let{values:t}=a({values:["--from"],argv:e}),r=h,s;try{let{made:o,ours:n,reads:c}=await g(r);n||(console.error(i(r,c)),process.exit(1)),s=o}catch(o){if(!o.code)throw o;console.error(l(r,o.code)),process.exit(1)}if(console.log(`\u5DE5\u4F5C\u533A\uFF1A${r}\uFF08${s?"\u65B0\u5EFA":"\u5DF2\u6709"}\uFF09`),t.has("--from")){let o=f.resolve(t.get("--from"));await p.stat(o).then(n=>n.isDirectory(),()=>!1)||(console.error(`No such folder: ${o} (--from names an older Gallery's reports/ folder).`),process.exit(1)),u(o,r)&&(console.error(`${o} is this workspace: --from names another folder (an older Gallery's reports/).`),process.exit(1));for(let n of $(await d({from:o,to:r}),o,r))console.log(n)}console.log('Next: gallery new <slug> "<title>" makes a document; gallery open opens the workbench.')}export{$ as a,C as b};
@@ -1,2 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as A}from"./chunk-BFE45AKL.mjs";import{c as _,d as P}from"./chunk-5MHMDLZD.mjs";import"./chunk-64K7IPLO.mjs";import{b as $,f as M}from"./chunk-NSKUTQ5J.mjs";import"./chunk-5L7RYZCL.mjs";import{randomBytes as K}from"node:crypto";import{existsSync as X,readdirSync as G,readFileSync as B,statSync as R}from"node:fs";import c from"node:fs/promises";import C from"node:os";import n from"node:path";import{release as q,reportsDirectory as H,skillDirectory as J}from"../browser/shared/paths.mjs";import{copyOldDocuments as V,ensureWorkspace as Q,layoutOf as Y,oldStateOf as z}from"../browser/shared/workspace.mjs";var v={claude:{name:"Claude Code",home:t=>t.CLAUDE_CONFIG_DIR||n.join(C.homedir(),".claude"),project:".claude"},codex:{name:"Codex",home:t=>t.CODEX_HOME||n.join(C.homedir(),".codex"),project:".codex"}},x=t=>R(t,{throwIfNoEntry:!1})?.isDirectory()??!1;function Z({agent:t=null,project:e=!1,dir:r=null,cwd:o=process.cwd(),env:s=process.env}={}){if(r)return[{agent:null,target:n.resolve(o,r),skills:null}];let a=t?[t]:Object.keys(v),u=d=>e?n.join(n.resolve(o),v[d].project):n.resolve(v[d].home(s)),p=a.filter(d=>x(u(d)));return(t||p.length?t?a:p:["claude"]).map(d=>{let h=n.join(u(d),"skills");return{agent:d,target:n.join(h,"gallery"),skills:h}})}function ee(t){let e;try{e=B(n.join(t,"SKILL.md"),"utf8")}catch{return null}let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e.replace(/^/,""));return r?/^name:\s*["']?([\w.-]+)["']?\s*$/m.exec(r[1])?.[1]??null:null}function T(t){let e=R(t,{throwIfNoEntry:!1});if(!e)return{kind:"absent"};if(!e.isDirectory())return{kind:"other",why:"it is a file"};let r=G(t);if(r.length===0)return{kind:"absent"};if(r.includes(".git"))return{kind:"other",why:"it is a git checkout"};let o=ee(t),s=u=>r.includes(u);return(s("package.json")&&s("src")||s("reports"))&&(o==="gallery"||o==="html-report-studio")?{kind:"fat",name:o}:o==="gallery"&&!s("package.json")&&!s("src")&&!s("reports")?{kind:"thin"}:{kind:"other",why:o?`its SKILL.md is the skill "${o}"`:"it holds no Gallery skill"}}function te(t){return x(t)?G(t,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.name.startsWith(".")).map(e=>n.join(t,e.name)).filter(e=>T(e).kind==="fat"):[]}function oe(t){let e=n.join(z(t),"servers");return x(e)?G(e).filter(r=>r.endsWith(".json")).flatMap(r=>{try{let{pid:o,port:s}=JSON.parse(B(n.join(e,r),"utf8"));return!Number.isInteger(o)||o<=0||o===process.pid?[]:(process.kill(o,0),[{pid:o,port:s}])}catch(o){return o.code==="EPERM"?[{pid:Number.NaN,port:null}]:[]}}):[]}async function O(t){let e=0,r=0,o=async s=>{for(let a of await c.readdir(s,{withFileTypes:!0})){let u=n.join(s,a.name);a.isDirectory()?await o(u):(e++,r+=(await c.lstat(u)).size)}};return await o(t).catch(()=>{}),{files:e,bytes:r}}var U=t=>`${(t/1024/1024).toFixed(1)} MB`,re=(t,e)=>`${t} ${e}${t===1?"":"s"}`;async function j(t,e){for(let r=0;;r++)try{return await c.rename(t,e)}catch(o){if(process.platform!=="win32"||r>=10||!["EPERM","EBUSY","EACCES"].includes(o.code))throw o;await new Promise(s=>setTimeout(s,100*(r+1)))}}function se(t,e=new Date){let r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,o=n.join(Y(t).gallery,`old-skill-${r}`);for(let s=1;;s++){let a=s===1?o:`${o}-${s}`;if(!X(a))return a}}async function ne(t,e){await c.mkdir(n.dirname(e),{recursive:!0});try{return await j(t,e),null}catch(s){if(s.code!=="EXDEV")return`${s.code??s.message}`}let r=await O(t);await c.cp(t,e,{recursive:!0,preserveTimestamps:!0,verbatimSymlinks:!0,errorOnExist:!0,force:!1});let o=await O(e);return o.files!==r.files||o.bytes!==r.bytes?`the copy holds ${o.files} files, ${o.bytes} bytes, of ${r.files}, ${r.bytes}: the old folder was left as it was`:(await c.rm(t,{recursive:!0,force:!0}),null)}async function W(t){let e=[],r=async o=>{for(let s of await c.readdir(o,{withFileTypes:!0})){let a=n.join(o,s.name);s.isDirectory()?await r(a):e.push([n.relative(t,a).split(n.sep).join("/"),await c.readFile(a)])}};return await r(t),e.sort(([o],[s])=>o<s?-1:o>s?1:0)}var ie=(t,e)=>t.length===e.length&&t.every(([r,o],s)=>r===e[s][0]&&o.equals(e[s][1]));async function le(t,e,r){if(r==="thin"&&ie(await W(t),await W(e)))return"same";let o=n.dirname(e);await c.mkdir(o,{recursive:!0});let s=K(4).toString("hex"),a=n.join(o,`.gallery-skill-new-${s}`);if(await c.cp(t,a,{recursive:!0}),r==="absent")return X(e)&&await c.rmdir(e),await j(a,e),"new";let u=n.join(o,`.gallery-skill-old-${s}`);await j(e,u);try{await j(a,e)}catch(p){throw await j(u,e).catch(()=>{}),await c.rm(a,{recursive:!0,force:!0}),p}return await c.rm(u,{recursive:!0,force:!0}),"updated"}async function ge(t,{version:e}){let{positional:r,options:o,values:s}=M({options:["--project"],values:["--agent","--dir"],argv:t});if(r[0]!=="install")throw new $(r.length?`No such skill command: ${r[0]} (install).`:"Say what to do: gallery skill install.");if(r.length>1)throw new $(`gallery skill install takes no other argument: ${r[1]}`);let a=s.get("--agent")??null;if(a!==null&&!Object.hasOwn(v,a))throw new $(`--agent is claude or codex, not ${a}.`);let u=s.get("--dir")??null;if(u!==null&&(a!==null||o.has("--project")))throw new $("--dir names the skill's folder itself: not with --agent or --project.");let p=Z({agent:a,project:o.has("--project"),dir:u}),d=[],h=p.map(i=>({...i,...T(i.target)}));for(let{target:i,kind:l,why:f}of h)l==="other"&&d.push(`${i} holds something that is not a Gallery skill (${f}): move it away, or pass --dir <another folder>.`);let F=[...new Set(h.flatMap(({target:i,kind:l,skills:f})=>[...l==="fat"?[i]:[],...f?te(f):[]]))];for(let i of F)for(let{pid:l,port:f}of oe(i))d.push(Number.isNaN(l)?`The older Gallery skill ${i} has a preview server running that this user cannot see: stop it first.`:`The older Gallery skill ${i} has its preview server running (pid ${l}${f?`, port ${f}`:""}): stop it first (close the window that runs it, or end process ${l}), then run gallery skill install again.`);if(d.length){for(let i of d)console.error(i);console.error("Nothing was changed."),process.exit(1)}if(F.length){let i=H;try{let{ours:l,reads:f}=await Q(i);l||(console.error(P(i,f)),process.exit(1))}catch(l){if(!l.code)throw l;console.error(_(i,l.code)),process.exit(1)}console.log(`\u5DE5\u4F5C\u533A\uFF1A${i}`);for(let l of F){console.log(`An older Gallery skill (the whole tools) is in ${l}: its documents go into the workspace, then it moves out of the skills folder.`);let f=n.join(l,"reports");if(x(f)){let m=await V({from:f,to:i,state:z(l)});for(let w of A(m,f,i))console.log(` ${w}`)}else console.log(" It holds no documents (no reports/ folder).");let y=n.join(l,"exports");if(x(y)){let m=Y(i).exports;await c.mkdir(m,{recursive:!0});let w=[],I=[];for(let E of(await c.readdir(y)).filter(b=>b.endsWith(".html")).sort())try{await c.copyFile(n.join(y,E),n.join(m,E),c.constants.COPYFILE_EXCL),w.push(E)}catch(b){if(b.code!=="EEXIST")throw b;I.push(E)}w.length&&console.log(` Exports: copied ${re(w.length,"file")} into ${m}: ${w.join(", ")}`),I.length&&console.log(` Exports not copied (the name is taken in ${m}; they stay in the moved folder's exports/): ${I.join(", ")}`)}let{bytes:g}=await O(l),k=await O(n.join(l,"node_modules")),D=se(i),L=await ne(l,D);L&&(console.error(`Could not move ${l} to ${D} (${L}). Its documents are copied; move the folder out of the skills folder yourself (it is never needed in it again), then run gallery skill install again.`),process.exit(1)),console.log(` Moved the old skill to ${D} (${U(g)}${k.files?`; its node_modules/, ${U(k.bytes)}, may be deleted: nothing reads it any more`:""}).`)}}let N=J,S=null;if(!q){let{buildSkill:i}=await import("./chunk-EZY3WC6Z.mjs");S=await c.mkdtemp(n.join(C.tmpdir(),"gallery-skill-")),N=n.join(S,"gallery"),i(N,{version:e})}try{let i=!1;for(let{agent:l,target:f}of h){let y=T(f).kind,g=await le(N,f,y),k=l?` for ${v[l].name}`:"";console.log(g==="same"?`The Gallery skill ${e}${k} is installed already, unchanged: ${f}`:`${g==="updated"?"Updated":"Installed"} the Gallery skill ${e}${k}: ${f}`),i||=g!=="same"}i&&console.log("Open a new Agent session to use it.")}finally{S&&await c.rm(S,{recursive:!0,force:!0})}}export{v as AGENTS,T as kindOf,ge as run,Z as targetsOf};
@@ -1,2 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b,c,d,e,f,g}from"./chunk-4FS7Z7WR.mjs";import"./chunk-6RGJOMJP.mjs";import"./chunk-QJIR2BLP.mjs";import"./chunk-P2CAZPDP.mjs";import"./chunk-E7LWZRXY.mjs";import"./chunk-AUZGSZJH.mjs";import"./chunk-BGGDRNYQ.mjs";import"./chunk-6QXGZM36.mjs";import"./chunk-UALRNVSE.mjs";import"./chunk-W3BGBJQW.mjs";import"./chunk-JVHHHGEA.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-TYK6VNAB.mjs";import"./chunk-CY2FNNAB.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-L3QKH4OK.mjs";import"./chunk-W4VKN3GF.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as handInReports,e as idLines,f as inStepLines,d as noteNew,b as previewSettled,g as rereadLine,c as roundBegins};
@@ -1,16 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as Ge}from"./chunk-UMHUSOPJ.mjs";import{E as Jt,G as Vt,J as Pe,K as Ue,L as ze,M as Xt,c as lt,d as Ke,m as St,n as He,u as qt,v as ft,x as We}from"./chunk-L3QKH4OK.mjs";import{b as rt,e as on}from"./chunk-A55HN5OK.mjs";on();import an from"node:path";import{attr as w,curlyQuoted as cn}from"../browser/shared/html-tree.mjs";import{FOLDED_LINES as qe,LINE_START as Je,NOWRAP as Zt,lineStart as rn,validFolded as ln}from"../browser/shared/code-lines.mjs";import{COLORS as fn}from"../browser/shared/colors.mjs";import{FLOWS as dn,instanceSlots as at,isInstance as it,isSlot as cs,matchesNode as pt}from"../browser/shared/components/index.mjs";import{HEADED as dt}from"../browser/shared/components/dialog.mjs";import{pageLanguage as un}from"../browser/shared/components/page.mjs";import{SHEETS_LABEL as Ve,shortSheets as mn}from"../browser/shared/components/sheets.mjs";import{iconMarkup as Xe,iconValueOf as rs}from"../browser/shared/emoji/icon-value.mjs";import{escapeText as mt}from"../browser/shared/escape.mjs";import{COLUMN_GAP as hn,READING_WIDTH as Tt,SPAN as Ze,SPAN_SIZE as ut}from"../browser/shared/media.mjs";import{kitNamespace as ls}from"../browser/shared/old-names.mjs";import{CHART_DATA as fs,CHART_SOURCE as tt,nextChartKey as gn}from"../browser/shared/table-chart.mjs";import{BLOCK_COLORS as ae}from"../browser/editor/components/colors.mjs";import{DETAILS as pn,DIALOG as Yt,PAGE as ds,SECTION as Nn,SHEETS as On}from"../browser/editor/components/kit.mjs";import{DIALOG_TRIGGER as $n}from"../browser/editor/components/dialog/index.mjs";import{CHECKED as ie,FLOW as ht,TODO as te}from"../browser/editor/components/list/index.mjs";import{texSource as wn}from"../browser/editor/components/math/index.mjs";import{BOX_CLASSES as us,HOLDS_ONE as bn,UNIT_KINDS as kn}from"../browser/editor/components/registry.mjs";import{HEADER_LOOK as Qe}from"../browser/editor/components/table/index.mjs";import{backgroundColor as Ln,parseColor as yn,textColor as vn}from"../browser/editor/page/clipboard/import/colors.mjs";var ce=new Set(["script","style","template","textarea","noscript","code","svg","math","select","option","button","iframe","video","audio","canvas","object","picture"]),_t=["doc-figure","doc-code","doc-diff","doc-math-inline","doc-math-block","doc-link-mention","doc-sheet-tabs","doc-state-fields","doc-filter-row","doc-image","doc-file","doc-bookmark","doc-embed","doc-icon","doc-title","doc-table-meta"],re=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th","dt","dd","blockquote","figcaption","caption","summary"]),Et=new Set(["main","section","div","article","aside","blockquote","li","details","dialog"]),Cn=new Set(fn.map(({name:e})=>e)),C=e=>(w(e,"class")??"").split(/\s+/).filter(Boolean),Ye=e=>C(e).every(n=>ae.includes(n)),xn=ae.filter(e=>e.startsWith("doc-highlight-")),ct=e=>C(e).some(n=>!ls(n)),R=e=>e.nodeName==="#text",jt=/^[\s\u200b-\u200d\u2060\ufeff]*$/,V=e=>R(e)&&jt.test(e.value),y=e=>(e.childNodes??[]).filter(n=>n.tagName),Z=e=>(e.attrs??[]).map(n=>n.name),G=(e,n)=>Z(e).every(u=>n.includes(u)),Sn=[Nn.match,pn.match,Yt.match,On.match,"table.doc-table"].join(", ");function ms(e){let n=C(e);return n.some(u=>_t.includes(u))||Ke(e)||pt(e,Sn)||us.some(([u])=>n.includes(u))||kn.some(u=>u.class&&n.includes(u.class)&&(!u.tag||[u.tag].flat().includes(e.tagName)))}var Tn=e=>{for(let n=e.parentNode;n?.tagName&&n.tagName!=="main";n=n.parentNode)if(n.tagName==="figure")return!0;return!1},hs=new Set(["thead","tbody","tfoot","tr","colgroup","col"]),le=e=>ct(e)&&e.tagName!=="figure"&&!re.has(e.tagName)&&!hs.has(e.tagName)&&!ms(e),gs=new Set([...lt].filter(e=>!["header","main","dialog","form","fieldset","caption","dd","dt","figcaption","summary","li","td","th",...hs].includes(e))),En=/\\\(([\s\S]*?)\\\)/g,wt=e=>wn(e)&&/\S/.test(e);function In(e,n=!0){let u=n?e:/^\s*(?:\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$)/.exec(e)?.[0]??"";return/[<>]/.test(u)&&wt(u.replace(/</g,"\\lt ").replace(/>/g,"\\gt "))}var ee=new Set(["br","wbr","img","input"]),ps=new Set([...lt,"script","style","template","noscript","link","meta"]),Ns=new Set(["input","select","textarea","button","label","option"]),An=new Set([...lt,"hgroup","search","center","dir","listing","xmp","plaintext"]),se=e=>y(e).some(n=>An.has(n.tagName)||se(n)),Os=new Set(["main","section","div","article","aside","blockquote"]),_n=dn.join(", "),$s=e=>Os.has(e.tagName)&&!ct(e)&&(C(e).length===0||pt(e,_n))||cs(e),et=e=>R(e)?!jt.test(e.value):(e.childNodes??[]).some(et),jn=us.filter(([,e])=>bn.has(e)).map(([e])=>e),Bn=e=>$s(e)&&C(e).some(n=>jn.includes(n)),ws=e=>e.childNodes.some(n=>R(n)&&!jt.test(n.value))&&y(e).some(n=>lt.has(n.tagName)),Mn=/^[ \t\n\r\f]*/;function Qt(e){let n=[],u=[];for(let d of e)d.tagName&&ps.has(d.tagName)?(n.push(u),u=[]):u.push(d);n.push(u);let p=d=>!d.tagName&&!et(d),N=d=>(R(d)||d.tagName&&!Ns.has(d.tagName))&&et(d);return n.map(d=>{let O=d.findIndex(m=>!p(m));return O<0?[]:d.slice(O,d.findLastIndex(m=>!p(m))+1)}).filter(d=>d.some(N))}function Dn(e){let n=[],u=p=>{for(let N of p.childNodes??[])N.tagName==="style"?n.push(N.childNodes.map(d=>d.value??"").join("")):N.tagName&&N.tagName!=="template"&&u(N)};return u(e),n.flatMap(p=>[...p.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," ").matchAll(/([^{};]*)\{/g)].map(([,N])=>N))}var Rn=(e,{tags:n=[],classes:u=[]})=>{let p=[...n.map(d=>`(?<![\\w.#-])${d}`),...u.map(d=>`\\.${d}`)],N=p.length?new RegExp(`(?:${p.join("|")})(?![\\w-])`,"i"):null;return!!N&&e.some(d=>N.test(d))};function Fn(e){let n=[],u=p=>{for(let N of p.childNodes??[])N.tagName==="script"?n.push(N.childNodes.map(d=>d.value??"").join("")):N.tagName&&N.tagName!=="template"&&u(N)};return u(e),n.join(`
3
- `)}var fe=["contains-task-list","task-list-item"],de=["task-list-item"],bs=["task-list-item-checkbox"],ue=(e,n)=>C(e).every(u=>n.includes(u));function ks(e){let n=e.childNodes.find(u=>!V(u));return n?.tagName==="input"&&G(n,["type","checked","disabled","class"])&&w(n,"type")?.toLowerCase()==="checkbox"&&ue(n,bs)&&n.sourceCodeLocation?.startTag?n:null}var Ls=e=>e.tagName==="li"&&ue(e,de)&&w(e,ie)===void 0&&e.sourceCodeLocation?.startTag&&ks(e),Gn=e=>e.tagName==="ul"&&ue(e,fe)&&y(e).length>0&&e.childNodes.every(n=>n.tagName==="li"||V(n))&&y(e).every(Ls),Kn={classes:[...new Set([...fe,...de,...bs])]},Hn=/checkbox|task-list/i,ne=e=>e.tagName==="ol"&&(w(e,"data-doc-chart")==="flow"||w(e,"data-flow")!==void 0&&w(e,"data-doc-chart")===void 0),Wn=e=>e?.tagName==="ol"&&!ct(e)&&(C(e).includes(ht)||ne(e)),Pn=e=>e.tagName==="li"&&Wn(e.parentNode),At="doc-icon",Un=e=>e.some(n=>n.tagName==="strong"||n.tagName==="b")&&e.every(n=>n.tagName==="strong"||n.tagName==="b"||R(n)&&jt.test(n.value)||n.nodeName==="#comment"),zn=/^(?:inherit|unset|currentcolor|none)$/i,qn=/^(?:inherit|initial|unset|revert|revert-layer|transparent|none)$/i,U=e=>e.replace(/\s+/g," ").trim(),ts=/^\s*--doc-(?:table-height|span)\s*:/i;function oe(e){let n=e.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," "),u=[],p="",N=0,d=0;for(let O=0;O<=n.length;O++){let m=n[O];p?m==="\\"?O++:m===p&&(p=""):m==='"'||m==="'"?p=m:m==="("?N++:m===")"?N=Math.max(0,N-1):(m===";"&&N===0||O===n.length)&&(u.push(n.slice(d,O)),d=O+1)}return u.filter(O=>O.trim())}function ys(e){let n=new Map;for(let c of oe(e)){let $=c.indexOf(":"),i=U($<0?c:c.slice(0,$)).toLowerCase();n.set(i==="background-color"?"background":i,$<0?"":U(c.slice($+1).replace(/!\s*important\s*$/i,"")))}let u=[],p=[],N,d,O=new Set,m=(c,$,i)=>{if((c==="color"?zn:qn).test($))return;let f=yn($);if(!f||f.a===0&&c==="color"){u.push(c);return}if(f.a===0)return;let g=i($,{nearest:!0})?.replace(/_background$/,"");if(!g||!Cn.has(g)){p.push(`${c} ${$} left out: the ${c==="color"?"text's":"page's"} own is the nearest`);return}return i($)?.replace(/_background$/,"")!==g&&p.push(`${c} ${$} written as the kit's ${g}${c==="color"?"":" highlight"}`),g};for(let[c,$]of n)c==="color"?N=m(c,$,vn):c==="background"?d=m(c,$,Ln):c==="font-weight"&&/^(?:bold|bolder|[6-9]\d\d)$/i.test($)?O.add("strong"):c==="font-style"&&/^(?:italic|oblique)\b/i.test($)?O.add("em"):(c==="text-decoration"||c==="text-decoration-line")&&/^(?:(?:underline|line-through|solid)\s*)+$/i.test($)&&/underline|line-through/i.test($)?(/underline/i.test($)&&O.add("u"),/line-through/i.test($)&&O.add("s")):u.push(c);if(u.length)return{foreign:[...new Set(u)]};let L=[];N&&L.push([`<span class="doc-text-${N}">`,"</span>"]),d&&L.push([`<span class="doc-highlight-${d}">`,"</span>"]);for(let c of["strong","em","u","s"])O.has(c)&&L.push([`<${c}>`,`</${c}>`]);return{open:L.map(([c])=>c).join(""),close:L.map(([,c])=>c).reverse().join(""),notes:p}}var es=/^(?:language|lang)-([\w#+.-]+)$/,Jn=new Set(["data-language","data-lang","data-block-id"]),Vn=[{name:Je,names:[Je,"data-start"],value:e=>rn(e)?.toString()??null,says:"the number of its first line is a whole number from 1"},{name:"data-line-numbers",names:["data-line-numbers"],value:e=>/^\s*(?:true|false)\s*$/i.test(e)?e.trim().toLowerCase():null,says:"false hides its line numbers, true shows them"},{name:qe,names:[qe],value:e=>ln(U(e))?U(e):null,says:"its folded lines are their numbers from 1, spaces between"}],ss="data-title",ns="data-wrap",Xn=e=>y(e).length===1&&y(e)[0].tagName==="code"&&e.childNodes.every(n=>n.tagName||V(n))?y(e)[0]:null,Zn=new Set(["a","abbr","b","bdi","bdo","cite","code","data","del","dfn","em","font","i","ins","kbd","mark","q","s","samp","small","span","strike","strong","sub","sup","time","tt","u","var","br","wbr"]),Qn=new Set(["code","kbd","samp","tt","var"]);function vs(e){for(let n of e.childNodes){if(R(n))continue;if(!n.tagName)return"a comment in its <figcaption>";if(["img","picture","svg"].includes(n.tagName))return"a picture in its <figcaption>";if(!Zn.has(n.tagName))return`a <${n.tagName}> in its <figcaption>`;if(!n.sourceCodeLocation?.startTag||!(n.sourceCodeLocation.endTag||ee.has(n.tagName)))return`a <${n.tagName}> not closed in its <figcaption>`;let u=vs(n);if(u)return u}return""}function os(e){let n=y(e),u=n.filter(L=>L.tagName==="pre"),p=n.filter(L=>L.tagName==="figcaption");if(!u.length)return null;let[N]=u,[d=null]=p,O=e.childNodes.find(L=>!L.tagName&&!V(L)),m=u.length>1||p.length>1||n.length>u.length+p.length?"more than the pre and one <figcaption> in its <figure>":O?R(O)?"words in its <figure> outside its caption":"a comment in its <figure>":d?Z(d).length?`its <figcaption> has an attribute of its own (${Z(d).join(", ")})`:d.sourceCodeLocation?.endTag?vs(d):"its <figcaption> is not closed in the file":"";return m?{pre:N,caption:d,why:m}:{pre:N,caption:d}}function It(e){let n=(e.attrs??[]).filter(({value:p})=>p.trim()),u=e.tagName==="abbr";return n.map(p=>`${p.name} ${JSON.stringify(U(p.value))} dropped: ${u&&p.name==="title"?"write the full name in the text":"write it in the text if the reader needs it"}`)}var z=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;");function Yn(e){let n=new Set,u=p=>{for(let N of p.childNodes??[])if(N.tagName){for(let d of[tt,fs])w(N,d)!==void 0&&n.add(w(N,d));u(N.tagName==="template"?N.content:N)}};return u(e),n}function to(e){let n=new Map,u=p=>{for(let N of p.childNodes??[]){if(!N.tagName)continue;let d=w(N,"id");d!==void 0&&n.set(d,(n.get(d)??0)+1),u(N.tagName==="template"?N.content:N)}};return u(e),n}var eo=/^[A-Za-z][\w-]{0,63}$/;function so(e){let n=Ge(e),u=rt(n,{sourceCodeLocationInfo:!0}),p=bt(u);if(!p)return{text:n,changes:[]};let N=[],d=[],O=t=>n.slice(0,t).split(`
4
- `).length,m=(t,s,o=[],l={})=>{let a=O(t.sourceCodeLocation.startOffset);o.length||d.push({line:a,rule:s,...l});for(let r of o)d.push({line:a,rule:s,note:r,...l})},L=0,c=(t,s,o,{opens:l=null,closes:a=null,move:r=null,leaves:h=!1}={})=>N.push({start:t,end:s,text:o,order:L++,opens:l,closes:a,move:r,leaves:h}),$=(t,s,o,l)=>{c(t,t,o,{opens:s}),c(s,s,l,{closes:t})},i=t=>t.sourceCodeLocation?.startTag,f=t=>t.sourceCodeLocation?.endTag,g=(t,s,{drop:o=[]}={})=>{let l=C(t).filter(h=>!o.includes(h)),a=[...l,...s.filter(h=>!l.includes(h))],r=t.sourceCodeLocation.attrs?.class;if(a.join(" ")!==C(t).join(" "))if(r&&a.length)c(r.startOffset,r.endOffset,`class="${z(a.join(" "))}"`);else if(r)x(t,"class");else{let h=i(t).startOffset+1+t.tagName.length;c(h,h,` class="${z(a.join(" "))}"`)}},x=(t,s)=>{let o=t.sourceCodeLocation.attrs[s],l=o.startOffset;for(;/[ \t\n\r\f]/.test(n[l-1]??"");)l--;c(l,o.endOffset,"")},T=(t,s,{classes:o=[],drop:l=[]}={})=>{let a=t.sourceCodeLocation,r=Object.entries(a.attrs??{}).filter(([v])=>v!=="class"&&!l.includes(v)).map(([,v])=>` ${n.slice(v.startOffset,v.endOffset)}`).join(""),h=[...o,...C(t).filter(v=>!o.includes(v))];return`<${s}${h.length?` class="${z(h.join(" "))}"`:""}${r}>`},M,q=t=>Rn(M??=Dn(u),t),Q,As=t=>t.test(Q??=Fn(u)),K=(t,s,o)=>{c(i(t).startOffset,i(t).endOffset,s),f(t)&&c(f(t).startOffset,f(t).endOffset,o)},Mt=t=>K(t,"",""),W=t=>!!(i(t)&&(f(t)||t.tagName==="img")),he,ge=t=>{let s=w(t,"id");if(t.tagName!=="dialog"||!G(t,["id"])||!eo.test(s??"")||!W(t))return!1;let o=y(t);return!(o.length?gs.has(o[0].tagName)&&W(o[0]):t.childNodes.some(a=>!V(a)&&a.nodeName!=="#comment"))||o.some(a=>a.tagName==="form")?!1:(he??=to(u),he.get(s)===1)},_s=t=>{let s=y(t)[0];return!pt(s,Yt.short)||Z(s).length?null:t.childNodes.slice(0,t.childNodes.indexOf(s)).every(V)?s:null},pe=t=>t.tagName==="dialog"&&(C(t).includes("doc-dialog")||ge(t)),Dt=(t,s=[])=>{for(let o of t.childNodes??[])if(o!==p){if(it(o)){at(o).forEach(l=>Dt(l,s));continue}pe(o)&&W(o)?s.push(o):Dt(o,s)}return s},Rt=f(p)?Dt(u):[],Ne,js=t=>(Ne??=new Set((function s(o,l=[]){for(let a of o.childNodes??[])if(a.tagName){if(it(a)){at(a).forEach(r=>s(r,l));continue}pe(a)&&l.push(w(a,"id")),s(a,l)}return l})({childNodes:[p,...Rt]})),/^#./.test(t??"")&&Ne.has(t.slice(1))),Bs=t=>{let[s,...o]=y(t);if(!s||o.length||!C(s).includes("doc-dialog-panel"))return null;let[l,a,...r]=y(s);if(r.length||!l||!a||!C(l).includes(dt.header)||!C(a).includes("doc-dialog-content"))return null;let h=S=>S.childNodes.some(_=>!_.tagName&&!V(_)&&_.nodeName!=="#comment");if(h(s)||h(l)||!W(l)||!i(a))return null;let v=y(l),k=v.filter(S=>C(S).includes(dt.title)),I=v.filter(S=>!k.includes(S)),A=S=>(C(S).includes(dt.close)||w(S,dt.closeAttribute)!==void 0)&&W(S);return k.length!==1||!W(k[0])||I.length>1||!I.every(A)?null:{header:l,title:k[0],close:I[0]??null,content:a}},Nt,Oe=(t,s=[])=>{for(let o of t.childNodes??[])if(o.tagName){for(let{name:l,value:a}of o.attrs)l!=="id"&&l!=="class"&&s.push(a);(o.tagName==="script"||o.tagName==="style")&&s.push(o.childNodes.map(l=>l.value??"").join("")),Oe(o,s)}return s},Ms=(t,s)=>{Nt??=Oe(u).join(`
5
- `);let o=0;for(let l=Nt.indexOf(t);l>=0;l=Nt.indexOf(t,l+t.length))!/[\w-]/.test(Nt[l-1]??"")&&!/[\w-]/.test(Nt[l+t.length]??"")&&o++;return o>(s?1:0)};function Ds(t){let s=Bs(t);if(!s)return;let{header:o,title:l,close:a,content:r}=s,h=w(l,"id"),v=!!h&&w(t,"aria-labelledby")?.trim()===h;v&&x(t,"aria-labelledby"),c(i(o).startOffset,i(o).endOffset,n.slice(i(r).startOffset,i(r).endOffset));let k=i(l).startOffset+1;c(k,k+l.tagName.length,"h3"),g(l,[],{drop:[dt.title]}),h!==void 0&&!(h&&Ms(h,v))&&x(l,"id"),c(f(l).startOffset,f(l).endOffset,"</h3>"),a&&c(a.sourceCodeLocation.startOffset,a.sourceCodeLocation.endOffset,""),c(f(o).startOffset,f(o).endOffset,""),c(i(r).startOffset,i(r).endOffset,"")}let Ft=t=>{for(let s of t.childNodes??[]){if(it(s)){at(s).forEach(Ft);continue}s.tagName&&pt(s,Yt.match)&&Ds(s),Ft(s)}},$e=new Set;function we(t){let s=t.tagName;if(!W(t))return!1;let o=[];if(s==="mark"&&G(t,[]))K(t,'<span class="doc-highlight-yellow">',"</span>");else if((s==="del"||s==="strike")&&G(t,["cite","datetime"]))K(t,"<s>","</s>"),o=It(t);else if(s==="ins"&&G(t,["cite","datetime"]))K(t,"<u>","</u>"),o=It(t);else{if(["kbd","samp","tt","var"].includes(s)&&G(t,[]))return K(t,"<code>","</code>"),$e.add(t),m(t,s),!0;if(s==="a"&&G(t,["href"])&&js(w(t,"href")))return g(t,[$n]),m(t,"dialog link"),!1;if(s==="small"&&G(t,[]))K(t,'<span class="doc-text-gray">',"</span>");else if(s==="q"&&G(t,["cite"]))K(t,"\u201C","\u201D"),o=It(t);else if(["abbr","cite","dfn","time","bdi","data"].includes(s)&&G(t,["title","datetime","value"]))Mt(t),o=It(t);else if(s==="span"&&G(t,[])||s==="font"&&G(t,["color"])&&!w(t,"color")?.trim())Mt(t);else if(s==="span"&&G(t,["style"])||s==="font"&&G(t,["color"])){let l=ys(s==="span"?w(t,"style")??"":`color: ${w(t,"color")}`);if(l.foreign)return!1;K(t,l.open,l.close),o=l.notes}else return!1}return $e.add(t),m(t,s,o),!1}function Rs(t){let{startOffset:s,endOffset:o}=t.sourceCodeLocation,l=n.slice(s,o);for(let a of l.matchAll(En))$(s+a.index,s+a.index+a[0].length,'<span class="doc-math-inline">',"</span>"),d.push({line:O(s+a.index),rule:"formula"})}let Gt=new Set,be=new Set;function kt(t,s=()=>!1){for(let o of Qt(t)){if(!o.every(k=>k.tagName?i(k)&&(f(k)||ee.has(k.tagName))&&!se(k):k.sourceCodeLocation))continue;let l=o[0].sourceCodeLocation.startOffset,a=o.at(-1).sourceCodeLocation.endOffset,r=n.slice(l,a),h=l+Mn.exec(r)[0].length,v=a-/[ \t\n\r\f]*$/.exec(r)[0].length;if(o.every(R)&&wt(n.slice(h,v)))$(h,v,'<div class="doc-math-block">',"</div>"),d.push({line:O(h),rule:"display formula"}),o.forEach(k=>be.add(k));else if(s(o)){let k=Un(o);$(h,v,k?"<p>":"<p><strong>",k?"</p>":"</strong></p>"),d.push({line:O(h),rule:"step title",...Le(o[0].parentNode)}),o.forEach(I=>Gt.add(I))}else $(h,v,"<p>","</p>"),d.push({line:O(h),rule:"loose words"}),o.forEach(k=>Gt.add(k))}}let Fs=t=>t[0].parentNode.childNodes.slice(0,t[0].parentNode.childNodes.indexOf(t[0])).every(s=>!s.tagName||C(s).includes(At)),ke=new Set,Le=t=>ke.has(t.parentNode)?{}:(ke.add(t.parentNode),{note:"a step's own words written as its title, the first block of its node: <li><p><strong>\u2026</strong></p> then its content (a paragraph, a list\u2026)</li>"}),Gs=t=>{if(kt(t.childNodes,Fs),t.childNodes.filter(a=>a.tagName&&!C(a).includes(At)).length>0||Qt(t.childNodes).length>0||!i(t)||!f(t))return;let l=t.childNodes.filter(a=>a.tagName).at(-1)?.sourceCodeLocation?.endOffset??i(t).endOffset;c(l,l,"<p></p>"),d.push({line:O(l),rule:"step title",...Le(t)})},Kt,ye=()=>{Kt??=Yn(u);let t=gn(Kt);return Kt.add(t),t},Ks=(t,s)=>`<div data-doc-chart="${z(w(t,"data-doc-chart"))}" ${fs}="${z(s)}"></div>`,Ot=n.includes(`\r
6
- `)?`\r
7
- `:`
8
- `,ve=t=>/^[ \t]*/.exec(n.slice(n.lastIndexOf(`
9
- `,t-1)+1))[0];function Ce(t,s,o,l=null){let a=xe(t),r=a?ft(n,a.sourceCodeLocation.startOffset,a.sourceCodeLocation.endOffset):null,h=!!r&&(r.start!==a.sourceCodeLocation.startOffset||r.end!==a.sourceCodeLocation.endOffset),v=a?{from:i(a).endOffset,to:f(a).startOffset}:null,k=_=>`<figure class="doc-figure">${_?`<h3>${_}</h3>`:""}${Ks(t,o)}</figure>`,I=_=>v?_:_(""),A=h?`${Ot}${ve(i(s).startOffset)}`:"",S=!!(l??f(s));if(S){let _=l?f(t).endOffset:f(s).endOffset;c(_,_,I(F=>`${l??""}${A}${k(F)}`),{closes:i(s).startOffset,move:v}),d.push({line:O(_),rule:"chart",key:o})}else c(i(s).startOffset,i(s).startOffset,I(_=>`${k(_)}${A}`),{opens:i(s).endOffset,move:v}),d.push({line:O(i(s).startOffset),rule:"chart",key:o});return r&&c(r.start,r.end,""),S&&!!l}let[Hs]=Qe,xe=t=>{let s=t.childNodes.find(o=>!V(o));return s?.tagName!=="caption"||!W(s)||Z(s).length>0||!et(s)||!s.childNodes.every(o=>R(o)||o.tagName&&!ps.has(o.tagName)&&!Ns.has(o.tagName)&&!se(o))||s.childNodes.every(R)&&wt(n.slice(i(s).endOffset,f(s).startOffset))||q({tags:["caption"]})?null:s},Ws=t=>{let s=w(t,"rowspan");return s===void 0||/^\s*\d+\s*$/.test(s)&&Number(s)===1},Ps=t=>(w(t,"scope")??"").trim().toLowerCase()==="row";function Us(t){let s=y(t).filter(h=>["thead","tbody","tfoot"].includes(h.tagName)),o=s.flatMap(h=>y(h)).flatMap(h=>y(h)).filter(h=>h.tagName==="th"&&i(h)),l=!q({tags:["th","thead"]});if(l)for(let h of o)Ps(h)||g(h,ae.some(v=>C(h).includes(v))?[Hs]:Qe);let a=l||!o.length?[]:["its th as written (no header look, no thead): the document's own <style> styles th"],r=h=>h.length>0&&h.every(v=>v.tagName==="tr"&&W(v));for(let h of s){let v=y(h);if(h.tagName!=="tbody"||!r(v))continue;let[k,...I]=v,A=l&&s.length===1&&I.length>0&&y(k).length>0&&y(k).every(F=>F.tagName==="th"&&Ws(F)),S=i(h);if(S){if(!A||!f(h))continue;c(S.startOffset,S.endOffset,"<thead>"),c(k.sourceCodeLocation.endOffset,k.sourceCodeLocation.endOffset,`</thead>${n.slice(S.startOffset,S.endOffset)}`),m(k,"header row");continue}A&&($(k.sourceCodeLocation.startOffset,k.sourceCodeLocation.endOffset,"<thead>","</thead>"),m(k,"header row"));let _=A?I:v;$(_[0].sourceCodeLocation.startOffset,_.at(-1).sourceCodeLocation.endOffset,"<tbody>","</tbody>")}return a}let Ht,zs=()=>{Ht??=(function s(o,l=new Set){for(let a of o.childNodes??[])a.tagName&&(w(a,"data-doc-sheets")!==void 0&&l.add(w(a,"data-doc-sheets")),s(a.tagName==="template"?a.content:a,l));return l})(u);let t=1;for(;Ht.has(`tabs-${t}`);)t++;return Ht.add(`tabs-${t}`),`tabs-${t}`},Se=new Set,qs=t=>{let s=[],o=a=>a.childNodes.map(r=>R(r)?r.sourceCodeLocation?n.slice(r.sourceCodeLocation.startOffset,r.sourceCodeLocation.endOffset):r.value:r.tagName?(i(r)&&s.push(U(n.slice(i(r).startOffset,i(r).endOffset))),r.tagName==="br"?" ":o(r)):"").join(""),l=a=>a.childNodes.map(r=>R(r)?r.value:r.tagName==="br"?" ":r.tagName?l(r):"").join("");return{raw:U(o(t)),plain:U(l(t)),left:[...new Set(s)]}},Js=(t,s,o)=>{let l=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,48).replace(/-+$/,"")||`tab-${s+1}`,a=l;for(let r=2;o.has(a);r++)a=`${l}-${r}`;return o.add(a),a};function Vs(t,s){let o=un(n),l=Ve[o]??Ve.zh,a=w(t,"data-doc-sheets")?.trim()?null:zs(),r=new Set,h=[],v=s.map(({section:I,heading:A},S)=>{let{raw:_,plain:F,left:Y}=qs(A),st=Js(F,S,r);Z(A).length&&h.push(`${Z(A).join(", ")} of the heading "${F}" left out: a tab is its name alone`);for(let nt of Y)h.push(`${nt} in the heading "${F}" left out: a tab's name is plain text`);K(I,`<div data-doc-sheet="${st}">`,"</div>"),Se.add(A);let{startOffset:J,endOffset:X}=A.sourceCodeLocation,P=ft(n,J,X);return c(P.start,P.end,Ot.repeat(n.slice(P.start,P.end).split(`
10
- `).length-1)),We({sheet:st,title:_})}),k=T(t,t.tagName,{classes:["doc-sheet-shell"],drop:a?["data-doc-sheets"]:[]});a&&(k=k.replace(/>$/,` data-doc-sheets="${a}">`)),w(t,"aria-label")===void 0&&(k=k.replace(/>$/,` aria-label="${l}">`)),c(i(t).startOffset,i(t).endOffset,`${k}<div class="doc-sheet-tabs" aria-label="${l}">${v.join("")}</div>`),m(t,"sheets",h)}let Xs=t=>{let s=y(t)[0];return y(t).length===1&&s.tagName==="a"&&C(s).join(" ")==="doc-bookmark"&&G(s,["class","href","title","target","rel"])&&!!w(s,"href")?.trim()&&W(s)&&s.childNodes.every(R)&&t.childNodes.every(o=>o===s||V(o))};function Zs(t){let s=y(t)[0],o=w(s,"href").trim(),l=U(w(s,"title")??""),a=o;try{a=new URL(o).hostname||o}catch{}let r=[],h=w(s,"target");h!==void 0&&h.trim()!=="_blank"&&r.push(`target ${JSON.stringify(U(h))} left out: a bookmark opens its page in a new tab`);let v=w(s,"rel");v!==void 0&&v.split(/\s+/).some(A=>A&&!["noopener","noreferrer"].includes(A.toLowerCase()))&&r.push(`rel ${JSON.stringify(U(v))} left out: a bookmark's link is rel="noopener noreferrer"`),c(i(t).startOffset,i(t).endOffset,T(t,"figure",{classes:["doc-bookmark"]}));let k=et(s)?"":mt(a);c(i(s).startOffset,i(s).endOffset,`<a class="doc-bookmark-card" href="${z(o)}" target="_blank" rel="noopener noreferrer"><span class="doc-bookmark-text"><span class="doc-bookmark-title">${k}`);let I=l?`<span class="doc-bookmark-description">${mt(l)}</span>`:"";c(f(s).startOffset,f(s).endOffset,`</span>${I}<span class="doc-bookmark-url"><span class="doc-bookmark-href">${mt(o)}</span></span></span></a>`),c(f(t).startOffset,f(t).endOffset,"<figcaption></figcaption></figure>"),m(t,"bookmark",r)}let Qs=t=>{let s=t?.parentNode;if(!t?.tagName||!C(t).includes("doc-column")||!s?.tagName||!C(s).includes("doc-columns"))return null;let o=r=>Number(/--doc-column-ratio\s*:\s*(\d*\.?\d+)/i.exec(w(r,"style")??"")?.[1]??1)||1,l=y(s).filter(r=>C(r).includes("doc-column")),a=l.reduce((r,h)=>r+o(h),0);return(Tt-hn*(l.length-1))/Tt*(o(t)/a)},Wt=(t,s,o)=>{let l=w(t,"width"),a=/^\s*(\d+(?:\.\d+)?)\s*(px|%)?\s*$/i.exec(l??""),r=(s?w(s,"style")??"":"").trim().replace(/;\s*$/,""),h=t.sourceCodeLocation.attrs?.width;if(!a||!h||/--doc-span\s*:/i.test(r))return null;let v=a[2]==="%",k=v?Qs(o):null,I=v?Number(a[1])/100*(k??1):Number(a[1])/Tt,A=Math.round(Math.min(ut.max,Math.max(ut.min,I))*1e3)/1e3,S=h.startOffset;for(;/[ \t\n\r\f]/.test(n[S-1]??"");)S--;c(S,h.endOffset,"");let _=I<ut.min||I>ut.max?`, within ${ut.min} to ${ut.max}`:"",F=v?k===null?"a share of the width it stands in":`a share of the width it stands in, its column ${Math.round(k*1e3)/1e3} of the reading width`:`${Number(a[1])}px of the ${Tt}px reading width`;return{attribute:` style="${z(`${r?`${r}; `:""}${Ze}: ${A}`)}"`,note:`width="${l}" written as ${Ze}: ${A} on its figure (${F}${_}; at most the width it stands in)`}},Pt=(t,s)=>{let o=t?T(t,"figure",{classes:["doc-image"],drop:s?.attribute?["style"]:[]}):'<figure class="doc-image">';return s?.attribute?`${o.slice(0,-1)}${s.attribute}>`:o},Ys=t=>y(t).filter(s=>s.tagName==="img").length===1&&y(t).every(s=>s.tagName==="img"||s.tagName==="figcaption")&&t.childNodes.every(s=>s.tagName||V(s)),tn=t=>y(t).length===1&&y(t)[0].tagName==="img"&&t.childNodes.every(s=>s.tagName||V(s)),en=t=>t.childNodes.length>0&&t.childNodes.every(R)&&wt(n.slice(i(t).endOffset,f(t).startOffset)),Ut=new Set,Te=()=>q(Kn)||As(Hn),Ee=t=>Gn(t)&&!Te();function Ie(t,s=null,o=null,l=[]){let a=Xn(t),r=[t,a].filter(Boolean),h=[s,...r].filter(Boolean),v=r.flatMap(C).map(b=>es.exec(b)?.[1]).find(Boolean)??h.map(b=>w(b,"data-language")??w(b,"data-lang")).find(Boolean),k=b=>h.find(E=>E.sourceCodeLocation.attrs?.[b]),I=(b,E)=>{let B=b?.sourceCodeLocation.attrs[E];return B?` ${n.slice(B.startOffset,B.endOffset)}`:""},A=k("id"),S=[...l],_=new Map(h.map(b=>[b,new Set])),F=b=>b.flatMap(E=>h.filter(B=>w(B,E)!==void 0).map(B=>(_.get(B).add(E),{element:B,name:E,value:w(B,E)}))),Y=(b,E)=>S.push(`${b.name} ${JSON.stringify(U(b.value))} left out (its <${b.element.tagName}>'s): ${E}`),st=Vn.flatMap(({name:b,names:E,value:B,says:H})=>{let ot=F(E),D=ot.find(j=>B(j.value)!==null);for(let j of ot)j!==D&&Y(j,B(j.value)===null?H:`the block takes its <${D.element.tagName}>'s ${D.name}`);return D?[` ${b}="${z(B(D.value))}"`]:[]}),J=F([ns]),X=J.find(b=>/^\s*(?:true|false)\s*$/i.test(b.value));for(let b of J)b!==X&&Y(b,X?`the block takes its <${X.element.tagName}>'s ${ns}`:"false keeps its long lines on one line (they scroll), true wraps them");let P=X?X.value.trim().toLowerCase()==="false":r.some(b=>C(b).includes(Zt)),nt=r.flatMap(C).find(b=>xn.includes(b)),je=F([ss]),yt=o?null:je[0],Be=yt?mt(U(yt.value)):"";for(let b of je)b!==yt&&Y(b,o?"its caption is its title":`the block takes its <${yt.element.tagName}>'s ${ss}`);let Me=b=>Object.keys(b.sourceCodeLocation.attrs??{}).filter(E=>E!=="class"&&!Jn.has(E)&&!(E==="id"&&b===A)&&!_.get(b).has(E)),De=b=>{let E=C(b).filter(j=>!es.test(j)&&j!==Zt&&j!==nt),B=Me(b),ot=(b.attrs.find(j=>j.name==="style")?.value??"").split(";").map(j=>j.trim()).filter(Boolean).every(j=>/^--doc-code-height\s*:/i.test(j)),D=[...E.length?[`class ${JSON.stringify(E.join(" "))}`]:[],...B.filter(j=>!(j==="style"&&ot))];return D.length&&S.push(`${D.join(", ")} kept on its <${b.tagName}>`),`<${b.tagName}${E.length?` class="${z(E.join(" "))}"`:""}${B.map(j=>I(b,j)).join("")}>`},zt=s?Me(s):[],Re=`<div class="doc-code${P?` ${Zt}`:""}${nt?` ${nt}`:""}"${I(A,"id")}${I(k("data-block-id"),"data-block-id")}${v?` data-language="${z(v.toLowerCase())}"`:""}${st.join("")}${zt.map(b=>I(s,b)).join("")}>`;zt.length&&S.push(`${zt.join(", ")} kept on the block (its <figure>'s)`);let Fe=De(t),vt=b=>a?`${b}${Fe}`:`${b}${Fe}<code>`,Ct=a&&W(a)?"</pre>":"</code></pre>",xt=b=>`<div class="doc-code-title">${b}</div>`;if(!s)K(t,vt(`${Re}${xt(Be)}`),`${Ct}</div>`);else if(K(s,Re,"</div>"),!o)K(t,vt(xt(Be)),Ct);else{let{startOffset:b,endOffset:E}=o.sourceCodeLocation,B={from:i(o).endOffset,to:f(o).startOffset},H=D=>D.replace(/[ \t\n\r\f]+/g," ").trim(),ot=(D,j)=>n.slice(D,j).split(`
11
- `).length-1;if(b<t.sourceCodeLocation.startOffset)c(b,E,D=>`${xt(H(D))}${Ot.repeat(ot(b,E))}`,{move:B}),K(t,vt(""),Ct);else{let D=ft(n,b,E),j=ot(D.start,D.end),sn=j?`${Ot.repeat(j)}${ve(i(t).startOffset)}`:"";c(i(t).startOffset,i(t).endOffset,nn=>vt(`${xt(H(nn))}${sn}`),{move:B}),c(D.start,D.end,""),f(t)&&c(f(t).startOffset,f(t).endOffset,Ct)}}if(a&&Z(a).length&&c(i(a).startOffset,i(a).endOffset,De(a)),o){let b=new Set,E=B=>{for(let H of y(B))(!Qn.has(H.tagName)||Z(H).length)&&b.add(U(n.slice(i(H).startOffset,i(H).endOffset))),ee.has(H.tagName)?c(i(H).startOffset,i(H).endOffset,H.tagName==="br"?" ":""):(Mt(H),E(H))};E(o);for(let B of b)S.push(`${B} in its caption left out: a code block's title is plain text`)}m(s??t,"code",S)}function Ae(t,s){let o=t.tagName;if(!W(t))return!1;if((o==="p"||o==="div"&&C(t).length===0)&&en(t))return K(t,T(t,"div",{classes:["doc-math-block"]}),"</div>"),m(t,"display formula"),!0;if(o==="figure"&&C(t).length===0&&Ys(t)){let r=Wt(y(t).find(h=>h.tagName==="img"),t,s);return c(i(t).startOffset,i(t).endOffset,Pt(t,r)),y(t).some(h=>h.tagName==="figcaption")||c(f(t).startOffset,f(t).startOffset,"<figcaption></figcaption>"),m(t,"figure",r?[r.note]:[]),!0}if(o==="img"&&Et.has(s?.tagName)){let r=Wt(t,null,s);return $(i(t).startOffset,i(t).endOffset,Pt(null,r),"<figcaption></figcaption></figure>"),m(t,"picture",r?[r.note]:[]),!0}if(o==="p"&&Et.has(s?.tagName)&&Xs(t))return Zs(t),!0;if(w(t,"data-doc-sheets")!==void 0){let r=mn(t)?.tabs;return r&&Vs(t,r),!1}if(o==="p"&&tn(t)){let r=Wt(y(t)[0],t,s);return K(t,Pt(t,r),"<figcaption></figcaption></figure>"),m(t,"picture",r?[r.note]:[]),!0}let l=o==="figure"&&C(t).length===0?os(t):null;if(l&&!l.why&&W(l.pre))return Ie(l.pre,t,l.caption),!0;if(o==="pre"&&!C(s??{}).includes("doc-code")){let h=s?.tagName==="figure"&&C(s).length===0&&y(s).some(k=>k.tagName==="figcaption")?os(s):null,v=h?.pre===t?h.why:"";return Ie(t,null,null,v?[`its <figure>'s caption stays a caption beside it: ${v}; a <figure> holding the pre and one <figcaption> of words alone makes them its title`]:[]),!0}if(o==="figure")return!Et.has(s?.tagName)||Tn(t)?!0:(g(t,["doc-figure"]),m(t,"figure"),ct(t));let a=o==="table"&&C(s??{}).includes("doc-table-wrap");if(o==="table"&&w(t,"data-doc-chart")!==void 0&&!Et.has((a?s.parentNode:s)?.tagName))return!1;if(o==="table"&&w(t,"data-doc-chart")!==void 0&&a&&i(s)){let r=w(s,tt)??ye();if(Ce(t,s,r),w(s,tt)===void 0){let h=i(s).endOffset-1;c(h,h,` ${tt}="${z(r)}"`)}return c(i(t).startOffset,i(t).endOffset,T(t,"table",{drop:["data-doc-chart"]})),!1}if(o==="table"&&(!ct(t)||ms(t))&&!C(s??{}).includes("doc-table-wrap")){let r=t.sourceCodeLocation.attrs?.["data-block-id"],h=w(t,"data-doc-chart")!==void 0,k=(w(t,tt)?.trim()||null)??(h?ye():null),I=w(t,"style"),A=I===void 0?[]:oe(I).filter(P=>ts.test(P)),S=A.length?oe(I).filter(P=>!ts.test(P)):[],_=P=>` style="${z(P.map(nt=>nt.trim()).join("; "))}"`,F=`<div class="doc-table-wrap"${r?` ${n.slice(r.startOffset,r.endOffset)}`:""}${k?` ${tt}="${z(k)}"`:""}${A.length?_(A):""}>`,Y=T(t,"table",{classes:["doc-table"],drop:["data-block-id",...w(t,tt)!==void 0?[tt]:[],...h?["data-doc-chart"]:[],...A.length?["style"]:[]]}),st=S.length?`${Y.slice(0,-1)}${_(S)}>`:Y,J=h?null:xe(t),X=!1;if(h&&(X=Ce(t,t,k,"</div>")),J){let P=n.slice(i(t).endOffset,J.sourceCodeLocation.startOffset);c(i(t).startOffset,i(J).endOffset,'<p class="doc-note">'),c(f(J).startOffset,f(J).endOffset,`</p>${P}${F}${st}`),m(J,"caption")}else c(i(t).startOffset,i(t).startOffset,F,{opens:f(t).endOffset}),c(i(t).startOffset,i(t).endOffset,st);return X||c(f(t).endOffset,f(t).endOffset,"</div>",{closes:i(t).startOffset}),m(t,"table",Us(t)),!1}if(o==="details"&&Ye(t)){let r=y(t)[0]?.tagName==="summary"?y(t)[0]:null;return!r||!W(r)||(c(i(t).startOffset,i(t).endOffset,T(t,"details",{classes:["doc-details"]})),y(r).some(h=>C(h).includes("doc-details-summary-label"))||$(i(r).endOffset,f(r).startOffset,'<span class="doc-details-summary-label">',"</span>"),$(f(r).endOffset,f(t).startOffset,'<div class="doc-details-content">',"</div>"),kt(t.childNodes.slice(t.childNodes.indexOf(r)+1)),m(t,"details")),!1}if(o==="dialog"&&ge(t)){let r=_s(t);return c(i(t).startOffset,i(t).endOffset,T(t,"dialog",{classes:["doc-dialog"]})),$(i(t).endOffset,f(t).startOffset,'<div class="doc-dialog-panel"><div class="doc-dialog-content">',"</div></div>"),r&&K(r,"<h3>","</h3>"),kt(t.childNodes.slice(r?t.childNodes.indexOf(r)+1:0)),m(t,"dialog"),!1}if(o==="aside"&&Ye(t)&&!q({tags:["aside"]}))return g(t,["doc-panel"]),Ut.add(t),m(t,"aside"),!1;if(o==="ul"&&Ee(t)){g(t,[te],{drop:fe});for(let r of y(t))_e(r);return m(t,"task list"),!1}if(ne(t)&&!ct(t))return c(i(t).startOffset,i(t).endOffset,T(t,"ol",{classes:[ht],drop:["data-doc-chart","data-flow"]})),m(t,"flowchart"),!1;if(o==="ul"&&C(t).includes(te)&&!ct(t)){let r=y(t).filter(Ls);if(r.length&&!Te()){for(let h of r)_e(h);m(t,"task list")}return!1}return!1}function _e(t){let s=ks(t);if(g(t,[],{drop:de}),w(s,"checked")!==void 0){let a=i(t).startOffset+1+t.tagName.length;c(a,a,` ${ie}`)}let{startOffset:o,endOffset:l}=s.sourceCodeLocation;c(o,l+(n[l]===" "?1:0),"")}function $t(t,s=null,o=!1){let l=()=>Qt(t.childNodes).length>0;$s(t)&&(ws(t)||(Ut.has(t)||Bn(t))&&l())?kt(t.childNodes):Pn(t)&&i(t)&&Gs(t);for(let a of t.childNodes??[]){if(R(a)){a.sourceCodeLocation&&a.value.includes("\\(")&&!be.has(a)&&Rs(a);continue}if(!(!a.tagName||ce.has(a.tagName)||Se.has(a))){if(it(a)){for(let r of at(a))Ut.add(r),$t(r,r);continue}if(!(w(a,"data-doc-chart")!==void 0&&a.tagName!=="table"&&!ne(a)||w(a,"contenteditable")!==void 0)&&!C(a).some(r=>_t.includes(r))){if(a.tagName==="pre"){Ae(a,t);continue}if(!(le(a)&&!Ee(a))){if(Gt.has(a)){we(a)||$t(a,a,!0);continue}Ae(a,t)||o&&we(a)||$t(a,a,o||re.has(a.tagName))}}}}}$t(p,p),$t({childNodes:Rt}),n.includes(dt.header)&&Ft(u);for(let t of Rt){let{startOffset:s,endOffset:o}=t.sourceCodeLocation,l=ft(n,s,o),a=f(p).startOffset,r=l.end>o?qt(n,a):null;c(a,a,h=>r===null?h:`${h}${Ot}${r}`,{move:{from:s,to:o}}),c(l.start,l.end,"",{leaves:!0}),m(t,"card outside main")}if(!N.length)return{text:n,changes:[]};let Lt=N;for(let t of N.filter(s=>s.move)){let{from:s,to:o}=t.move,l=Lt.filter(a=>!a.move&&!a.leaves&&a.start>=s&&a.end<=o);Lt=Lt.filter(a=>!l.includes(a)),t.text=t.text(as(n.slice(s,o),l,s)),t.move=null}return{text:as(n,Lt),changes:d.sort((t,s)=>t.line-s.line)}}function as(e,n,u=0){let p=m=>m.closes!==null?0:m.opens!==null?2:1,N=(m,L)=>p(m)-p(L)||(m.closes!==null?L.closes-m.closes||L.order-m.order:0)||(m.opens!==null?L.opens-m.opens:0)||m.order-L.order,d=[...n].sort((m,L)=>L.start-m.start||L.end-m.end||(m.start===m.end?N(L,m):L.order-m.order)),O=e;for(let{start:m,end:L,text:c}of d)O=O.slice(0,m-u)+c+O.slice(L-u);return O}function Cs(e,{finish:n=u=>u}={}){let{text:u,changes:p}=so(e);return{text:p.length?n(u):u,changes:p}}function Mo(e,{finish:n,next:u,metadata:p=null}={}){let N=Xt(e);if(N.length)return{text:e,changes:[],added:0,given:[],repeated:N,title:null,icon:null};let d=Cs(e,{finish:n}),{text:O,added:m,given:L}=Pe(d.text,u),c=xs(O,p);return{...c,changes:d.changes,added:m,given:ze(c.text,L),repeated:N}}function Do(e){return Xt(e).length?[]:Ue(Cs(e).text)}function xs(e,n=null){let u=rt(e,{sourceCodeLocationInfo:!0}),p=bt(u),N=p&&gt(p,c=>pt(c,ds.title)),d=N?.sourceCodeLocation?.endTag?St(e.slice(N.sourceCodeLocation.startTag.endOffset,N.sourceCodeLocation.endTag.startOffset)):"",O=e,m=null;if(d){let c=gt(u,x=>x.tagName==="head"),i=(c&&gt(c,x=>x.tagName==="title"))?.sourceCodeLocation,f=typeof n?.title=="string"?n.title:null,g=!1;if(i?.startTag&&i.endTag){let x=St(e.slice(i.startTag.endOffset,i.endTag.startOffset));if(!(f&&f!==d&&f.includes(d)?x.split(f).join("\0").includes(d):x.includes(d))){let M=f&&f!==d&&He(e,{from:f,to:d})||{start:i.startTag.endOffset,end:i.endTag.startOffset,text:mt(d)};O=e.slice(0,M.start)+M.text+e.slice(M.end),g=!0}}(g||f!==null&&f!==d)&&(m={from:f,to:d,page:g})}let L=null;if(p&&n&&typeof n=="object"){let c=Vt(e),$=c.units.find(g=>g.kind==="icon"&&c.boxes[g.box]?.kind==="header"),i=$?rs(e.slice($.start,$.end)):null,f=n.icon??null;$?i!==null&&i!==f&&(L={from:f,to:i}):L=f===null?null:{from:f,to:f,missing:!0}}return{text:O,title:m,icon:L}}function Ro(e,{title:n,icon:u}={}){let p=$=>{let i=bt(rt($,{sourceCodeLocationInfo:!0})),f=i&&gt(i,g=>pt(g,ds.title));return f?.sourceCodeLocation?.endTag?f.sourceCodeLocation:null},N=$=>{let i=Vt($);return i.units.find(f=>f.kind==="icon"&&i.boxes[f.box]?.kind==="header")??null},d=p(e);if(!d)return{missing:!0};let O=St(e.slice(d.startTag.endOffset,d.endTag.startOffset)),m=N(e),L={title:O,icon:m?rs(e.slice(m.start,m.end)):null},c=e;if(u!==void 0&&u!==L.icon){if(m&&u===null){let $=ft(c,m.start,m.end);c=c.slice(0,$.start)+c.slice($.end)}else if(m){let $=/\sdata-block-id="[^"]*"/.exec(/^<[^>]*>/.exec(c.slice(m.start,m.end))?.[0]??"")?.[0]??"";c=c.slice(0,m.start)+Xe(u,$)+c.slice(m.end)}else{let $=qt(c,d.startTag.startOffset);c=c.slice(0,d.startTag.startOffset)+Xe(u)+($===null?"":`
12
- ${$}`)+c.slice(d.startTag.startOffset)}d=p(c)}return n!==void 0&&(c=c.slice(0,d.startTag.endOffset)+mt(n)+c.slice(d.endTag.startOffset),c=xs(c,{title:O||null}).text),{text:c,before:L}}function Fo(e,n,{dryRun:u=!1,pending:p=!1,reread:N=!u&&!p}={}){let d=new Map;for(let{rule:L,line:c}of n)d.set(L,[...new Set([...d.get(L)??[],c])]);let O=[...d].map(([L,c])=>`${L} (line${c.length>1?"s":""} ${c.join(", ")})`).join(", "),m=an.resolve(e);return[p?`natural ${m}: ${O} not rewritten yet: the export rewrites them in this file as the kit's markup (nothing to fix)`:`natural ${m}: ${O}${u?" would be":""} rewritten in this file as the kit's markup (nothing to fix)`,...n.filter(L=>L.note).map(({line:L,rule:c,note:$})=>` line ${L}, ${c}: ${$}`),...N?[" re-read the file before editing it"]:[]]}var is="strong, em, b, i, u, s, code, a, sub, sup and br, the kit's colors (doc-text-*, doc-highlight-*) and formulas",me=`write a to-do list as ul.${te} \u203A li, li[${ie}] for a checked item (a GFM task list, every item starting with its box, is made one unless the document's own style or script uses GFM's classes or the boxes)`,Ss=e=>C(e).every(ls),Ts=e=>y(e).flatMap(n=>[...n.tagName==="span"&&!(G(n,["class"])&&Ss(n))?[n]:[],...Ts(n)]),Es=e=>y(e).some(n=>n.tagName==="img"||Es(n)),Is=e=>y(e).some(n=>n.tagName==="svg"||n.tagName==="canvas"||Is(n)),Bt=e=>y(e).some(n=>n.tagName==="input"&&w(n,"type")?.toLowerCase()==="checkbox"||Bt(n)),no=(e,n)=>{if(e==="tag:img")return"a picture amid the words: give it a paragraph of its own";if(e==="tag:span"){let u=Ts(n).filter(p=>G(p,["style","class"])&&w(p,"style")!==void 0&&Ss(p)).map(p=>ys(w(p,"style")).foreign).find(Boolean);return u?`a span with a style the kit has no format for (${u.join(", ")}): left as written`:`a <span> with a class or attribute of the document's own (the preview edits ${is})`}return e==="tag:input"&&Bt(n)?`a checkbox amid the words: ${me}`:e.startsWith("tag:")&&lt.has(e.slice(4))?`a block (<${e.slice(4)}>) amid the words: give the words a paragraph of their own`:e.startsWith("tag:")?`<${e.slice(4)}> amid the words (the preview edits ${is})`:e==="comment"?"an HTML comment amid the words":e==="markup"?"an element not closed in the file (the parser closed it)":e==="mention"?'a page block written another way: the preview edits only <a class="doc-link-mention" href="../<slug>/doc.html"><span class="doc-link-mention-icon"></span>title</a>, its title plain words, no other attribute':e==="link"?"a javascript: or data: link":e},oo=new Set([...Os,"details"]);function Go(e){let n=rt(e,{sourceCodeLocationInfo:!0}),u=bt(n);if(!u)return[];let p=$=>e.slice(0,$).split(`
13
- `).length,N=new Map,d=[],O=$=>{oo.has($.tagName)&&$.sourceCodeLocation?.startTag&&ws($)&&d.push({line:p($.sourceCodeLocation.startOffset),text:`<${$.tagName}>: words straight in it, outside any paragraph: give them a <p> (the preview cannot reach them, nor move its blocks one by one)`})},m=($,i=()=>!1)=>{for(let f of y($)){if(i(f))continue;let g=f.sourceCodeLocation?.startTag;g&&N.set(g.endOffset-1,f),m(f,i)}},L=$=>{for(let i of $.childNodes??[]){if(!i.tagName||ce.has(i.tagName))continue;if(it(i)){m(i,cs),at(i).forEach(L);continue}if(w(i,"data-doc-chart")!==void 0||C(i).some(x=>_t.includes(x))||le(i))continue;let f=i.sourceCodeLocation?.startTag;f&&N.set(f.endOffset-1,i);let g=i.sourceCodeLocation?.endTag;if(re.has(i.tagName)&&f&&i.childNodes.some(x=>R(x)&&/\\\[|\$\$/.test(x.value))&&!(g&&i.childNodes.every(R)&&wt(e.slice(f.endOffset,g.startOffset)))){let x=In(e.slice(f.endOffset,g?g.startOffset:i.sourceCodeLocation.endOffset),!!g);d.push({line:p(f.startOffset),text:x?`<${i.tagName}>: the formula holds a bare < or >: write \\lt / \\gt (or &lt; / &gt;)`:`<${i.tagName}>: a display formula (\\[\u2026\\] or $$\u2026$$) amid the words: give it a paragraph of its own`})}i.tagName==="caption"&&f&&(et(i)||y(i).length>0)&&d.push({line:p(f.startOffset),text:'<caption>: the preview cannot edit a table caption; write the line above the table as <p class="doc-note">'}),O(i),L(i)}};O(u),L(u);let c=new Set;for(let{at:$,reason:i}of Jt(e).locks){let f=N.get($);if(!f)continue;let g=i==="tag:input"&&f.tagName==="li"&&Bt(f)&&f.parentNode?.sourceCodeLocation?.startTag?f.parentNode:null;g&&c.has(g)||(g&&c.add(g),g?d.push({line:p(g.sourceCodeLocation.startOffset),text:`<${g.tagName}>: checkboxes in its items: ${me}`}):d.push({line:p(f.sourceCodeLocation.startOffset),text:`<${f.tagName}>: ${no(i,f)}`}))}return d.sort(($,i)=>$.line-i.line).map(({line:$,text:i})=>`line ${$}: ${i}`)}function Ko(e){let n=rt(e,{sourceCodeLocationInfo:!0}),u=bt(n);if(!u)return[];let p=f=>e.slice(0,f).split(`
14
- `).length,N=[],d=[],O=f=>{for(let g of f.childNodes??[])g.tagName==="style"?d.push((g.childNodes??[]).map(x=>x.value??"").join("")):O(g)};O(n);let m=d.join(`
15
- `).replace(/\/\*[\s\S]*?\*\//g,""),L=f=>new RegExp(`\\.${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`).test(m),c=f=>{for(let g of y(f).filter(x=>x.tagName==="colgroup"&&w(x,"data-doc-columns")===void 0)){let x=[g,...y(g)].filter(M=>w(M,"width")!==void 0||/(?:^|;)\s*(?:min-|max-)?width\s*:/i.test(w(M,"style")??"")),T=(g.sourceCodeLocation?g:y(g)[0])?.sourceCodeLocation;x.length&&T&&N.push({line:p(T.startOffset),text:`<${g.sourceCodeLocation?"colgroup":"col"}> widths: the kit sizes columns itself; a merged table uses yours`})}},$=f=>{for(let g of f.childNodes??[]){if(!g.tagName||ce.has(g.tagName))continue;if(it(g)){at(g).forEach($);continue}if(w(g,"data-doc-chart")!==void 0||C(g).some(T=>_t.includes(T)))continue;if(le(g)){let T=g.sourceCodeLocation,M=cn(e,g).some(({name:q})=>q==="class");if(gs.has(g.tagName)&&T?.startTag&&!M&&(et(g)||Es(g))&&!Is(g)&&!C(g).some(L)){let q=(g.tagName==="ul"||g.tagName==="ol")&&Bt(g)?`; for its checkboxes, ${me}`:"";N.push({line:p(T.startOffset),text:`<${g.tagName} class="${w(g,"class").trim()}"> is a whole block (\u6574\u4F53\u5757): the reader moves it whole and edits its words in place; right for a layout of yours that is no figure (a figure, a diagram or a timeline, goes in <figure class="doc-figure">); drop its class only if its contents were meant as ordinary blocks${q}`})}continue}g.tagName==="table"&&c(g);let x=g.tagName==="ol"&&C(g).includes(ht)?y(g).find(T=>T.tagName!=="li"&&T.sourceCodeLocation):null;if(x&&N.push({line:p(x.sourceCodeLocation.startOffset),text:`<ol class="${ht}"> holds a <${x.tagName}> outside its items: a flowchart's steps are its <li>s (what one holds after its words, a paragraph or a list, is that step's content)`}),g.tagName==="ol"&&C(g).includes(ht))for(let T of y(g).filter(M=>M.tagName==="li")){let M=y(T).find(Q=>!C(Q).includes(At)),q=M?T.childNodes.slice(0,T.childNodes.indexOf(M)):[];M&&M.tagName!=="p"&&M.sourceCodeLocation&&!q.some(Q=>!C(Q).includes(At)&&et(Q))&&N.push({line:p(M.sourceCodeLocation.startOffset),text:`a step of <ol class="${ht}"> begins with a <${M.tagName}>: a step's first block is its title, a paragraph (<p><strong>\u2026</strong></p>), the blocks after it its content`})}$(g)}};return $(u),i(u,(f,g)=>N.push({line:f,text:`a ${ao[g]} in the text: the page shows it as a break or an empty line, not as a character (a tool that decodes \\u2028 or \\u2029 escapes writes one); write the break the text means (<br>, a new paragraph, a new line in code) or take it out`})),N.sort((f,g)=>f.line-g.line).map(({line:f,text:g})=>`line ${f}: ${g}`);function i(f,g){for(let x of f.childNodes??[])if(!(x.tagName==="script"||x.tagName==="style")){if(it(x)){at(x).forEach(T=>i(T,g));continue}if(R(x)&&x.sourceCodeLocation&&/[\u2028\u2029]/.test(x.value)){let{startOffset:T,endOffset:M}=x.sourceCodeLocation,Q=e.slice(T,M).search(/[\u2028\u2029]/);g(p(T+Math.max(Q,0)),x.value.match(/[\u2028\u2029]/)[0])}i(x,g)}}}function Ho(e){let n=O=>e.slice(0,O).split(`
16
- `).length,u=O=>R(O)?O.value:(O.childNodes??[]).map(u).join(""),p=O=>u(O).replace(/\s+/g," ").trim(),N=O=>y(O).find(m=>/^h[1-6]$/.test(m.tagName)),d=[];for(let O of Jt(e).units){if(O.keep?.reason!=="script"||!O.keep.own)continue;let m=O.node.parentNode;for(;m&&m.tagName!=="section";)m=m.parentNode;let L=O.tag==="section"&&N(O.node)?` ${p(N(O.node))}`:"",c=m?.tagName&&N(m)?` in ${p(N(m))}`:"";d.push({line:n(O.elStart),text:`<${O.tag}>${L}${c} kept by the script: ${O.keep.names.join(", ")} (the reader cannot delete or convert it; rename any of these the script does not select it by)`})}return d.sort((O,m)=>O.line-m.line).map(({line:O,text:m})=>`line ${O}: ${m}`)}var ao={"\u2028":"line separator (U+2028)","\u2029":"paragraph separator (U+2029)"};function bt(e){return gt(e,n=>n.tagName==="main")}function gt(e,n){if(e.tagName&&n(e))return e;for(let u of e.childNodes??[]){let p=gt(u,n);if(p)return p}return null}export{so as a,Cs as b,Mo as c,Do as d,xs as e,Ro as f,Fo as g,Go as h,Ko as i,Ho as j};
@@ -1,2 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{spawn as G}from"node:child_process";import{existsSync as O}from"node:fs";import S from"node:fs/promises";import I from"node:os";import q from"node:path";import{APART as T}from"../browser/editor/components/registry.mjs";var _=6e4,b=600,B=["A4","A3","Letter","Legal","Tabloid"];function F(){if(process.env.GALLERY_BROWSER)return process.env.GALLERY_BROWSER;let{PROGRAMFILES:o="","PROGRAMFILES(X86)":e="",LOCALAPPDATA:r="",HOME:i=""}=process.env;return({win32:[`${o}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Google\\Chrome\\Application\\chrome.exe`,`${r}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Microsoft\\Edge\\Application\\msedge.exe`,`${o}\\Microsoft\\Edge\\Application\\msedge.exe`],darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Chromium.app/Contents/MacOS/Chromium",...i?[`${i}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,`${i}/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`,`${i}/Applications/Chromium.app/Contents/MacOS/Chromium`]:[]],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome","/usr/bin/microsoft-edge","/usr/bin/microsoft-edge-stable","/opt/microsoft/msedge/msedge","/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"]}[process.platform]??[]).find(s=>s&&O(s))??null}var $=()=>process.getuid?.()===0?["--no-sandbox"]:[],Z=()=>["--no-first-run","--no-default-browser-check","--disable-extensions","--hide-scrollbars","--lang=zh-CN",...$()];function ee(o,e,r=[]){let i=o.location()?.url??"";return!/^Failed to load resource|^Refused to |Content Security Policy/.test(o.text())&&(!i||i.startsWith(e)||r.includes(i))}var te=o=>o.evaluateOnNewDocument(()=>{globalThis.__qaViolations=[],document.addEventListener("securitypolicyviolation",e=>{globalThis.__qaViolations.push({url:e.blockedURI,directive:e.effectiveDirective||e.violatedDirective,source:e.sourceFile,line:e.lineNumber})})}),N=3e4,E=o=>new Promise(e=>setTimeout(e,o).unref()),R=o=>String(o??"").replace(/\s+/g," ").trim(),M=o=>{let e=o.split(/\r?\n/).map(R).filter(Boolean).at(-1);return e?`: ${e.slice(0,200)}`:""};async function oe({executablePath:o,args:e=[],attempts:r=2,start:i=V}){let l=[];for(let s=0;s<r;s+=1){let a=await S.mkdtemp(q.join(I.tmpdir(),"gallery-browser-")),t=()=>S.rm(a,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{});try{let{browser:n,stop:c}=await i({executablePath:o,args:e,profile:a});return{browser:n,failures:l,close:async()=>{await c().catch(()=>{}),await t()}}}catch(n){l.push(R(n?.message??n)),await t()}}throw Object.assign(new Error(l.at(-1)??"the browser did not start"),{failures:l})}async function V({executablePath:o,args:e,profile:r,starting:i=N}){let{default:l}=await import("./chunk-GB5SOYQJ.mjs"),s=await l.defaultArgs({headless:!0,userDataDir:r,args:[...e,"--remote-debugging-port=0"]}),a=process.platform!=="win32",t=G(o,s,{stdio:["ignore","ignore","pipe"],windowsHide:!0,detached:a}),n=!1;t.on("error",()=>n||=t.pid===void 0);let c=()=>n||t.exitCode!==null||t.signalCode!==null,u=new Promise(h=>t.once("exit",h)),m=()=>{if(!c())try{a?process.kill(-t.pid,"SIGKILL"):t.kill()}catch{try{t.kill("SIGKILL")}catch{}}};process.once("exit",m);let p="",d=new Promise((h,v)=>{let P=setTimeout(()=>v(new Error(`it said nothing of its DevTools port in ${i/1e3}s${M(p)}`)),i);t.stderr.setEncoding("utf8"),t.stderr.on("data",f=>{p=`${p}${f}`.slice(-4e3);let y=/DevTools listening on (ws:\/\/\S+)/.exec(p);y&&(clearTimeout(P),h(y[1]))}),t.once("error",f=>(clearTimeout(P),v(f))),t.once("exit",(f,y)=>(clearTimeout(P),v(new Error(`it stopped (${y??`exit ${f}`}) before it opened its DevTools port${M(p)}`))))}),g=async()=>{try{c()||await Promise.race([u,E(5e3)]),m(),c()||await Promise.race([u,E(3e3)])}finally{process.off("exit",m)}},x;try{x=await l.connect({browserWSEndpoint:await d,defaultViewport:{width:800,height:600}})}catch(h){throw m(),await g(),h}return{browser:x,stop:async()=>{await Promise.race([x.close().catch(()=>{}),E(5e3)]),await g()}}}var w=null,L=0,C=0;async function W(){let o=F();if(!o)throw Object.assign(new Error("\u6CA1\u6709\u627E\u5230 Chrome \u6216 Edge\uFF1A\u5BFC\u51FA PDF \u9700\u8981\u7535\u8111\u4E0A\u88C5\u6709\u5176\u4E2D\u4E00\u4E2A\u6D4F\u89C8\u5668"),{reason:"browser"});let{default:e}=await import("./chunk-GB5SOYQJ.mjs");return e.launch({executablePath:o,headless:!0,args:["--no-first-run","--no-default-browser-check","--disable-extensions",...$()]})}async function k(o,e){clearTimeout(L),C+=1,w??=W().catch(i=>{throw w=null,i});let r=await(await w).newPage();try{return await r.emulateMediaFeatures([{name:"prefers-reduced-motion",value:"reduce"},{name:"prefers-color-scheme",value:"light"}]),await r.setViewport({width:1200,height:900}),await r.setContent(o,{waitUntil:"load",timeout:6e4}),await A(r,{changing:b}),await e(r)}finally{await r.close().catch(()=>{}),C-=1,C===0&&(L=setTimeout(async()=>{let i=w;w=null,(await i?.catch(()=>null))?.close().catch(()=>{})},_))}}async function A(o,{timeout:e=15e3,changing:r=e}={}){let i=[],l=(a,t,n=e)=>{t!==!0&&i.push(`${a} (${t===!1?`not in ${n/1e3}s`:t})`)},s=(a,t=e)=>o.evaluate(a,t).catch(n=>n.message);return l("the fonts loaded",await s(a=>Promise.race([Promise.resolve(document.fonts?.ready).then(()=>!0),new Promise(t=>setTimeout(()=>t(!1),a))]))),l("the kit's first drawing done (data-doc-drawn)",await s(a=>new Promise(t=>{let n=Date.now(),c=()=>{!globalThis.DocKit||document.documentElement.hasAttribute("data-doc-drawn")?(globalThis.DocCode?.colorAll?.(),t(!0)):Date.now()-n>a?t(!1):setTimeout(c,50)};c()}))),l("the page done changing",await s(a=>new Promise(t=>{let n=()=>[document.documentElement.scrollHeight,...[...document.querySelectorAll("[style]")].map(d=>d.getAttribute("style")),...[...document.adoptedStyleSheets??[]].flatMap(d=>[...d.cssRules].map(g=>g.cssText)),...[...document.querySelectorAll("svg, canvas")].map(d=>d.outerHTML.length),[...document.images].filter(d=>d.complete).length].join("|"),c=Date.now(),u=n(),m=0,p=()=>{let d=n();m=d===u?m+1:0,u=d,m>=3?t(!0):Date.now()-c>a?t(!1):setTimeout(p,100)};setTimeout(p,100)}),r),r),i}async function D(o){await o.evaluate(()=>{document.documentElement.setAttribute("data-doc-theme","light");for(let e of document.querySelectorAll("[data-doc-sheets]")){let r=e.querySelector(":scope > .doc-sheet-tabs");if(r){for(let i of r.querySelectorAll(":scope > .doc-sheet-tab")){let l=i.getAttribute("data-sheet-tab"),s=[...e.querySelectorAll(":scope > [data-doc-sheet]")].find(n=>n.getAttribute("data-doc-sheet")===l);if(!s)continue;s.hidden=!1,s.removeAttribute("aria-hidden"),s.style.setProperty("display","block","important");let a=r.cloneNode(!1);a.removeAttribute("id"),a.removeAttribute("role"),a.style.setProperty("break-after","avoid");let t=i.cloneNode(!0);t.removeAttribute("id"),t.setAttribute("aria-selected","true"),t.classList.add("is-active"),a.append(t),s.before(a)}r.style.setProperty("display","none","important")}}for(let e of document.querySelectorAll("details"))e.open=!0;window.dispatchEvent(new Event("resize"))}),await A(o,{changing:b})}var H={A4:793.7,A3:1122.5,Letter:816,Legal:816,Tabloid:1056},K=96;async function j(o,e){await o.emulateMediaType("print");let r=await o.evaluate(()=>Math.max(0,innerWidth-document.documentElement.clientWidth));await o.setViewport({width:Math.floor(e)+r,height:900}),await A(o,{changing:b})}function re(o,{paper:e="A4",scale:r=1}={}){let i=B.includes(e)?e:"A4",l=Math.min(2,Math.max(.1,r));return k(o,async s=>(await D(s),await j(s,(H[i]-2*K)/l),Buffer.from(await s.pdf({format:i,scale:l,printBackground:!0,margin:{top:"1in",right:"1in",bottom:"1in",left:"1in"}}))))}function ie(o){return k(o,async e=>{await D(e);let r=e.viewport(),i=await e.$$("main figure.doc-figure"),l=[];for(let s of i){let a=0;try{a=await s.evaluate(async(t,n)=>{let c=[];for(let u=t.closest(n);u;u=u.parentElement.closest(n))c.unshift(u);for(let u of c)u.style.setProperty("height","auto"),u.style.setProperty("max-height","calc(100dvh - (2 * var(--doc-dialog-margin)))"),u.showModal();return await new Promise(u=>requestAnimationFrame(()=>requestAnimationFrame(u))),c.length?Math.ceil(t.getBoundingClientRect().height):0},T),a&&(await e.setViewport({...r,height:r.height+a}),await A(e,{changing:b})),await s.evaluate(t=>t.scrollIntoView({block:"center"})),l.push(Buffer.from(await s.screenshot({type:"png"})))}catch{l.push(null)}await s.evaluate((t,n)=>{for(let c=t.closest(n);c;c=c.parentElement.closest(n))c.close(),c.style.removeProperty("height"),c.style.removeProperty("max-height"),c.getAttribute("style")||c.removeAttribute("style")},T).catch(()=>{}),a&&await e.setViewport(r).catch(()=>{})}return l})}export{F as a,Z as b,ee as c,te as d,oe as e,A as f,re as g,ie as h};
@@ -1,2 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as k}from"./chunk-SYGN7GLU.mjs";import{b as B,c as I}from"./chunk-342HXE3Q.mjs";import{a as l,b as x,c as S,d as $}from"./chunk-FDLXYYG4.mjs";import{a as y,b,g as v}from"./chunk-4FS7Z7WR.mjs";import{k as h}from"./chunk-Y6RLRPG3.mjs";import"./chunk-6RGJOMJP.mjs";import"./chunk-QJIR2BLP.mjs";import"./chunk-P2CAZPDP.mjs";import"./chunk-E7LWZRXY.mjs";import{j as u}from"./chunk-NSKUTQ5J.mjs";import{j as c,p as m,s as d,t as w,u as g}from"./chunk-AUZGSZJH.mjs";import"./chunk-BGGDRNYQ.mjs";import"./chunk-6QXGZM36.mjs";import"./chunk-UALRNVSE.mjs";import"./chunk-W3BGBJQW.mjs";import"./chunk-JVHHHGEA.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-TYK6VNAB.mjs";import"./chunk-CY2FNNAB.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-L3QKH4OK.mjs";import"./chunk-W4VKN3GF.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";async function C(L){let{slugs:o,options:M}=await u({options:["--allow-failures"],argv:L});o.length===0&&(console.error(k()),process.exit(1));let N=await h(o),s=await c(o,{prepare:l({say:!1})}),t=await y(o.filter(e=>!s.has(e)));await b(o.filter(e=>s.has(e)||t.failures.has(e))),await S(o),await $(o);let p=o.filter(e=>!s.has(e)&&!t.failures.has(e)),{built:a,exported:i,failures:n}=p.length>0?await m(p,{prepare:l({say:!1})}):{built:[],exported:[],failures:new Map};for(let[e,r]of[...s,...t.failures])n.set(e,r);await w(n,{exportNote:!0}),await N.keep(i.map(({slug:e})=>e));let R=new Map(a.map(({report:e,removed:r})=>[e.slug,r]));for(let{slug:e,bytes:r,sha256:D}of i){let f=R.get(e),j=f.length>0?`; shared scripts and styles left out (unused): ${f.join(", ")}`:"";console.log(`Exported ${B(e)} (${r.toLocaleString("en-US")} bytes, sha256 ${D})${j}`)}d(a.map(({report:e})=>e)),x(a.map(({report:e})=>e));for(let e of t.lines)console.log(e);t.written.length>0&&console.log(v(t.written));for(let{slug:e}of i)console.log(I(e));g(n,{above:!0,allow:M.has("--allow-failures")})}export{C as run};