@surething/cockpit 1.0.194 → 1.0.195

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 (385) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +4 -3
  3. package/.next-prod/build-manifest.json +3 -3
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/react-loadable-manifest.json +1 -1
  6. package/.next-prod/routes-manifest.json +6 -0
  7. package/.next-prod/server/app/_global-error/page.js +3 -3
  8. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next-prod/server/app/_global-error.html +1 -1
  10. package/.next-prod/server/app/_global-error.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  14. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  15. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  16. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  17. package/.next-prod/server/app/_not-found/page.js +2 -2
  18. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  19. package/.next-prod/server/app/_not-found.html +2 -2
  20. package/.next-prod/server/app/_not-found.rsc +2 -2
  21. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +2 -2
  22. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  23. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +2 -2
  24. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  25. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  26. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  27. package/.next-prod/server/app/api/bash/route.js +1 -1
  28. package/.next-prod/server/app/api/chat/codex/route.js +2 -2
  29. package/.next-prod/server/app/api/chat/deepseek/route.js +16 -0
  30. package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -0
  31. package/.next-prod/server/app/api/chat/deepseek/route_client-reference-manifest.js +1 -0
  32. package/.next-prod/server/app/api/chat/kimi/route.js +13 -13
  33. package/.next-prod/server/app/api/chat/ollama/route.js +2 -2
  34. package/.next-prod/server/app/api/chat/route.js +1 -1
  35. package/.next-prod/server/app/api/claude-stats/route.js +1 -1
  36. package/.next-prod/server/app/api/commands/route.js +1 -1
  37. package/.next-prod/server/app/api/comments/route.js +1 -1
  38. package/.next-prod/server/app/api/db/columns/route.js +2 -2
  39. package/.next-prod/server/app/api/db/connect/route.js +1 -1
  40. package/.next-prod/server/app/api/db/disconnect/route.js +1 -1
  41. package/.next-prod/server/app/api/db/export/route.js +1 -1
  42. package/.next-prod/server/app/api/db/query/route.js +1 -1
  43. package/.next-prod/server/app/api/db/schemas/route.js +1 -1
  44. package/.next-prod/server/app/api/extension/version/route.js +1 -1
  45. package/.next-prod/server/app/api/file/route.js +1 -1
  46. package/.next-prod/server/app/api/files/blame/route.js +1 -1
  47. package/.next-prod/server/app/api/files/clipboard/route.js +1 -1
  48. package/.next-prod/server/app/api/files/copy/route.js +1 -1
  49. package/.next-prod/server/app/api/files/delete/route.js +1 -1
  50. package/.next-prod/server/app/api/files/expanded/route.js +1 -1
  51. package/.next-prod/server/app/api/files/index/route.js +1 -1
  52. package/.next-prod/server/app/api/files/init/route.js +1 -1
  53. package/.next-prod/server/app/api/files/paste/route.js +1 -1
  54. package/.next-prod/server/app/api/files/read/route.js +1 -1
  55. package/.next-prod/server/app/api/files/readdir/route.js +1 -1
  56. package/.next-prod/server/app/api/files/recent/route.js +1 -1
  57. package/.next-prod/server/app/api/files/save/route.js +1 -1
  58. package/.next-prod/server/app/api/files/search/route.js +1 -1
  59. package/.next-prod/server/app/api/files/stat/route.js +1 -1
  60. package/.next-prod/server/app/api/files/text/route.js +1 -1
  61. package/.next-prod/server/app/api/git/branch-diff/route.js +1 -1
  62. package/.next-prod/server/app/api/git/branches/route.js +1 -1
  63. package/.next-prod/server/app/api/git/commit-diff/route.js +1 -1
  64. package/.next-prod/server/app/api/git/commits/route.js +1 -1
  65. package/.next-prod/server/app/api/git/diff/route.js +1 -1
  66. package/.next-prod/server/app/api/git/discard/route.js +1 -1
  67. package/.next-prod/server/app/api/git/stage/route.js +1 -1
  68. package/.next-prod/server/app/api/git/status/route.js +1 -1
  69. package/.next-prod/server/app/api/git/unstage/route.js +1 -1
  70. package/.next-prod/server/app/api/git/worktree/route.js +1 -1
  71. package/.next-prod/server/app/api/global-state/route.js +1 -1
  72. package/.next-prod/server/app/api/jupyter/load/route.js +1 -1
  73. package/.next-prod/server/app/api/jupyter/save/route.js +1 -1
  74. package/.next-prod/server/app/api/jupyter/shutdown/route.js +1 -1
  75. package/.next-prod/server/app/api/lsp/definition/route.js +1 -1
  76. package/.next-prod/server/app/api/lsp/hover/route.js +1 -1
  77. package/.next-prod/server/app/api/lsp/references/route.js +1 -1
  78. package/.next-prod/server/app/api/lsp/status/route.js +1 -1
  79. package/.next-prod/server/app/api/lsp/warmup/route.js +1 -1
  80. package/.next-prod/server/app/api/mysql/columns/route.js +2 -2
  81. package/.next-prod/server/app/api/mysql/connect/route.js +1 -1
  82. package/.next-prod/server/app/api/mysql/disconnect/route.js +1 -1
  83. package/.next-prod/server/app/api/mysql/export/route.js +1 -1
  84. package/.next-prod/server/app/api/mysql/query/route.js +1 -1
  85. package/.next-prod/server/app/api/mysql/schemas/route.js +2 -2
  86. package/.next-prod/server/app/api/neo4j/connect/route.js +1 -1
  87. package/.next-prod/server/app/api/neo4j/disconnect/route.js +1 -1
  88. package/.next-prod/server/app/api/neo4j/query/route.js +1 -1
  89. package/.next-prod/server/app/api/neo4j/schema/route.js +1 -1
  90. package/.next-prod/server/app/api/note/route.js +1 -1
  91. package/.next-prod/server/app/api/ollama/models/route.js +1 -1
  92. package/.next-prod/server/app/api/ollama/start/route.js +1 -1
  93. package/.next-prod/server/app/api/open-cursor/route.js +1 -1
  94. package/.next-prod/server/app/api/open-vscode/route.js +1 -1
  95. package/.next-prod/server/app/api/pick-folder/route.js +1 -1
  96. package/.next-prod/server/app/api/pinned-sessions/route.js +1 -1
  97. package/.next-prod/server/app/api/project-settings/route.js +1 -1
  98. package/.next-prod/server/app/api/project-state/route.js +1 -1
  99. package/.next-prod/server/app/api/projects/route.js +1 -1
  100. package/.next-prod/server/app/api/redis/command/route.js +1 -1
  101. package/.next-prod/server/app/api/redis/connect/route.js +1 -1
  102. package/.next-prod/server/app/api/redis/delete/route.js +1 -1
  103. package/.next-prod/server/app/api/redis/disconnect/route.js +1 -1
  104. package/.next-prod/server/app/api/redis/get/route.js +1 -1
  105. package/.next-prod/server/app/api/redis/keys/route.js +1 -1
  106. package/.next-prod/server/app/api/redis/set/route.js +1 -1
  107. package/.next-prod/server/app/api/review/[id]/comments/route.js +1 -1
  108. package/.next-prod/server/app/api/review/[id]/replies/route.js +1 -1
  109. package/.next-prod/server/app/api/review/[id]/route.js +1 -1
  110. package/.next-prod/server/app/api/review/identify/route.js +1 -1
  111. package/.next-prod/server/app/api/review/order/route.js +1 -1
  112. package/.next-prod/server/app/api/review/route.js +1 -1
  113. package/.next-prod/server/app/api/review/share-info/route.js +1 -1
  114. package/.next-prod/server/app/api/review/users/route.js +1 -1
  115. package/.next-prod/server/app/api/scheduled-tasks/route.js +1 -1
  116. package/.next-prod/server/app/api/services/config/route.js +1 -1
  117. package/.next-prod/server/app/api/services/scripts/route.js +1 -1
  118. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js +1 -1
  119. package/.next-prod/server/app/api/session/[sessionId]/history/route.js +1 -1
  120. package/.next-prod/server/app/api/session-by-path/route.js +1 -1
  121. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js +1 -1
  122. package/.next-prod/server/app/api/sessions/projects/route.js +1 -1
  123. package/.next-prod/server/app/api/sessions/route.js +1 -1
  124. package/.next-prod/server/app/api/settings/route.js +1 -1
  125. package/.next-prod/server/app/api/skills/[id]/route.js +1 -1
  126. package/.next-prod/server/app/api/skills/content/route.js +1 -1
  127. package/.next-prod/server/app/api/skills/route.js +1 -1
  128. package/.next-prod/server/app/api/terminal/aliases/route.js +1 -1
  129. package/.next-prod/server/app/api/terminal/autocomplete/route.js +1 -1
  130. package/.next-prod/server/app/api/terminal/bubble-order/route.js +1 -1
  131. package/.next-prod/server/app/api/terminal/env/route.js +1 -1
  132. package/.next-prod/server/app/api/terminal/history/route.js +1 -1
  133. package/.next-prod/server/app/api/version/route.js +1 -1
  134. package/.next-prod/server/app/favicon.ico/route.js +1 -1
  135. package/.next-prod/server/app/manifest.webmanifest/route.js +2 -2
  136. package/.next-prod/server/app/page.js +3 -3
  137. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  138. package/.next-prod/server/app/project/page.js +5 -5
  139. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  140. package/.next-prod/server/app/review/[id]/page.js +2 -2
  141. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  142. package/.next-prod/server/app-paths-manifest.json +4 -3
  143. package/.next-prod/server/chunks/4098.js +1 -1
  144. package/.next-prod/server/chunks/4490.js +1 -1
  145. package/.next-prod/server/chunks/5394.js +1 -1
  146. package/.next-prod/server/middleware-build-manifest.js +1 -1
  147. package/.next-prod/server/middleware-react-loadable-manifest.js +1 -1
  148. package/.next-prod/server/pages/404.html +2 -2
  149. package/.next-prod/server/pages/500.html +1 -1
  150. package/.next-prod/server/server-reference-manifest.json +1 -1
  151. package/.next-prod/static/chunks/{700.0aaec5a3a570d182.js → 700.642136ad4fbe16ca.js} +4 -4
  152. package/.next-prod/static/chunks/app/{api/bash/route-94e40d01eb0846a0.js → _global-error/page-aa58df485295770f.js} +1 -1
  153. package/.next-prod/static/chunks/app/api/{chat/codex/route-94e40d01eb0846a0.js → bash/route-aa58df485295770f.js} +1 -1
  154. package/.next-prod/static/chunks/app/api/chat/{kimi/route-94e40d01eb0846a0.js → codex/route-aa58df485295770f.js} +1 -1
  155. package/.next-prod/static/chunks/app/{_global-error/page-94e40d01eb0846a0.js → api/chat/deepseek/route-aa58df485295770f.js} +1 -1
  156. package/.next-prod/static/chunks/app/api/chat/kimi/route-aa58df485295770f.js +1 -0
  157. package/.next-prod/static/chunks/app/api/chat/ollama/route-aa58df485295770f.js +1 -0
  158. package/.next-prod/static/chunks/app/api/chat/route-aa58df485295770f.js +1 -0
  159. package/.next-prod/static/chunks/app/api/claude-stats/route-aa58df485295770f.js +1 -0
  160. package/.next-prod/static/chunks/app/api/commands/route-aa58df485295770f.js +1 -0
  161. package/.next-prod/static/chunks/app/api/comments/route-aa58df485295770f.js +1 -0
  162. package/.next-prod/static/chunks/app/api/db/columns/route-aa58df485295770f.js +1 -0
  163. package/.next-prod/static/chunks/app/api/db/connect/route-aa58df485295770f.js +1 -0
  164. package/.next-prod/static/chunks/app/api/db/disconnect/route-aa58df485295770f.js +1 -0
  165. package/.next-prod/static/chunks/app/api/db/export/route-aa58df485295770f.js +1 -0
  166. package/.next-prod/static/chunks/app/api/db/query/route-aa58df485295770f.js +1 -0
  167. package/.next-prod/static/chunks/app/api/db/schemas/route-aa58df485295770f.js +1 -0
  168. package/.next-prod/static/chunks/app/api/extension/version/route-aa58df485295770f.js +1 -0
  169. package/.next-prod/static/chunks/app/api/file/route-aa58df485295770f.js +1 -0
  170. package/.next-prod/static/chunks/app/api/files/blame/route-aa58df485295770f.js +1 -0
  171. package/.next-prod/static/chunks/app/api/files/clipboard/route-aa58df485295770f.js +1 -0
  172. package/.next-prod/static/chunks/app/api/files/copy/route-aa58df485295770f.js +1 -0
  173. package/.next-prod/static/chunks/app/api/files/delete/route-aa58df485295770f.js +1 -0
  174. package/.next-prod/static/chunks/app/api/files/expanded/route-aa58df485295770f.js +1 -0
  175. package/.next-prod/static/chunks/app/api/files/index/route-aa58df485295770f.js +1 -0
  176. package/.next-prod/static/chunks/app/api/files/init/route-aa58df485295770f.js +1 -0
  177. package/.next-prod/static/chunks/app/api/files/paste/route-aa58df485295770f.js +1 -0
  178. package/.next-prod/static/chunks/app/api/files/read/route-aa58df485295770f.js +1 -0
  179. package/.next-prod/static/chunks/app/api/files/readdir/route-aa58df485295770f.js +1 -0
  180. package/.next-prod/static/chunks/app/api/files/recent/route-aa58df485295770f.js +1 -0
  181. package/.next-prod/static/chunks/app/api/files/save/route-aa58df485295770f.js +1 -0
  182. package/.next-prod/static/chunks/app/api/files/search/route-aa58df485295770f.js +1 -0
  183. package/.next-prod/static/chunks/app/api/files/stat/route-aa58df485295770f.js +1 -0
  184. package/.next-prod/static/chunks/app/api/files/text/route-aa58df485295770f.js +1 -0
  185. package/.next-prod/static/chunks/app/api/git/branch-diff/route-aa58df485295770f.js +1 -0
  186. package/.next-prod/static/chunks/app/api/git/branches/route-aa58df485295770f.js +1 -0
  187. package/.next-prod/static/chunks/app/api/git/commit-diff/route-aa58df485295770f.js +1 -0
  188. package/.next-prod/static/chunks/app/api/git/commits/route-aa58df485295770f.js +1 -0
  189. package/.next-prod/static/chunks/app/api/git/diff/route-aa58df485295770f.js +1 -0
  190. package/.next-prod/static/chunks/app/api/git/discard/route-aa58df485295770f.js +1 -0
  191. package/.next-prod/static/chunks/app/api/git/stage/route-aa58df485295770f.js +1 -0
  192. package/.next-prod/static/chunks/app/api/git/status/route-aa58df485295770f.js +1 -0
  193. package/.next-prod/static/chunks/app/api/git/unstage/route-aa58df485295770f.js +1 -0
  194. package/.next-prod/static/chunks/app/api/git/worktree/route-aa58df485295770f.js +1 -0
  195. package/.next-prod/static/chunks/app/api/global-state/route-aa58df485295770f.js +1 -0
  196. package/.next-prod/static/chunks/app/api/jupyter/load/route-aa58df485295770f.js +1 -0
  197. package/.next-prod/static/chunks/app/api/jupyter/save/route-aa58df485295770f.js +1 -0
  198. package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-aa58df485295770f.js +1 -0
  199. package/.next-prod/static/chunks/app/api/lsp/definition/route-aa58df485295770f.js +1 -0
  200. package/.next-prod/static/chunks/app/api/lsp/hover/route-aa58df485295770f.js +1 -0
  201. package/.next-prod/static/chunks/app/api/lsp/references/route-aa58df485295770f.js +1 -0
  202. package/.next-prod/static/chunks/app/api/lsp/status/route-aa58df485295770f.js +1 -0
  203. package/.next-prod/static/chunks/app/api/lsp/warmup/route-aa58df485295770f.js +1 -0
  204. package/.next-prod/static/chunks/app/api/mysql/columns/route-aa58df485295770f.js +1 -0
  205. package/.next-prod/static/chunks/app/api/mysql/connect/route-aa58df485295770f.js +1 -0
  206. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-aa58df485295770f.js +1 -0
  207. package/.next-prod/static/chunks/app/api/mysql/export/route-aa58df485295770f.js +1 -0
  208. package/.next-prod/static/chunks/app/api/mysql/query/route-aa58df485295770f.js +1 -0
  209. package/.next-prod/static/chunks/app/api/mysql/schemas/route-aa58df485295770f.js +1 -0
  210. package/.next-prod/static/chunks/app/api/neo4j/connect/route-aa58df485295770f.js +1 -0
  211. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-aa58df485295770f.js +1 -0
  212. package/.next-prod/static/chunks/app/api/neo4j/query/route-aa58df485295770f.js +1 -0
  213. package/.next-prod/static/chunks/app/api/neo4j/schema/route-aa58df485295770f.js +1 -0
  214. package/.next-prod/static/chunks/app/api/note/route-aa58df485295770f.js +1 -0
  215. package/.next-prod/static/chunks/app/api/ollama/models/route-aa58df485295770f.js +1 -0
  216. package/.next-prod/static/chunks/app/api/ollama/start/route-aa58df485295770f.js +1 -0
  217. package/.next-prod/static/chunks/app/api/open-cursor/route-aa58df485295770f.js +1 -0
  218. package/.next-prod/static/chunks/app/api/open-vscode/route-aa58df485295770f.js +1 -0
  219. package/.next-prod/static/chunks/app/api/pick-folder/route-aa58df485295770f.js +1 -0
  220. package/.next-prod/static/chunks/app/api/pinned-sessions/route-aa58df485295770f.js +1 -0
  221. package/.next-prod/static/chunks/app/api/project-settings/route-aa58df485295770f.js +1 -0
  222. package/.next-prod/static/chunks/app/api/project-state/route-aa58df485295770f.js +1 -0
  223. package/.next-prod/static/chunks/app/api/projects/route-aa58df485295770f.js +1 -0
  224. package/.next-prod/static/chunks/app/api/redis/command/route-aa58df485295770f.js +1 -0
  225. package/.next-prod/static/chunks/app/api/redis/connect/route-aa58df485295770f.js +1 -0
  226. package/.next-prod/static/chunks/app/api/redis/delete/route-aa58df485295770f.js +1 -0
  227. package/.next-prod/static/chunks/app/api/redis/disconnect/route-aa58df485295770f.js +1 -0
  228. package/.next-prod/static/chunks/app/api/redis/get/route-aa58df485295770f.js +1 -0
  229. package/.next-prod/static/chunks/app/api/redis/keys/route-aa58df485295770f.js +1 -0
  230. package/.next-prod/static/chunks/app/api/redis/set/route-aa58df485295770f.js +1 -0
  231. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-aa58df485295770f.js +1 -0
  232. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-aa58df485295770f.js +1 -0
  233. package/.next-prod/static/chunks/app/api/review/[id]/route-aa58df485295770f.js +1 -0
  234. package/.next-prod/static/chunks/app/api/review/identify/route-aa58df485295770f.js +1 -0
  235. package/.next-prod/static/chunks/app/api/review/order/route-aa58df485295770f.js +1 -0
  236. package/.next-prod/static/chunks/app/api/review/route-aa58df485295770f.js +1 -0
  237. package/.next-prod/static/chunks/app/api/review/share-info/route-aa58df485295770f.js +1 -0
  238. package/.next-prod/static/chunks/app/api/review/users/route-aa58df485295770f.js +1 -0
  239. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-aa58df485295770f.js +1 -0
  240. package/.next-prod/static/chunks/app/api/services/config/route-aa58df485295770f.js +1 -0
  241. package/.next-prod/static/chunks/app/api/services/scripts/route-aa58df485295770f.js +1 -0
  242. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-aa58df485295770f.js +1 -0
  243. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-aa58df485295770f.js +1 -0
  244. package/.next-prod/static/chunks/app/api/session-by-path/route-aa58df485295770f.js +1 -0
  245. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-aa58df485295770f.js +1 -0
  246. package/.next-prod/static/chunks/app/api/sessions/projects/route-aa58df485295770f.js +1 -0
  247. package/.next-prod/static/chunks/app/api/sessions/route-aa58df485295770f.js +1 -0
  248. package/.next-prod/static/chunks/app/api/settings/route-aa58df485295770f.js +1 -0
  249. package/.next-prod/static/chunks/app/api/skills/[id]/route-aa58df485295770f.js +1 -0
  250. package/.next-prod/static/chunks/app/api/skills/content/route-aa58df485295770f.js +1 -0
  251. package/.next-prod/static/chunks/app/api/skills/route-aa58df485295770f.js +1 -0
  252. package/.next-prod/static/chunks/app/api/terminal/aliases/route-aa58df485295770f.js +1 -0
  253. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-aa58df485295770f.js +1 -0
  254. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-aa58df485295770f.js +1 -0
  255. package/.next-prod/static/chunks/app/api/terminal/env/route-aa58df485295770f.js +1 -0
  256. package/.next-prod/static/chunks/app/api/terminal/history/route-aa58df485295770f.js +1 -0
  257. package/.next-prod/static/chunks/app/api/version/route-aa58df485295770f.js +1 -0
  258. package/.next-prod/static/chunks/app/manifest.webmanifest/route-aa58df485295770f.js +1 -0
  259. package/.next-prod/static/chunks/app/project/page-3a148e22b1d92a17.js +29 -0
  260. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-aa58df485295770f.js +1 -0
  261. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-aa58df485295770f.js +1 -0
  262. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-aa58df485295770f.js +1 -0
  263. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-aa58df485295770f.js +1 -0
  264. package/.next-prod/static/chunks/{webpack-9a8ea3995034c536.js → webpack-c669c0003eb75661.js} +1 -1
  265. package/.next-prod/static/css/083cb04521b4969d.css +1 -0
  266. package/.next-prod/static/iLRBjFXcqOGmNS619Y9Uo/_buildManifest.js +1 -0
  267. package/.next-prod/trace +12 -12
  268. package/.next-prod/trace-build +1 -1
  269. package/.next-prod/types/app/api/chat/deepseek/route.ts +351 -0
  270. package/.next-prod/types/routes.d.ts +2 -1
  271. package/.next-prod/types/validator.ts +9 -0
  272. package/dist/{chunk-ZDTXJE6Z.mjs → chunk-J6PMXUI4.mjs} +2 -0
  273. package/dist/scheduledTasks.mjs +1 -1
  274. package/dist/wsServer.mjs +1 -1
  275. package/package.json +1 -1
  276. package/.next-prod/static/GrlHt_NxoSxuOTl-aMQdx/_buildManifest.js +0 -1
  277. package/.next-prod/static/chunks/app/api/chat/ollama/route-94e40d01eb0846a0.js +0 -1
  278. package/.next-prod/static/chunks/app/api/chat/route-94e40d01eb0846a0.js +0 -1
  279. package/.next-prod/static/chunks/app/api/claude-stats/route-94e40d01eb0846a0.js +0 -1
  280. package/.next-prod/static/chunks/app/api/commands/route-94e40d01eb0846a0.js +0 -1
  281. package/.next-prod/static/chunks/app/api/comments/route-94e40d01eb0846a0.js +0 -1
  282. package/.next-prod/static/chunks/app/api/db/columns/route-94e40d01eb0846a0.js +0 -1
  283. package/.next-prod/static/chunks/app/api/db/connect/route-94e40d01eb0846a0.js +0 -1
  284. package/.next-prod/static/chunks/app/api/db/disconnect/route-94e40d01eb0846a0.js +0 -1
  285. package/.next-prod/static/chunks/app/api/db/export/route-94e40d01eb0846a0.js +0 -1
  286. package/.next-prod/static/chunks/app/api/db/query/route-94e40d01eb0846a0.js +0 -1
  287. package/.next-prod/static/chunks/app/api/db/schemas/route-94e40d01eb0846a0.js +0 -1
  288. package/.next-prod/static/chunks/app/api/extension/version/route-94e40d01eb0846a0.js +0 -1
  289. package/.next-prod/static/chunks/app/api/file/route-94e40d01eb0846a0.js +0 -1
  290. package/.next-prod/static/chunks/app/api/files/blame/route-94e40d01eb0846a0.js +0 -1
  291. package/.next-prod/static/chunks/app/api/files/clipboard/route-94e40d01eb0846a0.js +0 -1
  292. package/.next-prod/static/chunks/app/api/files/copy/route-94e40d01eb0846a0.js +0 -1
  293. package/.next-prod/static/chunks/app/api/files/delete/route-94e40d01eb0846a0.js +0 -1
  294. package/.next-prod/static/chunks/app/api/files/expanded/route-94e40d01eb0846a0.js +0 -1
  295. package/.next-prod/static/chunks/app/api/files/index/route-94e40d01eb0846a0.js +0 -1
  296. package/.next-prod/static/chunks/app/api/files/init/route-94e40d01eb0846a0.js +0 -1
  297. package/.next-prod/static/chunks/app/api/files/paste/route-94e40d01eb0846a0.js +0 -1
  298. package/.next-prod/static/chunks/app/api/files/read/route-94e40d01eb0846a0.js +0 -1
  299. package/.next-prod/static/chunks/app/api/files/readdir/route-94e40d01eb0846a0.js +0 -1
  300. package/.next-prod/static/chunks/app/api/files/recent/route-94e40d01eb0846a0.js +0 -1
  301. package/.next-prod/static/chunks/app/api/files/save/route-94e40d01eb0846a0.js +0 -1
  302. package/.next-prod/static/chunks/app/api/files/search/route-94e40d01eb0846a0.js +0 -1
  303. package/.next-prod/static/chunks/app/api/files/stat/route-94e40d01eb0846a0.js +0 -1
  304. package/.next-prod/static/chunks/app/api/files/text/route-94e40d01eb0846a0.js +0 -1
  305. package/.next-prod/static/chunks/app/api/git/branch-diff/route-94e40d01eb0846a0.js +0 -1
  306. package/.next-prod/static/chunks/app/api/git/branches/route-94e40d01eb0846a0.js +0 -1
  307. package/.next-prod/static/chunks/app/api/git/commit-diff/route-94e40d01eb0846a0.js +0 -1
  308. package/.next-prod/static/chunks/app/api/git/commits/route-94e40d01eb0846a0.js +0 -1
  309. package/.next-prod/static/chunks/app/api/git/diff/route-94e40d01eb0846a0.js +0 -1
  310. package/.next-prod/static/chunks/app/api/git/discard/route-94e40d01eb0846a0.js +0 -1
  311. package/.next-prod/static/chunks/app/api/git/stage/route-94e40d01eb0846a0.js +0 -1
  312. package/.next-prod/static/chunks/app/api/git/status/route-94e40d01eb0846a0.js +0 -1
  313. package/.next-prod/static/chunks/app/api/git/unstage/route-94e40d01eb0846a0.js +0 -1
  314. package/.next-prod/static/chunks/app/api/git/worktree/route-94e40d01eb0846a0.js +0 -1
  315. package/.next-prod/static/chunks/app/api/global-state/route-94e40d01eb0846a0.js +0 -1
  316. package/.next-prod/static/chunks/app/api/jupyter/load/route-94e40d01eb0846a0.js +0 -1
  317. package/.next-prod/static/chunks/app/api/jupyter/save/route-94e40d01eb0846a0.js +0 -1
  318. package/.next-prod/static/chunks/app/api/jupyter/shutdown/route-94e40d01eb0846a0.js +0 -1
  319. package/.next-prod/static/chunks/app/api/lsp/definition/route-94e40d01eb0846a0.js +0 -1
  320. package/.next-prod/static/chunks/app/api/lsp/hover/route-94e40d01eb0846a0.js +0 -1
  321. package/.next-prod/static/chunks/app/api/lsp/references/route-94e40d01eb0846a0.js +0 -1
  322. package/.next-prod/static/chunks/app/api/lsp/status/route-94e40d01eb0846a0.js +0 -1
  323. package/.next-prod/static/chunks/app/api/lsp/warmup/route-94e40d01eb0846a0.js +0 -1
  324. package/.next-prod/static/chunks/app/api/mysql/columns/route-94e40d01eb0846a0.js +0 -1
  325. package/.next-prod/static/chunks/app/api/mysql/connect/route-94e40d01eb0846a0.js +0 -1
  326. package/.next-prod/static/chunks/app/api/mysql/disconnect/route-94e40d01eb0846a0.js +0 -1
  327. package/.next-prod/static/chunks/app/api/mysql/export/route-94e40d01eb0846a0.js +0 -1
  328. package/.next-prod/static/chunks/app/api/mysql/query/route-94e40d01eb0846a0.js +0 -1
  329. package/.next-prod/static/chunks/app/api/mysql/schemas/route-94e40d01eb0846a0.js +0 -1
  330. package/.next-prod/static/chunks/app/api/neo4j/connect/route-94e40d01eb0846a0.js +0 -1
  331. package/.next-prod/static/chunks/app/api/neo4j/disconnect/route-94e40d01eb0846a0.js +0 -1
  332. package/.next-prod/static/chunks/app/api/neo4j/query/route-94e40d01eb0846a0.js +0 -1
  333. package/.next-prod/static/chunks/app/api/neo4j/schema/route-94e40d01eb0846a0.js +0 -1
  334. package/.next-prod/static/chunks/app/api/note/route-94e40d01eb0846a0.js +0 -1
  335. package/.next-prod/static/chunks/app/api/ollama/models/route-94e40d01eb0846a0.js +0 -1
  336. package/.next-prod/static/chunks/app/api/ollama/start/route-94e40d01eb0846a0.js +0 -1
  337. package/.next-prod/static/chunks/app/api/open-cursor/route-94e40d01eb0846a0.js +0 -1
  338. package/.next-prod/static/chunks/app/api/open-vscode/route-94e40d01eb0846a0.js +0 -1
  339. package/.next-prod/static/chunks/app/api/pick-folder/route-94e40d01eb0846a0.js +0 -1
  340. package/.next-prod/static/chunks/app/api/pinned-sessions/route-94e40d01eb0846a0.js +0 -1
  341. package/.next-prod/static/chunks/app/api/project-settings/route-94e40d01eb0846a0.js +0 -1
  342. package/.next-prod/static/chunks/app/api/project-state/route-94e40d01eb0846a0.js +0 -1
  343. package/.next-prod/static/chunks/app/api/projects/route-94e40d01eb0846a0.js +0 -1
  344. package/.next-prod/static/chunks/app/api/redis/command/route-94e40d01eb0846a0.js +0 -1
  345. package/.next-prod/static/chunks/app/api/redis/connect/route-94e40d01eb0846a0.js +0 -1
  346. package/.next-prod/static/chunks/app/api/redis/delete/route-94e40d01eb0846a0.js +0 -1
  347. package/.next-prod/static/chunks/app/api/redis/disconnect/route-94e40d01eb0846a0.js +0 -1
  348. package/.next-prod/static/chunks/app/api/redis/get/route-94e40d01eb0846a0.js +0 -1
  349. package/.next-prod/static/chunks/app/api/redis/keys/route-94e40d01eb0846a0.js +0 -1
  350. package/.next-prod/static/chunks/app/api/redis/set/route-94e40d01eb0846a0.js +0 -1
  351. package/.next-prod/static/chunks/app/api/review/[id]/comments/route-94e40d01eb0846a0.js +0 -1
  352. package/.next-prod/static/chunks/app/api/review/[id]/replies/route-94e40d01eb0846a0.js +0 -1
  353. package/.next-prod/static/chunks/app/api/review/[id]/route-94e40d01eb0846a0.js +0 -1
  354. package/.next-prod/static/chunks/app/api/review/identify/route-94e40d01eb0846a0.js +0 -1
  355. package/.next-prod/static/chunks/app/api/review/order/route-94e40d01eb0846a0.js +0 -1
  356. package/.next-prod/static/chunks/app/api/review/route-94e40d01eb0846a0.js +0 -1
  357. package/.next-prod/static/chunks/app/api/review/share-info/route-94e40d01eb0846a0.js +0 -1
  358. package/.next-prod/static/chunks/app/api/review/users/route-94e40d01eb0846a0.js +0 -1
  359. package/.next-prod/static/chunks/app/api/scheduled-tasks/route-94e40d01eb0846a0.js +0 -1
  360. package/.next-prod/static/chunks/app/api/services/config/route-94e40d01eb0846a0.js +0 -1
  361. package/.next-prod/static/chunks/app/api/services/scripts/route-94e40d01eb0846a0.js +0 -1
  362. package/.next-prod/static/chunks/app/api/session/[sessionId]/fork/route-94e40d01eb0846a0.js +0 -1
  363. package/.next-prod/static/chunks/app/api/session/[sessionId]/history/route-94e40d01eb0846a0.js +0 -1
  364. package/.next-prod/static/chunks/app/api/session-by-path/route-94e40d01eb0846a0.js +0 -1
  365. package/.next-prod/static/chunks/app/api/sessions/projects/[encodedPath]/route-94e40d01eb0846a0.js +0 -1
  366. package/.next-prod/static/chunks/app/api/sessions/projects/route-94e40d01eb0846a0.js +0 -1
  367. package/.next-prod/static/chunks/app/api/sessions/route-94e40d01eb0846a0.js +0 -1
  368. package/.next-prod/static/chunks/app/api/settings/route-94e40d01eb0846a0.js +0 -1
  369. package/.next-prod/static/chunks/app/api/skills/[id]/route-94e40d01eb0846a0.js +0 -1
  370. package/.next-prod/static/chunks/app/api/skills/content/route-94e40d01eb0846a0.js +0 -1
  371. package/.next-prod/static/chunks/app/api/skills/route-94e40d01eb0846a0.js +0 -1
  372. package/.next-prod/static/chunks/app/api/terminal/aliases/route-94e40d01eb0846a0.js +0 -1
  373. package/.next-prod/static/chunks/app/api/terminal/autocomplete/route-94e40d01eb0846a0.js +0 -1
  374. package/.next-prod/static/chunks/app/api/terminal/bubble-order/route-94e40d01eb0846a0.js +0 -1
  375. package/.next-prod/static/chunks/app/api/terminal/env/route-94e40d01eb0846a0.js +0 -1
  376. package/.next-prod/static/chunks/app/api/terminal/history/route-94e40d01eb0846a0.js +0 -1
  377. package/.next-prod/static/chunks/app/api/version/route-94e40d01eb0846a0.js +0 -1
  378. package/.next-prod/static/chunks/app/manifest.webmanifest/route-94e40d01eb0846a0.js +0 -1
  379. package/.next-prod/static/chunks/app/project/page-66c22be12277e5c1.js +0 -29
  380. package/.next-prod/static/chunks/next/dist/client/components/builtin/app-error-94e40d01eb0846a0.js +0 -1
  381. package/.next-prod/static/chunks/next/dist/client/components/builtin/forbidden-94e40d01eb0846a0.js +0 -1
  382. package/.next-prod/static/chunks/next/dist/client/components/builtin/not-found-94e40d01eb0846a0.js +0 -1
  383. package/.next-prod/static/chunks/next/dist/client/components/builtin/unauthorized-94e40d01eb0846a0.js +0 -1
  384. package/.next-prod/static/css/2a6d4c877711db09.css +0 -1
  385. /package/.next-prod/static/{GrlHt_NxoSxuOTl-aMQdx → iLRBjFXcqOGmNS619Y9Uo}/_ssgManifest.js +0 -0
@@ -1,5 +1,4 @@
1
- (()=>{var a={};a.id=8974,a.ids=[8974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1482:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({onSelectSession:a}){let{t:b}=(0,f.Bd)(),[c,h]=(0,e.useState)([]),[i,j]=(0,e.useState)({}),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(""),q=(0,e.useRef)(null);(0,e.useCallback)(async()=>{l(!0),n(null),j({});try{let a=await fetch("/api/sessions/projects");if(!a.ok)throw Error("Failed to load projects");let b=await a.json();h(b)}catch(a){n(a instanceof Error?a.message:"Unknown error")}finally{l(!1)}},[]);let r=(0,e.useCallback)(async a=>{j(b=>({...b,[a]:{...b[a],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));try{let b=await fetch(`/api/sessions/projects/${encodeURIComponent(a)}`);if(!b.ok)throw Error("Failed to load sessions");let c=await b.json();j(b=>({...b,[a]:{...b[a],isLoading:!1,sessions:c}}))}catch(b){j(c=>({...c,[a]:{...c[a],isLoading:!1,error:b instanceof Error?b.message:"Unknown error"}}))}},[]),s=(0,e.useCallback)(a=>{let b=i[a];b?.isExpanded?j(b=>({...b,[a]:{...b[a],isExpanded:!1}})):b?.sessions?.length?j(b=>({...b,[a]:{...b[a],isExpanded:!0}})):r(a)},[i,r]);return(0,d.jsxs)("div",{className:"flex-1 flex flex-col bg-card",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-lg font-medium text-foreground",children:b("workspace.selectProject")}),(0,d.jsx)("input",{ref:q,type:"text",placeholder:b("workspace.searchProjectPath"),value:o,onChange:a=>p(a.target.value),className:"px-3 py-1.5 text-sm border border-border rounded-lg bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[k&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:b("workspace.loadingProjects")})]})}),m&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsx)("div",{className:"text-sm text-red-500",children:m})}),!k&&!m&&0===c.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:b("workspace.projectNotFound")})}),!k&&!m&&(0,d.jsx)("div",{className:"space-y-2",children:c.filter(a=>a.fullPath.toLowerCase().includes(o.toLowerCase())).map(c=>{let e=i[c.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null};return(0,d.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,d.jsxs)("button",{onClick:()=>s(c.encodedPath),className:"w-full flex items-center gap-3 p-3 hover:bg-accent transition-colors text-left",children:[(0,d.jsx)("svg",{className:`w-4 h-4 text-muted-foreground transition-transform ${e.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,d.jsx)("svg",{className:"w-5 h-5 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm font-medium text-foreground truncate",children:c.name}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:c.fullPath})]}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground bg-secondary px-2 py-0.5 rounded",children:b("workspace.sessions",{count:c.sessionCount})})]}),e.isExpanded&&(0,d.jsxs)("div",{className:"border-t border-border bg-secondary/30",children:[e.isLoading&&(0,d.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:b("workspace.loadingSessions")})]}),e.error&&(0,d.jsx)("div",{className:"p-3 text-xs text-red-500",children:e.error}),!e.isLoading&&!e.error&&0===e.sessions.length&&(0,d.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:b("workspace.noSessions")}),!e.isLoading&&!e.error&&e.sessions.map(b=>(0,d.jsxs)("button",{onClick:()=>{a(c.fullPath,(b.path.split("/").pop()||"").replace(".jsonl",""))},className:"w-full flex items-start gap-3 p-3 hover:bg-accent transition-colors text-left border-t border-border first:border-t-0",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:b.title}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:new Date(b.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),b.firstMessages.length>0&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-1 truncate",children:b.firstMessages[0]})]})]},b.path))]})]},c.encodedPath)})})]})]})}},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},14024:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>q});var d=c(48249),e=c(67484),f=c(44384),g=c(33932);function h({currentCwd:a,onSwitchProject:b,collapsed:c,sessions:g}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(0),n=(0,e.useRef)(null),o=(0,e.useCallback)(a=>{b(a.cwd,a.sessionId),k(!1)},[b]),p=g.filter(a=>"loading"===a.status).length,q=g.filter(a=>"unread"===a.status).length,r=(0,e.useCallback)(a=>{let b=Math.floor((l-a)/6e4);if(b<1)return i("common.justNow");if(b<60)return i("common.minutesAgo",{count:b});let c=Math.floor(b/60);return c<24?i("common.hoursAgo",{count:c}):i("common.daysAgo",{count:Math.floor(c/24)})},[i,l]);return(0,d.jsxs)("div",{className:"relative",ref:n,children:[(0,d.jsxs)("button",{onClick:()=>{m(Date.now()),k(!j)},className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"w-full justify-center":"w-full"}`,title:i("sessions.recentSessions"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),!c&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:i("sessions.recentSessions")}),p>0&&(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-orange-9 animate-pulse ${c?"absolute -top-1 -right-1":""}`,children:p}),q>0&&(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${c&&!p?"absolute -top-1 -right-1":""}`,children:q})]}),j&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:i("sessions.recentSessions")}),p>0&&(0,d.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",i("sessions.runningCount",{count:p}),")"]}),q>0&&(0,d.jsxs)("span",{className:"ml-2 text-xs text-red-500",children:["(",i("sessions.unreadCount",{count:q}),")"]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===g.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:i("sessions.noSessions")}):g.map((b,c)=>{let e;return(0,d.jsxs)("button",{onClick:()=>o(b),className:`w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 ${c!==g.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${"loading"===b.status?"bg-orange-9 animate-pulse":"unread"===b.status?"bg-red-500":"bg-muted-foreground/30"}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",title:b.cwd,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"font-medium text-sm truncate",children:(e=b.cwd).split("/").pop()||e}),"loading"===b.status&&(0,d.jsx)("span",{className:"text-xs text-orange-11 flex-shrink-0",children:i("sessions.running")}),"unread"===b.status&&(0,d.jsx)("span",{className:"text-xs text-red-500 flex-shrink-0",children:i("sessions.done")}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:r(b.lastActive)})]}),(b.lastUserMessage||b.title)&&(0,d.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:b.lastUserMessage||b.title})]})]},`${b.cwd}-${b.sessionId}`)})})]})]})}function i({collapsed:a,pinnedSessions:b,onSwitchProject:c,onUnpin:g,onUpdateTitle:h,onReorder:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(!1),n=(0,e.useRef)(null),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(""),s=(0,e.useRef)(null),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(null),x=(0,e.useCallback)(a=>{o||(c(a.cwd,a.sessionId),m(!1))},[c,o]),y=(0,e.useCallback)((a,b)=>{b.stopPropagation(),p(a.sessionId),r(a.customTitle||"")},[]),z=(0,e.useCallback)(()=>{o&&q.trim()&&h(o,q.trim()),p(null)},[o,q,h]),A=(0,e.useCallback)(a=>{u(a)},[]),B=(0,e.useCallback)((a,b)=>{a.preventDefault(),w(b)},[]),C=(0,e.useCallback)(a=>{if(null===t||t===a){u(null),w(null);return}let c=[...b],[d]=c.splice(t,1);c.splice(a,0,d),j(c),u(null),w(null)},[t,b,j]),D=(0,e.useCallback)(()=>{u(null),w(null)},[]);return(0,d.jsxs)("div",{className:"relative",ref:n,children:[(0,d.jsxs)("button",{onClick:()=>m(!l),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:k("sessions.pinnedSessions"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:k("sessions.pinnedSessions")}),a&&b.length>0&&(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length})]}),l&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 max-h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:(0,d.jsx)("span",{className:"text-sm font-medium",children:k("sessions.pinnedSessions")})}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:k("sessions.noPinnedSessions")}):b.map((a,c)=>{let e;return(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>A(c),onDragOver:a=>B(a,c),onDrop:()=>C(c),onDragEnd:D,onClick:()=>x(a),className:`group w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 cursor-pointer ${c!==b.length-1?"border-b border-border/50":""} ${t===c?"opacity-50":""} ${v===c?"border-t-2 border-brand":""}`,children:[(0,d.jsx)("span",{className:"mt-1.5 text-muted-foreground/30 flex-shrink-0 cursor-grab",children:(0,d.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 10 16",fill:"currentColor",children:[(0,d.jsx)("circle",{cx:"3",cy:"2",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"2",r:"1.5"}),(0,d.jsx)("circle",{cx:"3",cy:"8",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"8",r:"1.5"}),(0,d.jsx)("circle",{cx:"3",cy:"14",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"14",r:"1.5"})]})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",title:a.cwd,children:[(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsx)("span",{className:"font-medium text-sm truncate",children:(e=a.cwd).split("/").pop()||e})}),o===a.sessionId?(0,d.jsx)("input",{ref:s,type:"text",value:q,onChange:a=>r(a.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||("Enter"===a.key&&z(),"Escape"===a.key&&p(null))},onBlur:z,onClick:a=>a.stopPropagation(),className:"w-full text-xs px-1 py-0.5 border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring mt-0.5"}):(0,d.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:a.customTitle||a.sessionId.slice(0,8)})]}),o!==a.sessionId&&(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity mt-0.5",children:[(0,d.jsx)("button",{onClick:b=>y(a,b),className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:k("sessions.editTitle"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),g(a.sessionId)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:k("sessions.remove"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},a.sessionId)})})]})]})}var j=c(31037);function k(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}function l(a){return a.unread?"bg-red-500":a.completed?"bg-muted-foreground":a.paused?"bg-yellow-500":"error"===a.lastResult?"bg-red-500":"bg-green-500"}function m({collapsed:a,tasks:b,unreadCount:c,onSwitchProject:g,onPause:h,onResume:i,onTrigger:n,onDelete:o,onMarkRead:p,onUpdateTask:q,onReorder:r}){let{t:s}=(0,f.Bd)(),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),x=(0,e.useRef)(null),y=b.filter(a=>!a.completed),z=y.filter(a=>!a.paused).length,A=b.filter(a=>a.completed),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),F=(0,e.useCallback)(a=>{C(a)},[]),G=(0,e.useCallback)((a,b)=>{a.preventDefault(),E(b)},[]),H=(0,e.useCallback)(a=>{if(null===B||B===a){C(null),E(null);return}let b=[...y],[c]=b.splice(B,1);b.splice(a,0,c),r([...b,...A].map(a=>a.id)),C(null),E(null)},[B,y,A,r]),I=(0,e.useCallback)(()=>{C(null),E(null)},[]),[,J]=(0,e.useState)(0);return(0,d.jsxs)("div",{className:"relative",ref:x,children:[(0,d.jsxs)("button",{onClick:()=>u(!t),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:s("scheduledTasks.title"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:s("scheduledTasks.title")}),c>0?(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length}):null]}),t&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-96 max-h-[500px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:s("scheduledTasks.title")}),y.length>0&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[s("scheduledTasks.activeCount",{running:z}),y.length-z>0?` \xb7 ${s("scheduledTasks.pausedCount",{paused:y.length-z})}`:""]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:s("scheduledTasks.noScheduledTasks")}):(0,d.jsxs)(d.Fragment,{children:[y.map((a,b)=>{var c;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>F(b),onDragOver:a=>G(a,b),onDrop:()=>H(b),onDragEnd:I,className:`group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 cursor-pointer ${a.unread?"bg-brand/5":""} ${B===b?"opacity-50":""} ${D===b?"border-t-2 border-brand":""}`,onClick:()=>{g(a.cwd,a.sessionId),a.unread&&p(a.id),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${l(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:(c=a.cwd).split("/").pop()||c}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:a.completed?s("scheduledTasks.completed"):a.paused?s("scheduledTasks.paused"):s("common.running")})]}),(0,d.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5",title:a.message,children:a.message}),(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:k(a,s)}),(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsx)("span",{children:a.paused?s("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,s)}),a.lastFiredAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsxs)("span",{children:[s("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]}),(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),n(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:s("scheduledTasks.runNow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:s("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.paused?(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),i(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-500",title:s("scheduledTasks.resume"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),h(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-yellow-500",title:s("scheduledTasks.pause"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})},a.id)}),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-muted/30 border-b border-border/50",children:s("scheduledTasks.completedCount",{count:A.length})}),A.map(a=>(0,d.jsx)("div",{className:"group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 opacity-60 cursor-pointer",onClick:()=>{g(a.cwd,a.sessionId),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${l(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[k(a,s)," \xb7 ","success"===a.lastResult?s("scheduledTasks.success"):s("scheduledTasks.failure")]})]}),(0,d.jsx)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]})},a.id))]})]})})]}),v&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30",onClick:()=>w(null)}),(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(j.E,{onClose:()=>w(null),onCreate:()=>{},editTask:{id:v.id,message:v.message,type:v.type,delayMinutes:v.delayMinutes,intervalMinutes:v.intervalMinutes,activeFrom:v.activeFrom,activeTo:v.activeTo,cron:v.cron},onUpdate:(a,b)=>{q(a,b),w(null)}})})]})]})}var n=c(132),o=c(21108),p=c(13928);function q({projects:a,activeIndex:b,collapsed:c,currentCwd:j,onSelectProject:k,onRemoveProject:l,onReorderProjects:r,onToggleCollapse:s,onOpenSessionBrowser:t,onOpenSettings:u,onOpenNote:v,onOpenSkills:w,onSwitchProject:x,onAddProject:y}){let{t:z}=(0,f.Bd)(),{pinnedSessions:A,unpinSession:B,updateTitle:C,reorder:D}=(0,n.P)(),{tasks:E,unreadCount:F,reload:G,pauseTask:H,resumeTask:I,triggerTask:J,deleteTask:K,updateTask:L,markRead:M,reorderTasks:N}=(0,o.n)(),[O,P]=(0,e.useState)(!1),[Q,R]=(0,e.useState)(null),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)([]);(0,e.useRef)(U);let W=(0,e.useRef)(G),X=(0,e.useCallback)(a=>{try{if("task-fired"===a.type)return void W.current();let{data:b}=a;if(!b)return;V(b.sessions||[])}catch{}},[]);(0,p.h)({url:"/ws/global-state",onMessage:X});let Y=new Set(U.filter(a=>"loading"===a.status).map(a=>a.cwd)),Z=new Set(U.filter(a=>"unread"===a.status).map(a=>a.cwd)),$=(0,e.useCallback)(a=>{R(a)},[]),_=(0,e.useCallback)((a,b)=>{a.preventDefault(),null!==Q&&Q!==b&&T(b)},[Q]),aa=(0,e.useCallback)(b=>{if(null!==Q&&Q!==b){let c=[...a],[d]=c.splice(Q,1);c.splice(b,0,d),r(c)}R(null),T(null)},[Q,a,r]),ab=(0,e.useCallback)(()=>{R(null),T(null)},[]);return(0,d.jsxs)("div",{className:`h-full bg-card border-r border-border flex flex-col transition-all duration-200 ${c?"w-12":"w-56"}`,children:[(0,d.jsxs)("div",{className:"p-2 border-b border-border relative",onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1),children:[(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:t,title:z("workspace.openProject"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]}),!c&&(0,d.jsx)("span",{className:"text-sm",children:z("workspace.openProject")})]}),O&&(c?(0,d.jsx)("button",{className:"absolute inset-0 m-2 flex items-center justify-center px-2 py-2 rounded-lg bg-accent text-foreground transition-colors z-10",onClick:s,title:z("workspace.expandSidebar"),children:(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0 rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}):(0,d.jsx)("button",{className:"absolute top-1/2 -translate-y-1/2 right-2 p-2 rounded-lg bg-accent text-foreground transition-colors z-10",onClick:s,title:z("workspace.collapseSidebar"),children:(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}))]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:a.map((a,e)=>{var f;let h;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>$(e),onDragOver:a=>_(a,e),onDrop:()=>aa(e),onDragEnd:ab,className:`${S===e?"border-t-2 border-brand":""} ${Q===e?"opacity-50":""}`,children:(0,d.jsx)(g.ProjectItem,{index:e,name:(h=(f=a.cwd).split("/").filter(Boolean))[h.length-1]||f,cwd:a.cwd,isActive:e===b,collapsed:c,hasUnread:Z.has(a.cwd),isLoading:Y.has(a.cwd),onClick:()=>k(e),onRemove:()=>l(e),onOpenNote:()=>v(a.cwd)})},a.cwd)})}),(0,d.jsxs)("div",{className:"p-2 border-t border-border space-y-1",children:[(0,d.jsx)(h,{currentCwd:j,onSwitchProject:x,collapsed:c,sessions:U}),(0,d.jsx)(i,{collapsed:c,pinnedSessions:A,onSwitchProject:x,onUnpin:B,onUpdateTitle:C,onReorder:D}),(0,d.jsx)(m,{collapsed:c,tasks:E,unreadCount:F,onSwitchProject:x,onPause:H,onResume:I,onTrigger:J,onDelete:K,onMarkRead:M,onUpdateTask:L,onReorder:N}),(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:()=>v(),title:z("workspace.notes"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),!c&&(0,d.jsx)("span",{className:"text-sm",children:z("workspace.notes")})]}),(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:w,title:z("workspace.skills"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})}),!c&&(0,d.jsx)("span",{className:"text-sm",children:z("workspace.skills")})]}),(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:u,title:z("workspace.settings"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),!c&&(0,d.jsx)("span",{className:"text-sm",children:z("workspace.settings")})]})]})]})}},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},20999:(a,b,c)=>{"use strict";a.exports=c(41421)},23765:a=>{var b=!0,c=!1,d=!1;function e(a,b,c){var d=a.attrIndex(b),e=[b,c];d<0?a.attrPush(e):a.attrs[d]=e}a.exports=function(a,f){f&&(b=!f.enabled,c=!!f.label,d=!!f.labelAfter),a.core.ruler.after("inline","github-task-lists",function(a){for(var f=a.tokens,g=2;g<f.length;g++)(function(a,b){var c;return"inline"===a[b].type&&"paragraph_open"===a[b-1].type&&"list_item_open"===a[b-2].type&&(0===(c=a[b]).content.indexOf("[ ] ")||0===c.content.indexOf("[x] ")||0===c.content.indexOf("[X] "))})(f,g)&&(function(a,e){if(a.children.unshift(function(a,c){var d=new c("html_inline","",0),e=b?' disabled="" ':"";return 0===a.content.indexOf("[ ] ")?d.content='<input class="task-list-item-checkbox"'+e+'type="checkbox">':(0===a.content.indexOf("[x] ")||0===a.content.indexOf("[X] "))&&(d.content='<input class="task-list-item-checkbox" checked=""'+e+'type="checkbox">'),d}(a,e)),a.children[1].content=a.children[1].content.slice(3),a.content=a.content.slice(3),c)if(d){a.children.pop();var f="task-item-"+Math.ceil(1e7*Math.random()-1e3);a.children[0].content=a.children[0].content.slice(0,-1)+' id="'+f+'">',a.children.push(function(a,b,c){var d=new c("html_inline","",0);return d.content='<label class="task-list-item-label" for="'+b+'">'+a+"</label>",d.attrs=[{for:b}],d}(a.content,f,e))}else a.children.unshift(function(a){var b=new a("html_inline","",0);return b.content="<label>",b}(e)),a.children.push(function(a){var b=new a("html_inline","",0);return b.content="</label>",b}(e))}(f[g],a.Token),e(f[g-2],"class","task-list-item"+(b?"":" enabled")),e(f[function(a,b){for(var c=a[b].level-1,d=b-1;d>=0;d--)if(a[d].level===c)return d;return -1}(f,g-2)],"class","contains-task-list"))})}},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},33932:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({number:a,isActive:b}){return(0,d.jsxs)("svg",{className:`w-6 h-6 flex-shrink-0 ${b?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),(0,d.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:a})]})}function h({index:a,name:b,cwd:c,isActive:i,collapsed:j,hasUnread:k,isLoading:l,onClick:m,onRemove:n,onOpenNote:o}){let{t:p}=(0,f.Bd)(),[q,r]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${j?"justify-center":""} ${i?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:m,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),title:c,children:[(0,d.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,d.jsx)(g,{number:a+1,isActive:i}),k&&!i&&!l&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),l&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"})]}),!j&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"flex-1 truncate text-sm",children:b}),!l&&i?(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]}),q&&!j&&(0,d.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[o&&(0,d.jsx)("button",{className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),o()},title:p("workspace.projectNotes"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors",onClick:a=>{a.stopPropagation(),n()},title:p("workspace.closeProject"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})}},34396:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>h,dynamic:()=>f,generateMetadata:()=>g});var d=c(5735),e=c(51675);c(43647),c(49090),c(41824);let f="force-dynamic";async function g({searchParams:a}){let b=(await a).cwd,c=b?.split("/").filter(Boolean).pop();return{title:c?`Cockpit - ${c}`:"Cockpit"}}async function h({searchParams:a}){let{cwd:b,sessionId:c}=await a;return(0,d.jsx)(e.Workspace,{initialCwd:b,initialSessionId:c})}},38194:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>M,handler:()=>O,routeModule:()=>N});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(63747),o=c(24235),p=c(23938),q=c(261),r=c(66758),s=c(77243),t=c(26713),u=c(37527),v=c(22820),w=c(88216),x=c(47929),y=c(79551),z=c(71797),A=c(89125),B=c(86439),C=c(77068),D=c(27269),E=c(61287),F=c(81494),G=c(70722),H=c(70753),I=c(43954),J=c(17891),K={};for(let a in E)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(K[a]=()=>E[a]);c.d(b,K);let L={children:["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,34396)),"/home/runner/work/cockpit/cockpit/src/app/page.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}}]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/home/runner/work/cockpit/cockpit/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.bind(c,81227)),"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]}.children,M={require:c,loadChunk:()=>Promise.resolve()},N=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:L},distDir:".next-prod",relativeProjectDir:""});async function O(a,b,d){var K,P,Q,R,S;d.requestMeta&&(0,h.setRequestMeta)(a,d.requestMeta),N.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let T=!!(0,h.getRequestMeta)(a,"minimalMode"),U="/page";"/index"===U&&(U="/");let V=await N.prepare(a,b,{srcPage:U,multiZoneDraftMode:!1});if(!V)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:W,query:X,params:Y,pageIsDynamic:Z,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,serverActionsManifest:ab,clientReferenceManifest:ac,subresourceIntegrityManifest:ad,prerenderManifest:ae,isDraftMode:af,resolvedPathname:ag,revalidateOnlyGenerated:ah,routerServerContext:ai,nextConfig:aj,parsedUrl:ak,interceptionRoutePatterns:al,deploymentId:am,clientAssetToken:an}=V,ao=(0,q.normalizeAppPath)(U),{isOnDemandRevalidate:ap}=V,aq=aj.experimental.ppr&&!aj.cacheComponents&&(0,I.isInterceptionRouteAppPath)(ag)?null:N.match(ag,ae),ar=(null==aq?void 0:aq.route)??null,as=!!ae.routes[ag],at=a.headers["user-agent"]||"",au=(0,t.getBotType)(at),av=(0,p.isHtmlBotRequest)(a),aw=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ax=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ay=(0,r.getIsPossibleServerAction)(a),az=(0,m.checkIsAppPPREnabled)(aj.experimental.ppr),aA=a.headers[x.NEXT_RESUME_STATE_LENGTH_HEADER];if(!(0,h.getRequestMeta)(a,"postponed")&&T&&az&&ay&&aA&&"string"==typeof aA){let e=parseInt(aA,10),{maxPostponedStateSize:f,maxPostponedStateSizeBytes:g}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize);if(!isNaN(e)&&e>0){if(e>g)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(f)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let i="1 MB",j=(null==(S=aj.experimental.serverActions)?void 0:S.bodySizeLimit)??i,k=e+(j!==i?c(95726).parse(j):1048576),l=await (0,D.readBodyWithSizeLimit)(a,k);if(null===l)return b.statusCode=413,b.end("Request body exceeded limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;if(l.length>=e){let b=l.subarray(0,e).toString("utf8");(0,h.addRequestMeta)(a,"postponed",b);let c=l.subarray(e);(0,h.addRequestMeta)(a,"actionBody",c)}else throw Object.defineProperty(Error(`invariant: expected ${e} bytes of postponed state but only received ${l.length} bytes`),"__NEXT_ERROR_CODE",{value:"E979",enumerable:!1,configurable:!0})}}if(!(0,h.getRequestMeta)(a,"postponed")&&az&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let{maxPostponedStateSize:c,maxPostponedStateSizeBytes:e}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize),f=await (0,D.readBodyWithSizeLimit)(a,e);if(null===f)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(c)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let g=f.toString("utf8");(0,h.addRequestMeta)(a,"postponed",g)}let aB=!0===N.isDev||!0===aj.experimental.exposeTestingApiInProductionBuild,aC=aB&&("1"===a.headers[s.NEXT_INSTANT_PREFETCH_HEADER]||void 0===a.headers[s.RSC_HEADER]&&"string"==typeof a.headers.cookie&&a.headers.cookie.includes(s.NEXT_INSTANT_TEST_COOKIE+"=")),aD=(az||aC)&&((null==(K=ae.routes[ao]??ae.dynamicRoutes[ao])?void 0:K.renderingMode)==="PARTIALLY_STATIC"||aC&&(aB||(null==ai?void 0:ai.experimentalTestProxy)===!0)),aE=aC&&aD,aF=aE&&!0===N.isDev,aG=!1,aH=aD?(0,h.getRequestMeta)(a,"postponed"):void 0,aI=null==(P=ae.routes[ag])?void 0:P.prefetchDataRoute,aJ=aD&&ax&&!aw&&!aI;T&&(aJ=aJ&&!!aH);let aK=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),aL=(!au||!aD)&&(!at||(0,p.shouldServeStreamingMetadata)(at,aj.htmlLimitedBots)),aM=!!((ar||as||ae.routes[ao])&&!(au&&aD)),aN=aD&&!0===aj.cacheComponents,aO=!0===N.isDev||!aM||"string"==typeof aH||(aN&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aJ&&!T:aJ),aP=!!au&&aD,aQ=(null==ar?void 0:ar.remainingPrerenderableParams)??[],aR=(null==ar?void 0:ar.fallback)===null&&((null==(Q=ar.fallbackRootParams)?void 0:Q.length)??0)>0,aS=null;if(!af&&aM&&!aO&&!ay&&!aH&&!aJ){let a=aq?"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:aq.source:null;if(!0===aj.experimental.partialFallbacks&&a&&(null==ar?void 0:ar.fallbackRouteParams)&&!aR){if(aQ.length>0){let b,c=(b=new Map(aQ.map(a=>[a.paramName,a])),a.split("/").map(a=>{let c=(0,J.getSegmentParam)(a);if(!c)return a;let d=b.get(c.paramName);if(!d)return a;let e=null==Y?void 0:Y[d.paramName];if(!e)return a;let f=Array.isArray(e)?e.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(e);return a.replace(function(a){let{repeat:b,optional:c}=(0,J.getParamProperties)(a.paramType);return c?`[[...${a.paramName}]]`:b?`[...${a.paramName}]`:`[${a.paramName}]`}(d),f)}).join("/")||"/");aS=c!==a?c:null}}else aS=ag}let aT=aS;!aT&&(N.isDev||aM&&Z&&(null==ar?void 0:ar.fallbackRouteParams)&&!ay)&&(aT=ag),N.isDev||af||!aM||!ax||aJ||(0,k.d)(a.headers);let aU={...E,tree:L,handler:O,routeModule:N,__next_app__:M};ab&&ac&&(0,o.setManifestsSingleton)({page:U,clientReferenceManifest:ac,serverActionsManifest:ab});let aV=a.method||"GET",aW=(0,g.getTracer)(),aX=aW.getActiveScopeSpan(),aY=!!(null==ai?void 0:ai.isWrappedByNextServer),aZ=!0===aj.experimental.partialFallbacks&&aQ.length>0?(null==ar||null==(R=ar.fallbackRouteParams)?void 0:R.filter(a=>!aQ.some(b=>b.paramName===a.paramName)))??[]:[],a$=async()=>((null==ai?void 0:ai.render404)?await ai.render404(a,b,ak,!1):b.end("This page could not be found"),null);try{let k,m=N.getVaryHeader(ag,al);b.setHeader("Vary",m);let o=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return N.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aW.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aV} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a),k&&k!==c&&(k.setAttribute("http.route",d),k.updateName(a))}else c.updateName(`${aV} ${U}`)})},p=(0,h.getRequestMeta)(a,"incrementalCache")||await N.getIncrementalCache(a,aj,ae,T);null==p||p.resetRequestCache(),globalThis.__incrementalCache=p;let q=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let k={query:X,params:Y,page:ao,sharedContext:{buildId:W,deploymentId:am,clientAssetToken:an},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aU,Component:(0,j.T)(aU),params:Y,routeModule:N,page:U,postponed:f,shouldWaitOnAllReady:aP,serveStreamingMetadata:aL,supportsDynamicResponse:"string"==typeof f||aO,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,subresourceIntegrityManifest:ad,setCacheStatus:null==ai?void 0:ai.setCacheStatus,setIsrStatus:null==ai?void 0:ai.setIsrStatus,setReactDebugChannel:null==ai?void 0:ai.setReactDebugChannel,sendErrorsToBrowser:null==ai?void 0:ai.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),N.relativeProjectDir),isDraftMode:af,botType:au,isOnDemandRevalidate:ap,isPossibleServerAction:ay,assetPrefix:aj.assetPrefix,nextConfigOutput:aj.output,crossOrigin:aj.crossOrigin,trailingSlash:aj.trailingSlash,images:aj.images,previewProps:ae.preview,enableTainting:aj.experimental.taint,htmlLimitedBots:aj.htmlLimitedBots,reactMaxHeadersLength:aj.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:p,cacheLifeProfiles:aj.cacheLife,basePath:aj.basePath,serverActions:aj.experimental.serverActions,logServerFunctions:"object"==typeof aj.logging&&!!aj.logging.serverFunctions,...aE||aF||aG?{isBuildTimePrerendering:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:aF}:{},cacheComponents:!!aj.cacheComponents,experimental:{isRoutePPREnabled:aD,expireTime:aj.expireTime,staleTimes:aj.experimental.staleTimes,dynamicOnHover:!!aj.experimental.dynamicOnHover,optimisticRouting:!!aj.experimental.optimisticRouting,inlineCss:!!aj.experimental.inlineCss,prefetchInlining:aj.experimental.prefetchInlining??!1,authInterrupts:!!aj.experimental.authInterrupts,cachedNavigations:!!aj.experimental.cachedNavigations,clientTraceMetadata:aj.experimental.clientTraceMetadata||[],clientParamParsingOrigins:aj.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,C.parseMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>N.onRequestError(a,b,d,e,ai),err:(0,h.getRequestMeta)(a,"invokeError")}};i&&(k.renderOpts.supportsDynamicResponse=!1);let l=await o(e,k),{metadata:m}=l,{cacheControl:n,headers:q={},fetchTags:r,fetchMetrics:s}=m;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,aM&&(null==n?void 0:n.revalidate)===0&&!N.isDev&&!aD){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ag}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
2
- see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:l,headers:q,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},r=async({hasResolved:c,previousCacheEntry:g,isRevalidating:i,span:j,forceStaticRender:k=!1})=>{let l=!1===N.isDev,m=c||b.writableEnded;try{let f;if(ap&&ah&&!g&&!T)return(null==ai?void 0:ai.render404)?await ai.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ar&&(f=(0,v.parseFallbackField)(ar.fallback)),!0===aj.experimental.partialFallbacks&&(null==ar?void 0:ar.fallback)===null&&!aR&&aQ.length>0&&(f=v.FallbackMode.PRERENDER),f===v.FallbackMode.PRERENDER&&(0,t.isBot)(at)&&(!aD||av)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==g?void 0:g.isStale)===-1&&(ap=!0),ap&&(f!==v.FallbackMode.NOT_FOUND||g)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),!T&&f!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aT&&!m&&!af&&Z&&(l||!as)){if((l||ar)&&f===v.FallbackMode.NOT_FOUND){if(aj.adapterPath)return await a$();throw new B.NoFallbackError}if(aD&&(aj.cacheComponents?!aJ:!ax)){let b=l&&"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:ao,f=(l||aE)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;aE&&f&&(0,h.addRequestMeta)(a,"fallbackParams",f);let g=await N.handleResponse({cacheKey:b,req:a,nextConfig:aj,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:ae,isRoutePPREnabled:aD,responseGenerator:async()=>q({span:j,postponed:void 0,fallbackRouteParams:f,forceStaticRender:!0}),waitUntil:d.waitUntil,isMinimalMode:T});if(null===g)return null;if(g)return T||!aD||!(aQ.length>0)||!0!==aj.experimental.partialFallbacks||!aS||!p||ap||aG||aB||aC||aw||(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(aS,p,aD,!1,a=>q({span:a.span,postponed:void 0,fallbackRouteParams:aZ.length>0?(0,n.createOpaqueFallbackRouteParams)(aZ):null,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}),delete g.cacheControl,g}}let o=ap||i||!aH?void 0:aH;if(aN&&!T&&p&&(aJ||ay)&&!k){let b=await p.get(ag,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(o=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(ag,p,aD,!1,a=>r({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if((aE||aF)&&void 0!==o)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=(l&&(0,h.getRequestMeta)(a,"renderFallbackShell")||aE&&!as)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;if((l||aE)&&aj.cacheComponents&&!as&&(null==ar?void 0:ar.fallbackRouteParams)){let b=(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams);b&&(0,h.addRequestMeta)(a,"fallbackParams",b)}return q({span:j,postponed:o,fallbackRouteParams:s,forceStaticRender:k})}catch(b){throw(null==g?void 0:g.isStale)&&await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}},D=async c=>{var f,g,i,j,k;let l,m=await N.handleResponse({cacheKey:aS,responseGenerator:a=>r({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ap,isRoutePPREnabled:aD,req:a,nextConfig:aj,prerenderManifest:ae,waitUntil:d.waitUntil,isMinimalMode:T});if(af&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),N.isDev&&b.setHeader("Cache-Control","no-cache, must-revalidate"),!m){if(aS)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;ax&&!ay&&am&&b.setHeader(x.NEXT_NAV_DEPLOYMENT_ID_HEADER,am),aM&&!aJ&&(!n||aw)&&(T||b.setHeader("x-nextjs-cache",ap?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:o}=m;if(aH)l={revalidate:0,expire:void 0};else if(aJ)l={revalidate:0,expire:void 0};else if(!N.isDev)if(af)l={revalidate:0,expire:void 0};else if(aM){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??aj.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR_SECONDS,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof aK&&(null==o?void 0:o.kind)===u.CachedRouteKind.APP_PAGE&&o.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=o.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];T&&aM&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=o.segmentData.get(aK);return void 0!==d?(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let p=aN?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(p&&await p(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(o.headers){let a={...o.headers};for(let[c,d]of(T&&aM||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=o.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(T&&aM&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!o.status||ax&&aD||(b.statusCode=o.status),!T&&o.status&&F.RedirectStatusCode[o.status]&&ax&&(b.statusCode=200),n&&!aJ&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ax&&!af){if(void 0===o.rscData){if(o.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(aj.cacheComponents)return b.statusCode=404,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new G.InvariantError(`Expected RSC response, got ${o.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:o.html,cacheControl:m.cacheControl})}return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(o.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=o.html;if(aC&&aE){let c=!0===N.isDev?crypto.randomUUID():null;return v.pipeThrough((0,z.createInstantTestScriptInsertionTransformStream)(c)),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})}if(!n||T||ax)return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:m.cacheControl});if(aE||aF)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let B=new TransformStream;return v.push(B.readable),q({span:c,postponed:o.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(B.writable)}).catch(a=>{B.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aY||!aX)return k=aW.getActiveScopeSpan(),await aW.withPropagatedContext(a.headers,()=>aW.trace(i.BaseServerSpan.handleRequest,{spanName:`${aV} ${U}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aV,"http.target":a.url}},D),void 0,!aY);await D(aX)}catch(b){throw b instanceof B.NoFallbackError||await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}}},38581:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Workspace:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(14024),i=c(1482),j=c(64874),k=c(60306),l=c(62807),m=c(48392),n=c(50605),o=c(68122),p=a([n]);function q({initialCwd:a,initialSessionId:b}){let{t:c}=(0,g.Bd)(),[d,p]=(0,f.useState)([]),[r,s]=(0,f.useState)(0),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(!1),[z,A]=(0,f.useState)(!1),[B,C]=(0,f.useState)(!1),[D,E]=(0,f.useState)(null),[F,G]=(0,f.useState)(!1),[H,I]=(0,f.useState)(!1),[J,K]=(0,f.useState)(new Set),L=(0,f.useRef)(new Map),M=(0,f.useRef)(new Map),N=(0,f.useRef)(new Map);(0,f.useRef)(null),(0,f.useCallback)(async()=>{try{let a=await fetch("/api/projects");if(a.ok){let b=await a.json();p(b.projects||[]),s(b.activeIndex||0),u(b.collapsed||!1)}}catch(a){console.error("Failed to load projects:",a)}finally{I(!0)}},[]);let O=(0,f.useCallback)(async(a,b,c)=>{try{await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projects:a,activeIndex:b,collapsed:c})})}catch(a){console.error("Failed to save projects:",a)}},[]),P=(0,f.useCallback)((a,b)=>{let c=new URL(window.location.href);c.searchParams.set("cwd",a),b?c.searchParams.set("sessionId",b):c.searchParams.delete("sessionId"),window.history.replaceState({},"",c.toString());let d=a.split("/").filter(Boolean).pop();document.title=d?`Cockpit - ${d}`:"Cockpit"},[]);(0,f.useRef)(!1);let Q=(0,f.useCallback)(a=>{s(a),O(d,a,t);let b=d[a];if(b?.cwd){let a=N.current.get(b.cwd);P(b.cwd,a)}},[d,t,O,P]),R=(0,f.useCallback)(a=>{let b=d.filter((b,c)=>c!==a),c=r;a<r?c=r-1:a===r&&c>=b.length&&(c=Math.max(0,b.length-1)),p(b),s(c),O(b,c,t)},[d,r,t,O]),S=(0,f.useCallback)(a=>{let b=d[r],c=a.findIndex(a=>a.cwd===b?.cwd);p(a),s(c>=0?c:0),O(a,c>=0?c:0,t)},[d,r,t,O]),T=(0,f.useCallback)(()=>{let a=!t;u(a),O(d,r,a)},[d,r,t,O]),U=(0,f.useCallback)((a,b)=>{N.current.set(a,b);let c=d.findIndex(b=>b.cwd===a);if(c>=0){let e=L.current.get(a);e?.contentWindow&&e.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b,switchToAgent:!0},"*"),s(c),O(d,c,t)}else{let c=[...d,{cwd:a}],e=c.length-1;p(c),s(e),O(c,e,t),M.current.set(a,{sessionId:b,switchToAgent:!0})}P(a,b),w(!1)},[d,t,O,P]),V=(0,f.useCallback)((a,b)=>{N.current.set(a,b);let c=d.findIndex(b=>b.cwd===a);if(c>=0){let e=L.current.get(a);e?.contentWindow&&e.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b,switchToAgent:!0},"*"),c!==r&&(s(c),O(d,c,t))}else{let c=[...d,{cwd:a}],e=c.length-1;p(c),s(e),O(c,e,t),M.current.set(a,{sessionId:b,switchToAgent:!0})}P(a,b)},[d,r,t,O,P]),W=(0,f.useCallback)(a=>{let b=M.current.get(a);if(b){let c=L.current.get(a);c?.contentWindow&&c.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b.sessionId,switchToAgent:b.switchToAgent},"*"),M.current.delete(a)}},[]);return H?(0,e.jsxs)("div",{className:"h-screen flex bg-background overflow-hidden",children:[(0,e.jsx)(h.ProjectSidebar,{projects:d,activeIndex:r,collapsed:t,currentCwd:d[r]?.cwd,onSelectProject:Q,onRemoveProject:R,onReorderProjects:S,onToggleCollapse:T,onOpenSessionBrowser:()=>w(!0),onOpenSettings:()=>y(!0),onOpenNote:a=>{E(a??null),C(!0)},onOpenSkills:()=>G(!0),onSwitchProject:V,onAddProject:a=>{let b=d.findIndex(b=>b.cwd===a);if(b>=0)s(b),O(d,b,t);else{let b=[...d,{cwd:a}],c=b.length-1;p(b),s(c),O(b,c,t)}}}),(0,e.jsx)("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:0===d.length?(0,e.jsx)(i.EmptyState,{onSelectSession:U}):(0,e.jsx)("div",{className:"flex-1 relative overflow-hidden",children:d.map((a,b)=>J.has(a.cwd)&&(0,e.jsx)("iframe",{ref:b=>{b?L.current.set(a.cwd,b):L.current.delete(a.cwd)},src:`/project?cwd=${encodeURIComponent(a.cwd)}`,onLoad:()=>W(a.cwd),className:`absolute inset-0 w-full h-full border-0 ${b===r?"block":"hidden"}`,title:`Project: ${a.cwd}`},a.cwd))})}),(0,e.jsx)(j.r,{isOpen:v,onClose:()=>w(!1),onSelectSession:U,onAddProject:a=>{let b=d.findIndex(b=>b.cwd===a);if(b>=0)s(b),O(d,b,t);else{let b=[...d,{cwd:a}],c=b.length-1;p(b),s(c),O(b,c,t)}w(!1)}}),(0,e.jsx)(k.b,{isOpen:x,onClose:()=>y(!1)}),(0,e.jsx)(l.w,{isOpen:z,onClose:()=>A(!1)}),(0,e.jsx)(m.k,{isOpen:B,onClose:()=>{C(!1),E(null)},projectCwd:D,projectName:D?D.split("/").pop():null}),(0,e.jsx)(n.g,{isOpen:F,onClose:()=>G(!1)}),(0,e.jsx)(o.M,{onNavigate:V})]}):(0,e.jsx)("div",{className:"h-screen flex items-center justify-center bg-card",children:(0,e.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,e.jsxs)("svg",{className:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,e.jsx)("span",{children:c("workspace.loadingText")})]})})}n=(p.then?(await p)():p)[0],d()}catch(a){d(a)}})},39017:(a,b,c)=>{Promise.resolve().then(c.bind(c,1482)),Promise.resolve().then(c.bind(c,33932)),Promise.resolve().then(c.bind(c,14024)),Promise.resolve().then(c.bind(c,38581))},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41421:(a,b,c)=>{"use strict";var d=c(67484),e=c(42237),f="function"==typeof Object.is?Object.is:function(a,b){return a===b&&(0!==a||1/a==1/b)||a!=a&&b!=b},g=e.useSyncExternalStore,h=d.useRef,i=d.useEffect,j=d.useMemo,k=d.useDebugValue;b.useSyncExternalStoreWithSelector=function(a,b,c,d,e){var l=h(null);if(null===l.current){var m={hasValue:!1,value:null};l.current=m}else m=l.current;var n=g(a,(l=j(function(){function a(a){if(!i){if(i=!0,g=a,a=d(a),void 0!==e&&m.hasValue){var b=m.value;if(e(b,a))return h=b}return h=a}if(b=h,f(g,a))return b;var c=d(a);return void 0!==e&&e(b,c)?(g=a,b):(g=a,h=c)}var g,h,i=!1,j=void 0===c?null:c;return[function(){return a(b())},null===j?void 0:function(){return a(j())}]},[b,c,d,e]))[0],l[1]);return i(function(){m.hasValue=!0,m.value=n},[n]),k(n),n}},41824:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call EmptyState() from the server but EmptyState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/EmptyState.tsx","EmptyState")},43647:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/ProjectSidebar.tsx","ProjectSidebar")},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},48392:(a,b,c)=>{"use strict";let d,e;c.d(b,{k:()=>oA});var f,g,h,i,j,k,l,m,n,o,p,q,r,s={};c.r(s),c.d(s,{decode:()=>lF,encode:()=>lI,format:()=>lJ,parse:()=>lU});var t={};c.r(t),c.d(t,{Any:()=>lX,Cc:()=>lY,Cf:()=>lZ,P:()=>lV,S:()=>lW,Z:()=>l$});var u={};c.r(u),c.d(u,{arrayReplaceAt:()=>me,assign:()=>md,escapeHtml:()=>mq,escapeRE:()=>ms,fromCodePoint:()=>mg,has:()=>mc,isMdAsciiPunct:()=>mw,isPunctChar:()=>mv,isSpace:()=>mt,isString:()=>ma,isValidEntityCode:()=>mf,isWhiteSpace:()=>mu,lib:()=>my,normalizeReference:()=>mx,unescapeAll:()=>ml,unescapeMd:()=>mk});var v={};c.r(v),c.d(v,{parseLinkDestination:()=>mA,parseLinkLabel:()=>mz,parseLinkTitle:()=>mB});var w=c(48249),x=c(67484),y=c(44384),z=c(41564),A=c(74429),B=c(42237);function C(a){this.content=a}C.prototype={constructor:C,find:function(a){for(var b=0;b<this.content.length;b+=2)if(this.content[b]===a)return b;return -1},get:function(a){var b=this.find(a);return -1==b?void 0:this.content[b+1]},update:function(a,b,c){var d=c&&c!=a?this.remove(c):this,e=d.find(a),f=d.content.slice();return -1==e?f.push(c||a,b):(f[e+1]=b,c&&(f[e]=c)),new C(f)},remove:function(a){var b=this.find(a);if(-1==b)return this;var c=this.content.slice();return c.splice(b,2),new C(c)},addToStart:function(a,b){return new C([a,b].concat(this.remove(a).content))},addToEnd:function(a,b){var c=this.remove(a).content.slice();return c.push(a,b),new C(c)},addBefore:function(a,b,c){var d=this.remove(b),e=d.content.slice(),f=d.find(a);return e.splice(-1==f?e.length:f,0,b,c),new C(e)},forEach:function(a){for(var b=0;b<this.content.length;b+=2)a(this.content[b],this.content[b+1])},prepend:function(a){return(a=C.from(a)).size?new C(a.content.concat(this.subtract(a).content)):this},append:function(a){return(a=C.from(a)).size?new C(this.subtract(a).content.concat(a.content)):this},subtract:function(a){var b=this;a=C.from(a);for(var c=0;c<a.content.length;c+=2)b=b.remove(a.content[c]);return b},toObject:function(){var a={};return this.forEach(function(b,c){a[b]=c}),a},get size(){return this.content.length>>1}},C.from=function(a){if(a instanceof C)return a;var b=[];if(a)for(var c in a)b.push(c,a[c]);return new C(b)};class D{constructor(a,b){if(this.content=a,this.size=b||0,null==b)for(let b=0;b<a.length;b++)this.size+=a[b].nodeSize}nodesBetween(a,b,c,d=0,e){for(let f=0,g=0;g<b;f++){let h=this.content[f],i=g+h.nodeSize;if(i>a&&!1!==c(h,d+g,e||null,f)&&h.content.size){let e=g+1;h.nodesBetween(Math.max(0,a-e),Math.min(h.content.size,b-e),c,d+e)}g=i}}descendants(a){this.nodesBetween(0,this.size,a)}textBetween(a,b,c,d){let e="",f=!0;return this.nodesBetween(a,b,(g,h)=>{let i=g.isText?g.text.slice(Math.max(a,h)-h,b-h):g.isLeaf?d?"function"==typeof d?d(g):d:g.type.spec.leafText?g.type.spec.leafText(g):"":"";g.isBlock&&(g.isLeaf&&i||g.isTextblock)&&c&&(f?f=!1:e+=c),e+=i},0),e}append(a){if(!a.size)return this;if(!this.size)return a;let b=this.lastChild,c=a.firstChild,d=this.content.slice(),e=0;for(b.isText&&b.sameMarkup(c)&&(d[d.length-1]=b.withText(b.text+c.text),e=1);e<a.content.length;e++)d.push(a.content[e]);return new D(d,this.size+a.size)}cut(a,b=this.size){if(0==a&&b==this.size)return this;let c=[],d=0;if(b>a)for(let e=0,f=0;f<b;e++){let g=this.content[e],h=f+g.nodeSize;h>a&&((f<a||h>b)&&(g=g.isText?g.cut(Math.max(0,a-f),Math.min(g.text.length,b-f)):g.cut(Math.max(0,a-f-1),Math.min(g.content.size,b-f-1))),c.push(g),d+=g.nodeSize),f=h}return new D(c,d)}cutByIndex(a,b){return a==b?D.empty:0==a&&b==this.content.length?this:new D(this.content.slice(a,b))}replaceChild(a,b){let c=this.content[a];if(c==b)return this;let d=this.content.slice(),e=this.size+b.nodeSize-c.nodeSize;return d[a]=b,new D(d,e)}addToStart(a){return new D([a].concat(this.content),this.size+a.nodeSize)}addToEnd(a){return new D(this.content.concat(a),this.size+a.nodeSize)}eq(a){if(this.content.length!=a.content.length)return!1;for(let b=0;b<this.content.length;b++)if(!this.content[b].eq(a.content[b]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(a){let b=this.content[a];if(!b)throw RangeError("Index "+a+" out of range for "+this);return b}maybeChild(a){return this.content[a]||null}forEach(a){for(let b=0,c=0;b<this.content.length;b++){let d=this.content[b];a(d,c,b),c+=d.nodeSize}}findDiffStart(a,b=0){return function a(b,c,d){for(let e=0;;e++){if(e==b.childCount||e==c.childCount)return b.childCount==c.childCount?null:d;let f=b.child(e),g=c.child(e);if(f==g){d+=f.nodeSize;continue}if(!f.sameMarkup(g))return d;if(f.isText&&f.text!=g.text){for(let a=0;f.text[a]==g.text[a];a++)d++;return d}if(f.content.size||g.content.size){let b=a(f.content,g.content,d+1);if(null!=b)return b}d+=f.nodeSize}}(this,a,b)}findDiffEnd(a,b=this.size,c=a.size){return function a(b,c,d,e){for(let f=b.childCount,g=c.childCount;;){if(0==f||0==g)return f==g?null:{a:d,b:e};let h=b.child(--f),i=c.child(--g),j=h.nodeSize;if(h==i){d-=j,e-=j;continue}if(!h.sameMarkup(i))return{a:d,b:e};if(h.isText&&h.text!=i.text){let a=0,b=Math.min(h.text.length,i.text.length);for(;a<b&&h.text[h.text.length-a-1]==i.text[i.text.length-a-1];)a++,d--,e--;return{a:d,b:e}}if(h.content.size||i.content.size){let b=a(h.content,i.content,d-1,e-1);if(b)return b}d-=j,e-=j}}(this,a,b,c)}findIndex(a){if(0==a)return F(0,a);if(a==this.size)return F(this.content.length,a);if(a>this.size||a<0)throw RangeError(`Position ${a} outside of fragment (${this})`);for(let b=0,c=0;;b++){let d=c+this.child(b).nodeSize;if(d>=a){if(d==a)return F(b+1,d);return F(b,c)}c=d}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(a=>a.toJSON()):null}static fromJSON(a,b){if(!b)return D.empty;if(!Array.isArray(b))throw RangeError("Invalid input for Fragment.fromJSON");return new D(b.map(a.nodeFromJSON))}static fromArray(a){if(!a.length)return D.empty;let b,c=0;for(let d=0;d<a.length;d++){let e=a[d];c+=e.nodeSize,d&&e.isText&&a[d-1].sameMarkup(e)?(b||(b=a.slice(0,d)),b[b.length-1]=e.withText(b[b.length-1].text+e.text)):b&&b.push(e)}return new D(b||a,c)}static from(a){if(!a)return D.empty;if(a instanceof D)return a;if(Array.isArray(a))return this.fromArray(a);if(a.attrs)return new D([a],a.nodeSize);throw RangeError("Can not convert "+a+" to a Fragment"+(a.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}D.empty=new D([],0);let E={index:0,offset:0};function F(a,b){return E.index=a,E.offset=b,E}function G(a,b){if(a===b)return!0;if(!(a&&"object"==typeof a)||!(b&&"object"==typeof b))return!1;let c=Array.isArray(a);if(Array.isArray(b)!=c)return!1;if(c){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!G(a[c],b[c]))return!1}else{for(let c in a)if(!(c in b)||!G(a[c],b[c]))return!1;for(let c in b)if(!(c in a))return!1}return!0}class H{constructor(a,b){this.type=a,this.attrs=b}addToSet(a){let b,c=!1;for(let d=0;d<a.length;d++){let e=a[d];if(this.eq(e))return a;if(this.type.excludes(e.type))b||(b=a.slice(0,d));else{if(e.type.excludes(this.type))return a;!c&&e.type.rank>this.type.rank&&(b||(b=a.slice(0,d)),b.push(this),c=!0),b&&b.push(e)}}return b||(b=a.slice()),c||b.push(this),b}removeFromSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return a.slice(0,b).concat(a.slice(b+1));return a}isInSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return!0;return!1}eq(a){return this==a||this.type==a.type&&G(this.attrs,a.attrs)}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return a}static fromJSON(a,b){if(!b)throw RangeError("Invalid input for Mark.fromJSON");let c=a.marks[b.type];if(!c)throw RangeError(`There is no mark type ${b.type} in this schema`);let d=c.create(b.attrs);return c.checkAttrs(d.attrs),d}static sameSet(a,b){if(a==b)return!0;if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].eq(b[c]))return!1;return!0}static setFrom(a){if(!a||Array.isArray(a)&&0==a.length)return H.none;if(a instanceof H)return[a];let b=a.slice();return b.sort((a,b)=>a.type.rank-b.type.rank),b}}H.none=[];class I extends Error{}class J{constructor(a,b,c){this.content=a,this.openStart=b,this.openEnd=c}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(a,b){let c=function a(b,c,d,e){let{index:f,offset:g}=b.findIndex(c),h=b.maybeChild(f);if(g==c||h.isText)return e&&!e.canReplace(f,f,d)?null:b.cut(0,c).append(d).append(b.cut(c));let i=a(h.content,c-g-1,d,h);return i&&b.replaceChild(f,h.copy(i))}(this.content,a+this.openStart,b);return c&&new J(c,this.openStart,this.openEnd)}removeBetween(a,b){return new J(function a(b,c,d){let{index:e,offset:f}=b.findIndex(c),g=b.maybeChild(e),{index:h,offset:i}=b.findIndex(d);if(f==c||g.isText){if(i!=d&&!b.child(h).isText)throw RangeError("Removing non-flat range");return b.cut(0,c).append(b.cut(d))}if(e!=h)throw RangeError("Removing non-flat range");return b.replaceChild(e,g.copy(a(g.content,c-f-1,d-f-1)))}(this.content,a+this.openStart,b+this.openStart),this.openStart,this.openEnd)}eq(a){return this.content.eq(a.content)&&this.openStart==a.openStart&&this.openEnd==a.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let a={content:this.content.toJSON()};return this.openStart>0&&(a.openStart=this.openStart),this.openEnd>0&&(a.openEnd=this.openEnd),a}static fromJSON(a,b){if(!b)return J.empty;let c=b.openStart||0,d=b.openEnd||0;if("number"!=typeof c||"number"!=typeof d)throw RangeError("Invalid input for Slice.fromJSON");return new J(D.fromJSON(a,b.content),c,d)}static maxOpen(a,b=!0){let c=0,d=0;for(let d=a.firstChild;d&&!d.isLeaf&&(b||!d.type.spec.isolating);d=d.firstChild)c++;for(let c=a.lastChild;c&&!c.isLeaf&&(b||!c.type.spec.isolating);c=c.lastChild)d++;return new J(a,c,d)}}function K(a,b){if(!b.type.compatibleContent(a.type))throw new I("Cannot join "+b.type.name+" onto "+a.type.name)}function L(a,b,c){let d=a.node(c);return K(d,b.node(c)),d}function M(a,b){let c=b.length-1;c>=0&&a.isText&&a.sameMarkup(b[c])?b[c]=a.withText(b[c].text+a.text):b.push(a)}function N(a,b,c,d){let e=(b||a).node(c),f=0,g=b?b.index(c):e.childCount;a&&(f=a.index(c),a.depth>c?f++:a.textOffset&&(M(a.nodeAfter,d),f++));for(let a=f;a<g;a++)M(e.child(a),d);b&&b.depth==c&&b.textOffset&&M(b.nodeBefore,d)}function O(a,b){return a.type.checkContent(b),a.copy(b)}function P(a,b,c){let d=[];return N(null,a,c,d),a.depth>c&&M(O(L(a,b,c+1),P(a,b,c+1)),d),N(b,null,c,d),new D(d)}J.empty=new J(D.empty,0,0);class Q{constructor(a,b,c){this.pos=a,this.path=b,this.parentOffset=c,this.depth=b.length/3-1}resolveDepth(a){return null==a?this.depth:a<0?this.depth+a:a}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(a){return this.path[3*this.resolveDepth(a)]}index(a){return this.path[3*this.resolveDepth(a)+1]}indexAfter(a){return a=this.resolveDepth(a),this.index(a)+(a!=this.depth||this.textOffset?1:0)}start(a){return 0==(a=this.resolveDepth(a))?0:this.path[3*a-1]+1}end(a){return a=this.resolveDepth(a),this.start(a)+this.node(a).content.size}before(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position before the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]}after(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position after the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]+this.path[3*a].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let a=this.parent,b=this.index(this.depth);if(b==a.childCount)return null;let c=this.pos-this.path[this.path.length-1],d=a.child(b);return c?a.child(b).cut(c):d}get nodeBefore(){let a=this.index(this.depth),b=this.pos-this.path[this.path.length-1];return b?this.parent.child(a).cut(0,b):0==a?null:this.parent.child(a-1)}posAtIndex(a,b){b=this.resolveDepth(b);let c=this.path[3*b],d=0==b?0:this.path[3*b-1]+1;for(let b=0;b<a;b++)d+=c.child(b).nodeSize;return d}marks(){let a=this.parent,b=this.index();if(0==a.content.size)return H.none;if(this.textOffset)return a.child(b).marks;let c=a.maybeChild(b-1),d=a.maybeChild(b);if(!c){let a=c;c=d,d=a}let e=c.marks;for(var f=0;f<e.length;f++)!1!==e[f].type.spec.inclusive||d&&e[f].isInSet(d.marks)||(e=e[f--].removeFromSet(e));return e}marksAcross(a){let b=this.parent.maybeChild(this.index());if(!b||!b.isInline)return null;let c=b.marks,d=a.parent.maybeChild(a.index());for(var e=0;e<c.length;e++)!1!==c[e].type.spec.inclusive||d&&c[e].isInSet(d.marks)||(c=c[e--].removeFromSet(c));return c}sharedDepth(a){for(let b=this.depth;b>0;b--)if(this.start(b)<=a&&this.end(b)>=a)return b;return 0}blockRange(a=this,b){if(a.pos<this.pos)return a.blockRange(this);for(let c=this.depth-(this.parent.inlineContent||this.pos==a.pos?1:0);c>=0;c--)if(a.pos<=this.end(c)&&(!b||b(this.node(c))))return new U(this,a,c);return null}sameParent(a){return this.pos-this.parentOffset==a.pos-a.parentOffset}max(a){return a.pos>this.pos?a:this}min(a){return a.pos<this.pos?a:this}toString(){let a="";for(let b=1;b<=this.depth;b++)a+=(a?"/":"")+this.node(b).type.name+"_"+this.index(b-1);return a+":"+this.parentOffset}static resolve(a,b){if(!(b>=0&&b<=a.content.size))throw RangeError("Position "+b+" out of range");let c=[],d=0,e=b;for(let b=a;;){let{index:a,offset:f}=b.content.findIndex(e),g=e-f;if(c.push(b,a,d+f),!g||(b=b.child(a)).isText)break;e=g-1,d+=f+1}return new Q(b,c,e)}static resolveCached(a,b){let c=T.get(a);if(c)for(let a=0;a<c.elts.length;a++){let d=c.elts[a];if(d.pos==b)return d}else T.set(a,c=new R);let d=c.elts[c.i]=Q.resolve(a,b);return c.i=(c.i+1)%S,d}}class R{constructor(){this.elts=[],this.i=0}}let S=12,T=new WeakMap;class U{constructor(a,b,c){this.$from=a,this.$to=b,this.depth=c}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let V=Object.create(null);class W{constructor(a,b,c,d=H.none){this.type=a,this.attrs=b,this.marks=d,this.content=c||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(a){return this.content.child(a)}maybeChild(a){return this.content.maybeChild(a)}forEach(a){this.content.forEach(a)}nodesBetween(a,b,c,d=0){this.content.nodesBetween(a,b,c,d,this)}descendants(a){this.nodesBetween(0,this.content.size,a)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(a,b,c,d){return this.content.textBetween(a,b,c,d)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(a){return this==a||this.sameMarkup(a)&&this.content.eq(a.content)}sameMarkup(a){return this.hasMarkup(a.type,a.attrs,a.marks)}hasMarkup(a,b,c){return this.type==a&&G(this.attrs,b||a.defaultAttrs||V)&&H.sameSet(this.marks,c||H.none)}copy(a=null){return a==this.content?this:new W(this.type,this.attrs,a,this.marks)}mark(a){return a==this.marks?this:new W(this.type,this.attrs,this.content,a)}cut(a,b=this.content.size){return 0==a&&b==this.content.size?this:this.copy(this.content.cut(a,b))}slice(a,b=this.content.size,c=!1){if(a==b)return J.empty;let d=this.resolve(a),e=this.resolve(b),f=c?0:d.sharedDepth(b),g=d.start(f);return new J(d.node(f).content.cut(d.pos-g,e.pos-g),d.depth-f,e.depth-f)}replace(a,b,c){var d=this.resolve(a),e=this.resolve(b);if(c.openStart>d.depth)throw new I("Inserted content deeper than insertion position");if(d.depth-c.openStart!=e.depth-c.openEnd)throw new I("Inconsistent open depths");return function a(b,c,d,e){let f=b.index(e),g=b.node(e);if(f==c.index(e)&&e<b.depth-d.openStart){let h=a(b,c,d,e+1);return g.copy(g.content.replaceChild(f,h))}if(!d.content.size)return O(g,P(b,c,e));if(d.openStart||d.openEnd||b.depth!=e||c.depth!=e){let{start:a,end:f}=function(a,b){let c=b.depth-a.openStart,d=b.node(c).copy(a.content);for(let a=c-1;a>=0;a--)d=b.node(a).copy(D.from(d));return{start:d.resolveNoCache(a.openStart+c),end:d.resolveNoCache(d.content.size-a.openEnd-c)}}(d,b);return O(g,function a(b,c,d,e,f){let g=b.depth>f&&L(b,c,f+1),h=e.depth>f&&L(d,e,f+1),i=[];return N(null,b,f,i),g&&h&&c.index(f)==d.index(f)?(K(g,h),M(O(g,a(b,c,d,e,f+1)),i)):(g&&M(O(g,P(b,c,f+1)),i),N(c,d,f,i),h&&M(O(h,P(d,e,f+1)),i)),N(e,null,f,i),new D(i)}(b,a,f,c,e))}{let a=b.parent,e=a.content;return O(a,e.cut(0,b.parentOffset).append(d.content).append(e.cut(c.parentOffset)))}}(d,e,c,0)}nodeAt(a){for(let b=this;;){let{index:c,offset:d}=b.content.findIndex(a);if(!(b=b.maybeChild(c)))return null;if(d==a||b.isText)return b;a-=d+1}}childAfter(a){let{index:b,offset:c}=this.content.findIndex(a);return{node:this.content.maybeChild(b),index:b,offset:c}}childBefore(a){if(0==a)return{node:null,index:0,offset:0};let{index:b,offset:c}=this.content.findIndex(a);if(c<a)return{node:this.content.child(b),index:b,offset:c};let d=this.content.child(b-1);return{node:d,index:b-1,offset:c-d.nodeSize}}resolve(a){return Q.resolveCached(this,a)}resolveNoCache(a){return Q.resolve(this,a)}rangeHasMark(a,b,c){let d=!1;return b>a&&this.nodesBetween(a,b,a=>(c.isInSet(a.marks)&&(d=!0),!d)),d}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let a=this.type.name;return this.content.size&&(a+="("+this.content.toStringInner()+")"),Y(this.marks,a)}contentMatchAt(a){let b=this.type.contentMatch.matchFragment(this.content,0,a);if(!b)throw Error("Called contentMatchAt on a node with invalid content");return b}canReplace(a,b,c=D.empty,d=0,e=c.childCount){let f=this.contentMatchAt(a).matchFragment(c,d,e),g=f&&f.matchFragment(this.content,b);if(!g||!g.validEnd)return!1;for(let a=d;a<e;a++)if(!this.type.allowsMarks(c.child(a).marks))return!1;return!0}canReplaceWith(a,b,c,d){if(d&&!this.type.allowsMarks(d))return!1;let e=this.contentMatchAt(a).matchType(c),f=e&&e.matchFragment(this.content,b);return!!f&&f.validEnd}canAppend(a){return a.content.size?this.canReplace(this.childCount,this.childCount,a.content):this.type.compatibleContent(a.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let a=H.none;for(let b=0;b<this.marks.length;b++){let c=this.marks[b];c.type.checkAttrs(c.attrs),a=c.addToSet(a)}if(!H.sameSet(a,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(a=>a.type.name)}`);this.content.forEach(a=>a.check())}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return this.content.size&&(a.content=this.content.toJSON()),this.marks.length&&(a.marks=this.marks.map(a=>a.toJSON())),a}static fromJSON(a,b){let c;if(!b)throw RangeError("Invalid input for Node.fromJSON");if(b.marks){if(!Array.isArray(b.marks))throw RangeError("Invalid mark data for Node.fromJSON");c=b.marks.map(a.markFromJSON)}if("text"==b.type){if("string"!=typeof b.text)throw RangeError("Invalid text node in JSON");return a.text(b.text,c)}let d=D.fromJSON(a,b.content),e=a.nodeType(b.type).create(b.attrs,d,c);return e.type.checkAttrs(e.attrs),e}}W.prototype.text=void 0;class X extends W{constructor(a,b,c,d){if(super(a,b,null,d),!c)throw RangeError("Empty text nodes are not allowed");this.text=c}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Y(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(a,b){return this.text.slice(a,b)}get nodeSize(){return this.text.length}mark(a){return a==this.marks?this:new X(this.type,this.attrs,this.text,a)}withText(a){return a==this.text?this:new X(this.type,this.attrs,a,this.marks)}cut(a=0,b=this.text.length){return 0==a&&b==this.text.length?this:this.withText(this.text.slice(a,b))}eq(a){return this.sameMarkup(a)&&this.text==a.text}toJSON(){let a=super.toJSON();return a.text=this.text,a}}function Y(a,b){for(let c=a.length-1;c>=0;c--)b=a[c].type.name+"("+b+")";return b}class Z{constructor(a){this.validEnd=a,this.next=[],this.wrapCache=[]}static parse(a,b){var c;let d,e=new $(a,b);if(null==e.next)return Z.empty;let f=function a(b){let c=[];do c.push(function(b){let c=[];do c.push(function(b){let c=function(b){if(b.eat("(")){let c=a(b);return b.eat(")")||b.err("Missing closing paren"),c}if(/\W/.test(b.next))b.err("Unexpected token '"+b.next+"'");else{let a=(function(a,b){let c=a.nodeTypes,d=c[b];if(d)return[d];let e=[];for(let a in c){let d=c[a];d.isInGroup(b)&&e.push(d)}return 0==e.length&&a.err("No node type or group '"+b+"' found"),e})(b,b.next).map(a=>(null==b.inline?b.inline=a.isInline:b.inline!=a.isInline&&b.err("Mixing inline and block content"),{type:"name",value:a}));return b.pos++,1==a.length?a[0]:{type:"choice",exprs:a}}}(b);for(;;)if(b.eat("+"))c={type:"plus",expr:c};else if(b.eat("*"))c={type:"star",expr:c};else if(b.eat("?"))c={type:"opt",expr:c};else if(b.eat("{"))c=function(a,b){let c=_(a),d=c;return a.eat(",")&&(d="}"!=a.next?_(a):-1),a.eat("}")||a.err("Unclosed braced range"),{type:"range",min:c,max:d,expr:b}}(b,c);else break;return c}(b));while(b.next&&")"!=b.next&&"|"!=b.next);return 1==c.length?c[0]:{type:"seq",exprs:c}}(b));while(b.eat("|"));return 1==c.length?c[0]:{type:"choice",exprs:c}}(e);e.next&&e.err("Unexpected trailing text");let g=(c=function(a){let b=[[]];return e(function a(b,f){if("choice"==b.type)return b.exprs.reduce((b,c)=>b.concat(a(c,f)),[]);if("seq"==b.type)for(let d=0;;d++){let g=a(b.exprs[d],f);if(d==b.exprs.length-1)return g;e(g,f=c())}else if("star"==b.type){let g=c();return d(f,g),e(a(b.expr,g),g),[d(g)]}else if("plus"==b.type){let g=c();return e(a(b.expr,f),g),e(a(b.expr,g),g),[d(g)]}else if("opt"==b.type)return[d(f)].concat(a(b.expr,f));else if("range"==b.type){let g=f;for(let d=0;d<b.min;d++){let d=c();e(a(b.expr,g),d),g=d}if(-1==b.max)e(a(b.expr,g),g);else for(let f=b.min;f<b.max;f++){let f=c();d(g,f),e(a(b.expr,g),f),g=f}return[d(g)]}else if("name"==b.type)return[d(f,void 0,b.value)];else throw Error("Unknown expr type")}(a,0),c()),b;function c(){return b.push([])-1}function d(a,c,d){let e={term:d,to:c};return b[a].push(e),e}function e(a,b){a.forEach(a=>a.to=b)}}(f),d=Object.create(null),function a(b){let e=[];b.forEach(a=>{c[a].forEach(({term:a,to:b})=>{let d;if(a){for(let b=0;b<e.length;b++)e[b][0]==a&&(d=e[b][1]);ab(c,b).forEach(b=>{d||e.push([a,d=[]]),-1==d.indexOf(b)&&d.push(b)})}})});let f=d[b.join(",")]=new Z(b.indexOf(c.length-1)>-1);for(let b=0;b<e.length;b++){let c=e[b][1].sort(aa);f.next.push({type:e[b][0],next:d[c.join(",")]||a(c)})}return f}(ab(c,0)));return function(a,b){for(let c=0,d=[a];c<d.length;c++){let a=d[c],e=!a.validEnd,f=[];for(let b=0;b<a.next.length;b++){let{type:c,next:g}=a.next[b];f.push(c.name),e&&!(c.isText||c.hasRequiredAttrs())&&(e=!1),-1==d.indexOf(g)&&d.push(g)}e&&b.err("Only non-generatable nodes ("+f.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(g,e),g}matchType(a){for(let b=0;b<this.next.length;b++)if(this.next[b].type==a)return this.next[b].next;return null}matchFragment(a,b=0,c=a.childCount){let d=this;for(let e=b;d&&e<c;e++)d=d.matchType(a.child(e).type);return d}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let a=0;a<this.next.length;a++){let{type:b}=this.next[a];if(!(b.isText||b.hasRequiredAttrs()))return b}return null}compatible(a){for(let b=0;b<this.next.length;b++)for(let c=0;c<a.next.length;c++)if(this.next[b].type==a.next[c].type)return!0;return!1}fillBefore(a,b=!1,c=0){let d=[this];return function e(f,g){let h=f.matchFragment(a,c);if(h&&(!b||h.validEnd))return D.from(g.map(a=>a.createAndFill()));for(let a=0;a<f.next.length;a++){let{type:b,next:c}=f.next[a];if(!(b.isText||b.hasRequiredAttrs())&&-1==d.indexOf(c)){d.push(c);let a=e(c,g.concat(b));if(a)return a}}return null}(this,[])}findWrapping(a){for(let b=0;b<this.wrapCache.length;b+=2)if(this.wrapCache[b]==a)return this.wrapCache[b+1];let b=this.computeWrapping(a);return this.wrapCache.push(a,b),b}computeWrapping(a){let b=Object.create(null),c=[{match:this,type:null,via:null}];for(;c.length;){let d=c.shift(),e=d.match;if(e.matchType(a)){let a=[];for(let b=d;b.type;b=b.via)a.push(b.type);return a.reverse()}for(let a=0;a<e.next.length;a++){let{type:f,next:g}=e.next[a];f.isLeaf||f.hasRequiredAttrs()||f.name in b||d.type&&!g.validEnd||(c.push({match:f.contentMatch,type:f,via:d}),b[f.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(a){if(a>=this.next.length)throw RangeError(`There's no ${a}th edge in this content match`);return this.next[a]}toString(){let a=[];return!function b(c){a.push(c);for(let d=0;d<c.next.length;d++)-1==a.indexOf(c.next[d].next)&&b(c.next[d].next)}(this),a.map((b,c)=>{let d=c+(b.validEnd?"*":" ")+" ";for(let c=0;c<b.next.length;c++)d+=(c?", ":"")+b.next[c].type.name+"->"+a.indexOf(b.next[c].next);return d}).join("\n")}}Z.empty=new Z(!0);class ${constructor(a,b){this.string=a,this.nodeTypes=b,this.inline=null,this.pos=0,this.tokens=a.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(a){return this.next==a&&(this.pos++||!0)}err(a){throw SyntaxError(a+" (in content expression '"+this.string+"')")}}function _(a){/\D/.test(a.next)&&a.err("Expected number, got '"+a.next+"'");let b=Number(a.next);return a.pos++,b}function aa(a,b){return b-a}function ab(a,b){let c=[];return function b(d){let e=a[d];if(1==e.length&&!e[0].term)return b(e[0].to);c.push(d);for(let a=0;a<e.length;a++){let{term:d,to:f}=e[a];d||-1!=c.indexOf(f)||b(f)}}(b),c.sort(aa)}function ac(a){let b=Object.create(null);for(let c in a){let d=a[c];if(!d.hasDefault)return null;b[c]=d.default}return b}function ad(a,b){let c=Object.create(null);for(let d in a){let e=b&&b[d];if(void 0===e){let b=a[d];if(b.hasDefault)e=b.default;else throw RangeError("No value supplied for attribute "+d)}c[d]=e}return c}function ae(a,b,c,d){for(let d in b)if(!(d in a))throw RangeError(`Unsupported attribute ${d} for ${c} of type ${d}`);for(let c in a){let d=a[c];d.validate&&d.validate(b[c])}}function af(a,b){let c=Object.create(null);if(b)for(let d in b)c[d]=new ah(a,d,b[d]);return c}class ag{constructor(a,b,c){this.name=a,this.schema=b,this.spec=c,this.markSet=null,this.groups=c.group?c.group.split(" "):[],this.attrs=af(a,c.attrs),this.defaultAttrs=ac(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(c.inline||"text"==a),this.isText="text"==a}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Z.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(a){return this.groups.indexOf(a)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let a in this.attrs)if(this.attrs[a].isRequired)return!0;return!1}compatibleContent(a){return this==a||this.contentMatch.compatible(a.contentMatch)}computeAttrs(a){return!a&&this.defaultAttrs?this.defaultAttrs:ad(this.attrs,a)}create(a=null,b,c){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new W(this,this.computeAttrs(a),D.from(b),H.setFrom(c))}createChecked(a=null,b,c){return b=D.from(b),this.checkContent(b),new W(this,this.computeAttrs(a),b,H.setFrom(c))}createAndFill(a=null,b,c){if(a=this.computeAttrs(a),(b=D.from(b)).size){let a=this.contentMatch.fillBefore(b);if(!a)return null;b=a.append(b)}let d=this.contentMatch.matchFragment(b),e=d&&d.fillBefore(D.empty,!0);return e?new W(this,a,b.append(e),H.setFrom(c)):null}validContent(a){let b=this.contentMatch.matchFragment(a);if(!b||!b.validEnd)return!1;for(let b=0;b<a.childCount;b++)if(!this.allowsMarks(a.child(b).marks))return!1;return!0}checkContent(a){if(!this.validContent(a))throw RangeError(`Invalid content for node ${this.name}: ${a.toString().slice(0,50)}`)}checkAttrs(a){ae(this.attrs,a,"node",this.name)}allowsMarkType(a){return null==this.markSet||this.markSet.indexOf(a)>-1}allowsMarks(a){if(null==this.markSet)return!0;for(let b=0;b<a.length;b++)if(!this.allowsMarkType(a[b].type))return!1;return!0}allowedMarks(a){let b;if(null==this.markSet)return a;for(let c=0;c<a.length;c++)this.allowsMarkType(a[c].type)?b&&b.push(a[c]):b||(b=a.slice(0,c));return b?b.length?b:H.none:a}static compile(a,b){let c=Object.create(null);a.forEach((a,d)=>c[a]=new ag(a,b,d));let d=b.spec.topNode||"doc";if(!c[d])throw RangeError("Schema is missing its top node type ('"+d+"')");if(!c.text)throw RangeError("Every schema needs a 'text' type");for(let a in c.text.attrs)throw RangeError("The text node type should not have attributes");return c}}class ah{constructor(a,b,c){this.hasDefault=Object.prototype.hasOwnProperty.call(c,"default"),this.default=c.default,this.validate="string"==typeof c.validate?function(a,b,c){let d=c.split("|");return c=>{let e=null===c?"null":typeof c;if(0>d.indexOf(e))throw RangeError(`Expected value of type ${d} for attribute ${b} on type ${a}, got ${e}`)}}(a,b,c.validate):c.validate}get isRequired(){return!this.hasDefault}}class ai{constructor(a,b,c,d){this.name=a,this.rank=b,this.schema=c,this.spec=d,this.attrs=af(a,d.attrs),this.excluded=null;let e=ac(this.attrs);this.instance=e?new H(this,e):null}create(a=null){return!a&&this.instance?this.instance:new H(this,ad(this.attrs,a))}static compile(a,b){let c=Object.create(null),d=0;return a.forEach((a,e)=>c[a]=new ai(a,d++,b,e)),c}removeFromSet(a){for(var b=0;b<a.length;b++)a[b].type==this&&(a=a.slice(0,b).concat(a.slice(b+1)),b--);return a}isInSet(a){for(let b=0;b<a.length;b++)if(a[b].type==this)return a[b]}checkAttrs(a){ae(this.attrs,a,"mark",this.name)}excludes(a){return this.excluded.indexOf(a)>-1}}class aj{constructor(a){this.linebreakReplacement=null,this.cached=Object.create(null);let b=this.spec={};for(let c in a)b[c]=a[c];b.nodes=C.from(a.nodes),b.marks=C.from(a.marks||{}),this.nodes=ag.compile(this.spec.nodes,this),this.marks=ai.compile(this.spec.marks,this);let c=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw RangeError(a+" can not be both a node and a mark");let b=this.nodes[a],d=b.spec.content||"",e=b.spec.marks;if(b.contentMatch=c[d]||(c[d]=Z.parse(d,this.nodes)),b.inlineContent=b.contentMatch.inlineContent,b.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!b.isInline||!b.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=b}b.markSet="_"==e?null:e?ak(this,e.split(" ")):""!=e&&b.inlineContent?null:[]}for(let a in this.marks){let b=this.marks[a],c=b.spec.excludes;b.excluded=null==c?[b]:""==c?[]:ak(this,c.split(" "))}this.nodeFromJSON=a=>W.fromJSON(this,a),this.markFromJSON=a=>H.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(a,b=null,c,d){if("string"==typeof a)a=this.nodeType(a);else if(a instanceof ag){if(a.schema!=this)throw RangeError("Node type from different schema used ("+a.name+")")}else throw RangeError("Invalid node type: "+a);return a.createChecked(b,c,d)}text(a,b){let c=this.nodes.text;return new X(c,c.defaultAttrs,a,H.setFrom(b))}mark(a,b){return"string"==typeof a&&(a=this.marks[a]),a.create(b)}nodeType(a){let b=this.nodes[a];if(!b)throw RangeError("Unknown node type: "+a);return b}}function ak(a,b){let c=[];for(let d=0;d<b.length;d++){let e=b[d],f=a.marks[e],g=f;if(f)c.push(f);else for(let b in a.marks){let d=a.marks[b];("_"==e||d.spec.group&&d.spec.group.split(" ").indexOf(e)>-1)&&c.push(g=d)}if(!g)throw SyntaxError("Unknown mark type: '"+b[d]+"'")}return c}class al{constructor(a,b){this.schema=a,this.rules=b,this.tags=[],this.styles=[];let c=this.matchedStyles=[];b.forEach(a=>{if(null!=a.tag)this.tags.push(a);else if(null!=a.style){let b=/[^=]*/.exec(a.style)[0];0>c.indexOf(b)&&c.push(b),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(b=>{if(!/^(ul|ol)\b/.test(b.tag)||!b.node)return!1;let c=a.nodes[b.node];return c.contentMatch.matchType(c)})}parse(a,b={}){let c=new ar(this,b,!1);return c.addAll(a,H.none,b.from,b.to),c.finish()}parseSlice(a,b={}){let c=new ar(this,b,!0);return c.addAll(a,H.none,b.from,b.to),J.maxOpen(c.finish())}matchTag(a,b,c){for(let f=c?this.tags.indexOf(c)+1:0;f<this.tags.length;f++){var d,e;let c=this.tags[f];if(d=a,e=c.tag,(d.matches||d.msMatchesSelector||d.webkitMatchesSelector||d.mozMatchesSelector).call(d,e)&&(void 0===c.namespace||a.namespaceURI==c.namespace)&&(!c.context||b.matchesContext(c.context))){if(c.getAttrs){let b=c.getAttrs(a);if(!1===b)continue;c.attrs=b||void 0}return c}}}matchStyle(a,b,c,d){for(let e=d?this.styles.indexOf(d)+1:0;e<this.styles.length;e++){let d=this.styles[e],f=d.style;if(0==f.indexOf(a)&&(!d.context||c.matchesContext(d.context))&&(!(f.length>a.length)||61==f.charCodeAt(a.length)&&f.slice(a.length+1)==b)){if(d.getAttrs){let a=d.getAttrs(b);if(!1===a)continue;d.attrs=a||void 0}return d}}}static schemaRules(a){let b=[];function c(a){let c=null==a.priority?50:a.priority,d=0;for(;d<b.length;d++){let a=b[d];if((null==a.priority?50:a.priority)<c)break}b.splice(d,0,a)}for(let b in a.marks){let d=a.marks[b].spec.parseDOM;d&&d.forEach(a=>{c(a=as(a)),a.mark||a.ignore||a.clearMark||(a.mark=b)})}for(let b in a.nodes){let d=a.nodes[b].spec.parseDOM;d&&d.forEach(a=>{c(a=as(a)),a.node||a.ignore||a.mark||(a.node=b)})}return b}static fromSchema(a){return a.cached.domParser||(a.cached.domParser=new al(a,al.schemaRules(a)))}}let am={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},an={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ao={ol:!0,ul:!0};function ap(a,b,c){return null!=b?!!b|2*("full"===b):a&&"pre"==a.whitespace?3:-5&c}class aq{constructor(a,b,c,d,e,f){this.type=a,this.attrs=b,this.marks=c,this.solid=d,this.options=f,this.content=[],this.activeMarks=H.none,this.match=e||(4&f?null:a.contentMatch)}findWrapping(a){if(!this.match){if(!this.type)return[];let b=this.type.contentMatch.fillBefore(D.from(a));if(b)this.match=this.type.contentMatch.matchFragment(b);else{let b=this.type.contentMatch,c;return(c=b.findWrapping(a.type))?(this.match=b,c):null}}return this.match.findWrapping(a.type)}finish(a){if(!(1&this.options)){let a=this.content[this.content.length-1],b;a&&a.isText&&(b=/[ \t\r\n\u000c]+$/.exec(a.text))&&(a.text.length==b[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-b[0].length)))}let b=D.from(this.content);return!a&&this.match&&(b=b.append(this.match.fillBefore(D.empty,!0))),this.type?this.type.create(this.attrs,b,this.marks):b}inlineContext(a){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:a.parentNode&&!am.hasOwnProperty(a.parentNode.nodeName.toLowerCase())}}class ar{constructor(a,b,c){this.parser=a,this.options=b,this.isOpen=c,this.open=0,this.localPreserveWS=!1;let d=b.topNode,e,f=ap(null,b.preserveWhitespace,0)|4*!!c;e=d?new aq(d.type,d.attrs,H.none,!0,b.topMatch||d.type.contentMatch,f):c?new aq(null,null,H.none,!0,null,f):new aq(a.schema.topNodeType,null,H.none,!0,null,f),this.nodes=[e],this.find=b.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(a,b){3==a.nodeType?this.addTextNode(a,b):1==a.nodeType&&this.addElement(a,b)}addTextNode(a,b){let c=a.nodeValue,d=this.top,e=2&d.options?"full":this.localPreserveWS||(1&d.options)>0,{schema:f}=this.parser;if("full"===e||d.inlineContext(a)||/[^ \t\r\n\u000c]/.test(c)){if(e)if("full"===e)c=c.replace(/\r\n?/g,"\n");else if(f.linebreakReplacement&&/[\r\n]/.test(c)&&this.top.findWrapping(f.linebreakReplacement.create())){let a=c.split(/\r?\n|\r/);for(let c=0;c<a.length;c++)c&&this.insertNode(f.linebreakReplacement.create(),b,!0),a[c]&&this.insertNode(f.text(a[c]),b,!/\S/.test(a[c]));c=""}else c=c.replace(/\r?\n|\r/g," ");else if(c=c.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(c)&&this.open==this.nodes.length-1){let b=d.content[d.content.length-1],e=a.previousSibling;(!b||e&&"BR"==e.nodeName||b.isText&&/[ \t\r\n\u000c]$/.test(b.text))&&(c=c.slice(1))}c&&this.insertNode(f.text(c),b,!/\S/.test(c)),this.findInText(a)}else this.findInside(a)}addElement(a,b,c){let d=this.localPreserveWS,e=this.top;("PRE"==a.tagName||/pre/.test(a.style&&a.style.whiteSpace))&&(this.localPreserveWS=!0);let f=a.nodeName.toLowerCase(),g;ao.hasOwnProperty(f)&&this.parser.normalizeLists&&function(a){for(let b=a.firstChild,c=null;b;b=b.nextSibling){let a=1==b.nodeType?b.nodeName.toLowerCase():null;a&&ao.hasOwnProperty(a)&&c?(c.appendChild(b),b=c):"li"==a?c=b:a&&(c=null)}}(a);let h=this.options.ruleFromNode&&this.options.ruleFromNode(a)||(g=this.parser.matchTag(a,this,c));a:if(h?h.ignore:an.hasOwnProperty(f))this.findInside(a),this.ignoreFallback(a,b);else if(!h||h.skip||h.closeParent){h&&h.closeParent?this.open=Math.max(0,this.open-1):h&&h.skip.nodeType&&(a=h.skip);let c,d=this.needsBlock;if(am.hasOwnProperty(f))e.content.length&&e.content[0].isInline&&this.open&&(this.open--,e=this.top),c=!0,e.type||(this.needsBlock=!0);else if(!a.firstChild){this.leafFallback(a,b);break a}let g=h&&h.skip?b:this.readStyles(a,b);g&&this.addAll(a,g),c&&this.sync(e),this.needsBlock=d}else{let c=this.readStyles(a,b);c&&this.addElementByRule(a,h,c,!1===h.consuming?g:void 0)}this.localPreserveWS=d}leafFallback(a,b){"BR"==a.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(a.ownerDocument.createTextNode("\n"),b)}ignoreFallback(a,b){"BR"!=a.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),b,!0)}readStyles(a,b){let c=a.style;if(c&&c.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let d=this.parser.matchedStyles[a],e=c.getPropertyValue(d);if(e)for(let a;;){let c=this.parser.matchStyle(d,e,this,a);if(!c)break;if(c.ignore)return null;if(b=c.clearMark?b.filter(a=>!c.clearMark(a)):b.concat(this.parser.schema.marks[c.mark].create(c.attrs)),!1===c.consuming)a=c;else break}}return b}addElementByRule(a,b,c,d){let e,f;if(b.node)if((f=this.parser.schema.nodes[b.node]).isLeaf)this.insertNode(f.create(b.attrs),c,"BR"==a.nodeName)||this.leafFallback(a,c);else{let a=this.enter(f,b.attrs||null,c,b.preserveWhitespace);a&&(e=!0,c=a)}else{let a=this.parser.schema.marks[b.mark];c=c.concat(a.create(b.attrs))}let g=this.top;if(f&&f.isLeaf)this.findInside(a);else if(d)this.addElement(a,c,d);else if(b.getContent)this.findInside(a),b.getContent(a,this.parser.schema).forEach(a=>this.insertNode(a,c,!1));else{let d=a;"string"==typeof b.contentElement?d=a.querySelector(b.contentElement):"function"==typeof b.contentElement?d=b.contentElement(a):b.contentElement&&(d=b.contentElement),this.findAround(a,d,!0),this.addAll(d,c),this.findAround(a,d,!1)}e&&this.sync(g)&&this.open--}addAll(a,b,c,d){let e=c||0;for(let f=c?a.childNodes[c]:a.firstChild,g=null==d?null:a.childNodes[d];f!=g;f=f.nextSibling,++e)this.findAtPoint(a,e),this.addDOM(f,b);this.findAtPoint(a,e)}findPlace(a,b,c){let d,e;for(let b=this.open,f=0;b>=0;b--){let g=this.nodes[b],h=g.findWrapping(a);if(h&&(!d||d.length>h.length+f)&&(d=h,e=g,!h.length))break;if(g.solid){if(c)break;f+=2}}if(!d)return null;this.sync(e);for(let a=0;a<d.length;a++)b=this.enterInner(d[a],null,b,!1);return b}insertNode(a,b,c){if(a.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(b=this.enterInner(a,null,b))}let d=this.findPlace(a,b,c);if(d){this.closeExtra();let b=this.top;b.match&&(b.match=b.match.matchType(a.type));let c=H.none;for(let e of d.concat(a.marks))(b.type?b.type.allowsMarkType(e.type):at(e.type,a.type))&&(c=e.addToSet(c));return b.content.push(a.mark(c)),!0}return!1}enter(a,b,c,d){let e=this.findPlace(a.create(b),c,!1);return e&&(e=this.enterInner(a,b,c,!0,d)),e}enterInner(a,b,c,d=!1,e){this.closeExtra();let f=this.top;f.match=f.match&&f.match.matchType(a);let g=ap(a,e,f.options);4&f.options&&0==f.content.length&&(g|=4);let h=H.none;return c=c.filter(b=>(f.type?!f.type.allowsMarkType(b.type):!at(b.type,a))||(h=b.addToSet(h),!1)),this.nodes.push(new aq(a,b,h,d,null,g)),this.open++,c}closeExtra(a=!1){let b=this.nodes.length-1;if(b>this.open){for(;b>this.open;b--)this.nodes[b-1].content.push(this.nodes[b].finish(a));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(a){for(let b=this.open;b>=0;b--)if(this.nodes[b]==a)return this.open=b,!0;else this.localPreserveWS&&(this.nodes[b].options|=1);return!1}get currentPos(){this.closeExtra();let a=0;for(let b=this.open;b>=0;b--){let c=this.nodes[b].content;for(let b=c.length-1;b>=0;b--)a+=c[b].nodeSize;b&&a++}return a}findAtPoint(a,b){if(this.find)for(let c=0;c<this.find.length;c++)this.find[c].node==a&&this.find[c].offset==b&&(this.find[c].pos=this.currentPos)}findInside(a){if(this.find)for(let b=0;b<this.find.length;b++)null==this.find[b].pos&&1==a.nodeType&&a.contains(this.find[b].node)&&(this.find[b].pos=this.currentPos)}findAround(a,b,c){if(a!=b&&this.find)for(let d=0;d<this.find.length;d++)null==this.find[d].pos&&1==a.nodeType&&a.contains(this.find[d].node)&&b.compareDocumentPosition(this.find[d].node)&(c?2:4)&&(this.find[d].pos=this.currentPos)}findInText(a){if(this.find)for(let b=0;b<this.find.length;b++)this.find[b].node==a&&(this.find[b].pos=this.currentPos-(a.nodeValue.length-this.find[b].offset))}matchesContext(a){if(a.indexOf("|")>-1)return a.split(/\s*\|\s*/).some(this.matchesContext,this);let b=a.split("/"),c=this.options.context,d=!this.isOpen&&(!c||c.parent.type==this.nodes[0].type),e=-(c?c.depth+1:0)+ +!d,f=(a,g)=>{for(;a>=0;a--){let h=b[a];if(""==h){if(a==b.length-1||0==a)continue;for(;g>=e;g--)if(f(a-1,g))return!0;return!1}{let a=g>0||0==g&&d?this.nodes[g].type:c&&g>=e?c.node(g-e).type:null;if(!a||a.name!=h&&!a.isInGroup(h))return!1;g--}}return!0};return f(b.length-1,this.open)}textblockFromContext(){let a=this.options.context;if(a)for(let b=a.depth;b>=0;b--){let c=a.node(b).contentMatchAt(a.indexAfter(b)).defaultType;if(c&&c.isTextblock&&c.defaultAttrs)return c}for(let a in this.parser.schema.nodes){let b=this.parser.schema.nodes[a];if(b.isTextblock&&b.defaultAttrs)return b}}}function as(a){let b={};for(let c in a)b[c]=a[c];return b}function at(a,b){let c=b.schema.nodes;for(let d in c){let e=c[d];if(!e.allowsMarkType(a))continue;let f=[],g=a=>{f.push(a);for(let c=0;c<a.edgeCount;c++){let{type:d,next:e}=a.edge(c);if(d==b||0>f.indexOf(e)&&g(e))return!0}};if(g(e.contentMatch))return!0}}class au{constructor(a,b){this.nodes=a,this.marks=b}serializeFragment(a,b={},c){c||(c=aw(b).createDocumentFragment());let d=c,e=[];return a.forEach(a=>{if(e.length||a.marks.length){let c=0,f=0;for(;c<e.length&&f<a.marks.length;){let b=a.marks[f];if(!this.marks[b.type.name]){f++;continue}if(!b.eq(e[c][0])||!1===b.type.spec.spanning)break;c++,f++}for(;c<e.length;)d=e.pop()[1];for(;f<a.marks.length;){let c=a.marks[f++],g=this.serializeMark(c,a.isInline,b);g&&(e.push([c,d]),d.appendChild(g.dom),d=g.contentDOM||g.dom)}}d.appendChild(this.serializeNodeInner(a,b))}),c}serializeNodeInner(a,b){let{dom:c,contentDOM:d}=ay(aw(b),this.nodes[a.type.name](a),null,a.attrs);if(d){if(a.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(a.content,b,d)}return c}serializeNode(a,b={}){let c=this.serializeNodeInner(a,b);for(let d=a.marks.length-1;d>=0;d--){let e=this.serializeMark(a.marks[d],a.isInline,b);e&&((e.contentDOM||e.dom).appendChild(c),c=e.dom)}return c}serializeMark(a,b,c={}){let d=this.marks[a.type.name];return d&&ay(aw(c),d(a,b),null,a.attrs)}static renderSpec(a,b,c=null,d){return ay(a,b,c,d)}static fromSchema(a){return a.cached.domSerializer||(a.cached.domSerializer=new au(this.nodesFromSchema(a),this.marksFromSchema(a)))}static nodesFromSchema(a){let b=av(a.nodes);return b.text||(b.text=a=>a.text),b}static marksFromSchema(a){return av(a.marks)}}function av(a){let b={};for(let c in a){let d=a[c].spec.toDOM;d&&(b[c]=d)}return b}function aw(a){return a.document||window.document}let ax=new WeakMap;function ay(a,b,c,d){let e,f,g;if("string"==typeof b)return{dom:a.createTextNode(b)};if(null!=b.nodeType)return{dom:b};if(b.dom&&null!=b.dom.nodeType)return b;let h=b[0],i;if("string"!=typeof h)throw RangeError("Invalid array passed to renderSpec");if(d&&(void 0===(f=ax.get(d))&&ax.set(d,(g=null,!function a(b){if(b&&"object"==typeof b)if(Array.isArray(b))if("string"==typeof b[0])g||(g=[]),g.push(b);else for(let c=0;c<b.length;c++)a(b[c]);else for(let c in b)a(b[c])}(d),f=g)),i=f)&&i.indexOf(b)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let j=h.indexOf(" ");j>0&&(c=h.slice(0,j),h=h.slice(j+1));let k=c?a.createElementNS(c,h):a.createElement(h),l=b[1],m=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){for(let a in m=2,l)if(null!=l[a]){let b=a.indexOf(" ");b>0?k.setAttributeNS(a.slice(0,b),a.slice(b+1),l[a]):"style"==a&&k.style?k.style.cssText=l[a]:k.setAttribute(a,l[a])}}for(let f=m;f<b.length;f++){let g=b[f];if(0===g){if(f<b.length-1||f>m)throw RangeError("Content hole must be the only child of its parent node");return{dom:k,contentDOM:k}}{let{dom:b,contentDOM:f}=ay(a,g,c,d);if(k.appendChild(b),f){if(e)throw RangeError("Multiple content holes");e=f}}}return{dom:k,contentDOM:e}}class az{constructor(a,b,c){this.pos=a,this.delInfo=b,this.recover=c}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class aA{constructor(a,b=!1){if(this.ranges=a,this.inverted=b,!a.length&&aA.empty)return aA.empty}recover(a){let b=0,c=65535&a;if(!this.inverted)for(let a=0;a<c;a++)b+=this.ranges[3*a+2]-this.ranges[3*a+1];return this.ranges[3*c]+b+(a-(65535&a))/65536}mapResult(a,b=1){return this._map(a,b,!1)}map(a,b=1){return this._map(a,b,!0)}_map(a,b,c){let d=0,e=this.inverted?2:1,f=this.inverted?1:2;for(let g=0;g<this.ranges.length;g+=3){let h=this.ranges[g]-(this.inverted?d:0);if(h>a)break;let i=this.ranges[g+e],j=this.ranges[g+f],k=h+i;if(a<=k){let e=i?a==h?-1:a==k?1:b:b,f=h+d+(e<0?0:j);if(c)return f;let l=a==(b<0?h:k)?null:g/3+(a-h)*65536,m=a==h?2:a==k?1:4;return(b<0?a!=h:a!=k)&&(m|=8),new az(f,m,l)}d+=j-i}return c?a+d:new az(a+d,0,null)}touches(a,b){let c=0,d=65535&b,e=this.inverted?2:1,f=this.inverted?1:2;for(let b=0;b<this.ranges.length;b+=3){let g=this.ranges[b]-(this.inverted?c:0);if(g>a)break;let h=this.ranges[b+e];if(a<=g+h&&b==3*d)return!0;c+=this.ranges[b+f]-h}return!1}forEach(a){let b=this.inverted?2:1,c=this.inverted?1:2;for(let d=0,e=0;d<this.ranges.length;d+=3){let f=this.ranges[d],g=f-(this.inverted?e:0),h=f+(this.inverted?0:e),i=this.ranges[d+b],j=this.ranges[d+c];a(g,g+i,h,h+j),e+=j-i}}invert(){return new aA(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(a){return 0==a?aA.empty:new aA(a<0?[0,-a,0]:[0,0,a])}}aA.empty=new aA([]);class aB{constructor(a,b,c=0,d=a?a.length:0){this.mirror=b,this.from=c,this.to=d,this._maps=a||[],this.ownData=!(a||b)}get maps(){return this._maps}slice(a=0,b=this.maps.length){return new aB(this._maps,this.mirror,a,b)}appendMap(a,b){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(a),null!=b&&this.setMirror(this._maps.length-1,b)}appendMapping(a){for(let b=0,c=this._maps.length;b<a._maps.length;b++){let d=a.getMirror(b);this.appendMap(a._maps[b],null!=d&&d<b?c+d:void 0)}}getMirror(a){if(this.mirror){for(let b=0;b<this.mirror.length;b++)if(this.mirror[b]==a)return this.mirror[b+(b%2?-1:1)]}}setMirror(a,b){this.mirror||(this.mirror=[]),this.mirror.push(a,b)}appendMappingInverted(a){for(let b=a.maps.length-1,c=this._maps.length+a._maps.length;b>=0;b--){let d=a.getMirror(b);this.appendMap(a._maps[b].invert(),null!=d&&d>b?c-d-1:void 0)}}invert(){let a=new aB;return a.appendMappingInverted(this),a}map(a,b=1){if(this.mirror)return this._map(a,b,!0);for(let c=this.from;c<this.to;c++)a=this._maps[c].map(a,b);return a}mapResult(a,b=1){return this._map(a,b,!1)}_map(a,b,c){let d=0;for(let c=this.from;c<this.to;c++){let e=this._maps[c].mapResult(a,b);if(null!=e.recover){let b=this.getMirror(c);if(null!=b&&b>c&&b<this.to){c=b,a=this._maps[b].recover(e.recover);continue}}d|=e.delInfo,a=e.pos}return c?a:new az(a,d,null)}}let aC=Object.create(null);class aD{getMap(){return aA.empty}merge(a){return null}static fromJSON(a,b){if(!b||!b.stepType)throw RangeError("Invalid input for Step.fromJSON");let c=aC[b.stepType];if(!c)throw RangeError(`No step type ${b.stepType} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in aC)throw RangeError("Duplicate use of step JSON ID "+a);return aC[a]=b,b.prototype.jsonID=a,b}}class aE{constructor(a,b){this.doc=a,this.failed=b}static ok(a){return new aE(a,null)}static fail(a){return new aE(null,a)}static fromReplace(a,b,c,d){try{return aE.ok(a.replace(b,c,d))}catch(a){if(a instanceof I)return aE.fail(a.message);throw a}}}function aF(a,b,c){let d=[];for(let e=0;e<a.childCount;e++){let f=a.child(e);f.content.size&&(f=f.copy(aF(f.content,b,f))),f.isInline&&(f=b(f,c,e)),d.push(f)}return D.fromArray(d)}class aG extends aD{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=a.resolve(this.from),d=c.node(c.sharedDepth(this.to)),e=new J(aF(b.content,(a,b)=>a.isAtom&&b.type.allowsMarkType(this.mark.type)?a.mark(this.mark.addToSet(a.marks)):a,d),b.openStart,b.openEnd);return aE.fromReplace(a,this.from,this.to,e)}invert(){return new aH(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new aG(b.pos,c.pos,this.mark)}merge(a){return a instanceof aG&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new aG(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new aG(b.from,b.to,a.markFromJSON(b.mark))}}aD.jsonID("addMark",aG);class aH extends aD{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=new J(aF(b.content,a=>a.mark(this.mark.removeFromSet(a.marks)),a),b.openStart,b.openEnd);return aE.fromReplace(a,this.from,this.to,c)}invert(){return new aG(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new aH(b.pos,c.pos,this.mark)}merge(a){return a instanceof aH&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new aH(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new aH(b.from,b.to,a.markFromJSON(b.mark))}}aD.jsonID("removeMark",aH);class aI extends aD{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return aE.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.addToSet(b.marks));return aE.fromReplace(a,this.pos,this.pos+1,new J(D.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);if(b){let a=this.mark.addToSet(b.marks);if(a.length==b.marks.length){for(let c=0;c<b.marks.length;c++)if(!b.marks[c].isInSet(a))return new aI(this.pos,b.marks[c]);return new aI(this.pos,this.mark)}}return new aJ(this.pos,this.mark)}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new aI(b.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new aI(b.pos,a.markFromJSON(b.mark))}}aD.jsonID("addNodeMark",aI);class aJ extends aD{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return aE.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.removeFromSet(b.marks));return aE.fromReplace(a,this.pos,this.pos+1,new J(D.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);return b&&this.mark.isInSet(b.marks)?new aI(this.pos,this.mark):this}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new aJ(b.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new aJ(b.pos,a.markFromJSON(b.mark))}}aD.jsonID("removeNodeMark",aJ);class aK extends aD{constructor(a,b,c,d=!1){super(),this.from=a,this.to=b,this.slice=c,this.structure=d}apply(a){return this.structure&&aM(a,this.from,this.to)?aE.fail("Structure replace would overwrite content"):aE.fromReplace(a,this.from,this.to,this.slice)}getMap(){return new aA([this.from,this.to-this.from,this.slice.size])}invert(a){return new aK(this.from,this.from+this.slice.size,a.slice(this.from,this.to))}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deletedAcross&&c.deletedAcross?null:new aK(b.pos,Math.max(b.pos,c.pos),this.slice,this.structure)}merge(a){if(!(a instanceof aK)||a.structure||this.structure)return null;if(this.from+this.slice.size!=a.from||this.slice.openEnd||a.slice.openStart)if(a.to!=this.from||this.slice.openStart||a.slice.openEnd)return null;else{let b=this.slice.size+a.slice.size==0?J.empty:new J(a.slice.content.append(this.slice.content),a.slice.openStart,this.slice.openEnd);return new aK(a.from,this.to,b,this.structure)}{let b=this.slice.size+a.slice.size==0?J.empty:new J(this.slice.content.append(a.slice.content),this.slice.openStart,a.slice.openEnd);return new aK(this.from,this.to+(a.to-a.from),b,this.structure)}}toJSON(){let a={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new aK(b.from,b.to,J.fromJSON(a,b.slice),!!b.structure)}}aD.jsonID("replace",aK);class aL extends aD{constructor(a,b,c,d,e,f,g=!1){super(),this.from=a,this.to=b,this.gapFrom=c,this.gapTo=d,this.slice=e,this.insert=f,this.structure=g}apply(a){if(this.structure&&(aM(a,this.from,this.gapFrom)||aM(a,this.gapTo,this.to)))return aE.fail("Structure gap-replace would overwrite content");let b=a.slice(this.gapFrom,this.gapTo);if(b.openStart||b.openEnd)return aE.fail("Gap is not a flat range");let c=this.slice.insertAt(this.insert,b.content);return c?aE.fromReplace(a,this.from,this.to,c):aE.fail("Content does not fit in gap")}getMap(){return new aA([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(a){let b=this.gapTo-this.gapFrom;return new aL(this.from,this.from+this.slice.size+b,this.from+this.insert,this.from+this.insert+b,a.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1),d=this.from==this.gapFrom?b.pos:a.map(this.gapFrom,-1),e=this.to==this.gapTo?c.pos:a.map(this.gapTo,1);return b.deletedAcross&&c.deletedAcross||d<b.pos||e>c.pos?null:new aL(b.pos,c.pos,d,e,this.slice,this.insert,this.structure)}toJSON(){let a={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to||"number"!=typeof b.gapFrom||"number"!=typeof b.gapTo||"number"!=typeof b.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new aL(b.from,b.to,b.gapFrom,b.gapTo,J.fromJSON(a,b.slice),b.insert,!!b.structure)}}function aM(a,b,c){let d=a.resolve(b),e=c-b,f=d.depth;for(;e>0&&f>0&&d.indexAfter(f)==d.node(f).childCount;)f--,e--;if(e>0){let a=d.node(f).maybeChild(d.indexAfter(f));for(;e>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,e--}}return!1}function aN(a,b,c,d=c.contentMatch,e=!0){let f=a.doc.nodeAt(b),g=[],h=b+1;for(let b=0;b<f.childCount;b++){let i=f.child(b),j=h+i.nodeSize,k=d.matchType(i.type);if(k){d=k;for(let b=0;b<i.marks.length;b++)c.allowsMarkType(i.marks[b].type)||a.step(new aH(h,j,i.marks[b]));if(e&&i.isText&&"pre"!=c.whitespace){let a,b=/\r?\n|\r/g,d;for(;a=b.exec(i.text);)d||(d=new J(D.from(c.schema.text(" ",c.allowedMarks(i.marks))),0,0)),g.push(new aK(h+a.index,h+a.index+a[0].length,d))}}else g.push(new aK(h,j,J.empty));h=j}if(!d.validEnd){let b=d.fillBefore(D.empty,!0);a.replace(h,h,new J(b,0,0))}for(let b=g.length-1;b>=0;b--)a.step(g[b])}function aO(a){let b=a.parent.content.cutByIndex(a.startIndex,a.endIndex);for(let c=a.depth,d=0,e=0;;--c){let f=a.$from.node(c),g=a.$from.index(c)+d,h=a.$to.indexAfter(c)-e;if(c<a.depth&&f.canReplace(g,h,b))return c;if(0==c||f.type.spec.isolating||!((0==g||f.canReplace(g,f.childCount))&&(h==f.childCount||f.canReplace(0,h))))break;g&&(d=1),h<f.childCount&&(e=1)}return null}function aP(a,b,c=null,d=a){let e=function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.contentMatchAt(d).findWrapping(b);if(!f)return null;let g=f.length?f[0]:b;return c.canReplaceWith(d,e,g)?f:null}(a,b),f=e&&function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.child(d),g=b.contentMatch.findWrapping(f.type);if(!g)return null;let h=(g.length?g[g.length-1]:b).contentMatch;for(let a=d;h&&a<e;a++)h=h.matchType(c.child(a).type);return h&&h.validEnd?g:null}(d,b);return f?e.map(aQ).concat({type:b,attrs:c}).concat(f.map(aQ)):null}function aQ(a){return{type:a,attrs:null}}function aR(a,b,c,d){b.forEach((e,f)=>{if(e.isText){let g,h=/\r?\n|\r/g;for(;g=h.exec(e.text);){let e=a.mapping.slice(d).map(c+1+f+g.index);a.replaceWith(e,e+1,b.type.schema.linebreakReplacement.create())}}})}function aS(a,b,c,d){b.forEach((e,f)=>{if(e.type==e.type.schema.linebreakReplacement){let e=a.mapping.slice(d).map(c+1+f);a.replaceWith(e,e+1,b.type.schema.text("\n"))}})}function aT(a,b,c=1,d){let e=a.resolve(b),f=e.depth-c,g=d&&d[d.length-1]||e.parent;if(f<0||e.parent.type.spec.isolating||!e.parent.canReplace(e.index(),e.parent.childCount)||!g.type.validContent(e.parent.content.cutByIndex(e.index(),e.parent.childCount)))return!1;for(let a=e.depth-1,b=c-2;a>f;a--,b--){let c=e.node(a),f=e.index(a);if(c.type.spec.isolating)return!1;let g=c.content.cutByIndex(f,c.childCount),h=d&&d[b+1];h&&(g=g.replaceChild(0,h.type.create(h.attrs)));let i=d&&d[b]||c;if(!c.canReplace(f+1,c.childCount)||!i.type.validContent(g))return!1}let h=e.indexAfter(f),i=d&&d[0];return e.node(f).canReplaceWith(h,h,i?i.type:e.node(f+1).type)}function aU(a,b){let c=a.resolve(b),d=c.index();return aV(c.nodeBefore,c.nodeAfter)&&c.parent.canReplace(d,d+1)}function aV(a,b){return!!(a&&b&&!a.isLeaf&&function(a,b){b.content.size||a.type.compatibleContent(b.type);let c=a.contentMatchAt(a.childCount),{linebreakReplacement:d}=a.type.schema;for(let e=0;e<b.childCount;e++){let f=b.child(e),g=f.type==d?a.type.schema.nodes.text:f.type;if(!(c=c.matchType(g))||!a.type.allowsMarks(f.marks))return!1}return c.validEnd}(a,b))}function aW(a,b,c=-1){let d=a.resolve(b);for(let a=d.depth;;a--){let e,f,g=d.index(a);if(a==d.depth?(e=d.nodeBefore,f=d.nodeAfter):c>0?(e=d.node(a+1),g++,f=d.node(a).maybeChild(g)):(e=d.node(a).maybeChild(g-1),f=d.node(a+1)),e&&!e.isTextblock&&aV(e,f)&&d.node(a).canReplace(g,g+1))return b;if(0==a)break;b=c<0?d.before(a):d.after(a)}}function aX(a,b,c){let d=a.resolve(b);if(!c.content.size)return b;let e=c.content;for(let a=0;a<c.openStart;a++)e=e.firstChild.content;for(let a=1;a<=(0==c.openStart&&c.size?2:1);a++)for(let b=d.depth;b>=0;b--){let c=b==d.depth?0:d.pos<=(d.start(b+1)+d.end(b+1))/2?-1:1,f=d.index(b)+ +(c>0),g=d.node(b),h=!1;if(1==a)h=g.canReplace(f,f,e);else{let a=g.contentMatchAt(f).findWrapping(e.firstChild.type);h=a&&g.canReplaceWith(f,f,a[0])}if(h)return 0==c?d.pos:c<0?d.before(b+1):d.after(b+1)}return null}function aY(a,b,c=b,d=J.empty){if(b==c&&!d.size)return null;let e=a.resolve(b),f=a.resolve(c);return aZ(e,f,d)?new aK(b,c,d):new a$(e,f,d).fit()}function aZ(a,b,c){return!c.openStart&&!c.openEnd&&a.start()==b.start()&&a.parent.canReplace(a.index(),b.index(),c.content)}aD.jsonID("replaceAround",aL);class a${constructor(a,b,c){this.$from=a,this.$to=b,this.unplaced=c,this.frontier=[],this.placed=D.empty;for(let b=0;b<=a.depth;b++){let c=a.node(b);this.frontier.push({type:c.type,match:c.contentMatchAt(a.indexAfter(b))})}for(let b=a.depth;b>0;b--)this.placed=D.from(a.node(b).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let a=this.mustMoveInline(),b=this.placed.size-this.depth-this.$from.depth,c=this.$from,d=this.close(a<0?this.$to:c.doc.resolve(a));if(!d)return null;let e=this.placed,f=c.depth,g=d.depth;for(;f&&g&&1==e.childCount;)e=e.firstChild.content,f--,g--;let h=new J(e,f,g);return a>-1?new aL(c.pos,a,this.$to.pos,this.$to.end(),h,b):h.size||c.pos!=this.$to.pos?new aK(c.pos,d.pos,h):null}findFittable(){let a=this.unplaced.openStart;for(let b=this.unplaced.content,c=0,d=this.unplaced.openEnd;c<a;c++){let e=b.firstChild;if(b.childCount>1&&(d=0),e.type.spec.isolating&&d<=c){a=c;break}b=e.content}for(let b=1;b<=2;b++)for(let c=1==b?a:this.unplaced.openStart;c>=0;c--){let a=null,d=(c?(a=a1(this.unplaced.content,c-1).firstChild).content:this.unplaced.content).firstChild;for(let e=this.depth;e>=0;e--){let{type:f,match:g}=this.frontier[e],h,i=null;if(1==b&&(d?g.matchType(d.type)||(i=g.fillBefore(D.from(d),!1)):a&&f.compatibleContent(a.type)))return{sliceDepth:c,frontierDepth:e,parent:a,inject:i};if(2==b&&d&&(h=g.findWrapping(d.type)))return{sliceDepth:c,frontierDepth:e,parent:a,wrap:h};if(a&&g.matchType(a.type))break}}}openMore(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=a1(a,b);return!!d.childCount&&!d.firstChild.isLeaf&&(this.unplaced=new J(a,b+1,Math.max(c,d.size+b>=a.size-c?b+1:0)),!0)}dropNode(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=a1(a,b);if(d.childCount<=1&&b>0){let e=a.size-b<=b+d.size;this.unplaced=new J(a_(a,b-1,1),b-1,e?b-1:c)}else this.unplaced=new J(a_(a,b,1),b,c)}placeNodes({sliceDepth:a,frontierDepth:b,parent:c,inject:d,wrap:e}){for(;this.depth>b;)this.closeFrontierNode();if(e)for(let a=0;a<e.length;a++)this.openFrontierNode(e[a]);let f=this.unplaced,g=c?c.content:f.content,h=f.openStart-a,i=0,j=[],{match:k,type:l}=this.frontier[b];if(d){for(let a=0;a<d.childCount;a++)j.push(d.child(a));k=k.matchFragment(d)}let m=g.size+a-(f.content.size-f.openEnd);for(;i<g.childCount;){let a=g.child(i),b=k.matchType(a.type);if(!b)break;(++i>1||0==h||a.content.size)&&(k=b,j.push(function a(b,c,d){if(c<=0)return b;let e=b.content;return c>1&&(e=e.replaceChild(0,a(e.firstChild,c-1,1==e.childCount?d-1:0))),c>0&&(e=b.type.contentMatch.fillBefore(e).append(e),d<=0&&(e=e.append(b.type.contentMatch.matchFragment(e).fillBefore(D.empty,!0)))),b.copy(e)}(a.mark(l.allowedMarks(a.marks)),1==i?h:0,i==g.childCount?m:-1)))}let n=i==g.childCount;n||(m=-1),this.placed=a0(this.placed,b,D.from(j)),this.frontier[b].match=k,n&&m<0&&c&&c.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let a=0,b=g;a<m;a++){let a=b.lastChild;this.frontier.push({type:a.type,match:a.contentMatchAt(a.childCount)}),b=a.content}this.unplaced=n?0==a?J.empty:new J(a_(f.content,a-1,1),a-1,m<0?f.openEnd:a-1):new J(a_(f.content,a,i),f.openStart,f.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let a=this.frontier[this.depth],b;if(!a.type.isTextblock||!a2(this.$to,this.$to.depth,a.type,a.match,!1)||this.$to.depth==this.depth&&(b=this.findCloseLevel(this.$to))&&b.depth==this.depth)return -1;let{depth:c}=this.$to,d=this.$to.after(c);for(;c>1&&d==this.$to.end(--c);)++d;return d}findCloseLevel(a){b:for(let b=Math.min(this.depth,a.depth);b>=0;b--){let{match:c,type:d}=this.frontier[b],e=b<a.depth&&a.end(b+1)==a.pos+(a.depth-(b+1)),f=a2(a,b,d,c,e);if(f){for(let c=b-1;c>=0;c--){let{match:b,type:d}=this.frontier[c],e=a2(a,c,d,b,!0);if(!e||e.childCount)continue b}return{depth:b,fit:f,move:e?a.doc.resolve(a.after(b+1)):a}}}}close(a){let b=this.findCloseLevel(a);if(!b)return null;for(;this.depth>b.depth;)this.closeFrontierNode();b.fit.childCount&&(this.placed=a0(this.placed,b.depth,b.fit)),a=b.move;for(let c=b.depth+1;c<=a.depth;c++){let b=a.node(c),d=b.type.contentMatch.fillBefore(b.content,!0,a.index(c));this.openFrontierNode(b.type,b.attrs,d)}return a}openFrontierNode(a,b=null,c){let d=this.frontier[this.depth];d.match=d.match.matchType(a),this.placed=a0(this.placed,this.depth,D.from(a.create(b,c))),this.frontier.push({type:a,match:a.contentMatch})}closeFrontierNode(){let a=this.frontier.pop().match.fillBefore(D.empty,!0);a.childCount&&(this.placed=a0(this.placed,this.frontier.length,a))}}function a_(a,b,c){return 0==b?a.cutByIndex(c,a.childCount):a.replaceChild(0,a.firstChild.copy(a_(a.firstChild.content,b-1,c)))}function a0(a,b,c){return 0==b?a.append(c):a.replaceChild(a.childCount-1,a.lastChild.copy(a0(a.lastChild.content,b-1,c)))}function a1(a,b){for(let c=0;c<b;c++)a=a.firstChild.content;return a}function a2(a,b,c,d,e){let f=a.node(b),g=e?a.indexAfter(b):a.index(b);if(g==f.childCount&&!c.compatibleContent(f.type))return null;let h=d.fillBefore(f.content,!0,g);return h&&!function(a,b,c){for(let d=c;d<b.childCount;d++)if(!a.allowsMarks(b.child(d).marks))return!0;return!1}(c,f.content,g)?h:null}function a3(a,b){let c=[],d=Math.min(a.depth,b.depth);for(let e=d;e>=0;e--){let d=a.start(e);if(d<a.pos-(a.depth-e)||b.end(e)>b.pos+(b.depth-e)||a.node(e).type.spec.isolating||b.node(e).type.spec.isolating)break;(d==b.start(e)||e==a.depth&&e==b.depth&&a.parent.inlineContent&&b.parent.inlineContent&&e&&b.start(e-1)==d-1)&&c.push(e)}return c}class a4 extends aD{constructor(a,b,c){super(),this.pos=a,this.attr=b,this.value=c}apply(a){let b=a.nodeAt(this.pos);if(!b)return aE.fail("No node at attribute step's position");let c=Object.create(null);for(let a in b.attrs)c[a]=b.attrs[a];c[this.attr]=this.value;let d=b.type.create(c,null,b.marks);return aE.fromReplace(a,this.pos,this.pos+1,new J(D.from(d),0,+!b.isLeaf))}getMap(){return aA.empty}invert(a){return new a4(this.pos,this.attr,a.nodeAt(this.pos).attrs[this.attr])}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new a4(b.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(a,b){if("number"!=typeof b.pos||"string"!=typeof b.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new a4(b.pos,b.attr,b.value)}}aD.jsonID("attr",a4);class a5 extends aD{constructor(a,b){super(),this.attr=a,this.value=b}apply(a){let b=Object.create(null);for(let c in a.attrs)b[c]=a.attrs[c];b[this.attr]=this.value;let c=a.type.create(b,a.content,a.marks);return aE.ok(c)}getMap(){return aA.empty}invert(a){return new a5(this.attr,a.attrs[this.attr])}map(a){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(a,b){if("string"!=typeof b.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new a5(b.attr,b.value)}}aD.jsonID("docAttr",a5);let a6=class extends Error{};(a6=function a(b){let c=Error.call(this,b);return c.__proto__=a.prototype,c}).prototype=Object.create(Error.prototype),a6.prototype.constructor=a6,a6.prototype.name="TransformError";class a7{constructor(a){this.doc=a,this.steps=[],this.docs=[],this.mapping=new aB}get before(){return this.docs.length?this.docs[0]:this.doc}step(a){let b=this.maybeStep(a);if(b.failed)throw new a6(b.failed);return this}maybeStep(a){let b=a.apply(this.doc);return b.failed||this.addStep(a,b.doc),b}get docChanged(){return this.steps.length>0}changedRange(){let a=1e9,b=-1e9;for(let c=0;c<this.mapping.maps.length;c++){let d=this.mapping.maps[c];c&&(a=d.map(a,1),b=d.map(b,-1)),d.forEach((c,d,e,f)=>{a=Math.min(a,e),b=Math.max(b,f)})}return 1e9==a?null:{from:a,to:b}}addStep(a,b){this.docs.push(this.doc),this.steps.push(a),this.mapping.appendMap(a.getMap()),this.doc=b}replace(a,b=a,c=J.empty){let d=aY(this.doc,a,b,c);return d&&this.step(d),this}replaceWith(a,b,c){return this.replace(a,b,new J(D.from(c),0,0))}delete(a,b){return this.replace(a,b,J.empty)}insert(a,b){return this.replaceWith(a,a,b)}replaceRange(a,b,c){return!function(a,b,c,d){if(!d.size)return a.deleteRange(b,c);let e=a.doc.resolve(b),f=a.doc.resolve(c);if(aZ(e,f,d))return a.step(new aK(b,c,d));let g=a3(e,f);0==g[g.length-1]&&g.pop();let h=-(e.depth+1);g.unshift(h);for(let a=e.depth,b=e.pos-1;a>0;a--,b--){let c=e.node(a).type.spec;if(c.defining||c.definingAsContext||c.isolating)break;g.indexOf(a)>-1?h=a:e.before(a)==b&&g.splice(1,0,-a)}let i=g.indexOf(h),j=[],k=d.openStart;for(let a=d.content,b=0;;b++){let c=a.firstChild;if(j.push(c),b==d.openStart)break;a=c.content}for(let a=k-1;a>=0;a--){var l;let b=j[a],c=(l=b.type).spec.defining||l.spec.definingForContent;if(c&&!b.sameMarkup(e.node(Math.abs(h)-1)))k=a;else if(c||!b.type.isTextblock)break}for(let b=d.openStart;b>=0;b--){let h=(b+k+1)%(d.openStart+1),l=j[h];if(l)for(let b=0;b<g.length;b++){let j=g[(b+i)%g.length],k=!0;j<0&&(k=!1,j=-j);let m=e.node(j-1),n=e.index(j-1);if(m.canReplaceWith(n,n,l.type,l.marks))return a.replace(e.before(j),k?f.after(j):c,new J(function a(b,c,d,e,f){if(c<d){let f=b.firstChild;b=b.replaceChild(0,f.copy(a(f.content,c+1,d,e,f)))}if(c>e){let a=f.contentMatchAt(0),c=a.fillBefore(b).append(b);b=c.append(a.matchFragment(c).fillBefore(D.empty,!0))}return b}(d.content,0,d.openStart,h),h,d.openEnd))}}let m=a.steps.length;for(let h=g.length-1;h>=0&&(a.replace(b,c,d),!(a.steps.length>m));h--){let a=g[h];a<0||(b=e.before(a),c=f.after(a))}}(this,a,b,c),this}replaceRangeWith(a,b,c){var d=a,e=b;if(!c.isInline&&d==e&&this.doc.resolve(d).parent.content.size){let a=function(a,b,c){let d=a.resolve(b);if(d.parent.canReplaceWith(d.index(),d.index(),c))return b;if(0==d.parentOffset)for(let a=d.depth-1;a>=0;a--){let b=d.index(a);if(d.node(a).canReplaceWith(b,b,c))return d.before(a+1);if(b>0)return null}if(d.parentOffset==d.parent.content.size)for(let a=d.depth-1;a>=0;a--){let b=d.indexAfter(a);if(d.node(a).canReplaceWith(b,b,c))return d.after(a+1);if(b<d.node(a).childCount)break}return null}(this.doc,d,c.type);null!=a&&(d=e=a)}return this.replaceRange(d,e,new J(D.from(c),0,0)),this}deleteRange(a,b){return!function(a,b,c){let d=a.doc.resolve(b),e=a.doc.resolve(c),f=a3(d,e);for(let b=0;b<f.length;b++){let c=f[b],g=b==f.length-1;if(g&&0==c||d.node(c).type.contentMatch.validEnd)return a.delete(d.start(c),e.end(c));if(c>0&&(g||d.node(c-1).canReplace(d.index(c-1),e.indexAfter(c-1))))return a.delete(d.before(c),e.after(c))}for(let f=1;f<=d.depth&&f<=e.depth;f++)if(b-d.start(f)==d.depth-f&&c>d.end(f)&&e.end(f)-c!=e.depth-f&&d.start(f-1)==e.start(f-1)&&d.node(f-1).canReplace(d.index(f-1),e.index(f-1)))return a.delete(d.before(f),c);a.delete(b,c)}(this,a,b),this}lift(a,b){return!function(a,b,c){let{$from:d,$to:e,depth:f}=b,g=d.before(f+1),h=e.after(f+1),i=g,j=h,k=D.empty,l=0;for(let a=f,b=!1;a>c;a--)b||d.index(a)>0?(b=!0,k=D.from(d.node(a).copy(k)),l++):i--;let m=D.empty,n=0;for(let a=f,b=!1;a>c;a--)b||e.after(a+1)<e.end(a)?(b=!0,m=D.from(e.node(a).copy(m)),n++):j++;a.step(new aL(i,j,g,h,new J(k.append(m),l,n),k.size-l,!0))}(this,a,b),this}join(a,b=1){return!function(a,b,c){let d=null,{linebreakReplacement:e}=a.doc.type.schema,f=a.doc.resolve(b-c),g=f.node().type;if(e&&g.inlineContent){let a="pre"==g.whitespace,b=!!g.contentMatch.matchType(e);a&&!b?d=!1:!a&&b&&(d=!0)}let h=a.steps.length;if(!1===d){let d=a.doc.resolve(b+c);aS(a,d.node(),d.before(),h)}g.inlineContent&&aN(a,b+c-1,g,f.node().contentMatchAt(f.index()),null==d);let i=a.mapping.slice(h),j=i.map(b-c);if(a.step(new aK(j,i.map(b+c,-1),J.empty,!0)),!0===d){let b=a.doc.resolve(j);aR(a,b.node(),b.before(),a.steps.length)}}(this,a,b),this}wrap(a,b){return!function(a,b,c){let d=D.empty;for(let a=c.length-1;a>=0;a--){if(d.size){let b=c[a].type.contentMatch.matchFragment(d);if(!b||!b.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}d=D.from(c[a].type.create(c[a].attrs,d))}let e=b.start,f=b.end;a.step(new aL(e,f,e,f,new J(d,0,0),c.length,!0))}(this,a,b),this}setBlockType(a,b=a,c,d=null){var e=this;if(!c.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let f=e.steps.length;return e.doc.nodesBetween(a,b,(a,b)=>{var g,h,i;let j,k,l="function"==typeof d?d(a):d;if(a.isTextblock&&!a.hasMarkup(c,l)&&(g=e.doc,h=e.mapping.slice(f).map(b),i=c,k=(j=g.resolve(h)).index(),j.parent.canReplaceWith(k,k+1,i))){let d=null;if(c.schema.linebreakReplacement){let a="pre"==c.whitespace,b=!!c.contentMatch.matchType(c.schema.linebreakReplacement);a&&!b?d=!1:!a&&b&&(d=!0)}!1===d&&aS(e,a,b,f),aN(e,e.mapping.slice(f).map(b,1),c,void 0,null===d);let g=e.mapping.slice(f),h=g.map(b,1),i=g.map(b+a.nodeSize,1);return e.step(new aL(h,i,h+1,i-1,new J(D.from(c.create(l,null,a.marks)),0,0),1,!0)),!0===d&&aR(e,a,b,f),!1}}),this}setNodeMarkup(a,b,c=null,d){return!function(a,b,c,d,e){let f=a.doc.nodeAt(b);if(!f)throw RangeError("No node at given position");c||(c=f.type);let g=c.create(d,null,e||f.marks);if(f.isLeaf)return a.replaceWith(b,b+f.nodeSize,g);if(!c.validContent(f.content))throw RangeError("Invalid content for node type "+c.name);a.step(new aL(b,b+f.nodeSize,b+1,b+f.nodeSize-1,new J(D.from(g),0,0),1,!0))}(this,a,b,c,d),this}setNodeAttribute(a,b,c){return this.step(new a4(a,b,c)),this}setDocAttribute(a,b){return this.step(new a5(a,b)),this}addNodeMark(a,b){return this.step(new aI(a,b)),this}removeNodeMark(a,b){let c=this.doc.nodeAt(a);if(!c)throw RangeError("No node at position "+a);if(b instanceof H)b.isInSet(c.marks)&&this.step(new aJ(a,b));else{let d=c.marks,e,f=[];for(;e=b.isInSet(d);)f.push(new aJ(a,e)),d=e.removeFromSet(d);for(let a=f.length-1;a>=0;a--)this.step(f[a])}return this}split(a,b=1,c){return!function(a,b,c=1,d){let e=a.doc.resolve(b),f=D.empty,g=D.empty;for(let a=e.depth,b=e.depth-c,h=c-1;a>b;a--,h--){f=D.from(e.node(a).copy(f));let b=d&&d[h];g=D.from(b?b.type.create(b.attrs,g):e.node(a).copy(g))}a.step(new aK(b,b,new J(f.append(g),c,c),!0))}(this,a,b,c),this}addMark(a,b,c){var d;let e,f,g,h;return d=this,g=[],h=[],d.doc.nodesBetween(a,b,(d,i,j)=>{if(!d.isInline)return;let k=d.marks;if(!c.isInSet(k)&&j.type.allowsMarkType(c.type)){let j=Math.max(i,a),l=Math.min(i+d.nodeSize,b),m=c.addToSet(k);for(let a=0;a<k.length;a++)k[a].isInSet(m)||(e&&e.to==j&&e.mark.eq(k[a])?e.to=l:g.push(e=new aH(j,l,k[a])));f&&f.to==j?f.to=l:h.push(f=new aG(j,l,c))}}),g.forEach(a=>d.step(a)),h.forEach(a=>d.step(a)),this}removeMark(a,b,c){var d;let e,f;return d=this,e=[],f=0,d.doc.nodesBetween(a,b,(d,g)=>{if(!d.isInline)return;f++;let h=null;if(c instanceof ai){let a=d.marks,b;for(;b=c.isInSet(a);)(h||(h=[])).push(b),a=b.removeFromSet(a)}else c?c.isInSet(d.marks)&&(h=[c]):h=d.marks;if(h&&h.length){let c=Math.min(g+d.nodeSize,b);for(let b=0;b<h.length;b++){let d=h[b],i;for(let a=0;a<e.length;a++){let b=e[a];b.step==f-1&&d.eq(e[a].style)&&(i=b)}i?(i.to=c,i.step=f):e.push({style:d,from:Math.max(g,a),to:c,step:f})}}}),e.forEach(a=>d.step(new aH(a.from,a.to,a.style))),this}clearIncompatible(a,b,c){return aN(this,a,b,c),this}}let a8=Object.create(null);class a9{constructor(a,b,c){this.$anchor=a,this.$head=b,this.ranges=c||[new ba(a.min(b),a.max(b))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let a=this.ranges;for(let b=0;b<a.length;b++)if(a[b].$from.pos!=a[b].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(a,b=J.empty){let c=b.content.lastChild,d=null;for(let a=0;a<b.openEnd;a++)d=c,c=c.lastChild;let e=a.steps.length,f=this.ranges;for(let g=0;g<f.length;g++){let{$from:h,$to:i}=f[g],j=a.mapping.slice(e);a.replaceRange(j.map(h.pos),j.map(i.pos),g?J.empty:b),0==g&&bk(a,e,(c?c.isInline:d&&d.isTextblock)?-1:1)}}replaceWith(a,b){let c=a.steps.length,d=this.ranges;for(let e=0;e<d.length;e++){let{$from:f,$to:g}=d[e],h=a.mapping.slice(c),i=h.map(f.pos),j=h.map(g.pos);e?a.deleteRange(i,j):(a.replaceRangeWith(i,j,b),bk(a,c,b.isInline?-1:1))}}static findFrom(a,b,c=!1){let d=a.parent.inlineContent?new bd(a):bj(a.node(0),a.parent,a.pos,a.index(),b,c);if(d)return d;for(let d=a.depth-1;d>=0;d--){let e=b<0?bj(a.node(0),a.node(d),a.before(d+1),a.index(d),b,c):bj(a.node(0),a.node(d),a.after(d+1),a.index(d)+1,b,c);if(e)return e}return null}static near(a,b=1){return this.findFrom(a,b)||this.findFrom(a,-b)||new bh(a.node(0))}static atStart(a){return bj(a,a,0,0,1)||new bh(a)}static atEnd(a){return bj(a,a,a.content.size,a.childCount,-1)||new bh(a)}static fromJSON(a,b){if(!b||!b.type)throw RangeError("Invalid input for Selection.fromJSON");let c=a8[b.type];if(!c)throw RangeError(`No selection type ${b.type} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in a8)throw RangeError("Duplicate use of selection JSON ID "+a);return a8[a]=b,b.prototype.jsonID=a,b}getBookmark(){return bd.between(this.$anchor,this.$head).getBookmark()}}a9.prototype.visible=!0;class ba{constructor(a,b){this.$from=a,this.$to=b}}let bb=!1;function bc(a){bb||a.parent.inlineContent||(bb=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+a.parent.type.name+")"))}class bd extends a9{constructor(a,b=a){bc(a),bc(b),super(a,b)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(a,b){let c=a.resolve(b.map(this.head));if(!c.parent.inlineContent)return a9.near(c);let d=a.resolve(b.map(this.anchor));return new bd(d.parent.inlineContent?d:c,c)}replace(a,b=J.empty){if(super.replace(a,b),b==J.empty){let b=this.$from.marksAcross(this.$to);b&&a.ensureMarks(b)}}eq(a){return a instanceof bd&&a.anchor==this.anchor&&a.head==this.head}getBookmark(){return new be(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(a,b){if("number"!=typeof b.anchor||"number"!=typeof b.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new bd(a.resolve(b.anchor),a.resolve(b.head))}static create(a,b,c=b){let d=a.resolve(b);return new this(d,c==b?d:a.resolve(c))}static between(a,b,c){let d=a.pos-b.pos;if((!c||d)&&(c=d>=0?1:-1),!b.parent.inlineContent){let a=a9.findFrom(b,c,!0)||a9.findFrom(b,-c,!0);if(!a)return a9.near(b,c);b=a.$head}return a.parent.inlineContent||(0==d?a=b:(a=(a9.findFrom(a,-c,!0)||a9.findFrom(a,c,!0)).$anchor).pos<b.pos!=d<0&&(a=b)),new bd(a,b)}}a9.jsonID("text",bd);class be{constructor(a,b){this.anchor=a,this.head=b}map(a){return new be(a.map(this.anchor),a.map(this.head))}resolve(a){return bd.between(a.resolve(this.anchor),a.resolve(this.head))}}class bf extends a9{constructor(a){let b=a.nodeAfter,c=a.node(0).resolve(a.pos+b.nodeSize);super(a,c),this.node=b}map(a,b){let{deleted:c,pos:d}=b.mapResult(this.anchor),e=a.resolve(d);return c?a9.near(e):new bf(e)}content(){return new J(D.from(this.node),0,0)}eq(a){return a instanceof bf&&a.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bg(this.anchor)}static fromJSON(a,b){if("number"!=typeof b.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new bf(a.resolve(b.anchor))}static create(a,b){return new bf(a.resolve(b))}static isSelectable(a){return!a.isText&&!1!==a.type.spec.selectable}}bf.prototype.visible=!1,a9.jsonID("node",bf);class bg{constructor(a){this.anchor=a}map(a){let{deleted:b,pos:c}=a.mapResult(this.anchor);return b?new be(c,c):new bg(c)}resolve(a){let b=a.resolve(this.anchor),c=b.nodeAfter;return c&&bf.isSelectable(c)?new bf(b):a9.near(b)}}class bh extends a9{constructor(a){super(a.resolve(0),a.resolve(a.content.size))}replace(a,b=J.empty){if(b==J.empty){a.delete(0,a.doc.content.size);let b=a9.atStart(a.doc);b.eq(a.selection)||a.setSelection(b)}else super.replace(a,b)}toJSON(){return{type:"all"}}static fromJSON(a){return new bh(a)}map(a){return new bh(a)}eq(a){return a instanceof bh}getBookmark(){return bi}}a9.jsonID("all",bh);let bi={map(){return this},resolve:a=>new bh(a)};function bj(a,b,c,d,e,f=!1){if(b.inlineContent)return bd.create(a,c);for(let g=d-(e>0?0:1);e>0?g<b.childCount:g>=0;g+=e){let d=b.child(g);if(d.isAtom){if(!f&&bf.isSelectable(d))return bf.create(a,c-(e<0?d.nodeSize:0))}else{let b=bj(a,d,c+e,e<0?d.childCount:0,e,f);if(b)return b}c+=d.nodeSize*e}return null}function bk(a,b,c){let d,e=a.steps.length-1;if(e<b)return;let f=a.steps[e];(f instanceof aK||f instanceof aL)&&(a.mapping.maps[e].forEach((a,b,c,e)=>{null==d&&(d=e)}),a.setSelection(a9.near(a.doc.resolve(d),c)))}class bl extends a7{constructor(a){super(a.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=a.selection,this.storedMarks=a.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(a){if(a.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=a,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(a){return this.storedMarks=a,this.updated|=2,this}ensureMarks(a){return H.sameSet(this.storedMarks||this.selection.$from.marks(),a)||this.setStoredMarks(a),this}addStoredMark(a){return this.ensureMarks(a.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(a){return this.ensureMarks(a.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(a,b){super.addStep(a,b),this.updated=-3&this.updated,this.storedMarks=null}setTime(a){return this.time=a,this}replaceSelection(a){return this.selection.replace(this,a),this}replaceSelectionWith(a,b=!0){let c=this.selection;return b&&(a=a.mark(this.storedMarks||(c.empty?c.$from.marks():c.$from.marksAcross(c.$to)||H.none))),c.replaceWith(this,a),this}deleteSelection(){return this.selection.replace(this),this}insertText(a,b,c){let d=this.doc.type.schema;if(null==b)return a?this.replaceSelectionWith(d.text(a),!0):this.deleteSelection();{if(null==c&&(c=b),!a)return this.deleteRange(b,c);let e=this.storedMarks;if(!e){let a=this.doc.resolve(b);e=c==b?a.marks():a.marksAcross(this.doc.resolve(c))}return this.replaceRangeWith(b,c,d.text(a,e)),this.selection.empty||this.selection.to!=b+a.length||this.setSelection(a9.near(this.selection.$to)),this}}setMeta(a,b){return this.meta["string"==typeof a?a:a.key]=b,this}getMeta(a){return this.meta["string"==typeof a?a:a.key]}get isGeneric(){for(let a in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function bm(a,b){return b&&a?a.bind(b):a}class bn{constructor(a,b,c){this.name=a,this.init=bm(b.init,c),this.apply=bm(b.apply,c)}}let bo=[new bn("doc",{init:a=>a.doc||a.schema.topNodeType.createAndFill(),apply:a=>a.doc}),new bn("selection",{init:(a,b)=>a.selection||a9.atStart(b.doc),apply:a=>a.selection}),new bn("storedMarks",{init:a=>a.storedMarks||null,apply:(a,b,c,d)=>d.selection.$cursor?a.storedMarks:null}),new bn("scrollToSelection",{init:()=>0,apply:(a,b)=>a.scrolledIntoView?b+1:b})];class bp{constructor(a,b){this.schema=a,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bo.slice(),b&&b.forEach(a=>{if(this.pluginsByKey[a.key])throw RangeError("Adding different instances of a keyed plugin ("+a.key+")");this.plugins.push(a),this.pluginsByKey[a.key]=a,a.spec.state&&this.fields.push(new bn(a.key,a.spec.state,a))})}}class bq{constructor(a){this.config=a}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(a){return this.applyTransaction(a).state}filterTransaction(a,b=-1){for(let c=0;c<this.config.plugins.length;c++)if(c!=b){let b=this.config.plugins[c];if(b.spec.filterTransaction&&!b.spec.filterTransaction.call(b,a,this))return!1}return!0}applyTransaction(a){if(!this.filterTransaction(a))return{state:this,transactions:[]};let b=[a],c=this.applyInner(a),d=null;for(;;){let e=!1;for(let f=0;f<this.config.plugins.length;f++){let g=this.config.plugins[f];if(g.spec.appendTransaction){let h=d?d[f].n:0,i=d?d[f].state:this,j=h<b.length&&g.spec.appendTransaction.call(g,h?b.slice(h):b,i,c);if(j&&c.filterTransaction(j,f)){if(j.setMeta("appendedTransaction",a),!d){d=[];for(let a=0;a<this.config.plugins.length;a++)d.push(a<f?{state:c,n:b.length}:{state:this,n:0})}b.push(j),c=c.applyInner(j),e=!0}d&&(d[f]={state:c,n:b.length})}}if(!e)return{state:c,transactions:b}}}applyInner(a){if(!a.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let b=new bq(this.config),c=this.config.fields;for(let d=0;d<c.length;d++){let e=c[d];b[e.name]=e.apply(a,this[e.name],this,b)}return b}get tr(){return new bl(this)}static create(a){let b=new bp(a.doc?a.doc.type.schema:a.schema,a.plugins),c=new bq(b);for(let d=0;d<b.fields.length;d++)c[b.fields[d].name]=b.fields[d].init(a,c);return c}reconfigure(a){let b=new bp(this.schema,a.plugins),c=b.fields,d=new bq(b);for(let b=0;b<c.length;b++){let e=c[b].name;d[e]=this.hasOwnProperty(e)?this[e]:c[b].init(a,d)}return d}toJSON(a){let b={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(b.storedMarks=this.storedMarks.map(a=>a.toJSON())),a&&"object"==typeof a)for(let c in a){if("doc"==c||"selection"==c)throw RangeError("The JSON fields `doc` and `selection` are reserved");let d=a[c],e=d.spec.state;e&&e.toJSON&&(b[c]=e.toJSON.call(d,this[d.key]))}return b}static fromJSON(a,b,c){if(!b)throw RangeError("Invalid input for EditorState.fromJSON");if(!a.schema)throw RangeError("Required config field 'schema' missing");let d=new bp(a.schema,a.plugins),e=new bq(d);return d.fields.forEach(d=>{if("doc"==d.name)e.doc=W.fromJSON(a.schema,b.doc);else if("selection"==d.name)e.selection=a9.fromJSON(e.doc,b.selection);else if("storedMarks"==d.name)b.storedMarks&&(e.storedMarks=b.storedMarks.map(a.schema.markFromJSON));else{if(c)for(let f in c){let g=c[f],h=g.spec.state;if(g.key==d.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(b,f)){e[d.name]=h.fromJSON.call(g,a,b[f],e);return}}e[d.name]=d.init(a,e)}}),e}}class br{constructor(a){this.spec=a,this.props={},a.props&&function a(b,c,d){for(let e in b){let f=b[e];f instanceof Function?f=f.bind(c):"handleDOMEvents"==e&&(f=a(f,c,{})),d[e]=f}return d}(a.props,this,this.props),this.key=a.key?a.key.key:bt("plugin")}getState(a){return a[this.key]}}let bs=Object.create(null);function bt(a){return a in bs?a+"$"+ ++bs[a]:(bs[a]=0,a+"$")}class bu{constructor(a="key"){this.key=bt(a)}get(a){return a.config.pluginsByKey[this.key]}getState(a){return a[this.key]}}let bv=(a,b)=>!a.selection.empty&&(b&&b(a.tr.deleteSelection().scrollIntoView()),!0);function bw(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("backward",a):!(c.parentOffset>0))?c:null}let bx=(a,b,c)=>{let d=bw(a,c);if(!d)return!1;let e=bB(d);if(!e){let c=d.blockRange(),e=c&&aO(c);return null!=e&&(b&&b(a.tr.lift(c,e).scrollIntoView()),!0)}let f=e.nodeBefore;if(bL(a,e,b,-1))return!0;if(0==d.parent.content.size&&(bz(f,"end")||bf.isSelectable(f)))for(let c=d.depth;;c--){let g=aY(a.doc,d.before(c),d.after(c),J.empty);if(g&&g.slice.size<g.to-g.from){if(b){let c=a.tr.step(g);c.setSelection(bz(f,"end")?a9.findFrom(c.doc.resolve(c.mapping.map(e.pos,-1)),-1):bf.create(c.doc,e.pos-f.nodeSize)),b(c.scrollIntoView())}return!0}if(1==c||d.node(c-1).childCount>1)break}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos-f.nodeSize,e.pos).scrollIntoView()),!0)};function by(a,b,c){let d=b.nodeBefore,e=b.pos-1;for(;!d.isTextblock;e--){if(d.type.spec.isolating)return!1;let a=d.lastChild;if(!a)return!1;d=a}let f=b.nodeAfter,g=b.pos+1;for(;!f.isTextblock;g++){if(f.type.spec.isolating)return!1;let a=f.firstChild;if(!a)return!1;f=a}let h=aY(a.doc,e,g,J.empty);if(!h||h.from!=e||h instanceof aK&&h.slice.size>=g-e)return!1;if(c){let b=a.tr.step(h);b.setSelection(bd.create(b.doc,e)),c(b.scrollIntoView())}return!0}function bz(a,b,c=!1){for(let d=a;d;d="start"==b?d.firstChild:d.lastChild){if(d.isTextblock)return!0;if(c&&1!=d.childCount)break}return!1}let bA=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("backward",a):d.parentOffset>0)return!1;f=bB(d)}let g=f&&f.nodeBefore;return!!g&&!!bf.isSelectable(g)&&(b&&b(a.tr.setSelection(bf.create(a.doc,f.pos-g.nodeSize)).scrollIntoView()),!0)};function bB(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){if(a.index(b)>0)return a.doc.resolve(a.before(b+1));if(a.node(b).type.spec.isolating)break}return null}function bC(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("forward",a):!(c.parentOffset<c.parent.content.size))?c:null}let bD=(a,b,c)=>{let d=bC(a,c);if(!d)return!1;let e=bF(d);if(!e)return!1;let f=e.nodeAfter;if(bL(a,e,b,1))return!0;if(0==d.parent.content.size&&(bz(f,"start")||bf.isSelectable(f))){let c=aY(a.doc,d.before(),d.after(),J.empty);if(c&&c.slice.size<c.to-c.from){if(b){let d=a.tr.step(c);d.setSelection(bz(f,"start")?a9.findFrom(d.doc.resolve(d.mapping.map(e.pos)),1):bf.create(d.doc,d.mapping.map(e.pos))),b(d.scrollIntoView())}return!0}}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos,e.pos+f.nodeSize).scrollIntoView()),!0)},bE=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("forward",a):d.parentOffset<d.parent.content.size)return!1;f=bF(d)}let g=f&&f.nodeAfter;return!!g&&!!bf.isSelectable(g)&&(b&&b(a.tr.setSelection(bf.create(a.doc,f.pos)).scrollIntoView()),!0)};function bF(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){let c=a.node(b);if(a.index(b)+1<c.childCount)return a.doc.resolve(a.after(b+1));if(c.type.spec.isolating)break}return null}let bG=(a,b)=>{let{$head:c,$anchor:d}=a.selection;return!!c.parent.type.spec.code&&!!c.sameParent(d)&&(b&&b(a.tr.insertText("\n").scrollIntoView()),!0)};function bH(a){for(let b=0;b<a.edgeCount;b++){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}let bI=(a,b)=>{let{$head:c,$anchor:d}=a.selection;if(!c.parent.type.spec.code||!c.sameParent(d))return!1;let e=c.node(-1),f=c.indexAfter(-1),g=bH(e.contentMatchAt(f));if(!g||!e.canReplaceWith(f,f,g))return!1;if(b){let d=c.after(),e=a.tr.replaceWith(d,d,g.createAndFill());e.setSelection(a9.near(e.doc.resolve(d),1)),b(e.scrollIntoView())}return!0},bJ=(a,b)=>{let c=a.selection,{$from:d,$to:e}=c;if(c instanceof bh||d.parent.inlineContent||e.parent.inlineContent)return!1;let f=bH(e.parent.contentMatchAt(e.indexAfter()));if(!f||!f.isTextblock)return!1;if(b){let c=(!d.parentOffset&&e.index()<e.parent.childCount?d:e).pos,g=a.tr.insert(c,f.createAndFill());g.setSelection(bd.create(g.doc,c+1)),b(g.scrollIntoView())}return!0},bK=(a,b)=>{let{$cursor:c}=a.selection;if(!c||c.parent.content.size)return!1;if(c.depth>1&&c.after()!=c.end(-1)){let d=c.before();if(aT(a.doc,d))return b&&b(a.tr.split(d).scrollIntoView()),!0}let d=c.blockRange(),e=d&&aO(d);return null!=e&&(b&&b(a.tr.lift(d,e).scrollIntoView()),!0)};function bL(a,b,c,d){let e,f,g,h=b.nodeBefore,i=b.nodeAfter,j,k,l=h.type.spec.isolating||i.type.spec.isolating;if(!l&&(e=b.nodeBefore,f=b.nodeAfter,g=b.index(),e&&f&&e.type.compatibleContent(f.type)&&(!e.content.size&&b.parent.canReplace(g-1,g)?(c&&c(a.tr.delete(b.pos-e.nodeSize,b.pos).scrollIntoView()),!0):!!b.parent.canReplace(g,g+1)&&!!(f.isTextblock||aU(a.doc,b.pos))&&(c&&c(a.tr.join(b.pos).scrollIntoView()),!0))))return!0;let m=!l&&b.parent.canReplace(b.index(),b.index()+1);if(m&&(j=(k=h.contentMatchAt(h.childCount)).findWrapping(i.type))&&k.matchType(j[0]||i.type).validEnd){if(c){let d=b.pos+i.nodeSize,e=D.empty;for(let a=j.length-1;a>=0;a--)e=D.from(j[a].create(null,e));e=D.from(h.copy(e));let f=a.tr.step(new aL(b.pos-1,d,b.pos,d,new J(e,1,0),j.length,!0)),g=f.doc.resolve(d+2*j.length);g.nodeAfter&&g.nodeAfter.type==h.type&&aU(f.doc,g.pos)&&f.join(g.pos),c(f.scrollIntoView())}return!0}let n=i.type.spec.isolating||d>0&&l?null:a9.findFrom(b,1),o=n&&n.$from.blockRange(n.$to),p=o&&aO(o);if(null!=p&&p>=b.depth)return c&&c(a.tr.lift(o,p).scrollIntoView()),!0;if(m&&bz(i,"start",!0)&&bz(h,"end")){let d=h,e=[];for(;e.push(d),!d.isTextblock;)d=d.lastChild;let f=i,g=1;for(;!f.isTextblock;f=f.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,f.content)){if(c){let d=D.empty;for(let a=e.length-1;a>=0;a--)d=D.from(e[a].copy(d));c(a.tr.step(new aL(b.pos-e.length,b.pos+i.nodeSize,b.pos+g,b.pos+i.nodeSize-g,new J(d,e.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function bM(a){return function(b,c){let d=b.selection,e=a<0?d.$from:d.$to,f=e.depth;for(;e.node(f).isInline;){if(!f)return!1;f--}return!!e.node(f).isTextblock&&(c&&c(b.tr.setSelection(bd.create(b.doc,a<0?e.start(f):e.end(f)))),!0)}}let bN=bM(-1),bO=bM(1);function bP(a,b=null){return function(c,d){let e=!1;for(let d=0;d<c.selection.ranges.length&&!e;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];c.doc.nodesBetween(f,g,(d,f)=>{if(e)return!1;if(!(!d.isTextblock||d.hasMarkup(a,b)))if(d.type==a)e=!0;else{let b=c.doc.resolve(f),d=b.index();e=b.parent.canReplaceWith(d,d+1,a)}})}if(!e)return!1;if(d){let e=c.tr;for(let d=0;d<c.selection.ranges.length;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];e.setBlockType(f,g,a,b)}d(e.scrollIntoView())}return!0}}function bQ(...a){return function(b,c,d){for(let e=0;e<a.length;e++)if(a[e](b,c,d))return!0;return!1}}let bR=bQ(bv,bx,bA),bS=bQ(bv,bD,bE),bT={Enter:bQ(bG,bJ,bK,(a,b)=>{let{$from:c,$to:d}=a.selection;if(a.selection instanceof bf&&a.selection.node.isBlock)return!!c.parentOffset&&!!aT(a.doc,c.pos)&&(b&&b(a.tr.split(c.pos).scrollIntoView()),!0);if(!c.depth)return!1;let e=[],f,g,h=!1,i=!1;for(let a=c.depth;;a--){if(c.node(a).isBlock){let b;h=c.end(a)==c.pos+(c.depth-a),i=c.start(a)==c.pos-(c.depth-a),g=bH(c.node(a-1).contentMatchAt(c.indexAfter(a-1)));e.unshift(b||(h&&g?{type:g}:null)),f=a;break}if(1==a)return!1;e.unshift(null)}let j=a.tr;(a.selection instanceof bd||a.selection instanceof bh)&&j.deleteSelection();let k=j.mapping.map(c.pos),l=aT(j.doc,k,e.length,e);if(l||(e[0]=g?{type:g}:null,l=aT(j.doc,k,e.length,e)),!l)return!1;if(j.split(k,e.length,e),!h&&i&&c.node(f).type!=g){let a=j.mapping.map(c.before(f)),b=j.doc.resolve(a);g&&c.node(f-1).canReplaceWith(b.index(),b.index()+1,g)&&j.setNodeMarkup(j.mapping.map(c.before(f)),g)}return b&&b(j.scrollIntoView()),!0}),"Mod-Enter":bI,Backspace:bR,"Mod-Backspace":bR,"Shift-Backspace":bR,Delete:bS,"Mod-Delete":bS,"Mod-a":(a,b)=>(b&&b(a.tr.setSelection(new bh(a.doc))),!0)},bU={"Ctrl-h":bT.Backspace,"Alt-Backspace":bT["Mod-Backspace"],"Ctrl-d":bT.Delete,"Ctrl-Alt-Backspace":bT["Mod-Delete"],"Alt-Delete":bT["Mod-Delete"],"Alt-d":bT["Mod-Delete"],"Ctrl-a":bN,"Ctrl-e":bO};for(let a in bT)bU[a]=bT[a];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();let bV=function(a){for(var b=0;;b++)if(!(a=a.previousSibling))return b},bW=function(a){let b=a.assignedSlot||a.parentNode;return b&&11==b.nodeType?b.host:b},bX=null,bY=function(a,b,c){let d=bX||(bX=document.createRange());return d.setEnd(a,null==c?a.nodeValue.length:c),d.setStart(a,b||0),d},bZ=function(){bX=null},b$=function(a,b,c,d){return c&&(b0(a,b,c,d,-1)||b0(a,b,c,d,1))},b_=/^(img|br|input|textarea|hr)$/i;function b0(a,b,c,d,e){for(var f;;){if(a==c&&b==d)return!0;if(b==(e<0?0:b1(a))){let c=a.parentNode;if(!c||1!=c.nodeType||b2(a)||b_.test(a.nodeName)||"false"==a.contentEditable)return!1;b=bV(a)+(e<0?0:1),a=c}else{if(1!=a.nodeType)return!1;let c=a.childNodes[b+(e<0?-1:0)];if(1==c.nodeType&&"false"==c.contentEditable)if(null==(f=c.pmViewDesc)||!f.ignoreForSelection)return!1;else b+=e;else a=c,b=e<0?b1(a):0}}}function b1(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function b2(a){let b;for(let c=a;c&&!(b=c.pmViewDesc);c=c.parentNode);return b&&b.node&&b.node.isBlock&&(b.dom==a||b.contentDOM==a)}let b3=function(a){return a.focusNode&&b$(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset)};function b4(a,b){let c=document.createEvent("Event");return c.initEvent("keydown",!0,!0),c.keyCode=a,c.key=c.code=b,c}let b5="u">typeof navigator?navigator:null,b6="u">typeof document?document:null,b7=b5&&b5.userAgent||"",b8=/Edge\/(\d+)/.exec(b7),b9=/MSIE \d/.exec(b7),ca=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(b7),cb=!!(b9||ca||b8),cc=b9?document.documentMode:ca?+ca[1]:b8?+b8[1]:0,cd=!cb&&/gecko\/(\d+)/i.test(b7);cd&&(/Firefox\/(\d+)/.exec(b7)||[0,0])[1];let ce=!cb&&/Chrome\/(\d+)/.exec(b7),cf=!!ce,cg=ce?+ce[1]:0,ch=!cb&&!!b5&&/Apple Computer/.test(b5.vendor),ci=ch&&(/Mobile\/\w+/.test(b7)||!!b5&&b5.maxTouchPoints>2),cj=ci||!!b5&&/Mac/.test(b5.platform),ck=!!b5&&/Win/.test(b5.platform),cl=/Android \d/.test(b7),cm=!!b6&&"webkitFontSmoothing"in b6.documentElement.style,cn=cm?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function co(a,b){return"number"==typeof a?a:a[b]}function cp(a,b,c){let d=a.someProp("scrollThreshold")||0,e=a.someProp("scrollMargin")||5,f=a.dom.ownerDocument;for(let g=c||a.dom;g;){if(1!=g.nodeType){g=bW(g);continue}let a=g,c=a==f.body,h=c?function(a){let b=a.defaultView&&a.defaultView.visualViewport;return b?{left:0,right:b.width,top:0,bottom:b.height}:{left:0,right:a.documentElement.clientWidth,top:0,bottom:a.documentElement.clientHeight}}(f):function(a){let b=a.getBoundingClientRect(),c=b.width/a.offsetWidth||1,d=b.height/a.offsetHeight||1;return{left:b.left,right:b.left+a.clientWidth*c,top:b.top,bottom:b.top+a.clientHeight*d}}(a),i=0,j=0;if(b.top<h.top+co(d,"top")?j=-(h.top-b.top+co(e,"top")):b.bottom>h.bottom-co(d,"bottom")&&(j=b.bottom-b.top>h.bottom-h.top?b.top+co(e,"top")-h.top:b.bottom-h.bottom+co(e,"bottom")),b.left<h.left+co(d,"left")?i=-(h.left-b.left+co(e,"left")):b.right>h.right-co(d,"right")&&(i=b.right-h.right+co(e,"right")),i||j)if(c)f.defaultView.scrollBy(i,j);else{let c=a.scrollLeft,d=a.scrollTop;j&&(a.scrollTop+=j),i&&(a.scrollLeft+=i);let e=a.scrollLeft-c,f=a.scrollTop-d;b={left:b.left-e,top:b.top-f,right:b.right-e,bottom:b.bottom-f}}let k=c?"fixed":getComputedStyle(g).position;if(/^(fixed|sticky)$/.test(k))break;g="absolute"==k?g.offsetParent:bW(g)}}function cq(a){let b=[],c=a.ownerDocument;for(let d=a;d&&(b.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),a!=c);d=bW(d));return b}function cr(a,b){for(let c=0;c<a.length;c++){let{dom:d,top:e,left:f}=a[c];d.scrollTop!=e+b&&(d.scrollTop=e+b),d.scrollLeft!=f&&(d.scrollLeft=f)}}let cs=null;function ct(a,b){return a.left>=b.left-1&&a.left<=b.right+1&&a.top>=b.top-1&&a.top<=b.bottom+1}function cu(a){return a.top<a.bottom||a.left<a.right}function cv(a,b){let c=a.getClientRects();if(c.length){let a=c[b<0?0:c.length-1];if(cu(a))return a}return Array.prototype.find.call(c,cu)||a.getBoundingClientRect()}let cw=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function cx(a,b,c){let{node:d,offset:e,atom:f}=a.docView.domFromPos(b,c<0?-1:1),g=cm||cd;if(3==d.nodeType)if(g&&(cw.test(d.nodeValue)||(c<0?!e:e==d.nodeValue.length))){let a=cv(bY(d,e,e),c);if(cd&&e&&/\s/.test(d.nodeValue[e-1])&&e<d.nodeValue.length){let b=cv(bY(d,e-1,e-1),-1);if(b.top==a.top){let c=cv(bY(d,e,e+1),-1);if(c.top!=a.top)return cy(c,c.left<b.left)}}return a}else{let a=e,b=e,f=c<0?1:-1;return c<0&&!e?(b++,f=-1):c>=0&&e==d.nodeValue.length?(a--,f=1):c<0?a--:b++,cy(cv(bY(d,a,b),f),f<0)}if(!a.state.doc.resolve(b-(f||0)).parent.inlineContent){if(null==f&&e&&(c<0||e==b1(d))){let a=d.childNodes[e-1];if(1==a.nodeType)return cz(a.getBoundingClientRect(),!1)}if(null==f&&e<b1(d)){let a=d.childNodes[e];if(1==a.nodeType)return cz(a.getBoundingClientRect(),!0)}return cz(d.getBoundingClientRect(),c>=0)}if(null==f&&e&&(c<0||e==b1(d))){let a=d.childNodes[e-1],b=3==a.nodeType?bY(a,b1(a)-!g):1!=a.nodeType||"BR"==a.nodeName&&a.nextSibling?null:a;if(b)return cy(cv(b,1),!1)}if(null==f&&e<b1(d)){let a=d.childNodes[e];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let b=a?3==a.nodeType?bY(a,0,+!g):1==a.nodeType?a:null:null;if(b)return cy(cv(b,-1),!0)}return cy(cv(3==d.nodeType?bY(d):d,-c),c>=0)}function cy(a,b){if(0==a.width)return a;let c=b?a.left:a.right;return{top:a.top,bottom:a.bottom,left:c,right:c}}function cz(a,b){if(0==a.height)return a;let c=b?a.top:a.bottom;return{top:c,bottom:c,left:a.left,right:a.right}}function cA(a,b,c){let d=a.state,e=a.root.activeElement;d!=b&&a.updateState(b),e!=a.dom&&a.focus();try{return c()}finally{d!=b&&a.updateState(d),e!=a.dom&&e&&e.focus()}}let cB=/[\u0590-\u08ac]/,cC=null,cD=null,cE=!1;class cF{constructor(a,b,c,d){this.parent=a,this.children=b,this.dom=c,this.contentDOM=d,this.dirty=0,c.pmViewDesc=this}matchesWidget(a){return!1}matchesMark(a){return!1}matchesNode(a,b,c){return!1}matchesHack(a){return!1}parseRule(){return null}stopEvent(a){return!1}get size(){let a=0;for(let b=0;b<this.children.length;b++)a+=this.children[b].size;return a}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let a=0;a<this.children.length;a++)this.children[a].destroy()}posBeforeChild(a){for(let b=0,c=this.posAtStart;;b++){let d=this.children[b];if(d==a)return c;c+=d.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(a,b,c){let d;if(this.contentDOM&&this.contentDOM.contains(1==a.nodeType?a:a.parentNode))if(c<0){let c,d;if(a==this.contentDOM)c=a.childNodes[b-1];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.previousSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.previousSibling;return c?this.posBeforeChild(d)+d.size:this.posAtStart}else{let c,d;if(a==this.contentDOM)c=a.childNodes[b];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.nextSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.nextSibling;return c?this.posBeforeChild(d):this.posAtEnd}if(a==this.dom&&this.contentDOM)d=b>bV(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))d=2&a.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==b)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!1;break}if(b.previousSibling)break}if(null==d&&b==a.childNodes.length)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!0;break}if(b.nextSibling)break}}return(null==d?c>0:d)?this.posAtEnd:this.posAtStart}nearestDesc(a,b=!1){for(let c=!0,d=a;d;d=d.parentNode){let e=this.getDesc(d),f;if(e&&(!b||e.node))if(!c||!(f=e.nodeDOM)||(1==f.nodeType?f.contains(1==a.nodeType?a:a.parentNode):f==a))return e;else c=!1}}getDesc(a){let b=a.pmViewDesc;for(let a=b;a;a=a.parent)if(a==this)return b}posFromDOM(a,b,c){for(let d=a;d;d=d.parentNode){let e=this.getDesc(d);if(e)return e.localPosFromDOM(a,b,c)}return -1}descAt(a){for(let b=0,c=0;b<this.children.length;b++){let d=this.children[b],e=c+d.size;if(c==a&&e!=c){for(;!d.border&&d.children.length;)for(let a=0;a<d.children.length;a++){let b=d.children[a];if(b.size){d=b;break}}return d}if(a<e)return d.descAt(a-c-d.border);c=e}}domFromPos(a,b){if(!this.contentDOM)return{node:this.dom,offset:0,atom:a+1};let c=0,d=0;for(let b=0;c<this.children.length;c++){let e=this.children[c],f=b+e.size;if(f>a||e instanceof cM){d=a-b;break}b=f}if(d)return this.children[c].domFromPos(d-this.children[c].border,b);for(let a;c&&!(a=this.children[c-1]).size&&a instanceof cG&&a.side>=0;c--);if(b<=0){let a,d=!0;for(;(a=c?this.children[c-1]:null)&&a.dom.parentNode!=this.contentDOM;c--,d=!1);return a&&b&&d&&!a.border&&!a.domAtom?a.domFromPos(a.size,b):{node:this.contentDOM,offset:a?bV(a.dom)+1:0}}{let a,d=!0;for(;(a=c<this.children.length?this.children[c]:null)&&a.dom.parentNode!=this.contentDOM;c++,d=!1);return a&&d&&!a.border&&!a.domAtom?a.domFromPos(0,b):{node:this.contentDOM,offset:a?bV(a.dom):this.contentDOM.childNodes.length}}}parseRange(a,b,c=0){if(0==this.children.length)return{node:this.contentDOM,from:a,to:b,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let d=-1,e=-1;for(let f=c,g=0;;g++){let c=this.children[g],h=f+c.size;if(-1==d&&a<=h){let e=f+c.border;if(a>=e&&b<=h-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(a,b,e);a=f;for(let b=g;b>0;b--){let c=this.children[b-1];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(1)){d=bV(c.dom)+1;break}a-=c.size}-1==d&&(d=0)}if(d>-1&&(h>b||g==this.children.length-1)){b=h;for(let a=g+1;a<this.children.length;a++){let c=this.children[a];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(-1)){e=bV(c.dom);break}b+=c.size}-1==e&&(e=this.contentDOM.childNodes.length);break}f=h}return{node:this.contentDOM,from:a,to:b,fromOffset:d,toOffset:e}}emptyChildAt(a){if(this.border||!this.contentDOM||!this.children.length)return!1;let b=this.children[a<0?0:this.children.length-1];return 0==b.size||b.emptyChildAt(a)}domAfterPos(a){let{node:b,offset:c}=this.domFromPos(a,0);if(1!=b.nodeType||c==b.childNodes.length)throw RangeError("No node after pos "+a);return b.childNodes[c]}setSelection(a,b,c,d=!1){let e=Math.min(a,b),f=Math.max(a,b);for(let g=0,h=0;g<this.children.length;g++){let i=this.children[g],j=h+i.size;if(e>h&&f<j)return i.setSelection(a-h-i.border,b-h-i.border,c,d);h=j}let g=this.domFromPos(a,a?-1:1),h=b==a?g:this.domFromPos(b,b?-1:1),i=c.root.getSelection(),j=c.domSelectionRange(),k=!1;if((cd||ch)&&a==b){let{node:a,offset:b}=g;if(3==a.nodeType){if((k=!!(b&&"\n"==a.nodeValue[b-1]))&&b==a.nodeValue.length)for(let b=a,c;b;b=b.parentNode){if(c=b.nextSibling){"BR"==c.nodeName&&(g=h={node:c.parentNode,offset:bV(c)+1});break}let a=b.pmViewDesc;if(a&&a.node&&a.node.isBlock)break}}else{let c=a.childNodes[b-1];k=c&&("BR"==c.nodeName||"false"==c.contentEditable)}}if(cd&&j.focusNode&&j.focusNode!=h.node&&1==j.focusNode.nodeType){let a=j.focusNode.childNodes[j.focusOffset];a&&"false"==a.contentEditable&&(d=!0)}if(!(d||k&&ch)&&b$(g.node,g.offset,j.anchorNode,j.anchorOffset)&&b$(h.node,h.offset,j.focusNode,j.focusOffset))return;let l=!1;if((i.extend||a==b)&&!(k&&cd)){i.collapse(g.node,g.offset);try{a!=b&&i.extend(h.node,h.offset),l=!0}catch(a){}}if(!l){if(a>b){let a=g;g=h,h=a}let c=document.createRange();c.setEnd(h.node,h.offset),c.setStart(g.node,g.offset),i.removeAllRanges(),i.addRange(c)}}ignoreMutation(a){return!this.contentDOM&&"selection"!=a.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(a,b){for(let c=0,d=0;d<this.children.length;d++){let e=this.children[d],f=c+e.size;if(c==f?a<=f&&b>=c:a<f&&b>c){let d=c+e.border,g=f-e.border;if(a>=d&&b<=g){this.dirty=a==c||b==f?2:1,a==d&&b==g&&(e.contentLost||e.dom.parentNode!=this.contentDOM)?e.dirty=3:e.markDirty(a-d,b-d);return}e.dirty=e.dom!=e.contentDOM||e.dom.parentNode!=this.contentDOM||e.children.length?3:2}c=f}this.dirty=2}markParentsDirty(){let a=1;for(let b=this.parent;b;b=b.parent,a++){let c=1==a?2:1;b.dirty<c&&(b.dirty=c)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(a){return!1}}class cG extends cF{constructor(a,b,c,d){let e,f=b.type.toDOM;if("function"==typeof f&&(f=f(c,()=>e?e.parent?e.parent.posBeforeChild(e):void 0:d)),!b.type.spec.raw){if(1!=f.nodeType){let a=document.createElement("span");a.appendChild(f),f=a}f.contentEditable="false",f.classList.add("ProseMirror-widget")}super(a,[],f,null),this.widget=b,this.widget=b,e=this}matchesWidget(a){return 0==this.dirty&&a.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(a){let b=this.widget.spec.stopEvent;return!!b&&b(a)}ignoreMutation(a){return"selection"!=a.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class cH extends cF{constructor(a,b,c,d){super(a,[],b,null),this.textDOM=c,this.text=d}get size(){return this.text.length}localPosFromDOM(a,b){return a!=this.textDOM?this.posAtStart+(b?this.size:0):this.posAtStart+b}domFromPos(a){return{node:this.textDOM,offset:a}}ignoreMutation(a){return"characterData"===a.type&&a.target.nodeValue==a.oldValue}}class cI extends cF{constructor(a,b,c,d,e){super(a,[],c,d),this.mark=b,this.spec=e}static create(a,b,c,d){let e=d.nodeViews[b.type.name],f=e&&e(b,d,c);return f&&f.dom||(f=au.renderSpec(document,b.type.spec.toDOM(b,c),null,b.attrs)),new cI(a,b,f.dom,f.contentDOM||f.dom,f)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(a){return 3!=this.dirty&&this.mark.eq(a)}markDirty(a,b){if(super.markDirty(a,b),0!=this.dirty){let a=this.parent;for(;!a.node;)a=a.parent;a.dirty<this.dirty&&(a.dirty=this.dirty),this.dirty=0}}slice(a,b,c){let d=cI.create(this.parent,this.mark,!0,c),e=this.children,f=this.size;b<f&&(e=cX(e,b,f,c)),a>0&&(e=cX(e,0,a,c));for(let a=0;a<e.length;a++)e[a].parent=d;return d.children=e,d}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class cJ extends cF{constructor(a,b,c,d,e,f,g,h,i){super(a,[],e,f),this.node=b,this.outerDeco=c,this.innerDeco=d,this.nodeDOM=g}static create(a,b,c,d,e,f){let g=e.nodeViews[b.type.name],h,i=g&&g(b,e,()=>h?h.parent?h.parent.posBeforeChild(h):void 0:f,c,d),j=i&&i.dom,k=i&&i.contentDOM;if(b.isText)if(j){if(3!=j.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else j=document.createTextNode(b.text);else if(!j){let a=au.renderSpec(document,b.type.spec.toDOM(b),null,b.attrs);({dom:j,contentDOM:k}=a)}k||b.isText||"BR"==j.nodeName||(j.hasAttribute("contenteditable")||(j.contentEditable="false"),b.type.spec.draggable&&(j.draggable=!0));let l=j;return(j=cS(j,c,b),i)?h=new cN(a,b,c,d,j,k||null,l,i,e,f+1):b.isText?new cL(a,b,c,d,j,l,e):new cJ(a,b,c,d,j,k||null,l,e,f+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let a={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(a.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let b=this.children.length-1;b>=0;b--){let c=this.children[b];if(this.dom.contains(c.dom.parentNode)){a.contentElement=c.dom.parentNode;break}}a.contentElement||(a.getContent=()=>D.empty)}else a.contentElement=this.contentDOM;else a.getContent=()=>this.node.content;return a}matchesNode(a,b,c){return 0==this.dirty&&a.eq(this.node)&&cT(b,this.outerDeco)&&c.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(a,b){let c=this.node.inlineContent,d=b,e=a.composing?this.localCompositionInfo(a,b):null,f=e&&e.pos>-1?e:null,g=e&&e.pos<0,h=new cV(this,f&&f.node,a);(function(a,b,c,d){let e=b.locals(a),f=0;if(0==e.length){for(let c=0;c<a.childCount;c++){let g=a.child(c);d(g,e,b.forChild(f,g),c),f+=g.nodeSize}return}let g=0,h=[],i=null;for(let j=0;;){let k,l,m,n;for(;g<e.length&&e[g].to==f;){let a=e[g++];a.widget&&(k?(l||(l=[k])).push(a):k=a)}if(k)if(l){l.sort(cW);for(let a=0;a<l.length;a++)c(l[a],j,!!i)}else c(k,j,!!i);if(i)n=-1,m=i,i=null;else if(j<a.childCount)n=j,m=a.child(j++);else break;for(let a=0;a<h.length;a++)h[a].to<=f&&h.splice(a--,1);for(;g<e.length&&e[g].from<=f&&e[g].to>f;)h.push(e[g++]);let o=f+m.nodeSize;if(m.isText){let a=o;g<e.length&&e[g].from<a&&(a=e[g].from);for(let b=0;b<h.length;b++)h[b].to<a&&(a=h[b].to);a<o&&(i=m.cut(a-f),m=m.cut(0,a-f),o=a,n=-1)}else for(;g<e.length&&e[g].to<o;)g++;let p=m.isInline&&!m.isLeaf?h.filter(a=>!a.inline):h.slice();d(m,p,b.forChild(f,m),n),f=o}})(this.node,this.innerDeco,(b,e,f)=>{b.spec.marks?h.syncToMarks(b.spec.marks,c,a,e):b.type.side>=0&&!f&&h.syncToMarks(e==this.node.childCount?H.none:this.node.child(e).marks,c,a,e),h.placeWidget(b,a,d)},(b,f,i,j)=>{let k;h.syncToMarks(b.marks,c,a,j),h.findNodeMatch(b,f,i,j)||g&&a.state.selection.from>d&&a.state.selection.to<d+b.nodeSize&&(k=h.findIndexWithChild(e.node))>-1&&h.updateNodeAt(b,f,i,k,a)||h.updateNextNode(b,f,i,a,j,d)||h.addNode(b,f,i,a,d),d+=b.nodeSize}),h.syncToMarks([],c,a,0),this.node.isTextblock&&h.addTextblockHacks(),h.destroyRest(),(h.changed||2==this.dirty)&&(f&&this.protectLocalComposition(a,f),function a(b,c,d){let e=b.firstChild,f=!1;for(let g=0;g<c.length;g++){let h=c[g],i=h.dom;if(i.parentNode==b){for(;i!=e;)e=cU(e),f=!0;e=e.nextSibling}else f=!0,b.insertBefore(i,e);if(h instanceof cI){let c=e?e.previousSibling:b.lastChild;a(h.contentDOM,h.children,d),e=c?c.nextSibling:b.firstChild}}for(;e;)e=cU(e),f=!0;f&&d.trackWrites==b&&(d.trackWrites=null)}(this.contentDOM,this.children,a),ci&&function(a){if("UL"==a.nodeName||"OL"==a.nodeName){let b=a.style.cssText;a.style.cssText=b+"; list-style: square !important",window.getComputedStyle(a).listStyle,a.style.cssText=b}}(this.dom))}localCompositionInfo(a,b){let{from:c,to:d}=a.state.selection;if(!(a.state.selection instanceof bd)||c<b||d>b+this.node.content.size)return null;let e=a.input.compositionNode;if(!e||!this.dom.contains(e.parentNode))return null;if(!this.node.inlineContent)return{node:e,pos:-1,text:""};{let a=e.nodeValue,f=function(a,b,c,d){for(let e=0,f=0;e<a.childCount&&f<=d;){let g=a.child(e++),h=f;if(f+=g.nodeSize,!g.isText)continue;let i=g.text;for(;e<a.childCount;){let b=a.child(e++);if(f+=b.nodeSize,!b.isText)break;i+=b.text}if(f>=c){if(f>=d&&i.slice(d-b.length-h,d-h)==b)return d-b.length;let a=h<d?i.lastIndexOf(b,d-h-1):-1;if(a>=0&&a+b.length+h>=c)return h+a;if(c==d&&i.length>=d+b.length-h&&i.slice(d-h,d-h+b.length)==b)return d}}return -1}(this.node.content,a,c-b,d-b);return f<0?null:{node:e,pos:f,text:a}}}protectLocalComposition(a,{node:b,pos:c,text:d}){if(this.getDesc(b))return;let e=b;for(;e.parentNode!=this.contentDOM;e=e.parentNode){for(;e.previousSibling;)e.parentNode.removeChild(e.previousSibling);for(;e.nextSibling;)e.parentNode.removeChild(e.nextSibling);e.pmViewDesc&&(e.pmViewDesc=void 0)}let f=new cH(this,e,b,d);a.input.compositionNodes.push(f),this.children=cX(this.children,c,c+d.length,a,f)}update(a,b,c,d){return 3!=this.dirty&&!!a.sameMarkup(this.node)&&(this.updateInner(a,b,c,d),!0)}updateInner(a,b,c,d){this.updateOuterDeco(b),this.node=a,this.innerDeco=c,this.contentDOM&&this.updateChildren(d,this.posAtStart),this.dirty=0}updateOuterDeco(a){if(cT(a,this.outerDeco))return;let b=1!=this.nodeDOM.nodeType,c=this.dom;this.dom=cR(this.dom,this.nodeDOM,cQ(this.outerDeco,this.node,b),cQ(a,this.node,b)),this.dom!=c&&(c.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=a}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function cK(a,b,c,d,e){cS(d,b,a);let f=new cJ(void 0,a,b,c,d,d,d,e,0);return f.contentDOM&&f.updateChildren(e,0),f}class cL extends cJ{constructor(a,b,c,d,e,f,g){super(a,b,c,d,e,null,f,g,0)}parseRule(){let a=this.nodeDOM.parentNode;for(;a&&a!=this.dom&&!a.pmIsDeco;)a=a.parentNode;return{skip:a||!0}}update(a,b,c,d){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!a.sameMarkup(this.node)&&(this.updateOuterDeco(b),(0!=this.dirty||a.text!=this.node.text)&&a.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=a.text,d.trackWrites==this.nodeDOM&&(d.trackWrites=null)),this.node=a,this.dirty=0,!0)}inParent(){let a=this.parent.contentDOM;for(let b=this.nodeDOM;b;b=b.parentNode)if(b==a)return!0;return!1}domFromPos(a){return{node:this.nodeDOM,offset:a}}localPosFromDOM(a,b,c){return a==this.nodeDOM?this.posAtStart+Math.min(b,this.node.text.length):super.localPosFromDOM(a,b,c)}ignoreMutation(a){return"characterData"!=a.type&&"selection"!=a.type}slice(a,b,c){let d=this.node.cut(a,b),e=document.createTextNode(d.text);return new cL(this.parent,d,this.outerDeco,this.innerDeco,e,e,c)}markDirty(a,b){super.markDirty(a,b),this.dom!=this.nodeDOM&&(0==a||b==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(a){return this.node.text==a}}class cM extends cF{parseRule(){return{ignore:!0}}matchesHack(a){return 0==this.dirty&&this.dom.nodeName==a}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class cN extends cJ{constructor(a,b,c,d,e,f,g,h,i,j){super(a,b,c,d,e,f,g,i,j),this.spec=h}update(a,b,c,d){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==a.type||this.spec.multiType)){let e=this.spec.update(a,b,c);return e&&this.updateInner(a,b,c,d),e}return(!!this.contentDOM||!!a.isLeaf)&&super.update(a,b,c,d)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(a,b,c,d){this.spec.setSelection?this.spec.setSelection(a,b,c.root):super.setSelection(a,b,c,d)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(a){return!!this.spec.stopEvent&&this.spec.stopEvent(a)}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}}let cO=function(a){a&&(this.nodeName=a)};cO.prototype=Object.create(null);let cP=[new cO];function cQ(a,b,c){if(0==a.length)return cP;let d=c?cP[0]:new cO,e=[d];for(let f=0;f<a.length;f++){let g=a[f].type.attrs;if(g)for(let a in g.nodeName&&e.push(d=new cO(g.nodeName)),g){let f=g[a];null!=f&&(c&&1==e.length&&e.push(d=new cO(b.isInline?"span":"div")),"class"==a?d.class=(d.class?d.class+" ":"")+f:"style"==a?d.style=(d.style?d.style+";":"")+f:"nodeName"!=a&&(d[a]=f))}}return e}function cR(a,b,c,d){if(c==cP&&d==cP)return b;let e=b;for(let b=0;b<d.length;b++){let f=d[b],g=c[b];if(b){let b;g&&g.nodeName==f.nodeName&&e!=a&&(b=e.parentNode)&&b.nodeName.toLowerCase()==f.nodeName||((b=document.createElement(f.nodeName)).pmIsDeco=!0,b.appendChild(e),g=cP[0]),e=b}!function(a,b,c){for(let d in b)"class"==d||"style"==d||"nodeName"==d||d in c||a.removeAttribute(d);for(let d in c)"class"!=d&&"style"!=d&&"nodeName"!=d&&c[d]!=b[d]&&a.setAttribute(d,c[d]);if(b.class!=c.class){let d=b.class?b.class.split(" ").filter(Boolean):[],e=c.class?c.class.split(" ").filter(Boolean):[];for(let b=0;b<d.length;b++)-1==e.indexOf(d[b])&&a.classList.remove(d[b]);for(let b=0;b<e.length;b++)-1==d.indexOf(e[b])&&a.classList.add(e[b]);0==a.classList.length&&a.removeAttribute("class")}if(b.style!=c.style){if(b.style){let c=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,d;for(;d=c.exec(b.style);)a.style.removeProperty(d[1])}c.style&&(a.style.cssText+=c.style)}}(e,g||cP[0],f)}return e}function cS(a,b,c){return cR(a,a,cP,cQ(b,c,1!=a.nodeType))}function cT(a,b){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].type.eq(b[c].type))return!1;return!0}function cU(a){let b=a.nextSibling;return a.parentNode.removeChild(a),b}class cV{constructor(a,b,c){this.lock=b,this.view=c,this.index=0,this.stack=[],this.changed=!1,this.top=a,this.preMatch=function(a,b){let c=b,d=c.children.length,e=a.childCount,f=new Map,g=[];c:for(;e>0;){let h;for(;;)if(d){let a=c.children[d-1];if(a instanceof cI)c=a,d=a.children.length;else{h=a,d--;break}}else if(c==b)break c;else d=c.parent.children.indexOf(c),c=c.parent;let i=h.node;if(i){if(i!=a.child(e-1))break;--e,f.set(h,e),g.push(h)}}return{index:e,matched:f,matches:g.reverse()}}(a.node.content,a)}destroyBetween(a,b){if(a!=b){for(let c=a;c<b;c++)this.top.children[c].destroy();this.top.children.splice(a,b-a),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(a,b,c,d){let e=0,f=this.stack.length>>1,g=Math.min(f,a.length);for(;e<g&&(e==f-1?this.top:this.stack[e+1<<1]).matchesMark(a[e])&&!1!==a[e].type.spec.spanning;)e++;for(;e<f;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),f--;for(;f<a.length;){this.stack.push(this.top,this.index+1);let e=-1,g=this.top.children.length;d<this.preMatch.index&&(g=Math.min(this.index+3,g));for(let b=this.index;b<g;b++){let c=this.top.children[b];if(c.matchesMark(a[f])&&!this.isLocked(c.dom)){e=b;break}}if(e>-1)e>this.index&&(this.changed=!0,this.destroyBetween(this.index,e)),this.top=this.top.children[this.index];else{let d=cI.create(this.top,a[f],b,c);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,f++}}findNodeMatch(a,b,c,d){let e=-1,f;if(d>=this.preMatch.index&&(f=this.preMatch.matches[d-this.preMatch.index]).parent==this.top&&f.matchesNode(a,b,c))e=this.top.children.indexOf(f,this.index);else for(let d=this.index,f=Math.min(this.top.children.length,d+5);d<f;d++){let f=this.top.children[d];if(f.matchesNode(a,b,c)&&!this.preMatch.matched.has(f)){e=d;break}}return!(e<0)&&(this.destroyBetween(this.index,e),this.index++,!0)}updateNodeAt(a,b,c,d,e){let f=this.top.children[d];return 3==f.dirty&&f.dom==f.contentDOM&&(f.dirty=2),!!f.update(a,b,c,e)&&(this.destroyBetween(this.index,d),this.index++,!0)}findIndexWithChild(a){for(;;){let b=a.parentNode;if(!b)return -1;if(b==this.top.contentDOM){let b=a.pmViewDesc;if(b){for(let a=this.index;a<this.top.children.length;a++)if(this.top.children[a]==b)return a}return -1}a=b}}updateNextNode(a,b,c,d,e,f){for(let g=this.index;g<this.top.children.length;g++){let h=this.top.children[g];if(h instanceof cJ){let i=this.preMatch.matched.get(h);if(null!=i&&i!=e)return!1;let j=h.dom,k,l=this.isLocked(j)&&!(a.isText&&h.node&&h.node.isText&&h.nodeDOM.nodeValue==a.text&&3!=h.dirty&&cT(b,h.outerDeco));if(!l&&h.update(a,b,c,d))return this.destroyBetween(this.index,g),h.dom!=j&&(this.changed=!0),this.index++,!0;if(!l&&(k=this.recreateWrapper(h,a,b,c,d,f)))return this.destroyBetween(this.index,g),this.top.children[this.index]=k,k.contentDOM&&(k.dirty=2,k.updateChildren(d,f+1),k.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(a,b,c,d,e,f){if(a.dirty||b.isAtom||!a.children.length||!a.node.content.eq(b.content)||!cT(c,a.outerDeco)||!d.eq(a.innerDeco))return null;let g=cJ.create(this.top,b,c,d,e,f);if(g.contentDOM)for(let b of(g.children=a.children,a.children=[],g.children))b.parent=g;return a.destroy(),g}addNode(a,b,c,d,e){let f=cJ.create(this.top,a,b,c,d,e);f.contentDOM&&f.updateChildren(d,e+1),this.top.children.splice(this.index++,0,f),this.changed=!0}placeWidget(a,b,c){let d=this.index<this.top.children.length?this.top.children[this.index]:null;if(d&&d.matchesWidget(a)&&(a==d.widget||!d.widget.type.toDOM.parentNode))this.index++;else{let d=new cG(this.top,a,b,c);this.top.children.splice(this.index++,0,d),this.changed=!0}}addTextblockHacks(){let a=this.top.children[this.index-1],b=this.top;for(;a instanceof cI;)a=(b=a).children[b.children.length-1];(!a||!(a instanceof cL)||/\n$/.test(a.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(a.node.text))&&((ch||cf)&&a&&"false"==a.dom.contentEditable&&this.addHackNode("IMG",b),this.addHackNode("BR",this.top))}addHackNode(a,b){if(b==this.top&&this.index<b.children.length&&b.children[this.index].matchesHack(a))this.index++;else{let c=document.createElement(a);"IMG"==a&&(c.className="ProseMirror-separator",c.alt=""),"BR"==a&&(c.className="ProseMirror-trailingBreak");let d=new cM(this.top,[],c,null);b!=this.top?b.children.push(d):b.children.splice(this.index++,0,d),this.changed=!0}}isLocked(a){return this.lock&&(a==this.lock||1==a.nodeType&&a.contains(this.lock.parentNode))}}function cW(a,b){return a.type.side-b.type.side}function cX(a,b,c,d,e){let f=[];for(let g=0,h=0;g<a.length;g++){let i=a[g],j=h,k=h+=i.size;j>=c||k<=b?f.push(i):(j<b&&f.push(i.slice(0,b-j,d)),e&&(f.push(e),e=void 0),k>c&&f.push(i.slice(c-j,i.size,d)))}return f}function cY(a,b=null){let c=a.domSelectionRange(),d=a.state.doc;if(!c.focusNode)return null;let e=a.docView.nearestDesc(c.focusNode),f=e&&0==e.size,g=a.docView.posFromDOM(c.focusNode,c.focusOffset,1);if(g<0)return null;let h=d.resolve(g),i,j;if(b3(c)){for(i=g;e&&!e.node;)e=e.parent;let a=e.node;if(e&&a.isAtom&&bf.isSelectable(a)&&e.parent&&!(a.isInline&&function(a,b,c){for(let d=0==b,e=b==b1(a);d||e;){if(a==c)return!0;let b=bV(a);if(!(a=a.parentNode))return!1;d=d&&0==b,e=e&&b==b1(a)}}(c.focusNode,c.focusOffset,e.dom))){let a=e.posBefore;j=new bf(g==a?h:d.resolve(a))}}else{if(c instanceof a.dom.ownerDocument.defaultView.Selection&&c.rangeCount>1){let b=g,e=g;for(let d=0;d<c.rangeCount;d++){let f=c.getRangeAt(d);b=Math.min(b,a.docView.posFromDOM(f.startContainer,f.startOffset,1)),e=Math.max(e,a.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(b<0)return null;[i,g]=e==a.state.selection.anchor?[e,b]:[b,e],h=d.resolve(g)}else i=a.docView.posFromDOM(c.anchorNode,c.anchorOffset,1);if(i<0)return null}let k=d.resolve(i);if(!j){let c="pointer"==b||a.state.selection.head<h.pos&&!f?1:-1;j=c5(a,k,h,c)}return j}function cZ(a){return a.editable?a.hasFocus():c7(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function c$(a,b=!1){let c=a.state.selection;if(c3(a,c),cZ(a)){if(!b&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&cf){let b=a.domSelectionRange(),c=a.domObserver.currentSelection;if(b.anchorNode&&c.anchorNode&&b$(b.anchorNode,b.anchorOffset,c.anchorNode,c.anchorOffset)){a.input.mouseDown.delayedSelectionSync=!0,a.domObserver.setCurSelection();return}}if(a.domObserver.disconnectSelection(),a.cursorWrapper)!function(a){let b=a.domSelection();if(!b)return;let c=a.cursorWrapper.dom,d="IMG"==c.nodeName;d?b.collapse(c.parentNode,bV(c)+1):b.collapse(c,0),!d&&!a.state.selection.visible&&cb&&cc<=11&&(c.disabled=!0,c.disabled=!1)}(a);else{var d;let e,f,g,h,{anchor:i,head:j}=c,k,l;c_&&!(c instanceof bd)&&(c.$from.parent.inlineContent||(k=c0(a,c.from)),c.empty||c.$from.parent.inlineContent||(l=c0(a,c.to))),a.docView.setSelection(i,j,a,b),c_&&(k&&c2(k),l&&c2(l)),c.visible?a.dom.classList.remove("ProseMirror-hideselection"):(a.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((e=(d=a).dom.ownerDocument).removeEventListener("selectionchange",d.input.hideSelectionGuard),g=(f=d.domSelectionRange()).anchorNode,h=f.anchorOffset,e.addEventListener("selectionchange",d.input.hideSelectionGuard=()=>{(f.anchorNode!=g||f.anchorOffset!=h)&&(e.removeEventListener("selectionchange",d.input.hideSelectionGuard),setTimeout(()=>{(!cZ(d)||d.state.selection.visible)&&d.dom.classList.remove("ProseMirror-hideselection")},20))})))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}let c_=ch||cf&&cg<63;function c0(a,b){let{node:c,offset:d}=a.docView.domFromPos(b,0),e=d<c.childNodes.length?c.childNodes[d]:null,f=d?c.childNodes[d-1]:null;if(ch&&e&&"false"==e.contentEditable)return c1(e);if((!e||"false"==e.contentEditable)&&(!f||"false"==f.contentEditable)){if(e)return c1(e);else if(f)return c1(f)}}function c1(a){return a.contentEditable="true",ch&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function c2(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function c3(a,b){if(b instanceof bf){let c=a.docView.descAt(b.from);c!=a.lastSelectedViewDesc&&(c4(a),c&&c.selectNode(),a.lastSelectedViewDesc=c)}else c4(a)}function c4(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function c5(a,b,c,d){return a.someProp("createSelectionBetween",d=>d(a,b,c))||bd.between(b,c,d)}function c6(a){return(!a.editable||!!a.hasFocus())&&c7(a)}function c7(a){let b=a.domSelectionRange();if(!b.anchorNode)return!1;try{return a.dom.contains(3==b.anchorNode.nodeType?b.anchorNode.parentNode:b.anchorNode)&&(a.editable||a.dom.contains(3==b.focusNode.nodeType?b.focusNode.parentNode:b.focusNode))}catch(a){return!1}}function c8(a,b){let{$anchor:c,$head:d}=a.selection,e=b>0?c.max(d):c.min(d),f=e.parent.inlineContent?e.depth?a.doc.resolve(b>0?e.after():e.before()):null:e;return f&&a9.findFrom(f,b)}function c9(a,b){return a.dispatch(a.state.tr.setSelection(b).scrollIntoView()),!0}function da(a,b,c){let d=a.state.selection;if(d instanceof bd){if(c.indexOf("s")>-1){let{$head:c}=d,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter;if(!e||e.isText||!e.isLeaf)return!1;let f=a.state.doc.resolve(c.pos+e.nodeSize*(b<0?-1:1));return c9(a,new bd(d.$anchor,f))}else if(!d.empty)return!1;else if(a.endOfTextblock(b>0?"forward":"backward")){let c=c8(a.state,b);return!!c&&c instanceof bf&&c9(a,c)}else if(!(cj&&c.indexOf("m")>-1)){let c=d.$head,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter,f;if(!e||e.isText)return!1;let g=b<0?c.pos-e.nodeSize:c.pos;return!!(e.isAtom||(f=a.docView.descAt(g))&&!f.contentDOM)&&(bf.isSelectable(e)?c9(a,new bf(b<0?a.state.doc.resolve(c.pos-e.nodeSize):c)):!!cm&&c9(a,new bd(a.state.doc.resolve(b<0?g:g+e.nodeSize))))}}else{if(d instanceof bf&&d.node.isInline)return c9(a,new bd(b>0?d.$to:d.$from));let c=c8(a.state,b);return!!c&&c9(a,c)}}function db(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function dc(a,b){let c=a.pmViewDesc;return c&&0==c.size&&(b<0||a.nextSibling||"BR"!=a.nodeName)}function dd(a,b){return b<0?function(a){let b=a.domSelectionRange(),c=b.focusNode,d=b.focusOffset;if(!c)return;let e,f,g=!1;for(cd&&1==c.nodeType&&d<db(c)&&dc(c.childNodes[d],-1)&&(g=!0);;)if(d>0)if(1!=c.nodeType)break;else{let a=c.childNodes[d-1];if(dc(a,-1))e=c,f=--d;else if(3==a.nodeType)d=(c=a).nodeValue.length;else break}else if(de(c))break;else{let b=c.previousSibling;for(;b&&dc(b,-1);)e=c.parentNode,f=bV(b),b=b.previousSibling;if(b)d=db(c=b);else{if((c=c.parentNode)==a.dom)break;d=0}}g?df(a,c,d):e&&df(a,e,f)}(a):function(a){let b,c,d=a.domSelectionRange(),e=d.focusNode,f=d.focusOffset;if(!e)return;let g=db(e);for(;;)if(f<g){if(1!=e.nodeType)break;if(dc(e.childNodes[f],1))b=e,c=++f;else break}else if(de(e))break;else{let d=e.nextSibling;for(;d&&dc(d,1);)b=d.parentNode,c=bV(d)+1,d=d.nextSibling;if(d)f=0,g=db(e=d);else{if((e=e.parentNode)==a.dom)break;f=g=0}}b&&df(a,b,c)}(a)}function de(a){let b=a.pmViewDesc;return b&&b.node&&b.node.isBlock}function df(a,b,c){if(3!=b.nodeType){let a,d;(d=function(a,b){for(;a&&b==a.childNodes.length&&!b2(a);)b=bV(a)+1,a=a.parentNode;for(;a&&b<a.childNodes.length;){let c=a.childNodes[b];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;a=c,b=0}}(b,c))?(b=d,c=0):(a=function(a,b){for(;a&&!b&&!b2(a);)b=bV(a),a=a.parentNode;for(;a&&b;){let c=a.childNodes[b-1];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;b=(a=c).childNodes.length}}(b,c))&&(b=a,c=a.nodeValue.length)}let d=a.domSelection();if(!d)return;if(b3(d)){let a=document.createRange();a.setEnd(b,c),a.setStart(b,c),d.removeAllRanges(),d.addRange(a)}else d.extend&&d.extend(b,c);a.domObserver.setCurSelection();let{state:e}=a;setTimeout(()=>{a.state==e&&c$(a)},50)}function dg(a,b){let c=a.state.doc.resolve(b);if(!(cf||ck)&&c.parent.inlineContent){let d=a.coordsAtPos(b);if(b>c.start()){let c=a.coordsAtPos(b-1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left<d.left?"ltr":"rtl"}if(b<c.end()){let c=a.coordsAtPos(b+1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left>d.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(a.dom).direction?"rtl":"ltr"}function dh(a,b,c){let d=a.state.selection;if(d instanceof bd&&!d.empty||c.indexOf("s")>-1||cj&&c.indexOf("m")>-1)return!1;let{$from:e,$to:f}=d;if(!e.parent.inlineContent||a.endOfTextblock(b<0?"up":"down")){let c=c8(a.state,b);if(c&&c instanceof bf)return c9(a,c)}if(!e.parent.inlineContent){let c=b<0?e:f,g=d instanceof bh?a9.near(c,b):a9.findFrom(c,b);return!!g&&c9(a,g)}return!1}function di(a,b){if(!(a.state.selection instanceof bd))return!0;let{$head:c,$anchor:d,empty:e}=a.state.selection;if(!c.sameParent(d))return!0;if(!e)return!1;if(a.endOfTextblock(b>0?"forward":"backward"))return!0;let f=!c.textOffset&&(b<0?c.nodeBefore:c.nodeAfter);if(f&&!f.isText){let d=a.state.tr;return b<0?d.delete(c.pos-f.nodeSize,c.pos):d.delete(c.pos,c.pos+f.nodeSize),a.dispatch(d),!0}return!1}function dj(a,b,c){a.domObserver.stop(),b.contentEditable=c,a.domObserver.start()}function dk(a,b){a.someProp("transformCopied",c=>{b=c(b,a)});let c=[],{content:d,openStart:e,openEnd:f}=b;for(;e>1&&f>1&&1==d.childCount&&1==d.firstChild.childCount;){e--,f--;let a=d.firstChild;c.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),d=a.content}let g=a.someProp("clipboardSerializer")||au.fromSchema(a.state.schema),h=dt(),i=h.createElement("div");i.appendChild(g.serializeFragment(d,{document:h}));let j=i.firstChild,k,l=0;for(;j&&1==j.nodeType&&(k=dr[j.nodeName.toLowerCase()]);){for(let a=k.length-1;a>=0;a--){let b=h.createElement(k[a]);for(;i.firstChild;)b.appendChild(i.firstChild);i.appendChild(b),l++}j=i.firstChild}return j&&1==j.nodeType&&j.setAttribute("data-pm-slice",`${e} ${f}${l?` -${l}`:""} ${JSON.stringify(c)}`),{dom:i,text:a.someProp("clipboardTextSerializer",c=>c(b,a))||b.content.textBetween(0,b.content.size,"\n\n"),slice:b}}function dl(a,b,c,d,e){let f,g,h=e.parent.type.spec.code;if(!c&&!b)return null;let i=!!b&&(d||h||!c);if(i){if(a.someProp("transformPastedText",c=>{b=c(b,h||d,a)}),h)return g=new J(D.from(a.state.schema.text(b.replace(/\r\n?/g,"\n"))),0,0),a.someProp("transformPasted",b=>{g=b(g,a,!0)}),g;let c=a.someProp("clipboardTextParser",c=>c(b,e,d,a));if(c)g=c;else{let c=e.marks(),{schema:d}=a.state,g=au.fromSchema(d);f=document.createElement("div"),b.split(/(?:\r\n?|\n)+/).forEach(a=>{let b=f.appendChild(document.createElement("p"));a&&b.appendChild(g.serializeNode(d.text(a,c)))})}}else a.someProp("transformPastedHTML",b=>{c=b(c,a)}),f=function(a){var b;let c,d=/^(\s*<meta [^>]*>)*/.exec(a);d&&(a=a.slice(d[0].length));let e=dt().createElement("div"),f=/<([a-z][^>\s]+)/i.exec(a),g;if((g=f&&dr[f[1].toLowerCase()])&&(a=g.map(a=>"<"+a+">").join("")+a+g.map(a=>"</"+a+">").reverse().join("")),e.innerHTML=(b=a,(c=window.trustedTypes)?(du||(du=c.defaultPolicy||c.createPolicy("ProseMirrorClipboard",{createHTML:a=>a})),du.createHTML(b)):b),g)for(let a=0;a<g.length;a++)e=e.querySelector(g[a])||e;return e}(c),cm&&function(a){let b=a.querySelectorAll(cf?"span:not([class]):not([style])":"span.Apple-converted-space");for(let c=0;c<b.length;c++){let d=b[c];1==d.childNodes.length&&"\xa0"==d.textContent&&d.parentNode&&d.parentNode.replaceChild(a.ownerDocument.createTextNode(" "),d)}}(f);let j=f&&f.querySelector("[data-pm-slice]"),k=j&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(j.getAttribute("data-pm-slice")||"");if(k&&k[3])for(let a=+k[3];a>0;a--){let a=f.firstChild;for(;a&&1!=a.nodeType;)a=a.nextSibling;if(!a)break;f=a}if(g||(g=(a.someProp("clipboardParser")||a.someProp("domParser")||al.fromSchema(a.state.schema)).parseSlice(f,{preserveWhitespace:!!(i||k),context:e,ruleFromNode:a=>"BR"!=a.nodeName||a.nextSibling||!a.parentNode||dm.test(a.parentNode.nodeName)?null:{ignore:!0}})),k)g=function(a,b){if(!a.size)return a;let c=a.content.firstChild.type.schema,d;try{d=JSON.parse(b)}catch(b){return a}let{content:e,openStart:f,openEnd:g}=a;for(let a=d.length-2;a>=0;a-=2){let b=c.nodes[d[a]];if(!b||b.hasRequiredAttrs())break;e=D.from(b.create(d[a+1],e)),f++,g++}return new J(e,f,g)}(dq(g,+k[1],+k[2]),k[4]);else if((g=J.maxOpen(function(a,b){if(a.childCount<2)return a;for(let c=b.depth;c>=0;c--){let d=b.node(c).contentMatchAt(b.index(c)),e,f=[];if(a.forEach(a=>{if(!f)return;let b=d.findWrapping(a.type),c;if(!b)return f=null;if(c=f.length&&e.length&&function a(b,c,d,e,f){if(f<b.length&&f<c.length&&b[f]==c[f]){let g=a(b,c,d,e.lastChild,f+1);if(g)return e.copy(e.content.replaceChild(e.childCount-1,g));if(e.contentMatchAt(e.childCount).matchType(f==b.length-1?d.type:b[f+1]))return e.copy(e.content.append(D.from(dn(d,b,f+1))))}}(b,e,a,f[f.length-1],0))f[f.length-1]=c;else{f.length&&(f[f.length-1]=function a(b,c){if(0==c)return b;let d=b.content.replaceChild(b.childCount-1,a(b.lastChild,c-1)),e=b.contentMatchAt(b.childCount).fillBefore(D.empty,!0);return b.copy(d.append(e))}(f[f.length-1],e.length));let c=dn(a,b);f.push(c),d=d.matchType(c.type),e=b}}),f)return D.from(f)}return a}(g.content,e),!0)).openStart||g.openEnd){let a=0,b=0;for(let b=g.content.firstChild;a<g.openStart&&!b.type.spec.isolating;a++,b=b.firstChild);for(let a=g.content.lastChild;b<g.openEnd&&!a.type.spec.isolating;b++,a=a.lastChild);g=dq(g,a,b)}return a.someProp("transformPasted",b=>{g=b(g,a,i)}),g}let dm=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function dn(a,b,c=0){for(let d=b.length-1;d>=c;d--)a=b[d].create(null,D.from(a));return a}function dp(a,b,c,d,e,f){let g=b<0?a.firstChild:a.lastChild,h=g.content;return a.childCount>1&&(f=0),e<d-1&&(h=dp(h,b,c,d,e+1,f)),e>=c&&(h=b<0?g.contentMatchAt(0).fillBefore(h,f<=e).append(h):h.append(g.contentMatchAt(g.childCount).fillBefore(D.empty,!0))),a.replaceChild(b<0?0:a.childCount-1,g.copy(h))}function dq(a,b,c){return b<a.openStart&&(a=new J(dp(a.content,-1,b,a.openStart,0,a.openEnd),b,a.openEnd)),c<a.openEnd&&(a=new J(dp(a.content,1,c,a.openEnd,0,0),a.openStart,c)),a}let dr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},ds=null;function dt(){return ds||(ds=document.implementation.createHTMLDocument("title"))}let du=null,dv={},dw={},dx={touchstart:!0,touchmove:!0};class dy{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function dz(a,b){a.input.lastSelectionOrigin=b,a.input.lastSelectionTime=Date.now()}function dA(a){a.someProp("handleDOMEvents",b=>{for(let c in b)a.input.eventHandlers[c]||a.dom.addEventListener(c,a.input.eventHandlers[c]=b=>dB(a,b))})}function dB(a,b){return a.someProp("handleDOMEvents",c=>{let d=c[b.type];return!!d&&(d(a,b)||b.defaultPrevented)})}function dC(a){return{left:a.clientX,top:a.clientY}}function dD(a,b,c,d,e){if(-1==d)return!1;let f=a.state.doc.resolve(d);for(let d=f.depth+1;d>0;d--)if(a.someProp(b,b=>d>f.depth?b(a,c,f.nodeAfter,f.before(d),e,!0):b(a,c,f.node(d),f.before(d),e,!1)))return!0;return!1}function dE(a,b,c){if(a.focused||a.focus(),a.state.selection.eq(b))return;let d=a.state.tr.setSelection(b);"pointer"==c&&d.setMeta("pointer",!0),a.dispatch(d)}dw.keydown=(a,b)=>{if((a.input.shiftKey=16==b.keyCode||b.shiftKey,!dH(a,b))&&(a.input.lastKeyCode=b.keyCode,a.input.lastKeyCodeTime=Date.now(),!cl||!cf||13!=b.keyCode))if(229!=b.keyCode&&a.domObserver.forceFlush(),!ci||13!=b.keyCode||b.ctrlKey||b.altKey||b.metaKey)a.someProp("handleKeyDown",c=>c(a,b))||function(a,b){let c,d=b.keyCode,e=(c="",b.ctrlKey&&(c+="c"),b.metaKey&&(c+="m"),b.altKey&&(c+="a"),b.shiftKey&&(c+="s"),c);if(8==d||cj&&72==d&&"c"==e)return di(a,-1)||dd(a,-1);if(46==d&&!b.shiftKey||cj&&68==d&&"c"==e)return di(a,1)||dd(a,1);if(13==d||27==d)return!0;if(37==d||cj&&66==d&&"c"==e){let b=37==d?"ltr"==dg(a,a.state.selection.from)?-1:1:-1;return da(a,b,e)||dd(a,b)}if(39==d||cj&&70==d&&"c"==e){let b=39==d?"ltr"==dg(a,a.state.selection.from)?1:-1:1;return da(a,b,e)||dd(a,b)}else if(38==d||cj&&80==d&&"c"==e)return dh(a,-1,e)||dd(a,-1);else if(40==d||cj&&78==d&&"c"==e)return function(a){if(!ch||a.state.selection.$head.parentOffset>0)return!1;let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(b&&1==b.nodeType&&0==c&&b.firstChild&&"false"==b.firstChild.contentEditable){let c=b.firstChild;dj(a,c,"true"),setTimeout(()=>dj(a,c,"false"),20)}return!1}(a)||dh(a,1,e)||dd(a,1);else if(e==(cj?"m":"c")&&(66==d||73==d||89==d||90==d))return!0;return!1}(a,b)?b.preventDefault():dz(a,"key");else{let b=Date.now();a.input.lastIOSEnter=b,a.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{a.input.lastIOSEnter==b&&(a.someProp("handleKeyDown",b=>b(a,b4(13,"Enter"))),a.input.lastIOSEnter=0)},200)}},dw.keyup=(a,b)=>{16==b.keyCode&&(a.input.shiftKey=!1)},dw.keypress=(a,b)=>{if(dH(a,b)||!b.charCode||b.ctrlKey&&!b.altKey||cj&&b.metaKey)return;if(a.someProp("handleKeyPress",c=>c(a,b)))return void b.preventDefault();let c=a.state.selection;if(!(c instanceof bd)||!c.$from.sameParent(c.$to)){let d=String.fromCharCode(b.charCode),e=()=>a.state.tr.insertText(d).scrollIntoView();/[\r\n]/.test(d)||a.someProp("handleTextInput",b=>b(a,c.$from.pos,c.$to.pos,d,e))||a.dispatch(e()),b.preventDefault()}};let dF=cj?"metaKey":"ctrlKey";dv.mousedown=(a,b)=>{var c;let d,e;a.input.shiftKey=b.shiftKey;let f=dL(a),g=Date.now(),h="singleClick";g-a.input.lastClick.time<500&&(d=(c=a.input.lastClick).x-b.clientX)*d+(e=c.y-b.clientY)*e<100&&!b[dF]&&a.input.lastClick.button==b.button&&("singleClick"==a.input.lastClick.type?h="doubleClick":"doubleClick"==a.input.lastClick.type&&(h="tripleClick")),a.input.lastClick={time:g,x:b.clientX,y:b.clientY,type:h,button:b.button};let i=a.posAtCoords(dC(b));i&&("singleClick"==h?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new dG(a,i,b,!!f)):("doubleClick"==h?function(a,b,c,d){return dD(a,"handleDoubleClickOn",b,c,d)||a.someProp("handleDoubleClick",c=>c(a,b,d))}:function(a,b,c,d){return dD(a,"handleTripleClickOn",b,c,d)||a.someProp("handleTripleClick",c=>c(a,b,d))||function(a,b,c){if(0!=c.button)return!1;let d=a.state.doc;if(-1==b)return!!d.inlineContent&&(dE(a,bd.create(d,0,d.content.size),"pointer"),!0);let e=d.resolve(b);for(let b=e.depth+1;b>0;b--){let c=b>e.depth?e.nodeAfter:e.node(b),f=e.before(b);if(c.inlineContent)dE(a,bd.create(d,f+1,f+1+c.content.size),"pointer");else{if(!bf.isSelectable(c))continue;dE(a,bf.create(d,f),"pointer")}return!0}}(a,c,d)})(a,i.pos,i.inside,b)?b.preventDefault():dz(a,"pointer"))};class dG{constructor(a,b,c,d){let e,f;if(this.view=a,this.pos=b,this.event=c,this.flushed=d,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=a.state.doc,this.selectNode=!!c[dF],this.allowDefault=c.shiftKey,b.inside>-1)e=a.state.doc.nodeAt(b.inside),f=b.inside;else{let c=a.state.doc.resolve(b.pos);e=c.parent,f=c.depth?c.before():0}const g=d?null:c.target,h=g?a.docView.nearestDesc(g,!0):null;this.target=h&&1==h.nodeDOM.nodeType?h.nodeDOM:null;let{selection:i}=a.state;(0==c.button&&e.type.spec.draggable&&!1!==e.type.spec.selectable||i instanceof bf&&i.from<=f&&i.to>f)&&(this.mightDrag={node:e,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&cd&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),a.root.addEventListener("mouseup",this.up=this.up.bind(this)),a.root.addEventListener("mousemove",this.move=this.move.bind(this)),dz(a,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>c$(this.view)),this.view.input.mouseDown=null}up(a){if(this.done(),!this.view.dom.contains(a.target))return;let b=this.pos;if(this.view.state.doc!=this.startDoc&&(b=this.view.posAtCoords(dC(a))),this.updateAllowDefault(a),this.allowDefault||!b)dz(this.view,"pointer");else{var c,d,e,f;(c=this.view,d=b.pos,e=b.inside,f=this.selectNode,dD(c,"handleClickOn",d,e,a)||c.someProp("handleClick",b=>b(c,d,a))||(f?function(a,b){if(-1==b)return!1;let c=a.state.selection,d,e;c instanceof bf&&(d=c.node);let f=a.state.doc.resolve(b);for(let a=f.depth+1;a>0;a--){let b=a>f.depth?f.nodeAfter:f.node(a);if(bf.isSelectable(b)){e=d&&c.$from.depth>0&&a>=c.$from.depth&&f.before(c.$from.depth+1)==c.$from.pos?f.before(c.$from.depth):f.before(a);break}}return null!=e&&(dE(a,bf.create(a.state.doc,e),"pointer"),!0)}(c,e):function(a,b){if(-1==b)return!1;let c=a.state.doc.resolve(b),d=c.nodeAfter;return!!(d&&d.isAtom&&bf.isSelectable(d))&&(dE(a,new bf(c),"pointer"),!0)}(c,e)))?a.preventDefault():0==a.button&&(this.flushed||ch&&this.mightDrag&&!this.mightDrag.node.isAtom||cf&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(b.pos-this.view.state.selection.from),Math.abs(b.pos-this.view.state.selection.to)))?(dE(this.view,a9.near(this.view.state.doc.resolve(b.pos)),"pointer"),a.preventDefault()):dz(this.view,"pointer")}}move(a){this.updateAllowDefault(a),dz(this.view,"pointer"),0==a.buttons&&this.done()}updateAllowDefault(a){!this.allowDefault&&(Math.abs(this.event.x-a.clientX)>4||Math.abs(this.event.y-a.clientY)>4)&&(this.allowDefault=!0)}}function dH(a,b){return!!a.composing||!!(ch&&500>Math.abs(b.timeStamp-a.input.compositionEndedAt))&&(a.input.compositionEndedAt=-2e8,!0)}dv.touchstart=a=>{a.input.lastTouch=Date.now(),dL(a),dz(a,"pointer")},dv.touchmove=a=>{a.input.lastTouch=Date.now(),dz(a,"pointer")},dv.contextmenu=a=>dL(a);let dI=cl?5e3:-1;function dJ(a,b){clearTimeout(a.input.composingTimeout),b>-1&&(a.input.composingTimeout=setTimeout(()=>dL(a),b))}function dK(a){let b;for(a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=((b=document.createEvent("Event")).initEvent("event",!0,!0),b.timeStamp));a.input.compositionNodes.length>0;)a.input.compositionNodes.pop().markParentsDirty()}function dL(a,b=!1){if(!cl||!(a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),dK(a),b||a.docView&&a.docView.dirty){let c=cY(a),d=a.state.selection;return c&&!c.eq(d)?a.dispatch(a.state.tr.setSelection(c)):(a.markCursor||b)&&!d.$from.node(d.$from.sharedDepth(d.to)).inlineContent?a.dispatch(a.state.tr.deleteSelection()):a.updateState(a.state),!0}return!1}}dw.compositionstart=dw.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:b}=a,c=b.selection.$to;if(b.selection instanceof bd&&(b.storedMarks||!c.textOffset&&c.parentOffset&&c.nodeBefore.marks.some(a=>!1===a.type.spec.inclusive)||cf&&ck&&function(a){let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(!b||1!=b.nodeType||c>=b.childNodes.length)return!1;let d=b.childNodes[c];return 1==d.nodeType&&"false"==d.contentEditable}(a)))a.markCursor=a.state.storedMarks||c.marks(),dL(a,!0),a.markCursor=null;else if(dL(a,!b.selection.empty),cd&&b.selection.empty&&c.parentOffset&&!c.textOffset&&c.nodeBefore.marks.length){let b=a.domSelectionRange();for(let c=b.focusNode,d=b.focusOffset;c&&1==c.nodeType&&0!=d;){let b=d<0?c.lastChild:c.childNodes[d-1];if(!b)break;if(3==b.nodeType){let c=a.domSelection();c&&c.collapse(b,b.nodeValue.length);break}c=b,d=-1}}a.input.composing=!0}dJ(a,dI)},dw.compositionend=(a,b)=>{a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=b.timeStamp,a.input.compositionPendingChanges=a.domObserver.pendingRecords().length?a.input.compositionID:0,a.input.compositionNode=null,a.input.badSafariComposition?a.domObserver.forceFlush():a.input.compositionPendingChanges&&Promise.resolve().then(()=>a.domObserver.flush()),a.input.compositionID++,dJ(a,20))};let dM=cb&&cc<15||ci&&cn<604;function dN(a,b,c,d,e){let f=dl(a,b,c,d,a.state.selection.$from);if(a.someProp("handlePaste",b=>b(a,e,f||J.empty)))return!0;if(!f)return!1;let g=0==f.openStart&&0==f.openEnd&&1==f.content.childCount?f.content.firstChild:null,h=g?a.state.tr.replaceSelectionWith(g,d):a.state.tr.replaceSelection(f);return a.dispatch(h.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function dO(a){let b=a.getData("text/plain")||a.getData("Text");if(b)return b;let c=a.getData("text/uri-list");return c?c.replace(/\r?\n/g," "):""}dv.copy=dw.cut=(a,b)=>{let c=a.state.selection,d="cut"==b.type;if(c.empty)return;let e=dM?null:b.clipboardData,{dom:f,text:g}=dk(a,c.content());e?(b.preventDefault(),e.clearData(),e.setData("text/html",f.innerHTML),e.setData("text/plain",g)):function(a,b){if(!a.dom.parentNode)return;let c=a.dom.parentNode.appendChild(document.createElement("div"));c.appendChild(b),c.style.cssText="position: fixed; left: -10000px; top: 10px";let d=getSelection(),e=document.createRange();e.selectNodeContents(b),a.dom.blur(),d.removeAllRanges(),d.addRange(e),setTimeout(()=>{c.parentNode&&c.parentNode.removeChild(c),a.focus()},50)}(a,f),d&&a.dispatch(a.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},dw.paste=(a,b)=>{if(a.composing&&!cl)return;let c=dM?null:b.clipboardData,d=a.input.shiftKey&&45!=a.input.lastKeyCode;c&&dN(a,dO(c),c.getData("text/html"),d,b)?b.preventDefault():function(a,b){if(!a.dom.parentNode)return;let c=a.input.shiftKey||a.state.selection.$from.parent.type.spec.code,d=a.dom.parentNode.appendChild(document.createElement(c?"textarea":"div"));c||(d.contentEditable="true"),d.style.cssText="position: fixed; left: -10000px; top: 10px",d.focus();let e=a.input.shiftKey&&45!=a.input.lastKeyCode;setTimeout(()=>{a.focus(),d.parentNode&&d.parentNode.removeChild(d),c?dN(a,d.value,null,e,b):dN(a,d.textContent,d.innerHTML,e,b)},50)}(a,b)};class dP{constructor(a,b,c){this.slice=a,this.move=b,this.node=c}}let dQ=cj?"altKey":"ctrlKey";function dR(a,b){let c=a.someProp("dragCopies",a=>!a(b));return null!=c?c:!b[dQ]}for(let a in dv.dragstart=(a,b)=>{let c,d=a.input.mouseDown;if(d&&d.done(),!b.dataTransfer)return;let e=a.state.selection,f=e.empty?null:a.posAtCoords(dC(b));if(f&&f.pos>=e.from&&f.pos<=(e instanceof bf?e.to-1:e.to));else if(d&&d.mightDrag)c=bf.create(a.state.doc,d.mightDrag.pos);else if(b.target&&1==b.target.nodeType){let d=a.docView.nearestDesc(b.target,!0);d&&d.node.type.spec.draggable&&d!=a.docView&&(c=bf.create(a.state.doc,d.posBefore))}let g=(c||a.state.selection).content(),{dom:h,text:i,slice:j}=dk(a,g);b.dataTransfer.files.length&&cf&&!(cg>120)||b.dataTransfer.clearData(),b.dataTransfer.setData(dM?"Text":"text/html",h.innerHTML),b.dataTransfer.effectAllowed="copyMove",dM||b.dataTransfer.setData("text/plain",i),a.dragging=new dP(j,dR(a,b),c)},dv.dragend=a=>{let b=a.dragging;window.setTimeout(()=>{a.dragging==b&&(a.dragging=null)},50)},dw.dragover=dw.dragenter=(a,b)=>b.preventDefault(),dw.drop=(a,b)=>{try{!function(a,b,c){if(!b.dataTransfer)return;let d=a.posAtCoords(dC(b));if(!d)return;let e=a.state.doc.resolve(d.pos),f=c&&c.slice;f?a.someProp("transformPasted",b=>{f=b(f,a,!1)}):f=dl(a,dO(b.dataTransfer),dM?null:b.dataTransfer.getData("text/html"),!1,e);let g=!!(c&&dR(a,b));if(a.someProp("handleDrop",c=>c(a,b,f||J.empty,g)))return b.preventDefault();if(!f)return;b.preventDefault();let h=f?aX(a.state.doc,e.pos,f):e.pos;null==h&&(h=e.pos);let i=a.state.tr;if(g){let{node:a}=c;a?a.replace(i):i.deleteSelection()}let j=i.mapping.map(h),k=0==f.openStart&&0==f.openEnd&&1==f.content.childCount,l=i.doc;if(k?i.replaceRangeWith(j,j,f.content.firstChild):i.replaceRange(j,j,f),i.doc.eq(l))return;let m=i.doc.resolve(j);if(k&&bf.isSelectable(f.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(f.content.firstChild))i.setSelection(new bf(m));else{let b=i.mapping.map(h);i.mapping.maps[i.mapping.maps.length-1].forEach((a,c,d,e)=>b=e),i.setSelection(c5(a,m,i.doc.resolve(b)))}a.focus(),a.dispatch(i.setMeta("uiEvent","drop"))}(a,b,a.dragging)}finally{a.dragging=null}},dv.focus=a=>{a.input.lastFocus=Date.now(),a.focused||(a.domObserver.stop(),a.dom.classList.add("ProseMirror-focused"),a.domObserver.start(),a.focused=!0,setTimeout(()=>{a.docView&&a.hasFocus()&&!a.domObserver.currentSelection.eq(a.domSelectionRange())&&c$(a)},20))},dv.blur=(a,b)=>{a.focused&&(a.domObserver.stop(),a.dom.classList.remove("ProseMirror-focused"),a.domObserver.start(),b.relatedTarget&&a.dom.contains(b.relatedTarget)&&a.domObserver.currentSelection.clear(),a.focused=!1)},dv.beforeinput=(a,b)=>{if(cf&&cl&&"deleteContentBackward"==b.inputType){a.domObserver.flushSoon();let{domChangeCount:b}=a.input;setTimeout(()=>{if(a.input.domChangeCount!=b||(a.dom.blur(),a.focus(),a.someProp("handleKeyDown",b=>b(a,b4(8,"Backspace")))))return;let{$cursor:c}=a.state.selection;c&&c.pos>0&&a.dispatch(a.state.tr.delete(c.pos-1,c.pos).scrollIntoView())},50)}},dw)dv[a]=dw[a];function dS(a,b){if(a==b)return!0;for(let c in a)if(a[c]!==b[c])return!1;for(let c in b)if(!(c in a))return!1;return!0}class dT{constructor(a,b){this.toDOM=a,this.spec=b||dY,this.side=this.spec.side||0}map(a,b,c,d){let{pos:e,deleted:f}=a.mapResult(b.from+d,this.side<0?-1:1);return f?null:new dW(e-c,e-c,this)}valid(){return!0}eq(a){return this==a||a instanceof dT&&(this.spec.key&&this.spec.key==a.spec.key||this.toDOM==a.toDOM&&dS(this.spec,a.spec))}destroy(a){this.spec.destroy&&this.spec.destroy(a)}}class dU{constructor(a,b){this.attrs=a,this.spec=b||dY}map(a,b,c,d){let e=a.map(b.from+d,this.spec.inclusiveStart?-1:1)-c,f=a.map(b.to+d,this.spec.inclusiveEnd?1:-1)-c;return e>=f?null:new dW(e,f,this)}valid(a,b){return b.from<b.to}eq(a){return this==a||a instanceof dU&&dS(this.attrs,a.attrs)&&dS(this.spec,a.spec)}static is(a){return a.type instanceof dU}destroy(){}}class dV{constructor(a,b){this.attrs=a,this.spec=b||dY}map(a,b,c,d){let e=a.mapResult(b.from+d,1);if(e.deleted)return null;let f=a.mapResult(b.to+d,-1);return f.deleted||f.pos<=e.pos?null:new dW(e.pos-c,f.pos-c,this)}valid(a,b){let{index:c,offset:d}=a.content.findIndex(b.from),e;return d==b.from&&!(e=a.child(c)).isText&&d+e.nodeSize==b.to}eq(a){return this==a||a instanceof dV&&dS(this.attrs,a.attrs)&&dS(this.spec,a.spec)}destroy(){}}class dW{constructor(a,b,c){this.from=a,this.to=b,this.type=c}copy(a,b){return new dW(a,b,this.type)}eq(a,b=0){return this.type.eq(a.type)&&this.from+b==a.from&&this.to+b==a.to}map(a,b,c){return this.type.map(a,this,b,c)}static widget(a,b,c){return new dW(a,a,new dT(b,c))}static inline(a,b,c,d){return new dW(a,b,new dU(c,d))}static node(a,b,c,d){return new dW(a,b,new dV(c,d))}get spec(){return this.type.spec}get inline(){return this.type instanceof dU}get widget(){return this.type instanceof dT}}let dX=[],dY={};class dZ{constructor(a,b){this.local=a.length?a:dX,this.children=b.length?b:dX}static create(a,b){return b.length?d3(b,a,0,dY):d$}find(a,b,c){let d=[];return this.findInner(null==a?0:a,null==b?1e9:b,d,0,c),d}findInner(a,b,c,d,e){for(let f=0;f<this.local.length;f++){let g=this.local[f];g.from<=b&&g.to>=a&&(!e||e(g.spec))&&c.push(g.copy(g.from+d,g.to+d))}for(let f=0;f<this.children.length;f+=3)if(this.children[f]<b&&this.children[f+1]>a){let g=this.children[f]+1;this.children[f+2].findInner(a-g,b-g,c,d+g,e)}}map(a,b,c){return this==d$||0==a.maps.length?this:this.mapInner(a,b,0,0,c||dY)}mapInner(a,b,c,d,e){let f;for(let g=0;g<this.local.length;g++){let h=this.local[g].map(a,c,d);h&&h.type.valid(b,h)?(f||(f=[])).push(h):e.onRemove&&e.onRemove(this.local[g].spec)}return this.children.length?function(a,b,c,d,e,f,g){let h=a.slice();for(let a=0,b=f;a<c.maps.length;a++){let d=0;c.maps[a].forEach((a,c,e,f)=>{let g=f-e-(c-a);for(let e=0;e<h.length;e+=3){let f=h[e+1];if(f<0||a>f+b-d)continue;let i=h[e]+b-d;c>=i?h[e+1]=a<=i?-2:-1:a>=b&&g&&(h[e]+=g,h[e+1]+=g)}d+=g}),b=c.maps[a].map(b,-1)}let i=!1;for(let b=0;b<h.length;b+=3)if(h[b+1]<0){if(-2==h[b+1]){i=!0,h[b+1]=-1;continue}let j=c.map(a[b]+f),k=j-e;if(k<0||k>=d.content.size){i=!0;continue}let l=c.map(a[b+1]+f,-1)-e,{index:m,offset:n}=d.content.findIndex(k),o=d.maybeChild(m);if(o&&n==k&&n+o.nodeSize==l){let d=h[b+2].mapInner(c,o,j+1,a[b]+f+1,g);d!=d$?(h[b]=k,h[b+1]=l,h[b+2]=d):(h[b+1]=-2,i=!0)}else i=!0}if(i){let i=d3(function(a,b,c,d,e,f,g){for(let h=0;h<a.length;h+=3)-1==a[h+1]&&function a(b,f){for(let a=0;a<b.local.length;a++){let h=b.local[a].map(d,e,f);h?c.push(h):g.onRemove&&g.onRemove(b.local[a].spec)}for(let c=0;c<b.children.length;c+=3)a(b.children[c+2],b.children[c]+f+1)}(a[h+2],b[h]+f+1);return c}(h,a,b,c,e,f,g),d,0,g);b=i.local;for(let a=0;a<h.length;a+=3)h[a+1]<0&&(h.splice(a,3),a-=3);for(let a=0,b=0;a<i.children.length;a+=3){let c=i.children[a];for(;b<h.length&&h[b]<c;)b+=3;h.splice(b,0,i.children[a],i.children[a+1],i.children[a+2])}}return new dZ(b.sort(d4),h)}(this.children,f||[],a,b,c,d,e):f?new dZ(f.sort(d4),dX):d$}add(a,b){return b.length?this==d$?dZ.create(a,b):this.addInner(a,b,0):this}addInner(a,b,c){let d,e=0;a.forEach((a,f)=>{let g=f+c,h;if(h=d1(b,a,g)){for(d||(d=this.children.slice());e<d.length&&d[e]<f;)e+=3;d[e]==f?d[e+2]=d[e+2].addInner(a,h,g+1):d.splice(e,0,f,f+a.nodeSize,d3(h,a,g+1,dY)),e+=3}});let f=d0(e?d2(b):b,-c);for(let b=0;b<f.length;b++)f[b].type.valid(a,f[b])||f.splice(b--,1);return new dZ(f.length?this.local.concat(f).sort(d4):this.local,d||this.children)}remove(a){return 0==a.length||this==d$?this:this.removeInner(a,0)}removeInner(a,b){let c=this.children,d=this.local;for(let d=0;d<c.length;d+=3){let e,f=c[d]+b,g=c[d+1]+b;for(let b=0,c;b<a.length;b++)(c=a[b])&&c.from>f&&c.to<g&&(a[b]=null,(e||(e=[])).push(c));if(!e)continue;c==this.children&&(c=this.children.slice());let h=c[d+2].removeInner(e,f+1);h!=d$?c[d+2]=h:(c.splice(d,3),d-=3)}if(d.length){for(let c=0,e;c<a.length;c++)if(e=a[c])for(let a=0;a<d.length;a++)d[a].eq(e,b)&&(d==this.local&&(d=this.local.slice()),d.splice(a--,1))}return c==this.children&&d==this.local?this:d.length||c.length?new dZ(d,c):d$}forChild(a,b){let c,d;if(this==d$)return this;if(b.isLeaf)return dZ.empty;for(let b=0;b<this.children.length;b+=3)if(this.children[b]>=a){this.children[b]==a&&(c=this.children[b+2]);break}let e=a+1,f=e+b.content.size;for(let a=0;a<this.local.length;a++){let b=this.local[a];if(b.from<f&&b.to>e&&b.type instanceof dU){let a=Math.max(e,b.from)-e,c=Math.min(f,b.to)-e;a<c&&(d||(d=[])).push(b.copy(a,c))}}if(d){let a=new dZ(d.sort(d4),dX);return c?new d_([a,c]):a}return c||d$}eq(a){if(this==a)return!0;if(!(a instanceof dZ)||this.local.length!=a.local.length||this.children.length!=a.children.length)return!1;for(let b=0;b<this.local.length;b++)if(!this.local[b].eq(a.local[b]))return!1;for(let b=0;b<this.children.length;b+=3)if(this.children[b]!=a.children[b]||this.children[b+1]!=a.children[b+1]||!this.children[b+2].eq(a.children[b+2]))return!1;return!0}locals(a){return d5(this.localsInner(a))}localsInner(a){if(this==d$)return dX;if(a.inlineContent||!this.local.some(dU.is))return this.local;let b=[];for(let a=0;a<this.local.length;a++)this.local[a].type instanceof dU||b.push(this.local[a]);return b}forEachSet(a){a(this)}}dZ.empty=new dZ([],[]),dZ.removeOverlap=d5;let d$=dZ.empty;class d_{constructor(a){this.members=a}map(a,b){let c=this.members.map(c=>c.map(a,b,dY));return d_.from(c)}forChild(a,b){if(b.isLeaf)return dZ.empty;let c=[];for(let d=0;d<this.members.length;d++){let e=this.members[d].forChild(a,b);e!=d$&&(e instanceof d_?c=c.concat(e.members):c.push(e))}return d_.from(c)}eq(a){if(!(a instanceof d_)||a.members.length!=this.members.length)return!1;for(let b=0;b<this.members.length;b++)if(!this.members[b].eq(a.members[b]))return!1;return!0}locals(a){let b,c=!0;for(let d=0;d<this.members.length;d++){let e=this.members[d].localsInner(a);if(e.length)if(b){c&&(b=b.slice(),c=!1);for(let a=0;a<e.length;a++)b.push(e[a])}else b=e}return b?d5(c?b:b.sort(d4)):dX}static from(a){switch(a.length){case 0:return d$;case 1:return a[0];default:return new d_(a.every(a=>a instanceof dZ)?a:a.reduce((a,b)=>a.concat(b instanceof dZ?b:b.members),[]))}}forEachSet(a){for(let b=0;b<this.members.length;b++)this.members[b].forEachSet(a)}}function d0(a,b){if(!b||!a.length)return a;let c=[];for(let d=0;d<a.length;d++){let e=a[d];c.push(new dW(e.from+b,e.to+b,e.type))}return c}function d1(a,b,c){if(b.isLeaf)return null;let d=c+b.nodeSize,e=null;for(let b=0,f;b<a.length;b++)(f=a[b])&&f.from>c&&f.to<d&&((e||(e=[])).push(f),a[b]=null);return e}function d2(a){let b=[];for(let c=0;c<a.length;c++)null!=a[c]&&b.push(a[c]);return b}function d3(a,b,c,d){let e=[],f=!1;b.forEach((b,g)=>{let h=d1(a,b,g+c);if(h){f=!0;let a=d3(h,b,c+g+1,d);a!=d$&&e.push(g,g+b.nodeSize,a)}});let g=d0(f?d2(a):a,-c).sort(d4);for(let a=0;a<g.length;a++)g[a].type.valid(b,g[a])||(d.onRemove&&d.onRemove(g[a].spec),g.splice(a--,1));return g.length||e.length?new dZ(g,e):d$}function d4(a,b){return a.from-b.from||a.to-b.to}function d5(a){let b=a;for(let c=0;c<b.length-1;c++){let d=b[c];if(d.from!=d.to)for(let e=c+1;e<b.length;e++){let f=b[e];if(f.from==d.from){f.to!=d.to&&(b==a&&(b=a.slice()),b[e]=f.copy(f.from,d.to),d6(b,e+1,f.copy(d.to,f.to)));continue}f.from<d.to&&(b==a&&(b=a.slice()),b[c]=d.copy(d.from,f.from),d6(b,e,d.copy(f.from,d.to)));break}}return b}function d6(a,b,c){for(;b<a.length&&d4(c,a[b])>0;)b++;a.splice(b,0,c)}function d7(a){let b=[];return a.someProp("decorations",c=>{let d=c(a.state);d&&d!=d$&&b.push(d)}),a.cursorWrapper&&b.push(dZ.create(a.state.doc,[a.cursorWrapper.deco])),d_.from(b)}let d8={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},d9=cb&&cc<=11;class ea{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(a){this.anchorNode=a.anchorNode,this.anchorOffset=a.anchorOffset,this.focusNode=a.focusNode,this.focusOffset=a.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(a){return a.anchorNode==this.anchorNode&&a.anchorOffset==this.anchorOffset&&a.focusNode==this.focusNode&&a.focusOffset==this.focusOffset}}class eb{constructor(a,b){this.view=a,this.handleDOMChange=b,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ea,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(b=>{for(let a=0;a<b.length;a++)this.queue.push(b[a]);cb&&cc<=11&&b.some(a=>"childList"==a.type&&a.removedNodes.length||"characterData"==a.type&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():ch&&a.composing&&b.some(a=>"childList"==a.type&&"TR"==a.target.nodeName)?(a.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),d9&&(this.onCharData=a=>{this.queue.push({target:a.target,type:"characterData",oldValue:a.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,d8)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let a=this.observer.takeRecords();if(a.length){for(let b=0;b<a.length;b++)this.queue.push(a[b]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(c6(this.view)){if(this.suppressingSelectionUpdates)return c$(this.view);if(cb&&cc<=11&&!this.view.state.selection.empty){let a=this.view.domSelectionRange();if(a.focusNode&&b$(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(a){if(!a.focusNode)return!0;let b=new Set,c;for(let c=a.focusNode;c;c=bW(c))b.add(c);for(let d=a.anchorNode;d;d=bW(d))if(b.has(d)){c=d;break}let d=c&&this.view.docView.nearestDesc(c);if(d&&d.ignoreMutation({type:"selection",target:3==c.nodeType?c.parentNode:c}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let a of this.observer.takeRecords())this.queue.push(a);return this.queue}flush(){var a;let{view:b}=this;if(!b.docView||this.flushingSoon>-1)return;let c=this.pendingRecords();c.length&&(this.queue=[]);let d=b.domSelectionRange(),e=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(d)&&c6(b)&&!this.ignoreSelectionChange(d),f=-1,g=-1,h=!1,i=[];if(b.editable)for(let a=0;a<c.length;a++){let b=this.registerMutation(c[a],i);b&&(f=f<0?b.from:Math.min(b.from,f),g=g<0?b.to:Math.max(b.to,g),b.typeOver&&(h=!0))}if(i.some(a=>"BR"==a.nodeName)&&(8==b.input.lastKeyCode||46==b.input.lastKeyCode)){for(let a of i)if("BR"==a.nodeName&&a.parentNode){let b=a.nextSibling;b&&1==b.nodeType&&"false"==b.contentEditable&&a.parentNode.removeChild(a)}}else if(cd&&i.length){let a=i.filter(a=>"BR"==a.nodeName);if(2==a.length){let[b,c]=a;b.parentNode&&b.parentNode.parentNode==c.parentNode?c.remove():b.remove()}else{let{focusNode:c}=this.currentSelection;for(let d of a){let a=d.parentNode;a&&"LI"==a.nodeName&&(!c||function(a,b){for(let c=b.parentNode;c&&c!=a.dom;c=c.parentNode){let b=a.docView.nearestDesc(c,!0);if(b&&b.node.isBlock)return c}return null}(b,c)!=a)&&d.remove()}}}let j=null;f<0&&e&&b.input.lastFocus>Date.now()-200&&Math.max(b.input.lastTouch,b.input.lastClick.time)<Date.now()-300&&b3(d)&&(j=cY(b))&&j.eq(a9.near(b.state.doc.resolve(0),1))?(b.input.lastFocus=0,c$(b),this.currentSelection.set(d),b.scrollToSelection()):(f>-1||e)&&(f>-1&&(b.docView.markDirty(f,g),a=b,!ec.has(a)&&(ec.set(a,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace))&&(a.requiresGeckoHackNode=cd,ed||(console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),ed=!0))),b.input.badSafariComposition&&(b.input.badSafariComposition=!1,function(a,b){var c;let{focusNode:d,focusOffset:e}=a.domSelectionRange();for(let f of b)if((null==(c=f.parentNode)?void 0:c.nodeName)=="TR"){let b=f.nextSibling;for(;b&&"TD"!=b.nodeName&&"TH"!=b.nodeName;)b=b.nextSibling;if(b){let c=b;for(;;){let a=c.firstChild;if(!a||1!=a.nodeType||"false"==a.contentEditable||/^(BR|IMG)$/.test(a.nodeName))break;c=a}c.insertBefore(f,c.firstChild),d==f&&a.domSelection().collapse(f,e)}else f.parentNode.removeChild(f)}}(b,i)),this.handleDOMChange(f,g,h,i),b.docView&&b.docView.dirty?b.updateState(b.state):this.currentSelection.eq(d)||c$(b),this.currentSelection.set(d))}registerMutation(a,b){if(b.indexOf(a.target)>-1)return null;let c=this.view.docView.nearestDesc(a.target);if("attributes"==a.type&&(c==this.view.docView||"contenteditable"==a.attributeName||"style"==a.attributeName&&!a.oldValue&&!a.target.getAttribute("style"))||!c||c.ignoreMutation(a))return null;if("childList"==a.type){for(let c=0;c<a.addedNodes.length;c++){let d=a.addedNodes[c];b.push(d),3==d.nodeType&&(this.lastChangedTextNode=d)}if(c.contentDOM&&c.contentDOM!=c.dom&&!c.contentDOM.contains(a.target))return{from:c.posBefore,to:c.posAfter};let d=a.previousSibling,e=a.nextSibling;if(cb&&cc<=11&&a.addedNodes.length)for(let b=0;b<a.addedNodes.length;b++){let{previousSibling:c,nextSibling:f}=a.addedNodes[b];(!c||0>Array.prototype.indexOf.call(a.addedNodes,c))&&(d=c),(!f||0>Array.prototype.indexOf.call(a.addedNodes,f))&&(e=f)}let f=d&&d.parentNode==a.target?bV(d)+1:0,g=c.localPosFromDOM(a.target,f,-1),h=e&&e.parentNode==a.target?bV(e):a.target.childNodes.length;return{from:g,to:c.localPosFromDOM(a.target,h,1)}}return"attributes"==a.type?{from:c.posAtStart-c.border,to:c.posAtEnd+c.border}:(this.lastChangedTextNode=a.target,{from:c.posAtStart,to:c.posAtEnd,typeOver:a.target.nodeValue==a.oldValue})}}let ec=new WeakMap,ed=!1;function ee(a,b){let c=b.startContainer,d=b.startOffset,e=b.endContainer,f=b.endOffset,g=a.domAtPos(a.state.selection.anchor);return b$(g.node,g.offset,e,f)&&([c,d,e,f]=[e,f,c,d]),{anchorNode:c,anchorOffset:d,focusNode:e,focusOffset:f}}function ef(a){let b=a.pmViewDesc;if(b)return b.parseRule();if("BR"==a.nodeName&&a.parentNode){if(ch&&/^(ul|ol)$/i.test(a.parentNode.nodeName)){let a=document.createElement("div");return a.appendChild(document.createElement("li")),{skip:a}}else if(a.parentNode.lastChild==a||ch&&/^(tr|table)$/i.test(a.parentNode.nodeName))return{ignore:!0}}else if("IMG"==a.nodeName&&a.getAttribute("mark-placeholder"))return{ignore:!0};return null}let eg=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function eh(a,b,c){return Math.max(c.anchor,c.head)>b.content.size?null:c5(a,b.resolve(c.anchor),b.resolve(c.head))}function ei(a,b,c){let d=a.depth,e=b?a.end():a.pos;for(;d>0&&(b||a.indexAfter(d)==a.node(d).childCount);)d--,e++,b=!1;if(c){let b=a.node(d).maybeChild(a.indexAfter(d));for(;b&&!b.isLeaf;)b=b.firstChild,e++}return e}function ej(a){if(2!=a.length)return!1;let b=a.charCodeAt(0),c=a.charCodeAt(1);return b>=56320&&b<=57343&&c>=55296&&c<=56319}class ek{constructor(a,b){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new dy,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=b,this.state=b.state,this.directPlugins=b.plugins||[],this.directPlugins.forEach(ep),this.dispatch=this.dispatch.bind(this),this.dom=a&&a.mount||document.createElement("div"),a&&(a.appendChild?a.appendChild(this.dom):"function"==typeof a?a(this.dom):a.mount&&(this.mounted=!0)),this.editable=en(this),em(this),this.nodeViews=eo(this),this.docView=cK(this.state.doc,el(this),d7(this),this.dom,this),this.domObserver=new eb(this,(a,b,c,d)=>(function(a,b,c,d,e){let f,g,h,i=a.input.compositionPendingChanges||(a.composing?a.input.compositionID:0);if(a.input.compositionPendingChanges=0,b<0){let b=a.input.lastSelectionTime>Date.now()-50?a.input.lastSelectionOrigin:null,c=cY(a,b);if(c&&!a.state.selection.eq(c)){if(cf&&cl&&13===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",b=>b(a,b4(13,"Enter"))))return;let d=a.state.tr.setSelection(c);"pointer"==b?d.setMeta("pointer",!0):"key"==b&&d.scrollIntoView(),i&&d.setMeta("composition",i),a.dispatch(d)}return}let j=a.state.doc.resolve(b),k=j.sharedDepth(c);b=j.before(k+1),c=a.state.doc.resolve(c).after(k+1);let l=a.state.selection,m=function(a,b,c){let d,{node:e,fromOffset:f,toOffset:g,from:h,to:i}=a.docView.parseRange(b,c),j=a.domSelectionRange(),k=j.anchorNode;if(k&&a.dom.contains(1==k.nodeType?k:k.parentNode)&&(d=[{node:k,offset:j.anchorOffset}],b3(j)||d.push({node:j.focusNode,offset:j.focusOffset})),cf&&8===a.input.lastKeyCode)for(let a=g;a>f;a--){let b=e.childNodes[a-1],c=b.pmViewDesc;if("BR"==b.nodeName&&!c){g=a;break}if(!c||c.size)break}let l=a.state.doc,m=a.someProp("domParser")||al.fromSchema(a.state.schema),n=l.resolve(h),o=null,p=m.parse(e,{topNode:n.parent,topMatch:n.parent.contentMatchAt(n.index()),topOpen:!0,from:f,to:g,preserveWhitespace:"pre"!=n.parent.type.whitespace||"full",findPositions:d,ruleFromNode:ef,context:n});if(d&&null!=d[0].pos){let a=d[0].pos,b=d[1]&&d[1].pos;null==b&&(b=a),o={anchor:a+h,head:b+h}}return{doc:p,sel:o,from:h,to:i}}(a,b,c),n=a.state.doc,o=n.slice(m.from,m.to);8===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime?(f=a.state.selection.to,g="end"):(f=a.state.selection.from,g="start"),a.input.lastKeyCode=null;let p=function(a,b,c,d,e){let f=a.findDiffStart(b,c);if(null==f)return null;let{a:g,b:h}=a.findDiffEnd(b,c+a.size,c+b.size);if("end"==e){let a=Math.max(0,f-Math.min(g,h));d-=g+a-f}if(g<f&&a.size<b.size){let a=d<=f&&d>=g?f-d:0;(f-=a)&&f<b.size&&ej(b.textBetween(f-1,f+1))&&(f+=a?1:-1),h=f+(h-g),g=f}else if(h<f){let b=d<=f&&d>=h?f-d:0;(f-=b)&&f<a.size&&ej(a.textBetween(f-1,f+1))&&(f+=b?1:-1),g=f+(g-h),h=f}return{start:f,endA:g,endB:h}}(o.content,m.doc.content,m.from,f,g);if(p&&a.input.domChangeCount++,(ci&&a.input.lastIOSEnter>Date.now()-225||cl)&&e.some(a=>1==a.nodeType&&!eg.test(a.nodeName))&&(!p||p.endA>=p.endB)&&a.someProp("handleKeyDown",b=>b(a,b4(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!p)if(d&&l instanceof bd&&!l.empty&&l.$head.sameParent(l.$anchor)&&!a.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(m.sel){let b=eh(a,a.state.doc,m.sel);if(b&&!b.eq(a.state.selection)){let c=a.state.tr.setSelection(b);i&&c.setMeta("composition",i),a.dispatch(c)}}return}a.state.selection.from<a.state.selection.to&&p.start==p.endB&&a.state.selection instanceof bd&&(p.start>a.state.selection.from&&p.start<=a.state.selection.from+2&&a.state.selection.from>=m.from?p.start=a.state.selection.from:p.endA<a.state.selection.to&&p.endA>=a.state.selection.to-2&&a.state.selection.to<=m.to&&(p.endB+=a.state.selection.to-p.endA,p.endA=a.state.selection.to)),cb&&cc<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>m.from&&" \xa0"==m.doc.textBetween(p.start-m.from-1,p.start-m.from+1)&&(p.start--,p.endA--,p.endB--);let q=m.doc.resolveNoCache(p.start-m.from),r=m.doc.resolveNoCache(p.endB-m.from),s=n.resolve(p.start),t=q.sameParent(r)&&q.parent.inlineContent&&s.end()>=p.endA;if((ci&&a.input.lastIOSEnter>Date.now()-225&&(!t||e.some(a=>"DIV"==a.nodeName||"P"==a.nodeName))||!t&&q.pos<m.doc.content.size&&(!q.sameParent(r)||!q.parent.inlineContent)&&q.pos<r.pos&&!/\S/.test(m.doc.textBetween(q.pos,r.pos,"","")))&&a.someProp("handleKeyDown",b=>b(a,b4(13,"Enter")))){a.input.lastIOSEnter=0;return}if(a.state.selection.anchor>p.start&&function(a,b,c,d,e){if(c-b<=e.pos-d.pos||ei(d,!0,!1)<e.pos)return!1;let f=a.resolve(b);if(!d.parent.isTextblock){let a=f.nodeAfter;return null!=a&&c==b+a.nodeSize}if(f.parentOffset<f.parent.content.size||!f.parent.isTextblock)return!1;let g=a.resolve(ei(f,!0,!0));return!(!g.parent.isTextblock||g.pos>c||ei(g,!0,!1)<c)&&d.parent.content.cut(d.parentOffset).eq(g.parent.content)}(n,p.start,p.endA,q,r)&&a.someProp("handleKeyDown",b=>b(a,b4(8,"Backspace")))){cl&&cf&&a.domObserver.suppressSelectionUpdates();return}cf&&p.endB==p.start&&(a.input.lastChromeDelete=Date.now()),cl&&!t&&q.start()!=r.start()&&0==r.parentOffset&&q.depth==r.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==p.endA&&(p.endB-=2,r=m.doc.resolveNoCache(p.endB-m.from),setTimeout(()=>{a.someProp("handleKeyDown",function(b){return b(a,b4(13,"Enter"))})},20));let u=p.start,v=p.endA,w=b=>{let c=b||a.state.tr.replace(u,v,m.doc.slice(p.start-m.from,p.endB-m.from));if(m.sel){let b=eh(a,c.doc,m.sel);b&&!(cf&&a.composing&&b.empty&&(p.start!=p.endB||a.input.lastChromeDelete<Date.now()-100)&&(b.head==u||b.head==c.mapping.map(v)-1)||cb&&b.empty&&b.head==u)&&c.setSelection(b)}return i&&c.setMeta("composition",i),c.scrollIntoView()};if(t)if(q.pos==r.pos){cb&&cc<=11&&0==q.parentOffset&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>c$(a),20));let b=w(a.state.tr.delete(u,v)),c=n.resolve(p.start).marksAcross(n.resolve(p.endA));c&&b.ensureMarks(c),a.dispatch(b)}else if(p.endA==p.endB&&(h=function(a,b){let c=a.firstChild.marks,d=b.firstChild.marks,e=c,f=d,g,h,i;for(let a=0;a<d.length;a++)e=d[a].removeFromSet(e);for(let a=0;a<c.length;a++)f=c[a].removeFromSet(f);if(1==e.length&&0==f.length)h=e[0],g="add",i=a=>a.mark(h.addToSet(a.marks));else{if(0!=e.length||1!=f.length)return null;h=f[0],g="remove",i=a=>a.mark(h.removeFromSet(a.marks))}let j=[];for(let a=0;a<b.childCount;a++)j.push(i(b.child(a)));if(D.from(j).eq(a))return{mark:h,type:g}}(q.parent.content.cut(q.parentOffset,r.parentOffset),s.parent.content.cut(s.parentOffset,p.endA-s.start())))){let b=w(a.state.tr);"add"==h.type?b.addMark(u,v,h.mark):b.removeMark(u,v,h.mark),a.dispatch(b)}else if(q.parent.child(q.index()).isText&&q.index()==r.index()-!r.textOffset){let b=q.parent.textBetween(q.parentOffset,r.parentOffset),c=()=>w(a.state.tr.insertText(b,u,v));a.someProp("handleTextInput",d=>d(a,u,v,b,c))||a.dispatch(c())}else a.dispatch(w());else a.dispatch(w())})(this,a,b,c,d)),this.domObserver.start(),function(a){for(let b in dv){let c=dv[b];a.dom.addEventListener(b,a.input.eventHandlers[b]=b=>{!function(a,b){if(!b.bubbles)return!0;if(b.defaultPrevented)return!1;for(let c=b.target;c!=a.dom;c=c.parentNode)if(!c||11==c.nodeType||c.pmViewDesc&&c.pmViewDesc.stopEvent(b))return!1;return!0}(a,b)||dB(a,b)||!a.editable&&b.type in dw||c(a,b)},dx[b]?{passive:!0}:void 0)}ch&&a.dom.addEventListener("input",()=>null),dA(a)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let a=this._props;for(let b in this._props={},a)this._props[b]=a[b];this._props.state=this.state}return this._props}update(a){a.handleDOMEvents!=this._props.handleDOMEvents&&dA(this);let b=this._props;this._props=a,a.plugins&&(a.plugins.forEach(ep),this.directPlugins=a.plugins),this.updateStateInner(a.state,b)}setProps(a){let b={};for(let a in this._props)b[a]=this._props[a];for(let c in b.state=this.state,a)b[c]=a[c];this.update(b)}updateState(a){this.updateStateInner(a,this._props)}updateStateInner(a,b){var c,d,e;let f=this.state,g=!1,h=!1;a.storedMarks&&this.composing&&(dK(this),h=!0),this.state=a;let i=f.plugins!=a.plugins||this._props.plugins!=b.plugins;if(i||this._props.plugins!=b.plugins||this._props.nodeViews!=b.nodeViews){let a=eo(this);(function(a,b){let c=0,d=0;for(let d in a){if(a[d]!=b[d])return!0;c++}for(let a in b)d++;return c!=d})(a,this.nodeViews)&&(this.nodeViews=a,g=!0)}(i||b.handleDOMEvents!=this._props.handleDOMEvents)&&dA(this),this.editable=en(this),em(this);let j=d7(this),k=el(this),l=f.plugins==a.plugins||f.doc.eq(a.doc)?a.scrollToSelection>f.scrollToSelection?"to selection":"preserve":"reset",m=g||!this.docView.matchesNode(a.doc,k,j);(m||!a.selection.eq(f.selection))&&(h=!0);let n="preserve"==l&&h&&null==this.dom.style.overflowAnchor&&function(a){let b,c,d=a.dom.getBoundingClientRect(),e=Math.max(0,d.top);for(let f=(d.left+d.right)/2,g=e+1;g<Math.min(innerHeight,d.bottom);g+=5){let d=a.root.elementFromPoint(f,g);if(!d||d==a.dom||!a.dom.contains(d))continue;let h=d.getBoundingClientRect();if(h.top>=e-20){b=d,c=h.top;break}}return{refDOM:b,refTop:c,stack:cq(a.dom)}}(this);if(h){let b,c,h;this.domObserver.stop();let i=m&&(cb||cf)&&!this.composing&&!f.selection.empty&&!a.selection.empty&&(d=f.selection,e=a.selection,h=Math.min(d.$anchor.sharedDepth(d.head),e.$anchor.sharedDepth(e.head)),d.$anchor.start(h)!=e.$anchor.start(h));if(m){let b=cf?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(a){let b=a.domSelectionRange();if(!b.focusNode)return null;let c=function(a,b){for(;;){if(3==a.nodeType&&b)return a;if(1==a.nodeType&&b>0){if("false"==a.contentEditable)return null;b=b1(a=a.childNodes[b-1])}else{if(!a.parentNode||b2(a))return null;b=bV(a),a=a.parentNode}}}(b.focusNode,b.focusOffset),d=function(a,b){for(;;){if(3==a.nodeType&&b<a.nodeValue.length)return a;if(1==a.nodeType&&b<a.childNodes.length){if("false"==a.contentEditable)return null;a=a.childNodes[b],b=0}else{if(!a.parentNode||b2(a))return null;b=bV(a)+1,a=a.parentNode}}}(b.focusNode,b.focusOffset);if(c&&d&&c!=d){let b=d.pmViewDesc,e=a.domObserver.lastChangedTextNode;if(c==e||d==e)return e;if(!b||!b.isText(d.nodeValue))return d;if(a.input.compositionNode==d){let a=c.pmViewDesc;if(!(!a||!a.isText(c.nodeValue)))return d}}return c||d}(this)),(g||!this.docView.update(a.doc,k,j,this))&&(this.docView.updateOuterDeco(k),this.docView.destroy(),this.docView=cK(a.doc,k,j,this.dom,this)),!b||this.trackWrites&&this.dom.contains(this.trackWrites)||(i=!0)}i||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(b=this.docView.domFromPos(this.state.selection.anchor,0),c=this.domSelectionRange(),b$(b.node,b.offset,c.anchorNode,c.anchorOffset)))?c$(this,i):(c3(this,a.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(f),(null==(c=this.dragging)?void 0:c.node)&&!f.doc.eq(a.doc)&&this.updateDraggedNode(this.dragging,f),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():n&&function({refDOM:a,refTop:b,stack:c}){let d=a?a.getBoundingClientRect().top:0;cr(c,0==d?0:d-b)}(n)}scrollToSelection(){let a=this.domSelectionRange().focusNode;if(a&&this.dom.contains(1==a.nodeType?a:a.parentNode))if(this.someProp("handleScrollToSelection",a=>a(this)));else if(this.state.selection instanceof bf){let b=this.docView.domAfterPos(this.state.selection.from);1==b.nodeType&&cp(this,b.getBoundingClientRect(),a)}else cp(this,this.coordsAtPos(this.state.selection.head,1),a)}destroyPluginViews(){let a;for(;a=this.pluginViews.pop();)a.destroy&&a.destroy()}updatePluginViews(a){if(a&&a.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let b=0;b<this.pluginViews.length;b++){let c=this.pluginViews[b];c.update&&c.update(this,a)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let a=0;a<this.directPlugins.length;a++){let b=this.directPlugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}for(let a=0;a<this.state.plugins.length;a++){let b=this.state.plugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}}}updateDraggedNode(a,b){let c=a.node,d=-1;if(this.state.doc.nodeAt(c.from)==c.node)d=c.from;else{let a=c.from+(this.state.doc.content.size-b.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==c.node&&(d=a)}this.dragging=new dP(a.slice,a.move,d<0?void 0:bf.create(this.state.doc,d))}someProp(a,b){let c=this._props&&this._props[a],d;if(null!=c&&(d=b?b(c):c))return d;for(let c=0;c<this.directPlugins.length;c++){let e=this.directPlugins[c].props[a];if(null!=e&&(d=b?b(e):e))return d}let e=this.state.plugins;if(e)for(let c=0;c<e.length;c++){let f=e[c].props[a];if(null!=f&&(d=b?b(f):f))return d}}hasFocus(){if(cb){let a=this.root.activeElement;if(a==this.dom)return!0;if(!a||!this.dom.contains(a))return!1;for(;a&&this.dom!=a&&this.dom.contains(a);){if("false"==a.contentEditable)return!1;a=a.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(a){if(a.setActive)return a.setActive();if(cs)return a.focus(cs);let b=cq(a);a.focus(null==cs?{get preventScroll(){return cs={preventScroll:!0},!0}}:void 0),cs||(cs=!1,cr(b,0))}(this.dom),c$(this),this.domObserver.start()}get root(){let a=this._root;if(null==a){for(let a=this.dom.parentNode;a;a=a.parentNode)if(9==a.nodeType||11==a.nodeType&&a.host)return a.getSelection||(Object.getPrototypeOf(a).getSelection=()=>a.ownerDocument.getSelection()),this._root=a}return a||document}updateRoot(){this._root=null}posAtCoords(a){return function(a,b){var c;let d,e,f=a.dom.ownerDocument,g,h=0,i=function(a,b,c){if(a.caretPositionFromPoint)try{let d=a.caretPositionFromPoint(b,c);if(d)return{node:d.offsetNode,offset:Math.min(b1(d.offsetNode),d.offset)}}catch(a){}if(a.caretRangeFromPoint){let d=a.caretRangeFromPoint(b,c);if(d)return{node:d.startContainer,offset:Math.min(b1(d.startContainer),d.startOffset)}}}(f,b.left,b.top);i&&({node:g,offset:h}=i);let j=(a.root.elementFromPoint?a.root:f).elementFromPoint(b.left,b.top);if(!j||!a.dom.contains(1!=j.nodeType?j.parentNode:j)){let c=a.dom.getBoundingClientRect();if(!ct(b,c)||!(j=function a(b,c,d){let e=b.childNodes.length;if(e&&d.top<d.bottom)for(let f=Math.max(0,Math.min(e-1,Math.floor(e*(c.top-d.top)/(d.bottom-d.top))-2)),g=f;;){let d=b.childNodes[g];if(1==d.nodeType){let b=d.getClientRects();for(let e=0;e<b.length;e++){let f=b[e];if(ct(c,f))return a(d,c,f)}}if((g=(g+1)%e)==f)break}return b}(a.dom,b,c)))return null}if(ch)for(let a=j;g&&a;a=bW(a))a.draggable&&(g=void 0);if(j=(d=(c=j).parentNode)&&/^li$/i.test(d.nodeName)&&b.left<c.getBoundingClientRect().left?d:c,g){let c;if(cd&&1==g.nodeType&&(h=Math.min(h,g.childNodes.length))<g.childNodes.length){let a=g.childNodes[h],c;"IMG"==a.nodeName&&(c=a.getBoundingClientRect()).right<=b.left&&c.bottom>b.top&&h++}cm&&h&&1==g.nodeType&&1==(c=g.childNodes[h-1]).nodeType&&"false"==c.contentEditable&&c.getBoundingClientRect().top>=b.top&&h--,g==a.dom&&h==g.childNodes.length-1&&1==g.lastChild.nodeType&&b.top>g.lastChild.getBoundingClientRect().bottom?e=a.state.doc.content.size:(0==h||1!=g.nodeType||"BR"!=g.childNodes[h-1].nodeName)&&(e=function(a,b,c,d){let e=-1;for(let c=b,f=!1;c!=a.dom;){let b=a.docView.nearestDesc(c,!0),g;if(!b)return null;if(1==b.dom.nodeType&&(b.node.isBlock&&b.parent||!b.contentDOM)&&((g=b.dom.getBoundingClientRect()).width||g.height)&&(b.node.isBlock&&b.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(b.dom.nodeName)&&(!f&&g.left>d.left||g.top>d.top?e=b.posBefore:(!f&&g.right<d.left||g.bottom<d.top)&&(e=b.posAfter),f=!0),!b.contentDOM&&e<0&&!b.node.isText))return(b.node.isBlock?d.top<(g.top+g.bottom)/2:d.left<(g.left+g.right)/2)?b.posBefore:b.posAfter;c=b.dom.parentNode}return e>-1?e:a.docView.posFromDOM(b,c,-1)}(a,g,h,b))}null==e&&(e=function(a,b,c){let{node:d,offset:e}=function a(b,c){let d,e,f,g=2e8,h,i=0,j=c.top,k=c.top;for(let a=b.firstChild,l=0;a;a=a.nextSibling,l++){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=bY(a).getClientRects()}for(let m=0;m<b.length;m++){let n=b[m];if(n.top<=j&&n.bottom>=k){j=Math.max(n.bottom,j),k=Math.min(n.top,k);let b=n.left>c.left?n.left-c.left:n.right<c.left?c.left-n.right:0;if(b<g){f=a,g=b,h=b&&3==f.nodeType?{left:n.right<c.left?n.right:n.left,top:c.top}:c,1==a.nodeType&&b&&(i=l+ +(c.left>=(n.left+n.right)/2));continue}}else n.top>c.top&&!d&&n.left<=c.left&&n.right>=c.left&&(d=a,e={left:Math.max(n.left,Math.min(n.right,c.left)),top:n.top});!f&&(c.left>=n.right&&c.top>=n.top||c.left>=n.left&&c.top>=n.bottom)&&(i=l+1)}}return(!f&&d&&(f=d,h=e,g=0),f&&3==f.nodeType)?function(a,b){let c=a.nodeValue.length,d=document.createRange(),e;for(let f=0;f<c;f++){d.setEnd(a,f+1),d.setStart(a,f);let c=cv(d,1);if(c.top!=c.bottom&&ct(b,c)){e={node:a,offset:f+ +(b.left>=(c.left+c.right)/2)};break}}return d.detach(),e||{node:a,offset:0}}(f,h):!f||g&&1==f.nodeType?{node:b,offset:i}:a(f,h)}(b,c),f=-1;if(1==d.nodeType&&!d.firstChild){let a=d.getBoundingClientRect();f=a.left!=a.right&&c.left>(a.left+a.right)/2?1:-1}return a.docView.posFromDOM(d,e,f)}(a,j,b));let k=a.docView.nearestDesc(j,!0);return{pos:e,inside:k?k.posAtStart-k.border:-1}}(this,a)}coordsAtPos(a,b=1){return cx(this,a,b)}domAtPos(a,b=0){return this.docView.domFromPos(a,b)}nodeDOM(a){let b=this.docView.descAt(a);return b?b.nodeDOM:null}posAtDOM(a,b,c=-1){let d=this.docView.posFromDOM(a,b,c);if(null==d)throw RangeError("DOM position not inside the editor");return d}endOfTextblock(a,b){return function(a,b,c){let d,e;return cC==b&&cD==c?cE:(cC=b,cD=c,cE="up"==c||"down"==c?(d=b.selection,e="up"==c?d.$from:d.$to,cA(a,b,()=>{let{node:b}=a.docView.domFromPos(e.pos,"up"==c?-1:1);for(;;){let c=a.docView.nearestDesc(b,!0);if(!c)break;if(c.node.isBlock){b=c.contentDOM||c.dom;break}b=c.dom.parentNode}let d=cx(a,e.pos,1);for(let a=b.firstChild;a;a=a.nextSibling){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=bY(a,0,a.nodeValue.length).getClientRects()}for(let a=0;a<b.length;a++){let e=b[a];if(e.bottom>e.top+1&&("up"==c?d.top-e.top>(e.bottom-d.top)*2:e.bottom-d.bottom>(d.bottom-e.top)*2))return!1}}return!0})):function(a,b,c){let{$head:d}=b.selection;if(!d.parent.isTextblock)return!1;let e=d.parentOffset,f=e==d.parent.content.size,g=a.domSelection();return g?cB.test(d.parent.textContent)&&g.modify?cA(a,b,()=>{let{focusNode:b,focusOffset:e,anchorNode:f,anchorOffset:h}=a.domSelectionRange(),i=g.caretBidiLevel;g.modify("move",c,"character");let j=d.depth?a.docView.domAfterPos(d.before()):a.dom,{focusNode:k,focusOffset:l}=a.domSelectionRange(),m=k&&!j.contains(1==k.nodeType?k:k.parentNode)||b==k&&e==l;try{g.collapse(f,h),b&&(b!=f||e!=h)&&g.extend&&g.extend(b,e)}catch(a){}return null!=i&&(g.caretBidiLevel=i),m}):"left"==c||"backward"==c?!e:f:d.pos==d.start()||d.pos==d.end()}(a,b,c))}(this,b||this.state,a)}pasteHTML(a,b){return dN(this,"",a,!1,b||new ClipboardEvent("paste"))}pasteText(a,b){return dN(this,a,null,!0,b||new ClipboardEvent("paste"))}serializeForClipboard(a){return dk(this,a)}destroy(){if(this.docView){for(let a in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(a,this.input.eventHandlers[a]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],d7(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,bZ()}}get isDestroyed(){return null==this.docView}dispatchEvent(a){!dB(this,a)&&dv[a.type]&&(this.editable||!(a.type in dw))&&dv[a.type](this,a)}domSelectionRange(){let a=this.domSelection();return a?ch&&11===this.root.nodeType&&function(a){let b=a.activeElement;for(;b&&b.shadowRoot;)b=b.shadowRoot.activeElement;return b}(this.dom.ownerDocument)==this.dom&&function(a,b){let c;if(b.getComposedRanges){let c=b.getComposedRanges(a.root)[0];if(c)return ee(a,c)}function d(a){a.preventDefault(),a.stopImmediatePropagation(),c=a.getTargetRanges()[0]}return a.dom.addEventListener("beforeinput",d,!0),document.execCommand("indent"),a.dom.removeEventListener("beforeinput",d,!0),c?ee(a,c):null}(this,a)||a:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function el(a){let b=Object.create(null);return b.class="ProseMirror",b.contenteditable=String(a.editable),a.someProp("attributes",c=>{if("function"==typeof c&&(c=c(a.state)),c)for(let a in c)"class"==a?b.class+=" "+c[a]:"style"==a?b.style=(b.style?b.style+";":"")+c[a]:b[a]||"contenteditable"==a||"nodeName"==a||(b[a]=String(c[a]))}),b.translate||(b.translate="no"),[dW.node(0,a.state.doc.content.size,b)]}function em(a){if(a.markCursor){let b=document.createElement("img");b.className="ProseMirror-separator",b.setAttribute("mark-placeholder","true"),b.setAttribute("alt",""),a.cursorWrapper={dom:b,deco:dW.widget(a.state.selection.from,b,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function en(a){return!a.someProp("editable",b=>!1===b(a.state))}function eo(a){let b=Object.create(null);function c(a){for(let c in a)Object.prototype.hasOwnProperty.call(b,c)||(b[c]=a[c])}return a.someProp("nodeViews",c),a.someProp("markViews",c),b}function ep(a){if(a.spec.state||a.spec.filterTransaction||a.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}ek.prototype.dispatch=function(a){let b=this._props.dispatchTransaction;b?b.call(this,a):this.updateState(this.state.apply(a))};for(var eq={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},er={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},es="u">typeof navigator&&/Mac/.test(navigator.platform),et="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),eu=0;eu<10;eu++)eq[48+eu]=eq[96+eu]=String(eu);for(var eu=1;eu<=24;eu++)eq[eu+111]="F"+eu;for(var eu=65;eu<=90;eu++)eq[eu]=String.fromCharCode(eu+32),er[eu]=String.fromCharCode(eu);for(var ev in eq)er.hasOwnProperty(ev)||(er[ev]=eq[ev]);let ew="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ex="u">typeof navigator&&/Win/.test(navigator.platform);function ey(a,b,c=!0){return b.altKey&&(a="Alt-"+a),b.ctrlKey&&(a="Ctrl-"+a),b.metaKey&&(a="Meta-"+a),c&&b.shiftKey&&(a="Shift-"+a),a}function ez(a){let b=function(a){let b=Object.create(null);for(let c in a)b[function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"==g&&(g=" ");for(let a=0;a<f.length-1;a++){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))ew?e=!0:c=!0;else throw Error("Unrecognized modifier name: "+g)}return b&&(g="Alt-"+g),c&&(g="Ctrl-"+g),e&&(g="Meta-"+g),d&&(g="Shift-"+g),g}(c)]=a[c];return b}(a);return function(a,c){var d;let e=("Esc"==(d=!(es&&c.metaKey&&c.shiftKey&&!c.ctrlKey&&!c.altKey||et&&c.shiftKey&&c.key&&1==c.key.length||"Unidentified"==c.key)&&c.key||(c.shiftKey?er:eq)[c.keyCode]||c.key||"Unidentified")&&(d="Escape"),"Del"==d&&(d="Delete"),"Left"==d&&(d="ArrowLeft"),"Up"==d&&(d="ArrowUp"),"Right"==d&&(d="ArrowRight"),"Down"==d&&(d="ArrowDown"),d),f,g=b[ey(e,c)];if(g&&g(a.state,a.dispatch,a))return!0;if(1==e.length&&" "!=e){if(c.shiftKey){let d=b[ey(e,c,!1)];if(d&&d(a.state,a.dispatch,a))return!0}if((c.altKey||c.metaKey||c.ctrlKey)&&!(ex&&c.ctrlKey&&c.altKey)&&(f=eq[c.keyCode])&&f!=e){let d=b[ey(f,c)];if(d&&d(a.state,a.dispatch,a))return!0}}return!1}}var eA=Object.defineProperty,eB=(a,b)=>{for(var c in b)eA(a,c,{get:b[c],enumerable:!0})};function eC(a){let{state:b,transaction:c}=a,{selection:d}=c,{doc:e}=c,{storedMarks:f}=c;return{...b,apply:b.apply.bind(b),applyTransaction:b.applyTransaction.bind(b),plugins:b.plugins,schema:b.schema,reconfigure:b.reconfigure.bind(b),toJSON:b.toJSON.bind(b),get storedMarks(){return f},get selection(){return d},get doc(){return e},get tr(){return d=c.selection,e=c.doc,f=c.storedMarks,c}}}var eD=class{constructor(a){this.editor=a.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=a.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:a,editor:b,state:c}=this,{view:d}=b,{tr:e}=c,f=this.buildProps(e);return Object.fromEntries(Object.entries(a).map(([a,b])=>[a,(...a)=>{let c=b(...a)(f);return e.getMeta("preventDispatch")||this.hasCustomState||d.dispatch(e),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g=[],h=!!a,i=a||e.tr,j=()=>(h||!b||i.getMeta("preventDispatch")||this.hasCustomState||f.dispatch(i),g.every(a=>!0===a)),k={...Object.fromEntries(Object.entries(c).map(([a,c])=>[a,(...a)=>{let d=this.buildProps(i,b),e=c(...a)(d);return g.push(e),k}])),run:j};return k}createCan(a){let{rawCommands:b,state:c}=this,d=a||c.tr,e=this.buildProps(d,!1);return{...Object.fromEntries(Object.entries(b).map(([a,b])=>[a,(...a)=>b(...a)({...e,dispatch:void 0})])),chain:()=>this.createChain(d,!1)}}buildProps(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g={tr:a,editor:d,view:f,state:eC({state:e,transaction:a}),dispatch:b?()=>void 0:void 0,chain:()=>this.createChain(a,b),can:()=>this.createCan(a),get commands(){return Object.fromEntries(Object.entries(c).map(([a,b])=>[a,(...a)=>b(...a)(g)]))}};return g}},eE={};eB(eE,{blur:()=>eF,clearContent:()=>eG,clearNodes:()=>eH,command:()=>eI,createParagraphNear:()=>eJ,cut:()=>eK,deleteCurrentNode:()=>eL,deleteNode:()=>eN,deleteRange:()=>eO,deleteSelection:()=>eP,enter:()=>eQ,exitCode:()=>eR,extendMarkRange:()=>eY,first:()=>eZ,focus:()=>e3,forEach:()=>e4,insertContent:()=>e5,insertContentAt:()=>e9,joinBackward:()=>fc,joinDown:()=>fb,joinForward:()=>fd,joinItemBackward:()=>fe,joinItemForward:()=>ff,joinTextblockBackward:()=>fg,joinTextblockForward:()=>fh,joinUp:()=>fa,keyboardShortcut:()=>fj,lift:()=>fl,liftEmptyBlock:()=>fm,liftListItem:()=>fn,newlineInCode:()=>fo,resetAttributes:()=>fr,scrollIntoView:()=>fs,selectAll:()=>ft,selectNodeBackward:()=>fu,selectNodeForward:()=>fv,selectParentNode:()=>fw,selectTextblockEnd:()=>fx,selectTextblockStart:()=>fy,setContent:()=>fA,setMark:()=>f6,setMeta:()=>f7,setNode:()=>f8,setNodeSelection:()=>f9,setTextDirection:()=>ga,setTextSelection:()=>gb,sinkListItem:()=>gc,splitBlock:()=>ge,splitListItem:()=>gf,toggleList:()=>gi,toggleMark:()=>gj,toggleNode:()=>gk,toggleWrap:()=>gl,undoInputRule:()=>gm,unsetAllMarks:()=>gn,unsetMark:()=>go,unsetTextDirection:()=>gp,updateAttributes:()=>gq,wrapIn:()=>gr,wrapInList:()=>gs});var eF=()=>({editor:a,view:b})=>(requestAnimationFrame(()=>{var c;a.isDestroyed||(b.dom.blur(),null==(c=null==window?void 0:window.getSelection())||c.removeAllRanges())}),!0),eG=(a=!0)=>({commands:b})=>b.setContent("",{emitUpdate:a}),eH=()=>({state:a,tr:b,dispatch:c})=>{let{selection:d}=b,{ranges:e}=d;return!c||(e.forEach(({$from:c,$to:d})=>{a.doc.nodesBetween(c.pos,d.pos,(a,c)=>{if(a.type.isText)return;let{doc:d,mapping:e}=b,f=d.resolve(e.map(c)),g=d.resolve(e.map(c+a.nodeSize)),h=f.blockRange(g);if(!h)return;let i=aO(h);if(a.type.isTextblock){let{defaultType:a}=f.parent.contentMatchAt(f.index());b.setNodeMarkup(h.start,a)}(i||0===i)&&b.lift(h,i)})}),!0)},eI=a=>b=>a(b),eJ=()=>({state:a,dispatch:b})=>bJ(a,b),eK=(a,b)=>({editor:c,tr:d})=>{let{state:e}=c,f=e.doc.slice(a.from,a.to);d.deleteRange(a.from,a.to);let g=d.mapping.map(b);return d.insert(g,f.content),d.setSelection(new bd(d.doc.resolve(Math.max(g-1,0)))),!0},eL=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,d=c.$anchor.node();if(d.content.size>0)return!1;let e=a.selection.$anchor;for(let c=e.depth;c>0;c-=1)if(e.node(c).type===d.type){if(b){let b=e.before(c),d=e.after(c);a.delete(b,d).scrollIntoView()}return!0}return!1};function eM(a,b){if("string"==typeof a){if(!b.nodes[a])throw Error(`There is no node type named '${a}'. Maybe you forgot to add the extension?`);return b.nodes[a]}return a}var eN=a=>({tr:b,state:c,dispatch:d})=>{let e=eM(a,c.schema),f=b.selection.$anchor;for(let a=f.depth;a>0;a-=1)if(f.node(a).type===e){if(d){let c=f.before(a),d=f.after(a);b.delete(c,d).scrollIntoView()}return!0}return!1},eO=a=>({tr:b,dispatch:c})=>{let{from:d,to:e}=a;return c&&b.delete(d,e),!0},eP=()=>({state:a,dispatch:b})=>bv(a,b),eQ=()=>({commands:a})=>a.keyboardShortcut("Enter"),eR=()=>({state:a,dispatch:b})=>bI(a,b);function eS(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function eT(a,b,c={strict:!0}){let d=Object.keys(b);return!d.length||d.every(d=>c.strict?b[d]===a[d]:eS(b[d])?b[d].test(a[d]):b[d]===a[d])}function eU(a,b,c={}){return a.find(a=>a.type===b&&eT(Object.fromEntries(Object.keys(c).map(b=>[b,a.attrs[b]])),c))}function eV(a,b,c={}){return!!eU(a,b,c)}function eW(a,b,c){var d;if(!a||!b)return;let e=a.parent.childAfter(a.parentOffset);if(e.node&&e.node.marks.some(a=>a.type===b)||(e=a.parent.childBefore(a.parentOffset)),!e.node||!e.node.marks.some(a=>a.type===b)||(c=c||(null==(d=e.node.marks[0])?void 0:d.attrs),!eU([...e.node.marks],b,c)))return;let f=e.index,g=a.start()+e.offset,h=f+1,i=g+e.node.nodeSize;for(;f>0&&eV([...a.parent.child(f-1).marks],b,c);)f-=1,g-=a.parent.child(f).nodeSize;for(;h<a.parent.childCount&&eV([...a.parent.child(h).marks],b,c);)i+=a.parent.child(h).nodeSize,h+=1;return{from:g,to:i}}function eX(a,b){if("string"==typeof a){if(!b.marks[a])throw Error(`There is no mark type named '${a}'. Maybe you forgot to add the extension?`);return b.marks[a]}return a}var eY=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=eX(a,d.schema),{doc:g,selection:h}=c,{$from:i,from:j,to:k}=h;if(e){let a=eW(i,f,b);if(a&&a.from<=j&&a.to>=k){let b=bd.create(g,a.from,a.to);c.setSelection(b)}}return!0},eZ=a=>b=>{let c="function"==typeof a?a(b):a;for(let a=0;a<c.length;a+=1)if(c[a](b))return!0;return!1};function e$(a){return a instanceof bd}function e_(a=0,b=0,c=0){return Math.min(Math.max(a,b),c)}function e0(a,b=null){if(!b)return null;let c=a9.atStart(a),d=a9.atEnd(a);if("start"===b||!0===b)return c;if("end"===b)return d;let e=c.from,f=d.to;return"all"===b?bd.create(a,e_(0,e,f),e_(a.content.size,e,f)):bd.create(a,e_(b,e,f),e_(b,e,f))}function e1(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function e2(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var e3=(a=null,b={})=>({editor:c,view:d,tr:e,dispatch:f})=>{b={scrollIntoView:!0,...b};let g=()=>{(e2()||e1())&&d.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!e2()&&!e1()&&d.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!c.isDestroyed&&(d.focus(),(null==b?void 0:b.scrollIntoView)&&c.commands.scrollIntoView())})};try{if(d.hasFocus()&&null===a||!1===a)return!0}catch{return!1}if(f&&null===a&&!e$(c.state.selection))return g(),!0;let h=e0(e.doc,a)||c.state.selection,i=c.state.selection.eq(h);return f&&(i||e.setSelection(h),i&&e.storedMarks&&e.setStoredMarks(e.storedMarks),g()),!0},e4=(a,b)=>c=>a.every((a,d)=>b(a,{...c,index:d})),e5=(a,b)=>({tr:c,commands:d})=>d.insertContentAt({from:c.selection.from,to:c.selection.to},a,b),e6=a=>{let b=a.childNodes;for(let c=b.length-1;c>=0;c-=1){let d=b[c];3===d.nodeType&&d.nodeValue&&/^(\n\s\s|\n)$/.test(d.nodeValue)?a.removeChild(d):1===d.nodeType&&e6(d)}return a};function e7(a){if("u"<typeof window)throw Error("[tiptap error]: there is no window object available, so this function cannot be used");let b=`<body>${a}</body>`;return e6(new window.DOMParser().parseFromString(b,"text/html").body)}function e8(a,b,c){if(a instanceof W||a instanceof D)return a;c={slice:!0,parseOptions:{},...c};let d="object"==typeof a&&null!==a,e="string"==typeof a;if(d)try{if(Array.isArray(a)&&a.length>0)return D.fromArray(a.map(a=>b.nodeFromJSON(a)));let d=b.nodeFromJSON(a);return c.errorOnInvalidContent&&d.check(),d}catch(d){if(c.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:d});return console.warn("[tiptap warn]: Invalid content.","Passed value:",a,"Error:",d),e8("",b,c)}if(e){if(c.errorOnInvalidContent){let d=!1,e="",f=new aj({topNode:b.spec.topNode,marks:b.spec.marks,nodes:b.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:a=>(d=!0,e="string"==typeof a?a:a.outerHTML,null)}]}})});if(c.slice?al.fromSchema(f).parseSlice(e7(a),c.parseOptions):al.fromSchema(f).parse(e7(a),c.parseOptions),c.errorOnInvalidContent&&d)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${e}`)})}let d=al.fromSchema(b);return c.slice?d.parseSlice(e7(a),c.parseOptions).content:d.parse(e7(a),c.parseOptions)}return e8("",b,c)}var e9=(a,b,c)=>({tr:d,dispatch:e,editor:f})=>{var g;if(e){let e,h;c={parseOptions:f.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...c};let i=a=>{f.emit("contentError",{editor:f,error:a,disableCollaboration:()=>{"collaboration"in f.storage&&"object"==typeof f.storage.collaboration&&f.storage.collaboration&&(f.storage.collaboration.isDisabled=!0)}})},j={preserveWhitespace:"full",...c.parseOptions};if(!c.errorOnInvalidContent&&!f.options.enableContentCheck&&f.options.emitContentError)try{e8(b,f.schema,{parseOptions:j,errorOnInvalidContent:!0})}catch(a){i(a)}try{e=e8(b,f.schema,{parseOptions:j,errorOnInvalidContent:null!=(g=c.errorOnInvalidContent)?g:f.options.enableContentCheck})}catch(a){return i(a),!1}let{from:k,to:l}="number"==typeof a?{from:a,to:a}:{from:a.from,to:a.to},m=!0,n=!0;if((!("type"in e)?e:[e]).forEach(a=>{a.check(),m=!!m&&a.isText&&0===a.marks.length,n=!!n&&a.isBlock}),k===l&&n){let{parent:a}=d.doc.resolve(k);!a.isTextblock||a.type.spec.code||a.childCount||(k-=1,l+=1)}if(m){if(Array.isArray(b))h=b.map(a=>a.text||"").join("");else if(b instanceof D){let a="";b.forEach(b=>{b.text&&(a+=b.text)}),h=a}else h="object"==typeof b&&b&&b.text?b.text:b;d.insertText(h,k,l)}else{h=e;let a=d.doc.resolve(k),b=a.node(),c=0===a.parentOffset,f=b.isText||b.isTextblock,g=b.content.size>0;c&&f&&g&&(k=Math.max(0,k-1)),d.replaceWith(k,l,h)}c.updateSelection&&function(a,b){let c=a.steps.length-1;if(c<b)return;let d=a.steps[c];if(!(d instanceof aK||d instanceof aL))return;let e=a.mapping.maps[c],f=0;e.forEach((a,b,c,d)=>{0===f&&(f=d)}),a.setSelection(a9.near(a.doc.resolve(f),-1))}(d,d.steps.length-1),c.applyInputRules&&d.setMeta("applyInputRules",{from:k,text:h}),c.applyPasteRules&&d.setMeta("applyPasteRules",{from:k,text:h})}return!0},fa=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d=c instanceof bf,e;if(d){if(c.node.isTextblock||!aU(a.doc,c.from))return!1;e=c.from}else if(null==(e=aW(a.doc,c.from,-1)))return!1;if(b){let c=a.tr.join(e);d&&c.setSelection(bf.create(c.doc,e-a.doc.resolve(e).nodeBefore.nodeSize)),b(c.scrollIntoView())}return!0})(a,b),fb=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d;if(c instanceof bf){if(c.node.isTextblock||!aU(a.doc,c.to))return!1;d=c.to}else if(null==(d=aW(a.doc,c.to,1)))return!1;return b&&b(a.tr.join(d).scrollIntoView()),!0})(a,b),fc=()=>({state:a,dispatch:b})=>bx(a,b),fd=()=>({state:a,dispatch:b})=>bD(a,b),fe=()=>({state:a,dispatch:b,tr:c})=>{try{let d=aW(a.doc,a.selection.$from.pos,-1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},ff=()=>({state:a,dispatch:b,tr:c})=>{try{let d=aW(a.doc,a.selection.$from.pos,1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},fg=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=bw(a,c);if(!d)return!1;let e=bB(d);return!!e&&by(a,e,b)})(a,b),fh=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=bC(a,c);if(!d)return!1;let e=bF(d);return!!e&&by(a,e,b)})(a,b);function fi(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var fj=a=>({editor:b,view:c,tr:d,dispatch:e})=>{let f=(function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"===g&&(g=" ");for(let a=0;a<f.length-1;a+=1){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))e2()||fi()?e=!0:c=!0;else throw Error(`Unrecognized modifier name: ${g}`)}return b&&(g=`Alt-${g}`),c&&(g=`Ctrl-${g}`),e&&(g=`Meta-${g}`),d&&(g=`Shift-${g}`),g})(a).split(/-(?!$)/),g=f.find(a=>!["Alt","Ctrl","Meta","Shift"].includes(a)),h=new KeyboardEvent("keydown",{key:"Space"===g?" ":g,altKey:f.includes("Alt"),ctrlKey:f.includes("Ctrl"),metaKey:f.includes("Meta"),shiftKey:f.includes("Shift"),bubbles:!0,cancelable:!0}),i=b.captureTransaction(()=>{c.someProp("handleKeyDown",a=>a(c,h))});return null==i||i.steps.forEach(a=>{let b=a.map(d.mapping);b&&e&&d.maybeStep(b)}),!0};function fk(a,b,c={}){let{from:d,to:e,empty:f}=a.selection,g=b?eM(b,a.schema):null,h=[];a.doc.nodesBetween(d,e,(a,b)=>{if(a.isText)return;let c=Math.max(d,b),f=Math.min(e,b+a.nodeSize);h.push({node:a,from:c,to:f})});let i=e-d,j=h.filter(a=>!g||g.name===a.node.type.name).filter(a=>eT(a.node.attrs,c,{strict:!1}));return f?!!j.length:j.reduce((a,b)=>a+b.to-b.from,0)>=i}var fl=(a,b={})=>({state:c,dispatch:d})=>{let e=eM(a,c.schema);return!!fk(c,e,b)&&((a,b)=>{let{$from:c,$to:d}=a.selection,e=c.blockRange(d),f=e&&aO(e);return null!=f&&(b&&b(a.tr.lift(e,f).scrollIntoView()),!0)})(c,d)},fm=()=>({state:a,dispatch:b})=>bK(a,b),fn=a=>({state:b,dispatch:c})=>{var d;return(d=eM(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);return!!f&&(!b||(c.node(f.depth-1).type==d?function(a,b,c,d){let e=a.tr,f=d.end,g=d.$to.end(d.depth);f<g&&(e.step(new aL(f-1,g,f,g,new J(D.from(c.create(null,d.parent.copy())),1,0),1,!0)),d=new U(e.doc.resolve(d.$from.pos),e.doc.resolve(g),d.depth));let h=aO(d);if(null==h)return!1;e.lift(d,h);let i=e.doc.resolve(e.mapping.map(f,-1)-1);return aU(e.doc,i.pos)&&i.nodeBefore.type==i.nodeAfter.type&&e.join(i.pos),b(e.scrollIntoView()),!0}(a,b,d,f):function(a,b,c){let d=a.tr,e=c.parent;for(let a=c.end,b=c.endIndex-1,f=c.startIndex;b>f;b--)a-=e.child(b).nodeSize,d.delete(a-1,a+1);let f=d.doc.resolve(c.start),g=f.nodeAfter;if(d.mapping.map(c.end)!=c.start+f.nodeAfter.nodeSize)return!1;let h=0==c.startIndex,i=c.endIndex==e.childCount,j=f.node(-1),k=f.index(-1);if(!j.canReplace(k+ +!h,k+1,g.content.append(i?D.empty:D.from(e))))return!1;let l=f.pos,m=l+g.nodeSize;return d.step(new aL(l-!!h,m+ +!!i,l+1,m-1,new J((h?D.empty:D.from(e.copy(D.empty))).append(i?D.empty:D.from(e.copy(D.empty))),+!h,+!i),+!h)),b(d.scrollIntoView()),!0}(a,b,f)))})(b,c)},fo=()=>({state:a,dispatch:b})=>bG(a,b);function fp(a,b){return b.nodes[a]?"node":b.marks[a]?"mark":null}function fq(a,b){let c="string"==typeof b?[b]:b;return Object.keys(a).reduce((b,d)=>(c.includes(d)||(b[d]=a[d]),b),{})}var fr=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=fp("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=eM(a,d.schema)),"mark"===h&&(g=eX(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{d.doc.nodesBetween(a.$from.pos,a.$to.pos,(a,d)=>{f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,fq(a.attrs,b))),g&&a.marks.length&&a.marks.forEach(f=>{g===f.type&&(i=!0,e&&c.addMark(d,d+a.nodeSize,g.create(fq(f.attrs,b))))})})}),i},fs=()=>({tr:a,dispatch:b})=>(b&&a.scrollIntoView(),!0),ft=()=>({tr:a,dispatch:b})=>{if(b){let b=new bh(a.doc);a.setSelection(b)}return!0},fu=()=>({state:a,dispatch:b})=>bA(a,b),fv=()=>({state:a,dispatch:b})=>bE(a,b),fw=()=>({state:a,dispatch:b})=>((a,b)=>{let{$from:c,to:d}=a.selection,e,f=c.sharedDepth(d);return 0!=f&&(e=c.before(f),b&&b(a.tr.setSelection(bf.create(a.doc,e))),!0)})(a,b),fx=()=>({state:a,dispatch:b})=>bO(a,b),fy=()=>({state:a,dispatch:b})=>bN(a,b);function fz(a,b,c={},d={}){return e8(a,b,{slice:!1,parseOptions:c,errorOnInvalidContent:d.errorOnInvalidContent})}var fA=(a,{errorOnInvalidContent:b,emitUpdate:c=!0,parseOptions:d={}}={})=>({editor:e,tr:f,dispatch:g,commands:h})=>{let{doc:i}=f;if("full"!==d.preserveWhitespace){let h=fz(a,e.schema,d,{errorOnInvalidContent:null!=b?b:e.options.enableContentCheck});return g&&f.replaceWith(0,i.content.size,h).setMeta("preventUpdate",!c),!0}return g&&f.setMeta("preventUpdate",!c),h.insertContentAt({from:0,to:i.content.size},a,{parseOptions:d,errorOnInvalidContent:null!=b?b:e.options.enableContentCheck})};function fB(a,b){let c=eX(b,a.schema),{from:d,to:e,empty:f}=a.selection,g=[];f?(a.storedMarks&&g.push(...a.storedMarks),g.push(...a.selection.$head.marks())):a.doc.nodesBetween(d,e,a=>{g.push(...a.marks)});let h=g.find(a=>a.type.name===c.name);return h?{...h.attrs}:{}}function fC(a,b){let c=new a7(a);return b.forEach(a=>{a.steps.forEach(a=>{c.step(a)})}),c}function fD(a,b){for(let c=a.depth;c>0;c-=1){let d=a.node(c);if(b(d))return{pos:c>0?a.before(c):0,start:a.start(c),depth:c,node:d}}}function fE(a){return b=>fD(b.$from,a)}function fF(a,b,c){return void 0===a.config[b]&&a.parent?fF(a.parent,b,c):"function"==typeof a.config[b]?a.config[b].bind({...c,parent:a.parent?fF(a.parent,b,c):null}):a.config[b]}function fG(a){return a.map(a=>{let b={name:a.name,options:a.options,storage:a.storage},c=fF(a,"addExtensions",b);return c?[a,...fG(c())]:a}).flat(10)}function fH(a,b){let c=au.fromSchema(b).serializeFragment(a),d=document.implementation.createHTMLDocument().createElement("div");return d.appendChild(c),d.innerHTML}function fI(a){return"function"==typeof a}function fJ(a,b,...c){return fI(a)?b?a.bind(b)(...c):a(...c):a}function fK(a){let b=a.filter(a=>"extension"===a.type);return{baseExtensions:b,nodeExtensions:a.filter(a=>"node"===a.type),markExtensions:a.filter(a=>"mark"===a.type)}}function fL(a){let b=[],{nodeExtensions:c,markExtensions:d}=fK(a),e=[...c,...d],f={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},g=c.filter(a=>"text"!==a.name).map(a=>a.name),h=d.map(a=>a.name),i=[...g,...h];return a.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage,extensions:e},d=fF(a,"addGlobalAttributes",c);d&&d().forEach(a=>{(Array.isArray(a.types)?a.types:"*"===a.types?i:"nodes"===a.types?g:"marks"===a.types?h:[]).forEach(c=>{Object.entries(a.attributes).forEach(([a,d])=>{b.push({type:c,name:a,attribute:{...f,...d}})})})})}),e.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage},d=fF(a,"addAttributes",c);d&&Object.entries(d()).forEach(([c,d])=>{let e={...f,...d};"function"==typeof(null==e?void 0:e.default)&&(e.default=e.default()),(null==e?void 0:e.isRequired)&&(null==e?void 0:e.default)===void 0&&delete e.default,b.push({type:a.name,name:c,attribute:e})})}),b}function fM(...a){return a.filter(a=>!!a).reduce((a,b)=>{let c={...a};return Object.entries(b).forEach(([a,b])=>{if(!c[a]){c[a]=b;return}if("class"===a){let d=b?String(b).split(" "):[],e=c[a]?c[a].split(" "):[],f=d.filter(a=>!e.includes(a));c[a]=[...e,...f].join(" ")}else if("style"===a){let d=b?b.split(";").map(a=>a.trim()).filter(Boolean):[],e=c[a]?c[a].split(";").map(a=>a.trim()).filter(Boolean):[],f=new Map;e.forEach(a=>{let[b,c]=a.split(":").map(a=>a.trim());f.set(b,c)}),d.forEach(a=>{let[b,c]=a.split(":").map(a=>a.trim());f.set(b,c)}),c[a]=Array.from(f.entries()).map(([a,b])=>`${a}: ${b}`).join("; ")}else c[a]=b}),c},{})}function fN(a,b){return b.filter(b=>b.type===a.type.name).filter(a=>a.attribute.rendered).map(b=>b.attribute.renderHTML?b.attribute.renderHTML(a.attrs)||{}:{[b.name]:a.attrs[b.name]}).reduce((a,b)=>fM(a,b),{})}function fO(a,b){return"style"in a?a:{...a,getAttrs:c=>{let d=a.getAttrs?a.getAttrs(c):a.attrs;if(!1===d)return!1;let e=b.reduce((a,b)=>{var d;let e=b.attribute.parseHTML?b.attribute.parseHTML(c):"string"!=typeof(d=c.getAttribute(b.name))?d:d.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(d):"true"===d||"false"!==d&&d;return null==e?a:{...a,[b.name]:e}},{});return{...d,...e}}}}function fP(a){return Object.fromEntries(Object.entries(a).filter(([a,b])=>!("attrs"===a&&function(a={}){return 0===Object.keys(a).length&&a.constructor===Object}(b))&&null!=b))}function fQ(a){var b,c;let d={};return!(null==(b=null==a?void 0:a.attribute)?void 0:b.isRequired)&&"default"in((null==a?void 0:a.attribute)||{})&&(d.default=a.attribute.default),(null==(c=null==a?void 0:a.attribute)?void 0:c.validate)!==void 0&&(d.validate=a.attribute.validate),[a.name,d]}function fR(a){return a.sort((a,b)=>{let c=fF(a,"priority")||100,d=fF(b,"priority")||100;return c>d?-1:+(c<d)})}function fS(a){var b;let c=fR(fG(a)),d=Array.from(new Set((b=c.map(a=>a.name)).filter((a,c)=>b.indexOf(a)!==c)));return d.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${d.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),c}function fT(a,b,c){let{from:d,to:e}=b,{blockSeparator:f="\n\n",textSerializers:g={}}=c||{},h="";return a.nodesBetween(d,e,(a,c,i,j)=>{var k;a.isBlock&&c>d&&(h+=f);let l=null==g?void 0:g[a.type.name];if(l)return i&&(h+=l({node:a,pos:c,parent:i,index:j,range:b})),!1;a.isText&&(h+=null==(k=null==a?void 0:a.text)?void 0:k.slice(Math.max(d,c)-c,e-c))}),h}function fU(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,a])=>a.spec.toText).map(([a,b])=>[a,b.spec.toText]))}function fV(a,b){let c=fp("string"==typeof b?b:b.name,a.schema);return"node"===c?function(a,b){let c=eM(b,a.schema),{from:d,to:e}=a.selection,f=[];a.doc.nodesBetween(d,e,a=>{f.push(a)});let g=f.reverse().find(a=>a.type.name===c.name);return g?{...g.attrs}:{}}(a,b):"mark"===c?fB(a,b):{}}function fW(a){let b,{mapping:c,steps:d}=a,e=[];return c.maps.forEach((a,b)=>{let f=[];if(a.ranges.length)a.forEach((a,b)=>{f.push({from:a,to:b})});else{let{from:a,to:c}=d[b];if(void 0===a||void 0===c)return;f.push({from:a,to:c})}f.forEach(({from:a,to:d})=>{let f=c.slice(b).map(a,-1),g=c.slice(b).map(d),h=c.invert().map(f,-1),i=c.invert().map(g);e.push({oldRange:{from:h,to:i},newRange:{from:f,to:g}})})}),1===(b=function(a,b=JSON.stringify){let c={};return a.filter(a=>{let d=b(a);return!Object.prototype.hasOwnProperty.call(c,d)&&(c[d]=!0)})}(e)).length?b:b.filter((a,c)=>!b.filter((a,b)=>b!==c).some(b=>a.oldRange.from>=b.oldRange.from&&a.oldRange.to<=b.oldRange.to&&a.newRange.from>=b.newRange.from&&a.newRange.to<=b.newRange.to))}function fX(a,b,c){let d=[];return a===b?c.resolve(a).marks().forEach(b=>{let e=eW(c.resolve(a),b.type);e&&d.push({mark:b,...e})}):c.nodesBetween(a,b,(a,b)=>{a&&(null==a?void 0:a.nodeSize)!==void 0&&d.push(...a.marks.map(c=>({from:b,to:b+a.nodeSize,mark:c})))}),d}function fY(a,b){return b.nodes[a]||b.marks[a]||null}function fZ(a,b,c){return Object.fromEntries(Object.entries(c).filter(([c])=>{let d=a.find(a=>a.type===b&&a.name===c);return!!d&&d.attribute.keepOnSplit}))}function f$(a,b,c={}){let{empty:d,ranges:e}=a.selection,f=b?eX(b,a.schema):null;if(d)return!!(a.storedMarks||a.selection.$from.marks()).filter(a=>!f||f.name===a.type.name).find(a=>eT(a.attrs,c,{strict:!1}));let g=0,h=[];if(e.forEach(({$from:b,$to:c})=>{let d=b.pos,e=c.pos;a.doc.nodesBetween(d,e,(a,b)=>{if(f&&a.inlineContent&&!a.type.allowsMarkType(f))return!1;if(!a.isText&&!a.marks.length)return;let c=Math.max(d,b),i=Math.min(e,b+a.nodeSize);g+=i-c,h.push(...a.marks.map(a=>({mark:a,from:c,to:i})))})}),0===g)return!1;let i=h.filter(a=>!f||f.name===a.mark.type.name).filter(a=>eT(a.mark.attrs,c,{strict:!1})).reduce((a,b)=>a+b.to-b.from,0),j=h.filter(a=>!f||a.mark.type!==f&&a.mark.type.excludes(f)).reduce((a,b)=>a+b.to-b.from,0);return(i>0?i+j:i)>=g}function f_(a,b){return Array.isArray(b)?b.some(b=>("string"==typeof b?b:b.name)===a.name):b}function f0(a,b){let{nodeExtensions:c}=fK(b),d=c.find(b=>b.name===a);if(!d)return!1;let e={name:d.name,options:d.options,storage:d.storage},f=fJ(fF(d,"group",e));return"string"==typeof f&&f.split(" ").includes("list")}function f1(a,{checkChildren:b=!0,ignoreWhitespace:c=!1}={}){var d;if(c){if("hardBreak"===a.type.name)return!0;if(a.isText)return/^\s*$/m.test(null!=(d=a.text)?d:"")}if(a.isText)return!a.text;if(a.isAtom||a.isLeaf)return!1;if(0===a.content.childCount)return!0;if(b){let d=!0;return a.content.forEach(a=>{!1!==d&&(f1(a,{ignoreWhitespace:c,checkChildren:b})||(d=!1))}),d}return!1}function f2(a){return a instanceof bf}var f3=class a{constructor(a){this.position=a}static fromJSON(b){return new a(b.position)}toJSON(){return{position:this.position}}};function f4(a,b){let c=b.mapping.mapResult(a.position);return{position:new f3(c.pos),mapResult:c}}function f5(a){return new f3(a)}var f6=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let{selection:f}=c,{empty:g,ranges:h}=f,i=eX(a,d.schema);if(e)if(g){let a=fB(d,i);c.addStoredMark(i.create({...a,...b}))}else h.forEach(a=>{let e=a.$from.pos,f=a.$to.pos;d.doc.nodesBetween(e,f,(a,d)=>{let g=Math.max(d,e),h=Math.min(d+a.nodeSize,f);a.marks.find(a=>a.type===i)?a.marks.forEach(a=>{i===a.type&&c.addMark(g,h,i.create({...a.attrs,...b}))}):c.addMark(g,h,i.create(b))})});return function(a,b,c){var d;let{selection:e}=b,f=null;if(e$(e)&&(f=e.$cursor),f){let b=null!=(d=a.storedMarks)?d:f.marks();return f.parent.type.allowsMarkType(c)&&(!!c.isInSet(b)||!b.some(a=>a.type.excludes(c)))}let{ranges:g}=e;return g.some(({$from:b,$to:d})=>{let e=0===b.depth&&a.doc.inlineContent&&a.doc.type.allowsMarkType(c);return a.doc.nodesBetween(b.pos,d.pos,(a,b,d)=>{if(e)return!1;if(a.isInline){let b=!d||d.type.allowsMarkType(c),f=!!c.isInSet(a.marks)||!a.marks.some(a=>a.type.excludes(c));e=b&&f}return!e}),e})}(d,c,i)},f7=(a,b)=>({tr:c})=>(c.setMeta(a,b),!0),f8=(a,b={})=>({state:c,dispatch:d,chain:e})=>{let f,g=eM(a,c.schema);return(c.selection.$anchor.sameParent(c.selection.$head)&&(f=c.selection.$anchor.parent.attrs),g.isTextblock)?e().command(({commands:a})=>!!bP(g,{...f,...b})(c)||a.clearNodes()).command(({state:a})=>bP(g,{...f,...b})(a,d)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},f9=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,d=e_(a,0,c.content.size),e=bf.create(c,d);b.setSelection(e)}return!0},ga=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f,g,{selection:h}=d;return"number"==typeof b?(f=b,g=b):b&&"from"in b&&"to"in b?(f=b.from,g=b.to):(f=h.from,g=h.to),e&&c.doc.nodesBetween(f,g,(b,d)=>{b.isText||c.setNodeMarkup(d,void 0,{...b.attrs,dir:a})}),!0},gb=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,{from:d,to:e}="number"==typeof a?{from:a,to:a}:a,f=bd.atStart(c).from,g=bd.atEnd(c).to,h=e_(d,f,g),i=e_(e,f,g),j=bd.create(c,h,i);b.setSelection(j)}return!0},gc=a=>({state:b,dispatch:c})=>{var d;return(d=eM(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);if(!f)return!1;let g=f.startIndex;if(0==g)return!1;let h=f.parent,i=h.child(g-1);if(i.type!=d)return!1;if(b){let c=i.lastChild&&i.lastChild.type==h.type,e=D.from(c?d.create():null),g=new J(D.from(d.create(null,D.from(h.type.create(null,e)))),c?3:1,0),j=f.start,k=f.end;b(a.tr.step(new aL(j-(c?3:1),k,j,k,g,1,!0)).scrollIntoView())}return!0})(b,c)};function gd(a,b){let c=a.storedMarks||a.selection.$to.parentOffset&&a.selection.$from.marks();if(c){let d=c.filter(a=>null==b?void 0:b.includes(a.type.name));a.tr.ensureMarks(d)}}var ge=({keepMarks:a=!0}={})=>({tr:b,state:c,dispatch:d,editor:e})=>{let{selection:f,doc:g}=b,{$from:h,$to:i}=f,j=fZ(e.extensionManager.attributes,h.node().type.name,h.node().attrs);if(f instanceof bf&&f.node.isBlock)return!!h.parentOffset&&!!aT(g,h.pos)&&(d&&(a&&gd(c,e.extensionManager.splittableMarks),b.split(h.pos).scrollIntoView()),!0);if(!h.parent.isBlock)return!1;let k=i.parentOffset===i.parent.content.size,l=0===h.depth?void 0:function(a){for(let b=0;b<a.edgeCount;b+=1){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}(h.node(-1).contentMatchAt(h.indexAfter(-1))),m=k&&l?[{type:l,attrs:j}]:void 0,n=aT(b.doc,b.mapping.map(h.pos),1,m);if(!m&&!n&&aT(b.doc,b.mapping.map(h.pos),1,l?[{type:l}]:void 0)&&(n=!0,m=l?[{type:l,attrs:j}]:void 0),d){if(n&&(f instanceof bd&&b.deleteSelection(),b.split(b.mapping.map(h.pos),1,m),l&&!k&&!h.parentOffset&&h.parent.type!==l)){let a=b.mapping.map(h.before()),c=b.doc.resolve(a);h.node(-1).canReplaceWith(c.index(),c.index()+1,l)&&b.setNodeMarkup(b.mapping.map(h.before()),l)}a&&gd(c,e.extensionManager.splittableMarks),b.scrollIntoView()}return n},gf=(a,b={})=>({tr:c,state:d,dispatch:e,editor:f})=>{var g;let h=eM(a,d.schema),{$from:i,$to:j}=d.selection,k=d.selection.node;if(k&&k.isBlock||i.depth<2||!i.sameParent(j))return!1;let l=i.node(-1);if(l.type!==h)return!1;let m=f.extensionManager.attributes;if(0===i.parent.content.size&&i.node(-1).childCount===i.indexAfter(-1)){if(2===i.depth||i.node(-3).type!==h||i.index(-2)!==i.node(-2).childCount-1)return!1;if(e){let a=D.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-d;b>=i.depth-3;b-=1)a=D.from(i.node(b).copy(a));let e=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3,f={...fZ(m,i.node().type.name,i.node().attrs),...b},j=(null==(g=h.contentMatch.defaultType)?void 0:g.createAndFill(f))||void 0;a=a.append(D.from(h.createAndFill(null,j)||void 0));let k=i.before(i.depth-(d-1));c.replace(k,i.after(-e),new J(a,4-d,0));let l=-1;c.doc.nodesBetween(k,c.doc.content.size,(a,b)=>{if(l>-1)return!1;a.isTextblock&&0===a.content.size&&(l=b+1)}),l>-1&&c.setSelection(bd.near(c.doc.resolve(l))),c.scrollIntoView()}return!0}let n=j.pos===i.end()?l.contentMatchAt(0).defaultType:null,o={...fZ(m,l.type.name,l.attrs),...b},p={...fZ(m,i.node().type.name,i.node().attrs),...b};c.delete(i.pos,j.pos);let q=n?[{type:h,attrs:o},{type:n,attrs:p}]:[{type:h,attrs:o}];if(!aT(c.doc,i.pos,2))return!1;if(e){let{selection:a,storedMarks:b}=d,{splittableMarks:g}=f.extensionManager,h=b||a.$to.parentOffset&&a.$from.marks();if(c.split(i.pos,2,q).scrollIntoView(),!h||!e)return!0;let j=h.filter(a=>g.includes(a.type.name));c.ensureMarks(j)}return!0},gg=(a,b)=>{let c=fE(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(Math.max(0,c.pos-1)).before(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&aU(a.doc,c.pos))||(a.join(c.pos),!0)},gh=(a,b)=>{let c=fE(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(c.start).after(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&aU(a.doc,d))||(a.join(d),!0)},gi=(a,b,c,d={})=>({editor:e,tr:f,state:g,dispatch:h,chain:i,commands:j,can:k})=>{let{extensions:l,splittableMarks:m}=e.extensionManager,n=eM(a,g.schema),o=eM(b,g.schema),{selection:p,storedMarks:q}=g,{$from:r,$to:s}=p,t=r.blockRange(s),u=q||p.$to.parentOffset&&p.$from.marks();if(!t)return!1;let v=fE(a=>f0(a.type.name,l))(p);if(t.depth>=1&&v&&t.depth-v.depth<=1){if(v.node.type===n)return j.liftListItem(o);if(f0(v.node.type.name,l)&&n.validContent(v.node.content)&&h)return i().command(()=>(f.setNodeMarkup(v.pos,n),!0)).command(()=>gg(f,n)).command(()=>gh(f,n)).run()}return c&&u&&h?i().command(()=>{let a=k().wrapInList(n,d),b=u.filter(a=>m.includes(a.type.name));return f.ensureMarks(b),!!a||j.clearNodes()}).wrapInList(n,d).command(()=>gg(f,n)).command(()=>gh(f,n)).run():i().command(()=>!!k().wrapInList(n,d)||j.clearNodes()).wrapInList(n,d).command(()=>gg(f,n)).command(()=>gh(f,n)).run()},gj=(a,b={},c={})=>({state:d,commands:e})=>{let{extendEmptyMarkRange:f=!1}=c,g=eX(a,d.schema);return f$(d,g,b)?e.unsetMark(g,{extendEmptyMarkRange:f}):e.setMark(g,b)},gk=(a,b,c={})=>({state:d,commands:e})=>{let f,g=eM(a,d.schema),h=eM(b,d.schema),i=fk(d,g,c);return(d.selection.$anchor.sameParent(d.selection.$head)&&(f=d.selection.$anchor.parent.attrs),i)?e.setNode(h,f):e.setNode(g,{...f,...c})},gl=(a,b={})=>({state:c,commands:d})=>{let e=eM(a,c.schema);return fk(c,e,b)?d.lift(e):d.wrapIn(e,b)},gm=()=>({state:a,dispatch:b})=>{let c=a.plugins;for(let d=0;d<c.length;d+=1){let e,f=c[d];if(f.spec.isInputRules&&(e=f.getState(a))){if(b){let b=a.tr,c=e.transform;for(let a=c.steps.length-1;a>=0;a-=1)b.step(c.steps[a].invert(c.docs[a]));if(e.text){let c=b.doc.resolve(e.from).marks();b.replaceWith(e.from,e.to,a.schema.text(e.text,c))}else b.delete(e.from,e.to)}return!0}}return!1},gn=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,{empty:d,ranges:e}=c;return!!d||(b&&e.forEach(b=>{a.removeMark(b.$from.pos,b.$to.pos)}),!0)},go=(a,b={})=>({tr:c,state:d,dispatch:e})=>{var f;let{extendEmptyMarkRange:g=!1}=b,{selection:h}=c,i=eX(a,d.schema),{$from:j,empty:k,ranges:l}=h;if(!e)return!0;if(k&&g){let{from:a,to:b}=h,d=null==(f=j.marks().find(a=>a.type===i))?void 0:f.attrs,e=eW(j,i,d);e&&(a=e.from,b=e.to),c.removeMark(a,b,i)}else l.forEach(a=>{c.removeMark(a.$from.pos,a.$to.pos,i)});return c.removeStoredMark(i),!0},gp=a=>({tr:b,state:c,dispatch:d})=>{let e,f,{selection:g}=c;return"number"==typeof a?(e=a,f=a):a&&"from"in a&&"to"in a?(e=a.from,f=a.to):(e=g.from,f=g.to),d&&b.doc.nodesBetween(e,f,(a,c)=>{if(a.isText)return;let d={...a.attrs};delete d.dir,b.setNodeMarkup(c,void 0,d)}),!0},gq=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=fp("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=eM(a,d.schema)),"mark"===h&&(g=eX(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{let h,j,k,l,m=a.$from.pos,n=a.$to.pos;c.selection.empty?d.doc.nodesBetween(m,n,(a,b)=>{f&&f===a.type&&(i=!0,k=Math.max(b,m),l=Math.min(b+a.nodeSize,n),h=b,j=a)}):d.doc.nodesBetween(m,n,(a,d)=>{d<m&&f&&f===a.type&&(i=!0,k=Math.max(d,m),l=Math.min(d+a.nodeSize,n),h=d,j=a),d>=m&&d<=n&&(f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,{...a.attrs,...b})),g&&a.marks.length&&a.marks.forEach(f=>{if(g===f.type&&(i=!0,e)){let e=Math.max(d,m),h=Math.min(d+a.nodeSize,n);c.addMark(e,h,g.create({...f.attrs,...b}))}}))}),j&&(void 0!==h&&e&&c.setNodeMarkup(h,void 0,{...j.attrs,...b}),g&&j.marks.length&&j.marks.forEach(a=>{g===a.type&&e&&c.addMark(k,l,g.create({...a.attrs,...b}))}))}),i},gr=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f),h=g&&aP(g,a,b);return!!h&&(d&&d(c.tr.wrap(g,h).scrollIntoView()),!0)}})(eM(a,c.schema),b)(c,d),gs=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f);if(!g)return!1;let h=d?c.tr:null;return!!function(a,b,c,d=null){let e=!1,f=b,g=b.$from.doc;if(b.depth>=2&&b.$from.node(b.depth-1).type.compatibleContent(c)&&0==b.startIndex){if(0==b.$from.index(b.depth-1))return!1;let a=g.resolve(b.start-2);f=new U(a,a,b.depth),b.endIndex<b.parent.childCount&&(b=new U(b.$from,g.resolve(b.$to.end(b.depth)),b.depth)),e=!0}let h=aP(f,c,d,b);return!!h&&(a&&function(a,b,c,d,e){let f=D.empty;for(let a=c.length-1;a>=0;a--)f=D.from(c[a].type.create(c[a].attrs,f));a.step(new aL(b.start-2*!!d,b.end,b.start,b.end,new J(f,0,0),c.length,!0));let g=0;for(let a=0;a<c.length;a++)c[a].type==e&&(g=a+1);let h=c.length-g,i=b.start+c.length-2*!!d,j=b.parent;for(let c=b.startIndex,d=b.endIndex,e=!0;c<d;c++,e=!1)!e&&aT(a.doc,i,h)&&(a.split(i,h),i+=2*h),i+=j.child(c).nodeSize}(a,b,h,e,c),!0)}(h,g,a,b)&&(d&&d(h.scrollIntoView()),!0)}})(eM(a,c.schema),b)(c,d),gt=class{constructor(){this.callbacks={}}on(a,b){return this.callbacks[a]||(this.callbacks[a]=[]),this.callbacks[a].push(b),this}emit(a,...b){let c=this.callbacks[a];return c&&c.forEach(a=>a.apply(this,b)),this}off(a,b){let c=this.callbacks[a];return c&&(b?this.callbacks[a]=c.filter(a=>a!==b):delete this.callbacks[a]),this}once(a,b){let c=(...d)=>{this.off(a,c),b.apply(this,d)};return this.on(a,c)}removeAllListeners(){this.callbacks={}}},gu=class{constructor(a){var b;this.find=a.find,this.handler=a.handler,this.undoable=null==(b=a.undoable)||b}};function gv(a){var b;let{editor:c,from:d,to:e,text:f,rules:g,plugin:h}=a,{view:i}=c;if(i.composing)return!1;let j=i.state.doc.resolve(d);if(j.parent.type.spec.code||(null==(b=j.nodeBefore||j.nodeAfter)?void 0:b.marks.find(a=>a.type.spec.code)))return!1;let k=!1,l=((a,b=500)=>{let c="",d=a.parentOffset;return a.parent.nodesBetween(Math.max(0,d-b),d,(a,b,e,f)=>{var g,h;let i=(null==(h=(g=a.type.spec).toText)?void 0:h.call(g,{node:a,pos:b,parent:e,index:f}))||a.textContent||"%leaf%";c+=a.isAtom&&!a.isText?i:i.slice(0,Math.max(0,d-b))}),c})(j)+f;return g.forEach(a=>{if(k)return;let b=((a,b)=>{if(eS(b))return b.exec(a);let c=b(a);if(!c)return null;let d=[c.text];return d.index=c.index,d.input=a,d.data=c.data,c.replaceWith&&(c.text.includes(c.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),d.push(c.replaceWith)),d})(l,a.find);if(!b)return;let g=i.state.tr,j=eC({state:i.state,transaction:g}),m={from:d-(b[0].length-f.length),to:e},{commands:n,chain:o,can:p}=new eD({editor:c,state:j});null!==a.handler({state:j,range:m,match:b,commands:n,chain:o,can:p})&&g.steps.length&&(a.undoable&&g.setMeta(h,{transform:g,from:d,to:e,text:f}),i.dispatch(g),k=!0)}),k}function gw(a){return"Object"===Object.prototype.toString.call(a).slice(8,-1)&&a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}var gx=class{constructor(a={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...a},this.name=this.config.name}get options(){return{...fJ(fF(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...fJ(fF(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(a={}){let b=this.extend({...this.config,addOptions:()=>(function a(b,c){let d={...b};return gw(b)&&gw(c)&&Object.keys(c).forEach(e=>{gw(c[e])&&gw(b[e])?d[e]=a(b[e],c[e]):d[e]=c[e]}),d})(this.options,a)});return b.name=this.name,b.parent=this.parent,b}extend(a={}){let b=new this.constructor({...this.config,...a});return b.parent=this,this.child=b,b.name="name"in a?a.name:b.parent.name,b}},gy=class a extends gx{constructor(){super(...arguments),this.type="mark"}static create(b={}){return new a("function"==typeof b?b():b)}static handleExit({editor:a,mark:b}){let{tr:c}=a.state,d=a.state.selection.$from;if(d.pos===d.end()){let e=d.marks();if(!e.find(a=>(null==a?void 0:a.type.name)===b.name))return!1;let f=e.find(a=>(null==a?void 0:a.type.name)===b.name);return f&&c.removeStoredMark(f),c.insertText(" ",d.pos),a.view.dispatch(c),!0}return!1}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},gz=class{constructor(a){this.find=a.find,this.handler=a.handler}},gA=null,gB=class{constructor(a,b){this.splittableMarks=[],this.editor=b,this.baseExtensions=a,this.extensions=fS(a),this.schema=function(a,b){var c;let d=fL(a),{nodeExtensions:e,markExtensions:f}=fK(a),g=null==(c=e.find(a=>fF(a,"topNode")))?void 0:c.name;return new aj({topNode:g,nodes:Object.fromEntries(e.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=fP({...a.reduce((a,b)=>{let d=fF(b,"extendNodeSchema",f);return{...a,...d?d(c):{}}},{}),content:fJ(fF(c,"content",f)),marks:fJ(fF(c,"marks",f)),group:fJ(fF(c,"group",f)),inline:fJ(fF(c,"inline",f)),atom:fJ(fF(c,"atom",f)),selectable:fJ(fF(c,"selectable",f)),draggable:fJ(fF(c,"draggable",f)),code:fJ(fF(c,"code",f)),whitespace:fJ(fF(c,"whitespace",f)),linebreakReplacement:fJ(fF(c,"linebreakReplacement",f)),defining:fJ(fF(c,"defining",f)),isolating:fJ(fF(c,"isolating",f)),attrs:Object.fromEntries(e.map(fQ))}),h=fJ(fF(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>fO(a,e)));let i=fF(c,"renderHTML",f);i&&(g.toDOM=a=>i({node:a,HTMLAttributes:fN(a,e)}));let j=fF(c,"renderText",f);return j&&(g.toText=j),[c.name,g]})),marks:Object.fromEntries(f.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=fP({...a.reduce((a,b)=>{let d=fF(b,"extendMarkSchema",f);return{...a,...d?d(c):{}}},{}),inclusive:fJ(fF(c,"inclusive",f)),excludes:fJ(fF(c,"excludes",f)),group:fJ(fF(c,"group",f)),spanning:fJ(fF(c,"spanning",f)),code:fJ(fF(c,"code",f)),attrs:Object.fromEntries(e.map(fQ))}),h=fJ(fF(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>fO(a,e)));let i=fF(c,"renderHTML",f);return i&&(g.toDOM=a=>i({mark:a,HTMLAttributes:fN(a,e)})),[c.name,g]}))})}(this.extensions,b),this.setupExtensions()}get commands(){return this.extensions.reduce((a,b)=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:this.editor,type:fY(b.name,this.schema)},d=fF(b,"addCommands",c);return d?{...a,...d()}:a},{})}get plugins(){let{editor:a}=this;return fR([...this.extensions].reverse()).flatMap(b=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:fY(b.name,this.schema)},d=[],e=fF(b,"addKeyboardShortcuts",c),f={};if("mark"===b.type&&fF(b,"exitable",c)&&(f.ArrowRight=()=>gy.handleExit({editor:a,mark:b})),e){let b=Object.fromEntries(Object.entries(e()).map(([b,c])=>[b,()=>c({editor:a})]));f={...f,...b}}let g=new br({props:{handleKeyDown:ez(f)}});d.push(g);let h=fF(b,"addInputRules",c);if(f_(b,a.options.enableInputRules)&&h){let b=h();if(b&&b.length){let c=function(a){let{editor:b,rules:c}=a,d=new br({state:{init:()=>null,apply(a,e,f){let g=a.getMeta(d);if(g)return g;let h=a.getMeta("applyInputRules");return h&&setTimeout(()=>{let{text:a}=h;"string"==typeof a||(a=fH(D.from(a),f.schema));let{from:e}=h,g=e+a.length;gv({editor:b,from:e,to:g,text:a,rules:c,plugin:d})}),a.selectionSet||a.docChanged?null:e}},props:{handleTextInput:(a,e,f,g)=>gv({editor:b,from:e,to:f,text:g,rules:c,plugin:d}),handleDOMEvents:{compositionend:a=>(setTimeout(()=>{let{$cursor:e}=a.state.selection;e&&gv({editor:b,from:e.pos,to:e.pos,text:"",rules:c,plugin:d})}),!1)},handleKeyDown(a,e){if("Enter"!==e.key)return!1;let{$cursor:f}=a.state.selection;return!!f&&gv({editor:b,from:f.pos,to:f.pos,text:"\n",rules:c,plugin:d})}},isInputRules:!0});return d}({editor:a,rules:b}),e=Array.isArray(c)?c:[c];d.push(...e)}}let i=fF(b,"addPasteRules",c);if(f_(b,a.options.enablePasteRules)&&i){let b=i();if(b&&b.length){let c=function(a){let b,{editor:c,rules:d}=a,e=null,f=!1,g=!1,h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}let i=({state:a,from:d,to:e,rule:f,pasteEvt:g})=>{let i=a.tr;if(function(a){let{editor:b,state:c,from:d,to:e,rule:f,pasteEvent:g,dropEvent:h}=a,{commands:i,chain:j,can:k}=new eD({editor:b,state:c}),l=[];return c.doc.nodesBetween(d,e,(a,b)=>{var m,n,o,p,q;if((null==(n=null==(m=a.type)?void 0:m.spec)?void 0:n.code)||!(a.isText||a.isTextblock||a.isInline))return;let r=null!=(q=null!=(p=null==(o=a.content)?void 0:o.size)?p:a.nodeSize)?q:0,s=Math.max(d,b),t=Math.min(e,b+r);s>=t||((a,b,c)=>{if(eS(b))return[...a.matchAll(b)];let d=b(a,c);return d?d.map(b=>{let c=[b.text];return c.index=b.index,c.input=a,c.data=b.data,b.replaceWith&&(b.text.includes(b.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),c.push(b.replaceWith)),c}):[]})(a.isText?a.text||"":a.textBetween(s-b,t-b,void 0,""),f.find,g).forEach(a=>{if(void 0===a.index)return;let b=s+a.index+1,d=b+a[0].length,e={from:c.tr.mapping.map(b),to:c.tr.mapping.map(d)},m=f.handler({state:c,range:e,match:a,commands:i,chain:j,can:k,pasteEvent:g,dropEvent:h});l.push(m)})}),l.every(a=>null!==a)}({editor:c,state:eC({state:a,transaction:i}),from:Math.max(d-1,0),to:e.b-1,rule:f,pasteEvent:g,dropEvent:b})&&i.steps.length){try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}return h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,i}};return d.map(a=>new br({view(a){let b=b=>{var d;(e=(null==(d=a.dom.parentElement)?void 0:d.contains(b.target))?a.dom.parentElement:null)&&(gA=c)},d=()=>{gA&&(gA=null)};return window.addEventListener("dragstart",b),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",b),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(a,c)=>{if(g=e===a.dom.parentElement,b=c,!g){let a=gA;(null==a?void 0:a.isEditable)&&setTimeout(()=>{let b=a.state.selection;b&&a.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(a,b)=>{var c;let d=null==(c=b.clipboardData)?void 0:c.getData("text/html");return h=b,f=!!(null==d?void 0:d.includes("data-pm-slice")),!1}}},appendTransaction:(b,c,d)=>{let e=b[0],j="paste"===e.getMeta("uiEvent")&&!f,k="drop"===e.getMeta("uiEvent")&&!g,l=e.getMeta("applyPasteRules"),m=!!l;if(!j&&!k&&!m)return;if(m){var n,o;let b,{text:c}=l;"string"==typeof c||(c=fH(D.from(c),d.schema));let{from:e}=l,f=e+c.length;return i({rule:a,state:d,from:e,to:{b:f},pasteEvt:(n=c,null==(o=(b=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||o.setData("text/html",n),b)})}let p=c.doc.content.findDiffStart(d.doc.content),q=c.doc.content.findDiffEnd(d.doc.content);if("number"==typeof p&&q&&p!==q.b)return i({rule:a,state:d,from:p,to:q,pasteEvt:h})}}))}({editor:a,rules:b});d.push(...c)}}let j=fF(b,"addProseMirrorPlugins",c);if(j){let a=j();d.push(...a)}return d})}get attributes(){return fL(this.extensions)}get nodeViews(){let{editor:a}=this,{nodeExtensions:b}=fK(this.extensions);return Object.fromEntries(b.filter(a=>!!fF(a,"addNodeView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:eM(b.name,this.schema)},e=fF(b,"addNodeView",d);if(!e)return[];let f=e();return f?[b.name,(d,e,g,h,i)=>{let j=fN(d,c);return f({node:d,view:e,getPos:g,decorations:h,innerDecorations:i,editor:a,extension:b,HTMLAttributes:j})}]:[]}))}dispatchTransaction(a){let{editor:b}=this;return fR([...this.extensions].reverse()).reduceRight((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:fY(c.name,this.schema)},e=fF(c,"dispatchTransaction",d);return e?b=>{e.call(d,{transaction:b,next:a})}:a},a)}transformPastedHTML(a){let{editor:b}=this;return fR([...this.extensions]).reduce((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:fY(c.name,this.schema)},e=fF(c,"transformPastedHTML",d);return e?(b,c)=>{let f=a(b,c);return e.call(d,f)}:a},a||(a=>a))}get markViews(){let{editor:a}=this,{markExtensions:b}=fK(this.extensions);return Object.fromEntries(b.filter(a=>!!fF(a,"addMarkView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:eX(b.name,this.schema)},e=fF(b,"addMarkView",d);return e?[b.name,(d,f,g)=>{let h=fN(d,c);return e()({mark:d,view:f,inline:g,editor:a,extension:b,HTMLAttributes:h,updateAttributes:b=>{!function(a,b,c={}){let{state:d}=b,{doc:e,tr:f}=d;e.descendants((b,d)=>{let e=f.mapping.map(d),g=f.mapping.map(d)+b.nodeSize,h=null;if(b.marks.forEach(b=>{if(b!==a)return!1;h=b}),!h)return;let i=!1;if(Object.keys(c).forEach(a=>{c[a]!==h.attrs[a]&&(i=!0)}),i){let b=a.type.create({...a.attrs,...c});f.removeMark(e,g,a.type),f.addMark(e,g,b)}}),f.docChanged&&b.view.dispatch(f)}(d,a,b)}})}]:[]}))}setupExtensions(){let a=this.extensions;this.editor.extensionStorage=Object.fromEntries(a.map(a=>[a.name,a.storage])),a.forEach(a=>{var b;let c={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:this.editor,type:fY(a.name,this.schema)};"mark"===a.type&&(null==(b=fJ(fF(a,"keepOnSplit",c)))||b)&&this.splittableMarks.push(a.name);let d=fF(a,"onBeforeCreate",c),e=fF(a,"onCreate",c),f=fF(a,"onUpdate",c),g=fF(a,"onSelectionUpdate",c),h=fF(a,"onTransaction",c),i=fF(a,"onFocus",c),j=fF(a,"onBlur",c),k=fF(a,"onDestroy",c);d&&this.editor.on("beforeCreate",d),e&&this.editor.on("create",e),f&&this.editor.on("update",f),g&&this.editor.on("selectionUpdate",g),h&&this.editor.on("transaction",h),i&&this.editor.on("focus",i),j&&this.editor.on("blur",j),k&&this.editor.on("destroy",k)})}};gB.resolve=fS,gB.sort=fR,gB.flatten=fG;var gC={};eB(gC,{ClipboardTextSerializer:()=>gE,Commands:()=>gF,Delete:()=>gG,Drop:()=>gH,Editable:()=>gI,FocusEvents:()=>gK,Keymap:()=>gL,Paste:()=>gM,Tabindex:()=>gN,TextDirection:()=>gO,focusEventsPluginKey:()=>gJ});var gD=class a extends gx{constructor(){super(...arguments),this.type="extension"}static create(b={}){return new a("function"==typeof b?b():b)}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},gE=gD.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new br({key:new bu("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:a}=this,{state:b,schema:c}=a,{doc:d,selection:e}=b,{ranges:f}=e,g=Math.min(...f.map(a=>a.$from.pos)),h=Math.max(...f.map(a=>a.$to.pos)),i=fU(c);return fT(d,{from:g,to:h},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:i})}}})]}}),gF=gD.create({name:"commands",addCommands:()=>({...eE})}),gG=gD.create({name:"delete",onUpdate({transaction:a,appendedTransactions:b}){var c,d,e;let f=()=>{var c,d,e,f;if(null!=(f=null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.filterTransaction)?void 0:e.call(d,a))?f:a.getMeta("y-sync$"))return;let g=fC(a.before,[a,...b]);fW(g).forEach(b=>{g.mapping.mapResult(b.oldRange.from).deletedAfter&&g.mapping.mapResult(b.oldRange.to).deletedBefore&&g.before.nodesBetween(b.oldRange.from,b.oldRange.to,(c,d)=>{let e=d+c.nodeSize-2,f=b.oldRange.from<=d&&e<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:c,from:d,to:e,newFrom:g.mapping.map(d),newTo:g.mapping.map(e),deletedRange:b.oldRange,newRange:b.newRange,partial:!f,editor:this.editor,transaction:a,combinedTransform:g})})});let h=g.mapping;g.steps.forEach((b,c)=>{var d,e;if(b instanceof aH){let f=h.slice(c).map(b.from,-1),i=h.slice(c).map(b.to),j=h.invert().map(f,-1),k=h.invert().map(i),l=null==(d=g.doc.nodeAt(f-1))?void 0:d.marks.some(a=>a.eq(b.mark)),m=null==(e=g.doc.nodeAt(i))?void 0:e.marks.some(a=>a.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:j,to:k},newRange:{from:f,to:i},partial:!!(m||l),editor:this.editor,transaction:a,combinedTransform:g})}})};null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.async)||e?setTimeout(f,0):f()}}),gH=gD.create({name:"drop",addProseMirrorPlugins(){return[new br({key:new bu("tiptapDrop"),props:{handleDrop:(a,b,c,d)=>{this.editor.emit("drop",{editor:this.editor,event:b,slice:c,moved:d})}}})]}}),gI=gD.create({name:"editable",addProseMirrorPlugins(){return[new br({key:new bu("editable"),props:{editable:()=>this.editor.options.editable}})]}}),gJ=new bu("focusEvents"),gK=gD.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:a}=this;return[new br({key:gJ,props:{handleDOMEvents:{focus:(b,c)=>{a.isFocused=!0;let d=a.state.tr.setMeta("focus",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1},blur:(b,c)=>{a.isFocused=!1;let d=a.state.tr.setMeta("blur",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1}}}})]}}),gL=gD.create({name:"keymap",addKeyboardShortcuts(){let a=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:b})=>{let{selection:c,doc:d}=b,{empty:e,$anchor:f}=c,{pos:g,parent:h}=f,i=f.parent.isTextblock&&g>0?b.doc.resolve(g-1):f,j=i.parent.type.spec.isolating,k=f.pos-f.parentOffset,l=j&&1===i.parent.childCount?k===f.pos:a9.atStart(d).from===g;return!!e&&!!h.type.isTextblock&&!h.textContent.length&&!!l&&(!l||"paragraph"!==f.parent.type.name)&&a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),b=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),c={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:a,"Mod-Backspace":a,"Shift-Backspace":a,Delete:b,"Mod-Delete":b,"Mod-a":()=>this.editor.commands.selectAll()},d={...c},e={...c,"Ctrl-h":a,"Alt-Backspace":a,"Ctrl-d":b,"Ctrl-Alt-Backspace":b,"Alt-Delete":b,"Alt-d":b,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return e2()||fi()?e:d},addProseMirrorPlugins(){return[new br({key:new bu("clearDocument"),appendTransaction:(a,b,c)=>{if(a.some(a=>a.getMeta("composition")))return;let d=a.some(a=>a.docChanged)&&!b.doc.eq(c.doc),e=a.some(a=>a.getMeta("preventClearDocument"));if(!d||e)return;let{empty:f,from:g,to:h}=b.selection,i=a9.atStart(b.doc).from,j=a9.atEnd(b.doc).to;if(f||g!==i||h!==j||!f1(c.doc))return;let k=c.tr,l=eC({state:c,transaction:k}),{commands:m}=new eD({editor:this.editor,state:l});if(m.clearNodes(),k.steps.length)return k}})]}}),gM=gD.create({name:"paste",addProseMirrorPlugins(){return[new br({key:new bu("tiptapPaste"),props:{handlePaste:(a,b,c)=>{this.editor.emit("paste",{editor:this.editor,event:b,slice:c})}}})]}}),gN=gD.create({name:"tabindex",addProseMirrorPlugins(){return[new br({key:new bu("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),gO=gD.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:a}=fK(this.extensions);return[{types:a.filter(a=>"text"!==a.name).map(a=>a.name),attributes:{dir:{default:this.options.direction,parseHTML:a=>{let b=a.getAttribute("dir");return b&&("ltr"===b||"rtl"===b||"auto"===b)?b:this.options.direction},renderHTML:a=>a.dir?{dir:a.dir}:{}}}}]},addProseMirrorPlugins(){return[new br({key:new bu("textDirection"),props:{attributes:()=>{let a=this.options.direction;return a?{dir:a}:{}}}})]}}),gP=class a{constructor(a,b,c=!1,d=null){this.currentNode=null,this.actualDepth=null,this.isBlock=c,this.resolvedPos=a,this.editor=b,this.currentNode=d}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var a;return null!=(a=this.actualDepth)?a:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(a){let b=this.from,c=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);b=this.from+1,c=this.to-1}this.editor.commands.insertContentAt({from:b,to:c},a)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(0===this.depth)return null;let b=this.resolvedPos.start(this.resolvedPos.depth-1);return new a(this.resolvedPos.doc.resolve(b),this.editor)}get before(){let b=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.from-3)),new a(b,this.editor)}get after(){let b=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.to+3)),new a(b,this.editor)}get children(){let b=[];return this.node.content.forEach((c,d)=>{let e=c.isBlock&&!c.isTextblock,f=c.isAtom&&!c.isText,g=c.isInline,h=this.pos+d+ +!f;if(h<0||h>this.resolvedPos.doc.nodeSize-2)return;let i=this.resolvedPos.doc.resolve(h);if(!e&&!g&&i.depth<=this.depth)return;let j=new a(i,this.editor,e,e||g?c:null);e&&(j.actualDepth=this.depth+1),b.push(j)}),b}get firstChild(){return this.children[0]||null}get lastChild(){let a=this.children;return a[a.length-1]||null}closest(a,b={}){let c=null,d=this.parent;for(;d&&!c;){if(d.node.type.name===a)if(Object.keys(b).length>0){let a=d.node.attrs,c=Object.keys(b);for(let d=0;d<c.length;d+=1){let e=c[d];if(a[e]!==b[e])break}}else c=d;d=d.parent}return c}querySelector(a,b={}){return this.querySelectorAll(a,b,!0)[0]||null}querySelectorAll(a,b={},c=!1){let d=[];if(!this.children||0===this.children.length)return d;let e=Object.keys(b);return this.children.forEach(f=>{c&&d.length>0||(f.node.type.name===a&&e.every(a=>b[a]===f.node.attrs[a])&&d.push(f),c&&d.length>0||(d=d.concat(f.querySelectorAll(a,b,c))))}),d}setAttribute(a){let{tr:b}=this.editor.state;b.setNodeMarkup(this.from,void 0,{...this.node.attrs,...a}),this.editor.view.dispatch(b)}},gQ=`.ProseMirror {
1
+ (()=>{var a={};a.id=8974,a.ids=[8974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1482:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>g});var d=c(48249),e=c(67484),f=c(44384);function g({onSelectSession:a}){let{t:b}=(0,f.Bd)(),[c,h]=(0,e.useState)([]),[i,j]=(0,e.useState)({}),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(""),q=(0,e.useRef)(null);(0,e.useCallback)(async()=>{l(!0),n(null),j({});try{let a=await fetch("/api/sessions/projects");if(!a.ok)throw Error("Failed to load projects");let b=await a.json();h(b)}catch(a){n(a instanceof Error?a.message:"Unknown error")}finally{l(!1)}},[]);let r=(0,e.useCallback)(async a=>{j(b=>({...b,[a]:{...b[a],isExpanded:!0,isLoading:!0,sessions:[],error:null}}));try{let b=await fetch(`/api/sessions/projects/${encodeURIComponent(a)}`);if(!b.ok)throw Error("Failed to load sessions");let c=await b.json();j(b=>({...b,[a]:{...b[a],isLoading:!1,sessions:c}}))}catch(b){j(c=>({...c,[a]:{...c[a],isLoading:!1,error:b instanceof Error?b.message:"Unknown error"}}))}},[]),s=(0,e.useCallback)(a=>{let b=i[a];b?.isExpanded?j(b=>({...b,[a]:{...b[a],isExpanded:!1}})):b?.sessions?.length?j(b=>({...b,[a]:{...b[a],isExpanded:!0}})):r(a)},[i,r]);return(0,d.jsxs)("div",{className:"flex-1 flex flex-col bg-card",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[(0,d.jsx)("h2",{className:"text-lg font-medium text-foreground",children:b("workspace.selectProject")}),(0,d.jsx)("input",{ref:q,type:"text",placeholder:b("workspace.searchProjectPath"),value:o,onChange:a=>p(a.target.value),className:"px-3 py-1.5 text-sm border border-border rounded-lg bg-card text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[k&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:b("workspace.loadingProjects")})]})}),m&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsx)("div",{className:"text-sm text-red-500",children:m})}),!k&&!m&&0===c.length&&(0,d.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,d.jsx)("div",{className:"text-sm text-muted-foreground",children:b("workspace.projectNotFound")})}),!k&&!m&&(0,d.jsx)("div",{className:"space-y-2",children:c.filter(a=>a.fullPath.toLowerCase().includes(o.toLowerCase())).map(c=>{let e=i[c.encodedPath]||{isExpanded:!1,isLoading:!1,sessions:[],error:null};return(0,d.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,d.jsxs)("button",{onClick:()=>s(c.encodedPath),className:"w-full flex items-center gap-3 p-3 hover:bg-accent transition-colors text-left",children:[(0,d.jsx)("svg",{className:`w-4 h-4 text-muted-foreground transition-transform ${e.isExpanded?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,d.jsx)("svg",{className:"w-5 h-5 text-brand",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm font-medium text-foreground truncate",children:c.name}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:c.fullPath})]}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground bg-secondary px-2 py-0.5 rounded",children:b("workspace.sessions",{count:c.sessionCount})})]}),e.isExpanded&&(0,d.jsxs)("div",{className:"border-t border-border bg-secondary/30",children:[e.isLoading&&(0,d.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,d.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,d.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,d.jsx)("span",{children:b("workspace.loadingSessions")})]}),e.error&&(0,d.jsx)("div",{className:"p-3 text-xs text-red-500",children:e.error}),!e.isLoading&&!e.error&&0===e.sessions.length&&(0,d.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:b("workspace.noSessions")}),!e.isLoading&&!e.error&&e.sessions.map(b=>(0,d.jsxs)("button",{onClick:()=>{a(c.fullPath,(b.path.split("/").pop()||"").replace(".jsonl",""))},className:"w-full flex items-start gap-3 p-3 hover:bg-accent transition-colors text-left border-t border-border first:border-t-0",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-muted-foreground mt-0.5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:b.title}),(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:new Date(b.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),b.firstMessages.length>0&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground mt-1 truncate",children:b.firstMessages[0]})]})]},b.path))]})]},c.encodedPath)})})]})]})}},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},14024:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>q});var d=c(48249),e=c(67484),f=c(44384),g=c(33932);function h({currentCwd:a,onSwitchProject:b,collapsed:c,sessions:g}){let{t:i}=(0,f.Bd)(),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(0),n=(0,e.useRef)(null),o=(0,e.useCallback)(a=>{b(a.cwd,a.sessionId),k(!1)},[b]),p=g.filter(a=>"loading"===a.status).length,q=g.filter(a=>"unread"===a.status).length,r=(0,e.useCallback)(a=>{let b=Math.floor((l-a)/6e4);if(b<1)return i("common.justNow");if(b<60)return i("common.minutesAgo",{count:b});let c=Math.floor(b/60);return c<24?i("common.hoursAgo",{count:c}):i("common.daysAgo",{count:Math.floor(c/24)})},[i,l]);return(0,d.jsxs)("div",{className:"relative",ref:n,children:[(0,d.jsxs)("button",{onClick:()=>{m(Date.now()),k(!j)},className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"w-full justify-center":"w-full"}`,title:i("sessions.recentSessions"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),!c&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:i("sessions.recentSessions")}),p>0&&(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-orange-9 animate-pulse ${c?"absolute -top-1 -right-1":""}`,children:p}),q>0&&(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${c&&!p?"absolute -top-1 -right-1":""}`,children:q})]}),j&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:i("sessions.recentSessions")}),p>0&&(0,d.jsxs)("span",{className:"ml-2 text-xs text-orange-11",children:["(",i("sessions.runningCount",{count:p}),")"]}),q>0&&(0,d.jsxs)("span",{className:"ml-2 text-xs text-red-500",children:["(",i("sessions.unreadCount",{count:q}),")"]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===g.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:i("sessions.noSessions")}):g.map((b,c)=>{let e;return(0,d.jsxs)("button",{onClick:()=>o(b),className:`w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 ${c!==g.length-1?"border-b border-border/50":""} ${a===b.cwd?"bg-accent/50":""}`,children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${"loading"===b.status?"bg-orange-9 animate-pulse":"unread"===b.status?"bg-red-500":"bg-muted-foreground/30"}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",title:b.cwd,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"font-medium text-sm truncate",children:(e=b.cwd).split("/").pop()||e}),"loading"===b.status&&(0,d.jsx)("span",{className:"text-xs text-orange-11 flex-shrink-0",children:i("sessions.running")}),"unread"===b.status&&(0,d.jsx)("span",{className:"text-xs text-red-500 flex-shrink-0",children:i("sessions.done")}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:r(b.lastActive)})]}),(b.lastUserMessage||b.title)&&(0,d.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:b.lastUserMessage||b.title})]})]},`${b.cwd}-${b.sessionId}`)})})]})]})}function i({collapsed:a,pinnedSessions:b,onSwitchProject:c,onUnpin:g,onUpdateTitle:h,onReorder:j}){let{t:k}=(0,f.Bd)(),[l,m]=(0,e.useState)(!1),n=(0,e.useRef)(null),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(""),s=(0,e.useRef)(null),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(null),x=(0,e.useCallback)(a=>{o||(c(a.cwd,a.sessionId),m(!1))},[c,o]),y=(0,e.useCallback)((a,b)=>{b.stopPropagation(),p(a.sessionId),r(a.customTitle||"")},[]),z=(0,e.useCallback)(()=>{o&&q.trim()&&h(o,q.trim()),p(null)},[o,q,h]),A=(0,e.useCallback)(a=>{u(a)},[]),B=(0,e.useCallback)((a,b)=>{a.preventDefault(),w(b)},[]),C=(0,e.useCallback)(a=>{if(null===t||t===a){u(null),w(null);return}let c=[...b],[d]=c.splice(t,1);c.splice(a,0,d),j(c),u(null),w(null)},[t,b,j]),D=(0,e.useCallback)(()=>{u(null),w(null)},[]);return(0,d.jsxs)("div",{className:"relative",ref:n,children:[(0,d.jsxs)("button",{onClick:()=>m(!l),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:k("sessions.pinnedSessions"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:k("sessions.pinnedSessions")}),a&&b.length>0&&(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length})]}),l&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-80 max-h-[450px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsx)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg",children:(0,d.jsx)("span",{className:"text-sm font-medium",children:k("sessions.pinnedSessions")})}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:k("sessions.noPinnedSessions")}):b.map((a,c)=>{let e;return(0,d.jsxs)("div",{draggable:!0,onDragStart:()=>A(c),onDragOver:a=>B(a,c),onDrop:()=>C(c),onDragEnd:D,onClick:()=>x(a),className:`group w-full px-3 py-2 text-left hover:bg-accent transition-colors flex items-start gap-2 cursor-pointer ${c!==b.length-1?"border-b border-border/50":""} ${t===c?"opacity-50":""} ${v===c?"border-t-2 border-brand":""}`,children:[(0,d.jsx)("span",{className:"mt-1.5 text-muted-foreground/30 flex-shrink-0 cursor-grab",children:(0,d.jsxs)("svg",{className:"w-3 h-3",viewBox:"0 0 10 16",fill:"currentColor",children:[(0,d.jsx)("circle",{cx:"3",cy:"2",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"2",r:"1.5"}),(0,d.jsx)("circle",{cx:"3",cy:"8",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"8",r:"1.5"}),(0,d.jsx)("circle",{cx:"3",cy:"14",r:"1.5"}),(0,d.jsx)("circle",{cx:"7",cy:"14",r:"1.5"})]})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",title:a.cwd,children:[(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsx)("span",{className:"font-medium text-sm truncate",children:(e=a.cwd).split("/").pop()||e})}),o===a.sessionId?(0,d.jsx)("input",{ref:s,type:"text",value:q,onChange:a=>r(a.target.value),onKeyDown:a=>{a.nativeEvent.isComposing||("Enter"===a.key&&z(),"Escape"===a.key&&p(null))},onBlur:z,onClick:a=>a.stopPropagation(),className:"w-full text-xs px-1 py-0.5 border border-border rounded bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring mt-0.5"}):(0,d.jsx)("div",{className:"text-xs text-foreground/80 truncate",children:a.customTitle||a.sessionId.slice(0,8)})]}),o!==a.sessionId&&(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity mt-0.5",children:[(0,d.jsx)("button",{onClick:b=>y(a,b),className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:k("sessions.editTitle"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),g(a.sessionId)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:k("sessions.remove"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},a.sessionId)})})]})]})}var j=c(31037);function k(a,b){if("once"===a.type)return b("scheduledTasks.onceType",{minutes:a.delayMinutes});if("interval"===a.type){let c=b("scheduledTasks.everyNMinutes",{minutes:a.intervalMinutes});return a.activeFrom&&a.activeTo?`${c} (${a.activeFrom}-${a.activeTo})`:c}return"cron"===a.type?a.cron||"cron":a.type}function l(a){return a.unread?"bg-red-500":a.completed?"bg-muted-foreground":a.paused?"bg-yellow-500":"error"===a.lastResult?"bg-red-500":"bg-green-500"}function m({collapsed:a,tasks:b,unreadCount:c,onSwitchProject:g,onPause:h,onResume:i,onTrigger:n,onDelete:o,onMarkRead:p,onUpdateTask:q,onReorder:r}){let{t:s}=(0,f.Bd)(),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),x=(0,e.useRef)(null),y=b.filter(a=>!a.completed),z=y.filter(a=>!a.paused).length,A=b.filter(a=>a.completed),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),F=(0,e.useCallback)(a=>{C(a)},[]),G=(0,e.useCallback)((a,b)=>{a.preventDefault(),E(b)},[]),H=(0,e.useCallback)(a=>{if(null===B||B===a){C(null),E(null);return}let b=[...y],[c]=b.splice(B,1);b.splice(a,0,c),r([...b,...A].map(a=>a.id)),C(null),E(null)},[B,y,A,r]),I=(0,e.useCallback)(()=>{C(null),E(null)},[]),[,J]=(0,e.useState)(0);return(0,d.jsxs)("div",{className:"relative",ref:x,children:[(0,d.jsxs)("button",{onClick:()=>u(!t),className:`relative flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${a?"w-full justify-center":"w-full"}`,title:s("scheduledTasks.title"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6l4 2"})]}),!a&&(0,d.jsx)("span",{className:"text-sm flex-1 text-left",children:s("scheduledTasks.title")}),c>0?(0,d.jsx)("span",{className:`min-w-[18px] h-[18px] px-1 text-white text-xs font-medium rounded-full flex items-center justify-center bg-red-500 ${a?"absolute -top-1 -right-1":""}`,children:c}):a&&b.length>0?(0,d.jsx)("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 text-muted-foreground text-xs font-medium rounded-full flex items-center justify-center bg-accent",children:b.length}):null]}),t&&(0,d.jsxs)("div",{className:"absolute left-full bottom-0 ml-2 w-96 max-h-[500px] bg-popover border border-border rounded-lg shadow-lg z-50 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b border-border bg-muted/50 flex-shrink-0 rounded-t-lg flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium",children:s("scheduledTasks.title")}),y.length>0&&(0,d.jsxs)("span",{className:"text-xs text-muted-foreground",children:[s("scheduledTasks.activeCount",{running:z}),y.length-z>0?` \xb7 ${s("scheduledTasks.pausedCount",{paused:y.length-z})}`:""]})]}),(0,d.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:0===b.length?(0,d.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:s("scheduledTasks.noScheduledTasks")}):(0,d.jsxs)(d.Fragment,{children:[y.map((a,b)=>{var c;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>F(b),onDragOver:a=>G(a,b),onDrop:()=>H(b),onDragEnd:I,className:`group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 cursor-pointer ${a.unread?"bg-brand/5":""} ${B===b?"opacity-50":""} ${D===b?"border-t-2 border-brand":""}`,onClick:()=>{g(a.cwd,a.sessionId),a.unread&&p(a.id),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${l(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:(c=a.cwd).split("/").pop()||c}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:"\xb7"}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:a.completed?s("scheduledTasks.completed"):a.paused?s("scheduledTasks.paused"):s("common.running")})]}),(0,d.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5",title:a.message,children:a.message}),(0,d.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[(0,d.jsx)("span",{children:k(a,s)}),(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsx)("span",{children:a.paused?s("scheduledTasks.paused"):function(a,b){if(!a)return"-";let c=a-Date.now();if(c<=0)return b("scheduledTasks.aboutToTrigger");if(c<6e4)return b("scheduledTasks.secondsLater",{count:Math.ceil(c/1e3)});if(c<36e5)return b("scheduledTasks.minutesLater",{count:Math.ceil(c/6e4)});if(c<864e5){let a=Math.floor(c/36e5),d=Math.ceil(c%36e5/6e4);return d>0?b("scheduledTasks.hoursMinutesLater",{h:a,m:d}):b("scheduledTasks.hoursLater",{h:a})}return new Date(a).toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.nextFireTime,s)}),a.lastFiredAt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{children:"\xb7"}),(0,d.jsxs)("span",{children:[s("scheduledTasks.lastResult"),": ","success"===a.lastResult?"✓":"✗"]})]})]})]}),(0,d.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),n(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-brand",title:s("scheduledTasks.runNow"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M8 5v14l11-7z"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),w(a)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground",title:s("common.edit"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),a.paused?(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),i(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-green-500",title:s("scheduledTasks.resume"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"})})}):(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),h(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-yellow-500",title:s("scheduledTasks.pause"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 9v6m4-6v6"})})}),(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})},a.id)}),A.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-muted/30 border-b border-border/50",children:s("scheduledTasks.completedCount",{count:A.length})}),A.map(a=>(0,d.jsx)("div",{className:"group px-3 py-2 hover:bg-accent transition-colors border-b border-border/50 opacity-60 cursor-pointer",onClick:()=>{g(a.cwd,a.sessionId),u(!1)},children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)("span",{className:`mt-1.5 w-2 h-2 rounded-full flex-shrink-0 ${l(a)}`}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-sm text-foreground truncate",children:a.message}),(0,d.jsxs)("div",{className:"text-xs text-muted-foreground mt-0.5",children:[k(a,s)," \xb7 ","success"===a.lastResult?s("scheduledTasks.success"):s("scheduledTasks.failure")]})]}),(0,d.jsx)("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,d.jsx)("button",{onClick:b=>{b.stopPropagation(),o(a.id)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-destructive",title:s("common.delete"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]})},a.id))]})]})})]}),v&&(0,d.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30",onClick:()=>w(null)}),(0,d.jsx)("div",{className:"relative",children:(0,d.jsx)(j.E,{onClose:()=>w(null),onCreate:()=>{},editTask:{id:v.id,message:v.message,type:v.type,delayMinutes:v.delayMinutes,intervalMinutes:v.intervalMinutes,activeFrom:v.activeFrom,activeTo:v.activeTo,cron:v.cron},onUpdate:(a,b)=>{q(a,b),w(null)}})})]})]})}var n=c(132),o=c(21108),p=c(13928);function q({projects:a,activeIndex:b,collapsed:c,currentCwd:j,onSelectProject:k,onRemoveProject:l,onReorderProjects:r,onToggleCollapse:s,onOpenSessionBrowser:t,onOpenSettings:u,onOpenNote:v,onOpenSkills:w,onSwitchProject:x,onAddProject:y}){let{t:z}=(0,f.Bd)(),{pinnedSessions:A,unpinSession:B,updateTitle:C,reorder:D}=(0,n.P)(),{tasks:E,unreadCount:F,reload:G,pauseTask:H,resumeTask:I,triggerTask:J,deleteTask:K,updateTask:L,markRead:M,reorderTasks:N}=(0,o.n)(),[O,P]=(0,e.useState)(!1),[Q,R]=(0,e.useState)(null),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)([]);(0,e.useRef)(U);let W=(0,e.useRef)(G),X=(0,e.useCallback)(a=>{try{if("task-fired"===a.type)return void W.current();let{data:b}=a;if(!b)return;V(b.sessions||[])}catch{}},[]);(0,p.h)({url:"/ws/global-state",onMessage:X});let Y=new Set(U.filter(a=>"loading"===a.status).map(a=>a.cwd)),Z=new Set(U.filter(a=>"unread"===a.status).map(a=>a.cwd)),$=(0,e.useCallback)(a=>{R(a)},[]),_=(0,e.useCallback)((a,b)=>{a.preventDefault(),null!==Q&&Q!==b&&T(b)},[Q]),aa=(0,e.useCallback)(b=>{if(null!==Q&&Q!==b){let c=[...a],[d]=c.splice(Q,1);c.splice(b,0,d),r(c)}R(null),T(null)},[Q,a,r]),ab=(0,e.useCallback)(()=>{R(null),T(null)},[]);return(0,d.jsxs)("div",{className:`h-full bg-card border-r border-border flex flex-col transition-all duration-200 ${c?"w-12":"w-56"}`,children:[(0,d.jsxs)("div",{className:"p-2 border-b border-border relative",onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1),children:[(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:t,title:z("workspace.openProject"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),(0,d.jsx)("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]}),!c&&(0,d.jsx)("span",{className:"text-sm",children:z("workspace.openProject")})]}),O&&(c?(0,d.jsx)("button",{className:"absolute inset-0 m-2 flex items-center justify-center px-2 py-2 rounded-lg bg-accent text-foreground transition-colors z-10",onClick:s,title:z("workspace.expandSidebar"),children:(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0 rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}):(0,d.jsx)("button",{className:"absolute top-1/2 -translate-y-1/2 right-2 p-2 rounded-lg bg-accent text-foreground transition-colors z-10",onClick:s,title:z("workspace.collapseSidebar"),children:(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}))]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:a.map((a,e)=>{var f;let h;return(0,d.jsx)("div",{draggable:!0,onDragStart:()=>$(e),onDragOver:a=>_(a,e),onDrop:()=>aa(e),onDragEnd:ab,className:`${S===e?"border-t-2 border-brand":""} ${Q===e?"opacity-50":""}`,children:(0,d.jsx)(g.ProjectItem,{index:e,name:(h=(f=a.cwd).split("/").filter(Boolean))[h.length-1]||f,cwd:a.cwd,isActive:e===b,collapsed:c,hasUnread:Z.has(a.cwd),isLoading:Y.has(a.cwd),onClick:()=>k(e),onRemove:()=>l(e),onOpenNote:()=>v(a.cwd)})},a.cwd)})}),(0,d.jsxs)("div",{className:"p-2 border-t border-border space-y-1",children:[(0,d.jsx)(h,{currentCwd:j,onSwitchProject:x,collapsed:c,sessions:U}),(0,d.jsx)(i,{collapsed:c,pinnedSessions:A,onSwitchProject:x,onUnpin:B,onUpdateTitle:C,onReorder:D}),(0,d.jsx)(m,{collapsed:c,tasks:E,unreadCount:F,onSwitchProject:x,onPause:H,onResume:I,onTrigger:J,onDelete:K,onMarkRead:M,onUpdateTask:L,onReorder:N}),(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:()=>v(),title:z("workspace.notes"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),!c&&(0,d.jsx)("span",{className:"text-sm",children:z("workspace.notes")})]}),(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:w,title:z("workspace.skills"),children:[(0,d.jsx)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})}),!c&&(0,d.jsx)("span",{className:"text-sm",children:z("workspace.skills")})]}),(0,d.jsxs)("button",{className:`w-full flex items-center gap-2 px-2 py-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors ${c?"justify-center":""}`,onClick:u,title:z("workspace.settings"),children:[(0,d.jsxs)("svg",{className:"w-5 h-5 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),!c&&(0,d.jsx)("span",{className:"text-sm",children:z("workspace.settings")})]})]})]})}},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},20999:(a,b,c)=>{"use strict";a.exports=c(41421)},23765:a=>{var b=!0,c=!1,d=!1;function e(a,b,c){var d=a.attrIndex(b),e=[b,c];d<0?a.attrPush(e):a.attrs[d]=e}a.exports=function(a,f){f&&(b=!f.enabled,c=!!f.label,d=!!f.labelAfter),a.core.ruler.after("inline","github-task-lists",function(a){for(var f=a.tokens,g=2;g<f.length;g++)(function(a,b){var c;return"inline"===a[b].type&&"paragraph_open"===a[b-1].type&&"list_item_open"===a[b-2].type&&(0===(c=a[b]).content.indexOf("[ ] ")||0===c.content.indexOf("[x] ")||0===c.content.indexOf("[X] "))})(f,g)&&(function(a,e){if(a.children.unshift(function(a,c){var d=new c("html_inline","",0),e=b?' disabled="" ':"";return 0===a.content.indexOf("[ ] ")?d.content='<input class="task-list-item-checkbox"'+e+'type="checkbox">':(0===a.content.indexOf("[x] ")||0===a.content.indexOf("[X] "))&&(d.content='<input class="task-list-item-checkbox" checked=""'+e+'type="checkbox">'),d}(a,e)),a.children[1].content=a.children[1].content.slice(3),a.content=a.content.slice(3),c)if(d){a.children.pop();var f="task-item-"+Math.ceil(1e7*Math.random()-1e3);a.children[0].content=a.children[0].content.slice(0,-1)+' id="'+f+'">',a.children.push(function(a,b,c){var d=new c("html_inline","",0);return d.content='<label class="task-list-item-label" for="'+b+'">'+a+"</label>",d.attrs=[{for:b}],d}(a.content,f,e))}else a.children.unshift(function(a){var b=new a("html_inline","",0);return b.content="<label>",b}(e)),a.children.push(function(a){var b=new a("html_inline","",0);return b.content="</label>",b}(e))}(f[g],a.Token),e(f[g-2],"class","task-list-item"+(b?"":" enabled")),e(f[function(a,b){for(var c=a[b].level-1,d=b-1;d>=0;d--)if(a[d].level===c)return d;return -1}(f,g-2)],"class","contains-task-list"))})}},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},33932:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>h});var d=c(48249),e=c(67484),f=c(44384);function g({number:a,isActive:b}){return(0,d.jsxs)("svg",{className:`w-6 h-6 flex-shrink-0 ${b?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),(0,d.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:a})]})}function h({index:a,name:b,cwd:c,isActive:i,collapsed:j,hasUnread:k,isLoading:l,onClick:m,onRemove:n,onOpenNote:o}){let{t:p}=(0,f.Bd)(),[q,r]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${j?"justify-center":""} ${i?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:m,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),title:c,children:[(0,d.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,d.jsx)(g,{number:a+1,isActive:i}),k&&!i&&!l&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),l&&(0,d.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"})]}),!j&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"flex-1 truncate text-sm",children:b}),!l&&i?(0,d.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]}),q&&!j&&(0,d.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[o&&(0,d.jsx)("button",{className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),o()},title:p("workspace.projectNotes"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,d.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors",onClick:a=>{a.stopPropagation(),n()},title:p("workspace.closeProject"),children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})}},34396:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>h,dynamic:()=>f,generateMetadata:()=>g});var d=c(5735),e=c(51675);c(43647),c(49090),c(41824);let f="force-dynamic";async function g({searchParams:a}){let b=(await a).cwd,c=b?.split("/").filter(Boolean).pop();return{title:c?`Cockpit - ${c}`:"Cockpit"}}async function h({searchParams:a}){let{cwd:b,sessionId:c}=await a;return(0,d.jsx)(e.Workspace,{initialCwd:b,initialSessionId:c})}},38581:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Workspace:()=>q});var e=c(48249),f=c(67484),g=c(44384),h=c(14024),i=c(1482),j=c(64874),k=c(60306),l=c(62807),m=c(48392),n=c(50605),o=c(68122),p=a([n]);function q({initialCwd:a,initialSessionId:b}){let{t:c}=(0,g.Bd)(),[d,p]=(0,f.useState)([]),[r,s]=(0,f.useState)(0),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(!1),[x,y]=(0,f.useState)(!1),[z,A]=(0,f.useState)(!1),[B,C]=(0,f.useState)(!1),[D,E]=(0,f.useState)(null),[F,G]=(0,f.useState)(!1),[H,I]=(0,f.useState)(!1),[J,K]=(0,f.useState)(new Set),L=(0,f.useRef)(new Map),M=(0,f.useRef)(new Map),N=(0,f.useRef)(new Map);(0,f.useRef)(null),(0,f.useCallback)(async()=>{try{let a=await fetch("/api/projects");if(a.ok){let b=await a.json();p(b.projects||[]),s(b.activeIndex||0),u(b.collapsed||!1)}}catch(a){console.error("Failed to load projects:",a)}finally{I(!0)}},[]);let O=(0,f.useCallback)(async(a,b,c)=>{try{await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projects:a,activeIndex:b,collapsed:c})})}catch(a){console.error("Failed to save projects:",a)}},[]),P=(0,f.useCallback)((a,b)=>{let c=new URL(window.location.href);c.searchParams.set("cwd",a),b?c.searchParams.set("sessionId",b):c.searchParams.delete("sessionId"),window.history.replaceState({},"",c.toString());let d=a.split("/").filter(Boolean).pop();document.title=d?`Cockpit - ${d}`:"Cockpit"},[]);(0,f.useRef)(!1);let Q=(0,f.useCallback)(a=>{s(a),O(d,a,t);let b=d[a];if(b?.cwd){let a=N.current.get(b.cwd);P(b.cwd,a)}},[d,t,O,P]),R=(0,f.useCallback)(a=>{let b=d.filter((b,c)=>c!==a),c=r;a<r?c=r-1:a===r&&c>=b.length&&(c=Math.max(0,b.length-1)),p(b),s(c),O(b,c,t)},[d,r,t,O]),S=(0,f.useCallback)(a=>{let b=d[r],c=a.findIndex(a=>a.cwd===b?.cwd);p(a),s(c>=0?c:0),O(a,c>=0?c:0,t)},[d,r,t,O]),T=(0,f.useCallback)(()=>{let a=!t;u(a),O(d,r,a)},[d,r,t,O]),U=(0,f.useCallback)((a,b)=>{N.current.set(a,b);let c=d.findIndex(b=>b.cwd===a);if(c>=0){let e=L.current.get(a);e?.contentWindow&&e.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b,switchToAgent:!0},"*"),s(c),O(d,c,t)}else{let c=[...d,{cwd:a}],e=c.length-1;p(c),s(e),O(c,e,t),M.current.set(a,{sessionId:b,switchToAgent:!0})}P(a,b),w(!1)},[d,t,O,P]),V=(0,f.useCallback)((a,b)=>{N.current.set(a,b);let c=d.findIndex(b=>b.cwd===a);if(c>=0){let e=L.current.get(a);e?.contentWindow&&e.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b,switchToAgent:!0},"*"),c!==r&&(s(c),O(d,c,t))}else{let c=[...d,{cwd:a}],e=c.length-1;p(c),s(e),O(c,e,t),M.current.set(a,{sessionId:b,switchToAgent:!0})}P(a,b)},[d,r,t,O,P]),W=(0,f.useCallback)(a=>{let b=M.current.get(a);if(b){let c=L.current.get(a);c?.contentWindow&&c.contentWindow.postMessage({type:"SWITCH_SESSION",sessionId:b.sessionId,switchToAgent:b.switchToAgent},"*"),M.current.delete(a)}},[]);return H?(0,e.jsxs)("div",{className:"h-screen flex bg-background overflow-hidden",children:[(0,e.jsx)(h.ProjectSidebar,{projects:d,activeIndex:r,collapsed:t,currentCwd:d[r]?.cwd,onSelectProject:Q,onRemoveProject:R,onReorderProjects:S,onToggleCollapse:T,onOpenSessionBrowser:()=>w(!0),onOpenSettings:()=>y(!0),onOpenNote:a=>{E(a??null),C(!0)},onOpenSkills:()=>G(!0),onSwitchProject:V,onAddProject:a=>{let b=d.findIndex(b=>b.cwd===a);if(b>=0)s(b),O(d,b,t);else{let b=[...d,{cwd:a}],c=b.length-1;p(b),s(c),O(b,c,t)}}}),(0,e.jsx)("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:0===d.length?(0,e.jsx)(i.EmptyState,{onSelectSession:U}):(0,e.jsx)("div",{className:"flex-1 relative overflow-hidden",children:d.map((a,b)=>J.has(a.cwd)&&(0,e.jsx)("iframe",{ref:b=>{b?L.current.set(a.cwd,b):L.current.delete(a.cwd)},src:`/project?cwd=${encodeURIComponent(a.cwd)}`,onLoad:()=>W(a.cwd),className:`absolute inset-0 w-full h-full border-0 ${b===r?"block":"hidden"}`,title:`Project: ${a.cwd}`},a.cwd))})}),(0,e.jsx)(j.r,{isOpen:v,onClose:()=>w(!1),onSelectSession:U,onAddProject:a=>{let b=d.findIndex(b=>b.cwd===a);if(b>=0)s(b),O(d,b,t);else{let b=[...d,{cwd:a}],c=b.length-1;p(b),s(c),O(b,c,t)}w(!1)}}),(0,e.jsx)(k.b,{isOpen:x,onClose:()=>y(!1)}),(0,e.jsx)(l.w,{isOpen:z,onClose:()=>A(!1)}),(0,e.jsx)(m.k,{isOpen:B,onClose:()=>{C(!1),E(null)},projectCwd:D,projectName:D?D.split("/").pop():null}),(0,e.jsx)(n.g,{isOpen:F,onClose:()=>G(!1)}),(0,e.jsx)(o.M,{onNavigate:V})]}):(0,e.jsx)("div",{className:"h-screen flex items-center justify-center bg-card",children:(0,e.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,e.jsxs)("svg",{className:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,e.jsx)("span",{children:c("workspace.loadingText")})]})})}n=(p.then?(await p)():p)[0],d()}catch(a){d(a)}})},39017:(a,b,c)=>{Promise.resolve().then(c.bind(c,1482)),Promise.resolve().then(c.bind(c,33932)),Promise.resolve().then(c.bind(c,14024)),Promise.resolve().then(c.bind(c,38581))},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41421:(a,b,c)=>{"use strict";var d=c(67484),e=c(42237),f="function"==typeof Object.is?Object.is:function(a,b){return a===b&&(0!==a||1/a==1/b)||a!=a&&b!=b},g=e.useSyncExternalStore,h=d.useRef,i=d.useEffect,j=d.useMemo,k=d.useDebugValue;b.useSyncExternalStoreWithSelector=function(a,b,c,d,e){var l=h(null);if(null===l.current){var m={hasValue:!1,value:null};l.current=m}else m=l.current;var n=g(a,(l=j(function(){function a(a){if(!i){if(i=!0,g=a,a=d(a),void 0!==e&&m.hasValue){var b=m.value;if(e(b,a))return h=b}return h=a}if(b=h,f(g,a))return b;var c=d(a);return void 0!==e&&e(b,c)?(g=a,b):(g=a,h=c)}var g,h,i=!1,j=void 0===c?null:c;return[function(){return a(b())},null===j?void 0:function(){return a(j())}]},[b,c,d,e]))[0],l[1]);return i(function(){m.hasValue=!0,m.value=n},[n]),k(n),n}},41824:(a,b,c)=>{"use strict";c.d(b,{EmptyState:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call EmptyState() from the server but EmptyState is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/EmptyState.tsx","EmptyState")},43647:(a,b,c)=>{"use strict";c.d(b,{ProjectSidebar:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectSidebar() from the server but ProjectSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/ProjectSidebar.tsx","ProjectSidebar")},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},48392:(a,b,c)=>{"use strict";let d,e;c.d(b,{k:()=>oA});var f,g,h,i,j,k,l,m,n,o,p,q,r,s={};c.r(s),c.d(s,{decode:()=>lF,encode:()=>lI,format:()=>lJ,parse:()=>lU});var t={};c.r(t),c.d(t,{Any:()=>lX,Cc:()=>lY,Cf:()=>lZ,P:()=>lV,S:()=>lW,Z:()=>l$});var u={};c.r(u),c.d(u,{arrayReplaceAt:()=>me,assign:()=>md,escapeHtml:()=>mq,escapeRE:()=>ms,fromCodePoint:()=>mg,has:()=>mc,isMdAsciiPunct:()=>mw,isPunctChar:()=>mv,isSpace:()=>mt,isString:()=>ma,isValidEntityCode:()=>mf,isWhiteSpace:()=>mu,lib:()=>my,normalizeReference:()=>mx,unescapeAll:()=>ml,unescapeMd:()=>mk});var v={};c.r(v),c.d(v,{parseLinkDestination:()=>mA,parseLinkLabel:()=>mz,parseLinkTitle:()=>mB});var w=c(48249),x=c(67484),y=c(44384),z=c(41564),A=c(74429),B=c(42237);function C(a){this.content=a}C.prototype={constructor:C,find:function(a){for(var b=0;b<this.content.length;b+=2)if(this.content[b]===a)return b;return -1},get:function(a){var b=this.find(a);return -1==b?void 0:this.content[b+1]},update:function(a,b,c){var d=c&&c!=a?this.remove(c):this,e=d.find(a),f=d.content.slice();return -1==e?f.push(c||a,b):(f[e+1]=b,c&&(f[e]=c)),new C(f)},remove:function(a){var b=this.find(a);if(-1==b)return this;var c=this.content.slice();return c.splice(b,2),new C(c)},addToStart:function(a,b){return new C([a,b].concat(this.remove(a).content))},addToEnd:function(a,b){var c=this.remove(a).content.slice();return c.push(a,b),new C(c)},addBefore:function(a,b,c){var d=this.remove(b),e=d.content.slice(),f=d.find(a);return e.splice(-1==f?e.length:f,0,b,c),new C(e)},forEach:function(a){for(var b=0;b<this.content.length;b+=2)a(this.content[b],this.content[b+1])},prepend:function(a){return(a=C.from(a)).size?new C(a.content.concat(this.subtract(a).content)):this},append:function(a){return(a=C.from(a)).size?new C(this.subtract(a).content.concat(a.content)):this},subtract:function(a){var b=this;a=C.from(a);for(var c=0;c<a.content.length;c+=2)b=b.remove(a.content[c]);return b},toObject:function(){var a={};return this.forEach(function(b,c){a[b]=c}),a},get size(){return this.content.length>>1}},C.from=function(a){if(a instanceof C)return a;var b=[];if(a)for(var c in a)b.push(c,a[c]);return new C(b)};class D{constructor(a,b){if(this.content=a,this.size=b||0,null==b)for(let b=0;b<a.length;b++)this.size+=a[b].nodeSize}nodesBetween(a,b,c,d=0,e){for(let f=0,g=0;g<b;f++){let h=this.content[f],i=g+h.nodeSize;if(i>a&&!1!==c(h,d+g,e||null,f)&&h.content.size){let e=g+1;h.nodesBetween(Math.max(0,a-e),Math.min(h.content.size,b-e),c,d+e)}g=i}}descendants(a){this.nodesBetween(0,this.size,a)}textBetween(a,b,c,d){let e="",f=!0;return this.nodesBetween(a,b,(g,h)=>{let i=g.isText?g.text.slice(Math.max(a,h)-h,b-h):g.isLeaf?d?"function"==typeof d?d(g):d:g.type.spec.leafText?g.type.spec.leafText(g):"":"";g.isBlock&&(g.isLeaf&&i||g.isTextblock)&&c&&(f?f=!1:e+=c),e+=i},0),e}append(a){if(!a.size)return this;if(!this.size)return a;let b=this.lastChild,c=a.firstChild,d=this.content.slice(),e=0;for(b.isText&&b.sameMarkup(c)&&(d[d.length-1]=b.withText(b.text+c.text),e=1);e<a.content.length;e++)d.push(a.content[e]);return new D(d,this.size+a.size)}cut(a,b=this.size){if(0==a&&b==this.size)return this;let c=[],d=0;if(b>a)for(let e=0,f=0;f<b;e++){let g=this.content[e],h=f+g.nodeSize;h>a&&((f<a||h>b)&&(g=g.isText?g.cut(Math.max(0,a-f),Math.min(g.text.length,b-f)):g.cut(Math.max(0,a-f-1),Math.min(g.content.size,b-f-1))),c.push(g),d+=g.nodeSize),f=h}return new D(c,d)}cutByIndex(a,b){return a==b?D.empty:0==a&&b==this.content.length?this:new D(this.content.slice(a,b))}replaceChild(a,b){let c=this.content[a];if(c==b)return this;let d=this.content.slice(),e=this.size+b.nodeSize-c.nodeSize;return d[a]=b,new D(d,e)}addToStart(a){return new D([a].concat(this.content),this.size+a.nodeSize)}addToEnd(a){return new D(this.content.concat(a),this.size+a.nodeSize)}eq(a){if(this.content.length!=a.content.length)return!1;for(let b=0;b<this.content.length;b++)if(!this.content[b].eq(a.content[b]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(a){let b=this.content[a];if(!b)throw RangeError("Index "+a+" out of range for "+this);return b}maybeChild(a){return this.content[a]||null}forEach(a){for(let b=0,c=0;b<this.content.length;b++){let d=this.content[b];a(d,c,b),c+=d.nodeSize}}findDiffStart(a,b=0){return function a(b,c,d){for(let e=0;;e++){if(e==b.childCount||e==c.childCount)return b.childCount==c.childCount?null:d;let f=b.child(e),g=c.child(e);if(f==g){d+=f.nodeSize;continue}if(!f.sameMarkup(g))return d;if(f.isText&&f.text!=g.text){for(let a=0;f.text[a]==g.text[a];a++)d++;return d}if(f.content.size||g.content.size){let b=a(f.content,g.content,d+1);if(null!=b)return b}d+=f.nodeSize}}(this,a,b)}findDiffEnd(a,b=this.size,c=a.size){return function a(b,c,d,e){for(let f=b.childCount,g=c.childCount;;){if(0==f||0==g)return f==g?null:{a:d,b:e};let h=b.child(--f),i=c.child(--g),j=h.nodeSize;if(h==i){d-=j,e-=j;continue}if(!h.sameMarkup(i))return{a:d,b:e};if(h.isText&&h.text!=i.text){let a=0,b=Math.min(h.text.length,i.text.length);for(;a<b&&h.text[h.text.length-a-1]==i.text[i.text.length-a-1];)a++,d--,e--;return{a:d,b:e}}if(h.content.size||i.content.size){let b=a(h.content,i.content,d-1,e-1);if(b)return b}d-=j,e-=j}}(this,a,b,c)}findIndex(a){if(0==a)return F(0,a);if(a==this.size)return F(this.content.length,a);if(a>this.size||a<0)throw RangeError(`Position ${a} outside of fragment (${this})`);for(let b=0,c=0;;b++){let d=c+this.child(b).nodeSize;if(d>=a){if(d==a)return F(b+1,d);return F(b,c)}c=d}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(a=>a.toJSON()):null}static fromJSON(a,b){if(!b)return D.empty;if(!Array.isArray(b))throw RangeError("Invalid input for Fragment.fromJSON");return new D(b.map(a.nodeFromJSON))}static fromArray(a){if(!a.length)return D.empty;let b,c=0;for(let d=0;d<a.length;d++){let e=a[d];c+=e.nodeSize,d&&e.isText&&a[d-1].sameMarkup(e)?(b||(b=a.slice(0,d)),b[b.length-1]=e.withText(b[b.length-1].text+e.text)):b&&b.push(e)}return new D(b||a,c)}static from(a){if(!a)return D.empty;if(a instanceof D)return a;if(Array.isArray(a))return this.fromArray(a);if(a.attrs)return new D([a],a.nodeSize);throw RangeError("Can not convert "+a+" to a Fragment"+(a.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}D.empty=new D([],0);let E={index:0,offset:0};function F(a,b){return E.index=a,E.offset=b,E}function G(a,b){if(a===b)return!0;if(!(a&&"object"==typeof a)||!(b&&"object"==typeof b))return!1;let c=Array.isArray(a);if(Array.isArray(b)!=c)return!1;if(c){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!G(a[c],b[c]))return!1}else{for(let c in a)if(!(c in b)||!G(a[c],b[c]))return!1;for(let c in b)if(!(c in a))return!1}return!0}class H{constructor(a,b){this.type=a,this.attrs=b}addToSet(a){let b,c=!1;for(let d=0;d<a.length;d++){let e=a[d];if(this.eq(e))return a;if(this.type.excludes(e.type))b||(b=a.slice(0,d));else{if(e.type.excludes(this.type))return a;!c&&e.type.rank>this.type.rank&&(b||(b=a.slice(0,d)),b.push(this),c=!0),b&&b.push(e)}}return b||(b=a.slice()),c||b.push(this),b}removeFromSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return a.slice(0,b).concat(a.slice(b+1));return a}isInSet(a){for(let b=0;b<a.length;b++)if(this.eq(a[b]))return!0;return!1}eq(a){return this==a||this.type==a.type&&G(this.attrs,a.attrs)}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return a}static fromJSON(a,b){if(!b)throw RangeError("Invalid input for Mark.fromJSON");let c=a.marks[b.type];if(!c)throw RangeError(`There is no mark type ${b.type} in this schema`);let d=c.create(b.attrs);return c.checkAttrs(d.attrs),d}static sameSet(a,b){if(a==b)return!0;if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].eq(b[c]))return!1;return!0}static setFrom(a){if(!a||Array.isArray(a)&&0==a.length)return H.none;if(a instanceof H)return[a];let b=a.slice();return b.sort((a,b)=>a.type.rank-b.type.rank),b}}H.none=[];class I extends Error{}class J{constructor(a,b,c){this.content=a,this.openStart=b,this.openEnd=c}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(a,b){let c=function a(b,c,d,e){let{index:f,offset:g}=b.findIndex(c),h=b.maybeChild(f);if(g==c||h.isText)return e&&!e.canReplace(f,f,d)?null:b.cut(0,c).append(d).append(b.cut(c));let i=a(h.content,c-g-1,d,h);return i&&b.replaceChild(f,h.copy(i))}(this.content,a+this.openStart,b);return c&&new J(c,this.openStart,this.openEnd)}removeBetween(a,b){return new J(function a(b,c,d){let{index:e,offset:f}=b.findIndex(c),g=b.maybeChild(e),{index:h,offset:i}=b.findIndex(d);if(f==c||g.isText){if(i!=d&&!b.child(h).isText)throw RangeError("Removing non-flat range");return b.cut(0,c).append(b.cut(d))}if(e!=h)throw RangeError("Removing non-flat range");return b.replaceChild(e,g.copy(a(g.content,c-f-1,d-f-1)))}(this.content,a+this.openStart,b+this.openStart),this.openStart,this.openEnd)}eq(a){return this.content.eq(a.content)&&this.openStart==a.openStart&&this.openEnd==a.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let a={content:this.content.toJSON()};return this.openStart>0&&(a.openStart=this.openStart),this.openEnd>0&&(a.openEnd=this.openEnd),a}static fromJSON(a,b){if(!b)return J.empty;let c=b.openStart||0,d=b.openEnd||0;if("number"!=typeof c||"number"!=typeof d)throw RangeError("Invalid input for Slice.fromJSON");return new J(D.fromJSON(a,b.content),c,d)}static maxOpen(a,b=!0){let c=0,d=0;for(let d=a.firstChild;d&&!d.isLeaf&&(b||!d.type.spec.isolating);d=d.firstChild)c++;for(let c=a.lastChild;c&&!c.isLeaf&&(b||!c.type.spec.isolating);c=c.lastChild)d++;return new J(a,c,d)}}function K(a,b){if(!b.type.compatibleContent(a.type))throw new I("Cannot join "+b.type.name+" onto "+a.type.name)}function L(a,b,c){let d=a.node(c);return K(d,b.node(c)),d}function M(a,b){let c=b.length-1;c>=0&&a.isText&&a.sameMarkup(b[c])?b[c]=a.withText(b[c].text+a.text):b.push(a)}function N(a,b,c,d){let e=(b||a).node(c),f=0,g=b?b.index(c):e.childCount;a&&(f=a.index(c),a.depth>c?f++:a.textOffset&&(M(a.nodeAfter,d),f++));for(let a=f;a<g;a++)M(e.child(a),d);b&&b.depth==c&&b.textOffset&&M(b.nodeBefore,d)}function O(a,b){return a.type.checkContent(b),a.copy(b)}function P(a,b,c){let d=[];return N(null,a,c,d),a.depth>c&&M(O(L(a,b,c+1),P(a,b,c+1)),d),N(b,null,c,d),new D(d)}J.empty=new J(D.empty,0,0);class Q{constructor(a,b,c){this.pos=a,this.path=b,this.parentOffset=c,this.depth=b.length/3-1}resolveDepth(a){return null==a?this.depth:a<0?this.depth+a:a}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(a){return this.path[3*this.resolveDepth(a)]}index(a){return this.path[3*this.resolveDepth(a)+1]}indexAfter(a){return a=this.resolveDepth(a),this.index(a)+(a!=this.depth||this.textOffset?1:0)}start(a){return 0==(a=this.resolveDepth(a))?0:this.path[3*a-1]+1}end(a){return a=this.resolveDepth(a),this.start(a)+this.node(a).content.size}before(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position before the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]}after(a){if(!(a=this.resolveDepth(a)))throw RangeError("There is no position after the top-level node");return a==this.depth+1?this.pos:this.path[3*a-1]+this.path[3*a].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let a=this.parent,b=this.index(this.depth);if(b==a.childCount)return null;let c=this.pos-this.path[this.path.length-1],d=a.child(b);return c?a.child(b).cut(c):d}get nodeBefore(){let a=this.index(this.depth),b=this.pos-this.path[this.path.length-1];return b?this.parent.child(a).cut(0,b):0==a?null:this.parent.child(a-1)}posAtIndex(a,b){b=this.resolveDepth(b);let c=this.path[3*b],d=0==b?0:this.path[3*b-1]+1;for(let b=0;b<a;b++)d+=c.child(b).nodeSize;return d}marks(){let a=this.parent,b=this.index();if(0==a.content.size)return H.none;if(this.textOffset)return a.child(b).marks;let c=a.maybeChild(b-1),d=a.maybeChild(b);if(!c){let a=c;c=d,d=a}let e=c.marks;for(var f=0;f<e.length;f++)!1!==e[f].type.spec.inclusive||d&&e[f].isInSet(d.marks)||(e=e[f--].removeFromSet(e));return e}marksAcross(a){let b=this.parent.maybeChild(this.index());if(!b||!b.isInline)return null;let c=b.marks,d=a.parent.maybeChild(a.index());for(var e=0;e<c.length;e++)!1!==c[e].type.spec.inclusive||d&&c[e].isInSet(d.marks)||(c=c[e--].removeFromSet(c));return c}sharedDepth(a){for(let b=this.depth;b>0;b--)if(this.start(b)<=a&&this.end(b)>=a)return b;return 0}blockRange(a=this,b){if(a.pos<this.pos)return a.blockRange(this);for(let c=this.depth-(this.parent.inlineContent||this.pos==a.pos?1:0);c>=0;c--)if(a.pos<=this.end(c)&&(!b||b(this.node(c))))return new U(this,a,c);return null}sameParent(a){return this.pos-this.parentOffset==a.pos-a.parentOffset}max(a){return a.pos>this.pos?a:this}min(a){return a.pos<this.pos?a:this}toString(){let a="";for(let b=1;b<=this.depth;b++)a+=(a?"/":"")+this.node(b).type.name+"_"+this.index(b-1);return a+":"+this.parentOffset}static resolve(a,b){if(!(b>=0&&b<=a.content.size))throw RangeError("Position "+b+" out of range");let c=[],d=0,e=b;for(let b=a;;){let{index:a,offset:f}=b.content.findIndex(e),g=e-f;if(c.push(b,a,d+f),!g||(b=b.child(a)).isText)break;e=g-1,d+=f+1}return new Q(b,c,e)}static resolveCached(a,b){let c=T.get(a);if(c)for(let a=0;a<c.elts.length;a++){let d=c.elts[a];if(d.pos==b)return d}else T.set(a,c=new R);let d=c.elts[c.i]=Q.resolve(a,b);return c.i=(c.i+1)%S,d}}class R{constructor(){this.elts=[],this.i=0}}let S=12,T=new WeakMap;class U{constructor(a,b,c){this.$from=a,this.$to=b,this.depth=c}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}let V=Object.create(null);class W{constructor(a,b,c,d=H.none){this.type=a,this.attrs=b,this.marks=d,this.content=c||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(a){return this.content.child(a)}maybeChild(a){return this.content.maybeChild(a)}forEach(a){this.content.forEach(a)}nodesBetween(a,b,c,d=0){this.content.nodesBetween(a,b,c,d,this)}descendants(a){this.nodesBetween(0,this.content.size,a)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(a,b,c,d){return this.content.textBetween(a,b,c,d)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(a){return this==a||this.sameMarkup(a)&&this.content.eq(a.content)}sameMarkup(a){return this.hasMarkup(a.type,a.attrs,a.marks)}hasMarkup(a,b,c){return this.type==a&&G(this.attrs,b||a.defaultAttrs||V)&&H.sameSet(this.marks,c||H.none)}copy(a=null){return a==this.content?this:new W(this.type,this.attrs,a,this.marks)}mark(a){return a==this.marks?this:new W(this.type,this.attrs,this.content,a)}cut(a,b=this.content.size){return 0==a&&b==this.content.size?this:this.copy(this.content.cut(a,b))}slice(a,b=this.content.size,c=!1){if(a==b)return J.empty;let d=this.resolve(a),e=this.resolve(b),f=c?0:d.sharedDepth(b),g=d.start(f);return new J(d.node(f).content.cut(d.pos-g,e.pos-g),d.depth-f,e.depth-f)}replace(a,b,c){var d=this.resolve(a),e=this.resolve(b);if(c.openStart>d.depth)throw new I("Inserted content deeper than insertion position");if(d.depth-c.openStart!=e.depth-c.openEnd)throw new I("Inconsistent open depths");return function a(b,c,d,e){let f=b.index(e),g=b.node(e);if(f==c.index(e)&&e<b.depth-d.openStart){let h=a(b,c,d,e+1);return g.copy(g.content.replaceChild(f,h))}if(!d.content.size)return O(g,P(b,c,e));if(d.openStart||d.openEnd||b.depth!=e||c.depth!=e){let{start:a,end:f}=function(a,b){let c=b.depth-a.openStart,d=b.node(c).copy(a.content);for(let a=c-1;a>=0;a--)d=b.node(a).copy(D.from(d));return{start:d.resolveNoCache(a.openStart+c),end:d.resolveNoCache(d.content.size-a.openEnd-c)}}(d,b);return O(g,function a(b,c,d,e,f){let g=b.depth>f&&L(b,c,f+1),h=e.depth>f&&L(d,e,f+1),i=[];return N(null,b,f,i),g&&h&&c.index(f)==d.index(f)?(K(g,h),M(O(g,a(b,c,d,e,f+1)),i)):(g&&M(O(g,P(b,c,f+1)),i),N(c,d,f,i),h&&M(O(h,P(d,e,f+1)),i)),N(e,null,f,i),new D(i)}(b,a,f,c,e))}{let a=b.parent,e=a.content;return O(a,e.cut(0,b.parentOffset).append(d.content).append(e.cut(c.parentOffset)))}}(d,e,c,0)}nodeAt(a){for(let b=this;;){let{index:c,offset:d}=b.content.findIndex(a);if(!(b=b.maybeChild(c)))return null;if(d==a||b.isText)return b;a-=d+1}}childAfter(a){let{index:b,offset:c}=this.content.findIndex(a);return{node:this.content.maybeChild(b),index:b,offset:c}}childBefore(a){if(0==a)return{node:null,index:0,offset:0};let{index:b,offset:c}=this.content.findIndex(a);if(c<a)return{node:this.content.child(b),index:b,offset:c};let d=this.content.child(b-1);return{node:d,index:b-1,offset:c-d.nodeSize}}resolve(a){return Q.resolveCached(this,a)}resolveNoCache(a){return Q.resolve(this,a)}rangeHasMark(a,b,c){let d=!1;return b>a&&this.nodesBetween(a,b,a=>(c.isInSet(a.marks)&&(d=!0),!d)),d}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let a=this.type.name;return this.content.size&&(a+="("+this.content.toStringInner()+")"),Y(this.marks,a)}contentMatchAt(a){let b=this.type.contentMatch.matchFragment(this.content,0,a);if(!b)throw Error("Called contentMatchAt on a node with invalid content");return b}canReplace(a,b,c=D.empty,d=0,e=c.childCount){let f=this.contentMatchAt(a).matchFragment(c,d,e),g=f&&f.matchFragment(this.content,b);if(!g||!g.validEnd)return!1;for(let a=d;a<e;a++)if(!this.type.allowsMarks(c.child(a).marks))return!1;return!0}canReplaceWith(a,b,c,d){if(d&&!this.type.allowsMarks(d))return!1;let e=this.contentMatchAt(a).matchType(c),f=e&&e.matchFragment(this.content,b);return!!f&&f.validEnd}canAppend(a){return a.content.size?this.canReplace(this.childCount,this.childCount,a.content):this.type.compatibleContent(a.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let a=H.none;for(let b=0;b<this.marks.length;b++){let c=this.marks[b];c.type.checkAttrs(c.attrs),a=c.addToSet(a)}if(!H.sameSet(a,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(a=>a.type.name)}`);this.content.forEach(a=>a.check())}toJSON(){let a={type:this.type.name};for(let b in this.attrs){a.attrs=this.attrs;break}return this.content.size&&(a.content=this.content.toJSON()),this.marks.length&&(a.marks=this.marks.map(a=>a.toJSON())),a}static fromJSON(a,b){let c;if(!b)throw RangeError("Invalid input for Node.fromJSON");if(b.marks){if(!Array.isArray(b.marks))throw RangeError("Invalid mark data for Node.fromJSON");c=b.marks.map(a.markFromJSON)}if("text"==b.type){if("string"!=typeof b.text)throw RangeError("Invalid text node in JSON");return a.text(b.text,c)}let d=D.fromJSON(a,b.content),e=a.nodeType(b.type).create(b.attrs,d,c);return e.type.checkAttrs(e.attrs),e}}W.prototype.text=void 0;class X extends W{constructor(a,b,c,d){if(super(a,b,null,d),!c)throw RangeError("Empty text nodes are not allowed");this.text=c}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Y(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(a,b){return this.text.slice(a,b)}get nodeSize(){return this.text.length}mark(a){return a==this.marks?this:new X(this.type,this.attrs,this.text,a)}withText(a){return a==this.text?this:new X(this.type,this.attrs,a,this.marks)}cut(a=0,b=this.text.length){return 0==a&&b==this.text.length?this:this.withText(this.text.slice(a,b))}eq(a){return this.sameMarkup(a)&&this.text==a.text}toJSON(){let a=super.toJSON();return a.text=this.text,a}}function Y(a,b){for(let c=a.length-1;c>=0;c--)b=a[c].type.name+"("+b+")";return b}class Z{constructor(a){this.validEnd=a,this.next=[],this.wrapCache=[]}static parse(a,b){var c;let d,e=new $(a,b);if(null==e.next)return Z.empty;let f=function a(b){let c=[];do c.push(function(b){let c=[];do c.push(function(b){let c=function(b){if(b.eat("(")){let c=a(b);return b.eat(")")||b.err("Missing closing paren"),c}if(/\W/.test(b.next))b.err("Unexpected token '"+b.next+"'");else{let a=(function(a,b){let c=a.nodeTypes,d=c[b];if(d)return[d];let e=[];for(let a in c){let d=c[a];d.isInGroup(b)&&e.push(d)}return 0==e.length&&a.err("No node type or group '"+b+"' found"),e})(b,b.next).map(a=>(null==b.inline?b.inline=a.isInline:b.inline!=a.isInline&&b.err("Mixing inline and block content"),{type:"name",value:a}));return b.pos++,1==a.length?a[0]:{type:"choice",exprs:a}}}(b);for(;;)if(b.eat("+"))c={type:"plus",expr:c};else if(b.eat("*"))c={type:"star",expr:c};else if(b.eat("?"))c={type:"opt",expr:c};else if(b.eat("{"))c=function(a,b){let c=_(a),d=c;return a.eat(",")&&(d="}"!=a.next?_(a):-1),a.eat("}")||a.err("Unclosed braced range"),{type:"range",min:c,max:d,expr:b}}(b,c);else break;return c}(b));while(b.next&&")"!=b.next&&"|"!=b.next);return 1==c.length?c[0]:{type:"seq",exprs:c}}(b));while(b.eat("|"));return 1==c.length?c[0]:{type:"choice",exprs:c}}(e);e.next&&e.err("Unexpected trailing text");let g=(c=function(a){let b=[[]];return e(function a(b,f){if("choice"==b.type)return b.exprs.reduce((b,c)=>b.concat(a(c,f)),[]);if("seq"==b.type)for(let d=0;;d++){let g=a(b.exprs[d],f);if(d==b.exprs.length-1)return g;e(g,f=c())}else if("star"==b.type){let g=c();return d(f,g),e(a(b.expr,g),g),[d(g)]}else if("plus"==b.type){let g=c();return e(a(b.expr,f),g),e(a(b.expr,g),g),[d(g)]}else if("opt"==b.type)return[d(f)].concat(a(b.expr,f));else if("range"==b.type){let g=f;for(let d=0;d<b.min;d++){let d=c();e(a(b.expr,g),d),g=d}if(-1==b.max)e(a(b.expr,g),g);else for(let f=b.min;f<b.max;f++){let f=c();d(g,f),e(a(b.expr,g),f),g=f}return[d(g)]}else if("name"==b.type)return[d(f,void 0,b.value)];else throw Error("Unknown expr type")}(a,0),c()),b;function c(){return b.push([])-1}function d(a,c,d){let e={term:d,to:c};return b[a].push(e),e}function e(a,b){a.forEach(a=>a.to=b)}}(f),d=Object.create(null),function a(b){let e=[];b.forEach(a=>{c[a].forEach(({term:a,to:b})=>{let d;if(a){for(let b=0;b<e.length;b++)e[b][0]==a&&(d=e[b][1]);ab(c,b).forEach(b=>{d||e.push([a,d=[]]),-1==d.indexOf(b)&&d.push(b)})}})});let f=d[b.join(",")]=new Z(b.indexOf(c.length-1)>-1);for(let b=0;b<e.length;b++){let c=e[b][1].sort(aa);f.next.push({type:e[b][0],next:d[c.join(",")]||a(c)})}return f}(ab(c,0)));return function(a,b){for(let c=0,d=[a];c<d.length;c++){let a=d[c],e=!a.validEnd,f=[];for(let b=0;b<a.next.length;b++){let{type:c,next:g}=a.next[b];f.push(c.name),e&&!(c.isText||c.hasRequiredAttrs())&&(e=!1),-1==d.indexOf(g)&&d.push(g)}e&&b.err("Only non-generatable nodes ("+f.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(g,e),g}matchType(a){for(let b=0;b<this.next.length;b++)if(this.next[b].type==a)return this.next[b].next;return null}matchFragment(a,b=0,c=a.childCount){let d=this;for(let e=b;d&&e<c;e++)d=d.matchType(a.child(e).type);return d}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let a=0;a<this.next.length;a++){let{type:b}=this.next[a];if(!(b.isText||b.hasRequiredAttrs()))return b}return null}compatible(a){for(let b=0;b<this.next.length;b++)for(let c=0;c<a.next.length;c++)if(this.next[b].type==a.next[c].type)return!0;return!1}fillBefore(a,b=!1,c=0){let d=[this];return function e(f,g){let h=f.matchFragment(a,c);if(h&&(!b||h.validEnd))return D.from(g.map(a=>a.createAndFill()));for(let a=0;a<f.next.length;a++){let{type:b,next:c}=f.next[a];if(!(b.isText||b.hasRequiredAttrs())&&-1==d.indexOf(c)){d.push(c);let a=e(c,g.concat(b));if(a)return a}}return null}(this,[])}findWrapping(a){for(let b=0;b<this.wrapCache.length;b+=2)if(this.wrapCache[b]==a)return this.wrapCache[b+1];let b=this.computeWrapping(a);return this.wrapCache.push(a,b),b}computeWrapping(a){let b=Object.create(null),c=[{match:this,type:null,via:null}];for(;c.length;){let d=c.shift(),e=d.match;if(e.matchType(a)){let a=[];for(let b=d;b.type;b=b.via)a.push(b.type);return a.reverse()}for(let a=0;a<e.next.length;a++){let{type:f,next:g}=e.next[a];f.isLeaf||f.hasRequiredAttrs()||f.name in b||d.type&&!g.validEnd||(c.push({match:f.contentMatch,type:f,via:d}),b[f.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(a){if(a>=this.next.length)throw RangeError(`There's no ${a}th edge in this content match`);return this.next[a]}toString(){let a=[];return!function b(c){a.push(c);for(let d=0;d<c.next.length;d++)-1==a.indexOf(c.next[d].next)&&b(c.next[d].next)}(this),a.map((b,c)=>{let d=c+(b.validEnd?"*":" ")+" ";for(let c=0;c<b.next.length;c++)d+=(c?", ":"")+b.next[c].type.name+"->"+a.indexOf(b.next[c].next);return d}).join("\n")}}Z.empty=new Z(!0);class ${constructor(a,b){this.string=a,this.nodeTypes=b,this.inline=null,this.pos=0,this.tokens=a.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(a){return this.next==a&&(this.pos++||!0)}err(a){throw SyntaxError(a+" (in content expression '"+this.string+"')")}}function _(a){/\D/.test(a.next)&&a.err("Expected number, got '"+a.next+"'");let b=Number(a.next);return a.pos++,b}function aa(a,b){return b-a}function ab(a,b){let c=[];return function b(d){let e=a[d];if(1==e.length&&!e[0].term)return b(e[0].to);c.push(d);for(let a=0;a<e.length;a++){let{term:d,to:f}=e[a];d||-1!=c.indexOf(f)||b(f)}}(b),c.sort(aa)}function ac(a){let b=Object.create(null);for(let c in a){let d=a[c];if(!d.hasDefault)return null;b[c]=d.default}return b}function ad(a,b){let c=Object.create(null);for(let d in a){let e=b&&b[d];if(void 0===e){let b=a[d];if(b.hasDefault)e=b.default;else throw RangeError("No value supplied for attribute "+d)}c[d]=e}return c}function ae(a,b,c,d){for(let d in b)if(!(d in a))throw RangeError(`Unsupported attribute ${d} for ${c} of type ${d}`);for(let c in a){let d=a[c];d.validate&&d.validate(b[c])}}function af(a,b){let c=Object.create(null);if(b)for(let d in b)c[d]=new ah(a,d,b[d]);return c}class ag{constructor(a,b,c){this.name=a,this.schema=b,this.spec=c,this.markSet=null,this.groups=c.group?c.group.split(" "):[],this.attrs=af(a,c.attrs),this.defaultAttrs=ac(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(c.inline||"text"==a),this.isText="text"==a}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Z.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(a){return this.groups.indexOf(a)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let a in this.attrs)if(this.attrs[a].isRequired)return!0;return!1}compatibleContent(a){return this==a||this.contentMatch.compatible(a.contentMatch)}computeAttrs(a){return!a&&this.defaultAttrs?this.defaultAttrs:ad(this.attrs,a)}create(a=null,b,c){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new W(this,this.computeAttrs(a),D.from(b),H.setFrom(c))}createChecked(a=null,b,c){return b=D.from(b),this.checkContent(b),new W(this,this.computeAttrs(a),b,H.setFrom(c))}createAndFill(a=null,b,c){if(a=this.computeAttrs(a),(b=D.from(b)).size){let a=this.contentMatch.fillBefore(b);if(!a)return null;b=a.append(b)}let d=this.contentMatch.matchFragment(b),e=d&&d.fillBefore(D.empty,!0);return e?new W(this,a,b.append(e),H.setFrom(c)):null}validContent(a){let b=this.contentMatch.matchFragment(a);if(!b||!b.validEnd)return!1;for(let b=0;b<a.childCount;b++)if(!this.allowsMarks(a.child(b).marks))return!1;return!0}checkContent(a){if(!this.validContent(a))throw RangeError(`Invalid content for node ${this.name}: ${a.toString().slice(0,50)}`)}checkAttrs(a){ae(this.attrs,a,"node",this.name)}allowsMarkType(a){return null==this.markSet||this.markSet.indexOf(a)>-1}allowsMarks(a){if(null==this.markSet)return!0;for(let b=0;b<a.length;b++)if(!this.allowsMarkType(a[b].type))return!1;return!0}allowedMarks(a){let b;if(null==this.markSet)return a;for(let c=0;c<a.length;c++)this.allowsMarkType(a[c].type)?b&&b.push(a[c]):b||(b=a.slice(0,c));return b?b.length?b:H.none:a}static compile(a,b){let c=Object.create(null);a.forEach((a,d)=>c[a]=new ag(a,b,d));let d=b.spec.topNode||"doc";if(!c[d])throw RangeError("Schema is missing its top node type ('"+d+"')");if(!c.text)throw RangeError("Every schema needs a 'text' type");for(let a in c.text.attrs)throw RangeError("The text node type should not have attributes");return c}}class ah{constructor(a,b,c){this.hasDefault=Object.prototype.hasOwnProperty.call(c,"default"),this.default=c.default,this.validate="string"==typeof c.validate?function(a,b,c){let d=c.split("|");return c=>{let e=null===c?"null":typeof c;if(0>d.indexOf(e))throw RangeError(`Expected value of type ${d} for attribute ${b} on type ${a}, got ${e}`)}}(a,b,c.validate):c.validate}get isRequired(){return!this.hasDefault}}class ai{constructor(a,b,c,d){this.name=a,this.rank=b,this.schema=c,this.spec=d,this.attrs=af(a,d.attrs),this.excluded=null;let e=ac(this.attrs);this.instance=e?new H(this,e):null}create(a=null){return!a&&this.instance?this.instance:new H(this,ad(this.attrs,a))}static compile(a,b){let c=Object.create(null),d=0;return a.forEach((a,e)=>c[a]=new ai(a,d++,b,e)),c}removeFromSet(a){for(var b=0;b<a.length;b++)a[b].type==this&&(a=a.slice(0,b).concat(a.slice(b+1)),b--);return a}isInSet(a){for(let b=0;b<a.length;b++)if(a[b].type==this)return a[b]}checkAttrs(a){ae(this.attrs,a,"mark",this.name)}excludes(a){return this.excluded.indexOf(a)>-1}}class aj{constructor(a){this.linebreakReplacement=null,this.cached=Object.create(null);let b=this.spec={};for(let c in a)b[c]=a[c];b.nodes=C.from(a.nodes),b.marks=C.from(a.marks||{}),this.nodes=ag.compile(this.spec.nodes,this),this.marks=ai.compile(this.spec.marks,this);let c=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw RangeError(a+" can not be both a node and a mark");let b=this.nodes[a],d=b.spec.content||"",e=b.spec.marks;if(b.contentMatch=c[d]||(c[d]=Z.parse(d,this.nodes)),b.inlineContent=b.contentMatch.inlineContent,b.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!b.isInline||!b.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=b}b.markSet="_"==e?null:e?ak(this,e.split(" ")):""!=e&&b.inlineContent?null:[]}for(let a in this.marks){let b=this.marks[a],c=b.spec.excludes;b.excluded=null==c?[b]:""==c?[]:ak(this,c.split(" "))}this.nodeFromJSON=a=>W.fromJSON(this,a),this.markFromJSON=a=>H.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(a,b=null,c,d){if("string"==typeof a)a=this.nodeType(a);else if(a instanceof ag){if(a.schema!=this)throw RangeError("Node type from different schema used ("+a.name+")")}else throw RangeError("Invalid node type: "+a);return a.createChecked(b,c,d)}text(a,b){let c=this.nodes.text;return new X(c,c.defaultAttrs,a,H.setFrom(b))}mark(a,b){return"string"==typeof a&&(a=this.marks[a]),a.create(b)}nodeType(a){let b=this.nodes[a];if(!b)throw RangeError("Unknown node type: "+a);return b}}function ak(a,b){let c=[];for(let d=0;d<b.length;d++){let e=b[d],f=a.marks[e],g=f;if(f)c.push(f);else for(let b in a.marks){let d=a.marks[b];("_"==e||d.spec.group&&d.spec.group.split(" ").indexOf(e)>-1)&&c.push(g=d)}if(!g)throw SyntaxError("Unknown mark type: '"+b[d]+"'")}return c}class al{constructor(a,b){this.schema=a,this.rules=b,this.tags=[],this.styles=[];let c=this.matchedStyles=[];b.forEach(a=>{if(null!=a.tag)this.tags.push(a);else if(null!=a.style){let b=/[^=]*/.exec(a.style)[0];0>c.indexOf(b)&&c.push(b),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(b=>{if(!/^(ul|ol)\b/.test(b.tag)||!b.node)return!1;let c=a.nodes[b.node];return c.contentMatch.matchType(c)})}parse(a,b={}){let c=new ar(this,b,!1);return c.addAll(a,H.none,b.from,b.to),c.finish()}parseSlice(a,b={}){let c=new ar(this,b,!0);return c.addAll(a,H.none,b.from,b.to),J.maxOpen(c.finish())}matchTag(a,b,c){for(let f=c?this.tags.indexOf(c)+1:0;f<this.tags.length;f++){var d,e;let c=this.tags[f];if(d=a,e=c.tag,(d.matches||d.msMatchesSelector||d.webkitMatchesSelector||d.mozMatchesSelector).call(d,e)&&(void 0===c.namespace||a.namespaceURI==c.namespace)&&(!c.context||b.matchesContext(c.context))){if(c.getAttrs){let b=c.getAttrs(a);if(!1===b)continue;c.attrs=b||void 0}return c}}}matchStyle(a,b,c,d){for(let e=d?this.styles.indexOf(d)+1:0;e<this.styles.length;e++){let d=this.styles[e],f=d.style;if(0==f.indexOf(a)&&(!d.context||c.matchesContext(d.context))&&(!(f.length>a.length)||61==f.charCodeAt(a.length)&&f.slice(a.length+1)==b)){if(d.getAttrs){let a=d.getAttrs(b);if(!1===a)continue;d.attrs=a||void 0}return d}}}static schemaRules(a){let b=[];function c(a){let c=null==a.priority?50:a.priority,d=0;for(;d<b.length;d++){let a=b[d];if((null==a.priority?50:a.priority)<c)break}b.splice(d,0,a)}for(let b in a.marks){let d=a.marks[b].spec.parseDOM;d&&d.forEach(a=>{c(a=as(a)),a.mark||a.ignore||a.clearMark||(a.mark=b)})}for(let b in a.nodes){let d=a.nodes[b].spec.parseDOM;d&&d.forEach(a=>{c(a=as(a)),a.node||a.ignore||a.mark||(a.node=b)})}return b}static fromSchema(a){return a.cached.domParser||(a.cached.domParser=new al(a,al.schemaRules(a)))}}let am={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},an={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ao={ol:!0,ul:!0};function ap(a,b,c){return null!=b?!!b|2*("full"===b):a&&"pre"==a.whitespace?3:-5&c}class aq{constructor(a,b,c,d,e,f){this.type=a,this.attrs=b,this.marks=c,this.solid=d,this.options=f,this.content=[],this.activeMarks=H.none,this.match=e||(4&f?null:a.contentMatch)}findWrapping(a){if(!this.match){if(!this.type)return[];let b=this.type.contentMatch.fillBefore(D.from(a));if(b)this.match=this.type.contentMatch.matchFragment(b);else{let b=this.type.contentMatch,c;return(c=b.findWrapping(a.type))?(this.match=b,c):null}}return this.match.findWrapping(a.type)}finish(a){if(!(1&this.options)){let a=this.content[this.content.length-1],b;a&&a.isText&&(b=/[ \t\r\n\u000c]+$/.exec(a.text))&&(a.text.length==b[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-b[0].length)))}let b=D.from(this.content);return!a&&this.match&&(b=b.append(this.match.fillBefore(D.empty,!0))),this.type?this.type.create(this.attrs,b,this.marks):b}inlineContext(a){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:a.parentNode&&!am.hasOwnProperty(a.parentNode.nodeName.toLowerCase())}}class ar{constructor(a,b,c){this.parser=a,this.options=b,this.isOpen=c,this.open=0,this.localPreserveWS=!1;let d=b.topNode,e,f=ap(null,b.preserveWhitespace,0)|4*!!c;e=d?new aq(d.type,d.attrs,H.none,!0,b.topMatch||d.type.contentMatch,f):c?new aq(null,null,H.none,!0,null,f):new aq(a.schema.topNodeType,null,H.none,!0,null,f),this.nodes=[e],this.find=b.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(a,b){3==a.nodeType?this.addTextNode(a,b):1==a.nodeType&&this.addElement(a,b)}addTextNode(a,b){let c=a.nodeValue,d=this.top,e=2&d.options?"full":this.localPreserveWS||(1&d.options)>0,{schema:f}=this.parser;if("full"===e||d.inlineContext(a)||/[^ \t\r\n\u000c]/.test(c)){if(e)if("full"===e)c=c.replace(/\r\n?/g,"\n");else if(f.linebreakReplacement&&/[\r\n]/.test(c)&&this.top.findWrapping(f.linebreakReplacement.create())){let a=c.split(/\r?\n|\r/);for(let c=0;c<a.length;c++)c&&this.insertNode(f.linebreakReplacement.create(),b,!0),a[c]&&this.insertNode(f.text(a[c]),b,!/\S/.test(a[c]));c=""}else c=c.replace(/\r?\n|\r/g," ");else if(c=c.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(c)&&this.open==this.nodes.length-1){let b=d.content[d.content.length-1],e=a.previousSibling;(!b||e&&"BR"==e.nodeName||b.isText&&/[ \t\r\n\u000c]$/.test(b.text))&&(c=c.slice(1))}c&&this.insertNode(f.text(c),b,!/\S/.test(c)),this.findInText(a)}else this.findInside(a)}addElement(a,b,c){let d=this.localPreserveWS,e=this.top;("PRE"==a.tagName||/pre/.test(a.style&&a.style.whiteSpace))&&(this.localPreserveWS=!0);let f=a.nodeName.toLowerCase(),g;ao.hasOwnProperty(f)&&this.parser.normalizeLists&&function(a){for(let b=a.firstChild,c=null;b;b=b.nextSibling){let a=1==b.nodeType?b.nodeName.toLowerCase():null;a&&ao.hasOwnProperty(a)&&c?(c.appendChild(b),b=c):"li"==a?c=b:a&&(c=null)}}(a);let h=this.options.ruleFromNode&&this.options.ruleFromNode(a)||(g=this.parser.matchTag(a,this,c));a:if(h?h.ignore:an.hasOwnProperty(f))this.findInside(a),this.ignoreFallback(a,b);else if(!h||h.skip||h.closeParent){h&&h.closeParent?this.open=Math.max(0,this.open-1):h&&h.skip.nodeType&&(a=h.skip);let c,d=this.needsBlock;if(am.hasOwnProperty(f))e.content.length&&e.content[0].isInline&&this.open&&(this.open--,e=this.top),c=!0,e.type||(this.needsBlock=!0);else if(!a.firstChild){this.leafFallback(a,b);break a}let g=h&&h.skip?b:this.readStyles(a,b);g&&this.addAll(a,g),c&&this.sync(e),this.needsBlock=d}else{let c=this.readStyles(a,b);c&&this.addElementByRule(a,h,c,!1===h.consuming?g:void 0)}this.localPreserveWS=d}leafFallback(a,b){"BR"==a.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(a.ownerDocument.createTextNode("\n"),b)}ignoreFallback(a,b){"BR"!=a.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),b,!0)}readStyles(a,b){let c=a.style;if(c&&c.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let d=this.parser.matchedStyles[a],e=c.getPropertyValue(d);if(e)for(let a;;){let c=this.parser.matchStyle(d,e,this,a);if(!c)break;if(c.ignore)return null;if(b=c.clearMark?b.filter(a=>!c.clearMark(a)):b.concat(this.parser.schema.marks[c.mark].create(c.attrs)),!1===c.consuming)a=c;else break}}return b}addElementByRule(a,b,c,d){let e,f;if(b.node)if((f=this.parser.schema.nodes[b.node]).isLeaf)this.insertNode(f.create(b.attrs),c,"BR"==a.nodeName)||this.leafFallback(a,c);else{let a=this.enter(f,b.attrs||null,c,b.preserveWhitespace);a&&(e=!0,c=a)}else{let a=this.parser.schema.marks[b.mark];c=c.concat(a.create(b.attrs))}let g=this.top;if(f&&f.isLeaf)this.findInside(a);else if(d)this.addElement(a,c,d);else if(b.getContent)this.findInside(a),b.getContent(a,this.parser.schema).forEach(a=>this.insertNode(a,c,!1));else{let d=a;"string"==typeof b.contentElement?d=a.querySelector(b.contentElement):"function"==typeof b.contentElement?d=b.contentElement(a):b.contentElement&&(d=b.contentElement),this.findAround(a,d,!0),this.addAll(d,c),this.findAround(a,d,!1)}e&&this.sync(g)&&this.open--}addAll(a,b,c,d){let e=c||0;for(let f=c?a.childNodes[c]:a.firstChild,g=null==d?null:a.childNodes[d];f!=g;f=f.nextSibling,++e)this.findAtPoint(a,e),this.addDOM(f,b);this.findAtPoint(a,e)}findPlace(a,b,c){let d,e;for(let b=this.open,f=0;b>=0;b--){let g=this.nodes[b],h=g.findWrapping(a);if(h&&(!d||d.length>h.length+f)&&(d=h,e=g,!h.length))break;if(g.solid){if(c)break;f+=2}}if(!d)return null;this.sync(e);for(let a=0;a<d.length;a++)b=this.enterInner(d[a],null,b,!1);return b}insertNode(a,b,c){if(a.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(b=this.enterInner(a,null,b))}let d=this.findPlace(a,b,c);if(d){this.closeExtra();let b=this.top;b.match&&(b.match=b.match.matchType(a.type));let c=H.none;for(let e of d.concat(a.marks))(b.type?b.type.allowsMarkType(e.type):at(e.type,a.type))&&(c=e.addToSet(c));return b.content.push(a.mark(c)),!0}return!1}enter(a,b,c,d){let e=this.findPlace(a.create(b),c,!1);return e&&(e=this.enterInner(a,b,c,!0,d)),e}enterInner(a,b,c,d=!1,e){this.closeExtra();let f=this.top;f.match=f.match&&f.match.matchType(a);let g=ap(a,e,f.options);4&f.options&&0==f.content.length&&(g|=4);let h=H.none;return c=c.filter(b=>(f.type?!f.type.allowsMarkType(b.type):!at(b.type,a))||(h=b.addToSet(h),!1)),this.nodes.push(new aq(a,b,h,d,null,g)),this.open++,c}closeExtra(a=!1){let b=this.nodes.length-1;if(b>this.open){for(;b>this.open;b--)this.nodes[b-1].content.push(this.nodes[b].finish(a));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(a){for(let b=this.open;b>=0;b--)if(this.nodes[b]==a)return this.open=b,!0;else this.localPreserveWS&&(this.nodes[b].options|=1);return!1}get currentPos(){this.closeExtra();let a=0;for(let b=this.open;b>=0;b--){let c=this.nodes[b].content;for(let b=c.length-1;b>=0;b--)a+=c[b].nodeSize;b&&a++}return a}findAtPoint(a,b){if(this.find)for(let c=0;c<this.find.length;c++)this.find[c].node==a&&this.find[c].offset==b&&(this.find[c].pos=this.currentPos)}findInside(a){if(this.find)for(let b=0;b<this.find.length;b++)null==this.find[b].pos&&1==a.nodeType&&a.contains(this.find[b].node)&&(this.find[b].pos=this.currentPos)}findAround(a,b,c){if(a!=b&&this.find)for(let d=0;d<this.find.length;d++)null==this.find[d].pos&&1==a.nodeType&&a.contains(this.find[d].node)&&b.compareDocumentPosition(this.find[d].node)&(c?2:4)&&(this.find[d].pos=this.currentPos)}findInText(a){if(this.find)for(let b=0;b<this.find.length;b++)this.find[b].node==a&&(this.find[b].pos=this.currentPos-(a.nodeValue.length-this.find[b].offset))}matchesContext(a){if(a.indexOf("|")>-1)return a.split(/\s*\|\s*/).some(this.matchesContext,this);let b=a.split("/"),c=this.options.context,d=!this.isOpen&&(!c||c.parent.type==this.nodes[0].type),e=-(c?c.depth+1:0)+ +!d,f=(a,g)=>{for(;a>=0;a--){let h=b[a];if(""==h){if(a==b.length-1||0==a)continue;for(;g>=e;g--)if(f(a-1,g))return!0;return!1}{let a=g>0||0==g&&d?this.nodes[g].type:c&&g>=e?c.node(g-e).type:null;if(!a||a.name!=h&&!a.isInGroup(h))return!1;g--}}return!0};return f(b.length-1,this.open)}textblockFromContext(){let a=this.options.context;if(a)for(let b=a.depth;b>=0;b--){let c=a.node(b).contentMatchAt(a.indexAfter(b)).defaultType;if(c&&c.isTextblock&&c.defaultAttrs)return c}for(let a in this.parser.schema.nodes){let b=this.parser.schema.nodes[a];if(b.isTextblock&&b.defaultAttrs)return b}}}function as(a){let b={};for(let c in a)b[c]=a[c];return b}function at(a,b){let c=b.schema.nodes;for(let d in c){let e=c[d];if(!e.allowsMarkType(a))continue;let f=[],g=a=>{f.push(a);for(let c=0;c<a.edgeCount;c++){let{type:d,next:e}=a.edge(c);if(d==b||0>f.indexOf(e)&&g(e))return!0}};if(g(e.contentMatch))return!0}}class au{constructor(a,b){this.nodes=a,this.marks=b}serializeFragment(a,b={},c){c||(c=aw(b).createDocumentFragment());let d=c,e=[];return a.forEach(a=>{if(e.length||a.marks.length){let c=0,f=0;for(;c<e.length&&f<a.marks.length;){let b=a.marks[f];if(!this.marks[b.type.name]){f++;continue}if(!b.eq(e[c][0])||!1===b.type.spec.spanning)break;c++,f++}for(;c<e.length;)d=e.pop()[1];for(;f<a.marks.length;){let c=a.marks[f++],g=this.serializeMark(c,a.isInline,b);g&&(e.push([c,d]),d.appendChild(g.dom),d=g.contentDOM||g.dom)}}d.appendChild(this.serializeNodeInner(a,b))}),c}serializeNodeInner(a,b){let{dom:c,contentDOM:d}=ay(aw(b),this.nodes[a.type.name](a),null,a.attrs);if(d){if(a.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(a.content,b,d)}return c}serializeNode(a,b={}){let c=this.serializeNodeInner(a,b);for(let d=a.marks.length-1;d>=0;d--){let e=this.serializeMark(a.marks[d],a.isInline,b);e&&((e.contentDOM||e.dom).appendChild(c),c=e.dom)}return c}serializeMark(a,b,c={}){let d=this.marks[a.type.name];return d&&ay(aw(c),d(a,b),null,a.attrs)}static renderSpec(a,b,c=null,d){return ay(a,b,c,d)}static fromSchema(a){return a.cached.domSerializer||(a.cached.domSerializer=new au(this.nodesFromSchema(a),this.marksFromSchema(a)))}static nodesFromSchema(a){let b=av(a.nodes);return b.text||(b.text=a=>a.text),b}static marksFromSchema(a){return av(a.marks)}}function av(a){let b={};for(let c in a){let d=a[c].spec.toDOM;d&&(b[c]=d)}return b}function aw(a){return a.document||window.document}let ax=new WeakMap;function ay(a,b,c,d){let e,f,g;if("string"==typeof b)return{dom:a.createTextNode(b)};if(null!=b.nodeType)return{dom:b};if(b.dom&&null!=b.dom.nodeType)return b;let h=b[0],i;if("string"!=typeof h)throw RangeError("Invalid array passed to renderSpec");if(d&&(void 0===(f=ax.get(d))&&ax.set(d,(g=null,!function a(b){if(b&&"object"==typeof b)if(Array.isArray(b))if("string"==typeof b[0])g||(g=[]),g.push(b);else for(let c=0;c<b.length;c++)a(b[c]);else for(let c in b)a(b[c])}(d),f=g)),i=f)&&i.indexOf(b)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let j=h.indexOf(" ");j>0&&(c=h.slice(0,j),h=h.slice(j+1));let k=c?a.createElementNS(c,h):a.createElement(h),l=b[1],m=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){for(let a in m=2,l)if(null!=l[a]){let b=a.indexOf(" ");b>0?k.setAttributeNS(a.slice(0,b),a.slice(b+1),l[a]):"style"==a&&k.style?k.style.cssText=l[a]:k.setAttribute(a,l[a])}}for(let f=m;f<b.length;f++){let g=b[f];if(0===g){if(f<b.length-1||f>m)throw RangeError("Content hole must be the only child of its parent node");return{dom:k,contentDOM:k}}{let{dom:b,contentDOM:f}=ay(a,g,c,d);if(k.appendChild(b),f){if(e)throw RangeError("Multiple content holes");e=f}}}return{dom:k,contentDOM:e}}class az{constructor(a,b,c){this.pos=a,this.delInfo=b,this.recover=c}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class aA{constructor(a,b=!1){if(this.ranges=a,this.inverted=b,!a.length&&aA.empty)return aA.empty}recover(a){let b=0,c=65535&a;if(!this.inverted)for(let a=0;a<c;a++)b+=this.ranges[3*a+2]-this.ranges[3*a+1];return this.ranges[3*c]+b+(a-(65535&a))/65536}mapResult(a,b=1){return this._map(a,b,!1)}map(a,b=1){return this._map(a,b,!0)}_map(a,b,c){let d=0,e=this.inverted?2:1,f=this.inverted?1:2;for(let g=0;g<this.ranges.length;g+=3){let h=this.ranges[g]-(this.inverted?d:0);if(h>a)break;let i=this.ranges[g+e],j=this.ranges[g+f],k=h+i;if(a<=k){let e=i?a==h?-1:a==k?1:b:b,f=h+d+(e<0?0:j);if(c)return f;let l=a==(b<0?h:k)?null:g/3+(a-h)*65536,m=a==h?2:a==k?1:4;return(b<0?a!=h:a!=k)&&(m|=8),new az(f,m,l)}d+=j-i}return c?a+d:new az(a+d,0,null)}touches(a,b){let c=0,d=65535&b,e=this.inverted?2:1,f=this.inverted?1:2;for(let b=0;b<this.ranges.length;b+=3){let g=this.ranges[b]-(this.inverted?c:0);if(g>a)break;let h=this.ranges[b+e];if(a<=g+h&&b==3*d)return!0;c+=this.ranges[b+f]-h}return!1}forEach(a){let b=this.inverted?2:1,c=this.inverted?1:2;for(let d=0,e=0;d<this.ranges.length;d+=3){let f=this.ranges[d],g=f-(this.inverted?e:0),h=f+(this.inverted?0:e),i=this.ranges[d+b],j=this.ranges[d+c];a(g,g+i,h,h+j),e+=j-i}}invert(){return new aA(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(a){return 0==a?aA.empty:new aA(a<0?[0,-a,0]:[0,0,a])}}aA.empty=new aA([]);class aB{constructor(a,b,c=0,d=a?a.length:0){this.mirror=b,this.from=c,this.to=d,this._maps=a||[],this.ownData=!(a||b)}get maps(){return this._maps}slice(a=0,b=this.maps.length){return new aB(this._maps,this.mirror,a,b)}appendMap(a,b){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(a),null!=b&&this.setMirror(this._maps.length-1,b)}appendMapping(a){for(let b=0,c=this._maps.length;b<a._maps.length;b++){let d=a.getMirror(b);this.appendMap(a._maps[b],null!=d&&d<b?c+d:void 0)}}getMirror(a){if(this.mirror){for(let b=0;b<this.mirror.length;b++)if(this.mirror[b]==a)return this.mirror[b+(b%2?-1:1)]}}setMirror(a,b){this.mirror||(this.mirror=[]),this.mirror.push(a,b)}appendMappingInverted(a){for(let b=a.maps.length-1,c=this._maps.length+a._maps.length;b>=0;b--){let d=a.getMirror(b);this.appendMap(a._maps[b].invert(),null!=d&&d>b?c-d-1:void 0)}}invert(){let a=new aB;return a.appendMappingInverted(this),a}map(a,b=1){if(this.mirror)return this._map(a,b,!0);for(let c=this.from;c<this.to;c++)a=this._maps[c].map(a,b);return a}mapResult(a,b=1){return this._map(a,b,!1)}_map(a,b,c){let d=0;for(let c=this.from;c<this.to;c++){let e=this._maps[c].mapResult(a,b);if(null!=e.recover){let b=this.getMirror(c);if(null!=b&&b>c&&b<this.to){c=b,a=this._maps[b].recover(e.recover);continue}}d|=e.delInfo,a=e.pos}return c?a:new az(a,d,null)}}let aC=Object.create(null);class aD{getMap(){return aA.empty}merge(a){return null}static fromJSON(a,b){if(!b||!b.stepType)throw RangeError("Invalid input for Step.fromJSON");let c=aC[b.stepType];if(!c)throw RangeError(`No step type ${b.stepType} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in aC)throw RangeError("Duplicate use of step JSON ID "+a);return aC[a]=b,b.prototype.jsonID=a,b}}class aE{constructor(a,b){this.doc=a,this.failed=b}static ok(a){return new aE(a,null)}static fail(a){return new aE(null,a)}static fromReplace(a,b,c,d){try{return aE.ok(a.replace(b,c,d))}catch(a){if(a instanceof I)return aE.fail(a.message);throw a}}}function aF(a,b,c){let d=[];for(let e=0;e<a.childCount;e++){let f=a.child(e);f.content.size&&(f=f.copy(aF(f.content,b,f))),f.isInline&&(f=b(f,c,e)),d.push(f)}return D.fromArray(d)}class aG extends aD{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=a.resolve(this.from),d=c.node(c.sharedDepth(this.to)),e=new J(aF(b.content,(a,b)=>a.isAtom&&b.type.allowsMarkType(this.mark.type)?a.mark(this.mark.addToSet(a.marks)):a,d),b.openStart,b.openEnd);return aE.fromReplace(a,this.from,this.to,e)}invert(){return new aH(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new aG(b.pos,c.pos,this.mark)}merge(a){return a instanceof aG&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new aG(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new aG(b.from,b.to,a.markFromJSON(b.mark))}}aD.jsonID("addMark",aG);class aH extends aD{constructor(a,b,c){super(),this.from=a,this.to=b,this.mark=c}apply(a){let b=a.slice(this.from,this.to),c=new J(aF(b.content,a=>a.mark(this.mark.removeFromSet(a.marks)),a),b.openStart,b.openEnd);return aE.fromReplace(a,this.from,this.to,c)}invert(){return new aG(this.from,this.to,this.mark)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deleted&&c.deleted||b.pos>=c.pos?null:new aH(b.pos,c.pos,this.mark)}merge(a){return a instanceof aH&&a.mark.eq(this.mark)&&this.from<=a.to&&this.to>=a.from?new aH(Math.min(this.from,a.from),Math.max(this.to,a.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new aH(b.from,b.to,a.markFromJSON(b.mark))}}aD.jsonID("removeMark",aH);class aI extends aD{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return aE.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.addToSet(b.marks));return aE.fromReplace(a,this.pos,this.pos+1,new J(D.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);if(b){let a=this.mark.addToSet(b.marks);if(a.length==b.marks.length){for(let c=0;c<b.marks.length;c++)if(!b.marks[c].isInSet(a))return new aI(this.pos,b.marks[c]);return new aI(this.pos,this.mark)}}return new aJ(this.pos,this.mark)}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new aI(b.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new aI(b.pos,a.markFromJSON(b.mark))}}aD.jsonID("addNodeMark",aI);class aJ extends aD{constructor(a,b){super(),this.pos=a,this.mark=b}apply(a){let b=a.nodeAt(this.pos);if(!b)return aE.fail("No node at mark step's position");let c=b.type.create(b.attrs,null,this.mark.removeFromSet(b.marks));return aE.fromReplace(a,this.pos,this.pos+1,new J(D.from(c),0,+!b.isLeaf))}invert(a){let b=a.nodeAt(this.pos);return b&&this.mark.isInSet(b.marks)?new aI(this.pos,this.mark):this}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new aJ(b.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(a,b){if("number"!=typeof b.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new aJ(b.pos,a.markFromJSON(b.mark))}}aD.jsonID("removeNodeMark",aJ);class aK extends aD{constructor(a,b,c,d=!1){super(),this.from=a,this.to=b,this.slice=c,this.structure=d}apply(a){return this.structure&&aM(a,this.from,this.to)?aE.fail("Structure replace would overwrite content"):aE.fromReplace(a,this.from,this.to,this.slice)}getMap(){return new aA([this.from,this.to-this.from,this.slice.size])}invert(a){return new aK(this.from,this.from+this.slice.size,a.slice(this.from,this.to))}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1);return b.deletedAcross&&c.deletedAcross?null:new aK(b.pos,Math.max(b.pos,c.pos),this.slice,this.structure)}merge(a){if(!(a instanceof aK)||a.structure||this.structure)return null;if(this.from+this.slice.size!=a.from||this.slice.openEnd||a.slice.openStart)if(a.to!=this.from||this.slice.openStart||a.slice.openEnd)return null;else{let b=this.slice.size+a.slice.size==0?J.empty:new J(a.slice.content.append(this.slice.content),a.slice.openStart,this.slice.openEnd);return new aK(a.from,this.to,b,this.structure)}{let b=this.slice.size+a.slice.size==0?J.empty:new J(this.slice.content.append(a.slice.content),this.slice.openStart,a.slice.openEnd);return new aK(this.from,this.to+(a.to-a.from),b,this.structure)}}toJSON(){let a={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new aK(b.from,b.to,J.fromJSON(a,b.slice),!!b.structure)}}aD.jsonID("replace",aK);class aL extends aD{constructor(a,b,c,d,e,f,g=!1){super(),this.from=a,this.to=b,this.gapFrom=c,this.gapTo=d,this.slice=e,this.insert=f,this.structure=g}apply(a){if(this.structure&&(aM(a,this.from,this.gapFrom)||aM(a,this.gapTo,this.to)))return aE.fail("Structure gap-replace would overwrite content");let b=a.slice(this.gapFrom,this.gapTo);if(b.openStart||b.openEnd)return aE.fail("Gap is not a flat range");let c=this.slice.insertAt(this.insert,b.content);return c?aE.fromReplace(a,this.from,this.to,c):aE.fail("Content does not fit in gap")}getMap(){return new aA([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(a){let b=this.gapTo-this.gapFrom;return new aL(this.from,this.from+this.slice.size+b,this.from+this.insert,this.from+this.insert+b,a.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(a){let b=a.mapResult(this.from,1),c=a.mapResult(this.to,-1),d=this.from==this.gapFrom?b.pos:a.map(this.gapFrom,-1),e=this.to==this.gapTo?c.pos:a.map(this.gapTo,1);return b.deletedAcross&&c.deletedAcross||d<b.pos||e>c.pos?null:new aL(b.pos,c.pos,d,e,this.slice,this.insert,this.structure)}toJSON(){let a={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(a.slice=this.slice.toJSON()),this.structure&&(a.structure=!0),a}static fromJSON(a,b){if("number"!=typeof b.from||"number"!=typeof b.to||"number"!=typeof b.gapFrom||"number"!=typeof b.gapTo||"number"!=typeof b.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new aL(b.from,b.to,b.gapFrom,b.gapTo,J.fromJSON(a,b.slice),b.insert,!!b.structure)}}function aM(a,b,c){let d=a.resolve(b),e=c-b,f=d.depth;for(;e>0&&f>0&&d.indexAfter(f)==d.node(f).childCount;)f--,e--;if(e>0){let a=d.node(f).maybeChild(d.indexAfter(f));for(;e>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,e--}}return!1}function aN(a,b,c,d=c.contentMatch,e=!0){let f=a.doc.nodeAt(b),g=[],h=b+1;for(let b=0;b<f.childCount;b++){let i=f.child(b),j=h+i.nodeSize,k=d.matchType(i.type);if(k){d=k;for(let b=0;b<i.marks.length;b++)c.allowsMarkType(i.marks[b].type)||a.step(new aH(h,j,i.marks[b]));if(e&&i.isText&&"pre"!=c.whitespace){let a,b=/\r?\n|\r/g,d;for(;a=b.exec(i.text);)d||(d=new J(D.from(c.schema.text(" ",c.allowedMarks(i.marks))),0,0)),g.push(new aK(h+a.index,h+a.index+a[0].length,d))}}else g.push(new aK(h,j,J.empty));h=j}if(!d.validEnd){let b=d.fillBefore(D.empty,!0);a.replace(h,h,new J(b,0,0))}for(let b=g.length-1;b>=0;b--)a.step(g[b])}function aO(a){let b=a.parent.content.cutByIndex(a.startIndex,a.endIndex);for(let c=a.depth,d=0,e=0;;--c){let f=a.$from.node(c),g=a.$from.index(c)+d,h=a.$to.indexAfter(c)-e;if(c<a.depth&&f.canReplace(g,h,b))return c;if(0==c||f.type.spec.isolating||!((0==g||f.canReplace(g,f.childCount))&&(h==f.childCount||f.canReplace(0,h))))break;g&&(d=1),h<f.childCount&&(e=1)}return null}function aP(a,b,c=null,d=a){let e=function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.contentMatchAt(d).findWrapping(b);if(!f)return null;let g=f.length?f[0]:b;return c.canReplaceWith(d,e,g)?f:null}(a,b),f=e&&function(a,b){let{parent:c,startIndex:d,endIndex:e}=a,f=c.child(d),g=b.contentMatch.findWrapping(f.type);if(!g)return null;let h=(g.length?g[g.length-1]:b).contentMatch;for(let a=d;h&&a<e;a++)h=h.matchType(c.child(a).type);return h&&h.validEnd?g:null}(d,b);return f?e.map(aQ).concat({type:b,attrs:c}).concat(f.map(aQ)):null}function aQ(a){return{type:a,attrs:null}}function aR(a,b,c,d){b.forEach((e,f)=>{if(e.isText){let g,h=/\r?\n|\r/g;for(;g=h.exec(e.text);){let e=a.mapping.slice(d).map(c+1+f+g.index);a.replaceWith(e,e+1,b.type.schema.linebreakReplacement.create())}}})}function aS(a,b,c,d){b.forEach((e,f)=>{if(e.type==e.type.schema.linebreakReplacement){let e=a.mapping.slice(d).map(c+1+f);a.replaceWith(e,e+1,b.type.schema.text("\n"))}})}function aT(a,b,c=1,d){let e=a.resolve(b),f=e.depth-c,g=d&&d[d.length-1]||e.parent;if(f<0||e.parent.type.spec.isolating||!e.parent.canReplace(e.index(),e.parent.childCount)||!g.type.validContent(e.parent.content.cutByIndex(e.index(),e.parent.childCount)))return!1;for(let a=e.depth-1,b=c-2;a>f;a--,b--){let c=e.node(a),f=e.index(a);if(c.type.spec.isolating)return!1;let g=c.content.cutByIndex(f,c.childCount),h=d&&d[b+1];h&&(g=g.replaceChild(0,h.type.create(h.attrs)));let i=d&&d[b]||c;if(!c.canReplace(f+1,c.childCount)||!i.type.validContent(g))return!1}let h=e.indexAfter(f),i=d&&d[0];return e.node(f).canReplaceWith(h,h,i?i.type:e.node(f+1).type)}function aU(a,b){let c=a.resolve(b),d=c.index();return aV(c.nodeBefore,c.nodeAfter)&&c.parent.canReplace(d,d+1)}function aV(a,b){return!!(a&&b&&!a.isLeaf&&function(a,b){b.content.size||a.type.compatibleContent(b.type);let c=a.contentMatchAt(a.childCount),{linebreakReplacement:d}=a.type.schema;for(let e=0;e<b.childCount;e++){let f=b.child(e),g=f.type==d?a.type.schema.nodes.text:f.type;if(!(c=c.matchType(g))||!a.type.allowsMarks(f.marks))return!1}return c.validEnd}(a,b))}function aW(a,b,c=-1){let d=a.resolve(b);for(let a=d.depth;;a--){let e,f,g=d.index(a);if(a==d.depth?(e=d.nodeBefore,f=d.nodeAfter):c>0?(e=d.node(a+1),g++,f=d.node(a).maybeChild(g)):(e=d.node(a).maybeChild(g-1),f=d.node(a+1)),e&&!e.isTextblock&&aV(e,f)&&d.node(a).canReplace(g,g+1))return b;if(0==a)break;b=c<0?d.before(a):d.after(a)}}function aX(a,b,c){let d=a.resolve(b);if(!c.content.size)return b;let e=c.content;for(let a=0;a<c.openStart;a++)e=e.firstChild.content;for(let a=1;a<=(0==c.openStart&&c.size?2:1);a++)for(let b=d.depth;b>=0;b--){let c=b==d.depth?0:d.pos<=(d.start(b+1)+d.end(b+1))/2?-1:1,f=d.index(b)+ +(c>0),g=d.node(b),h=!1;if(1==a)h=g.canReplace(f,f,e);else{let a=g.contentMatchAt(f).findWrapping(e.firstChild.type);h=a&&g.canReplaceWith(f,f,a[0])}if(h)return 0==c?d.pos:c<0?d.before(b+1):d.after(b+1)}return null}function aY(a,b,c=b,d=J.empty){if(b==c&&!d.size)return null;let e=a.resolve(b),f=a.resolve(c);return aZ(e,f,d)?new aK(b,c,d):new a$(e,f,d).fit()}function aZ(a,b,c){return!c.openStart&&!c.openEnd&&a.start()==b.start()&&a.parent.canReplace(a.index(),b.index(),c.content)}aD.jsonID("replaceAround",aL);class a${constructor(a,b,c){this.$from=a,this.$to=b,this.unplaced=c,this.frontier=[],this.placed=D.empty;for(let b=0;b<=a.depth;b++){let c=a.node(b);this.frontier.push({type:c.type,match:c.contentMatchAt(a.indexAfter(b))})}for(let b=a.depth;b>0;b--)this.placed=D.from(a.node(b).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let a=this.mustMoveInline(),b=this.placed.size-this.depth-this.$from.depth,c=this.$from,d=this.close(a<0?this.$to:c.doc.resolve(a));if(!d)return null;let e=this.placed,f=c.depth,g=d.depth;for(;f&&g&&1==e.childCount;)e=e.firstChild.content,f--,g--;let h=new J(e,f,g);return a>-1?new aL(c.pos,a,this.$to.pos,this.$to.end(),h,b):h.size||c.pos!=this.$to.pos?new aK(c.pos,d.pos,h):null}findFittable(){let a=this.unplaced.openStart;for(let b=this.unplaced.content,c=0,d=this.unplaced.openEnd;c<a;c++){let e=b.firstChild;if(b.childCount>1&&(d=0),e.type.spec.isolating&&d<=c){a=c;break}b=e.content}for(let b=1;b<=2;b++)for(let c=1==b?a:this.unplaced.openStart;c>=0;c--){let a=null,d=(c?(a=a1(this.unplaced.content,c-1).firstChild).content:this.unplaced.content).firstChild;for(let e=this.depth;e>=0;e--){let{type:f,match:g}=this.frontier[e],h,i=null;if(1==b&&(d?g.matchType(d.type)||(i=g.fillBefore(D.from(d),!1)):a&&f.compatibleContent(a.type)))return{sliceDepth:c,frontierDepth:e,parent:a,inject:i};if(2==b&&d&&(h=g.findWrapping(d.type)))return{sliceDepth:c,frontierDepth:e,parent:a,wrap:h};if(a&&g.matchType(a.type))break}}}openMore(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=a1(a,b);return!!d.childCount&&!d.firstChild.isLeaf&&(this.unplaced=new J(a,b+1,Math.max(c,d.size+b>=a.size-c?b+1:0)),!0)}dropNode(){let{content:a,openStart:b,openEnd:c}=this.unplaced,d=a1(a,b);if(d.childCount<=1&&b>0){let e=a.size-b<=b+d.size;this.unplaced=new J(a_(a,b-1,1),b-1,e?b-1:c)}else this.unplaced=new J(a_(a,b,1),b,c)}placeNodes({sliceDepth:a,frontierDepth:b,parent:c,inject:d,wrap:e}){for(;this.depth>b;)this.closeFrontierNode();if(e)for(let a=0;a<e.length;a++)this.openFrontierNode(e[a]);let f=this.unplaced,g=c?c.content:f.content,h=f.openStart-a,i=0,j=[],{match:k,type:l}=this.frontier[b];if(d){for(let a=0;a<d.childCount;a++)j.push(d.child(a));k=k.matchFragment(d)}let m=g.size+a-(f.content.size-f.openEnd);for(;i<g.childCount;){let a=g.child(i),b=k.matchType(a.type);if(!b)break;(++i>1||0==h||a.content.size)&&(k=b,j.push(function a(b,c,d){if(c<=0)return b;let e=b.content;return c>1&&(e=e.replaceChild(0,a(e.firstChild,c-1,1==e.childCount?d-1:0))),c>0&&(e=b.type.contentMatch.fillBefore(e).append(e),d<=0&&(e=e.append(b.type.contentMatch.matchFragment(e).fillBefore(D.empty,!0)))),b.copy(e)}(a.mark(l.allowedMarks(a.marks)),1==i?h:0,i==g.childCount?m:-1)))}let n=i==g.childCount;n||(m=-1),this.placed=a0(this.placed,b,D.from(j)),this.frontier[b].match=k,n&&m<0&&c&&c.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let a=0,b=g;a<m;a++){let a=b.lastChild;this.frontier.push({type:a.type,match:a.contentMatchAt(a.childCount)}),b=a.content}this.unplaced=n?0==a?J.empty:new J(a_(f.content,a-1,1),a-1,m<0?f.openEnd:a-1):new J(a_(f.content,a,i),f.openStart,f.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let a=this.frontier[this.depth],b;if(!a.type.isTextblock||!a2(this.$to,this.$to.depth,a.type,a.match,!1)||this.$to.depth==this.depth&&(b=this.findCloseLevel(this.$to))&&b.depth==this.depth)return -1;let{depth:c}=this.$to,d=this.$to.after(c);for(;c>1&&d==this.$to.end(--c);)++d;return d}findCloseLevel(a){b:for(let b=Math.min(this.depth,a.depth);b>=0;b--){let{match:c,type:d}=this.frontier[b],e=b<a.depth&&a.end(b+1)==a.pos+(a.depth-(b+1)),f=a2(a,b,d,c,e);if(f){for(let c=b-1;c>=0;c--){let{match:b,type:d}=this.frontier[c],e=a2(a,c,d,b,!0);if(!e||e.childCount)continue b}return{depth:b,fit:f,move:e?a.doc.resolve(a.after(b+1)):a}}}}close(a){let b=this.findCloseLevel(a);if(!b)return null;for(;this.depth>b.depth;)this.closeFrontierNode();b.fit.childCount&&(this.placed=a0(this.placed,b.depth,b.fit)),a=b.move;for(let c=b.depth+1;c<=a.depth;c++){let b=a.node(c),d=b.type.contentMatch.fillBefore(b.content,!0,a.index(c));this.openFrontierNode(b.type,b.attrs,d)}return a}openFrontierNode(a,b=null,c){let d=this.frontier[this.depth];d.match=d.match.matchType(a),this.placed=a0(this.placed,this.depth,D.from(a.create(b,c))),this.frontier.push({type:a,match:a.contentMatch})}closeFrontierNode(){let a=this.frontier.pop().match.fillBefore(D.empty,!0);a.childCount&&(this.placed=a0(this.placed,this.frontier.length,a))}}function a_(a,b,c){return 0==b?a.cutByIndex(c,a.childCount):a.replaceChild(0,a.firstChild.copy(a_(a.firstChild.content,b-1,c)))}function a0(a,b,c){return 0==b?a.append(c):a.replaceChild(a.childCount-1,a.lastChild.copy(a0(a.lastChild.content,b-1,c)))}function a1(a,b){for(let c=0;c<b;c++)a=a.firstChild.content;return a}function a2(a,b,c,d,e){let f=a.node(b),g=e?a.indexAfter(b):a.index(b);if(g==f.childCount&&!c.compatibleContent(f.type))return null;let h=d.fillBefore(f.content,!0,g);return h&&!function(a,b,c){for(let d=c;d<b.childCount;d++)if(!a.allowsMarks(b.child(d).marks))return!0;return!1}(c,f.content,g)?h:null}function a3(a,b){let c=[],d=Math.min(a.depth,b.depth);for(let e=d;e>=0;e--){let d=a.start(e);if(d<a.pos-(a.depth-e)||b.end(e)>b.pos+(b.depth-e)||a.node(e).type.spec.isolating||b.node(e).type.spec.isolating)break;(d==b.start(e)||e==a.depth&&e==b.depth&&a.parent.inlineContent&&b.parent.inlineContent&&e&&b.start(e-1)==d-1)&&c.push(e)}return c}class a4 extends aD{constructor(a,b,c){super(),this.pos=a,this.attr=b,this.value=c}apply(a){let b=a.nodeAt(this.pos);if(!b)return aE.fail("No node at attribute step's position");let c=Object.create(null);for(let a in b.attrs)c[a]=b.attrs[a];c[this.attr]=this.value;let d=b.type.create(c,null,b.marks);return aE.fromReplace(a,this.pos,this.pos+1,new J(D.from(d),0,+!b.isLeaf))}getMap(){return aA.empty}invert(a){return new a4(this.pos,this.attr,a.nodeAt(this.pos).attrs[this.attr])}map(a){let b=a.mapResult(this.pos,1);return b.deletedAfter?null:new a4(b.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(a,b){if("number"!=typeof b.pos||"string"!=typeof b.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new a4(b.pos,b.attr,b.value)}}aD.jsonID("attr",a4);class a5 extends aD{constructor(a,b){super(),this.attr=a,this.value=b}apply(a){let b=Object.create(null);for(let c in a.attrs)b[c]=a.attrs[c];b[this.attr]=this.value;let c=a.type.create(b,a.content,a.marks);return aE.ok(c)}getMap(){return aA.empty}invert(a){return new a5(this.attr,a.attrs[this.attr])}map(a){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(a,b){if("string"!=typeof b.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new a5(b.attr,b.value)}}aD.jsonID("docAttr",a5);let a6=class extends Error{};(a6=function a(b){let c=Error.call(this,b);return c.__proto__=a.prototype,c}).prototype=Object.create(Error.prototype),a6.prototype.constructor=a6,a6.prototype.name="TransformError";class a7{constructor(a){this.doc=a,this.steps=[],this.docs=[],this.mapping=new aB}get before(){return this.docs.length?this.docs[0]:this.doc}step(a){let b=this.maybeStep(a);if(b.failed)throw new a6(b.failed);return this}maybeStep(a){let b=a.apply(this.doc);return b.failed||this.addStep(a,b.doc),b}get docChanged(){return this.steps.length>0}changedRange(){let a=1e9,b=-1e9;for(let c=0;c<this.mapping.maps.length;c++){let d=this.mapping.maps[c];c&&(a=d.map(a,1),b=d.map(b,-1)),d.forEach((c,d,e,f)=>{a=Math.min(a,e),b=Math.max(b,f)})}return 1e9==a?null:{from:a,to:b}}addStep(a,b){this.docs.push(this.doc),this.steps.push(a),this.mapping.appendMap(a.getMap()),this.doc=b}replace(a,b=a,c=J.empty){let d=aY(this.doc,a,b,c);return d&&this.step(d),this}replaceWith(a,b,c){return this.replace(a,b,new J(D.from(c),0,0))}delete(a,b){return this.replace(a,b,J.empty)}insert(a,b){return this.replaceWith(a,a,b)}replaceRange(a,b,c){return!function(a,b,c,d){if(!d.size)return a.deleteRange(b,c);let e=a.doc.resolve(b),f=a.doc.resolve(c);if(aZ(e,f,d))return a.step(new aK(b,c,d));let g=a3(e,f);0==g[g.length-1]&&g.pop();let h=-(e.depth+1);g.unshift(h);for(let a=e.depth,b=e.pos-1;a>0;a--,b--){let c=e.node(a).type.spec;if(c.defining||c.definingAsContext||c.isolating)break;g.indexOf(a)>-1?h=a:e.before(a)==b&&g.splice(1,0,-a)}let i=g.indexOf(h),j=[],k=d.openStart;for(let a=d.content,b=0;;b++){let c=a.firstChild;if(j.push(c),b==d.openStart)break;a=c.content}for(let a=k-1;a>=0;a--){var l;let b=j[a],c=(l=b.type).spec.defining||l.spec.definingForContent;if(c&&!b.sameMarkup(e.node(Math.abs(h)-1)))k=a;else if(c||!b.type.isTextblock)break}for(let b=d.openStart;b>=0;b--){let h=(b+k+1)%(d.openStart+1),l=j[h];if(l)for(let b=0;b<g.length;b++){let j=g[(b+i)%g.length],k=!0;j<0&&(k=!1,j=-j);let m=e.node(j-1),n=e.index(j-1);if(m.canReplaceWith(n,n,l.type,l.marks))return a.replace(e.before(j),k?f.after(j):c,new J(function a(b,c,d,e,f){if(c<d){let f=b.firstChild;b=b.replaceChild(0,f.copy(a(f.content,c+1,d,e,f)))}if(c>e){let a=f.contentMatchAt(0),c=a.fillBefore(b).append(b);b=c.append(a.matchFragment(c).fillBefore(D.empty,!0))}return b}(d.content,0,d.openStart,h),h,d.openEnd))}}let m=a.steps.length;for(let h=g.length-1;h>=0&&(a.replace(b,c,d),!(a.steps.length>m));h--){let a=g[h];a<0||(b=e.before(a),c=f.after(a))}}(this,a,b,c),this}replaceRangeWith(a,b,c){var d=a,e=b;if(!c.isInline&&d==e&&this.doc.resolve(d).parent.content.size){let a=function(a,b,c){let d=a.resolve(b);if(d.parent.canReplaceWith(d.index(),d.index(),c))return b;if(0==d.parentOffset)for(let a=d.depth-1;a>=0;a--){let b=d.index(a);if(d.node(a).canReplaceWith(b,b,c))return d.before(a+1);if(b>0)return null}if(d.parentOffset==d.parent.content.size)for(let a=d.depth-1;a>=0;a--){let b=d.indexAfter(a);if(d.node(a).canReplaceWith(b,b,c))return d.after(a+1);if(b<d.node(a).childCount)break}return null}(this.doc,d,c.type);null!=a&&(d=e=a)}return this.replaceRange(d,e,new J(D.from(c),0,0)),this}deleteRange(a,b){return!function(a,b,c){let d=a.doc.resolve(b),e=a.doc.resolve(c),f=a3(d,e);for(let b=0;b<f.length;b++){let c=f[b],g=b==f.length-1;if(g&&0==c||d.node(c).type.contentMatch.validEnd)return a.delete(d.start(c),e.end(c));if(c>0&&(g||d.node(c-1).canReplace(d.index(c-1),e.indexAfter(c-1))))return a.delete(d.before(c),e.after(c))}for(let f=1;f<=d.depth&&f<=e.depth;f++)if(b-d.start(f)==d.depth-f&&c>d.end(f)&&e.end(f)-c!=e.depth-f&&d.start(f-1)==e.start(f-1)&&d.node(f-1).canReplace(d.index(f-1),e.index(f-1)))return a.delete(d.before(f),c);a.delete(b,c)}(this,a,b),this}lift(a,b){return!function(a,b,c){let{$from:d,$to:e,depth:f}=b,g=d.before(f+1),h=e.after(f+1),i=g,j=h,k=D.empty,l=0;for(let a=f,b=!1;a>c;a--)b||d.index(a)>0?(b=!0,k=D.from(d.node(a).copy(k)),l++):i--;let m=D.empty,n=0;for(let a=f,b=!1;a>c;a--)b||e.after(a+1)<e.end(a)?(b=!0,m=D.from(e.node(a).copy(m)),n++):j++;a.step(new aL(i,j,g,h,new J(k.append(m),l,n),k.size-l,!0))}(this,a,b),this}join(a,b=1){return!function(a,b,c){let d=null,{linebreakReplacement:e}=a.doc.type.schema,f=a.doc.resolve(b-c),g=f.node().type;if(e&&g.inlineContent){let a="pre"==g.whitespace,b=!!g.contentMatch.matchType(e);a&&!b?d=!1:!a&&b&&(d=!0)}let h=a.steps.length;if(!1===d){let d=a.doc.resolve(b+c);aS(a,d.node(),d.before(),h)}g.inlineContent&&aN(a,b+c-1,g,f.node().contentMatchAt(f.index()),null==d);let i=a.mapping.slice(h),j=i.map(b-c);if(a.step(new aK(j,i.map(b+c,-1),J.empty,!0)),!0===d){let b=a.doc.resolve(j);aR(a,b.node(),b.before(),a.steps.length)}}(this,a,b),this}wrap(a,b){return!function(a,b,c){let d=D.empty;for(let a=c.length-1;a>=0;a--){if(d.size){let b=c[a].type.contentMatch.matchFragment(d);if(!b||!b.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}d=D.from(c[a].type.create(c[a].attrs,d))}let e=b.start,f=b.end;a.step(new aL(e,f,e,f,new J(d,0,0),c.length,!0))}(this,a,b),this}setBlockType(a,b=a,c,d=null){var e=this;if(!c.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let f=e.steps.length;return e.doc.nodesBetween(a,b,(a,b)=>{var g,h,i;let j,k,l="function"==typeof d?d(a):d;if(a.isTextblock&&!a.hasMarkup(c,l)&&(g=e.doc,h=e.mapping.slice(f).map(b),i=c,k=(j=g.resolve(h)).index(),j.parent.canReplaceWith(k,k+1,i))){let d=null;if(c.schema.linebreakReplacement){let a="pre"==c.whitespace,b=!!c.contentMatch.matchType(c.schema.linebreakReplacement);a&&!b?d=!1:!a&&b&&(d=!0)}!1===d&&aS(e,a,b,f),aN(e,e.mapping.slice(f).map(b,1),c,void 0,null===d);let g=e.mapping.slice(f),h=g.map(b,1),i=g.map(b+a.nodeSize,1);return e.step(new aL(h,i,h+1,i-1,new J(D.from(c.create(l,null,a.marks)),0,0),1,!0)),!0===d&&aR(e,a,b,f),!1}}),this}setNodeMarkup(a,b,c=null,d){return!function(a,b,c,d,e){let f=a.doc.nodeAt(b);if(!f)throw RangeError("No node at given position");c||(c=f.type);let g=c.create(d,null,e||f.marks);if(f.isLeaf)return a.replaceWith(b,b+f.nodeSize,g);if(!c.validContent(f.content))throw RangeError("Invalid content for node type "+c.name);a.step(new aL(b,b+f.nodeSize,b+1,b+f.nodeSize-1,new J(D.from(g),0,0),1,!0))}(this,a,b,c,d),this}setNodeAttribute(a,b,c){return this.step(new a4(a,b,c)),this}setDocAttribute(a,b){return this.step(new a5(a,b)),this}addNodeMark(a,b){return this.step(new aI(a,b)),this}removeNodeMark(a,b){let c=this.doc.nodeAt(a);if(!c)throw RangeError("No node at position "+a);if(b instanceof H)b.isInSet(c.marks)&&this.step(new aJ(a,b));else{let d=c.marks,e,f=[];for(;e=b.isInSet(d);)f.push(new aJ(a,e)),d=e.removeFromSet(d);for(let a=f.length-1;a>=0;a--)this.step(f[a])}return this}split(a,b=1,c){return!function(a,b,c=1,d){let e=a.doc.resolve(b),f=D.empty,g=D.empty;for(let a=e.depth,b=e.depth-c,h=c-1;a>b;a--,h--){f=D.from(e.node(a).copy(f));let b=d&&d[h];g=D.from(b?b.type.create(b.attrs,g):e.node(a).copy(g))}a.step(new aK(b,b,new J(f.append(g),c,c),!0))}(this,a,b,c),this}addMark(a,b,c){var d;let e,f,g,h;return d=this,g=[],h=[],d.doc.nodesBetween(a,b,(d,i,j)=>{if(!d.isInline)return;let k=d.marks;if(!c.isInSet(k)&&j.type.allowsMarkType(c.type)){let j=Math.max(i,a),l=Math.min(i+d.nodeSize,b),m=c.addToSet(k);for(let a=0;a<k.length;a++)k[a].isInSet(m)||(e&&e.to==j&&e.mark.eq(k[a])?e.to=l:g.push(e=new aH(j,l,k[a])));f&&f.to==j?f.to=l:h.push(f=new aG(j,l,c))}}),g.forEach(a=>d.step(a)),h.forEach(a=>d.step(a)),this}removeMark(a,b,c){var d;let e,f;return d=this,e=[],f=0,d.doc.nodesBetween(a,b,(d,g)=>{if(!d.isInline)return;f++;let h=null;if(c instanceof ai){let a=d.marks,b;for(;b=c.isInSet(a);)(h||(h=[])).push(b),a=b.removeFromSet(a)}else c?c.isInSet(d.marks)&&(h=[c]):h=d.marks;if(h&&h.length){let c=Math.min(g+d.nodeSize,b);for(let b=0;b<h.length;b++){let d=h[b],i;for(let a=0;a<e.length;a++){let b=e[a];b.step==f-1&&d.eq(e[a].style)&&(i=b)}i?(i.to=c,i.step=f):e.push({style:d,from:Math.max(g,a),to:c,step:f})}}}),e.forEach(a=>d.step(new aH(a.from,a.to,a.style))),this}clearIncompatible(a,b,c){return aN(this,a,b,c),this}}let a8=Object.create(null);class a9{constructor(a,b,c){this.$anchor=a,this.$head=b,this.ranges=c||[new ba(a.min(b),a.max(b))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let a=this.ranges;for(let b=0;b<a.length;b++)if(a[b].$from.pos!=a[b].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(a,b=J.empty){let c=b.content.lastChild,d=null;for(let a=0;a<b.openEnd;a++)d=c,c=c.lastChild;let e=a.steps.length,f=this.ranges;for(let g=0;g<f.length;g++){let{$from:h,$to:i}=f[g],j=a.mapping.slice(e);a.replaceRange(j.map(h.pos),j.map(i.pos),g?J.empty:b),0==g&&bk(a,e,(c?c.isInline:d&&d.isTextblock)?-1:1)}}replaceWith(a,b){let c=a.steps.length,d=this.ranges;for(let e=0;e<d.length;e++){let{$from:f,$to:g}=d[e],h=a.mapping.slice(c),i=h.map(f.pos),j=h.map(g.pos);e?a.deleteRange(i,j):(a.replaceRangeWith(i,j,b),bk(a,c,b.isInline?-1:1))}}static findFrom(a,b,c=!1){let d=a.parent.inlineContent?new bd(a):bj(a.node(0),a.parent,a.pos,a.index(),b,c);if(d)return d;for(let d=a.depth-1;d>=0;d--){let e=b<0?bj(a.node(0),a.node(d),a.before(d+1),a.index(d),b,c):bj(a.node(0),a.node(d),a.after(d+1),a.index(d)+1,b,c);if(e)return e}return null}static near(a,b=1){return this.findFrom(a,b)||this.findFrom(a,-b)||new bh(a.node(0))}static atStart(a){return bj(a,a,0,0,1)||new bh(a)}static atEnd(a){return bj(a,a,a.content.size,a.childCount,-1)||new bh(a)}static fromJSON(a,b){if(!b||!b.type)throw RangeError("Invalid input for Selection.fromJSON");let c=a8[b.type];if(!c)throw RangeError(`No selection type ${b.type} defined`);return c.fromJSON(a,b)}static jsonID(a,b){if(a in a8)throw RangeError("Duplicate use of selection JSON ID "+a);return a8[a]=b,b.prototype.jsonID=a,b}getBookmark(){return bd.between(this.$anchor,this.$head).getBookmark()}}a9.prototype.visible=!0;class ba{constructor(a,b){this.$from=a,this.$to=b}}let bb=!1;function bc(a){bb||a.parent.inlineContent||(bb=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+a.parent.type.name+")"))}class bd extends a9{constructor(a,b=a){bc(a),bc(b),super(a,b)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(a,b){let c=a.resolve(b.map(this.head));if(!c.parent.inlineContent)return a9.near(c);let d=a.resolve(b.map(this.anchor));return new bd(d.parent.inlineContent?d:c,c)}replace(a,b=J.empty){if(super.replace(a,b),b==J.empty){let b=this.$from.marksAcross(this.$to);b&&a.ensureMarks(b)}}eq(a){return a instanceof bd&&a.anchor==this.anchor&&a.head==this.head}getBookmark(){return new be(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(a,b){if("number"!=typeof b.anchor||"number"!=typeof b.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new bd(a.resolve(b.anchor),a.resolve(b.head))}static create(a,b,c=b){let d=a.resolve(b);return new this(d,c==b?d:a.resolve(c))}static between(a,b,c){let d=a.pos-b.pos;if((!c||d)&&(c=d>=0?1:-1),!b.parent.inlineContent){let a=a9.findFrom(b,c,!0)||a9.findFrom(b,-c,!0);if(!a)return a9.near(b,c);b=a.$head}return a.parent.inlineContent||(0==d?a=b:(a=(a9.findFrom(a,-c,!0)||a9.findFrom(a,c,!0)).$anchor).pos<b.pos!=d<0&&(a=b)),new bd(a,b)}}a9.jsonID("text",bd);class be{constructor(a,b){this.anchor=a,this.head=b}map(a){return new be(a.map(this.anchor),a.map(this.head))}resolve(a){return bd.between(a.resolve(this.anchor),a.resolve(this.head))}}class bf extends a9{constructor(a){let b=a.nodeAfter,c=a.node(0).resolve(a.pos+b.nodeSize);super(a,c),this.node=b}map(a,b){let{deleted:c,pos:d}=b.mapResult(this.anchor),e=a.resolve(d);return c?a9.near(e):new bf(e)}content(){return new J(D.from(this.node),0,0)}eq(a){return a instanceof bf&&a.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bg(this.anchor)}static fromJSON(a,b){if("number"!=typeof b.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new bf(a.resolve(b.anchor))}static create(a,b){return new bf(a.resolve(b))}static isSelectable(a){return!a.isText&&!1!==a.type.spec.selectable}}bf.prototype.visible=!1,a9.jsonID("node",bf);class bg{constructor(a){this.anchor=a}map(a){let{deleted:b,pos:c}=a.mapResult(this.anchor);return b?new be(c,c):new bg(c)}resolve(a){let b=a.resolve(this.anchor),c=b.nodeAfter;return c&&bf.isSelectable(c)?new bf(b):a9.near(b)}}class bh extends a9{constructor(a){super(a.resolve(0),a.resolve(a.content.size))}replace(a,b=J.empty){if(b==J.empty){a.delete(0,a.doc.content.size);let b=a9.atStart(a.doc);b.eq(a.selection)||a.setSelection(b)}else super.replace(a,b)}toJSON(){return{type:"all"}}static fromJSON(a){return new bh(a)}map(a){return new bh(a)}eq(a){return a instanceof bh}getBookmark(){return bi}}a9.jsonID("all",bh);let bi={map(){return this},resolve:a=>new bh(a)};function bj(a,b,c,d,e,f=!1){if(b.inlineContent)return bd.create(a,c);for(let g=d-(e>0?0:1);e>0?g<b.childCount:g>=0;g+=e){let d=b.child(g);if(d.isAtom){if(!f&&bf.isSelectable(d))return bf.create(a,c-(e<0?d.nodeSize:0))}else{let b=bj(a,d,c+e,e<0?d.childCount:0,e,f);if(b)return b}c+=d.nodeSize*e}return null}function bk(a,b,c){let d,e=a.steps.length-1;if(e<b)return;let f=a.steps[e];(f instanceof aK||f instanceof aL)&&(a.mapping.maps[e].forEach((a,b,c,e)=>{null==d&&(d=e)}),a.setSelection(a9.near(a.doc.resolve(d),c)))}class bl extends a7{constructor(a){super(a.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=a.selection,this.storedMarks=a.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(a){if(a.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=a,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(a){return this.storedMarks=a,this.updated|=2,this}ensureMarks(a){return H.sameSet(this.storedMarks||this.selection.$from.marks(),a)||this.setStoredMarks(a),this}addStoredMark(a){return this.ensureMarks(a.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(a){return this.ensureMarks(a.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(a,b){super.addStep(a,b),this.updated=-3&this.updated,this.storedMarks=null}setTime(a){return this.time=a,this}replaceSelection(a){return this.selection.replace(this,a),this}replaceSelectionWith(a,b=!0){let c=this.selection;return b&&(a=a.mark(this.storedMarks||(c.empty?c.$from.marks():c.$from.marksAcross(c.$to)||H.none))),c.replaceWith(this,a),this}deleteSelection(){return this.selection.replace(this),this}insertText(a,b,c){let d=this.doc.type.schema;if(null==b)return a?this.replaceSelectionWith(d.text(a),!0):this.deleteSelection();{if(null==c&&(c=b),!a)return this.deleteRange(b,c);let e=this.storedMarks;if(!e){let a=this.doc.resolve(b);e=c==b?a.marks():a.marksAcross(this.doc.resolve(c))}return this.replaceRangeWith(b,c,d.text(a,e)),this.selection.empty||this.selection.to!=b+a.length||this.setSelection(a9.near(this.selection.$to)),this}}setMeta(a,b){return this.meta["string"==typeof a?a:a.key]=b,this}getMeta(a){return this.meta["string"==typeof a?a:a.key]}get isGeneric(){for(let a in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function bm(a,b){return b&&a?a.bind(b):a}class bn{constructor(a,b,c){this.name=a,this.init=bm(b.init,c),this.apply=bm(b.apply,c)}}let bo=[new bn("doc",{init:a=>a.doc||a.schema.topNodeType.createAndFill(),apply:a=>a.doc}),new bn("selection",{init:(a,b)=>a.selection||a9.atStart(b.doc),apply:a=>a.selection}),new bn("storedMarks",{init:a=>a.storedMarks||null,apply:(a,b,c,d)=>d.selection.$cursor?a.storedMarks:null}),new bn("scrollToSelection",{init:()=>0,apply:(a,b)=>a.scrolledIntoView?b+1:b})];class bp{constructor(a,b){this.schema=a,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bo.slice(),b&&b.forEach(a=>{if(this.pluginsByKey[a.key])throw RangeError("Adding different instances of a keyed plugin ("+a.key+")");this.plugins.push(a),this.pluginsByKey[a.key]=a,a.spec.state&&this.fields.push(new bn(a.key,a.spec.state,a))})}}class bq{constructor(a){this.config=a}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(a){return this.applyTransaction(a).state}filterTransaction(a,b=-1){for(let c=0;c<this.config.plugins.length;c++)if(c!=b){let b=this.config.plugins[c];if(b.spec.filterTransaction&&!b.spec.filterTransaction.call(b,a,this))return!1}return!0}applyTransaction(a){if(!this.filterTransaction(a))return{state:this,transactions:[]};let b=[a],c=this.applyInner(a),d=null;for(;;){let e=!1;for(let f=0;f<this.config.plugins.length;f++){let g=this.config.plugins[f];if(g.spec.appendTransaction){let h=d?d[f].n:0,i=d?d[f].state:this,j=h<b.length&&g.spec.appendTransaction.call(g,h?b.slice(h):b,i,c);if(j&&c.filterTransaction(j,f)){if(j.setMeta("appendedTransaction",a),!d){d=[];for(let a=0;a<this.config.plugins.length;a++)d.push(a<f?{state:c,n:b.length}:{state:this,n:0})}b.push(j),c=c.applyInner(j),e=!0}d&&(d[f]={state:c,n:b.length})}}if(!e)return{state:c,transactions:b}}}applyInner(a){if(!a.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let b=new bq(this.config),c=this.config.fields;for(let d=0;d<c.length;d++){let e=c[d];b[e.name]=e.apply(a,this[e.name],this,b)}return b}get tr(){return new bl(this)}static create(a){let b=new bp(a.doc?a.doc.type.schema:a.schema,a.plugins),c=new bq(b);for(let d=0;d<b.fields.length;d++)c[b.fields[d].name]=b.fields[d].init(a,c);return c}reconfigure(a){let b=new bp(this.schema,a.plugins),c=b.fields,d=new bq(b);for(let b=0;b<c.length;b++){let e=c[b].name;d[e]=this.hasOwnProperty(e)?this[e]:c[b].init(a,d)}return d}toJSON(a){let b={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(b.storedMarks=this.storedMarks.map(a=>a.toJSON())),a&&"object"==typeof a)for(let c in a){if("doc"==c||"selection"==c)throw RangeError("The JSON fields `doc` and `selection` are reserved");let d=a[c],e=d.spec.state;e&&e.toJSON&&(b[c]=e.toJSON.call(d,this[d.key]))}return b}static fromJSON(a,b,c){if(!b)throw RangeError("Invalid input for EditorState.fromJSON");if(!a.schema)throw RangeError("Required config field 'schema' missing");let d=new bp(a.schema,a.plugins),e=new bq(d);return d.fields.forEach(d=>{if("doc"==d.name)e.doc=W.fromJSON(a.schema,b.doc);else if("selection"==d.name)e.selection=a9.fromJSON(e.doc,b.selection);else if("storedMarks"==d.name)b.storedMarks&&(e.storedMarks=b.storedMarks.map(a.schema.markFromJSON));else{if(c)for(let f in c){let g=c[f],h=g.spec.state;if(g.key==d.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(b,f)){e[d.name]=h.fromJSON.call(g,a,b[f],e);return}}e[d.name]=d.init(a,e)}}),e}}class br{constructor(a){this.spec=a,this.props={},a.props&&function a(b,c,d){for(let e in b){let f=b[e];f instanceof Function?f=f.bind(c):"handleDOMEvents"==e&&(f=a(f,c,{})),d[e]=f}return d}(a.props,this,this.props),this.key=a.key?a.key.key:bt("plugin")}getState(a){return a[this.key]}}let bs=Object.create(null);function bt(a){return a in bs?a+"$"+ ++bs[a]:(bs[a]=0,a+"$")}class bu{constructor(a="key"){this.key=bt(a)}get(a){return a.config.pluginsByKey[this.key]}getState(a){return a[this.key]}}let bv=(a,b)=>!a.selection.empty&&(b&&b(a.tr.deleteSelection().scrollIntoView()),!0);function bw(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("backward",a):!(c.parentOffset>0))?c:null}let bx=(a,b,c)=>{let d=bw(a,c);if(!d)return!1;let e=bB(d);if(!e){let c=d.blockRange(),e=c&&aO(c);return null!=e&&(b&&b(a.tr.lift(c,e).scrollIntoView()),!0)}let f=e.nodeBefore;if(bL(a,e,b,-1))return!0;if(0==d.parent.content.size&&(bz(f,"end")||bf.isSelectable(f)))for(let c=d.depth;;c--){let g=aY(a.doc,d.before(c),d.after(c),J.empty);if(g&&g.slice.size<g.to-g.from){if(b){let c=a.tr.step(g);c.setSelection(bz(f,"end")?a9.findFrom(c.doc.resolve(c.mapping.map(e.pos,-1)),-1):bf.create(c.doc,e.pos-f.nodeSize)),b(c.scrollIntoView())}return!0}if(1==c||d.node(c-1).childCount>1)break}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos-f.nodeSize,e.pos).scrollIntoView()),!0)};function by(a,b,c){let d=b.nodeBefore,e=b.pos-1;for(;!d.isTextblock;e--){if(d.type.spec.isolating)return!1;let a=d.lastChild;if(!a)return!1;d=a}let f=b.nodeAfter,g=b.pos+1;for(;!f.isTextblock;g++){if(f.type.spec.isolating)return!1;let a=f.firstChild;if(!a)return!1;f=a}let h=aY(a.doc,e,g,J.empty);if(!h||h.from!=e||h instanceof aK&&h.slice.size>=g-e)return!1;if(c){let b=a.tr.step(h);b.setSelection(bd.create(b.doc,e)),c(b.scrollIntoView())}return!0}function bz(a,b,c=!1){for(let d=a;d;d="start"==b?d.firstChild:d.lastChild){if(d.isTextblock)return!0;if(c&&1!=d.childCount)break}return!1}let bA=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("backward",a):d.parentOffset>0)return!1;f=bB(d)}let g=f&&f.nodeBefore;return!!g&&!!bf.isSelectable(g)&&(b&&b(a.tr.setSelection(bf.create(a.doc,f.pos-g.nodeSize)).scrollIntoView()),!0)};function bB(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){if(a.index(b)>0)return a.doc.resolve(a.before(b+1));if(a.node(b).type.spec.isolating)break}return null}function bC(a,b){let{$cursor:c}=a.selection;return c&&(b?b.endOfTextblock("forward",a):!(c.parentOffset<c.parent.content.size))?c:null}let bD=(a,b,c)=>{let d=bC(a,c);if(!d)return!1;let e=bF(d);if(!e)return!1;let f=e.nodeAfter;if(bL(a,e,b,1))return!0;if(0==d.parent.content.size&&(bz(f,"start")||bf.isSelectable(f))){let c=aY(a.doc,d.before(),d.after(),J.empty);if(c&&c.slice.size<c.to-c.from){if(b){let d=a.tr.step(c);d.setSelection(bz(f,"start")?a9.findFrom(d.doc.resolve(d.mapping.map(e.pos)),1):bf.create(d.doc,d.mapping.map(e.pos))),b(d.scrollIntoView())}return!0}}return!!f.isAtom&&e.depth==d.depth-1&&(b&&b(a.tr.delete(e.pos,e.pos+f.nodeSize).scrollIntoView()),!0)},bE=(a,b,c)=>{let{$head:d,empty:e}=a.selection,f=d;if(!e)return!1;if(d.parent.isTextblock){if(c?!c.endOfTextblock("forward",a):d.parentOffset<d.parent.content.size)return!1;f=bF(d)}let g=f&&f.nodeAfter;return!!g&&!!bf.isSelectable(g)&&(b&&b(a.tr.setSelection(bf.create(a.doc,f.pos)).scrollIntoView()),!0)};function bF(a){if(!a.parent.type.spec.isolating)for(let b=a.depth-1;b>=0;b--){let c=a.node(b);if(a.index(b)+1<c.childCount)return a.doc.resolve(a.after(b+1));if(c.type.spec.isolating)break}return null}let bG=(a,b)=>{let{$head:c,$anchor:d}=a.selection;return!!c.parent.type.spec.code&&!!c.sameParent(d)&&(b&&b(a.tr.insertText("\n").scrollIntoView()),!0)};function bH(a){for(let b=0;b<a.edgeCount;b++){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}let bI=(a,b)=>{let{$head:c,$anchor:d}=a.selection;if(!c.parent.type.spec.code||!c.sameParent(d))return!1;let e=c.node(-1),f=c.indexAfter(-1),g=bH(e.contentMatchAt(f));if(!g||!e.canReplaceWith(f,f,g))return!1;if(b){let d=c.after(),e=a.tr.replaceWith(d,d,g.createAndFill());e.setSelection(a9.near(e.doc.resolve(d),1)),b(e.scrollIntoView())}return!0},bJ=(a,b)=>{let c=a.selection,{$from:d,$to:e}=c;if(c instanceof bh||d.parent.inlineContent||e.parent.inlineContent)return!1;let f=bH(e.parent.contentMatchAt(e.indexAfter()));if(!f||!f.isTextblock)return!1;if(b){let c=(!d.parentOffset&&e.index()<e.parent.childCount?d:e).pos,g=a.tr.insert(c,f.createAndFill());g.setSelection(bd.create(g.doc,c+1)),b(g.scrollIntoView())}return!0},bK=(a,b)=>{let{$cursor:c}=a.selection;if(!c||c.parent.content.size)return!1;if(c.depth>1&&c.after()!=c.end(-1)){let d=c.before();if(aT(a.doc,d))return b&&b(a.tr.split(d).scrollIntoView()),!0}let d=c.blockRange(),e=d&&aO(d);return null!=e&&(b&&b(a.tr.lift(d,e).scrollIntoView()),!0)};function bL(a,b,c,d){let e,f,g,h=b.nodeBefore,i=b.nodeAfter,j,k,l=h.type.spec.isolating||i.type.spec.isolating;if(!l&&(e=b.nodeBefore,f=b.nodeAfter,g=b.index(),e&&f&&e.type.compatibleContent(f.type)&&(!e.content.size&&b.parent.canReplace(g-1,g)?(c&&c(a.tr.delete(b.pos-e.nodeSize,b.pos).scrollIntoView()),!0):!!b.parent.canReplace(g,g+1)&&!!(f.isTextblock||aU(a.doc,b.pos))&&(c&&c(a.tr.join(b.pos).scrollIntoView()),!0))))return!0;let m=!l&&b.parent.canReplace(b.index(),b.index()+1);if(m&&(j=(k=h.contentMatchAt(h.childCount)).findWrapping(i.type))&&k.matchType(j[0]||i.type).validEnd){if(c){let d=b.pos+i.nodeSize,e=D.empty;for(let a=j.length-1;a>=0;a--)e=D.from(j[a].create(null,e));e=D.from(h.copy(e));let f=a.tr.step(new aL(b.pos-1,d,b.pos,d,new J(e,1,0),j.length,!0)),g=f.doc.resolve(d+2*j.length);g.nodeAfter&&g.nodeAfter.type==h.type&&aU(f.doc,g.pos)&&f.join(g.pos),c(f.scrollIntoView())}return!0}let n=i.type.spec.isolating||d>0&&l?null:a9.findFrom(b,1),o=n&&n.$from.blockRange(n.$to),p=o&&aO(o);if(null!=p&&p>=b.depth)return c&&c(a.tr.lift(o,p).scrollIntoView()),!0;if(m&&bz(i,"start",!0)&&bz(h,"end")){let d=h,e=[];for(;e.push(d),!d.isTextblock;)d=d.lastChild;let f=i,g=1;for(;!f.isTextblock;f=f.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,f.content)){if(c){let d=D.empty;for(let a=e.length-1;a>=0;a--)d=D.from(e[a].copy(d));c(a.tr.step(new aL(b.pos-e.length,b.pos+i.nodeSize,b.pos+g,b.pos+i.nodeSize-g,new J(d,e.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function bM(a){return function(b,c){let d=b.selection,e=a<0?d.$from:d.$to,f=e.depth;for(;e.node(f).isInline;){if(!f)return!1;f--}return!!e.node(f).isTextblock&&(c&&c(b.tr.setSelection(bd.create(b.doc,a<0?e.start(f):e.end(f)))),!0)}}let bN=bM(-1),bO=bM(1);function bP(a,b=null){return function(c,d){let e=!1;for(let d=0;d<c.selection.ranges.length&&!e;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];c.doc.nodesBetween(f,g,(d,f)=>{if(e)return!1;if(!(!d.isTextblock||d.hasMarkup(a,b)))if(d.type==a)e=!0;else{let b=c.doc.resolve(f),d=b.index();e=b.parent.canReplaceWith(d,d+1,a)}})}if(!e)return!1;if(d){let e=c.tr;for(let d=0;d<c.selection.ranges.length;d++){let{$from:{pos:f},$to:{pos:g}}=c.selection.ranges[d];e.setBlockType(f,g,a,b)}d(e.scrollIntoView())}return!0}}function bQ(...a){return function(b,c,d){for(let e=0;e<a.length;e++)if(a[e](b,c,d))return!0;return!1}}let bR=bQ(bv,bx,bA),bS=bQ(bv,bD,bE),bT={Enter:bQ(bG,bJ,bK,(a,b)=>{let{$from:c,$to:d}=a.selection;if(a.selection instanceof bf&&a.selection.node.isBlock)return!!c.parentOffset&&!!aT(a.doc,c.pos)&&(b&&b(a.tr.split(c.pos).scrollIntoView()),!0);if(!c.depth)return!1;let e=[],f,g,h=!1,i=!1;for(let a=c.depth;;a--){if(c.node(a).isBlock){let b;h=c.end(a)==c.pos+(c.depth-a),i=c.start(a)==c.pos-(c.depth-a),g=bH(c.node(a-1).contentMatchAt(c.indexAfter(a-1)));e.unshift(b||(h&&g?{type:g}:null)),f=a;break}if(1==a)return!1;e.unshift(null)}let j=a.tr;(a.selection instanceof bd||a.selection instanceof bh)&&j.deleteSelection();let k=j.mapping.map(c.pos),l=aT(j.doc,k,e.length,e);if(l||(e[0]=g?{type:g}:null,l=aT(j.doc,k,e.length,e)),!l)return!1;if(j.split(k,e.length,e),!h&&i&&c.node(f).type!=g){let a=j.mapping.map(c.before(f)),b=j.doc.resolve(a);g&&c.node(f-1).canReplaceWith(b.index(),b.index()+1,g)&&j.setNodeMarkup(j.mapping.map(c.before(f)),g)}return b&&b(j.scrollIntoView()),!0}),"Mod-Enter":bI,Backspace:bR,"Mod-Backspace":bR,"Shift-Backspace":bR,Delete:bS,"Mod-Delete":bS,"Mod-a":(a,b)=>(b&&b(a.tr.setSelection(new bh(a.doc))),!0)},bU={"Ctrl-h":bT.Backspace,"Alt-Backspace":bT["Mod-Backspace"],"Ctrl-d":bT.Delete,"Ctrl-Alt-Backspace":bT["Mod-Delete"],"Alt-Delete":bT["Mod-Delete"],"Alt-d":bT["Mod-Delete"],"Ctrl-a":bN,"Ctrl-e":bO};for(let a in bT)bU[a]=bT[a];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();let bV=function(a){for(var b=0;;b++)if(!(a=a.previousSibling))return b},bW=function(a){let b=a.assignedSlot||a.parentNode;return b&&11==b.nodeType?b.host:b},bX=null,bY=function(a,b,c){let d=bX||(bX=document.createRange());return d.setEnd(a,null==c?a.nodeValue.length:c),d.setStart(a,b||0),d},bZ=function(){bX=null},b$=function(a,b,c,d){return c&&(b0(a,b,c,d,-1)||b0(a,b,c,d,1))},b_=/^(img|br|input|textarea|hr)$/i;function b0(a,b,c,d,e){for(var f;;){if(a==c&&b==d)return!0;if(b==(e<0?0:b1(a))){let c=a.parentNode;if(!c||1!=c.nodeType||b2(a)||b_.test(a.nodeName)||"false"==a.contentEditable)return!1;b=bV(a)+(e<0?0:1),a=c}else{if(1!=a.nodeType)return!1;let c=a.childNodes[b+(e<0?-1:0)];if(1==c.nodeType&&"false"==c.contentEditable)if(null==(f=c.pmViewDesc)||!f.ignoreForSelection)return!1;else b+=e;else a=c,b=e<0?b1(a):0}}}function b1(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function b2(a){let b;for(let c=a;c&&!(b=c.pmViewDesc);c=c.parentNode);return b&&b.node&&b.node.isBlock&&(b.dom==a||b.contentDOM==a)}let b3=function(a){return a.focusNode&&b$(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset)};function b4(a,b){let c=document.createEvent("Event");return c.initEvent("keydown",!0,!0),c.keyCode=a,c.key=c.code=b,c}let b5="u">typeof navigator?navigator:null,b6="u">typeof document?document:null,b7=b5&&b5.userAgent||"",b8=/Edge\/(\d+)/.exec(b7),b9=/MSIE \d/.exec(b7),ca=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(b7),cb=!!(b9||ca||b8),cc=b9?document.documentMode:ca?+ca[1]:b8?+b8[1]:0,cd=!cb&&/gecko\/(\d+)/i.test(b7);cd&&(/Firefox\/(\d+)/.exec(b7)||[0,0])[1];let ce=!cb&&/Chrome\/(\d+)/.exec(b7),cf=!!ce,cg=ce?+ce[1]:0,ch=!cb&&!!b5&&/Apple Computer/.test(b5.vendor),ci=ch&&(/Mobile\/\w+/.test(b7)||!!b5&&b5.maxTouchPoints>2),cj=ci||!!b5&&/Mac/.test(b5.platform),ck=!!b5&&/Win/.test(b5.platform),cl=/Android \d/.test(b7),cm=!!b6&&"webkitFontSmoothing"in b6.documentElement.style,cn=cm?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function co(a,b){return"number"==typeof a?a:a[b]}function cp(a,b,c){let d=a.someProp("scrollThreshold")||0,e=a.someProp("scrollMargin")||5,f=a.dom.ownerDocument;for(let g=c||a.dom;g;){if(1!=g.nodeType){g=bW(g);continue}let a=g,c=a==f.body,h=c?function(a){let b=a.defaultView&&a.defaultView.visualViewport;return b?{left:0,right:b.width,top:0,bottom:b.height}:{left:0,right:a.documentElement.clientWidth,top:0,bottom:a.documentElement.clientHeight}}(f):function(a){let b=a.getBoundingClientRect(),c=b.width/a.offsetWidth||1,d=b.height/a.offsetHeight||1;return{left:b.left,right:b.left+a.clientWidth*c,top:b.top,bottom:b.top+a.clientHeight*d}}(a),i=0,j=0;if(b.top<h.top+co(d,"top")?j=-(h.top-b.top+co(e,"top")):b.bottom>h.bottom-co(d,"bottom")&&(j=b.bottom-b.top>h.bottom-h.top?b.top+co(e,"top")-h.top:b.bottom-h.bottom+co(e,"bottom")),b.left<h.left+co(d,"left")?i=-(h.left-b.left+co(e,"left")):b.right>h.right-co(d,"right")&&(i=b.right-h.right+co(e,"right")),i||j)if(c)f.defaultView.scrollBy(i,j);else{let c=a.scrollLeft,d=a.scrollTop;j&&(a.scrollTop+=j),i&&(a.scrollLeft+=i);let e=a.scrollLeft-c,f=a.scrollTop-d;b={left:b.left-e,top:b.top-f,right:b.right-e,bottom:b.bottom-f}}let k=c?"fixed":getComputedStyle(g).position;if(/^(fixed|sticky)$/.test(k))break;g="absolute"==k?g.offsetParent:bW(g)}}function cq(a){let b=[],c=a.ownerDocument;for(let d=a;d&&(b.push({dom:d,top:d.scrollTop,left:d.scrollLeft}),a!=c);d=bW(d));return b}function cr(a,b){for(let c=0;c<a.length;c++){let{dom:d,top:e,left:f}=a[c];d.scrollTop!=e+b&&(d.scrollTop=e+b),d.scrollLeft!=f&&(d.scrollLeft=f)}}let cs=null;function ct(a,b){return a.left>=b.left-1&&a.left<=b.right+1&&a.top>=b.top-1&&a.top<=b.bottom+1}function cu(a){return a.top<a.bottom||a.left<a.right}function cv(a,b){let c=a.getClientRects();if(c.length){let a=c[b<0?0:c.length-1];if(cu(a))return a}return Array.prototype.find.call(c,cu)||a.getBoundingClientRect()}let cw=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function cx(a,b,c){let{node:d,offset:e,atom:f}=a.docView.domFromPos(b,c<0?-1:1),g=cm||cd;if(3==d.nodeType)if(g&&(cw.test(d.nodeValue)||(c<0?!e:e==d.nodeValue.length))){let a=cv(bY(d,e,e),c);if(cd&&e&&/\s/.test(d.nodeValue[e-1])&&e<d.nodeValue.length){let b=cv(bY(d,e-1,e-1),-1);if(b.top==a.top){let c=cv(bY(d,e,e+1),-1);if(c.top!=a.top)return cy(c,c.left<b.left)}}return a}else{let a=e,b=e,f=c<0?1:-1;return c<0&&!e?(b++,f=-1):c>=0&&e==d.nodeValue.length?(a--,f=1):c<0?a--:b++,cy(cv(bY(d,a,b),f),f<0)}if(!a.state.doc.resolve(b-(f||0)).parent.inlineContent){if(null==f&&e&&(c<0||e==b1(d))){let a=d.childNodes[e-1];if(1==a.nodeType)return cz(a.getBoundingClientRect(),!1)}if(null==f&&e<b1(d)){let a=d.childNodes[e];if(1==a.nodeType)return cz(a.getBoundingClientRect(),!0)}return cz(d.getBoundingClientRect(),c>=0)}if(null==f&&e&&(c<0||e==b1(d))){let a=d.childNodes[e-1],b=3==a.nodeType?bY(a,b1(a)-!g):1!=a.nodeType||"BR"==a.nodeName&&a.nextSibling?null:a;if(b)return cy(cv(b,1),!1)}if(null==f&&e<b1(d)){let a=d.childNodes[e];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let b=a?3==a.nodeType?bY(a,0,+!g):1==a.nodeType?a:null:null;if(b)return cy(cv(b,-1),!0)}return cy(cv(3==d.nodeType?bY(d):d,-c),c>=0)}function cy(a,b){if(0==a.width)return a;let c=b?a.left:a.right;return{top:a.top,bottom:a.bottom,left:c,right:c}}function cz(a,b){if(0==a.height)return a;let c=b?a.top:a.bottom;return{top:c,bottom:c,left:a.left,right:a.right}}function cA(a,b,c){let d=a.state,e=a.root.activeElement;d!=b&&a.updateState(b),e!=a.dom&&a.focus();try{return c()}finally{d!=b&&a.updateState(d),e!=a.dom&&e&&e.focus()}}let cB=/[\u0590-\u08ac]/,cC=null,cD=null,cE=!1;class cF{constructor(a,b,c,d){this.parent=a,this.children=b,this.dom=c,this.contentDOM=d,this.dirty=0,c.pmViewDesc=this}matchesWidget(a){return!1}matchesMark(a){return!1}matchesNode(a,b,c){return!1}matchesHack(a){return!1}parseRule(){return null}stopEvent(a){return!1}get size(){let a=0;for(let b=0;b<this.children.length;b++)a+=this.children[b].size;return a}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let a=0;a<this.children.length;a++)this.children[a].destroy()}posBeforeChild(a){for(let b=0,c=this.posAtStart;;b++){let d=this.children[b];if(d==a)return c;c+=d.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(a,b,c){let d;if(this.contentDOM&&this.contentDOM.contains(1==a.nodeType?a:a.parentNode))if(c<0){let c,d;if(a==this.contentDOM)c=a.childNodes[b-1];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.previousSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.previousSibling;return c?this.posBeforeChild(d)+d.size:this.posAtStart}else{let c,d;if(a==this.contentDOM)c=a.childNodes[b];else{for(;a.parentNode!=this.contentDOM;)a=a.parentNode;c=a.nextSibling}for(;c&&!((d=c.pmViewDesc)&&d.parent==this);)c=c.nextSibling;return c?this.posBeforeChild(d):this.posAtEnd}if(a==this.dom&&this.contentDOM)d=b>bV(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))d=2&a.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==b)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!1;break}if(b.previousSibling)break}if(null==d&&b==a.childNodes.length)for(let b=a;;b=b.parentNode){if(b==this.dom){d=!0;break}if(b.nextSibling)break}}return(null==d?c>0:d)?this.posAtEnd:this.posAtStart}nearestDesc(a,b=!1){for(let c=!0,d=a;d;d=d.parentNode){let e=this.getDesc(d),f;if(e&&(!b||e.node))if(!c||!(f=e.nodeDOM)||(1==f.nodeType?f.contains(1==a.nodeType?a:a.parentNode):f==a))return e;else c=!1}}getDesc(a){let b=a.pmViewDesc;for(let a=b;a;a=a.parent)if(a==this)return b}posFromDOM(a,b,c){for(let d=a;d;d=d.parentNode){let e=this.getDesc(d);if(e)return e.localPosFromDOM(a,b,c)}return -1}descAt(a){for(let b=0,c=0;b<this.children.length;b++){let d=this.children[b],e=c+d.size;if(c==a&&e!=c){for(;!d.border&&d.children.length;)for(let a=0;a<d.children.length;a++){let b=d.children[a];if(b.size){d=b;break}}return d}if(a<e)return d.descAt(a-c-d.border);c=e}}domFromPos(a,b){if(!this.contentDOM)return{node:this.dom,offset:0,atom:a+1};let c=0,d=0;for(let b=0;c<this.children.length;c++){let e=this.children[c],f=b+e.size;if(f>a||e instanceof cM){d=a-b;break}b=f}if(d)return this.children[c].domFromPos(d-this.children[c].border,b);for(let a;c&&!(a=this.children[c-1]).size&&a instanceof cG&&a.side>=0;c--);if(b<=0){let a,d=!0;for(;(a=c?this.children[c-1]:null)&&a.dom.parentNode!=this.contentDOM;c--,d=!1);return a&&b&&d&&!a.border&&!a.domAtom?a.domFromPos(a.size,b):{node:this.contentDOM,offset:a?bV(a.dom)+1:0}}{let a,d=!0;for(;(a=c<this.children.length?this.children[c]:null)&&a.dom.parentNode!=this.contentDOM;c++,d=!1);return a&&d&&!a.border&&!a.domAtom?a.domFromPos(0,b):{node:this.contentDOM,offset:a?bV(a.dom):this.contentDOM.childNodes.length}}}parseRange(a,b,c=0){if(0==this.children.length)return{node:this.contentDOM,from:a,to:b,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let d=-1,e=-1;for(let f=c,g=0;;g++){let c=this.children[g],h=f+c.size;if(-1==d&&a<=h){let e=f+c.border;if(a>=e&&b<=h-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(a,b,e);a=f;for(let b=g;b>0;b--){let c=this.children[b-1];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(1)){d=bV(c.dom)+1;break}a-=c.size}-1==d&&(d=0)}if(d>-1&&(h>b||g==this.children.length-1)){b=h;for(let a=g+1;a<this.children.length;a++){let c=this.children[a];if(c.size&&c.dom.parentNode==this.contentDOM&&!c.emptyChildAt(-1)){e=bV(c.dom);break}b+=c.size}-1==e&&(e=this.contentDOM.childNodes.length);break}f=h}return{node:this.contentDOM,from:a,to:b,fromOffset:d,toOffset:e}}emptyChildAt(a){if(this.border||!this.contentDOM||!this.children.length)return!1;let b=this.children[a<0?0:this.children.length-1];return 0==b.size||b.emptyChildAt(a)}domAfterPos(a){let{node:b,offset:c}=this.domFromPos(a,0);if(1!=b.nodeType||c==b.childNodes.length)throw RangeError("No node after pos "+a);return b.childNodes[c]}setSelection(a,b,c,d=!1){let e=Math.min(a,b),f=Math.max(a,b);for(let g=0,h=0;g<this.children.length;g++){let i=this.children[g],j=h+i.size;if(e>h&&f<j)return i.setSelection(a-h-i.border,b-h-i.border,c,d);h=j}let g=this.domFromPos(a,a?-1:1),h=b==a?g:this.domFromPos(b,b?-1:1),i=c.root.getSelection(),j=c.domSelectionRange(),k=!1;if((cd||ch)&&a==b){let{node:a,offset:b}=g;if(3==a.nodeType){if((k=!!(b&&"\n"==a.nodeValue[b-1]))&&b==a.nodeValue.length)for(let b=a,c;b;b=b.parentNode){if(c=b.nextSibling){"BR"==c.nodeName&&(g=h={node:c.parentNode,offset:bV(c)+1});break}let a=b.pmViewDesc;if(a&&a.node&&a.node.isBlock)break}}else{let c=a.childNodes[b-1];k=c&&("BR"==c.nodeName||"false"==c.contentEditable)}}if(cd&&j.focusNode&&j.focusNode!=h.node&&1==j.focusNode.nodeType){let a=j.focusNode.childNodes[j.focusOffset];a&&"false"==a.contentEditable&&(d=!0)}if(!(d||k&&ch)&&b$(g.node,g.offset,j.anchorNode,j.anchorOffset)&&b$(h.node,h.offset,j.focusNode,j.focusOffset))return;let l=!1;if((i.extend||a==b)&&!(k&&cd)){i.collapse(g.node,g.offset);try{a!=b&&i.extend(h.node,h.offset),l=!0}catch(a){}}if(!l){if(a>b){let a=g;g=h,h=a}let c=document.createRange();c.setEnd(h.node,h.offset),c.setStart(g.node,g.offset),i.removeAllRanges(),i.addRange(c)}}ignoreMutation(a){return!this.contentDOM&&"selection"!=a.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(a,b){for(let c=0,d=0;d<this.children.length;d++){let e=this.children[d],f=c+e.size;if(c==f?a<=f&&b>=c:a<f&&b>c){let d=c+e.border,g=f-e.border;if(a>=d&&b<=g){this.dirty=a==c||b==f?2:1,a==d&&b==g&&(e.contentLost||e.dom.parentNode!=this.contentDOM)?e.dirty=3:e.markDirty(a-d,b-d);return}e.dirty=e.dom!=e.contentDOM||e.dom.parentNode!=this.contentDOM||e.children.length?3:2}c=f}this.dirty=2}markParentsDirty(){let a=1;for(let b=this.parent;b;b=b.parent,a++){let c=1==a?2:1;b.dirty<c&&(b.dirty=c)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(a){return!1}}class cG extends cF{constructor(a,b,c,d){let e,f=b.type.toDOM;if("function"==typeof f&&(f=f(c,()=>e?e.parent?e.parent.posBeforeChild(e):void 0:d)),!b.type.spec.raw){if(1!=f.nodeType){let a=document.createElement("span");a.appendChild(f),f=a}f.contentEditable="false",f.classList.add("ProseMirror-widget")}super(a,[],f,null),this.widget=b,this.widget=b,e=this}matchesWidget(a){return 0==this.dirty&&a.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(a){let b=this.widget.spec.stopEvent;return!!b&&b(a)}ignoreMutation(a){return"selection"!=a.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class cH extends cF{constructor(a,b,c,d){super(a,[],b,null),this.textDOM=c,this.text=d}get size(){return this.text.length}localPosFromDOM(a,b){return a!=this.textDOM?this.posAtStart+(b?this.size:0):this.posAtStart+b}domFromPos(a){return{node:this.textDOM,offset:a}}ignoreMutation(a){return"characterData"===a.type&&a.target.nodeValue==a.oldValue}}class cI extends cF{constructor(a,b,c,d,e){super(a,[],c,d),this.mark=b,this.spec=e}static create(a,b,c,d){let e=d.nodeViews[b.type.name],f=e&&e(b,d,c);return f&&f.dom||(f=au.renderSpec(document,b.type.spec.toDOM(b,c),null,b.attrs)),new cI(a,b,f.dom,f.contentDOM||f.dom,f)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(a){return 3!=this.dirty&&this.mark.eq(a)}markDirty(a,b){if(super.markDirty(a,b),0!=this.dirty){let a=this.parent;for(;!a.node;)a=a.parent;a.dirty<this.dirty&&(a.dirty=this.dirty),this.dirty=0}}slice(a,b,c){let d=cI.create(this.parent,this.mark,!0,c),e=this.children,f=this.size;b<f&&(e=cX(e,b,f,c)),a>0&&(e=cX(e,0,a,c));for(let a=0;a<e.length;a++)e[a].parent=d;return d.children=e,d}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class cJ extends cF{constructor(a,b,c,d,e,f,g,h,i){super(a,[],e,f),this.node=b,this.outerDeco=c,this.innerDeco=d,this.nodeDOM=g}static create(a,b,c,d,e,f){let g=e.nodeViews[b.type.name],h,i=g&&g(b,e,()=>h?h.parent?h.parent.posBeforeChild(h):void 0:f,c,d),j=i&&i.dom,k=i&&i.contentDOM;if(b.isText)if(j){if(3!=j.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else j=document.createTextNode(b.text);else if(!j){let a=au.renderSpec(document,b.type.spec.toDOM(b),null,b.attrs);({dom:j,contentDOM:k}=a)}k||b.isText||"BR"==j.nodeName||(j.hasAttribute("contenteditable")||(j.contentEditable="false"),b.type.spec.draggable&&(j.draggable=!0));let l=j;return(j=cS(j,c,b),i)?h=new cN(a,b,c,d,j,k||null,l,i,e,f+1):b.isText?new cL(a,b,c,d,j,l,e):new cJ(a,b,c,d,j,k||null,l,e,f+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let a={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(a.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let b=this.children.length-1;b>=0;b--){let c=this.children[b];if(this.dom.contains(c.dom.parentNode)){a.contentElement=c.dom.parentNode;break}}a.contentElement||(a.getContent=()=>D.empty)}else a.contentElement=this.contentDOM;else a.getContent=()=>this.node.content;return a}matchesNode(a,b,c){return 0==this.dirty&&a.eq(this.node)&&cT(b,this.outerDeco)&&c.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(a,b){let c=this.node.inlineContent,d=b,e=a.composing?this.localCompositionInfo(a,b):null,f=e&&e.pos>-1?e:null,g=e&&e.pos<0,h=new cV(this,f&&f.node,a);(function(a,b,c,d){let e=b.locals(a),f=0;if(0==e.length){for(let c=0;c<a.childCount;c++){let g=a.child(c);d(g,e,b.forChild(f,g),c),f+=g.nodeSize}return}let g=0,h=[],i=null;for(let j=0;;){let k,l,m,n;for(;g<e.length&&e[g].to==f;){let a=e[g++];a.widget&&(k?(l||(l=[k])).push(a):k=a)}if(k)if(l){l.sort(cW);for(let a=0;a<l.length;a++)c(l[a],j,!!i)}else c(k,j,!!i);if(i)n=-1,m=i,i=null;else if(j<a.childCount)n=j,m=a.child(j++);else break;for(let a=0;a<h.length;a++)h[a].to<=f&&h.splice(a--,1);for(;g<e.length&&e[g].from<=f&&e[g].to>f;)h.push(e[g++]);let o=f+m.nodeSize;if(m.isText){let a=o;g<e.length&&e[g].from<a&&(a=e[g].from);for(let b=0;b<h.length;b++)h[b].to<a&&(a=h[b].to);a<o&&(i=m.cut(a-f),m=m.cut(0,a-f),o=a,n=-1)}else for(;g<e.length&&e[g].to<o;)g++;let p=m.isInline&&!m.isLeaf?h.filter(a=>!a.inline):h.slice();d(m,p,b.forChild(f,m),n),f=o}})(this.node,this.innerDeco,(b,e,f)=>{b.spec.marks?h.syncToMarks(b.spec.marks,c,a,e):b.type.side>=0&&!f&&h.syncToMarks(e==this.node.childCount?H.none:this.node.child(e).marks,c,a,e),h.placeWidget(b,a,d)},(b,f,i,j)=>{let k;h.syncToMarks(b.marks,c,a,j),h.findNodeMatch(b,f,i,j)||g&&a.state.selection.from>d&&a.state.selection.to<d+b.nodeSize&&(k=h.findIndexWithChild(e.node))>-1&&h.updateNodeAt(b,f,i,k,a)||h.updateNextNode(b,f,i,a,j,d)||h.addNode(b,f,i,a,d),d+=b.nodeSize}),h.syncToMarks([],c,a,0),this.node.isTextblock&&h.addTextblockHacks(),h.destroyRest(),(h.changed||2==this.dirty)&&(f&&this.protectLocalComposition(a,f),function a(b,c,d){let e=b.firstChild,f=!1;for(let g=0;g<c.length;g++){let h=c[g],i=h.dom;if(i.parentNode==b){for(;i!=e;)e=cU(e),f=!0;e=e.nextSibling}else f=!0,b.insertBefore(i,e);if(h instanceof cI){let c=e?e.previousSibling:b.lastChild;a(h.contentDOM,h.children,d),e=c?c.nextSibling:b.firstChild}}for(;e;)e=cU(e),f=!0;f&&d.trackWrites==b&&(d.trackWrites=null)}(this.contentDOM,this.children,a),ci&&function(a){if("UL"==a.nodeName||"OL"==a.nodeName){let b=a.style.cssText;a.style.cssText=b+"; list-style: square !important",window.getComputedStyle(a).listStyle,a.style.cssText=b}}(this.dom))}localCompositionInfo(a,b){let{from:c,to:d}=a.state.selection;if(!(a.state.selection instanceof bd)||c<b||d>b+this.node.content.size)return null;let e=a.input.compositionNode;if(!e||!this.dom.contains(e.parentNode))return null;if(!this.node.inlineContent)return{node:e,pos:-1,text:""};{let a=e.nodeValue,f=function(a,b,c,d){for(let e=0,f=0;e<a.childCount&&f<=d;){let g=a.child(e++),h=f;if(f+=g.nodeSize,!g.isText)continue;let i=g.text;for(;e<a.childCount;){let b=a.child(e++);if(f+=b.nodeSize,!b.isText)break;i+=b.text}if(f>=c){if(f>=d&&i.slice(d-b.length-h,d-h)==b)return d-b.length;let a=h<d?i.lastIndexOf(b,d-h-1):-1;if(a>=0&&a+b.length+h>=c)return h+a;if(c==d&&i.length>=d+b.length-h&&i.slice(d-h,d-h+b.length)==b)return d}}return -1}(this.node.content,a,c-b,d-b);return f<0?null:{node:e,pos:f,text:a}}}protectLocalComposition(a,{node:b,pos:c,text:d}){if(this.getDesc(b))return;let e=b;for(;e.parentNode!=this.contentDOM;e=e.parentNode){for(;e.previousSibling;)e.parentNode.removeChild(e.previousSibling);for(;e.nextSibling;)e.parentNode.removeChild(e.nextSibling);e.pmViewDesc&&(e.pmViewDesc=void 0)}let f=new cH(this,e,b,d);a.input.compositionNodes.push(f),this.children=cX(this.children,c,c+d.length,a,f)}update(a,b,c,d){return 3!=this.dirty&&!!a.sameMarkup(this.node)&&(this.updateInner(a,b,c,d),!0)}updateInner(a,b,c,d){this.updateOuterDeco(b),this.node=a,this.innerDeco=c,this.contentDOM&&this.updateChildren(d,this.posAtStart),this.dirty=0}updateOuterDeco(a){if(cT(a,this.outerDeco))return;let b=1!=this.nodeDOM.nodeType,c=this.dom;this.dom=cR(this.dom,this.nodeDOM,cQ(this.outerDeco,this.node,b),cQ(a,this.node,b)),this.dom!=c&&(c.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=a}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function cK(a,b,c,d,e){cS(d,b,a);let f=new cJ(void 0,a,b,c,d,d,d,e,0);return f.contentDOM&&f.updateChildren(e,0),f}class cL extends cJ{constructor(a,b,c,d,e,f,g){super(a,b,c,d,e,null,f,g,0)}parseRule(){let a=this.nodeDOM.parentNode;for(;a&&a!=this.dom&&!a.pmIsDeco;)a=a.parentNode;return{skip:a||!0}}update(a,b,c,d){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!a.sameMarkup(this.node)&&(this.updateOuterDeco(b),(0!=this.dirty||a.text!=this.node.text)&&a.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=a.text,d.trackWrites==this.nodeDOM&&(d.trackWrites=null)),this.node=a,this.dirty=0,!0)}inParent(){let a=this.parent.contentDOM;for(let b=this.nodeDOM;b;b=b.parentNode)if(b==a)return!0;return!1}domFromPos(a){return{node:this.nodeDOM,offset:a}}localPosFromDOM(a,b,c){return a==this.nodeDOM?this.posAtStart+Math.min(b,this.node.text.length):super.localPosFromDOM(a,b,c)}ignoreMutation(a){return"characterData"!=a.type&&"selection"!=a.type}slice(a,b,c){let d=this.node.cut(a,b),e=document.createTextNode(d.text);return new cL(this.parent,d,this.outerDeco,this.innerDeco,e,e,c)}markDirty(a,b){super.markDirty(a,b),this.dom!=this.nodeDOM&&(0==a||b==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(a){return this.node.text==a}}class cM extends cF{parseRule(){return{ignore:!0}}matchesHack(a){return 0==this.dirty&&this.dom.nodeName==a}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class cN extends cJ{constructor(a,b,c,d,e,f,g,h,i,j){super(a,b,c,d,e,f,g,i,j),this.spec=h}update(a,b,c,d){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==a.type||this.spec.multiType)){let e=this.spec.update(a,b,c);return e&&this.updateInner(a,b,c,d),e}return(!!this.contentDOM||!!a.isLeaf)&&super.update(a,b,c,d)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(a,b,c,d){this.spec.setSelection?this.spec.setSelection(a,b,c.root):super.setSelection(a,b,c,d)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(a){return!!this.spec.stopEvent&&this.spec.stopEvent(a)}ignoreMutation(a){return this.spec.ignoreMutation?this.spec.ignoreMutation(a):super.ignoreMutation(a)}}let cO=function(a){a&&(this.nodeName=a)};cO.prototype=Object.create(null);let cP=[new cO];function cQ(a,b,c){if(0==a.length)return cP;let d=c?cP[0]:new cO,e=[d];for(let f=0;f<a.length;f++){let g=a[f].type.attrs;if(g)for(let a in g.nodeName&&e.push(d=new cO(g.nodeName)),g){let f=g[a];null!=f&&(c&&1==e.length&&e.push(d=new cO(b.isInline?"span":"div")),"class"==a?d.class=(d.class?d.class+" ":"")+f:"style"==a?d.style=(d.style?d.style+";":"")+f:"nodeName"!=a&&(d[a]=f))}}return e}function cR(a,b,c,d){if(c==cP&&d==cP)return b;let e=b;for(let b=0;b<d.length;b++){let f=d[b],g=c[b];if(b){let b;g&&g.nodeName==f.nodeName&&e!=a&&(b=e.parentNode)&&b.nodeName.toLowerCase()==f.nodeName||((b=document.createElement(f.nodeName)).pmIsDeco=!0,b.appendChild(e),g=cP[0]),e=b}!function(a,b,c){for(let d in b)"class"==d||"style"==d||"nodeName"==d||d in c||a.removeAttribute(d);for(let d in c)"class"!=d&&"style"!=d&&"nodeName"!=d&&c[d]!=b[d]&&a.setAttribute(d,c[d]);if(b.class!=c.class){let d=b.class?b.class.split(" ").filter(Boolean):[],e=c.class?c.class.split(" ").filter(Boolean):[];for(let b=0;b<d.length;b++)-1==e.indexOf(d[b])&&a.classList.remove(d[b]);for(let b=0;b<e.length;b++)-1==d.indexOf(e[b])&&a.classList.add(e[b]);0==a.classList.length&&a.removeAttribute("class")}if(b.style!=c.style){if(b.style){let c=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,d;for(;d=c.exec(b.style);)a.style.removeProperty(d[1])}c.style&&(a.style.cssText+=c.style)}}(e,g||cP[0],f)}return e}function cS(a,b,c){return cR(a,a,cP,cQ(b,c,1!=a.nodeType))}function cT(a,b){if(a.length!=b.length)return!1;for(let c=0;c<a.length;c++)if(!a[c].type.eq(b[c].type))return!1;return!0}function cU(a){let b=a.nextSibling;return a.parentNode.removeChild(a),b}class cV{constructor(a,b,c){this.lock=b,this.view=c,this.index=0,this.stack=[],this.changed=!1,this.top=a,this.preMatch=function(a,b){let c=b,d=c.children.length,e=a.childCount,f=new Map,g=[];c:for(;e>0;){let h;for(;;)if(d){let a=c.children[d-1];if(a instanceof cI)c=a,d=a.children.length;else{h=a,d--;break}}else if(c==b)break c;else d=c.parent.children.indexOf(c),c=c.parent;let i=h.node;if(i){if(i!=a.child(e-1))break;--e,f.set(h,e),g.push(h)}}return{index:e,matched:f,matches:g.reverse()}}(a.node.content,a)}destroyBetween(a,b){if(a!=b){for(let c=a;c<b;c++)this.top.children[c].destroy();this.top.children.splice(a,b-a),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(a,b,c,d){let e=0,f=this.stack.length>>1,g=Math.min(f,a.length);for(;e<g&&(e==f-1?this.top:this.stack[e+1<<1]).matchesMark(a[e])&&!1!==a[e].type.spec.spanning;)e++;for(;e<f;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),f--;for(;f<a.length;){this.stack.push(this.top,this.index+1);let e=-1,g=this.top.children.length;d<this.preMatch.index&&(g=Math.min(this.index+3,g));for(let b=this.index;b<g;b++){let c=this.top.children[b];if(c.matchesMark(a[f])&&!this.isLocked(c.dom)){e=b;break}}if(e>-1)e>this.index&&(this.changed=!0,this.destroyBetween(this.index,e)),this.top=this.top.children[this.index];else{let d=cI.create(this.top,a[f],b,c);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,f++}}findNodeMatch(a,b,c,d){let e=-1,f;if(d>=this.preMatch.index&&(f=this.preMatch.matches[d-this.preMatch.index]).parent==this.top&&f.matchesNode(a,b,c))e=this.top.children.indexOf(f,this.index);else for(let d=this.index,f=Math.min(this.top.children.length,d+5);d<f;d++){let f=this.top.children[d];if(f.matchesNode(a,b,c)&&!this.preMatch.matched.has(f)){e=d;break}}return!(e<0)&&(this.destroyBetween(this.index,e),this.index++,!0)}updateNodeAt(a,b,c,d,e){let f=this.top.children[d];return 3==f.dirty&&f.dom==f.contentDOM&&(f.dirty=2),!!f.update(a,b,c,e)&&(this.destroyBetween(this.index,d),this.index++,!0)}findIndexWithChild(a){for(;;){let b=a.parentNode;if(!b)return -1;if(b==this.top.contentDOM){let b=a.pmViewDesc;if(b){for(let a=this.index;a<this.top.children.length;a++)if(this.top.children[a]==b)return a}return -1}a=b}}updateNextNode(a,b,c,d,e,f){for(let g=this.index;g<this.top.children.length;g++){let h=this.top.children[g];if(h instanceof cJ){let i=this.preMatch.matched.get(h);if(null!=i&&i!=e)return!1;let j=h.dom,k,l=this.isLocked(j)&&!(a.isText&&h.node&&h.node.isText&&h.nodeDOM.nodeValue==a.text&&3!=h.dirty&&cT(b,h.outerDeco));if(!l&&h.update(a,b,c,d))return this.destroyBetween(this.index,g),h.dom!=j&&(this.changed=!0),this.index++,!0;if(!l&&(k=this.recreateWrapper(h,a,b,c,d,f)))return this.destroyBetween(this.index,g),this.top.children[this.index]=k,k.contentDOM&&(k.dirty=2,k.updateChildren(d,f+1),k.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(a,b,c,d,e,f){if(a.dirty||b.isAtom||!a.children.length||!a.node.content.eq(b.content)||!cT(c,a.outerDeco)||!d.eq(a.innerDeco))return null;let g=cJ.create(this.top,b,c,d,e,f);if(g.contentDOM)for(let b of(g.children=a.children,a.children=[],g.children))b.parent=g;return a.destroy(),g}addNode(a,b,c,d,e){let f=cJ.create(this.top,a,b,c,d,e);f.contentDOM&&f.updateChildren(d,e+1),this.top.children.splice(this.index++,0,f),this.changed=!0}placeWidget(a,b,c){let d=this.index<this.top.children.length?this.top.children[this.index]:null;if(d&&d.matchesWidget(a)&&(a==d.widget||!d.widget.type.toDOM.parentNode))this.index++;else{let d=new cG(this.top,a,b,c);this.top.children.splice(this.index++,0,d),this.changed=!0}}addTextblockHacks(){let a=this.top.children[this.index-1],b=this.top;for(;a instanceof cI;)a=(b=a).children[b.children.length-1];(!a||!(a instanceof cL)||/\n$/.test(a.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(a.node.text))&&((ch||cf)&&a&&"false"==a.dom.contentEditable&&this.addHackNode("IMG",b),this.addHackNode("BR",this.top))}addHackNode(a,b){if(b==this.top&&this.index<b.children.length&&b.children[this.index].matchesHack(a))this.index++;else{let c=document.createElement(a);"IMG"==a&&(c.className="ProseMirror-separator",c.alt=""),"BR"==a&&(c.className="ProseMirror-trailingBreak");let d=new cM(this.top,[],c,null);b!=this.top?b.children.push(d):b.children.splice(this.index++,0,d),this.changed=!0}}isLocked(a){return this.lock&&(a==this.lock||1==a.nodeType&&a.contains(this.lock.parentNode))}}function cW(a,b){return a.type.side-b.type.side}function cX(a,b,c,d,e){let f=[];for(let g=0,h=0;g<a.length;g++){let i=a[g],j=h,k=h+=i.size;j>=c||k<=b?f.push(i):(j<b&&f.push(i.slice(0,b-j,d)),e&&(f.push(e),e=void 0),k>c&&f.push(i.slice(c-j,i.size,d)))}return f}function cY(a,b=null){let c=a.domSelectionRange(),d=a.state.doc;if(!c.focusNode)return null;let e=a.docView.nearestDesc(c.focusNode),f=e&&0==e.size,g=a.docView.posFromDOM(c.focusNode,c.focusOffset,1);if(g<0)return null;let h=d.resolve(g),i,j;if(b3(c)){for(i=g;e&&!e.node;)e=e.parent;let a=e.node;if(e&&a.isAtom&&bf.isSelectable(a)&&e.parent&&!(a.isInline&&function(a,b,c){for(let d=0==b,e=b==b1(a);d||e;){if(a==c)return!0;let b=bV(a);if(!(a=a.parentNode))return!1;d=d&&0==b,e=e&&b==b1(a)}}(c.focusNode,c.focusOffset,e.dom))){let a=e.posBefore;j=new bf(g==a?h:d.resolve(a))}}else{if(c instanceof a.dom.ownerDocument.defaultView.Selection&&c.rangeCount>1){let b=g,e=g;for(let d=0;d<c.rangeCount;d++){let f=c.getRangeAt(d);b=Math.min(b,a.docView.posFromDOM(f.startContainer,f.startOffset,1)),e=Math.max(e,a.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(b<0)return null;[i,g]=e==a.state.selection.anchor?[e,b]:[b,e],h=d.resolve(g)}else i=a.docView.posFromDOM(c.anchorNode,c.anchorOffset,1);if(i<0)return null}let k=d.resolve(i);if(!j){let c="pointer"==b||a.state.selection.head<h.pos&&!f?1:-1;j=c5(a,k,h,c)}return j}function cZ(a){return a.editable?a.hasFocus():c7(a)&&document.activeElement&&document.activeElement.contains(a.dom)}function c$(a,b=!1){let c=a.state.selection;if(c3(a,c),cZ(a)){if(!b&&a.input.mouseDown&&a.input.mouseDown.allowDefault&&cf){let b=a.domSelectionRange(),c=a.domObserver.currentSelection;if(b.anchorNode&&c.anchorNode&&b$(b.anchorNode,b.anchorOffset,c.anchorNode,c.anchorOffset)){a.input.mouseDown.delayedSelectionSync=!0,a.domObserver.setCurSelection();return}}if(a.domObserver.disconnectSelection(),a.cursorWrapper)!function(a){let b=a.domSelection();if(!b)return;let c=a.cursorWrapper.dom,d="IMG"==c.nodeName;d?b.collapse(c.parentNode,bV(c)+1):b.collapse(c,0),!d&&!a.state.selection.visible&&cb&&cc<=11&&(c.disabled=!0,c.disabled=!1)}(a);else{var d;let e,f,g,h,{anchor:i,head:j}=c,k,l;c_&&!(c instanceof bd)&&(c.$from.parent.inlineContent||(k=c0(a,c.from)),c.empty||c.$from.parent.inlineContent||(l=c0(a,c.to))),a.docView.setSelection(i,j,a,b),c_&&(k&&c2(k),l&&c2(l)),c.visible?a.dom.classList.remove("ProseMirror-hideselection"):(a.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((e=(d=a).dom.ownerDocument).removeEventListener("selectionchange",d.input.hideSelectionGuard),g=(f=d.domSelectionRange()).anchorNode,h=f.anchorOffset,e.addEventListener("selectionchange",d.input.hideSelectionGuard=()=>{(f.anchorNode!=g||f.anchorOffset!=h)&&(e.removeEventListener("selectionchange",d.input.hideSelectionGuard),setTimeout(()=>{(!cZ(d)||d.state.selection.visible)&&d.dom.classList.remove("ProseMirror-hideselection")},20))})))}a.domObserver.setCurSelection(),a.domObserver.connectSelection()}}let c_=ch||cf&&cg<63;function c0(a,b){let{node:c,offset:d}=a.docView.domFromPos(b,0),e=d<c.childNodes.length?c.childNodes[d]:null,f=d?c.childNodes[d-1]:null;if(ch&&e&&"false"==e.contentEditable)return c1(e);if((!e||"false"==e.contentEditable)&&(!f||"false"==f.contentEditable)){if(e)return c1(e);else if(f)return c1(f)}}function c1(a){return a.contentEditable="true",ch&&a.draggable&&(a.draggable=!1,a.wasDraggable=!0),a}function c2(a){a.contentEditable="false",a.wasDraggable&&(a.draggable=!0,a.wasDraggable=null)}function c3(a,b){if(b instanceof bf){let c=a.docView.descAt(b.from);c!=a.lastSelectedViewDesc&&(c4(a),c&&c.selectNode(),a.lastSelectedViewDesc=c)}else c4(a)}function c4(a){a.lastSelectedViewDesc&&(a.lastSelectedViewDesc.parent&&a.lastSelectedViewDesc.deselectNode(),a.lastSelectedViewDesc=void 0)}function c5(a,b,c,d){return a.someProp("createSelectionBetween",d=>d(a,b,c))||bd.between(b,c,d)}function c6(a){return(!a.editable||!!a.hasFocus())&&c7(a)}function c7(a){let b=a.domSelectionRange();if(!b.anchorNode)return!1;try{return a.dom.contains(3==b.anchorNode.nodeType?b.anchorNode.parentNode:b.anchorNode)&&(a.editable||a.dom.contains(3==b.focusNode.nodeType?b.focusNode.parentNode:b.focusNode))}catch(a){return!1}}function c8(a,b){let{$anchor:c,$head:d}=a.selection,e=b>0?c.max(d):c.min(d),f=e.parent.inlineContent?e.depth?a.doc.resolve(b>0?e.after():e.before()):null:e;return f&&a9.findFrom(f,b)}function c9(a,b){return a.dispatch(a.state.tr.setSelection(b).scrollIntoView()),!0}function da(a,b,c){let d=a.state.selection;if(d instanceof bd){if(c.indexOf("s")>-1){let{$head:c}=d,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter;if(!e||e.isText||!e.isLeaf)return!1;let f=a.state.doc.resolve(c.pos+e.nodeSize*(b<0?-1:1));return c9(a,new bd(d.$anchor,f))}else if(!d.empty)return!1;else if(a.endOfTextblock(b>0?"forward":"backward")){let c=c8(a.state,b);return!!c&&c instanceof bf&&c9(a,c)}else if(!(cj&&c.indexOf("m")>-1)){let c=d.$head,e=c.textOffset?null:b<0?c.nodeBefore:c.nodeAfter,f;if(!e||e.isText)return!1;let g=b<0?c.pos-e.nodeSize:c.pos;return!!(e.isAtom||(f=a.docView.descAt(g))&&!f.contentDOM)&&(bf.isSelectable(e)?c9(a,new bf(b<0?a.state.doc.resolve(c.pos-e.nodeSize):c)):!!cm&&c9(a,new bd(a.state.doc.resolve(b<0?g:g+e.nodeSize))))}}else{if(d instanceof bf&&d.node.isInline)return c9(a,new bd(b>0?d.$to:d.$from));let c=c8(a.state,b);return!!c&&c9(a,c)}}function db(a){return 3==a.nodeType?a.nodeValue.length:a.childNodes.length}function dc(a,b){let c=a.pmViewDesc;return c&&0==c.size&&(b<0||a.nextSibling||"BR"!=a.nodeName)}function dd(a,b){return b<0?function(a){let b=a.domSelectionRange(),c=b.focusNode,d=b.focusOffset;if(!c)return;let e,f,g=!1;for(cd&&1==c.nodeType&&d<db(c)&&dc(c.childNodes[d],-1)&&(g=!0);;)if(d>0)if(1!=c.nodeType)break;else{let a=c.childNodes[d-1];if(dc(a,-1))e=c,f=--d;else if(3==a.nodeType)d=(c=a).nodeValue.length;else break}else if(de(c))break;else{let b=c.previousSibling;for(;b&&dc(b,-1);)e=c.parentNode,f=bV(b),b=b.previousSibling;if(b)d=db(c=b);else{if((c=c.parentNode)==a.dom)break;d=0}}g?df(a,c,d):e&&df(a,e,f)}(a):function(a){let b,c,d=a.domSelectionRange(),e=d.focusNode,f=d.focusOffset;if(!e)return;let g=db(e);for(;;)if(f<g){if(1!=e.nodeType)break;if(dc(e.childNodes[f],1))b=e,c=++f;else break}else if(de(e))break;else{let d=e.nextSibling;for(;d&&dc(d,1);)b=d.parentNode,c=bV(d)+1,d=d.nextSibling;if(d)f=0,g=db(e=d);else{if((e=e.parentNode)==a.dom)break;f=g=0}}b&&df(a,b,c)}(a)}function de(a){let b=a.pmViewDesc;return b&&b.node&&b.node.isBlock}function df(a,b,c){if(3!=b.nodeType){let a,d;(d=function(a,b){for(;a&&b==a.childNodes.length&&!b2(a);)b=bV(a)+1,a=a.parentNode;for(;a&&b<a.childNodes.length;){let c=a.childNodes[b];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;a=c,b=0}}(b,c))?(b=d,c=0):(a=function(a,b){for(;a&&!b&&!b2(a);)b=bV(a),a=a.parentNode;for(;a&&b;){let c=a.childNodes[b-1];if(3==c.nodeType)return c;if(1==c.nodeType&&"false"==c.contentEditable)break;b=(a=c).childNodes.length}}(b,c))&&(b=a,c=a.nodeValue.length)}let d=a.domSelection();if(!d)return;if(b3(d)){let a=document.createRange();a.setEnd(b,c),a.setStart(b,c),d.removeAllRanges(),d.addRange(a)}else d.extend&&d.extend(b,c);a.domObserver.setCurSelection();let{state:e}=a;setTimeout(()=>{a.state==e&&c$(a)},50)}function dg(a,b){let c=a.state.doc.resolve(b);if(!(cf||ck)&&c.parent.inlineContent){let d=a.coordsAtPos(b);if(b>c.start()){let c=a.coordsAtPos(b-1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left<d.left?"ltr":"rtl"}if(b<c.end()){let c=a.coordsAtPos(b+1),e=(c.top+c.bottom)/2;if(e>d.top&&e<d.bottom&&Math.abs(c.left-d.left)>1)return c.left>d.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(a.dom).direction?"rtl":"ltr"}function dh(a,b,c){let d=a.state.selection;if(d instanceof bd&&!d.empty||c.indexOf("s")>-1||cj&&c.indexOf("m")>-1)return!1;let{$from:e,$to:f}=d;if(!e.parent.inlineContent||a.endOfTextblock(b<0?"up":"down")){let c=c8(a.state,b);if(c&&c instanceof bf)return c9(a,c)}if(!e.parent.inlineContent){let c=b<0?e:f,g=d instanceof bh?a9.near(c,b):a9.findFrom(c,b);return!!g&&c9(a,g)}return!1}function di(a,b){if(!(a.state.selection instanceof bd))return!0;let{$head:c,$anchor:d,empty:e}=a.state.selection;if(!c.sameParent(d))return!0;if(!e)return!1;if(a.endOfTextblock(b>0?"forward":"backward"))return!0;let f=!c.textOffset&&(b<0?c.nodeBefore:c.nodeAfter);if(f&&!f.isText){let d=a.state.tr;return b<0?d.delete(c.pos-f.nodeSize,c.pos):d.delete(c.pos,c.pos+f.nodeSize),a.dispatch(d),!0}return!1}function dj(a,b,c){a.domObserver.stop(),b.contentEditable=c,a.domObserver.start()}function dk(a,b){a.someProp("transformCopied",c=>{b=c(b,a)});let c=[],{content:d,openStart:e,openEnd:f}=b;for(;e>1&&f>1&&1==d.childCount&&1==d.firstChild.childCount;){e--,f--;let a=d.firstChild;c.push(a.type.name,a.attrs!=a.type.defaultAttrs?a.attrs:null),d=a.content}let g=a.someProp("clipboardSerializer")||au.fromSchema(a.state.schema),h=dt(),i=h.createElement("div");i.appendChild(g.serializeFragment(d,{document:h}));let j=i.firstChild,k,l=0;for(;j&&1==j.nodeType&&(k=dr[j.nodeName.toLowerCase()]);){for(let a=k.length-1;a>=0;a--){let b=h.createElement(k[a]);for(;i.firstChild;)b.appendChild(i.firstChild);i.appendChild(b),l++}j=i.firstChild}return j&&1==j.nodeType&&j.setAttribute("data-pm-slice",`${e} ${f}${l?` -${l}`:""} ${JSON.stringify(c)}`),{dom:i,text:a.someProp("clipboardTextSerializer",c=>c(b,a))||b.content.textBetween(0,b.content.size,"\n\n"),slice:b}}function dl(a,b,c,d,e){let f,g,h=e.parent.type.spec.code;if(!c&&!b)return null;let i=!!b&&(d||h||!c);if(i){if(a.someProp("transformPastedText",c=>{b=c(b,h||d,a)}),h)return g=new J(D.from(a.state.schema.text(b.replace(/\r\n?/g,"\n"))),0,0),a.someProp("transformPasted",b=>{g=b(g,a,!0)}),g;let c=a.someProp("clipboardTextParser",c=>c(b,e,d,a));if(c)g=c;else{let c=e.marks(),{schema:d}=a.state,g=au.fromSchema(d);f=document.createElement("div"),b.split(/(?:\r\n?|\n)+/).forEach(a=>{let b=f.appendChild(document.createElement("p"));a&&b.appendChild(g.serializeNode(d.text(a,c)))})}}else a.someProp("transformPastedHTML",b=>{c=b(c,a)}),f=function(a){var b;let c,d=/^(\s*<meta [^>]*>)*/.exec(a);d&&(a=a.slice(d[0].length));let e=dt().createElement("div"),f=/<([a-z][^>\s]+)/i.exec(a),g;if((g=f&&dr[f[1].toLowerCase()])&&(a=g.map(a=>"<"+a+">").join("")+a+g.map(a=>"</"+a+">").reverse().join("")),e.innerHTML=(b=a,(c=window.trustedTypes)?(du||(du=c.defaultPolicy||c.createPolicy("ProseMirrorClipboard",{createHTML:a=>a})),du.createHTML(b)):b),g)for(let a=0;a<g.length;a++)e=e.querySelector(g[a])||e;return e}(c),cm&&function(a){let b=a.querySelectorAll(cf?"span:not([class]):not([style])":"span.Apple-converted-space");for(let c=0;c<b.length;c++){let d=b[c];1==d.childNodes.length&&"\xa0"==d.textContent&&d.parentNode&&d.parentNode.replaceChild(a.ownerDocument.createTextNode(" "),d)}}(f);let j=f&&f.querySelector("[data-pm-slice]"),k=j&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(j.getAttribute("data-pm-slice")||"");if(k&&k[3])for(let a=+k[3];a>0;a--){let a=f.firstChild;for(;a&&1!=a.nodeType;)a=a.nextSibling;if(!a)break;f=a}if(g||(g=(a.someProp("clipboardParser")||a.someProp("domParser")||al.fromSchema(a.state.schema)).parseSlice(f,{preserveWhitespace:!!(i||k),context:e,ruleFromNode:a=>"BR"!=a.nodeName||a.nextSibling||!a.parentNode||dm.test(a.parentNode.nodeName)?null:{ignore:!0}})),k)g=function(a,b){if(!a.size)return a;let c=a.content.firstChild.type.schema,d;try{d=JSON.parse(b)}catch(b){return a}let{content:e,openStart:f,openEnd:g}=a;for(let a=d.length-2;a>=0;a-=2){let b=c.nodes[d[a]];if(!b||b.hasRequiredAttrs())break;e=D.from(b.create(d[a+1],e)),f++,g++}return new J(e,f,g)}(dq(g,+k[1],+k[2]),k[4]);else if((g=J.maxOpen(function(a,b){if(a.childCount<2)return a;for(let c=b.depth;c>=0;c--){let d=b.node(c).contentMatchAt(b.index(c)),e,f=[];if(a.forEach(a=>{if(!f)return;let b=d.findWrapping(a.type),c;if(!b)return f=null;if(c=f.length&&e.length&&function a(b,c,d,e,f){if(f<b.length&&f<c.length&&b[f]==c[f]){let g=a(b,c,d,e.lastChild,f+1);if(g)return e.copy(e.content.replaceChild(e.childCount-1,g));if(e.contentMatchAt(e.childCount).matchType(f==b.length-1?d.type:b[f+1]))return e.copy(e.content.append(D.from(dn(d,b,f+1))))}}(b,e,a,f[f.length-1],0))f[f.length-1]=c;else{f.length&&(f[f.length-1]=function a(b,c){if(0==c)return b;let d=b.content.replaceChild(b.childCount-1,a(b.lastChild,c-1)),e=b.contentMatchAt(b.childCount).fillBefore(D.empty,!0);return b.copy(d.append(e))}(f[f.length-1],e.length));let c=dn(a,b);f.push(c),d=d.matchType(c.type),e=b}}),f)return D.from(f)}return a}(g.content,e),!0)).openStart||g.openEnd){let a=0,b=0;for(let b=g.content.firstChild;a<g.openStart&&!b.type.spec.isolating;a++,b=b.firstChild);for(let a=g.content.lastChild;b<g.openEnd&&!a.type.spec.isolating;b++,a=a.lastChild);g=dq(g,a,b)}return a.someProp("transformPasted",b=>{g=b(g,a,i)}),g}let dm=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function dn(a,b,c=0){for(let d=b.length-1;d>=c;d--)a=b[d].create(null,D.from(a));return a}function dp(a,b,c,d,e,f){let g=b<0?a.firstChild:a.lastChild,h=g.content;return a.childCount>1&&(f=0),e<d-1&&(h=dp(h,b,c,d,e+1,f)),e>=c&&(h=b<0?g.contentMatchAt(0).fillBefore(h,f<=e).append(h):h.append(g.contentMatchAt(g.childCount).fillBefore(D.empty,!0))),a.replaceChild(b<0?0:a.childCount-1,g.copy(h))}function dq(a,b,c){return b<a.openStart&&(a=new J(dp(a.content,-1,b,a.openStart,0,a.openEnd),b,a.openEnd)),c<a.openEnd&&(a=new J(dp(a.content,1,c,a.openEnd,0,0),a.openStart,c)),a}let dr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},ds=null;function dt(){return ds||(ds=document.implementation.createHTMLDocument("title"))}let du=null,dv={},dw={},dx={touchstart:!0,touchmove:!0};class dy{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function dz(a,b){a.input.lastSelectionOrigin=b,a.input.lastSelectionTime=Date.now()}function dA(a){a.someProp("handleDOMEvents",b=>{for(let c in b)a.input.eventHandlers[c]||a.dom.addEventListener(c,a.input.eventHandlers[c]=b=>dB(a,b))})}function dB(a,b){return a.someProp("handleDOMEvents",c=>{let d=c[b.type];return!!d&&(d(a,b)||b.defaultPrevented)})}function dC(a){return{left:a.clientX,top:a.clientY}}function dD(a,b,c,d,e){if(-1==d)return!1;let f=a.state.doc.resolve(d);for(let d=f.depth+1;d>0;d--)if(a.someProp(b,b=>d>f.depth?b(a,c,f.nodeAfter,f.before(d),e,!0):b(a,c,f.node(d),f.before(d),e,!1)))return!0;return!1}function dE(a,b,c){if(a.focused||a.focus(),a.state.selection.eq(b))return;let d=a.state.tr.setSelection(b);"pointer"==c&&d.setMeta("pointer",!0),a.dispatch(d)}dw.keydown=(a,b)=>{if((a.input.shiftKey=16==b.keyCode||b.shiftKey,!dH(a,b))&&(a.input.lastKeyCode=b.keyCode,a.input.lastKeyCodeTime=Date.now(),!cl||!cf||13!=b.keyCode))if(229!=b.keyCode&&a.domObserver.forceFlush(),!ci||13!=b.keyCode||b.ctrlKey||b.altKey||b.metaKey)a.someProp("handleKeyDown",c=>c(a,b))||function(a,b){let c,d=b.keyCode,e=(c="",b.ctrlKey&&(c+="c"),b.metaKey&&(c+="m"),b.altKey&&(c+="a"),b.shiftKey&&(c+="s"),c);if(8==d||cj&&72==d&&"c"==e)return di(a,-1)||dd(a,-1);if(46==d&&!b.shiftKey||cj&&68==d&&"c"==e)return di(a,1)||dd(a,1);if(13==d||27==d)return!0;if(37==d||cj&&66==d&&"c"==e){let b=37==d?"ltr"==dg(a,a.state.selection.from)?-1:1:-1;return da(a,b,e)||dd(a,b)}if(39==d||cj&&70==d&&"c"==e){let b=39==d?"ltr"==dg(a,a.state.selection.from)?1:-1:1;return da(a,b,e)||dd(a,b)}else if(38==d||cj&&80==d&&"c"==e)return dh(a,-1,e)||dd(a,-1);else if(40==d||cj&&78==d&&"c"==e)return function(a){if(!ch||a.state.selection.$head.parentOffset>0)return!1;let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(b&&1==b.nodeType&&0==c&&b.firstChild&&"false"==b.firstChild.contentEditable){let c=b.firstChild;dj(a,c,"true"),setTimeout(()=>dj(a,c,"false"),20)}return!1}(a)||dh(a,1,e)||dd(a,1);else if(e==(cj?"m":"c")&&(66==d||73==d||89==d||90==d))return!0;return!1}(a,b)?b.preventDefault():dz(a,"key");else{let b=Date.now();a.input.lastIOSEnter=b,a.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{a.input.lastIOSEnter==b&&(a.someProp("handleKeyDown",b=>b(a,b4(13,"Enter"))),a.input.lastIOSEnter=0)},200)}},dw.keyup=(a,b)=>{16==b.keyCode&&(a.input.shiftKey=!1)},dw.keypress=(a,b)=>{if(dH(a,b)||!b.charCode||b.ctrlKey&&!b.altKey||cj&&b.metaKey)return;if(a.someProp("handleKeyPress",c=>c(a,b)))return void b.preventDefault();let c=a.state.selection;if(!(c instanceof bd)||!c.$from.sameParent(c.$to)){let d=String.fromCharCode(b.charCode),e=()=>a.state.tr.insertText(d).scrollIntoView();/[\r\n]/.test(d)||a.someProp("handleTextInput",b=>b(a,c.$from.pos,c.$to.pos,d,e))||a.dispatch(e()),b.preventDefault()}};let dF=cj?"metaKey":"ctrlKey";dv.mousedown=(a,b)=>{var c;let d,e;a.input.shiftKey=b.shiftKey;let f=dL(a),g=Date.now(),h="singleClick";g-a.input.lastClick.time<500&&(d=(c=a.input.lastClick).x-b.clientX)*d+(e=c.y-b.clientY)*e<100&&!b[dF]&&a.input.lastClick.button==b.button&&("singleClick"==a.input.lastClick.type?h="doubleClick":"doubleClick"==a.input.lastClick.type&&(h="tripleClick")),a.input.lastClick={time:g,x:b.clientX,y:b.clientY,type:h,button:b.button};let i=a.posAtCoords(dC(b));i&&("singleClick"==h?(a.input.mouseDown&&a.input.mouseDown.done(),a.input.mouseDown=new dG(a,i,b,!!f)):("doubleClick"==h?function(a,b,c,d){return dD(a,"handleDoubleClickOn",b,c,d)||a.someProp("handleDoubleClick",c=>c(a,b,d))}:function(a,b,c,d){return dD(a,"handleTripleClickOn",b,c,d)||a.someProp("handleTripleClick",c=>c(a,b,d))||function(a,b,c){if(0!=c.button)return!1;let d=a.state.doc;if(-1==b)return!!d.inlineContent&&(dE(a,bd.create(d,0,d.content.size),"pointer"),!0);let e=d.resolve(b);for(let b=e.depth+1;b>0;b--){let c=b>e.depth?e.nodeAfter:e.node(b),f=e.before(b);if(c.inlineContent)dE(a,bd.create(d,f+1,f+1+c.content.size),"pointer");else{if(!bf.isSelectable(c))continue;dE(a,bf.create(d,f),"pointer")}return!0}}(a,c,d)})(a,i.pos,i.inside,b)?b.preventDefault():dz(a,"pointer"))};class dG{constructor(a,b,c,d){let e,f;if(this.view=a,this.pos=b,this.event=c,this.flushed=d,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=a.state.doc,this.selectNode=!!c[dF],this.allowDefault=c.shiftKey,b.inside>-1)e=a.state.doc.nodeAt(b.inside),f=b.inside;else{let c=a.state.doc.resolve(b.pos);e=c.parent,f=c.depth?c.before():0}const g=d?null:c.target,h=g?a.docView.nearestDesc(g,!0):null;this.target=h&&1==h.nodeDOM.nodeType?h.nodeDOM:null;let{selection:i}=a.state;(0==c.button&&e.type.spec.draggable&&!1!==e.type.spec.selectable||i instanceof bf&&i.from<=f&&i.to>f)&&(this.mightDrag={node:e,pos:f,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&cd&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),a.root.addEventListener("mouseup",this.up=this.up.bind(this)),a.root.addEventListener("mousemove",this.move=this.move.bind(this)),dz(a,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>c$(this.view)),this.view.input.mouseDown=null}up(a){if(this.done(),!this.view.dom.contains(a.target))return;let b=this.pos;if(this.view.state.doc!=this.startDoc&&(b=this.view.posAtCoords(dC(a))),this.updateAllowDefault(a),this.allowDefault||!b)dz(this.view,"pointer");else{var c,d,e,f;(c=this.view,d=b.pos,e=b.inside,f=this.selectNode,dD(c,"handleClickOn",d,e,a)||c.someProp("handleClick",b=>b(c,d,a))||(f?function(a,b){if(-1==b)return!1;let c=a.state.selection,d,e;c instanceof bf&&(d=c.node);let f=a.state.doc.resolve(b);for(let a=f.depth+1;a>0;a--){let b=a>f.depth?f.nodeAfter:f.node(a);if(bf.isSelectable(b)){e=d&&c.$from.depth>0&&a>=c.$from.depth&&f.before(c.$from.depth+1)==c.$from.pos?f.before(c.$from.depth):f.before(a);break}}return null!=e&&(dE(a,bf.create(a.state.doc,e),"pointer"),!0)}(c,e):function(a,b){if(-1==b)return!1;let c=a.state.doc.resolve(b),d=c.nodeAfter;return!!(d&&d.isAtom&&bf.isSelectable(d))&&(dE(a,new bf(c),"pointer"),!0)}(c,e)))?a.preventDefault():0==a.button&&(this.flushed||ch&&this.mightDrag&&!this.mightDrag.node.isAtom||cf&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(b.pos-this.view.state.selection.from),Math.abs(b.pos-this.view.state.selection.to)))?(dE(this.view,a9.near(this.view.state.doc.resolve(b.pos)),"pointer"),a.preventDefault()):dz(this.view,"pointer")}}move(a){this.updateAllowDefault(a),dz(this.view,"pointer"),0==a.buttons&&this.done()}updateAllowDefault(a){!this.allowDefault&&(Math.abs(this.event.x-a.clientX)>4||Math.abs(this.event.y-a.clientY)>4)&&(this.allowDefault=!0)}}function dH(a,b){return!!a.composing||!!(ch&&500>Math.abs(b.timeStamp-a.input.compositionEndedAt))&&(a.input.compositionEndedAt=-2e8,!0)}dv.touchstart=a=>{a.input.lastTouch=Date.now(),dL(a),dz(a,"pointer")},dv.touchmove=a=>{a.input.lastTouch=Date.now(),dz(a,"pointer")},dv.contextmenu=a=>dL(a);let dI=cl?5e3:-1;function dJ(a,b){clearTimeout(a.input.composingTimeout),b>-1&&(a.input.composingTimeout=setTimeout(()=>dL(a),b))}function dK(a){let b;for(a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=((b=document.createEvent("Event")).initEvent("event",!0,!0),b.timeStamp));a.input.compositionNodes.length>0;)a.input.compositionNodes.pop().markParentsDirty()}function dL(a,b=!1){if(!cl||!(a.domObserver.flushingSoon>=0)){if(a.domObserver.forceFlush(),dK(a),b||a.docView&&a.docView.dirty){let c=cY(a),d=a.state.selection;return c&&!c.eq(d)?a.dispatch(a.state.tr.setSelection(c)):(a.markCursor||b)&&!d.$from.node(d.$from.sharedDepth(d.to)).inlineContent?a.dispatch(a.state.tr.deleteSelection()):a.updateState(a.state),!0}return!1}}dw.compositionstart=dw.compositionupdate=a=>{if(!a.composing){a.domObserver.flush();let{state:b}=a,c=b.selection.$to;if(b.selection instanceof bd&&(b.storedMarks||!c.textOffset&&c.parentOffset&&c.nodeBefore.marks.some(a=>!1===a.type.spec.inclusive)||cf&&ck&&function(a){let{focusNode:b,focusOffset:c}=a.domSelectionRange();if(!b||1!=b.nodeType||c>=b.childNodes.length)return!1;let d=b.childNodes[c];return 1==d.nodeType&&"false"==d.contentEditable}(a)))a.markCursor=a.state.storedMarks||c.marks(),dL(a,!0),a.markCursor=null;else if(dL(a,!b.selection.empty),cd&&b.selection.empty&&c.parentOffset&&!c.textOffset&&c.nodeBefore.marks.length){let b=a.domSelectionRange();for(let c=b.focusNode,d=b.focusOffset;c&&1==c.nodeType&&0!=d;){let b=d<0?c.lastChild:c.childNodes[d-1];if(!b)break;if(3==b.nodeType){let c=a.domSelection();c&&c.collapse(b,b.nodeValue.length);break}c=b,d=-1}}a.input.composing=!0}dJ(a,dI)},dw.compositionend=(a,b)=>{a.composing&&(a.input.composing=!1,a.input.compositionEndedAt=b.timeStamp,a.input.compositionPendingChanges=a.domObserver.pendingRecords().length?a.input.compositionID:0,a.input.compositionNode=null,a.input.badSafariComposition?a.domObserver.forceFlush():a.input.compositionPendingChanges&&Promise.resolve().then(()=>a.domObserver.flush()),a.input.compositionID++,dJ(a,20))};let dM=cb&&cc<15||ci&&cn<604;function dN(a,b,c,d,e){let f=dl(a,b,c,d,a.state.selection.$from);if(a.someProp("handlePaste",b=>b(a,e,f||J.empty)))return!0;if(!f)return!1;let g=0==f.openStart&&0==f.openEnd&&1==f.content.childCount?f.content.firstChild:null,h=g?a.state.tr.replaceSelectionWith(g,d):a.state.tr.replaceSelection(f);return a.dispatch(h.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function dO(a){let b=a.getData("text/plain")||a.getData("Text");if(b)return b;let c=a.getData("text/uri-list");return c?c.replace(/\r?\n/g," "):""}dv.copy=dw.cut=(a,b)=>{let c=a.state.selection,d="cut"==b.type;if(c.empty)return;let e=dM?null:b.clipboardData,{dom:f,text:g}=dk(a,c.content());e?(b.preventDefault(),e.clearData(),e.setData("text/html",f.innerHTML),e.setData("text/plain",g)):function(a,b){if(!a.dom.parentNode)return;let c=a.dom.parentNode.appendChild(document.createElement("div"));c.appendChild(b),c.style.cssText="position: fixed; left: -10000px; top: 10px";let d=getSelection(),e=document.createRange();e.selectNodeContents(b),a.dom.blur(),d.removeAllRanges(),d.addRange(e),setTimeout(()=>{c.parentNode&&c.parentNode.removeChild(c),a.focus()},50)}(a,f),d&&a.dispatch(a.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},dw.paste=(a,b)=>{if(a.composing&&!cl)return;let c=dM?null:b.clipboardData,d=a.input.shiftKey&&45!=a.input.lastKeyCode;c&&dN(a,dO(c),c.getData("text/html"),d,b)?b.preventDefault():function(a,b){if(!a.dom.parentNode)return;let c=a.input.shiftKey||a.state.selection.$from.parent.type.spec.code,d=a.dom.parentNode.appendChild(document.createElement(c?"textarea":"div"));c||(d.contentEditable="true"),d.style.cssText="position: fixed; left: -10000px; top: 10px",d.focus();let e=a.input.shiftKey&&45!=a.input.lastKeyCode;setTimeout(()=>{a.focus(),d.parentNode&&d.parentNode.removeChild(d),c?dN(a,d.value,null,e,b):dN(a,d.textContent,d.innerHTML,e,b)},50)}(a,b)};class dP{constructor(a,b,c){this.slice=a,this.move=b,this.node=c}}let dQ=cj?"altKey":"ctrlKey";function dR(a,b){let c=a.someProp("dragCopies",a=>!a(b));return null!=c?c:!b[dQ]}for(let a in dv.dragstart=(a,b)=>{let c,d=a.input.mouseDown;if(d&&d.done(),!b.dataTransfer)return;let e=a.state.selection,f=e.empty?null:a.posAtCoords(dC(b));if(f&&f.pos>=e.from&&f.pos<=(e instanceof bf?e.to-1:e.to));else if(d&&d.mightDrag)c=bf.create(a.state.doc,d.mightDrag.pos);else if(b.target&&1==b.target.nodeType){let d=a.docView.nearestDesc(b.target,!0);d&&d.node.type.spec.draggable&&d!=a.docView&&(c=bf.create(a.state.doc,d.posBefore))}let g=(c||a.state.selection).content(),{dom:h,text:i,slice:j}=dk(a,g);b.dataTransfer.files.length&&cf&&!(cg>120)||b.dataTransfer.clearData(),b.dataTransfer.setData(dM?"Text":"text/html",h.innerHTML),b.dataTransfer.effectAllowed="copyMove",dM||b.dataTransfer.setData("text/plain",i),a.dragging=new dP(j,dR(a,b),c)},dv.dragend=a=>{let b=a.dragging;window.setTimeout(()=>{a.dragging==b&&(a.dragging=null)},50)},dw.dragover=dw.dragenter=(a,b)=>b.preventDefault(),dw.drop=(a,b)=>{try{!function(a,b,c){if(!b.dataTransfer)return;let d=a.posAtCoords(dC(b));if(!d)return;let e=a.state.doc.resolve(d.pos),f=c&&c.slice;f?a.someProp("transformPasted",b=>{f=b(f,a,!1)}):f=dl(a,dO(b.dataTransfer),dM?null:b.dataTransfer.getData("text/html"),!1,e);let g=!!(c&&dR(a,b));if(a.someProp("handleDrop",c=>c(a,b,f||J.empty,g)))return b.preventDefault();if(!f)return;b.preventDefault();let h=f?aX(a.state.doc,e.pos,f):e.pos;null==h&&(h=e.pos);let i=a.state.tr;if(g){let{node:a}=c;a?a.replace(i):i.deleteSelection()}let j=i.mapping.map(h),k=0==f.openStart&&0==f.openEnd&&1==f.content.childCount,l=i.doc;if(k?i.replaceRangeWith(j,j,f.content.firstChild):i.replaceRange(j,j,f),i.doc.eq(l))return;let m=i.doc.resolve(j);if(k&&bf.isSelectable(f.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(f.content.firstChild))i.setSelection(new bf(m));else{let b=i.mapping.map(h);i.mapping.maps[i.mapping.maps.length-1].forEach((a,c,d,e)=>b=e),i.setSelection(c5(a,m,i.doc.resolve(b)))}a.focus(),a.dispatch(i.setMeta("uiEvent","drop"))}(a,b,a.dragging)}finally{a.dragging=null}},dv.focus=a=>{a.input.lastFocus=Date.now(),a.focused||(a.domObserver.stop(),a.dom.classList.add("ProseMirror-focused"),a.domObserver.start(),a.focused=!0,setTimeout(()=>{a.docView&&a.hasFocus()&&!a.domObserver.currentSelection.eq(a.domSelectionRange())&&c$(a)},20))},dv.blur=(a,b)=>{a.focused&&(a.domObserver.stop(),a.dom.classList.remove("ProseMirror-focused"),a.domObserver.start(),b.relatedTarget&&a.dom.contains(b.relatedTarget)&&a.domObserver.currentSelection.clear(),a.focused=!1)},dv.beforeinput=(a,b)=>{if(cf&&cl&&"deleteContentBackward"==b.inputType){a.domObserver.flushSoon();let{domChangeCount:b}=a.input;setTimeout(()=>{if(a.input.domChangeCount!=b||(a.dom.blur(),a.focus(),a.someProp("handleKeyDown",b=>b(a,b4(8,"Backspace")))))return;let{$cursor:c}=a.state.selection;c&&c.pos>0&&a.dispatch(a.state.tr.delete(c.pos-1,c.pos).scrollIntoView())},50)}},dw)dv[a]=dw[a];function dS(a,b){if(a==b)return!0;for(let c in a)if(a[c]!==b[c])return!1;for(let c in b)if(!(c in a))return!1;return!0}class dT{constructor(a,b){this.toDOM=a,this.spec=b||dY,this.side=this.spec.side||0}map(a,b,c,d){let{pos:e,deleted:f}=a.mapResult(b.from+d,this.side<0?-1:1);return f?null:new dW(e-c,e-c,this)}valid(){return!0}eq(a){return this==a||a instanceof dT&&(this.spec.key&&this.spec.key==a.spec.key||this.toDOM==a.toDOM&&dS(this.spec,a.spec))}destroy(a){this.spec.destroy&&this.spec.destroy(a)}}class dU{constructor(a,b){this.attrs=a,this.spec=b||dY}map(a,b,c,d){let e=a.map(b.from+d,this.spec.inclusiveStart?-1:1)-c,f=a.map(b.to+d,this.spec.inclusiveEnd?1:-1)-c;return e>=f?null:new dW(e,f,this)}valid(a,b){return b.from<b.to}eq(a){return this==a||a instanceof dU&&dS(this.attrs,a.attrs)&&dS(this.spec,a.spec)}static is(a){return a.type instanceof dU}destroy(){}}class dV{constructor(a,b){this.attrs=a,this.spec=b||dY}map(a,b,c,d){let e=a.mapResult(b.from+d,1);if(e.deleted)return null;let f=a.mapResult(b.to+d,-1);return f.deleted||f.pos<=e.pos?null:new dW(e.pos-c,f.pos-c,this)}valid(a,b){let{index:c,offset:d}=a.content.findIndex(b.from),e;return d==b.from&&!(e=a.child(c)).isText&&d+e.nodeSize==b.to}eq(a){return this==a||a instanceof dV&&dS(this.attrs,a.attrs)&&dS(this.spec,a.spec)}destroy(){}}class dW{constructor(a,b,c){this.from=a,this.to=b,this.type=c}copy(a,b){return new dW(a,b,this.type)}eq(a,b=0){return this.type.eq(a.type)&&this.from+b==a.from&&this.to+b==a.to}map(a,b,c){return this.type.map(a,this,b,c)}static widget(a,b,c){return new dW(a,a,new dT(b,c))}static inline(a,b,c,d){return new dW(a,b,new dU(c,d))}static node(a,b,c,d){return new dW(a,b,new dV(c,d))}get spec(){return this.type.spec}get inline(){return this.type instanceof dU}get widget(){return this.type instanceof dT}}let dX=[],dY={};class dZ{constructor(a,b){this.local=a.length?a:dX,this.children=b.length?b:dX}static create(a,b){return b.length?d3(b,a,0,dY):d$}find(a,b,c){let d=[];return this.findInner(null==a?0:a,null==b?1e9:b,d,0,c),d}findInner(a,b,c,d,e){for(let f=0;f<this.local.length;f++){let g=this.local[f];g.from<=b&&g.to>=a&&(!e||e(g.spec))&&c.push(g.copy(g.from+d,g.to+d))}for(let f=0;f<this.children.length;f+=3)if(this.children[f]<b&&this.children[f+1]>a){let g=this.children[f]+1;this.children[f+2].findInner(a-g,b-g,c,d+g,e)}}map(a,b,c){return this==d$||0==a.maps.length?this:this.mapInner(a,b,0,0,c||dY)}mapInner(a,b,c,d,e){let f;for(let g=0;g<this.local.length;g++){let h=this.local[g].map(a,c,d);h&&h.type.valid(b,h)?(f||(f=[])).push(h):e.onRemove&&e.onRemove(this.local[g].spec)}return this.children.length?function(a,b,c,d,e,f,g){let h=a.slice();for(let a=0,b=f;a<c.maps.length;a++){let d=0;c.maps[a].forEach((a,c,e,f)=>{let g=f-e-(c-a);for(let e=0;e<h.length;e+=3){let f=h[e+1];if(f<0||a>f+b-d)continue;let i=h[e]+b-d;c>=i?h[e+1]=a<=i?-2:-1:a>=b&&g&&(h[e]+=g,h[e+1]+=g)}d+=g}),b=c.maps[a].map(b,-1)}let i=!1;for(let b=0;b<h.length;b+=3)if(h[b+1]<0){if(-2==h[b+1]){i=!0,h[b+1]=-1;continue}let j=c.map(a[b]+f),k=j-e;if(k<0||k>=d.content.size){i=!0;continue}let l=c.map(a[b+1]+f,-1)-e,{index:m,offset:n}=d.content.findIndex(k),o=d.maybeChild(m);if(o&&n==k&&n+o.nodeSize==l){let d=h[b+2].mapInner(c,o,j+1,a[b]+f+1,g);d!=d$?(h[b]=k,h[b+1]=l,h[b+2]=d):(h[b+1]=-2,i=!0)}else i=!0}if(i){let i=d3(function(a,b,c,d,e,f,g){for(let h=0;h<a.length;h+=3)-1==a[h+1]&&function a(b,f){for(let a=0;a<b.local.length;a++){let h=b.local[a].map(d,e,f);h?c.push(h):g.onRemove&&g.onRemove(b.local[a].spec)}for(let c=0;c<b.children.length;c+=3)a(b.children[c+2],b.children[c]+f+1)}(a[h+2],b[h]+f+1);return c}(h,a,b,c,e,f,g),d,0,g);b=i.local;for(let a=0;a<h.length;a+=3)h[a+1]<0&&(h.splice(a,3),a-=3);for(let a=0,b=0;a<i.children.length;a+=3){let c=i.children[a];for(;b<h.length&&h[b]<c;)b+=3;h.splice(b,0,i.children[a],i.children[a+1],i.children[a+2])}}return new dZ(b.sort(d4),h)}(this.children,f||[],a,b,c,d,e):f?new dZ(f.sort(d4),dX):d$}add(a,b){return b.length?this==d$?dZ.create(a,b):this.addInner(a,b,0):this}addInner(a,b,c){let d,e=0;a.forEach((a,f)=>{let g=f+c,h;if(h=d1(b,a,g)){for(d||(d=this.children.slice());e<d.length&&d[e]<f;)e+=3;d[e]==f?d[e+2]=d[e+2].addInner(a,h,g+1):d.splice(e,0,f,f+a.nodeSize,d3(h,a,g+1,dY)),e+=3}});let f=d0(e?d2(b):b,-c);for(let b=0;b<f.length;b++)f[b].type.valid(a,f[b])||f.splice(b--,1);return new dZ(f.length?this.local.concat(f).sort(d4):this.local,d||this.children)}remove(a){return 0==a.length||this==d$?this:this.removeInner(a,0)}removeInner(a,b){let c=this.children,d=this.local;for(let d=0;d<c.length;d+=3){let e,f=c[d]+b,g=c[d+1]+b;for(let b=0,c;b<a.length;b++)(c=a[b])&&c.from>f&&c.to<g&&(a[b]=null,(e||(e=[])).push(c));if(!e)continue;c==this.children&&(c=this.children.slice());let h=c[d+2].removeInner(e,f+1);h!=d$?c[d+2]=h:(c.splice(d,3),d-=3)}if(d.length){for(let c=0,e;c<a.length;c++)if(e=a[c])for(let a=0;a<d.length;a++)d[a].eq(e,b)&&(d==this.local&&(d=this.local.slice()),d.splice(a--,1))}return c==this.children&&d==this.local?this:d.length||c.length?new dZ(d,c):d$}forChild(a,b){let c,d;if(this==d$)return this;if(b.isLeaf)return dZ.empty;for(let b=0;b<this.children.length;b+=3)if(this.children[b]>=a){this.children[b]==a&&(c=this.children[b+2]);break}let e=a+1,f=e+b.content.size;for(let a=0;a<this.local.length;a++){let b=this.local[a];if(b.from<f&&b.to>e&&b.type instanceof dU){let a=Math.max(e,b.from)-e,c=Math.min(f,b.to)-e;a<c&&(d||(d=[])).push(b.copy(a,c))}}if(d){let a=new dZ(d.sort(d4),dX);return c?new d_([a,c]):a}return c||d$}eq(a){if(this==a)return!0;if(!(a instanceof dZ)||this.local.length!=a.local.length||this.children.length!=a.children.length)return!1;for(let b=0;b<this.local.length;b++)if(!this.local[b].eq(a.local[b]))return!1;for(let b=0;b<this.children.length;b+=3)if(this.children[b]!=a.children[b]||this.children[b+1]!=a.children[b+1]||!this.children[b+2].eq(a.children[b+2]))return!1;return!0}locals(a){return d5(this.localsInner(a))}localsInner(a){if(this==d$)return dX;if(a.inlineContent||!this.local.some(dU.is))return this.local;let b=[];for(let a=0;a<this.local.length;a++)this.local[a].type instanceof dU||b.push(this.local[a]);return b}forEachSet(a){a(this)}}dZ.empty=new dZ([],[]),dZ.removeOverlap=d5;let d$=dZ.empty;class d_{constructor(a){this.members=a}map(a,b){let c=this.members.map(c=>c.map(a,b,dY));return d_.from(c)}forChild(a,b){if(b.isLeaf)return dZ.empty;let c=[];for(let d=0;d<this.members.length;d++){let e=this.members[d].forChild(a,b);e!=d$&&(e instanceof d_?c=c.concat(e.members):c.push(e))}return d_.from(c)}eq(a){if(!(a instanceof d_)||a.members.length!=this.members.length)return!1;for(let b=0;b<this.members.length;b++)if(!this.members[b].eq(a.members[b]))return!1;return!0}locals(a){let b,c=!0;for(let d=0;d<this.members.length;d++){let e=this.members[d].localsInner(a);if(e.length)if(b){c&&(b=b.slice(),c=!1);for(let a=0;a<e.length;a++)b.push(e[a])}else b=e}return b?d5(c?b:b.sort(d4)):dX}static from(a){switch(a.length){case 0:return d$;case 1:return a[0];default:return new d_(a.every(a=>a instanceof dZ)?a:a.reduce((a,b)=>a.concat(b instanceof dZ?b:b.members),[]))}}forEachSet(a){for(let b=0;b<this.members.length;b++)this.members[b].forEachSet(a)}}function d0(a,b){if(!b||!a.length)return a;let c=[];for(let d=0;d<a.length;d++){let e=a[d];c.push(new dW(e.from+b,e.to+b,e.type))}return c}function d1(a,b,c){if(b.isLeaf)return null;let d=c+b.nodeSize,e=null;for(let b=0,f;b<a.length;b++)(f=a[b])&&f.from>c&&f.to<d&&((e||(e=[])).push(f),a[b]=null);return e}function d2(a){let b=[];for(let c=0;c<a.length;c++)null!=a[c]&&b.push(a[c]);return b}function d3(a,b,c,d){let e=[],f=!1;b.forEach((b,g)=>{let h=d1(a,b,g+c);if(h){f=!0;let a=d3(h,b,c+g+1,d);a!=d$&&e.push(g,g+b.nodeSize,a)}});let g=d0(f?d2(a):a,-c).sort(d4);for(let a=0;a<g.length;a++)g[a].type.valid(b,g[a])||(d.onRemove&&d.onRemove(g[a].spec),g.splice(a--,1));return g.length||e.length?new dZ(g,e):d$}function d4(a,b){return a.from-b.from||a.to-b.to}function d5(a){let b=a;for(let c=0;c<b.length-1;c++){let d=b[c];if(d.from!=d.to)for(let e=c+1;e<b.length;e++){let f=b[e];if(f.from==d.from){f.to!=d.to&&(b==a&&(b=a.slice()),b[e]=f.copy(f.from,d.to),d6(b,e+1,f.copy(d.to,f.to)));continue}f.from<d.to&&(b==a&&(b=a.slice()),b[c]=d.copy(d.from,f.from),d6(b,e,d.copy(f.from,d.to)));break}}return b}function d6(a,b,c){for(;b<a.length&&d4(c,a[b])>0;)b++;a.splice(b,0,c)}function d7(a){let b=[];return a.someProp("decorations",c=>{let d=c(a.state);d&&d!=d$&&b.push(d)}),a.cursorWrapper&&b.push(dZ.create(a.state.doc,[a.cursorWrapper.deco])),d_.from(b)}let d8={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},d9=cb&&cc<=11;class ea{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(a){this.anchorNode=a.anchorNode,this.anchorOffset=a.anchorOffset,this.focusNode=a.focusNode,this.focusOffset=a.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(a){return a.anchorNode==this.anchorNode&&a.anchorOffset==this.anchorOffset&&a.focusNode==this.focusNode&&a.focusOffset==this.focusOffset}}class eb{constructor(a,b){this.view=a,this.handleDOMChange=b,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ea,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(b=>{for(let a=0;a<b.length;a++)this.queue.push(b[a]);cb&&cc<=11&&b.some(a=>"childList"==a.type&&a.removedNodes.length||"characterData"==a.type&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():ch&&a.composing&&b.some(a=>"childList"==a.type&&"TR"==a.target.nodeName)?(a.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),d9&&(this.onCharData=a=>{this.queue.push({target:a.target,type:"characterData",oldValue:a.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,d8)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let a=this.observer.takeRecords();if(a.length){for(let b=0;b<a.length;b++)this.queue.push(a[b]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(c6(this.view)){if(this.suppressingSelectionUpdates)return c$(this.view);if(cb&&cc<=11&&!this.view.state.selection.empty){let a=this.view.domSelectionRange();if(a.focusNode&&b$(a.focusNode,a.focusOffset,a.anchorNode,a.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(a){if(!a.focusNode)return!0;let b=new Set,c;for(let c=a.focusNode;c;c=bW(c))b.add(c);for(let d=a.anchorNode;d;d=bW(d))if(b.has(d)){c=d;break}let d=c&&this.view.docView.nearestDesc(c);if(d&&d.ignoreMutation({type:"selection",target:3==c.nodeType?c.parentNode:c}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let a of this.observer.takeRecords())this.queue.push(a);return this.queue}flush(){var a;let{view:b}=this;if(!b.docView||this.flushingSoon>-1)return;let c=this.pendingRecords();c.length&&(this.queue=[]);let d=b.domSelectionRange(),e=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(d)&&c6(b)&&!this.ignoreSelectionChange(d),f=-1,g=-1,h=!1,i=[];if(b.editable)for(let a=0;a<c.length;a++){let b=this.registerMutation(c[a],i);b&&(f=f<0?b.from:Math.min(b.from,f),g=g<0?b.to:Math.max(b.to,g),b.typeOver&&(h=!0))}if(i.some(a=>"BR"==a.nodeName)&&(8==b.input.lastKeyCode||46==b.input.lastKeyCode)){for(let a of i)if("BR"==a.nodeName&&a.parentNode){let b=a.nextSibling;b&&1==b.nodeType&&"false"==b.contentEditable&&a.parentNode.removeChild(a)}}else if(cd&&i.length){let a=i.filter(a=>"BR"==a.nodeName);if(2==a.length){let[b,c]=a;b.parentNode&&b.parentNode.parentNode==c.parentNode?c.remove():b.remove()}else{let{focusNode:c}=this.currentSelection;for(let d of a){let a=d.parentNode;a&&"LI"==a.nodeName&&(!c||function(a,b){for(let c=b.parentNode;c&&c!=a.dom;c=c.parentNode){let b=a.docView.nearestDesc(c,!0);if(b&&b.node.isBlock)return c}return null}(b,c)!=a)&&d.remove()}}}let j=null;f<0&&e&&b.input.lastFocus>Date.now()-200&&Math.max(b.input.lastTouch,b.input.lastClick.time)<Date.now()-300&&b3(d)&&(j=cY(b))&&j.eq(a9.near(b.state.doc.resolve(0),1))?(b.input.lastFocus=0,c$(b),this.currentSelection.set(d),b.scrollToSelection()):(f>-1||e)&&(f>-1&&(b.docView.markDirty(f,g),a=b,!ec.has(a)&&(ec.set(a,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(a.dom).whiteSpace))&&(a.requiresGeckoHackNode=cd,ed||(console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),ed=!0))),b.input.badSafariComposition&&(b.input.badSafariComposition=!1,function(a,b){var c;let{focusNode:d,focusOffset:e}=a.domSelectionRange();for(let f of b)if((null==(c=f.parentNode)?void 0:c.nodeName)=="TR"){let b=f.nextSibling;for(;b&&"TD"!=b.nodeName&&"TH"!=b.nodeName;)b=b.nextSibling;if(b){let c=b;for(;;){let a=c.firstChild;if(!a||1!=a.nodeType||"false"==a.contentEditable||/^(BR|IMG)$/.test(a.nodeName))break;c=a}c.insertBefore(f,c.firstChild),d==f&&a.domSelection().collapse(f,e)}else f.parentNode.removeChild(f)}}(b,i)),this.handleDOMChange(f,g,h,i),b.docView&&b.docView.dirty?b.updateState(b.state):this.currentSelection.eq(d)||c$(b),this.currentSelection.set(d))}registerMutation(a,b){if(b.indexOf(a.target)>-1)return null;let c=this.view.docView.nearestDesc(a.target);if("attributes"==a.type&&(c==this.view.docView||"contenteditable"==a.attributeName||"style"==a.attributeName&&!a.oldValue&&!a.target.getAttribute("style"))||!c||c.ignoreMutation(a))return null;if("childList"==a.type){for(let c=0;c<a.addedNodes.length;c++){let d=a.addedNodes[c];b.push(d),3==d.nodeType&&(this.lastChangedTextNode=d)}if(c.contentDOM&&c.contentDOM!=c.dom&&!c.contentDOM.contains(a.target))return{from:c.posBefore,to:c.posAfter};let d=a.previousSibling,e=a.nextSibling;if(cb&&cc<=11&&a.addedNodes.length)for(let b=0;b<a.addedNodes.length;b++){let{previousSibling:c,nextSibling:f}=a.addedNodes[b];(!c||0>Array.prototype.indexOf.call(a.addedNodes,c))&&(d=c),(!f||0>Array.prototype.indexOf.call(a.addedNodes,f))&&(e=f)}let f=d&&d.parentNode==a.target?bV(d)+1:0,g=c.localPosFromDOM(a.target,f,-1),h=e&&e.parentNode==a.target?bV(e):a.target.childNodes.length;return{from:g,to:c.localPosFromDOM(a.target,h,1)}}return"attributes"==a.type?{from:c.posAtStart-c.border,to:c.posAtEnd+c.border}:(this.lastChangedTextNode=a.target,{from:c.posAtStart,to:c.posAtEnd,typeOver:a.target.nodeValue==a.oldValue})}}let ec=new WeakMap,ed=!1;function ee(a,b){let c=b.startContainer,d=b.startOffset,e=b.endContainer,f=b.endOffset,g=a.domAtPos(a.state.selection.anchor);return b$(g.node,g.offset,e,f)&&([c,d,e,f]=[e,f,c,d]),{anchorNode:c,anchorOffset:d,focusNode:e,focusOffset:f}}function ef(a){let b=a.pmViewDesc;if(b)return b.parseRule();if("BR"==a.nodeName&&a.parentNode){if(ch&&/^(ul|ol)$/i.test(a.parentNode.nodeName)){let a=document.createElement("div");return a.appendChild(document.createElement("li")),{skip:a}}else if(a.parentNode.lastChild==a||ch&&/^(tr|table)$/i.test(a.parentNode.nodeName))return{ignore:!0}}else if("IMG"==a.nodeName&&a.getAttribute("mark-placeholder"))return{ignore:!0};return null}let eg=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function eh(a,b,c){return Math.max(c.anchor,c.head)>b.content.size?null:c5(a,b.resolve(c.anchor),b.resolve(c.head))}function ei(a,b,c){let d=a.depth,e=b?a.end():a.pos;for(;d>0&&(b||a.indexAfter(d)==a.node(d).childCount);)d--,e++,b=!1;if(c){let b=a.node(d).maybeChild(a.indexAfter(d));for(;b&&!b.isLeaf;)b=b.firstChild,e++}return e}function ej(a){if(2!=a.length)return!1;let b=a.charCodeAt(0),c=a.charCodeAt(1);return b>=56320&&b<=57343&&c>=55296&&c<=56319}class ek{constructor(a,b){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new dy,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=b,this.state=b.state,this.directPlugins=b.plugins||[],this.directPlugins.forEach(ep),this.dispatch=this.dispatch.bind(this),this.dom=a&&a.mount||document.createElement("div"),a&&(a.appendChild?a.appendChild(this.dom):"function"==typeof a?a(this.dom):a.mount&&(this.mounted=!0)),this.editable=en(this),em(this),this.nodeViews=eo(this),this.docView=cK(this.state.doc,el(this),d7(this),this.dom,this),this.domObserver=new eb(this,(a,b,c,d)=>(function(a,b,c,d,e){let f,g,h,i=a.input.compositionPendingChanges||(a.composing?a.input.compositionID:0);if(a.input.compositionPendingChanges=0,b<0){let b=a.input.lastSelectionTime>Date.now()-50?a.input.lastSelectionOrigin:null,c=cY(a,b);if(c&&!a.state.selection.eq(c)){if(cf&&cl&&13===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime&&a.someProp("handleKeyDown",b=>b(a,b4(13,"Enter"))))return;let d=a.state.tr.setSelection(c);"pointer"==b?d.setMeta("pointer",!0):"key"==b&&d.scrollIntoView(),i&&d.setMeta("composition",i),a.dispatch(d)}return}let j=a.state.doc.resolve(b),k=j.sharedDepth(c);b=j.before(k+1),c=a.state.doc.resolve(c).after(k+1);let l=a.state.selection,m=function(a,b,c){let d,{node:e,fromOffset:f,toOffset:g,from:h,to:i}=a.docView.parseRange(b,c),j=a.domSelectionRange(),k=j.anchorNode;if(k&&a.dom.contains(1==k.nodeType?k:k.parentNode)&&(d=[{node:k,offset:j.anchorOffset}],b3(j)||d.push({node:j.focusNode,offset:j.focusOffset})),cf&&8===a.input.lastKeyCode)for(let a=g;a>f;a--){let b=e.childNodes[a-1],c=b.pmViewDesc;if("BR"==b.nodeName&&!c){g=a;break}if(!c||c.size)break}let l=a.state.doc,m=a.someProp("domParser")||al.fromSchema(a.state.schema),n=l.resolve(h),o=null,p=m.parse(e,{topNode:n.parent,topMatch:n.parent.contentMatchAt(n.index()),topOpen:!0,from:f,to:g,preserveWhitespace:"pre"!=n.parent.type.whitespace||"full",findPositions:d,ruleFromNode:ef,context:n});if(d&&null!=d[0].pos){let a=d[0].pos,b=d[1]&&d[1].pos;null==b&&(b=a),o={anchor:a+h,head:b+h}}return{doc:p,sel:o,from:h,to:i}}(a,b,c),n=a.state.doc,o=n.slice(m.from,m.to);8===a.input.lastKeyCode&&Date.now()-100<a.input.lastKeyCodeTime?(f=a.state.selection.to,g="end"):(f=a.state.selection.from,g="start"),a.input.lastKeyCode=null;let p=function(a,b,c,d,e){let f=a.findDiffStart(b,c);if(null==f)return null;let{a:g,b:h}=a.findDiffEnd(b,c+a.size,c+b.size);if("end"==e){let a=Math.max(0,f-Math.min(g,h));d-=g+a-f}if(g<f&&a.size<b.size){let a=d<=f&&d>=g?f-d:0;(f-=a)&&f<b.size&&ej(b.textBetween(f-1,f+1))&&(f+=a?1:-1),h=f+(h-g),g=f}else if(h<f){let b=d<=f&&d>=h?f-d:0;(f-=b)&&f<a.size&&ej(a.textBetween(f-1,f+1))&&(f+=b?1:-1),g=f+(g-h),h=f}return{start:f,endA:g,endB:h}}(o.content,m.doc.content,m.from,f,g);if(p&&a.input.domChangeCount++,(ci&&a.input.lastIOSEnter>Date.now()-225||cl)&&e.some(a=>1==a.nodeType&&!eg.test(a.nodeName))&&(!p||p.endA>=p.endB)&&a.someProp("handleKeyDown",b=>b(a,b4(13,"Enter")))){a.input.lastIOSEnter=0;return}if(!p)if(d&&l instanceof bd&&!l.empty&&l.$head.sameParent(l.$anchor)&&!a.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(m.sel){let b=eh(a,a.state.doc,m.sel);if(b&&!b.eq(a.state.selection)){let c=a.state.tr.setSelection(b);i&&c.setMeta("composition",i),a.dispatch(c)}}return}a.state.selection.from<a.state.selection.to&&p.start==p.endB&&a.state.selection instanceof bd&&(p.start>a.state.selection.from&&p.start<=a.state.selection.from+2&&a.state.selection.from>=m.from?p.start=a.state.selection.from:p.endA<a.state.selection.to&&p.endA>=a.state.selection.to-2&&a.state.selection.to<=m.to&&(p.endB+=a.state.selection.to-p.endA,p.endA=a.state.selection.to)),cb&&cc<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>m.from&&" \xa0"==m.doc.textBetween(p.start-m.from-1,p.start-m.from+1)&&(p.start--,p.endA--,p.endB--);let q=m.doc.resolveNoCache(p.start-m.from),r=m.doc.resolveNoCache(p.endB-m.from),s=n.resolve(p.start),t=q.sameParent(r)&&q.parent.inlineContent&&s.end()>=p.endA;if((ci&&a.input.lastIOSEnter>Date.now()-225&&(!t||e.some(a=>"DIV"==a.nodeName||"P"==a.nodeName))||!t&&q.pos<m.doc.content.size&&(!q.sameParent(r)||!q.parent.inlineContent)&&q.pos<r.pos&&!/\S/.test(m.doc.textBetween(q.pos,r.pos,"","")))&&a.someProp("handleKeyDown",b=>b(a,b4(13,"Enter")))){a.input.lastIOSEnter=0;return}if(a.state.selection.anchor>p.start&&function(a,b,c,d,e){if(c-b<=e.pos-d.pos||ei(d,!0,!1)<e.pos)return!1;let f=a.resolve(b);if(!d.parent.isTextblock){let a=f.nodeAfter;return null!=a&&c==b+a.nodeSize}if(f.parentOffset<f.parent.content.size||!f.parent.isTextblock)return!1;let g=a.resolve(ei(f,!0,!0));return!(!g.parent.isTextblock||g.pos>c||ei(g,!0,!1)<c)&&d.parent.content.cut(d.parentOffset).eq(g.parent.content)}(n,p.start,p.endA,q,r)&&a.someProp("handleKeyDown",b=>b(a,b4(8,"Backspace")))){cl&&cf&&a.domObserver.suppressSelectionUpdates();return}cf&&p.endB==p.start&&(a.input.lastChromeDelete=Date.now()),cl&&!t&&q.start()!=r.start()&&0==r.parentOffset&&q.depth==r.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==p.endA&&(p.endB-=2,r=m.doc.resolveNoCache(p.endB-m.from),setTimeout(()=>{a.someProp("handleKeyDown",function(b){return b(a,b4(13,"Enter"))})},20));let u=p.start,v=p.endA,w=b=>{let c=b||a.state.tr.replace(u,v,m.doc.slice(p.start-m.from,p.endB-m.from));if(m.sel){let b=eh(a,c.doc,m.sel);b&&!(cf&&a.composing&&b.empty&&(p.start!=p.endB||a.input.lastChromeDelete<Date.now()-100)&&(b.head==u||b.head==c.mapping.map(v)-1)||cb&&b.empty&&b.head==u)&&c.setSelection(b)}return i&&c.setMeta("composition",i),c.scrollIntoView()};if(t)if(q.pos==r.pos){cb&&cc<=11&&0==q.parentOffset&&(a.domObserver.suppressSelectionUpdates(),setTimeout(()=>c$(a),20));let b=w(a.state.tr.delete(u,v)),c=n.resolve(p.start).marksAcross(n.resolve(p.endA));c&&b.ensureMarks(c),a.dispatch(b)}else if(p.endA==p.endB&&(h=function(a,b){let c=a.firstChild.marks,d=b.firstChild.marks,e=c,f=d,g,h,i;for(let a=0;a<d.length;a++)e=d[a].removeFromSet(e);for(let a=0;a<c.length;a++)f=c[a].removeFromSet(f);if(1==e.length&&0==f.length)h=e[0],g="add",i=a=>a.mark(h.addToSet(a.marks));else{if(0!=e.length||1!=f.length)return null;h=f[0],g="remove",i=a=>a.mark(h.removeFromSet(a.marks))}let j=[];for(let a=0;a<b.childCount;a++)j.push(i(b.child(a)));if(D.from(j).eq(a))return{mark:h,type:g}}(q.parent.content.cut(q.parentOffset,r.parentOffset),s.parent.content.cut(s.parentOffset,p.endA-s.start())))){let b=w(a.state.tr);"add"==h.type?b.addMark(u,v,h.mark):b.removeMark(u,v,h.mark),a.dispatch(b)}else if(q.parent.child(q.index()).isText&&q.index()==r.index()-!r.textOffset){let b=q.parent.textBetween(q.parentOffset,r.parentOffset),c=()=>w(a.state.tr.insertText(b,u,v));a.someProp("handleTextInput",d=>d(a,u,v,b,c))||a.dispatch(c())}else a.dispatch(w());else a.dispatch(w())})(this,a,b,c,d)),this.domObserver.start(),function(a){for(let b in dv){let c=dv[b];a.dom.addEventListener(b,a.input.eventHandlers[b]=b=>{!function(a,b){if(!b.bubbles)return!0;if(b.defaultPrevented)return!1;for(let c=b.target;c!=a.dom;c=c.parentNode)if(!c||11==c.nodeType||c.pmViewDesc&&c.pmViewDesc.stopEvent(b))return!1;return!0}(a,b)||dB(a,b)||!a.editable&&b.type in dw||c(a,b)},dx[b]?{passive:!0}:void 0)}ch&&a.dom.addEventListener("input",()=>null),dA(a)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let a=this._props;for(let b in this._props={},a)this._props[b]=a[b];this._props.state=this.state}return this._props}update(a){a.handleDOMEvents!=this._props.handleDOMEvents&&dA(this);let b=this._props;this._props=a,a.plugins&&(a.plugins.forEach(ep),this.directPlugins=a.plugins),this.updateStateInner(a.state,b)}setProps(a){let b={};for(let a in this._props)b[a]=this._props[a];for(let c in b.state=this.state,a)b[c]=a[c];this.update(b)}updateState(a){this.updateStateInner(a,this._props)}updateStateInner(a,b){var c,d,e;let f=this.state,g=!1,h=!1;a.storedMarks&&this.composing&&(dK(this),h=!0),this.state=a;let i=f.plugins!=a.plugins||this._props.plugins!=b.plugins;if(i||this._props.plugins!=b.plugins||this._props.nodeViews!=b.nodeViews){let a=eo(this);(function(a,b){let c=0,d=0;for(let d in a){if(a[d]!=b[d])return!0;c++}for(let a in b)d++;return c!=d})(a,this.nodeViews)&&(this.nodeViews=a,g=!0)}(i||b.handleDOMEvents!=this._props.handleDOMEvents)&&dA(this),this.editable=en(this),em(this);let j=d7(this),k=el(this),l=f.plugins==a.plugins||f.doc.eq(a.doc)?a.scrollToSelection>f.scrollToSelection?"to selection":"preserve":"reset",m=g||!this.docView.matchesNode(a.doc,k,j);(m||!a.selection.eq(f.selection))&&(h=!0);let n="preserve"==l&&h&&null==this.dom.style.overflowAnchor&&function(a){let b,c,d=a.dom.getBoundingClientRect(),e=Math.max(0,d.top);for(let f=(d.left+d.right)/2,g=e+1;g<Math.min(innerHeight,d.bottom);g+=5){let d=a.root.elementFromPoint(f,g);if(!d||d==a.dom||!a.dom.contains(d))continue;let h=d.getBoundingClientRect();if(h.top>=e-20){b=d,c=h.top;break}}return{refDOM:b,refTop:c,stack:cq(a.dom)}}(this);if(h){let b,c,h;this.domObserver.stop();let i=m&&(cb||cf)&&!this.composing&&!f.selection.empty&&!a.selection.empty&&(d=f.selection,e=a.selection,h=Math.min(d.$anchor.sharedDepth(d.head),e.$anchor.sharedDepth(e.head)),d.$anchor.start(h)!=e.$anchor.start(h));if(m){let b=cf?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(a){let b=a.domSelectionRange();if(!b.focusNode)return null;let c=function(a,b){for(;;){if(3==a.nodeType&&b)return a;if(1==a.nodeType&&b>0){if("false"==a.contentEditable)return null;b=b1(a=a.childNodes[b-1])}else{if(!a.parentNode||b2(a))return null;b=bV(a),a=a.parentNode}}}(b.focusNode,b.focusOffset),d=function(a,b){for(;;){if(3==a.nodeType&&b<a.nodeValue.length)return a;if(1==a.nodeType&&b<a.childNodes.length){if("false"==a.contentEditable)return null;a=a.childNodes[b],b=0}else{if(!a.parentNode||b2(a))return null;b=bV(a)+1,a=a.parentNode}}}(b.focusNode,b.focusOffset);if(c&&d&&c!=d){let b=d.pmViewDesc,e=a.domObserver.lastChangedTextNode;if(c==e||d==e)return e;if(!b||!b.isText(d.nodeValue))return d;if(a.input.compositionNode==d){let a=c.pmViewDesc;if(!(!a||!a.isText(c.nodeValue)))return d}}return c||d}(this)),(g||!this.docView.update(a.doc,k,j,this))&&(this.docView.updateOuterDeco(k),this.docView.destroy(),this.docView=cK(a.doc,k,j,this.dom,this)),!b||this.trackWrites&&this.dom.contains(this.trackWrites)||(i=!0)}i||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(b=this.docView.domFromPos(this.state.selection.anchor,0),c=this.domSelectionRange(),b$(b.node,b.offset,c.anchorNode,c.anchorOffset)))?c$(this,i):(c3(this,a.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(f),(null==(c=this.dragging)?void 0:c.node)&&!f.doc.eq(a.doc)&&this.updateDraggedNode(this.dragging,f),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():n&&function({refDOM:a,refTop:b,stack:c}){let d=a?a.getBoundingClientRect().top:0;cr(c,0==d?0:d-b)}(n)}scrollToSelection(){let a=this.domSelectionRange().focusNode;if(a&&this.dom.contains(1==a.nodeType?a:a.parentNode))if(this.someProp("handleScrollToSelection",a=>a(this)));else if(this.state.selection instanceof bf){let b=this.docView.domAfterPos(this.state.selection.from);1==b.nodeType&&cp(this,b.getBoundingClientRect(),a)}else cp(this,this.coordsAtPos(this.state.selection.head,1),a)}destroyPluginViews(){let a;for(;a=this.pluginViews.pop();)a.destroy&&a.destroy()}updatePluginViews(a){if(a&&a.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let b=0;b<this.pluginViews.length;b++){let c=this.pluginViews[b];c.update&&c.update(this,a)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let a=0;a<this.directPlugins.length;a++){let b=this.directPlugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}for(let a=0;a<this.state.plugins.length;a++){let b=this.state.plugins[a];b.spec.view&&this.pluginViews.push(b.spec.view(this))}}}updateDraggedNode(a,b){let c=a.node,d=-1;if(this.state.doc.nodeAt(c.from)==c.node)d=c.from;else{let a=c.from+(this.state.doc.content.size-b.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==c.node&&(d=a)}this.dragging=new dP(a.slice,a.move,d<0?void 0:bf.create(this.state.doc,d))}someProp(a,b){let c=this._props&&this._props[a],d;if(null!=c&&(d=b?b(c):c))return d;for(let c=0;c<this.directPlugins.length;c++){let e=this.directPlugins[c].props[a];if(null!=e&&(d=b?b(e):e))return d}let e=this.state.plugins;if(e)for(let c=0;c<e.length;c++){let f=e[c].props[a];if(null!=f&&(d=b?b(f):f))return d}}hasFocus(){if(cb){let a=this.root.activeElement;if(a==this.dom)return!0;if(!a||!this.dom.contains(a))return!1;for(;a&&this.dom!=a&&this.dom.contains(a);){if("false"==a.contentEditable)return!1;a=a.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(a){if(a.setActive)return a.setActive();if(cs)return a.focus(cs);let b=cq(a);a.focus(null==cs?{get preventScroll(){return cs={preventScroll:!0},!0}}:void 0),cs||(cs=!1,cr(b,0))}(this.dom),c$(this),this.domObserver.start()}get root(){let a=this._root;if(null==a){for(let a=this.dom.parentNode;a;a=a.parentNode)if(9==a.nodeType||11==a.nodeType&&a.host)return a.getSelection||(Object.getPrototypeOf(a).getSelection=()=>a.ownerDocument.getSelection()),this._root=a}return a||document}updateRoot(){this._root=null}posAtCoords(a){return function(a,b){var c;let d,e,f=a.dom.ownerDocument,g,h=0,i=function(a,b,c){if(a.caretPositionFromPoint)try{let d=a.caretPositionFromPoint(b,c);if(d)return{node:d.offsetNode,offset:Math.min(b1(d.offsetNode),d.offset)}}catch(a){}if(a.caretRangeFromPoint){let d=a.caretRangeFromPoint(b,c);if(d)return{node:d.startContainer,offset:Math.min(b1(d.startContainer),d.startOffset)}}}(f,b.left,b.top);i&&({node:g,offset:h}=i);let j=(a.root.elementFromPoint?a.root:f).elementFromPoint(b.left,b.top);if(!j||!a.dom.contains(1!=j.nodeType?j.parentNode:j)){let c=a.dom.getBoundingClientRect();if(!ct(b,c)||!(j=function a(b,c,d){let e=b.childNodes.length;if(e&&d.top<d.bottom)for(let f=Math.max(0,Math.min(e-1,Math.floor(e*(c.top-d.top)/(d.bottom-d.top))-2)),g=f;;){let d=b.childNodes[g];if(1==d.nodeType){let b=d.getClientRects();for(let e=0;e<b.length;e++){let f=b[e];if(ct(c,f))return a(d,c,f)}}if((g=(g+1)%e)==f)break}return b}(a.dom,b,c)))return null}if(ch)for(let a=j;g&&a;a=bW(a))a.draggable&&(g=void 0);if(j=(d=(c=j).parentNode)&&/^li$/i.test(d.nodeName)&&b.left<c.getBoundingClientRect().left?d:c,g){let c;if(cd&&1==g.nodeType&&(h=Math.min(h,g.childNodes.length))<g.childNodes.length){let a=g.childNodes[h],c;"IMG"==a.nodeName&&(c=a.getBoundingClientRect()).right<=b.left&&c.bottom>b.top&&h++}cm&&h&&1==g.nodeType&&1==(c=g.childNodes[h-1]).nodeType&&"false"==c.contentEditable&&c.getBoundingClientRect().top>=b.top&&h--,g==a.dom&&h==g.childNodes.length-1&&1==g.lastChild.nodeType&&b.top>g.lastChild.getBoundingClientRect().bottom?e=a.state.doc.content.size:(0==h||1!=g.nodeType||"BR"!=g.childNodes[h-1].nodeName)&&(e=function(a,b,c,d){let e=-1;for(let c=b,f=!1;c!=a.dom;){let b=a.docView.nearestDesc(c,!0),g;if(!b)return null;if(1==b.dom.nodeType&&(b.node.isBlock&&b.parent||!b.contentDOM)&&((g=b.dom.getBoundingClientRect()).width||g.height)&&(b.node.isBlock&&b.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(b.dom.nodeName)&&(!f&&g.left>d.left||g.top>d.top?e=b.posBefore:(!f&&g.right<d.left||g.bottom<d.top)&&(e=b.posAfter),f=!0),!b.contentDOM&&e<0&&!b.node.isText))return(b.node.isBlock?d.top<(g.top+g.bottom)/2:d.left<(g.left+g.right)/2)?b.posBefore:b.posAfter;c=b.dom.parentNode}return e>-1?e:a.docView.posFromDOM(b,c,-1)}(a,g,h,b))}null==e&&(e=function(a,b,c){let{node:d,offset:e}=function a(b,c){let d,e,f,g=2e8,h,i=0,j=c.top,k=c.top;for(let a=b.firstChild,l=0;a;a=a.nextSibling,l++){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=bY(a).getClientRects()}for(let m=0;m<b.length;m++){let n=b[m];if(n.top<=j&&n.bottom>=k){j=Math.max(n.bottom,j),k=Math.min(n.top,k);let b=n.left>c.left?n.left-c.left:n.right<c.left?c.left-n.right:0;if(b<g){f=a,g=b,h=b&&3==f.nodeType?{left:n.right<c.left?n.right:n.left,top:c.top}:c,1==a.nodeType&&b&&(i=l+ +(c.left>=(n.left+n.right)/2));continue}}else n.top>c.top&&!d&&n.left<=c.left&&n.right>=c.left&&(d=a,e={left:Math.max(n.left,Math.min(n.right,c.left)),top:n.top});!f&&(c.left>=n.right&&c.top>=n.top||c.left>=n.left&&c.top>=n.bottom)&&(i=l+1)}}return(!f&&d&&(f=d,h=e,g=0),f&&3==f.nodeType)?function(a,b){let c=a.nodeValue.length,d=document.createRange(),e;for(let f=0;f<c;f++){d.setEnd(a,f+1),d.setStart(a,f);let c=cv(d,1);if(c.top!=c.bottom&&ct(b,c)){e={node:a,offset:f+ +(b.left>=(c.left+c.right)/2)};break}}return d.detach(),e||{node:a,offset:0}}(f,h):!f||g&&1==f.nodeType?{node:b,offset:i}:a(f,h)}(b,c),f=-1;if(1==d.nodeType&&!d.firstChild){let a=d.getBoundingClientRect();f=a.left!=a.right&&c.left>(a.left+a.right)/2?1:-1}return a.docView.posFromDOM(d,e,f)}(a,j,b));let k=a.docView.nearestDesc(j,!0);return{pos:e,inside:k?k.posAtStart-k.border:-1}}(this,a)}coordsAtPos(a,b=1){return cx(this,a,b)}domAtPos(a,b=0){return this.docView.domFromPos(a,b)}nodeDOM(a){let b=this.docView.descAt(a);return b?b.nodeDOM:null}posAtDOM(a,b,c=-1){let d=this.docView.posFromDOM(a,b,c);if(null==d)throw RangeError("DOM position not inside the editor");return d}endOfTextblock(a,b){return function(a,b,c){let d,e;return cC==b&&cD==c?cE:(cC=b,cD=c,cE="up"==c||"down"==c?(d=b.selection,e="up"==c?d.$from:d.$to,cA(a,b,()=>{let{node:b}=a.docView.domFromPos(e.pos,"up"==c?-1:1);for(;;){let c=a.docView.nearestDesc(b,!0);if(!c)break;if(c.node.isBlock){b=c.contentDOM||c.dom;break}b=c.dom.parentNode}let d=cx(a,e.pos,1);for(let a=b.firstChild;a;a=a.nextSibling){let b;if(1==a.nodeType)b=a.getClientRects();else{if(3!=a.nodeType)continue;b=bY(a,0,a.nodeValue.length).getClientRects()}for(let a=0;a<b.length;a++){let e=b[a];if(e.bottom>e.top+1&&("up"==c?d.top-e.top>(e.bottom-d.top)*2:e.bottom-d.bottom>(d.bottom-e.top)*2))return!1}}return!0})):function(a,b,c){let{$head:d}=b.selection;if(!d.parent.isTextblock)return!1;let e=d.parentOffset,f=e==d.parent.content.size,g=a.domSelection();return g?cB.test(d.parent.textContent)&&g.modify?cA(a,b,()=>{let{focusNode:b,focusOffset:e,anchorNode:f,anchorOffset:h}=a.domSelectionRange(),i=g.caretBidiLevel;g.modify("move",c,"character");let j=d.depth?a.docView.domAfterPos(d.before()):a.dom,{focusNode:k,focusOffset:l}=a.domSelectionRange(),m=k&&!j.contains(1==k.nodeType?k:k.parentNode)||b==k&&e==l;try{g.collapse(f,h),b&&(b!=f||e!=h)&&g.extend&&g.extend(b,e)}catch(a){}return null!=i&&(g.caretBidiLevel=i),m}):"left"==c||"backward"==c?!e:f:d.pos==d.start()||d.pos==d.end()}(a,b,c))}(this,b||this.state,a)}pasteHTML(a,b){return dN(this,"",a,!1,b||new ClipboardEvent("paste"))}pasteText(a,b){return dN(this,a,null,!0,b||new ClipboardEvent("paste"))}serializeForClipboard(a){return dk(this,a)}destroy(){if(this.docView){for(let a in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(a,this.input.eventHandlers[a]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],d7(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,bZ()}}get isDestroyed(){return null==this.docView}dispatchEvent(a){!dB(this,a)&&dv[a.type]&&(this.editable||!(a.type in dw))&&dv[a.type](this,a)}domSelectionRange(){let a=this.domSelection();return a?ch&&11===this.root.nodeType&&function(a){let b=a.activeElement;for(;b&&b.shadowRoot;)b=b.shadowRoot.activeElement;return b}(this.dom.ownerDocument)==this.dom&&function(a,b){let c;if(b.getComposedRanges){let c=b.getComposedRanges(a.root)[0];if(c)return ee(a,c)}function d(a){a.preventDefault(),a.stopImmediatePropagation(),c=a.getTargetRanges()[0]}return a.dom.addEventListener("beforeinput",d,!0),document.execCommand("indent"),a.dom.removeEventListener("beforeinput",d,!0),c?ee(a,c):null}(this,a)||a:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function el(a){let b=Object.create(null);return b.class="ProseMirror",b.contenteditable=String(a.editable),a.someProp("attributes",c=>{if("function"==typeof c&&(c=c(a.state)),c)for(let a in c)"class"==a?b.class+=" "+c[a]:"style"==a?b.style=(b.style?b.style+";":"")+c[a]:b[a]||"contenteditable"==a||"nodeName"==a||(b[a]=String(c[a]))}),b.translate||(b.translate="no"),[dW.node(0,a.state.doc.content.size,b)]}function em(a){if(a.markCursor){let b=document.createElement("img");b.className="ProseMirror-separator",b.setAttribute("mark-placeholder","true"),b.setAttribute("alt",""),a.cursorWrapper={dom:b,deco:dW.widget(a.state.selection.from,b,{raw:!0,marks:a.markCursor})}}else a.cursorWrapper=null}function en(a){return!a.someProp("editable",b=>!1===b(a.state))}function eo(a){let b=Object.create(null);function c(a){for(let c in a)Object.prototype.hasOwnProperty.call(b,c)||(b[c]=a[c])}return a.someProp("nodeViews",c),a.someProp("markViews",c),b}function ep(a){if(a.spec.state||a.spec.filterTransaction||a.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}ek.prototype.dispatch=function(a){let b=this._props.dispatchTransaction;b?b.call(this,a):this.updateState(this.state.apply(a))};for(var eq={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},er={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},es="u">typeof navigator&&/Mac/.test(navigator.platform),et="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),eu=0;eu<10;eu++)eq[48+eu]=eq[96+eu]=String(eu);for(var eu=1;eu<=24;eu++)eq[eu+111]="F"+eu;for(var eu=65;eu<=90;eu++)eq[eu]=String.fromCharCode(eu+32),er[eu]=String.fromCharCode(eu);for(var ev in eq)er.hasOwnProperty(ev)||(er[ev]=eq[ev]);let ew="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ex="u">typeof navigator&&/Win/.test(navigator.platform);function ey(a,b,c=!0){return b.altKey&&(a="Alt-"+a),b.ctrlKey&&(a="Ctrl-"+a),b.metaKey&&(a="Meta-"+a),c&&b.shiftKey&&(a="Shift-"+a),a}function ez(a){let b=function(a){let b=Object.create(null);for(let c in a)b[function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"==g&&(g=" ");for(let a=0;a<f.length-1;a++){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))ew?e=!0:c=!0;else throw Error("Unrecognized modifier name: "+g)}return b&&(g="Alt-"+g),c&&(g="Ctrl-"+g),e&&(g="Meta-"+g),d&&(g="Shift-"+g),g}(c)]=a[c];return b}(a);return function(a,c){var d;let e=("Esc"==(d=!(es&&c.metaKey&&c.shiftKey&&!c.ctrlKey&&!c.altKey||et&&c.shiftKey&&c.key&&1==c.key.length||"Unidentified"==c.key)&&c.key||(c.shiftKey?er:eq)[c.keyCode]||c.key||"Unidentified")&&(d="Escape"),"Del"==d&&(d="Delete"),"Left"==d&&(d="ArrowLeft"),"Up"==d&&(d="ArrowUp"),"Right"==d&&(d="ArrowRight"),"Down"==d&&(d="ArrowDown"),d),f,g=b[ey(e,c)];if(g&&g(a.state,a.dispatch,a))return!0;if(1==e.length&&" "!=e){if(c.shiftKey){let d=b[ey(e,c,!1)];if(d&&d(a.state,a.dispatch,a))return!0}if((c.altKey||c.metaKey||c.ctrlKey)&&!(ex&&c.ctrlKey&&c.altKey)&&(f=eq[c.keyCode])&&f!=e){let d=b[ey(f,c)];if(d&&d(a.state,a.dispatch,a))return!0}}return!1}}var eA=Object.defineProperty,eB=(a,b)=>{for(var c in b)eA(a,c,{get:b[c],enumerable:!0})};function eC(a){let{state:b,transaction:c}=a,{selection:d}=c,{doc:e}=c,{storedMarks:f}=c;return{...b,apply:b.apply.bind(b),applyTransaction:b.applyTransaction.bind(b),plugins:b.plugins,schema:b.schema,reconfigure:b.reconfigure.bind(b),toJSON:b.toJSON.bind(b),get storedMarks(){return f},get selection(){return d},get doc(){return e},get tr(){return d=c.selection,e=c.doc,f=c.storedMarks,c}}}var eD=class{constructor(a){this.editor=a.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=a.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:a,editor:b,state:c}=this,{view:d}=b,{tr:e}=c,f=this.buildProps(e);return Object.fromEntries(Object.entries(a).map(([a,b])=>[a,(...a)=>{let c=b(...a)(f);return e.getMeta("preventDispatch")||this.hasCustomState||d.dispatch(e),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g=[],h=!!a,i=a||e.tr,j=()=>(h||!b||i.getMeta("preventDispatch")||this.hasCustomState||f.dispatch(i),g.every(a=>!0===a)),k={...Object.fromEntries(Object.entries(c).map(([a,c])=>[a,(...a)=>{let d=this.buildProps(i,b),e=c(...a)(d);return g.push(e),k}])),run:j};return k}createCan(a){let{rawCommands:b,state:c}=this,d=a||c.tr,e=this.buildProps(d,!1);return{...Object.fromEntries(Object.entries(b).map(([a,b])=>[a,(...a)=>b(...a)({...e,dispatch:void 0})])),chain:()=>this.createChain(d,!1)}}buildProps(a,b=!0){let{rawCommands:c,editor:d,state:e}=this,{view:f}=d,g={tr:a,editor:d,view:f,state:eC({state:e,transaction:a}),dispatch:b?()=>void 0:void 0,chain:()=>this.createChain(a,b),can:()=>this.createCan(a),get commands(){return Object.fromEntries(Object.entries(c).map(([a,b])=>[a,(...a)=>b(...a)(g)]))}};return g}},eE={};eB(eE,{blur:()=>eF,clearContent:()=>eG,clearNodes:()=>eH,command:()=>eI,createParagraphNear:()=>eJ,cut:()=>eK,deleteCurrentNode:()=>eL,deleteNode:()=>eN,deleteRange:()=>eO,deleteSelection:()=>eP,enter:()=>eQ,exitCode:()=>eR,extendMarkRange:()=>eY,first:()=>eZ,focus:()=>e3,forEach:()=>e4,insertContent:()=>e5,insertContentAt:()=>e9,joinBackward:()=>fc,joinDown:()=>fb,joinForward:()=>fd,joinItemBackward:()=>fe,joinItemForward:()=>ff,joinTextblockBackward:()=>fg,joinTextblockForward:()=>fh,joinUp:()=>fa,keyboardShortcut:()=>fj,lift:()=>fl,liftEmptyBlock:()=>fm,liftListItem:()=>fn,newlineInCode:()=>fo,resetAttributes:()=>fr,scrollIntoView:()=>fs,selectAll:()=>ft,selectNodeBackward:()=>fu,selectNodeForward:()=>fv,selectParentNode:()=>fw,selectTextblockEnd:()=>fx,selectTextblockStart:()=>fy,setContent:()=>fA,setMark:()=>f6,setMeta:()=>f7,setNode:()=>f8,setNodeSelection:()=>f9,setTextDirection:()=>ga,setTextSelection:()=>gb,sinkListItem:()=>gc,splitBlock:()=>ge,splitListItem:()=>gf,toggleList:()=>gi,toggleMark:()=>gj,toggleNode:()=>gk,toggleWrap:()=>gl,undoInputRule:()=>gm,unsetAllMarks:()=>gn,unsetMark:()=>go,unsetTextDirection:()=>gp,updateAttributes:()=>gq,wrapIn:()=>gr,wrapInList:()=>gs});var eF=()=>({editor:a,view:b})=>(requestAnimationFrame(()=>{var c;a.isDestroyed||(b.dom.blur(),null==(c=null==window?void 0:window.getSelection())||c.removeAllRanges())}),!0),eG=(a=!0)=>({commands:b})=>b.setContent("",{emitUpdate:a}),eH=()=>({state:a,tr:b,dispatch:c})=>{let{selection:d}=b,{ranges:e}=d;return!c||(e.forEach(({$from:c,$to:d})=>{a.doc.nodesBetween(c.pos,d.pos,(a,c)=>{if(a.type.isText)return;let{doc:d,mapping:e}=b,f=d.resolve(e.map(c)),g=d.resolve(e.map(c+a.nodeSize)),h=f.blockRange(g);if(!h)return;let i=aO(h);if(a.type.isTextblock){let{defaultType:a}=f.parent.contentMatchAt(f.index());b.setNodeMarkup(h.start,a)}(i||0===i)&&b.lift(h,i)})}),!0)},eI=a=>b=>a(b),eJ=()=>({state:a,dispatch:b})=>bJ(a,b),eK=(a,b)=>({editor:c,tr:d})=>{let{state:e}=c,f=e.doc.slice(a.from,a.to);d.deleteRange(a.from,a.to);let g=d.mapping.map(b);return d.insert(g,f.content),d.setSelection(new bd(d.doc.resolve(Math.max(g-1,0)))),!0},eL=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,d=c.$anchor.node();if(d.content.size>0)return!1;let e=a.selection.$anchor;for(let c=e.depth;c>0;c-=1)if(e.node(c).type===d.type){if(b){let b=e.before(c),d=e.after(c);a.delete(b,d).scrollIntoView()}return!0}return!1};function eM(a,b){if("string"==typeof a){if(!b.nodes[a])throw Error(`There is no node type named '${a}'. Maybe you forgot to add the extension?`);return b.nodes[a]}return a}var eN=a=>({tr:b,state:c,dispatch:d})=>{let e=eM(a,c.schema),f=b.selection.$anchor;for(let a=f.depth;a>0;a-=1)if(f.node(a).type===e){if(d){let c=f.before(a),d=f.after(a);b.delete(c,d).scrollIntoView()}return!0}return!1},eO=a=>({tr:b,dispatch:c})=>{let{from:d,to:e}=a;return c&&b.delete(d,e),!0},eP=()=>({state:a,dispatch:b})=>bv(a,b),eQ=()=>({commands:a})=>a.keyboardShortcut("Enter"),eR=()=>({state:a,dispatch:b})=>bI(a,b);function eS(a){return"[object RegExp]"===Object.prototype.toString.call(a)}function eT(a,b,c={strict:!0}){let d=Object.keys(b);return!d.length||d.every(d=>c.strict?b[d]===a[d]:eS(b[d])?b[d].test(a[d]):b[d]===a[d])}function eU(a,b,c={}){return a.find(a=>a.type===b&&eT(Object.fromEntries(Object.keys(c).map(b=>[b,a.attrs[b]])),c))}function eV(a,b,c={}){return!!eU(a,b,c)}function eW(a,b,c){var d;if(!a||!b)return;let e=a.parent.childAfter(a.parentOffset);if(e.node&&e.node.marks.some(a=>a.type===b)||(e=a.parent.childBefore(a.parentOffset)),!e.node||!e.node.marks.some(a=>a.type===b)||(c=c||(null==(d=e.node.marks[0])?void 0:d.attrs),!eU([...e.node.marks],b,c)))return;let f=e.index,g=a.start()+e.offset,h=f+1,i=g+e.node.nodeSize;for(;f>0&&eV([...a.parent.child(f-1).marks],b,c);)f-=1,g-=a.parent.child(f).nodeSize;for(;h<a.parent.childCount&&eV([...a.parent.child(h).marks],b,c);)i+=a.parent.child(h).nodeSize,h+=1;return{from:g,to:i}}function eX(a,b){if("string"==typeof a){if(!b.marks[a])throw Error(`There is no mark type named '${a}'. Maybe you forgot to add the extension?`);return b.marks[a]}return a}var eY=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=eX(a,d.schema),{doc:g,selection:h}=c,{$from:i,from:j,to:k}=h;if(e){let a=eW(i,f,b);if(a&&a.from<=j&&a.to>=k){let b=bd.create(g,a.from,a.to);c.setSelection(b)}}return!0},eZ=a=>b=>{let c="function"==typeof a?a(b):a;for(let a=0;a<c.length;a+=1)if(c[a](b))return!0;return!1};function e$(a){return a instanceof bd}function e_(a=0,b=0,c=0){return Math.min(Math.max(a,b),c)}function e0(a,b=null){if(!b)return null;let c=a9.atStart(a),d=a9.atEnd(a);if("start"===b||!0===b)return c;if("end"===b)return d;let e=c.from,f=d.to;return"all"===b?bd.create(a,e_(0,e,f),e_(a.content.size,e,f)):bd.create(a,e_(b,e,f),e_(b,e,f))}function e1(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function e2(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var e3=(a=null,b={})=>({editor:c,view:d,tr:e,dispatch:f})=>{b={scrollIntoView:!0,...b};let g=()=>{(e2()||e1())&&d.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!e2()&&!e1()&&d.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!c.isDestroyed&&(d.focus(),(null==b?void 0:b.scrollIntoView)&&c.commands.scrollIntoView())})};try{if(d.hasFocus()&&null===a||!1===a)return!0}catch{return!1}if(f&&null===a&&!e$(c.state.selection))return g(),!0;let h=e0(e.doc,a)||c.state.selection,i=c.state.selection.eq(h);return f&&(i||e.setSelection(h),i&&e.storedMarks&&e.setStoredMarks(e.storedMarks),g()),!0},e4=(a,b)=>c=>a.every((a,d)=>b(a,{...c,index:d})),e5=(a,b)=>({tr:c,commands:d})=>d.insertContentAt({from:c.selection.from,to:c.selection.to},a,b),e6=a=>{let b=a.childNodes;for(let c=b.length-1;c>=0;c-=1){let d=b[c];3===d.nodeType&&d.nodeValue&&/^(\n\s\s|\n)$/.test(d.nodeValue)?a.removeChild(d):1===d.nodeType&&e6(d)}return a};function e7(a){if("u"<typeof window)throw Error("[tiptap error]: there is no window object available, so this function cannot be used");let b=`<body>${a}</body>`;return e6(new window.DOMParser().parseFromString(b,"text/html").body)}function e8(a,b,c){if(a instanceof W||a instanceof D)return a;c={slice:!0,parseOptions:{},...c};let d="object"==typeof a&&null!==a,e="string"==typeof a;if(d)try{if(Array.isArray(a)&&a.length>0)return D.fromArray(a.map(a=>b.nodeFromJSON(a)));let d=b.nodeFromJSON(a);return c.errorOnInvalidContent&&d.check(),d}catch(d){if(c.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:d});return console.warn("[tiptap warn]: Invalid content.","Passed value:",a,"Error:",d),e8("",b,c)}if(e){if(c.errorOnInvalidContent){let d=!1,e="",f=new aj({topNode:b.spec.topNode,marks:b.spec.marks,nodes:b.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:a=>(d=!0,e="string"==typeof a?a:a.outerHTML,null)}]}})});if(c.slice?al.fromSchema(f).parseSlice(e7(a),c.parseOptions):al.fromSchema(f).parse(e7(a),c.parseOptions),c.errorOnInvalidContent&&d)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${e}`)})}let d=al.fromSchema(b);return c.slice?d.parseSlice(e7(a),c.parseOptions).content:d.parse(e7(a),c.parseOptions)}return e8("",b,c)}var e9=(a,b,c)=>({tr:d,dispatch:e,editor:f})=>{var g;if(e){let e,h;c={parseOptions:f.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...c};let i=a=>{f.emit("contentError",{editor:f,error:a,disableCollaboration:()=>{"collaboration"in f.storage&&"object"==typeof f.storage.collaboration&&f.storage.collaboration&&(f.storage.collaboration.isDisabled=!0)}})},j={preserveWhitespace:"full",...c.parseOptions};if(!c.errorOnInvalidContent&&!f.options.enableContentCheck&&f.options.emitContentError)try{e8(b,f.schema,{parseOptions:j,errorOnInvalidContent:!0})}catch(a){i(a)}try{e=e8(b,f.schema,{parseOptions:j,errorOnInvalidContent:null!=(g=c.errorOnInvalidContent)?g:f.options.enableContentCheck})}catch(a){return i(a),!1}let{from:k,to:l}="number"==typeof a?{from:a,to:a}:{from:a.from,to:a.to},m=!0,n=!0;if((!("type"in e)?e:[e]).forEach(a=>{a.check(),m=!!m&&a.isText&&0===a.marks.length,n=!!n&&a.isBlock}),k===l&&n){let{parent:a}=d.doc.resolve(k);!a.isTextblock||a.type.spec.code||a.childCount||(k-=1,l+=1)}if(m){if(Array.isArray(b))h=b.map(a=>a.text||"").join("");else if(b instanceof D){let a="";b.forEach(b=>{b.text&&(a+=b.text)}),h=a}else h="object"==typeof b&&b&&b.text?b.text:b;d.insertText(h,k,l)}else{h=e;let a=d.doc.resolve(k),b=a.node(),c=0===a.parentOffset,f=b.isText||b.isTextblock,g=b.content.size>0;c&&f&&g&&(k=Math.max(0,k-1)),d.replaceWith(k,l,h)}c.updateSelection&&function(a,b){let c=a.steps.length-1;if(c<b)return;let d=a.steps[c];if(!(d instanceof aK||d instanceof aL))return;let e=a.mapping.maps[c],f=0;e.forEach((a,b,c,d)=>{0===f&&(f=d)}),a.setSelection(a9.near(a.doc.resolve(f),-1))}(d,d.steps.length-1),c.applyInputRules&&d.setMeta("applyInputRules",{from:k,text:h}),c.applyPasteRules&&d.setMeta("applyPasteRules",{from:k,text:h})}return!0},fa=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d=c instanceof bf,e;if(d){if(c.node.isTextblock||!aU(a.doc,c.from))return!1;e=c.from}else if(null==(e=aW(a.doc,c.from,-1)))return!1;if(b){let c=a.tr.join(e);d&&c.setSelection(bf.create(c.doc,e-a.doc.resolve(e).nodeBefore.nodeSize)),b(c.scrollIntoView())}return!0})(a,b),fb=()=>({state:a,dispatch:b})=>((a,b)=>{let c=a.selection,d;if(c instanceof bf){if(c.node.isTextblock||!aU(a.doc,c.to))return!1;d=c.to}else if(null==(d=aW(a.doc,c.to,1)))return!1;return b&&b(a.tr.join(d).scrollIntoView()),!0})(a,b),fc=()=>({state:a,dispatch:b})=>bx(a,b),fd=()=>({state:a,dispatch:b})=>bD(a,b),fe=()=>({state:a,dispatch:b,tr:c})=>{try{let d=aW(a.doc,a.selection.$from.pos,-1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},ff=()=>({state:a,dispatch:b,tr:c})=>{try{let d=aW(a.doc,a.selection.$from.pos,1);if(null==d)return!1;return c.join(d,2),b&&b(c),!0}catch{return!1}},fg=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=bw(a,c);if(!d)return!1;let e=bB(d);return!!e&&by(a,e,b)})(a,b),fh=()=>({state:a,dispatch:b})=>((a,b,c)=>{let d=bC(a,c);if(!d)return!1;let e=bF(d);return!!e&&by(a,e,b)})(a,b);function fi(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var fj=a=>({editor:b,view:c,tr:d,dispatch:e})=>{let f=(function(a){let b,c,d,e,f=a.split(/-(?!$)/),g=f[f.length-1];"Space"===g&&(g=" ");for(let a=0;a<f.length-1;a+=1){let g=f[a];if(/^(cmd|meta|m)$/i.test(g))e=!0;else if(/^a(lt)?$/i.test(g))b=!0;else if(/^(c|ctrl|control)$/i.test(g))c=!0;else if(/^s(hift)?$/i.test(g))d=!0;else if(/^mod$/i.test(g))e2()||fi()?e=!0:c=!0;else throw Error(`Unrecognized modifier name: ${g}`)}return b&&(g=`Alt-${g}`),c&&(g=`Ctrl-${g}`),e&&(g=`Meta-${g}`),d&&(g=`Shift-${g}`),g})(a).split(/-(?!$)/),g=f.find(a=>!["Alt","Ctrl","Meta","Shift"].includes(a)),h=new KeyboardEvent("keydown",{key:"Space"===g?" ":g,altKey:f.includes("Alt"),ctrlKey:f.includes("Ctrl"),metaKey:f.includes("Meta"),shiftKey:f.includes("Shift"),bubbles:!0,cancelable:!0}),i=b.captureTransaction(()=>{c.someProp("handleKeyDown",a=>a(c,h))});return null==i||i.steps.forEach(a=>{let b=a.map(d.mapping);b&&e&&d.maybeStep(b)}),!0};function fk(a,b,c={}){let{from:d,to:e,empty:f}=a.selection,g=b?eM(b,a.schema):null,h=[];a.doc.nodesBetween(d,e,(a,b)=>{if(a.isText)return;let c=Math.max(d,b),f=Math.min(e,b+a.nodeSize);h.push({node:a,from:c,to:f})});let i=e-d,j=h.filter(a=>!g||g.name===a.node.type.name).filter(a=>eT(a.node.attrs,c,{strict:!1}));return f?!!j.length:j.reduce((a,b)=>a+b.to-b.from,0)>=i}var fl=(a,b={})=>({state:c,dispatch:d})=>{let e=eM(a,c.schema);return!!fk(c,e,b)&&((a,b)=>{let{$from:c,$to:d}=a.selection,e=c.blockRange(d),f=e&&aO(e);return null!=f&&(b&&b(a.tr.lift(e,f).scrollIntoView()),!0)})(c,d)},fm=()=>({state:a,dispatch:b})=>bK(a,b),fn=a=>({state:b,dispatch:c})=>{var d;return(d=eM(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);return!!f&&(!b||(c.node(f.depth-1).type==d?function(a,b,c,d){let e=a.tr,f=d.end,g=d.$to.end(d.depth);f<g&&(e.step(new aL(f-1,g,f,g,new J(D.from(c.create(null,d.parent.copy())),1,0),1,!0)),d=new U(e.doc.resolve(d.$from.pos),e.doc.resolve(g),d.depth));let h=aO(d);if(null==h)return!1;e.lift(d,h);let i=e.doc.resolve(e.mapping.map(f,-1)-1);return aU(e.doc,i.pos)&&i.nodeBefore.type==i.nodeAfter.type&&e.join(i.pos),b(e.scrollIntoView()),!0}(a,b,d,f):function(a,b,c){let d=a.tr,e=c.parent;for(let a=c.end,b=c.endIndex-1,f=c.startIndex;b>f;b--)a-=e.child(b).nodeSize,d.delete(a-1,a+1);let f=d.doc.resolve(c.start),g=f.nodeAfter;if(d.mapping.map(c.end)!=c.start+f.nodeAfter.nodeSize)return!1;let h=0==c.startIndex,i=c.endIndex==e.childCount,j=f.node(-1),k=f.index(-1);if(!j.canReplace(k+ +!h,k+1,g.content.append(i?D.empty:D.from(e))))return!1;let l=f.pos,m=l+g.nodeSize;return d.step(new aL(l-!!h,m+ +!!i,l+1,m-1,new J((h?D.empty:D.from(e.copy(D.empty))).append(i?D.empty:D.from(e.copy(D.empty))),+!h,+!i),+!h)),b(d.scrollIntoView()),!0}(a,b,f)))})(b,c)},fo=()=>({state:a,dispatch:b})=>bG(a,b);function fp(a,b){return b.nodes[a]?"node":b.marks[a]?"mark":null}function fq(a,b){let c="string"==typeof b?[b]:b;return Object.keys(a).reduce((b,d)=>(c.includes(d)||(b[d]=a[d]),b),{})}var fr=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=fp("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=eM(a,d.schema)),"mark"===h&&(g=eX(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{d.doc.nodesBetween(a.$from.pos,a.$to.pos,(a,d)=>{f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,fq(a.attrs,b))),g&&a.marks.length&&a.marks.forEach(f=>{g===f.type&&(i=!0,e&&c.addMark(d,d+a.nodeSize,g.create(fq(f.attrs,b))))})})}),i},fs=()=>({tr:a,dispatch:b})=>(b&&a.scrollIntoView(),!0),ft=()=>({tr:a,dispatch:b})=>{if(b){let b=new bh(a.doc);a.setSelection(b)}return!0},fu=()=>({state:a,dispatch:b})=>bA(a,b),fv=()=>({state:a,dispatch:b})=>bE(a,b),fw=()=>({state:a,dispatch:b})=>((a,b)=>{let{$from:c,to:d}=a.selection,e,f=c.sharedDepth(d);return 0!=f&&(e=c.before(f),b&&b(a.tr.setSelection(bf.create(a.doc,e))),!0)})(a,b),fx=()=>({state:a,dispatch:b})=>bO(a,b),fy=()=>({state:a,dispatch:b})=>bN(a,b);function fz(a,b,c={},d={}){return e8(a,b,{slice:!1,parseOptions:c,errorOnInvalidContent:d.errorOnInvalidContent})}var fA=(a,{errorOnInvalidContent:b,emitUpdate:c=!0,parseOptions:d={}}={})=>({editor:e,tr:f,dispatch:g,commands:h})=>{let{doc:i}=f;if("full"!==d.preserveWhitespace){let h=fz(a,e.schema,d,{errorOnInvalidContent:null!=b?b:e.options.enableContentCheck});return g&&f.replaceWith(0,i.content.size,h).setMeta("preventUpdate",!c),!0}return g&&f.setMeta("preventUpdate",!c),h.insertContentAt({from:0,to:i.content.size},a,{parseOptions:d,errorOnInvalidContent:null!=b?b:e.options.enableContentCheck})};function fB(a,b){let c=eX(b,a.schema),{from:d,to:e,empty:f}=a.selection,g=[];f?(a.storedMarks&&g.push(...a.storedMarks),g.push(...a.selection.$head.marks())):a.doc.nodesBetween(d,e,a=>{g.push(...a.marks)});let h=g.find(a=>a.type.name===c.name);return h?{...h.attrs}:{}}function fC(a,b){let c=new a7(a);return b.forEach(a=>{a.steps.forEach(a=>{c.step(a)})}),c}function fD(a,b){for(let c=a.depth;c>0;c-=1){let d=a.node(c);if(b(d))return{pos:c>0?a.before(c):0,start:a.start(c),depth:c,node:d}}}function fE(a){return b=>fD(b.$from,a)}function fF(a,b,c){return void 0===a.config[b]&&a.parent?fF(a.parent,b,c):"function"==typeof a.config[b]?a.config[b].bind({...c,parent:a.parent?fF(a.parent,b,c):null}):a.config[b]}function fG(a){return a.map(a=>{let b={name:a.name,options:a.options,storage:a.storage},c=fF(a,"addExtensions",b);return c?[a,...fG(c())]:a}).flat(10)}function fH(a,b){let c=au.fromSchema(b).serializeFragment(a),d=document.implementation.createHTMLDocument().createElement("div");return d.appendChild(c),d.innerHTML}function fI(a){return"function"==typeof a}function fJ(a,b,...c){return fI(a)?b?a.bind(b)(...c):a(...c):a}function fK(a){let b=a.filter(a=>"extension"===a.type);return{baseExtensions:b,nodeExtensions:a.filter(a=>"node"===a.type),markExtensions:a.filter(a=>"mark"===a.type)}}function fL(a){let b=[],{nodeExtensions:c,markExtensions:d}=fK(a),e=[...c,...d],f={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},g=c.filter(a=>"text"!==a.name).map(a=>a.name),h=d.map(a=>a.name),i=[...g,...h];return a.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage,extensions:e},d=fF(a,"addGlobalAttributes",c);d&&d().forEach(a=>{(Array.isArray(a.types)?a.types:"*"===a.types?i:"nodes"===a.types?g:"marks"===a.types?h:[]).forEach(c=>{Object.entries(a.attributes).forEach(([a,d])=>{b.push({type:c,name:a,attribute:{...f,...d}})})})})}),e.forEach(a=>{let c={name:a.name,options:a.options,storage:a.storage},d=fF(a,"addAttributes",c);d&&Object.entries(d()).forEach(([c,d])=>{let e={...f,...d};"function"==typeof(null==e?void 0:e.default)&&(e.default=e.default()),(null==e?void 0:e.isRequired)&&(null==e?void 0:e.default)===void 0&&delete e.default,b.push({type:a.name,name:c,attribute:e})})}),b}function fM(...a){return a.filter(a=>!!a).reduce((a,b)=>{let c={...a};return Object.entries(b).forEach(([a,b])=>{if(!c[a]){c[a]=b;return}if("class"===a){let d=b?String(b).split(" "):[],e=c[a]?c[a].split(" "):[],f=d.filter(a=>!e.includes(a));c[a]=[...e,...f].join(" ")}else if("style"===a){let d=b?b.split(";").map(a=>a.trim()).filter(Boolean):[],e=c[a]?c[a].split(";").map(a=>a.trim()).filter(Boolean):[],f=new Map;e.forEach(a=>{let[b,c]=a.split(":").map(a=>a.trim());f.set(b,c)}),d.forEach(a=>{let[b,c]=a.split(":").map(a=>a.trim());f.set(b,c)}),c[a]=Array.from(f.entries()).map(([a,b])=>`${a}: ${b}`).join("; ")}else c[a]=b}),c},{})}function fN(a,b){return b.filter(b=>b.type===a.type.name).filter(a=>a.attribute.rendered).map(b=>b.attribute.renderHTML?b.attribute.renderHTML(a.attrs)||{}:{[b.name]:a.attrs[b.name]}).reduce((a,b)=>fM(a,b),{})}function fO(a,b){return"style"in a?a:{...a,getAttrs:c=>{let d=a.getAttrs?a.getAttrs(c):a.attrs;if(!1===d)return!1;let e=b.reduce((a,b)=>{var d;let e=b.attribute.parseHTML?b.attribute.parseHTML(c):"string"!=typeof(d=c.getAttribute(b.name))?d:d.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(d):"true"===d||"false"!==d&&d;return null==e?a:{...a,[b.name]:e}},{});return{...d,...e}}}}function fP(a){return Object.fromEntries(Object.entries(a).filter(([a,b])=>!("attrs"===a&&function(a={}){return 0===Object.keys(a).length&&a.constructor===Object}(b))&&null!=b))}function fQ(a){var b,c;let d={};return!(null==(b=null==a?void 0:a.attribute)?void 0:b.isRequired)&&"default"in((null==a?void 0:a.attribute)||{})&&(d.default=a.attribute.default),(null==(c=null==a?void 0:a.attribute)?void 0:c.validate)!==void 0&&(d.validate=a.attribute.validate),[a.name,d]}function fR(a){return a.sort((a,b)=>{let c=fF(a,"priority")||100,d=fF(b,"priority")||100;return c>d?-1:+(c<d)})}function fS(a){var b;let c=fR(fG(a)),d=Array.from(new Set((b=c.map(a=>a.name)).filter((a,c)=>b.indexOf(a)!==c)));return d.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${d.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),c}function fT(a,b,c){let{from:d,to:e}=b,{blockSeparator:f="\n\n",textSerializers:g={}}=c||{},h="";return a.nodesBetween(d,e,(a,c,i,j)=>{var k;a.isBlock&&c>d&&(h+=f);let l=null==g?void 0:g[a.type.name];if(l)return i&&(h+=l({node:a,pos:c,parent:i,index:j,range:b})),!1;a.isText&&(h+=null==(k=null==a?void 0:a.text)?void 0:k.slice(Math.max(d,c)-c,e-c))}),h}function fU(a){return Object.fromEntries(Object.entries(a.nodes).filter(([,a])=>a.spec.toText).map(([a,b])=>[a,b.spec.toText]))}function fV(a,b){let c=fp("string"==typeof b?b:b.name,a.schema);return"node"===c?function(a,b){let c=eM(b,a.schema),{from:d,to:e}=a.selection,f=[];a.doc.nodesBetween(d,e,a=>{f.push(a)});let g=f.reverse().find(a=>a.type.name===c.name);return g?{...g.attrs}:{}}(a,b):"mark"===c?fB(a,b):{}}function fW(a){let b,{mapping:c,steps:d}=a,e=[];return c.maps.forEach((a,b)=>{let f=[];if(a.ranges.length)a.forEach((a,b)=>{f.push({from:a,to:b})});else{let{from:a,to:c}=d[b];if(void 0===a||void 0===c)return;f.push({from:a,to:c})}f.forEach(({from:a,to:d})=>{let f=c.slice(b).map(a,-1),g=c.slice(b).map(d),h=c.invert().map(f,-1),i=c.invert().map(g);e.push({oldRange:{from:h,to:i},newRange:{from:f,to:g}})})}),1===(b=function(a,b=JSON.stringify){let c={};return a.filter(a=>{let d=b(a);return!Object.prototype.hasOwnProperty.call(c,d)&&(c[d]=!0)})}(e)).length?b:b.filter((a,c)=>!b.filter((a,b)=>b!==c).some(b=>a.oldRange.from>=b.oldRange.from&&a.oldRange.to<=b.oldRange.to&&a.newRange.from>=b.newRange.from&&a.newRange.to<=b.newRange.to))}function fX(a,b,c){let d=[];return a===b?c.resolve(a).marks().forEach(b=>{let e=eW(c.resolve(a),b.type);e&&d.push({mark:b,...e})}):c.nodesBetween(a,b,(a,b)=>{a&&(null==a?void 0:a.nodeSize)!==void 0&&d.push(...a.marks.map(c=>({from:b,to:b+a.nodeSize,mark:c})))}),d}function fY(a,b){return b.nodes[a]||b.marks[a]||null}function fZ(a,b,c){return Object.fromEntries(Object.entries(c).filter(([c])=>{let d=a.find(a=>a.type===b&&a.name===c);return!!d&&d.attribute.keepOnSplit}))}function f$(a,b,c={}){let{empty:d,ranges:e}=a.selection,f=b?eX(b,a.schema):null;if(d)return!!(a.storedMarks||a.selection.$from.marks()).filter(a=>!f||f.name===a.type.name).find(a=>eT(a.attrs,c,{strict:!1}));let g=0,h=[];if(e.forEach(({$from:b,$to:c})=>{let d=b.pos,e=c.pos;a.doc.nodesBetween(d,e,(a,b)=>{if(f&&a.inlineContent&&!a.type.allowsMarkType(f))return!1;if(!a.isText&&!a.marks.length)return;let c=Math.max(d,b),i=Math.min(e,b+a.nodeSize);g+=i-c,h.push(...a.marks.map(a=>({mark:a,from:c,to:i})))})}),0===g)return!1;let i=h.filter(a=>!f||f.name===a.mark.type.name).filter(a=>eT(a.mark.attrs,c,{strict:!1})).reduce((a,b)=>a+b.to-b.from,0),j=h.filter(a=>!f||a.mark.type!==f&&a.mark.type.excludes(f)).reduce((a,b)=>a+b.to-b.from,0);return(i>0?i+j:i)>=g}function f_(a,b){return Array.isArray(b)?b.some(b=>("string"==typeof b?b:b.name)===a.name):b}function f0(a,b){let{nodeExtensions:c}=fK(b),d=c.find(b=>b.name===a);if(!d)return!1;let e={name:d.name,options:d.options,storage:d.storage},f=fJ(fF(d,"group",e));return"string"==typeof f&&f.split(" ").includes("list")}function f1(a,{checkChildren:b=!0,ignoreWhitespace:c=!1}={}){var d;if(c){if("hardBreak"===a.type.name)return!0;if(a.isText)return/^\s*$/m.test(null!=(d=a.text)?d:"")}if(a.isText)return!a.text;if(a.isAtom||a.isLeaf)return!1;if(0===a.content.childCount)return!0;if(b){let d=!0;return a.content.forEach(a=>{!1!==d&&(f1(a,{ignoreWhitespace:c,checkChildren:b})||(d=!1))}),d}return!1}function f2(a){return a instanceof bf}var f3=class a{constructor(a){this.position=a}static fromJSON(b){return new a(b.position)}toJSON(){return{position:this.position}}};function f4(a,b){let c=b.mapping.mapResult(a.position);return{position:new f3(c.pos),mapResult:c}}function f5(a){return new f3(a)}var f6=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let{selection:f}=c,{empty:g,ranges:h}=f,i=eX(a,d.schema);if(e)if(g){let a=fB(d,i);c.addStoredMark(i.create({...a,...b}))}else h.forEach(a=>{let e=a.$from.pos,f=a.$to.pos;d.doc.nodesBetween(e,f,(a,d)=>{let g=Math.max(d,e),h=Math.min(d+a.nodeSize,f);a.marks.find(a=>a.type===i)?a.marks.forEach(a=>{i===a.type&&c.addMark(g,h,i.create({...a.attrs,...b}))}):c.addMark(g,h,i.create(b))})});return function(a,b,c){var d;let{selection:e}=b,f=null;if(e$(e)&&(f=e.$cursor),f){let b=null!=(d=a.storedMarks)?d:f.marks();return f.parent.type.allowsMarkType(c)&&(!!c.isInSet(b)||!b.some(a=>a.type.excludes(c)))}let{ranges:g}=e;return g.some(({$from:b,$to:d})=>{let e=0===b.depth&&a.doc.inlineContent&&a.doc.type.allowsMarkType(c);return a.doc.nodesBetween(b.pos,d.pos,(a,b,d)=>{if(e)return!1;if(a.isInline){let b=!d||d.type.allowsMarkType(c),f=!!c.isInSet(a.marks)||!a.marks.some(a=>a.type.excludes(c));e=b&&f}return!e}),e})}(d,c,i)},f7=(a,b)=>({tr:c})=>(c.setMeta(a,b),!0),f8=(a,b={})=>({state:c,dispatch:d,chain:e})=>{let f,g=eM(a,c.schema);return(c.selection.$anchor.sameParent(c.selection.$head)&&(f=c.selection.$anchor.parent.attrs),g.isTextblock)?e().command(({commands:a})=>!!bP(g,{...f,...b})(c)||a.clearNodes()).command(({state:a})=>bP(g,{...f,...b})(a,d)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},f9=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,d=e_(a,0,c.content.size),e=bf.create(c,d);b.setSelection(e)}return!0},ga=(a,b)=>({tr:c,state:d,dispatch:e})=>{let f,g,{selection:h}=d;return"number"==typeof b?(f=b,g=b):b&&"from"in b&&"to"in b?(f=b.from,g=b.to):(f=h.from,g=h.to),e&&c.doc.nodesBetween(f,g,(b,d)=>{b.isText||c.setNodeMarkup(d,void 0,{...b.attrs,dir:a})}),!0},gb=a=>({tr:b,dispatch:c})=>{if(c){let{doc:c}=b,{from:d,to:e}="number"==typeof a?{from:a,to:a}:a,f=bd.atStart(c).from,g=bd.atEnd(c).to,h=e_(d,f,g),i=e_(e,f,g),j=bd.create(c,h,i);b.setSelection(j)}return!0},gc=a=>({state:b,dispatch:c})=>{var d;return(d=eM(a,b.schema),function(a,b){let{$from:c,$to:e}=a.selection,f=c.blockRange(e,a=>a.childCount>0&&a.firstChild.type==d);if(!f)return!1;let g=f.startIndex;if(0==g)return!1;let h=f.parent,i=h.child(g-1);if(i.type!=d)return!1;if(b){let c=i.lastChild&&i.lastChild.type==h.type,e=D.from(c?d.create():null),g=new J(D.from(d.create(null,D.from(h.type.create(null,e)))),c?3:1,0),j=f.start,k=f.end;b(a.tr.step(new aL(j-(c?3:1),k,j,k,g,1,!0)).scrollIntoView())}return!0})(b,c)};function gd(a,b){let c=a.storedMarks||a.selection.$to.parentOffset&&a.selection.$from.marks();if(c){let d=c.filter(a=>null==b?void 0:b.includes(a.type.name));a.tr.ensureMarks(d)}}var ge=({keepMarks:a=!0}={})=>({tr:b,state:c,dispatch:d,editor:e})=>{let{selection:f,doc:g}=b,{$from:h,$to:i}=f,j=fZ(e.extensionManager.attributes,h.node().type.name,h.node().attrs);if(f instanceof bf&&f.node.isBlock)return!!h.parentOffset&&!!aT(g,h.pos)&&(d&&(a&&gd(c,e.extensionManager.splittableMarks),b.split(h.pos).scrollIntoView()),!0);if(!h.parent.isBlock)return!1;let k=i.parentOffset===i.parent.content.size,l=0===h.depth?void 0:function(a){for(let b=0;b<a.edgeCount;b+=1){let{type:c}=a.edge(b);if(c.isTextblock&&!c.hasRequiredAttrs())return c}return null}(h.node(-1).contentMatchAt(h.indexAfter(-1))),m=k&&l?[{type:l,attrs:j}]:void 0,n=aT(b.doc,b.mapping.map(h.pos),1,m);if(!m&&!n&&aT(b.doc,b.mapping.map(h.pos),1,l?[{type:l}]:void 0)&&(n=!0,m=l?[{type:l,attrs:j}]:void 0),d){if(n&&(f instanceof bd&&b.deleteSelection(),b.split(b.mapping.map(h.pos),1,m),l&&!k&&!h.parentOffset&&h.parent.type!==l)){let a=b.mapping.map(h.before()),c=b.doc.resolve(a);h.node(-1).canReplaceWith(c.index(),c.index()+1,l)&&b.setNodeMarkup(b.mapping.map(h.before()),l)}a&&gd(c,e.extensionManager.splittableMarks),b.scrollIntoView()}return n},gf=(a,b={})=>({tr:c,state:d,dispatch:e,editor:f})=>{var g;let h=eM(a,d.schema),{$from:i,$to:j}=d.selection,k=d.selection.node;if(k&&k.isBlock||i.depth<2||!i.sameParent(j))return!1;let l=i.node(-1);if(l.type!==h)return!1;let m=f.extensionManager.attributes;if(0===i.parent.content.size&&i.node(-1).childCount===i.indexAfter(-1)){if(2===i.depth||i.node(-3).type!==h||i.index(-2)!==i.node(-2).childCount-1)return!1;if(e){let a=D.empty,d=i.index(-1)?1:i.index(-2)?2:3;for(let b=i.depth-d;b>=i.depth-3;b-=1)a=D.from(i.node(b).copy(a));let e=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3,f={...fZ(m,i.node().type.name,i.node().attrs),...b},j=(null==(g=h.contentMatch.defaultType)?void 0:g.createAndFill(f))||void 0;a=a.append(D.from(h.createAndFill(null,j)||void 0));let k=i.before(i.depth-(d-1));c.replace(k,i.after(-e),new J(a,4-d,0));let l=-1;c.doc.nodesBetween(k,c.doc.content.size,(a,b)=>{if(l>-1)return!1;a.isTextblock&&0===a.content.size&&(l=b+1)}),l>-1&&c.setSelection(bd.near(c.doc.resolve(l))),c.scrollIntoView()}return!0}let n=j.pos===i.end()?l.contentMatchAt(0).defaultType:null,o={...fZ(m,l.type.name,l.attrs),...b},p={...fZ(m,i.node().type.name,i.node().attrs),...b};c.delete(i.pos,j.pos);let q=n?[{type:h,attrs:o},{type:n,attrs:p}]:[{type:h,attrs:o}];if(!aT(c.doc,i.pos,2))return!1;if(e){let{selection:a,storedMarks:b}=d,{splittableMarks:g}=f.extensionManager,h=b||a.$to.parentOffset&&a.$from.marks();if(c.split(i.pos,2,q).scrollIntoView(),!h||!e)return!0;let j=h.filter(a=>g.includes(a.type.name));c.ensureMarks(j)}return!0},gg=(a,b)=>{let c=fE(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(Math.max(0,c.pos-1)).before(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&aU(a.doc,c.pos))||(a.join(c.pos),!0)},gh=(a,b)=>{let c=fE(a=>a.type===b)(a.selection);if(!c)return!0;let d=a.doc.resolve(c.start).after(c.depth);if(void 0===d)return!0;let e=a.doc.nodeAt(d);return!(c.node.type===(null==e?void 0:e.type)&&aU(a.doc,d))||(a.join(d),!0)},gi=(a,b,c,d={})=>({editor:e,tr:f,state:g,dispatch:h,chain:i,commands:j,can:k})=>{let{extensions:l,splittableMarks:m}=e.extensionManager,n=eM(a,g.schema),o=eM(b,g.schema),{selection:p,storedMarks:q}=g,{$from:r,$to:s}=p,t=r.blockRange(s),u=q||p.$to.parentOffset&&p.$from.marks();if(!t)return!1;let v=fE(a=>f0(a.type.name,l))(p);if(t.depth>=1&&v&&t.depth-v.depth<=1){if(v.node.type===n)return j.liftListItem(o);if(f0(v.node.type.name,l)&&n.validContent(v.node.content)&&h)return i().command(()=>(f.setNodeMarkup(v.pos,n),!0)).command(()=>gg(f,n)).command(()=>gh(f,n)).run()}return c&&u&&h?i().command(()=>{let a=k().wrapInList(n,d),b=u.filter(a=>m.includes(a.type.name));return f.ensureMarks(b),!!a||j.clearNodes()}).wrapInList(n,d).command(()=>gg(f,n)).command(()=>gh(f,n)).run():i().command(()=>!!k().wrapInList(n,d)||j.clearNodes()).wrapInList(n,d).command(()=>gg(f,n)).command(()=>gh(f,n)).run()},gj=(a,b={},c={})=>({state:d,commands:e})=>{let{extendEmptyMarkRange:f=!1}=c,g=eX(a,d.schema);return f$(d,g,b)?e.unsetMark(g,{extendEmptyMarkRange:f}):e.setMark(g,b)},gk=(a,b,c={})=>({state:d,commands:e})=>{let f,g=eM(a,d.schema),h=eM(b,d.schema),i=fk(d,g,c);return(d.selection.$anchor.sameParent(d.selection.$head)&&(f=d.selection.$anchor.parent.attrs),i)?e.setNode(h,f):e.setNode(g,{...f,...c})},gl=(a,b={})=>({state:c,commands:d})=>{let e=eM(a,c.schema);return fk(c,e,b)?d.lift(e):d.wrapIn(e,b)},gm=()=>({state:a,dispatch:b})=>{let c=a.plugins;for(let d=0;d<c.length;d+=1){let e,f=c[d];if(f.spec.isInputRules&&(e=f.getState(a))){if(b){let b=a.tr,c=e.transform;for(let a=c.steps.length-1;a>=0;a-=1)b.step(c.steps[a].invert(c.docs[a]));if(e.text){let c=b.doc.resolve(e.from).marks();b.replaceWith(e.from,e.to,a.schema.text(e.text,c))}else b.delete(e.from,e.to)}return!0}}return!1},gn=()=>({tr:a,dispatch:b})=>{let{selection:c}=a,{empty:d,ranges:e}=c;return!!d||(b&&e.forEach(b=>{a.removeMark(b.$from.pos,b.$to.pos)}),!0)},go=(a,b={})=>({tr:c,state:d,dispatch:e})=>{var f;let{extendEmptyMarkRange:g=!1}=b,{selection:h}=c,i=eX(a,d.schema),{$from:j,empty:k,ranges:l}=h;if(!e)return!0;if(k&&g){let{from:a,to:b}=h,d=null==(f=j.marks().find(a=>a.type===i))?void 0:f.attrs,e=eW(j,i,d);e&&(a=e.from,b=e.to),c.removeMark(a,b,i)}else l.forEach(a=>{c.removeMark(a.$from.pos,a.$to.pos,i)});return c.removeStoredMark(i),!0},gp=a=>({tr:b,state:c,dispatch:d})=>{let e,f,{selection:g}=c;return"number"==typeof a?(e=a,f=a):a&&"from"in a&&"to"in a?(e=a.from,f=a.to):(e=g.from,f=g.to),d&&b.doc.nodesBetween(e,f,(a,c)=>{if(a.isText)return;let d={...a.attrs};delete d.dir,b.setNodeMarkup(c,void 0,d)}),!0},gq=(a,b={})=>({tr:c,state:d,dispatch:e})=>{let f=null,g=null,h=fp("string"==typeof a?a:a.name,d.schema);if(!h)return!1;"node"===h&&(f=eM(a,d.schema)),"mark"===h&&(g=eX(a,d.schema));let i=!1;return c.selection.ranges.forEach(a=>{let h,j,k,l,m=a.$from.pos,n=a.$to.pos;c.selection.empty?d.doc.nodesBetween(m,n,(a,b)=>{f&&f===a.type&&(i=!0,k=Math.max(b,m),l=Math.min(b+a.nodeSize,n),h=b,j=a)}):d.doc.nodesBetween(m,n,(a,d)=>{d<m&&f&&f===a.type&&(i=!0,k=Math.max(d,m),l=Math.min(d+a.nodeSize,n),h=d,j=a),d>=m&&d<=n&&(f&&f===a.type&&(i=!0,e&&c.setNodeMarkup(d,void 0,{...a.attrs,...b})),g&&a.marks.length&&a.marks.forEach(f=>{if(g===f.type&&(i=!0,e)){let e=Math.max(d,m),h=Math.min(d+a.nodeSize,n);c.addMark(e,h,g.create({...f.attrs,...b}))}}))}),j&&(void 0!==h&&e&&c.setNodeMarkup(h,void 0,{...j.attrs,...b}),g&&j.marks.length&&j.marks.forEach(a=>{g===a.type&&e&&c.addMark(k,l,g.create({...a.attrs,...b}))}))}),i},gr=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f),h=g&&aP(g,a,b);return!!h&&(d&&d(c.tr.wrap(g,h).scrollIntoView()),!0)}})(eM(a,c.schema),b)(c,d),gs=(a,b={})=>({state:c,dispatch:d})=>(function(a,b=null){return function(c,d){let{$from:e,$to:f}=c.selection,g=e.blockRange(f);if(!g)return!1;let h=d?c.tr:null;return!!function(a,b,c,d=null){let e=!1,f=b,g=b.$from.doc;if(b.depth>=2&&b.$from.node(b.depth-1).type.compatibleContent(c)&&0==b.startIndex){if(0==b.$from.index(b.depth-1))return!1;let a=g.resolve(b.start-2);f=new U(a,a,b.depth),b.endIndex<b.parent.childCount&&(b=new U(b.$from,g.resolve(b.$to.end(b.depth)),b.depth)),e=!0}let h=aP(f,c,d,b);return!!h&&(a&&function(a,b,c,d,e){let f=D.empty;for(let a=c.length-1;a>=0;a--)f=D.from(c[a].type.create(c[a].attrs,f));a.step(new aL(b.start-2*!!d,b.end,b.start,b.end,new J(f,0,0),c.length,!0));let g=0;for(let a=0;a<c.length;a++)c[a].type==e&&(g=a+1);let h=c.length-g,i=b.start+c.length-2*!!d,j=b.parent;for(let c=b.startIndex,d=b.endIndex,e=!0;c<d;c++,e=!1)!e&&aT(a.doc,i,h)&&(a.split(i,h),i+=2*h),i+=j.child(c).nodeSize}(a,b,h,e,c),!0)}(h,g,a,b)&&(d&&d(h.scrollIntoView()),!0)}})(eM(a,c.schema),b)(c,d),gt=class{constructor(){this.callbacks={}}on(a,b){return this.callbacks[a]||(this.callbacks[a]=[]),this.callbacks[a].push(b),this}emit(a,...b){let c=this.callbacks[a];return c&&c.forEach(a=>a.apply(this,b)),this}off(a,b){let c=this.callbacks[a];return c&&(b?this.callbacks[a]=c.filter(a=>a!==b):delete this.callbacks[a]),this}once(a,b){let c=(...d)=>{this.off(a,c),b.apply(this,d)};return this.on(a,c)}removeAllListeners(){this.callbacks={}}},gu=class{constructor(a){var b;this.find=a.find,this.handler=a.handler,this.undoable=null==(b=a.undoable)||b}};function gv(a){var b;let{editor:c,from:d,to:e,text:f,rules:g,plugin:h}=a,{view:i}=c;if(i.composing)return!1;let j=i.state.doc.resolve(d);if(j.parent.type.spec.code||(null==(b=j.nodeBefore||j.nodeAfter)?void 0:b.marks.find(a=>a.type.spec.code)))return!1;let k=!1,l=((a,b=500)=>{let c="",d=a.parentOffset;return a.parent.nodesBetween(Math.max(0,d-b),d,(a,b,e,f)=>{var g,h;let i=(null==(h=(g=a.type.spec).toText)?void 0:h.call(g,{node:a,pos:b,parent:e,index:f}))||a.textContent||"%leaf%";c+=a.isAtom&&!a.isText?i:i.slice(0,Math.max(0,d-b))}),c})(j)+f;return g.forEach(a=>{if(k)return;let b=((a,b)=>{if(eS(b))return b.exec(a);let c=b(a);if(!c)return null;let d=[c.text];return d.index=c.index,d.input=a,d.data=c.data,c.replaceWith&&(c.text.includes(c.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),d.push(c.replaceWith)),d})(l,a.find);if(!b)return;let g=i.state.tr,j=eC({state:i.state,transaction:g}),m={from:d-(b[0].length-f.length),to:e},{commands:n,chain:o,can:p}=new eD({editor:c,state:j});null!==a.handler({state:j,range:m,match:b,commands:n,chain:o,can:p})&&g.steps.length&&(a.undoable&&g.setMeta(h,{transform:g,from:d,to:e,text:f}),i.dispatch(g),k=!0)}),k}function gw(a){return"Object"===Object.prototype.toString.call(a).slice(8,-1)&&a.constructor===Object&&Object.getPrototypeOf(a)===Object.prototype}var gx=class{constructor(a={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...a},this.name=this.config.name}get options(){return{...fJ(fF(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...fJ(fF(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(a={}){let b=this.extend({...this.config,addOptions:()=>(function a(b,c){let d={...b};return gw(b)&&gw(c)&&Object.keys(c).forEach(e=>{gw(c[e])&&gw(b[e])?d[e]=a(b[e],c[e]):d[e]=c[e]}),d})(this.options,a)});return b.name=this.name,b.parent=this.parent,b}extend(a={}){let b=new this.constructor({...this.config,...a});return b.parent=this,this.child=b,b.name="name"in a?a.name:b.parent.name,b}},gy=class a extends gx{constructor(){super(...arguments),this.type="mark"}static create(b={}){return new a("function"==typeof b?b():b)}static handleExit({editor:a,mark:b}){let{tr:c}=a.state,d=a.state.selection.$from;if(d.pos===d.end()){let e=d.marks();if(!e.find(a=>(null==a?void 0:a.type.name)===b.name))return!1;let f=e.find(a=>(null==a?void 0:a.type.name)===b.name);return f&&c.removeStoredMark(f),c.insertText(" ",d.pos),a.view.dispatch(c),!0}return!1}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},gz=class{constructor(a){this.find=a.find,this.handler=a.handler}},gA=null,gB=class{constructor(a,b){this.splittableMarks=[],this.editor=b,this.baseExtensions=a,this.extensions=fS(a),this.schema=function(a,b){var c;let d=fL(a),{nodeExtensions:e,markExtensions:f}=fK(a),g=null==(c=e.find(a=>fF(a,"topNode")))?void 0:c.name;return new aj({topNode:g,nodes:Object.fromEntries(e.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=fP({...a.reduce((a,b)=>{let d=fF(b,"extendNodeSchema",f);return{...a,...d?d(c):{}}},{}),content:fJ(fF(c,"content",f)),marks:fJ(fF(c,"marks",f)),group:fJ(fF(c,"group",f)),inline:fJ(fF(c,"inline",f)),atom:fJ(fF(c,"atom",f)),selectable:fJ(fF(c,"selectable",f)),draggable:fJ(fF(c,"draggable",f)),code:fJ(fF(c,"code",f)),whitespace:fJ(fF(c,"whitespace",f)),linebreakReplacement:fJ(fF(c,"linebreakReplacement",f)),defining:fJ(fF(c,"defining",f)),isolating:fJ(fF(c,"isolating",f)),attrs:Object.fromEntries(e.map(fQ))}),h=fJ(fF(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>fO(a,e)));let i=fF(c,"renderHTML",f);i&&(g.toDOM=a=>i({node:a,HTMLAttributes:fN(a,e)}));let j=fF(c,"renderText",f);return j&&(g.toText=j),[c.name,g]})),marks:Object.fromEntries(f.map(c=>{let e=d.filter(a=>a.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:b},g=fP({...a.reduce((a,b)=>{let d=fF(b,"extendMarkSchema",f);return{...a,...d?d(c):{}}},{}),inclusive:fJ(fF(c,"inclusive",f)),excludes:fJ(fF(c,"excludes",f)),group:fJ(fF(c,"group",f)),spanning:fJ(fF(c,"spanning",f)),code:fJ(fF(c,"code",f)),attrs:Object.fromEntries(e.map(fQ))}),h=fJ(fF(c,"parseHTML",f));h&&(g.parseDOM=h.map(a=>fO(a,e)));let i=fF(c,"renderHTML",f);return i&&(g.toDOM=a=>i({mark:a,HTMLAttributes:fN(a,e)})),[c.name,g]}))})}(this.extensions,b),this.setupExtensions()}get commands(){return this.extensions.reduce((a,b)=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:this.editor,type:fY(b.name,this.schema)},d=fF(b,"addCommands",c);return d?{...a,...d()}:a},{})}get plugins(){let{editor:a}=this;return fR([...this.extensions].reverse()).flatMap(b=>{let c={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:fY(b.name,this.schema)},d=[],e=fF(b,"addKeyboardShortcuts",c),f={};if("mark"===b.type&&fF(b,"exitable",c)&&(f.ArrowRight=()=>gy.handleExit({editor:a,mark:b})),e){let b=Object.fromEntries(Object.entries(e()).map(([b,c])=>[b,()=>c({editor:a})]));f={...f,...b}}let g=new br({props:{handleKeyDown:ez(f)}});d.push(g);let h=fF(b,"addInputRules",c);if(f_(b,a.options.enableInputRules)&&h){let b=h();if(b&&b.length){let c=function(a){let{editor:b,rules:c}=a,d=new br({state:{init:()=>null,apply(a,e,f){let g=a.getMeta(d);if(g)return g;let h=a.getMeta("applyInputRules");return h&&setTimeout(()=>{let{text:a}=h;"string"==typeof a||(a=fH(D.from(a),f.schema));let{from:e}=h,g=e+a.length;gv({editor:b,from:e,to:g,text:a,rules:c,plugin:d})}),a.selectionSet||a.docChanged?null:e}},props:{handleTextInput:(a,e,f,g)=>gv({editor:b,from:e,to:f,text:g,rules:c,plugin:d}),handleDOMEvents:{compositionend:a=>(setTimeout(()=>{let{$cursor:e}=a.state.selection;e&&gv({editor:b,from:e.pos,to:e.pos,text:"",rules:c,plugin:d})}),!1)},handleKeyDown(a,e){if("Enter"!==e.key)return!1;let{$cursor:f}=a.state.selection;return!!f&&gv({editor:b,from:f.pos,to:f.pos,text:"\n",rules:c,plugin:d})}},isInputRules:!0});return d}({editor:a,rules:b}),e=Array.isArray(c)?c:[c];d.push(...e)}}let i=fF(b,"addPasteRules",c);if(f_(b,a.options.enablePasteRules)&&i){let b=i();if(b&&b.length){let c=function(a){let b,{editor:c,rules:d}=a,e=null,f=!1,g=!1,h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}let i=({state:a,from:d,to:e,rule:f,pasteEvt:g})=>{let i=a.tr;if(function(a){let{editor:b,state:c,from:d,to:e,rule:f,pasteEvent:g,dropEvent:h}=a,{commands:i,chain:j,can:k}=new eD({editor:b,state:c}),l=[];return c.doc.nodesBetween(d,e,(a,b)=>{var m,n,o,p,q;if((null==(n=null==(m=a.type)?void 0:m.spec)?void 0:n.code)||!(a.isText||a.isTextblock||a.isInline))return;let r=null!=(q=null!=(p=null==(o=a.content)?void 0:o.size)?p:a.nodeSize)?q:0,s=Math.max(d,b),t=Math.min(e,b+r);s>=t||((a,b,c)=>{if(eS(b))return[...a.matchAll(b)];let d=b(a,c);return d?d.map(b=>{let c=[b.text];return c.index=b.index,c.input=a,c.data=b.data,b.replaceWith&&(b.text.includes(b.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),c.push(b.replaceWith)),c}):[]})(a.isText?a.text||"":a.textBetween(s-b,t-b,void 0,""),f.find,g).forEach(a=>{if(void 0===a.index)return;let b=s+a.index+1,d=b+a[0].length,e={from:c.tr.mapping.map(b),to:c.tr.mapping.map(d)},m=f.handler({state:c,range:e,match:a,commands:i,chain:j,can:k,pasteEvent:g,dropEvent:h});l.push(m)})}),l.every(a=>null!==a)}({editor:c,state:eC({state:a,transaction:i}),from:Math.max(d-1,0),to:e.b-1,rule:f,pasteEvent:g,dropEvent:b})&&i.steps.length){try{b="u">typeof DragEvent?new DragEvent("drop"):null}catch{b=null}return h="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,i}};return d.map(a=>new br({view(a){let b=b=>{var d;(e=(null==(d=a.dom.parentElement)?void 0:d.contains(b.target))?a.dom.parentElement:null)&&(gA=c)},d=()=>{gA&&(gA=null)};return window.addEventListener("dragstart",b),window.addEventListener("dragend",d),{destroy(){window.removeEventListener("dragstart",b),window.removeEventListener("dragend",d)}}},props:{handleDOMEvents:{drop:(a,c)=>{if(g=e===a.dom.parentElement,b=c,!g){let a=gA;(null==a?void 0:a.isEditable)&&setTimeout(()=>{let b=a.state.selection;b&&a.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(a,b)=>{var c;let d=null==(c=b.clipboardData)?void 0:c.getData("text/html");return h=b,f=!!(null==d?void 0:d.includes("data-pm-slice")),!1}}},appendTransaction:(b,c,d)=>{let e=b[0],j="paste"===e.getMeta("uiEvent")&&!f,k="drop"===e.getMeta("uiEvent")&&!g,l=e.getMeta("applyPasteRules"),m=!!l;if(!j&&!k&&!m)return;if(m){var n,o;let b,{text:c}=l;"string"==typeof c||(c=fH(D.from(c),d.schema));let{from:e}=l,f=e+c.length;return i({rule:a,state:d,from:e,to:{b:f},pasteEvt:(n=c,null==(o=(b=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||o.setData("text/html",n),b)})}let p=c.doc.content.findDiffStart(d.doc.content),q=c.doc.content.findDiffEnd(d.doc.content);if("number"==typeof p&&q&&p!==q.b)return i({rule:a,state:d,from:p,to:q,pasteEvt:h})}}))}({editor:a,rules:b});d.push(...c)}}let j=fF(b,"addProseMirrorPlugins",c);if(j){let a=j();d.push(...a)}return d})}get attributes(){return fL(this.extensions)}get nodeViews(){let{editor:a}=this,{nodeExtensions:b}=fK(this.extensions);return Object.fromEntries(b.filter(a=>!!fF(a,"addNodeView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:eM(b.name,this.schema)},e=fF(b,"addNodeView",d);if(!e)return[];let f=e();return f?[b.name,(d,e,g,h,i)=>{let j=fN(d,c);return f({node:d,view:e,getPos:g,decorations:h,innerDecorations:i,editor:a,extension:b,HTMLAttributes:j})}]:[]}))}dispatchTransaction(a){let{editor:b}=this;return fR([...this.extensions].reverse()).reduceRight((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:fY(c.name,this.schema)},e=fF(c,"dispatchTransaction",d);return e?b=>{e.call(d,{transaction:b,next:a})}:a},a)}transformPastedHTML(a){let{editor:b}=this;return fR([...this.extensions]).reduce((a,c)=>{let d={name:c.name,options:c.options,storage:this.editor.extensionStorage[c.name],editor:b,type:fY(c.name,this.schema)},e=fF(c,"transformPastedHTML",d);return e?(b,c)=>{let f=a(b,c);return e.call(d,f)}:a},a||(a=>a))}get markViews(){let{editor:a}=this,{markExtensions:b}=fK(this.extensions);return Object.fromEntries(b.filter(a=>!!fF(a,"addMarkView")).map(b=>{let c=this.attributes.filter(a=>a.type===b.name),d={name:b.name,options:b.options,storage:this.editor.extensionStorage[b.name],editor:a,type:eX(b.name,this.schema)},e=fF(b,"addMarkView",d);return e?[b.name,(d,f,g)=>{let h=fN(d,c);return e()({mark:d,view:f,inline:g,editor:a,extension:b,HTMLAttributes:h,updateAttributes:b=>{!function(a,b,c={}){let{state:d}=b,{doc:e,tr:f}=d;e.descendants((b,d)=>{let e=f.mapping.map(d),g=f.mapping.map(d)+b.nodeSize,h=null;if(b.marks.forEach(b=>{if(b!==a)return!1;h=b}),!h)return;let i=!1;if(Object.keys(c).forEach(a=>{c[a]!==h.attrs[a]&&(i=!0)}),i){let b=a.type.create({...a.attrs,...c});f.removeMark(e,g,a.type),f.addMark(e,g,b)}}),f.docChanged&&b.view.dispatch(f)}(d,a,b)}})}]:[]}))}setupExtensions(){let a=this.extensions;this.editor.extensionStorage=Object.fromEntries(a.map(a=>[a.name,a.storage])),a.forEach(a=>{var b;let c={name:a.name,options:a.options,storage:this.editor.extensionStorage[a.name],editor:this.editor,type:fY(a.name,this.schema)};"mark"===a.type&&(null==(b=fJ(fF(a,"keepOnSplit",c)))||b)&&this.splittableMarks.push(a.name);let d=fF(a,"onBeforeCreate",c),e=fF(a,"onCreate",c),f=fF(a,"onUpdate",c),g=fF(a,"onSelectionUpdate",c),h=fF(a,"onTransaction",c),i=fF(a,"onFocus",c),j=fF(a,"onBlur",c),k=fF(a,"onDestroy",c);d&&this.editor.on("beforeCreate",d),e&&this.editor.on("create",e),f&&this.editor.on("update",f),g&&this.editor.on("selectionUpdate",g),h&&this.editor.on("transaction",h),i&&this.editor.on("focus",i),j&&this.editor.on("blur",j),k&&this.editor.on("destroy",k)})}};gB.resolve=fS,gB.sort=fR,gB.flatten=fG;var gC={};eB(gC,{ClipboardTextSerializer:()=>gE,Commands:()=>gF,Delete:()=>gG,Drop:()=>gH,Editable:()=>gI,FocusEvents:()=>gK,Keymap:()=>gL,Paste:()=>gM,Tabindex:()=>gN,TextDirection:()=>gO,focusEventsPluginKey:()=>gJ});var gD=class a extends gx{constructor(){super(...arguments),this.type="extension"}static create(b={}){return new a("function"==typeof b?b():b)}configure(a){return super.configure(a)}extend(a){let b="function"==typeof a?a():a;return super.extend(b)}},gE=gD.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new br({key:new bu("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:a}=this,{state:b,schema:c}=a,{doc:d,selection:e}=b,{ranges:f}=e,g=Math.min(...f.map(a=>a.$from.pos)),h=Math.max(...f.map(a=>a.$to.pos)),i=fU(c);return fT(d,{from:g,to:h},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:i})}}})]}}),gF=gD.create({name:"commands",addCommands:()=>({...eE})}),gG=gD.create({name:"delete",onUpdate({transaction:a,appendedTransactions:b}){var c,d,e;let f=()=>{var c,d,e,f;if(null!=(f=null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.filterTransaction)?void 0:e.call(d,a))?f:a.getMeta("y-sync$"))return;let g=fC(a.before,[a,...b]);fW(g).forEach(b=>{g.mapping.mapResult(b.oldRange.from).deletedAfter&&g.mapping.mapResult(b.oldRange.to).deletedBefore&&g.before.nodesBetween(b.oldRange.from,b.oldRange.to,(c,d)=>{let e=d+c.nodeSize-2,f=b.oldRange.from<=d&&e<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:c,from:d,to:e,newFrom:g.mapping.map(d),newTo:g.mapping.map(e),deletedRange:b.oldRange,newRange:b.newRange,partial:!f,editor:this.editor,transaction:a,combinedTransform:g})})});let h=g.mapping;g.steps.forEach((b,c)=>{var d,e;if(b instanceof aH){let f=h.slice(c).map(b.from,-1),i=h.slice(c).map(b.to),j=h.invert().map(f,-1),k=h.invert().map(i),l=null==(d=g.doc.nodeAt(f-1))?void 0:d.marks.some(a=>a.eq(b.mark)),m=null==(e=g.doc.nodeAt(i))?void 0:e.marks.some(a=>a.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:j,to:k},newRange:{from:f,to:i},partial:!!(m||l),editor:this.editor,transaction:a,combinedTransform:g})}})};null==(e=null==(d=null==(c=this.editor.options.coreExtensionOptions)?void 0:c.delete)?void 0:d.async)||e?setTimeout(f,0):f()}}),gH=gD.create({name:"drop",addProseMirrorPlugins(){return[new br({key:new bu("tiptapDrop"),props:{handleDrop:(a,b,c,d)=>{this.editor.emit("drop",{editor:this.editor,event:b,slice:c,moved:d})}}})]}}),gI=gD.create({name:"editable",addProseMirrorPlugins(){return[new br({key:new bu("editable"),props:{editable:()=>this.editor.options.editable}})]}}),gJ=new bu("focusEvents"),gK=gD.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:a}=this;return[new br({key:gJ,props:{handleDOMEvents:{focus:(b,c)=>{a.isFocused=!0;let d=a.state.tr.setMeta("focus",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1},blur:(b,c)=>{a.isFocused=!1;let d=a.state.tr.setMeta("blur",{event:c}).setMeta("addToHistory",!1);return b.dispatch(d),!1}}}})]}}),gL=gD.create({name:"keymap",addKeyboardShortcuts(){let a=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:b})=>{let{selection:c,doc:d}=b,{empty:e,$anchor:f}=c,{pos:g,parent:h}=f,i=f.parent.isTextblock&&g>0?b.doc.resolve(g-1):f,j=i.parent.type.spec.isolating,k=f.pos-f.parentOffset,l=j&&1===i.parent.childCount?k===f.pos:a9.atStart(d).from===g;return!!e&&!!h.type.isTextblock&&!h.textContent.length&&!!l&&(!l||"paragraph"!==f.parent.type.name)&&a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),b=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),c={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:a,"Mod-Backspace":a,"Shift-Backspace":a,Delete:b,"Mod-Delete":b,"Mod-a":()=>this.editor.commands.selectAll()},d={...c},e={...c,"Ctrl-h":a,"Alt-Backspace":a,"Ctrl-d":b,"Ctrl-Alt-Backspace":b,"Alt-Delete":b,"Alt-d":b,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return e2()||fi()?e:d},addProseMirrorPlugins(){return[new br({key:new bu("clearDocument"),appendTransaction:(a,b,c)=>{if(a.some(a=>a.getMeta("composition")))return;let d=a.some(a=>a.docChanged)&&!b.doc.eq(c.doc),e=a.some(a=>a.getMeta("preventClearDocument"));if(!d||e)return;let{empty:f,from:g,to:h}=b.selection,i=a9.atStart(b.doc).from,j=a9.atEnd(b.doc).to;if(f||g!==i||h!==j||!f1(c.doc))return;let k=c.tr,l=eC({state:c,transaction:k}),{commands:m}=new eD({editor:this.editor,state:l});if(m.clearNodes(),k.steps.length)return k}})]}}),gM=gD.create({name:"paste",addProseMirrorPlugins(){return[new br({key:new bu("tiptapPaste"),props:{handlePaste:(a,b,c)=>{this.editor.emit("paste",{editor:this.editor,event:b,slice:c})}}})]}}),gN=gD.create({name:"tabindex",addProseMirrorPlugins(){return[new br({key:new bu("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),gO=gD.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:a}=fK(this.extensions);return[{types:a.filter(a=>"text"!==a.name).map(a=>a.name),attributes:{dir:{default:this.options.direction,parseHTML:a=>{let b=a.getAttribute("dir");return b&&("ltr"===b||"rtl"===b||"auto"===b)?b:this.options.direction},renderHTML:a=>a.dir?{dir:a.dir}:{}}}}]},addProseMirrorPlugins(){return[new br({key:new bu("textDirection"),props:{attributes:()=>{let a=this.options.direction;return a?{dir:a}:{}}}})]}}),gP=class a{constructor(a,b,c=!1,d=null){this.currentNode=null,this.actualDepth=null,this.isBlock=c,this.resolvedPos=a,this.editor=b,this.currentNode=d}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var a;return null!=(a=this.actualDepth)?a:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(a){let b=this.from,c=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);b=this.from+1,c=this.to-1}this.editor.commands.insertContentAt({from:b,to:c},a)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(0===this.depth)return null;let b=this.resolvedPos.start(this.resolvedPos.depth-1);return new a(this.resolvedPos.doc.resolve(b),this.editor)}get before(){let b=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.from-3)),new a(b,this.editor)}get after(){let b=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return b.depth!==this.depth&&(b=this.resolvedPos.doc.resolve(this.to+3)),new a(b,this.editor)}get children(){let b=[];return this.node.content.forEach((c,d)=>{let e=c.isBlock&&!c.isTextblock,f=c.isAtom&&!c.isText,g=c.isInline,h=this.pos+d+ +!f;if(h<0||h>this.resolvedPos.doc.nodeSize-2)return;let i=this.resolvedPos.doc.resolve(h);if(!e&&!g&&i.depth<=this.depth)return;let j=new a(i,this.editor,e,e||g?c:null);e&&(j.actualDepth=this.depth+1),b.push(j)}),b}get firstChild(){return this.children[0]||null}get lastChild(){let a=this.children;return a[a.length-1]||null}closest(a,b={}){let c=null,d=this.parent;for(;d&&!c;){if(d.node.type.name===a)if(Object.keys(b).length>0){let a=d.node.attrs,c=Object.keys(b);for(let d=0;d<c.length;d+=1){let e=c[d];if(a[e]!==b[e])break}}else c=d;d=d.parent}return c}querySelector(a,b={}){return this.querySelectorAll(a,b,!0)[0]||null}querySelectorAll(a,b={},c=!1){let d=[];if(!this.children||0===this.children.length)return d;let e=Object.keys(b);return this.children.forEach(f=>{c&&d.length>0||(f.node.type.name===a&&e.every(a=>b[a]===f.node.attrs[a])&&d.push(f),c&&d.length>0||(d=d.concat(f.querySelectorAll(a,b,c))))}),d}setAttribute(a){let{tr:b}=this.editor.state;b.setNodeMarkup(this.from,void 0,{...this.node.attrs,...a}),this.editor.view.dispatch(b)}},gQ=`.ProseMirror {
3
2
  position: relative;
4
3
  }
5
4
 
@@ -94,4 +93,5 @@ ${b.slice(j+2)}`,l+=1;else break}b.push({indent:j,number:parseInt(h,10),content:
94
93
  `},mC.image=function(a,b,c,d,e){let f=a[b];return f.attrs[f.attrIndex("alt")][1]=e.renderInlineAsText(f.children,c,d),e.renderToken(a,b,c)},mC.hardbreak=function(a,b,c){return c.xhtmlOut?"<br />\n":"<br>\n"},mC.softbreak=function(a,b,c){return c.breaks?c.xhtmlOut?"<br />\n":"<br>\n":"\n"},mC.text=function(a,b){return mq(a[b].content)},mC.html_block=function(a,b){return a[b].content},mC.html_inline=function(a,b){return a[b].content},mD.prototype.renderAttrs=function(a){let b,c,d;if(!a.attrs)return"";for(b=0,d="",c=a.attrs.length;b<c;b++)d+=" "+mq(a.attrs[b][0])+'="'+mq(a.attrs[b][1])+'"';return d},mD.prototype.renderToken=function(a,b,c){let d=a[b],e="";if(d.hidden)return"";d.block&&-1!==d.nesting&&b&&a[b-1].hidden&&(e+="\n"),e+=(-1===d.nesting?"</":"<")+d.tag,e+=this.renderAttrs(d),0===d.nesting&&c.xhtmlOut&&(e+=" /");let f=!1;if(d.block&&(f=!0,1===d.nesting&&b+1<a.length)){let c=a[b+1];"inline"===c.type||c.hidden?f=!1:-1===c.nesting&&c.tag===d.tag&&(f=!1)}return e+(f?">\n":">")},mD.prototype.renderInline=function(a,b,c){let d="",e=this.rules;for(let f=0,g=a.length;f<g;f++){let g=a[f].type;void 0!==e[g]?d+=e[g](a,f,b,c,this):d+=this.renderToken(a,f,b)}return d},mD.prototype.renderInlineAsText=function(a,b,c){let d="";for(let e=0,f=a.length;e<f;e++)switch(a[e].type){case"text":case"html_inline":case"html_block":d+=a[e].content;break;case"image":d+=this.renderInlineAsText(a[e].children,b,c);break;case"softbreak":case"hardbreak":d+="\n"}return d},mD.prototype.render=function(a,b,c){let d="",e=this.rules;for(let f=0,g=a.length;f<g;f++){let g=a[f].type;"inline"===g?d+=this.renderInline(a[f].children,b,c):void 0!==e[g]?d+=e[g](a,f,b,c,this):d+=this.renderToken(a,f,b,c)}return d},mE.prototype.__find__=function(a){for(let b=0;b<this.__rules__.length;b++)if(this.__rules__[b].name===a)return b;return -1},mE.prototype.__compile__=function(){let a=this,b=[""];a.__rules__.forEach(function(a){a.enabled&&a.alt.forEach(function(a){0>b.indexOf(a)&&b.push(a)})}),a.__cache__={},b.forEach(function(b){a.__cache__[b]=[],a.__rules__.forEach(function(c){!c.enabled||b&&0>c.alt.indexOf(b)||a.__cache__[b].push(c.fn)})})},mE.prototype.at=function(a,b,c){let d=this.__find__(a);if(-1===d)throw Error("Parser rule not found: "+a);this.__rules__[d].fn=b,this.__rules__[d].alt=(c||{}).alt||[],this.__cache__=null},mE.prototype.before=function(a,b,c,d){let e=this.__find__(a);if(-1===e)throw Error("Parser rule not found: "+a);this.__rules__.splice(e,0,{name:b,enabled:!0,fn:c,alt:(d||{}).alt||[]}),this.__cache__=null},mE.prototype.after=function(a,b,c,d){let e=this.__find__(a);if(-1===e)throw Error("Parser rule not found: "+a);this.__rules__.splice(e+1,0,{name:b,enabled:!0,fn:c,alt:(d||{}).alt||[]}),this.__cache__=null},mE.prototype.push=function(a,b,c){this.__rules__.push({name:a,enabled:!0,fn:b,alt:(c||{}).alt||[]}),this.__cache__=null},mE.prototype.enable=function(a,b){Array.isArray(a)||(a=[a]);let c=[];return a.forEach(function(a){let d=this.__find__(a);if(d<0){if(b)return;throw Error("Rules manager: invalid rule name "+a)}this.__rules__[d].enabled=!0,c.push(a)},this),this.__cache__=null,c},mE.prototype.enableOnly=function(a,b){Array.isArray(a)||(a=[a]),this.__rules__.forEach(function(a){a.enabled=!1}),this.enable(a,b)},mE.prototype.disable=function(a,b){Array.isArray(a)||(a=[a]);let c=[];return a.forEach(function(a){let d=this.__find__(a);if(d<0){if(b)return;throw Error("Rules manager: invalid rule name "+a)}this.__rules__[d].enabled=!1,c.push(a)},this),this.__cache__=null,c},mE.prototype.getRules=function(a){return null===this.__cache__&&this.__compile__(),this.__cache__[a]||[]},mF.prototype.attrIndex=function(a){if(!this.attrs)return -1;let b=this.attrs;for(let c=0,d=b.length;c<d;c++)if(b[c][0]===a)return c;return -1},mF.prototype.attrPush=function(a){this.attrs?this.attrs.push(a):this.attrs=[a]},mF.prototype.attrSet=function(a,b){let c=this.attrIndex(a),d=[a,b];c<0?this.attrPush(d):this.attrs[c]=d},mF.prototype.attrGet=function(a){let b=this.attrIndex(a),c=null;return b>=0&&(c=this.attrs[b][1]),c},mF.prototype.attrJoin=function(a,b){let c=this.attrIndex(a);c<0?this.attrPush([a,b]):this.attrs[c][1]=this.attrs[c][1]+" "+b},mG.prototype.Token=mF;let mH=/\r\n?|\n/g,mI=/\0/g,mJ=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,mK=/\((c|tm|r)\)/i,mL=/\((c|tm|r)\)/ig,mM={c:"\xa9",r:"\xae",tm:"™"};function mN(a,b){return mM[b.toLowerCase()]}let mO=/['"]/,mP=/['"]/g;function mQ(a,b,c){return a.slice(0,b)+c+a.slice(b+1)}let mR=[["normalize",function(a){let b;b=(b=a.src.replace(mH,"\n")).replace(mI,"�"),a.src=b}],["block",function(a){let b;a.inlineMode?((b=new a.Token("inline","",0)).content=a.src,b.map=[0,1],b.children=[],a.tokens.push(b)):a.md.block.parse(a.src,a.md,a.env,a.tokens)}],["inline",function(a){let b=a.tokens;for(let c=0,d=b.length;c<d;c++){let d=b[c];"inline"===d.type&&a.md.inline.parse(d.content,a.md,a.env,d.children)}}],["linkify",function(a){let b=a.tokens;if(a.md.options.linkify)for(let e=0,f=b.length;e<f;e++){if("inline"!==b[e].type||!a.md.linkify.pretest(b[e].content))continue;let f=b[e].children,g=0;for(let h=f.length-1;h>=0;h--){let i=f[h];if("link_close"===i.type){for(h--;f[h].level!==i.level&&"link_open"!==f[h].type;)h--;continue}if("html_inline"===i.type){var c,d;c=i.content,/^<a[>\s]/i.test(c)&&g>0&&g--,d=i.content,/^<\/a\s*>/i.test(d)&&g++}if(!(g>0)&&"text"===i.type&&a.md.linkify.test(i.content)){let c=i.content,d=a.md.linkify.match(c),g=[],j=i.level,k=0;d.length>0&&0===d[0].index&&h>0&&"text_special"===f[h-1].type&&(d=d.slice(1));for(let b=0;b<d.length;b++){let e=d[b].url,f=a.md.normalizeLink(e);if(!a.md.validateLink(f))continue;let h=d[b].text;h=d[b].schema?"mailto:"!==d[b].schema||/^mailto:/i.test(h)?a.md.normalizeLinkText(h):a.md.normalizeLinkText("mailto:"+h).replace(/^mailto:/,""):a.md.normalizeLinkText("http://"+h).replace(/^http:\/\//,"");let i=d[b].index;if(i>k){let b=new a.Token("text","",0);b.content=c.slice(k,i),b.level=j,g.push(b)}let l=new a.Token("link_open","a",1);l.attrs=[["href",f]],l.level=j++,l.markup="linkify",l.info="auto",g.push(l);let m=new a.Token("text","",0);m.content=h,m.level=j,g.push(m);let n=new a.Token("link_close","a",-1);n.level=--j,n.markup="linkify",n.info="auto",g.push(n),k=d[b].lastIndex}if(k<c.length){let b=new a.Token("text","",0);b.content=c.slice(k),b.level=j,g.push(b)}b[e].children=f=me(f,h,g)}}}}],["replacements",function(a){let b;if(a.md.options.typographer)for(b=a.tokens.length-1;b>=0;b--)"inline"===a.tokens[b].type&&(mK.test(a.tokens[b].content)&&function(a){let b=0;for(let c=a.length-1;c>=0;c--){let d=a[c];"text"!==d.type||b||(d.content=d.content.replace(mL,mN)),"link_open"===d.type&&"auto"===d.info&&b--,"link_close"===d.type&&"auto"===d.info&&b++}}(a.tokens[b].children),mJ.test(a.tokens[b].content)&&function(a){let b=0;for(let c=a.length-1;c>=0;c--){let d=a[c];"text"===d.type&&!b&&mJ.test(d.content)&&(d.content=d.content.replace(/\+-/g,"\xb1").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1—").replace(/(^|\s)--(?=\s|$)/mg,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1–")),"link_open"===d.type&&"auto"===d.info&&b--,"link_close"===d.type&&"auto"===d.info&&b++}}(a.tokens[b].children))}],["smartquotes",function(a){if(a.md.options.typographer)for(let b=a.tokens.length-1;b>=0;b--)"inline"===a.tokens[b].type&&mO.test(a.tokens[b].content)&&function(a,b){let c,d=[];for(let e=0;e<a.length;e++){let f=a[e],g=a[e].level;for(c=d.length-1;c>=0&&!(d[c].level<=g);c--);if(d.length=c+1,"text"!==f.type)continue;let h=f.content,i=0,j=h.length;e:for(;i<j;){mP.lastIndex=i;let k=mP.exec(h);if(!k)break;let l=!0,m=!0;i=k.index+1;let n="'"===k[0],o=32;if(k.index-1>=0)o=h.charCodeAt(k.index-1);else for(c=e-1;c>=0&&"softbreak"!==a[c].type&&"hardbreak"!==a[c].type;c--)if(a[c].content){o=a[c].content.charCodeAt(a[c].content.length-1);break}let p=32;if(i<j)p=h.charCodeAt(i);else for(c=e+1;c<a.length&&"softbreak"!==a[c].type&&"hardbreak"!==a[c].type;c++)if(a[c].content){p=a[c].content.charCodeAt(0);break}let q=mw(o)||mv(String.fromCharCode(o)),r=mw(p)||mv(String.fromCharCode(p)),s=mu(o),t=mu(p);if(t?l=!1:r&&!(s||q)&&(l=!1),s?m=!1:q&&!(t||r)&&(m=!1),34===p&&'"'===k[0]&&o>=48&&o<=57&&(m=l=!1),l&&m&&(l=q,m=r),!l&&!m){n&&(f.content=mQ(f.content,k.index,"’"));continue}if(m)for(c=d.length-1;c>=0;c--){let l=d[c];if(d[c].level<g)break;if(l.single===n&&d[c].level===g){let g,m;l=d[c],n?(g=b.md.options.quotes[2],m=b.md.options.quotes[3]):(g=b.md.options.quotes[0],m=b.md.options.quotes[1]),f.content=mQ(f.content,k.index,m),a[l.token].content=mQ(a[l.token].content,l.pos,g),i+=m.length-1,l.token===e&&(i+=g.length-1),j=(h=f.content).length,d.length=c;continue e}}l?d.push({token:e,pos:k.index,single:n,level:g}):m&&n&&(f.content=mQ(f.content,k.index,"’"))}}}(a.tokens[b].children,a)}],["text_join",function(a){let b,c,d=a.tokens,e=d.length;for(let a=0;a<e;a++){if("inline"!==d[a].type)continue;let e=d[a].children,f=e.length;for(b=0;b<f;b++)"text_special"===e[b].type&&(e[b].type="text");for(b=c=0;b<f;b++)"text"===e[b].type&&b+1<f&&"text"===e[b+1].type?e[b+1].content=e[b].content+e[b+1].content:(b!==c&&(e[c]=e[b]),c++);b!==c&&(e.length=c)}}]];function mS(){this.ruler=new mE;for(let a=0;a<mR.length;a++)this.ruler.push(mR[a][0],mR[a][1])}function mT(a,b,c,d){this.src=a,this.md=b,this.env=c,this.tokens=d,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;let e=this.src;for(let a=0,b=0,c=0,d=0,f=e.length,g=!1;b<f;b++){let h=e.charCodeAt(b);if(!g)if(mt(h)){c++,9===h?d+=4-d%4:d++;continue}else g=!0;(10===h||b===f-1)&&(10!==h&&b++,this.bMarks.push(a),this.eMarks.push(b),this.tShift.push(c),this.sCount.push(d),this.bsCount.push(0),g=!1,c=0,d=0,a=b+1)}this.bMarks.push(e.length),this.eMarks.push(e.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}function mU(a,b){let c=a.bMarks[b]+a.tShift[b],d=a.eMarks[b];return a.src.slice(c,d)}function mV(a){let b=[],c=a.length,d=0,e=a.charCodeAt(d),f=!1,g=0,h="";for(;d<c;)124===e&&(f?(h+=a.substring(g,d-1),g=d):(b.push(h+a.substring(g,d)),h="",g=d+1)),f=92===e,d++,e=a.charCodeAt(d);return b.push(h+a.substring(g)),b}function mW(a,b){let c=a.eMarks[b],d=a.bMarks[b]+a.tShift[b],e=a.src.charCodeAt(d++);return 42!==e&&45!==e&&43!==e||d<c&&!mt(a.src.charCodeAt(d))?-1:d}function mX(a,b){let c=a.bMarks[b]+a.tShift[b],d=a.eMarks[b],e=c;if(e+1>=d)return -1;let f=a.src.charCodeAt(e++);if(f<48||f>57)return -1;for(;;){if(e>=d)return -1;if((f=a.src.charCodeAt(e++))>=48&&f<=57){if(e-c>=10)return -1;continue}if(41===f||46===f)break;return -1}return e<d&&!mt(f=a.src.charCodeAt(e))?-1:e}mS.prototype.process=function(a){let b=this.ruler.getRules("");for(let c=0,d=b.length;c<d;c++)b[c](a)},mS.prototype.State=mG,mT.prototype.push=function(a,b,c){let d=new mF(a,b,c);return d.block=!0,c<0&&this.level--,d.level=this.level,c>0&&this.level++,this.tokens.push(d),d},mT.prototype.isEmpty=function(a){return this.bMarks[a]+this.tShift[a]>=this.eMarks[a]},mT.prototype.skipEmptyLines=function(a){for(let b=this.lineMax;a<b&&!(this.bMarks[a]+this.tShift[a]<this.eMarks[a]);a++);return a},mT.prototype.skipSpaces=function(a){for(let b=this.src.length;a<b&&mt(this.src.charCodeAt(a));a++);return a},mT.prototype.skipSpacesBack=function(a,b){if(a<=b)return a;for(;a>b;)if(!mt(this.src.charCodeAt(--a)))return a+1;return a},mT.prototype.skipChars=function(a,b){for(let c=this.src.length;a<c&&this.src.charCodeAt(a)===b;a++);return a},mT.prototype.skipCharsBack=function(a,b,c){if(a<=c)return a;for(;a>c;)if(b!==this.src.charCodeAt(--a))return a+1;return a},mT.prototype.getLines=function(a,b,c,d){if(a>=b)return"";let e=Array(b-a);for(let f=0,g=a;g<b;g++,f++){let a,h=0,i=this.bMarks[g],j=i;for(a=g+1<b||d?this.eMarks[g]+1:this.eMarks[g];j<a&&h<c;){let a=this.src.charCodeAt(j);if(mt(a))9===a?h+=4-(h+this.bsCount[g])%4:h++;else if(j-i<this.tShift[g])h++;else break;j++}h>c?e[f]=Array(h-c+1).join(" ")+this.src.slice(j,a):e[f]=this.src.slice(j,a)}return e.join("")},mT.prototype.Token=mF;let mY="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",mZ="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",m$=RegExp("^(?:"+mY+"|"+mZ+"|\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)"),m_=RegExp("^(?:"+mY+"|"+mZ+")"),m0=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[RegExp("^</?(address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?=(\\s|/?>|$))","i"),/^$/,!0],[RegExp(m_.source+"\\s*$"),/^$/,!1]],m1=[["table",function(a,b,c,d){let e;if(b+2>c)return!1;let f=b+1;if(a.sCount[f]<a.blkIndent||a.sCount[f]-a.blkIndent>=4)return!1;let g=a.bMarks[f]+a.tShift[f];if(g>=a.eMarks[f])return!1;let h=a.src.charCodeAt(g++);if(124!==h&&45!==h&&58!==h||g>=a.eMarks[f])return!1;let i=a.src.charCodeAt(g++);if(124!==i&&45!==i&&58!==i&&!mt(i)||45===h&&mt(i))return!1;for(;g<a.eMarks[f];){let b=a.src.charCodeAt(g);if(124!==b&&45!==b&&58!==b&&!mt(b))return!1;g++}let j=mU(a,b+1),k=j.split("|"),l=[];for(let a=0;a<k.length;a++){let b=k[a].trim();if(!b)if(0===a||a===k.length-1)continue;else return!1;if(!/^:?-+:?$/.test(b))return!1;58===b.charCodeAt(b.length-1)?l.push(58===b.charCodeAt(0)?"center":"right"):58===b.charCodeAt(0)?l.push("left"):l.push("")}if(-1===(j=mU(a,b).trim()).indexOf("|")||a.sCount[b]-a.blkIndent>=4)return!1;(k=mV(j)).length&&""===k[0]&&k.shift(),k.length&&""===k[k.length-1]&&k.pop();let m=k.length;if(0===m||m!==l.length)return!1;if(d)return!0;let n=a.parentType;a.parentType="table";let o=a.md.block.ruler.getRules("blockquote"),p=a.push("table_open","table",1),q=[b,0];p.map=q,a.push("thead_open","thead",1).map=[b,b+1],a.push("tr_open","tr",1).map=[b,b+1];for(let b=0;b<k.length;b++){let c=a.push("th_open","th",1);l[b]&&(c.attrs=[["style","text-align:"+l[b]]]);let d=a.push("inline","",0);d.content=k[b].trim(),d.children=[],a.push("th_close","th",-1)}a.push("tr_close","tr",-1),a.push("thead_close","thead",-1);let r=0;for(f=b+2;f<c&&!(a.sCount[f]<a.blkIndent);f++){let d=!1;for(let b=0,e=o.length;b<e;b++)if(o[b](a,f,c,!0)){d=!0;break}if(d||!(j=mU(a,f).trim())||a.sCount[f]-a.blkIndent>=4||((k=mV(j)).length&&""===k[0]&&k.shift(),k.length&&""===k[k.length-1]&&k.pop(),(r+=m-k.length)>65536))break;f===b+2&&(a.push("tbody_open","tbody",1).map=e=[b+2,0]),a.push("tr_open","tr",1).map=[f,f+1];for(let b=0;b<m;b++){let c=a.push("td_open","td",1);l[b]&&(c.attrs=[["style","text-align:"+l[b]]]);let d=a.push("inline","",0);d.content=k[b]?k[b].trim():"",d.children=[],a.push("td_close","td",-1)}a.push("tr_close","tr",-1)}return e&&(a.push("tbody_close","tbody",-1),e[1]=f),a.push("table_close","table",-1),q[1]=f,a.parentType=n,a.line=f,!0},["paragraph","reference"]],["code",function(a,b,c){if(a.sCount[b]-a.blkIndent<4)return!1;let d=b+1,e=d;for(;d<c;){if(a.isEmpty(d)){d++;continue}if(a.sCount[d]-a.blkIndent>=4){e=++d;continue}break}a.line=e;let f=a.push("code_block","code",0);return f.content=a.getLines(b,e,4+a.blkIndent,!1)+"\n",f.map=[b,a.line],!0}],["fence",function(a,b,c,d){let e=a.bMarks[b]+a.tShift[b],f=a.eMarks[b];if(a.sCount[b]-a.blkIndent>=4||e+3>f)return!1;let g=a.src.charCodeAt(e);if(126!==g&&96!==g)return!1;let h=e,i=(e=a.skipChars(e,g))-h;if(i<3)return!1;let j=a.src.slice(h,e),k=a.src.slice(e,f);if(96===g&&k.indexOf(String.fromCharCode(g))>=0)return!1;if(d)return!0;let l=b,m=!1;for(;!(++l>=c)&&(!((e=h=a.bMarks[l]+a.tShift[l])<(f=a.eMarks[l]))||!(a.sCount[l]<a.blkIndent));){;if(!(a.src.charCodeAt(e)!==g||a.sCount[l]-a.blkIndent>=4||(e=a.skipChars(e,g))-h<i)&&!((e=a.skipSpaces(e))<f)){m=!0;break}}i=a.sCount[b],a.line=l+ +!!m;let n=a.push("fence","code",0);return n.info=k,n.content=a.getLines(b+1,l,i,!0),n.markup=j,n.map=[b,a.line],!0},["paragraph","reference","blockquote","list"]],["blockquote",function(a,b,c,d){let e,f=a.bMarks[b]+a.tShift[b],g=a.eMarks[b],h=a.lineMax;if(a.sCount[b]-a.blkIndent>=4||62!==a.src.charCodeAt(f))return!1;if(d)return!0;let i=[],j=[],k=[],l=[],m=a.md.block.ruler.getRules("blockquote"),n=a.parentType;a.parentType="blockquote";let o=!1;for(e=b;e<c;e++){let b=a.sCount[e]<a.blkIndent;if((f=a.bMarks[e]+a.tShift[e])>=(g=a.eMarks[e]))break;if(62===a.src.charCodeAt(f++)&&!b){let b,c,d=a.sCount[e]+1;32===a.src.charCodeAt(f)?(f++,d++,c=!1,b=!0):9===a.src.charCodeAt(f)?(b=!0,(a.bsCount[e]+d)%4==3?(f++,d++,c=!1):c=!0):b=!1;let h=d;for(i.push(a.bMarks[e]),a.bMarks[e]=f;f<g;){let b=a.src.charCodeAt(f);if(mt(b))9===b?h+=4-(h+a.bsCount[e]+ +!!c)%4:h++;else break;f++}o=f>=g,j.push(a.bsCount[e]),a.bsCount[e]=a.sCount[e]+1+ +!!b,k.push(a.sCount[e]),a.sCount[e]=h-d,l.push(a.tShift[e]),a.tShift[e]=f-a.bMarks[e];continue}if(o)break;let d=!1;for(let b=0,f=m.length;b<f;b++)if(m[b](a,e,c,!0)){d=!0;break}if(d){a.lineMax=e,0!==a.blkIndent&&(i.push(a.bMarks[e]),j.push(a.bsCount[e]),l.push(a.tShift[e]),k.push(a.sCount[e]),a.sCount[e]-=a.blkIndent);break}i.push(a.bMarks[e]),j.push(a.bsCount[e]),l.push(a.tShift[e]),k.push(a.sCount[e]),a.sCount[e]=-1}let p=a.blkIndent;a.blkIndent=0;let q=a.push("blockquote_open","blockquote",1);q.markup=">";let r=[b,0];q.map=r,a.md.block.tokenize(a,b,e),a.push("blockquote_close","blockquote",-1).markup=">",a.lineMax=h,a.parentType=n,r[1]=a.line;for(let c=0;c<l.length;c++)a.bMarks[c+b]=i[c],a.tShift[c+b]=l[c],a.sCount[c+b]=k[c],a.bsCount[c+b]=j[c];return a.blkIndent=p,!0},["paragraph","reference","blockquote","list"]],["hr",function(a,b,c,d){let e=a.eMarks[b];if(a.sCount[b]-a.blkIndent>=4)return!1;let f=a.bMarks[b]+a.tShift[b],g=a.src.charCodeAt(f++);if(42!==g&&45!==g&&95!==g)return!1;let h=1;for(;f<e;){let b=a.src.charCodeAt(f++);if(b!==g&&!mt(b))return!1;b===g&&h++}if(h<3)return!1;if(d)return!0;a.line=b+1;let i=a.push("hr","hr",0);return i.map=[b,a.line],i.markup=Array(h+1).join(String.fromCharCode(g)),!0},["paragraph","reference","blockquote","list"]],["list",function(a,b,c,d){let e,f,g,h,i,j,k,l=b,m=!0;if(a.sCount[l]-a.blkIndent>=4||a.listIndent>=0&&a.sCount[l]-a.listIndent>=4&&a.sCount[l]<a.blkIndent)return!1;let n=!1;if(d&&"paragraph"===a.parentType&&a.sCount[l]>=a.blkIndent&&(n=!0),(k=mX(a,l))>=0){if(i=!0,g=a.bMarks[l]+a.tShift[l],j=Number(a.src.slice(g,k-1)),n&&1!==j)return!1}else{if(!((k=mW(a,l))>=0))return!1;i=!1}if(n&&a.skipSpaces(k)>=a.eMarks[l])return!1;if(d)return!0;let o=a.src.charCodeAt(k-1),p=a.tokens.length;i?(h=a.push("ordered_list_open","ol",1),1!==j&&(h.attrs=[["start",j]])):h=a.push("bullet_list_open","ul",1);let q=[l,0];h.map=q,h.markup=String.fromCharCode(o);let r=!1,s=a.md.block.ruler.getRules("list"),t=a.parentType;for(a.parentType="list";l<c;){let b;f=k,e=a.eMarks[l];let d=a.sCount[l]+k-(a.bMarks[l]+a.tShift[l]),j=d;for(;f<e;){let b=a.src.charCodeAt(f);if(9===b)j+=4-(j+a.bsCount[l])%4;else if(32===b)j++;else break;f++}let n=f;(b=n>=e?1:j-d)>4&&(b=1);let p=d+b;(h=a.push("list_item_open","li",1)).markup=String.fromCharCode(o);let q=[l,0];h.map=q,i&&(h.info=a.src.slice(g,k-1));let t=a.tight,u=a.tShift[l],v=a.sCount[l],w=a.listIndent;if(a.listIndent=a.blkIndent,a.blkIndent=p,a.tight=!0,a.tShift[l]=n-a.bMarks[l],a.sCount[l]=j,n>=e&&a.isEmpty(l+1)?a.line=Math.min(a.line+2,c):a.md.block.tokenize(a,l,c,!0),(!a.tight||r)&&(m=!1),r=a.line-l>1&&a.isEmpty(a.line-1),a.blkIndent=a.listIndent,a.listIndent=w,a.tShift[l]=u,a.sCount[l]=v,a.tight=t,(h=a.push("list_item_close","li",-1)).markup=String.fromCharCode(o),l=a.line,q[1]=l,l>=c||a.sCount[l]<a.blkIndent||a.sCount[l]-a.blkIndent>=4)break;let x=!1;for(let b=0,d=s.length;b<d;b++)if(s[b](a,l,c,!0)){x=!0;break}if(x)break;if(i){if((k=mX(a,l))<0)break;g=a.bMarks[l]+a.tShift[l]}else if((k=mW(a,l))<0)break;if(o!==a.src.charCodeAt(k-1))break}return(h=i?a.push("ordered_list_close","ol",-1):a.push("bullet_list_close","ul",-1)).markup=String.fromCharCode(o),q[1]=l,a.line=l,a.parentType=t,m&&function(a,b){let c=a.level+2;for(let d=b+2,e=a.tokens.length-2;d<e;d++)a.tokens[d].level===c&&"paragraph_open"===a.tokens[d].type&&(a.tokens[d+2].hidden=!0,a.tokens[d].hidden=!0,d+=2)}(a,p),!0},["paragraph","reference","blockquote"]],["reference",function(a,b,c,d){let e,f=a.bMarks[b]+a.tShift[b],g=a.eMarks[b],h=b+1;if(a.sCount[b]-a.blkIndent>=4||91!==a.src.charCodeAt(f))return!1;function i(b){let c=a.lineMax;if(b>=c||a.isEmpty(b))return null;let d=!1;if(a.sCount[b]-a.blkIndent>3&&(d=!0),a.sCount[b]<0&&(d=!0),!d){let d=a.md.block.ruler.getRules("reference"),e=a.parentType;a.parentType="reference";let f=!1;for(let e=0,g=d.length;e<g;e++)if(d[e](a,b,c,!0)){f=!0;break}if(a.parentType=e,f)return null}let e=a.bMarks[b]+a.tShift[b],f=a.eMarks[b];return a.src.slice(e,f+1)}let j=a.src.slice(f,g+1);g=j.length;let k=-1;for(f=1;f<g;f++){let a=j.charCodeAt(f);if(91===a)return!1;if(93===a){k=f;break}if(10===a){let a=i(h);null!==a&&(j+=a,g=j.length,h++)}else if(92===a&&++f<g&&10===j.charCodeAt(f)){let a=i(h);null!==a&&(j+=a,g=j.length,h++)}}if(k<0||58!==j.charCodeAt(k+1))return!1;for(f=k+2;f<g;f++){let a=j.charCodeAt(f);if(10===a){let a=i(h);null!==a&&(j+=a,g=j.length,h++)}else if(mt(a));else break}let l=a.md.helpers.parseLinkDestination(j,f,g);if(!l.ok)return!1;let m=a.md.normalizeLink(l.str);if(!a.md.validateLink(m))return!1;let n=f=l.pos,o=h,p=f;for(;f<g;f++){let a=j.charCodeAt(f);if(10===a){let a=i(h);null!==a&&(j+=a,g=j.length,h++)}else if(mt(a));else break}let q=a.md.helpers.parseLinkTitle(j,f,g);for(;q.can_continue;){let b=i(h);if(null===b)break;j+=b,f=g,g=j.length,h++,q=a.md.helpers.parseLinkTitle(j,f,g,q)}for(f<g&&p!==f&&q.ok?(e=q.str,f=q.pos):(e="",f=n,h=o);f<g&&mt(j.charCodeAt(f));)f++;if(f<g&&10!==j.charCodeAt(f)&&e)for(e="",f=n,h=o;f<g&&mt(j.charCodeAt(f));)f++;if(f<g&&10!==j.charCodeAt(f))return!1;let r=mx(j.slice(1,k));return!!r&&(!!d||(void 0===a.env.references&&(a.env.references={}),void 0===a.env.references[r]&&(a.env.references[r]={title:e,href:m}),a.line=h,!0))}],["html_block",function(a,b,c,d){let e=a.bMarks[b]+a.tShift[b],f=a.eMarks[b];if(a.sCount[b]-a.blkIndent>=4||!a.md.options.html||60!==a.src.charCodeAt(e))return!1;let g=a.src.slice(e,f),h=0;for(;h<m0.length&&!m0[h][0].test(g);h++);if(h===m0.length)return!1;if(d)return m0[h][2];let i=b+1;if(!m0[h][1].test(g)){for(;i<c&&!(a.sCount[i]<a.blkIndent);i++)if(e=a.bMarks[i]+a.tShift[i],f=a.eMarks[i],g=a.src.slice(e,f),m0[h][1].test(g)){0!==g.length&&i++;break}}a.line=i;let j=a.push("html_block","",0);return j.map=[b,i],j.content=a.getLines(b,i,a.blkIndent,!0),!0},["paragraph","reference","blockquote"]],["heading",function(a,b,c,d){let e=a.bMarks[b]+a.tShift[b],f=a.eMarks[b];if(a.sCount[b]-a.blkIndent>=4)return!1;let g=a.src.charCodeAt(e);if(35!==g||e>=f)return!1;let h=1;for(g=a.src.charCodeAt(++e);35===g&&e<f&&h<=6;)h++,g=a.src.charCodeAt(++e);if(h>6||e<f&&!mt(g))return!1;if(d)return!0;f=a.skipSpacesBack(f,e);let i=a.skipCharsBack(f,35,e);i>e&&mt(a.src.charCodeAt(i-1))&&(f=i),a.line=b+1;let j=a.push("heading_open","h"+String(h),1);j.markup="########".slice(0,h),j.map=[b,a.line];let k=a.push("inline","",0);return k.content=a.src.slice(e,f).trim(),k.map=[b,a.line],k.children=[],a.push("heading_close","h"+String(h),-1).markup="########".slice(0,h),!0},["paragraph","reference","blockquote"]],["lheading",function(a,b,c){let d,e=a.md.block.ruler.getRules("paragraph");if(a.sCount[b]-a.blkIndent>=4)return!1;let f=a.parentType;a.parentType="paragraph";let g=0,h=b+1;for(;h<c&&!a.isEmpty(h);h++){if(a.sCount[h]-a.blkIndent>3)continue;if(a.sCount[h]>=a.blkIndent){let b=a.bMarks[h]+a.tShift[h],c=a.eMarks[h];if(b<c&&(45===(d=a.src.charCodeAt(b))||61===d)&&(b=a.skipChars(b,d),(b=a.skipSpaces(b))>=c)){g=61===d?1:2;break}}if(a.sCount[h]<0)continue;let b=!1;for(let d=0,f=e.length;d<f;d++)if(e[d](a,h,c,!0)){b=!0;break}if(b)break}if(!g)return!1;let i=a.getLines(b,h,a.blkIndent,!1).trim();a.line=h+1;let j=a.push("heading_open","h"+String(g),1);j.markup=String.fromCharCode(d),j.map=[b,a.line];let k=a.push("inline","",0);return k.content=i,k.map=[b,a.line-1],k.children=[],a.push("heading_close","h"+String(g),-1).markup=String.fromCharCode(d),a.parentType=f,!0}],["paragraph",function(a,b,c){let d=a.md.block.ruler.getRules("paragraph"),e=a.parentType,f=b+1;for(a.parentType="paragraph";f<c&&!a.isEmpty(f);f++){if(a.sCount[f]-a.blkIndent>3||a.sCount[f]<0)continue;let b=!1;for(let e=0,g=d.length;e<g;e++)if(d[e](a,f,c,!0)){b=!0;break}if(b)break}let g=a.getLines(b,f,a.blkIndent,!1).trim();a.line=f,a.push("paragraph_open","p",1).map=[b,a.line];let h=a.push("inline","",0);return h.content=g,h.map=[b,a.line],h.children=[],a.push("paragraph_close","p",-1),a.parentType=e,!0}]];function m2(){this.ruler=new mE;for(let a=0;a<m1.length;a++)this.ruler.push(m1[a][0],m1[a][1],{alt:(m1[a][2]||[]).slice()})}function m3(a,b,c,d){this.src=a,this.env=c,this.md=b,this.tokens=d,this.tokens_meta=Array(d.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}m2.prototype.tokenize=function(a,b,c){let d=this.ruler.getRules(""),e=d.length,f=a.md.options.maxNesting,g=b,h=!1;for(;g<c&&(a.line=g=a.skipEmptyLines(g),!(g>=c)&&!(a.sCount[g]<a.blkIndent));){if(a.level>=f){a.line=c;break}let b=a.line,i=!1;for(let f=0;f<e;f++)if(i=d[f](a,g,c,!1)){if(b>=a.line)throw Error("block rule didn't increment state.line");break}if(!i)throw Error("none of the block rules matched");a.tight=!h,a.isEmpty(a.line-1)&&(h=!0),(g=a.line)<c&&a.isEmpty(g)&&(h=!0,a.line=++g)}},m2.prototype.parse=function(a,b,c,d){if(!a)return;let e=new this.State(a,b,c,d);this.tokenize(e,e.line,e.lineMax)},m2.prototype.State=mT,m3.prototype.pushPending=function(){let a=new mF("text","",0);return a.content=this.pending,a.level=this.pendingLevel,this.tokens.push(a),this.pending="",a},m3.prototype.push=function(a,b,c){this.pending&&this.pushPending();let d=new mF(a,b,c),e=null;return c<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),d.level=this.level,c>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],e={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(d),this.tokens_meta.push(e),d},m3.prototype.scanDelims=function(a,b){let c=this.posMax,d=this.src.charCodeAt(a),e=a>0?this.src.charCodeAt(a-1):32,f=a;for(;f<c&&this.src.charCodeAt(f)===d;)f++;let g=f-a,h=f<c?this.src.charCodeAt(f):32,i=mw(e)||mv(String.fromCharCode(e)),j=mw(h)||mv(String.fromCharCode(h)),k=mu(e),l=mu(h),m=!l&&(!j||k||i),n=!k&&(!i||l||j);return{can_open:m&&(b||!n||i),can_close:n&&(b||!m||j),length:g}},m3.prototype.Token=mF;let m4=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i,m5=[];for(let a=0;a<256;a++)m5.push(0);function m6(a,b){let c,d=[],e=b.length;for(let f=0;f<e;f++){let e=b[f];if(126!==e.marker||-1===e.end)continue;let g=b[e.end];(c=a.tokens[e.token]).type="s_open",c.tag="s",c.nesting=1,c.markup="~~",c.content="",(c=a.tokens[g.token]).type="s_close",c.tag="s",c.nesting=-1,c.markup="~~",c.content="","text"===a.tokens[g.token-1].type&&"~"===a.tokens[g.token-1].content&&d.push(g.token-1)}for(;d.length;){let b=d.pop(),e=b+1;for(;e<a.tokens.length&&"s_close"===a.tokens[e].type;)e++;b!==--e&&(c=a.tokens[e],a.tokens[e]=a.tokens[b],a.tokens[b]=c)}}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(a){m5[a.charCodeAt(0)]=1});function m7(a,b){let c=b.length;for(let d=c-1;d>=0;d--){let c=b[d];if(95!==c.marker&&42!==c.marker||-1===c.end)continue;let e=b[c.end],f=d>0&&b[d-1].end===c.end+1&&b[d-1].marker===c.marker&&b[d-1].token===c.token-1&&b[c.end+1].token===e.token+1,g=String.fromCharCode(c.marker),h=a.tokens[c.token];h.type=f?"strong_open":"em_open",h.tag=f?"strong":"em",h.nesting=1,h.markup=f?g+g:g,h.content="";let i=a.tokens[e.token];i.type=f?"strong_close":"em_close",i.tag=f?"strong":"em",i.nesting=-1,i.markup=f?g+g:g,i.content="",f&&(a.tokens[b[d-1].token].content="",a.tokens[b[c.end+1].token].content="",d--)}}let m8=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,m9=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/,na=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,nb=/^&([a-z][a-z0-9]{1,31});/i;function nc(a){let b={},c=a.length;if(!c)return;let d=0,e=-2,f=[];for(let g=0;g<c;g++){let c=a[g];if(f.push(0),(a[d].marker!==c.marker||e!==c.token-1)&&(d=g),e=c.token,c.length=c.length||0,!c.close)continue;b.hasOwnProperty(c.marker)||(b[c.marker]=[-1,-1,-1,-1,-1,-1]);let h=b[c.marker][3*!!c.open+c.length%3],i=d-f[d]-1,j=i;for(;i>h;i-=f[i]+1){let b=a[i];if(b.marker===c.marker&&b.open&&b.end<0){let d=!1;if((b.close||c.open)&&(b.length+c.length)%3==0&&(b.length%3!=0||c.length%3!=0)&&(d=!0),!d){let d=i>0&&!a[i-1].open?f[i-1]+1:0;f[g]=g-i+d,f[i]=d,c.open=!1,b.end=g,b.close=!1,j=-1,e=-2;break}}}-1!==j&&(b[c.marker][3*!!c.open+(c.length||0)%3]=j)}}let nd=[["text",function(a,b){let c=a.pos;for(;c<a.posMax&&!function(a){switch(a){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}(a.src.charCodeAt(c));)c++;return c!==a.pos&&(b||(a.pending+=a.src.slice(a.pos,c)),a.pos=c,!0)}],["linkify",function(a,b){if(!a.md.options.linkify||a.linkLevel>0)return!1;let c=a.pos;if(c+3>a.posMax||58!==a.src.charCodeAt(c)||47!==a.src.charCodeAt(c+1)||47!==a.src.charCodeAt(c+2))return!1;let d=a.pending.match(m4);if(!d)return!1;let e=d[1],f=a.md.linkify.matchAtStart(a.src.slice(c-e.length));if(!f)return!1;let g=f.url;if(g.length<=e.length)return!1;let h=g.length;for(;h>0&&42===g.charCodeAt(h-1);)h--;h!==g.length&&(g=g.slice(0,h));let i=a.md.normalizeLink(g);if(!a.md.validateLink(i))return!1;if(!b){a.pending=a.pending.slice(0,-e.length);let b=a.push("link_open","a",1);b.attrs=[["href",i]],b.markup="linkify",b.info="auto",a.push("text","",0).content=a.md.normalizeLinkText(g);let c=a.push("link_close","a",-1);c.markup="linkify",c.info="auto"}return a.pos+=g.length-e.length,!0}],["newline",function(a,b){let c=a.pos;if(10!==a.src.charCodeAt(c))return!1;let d=a.pending.length-1,e=a.posMax;if(!b)if(d>=0&&32===a.pending.charCodeAt(d))if(d>=1&&32===a.pending.charCodeAt(d-1)){let b=d-1;for(;b>=1&&32===a.pending.charCodeAt(b-1);)b--;a.pending=a.pending.slice(0,b),a.push("hardbreak","br",0)}else a.pending=a.pending.slice(0,-1),a.push("softbreak","br",0);else a.push("softbreak","br",0);for(c++;c<e&&mt(a.src.charCodeAt(c));)c++;return a.pos=c,!0}],["escape",function(a,b){let c=a.pos,d=a.posMax;if(92!==a.src.charCodeAt(c)||++c>=d)return!1;let e=a.src.charCodeAt(c);if(10===e){for(b||a.push("hardbreak","br",0),c++;c<d&&mt(e=a.src.charCodeAt(c));)c++;return a.pos=c,!0}let f=a.src[c];if(e>=55296&&e<=56319&&c+1<d){let b=a.src.charCodeAt(c+1);b>=56320&&b<=57343&&(f+=a.src[c+1],c++)}let g="\\"+f;if(!b){let b=a.push("text_special","",0);e<256&&0!==m5[e]?b.content=f:b.content=g,b.markup=g,b.info="escape"}return a.pos=c+1,!0}],["backticks",function(a,b){let c,d=a.pos;if(96!==a.src.charCodeAt(d))return!1;let e=d;d++;let f=a.posMax;for(;d<f&&96===a.src.charCodeAt(d);)d++;let g=a.src.slice(e,d),h=g.length;if(a.backticksScanned&&(a.backticks[h]||0)<=e)return b||(a.pending+=g),a.pos+=h,!0;let i=d;for(;-1!==(c=a.src.indexOf("`",i));){for(i=c+1;i<f&&96===a.src.charCodeAt(i);)i++;let e=i-c;if(e===h){if(!b){let b=a.push("code_inline","code",0);b.markup=g,b.content=a.src.slice(d,c).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return a.pos=i,!0}a.backticks[e]=c}return a.backticksScanned=!0,b||(a.pending+=g),a.pos+=h,!0}],["strikethrough",function(a,b){let c=a.pos,d=a.src.charCodeAt(c);if(b||126!==d)return!1;let e=a.scanDelims(a.pos,!0),f=e.length,g=String.fromCharCode(d);if(f<2)return!1;f%2&&(a.push("text","",0).content=g,f--);for(let b=0;b<f;b+=2)a.push("text","",0).content=g+g,a.delimiters.push({marker:d,length:0,token:a.tokens.length-1,end:-1,open:e.can_open,close:e.can_close});return a.pos+=e.length,!0}],["emphasis",function(a,b){let c=a.pos,d=a.src.charCodeAt(c);if(b||95!==d&&42!==d)return!1;let e=a.scanDelims(a.pos,42===d);for(let b=0;b<e.length;b++)a.push("text","",0).content=String.fromCharCode(d),a.delimiters.push({marker:d,length:e.length,token:a.tokens.length-1,end:-1,open:e.can_open,close:e.can_close});return a.pos+=e.length,!0}],["link",function(a,b){let c,d,e,f,g="",h="",i=a.pos,j=!0;if(91!==a.src.charCodeAt(a.pos))return!1;let k=a.pos,l=a.posMax,m=a.pos+1,n=a.md.helpers.parseLinkLabel(a,a.pos,!0);if(n<0)return!1;let o=n+1;if(o<l&&40===a.src.charCodeAt(o)){for(j=!1,o++;o<l&&(mt(c=a.src.charCodeAt(o))||10===c);o++);if(o>=l)return!1;if(i=o,(e=a.md.helpers.parseLinkDestination(a.src,o,a.posMax)).ok){for(g=a.md.normalizeLink(e.str),a.md.validateLink(g)?o=e.pos:g="",i=o;o<l&&(mt(c=a.src.charCodeAt(o))||10===c);o++);if(e=a.md.helpers.parseLinkTitle(a.src,o,a.posMax),o<l&&i!==o&&e.ok)for(h=e.str,o=e.pos;o<l&&(mt(c=a.src.charCodeAt(o))||10===c);o++);}(o>=l||41!==a.src.charCodeAt(o))&&(j=!0),o++}if(j){if(void 0===a.env.references)return!1;if(o<l&&91===a.src.charCodeAt(o)?(i=o+1,(o=a.md.helpers.parseLinkLabel(a,o))>=0?d=a.src.slice(i,o++):o=n+1):o=n+1,d||(d=a.src.slice(m,n)),!(f=a.env.references[mx(d)]))return a.pos=k,!1;g=f.href,h=f.title}if(!b){a.pos=m,a.posMax=n;let b=a.push("link_open","a",1),c=[["href",g]];b.attrs=c,h&&c.push(["title",h]),a.linkLevel++,a.md.inline.tokenize(a),a.linkLevel--,a.push("link_close","a",-1)}return a.pos=o,a.posMax=l,!0}],["image",function(a,b){let c,d,e,f,g,h,i,j,k="",l=a.pos,m=a.posMax;if(33!==a.src.charCodeAt(a.pos)||91!==a.src.charCodeAt(a.pos+1))return!1;let n=a.pos+2,o=a.md.helpers.parseLinkLabel(a,a.pos+1,!1);if(o<0)return!1;if((f=o+1)<m&&40===a.src.charCodeAt(f)){for(f++;f<m&&(mt(c=a.src.charCodeAt(f))||10===c);f++);if(f>=m)return!1;for(j=f,(h=a.md.helpers.parseLinkDestination(a.src,f,a.posMax)).ok&&(k=a.md.normalizeLink(h.str),a.md.validateLink(k)?f=h.pos:k=""),j=f;f<m&&(mt(c=a.src.charCodeAt(f))||10===c);f++);if(h=a.md.helpers.parseLinkTitle(a.src,f,a.posMax),f<m&&j!==f&&h.ok)for(i=h.str,f=h.pos;f<m&&(mt(c=a.src.charCodeAt(f))||10===c);f++);else i="";if(f>=m||41!==a.src.charCodeAt(f))return a.pos=l,!1;f++}else{if(void 0===a.env.references)return!1;if(f<m&&91===a.src.charCodeAt(f)?(j=f+1,(f=a.md.helpers.parseLinkLabel(a,f))>=0?e=a.src.slice(j,f++):f=o+1):f=o+1,e||(e=a.src.slice(n,o)),!(g=a.env.references[mx(e)]))return a.pos=l,!1;k=g.href,i=g.title}if(!b){d=a.src.slice(n,o);let b=[];a.md.inline.parse(d,a.md,a.env,b);let c=a.push("image","img",0),e=[["src",k],["alt",""]];c.attrs=e,c.children=b,c.content=d,i&&e.push(["title",i])}return a.pos=f,a.posMax=m,!0}],["autolink",function(a,b){let c=a.pos;if(60!==a.src.charCodeAt(c))return!1;let d=a.pos,e=a.posMax;for(;;){if(++c>=e)return!1;let b=a.src.charCodeAt(c);if(60===b)return!1;if(62===b)break}let f=a.src.slice(d+1,c);if(m9.test(f)){let c=a.md.normalizeLink(f);if(!a.md.validateLink(c))return!1;if(!b){let b=a.push("link_open","a",1);b.attrs=[["href",c]],b.markup="autolink",b.info="auto",a.push("text","",0).content=a.md.normalizeLinkText(f);let d=a.push("link_close","a",-1);d.markup="autolink",d.info="auto"}return a.pos+=f.length+2,!0}if(m8.test(f)){let c=a.md.normalizeLink("mailto:"+f);if(!a.md.validateLink(c))return!1;if(!b){let b=a.push("link_open","a",1);b.attrs=[["href",c]],b.markup="autolink",b.info="auto",a.push("text","",0).content=a.md.normalizeLinkText(f);let d=a.push("link_close","a",-1);d.markup="autolink",d.info="auto"}return a.pos+=f.length+2,!0}return!1}],["html_inline",function(a,b){let c;if(!a.md.options.html)return!1;let d=a.posMax,e=a.pos;if(60!==a.src.charCodeAt(e)||e+2>=d)return!1;let f=a.src.charCodeAt(e+1);if(33!==f&&63!==f&&47!==f&&(!((c=32|f)>=97)||!(c<=122)))return!1;let g=a.src.slice(e).match(m$);if(!g)return!1;if(!b){var h,i;let b=a.push("html_inline","",0);b.content=g[0],h=b.content,/^<a[>\s]/i.test(h)&&a.linkLevel++,i=b.content,/^<\/a\s*>/i.test(i)&&a.linkLevel--}return a.pos+=g[0].length,!0}],["entity",function(a,b){let c=a.pos,d=a.posMax;if(38!==a.src.charCodeAt(c)||c+1>=d)return!1;if(35===a.src.charCodeAt(c+1)){let d=a.src.slice(c).match(na);if(d){if(!b){let b="x"===d[1][0].toLowerCase()?parseInt(d[1].slice(1),16):parseInt(d[1],10),c=a.push("text_special","",0);c.content=mf(b)?mg(b):mg(65533),c.markup=d[0],c.info="entity"}return a.pos+=d[0].length,!0}}else{let d=a.src.slice(c).match(nb);if(d){let c=l7(d[0]);if(c!==d[0]){if(!b){let b=a.push("text_special","",0);b.content=c,b.markup=d[0],b.info="entity"}return a.pos+=d[0].length,!0}}}return!1}]],ne=[["balance_pairs",function(a){let b=a.tokens_meta,c=a.tokens_meta.length;nc(a.delimiters);for(let a=0;a<c;a++)b[a]&&b[a].delimiters&&nc(b[a].delimiters)}],["strikethrough",function(a){let b=a.tokens_meta,c=a.tokens_meta.length;m6(a,a.delimiters);for(let d=0;d<c;d++)b[d]&&b[d].delimiters&&m6(a,b[d].delimiters)}],["emphasis",function(a){let b=a.tokens_meta,c=a.tokens_meta.length;m7(a,a.delimiters);for(let d=0;d<c;d++)b[d]&&b[d].delimiters&&m7(a,b[d].delimiters)}],["fragments_join",function(a){let b,c,d=0,e=a.tokens,f=a.tokens.length;for(b=c=0;b<f;b++)e[b].nesting<0&&d--,e[b].level=d,e[b].nesting>0&&d++,"text"===e[b].type&&b+1<f&&"text"===e[b+1].type?e[b+1].content=e[b].content+e[b+1].content:(b!==c&&(e[c]=e[b]),c++);b!==c&&(e.length=c)}]];function nf(){this.ruler=new mE;for(let a=0;a<nd.length;a++)this.ruler.push(nd[a][0],nd[a][1]);this.ruler2=new mE;for(let a=0;a<ne.length;a++)this.ruler2.push(ne[a][0],ne[a][1])}function ng(a){let b=Array.prototype.slice.call(arguments,1);return b.forEach(function(b){b&&Object.keys(b).forEach(function(c){a[c]=b[c]})}),a}function nh(a){return Object.prototype.toString.call(a)}function ni(a){return"[object Function]"===nh(a)}function nj(a){return a.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}nf.prototype.skipToken=function(a){let b=a.pos,c=this.ruler.getRules(""),d=c.length,e=a.md.options.maxNesting,f=a.cache;if(void 0!==f[b]){a.pos=f[b];return}let g=!1;if(a.level<e){for(let e=0;e<d;e++)if(a.level++,g=c[e](a,!0),a.level--,g){if(b>=a.pos)throw Error("inline rule didn't increment state.pos");break}}else a.pos=a.posMax;!g&&a.pos++,f[b]=a.pos},nf.prototype.tokenize=function(a){let b=this.ruler.getRules(""),c=b.length,d=a.posMax,e=a.md.options.maxNesting;for(;a.pos<d;){let f=a.pos,g=!1;if(a.level<e){for(let d=0;d<c;d++)if(g=b[d](a,!1)){if(f>=a.pos)throw Error("inline rule didn't increment state.pos");break}}if(g){if(a.pos>=d)break;continue}a.pending+=a.src[a.pos++]}a.pending&&a.pushPending()},nf.prototype.parse=function(a,b,c,d){let e=new this.State(a,b,c,d);this.tokenize(e);let f=this.ruler2.getRules(""),g=f.length;for(let a=0;a<g;a++)f[a](e)},nf.prototype.State=m3;let nk={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1},nl={"http:":{validate:function(a,b,c){let d=a.slice(b);return(c.re.http||(c.re.http=RegExp("^\\/\\/"+c.re.src_auth+c.re.src_host_port_strict+c.re.src_path,"i")),c.re.http.test(d))?d.match(c.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(a,b,c){let d=a.slice(b);return(c.re.no_http||(c.re.no_http=RegExp("^"+c.re.src_auth+"(?:localhost|(?:(?:"+c.re.src_domain+")\\.)+"+c.re.src_domain_root+")"+c.re.src_port+c.re.src_host_terminator+c.re.src_path,"i")),c.re.no_http.test(d))?b>=3&&":"===a[b-3]||b>=3&&"/"===a[b-3]?0:d.match(c.re.no_http)[0].length:0}},"mailto:":{validate:function(a,b,c){let d=a.slice(b);return(c.re.mailto||(c.re.mailto=RegExp("^"+c.re.src_email_name+"@"+c.re.src_host_strict,"i")),c.re.mailto.test(d))?d.match(c.re.mailto)[0].length:0}}},nm="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function nn(){return function(a,b){b.normalize(a)}}function no(a){var b;let c,d,e=(b=a.__opts__,b=b||{},(c={}).src_Any=lX.source,c.src_Cc=lY.source,c.src_Z=l$.source,c.src_P=lV.source,c.src_ZPCc=[c.src_Z,c.src_P,c.src_Cc].join("|"),c.src_ZCc=[c.src_Z,c.src_Cc].join("|"),c.src_pseudo_letter="(?:(?!"+(d="[><|]")+"|"+c.src_ZPCc+")"+c.src_Any+")",c.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",c.src_auth="(?:(?:(?!"+c.src_ZCc+"|[@/\\[\\]()]).)+@)?",c.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",c.src_host_terminator="(?=$|"+d+"|"+c.src_ZPCc+")(?!"+(b["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+c.src_ZPCc+"))",c.src_path="(?:[/?#](?:(?!"+c.src_ZCc+"|"+d+"|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+c.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+c.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+c.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+c.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+c.src_ZCc+"|[']).)+\\'|\\'(?="+c.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+c.src_ZCc+"|[.]|$)|"+(b["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+c.src_ZCc+"|$)|;(?!"+c.src_ZCc+"|$)|\\!+(?!"+c.src_ZCc+"|[!]|$)|\\?(?!"+c.src_ZCc+"|[?]|$))+|\\/)?",c.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',c.src_xn="xn--[a-z0-9\\-]{1,59}",c.src_domain_root="(?:"+c.src_xn+"|"+c.src_pseudo_letter+"{1,63})",c.src_domain="(?:"+c.src_xn+"|(?:"+c.src_pseudo_letter+")|(?:"+c.src_pseudo_letter+"(?:-|"+c.src_pseudo_letter+"){0,61}"+c.src_pseudo_letter+"))",c.src_host="(?:(?:(?:(?:"+c.src_domain+")\\.)*"+c.src_domain+"))",c.tpl_host_fuzzy="(?:"+c.src_ip4+"|(?:(?:(?:"+c.src_domain+")\\.)+(?:%TLDS%)))",c.tpl_host_no_ip_fuzzy="(?:(?:(?:"+c.src_domain+")\\.)+(?:%TLDS%))",c.src_host_strict=c.src_host+c.src_host_terminator,c.tpl_host_fuzzy_strict=c.tpl_host_fuzzy+c.src_host_terminator,c.src_host_port_strict=c.src_host+c.src_port+c.src_host_terminator,c.tpl_host_port_fuzzy_strict=c.tpl_host_fuzzy+c.src_port+c.src_host_terminator,c.tpl_host_port_no_ip_fuzzy_strict=c.tpl_host_no_ip_fuzzy+c.src_port+c.src_host_terminator,c.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+c.src_ZPCc+"|>|$))",c.tpl_email_fuzzy="(^|"+d+'|"|\\(|'+c.src_ZCc+")("+c.src_email_name+"@"+c.tpl_host_fuzzy_strict+")",c.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+c.src_ZPCc+"))((?![$+<=>^`||])"+c.tpl_host_port_fuzzy_strict+c.src_path+")",c.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+c.src_ZPCc+"))((?![$+<=>^`||])"+c.tpl_host_port_no_ip_fuzzy_strict+c.src_path+")",a.re=c),f=a.__tlds__.slice();function g(a){return a.replace("%TLDS%",e.src_tlds)}a.onCompile(),a.__tlds_replaced__||f.push("a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]"),f.push(e.src_xn),e.src_tlds=f.join("|"),e.email_fuzzy=RegExp(g(e.tpl_email_fuzzy),"i"),e.link_fuzzy=RegExp(g(e.tpl_link_fuzzy),"i"),e.link_no_ip_fuzzy=RegExp(g(e.tpl_link_no_ip_fuzzy),"i"),e.host_fuzzy_test=RegExp(g(e.tpl_host_fuzzy_test),"i");let h=[];function i(a,b){throw Error('(LinkifyIt) Invalid schema "'+a+'": '+b)}a.__compiled__={},Object.keys(a.__schemas__).forEach(function(b){let c=a.__schemas__[b];if(null===c)return;let d={validate:null,link:null};if(a.__compiled__[b]=d,"[object Object]"===nh(c)){if("[object RegExp]"===nh(c.validate)){var e;e=c.validate,d.validate=function(a,b){let c=a.slice(b);return e.test(c)?c.match(e)[0].length:0}}else ni(c.validate)?d.validate=c.validate:i(b,c);ni(c.normalize)?d.normalize=c.normalize:c.normalize?i(b,c):d.normalize=nn();return}"[object String]"===nh(c)?h.push(b):i(b,c)}),h.forEach(function(b){a.__compiled__[a.__schemas__[b]]&&(a.__compiled__[b].validate=a.__compiled__[a.__schemas__[b]].validate,a.__compiled__[b].normalize=a.__compiled__[a.__schemas__[b]].normalize)}),a.__compiled__[""]={validate:null,normalize:nn()};let j=Object.keys(a.__compiled__).filter(function(b){return b.length>0&&a.__compiled__[b]}).map(nj).join("|");a.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+j+")","i"),a.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+j+")","ig"),a.re.schema_at_start=RegExp("^"+a.re.schema_search.source,"i"),a.re.pretest=RegExp("("+a.re.schema_test.source+")|("+a.re.host_fuzzy_test.source+")|@","i"),a.__index__=-1,a.__text_cache__=""}function np(a,b){let c=a.__index__,d=a.__last_index__,e=a.__text_cache__.slice(c,d);this.schema=a.__schema__.toLowerCase(),this.index=c+b,this.lastIndex=d+b,this.raw=e,this.text=e,this.url=e}function nq(a,b){let c=new np(a,b);return a.__compiled__[c.schema].normalize(c,a),c}function nr(a,b){if(!(this instanceof nr))return new nr(a,b);!b&&Object.keys(a||{}).reduce(function(a,b){return a||nk.hasOwnProperty(b)},!1)&&(b=a,a={}),this.__opts__=ng({},nk,b),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=ng({},nl,a),this.__compiled__={},this.__tlds__=nm,this.__tlds_replaced__=!1,this.re={},no(this)}nr.prototype.add=function(a,b){return this.__schemas__[a]=b,no(this),this},nr.prototype.set=function(a){return this.__opts__=ng(this.__opts__,a),this},nr.prototype.test=function(a){let b,c,d,e,f,g,h,i;if(this.__text_cache__=a,this.__index__=-1,!a.length)return!1;if(this.re.schema_test.test(a)){for((h=this.re.schema_search).lastIndex=0;null!==(b=h.exec(a));)if(e=this.testSchemaAt(a,b[2],h.lastIndex)){this.__schema__=b[2],this.__index__=b.index+b[1].length,this.__last_index__=b.index+b[0].length+e;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(i=a.search(this.re.host_fuzzy_test))>=0&&(this.__index__<0||i<this.__index__)&&null!==(c=a.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(f=c.index+c[1].length,(this.__index__<0||f<this.__index__)&&(this.__schema__="",this.__index__=f,this.__last_index__=c.index+c[0].length)),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&a.indexOf("@")>=0&&null!==(d=a.match(this.re.email_fuzzy))&&(f=d.index+d[1].length,g=d.index+d[0].length,(this.__index__<0||f<this.__index__||f===this.__index__&&g>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=f,this.__last_index__=g)),this.__index__>=0},nr.prototype.pretest=function(a){return this.re.pretest.test(a)},nr.prototype.testSchemaAt=function(a,b,c){return this.__compiled__[b.toLowerCase()]?this.__compiled__[b.toLowerCase()].validate(a,c,this):0},nr.prototype.match=function(a){let b=[],c=0;this.__index__>=0&&this.__text_cache__===a&&(b.push(nq(this,c)),c=this.__last_index__);let d=c?a.slice(c):a;for(;this.test(d);)b.push(nq(this,c)),d=d.slice(this.__last_index__),c+=this.__last_index__;return b.length?b:null},nr.prototype.matchAtStart=function(a){if(this.__text_cache__=a,this.__index__=-1,!a.length)return null;let b=this.re.schema_at_start.exec(a);if(!b)return null;let c=this.testSchemaAt(a,b[2],b[0].length);return c?(this.__schema__=b[2],this.__index__=b.index+b[1].length,this.__last_index__=b.index+b[0].length+c,nq(this,0)):null},nr.prototype.tlds=function(a,b){return(a=Array.isArray(a)?a:[a],b)?this.__tlds__=this.__tlds__.concat(a).sort().filter(function(a,b,c){return a!==c[b-1]}).reverse():(this.__tlds__=a.slice(),this.__tlds_replaced__=!0),no(this),this},nr.prototype.normalize=function(a){a.schema||(a.url="http://"+a.url),"mailto:"!==a.schema||/^mailto:/i.test(a.url)||(a.url="mailto:"+a.url)},nr.prototype.onCompile=function(){};let ns=/^xn--/,nt=/[^\0-\x7F]/,nu=/[\x2E\u3002\uFF0E\uFF61]/g,nv={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},nw=Math.floor,nx=String.fromCharCode;function ny(a){throw RangeError(nv[a])}function nz(a,b){let c=a.split("@"),d="";return c.length>1&&(d=c[0]+"@",a=c[1]),d+(function(a,b){let c=[],d=a.length;for(;d--;)c[d]=b(a[d]);return c})((a=a.replace(nu,".")).split("."),b).join(".")}let nA=function(a,b){return a+22+75*(a<26)-((0!=b)<<5)},nB=function(a,b,c){let d=0;for(a=c?nw(a/700):a>>1,a+=nw(a/b);a>455;d+=36)a=nw(a/35);return nw(d+36*a/(a+38))},nC=function(a){let b=[],c=a.length,d=0,e=128,f=72,g=a.lastIndexOf("-");g<0&&(g=0);for(let c=0;c<g;++c)a.charCodeAt(c)>=128&&ny("not-basic"),b.push(a.charCodeAt(c));for(let i=g>0?g+1:0;i<c;){let g=d;for(let b=1,e=36;;e+=36){var h;i>=c&&ny("invalid-input");let g=(h=a.charCodeAt(i++))>=48&&h<58?26+(h-48):h>=65&&h<91?h-65:h>=97&&h<123?h-97:36;g>=36&&ny("invalid-input"),g>nw((0x7fffffff-d)/b)&&ny("overflow"),d+=g*b;let j=e<=f?1:e>=f+26?26:e-f;if(g<j)break;let k=36-j;b>nw(0x7fffffff/k)&&ny("overflow"),b*=k}let j=b.length+1;f=nB(d-g,j,0==g),nw(d/j)>0x7fffffff-e&&ny("overflow"),e+=nw(d/j),d%=j,b.splice(d++,0,e)}return String.fromCodePoint(...b)},nD=function(a){let b=[],c=(a=function(a){let b=[],c=0,d=a.length;for(;c<d;){let e=a.charCodeAt(c++);if(e>=55296&&e<=56319&&c<d){let d=a.charCodeAt(c++);(64512&d)==56320?b.push(((1023&e)<<10)+(1023&d)+65536):(b.push(e),c--)}else b.push(e)}return b}(a)).length,d=128,e=0,f=72;for(let c of a)c<128&&b.push(nx(c));let g=b.length,h=g;for(g&&b.push("-");h<c;){let c=0x7fffffff;for(let b of a)b>=d&&b<c&&(c=b);let i=h+1;for(let j of(c-d>nw((0x7fffffff-e)/i)&&ny("overflow"),e+=(c-d)*i,d=c,a))if(j<d&&++e>0x7fffffff&&ny("overflow"),j===d){let a=e;for(let c=36;;c+=36){let d=c<=f?1:c>=f+26?26:c-f;if(a<d)break;let e=a-d,g=36-d;b.push(nx(nA(d+e%g,0))),a=nw(e/g)}b.push(nx(nA(a,0))),f=nB(e,i,h===g),e=0,++h}++e,++d}return b.join("")},nE={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}},nF=/^(vbscript|javascript|file|data):/,nG=/^data:image\/(gif|png|jpeg|webp);/;function nH(a){let b=a.trim().toLowerCase();return!nF.test(b)||nG.test(b)}let nI=["http:","https:","mailto:"];function nJ(a){let b=lU(a,!0);if(b.hostname&&(!b.protocol||nI.indexOf(b.protocol)>=0))try{var c;c=b.hostname,b.hostname=nz(c,function(a){return nt.test(a)?"xn--"+nD(a):a})}catch(a){}return lI(lJ(b))}function nK(a){let b=lU(a,!0);if(b.hostname&&(!b.protocol||nI.indexOf(b.protocol)>=0))try{var c;c=b.hostname,b.hostname=nz(c,function(a){return ns.test(a)?nC(a.slice(4).toLowerCase()):a})}catch(a){}return lF(lJ(b),lF.defaultChars+"%")}function nL(a,b){if(!(this instanceof nL))return new nL(a,b);b||ma(a)||(b=a||{},a="default"),this.inline=new nf,this.block=new m2,this.core=new mS,this.renderer=new mD,this.linkify=new nr,this.validateLink=nH,this.normalizeLink=nJ,this.normalizeLinkText=nK,this.utils=u,this.helpers=md({},v),this.options={},this.configure(a),b&&this.set(b)}nL.prototype.set=function(a){return md(this.options,a),this},nL.prototype.configure=function(a){let b=this;if(ma(a)){let b=a;if(!(a=nE[b]))throw Error('Wrong `markdown-it` preset "'+b+'", check name')}if(!a)throw Error("Wrong `markdown-it` preset, can't be empty");return a.options&&b.set(a.options),a.components&&Object.keys(a.components).forEach(function(c){a.components[c].rules&&b[c].ruler.enableOnly(a.components[c].rules),a.components[c].rules2&&b[c].ruler2.enableOnly(a.components[c].rules2)}),this},nL.prototype.enable=function(a,b){let c=[];Array.isArray(a)||(a=[a]),["core","block","inline"].forEach(function(b){c=c.concat(this[b].ruler.enable(a,!0))},this),c=c.concat(this.inline.ruler2.enable(a,!0));let d=a.filter(function(a){return 0>c.indexOf(a)});if(d.length&&!b)throw Error("MarkdownIt. Failed to enable unknown rule(s): "+d);return this},nL.prototype.disable=function(a,b){let c=[];Array.isArray(a)||(a=[a]),["core","block","inline"].forEach(function(b){c=c.concat(this[b].ruler.disable(a,!0))},this),c=c.concat(this.inline.ruler2.disable(a,!0));let d=a.filter(function(a){return 0>c.indexOf(a)});if(d.length&&!b)throw Error("MarkdownIt. Failed to disable unknown rule(s): "+d);return this},nL.prototype.use=function(a){let b=[this].concat(Array.prototype.slice.call(arguments,1));return a.apply(a,b),this},nL.prototype.parse=function(a,b){if("string"!=typeof a)throw Error("Input data should be a String");let c=new this.core.State(a,this,b);return this.core.process(c),c.tokens},nL.prototype.render=function(a,b){return b=b||{},this.renderer.render(this.parse(a,b),this.options,b)},nL.prototype.parseInline=function(a,b){let c=new this.core.State(a,this,b);return c.inlineMode=!0,this.core.process(c),c.tokens},nL.prototype.renderInline=function(a,b){return b=b||{},this.renderer.render(this.parseInline(a,b),this.options,b)};let nM=new aj({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>["p",0]},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["div",["hr"]]},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:a=>["h"+a.attrs.level,0]},code_block:{content:"text*",group:"block",code:!0,defining:!0,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:a=>({params:a.getAttribute("data-params")||""})}],toDOM:a=>["pre",a.attrs.params?{"data-params":a.attrs.params}:{},["code",0]]},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:"ol",getAttrs:a=>({order:a.hasAttribute("start")?+a.getAttribute("start"):1,tight:a.hasAttribute("data-tight")})}],toDOM:a=>["ol",{start:1==a.attrs.order?null:a.attrs.order,"data-tight":a.attrs.tight?"true":null},0]},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:!1}},parseDOM:[{tag:"ul",getAttrs:a=>({tight:a.hasAttribute("data-tight")})}],toDOM:a=>["ul",{"data-tight":a.attrs.tight?"true":null},0]},list_item:{content:"block+",defining:!0,parseDOM:[{tag:"li"}],toDOM:()=>["li",0]},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:a=>({src:a.getAttribute("src"),title:a.getAttribute("title"),alt:a.getAttribute("alt")})}],toDOM:a=>["img",a.attrs]},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:a=>"em"==a.type.name}],toDOM:()=>["em"]},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:a=>"normal"!=a.style.fontWeight&&null},{style:"font-weight=400",clearMark:a=>"strong"==a.type.name},{style:"font-weight",getAttrs:a=>/^(bold(er)?|[5-9]\d{2,})$/.test(a)&&null}],toDOM:()=>["strong"]},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:a=>({href:a.getAttribute("href"),title:a.getAttribute("title")})}],toDOM:a=>["a",a.attrs]},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>["code"]}}});class nN{constructor(a,b){this.schema=a,this.tokenHandlers=b,this.stack=[{type:a.topNodeType,attrs:null,content:[],marks:H.none}]}top(){return this.stack[this.stack.length-1]}push(a){this.stack.length&&this.top().content.push(a)}addText(a){if(!a)return;let b=this.top(),c=b.content,d=c[c.length-1],e=this.schema.text(a,b.marks),f;d&&(f=function(a,b){if(a.isText&&b.isText&&H.sameSet(a.marks,b.marks))return a.withText(a.text+b.text)}(d,e))?c[c.length-1]=f:c.push(e)}openMark(a){let b=this.top();b.marks=a.addToSet(b.marks)}closeMark(a){let b=this.top();b.marks=a.removeFromSet(b.marks)}parseTokens(a){for(let b=0;b<a.length;b++){let c=a[b],d=this.tokenHandlers[c.type];if(!d)throw Error("Token type `"+c.type+"` not supported by Markdown parser");d(this,c,a,b)}}addNode(a,b,c){let d=this.top(),e=a.createAndFill(b,c,d?d.marks:[]);return e?(this.push(e),e):null}openNode(a,b){this.stack.push({type:a,attrs:b,content:[],marks:H.none})}closeNode(){let a=this.stack.pop();return this.addNode(a.type,a.attrs,a.content)}}function nO(a,b,c,d){return a.getAttrs?a.getAttrs(b,c,d):a.attrs instanceof Function?a.attrs(b):a.attrs}function nP(a,b){return a.noCloseToken||"code_inline"==b||"code_block"==b||"fence"==b}function nQ(a){return"\n"==a[a.length-1]?a.slice(0,a.length-1):a}function nR(){}class nS{constructor(a,b,c){this.schema=a,this.tokenizer=b,this.tokens=c,this.tokenHandlers=function(a,b){let c=Object.create(null);for(let d in b){let e=b[d];if(e.block){let b=a.nodeType(e.block);nP(e,d)?c[d]=(a,c,d,f)=>{a.openNode(b,nO(e,c,d,f)),a.addText(nQ(c.content)),a.closeNode()}:(c[d+"_open"]=(a,c,d,f)=>a.openNode(b,nO(e,c,d,f)),c[d+"_close"]=a=>a.closeNode())}else if(e.node){let b=a.nodeType(e.node);c[d]=(a,c,d,f)=>a.addNode(b,nO(e,c,d,f))}else if(e.mark){let b=a.marks[e.mark];nP(e,d)?c[d]=(a,c,d,f)=>{a.openMark(b.create(nO(e,c,d,f))),a.addText(nQ(c.content)),a.closeMark(b)}:(c[d+"_open"]=(a,c,d,f)=>a.openMark(b.create(nO(e,c,d,f))),c[d+"_close"]=a=>a.closeMark(b))}else if(e.ignore)nP(e,d)?c[d]=nR:(c[d+"_open"]=nR,c[d+"_close"]=nR);else throw RangeError("Unrecognized parsing spec "+JSON.stringify(e))}return c.text=(a,b)=>a.addText(b.content),c.inline=(a,b)=>a.parseTokens(b.children),c.softbreak=c.softbreak||(a=>a.addText(" ")),c}(a,c)}parse(a,b={}){let c=new nN(this.schema,this.tokenHandlers),d;c.parseTokens(this.tokenizer.parse(a,b));do d=c.closeNode();while(c.stack.length);return d||this.schema.topNodeType.createAndFill()}}function nT(a,b){for(;++b<a.length;)if("list_item_open"!=a[b].type)return a[b].hidden;return!1}new nS(nM,nL("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(a,b,c)=>({tight:nT(b,c)})},ordered_list:{block:"ordered_list",getAttrs:(a,b,c)=>({order:+a.attrGet("start")||1,tight:nT(b,c)})},heading:{block:"heading",getAttrs:a=>({level:+a.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:!0},fence:{block:"code_block",getAttrs:a=>({params:a.info||""}),noCloseToken:!0},hr:{node:"horizontal_rule"},image:{node:"image",getAttrs:a=>({src:a.attrGet("src"),title:a.attrGet("title")||null,alt:a.children[0]&&a.children[0].content||null})},hardbreak:{node:"hard_break"},em:{mark:"em"},strong:{mark:"strong"},link:{mark:"link",getAttrs:a=>({href:a.attrGet("href"),title:a.attrGet("title")||null})},code_inline:{mark:"code",noCloseToken:!0}});let nU={open:"",close:"",mixable:!0};class nV{constructor(a,b,c={}){this.nodes=a,this.marks=b,this.options=c}serialize(a,b={}){b=Object.assign({},this.options,b);let c=new nY(this.nodes,this.marks,b);return c.renderContent(a),c.out}}let nW=new nV({blockquote(a,b){a.wrapBlock("> ",null,b,()=>a.renderContent(b))},code_block(a,b){let c=b.textContent.match(/`{3,}/gm),d=c?c.sort().slice(-1)[0]+"`":"```";a.write(d+(b.attrs.params||"")+"\n"),a.text(b.textContent,!1),a.write("\n"),a.write(d),a.closeBlock(b)},heading(a,b){a.write(a.repeat("#",b.attrs.level)+" "),a.renderInline(b,!1),a.closeBlock(b)},horizontal_rule(a,b){a.write(b.attrs.markup||"---"),a.closeBlock(b)},bullet_list(a,b){a.renderList(b," ",()=>(b.attrs.bullet||"*")+" ")},ordered_list(a,b){let c=b.attrs.order||1,d=String(c+b.childCount-1).length,e=a.repeat(" ",d+2);a.renderList(b,e,b=>{let e=String(c+b);return a.repeat(" ",d-e.length)+e+". "})},list_item(a,b){a.renderContent(b)},paragraph(a,b){a.renderInline(b),a.closeBlock(b)},image(a,b){a.write("!["+a.esc(b.attrs.alt||"")+"]("+b.attrs.src.replace(/[\(\)]/g,"\\$&")+(b.attrs.title?' "'+b.attrs.title.replace(/"/g,'\\"')+'"':"")+")")},hard_break(a,b,c,d){for(let e=d+1;e<c.childCount;e++)if(c.child(e).type!=b.type)return void a.write("\\\n")},text(a,b){a.text(b.text,!a.inAutolink)}},{em:{open:"*",close:"*",mixable:!0,expelEnclosingWhitespace:!0},strong:{open:"**",close:"**",mixable:!0,expelEnclosingWhitespace:!0},link:{open:(a,b,c,d)=>(a.inAutolink=function(a,b,c){if(a.attrs.title||!/^\w+:/.test(a.attrs.href))return!1;let d=b.child(c);return!!d.isText&&d.text==a.attrs.href&&d.marks[d.marks.length-1]==a&&(c==b.childCount-1||!a.isInSet(b.child(c+1).marks))}(b,c,d),a.inAutolink?"<":"["),close(a,b,c,d){let{inAutolink:e}=a;return a.inAutolink=void 0,e?">":"]("+b.attrs.href.replace(/[\(\)"]/g,"\\$&")+(b.attrs.title?` "${b.attrs.title.replace(/"/g,'\\"')}"`:"")+")"},mixable:!0},code:{open:(a,b,c,d)=>nX(c.child(d),-1),close:(a,b,c,d)=>nX(c.child(d-1),1),escape:!1}});function nX(a,b){let c=/`+/g,d,e=0;if(a.isText)for(;d=c.exec(a.text);)e=Math.max(e,d[0].length);let f=e>0&&b>0?" `":"`";for(let a=0;a<e;a++)f+="`";return e>0&&b<0&&(f+=" "),f}class nY{constructor(a,b,c){this.nodes=a,this.marks=b,this.options=c,this.delim="",this.out="",this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,void 0===this.options.tightLists&&(this.options.tightLists=!1),void 0===this.options.hardBreakNodeName&&(this.options.hardBreakNodeName="hard_break")}flushClose(a=2){if(this.closed){if(this.atBlank()||(this.out+="\n"),a>1){let b=this.delim,c=/\s+$/.exec(b);c&&(b=b.slice(0,b.length-c[0].length));for(let c=1;c<a;c++)this.out+=b+"\n"}this.closed=null}}getMark(a){let b=this.marks[a];if(!b){if(!1!==this.options.strict)throw Error(`Mark type \`${a}\` not supported by Markdown renderer`);b=nU}return b}wrapBlock(a,b,c,d){let e=this.delim;this.write(null!=b?b:a),this.delim+=a,d(),this.delim=e,this.closeBlock(c)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){this.atBlank()||(this.out+="\n")}write(a){this.flushClose(),this.delim&&this.atBlank()&&(this.out+=this.delim),a&&(this.out+=a)}closeBlock(a){this.closed=a}text(a,b=!0){let c=a.split("\n");for(let a=0;a<c.length;a++)this.write(),!b&&"["==c[a][0]&&/(^|[^\\])\!$/.test(this.out)&&(this.out=this.out.slice(0,this.out.length-1)+"\\!"),this.out+=b?this.esc(c[a],this.atBlockStart):c[a],a!=c.length-1&&(this.out+="\n")}render(a,b,c){if(this.nodes[a.type.name])this.nodes[a.type.name](this,a,b,c);else if(!1!==this.options.strict)throw Error("Token type `"+a.type.name+"` not supported by Markdown renderer");else!a.type.isLeaf&&(a.type.inlineContent?this.renderInline(a):this.renderContent(a),a.isBlock&&this.closeBlock(a))}renderContent(a){a.forEach((b,c,d)=>this.render(b,a,d))}renderInline(a,b=!0){this.atBlockStart=b;let c=[],d="",e=(b,e,f)=>{let g=b?b.marks:[];b&&b.type.name===this.options.hardBreakNodeName&&(g=g.filter(b=>{if(f+1==a.childCount)return!1;let c=a.child(f+1);return b.isInSet(c.marks)&&(!c.isText||/\S/.test(c.text))}));let h=d;if(d="",b&&b.isText&&g.some(a=>{let b=this.getMark(a.type.name);return b&&b.expelEnclosingWhitespace&&!a.isInSet(c)})){let[a,d,e]=/^(\s*)(.*)$/m.exec(b.text);d&&(h+=d,(b=e?b.withText(e):null)||(g=c))}if(b&&b.isText&&g.some(b=>{let c=this.getMark(b.type.name);return c&&c.expelEnclosingWhitespace&&!this.isMarkAhead(a,f+1,b)})){let[a,e,f]=/^(.*?)(\s*)$/m.exec(b.text);f&&(d=f,(b=e?b.withText(e):null)||(g=c))}let i=g.length?g[g.length-1]:null,j=i&&!1===this.getMark(i.type.name).escape,k=g.length-!!j;c:for(let a=0;a<k;a++){let b=g[a];if(!this.getMark(b.type.name).mixable)break;for(let d=0;d<c.length;d++){let e=c[d];if(!this.getMark(e.type.name).mixable)break;if(b.eq(e)){a>d?g=g.slice(0,d).concat(b).concat(g.slice(d,a)).concat(g.slice(a+1,k)):d>a&&(g=g.slice(0,a).concat(g.slice(a+1,d)).concat(b).concat(g.slice(d,k)));continue c}}}let l=0;for(;l<Math.min(c.length,k)&&g[l].eq(c[l]);)++l;for(;l<c.length;)this.text(this.markString(c.pop(),!1,a,f),!1);if(h&&this.text(h),b){for(;c.length<k;){let b=g[c.length];c.push(b),this.text(this.markString(b,!0,a,f),!1),this.atBlockStart=!1}j&&b.isText?this.text(this.markString(i,!0,a,f)+b.text+this.markString(i,!1,a,f+1),!1):this.render(b,a,f),this.atBlockStart=!1}(null==b?void 0:b.isText)&&b.nodeSize>0&&(this.atBlockStart=!1)};a.forEach(e),e(null,0,a.childCount),this.atBlockStart=!1}renderList(a,b,c){this.closed&&this.closed.type==a.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let d=void 0!==a.attrs.tight?a.attrs.tight:this.options.tightLists,e=this.inTightList;this.inTightList=d,a.forEach((e,f,g)=>{g&&d&&this.flushClose(1),this.wrapBlock(b,c(g),a,()=>this.render(e,a,g))}),this.inTightList=e}esc(a,b=!1){return a=a.replace(/[`*\\~\[\]_]/g,(b,c)=>"_"==b&&c>0&&c+1<a.length&&a[c-1].match(/\w/)&&a[c+1].match(/\w/)?b:"\\"+b),b&&(a=a.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ")),this.options.escapeExtraCharacters&&(a=a.replace(this.options.escapeExtraCharacters,"\\$&")),a}quote(a){let b=-1==a.indexOf('"')?'""':-1==a.indexOf("'")?"''":"()";return b[0]+a+b[1]}repeat(a,b){let c="";for(let d=0;d<b;d++)c+=a;return c}markString(a,b,c,d){let e=this.getMark(a.type.name),f=b?e.open:e.close;return"string"==typeof f?f:f(this,a,c,d)}getEnclosingWhitespace(a){return{leading:(a.match(/^(\s+)/)||[void 0])[0],trailing:(a.match(/(\s+)$/)||[void 0])[0]}}isMarkAhead(a,b,c){for(;;b++){if(b>=a.childCount)return!1;let d=a.child(b);if(d.type.name!=this.options.hardBreakNodeName)return c.isInSet(d.marks);b++}}}var nZ=c(23765),n$=Object.defineProperty,n_=(a,b,c)=>{let d;return(d="symbol"!=typeof b?b+"":b)in a?n$(a,d,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[d]=c,c};let n0=gD.create({name:"markdownTightLists",addOptions:()=>({tight:!0,tightClass:"tight",listTypes:["bulletList","orderedList"]}),addGlobalAttributes(){return[{types:this.options.listTypes,attributes:{tight:{default:this.options.tight,parseHTML:a=>"true"===a.getAttribute("data-tight")||!a.querySelector("p"),renderHTML:a=>({class:a.tight?this.options.tightClass:null,"data-tight":a.tight?"true":null})}}}]},addCommands(){var a=this;return{toggleTight:function(){let b=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return c=>{let{editor:d,commands:e}=c;return a.options.listTypes.some(a=>(function(a){if(!d.isActive(a))return!1;let c=d.getAttributes(a);return e.updateAttributes(a,{tight:null!=b?b:!(null!=c&&c.tight)})})(a))}}}}}),n1=nL();function n2(a,b){return n1.inline.State.prototype.scanDelims.call({src:a,posMax:a.length}),new n1.inline.State(a,null,null,[]).scanDelims(b,!0)}function n3(a,b,c,d){let e=a.substring(0,c)+a.substring(c+b.length);return e.substring(0,c+d)+b+e.substring(c+d)}class n4 extends nY{constructor(a,b,c){super(a,b,null!=c?c:{}),n_(this,"inTable",!1),this.inlines=[]}render(a,b,c){super.render(a,b,c);let d=this.inlines[this.inlines.length-1];if(null!=d&&d.start&&null!=d&&d.end){var e;let a,{delimiter:b,start:c,end:f}=this.normalizeInline(d);this.out=(e=this.out,(a=function(a,b,c,d){let e=d,f=a;for(;e>c&&!n2(f,e).can_close;)f=n3(f,b,e,-1),e--;return{text:f,from:c,to:e}}((a=function(a,b,c,d){let e=c,f=a;for(;e<d&&!n2(f,e).can_open;)f=n3(f,b,e,1),e++;return{text:f,from:e,to:d}}((a={text:e,from:c,to:f}).text,b,a.from,a.to)).text,b,a.from,a.to)).to-a.from<b.length+1&&(a.text=a.text.substring(0,a.from)+a.text.substring(a.to+b.length)),a.text),this.inlines.pop()}}markString(a,b,c,d){let e=this.marks[a.type.name];if(e.expelEnclosingWhitespace)if(b)this.inlines.push({start:this.out.length,delimiter:e.open});else{let a=this.inlines.pop();this.inlines.push({...a,end:this.out.length})}return super.markString(a,b,c,d)}normalizeInline(a){let{start:b,end:c}=a;for(;this.out.charAt(b).match(/\s/);)b++;return{...a,start:b}}}let n5=gy.create({name:"markdownHTMLMark",addStorage:()=>({markdown:{serialize:{open(a,b){var c,d;return this.editor.storage.markdown.options.html?null!=(c=null==(d=n6(b))?void 0:d[0])?c:"":(console.warn(`Tiptap Markdown: "${b.type.name}" mark is only available in html mode`),"")},close(a,b){var c,d;return this.editor.storage.markdown.options.html&&null!=(c=null==(d=n6(b))?void 0:d[1])?c:""}},parse:{}}})});function n6(a){let b=a.type.schema,c=b.text(" ",[a]),d=fH(D.from(c),b).match(/^(<.*?>) (<\/.*?>)$/);return d?[d[1],d[2]]:null}function n7(a){let b=`<body>${a}</body>`;return new window.DOMParser().parseFromString(b,"text/html").body}let n8=g2.create({name:"markdownHTMLNode",addStorage:()=>({markdown:{serialize(a,b,c){var d,e;let f,g,h;this.editor.storage.markdown.options.html?a.write((d=b,e=c,f=d.type.schema,g=fH(D.from(d),f),d.isBlock&&(e instanceof D||e.type.name===f.topNodeType.name)?((h=n7(g).firstElementChild).innerHTML=h.innerHTML.trim()?`
95
94
  ${h.innerHTML}
96
95
  `:`
97
- `,h.outerHTML):g)):(console.warn(`Tiptap Markdown: "${b.type.name}" node is only available in html mode`),a.write(`[${b.type.name}]`)),b.isBlock&&a.closeBlock(b)},parse:{}}})}),n9=g2.create({name:"blockquote"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.blockquote,parse:{}}})}),oa=g2.create({name:"bulletList"}).extend({addStorage:()=>({markdown:{serialize(a,b){return a.renderList(b," ",()=>(this.editor.storage.markdown.options.bulletListMarker||"-")+" ")},parse:{}}})}),ob=g2.create({name:"codeBlock"}).extend({addStorage:()=>({markdown:{serialize(a,b){a.write("```"+(b.attrs.language||"")+"\n"),a.text(b.textContent,!1),a.ensureNewLine(),a.write("```"),a.closeBlock(b)},parse:{setup(a){var b;a.set({langPrefix:null!=(b=this.options.languageClassPrefix)?b:"language-"})},updateDOM(a){a.innerHTML=a.innerHTML.replace(/\n<\/code><\/pre>/g,"</code></pre>")}}}})}),oc=g2.create({name:"hardBreak"}).extend({addStorage:()=>({markdown:{serialize(a,b,c,d){for(let e=d+1;e<c.childCount;e++)if(c.child(e).type!=b.type)return void a.write(a.inTable?n8.storage.markdown.serialize.call(this,a,b,c):"\\\n")},parse:{}}})}),od=g2.create({name:"heading"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.heading,parse:{}}})}),oe=g2.create({name:"horizontalRule"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.horizontal_rule,parse:{}}})}),of=g2.create({name:"image"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.image,parse:{}}})}),og=g2.create({name:"listItem"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.list_item,parse:{}}})}),oh=g2.create({name:"orderedList"}).extend({addStorage:()=>({markdown:{serialize(a,b,c,d){let e=b.attrs.start||1,f=String(e+b.childCount-1).length,g=a.repeat(" ",f+2),h=function(a,b,c){let d=0;for(;c-d>0&&b.child(c-d-1).type.name===a.type.name;d++);return d}(b,c,d)%2?") ":". ";a.renderList(b,g,b=>{let c=String(e+b);return a.repeat(" ",f-c.length)+c+h})},parse:{}}})}),oi=g2.create({name:"paragraph"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.paragraph,parse:{}}})});function oj(a){var b,c;return null!=(b=null==a||null==(c=a.content)?void 0:c.content)?b:[]}let ok=g2.create({name:"table"}).extend({addStorage:()=>({markdown:{serialize(a,b,c){let d,e,f;(e=(d=oj(b))[0],f=d.slice(1),oj(e).some(a=>"tableHeader"!==a.type.name||ol(a)||a.childCount>1)||f.some(a=>oj(a).some(a=>"tableHeader"===a.type.name||ol(a)||a.childCount>1)))?n8.storage.markdown.serialize.call(this,a,b,c):(a.inTable=!0,b.forEach((b,c,d)=>{if(a.write("| "),b.forEach((b,c,d)=>{d&&a.write(" | ");let e=b.firstChild;e.textContent.trim()&&a.renderInline(e)}),a.write(" |"),a.ensureNewLine(),!d){let c=Array.from({length:b.childCount}).map(()=>"---").join(" | ");a.write(`| ${c} |`),a.ensureNewLine()}}),a.closeBlock(b),a.inTable=!1)},parse:{}}})});function ol(a){return a.attrs.colspan>1||a.attrs.rowspan>1}let om=g2.create({name:"taskItem"}).extend({addStorage:()=>({markdown:{serialize(a,b){let c=b.attrs.checked?"[x]":"[ ]";a.write(`${c} `),a.renderContent(b)},parse:{updateDOM(a){[...a.querySelectorAll(".task-list-item")].forEach(a=>{let b=a.querySelector("input");a.setAttribute("data-type","taskItem"),b&&(a.setAttribute("data-checked",b.checked),b.remove())})}}}})}),on=g2.create({name:"taskList"}).extend({addStorage:()=>({markdown:{serialize:oa.storage.markdown.serialize,parse:{setup(a){a.use(nZ)},updateDOM(a){[...a.querySelectorAll(".contains-task-list")].forEach(a=>{a.setAttribute("data-type","taskList")})}}}})}),oo=[n9,oa,ob,oc,od,oe,n8,of,og,oh,oi,ok,om,on,g2.create({name:"text"}).extend({addStorage:()=>({markdown:{serialize(a,b){var c;a.text(null==(c=b.text)?void 0:c.replace(/</g,"&lt;").replace(/>/g,"&gt;"))},parse:{}}})}),gy.create({name:"bold"}).extend({addStorage:()=>({markdown:{serialize:nW.marks.strong,parse:{}}})}),gy.create({name:"code"}).extend({addStorage:()=>({markdown:{serialize:nW.marks.code,parse:{}}})}),n5,gy.create({name:"italic"}).extend({addStorage:()=>({markdown:{serialize:nW.marks.em,parse:{}}})}),gy.create({name:"link"}).extend({addStorage:()=>({markdown:{serialize:nW.marks.link,parse:{}}})}),gy.create({name:"strike"}).extend({addStorage:()=>({markdown:{serialize:{open:"~~",close:"~~",expelEnclosingWhitespace:!0},parse:{}}})})];function op(a){var b,c;let d=null==(b=a.storage)?void 0:b.markdown,e=null==(c=oo.find(b=>b.name===a.name))?void 0:c.storage.markdown;return d||e?{...e,...d}:null}class oq{constructor(a){n_(this,"editor",null),this.editor=a}serialize(a){let b=new n4(this.nodes,this.marks,{hardBreakNodeName:oc.name});return b.renderContent(a),b.out}get nodes(){var a;return{...Object.fromEntries(Object.keys(this.editor.schema.nodes).map(a=>[a,this.serializeNode(n8)])),...Object.fromEntries(null!=(a=this.editor.extensionManager.extensions.filter(a=>"node"===a.type&&this.serializeNode(a)).map(a=>[a.name,this.serializeNode(a)]))?a:[])}}get marks(){var a;return{...Object.fromEntries(Object.keys(this.editor.schema.marks).map(a=>[a,this.serializeMark(n5)])),...Object.fromEntries(null!=(a=this.editor.extensionManager.extensions.filter(a=>"mark"===a.type&&this.serializeMark(a)).map(a=>[a.name,this.serializeMark(a)]))?a:[])}}serializeNode(a){var b;return null==(b=op(a))||null==(b=b.serialize)?void 0:b.bind({editor:this.editor,options:a.options})}serializeMark(a){var b;let c=null==(b=op(a))?void 0:b.serialize;return c?{...c,open:"function"==typeof c.open?c.open.bind({editor:this.editor,options:a.options}):c.open,close:"function"==typeof c.close?c.close.bind({editor:this.editor,options:a.options}):c.close}:null}}class or{constructor(a,b){n_(this,"editor",null),n_(this,"md",null);let{html:c,linkify:d,breaks:e}=b;this.editor=a,this.md=this.withPatchedRenderer(nL({html:c,linkify:d,breaks:e}))}parse(a){let{inline:b}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof a){this.editor.extensionManager.extensions.forEach(a=>{var b;return null==(b=op(a))||null==(b=b.parse)||null==(b=b.setup)?void 0:b.call({editor:this.editor,options:a.options},this.md)});let c=n7(this.md.render(a));return this.editor.extensionManager.extensions.forEach(a=>{var b;return null==(b=op(a))||null==(b=b.parse)||null==(b=b.updateDOM)?void 0:b.call({editor:this.editor,options:a.options},c)}),this.normalizeDOM(c,{inline:b,content:a}),c.innerHTML}return a}normalizeDOM(a,b){let{inline:c,content:d}=b;return this.normalizeBlocks(a),a.querySelectorAll("*").forEach(a=>{var b;(null==(b=a.nextSibling)?void 0:b.nodeType)!==Node.TEXT_NODE||a.closest("pre")||(a.nextSibling.textContent=a.nextSibling.textContent.replace(/^\n/,""))}),c&&this.normalizeInline(a,d),a}normalizeBlocks(a){let b=Object.values(this.editor.schema.nodes).filter(a=>a.isBlock).map(a=>{var b;return null==(b=a.spec.parseDOM)?void 0:b.map(a=>a.tag)}).flat().filter(Boolean).join(",");b&&[...a.querySelectorAll(b)].forEach(a=>{a.parentElement.matches("p")&&function(a){let b=a.parentElement,c=b.cloneNode();for(;b.firstChild&&b.firstChild!==a;)c.appendChild(b.firstChild);c.childNodes.length>0&&b.parentElement.insertBefore(c,b),b.parentElement.insertBefore(a,b),0===b.childNodes.length&&b.remove()}(a)})}normalizeInline(a,b){var c,d,e,f,g;if(null!=(c=a.firstElementChild)&&c.matches("p")){let c=a.firstElementChild,{nextElementSibling:h}=c,i=null!=(d=null==(e=b.match(/^\s+/))?void 0:e[0])?d:"",j=h?"":null!=(f=null==(g=b.match(/\s+$/))?void 0:g[0])?f:"";if(b.match(/^\n\n/)){c.innerHTML=`${c.innerHTML}${j}`;return}let k=c.parentNode;for(;c.firstChild;)k.insertBefore(c.firstChild,c);k.removeChild(c),a.innerHTML=`${i}${a.innerHTML}${j}`}}withPatchedRenderer(a){let b=a=>function(){let b=a(...arguments);return"\n"===b?b:"\n"===b[b.length-1]?b.slice(0,-1):b};return a.renderer.rules.hardbreak=b(a.renderer.rules.hardbreak),a.renderer.rules.softbreak=b(a.renderer.rules.softbreak),a.renderer.rules.fence=b(a.renderer.rules.fence),a.renderer.rules.code_block=b(a.renderer.rules.code_block),a.renderer.renderToken=b(a.renderer.renderToken.bind(a.renderer)),a}}let ot=gD.create({name:"markdownClipboard",addOptions:()=>({transformPastedText:!1,transformCopiedText:!1}),addProseMirrorPlugins(){return[new br({key:new bu("markdownClipboard"),props:{clipboardTextParser:(a,b,c)=>{if(c||!this.options.transformPastedText)return null;let d=this.editor.storage.markdown.parser.parse(a,{inline:!0});return al.fromSchema(this.editor.schema).parseSlice(n7(d),{preserveWhitespace:!0,context:b})},clipboardTextSerializer:a=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(a.content):null}})]}}),ou=gD.create({name:"markdown",priority:50,addOptions:()=>({html:!0,tightLists:!0,tightListClass:"tight",bulletListMarker:"-",linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}),addCommands(){let a=gC.Commands.config.addCommands();return{setContent:(b,c)=>d=>a.setContent(d.editor.storage.markdown.parser.parse(b),c)(d),insertContentAt:(b,c,d)=>e=>a.insertContentAt(b,e.editor.storage.markdown.parser.parse(c,{inline:!0}),d)(e)}},onBeforeCreate(){this.editor.storage.markdown={options:{...this.options},parser:new or(this.editor,this.options),serializer:new oq(this.editor),getMarkdown:()=>this.editor.storage.markdown.serializer.serialize(this.editor.state.doc)},this.editor.options.initialContent=this.editor.options.content,this.editor.options.content=this.editor.storage.markdown.parser.parse(this.editor.options.content)},onCreate(){this.editor.options.content=this.editor.options.initialContent,delete this.editor.options.initialContent},addStorage:()=>({}),addExtensions(){return[n0.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),ot.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}});function ov(a){return a.storage.markdown.getMarkdown()}function ow(){return[{label:z.A.t("slashCommands.heading1"),icon:"H1",description:z.A.t("slashCommands.heading1Desc"),action:a=>a.chain().focus().toggleHeading({level:1}).run()},{label:z.A.t("slashCommands.heading2"),icon:"H2",description:z.A.t("slashCommands.heading2Desc"),action:a=>a.chain().focus().toggleHeading({level:2}).run()},{label:z.A.t("slashCommands.heading3"),icon:"H3",description:z.A.t("slashCommands.heading3Desc"),action:a=>a.chain().focus().toggleHeading({level:3}).run()},{label:z.A.t("slashCommands.bulletList"),icon:"•",description:z.A.t("slashCommands.bulletListDesc"),action:a=>a.chain().focus().toggleBulletList().run()},{label:z.A.t("slashCommands.orderedList"),icon:"1.",description:z.A.t("slashCommands.orderedListDesc"),action:a=>a.chain().focus().toggleOrderedList().run()},{label:z.A.t("slashCommands.taskList"),icon:"☑",description:z.A.t("slashCommands.taskListDesc"),action:a=>a.chain().focus().toggleTaskList().run()},{label:z.A.t("slashCommands.blockquote"),icon:"❝",description:z.A.t("slashCommands.blockquoteDesc"),action:a=>a.chain().focus().toggleBlockquote().run()},{label:z.A.t("slashCommands.codeBlock"),icon:"<>",description:z.A.t("slashCommands.codeBlockDesc"),action:a=>a.chain().focus().toggleCodeBlock().run()},{label:z.A.t("slashCommands.table"),icon:"▦",description:z.A.t("slashCommands.tableDesc"),action:a=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{label:z.A.t("slashCommands.horizontalRule"),icon:"──",description:z.A.t("slashCommands.horizontalRuleDesc"),action:a=>a.chain().focus().setHorizontalRule().run()},{label:z.A.t("slashCommands.link"),icon:"\uD83D\uDD17",description:z.A.t("slashCommands.linkDesc"),action:a=>{window.dispatchEvent(new CustomEvent("tiptap-insert-link"))}}]}function ox({editor:a,query:b,position:c,onClose:d}){let[e,f]=(0,x.useState)(0),g=(0,x.useRef)(null),h=ow().filter(a=>a.label.toLowerCase().includes(b.toLowerCase())||a.description.toLowerCase().includes(b.toLowerCase()));return 0===h.length?null:(0,w.jsx)("div",{ref:g,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lg py-1 w-56 max-h-64 overflow-y-auto",style:{top:c.top,left:c.left},children:h.map((c,g)=>(0,w.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${g===e?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>{a.chain().focus().deleteRange({from:a.state.selection.from-b.length-1,to:a.state.selection.from}).run(),c.action(a),d()},onMouseEnter:()=>f(g),children:[(0,w.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:c.icon}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("div",{className:"font-medium",children:c.label}),(0,w.jsx)("div",{className:"text-xs text-muted-foreground",children:c.description})]})]},c.label))})}function oy({editor:a,onClose:b,position:c}){let{t:d}=(0,y.Bd)(),[e,f]=(0,x.useState)(()=>a.getAttributes("link").href||""),g=(0,x.useRef)(null),h=()=>{let c=e.trim();if(c){let b=c.match(/^https?:\/\//)?c:`https://${c}`;a.chain().focus().extendMarkRange("link").setLink({href:b}).run()}else a.chain().focus().extendMarkRange("link").unsetLink().run();b()},i=c?{top:c.top,left:c.left}:{};return(0,w.jsxs)("div",{className:`${c?"fixed":"absolute top-full left-0 mt-1"} z-[60] bg-popover border border-border rounded-lg shadow-lg p-2 flex items-center gap-2`,style:i,children:[(0,w.jsx)("input",{ref:g,type:"text",value:e,onChange:a=>f(a.target.value),onKeyDown:a=>{"Enter"===a.key?(a.preventDefault(),h()):"Escape"===a.key&&(a.preventDefault(),b())},placeholder:d("editor.linkPlaceholder"),className:"bg-background border border-border rounded px-2 py-1 text-sm w-64 outline-none focus:border-brand"}),(0,w.jsx)("button",{onClick:h,className:"p-1 rounded text-sm font-medium text-brand hover:bg-brand/10 transition-colors",title:d("editor.confirmLink"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})}),a.isActive("link")&&(0,w.jsx)("button",{onClick:()=>{a.chain().focus().extendMarkRange("link").unsetLink().run(),b()},className:"p-1 rounded text-sm font-medium text-red-500 hover:bg-red-500/10 transition-colors",title:d("editor.removeLink"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})}function oz({editor:a}){let{t:b}=(0,y.Bd)(),[c,d]=(0,x.useState)(!1),e=(0,x.useRef)(null),[,f]=(0,x.useState)(0);if(!a)return null;let g=a=>`p-1.5 rounded text-xs font-medium transition-colors ${a?"bg-brand/15 text-brand":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,h="w-px h-5 bg-border mx-0.5",i=a.isActive("table");return(0,w.jsxs)("div",{className:"flex items-center gap-0.5 px-4 py-1.5 border-b border-border flex-shrink-0 flex-wrap",children:[(0,w.jsx)("button",{className:g(a.isActive("heading",{level:1})),onClick:()=>a.chain().focus().toggleHeading({level:1}).run(),title:b("editor.heading1"),children:"H1"}),(0,w.jsx)("button",{className:g(a.isActive("heading",{level:2})),onClick:()=>a.chain().focus().toggleHeading({level:2}).run(),title:b("editor.heading2"),children:"H2"}),(0,w.jsx)("button",{className:g(a.isActive("heading",{level:3})),onClick:()=>a.chain().focus().toggleHeading({level:3}).run(),title:b("editor.heading3"),children:"H3"}),(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:g(a.isActive("bold")),onClick:()=>a.chain().focus().toggleBold().run(),title:b("editor.bold"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})})}),(0,w.jsx)("button",{className:g(a.isActive("italic")),onClick:()=>a.chain().focus().toggleItalic().run(),title:b("editor.italic"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})})}),(0,w.jsx)("button",{className:g(a.isActive("strike")),onClick:()=>a.chain().focus().toggleStrike().run(),title:b("editor.strikethrough"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})})}),(0,w.jsx)("button",{className:g(a.isActive("code")),onClick:()=>a.chain().focus().toggleCode().run(),title:b("editor.inlineCode"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})})}),(0,w.jsx)("div",{className:h}),(0,w.jsxs)("div",{className:"relative",children:[(0,w.jsx)("button",{ref:e,className:g(a.isActive("link")),onClick:()=>d(!c),title:b("editor.link"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})})}),c&&(0,w.jsx)(oy,{editor:a,onClose:()=>d(!1),position:null})]}),(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:g(a.isActive("bulletList")),onClick:()=>a.chain().focus().toggleBulletList().run(),title:b("editor.bulletList"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})})}),(0,w.jsx)("button",{className:g(a.isActive("orderedList")),onClick:()=>a.chain().focus().toggleOrderedList().run(),title:b("editor.orderedList"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})})}),(0,w.jsx)("button",{className:g(a.isActive("taskList")),onClick:()=>a.chain().focus().toggleTaskList().run(),title:b("editor.taskList"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM17.99 9l-1.41-1.42-6.59 6.59-2.58-2.57-1.42 1.41 4 3.99z"})})}),(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:g(a.isActive("blockquote")),onClick:()=>a.chain().focus().toggleBlockquote().run(),title:b("editor.blockquote"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})}),(0,w.jsx)("button",{className:g(a.isActive("codeBlock")),onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.codeBlock"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H4V5h16v14zm-7.5-4.5L15 12l-2.5-2.5L11 11l1.5 1.5L11 14l1.5 1.5zM9.5 14.5L7 12l2.5-2.5L11 11 9.5 12.5 11 14l-1.5.5z"})})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:b("editor.table"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-9 15H4v-4h7v4zm0-6H4V7h7v4zm9 6h-7v-4h7v4zm0-6h-7V7h7v4z"})})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().setHorizontalRule().run(),title:b("editor.horizontalRule"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M4 11h16v2H4z"})})}),i&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().addRowBefore().run(),title:b("editor.insertRowAbove"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zM11 17H4v-2h7v2zm0-4H4v-2h7v2zm9 4h-7v-2h7v2zm0-4h-7v-2h7v2z"}),(0,w.jsx)("path",{d:"M14 1h-4v2H8v2h2v2h4V5h2V3h-2z",opacity:".6"})]})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().addRowAfter().run(),title:b("editor.insertRowBelow"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v10h20V6c0-1.1-.9-2-2-2zM11 12H4v-2h7v2zm0-4H4V6h7v2zm9 4h-7v-2h7v2zm0-4h-7V6h7v2z"}),(0,w.jsx)("path",{d:"M14 19h-4v2H8v2h2v-2h4v2h2v-2h-2z",opacity:".6"})]})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().addColumnBefore().run(),title:b("editor.insertColumnLeft"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 11H10v-2h7v2zm0-4H10V9h7v2z"}),(0,w.jsx)("path",{d:"M1 14v-4h2V8h2v2h-2v4h2v2H3v-2z",opacity:".6"})]})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().addColumnAfter().run(),title:b("editor.insertColumnRight"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M4 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h10V4H4zm7 11H4v-2h7v2zm0-4H4V9h7v2z"}),(0,w.jsx)("path",{d:"M18 4v20h2c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-2z"}),(0,w.jsx)("path",{d:"M21 14v-4h2V8h2v2h-2v4h2v2h-2v-2z",opacity:".6"})]})}),(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-500 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteRow().run(),title:b("editor.deleteRow"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zm-8 8H4v-2h8v2z"}),(0,w.jsx)("path",{d:"M15 13l-1.41 1.41L15.17 16l-1.58 1.59L15 19l1.59-1.59L18.17 19l1.42-1.41L18 16l1.59-1.59L18.17 13 16.59 14.41z",fill:"currentColor"})]})}),(0,w.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-500 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteColumn().run(),title:b("editor.deleteColumn"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 7H10V9h7v2z"}),(0,w.jsx)("path",{d:"M13 16l-1.41 1.41L13.17 19l-1.58 1.59L13 22l1.59-1.59L16.17 22l1.42-1.41L16 19l1.59-1.59L16.17 16l-1.58 1.41z",fill:"currentColor"})]})}),(0,w.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-500 hover:bg-red-500/10",onClick:()=>a.chain().focus().deleteTable().run(),title:b("editor.deleteTable"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]}),a.isActive("codeBlock")&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-500 hover:bg-red-500/10",onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.deleteCodeBlock"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})]})}function oA({isOpen:a,onClose:b,projectCwd:c,projectName:d}){let{t:e}=(0,y.Bd)(),[f,g]=(0,x.useState)(!0),[h,i]=(0,x.useState)(!1),j=(0,x.useRef)(null),k=(0,x.useRef)(!1),[l,m]=(0,x.useState)(null),n=(0,x.useRef)(null),o=c?`/api/note?cwd=${encodeURIComponent(c)}`:"/api/note",p=(0,x.useCallback)(async a=>{i(!0);try{await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:a})}),k.current=!1}catch(a){console.error("Failed to save note:",a)}finally{i(!1)}},[o]),q=(0,x.useCallback)(a=>{k.current=!0,j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{p(a)},5e3)},[p]),r=function(a={},b=[]){let c=(0,x.useRef)(a);c.current=a;let[d]=(0,x.useState)(()=>new hG(c)),e=(0,B.useSyncExternalStore)(d.subscribe,d.getEditor,d.getServerSnapshot);return(0,x.useDebugValue)(e),(0,x.useEffect)(d.onRender(b)),!function(a){var b;let[c]=(0,x.useState)(()=>new hD(a.editor)),d=(0,hx.useSyncExternalStoreWithSelector)(c.subscribe,c.getSnapshot,c.getServerSnapshot,a.selector,null!=(b=a.equalityFn)?b:hv);hC(()=>c.watch(a.editor),[a.editor,c]),(0,x.useDebugValue)(d)}({editor:e,selector:({transactionNumber:b})=>!1===a.shouldRerenderOnTransaction||void 0===a.shouldRerenderOnTransaction?null:a.immediatelyRender&&0===b?0:b+1}),e}({immediatelyRender:!1,extensions:[kH.configure({heading:{levels:[1,2,3]}}),kD.configure({placeholder:()=>z.A.t("editor.placeholder")}),lC.configure({resizable:!0}),lv,lt,lu,j2,jD.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"tiptap-link",target:"_blank",rel:"noopener noreferrer"}}),j1.configure({nested:!0}),ou.configure({html:!0,transformCopiedText:!0,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},handleClick:(a,b,c)=>{if(c.metaKey||c.ctrlKey){let c=a.state.doc.resolve(b).marks().find(a=>"link"===a.type.name)?.attrs;if(c?.href)return window.open(c.href,"_blank","noopener,noreferrer"),!0}return!1},handleKeyDown:(a,b)=>{if("Backspace"===b.key&&s.current){let a=s.current;if(a.isActive("codeBlock")){let{$from:b}=a.state.selection,c=b.node(b.depth);if("codeBlock"===c.type.name&&""===c.textContent)return a.chain().focus().toggleCodeBlock().run(),!0}}return"/"!==b.key||l||setTimeout(()=>{if(!s.current)return;let{from:a}=s.current.state.selection;if("/"===s.current.state.doc.textBetween(Math.max(0,a-1),a,"\n")){n.current=a;let b=s.current.view.coordsAtPos(a);m({query:"",position:{top:b.bottom+4,left:b.left}})}},0),!1}},onUpdate:({editor:a})=>{if(q(ov(a)),null!==n.current){let{from:b}=a.state.selection;if(b<n.current)m(null),n.current=null;else{let c=a.state.doc.textBetween(n.current,b,"\n");c.includes(" ")||c.includes("\n")?(m(null),n.current=null):m(a=>a?{...a,query:c}:null)}}}}),s=(0,x.useRef)(r),t=(0,x.useCallback)(()=>{j.current&&(clearTimeout(j.current),j.current=null),k.current&&r&&p(ov(r)),m(null),n.current=null,b()},[r,p,b]);return a?(0,w.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,w.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:t}),(0,w.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] mx-4 flex flex-col overflow-hidden",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("h2",{className:"text-sm font-medium text-foreground",children:d?e("editor.noteTitle",{name:d}):e("editor.noteUntitled")}),h&&(0,w.jsx)("span",{className:"text-xs text-muted-foreground",children:e("editor.saving")})]}),(0,w.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,w.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,w.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,w.jsx)(oz,{editor:r}),(0,w.jsx)("div",{className:"flex-1 overflow-y-auto",children:f?(0,w.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,w.jsx)("span",{children:e("common.loading")})}):(0,w.jsx)(hB,{editor:r})})]}),l&&r&&(0,w.jsx)(ox,{editor:r,query:l.query,position:l.position,onClose:()=>{m(null),n.current=null}})]}):null}ow()},48745:(a,b,c)=>{Promise.resolve().then(c.bind(c,41824)),Promise.resolve().then(c.bind(c,49090)),Promise.resolve().then(c.bind(c,43647)),Promise.resolve().then(c.bind(c,51675))},49090:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectItem() from the server but ProjectItem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/ProjectItem.tsx","ProjectItem")},50605:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>k});var e=c(48249),f=c(67484),g=c(81749),h=c(65256),i=c(61858),j=a([h]);function k({isOpen:a,onClose:b}){let[c,d]=(0,f.useState)([]),[j,m]=(0,f.useState)(!1),[n,o]=(0,f.useState)(""),[p,q]=(0,f.useState)(!1),[r,s]=(0,f.useState)(""),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useCallback)(async()=>{m(!0);try{let a=await fetch("/api/skills");if(a.ok){let b=await a.json();d(b)}}catch(a){console.error("Failed to load skills",a)}finally{m(!1)}},[]),y=(0,f.useMemo)(()=>{let a=n.trim().toLowerCase();return a?c.filter(b=>b.name.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):c},[c,n]),z=(0,f.useCallback)(async()=>{let a=r.trim();if(a){u(!0);try{let b=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})});if(!b.ok){let a=await b.json().catch(()=>({}));(0,g.oR)(a.error||"Failed to add skill","error");return}(0,g.oR)("Skill added","success"),s(""),q(!1),await x(),(0,i.k)()}catch(a){console.error(a),(0,g.oR)("Failed to add skill","error")}finally{u(!1)}}},[r,x]),A=(0,f.useCallback)(async a=>{try{if(!(await fetch(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"})).ok)return void(0,g.oR)("Failed to delete","error");d(b=>b.filter(b=>b.id!==a)),(0,i.k)()}catch(a){console.error(a),(0,g.oR)("Failed to delete","error")}},[]),B=(0,f.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,g.oR)("Path copied","success")}catch{(0,g.oR)("Failed to copy","error")}},[]);return a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-3xl h-[80vh] mx-4 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:"Skills"}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"Close",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"relative flex-1",children:[(0,e.jsxs)("svg",{className:"w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"11",cy:"11",r:"7",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-4.35-4.35"})]}),(0,e.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:"Search skills...",className:"w-full pl-8 pr-3 py-1.5 text-sm border border-border rounded-md bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,e.jsx)("button",{onClick:()=>q(!0),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 active:scale-95 transition-all",children:"+ Add Skill"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:j?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:"Loading..."}):0===y.length?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:0===c.length?'No skills yet. Click "Add Skill" to add one.':"No skills match your search."}):y.map(a=>(0,e.jsx)(l,{skill:a,onPreview:()=>w(a.id),onDelete:()=>A(a.id),onCopyPath:()=>B(a.path)},a.id))})]})]}),p&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:()=>{t||(q(!1),s(""))}}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-lg mx-4 p-5",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:"Add Skill"}),(0,e.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:"Absolute path to SKILL.md"}),(0,e.jsx)("input",{type:"text",value:r,onChange:a=>s(a.target.value),onKeyDown:a=>{"Enter"!==a.key||t||z()},placeholder:"/Users/you/.../skills/foo/SKILL.md",autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,e.jsx)("button",{onClick:()=>{q(!1),s("")},disabled:t,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50",children:"Cancel"}),(0,e.jsx)("button",{onClick:z,disabled:t||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 transition-colors disabled:opacity-50",children:t?"Adding...":"Add"})]})]})]}),v&&(0,e.jsx)(h.d,{skillId:v,onClose:()=>w(null)})]}):null}function l({skill:a,onPreview:b,onDelete:c,onCopyPath:d}){let[g,h]=(0,f.useState)(!1);return(0,e.jsx)("div",{className:`border border-border rounded-lg p-3 bg-card hover:bg-accent/30 transition-colors ${a.valid?"":"opacity-60"}`,children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"w-9 h-9 flex-shrink-0 flex items-center justify-center rounded-md bg-brand/10 text-brand text-lg",children:a.icon?(0,e.jsx)("span",{children:a.icon}):(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,e.jsxs)("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",a.name]}),a.description&&(0,e.jsx)("span",{className:"text-sm text-muted-foreground line-clamp-2",children:a.description}),!a.valid&&(0,e.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:"Invalid"})]}),a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 truncate",children:a.argumentHint}),(0,e.jsx)("div",{className:"flex items-center gap-1 mt-1",children:(0,e.jsx)("button",{onClick:d,className:"text-xs text-muted-foreground hover:text-foreground font-mono truncate text-left",title:"Copy path",children:a.path})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,e.jsx)("button",{onClick:b,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:"Preview",children:(0,e.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),g?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>{h(!1),c()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:"Confirm"}),(0,e.jsx)("button",{onClick:()=>h(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:"Cancel"})]}):(0,e.jsx)("button",{onClick:()=>h(!0),className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:"Delete",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 7h22M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3"})})})]})]})})}h=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},51675:(a,b,c)=>{"use strict";c.d(b,{Workspace:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Workspace() from the server but Workspace is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/Workspace.tsx","Workspace")},62807:(a,b,c)=>{"use strict";c.d(b,{w:()=>p});var d=c(48249),e=c(67484),f=c(44384);let g={"claude-opus-4-6":{label:"Opus 4.6",input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#f97316"},"claude-opus-4-5-20251101":{label:"Opus 4.5",input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#fb923c"},"claude-sonnet-4-6":{label:"Sonnet 4.6",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#3b82f6"},"claude-sonnet-4-5-20250929":{label:"Sonnet 4.5",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#60a5fa"},"claude-haiku-4-5-20251001":{label:"Haiku 4.5",input:1,output:5,cacheRead:.1,cacheWrite:1.25,color:"#22c55e"}},h={label:"",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#94a3b8"};function i(a){if(g[a])return g[a];let b=a.toLowerCase();return b.includes("opus")?{...h,input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#f97316"}:b.includes("haiku")?{...h,input:1,output:5,cacheRead:.1,cacheWrite:1.25,color:"#22c55e"}:h}function j(a){let b=g[a];return b?b.label:a.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/-/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function k(a){return(g[a]??i(a)).color}function l(a){return a>=1e9?`${(a/1e9).toFixed(1)}B`:a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function m(a){return a>=1e3?`$${a.toFixed(0)}`:a>=100?`$${a.toFixed(1)}`:`$${a.toFixed(2)}`}function n({data:a,height:b=200,formatValue:c=l}){let f=(0,e.useRef)(null),g=(0,e.useRef)(null),[h,i]=(0,e.useState)(null),j=(0,e.useRef)([]);(0,e.useCallback)(()=>{let d=f.current,e=g.current;if(!d||!e)return;let h=window.devicePixelRatio||1,i=e.getBoundingClientRect().width;d.width=i*h,d.height=b*h,d.style.width=`${i}px`,d.style.height=`${b}px`;let k=d.getContext("2d");k.scale(h,h),k.clearRect(0,0,i,b);let{labels:l,datasets:m}=a;if(0===l.length)return;let n=i-50-12,o=b-8-28,p=function(a){if(a<=0)return 1;let b=Math.pow(10,Math.floor(Math.log10(a))),c=a/b;return c<=1?b:c<=2?2*b:c<=5?5*b:10*b}(Math.max(1,...l.map((a,b)=>m.reduce((a,c)=>a+c.data[b],0))));k.fillStyle=getComputedStyle(d).getPropertyValue("color")||"#888",k.font="10px ui-monospace, monospace",k.textAlign="right",k.textBaseline="middle";for(let a=0;a<=4;a++){var q;let b=p/4*a,e=8+o-b/p*o;k.fillText(c(b),44,e),k.strokeStyle=(q="--border",getComputedStyle(d).getPropertyValue(q).trim()||"#333"),k.lineWidth=.5,k.beginPath(),k.moveTo(50,e),k.lineTo(50+n,e),k.stroke()}let r=n/l.length,s=Math.max(4,Math.min(.6*r,32)),t=[];l.forEach((a,b)=>{let c=50+b*r+(r-s)/2,e=0;m.forEach(d=>{var f,g,h,i,j,l;let m=d.data[b];if(m<=0)return;let n=m/p*o,q=8+o-e-n;k.fillStyle=d.color,f=k,g=c,h=q,i=s,l=2,(j=n)<1||(l=Math.min(l,j/2,i/2),f.beginPath(),f.moveTo(g+l,h),f.lineTo(g+i-l,h),f.quadraticCurveTo(g+i,h,g+i,h+l),f.lineTo(g+i,h+j-l),f.quadraticCurveTo(g+i,h+j,g+i-l,h+j),f.lineTo(g+l,h+j),f.quadraticCurveTo(g,h+j,g,h+j-l),f.lineTo(g,h+l),f.quadraticCurveTo(g,h,g+l,h),f.fill()),t.push({x:c,y:q,w:s,h:n,label:a,value:m,dataset:d.label,color:d.color}),e+=n}),k.fillStyle=getComputedStyle(d).getPropertyValue("color")||"#888",k.font="9px ui-monospace, monospace",k.textAlign="center",k.textBaseline="top",b%(l.length>20?Math.ceil(l.length/15):1)==0&&k.fillText(a,c+s/2,8+o+6)}),j.current=t},[a,b,c]);let k=(0,e.useCallback)(a=>{let b=f.current?.getBoundingClientRect();if(!b)return;let d=a.clientX-b.left,e=a.clientY-b.top,g=j.current.find(a=>d>=a.x&&d<=a.x+a.w&&e>=a.y&&e<=a.y+a.h);g?i({x:a.clientX-b.left,y:g.y-4,content:`${g.dataset}: ${c(g.value)}`}):i(null)},[c]);return(0,d.jsxs)("div",{ref:g,className:"relative w-full text-muted-foreground",children:[(0,d.jsx)("canvas",{ref:f,className:"w-full",style:{height:b},onMouseMove:k,onMouseLeave:()=>i(null)}),h&&(0,d.jsx)("div",{className:"absolute pointer-events-none bg-popover text-popover-foreground text-[10px] px-2 py-1 rounded shadow-lg border border-border whitespace-nowrap z-10",style:{left:h.x,top:h.y,transform:"translate(-50%, -100%)"},children:h.content})]})}function o({hourCounts:a}){let{t:b}=(0,f.Bd)(),c=Math.max(1,...Object.values(a)),e=Array.from({length:24},(a,b)=>b);return(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:b("tokenStats.activeHours")}),(0,d.jsx)("div",{className:"flex gap-[2px] items-end h-16",children:e.map(e=>{let f=a[String(e)]||0,g=f/c;return(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-0.5",title:b("tokenStats.hourSessions",{h:e,count:f}),children:[(0,d.jsx)("div",{className:"w-full rounded-sm transition-all",style:{height:`${Math.max(2,48*g)}px`,backgroundColor:g>0?`rgba(59, 130, 246, ${.2+.8*g})`:"var(--muted)"}}),e%3==0&&(0,d.jsx)("span",{className:"text-[8px] text-muted-foreground",children:e})]},e)})})]})}function p({isOpen:a,onClose:b}){var c;let g,h,{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(!0),[w,x]=(0,e.useState)("day"),[y,z]=(0,e.useState)("tokens"),[A,B]=(0,e.useState)("claude"),C=(0,e.useMemo)(()=>s?.modelUsage?Object.entries(s.modelUsage).filter(([a])=>!a.startsWith("<")).map(([a,b])=>{let c;return{id:a,label:j(a),color:k(a),usage:b,cost:(c=i(a),b.inputTokens/1e6*c.input+b.outputTokens/1e6*c.output+b.cacheReadInputTokens/1e6*c.cacheRead+b.cacheCreationInputTokens/1e6*c.cacheWrite),totalTokens:b.inputTokens+b.outputTokens+b.cacheReadInputTokens+b.cacheCreationInputTokens}}).sort((a,b)=>b.cost-a.cost):[],[s]),D=(0,e.useMemo)(()=>C.reduce((a,b)=>a+b.cost,0),[C]),E=(0,e.useMemo)(()=>C.map(a=>a.id),[C]),F=(0,e.useMemo)(()=>{let a={};for(let b of C)a[b.id]=b.totalTokens>0?b.cost/b.totalTokens:0;return a},[C]),{activityChart:G,tokenChart:H,costChart:I}=(0,e.useMemo)(()=>{let a=s?.dailyActivity||[],b=s?.dailyModelTokens||[];if("day"===w){let c=a.slice(-60),d=b.slice(-60),e={labels:c.map(a=>a.date.slice(5)),datasets:[{label:r("tokenStats.messages"),data:c.map(a=>a.messageCount),color:"#3b82f6"},{label:r("tokenStats.toolCalls"),data:c.map(a=>a.toolCallCount),color:"#22c55e"}]},f=d.map(a=>a.date.slice(5));return{activityChart:e,tokenChart:{labels:f,datasets:E.map(a=>({label:j(a),data:d.map(b=>b.tokensByModel[a]||0),color:k(a)}))},costChart:{labels:f,datasets:E.map(a=>({label:j(a),data:d.map(b=>(b.tokensByModel[a]||0)*(F[a]||0)),color:k(a)}))}}}if("week"===w){let c=function(a,b){let c=new Map;for(let b of a){let a=new Date(b.date),d=new Date(a);d.setDate(a.getDate()-a.getDay());let e=d.toISOString().slice(0,10),f=e.slice(5);c.has(e)||c.set(e,{label:f,messages:0,sessions:0,tools:0,tokensByModel:{}});let g=c.get(e);g.messages+=b.messageCount,g.sessions+=b.sessionCount,g.tools+=b.toolCallCount}for(let a of b){let b=new Date(a.date),d=new Date(b);d.setDate(b.getDate()-b.getDay());let e=d.toISOString().slice(0,10);c.has(e)||c.set(e,{label:e.slice(5),messages:0,sessions:0,tools:0,tokensByModel:{}});let f=c.get(e);for(let[b,c]of Object.entries(a.tokensByModel))f.tokensByModel[b]=(f.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:r("tokenStats.messages"),data:c.map(a=>a.messages),color:"#3b82f6"},{label:r("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:"#22c55e"}]};return{activityChart:e,tokenChart:{labels:d,datasets:E.map(a=>({label:j(a),data:c.map(b=>b.tokensByModel[a]||0),color:k(a)}))},costChart:{labels:d,datasets:E.map(a=>({label:j(a),data:c.map(b=>(b.tokensByModel[a]||0)*(F[a]||0)),color:k(a)}))}}}let c=function(a,b){let c=new Map;for(let b of a){let a=b.date.slice(0,7);c.has(a)||c.set(a,{label:a,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(a);d.messages+=b.messageCount,d.sessions+=b.sessionCount,d.tools+=b.toolCallCount}for(let a of b){let b=a.date.slice(0,7);c.has(b)||c.set(b,{label:b,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(b);for(let[b,c]of Object.entries(a.tokensByModel))d.tokensByModel[b]=(d.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:r("tokenStats.messages"),data:c.map(a=>a.messages),color:"#3b82f6"},{label:r("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:"#22c55e"}]};return{activityChart:e,tokenChart:{labels:d,datasets:E.map(a=>({label:j(a),data:c.map(b=>b.tokensByModel[a]||0),color:k(a)}))},costChart:{labels:d,datasets:E.map(a=>({label:j(a),data:c.map(b=>(b.tokensByModel[a]||0)*(F[a]||0)),color:k(a)}))}}},[s,w,E,F,r]);if(!a)return null;let J=[{key:"day",label:r("tokenStats.day")},{key:"week",label:r("tokenStats.week")},{key:"month",label:r("tokenStats.month")}];return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,d.jsxs)("div",{className:"relative bg-card rounded-xl shadow-xl w-full max-w-4xl mx-4 max-h-[90vh] flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-6 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("tokenStats.title")}),(0,d.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:["claude","claude2"].map(a=>(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${A===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{t(null),B(a)},children:"claude"===a?"Claude":"Claude 2"},a))}),(0,d.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:J.map(a=>(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${w===a.key?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>x(a.key),children:a.label},a.key))})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-6",children:u?(0,d.jsx)("div",{className:"text-center text-muted-foreground py-12",children:r("common.loading")}):s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,d.jsx)(q,{label:r("tokenStats.totalSessions"),value:String(s.totalSessions??0)}),(0,d.jsx)(q,{label:r("tokenStats.totalMessages"),value:l(s.totalMessages??0)}),(0,d.jsx)(q,{label:r("tokenStats.equivalentApiCost"),value:m(D),highlight:!0}),(0,d.jsx)(q,{label:r("tokenStats.longestSession"),value:s.longestSession?(g=Math.floor((c=s.longestSession.duration)/36e5),h=Math.floor(c%36e5/6e4),g>0?`${g}h ${h}m`:`${h}m`):"-"}),(0,d.jsx)(q,{label:r("tokenStats.firstUse"),value:s.firstSessionDate?s.firstSessionDate.slice(0,10):"-"})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:r("tokenStats.activityTrend")}),(0,d.jsxs)("div",{className:"flex items-center gap-3 text-[10px]",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"#3b82f6"}}),r("tokenStats.messages")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"#22c55e"}}),r("tokenStats.toolCalls")]})]})]}),(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(n,{data:G,height:180})})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:r("tokenStats.byModel")}),(0,d.jsxs)("div",{className:"flex bg-muted rounded-md p-0.5",children:[(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"tokens"===y?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>z("tokens"),children:r("tokenStats.tokenUsage")}),(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"cost"===y?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>z("cost"),children:r("tokenStats.equivalentCost")})]})]}),(0,d.jsx)("div",{className:"flex items-center gap-3 text-[10px] flex-wrap",children:C.map(a=>(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:a.color}}),a.label]},a.id))})]}),(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(n,{data:"tokens"===y?H:I,height:180,formatValue:"tokens"===y?l:m})})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:r("tokenStats.modelCostDetail")}),(0,d.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,d.jsxs)("table",{className:"w-full text-xs",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"bg-muted/50 text-muted-foreground",children:[(0,d.jsx)("th",{className:"text-left px-3 py-2 font-medium",children:r("tokenStats.model")}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Input"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Output"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Read"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Write"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:r("tokenStats.share")}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:r("tokenStats.equivalentCost")})]})}),(0,d.jsxs)("tbody",{children:[C.map(a=>(0,d.jsxs)("tr",{className:"border-t border-border",children:[(0,d.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a.color}}),a.label]})}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(a.usage.inputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(a.usage.outputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(a.usage.cacheReadInputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(a.usage.cacheCreationInputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D>0?`${(a.cost/D*100).toFixed(1)}%`:"-"}),(0,d.jsx)("td",{className:"px-3 py-2 text-right font-medium text-foreground",children:m(a.cost)})]},a.id)),(0,d.jsxs)("tr",{className:"border-t-2 border-border bg-muted/30",children:[(0,d.jsx)("td",{className:"px-3 py-2 font-medium text-foreground",children:r("tokenStats.total")}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(C.reduce((a,b)=>a+b.usage.inputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(C.reduce((a,b)=>a+b.usage.outputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(C.reduce((a,b)=>a+b.usage.cacheReadInputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(C.reduce((a,b)=>a+b.usage.cacheCreationInputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:"100%"}),(0,d.jsx)("td",{className:"px-3 py-2 text-right font-bold text-foreground",children:m(D)})]})]})]})})]}),s.hourCounts&&Object.keys(s.hourCounts).length>0&&(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(o,{hourCounts:s.hourCounts})})]}):(0,d.jsx)("div",{className:"text-center text-muted-foreground py-12",children:r("tokenStats.notFound")})})]})]})}function q({label:a,value:b,highlight:c}){return(0,d.jsxs)("div",{className:"bg-muted/30 rounded-lg px-3 py-2.5",children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:a}),(0,d.jsx)("div",{className:`text-sm font-semibold mt-0.5 ${c?"text-brand":"text-foreground"}`,children:b})]})}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},65256:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{d:()=>k});var e=c(48249),f=c(67484),g=c(49280),h=c(79029),i=c(81749),j=a([h]);function k({skillId:a,onClose:b}){let[c,d]=(0,f.useState)(null),[j,l]=(0,f.useState)(!0),[m,n]=(0,f.useState)("preview"),o=(0,f.useCallback)(async()=>{if(c?.path)try{await navigator.clipboard.writeText(c.path),(0,i.oR)("Path copied","success")}catch{(0,i.oR)("Failed to copy","error")}},[c]);return(0,e.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-4xl h-[85vh] mx-4 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground truncate",children:c?.name?`/${c.name}`:"Skill Preview"}),(0,e.jsx)("button",{onClick:o,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"Copy path",children:(0,e.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})]}),c?.path&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5",children:c.path})]}),(0,e.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,e.jsx)("button",{onClick:()=>n("preview"),className:`px-3 py-1 transition-colors ${"preview"===m?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:"Preview"}),(0,e.jsx)("button",{onClick:()=>n("source"),className:`px-3 py-1 transition-colors ${"source"===m?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:"Source"})]}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors flex-shrink-0",title:"Close",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:j?(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading..."}):c&&c.valid?"preview"===m?(0,e.jsx)("div",{className:"px-6 py-4",children:(0,e.jsx)(g.T,{content:c.content})}):(0,e.jsx)(h.XO,{content:c.content,filePath:c.path,className:"min-h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"File cannot be read."})})]})]})}h=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},68122:(a,b,c)=>{"use strict";c.d(b,{M:()=>m,O:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(74429);let h=[],i=[];function j(){i.forEach(a=>a())}function k(a){let b=`session-toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;h=[...h,{...a,id:b}],j()}function l(a){h=h.filter(b=>b.id!==a),j()}function m({onNavigate:a}){let b=function(){let[,a]=(0,e.useState)(0);return h}();return 0===b.length?null:(0,g.createPortal)((0,d.jsx)("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none",children:b.map(b=>(0,d.jsx)(n,{item:b,onNavigate:a,onRemove:l},b.id))}),document.body)}function n({item:a,onNavigate:b,onRemove:c}){let{t:g}=(0,f.Bd)(),[h,i]=(0,e.useState)(!1),j=(0,e.useRef)(void 0),k=(0,e.useCallback)(()=>{i(!0),setTimeout(()=>c(a.id),300)},[a.id,c]),l=(0,e.useCallback)(()=>{clearTimeout(j.current),b(a.cwd,a.sessionId),c(a.id)},[a,b,c]),m=(0,e.useCallback)(()=>{clearTimeout(j.current)},[]),o=(0,e.useCallback)(()=>{j.current=setTimeout(k,2e3)},[k]);return(0,d.jsxs)("div",{className:`pointer-events-auto bg-card border border-border rounded-lg shadow-lg px-3 py-2.5 min-w-[260px] max-w-[340px] cursor-pointer hover:bg-accent transition-all ${h?"opacity-0 -translate-x-4":"opacity-100 translate-x-0"}`,style:{animation:h?void 0:"slideInLeft 0.3s ease-out"},onClick:l,onMouseEnter:m,onMouseLeave:o,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-green-9 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.projectName}),(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:g("common.done")}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k()},className:"ml-auto p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.message&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground truncate mt-1 ml-6",children:a.message})]})}},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},73136:a=>{"use strict";a.exports=require("node:url")},76760:a=>{"use strict";a.exports=require("node:path")},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},78908:a=>{"use strict";a.exports=import("shiki")},79327:a=>{"use strict";a.exports=require("node:process")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")}};var b=require("../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,8465,4793,3353,6043,7514,4732],()=>b(b.s=38194));module.exports=c})();
96
+ `,h.outerHTML):g)):(console.warn(`Tiptap Markdown: "${b.type.name}" node is only available in html mode`),a.write(`[${b.type.name}]`)),b.isBlock&&a.closeBlock(b)},parse:{}}})}),n9=g2.create({name:"blockquote"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.blockquote,parse:{}}})}),oa=g2.create({name:"bulletList"}).extend({addStorage:()=>({markdown:{serialize(a,b){return a.renderList(b," ",()=>(this.editor.storage.markdown.options.bulletListMarker||"-")+" ")},parse:{}}})}),ob=g2.create({name:"codeBlock"}).extend({addStorage:()=>({markdown:{serialize(a,b){a.write("```"+(b.attrs.language||"")+"\n"),a.text(b.textContent,!1),a.ensureNewLine(),a.write("```"),a.closeBlock(b)},parse:{setup(a){var b;a.set({langPrefix:null!=(b=this.options.languageClassPrefix)?b:"language-"})},updateDOM(a){a.innerHTML=a.innerHTML.replace(/\n<\/code><\/pre>/g,"</code></pre>")}}}})}),oc=g2.create({name:"hardBreak"}).extend({addStorage:()=>({markdown:{serialize(a,b,c,d){for(let e=d+1;e<c.childCount;e++)if(c.child(e).type!=b.type)return void a.write(a.inTable?n8.storage.markdown.serialize.call(this,a,b,c):"\\\n")},parse:{}}})}),od=g2.create({name:"heading"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.heading,parse:{}}})}),oe=g2.create({name:"horizontalRule"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.horizontal_rule,parse:{}}})}),of=g2.create({name:"image"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.image,parse:{}}})}),og=g2.create({name:"listItem"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.list_item,parse:{}}})}),oh=g2.create({name:"orderedList"}).extend({addStorage:()=>({markdown:{serialize(a,b,c,d){let e=b.attrs.start||1,f=String(e+b.childCount-1).length,g=a.repeat(" ",f+2),h=function(a,b,c){let d=0;for(;c-d>0&&b.child(c-d-1).type.name===a.type.name;d++);return d}(b,c,d)%2?") ":". ";a.renderList(b,g,b=>{let c=String(e+b);return a.repeat(" ",f-c.length)+c+h})},parse:{}}})}),oi=g2.create({name:"paragraph"}).extend({addStorage:()=>({markdown:{serialize:nW.nodes.paragraph,parse:{}}})});function oj(a){var b,c;return null!=(b=null==a||null==(c=a.content)?void 0:c.content)?b:[]}let ok=g2.create({name:"table"}).extend({addStorage:()=>({markdown:{serialize(a,b,c){let d,e,f;(e=(d=oj(b))[0],f=d.slice(1),oj(e).some(a=>"tableHeader"!==a.type.name||ol(a)||a.childCount>1)||f.some(a=>oj(a).some(a=>"tableHeader"===a.type.name||ol(a)||a.childCount>1)))?n8.storage.markdown.serialize.call(this,a,b,c):(a.inTable=!0,b.forEach((b,c,d)=>{if(a.write("| "),b.forEach((b,c,d)=>{d&&a.write(" | ");let e=b.firstChild;e.textContent.trim()&&a.renderInline(e)}),a.write(" |"),a.ensureNewLine(),!d){let c=Array.from({length:b.childCount}).map(()=>"---").join(" | ");a.write(`| ${c} |`),a.ensureNewLine()}}),a.closeBlock(b),a.inTable=!1)},parse:{}}})});function ol(a){return a.attrs.colspan>1||a.attrs.rowspan>1}let om=g2.create({name:"taskItem"}).extend({addStorage:()=>({markdown:{serialize(a,b){let c=b.attrs.checked?"[x]":"[ ]";a.write(`${c} `),a.renderContent(b)},parse:{updateDOM(a){[...a.querySelectorAll(".task-list-item")].forEach(a=>{let b=a.querySelector("input");a.setAttribute("data-type","taskItem"),b&&(a.setAttribute("data-checked",b.checked),b.remove())})}}}})}),on=g2.create({name:"taskList"}).extend({addStorage:()=>({markdown:{serialize:oa.storage.markdown.serialize,parse:{setup(a){a.use(nZ)},updateDOM(a){[...a.querySelectorAll(".contains-task-list")].forEach(a=>{a.setAttribute("data-type","taskList")})}}}})}),oo=[n9,oa,ob,oc,od,oe,n8,of,og,oh,oi,ok,om,on,g2.create({name:"text"}).extend({addStorage:()=>({markdown:{serialize(a,b){var c;a.text(null==(c=b.text)?void 0:c.replace(/</g,"&lt;").replace(/>/g,"&gt;"))},parse:{}}})}),gy.create({name:"bold"}).extend({addStorage:()=>({markdown:{serialize:nW.marks.strong,parse:{}}})}),gy.create({name:"code"}).extend({addStorage:()=>({markdown:{serialize:nW.marks.code,parse:{}}})}),n5,gy.create({name:"italic"}).extend({addStorage:()=>({markdown:{serialize:nW.marks.em,parse:{}}})}),gy.create({name:"link"}).extend({addStorage:()=>({markdown:{serialize:nW.marks.link,parse:{}}})}),gy.create({name:"strike"}).extend({addStorage:()=>({markdown:{serialize:{open:"~~",close:"~~",expelEnclosingWhitespace:!0},parse:{}}})})];function op(a){var b,c;let d=null==(b=a.storage)?void 0:b.markdown,e=null==(c=oo.find(b=>b.name===a.name))?void 0:c.storage.markdown;return d||e?{...e,...d}:null}class oq{constructor(a){n_(this,"editor",null),this.editor=a}serialize(a){let b=new n4(this.nodes,this.marks,{hardBreakNodeName:oc.name});return b.renderContent(a),b.out}get nodes(){var a;return{...Object.fromEntries(Object.keys(this.editor.schema.nodes).map(a=>[a,this.serializeNode(n8)])),...Object.fromEntries(null!=(a=this.editor.extensionManager.extensions.filter(a=>"node"===a.type&&this.serializeNode(a)).map(a=>[a.name,this.serializeNode(a)]))?a:[])}}get marks(){var a;return{...Object.fromEntries(Object.keys(this.editor.schema.marks).map(a=>[a,this.serializeMark(n5)])),...Object.fromEntries(null!=(a=this.editor.extensionManager.extensions.filter(a=>"mark"===a.type&&this.serializeMark(a)).map(a=>[a.name,this.serializeMark(a)]))?a:[])}}serializeNode(a){var b;return null==(b=op(a))||null==(b=b.serialize)?void 0:b.bind({editor:this.editor,options:a.options})}serializeMark(a){var b;let c=null==(b=op(a))?void 0:b.serialize;return c?{...c,open:"function"==typeof c.open?c.open.bind({editor:this.editor,options:a.options}):c.open,close:"function"==typeof c.close?c.close.bind({editor:this.editor,options:a.options}):c.close}:null}}class or{constructor(a,b){n_(this,"editor",null),n_(this,"md",null);let{html:c,linkify:d,breaks:e}=b;this.editor=a,this.md=this.withPatchedRenderer(nL({html:c,linkify:d,breaks:e}))}parse(a){let{inline:b}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof a){this.editor.extensionManager.extensions.forEach(a=>{var b;return null==(b=op(a))||null==(b=b.parse)||null==(b=b.setup)?void 0:b.call({editor:this.editor,options:a.options},this.md)});let c=n7(this.md.render(a));return this.editor.extensionManager.extensions.forEach(a=>{var b;return null==(b=op(a))||null==(b=b.parse)||null==(b=b.updateDOM)?void 0:b.call({editor:this.editor,options:a.options},c)}),this.normalizeDOM(c,{inline:b,content:a}),c.innerHTML}return a}normalizeDOM(a,b){let{inline:c,content:d}=b;return this.normalizeBlocks(a),a.querySelectorAll("*").forEach(a=>{var b;(null==(b=a.nextSibling)?void 0:b.nodeType)!==Node.TEXT_NODE||a.closest("pre")||(a.nextSibling.textContent=a.nextSibling.textContent.replace(/^\n/,""))}),c&&this.normalizeInline(a,d),a}normalizeBlocks(a){let b=Object.values(this.editor.schema.nodes).filter(a=>a.isBlock).map(a=>{var b;return null==(b=a.spec.parseDOM)?void 0:b.map(a=>a.tag)}).flat().filter(Boolean).join(",");b&&[...a.querySelectorAll(b)].forEach(a=>{a.parentElement.matches("p")&&function(a){let b=a.parentElement,c=b.cloneNode();for(;b.firstChild&&b.firstChild!==a;)c.appendChild(b.firstChild);c.childNodes.length>0&&b.parentElement.insertBefore(c,b),b.parentElement.insertBefore(a,b),0===b.childNodes.length&&b.remove()}(a)})}normalizeInline(a,b){var c,d,e,f,g;if(null!=(c=a.firstElementChild)&&c.matches("p")){let c=a.firstElementChild,{nextElementSibling:h}=c,i=null!=(d=null==(e=b.match(/^\s+/))?void 0:e[0])?d:"",j=h?"":null!=(f=null==(g=b.match(/\s+$/))?void 0:g[0])?f:"";if(b.match(/^\n\n/)){c.innerHTML=`${c.innerHTML}${j}`;return}let k=c.parentNode;for(;c.firstChild;)k.insertBefore(c.firstChild,c);k.removeChild(c),a.innerHTML=`${i}${a.innerHTML}${j}`}}withPatchedRenderer(a){let b=a=>function(){let b=a(...arguments);return"\n"===b?b:"\n"===b[b.length-1]?b.slice(0,-1):b};return a.renderer.rules.hardbreak=b(a.renderer.rules.hardbreak),a.renderer.rules.softbreak=b(a.renderer.rules.softbreak),a.renderer.rules.fence=b(a.renderer.rules.fence),a.renderer.rules.code_block=b(a.renderer.rules.code_block),a.renderer.renderToken=b(a.renderer.renderToken.bind(a.renderer)),a}}let ot=gD.create({name:"markdownClipboard",addOptions:()=>({transformPastedText:!1,transformCopiedText:!1}),addProseMirrorPlugins(){return[new br({key:new bu("markdownClipboard"),props:{clipboardTextParser:(a,b,c)=>{if(c||!this.options.transformPastedText)return null;let d=this.editor.storage.markdown.parser.parse(a,{inline:!0});return al.fromSchema(this.editor.schema).parseSlice(n7(d),{preserveWhitespace:!0,context:b})},clipboardTextSerializer:a=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(a.content):null}})]}}),ou=gD.create({name:"markdown",priority:50,addOptions:()=>({html:!0,tightLists:!0,tightListClass:"tight",bulletListMarker:"-",linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}),addCommands(){let a=gC.Commands.config.addCommands();return{setContent:(b,c)=>d=>a.setContent(d.editor.storage.markdown.parser.parse(b),c)(d),insertContentAt:(b,c,d)=>e=>a.insertContentAt(b,e.editor.storage.markdown.parser.parse(c,{inline:!0}),d)(e)}},onBeforeCreate(){this.editor.storage.markdown={options:{...this.options},parser:new or(this.editor,this.options),serializer:new oq(this.editor),getMarkdown:()=>this.editor.storage.markdown.serializer.serialize(this.editor.state.doc)},this.editor.options.initialContent=this.editor.options.content,this.editor.options.content=this.editor.storage.markdown.parser.parse(this.editor.options.content)},onCreate(){this.editor.options.content=this.editor.options.initialContent,delete this.editor.options.initialContent},addStorage:()=>({}),addExtensions(){return[n0.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),ot.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}});function ov(a){return a.storage.markdown.getMarkdown()}function ow(){return[{label:z.A.t("slashCommands.heading1"),icon:"H1",description:z.A.t("slashCommands.heading1Desc"),action:a=>a.chain().focus().toggleHeading({level:1}).run()},{label:z.A.t("slashCommands.heading2"),icon:"H2",description:z.A.t("slashCommands.heading2Desc"),action:a=>a.chain().focus().toggleHeading({level:2}).run()},{label:z.A.t("slashCommands.heading3"),icon:"H3",description:z.A.t("slashCommands.heading3Desc"),action:a=>a.chain().focus().toggleHeading({level:3}).run()},{label:z.A.t("slashCommands.bulletList"),icon:"•",description:z.A.t("slashCommands.bulletListDesc"),action:a=>a.chain().focus().toggleBulletList().run()},{label:z.A.t("slashCommands.orderedList"),icon:"1.",description:z.A.t("slashCommands.orderedListDesc"),action:a=>a.chain().focus().toggleOrderedList().run()},{label:z.A.t("slashCommands.taskList"),icon:"☑",description:z.A.t("slashCommands.taskListDesc"),action:a=>a.chain().focus().toggleTaskList().run()},{label:z.A.t("slashCommands.blockquote"),icon:"❝",description:z.A.t("slashCommands.blockquoteDesc"),action:a=>a.chain().focus().toggleBlockquote().run()},{label:z.A.t("slashCommands.codeBlock"),icon:"<>",description:z.A.t("slashCommands.codeBlockDesc"),action:a=>a.chain().focus().toggleCodeBlock().run()},{label:z.A.t("slashCommands.table"),icon:"▦",description:z.A.t("slashCommands.tableDesc"),action:a=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{label:z.A.t("slashCommands.horizontalRule"),icon:"──",description:z.A.t("slashCommands.horizontalRuleDesc"),action:a=>a.chain().focus().setHorizontalRule().run()},{label:z.A.t("slashCommands.link"),icon:"\uD83D\uDD17",description:z.A.t("slashCommands.linkDesc"),action:a=>{window.dispatchEvent(new CustomEvent("tiptap-insert-link"))}}]}function ox({editor:a,query:b,position:c,onClose:d}){let[e,f]=(0,x.useState)(0),g=(0,x.useRef)(null),h=ow().filter(a=>a.label.toLowerCase().includes(b.toLowerCase())||a.description.toLowerCase().includes(b.toLowerCase()));return 0===h.length?null:(0,w.jsx)("div",{ref:g,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lg py-1 w-56 max-h-64 overflow-y-auto",style:{top:c.top,left:c.left},children:h.map((c,g)=>(0,w.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${g===e?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>{a.chain().focus().deleteRange({from:a.state.selection.from-b.length-1,to:a.state.selection.from}).run(),c.action(a),d()},onMouseEnter:()=>f(g),children:[(0,w.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:c.icon}),(0,w.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,w.jsx)("div",{className:"font-medium",children:c.label}),(0,w.jsx)("div",{className:"text-xs text-muted-foreground",children:c.description})]})]},c.label))})}function oy({editor:a,onClose:b,position:c}){let{t:d}=(0,y.Bd)(),[e,f]=(0,x.useState)(()=>a.getAttributes("link").href||""),g=(0,x.useRef)(null),h=()=>{let c=e.trim();if(c){let b=c.match(/^https?:\/\//)?c:`https://${c}`;a.chain().focus().extendMarkRange("link").setLink({href:b}).run()}else a.chain().focus().extendMarkRange("link").unsetLink().run();b()},i=c?{top:c.top,left:c.left}:{};return(0,w.jsxs)("div",{className:`${c?"fixed":"absolute top-full left-0 mt-1"} z-[60] bg-popover border border-border rounded-lg shadow-lg p-2 flex items-center gap-2`,style:i,children:[(0,w.jsx)("input",{ref:g,type:"text",value:e,onChange:a=>f(a.target.value),onKeyDown:a=>{"Enter"===a.key?(a.preventDefault(),h()):"Escape"===a.key&&(a.preventDefault(),b())},placeholder:d("editor.linkPlaceholder"),className:"bg-background border border-border rounded px-2 py-1 text-sm w-64 outline-none focus:border-brand"}),(0,w.jsx)("button",{onClick:h,className:"p-1 rounded text-sm font-medium text-brand hover:bg-brand/10 transition-colors",title:d("editor.confirmLink"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})}),a.isActive("link")&&(0,w.jsx)("button",{onClick:()=>{a.chain().focus().extendMarkRange("link").unsetLink().run(),b()},className:"p-1 rounded text-sm font-medium text-red-500 hover:bg-red-500/10 transition-colors",title:d("editor.removeLink"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})}function oz({editor:a}){let{t:b}=(0,y.Bd)(),[c,d]=(0,x.useState)(!1),e=(0,x.useRef)(null),[,f]=(0,x.useState)(0);if(!a)return null;let g=a=>`p-1.5 rounded text-xs font-medium transition-colors ${a?"bg-brand/15 text-brand":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,h="w-px h-5 bg-border mx-0.5",i=a.isActive("table");return(0,w.jsxs)("div",{className:"flex items-center gap-0.5 px-4 py-1.5 border-b border-border flex-shrink-0 flex-wrap",children:[(0,w.jsx)("button",{className:g(a.isActive("heading",{level:1})),onClick:()=>a.chain().focus().toggleHeading({level:1}).run(),title:b("editor.heading1"),children:"H1"}),(0,w.jsx)("button",{className:g(a.isActive("heading",{level:2})),onClick:()=>a.chain().focus().toggleHeading({level:2}).run(),title:b("editor.heading2"),children:"H2"}),(0,w.jsx)("button",{className:g(a.isActive("heading",{level:3})),onClick:()=>a.chain().focus().toggleHeading({level:3}).run(),title:b("editor.heading3"),children:"H3"}),(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:g(a.isActive("bold")),onClick:()=>a.chain().focus().toggleBold().run(),title:b("editor.bold"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})})}),(0,w.jsx)("button",{className:g(a.isActive("italic")),onClick:()=>a.chain().focus().toggleItalic().run(),title:b("editor.italic"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})})}),(0,w.jsx)("button",{className:g(a.isActive("strike")),onClick:()=>a.chain().focus().toggleStrike().run(),title:b("editor.strikethrough"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})})}),(0,w.jsx)("button",{className:g(a.isActive("code")),onClick:()=>a.chain().focus().toggleCode().run(),title:b("editor.inlineCode"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})})}),(0,w.jsx)("div",{className:h}),(0,w.jsxs)("div",{className:"relative",children:[(0,w.jsx)("button",{ref:e,className:g(a.isActive("link")),onClick:()=>d(!c),title:b("editor.link"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})})}),c&&(0,w.jsx)(oy,{editor:a,onClose:()=>d(!1),position:null})]}),(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:g(a.isActive("bulletList")),onClick:()=>a.chain().focus().toggleBulletList().run(),title:b("editor.bulletList"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})})}),(0,w.jsx)("button",{className:g(a.isActive("orderedList")),onClick:()=>a.chain().focus().toggleOrderedList().run(),title:b("editor.orderedList"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})})}),(0,w.jsx)("button",{className:g(a.isActive("taskList")),onClick:()=>a.chain().focus().toggleTaskList().run(),title:b("editor.taskList"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM17.99 9l-1.41-1.42-6.59 6.59-2.58-2.57-1.42 1.41 4 3.99z"})})}),(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:g(a.isActive("blockquote")),onClick:()=>a.chain().focus().toggleBlockquote().run(),title:b("editor.blockquote"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})}),(0,w.jsx)("button",{className:g(a.isActive("codeBlock")),onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.codeBlock"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H4V5h16v14zm-7.5-4.5L15 12l-2.5-2.5L11 11l1.5 1.5L11 14l1.5 1.5zM9.5 14.5L7 12l2.5-2.5L11 11 9.5 12.5 11 14l-1.5.5z"})})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:b("editor.table"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-9 15H4v-4h7v4zm0-6H4V7h7v4zm9 6h-7v-4h7v4zm0-6h-7V7h7v4z"})})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().setHorizontalRule().run(),title:b("editor.horizontalRule"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M4 11h16v2H4z"})})}),i&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().addRowBefore().run(),title:b("editor.insertRowAbove"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zM11 17H4v-2h7v2zm0-4H4v-2h7v2zm9 4h-7v-2h7v2zm0-4h-7v-2h7v2z"}),(0,w.jsx)("path",{d:"M14 1h-4v2H8v2h2v2h4V5h2V3h-2z",opacity:".6"})]})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().addRowAfter().run(),title:b("editor.insertRowBelow"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v10h20V6c0-1.1-.9-2-2-2zM11 12H4v-2h7v2zm0-4H4V6h7v2zm9 4h-7v-2h7v2zm0-4h-7V6h7v2z"}),(0,w.jsx)("path",{d:"M14 19h-4v2H8v2h2v-2h4v2h2v-2h-2z",opacity:".6"})]})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().addColumnBefore().run(),title:b("editor.insertColumnLeft"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 11H10v-2h7v2zm0-4H10V9h7v2z"}),(0,w.jsx)("path",{d:"M1 14v-4h2V8h2v2h-2v4h2v2H3v-2z",opacity:".6"})]})}),(0,w.jsx)("button",{className:g(!1),onClick:()=>a.chain().focus().addColumnAfter().run(),title:b("editor.insertColumnRight"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M4 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h10V4H4zm7 11H4v-2h7v2zm0-4H4V9h7v2z"}),(0,w.jsx)("path",{d:"M18 4v20h2c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-2z"}),(0,w.jsx)("path",{d:"M21 14v-4h2V8h2v2h-2v4h2v2h-2v-2z",opacity:".6"})]})}),(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-500 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteRow().run(),title:b("editor.deleteRow"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M20 4H4c-1.1 0-2 .9-2 2v2h20V6c0-1.1-.9-2-2-2zm0 6H2v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10zm-8 8H4v-2h8v2z"}),(0,w.jsx)("path",{d:"M15 13l-1.41 1.41L15.17 16l-1.58 1.59L15 19l1.59-1.59L18.17 19l1.42-1.41L18 16l1.59-1.59L18.17 13 16.59 14.41z",fill:"currentColor"})]})}),(0,w.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-orange-500 hover:bg-orange-500/10",onClick:()=>a.chain().focus().deleteColumn().run(),title:b("editor.deleteColumn"),children:(0,w.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,w.jsx)("path",{d:"M6 4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h2V4H6zm4 0v20h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H10zm7 7H10V9h7v2z"}),(0,w.jsx)("path",{d:"M13 16l-1.41 1.41L13.17 19l-1.58 1.59L13 22l1.59-1.59L16.17 22l1.42-1.41L16 19l1.59-1.59L16.17 16l-1.58 1.41z",fill:"currentColor"})]})}),(0,w.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-500 hover:bg-red-500/10",onClick:()=>a.chain().focus().deleteTable().run(),title:b("editor.deleteTable"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]}),a.isActive("codeBlock")&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:h}),(0,w.jsx)("button",{className:"p-1.5 rounded text-xs font-medium transition-colors text-red-500 hover:bg-red-500/10",onClick:()=>a.chain().focus().toggleCodeBlock().run(),title:b("editor.deleteCodeBlock"),children:(0,w.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,w.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]})]})}function oA({isOpen:a,onClose:b,projectCwd:c,projectName:d}){let{t:e}=(0,y.Bd)(),[f,g]=(0,x.useState)(!0),[h,i]=(0,x.useState)(!1),j=(0,x.useRef)(null),k=(0,x.useRef)(!1),[l,m]=(0,x.useState)(null),n=(0,x.useRef)(null),o=c?`/api/note?cwd=${encodeURIComponent(c)}`:"/api/note",p=(0,x.useCallback)(async a=>{i(!0);try{await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:a})}),k.current=!1}catch(a){console.error("Failed to save note:",a)}finally{i(!1)}},[o]),q=(0,x.useCallback)(a=>{k.current=!0,j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{p(a)},5e3)},[p]),r=function(a={},b=[]){let c=(0,x.useRef)(a);c.current=a;let[d]=(0,x.useState)(()=>new hG(c)),e=(0,B.useSyncExternalStore)(d.subscribe,d.getEditor,d.getServerSnapshot);return(0,x.useDebugValue)(e),(0,x.useEffect)(d.onRender(b)),!function(a){var b;let[c]=(0,x.useState)(()=>new hD(a.editor)),d=(0,hx.useSyncExternalStoreWithSelector)(c.subscribe,c.getSnapshot,c.getServerSnapshot,a.selector,null!=(b=a.equalityFn)?b:hv);hC(()=>c.watch(a.editor),[a.editor,c]),(0,x.useDebugValue)(d)}({editor:e,selector:({transactionNumber:b})=>!1===a.shouldRerenderOnTransaction||void 0===a.shouldRerenderOnTransaction?null:a.immediatelyRender&&0===b?0:b+1}),e}({immediatelyRender:!1,extensions:[kH.configure({heading:{levels:[1,2,3]}}),kD.configure({placeholder:()=>z.A.t("editor.placeholder")}),lC.configure({resizable:!0}),lv,lt,lu,j2,jD.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"tiptap-link",target:"_blank",rel:"noopener noreferrer"}}),j1.configure({nested:!0}),ou.configure({html:!0,transformCopiedText:!0,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},handleClick:(a,b,c)=>{if(c.metaKey||c.ctrlKey){let c=a.state.doc.resolve(b).marks().find(a=>"link"===a.type.name)?.attrs;if(c?.href)return window.open(c.href,"_blank","noopener,noreferrer"),!0}return!1},handleKeyDown:(a,b)=>{if("Backspace"===b.key&&s.current){let a=s.current;if(a.isActive("codeBlock")){let{$from:b}=a.state.selection,c=b.node(b.depth);if("codeBlock"===c.type.name&&""===c.textContent)return a.chain().focus().toggleCodeBlock().run(),!0}}return"/"!==b.key||l||setTimeout(()=>{if(!s.current)return;let{from:a}=s.current.state.selection;if("/"===s.current.state.doc.textBetween(Math.max(0,a-1),a,"\n")){n.current=a;let b=s.current.view.coordsAtPos(a);m({query:"",position:{top:b.bottom+4,left:b.left}})}},0),!1}},onUpdate:({editor:a})=>{if(q(ov(a)),null!==n.current){let{from:b}=a.state.selection;if(b<n.current)m(null),n.current=null;else{let c=a.state.doc.textBetween(n.current,b,"\n");c.includes(" ")||c.includes("\n")?(m(null),n.current=null):m(a=>a?{...a,query:c}:null)}}}}),s=(0,x.useRef)(r),t=(0,x.useCallback)(()=>{j.current&&(clearTimeout(j.current),j.current=null),k.current&&r&&p(ov(r)),m(null),n.current=null,b()},[r,p,b]);return a?(0,w.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,w.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:t}),(0,w.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] mx-4 flex flex-col overflow-hidden",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsx)("h2",{className:"text-sm font-medium text-foreground",children:d?e("editor.noteTitle",{name:d}):e("editor.noteUntitled")}),h&&(0,w.jsx)("span",{className:"text-xs text-muted-foreground",children:e("editor.saving")})]}),(0,w.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,w.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,w.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,w.jsx)(oz,{editor:r}),(0,w.jsx)("div",{className:"flex-1 overflow-y-auto",children:f?(0,w.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,w.jsx)("span",{children:e("common.loading")})}):(0,w.jsx)(hB,{editor:r})})]}),l&&r&&(0,w.jsx)(ox,{editor:r,query:l.query,position:l.position,onClose:()=>{m(null),n.current=null}})]}):null}ow()},48745:(a,b,c)=>{Promise.resolve().then(c.bind(c,41824)),Promise.resolve().then(c.bind(c,49090)),Promise.resolve().then(c.bind(c,43647)),Promise.resolve().then(c.bind(c,51675))},49090:(a,b,c)=>{"use strict";c.d(b,{ProjectItem:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call ProjectItem() from the server but ProjectItem is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/ProjectItem.tsx","ProjectItem")},50605:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{g:()=>k});var e=c(48249),f=c(67484),g=c(81749),h=c(65256),i=c(61858),j=a([h]);function k({isOpen:a,onClose:b}){let[c,d]=(0,f.useState)([]),[j,m]=(0,f.useState)(!1),[n,o]=(0,f.useState)(""),[p,q]=(0,f.useState)(!1),[r,s]=(0,f.useState)(""),[t,u]=(0,f.useState)(!1),[v,w]=(0,f.useState)(null),x=(0,f.useCallback)(async()=>{m(!0);try{let a=await fetch("/api/skills");if(a.ok){let b=await a.json();d(b)}}catch(a){console.error("Failed to load skills",a)}finally{m(!1)}},[]),y=(0,f.useMemo)(()=>{let a=n.trim().toLowerCase();return a?c.filter(b=>b.name.toLowerCase().includes(a)||b.description.toLowerCase().includes(a)||b.path.toLowerCase().includes(a)):c},[c,n]),z=(0,f.useCallback)(async()=>{let a=r.trim();if(a){u(!0);try{let b=await fetch("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})});if(!b.ok){let a=await b.json().catch(()=>({}));(0,g.oR)(a.error||"Failed to add skill","error");return}(0,g.oR)("Skill added","success"),s(""),q(!1),await x(),(0,i.k)()}catch(a){console.error(a),(0,g.oR)("Failed to add skill","error")}finally{u(!1)}}},[r,x]),A=(0,f.useCallback)(async a=>{try{if(!(await fetch(`/api/skills/${encodeURIComponent(a)}`,{method:"DELETE"})).ok)return void(0,g.oR)("Failed to delete","error");d(b=>b.filter(b=>b.id!==a)),(0,i.k)()}catch(a){console.error(a),(0,g.oR)("Failed to delete","error")}},[]),B=(0,f.useCallback)(async a=>{try{await navigator.clipboard.writeText(a),(0,g.oR)("Path copied","success")}catch{(0,g.oR)("Failed to copy","error")}},[]);return a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-3xl h-[80vh] mx-4 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground",children:"Skills"}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"Close",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"relative flex-1",children:[(0,e.jsxs)("svg",{className:"w-4 h-4 absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("circle",{cx:"11",cy:"11",r:"7",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-4.35-4.35"})]}),(0,e.jsx)("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:"Search skills...",className:"w-full pl-8 pr-3 py-1.5 text-sm border border-border rounded-md bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,e.jsx)("button",{onClick:()=>q(!0),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 active:scale-95 transition-all",children:"+ Add Skill"})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:j?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:"Loading..."}):0===y.length?(0,e.jsx)("div",{className:"text-center text-muted-foreground py-8 text-sm",children:0===c.length?'No skills yet. Click "Add Skill" to add one.':"No skills match your search."}):y.map(a=>(0,e.jsx)(l,{skill:a,onPreview:()=>w(a.id),onDelete:()=>A(a.id),onCopyPath:()=>B(a.path)},a.id))})]})]}),p&&(0,e.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:()=>{t||(q(!1),s(""))}}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-lg mx-4 p-5",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-foreground mb-3",children:"Add Skill"}),(0,e.jsx)("label",{className:"block text-xs text-muted-foreground mb-1",children:"Absolute path to SKILL.md"}),(0,e.jsx)("input",{type:"text",value:r,onChange:a=>s(a.target.value),onKeyDown:a=>{"Enter"!==a.key||t||z()},placeholder:"/Users/you/.../skills/foo/SKILL.md",autoFocus:!0,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-md bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),(0,e.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,e.jsx)("button",{onClick:()=>{q(!1),s("")},disabled:t,className:"px-3 py-1.5 text-sm rounded-md border border-border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50",children:"Cancel"}),(0,e.jsx)("button",{onClick:z,disabled:t||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-brand text-white hover:bg-teal-10 transition-colors disabled:opacity-50",children:t?"Adding...":"Add"})]})]})]}),v&&(0,e.jsx)(h.d,{skillId:v,onClose:()=>w(null)})]}):null}function l({skill:a,onPreview:b,onDelete:c,onCopyPath:d}){let[g,h]=(0,f.useState)(!1);return(0,e.jsx)("div",{className:`border border-border rounded-lg p-3 bg-card hover:bg-accent/30 transition-colors ${a.valid?"":"opacity-60"}`,children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:"w-9 h-9 flex-shrink-0 flex items-center justify-center rounded-md bg-brand/10 text-brand text-lg",children:a.icon?(0,e.jsx)("span",{children:a.icon}):(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3l1.9 4.8L19 9l-4.1 3.1L16 18l-4-2.8L8 18l1.1-5.9L5 9l5.1-1.2L12 3z"})})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,e.jsxs)("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",a.name]}),a.description&&(0,e.jsx)("span",{className:"text-sm text-muted-foreground line-clamp-2",children:a.description}),!a.valid&&(0,e.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-red-9/15 text-red-11",children:"Invalid"})]}),a.argumentHint&&(0,e.jsx)("div",{className:"font-mono text-xs text-muted-foreground mt-0.5 truncate",children:a.argumentHint}),(0,e.jsx)("div",{className:"flex items-center gap-1 mt-1",children:(0,e.jsx)("button",{onClick:d,className:"text-xs text-muted-foreground hover:text-foreground font-mono truncate text-left",title:"Copy path",children:a.path})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,e.jsx)("button",{onClick:b,disabled:!a.valid,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:"Preview",children:(0,e.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}),g?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>{h(!1),c()},className:"px-2 py-1 text-xs rounded bg-red-9 text-white hover:bg-red-10",children:"Confirm"}),(0,e.jsx)("button",{onClick:()=>h(!1),className:"px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground",children:"Cancel"})]}):(0,e.jsx)("button",{onClick:()=>h(!0),className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-red-9/10 rounded transition-colors",title:"Delete",children:(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M1 7h22M9 7V4a1 1 0 011-1h4a1 1 0 011 1v3"})})})]})]})})}h=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},51675:(a,b,c)=>{"use strict";c.d(b,{Workspace:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Workspace() from the server but Workspace is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/cockpit/cockpit/src/components/workspace/Workspace.tsx","Workspace")},62399:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>M,handler:()=>O,routeModule:()=>N});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(63747),o=c(24235),p=c(23938),q=c(261),r=c(66758),s=c(77243),t=c(26713),u=c(37527),v=c(22820),w=c(88216),x=c(47929),y=c(79551),z=c(71797),A=c(89125),B=c(86439),C=c(77068),D=c(27269),E=c(61287),F=c(81494),G=c(70722),H=c(70753),I=c(43954),J=c(17891),K={};for(let a in E)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(K[a]=()=>E[a]);c.d(b,K);let L={children:["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,34396)),"/home/runner/work/cockpit/cockpit/src/app/page.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}}]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/home/runner/work/cockpit/cockpit/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.bind(c,81227)),"/home/runner/work/cockpit/cockpit/src/app/global-error.tsx"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:"/manifest.webmanifest"}},[]]}.children,M={require:c,loadChunk:()=>Promise.resolve()},N=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:L},distDir:".next-prod",relativeProjectDir:""});async function O(a,b,d){var K,P,Q,R,S;d.requestMeta&&(0,h.setRequestMeta)(a,d.requestMeta),N.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let T=!!(0,h.getRequestMeta)(a,"minimalMode"),U="/page";"/index"===U&&(U="/");let V=await N.prepare(a,b,{srcPage:U,multiZoneDraftMode:!1});if(!V)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:W,query:X,params:Y,pageIsDynamic:Z,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,serverActionsManifest:ab,clientReferenceManifest:ac,subresourceIntegrityManifest:ad,prerenderManifest:ae,isDraftMode:af,resolvedPathname:ag,revalidateOnlyGenerated:ah,routerServerContext:ai,nextConfig:aj,parsedUrl:ak,interceptionRoutePatterns:al,deploymentId:am,clientAssetToken:an}=V,ao=(0,q.normalizeAppPath)(U),{isOnDemandRevalidate:ap}=V,aq=aj.experimental.ppr&&!aj.cacheComponents&&(0,I.isInterceptionRouteAppPath)(ag)?null:N.match(ag,ae),ar=(null==aq?void 0:aq.route)??null,as=!!ae.routes[ag],at=a.headers["user-agent"]||"",au=(0,t.getBotType)(at),av=(0,p.isHtmlBotRequest)(a),aw=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ax=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ay=(0,r.getIsPossibleServerAction)(a),az=(0,m.checkIsAppPPREnabled)(aj.experimental.ppr),aA=a.headers[x.NEXT_RESUME_STATE_LENGTH_HEADER];if(!(0,h.getRequestMeta)(a,"postponed")&&T&&az&&ay&&aA&&"string"==typeof aA){let e=parseInt(aA,10),{maxPostponedStateSize:f,maxPostponedStateSizeBytes:g}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize);if(!isNaN(e)&&e>0){if(e>g)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(f)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let i="1 MB",j=(null==(S=aj.experimental.serverActions)?void 0:S.bodySizeLimit)??i,k=e+(j!==i?c(95726).parse(j):1048576),l=await (0,D.readBodyWithSizeLimit)(a,k);if(null===l)return b.statusCode=413,b.end("Request body exceeded limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;if(l.length>=e){let b=l.subarray(0,e).toString("utf8");(0,h.addRequestMeta)(a,"postponed",b);let c=l.subarray(e);(0,h.addRequestMeta)(a,"actionBody",c)}else throw Object.defineProperty(Error(`invariant: expected ${e} bytes of postponed state but only received ${l.length} bytes`),"__NEXT_ERROR_CODE",{value:"E979",enumerable:!1,configurable:!0})}}if(!(0,h.getRequestMeta)(a,"postponed")&&az&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let{maxPostponedStateSize:c,maxPostponedStateSizeBytes:e}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize),f=await (0,D.readBodyWithSizeLimit)(a,e);if(null===f)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(c)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let g=f.toString("utf8");(0,h.addRequestMeta)(a,"postponed",g)}let aB=!0===N.isDev||!0===aj.experimental.exposeTestingApiInProductionBuild,aC=aB&&("1"===a.headers[s.NEXT_INSTANT_PREFETCH_HEADER]||void 0===a.headers[s.RSC_HEADER]&&"string"==typeof a.headers.cookie&&a.headers.cookie.includes(s.NEXT_INSTANT_TEST_COOKIE+"=")),aD=(az||aC)&&((null==(K=ae.routes[ao]??ae.dynamicRoutes[ao])?void 0:K.renderingMode)==="PARTIALLY_STATIC"||aC&&(aB||(null==ai?void 0:ai.experimentalTestProxy)===!0)),aE=aC&&aD,aF=aE&&!0===N.isDev,aG=!1,aH=aD?(0,h.getRequestMeta)(a,"postponed"):void 0,aI=null==(P=ae.routes[ag])?void 0:P.prefetchDataRoute,aJ=aD&&ax&&!aw&&!aI;T&&(aJ=aJ&&!!aH);let aK=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),aL=(!au||!aD)&&(!at||(0,p.shouldServeStreamingMetadata)(at,aj.htmlLimitedBots)),aM=!!((ar||as||ae.routes[ao])&&!(au&&aD)),aN=aD&&!0===aj.cacheComponents,aO=!0===N.isDev||!aM||"string"==typeof aH||(aN&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aJ&&!T:aJ),aP=!!au&&aD,aQ=(null==ar?void 0:ar.remainingPrerenderableParams)??[],aR=(null==ar?void 0:ar.fallback)===null&&((null==(Q=ar.fallbackRootParams)?void 0:Q.length)??0)>0,aS=null;if(!af&&aM&&!aO&&!ay&&!aH&&!aJ){let a=aq?"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:aq.source:null;if(!0===aj.experimental.partialFallbacks&&a&&(null==ar?void 0:ar.fallbackRouteParams)&&!aR){if(aQ.length>0){let b,c=(b=new Map(aQ.map(a=>[a.paramName,a])),a.split("/").map(a=>{let c=(0,J.getSegmentParam)(a);if(!c)return a;let d=b.get(c.paramName);if(!d)return a;let e=null==Y?void 0:Y[d.paramName];if(!e)return a;let f=Array.isArray(e)?e.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(e);return a.replace(function(a){let{repeat:b,optional:c}=(0,J.getParamProperties)(a.paramType);return c?`[[...${a.paramName}]]`:b?`[...${a.paramName}]`:`[${a.paramName}]`}(d),f)}).join("/")||"/");aS=c!==a?c:null}}else aS=ag}let aT=aS;!aT&&(N.isDev||aM&&Z&&(null==ar?void 0:ar.fallbackRouteParams)&&!ay)&&(aT=ag),N.isDev||af||!aM||!ax||aJ||(0,k.d)(a.headers);let aU={...E,tree:L,handler:O,routeModule:N,__next_app__:M};ab&&ac&&(0,o.setManifestsSingleton)({page:U,clientReferenceManifest:ac,serverActionsManifest:ab});let aV=a.method||"GET",aW=(0,g.getTracer)(),aX=aW.getActiveScopeSpan(),aY=!!(null==ai?void 0:ai.isWrappedByNextServer),aZ=!0===aj.experimental.partialFallbacks&&aQ.length>0?(null==ar||null==(R=ar.fallbackRouteParams)?void 0:R.filter(a=>!aQ.some(b=>b.paramName===a.paramName)))??[]:[],a$=async()=>((null==ai?void 0:ai.render404)?await ai.render404(a,b,ak,!1):b.end("This page could not be found"),null);try{let k,m=N.getVaryHeader(ag,al);b.setHeader("Vary",m);let o=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return N.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aW.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aV} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a),k&&k!==c&&(k.setAttribute("http.route",d),k.updateName(a))}else c.updateName(`${aV} ${U}`)})},p=(0,h.getRequestMeta)(a,"incrementalCache")||await N.getIncrementalCache(a,aj,ae,T);null==p||p.resetRequestCache(),globalThis.__incrementalCache=p;let q=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let k={query:X,params:Y,page:ao,sharedContext:{buildId:W,deploymentId:am,clientAssetToken:an},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aU,Component:(0,j.T)(aU),params:Y,routeModule:N,page:U,postponed:f,shouldWaitOnAllReady:aP,serveStreamingMetadata:aL,supportsDynamicResponse:"string"==typeof f||aO,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,subresourceIntegrityManifest:ad,setCacheStatus:null==ai?void 0:ai.setCacheStatus,setIsrStatus:null==ai?void 0:ai.setIsrStatus,setReactDebugChannel:null==ai?void 0:ai.setReactDebugChannel,sendErrorsToBrowser:null==ai?void 0:ai.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),N.relativeProjectDir),isDraftMode:af,botType:au,isOnDemandRevalidate:ap,isPossibleServerAction:ay,assetPrefix:aj.assetPrefix,nextConfigOutput:aj.output,crossOrigin:aj.crossOrigin,trailingSlash:aj.trailingSlash,images:aj.images,previewProps:ae.preview,enableTainting:aj.experimental.taint,htmlLimitedBots:aj.htmlLimitedBots,reactMaxHeadersLength:aj.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:p,cacheLifeProfiles:aj.cacheLife,basePath:aj.basePath,serverActions:aj.experimental.serverActions,logServerFunctions:"object"==typeof aj.logging&&!!aj.logging.serverFunctions,...aE||aF||aG?{isBuildTimePrerendering:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:aF}:{},cacheComponents:!!aj.cacheComponents,experimental:{isRoutePPREnabled:aD,expireTime:aj.expireTime,staleTimes:aj.experimental.staleTimes,dynamicOnHover:!!aj.experimental.dynamicOnHover,optimisticRouting:!!aj.experimental.optimisticRouting,inlineCss:!!aj.experimental.inlineCss,prefetchInlining:aj.experimental.prefetchInlining??!1,authInterrupts:!!aj.experimental.authInterrupts,cachedNavigations:!!aj.experimental.cachedNavigations,clientTraceMetadata:aj.experimental.clientTraceMetadata||[],clientParamParsingOrigins:aj.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,C.parseMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>N.onRequestError(a,b,d,e,ai),err:(0,h.getRequestMeta)(a,"invokeError")}};i&&(k.renderOpts.supportsDynamicResponse=!1);let l=await o(e,k),{metadata:m}=l,{cacheControl:n,headers:q={},fetchTags:r,fetchMetrics:s}=m;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,aM&&(null==n?void 0:n.revalidate)===0&&!N.isDev&&!aD){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ag}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
97
+ see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:l,headers:q,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},r=async({hasResolved:c,previousCacheEntry:g,isRevalidating:i,span:j,forceStaticRender:k=!1})=>{let l=!1===N.isDev,m=c||b.writableEnded;try{let f;if(ap&&ah&&!g&&!T)return(null==ai?void 0:ai.render404)?await ai.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ar&&(f=(0,v.parseFallbackField)(ar.fallback)),!0===aj.experimental.partialFallbacks&&(null==ar?void 0:ar.fallback)===null&&!aR&&aQ.length>0&&(f=v.FallbackMode.PRERENDER),f===v.FallbackMode.PRERENDER&&(0,t.isBot)(at)&&(!aD||av)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==g?void 0:g.isStale)===-1&&(ap=!0),ap&&(f!==v.FallbackMode.NOT_FOUND||g)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),!T&&f!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aT&&!m&&!af&&Z&&(l||!as)){if((l||ar)&&f===v.FallbackMode.NOT_FOUND){if(aj.adapterPath)return await a$();throw new B.NoFallbackError}if(aD&&(aj.cacheComponents?!aJ:!ax)){let b=l&&"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:ao,f=(l||aE)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;aE&&f&&(0,h.addRequestMeta)(a,"fallbackParams",f);let g=await N.handleResponse({cacheKey:b,req:a,nextConfig:aj,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:ae,isRoutePPREnabled:aD,responseGenerator:async()=>q({span:j,postponed:void 0,fallbackRouteParams:f,forceStaticRender:!0}),waitUntil:d.waitUntil,isMinimalMode:T});if(null===g)return null;if(g)return T||!aD||!(aQ.length>0)||!0!==aj.experimental.partialFallbacks||!aS||!p||ap||aG||aB||aC||aw||(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(aS,p,aD,!1,a=>q({span:a.span,postponed:void 0,fallbackRouteParams:aZ.length>0?(0,n.createOpaqueFallbackRouteParams)(aZ):null,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}),delete g.cacheControl,g}}let o=ap||i||!aH?void 0:aH;if(aN&&!T&&p&&(aJ||ay)&&!k){let b=await p.get(ag,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(o=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(ag,p,aD,!1,a=>r({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if((aE||aF)&&void 0!==o)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=(l&&(0,h.getRequestMeta)(a,"renderFallbackShell")||aE&&!as)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;if((l||aE)&&aj.cacheComponents&&!as&&(null==ar?void 0:ar.fallbackRouteParams)){let b=(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams);b&&(0,h.addRequestMeta)(a,"fallbackParams",b)}return q({span:j,postponed:o,fallbackRouteParams:s,forceStaticRender:k})}catch(b){throw(null==g?void 0:g.isStale)&&await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}},D=async c=>{var f,g,i,j,k;let l,m=await N.handleResponse({cacheKey:aS,responseGenerator:a=>r({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ap,isRoutePPREnabled:aD,req:a,nextConfig:aj,prerenderManifest:ae,waitUntil:d.waitUntil,isMinimalMode:T});if(af&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),N.isDev&&b.setHeader("Cache-Control","no-cache, must-revalidate"),!m){if(aS)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;ax&&!ay&&am&&b.setHeader(x.NEXT_NAV_DEPLOYMENT_ID_HEADER,am),aM&&!aJ&&(!n||aw)&&(T||b.setHeader("x-nextjs-cache",ap?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:o}=m;if(aH)l={revalidate:0,expire:void 0};else if(aJ)l={revalidate:0,expire:void 0};else if(!N.isDev)if(af)l={revalidate:0,expire:void 0};else if(aM){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??aj.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR_SECONDS,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof aK&&(null==o?void 0:o.kind)===u.CachedRouteKind.APP_PAGE&&o.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=o.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];T&&aM&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=o.segmentData.get(aK);return void 0!==d?(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let p=aN?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(p&&await p(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(o.headers){let a={...o.headers};for(let[c,d]of(T&&aM||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=o.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(T&&aM&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!o.status||ax&&aD||(b.statusCode=o.status),!T&&o.status&&F.RedirectStatusCode[o.status]&&ax&&(b.statusCode=200),n&&!aJ&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ax&&!af){if(void 0===o.rscData){if(o.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(aj.cacheComponents)return b.statusCode=404,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new G.InvariantError(`Expected RSC response, got ${o.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:o.html,cacheControl:m.cacheControl})}return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(o.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=o.html;if(aC&&aE){let c=!0===N.isDev?crypto.randomUUID():null;return v.pipeThrough((0,z.createInstantTestScriptInsertionTransformStream)(c)),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})}if(!n||T||ax)return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:m.cacheControl});if(aE||aF)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let B=new TransformStream;return v.push(B.readable),q({span:c,postponed:o.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(B.writable)}).catch(a=>{B.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aY||!aX)return k=aW.getActiveScopeSpan(),await aW.withPropagatedContext(a.headers,()=>aW.trace(i.BaseServerSpan.handleRequest,{spanName:`${aV} ${U}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aV,"http.target":a.url}},D),void 0,!aY);await D(aX)}catch(b){throw b instanceof B.NoFallbackError||await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}}},62807:(a,b,c)=>{"use strict";c.d(b,{w:()=>p});var d=c(48249),e=c(67484),f=c(44384);let g={"claude-opus-4-6":{label:"Opus 4.6",input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#f97316"},"claude-opus-4-5-20251101":{label:"Opus 4.5",input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#fb923c"},"claude-sonnet-4-6":{label:"Sonnet 4.6",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#3b82f6"},"claude-sonnet-4-5-20250929":{label:"Sonnet 4.5",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#60a5fa"},"claude-haiku-4-5-20251001":{label:"Haiku 4.5",input:1,output:5,cacheRead:.1,cacheWrite:1.25,color:"#22c55e"}},h={label:"",input:3,output:15,cacheRead:.3,cacheWrite:3.75,color:"#94a3b8"};function i(a){if(g[a])return g[a];let b=a.toLowerCase();return b.includes("opus")?{...h,input:5,output:25,cacheRead:.5,cacheWrite:6.25,color:"#f97316"}:b.includes("haiku")?{...h,input:1,output:5,cacheRead:.1,cacheWrite:1.25,color:"#22c55e"}:h}function j(a){let b=g[a];return b?b.label:a.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/-/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function k(a){return(g[a]??i(a)).color}function l(a){return a>=1e9?`${(a/1e9).toFixed(1)}B`:a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function m(a){return a>=1e3?`$${a.toFixed(0)}`:a>=100?`$${a.toFixed(1)}`:`$${a.toFixed(2)}`}function n({data:a,height:b=200,formatValue:c=l}){let f=(0,e.useRef)(null),g=(0,e.useRef)(null),[h,i]=(0,e.useState)(null),j=(0,e.useRef)([]);(0,e.useCallback)(()=>{let d=f.current,e=g.current;if(!d||!e)return;let h=window.devicePixelRatio||1,i=e.getBoundingClientRect().width;d.width=i*h,d.height=b*h,d.style.width=`${i}px`,d.style.height=`${b}px`;let k=d.getContext("2d");k.scale(h,h),k.clearRect(0,0,i,b);let{labels:l,datasets:m}=a;if(0===l.length)return;let n=i-50-12,o=b-8-28,p=function(a){if(a<=0)return 1;let b=Math.pow(10,Math.floor(Math.log10(a))),c=a/b;return c<=1?b:c<=2?2*b:c<=5?5*b:10*b}(Math.max(1,...l.map((a,b)=>m.reduce((a,c)=>a+c.data[b],0))));k.fillStyle=getComputedStyle(d).getPropertyValue("color")||"#888",k.font="10px ui-monospace, monospace",k.textAlign="right",k.textBaseline="middle";for(let a=0;a<=4;a++){var q;let b=p/4*a,e=8+o-b/p*o;k.fillText(c(b),44,e),k.strokeStyle=(q="--border",getComputedStyle(d).getPropertyValue(q).trim()||"#333"),k.lineWidth=.5,k.beginPath(),k.moveTo(50,e),k.lineTo(50+n,e),k.stroke()}let r=n/l.length,s=Math.max(4,Math.min(.6*r,32)),t=[];l.forEach((a,b)=>{let c=50+b*r+(r-s)/2,e=0;m.forEach(d=>{var f,g,h,i,j,l;let m=d.data[b];if(m<=0)return;let n=m/p*o,q=8+o-e-n;k.fillStyle=d.color,f=k,g=c,h=q,i=s,l=2,(j=n)<1||(l=Math.min(l,j/2,i/2),f.beginPath(),f.moveTo(g+l,h),f.lineTo(g+i-l,h),f.quadraticCurveTo(g+i,h,g+i,h+l),f.lineTo(g+i,h+j-l),f.quadraticCurveTo(g+i,h+j,g+i-l,h+j),f.lineTo(g+l,h+j),f.quadraticCurveTo(g,h+j,g,h+j-l),f.lineTo(g,h+l),f.quadraticCurveTo(g,h,g+l,h),f.fill()),t.push({x:c,y:q,w:s,h:n,label:a,value:m,dataset:d.label,color:d.color}),e+=n}),k.fillStyle=getComputedStyle(d).getPropertyValue("color")||"#888",k.font="9px ui-monospace, monospace",k.textAlign="center",k.textBaseline="top",b%(l.length>20?Math.ceil(l.length/15):1)==0&&k.fillText(a,c+s/2,8+o+6)}),j.current=t},[a,b,c]);let k=(0,e.useCallback)(a=>{let b=f.current?.getBoundingClientRect();if(!b)return;let d=a.clientX-b.left,e=a.clientY-b.top,g=j.current.find(a=>d>=a.x&&d<=a.x+a.w&&e>=a.y&&e<=a.y+a.h);g?i({x:a.clientX-b.left,y:g.y-4,content:`${g.dataset}: ${c(g.value)}`}):i(null)},[c]);return(0,d.jsxs)("div",{ref:g,className:"relative w-full text-muted-foreground",children:[(0,d.jsx)("canvas",{ref:f,className:"w-full",style:{height:b},onMouseMove:k,onMouseLeave:()=>i(null)}),h&&(0,d.jsx)("div",{className:"absolute pointer-events-none bg-popover text-popover-foreground text-[10px] px-2 py-1 rounded shadow-lg border border-border whitespace-nowrap z-10",style:{left:h.x,top:h.y,transform:"translate(-50%, -100%)"},children:h.content})]})}function o({hourCounts:a}){let{t:b}=(0,f.Bd)(),c=Math.max(1,...Object.values(a)),e=Array.from({length:24},(a,b)=>b);return(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:b("tokenStats.activeHours")}),(0,d.jsx)("div",{className:"flex gap-[2px] items-end h-16",children:e.map(e=>{let f=a[String(e)]||0,g=f/c;return(0,d.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-0.5",title:b("tokenStats.hourSessions",{h:e,count:f}),children:[(0,d.jsx)("div",{className:"w-full rounded-sm transition-all",style:{height:`${Math.max(2,48*g)}px`,backgroundColor:g>0?`rgba(59, 130, 246, ${.2+.8*g})`:"var(--muted)"}}),e%3==0&&(0,d.jsx)("span",{className:"text-[8px] text-muted-foreground",children:e})]},e)})})]})}function p({isOpen:a,onClose:b}){var c;let g,h,{t:r}=(0,f.Bd)(),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(!0),[w,x]=(0,e.useState)("day"),[y,z]=(0,e.useState)("tokens"),[A,B]=(0,e.useState)("claude"),C=(0,e.useMemo)(()=>s?.modelUsage?Object.entries(s.modelUsage).filter(([a])=>!a.startsWith("<")).map(([a,b])=>{let c;return{id:a,label:j(a),color:k(a),usage:b,cost:(c=i(a),b.inputTokens/1e6*c.input+b.outputTokens/1e6*c.output+b.cacheReadInputTokens/1e6*c.cacheRead+b.cacheCreationInputTokens/1e6*c.cacheWrite),totalTokens:b.inputTokens+b.outputTokens+b.cacheReadInputTokens+b.cacheCreationInputTokens}}).sort((a,b)=>b.cost-a.cost):[],[s]),D=(0,e.useMemo)(()=>C.reduce((a,b)=>a+b.cost,0),[C]),E=(0,e.useMemo)(()=>C.map(a=>a.id),[C]),F=(0,e.useMemo)(()=>{let a={};for(let b of C)a[b.id]=b.totalTokens>0?b.cost/b.totalTokens:0;return a},[C]),{activityChart:G,tokenChart:H,costChart:I}=(0,e.useMemo)(()=>{let a=s?.dailyActivity||[],b=s?.dailyModelTokens||[];if("day"===w){let c=a.slice(-60),d=b.slice(-60),e={labels:c.map(a=>a.date.slice(5)),datasets:[{label:r("tokenStats.messages"),data:c.map(a=>a.messageCount),color:"#3b82f6"},{label:r("tokenStats.toolCalls"),data:c.map(a=>a.toolCallCount),color:"#22c55e"}]},f=d.map(a=>a.date.slice(5));return{activityChart:e,tokenChart:{labels:f,datasets:E.map(a=>({label:j(a),data:d.map(b=>b.tokensByModel[a]||0),color:k(a)}))},costChart:{labels:f,datasets:E.map(a=>({label:j(a),data:d.map(b=>(b.tokensByModel[a]||0)*(F[a]||0)),color:k(a)}))}}}if("week"===w){let c=function(a,b){let c=new Map;for(let b of a){let a=new Date(b.date),d=new Date(a);d.setDate(a.getDate()-a.getDay());let e=d.toISOString().slice(0,10),f=e.slice(5);c.has(e)||c.set(e,{label:f,messages:0,sessions:0,tools:0,tokensByModel:{}});let g=c.get(e);g.messages+=b.messageCount,g.sessions+=b.sessionCount,g.tools+=b.toolCallCount}for(let a of b){let b=new Date(a.date),d=new Date(b);d.setDate(b.getDate()-b.getDay());let e=d.toISOString().slice(0,10);c.has(e)||c.set(e,{label:e.slice(5),messages:0,sessions:0,tools:0,tokensByModel:{}});let f=c.get(e);for(let[b,c]of Object.entries(a.tokensByModel))f.tokensByModel[b]=(f.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:r("tokenStats.messages"),data:c.map(a=>a.messages),color:"#3b82f6"},{label:r("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:"#22c55e"}]};return{activityChart:e,tokenChart:{labels:d,datasets:E.map(a=>({label:j(a),data:c.map(b=>b.tokensByModel[a]||0),color:k(a)}))},costChart:{labels:d,datasets:E.map(a=>({label:j(a),data:c.map(b=>(b.tokensByModel[a]||0)*(F[a]||0)),color:k(a)}))}}}let c=function(a,b){let c=new Map;for(let b of a){let a=b.date.slice(0,7);c.has(a)||c.set(a,{label:a,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(a);d.messages+=b.messageCount,d.sessions+=b.sessionCount,d.tools+=b.toolCallCount}for(let a of b){let b=a.date.slice(0,7);c.has(b)||c.set(b,{label:b,messages:0,sessions:0,tools:0,tokensByModel:{}});let d=c.get(b);for(let[b,c]of Object.entries(a.tokensByModel))d.tokensByModel[b]=(d.tokensByModel[b]||0)+c}return Array.from(c.values()).sort((a,b)=>a.label.localeCompare(b.label))}(a,b),d=c.map(a=>a.label),e={labels:d,datasets:[{label:r("tokenStats.messages"),data:c.map(a=>a.messages),color:"#3b82f6"},{label:r("tokenStats.toolCalls"),data:c.map(a=>a.tools),color:"#22c55e"}]};return{activityChart:e,tokenChart:{labels:d,datasets:E.map(a=>({label:j(a),data:c.map(b=>b.tokensByModel[a]||0),color:k(a)}))},costChart:{labels:d,datasets:E.map(a=>({label:j(a),data:c.map(b=>(b.tokensByModel[a]||0)*(F[a]||0)),color:k(a)}))}}},[s,w,E,F,r]);if(!a)return null;let J=[{key:"day",label:r("tokenStats.day")},{key:"week",label:r("tokenStats.week")},{key:"month",label:r("tokenStats.month")}];return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,d.jsxs)("div",{className:"relative bg-card rounded-xl shadow-xl w-full max-w-4xl mx-4 max-h-[90vh] flex flex-col overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-6 py-3 border-b border-border flex-shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("tokenStats.title")}),(0,d.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:["claude","claude2"].map(a=>(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${A===a?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{t(null),B(a)},children:"claude"===a?"Claude":"Claude 2"},a))}),(0,d.jsx)("div",{className:"flex bg-muted rounded-md p-0.5",children:J.map(a=>(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${w===a.key?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>x(a.key),children:a.label},a.key))})]}),(0,d.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-6",children:u?(0,d.jsx)("div",{className:"text-center text-muted-foreground py-12",children:r("common.loading")}):s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"grid grid-cols-5 gap-3",children:[(0,d.jsx)(q,{label:r("tokenStats.totalSessions"),value:String(s.totalSessions??0)}),(0,d.jsx)(q,{label:r("tokenStats.totalMessages"),value:l(s.totalMessages??0)}),(0,d.jsx)(q,{label:r("tokenStats.equivalentApiCost"),value:m(D),highlight:!0}),(0,d.jsx)(q,{label:r("tokenStats.longestSession"),value:s.longestSession?(g=Math.floor((c=s.longestSession.duration)/36e5),h=Math.floor(c%36e5/6e4),g>0?`${g}h ${h}m`:`${h}m`):"-"}),(0,d.jsx)(q,{label:r("tokenStats.firstUse"),value:s.firstSessionDate?s.firstSessionDate.slice(0,10):"-"})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:r("tokenStats.activityTrend")}),(0,d.jsxs)("div",{className:"flex items-center gap-3 text-[10px]",children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"#3b82f6"}}),r("tokenStats.messages")]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"#22c55e"}}),r("tokenStats.toolCalls")]})]})]}),(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(n,{data:G,height:180})})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:r("tokenStats.byModel")}),(0,d.jsxs)("div",{className:"flex bg-muted rounded-md p-0.5",children:[(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"tokens"===y?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>z("tokens"),children:r("tokenStats.tokenUsage")}),(0,d.jsx)("button",{className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${"cost"===y?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>z("cost"),children:r("tokenStats.equivalentCost")})]})]}),(0,d.jsx)("div",{className:"flex items-center gap-3 text-[10px] flex-wrap",children:C.map(a=>(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:a.color}}),a.label]},a.id))})]}),(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(n,{data:"tokens"===y?H:I,height:180,formatValue:"tokens"===y?l:m})})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:r("tokenStats.modelCostDetail")}),(0,d.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,d.jsxs)("table",{className:"w-full text-xs",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"bg-muted/50 text-muted-foreground",children:[(0,d.jsx)("th",{className:"text-left px-3 py-2 font-medium",children:r("tokenStats.model")}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Input"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Output"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Read"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:"Cache Write"}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:r("tokenStats.share")}),(0,d.jsx)("th",{className:"text-right px-3 py-2 font-medium",children:r("tokenStats.equivalentCost")})]})}),(0,d.jsxs)("tbody",{children:[C.map(a=>(0,d.jsxs)("tr",{className:"border-t border-border",children:[(0,d.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a.color}}),a.label]})}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(a.usage.inputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(a.usage.outputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(a.usage.cacheReadInputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(a.usage.cacheCreationInputTokens)}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:D>0?`${(a.cost/D*100).toFixed(1)}%`:"-"}),(0,d.jsx)("td",{className:"px-3 py-2 text-right font-medium text-foreground",children:m(a.cost)})]},a.id)),(0,d.jsxs)("tr",{className:"border-t-2 border-border bg-muted/30",children:[(0,d.jsx)("td",{className:"px-3 py-2 font-medium text-foreground",children:r("tokenStats.total")}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(C.reduce((a,b)=>a+b.usage.inputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(C.reduce((a,b)=>a+b.usage.outputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(C.reduce((a,b)=>a+b.usage.cacheReadInputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:l(C.reduce((a,b)=>a+b.usage.cacheCreationInputTokens,0))}),(0,d.jsx)("td",{className:"px-3 py-2 text-right text-muted-foreground",children:"100%"}),(0,d.jsx)("td",{className:"px-3 py-2 text-right font-bold text-foreground",children:m(D)})]})]})]})})]}),s.hourCounts&&Object.keys(s.hourCounts).length>0&&(0,d.jsx)("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:(0,d.jsx)(o,{hourCounts:s.hourCounts})})]}):(0,d.jsx)("div",{className:"text-center text-muted-foreground py-12",children:r("tokenStats.notFound")})})]})]})}function q({label:a,value:b,highlight:c}){return(0,d.jsxs)("div",{className:"bg-muted/30 rounded-lg px-3 py-2.5",children:[(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:a}),(0,d.jsx)("div",{className:`text-sm font-semibold mt-0.5 ${c?"text-brand":"text-foreground"}`,children:b})]})}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},65256:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{d:()=>k});var e=c(48249),f=c(67484),g=c(49280),h=c(79029),i=c(81749),j=a([h]);function k({skillId:a,onClose:b}){let[c,d]=(0,f.useState)(null),[j,l]=(0,f.useState)(!0),[m,n]=(0,f.useState)("preview"),o=(0,f.useCallback)(async()=>{if(c?.path)try{await navigator.clipboard.writeText(c.path),(0,i.oR)("Path copied","success")}catch{(0,i.oR)("Failed to copy","error")}},[c]);return(0,e.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:b}),(0,e.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-4xl h-[85vh] mx-4 flex flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{className:"text-sm font-medium text-foreground truncate",children:c?.name?`/${c.name}`:"Skill Preview"}),(0,e.jsx)("button",{onClick:o,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"Copy path",children:(0,e.jsxs)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,e.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:2}),(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})]}),c?.path&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5",children:c.path})]}),(0,e.jsxs)("div",{className:"flex items-center rounded-md border border-border overflow-hidden text-xs flex-shrink-0",children:[(0,e.jsx)("button",{onClick:()=>n("preview"),className:`px-3 py-1 transition-colors ${"preview"===m?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:"Preview"}),(0,e.jsx)("button",{onClick:()=>n("source"),className:`px-3 py-1 transition-colors ${"source"===m?"bg-brand text-white":"text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:"Source"})]}),(0,e.jsx)("button",{onClick:b,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors flex-shrink-0",title:"Close",children:(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,e.jsx)("div",{className:"flex-1 overflow-auto",children:j?(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading..."}):c&&c.valid?"preview"===m?(0,e.jsx)("div",{className:"px-6 py-4",children:(0,e.jsx)(g.T,{content:c.content})}):(0,e.jsx)(h.XO,{content:c.content,filePath:c.path,className:"min-h-full"}):(0,e.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"File cannot be read."})})]})]})}h=(j.then?(await j)():j)[0],d()}catch(a){d(a)}})},68122:(a,b,c)=>{"use strict";c.d(b,{M:()=>m,O:()=>k});var d=c(48249),e=c(67484),f=c(44384),g=c(74429);let h=[],i=[];function j(){i.forEach(a=>a())}function k(a){let b=`session-toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;h=[...h,{...a,id:b}],j()}function l(a){h=h.filter(b=>b.id!==a),j()}function m({onNavigate:a}){let b=function(){let[,a]=(0,e.useState)(0);return h}();return 0===b.length?null:(0,g.createPortal)((0,d.jsx)("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col gap-2 pointer-events-none",children:b.map(b=>(0,d.jsx)(n,{item:b,onNavigate:a,onRemove:l},b.id))}),document.body)}function n({item:a,onNavigate:b,onRemove:c}){let{t:g}=(0,f.Bd)(),[h,i]=(0,e.useState)(!1),j=(0,e.useRef)(void 0),k=(0,e.useCallback)(()=>{i(!0),setTimeout(()=>c(a.id),300)},[a.id,c]),l=(0,e.useCallback)(()=>{clearTimeout(j.current),b(a.cwd,a.sessionId),c(a.id)},[a,b,c]),m=(0,e.useCallback)(()=>{clearTimeout(j.current)},[]),o=(0,e.useCallback)(()=>{j.current=setTimeout(k,2e3)},[k]);return(0,d.jsxs)("div",{className:`pointer-events-auto bg-card border border-border rounded-lg shadow-lg px-3 py-2.5 min-w-[260px] max-w-[340px] cursor-pointer hover:bg-accent transition-all ${h?"opacity-0 -translate-x-4":"opacity-100 translate-x-0"}`,style:{animation:h?void 0:"slideInLeft 0.3s ease-out"},onClick:l,onMouseEnter:m,onMouseLeave:o,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4 text-green-9 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.projectName}),(0,d.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:g("common.done")}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),k()},className:"ml-auto p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:(0,d.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.message&&(0,d.jsx)("div",{className:"text-xs text-muted-foreground truncate mt-1 ml-6",children:a.message})]})}},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},73136:a=>{"use strict";a.exports=require("node:url")},76760:a=>{"use strict";a.exports=require("node:path")},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},78908:a=>{"use strict";a.exports=import("shiki")},79327:a=>{"use strict";a.exports=require("node:process")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")}};var b=require("../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,8465,4793,3353,6043,7514,4732],()=>b(b.s=62399));module.exports=c})();