@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
@@ -0,0 +1,10 @@
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 Je,b as Qe,c as ge,e as At,h as Xe,i as tn}from"./chunk-VFX2KNHP.mjs";import{A as Ye,B as We,C as Te,D as Q,E as Ze,a as me,g as Oe,h as He,j as Ne,l as Fe,m as wt,n as ke,o as $e,p as ne,q as Ft,r as De,s as Ve,t as vt,u as Le,v as Ge,w as Me,x as kt,y as G,z as je}from"./chunk-VS7JIGJW.mjs";import{g as Ct}from"./chunk-HDWTZ763.mjs";import{b as pe,c as he,e as Ee}from"./chunk-A55HN5OK.mjs";import{BLOCK_TYPES as Ie,COPIED_AS_ITSELF as Kn,IDENTITY as gn}from"../browser/editor/components/registry.mjs";import{copyKeys as Un}from"../browser/editor/components/figure/index.mjs";import{accepts as xe,attributeValue as An,BLOCK_TYPES as Dt,boxRole as we,CHAPTER as En,holdsStraight as On,IDENTITY as Ke,isLead as rn,SIZES as Nn,sizeValue as ln,TOGGLES as an}from"../browser/editor/components/registry.mjs";import{iconMarkup as $n,iconValueOf as Ln,validIcon as Mn}from"../browser/editor/components/icon/index.mjs";Ee();import{attributeValue as bn,BLOCK_TYPES as en,HOSTS as xn,TOGGLES as wn}from"../browser/editor/components/registry.mjs";import{texSource as nn}from"../browser/editor/components/math/index.mjs";var Ce=new Set(Object.entries(en).filter(([,s])=>!s.box&&!s.bare).map(([s])=>s)),se=(s,m,I="")=>{let k=Q[m.type]?.leaf;if(k)return k(s,m,I);let g=[s.className,...m.classes??[]].filter(Boolean).join(" ");return`<${s.tag}${g?` class="${g}"`:""}${ke(m.attributes)}${I}>${m.html}</${s.tag}>`},Be=(s,m)=>s===void 0||!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(s).every(([I,k])=>typeof k=="string"&&bn(m,I,k)),qe=s=>s?.empty===!0,Pe=(s,m)=>s===void 0?null:I=>s.includes(m.slice(I.startOffset,I.endOffset));function ye(s,m,{empty:I=!1,file:k}={}){if(typeof m!="string"||!m.trim()&&!(I&&m===""))return!1;if(m==="")return!0;if(s.tex&&!nn(m))return!1;let g=s.inside??s.tag,$=`<${g}>${m}</${g}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;return u.length===0&&w?.tagName===g&&ge(w,[],s.inside!==void 0,{cell:g==="td"||g==="th",known:Pe(k,$)})===null}var vn=new Set(Object.values(en).filter(s=>s.text&&s.className).map(s=>s.kind));function ze(s,m){if(s.keep?.reason==="script")return null;if(s.kind==="list")return m.some(k=>k.unit===s.id&&k.kind==="list")?"list":null;let I=Q[s.kind];return I?.written?I.written(s)?"written":null:s.text===void 0||s.nested?null:["p","h1","h2","h3","h4","li"].includes(s.tag)||vn.has(s.kind)?"text":null}function be(s,m,I){if(!Array.isArray(m)||!m.every(g=>Sn(s,g,I)))return"invalid";let k=m.filter(g=>g.keep);return k.length>1?"invalid":m.length>k.length&&!s.caps.split||k.length===0&&!s.caps.remove||m.length===0&&s.nested?"fixed":k.length===1&&k[0].html.trim()===""&&!s.caps.empty?"empty":null}function sn(s,m,I){let k=`<table><tbody><tr><${s}>${m}</${s}></tr></tbody></table>`,[g,...$]=he(k,{sourceCodeLocationInfo:!0}).childNodes,w=$.length===0&&g?.tagName==="table"&&g.childNodes.length===1?g.childNodes[0]:null,u=w?.childNodes.length===1?w.childNodes[0]:null,h=u?.childNodes.length===1?u.childNodes[0]:null;return h?.tagName===s&&ge(h,[],!1,{cell:!0,known:Pe(I,k)})===null}var on={p:"paragraph",h1:"heading",h2:"heading",h3:"heading",h4:"heading",li:"item"},In=(s,m)=>s.classes===void 0||!s.keep&&Array.isArray(s.classes)&&new Set(s.classes).size===s.classes.length&&s.classes.every(I=>(wn[on[m]]??[]).includes(I));function Sn(s,m,I){if(!m||typeof m.html!="string"||xn[s.kind]?.tex&&!nn(m.html))return!1;let k=m.keep?s.tag:m.tag;if(!m.keep&&Je[s.tag]!==k||!In(m,k)||m.attributes!==void 0&&(m.keep||!Be(m.attributes,on[k])))return!1;let g=k==="td"||k==="th",$=g?`<table><tbody><tr><${k}>${m.html}</${k}></tr></tbody></table>`:`<${k}>${m.html}</${k}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;if(u.length>0||!w)return!1;let h=w;if(g){let p=w.tagName==="table"&&w.childNodes.length===1?w.childNodes[0]:null,f=p?.childNodes.length===1?p.childNodes[0]:null;h=f?.childNodes.length===1?f.childNodes[0]:null}return h?.tagName===k&&ge(h,[],Qe(s.kind,s.tag,s.caps),{cell:g,known:Pe(I,$)})===null}import{attr as cn}from"../browser/shared/html-tree.mjs";import{pageLanguage as jn}from"../browser/shared/components/page.mjs";import{SHEETS as Tn}from"../browser/editor/components/kit.mjs";import{BLOCK_ID as Cn}from"../browser/shared/ids.mjs";function fn({current:s,edits:m,units:I=[],partial:k=!1,ids:g=!1,touch:$=[],proposals:w=null}){let u=At(s),h=u.blocks,p=s.includes(`\r
3
+ `)?`\r
4
+ `:`
5
+ `,f=[],O=[],j=[],K=new Map,q=null,X,xt=!1,tt=(t,n)=>f.push({unit:t.id,reason:n}),et=t=>{let o=Ft(t).replace(/[0-9.]/g,l=>String.fromCharCode(l.charCodeAt(0)-65248)).replace(/[\s,,]/g,"").replace(/[−–]/g,"-").match(/-?\d+(?:\.\d+)?/)?.[0];return o===void 0?null:Number(o)},ht=(t,n,o)=>{if(t.kind!=="cell")return;let l=s.slice(t.start,t.innerStart),a=/\sdata-sort-value(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/.exec(l);if(!a)return;let d=(a[1]??a[2]??a[3]??"").trim(),x=/^-?\d+(\.\d+)?(e[-+]?\d+)?$/i.test(d)?Number(d):null,[S,c]=[et(s.slice(t.innerStart,t.innerEnd)),et(n)],b="";x!==null&&c!==null?b=` data-sort-value="${Number((c*(S?x/S:1)).toPrecision(12))}"`:x!==null&&S===null&&(b=a[0]),b!==a[0]&&O.push({start:t.start+a.index,end:t.start+a.index+a[0].length,text:b,of:[{id:o}]})},Vt=t=>{t.keep&&ee(t)?tt(t,"referenced"):j.push({start:t.start,end:t.end},...t.companion?[t.companion]:[])},oe=(t,n)=>{let o=t.classAttr,l=o?o.value.split(/\s+/).filter(Boolean):[],a=l;for(let[x,S]of n)a=S?a.includes(x)?a:[...a,x]:a.filter(c=>c!==x);if(a.join(" ")===l.join(" "))return;if(ut(t),!o){let x=/^<[A-Za-z][\w-]*/.exec(s.slice(t.elStart,t.elStart+40));if(!x)return tt(t,"unknown");let S=t.elStart+x[0].length;O.push({start:S,end:S,text:` class="${a.join(" ")}"`});return}if(a.length===0){O.push({...ne(s,o.start,o.end),text:""});return}let d=/=\s*'/.test(s.slice(o.start,o.end))?"'":'"';O.push({start:o.start,end:o.end,text:`class=${d}${a.join(" ")}${d}`})},It=typeof g=="function"?g:g?Xe:null,ct=new Set([...s.matchAll(tn)].map(t=>t[1]??t[2])),qt=()=>{for(;;){let t=It();if(!ct.has(t))return ct.add(t)&&t}},re=[],Pt=[],Gt=t=>t?` ${Ke}="${t}"`:"",le=t=>typeof t=="string"&&Cn.test(t)&&!ct.has(t),ft=(t,n)=>{let o=It?le(n)?(ct.add(n),n):qt():null;return o&&t!==void 0&&Pt.push({key:t,id:o}),Gt(o)},ot=new Set,zt=t=>{ot.add(t.at);let n=w?.get(t.id),o=It?le(n)?(ct.add(n),n):qt():null;return o&&re.push({at:t.at,id:o}),Gt(o)},ut=t=>{if(!It||!t||t.blockId||t.at===void 0||ot.has(t.at))return;let n=$e(s,t.at);O.push({start:n,end:n,text:zt(t)})},St=t=>{let{element:n,source:o}=vt(t.restore),l=n.sourceCodeLocation,a=cn(n,Ke);if(a&&!ct.has(a))return ct.add(a),t.key!==void 0&&Pt.push({key:t.key,id:a}),o;let d=o,x=l.startTag.endOffset-1;if(a){let S=l.attrs[Ke],c=ne(d,S.startOffset,S.endOffset);d=d.slice(0,c.start)+d.slice(c.end),x-=c.end-c.start}return x=$e(d,x),d.slice(0,x)+ft(t.key,t.blockId)+d.slice(x)},gt=t=>{let n=null;for(let o of u.units)o.elStart<=t.start&&t.start<o.end&&(!n||o.elStart>n.elStart)&&(n=o);return n},_=new Set;for(let t of m){let{id:n,parts:o}=t??{},l=Number.isInteger(n)?h[n]:void 0;if(!l){f.push({id:n,reason:"unknown"});continue}if(Array.isArray(o)&&o.length===0&&l.self!==null&&u.units[l.self].keep){f.push({id:n,reason:"referenced"});continue}let a=be(l,o,s);if(a){f.push({id:n,reason:a});continue}if(o.length===0){let N={...je(s,l.start,l.end),of:[{id:n}]};O.push(N),K.set(n,N),l.self!==null&&_.add(l.self);continue}let d=G(s,l.start),x=d===null?"":p+d,S=N=>`<${N.tag}${N.classes?` class="${N.classes.join(" ")}"`:""}${ke(N.attributes)}${ft(N.key,N.blockId)}>${N.html}</${N.tag}>`,c=o.findIndex(N=>N.keep),b=gt(l),v=b&&b.at===l.innerStart-1;if((!v||l.tag==="li")&&ut(b),l.tag==="li"&&c>=0){let N=o.slice(0,c),z=o.slice(c+1),C=b?{start:b.start,end:b.end}:null;O.push({start:l.innerStart,end:l.innerEnd,text:o[c].html,of:[{id:n}]}),N.length>0&&O.push({start:l.start,end:l.start,seq:1/0,text:N.map(S).join(x)+x,edge:C,of:[{id:n}]}),z.length>0&&O.push({start:l.end,end:l.end,text:x+z.map(S).join(x),edge:C,of:[{id:n}]})}else{let N=s.slice(l.start,l.innerStart);if(v&&It&&!b.blockId&&!ot.has(b.at)&&(N=`${N.slice(0,-1)}${zt(b)}>`),o.length===1&&c===0&&N===s.slice(l.start,l.innerStart)){O.push({start:l.innerStart,end:l.innerEnd,text:o[0].html,of:[{id:n}]}),ht(l,o[0].html,n),l.kind==="title"&&(q={from:Ft(s.slice(l.innerStart,l.innerEnd)),to:Ft(o[0].html)});continue}let z=o.map(C=>C.keep?N+C.html+s.slice(l.innerEnd,l.end):S(C)).join(x);O.push({start:l.start,end:l.end,text:z,of:[{id:n}]})}l.kind==="title"&&(q={from:Ft(s.slice(l.innerStart,l.innerEnd)),to:Ft(o[0].html)})}let Y=(t,n,o)=>{let l=u.units.filter(c=>c.box===t),a=[];for(let c=1;c<l.length;c++){let b=s.slice(l[c-1].end,l[c].start);b.trim()||a.push({pair:[l[c-1],l[c]],gap:b})}let d=a.find(({pair:c})=>c.includes(n))??a[0];if(d)return d.gap.replace(/\r?\n/g,p);let x=G(s,o.start),S=we(u.boxes[t]?.kind)==="root"?p:"";return x===null?"":S+p+x},Yt=t=>{if(t.kind!=="nest"||G(s,t.innerEnd)!==null)return null;let n=u.units[t.unit];return n?G(s,n.elStart):null},Wt=(t,n)=>{let o=s.slice(t.at+1,t.innerEnd).match(/\n([ \t]*)\S/);return o?o[1]:`${n??""} `},Kt=(t,n)=>n!==null&&we(t.kind)==="root",mt=[],Zt=(t,n,o,l)=>{let a=Number.isInteger(n?.into)?u.boxes[n.into]:null,d=Number.isInteger(n?.after),x=a?null:u.units[d?n.after:n?.before],S=a??(x?u.boxes[x.box]:null),c=z=>z>=t.start&&z<t.end;if(!S||!(xe(S.kind,te(t))||l===S.kind)||t.kind==="tab"&&S.id!==t.box||x&&(x===t||!o.has(x.id)||c(x.elStart))||a&&c(S.at))return tt(t,"position");let b=G(s,t.start);if(ut(t),a){if(a.innerEnd===null)return tt(t,"missing");let z=Yt(a);if(z!==null){mt.push({start:t.start,end:t.end,at:a.innerEnd,seq:lt++,from:b,to:z+nt,wrap:R=>p+z+nt+R+p+z});return}let C=G(s,a.innerEnd),W=Wt(a,C),T=C!==null&&W.startsWith(C)?W.slice(C.length):" ",P=Kt(a,C);mt.push({start:t.start,end:t.end,at:P?a.innerEnd-C.length:a.innerEnd,seq:lt++,from:b,to:W,wrap:R=>C===null?R:P?C+T+R+p:T+R+p+C});return}let v=Y(x.box,x,x),N=d?v.includes(`
6
+ `)?v.slice(v.lastIndexOf(`
7
+ `)+1):null:G(s,x.start);mt.push({start:t.start,end:t.end,at:d?x.end:x.start,seq:lt++,from:b,to:N,wrap:z=>d?v+z:z+v})},yt=(t,n)=>t.classes===void 0||Array.isArray(t.classes)&&new Set(t.classes).size===t.classes.length&&t.classes.every(o=>(an[n.kind]??[]).includes(o)),Ut=(t,n)=>!Ze(t)&&(Q[t.type]?.check?.(t)??!0)&&yt(t,n)&&Be(t.attributes,n.kind),Rt=(t,n,o={})=>ye(t,n,{...o,file:s}),_t=(t,n)=>{if(st.has(t.id))return;let o=Dt[n?.type],l=ze(t,u.boxes);if(!(l==="text"||l==="written"&&o?.kind!==t.kind)||!Ce.has(n?.type)||!ye(o,n.html,{empty:qe(o),file:s}))return tt(t,"invalid");if(!it.has(t.id)&&!dt.has(t.id)&&!xe(u.boxes[t.box].kind,o.kind))return tt(t,"position");if(!Ut(n,o))return tt(t,"invalid");let a=t.blockId?Gt(t.blockId):zt(t);ot.add(t.at);let d=l==="written"&&t.node?He(s,t.node,Q[t.kind].attribute):t.carried;O.push({start:t.elStart,end:t.end,text:se(o,n,d+a)})},ae=(t,n)=>{if(st.has(t.id))return;let o=Q[t.kind]?.rewrite;if(!o)return tt(t,"invalid");let l=o(s,t.node,n,{validCell:(a,d)=>sn(a,d,s),get packages(){return Ct().packages}});if(!l)return tt(t,"invalid");ut(t),O.push(...[l].flat())},ce=(t,n)=>{if(ze(t,u.boxes)!=="list"||n!=="ul"&&n!=="ol")return tt(t,"invalid");let o=/^<(ul|ol)\b/i.exec(s.slice(t.elStart,t.elStart+3)),l=/<\/(ul|ol)\s*>$/i.exec(s.slice(t.elStart,t.end));if(!o||!l)return tt(t,"unknown");if(o[1].toLowerCase()===n)return;ut(t);let a=t.end-l[0].length+2;O.push({start:t.elStart+1,end:t.elStart+3,text:n},{start:a,end:a+2,text:n})},Et=new Set([...s.matchAll(/\sid\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi)].map(t=>t[1]??t[2]??t[3])),Ot=new Map,Nt=new Set,nt=/\n(\t|[ ]+)</.exec(s)?.[1]??" ",bt=(t,n)=>{let o=d=>xe(n,d)||t?.stood===n;if(t?.restore!==void 0){let d=vt(t.restore),x=d?.kind==="item"?Ne(d.element,n):d?.kind;if(!d||!o(x))return!1;if(t.children===void 0)return!0;if(t.boxKeys!==void 0){let c=Oe(d.element,d.kind);return Array.isArray(t.boxKeys)&&t.boxKeys.length===t.children.length&&t.children.every((b,v)=>{let N=c.find(({key:z})=>z===t.boxKeys[v]);return!!N&&bt(b,N.kind)})}let S=Dt[t.type];return On(S)&&S.kind===x&&t.children.every(c=>bt(c,S.box))}if(t?.unit!==void 0){let d=Number.isInteger(t.unit)?u.units[t.unit]:void 0;return!d||Nt.has(d.id)||st.has(d.id)||it.has(d.id)||_.has(d.id)||d.kind==="tab"||!o(te(d))?!1:(Nt.add(d.id),!0)}let l=Dt[t?.type];if(!l||!o(l.kind))return!1;if(t.type==="divider")return!0;if(t.type==="icon")return Mn(t.icon);let a=Q[t.type];return l.bare&&a?.check?a.check(t,{validLeaf:Rt,usedIds:Et})&&yt(t,l):l.box?!Array.isArray(t.children)||t.children.length===0&&!a?.empty||!yt(t,l)||a?.check&&!a.check(t,{validLeaf:Rt,usedIds:Et})?!1:t.children.every(d=>bt(d,l.box)):!Ce.has(t.type)||!ye(l,t.html,{empty:qe(l),file:s})||!Ut(t,l)?!1:t.children===void 0?!0:Array.isArray(t.children)&&a?.children?.(t,bt)===!0},Z=(t,n)=>{if(t.unit!==void 0){let b=Ot.get(t.unit);return kt(H(b),b.from,n)}if(t.restore!==void 0&&t.children===void 0)return kt(St(t),"",n);let o=Dt[t.type];if(t.type==="divider")return`<hr${ft(t.key,t.blockId)}>`;if(t.type==="icon")return $n(t.icon,ft(t.key,t.blockId));let l=n===null?null:n+nt,a=(b,v,N,z=n,C=l)=>C===null?b+v.join("")+N:b+v.map(W=>p+C+W).join("")+p+z+N,d=b=>t.children.map(v=>Z(v,b));if(t.restore!==void 0&&t.boxKeys!==void 0){let b=St(t),{element:v,kind:N}=vt(b),z=Oe(v,N).flatMap(({element:C,key:W})=>{let T=t.children.filter((at,jt)=>t.boxKeys[jt]===W);if(T.length===0)return[];let{startTag:P,endTag:R}=C.sourceCodeLocation,J=n===null?null:G(b,P.startOffset),pt=J===null?null:J+nt;return[{start:P.endOffset,end:R.startOffset,text:a("",T.map(at=>Z(at,pt)),"",J,pt)}]}).sort((C,W)=>W.start-C.start).reduce((C,{start:W,end:T,text:P})=>C.slice(0,W)+P+C.slice(T),b);return kt(z,"",n)}if(t.restore!==void 0){let b=St(t),{element:v}=vt(b),{startTag:N,endTag:z}=v.sourceCodeLocation,C=v.childNodes.findLastIndex(T=>T.tagName),W=v.childNodes.slice(C+1).filter(T=>T.nodeName==="#comment").map(({sourceCodeLocation:{startOffset:T,endOffset:P}})=>kt(b.slice(T,P),G(b,T),l));return a(kt(b.slice(0,N.endOffset),"",n),[...d(l),...W],z?b.slice(z.startOffset):`</${o.tag}>`)}let x={get id(){return ft(t.key,t.blockId)},get language(){return jn(s)},idOf:b=>ft(b.key,b.blockId),render:(b,v)=>Z(b,v),indent:n,inner:l,step:nt,block:a,children:d,deep:b=>n===null?null:n+nt.repeat(b)},S=Q[t.type]?.write;if(o.bare&&S)return S(t,x);if(!o.box)return t.children?S(t,x):se(o,t,ft(t.key,t.blockId));if(S)return S(t,x);let c=[o.className,...t.classes??[]].filter(Boolean).join(" ");return a(`<${o.tag}${c?` class="${c}"`:""}${ft(t.key,t.blockId)}>`,d(l),`</${o.tag}>`)},rt=[],fe=t=>{let{insert:n,place:o}=t,l=T=>f.push({unit:t.id,reason:T}),a=n?.restore!==void 0?vt(n.restore):null;if(n?.type==="icon"||a?.kind==="icon"){let T=Number.isInteger(o?.into)?u.boxes[o.into]:null,P=T?null:u.units[Number.isInteger(o?.after)?o.after:o?.before],R=T??(P?u.boxes[P.box]:null);if(rn(R?.kind,"icon")){if(!bt(n,R.kind))return l("invalid");if(R.innerEnd===null)return l("missing");let at=u.units.find(_e=>_e.box===R.id&&_e.kind!=="icon"),jt=at?at.start:R.innerEnd,Tt=G(s,jt);rt.push({at:jt,seq:lt++,text:()=>Z(n,Tt)+(Tt===null?"":p+Tt)});return}if(!bt(n,"header"))return l("invalid");let J=h.find(at=>at.kind==="title");if(!J)return l("missing");let pt=G(s,J.start);rt.push({at:J.start,seq:lt++,text:()=>Z(n,pt)+(pt===null?"":p+pt)}),X=a?Ln(a.source):n.icon;return}if(n?.type==="tab"||a?.kind==="tab")return ue(t,a,l);let d=Number.isInteger(o?.into)?u.boxes[o.into]:null,x=Number.isInteger(o?.after),S=d?null:u.units[x?o.after:o?.before],c=d??(S?u.boxes[S.box]:null),b=n?.restore!==void 0?vt(n.restore):null,v=b?c&&b.kind==="item"?Ne(b.element,c.kind):b.kind:Dt[n?.type]?.kind;if(!c||!v||!(xe(c.kind,v)||n.stood===c.kind)||S&&!Ht.has(S.id))return l("position");let N=new Set(Nt);if(!bt(n,c.kind))return l("invalid");for(let T of Nt){if(N.has(T))continue;let P=u.units[T];ut(P);let R={start:P.start,end:P.end,at:null,from:G(s,P.start)};Ot.set(T,R),mt.push(R)}if(d){if(d.innerEnd===null)return l("missing");let T=Yt(d);if(T!==null){rt.push({at:d.innerEnd,seq:lt++,text:()=>p+T+nt+Z(n,T+nt)+p+T});return}let P=G(s,d.innerEnd),R=Wt(d,P),J=P!==null&&R.startsWith(P)?R.slice(P.length):nt,pt=u.units.filter(Tt=>Tt.box===d.id),at=we(d.kind)==="root"&&En.has(v)&&(pt.some(Tt=>Ht.has(Tt.id))||!d.pure&&(pt.length>0||n.restore!==void 0))?p:"",jt=Kt(d,P);rt.push({at:jt?d.innerEnd-P.length:d.innerEnd,seq:lt++,text:()=>P===null?Z(n,null):jt?at+P+J+Z(n,R)+p:J+Z(n,R)+p+P});return}let z=x?S.end:S.start;if(we(c.kind)==="root"){let T=Y(S.box,S,S),P=x?T.includes(`
8
+ `)?T.slice(T.lastIndexOf(`
9
+ `)+1):null:G(s,S.start);rt.push({at:z,seq:lt++,text:()=>x?T+Z(n,P):Z(n,P)+T});return}let C=G(s,S.start),W=C===null?"":p+C;rt.push({at:z,seq:lt++,text:()=>x?W+Z(n,C):Z(n,C)+W})},ue=({insert:t,place:n},o,l)=>{let a=Number.isInteger(n?.after),d=u.units[a?n.after:n?.before];if(d?.kind!=="tab"||!Ht.has(d.id))return l("position");if(!bt(t,"tabs"))return l("invalid");let x=d.companion,S=u.units[d.parent??-1];if(!x||!S)return l("missing");let c=o?cn(o.element,Tn.tabKey):t.sheet,b=s.slice(S.start,S.end);if(b.includes(`data-sheet-tab="${c}"`)||b.includes(`data-doc-sheet="${c}"`))return l("invalid");let v=G(s,d.start),N=G(s,x.start),z=(R,J)=>R===null?J:a?p+R+J:J+p+R,C=()=>o?kt(St(t),"",v):We({...t,sheet:c},ft(t.key,t.blockId)),W=()=>{if(o)return kt(o.panel,"",N);let R=`<div data-doc-sheet="${c}">`;if(t.children.length===0)return N===null?`${R}</div>`:`${R}${p}${N}</div>`;let J=N===null?null:N+nt,pt=t.children.map(at=>Z(at,J));return J===null?R+pt.join("")+"</div>":R+pt.map(at=>p+J+at).join("")+p+N+"</div>"};rt.push({at:a?d.end:d.start,seq:lt++,text:()=>z(v,C())});let T=a?/^\s*/.exec(s.slice(x.end))[0]:/\s*$/.exec(s.slice(0,x.start))[0],P=N!==null&&/\n[ \t]*\r?\n/.test(T)?p:"";rt.push({at:a?x.end:x.start,seq:lt++,text:()=>a?P+z(N,W()):z(N,W())+P})},$t=(t,n)=>{let o=t.node?.sourceCodeLocation;if(t.at===void 0||!o)return tt(t,"unknown");ut(t),O.push(...Te(s,o.startTag,[["style",l=>Ve(l?.value??"",n)||null]]))},Se=(t,n)=>{let o=t.node?.sourceCodeLocation;if(t.at===void 0||!o)return tt(t,"unknown");ut(t),O.push(...Te(s,o.startTag,n))},D=new Map,Jt=new Map,Qt=new Map,st=new Set(I.filter(t=>t?.remove===!0).map(t=>t.id)),it=new Set(I.filter(t=>t?.move).map(t=>t.id)),dt=new Map,Xt=(t,n)=>n?.unit!==void 0?dt.set(n.unit,t.id):Array.isArray(n?.children)&&n.children.forEach(o=>Xt(t,o));I.forEach(t=>Xt(t,t?.insert));let Lt=new Map(I.filter(t=>Number.isInteger(t?.id)&&t.replace).map(t=>[t.id,t.replace])),te=t=>Dt[Lt.get(t.id)?.type]?.kind??t.kind,Ht=new Set(u.units.map(t=>t.id).filter(t=>!st.has(t)&&!it.has(t)&&!dt.has(t)&&!_.has(t))),Ae=u.units.filter(t=>it.has(t.id)||dt.has(t.id)),de=(t,n)=>o=>n.some(l=>l!==t&&t.start<=l.start&&l.end<=t.end&&l.start<=o&&o<l.end),ee=t=>!!t.keep&&!t.keep.at.every(de(t,Ae)),Mt=(t,n)=>{let o=[O,j,mt,rt],l=o.map(a=>a.length);n(),o.forEach((a,d)=>a.slice(l[d]).forEach(x=>x.of??=t))},lt=0;for(let t of I){let{id:n,remove:o,toggle:l,on:a,move:d,size:x,value:S,attribute:c,stood:b}=t??{},v=Number.isInteger(n)?u.units[n]:void 0;Mt([{unit:n}],()=>{if(t?.insert&&typeof n=="string")fe(t);else if(v&&t.replace){let N=f.length;_t(v,t.replace),f.length>N&&Lt.delete(v.id)}else v&&t.retag?ce(v,t.retag):v&&(t.table||t.source)?ae(v,t.table??t.source):v&&o===!0?ee(v)?f.push({unit:n,reason:"referenced"}):v.kind==="tab"&&u.units.every(N=>N.box!==v.box||st.has(N.id))?f.push({unit:n,reason:"last"}):(v.kind==="icon"&&!rn(u.boxes[v.box]?.kind,"icon")&&(xt=!0),Vt(v)):v&&d&&typeof d=="object"&&!st.has(n)?_.has(n)||Zt(v,d,Ht,b):v&&typeof a=="boolean"&&(an[v.kind]??[]).includes(l)?(D.get(v)??D.set(v,new Map).get(v)).set(l,a):v&&Nn[v.kind]?.[x]&&(S===null||ln(v.kind,x,S)!==null)?st.has(n)||(Jt.get(v)??Jt.set(v,new Map).get(v)).set(x,S===null?null:ln(v.kind,x,S)):v&&typeof c=="string"&&An(v.kind,c,S)?st.has(n)||(Qt.get(v)??Qt.set(v,new Map).get(v)).set(c,S):f.push({unit:n,reason:x===void 0&&c===void 0?"unknown":"invalid"})})}let e=new Set(f.map(t=>t.unit).filter(t=>t!==void 0)),i=t=>(st.has(t.id)||it.has(t.id)||dt.has(t.id))&&!e.has(dt.get(t.id)??t.id);for(let t of u.boxes){if(!["list","quote"].includes(t.kind)||!t.pure||t.unit===null)continue;let n=u.units[t.unit];if(!n||st.has(n.id)||it.has(n.id)||dt.has(n.id))continue;let o=u.units.filter(a=>a.box===t.id);if(o.length===0||!o.every(i))continue;let l=a=>!!a&&(a.into===t.id||[n,...o].some(d=>a.after===d.id||a.before===d.id));I.some(a=>l(a?.insert?a.place:a?.move))||Vt(n)}for(let[t,n]of D)Mt([{unit:t.id}],()=>oe(t,n));for(let[t,n]of Jt)Mt([{unit:t.id}],()=>$t(t,n));for(let[t,n]of Qt)Mt([{unit:t.id}],()=>Se(t,n));for(let t of $)ut(u.units[t]);let r=new Set([...K.keys()].map(t=>h[t].wrapper).filter(Boolean));for(let t of r){let n=t.ids.map(o=>K.get(o));n.some(o=>!o)||j.some(o=>o.start<=t.start&&t.end<=o.end)||(n.forEach(o=>o.skip=!0),O.push({...je(s,t.start,t.end),of:t.ids.map(o=>({id:o}))}))}if(q&&q.from!==q.to){let t=De(s,q);q.synced=!!t,t&&O.push(t)}else q=null;let y=new Map;for(let t of j){let n=`${t.start}:${t.end}`;y.has(n)?y.get(n).of=[...y.get(n).of??[],...t.of??[]]:y.set(n,t)}j.splice(0,j.length,...y.values());let L=(t,n)=>{t.of?.length||f.push({reason:n});for(let o of t.of??[])f.push({...o,reason:n})},E=(t,n,o)=>n===o?t.start<n&&n<t.end:t.start<=n&&o<=t.end,M=(t,n,o,l=null)=>{let a=null;for(let d of mt){let x=l!==null&&d.start===l.start&&d.end===l.end;d!==o&&(x||E(d,t,n))&&(!a||d.start>=a.start)&&(a=d)}return a},A=(t,n,o,l=null)=>{let a=M(t,n,o,l);return j.some(d=>d!==o&&E(d,t,n)&&!(a&&E(d,a.start,a.end)))},B=new Set,H=t=>{if(B.has(t))return L(t,"position"),"";B.add(t);try{return V(t)}finally{B.delete(t)}},V=t=>{let[n,o]=t?[t.start,t.end]:[0,s.length],l=(c,b,v=null,N=null)=>M(c,b,v,N)===t&&!A(c,b,v,N),a=[];for(let c of[...j,...mt].filter(b=>b!==t&&l(b.start,b.end,b)).sort((b,v)=>b.start-v.start)){let b=a.at(-1);b&&(c.start<=b.end||!s.slice(b.end,c.start).trim())?(b.end=Math.max(b.end,c.end),b.of.push(...c.of??[])):a.push({start:c.start,end:c.end,of:[...c.of??[]]})}let d=[...O.filter(c=>!c.skip&&l(c.start,c.end,null,c.edge??null)).map(c=>({...c,seq:c.seq??-2})),...a.map(c=>({...Ye(s,c.start,c.end),seq:-1,of:c.of})),...[...mt.filter(c=>c.at!==null),...rt].filter(c=>l(c.at,c.at,c)).map(c=>({start:c.at,end:c.at,seq:c.seq,text:c.text?c.text():c.wrap(kt(H(c),c.from,c.to)),of:c.of}))].sort((c,b)=>c.start-b.start||c.end-c.start-(b.end-b.start)||c.seq-b.seq),x=[];for(let c of d)x.length>0&&c.start<x.at(-1).end?L(c,"overlap"):x.push(c);let S=s.slice(n,o);for(let c of x.reverse())S=S.slice(0,c.start-n)+c.text+S.slice(c.end-n);return S},U=H(null);if(f.length>0&&!k)return{ok:!1,conflicts:f};let F=X??(xt?null:void 0);return{ok:f.length===0,text:U,version:me(U),ids:{assigned:re,created:Pt},...q?{title:q}:{},...F!==void 0?{icon:F}:{},...k?{conflicts:f}:{}}}import{attr as yn}from"../browser/shared/html-tree.mjs";import{outsideKey as Rn}from"../browser/shared/ids.mjs";import{CHART_SOURCE as _n}from"../browser/shared/table-chart.mjs";Ee();import{commonPrefix as un,commonRun as xs,commonSuffix as dn,mergeText as pn}from"../browser/editor/page/merge.mjs";var ie=new Map;function ve(s){let m=ie.get(s);if(m)return m;let I=/data-block-id/i.test(s)?Fe(s,[pe(s,{sourceCodeLocationInfo:!0})]):[],k="",g=0,$=0,w=[];for(let h of I)k+=s.slice(g,h.start),g=h.end,$+=h.end-h.start,w.push({at:k.length,end:h.end,removed:$});k+=s.slice(g);let u={text:k,at:h=>h-(w.findLast(p=>p.end<=h)?.removed??0),source:h=>h+(w.findLast(p=>p.at<=h)?.removed??0)};for(ie.set(s,u);ie.size>4;)ie.delete(ie.keys().next().value);return u}function Ue(s,m,I,k=I.start){let[g,$]=[ve(s),ve(m)],w=g.at(I.start),u=g.text.slice(w,g.at(I.end)),h=K=>$.source(K+g.at(k)-w),p=K=>{let q=[];for(let X=K.indexOf(u);X>=0;X=K.indexOf(u,X+1))q.push(X);return q},f=p($.text);if(f.length<=1&&p(g.text).length<=1)return f.length===1?h(f[0]):-1;let O=g.text.slice(Math.max(0,w-120),w),j=f.filter(K=>$.text.slice(Math.max(0,K-O.length),K)===O);return j.length===1?h(j[0]):f.length>1?-2:-1}function Re(s,m,I,k){let[$,w]=[ve(s),ve(m)],[u,h]=[$.at(I.start),$.at(I.end)],p=$.text.slice(Math.max(0,u-400),u),f=$.text.slice(h,h+400),O=k.filter(q=>q.tag===I.tag).map(q=>{let[X,xt]=[w.at(q.start),w.at(q.end)];return{other:q,score:dn(p,w.text.slice(Math.max(0,X-400),X))+un(f,w.text.slice(xt,xt+400))}}).sort((q,X)=>X.score-q.score),[j,K]=O;return j&&j.score>=40&&j.score-(K?.score??0)>=20?j.other:null}function hn(s,m){let I=h=>h.replace(/<[^>]*>/g," ").replace(/&(?:[a-z]+|#\d+);/gi," ").replace(/\s+/g," ").trim(),k=I(s),g=I(m);if(!k||!g)return!k&&!g;if(k.length<2||g.length<2)return k===g;let $=h=>{let p=new Map;for(let f=0;f<h.length-1;f++)p.set(h.slice(f,f+2),(p.get(h.slice(f,f+2))??0)+1);return p},w=$(g),u=0;for(let[h,p]of $(k))u+=Math.min(p,w.get(h)??0);return 2*u/(k.length-1+g.length-1)>=.5}Ee();import{IDENTITY as Bn}from"../browser/editor/components/registry.mjs";import{escapeAttribute as qn}from"../browser/shared/escape.mjs";import{attr as mn}from"../browser/shared/html-tree.mjs";import{CHART_SOURCE as Bt,TABLE_READERS as Pn,nextChartKey as zn}from"../browser/shared/table-chart.mjs";function kn(s,m,I=new Set){if(m.size===0&&I.size===0||!s.includes(Bt))return{text:s,keys:{}};let k=[],g=(h,p)=>{for(let f of h.childNodes??[]){if(!f.tagName)continue;let O=mn(f,Bn),j=p||m.has(O);for(let K of[Bt,...Pn]){let q=mn(f,K);q!==void 0&&k.push({name:K,key:q,made:j||K===Bt&&I.has(O),at:f.sourceCodeLocation?.attrs?.[K]??null})}g(f.tagName==="template"?f.content:f,j)}};g(pe(s,{sourceCodeLocationInfo:!0}),!1);let $=new Set(k.map(({key:h})=>h)),w={};for(let h of new Set(k.filter(p=>p.made&&p.name===Bt).map(p=>p.key))){let p=k.filter(O=>O.key===h&&!O.made),f=k.some(O=>O.key===h&&O.made&&O.name!==Bt);f&&p.length>0?(w[h]=zn($),$.add(w[h])):!f&&p.some(O=>O.name===Bt)&&(w[h]=null)}return{text:k.filter(({name:h,key:p,made:f,at:O})=>f&&O&&Object.hasOwn(w,p)&&!(w[p]===null&&h!==Bt)).map(({name:h,key:p,at:f})=>w[p]===null?{...ne(s,f.startOffset,f.endOffset),put:""}:{start:f.startOffset,end:f.endOffset,put:`${h}="${qn(w[p])}"`}).sort((h,p)=>p.start-h.start).reduce((h,{start:p,end:f,put:O})=>h.slice(0,p)+O+h.slice(f),s),keys:w}}function Hn({current:s,opening:m=null,texts:I=[],units:k=[],touch:g=[],ids:$=!0,seal:w=null,pageIds:u=null}){let h=At(s),p=typeof m=="string"?At(m):null,f=e=>s.slice(e.innerStart,e.innerEnd),O=null,j=e=>(O??=new Map(h.units.map(i=>[i.id,wt(s,i)]))).get(e.id),K=new Map,q=new Set,X=new Map,xt=new Set(Array.isArray(u)?u.filter(e=>typeof e=="string"):[]),tt=(e,i,r=!0,y=[])=>{let L=F=>!!F.blockId&&xt.has(F.blockId)&&!y.includes(F.blockId),E=xt.size>0?h.units.filter(F=>!L(F)):h.units,M=typeof i=="string"?E.filter(F=>j(F)===i):[],A=e>=0?p?.units[e]:void 0,B=A&&M.length>1?p.units.filter(F=>!L(F)&&wt(m,F)===i):[];if(M.length===1)return{unit:M[0]};if(B.length===M.length&&B.includes(A))return{unit:M[B.indexOf(A)]};if(!A)return M.length>1?{reason:"ambiguous"}:{gone:!0};let H=Ue(m,s,A,A.elStart),V=H>=0?E.find(F=>F.elStart===H):null;if(V)return{unit:V};if(H===-2||M.length>1)return{reason:"ambiguous"};if(!r)return{gone:!0};let U=Re(m,s,A,E);return U&&hn(m.slice(A.start,A.end),s.slice(U.start,U.end))?{unit:U,changed:!0}:{gone:!0}},et=e=>{if(!e||typeof e.key!="number"&&typeof e.key!="string")return{reason:"invalid"};if(K.has(e.key))return K.get(e.key);let i,r=typeof e.blockId=="string"?h.units.filter(y=>y.blockId===e.blockId):[];if(r.length===1&&typeof e.id!="string")i={unit:r[0]};else if(typeof e.id=="string"){let y=h.units.filter(L=>L.blockId===e.id);i=y.length===1?{unit:y[0]}:y.length>1?{reason:"ambiguous"}:Number.isInteger(e.open)&&typeof e.openHash=="string"?tt(e.open,e.openHash,!1,[e.id]):{gone:!0}}else Number.isInteger(e.open)?i=tt(e.open,e.hash,!0,[e.blockId]):i={reason:"invalid"};return i.unit&&!i.unit.blockId&&typeof e.blockId=="string"&&X.set(i.unit.id,e.blockId),K.set(e.key,i),i.unit&&ht(e,i)&&q.add(e.key),i},ht=(e,i)=>i.changed||e.hash===null||typeof e.hash=="string"&&j(i.unit)!==e.hash,Vt=new Set(h.units.map(e=>e.blockId).filter(Boolean)),oe=[],It=e=>e?.restore!==void 0?yn(vt(e.restore?.source)?.element??{},gn)??e.blockId:e?.blockId,ct=e=>{let i=It(e);if(typeof i=="string"&&Vt.has(i))return!0;let r=Ie[e?.type];return!!r?.keyed&&typeof e.id=="string"&&h.boxes.some(y=>y.kind===r.box&&y.key===e.id)},qt=e=>{let i=It(e);e?.key!==void 0&&typeof i=="string"&&Vt.has(i)&&oe.push({key:e.key,id:i}),Array.isArray(e?.children)&&e.children.forEach(qt)},re=(e,i)=>{let r=Ie[i?.type];return!!r&&s.slice(e.elStart,e.end)===se(r,i,(e.carried??"")+(e.blockId?` ${gn}="${e.blockId}"`:""))},Pt=(e,i,r)=>Array.isArray(e)&&Array.isArray(i)&&e.length===i.length&&e[0]===i[0]&&e.slice(1).every((y,L)=>y[0]===i[L+1]?.[0]&&y[1]===i[L+1][1]&&(!r||y[2]===i[L+1][2])),Gt=e=>{if(!e||typeof e.before!="string")return{reason:"invalid"};let i=r=>({block:r,changed:f(r)!==e.before});if(e.title){let r=h.blocks.filter(y=>y.kind==="title");return r.length===1?i(r[0]):{reason:r.length?"ambiguous":"missing"}}if(e.unit){let r=et(e.unit);if(!r.unit)return{reason:r.gone?"missing":r.reason};let y=h.blocks.filter(M=>M.unit===r.unit.id);if(e.self){let M=y.find(A=>A.self===r.unit.id);return M?i(M):{reason:"missing"}}let L=y.find(M=>Pt(M.path,e.path,!1));if(L&&Pt(L.path,e.path,!0))return i(L);let E=y.filter(M=>f(M)===e.before);return E.length===1?i(E[0]):{reason:Q[r.unit.kind]?.textParts&&!ht(e.unit,r)?"package":"structure"}}if(Number.isInteger(e.open)||e.outside){let r=h.blocks.filter(A=>A.unit===null&&A.kind!=="title"&&f(A)===e.before);if(r.length===1)return i(r[0]);let y=Number.isInteger(e.open)?p?.blocks[e.open]:null;if(!y||r.length>1)return{reason:r.length>1?"ambiguous":"missing"};let L=Ue(m,s,y),E=L>=0?h.blocks.find(A=>A.start===L):null;if(E)return i(E);let M=L===-2?null:Re(m,s,y,h.blocks.filter(A=>A.unit===null));return M?i(M):{reason:L===-2?"ambiguous":"missing"}}return{reason:"invalid"}},le=e=>{if(e?.main)return h.boxes.find(r=>r.kind==="main")??null;if(e&&!e.unit&&typeof e.kind=="string")return h.boxes.find(r=>r.unit===null&&r.kind===e.kind&&(r.key??null)===(e.key??null))??null;let i=e?.unit?et(e.unit):null;return i?.unit?h.boxes.find(r=>r.unit===i.unit.id&&r.kind===e.kind&&(r.key??null)===(e.key??null))??null:null},ft=[],ot=e=>{e&&typeof e=="object"&&(typeof e.key=="number"||typeof e.key=="string")&&ft.push(e)},zt=e=>{e?.unit!==void 0&&ot(e.unit),e?.copy!==void 0&&ot(e.copy),Array.isArray(e?.children)&&e.children.forEach(zt)},ut=e=>{ot(e?.after),ot(e?.before),ot(e?.into?.unit)};for(let e of I)ot(e?.block?.unit);for(let e of k)ot(e?.unit),ut(e?.place),ut(e?.move),zt(e?.insert);g.forEach(ot);let St=new Map;for(let e of ft){let i=et(e);i.unit&&(St.get(i.unit)??St.set(i.unit,[]).get(i.unit)).push({key:e.key,changed:!!i.changed})}for(let e of St.values())if(!(new Set(e.map(i=>i.key)).size<2))for(let i of e)i.changed&&K.set(i.key,{gone:!0});let gt=new Map,_=new Map,Y=(e,i,r,y={})=>e.set(i,{key:i,status:"conflict",reason:r,...y}),Yt=new Map,Wt=(e,i,r,y)=>{let L=M=>{for(let A=M.unit;A!=null;A=i.units[A]?.parent)if(A===r.id)return!0;return!1};if(!y)return{hash:wt(e,r),theirs:i.blocks.filter(L).map(M=>e.slice(M.innerStart,M.innerEnd)).join(`
10
+ `)};let E=M=>Object.fromEntries(y.filter(A=>typeof M?.[A]=="string").map(A=>[A,M[A]]));return{theirs:E(Q[r.kind]?.dataOf?.(e,r.node,Ct().packages)??{}),parts:E(r.parts)}},Kt=(e,i,r=null,y={})=>{Yt.set(e,{unit:i,held:r}),Y(_,e,"changed",{...Wt(s,h,i,r),...y})},mt=[],Zt=new Map;for(let e of I){let{key:i,block:r}=e??{},y=e?.parts,L=Array.isArray(y)?y.filter(A=>!A?.keep):[];L.some(ct)&&(L.forEach(qt),y=y.filter(A=>A?.keep||!ct(A)));let E=Gt(r);if(!E.block){E.reason==="missing"&&Array.isArray(y)&&!y.some(A=>A?.keep)&&y.every(ct)?gt.set(i,{key:i,status:"applied"}):Y(gt,i,E.reason);continue}let M=Array.isArray(y)&&y.length===1&&y[0]?.keep&&typeof y[0].html=="string"?y[0].html:null;if(E.changed&&M!==null&&M===f(E.block))gt.set(i,{key:i,status:"applied"});else if(E.changed){let A=M===null?null:pn(r.before,M,f(E.block));if(A===null||be(E.block,[{keep:!0,html:A}],s)){Y(gt,i,"changed",{theirs:f(E.block)});continue}y=[{keep:!0,html:A}],gt.set(i,{key:i,status:"merged",html:A})}else gt.set(i,{key:i,status:"applied"});Zt.set(E.block.id,i),mt.push({id:E.block.id,parts:y})}let yt=[],Ut=new Map,Rt=(e,i)=>Ut.set(e,[...Ut.get(e)??[],i]),_t={},ae=e=>{if(e?.into){let y=le(e.into);return y?{into:y.id}:null}let i=!!e?.after,r=et(i?e.after:e?.before);return r?.unit?{[i?"after":"before"]:r.unit.id}:null},ce=null,Et=e=>{if(e?.unit!==void 0){let y=et(e.unit);return y.unit?{unit:y.unit.id,stood:e.stood}:null}if(e?.restore!==void 0){let{source:y,seal:L}=e.restore??{};if(!w||typeof y!="string"||L!==w(y))return null;let E=Array.isArray(e.children)?e.children.map(Et):void 0;return E?.includes(null)?null:{restore:y,key:e.key,blockId:e.blockId,stood:e.stood,...E?{type:e.type,children:E}:{}}}if(e?.copy!==void 0){let y=et(e.copy),L=e.keys===void 0?null:Un(e.keys);return e.keys!==void 0&&!L?null:y.unit&&Kn.has(y.unit.kind)?{restore:Me(s,y.unit,{keys:L,taken:ce??=new Set(Le(s))}),key:e.key,blockId:e.blockId}:null}if(!e||typeof e!="object")return null;let i=Q[e.type]?.source;if(i){let y=M=>Me(M,{start:0,end:M.length},{taken:ce??=new Set(Le(s))}),L=Array.isArray(e.children)?e.children.map(Et):void 0;if(L?.includes(null))return null;let E=i(e,{packages:Ct().packages,written:y});return E?{restore:E,key:e.key,blockId:e.blockId,...L?{type:e.type,children:L,boxKeys:e.boxKeys}:{}}:null}let r=Array.isArray(e.children)?e.children.map(Et):void 0;return r?.includes(null)?null:{...e,...r?{children:r}:{}}},Ot=new Set,Nt=e=>[...Ot].filter(i=>i!==e&&[e,e.companion].some(r=>r&&r.start<=i.start&&i.end<=r.end)),nt=e=>{if(e?.unit!==void 0){let i=et(e.unit);i.unit&&Ot.add(i.unit)}else Array.isArray(e?.children)&&e.children.forEach(nt)};for(let e of k)e?.move?nt({unit:e.unit}):e?.insert&&nt(e.insert);let bt=(e,i)=>{let r=h.boxes.filter(E=>E.unit===e.id),y=new Map(i.map(E=>[et(E).unit,E])),L=h.units.filter(E=>r.some(M=>M.id===E.box));return r.every(E=>E.pure)&&L.length>0&&L.every(E=>Ot.has(E)||y.has(E)&&!ht(y.get(E),{unit:E}))},Z=new Set,rt=e=>{if(e?.unit!==void 0){let i=et(e.unit);i.unit&&Z.add(i.unit)}else Array.isArray(e?.children)&&e.children.forEach(rt)},fe=[],ue=[],$t=new Map;for(let e of k){let i=e?.key;if(e?.insert&&ct(e.insert)){qt({...e.insert,key:e.insert.key??i}),_.set(i,{key:i,status:"applied"});continue}if(e?.insert){let B=Et({...e.insert,key:e.insert.key??i}),H=ae(e.place);if(!B||!H){Y(_,i,!B&&Q[e.insert.type]?.source?Q[e.insert.type].unwritten(e.insert,{packages:Ct().packages}):"position");continue}_.set(i,{key:i,status:"applied"}),Rt(i,i),yt.push({id:i,insert:B,place:H}),rt(e.insert);continue}let r=et(e?.unit);if(e?.force===!0&&r.gone&&typeof e.hash=="string"&&typeof e.unit.id!="string"){let B=Number.isInteger(e.unit.open)&&e.unit.open>=0?p?.units[e.unit.open]:void 0;r=!p||p.units.some(V=>V!==B&&wt(m,V)===e.hash)?{reason:"ambiguous"}:tt(-1,e.hash,!1,[e.unit.blockId]),r.unit&&!r.unit.blockId&&typeof e.unit.blockId=="string"&&X.set(r.unit.id,e.unit.blockId),K.set(e.unit.key,r)}if(e?.source&&r.gone&&typeof e.unit.id=="string"&&e.parts&&typeof e.parts=="object"){let B=Object.entries(e.parts).filter(([,V])=>typeof V=="string"),H=B.length>0?h.units.filter(V=>V.parts&&!xt.has(V.blockId)&&B.every(([U,F])=>V.parts[U]===F)):[];H.length===1&&(r={unit:H[0]},H[0].blockId||X.set(H[0].id,e.unit.id),K.set(e.unit.key,r),ht(e.unit,r)&&q.add(e.unit.key))}let y=typeof e?.size=="string"||typeof e?.toggle=="string"||typeof e?.attribute=="string",L=e?.remove===!0&&Array.isArray(e.items)&&e.force!==!0&&!!r.unit&&ht(e.unit,r)&&bt(r.unit,e.items);if(e?.remove===!0&&Array.isArray(e.items)&&e.force!==!0&&!L&&(r.gone||r.unit&&ht(e.unit,r))){let B=e.items.map(U=>({ref:U,found:et(U)})),H=B.find(U=>!U.found.unit&&!U.found.gone),V=B.filter(U=>U.found.unit&&!Ot.has(U.found.unit));if(H)Y(_,i,H.found.reason);else if(V.some(U=>ht(U.ref,U.found)))r.unit?Kt(i,r.unit):Y(_,i,"changed");else if(V.some(U=>$t.has(U.found.unit)))Y(_,i,"ambiguous");else{_.set(i,{key:i,status:"applied"});for(let{ref:U,found:F}of V)$t.set(F.unit,U.key),Rt(F.unit.id,i),yt.push({id:F.unit.id,remove:!0})}continue}if(!r.unit){r.gone&&(e?.remove===!0||y)?_.set(i,{key:i,status:"applied"}):Y(_,i,r.gone?"missing":r.reason);continue}if(e.replace&&re(r.unit,e.replace)){_.set(i,{key:i,status:"applied"});continue}if(e.source){let B=Q[r.unit.kind]?.definition?.(r.unit.node,Ct().packages);if(typeof B!="string"||B!==e.definition){Y(_,i,"definition");continue}}if(e.table&&Q[r.unit.kind]?.definition){Y(_,i,"invalid");continue}let E=e.source;if(e.source&&typeof e.source=="object"&&(e.force===!0||ht(e.unit,r))){let B=e.force===!0||!r.changed,H=t=>B&&t.every(n=>typeof e.parts?.[n]=="string"&&e.parts[n]===r.unit.parts?.[n]),V=Fn(e.source,e.together),U=V.filter(H).flat(),F=V.filter(t=>!H(t)).flat();if(F.length>0){if(Kt(i,r.unit,F,U.length>0?{wrote:U}:{}),U.length===0)continue;E=Object.fromEntries(U.map(t=>[t,e.source[t]]))}}else if((e.remove===!0||e.replace||e.table)&&!L&&(e.force===!0?j(r.unit)!==e.hash:ht(e.unit,r))){Kt(i,r.unit);continue}let M=E!==e.source;if($t.has(r.unit)&&$t.get(r.unit)!==e.unit.key){Y(_,i,"ambiguous");continue}$t.set(r.unit,e.unit.key);let A=null;if(e.remove===!0){A={remove:!0};let{unit:B}=r,H=B.companion?Ge(s,B):kt(s.slice(B.start,B.end),G(s,B.start),"");_t[i]={source:H,seal:w?w(H):null,...Nt(B).length>0?{around:!0}:{}}}else if(e.move){let B=ae(e.move);if(!B){Y(_,i,"position");continue}A={move:B,stood:e.stood}}else e.replace?A={replace:e.replace}:typeof e.retag=="string"?A={retag:e.retag}:e.table&&typeof e.table=="object"?A={table:e.table}:E&&typeof E=="object"?A={source:E}:typeof e.toggle=="string"?A={toggle:e.toggle,on:e.on}:typeof e.size=="string"?A={size:e.size,value:e.value}:typeof e.attribute=="string"&&(A={attribute:e.attribute,value:e.value});if(!A){Y(_,i,"unknown");continue}M||_.set(i,{key:i,status:"applied"}),Rt(r.unit.id,i),yt.push({id:r.unit.id,...A}),A.attribute===_n&&typeof A.value=="string"&&ue.push(r.unit),A.move&&Z.add(r.unit),A.remove&&fe.push({key:i,unit:r.unit})}for(let{key:e,unit:i}of fe)Nt(i).every(r=>Z.has(r))||(Y(_,e,"position"),delete _t[e],yt.splice(yt.findIndex(r=>r.id===i.id&&r.remove),1));let Se=[...new Set(g.map(et).filter(e=>e.unit).map(e=>e.unit.id))],D=fn({current:s,edits:mt,units:yt,partial:!0,ids:$,touch:Se,proposals:X}),Jt=new Map((D.ids?.assigned??[]).map(({at:e,id:i})=>[e,i])),Qt=new Set(ue.map(e=>e.blockId??Jt.get(e.at)).filter(Boolean)),st=kn(D.text,new Set((D.ids?.created??[]).map(({id:e})=>e)),Qt);D.text=st.text;for(let e of D.conflicts??[]){e.id!==void 0&&Zt.has(e.id)&&Y(gt,Zt.get(e.id),e.reason);for(let i of Ut.get(e.unit)??[])Y(_,i,e.reason),delete _t[i]}let it=At(D.text),dt=new Map,Xt=new Map(D.ids.assigned.map(({at:e,id:i})=>[e,i]));for(let[e,i]of K){let r=i.unit?i.unit.blockId??Xt.get(i.unit.at):null;r&&dt.set(e,r)}for(let[e,{unit:i,held:r}]of Yt){let y=i.blockId??Xt.get(i.at),L=y?it.units.filter(E=>E.blockId===y):[];L.length===1&&_.get(e)?.reason==="changed"&&Object.assign(_.get(e),Wt(D.text,it,L[0],r))}let Lt=new Map([...oe,...D.ids.created].map(({key:e,id:i})=>[e,i])),te=new Set([...dt.values(),...Lt.values()]),Ht=new Set(it.units.map(e=>e.blockId).filter(Boolean)),Ae=[...te].filter(e=>!Ht.has(e)),de=new Map,ee=new Map,Mt=e=>{let r=(Array.isArray(e?.children)?e.children.map(Mt).some(Boolean):!1)||[e?.unit,e?.copy].some(y=>y!==void 0&&q.has(y?.key));return e?.key!==void 0&&ee.set(e.key,r),r};for(let e of k)e?.insert&&Mt({...e.insert,key:e.insert.key??e.key});for(let[e,i]of[...dt,...[...Lt].filter(([r])=>ee.get(r)!==!0)]){if(q.has(e))continue;let r=it.units.filter(y=>y.blockId===i);r.length===1&&de.set(e,wt(D.text,r[0]))}let lt=k.filter(e=>Ie[e?.insert?.type]?.keyed&&typeof e.insert.id=="string"&&_.get(e.key)?.status==="applied").map(e=>({key:e.insert.id,box:Ie[e.insert.type].box}));return{text:D.text,version:me(D.text),texts:[...gt.values()],units:[..._.values()],ids:Object.fromEntries(dt),made:Object.fromEntries(Lt),hashes:Object.fromEntries(de),removed:_t,gone:Ae,file:Gn(D.text,it,te,new Set(Lt.values())),outside:Vn(D.text,it),keyed:Dn(D.text,it,lt),...Object.keys(st.keys).length>0?{chartKeys:st.keys}:{},...D.title?{title:D.title}:{},...D.icon!==void 0?{icon:D.icon}:{}}}function Fn(s,m){let I=[];for(let k of[...Array.isArray(m)?m:[],...Object.keys(s).map(g=>[g])]){let g=Array.isArray(k)?k.filter(w=>typeof w=="string"&&Object.hasOwn(s,w)):[],$=I.filter(w=>g.some(u=>w.includes(u)));if(g.length!==0){for(let w of $)I.splice(I.indexOf(w),1);I.push([...new Set([...$.flat(),...g])])}}return I}function Dn(s,m,I){let k={};for(let{key:g,box:$}of I){let w=m.boxes.find(u=>u.kind===$&&u.key===g);w&&(k[g]={units:m.units.filter(u=>u.box===w.id).map(u=>u.blockId??{hash:wt(s,u)})})}return k}function Vn(s,m){let I={};for(let k of m.blocks){let g=k.unit===null?Rn(k.kind==="title",yn(k.node,"id")):null;g&&(I[g]=s.slice(k.innerStart,k.innerEnd))}return I}function Gn(s,m,I,k){let g=new Map;for(let u of m.units)u.blockId&&g.set(u.blockId,(g.get(u.blockId)??0)+1);let $=u=>{for(let h=u.parent;h!=null;h=m.units[h].parent)if(k.has(m.units[h].blockId))return!0;return!1},w={};for(let u of m.units){if(!u.blockId||g.get(u.blockId)!==1||!(I.has(u.blockId)||$(u)))continue;let h=u.parent===null?null:m.units[u.parent];w[u.blockId]={kind:u.kind,hash:wt(s,u),keep:u.keep??null,...u.grid?{grid:!0}:{},...u.parts?{parts:u.parts}:{},parent:h?h.blockId??"":null,boxes:m.boxes.filter(p=>p.unit===u.id).map(p=>({kind:p.kind,key:p.key,units:m.units.filter(f=>f.box===p.id).map(f=>f.blockId??{hash:wt(s,f)})})),blocks:m.blocks.filter(p=>p.unit===u.id).map(p=>({...p.self!==null?{self:!0}:{path:p.path},kind:p.kind,caps:Object.keys(p.caps),inner:s.slice(p.innerStart,p.innerEnd),...p.atoms.length>0?{atoms:p.atoms}:{}})),...Q[u.kind]?.definition&&(k.has(u.blockId)||$(u))?{markup:s.slice(u.elStart,u.end)}:{}}}return w}function Ys({current:s,units:m=[]}){let I=At(s),k=[];for(let g of m){if(typeof g?.id!="string"||typeof g.key!="string"&&typeof g.key!="number")continue;let $=I.units.filter(u=>u.blockId===g.id);if($.length===0){k.push({key:g.key,gone:!0});continue}if($.length>1||g.from===void 0||g.from===g.parent||g.from===""||g.parent==="")continue;($[0].parent===null?null:I.units[$[0].parent].blockId??"")===g.from&&k.push({key:g.key,moved:!0})}return k}function Ws({current:s,instances:m=[],pageIds:I=null}){let k=At(s),g=new Set(Array.isArray(I)?I.filter(w=>typeof w=="string"):[]),$=[];for(let w of m){if(typeof w?.id!="string"||typeof w.key!="string"&&typeof w.key!="number"||!w.parts||typeof w.parts!="object")continue;let u=j=>Object.entries(w.parts).filter(([K,q])=>typeof j.parts?.[K]=="string"&&j.parts[K]!==q?.after&&Array.isArray(q?.before)&&q.before.includes(j.parts[K])),h=k.units.filter(j=>j.blockId===w.id),p=h.length===0?k.units.filter(j=>j.parts&&!g.has(j.blockId)&&u(j).length>0):[],f=h.length===1?h[0]:p.length===1?p[0]:null,O=f?u(f):[];O.length>0&&$.push({key:w.key,parts:Object.fromEntries(O.map(([j])=>[j,f.parts[j]])),markup:s.slice(f.elStart,f.end)})}return $}function Zs({current:s,opening:m=null,texts:I=[],pageIds:k=null}){let g=I.filter(f=>typeof f?.block?.before=="string"&&typeof f.original=="string").map(f=>({entry:f,was:new Set([f.original,...Array.isArray(f.earlier)?f.earlier.filter(O=>typeof O=="string"):[]].filter(O=>O!==f.block.before))})).filter(({was:f})=>f.size>0),$=f=>Hn({current:s,opening:m,ids:!1,pageIds:k,texts:f.map(({entry:{key:O,block:j}})=>({key:O,block:j,parts:[{keep:!0,html:j.before}]}))}).texts,w=$(g),u=new Set(w.filter(f=>f.reason==="overlap").map(f=>f.key)),h=[...w.filter(f=>!u.has(f.key)),...g.filter(({entry:f})=>u.has(f.key)).flatMap(f=>$([f]))],p=new Map(g.map(({entry:f,was:O})=>[f.key,O]));return h.filter(f=>f.status==="merged"&&p.get(f.key)?.has(f.html)).map(({key:f,html:O})=>({key:f,theirs:O}))}export{fn as a,xs as b,hn as c,Hn as d,Ys as e,Ws as f,Zs as g};