@mndrk/agx 2.0.2 → 2.0.3
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.
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/BUILD_ID +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/app-path-routes-manifest.json +2 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/build-manifest.json +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/prerender-manifest.json +27 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/routes-manifest.json +6 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/file-search/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/health/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/learnings/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/logs/stream/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/memories/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/cancel/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/signal/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/start/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/orchestrator/tasks/[taskId]/status/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/[id]/migrate-v1/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/[id]/migrate-v2/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/projects/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/queue/complete/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/queue/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/system/db-status/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/comments/[commentId]/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/comments/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/costs/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/dependencies/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/events/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/history/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/metrics/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/pause/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/replan/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/restart/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/resume/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/rollback/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/start/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/graph/stop/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/heartbeat/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/history/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/logs/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/logs/stream/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/nodes/[nodeId]/comments/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/nodes/[nodeId]/complete/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/nodes/[nodeId]/fail/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/nodes/[nodeId]/resume/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/nodes/[nodeId]/start/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/nodes/[nodeId]/stop/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/nodes/[nodeId]/verify/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/[id]/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/assign-orphans/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/tasks/stream/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/api/user-settings/route.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board.segments/board/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/board.segments/board.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph.segments/execution-graph/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/execution-graph.segments/execution-graph.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.rsc +3 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/graph/[taskId]/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/graph/[taskId]/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.html +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.rsc +3 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.segments/_full.segment.rsc +3 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.segments/projects/orphans/__PAGE__.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.segments/projects/orphans.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/orphans.segments/projects.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.rsc +3 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.segments/_full.segment.rsc +3 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.segments/projects/__PAGE__.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/projects.segments/projects.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.segments/_full.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status/page.js.nft.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status/page_client-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status.rsc +3 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status.segments/_full.segment.rsc +3 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status.segments/_head.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status.segments/_index.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status.segments/_tree.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status.segments/status/__PAGE__.segment.rsc +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/status.segments/status.segment.rsc +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page/app-paths-manifest.json +3 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page/build-manifest.json +18 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page/next-font-manifest.json +11 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page/react-loadable-manifest.json +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page/server-reference-manifest.json +4 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page.js +15 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page.js.map +5 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page.js.nft.json +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome/page_client-reference-manifest.js +2 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.html +9 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.meta +15 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.rsc +23 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.segments/_full.segment.rsc +23 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.segments/_head.segment.rsc +5 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.segments/_index.segment.rsc +9 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.segments/_tree.segment.rsc +5 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.segments/welcome/__PAGE__.segment.rsc +9 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app/welcome.segments/welcome.segment.rsc +4 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/app-paths-manifest.json +2 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/7e210_Agents_agx-cloud__next-internal_server_app_welcome_page_actions_5176f4d4.js +3 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/Projects_Agents_agx-cloud_304dc58c._.js +3 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/Projects_Agents_agx-cloud_aaa774d8._.js +4 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/Projects_Agents_agx-cloud_components_chat-ui_f59beea5._.js +95 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/{Projects_Agents_agx-cloud_e1b68242._.js → Projects_Agents_agx-cloud_d54d1b77._.js} +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/Projects_Agents_agx-cloud_ef78b9d7._.js +3 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/{[root-of-the-server]__9d72d782._.js → [root-of-the-server]__00507cd5._.js} +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/[root-of-the-server]__24a978df._.js +3 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/[root-of-the-server]__8b322dc4._.js +3 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/{[root-of-the-server]__657b446b._.js → [root-of-the-server]__99fa92e8._.js} +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/[root-of-the-server]__a4a5c57b._.js +3 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/{[root-of-the-server]__1e273070._.js → [root-of-the-server]__a73fd1ea._.js} +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/ae43b_@dnd-kit_core_dist_core_esm_e4fe20d7.js +3 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/middleware-manifest.json +5 -5
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/next-font-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/next-font-manifest.json +4 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages/404.html +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/pages/500.html +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/server-reference-manifest.js +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/server-reference-manifest.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/04612fc0fdf7b4ef.css +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/0804e1cf36ac4c40.js +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/{1e899e8bb554fde8.js → 122dafa7cd2594e4.js} +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/38cf24cf2de25782.js +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/55e870d6246760c7.js +93 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/{4256a16941bc22fb.js → 60a9c7b6ddb4f3f5.js} +2 -2
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/7d2c10033c8a8554.js +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/870ea0d4e47d21ce.js +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/{0a0d449e527ef5e2.js → a56604cde5f45ff6.js} +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/ae26536f21ac3989.js +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/b3af23a09f4d9204.js +1 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/{4926ceb649af0e91.js → cdd364319efbfb0a.js} +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/app/welcome/page.tsx +117 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/components/chat-ui/ChatPreview.tsx +85 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/lib/demo-threads.ts +76 -0
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/scripts/fix-turbopack-externals.mjs +94 -0
- package/package.json +1 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/Projects_Agents_agx-cloud_37dc866e._.js +0 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/Projects_Agents_agx-cloud_a7533794._.js +0 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/[root-of-the-server]__13df20fe._.js +0 -95
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/server/chunks/ssr/ae43b_lucide-react_dist_esm_icons_search_04b9412a.js +0 -3
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/09c6c56e4afc8647.js +0 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/0d58db99a936501d.js +0 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/652b21250c785942.css +0 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/dc534541f2bd6342.js +0 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/e4e1f0e19efe31cb.js +0 -1
- package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/fb502daefdaec131.js +0 -93
- /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{Bhse4ZIyeG-RAxhOSkjdu → NUZvhyZNQzdxfq6-qS6F_}/_buildManifest.js +0 -0
- /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{Bhse4ZIyeG-RAxhOSkjdu → NUZvhyZNQzdxfq6-qS6F_}/_clientMiddlewareManifest.json +0 -0
- /package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/{Bhse4ZIyeG-RAxhOSkjdu → NUZvhyZNQzdxfq6-qS6F_}/_ssgManifest.js +0 -0
package/cloud-runtime/standalone/Projects/Agents/agx-cloud/.next/static/chunks/55e870d6246760c7.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,26410,e=>{e.v({fileMentionFadeIn:"FileMentionPopover-module__NItQTa__fileMentionFadeIn",popover:"FileMentionPopover-module__NItQTa__popover"})},26341,e=>{"use strict";var t=e.i(72218),n=e.i(95459);function r(e){return`threadId=${encodeURIComponent(e)}`}var s=e.i(89934),i=e.i(59853),o=e.i(23362),a=e.i(10971),l=e.i(41157);let d=(0,l.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);var c=e.i(66638),h=e.i(22522);let u=(0,l.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);var p=e.i(61606),f=e.i(34285),m=e.i(64244);function g({threads:e,participants:r=[],activeThreadId:s,isLoading:l,isCreating:g,onSelectThread:x,onCreateThread:y,onRenameThread:b,onDeleteThread:v,deletingThreadId:w=null,renamingThreadId:k=null,onAddParticipant:S,onUpdateParticipant:C,onRemoveParticipant:M,activeParticipantIds:N=[],onToggleParticipantActive:T,onReorderParticipants:j,visible:O=!1,isRestoringActiveThread:E=!1,onToggle:A,onSearch:I}){let D=(0,n.useRef)(null),[R,P]=(0,n.useState)(null),{projects:z}=(0,f.useProjects)(),$=e.length>0,L=!!O,B=!!(S&&C&&M),V=[...e].sort((e,t)=>(e.title??"").localeCompare(t.title??""));!function({focusTarget:e,shouldFocus:t}){(0,n.useEffect)(()=>{if(!t||"u"<typeof document)return;let n=e.current;if(!n||n instanceof HTMLButtonElement&&n.disabled)return;let r=document.activeElement;if(!(r&&(n===r||n.contains(r))))try{n.focus({preventScroll:!0})}catch{n.focus()}},[e,t])}({focusTarget:D,shouldFocus:L&&!(l&&!$||E&&$)&&!$&&!g});let F=(e,t)=>{let n=window.prompt("Rename workspace",t);if(null===n)return;let r=n.trim();r?b(e,r):window.alert("Workspace title is required.")};return L?(0,t.jsxs)("aside",{id:"thread-sidebar",className:"thread-sidebar","aria-label":"Workspace sidebar","aria-busy":l?"true":void 0,children:[(0,t.jsxs)("div",{className:"thread-sidebar__brand",children:[(0,t.jsx)("div",{className:"flex items-center justify-center mr-2","aria-hidden":"true",children:(0,t.jsxs)("svg",{width:"52",height:"31",viewBox:"0 0 64 38",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("rect",{width:"64",height:"38",rx:"8",fill:"black"}),(0,t.jsxs)("g",{stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M 14 27 C 17 16 19 10 20 8 C 21 12 23 20 25 27"}),(0,t.jsx)("path",{d:"M 16 20 C 19 19 21 21 23 20"}),(0,t.jsx)("path",{d:"M 40 13 C 35 10 30 13 30 19 C 30 25 34 28 38 27 C 40 26 40 22 40 20 L 36 20"}),(0,t.jsx)("path",{d:"M 46 11 C 48 16 51 22 54 27"}),(0,t.jsx)("path",{d:"M 54 11 C 52 16 49 22 46 27"})]})]})}),A&&(0,t.jsx)("button",{type:"button",onClick:A,"aria-label":"Hide workspaces",title:"Hide workspaces",className:"ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-slate-400 transition-all hover:bg-slate-100 hover:text-slate-600",children:(0,t.jsx)(a.PanelLeftClose,{className:"h-4 w-4",strokeWidth:1.75})})]}),(0,t.jsxs)("div",{className:"thread-sidebar__content",children:[I&&(0,t.jsx)("div",{className:"px-3 pt-2 pb-1",children:(0,t.jsxs)("button",{type:"button",onClick:I,className:"flex items-center gap-2 w-full h-8 px-2.5 rounded-lg border border-slate-200 bg-white text-slate-400 text-xs hover:border-slate-300 hover:text-slate-500 transition-all",children:[(0,t.jsx)(h.Search,{className:"h-3.5 w-3.5 shrink-0",strokeWidth:1.75}),(0,t.jsx)("span",{children:"Search…"}),(0,t.jsx)("kbd",{className:"ml-auto text-[10px] font-sans font-medium text-slate-300 bg-slate-50 border border-slate-200 rounded px-1 py-0.5",children:"⌘K"})]})}),(0,t.jsxs)("nav",{className:"thread-sidebar__section",children:[(0,t.jsxs)("div",{className:"thread-sidebar__section-header",children:[(0,t.jsx)("p",{className:"thread-sidebar__section-label",children:"Workspace"}),(0,t.jsx)("div",{className:"thread-sidebar__header-actions",children:(0,t.jsx)("button",{type:"button",className:"thread-sidebar__action",onClick:()=>{let e=window.prompt("Workspace title");if(null===e)return;let t=e.trim();t?y({title:t}):window.alert("Workspace title is required.")},disabled:g,"aria-label":g?"Creating workspace":"Create workspace",title:g?"Creating…":"Create workspace",children:(0,t.jsx)(c.Plus,{size:14})})})]}),V.map(e=>{let n=e.id===s,r=w===e.id,o=k===e.id,a=e.title?.trim()||"Untitled workspace";return(0,t.jsxs)("div",{className:"thread-sidebar__workspace-item group",children:[(0,t.jsxs)("button",{type:"button",className:`thread-sidebar__nav-item thread-sidebar__workspace-nav-item ${n?"thread-sidebar__nav-item--active thread-sidebar__workspace-nav-item--active":""}`,onClick:()=>x(e.id),"aria-current":n?"page":void 0,children:[(0,t.jsx)(i.Hash,{size:18}),(0,t.jsx)("span",{className:"thread-sidebar__workspace-title",children:a})]}),(0,t.jsxs)("div",{className:"thread-sidebar__workspace-actions",children:[(0,t.jsx)("button",{type:"button",className:"thread-sidebar__workspace-action",onClick:()=>F?.(e.id,a),disabled:o||r,"aria-label":`Rename workspace ${a}`,title:`Rename workspace ${a}`,children:(0,t.jsx)(d,{size:12})}),(0,t.jsx)("button",{type:"button",className:"thread-sidebar__workspace-action thread-sidebar__workspace-action--delete",onClick:()=>{v(e.id)},disabled:r||o,"aria-label":`Delete workspace ${a}`,title:`Delete workspace ${a}`,children:(0,t.jsx)(u,{size:12})})]})]},e.id)})]}),(0,t.jsxs)("nav",{className:"thread-sidebar__section",children:[(0,t.jsx)("div",{className:"thread-sidebar__section-header",children:(0,t.jsx)(p.default,{href:"/projects",className:"thread-sidebar__section-label hover:text-slate-700 transition-colors cursor-pointer",children:"Boards"})}),(0,t.jsx)("div",{className:"thread-sidebar__workspace-list",children:z.map(e=>(0,t.jsx)("div",{className:"thread-sidebar__workspace-item group",children:(0,t.jsxs)(p.default,{href:`/projects/${e.slug}`,className:"thread-sidebar__nav-item thread-sidebar__workspace-nav-item flex items-center gap-3",children:[(0,t.jsx)(o.Minus,{size:16,className:"flex-shrink-0 text-slate-400"}),(0,t.jsx)("span",{className:"thread-sidebar__workspace-title",children:e.name})]})},e.slug))})]}),(0,t.jsxs)("section",{className:"thread-sidebar__section",children:[(0,t.jsxs)("div",{className:"thread-sidebar__section-header",children:[(0,t.jsx)("p",{className:"thread-sidebar__section-label",children:"Agents"}),(0,t.jsx)("div",{className:"thread-sidebar__header-actions",children:(0,t.jsx)("button",{type:"button",className:"thread-sidebar__action",onClick:()=>P(e=>(e??0)+1),disabled:!B,"aria-label":"Add agent",title:"Add agent",children:(0,t.jsx)(c.Plus,{size:14})})})]}),B?(0,t.jsx)(m.ParticipantBar,{participants:r,onAdd:S,onUpdate:C,onRemove:M,activeParticipantIds:N,onToggleActive:T,onReorder:j,showInlineAdd:!1,openAddNonce:R??void 0,variant:"sidebar"}):(0,t.jsx)("p",{className:"thread-sidebar__models-empty",children:"Agent configuration unavailable"})]})]}),(0,t.jsx)("div",{className:"mt-auto px-3 pb-3",children:(0,t.jsxs)("a",{href:"https://discord.gg/y77e9Euz",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full py-2 rounded-lg text-white text-sm font-medium transition-colors",style:{backgroundColor:"#5865F2"},onMouseEnter:e=>e.currentTarget.style.backgroundColor="#4752C4",onMouseLeave:e=>e.currentTarget.style.backgroundColor="#5865F2",children:[(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 71 55",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{d:"M60.1 4.9A58.5 58.5 0 0045.4.2a.2.2 0 00-.2.1 40.8 40.8 0 00-1.8 3.7 54 54 0 00-16.2 0A37.4 37.4 0 0025.4.3a.2.2 0 00-.2-.1A58.4 58.4 0 0010.5 4.9a.2.2 0 00-.1.1C1.5 18.7-.9 32.2.3 45.5v.1a58.8 58.8 0 0017.7 9a.2.2 0 00.3-.1 42 42 0 003.6-5.9.2.2 0 00-.1-.3 38.8 38.8 0 01-5.5-2.6.2.2 0 01 0-.4l1.1-.9a.2.2 0 01.2 0 42 42 0 0035.6 0 .2.2 0 01.2 0l1.1.9a.2.2 0 010 .4 36.4 36.4 0 01-5.5 2.6.2.2 0 00-.1.3 47.2 47.2 0 003.6 5.9.2.2 0 00.3.1 58.6 58.6 0 0017.7-9v-.1c1.4-15.2-2.4-28.4-10-40.1a.2.2 0 00-.1-.1zM23.7 37.3c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7zm23.3 0c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7z"})}),"Join Discord"]})})]}):(0,t.jsxs)("aside",{id:"thread-sidebar",className:"thread-sidebar thread-sidebar--collapsed","aria-label":"Workspace sidebar",children:[(0,t.jsx)("div",{className:"thread-sidebar__brand",children:(0,t.jsx)("button",{type:"button",onClick:A,className:"thread-sidebar__brand-icon p-0 bg-transparent hover:bg-transparent border-none outline-none","aria-label":"Show workspaces",title:"Show workspaces",children:(0,t.jsxs)("svg",{width:"52",height:"31",viewBox:"0 0 64 38",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"transition-transform hover:scale-105",children:[(0,t.jsx)("rect",{width:"64",height:"38",rx:"8",fill:"black"}),(0,t.jsxs)("g",{stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M 14 27 C 17 16 19 10 20 8 C 21 12 23 20 25 27"}),(0,t.jsx)("path",{d:"M 16 20 C 19 19 21 21 23 20"}),(0,t.jsx)("path",{d:"M 40 13 C 35 10 30 13 30 19 C 30 25 34 28 38 27 C 40 26 40 22 40 20 L 36 20"}),(0,t.jsx)("path",{d:"M 46 11 C 48 16 51 22 54 27"}),(0,t.jsx)("path",{d:"M 54 11 C 52 16 49 22 46 27"})]})]})})}),(0,t.jsx)("div",{className:"mt-auto p-2",children:(0,t.jsx)("a",{href:"https://discord.gg/y77e9Euz",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center w-8 h-8 rounded-lg text-white transition-colors",style:{backgroundColor:"#5865F2"},onMouseEnter:e=>e.currentTarget.style.backgroundColor="#4752C4",onMouseLeave:e=>e.currentTarget.style.backgroundColor="#5865F2",title:"Join Discord",children:(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 71 55",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{d:"M60.1 4.9A58.5 58.5 0 0045.4.2a.2.2 0 00-.2.1 40.8 40.8 0 00-1.8 3.7 54 54 0 00-16.2 0A37.4 37.4 0 0025.4.3a.2.2 0 00-.2-.1A58.4 58.4 0 0010.5 4.9a.2.2 0 00-.1.1C1.5 18.7-.9 32.2.3 45.5v.1a58.8 58.8 0 0017.7 9a.2.2 0 00.3-.1 42 42 0 003.6-5.9.2.2 0 00-.1-.3 38.8 38.8 0 01-5.5-2.6.2.2 0 01 0-.4l1.1-.9a.2.2 0 01.2 0 42 42 0 0035.6 0 .2.2 0 01.2 0l1.1.9a.2.2 0 010 .4 36.4 36.4 0 01-5.5 2.6.2.2 0 00-.1.3 47.2 47.2 0 003.6 5.9.2.2 0 00.3.1 58.6 58.6 0 0017.7-9v-.1c1.4-15.2-2.4-28.4-10-40.1a.2.2 0 00-.1-.1zM23.7 37.3c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7zm23.3 0c-3.5 0-6.3-3.2-6.3-7s2.8-7 6.3-7 6.4 3.2 6.3 7-2.8 7-6.3 7z"})})})})]})}var x=e.i(37433);let y={ack:{symbol:"👍",label:"Acknowledged"},working:{symbol:"🔄",label:"Working"},done:{symbol:"✅",label:"Done"},clarify:{symbol:"❓",label:"Needs clarification"},blocked:{symbol:"⛔",label:"Blocked"}};function b({type:e,count:n,participantIds:r}){let s=y[e],i=r.join(", "),o=i?`${s.label}: ${i}`:s.label;return(0,t.jsxs)("span",{title:o,className:"inline-flex items-center gap-1 rounded-full border border-zinc-300 bg-zinc-50 px-2 py-0.5 text-xs text-zinc-700",children:[(0,t.jsx)("span",{"aria-hidden":!0,children:s.symbol}),(0,t.jsx)("span",{className:"tabular-nums",children:n})]})}function v({reactions:e}){if(!e||0===e.length)return null;let n=[...e].sort((e,t)=>t.count!==e.count?t.count-e.count:e.type.localeCompare(t.type));return(0,t.jsx)("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:n.map(e=>(0,t.jsx)(b,{type:e.type,count:e.count,participantIds:e.participantIds},e.type))})}var w=e.i(2263);let k=(0,l.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);function S({attachments:e,compact:n=!1}){if(0===e.length)return null;let r=e.filter(e=>e.mimeType.startsWith("image/")),s=e.filter(e=>!e.mimeType.startsWith("image/")),i=n?"max-w-[120px]":"max-w-[240px]",o=n?"max-h-[90px]":"max-h-[180px]";return(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[r.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.map(e=>(0,t.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg overflow-hidden border border-slate-200 hover:border-slate-300 transition-colors",children:(0,t.jsx)("img",{src:e.url,alt:e.filename,className:`${i} ${o} object-cover`,loading:"lazy"})},e.id))}),s.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.map(e=>{var r;return(0,t.jsxs)("a",{href:e.url,download:e.filename,className:`inline-flex items-center gap-1.5 rounded-md border border-slate-200 bg-slate-50 text-slate-600 hover:bg-slate-100 hover:border-slate-300 transition-colors ${n?"px-2 py-0.5 text-[11px]":"px-2.5 py-1 text-xs"}`,children:[(0,t.jsx)(w.FileText,{className:`text-slate-400 shrink-0 ${n?"w-3 h-3":"w-3.5 h-3.5"}`}),(0,t.jsx)("span",{className:`truncate ${n?"max-w-[100px]":"max-w-[150px]"}`,children:e.filename}),(0,t.jsx)("span",{className:"text-slate-400 shrink-0",children:(r=e.size)<1024?`${r}B`:r<1048576?`${(r/1024).toFixed(0)}KB`:`${(r/1048576).toFixed(1)}MB`}),(0,t.jsx)(k,{className:`text-slate-400 shrink-0 ${n?"w-2.5 h-2.5":"w-3 h-3"}`})]},e.id)})})]})}let C=(0,l.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var M=e.i(64049);let N=(0,l.default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);function T(e){return e.replace(/\[reaction\s+[^\]]*\]/gi,"").replace(/\[agx:[^\]]*\]/g,"").replace(/\[checkpoint\]/g,"").replace(/\[criteria:\s*[^\]]*\]/g,"").replace(/\[done\]/g,"").replace(/\[blocked[^\]]*\]/g,"").replace(/^\[SKIP\]$/gm,"").trim()}function j({message:e,participantName:n,participantColor:r,participantId:s,onReply:i,onOpenThread:o,onSummarize:a,summarizing:l,isRoot:d=!1,highlighted:c=!1,hideUserAvatarAndName:h=!1}){let u,p="user"===e.role,f=T(e.content);return f||e.attachments?.length?(0,t.jsxs)("div",{className:`flex gap-4 group transition-colors ${!d?"py-4":""} ${c?"rounded-lg bg-amber-50/90 px-2 -mx-2 ring-1 ring-amber-200":""}`,children:[!(p&&h)&&(0,t.jsx)("div",{className:`w-9 h-9 rounded-full flex items-center justify-center shrink-0 ${p?"bg-slate-200 text-slate-600":"bg-slate-100 overflow-hidden"}`,children:p?(0,t.jsx)(M.User,{className:"w-5 h-5"}):s?(0,t.jsx)("img",{src:(0,m.agentAvatarUrl)(s,36,r),alt:"",className:"w-full h-full object-cover"}):(0,t.jsx)(M.User,{className:"w-5 h-5 opacity-70"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2 mb-1",children:[!(p&&h)&&(0,t.jsx)("span",{className:"font-bold text-[15px]",style:!p&&r?{color:r}:{},children:p?"You":n||"Unknown"}),(0,t.jsx)("span",{className:"text-xs text-slate-400 font-medium",children:(u=e.timestamp,new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(u))})]}),(0,t.jsxs)("div",{className:`text-[15px] text-slate-800 leading-relaxed ${p?"cursor-pointer hover:bg-slate-50/50 transition-colors rounded p-1 -mx-1":""}`,onClick:()=>{p&&o&&o(e.id)},children:[(0,t.jsx)(x.Markdown,{content:f,isUser:p}),e.attachments&&e.attachments.length>0&&(0,t.jsx)(S,{attachments:e.attachments})]}),d&&(0,t.jsxs)("div",{className:"mt-4 flex gap-2",children:[(0,t.jsx)(v,{reactions:e.reactions}),i&&!p&&(0,t.jsxs)("button",{type:"button",onClick:()=>i(e.id),className:"flex items-center gap-1.5 px-2.5 py-1 text-slate-500 hover:text-slate-800 rounded-full hover:bg-slate-50 transition-colors text-xs font-semibold",children:[(0,t.jsx)(C,{className:"w-3 h-3"}),"Reply"]}),a&&(0,t.jsxs)("button",{type:"button",onClick:()=>a(e.id),disabled:l,className:"flex items-center gap-1.5 px-2.5 py-1 text-slate-500 hover:text-slate-800 rounded-full hover:bg-slate-50 transition-colors text-xs font-semibold disabled:opacity-50 disabled:cursor-not-allowed",children:[l?(0,t.jsx)(N,{className:"w-3 h-3 animate-spin"}):(0,t.jsx)(w.FileText,{className:"w-3 h-3"}),l?"Summarizing…":"Summarize"]})]})]})]}):null}function O(){return(0,t.jsxs)("span",{className:"inline-flex items-center gap-[3px] ml-1",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-400 animate-[pulse-dot_1.4s_ease-in-out_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-400 animate-[pulse-dot_1.4s_ease-in-out_0.2s_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-400 animate-[pulse-dot_1.4s_ease-in-out_0.4s_infinite]"})]})}function E({participantId:e,participantName:n,participantColor:r,content:s}){let i=T(s),o=i.length>0;return(0,t.jsxs)("div",{className:"flex gap-4 py-4 group transition-colors animate-in fade-in slide-in-from-bottom-2 duration-300",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-full bg-slate-100 overflow-hidden shrink-0 shadow-sm border border-slate-100",children:(0,t.jsx)("img",{src:(0,m.agentAvatarUrl)(e,36,r),alt:"",className:"w-full h-full object-cover"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2 mb-1",children:[(0,t.jsx)("span",{className:"font-bold text-[15px]",style:{color:r},children:n}),(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-bold opacity-0 group-hover:opacity-100 transition-opacity",children:"Streaming"})]}),(0,t.jsx)("div",{className:"text-[15px] text-slate-800 leading-relaxed min-h-[1.5rem] flex items-center",children:o?(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)(x.Markdown,{content:i}),(0,t.jsx)("span",{className:"inline-flex items-baseline ml-0.5",children:(0,t.jsx)("span",{className:"w-1 h-1 rounded-full bg-indigo-400 animate-[pulse-dot_1.4s_ease-in-out_infinite]"})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2 text-slate-400 italic",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"thinking"}),(0,t.jsx)(O,{})]})})]})]})}var A=e.i(35189),I=e.i(35312),D=e.i(15875);let R=(0,l.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var P=e.i(20709);let z=(0,l.default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);var $=e.i(64714);let L=$.default.env.NEXT_PUBLIC_AGX_BOARD_URL||"http://localhost:41741";async function B(){let e=await fetch(`${L}/api/projects`);if(!e.ok){if(503===e.status)throw Error("SCHEMA_NOT_READY");throw Error(`Failed to list projects: ${e.status}`)}let t=await e.json();return t.projects??t}async function V(e,t){let n=await fetch(`${L}/api/projects`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,description:t})});if(!n.ok)throw Error(`Failed to create project: ${n.status}`);return n.json()}async function F(e,t){let n=await fetch(`${L}/api/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,...t})});if(!n.ok)throw Error(`Failed to create task: ${n.status}`);let r=await n.json(),s=r.task??r;return r.id&&!s.id&&(s.id=r.id),s}async function _(e){let t=await fetch(`${L}/api/tasks/${e}`);if(!t.ok)return null;let n=await t.json();return n.task??n}async function H(e,t,n,r){let s=[],i={...r},o=new Map((function(e){let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e)n.set(r.id,(r.dependsOn||[]).filter(e=>t.has(e)));let r=[],s=new Set,i=new Set;for(let t of e)!function t(o){if(!s.has(o)&&!i.has(o)){for(let e of(i.add(o),n.get(o)||[]))t(e);i.delete(o),s.add(o),r.push(e.find(e=>e.id===o))}}(t.id);return r})(e).map(e=>[e.id,e]));for(;o.size>0;){let e=[];for(let t of o.values())(t.dependsOn||[]).every(e=>!o.has(e)||i[e])&&e.push(t);0===e.length&&e.push(...o.values());let n=await Promise.allSettled(e.map(async e=>{let n=i[e.id];if(n&&await _(n))return{task:e,remoteId:n};let r=(e.dependsOn||[]).map(e=>i[e]).filter(Boolean),s=await F(e.description,{title:e.title,project_id:t,depends_on:r.length>0?r:void 0});return{task:e,remoteId:s.id}}));for(let t of n)if("fulfilled"===t.status){let{task:e,remoteId:n}=t.value;i[e.id]=n,s.push({clientTaskId:e.id,remoteTaskId:n,status:"created"}),o.delete(e.id)}else{let r=e[n.indexOf(t)];s.push({clientTaskId:r.id,status:"failed",error:t.reason instanceof Error?t.reason.message:"Unknown error"}),o.delete(r.id)}}return{buildId:n,projectId:t,results:s}}let U=(0,l.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var W=e.i(986);function q({onSelect:e,onClose:r}){let[s,i]=(0,n.useState)([]),[o,a]=(0,n.useState)(!0),[l,d]=(0,n.useState)(null),[h,u]=(0,n.useState)(!1),[p,f]=(0,n.useState)(""),[m,g]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{try{let e=await B();i(e)}catch(e){e instanceof Error&&"SCHEMA_NOT_READY"===e.message?d("agx-cloud database not ready. Run migrations first."):d("Failed to load projects. Is agx-cloud running?")}finally{a(!1)}})()},[]);let x=(0,n.useCallback)(async()=>{let t=p.trim();if(t){u(!0);try{let n=await V(t);e(n.id,n.name)}catch(e){d("Failed to create project")}finally{u(!1)}}},[p,e]);return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/20 backdrop-blur-sm",children:(0,t.jsxs)("div",{className:"bg-white rounded-2xl shadow-xl border border-slate-200 w-full max-w-sm mx-4 overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-slate-100",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(U,{className:"w-4 h-4 text-slate-500"}),(0,t.jsx)("h3",{className:"text-sm font-bold text-slate-900",children:"Select Project"})]}),(0,t.jsx)("button",{type:"button",onClick:r,className:"p-1 text-slate-400 hover:text-slate-600 rounded-md hover:bg-slate-100",children:(0,t.jsx)(P.X,{className:"w-4 h-4"})})]}),(0,t.jsxs)("div",{className:"p-4 max-h-64 overflow-y-auto",children:[o&&(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(N,{className:"w-5 h-5 text-slate-400 animate-spin"})}),l&&(0,t.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-amber-50 rounded-lg text-amber-700 text-xs font-medium",children:[(0,t.jsx)(W.AlertTriangle,{className:"w-4 h-4 shrink-0"}),l]}),!o&&!l&&0===s.length&&(0,t.jsx)("p",{className:"text-xs text-slate-500 text-center py-4",children:"No projects found. Create one below."}),!o&&s.map(n=>(0,t.jsxs)("button",{type:"button",onClick:()=>e(n.id,n.name),className:"w-full text-left px-3 py-2.5 rounded-lg hover:bg-slate-50 transition-colors flex items-center gap-3 group",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-lg bg-slate-100 flex items-center justify-center shrink-0",children:(0,t.jsx)(U,{className:"w-4 h-4 text-slate-400 group-hover:text-slate-600"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-slate-800 truncate",children:n.name}),n.description&&(0,t.jsx)("div",{className:"text-[11px] text-slate-500 truncate",children:n.description})]})]},n.id))]}),(0,t.jsx)("div",{className:"px-4 pb-4 pt-2 border-t border-slate-100",children:m?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"text",value:p,onChange:e=>f(e.target.value),onKeyDown:e=>"Enter"===e.key&&x(),placeholder:"Project name",autoFocus:!0,className:"flex-1 h-8 px-3 text-sm border border-slate-200 rounded-lg outline-none focus:ring-1 focus:ring-slate-300"}),(0,t.jsx)("button",{type:"button",onClick:x,disabled:h||!p.trim(),className:"h-8 px-3 text-xs font-bold text-white bg-slate-900 hover:bg-slate-800 rounded-lg disabled:opacity-40",children:h?"…":"Create"}),(0,t.jsx)("button",{type:"button",onClick:()=>g(!1),className:"h-8 px-2 text-slate-400 hover:text-slate-600",children:(0,t.jsx)(P.X,{className:"w-3.5 h-3.5"})})]}):(0,t.jsxs)("button",{type:"button",onClick:()=>g(!0),className:"flex items-center gap-1.5 text-xs font-bold text-slate-500 hover:text-slate-700",children:[(0,t.jsx)(c.Plus,{className:"w-3.5 h-3.5"}),"Create new project"]})})]})})}function K({draft:e,onUpdate:r,onBuild:s,building:i}){let[o,a]=(0,n.useState)(null),[l,d]=(0,n.useState)(!1),h=(0,n.useCallback)((t,n)=>{let s=e.tasks.map(e=>e.id===t?{...e,...n}:e);r({...e,tasks:s,revision:e.revision+1})},[e,r]),u=(0,n.useCallback)(t=>{let n=e.tasks.filter(e=>e.id!==t);r({...e,tasks:n,revision:e.revision+1})},[e,r]),p=(0,n.useCallback)(()=>{let t={id:crypto.randomUUID(),title:"New task",description:"Add description..."};r({...e,tasks:[...e.tasks,t],revision:e.revision+1})},[e,r]),f=(0,n.useCallback)(()=>{d(!0)},[]),m=(0,n.useCallback)((t,n)=>{d(!1),s(e,t,n)},[e,s]),g="idle"===e.buildStatus||!e.buildStatus;return(0,t.jsxs)("div",{className:"mt-6 p-4 bg-slate-50/80 rounded-2xl border border-slate-100 shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(A.Zap,{className:"w-3.5 h-3.5 text-amber-500 fill-amber-500"}),(0,t.jsx)("span",{className:"text-[10px] font-extrabold uppercase tracking-widest text-slate-400",children:"Tasks"})]}),(0,t.jsxs)("span",{className:"text-[11px] font-bold text-slate-500",children:[e.tasks.length," task",1!==e.tasks.length?"s":""]})]}),(0,t.jsx)("div",{className:"space-y-1 mb-4",children:e.tasks.map(e=>{let n=o===e.id;return(0,t.jsxs)("div",{className:"group",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-lg hover:bg-white/60 transition-colors",children:[g&&(0,t.jsx)(I.GripVertical,{className:"w-3.5 h-3.5 text-slate-300 opacity-0 group-hover:opacity-100 cursor-grab shrink-0"}),(0,t.jsx)("button",{type:"button",onClick:()=>a(n?null:e.id),className:"shrink-0 text-slate-400 hover:text-slate-600",children:n?(0,t.jsx)(D.ChevronDown,{className:"w-3.5 h-3.5"}):(0,t.jsx)(R,{className:"w-3.5 h-3.5"})}),g?(0,t.jsx)("input",{type:"text",value:e.title,onChange:t=>h(e.id,{title:t.target.value}),className:"flex-1 text-xs font-semibold text-slate-700 bg-transparent border-none outline-none focus:ring-0 p-0"}):(0,t.jsx)("span",{className:"flex-1 text-xs font-semibold text-slate-700",children:e.title}),g&&(0,t.jsx)("button",{type:"button",onClick:()=>u(e.id),className:"shrink-0 text-slate-300 hover:text-rose-500 opacity-0 group-hover:opacity-100 transition-all",children:(0,t.jsx)(P.X,{className:"w-3.5 h-3.5"})})]}),n&&(0,t.jsx)("div",{className:"ml-9 mr-2 mb-2",children:g?(0,t.jsx)("textarea",{value:e.description,onChange:t=>h(e.id,{description:t.target.value}),rows:4,className:"w-full text-xs text-slate-500 bg-white/80 border border-slate-200 rounded-lg p-2 outline-none focus:ring-1 focus:ring-slate-300 resize-y"}):(0,t.jsx)("p",{className:"text-xs text-slate-500 whitespace-pre-wrap",children:e.description})})]},e.id)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,t.jsxs)("button",{type:"button",onClick:p,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold text-slate-500 hover:text-slate-700 rounded-full border border-dashed border-slate-300 hover:border-slate-400 transition-all",children:[(0,t.jsx)(c.Plus,{className:"w-3 h-3"}),"Add task"]}),(0,t.jsx)("div",{className:"flex-1"}),g&&(0,t.jsxs)("button",{type:"button",onClick:f,disabled:i||0===e.tasks.length,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-bold text-white bg-slate-900 hover:bg-slate-800 rounded-full shadow-sm transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,t.jsx)(z,{className:"w-3 h-3"}),i?"Pushing…":"Push to agx"]})]}),l&&(0,t.jsx)(q,{onSelect:m,onClose:()=>d(!1)})]})}let J=new Set(["completed","done","failed","blocked"]);var G=e.i(69826),X=e.i(38783);let Y=(0,l.default)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]);var Q=e.i(54003);let Z={queued:(0,t.jsx)(X.Circle,{className:"w-4 h-4 text-slate-300"}),pending:(0,t.jsx)(X.Circle,{className:"w-4 h-4 text-slate-300"}),in_progress:(0,t.jsx)(N,{className:"w-4 h-4 text-blue-500 animate-spin"}),running:(0,t.jsx)(N,{className:"w-4 h-4 text-blue-500 animate-spin"}),blocked:(0,t.jsx)(Y,{className:"w-4 h-4 text-amber-500"}),completed:(0,t.jsx)(G.CheckCircle2,{className:"w-4 h-4 text-emerald-500"}),done:(0,t.jsx)(G.CheckCircle2,{className:"w-4 h-4 text-emerald-500"}),failed:(0,t.jsx)(Q.XCircle,{className:"w-4 h-4 text-rose-500"})};function ee({draft:e,onPush:r,pushing:s}){let[i,o]=(0,n.useState)(!1),{tasks:a,error:l}=function({projectId:e,enabled:t,interval:r=3e4}){let[s,i]=(0,n.useState)([]),[o,a]=(0,n.useState)(null),l=(0,n.useRef)(0),d=(0,n.useRef)([]),c=(0,n.useCallback)(async()=>{if(e&&"undefined"!==e)try{let t=$.default.env.NEXT_PUBLIC_AGX_BOARD_URL||"http://localhost:41741",n=await fetch(`${t}/api/tasks?project=${e}`);if(!n.ok)throw Error(`Poll failed: ${n.status}`);let r=await n.json(),s=r.tasks??r;d.current=s,i(s),a(null)}catch(e){a(e instanceof Error?e.message:"Poll failed")}},[e]);return(0,n.useEffect)(()=>{if(!t||!e)return;l.current=Date.now(),c();let n=setInterval(()=>{Date.now()-l.current>18e5||d.current.length>0&&d.current.every(e=>J.has(e.status))?clearInterval(n):c()},r);return()=>clearInterval(n)},[t,e,r,c]),{tasks:s,error:o,refetch:c}}({projectId:e.projectId??null,enabled:!!e.projectId&&"done"===e.buildStatus}),d=new Map;if(e.builtTaskIds)for(let[t,n]of Object.entries(e.builtTaskIds)){let e=a.find(e=>e.id===n);e&&d.set(t,e)}let c=e.tasks.filter(e=>{let t=d.get(e.id);return t&&("completed"===t.status||"done"===t.status)}).length,h=e.tasks.length>0?c/e.tasks.length:0,u=(0,n.useCallback)(()=>{e.projectId&&e.projectName?r?.(e,e.projectId,e.projectName):o(!0)},[e,r]),p=(0,n.useCallback)((t,n)=>{o(!1),r?.(e,t,n)},[e,r]);e.tasks.some(t=>!e.builtTaskIds?.[t.id]);let f=e.tasks.some(e=>{let t=d.get(e.id);return t&&"queued"!==t.status&&"pending"!==t.status});return(0,t.jsxs)("div",{className:"mt-6 p-4 bg-slate-50/80 rounded-2xl border border-slate-100 shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(A.Zap,{className:"w-3.5 h-3.5 text-amber-500 fill-amber-500"}),(0,t.jsx)("span",{className:"text-[10px] font-extrabold uppercase tracking-widest text-slate-400",children:"Tasks"}),e.projectName&&(0,t.jsxs)("span",{className:"text-[10px] font-semibold text-slate-400",children:["· ",e.projectName]})]}),(0,t.jsxs)("span",{className:"text-[11px] font-bold text-slate-600",children:[c,"/",e.tasks.length," Complete"]})]}),(0,t.jsx)("div",{className:"space-y-3 mb-4",children:e.tasks.map(e=>{let n=d.get(e.id),r=n?.status||"queued",s=Z[r]||Z.queued;return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[s,(0,t.jsx)("span",{className:`text-xs font-semibold ${"completed"===r||"done"===r?"text-slate-600":"text-slate-500"}`,children:e.title})]},e.id)})}),(0,t.jsx)("div",{className:"h-1.5 w-full bg-slate-200 rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-emerald-500 rounded-full shadow-[0_0_8px_rgba(16,185,129,0.4)] transition-all duration-500",style:{width:`${Math.round(100*h)}%`}})}),r&&!f&&(0,t.jsxs)("div",{className:"mt-3 flex items-center gap-3",children:["partial_failure"===e.buildStatus&&(0,t.jsx)("span",{className:"text-[11px] text-amber-600 font-semibold",children:"Some tasks failed to push."}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsxs)("button",{type:"button",onClick:u,disabled:s,className:"flex items-center gap-1.5 px-4 py-1.5 text-xs font-bold text-white bg-slate-900 hover:bg-slate-800 rounded-full shadow-sm transition-all disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,t.jsx)(z,{className:"w-3 h-3"}),s?"Pushing…":"Push to agx"]})]}),l&&(0,t.jsxs)("div",{className:"mt-2 text-[11px] text-amber-600 font-medium",children:["Status polling error: ",l]}),i&&(0,t.jsx)(q,{onSelect:p,onClose:()=>o(!1)})]})}let et=(0,l.default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var en=e.i(14670);let er=(0,l.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),es=(0,l.default)("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),ei="<!-- thread-summary -->";function eo({messages:e,streaming:r,participants:s,onOpenThread:i,onCopyThread:o,onAddToChat:a,onDeleteThreadRoot:l,onSummarize:d,onCreateTasks:c,onUpdateTaskDraft:h,onBuildTasks:p,summarizingThreads:f,extractingTasks:g,buildingDrafts:y,taskDrafts:b,deletingThreadRootId:v,highlightedMessageId:w}){let k=(0,n.useRef)(null),O=(0,n.useRef)(new Map),A=Object.fromEntries(s.map(e=>[e.id,e])),I=(0,n.useMemo)(()=>e.filter(e=>!e.rootMessageId),[e]),D=(0,n.useMemo)(()=>(function(e){let t=new Map;for(let n of e){let e=n.rootMessageId;if(!e)continue;let r=t.get(e);r||(r={rootMessageId:e,replyCount:0,participants:[],lastActivityAt:0,previewReplies:[],allReplies:[]},t.set(e,r)),r.replyCount++,r.lastActivityAt=Math.max(r.lastActivityAt,n.timestamp),r.lastReply=n,r.allReplies.push(n),n.participantId&&!r.participants.includes(n.participantId)?r.participants.push(n.participantId):n.participantId||r.participants.includes("user")||r.participants.push("user")}for(let e of t.values())e.allReplies.sort((e,t)=>e.timestamp-t.timestamp),e.previewReplies=[...e.allReplies],e.previewReplies.length>2&&(e.previewReplies=e.previewReplies.slice(-2));return t})(e),[e]),R=(0,n.useCallback)((e,t)=>{t?O.current.set(e,t):O.current.delete(e)},[]);return(0,n.useEffect)(()=>{if(!w)return;let e=O.current.get(w);e&&e.scrollIntoView({behavior:"smooth",block:"center"})},[w,e]),(0,n.useEffect)(()=>{w||k.current?.scrollIntoView({behavior:"smooth"})},[w,I,r]),(0,t.jsx)("div",{className:"chat-scrollbar flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto",children:[0===I.length&&0===Object.keys(r).length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center text-slate-400 mt-32 space-y-3",children:[(0,t.jsx)(C,{className:"h-6 w-6",strokeWidth:1.5}),(0,t.jsx)("span",{className:"text-sm font-medium tracking-wide",children:"Start a workspace"})]}),I.map(e=>{let n=e.participantId?A[e.participantId]:null,s=D.get(e.id),k=v===e.id,O=s?.allReplies.find(e=>e.content.startsWith(ei)),I=O?O.content.slice(ei.length).trim():null,P=(s?.previewReplies||[]).filter(e=>!e.content.startsWith(ei));return(0,t.jsxs)("div",{className:"max-w-2xl mx-auto bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden mb-6 group transition-all hover:border-slate-300 relative",children:[(o||a||l)&&(0,t.jsxs)("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[a&&(0,t.jsx)("button",{type:"button",onClick:()=>a(e.id),className:"p-1.5 text-slate-400 hover:bg-indigo-50 hover:text-indigo-600 rounded-md transition-colors",title:"Add to chat",children:(0,t.jsx)(es,{className:"w-3.5 h-3.5"})}),o&&(0,t.jsx)("button",{type:"button",onClick:()=>o(e.id),className:"p-1.5 text-slate-400 hover:bg-slate-100 rounded-md transition-colors",title:"Copy thread as markdown",children:(0,t.jsx)(et,{className:"w-3.5 h-3.5"})}),l&&(0,t.jsx)("button",{type:"button",onClick:()=>l(e.id),disabled:k,className:"p-1.5 text-slate-400 hover:bg-rose-50 hover:text-rose-600 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Delete this thread",children:k?(0,t.jsx)(N,{className:"w-3.5 h-3.5 animate-spin"}):(0,t.jsx)(u,{className:"w-3.5 h-3.5"})})]}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("div",{className:"p-5",children:(0,t.jsxs)("div",{ref:t=>R(e.id,t),"data-message-id":e.id,className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"flex gap-3 mb-4",children:["user"!==e.role&&(0,t.jsx)("div",{className:"w-10 h-10 rounded-full bg-slate-100 overflow-hidden border border-slate-100 shadow-sm flex items-center justify-center shrink-0",children:n?(0,t.jsx)("img",{src:(0,m.agentAvatarUrl)(n.id,40,n.color),alt:n.name,className:"w-full h-full object-cover"}):(0,t.jsx)("img",{src:(0,m.agentAvatarUrl)(e.participantId||"assistant",40),alt:e.participantId||"Assistant",className:"w-full h-full object-cover"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 pt-0.5",children:["user"!==e.role&&(0,t.jsx)("div",{className:"flex items-center gap-2 mb-0.5",children:(0,t.jsx)("span",{className:"font-bold text-sm text-slate-900",children:n?.name||e.participantId||"Assistant"})}),(0,t.jsxs)("div",{className:"cursor-pointer group/msg-title mb-1",onClick:()=>i?.(e.id),children:[(0,t.jsx)("h3",{className:"text-lg font-bold text-slate-900 leading-tight group-hover/msg-title:text-indigo-600 transition-colors line-clamp-1",children:T(e.content.split("\n")[0])}),(0,t.jsx)("div",{className:"mt-1",children:(0,t.jsx)("span",{className:"text-[11px] font-medium text-slate-400",children:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(e.timestamp)})}),(e.content.length>80||e.content.includes("\n"))&&(0,t.jsx)("div",{className:"mt-2 text-[15px] text-slate-600 leading-relaxed",children:(0,t.jsx)(x.Markdown,{content:T(e.content),isUser:"user"===e.role})})]})]})]}),e.attachments&&e.attachments.length>0&&(0,t.jsx)("div",{className:`mb-4 ${"user"!==e.role?"ml-[52px]":""}`,children:(0,t.jsx)(S,{attachments:e.attachments,compact:!0})}),I&&(0,t.jsx)("div",{className:"mb-4 text-sm text-slate-600 leading-relaxed",children:(0,t.jsx)(x.Markdown,{content:I,isUser:!1})}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[d&&s&&s.replyCount>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>d(e.id),disabled:f?.has(e.id),className:"flex items-center gap-1.5 px-3 py-1.5 bg-white border border-slate-200 rounded-full text-xs font-bold text-slate-600 hover:bg-slate-50 transition-colors shadow-sm disabled:opacity-50",children:[f?.has(e.id)?(0,t.jsx)(N,{className:"w-3.5 h-3.5 animate-spin text-slate-400"}):(0,t.jsx)(en.Clock,{className:"w-3.5 h-3.5 text-slate-400"}),f?.has(e.id)?"Summarizing…":"Summarize"]}),c&&s&&s.replyCount>0&&(0,t.jsxs)("button",{type:"button",onClick:()=>c(e.id),disabled:g?.has(e.id),className:"flex items-center gap-1.5 px-3 py-1.5 bg-white border border-slate-200 rounded-full text-xs font-bold text-slate-600 hover:bg-slate-50 transition-colors shadow-sm disabled:opacity-50",children:[g?.has(e.id)?(0,t.jsx)(N,{className:"w-3.5 h-3.5 animate-spin text-slate-400"}):(0,t.jsx)(er,{className:"w-3.5 h-3.5 text-slate-400"}),g?.has(e.id)?"Extracting…":b?.[e.id]?"Re-extract tasks":"Create tasks"]}),s&&s.replyCount>0&&i&&(0,t.jsxs)("button",{type:"button",onClick:()=>i(e.id),className:"flex items-center gap-2 px-3 py-1.5 bg-slate-50 border border-slate-100 rounded-full text-xs font-bold text-slate-500 hover:bg-slate-100 transition-colors",children:[(0,t.jsx)("div",{className:"flex -space-x-1.5",children:s.participants.slice(0,3).map(e=>{if("user"===e)return(0,t.jsx)("div",{className:"w-4 h-4 rounded-full bg-slate-200 flex items-center justify-center ring-1 ring-white",children:(0,t.jsx)(M.User,{className:"w-2.5 h-2.5 text-slate-400"})},"user");let n=A[e];return n?(0,t.jsx)("img",{src:(0,m.agentAvatarUrl)(e,16,n.color),alt:n.name,className:"w-4 h-4 rounded-full ring-1 ring-white"},e):(0,t.jsx)("div",{className:"w-4 h-4 rounded-full bg-slate-200 ring-1 ring-white"},e)})}),(0,t.jsxs)("span",{children:[s.replyCount," replies"]})]})]}),b?.[e.id]&&(b[e.id].builtTaskIds&&Object.keys(b[e.id].builtTaskIds).length>0?(0,t.jsx)(ee,{draft:b[e.id],onPush:(t,n,r)=>p?.(e.id,t,n,r),pushing:y?.has(b[e.id].draftId)}):(0,t.jsx)(K,{draft:b[e.id],onUpdate:t=>h?.(e.id,t),onBuild:(t,n,r)=>p?.(e.id,t,n,r),building:y?.has(b[e.id].draftId)})),g?.has(e.id)&&(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-2 text-xs text-slate-400",children:[(0,t.jsx)(N,{className:"w-3.5 h-3.5 animate-spin"}),(0,t.jsx)("span",{children:"Extracting tasks…"})]})]})}),!I&&s&&s.replyCount>0&&(0,t.jsx)("div",{className:"p-6 pt-0 border-t border-slate-100 bg-slate-50/10",children:(0,t.jsxs)("div",{className:"pt-4 max-h-[320px] overflow-hidden relative",children:[s.replyCount>P.length&&(0,t.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[(0,t.jsx)("div",{className:"flex-1 h-px bg-slate-100"}),(0,t.jsxs)("button",{onClick:()=>i?.(e.id),className:"flex items-center gap-2 text-[11px] font-bold uppercase tracking-wider text-slate-400 hover:text-indigo-600 transition-colors shrink-0",children:[(0,t.jsx)(C,{className:"w-3.5 h-3.5"}),(0,t.jsxs)("span",{children:["Show ",s.replyCount-P.length," more ",s.replyCount-P.length==1?"reply":"replies"]})]}),(0,t.jsx)("div",{className:"flex-1 h-px bg-slate-100"})]}),(0,t.jsx)("div",{className:"space-y-1",children:P.map(e=>{let n=e.participantId?A[e.participantId]:null;return(0,t.jsx)("div",{ref:t=>R(e.id,t),"data-message-id":e.id,children:(0,t.jsx)(j,{isRoot:!1,message:e,participantName:n?.name||e.participantId||"Assistant",participantColor:n?.color,participantId:n?.id||e.participantId||void 0,onOpenThread:i,highlighted:e.id===w})},e.id)})}),(0,t.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-slate-50 via-slate-50/80 to-transparent pointer-events-none z-10"})]})}),Object.entries(r).filter(([,t])=>t.rootMessageId===e.id).map(([e,n])=>{let r=A[e];return(0,t.jsx)("div",{className:"px-6 pb-4",children:(0,t.jsx)(E,{participantId:e,participantName:r?.name||e,participantColor:r?.color||"#888",content:n.content})},`streaming-${e}`)})]})]},e.id)}),Object.entries(r).filter(([,e])=>!e.rootMessageId).map(([e,n])=>{let r=A[e];return(0,t.jsx)("div",{className:"max-w-2xl mx-auto mb-8 px-4",children:(0,t.jsx)(E,{participantId:e,participantName:r?.name||e,participantColor:r?.color||"#888",content:n.content})},`streaming-${e}`)}),(0,t.jsx)("div",{ref:k})]})})}let ea=(0,l.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);function el({messages:e,streaming:r,participants:s,rootMessageId:i,onClose:o,onCopyThread:a,onAddToChat:l,onDeleteThreadRoot:d,highlightedMessageId:c,renderReplyComposer:h}){let p=(0,n.useRef)(null),f=(0,n.useRef)(new Map),g=Object.fromEntries(s.map(e=>[e.id,e])),y=(0,n.useMemo)(()=>{let t=e.find(e=>e.id===i),n=e.filter(e=>e.rootMessageId===i).sort((e,t)=>e.timestamp-t.timestamp);return t?[t,...n]:n},[e,i]);return(0,n.useEffect)(()=>{if(c){let e=f.current.get(c);e&&e.scrollIntoView({behavior:"smooth",block:"center"})}else p.current?.scrollIntoView({behavior:"smooth"})},[c,y,r]),(0,t.jsxs)("div",{className:"flex flex-col h-full overflow-hidden bg-slate-50",children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4 md:p-8 space-y-6 chat-scrollbar",children:(0,t.jsxs)("div",{className:"max-w-2xl mx-auto space-y-8 pb-4",children:[y.map(e=>{let n,r="user"===e.role,s=e.participantId?g[e.participantId]:null;return(0,t.jsxs)("div",{ref:t=>{var n;return n=e.id,void(t?f.current.set(n,t):f.current.delete(n))},"data-message-id":e.id,className:"group relative flex gap-4 ",children:[(0,t.jsx)("div",{className:"flex-shrink-0 mt-1",children:r?(0,t.jsx)("div",{className:"w-10 h-10 bg-slate-200 rounded-full flex items-center justify-center text-slate-600 shadow-sm",children:(0,t.jsx)(M.User,{size:20})}):(0,t.jsx)("img",{src:s?(0,m.agentAvatarUrl)(s.id,40,s.color):(0,m.agentAvatarUrl)(e.participantId||"assistant",40),alt:s?.name||e.participantId||"Assistant",className:"w-10 h-10 rounded-full shadow-sm border border-slate-100 object-cover bg-slate-100"})}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5 max-w-full overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-bold text-sm text-slate-900",style:!r&&s?.color?{color:s.color}:void 0,children:r?"You":s?.name||e.participantId||"Assistant"}),void 0===e.rootMessageId&&e.id===i&&(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 bg-slate-100 text-slate-500 rounded font-mono uppercase",children:"ROOT"}),(0,t.jsx)("span",{className:"text-[11px] text-slate-400",children:(n=e.timestamp,new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(n))})]}),(0,t.jsxs)("div",{className:`rounded-2xl p-4 text-[15px] leading-relaxed shadow-sm border ${r?"bg-slate-100 text-slate-700 border-slate-200":"bg-white text-slate-700 border-slate-200"} ${e.id===c?"ring-2 ring-indigo-400":""}`,children:[(0,t.jsx)(x.Markdown,{content:T(e.content),isUser:r}),e.attachments&&e.attachments.length>0&&(0,t.jsx)(S,{attachments:e.attachments}),e.reactions&&e.reactions.length>0&&(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(v,{reactions:e.reactions})})]}),(0,t.jsxs)("div",{className:"absolute top-8 -right-2 opacity-0 group-hover:opacity-100 transition-opacity flex items-center gap-1 bg-white border border-slate-200 rounded-lg shadow-sm p-1 z-10 translate-x-full",children:[e.id===i&&l&&(0,t.jsx)("button",{onClick:()=>l(e.id),className:"p-1.5 text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 rounded",title:"Add to chat",children:(0,t.jsx)(es,{size:14})}),e.id===i&&a&&(0,t.jsx)("button",{onClick:()=>a(e.id),className:"p-1.5 text-slate-400 hover:text-slate-600 hover:bg-slate-50 rounded",title:"Copy Thread",children:(0,t.jsx)(et,{size:14})}),(0,t.jsx)("button",{className:"p-1.5 text-slate-400 hover:text-slate-600 hover:bg-slate-50 rounded",title:"Maximize",children:(0,t.jsx)(ea,{size:14})}),e.id===i&&d&&(0,t.jsx)("button",{onClick:()=>d(e.id),className:"p-1.5 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded",title:"Delete Thread",children:(0,t.jsx)(u,{size:14})})]})]})]},e.id)}),Object.entries(r).filter(([,e])=>e.rootMessageId===i).map(([e,n])=>{let r=g[e],s=n.content.trim().length>0;return(0,t.jsxs)("div",{className:"flex gap-4 group relative",children:[(0,t.jsx)("div",{className:"flex-shrink-0 mt-1",children:(0,t.jsx)("img",{src:r?(0,m.agentAvatarUrl)(r.id,40,r.color):(0,m.agentAvatarUrl)(e,40),alt:r?.name||e,className:"w-10 h-10 rounded-full shadow-sm border border-slate-100 object-cover bg-slate-100"})}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5 max-w-full overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-bold text-sm text-slate-900",style:r?.color?{color:r.color}:void 0,children:r?.name||e}),!s&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-[3px]",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-400 animate-[pulse-dot_1.4s_ease-in-out_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-400 animate-[pulse-dot_1.4s_ease-in-out_0.2s_infinite]"}),(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-400 animate-[pulse-dot_1.4s_ease-in-out_0.4s_infinite]"})]})]}),s&&(0,t.jsx)("div",{className:"rounded-2xl p-4 text-[15px] leading-relaxed shadow-sm border bg-white text-slate-700 border-slate-200",children:(0,t.jsx)(x.Markdown,{content:T(n.content),isUser:!1})})]})]},`streaming-${e}`)}),(0,t.jsx)("div",{ref:p,className:"h-4"})]})}),(0,t.jsx)("div",{className:"z-20",children:h(i)})]})}let ed=(0,l.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),ec=(0,l.default)("search-x",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);function eh({query:e,results:n,total:r,participants:s,threadTitleById:i,isLoading:o,error:a,onSelectResult:l,headerSlot:d}){let c=Object.fromEntries(s.map(e=>[e.id,e]));return(0,t.jsx)("div",{className:"chat-scrollbar flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"max-w-3xl mx-auto",children:[d?(0,t.jsx)("div",{className:"sticky top-0 z-20 bg-slate-50/70 backdrop-blur-md pt-4 pb-6 px-4 -mx-4 border-b border-transparent transition-colors",children:(0,t.jsx)("div",{className:"max-w-2xl mx-auto",children:d})}):null,(0,t.jsxs)("div",{className:"mb-4 rounded-xl border border-slate-200 bg-white px-4 py-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-slate-700",children:"Search results"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-slate-500",children:o?"Searching…":`${r} result${1===r?"":"s"} for "${e}"`}),a?(0,t.jsx)("div",{className:"mt-2 text-sm text-rose-600",children:a}):null]}),o||a||0!==n.length?null:(0,t.jsxs)("div",{className:"mt-20 flex flex-col items-center justify-center space-y-2 text-slate-400",children:[(0,t.jsx)(ec,{className:"h-6 w-6",strokeWidth:1.5}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No matching messages"})]}),(0,t.jsx)("div",{className:"space-y-3 pb-6",children:n.map(e=>{var n;let r=e.participantId?c[e.participantId]:null,s=i[e.threadId]||"Untitled workspace",o="user"===e.role?"You":r?.name||e.participantId||"Assistant";return(0,t.jsxs)("button",{type:"button",onClick:()=>l(e),className:"w-full rounded-xl border border-slate-200 bg-white p-4 text-left transition hover:border-slate-300 hover:shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-400",children:[(0,t.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("div",{className:"flex h-8 w-8 items-center justify-center overflow-hidden rounded-full bg-slate-100",children:"user"===e.role?(0,t.jsx)(M.User,{className:"h-4 w-4 text-slate-700"}):r?(0,t.jsx)("img",{src:(0,m.agentAvatarUrl)(r.id,32,r.color),alt:"",className:"h-full w-full object-cover"}):(0,t.jsx)(ed,{className:"h-4 w-4 text-slate-700"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"truncate text-sm font-semibold text-slate-800",children:o}),(0,t.jsx)("p",{className:"truncate text-xs text-slate-500",children:s})]})]}),(0,t.jsx)("span",{className:"shrink-0 text-xs text-slate-400",children:(n=e.timestamp,new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(n))})]}),(0,t.jsx)("p",{className:"text-sm leading-relaxed text-slate-700",children:function(e){let n=e.split(/(<\/?mark>)/g),r=!1,s=[];for(let[e,i]of n.entries()){if("<mark>"===i){r=!0;continue}if("</mark>"===i){r=!1;continue}i&&s.push(r?(0,t.jsx)("mark",{className:"rounded bg-amber-200/80 px-0.5",children:i},`${e}-mark`):(0,t.jsx)("span",{children:i},`${e}-text`))}return s}(e.snippet)})]},`${e.threadId}-${e.messageId}`)})})]})})}var eu=n,ep=e.i(50333),ef=e.i(32527);function em(e){this.content=e}em.prototype={constructor:em,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return -1},get:function(e){var t=this.find(e);return -1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,s=r.find(e),i=r.content.slice();return -1==s?i.push(n||e,t):(i[s+1]=t,n&&(i[s]=n)),new em(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new em(n)},addToStart:function(e,t){return new em([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new em(n)},addBefore:function(e,t,n){var r=this.remove(t),s=r.content.slice(),i=r.find(e);return s.splice(-1==i?s.length:i,0,t,n),new em(s)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=em.from(e)).size?new em(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=em.from(e)).size?new em(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=em.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},em.from=function(e){if(e instanceof em)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new em(t)};class eg{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,s){for(let i=0,o=0;o<t;i++){let a=this.content[i],l=o+a.nodeSize;if(l>e&&!1!==n(a,r+o,s||null,i)&&a.content.size){let s=o+1;a.nodesBetween(Math.max(0,e-s),Math.min(a.content.size,t-s),n,r+s)}o=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let s="",i=!0;return this.nodesBetween(e,t,(o,a)=>{let l=o.isText?o.text.slice(Math.max(e,a)-a,t-a):o.isLeaf?r?"function"==typeof r?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&l||o.isTextblock)&&n&&(i?i=!1:s+=n),s+=l},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new eg(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let s=0,i=0;i<t;s++){let o=this.content[s],a=i+o.nodeSize;a>e&&((i<e||a>t)&&(o=o.isText?o.cut(Math.max(0,e-i),Math.min(o.text.length,t-i)):o.cut(Math.max(0,e-i-1),Math.min(o.content.size,t-i-1))),n.push(o),r+=o.nodeSize),i=a}return new eg(n,r)}cutByIndex(e,t){return e==t?eg.empty:0==e&&t==this.content.length?this:new eg(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new eg(r,s)}addToStart(e){return new eg([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new eg(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))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(e){let t=this.content[e];if(!t)throw RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return function e(t,n,r){for(let s=0;;s++){if(s==t.childCount||s==n.childCount)return t.childCount==n.childCount?null:r;let i=t.child(s),o=n.child(s);if(i==o){r+=i.nodeSize;continue}if(!i.sameMarkup(o))return r;if(i.isText&&i.text!=o.text){for(let e=0;i.text[e]==o.text[e];e++)r++;return r}if(i.content.size||o.content.size){let t=e(i.content,o.content,r+1);if(null!=t)return t}r+=i.nodeSize}}(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return function e(t,n,r,s){for(let i=t.childCount,o=n.childCount;;){if(0==i||0==o)return i==o?null:{a:r,b:s};let a=t.child(--i),l=n.child(--o),d=a.nodeSize;if(a==l){r-=d,s-=d;continue}if(!a.sameMarkup(l))return{a:r,b:s};if(a.isText&&a.text!=l.text){let e=0,t=Math.min(a.text.length,l.text.length);for(;e<t&&a.text[a.text.length-e-1]==l.text[l.text.length-e-1];)e++,r--,s--;return{a:r,b:s}}if(a.content.size||l.content.size){let t=e(a.content,l.content,r-1,s-1);if(t)return t}r-=d,s-=d}}(this,e,t,n)}findIndex(e){if(0==e)return ey(0,e);if(e==this.size)return ey(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e){if(r==e)return ey(t+1,r);return ey(t,n)}n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return eg.empty;if(!Array.isArray(t))throw RangeError("Invalid input for Fragment.fromJSON");return new eg(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return eg.empty;let t,n=0;for(let r=0;r<e.length;r++){let s=e[r];n+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new eg(t||e,n)}static from(e){if(!e)return eg.empty;if(e instanceof eg)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new eg([e],e.nodeSize);throw RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}eg.empty=new eg([],0);let ex={index:0,offset:0};function ey(e,t){return ex.index=e,ex.offset=t,ex}function eb(e,t){if(e===t)return!0;if(!(e&&"object"==typeof e)||!(t&&"object"==typeof t))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!eb(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!eb(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class ev{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&eb(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return ev.none;if(e instanceof ev)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}ev.none=[];class ew extends Error{}class ek{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=function e(t,n,r,s){let{index:i,offset:o}=t.findIndex(n),a=t.maybeChild(i);if(o==n||a.isText)return s&&!s.canReplace(i,i,r)?null:t.cut(0,n).append(r).append(t.cut(n));let l=e(a.content,n-o-1,r,a);return l&&t.replaceChild(i,a.copy(l))}(this.content,e+this.openStart,t);return n&&new ek(n,this.openStart,this.openEnd)}removeBetween(e,t){return new ek(function e(t,n,r){let{index:s,offset:i}=t.findIndex(n),o=t.maybeChild(s),{index:a,offset:l}=t.findIndex(r);if(i==n||o.isText){if(l!=r&&!t.child(a).isText)throw RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(s!=a)throw RangeError("Removing non-flat range");return t.replaceChild(s,o.copy(e(o.content,n-i-1,r-i-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return ek.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw RangeError("Invalid input for Slice.fromJSON");return new ek(eg.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new ek(e,n,r)}}function eS(e,t){if(!t.type.compatibleContent(e.type))throw new ew("Cannot join "+t.type.name+" onto "+e.type.name)}function eC(e,t,n){let r=e.node(n);return eS(r,t.node(n)),r}function eM(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function eN(e,t,n,r){let s=(t||e).node(n),i=0,o=t?t.index(n):s.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(eM(e.nodeAfter,r),i++));for(let e=i;e<o;e++)eM(s.child(e),r);t&&t.depth==n&&t.textOffset&&eM(t.nodeBefore,r)}function eT(e,t){return e.type.checkContent(t),e.copy(t)}function ej(e,t,n){let r=[];return eN(null,e,n,r),e.depth>n&&eM(eT(eC(e,t,n+1),ej(e,t,n+1)),r),eN(t,null,n,r),new eg(r)}ek.empty=new ek(eg.empty,0,0);class eO{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return ev.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let s=n.marks;for(var i=0;i<s.length;i++)!1!==s[i].type.spec.inclusive||r&&s[i].isInSet(r.marks)||(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||r&&n[s].isInSet(r.marks)||(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new eD(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw RangeError("Position "+t+" out of range");let n=[],r=0,s=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(s),o=s-i;if(n.push(t,e,r+i),!o||(t=t.child(e)).isText)break;s=o-1,r+=i+1}return new eO(t,n,s)}static resolveCached(e,t){let n=eI.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else eI.set(e,n=new eE);let r=n.elts[n.i]=eO.resolve(e,t);return n.i=(n.i+1)%eA,r}}class eE{constructor(){this.elts=[],this.i=0}}let eA=12,eI=new WeakMap;class eD{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}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 eR=Object.create(null);class eP{constructor(e,t,n,r=ev.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||eg.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&eb(this.attrs,t||e.defaultAttrs||eR)&&ev.sameSet(this.marks,n||ev.none)}copy(e=null){return e==this.content?this:new eP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new eP(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return ek.empty;let r=this.resolve(e),s=this.resolve(t),i=n?0:r.sharedDepth(t),o=r.start(i);return new ek(r.node(i).content.cut(r.pos-o,s.pos-o),r.depth-i,s.depth-i)}replace(e,t,n){var r=this.resolve(e),s=this.resolve(t);if(n.openStart>r.depth)throw new ew("Inserted content deeper than insertion position");if(r.depth-n.openStart!=s.depth-n.openEnd)throw new ew("Inconsistent open depths");return function e(t,n,r,s){let i=t.index(s),o=t.node(s);if(i==n.index(s)&&s<t.depth-r.openStart){let a=e(t,n,r,s+1);return o.copy(o.content.replaceChild(i,a))}if(!r.content.size)return eT(o,ej(t,n,s));if(r.openStart||r.openEnd||t.depth!=s||n.depth!=s){let{start:e,end:i}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(eg.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t);return eT(o,function e(t,n,r,s,i){let o=t.depth>i&&eC(t,n,i+1),a=s.depth>i&&eC(r,s,i+1),l=[];return eN(null,t,i,l),o&&a&&n.index(i)==r.index(i)?(eS(o,a),eM(eT(o,e(t,n,r,s,i+1)),l)):(o&&eM(eT(o,ej(t,n,i+1)),l),eN(n,r,i,l),a&&eM(eT(a,ej(r,s,i+1)),l)),eN(s,null,i,l),new eg(l)}(t,e,i,n,s))}{let e=t.parent,s=e.content;return eT(e,s.cut(0,t.parentOffset).append(r.content).append(s.cut(n.parentOffset)))}}(r,s,n,0)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(!(t=t.maybeChild(n)))return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return eO.resolveCached(this,e)}resolveNoCache(e){return eO.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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 e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),e$(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=eg.empty,r=0,s=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,s),o=i&&i.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<s;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(n),i=s&&s.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ev.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ev.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){let n;if(!t)throw RangeError("Invalid input for Node.fromJSON");if(t.marks){if(!Array.isArray(t.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=eg.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,n);return s.type.checkAttrs(s.attrs),s}}eP.prototype.text=void 0;class ez extends eP{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):e$(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new ez(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ez(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function e$(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class eL{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){var n;let r,s=new eB(e,t);if(null==s.next)return eL.empty;let i=function e(t){let n=[];do n.push(function(t){let n=[];do n.push(function(t){let n=function(t){if(t.eat("(")){let n=e(t);return t.eat(")")||t.err("Missing closing paren"),n}if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=(function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let s=[];for(let e in n){let r=n[e];r.isInGroup(t)&&s.push(r)}return 0==s.length&&e.err("No node type or group '"+t+"' found"),s})(t,t.next).map(e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}}(t);for(;;)if(t.eat("+"))n={type:"plus",expr:n};else if(t.eat("*"))n={type:"star",expr:n};else if(t.eat("?"))n={type:"opt",expr:n};else if(t.eat("{"))n=function(e,t){let n=eV(e),r=n;return e.eat(",")&&(r="}"!=e.next?eV(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}(t,n);else break;return n}(t));while(t.next&&")"!=t.next&&"|"!=t.next)return 1==n.length?n[0]:{type:"seq",exprs:n}}(t));while(t.eat("|"))return 1==n.length?n[0]:{type:"choice",exprs:n}}(s);s.next&&s.err("Unexpected trailing text");let o=(n=function(e){let t=[[]];return s(function e(t,i){if("choice"==t.type)return t.exprs.reduce((t,n)=>t.concat(e(n,i)),[]);if("seq"==t.type)for(let r=0;;r++){let o=e(t.exprs[r],i);if(r==t.exprs.length-1)return o;s(o,i=n())}else if("star"==t.type){let o=n();return r(i,o),s(e(t.expr,o),o),[r(o)]}else if("plus"==t.type){let o=n();return s(e(t.expr,i),o),s(e(t.expr,o),o),[r(o)]}else if("opt"==t.type)return[r(i)].concat(e(t.expr,i));else if("range"==t.type){let o=i;for(let r=0;r<t.min;r++){let r=n();s(e(t.expr,o),r),o=r}if(-1==t.max)s(e(t.expr,o),o);else for(let i=t.min;i<t.max;i++){let i=n();r(o,i),s(e(t.expr,o),i),o=i}return[r(o)]}else if("name"==t.type)return[r(i,void 0,t.value)];else throw Error("Unknown expr type")}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let s={term:r,to:n};return t[e].push(s),s}function s(e,t){e.forEach(e=>e.to=t)}}(i),r=Object.create(null),function e(t){let s=[];t.forEach(e=>{n[e].forEach(({term:e,to:t})=>{let r;if(e){for(let t=0;t<s.length;t++)s[t][0]==e&&(r=s[t][1]);e_(n,t).forEach(t=>{r||s.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)})}})});let i=r[t.join(",")]=new eL(t.indexOf(n.length-1)>-1);for(let t=0;t<s.length;t++){let n=s[t][1].sort(eF);i.next.push({type:s[t][0],next:r[n.join(",")]||e(n)})}return i}(e_(n,0)));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],s=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];i.push(n.name),s&&!(n.isText||n.hasRequiredAttrs())&&(s=!1),-1==r.indexOf(o)&&r.push(o)}s&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,s),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let s=t;r&&s<n;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function s(i,o){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return eg.from(o.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!(t.isText||t.hasRequiredAttrs())&&-1==r.indexOf(n)){r.push(n);let e=s(n,o.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),s=r.match;if(s.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<s.next.length;e++){let{type:i,next:o}=s.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!o.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return!function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}eL.empty=new eL(!0);class eB{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.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(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function eV(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function eF(e,t){return t-e}function e_(e,t){let n=[];return function t(r){let s=e[r];if(1==s.length&&!s[0].term)return t(s[0].to);n.push(r);for(let e=0;e<s.length;e++){let{term:r,to:i}=s[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(eF)}function eH(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function eU(e,t){let n=Object.create(null);for(let r in e){let s=t&&t[r];if(void 0===s){let t=e[r];if(t.hasDefault)s=t.default;else throw RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function eW(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function eq(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new eJ(e,r,t[r]);return n}class eK{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=eq(e,n.attrs),this.defaultAttrs=eH(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==eL.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:eU(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new eP(this,this.computeAttrs(e),eg.from(t),ev.setFrom(n))}createChecked(e=null,t,n){return t=eg.from(t),this.checkContent(t),new eP(this,this.computeAttrs(e),t,ev.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=eg.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(eg.empty,!0);return s?new eP(this,e,t.append(s),ev.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){eW(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){let t;if(null==this.markSet)return e;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:ev.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new eK(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}class eJ{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let s=null===n?"null":typeof n;if(0>r.indexOf(s))throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${s}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class eG{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=eq(e,r.attrs),this.excluded=null;let s=eH(this.attrs);this.instance=s?new ev(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ev(this,eU(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,s)=>n[e]=new eG(e,r++,t,s)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){eW(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class eX{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=em.from(e.nodes),t.marks=em.from(e.marks||{}),this.nodes=eK.compile(this.spec.nodes,this),this.marks=eG.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",s=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=eL.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==s?null:s?eY(this,s.split(" ")):""!=s&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:eY(this,n.split(" "))}this.nodeFromJSON=e=>eP.fromJSON(this,e),this.markFromJSON=e=>ev.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else if(e instanceof eK){if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")")}else throw RangeError("Invalid node type: "+e);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new ez(n,n.defaultAttrs,e,ev.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError("Unknown node type: "+e);return t}}function eY(e,t){let n=[];for(let r=0;r<t.length;r++){let s=t[r],i=e.marks[s],o=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==s||r.spec.group&&r.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=r)}if(!o)throw SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class eQ{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(null!=e.tag)this.tags.push(e);else if(null!=e.style){let t=/[^=]*/.exec(e.style)[0];0>n.indexOf(t)&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new e5(this,t,!1);return n.addAll(e,ev.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new e5(this,t,!0);return n.addAll(e,ev.none,t.from,t.to),ek.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){var r,s;let n=this.tags[i];if(r=e,s=n.tag,(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,s)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let r=this.styles[s],i=r.style;if(0==i.indexOf(e)&&(!r.context||n.matchesContext(r.context))&&(!(i.length>e.length)||61==i.charCodeAt(e.length)&&i.slice(e.length+1)==t)){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=e4(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=e4(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new eQ(e,eQ.schemaRules(e)))}}let eZ={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},e0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},e1={ol:!0,ul:!0};function e2(e,t,n){return null!=t?!!t|2*("full"===t):e&&"pre"==e.whitespace?3:-5&n}class e3{constructor(e,t,n,r,s,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=ev.none,this.match=s||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(eg.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e=this.content[this.content.length-1],t;e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-t[0].length)))}let t=eg.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(eg.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!eZ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class e5{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,s,i=e2(null,t.preserveWhitespace,0)|4*!!n;s=r?new e3(r.type,r.attrs,ev.none,!0,t.topMatch||r.type.contentMatch,i):n?new e3(null,null,ev.none,!0,null,i):new e3(e.schema.topNodeType,null,ev.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,s=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===s||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if("full"===s)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],s=e.previousSibling;(!t||s&&"BR"==s.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,s=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),o;e1.hasOwnProperty(i)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&e1.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(a?a.ignore:e0.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,r=this.needsBlock;if(eZ.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),n=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let o=a&&a.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(s),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],s=n.getPropertyValue(r);if(s)for(let e;;){let n=this.parser.matchStyle(r,s,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1===n.consuming)e=n;else break}}return t}addElementByRule(e,t,n,r){let s,i;if(t.node)if((i=this.parser.schema.nodes[t.node]).isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(s=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}s&&this.sync(o)&&this.open--}addAll(e,t,n,r){let s=n||0;for(let i=n?e.childNodes[n]:e.firstChild,o=null==r?null:e.childNodes[r];i!=o;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,n){let r,s;for(let t=this.open,i=0;t>=0;t--){let o=this.nodes[t],a=o.findWrapping(e);if(a&&(!r||r.length>a.length+i)&&(r=a,s=o,!a.length))break;if(o.solid){if(n)break;i+=2}}if(!r)return null;this.sync(s);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=ev.none;for(let s of r.concat(e.marks))(t.type?t.type.allowsMarkType(s.type):e6(s.type,e.type))&&(n=s.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,r)),s}enterInner(e,t,n,r=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let o=e2(e,s,i.options);4&i.options&&0==i.content.length&&(o|=4);let a=ev.none;return n=n.filter(t=>(i.type?!i.type.allowsMarkType(t.type):!e6(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new e3(e,t,a,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));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(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=1);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+ +!r,i=(e,o)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;o>=s;o--)if(i(e-1,o))return!0;return!1}{let e=o>0||0==o&&r?this.nodes[o].type:n&&o>=s?n.node(o-s).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;o--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function e4(e){let t={};for(let n in e)t[n]=e[n];return t}function e6(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let i=[],o=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:s}=e.edge(n);if(r==t||0>i.indexOf(s)&&o(s))return!0}};if(o(s.contentMatch))return!0}}class e8{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=e9(t).createDocumentFragment());let r=n,s=[];return e.forEach(e=>{if(s.length||e.marks.length){let n=0,i=0;for(;n<s.length&&i<e.marks.length;){let t=e.marks[i];if(!this.marks[t.type.name]){i++;continue}if(!t.eq(s[n][0])||!1===t.type.spec.spanning)break;n++,i++}for(;n<s.length;)r=s.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],o=this.serializeMark(n,e.isInline,t);o&&(s.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=tt(e9(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&tt(e9(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return tt(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new e8(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=e7(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return e7(e.marks)}}function e7(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function e9(e){return e.document||window.document}let te=new WeakMap;function tt(e,t,n,r){let s,i,o;if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let a=t[0],l;if("string"!=typeof a)throw RangeError("Invalid array passed to renderSpec");if(r&&(void 0===(i=te.get(r))&&te.set(r,(o=null,!function e(t){if(t&&"object"==typeof t)if(Array.isArray(t))if("string"==typeof t[0])o||(o=[]),o.push(t);else for(let n=0;n<t.length;n++)e(t[n]);else for(let n in t)e(t[n])}(r),i=o)),l=i)&&l.indexOf(t)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let d=a.indexOf(" ");d>0&&(n=a.slice(0,d),a=a.slice(d+1));let c=n?e.createElementNS(n,a):e.createElement(a),h=t[1],u=1;if(h&&"object"==typeof h&&null==h.nodeType&&!Array.isArray(h)){for(let e in u=2,h)if(null!=h[e]){let t=e.indexOf(" ");t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),h[e]):"style"==e&&c.style?c.style.cssText=h[e]:c.setAttribute(e,h[e])}}for(let i=u;i<t.length;i++){let o=t[i];if(0===o){if(i<t.length-1||i>u)throw RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}{let{dom:t,contentDOM:i}=tt(e,o,n,r);if(c.appendChild(t),i){if(s)throw RangeError("Multiple content holes");s=i}}}return{dom:c,contentDOM:s}}class tn{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}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 tr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&tr.empty)return tr.empty}recover(e){let t=0,n=65535&e;if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+(e-(65535&e))/65536}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let a=this.ranges[o]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[o+s],d=this.ranges[o+i],c=a+l;if(e<=c){let s=l?e==a?-1:e==c?1:t:t,i=a+r+(s<0?0:d);if(n)return i;let h=e==(t<0?a:c)?null:o/3+(e-a)*65536,u=e==a?2:e==c?1:4;return(t<0?e!=a:e!=c)&&(u|=8),new tn(i,u,h)}r+=d-l}return n?e+r:new tn(e+r,0,null)}touches(e,t){let n=0,r=65535&t,s=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let a=this.ranges[t+s];if(e<=o+a&&t==3*r)return!0;n+=this.ranges[t+i]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let i=this.ranges[r],o=i-(this.inverted?s:0),a=i+(this.inverted?0:s),l=this.ranges[r+t],d=this.ranges[r+n];e(o,o+l,a,a+d),s+=d-l}}invert(){return new tr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?tr.empty:new tr(e<0?[0,-e,0]:[0,0,e])}}tr.empty=new tr([]);class ts{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new ts(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new ts;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let s=this._maps[n].mapResult(e,t);if(null!=s.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(s.recover);continue}}r|=s.delInfo,e=s.pos}return n?e:new tn(e,r,null)}}let ti=Object.create(null);class to{getMap(){return tr.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError("Invalid input for Step.fromJSON");let n=ti[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ti)throw RangeError("Duplicate use of step JSON ID "+e);return ti[e]=t,t.prototype.jsonID=e,t}}class ta{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ta(e,null)}static fail(e){return new ta(null,e)}static fromReplace(e,t,n,r){try{return ta.ok(e.replace(t,n,r))}catch(e){if(e instanceof ew)return ta.fail(e.message);throw e}}}function tl(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let i=e.child(s);i.content.size&&(i=i.copy(tl(i.content,t,i))),i.isInline&&(i=t(i,n,s)),r.push(i)}return eg.fromArray(r)}class td extends to{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),s=new ek(tl(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return ta.fromReplace(e,this.from,this.to,s)}invert(){return new tc(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new td(t.pos,n.pos,this.mark)}merge(e){return e instanceof td&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new td(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new td(t.from,t.to,e.markFromJSON(t.mark))}}to.jsonID("addMark",td);class tc extends to{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new ek(tl(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return ta.fromReplace(e,this.from,this.to,n)}invert(){return new td(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new tc(t.pos,n.pos,this.mark)}merge(e){return e instanceof tc&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tc(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new tc(t.from,t.to,e.markFromJSON(t.mark))}}to.jsonID("removeMark",tc);class th extends to{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ta.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ta.fromReplace(e,this.pos,this.pos+1,new ek(eg.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new th(this.pos,t.marks[n]);return new th(this.pos,this.mark)}}return new tu(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new th(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new th(t.pos,e.markFromJSON(t.mark))}}to.jsonID("addNodeMark",th);class tu extends to{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ta.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ta.fromReplace(e,this.pos,this.pos+1,new ek(eg.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new th(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tu(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new tu(t.pos,e.markFromJSON(t.mark))}}to.jsonID("removeNodeMark",tu);class tp extends to{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&tm(e,this.from,this.to)?ta.fail("Structure replace would overwrite content"):ta.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new tr([this.from,this.to-this.from,this.slice.size])}invert(e){return new tp(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new tp(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof tp)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart)if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;else{let t=this.slice.size+e.slice.size==0?ek.empty:new ek(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new tp(e.from,this.to,t,this.structure)}{let t=this.slice.size+e.slice.size==0?ek.empty:new ek(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new tp(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for ReplaceStep.fromJSON");return new tp(t.from,t.to,ek.fromJSON(e,t.slice),!!t.structure)}}to.jsonID("replace",tp);class tf extends to{constructor(e,t,n,r,s,i,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=s,this.insert=i,this.structure=o}apply(e){if(this.structure&&(tm(e,this.from,this.gapFrom)||tm(e,this.gapTo,this.to)))return ta.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ta.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?ta.fromReplace(e,this.from,this.to,n):ta.fail("Content does not fit in gap")}getMap(){return new tr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new tf(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||s>n.pos?null:new tf(t.pos,n.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new tf(t.from,t.to,t.gapFrom,t.gapTo,ek.fromJSON(e,t.slice),t.insert,!!t.structure)}}function tm(e,t,n){let r=e.resolve(t),s=n-t,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,s--}}return!1}function tg(e,t,n,r=n.contentMatch,s=!0){let i=e.doc.nodeAt(t),o=[],a=t+1;for(let t=0;t<i.childCount;t++){let l=i.child(t),d=a+l.nodeSize,c=r.matchType(l.type);if(c){r=c;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new tc(a,d,l.marks[t]));if(s&&l.isText&&"pre"!=n.whitespace){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(l.text);)r||(r=new ek(eg.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),o.push(new tp(a+e.index,a+e.index+e[0].length,r))}}else o.push(new tp(a,d,ek.empty));a=d}if(!r.validEnd){let t=r.fillBefore(eg.empty,!0);e.replace(a,a,new ek(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function tx(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,s=0;;--n){let i=e.$from.node(n),o=e.$from.index(n)+r,a=e.$to.indexAfter(n)-s;if(n<e.depth&&i.canReplace(o,a,t))return n;if(0==n||i.type.spec.isolating||!((0==o||i.canReplace(o,i.childCount))&&(a==i.childCount||i.canReplace(0,a))))break;o&&(r=1),a<i.childCount&&(s=1)}return null}function ty(e,t,n=null,r=e){let s=function(e,t){let{parent:n,startIndex:r,endIndex:s}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let o=i.length?i[0]:t;return n.canReplaceWith(r,s,o)?i:null}(e,t),i=s&&function(e,t){let{parent:n,startIndex:r,endIndex:s}=e,i=n.child(r),o=t.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;a&&e<s;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?o:null}(r,t);return i?s.map(tb).concat({type:t,attrs:n}).concat(i.map(tb)):null}function tb(e){return{type:e,attrs:null}}function tv(e,t,n,r){t.forEach((s,i)=>{if(s.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(s.text);){let s=e.mapping.slice(r).map(n+1+i+o.index);e.replaceWith(s,s+1,t.type.schema.linebreakReplacement.create())}}})}function tw(e,t,n,r){t.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let s=e.mapping.slice(r).map(n+1+i);e.replaceWith(s,s+1,t.type.schema.text("\n"))}})}function tk(e,t,n=1,r){let s=e.resolve(t),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let e=s.depth-1,t=n-2;e>i;e--,t--){let n=s.node(e),i=s.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(i,n.childCount),a=r&&r[t+1];a&&(o=o.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(o))return!1}let a=s.indexAfter(i),l=r&&r[0];return s.node(i).canReplaceWith(a,a,l?l.type:s.node(i+1).type)}function tS(e,t){let n=e.resolve(t),r=n.index();return tC(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function tC(e,t){return!!(e&&t&&!e.isLeaf&&function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let s=0;s<t.childCount;s++){let i=t.child(s),o=i.type==r?e.type.schema.nodes.text:i.type;if(!(n=n.matchType(o))||!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function tM(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let s,i,o=r.index(e);if(e==r.depth?(s=r.nodeBefore,i=r.nodeAfter):n>0?(s=r.node(e+1),o++,i=r.node(e).maybeChild(o)):(s=r.node(e).maybeChild(o-1),i=r.node(e+1)),s&&!s.isTextblock&&tC(s,i)&&r.node(e).canReplace(o,o+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function tN(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let e=0;e<n.openStart;e++)s=s.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+ +(n>0),o=r.node(t),a=!1;if(1==e)a=o.canReplace(i,i,s);else{let e=o.contentMatchAt(i).findWrapping(s.firstChild.type);a=e&&o.canReplaceWith(i,i,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function tT(e,t,n=t,r=ek.empty){if(t==n&&!r.size)return null;let s=e.resolve(t),i=e.resolve(n);return tj(s,i,r)?new tp(t,n,r):new tO(s,i,r).fit()}function tj(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}to.jsonID("replaceAround",tf);class tO{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=eg.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=eg.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let s=this.placed,i=n.depth,o=r.depth;for(;i&&o&&1==s.childCount;)s=s.firstChild.content,i--,o--;let a=new ek(s,i,o);return e>-1?new tf(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new tp(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e=null,r=(n?(e=tI(this.unplaced.content,n-1).firstChild).content:this.unplaced.content).firstChild;for(let s=this.depth;s>=0;s--){let{type:i,match:o}=this.frontier[s],a,l=null;if(1==t&&(r?o.matchType(r.type)||(l=o.fillBefore(eg.from(r),!1)):e&&i.compatibleContent(e.type)))return{sliceDepth:n,frontierDepth:s,parent:e,inject:l};if(2==t&&r&&(a=o.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:s,parent:e,wrap:a};if(e&&o.matchType(e.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=tI(e,t);return!!r.childCount&&!r.firstChild.isLeaf&&(this.unplaced=new ek(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=tI(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new ek(tE(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new ek(tE(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let e=0;e<s.length;e++)this.openFrontierNode(s[e]);let i=this.unplaced,o=n?n.content:i.content,a=i.openStart-e,l=0,d=[],{match:c,type:h}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)d.push(r.child(e));c=c.matchFragment(r)}let u=o.size+e-(i.content.size-i.openEnd);for(;l<o.childCount;){let e=o.child(l),t=c.matchType(e.type);if(!t)break;(++l>1||0==a||e.content.size)&&(c=t,d.push(function e(t,n,r){if(n<=0)return t;let s=t.content;return n>1&&(s=s.replaceChild(0,e(s.firstChild,n-1,1==s.childCount?r-1:0))),n>0&&(s=t.type.contentMatch.fillBefore(s).append(s),r<=0&&(s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(eg.empty,!0)))),t.copy(s)}(e.mark(h.allowedMarks(e.marks)),1==l?a:0,l==o.childCount?u:-1)))}let p=l==o.childCount;p||(u=-1),this.placed=tA(this.placed,t,eg.from(d)),this.frontier[t].match=c,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<u;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?ek.empty:new ek(tE(i.content,e-1,1),e-1,u<0?i.openEnd:e-1):new ek(tE(i.content,e,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return -1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!tD(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return -1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){t:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=tD(e,t,r,n,s);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],s=tD(e,n,r,t,!0);if(!s||s.childCount)continue t}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=tA(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=tA(this.placed,this.depth,eg.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(eg.empty,!0);e.childCount&&(this.placed=tA(this.placed,this.frontier.length,e))}}function tE(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(tE(e.firstChild.content,t-1,n)))}function tA(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(tA(e.lastChild.content,t-1,n)))}function tI(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function tD(e,t,n,r,s){let i=e.node(t),o=s?e.indexAfter(t):e.index(t);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,o);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,o)?a:null}function tR(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let s=r;s>=0;s--){let r=e.start(s);if(r<e.pos-(e.depth-s)||t.end(s)>t.pos+(t.depth-s)||e.node(s).type.spec.isolating||t.node(s).type.spec.isolating)break;(r==t.start(s)||s==e.depth&&s==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&s&&t.start(s-1)==r-1)&&n.push(s)}return n}class tP extends to{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return ta.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return ta.fromReplace(e,this.pos,this.pos+1,new ek(eg.from(r),0,+!t.isLeaf))}getMap(){return tr.empty}invert(e){return new tP(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tP(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new tP(t.pos,t.attr,t.value)}}to.jsonID("attr",tP);class tz extends to{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return ta.ok(n)}getMap(){return tr.empty}invert(e){return new tz(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new tz(t.attr,t.value)}}to.jsonID("docAttr",tz);let t$=class extends Error{};(t$=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype),t$.prototype.constructor=t$,t$.prototype.name="TransformError";class tL{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ts}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new t$(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,s,i)=>{e=Math.min(e,s),t=Math.max(t,i)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=ek.empty){let r=tT(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new ek(eg.from(n),0,0))}delete(e,t){return this.replace(e,t,ek.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return!function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let s=e.doc.resolve(t),i=e.doc.resolve(n);if(tj(s,i,r))return e.step(new tp(t,n,r));let o=tR(s,i);0==o[o.length-1]&&o.pop();let a=-(s.depth+1);o.unshift(a);for(let e=s.depth,t=s.pos-1;e>0;e--,t--){let n=s.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?a=e:s.before(e)==t&&o.splice(1,0,-e)}let l=o.indexOf(a),d=[],c=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(d.push(n),t==r.openStart)break;e=n.content}for(let e=c-1;e>=0;e--){var h;let t=d[e],n=(h=t.type).spec.defining||h.spec.definingForContent;if(n&&!t.sameMarkup(s.node(Math.abs(a)-1)))c=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+c+1)%(r.openStart+1),h=d[a];if(h)for(let t=0;t<o.length;t++){let d=o[(t+l)%o.length],c=!0;d<0&&(c=!1,d=-d);let u=s.node(d-1),p=s.index(d-1);if(u.canReplaceWith(p,p,h.type,h.marks))return e.replace(s.before(d),c?i.after(d):n,new ek(function e(t,n,r,s,i){if(n<r){let i=t.firstChild;t=t.replaceChild(0,i.copy(e(i.content,n+1,r,s,i)))}if(n>s){let e=i.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(eg.empty,!0))}return t}(r.content,0,r.openStart,a),a,r.openEnd))}}let u=e.steps.length;for(let a=o.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>u));a--){let e=o[a];e<0||(t=s.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){var r=e,s=t;if(!n.isInline&&r==s&&this.doc.resolve(r).parent.content.size){let e=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)break}return null}(this.doc,r,n.type);null!=e&&(r=s=e)}return this.replaceRange(r,s,new ek(eg.from(n),0,0)),this}deleteRange(e,t){return!function(e,t,n){let r=e.doc.resolve(t),s=e.doc.resolve(n),i=tR(r,s);for(let t=0;t<i.length;t++){let n=i[t],o=t==i.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),s.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),s.indexAfter(n-1))))return e.delete(r.before(n),s.after(n))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&s.end(i)-n!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return!function(e,t,n){let{$from:r,$to:s,depth:i}=t,o=r.before(i+1),a=s.after(i+1),l=o,d=a,c=eg.empty,h=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,c=eg.from(r.node(e).copy(c)),h++):l--;let u=eg.empty,p=0;for(let e=i,t=!1;e>n;e--)t||s.after(e+1)<s.end(e)?(t=!0,u=eg.from(s.node(e).copy(u)),p++):d++;e.step(new tf(l,d,o,a,new ek(c.append(u),h,p),c.size-h,!0))}(this,e,t),this}join(e,t=1){return!function(e,t,n){let r=null,{linebreakReplacement:s}=e.doc.type.schema,i=e.doc.resolve(t-n),o=i.node().type;if(s&&o.inlineContent){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(s);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);tw(e,r.node(),r.before(),a)}o.inlineContent&&tg(e,t+n-1,o,i.node().contentMatchAt(i.index()),null==r);let l=e.mapping.slice(a),d=l.map(t-n);if(e.step(new tp(d,l.map(t+n,-1),ek.empty,!0)),!0===r){let t=e.doc.resolve(d);tv(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return!function(e,t,n){let r=eg.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=eg.from(n[e].type.create(n[e].attrs,r))}let s=t.start,i=t.end;e.step(new tf(s,i,s,i,new ek(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){var s=this;if(!n.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let i=s.steps.length;return s.doc.nodesBetween(e,t,(e,t)=>{var o,a,l;let d,c,h="function"==typeof r?r(e):r;if(e.isTextblock&&!e.hasMarkup(n,h)&&(o=s.doc,a=s.mapping.slice(i).map(t),l=n,c=(d=o.resolve(a)).index(),d.parent.canReplaceWith(c,c+1,l))){let r=null;if(n.schema.linebreakReplacement){let e="pre"==n.whitespace,t=!!n.contentMatch.matchType(n.schema.linebreakReplacement);e&&!t?r=!1:!e&&t&&(r=!0)}!1===r&&tw(s,e,t,i),tg(s,s.mapping.slice(i).map(t,1),n,void 0,null===r);let o=s.mapping.slice(i),a=o.map(t,1),l=o.map(t+e.nodeSize,1);return s.step(new tf(a,l,a+1,l-1,new ek(eg.from(n.create(h,null,e.marks)),0,0),1,!0)),!0===r&&tv(s,e,t,i),!1}}),this}setNodeMarkup(e,t,n=null,r){return!function(e,t,n,r,s){let i=e.doc.nodeAt(t);if(!i)throw RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,o);if(!n.validContent(i.content))throw RangeError("Invalid content for node type "+n.name);e.step(new tf(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new ek(eg.from(o),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new tP(e,t,n)),this}setDocAttribute(e,t){return this.step(new tz(e,t)),this}addNodeMark(e,t){return this.step(new th(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(t instanceof ev)t.isInSet(n.marks)&&this.step(new tu(e,t));else{let r=n.marks,s,i=[];for(;s=t.isInSet(r);)i.push(new tu(e,s)),r=s.removeFromSet(r);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return!function(e,t,n=1,r){let s=e.doc.resolve(t),i=eg.empty,o=eg.empty;for(let e=s.depth,t=s.depth-n,a=n-1;e>t;e--,a--){i=eg.from(s.node(e).copy(i));let t=r&&r[a];o=eg.from(t?t.type.create(t.attrs,o):s.node(e).copy(o))}e.step(new tp(t,t,new ek(i.append(o),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){var r;let s,i,o,a;return r=this,o=[],a=[],r.doc.nodesBetween(e,t,(r,l,d)=>{if(!r.isInline)return;let c=r.marks;if(!n.isInSet(c)&&d.type.allowsMarkType(n.type)){let d=Math.max(l,e),h=Math.min(l+r.nodeSize,t),u=n.addToSet(c);for(let e=0;e<c.length;e++)c[e].isInSet(u)||(s&&s.to==d&&s.mark.eq(c[e])?s.to=h:o.push(s=new tc(d,h,c[e])));i&&i.to==d?i.to=h:a.push(i=new td(d,h,n))}}),o.forEach(e=>r.step(e)),a.forEach(e=>r.step(e)),this}removeMark(e,t,n){var r;let s,i;return r=this,s=[],i=0,r.doc.nodesBetween(e,t,(r,o)=>{if(!r.isInline)return;i++;let a=null;if(n instanceof eG){let e=r.marks,t;for(;t=n.isInSet(e);)(a||(a=[])).push(t),e=t.removeFromSet(e)}else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length){let n=Math.min(o+r.nodeSize,t);for(let t=0;t<a.length;t++){let r=a[t],l;for(let e=0;e<s.length;e++){let t=s[e];t.step==i-1&&r.eq(s[e].style)&&(l=t)}l?(l.to=n,l.step=i):s.push({style:r,from:Math.max(o,e),to:n,step:i})}}}),s.forEach(e=>r.step(new tc(e.from,e.to,e.style))),this}clearIncompatible(e,t,n){return tg(this,e,t,n),this}}let tB=Object.create(null);class tV{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new tF(e.min(t),e.max(t))]}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 e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=ek.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let s=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:a,$to:l}=i[o],d=e.mapping.slice(s);e.replaceRange(d.map(a.pos),d.map(l.pos),o?ek.empty:t),0==o&&tY(e,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:i,$to:o}=r[s],a=e.mapping.slice(n),l=a.map(i.pos),d=a.map(o.pos);s?e.deleteRange(l,d):(e.replaceRangeWith(l,d,t),tY(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new tU(e):tX(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let s=t<0?tX(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):tX(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new tJ(e.node(0))}static atStart(e){return tX(e,e,0,0,1)||new tJ(e)}static atEnd(e){return tX(e,e,e.content.size,e.childCount,-1)||new tJ(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError("Invalid input for Selection.fromJSON");let n=tB[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in tB)throw RangeError("Duplicate use of selection JSON ID "+e);return tB[e]=t,t.prototype.jsonID=e,t}getBookmark(){return tU.between(this.$anchor,this.$head).getBookmark()}}tV.prototype.visible=!0;class tF{constructor(e,t){this.$from=e,this.$to=t}}let t_=!1;function tH(e){t_||e.parent.inlineContent||(t_=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class tU extends tV{constructor(e,t=e){tH(e),tH(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return tV.near(n);let r=e.resolve(t.map(this.anchor));return new tU(r.parent.inlineContent?r:n,n)}replace(e,t=ek.empty){if(super.replace(e,t),t==ek.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof tU&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new tW(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new tU(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if((!n||r)&&(n=r>=0?1:-1),!t.parent.inlineContent){let e=tV.findFrom(t,n,!0)||tV.findFrom(t,-n,!0);if(!e)return tV.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r?e=t:(e=(tV.findFrom(e,-n,!0)||tV.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0&&(e=t)),new tU(e,t)}}tV.jsonID("text",tU);class tW{constructor(e,t){this.anchor=e,this.head=t}map(e){return new tW(e.map(this.anchor),e.map(this.head))}resolve(e){return tU.between(e.resolve(this.anchor),e.resolve(this.head))}}class tq extends tV{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return n?tV.near(s):new tq(s)}content(){return new ek(eg.from(this.node),0,0)}eq(e){return e instanceof tq&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new tK(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw RangeError("Invalid input for NodeSelection.fromJSON");return new tq(e.resolve(t.anchor))}static create(e,t){return new tq(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}tq.prototype.visible=!1,tV.jsonID("node",tq);class tK{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new tW(n,n):new tK(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&tq.isSelectable(n)?new tq(t):tV.near(t)}}class tJ extends tV{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=ek.empty){if(t==ek.empty){e.delete(0,e.doc.content.size);let t=tV.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new tJ(e)}map(e){return new tJ(e)}eq(e){return e instanceof tJ}getBookmark(){return tG}}tV.jsonID("all",tJ);let tG={map(){return this},resolve:e=>new tJ(e)};function tX(e,t,n,r,s,i=!1){if(t.inlineContent)return tU.create(e,n);for(let o=r-(s>0?0:1);s>0?o<t.childCount:o>=0;o+=s){let r=t.child(o);if(r.isAtom){if(!i&&tq.isSelectable(r))return tq.create(e,n-(s<0?r.nodeSize:0))}else{let t=tX(e,r,n+s,s<0?r.childCount:0,s,i);if(t)return t}n+=r.nodeSize*s}return null}function tY(e,t,n){let r,s=e.steps.length-1;if(s<t)return;let i=e.steps[s];(i instanceof tp||i instanceof tf)&&(e.mapping.maps[s].forEach((e,t,n,s)=>{null==r&&(r=s)}),e.setSelection(tV.near(e.doc.resolve(r),n)))}class tQ extends tL{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.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(e){if(e.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(1|this.updated)&-3,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return ev.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||ev.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let e=this.doc.resolve(t);s=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,s)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(tV.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function tZ(e,t){return t&&e?e.bind(t):e}class t0{constructor(e,t,n){this.name=e,this.init=tZ(t.init,n),this.apply=tZ(t.apply,n)}}let t1=[new t0("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new t0("selection",{init:(e,t)=>e.selection||tV.atStart(t.doc),apply:e=>e.selection}),new t0("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new t0("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class t2{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=t1.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new t0(e.key,e.spec.state,e))})}}class t3{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let o=this.config.plugins[i];if(o.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[i].state:this,d=a<t.length&&o.spec.appendTransaction.call(o,a?t.slice(a):t,l,n);if(d&&n.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(d),n=n.applyInner(d),s=!0}r&&(r[i]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let t=new t3(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let s=n[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new tQ(this)}static create(e){let t=new t2(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new t3(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new t2(this.schema,e.plugins),n=t.fields,r=new t3(t);for(let t=0;t<n.length;t++){let s=n[t].name;r[s]=this.hasOwnProperty(s)?this[s]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],s=r.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let r=new t2(e.schema,e.plugins),s=new t3(r);return r.fields.forEach(r=>{if("doc"==r.name)s.doc=eP.fromJSON(e.schema,t.doc);else if("selection"==r.name)s.selection=tV.fromJSON(s.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let o=n[i],a=o.spec.state;if(o.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i)){s[r.name]=a.fromJSON.call(o,e,t[i],s);return}}s[r.name]=r.init(e,s)}}),s}}class t5{constructor(e){this.spec=e,this.props={},e.props&&function e(t,n,r){for(let s in t){let i=t[s];i instanceof Function?i=i.bind(n):"handleDOMEvents"==s&&(i=e(i,n,{})),r[s]=i}return r}(e.props,this,this.props),this.key=e.key?e.key.key:t6("plugin")}getState(e){return e[this.key]}}let t4=Object.create(null);function t6(e){return e in t4?e+"$"+ ++t4[e]:(t4[e]=0,e+"$")}class t8{constructor(e="key"){this.key=t6(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}let t7=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function t9(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("backward",e):!(n.parentOffset>0))?n:null}let ne=(e,t,n)=>{let r=t9(e,n);if(!r)return!1;let s=ns(r);if(!s){let n=r.blockRange(),s=n&&tx(n);return null!=s&&(t&&t(e.tr.lift(n,s).scrollIntoView()),!0)}let i=s.nodeBefore;if(nf(e,s,t,-1))return!0;if(0==r.parent.content.size&&(nn(i,"end")||tq.isSelectable(i)))for(let n=r.depth;;n--){let o=tT(e.doc,r.before(n),r.after(n),ek.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(nn(i,"end")?tV.findFrom(n.doc.resolve(n.mapping.map(s.pos,-1)),-1):tq.create(n.doc,s.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!!i.isAtom&&s.depth==r.depth-1&&(t&&t(e.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0)};function nt(e,t,n){let r=t.nodeBefore,s=t.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let i=t.nodeAfter,o=t.pos+1;for(;!i.isTextblock;o++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let a=tT(e.doc,s,o,ek.empty);if(!a||a.from!=s||a instanceof tp&&a.slice.size>=o-s)return!1;if(n){let t=e.tr.step(a);t.setSelection(tU.create(t.doc,s)),n(t.scrollIntoView())}return!0}function nn(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)break}return!1}let nr=(e,t,n)=>{let{$head:r,empty:s}=e.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=ns(r)}let o=i&&i.nodeBefore;return!!o&&!!tq.isSelectable(o)&&(t&&t(e.tr.setSelection(tq.create(e.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function ns(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ni(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("forward",e):!(n.parentOffset<n.parent.content.size))?n:null}let no=(e,t,n)=>{let r=ni(e,n);if(!r)return!1;let s=nl(r);if(!s)return!1;let i=s.nodeAfter;if(nf(e,s,t,1))return!0;if(0==r.parent.content.size&&(nn(i,"start")||tq.isSelectable(i))){let n=tT(e.doc,r.before(),r.after(),ek.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(nn(i,"start")?tV.findFrom(r.doc.resolve(r.mapping.map(s.pos)),1):tq.create(r.doc,r.mapping.map(s.pos))),t(r.scrollIntoView())}return!0}}return!!i.isAtom&&s.depth==r.depth-1&&(t&&t(e.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0)},na=(e,t,n)=>{let{$head:r,empty:s}=e.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=nl(r)}let o=i&&i.nodeAfter;return!!o&&!!tq.isSelectable(o)&&(t&&t(e.tr.setSelection(tq.create(e.doc,i.pos)).scrollIntoView()),!0)};function nl(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}let nd=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!!n.parent.type.spec.code&&!!n.sameParent(r)&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function nc(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}let nh=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=nc(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(t){let r=n.after(),s=e.tr.replaceWith(r,r,o.createAndFill());s.setSelection(tV.near(s.doc.resolve(r),1)),t(s.scrollIntoView())}return!0},nu=(e,t)=>{let n=e.selection,{$from:r,$to:s}=n;if(n instanceof tJ||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=nc(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,o=e.tr.insert(n,i.createAndFill());o.setSelection(tU.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},np=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(tk(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),s=r&&tx(r);return null!=s&&(t&&t(e.tr.lift(r,s).scrollIntoView()),!0)};function nf(e,t,n,r){let s,i,o,a=t.nodeBefore,l=t.nodeAfter,d,c,h=a.type.spec.isolating||l.type.spec.isolating;if(!h&&(s=t.nodeBefore,i=t.nodeAfter,o=t.index(),s&&i&&s.type.compatibleContent(i.type)&&(!s.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-s.nodeSize,t.pos).scrollIntoView()),!0):!!t.parent.canReplace(o,o+1)&&!!(i.isTextblock||tS(e.doc,t.pos))&&(n&&n(e.tr.join(t.pos).scrollIntoView()),!0))))return!0;let u=!h&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(d=(c=a.contentMatchAt(a.childCount)).findWrapping(l.type))&&c.matchType(d[0]||l.type).validEnd){if(n){let r=t.pos+l.nodeSize,s=eg.empty;for(let e=d.length-1;e>=0;e--)s=eg.from(d[e].create(null,s));s=eg.from(a.copy(s));let i=e.tr.step(new tf(t.pos-1,r,t.pos,r,new ek(s,1,0),d.length,!0)),o=i.doc.resolve(r+2*d.length);o.nodeAfter&&o.nodeAfter.type==a.type&&tS(i.doc,o.pos)&&i.join(o.pos),n(i.scrollIntoView())}return!0}let p=l.type.spec.isolating||r>0&&h?null:tV.findFrom(t,1),f=p&&p.$from.blockRange(p.$to),m=f&&tx(f);if(null!=m&&m>=t.depth)return n&&n(e.tr.lift(f,m).scrollIntoView()),!0;if(u&&nn(l,"start",!0)&&nn(a,"end")){let r=a,s=[];for(;s.push(r),!r.isTextblock;)r=r.lastChild;let i=l,o=1;for(;!i.isTextblock;i=i.firstChild)o++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=eg.empty;for(let e=s.length-1;e>=0;e--)r=eg.from(s[e].copy(r));n(e.tr.step(new tf(t.pos-s.length,t.pos+l.nodeSize,t.pos+o,t.pos+l.nodeSize-o,new ek(r,s.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function nm(e){return function(t,n){let r=t.selection,s=e<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return!!s.node(i).isTextblock&&(n&&n(t.tr.setSelection(tU.create(t.doc,e<0?s.start(i):s.end(i)))),!0)}}let ng=nm(-1),nx=nm(1);function ny(e,t=null){return function(n,r){let s=!1;for(let r=0;r<n.selection.ranges.length&&!s;r++){let{$from:{pos:i},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(i,o,(r,i)=>{if(s)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)s=!0;else{let t=n.doc.resolve(i),r=t.index();s=t.parent.canReplaceWith(r,r+1,e)}})}if(!s)return!1;if(r){let s=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:o}}=n.selection.ranges[r];s.setBlockType(i,o,e,t)}r(s.scrollIntoView())}return!0}}function nb(...e){return function(t,n,r){for(let s=0;s<e.length;s++)if(e[s](t,n,r))return!0;return!1}}let nv=nb(t7,ne,nr),nw=nb(t7,no,na),nk={Enter:nb(nd,nu,np,(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof tq&&e.selection.node.isBlock)return!!n.parentOffset&&!!tk(e.doc,n.pos)&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],i,o,a=!1,l=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){let t;a=n.end(e)==n.pos+(n.depth-e),l=n.start(e)==n.pos-(n.depth-e),o=nc(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));s.unshift(t||(a&&o?{type:o}:null)),i=e;break}if(1==e)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof tU||e.selection instanceof tJ)&&d.deleteSelection();let c=d.mapping.map(n.pos),h=tk(d.doc,c,s.length,s);if(h||(s[0]=o?{type:o}:null,h=tk(d.doc,c,s.length,s)),!h)return!1;if(d.split(c,s.length,s),!a&&l&&n.node(i).type!=o){let e=d.mapping.map(n.before(i)),t=d.doc.resolve(e);o&&n.node(i-1).canReplaceWith(t.index(),t.index()+1,o)&&d.setNodeMarkup(d.mapping.map(n.before(i)),o)}return t&&t(d.scrollIntoView()),!0}),"Mod-Enter":nh,Backspace:nv,"Mod-Backspace":nv,"Shift-Backspace":nv,Delete:nw,"Mod-Delete":nw,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new tJ(e.doc))),!0)},nS={"Ctrl-h":nk.Backspace,"Alt-Backspace":nk["Mod-Backspace"],"Ctrl-d":nk.Delete,"Ctrl-Alt-Backspace":nk["Mod-Delete"],"Alt-Delete":nk["Mod-Delete"],"Alt-d":nk["Mod-Delete"],"Ctrl-a":ng,"Ctrl-e":nx};for(let e in nk)nS[e]=nk[e];"u">typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"u">typeof os&&os.platform&&os.platform();let nC=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},nM=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},nN=null,nT=function(e,t,n){let r=nN||(nN=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},nj=function(){nN=null},nO=function(e,t,n,r){return n&&(nA(e,t,n,r,-1)||nA(e,t,n,r,1))},nE=/^(img|br|input|textarea|hr)$/i;function nA(e,t,n,r,s){for(var i;;){if(e==n&&t==r)return!0;if(t==(s<0?0:nI(e))){let n=e.parentNode;if(!n||1!=n.nodeType||nD(e)||nE.test(e.nodeName)||"false"==e.contentEditable)return!1;t=nC(e)+(s<0?0:1),e=n}else{if(1!=e.nodeType)return!1;let n=e.childNodes[t+(s<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable)if(null==(i=n.pmViewDesc)||!i.ignoreForSelection)return!1;else t+=s;else e=n,t=s<0?nI(e):0}}}function nI(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function nD(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}let nR=function(e){return e.focusNode&&nO(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function nP(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}let nz="u">typeof navigator?navigator:null,n$="u">typeof document?document:null,nL=nz&&nz.userAgent||"",nB=/Edge\/(\d+)/.exec(nL),nV=/MSIE \d/.exec(nL),nF=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nL),n_=!!(nV||nF||nB),nH=nV?document.documentMode:nF?+nF[1]:nB?+nB[1]:0,nU=!n_&&/gecko\/(\d+)/i.test(nL);nU&&(/Firefox\/(\d+)/.exec(nL)||[0,0])[1];let nW=!n_&&/Chrome\/(\d+)/.exec(nL),nq=!!nW,nK=nW?+nW[1]:0,nJ=!n_&&!!nz&&/Apple Computer/.test(nz.vendor),nG=nJ&&(/Mobile\/\w+/.test(nL)||!!nz&&nz.maxTouchPoints>2),nX=nG||!!nz&&/Mac/.test(nz.platform),nY=!!nz&&/Win/.test(nz.platform),nQ=/Android \d/.test(nL),nZ=!!n$&&"webkitFontSmoothing"in n$.documentElement.style,n0=nZ?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function n1(e,t){return"number"==typeof e?e:e[t]}function n2(e,t,n){let r=e.someProp("scrollThreshold")||0,s=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(1!=o.nodeType){o=nM(o);continue}let e=o,n=e==i.body,a=n?function(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}(i):function(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}(e),l=0,d=0;if(t.top<a.top+n1(r,"top")?d=-(a.top-t.top+n1(s,"top")):t.bottom>a.bottom-n1(r,"bottom")&&(d=t.bottom-t.top>a.bottom-a.top?t.top+n1(s,"top")-a.top:t.bottom-a.bottom+n1(s,"bottom")),t.left<a.left+n1(r,"left")?l=-(a.left-t.left+n1(s,"left")):t.right>a.right-n1(r,"right")&&(l=t.right-a.right+n1(s,"right")),l||d)if(n)i.defaultView.scrollBy(l,d);else{let n=e.scrollLeft,r=e.scrollTop;d&&(e.scrollTop+=d),l&&(e.scrollLeft+=l);let s=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-s,top:t.top-i,right:t.right-s,bottom:t.bottom-i}}let c=n?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(c))break;o="absolute"==c?o.offsetParent:nM(o)}}function n3(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=nM(r));return t}function n5(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:s,left:i}=e[n];r.scrollTop!=s+t&&(r.scrollTop=s+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let n4=null;function n6(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function n8(e){return e.top<e.bottom||e.left<e.right}function n7(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(n8(e))return e}return Array.prototype.find.call(n,n8)||e.getBoundingClientRect()}let n9=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function re(e,t,n){let{node:r,offset:s,atom:i}=e.docView.domFromPos(t,n<0?-1:1),o=nZ||nU;if(3==r.nodeType)if(o&&(n9.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let e=n7(nT(r,s,s),n);if(nU&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let t=n7(nT(r,s-1,s-1),-1);if(t.top==e.top){let n=n7(nT(r,s,s+1),-1);if(n.top!=e.top)return rt(n,n.left<t.left)}}return e}else{let e=s,t=s,i=n<0?1:-1;return n<0&&!s?(t++,i=-1):n>=0&&s==r.nodeValue.length?(e--,i=1):n<0?e--:t++,rt(n7(nT(r,e,t),i),i<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&s&&(n<0||s==nI(r))){let e=r.childNodes[s-1];if(1==e.nodeType)return rn(e.getBoundingClientRect(),!1)}if(null==i&&s<nI(r)){let e=r.childNodes[s];if(1==e.nodeType)return rn(e.getBoundingClientRect(),!0)}return rn(r.getBoundingClientRect(),n>=0)}if(null==i&&s&&(n<0||s==nI(r))){let e=r.childNodes[s-1],t=3==e.nodeType?nT(e,nI(e)-!o):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return rt(n7(t,1),!1)}if(null==i&&s<nI(r)){let e=r.childNodes[s];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?nT(e,0,+!o):1==e.nodeType?e:null:null;if(t)return rt(n7(t,-1),!0)}return rt(n7(3==r.nodeType?nT(r):r,-n),n>=0)}function rt(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function rn(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function rr(e,t,n){let r=e.state,s=e.root.activeElement;r!=t&&e.updateState(t),s!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),s!=e.dom&&s&&s.focus()}}let rs=/[\u0590-\u08ac]/,ri=null,ro=null,ra=!1;class rl{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.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(e,t,n){let r;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}if(e==this.dom&&this.contentDOM)r=t>nC(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),i;if(s&&(!t||s.node))if(!n||!(i=s.nodeDOM)||(1==i.nodeType?i.contains(1==e.nodeType?e:e.parentNode):i==e))return s;else n=!1}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,n)}return -1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],s=n+r.size;if(n==e&&s!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<s)return r.descAt(e-n-r.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let s=this.children[n],i=t+s.size;if(i>e||s instanceof rm){r=e-t;break}t=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof rd&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;(e=n?this.children[n-1]:null)&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?nC(e.dom)+1:0}}{let e,r=!0;for(;(e=n<this.children.length?this.children[n]:null)&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?nC(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let i=n,o=0;;o++){let n=this.children[o],a=i+n.size;if(-1==r&&e<=a){let s=i+n.border;if(e>=s&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,s);e=i;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=nC(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||o==this.children.length-1)){t=a;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){s=nC(n.dom);break}t+=n.size}-1==s&&(s=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let o=0,a=0;o<this.children.length;o++){let l=this.children[o],d=a+l.size;if(s>a&&i<d)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=d}let o=this.domFromPos(e,e?-1:1),a=t==e?o:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),d=n.domSelectionRange(),c=!1;if((nU||nJ)&&e==t){let{node:e,offset:t}=o;if(3==e.nodeType){if((c=!!(t&&"\n"==e.nodeValue[t-1]))&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){"BR"==n.nodeName&&(o=a={node:n.parentNode,offset:nC(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(nU&&d.focusNode&&d.focusNode!=a.node&&1==d.focusNode.nodeType){let e=d.focusNode.childNodes[d.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||c&&nJ)&&nO(o.node,o.offset,d.anchorNode,d.anchorOffset)&&nO(a.node,a.offset,d.focusNode,d.focusOffset))return;let h=!1;if((l.extend||e==t)&&!(c&&nU)){l.collapse(o.node,o.offset);try{e!=t&&l.extend(a.node,a.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=o;o=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let s=this.children[r],i=n+s.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+s.border,o=i-s.border;if(e>=r&&t<=o){this.dirty=e==n||t==i?2:1,e==r&&t==o&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=3:s.markDirty(e-r,t-r);return}s.dirty=s.dom!=s.contentDOM||s.dom.parentNode!=this.contentDOM||s.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class rd extends rl{constructor(e,t,n,r){let s,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:r)),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.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 rc extends rl{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class rh extends rl{constructor(e,t,n,r,s){super(e,[],n,r),this.mark=t,this.spec=s}static create(e,t,n,r){let s=r.nodeViews[t.type.name],i=s&&s(t,r,n);return i&&i.dom||(i=e8.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new rh(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=rh.create(this.parent,this.mark,!0,n),s=this.children,i=this.size;t<i&&(s=rN(s,t,i,n)),e>0&&(s=rN(s,0,e,n));for(let e=0;e<s.length;e++)s[e].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ru extends rl{constructor(e,t,n,r,s,i,o,a,l){super(e,[],s,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(e,t,n,r,s,i){let o=s.nodeViews[t.type.name],a,l=o&&o(t,s,()=>a?a.parent?a.parent.posBeforeChild(a):void 0:i,n,r),d=l&&l.dom,c=l&&l.contentDOM;if(t.isText)if(d){if(3!=d.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else d=document.createTextNode(t.text);else if(!d){let e=e8.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:d,contentDOM:c}=e)}c||t.isText||"BR"==d.nodeName||(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return(d=rw(d,n,t),l)?a=new rg(e,t,n,r,d,c||null,h,l,s,i+1):t.isText?new rf(e,t,n,r,d,h,s):new ru(e,t,n,r,d,c||null,h,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>eg.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&rk(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,o=s&&s.pos<0,a=new rC(this,i&&i.node,e);(function(e,t,n,r){let s=t.locals(e),i=0;if(0==s.length){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,s,t.forChild(i,o),n),i+=o.nodeSize}return}let o=0,a=[],l=null;for(let d=0;;){let c,h,u,p;for(;o<s.length&&s[o].to==i;){let e=s[o++];e.widget&&(c?(h||(h=[c])).push(e):c=e)}if(c)if(h){h.sort(rM);for(let e=0;e<h.length;e++)n(h[e],d,!!l)}else n(c,d,!!l);if(l)p=-1,u=l,l=null;else if(d<e.childCount)p=d,u=e.child(d++);else break;for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)a.push(s[o++]);let f=i+u.nodeSize;if(u.isText){let e=f;o<s.length&&s[o].from<e&&(e=s[o].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=u.cut(e-i),u=u.cut(0,e-i),f=e,p=-1)}else for(;o<s.length&&s[o].to<f;)o++;let m=u.isInline&&!u.isLeaf?a.filter(e=>!e.inline):a.slice();r(u,m,t.forChild(i,u),p),i=f}})(this.node,this.innerDeco,(t,s,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,s):t.type.side>=0&&!i&&a.syncToMarks(s==this.node.childCount?ev.none:this.node.child(s).marks,n,e,s),a.placeWidget(t,e,r)},(t,i,l,d)=>{let c;a.syncToMarks(t.marks,n,e,d),a.findNodeMatch(t,i,l,d)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(c=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(t,i,l,c,e)||a.updateNextNode(t,i,l,e,d,r)||a.addNode(t,i,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),function e(t,n,r){let s=t.firstChild,i=!1;for(let o=0;o<n.length;o++){let a=n[o],l=a.dom;if(l.parentNode==t){for(;l!=s;)s=rS(s),i=!0;s=s.nextSibling}else i=!0,t.insertBefore(l,s);if(a instanceof rh){let n=s?s.previousSibling:t.lastChild;e(a.contentDOM,a.children,r),s=n?n.nextSibling:t.firstChild}}for(;s;)s=rS(s),i=!0;i&&r.trackWrites==t&&(r.trackWrites=null)}(this.contentDOM,this.children,e),nG&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof tU)||n<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(!this.node.inlineContent)return{node:s,pos:-1,text:""};{let e=s.nodeValue,i=function(e,t,n,r){for(let s=0,i=0;s<e.childCount&&i<=r;){let o=e.child(s++),a=i;if(i+=o.nodeSize,!o.isText)continue;let l=o.text;for(;s<e.childCount;){let t=e.child(s++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return -1}(this.node.content,e,n-t,r-t);return i<0?null:{node:s,pos:i,text:e}}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new rc(this,s,t,r);e.input.compositionNodes.push(i),this.children=rN(this.children,n,n+r.length,e,i)}update(e,t,n,r){return 3!=this.dirty&&!!e.sameMarkup(this.node)&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(rk(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=rv(this.dom,this.nodeDOM,rb(this.outerDeco,this.node,t),rb(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}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 rp(e,t,n,r,s){rw(r,t,e);let i=new ru(void 0,e,t,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class rf extends ru{constructor(e,t,n,r,s,i,o){super(e,t,n,r,s,null,i,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return 3!=this.dirty&&(0==this.dirty||!!this.inParent())&&!!e.sameMarkup(this.node)&&(this.updateOuterDeco(t),(0!=this.dirty||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new rf(this.parent,r,this.outerDeco,this.innerDeco,s,s,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(0==e||t==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class rm extends rl{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class rg extends ru{constructor(e,t,n,r,s,i,o,a,l,d){super(e,t,n,r,s,i,o,l,d),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,r),s}return(!!this.contentDOM||!!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}let rx=function(e){e&&(this.nodeName=e)};rx.prototype=Object.create(null);let ry=[new rx];function rb(e,t,n){if(0==e.length)return ry;let r=n?ry[0]:new rx,s=[r];for(let i=0;i<e.length;i++){let o=e[i].type.attrs;if(o)for(let e in o.nodeName&&s.push(r=new rx(o.nodeName)),o){let i=o[e];null!=i&&(n&&1==s.length&&s.push(r=new rx(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}return s}function rv(e,t,n,r){if(n==ry&&r==ry)return t;let s=t;for(let t=0;t<r.length;t++){let i=r[t],o=n[t];if(t){let t;o&&o.nodeName==i.nodeName&&s!=e&&(t=s.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||((t=document.createElement(i.nodeName)).pmIsDeco=!0,t.appendChild(s),o=ry[0]),s=t}!function(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==s.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<s.length;t++)-1==r.indexOf(s[t])&&e.classList.add(s[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}(s,o||ry[0],i)}return s}function rw(e,t,n){return rv(e,e,ry,rb(t,n,1!=e.nodeType))}function rk(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function rS(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class rC{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,s=e.childCount,i=new Map,o=[];n:for(;s>0;){let a;for(;;)if(r){let e=n.children[r-1];if(e instanceof rh)n=e,r=e.children.length;else{a=e,r--;break}}else if(n==t)break n;else r=n.parent.children.indexOf(n),n=n.parent;let l=a.node;if(l){if(l!=e.child(s-1))break;--s,i.set(a,s),o.push(a)}}return{index:s,matched:i,matches:o.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&!1!==e[s].type.spec.spanning;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let s=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[i])&&!this.isLocked(n.dom)){s=t;break}}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{let r=rh.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let s=-1,i;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,n))s=this.top.children.indexOf(i,this.index);else for(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(e,t,n)&&!this.preMatch.matched.has(i)){s=r;break}}return!(s<0)&&(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,r,s){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,s)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return -1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return -1}e=t}}updateNextNode(e,t,n,r,s,i){for(let o=this.index;o<this.top.children.length;o++){let a=this.top.children[o];if(a instanceof ru){let l=this.preMatch.matched.get(a);if(null!=l&&l!=s)return!1;let d=a.dom,c,h=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&rk(t,a.outerDeco));if(!h&&a.update(e,t,n,r))return this.destroyBetween(this.index,o),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(a,e,t,n,r,i)))return this.destroyBetween(this.index,o),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!rk(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=ru.create(this.top,t,n,r,s,i);if(o.contentDOM)for(let t of(o.children=e.children,e.children=[],o.children))t.parent=o;return e.destroy(),o}addNode(e,t,n,r,s){let i=ru.create(this.top,e,t,n,r,s);i.contentDOM&&i.updateChildren(r,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new rd(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof rh;)e=(t=e).children[t.children.length-1];(!e||!(e instanceof rf)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((nJ||nq)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new rm(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function rM(e,t){return e.type.side-t.type.side}function rN(e,t,n,r,s){let i=[];for(let o=0,a=0;o<e.length;o++){let l=e[o],d=a,c=a+=l.size;d>=n||c<=t?i.push(l):(d<t&&i.push(l.slice(0,t-d,r)),s&&(i.push(s),s=void 0),c>n&&i.push(l.slice(n-d,l.size,r)))}return i}function rT(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),i=s&&0==s.size,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,d;if(nR(n)){for(l=o;s&&!s.node;)s=s.parent;let e=s.node;if(s&&e.isAtom&&tq.isSelectable(e)&&s.parent&&!(e.isInline&&function(e,t,n){for(let r=0==t,s=t==nI(e);r||s;){if(e==n)return!0;let t=nC(e);if(!(e=e.parentNode))return!1;r=r&&0==t,s=s&&t==nI(e)}}(n.focusNode,n.focusOffset,s.dom))){let e=s.posBefore;d=new tq(o==e?a:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,s=o;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),s=Math.max(s,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,o]=s==e.state.selection.anchor?[s,t]:[t,s],a=r.resolve(o)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let c=r.resolve(l);if(!d){let n="pointer"==t||e.state.selection.head<a.pos&&!i?1:-1;d=rz(e,c,a,n)}return d}function rj(e){return e.editable?e.hasFocus():rL(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function rO(e,t=!1){let n=e.state.selection;if(rR(e,n),rj(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&nq){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&nO(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,nC(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&n_&&nH<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{var r;let s,i,o,a,{anchor:l,head:d}=n,c,h;rE&&!(n instanceof tU)&&(n.$from.parent.inlineContent||(c=rA(e,n.from)),n.empty||n.$from.parent.inlineContent||(h=rA(e,n.to))),e.docView.setSelection(l,d,e,t),rE&&(c&&rD(c),h&&rD(h)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&((s=(r=e).dom.ownerDocument).removeEventListener("selectionchange",r.input.hideSelectionGuard),o=(i=r.domSelectionRange()).anchorNode,a=i.anchorOffset,s.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(i.anchorNode!=o||i.anchorOffset!=a)&&(s.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!rj(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}let rE=nJ||nq&&nK<63;function rA(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(nJ&&s&&"false"==s.contentEditable)return rI(s);if((!s||"false"==s.contentEditable)&&(!i||"false"==i.contentEditable)){if(s)return rI(s);else if(i)return rI(i)}}function rI(e){return e.contentEditable="true",nJ&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function rD(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function rR(e,t){if(t instanceof tq){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(rP(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else rP(e)}function rP(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function rz(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||tU.between(t,n,r)}function r$(e){return(!e.editable||!!e.hasFocus())&&rL(e)}function rL(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function rB(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return i&&tV.findFrom(i,t)}function rV(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function rF(e,t,n){let r=e.state.selection;if(r instanceof tU){if(n.indexOf("s")>-1){let{$head:n}=r,s=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+s.nodeSize*(t<0?-1:1));return rV(e,new tU(r.$anchor,i))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?"forward":"backward")){let n=rB(e.state,t);return!!n&&n instanceof tq&&rV(e,n)}else if(!(nX&&n.indexOf("m")>-1)){let n=r.$head,s=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,i;if(!s||s.isText)return!1;let o=t<0?n.pos-s.nodeSize:n.pos;return!!(s.isAtom||(i=e.docView.descAt(o))&&!i.contentDOM)&&(tq.isSelectable(s)?rV(e,new tq(t<0?e.state.doc.resolve(n.pos-s.nodeSize):n)):!!nZ&&rV(e,new tU(e.state.doc.resolve(t<0?o:o+s.nodeSize))))}}else{if(r instanceof tq&&r.node.isInline)return rV(e,new tU(t>0?r.$to:r.$from));let n=rB(e.state,t);return!!n&&rV(e,n)}}function r_(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function rH(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function rU(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,i,o=!1;for(nU&&1==n.nodeType&&r<r_(n)&&rH(n.childNodes[r],-1)&&(o=!0);;)if(r>0)if(1!=n.nodeType)break;else{let e=n.childNodes[r-1];if(rH(e,-1))s=n,i=--r;else if(3==e.nodeType)r=(n=e).nodeValue.length;else break}else if(rW(n))break;else{let t=n.previousSibling;for(;t&&rH(t,-1);)s=n.parentNode,i=nC(t),t=t.previousSibling;if(t)r=r_(n=t);else{if((n=n.parentNode)==e.dom)break;r=0}}o?rq(e,n,r):s&&rq(e,s,i)}(e):function(e){let t,n,r=e.domSelectionRange(),s=r.focusNode,i=r.focusOffset;if(!s)return;let o=r_(s);for(;;)if(i<o){if(1!=s.nodeType)break;if(rH(s.childNodes[i],1))t=s,n=++i;else break}else if(rW(s))break;else{let r=s.nextSibling;for(;r&&rH(r,1);)t=r.parentNode,n=nC(r)+1,r=r.nextSibling;if(r)i=0,o=r_(s=r);else{if((s=s.parentNode)==e.dom)break;i=o=0}}t&&rq(e,t,n)}(e)}function rW(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function rq(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!nD(e);)t=nC(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!nD(e);)t=nC(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(nR(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&rO(e)},50)}function rK(e,t){let n=e.state.doc.resolve(t);if(!(nq||nY)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),s=(n.top+n.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),s=(n.top+n.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function rJ(e,t,n){let r=e.state.selection;if(r instanceof tU&&!r.empty||n.indexOf("s")>-1||nX&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=rB(e.state,t);if(n&&n instanceof tq)return rV(e,n)}if(!s.parent.inlineContent){let n=t<0?s:i,o=r instanceof tJ?tV.near(n,t):tV.findFrom(n,t);return!!o&&rV(e,o)}return!1}function rG(e,t){if(!(e.state.selection instanceof tU))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function rX(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function rY(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:s,openEnd:i}=t;for(;s>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){s--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let o=e.someProp("clipboardSerializer")||e8.fromSchema(e.state.schema),a=r4(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let d=l.firstChild,c,h=0;for(;d&&1==d.nodeType&&(c=r3[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),h++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${s} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function rQ(e,t,n,r,s){let i,o,a=s.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return o=new ek(eg.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{o=t(o,e,!0)}),o;let n=e.someProp("clipboardTextParser",n=>n(t,s,r,e));if(n)o=n;else{let n=s.marks(),{schema:r}=e.state,o=e8.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(o.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),i=function(e){var t;let n,r=/^(\s*<meta [^>]*>)*/.exec(e);r&&(e=e.slice(r[0].length));let s=r4().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(e),o;if((o=i&&r3[i[1].toLowerCase()])&&(e=o.map(e=>"<"+e+">").join("")+e+o.map(e=>"</"+e+">").reverse().join("")),s.innerHTML=(t=e,(n=window.trustedTypes)?(r6||(r6=n.defaultPolicy||n.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),r6.createHTML(t)):t),o)for(let e=0;e<o.length;e++)s=s.querySelector(o[e])||s;return s}(n),nZ&&function(e){let t=e.querySelectorAll(nq?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);let d=i&&i.querySelector("[data-pm-slice]"),c=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let e=+c[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(o||(o=(e.someProp("clipboardParser")||e.someProp("domParser")||eQ.fromSchema(e.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||c),context:s,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||rZ.test(e.parentNode.nodeName)?null:{ignore:!0}})),c)o=function(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch(t){return e}let{content:s,openStart:i,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;s=eg.from(t.create(r[e+1],s)),i++,o++}return new ek(s,i,o)}(r2(o,+c[1],+c[2]),c[4]);else if((o=ek.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),s,i=[];if(e.forEach(e=>{if(!i)return;let t=r.findWrapping(e.type),n;if(!t)return i=null;if(n=i.length&&s.length&&function e(t,n,r,s,i){if(i<t.length&&i<n.length&&t[i]==n[i]){let o=e(t,n,r,s.lastChild,i+1);if(o)return s.copy(s.content.replaceChild(s.childCount-1,o));if(s.contentMatchAt(s.childCount).matchType(i==t.length-1?r.type:t[i+1]))return s.copy(s.content.append(eg.from(r0(r,t,i+1))))}}(t,s,e,i[i.length-1],0))i[i.length-1]=n;else{i.length&&(i[i.length-1]=function e(t,n){if(0==n)return t;let r=t.content.replaceChild(t.childCount-1,e(t.lastChild,n-1)),s=t.contentMatchAt(t.childCount).fillBefore(eg.empty,!0);return t.copy(r.append(s))}(i[i.length-1],s.length));let n=r0(e,t);i.push(n),r=r.matchType(n.type),s=t}}),i)return eg.from(i)}return e}(o.content,s),!0)).openStart||o.openEnd){let e=0,t=0;for(let t=o.content.firstChild;e<o.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=o.content.lastChild;t<o.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);o=r2(o,e,t)}return e.someProp("transformPasted",t=>{o=t(o,e,l)}),o}let rZ=/^(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 r0(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,eg.from(e));return e}function r1(e,t,n,r,s,i){let o=t<0?e.firstChild:e.lastChild,a=o.content;return e.childCount>1&&(i=0),s<r-1&&(a=r1(a,t,n,r,s+1,i)),s>=n&&(a=t<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(eg.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(a))}function r2(e,t,n){return t<e.openStart&&(e=new ek(r1(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new ek(r1(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}let r3={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},r5=null;function r4(){return r5||(r5=document.implementation.createHTMLDocument("title"))}let r6=null,r8={},r7={},r9={touchstart:!0,touchmove:!0};class se{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 st(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function sn(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>sr(e,t))})}function sr(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function ss(e){return{left:e.clientX,top:e.clientY}}function si(e,t,n,r,s){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),s,!0):t(e,n,i.node(r),i.before(r),s,!1)))return!0;return!1}function so(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}r7.keydown=(e,t)=>{if((e.input.shiftKey=16==t.keyCode||t.shiftKey,!sd(e,t))&&(e.input.lastKeyCode=t.keyCode,e.input.lastKeyCodeTime=Date.now(),!nQ||!nq||13!=t.keyCode))if(229!=t.keyCode&&e.domObserver.forceFlush(),!nG||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",n=>n(e,t))||function(e,t){let n,r=t.keyCode,s=(n="",t.ctrlKey&&(n+="c"),t.metaKey&&(n+="m"),t.altKey&&(n+="a"),t.shiftKey&&(n+="s"),n);if(8==r||nX&&72==r&&"c"==s)return rG(e,-1)||rU(e,-1);if(46==r&&!t.shiftKey||nX&&68==r&&"c"==s)return rG(e,1)||rU(e,1);if(13==r||27==r)return!0;if(37==r||nX&&66==r&&"c"==s){let t=37==r?"ltr"==rK(e,e.state.selection.from)?-1:1:-1;return rF(e,t,s)||rU(e,t)}if(39==r||nX&&70==r&&"c"==s){let t=39==r?"ltr"==rK(e,e.state.selection.from)?1:-1:1;return rF(e,t,s)||rU(e,t)}else if(38==r||nX&&80==r&&"c"==s)return rJ(e,-1,s)||rU(e,-1);else if(40==r||nX&&78==r&&"c"==s)return function(e){if(!nJ||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;rX(e,n,"true"),setTimeout(()=>rX(e,n,"false"),20)}return!1}(e)||rJ(e,1,s)||rU(e,1);else if(s==(nX?"m":"c")&&(66==r||73==r||89==r||90==r))return!0;return!1}(e,t)?t.preventDefault():st(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,nP(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},r7.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},r7.keypress=(e,t)=>{if(sd(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||nX&&t.metaKey)return;if(e.someProp("handleKeyPress",n=>n(e,t)))return void t.preventDefault();let n=e.state.selection;if(!(n instanceof tU)||!n.$from.sameParent(n.$to)){let r=String.fromCharCode(t.charCode),s=()=>e.state.tr.insertText(r).scrollIntoView();/[\r\n]/.test(r)||e.someProp("handleTextInput",t=>t(e,n.$from.pos,n.$to.pos,r,s))||e.dispatch(s()),t.preventDefault()}};let sa=nX?"metaKey":"ctrlKey";r8.mousedown=(e,t)=>{var n;let r,s;e.input.shiftKey=t.shiftKey;let i=sp(e),o=Date.now(),a="singleClick";o-e.input.lastClick.time<500&&(r=(n=e.input.lastClick).x-t.clientX)*r+(s=n.y-t.clientY)*s<100&&!t[sa]&&e.input.lastClick.button==t.button&&("singleClick"==e.input.lastClick.type?a="doubleClick":"doubleClick"==e.input.lastClick.type&&(a="tripleClick")),e.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:a,button:t.button};let l=e.posAtCoords(ss(t));l&&("singleClick"==a?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new sl(e,l,t,!!i)):("doubleClick"==a?function(e,t,n,r){return si(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}:function(e,t,n,r){return si(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(so(e,tU.create(r,0,r.content.size),"pointer"),!0);let s=r.resolve(t);for(let t=s.depth+1;t>0;t--){let n=t>s.depth?s.nodeAfter:s.node(t),i=s.before(t);if(n.inlineContent)so(e,tU.create(r,i+1,i+1+n.content.size),"pointer");else{if(!tq.isSelectable(n))continue;so(e,tq.create(r,i),"pointer")}return!0}}(e,n,r)})(e,l.pos,l.inside,t)?t.preventDefault():st(e,"pointer"))};class sl{constructor(e,t,n,r){let s,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[sa],this.allowDefault=n.shiftKey,t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);s=n.parent,i=n.depth?n.before():0}const o=r?null:n.target,a=o?e.docView.nearestDesc(o,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;(0==n.button&&s.type.spec.draggable&&!1!==s.type.spec.selectable||l instanceof tq&&l.from<=i&&l.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&nU&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),st(e,"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(()=>rO(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;if(this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ss(e))),this.updateAllowDefault(e),this.allowDefault||!t)st(this.view,"pointer");else{var n,r,s,i;(n=this.view,r=t.pos,s=t.inside,i=this.selectNode,si(n,"handleClickOn",r,s,e)||n.someProp("handleClick",t=>t(n,r,e))||(i?function(e,t){if(-1==t)return!1;let n=e.state.selection,r,s;n instanceof tq&&(r=n.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(tq.isSelectable(t)){s=r&&n.$from.depth>0&&e>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?i.before(n.$from.depth):i.before(e);break}}return null!=s&&(so(e,tq.create(e.state.doc,s),"pointer"),!0)}(n,s):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&tq.isSelectable(r))&&(so(e,new tq(n),"pointer"),!0)}(n,s)))?e.preventDefault():0==e.button&&(this.flushed||nJ&&this.mightDrag&&!this.mightDrag.node.isAtom||nq&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to)))?(so(this.view,tV.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):st(this.view,"pointer")}}move(e){this.updateAllowDefault(e),st(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function sd(e,t){return!!e.composing||!!(nJ&&500>Math.abs(t.timeStamp-e.input.compositionEndedAt))&&(e.input.compositionEndedAt=-2e8,!0)}r8.touchstart=e=>{e.input.lastTouch=Date.now(),sp(e),st(e,"pointer")},r8.touchmove=e=>{e.input.lastTouch=Date.now(),st(e,"pointer")},r8.contextmenu=e=>sp(e);let sc=nQ?5e3:-1;function sh(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>sp(e),t))}function su(e){let t;for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=((t=document.createEvent("Event")).initEvent("event",!0,!0),t.timeStamp));e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function sp(e,t=!1){if(!nQ||!(e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),su(e),t||e.docView&&e.docView.dirty){let n=rT(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}r7.compositionstart=r7.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof tU&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||nq&&nY&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),sp(e,!0),e.markCursor=null;else if(sp(e,!t.selection.empty),nU&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}sh(e,sc)},r7.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,sh(e,20))};let sf=n_&&nH<15||nG&&n0<604;function sm(e,t,n,r,s){let i=rQ(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,s,i||ek.empty)))return!0;if(!i)return!1;let o=0==i.openStart&&0==i.openEnd&&1==i.content.childCount?i.content.firstChild:null,a=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function sg(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}r8.copy=r7.cut=(e,t)=>{let n=e.state.selection,r="cut"==t.type;if(n.empty)return;let s=sf?null:t.clipboardData,{dom:i,text:o}=rY(e,n.content());s?(t.preventDefault(),s.clearData(),s.setData("text/html",i.innerHTML),s.setData("text/plain",o)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,i),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},r7.paste=(e,t)=>{if(e.composing&&!nQ)return;let n=sf?null:t.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&sm(e,sg(n),n.getData("text/html"),r,t)?t.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?sm(e,r.value,null,s,t):sm(e,r.textContent,r.innerHTML,s,t)},50)}(e,t)};class sx{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}let sy=nX?"altKey":"ctrlKey";function sb(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[sy]}for(let e in r8.dragstart=(e,t)=>{let n,r=e.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=e.state.selection,i=s.empty?null:e.posAtCoords(ss(t));if(i&&i.pos>=s.from&&i.pos<=(s instanceof tq?s.to-1:s.to));else if(r&&r.mightDrag)n=tq.create(e.state.doc,r.mightDrag.pos);else if(t.target&&1==t.target.nodeType){let r=e.docView.nearestDesc(t.target,!0);r&&r.node.type.spec.draggable&&r!=e.docView&&(n=tq.create(e.state.doc,r.posBefore))}let o=(n||e.state.selection).content(),{dom:a,text:l,slice:d}=rY(e,o);t.dataTransfer.files.length&&nq&&!(nK>120)||t.dataTransfer.clearData(),t.dataTransfer.setData(sf?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",sf||t.dataTransfer.setData("text/plain",l),e.dragging=new sx(d,sb(e,t),n)},r8.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},r7.dragover=r7.dragenter=(e,t)=>t.preventDefault(),r7.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(ss(t));if(!r)return;let s=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=rQ(e,sg(t.dataTransfer),sf?null:t.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&sb(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||ek.empty,o)))return t.preventDefault();if(!i)return;t.preventDefault();let a=i?tN(e.state.doc,s.pos,i):s.pos;null==a&&(a=s.pos);let l=e.state.tr;if(o){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let d=l.mapping.map(a),c=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,h=l.doc;if(c?l.replaceRangeWith(d,d,i.content.firstChild):l.replaceRange(d,d,i),l.doc.eq(h))return;let u=l.doc.resolve(d);if(c&&tq.isSelectable(i.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new tq(u));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,s)=>t=s),l.setSelection(rz(e,u,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},r8.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&rO(e)},20))},r8.blur=(e,t)=>{e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},r8.beforeinput=(e,t)=>{if(nq&&nQ&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,nP(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}},r7)r8[e]=r7[e];function sv(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class sw{constructor(e,t){this.toDOM=e,this.spec=t||sN,this.side=this.spec.side||0}map(e,t,n,r){let{pos:s,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new sC(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof sw&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&sv(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class sk{constructor(e,t){this.attrs=e,this.spec=t||sN}map(e,t,n,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return s>=i?null:new sC(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof sk&&sv(this.attrs,e.attrs)&&sv(this.spec,e.spec)}static is(e){return e.type instanceof sk}destroy(){}}class sS{constructor(e,t){this.attrs=e,this.spec=t||sN}map(e,t,n,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=s.pos?null:new sC(s.pos-n,i.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),s;return r==t.from&&!(s=e.child(n)).isText&&r+s.nodeSize==t.to}eq(e){return this==e||e instanceof sS&&sv(this.attrs,e.attrs)&&sv(this.spec,e.spec)}destroy(){}}class sC{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new sC(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new sC(e,e,new sw(t,n))}static inline(e,t,n,r){return new sC(e,t,new sk(n,r))}static node(e,t,n,r){return new sC(e,t,new sS(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof sk}get widget(){return this.type instanceof sw}}let sM=[],sN={};class sT{constructor(e,t){this.local=e.length?e:sM,this.children=t.length?t:sM}static create(e,t){return t.length?sD(t,e,0,sN):sj}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,s){for(let i=0;i<this.local.length;i++){let o=this.local[i];o.from<=t&&o.to>=e&&(!s||s(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let o=this.children[i]+1;this.children[i+2].findInner(e-o,t-o,n,r+o,s)}}map(e,t,n){return this==sj||0==e.maps.length?this:this.mapInner(e,t,0,0,n||sN)}mapInner(e,t,n,r,s){let i;for(let o=0;o<this.local.length;o++){let a=this.local[o].map(e,n,r);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[o].spec)}return this.children.length?function(e,t,n,r,s,i,o){let a=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,s,i)=>{let o=i-s-(n-e);for(let s=0;s<a.length;s+=3){let i=a[s+1];if(i<0||e>i+t-r)continue;let l=a[s]+t-r;n>=l?a[s+1]=e<=l?-2:-1:e>=t&&o&&(a[s]+=o,a[s+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let d=n.map(e[t]+i),c=d-s;if(c<0||c>=r.content.size){l=!0;continue}let h=n.map(e[t+1]+i,-1)-s,{index:u,offset:p}=r.content.findIndex(c),f=r.maybeChild(u);if(f&&p==c&&p+f.nodeSize==h){let r=a[t+2].mapInner(n,f,d+1,e[t]+i+1,o);r!=sj?(a[t]=c,a[t+1]=h,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=sD(function(e,t,n,r,s,i,o){for(let a=0;a<e.length;a+=3)-1==e[a+1]&&function e(t,i){for(let e=0;e<t.local.length;e++){let a=t.local[e].map(r,s,i);a?n.push(a):o.onRemove&&o.onRemove(t.local[e].spec)}for(let n=0;n<t.children.length;n+=3)e(t.children[n+2],t.children[n]+i+1)}(e[a+2],t[a]+i+1);return n}(a,e,t,n,s,i,o),r,0,o);t=l.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<l.children.length;e+=3){let n=l.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,l.children[e],l.children[e+1],l.children[e+2])}}return new sT(t.sort(sR),a)}(this.children,i||[],e,t,n,r,s):i?new sT(i.sort(sR),sM):sj}add(e,t){return t.length?this==sj?sT.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,s=0;e.forEach((e,i)=>{let o=i+n,a;if(a=sA(t,e,o)){for(r||(r=this.children.slice());s<r.length&&r[s]<i;)s+=3;r[s]==i?r[s+2]=r[s+2].addInner(e,a,o+1):r.splice(s,0,i,i+e.nodeSize,sD(a,e,o+1,sN)),s+=3}});let i=sE(s?sI(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new sT(i.length?this.local.concat(i).sort(sR):this.local,r||this.children)}remove(e){return 0==e.length||this==sj?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let s,i=n[r]+t,o=n[r+1]+t;for(let t=0,n;t<e.length;t++)(n=e[t])&&n.from>i&&n.to<o&&(e[t]=null,(s||(s=[])).push(n));if(!s)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(s,i+1);a!=sj?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length){for(let n=0,s;n<e.length;n++)if(s=e[n])for(let e=0;e<r.length;e++)r[e].eq(s,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1))}return n==this.children&&r==this.local?this:r.length||n.length?new sT(r,n):sj}forChild(e,t){let n,r;if(this==sj)return this;if(t.isLeaf)return sT.empty;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let s=e+1,i=s+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>s&&t.type instanceof sk){let e=Math.max(s,t.from)-s,n=Math.min(i,t.to)-s;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new sT(r.sort(sR),sM);return n?new sO([e,n]):e}return n||sj}eq(e){if(this==e)return!0;if(!(e instanceof sT)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return sP(this.localsInner(e))}localsInner(e){if(this==sj)return sM;if(e.inlineContent||!this.local.some(sk.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof sk||t.push(this.local[e]);return t}forEachSet(e){e(this)}}sT.empty=new sT([],[]),sT.removeOverlap=sP;let sj=sT.empty;class sO{constructor(e){this.members=e}map(e,t){let n=this.members.map(n=>n.map(e,t,sN));return sO.from(n)}forChild(e,t){if(t.isLeaf)return sT.empty;let n=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=sj&&(s instanceof sO?n=n.concat(s.members):n.push(s))}return sO.from(n)}eq(e){if(!(e instanceof sO)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<s.length;e++)t.push(s[e])}else t=s}return t?sP(n?t:t.sort(sR)):sM}static from(e){switch(e.length){case 0:return sj;case 1:return e[0];default:return new sO(e.every(e=>e instanceof sT)?e:e.reduce((e,t)=>e.concat(t instanceof sT?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function sE(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new sC(s.from+t,s.to+t,s.type))}return n}function sA(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let t=0,i;t<e.length;t++)(i=e[t])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),e[t]=null);return s}function sI(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function sD(e,t,n,r){let s=[],i=!1;t.forEach((t,o)=>{let a=sA(e,t,o+n);if(a){i=!0;let e=sD(a,t,n+o+1,r);e!=sj&&s.push(o,o+t.nodeSize,e)}});let o=sE(i?sI(e):e,-n).sort(sR);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||s.length?new sT(o,s):sj}function sR(e,t){return e.from-t.from||e.to-t.to}function sP(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let i=t[s];if(i.from==r.from){i.to!=r.to&&(t==e&&(t=e.slice()),t[s]=i.copy(i.from,r.to),sz(t,s+1,i.copy(r.to,i.to)));continue}i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),sz(t,s,r.copy(i.from,r.to)));break}}return t}function sz(e,t,n){for(;t<e.length&&sR(n,e[t])>0;)t++;e.splice(t,0,n)}function s$(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=sj&&t.push(r)}),e.cursorWrapper&&t.push(sT.create(e.state.doc,[e.cursorWrapper.deco])),sO.from(t)}let sL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},sB=n_&&nH<=11;class sV{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class sF{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new sV,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);n_&&nH<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():nJ&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),sB&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,sL)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);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(r$(this.view)){if(this.suppressingSelectionUpdates)return rO(this.view);if(n_&&nH<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&nO(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=nM(n))t.add(n);for(let r=e.anchorNode;r;r=nM(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:3==n.nodeType?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){var e;let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=t.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&r$(t)&&!this.ignoreSelectionChange(r),i=-1,o=-1,a=!1,l=[];if(t.editable)for(let e=0;e<n.length;e++){let t=this.registerMutation(n[e],l);t&&(i=i<0?t.from:Math.min(t.from,i),o=o<0?t.to:Math.max(t.to,o),t.typeOver&&(a=!0))}if(nU&&l.length){let e=l.filter(e=>"BR"==e.nodeName);if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;e&&"LI"==e.nodeName&&(!n||function(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}(t,n)!=e)&&r.remove()}}}else if((nq||nJ)&&l.some(e=>"BR"==e.nodeName)&&(8==t.input.lastKeyCode||46==t.input.lastKeyCode)){for(let e of l)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;t&&1==t.nodeType&&"false"==t.contentEditable&&e.parentNode.removeChild(e)}}let d=null;i<0&&s&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&nR(r)&&(d=rT(t))&&d.eq(tV.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,rO(t),this.currentSelection.set(r),t.scrollToSelection()):(i>-1||s)&&(i>-1&&(t.docView.markDirty(i,o),e=t,!s_.has(e)&&(s_.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))&&(e.requiresGeckoHackNode=nU,sH||(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."),sH=!0))),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:s}=e.domSelectionRange();for(let i of t)if((null==(n=i.parentNode)?void 0:n.nodeName)=="TR"){let t=i.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),r==i&&e.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}(t,l)),this.handleDOMChange(i,o,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(r)||rO(t),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,s=e.nextSibling;if(n_&&nH<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||0>Array.prototype.indexOf.call(e.addedNodes,n))&&(r=n),(!i||0>Array.prototype.indexOf.call(e.addedNodes,i))&&(s=i)}let i=r&&r.parentNode==e.target?nC(r)+1:0,o=n.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?nC(s):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let s_=new WeakMap,sH=!1;function sU(e,t){let n=t.startContainer,r=t.startOffset,s=t.endContainer,i=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return nO(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function sW(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(nJ&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}else if(e.parentNode.lastChild==e||nJ&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}let sq=/^(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 sK(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:rz(e,t.resolve(n.anchor),t.resolve(n.head))}function sJ(e,t,n){let r=e.depth,s=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,s++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,s++}return s}function sG(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class sX{constructor(e,t){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 se,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(s1),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=sZ(this),sQ(this),this.nodeViews=s0(this),this.docView=rp(this.state.doc,sY(this),s$(this),this.dom,this),this.domObserver=new sF(this,(e,t,n,r)=>(function(e,t,n,r,s){let i,o,a,l=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=rT(e,t);if(n&&!e.state.selection.eq(n)){if(nq&&nQ&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,nP(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),l&&r.setMeta("composition",l),e.dispatch(r)}return}let d=e.state.doc.resolve(t),c=d.sharedDepth(n);t=d.before(c+1),n=e.state.doc.resolve(n).after(c+1);let h=e.state.selection,u=function(e,t,n){let r,{node:s,fromOffset:i,toOffset:o,from:a,to:l}=e.docView.parseRange(t,n),d=e.domSelectionRange(),c=d.anchorNode;if(c&&e.dom.contains(1==c.nodeType?c:c.parentNode)&&(r=[{node:c,offset:d.anchorOffset}],nR(d)||r.push({node:d.focusNode,offset:d.focusOffset})),nq&&8===e.input.lastKeyCode)for(let e=o;e>i;e--){let t=s.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){o=e;break}if(!n||n.size)break}let h=e.state.doc,u=e.someProp("domParser")||eQ.fromSchema(e.state.schema),p=h.resolve(a),f=null,m=u.parse(s,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:sW,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),p=e.state.doc,f=p.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(i=e.state.selection.to,o="end"):(i=e.state.selection.from,o="start"),e.input.lastKeyCode=null;let m=function(e,t,n,r,s){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:o,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==s){let e=Math.max(0,i-Math.min(o,a));r-=o+e-i}if(o<i&&e.size<t.size){let e=r<=i&&r>=o?i-r:0;(i-=e)&&i<t.size&&sG(t.textBetween(i-1,i+1))&&(i+=e?1:-1),a=i+(a-o),o=i}else if(a<i){let t=r<=i&&r>=a?i-r:0;(i-=t)&&i<e.size&&sG(e.textBetween(i-1,i+1))&&(i+=t?1:-1),o=i+(o-a),a=i}return{start:i,endA:o,endB:a}}(f.content,u.doc.content,u.from,i,o);if(m&&e.input.domChangeCount++,(nG&&e.input.lastIOSEnter>Date.now()-225||nQ)&&s.some(e=>1==e.nodeType&&!sq.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",t=>t(e,nP(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!m)if(r&&h instanceof tU&&!h.empty&&h.$head.sameParent(h.$anchor)&&!e.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:h.from,endA:h.to,endB:h.to};else{if(u.sel){let t=sK(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);l&&n.setMeta("composition",l),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof tU&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),n_&&nH<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>u.from&&" "==u.doc.textBetween(m.start-u.from-1,m.start-u.from+1)&&(m.start--,m.endA--,m.endB--);let g=u.doc.resolveNoCache(m.start-u.from),x=u.doc.resolveNoCache(m.endB-u.from),y=p.resolve(m.start),b=g.sameParent(x)&&g.parent.inlineContent&&y.end()>=m.endA;if((nG&&e.input.lastIOSEnter>Date.now()-225&&(!b||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!b&&g.pos<u.doc.content.size&&(!g.sameParent(x)||!g.parent.inlineContent)&&g.pos<x.pos&&!/\S/.test(u.doc.textBetween(g.pos,x.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,nP(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&function(e,t,n,r,s){if(n-t<=s.pos-r.pos||sJ(r,!0,!1)<s.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=e.resolve(sJ(i,!0,!0));return!(!o.parent.isTextblock||o.pos>n||sJ(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(p,m.start,m.endA,g,x)&&e.someProp("handleKeyDown",t=>t(e,nP(8,"Backspace")))){nQ&&nq&&e.domObserver.suppressSelectionUpdates();return}nq&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),nQ&&!b&&g.start()!=x.start()&&0==x.parentOffset&&g.depth==x.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,x=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,nP(13,"Enter"))})},20));let v=m.start,w=m.endA,k=t=>{let n=t||e.state.tr.replace(v,w,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let t=sK(e,n.doc,u.sel);t&&!(nq&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==v||t.head==n.mapping.map(w)-1)||n_&&t.empty&&t.head==v)&&n.setSelection(t)}return l&&n.setMeta("composition",l),n.scrollIntoView()};if(b)if(g.pos==x.pos){n_&&nH<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>rO(e),20));let t=k(e.state.tr.delete(v,w)),n=p.resolve(m.start).marksAcross(p.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(a=function(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,s=n,i=r,o,a,l;for(let e=0;e<r.length;e++)s=r[e].removeFromSet(s);for(let e=0;e<n.length;e++)i=n[e].removeFromSet(i);if(1==s.length&&0==i.length)a=s[0],o="add",l=e=>e.mark(a.addToSet(e.marks));else{if(0!=s.length||1!=i.length)return null;a=i[0],o="remove",l=e=>e.mark(a.removeFromSet(e.marks))}let d=[];for(let e=0;e<t.childCount;e++)d.push(l(t.child(e)));if(eg.from(d).eq(e))return{mark:a,type:o}}(g.parent.content.cut(g.parentOffset,x.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let t=k(e.state.tr);"add"==a.type?t.addMark(v,w,a.mark):t.removeMark(v,w,a.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==x.index()-!x.textOffset){let t=g.parent.textBetween(g.parentOffset,x.parentOffset),n=()=>k(e.state.tr.insertText(t,v,w));e.someProp("handleTextInput",r=>r(e,v,w,t,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())})(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in r8){let n=r8[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,t)||sr(e,t)||!e.editable&&t.type in r7||n(e,t)},r9[t]?{passive:!0}:void 0)}nJ&&e.dom.addEventListener("input",()=>null),sn(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;for(let t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&sn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(s1),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];for(let n in t.state=this.state,e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n,r,s;let i=this.state,o=!1,a=!1;e.storedMarks&&this.composing&&(su(this),a=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=s0(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&sn(this),this.editable=sZ(this),sQ(this);let d=s$(this),c=sY(this),h=i.plugins==e.plugins||i.doc.eq(e.doc)?e.scrollToSelection>i.scrollToSelection?"to selection":"preserve":"reset",u=o||!this.docView.matchesNode(e.doc,c,d);(u||!e.selection.eq(i.selection))&&(a=!0);let p="preserve"==h&&a&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),s=Math.max(0,r.top);for(let i=(r.left+r.right)/2,o=s+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=e.root.elementFromPoint(i,o);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=s-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:n3(e.dom)}}(this);if(a){let t,n,a;this.domObserver.stop();let l=u&&(n_||nq)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&(r=i.selection,s=e.selection,a=Math.min(r.$anchor.sharedDepth(r.head),s.$anchor.sharedDepth(s.head)),r.$anchor.start(a)!=s.$anchor.start(a));if(u){let t=nq?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=nI(e=e.childNodes[t-1])}else{if(!e.parentNode||nD(e))return null;t=nC(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||nD(e))return null;t=nC(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,s=e.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}(this)),(o||!this.docView.update(e.doc,c,d,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=rp(e.doc,c,d,this.dom,this)),!t||this.trackWrites&&this.dom.contains(this.trackWrites)||(l=!0)}l||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&(t=this.docView.domFromPos(this.state.selection.anchor,0),n=this.domSelectionRange(),nO(t.node,t.offset,n.anchorNode,n.anchorOffset)))?rO(this,l):(rR(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),(null==(n=this.dragging)?void 0:n.node)&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),"reset"==h?this.dom.scrollTop=0:"to selection"==h?this.scrollToSelection():p&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;n5(n,0==r?0:r-t)}(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof tq){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&n2(this,t.getBoundingClientRect(),e)}else n2(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new sx(e.slice,e.move,r<0?void 0:tq.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(null!=n&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let s=this.directPlugins[n].props[e];if(null!=s&&(r=t?t(s):s))return r}let s=this.state.plugins;if(s)for(let n=0;n<s.length;n++){let i=s[n].props[e];if(null!=i&&(r=t?t(i):i))return r}}hasFocus(){if(n_){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(n4)return e.focus(n4);let t=n3(e);e.focus(null==n4?{get preventScroll(){return n4={preventScroll:!0},!0}}:void 0),n4||(n4=!1,n5(t,0))}(this.dom),rO(this),this.domObserver.start()}get root(){let e=this._root;if(null==e){for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return function(e,t){var n;let r,s,i=e.dom.ownerDocument,o,a=0,l=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(nI(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(nI(r.startContainer),r.startOffset)}}}(i,t.left,t.top);l&&({node:o,offset:a}=l);let d=(e.root.elementFromPoint?e.root:i).elementFromPoint(t.left,t.top);if(!d||!e.dom.contains(1!=d.nodeType?d.parentNode:d)){let n=e.dom.getBoundingClientRect();if(!n6(t,n)||!(d=function e(t,n,r){let s=t.childNodes.length;if(s&&r.top<r.bottom)for(let i=Math.max(0,Math.min(s-1,Math.floor(s*(n.top-r.top)/(r.bottom-r.top))-2)),o=i;;){let r=t.childNodes[o];if(1==r.nodeType){let t=r.getClientRects();for(let s=0;s<t.length;s++){let i=t[s];if(n6(n,i))return e(r,n,i)}}if((o=(o+1)%s)==i)break}return t}(e.dom,t,n)))return null}if(nJ)for(let e=d;o&&e;e=nM(e))e.draggable&&(o=void 0);if(d=(r=(n=d).parentNode)&&/^li$/i.test(r.nodeName)&&t.left<n.getBoundingClientRect().left?r:n,o){let n;if(nU&&1==o.nodeType&&(a=Math.min(a,o.childNodes.length))<o.childNodes.length){let e=o.childNodes[a],n;"IMG"==e.nodeName&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&a++}nZ&&a&&1==o.nodeType&&1==(n=o.childNodes[a-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=t.top&&a--,o==e.dom&&a==o.childNodes.length-1&&1==o.lastChild.nodeType&&t.top>o.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(0==a||1!=o.nodeType||"BR"!=o.childNodes[a-1].nodeName)&&(s=function(e,t,n,r){let s=-1;for(let n=t,i=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!i&&o.left>r.left||o.top>r.top?s=t.posBefore:(!i&&o.right<r.left||o.bottom<r.top)&&(s=t.posAfter),i=!0),!t.contentDOM&&s<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return s>-1?s:e.docView.posFromDOM(t,n,-1)}(e,o,a,t))}null==s&&(s=function(e,t,n){let{node:r,offset:s}=function e(t,n){let r,s,i,o=2e8,a,l=0,d=n.top,c=n.top;for(let e=t.firstChild,h=0;e;e=e.nextSibling,h++){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=nT(e).getClientRects()}for(let u=0;u<t.length;u++){let p=t[u];if(p.top<=d&&p.bottom>=c){d=Math.max(p.bottom,d),c=Math.min(p.top,c);let t=p.left>n.left?p.left-n.left:p.right<n.left?n.left-p.right:0;if(t<o){i=e,o=t,a=t&&3==i.nodeType?{left:p.right<n.left?p.right:p.left,top:n.top}:n,1==e.nodeType&&t&&(l=h+ +(n.left>=(p.left+p.right)/2));continue}}else p.top>n.top&&!r&&p.left<=n.left&&p.right>=n.left&&(r=e,s={left:Math.max(p.left,Math.min(p.right,n.left)),top:p.top});!i&&(n.left>=p.right&&n.top>=p.top||n.left>=p.left&&n.top>=p.bottom)&&(l=h+1)}}return(!i&&r&&(i=r,a=s,o=0),i&&3==i.nodeType)?function(e,t){let n=e.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(e,i+1),r.setStart(e,i);let n=n7(r,1);if(n.top!=n.bottom&&n6(t,n)){s={node:e,offset:i+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),s||{node:e,offset:0}}(i,a):!i||o&&1==i.nodeType?{node:t,offset:l}:e(i,a)}(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,s,i)}(e,d,t));let c=e.docView.nearestDesc(d,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}(this,e)}coordsAtPos(e,t=1){return re(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return function(e,t,n){let r,s;return ri==t&&ro==n?ra:(ri=t,ro=n,ra="up"==n||"down"==n?(r=t.selection,s="up"==n?r.$from:r.$to,rr(e,t,()=>{let{node:t}=e.docView.domFromPos(s.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=re(e,s.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=nT(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let s=t[e];if(s.bottom>s.top+1&&("up"==n?r.top-s.top>(s.bottom-r.top)*2:s.bottom-r.bottom>(r.bottom-s.top)*2))return!1}}return!0})):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=s==r.parent.content.size,o=e.domSelection();return o?rs.test(r.parent.textContent)&&o.modify?rr(e,t,()=>{let{focusNode:t,focusOffset:s,anchorNode:i,anchorOffset:a}=e.domSelectionRange(),l=o.caretBidiLevel;o.modify("move",n,"character");let d=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:c,focusOffset:h}=e.domSelectionRange(),u=c&&!d.contains(1==c.nodeType?c:c.parentNode)||t==c&&s==h;try{o.collapse(i,a),t&&(t!=i||s!=a)&&o.extend&&o.extend(t,s)}catch(e){}return null!=l&&(o.caretBidiLevel=l),u}):"left"==n||"backward"==n?!s:i:r.pos==r.start()||r.pos==r.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return sm(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return sm(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return rY(this,e)}destroy(){if(this.docView){for(let e in this.domObserver.stop(),this.input.eventHandlers)this.dom.removeEventListener(e,this.input.eventHandlers[e]);clearTimeout(this.input.composingTimeout),clearTimeout(this.input.lastIOSEnterFallbackTimeout),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],s$(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,nj()}}get isDestroyed(){return null==this.docView}dispatchEvent(e){!sr(this,e)&&r8[e.type]&&(this.editable||!(e.type in r7))&&r8[e.type](this,e)}domSelectionRange(){let e=this.domSelection();return e?nJ&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){let n;if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return sU(e,n)}function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?sU(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function sY(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[sC.node(0,e.state.doc.content.size,t)]}function sQ(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:sC.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function sZ(e){return!e.someProp("editable",t=>!1===t(e.state))}function s0(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function s1(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}sX.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var s2={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:"'"},s3={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},s5="u">typeof navigator&&/Mac/.test(navigator.platform),s4="u">typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),s6=0;s6<10;s6++)s2[48+s6]=s2[96+s6]=String(s6);for(var s6=1;s6<=24;s6++)s2[s6+111]="F"+s6;for(var s6=65;s6<=90;s6++)s2[s6]=String.fromCharCode(s6+32),s3[s6]=String.fromCharCode(s6);for(var s8 in s2)s3.hasOwnProperty(s8)||(s3[s8]=s2[s8]);let s7="u">typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),s9="u">typeof navigator&&/Win/.test(navigator.platform);function ie(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function it(e){let t=function(e){let t=Object.create(null);for(let n in e)t[function(e){let t,n,r,s,i=e.split(/-(?!$)/),o=i[i.length-1];"Space"==o&&(o=" ");for(let e=0;e<i.length-1;e++){let o=i[e];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else if(/^mod$/i.test(o))s7?s=!0:n=!0;else throw Error("Unrecognized modifier name: "+o)}return t&&(o="Alt-"+o),n&&(o="Ctrl-"+o),s&&(o="Meta-"+o),r&&(o="Shift-"+o),o}(n)]=e[n];return t}(e);return function(e,n){var r;let s=("Esc"==(r=!(s5&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||s4&&n.shiftKey&&n.key&&1==n.key.length||"Unidentified"==n.key)&&n.key||(n.shiftKey?s3:s2)[n.keyCode]||n.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),i,o=t[ie(s,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==s.length&&" "!=s){if(n.shiftKey){let r=t[ie(s,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(s9&&n.ctrlKey&&n.altKey)&&(i=s2[n.keyCode])&&i!=s){let r=t[ie(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var ir=Object.defineProperty,is=(e,t)=>{for(var n in t)ir(e,n,{get:t[n],enumerable:!0})};function ii(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var io=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(i);return s.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(s),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],a=!!e,l=e||s.tr,d=()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(l),o.every(e=>!0===e)),c={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(l,t),s=n(...e)(r);return o.push(s),c}])),run:d};return c}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,s=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...s,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:e,editor:r,view:i,state:ii({state:s,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},ia={};is(ia,{blur:()=>il,clearContent:()=>id,clearNodes:()=>ic,command:()=>ih,createParagraphNear:()=>iu,cut:()=>ip,deleteCurrentNode:()=>im,deleteNode:()=>ix,deleteRange:()=>iy,deleteSelection:()=>ib,enter:()=>iv,exitCode:()=>iw,extendMarkRange:()=>ij,first:()=>iO,focus:()=>iP,forEach:()=>iz,insertContent:()=>i$,insertContentAt:()=>iF,joinBackward:()=>iU,joinDown:()=>iH,joinForward:()=>iW,joinItemBackward:()=>iq,joinItemForward:()=>iK,joinTextblockBackward:()=>iJ,joinTextblockForward:()=>iG,joinUp:()=>i_,keyboardShortcut:()=>iY,lift:()=>iZ,liftEmptyBlock:()=>i0,liftListItem:()=>i1,newlineInCode:()=>i2,resetAttributes:()=>i4,scrollIntoView:()=>i6,selectAll:()=>i8,selectNodeBackward:()=>i7,selectNodeForward:()=>i9,selectParentNode:()=>oe,selectTextblockEnd:()=>ot,selectTextblockStart:()=>on,setContent:()=>oi,setMark:()=>oL,setMeta:()=>oB,setNode:()=>oV,setNodeSelection:()=>oF,setTextDirection:()=>o_,setTextSelection:()=>oH,sinkListItem:()=>oU,splitBlock:()=>oq,splitListItem:()=>oK,toggleList:()=>oX,toggleMark:()=>oY,toggleNode:()=>oQ,toggleWrap:()=>oZ,undoInputRule:()=>o0,unsetAllMarks:()=>o1,unsetMark:()=>o2,unsetTextDirection:()=>o3,updateAttributes:()=>o5,wrapIn:()=>o4,wrapInList:()=>o6});var il=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),id=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),ic=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:s}=r;return!n||(s.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:s}=t,i=r.resolve(s.map(n)),o=r.resolve(s.map(n+e.nodeSize)),a=i.blockRange(o);if(!a)return;let l=tx(a);if(e.type.isTextblock){let{defaultType:e}=i.parent.contentMatchAt(i.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)})}),!0)},ih=e=>t=>e(t),iu=()=>({state:e,dispatch:t})=>nu(e,t),ip=(e,t)=>({editor:n,tr:r})=>{let{state:s}=n,i=s.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,i.content),r.setSelection(new tU(r.doc.resolve(Math.max(o-1,0)))),!0},im=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let s=e.selection.$anchor;for(let n=s.depth;n>0;n-=1)if(s.node(n).type===r.type){if(t){let t=s.before(n),r=s.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function ig(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var ix=e=>({tr:t,state:n,dispatch:r})=>{let s=ig(e,n.schema),i=t.selection.$anchor;for(let e=i.depth;e>0;e-=1)if(i.node(e).type===s){if(r){let n=i.before(e),r=i.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},iy=e=>({tr:t,dispatch:n})=>{let{from:r,to:s}=e;return n&&t.delete(r,s),!0},ib=()=>({state:e,dispatch:t})=>t7(e,t),iv=()=>({commands:e})=>e.keyboardShortcut("Enter"),iw=()=>({state:e,dispatch:t})=>nh(e,t);function ik(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function iS(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:ik(t[r])?t[r].test(e[r]):t[r]===e[r])}function iC(e,t,n={}){return e.find(e=>e.type===t&&iS(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function iM(e,t,n={}){return!!iC(e,t,n)}function iN(e,t,n){var r;if(!e||!t)return;let s=e.parent.childAfter(e.parentOffset);if(s.node&&s.node.marks.some(e=>e.type===t)||(s=e.parent.childBefore(e.parentOffset)),!s.node||!s.node.marks.some(e=>e.type===t)||(n=n||(null==(r=s.node.marks[0])?void 0:r.attrs),!iC([...s.node.marks],t,n)))return;let i=s.index,o=e.start()+s.offset,a=i+1,l=o+s.node.nodeSize;for(;i>0&&iM([...e.parent.child(i-1).marks],t,n);)i-=1,o-=e.parent.child(i).nodeSize;for(;a<e.parent.childCount&&iM([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function iT(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var ij=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let i=iT(e,r.schema),{doc:o,selection:a}=n,{$from:l,from:d,to:c}=a;if(s){let e=iN(l,i,t);if(e&&e.from<=d&&e.to>=c){let t=tU.create(o,e.from,e.to);n.setSelection(t)}}return!0},iO=e=>t=>{let n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function iE(e){return e instanceof tU}function iA(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function iI(e,t=null){if(!t)return null;let n=tV.atStart(e),r=tV.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;let s=n.from,i=r.to;return"all"===t?tU.create(e,iA(0,s,i),iA(e.content.size,s,i)):tU.create(e,iA(t,s,i),iA(t,s,i))}function iD(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function iR(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var iP=(e=null,t={})=>({editor:n,view:r,tr:s,dispatch:i})=>{t={scrollIntoView:!0,...t};let o=()=>{(iR()||iD())&&r.dom.focus(),"u">typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&!iR()&&!iD()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{!n.isDestroyed&&(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&null===e||!1===e)return!0}catch{return!1}if(i&&null===e&&!iE(n.state.selection))return o(),!0;let a=iI(s.doc,e)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},iz=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),i$=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),iL=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){let r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&iL(r)}return e};function iB(e){if("u"<typeof window)throw Error("[tiptap error]: there is no window object available, so this function cannot be used");let t=`<body>${e}</body>`;return iL(new window.DOMParser().parseFromString(t,"text/html").body)}function iV(e,t,n){if(e instanceof eP||e instanceof eg)return e;n={slice:!0,parseOptions:{},...n};let r="object"==typeof e&&null!==e,s="string"==typeof e;if(r)try{if(Array.isArray(e)&&e.length>0)return eg.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",r),iV("",t,n)}if(s){if(n.errorOnInvalidContent){let r=!1,s="",i=new eX({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(r=!0,s="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?eQ.fromSchema(i).parseSlice(iB(e),n.parseOptions):eQ.fromSchema(i).parse(iB(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${s}`)})}let r=eQ.fromSchema(t);return n.slice?r.parseSlice(iB(e),n.parseOptions).content:r.parse(iB(e),n.parseOptions)}return iV("",t,n)}var iF=(e,t,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){let s,a;n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l=e=>{i.emit("contentError",{editor:i,error:e,disableCollaboration:()=>{"collaboration"in i.storage&&"object"==typeof i.storage.collaboration&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{iV(t,i.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(e){l(e)}try{s=iV(t,i.schema,{parseOptions:d,errorOnInvalidContent:null!=(o=n.errorOnInvalidContent)?o:i.options.enableContentCheck})}catch(e){return l(e),!1}let{from:c,to:h}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},u=!0,p=!0;if((!("type"in s)?s:[s]).forEach(e=>{e.check(),u=!!u&&e.isText&&0===e.marks.length,p=!!p&&e.isBlock}),c===h&&p){let{parent:e}=r.doc.resolve(c);!e.isTextblock||e.type.spec.code||e.childCount||(c-=1,h+=1)}if(u){if(Array.isArray(t))a=t.map(e=>e.text||"").join("");else if(t instanceof eg){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),a=e}else a="object"==typeof t&&t&&t.text?t.text:t;r.insertText(a,c,h)}else{a=s;let e=r.doc.resolve(c),t=e.node(),n=0===e.parentOffset,i=t.isText||t.isTextblock,o=t.content.size>0;n&&i&&o&&(c=Math.max(0,c-1)),r.replaceWith(c,h,a)}n.updateSelection&&function(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof tp||s instanceof tf))return;let i=e.mapping.maps[r],o=0;i.forEach((e,t,n,r)=>{0===o&&(o=r)}),e.setSelection(tV.near(e.doc.resolve(o),-1))}(r,r.steps.length-1,0),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:a}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:a})}return!0},i_=()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,r=n instanceof tq,s;if(r){if(n.node.isTextblock||!tS(e.doc,n.from))return!1;s=n.from}else if(null==(s=tM(e.doc,n.from,-1)))return!1;if(t){let n=e.tr.join(s);r&&n.setSelection(tq.create(n.doc,s-e.doc.resolve(s).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0})(e,t),iH=()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,r;if(n instanceof tq){if(n.node.isTextblock||!tS(e.doc,n.to))return!1;r=n.to}else if(null==(r=tM(e.doc,n.to,1)))return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0})(e,t),iU=()=>({state:e,dispatch:t})=>ne(e,t),iW=()=>({state:e,dispatch:t})=>no(e,t),iq=()=>({state:e,dispatch:t,tr:n})=>{try{let r=tM(e.doc,e.selection.$from.pos,-1);if(null==r)return!1;return n.join(r,2),t&&t(n),!0}catch{return!1}},iK=()=>({state:e,dispatch:t,tr:n})=>{try{let r=tM(e.doc,e.selection.$from.pos,1);if(null==r)return!1;return n.join(r,2),t&&t(n),!0}catch{return!1}},iJ=()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=t9(e,n);if(!r)return!1;let s=ns(r);return!!s&&nt(e,s,t)})(e,t),iG=()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=ni(e,n);if(!r)return!1;let s=nl(r);return!!s&&nt(e,s,t)})(e,t);function iX(){return"u">typeof navigator&&/Mac/.test(navigator.platform)}var iY=e=>({editor:t,view:n,tr:r,dispatch:s})=>{let i=(function(e){let t,n,r,s,i=e.split(/-(?!$)/),o=i[i.length-1];"Space"===o&&(o=" ");for(let e=0;e<i.length-1;e+=1){let o=i[e];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else if(/^mod$/i.test(o))iR()||iX()?s=!0:n=!0;else throw Error(`Unrecognized modifier name: ${o}`)}return t&&(o=`Alt-${o}`),n&&(o=`Ctrl-${o}`),s&&(o=`Meta-${o}`),r&&(o=`Shift-${o}`),o})(e).split(/-(?!$)/),o=i.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{let t=e.map(r.mapping);t&&s&&r.maybeStep(t)}),!0};function iQ(e,t,n={}){let{from:r,to:s,empty:i}=e.selection,o=t?ig(t,e.schema):null,a=[];e.doc.nodesBetween(r,s,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),i=Math.min(s,t+e.nodeSize);a.push({node:e,from:n,to:i})});let l=s-r,d=a.filter(e=>!o||o.name===e.node.type.name).filter(e=>iS(e.node.attrs,n,{strict:!1}));return i?!!d.length:d.reduce((e,t)=>e+t.to-t.from,0)>=l}var iZ=(e,t={})=>({state:n,dispatch:r})=>{let s=ig(e,n.schema);return!!iQ(n,s,t)&&((e,t)=>{let{$from:n,$to:r}=e.selection,s=n.blockRange(r),i=s&&tx(s);return null!=i&&(t&&t(e.tr.lift(s,i).scrollIntoView()),!0)})(n,r)},i0=()=>({state:e,dispatch:t})=>np(e,t),i1=e=>({state:t,dispatch:n})=>{var r;return(r=ig(e,t.schema),function(e,t){let{$from:n,$to:s}=e.selection,i=n.blockRange(s,e=>e.childCount>0&&e.firstChild.type==r);return!!i&&(!t||(n.node(i.depth-1).type==r?function(e,t,n,r){let s=e.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new tf(i-1,o,i,o,new ek(eg.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new eD(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));let a=tx(r);if(null==a)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(i,-1)-1);return tS(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos),t(s.scrollIntoView()),!0}(e,t,r,i):function(e,t,n){let r=e.tr,s=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=s.child(t).nodeSize,r.delete(e-1,e+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==s.childCount,d=i.node(-1),c=i.index(-1);if(!d.canReplace(c+ +!a,c+1,o.content.append(l?eg.empty:eg.from(s))))return!1;let h=i.pos,u=h+o.nodeSize;return r.step(new tf(h-!!a,u+ +!!l,h+1,u-1,new ek((a?eg.empty:eg.from(s.copy(eg.empty))).append(l?eg.empty:eg.from(s.copy(eg.empty))),+!a,+!l),+!a)),t(r.scrollIntoView()),!0}(e,t,i)))})(t,n)},i2=()=>({state:e,dispatch:t})=>nd(e,t);function i3(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function i5(e,t){let n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var i4=(e,t)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null,a=i3("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(i=ig(e,r.schema)),"mark"===a&&(o=iT(e,r.schema));let l=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{i&&i===e.type&&(l=!0,s&&n.setNodeMarkup(r,void 0,i5(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(i=>{o===i.type&&(l=!0,s&&n.addMark(r,r+e.nodeSize,o.create(i5(i.attrs,t))))})})}),l},i6=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),i8=()=>({tr:e,dispatch:t})=>{if(t){let t=new tJ(e.doc);e.setSelection(t)}return!0},i7=()=>({state:e,dispatch:t})=>nr(e,t),i9=()=>({state:e,dispatch:t})=>na(e,t),oe=()=>({state:e,dispatch:t})=>((e,t)=>{let{$from:n,to:r}=e.selection,s,i=n.sharedDepth(r);return 0!=i&&(s=n.before(i),t&&t(e.tr.setSelection(tq.create(e.doc,s))),!0)})(e,t),ot=()=>({state:e,dispatch:t})=>nx(e,t),on=()=>({state:e,dispatch:t})=>ng(e,t);function or(e,t,n={},r={}){return iV(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var oi=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{let{doc:l}=i;if("full"!==r.preserveWhitespace){let a=or(e,s.schema,r,{errorOnInvalidContent:null!=t?t:s.options.enableContentCheck});return o&&i.replaceWith(0,l.content.size,a).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=t?t:s.options.enableContentCheck})};function oo(e,t){let n=iT(t,e.schema),{from:r,to:s,empty:i}=e.selection,o=[];i?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,s,e=>{o.push(...e.marks)});let a=o.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}function oa(e,t){let n=new tL(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function ol(e){return t=>(function(e,t){for(let n=e.depth;n>0;n-=1){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}})(t.$from,e)}function od(e,t,n){return void 0===e.config[t]&&e.parent?od(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind({...n,parent:e.parent?od(e.parent,t,n):null}):e.config[t]}function oc(e){return e.map(e=>{let t={name:e.name,options:e.options,storage:e.storage},n=od(e,"addExtensions",t);return n?[e,...oc(n())]:e}).flat(10)}function oh(e,t){let n=e8.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function ou(e){return"function"==typeof e}function op(e,t,...n){return ou(e)?t?e.bind(t)(...n):e(...n):e}function of(e){let t=e.filter(e=>"extension"===e.type);return{baseExtensions:t,nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function om(e){let t=[],{nodeExtensions:n,markExtensions:r}=of(e),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage,extensions:s},r=od(e,"addGlobalAttributes",n);r&&r().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...i,...r}})})})})}),s.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage},r=od(e,"addAttributes",n);r&&Object.entries(r()).forEach(([n,r])=>{let s={...i,...r};"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&(null==s?void 0:s.default)===void 0&&delete s.default,t.push({type:e.name,name:n,attribute:s})})}),t}function og(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if("class"===e){let r=t?String(t).split(" "):[],s=n[e]?n[e].split(" "):[],i=r.filter(e=>!s.includes(e));n[e]=[...s,...i].join(" ")}else if("style"===e){let r=t?t.split(";").map(e=>e.trim()).filter(Boolean):[],s=n[e]?n[e].split(";").map(e=>e.trim()).filter(Boolean):[],i=new Map;s.forEach(e=>{let[t,n]=e.split(":").map(e=>e.trim());i.set(t,n)}),r.forEach(e=>{let[t,n]=e.split(":").map(e=>e.trim());i.set(t,n)}),n[e]=Array.from(i.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t}),n},{})}function ox(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>og(e,t),{})}function oy(e,t){return"style"in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;let s=t.reduce((e,t)=>{var r;let s=t.attribute.parseHTML?t.attribute.parseHTML(n):"string"!=typeof(r=n.getAttribute(t.name))?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):"true"===r||"false"!==r&&r;return null==s?e:{...e,[t.name]:s}},{});return{...r,...s}}}}function ob(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!("attrs"===e&&function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t))}function ov(e){var t,n;let r={};return!(null==(t=null==e?void 0:e.attribute)?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(r.default=e.attribute.default),(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function ow(e){return e.sort((e,t)=>{let n=od(e,"priority")||100,r=od(t,"priority")||100;return n>r?-1:+(n<r)})}function ok(e){var t;let n=ow(oc(e)),r=Array.from(new Set((t=n.map(e=>e.name)).filter((e,n)=>t.indexOf(e)!==n)));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(e=>`'${e}'`).join(", ")}]. This can lead to issues.`),n}function oS(e,t,n){let{from:r,to:s}=t,{blockSeparator:i="\n\n",textSerializers:o={}}=n||{},a="";return e.nodesBetween(r,s,(e,n,l,d)=>{var c;e.isBlock&&n>r&&(a+=i);let h=null==o?void 0:o[e.type.name];if(h)return l&&(a+=h({node:e,pos:n,parent:l,index:d,range:t})),!1;e.isText&&(a+=null==(c=null==e?void 0:e.text)?void 0:c.slice(Math.max(r,n)-n,s-n))}),a}function oC(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function oM(e,t){let n=i3("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){let n=ig(t,e.schema),{from:r,to:s}=e.selection,i=[];e.doc.nodesBetween(r,s,e=>{i.push(e)});let o=i.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}(e,t):"mark"===n?oo(e,t):{}}function oN(e){let t,{mapping:n,steps:r}=e,s=[];return n.maps.forEach((e,t)=>{let i=[];if(e.ranges.length)e.forEach((e,t)=>{i.push({from:e,to:t})});else{let{from:e,to:n}=r[t];if(void 0===e||void 0===n)return;i.push({from:e,to:n})}i.forEach(({from:e,to:r})=>{let i=n.slice(t).map(e,-1),o=n.slice(t).map(r),a=n.invert().map(i,-1),l=n.invert().map(o);s.push({oldRange:{from:a,to:l},newRange:{from:i,to:o}})})}),1===(t=function(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(s)).length?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function oT(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let s=iN(n.resolve(e),t.type);s&&r.push({mark:t,...s})}):n.nodesBetween(e,t,(e,t)=>{e&&(null==e?void 0:e.nodeSize)!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function oj(e,t){return t.nodes[e]||t.marks[e]||null}function oO(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function oE(e,t,n={}){let{empty:r,ranges:s}=e.selection,i=t?iT(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!i||i.name===e.type.name).find(e=>iS(e.attrs,n,{strict:!1}));let o=0,a=[];if(s.forEach(({$from:t,$to:n})=>{let r=t.pos,s=n.pos;e.doc.nodesBetween(r,s,(e,t)=>{if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),i=Math.min(s,t+e.nodeSize);o+=i-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:i})))})}),0===o)return!1;let l=a.filter(e=>!i||i.name===e.mark.type.name).filter(e=>iS(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),d=a.filter(e=>!i||e.mark.type!==i&&e.mark.type.excludes(i)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+d:l)>=o}function oA(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function oI(e,t){let{nodeExtensions:n}=of(t),r=n.find(t=>t.name===e);if(!r)return!1;let s={name:r.name,options:r.options,storage:r.storage},i=op(od(r,"group",s));return"string"==typeof i&&i.split(" ").includes("list")}function oD(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!=(r=e.text)?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let r=!0;return e.content.forEach(e=>{!1!==r&&(oD(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function oR(e){return e instanceof tq}var oP=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function oz(e,t){let n=t.mapping.mapResult(e.position);return{position:new oP(n.pos),mapResult:n}}function o$(e){return new oP(e)}var oL=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let{selection:i}=n,{empty:o,ranges:a}=i,l=iT(e,r.schema);if(s)if(o){let e=oo(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{let s=e.$from.pos,i=e.$to.pos;r.doc.nodesBetween(s,i,(e,r)=>{let o=Math.max(r,s),a=Math.min(r+e.nodeSize,i);e.marks.find(e=>e.type===l)?e.marks.forEach(e=>{l===e.type&&n.addMark(o,a,l.create({...e.attrs,...t}))}):n.addMark(o,a,l.create(t))})});return function(e,t,n){var r;let{selection:s}=t,i=null;if(iE(s)&&(i=s.$cursor),i){let t=null!=(r=e.storedMarks)?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:o}=s;return o.some(({$from:t,$to:r})=>{let s=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(s)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),i=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));s=t&&i}return!s}),s})}(r,n,l)},oB=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),oV=(e,t={})=>({state:n,dispatch:r,chain:s})=>{let i,o=ig(e,n.schema);return(n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),o.isTextblock)?s().command(({commands:e})=>!!ny(o,{...i,...t})(n)||e.clearNodes()).command(({state:e})=>ny(o,{...i,...t})(e,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},oF=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=iA(e,0,n.content.size),s=tq.create(n,r);t.setSelection(s)}return!0},o_=(e,t)=>({tr:n,state:r,dispatch:s})=>{let i,o,{selection:a}=r;return"number"==typeof t?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=a.from,o=a.to),s&&n.doc.nodesBetween(i,o,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},oH=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:s}="number"==typeof e?{from:e,to:e}:e,i=tU.atStart(n).from,o=tU.atEnd(n).to,a=iA(r,i,o),l=iA(s,i,o),d=tU.create(n,a,l);t.setSelection(d)}return!0},oU=e=>({state:t,dispatch:n})=>{var r;return(r=ig(e,t.schema),function(e,t){let{$from:n,$to:s}=e.selection,i=n.blockRange(s,e=>e.childCount>0&&e.firstChild.type==r);if(!i)return!1;let o=i.startIndex;if(0==o)return!1;let a=i.parent,l=a.child(o-1);if(l.type!=r)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,s=eg.from(n?r.create():null),o=new ek(eg.from(r.create(null,eg.from(a.type.create(null,s)))),n?3:1,0),d=i.start,c=i.end;t(e.tr.step(new tf(d-(n?3:1),c,d,c,o,1,!0)).scrollIntoView())}return!0})(t,n)};function oW(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(r)}}var oq=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:s})=>{let{selection:i,doc:o}=t,{$from:a,$to:l}=i,d=oO(s.extensionManager.attributes,a.node().type.name,a.node().attrs);if(i instanceof tq&&i.node.isBlock)return!!a.parentOffset&&!!tk(o,a.pos)&&(r&&(e&&oW(n,s.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;let c=l.parentOffset===l.parent.content.size,h=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1))),u=c&&h?[{type:h,attrs:d}]:void 0,p=tk(t.doc,t.mapping.map(a.pos),1,u);if(!u&&!p&&tk(t.doc,t.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(p=!0,u=h?[{type:h,attrs:d}]:void 0),r){if(p&&(i instanceof tU&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,u),h&&!c&&!a.parentOffset&&a.parent.type!==h)){let e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,h)&&t.setNodeMarkup(t.mapping.map(a.before()),h)}e&&oW(n,s.extensionManager.splittableMarks),t.scrollIntoView()}return p},oK=(e,t={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;let a=ig(e,r.schema),{$from:l,$to:d}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(d))return!1;let h=l.node(-1);if(h.type!==a)return!1;let u=i.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let e=eg.empty,r=l.index(-1)?1:l.index(-2)?2:3;for(let t=l.depth-r;t>=l.depth-3;t-=1)e=eg.from(l.node(t).copy(e));let s=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,i={...oO(u,l.node().type.name,l.node().attrs),...t},d=(null==(o=a.contentMatch.defaultType)?void 0:o.createAndFill(i))||void 0;e=e.append(eg.from(a.createAndFill(null,d)||void 0));let c=l.before(l.depth-(r-1));n.replace(c,l.after(-s),new ek(e,4-r,0));let h=-1;n.doc.nodesBetween(c,n.doc.content.size,(e,t)=>{if(h>-1)return!1;e.isTextblock&&0===e.content.size&&(h=t+1)}),h>-1&&n.setSelection(tU.near(n.doc.resolve(h))),n.scrollIntoView()}return!0}let p=d.pos===l.end()?h.contentMatchAt(0).defaultType:null,f={...oO(u,h.type.name,h.attrs),...t},m={...oO(u,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,d.pos);let g=p?[{type:a,attrs:f},{type:p,attrs:m}]:[{type:a,attrs:f}];if(!tk(n.doc,l.pos,2))return!1;if(s){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=i.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!s)return!0;let d=a.filter(e=>o.includes(e.type.name));n.ensureMarks(d)}return!0},oJ=(e,t)=>{let n=ol(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;let s=e.doc.nodeAt(r);return!(n.node.type===(null==s?void 0:s.type)&&tS(e.doc,n.pos))||(e.join(n.pos),!0)},oG=(e,t)=>{let n=ol(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;let s=e.doc.nodeAt(r);return!(n.node.type===(null==s?void 0:s.type)&&tS(e.doc,r))||(e.join(r),!0)},oX=(e,t,n,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:d,can:c})=>{let{extensions:h,splittableMarks:u}=s.extensionManager,p=ig(e,o.schema),f=ig(t,o.schema),{selection:m,storedMarks:g}=o,{$from:x,$to:y}=m,b=x.blockRange(y),v=g||m.$to.parentOffset&&m.$from.marks();if(!b)return!1;let w=ol(e=>oI(e.type.name,h))(m);if(b.depth>=1&&w&&b.depth-w.depth<=1){if(w.node.type===p)return d.liftListItem(f);if(oI(w.node.type.name,h)&&p.validContent(w.node.content)&&a)return l().command(()=>(i.setNodeMarkup(w.pos,p),!0)).command(()=>oJ(i,p)).command(()=>oG(i,p)).run()}return n&&v&&a?l().command(()=>{let e=c().wrapInList(p,r),t=v.filter(e=>u.includes(e.type.name));return i.ensureMarks(t),!!e||d.clearNodes()}).wrapInList(p,r).command(()=>oJ(i,p)).command(()=>oG(i,p)).run():l().command(()=>!!c().wrapInList(p,r)||d.clearNodes()).wrapInList(p,r).command(()=>oJ(i,p)).command(()=>oG(i,p)).run()},oY=(e,t={},n={})=>({state:r,commands:s})=>{let{extendEmptyMarkRange:i=!1}=n,o=iT(e,r.schema);return oE(r,o,t)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,t)},oQ=(e,t,n={})=>({state:r,commands:s})=>{let i,o=ig(e,r.schema),a=ig(t,r.schema),l=iQ(r,o,n);return(r.selection.$anchor.sameParent(r.selection.$head)&&(i=r.selection.$anchor.parent.attrs),l)?s.setNode(a,i):s.setNode(o,{...i,...n})},oZ=(e,t={})=>({state:n,commands:r})=>{let s=ig(e,n.schema);return iQ(n,s,t)?r.lift(s):r.wrapIn(s,t)},o0=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let s,i=n[r];if(i.spec.isInputRules&&(s=i.getState(e))){if(t){let t=e.tr,n=s.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(s.text){let n=t.doc.resolve(s.from).marks();t.replaceWith(s.from,s.to,e.schema.text(s.text,n))}else t.delete(s.from,s.to)}return!0}}return!1},o1=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:s}=n;return!!r||(t&&s.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0)},o2=(e,t={})=>({tr:n,state:r,dispatch:s})=>{var i;let{extendEmptyMarkRange:o=!1}=t,{selection:a}=n,l=iT(e,r.schema),{$from:d,empty:c,ranges:h}=a;if(!s)return!0;if(c&&o){let{from:e,to:t}=a,r=null==(i=d.marks().find(e=>e.type===l))?void 0:i.attrs,s=iN(d,l,r);s&&(e=s.from,t=s.to),n.removeMark(e,t,l)}else h.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},o3=e=>({tr:t,state:n,dispatch:r})=>{let s,i,{selection:o}=n;return"number"==typeof e?(s=e,i=e):e&&"from"in e&&"to"in e?(s=e.from,i=e.to):(s=o.from,i=o.to),r&&t.doc.nodesBetween(s,i,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},o5=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null,a=i3("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(i=ig(e,r.schema)),"mark"===a&&(o=iT(e,r.schema));let l=!1;return n.selection.ranges.forEach(e=>{let a,d,c,h,u=e.$from.pos,p=e.$to.pos;n.selection.empty?r.doc.nodesBetween(u,p,(e,t)=>{i&&i===e.type&&(l=!0,c=Math.max(t,u),h=Math.min(t+e.nodeSize,p),a=t,d=e)}):r.doc.nodesBetween(u,p,(e,r)=>{r<u&&i&&i===e.type&&(l=!0,c=Math.max(r,u),h=Math.min(r+e.nodeSize,p),a=r,d=e),r>=u&&r<=p&&(i&&i===e.type&&(l=!0,s&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(i=>{if(o===i.type&&(l=!0,s)){let s=Math.max(r,u),a=Math.min(r+e.nodeSize,p);n.addMark(s,a,o.create({...i.attrs,...t}))}}))}),d&&(void 0!==a&&s&&n.setNodeMarkup(a,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&s&&n.addMark(c,h,o.create({...e.attrs,...t}))}))}),l},o4=(e,t={})=>({state:n,dispatch:r})=>(function(e,t=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),a=o&&ty(o,e,t);return!!a&&(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0)}})(ig(e,n.schema),t)(n,r),o6=(e,t={})=>({state:n,dispatch:r})=>(function(e,t=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let a=r?n.tr:null;return!!function(e,t,n,r=null){let s=!1,i=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=o.resolve(t.start-2);i=new eD(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new eD(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),s=!0}let a=ty(i,n,r,t);return!!a&&(e&&function(e,t,n,r,s){let i=eg.empty;for(let e=n.length-1;e>=0;e--)i=eg.from(n[e].type.create(n[e].attrs,i));e.step(new tf(t.start-2*!!r,t.end,t.start,t.end,new ek(i,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==s&&(o=e+1);let a=n.length-o,l=t.start+n.length-2*!!r,d=t.parent;for(let n=t.startIndex,r=t.endIndex,s=!0;n<r;n++,s=!1)!s&&tk(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=d.child(n).nodeSize}(e,t,a,s,n),!0)}(a,o,e,t)&&(r&&r(a.scrollIntoView()),!0)}})(ig(e,n.schema),t)(n,r),o8=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},o7=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=null==(t=e.undoable)||t}};function o9(e){var t;let{editor:n,from:r,to:s,text:i,rules:o,plugin:a}=e,{view:l}=n;if(l.composing)return!1;let d=l.state.doc.resolve(r);if(d.parent.type.spec.code||(null==(t=d.nodeBefore||d.nodeAfter)?void 0:t.marks.find(e=>e.type.spec.code)))return!1;let c=!1,h=((e,t=500)=>{let n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,s,i)=>{var o,a;let l=(null==(a=(o=e.type.spec).toText)?void 0:a.call(o,{node:e,pos:t,parent:s,index:i}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?l:l.slice(0,Math.max(0,r-t))}),n})(d)+i;return o.forEach(e=>{if(c)return;let t=((e,t)=>{if(ik(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(h,e.find);if(!t)return;let o=l.state.tr,d=ii({state:l.state,transaction:o}),u={from:r-(t[0].length-i.length),to:s},{commands:p,chain:f,can:m}=new io({editor:n,state:d});null!==e.handler({state:d,range:u,match:t,commands:p,chain:f,can:m})&&o.steps.length&&(e.undoable&&o.setMeta(a,{transform:o,from:r,to:s,text:i}),l.dispatch(o),c=!0)}),c}function ae(e){return"Object"===Object.prototype.toString.call(e).slice(8,-1)&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}var at=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...op(od(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...op(od(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>(function e(t,n){let r={...t};return ae(t)&&ae(n)&&Object.keys(n).forEach(s=>{ae(n[s])&&ae(t[s])?r[s]=e(t[s],n[s]):r[s]=n[s]}),r})(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},an=class e extends at{constructor(){super(...arguments),this.type="mark"}static create(t={}){return new e("function"==typeof t?t():t)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let s=r.marks();if(!s.find(e=>(null==e?void 0:e.type.name)===t.name))return!1;let i=s.find(e=>(null==e?void 0:e.type.name)===t.name);return i&&n.removeStoredMark(i),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t="function"==typeof e?e():e;return super.extend(t)}},ar=class{constructor(e){this.find=e.find,this.handler=e.handler}},as=null,ai=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=ok(e),this.schema=function(e,t){var n;let r=om(e),{nodeExtensions:s,markExtensions:i}=of(e),o=null==(n=s.find(e=>od(e,"topNode")))?void 0:n.name;return new eX({topNode:o,nodes:Object.fromEntries(s.map(n=>{let s=r.filter(e=>e.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:t},o=ob({...e.reduce((e,t)=>{let r=od(t,"extendNodeSchema",i);return{...e,...r?r(n):{}}},{}),content:op(od(n,"content",i)),marks:op(od(n,"marks",i)),group:op(od(n,"group",i)),inline:op(od(n,"inline",i)),atom:op(od(n,"atom",i)),selectable:op(od(n,"selectable",i)),draggable:op(od(n,"draggable",i)),code:op(od(n,"code",i)),whitespace:op(od(n,"whitespace",i)),linebreakReplacement:op(od(n,"linebreakReplacement",i)),defining:op(od(n,"defining",i)),isolating:op(od(n,"isolating",i)),attrs:Object.fromEntries(s.map(ov))}),a=op(od(n,"parseHTML",i));a&&(o.parseDOM=a.map(e=>oy(e,s)));let l=od(n,"renderHTML",i);l&&(o.toDOM=e=>l({node:e,HTMLAttributes:ox(e,s)}));let d=od(n,"renderText",i);return d&&(o.toText=d),[n.name,o]})),marks:Object.fromEntries(i.map(n=>{let s=r.filter(e=>e.type===n.name),i={name:n.name,options:n.options,storage:n.storage,editor:t},o=ob({...e.reduce((e,t)=>{let r=od(t,"extendMarkSchema",i);return{...e,...r?r(n):{}}},{}),inclusive:op(od(n,"inclusive",i)),excludes:op(od(n,"excludes",i)),group:op(od(n,"group",i)),spanning:op(od(n,"spanning",i)),code:op(od(n,"code",i)),attrs:Object.fromEntries(s.map(ov))}),a=op(od(n,"parseHTML",i));a&&(o.parseDOM=a.map(e=>oy(e,s)));let l=od(n,"renderHTML",i);return l&&(o.toDOM=e=>l({mark:e,HTMLAttributes:ox(e,s)})),[n.name,o]}))})}(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:oj(t.name,this.schema)},r=od(t,"addCommands",n);return r?{...e,...r()}:e},{})}get plugins(){let{editor:e}=this;return ow([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:oj(t.name,this.schema)},r=[],s=od(t,"addKeyboardShortcuts",n),i={};if("mark"===t.type&&od(t,"exitable",n)&&(i.ArrowRight=()=>an.handleExit({editor:e,mark:t})),s){let t=Object.fromEntries(Object.entries(s()).map(([t,n])=>[t,()=>n({editor:e})]));i={...i,...t}}let o=new t5({props:{handleKeyDown:it(i)}});r.push(o);let a=od(t,"addInputRules",n);if(oA(t,e.options.enableInputRules)&&a){let t=a();if(t&&t.length){let n=function(e){let{editor:t,rules:n}=e,r=new t5({state:{init:()=>null,apply(e,s,i){let o=e.getMeta(r);if(o)return o;let a=e.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:e}=a;"string"==typeof e||(e=oh(eg.from(e),i.schema));let{from:s}=a,o=s+e.length;o9({editor:t,from:s,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:s}},props:{handleTextInput:(e,s,i,o)=>o9({editor:t,from:s,to:i,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:s}=e.state.selection;s&&o9({editor:t,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(e,s){if("Enter"!==s.key)return!1;let{$cursor:i}=e.state.selection;return!!i&&o9({editor:t,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:e,rules:t}),s=Array.isArray(n)?n:[n];r.push(...s)}}let l=od(t,"addPasteRules",n);if(oA(t,e.options.enablePasteRules)&&l){let t=l();if(t&&t.length){let n=function(e){let t,{editor:n,rules:r}=e,s=null,i=!1,o=!1,a="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="u">typeof DragEvent?new DragEvent("drop"):null}catch{t=null}let l=({state:e,from:r,to:s,rule:i,pasteEvt:o})=>{let l=e.tr;if(function(e){let{editor:t,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=e,{commands:l,chain:d,can:c}=new io({editor:t,state:n}),h=[];return n.doc.nodesBetween(r,s,(e,t)=>{var u,p,f,m,g;if((null==(p=null==(u=e.type)?void 0:u.spec)?void 0:p.code)||!(e.isText||e.isTextblock||e.isInline))return;let x=null!=(g=null!=(m=null==(f=e.content)?void 0:f.size)?m:e.nodeSize)?g:0,y=Math.max(r,t),b=Math.min(s,t+x);y>=b||((e,t,n)=>{if(ik(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(y-t,b-t,void 0,""),i.find,o).forEach(e=>{if(void 0===e.index)return;let t=y+e.index+1,r=t+e[0].length,s={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},u=i.handler({state:n,range:s,match:e,commands:l,chain:d,can:c,pasteEvent:o,dropEvent:a});h.push(u)})}),h.every(e=>null!==e)}({editor:n,state:ii({state:e,transaction:l}),from:Math.max(r-1,0),to:s.b-1,rule:i,pasteEvent:o,dropEvent:t})&&l.steps.length){try{t="u">typeof DragEvent?new DragEvent("drop"):null}catch{t=null}return a="u">typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}};return r.map(e=>new t5({view(e){let t=t=>{var r;(s=(null==(r=e.dom.parentElement)?void 0:r.contains(t.target))?e.dom.parentElement:null)&&(as=n)},r=()=>{as&&(as=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",r),{destroy(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:(e,n)=>{if(o=s===e.dom.parentElement,t=n,!o){let e=as;(null==e?void 0:e.isEditable)&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{var n;let r=null==(n=t.clipboardData)?void 0:n.getData("text/html");return a=t,i=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],d="paste"===s.getMeta("uiEvent")&&!i,c="drop"===s.getMeta("uiEvent")&&!o,h=s.getMeta("applyPasteRules"),u=!!h;if(!d&&!c&&!u)return;if(u){var p,f;let t,{text:n}=h;"string"==typeof n||(n=oh(eg.from(n),r.schema));let{from:s}=h,i=s+n.length;return l({rule:e,state:r,from:s,to:{b:i},pasteEvt:(p=n,null==(f=(t=new ClipboardEvent("paste",{clipboardData:new DataTransfer})).clipboardData)||f.setData("text/html",p),t)})}let m=n.doc.content.findDiffStart(r.doc.content),g=n.doc.content.findDiffEnd(r.doc.content);if("number"==typeof m&&g&&m!==g.b)return l({rule:e,state:r,from:m,to:g,pasteEvt:a})}}))}({editor:e,rules:t});r.push(...n)}}let d=od(t,"addProseMirrorPlugins",n);if(d){let e=d();r.push(...e)}return r})}get attributes(){return om(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=of(this.extensions);return Object.fromEntries(t.filter(e=>!!od(e,"addNodeView")).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:ig(t.name,this.schema)},s=od(t,"addNodeView",r);if(!s)return[];let i=s();return i?[t.name,(r,s,o,a,l)=>{let d=ox(r,n);return i({node:r,view:s,getPos:o,decorations:a,innerDecorations:l,editor:e,extension:t,HTMLAttributes:d})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return ow([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:oj(n.name,this.schema)},s=od(n,"dispatchTransaction",r);return s?t=>{s.call(r,{transaction:t,next:e})}:e},e)}get markViews(){let{editor:e}=this,{markExtensions:t}=of(this.extensions);return Object.fromEntries(t.filter(e=>!!od(e,"addMarkView")).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:iT(t.name,this.schema)},s=od(t,"addMarkView",r);return s?[t.name,(r,i,o)=>{let a=ox(r,n);return s()({mark:r,view:i,inline:o,editor:e,extension:t,HTMLAttributes:a,updateAttributes:t=>{!function(e,t,n={}){let{state:r}=t,{doc:s,tr:i}=r;s.descendants((t,r)=>{let s=i.mapping.map(r),o=i.mapping.map(r)+t.nodeSize,a=null;if(t.marks.forEach(t=>{if(t!==e)return!1;a=t}),!a)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==a.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});i.removeMark(s,o,e.type),i.addMark(s,o,t)}}),i.docChanged&&t.view.dispatch(i)}(r,e,t)}})}]:[]}))}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{var t;let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:oj(e.name,this.schema)};"mark"===e.type&&(null==(t=op(od(e,"keepOnSplit",n)))||t)&&this.splittableMarks.push(e.name);let r=od(e,"onBeforeCreate",n),s=od(e,"onCreate",n),i=od(e,"onUpdate",n),o=od(e,"onSelectionUpdate",n),a=od(e,"onTransaction",n),l=od(e,"onFocus",n),d=od(e,"onBlur",n),c=od(e,"onDestroy",n);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),i&&this.editor.on("update",i),o&&this.editor.on("selectionUpdate",o),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),d&&this.editor.on("blur",d),c&&this.editor.on("destroy",c)})}};ai.resolve=ok,ai.sort=ow,ai.flatten=oc,is({},{ClipboardTextSerializer:()=>aa,Commands:()=>al,Delete:()=>ad,Drop:()=>ac,Editable:()=>ah,FocusEvents:()=>ap,Keymap:()=>af,Paste:()=>am,Tabindex:()=>ag,TextDirection:()=>ax,focusEventsPluginKey:()=>au});var ao=class e extends at{constructor(){super(...arguments),this.type="extension"}static create(t={}){return new e("function"==typeof t?t():t)}configure(e){return super.configure(e)}extend(e){let t="function"==typeof e?e():e;return super.extend(t)}},aa=ao.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new t5({key:new t8("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:s}=t,{ranges:i}=s,o=Math.min(...i.map(e=>e.$from.pos)),a=Math.max(...i.map(e=>e.$to.pos)),l=oC(n);return oS(r,{from:o,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),al=ao.create({name:"commands",addCommands:()=>({...ia})}),ad=ao.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r,s;let i=()=>{var n,r,s,i;if(null!=(i=null==(s=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:s.call(r,e))?i:e.getMeta("y-sync$"))return;let o=oa(e.before,[e,...t]);oN(o).forEach(t=>{o.mapping.mapResult(t.oldRange.from).deletedAfter&&o.mapping.mapResult(t.oldRange.to).deletedBefore&&o.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let s=r+n.nodeSize-2,i=t.oldRange.from<=r&&s<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:s,newFrom:o.mapping.map(r),newTo:o.mapping.map(s),deletedRange:t.oldRange,newRange:t.newRange,partial:!i,editor:this.editor,transaction:e,combinedTransform:o})})});let a=o.mapping;o.steps.forEach((t,n)=>{var r,s;if(t instanceof tc){let i=a.slice(n).map(t.from,-1),l=a.slice(n).map(t.to),d=a.invert().map(i,-1),c=a.invert().map(l),h=null==(r=o.doc.nodeAt(i-1))?void 0:r.marks.some(e=>e.eq(t.mark)),u=null==(s=o.doc.nodeAt(l))?void 0:s.marks.some(e=>e.eq(t.mark));this.editor.emit("delete",{type:"mark",mark:t.mark,from:t.from,to:t.to,deletedRange:{from:d,to:c},newRange:{from:i,to:l},partial:!!(u||h),editor:this.editor,transaction:e,combinedTransform:o})}})};null==(s=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||s?setTimeout(i,0):i()}}),ac=ao.create({name:"drop",addProseMirrorPlugins(){return[new t5({key:new t8("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),ah=ao.create({name:"editable",addProseMirrorPlugins(){return[new t5({key:new t8("editable"),props:{editable:()=>this.editor.options.editable}})]}}),au=new t8("focusEvents"),ap=ao.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new t5({key:au,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),af=ao.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:s,$anchor:i}=n,{pos:o,parent:a}=i,l=i.parent.isTextblock&&o>0?t.doc.resolve(o-1):i,d=l.parent.type.spec.isolating,c=i.pos-i.parentOffset,h=d&&1===l.parent.childCount?c===i.pos:tV.atStart(r).from===o;return!!s&&!!a.type.isTextblock&&!a.textContent.length&&!!h&&(!h||"paragraph"!==i.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},s={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return iR()||iX()?s:r},addProseMirrorPlugins(){return[new t5({key:new t8("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),s=e.some(e=>e.getMeta("preventClearDocument"));if(!r||s)return;let{empty:i,from:o,to:a}=t.selection,l=tV.atStart(t.doc).from,d=tV.atEnd(t.doc).to;if(i||o!==l||a!==d||!oD(n.doc))return;let c=n.tr,h=ii({state:n,transaction:c}),{commands:u}=new io({editor:this.editor,state:h});if(u.clearNodes(),c.steps.length)return c}})]}}),am=ao.create({name:"paste",addProseMirrorPlugins(){return[new t5({key:new t8("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),ag=ao.create({name:"tabindex",addProseMirrorPlugins(){return[new t5({key:new t8("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ax=ao.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=of(this.extensions);return[{types:e.filter(e=>"text"!==e.name).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute("dir");return t&&("ltr"===t||"rtl"===t||"auto"===t)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new t5({key:new t8("textDirection"),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),ay=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}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 e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=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}`);t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}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 t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,a=this.pos+r+ +!i;if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;let l=this.resolvedPos.doc.resolve(a);if(!s&&!o&&l.depth<=this.depth)return;let d=new e(l,this.editor,s,s||o?n:null);s&&(d.actualDepth=this.depth+1),t.push(d)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let s=n[r];if(e[s]!==t[s])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;let s=Object.keys(t);return this.children.forEach(i=>{n&&r.length>0||(i.node.type.name===e&&s.every(e=>t[e]===i.node.attrs[e])&&r.push(i),n&&r.length>0||(r=r.concat(i.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},ab=`.ProseMirror {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.ProseMirror {
|
|
6
|
+
word-wrap: break-word;
|
|
7
|
+
white-space: pre-wrap;
|
|
8
|
+
white-space: break-spaces;
|
|
9
|
+
-webkit-font-variant-ligatures: none;
|
|
10
|
+
font-variant-ligatures: none;
|
|
11
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.ProseMirror [contenteditable="false"] {
|
|
15
|
+
white-space: normal;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
19
|
+
white-space: pre-wrap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.ProseMirror pre {
|
|
23
|
+
white-space: pre-wrap;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
img.ProseMirror-separator {
|
|
27
|
+
display: inline !important;
|
|
28
|
+
border: none !important;
|
|
29
|
+
margin: 0 !important;
|
|
30
|
+
width: 0 !important;
|
|
31
|
+
height: 0 !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ProseMirror-gapcursor {
|
|
35
|
+
display: none;
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
position: absolute;
|
|
38
|
+
margin: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ProseMirror-gapcursor:after {
|
|
42
|
+
content: "";
|
|
43
|
+
display: block;
|
|
44
|
+
position: absolute;
|
|
45
|
+
top: -2px;
|
|
46
|
+
width: 20px;
|
|
47
|
+
border-top: 1px solid black;
|
|
48
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@keyframes ProseMirror-cursor-blink {
|
|
52
|
+
to {
|
|
53
|
+
visibility: hidden;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ProseMirror-hideselection *::selection {
|
|
58
|
+
background: transparent;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
62
|
+
background: transparent;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ProseMirror-hideselection * {
|
|
66
|
+
caret-color: transparent;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
70
|
+
display: block;
|
|
71
|
+
}`,av=class extends o8{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"u">typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:oz,createMappablePosition:o$},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on("paste",({event:e,slice:t})=>this.options.onPaste(e,t)),this.on("delete",this.options.onDelete);const t=this.createDoc(),n=iI(t,this.options.autofocus);this.editorState=t3.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if("u"<typeof document)throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"u">typeof document&&(this.css=function(e,t,n){let r=document.querySelector("style[data-tiptap-style]");if(null!==r)return r;let s=document.createElement("style");return t&&s.setAttribute("nonce",t),s.setAttribute("data-tiptap-style",""),s.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(s),s}(ab,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if("state"===t)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=ou(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[ah,aa.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),al,ap,af,ag,ac,am,ad,ax.configure({direction:this.options.textDirection})].filter(e=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[e.name]):[],...this.options.extensions].filter(e=>["extension","node","mark"].includes(null==e?void 0:e.type));this.extensionManager=new ai(n,this)}createCommandManager(){this.commandManager=new io({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=or(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>"collaboration"!==e.name),this.createExtensionManager()}}),e=or(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new sX(e,{...t,attributes:{role:"textbox",...null==t?void 0:t.attributes},dispatchTransaction:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>{var t;return null==(t=this.capturedTransaction)?void 0:t.step(e)});return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),s=n.includes(e),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!s)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta("focus")||e.getMeta("blur")),a=null==o?void 0:o.getMeta("focus"),l=null==o?void 0:o.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:o}),l&&this.emit("blur",{editor:this,event:l.event,transaction:o}),e.getMeta("preventUpdate")||!n.some(e=>e.docChanged)||i.doc.eq(t.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return oM(this.state,e)}isActive(e,t){let n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return iQ(e,null,n)||oE(e,null,n);let r=i3(t,e.schema);return"node"===r?iQ(e,t,n):"mark"===r&&oE(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return oh(this.state.doc.content,this.schema)}getText(e){var t,n;let r,{blockSeparator:s="\n\n",textSerializers:i={}}=e||{};return t=this.state.doc,n={blockSeparator:s,textSerializers:{...oC(this.schema),...i}},r={from:0,to:t.content.size},oS(t,r,n)}get isEmpty(){return oD(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}$node(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}$pos(e){return new ay(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function aw(e){return new o7({find:e.find,handler:({state:t,range:n,match:r})=>{let s=op(e.getAttributes,void 0,r);if(!1===s||null===s)return null;let{tr:i}=t,o=r[r.length-1],a=r[0];if(o){let r=a.search(/\S/),l=n.from+a.indexOf(o),d=l+o.length;if(oT(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>l).length)return null;d<n.to&&i.delete(d,n.to),l>n.from&&i.delete(n.from+r,l);let c=n.from+r+o.length;i.addMark(n.from+r,c,e.type.create(s||{})),i.removeStoredMark(e.type)}},undoable:e.undoable})}function ak(e){return new o7({find:e.find,handler:({state:t,range:n,match:r})=>{let s=t.doc.resolve(n.from),i=op(e.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,i)},undoable:e.undoable})}function aS(e){return new o7({find:e.find,handler:({state:t,range:n,match:r,chain:s})=>{let i=op(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),l=a&&ty(a,e.type,i);if(!l)return null;if(o.wrap(a,l),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:s}=e.editor.extensionManager,i=r||n.$to.parentOffset&&n.$from.marks();if(i){let e=i.filter(e=>s.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";s().updateAttributes(t,i).run()}let d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===e.type&&tS(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,d))&&o.join(n.from-1)},undoable:e.undoable})}function aC(e){if(!(null==e?void 0:e.trim()))return{};let t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);s&&(t.class=s.map(e=>e.trim().slice(1)).join(" "));let i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(t.id=i[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{var s;let i=n[parseInt((null==(s=r.match(/__QUOTED_(\d+)__/))?void 0:s[1])||"0",10)];i&&(t[e]=i.slice(1,-1))});let o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return o&&o.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function aM(e){if(!e||0===Object.keys(e).length)return"";let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{"class"!==e&&"id"!==e&&(!0===n?t.push(e):!1!==n&&null!=n&&t.push(`${e}="${String(n)}"`))}),t.join(" ")}function aN(e){let{nodeName:t,name:n,parseAttributes:r=aC,serializeAttributes:s=aM,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:a}=e,l=n||t;return{parseMarkdown:(e,n)=>{let r={...i,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"block",start(e){var t;let n=RegExp(`^:::${l}(?:\\s|$)`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,s){let i=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),a=e.match(i);if(!a)return;let d=r(a[1]||"");if(!o.find(e=>!(e in d)))return{type:t,raw:a[0],attributes:d}}},renderMarkdown:e=>{let t=s((e=>{if(!a)return e;let t={};return a.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{})),n=t?` {${t}}`:"";return`:::${l}${n} :::`}}}function aT(e){let{nodeName:t,name:n,getContent:r,parseAttributes:s=aC,serializeAttributes:i=aM,defaultAttributes:o={},content:a="block",allowedAttributes:l}=e,d=n||t;return{parseMarkdown:(e,n)=>{let s;if(r){let t=r(e);s="string"==typeof t?[{type:"text",text:t}]:t}else s="block"===a?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let i={...o,...e.attributes};return n.createNode(t,i,s)},markdownTokenizer:{name:t,level:"block",start(e){var t;let n=RegExp(`^:::${d}`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,r){var i;let o=RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),l=e.match(o);if(!l)return;let[c,h=""]=l,u=s(h),p=1,f=c.length,m="",g=/^:::([\w-]*)(\s.*)?/gm,x=e.slice(f);for(g.lastIndex=0;;){let n=g.exec(x);if(null===n)break;let s=n.index,o=n[1];if(null==(i=n[2])||!i.endsWith(":::")){if(o)p+=1;else if(0==(p-=1)){let i=x.slice(0,s);m=i.trim();let o=e.slice(0,f+s+n[0].length),l=[];if(m)if("block"===a)for((l=r.blockTokens(i)).forEach(e=>{e.text&&(!e.tokens||0===e.tokens.length)&&(e.tokens=r.inlineTokens(e.text))});l.length>0;){let e=l[l.length-1];if("paragraph"!==e.type||e.text&&""!==e.text.trim())break;l.pop()}else l=r.inlineTokens(m);return{type:t,raw:o,attributes:u,content:m,tokens:l}}}}}},renderMarkdown:(e,t)=>{let n=i((e=>{if(!l)return e;let t={};return l.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{})),r=n?` {${n}}`:"",s=t.renderChildren(e.content||[],"\n\n");return`:::${d}${r}
|
|
72
|
+
|
|
73
|
+
${s}
|
|
74
|
+
|
|
75
|
+
:::`}}}function aj(e){if(!e.trim())return{};let t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;null!==r;){let[,s,i,o]=r;t[s]=i||o,r=n.exec(e)}return t}function aO(e){return Object.entries(e).filter(([,e])=>null!=e).map(([e,t])=>`${e}="${t}"`).join(" ")}function aE(e){let{nodeName:t,name:n,getContent:r,parseAttributes:s=aj,serializeAttributes:i=aO,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=e,d=n||t,c=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(e,n)=>{let s={...o,...e.attributes};if(a)return n.createNode(t,s);let i=r?r(e):e.content||"";return i?n.createNode(t,s,[n.createTextNode(i)]):n.createNode(t,s,[])},markdownTokenizer:{name:t,level:"inline",start(e){let t=a?RegExp(`\\[${c}\\s*[^\\]]*\\]`):RegExp(`\\[${c}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${c}\\]`),n=e.match(t),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize(e,n,r){let i=a?RegExp(`^\\[${c}\\s*([^\\]]*)\\]`):RegExp(`^\\[${c}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${c}\\]`),o=e.match(i);if(!o)return;let l="",d="";if(a){let[,e]=o;d=e}else{let[,e,t]=o;d=e,l=t||""}let h=s(d.trim());return{type:t,raw:o[0],content:l.trim(),attributes:h}}},renderMarkdown:e=>{let t="";r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>"text"===e.type).map(e=>e.text).join(""));let n=i((e=>{if(!l)return e;let t={};return l.forEach(n=>{let r="string"==typeof n?n:n.name,s="string"==typeof n?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(void 0!==s&&n===s)return;t[r]=n}}),t})(e.attrs||{})),s=n?` ${n}`:"";return a?`[${d}${s}]`:`[${d}${s}]${t}[/${d}]`}}}function aA(e,t,n){var r,s,i,o;let a=e.split("\n"),l=[],d="",c=0,h=t.baseIndentSize||2;for(;c<a.length;){let e,u=a[c],p=u.match(t.itemPattern);if(!p)if(l.length>0)break;else{if(""!==u.trim())return;c+=1,d=`${d}${u}
|
|
76
|
+
`;continue}let f=t.extractItemData(p),{indentLevel:m,mainContent:g}=f;d=`${d}${u}
|
|
77
|
+
`;let x=[g];for(c+=1;c<a.length;){let e=a[c];if(""===e.trim()){let t=a.slice(c+1).findIndex(e=>""!==e.trim());if(-1===t)break;if(((null==(s=null==(r=a[c+1+t].match(/^(\s*)/))?void 0:r[1])?void 0:s.length)||0)>m){x.push(e),d=`${d}${e}
|
|
78
|
+
`,c+=1;continue}break}if(((null==(o=null==(i=e.match(/^(\s*)/))?void 0:i[1])?void 0:o.length)||0)>m)x.push(e),d=`${d}${e}
|
|
79
|
+
`,c+=1;else break}let y=x.slice(1);if(y.length>0){let r=y.map(e=>e.slice(m+h)).join("\n");r.trim()&&(e=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let b=t.createToken(f,e);l.push(b)}if(0!==l.length)return{items:l,raw:d}}function aI(e,t,n,r){if(!e||!Array.isArray(e.content))return"";let s="function"==typeof n?n(r):n,[i,...o]=e.content,a=t.renderChildren([i]),l=[`${s}${a}`];return o&&o.length>0&&o.forEach(e=>{let n=t.renderChildren([e]);if(n){let e=n.split("\n").map(e=>e?t.indent(e):"").join("\n");l.push(e)}}),l.join("\n")}is({},{createAtomBlockMarkdownSpec:()=>aN,createBlockMarkdownSpec:()=>aT,createInlineMarkdownSpec:()=>aE,parseAttributes:()=>aC,parseIndentedBlocks:()=>aA,renderNestedMarkdownContent:()=>aI,serializeAttributes:()=>aM});var aD=class e extends at{constructor(){super(...arguments),this.type="node"}static create(t={}){return new e("function"==typeof t?t():t)}configure(e){return super.configure(e)}extend(e){let t="function"==typeof e?e():e;return super.extend(t)}};function aR(e){return new ar({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:s})=>{let i=op(e.getAttributes,void 0,r,s);if(!1===i||null===i)return null;let{tr:o}=t,a=r[r.length-1],l=r[0],d=n.to;if(a){let r=l.search(/\S/),s=n.from+l.indexOf(a),c=s+a.length;if(oT(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>s).length)return null;c<n.to&&o.delete(c,n.to),s>n.from&&o.delete(n.from+r,s),d=n.from+r+a.length,o.addMark(n.from+r,d,e.type.create(i||{})),o.removeStoredMark(e.type)}}})}let{getOwnPropertyNames:aP,getOwnPropertySymbols:az}=Object,{hasOwnProperty:a$}=Object.prototype;function aL(e,t){return function(n,r,s){return e(n,r,s)&&t(n,r,s)}}function aB(e){return function(t,n,r){if(!t||!n||"object"!=typeof t||"object"!=typeof n)return e(t,n,r);let{cache:s}=r,i=s.get(t),o=s.get(n);if(i&&o)return i===n&&o===t;s.set(t,n),s.set(n,t);let a=e(t,n,r);return s.delete(t),s.delete(n),a}}function aV(e){return aP(e).concat(az(e))}let aF=Object.hasOwn||((e,t)=>a$.call(e,t));function a_(e,t){return e===t||!e&&!t&&e!=e&&t!=t}let{getOwnPropertyDescriptor:aH,keys:aU}=Object;function aW(e,t){return e.byteLength===t.byteLength&&a3(new Uint8Array(e),new Uint8Array(t))}function aq(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function aK(e,t){return e.byteLength===t.byteLength&&a3(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function aJ(e,t){return a_(e.getTime(),t.getTime())}function aG(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function aX(e,t){return e===t}function aY(e,t,n){let r,s,i=e.size;if(i!==t.size)return!1;if(!i)return!0;let o=Array(i),a=e.entries(),l=0;for(;(r=a.next())&&!r.done;){let i=t.entries(),a=!1,d=0;for(;(s=i.next())&&!s.done;){if(o[d]){d++;continue}let i=r.value,c=s.value;if(n.equals(i[0],c[0],l,d,e,t,n)&&n.equals(i[1],c[1],i[0],c[0],e,t,n)){a=o[d]=!0;break}d++}if(!a)return!1;l++}return!0}function aQ(e,t,n){let r=aU(e),s=r.length;if(aU(t).length!==s)return!1;for(;s-- >0;)if(!a4(e,t,n,r[s]))return!1;return!0}function aZ(e,t,n){let r,s,i,o=aV(e),a=o.length;if(aV(t).length!==a)return!1;for(;a-- >0;)if(!a4(e,t,n,r=o[a])||(s=aH(e,r),i=aH(t,r),(s||i)&&(!s||!i||s.configurable!==i.configurable||s.enumerable!==i.enumerable||s.writable!==i.writable)))return!1;return!0}function a0(e,t){return a_(e.valueOf(),t.valueOf())}function a1(e,t){return e.source===t.source&&e.flags===t.flags}function a2(e,t,n){let r,s,i=e.size;if(i!==t.size)return!1;if(!i)return!0;let o=Array(i),a=e.values();for(;(r=a.next())&&!r.done;){let i=t.values(),a=!1,l=0;for(;(s=i.next())&&!s.done;){if(!o[l]&&n.equals(r.value,s.value,r.value,s.value,e,t,n)){a=o[l]=!0;break}l++}if(!a)return!1}return!0}function a3(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function a5(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function a4(e,t,n,r){return("_owner"===r||"__o"===r||"__v"===r)&&(!!e.$$typeof||!!t.$$typeof)||aF(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}let a6={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},a8=Object.prototype.toString,a7=a9();function a9(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:s=!1}=e,i=function({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:d,areRegExpsEqual:c,areSetsEqual:h,areTypedArraysEqual:u,areUrlsEqual:p,unknownTagComparators:f}){return function(m,g,x){if(m===g)return!0;if(null==m||null==g)return!1;let y=typeof m;if(y!==typeof g)return!1;if("object"!==y)return"number"===y?a(m,g,x):"function"===y&&i(m,g,x);let b=m.constructor;if(b!==g.constructor)return!1;if(b===Object)return l(m,g,x);if(Array.isArray(m))return t(m,g,x);if(b===Date)return r(m,g,x);if(b===RegExp)return c(m,g,x);if(b===Map)return o(m,g,x);if(b===Set)return h(m,g,x);let v=a8.call(m);if("[object Date]"===v)return r(m,g,x);if("[object RegExp]"===v)return c(m,g,x);if("[object Map]"===v)return o(m,g,x);if("[object Set]"===v)return h(m,g,x);if("[object Object]"===v)return"function"!=typeof m.then&&"function"!=typeof g.then&&l(m,g,x);if("[object URL]"===v)return p(m,g,x);if("[object Error]"===v)return s(m,g,x);if("[object Arguments]"===v)return l(m,g,x);if(a6[v])return u(m,g,x);if("[object ArrayBuffer]"===v)return e(m,g,x);if("[object DataView]"===v)return n(m,g,x);if("[object Boolean]"===v||"[object Number]"===v||"[object String]"===v)return d(m,g,x);if(f){let e=f[v];if(!e){let t=null!=m?m[Symbol.toStringTag]:void 0;t&&(e=f[t])}if(e)return e(m,g,x)}return!1}}(function({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:aW,areArraysEqual:n?aZ:aq,areDataViewsEqual:aK,areDatesEqual:aJ,areErrorsEqual:aG,areFunctionsEqual:aX,areMapsEqual:n?aL(aY,aZ):aY,areNumbersEqual:a_,areObjectsEqual:n?aZ:aQ,arePrimitiveWrappersEqual:a0,areRegExpsEqual:a1,areSetsEqual:n?aL(a2,aZ):a2,areTypedArraysEqual:n?aL(a3,aZ):a3,areUrlsEqual:a5,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=aB(r.areArraysEqual),t=aB(r.areMapsEqual),n=aB(r.areObjectsEqual),s=aB(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:s})}return r}(e)),o=n?n(i):function(e,t,n,r,s,o,a){return i(e,t,a)};return function({circular:e,comparator:t,createState:n,equals:r,strict:s}){if(n)return function(i,o){let{cache:a=e?new WeakMap:void 0,meta:l}=n();return t(i,o,{cache:a,equals:r,meta:l,strict:s})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};let i={cache:void 0,equals:r,meta:void 0,strict:s};return function(e,n){return t(e,n,i)}}({circular:t,comparator:i,createState:r,equals:o,strict:s})}a9({strict:!0}),a9({circular:!0}),a9({circular:!0,strict:!0}),a9({createInternalComparator:()=>a_}),a9({strict:!0,createInternalComparator:()=>a_}),a9({circular:!0,createInternalComparator:()=>a_}),a9({circular:!0,createInternalComparator:()=>a_,strict:!0});var le=e.i(29796),lt=({contentComponent:e})=>{let n=(0,ef.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,t.jsx)(t.Fragment,{children:Object.values(n)})},ln=class extends eu.default.Component{constructor(e){var t;super(e),this.editorContentRef=eu.default.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(null==(t=e.editor)?void 0:t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;let t=this.props.editor;if(t&&!t.isDestroyed&&(null==(e=t.view.dom)?void 0:e.parentNode)){let e,n;if(t.contentComponent)return;let r=this.editorContentRef.current;r.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:r}),e=new Set,n={},t.contentComponent={subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>n,getServerSnapshot:()=>n,setRenderer(t,r){n={...n,[t]:ep.default.createPortal(r.reactElement,r.element,t)},e.forEach(e=>e())},removeRenderer(t){let r={...n};delete r[t],n=r,e.forEach(e=>e())}},this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var e;let t=this.props.editor;if(t){this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null;try{if(!(null==(e=t.view.dom)?void 0:e.parentNode))return;let n=document.createElement("div");n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n})}catch{}}}render(){let{editor:e,innerRef:n,...r}=this.props;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{ref:((...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})})(n,this.editorContentRef),...r}),(null==e?void 0:e.contentComponent)&&(0,t.jsx)(lt,{contentComponent:e.contentComponent})]})}},lr=(0,eu.forwardRef)((e,t)=>{let n=eu.default.useMemo(()=>Math.floor(0xffffffff*Math.random()).toString(),[e.editor]);return eu.default.createElement(ln,{key:n,innerRef:t,...e})}),ls=eu.default.memo(lr),li="u">typeof window?eu.useLayoutEffect:eu.useEffect,lo=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}},la="u"<typeof window,ll=la||!!("u">typeof window&&window.next),ld=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){return void 0===this.options.current.immediatelyRender?la||ll?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender)?this.createEditor():null}createEditor(){return new av({...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBeforeCreate)?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBlur)?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onCreate)?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDestroy)?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null==(n=(t=this.options.current).onFocus)?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onSelectionUpdate)?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null==(n=(t=this.options.current).onTransaction)?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onUpdate)?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null==(n=(t=this.options.current).onContentError)?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDrop)?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null==(n=(t=this.options.current).onPaste)?void 0:n.call(t,...e)},onDelete:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDelete)?void 0:n.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var r;return e===(null==(r=t.extensions)?void 0:r[n])}):e[n]===t[n]))}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}},lc=(0,eu.createContext)({editor:null});lc.Consumer;var lh=(0,eu.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});eu.default.forwardRef((e,n)=>{let{onDragStart:r}=(0,eu.useContext)(lh),s=e.as||"div";return(0,t.jsx)(s,{...e,ref:n,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...e.style}})}),eu.default.createContext({markViewContentRef:()=>{}});var lu=(0,eu.createContext)({get editor(){throw Error("useTiptap must be used within a <Tiptap> provider")}});function lp({editor:e,instance:n,children:r}){let s=null!=e?e:n;if(!s)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,eu.useMemo)(()=>({editor:s}),[s]),o=(0,eu.useMemo)(()=>({editor:s}),[s]);return(0,t.jsx)(lc.Provider,{value:o,children:(0,t.jsx)(lu.Provider,{value:i,children:r})})}function lf({...e}){let{editor:n}=(0,eu.useContext)(lu);return(0,t.jsx)(ls,{editor:n,...e})}lu.displayName="TiptapContext",lp.displayName="Tiptap",lf.displayName="Tiptap.Content",Object.assign(lp,{Content:lf});var lm=(e,t)=>{if("slot"===e)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=null!=t?t:{};if("svg"===e)throw Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},lg=/^\s*>\s$/,lx=aD.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return lm("blockquote",{...og(this.options.HTMLAttributes,e),children:lm("slot",{})})},parseMarkdown:(e,t)=>t.createNode("blockquote",void 0,t.parseChildren(e.tokens||[])),renderMarkdown:(e,t)=>{if(!e.content)return"";let n=[];return e.content.forEach(e=>{let r=t.renderChildren([e]).split("\n").map(e=>""===e.trim()?">":`> ${e}`);n.push(r.join("\n"))}),n.join(`
|
|
80
|
+
>
|
|
81
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[aS({find:lg,type:this.type})]}}),ly=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,lb=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,lv=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,lw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,lk=an.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return lm("strong",{...og(this.options.HTMLAttributes,e),children:lm("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[aw({find:ly,type:this.type}),aw({find:lv,type:this.type})]},addPasteRules(){return[aR({find:lb,type:this.type}),aR({find:lw,type:this.type})]}}),lS=/(^|[^`])`([^`]+)`(?!`)$/,lC=/(^|[^`])`([^`]+)`(?!`)/g,lM=an.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",og(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,t)=>t.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:"",addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[aw({find:lS,type:this.type})]},addPasteRules(){return[aR({find:lC,type:this.type})]}}),lN=/^```([a-z]+)?[\s\n]$/,lT=/^~~~([a-z]+)?[\s\n]$/,lj=aD.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...(null==(t=e.firstElementChild)?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",og(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n;return(null==(n=e.raw)?void 0:n.startsWith("```"))===!1&&"indented"!==e.codeBlockStyle?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.language)||"";return e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join("\n"):`\`\`\`${r}
|
|
82
|
+
|
|
83
|
+
\`\`\``},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!!e&&t.parent.type.name===this.name&&(!!n||!t.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;let a=" ".repeat(n);return o?e.commands.insertContent(a):e.commands.command(({tr:e})=>{let{from:t,to:n}=s,i=r.doc.textBetween(t,n,"\n","\n").split("\n").map(e=>a+e).join("\n");return e.replaceWith(t,n,r.schema.text(i)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;let n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type===this.type&&(o?e.commands.command(({tr:e})=>{var t;let{pos:s}=i,o=i.start(),a=i.end(),l=r.doc.textBetween(o,a,"\n","\n").split("\n"),d=0,c=0,h=s-o;for(let e=0;e<l.length;e+=1){if(c+l[e].length>=h){d=e;break}c+=l[e].length+1}let u=Math.min(((null==(t=l[d].match(/^ */))?void 0:t[0])||"").length,n);if(0===u)return!0;let p=o;for(let e=0;e<d;e+=1)p+=l[e].length+1;return e.delete(p,p+u),s-p<=u&&e.setSelection(tU.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:t,to:i}=s,o=r.doc.textBetween(t,i,"\n","\n").split("\n").map(e=>{var t;let r=Math.min(((null==(t=e.match(/^ */))?void 0:t[0])||"").length,n);return e.slice(r)}).join("\n");return e.replaceWith(t,i,r.schema.text(o)),!0}))},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith("\n\n");return!!i&&!!o&&e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||s.parentOffset!==s.parent.nodeSize-2)return!1;let o=s.after();return void 0!==o&&(r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(tV.near(r.resolve(o))),!0)):e.commands.exitCode())}}},addInputRules(){return[ak({find:lN,type:this.type,getAttributes:e=>({language:e[1]})}),ak({find:lT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new t5({key:new t8("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=null==s?void 0:s.mode;if(!n||!i)return!1;let{tr:o,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(tU.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),lO=aD.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n\n"):""}),lE=aD.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",og(this.options.HTMLAttributes,e)]},renderText:()=>"\n",renderMarkdown:()=>`
|
|
84
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:s}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:i}=this.options,{splittableMarks:o}=r.extensionManager,a=s||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&i){let t=a.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),lA=aD.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){let n=this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0];return[`h${n}`,og(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.level)?parseInt(e.attrs.level,10):1,s="#".repeat(r);return e.content?`${s} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,...{[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}}),{})},addInputRules(){return this.options.levels.map(e=>ak({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),lI=aD.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",og(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!function(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof tq){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let s=r.depth;for(;s>=0;){let e=r.index(s);if(r.node(s).contentMatchAt(e).matchType(t))return!0;s-=1}return!1}(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,s=e();return oR(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(tU.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(tq.create(t.doc,n.pos)):t.setSelection(tU.create(t.doc,n.pos));else{let s=e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,i=null==s?void 0:s.create();i&&(t.insert(r,i),t.setSelection(tU.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){var e;return[new o7({find:(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type}).find,handler:({state:t,range:n,match:r})=>{let s=op(e.getAttributes,void 0,r)||{},{tr:i}=t,o=n.from,a=n.to,l=e.type.create(s);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;let t=r[0][r[0].length-1];i.insertText(t,o+r[0].length-1),i.replaceWith(e,a,l)}else if(r[0]){let t=e.type.isInline?o:o-1;i.insert(t,e.type.create(s)).delete(i.mapping.map(o),i.mapping.map(a))}i.scrollIntoView()},undoable:e.undoable})]}}),lD=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lR=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,lP=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,lz=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,l$=an.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",og(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[aw({find:lD,type:this.type}),aw({find:lP,type:this.type})]},addPasteRules(){return[aR({find:lR,type:this.type}),aR({find:lz,type:this.type})]}});let lL="numeric",lB="ascii",lV="alpha",lF="asciinumeric",l_="alphanumeric",lH="domain",lU="emoji",lW="whitespace";function lq(e,t,n){for(let r in t[lL]&&(t[lF]=!0,t[l_]=!0),t[lB]&&(t[lF]=!0,t[lV]=!0),t[lF]&&(t[l_]=!0),t[lV]&&(t[l_]=!0),t[l_]&&(t[lH]=!0),t[lU]&&(t[lH]=!0),t){let t=(r in n||(n[r]=[]),n[r]);0>t.indexOf(e)&&t.push(e)}}function lK(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}lK.groups={},lK.prototype={accepts(){return!!this.t},go(e){let t=this.j[e];if(t)return t;for(let t=0;t<this.jr.length;t++){let n=this.jr[t][0],r=this.jr[t][1];if(r&&n.test(e))return r}return this.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let s=0;s<e.length;s++)this.tt(e[s],t,n,r)},tr(e,t,n,r){let s;return r=r||lK.groups,t&&t.j?s=t:(s=new lK(t),n&&r&&lq(t,n,r)),this.jr.push([e,s]),s},ts(e,t,n,r){let s=this,i=e.length;if(!i)return s;for(let t=0;t<i-1;t++)s=s.tt(e[t]);return s.tt(e[i-1],t,n,r)},tt(e,t,n,r){if(r=r||lK.groups,t&&t.j)return this.j[e]=t,t;let s,i=this.go(e);return i?(Object.assign((s=new lK).j,i.j),s.jr.push.apply(s.jr,i.jr),s.jd=i.jd,s.t=i.t):s=new lK,t&&(r&&(s.t&&"string"==typeof s.t?lq(t,Object.assign(function(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}(s.t,r),n),r):n&&lq(t,n,r)),s.t=t),this.j[e]=s,s}};let lJ=(e,t,n,r,s)=>e.ta(t,n,r,s),lG=(e,t,n,r,s)=>e.tr(t,n,r,s),lX=(e,t,n,r,s)=>e.ts(t,n,r,s),lY=(e,t,n,r,s)=>e.tt(t,n,r,s),lQ="WORD",lZ="UWORD",l0="ASCIINUMERICAL",l1="ALPHANUMERICAL",l2="LOCALHOST",l3="UTLD",l5="SCHEME",l4="SLASH_SCHEME",l6="OPENBRACE",l8="CLOSEBRACE",l7="OPENBRACKET",l9="CLOSEBRACKET",de="OPENPAREN",dt="CLOSEPAREN",dn="OPENANGLEBRACKET",dr="CLOSEANGLEBRACKET",ds="FULLWIDTHLEFTPAREN",di="FULLWIDTHRIGHTPAREN",da="LEFTCORNERBRACKET",dl="RIGHTCORNERBRACKET",dd="LEFTWHITECORNERBRACKET",dc="RIGHTWHITECORNERBRACKET",dh="FULLWIDTHLESSTHAN",du="FULLWIDTHGREATERTHAN",dp="AMPERSAND",df="APOSTROPHE",dm="ASTERISK",dg="BACKSLASH",dx="BACKTICK",dy="CARET",db="COLON",dv="COMMA",dw="DOLLAR",dk="EQUALS",dS="EXCLAMATION",dC="HYPHEN",dM="PERCENT",dN="PIPE",dT="PLUS",dj="POUND",dO="QUERY",dE="QUOTE",dA="FULLWIDTHMIDDLEDOT",dI="SEMI",dD="SLASH",dR="TILDE",dP="UNDERSCORE",dz="EMOJI";var d$=Object.freeze({__proto__:null,ALPHANUMERICAL:l1,AMPERSAND:dp,APOSTROPHE:df,ASCIINUMERICAL:l0,ASTERISK:dm,AT:"AT",BACKSLASH:dg,BACKTICK:dx,CARET:dy,CLOSEANGLEBRACKET:dr,CLOSEBRACE:l8,CLOSEBRACKET:l9,CLOSEPAREN:dt,COLON:db,COMMA:dv,DOLLAR:dw,DOT:"DOT",EMOJI:dz,EQUALS:dk,EXCLAMATION:dS,FULLWIDTHGREATERTHAN:du,FULLWIDTHLEFTPAREN:ds,FULLWIDTHLESSTHAN:dh,FULLWIDTHMIDDLEDOT:dA,FULLWIDTHRIGHTPAREN:di,HYPHEN:dC,LEFTCORNERBRACKET:da,LEFTWHITECORNERBRACKET:dd,LOCALHOST:l2,NL:"NL",NUM:"NUM",OPENANGLEBRACKET:dn,OPENBRACE:l6,OPENBRACKET:l7,OPENPAREN:de,PERCENT:dM,PIPE:dN,PLUS:dT,POUND:dj,QUERY:dO,QUOTE:dE,RIGHTCORNERBRACKET:dl,RIGHTWHITECORNERBRACKET:dc,SCHEME:l5,SEMI:dI,SLASH:dD,SLASH_SCHEME:l4,SYM:"SYM",TILDE:dR,TLD:"TLD",UNDERSCORE:dP,UTLD:l3,UWORD:lZ,WORD:lQ,WS:"WS"});let dL=/[a-z]/,dB=/\p{L}/u,dV=/\p{Emoji}/u,dF=/\d/,d_=/\s/,dH=null,dU=null;function dW(e,t){let n=function(e){let t=[],n=e.length,r=0;for(;r<n;){let s,i=e.charCodeAt(r),o=i<55296||i>56319||r+1===n||(s=e.charCodeAt(r+1))<56320||s>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,s=[],i=0,o=0;for(;o<r;){let a=e,l=null,d=0,c=null,h=-1,u=-1;for(;o<r&&(l=a.go(n[o]));)(a=l).accepts()?(h=0,u=0,c=a):h>=0&&(h+=n[o].length,u++),d+=n[o].length,i+=n[o].length,o++;i-=h,o-=u,d-=h,s.push({t:c.t,v:t.slice(i-d,i),s:i-d,e:i})}return s}function dq(e,t,n,r,s){let i,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?i=e.j[o]:((i=new lK(r)).jr=s.slice(),e.j[o]=i),e=i}return(i=new lK(n)).jr=s.slice(),e.j[t[o-1]]=i,i}function dK(e){let t=[],n=[],r=0;for(;r<e.length;){let s=0;for(;"0123456789".indexOf(e[r+s])>=0;)s++;if(s>0){t.push(n.join(""));for(let t=parseInt(e.substring(r,r+s),10);t>0;t--)n.pop();r+=s}else n.push(e[r]),r++}return t}let dJ={defaultProtocol:"http",events:null,format:dX,formatHref:dX,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function dG(e,t=null){let n=Object.assign({},dJ);e&&(n=Object.assign(n,e instanceof dG?e.o:e));let r=n.ignoreTags,s=[];for(let e=0;e<r.length;e++)s.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=s}function dX(e){return e}function dY(e,t){this.t="token",this.v=e,this.tk=t}function dQ(e,t){class n extends dY{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}dG.prototype={o:dJ,ignoreTags:[],defaultRender:e=>e,check(e){return this.get("validate",e.toString(),e)},get(e,t,n){let r=null!=t,s=this.o[e];return s&&("object"==typeof s?"function"==typeof(s=n.t in s?s[n.t]:dJ[e])&&r&&(s=s(t,n)):"function"==typeof s&&r&&(s=s(t,n.t,n))),s},getObj(e,t,n){let r=this.o[e];return"function"==typeof r&&null!=t&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}},dY.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=dJ.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){let t=this.toHref(e.get("defaultProtocol")),n=e.get("formatHref",t,this),r=e.get("tagName",t,this),s=this.toFormattedString(e),i={},o=e.get("className",t,this),a=e.get("target",t,this),l=e.get("rel",t,this),d=e.getObj("attributes",t,this),c=e.getObj("events",t,this);return i.href=n,o&&(i.class=o),a&&(i.target=a),l&&(i.rel=l),d&&Object.assign(i,d),{tagName:r,attributes:i,content:s,eventListeners:c}}};let dZ=dQ("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),d0=dQ("text"),d1=dQ("nl"),d2=dQ("url",{isLink:!0,toHref(e=dJ.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==l2&&e[1].t===db}}),d3=e=>new lK(e);function d5(e,t,n){let r=n[0].s,s=n[n.length-1].e;return new e(t.slice(r,s),n)}let d4="u">typeof console&&console&&console.warn||(()=>{}),d6={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function d8(e,t=!1){if(d6.initialized&&d4(`linkifyjs: already initialized - will not register custom scheme "${e}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
85
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
86
|
+
2. Cannot start or end with "-"
|
|
87
|
+
3. "-" cannot repeat`);d6.customSchemes.push([e,t])}function d7(e){return d6.initialized||function(){d6.scanner=function(e=[]){let t={};lK.groups=t;let n=new lK;null==dH&&(dH=dK("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==dU&&(dU=dK("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),lY(n,"'",df),lY(n,"{",l6),lY(n,"}",l8),lY(n,"[",l7),lY(n,"]",l9),lY(n,"(",de),lY(n,")",dt),lY(n,"<",dn),lY(n,">",dr),lY(n,"(",ds),lY(n,")",di),lY(n,"「",da),lY(n,"」",dl),lY(n,"『",dd),lY(n,"』",dc),lY(n,"<",dh),lY(n,">",du),lY(n,"&",dp),lY(n,"*",dm),lY(n,"@","AT"),lY(n,"`",dx),lY(n,"^",dy),lY(n,":",db),lY(n,",",dv),lY(n,"$",dw),lY(n,".","DOT"),lY(n,"=",dk),lY(n,"!",dS),lY(n,"-",dC),lY(n,"%",dM),lY(n,"|",dN),lY(n,"+",dT),lY(n,"#",dj),lY(n,"?",dO),lY(n,'"',dE),lY(n,"/",dD),lY(n,";",dI),lY(n,"~",dR),lY(n,"_",dP),lY(n,"\\",dg),lY(n,"・",dA);let r=lG(n,dF,"NUM",{[lL]:!0});lG(r,dF,r);let s=lG(r,dL,l0,{[lF]:!0}),i=lG(r,dB,l1,{[l_]:!0}),o=lG(n,dL,lQ,{[lB]:!0});lG(o,dF,s),lG(o,dL,o),lG(s,dF,s),lG(s,dL,s);let a=lG(n,dB,lZ,{[lV]:!0});lG(a,dL),lG(a,dF,i),lG(a,dB,a),lG(i,dF,i),lG(i,dL),lG(i,dB,i);let l=lY(n,"\n","NL",{[lW]:!0}),d=lY(n,"\r","WS",{[lW]:!0}),c=lG(n,d_,"WS",{[lW]:!0});lY(n,"",c),lY(d,"\n",l),lY(d,"",c),lG(d,d_,c),lY(c,"\r"),lY(c,"\n"),lG(c,d_,c),lY(c,"",c);let h=lG(n,dV,dz,{[lU]:!0});lY(h,"#"),lG(h,dV,h),lY(h,"️",h);let u=lY(h,"");lY(u,"#"),lG(u,dV,h);let p=[[dL,o],[dF,s]],f=[[dL,null],[dB,a],[dF,i]];for(let e=0;e<dH.length;e++)dq(n,dH[e],"TLD",lQ,p);for(let e=0;e<dU.length;e++)dq(n,dU[e],l3,lZ,f);lq("TLD",{tld:!0,ascii:!0},t),lq(l3,{utld:!0,alpha:!0},t),dq(n,"file",l5,lQ,p),dq(n,"mailto",l5,lQ,p),dq(n,"http",l4,lQ,p),dq(n,"https",l4,lQ,p),dq(n,"ftp",l4,lQ,p),dq(n,"ftps",l4,lQ,p),lq(l5,{scheme:!0,ascii:!0},t),lq(l4,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],s=e[t][1]?{scheme:!0}:{slashscheme:!0};r.indexOf("-")>=0?s[lH]=!0:dL.test(r)?dF.test(r)?s[lF]=!0:s[lB]=!0:s[lL]=!0,lX(n,r,r,s)}return lX(n,"localhost",l2,{ascii:!0}),n.jd=new lK("SYM"),{start:n,tokens:Object.assign({groups:t},d$)}}(d6.customSchemes);for(let e=0;e<d6.tokenQueue.length;e++)d6.tokenQueue[e][1]({scanner:d6.scanner});d6.parser=function({groups:e}){let t=e.domain.concat([dp,dm,"AT",dg,dx,dy,dw,dk,dC,"NUM",dM,dN,dT,dj,dD,"SYM",dR,dP]),n=[df,db,dv,"DOT",dS,dM,dO,dE,dI,dn,dr,l6,l8,l9,l7,de,dt,ds,di,da,dl,dd,dc,dh,du],r=[dp,df,dm,dg,dx,dy,dw,dk,dC,l6,l8,dM,dN,dT,dj,dO,dD,"SYM",dR,dP],s=d3(),i=lY(s,dR);lJ(i,r,i),lJ(i,e.domain,i);let o=d3(),a=d3(),l=d3();lJ(s,e.domain,o),lJ(s,e.scheme,a),lJ(s,e.slashscheme,l),lJ(o,r,i),lJ(o,e.domain,o);let d=lY(o,"AT");lY(i,"AT",d),lY(a,"AT",d),lY(l,"AT",d);let c=lY(i,"DOT");lJ(c,r,i),lJ(c,e.domain,i);let h=d3();lJ(d,e.domain,h),lJ(h,e.domain,h);let u=lY(h,"DOT");lJ(u,e.domain,h);let p=d3(dZ);lJ(u,e.tld,p),lJ(u,e.utld,p),lY(d,l2,p);let f=lY(h,dC);lY(f,dC,f),lJ(f,e.domain,h),lJ(p,e.domain,h),lY(p,"DOT",u),lY(p,dC,f),lJ(lY(p,db),e.numeric,dZ);let m=lY(o,dC),g=lY(o,"DOT");lY(m,dC,m),lJ(m,e.domain,o),lJ(g,r,i),lJ(g,e.domain,o);let x=d3(d2);lJ(g,e.tld,x),lJ(g,e.utld,x),lJ(x,e.domain,o),lJ(x,r,i),lY(x,"DOT",g),lY(x,dC,m),lY(x,"AT",d);let y=lY(x,db),b=d3(d2);lJ(y,e.numeric,b);let v=d3(d2),w=d3();lJ(v,t,v),lJ(v,n,w),lJ(w,t,v),lJ(w,n,w),lY(x,dD,v),lY(b,dD,v);let k=lY(a,db),S=lY(l,db),C=lY(S,dD),M=lY(C,dD);lJ(a,e.domain,o),lY(a,"DOT",g),lY(a,dC,m),lJ(l,e.domain,o),lY(l,"DOT",g),lY(l,dC,m),lJ(k,e.domain,v),lY(k,dD,v),lY(k,dO,v),lJ(M,e.domain,v),lJ(M,t,v),lY(M,dD,v);let N=[[l6,l8],[l7,l9],[de,dt],[dn,dr],[ds,di],[da,dl],[dd,dc],[dh,du]];for(let e=0;e<N.length;e++){let[r,s]=N[e],i=lY(v,r);lY(w,r,i),lY(i,s,v);let o=d3(d2);lJ(i,t,o);let a=d3();lJ(i,n),lJ(o,t,o),lJ(o,n,a),lJ(a,t,o),lJ(a,n,a),lY(o,s,v),lY(a,s,v)}return lY(s,l2,x),lY(s,"NL",d1),{start:s,tokens:d$}}(d6.scanner.tokens);for(let e=0;e<d6.pluginQueue.length;e++)d6.pluginQueue[e][1]({scanner:d6.scanner,parser:d6.parser});d6.initialized=!0}(),function(e,t,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let a=e,l=null,d=null,c=0,h=null,u=-1;for(;s<r&&!(l=a.go(n[s].t));)o.push(n[s++]);for(;s<r&&(d=l||a.go(n[s].t));)l=null,(a=d).accepts()?(u=0,h=a):u>=0&&u++,s++,c++;if(u<0)(s-=c)<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(d5(d0,t,o)),o=[]),s-=u,c-=u;let e=h.t,r=n.slice(s-c,s);i.push(d5(e,t,r))}}return o.length>0&&i.push(d5(d0,t,o)),i}(d6.parser.start,e,dW(d6.scanner.start,e))}function d9(e,t=null,n=null){if(t&&"object"==typeof t){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new dG(n),s=d7(e),i=[];for(let e=0;e<s.length;e++){let n=s[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&i.push(n.toFormattedObject(r))}return i}d7.scan=dW;var ce="[\0- -\u2029 ]",ct=new RegExp(ce),cn=RegExp(`${ce}$`),cr=RegExp(ce,"g");function cs(e,t){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(e=>{let t="string"==typeof e?e:e.scheme;t&&n.push(t)}),!e||e.replace(cr,"").match(RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var ci=an.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{"string"==typeof e?d8(e):d8(e.scheme,e.optionalSlashes)})},onDestroy(){lK.groups={},d6.scanner=null,d6.parser=null,d6.tokenQueue=[],d6.pluginQueue=[],d6.customSchemes=[],d6.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!cs(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;let r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!/^\d{1,3}(\.\d{1,3}){3}$/.test(r)&&!!/\./.test(r)}}),addAttributes(){return{href:{default:null,parseHTML:e=>e.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{let t=e.getAttribute("href");return!!t&&!!this.options.isAllowedUri(t,{defaultValidate:e=>!!cs(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!cs(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",og(this.options.HTMLAttributes,e),0]:["a",og(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,t)=>t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{var n,r,s,i;let o=null!=(r=null==(n=e.attrs)?void 0:n.href)?r:"",a=null!=(i=null==(s=e.attrs)?void 0:s.title)?i:"",l=t.renderChildren(e);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return!!this.options.isAllowedUri(n,{defaultValidate:e=>!!cs(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&t().setMark(this.name,e).setMeta("preventAutolink",!0).run()},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return(!n||!!this.options.isAllowedUri(n,{defaultValidate:e=>!!cs(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[aR({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,s=d9(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!cs(e,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t},type:this.type,getAttributes:e=>{var t;return{href:null==(t=e.data)?void 0:t.href}}})]},addProseMirrorPlugins(){var e,t,n;let r=[],{protocols:s,defaultProtocol:i}=this.options;return this.options.autolink&&r.push((e={type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!cs(e,s),protocols:s,defaultProtocol:i}),shouldAutoLink:this.options.shouldAutoLink},new t5({key:new t8("autolink"),appendTransaction:(t,n,r)=>{let s=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),i=t.some(e=>e.getMeta("preventAutolink"));if(!s||i)return;let{tr:o}=r;if(oN(oa(n.doc,[...t])).forEach(({newRange:t})=>{var n,s;let i,a,l,d=(n=r.doc,s=e=>e.isTextblock,l=[],n.nodesBetween(t.from,t.to,(e,t)=>{s(e)&&l.push({node:e,pos:t})}),l);if(d.length>1)i=d[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0," ");else if(d.length){let e=r.doc.textBetween(t.from,t.to," "," ");if(!cn.test(e))return;i=d[0],a=r.doc.textBetween(i.pos,t.to,void 0," ")}if(i&&a){let t=a.split(ct).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let l=d7(n).map(t=>t.toObject(e.defaultProtocol));if(!(1===l.length?l[0].isLink:3===l.length&&!!l[1].isLink&&["()","[]"].includes(l[0].value+l[2].value)))return!1;l.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{oT(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}}))),r.push((t={type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection},new t5({key:new t8("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(0!==r.button||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let e=r.target;if(!e)return!1;let n=t.editor.view.dom;(o=e.closest("a"))&&!n.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(t.enableClickSelection&&(a=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let n=oM(e.state,t.type.name),r=null!=(s=o.href)?s:n.href,l=null!=(i=o.target)?i:n.target;r&&(window.open(r,l),a=!0)}return a}}}))),this.options.linkOnPaste&&r.push((n={editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink},new t5({key:new t8("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{shouldAutoLink:s}=n,{state:i}=e,{selection:o}=i,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(e=>{l+=e.textContent});let d=d9(l,{defaultProtocol:n.defaultProtocol}).find(e=>e.isLink&&e.value===l);return!!l&&!!d&&(void 0===s||!!s(d.value))&&n.editor.commands.setMark(n.type,{href:d.href})}}}))),r}}),co=Object.defineProperty,ca="textStyle",cl=/^\s*([-+*])\s$/,cd=aD.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",og(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>"list"!==e.type||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(ca)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=aS({find:cl,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=aS({find:cl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ca),editor:this.editor})),[e]}}),cc=aD.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",og(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{if("list_item"!==e.type)return[];let n=[];if(e.tokens&&e.tokens.length>0)if(e.tokens.some(e=>"paragraph"===e.type))n=t.parseChildren(e.tokens);else{let r=e.tokens[0];if(r&&"text"===r.type&&r.tokens&&r.tokens.length>0){if(n=[{type:"paragraph",content:t.parseInline(r.tokens)}],e.tokens.length>1){let r=e.tokens.slice(1),s=t.parseChildren(r);n.push(...s)}}else n=t.parseChildren(e.tokens)}return 0===n.length&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(e,t,n)=>aI(e,t,e=>{var t,n;if("bulletList"===e.parentType)return"- ";if("orderedList"===e.parentType){let r=(null==(n=null==(t=e.meta)?void 0:t.parentAttrs)?void 0:n.start)||1;return`${r+e.index}. `}return"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ch={},cu={findListItemPos:()=>cf,getNextListDepth:()=>cm,handleBackspace:()=>cb,handleDelete:()=>ck,hasListBefore:()=>cg,hasListItemAfter:()=>cS,hasListItemBefore:()=>cx,listItemHasSubList:()=>cy,nextListIsDeeper:()=>cv,nextListIsHigher:()=>cw};for(var cp in cu)co(ch,cp,{get:cu[cp],enumerable:!0});var cf=(e,t)=>{let{$from:n}=t.selection,r=ig(e,t.schema),s=n.depth,i=n.pos,o=null;for(;s>0&&null===o;)n.node(s).type===r?o=s:(s-=1,i-=1);return null===o?null:{$pos:t.doc.resolve(i),depth:o}},cm=(e,t)=>{let n=cf(e,t);if(!n)return!1;let[,r]=((e,t,n,r=20)=>{let s=e.doc.resolve(n),i=r,o=null;for(;i>0&&null===o;){let e=s.node(i);(null==e?void 0:e.type.name)===t?o=e:i-=1}return[o,i]})(t,e,n.$pos.pos+4);return r},cg=(e,t,n)=>{let{$anchor:r}=e.selection,s=Math.max(0,r.pos-2),i=e.doc.resolve(s).node();return!!i&&!!n.includes(i.type.name)},cx=(e,t)=>{var n;let{$anchor:r}=t.selection,s=t.doc.resolve(r.pos-2);return 0!==s.index()&&(null==(n=s.nodeBefore)?void 0:n.type.name)===e},cy=(e,t,n)=>{if(!n)return!1;let r=ig(e,t.schema),s=!1;return n.descendants(e=>{e.type===r&&(s=!0)}),s},cb=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!iQ(e.state,t)&&cg(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),s=[];r.node().descendants((e,n)=>{e.type.name===t&&s.push({node:e,pos:n})});let i=s.at(-1);if(!i)return!1;let o=e.state.doc.resolve(r.start()+i.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!iQ(e.state,t)||!(e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0)&&t.pos===n.pos})(e.state))return!1;let r=cf(t,e.state);if(!r)return!1;let s=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=cy(t,e.state,s);return cx(t,e.state)&&!i?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},cv=(e,t)=>{let n=cm(e,t),r=cf(e,t);return!!r&&!!n&&n>r.depth},cw=(e,t)=>{let n=cm(e,t),r=cf(e,t);return!!r&&!!n&&n<r.depth},ck=(e,t)=>{if(!iQ(e.state,t)||!((e,t)=>{let{$from:n,$to:r,$anchor:s}=e.selection;if(t){let n=ol(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return s.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2)&&n.pos===r.pos})(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:s}=n;return!(!n.empty&&r.sameParent(s))&&(cv(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():cw(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},cS=(e,t)=>{var n;let{$anchor:r}=t.selection,s=t.doc.resolve(r.pos-r.parentOffset-2);return s.index()!==s.parent.childCount-1&&(null==(n=s.nodeAfter)?void 0:n.type.name)===e},cC=ao.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&ck(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&ck(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&cb(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&cb(e,n,r)&&(t=!0)}),t}}}}),cM=/^(\s*)(\d+)\.\s+(.*)$/,cN=/^\s/,cT="textStyle",cj=/^(\d+)\.\s$/,cO=aD.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return 1===t?["ol",og(this.options.HTMLAttributes,n),0]:["ol",og(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>{var n;if("list"!==e.type||!e.ordered)return[];let r=e.start||1,s=e.items?(n=e.items,n.map(e=>{if("list_item"!==e.type)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if("paragraph"===e.type||"list"===e.type||"blockquote"===e.type||"code"===e.type)n.push(...t.parseChildren([e]));else if("text"===e.type&&e.tokens){let r=t.parseChildren([e]);n.push({type:"paragraph",content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:"listItem",content:n}})):[];return 1!==r?{type:"orderedList",attrs:{start:r},content:s}:{type:"orderedList",content:s}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/),n=null==t?void 0:t.index;return void 0!==n?n:-1},tokenize:(e,t,n)=>{var r;let s=e.split("\n"),[i,o]=function(e){let t=[],n=0,r=0;for(;n<e.length;){let s=e[n],i=s.match(cM);if(!i)break;let[,o,a,l]=i,d=o.length,c=l,h=n+1,u=[s];for(;h<e.length;){let t=e[h];if(t.match(cM))break;if(""===t.trim())u.push(t),c+="\n",h+=1;else if(t.match(cN))u.push(t),c+=`
|
|
88
|
+
${t.slice(d+2)}`,h+=1;else break}t.push({indent:d,number:parseInt(a,10),content:c.trim(),raw:u.join("\n")}),r=h,n=h}return[t,r]}(s);if(0===i.length)return;let a=function e(t,n,r){var s;let i=[],o=0;for(;o<t.length;){let a=t[o];if(a.indent===n){let l=a.content.split("\n"),d=(null==(s=l[0])?void 0:s.trim())||"",c=[];d&&c.push({type:"paragraph",raw:d,tokens:r.inlineTokens(d)});let h=l.slice(1).join("\n").trim();if(h){let e=r.blockTokens(h);c.push(...e)}let u=o+1,p=[];for(;u<t.length&&t[u].indent>n;)p.push(t[u]),u+=1;if(p.length>0){let t=Math.min(...p.map(e=>e.indent)),n=e(p,t,r);c.push({type:"list",ordered:!0,start:p[0].number,items:n,raw:p.map(e=>e.raw).join("\n")})}i.push({type:"list_item",raw:a.raw,tokens:c}),o=u}else o+=1}return i}(i,0,n);if(0!==a.length)return{type:"list",ordered:!0,start:(null==(r=i[0])?void 0:r.number)||1,items:a,raw:s.slice(0,o).join("\n")}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(cT)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=aS({find:cj,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=aS({find:cj,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(cT)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),cE=/^\s*(\[([( |x])?\])\s$/,cA=aD.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute("data-checked");return""===t||"true"===t},renderHTML:e=>({"data-checked":e.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",og(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;let r=(null==(n=e.attrs)?void 0:n.checked)?"x":" ";return aI(e,t,`- [${r}] `)},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),d=e=>{var t,n;a.ariaLabel=(null==(n=null==(t=this.options.a11y)?void 0:t.checkboxLabel)?void 0:n.call(t,e,a.checked))||`Task item checkbox for ${e.textContent||"empty task item"}`};d(e),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",e=>e.preventDefault()),a.addEventListener("change",t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}let{checked:s}=t.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if("number"!=typeof t)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...null==r?void 0:r.attrs,checked:s}),!0}).run(),r.isEditable||!this.options.onReadOnlyChecked||this.options.onReadOnlyChecked(e,s)||(a.checked=!a.checked)}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{s.setAttribute(e,t)}),s.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,i.append(a,o),s.append(i,l),Object.entries(t).forEach(([e,t])=>{s.setAttribute(e,t)});let c=new Set(Object.keys(t));return{dom:s,contentDOM:l,update:e=>{if(e.type!==this.type)return!1;s.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,d(e);let t=ox(e,r.extensionManager.attributes),n=new Set(Object.keys(t)),i=this.options.HTMLAttributes;return c.forEach(e=>{n.has(e)||(e in i?s.setAttribute(e,i[e]):s.removeAttribute(e))}),Object.entries(t).forEach(([e,t])=>{null==t?e in i?s.setAttribute(e,i[e]):s.removeAttribute(e):s.setAttribute(e,t)}),c=n,!0}}}},addInputRules(){return[aS({find:cE,type:this.type,getAttributes:e=>({checked:"x"===e[e.length-1]})})]}}),cI=aD.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",og(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;let n=null==(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:t.index;return void 0!==n?n:-1},tokenize(e,t,n){let r=e=>{let t=aA(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:"taskList",raw:t.raw,items:t.items}]:n.blockTokens(e)},s=aA(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ao.create({name:"listKit",addExtensions(){let e=[];return!1!==this.options.bulletList&&e.push(cd.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(cc.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(cC.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(cO.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(cA.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(cI.configure(this.options.taskList)),e}});var cD=" ",cR=aD.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",og(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(1===n.length&&"image"===n[0].type)return t.parseChildren([n[0]]);let r=t.parseInline(n);return 1===r.length&&"text"===r[0].type&&(r[0].text===cD||" "===r[0].text)?t.createNode("paragraph",void 0,[]):t.createNode("paragraph",void 0,r)},renderMarkdown:(e,t)=>{if(!e)return"";let n=Array.isArray(e.content)?e.content:[];return 0===n.length?cD:t.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cP=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,cz=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,c$=an.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",og(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[aw({find:cP,type:this.type})]},addPasteRules(){return[aR({find:cz,type:this.type})]}}),cL=aD.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),cB=an.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",og(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>`++${t.renderChildren(e)}++`,markdownTokenizer:{name:"underline",level:"inline",start:e=>e.indexOf("++"),tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let s=r[2].trim();return{type:"underline",raw:r[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});class cV{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!=(n=t.width)?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t,n=this.editorView.state.doc.resolve(this.cursorPos),r=!n.parent.inlineContent,s,i=this.editorView.dom,o=i.getBoundingClientRect(),a=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(r){let e=n.nodeBefore,t=n.nodeAfter;if(e||t){let n=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(n){let r=n.getBoundingClientRect(),i=e?r.bottom:r.top;e&&t&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let o=this.width/2*l;s={left:r.left,right:r.right,top:i-o,bottom:i+o}}}}if(!s){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;s={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let d=this.editorView.dom.offsetParent;if(!this.element&&(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r),d&&(d!=document.body||"static"!=getComputedStyle(d).position)){let n=d.getBoundingClientRect(),r=n.width/d.offsetWidth,s=n.height/d.offsetHeight;e=n.left-d.scrollLeft*r,t=n.top-d.scrollTop*s}else e=-pageXOffset,t=-pageYOffset;this.element.style.left=(s.left-e)/a+"px",this.element.style.top=(s.top-t)/l+"px",this.element.style.width=(s.right-s.left)/a+"px",this.element.style.height=(s.bottom-s.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,s="function"==typeof r?r(this.editorView,t,e):r;if(t&&!s){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=tN(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class cF extends tV{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return cF.valid(n)?new cF(n):tV.near(n)}content(){return ek.empty}eq(e){return e instanceof cF&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for GapCursor.fromJSON");return new cF(e.resolve(t.pos))}getBookmark(){return new c_(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0==n){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||cH(e.type))return!0;if(e.inlineContent)return!1}}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||cH(e.type))return!0;if(e.inlineContent)return!1}}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){r:for(;;){if(!n&&cF.valid(e))return e;let r=e.pos,s=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){s=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let o=e.doc.resolve(r);if(cF.valid(o))return o}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!tq.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),n=!1;continue r}break}s=i,r+=t;let o=e.doc.resolve(r);if(cF.valid(o))return o}return null}}}cF.prototype.visible=!1,cF.findFrom=cF.findGapCursorFrom,tV.jsonID("gapcursor",cF);class c_{constructor(e){this.pos=e}map(e){return new c_(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return cF.valid(t)?new cF(t):tV.near(t)}}function cH(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}let cU=it({ArrowLeft:cW("horiz",-1),ArrowRight:cW("horiz",1),ArrowUp:cW("vert",-1),ArrowDown:cW("vert",1)});function cW(e,t){let n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,s){let i=e.selection,o=t>0?i.$to:i.$from,a=i.empty;if(i instanceof tU){if(!s.endOfTextblock(n)||0==o.depth)return!1;a=!1,o=e.doc.resolve(t>0?o.after():o.before())}let l=cF.findGapCursorFrom(o,t,a);return!!l&&(r&&r(e.tr.setSelection(new cF(l))),!0)}}function cq(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!cF.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return!(s&&s.inside>-1&&tq.isSelectable(e.state.doc.nodeAt(s.inside)))&&(e.dispatch(e.state.tr.setSelection(new cF(r))),!0)}function cK(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof cF))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=eg.empty;for(let e=r.length-1;e>=0;e--)s=eg.from(r[e].createAndFill(null,s));let i=e.state.tr.replace(n.pos,n.pos,new ek(s,0,0));return i.setSelection(tU.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function cJ(e){if(!(e.selection instanceof cF))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",sT.create(e.doc,[sC.widget(e.selection.head,t,{key:"gapcursor"})])}var cG=function(){};cG.prototype.append=function(e){return e.length?(e=cG.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},cG.prototype.prepend=function(e){return e.length?cG.from(e).append(this):this},cG.prototype.appendInner=function(e){return new cY(this,e)},cG.prototype.slice=function(e,t){return(void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t)?cG.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},cG.prototype.get=function(e){if(!(e<0)&&!(e>=this.length))return this.getInner(e)},cG.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},cG.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},cG.from=function(e){return e instanceof cG?e:e&&e.length?new cX(e):cG.empty};var cX=function(e){function t(t){e.call(this),this.values=t}t.__proto__=e,t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var s=t;s<n;s++)if(!1===e(this.values[s],r+s))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var s=t-1;s>=n;s--)if(!1===e(this.values[s],r+s))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(cG);cG.empty=new cX([]);var cY=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return t.__proto__=e,t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var s=this.left.length;if(t<s&&!1===this.left.forEachInner(e,t,Math.min(n,s),r)||n>s&&!1===this.right.forEachInner(e,Math.max(t-s,0),Math.min(this.length,n)-s,r+s))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var s=this.left.length;if(t>s&&!1===this.right.forEachInvertedInner(e,t-s,Math.max(n,s)-s,r+s)||n<s&&!1===this.left.forEachInvertedInner(e,Math.min(t,s),n,r))return!1},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(cG);class cQ{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){let n,r,s,i;if(0==this.eventCount)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}t&&(r=(n=this.remapping(o,this.items.length)).maps.length);let a=e.tr,l=[],d=[];return this.items.forEach((e,t)=>{if(!e.step){n||(r=(n=this.remapping(o,t+1)).maps.length),r--,d.push(e);return}if(n){d.push(new cZ(e.map));let t=e.step.map(n.slice(r)),s;t&&a.maybeStep(t).doc&&(s=a.mapping.maps[a.mapping.maps.length-1],l.push(new cZ(s,void 0,void 0,l.length+d.length))),r--,s&&n.appendMap(s,r)}else a.maybeStep(e.step);if(e.selection)return s=n?e.selection.map(n.slice(r)):e.selection,i=new cQ(this.items.slice(0,o).append(d.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:i,transform:a,selection:s}}addTransform(e,t,n,r){var s,i;let o,a=[],l=this.eventCount,d=this.items,c=!r&&d.length?d.get(d.length-1):null;for(let n=0;n<e.steps.length;n++){let s=e.steps[n].invert(e.docs[n]),i=new cZ(e.mapping.maps[n],s,t),o;(o=c&&c.merge(i))&&(i=o,n?a.pop():d=d.slice(0,d.length-1)),a.push(i),t&&(l++,t=void 0),r||(c=i)}let h=l-n.depth;return h>c1&&(s=d,i=h,s.forEach((e,t)=>{if(e.selection&&0==i--)return o=t,!1}),d=s.slice(o),l-=h),new cQ(d.append(a),l)}remapping(e,t){let n=new ts;return this.items.forEach((t,r)=>{let s=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,s)},e,t),n}addMaps(e){return 0==this.eventCount?this:new cQ(this.items.append(e.map(e=>new cZ(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,o=this.eventCount;this.items.forEach(e=>{e.selection&&o--},r);let a=t;this.items.forEach(t=>{let r=s.getMirror(--a);if(null==r)return;i=Math.min(i,r);let l=s.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),d=t.selection&&t.selection.map(s.slice(a+1,r));d&&o++,n.push(new cZ(l,i,d))}else n.push(new cZ(l))},r);let l=[];for(let e=t;e<i;e++)l.push(new cZ(s.maps[e]));let d=new cQ(this.items.slice(0,r).append(l).append(n),o);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{!t.step&&e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],s=0;return this.items.forEach((i,o)=>{if(o>=e)r.push(i),i.selection&&s++;else if(i.step){let e=i.step.map(t.slice(n)),o=e&&e.getMap();if(n--,o&&t.appendMap(o,n),e){let a=i.selection&&i.selection.map(t.slice(n));a&&s++;let l=new cZ(o.invert(),e,a),d,c=r.length-1;(d=r.length&&r[c].merge(l))?r[c]=d:r.push(l)}}else i.map&&n--},this.items.length,0),new cQ(cG.from(r.reverse()),s)}}cQ.empty=new cQ(cG.empty,0);class cZ{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new cZ(t.getMap().invert(),t,this.selection)}}}class c0{constructor(e,t,n,r,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=s}}let c1=20;function c2(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,s)=>t.push(r,s));return t}function c3(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),i=t.map(e[r+1],-1);s<=i&&n.push(s,i)}return n}let c5=!1,c4=null;function c6(e){let t=e.plugins;if(c4!=t){c5=!1,c4=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){c5=!0;break}}return c5}let c8=new t8("history"),c7=new t8("closeHistory");function c9(e,t){return(n,r)=>{let s=c8.getState(n);if(!s||0==(e?s.undone:s.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=c6(t),s=c8.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),s,r),l=new c0(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(c8,{redo:n,historyState:l})}(s,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}let he=c9(!1,!0),ht=c9(!0,!0);c9(!1,!1),c9(!0,!1),ao.create({name:"characterCount",addOptions:()=>({limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(e=>""!==e).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=e=>{let t=(null==e?void 0:e.node)||this.editor.state.doc;if("textSize"===((null==e?void 0:e.mode)||this.options.mode)){let e=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=(null==e?void 0:e.node)||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new t5({key:new t8("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;let s=this.options.limit;if(null==s||0===s){e=!0;return}let i=this.storage.characters({node:r.doc});if(i>s){console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);let t=r.tr.deleteRange(0,i-s);return e=!0,t}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||0===n||null==n)return!0;let r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=n||r>n&&s>n&&s<=r)return!0;if(r>n&&s>n&&s>r||!e.getMeta("paste"))return!1;let i=e.selection.$head.pos;return e.deleteRange(i-(s-n),i),!(this.storage.characters({node:e.doc})>n)}})]}});var hn=ao.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[function(e={}){return new t5({view:t=>new cV(t,e)})}(this.options)]}});ao.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new t5({key:new t8("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:s}=t,i=[];if(!n||!r)return sT.create(e,[]);let o=0;"deepest"===this.options.mode&&e.descendants((e,t)=>{if(!e.isText){if(!(s>=t&&s<=t+e.nodeSize-1))return!1;o+=1}});let a=0;return e.descendants((e,t)=>!e.isText&&!!(s>=t&&s<=t+e.nodeSize-1)&&((a+=1,"deepest"===this.options.mode&&o-a>0||"shallowest"===this.options.mode&&a>1)?"deepest"===this.options.mode:void i.push(sC.node(t,t+e.nodeSize,{class:this.options.className})))),sT.create(e,i)}}})]}});var hr=ao.create({name:"gapCursor",addProseMirrorPlugins:()=>[new t5({props:{decorations:cJ,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&cF.valid(n)?new cF(n):null,handleClick:cq,handleKeyDown:cU,handleDOMEvents:{beforeinput:cK}}})],extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:null!=(t=op(od(e,"allowGapCursor",n)))?t:null}}}),hs="placeholder",hi=ao.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:hs,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${this.options.dataAttribute.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}`:`data-${hs}`;return[new t5({key:new t8("placeholder"),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=n,i=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=s>=n&&s<=n+t.nodeSize,a=!t.isLeaf&&oD(t);if((r||!this.options.showOnlyCurrent)&&a){let s=[this.options.emptyNodeClass];o&&s.push(this.options.emptyEditorClass);let a=sC.node(n,n+t.nodeSize,{class:s.join(" "),[e]:"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});i.push(a)}return this.options.includeChildren}),sT.create(t,i)}}})]}});function ho({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(null==t?void 0:t.type)===e}ao.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new t5({key:new t8("selection"),props:{decorations:n=>n.selection.empty||e.isFocused||!e.isEditable||oR(n.selection)||e.view.dragging?null:sT.create(n.doc,[sC.inline(n.selection.from,n.selection.to,{class:t.className})])}})]}});var ha=ao.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var e;let t=new t8(this.name),n=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(n).includes(e.name));return[new t5({key:t,appendTransaction:(e,r,s)=>{let{doc:i,tr:o,schema:a}=s,l=t.getState(s),d=i.content.size,c=a.nodes[n];if(l)return o.insert(d,c.create())},state:{init:(e,t)=>!ho({node:t.tr.doc.lastChild,types:r}),apply:(e,t)=>!e.docChanged||e.getMeta("__uniqueIDTransaction")?t:!ho({node:e.doc.lastChild,types:r})}})]}}),hl=ao.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>he(e,t),redo:()=>({state:e,dispatch:t})=>ht(e,t)}),addProseMirrorPlugins(){return[function(e={}){return new t5({key:c8,state:{init:()=>new c0(cQ.empty,cQ.empty,null,0,-1),apply:(t,n,r)=>(function(e,t,n,r){let s=n.getMeta(c8),i;if(s)return s.historyState;n.getMeta(c7)&&(e=new c0(e.done,e.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(o&&o.getMeta(c8))if(o.getMeta(c8).redo)return new c0(e.done.addTransform(n,void 0,r,c6(t)),e.undone,c2(n.mapping.maps),e.prevTime,e.prevComposition);else return new c0(e.done,e.undone.addTransform(n,void 0,r,c6(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))if(i=n.getMeta("rebased"))return new c0(e.done.rebased(n,i),e.undone.rebased(n,i),c3(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new c0(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),c3(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let s=n.getMeta("composition"),i=0==e.prevTime||!o&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let s=0;s<t.length;s+=2)e<=t[s+1]&&r>=t[s]&&(n=!0)}),n}(n,e.prevRanges)),a=o?c3(e.prevRanges,n.mapping):c2(n.mapping.maps);return new c0(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,c6(t)),cQ.empty,a,n.time,null==s?e.prevComposition:s)}})(n,r,t,e)},config:e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?he:"historyRedo"==n?ht:null;return!!r&&!!e.editable&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),hd=ao.create({name:"starterKit",addExtensions(){var e,t,n,r;let s=[];return!1!==this.options.bold&&s.push(lk.configure(this.options.bold)),!1!==this.options.blockquote&&s.push(lx.configure(this.options.blockquote)),!1!==this.options.bulletList&&s.push(cd.configure(this.options.bulletList)),!1!==this.options.code&&s.push(lM.configure(this.options.code)),!1!==this.options.codeBlock&&s.push(lj.configure(this.options.codeBlock)),!1!==this.options.document&&s.push(lO.configure(this.options.document)),!1!==this.options.dropcursor&&s.push(hn.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&s.push(hr.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&s.push(lE.configure(this.options.hardBreak)),!1!==this.options.heading&&s.push(lA.configure(this.options.heading)),!1!==this.options.undoRedo&&s.push(hl.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&s.push(lI.configure(this.options.horizontalRule)),!1!==this.options.italic&&s.push(l$.configure(this.options.italic)),!1!==this.options.listItem&&s.push(cc.configure(this.options.listItem)),!1!==this.options.listKeymap&&s.push(cC.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&s.push(ci.configure(null==(t=this.options)?void 0:t.link)),!1!==this.options.orderedList&&s.push(cO.configure(this.options.orderedList)),!1!==this.options.paragraph&&s.push(cR.configure(this.options.paragraph)),!1!==this.options.strike&&s.push(c$.configure(this.options.strike)),!1!==this.options.text&&s.push(cL.configure(this.options.text)),!1!==this.options.underline&&s.push(cB.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&s.push(ha.configure(null==(r=this.options)?void 0:r.trailingNode)),s}});let hc=/^[A-Za-z0-9_\-:]*$/,hh={id:"all",name:"All",provider:"claude",model:null,color:"#6B7280"},hu=/^[a-zA-Z0-9_-]*$/,hp=new Set(["image/jpeg","image/png","image/gif","image/webp","image/svg+xml","application/pdf","text/plain","text/csv","text/markdown","application/json","application/zip","application/gzip","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation"]),hf=new Set([".exe",".bat",".cmd",".com",".msi",".scr",".pif",".vbs",".vbe",".js",".jse",".ws",".wsf",".wsc",".wsh",".ps1",".ps2",".psc1",".psc2",".reg",".inf",".lnk",".dll",".sys",".drv"]),hm=[{path:`${$.default.env.HOME??"~"}/Code`,relativePath:"~/Code",type:"folder"},{path:`${$.default.env.HOME??"~"}/Projects`,relativePath:"~/Projects",type:"folder"},{path:`${$.default.env.HOME??"~"}/Desktop`,relativePath:"~/Desktop",type:"folder"},{path:`${$.default.env.HOME??"~"}/Documents`,relativePath:"~/Documents",type:"folder"},{path:`${$.default.env.HOME??"~"}/Downloads`,relativePath:"~/Downloads",type:"folder"}];function hg(e,t){let n=function(e,t){let n=e.trim().replace(/\/+$/,"");if("~"===n)return"~";if(n.startsWith("~/")||n.startsWith("/"))return n;let r=n.replace(/^\/+/,"");return"@~"===t?`~/${r}`:`/${r}`}(e,t.trigger);if(n.startsWith("~/")||n.startsWith("/")){let r=e.trim().startsWith("~/")||e.trim().startsWith("/")||"~"===e.trim()?null:function(e){if(!e.query.endsWith("/"))return null;let t=e.query.replace(/^\/+/,"").replace(/\/+$/,"");return"@~"===e.trigger?t?`~/${t}`:"~":t?`/${t}`:"/"}(t);if(r){let e=n.replace(/^~\/|^\//,"");return"~"===r?`~/${e}`:"/"===r?`/${e}`:`${r}/${e}`}}return n}async function hx(e){let t;if(0===e.length)return[];let n=e.map(e=>e.path);try{let r=await fetch("/api/file-read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:n})});if(!r.ok){let t=(await r.json().catch(()=>({}))).error??`HTTP ${r.status}`;return e.map(e=>({type:"file",path:e.path,label:e.label,content:null,error:t}))}t=(await r.json()).results}catch(n){let t=n instanceof Error?n.message:"Failed to fetch file contents";return e.map(e=>({type:"file",path:e.path,label:e.label,content:null,error:t}))}let r=new Map(t.map(e=>[e.path,e]));return e.map(e=>{let t=r.get(e.path);return{type:"file",path:e.path,label:e.label,content:t?.content??null,error:t?.error}})}async function hy(e){let t=await hx(e),n=0===t.length?"":t.map(e=>e.error||null===e.content?`<file path="${e.path}" error="${e.error??"unreadable"}" />`:`<file path="${e.path}">
|
|
89
|
+
${e.content}
|
|
90
|
+
</file>`).join("\n\n")+"\n\n";return{fileContextBlocks:t,contextPrefix:n}}let hb=aD.create({name:"participantMention",group:"inline",inline:!0,atom:!0,addAttributes:()=>({id:{default:null},name:{default:""},mode:{default:"sequential"}}),parseHTML:()=>[{tag:"span[data-participant-mention]"}],renderHTML({node:e,HTMLAttributes:t}){let n="parallel"===e.attrs.mode;return["span",og(t,{"data-participant-mention":"","data-id":e.attrs.id,"data-mode":e.attrs.mode,class:n?"composer-pill composer-pill--participant-parallel":"composer-pill composer-pill--participant",contenteditable:"false"}),`${n?"@@":"@"}${e.attrs.name}`]}}),hv=aD.create({name:"fileMention",group:"inline",inline:!0,atom:!0,addAttributes:()=>({path:{default:""},relativePath:{default:""},trigger:{default:"@/"},attachMode:{default:void 0}}),parseHTML:()=>[{tag:"span[data-file-mention]"}],renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.relativePath||e.attrs.path;return["span",og(t,{"data-file-mention":"","data-path":e.attrs.path,class:"composer-pill composer-pill--file",contenteditable:"false"}),`@${n}`]}}),hw=aD.create({name:"threadMention",group:"inline",inline:!0,atom:!0,addAttributes:()=>({threadId:{default:""},title:{default:""}}),parseHTML:()=>[{tag:"span[data-thread-mention]"}],renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.title.length>40?e.attrs.title.slice(0,37)+"...":e.attrs.title;return["span",og(t,{"data-thread-mention":"","data-thread-id":e.attrs.threadId,class:"composer-pill composer-pill--thread",contenteditable:"false"}),`#${n}`]}});function hk(e){let{state:t}=e,{$from:n}=t.selection,r=n.depth,s=-1;for(let e=r;e>=0;e--)if("paragraph"===n.node(e).type.name){s=e;break}if(-1===s)return null;let i=n.node(s),o=n.start(s),a=n.pos-o,l="",d=0,c=!1;return i.forEach((e,t)=>{let n=t+e.nodeSize;if(e.isText){let r=e.text??"";!c&&a>=t&&a<=n&&(d=l.length+(a-t),c=!0),l+=r}else if(e.isAtom){let r=hS(e);!c&&a>=t&&a<=n&&(d=l.length+r.length,c=!0),l+=r}}),c||(d=l.length),{text:l,cursorPos:d,blockStart:o}}function hS(e){switch(e.type.name){case"participantMention":{let t="parallel"===e.attrs.mode?"@@":"@";return`${t}${e.attrs.name}`}case"fileMention":{let t=e.attrs.relativePath||e.attrs.path;return`@${t}`}case"threadMention":{let t=(e.attrs.threadId??"").slice(0,8);return`@#${t}`}default:return""}}function hC(e,t,n,r){let{state:s}=e,i=s.doc.resolve(t),o=i.depth,a=null,l=t;for(let e=o;e>=0;e--){let t=i.node(e);if("paragraph"===t.type.name){a=t,l=i.start(e);break}}a||(a=s.doc.resolve(t).parent,l=t);let d=0,c=null,h=null;return(a.forEach((e,t)=>{let s=l+t,i=e.nodeSize;if(e.isText){let t=e.text??"",i=d+t.length;null===c&&n>=d&&n<=i&&(c=s+(n-d)),null===h&&r>=d&&r<=i&&(h=s+(r-d)),d=i}else if(e.isAtom){let t=hS(e),o=d+t.length;null===c&&n>=d&&n<=o&&(c=s),null===h&&r>=d&&r<=o&&(h=s+i),d=o}}),null===c&&n>=d&&(c=l+a.content.size),null===h&&r>=d&&(h=l+a.content.size),null===c||null===h)?null:{from:c,to:h}}function hM({isOpen:e,suggestions:r,activeIndex:s,listboxId:i,optionIdPrefix:o,onSelect:a}){let l=(0,n.useRef)([]);return((0,n.useEffect)(()=>{e&&l.current[s]?.scrollIntoView({block:"nearest"})},[s,e]),e&&0!==r.length)?(0,t.jsx)("div",{className:"absolute left-0 right-0 bottom-full mb-3 z-20",children:(0,t.jsx)("div",{role:"listbox",id:i,"aria-label":"Mention suggestions",className:"max-h-56 overflow-y-auto rounded-xl border border-zinc-200 bg-white shadow-lg",children:r.map((e,n)=>{let r=n===s;return(0,t.jsx)("button",{type:"button",role:"option",id:`${o}-${e.id}`,"aria-selected":r,ref:e=>{l.current[n]=e},className:`w-full px-3 py-2 text-left text-sm transition-colors ${r?"bg-blue-50 text-zinc-900":"text-zinc-700 hover:bg-zinc-50"}`,onMouseDown:e=>{e.preventDefault()},onClick:()=>a(e),children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:e.color},"aria-hidden":!0}),(0,t.jsx)("span",{className:"font-medium",children:e.name}),"all"===e.id?(0,t.jsx)("span",{className:"text-xs text-zinc-400",children:"All participants"}):e.model&&(0,t.jsx)("span",{className:"text-xs text-zinc-400",children:e.model})]})},e.id)})})}):null}function hN({isOpen:e,commands:r,activeIndex:s,listboxId:i,optionIdPrefix:o,onSelect:a}){let l=(0,n.useRef)([]);return((0,n.useEffect)(()=>{e&&l.current[s]?.scrollIntoView({block:"nearest"})},[s,e]),e&&0!==r.length)?(0,t.jsx)("div",{className:"absolute left-0 right-0 bottom-full mb-3 z-20",children:(0,t.jsx)("div",{role:"listbox",id:i,"aria-label":"Command suggestions",className:"max-h-56 overflow-y-auto rounded-xl border border-zinc-200 bg-white shadow-lg",children:r.map((e,n)=>{let r=n===s;return(0,t.jsx)("button",{type:"button",role:"option",id:`${o}-${e.name.slice(1)}`,"aria-selected":r,ref:e=>{l.current[n]=e},className:`w-full px-3 py-2 text-left text-sm transition-colors ${r?"bg-blue-50 text-zinc-900":"text-zinc-700 hover:bg-zinc-50"}`,onMouseDown:e=>e.preventDefault(),onClick:()=>a(e),children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium font-mono",children:e.name}),e.aliases&&e.aliases.length>0&&(0,t.jsxs)("span",{className:"text-xs text-zinc-300 font-mono",children:["(",e.aliases.join(", "),")"]}),(0,t.jsx)("span",{className:"text-xs text-zinc-400",children:e.description})]})},e.name)})})}):null}var hT=e.i(32857);let hj=(0,l.default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]),hO=(0,l.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);function hE({suggestion:e,isActive:n,optionId:r,onSelect:s,onAttachContents:i,itemRef:o}){let a="folder"===e.type,l="contents"===e.attachMode,d=function(e){if(!e)return null;let t=Math.floor((Date.now()-e)/864e5);return 0===t?"Today":1===t?"Yesterday":t<7?`${t}d ago`:t<30?`${Math.floor(t/7)}w ago`:t<365?`${Math.floor(t/30)}mo ago`:`${Math.floor(t/365)}y ago`}(e.modifiedAt),c=e.relativePath??e.path;return(0,t.jsxs)("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors ${n?"bg-blue-50":"hover:bg-zinc-50"}`,children:[(0,t.jsx)("span",{className:"shrink-0 text-zinc-400","aria-hidden":!0,children:a?n?(0,t.jsx)(U,{className:"h-4 w-4 text-amber-500"}):(0,t.jsx)(hO,{className:"h-4 w-4 text-amber-400"}):(0,t.jsx)(hj,{className:"h-4 w-4"})}),(0,t.jsxs)("button",{type:"button",role:"option",id:r,"aria-selected":n,ref:o,className:"min-w-0 flex-1 text-left",onMouseDown:e=>e.preventDefault(),onClick:()=>s(e),tabIndex:-1,children:[(0,t.jsxs)("span",{className:"flex items-baseline gap-2",children:[(0,t.jsx)("span",{className:`block truncate font-mono text-xs ${n?"text-zinc-900":"text-zinc-700"}`,children:c}),d&&(0,t.jsx)("span",{className:"shrink-0 text-xs text-zinc-400",children:d})]}),a&&e.manifest&&(0,t.jsxs)("span",{className:"block text-xs text-zinc-400",children:[e.manifest.childCount," items ·"," ",e.manifest.sizeSummary,l?(0,t.jsx)("span",{className:"ml-1 font-medium text-blue-500",children:"full tree"}):(0,t.jsx)("span",{className:"ml-1 text-zinc-400",children:"manifest"})]})]}),a&&!l&&(0,t.jsx)("button",{type:"button",className:"shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 transition-colors",title:"Attach full directory contents instead of manifest","aria-label":`Attach full contents of ${c}`,onMouseDown:e=>e.preventDefault(),onClick:()=>i(e),tabIndex:-1,children:"Attach contents"}),a&&l&&(0,t.jsx)("span",{className:"shrink-0 rounded bg-blue-50 px-1.5 py-0.5 text-xs font-medium text-blue-600",children:"full tree"})]})}var hA=e.i(26410);function hI({isOpen:e,suggestions:r,activeIndex:s,isLoading:i,error:o,listboxId:a,optionIdPrefix:l,onSelect:d,onAttachContents:c}){let h=(0,n.useRef)([]),u=(0,n.useRef)(null),[p,f]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{e&&h.current[s]?.scrollIntoView({block:"nearest"})},[s,e]),(0,n.useEffect)(()=>{e&&u.current&&f(u.current.getBoundingClientRect().top<280)},[e]),!e)return null;let m=r.length>0?`${l}-${s}`:void 0;return(0,t.jsx)("div",{ref:u,className:`${p?"absolute left-0 right-0 top-full mt-2 z-20":"absolute left-0 right-0 bottom-full mb-3 z-20"} ${hA.default.popover}`,children:(0,t.jsxs)("div",{role:"listbox",id:a,"aria-label":"File suggestions","aria-activedescendant":m,className:"max-h-64 overflow-y-auto rounded-xl border border-zinc-200 bg-white shadow-lg",children:[o&&!i&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-red-500",role:"alert",children:[(0,t.jsx)(hT.AlertCircle,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,t.jsx)("span",{children:o})]}),!o&&i&&0===r.length&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-zinc-400","aria-live":"polite","aria-label":"Searching for files",children:[(0,t.jsx)(N,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),(0,t.jsx)("span",{children:"Searching…"})]}),!o&&!i&&0===r.length&&(0,t.jsx)("div",{className:"px-3 py-3 text-sm text-zinc-400","aria-live":"polite",children:"No results"}),!o&&i&&r.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1 text-xs text-zinc-400 border-b border-zinc-100",children:[(0,t.jsx)(N,{className:"h-3 w-3 animate-spin","aria-hidden":!0}),(0,t.jsx)("span",{"aria-live":"polite","aria-label":"Updating results",children:"Updating…"})]}),r.length>0&&r.map((e,n)=>(0,t.jsx)(hE,{suggestion:e,isActive:n===s,optionId:`${l}-${n}`,onSelect:d,onAttachContents:c,itemRef:e=>{h.current[n]=e}},e.path))]})})}function hD({isOpen:e,suggestions:n,activeIndex:r,listboxId:s,optionIdPrefix:i,onSelect:o}){return e&&0!==n.length?(0,t.jsxs)("div",{className:"absolute bottom-full left-0 mb-2 w-80 bg-white rounded-xl shadow-xl border border-slate-200 overflow-hidden z-50 animate-in fade-in zoom-in-95 duration-100",role:"listbox",id:s,children:[(0,t.jsx)("div",{className:"px-3 py-2 bg-slate-50 border-b border-slate-100 text-[11px] font-bold text-slate-500 uppercase tracking-wider",children:"Reference Discussion"}),(0,t.jsx)("div",{className:"max-h-64 overflow-y-auto p-1",children:n.map((e,n)=>{let s=n===r;return(0,t.jsxs)("button",{role:"option",id:`${i}-${n}`,"aria-selected":s,onClick:()=>o(e),className:`w-full text-left px-3 py-2.5 rounded-lg flex items-start gap-3 transition-colors ${s?"bg-indigo-50":"hover:bg-slate-50"}`,children:[(0,t.jsx)("div",{className:`mt-0.5 p-1.5 rounded-md ${s?"bg-indigo-100 text-indigo-600":"bg-slate-100 text-slate-500"}`,children:(0,t.jsx)(C,{size:14,strokeWidth:2.5})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:`text-sm font-semibold truncate ${s?"text-indigo-900":"text-slate-900"}`,children:e.title}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,t.jsxs)("span",{className:`text-xs ${s?"text-indigo-600":"text-slate-500"}`,children:[e.replies.length," replies"]}),(0,t.jsx)("span",{className:"text-slate-300",children:"•"}),(0,t.jsxs)("span",{className:"text-[10px] text-slate-400 flex items-center gap-1",children:[(0,t.jsx)(en.Clock,{size:10}),function(e){if(!e)return"";let t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h`:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e)}(e.lastActivityAt)]})]})]})]},e.rootMessageId)})})]}):null}var hR=e.i(24429);let hP=(0,l.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);function hz({attachments:e,onRemove:n,onRetry:r}){return 0===e.length?null:(0,t.jsx)("div",{className:"flex flex-wrap gap-2 px-1 pb-2",children:e.map(e=>{var s;let i=e.mimeType.startsWith("image/"),o="failed"===e.status,a="uploading"===e.status;return(0,t.jsxs)("div",{className:`relative group flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-xs transition-all ${o?"border-red-200 bg-red-50 text-red-700":"border-slate-200 bg-slate-50 text-slate-600"}`,children:[i&&e.previewUrl?(0,t.jsx)("img",{src:e.previewUrl,alt:e.filename,className:"w-8 h-8 rounded object-cover shrink-0"}):(0,t.jsx)("div",{className:"w-8 h-8 rounded bg-slate-100 flex items-center justify-center shrink-0",children:i?(0,t.jsx)(hP,{className:"w-4 h-4 text-slate-400"}):(0,t.jsx)(w.FileText,{className:"w-4 h-4 text-slate-400"})}),(0,t.jsxs)("div",{className:"min-w-0 max-w-[120px]",children:[(0,t.jsx)("div",{className:"truncate font-medium",children:e.filename}),o&&e.error?(0,t.jsx)("div",{className:"truncate text-[10px] text-red-500",children:e.error}):(0,t.jsx)("div",{className:"text-[10px] text-slate-400",children:(s=e.size)<1024?`${s}B`:s<1048576?`${(s/1024).toFixed(0)}KB`:`${(s/1048576).toFixed(1)}MB`})]}),a&&(0,t.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-slate-200 rounded-b-lg overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-blue-500 transition-all",style:{width:`${e.progress}%`}})}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[o&&(0,t.jsx)("button",{type:"button",onClick:()=>r(e.id),className:"p-0.5 rounded hover:bg-red-100 transition-colors",title:"Retry upload",children:(0,t.jsx)(hR.RefreshCw,{className:"w-3 h-3"})}),(0,t.jsx)("button",{type:"button",onClick:()=>n(e.id),className:"p-0.5 rounded hover:bg-slate-200 transition-colors",title:"Remove",children:(0,t.jsx)(P.X,{className:"w-3 h-3"})})]})]},e.id)})})}function h$({onDrop:e,children:r}){let[s,i]=(0,n.useState)(!1),o={current:0},a=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),o.current++,e.dataTransfer.types.includes("Files")&&i(!0)},[]),l=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),d=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),o.current--,0===o.current&&i(!1)},[]),c=(0,n.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),o.current=0,i(!1),t.dataTransfer.files.length>0&&e(t.dataTransfer.files)},[e]);return(0,t.jsxs)("div",{className:"relative",onDragEnter:a,onDragOver:l,onDragLeave:d,onDrop:c,children:[r,s&&(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-lg border-2 border-dashed border-blue-400 bg-blue-50/80 pointer-events-none",children:(0,t.jsx)("span",{className:"text-sm font-medium text-blue-600",children:"Drop files to attach"})})]})}let hL=(0,l.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]);function hB(e,t,n,r,s){if(!e)return;let i=hC(e,t,n,r);i&&e.chain().focus().deleteRange(i).insertContent(s).insertContent(" ").run()}function hV({onSend:e,onStop:r,loading:s,participants:i,messages:o=[],commands:a,placeholder:l="Message — @name to mention, /search, /summarize",workspaceRoots:d=[],onConfigureRoots:c,pendingThreadInsert:h,onClearPendingThread:u}){let[p,f]=(0,n.useState)(10),m=(0,n.useRef)(null),g=(0,n.useRef)(!1),x=(0,n.useCallback)(()=>{m.current?.click()},[]),[y,b]=(0,n.useState)([]),v=function({participants:e,maxSuggestions:t=6}){let[r,s]=(0,n.useState)(null),[i,o]=(0,n.useState)(0),[a,l]=(0,n.useState)(!1),d=null!==r&&!a,c=r?.query??"",h=(0,n.useMemo)(()=>{let n;return n=c.toLowerCase(),[hh,...e].map(e=>{let t=e.name.toLowerCase(),r=e.id.toLowerCase();return n?t.startsWith(n)?{item:e,score:3,name:t}:r.startsWith(n)?{item:e,score:2,name:t}:t.includes(n)?{item:e,score:1,name:t}:null:{item:e,score:0,name:t}}).filter(e=>null!==e).sort((e,t)=>e.score!==t.score?t.score-e.score:e.name.localeCompare(t.name)).slice(0,t).map(e=>e.item)},[e,c,t]),u=(0,n.useCallback)((e,t)=>{let n=function(e,t){if(t<0||t>e.length)return null;let n=t;for(;n>0&&!/\s/.test(e[n-1]);)n--;let r=e.slice(n,t);if(!r.startsWith("@")||r.startsWith("@@@")||r.startsWith("@#"))return null;let s=r.startsWith("@@"),i=r.slice(s?2:1);return hc.test(i)?{startIndex:n,endIndex:t,query:i.toLowerCase(),mode:s?"parallel":"sequential",isParallel:s}:null}(e,t);s(e=>((e?.startIndex!==n?.startIndex||e?.isParallel!==n?.isParallel||e?.query!==n?.query)&&o(0),n))},[]),p=(0,n.useCallback)((e,t)=>{a||u(e,t)},[a,u]),f=(0,n.useCallback)(e=>{if(!d||0===h.length)return!1;switch(e.key){case"ArrowDown":return e.preventDefault(),o(e=>e<h.length-1?e+1:0),!0;case"ArrowUp":return e.preventDefault(),o(e=>e>0?e-1:h.length-1),!0;case"Enter":case"Tab":return e.preventDefault(),!0;case"Escape":return e.preventDefault(),s(null),!0;default:return!1}},[d,h.length]),m=(0,n.useCallback)(e=>{if(!r)return null;let t=r.isParallel?"@@":"@";return{text:`${t}${e.name} `,startIndex:r.startIndex,endIndex:r.endIndex}},[r]),g=(0,n.useCallback)(()=>{s(null),o(0)},[]);return{isOpen:d,query:c,filteredSuggestions:h,activeIndex:i,token:r,isComposing:a,handleInput:p,handleKeyDown:f,selectSuggestion:m,close:g,startComposition:(0,n.useCallback)(()=>{l(!0)},[]),endComposition:(0,n.useCallback)((e,t)=>{l(!1),u(e,t)},[u])}}({participants:i,maxSuggestions:6}),w=function({commands:e,maxSuggestions:t=6}){let[r,s]=(0,n.useState)(null),[i,o]=(0,n.useState)(0),a=null!==r,l=r?.query??"",d=(0,n.useMemo)(()=>{let n;return(n=l.toLowerCase())?e.filter(e=>!!e.name.slice(1).toLowerCase().startsWith(n)||(e.aliases?.some(e=>e.toLowerCase().startsWith(n))??!1)).slice(0,t):e.slice(0,t)},[e,l,t]),c=(0,n.useCallback)((e,t)=>{let n=function(e,t){if(t<0||t>e.length||!e.startsWith("/"))return null;let n=e.slice(0,t);if(/\s/.test(n))return null;let r=n.slice(1);return hu.test(r)?{startIndex:0,endIndex:t,query:r.toLowerCase()}:null}(e,t);s(e=>(e?.query!==n?.query&&o(0),n))},[]),h=(0,n.useCallback)(e=>{if(!a||0===d.length)return!1;switch(e.key){case"ArrowDown":return e.preventDefault(),o(e=>e<d.length-1?e+1:0),!0;case"ArrowUp":return e.preventDefault(),o(e=>e>0?e-1:d.length-1),!0;case"Enter":case"Tab":return e.preventDefault(),!0;case"Escape":return e.preventDefault(),s(null),!0;default:return!1}},[a,d.length]),u=(0,n.useCallback)(e=>!!r&&(e.execute(),s(null),o(0),!0),[r]);return{isOpen:a,query:l,filteredCommands:d,activeIndex:i,token:r,handleInput:c,handleKeyDown:h,selectCommand:u,close:(0,n.useCallback)(()=>{s(null),o(0)},[])}}({commands:a,maxSuggestions:6}),k=function({maxSuggestions:e=8,debounceMs:t=150}={}){let[r,s]=(0,n.useState)(null),[i,o]=(0,n.useState)([]),[a,l]=(0,n.useState)(0),[d,c]=(0,n.useState)(!1),[h,u]=(0,n.useState)(null),p=(0,n.useRef)(null),f=(0,n.useRef)(null),m=(0,n.useRef)(null),g=null!==r,x=(0,n.useCallback)(async(t,n)=>{p.current&&p.current.abort();let r=new AbortController;p.current=r,c(!0),u(null);try{let s=t.endsWith("/"),i=s?"*":t,a=new URLSearchParams({q:i,limit:String(e),includeFolders:"1"});if(s){let e="@~"===n?`${$.default.env.HOME??"~"}/${t.slice(0,-1)}`:`/${t.slice(0,-1)}`;a.set("root",e)}else"@~"===n&&a.set("root",$.default.env.HOME??"~");let d=await fetch(`/api/file-search?${a.toString()}`,{signal:r.signal});if(!d.ok){let e=await d.json().catch(()=>({}));throw Error(e.error??`HTTP ${d.status}`)}let c=await d.json();o(c.files.map(e=>({...e,attachMode:"folder"===e.type?"manifest":void 0}))),l(0)}catch(e){if("AbortError"===e.name)return;u(e.message??"Search failed"),o([])}finally{c(!1)}},[e]),y=(0,n.useCallback)((n,r)=>{if(null!==f.current&&clearTimeout(f.current),n!==m.current){if(n.length<3){p.current&&(p.current.abort(),p.current=null),m.current=n,c(!1),u(null),o(hm.slice(0,e).map(e=>({...e,attachMode:"manifest"}))),l(0);return}f.current=setTimeout(()=>{m.current=n,x(n,r)},t)}},[t,x,e]);(0,n.useEffect)(()=>()=>{null!==f.current&&clearTimeout(f.current),p.current&&p.current.abort()},[]);let b=(0,n.useCallback)((e,t)=>{let n=function(e,t){if(t<2||t>e.length)return null;let n=t;for(;n>0&&!/\s/.test(e[n-1]);)n--;let r=e.slice(n,t);if(!r.startsWith("@/")&&!r.startsWith("@~"))return null;let s=r.slice(0,2);return{startIndex:n,endIndex:t,query:r.slice(2),trigger:s}}(e,t);s(e=>((e?.startIndex!==n?.startIndex||e?.query!==n?.query||e?.trigger!==n?.trigger)&&null===n&&(null!==f.current&&clearTimeout(f.current),p.current&&(p.current.abort(),p.current=null),m.current=null,o([]),c(!1),u(null)),n)),n&&y(n.query,n.trigger)},[y]),v=(0,n.useCallback)(e=>{if(!g||0===i.length)return!1;switch(e.key){case"ArrowDown":return e.preventDefault(),l(e=>e<i.length-1?e+1:0),!0;case"ArrowUp":return e.preventDefault(),l(e=>e>0?e-1:i.length-1),!0;case"Enter":return e.preventDefault(),!0;case"Tab":return!0;case"Escape":return e.preventDefault(),s(null),o([]),!0;default:return!1}},[g,i.length]),w=(0,n.useCallback)(e=>{if(!r)return null;let t=hg(e.relativePath??e.path,r),n="folder"===e.type?"/":"",i=`@${t}${n} `;return s(null),o([]),{text:i,startIndex:r.startIndex,endIndex:r.endIndex}},[r]),k=(0,n.useCallback)(e=>{if(!r||"folder"!==e.type)return null;let t=hg(e.relativePath??e.path,r),n=t.startsWith("~/")?"@~":"@/",i=t.slice(1),o=`@${t}/`,a=r.startIndex+o.length,l=`${i}/`;return s({startIndex:r.startIndex,endIndex:a,query:l,trigger:n}),m.current=null,y(l,n),{text:o,startIndex:r.startIndex,endIndex:r.endIndex}},[r,y]),S=(0,n.useCallback)(e=>{o(t=>t.map(t=>t.path===e.path?{...t,attachMode:"contents"}:t))},[]);return{isOpen:g,token:r,suggestions:i,activeIndex:a,isLoading:d,error:h,handleInput:b,handleKeyDown:v,selectSuggestion:w,drillDown:k,close:(0,n.useCallback)(()=>{s(null),o([]),l(0)},[]),onAttachContents:S}}({maxSuggestions:8}),S=function({messages:e,maxSuggestions:t=5}){let[r,s]=(0,n.useState)(!1),[i,o]=(0,n.useState)(""),[a,l]=(0,n.useState)(0),[d,c]=(0,n.useState)([]),[h,u]=(0,n.useState)(null),p=(0,n.useRef)([]);(0,n.useEffect)(()=>{let t=e.filter(e=>!e.rootMessageId),n=new Map;e.forEach(e=>{if(e.rootMessageId){let t=n.get(e.rootMessageId)||[];t.push(e),n.set(e.rootMessageId,t)}}),p.current=t.map(e=>{let t=n.get(e.id)||[],r=[e,...t],s=Math.max(...r.map(e=>e.timestamp)),i=e.content.slice(0,60).replace(/\n/g," ").trim()||"Untitled",o=[...new Set(r.map(e=>e.participantId||"user"))];return{rootMessageId:e.id,title:i,rootMessage:e,replies:t,participantIds:o,lastActivityAt:s}}).sort((e,t)=>t.lastActivityAt-e.lastActivityAt)},[e]);let f=(0,n.useCallback)((e,n)=>{let r=e.slice(0,n).match(/@#([^@#\s]*)$/);if(r){s(!0);let e=r[1].toLowerCase();o(e),u(r.index),l(0),c(p.current.filter(t=>t.title.toLowerCase().includes(e)).slice(0,t))}else s(!1),u(null)},[t]),m=(0,n.useCallback)(e=>!!r&&0!==d.length&&("ArrowDown"===e.key?(e.preventDefault(),l(e=>(e+1)%d.length),!0):"ArrowUp"===e.key?(e.preventDefault(),l(e=>(e-1+d.length)%d.length),!0):"Escape"===e.key&&(e.preventDefault(),s(!1),!0)),[r,d.length]),g=(0,n.useCallback)(e=>null===h?null:{startIndex:h,endIndex:h+2+i.length,text:""},[h,i]);return{isOpen:r,suggestions:d,activeIndex:a,handleInput:f,handleKeyDown:m,selectSuggestion:g,close:(0,n.useCallback)(()=>{s(!1),u(null)},[]),exportDiscussion:(0,n.useCallback)(async e=>{let t=[];try{let e=await fetch("/api/participants");e.ok&&(t=await e.json())}catch(e){console.warn("Failed to fetch participants for export",e)}let n=await fetch("/api/thread-export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootMessageId:e.rootMessageId,title:e.title,messages:[e.rootMessage,...e.replies],participants:t})});if(!n.ok)throw Error(`Export failed: ${await n.text()}`);return await n.json()},[])}}({messages:o,maxSuggestions:8}),C=function(){let[e,t]=(0,n.useState)([]),r=(0,n.useRef)(new Map),s=(0,n.useCallback)(e=>{let n=new XMLHttpRequest;r.current.set(e.id,n);let s=new FormData;s.append("file",e.file),n.upload.onprogress=n=>{if(n.lengthComputable){let r=Math.round(n.loaded/n.total*100);t(t=>t.map(t=>t.id===e.id?{...t,progress:r}:t))}},n.onload=()=>{if(r.current.delete(e.id),n.status>=200&&n.status<300)try{let r=JSON.parse(n.responseText),s=r.attachments?.[0];if(s)return void t(t=>t.map(t=>t.id===e.id?{...t,status:"uploaded",progress:100,serverId:s.id}:t))}catch{}let s=(()=>{try{return JSON.parse(n.responseText)?.error||"Upload failed"}catch{return"Upload failed"}})();t(t=>t.map(t=>t.id===e.id?{...t,status:"failed",error:s}:t))},n.onerror=()=>{r.current.delete(e.id),t(t=>t.map(t=>t.id===e.id?{...t,status:"failed",error:"Network error"}:t))},n.open("POST","/api/upload"),n.send(s)},[]),i=(0,n.useCallback)(n=>{let r=Array.from(n),i=function(e){let t=e.reduce((e,t)=>e+t.size,0);if(t>0x3200000){let e=(t/1048576).toFixed(1);return{file:"(total)",reason:`Total attachment size (${e}MB) exceeds 50MB limit`}}return null}([...e.map(e=>({name:e.filename,size:e.size,type:e.mimeType})),...r.map(e=>({name:e.name,size:e.size,type:e.type}))]);if(i)return void alert(i.reason);let o=[];for(let e of r){let t=function(e){let t=e.name.includes(".")?"."+e.name.split(".").pop().toLowerCase():"";if(hf.has(t))return{file:e.name,reason:`File type "${t}" is not allowed`};if(e.type&&!hp.has(e.type))return{file:e.name,reason:`File type "${e.type}" is not supported`};if(!e.type&&!hp.has("application/octet-stream"),e.size>0xa00000){let t=(e.size/1048576).toFixed(1);return{file:e.name,reason:`File is too large (${t}MB). Maximum is 10MB`}}return 0===e.size?{file:e.name,reason:"File is empty"}:null}({name:e.name,size:e.size,type:e.type});if(t){o.push({id:crypto.randomUUID(),file:e,filename:e.name,mimeType:e.type,size:e.size,previewUrl:null,progress:0,status:"failed",error:t.reason});continue}let n=e.type.startsWith("image/")?URL.createObjectURL(e):null,r={id:crypto.randomUUID(),file:e,filename:e.name,mimeType:e.type||"application/octet-stream",size:e.size,previewUrl:n,progress:0,status:"uploading"};o.push(r)}for(let e of(t(e=>[...e,...o]),o))"uploading"===e.status&&s(e)},[e,s]),o=(0,n.useCallback)(e=>{t(t=>{let n=t.find(t=>t.id===e);n?.previewUrl&&URL.revokeObjectURL(n.previewUrl);let s=r.current.get(e);return s&&(s.abort(),r.current.delete(e)),n?.serverId&&fetch(`/api/upload/${n.serverId}`,{method:"DELETE"}).catch(()=>{}),t.filter(t=>t.id!==e)})},[]),a=(0,n.useCallback)(e=>{t(t=>{let n=t.find(t=>t.id===e);if(!n||"failed"!==n.status)return t;let r=t.map(t=>t.id===e?{...t,status:"uploading",error:void 0,progress:0}:t),i=r.find(t=>t.id===e);return setTimeout(()=>s(i),0),r})},[s]),l=(0,n.useCallback)(()=>{t(e=>{for(let t of e){t.previewUrl&&URL.revokeObjectURL(t.previewUrl);let e=r.current.get(t.id);e&&e.abort()}return r.current.clear(),[]})},[]),d=0===e.length||e.every(e=>"uploaded"===e.status||"failed"===e.status),c=e.some(e=>"uploaded"===e.status),h=e.filter(e=>"uploaded"===e.status&&e.serverId);return{staged:e,stageFiles:i,remove:o,retry:a,clear:l,canSend:d,hasUploaded:c,attachmentIds:h.map(e=>e.serverId),getAttachmentMetas:(0,n.useCallback)(()=>h.map(e=>({id:e.serverId,filename:e.filename,mimeType:e.mimeType,size:e.size,status:"uploaded",url:`/api/attachments/${e.serverId}`})),[h])}}(),M=function(){let[e,t]=(0,n.useState)([]),r=(0,n.useCallback)((e,n,r)=>{t(t=>t.find(t=>t.path===e)?t.map(t=>t.path===e?{...t,label:n,attachMode:r??t.attachMode}:t):[...t,{kind:"file-path",id:crypto.randomUUID(),path:e,label:n,attachMode:r}])},[]);return{filePaths:e,addFilePath:r,removeFilePath:(0,n.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),clearFilePaths:(0,n.useCallback)(()=>{t([])},[]),hasFilePaths:e.length>0}}(),N=function(e={},t=[]){let n=(0,eu.useRef)(e);n.current=e;let[r]=(0,eu.useState)(()=>new ld(n)),s=(0,ef.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,eu.useDebugValue)(s),(0,eu.useEffect)(r.onRender(t)),!function(e){var t;let[n]=(0,eu.useState)(()=>new lo(e.editor)),r=(0,le.useSyncExternalStoreWithSelector)(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(t=e.equalityFn)?t:a7);li(()=>n.watch(e.editor),[e.editor,n]),(0,eu.useDebugValue)(r)}({editor:s,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),s}({immediatelyRender:!1,extensions:[hd.configure({heading:!1,bulletList:!1,orderedList:!1,listItem:!1,blockquote:!1,codeBlock:!1,code:!1,horizontalRule:!1,hardBreak:{keepMarks:!1}}),hi.configure({placeholder:l}),hb,hv,hw],editorProps:{attributes:{class:"composer-editor",role:"combobox","aria-autocomplete":"list"},handlePaste:(e,t)=>{let n=t.clipboardData?.files;return!!n&&n.length>0&&(t.preventDefault(),C.stageFiles(n),!0)},handleDOMEvents:{compositionstart:()=>(g.current=!0,v.startComposition(),!1),compositionend:(e,t)=>(g.current=!1,setTimeout(()=>{if(!N)return;let e=hk(N);e&&v.endComposition(e.text,e.cursorPos)},0),!1)},handleKeyDown:(e,t)=>{if("Tab"===t.key||"Enter"===t.key&&!t.shiftKey){if(w.isOpen&&w.filteredCommands.length>0){t.preventDefault();let e=w.filteredCommands[w.activeIndex];return e&&I(e),!0}if(k.isOpen&&k.suggestions.length>0){t.preventDefault();let e=k.suggestions[k.activeIndex];return e&&("folder"===e.type?E(e):O(e)),!0}if(S.isOpen&&S.suggestions.length>0){t.preventDefault();let e=S.suggestions[S.activeIndex];return e&&A(e),!0}if(v.isOpen&&v.filteredSuggestions.length>0){t.preventDefault();let e=v.filteredSuggestions[v.activeIndex];return e&&j(e),!0}}let n={key:t.key,preventDefault:()=>t.preventDefault()};return!!(w.isOpen&&w.handleKeyDown(n)||k.isOpen&&k.handleKeyDown(n)||S.isOpen&&S.handleKeyDown(n)||v.handleKeyDown(n))||"Enter"===t.key&&!t.shiftKey&&(t.preventDefault(),D(),!0)}},onUpdate:({editor:e})=>{if(g.current)return;let t=hk(e);t&&(v.handleInput(t.text,t.cursorPos),w.handleInput(t.text,t.cursorPos),k.handleInput(t.text,t.cursorPos),S.handleInput(t.text,t.cursorPos))},onBlur:()=>{v.close(),w.close(),k.close(),S.close()}});(0,n.useEffect)(()=>{if(!h||!N)return;let{title:e,threadId:t,messages:n}=h;N.chain().focus().insertContent({type:"threadMention",attrs:{threadId:t,title:e}}).insertContent(" ").run();let r=n[0];if(r){let s={rootMessageId:t,title:e,rootMessage:r,replies:n.slice(1),participantIds:[...new Set(n.map(e=>e.participantId||"user"))],lastActivityAt:Math.max(...n.map(e=>e.timestamp))};S.exportDiscussion(s).then(e=>b(t=>[...t,e])).catch(e=>console.error("Failed to export discussion for Add to chat:",e))}u?.()},[h]);let T=(0,n.useCallback)(()=>{if(!N)return;let e=hk(N);e&&v.handleInput(e.text,e.cursorPos)},[N,v]),j=(0,n.useCallback)(e=>{if(!N)return;let t=v.selectSuggestion(e);if(!t)return;let n=hk(N);if(!n)return;let r=t.text.startsWith("@@"),s={type:"participantMention",attrs:{id:e.id,name:e.name,mode:r?"parallel":"sequential"}};hB(N,n.blockStart,t.startIndex,t.endIndex,s),v.close()},[N,v]),O=(0,n.useCallback)(e=>{if(!N)return;let t=k.selectSuggestion(e);if(!t)return;let n=hk(N);if(!n)return;let r={type:"fileMention",attrs:{path:e.path,relativePath:e.relativePath??e.path,trigger:k.token?.trigger??"@/",attachMode:e.attachMode}};hB(N,n.blockStart,t.startIndex,t.endIndex,r),M.addFilePath(e.path,e.relativePath??e.path,e.attachMode)},[N,k,M]),E=(0,n.useCallback)(e=>{if(!N)return;let t=hk(N);if(!t)return;let n=k.drillDown(e);if(!n)return;let r=hC(N,t.blockStart,n.startIndex,n.endIndex);r&&N.chain().focus().deleteRange(r).insertContent(n.text).run()},[N,k]),A=(0,n.useCallback)(async e=>{if(!N)return;let t=S.selectSuggestion(e);if(!t)return;let n=hk(N);if(!n)return;let r={type:"threadMention",attrs:{threadId:e.rootMessageId,title:e.title}};hB(N,n.blockStart,t.startIndex,t.endIndex,r);try{let t=await S.exportDiscussion(e);b(e=>[...e,t])}catch(e){console.error("Failed to export discussion:",e)}},[N,S]),I=(0,n.useCallback)(e=>{w.selectCommand(e),N&&N.commands.clearContent()},[w,N]),D=(0,n.useCallback)(async()=>{if(!N)return;let t=(function(e){if(!e.content)return"";let t=[];for(let n of e.content)n.type,t.push(function(e){if(!e.content)return"";let t="";for(let n of e.content)switch(n.type){case"text":t+=n.text??"";break;case"participantMention":{let e=n.attrs??{},r="parallel"===e.mode?"@@":"@";t+=`${r}${e.name}`;break}case"fileMention":{let e=n.attrs??{},r=e.relativePath||e.path;t+=`@${r}`;break}case"threadMention":{let e=((n.attrs??{}).threadId??"").slice(0,8);t+=`@#${e}`;break}default:"hardBreak"===n.type&&(t+="\n")}return t}(n));return t.join("\n")})(N.getJSON()).trim();if(!t&&!C.hasUploaded&&!M.hasFilePaths||!C.canSend)return;if(t){let e=a.find(e=>e.name===t||e.aliases?.some(e=>`/${e}`===t));if(e){e.execute(),N.commands.clearContent(),w.close(),v.close();return}}let n=t||"(attached files)";if(y.length>0){let e=y.map(e=>`- "${e.title}" — ${e.summary} (full transcript: ${e.filePath})`).join("\n");n=`Referenced threads:
|
|
91
|
+
${e}
|
|
92
|
+
|
|
93
|
+
${n}`}if(M.hasFilePaths){let e=await hy(M.filePaths);e.contextPrefix&&(n=e.contextPrefix+n)}let r=C.attachmentIds.length>0?C.attachmentIds:void 0,s=r?C.getAttachmentMetas():void 0;e(n,p,r,s),N.commands.clearContent(),b([]),C.clear(),M.clearFilePaths(),v.close(),w.close(),S.close()},[N,p,v,w,a,e,C,M,y,S]),R=v.isOpen&&v.filteredSuggestions.length>0;w.isOpen&&w.filteredCommands.length,k.isOpen&&k.suggestions.length,S.isOpen&&S.suggestions.length,R&&v.filteredSuggestions[v.activeIndex];let P=C.staged.some(e=>"uploading"===e.status),z=!N||N.isEmpty;return(0,t.jsx)("div",{className:"pb-6",children:(0,t.jsx)("div",{className:"max-w-3xl mx-auto",children:(0,t.jsx)(h$,{onDrop:C.stageFiles,children:(0,t.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-lg p-1.5 focus-within:ring-4 focus-within:ring-slate-900/5 transition-all",children:[C.staged.length>0&&(0,t.jsx)("div",{className:"mx-2 mt-2 mb-1",children:(0,t.jsx)(hz,{attachments:C.staged,onRemove:C.remove,onRetry:C.retry})}),(0,t.jsxs)("div",{className:"flex items-end gap-2 p-2 relative",children:[(0,t.jsx)("button",{type:"button",onClick:x,className:"p-2.5 text-slate-400 hover:bg-slate-50 hover:text-slate-600 rounded-xl transition-all shrink-0","aria-label":"Attach file",title:"Attach file",children:(0,t.jsx)(hL,{className:"h-5 w-5",strokeWidth:1.75})}),(0,t.jsx)("input",{ref:m,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&e.target.files.length>0&&(C.stageFiles(e.target.files),e.target.value="")}}),(0,t.jsxs)("div",{className:"flex-1 relative",onClick:T,children:[(0,t.jsx)(ls,{editor:N,className:"composer-editor"}),(0,t.jsx)(hM,{isOpen:v.isOpen&&!w.isOpen,suggestions:v.filteredSuggestions,activeIndex:v.activeIndex,listboxId:"composer-mention-listbox",optionIdPrefix:"composer-mention-option",onSelect:j}),(0,t.jsx)(hN,{isOpen:w.isOpen,commands:w.filteredCommands,activeIndex:w.activeIndex,listboxId:"composer-command-listbox",optionIdPrefix:"composer-command-option",onSelect:I}),(0,t.jsx)(hI,{isOpen:k.isOpen,suggestions:k.suggestions,activeIndex:k.activeIndex,isLoading:k.isLoading,error:k.error,listboxId:"composer-file-mention-listbox",optionIdPrefix:"composer-file-mention-option",onSelect:e=>{"folder"===e.type?E(e):O(e)},onAttachContents:k.onAttachContents}),(0,t.jsx)(hD,{isOpen:S.isOpen&&!w.isOpen&&!k.isOpen,suggestions:S.suggestions,activeIndex:S.activeIndex,listboxId:"composer-thread-mention-listbox",optionIdPrefix:"composer-thread-mention-option",onSelect:A})]}),s?(0,t.jsx)("button",{type:"button",onClick:r,className:"h-10 px-4 bg-red-50 text-red-600 border border-red-200 rounded-xl font-bold text-sm hover:bg-red-100 shadow-sm flex items-center gap-2 transition-all shrink-0",children:"Stop"}):(0,t.jsxs)("button",{type:"button",onClick:D,disabled:z&&!C.hasUploaded&&!M.hasFilePaths||P,className:"h-10 px-4 bg-slate-900 text-white rounded-xl font-bold text-sm hover:bg-slate-800 disabled:opacity-50 disabled:hover:bg-slate-900 disabled:cursor-not-allowed shadow-md flex items-center gap-2 transition-all shrink-0",children:["Send",(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,t.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})]})]}),(0,t.jsxs)("div",{className:"px-4 pb-2 flex items-center gap-3 mt-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-tighter",children:"Turn Limit"}),(0,t.jsx)("select",{value:p,onChange:e=>f(Number(e.target.value)),className:"bg-transparent border-none outline-none text-[11px] font-bold text-slate-900 cursor-pointer appearance-none hover:text-indigo-600 transition-colors",children:[1,3,5,10,20,50].map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]}),(0,t.jsx)("div",{className:"w-px h-3 bg-slate-200"}),(0,t.jsx)("div",{className:"flex gap-1 items-center overflow-x-auto no-scrollbar",children:0===i.length?(0,t.jsx)("span",{className:"text-[10px] font-medium text-slate-400",children:"No agents active"}):i.map(e=>(0,t.jsx)("div",{className:"w-4 h-4 rounded-full bg-slate-100 shadow-sm flex items-center justify-center overflow-hidden shrink-0",title:e.name,children:(0,t.jsx)("img",{src:`https://api.dicebear.com/9.x/bottts-neutral/svg?seed=${e.id}&backgroundColor=${e.color?e.color.replace("#",""):"e2e8f0"}`,alt:e.name,className:"w-full h-full rounded-full ring-1 ring-slate-200 object-cover"})},e.id))})]})]})})})})}function hF({logs:e,participants:r,onClear:s,open:i,onToggle:o}){let[a,l]=(0,n.useState)(420),[d,c]=(0,n.useState)(null),h=(0,n.useRef)(null),u=(0,n.useRef)(!1),p=(0,n.useRef)(0),f=(0,n.useRef)(0),m=Object.fromEntries(r.map(e=>[e.id,e]));(0,n.useEffect)(()=>{i&&h.current?.scrollIntoView({behavior:"smooth"})},[e.length,i]);let g=(0,n.useCallback)(e=>{e.preventDefault(),u.current=!0,p.current=e.clientX,f.current=a,e.target.setPointerCapture(e.pointerId)},[a]),x=(0,n.useCallback)(e=>{if(!u.current)return;let t=p.current-e.clientX;l(Math.max(280,Math.min(f.current+t,.6*window.innerWidth)))},[]),y=(0,n.useCallback)(()=>{u.current=!1},[]);if(!i)return null;let b=d?e.filter(e=>e.participantId===d):e;return(0,t.jsxs)("div",{className:"flex h-full shrink-0",children:[(0,t.jsx)("div",{onPointerDown:g,onPointerMove:x,onPointerUp:y,className:"w-1.5 cursor-col-resize bg-zinc-800 hover:bg-zinc-600 transition-colors flex items-center justify-center shrink-0",children:(0,t.jsx)("div",{className:"h-8 w-0.5 rounded-full bg-zinc-500"})}),(0,t.jsxs)("div",{className:"flex flex-col bg-zinc-950 h-full",style:{width:a},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-zinc-800 shrink-0",children:[(0,t.jsx)("span",{className:"text-[11px] text-zinc-400 font-mono",children:"Logs"}),(0,t.jsxs)("select",{value:d||"",onChange:e=>c(e.target.value||null),className:"bg-zinc-800 text-zinc-300 text-[11px] rounded px-1.5 py-0.5 outline-none",children:[(0,t.jsx)("option",{value:"",children:"All"}),r.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:s,className:"text-[11px] text-zinc-500 hover:text-zinc-300",children:"Clear"}),(0,t.jsx)("button",{onClick:o,className:"text-[11px] text-zinc-500 hover:text-zinc-300",children:"✕"})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto font-mono text-[11px] leading-4 px-3 py-2",children:[b.map((e,n)=>{let r=m[e.participantId]?.name||e.participantId,s=m[e.participantId]?.color||"#888",i="stderr"===e.stream;return(0,t.jsxs)("div",{className:"flex gap-2 whitespace-pre-wrap break-all",children:[(0,t.jsx)("span",{className:"text-zinc-600 shrink-0 select-none",children:new Date(e.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}),(0,t.jsx)("span",{className:"shrink-0",style:{color:s},children:r}),(0,t.jsx)("span",{className:i?"text-red-400":"text-zinc-400",children:e.line})]},n)}),(0,t.jsx)("div",{ref:h})]})]})]})}let h_="agx-chat:uiSettings",hH={threadSidebarVisible:!1};function hU(){return void 0!==window.localStorage}function hW(){if(!hU())return{...hH};let e=window.localStorage.getItem(h_);if(!e)return{...hH};try{let t=JSON.parse(e);return{...hH,threadSidebarVisible:"boolean"==typeof t.threadSidebarVisible&&t.threadSidebarVisible}}catch{return{...hH}}}function hq(e){var t={...hW(),threadSidebarVisible:e};if(hU())try{window.localStorage.setItem(h_,JSON.stringify(t))}catch{}}let hK="agx-chat:project-agent-config",hJ={activeParticipantIdsByThread:{}};function hG(){return void 0!==window.localStorage}function hX(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if("string"!=typeof r)continue;let e=r.trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function hY(){if(!hG())return{...hJ};let e=window.localStorage.getItem(hK);if(!e)return{...hJ};try{let t=JSON.parse(e).activeParticipantIdsByThread;if(!t||"object"!=typeof t)return{...hJ};return{activeParticipantIdsByThread:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,hX(t)]))}}catch{return{...hJ}}}function hQ(e,t){let n=e.trim();if(!n)return;let r=hY();r.activeParticipantIdsByThread[n]=hX(t);if(hG())try{window.localStorage.setItem(hK,JSON.stringify(r))}catch{}}let hZ={threadSidebarVisible:!1,workspaceRoots:[],homeSearchConsent:!1,hasCompletedFirstRun:!1,fileIgnorePatterns:[]};function h0(e){return e&&"object"==typeof e?{threadSidebarVisible:"boolean"==typeof e.threadSidebarVisible?e.threadSidebarVisible:hZ.threadSidebarVisible,workspaceRoots:Array.isArray(e.workspaceRoots)?e.workspaceRoots.filter(e=>"string"==typeof e):hZ.workspaceRoots,homeSearchConsent:"boolean"==typeof e.homeSearchConsent?e.homeSearchConsent:hZ.homeSearchConsent,hasCompletedFirstRun:"boolean"==typeof e.hasCompletedFirstRun?e.hasCompletedFirstRun:hZ.hasCompletedFirstRun,fileIgnorePatterns:Array.isArray(e.fileIgnorePatterns)?e.fileIgnorePatterns.filter(e=>"string"==typeof e):hZ.fileIgnorePatterns}:hZ}let h1="/api/userPreferences";function h2(e){return e.json().then(e=>e&&"object"==typeof e?h0(e.preferences??e):h0(e)).catch(()=>h0(null))}function h3(e){return e.statusText||`Failed to reach ${h1} (${e.status})`}async function h5(){let e=await fetch(h1,{cache:"no-store"});if(!e.ok)throw Error(h3(e));return h2(e)}async function h4(e){let t=await fetch(h1,{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({preferences:e})});if(!t.ok)throw Error(h3(t));return h2(t)}let h6=(0,l.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);var h8=e.i(48071);function h7(){let[e,r]=(0,n.useState)("unknown"),[s,i]=(0,n.useState)([]),[o,a]=(0,n.useState)(""),[l,d]=(0,n.useState)(!1),c=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/status");if(!e.ok)return void r("unknown");let t=await e.json();r("ok"===t.status?"ok":"degraded");let n=t.services.filter(e=>"agx-chat"===e.name||"agx-cloud"===e.name);i(n),a(new Date().toLocaleTimeString())}catch{r("unknown"),i([])}},[]);return(0,n.useEffect)(()=>{c();let e=setInterval(c,3e4);return()=>clearInterval(e)},[c]),(0,t.jsxs)("div",{className:"relative",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[(0,t.jsx)(p.default,{href:"/status",className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-slate-200 bg-white hover:bg-slate-50 transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-400",title:"System status",children:(0,t.jsx)("span",{className:`h-2.5 w-2.5 rounded-full ${"ok"===e?"bg-emerald-400":"degraded"===e?"bg-amber-400":"bg-slate-300"} ${"degraded"===e?"animate-pulse":""}`})}),l&&(0,t.jsxs)("div",{className:"absolute top-full right-0 mt-1.5 w-52 rounded-lg border border-slate-200 bg-white p-3 shadow-lg z-50 text-xs",children:[s.length>0?(0,t.jsx)("ul",{className:"space-y-1.5",children:s.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-slate-700 font-medium",children:e.name}),(0,t.jsx)("span",{className:"ok"===e.status?"text-emerald-600":"error"===e.status?"text-red-500":"text-slate-400",children:"ok"===e.status?"Healthy":"error"===e.status?e.detail||"Error":"Unavailable"})]},e.name))}):(0,t.jsx)("p",{className:"text-slate-400",children:"Checking..."}),o&&(0,t.jsxs)("p",{className:"text-slate-400 mt-2 pt-1.5 border-t border-slate-100",children:["Last check: ",o]})]})]})}function h9(e,t=!1){return(t?e.replace(/(?:^|\n)Thinking\.\.\.[\s\S]*?\.\.\.done thinking\.?\s*/g,"\n").trim():e).replaceAll("<!-- thread-summary -->","").replaceAll("<!-- task-draft -->","").trim().replace(/\r\n/g,"\n").replace(/\n{3,}/g,"\n\n").trim()}function ue(e,t,n){let r=Object.fromEntries(t.map(e=>[e.id,e])),s=[];for(let t of e){let e="user"===t.role?"You":t.participantId?r[t.participantId]?.name||t.participantId:"Assistant",n=h9(t.content,"user"!==t.role);n&&(s.push(`**${e}:**`),s.push(""),s.push(n),s.push(""))}if(n){let e=function(e){if(0===e.tasks.length)return"";let t=new Map(e.tasks.map(e=>[e.id,e.title.trim()])),n=["## Draft Tasks",""];return e.projectName&&n.push(`Project: ${e.projectName}`),e.buildStatus&&n.push(`Build status: ${e.buildStatus.replaceAll("_"," ")}`),(e.projectName||e.buildStatus)&&n.push(""),e.tasks.forEach((r,s)=>{let i=h9(r.title)||`Task ${s+1}`,o=h9(r.description),a=(r.dependsOn||[]).map(e=>t.get(e)?.trim()).filter(e=>!!e),l=e.builtTaskIds?.[r.id];n.push(`${s+1}. [ ] **${i}**`),o&&n.push(o),a.length>0&&n.push(`Depends on: ${a.join(", ")}`),l&&n.push(`agx task id: \`${l}\``),n.push("")}),n.join("\n").trim()}(n);e&&s.push(e)}return s.join("\n").trim()}function ut(){let{threads:e,activeThreadId:i,selectThread:o,createThread:a,deleteThread:l,updateThreadMessages:d,isCreating:c,deletingThreadId:u,renamingThreadId:p,isLoading:f,isRestoringActiveThread:m,renameThread:x}=(0,s.useThreadState)(),{messages:y,streaming:b,loading:v,logs:w,sendMessage:k,loadHistory:S,clearLogs:C,stop:M,stopThread:N}=function(e){let[t,s]=(0,n.useState)([]),[i,o]=(0,n.useState)({}),[a,l]=(0,n.useState)(0),[d,c]=(0,n.useState)([]),h=(0,n.useRef)(new Set),u=(0,n.useRef)(new Map),p=(0,n.useRef)(e),f=(0,n.useRef)(e);p.current=e,f.current!==e&&(f.current=e,s([]),c([]),o({}));let m=(0,n.useCallback)(async e=>{let t=e?.trim()||p.current?.trim();if(!t){s([]),c([]);return}let n=r(t);try{let[e,r]=await Promise.all([fetch(`/api/history?${n}`),fetch(`/api/logs?${n}`)]);if(p.current!==t)return;e.ok&&s(await e.json()),r.ok&&c(await r.json())}catch{}},[]),g=(0,n.useCallback)(async e=>{let t=e?.trim()||p.current?.trim();if(!t){s([]),c([]);return}let n=r(t);await Promise.all([fetch(`/api/history?${n}`,{method:"DELETE"}),fetch(`/api/logs?${n}`,{method:"DELETE"})]),p.current===t&&(s([]),c([]))},[]),x=(0,n.useCallback)(async(e,t=10,n,r,i,a,d)=>{let f=n?.trim()||p.current?.trim();if(!f)return;let m=Date.now(),g=`user-${m}`,x={id:g,role:"user",participantId:null,content:e,timestamp:m,rootMessageId:r||null,parentMessageId:r||null,depth:+!!r,...a&&a.length>0?{attachments:a}:{}};s(e=>[...e,x]),l(e=>e+1);let y=new AbortController;h.current.add(y);let b=new Set,v=r||g;u.current.has(v)||u.current.set(v,new Set),u.current.get(v).add(y);try{let n=await fetch("/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:f,prompt:e,maxRounds:t,userMessageId:g,rootMessageId:r||void 0,attachmentIds:i?.length?i:void 0,activeParticipantIds:Array.isArray(d)?d:void 0}),signal:y.signal});if(!n.ok||!n.body)return;let a=n.body.getReader(),l=new TextDecoder,h="";for(;;){let{done:e,value:t}=await a.read();if(e)break;let n=(h+=l.decode(t,{stream:!0})).split("\n");for(let e of(h=n.pop()||"",n)){if(!e.startsWith("data: "))continue;let t=e.slice(6).trim();if(t)try{let e=JSON.parse(t);if(p.current!==f)continue;if("participant-thinking"===e.type)b.add(e.participantId),o(t=>({...t,[e.participantId]:{content:"",rootMessageId:v}}));else if("participant-error"===e.type)o(t=>({...t,[e.participantId]:{content:`[Error: ${e.error}]`,rootMessageId:v}}));else if("log"===e.type)c(t=>[...t,{timestamp:Date.now(),participantId:e.participantId,stream:e.stream,line:e.line}]);else if("message-reactions"===e.type)s(t=>t.map(t=>t.id===e.messageId?{...t,reactions:e.reactions}:t));else if("participant-end"===e.type){let t=e.content||"";if(t.trim()){let n={id:e.messageId||`${e.participantId}-${Date.now()}`,role:"assistant",participantId:e.participantId,content:t,timestamp:Date.now(),rootMessageId:v,parentMessageId:v,depth:1};s(e=>[...e,n])}o(t=>{let n={...t};return delete n[e.participantId],n})}}catch{}}}}catch{}finally{if(h.current.delete(y),u.current.get(v)?.delete(y),u.current.get(v)?.size===0&&u.current.delete(v),l(e=>Math.max(0,e-1)),p.current===f){let e=[...b];o(t=>{let n={...t};for(let t of e)delete n[t];return n})}}},[]),y=(0,n.useCallback)(()=>{for(let e of h.current)e.abort();h.current.clear(),u.current.clear(),o({}),l(0)},[]),b=(0,n.useCallback)(e=>{let t=u.current.get(e);if(t&&0!==t.size){for(let e of t)e.abort(),h.current.delete(e);u.current.delete(e),o(t=>{let n={...t};for(let[t,r]of Object.entries(n))r.rootMessageId===e&&delete n[t];return n}),l(e=>Math.max(0,e-t.size))}},[]);return{messages:t,streaming:i,loading:a>0,logs:d,sendMessage:x,loadHistory:m,clearHistory:g,clearLogs:(0,n.useCallback)(async e=>{let t=e?.trim()||p.current?.trim();t?(await fetch(`/api/logs?${r(t)}`,{method:"DELETE"}).catch(()=>{}),p.current===t&&c([])):c([])},[]),stop:y,stopThread:b}}(i),[T,j]=(0,n.useState)([]),[O,E]=(0,n.useState)(!1),[A,I]=(0,n.useState)([]),[D,R]=(0,n.useState)(!1),[P,z]=(0,n.useState)(!1),[$,L]=(0,n.useState)(!1);(0,n.useEffect)(()=>{L(hW().threadSidebarVisible)},[]);let[B,V]=(0,n.useState)(null),[F,_]=(0,n.useState)(""),[U,W]=(0,n.useState)([]),[q,K]=(0,n.useState)(0),[J,G]=(0,n.useState)(!1),[X,Y]=(0,n.useState)(null),[Q,Z]=(0,n.useState)(null),[ee,et]=(0,n.useState)(new Set),[en,er]=(0,n.useState)(null),[es,ei]=(0,n.useState)({}),ea=(0,n.useCallback)(e=>{ei(t=>{let n="function"==typeof e?e(t):e;if(i)for(let[e,r]of Object.entries(n))t[e]!==r&&fetch("/api/task-drafts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:i,messageId:e,draft:r})}).catch(()=>{});return n})},[i]),[ed,ec]=(0,n.useState)(new Set),[eu,ep]=(0,n.useState)(new Set),ef=(0,n.useRef)(null),em=(0,n.useRef)(null),eg=(0,n.useRef)(null),ex=(0,n.useRef)(""),ey=(0,n.useCallback)(async(e=!1)=>{try{let e=await fetch("/api/participants");if(!e.ok)return;let t=await e.json();if(!Array.isArray(t))return;j(t)}finally{e&&E(!0)}},[]),eb=(0,n.useCallback)(async e=>{try{await h4({threadSidebarVisible:e})}catch(e){console.error("Unable to persist thread sidebar preference",e)}},[h4]),ev=(0,n.useCallback)(e=>{hq(e),eb(e)},[eb]),ew=F.trim(),ek=ew.length>0,eS=(0,n.useMemo)(()=>Object.fromEntries(e.map(e=>[e.id,e.title?.trim()||"Untitled workspace"])),[e]),eC=(0,n.useMemo)(()=>{if(!B)return[];let e=new Set([y.find(e=>e.id===B),...y.filter(e=>e.rootMessageId===B)].filter(Boolean).map(e=>e.participantId).filter(Boolean));return Object.keys(b).forEach(t=>{b[t].rootMessageId===B&&e.add(t)}),T.filter(t=>e.has(t.id))},[B,y,b,T]),eM=(0,n.useMemo)(()=>{let e=new Set(A);return T.filter(t=>e.has(t.id))},[T,A]),eN=(0,n.useMemo)(()=>{if(!B)return 0;let e=[y.find(e=>e.id===B),...y.filter(e=>e.rootMessageId===B)].filter(Boolean);return 0===e.length?0:Math.max(...e.map(e=>e.timestamp))},[B,y]),eT=(0,n.useMemo)(()=>{if(!B)return"";let e=y.find(e=>e.id===B);if(!e)return"Workspace";let t=e.content.trim();return t.length>60?t.slice(0,60)+"...":t},[B,y]),ej=(0,n.useCallback)(()=>{_(""),W([]),K(0),Y(null),G(!1)},[]);(0,n.useCallback)(()=>{let e=ue(y,T);navigator.clipboard.writeText(e).then(()=>{R(!0),setTimeout(()=>R(!1),2e3)})},[y,T]);let[eO,eE]=(0,n.useState)(null),eA=(0,n.useCallback)(e=>{let t=y.find(t=>t.id===e);if(!t)return;let n=[t,...y.filter(t=>t.rootMessageId===e).sort((e,t)=>e.timestamp-t.timestamp)];eE({title:t.content.slice(0,60).replace(/\n/g," ").trim()||"Untitled",threadId:e,messages:n})},[y]),eI=(0,n.useCallback)(e=>{let t=ue([y.find(t=>t.id===e),...y.filter(t=>t.rootMessageId===e).sort((e,t)=>e.timestamp-t.timestamp)].filter(Boolean),T,es[e]);navigator.clipboard.writeText(t).catch(e=>console.error("Failed to copy thread",e))},[y,T,es]);(0,n.useEffect)(()=>{ey(!0)},[ey]);let eD=(0,n.useMemo)(()=>{if(!O)return[];let e=new Set(T.map(e=>e.id)),t=new Set;for(let n of y)"assistant"===n.role&&n.participantId&&(e.has(n.participantId)||t.add(n.participantId));for(let n of Object.keys(b))e.has(n)||t.add(n);return Array.from(t).sort()},[y,T,O,b]);(0,n.useEffect)(()=>{if(!O)return;let e=eD.join("|");if(!e){ex.current="";return}ex.current!==e&&(ex.current=e,ey(!1))},[O,ey,eD]),(0,n.useEffect)(()=>{if(!O)return;let e=T.map(e=>e.id),t=new Set(e);if(!i)return void I(e);let n=function(e){let t=e.trim();if(!t)return null;let n=hY();return t in n.activeParticipantIdsByThread?[...n.activeParticipantIdsByThread[t]]:null}(i);if(null===n)return void I(e);let r=n.filter(e=>t.has(e));r.length!==n.length&&hQ(i,r),I(r)},[i,T,O]),(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await h5();if(e)return;L(e=>e===t.threadSidebarVisible?e:(hq(t.threadSidebarVisible),t.threadSidebarVisible))}catch(e){console.error("Failed to load user preferences",e)}})(),()=>{e=!0}},[h5,hq]),(0,n.useEffect)(()=>{f||c||0!==e.length||a({id:"global",title:"General"})},[f,c,e.length,a]),(0,n.useEffect)(()=>()=>{eg.current&&window.clearTimeout(eg.current)},[]),(0,n.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()){e.preventDefault(),ef.current?.focus(),ef.current?.select();return}"Escape"===e.key&&ew&&ej()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ej,ew]),(0,n.useEffect)(()=>{if(!ew){W([]),K(0),Y(null),G(!1);return}let e=!1;G(!0);let t=window.setTimeout(()=>{(async()=>{try{let t=new URLSearchParams({q:ew,limit:"20",offset:"0"}),n=await fetch(`/api/search?${t.toString()}`),r=await n.json().catch(()=>null);if(e)return;if(!n.ok){let e=r&&"object"==typeof r&&"error"in r?String(r.error):"Search failed";W([]),K(0),Y(e);return}W(Array.isArray(r.results)?r.results:[]),K("number"==typeof r.total?r.total:0),Y(null)}catch(t){if(e)return;console.error("Search request failed",t),W([]),K(0),Y("Search failed")}finally{e||G(!1)}})()},300);return()=>{e=!0,window.clearTimeout(t)}},[ew]);let eR=(0,n.useRef)(null);(0,n.useEffect)(()=>{null!==eR.current&&eR.current!==i&&(M(),em.current?(V(em.current),em.current=null):V(null)),eR.current=i,i&&(S(i),fetch(`/api/task-drafts?threadId=${encodeURIComponent(i)}`).then(e=>e.json()).then(e=>{e.drafts&&Object.keys(e.drafts).length>0?ei(e.drafts):ei({})}).catch(()=>ei({})))},[i,S,M]),(0,n.useEffect)(()=>{i&&d(i,y)},[i,y,d]);let eP=(0,n.useCallback)((e,t,n=10)=>{i&&0!==eM.length&&k(t,n,i,e,void 0,void 0,eM.map(e=>e.id))},[i,k,eM]),ez=(0,n.useCallback)(async e=>{if(i){if(0===eM.length)return void window.alert("Enable at least one agent in this workspace.");et(t=>new Set(t).add(e));try{let t=await fetch("/api/summarize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:i,rootMessageId:e,activeParticipantIds:eM.map(e=>e.id)})});t.ok?await S(i):console.error("Summarize failed:",await t.text())}catch(e){console.error("Summarize error:",e)}finally{et(t=>{let n=new Set(t);return n.delete(e),n})}}},[i,S,eM]),e$=(0,n.useCallback)(async e=>{if(i){if(0===eM.length)return void window.alert("Enable at least one agent in this workspace.");ec(t=>new Set(t).add(e));try{let t=await fetch("/api/tasks/extract",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:i,rootMessageId:e,activeParticipantIds:eM.map(e=>e.id)})});if(t.ok){let n=await t.json(),r={draftId:crypto.randomUUID(),revision:0,tasks:n.tasks,buildStatus:"idle"};ea(t=>({...t,[e]:r}))}else console.error("Task extraction failed:",await t.text())}catch(e){console.error("Task extraction error:",e)}finally{ec(t=>{let n=new Set(t);return n.delete(e),n})}}},[i,eM]),eL=(0,n.useCallback)((e,t)=>{ea(n=>({...n,[e]:t}))},[]),eB=(0,n.useCallback)(async(e,t,n,r)=>{if(i){ep(e=>new Set(e).add(t.draftId)),ea(s=>({...s,[e]:{...t,buildStatus:"building",projectId:n,projectName:r}}));try{let r=crypto.randomUUID(),s=await H(t.tasks,n,r,t.builtTaskIds),i={...t.builtTaskIds},o=!1;for(let e of s.results)"created"===e.status&&e.remoteTaskId?i[e.clientTaskId]=e.remoteTaskId:o=!0;ea(t=>({...t,[e]:{...t[e],buildId:r,buildStatus:o?"partial_failure":"done",builtTaskIds:i}}))}catch(t){console.error("Build error:",t),ea(t=>({...t,[e]:{...t[e],buildStatus:"partial_failure"}}))}finally{ep(e=>{let n=new Set(e);return n.delete(t.draftId),n})}}},[i]),eV=(0,n.useCallback)(()=>{if(!i)return;let e=(()=>{if(B)return B;let e=new Set(y.map(e=>e.rootMessageId).filter(e=>!!e));for(let t=y.length-1;t>=0;t-=1){let n=y[t];if(!n.rootMessageId&&e.has(n.id))return n.id}return null})();e?e$(e):console.warn("No thread with replies available to extract tasks from")},[i,e$,y,B]);(0,n.useCallback)(e=>{V(e)},[]);let eF=(0,n.useCallback)(e=>{V(e)},[]),e_=(0,n.useCallback)(e=>{let t=e?.trim()??"";t&&_(t),requestAnimationFrame(()=>{ef.current?.focus(),t||ef.current?.select()})},[]),eH=(0,n.useCallback)(()=>{if(!i)return;let e=(()=>{if(B)return B;let e=new Set(y.map(e=>e.rootMessageId).filter(e=>!!e));for(let t=y.length-1;t>=0;t-=1){let n=y[t];if(!n.rootMessageId&&e.has(n.id))return n.id}return null})();e?ez(e):console.warn("No thread with replies available to summarize")},[i,ez,y,B]),eU=(0,n.useCallback)(async(e,t,n,r)=>{let s=e.match(/^\/search(?:\s+([\s\S]+))?$/i);if(s)return void e_(s[1]);if(/^\/summarize(?:\s+[\s\S]+)?$/i.test(e))return void eH();if(/^\/tasks(?:\s+[\s\S]+)?$/i.test(e)||/^\/create(?:\s+[\s\S]+)?$/i.test(e))return void eV();let o=i;o||(o=(await a()).id);let l=eM.map(e=>e.id);0===l.length?window.alert("Enable at least one agent in this workspace."):B?await k(e,t,o,B,n,r,l):await k(e,t,o,null,n,r,l)},[i,a,e_,eH,B,eM,k]),eW=(0,n.useCallback)(e=>{let t=e.rootMessageId||e.messageId;e.threadId!==i?(em.current=t,o(e.threadId)):V(t),Z(null),window.requestAnimationFrame(()=>{Z(e.messageId),eg.current&&window.clearTimeout(eg.current),eg.current=window.setTimeout(()=>{Z(t=>t===e.messageId?null:t)},2e3)}),ej()},[i,ej,o]),eq=(0,n.useCallback)(async e=>{M(),await l(e)},[l,M]),eK=(0,n.useCallback)(async e=>{if(i&&e&&window.confirm("Delete this thread and all of its replies?")){er(e),N(e);try{let t=new URLSearchParams({threadId:i,rootMessageId:e}),n=await fetch(`/api/history?${t.toString()}`,{method:"DELETE"});if(!n.ok)return void console.error("Failed to delete message thread",await n.text());V(t=>t===e?null:t),Z(null);let r=y.filter(t=>t.id!==e&&t.rootMessageId!==e);d(i,r),await S(i)}catch(e){console.error("Failed to delete message thread",e)}finally{er(t=>t===e?null:t)}}},[i,S,y,N,d]),eJ=(0,n.useMemo)(()=>[{name:"/search",description:"Search messages (usage: /search <query>)",aliases:["find"],execute:()=>e_()},{name:"/summarize",description:"Summarize current thread or latest thread with replies",aliases:["sum"],execute:()=>eH()},{name:"/tasks",description:"Extract tasks from current thread discussion",aliases:["create"],execute:()=>eV()}],[e_,eH,eV]),eG=(0,n.useCallback)(e=>(0,t.jsx)(hV,{onSend:(t,n)=>eP(e,t,n),onStop:()=>N(e),loading:Object.values(b).some(t=>t.rootMessageId===e),participants:eM,messages:y,commands:eJ,placeholder:"Reply — @name to mention, /search, /summarize"}),[eP,N,b,eM,eJ,y]),eX=(0,n.useCallback)(()=>{L(e=>{let t=!e;return ev(t),t})},[ev]),eY=async e=>{let t=await fetch("/api/participants",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok){let e=await t.json();j(t=>[...t,e])}},eQ=async e=>{let t=await fetch("/api/participants",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok){let e=await t.json();j(t=>t.map(t=>t.id===e.id?e:t))}},eZ=async e=>{(await fetch(`/api/participants?id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(j(t=>t.filter(t=>t.id!==e)),i&&I(t=>{let n=t.filter(t=>t!==e);return hQ(i,n),n}))},e0=async e=>{j(t=>{let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>n.get(e)).filter(e=>!!e)}),await fetch("/api/participants",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderedIds:e})})},e1=(0,n.useCallback)((e,t)=>{I(n=>{if(!new Set(T.map(e=>e.id)).has(e))return n;let r=new Set(n);t?r.add(e):r.delete(e);let s=T.map(e=>e.id).filter(e=>r.has(e));return i&&hQ(i,s),s})},[i,T]),e2=(0,t.jsx)("div",{className:"border-b border-slate-200/60 bg-white px-6 py-2.5",children:(0,t.jsxs)("div",{className:"max-w-2xl mx-auto relative group/search",children:[(0,t.jsx)(h.Search,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400 group-focus-within/search:text-indigo-500 transition-colors",strokeWidth:2}),(0,t.jsx)("input",{ref:ef,type:"text",value:F,onChange:e=>_(e.target.value),onKeyDown:e=>{"Escape"===e.key&&ej()},placeholder:"Search messages…",className:"h-9 w-full rounded-lg border border-slate-200 bg-slate-50/80 pl-9 pr-16 text-sm font-medium outline-none placeholder:text-slate-400 transition-all focus:bg-white focus:border-indigo-300 focus:ring-2 focus:ring-indigo-500/10 hover:border-slate-300"}),ew?(0,t.jsxs)("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[11px] font-bold text-slate-400",children:J?"…":q}),(0,t.jsx)("button",{type:"button",onClick:ej,className:"text-[10px] font-bold text-slate-400 hover:text-slate-600 transition-colors",children:"✕"})]}):(0,t.jsx)("kbd",{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 px-1.5 py-0.5 text-[10px] font-sans font-bold text-slate-400 bg-slate-100 border border-slate-200 rounded-md",children:"⌘K"})]})});return(0,t.jsxs)("div",{className:"flex h-screen bg-white text-zinc-900",children:[(0,t.jsx)(g,{threads:e,participants:T,activeThreadId:i,isLoading:f,isRestoringActiveThread:m,isCreating:c,deletingThreadId:u,renamingThreadId:p,onSelectThread:o,onCreateThread:a,onRenameThread:x,onDeleteThread:eq,onAddParticipant:eY,onUpdateParticipant:eQ,onRemoveParticipant:eZ,activeParticipantIds:A,onToggleParticipantActive:e1,onReorderParticipants:e0,visible:$,onToggle:eX}),(0,t.jsxs)("div",{className:"flex flex-col flex-1 min-w-0 relative",children:[(0,t.jsxs)("div",{className:"absolute top-4 right-4 z-30 flex items-center gap-2",children:[(0,t.jsx)("a",{href:"/projects",className:"inline-flex items-center gap-1.5 h-8 px-3 text-xs font-medium text-slate-600 bg-white border border-slate-200 rounded-md hover:bg-slate-50 hover:text-slate-800 transition-colors",children:"View Boards"}),(0,t.jsx)(h7,{}),(0,t.jsx)("button",{type:"button",onClick:()=>z(!P),"aria-label":P?"Hide logs":`Show logs${w.length>0?` (${w.length})`:""}`,"aria-pressed":P,title:P?"Hide logs":`Show logs${w.length>0?` (${w.length})`:""}`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md border transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-400 ${P?"border-slate-300 bg-slate-50 text-slate-800":"border-slate-200 bg-white text-slate-500 hover:bg-slate-50 hover:text-slate-800"}`,children:(0,t.jsx)(h6,{className:"h-4 w-4",strokeWidth:1.75})})]}),B&&(0,t.jsx)("header",{className:"border-b border-slate-200 px-6 py-4 flex items-center h-16 pr-14",children:(0,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,t.jsx)("button",{onClick:()=>V(null),className:"p-1.5 text-slate-400 hover:text-indigo-600 hover:bg-zinc-100 rounded-lg transition-all active:scale-95 flex-shrink-0",title:"Back to main feed",children:(0,t.jsx)(h8.ChevronLeft,{size:22,strokeWidth:2.5})}),(0,t.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("h2",{className:"text-[15px] font-bold text-slate-900 tracking-tight leading-tight truncate max-w-[240px]",children:eT}),(0,t.jsx)("div",{className:"flex -space-x-1.5 ml-1 flex-shrink-0",children:eC.map(e=>(0,t.jsx)("img",{src:`https://api.dicebear.com/9.x/bottts-neutral/svg?seed=${e.id}&backgroundColor=${e.color?e.color.replace("#",""):"e2e8f0"}`,alt:e.name,className:"w-5 h-5 rounded-full border-2 border-white shadow-sm ring-1 ring-slate-200 object-cover",title:e.name},e.id))})]}),(0,t.jsxs)("div",{className:"text-[11px] text-slate-500 font-medium flex items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"opacity-80",children:[eC.length," agents"]}),(0,t.jsx)("span",{className:"w-0.5 h-0.5 rounded-full bg-slate-300"}),(0,t.jsxs)("span",{className:"opacity-80",children:["Updated ",function(e){if(!e)return"recently";let t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e)}(eN)]})]})]})]})}),m?(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center px-4 text-sm text-zinc-500",children:"Loading your last workspace…"}):(0,t.jsx)("div",{className:"flex flex-1 min-h-0 bg-slate-50 relative",children:(0,t.jsxs)("div",{className:"flex flex-col flex-1 min-w-0",children:[!B&&e2,ek?(0,t.jsx)(eh,{query:ew,results:U,total:q,participants:T,threadTitleById:eS,isLoading:J,error:X,onSelectResult:eW}):B?(0,t.jsx)(el,{messages:y,streaming:b,participants:T,rootMessageId:B,onClose:()=>V(null),onCopyThread:eI,onAddToChat:eA,onDeleteThreadRoot:eK,highlightedMessageId:Q||void 0,renderReplyComposer:eG}):(0,t.jsx)(eo,{messages:y,streaming:b,participants:T,onOpenThread:eF,onCopyThread:eI,onAddToChat:eA,onDeleteThreadRoot:eK,onSummarize:ez,onCreateTasks:e$,onUpdateTaskDraft:eL,onBuildTasks:eB,summarizingThreads:ee,extractingTasks:ed,buildingDrafts:eu,taskDrafts:es,deletingThreadRootId:en,highlightedMessageId:Q}),!ek&&!B&&(0,t.jsx)(hV,{onSend:eU,onStop:M,loading:v,participants:eM,messages:y,commands:eJ,pendingThreadInsert:eO,onClearPendingThread:()=>eE(null)})]})})]}),(0,t.jsx)(hF,{logs:w,participants:T,onClear:()=>void C(i),open:P,onToggle:()=>z(!1)})]})}e.s(["ChatContainer",()=>ut],26341)}]);
|