decocms 4.363.0 → 4.363.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-Df7Uu4Sr.js → AlertCircle-CgERhdh6.js} +1 -1
- package/dist/client/assets/{AreaChart-BRLjJaJt.js → AreaChart-kU4sTinA.js} +2 -2
- package/dist/client/assets/{ArrowLeft-Ce4LVTaQ.js → ArrowLeft-BVx6AQzq.js} +1 -1
- package/dist/client/assets/{ArrowRight-CuO69upc.js → ArrowRight-DZQert3q.js} +1 -1
- package/dist/client/assets/{ArrowUp-DmWBbOjK.js → ArrowUp-lpfNBlP2.js} +1 -1
- package/dist/client/assets/{Check-C1wq38_E.js → Check-DClZtAIP.js} +1 -1
- package/dist/client/assets/{CheckCircle-DWvslkKl.js → CheckCircle-BGqFZ8sM.js} +1 -1
- package/dist/client/assets/{ChevronRight-B76sbAXC.js → ChevronRight-BNfU55ld.js} +1 -1
- package/dist/client/assets/{ChevronSelectorVertical-C4wJ3zDR.js → ChevronSelectorVertical-ilm76_0p.js} +1 -1
- package/dist/client/assets/{ChevronUp-B0KEDz5f.js → ChevronUp-CbF1Gmeo.js} +1 -1
- package/dist/client/assets/{Copy01-rsN5AnPv.js → Copy01-DiITYBuR.js} +1 -1
- package/dist/client/assets/{CreditCard01-Cqs_Biv7.js → CreditCard01-Zpy-4Wu9.js} +1 -1
- package/dist/client/assets/Database01-zcGUPFsG.js +1 -0
- package/dist/client/assets/{DotsVertical-CBmzJDPB.js → DotsVertical-LmkOTjL4.js} +1 -1
- package/dist/client/assets/{Download01-zZEPtQ0U.js → Download01-C4blLpML.js} +1 -1
- package/dist/client/assets/ErrorBarContext-KbkdtIBU.js +1 -0
- package/dist/client/assets/{Eye-DFgd5114.js → Eye-Cd7v-liN.js} +1 -1
- package/dist/client/assets/File02-CceuR6rF.js +1 -0
- package/dist/client/assets/{GitBranch01-B7iymaqC.js → GitBranch01-Dil6c2wv.js} +1 -1
- package/dist/client/assets/{Globe01-Df6dZmsR.js → Globe01-BVji6jXS.js} +1 -1
- package/dist/client/assets/{HardDrive-CiahcooN.js → HardDrive-B4UY5qYp.js} +1 -1
- package/dist/client/assets/{Image01-CMpSR3RQ.js → Image01-CpXdMb8x.js} +1 -1
- package/dist/client/assets/{Key01-t3bX5YI3.js → Key01-BsAAVoJx.js} +1 -1
- package/dist/client/assets/{Link01-pX5C3rEv.js → Link01-OqB-2yPE.js} +1 -1
- package/dist/client/assets/{LinkExternal01-CzRiacvQ.js → LinkExternal01-DobnLseV.js} +1 -1
- package/dist/client/assets/{Monitor01-jzbehxNG.js → Monitor01-BTqHf-K4.js} +1 -1
- package/dist/client/assets/{Package-CiAH049d.js → Package-CCkk0w5h.js} +1 -1
- package/dist/client/assets/{Palette-CmMvG40G.js → Palette-BBWt8owf.js} +1 -1
- package/dist/client/assets/{Play-k9_JCuZW.js → Play-CPeIBqH_.js} +1 -1
- package/dist/client/assets/{Plus-Bac7Bl-V.js → Plus-DaErdsG1.js} +1 -1
- package/dist/client/assets/Printer-BG6NfeSZ.js +1 -0
- package/dist/client/assets/{SearchLg-iYej-M-S.js → SearchLg-DxQfk550.js} +1 -1
- package/dist/client/assets/{SearchMd-hxPQERkg.js → SearchMd-BNXjQ2BV.js} +1 -1
- package/dist/client/assets/Sector-D2wxgDkd.js +28 -0
- package/dist/client/assets/{Settings02-t15FjJbr.js → Settings02-DL8f5fN1.js} +1 -1
- package/dist/client/assets/{Share07-CJrTonmW.js → Share07-D1Sv14jA.js} +1 -1
- package/dist/client/assets/{Shield01-DS-tpugO.js → Shield01-BsobIEfQ.js} +1 -1
- package/dist/client/assets/{Stars01-ByE0-f1z.js → Stars01-f37Q7vDf.js} +1 -1
- package/dist/client/assets/{Sun-vdviKSpi.js → Sun-DjKz3VjB.js} +1 -1
- package/dist/client/assets/{XClose-DvenHyNp.js → SwitchHorizontal01-BIyO34Jw.js} +1 -1
- package/dist/client/assets/{Tool01-CmpQe3MS.js → Tool01-D6HOM_aJ.js} +1 -1
- package/dist/client/assets/{Tool02-BAA6OFl0.js → Tool02-BrfQeZRx.js} +1 -1
- package/dist/client/assets/{Trash01-C6vCLvEw.js → Trash01-DQjprOwc.js} +1 -1
- package/dist/client/assets/{TrendUp01-fHRYAiew.js → TrendUp01-DIz6JZwT.js} +1 -1
- package/dist/client/assets/{Upload01-lE597uPz.js → Upload01-BDeLrRhf.js} +1 -1
- package/dist/client/assets/{User01-BPodfm7s.js → User01-B8a5ssx2.js} +1 -1
- package/dist/client/assets/{UserSquare-CXhk4rLY.js → UserSquare-yIpHwPSn.js} +1 -1
- package/dist/client/assets/{Users01-Dgbd4CM_.js → Users01-BCRhQsCX.js} +1 -1
- package/dist/client/assets/{Users03-B4Km0_9u.js → Users03-DWh3D2_T.js} +1 -1
- package/dist/client/assets/{XCircle-BK1898xU.js → XCircle-DudPVYQR.js} +1 -1
- package/dist/client/assets/XClose-DpDcHm9Y.js +1 -0
- package/dist/client/assets/{Zap-nPZGKdXf.js → Zap-C5eiFR0N.js} +1 -1
- package/dist/client/assets/ZoomOut-DdupjPFF.js +1 -0
- package/dist/client/assets/access-gate-Dnh0JyKy.js +1 -0
- package/dist/client/assets/add-connection-dialog-BSihy3_s.js +1 -0
- package/dist/client/assets/agent-analytics-C1OAYjbt.js +2 -0
- package/dist/client/assets/agent-app-62cavSHy.js +1 -0
- package/dist/client/assets/agent-assets-vYQq8qui.js +1 -0
- package/dist/client/assets/agent-automation-BPNX454_.js +20 -0
- package/dist/client/assets/agent-automations-BLOXID0N.js +1 -0
- package/dist/client/assets/agent-connect-sources-BzEccd4r.js +1 -0
- package/dist/client/assets/agent-deck-DVW32bsA.js +1 -0
- package/dist/client/assets/agent-e2e-DM8adI3E.js +1 -0
- package/dist/client/assets/agent-file-C7nywZCe.js +1 -0
- package/dist/client/assets/agent-git-DarQSTRH.js +3 -0
- package/dist/client/assets/agent-hosting-Dnr2S-TT.js +1 -0
- package/dist/client/assets/agent-icon-vDfwuZu4.js +1 -0
- package/dist/client/assets/agent-library-file-D4p-8dXS.js +1 -0
- package/dist/client/assets/agent-monitor-DpaaBIhL.js +1 -0
- package/dist/client/assets/agent-overview-D9IrP622.js +1 -0
- package/dist/client/assets/agent-settings-CxGAsqqN.js +1 -0
- package/dist/client/assets/agent-site-editor-DTFbZmEY.js +1 -0
- package/dist/client/assets/agent-site-editor-code-Dcgjtfwk.js +2 -0
- package/dist/client/assets/agent-site-editor-content-BE26aik7.js +2 -0
- package/dist/client/assets/agent-site-editor-preview-ki_D8wtP.js +504 -0
- package/dist/client/assets/agent-view-DYYYDEW_.js +1 -0
- package/dist/client/assets/agent-view-guard-DomQyuot.js +1 -0
- package/dist/client/assets/agents-list-B0vnsITA.js +1 -0
- package/dist/client/assets/ai-providers-CxaMjUP7.js +1 -0
- package/dist/client/assets/{alert-D8igu3TO.js → alert-DcFgIKLk.js} +1 -1
- package/dist/client/assets/{alert-dialog-CFCsKBpN.js → alert-dialog-CiKfgw9r.js} +2 -2
- package/dist/client/assets/{api-keys-BIjM5sVA.js → api-keys-CEPWE1iS.js} +1 -1
- package/dist/client/assets/api-keys-DoGNEUpY.js +1 -0
- package/dist/client/assets/app-editor-CRjlYU-M.js +1 -0
- package/dist/client/assets/asset-utils-DJXdpjr9.js +1 -0
- package/dist/client/assets/{auth-catchall-E5QBtigN.js → auth-catchall-DV5KEwZ2.js} +1 -1
- package/dist/client/assets/{auth-entry-C91RF11H.js → auth-entry-Fe8qT_kq.js} +1 -1
- package/dist/client/assets/{auth-DeD0YpKg.js → auth-ksbj4Esa.js} +1 -1
- package/dist/client/assets/{auth-split-layout-BFF9n_Qv.js → auth-split-layout-CFJK_BXW.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-6UYdTwrd.js → authenticate-and-persist-oauth-DMvGjBUE.js} +1 -1
- package/dist/client/assets/{automation-list-row-Ba1cMA4W.js → automation-list-row-CkrObNhq.js} +1 -1
- package/dist/client/assets/automation-runs-C-5kRp10.js +1 -0
- package/dist/client/assets/automations-CKhgbURI.js +1 -0
- package/dist/client/assets/{autosend-DI1ZpOT0.js → autosend-BzUVLyEq.js} +1 -1
- package/dist/client/assets/{avatar-CfO1mReu.js → avatar-CW4PxBuN.js} +1 -1
- package/dist/client/assets/{badge-GP_pc1i_.js → badge-C5Ilvf_J.js} +1 -1
- package/dist/client/assets/{block-document-B_vPvGLi.js → block-document-Zfk-C1Kp.js} +3 -3
- package/dist/client/assets/breadcrumb-BajFgW5V.js +1 -0
- package/dist/client/assets/{buckets-BeX-azQt.js → buckets-CyNocIPE.js} +1 -1
- package/dist/client/assets/build-improve-prompt-doc-BrRLOIlw.js +2 -0
- package/dist/client/assets/bulk-category-panel-e217-dmm.js +1 -0
- package/dist/client/assets/calendar-DGiOuDgZ.js +1 -0
- package/dist/client/assets/{capability-load-error-BoR9RbMs.js → capability-load-error-DFv8gs5U.js} +1 -1
- package/dist/client/assets/{cards-m7YgOjsz.js → cards-XHNjVWeh.js} +3 -3
- package/dist/client/assets/category-editor-zLRtagcy.js +1 -0
- package/dist/client/assets/{chart-BanyRqbL.js → chart-C7CmtzOp.js} +2 -2
- package/dist/client/assets/chat-context-HB_KOUNM.js +35 -0
- package/dist/client/assets/{checkbox-ZsR1Bced.js → checkbox-Dg_GkeBT.js} +1 -1
- package/dist/client/assets/choose-editor-DO1mGCL1.js +1 -0
- package/dist/client/assets/{cli-auth-success-sB1yOlRg.js → cli-auth-success-e-RADpiN.js} +1 -1
- package/dist/client/assets/{client-icons-DHLFDmNu.js → client-icons-tt6oaVA2.js} +1 -1
- package/dist/client/assets/collapsible-CycyYnXe.js +1 -0
- package/dist/client/assets/collection-detail-DhtfN_Wl.js +1 -0
- package/dist/client/assets/collection-display-button-BRbx9UhH.js +1 -0
- package/dist/client/assets/{collection-search-7NUVJQfN.js → collection-search-j4HjYlys.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-D0kCJcbB.js → collection-table-wrapper-0LZ9BKlr.js} +1 -1
- package/dist/client/assets/{collection-tabs-MvaIz7gt.js → collection-tabs-Bc9QOlJ8.js} +1 -1
- package/dist/client/assets/{command-CF7nzIN2.js → command-BpjWfGyr.js} +1 -1
- package/dist/client/assets/command-palette-store-D19nXDNm.js +1 -0
- package/dist/client/assets/commerce-onboarding-CdG4FfWS.js +1 -0
- package/dist/client/assets/companion-mcps-section-CVcicsr9.js +1 -0
- package/dist/client/assets/companions-core-CZwGf1b1.js +1 -0
- package/dist/client/assets/{connect-G-ytX-wq.js → connect-COU6F3Do.js} +2 -2
- package/dist/client/assets/connect-layout-Bl-ol5HH.js +1 -0
- package/dist/client/assets/{connection-D885aDuM.js → connection-By77bjvj.js} +1 -1
- package/dist/client/assets/{connection-card-Nc1w-XCq.js → connection-card-Br8jDKgZ.js} +1 -1
- package/dist/client/assets/connection-detail-vVdPGlxv.js +1 -0
- package/dist/client/assets/{connection-form-helpers-B4IwDJJQ.js → connection-form-helpers-CFXh6BoJ.js} +1 -1
- package/dist/client/assets/connections-BBNFmXEe.js +1 -0
- package/dist/client/assets/content-blocks-o63cs2vh.js +1 -0
- package/dist/client/assets/{create-organization-dialog-gO5G25gp.js → create-organization-dialog-CRl8hry2.js} +1 -1
- package/dist/client/assets/decode-html-entities-Cf7wUEql.js +1 -0
- package/dist/client/assets/{decopilot-sse-pool-Bm_3HC4t.js → decopilot-sse-pool-D2Qtyl-A.js} +1 -1
- package/dist/client/assets/{dialog-CyDGwxcX.js → dialog-DJBpjJnY.js} +1 -1
- package/dist/client/assets/discover-y7BsppSE.js +1 -0
- package/dist/client/assets/{domain-settings-Cx6UibuZ.js → domain-settings-B_cuGCF0.js} +1 -1
- package/dist/client/assets/download-app-dialog-DYhv8XsJ.js +1 -0
- package/dist/client/assets/{drawer-CqSEztKC.js → drawer-B5NRhNfW.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CgwRqOnX.js → dropdown-menu-DzwCPltk.js} +1 -1
- package/dist/client/assets/{editor-D7S6MtwI.js → editor-BHnwprUT.js} +1 -1
- package/dist/client/assets/{empty-state-SN5mEPhX.js → empty-state-CJ95hR0w.js} +1 -1
- package/dist/client/assets/{empty-state-DfBha5W6.js → empty-state-CXolWOTn.js} +1 -1
- package/dist/client/assets/extract-connection-data-B1nPGa4h.js +1 -0
- package/dist/client/assets/{file-explorer-paPAvOUA.js → file-explorer-Dj1zqDxa.js} +2 -2
- package/dist/client/assets/file-preview-kRDXQYfi.js +1 -0
- package/dist/client/assets/file-share-button-P5GnoZYM.js +3 -0
- package/dist/client/assets/{file-type-icon--TvA6C0i.js → file-type-icon-Cg81au_Z.js} +1 -1
- package/dist/client/assets/folder-icon-Bey_C_xd.js +2 -0
- package/dist/client/assets/{form-BnUN8JhF.js → form-EGCuUtdG.js} +1 -1
- package/dist/client/assets/{general-DhiseHhA.js → general-BJ_Ksgnn.js} +1 -1
- package/dist/client/assets/github-D4UJ99TO.js +1 -0
- package/dist/client/assets/{github-icon-7BmoW2Y2.js → github-icon-CiNkodR8.js} +1 -1
- package/dist/client/assets/{github-repo-CTPv5ZM2.js → github-repo-C0igpkr9.js} +1 -1
- package/dist/client/assets/github-repo-scope-C8GSbvaz.js +1 -0
- package/dist/client/assets/home-Cmddezu3.js +1 -0
- package/dist/client/assets/{hooks-Bv30myGB.js → hooks-BSkeWBV7.js} +2 -2
- package/dist/client/assets/hooks-Bb9SArul.js +2 -0
- package/dist/client/assets/{index-y6Z5iMfg.js → index-6GXqHE0w.js} +42 -42
- package/dist/client/assets/{index-C2fs5Fhc.js → index-9FQARZdh.js} +1 -1
- package/dist/client/assets/index-B7ENeoW4.js +4 -0
- package/dist/client/assets/index-B9bOVdMd.js +90 -0
- package/dist/client/assets/index-BVRQ9yUZ.js +1 -0
- package/dist/client/assets/index-BaItIL-_.js +1 -0
- package/dist/client/assets/index-CUa7fAjf.js +24 -0
- package/dist/client/assets/index-CY40-aHW.js +1 -0
- package/dist/client/assets/{index-CnV8Y6tV.js → index-Cu77hgR2.js} +1 -1
- package/dist/client/assets/index-DCQ3taiG.js +1 -0
- package/dist/client/assets/{index-DD_a39Sy.js → index-Dg14Zpi9.js} +2 -2
- package/dist/client/assets/{index-B_j4TgZF.js → index-cEqwHhEg.js} +1 -1
- package/dist/client/assets/{index-Cf5RfBo5.js → index-hC6VOnUm.js} +2 -2
- package/dist/client/assets/index-qEipD_7S.js +1 -0
- package/dist/client/assets/index-redirect-BRL1uQPT.js +1 -0
- package/dist/client/assets/{infiniteQueryObserver-CvFtTJPb.js → infiniteQueryObserver-C7FrFXuf.js} +1 -1
- package/dist/client/assets/infra-billing-B0e93_qz.js +1 -0
- package/dist/client/assets/input-BRqLi1TH.js +8 -0
- package/dist/client/assets/input-D8xrvlz-.js +1 -0
- package/dist/client/assets/{input-DRjCNSPN.js → input-TvernbmY.js} +1 -1
- package/dist/client/assets/{integration-icon-CFGOsRgH.js → integration-icon-B6H5J7sl.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-qtYgFNfF.js → invite-member-dialog-CsolElt3.js} +1 -1
- package/dist/client/assets/{label-DGsSvY2I.js → label-aWEsDmHM.js} +1 -1
- package/dist/client/assets/{layout-C7iOarOb.js → layout-CAwe_kK2.js} +1 -1
- package/dist/client/assets/legacy-agents-deep-DJ_t0QLc.js +1 -0
- package/dist/client/assets/legacy-main-redirect-CySqEohs.js +1 -0
- package/dist/client/assets/library-DRmbr8Ht.js +161 -0
- package/dist/client/assets/{login-B4RHcX-Z.js → login-DQDbHhI7.js} +1 -1
- package/dist/client/assets/{markdown-Y6owwpHy.js → markdown-CBvmi8AF.js} +30 -30
- package/dist/client/assets/match-site-slug-config-D3fUJ6vX.js +1 -0
- package/dist/client/assets/{mcp-app-renderer-Cy31bAY0.js → mcp-app-renderer-BQ7hPzlx.js} +2 -2
- package/dist/client/assets/{mcp-oauth-Bm9ijvfC.js → mcp-oauth-DhRKpyTH.js} +1 -1
- package/dist/client/assets/members-NHaXKGgP.js +1 -0
- package/dist/client/assets/mini-report-page-BcG9QHwQ.js +1 -0
- package/dist/client/assets/monaco-editor-C5zvkMO4.js +9 -0
- package/dist/client/assets/monitoring-stats-row-CWqusnLf.js +1 -0
- package/dist/client/assets/{multi-select-kzt94BG4.js → multi-select-CvACpZbb.js} +1 -1
- package/dist/client/assets/mustache-DQXz9E52.js +4 -0
- package/dist/client/assets/{oauth-callback-CsYpPVhX.js → oauth-callback-BHJTnNxG.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-CkroR0wl.js → oauth-callback-ai-provider-wF0_7wc5.js} +1 -1
- package/dist/client/assets/omit-sandbox-map-jj4lCB2U.js +1 -0
- package/dist/client/assets/{onboarding-DN_VeGxV.js → onboarding-20FUHLvO.js} +1 -1
- package/dist/client/assets/optimistic-project-sidebar-views-DKtRXqQ0.js +1 -0
- package/dist/client/assets/org-layout-DRrVivAL.js +1 -0
- package/dist/client/assets/{organization-choice-Bugd-m5W.js → organization-choice-BmSYuBSE.js} +1 -1
- package/dist/client/assets/{orgs-Bv7LuXwC.js → orgs-1ZlqeM-y.js} +1 -1
- package/dist/client/assets/page-seo-form-Cpi2Oike.js +1 -0
- package/dist/client/assets/pair-CD8Vxcvs.js +47 -0
- package/dist/client/assets/{popover-DrJcYe9C.js → popover-Ci-k968-.js} +1 -1
- package/dist/client/assets/post-calendar-CgTLYrrU.js +1 -0
- package/dist/client/assets/post-editor-DyayPm7u.js +1 -0
- package/dist/client/assets/preview-content-DhEgigNG.js +1 -0
- package/dist/client/assets/preview-dialog-CKWnRekk.js +1 -0
- package/dist/client/assets/primitives-1lR28duD.js +1 -0
- package/dist/client/assets/{profile-Bs-irLLH.js → profile-DixSbE4L.js} +1 -1
- package/dist/client/assets/project-app-view-DBHiU3Rg.js +1 -0
- package/dist/client/assets/project-feed-boKgu_TR.js +1 -0
- package/dist/client/assets/project-icon-DIXBuD-A.js +1 -0
- package/dist/client/assets/project-reports-ChLta7_v.js +1 -0
- package/dist/client/assets/project-tasks-nUWazd1g.js +1 -0
- package/dist/client/assets/{prompts-wjQ-EFKj.js → prompts-BROxvafI.js} +1 -1
- package/dist/client/assets/provision-repo-scoped-github-connection-B6zdkC6p.js +1 -0
- package/dist/client/assets/record-editor-FqHaN2k4.js +1 -0
- package/dist/client/assets/redirect-editor-CWYZom_C.js +1 -0
- package/dist/client/assets/registry-C3_EEMj-.js +2 -0
- package/dist/client/assets/{registry-layout-DHYm94rU.js → registry-layout-BUEF9YqP.js} +4 -4
- package/dist/client/assets/{reports-D4elpaqK.js → reports-B1C9NU2m.js} +1 -1
- package/dist/client/assets/reports-BY7Ca1Ey.js +1 -0
- package/dist/client/assets/reports-tab-uLMivl2p.js +2 -0
- package/dist/client/assets/{repositories-3ia_V4sE.js → repositories-BgD13VwL.js} +1 -1
- package/dist/client/assets/repository-import-picker-DVnadPZ8.js +1 -0
- package/dist/client/assets/{repository-picker-s01uE4_E.js → repository-picker-BGpoa_g_.js} +1 -1
- package/dist/client/assets/require-capability-DSFKKTc-.js +1 -0
- package/dist/client/assets/{required-auth-layout-mSUodrzA.js → required-auth-layout-DMNBbcf3.js} +1 -1
- package/dist/client/assets/{reset-password-B_-cD_PK.js → reset-password-GCDcBOjo.js} +1 -1
- package/dist/client/assets/review-settings-VwYzzjCc.js +1 -0
- package/dist/client/assets/rich-text-link-control-C6A8Q9Jd.js +5 -0
- package/dist/client/assets/roles-PgEO9KN-.js +1 -0
- package/dist/client/assets/runnable-block-editor-Db2XbJYi.js +16 -0
- package/dist/client/assets/sandbox-lifecycle-context-DxbfUbxP.js +2 -0
- package/dist/client/assets/sandbox-url-D3mC8qhT.js +1 -0
- package/dist/client/assets/{schema-BDy_4D7A.js → schema-Cnskrzk1.js} +1 -1
- package/dist/client/assets/{scroll-area-C18Y2v3L.js → scroll-area-CaE3a4_T.js} +1 -1
- package/dist/client/assets/{search-input-L0lrukmF.js → search-input-lFP9sD3O.js} +1 -1
- package/dist/client/assets/{secrets-CdpkfmHa.js → secrets-BU_daRxy.js} +1 -1
- package/dist/client/assets/sections-editor-D-W8vM7g.js +2 -0
- package/dist/client/assets/{select-BGnwGqnU.js → select-Ce9NznPv.js} +1 -1
- package/dist/client/assets/select-model-CjTijsS7.js +1 -0
- package/dist/client/assets/self-tool-result-8OxPN9Nm.js +1 -0
- package/dist/client/assets/seo-editor-O94He1NF.js +1 -0
- package/dist/client/assets/serial-task-queue-CGOeQgpr.js +1 -0
- package/dist/client/assets/settings-layout-CWQI71Tg.js +1 -0
- package/dist/client/assets/settings-sidebar-BcAe-WS4.js +1 -0
- package/dist/client/assets/settings-tab-Cg5CqTki.js +5 -0
- package/dist/client/assets/shell-controls-gkZZS07l.js +1 -0
- package/dist/client/assets/shell-layout-C3IRibnI.js +1 -0
- package/dist/client/assets/site-url-en5df9c-.js +1 -0
- package/dist/client/assets/skill-preview-MIddvDZe.js +1 -0
- package/dist/client/assets/skills-hRnVKZ5K.js +1 -0
- package/dist/client/assets/{sso-CVpMpJ2m.js → sso-BePH_NId.js} +1 -1
- package/dist/client/assets/store-CqeIEwHN.js +1 -0
- package/dist/client/assets/store-registry-BCokMLik.js +2 -0
- package/dist/client/assets/switch-D5GcuD9Z.js +1 -0
- package/dist/client/assets/synced-repos-Cnp4m7yg.js +1 -0
- package/dist/client/assets/{table-DSIbUmyY.js → table-O0SpY8ZO.js} +1 -1
- package/dist/client/assets/{tabs-BVFMEVzk.js → tabs-DQoXHeZr.js} +1 -1
- package/dist/client/assets/{task-board-By8eCqZc.js → task-board-DyZE7mH1.js} +1 -1
- package/dist/client/assets/task-route-CayeX6cv.js +1 -0
- package/dist/client/assets/task-status-CyTozLxL.js +1 -0
- package/dist/client/assets/tasks-DGTMeQBa.js +1 -0
- package/dist/client/assets/{tasks-kFCSziTb.js → tasks-Da-h-zLm.js} +1 -1
- package/dist/client/assets/{textarea-CuF3aDTE.js → textarea-BpFOmm9_.js} +1 -1
- package/dist/client/assets/{thread-intent-q_RVjRN0.js → thread-intent-AJKohiRy.js} +1 -1
- package/dist/client/assets/thread-route-CEvVLI2K.js +1 -0
- package/dist/client/assets/thread-sheet-body-Bs4b4fMK.js +1 -0
- package/dist/client/assets/toggle-group-Cs1yIHkK.js +1 -0
- package/dist/client/assets/tool-namespace-ySa3S1AM.js +1 -0
- package/dist/client/assets/{toolbar-B5cewwJb.js → toolbar-DOOz2W24.js} +1 -1
- package/dist/client/assets/{toolbar-icon-button-BtBUZ8nA.js → toolbar-icon-button-Dp-AbzNZ.js} +1 -1
- package/dist/client/assets/{track-BYunSel2.js → track-Dns1NpdC.js} +1 -1
- package/dist/client/assets/{types-BB_Up-3A.js → types-C1gRrnQe.js} +6 -6
- package/dist/client/assets/usage-stats-D5mXC24B.js +141 -0
- package/dist/client/assets/{use-ai-providers-BMexfNaB.js → use-ai-providers-Bg_y9f3x.js} +1 -1
- package/dist/client/assets/{use-automations-BgzAjzua.js → use-automations-BI_yIok-.js} +1 -1
- package/dist/client/assets/{use-autosave-D70NA0HD.js → use-autosave-BB0U2eiK.js} +1 -1
- package/dist/client/assets/use-commerce-diagnostic-DqKipeip.js +1 -0
- package/dist/client/assets/use-connect-companion-Mci4Y6hu.js +1 -0
- package/dist/client/assets/{use-connection-ClORxmw4.js → use-connection-DCUpGmsb.js} +1 -1
- package/dist/client/assets/{use-copy-DUxpBqXm.js → use-copy-GVBAvo9n.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-DBeldBRq.js → use-create-virtual-mcp-CizXpVyQ.js} +1 -1
- package/dist/client/assets/{use-date-fns-locale-40K6SzJD.js → use-date-fns-locale-CcPpBz8y.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-kf66WQZj.js → use-debounced-autosave-wCEzYUZh.js} +1 -1
- package/dist/client/assets/{use-debounced-value-v41IOreQ.js → use-debounced-value-D0SYNQsR.js} +1 -1
- package/dist/client/assets/use-deco-credits-DjxZxHMq.js +1 -0
- package/dist/client/assets/{use-decopilot-events-C0NWoSQc.js → use-decopilot-events-zpeu2MCG.js} +1 -1
- package/dist/client/assets/{use-delete-connection-qmqqgsKa.js → use-delete-connection-B-DNpbCU.js} +1 -1
- package/dist/client/assets/{use-deployment-admin-C7c9x0vv.js → use-deployment-admin-Dpkh4HgH.js} +1 -1
- package/dist/client/assets/{use-file-configs-Dm3fOdMk.js → use-file-configs-B1FdrMZJ.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-Bw5rNIGx.js → use-infinite-scroll-BXOEU8Y7.js} +1 -1
- package/dist/client/assets/{use-join-requests-DbtrL0Pl.js → use-join-requests-1Ow065Yq.js} +1 -1
- package/dist/client/assets/use-main-panel-tabs-CeyJWpQP.js +1 -0
- package/dist/client/assets/{use-mcp-auth-status-kHe3lJRg.js → use-mcp-auth-status-CSQiZCDG.js} +1 -1
- package/dist/client/assets/use-mcp-client-Bq-mjhw3.js +10 -0
- package/dist/client/assets/{use-mcp-prompts-CtjkJFfg.js → use-mcp-prompts-CWmeNLXn.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-DRBItGTD.js → use-mcp-tools-DGdyHn8U.js} +1 -1
- package/dist/client/assets/{use-members-C23rfxcZ.js → use-members-Dnee1tF2.js} +1 -1
- package/dist/client/assets/use-navigate-to-agent-Drdqs1cr.js +1 -0
- package/dist/client/assets/use-open-billing-url-Cju1isPI.js +1 -0
- package/dist/client/assets/{use-org-auth-client-DvlpnDFO.js → use-org-auth-client-CVFBkaiI.js} +1 -1
- package/dist/client/assets/use-org-fs-DG1oJieK.js +1 -0
- package/dist/client/assets/{use-org-notice-DlsdC1WA.js → use-org-notice-PUfO84YR.js} +1 -1
- package/dist/client/assets/{use-org-sso-xd-5IiLc.js → use-org-sso-uleG21Aq.js} +1 -1
- package/dist/client/assets/{use-organization-roles-B3neE_6D.js → use-organization-roles-yO3kgQbK.js} +1 -1
- package/dist/client/assets/use-organization-settings-DrJN-E78.js +1 -0
- package/dist/client/assets/use-panel-navigate-CCqZdv2O.js +1 -0
- package/dist/client/assets/use-project-native-view-presence-01L5j4lu.js +1 -0
- package/dist/client/assets/use-project-scope-DZ9tacAx.js +1 -0
- package/dist/client/assets/use-registry-connections-cro5WL6A.js +1 -0
- package/dist/client/assets/{use-secrets-PkTonlJ_.js → use-secrets-w6G8jtp4.js} +1 -1
- package/dist/client/assets/use-section-preview-base-lro_p1nx.js +1 -0
- package/dist/client/assets/use-session-runtime-TS34dEJv.js +1 -0
- package/dist/client/assets/{use-status-sounds-C-6LEj0t.js → use-status-sounds-DQ2pMmh0.js} +1 -1
- package/dist/client/assets/{use-tags-BuxETA7b.js → use-tags-B6zE47mm.js} +1 -1
- package/dist/client/assets/use-task-metadata-C4MfiHBQ.js +1 -0
- package/dist/client/assets/use-thread-outputs-CpCqTMOi.js +1 -0
- package/dist/client/assets/{use-view-mode-BGsTNFK8.js → use-view-mode-B9wUn2ad.js} +1 -1
- package/dist/client/assets/use-virtual-mcp-CMlCV8Oj.js +1 -0
- package/dist/client/assets/useInfiniteQuery-CM35R0yt.js +1 -0
- package/dist/client/assets/useQueries-C6OAJOs7.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-DWyGwvh9.js +1 -0
- package/dist/client/assets/{users-CuqlxLsH.js → users-CYflDdFv.js} +1 -1
- package/dist/client/assets/utils-B-5U5Z26.js +4 -0
- package/dist/client/assets/utils-CVEq3hMx.js +1 -0
- package/dist/client/assets/variant-calendar-BsFwTl3D.js +1 -0
- package/dist/client/assets/variant-matcher-override-CRlEf4IL.js +1 -0
- package/dist/client/assets/{view-mode-toggle-BlEO3gFJ.js → view-mode-toggle-kY4gR8CN.js} +1 -1
- package/dist/client/assets/virtual-mcp-CKi1xJsO.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/ErrorBarContext-CQj5vlL8.js +0 -1
- package/dist/client/assets/Sector-CD1ykt0B.js +0 -28
- package/dist/client/assets/ZoomOut-DhJWoynj.js +0 -1
- package/dist/client/assets/access-gate-OgewzCmd.js +0 -1
- package/dist/client/assets/agent-icon-6EllA70W.js +0 -1
- package/dist/client/assets/agents-list-BY0vT0Wn.js +0 -1
- package/dist/client/assets/ai-providers-vUA1qSht.js +0 -1
- package/dist/client/assets/analytics-tab-Do-IciVD.js +0 -2
- package/dist/client/assets/api-keys-pPtOUmL_.js +0 -1
- package/dist/client/assets/app-editor-CSGywsTY.js +0 -1
- package/dist/client/assets/automation-runs-CoIkXCsB.js +0 -187
- package/dist/client/assets/automations-CJ2EIlox.js +0 -1
- package/dist/client/assets/breadcrumb-CAKgWNOZ.js +0 -1
- package/dist/client/assets/bulk-category-panel-BenSOwl7.js +0 -1
- package/dist/client/assets/category-editor-iK-flfht.js +0 -1
- package/dist/client/assets/cdn-tab-Ck8xjhCA.js +0 -1
- package/dist/client/assets/chat-context-C6UT7ht1.js +0 -35
- package/dist/client/assets/choose-editor-B8v8x2gP.js +0 -1
- package/dist/client/assets/collection-detail-CZicQp0E.js +0 -1
- package/dist/client/assets/collection-display-button-BiBiEJPp.js +0 -1
- package/dist/client/assets/commerce-onboarding-DKWZMrBI.js +0 -1
- package/dist/client/assets/connect-layout-BLwdQBWt.js +0 -1
- package/dist/client/assets/connection-detail-BboxJXTl.js +0 -1
- package/dist/client/assets/connections-H_c0ER6v.js +0 -1
- package/dist/client/assets/e2e-tab-DbA_PByD.js +0 -1
- package/dist/client/assets/extract-connection-data-DkL3Oqhk.js +0 -1
- package/dist/client/assets/folder-icon-C46JPU0-.js +0 -2
- package/dist/client/assets/index-9Wn-1DpE.js +0 -1
- package/dist/client/assets/index-BEyFhSeZ.js +0 -834
- package/dist/client/assets/index-DHHqS3nT.js +0 -1
- package/dist/client/assets/index-DR6uwZdc.js +0 -1
- package/dist/client/assets/index-I7v7d4v2.js +0 -1
- package/dist/client/assets/index-SmsG_b1w.js +0 -1
- package/dist/client/assets/index-redirect-C3gwJ6Fh.js +0 -1
- package/dist/client/assets/infra-billing-Ch_WWq-u.js +0 -1
- package/dist/client/assets/members-ypEfbto9.js +0 -1
- package/dist/client/assets/monaco-editor-D3QSLeam.js +0 -9
- package/dist/client/assets/monitoring-stats-row--wR3KC6f.js +0 -1
- package/dist/client/assets/org-layout-DzsJ720P.js +0 -1
- package/dist/client/assets/page-seo-form-DPrfWQ94.js +0 -1
- package/dist/client/assets/post-calendar-DyncB6BE.js +0 -1
- package/dist/client/assets/post-editor-FfaApBeX.js +0 -1
- package/dist/client/assets/primitives-DZEMS67c.js +0 -1
- package/dist/client/assets/project-app-view-C1W5Uv5V.js +0 -1
- package/dist/client/assets/project-icon-DQTfNALl.js +0 -1
- package/dist/client/assets/provision-repo-scoped-github-connection-WQFARyHG.js +0 -1
- package/dist/client/assets/record-editor-DaGE-E4Q.js +0 -1
- package/dist/client/assets/redirect-editor-BgylW9YL.js +0 -1
- package/dist/client/assets/registry-YIdSAHGV.js +0 -2
- package/dist/client/assets/repository-import-picker-DN9Nn9yd.js +0 -1
- package/dist/client/assets/require-capability-BVMwcBeZ.js +0 -1
- package/dist/client/assets/review-settings-BN9py8rz.js +0 -1
- package/dist/client/assets/roles-CGT8NKA4.js +0 -1
- package/dist/client/assets/sections-editor-BIoyRz1G.js +0 -2
- package/dist/client/assets/select-model-BNDe5FJr.js +0 -4
- package/dist/client/assets/self-tool-result-DM7xixxP.js +0 -1
- package/dist/client/assets/seo-editor-EIeTDSnb.js +0 -1
- package/dist/client/assets/settings-layout-CwJp96nZ.js +0 -1
- package/dist/client/assets/settings-sidebar-BvIIdmkC.js +0 -1
- package/dist/client/assets/shell-controls-nVElTnLJ.js +0 -1
- package/dist/client/assets/shell-layout-CTNVA2t4.js +0 -1
- package/dist/client/assets/skill-preview-BswJw8Eb.js +0 -4
- package/dist/client/assets/skills-DXWVIfB4.js +0 -1
- package/dist/client/assets/store-BUUS-eER.js +0 -1
- package/dist/client/assets/store-registry-DxfEOZiI.js +0 -2
- package/dist/client/assets/switch-CPLM-IZy.js +0 -1
- package/dist/client/assets/synced-repos-Bl-1vG4K.js +0 -1
- package/dist/client/assets/task-route-B8aecmdq.js +0 -1
- package/dist/client/assets/thread-route-jI9qvJe_.js +0 -1
- package/dist/client/assets/toggle-group-WfRpP-dB.js +0 -1
- package/dist/client/assets/use-destination-route-CY15sZqw.js +0 -1
- package/dist/client/assets/use-mcp-client-Cw1fcLqm.js +0 -10
- package/dist/client/assets/use-navigate-to-agent-COVw0ub8.js +0 -1
- package/dist/client/assets/use-organization-settings-DucmPYOE.js +0 -1
- package/dist/client/assets/use-panel-navigate-C6Ga2vR8.js +0 -1
- package/dist/client/assets/use-registry-connections-DBp-MS3e.js +0 -1
- package/dist/client/assets/use-section-preview-base-B4s2_IK6.js +0 -1
- package/dist/client/assets/use-virtual-mcp-Bnfc4yEo.js +0 -1
- package/dist/client/assets/useInfiniteQuery-DThUrotQ.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-Dsg0_SX3.js +0 -1
- package/dist/client/assets/variant-calendar-BhJlQ5r6.js +0 -1
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import{r as L,c as _,b as J,ar as m1,j as p,h as hf,B as Ln,ag as Uc,ae as g1,aq as y1,cG as pf,cH as x1,aB as b1,be as $n,cI as v1,l as G,o as k1,a1 as _n,a2 as Bn,a4 as zn,bu as S1,br as pl,by as C1,bx as w1,cJ as N1,bv as M1,cK as T1,bt as E1,G as xt,n as mf,a7 as gf,e as D1,K as ht,t as fa,m as ni,E as yf,bb as xf,a9 as O1,cL as bf,p as A1,bl as vf,bm as kf,bn as Sf,bo as Cf,d as ml,cM as I1,cN as j1,bB as qc,b6 as R1}from"./index-y6Z5iMfg.js";import{aJ as P1,b0 as L1,b1 as $1,C as _1,k as B1,u as ha,aq as z1,i as Kc,aC as F1,m as H1,b2 as W1,a_ as wf,b3 as V1,j as pa,b4 as Nf,A as Mf,b5 as wt,b6 as U1,W as q1,h as K1,z as J1,b7 as Y1,b8 as G1}from"./agent-icon-6EllA70W.js";import{i as ma}from"./ChevronRight-B76sbAXC.js";import{u as X1}from"./useInfiniteQuery-DThUrotQ.js";import{a as Tf,u as Q1}from"./use-connection-ClORxmw4.js";import{h as Z1,u as gl,p as e0,i as Ef,a as Df,S as t0}from"./use-mcp-client-Cw1fcLqm.js";import{a as n0}from"./use-virtual-mcp-Bnfc4yEo.js";import{c as r0,e as s0,a as Of,d as Tr,b as o0,T as Er}from"./table-DSIbUmyY.js";import{E as Jc}from"./empty-state-DfBha5W6.js";import{u as Af}from"./use-infinite-scroll-Bw5rNIGx.js";import{a as i0}from"./use-members-C23rfxcZ.js";import{i as yl}from"./AlertCircle-Df7Uu4Sr.js";import{i as a0}from"./CheckCircle-DWvslkKl.js";import{a as l0}from"./DotsVertical-CBmzJDPB.js";import{i as c0}from"./XCircle-BK1898xU.js";import{e as u0}from"./use-automations-BgzAjzua.js";import{u as d0}from"./useSuspenseInfiniteQuery-Dsg0_SX3.js";import{A as f0}from"./avatar-CfO1mReu.js";import{t as If,n as h0}from"./ChevronUp-B0KEDz5f.js";import{t as p0,b as jf,n as Rf}from"./Tool02-BAA6OFl0.js";import{t as ri}from"./Stars01-ByE0-f1z.js";import{i as Pf}from"./ArrowRight-CuO69upc.js";import{i as xl}from"./Check-C1wq38_E.js";import{a as Lf}from"./Copy01-rsN5AnPv.js";import{b as Fn,t as bl,c as Yc}from"./format-time-BtXRrtv4.js";import{u as $f}from"./use-copy-DUxpBqXm.js";import{M as vl,I as m0}from"./markdown-Y6owwpHy.js";import{g as g0,a as y0,r as x0,d as b0}from"./hooks-Bv30myGB.js";import{k as wr,q as v0,b as vs,a as k0,D as S0}from"./chat-context-C6UT7ht1.js";import{c as C0}from"./monaco-editor-D3QSLeam.js";import{M as w0}from"./mcp-app-renderer-Cy31bAY0.js";import{g as _f}from"./types-BB_Up-3A.js";import{s as N0}from"./Eye-DFgd5114.js";import{s as M0}from"./XClose-DvenHyNp.js";import{b as T0,a as E0}from"./Tool01-CmpQe3MS.js";import{i as D0}from"./Share07-CJrTonmW.js";import{i as O0}from"./SearchMd-hxPQERkg.js";import{u as A0,a as I0}from"./shell-layout-CTNVA2t4.js";import{a as kl}from"./use-panel-navigate-C6Ga2vR8.js";import{a as Ps}from"./Image01-CMpSR3RQ.js";import{n as Bf}from"./LinkExternal01-CzRiacvQ.js";import{I as Kn}from"./integration-icon-CFGOsRgH.js";import{b as Sl}from"./Users03-B4Km0_9u.js";import{a as Nt}from"./Palette-CmMvG40G.js";import{u as zf}from"./use-navigate-to-agent-COVw0ub8.js";import{i as Ls}from"./Link01-pX5C3rEv.js";import{g as j0}from"./use-mcp-prompts-CtjkJFfg.js";import{d as R0,c as P0,e as L0,b as $0,D as _0}from"./dialog-CyDGwxcX.js";import{F as B0,d as z0,a as F0,e as H0,b as W0,c as V0}from"./form-BnUN8JhF.js";import{I as U0}from"./input-DRjCNSPN.js";import{i as q0}from"./Globe01-Df6dZmsR.js";import{i as K0}from"./Monitor01-jzbehxNG.js";import{n as J0}from"./Download01-zZEPtQ0U.js";import{F as Y0}from"./file-type-icon--TvA6C0i.js";import{u as G0}from"./use-decopilot-events-C0NWoSQc.js";const X0={openrouter:t=>{const e=t?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function Ff(t){if(!t?.providerMetadata)return 0;for(const e of Object.values(X0)){const n=e(t.providerMetadata);if(n!==null)return n}return 0}function Hf(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0,cacheReadTokens:0,cacheWriteTokens:0}}function Wf(t,e){if(!e)return t;const n=e.inputTokenDetails?.cacheReadTokens??e.cachedInputTokens??0,r=e.inputTokenDetails?.cacheWriteTokens??0;return{inputTokens:t.inputTokens+(e.inputTokens??0),outputTokens:t.outputTokens+(e.outputTokens??0),reasoningTokens:t.reasoningTokens+(e.reasoningTokens??0),totalTokens:t.totalTokens+(e.totalTokens??0),cost:t.cost+Ff(e),cacheReadTokens:t.cacheReadTokens+n,cacheWriteTokens:t.cacheWriteTokens+r}}function Cl(t){const e=Math.max(t.inputTokens,t.cacheReadTokens+t.cacheWriteTokens);return e>0?t.cacheReadTokens/e:0}function KO(t){return t.reduce((e,n)=>Wf(e,n.metadata?.usage),Hf())}const Q0={damping:.7,stiffness:.05,mass:1.25},Z0=70,ey=1e3/60,ty=350;let si=!1;globalThis.document?.addEventListener("mousedown",()=>{si=!0});globalThis.document?.addEventListener("mouseup",()=>{si=!1});globalThis.document?.addEventListener("click",()=>{si=!1});const ny=(t={})=>{const[e,n]=L.useState(!1),[r,s]=L.useState(t.initial!==!1),[o,i]=L.useState(!1),a=L.useRef(null);a.current=t;const l=L.useCallback(()=>{if(!si)return!1;const b=window.getSelection();if(!b||!b.rangeCount)return!1;const v=b.getRangeAt(0);return v.commonAncestorContainer.contains(g.current)||g.current?.contains(v.commonAncestorContainer)},[]),c=L.useCallback(b=>{d.isAtBottom=b,s(b)},[]),u=L.useCallback(b=>{d.escapedFromLock=b,n(b)},[]),d=L.useMemo(()=>{let b;return{escapedFromLock:e,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(v){if(g.current){const{scrollBehavior:k}=getComputedStyle(g.current);k!=="auto"&&(g.current.style.scrollBehavior="auto"),g.current.scrollTop=v,d.ignoreScrollToTop=g.current.scrollTop,k!=="auto"&&(g.current.style.scrollBehavior=k)}},get targetScrollTop(){return!g.current||!x.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!x.current)return 0;const{targetScrollTop:v}=this;if(!t.targetScrollTop)return v;if(b?.targetScrollTop===v)return b.calculatedScrollTop;const k=Math.max(Math.min(t.targetScrollTop(v,{scrollElement:g.current,contentElement:x.current}),v),0);return b={targetScrollTop:v,calculatedScrollTop:k},requestAnimationFrame(()=>{b=void 0}),k},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Z0}}},[]),f=L.useCallback((b={})=>{typeof b=="string"&&(b={animation:b}),b.preserveScrollPosition||c(!0);const v=Date.now()+(Number(b.wait)||0),k=Mi(a.current,b.animation),{ignoreEscapes:N=!1}=b;let C,S=d.calculatedTargetScrollTop;b.duration instanceof Promise?b.duration.finally(()=>{C=Date.now()}):C=v+(b.duration??0);const w=async()=>{const M=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;const{scrollTop:T}=d,O=performance.now(),A=(O-(d.lastTick??O))/ey;if(d.animation||(d.animation={behavior:k,promise:M,ignoreEscapes:N}),d.animation.behavior===k&&(d.lastTick=O),l()||v>Date.now())return w();if(T<Math.min(S,d.calculatedTargetScrollTop)){if(d.animation?.behavior===k){if(k==="instant")return d.scrollTop=d.calculatedTargetScrollTop,w();d.velocity=(k.damping*d.velocity+k.stiffness*d.scrollDifference)/k.mass,d.accumulated+=d.velocity*A,d.scrollTop+=d.accumulated,d.scrollTop!==T&&(d.accumulated=0)}return w()}return C>Date.now()?(S=d.calculatedTargetScrollTop,w()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:Mi(a.current,a.current.resize),ignoreEscapes:N,duration:Math.max(0,C-Date.now())||void 0}):d.isAtBottom)});return M.then(T=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),T))};return b.wait!==!0&&(d.animation=void 0),d.animation?.behavior===k?d.animation.promise:w()},[c,l,d]),h=L.useCallback(()=>{u(!0),c(!1)},[u,c]),m=L.useCallback(({target:b})=>{if(b!==g.current)return;const{scrollTop:v,ignoreScrollToTop:k}=d;let{lastScrollTop:N=v}=d;d.lastScrollTop=v,d.ignoreScrollToTop=void 0,k&&k>v&&(N=k),i(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||v===k)return;if(l()){u(!0),c(!1);return}const C=v>N,S=v<N;if(d.animation?.ignoreEscapes){d.scrollTop=N;return}S&&(u(!0),c(!1)),C&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,l,d]),y=L.useCallback(({target:b,deltaY:v})=>{let k=b;for(;!["scroll","auto"].includes(getComputedStyle(k).overflow);){if(!k.parentElement)return;k=k.parentElement}k===g.current&&v<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),g=Gc(b=>{g.current?.removeEventListener("scroll",m),g.current?.removeEventListener("wheel",y),b?.addEventListener("scroll",m,{passive:!0}),b?.addEventListener("wheel",y,{passive:!0})},[]),x=Gc(b=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!b)return;let v;d.resizeObserver=new ResizeObserver(([k])=>{const{height:N}=k.contentRect,C=N-(v??N);if(d.resizeDifference=C,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),i(d.isNearBottom),C>=0){const S=Mi(a.current,v?a.current.resize:a.current.initial);f({animation:S,wait:!0,preserveScrollPosition:!0,duration:S==="instant"?void 0:ty})}else d.isNearBottom&&(u(!1),c(!0));v=N,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===C&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(b)},[]);return{contentRef:x,scrollRef:g,scrollToBottom:f,stopScroll:h,isAtBottom:r||o,isNearBottom:o,escapedFromLock:e,state:d}};function Gc(t,e){const n=L.useCallback(r=>(n.current=r,t(r)),e);return n}const Ni=new Map;function Mi(...t){const e={...Q0};let n=!1;for(const s of t){if(s==="instant"){n=!0;continue}typeof s=="object"&&(n=!1,e.damping=s.damping??e.damping,e.stiffness=s.stiffness??e.stiffness,e.mass=s.mass??e.mass)}const r=JSON.stringify(e);return Ni.has(r)||Ni.set(r,Object.freeze(e)),n?"instant":Ni.get(r)}function ry(t){let e=2166136261;for(let n=0;n<t.length;n++)e=Math.imul(e^t.charCodeAt(n),16777619);return`a${(e>>>0).toString(36).padStart(6,"0").slice(-6)}`}function wl(t){if(t&&typeof t=="object"&&"gatewayClientId"in t&&typeof t.gatewayClientId=="string")return t.gatewayClientId}function Nl(t,e){if(!e)return t;const n=`${ry(e)}_`;return t.startsWith(n)?t.slice(n.length):t}function sy(t,e){return Nl(t,e).replace(/[_-]/g," ").toLowerCase()}function oy(t,e){const n={};for(const r of t?.arguments??[])n[r.name]=r.required?Uc().min(1,e):Uc();return g1(n)}function iy(t,e){const n={};for(const r of t.arguments??[])n[r.name]=e?.[r.name]??"";return n}function ay(t){const e=_.c(74),{prompt:n,setPrompt:r,onSubmit:s,defaultValues:o}=t,i=L.useId(),a=J();let l,c;if(e[0]!==n||e[1]!==a){const W=oy(n,a("chat.dialogPromptArguments.required"));c=y1,l=m1(W),e[0]=n,e[1]=a,e[2]=l,e[3]=c}else l=e[2],c=e[3];let u;e[4]!==o||e[5]!==n?(u=n?iy(n,o):{},e[4]=o,e[5]=n,e[6]=u):u=e[6];let d;e[7]!==l||e[8]!==u?(d={resolver:l,defaultValues:u,mode:"onChange"},e[7]=l,e[8]=u,e[9]=d):d=e[9];const f=c(d);let h;e[10]!==n?.arguments?(h=n?.arguments??[],e[10]=n?.arguments,e[11]=h):h=e[11];const m=h;let y;e[12]!==f||e[13]!==s||e[14]!==r?(y=async W=>{await s(W),r(null),f.reset()},e[12]=f,e[13]=s,e[14]=r,e[15]=y):y=e[15];const g=y;let x;e[16]!==f||e[17]!==r?(x=W=>{W||(f.reset(),r(null))},e[16]=f,e[17]=r,e[18]=x):x=e[18];const b=x;if(!n)return null;let v;e[19]!==n._meta||e[20]!==n.name||e[21]!==n.title?(v=n.title||sy(n.name,wl(n._meta)),e[19]=n._meta,e[20]=n.name,e[21]=n.title,e[22]=v):v=e[22];let k;e[23]!==v?(k=p.jsx(R0,{children:p.jsx("span",{className:"capitalize",children:v})}),e[23]=v,e[24]=k):k=e[24];let N;e[25]!==n.description?(N=n.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[25]=n.description,e[26]=N):N=e[26];let C;e[27]!==N||e[28]!==k?(C=p.jsxs(P0,{children:[k,N]}),e[27]=N,e[28]=k,e[29]=C):C=e[29];let S;e[30]!==f||e[31]!==g?(S=W=>{W.stopPropagation(),f.handleSubmit(g)(W)},e[30]=f,e[31]=g,e[32]=S):S=e[32];let w;if(e[33]!==m||e[34]!==f.control||e[35]!==f.formState.isSubmitting||e[36]!==a){let W;e[38]!==f.control||e[39]!==f.formState.isSubmitting||e[40]!==a?(W=q=>p.jsx(z0,{control:f.control,name:q.name,render:X=>{const{field:te}=X;return p.jsxs(F0,{children:[p.jsxs(H0,{className:"text-xs",children:[q.name,q.required?null:p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ",a("chat.dialogPromptArguments.optional")]})]}),p.jsx(W0,{children:p.jsx(U0,{...te,value:te.value??"",required:q.required,placeholder:q.description??"",className:"h-9",disabled:f.formState.isSubmitting})}),p.jsx(V0,{})]})}},q.name),e[38]=f.control,e[39]=f.formState.isSubmitting,e[40]=a,e[41]=W):W=e[41],w=m.map(W),e[33]=m,e[34]=f.control,e[35]=f.formState.isSubmitting,e[36]=a,e[37]=w}else w=e[37];let M;e[42]!==b?(M=()=>b(!1),e[42]=b,e[43]=M):M=e[43];const T=f.formState.isSubmitting;let O;e[44]!==a?(O=a("chat.dialogPromptArguments.cancel"),e[44]=a,e[45]=O):O=e[45];let A;e[46]!==f.formState.isSubmitting||e[47]!==M||e[48]!==O?(A=p.jsx(Ln,{type:"button",variant:"ghost",onClick:M,disabled:T,children:O}),e[46]=f.formState.isSubmitting,e[47]=M,e[48]=O,e[49]=A):A=e[49];let P;e[50]!==f.formState.isSubmitting||e[51]!==a?(P=f.formState.isSubmitting?p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(hf,{size:"xs"}),a("chat.dialogPromptArguments.loading")]}):a("chat.dialogPromptArguments.usePrompt"),e[50]=f.formState.isSubmitting,e[51]=a,e[52]=P):P=e[52];let D;e[53]!==f.formState.isSubmitting||e[54]!==i||e[55]!==P?(D=p.jsx(Ln,{type:"submit",form:i,disabled:f.formState.isSubmitting,children:P}),e[53]=f.formState.isSubmitting,e[54]=i,e[55]=P,e[56]=D):D=e[56];let E;e[57]!==A||e[58]!==D?(E=p.jsxs(L0,{children:[A,D]}),e[57]=A,e[58]=D,e[59]=E):E=e[59];let j;e[60]!==i||e[61]!==S||e[62]!==w||e[63]!==E?(j=p.jsxs("form",{id:i,className:"space-y-4 py-4",autoComplete:"off",onSubmit:S,children:[w,E]}),e[60]=i,e[61]=S,e[62]=w,e[63]=E,e[64]=j):j=e[64];let I;e[65]!==f||e[66]!==j?(I=p.jsx(B0,{...f,children:j}),e[65]=f,e[66]=j,e[67]=I):I=e[67];let R;e[68]!==C||e[69]!==I?(R=p.jsxs($0,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,I]}),e[68]=C,e[69]=I,e[70]=R):R=e[70];let z;return e[71]!==b||e[72]!==R?(z=p.jsx(_0,{open:!0,onOpenChange:b,children:R}),e[71]=b,e[72]=R,e[73]=z):z=e[73],z}function ga(t){return t?t.replace(/[_-]/g," ").toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function It(t,e){return t==="output-error"||t==="output-denied"?"error":t==="approval-requested"?"approval":t==="input-streaming"||t==="input-available"||t==="output-available"&&e===!0?"loading":"idle"}function Nr(t){if(t==null||typeof t!="object")return;const e=t;if(e.structuredContent&&typeof e.structuredContent=="object")return e.structuredContent;if(Array.isArray(e.content)){const n=e.content[0];if(n?.type==="text"&&typeof n.text=="string")try{return JSON.parse(n.text)}catch{return}return}return t}var Xc=Object.defineProperty,ly=(t,e)=>{let n={};for(var r in t)Xc(n,r,{get:t[r],enumerable:!0});return Xc(n,Symbol.toStringTag,{value:"Module"}),n};function Ie(t){this.content=t}Ie.prototype={constructor:Ie,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),o=r.content.slice();return s==-1?o.push(n||t,e):(o[s+1]=e,n&&(o[s]=n)),new Ie(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Ie(n)},addToStart:function(t,e){return new Ie([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Ie(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),o=r.find(t);return s.splice(o==-1?s.length:o,0,e,n),new Ie(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Ie.from(t),t.size?new Ie(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Ie.from(t),t.size?new Ie(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Ie.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Ie.from=function(t){if(t instanceof Ie)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ie(e)};function Vf(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),o=e.child(r);if(s==o){n+=s.nodeSize;continue}if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){let i=s.text,a=o.text,l=0;for(;i[l]==a[l];l++)n++;return l&&l<i.length&&l<a.length&&Kf(i.charCodeAt(l-1))&&qf(i.charCodeAt(l))&&n--,n}if(s.content.size||o.content.size){let i=Vf(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function Uf(t,e,n,r){for(let s=t.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:n,b:r};let i=t.child(--s),a=e.child(--o),l=i.nodeSize;if(i==a){n-=l,r-=l;continue}if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let c=i.text,u=a.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,n--,r--;return d&&f&&d<c.length&&Kf(c.charCodeAt(d-1))&&qf(c.charCodeAt(d))&&(n++,r++),{a:n,b:r}}if(i.content.size||a.content.size){let c=Uf(i.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}function qf(t){return t>=56320&&t<57344}function Kf(t){return t>=55296&&t<56320}class ${constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,o){for(let i=0,a=0;a<n;i++){let l=this.content[i],c=a+l.nodeSize;if(c>e&&r(l,s+a,o||null,i)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,s+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let o="",i=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new $(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let o=0,i=0;i<n;o++){let a=this.content[o],l=i+a.nodeSize;l>e&&((i<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-i),Math.min(a.text.length,n-i)):a=a.cut(Math.max(0,e-i-1),Math.min(a.content.size,n-i-1))),r.push(a),s+=a.nodeSize),i=l}return new $(r,s)}cutByIndex(e,n){return e==n?$.empty:e==0&&n==this.content.length?this:new $(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new $(s,o)}addToStart(e){return new $([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new $(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Vf(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Uf(this,e,n,r)}findIndex(e){if(e==0)return $s(0,e);if(e==this.size)return $s(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),o=r+s.nodeSize;if(o>=e)return o==e?$s(n+1,o):$s(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return $.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return $.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return $.empty;let n,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(n||(n=e.slice(0,s)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new $(n||e,r)}static from(e){if(!e)return $.empty;if(e instanceof $)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new $([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}$.empty=new $([],0);const Ti={index:0,offset:0};function $s(t,e){return Ti.index=t,Ti.offset=e,Ti}function io(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!io(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!io(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let le=class ya{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&io(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ya.none;if(e instanceof ya)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};le.none=[];class ss extends Error{}class F{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Yf(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new F(r,this.openStart,this.openEnd)}removeBetween(e,n){return new F(Jf(this.content,e+this.openStart,n+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,n){if(!n)return F.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new F($.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)s++;return new F(e,r,s)}}F.empty=new F($.empty,0,0);function Jf(t,e,n){let{index:r,offset:s}=t.findIndex(e),o=t.maybeChild(r),{index:i,offset:a}=t.findIndex(n);if(s==e||o.isText){if(a!=n&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(Jf(o.content,e-s-1,n-s-1)))}function Yf(t,e,n,r,s,o){let{index:i,offset:a}=t.findIndex(e),l=t.maybeChild(i);if(a==e||l.isText)return o&&r<=0&&s<=0&&!o.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Yf(l.content,e-a-1,n,i==0?r-1:0,i==t.childCount-1?s-1:0,l);return c&&t.replaceChild(i,l.copy(c))}function cy(t,e,n){if(n.openStart>t.depth)throw new ss("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ss("Inconsistent open depths");return Gf(t,e,n,0)}function Gf(t,e,n,r){let s=t.index(r),o=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let i=Gf(t,e,n,r+1);return o.copy(o.content.replaceChild(s,i))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let i=t.parent,a=i.content;return Dn(i,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:i,end:a}=uy(n,t);return Dn(o,Qf(t,i,a,e,r))}else return Dn(o,ao(t,e,r))}function Xf(t,e){if(!e.type.compatibleContent(t.type))throw new ss("Cannot join "+e.type.name+" onto "+t.type.name)}function xa(t,e,n){let r=t.node(n);return Xf(r,e.node(n)),r}function En(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Wr(t,e,n,r){let s=(e||t).node(n),o=0,i=e?e.index(n):s.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(En(t.nodeAfter,r),o++));for(let a=o;a<i;a++)En(s.child(a),r);e&&e.depth==n&&e.textOffset&&En(e.nodeBefore,r)}function Dn(t,e){if(!t.type.validContent(e))throw new ss("Invalid content for node "+t.type.name);return t.copy(e)}function Qf(t,e,n,r,s){let o=t.depth>s&&xa(t,e,s+1),i=r.depth>s&&xa(n,r,s+1),a=[];return Wr(null,t,s,a),o&&i&&e.index(s)==n.index(s)?(Xf(o,i),En(Dn(o,Qf(t,e,n,r,s+1)),a)):(o&&En(Dn(o,ao(t,e,s+1)),a),Wr(e,n,s,a),i&&En(Dn(i,ao(n,r,s+1)),a)),Wr(r,null,s,a),new $(a)}function ao(t,e,n){let r=[];if(Wr(null,t,n,r),t.depth>n){let s=xa(t,e,n+1);En(Dn(s,ao(t,e,n+1)),r)}return Wr(e,null,n,r),new $(r)}function uy(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)s=e.node(o).copy($.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class is{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?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[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return le.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let a=r;r=s,s=a}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new lo(this,e,r);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 n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,o=n;for(let i=e;;){let{index:a,offset:l}=i.content.findIndex(o),c=o-l;if(r.push(i,a,s+l),!c||(i=i.child(a),i.isText))break;o=c-1,s+=l+1}return new is(n,r,o)}static resolveCached(e,n){let r=Qc.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==n)return i}else Qc.set(e,r=new dy);let s=r.elts[r.i]=is.resolve(e,n);return r.i=(r.i+1)%fy,s}}class dy{constructor(){this.elts=[],this.i=0}}const fy=12,Qc=new WeakMap;class lo{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}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)}}const hy=Object.create(null);let On=class ba{constructor(e,n,r,s=le.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||$.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,n,r,s=0){this.content.nodesBetween(e,n,r,s,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,n,r,s){return this.content.textBetween(e,n,r,s)}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,n,r){return this.type==e&&io(this.attrs,n||e.defaultAttrs||hy)&&le.sameSet(this.marks,r||le.none)}copy(e=null){return e==this.content?this:new ba(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ba(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return F.empty;let s=this.resolve(e),o=this.resolve(n),i=r?0:s.sharedDepth(n),a=s.start(i),c=s.node(i).content.cut(s.pos-a,o.pos-a);return new F(c,s.depth-i,o.depth-i)}replace(e,n,r){return cy(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return is.resolveCached(this,e)}resolveNoCache(e){return is.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}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()+")"),Zf(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=$.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),a=i&&i.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=s;l<o;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,n);return i?i.validEnd:!1}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=le.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!le.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=$.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,s,r);return o.type.checkAttrs(o.attrs),o}};On.prototype.text=void 0;class co extends On{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Zf(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new co(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new co(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Zf(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Hn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new py(e,n);if(r.next==null)return Hn.empty;let s=eh(r);r.next&&r.err("Unexpected trailing text");let o=ky(vy(s));return Sy(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let o=n;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function o(i,a){let l=i.matchFragment(e,r);if(l&&(!n||l.validEnd))return $.from(a.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,a.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let a=s;a.type;a=a.via)i.push(a.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:a,next:l}=o.next[i];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!s.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:s}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
|
|
2
|
-
`)}}Hn.empty=new Hn(!0);class py{constructor(e,n){this.string=e,this.nodeTypes=n,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 new SyntaxError(e+" (in content expression '"+this.string+"')")}}function eh(t){let e=[];do e.push(my(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function my(t){let e=[];do e.push(gy(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function gy(t){let e=by(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=yy(t,e);else break;return e}function Zc(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function yy(t,e){let n=Zc(t),r=n;return t.eat(",")&&(t.next!="}"?r=Zc(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function xy(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let o in n){let i=n[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function by(t){if(t.eat("(")){let e=eh(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=xy(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function vy(t){let e=[[]];return s(o(t,0),n()),e;function n(){return e.push([])-1}function r(i,a,l){let c={term:l,to:a};return e[i].push(c),c}function s(i,a){i.forEach(l=>l.to=a)}function o(i,a){if(i.type=="choice")return i.exprs.reduce((l,c)=>l.concat(o(c,a)),[]);if(i.type=="seq")for(let l=0;;l++){let c=o(i.exprs[l],a);if(l==i.exprs.length-1)return c;s(c,a=n())}else if(i.type=="star"){let l=n();return r(a,l),s(o(i.expr,l),l),[r(l)]}else if(i.type=="plus"){let l=n();return s(o(i.expr,a),l),s(o(i.expr,l),l),[r(l)]}else{if(i.type=="opt")return[r(a)].concat(o(i.expr,a));if(i.type=="range"){let l=a;for(let c=0;c<i.min;c++){let u=n();s(o(i.expr,l),u),l=u}if(i.max==-1)s(o(i.expr,l),l);else for(let c=i.min;c<i.max;c++){let u=n();r(l,u),s(o(i.expr,l),u),l=u}return[r(l)]}else{if(i.type=="name")return[r(a,void 0,i.value)];throw new Error("Unknown expr type")}}}}function th(t,e){return e-t}function eu(t,e){let n=[];return r(e),n.sort(th);function r(s){let o=t[s];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(s);for(let i=0;i<o.length;i++){let{term:a,to:l}=o[i];!a&&n.indexOf(l)==-1&&r(l)}}}function ky(t){let e=Object.create(null);return n(eu(t,0));function n(r){let s=[];r.forEach(i=>{t[i].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<s.length;u++)s[u][0]==a&&(c=s[u][1]);eu(t,l).forEach(u=>{c||s.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Hn(r.indexOf(t.length-1)>-1);for(let i=0;i<s.length;i++){let a=s[i][1].sort(th);o.next.push({type:s[i][0],next:e[a.join(",")]||n(a)})}return o}}function Sy(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],o=!s.validEnd,i=[];for(let a=0;a<s.next.length;a++){let{type:l,next:c}=s.next[a];i.push(l.name),o&&!(l.isText||l.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function nh(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function rh(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let o=t[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function sh(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}function oh(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new wy(t,r,e[r]);return n}let tu=class ih{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=oh(e,r.attrs),this.defaultAttrs=nh(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Hn.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:rh(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new On(this,this.computeAttrs(e),$.from(n),le.setFrom(r))}createChecked(e=null,n,r){return n=$.from(n),this.checkContent(n),new On(this,this.computeAttrs(e),n,le.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=$.from(n),n.size){let i=this.contentMatch.fillBefore(n);if(!i)return null;n=i.append(n)}let s=this.contentMatch.matchFragment(n),o=s&&s.fillBefore($.empty,!0);return o?new On(this,e,n.append(o),le.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){sh(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:le.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,i)=>r[o]=new ih(o,n,i));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Cy(t,e,n){let r=n.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class wy{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Cy(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class oi{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=oh(e,s.attrs),this.excluded=null;let o=nh(this.attrs);this.instance=o?new le(this,o):null}create(e=null){return!e&&this.instance?this.instance:new le(this,rh(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new oi(o,s++,n,i)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){sh(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class ah{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Ie.from(e.nodes),n.marks=Ie.from(e.marks||{}),this.nodes=tu.compile(this.spec.nodes,this),this.marks=oi.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=Hn.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?nu(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:nu(this,i.split(" "))}this.nodeFromJSON=s=>On.fromJSON(this,s),this.markFromJSON=s=>le.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof tu){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new co(r,r.defaultAttrs,e,le.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function nu(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],o=t.marks[s],i=o;if(o)n.push(o);else for(let a in t.marks){let l=t.marks[a];(s=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(s)>-1)&&n.push(i=l)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Ny(t){return t.tag!=null}function My(t){return t.style!=null}class Et{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(Ny(s))this.tags.push(s);else if(My(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new su(this,n,!1);return r.addAll(e,le.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new su(this,n,!0);return r.addAll(e,le.none,n.from,n.to),F.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(Dy(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,n,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],a=i.style;if(!(a.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(i.getAttrs){let l=i.getAttrs(n);if(l===!1)continue;i.attrs=l||void 0}return i}}}static schemaRules(e){let n=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<n.length;i++){let a=n[i];if((a.priority==null?50:a.priority)<o)break}n.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=ou(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{r(i=ou(i)),i.node||i.ignore||i.mark||(i.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Et(e,Et.schemaRules(e)))}}const lh={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},Ty={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ch={ol:!0,ul:!0},as=1,va=2,Vr=4;function ru(t,e,n){return e!=null?(e?as:0)|(e==="full"?va:0):t&&t.whitespace=="pre"?as|va:n&~Vr}class _s{constructor(e,n,r,s,o,i){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=le.none,this.match=o||(i&Vr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore($.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&as)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let n=$.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore($.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!lh.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class su{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,o,i=ru(null,n.preserveWhitespace,0)|(r?Vr:0);s?o=new _s(s.type,s.attrs,le.none,!0,n.topMatch||s.type.contentMatch,i):r?o=new _s(null,null,le.none,!0,null,i):o=new _s(e.schema.topNodeType,null,le.none,!0,null,i),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,o=s.options&va?"full":this.localPreserveWS||(s.options&as)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
|
|
3
|
-
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(i.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(i.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=s.content[s.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),a;ch.hasOwnProperty(i)&&this.parser.normalizeLists&&Ey(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:Ty.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(lh.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=l&&l.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
-
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let a=void 0;;){let l=this.parser.matchStyle(o,i,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,s){let o,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(i,n.attrs||null,r,n.preserveWhitespace);l&&(o=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}o&&this.sync(a)&&this.open--}addAll(e,n,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];i!=a;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,n);this.findAtPoint(e,o)}findPlace(e,n,r){let s,o;for(let i=this.open,a=0;i>=0;i--){let l=this.nodes[i],c=l.findWrapping(e);if(c&&(!s||s.length>c.length+a)&&(s=c,o=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)n=this.enterInner(s[i],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=le.none;for(let a of s.concat(e.marks))(o.type?o.type.allowsMarkType(a.type):iu(a.type,e.type))&&(i=a.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,n,r,s){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,s)),o}enterInner(e,n,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let a=ru(e,o,i.options);i.options&Vr&&i.content.length==0&&(a|=Vr);let l=le.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):iu(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new _s(e,n,l,s,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=as)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=o;l--)if(i(a-1,l))return!0;return!1}else{let u=l>0||l==0&&s?this.nodes[l].type:r&&l>=o?r.node(l-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return i(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ey(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ch.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Dy(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ou(t){let e={};for(let n in t)e[n]=t[n];return e}function iu(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let o=[],i=a=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class qt{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Bs(n).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let a=0,l=0;for(;a<o.length&&l<i.marks.length;){let c=i.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(o[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<o.length;)s=o.pop()[1];for(;l<i.marks.length;){let c=i.marks[l++],u=this.serializeMark(c,i.isInline,n);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(e,n){if(e.isText)return Bs(n).createTextNode(e.text);let{dom:r,contentDOM:s}=Zs(Bs(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Zs(Bs(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:Zs(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new qt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=au(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return au(e.marks)}}function au(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Bs(t){return t.document||window.document}const lu=new WeakMap;function Oy(t){let e=lu.get(t);return e===void 0&&lu.set(t,e=Ay(t)),e}function Ay(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Zs(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Oy(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(n=s.slice(0,i),s=s.slice(i+1));let a,l=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?l.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof f=="string")l.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:m}=Zs(t,f,n,r);if(l.appendChild(h),m){if(a)throw new RangeError("Multiple content holes");a=m}}}return{dom:l,contentDOM:a}}const uh=65535,dh=Math.pow(2,16);function Iy(t,e){return t+e*dh}function cu(t){return t&uh}function jy(t){return(t-(t&uh))/dh}const fh=1,hh=2,eo=4,ph=8;class ka{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ph)>0}get deletedBefore(){return(this.delInfo&(fh|eo))>0}get deletedAfter(){return(this.delInfo&(hh|eo))>0}get deletedAcross(){return(this.delInfo&eo)>0}}class et{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&et.empty)return et.empty}recover(e){let n=0,r=cu(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+jy(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let c=this.ranges[a+o],u=this.ranges[a+i],d=l+c;if(e<=d){let f=c?e==l?-1:e==d?1:n:n,h=l+s+(f<0?0:u);if(r)return h;let m=e==(n<0?l:d)?null:Iy(a/3,e-l),y=e==l?hh:e==d?fh:eo;return(n<0?e!=l:e!=d)&&(y|=ph),new ka(h,y,m)}s+=u-c}return r?e+s:new ka(e+s,0,null)}touches(e,n){let r=0,s=cu(n),o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+o],u=l+c;if(e<=u&&a==s*3)return!0;r+=this.ranges[a+i]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],a=i-(this.inverted?o:0),l=i+(this.inverted?0:o),c=this.ranges[s+n],u=this.ranges[s+r];e(a,a+c,l,l+u),o+=u-c}}invert(){return new et(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?et.empty:new et(e<0?[0,-e,0]:[0,0,e])}}et.empty=new et([]);class ls{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new ls(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new ls;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],a=i.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(o);if(l!=null&&l>o&&l<this.to){o=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new ka(e,s,null)}}const Ei=Object.create(null);class Fe{getMap(){return et.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ei[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ei)throw new RangeError("Duplicate use of step JSON ID "+e);return Ei[e]=n,n.prototype.jsonID=e,n}}class ke{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ke(e,null)}static fail(e){return new ke(null,e)}static fromReplace(e,n,r,s){try{return ke.ok(e.replace(n,r,s))}catch(o){if(o instanceof ss)return ke.fail(o.message);throw o}}}function Ml(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let o=t.child(s);o.content.size&&(o=o.copy(Ml(o.content,e,o))),o.isInline&&(o=e(o,n,s)),r.push(o)}return $.fromArray(r)}class sn extends Fe{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new F(Ml(n.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),n.openStart,n.openEnd);return ke.fromReplace(e,this.from,this.to,o)}invert(){return new pt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new sn(n.pos,r.pos,this.mark)}merge(e){return e instanceof sn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new sn(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new sn(n.from,n.to,e.markFromJSON(n.mark))}}Fe.jsonID("addMark",sn);class pt extends Fe{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new F(Ml(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return ke.fromReplace(e,this.from,this.to,r)}invert(){return new sn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new pt(n.pos,r.pos,this.mark)}merge(e){return e instanceof pt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new pt(n.from,n.to,e.markFromJSON(n.mark))}}Fe.jsonID("removeMark",pt);class on extends Fe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ke.fromReplace(e,this.pos,this.pos+1,new F($.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new on(this.pos,n.marks[s]);return new on(this.pos,this.mark)}}return new Wn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new on(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new on(n.pos,e.markFromJSON(n.mark))}}Fe.jsonID("addNodeMark",on);class Wn extends Fe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ke.fromReplace(e,this.pos,this.pos+1,new F($.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new on(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Wn(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Wn(n.pos,e.markFromJSON(n.mark))}}Fe.jsonID("removeNodeMark",Wn);class ve extends Fe{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Sa(e,this.from,this.to)?ke.fail("Structure replace would overwrite content"):ke.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new et([this.from,this.to-this.from,this.slice.size])}invert(e){return new ve(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&ve.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new ve(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ve)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?F.empty:new F(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ve(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?F.empty:new F(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ve(e.from,this.to,n,this.structure)}else return null}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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ve(n.from,n.to,F.fromJSON(e,n.slice),!!n.structure)}}ve.MAP_BIAS=1;Fe.jsonID("replace",ve);class Oe extends Fe{constructor(e,n,r,s,o,i,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=a}apply(e){if(this.structure&&(Sa(e,this.from,this.gapFrom)||Sa(e,this.gapTo,this.to)))return ke.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ke.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ke.fromReplace(e,this.from,this.to,r):ke.fail("Content does not fit in gap")}getMap(){return new et([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Oe(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||o>r.pos?null:new Oe(n.pos,r.pos,s,o,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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Oe(n.from,n.to,n.gapFrom,n.gapTo,F.fromJSON(e,n.slice),n.insert,!!n.structure)}}Fe.jsonID("replaceAround",Oe);function Sa(t,e,n){let r=t.resolve(e),s=n-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Ry(t,e,n,r){let s=[],o=[],i,a;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+l.nodeSize,n),m=r.addToSet(d);for(let y=0;y<d.length;y++)d[y].isInSet(m)||(i&&i.to==f&&i.mark.eq(d[y])?i.to=h:s.push(i=new pt(f,h,d[y])));a&&a.to==f?a.to=h:o.push(a=new sn(f,h,r))}}),s.forEach(l=>t.step(l)),o.forEach(l=>t.step(l))}function Py(t,e,n,r){let s=[],o=0;t.doc.nodesBetween(e,n,(i,a)=>{if(!i.isInline)return;o++;let l=null;if(r instanceof oi){let c=i.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(l=[r]):l=i.marks;if(l&&l.length){let c=Math.min(a+i.nodeSize,n);for(let u=0;u<l.length;u++){let d=l[u],f;for(let h=0;h<s.length;h++){let m=s[h];m.step==o-1&&d.eq(s[h].style)&&(f=m)}f?(f.to=c,f.step=o):s.push({style:d,from:Math.max(a,e),to:c,step:o})}}}),s.forEach(i=>t.step(new pt(i.from,i.to,i.style)))}function Tl(t,e,n,r=n.contentMatch,s=!0){let o=t.doc.nodeAt(e),i=[],a=e+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),u=a+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new ve(a,u,F.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new pt(a,u,c.marks[f]));if(s&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new F($.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new ve(a+f.index,a+f.index+f[0].length,m))}}a=u}if(!r.validEnd){let l=r.fillBefore($.empty,!0);t.replace(a,a,new F(l,0,0))}for(let l=i.length-1;l>=0;l--)t.step(i[l])}function Ly(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Mr(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,o=0;;--r){let i=t.$from.node(r),a=t.$from.index(r)+s,l=t.$to.indexAfter(r)-o;if(r<t.depth&&i.canReplace(a,l,n))return r;if(r==0||i.type.spec.isolating||!Ly(i,a,l))break;a&&(s=1),l<i.childCount&&(o=1)}return null}function $y(t,e,n){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),a=s.after(o+1),l=i,c=a,u=$.empty,d=0;for(let m=o,y=!1;m>n;m--)y||r.index(m)>0?(y=!0,u=$.from(r.node(m).copy(u)),d++):l--;let f=$.empty,h=0;for(let m=o,y=!1;m>n;m--)y||s.after(m+1)<s.end(m)?(y=!0,f=$.from(s.node(m).copy(f)),h++):c++;t.step(new Oe(l,c,i,a,new F(u.append(f),d,h),u.size-d,!0))}function El(t,e,n=null,r=t){let s=_y(t,e),o=s&&By(r,e);return o?s.map(uu).concat({type:e,attrs:n}).concat(o.map(uu)):null}function uu(t){return{type:t,attrs:null}}function _y(t,e){let{parent:n,startIndex:r,endIndex:s}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return n.canReplaceWith(r,s,i)?o:null}function By(t,e){let{parent:n,startIndex:r,endIndex:s}=t,o=n.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let l=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;l&&c<s;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:i}function zy(t,e,n){let r=$.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let a=n[i].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=$.from(n[i].type.create(n[i].attrs,r))}let s=e.start,o=e.end;t.step(new Oe(s,o,s,o,new F(r,0,0),n.length,!0))}function Fy(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(i,a)=>{let l=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,l)&&Hy(t.doc,t.mapping.slice(o).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&gh(t,i,a,o),Tl(t,t.mapping.slice(o).map(a,1),r,void 0,c===null);let u=t.mapping.slice(o),d=u.map(a,1),f=u.map(a+i.nodeSize,1);return t.step(new Oe(d,f,d+1,f-1,new F($.from(r.create(l,null,i.marks)),0,0),1,!0)),c===!0&&mh(t,i,a,o),!1}})}function mh(t,e,n,r){e.forEach((s,o)=>{if(s.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(s.text);){let l=t.mapping.slice(r).map(n+1+o+i.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function gh(t,e,n,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=t.mapping.slice(r).map(n+1+o);t.replaceWith(i,i+1,e.type.schema.text(`
|
|
5
|
-
`))}})}function Hy(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function Wy(t,e,n,r,s){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let i=n.create(r,null,s||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,i);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Oe(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new F($.from(i),0,0),1,!0))}function Wt(t,e,n=1,r){let s=t.resolve(e),o=s.depth-n,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>o;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),m=r&&r[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let y=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!y.type.validContent(h))return!1}let a=s.indexAfter(o),l=r&&r[0];return s.node(o).canReplaceWith(a,a,l?l.type:s.node(o+1).type)}function Vy(t,e,n=1,r){let s=t.doc.resolve(e),o=$.empty,i=$.empty;for(let a=s.depth,l=s.depth-n,c=n-1;a>l;a--,c--){o=$.from(s.node(a).copy(o));let u=r&&r[c];i=$.from(u?u.type.create(u.attrs,i):s.node(a).copy(i))}t.step(new ve(e,e,new F(o.append(i),n,n),!0))}function pn(t,e){let n=t.resolve(e),r=n.index();return yh(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Uy(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(i),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function yh(t,e){return!!(t&&e&&!t.isLeaf&&Uy(t,e))}function ii(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let o,i,a=r.index(s);if(s==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(s+1),a++,i=r.node(s).maybeChild(a)):(o=r.node(s).maybeChild(a-1),i=r.node(s+1)),o&&!o.isTextblock&&yh(o,i)&&r.node(s).canReplace(a,a+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function qy(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,o=t.doc.resolve(e-n),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let a=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);gh(t,u.node(),u.before(),a)}i.inlineContent&&Tl(t,e+n-1,i,o.node().contentMatchAt(o.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new ve(c,l.map(e+n,-1),F.empty,!0)),r===!0){let u=t.doc.resolve(c);mh(t,u.node(),u.before(),t.steps.length)}return t}function Ky(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,n))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,n))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function Dl(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let o=0;o<n.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let i=r.depth;i>=0;i--){let a=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,l=r.index(i)+(a>0?1:0),c=r.node(i),u=!1;if(o==1)u=c.canReplace(l,l,s);else{let d=c.contentMatchAt(l).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?r.pos:a<0?r.before(i+1):r.after(i+1)}return null}function ai(t,e,n=e,r=F.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),o=t.resolve(n);return xh(s,o,r)?new ve(e,n,r):new Jy(s,o,r).fit()}function xh(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Jy{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=$.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=$.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let o=this.placed,i=r.depth,a=s.depth;for(;i&&a&&o.childCount==1;)o=o.firstChild.content,i--,a--;let l=new F(o,i,a);return e>-1?new Oe(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new ve(r.pos,s.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=Di(this.unplaced.content,r-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(n==1&&(i?c.matchType(i.type)||(d=c.fillBefore($.from(i),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:a,parent:o,inject:d};if(n==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:a,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Di(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new F(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Di(e,n);if(s.childCount<=1&&n>0){let o=e.size-n<=n+s.size;this.unplaced=new F(Lr(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new F(Lr(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let y=0;y<o.length;y++)this.openFrontierNode(o[y]);let i=this.unplaced,a=r?r.content:i.content,l=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(s){for(let y=0;y<s.childCount;y++)u.push(s.child(y));d=d.matchFragment(s)}let h=a.size+e-(i.content.size-i.openEnd);for(;c<a.childCount;){let y=a.child(c),g=d.matchType(y.type);if(!g)break;c++,(c>1||l==0||y.content.size)&&(d=g,u.push(bh(y.mark(f.allowedMarks(y.marks)),c==1?l:0,c==a.childCount?h:-1)))}let m=c==a.childCount;m||(h=-1),this.placed=$r(this.placed,n,$.from(u)),this.frontier[n].match=d,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,g=a;y<h;y++){let x=g.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),g=x.content}this.unplaced=m?e==0?F.empty:new F(Lr(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new F(Lr(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Oi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),i=Oi(e,n,s,r,o);if(i){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=Oi(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:i,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=$r(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=$r(this.placed,this.depth,$.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore($.empty,!0);n.childCount&&(this.placed=$r(this.placed,this.frontier.length,n))}}function Lr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Lr(t.firstChild.content,e-1,n)))}function $r(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy($r(t.lastChild.content,e-1,n)))}function Di(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function bh(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,bh(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore($.empty,!0)))),t.copy(r)}function Oi(t,e,n,r,s){let o=t.node(e),i=s?t.indexAfter(e):t.index(e);if(i==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,i);return a&&!Yy(n,o.content,i)?a:null}function Yy(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Gy(t){return t.spec.defining||t.spec.definingForContent}function Xy(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),o=t.doc.resolve(n);if(xh(s,o,r))return t.step(new ve(e,n,r));let i=kh(s,o);i[i.length-1]==0&&i.pop();let a=-(s.depth+1);i.unshift(a);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let m=s.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(f)>-1?a=f:s.before(f)==h&&i.splice(1,0,-f)}let l=i.indexOf(a),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let m=f.firstChild;if(c.push(m),h==r.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let h=c[f],m=Gy(h.type);if(m&&!h.sameMarkup(s.node(Math.abs(a)-1)))u=f;else if(m||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),m=c[h];if(m)for(let y=0;y<i.length;y++){let g=i[(y+l)%i.length],x=!0;g<0&&(x=!1,g=-g);let b=s.node(g-1),v=s.index(g-1);if(b.canReplaceWith(v,v,m.type,m.marks))return t.replace(s.before(g),x?o.after(g):n,new F(vh(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=i.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=i[f];h<0||(e=s.before(h),n=o.after(h))}}function vh(t,e,n,r,s){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(vh(o.content,e+1,n,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(t).append(t);t=i.append(o.matchFragment(i).fillBefore($.empty,!0))}return t}function Qy(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=Ky(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new F($.from(r),0,0))}function Zy(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let i=r.sharedDepth(n),a=!1;for(let l=r.depth;l>i;l--)r.node(l).type.spec.isolating&&(a=!0);for(let l=s.depth;l>i;l--)s.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=r.depth;l>0&&e==r.start(l);l--)e=r.before(l);for(let l=s.depth;l>0&&n==s.start(l);l--)n=s.before(l);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let o=kh(r,s);for(let i=0;i<o.length;i++){let a=o[i],l=i==o.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return t.delete(r.start(a),s.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),s.indexAfter(a-1))))return t.delete(r.before(a),s.after(a))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(e-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 t.delete(r.before(i),n);t.delete(e,n)}function kh(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let o=t.start(s);if(o<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&n.push(s)}return n}class fr extends Fe{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return ke.fromReplace(e,this.pos,this.pos+1,new F($.from(s),0,n.isLeaf?0:1))}getMap(){return et.empty}invert(e){return new fr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new fr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new fr(n.pos,n.attr,n.value)}}Fe.jsonID("attr",fr);class cs extends Fe{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ke.ok(r)}getMap(){return et.empty}invert(e){return new cs(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new cs(n.attr,n.value)}}Fe.jsonID("docAttr",cs);let mr=class extends Error{};mr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};mr.prototype=Object.create(Error.prototype);mr.prototype.constructor=mr;mr.prototype.name="TransformError";class Sh{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ls}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new mr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((o,i,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=F.empty){let s=ai(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new F($.from(r),0,0))}delete(e,n){return this.replace(e,n,F.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Xy(this,e,n,r),this}replaceRangeWith(e,n,r){return Qy(this,e,n,r),this}deleteRange(e,n){return Zy(this,e,n),this}lift(e,n){return $y(this,e,n),this}join(e,n=1){return qy(this,e,n),this}wrap(e,n){return zy(this,e,n),this}setBlockType(e,n=e,r,s=null){return Fy(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return Wy(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new fr(e,n,r)),this}setDocAttribute(e,n){return this.step(new cs(e,n)),this}addNodeMark(e,n){return this.step(new on(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof le)n.isInSet(r.marks)&&this.step(new Wn(e,n));else{let s=r.marks,o,i=[];for(;o=n.isInSet(s);)i.push(new Wn(e,o)),s=o.removeFromSet(s);for(let a=i.length-1;a>=0;a--)this.step(i[a])}return this}split(e,n=1,r){return Vy(this,e,n,r),this}addMark(e,n,r){return Ry(this,e,n,r),this}removeMark(e,n,r){return Py(this,e,n,r),this}clearIncompatible(e,n,r){return Tl(this,e,n,r),this}}const Ai=Object.create(null);class Y{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new ex(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=F.empty){let r=n.content.lastChild,s=null;for(let a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],u=e.mapping.slice(o);e.replaceRange(u.map(l.pos),u.map(c.pos),a?F.empty:n),a==0&&hu(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:a}=s[o],l=e.mapping.slice(r),c=l.map(i.pos),u=l.map(a.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),hu(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new V(e):sr(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=n<0?sr(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):sr(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(i)return i}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Xe(e.node(0))}static atStart(e){return sr(e,e,0,0,1)||new Xe(e)}static atEnd(e){return sr(e,e,e.content.size,e.childCount,-1)||new Xe(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ai[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ai)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ai[e]=n,n.prototype.jsonID=e,n}getBookmark(){return V.between(this.$anchor,this.$head).getBookmark()}}Y.prototype.visible=!0;class ex{constructor(e,n){this.$from=e,this.$to=n}}let du=!1;function fu(t){!du&&!t.parent.inlineContent&&(du=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class V extends Y{constructor(e,n=e){fu(e),fu(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Y.near(r);let s=e.resolve(n.map(this.anchor));return new V(s.parent.inlineContent?s:r,r)}replace(e,n=F.empty){if(super.replace(e,n),n==F.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof V&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new li(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new V(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let o=Y.findFrom(n,r,!0)||Y.findFrom(n,-r,!0);if(o)n=o.$head;else return Y.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Y.findFrom(e,-r,!0)||Y.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new V(e,n)}}Y.jsonID("text",V);class li{constructor(e,n){this.anchor=e,this.head=n}map(e){return new li(e.map(this.anchor),e.map(this.head))}resolve(e){return V.between(e.resolve(this.anchor),e.resolve(this.head))}}class H extends Y{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),o=e.resolve(s);return r?Y.near(o):new H(o)}content(){return new F($.from(this.node),0,0)}eq(e){return e instanceof H&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ol(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new H(e.resolve(n.anchor))}static create(e,n){return new H(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}H.prototype.visible=!1;Y.jsonID("node",H);class Ol{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new li(r,r):new Ol(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&H.isSelectable(r)?new H(n):Y.near(n)}}class Xe extends Y{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=F.empty){if(n==F.empty){e.delete(0,e.doc.content.size);let r=Y.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Xe(e)}map(e){return new Xe(e)}eq(e){return e instanceof Xe}getBookmark(){return tx}}Y.jsonID("all",Xe);const tx={map(){return this},resolve(t){return new Xe(t)}};function sr(t,e,n,r,s,o=!1){if(e.inlineContent)return V.create(t,n);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let a=e.child(i);if(a.isAtom){if(!o&&H.isSelectable(a))return H.create(t,n-(s<0?a.nodeSize:0))}else{let l=sr(t,a,n+s,s<0?a.childCount:0,s,o);if(l)return l}n+=a.nodeSize*s}return null}function hu(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof ve||s instanceof Oe))return;let o=t.mapping.maps[r],i;o.forEach((a,l,c,u)=>{i==null&&(i=u)}),t.setSelection(Y.near(t.doc.resolve(i),n))}const pu=1,zs=2,mu=4;class nx extends Sh{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 new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|pu)&~zs,this.storedMarks=null,this}get selectionSet(){return(this.updated&pu)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=zs,this}ensureMarks(e){return le.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(this.updated&zs)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~zs,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||le.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(n);o=r==n?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Y.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=mu,this}get scrolledIntoView(){return(this.updated&mu)>0}}function gu(t,e){return!e||!t?t:t.bind(e)}class _r{constructor(e,n,r){this.name=e,this.init=gu(n.init,r),this.apply=gu(n.apply,r)}}const rx=[new _r("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new _r("selection",{init(t,e){return t.selection||Y.atStart(e.doc)},apply(t){return t.selection}}),new _r("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new _r("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Ii{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=rx.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new _r(r.key,r.spec.state,r))})}}class Cn{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,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let a=this.config.plugins[i];if(a.spec.appendTransaction){let l=s?s[i].n:0,c=s?s[i].state:this,u=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<i?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}s&&(s[i]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Cn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new nx(this)}static create(e){let n=new Ii(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Cn(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Ii(this.schema,e.plugins),r=n.fields,s=new Cn(n);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],o=s.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Ii(e.schema,e.plugins),o=new Cn(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=On.fromJSON(e.schema,n.doc);else if(i.name=="selection")o.selection=Y.fromJSON(o.doc,n.selection);else if(i.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){o[i.name]=c.fromJSON.call(l,e,n[a],o);return}}o[i.name]=i.init(e,o)}}),o}}function Ch(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ch(s,e,{})),n[r]=s}return n}class pe{constructor(e){this.spec=e,this.props={},e.props&&Ch(e.props,this,this.props),this.key=e.key?e.key.key:wh("plugin")}getState(e){return e[this.key]}}const ji=Object.create(null);function wh(t){return t in ji?t+"$"+ ++ji[t]:(ji[t]=0,t+"$")}class Ce{constructor(e="key"){this.key=wh(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Nh=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Mh(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Th=(t,e,n)=>{let r=Mh(t,n);if(!r)return!1;let s=Al(r);if(!s){let i=r.blockRange(),a=i&&Mr(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)}let o=s.nodeBefore;if(Lh(t,s,e,-1))return!0;if(r.parent.content.size==0&&(gr(o,"end")||H.isSelectable(o)))for(let i=r.depth;;i--){let a=ai(t.doc,r.before(i),r.after(i),F.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(gr(o,"end")?Y.findFrom(l.doc.resolve(l.mapping.map(s.pos,-1)),-1):H.create(l.doc,s.pos-o.nodeSize)),e(l.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return o.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},sx=(t,e,n)=>{let r=Mh(t,n);if(!r)return!1;let s=Al(r);return s?Eh(t,s,e):!1},ox=(t,e,n)=>{let r=Oh(t,n);if(!r)return!1;let s=Il(r);return s?Eh(t,s,e):!1};function Eh(t,e,n){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let i=e.nodeAfter,a=i,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=ai(t.doc,o,l,F.empty);if(!c||c.from!=o||c instanceof ve&&c.slice.size>=l-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(V.create(u.doc,o)),n(u.scrollIntoView())}return!0}function gr(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Dh=(t,e,n)=>{let{$head:r,empty:s}=t.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Al(r)}let i=o&&o.nodeBefore;return!i||!H.isSelectable(i)?!1:(e&&e(t.tr.setSelection(H.create(t.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function Al(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Oh(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Ah=(t,e,n)=>{let r=Oh(t,n);if(!r)return!1;let s=Il(r);if(!s)return!1;let o=s.nodeAfter;if(Lh(t,s,e,1))return!0;if(r.parent.content.size==0&&(gr(o,"start")||H.isSelectable(o))){let i=ai(t.doc,r.before(),r.after(),F.empty);if(i&&i.slice.size<i.to-i.from){if(e){let a=t.tr.step(i);a.setSelection(gr(o,"start")?Y.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):H.create(a.doc,a.mapping.map(s.pos))),e(a.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},Ih=(t,e,n)=>{let{$head:r,empty:s}=t.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=Il(r)}let i=o&&o.nodeAfter;return!i||!H.isSelectable(i)?!1:(e&&e(t.tr.setSelection(H.create(t.doc,o.pos)).scrollIntoView()),!0)};function Il(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const ix=(t,e)=>{let n=t.selection,r=n instanceof H,s;if(r){if(n.node.isTextblock||!pn(t.doc,n.from))return!1;s=n.from}else if(s=ii(t.doc,n.from,-1),s==null)return!1;if(e){let o=t.tr.join(s);r&&o.setSelection(H.create(o.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},ax=(t,e)=>{let n=t.selection,r;if(n instanceof H){if(n.node.isTextblock||!pn(t.doc,n.to))return!1;r=n.to}else if(r=ii(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},lx=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),o=s&&Mr(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)},jh=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
6
|
-
`).scrollIntoView()),!0)};function jl(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const cx=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),o=n.indexAfter(-1),i=jl(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,i.createAndFill());l.setSelection(Y.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Rh=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof Xe||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=jl(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=t.tr.insert(i,o.createAndFill());a.setSelection(V.create(a.doc,i+1)),e(a.scrollIntoView())}return!0},Ph=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Wt(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Mr(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function ux(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof H&&e.selection.node.isBlock)return!r.parentOffset||!Wt(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],i,a,l=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),a=jl(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),o.unshift(l&&a?{type:a}:null),i=h;break}else{if(h==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof V||e.selection instanceof Xe)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Wt(u.doc,d,o.length,o);if(f||(o[0]=a?{type:a}:null,f=Wt(u.doc,d,o.length,o)),!f)return!1;if(u.split(d,o.length,o),!l&&c&&r.node(i).type!=a){let h=u.mapping.map(r.before(i)),m=u.doc.resolve(h);a&&r.node(i-1).canReplaceWith(m.index(),m.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(i)),a)}return n&&n(u.scrollIntoView()),!0}}const dx=ux(),fx=(t,e)=>{let{$from:n,to:r}=t.selection,s,o=n.sharedDepth(r);return o==0?!1:(s=n.before(o),e&&e(t.tr.setSelection(H.create(t.doc,s))),!0)};function hx(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,o=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||pn(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Lh(t,e,n,r){let s=e.nodeBefore,o=e.nodeAfter,i,a,l=s.type.spec.isolating||o.type.spec.isolating;if(!l&&hx(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(a=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&a.matchType(i[0]||o.type).validEnd){if(n){let h=e.pos+o.nodeSize,m=$.empty;for(let x=i.length-1;x>=0;x--)m=$.from(i[x].create(null,m));m=$.from(s.copy(m));let y=t.tr.step(new Oe(e.pos-1,h,e.pos,h,new F(m,1,0),i.length,!0)),g=y.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==s.type&&pn(y.doc,g.pos)&&y.join(g.pos),n(y.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&l?null:Y.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Mr(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&gr(o,"start",!0)&&gr(s,"end")){let h=s,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let y=o,g=1;for(;!y.isTextblock;y=y.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,y.content)){if(n){let x=$.empty;for(let v=m.length-1;v>=0;v--)x=$.from(m[v].copy(x));let b=t.tr.step(new Oe(e.pos-m.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new F(x,m.length,0),0,!0));n(b.scrollIntoView())}return!0}}return!1}function $h(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(n&&n(e.tr.setSelection(V.create(e.doc,t<0?s.start(o):s.end(o)))),!0):!1}}const px=$h(-1),mx=$h(1);function gx(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o),a=i&&El(i,t,e);return a?(r&&r(n.tr.wrap(i,a).scrollIntoView()),!0):!1}}function yu(t,e=null){return function(n,r){let s=!1;for(let o=0;o<n.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:a}}=n.selection.ranges[o];n.doc.nodesBetween(i,a,(l,c)=>{if(s)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let o=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[i];o.setBlockType(a,l,t,e)}r(o.scrollIntoView())}return!0}}function Rl(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Rl(Nh,Th,Dh);Rl(Nh,Ah,Ih);Rl(jh,Rh,Ph,dx);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function yx(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o);if(!i)return!1;let a=r?n.tr:null;return xx(a,i,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function xx(t,e,n,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=i.resolve(e.start-2);o=new lo(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new lo(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let a=El(o,n,r,e);return a?(t&&bx(t,e,a,s,n),!0):!1}function bx(t,e,n,r,s){let o=$.empty;for(let u=n.length-1;u>=0;u--)o=$.from(n[u].type.create(n[u].attrs,o));t.step(new Oe(e.start-(r?2:0),e.end,e.start,e.end,new F(o,0,0),n.length,!0));let i=0;for(let u=0;u<n.length;u++)n[u].type==s&&(i=u+1);let a=n.length-i,l=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&Wt(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(u).nodeSize;return t}function vx(t){return function(e,n){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?kx(e,n,t,o):Sx(e,n,o):!0:!1}}function kx(t,e,n,r){let s=t.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new Oe(o-1,i,o,i,new F($.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new lo(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const a=Mr(r);if(a==null)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(o,-1)-1);return pn(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos),e(s.scrollIntoView()),!0}function Sx(t,e,n){let r=t.tr,s=n.parent;for(let h=n.end,m=n.endIndex-1,y=n.startIndex;m>y;m--)h-=s.child(m).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(n.start),i=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,i.content.append(l?$.empty:$.from(s))))return!1;let d=o.pos,f=d+i.nodeSize;return r.step(new Oe(d-(a?1:0),f+(l?1:0),d+1,f-1,new F((a?$.empty:$.from(s.copy($.empty))).append(l?$.empty:$.from(s.copy($.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function Cx(t){return function(e,n){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let a=o.parent,l=a.child(i-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=$.from(c?t.create():null),d=new F($.from(t.create(null,$.from(a.type.create(null,u)))),c?3:1,0),f=o.start,h=o.end;n(e.tr.step(new Oe(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const je=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},yr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Ca=null;const Bt=function(t,e,n){let r=Ca||(Ca=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},wx=function(){Ca=null},Vn=function(t,e,n,r){return n&&(xu(t,e,n,r,-1)||xu(t,e,n,r,1))},Nx=/^(img|br|input|textarea|hr)$/i;function xu(t,e,n,r,s){for(var o;;){if(t==n&&e==r)return!0;if(e==(s<0?0:at(t))){let i=t.parentNode;if(!i||i.nodeType!=1||ks(t)||Nx.test(t.nodeName)||t.contentEditable=="false")return!1;e=je(t)+(s<0?0:1),t=i}else if(t.nodeType==1){let i=t.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else t=i,e=s<0?at(t):0}else return!1}}function at(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Mx(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=at(t)}else if(t.parentNode&&!ks(t))e=je(t),t=t.parentNode;else return null}}function Tx(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!ks(t))e=je(t)+1,t=t.parentNode;else return null}}function Ex(t,e,n){for(let r=e==0,s=e==at(t);r||s;){if(t==n)return!0;let o=je(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,s=s&&o==at(t)}}function ks(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const ci=function(t){return t.focusNode&&Vn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function kn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Dx(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ox(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(at(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(at(r.startContainer),r.startOffset)}}}const Dt=typeof navigator<"u"?navigator:null,bu=typeof document<"u"?document:null,mn=Dt&&Dt.userAgent||"",wa=/Edge\/(\d+)/.exec(mn),_h=/MSIE \d/.exec(mn),Na=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mn),Qe=!!(_h||Na||wa),ln=_h?document.documentMode:Na?+Na[1]:wa?+wa[1]:0,lt=!Qe&&/gecko\/(\d+)/i.test(mn);lt&&+(/Firefox\/(\d+)/.exec(mn)||[0,0])[1];const Ma=!Qe&&/Chrome\/(\d+)/.exec(mn),Pe=!!Ma,Bh=Ma?+Ma[1]:0,ze=!Qe&&!!Dt&&/Apple Computer/.test(Dt.vendor),xr=ze&&(/Mobile\/\w+/.test(mn)||!!Dt&&Dt.maxTouchPoints>2),ot=xr||(Dt?/Mac/.test(Dt.platform):!1),zh=Dt?/Win/.test(Dt.platform):!1,zt=/Android \d/.test(mn),Ss=!!bu&&"webkitFontSmoothing"in bu.documentElement.style,Ax=Ss?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ix(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function jt(t,e){return typeof t=="number"?t:t[e]}function jx(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function vu(t,e,n){if(!Ta(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let i=n||t.dom;i;){if(i.nodeType!=1){i=yr(i);continue}let a=i,l=a==o.body,c=l?Ix(o):jx(a),u=0,d=0;if(e.top<c.top+jt(r,"top")?d=-(c.top-e.top+jt(s,"top")):e.bottom>c.bottom-jt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+jt(s,"top")-c.top:e.bottom-c.bottom+jt(s,"bottom")),e.left<c.left+jt(r,"left")?u=-(c.left-e.left+jt(s,"left")):e.right>c.right-jt(r,"right")&&(u=e.right-c.right+jt(s,"right")),u||d)if(l)o.defaultView.scrollBy(u,d);else{let h=a.scrollLeft,m=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let y=a.scrollLeft-h,g=a.scrollTop-m;e={left:e.left-y,top:e.top-g,right:e.right-y,bottom:e.bottom-g}}let f=l?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:yr(i)}}function Rx(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=n+1;i<Math.min(innerHeight,e.bottom);i+=5){let a=t.root.elementFromPoint(o,i);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,s=l.top;break}}return{refDOM:r,refTop:s,stack:Fh(t.dom)}}function Fh(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=yr(r));return e}function Px({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Hh(n,r==0?0:r-e)}function Hh(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:o}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let Zn=null;function Lx(t){if(t.setActive)return t.setActive();if(Zn)return t.focus(Zn);let e=Fh(t);t.focus(Zn==null?{get preventScroll(){return Zn={preventScroll:!0},!0}}:void 0),Zn||(Zn=!1,Hh(e,0))}function Wh(t,e){let n,r=2e8,s,o=0,i=e.top,a=e.top,l,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=Bt(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let m=f[h];if(m.top<=i&&m.bottom>=a){i=Math.max(m.bottom,i),a=Math.min(m.top,a);let y=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(y<r){n=u,r=y,s=y&&n.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&y&&(o=d+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!l&&m.left<=e.left&&m.right>=e.left&&(l=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!n&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=d+1)}}return!n&&l&&(n=l,s=c,r=0),n&&n.nodeType==3?$x(n,s):!n||r&&n.nodeType==1?{node:t,offset:o}:Wh(n,s)}function $x(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let i=Qt(r,1);if(i.top!=i.bottom&&Pl(e,i)){s={node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Pl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function _x(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Bx(t,e,n){let{node:r,offset:s}=Wh(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return t.docView.posFromDOM(r,s,o)}function zx(t,e,n,r){let s=-1;for(let o=e,i=!1;o!=t.dom;){let a=t.docView.nearestDesc(o,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!i&&l.left>r.left||l.top>r.top?s=a.posBefore:(!i&&l.right<r.left||l.bottom<r.top)&&(s=a.posAfter),i=!0),!a.contentDOM&&s<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;o=a.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function Vh(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=s;;){let i=t.childNodes[o];if(i.nodeType==1){let a=i.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Pl(e,c))return Vh(i,e,c)}}if((o=(o+1)%r)==s)break}return t}function Fx(t,e){let n=t.dom.ownerDocument,r,s=0,o=Ox(n,e.left,e.top);o&&({node:r,offset:s}=o);let i=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a;if(!i||!t.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=t.dom.getBoundingClientRect();if(!Pl(e,c)||(i=Vh(t.dom,e,c),!i))return null}if(ze)for(let c=i;r&&c;c=yr(c))c.draggable&&(r=void 0);if(i=_x(i,e),r){if(lt&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;Ss&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(a=zx(t,r,s,e))}a==null&&(a=Bx(t,i,e));let l=t.docView.nearestDesc(i,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Ta(t){return t.top<t.bottom||t.left<t.right}function Qt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Ta(r))return r}return Array.prototype.find.call(n,Ta)||t.getBoundingClientRect()}const Hx=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Uh(t,e,n){let{node:r,offset:s,atom:o}=t.docView.domFromPos(e,n<0?-1:1),i=Ss||lt;if(r.nodeType==3)if(i&&(Hx.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let l=Qt(Bt(r,s,s),n);if(lt&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Qt(Bt(r,s-1,s-1),-1);if(c.top==l.top){let u=Qt(Bt(r,s,s+1),-1);if(u.top!=l.top)return Dr(u,u.left<c.left)}}return l}else{let l=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(l--,u=1):n<0?l--:c++,Dr(Qt(Bt(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(n<0||s==at(r))){let l=r.childNodes[s-1];if(l.nodeType==1)return Ri(l.getBoundingClientRect(),!1)}if(o==null&&s<at(r)){let l=r.childNodes[s];if(l.nodeType==1)return Ri(l.getBoundingClientRect(),!0)}return Ri(r.getBoundingClientRect(),n>=0)}if(o==null&&s&&(n<0||s==at(r))){let l=r.childNodes[s-1],c=l.nodeType==3?Bt(l,at(l)-(i?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Dr(Qt(c,1),!1)}if(o==null&&s<at(r)){let l=r.childNodes[s];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Bt(l,0,i?0:1):l.nodeType==1?l:null:null;if(c)return Dr(Qt(c,-1),!0)}return Dr(Qt(r.nodeType==3?Bt(r):r,-n),n>=0)}function Dr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Ri(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function qh(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function Wx(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return qh(t,e,()=>{let{node:o}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let i=Uh(t,s.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Bt(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const Vx=/[\u0590-\u08ac]/;function Ux(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,a=t.domSelection();return a?!Vx.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?o:i:qh(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:m,focusOffset:y}=t.domSelectionRange(),g=m&&!h.contains(m.nodeType==1?m:m.parentNode)||l==m&&c==y;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return f!=null&&(a.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let ku=null,Su=null,Cu=!1;function qx(t,e,n){return ku==e&&Su==n?Cu:(ku=e,Su=n,Cu=n=="up"||n=="down"?Wx(t,e,n):Ux(t,e,n))}const ct=0,wu=1,wn=2,mt=3;class Cs{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=ct,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].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 n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.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,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,i;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>je(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!n||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],o=r+s.size;if(r==e&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let a=s.children[i];if(a.size){s=a;break}}return s}if(e<o)return s.descAt(e-r-s.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],a=o+i.size;if(a>e||i instanceof Jh){s=e-o;break}o=a}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Kh&&o.side>=0;r--);if(n<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&n&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?je(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?je(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,a=0;;a++){let l=this.children[a],c=i+l.size;if(s==-1&&e<=c){let u=i+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=i;for(let d=a;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=je(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>n||a==this.children.length-1)){n=c;for(let u=a+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=je(d.dom);break}n+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let o=Math.min(e,n),i=Math.max(e,n);for(let h=0,m=0;h<this.children.length;h++){let y=this.children[h],g=m+y.size;if(o>m&&i<g)return y.setSelection(e-m-y.border,n-m-y.border,r,s);m=g}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((lt||ze)&&e==n){let{node:h,offset:m}=a;if(h.nodeType==3){if(d=!!(m&&h.nodeValue[m-1]==`
|
|
7
|
-
`),d&&m==h.nodeValue.length)for(let y=h,g;y;y=y.parentNode){if(g=y.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:je(g)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=h.childNodes[m-1];d=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(lt&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&ze)&&Vn(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Vn(l.node,l.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&<)){c.collapse(a.node,a.offset);try{e!=n&&c.extend(l.node,l.offset),f=!0}catch{}}if(!f){if(e>n){let m=a;a=l,l=m}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?e<=i&&n>=r:e<i&&n>r){let a=r+o.border,l=i-o.border;if(e>=a&&n<=l){this.dirty=e==r||n==i?wn:wu,e==a&&n==l&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=mt:o.markDirty(e-a,n-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?wn:mt}r=i}this.dirty=wn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?wn:wu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Kh extends Cs{constructor(e,n,r,s){let o,i=n.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(i.nodeType!=1){let a=document.createElement("span");a.appendChild(i),i=a}i.hasAttribute("contenteditable")||(i.contentEditable="false"),i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==ct&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||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 Kx extends Cs{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class cn extends Cs{constructor(e,n,r,s,o){super(e,[],r,s),this.mark=n,this.spec=o}static create(e,n,r,s){let o=s.nodeViews[n.type.name],i=o&&o(n,s,r);return(!i||!i.dom)&&(i=qt.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new cn(e,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&mt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=mt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ct){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ct}}slice(e,n,r){let s=cn.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;n<i&&(o=Da(o,n,i,r)),e>0&&(o=Da(o,0,e,r));for(let a=0;a<o.length;a++)o[a].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class un extends Cs{constructor(e,n,r,s,o,i,a){super(e,[],o,i),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=a}static create(e,n,r,s,o,i){let a=o.nodeViews[n.type.name],l,c=a&&a(n,o,()=>{if(!l)return i;if(l.parent)return l.parent.posBeforeChild(l)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=qt.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Xh(u,r,n),c?l=new Jx(e,n,r,s,u,d||null,f,c):n.isText?new ui(e,n,r,s,u,f):new un(e,n,r,s,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let s=this.children[r];if(this.dom.contains(s.dom.parentNode)){n.contentElement=s.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(s=>s.nodeType==1&&e.indexOf(s.parentNode)<0&&this.dom.contains(s));r?n.contentElement=r:n.getContent=()=>$.empty}}return n}matchesNode(e,n,r){return this.dirty==ct&&e.eq(this.node)&&uo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,o=e.composing?this.localCompositionInfo(e,n):null,i=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new Gx(this,i&&i.node,e);Zx(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?le.none:this.node.child(u).marks,r,e,u),l.placeWidget(c,e,s)},(c,u,d,f)=>{l.syncToMarks(c.marks,r,e,f);let h;l.findNodeMatch(c,u,d,f)||a&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(c,u,d,h,e)||l.updateNextNode(c,u,d,e,f,s)||l.addNode(c,u,d,e,s),s+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==wn)&&(i&&this.protectLocalComposition(e,i),Yh(this.contentDOM,this.children,e),xr&&eb(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof V)||r<n||s>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,a=tb(this.node.content,i,r-n,s-n);return a<0?null:{node:o,pos:a,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Kx(this,o,n,s);e.input.compositionNodes.push(i),this.children=Da(this.children,r,r+s.length,e,i)}update(e,n,r,s){return this.dirty==mt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=ct}updateOuterDeco(e){if(uo(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Gh(this.dom,this.nodeDOM,Ea(this.outerDeco,this.node,n),Ea(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Nu(t,e,n,r,s){Xh(r,e,t);let o=new un(void 0,t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(s,0),o}class ui extends un{constructor(e,n,r,s,o,i){super(e,n,r,s,o,null,i)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==mt||this.dirty!=ct&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ct||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=ct,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),o=document.createTextNode(s.text);return new ui(this.parent,s,this.outerDeco,this.innerDeco,o,o)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=mt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Jh extends Cs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ct&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Jx extends un{constructor(e,n,r,s,o,i,a,l){super(e,n,r,s,o,i,a),this.spec=l}update(e,n,r,s){if(this.dirty==mt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Yh(t,e,n){let r=t.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],a=i.dom;if(a.parentNode==t){for(;a!=r;)r=Mu(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(a,r);if(i instanceof cn){let l=r?r.previousSibling:t.lastChild;Yh(i.contentDOM,i.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=Mu(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Ur=function(t){t&&(this.nodeName=t)};Ur.prototype=Object.create(null);const Nn=[new Ur];function Ea(t,e,n){if(t.length==0)return Nn;let r=n?Nn[0]:new Ur,s=[r];for(let o=0;o<t.length;o++){let i=t[o].type.attrs;if(i){i.nodeName&&s.push(r=new Ur(i.nodeName));for(let a in i){let l=i[a];l!=null&&(n&&s.length==1&&s.push(r=new Ur(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return s}function Gh(t,e,n,r){if(n==Nn&&r==Nn)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],a=n[o];if(o){let l;a&&a.nodeName==i.nodeName&&s!=t&&(l=s.parentNode)&&l.nodeName.toLowerCase()==i.nodeName||(l=document.createElement(i.nodeName),l.pmIsDeco=!0,l.appendChild(s),a=Nn[0]),s=l}Yx(s,a||Nn[0],i)}return s}function Yx(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&t.classList.add(s[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function Xh(t,e,n){return Gh(t,t,Nn,Ea(e,n,t.nodeType!=1))}function uo(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Mu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Gx{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Xx(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let o=0,i=this.stack.length>>1,a=Math.min(i,e.length);for(;o<a&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=ct,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[i])&&!this.isLocked(d.dom)){l=u;break}}if(l<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof cn&&u.dirty!=mt&&u.mark.type==e[i].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[i])&&(u.mark=e[i],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=cn.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,n,r))o=this.top.children.indexOf(i,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){o=a;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,s,o){let i=this.top.children[s];return i.dirty==mt&&i.dom==i.contentDOM&&(i.dirty=wn),i.update(e,n,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,o,i){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof un){let c=this.preMatch.matched.get(l);if(c!=null&&c!=o)return!1;let u=l.dom,d,f=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=mt&&uo(n,l.outerDeco));if(!f&&l.update(e,n,r,s))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(l,e,n,r,s,i)))return this.destroyBetween(this.index,a),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=wn,d.updateChildren(s,i+1),d.dirty=ct),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,o,i){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!uo(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let a=un.create(this.top,n,r,s,o,i);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,n,r,s,o){let i=un.create(this.top,e,n,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new Kh(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof cn;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ui)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ze||Pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Jh(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Xx(t,e){let n=e,r=n.children.length,s=t.childCount,o=new Map,i=[];e:for(;s>0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof cn)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(s-1))break;--s,o.set(a,s),i.push(a)}}return{index:s,matched:o,matches:i.reverse()}}function Qx(t,e){return t.type.side-e.type.side}function Zx(t,e,n,r){let s=e.locals(t),o=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(o,u),c),o+=u.nodeSize}return}let i=0,a=[],l=null;for(let c=0;;){let u,d;for(;i<s.length&&s[i].to==o;){let g=s[i++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(Qx);for(let g=0;g<d.length;g++)n(d[g],c,!!l)}else n(u,c,!!l);let f,h;if(l)h=-1,f=l,l=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=o&&a.splice(g--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)a.push(s[i++]);let m=o+f.nodeSize;if(f.isText){let g=m;i<s.length&&s[i].from<g&&(g=s[i].from);for(let x=0;x<a.length;x++)a[x].to<g&&(g=a[x].to);g<m&&(l=f.cut(g-o),f=f.cut(0,g-o),m=g,h=-1)}else for(;i<s.length&&s[i].to<m;)i++;let y=f.isInline&&!f.isLeaf?a.filter(g=>!g.inline):a.slice();r(f,y,e.forChild(o,f),h),o=m}}function eb(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function tb(t,e,n,r){for(let s=0,o=0;s<t.childCount&&o<=r;){let i=t.child(s++),a=o;if(o+=i.nodeSize,!i.isText)continue;let l=i.text;for(;s<t.childCount;){let c=t.child(s++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=n){if(o>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Da(t,e,n,r,s){let o=[];for(let i=0,a=0;i<t.length;i++){let l=t[i],c=a,u=a+=l.size;c>=n||u<=e?o.push(l):(c<e&&o.push(l.slice(0,e-c,r)),s&&(o.push(s),s=void 0),u>n&&o.push(l.slice(n-c,l.size,r)))}return o}function Ll(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),o=s&&s.size==0,i=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let a=r.resolve(i),l,c;if(ci(n)){for(l=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&H.isSelectable(d)&&s.parent&&!(d.isInline&&Ex(n.focusNode,n.focusOffset,s.dom))){let f=s.posBefore;c=new H(i==f?a:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,f=i;for(let h=0;h<n.rangeCount;h++){let m=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[l,i]=f==t.state.selection.anchor?[f,d]:[d,f],a=r.resolve(i)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let d=e=="pointer"||t.state.selection.head<a.pos&&!o?1:-1;c=$l(t,u,a,d)}return c}function Qh(t){return t.editable?t.hasFocus():ep(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Vt(t,e=!1){let n=t.state.selection;if(Zh(t,n),!Qh(t))return;let r=t.input.mouseDown;if(!e&&Pe&&r){let s=t.domSelectionRange(),o=t.domObserver.currentSelection;if(s.anchorNode&&o.anchorNode&&Vn(s.anchorNode,s.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)rb(t);else{let{anchor:s,head:o}=n,i,a;Tu&&!(n instanceof V)&&(n.$from.parent.inlineContent||(i=Eu(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=Eu(t,n.to))),t.docView.setSelection(s,o,t,e),Tu&&(i&&Du(i),a&&Du(a)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&nb(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Tu=ze||Pe&&Bh<63;function Eu(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(ze&&s&&s.contentEditable=="false")return Pi(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Pi(s);if(o)return Pi(o)}}function Pi(t){return t.contentEditable="true",ze&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Du(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function nb(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Qh(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function rb(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,je(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Qe&&ln<=11&&(n.disabled=!0,n.disabled=!1)}function Zh(t,e){if(e instanceof H){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Ou(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Ou(t)}function Ou(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function $l(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||V.between(e,n,r)}function Au(t){return t.editable&&!t.hasFocus()?!1:ep(t)}function ep(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function sb(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Vn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Oa(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return o&&Y.findFrom(o,e)}function en(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Iu(t,e,n){let r=t.state.selection;if(r instanceof V)if(n.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=t.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return en(t,new V(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Oa(t.state,e);return s&&s instanceof H?en(t,s):!1}else if(!(ot&&n.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let a=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=t.docView.descAt(a))&&!i.contentDOM?H.isSelectable(o)?en(t,new H(e<0?t.state.doc.resolve(s.pos-o.nodeSize):s)):Ss?en(t,new V(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof H&&r.node.isInline)return en(t,new V(e>0?r.$to:r.$from));{let s=Oa(t.state,e);return s?en(t,s):!1}}}function fo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function qr(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function er(t,e){return e<0?ob(t):ib(t)}function ob(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,o,i=!1;for(lt&&n.nodeType==1&&r<fo(n)&&qr(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(qr(a,-1))s=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(tp(n))break;{let a=n.previousSibling;for(;a&&qr(a,-1);)s=n.parentNode,o=je(a),a=a.previousSibling;if(a)n=a,r=fo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?Aa(t,n,r):s&&Aa(t,s,o)}function ib(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=fo(n),o,i;for(;;)if(r<s){if(n.nodeType!=1)break;let a=n.childNodes[r];if(qr(a,1))o=n,i=++r;else break}else{if(tp(n))break;{let a=n.nextSibling;for(;a&&qr(a,1);)o=a.parentNode,i=je(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=fo(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}o&&Aa(t,o,i)}function tp(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function ab(t,e){for(;t&&e==t.childNodes.length&&!ks(t);)e=je(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function lb(t,e){for(;t&&!e&&!ks(t);)e=je(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Aa(t,e,n){if(e.nodeType!=3){let o,i;(i=ab(e,n))?(e=i,n=0):(o=lb(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(ci(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Vt(t)},50)}function ju(t,e){let n=t.state.doc.resolve(e);if(!(Pe||zh)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Ru(t,e,n){let r=t.state.selection;if(r instanceof V&&!r.empty||n.indexOf("s")>-1||ot&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=Oa(t.state,e);if(i&&i instanceof H)return en(t,i)}if(!s.parent.inlineContent){let i=e<0?s:o,a=r instanceof Xe?Y.near(i,e):Y.findFrom(i,e);return a?en(t,a):!1}return!1}function Pu(t,e){if(!(t.state.selection instanceof V))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=t.state.tr;return e<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),t.dispatch(i),!0}return!1}function Lu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function cb(t){if(!ze||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Lu(t,r,"true"),setTimeout(()=>Lu(t,r,"false"),20)}return!1}function ub(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function db(t,e){let n=e.keyCode,r=ub(e);if(n==8||ot&&n==72&&r=="c")return Pu(t,-1)||er(t,-1);if(n==46&&!e.shiftKey||ot&&n==68&&r=="c")return Pu(t,1)||er(t,1);if(n==13||n==27)return!0;if(n==37||ot&&n==66&&r=="c"){let s=n==37?ju(t,t.state.selection.from)=="ltr"?-1:1:-1;return Iu(t,s,r)||er(t,s)}else if(n==39||ot&&n==70&&r=="c"){let s=n==39?ju(t,t.state.selection.from)=="ltr"?1:-1:1;return Iu(t,s,r)||er(t,s)}else{if(n==38||ot&&n==80&&r=="c")return Ru(t,-1,r)||er(t,-1);if(n==40||ot&&n==78&&r=="c")return cb(t)||Ru(t,1,r)||er(t,1);if(r==(ot?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function _l(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=t.someProp("clipboardSerializer")||qt.fromSchema(t.state.schema),a=ap(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=ip[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=a.createElement(u[h]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
8
|
-
|
|
9
|
-
`);return{dom:l,text:f,slice:e}}function np(t,e,n,r,s){let o=s.parent.type.spec.code,i,a;if(!n&&!e)return null;let l=!!e&&(r||o||!n);if(l){if(t.someProp("transformPastedText",f=>{e=f(e,o||r,t)}),o)return a=new F($.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
10
|
-
`))),0,0),t.someProp("transformPasted",f=>{a=f(a,t,!0)}),a;let d=t.someProp("clipboardTextParser",f=>f(e,s,r,t));if(d)a=d;else{let f=s.marks(),{schema:h}=t.state,m=qt.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let g=i.appendChild(document.createElement("p"));y&&g.appendChild(m.serializeNode(h.text(y,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=mb(n),Ss&&gb(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||Et.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!fb.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=yb($u(a,+u[1],+u[2]),u[4]);else if(a=F.maxOpen(hb(a.content,s),!0),a.openStart||a.openEnd){let d=0,f=0;for(let h=a.content.firstChild;d<a.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=a.content.lastChild;f<a.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);a=$u(a,d,f)}return t.someProp("transformPasted",d=>{a=d(a,t,l)}),a}const fb=/^(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 hb(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),o,i=[];if(t.forEach(a=>{if(!i)return;let l=s.findWrapping(a.type),c;if(!l)return i=null;if(c=i.length&&o.length&&sp(l,o,a,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=op(i[i.length-1],o.length));let u=rp(a,l);i.push(u),s=s.matchType(u.type),o=l}}),i)return $.from(i)}return t}function rp(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,$.from(t));return t}function sp(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let o=sp(t,e,n,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append($.from(rp(n,t,s+1))))}}function op(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,op(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore($.empty,!0);return t.copy(n.append(r))}function Ia(t,e,n,r,s,o){let i=e<0?t.firstChild:t.lastChild,a=i.content;return t.childCount>1&&(o=0),s<r-1&&(a=Ia(a,e,n,r,s+1,o)),s>=n&&(a=e<0?i.contentMatchAt(0).fillBefore(a,o<=s).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore($.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(a))}function $u(t,e,n){return e<t.openStart&&(t=new F(Ia(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new F(Ia(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const ip={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function ap(){return document.implementation.createHTMLDocument("title")}let Or=null;function pb(t){let e=window.trustedTypes;if(!e)return t;if(!Or){if(Or=e.defaultPolicy)try{return Or.createHTML(t)}catch{}Or=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Or.createHTML(t)}function mb(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=ap(),r=n.body,s=/<([a-z][^>\s]+)/i.exec(t),o;if((o=s&&ip[s[1].toLowerCase()])&&(t=o.map(i=>"<"+i+">").join("")+t+o.map(i=>"</"+i+">").reverse().join("")),r.innerHTML=pb(t),o)for(let i=0;i<o.length;i++)r=r.querySelector(o[i])||r;for(let i=0;i<n.styleSheets.length;i++){let a=n.styleSheets[i];for(let l=0;l<a.rules.length;l++){let c=a.rules[l];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function gb(t){let e=t.querySelectorAll(Pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function yb(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:o,openEnd:i}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;try{l.checkAttrs(r[a+1])}catch{break}s=$.from(l.create(r[a+1],s)),o++,i++}return new F(s,o,i)}const Ve={},Ue={},xb={touchstart:!0,touchmove:!0};class bb{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 vb(t){for(let e in Ve){let n=Ve[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Sb(t,r)&&!Bl(t,r)&&(t.editable||!(r.type in Ue))&&n(t,r)},xb[e]?{passive:!0}:void 0)}ze&&t.dom.addEventListener("input",()=>null),ja(t)}function Ft(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function kb(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function ja(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Bl(t,r))})}function Bl(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Sb(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Cb(t,e){!Bl(t,e)&&Ve[e.type]&&(t.editable||!(e.type in Ue))&&Ve[e.type](t,e)}Ue.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!dp(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(zt&&Pe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),xr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,kn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||db(t,n)?n.preventDefault():Ft(t,"key")};Ue.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ue.keypress=(t,e)=>{let n=e;if(dp(t)||!n.charCode||n.ctrlKey&&!n.altKey||ot&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",i=>i(t,r.$from.pos,r.$to.pos,s,o))&&t.dispatch(o()),n.preventDefault()}};function ws(t){return{left:t.clientX,top:t.clientY}}function wb(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function zl(t,e,n,r,s){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(t.someProp(e,a=>i>o.depth?a(t,n,o.nodeAfter,o.before(i),s,!0):a(t,n,o.node(i),o.before(i),s,!1)))return!0;return!1}function Ns(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Nb(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&H.isSelectable(r)?(Ns(t,new H(n)),!0):!1}function Mb(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof H&&(r=n.node);let o=t.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let a=i>o.depth?o.nodeAfter:o.node(i);if(H.isSelectable(a)){r&&n.$from.depth>0&&i>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?s=o.before(n.$from.depth):s=o.before(i);break}}return s!=null?(Ns(t,H.create(t.state.doc,s)),!0):!1}function Tb(t,e,n,r,s){return zl(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(s?Mb(t,n):Nb(t,n))}function Eb(t,e,n,r){return zl(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Db(t,e,n,r){return zl(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Ob(t,n,r)}function Ob(t,e,n){if(n.button!=0)return!1;let r=lp(t,e,!0),s=t.state.doc;return r?(Ns(t,r),r instanceof V&&s.eq(t.state.doc)&&(t.input.mouseDown=new Ib(t,r)),!0):!1}function lp(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?V.create(r,0,r.content.size):null;let s=r.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),a=s.before(o);if(i.inlineContent)return V.create(r,a+1,a+1+i.content.size);if(n&&H.isSelectable(i))return H.create(r,a)}return null}function Fl(t){return ho(t)}const cp=ot?"metaKey":"ctrlKey";Ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Fl(t),s=Date.now(),o="singleClick";s-t.input.lastClick.time<500&&wb(n,t.input.lastClick)&&!n[cp]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:o,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let i=t.posAtCoords(ws(n));i&&(o=="singleClick"?t.input.mouseDown=new Ab(t,i,n,!!r):(o=="doubleClick"?Eb:Db)(t,i.pos,i.inside,n)?n.preventDefault():Ft(t,"pointer"))};let up=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}};class Ab extends up{constructor(e,n,r,s){super(e),this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[cp],this.allowDefault=r.shiftKey;let o,i;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),i=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,i=u.depth?u.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof H&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&<&&!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()),Ft(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Vt(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ws(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ft(this.view,"pointer"):Tb(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ze&&this.mightDrag&&!this.mightDrag.node.isAtom||Pe&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Ns(this.view,Y.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ft(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ft(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class Ib extends up{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Ft(this.view,"pointer");let n=this.view.posAtCoords(ws(e)),r=n&&lp(this.view,n.inside,!1);if(!r)return;let{doc:s}=this.view.state,o=this.startSelection,[i,a]=r.from<o.from?[o.to,r.from]:[o.from,r.to];Ns(this.view,V.create(s,i,a))}}Ve.touchstart=t=>{t.input.lastTouch=Date.now(),Fl(t),Ft(t,"pointer")};Ve.touchmove=t=>{t.input.lastTouch=Date.now(),Ft(t,"pointer")};Ve.contextmenu=t=>Fl(t);function dp(t,e){return t.composing?!0:ze&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const jb=zt?5e3:-1;Ue.compositionstart=Ue.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Pe&&zh&&Rb(t)))t.markCursor=t.state.storedMarks||n.marks(),ho(t,!0),t.markCursor=null;else if(ho(t,!e.selection.empty),lt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let a=t.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}t.input.composing=!0}fp(t,jb)};function Rb(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Ue.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,fp(t,20))};function fp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ho(t),e))}function hp(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Pb(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Mx(e.focusNode,e.focusOffset),r=Tx(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let i=n.pmViewDesc;if(!(!i||!i.isText(n.nodeValue)))return r}}return n||r}function ho(t,e=!1){if(!(zt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),hp(t),e||t.docView&&t.docView.dirty){let n=Ll(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Lb(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const us=Qe&&ln<15||xr&&Ax<604;Ve.copy=Ue.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let o=us?null:n.clipboardData,i=r.content(),{dom:a,text:l}=_l(t,i);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):Lb(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $b(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function _b(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.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=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ds(t,r.value,null,s,e):ds(t,r.textContent,r.innerHTML,s,e)},50)}function ds(t,e,n,r,s){let o=np(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,s,o||F.empty)))return!0;if(!o)return!1;let i=$b(o),a=i?t.state.tr.replaceSelectionWith(i,r):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pp(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ue.paste=(t,e)=>{let n=e;if(t.composing&&!zt)return;let r=us?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ds(t,pp(r),r.getData("text/html"),s,n)?n.preventDefault():_b(t,n)};let mp=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}};const Bb=ot?"altKey":"ctrlKey";function gp(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[Bb]}Ve.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,o=s.empty?null:t.posAtCoords(ws(n)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof H?s.to-1:s.to))){if(r&&r.mightDrag)i=H.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(i=H.create(t.state.doc,d.posBefore))}}let a=(i||t.state.selection).content(),{dom:l,text:c,slice:u}=_l(t,a);(!n.dataTransfer.files.length||!Pe||Bh>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(us?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",us||n.dataTransfer.setData("text/plain",c),t.dragging=new mp(u,gp(t,n),i)};Ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ue.dragover=Ue.dragenter=(t,e)=>e.preventDefault();Ue.drop=(t,e)=>{try{zb(t,e,t.dragging)}finally{t.dragging=null}};function zb(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(ws(e));if(!r)return;let s=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",h=>{o=h(o,t,!1)}):o=np(t,pp(e.dataTransfer),us?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(n&&gp(t,e));if(t.someProp("handleDrop",h=>h(t,e,o||F.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?Dl(t.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let l=t.state.tr;if(i){let{node:h}=n;h?h.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(d))return;let f=l.doc.resolve(c);if(u&&H.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new H(f));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,y,g,x)=>h=x),l.setSelection($l(t,f,l.doc.resolve(h)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}Ve.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Vt(t)},20))};Ve.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ve.beforeinput=(t,e)=>{if(zt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,kn(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Ue)Ve[t]=Ue[t];function fs(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}let _u=class yp{constructor(e,n){this.toDOM=e,this.spec=n||An,this.side=this.spec.side||0}map(e,n,r,s){let{pos:o,deleted:i}=e.mapResult(n.from+s,this.side<0?-1:1);return i?null:new Kt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof yp&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&fs(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Kr=class Ra{constructor(e,n){this.attrs=e,this.spec=n||An}map(e,n,r,s){let o=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new Kt(o,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ra&&fs(this.attrs,e.attrs)&&fs(this.spec,e.spec)}static is(e){return e.type instanceof Ra}destroy(){}},Fb=class xp{constructor(e,n){this.attrs=e,this.spec=n||An}map(e,n,r,s){let o=e.mapResult(n.from+s,1);if(o.deleted)return null;let i=e.mapResult(n.to+s,-1);return i.deleted||i.pos<=o.pos?null:new Kt(o.pos-r,i.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),o;return s==n.from&&!(o=e.child(r)).isText&&s+o.nodeSize==n.to}eq(e){return this==e||e instanceof xp&&fs(this.attrs,e.attrs)&&fs(this.spec,e.spec)}destroy(){}},Kt=class Br{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Br(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Br(e,e,new _u(n,r))}static inline(e,n,r,s){return new Br(e,n,new Kr(r,s))}static node(e,n,r,s){return new Br(e,n,new Fb(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Kr}get widget(){return this.type instanceof _u}};const or=[],An={};let xe=class Zt{constructor(e,n){this.local=e.length?e:or,this.children=n.length?n:or}static create(e,n){return n.length?po(n,e,0,An):Be}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,o){for(let i=0;i<this.local.length;i++){let a=this.local[i];a.from<=n&&a.to>=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<n&&this.children[i+1]>e){let a=this.children[i]+1;this.children[i+2].findInner(e-a,n-a,r,s+a,o)}}map(e,n,r){return this==Be||e.maps.length==0?this:this.mapInner(e,n,0,0,r||An)}mapInner(e,n,r,s,o){let i;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(n,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?Hb(this.children,i||[],e,n,r,s,o):i?new Zt(i.sort(In),or):Be}add(e,n){return n.length?this==Be?Zt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,o=0;e.forEach((a,l)=>{let c=l+r,u;if(u=kp(n,a,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<l;)o+=3;s[o]==l?s[o+2]=s[o+2].addInner(a,u,c+1):s.splice(o,0,l,l+a.nodeSize,po(u,a,c+1,An)),o+=3}});let i=vp(o?Sp(n):n,-r);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||i.splice(a--,1);return new Zt(i.length?this.local.concat(i).sort(In):this.local,s||this.children)}remove(e){return e.length==0||this==Be?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,a=r[o]+n,l=r[o+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>a&&d.to<l&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,a+1);c!=Be?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let a=0;a<s.length;a++)s[a].eq(i,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new Zt(s,r):Be}forChild(e,n){if(this==Be)return this;if(n.isLeaf)return Zt.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,i=o+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<i&&l.to>o&&l.type instanceof Kr){let c=Math.max(o,l.from)-o,u=Math.min(i,l.to)-o;c<u&&(s||(s=[])).push(l.copy(c,u))}}if(s){let a=new Zt(s.sort(In),or);return r?new bp([a,r]):a}return r||Be}eq(e){if(this==e)return!0;if(!(e instanceof Zt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Hl(this.localsInner(e))}localsInner(e){if(this==Be)return or;if(e.inlineContent||!this.local.some(Kr.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Kr||n.push(this.local[r]);return n}forEachSet(e){e(this)}};xe.empty=new xe([],[]);xe.removeOverlap=Hl;const Be=xe.empty;let bp=class ir{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,An));return ir.from(r)}forChild(e,n){if(n.isLeaf)return xe.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,n);o!=Be&&(o instanceof ir?r=r.concat(o.members):r.push(o))}return ir.from(r)}eq(e){if(!(e instanceof ir)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let i=0;i<o.length;i++)n.push(o[i])}}return n?Hl(r?n:n.sort(In)):or}static from(e){switch(e.length){case 0:return Be;case 1:return e[0];default:return new ir(e.every(n=>n instanceof xe)?e:e.reduce((n,r)=>n.concat(r instanceof xe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function Hb(t,e,n,r,s,o,i){let a=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,m,y)=>{let g=y-m-(h-f);for(let x=0;x<a.length;x+=3){let b=a[x+1];if(b<0||f>b+u-d)continue;let v=a[x]+u-d;h>=v?a[x+1]=f<=v?-2:-1:f>=u&&g&&(a[x]+=g,a[x+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=n.map(t[c]+o),d=u-s;if(d<0||d>=r.content.size){l=!0;continue}let f=n.map(t[c+1]+o,-1),h=f-s,{index:m,offset:y}=r.content.findIndex(d),g=r.maybeChild(m);if(g&&y==d&&y+g.nodeSize==h){let x=a[c+2].mapInner(n,g,u+1,t[c]+o+1,i);x!=Be?(a[c]=d,a[c+1]=h,a[c+2]=x):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Wb(a,t,e,n,s,o,i),u=po(c,r,0,i);e=u.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<a.length&&a[f]<h;)f+=3;a.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new xe(e.sort(In),a)}function vp(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Kt(s.from+e,s.to+e,s.type))}return n}function Wb(t,e,n,r,s,o,i){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(r,s,c);d?n.push(d):i.onRemove&&i.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+o+1);return n}function kp(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let o=0,i;o<t.length;o++)(i=t[o])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),t[o]=null);return s}function Sp(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function po(t,e,n,r){let s=[],o=!1;e.forEach((a,l)=>{let c=kp(t,a,l+n);if(c){o=!0;let u=po(c,a,n+l+1,r);u!=Be&&s.push(l,l+a.nodeSize,u)}});let i=vp(o?Sp(t):t,-n).sort(In);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||s.length?new xe(i,s):Be}function In(t,e){return t.from-e.from||t.to-e.to}function Hl(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[s]=o.copy(o.from,r.to),Bu(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Bu(e,s,r.copy(o.from,r.to)));break}}}return e}function Bu(t,e,n){for(;e<t.length&&In(n,t[e])>0;)e++;t.splice(e,0,n)}function Li(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Be&&e.push(r)}),t.cursorWrapper&&e.push(xe.create(t.state.doc,[t.cursorWrapper.deco])),bp.from(e)}const Vb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ub=Qe&&ln<=11;class qb{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 Kb{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new qb,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Qe&&ln<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():ze&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Ub&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,Vb)),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 n=0;n<e.length;n++)this.queue.push(e[n]);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(Au(this.view)){if(this.suppressingSelectionUpdates)return Vt(this.view);if(Qe&&ln<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vn(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 n=new Set,r;for(let o=e.focusNode;o;o=yr(o))n.add(o);for(let o=e.anchorNode;o;o=yr(o))if(n.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Au(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,a=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],l);d&&(o=o<0?d.from:Math.min(d.from,o),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(a=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Pe&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(lt&&l.length){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Gb(e,d)!=h)&&f.remove()}}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ci(r)&&(c=Ll(e))&&c.eq(Y.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Vt(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),Jb(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Xb(e,l)),this.handleDOMChange(o,i,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Vt(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,o=e.nextSibling;if(Qe&&ln<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?je(s)+1:0,a=r.localPosFromDOM(e.target,i,-1),l=o&&o.parentNode==e.target?je(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let zu=new WeakMap,Fu=!1;function Jb(t){if(!zu.has(t)&&(zu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=lt,Fu)return;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."),Fu=!0}}function Hu(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=t.domAtPos(t.state.selection.anchor);return Vn(i.node,i.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function Yb(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Hu(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Hu(t,n):null}function Gb(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Xb(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let o of e)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let i=o.nextSibling;for(;i&&i.nodeName!="TD"&&i.nodeName!="TH";)i=i.nextSibling;if(i){let a=i;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(o,a.firstChild),r==o&&t.domSelection().collapse(o,s)}else o.parentNode.removeChild(o)}}function Qb(t,e,n,r){let{node:s,fromOffset:o,toOffset:i,from:a,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],ci(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Pe&&t.input.lastKeyCode===8)for(let x=i;x>o;x--){let b=s.childNodes[x-1],v=b.pmViewDesc;if(b.nodeName=="BR"&&!v){i=x;break}if(!v||v.size)break}let f=t.state.doc,h=t.someProp("domParser")||Et.fromSchema(t.state.schema),m=f.resolve(a),y=null,g=h.parse(s,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:o,to:i,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Zb(r),context:m});if(u&&u[0].pos!=null){let x=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=x),y={anchor:x+a,head:b+a}}return{doc:g,sel:y,from:a,to:l}}const Zb=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(ze&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||ze&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},ev=/^(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 tv(t,e,n,r,s){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let S=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,w=Ll(t,S);if(w&&!t.state.selection.eq(w)){if(Pe&&zt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",T=>T(t,kn(13,"Enter"))))return;let M=t.state.tr.setSelection(w);S=="pointer"?M.setMeta("pointer",!0):S=="key"&&M.scrollIntoView(),o&&M.setMeta("composition",o),t.dispatch(M)}return}let i=t.state.doc.resolve(e),a=i.sharedDepth(n);e=i.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=Qb(t,e,n,s),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let m=sv(d.content,c.doc.content,c.from,f,h);if(m&&t.input.domChangeCount++,(xr&&t.input.lastIOSEnter>Date.now()-225||zt)&&s.some(S=>S.nodeType==1&&!ev.test(S.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",S=>S(t,kn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&l instanceof V&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let S=Wu(t,t.state.doc,c.sel);if(S&&!S.eq(t.state.selection)){let w=t.state.tr.setSelection(S);o&&w.setMeta("composition",o),t.dispatch(w)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof V&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Qe&&ln<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)==" "&&(m.start--,m.endA--,m.endB--);let y=c.doc.resolveNoCache(m.start-c.from),g=c.doc.resolveNoCache(m.endB-c.from),x=u.resolve(m.start),b=y.sameParent(g)&&y.parent.inlineContent&&x.end()>=m.endA;if((xr&&t.input.lastIOSEnter>Date.now()-225&&(!b||s.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!b&&y.pos<c.doc.content.size&&(!y.sameParent(g)||!y.parent.inlineContent)&&y.pos<g.pos&&!/\S/.test(c.doc.textBetween(y.pos,g.pos,"","")))&&t.someProp("handleKeyDown",S=>S(t,kn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&rv(u,m.start,m.endA,y,g)&&t.someProp("handleKeyDown",S=>S(t,kn(8,"Backspace")))){zt&&Pe&&t.domObserver.suppressSelectionUpdates();return}Pe&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),zt&&!b&&y.start()!=g.start()&&g.parentOffset==0&&y.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,g=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(S){return S(t,kn(13,"Enter"))})},20));let v=m.start,k=m.endA,N=S=>{let w=S||t.state.tr.replace(v,k,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let M=Wu(t,w.doc,c.sel);M&&!(Pe&&t.composing&&M.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(M.head==v||M.head==w.mapping.map(k)-1)||Qe&&M.empty&&M.head==v)&&w.setSelection(M)}return o&&w.setMeta("composition",o),w.scrollIntoView()},C;if(b)if(y.pos==g.pos){Qe&&ln<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Vt(t),20));let S=N(t.state.tr.delete(v,k)),w=u.resolve(m.start).marksAcross(u.resolve(m.endA));w&&S.ensureMarks(w),t.dispatch(S)}else if(m.endA==m.endB&&(C=nv(y.parent.content.cut(y.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let S=N(t.state.tr);C.type=="add"?S.addMark(v,k,C.mark):S.removeMark(v,k,C.mark),t.dispatch(S)}else if(y.parent.child(y.index()).isText&&y.index()==g.index()-(g.textOffset?0:1)){let S=y.parent.textBetween(y.parentOffset,g.parentOffset),w=()=>N(t.state.tr.insertText(S,v,k));t.someProp("handleTextInput",M=>M(t,v,k,S,w))||t.dispatch(w())}else t.dispatch(N());else t.dispatch(N())}function Wu(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:$l(t,e.resolve(n.anchor),e.resolve(n.head))}function nv(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,o=r,i,a,l;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(s.length==1&&o.length==0)a=s[0],i="add",l=u=>u.mark(a.addToSet(u.marks));else if(s.length==0&&o.length==1)a=o[0],i="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if($.from(c).eq(t))return{mark:a,type:i}}function rv(t,e,n,r,s){if(n-e<=s.pos-r.pos||$i(r,!0,!1)<s.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let a=o.nodeAfter;return a!=null&&n==e+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=t.resolve($i(o,!0,!0));return!i.parent.isTextblock||i.pos>n||$i(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function $i(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function sv(t,e,n,r,s){let o=t.findDiffStart(e,n),i=n+t.size,a=n+e.size;if(o==null)return null;let{a:l,b:c}=t.findDiffEnd(e,i,a);if(s=="end"){let u=Math.max(0,o-Math.min(l,c));r-=l+u-o}if(l<o&&i<a){let u=r<=o&&r>=l?o-r:0;o-=u,c=o+(c-l),l=o}else if(c<o){let u=r<=o&&r>=c?o-r:0;o-=u,l=o+(l-c),c=o}return{start:o,endA:l,endB:c}}class Cp{constructor(e,n){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 bb,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Ju),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=qu(this),Uu(this),this.nodeViews=Ku(this),this.docView=Nu(this.state.doc,Vu(this),Li(this),this.dom,this),this.domObserver=new Kb(this,(r,s,o,i)=>tv(this,r,s,o,i)),this.domObserver.start(),vb(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ja(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ju),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(hp(this),i=!0),this.state=e;let a=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Ku(this);iv(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&ja(this),this.editable=qu(this),Uu(this);let l=Li(this),c=Vu(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,l);(d||!e.selection.eq(s.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Rx(this);if(i){this.domObserver.stop();let h=d&&(Qe||Pe)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&ov(s.selection,e.selection);if(d){let y=Pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Pb(this)),(o||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Nu(e.doc,c,l,this.dom,this)),y&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let m=this.input.mouseDown;h||!(m&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&sb(this)&&m.delaySelUpdate())?Vt(this,h):(Zh(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Px(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof H){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&vu(this,n.getBoundingClientRect(),e)}else vu(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){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&o<this.state.doc.content.size&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new mp(e.slice,e.move,s<0?void 0:H.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let a=this.directPlugins[i].props[e];if(a!=null&&(s=n?n(a):a))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let a=o[i].props[e];if(a!=null&&(s=n?n(a):a))return s}}hasFocus(){if(Qe){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(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Lx(this.dom),Vt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Fx(this,e)}coordsAtPos(e,n=1){return Uh(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return qx(this,n||this.state,e)}pasteHTML(e,n){return ds(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ds(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return _l(this,e)}destroy(){this.docView&&(kb(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Li(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,wx())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Cb(this,e)}domSelectionRange(){let e=this.domSelection();return e?ze&&this.root.nodeType===11&&Dx(this.dom.ownerDocument)==this.dom&&Yb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Cp.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Vu(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Kt.node(0,t.state.doc.content.size,e)]}function Uu(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Kt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function qu(t){return!t.someProp("editable",e=>e(t.state)===!1)}function ov(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Ku(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function iv(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function Ju(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var fn={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:"'"},mo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},av=typeof navigator<"u"&&/Mac/.test(navigator.platform),lv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Re=0;Re<10;Re++)fn[48+Re]=fn[96+Re]=String(Re);for(var Re=1;Re<=24;Re++)fn[Re+111]="F"+Re;for(var Re=65;Re<=90;Re++)fn[Re]=String.fromCharCode(Re+32),mo[Re]=String.fromCharCode(Re);for(var _i in fn)mo.hasOwnProperty(_i)||(mo[_i]=fn[_i]);function cv(t){var e=av&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||lv&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?mo:fn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const uv=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),dv=typeof navigator<"u"&&/Win/.test(navigator.platform);function fv(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,o,i;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))uv?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),i&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function hv(t){let e=Object.create(null);for(let n in t)e[fv(n)]=t[n];return e}function Bi(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function pv(t){return new pe({props:{handleKeyDown:wp(t)}})}function wp(t){let e=hv(t);return function(n,r){let s=cv(r),o,i=e[Bi(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[Bi(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(dv&&r.ctrlKey&&r.altKey)&&(o=fn[r.keyCode])&&o!=s){let a=e[Bi(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}function di(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,o=n.storedMarks,n}}}var hr=class Np{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(){const{rawCommands:e,editor:n,state:r}=this,{view:s}=n,{tr:o}=r,i=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...u)=>{const d=l(...u)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:s,state:o}=this,{view:i}=s,a=[],l=!!e,c=e||o.tr,u=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(c),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...y)=>{const g=this.buildProps(c,n),x=h(...y)(g);return a.push(x),d}])),run:u};return d}static createFakeChain(){const e=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){const{rawCommands:n,state:r}=this,s=!1,o=e||r.tr,i=this.buildProps(o,s);return{...Object.fromEntries(Object.entries(n).map(([a,l])=>[a,(...c)=>l(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,s)}}static createFallbackCan(){const e=Np.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(e,n=!0){const{rawCommands:r,editor:s,state:o}=this,{view:i}=s,a={tr:e,editor:s,view:i,state:di({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}};const mv=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),gv=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),yv=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:o,$to:i})=>{t.doc.nodesBetween(o.pos,i.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(l)),f=c.resolve(u.map(l+a.nodeSize)),h=d.blockRange(f);if(!h)return;const m=Mr(h);if(a.type.isTextblock){const{defaultType:y}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,y)}(m||m===0)&&e.lift(h,m)})}),!0},xv=t=>e=>t(e),bv=()=>({state:t,dispatch:e})=>Rh(t,e),vv=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,o=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new V(r.doc.resolve(Math.max(i-1,0)))),!0},kv=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(e){const i=s.before(o),a=s.after(o);t.delete(i,a).scrollIntoView()}return!0}return!1};function Ee(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}const Sv=t=>({tr:e,state:n,dispatch:r})=>{const s=Ee(t,n.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const a=o.before(i),l=o.after(i);e.delete(a,l).scrollIntoView()}return!0}return!1},Cv=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},wv=t=>t.content?/^text(\*|\+)/.test(t.content):!1,Yu=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return wv(r)?n==="left"?t.start()-1:t.end()+1:t.pos},Nv=(t,e,n)=>({from:Yu(t,n,"left"),to:Yu(e,n,"right")}),Mv=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){const n=t.tr,{ranges:r}=t.selection,s=n.steps.length;r.forEach(o=>{const i=n.mapping.slice(s),a=n.doc.resolve(i.map(o.$from.pos)),l=n.doc.resolve(i.map(o.$to.pos)),{from:c,to:u}=Nv(a,l,t.schema);n.deleteRange(c,u)}),n.selection.empty||n.setSelection(V.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),e(n)}return!0},Tv=()=>({commands:t})=>t.keyboardShortcut("Enter"),Ev=()=>({state:t,dispatch:e})=>cx(t,e);function Wl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function go(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Wl(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Mp(t,e,n={}){return t.find(r=>r.type===e&&go(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function Gu(t,e,n={}){return!!Mp(t,e,n)}function Vl(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(l=>l.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(l=>l.type===e))return;if(!n){const l=r.node.marks.find(c=>c.type===e);l&&(n=l.attrs)}if(!Mp([...r.node.marks],e,n))return;let s=r.index,o=t.start()+r.offset,i=s+1,a=o+r.node.nodeSize;for(;s>0&&Gu([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;i<t.parent.childCount&&Gu([...t.parent.child(i).marks],e,n);)a+=t.parent.child(i).nodeSize,i+=1;return{from:o,to:a}}function Jt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const Dv=(t,e)=>({tr:n,state:r,dispatch:s})=>{const o=Jt(t,r.schema),{doc:i,selection:a}=n,{$from:l,from:c,to:u}=a;if(s){const d=Vl(l,o,e);if(d&&d.from<=c&&d.to>=u){const f=V.create(i,d.from,d.to);n.setSelection(f)}}return!0},Ov=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Ul(t){return t instanceof V}function Ht(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Pa(t,e=null){if(!e)return null;const n=Y.atStart(t),r=Y.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,o=r.to;return e==="all"?V.create(t,Ht(0,s,o),Ht(t.content.size,s,o)):V.create(t,Ht(e,s,o),Ht(e,s,o))}function La(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function hs(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Av(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const Iv=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(hs()||La())&&r.dom.focus(),Av()&&!hs()&&!La()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(o&&t===null&&!Ul(n.state.selection))return i(),!0;const a=Pa(s.doc,t)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},jv=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),Rv=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Tp=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Tp(r)}return t};function zr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Tp(n)}function Ep(t){return typeof t?.nodesBetween=="function"}function br(t,e,n){if(Ep(t))return t;const r=typeof t=="object"&&t!==null;n={slice:!0,parseOptions:{},...n};const s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return $.fromArray(t.map(i=>e.nodeFromJSON(i)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),br("",e,n)}if(s){if(n.errorOnInvalidContent){let i=!1,a="";const l=new ah({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Et.fromSchema(l).parseSlice(zr(t),n.parseOptions):Et.fromSchema(l).parse(zr(t),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=Et.fromSchema(e);return n.slice?o.parseSlice(zr(t),n.parseOptions).content:o.parse(zr(t),n.parseOptions)}return br("",e,n)}function Dp(t){return!("type"in t)}function Op(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof ve||s instanceof Oe))return;const o=t.mapping.maps[r];let i=0;o.forEach((a,l,c,u)=>{i===0&&(i=u)}),t.setSelection(Y.near(t.doc.resolve(i),n))}const Pv=(t,e,n)=>({tr:r,dispatch:s,editor:o})=>{if(s){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=g=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{br(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{var i;a=br(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=n.errorOnInvalidContent)!==null&&i!==void 0?i:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;const m=Dp(a)?a.content:[a];if(m.forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let y;if(f)Array.isArray(e)?y=e.map(g=>g.text||"").join(""):Ep(e)?y=m.map(g=>{var x;return(x=g.text)!==null&&x!==void 0?x:""}).join(""):typeof e=="object"&&e&&e.text?y=e.text:y=e,r.insertText(y,u,d);else{y=$.from(m);const g=r.doc.resolve(u),x=g.node(),b=g.parentOffset===0,v=x.isText||x.isTextblock,k=x.content.size>0;b&&v&&k&&h&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&Op(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:y})}return!0};function Ap(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Lv=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{pos:s,attrs:o,content:i,updateSelection:a=!0}=t;let l;typeof s=="number"?l=e.doc.resolve(s):s?l=s:l=e.selection.$from;const c=Ap(l.parent.contentMatchAt(l.index()));if(!c)return!1;const u=Object.keys(c.spec.attrs||{}),d=o?Object.fromEntries(Object.entries(o).filter(([h])=>u.includes(h))):{};let f;if(i){const h=br(i,r.schema);f=c.createAndFill(d,h)}else f=c.createAndFill(d);return f?(n&&(e.insert(l.pos,f),a&&Op(e,e.steps.length-1,-1)),!0):!1},$v=()=>({state:t,dispatch:e})=>ix(t,e),_v=()=>({state:t,dispatch:e})=>ax(t,e),Bv=()=>({state:t,dispatch:e})=>Th(t,e),zv=()=>({state:t,dispatch:e})=>Ah(t,e),Fv=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ii(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Hv=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ii(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Wv=()=>({state:t,dispatch:e})=>sx(t,e),Vv=()=>({state:t,dispatch:e})=>ox(t,e);function Ip(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Uv(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,o,i;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))hs()||Ip()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const qv=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const o=Uv(t).split(/-(?!$)/),i=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l?.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function Ut(t,e,n={}){const{from:r,to:s,empty:o}=t.selection,i=e?Ee(e,t.schema):null,a=[];t.doc.nodesBetween(r,s,(u,d)=>{if(u.isText)return;const f=Math.max(r,d),h=Math.min(s,d+u.nodeSize);a.push({node:u,from:f,to:h})});const l=s-r,c=a.filter(u=>i?i.name===u.node.type.name:!0).filter(u=>go(u.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=l}const Kv=(t,e={})=>({state:n,dispatch:r})=>Ut(n,Ee(t,n.schema),e)?lx(n,r):!1,Jv=()=>({state:t,dispatch:e})=>Ph(t,e),Yv=t=>({state:e,dispatch:n})=>{const r=Ee(t,e.schema);return vx(r)(e,n)},Gv=()=>({state:t,dispatch:e})=>jh(t,e);function fi(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Xu(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}const Xv=(t,e)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const a=fi(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(o=Ee(t,r.schema)),a==="mark"&&(i=Jt(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{o&&o===u.type&&(l=!0,s&&n.setNodeMarkup(d,void 0,Xu(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(f=>{i===f.type&&(l=!0,s&&n.addMark(d,d+u.nodeSize,i.create(Xu(f.attrs,e))))})})}),l},Qv=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Zv=()=>({tr:t,dispatch:e})=>{if(e){const n=new Xe(t.doc);t.setSelection(n)}return!0},ek=()=>({state:t,dispatch:e})=>Dh(t,e),tk=()=>({state:t,dispatch:e})=>Ih(t,e),nk=()=>({state:t,dispatch:e})=>fx(t,e),rk=()=>({state:t,dispatch:e})=>mx(t,e),sk=()=>({state:t,dispatch:e})=>px(t,e);function $a(t,e,n={},r={}){return br(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const ok=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:a})=>{const{doc:l}=o;if(r.preserveWhitespace!=="full"){const c=$a(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});if(i){const u=Dp(c)?c.content:[c];o.replaceWith(0,l.content.size,u).setMeta("preventUpdate",!n)}return!0}return i&&o.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function jp(t,e){const n=Jt(e,t.schema),{from:r,to:s,empty:o}=t.selection,i=[];o?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,l=>{i.push(...l.marks)});const a=i.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function Rp(t,e){const n=new Sh(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function ik(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,o)=>{n(s)&&r.push({node:s,pos:o})}),r}function ak(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function hi(t){return e=>ak(e.$from,t)}function U(t,e,n){return t.config[e]===void 0&&t.parent?U(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?U(t.parent,e,n):null}):t.config[e]}function ql(t){return t.map(e=>{const n=U(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...ql(n())]:e}).flat(10)}function Kl(t,e){const n=qt.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Pp(t){return typeof t=="function"}function oe(t,e=void 0,...n){return Pp(t)?e?t.bind(e)(...n):t(...n):t}function lk(t={}){return Object.keys(t).length===0&&t.constructor===Object}function vr(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function Lp(t){const e=[],{nodeExtensions:n,markExtensions:r}=vr(t),s=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=n.filter(c=>c.name!=="text").map(c=>c.name),a=r.map(c=>c.name),l=[...i,...a];return t.forEach(c=>{const u=U(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:s});u&&u().forEach(d=>{let f;Array.isArray(d.types)?f=d.types:d.types==="*"?f=l:d.types==="nodes"?f=i:d.types==="marks"?f=a:f=[],f.forEach(h=>{Object.entries(d.attributes).forEach(([m,y])=>{e.push({type:h,name:m,attribute:{...o,...y}})})})})}),s.forEach(c=>{const u=U(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;const d=u();Object.entries(d).forEach(([f,h])=>{const m={...o,...h};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:f,attribute:m})})}),e}function ck(t){const e=[];let n="",r=!1,s=!1,o=0;const i=t.length;for(let a=0;a<i;a+=1){const l=t[a];if(l==="'"&&!s){r=!r,n+=l;continue}if(l==='"'&&!r){s=!s,n+=l;continue}if(!r&&!s){if(l==="("){o+=1,n+=l;continue}if(l===")"&&o>0){o-=1,n+=l;continue}if(l===";"&&o===0){e.push(n),n="";continue}}n+=l}return n&&e.push(n),e}function Qu(t){const e=[],n=ck(t||""),r=n.length;for(let s=0;s<r;s+=1){const o=n[s],i=o.indexOf(":");if(i===-1)continue;const a=o.slice(0,i).trim(),l=o.slice(i+1).trim();a&&l&&e.push([a,l])}return e}function Se(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,o])=>{if(s==="__proto__"){Object.defineProperty(r,s,{configurable:!0,enumerable:!0,value:o,writable:!0});return}if(!r[s]){r[s]=o;return}if(s==="class"){const i=o?String(o).split(" "):[],a=r[s]?r[s].split(" "):[],l=i.filter(c=>!a.includes(c));r[s]=[...a,...l].join(" ")}else if(s==="style"){const i=new Map([...Qu(r[s]),...Qu(o)]);r[s]=Array.from(i.entries()).map(([a,l])=>`${a}: ${l}`).join("; ")}else r[s]=o}),r},{})}function kr(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Se(n,r),{})}function uk(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Zu(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(n):uk(n.getAttribute(i.name));return a==null?o:{...o,[i.name]:a}},{});return{...r,...s}}}}function ed(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&lk(n)?!1:n!=null))}function td(t){var e,n;const r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function $p(t,e){var n;const r=Lp(t),{nodeExtensions:s,markExtensions:o}=vr(t),i=(n=s.find(c=>U(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(s.map(c=>{const u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=ed({...t.reduce((g,x)=>{const b=U(x,"extendNodeSchema",d);return{...g,...b?b(c):{}}},{}),content:oe(U(c,"content",d)),marks:oe(U(c,"marks",d)),group:oe(U(c,"group",d)),inline:oe(U(c,"inline",d)),atom:oe(U(c,"atom",d)),selectable:oe(U(c,"selectable",d)),draggable:oe(U(c,"draggable",d)),code:oe(U(c,"code",d)),whitespace:oe(U(c,"whitespace",d)),linebreakReplacement:oe(U(c,"linebreakReplacement",d)),defining:oe(U(c,"defining",d)),isolating:oe(U(c,"isolating",d)),attrs:Object.fromEntries(u.map(td))}),h=oe(U(c,"parseHTML",d));h&&(f.parseDOM=h.map(g=>Zu(g,u)));const m=U(c,"renderHTML",d);m&&(f.toDOM=g=>m({node:g,HTMLAttributes:kr(g,u)}));const y=U(c,"renderText",d);return y&&(f.toText=y),[c.name,f]})),l=Object.fromEntries(o.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=ed({...t.reduce((y,g)=>{const x=U(g,"extendMarkSchema",d);return{...y,...x?x(c):{}}},{}),inclusive:oe(U(c,"inclusive",d)),excludes:oe(U(c,"excludes",d)),group:oe(U(c,"group",d)),spanning:oe(U(c,"spanning",d)),code:oe(U(c,"code",d)),attrs:Object.fromEntries(u.map(td))}),h=oe(U(c,"parseHTML",d));h&&(f.parseDOM=h.map(y=>Zu(y,u)));const m=U(c,"renderHTML",d);return m&&(f.toDOM=y=>m({mark:y,HTMLAttributes:kr(y,u)})),[c.name,f]}));return new ah({topNode:i,nodes:a,marks:l})}function dk(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Jr(t){return t.sort((n,r)=>{const s=U(n,"priority")||100,o=U(r,"priority")||100;return s>o?-1:s<o?1:0})}function Jl(t){const e=Jr(ql(t)),n=dk(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function fk(t,e){return $p(Jl(t),e)}function GO(t,e){const n=fk(e),r=zr(t);return Et.fromSchema(n).parse(r).toJSON()}function _p(t,e,n){const{from:r,to:s}=e,{blockSeparator:o=`
|
|
11
|
-
|
|
12
|
-
`,textSerializers:i={}}=n||{};let a="";return t.nodesBetween(r,s,(l,c,u,d)=>{l.isBlock&&c>r&&(a+=o);const f=i?.[l.type.name];if(f)return u&&(a+=f({node:l,pos:c,parent:u,index:d,range:e})),!1;if(l.isText){var h;a+=l==null||(h=l.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,s-c)}}),a}function hk(t,e){return _p(t,{from:0,to:t.content.size},e)}function Bp(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function pk(t,e){const n=Ee(e,t.schema),{from:r,to:s}=t.selection,o=[];t.doc.nodesBetween(r,s,a=>{o.push(a)});const i=o.reverse().find(a=>a.type.name===n.name);return i?{...i.attrs}:{}}function zp(t,e){const n=fi(typeof e=="string"?e:e.name,t.schema);return n==="node"?pk(t,e):n==="mark"?jp(t,e):{}}function mk(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function gk(t){const e=mk(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function pi(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((a,l)=>{i.push({from:a,to:l})});else{const{from:a,to:l}=n[o];if(a===void 0||l===void 0)return;i.push({from:a,to:l})}i.forEach(({from:a,to:l})=>{const c=e.slice(o).map(a,-1),u=e.slice(o).map(l),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),gk(r)}function Yl(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const o=Vl(n.resolve(t),s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,o)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}const yk=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let o=r,i=null;for(;o>0&&i===null;){const a=s.node(o);a?.type.name===e?i=a:o-=1}return[i,o]},xk=t=>{const e=t.depth-1;if(e<0)return null;const n=t.index(e);return n===0?null:t.node(e).child(n-1)};function tr(t,e){return e.nodes[t]||e.marks[t]||null}function to(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}const bk=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,o,i,a)=>{var l,c;const u=((l=(c=s.type.spec).toText)===null||l===void 0?void 0:l.call(c,{node:s,pos:o,parent:i,index:a}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-o))}),n};function _a(t,e,n={}){const{empty:r,ranges:s}=t.selection,o=e?Jt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>go(u.attrs,n,{strict:!1}));let i=0;const a=[];if(s.forEach(({$from:u,$to:d})=>{const f=u.pos,h=d.pos;t.doc.nodesBetween(f,h,(m,y)=>{if(o&&m.inlineContent&&!m.type.allowsMarkType(o))return!1;if(!m.isText&&!m.marks.length)return;const g=Math.max(f,y),x=Math.min(h,y+m.nodeSize),b=x-g;i+=b,a.push(...m.marks.map(v=>({mark:v,from:g,to:x})))})}),i===0)return!1;const l=a.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>go(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=a.filter(u=>o?u.mark.type!==o&&u.mark.type.excludes(o):!0).reduce((u,d)=>u+d.to-d.from,0);return(l>0?l+c:l)>=i}function vk(t,e,n={}){if(!e)return Ut(t,null,n)||_a(t,null,n);const r=fi(e,t.schema);return r==="node"?Ut(t,e,n):r==="mark"?_a(t,e,n):!1}const kk=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const o=hi(a=>a.type.name===e)(t.selection);if(!o)return!1;const i=t.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Sk=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function nd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function zi(t,e){const{nodeExtensions:n}=vr(e),r=n.find(o=>o.name===t);if(!r)return!1;const s=oe(U(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof s!="string"?!1:s.split(" ").includes("list")}function Ms(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name==="hardBreak")return!0;if(t.isText){var r;return!/\S/.test((r=t.text)!==null&&r!==void 0?r:"")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(o=>{s!==!1&&(Ms(o,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Fp(t){return t instanceof H}function Ck({selection:t,pos:e,nodeSize:n,selectedOnTextSelection:r=!1}){const{from:s,to:o}=t;return!!(s<=e&&o>=e+n||r&&Ul(t)&&s>e&&o<e+n)}var Hp=class Wp{constructor(e){this.position=e}static fromJSON(e){return new Wp(e.position)}toJSON(){return{position:this.position}}};function wk(t,e){const n=e.mapping.mapResult(t.position);return{position:new Hp(n.pos),mapResult:n}}function Nk(t){return new Hp(t)}function XO(t,e,n){const s=t.state.doc.content.size,o=Ht(e,0,s),i=Ht(n,0,s),a=t.coordsAtPos(o),l=t.coordsAtPos(i,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),f=Math.max(a.right,l.right),h={top:c,bottom:u,left:d,right:f,width:f-d,height:u-c,x:d,y:c};return{...h,toJSON:()=>h}}function Mk(t,e,n){const{selection:r}=e;let s=null;if(Ul(r)&&(s=r.$cursor),s){var o;const a=(o=t.storedMarks)!==null&&o!==void 0?o:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(l=>l.type.excludes(n)))}const{ranges:i}=r;return i.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(n),m=!!n.isInSet(u.marks)||!u.marks.some(y=>y.type.excludes(n));c=h&&m}return!c}),c})}const Tk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=n,{empty:i,ranges:a}=o,l=Jt(t,r.schema);if(s)if(i){const c=jp(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const m=Math.max(h,u),y=Math.min(h+f.nodeSize,d);f.marks.find(g=>g.type===l)?f.marks.forEach(g=>{l===g.type&&n.addMark(m,y,l.create({...g.attrs,...e}))}):n.addMark(m,y,l.create(e))})});return Mk(r,n,l)},Ek=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Dk=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const o=Ee(t,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:a})=>yu(o,{...i,...e})(n)?!0:a.clearNodes()).command(({state:a})=>yu(o,{...i,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Ok=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Ht(t,0,r.content.size),o=H.create(r,s);e.setSelection(o)}return!0},Ak=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=r;let i,a;return typeof e=="number"?(i=e,a=e):e&&"from"in e&&"to"in e?(i=e.from,a=e.to):(i=o.from,a=o.to),s&&n.doc.nodesBetween(i,a,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},Ik=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:o}=typeof t=="number"?{from:t,to:t}:t,i=V.atStart(r).from,a=V.atEnd(r).to,l=Ht(s,i,a),c=Ht(o,i,a),u=V.create(r,l,c);e.setSelection(u)}return!0},jk=t=>({state:e,dispatch:n})=>{const r=Ee(t,e.schema);return Cx(r)(e,n)};function rd(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}const Rk=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:a,$to:l}=o,c=s.extensionManager.attributes,u=to(c,a.node().type.name,a.node().attrs);if(o instanceof H&&o.node.isBlock)return!a.parentOffset||!Wt(i,a.pos)?!1:(r&&(t&&rd(n,s.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,f=a.depth===0?void 0:Ap(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,m=Wt(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!m&&Wt(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(m=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(m&&(o instanceof V&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,h),f&&!d&&!a.parentOffset&&a.parent.type!==f)){const y=e.mapping.map(a.before()),g=e.doc.resolve(y);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&rd(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},Pk=(t,e={})=>({tr:n,state:r,dispatch:s,editor:o})=>{const i=Ee(t,r.schema),{$from:a,$to:l}=r.selection,c=r.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const u=a.node(-1);if(u.type!==i)return!1;const d=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==i||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){var f;let x=$.empty;const b=a.index(-1)?1:a.index(-2)?2:3;for(let w=a.depth-b;w>=a.depth-3;w-=1)x=$.from(a.node(w).copy(x));const v=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,k={...to(d,a.node().type.name,a.node().attrs),...e},N=((f=i.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(k))||void 0;x=x.append($.from(i.createAndFill(null,N)||void 0));const C=a.before(a.depth-(b-1));n.replace(C,a.after(-v),new F(x,4-b,0));let S=-1;n.doc.nodesBetween(C,n.doc.content.size,(w,M)=>{if(S>-1)return!1;w.isTextblock&&w.content.size===0&&(S=M+1)}),S>-1&&n.setSelection(V.near(n.doc.resolve(S))),n.scrollIntoView()}return!0}const h=l.pos===a.end()?u.contentMatchAt(0).defaultType:null,m={...to(d,u.type.name,u.attrs),...e},y={...to(d,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,l.pos);const g=h?[{type:i,attrs:m},{type:h,attrs:y}]:[{type:i,attrs:m}];if(!Wt(n.doc,a.pos,2))return!1;if(s){const{selection:x,storedMarks:b}=r,{splittableMarks:v}=o.extensionManager,k=b||x.$to.parentOffset&&x.$from.marks();if(n.split(a.pos,2,g).scrollIntoView(),!k||!s)return!0;const N=k.filter(C=>v.includes(C.type.name));n.ensureMarks(N)}return!0};function sd(t){return!t||t==="1"?null:t}function Vp(t,e){return sd(t)===sd(e)}const Fi=(t,e)=>{const n=hi(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return!(n.node.type===s?.type&&pn(t.doc,n.pos))||!Vp(n.node.attrs.type,s?.attrs.type)||t.join(n.pos),!0},Hi=(t,e)=>{const n=hi(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return!(n.node.type===s?.type&&pn(t.doc,r))||!Vp(n.node.attrs.type,s?.attrs.type)||t.join(r),!0};function Lk(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),s=e.resolve(n.nodeSize-1);return V.between(r,s)}const $k=(t,e,n,r={})=>({editor:s,tr:o,state:i,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=s.extensionManager,h=Ee(t,i.schema),m=Ee(e,i.schema),{selection:y,storedMarks:g}=i,{$from:x,$to:b}=y,v=x.blockRange(b),k=g||y.$to.parentOffset&&y.$from.marks();if(!v)return!1;const N=hi(P=>zi(P.type.name,d))(y),C=y.from===0&&y.to===i.doc.content.size,S=i.doc.content.content,w=S.length===1?S[0]:null,M=C&&w&&zi(w.type.name,d)?{node:w,pos:0}:null,T=N??M,O=!!N&&v.depth>=1&&v.depth-N.depth<=1,A=!!M;if((O||A)&&T){if(T.node.type===h)return C&&A?l().command(({tr:P,dispatch:D})=>{const E=Lk(P);return E?(P.setSelection(E),D&&D(P),!0):!1}).liftListItem(m).run():c.liftListItem(m);if(zi(T.node.type.name,d)&&h.validContent(T.node.content))return l().command(()=>(o.setNodeMarkup(T.pos,h),!0)).command(()=>Fi(o,h)).command(()=>Hi(o,h)).run()}return!n||!k||!a?l().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Fi(o,h)).command(()=>Hi(o,h)).run():l().command(()=>{const P=u().wrapInList(h,r),D=k.filter(E=>f.includes(E.type.name));return o.ensureMarks(D),P?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Fi(o,h)).command(()=>Hi(o,h)).run()},_k=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=n,i=Jt(t,r.schema);return _a(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},Bk=(t,e,n={})=>({state:r,commands:s})=>{const o=Ee(t,r.schema),i=Ee(e,r.schema),a=Ut(r,o,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(i,l):s.setNode(o,{...l,...n})},zk=(t,e={})=>({state:n,commands:r})=>{const s=Ee(t,n.schema);return Ut(n,s,e)?r.lift(s):r.wrapIn(s,e)},Fk=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let o;if(s.spec.isInputRules&&(o=s.getState(t))){if(e){const i=t.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l-=1)i.step(a.steps[l].invert(a.docs[l]));if(o.text){const l=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,t.schema.text(o.text,l))}else i.delete(o.from,o.to)}return!0}}return!1},Hk=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:s=!1}=t,{selection:o}=e,{empty:i,ranges:a}=o;if(i)return!0;const{nonClearableMarks:l}=r.extensionManager;if(n){const c=Object.values(r.schema.marks).filter(u=>s||!l.includes(u.name));a.forEach(u=>{for(const d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},Wk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{extendEmptyMarkRange:o=!1}=e,{selection:i}=n,a=Jt(t,r.schema),{$from:l,empty:c,ranges:u}=i;if(!s)return!0;if(c&&o){var d;let{from:f,to:h}=i;const m=Vl(l,a,(d=l.marks().find(y=>y.type===a))===null||d===void 0?void 0:d.attrs);m&&(f=m.from,h=m.to),n.removeMark(f,h,a)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},Vk=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let o,i;return typeof t=="number"?(o=t,i=t):t&&"from"in t&&"to"in t?(o=t.from,i=t.to):(o=s.from,i=s.to),r&&e.doc.nodesBetween(o,i,(a,l)=>{if(a.isText)return;const c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},Uk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const a=fi(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(o=Ee(t,r.schema)),a==="mark"&&(i=Jt(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let f,h,m,y;n.selection.empty?r.doc.nodesBetween(u,d,(g,x)=>{o&&o===g.type&&(l=!0,m=Math.max(x,u),y=Math.min(x+g.nodeSize,d),f=x,h=g)}):r.doc.nodesBetween(u,d,(g,x)=>{x<u&&o&&o===g.type&&(l=!0,m=Math.max(x,u),y=Math.min(x+g.nodeSize,d),f=x,h=g),x>=u&&x<=d&&(o&&o===g.type&&(l=!0,s&&n.setNodeMarkup(x,void 0,{...g.attrs,...e})),i&&g.marks.length&&g.marks.forEach(b=>{if(i===b.type&&(l=!0,s)){const v=Math.max(x,u),k=Math.min(x+g.nodeSize,d);n.addMark(v,k,i.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&s&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(g=>{i===g.type&&s&&n.addMark(m,y,i.create({...g.attrs,...e}))}))}),l},ar=new Ce("__tiptap_decorations__"),qk=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(ar,{type:"force",name:t}),!0),Kk=(t,e={})=>({state:n,dispatch:r})=>{const s=Ee(t,n.schema);return gx(s,e)(n,r)},Jk=(t,e={})=>({state:n,dispatch:r})=>{const s=Ee(t,n.schema);return yx(s,e)(n,r)};var Yk=ly({blur:()=>mv,clearContent:()=>gv,clearNodes:()=>yv,command:()=>xv,createParagraphNear:()=>bv,cut:()=>vv,deleteCurrentNode:()=>kv,deleteNode:()=>Sv,deleteRange:()=>Cv,deleteSelection:()=>Mv,enter:()=>Tv,exitCode:()=>Ev,extendMarkRange:()=>Dv,first:()=>Ov,focus:()=>Iv,forEach:()=>jv,insertContent:()=>Rv,insertContentAt:()=>Pv,insertDefaultBlock:()=>Lv,joinBackward:()=>Bv,joinDown:()=>_v,joinForward:()=>zv,joinItemBackward:()=>Fv,joinItemForward:()=>Hv,joinTextblockBackward:()=>Wv,joinTextblockForward:()=>Vv,joinUp:()=>$v,keyboardShortcut:()=>qv,lift:()=>Kv,liftEmptyBlock:()=>Jv,liftListItem:()=>Yv,newlineInCode:()=>Gv,resetAttributes:()=>Xv,scrollIntoView:()=>Qv,selectAll:()=>Zv,selectNodeBackward:()=>ek,selectNodeForward:()=>tk,selectParentNode:()=>nk,selectTextblockEnd:()=>rk,selectTextblockStart:()=>sk,setContent:()=>ok,setMark:()=>Tk,setMeta:()=>Ek,setNode:()=>Dk,setNodeSelection:()=>Ok,setTextDirection:()=>Ak,setTextSelection:()=>Ik,sinkListItem:()=>jk,splitBlock:()=>Rk,splitListItem:()=>Pk,toggleList:()=>$k,toggleMark:()=>_k,toggleNode:()=>Bk,toggleWrap:()=>zk,undoInputRule:()=>Fk,unsetAllMarks:()=>Hk,unsetMark:()=>Wk,unsetTextDirection:()=>Vk,updateAttributes:()=>Uk,updateDecorations:()=>qk,wrapIn:()=>Kk,wrapInList:()=>Jk});const Ar=new WeakMap;function Gk(t,e){var n;Ar.set(t,((n=Ar.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;const s=((r=Ar.get(t))!==null&&r!==void 0?r:1)-1;s>0?Ar.set(t,s):Ar.delete(t)}}var Xk=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function Qk(t){return t.kind==="widget"}function Up(t,e){const n=[],r=new Set;for(const s of t)s.kind==="widget"&&Qk(s)&&r.add(s.key),n.push(s.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function Zk(t,e,n){const{decorations:r,widgetKeys:s}=Up(e,n);return{set:xe.create(t,r),widgetKeys:s}}function qp({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function e2({decorations:t,from:e,to:n,docSize:r,extensionName:s,warnedExtensions:o}){return t.filter(i=>qp({position:i.anchor,from:e,to:n,docSize:r})?!0:(i.anchor===n||o.has(s)||(o.add(s),console.warn(`[tiptap warn]: Extension "${s}" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function t2(t){var e;const n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function Kp(t){return t.jsonID==="attr"}function n2(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||Kp(t))return!0;const n=t;return typeof n.from=="number"&&typeof n.to=="number"}function r2(t,e){let n=null,r=0,s=0;for(let o=0;o<t.childCount&&!(s>e.to);o+=1){const i=s+t.child(o).nodeSize;i>=e.from&&(n===null&&(n=s),r=i),s=i}return n===null?null:{from:n,to:r}}function s2(t,e){if(t.steps.some(o=>!n2(o)))return{type:"full"};const n=pi(t).map(({newRange:o})=>o);t.steps.forEach((o,i)=>{if(!Kp(o))return;const a=t.mapping.slice(i);n.push({from:a.map(o.pos,-1),to:a.map(o.pos+1)})});const r=[];for(const o of n){const i=r2(e,o);i&&r.push(i)}r.sort((o,i)=>o.from-i.from);const s=[];for(const o of r){const i=s[s.length-1];i&&o.from<=i.to?i.to=Math.max(i.to,o.to):s.push({...o})}return{type:"ranges",ranges:s}}function Jp(t,e,n,r){return t.map(e,n,{onRemove:s=>{const o=s?.key;typeof o=="string"&&r.delete(o)}})}function o2(t,e,n){var r,s;const o=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:xe.empty,i=new Set((s=e.widgetKeysByExtension[t])!==null&&s!==void 0?s:[]);return{set:Jp(o,n.mapping,n.doc,i),widgetKeys:i}}function od(t,e){const n=Object.values(e).flatMap(r=>r.find());return xe.create(t,n)}function id(t){const e=new Set;for(const n of Object.values(t))for(const r of n)e.add(r);return e}function i2(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${t}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${t}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function a2(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}const l2=new Set;var c2=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{const n=ar.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>i2(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=ar.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:l2}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){const e=[];for(const{name:n,addDecorations:r}of t){const s=r();s&&e.push({name:n,spec:s})}return e}createPlugin(){const{editor:t,entries:e}=this;return new pe({key:ar,state:{init:(n,r)=>{const s={},o={};for(const{name:a,spec:l}of e){const{set:c,widgetKeys:u}=this.buildFullSet(a,l,r);s[a]=c,o[a]=u}const i={decorationSetsByExtension:s,widgetKeysByExtension:o,mergedDecorationSet:this.buildMergedSet(r.doc,s),widgetKeys:id(o)};return this.warnDuplicateWidgetKeys(i),i},apply:(n,r,s,o)=>{const i=n.getMeta(ar),a=i?.type==="force"&&!i.name,l=i?.type==="force"?i.name:void 0,c={},u={},d=new Set;return Gk(t,()=>{for(const{name:f,spec:h}of e){const m=a||l===f;if(a2(h,{editor:t,tr:n,oldState:s,newState:o},m))if(h.update==="changedRanges"&&n.docChanged&&!m){const y=this.applyChangedRangesRecompute(f,h,r,n,o);c[f]=y.set,u[f]=y.widgetKeys,d.add(f)}else{const{set:y,widgetKeys:g}=this.buildFullSet(f,h,o);c[f]=y,u[f]=g,d.add(f)}else{const y=o2(f,r,n);c[f]=y.set,u[f]=y.widgetKeys}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:id(u)}}},props:{decorations(n){var r,s;return(r=(s=ar.getState(n))===null||s===void 0?void 0:s.mergedDecorationSet)!==null&&r!==void 0?r:xe.empty}}})}applyChangedRangesRecompute(t,e,n,r,s){const o=s2(r,s.doc);return o.type==="full"?this.buildFullSet(t,e,s):this.rebuildRanges(t,e,n,r,s,o.ranges)}rebuildRanges(t,e,n,r,s,o){var i,a;const l=(i=n.decorationSetsByExtension[t])!==null&&i!==void 0?i:xe.empty,c=new Set((a=n.widgetKeysByExtension[t])!==null&&a!==void 0?a:[]);let u=Jp(l,r.mapping,r.doc,c);const d=s.doc.content.size;for(const{from:f,to:h}of o){const m=u.find(f,h).filter(x=>qp({position:x.from,from:f,to:h,docSize:d}));for(const x of m){const b=t2(x);b&&c.delete(b)}u=u.remove(m);const{decorations:y,widgetKeys:g}=Up(e2({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:s,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:d,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);u=u.add(s.doc,y);for(const x of g)c.add(x)}return{set:u,widgetKeys:c}}buildFullSet(t,e,n){const r=this.runCreate(t,"create",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return Zk(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${t}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){}buildMergedSet(t,e){const n=Object.keys(e);return n.length===1?e[n[0]]:od(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:s}){return t.length===1?r[t[0].name]:s.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):od(n.doc,r)}};function u2(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(s=>Object.prototype.hasOwnProperty.call(e,s)&&Object.is(t[s],e[s]))}function d2(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof H){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function f2(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}function QO(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function ZO(t,e){const n=t.getAttribute("style");if(!n)return null;const r=n.split(";").map(o=>o.trim()).filter(Boolean),s=e.toLowerCase();for(let o=r.length-1;o>=0;o-=1){const i=r[o],a=i.indexOf(":");if(a!==-1&&i.slice(0,a).trim().toLowerCase()===s)return i.slice(a+1).trim()}return null}function eA(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")}function tA(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function h2(t){return typeof t=="number"}function p2(t){return Object.prototype.toString.call(t).slice(8,-1)}function Fs(t){return p2(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function ad(t,e,n){const r=t.split(`
|
|
13
|
-
`),s=[];let o="",i=0;const a=e.baseIndentSize||2;for(;i<r.length;){const u=r[i],d=u.match(e.itemPattern);if(!d){if(s.length>0)break;if(u.trim()===""){i+=1,o=`${o}${u}
|
|
14
|
-
`;continue}else return}const f=e.extractItemData(d),{indentLevel:h,mainContent:m}=f;o=`${o}${u}
|
|
15
|
-
`;const y=[m];for(i+=1;i<r.length;){var l;const v=r[i];if(v.trim()===""){var c;const k=r.slice(i+1).findIndex(N=>N.trim()!=="");if(k===-1)break;if((((c=r[i+1+k].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){y.push(v),o=`${o}${v}
|
|
16
|
-
`,i+=1;continue}else break}if((((l=v.match(/^(\s*)/))===null||l===void 0||(l=l[1])===null||l===void 0?void 0:l.length)||0)>h)y.push(v),o=`${o}${v}
|
|
17
|
-
`,i+=1;else break}let g;const x=y.slice(1);if(x.length>0){const v=x.map(k=>k.slice(h+a)).join(`
|
|
18
|
-
`);v.trim()&&(e.customNestedParser?g=e.customNestedParser(v):g=n.blockTokens(v))}const b=e.createToken(f,g);s.push(b)}if(s.length!==0)return{items:s,raw:o}}function Yp(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[o,...i]=t.content;let a=`${s}${e.renderChildren([o])}`;return i&&i.length>0&&i.forEach((l,c)=>{var u,d;const f=(u=(d=e.renderChild)===null||d===void 0?void 0:d.call(e,l,c+1))!==null&&u!==void 0?u:e.renderChildren([l]);if(f!=null){const h=f.split(`
|
|
19
|
-
`).map(m=>m?e.indent(m):e.indent("")).join(`
|
|
20
|
-
`);a+=l.type==="paragraph"?`
|
|
21
|
-
|
|
22
|
-
${h}`:`
|
|
23
|
-
${h}`}}),a}function ld(t){return typeof t.type=="string"?t.type:t.type.name}function nA(t,e){if(t.length!==e.length)return!1;const n=Array.from({length:e.length},()=>!1);return t.every(r=>{const s=ld(r),o=e.findIndex((i,a)=>!n[a]&&s===ld(i)&&u2(r.attrs,i.attrs));return o===-1?!1:(n[o]=!0,!0)})}function Gp(t,e){const n={...t};return Fs(t)&&Fs(e)&&Object.keys(e).forEach(r=>{Fs(e[r])&&Fs(t[r])?n[r]=Gp(t[r],e[r]):n[r]=e[r]}),n}function m2(t,e,n={}){const{state:r}=e,{doc:s,tr:o}=r,i=t;s.descendants((a,l)=>{const c=o.mapping.map(l),u=o.mapping.map(l)+a.nodeSize;let d=null;if(a.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){const h=t.type.create({...t.attrs,...n});o.removeMark(c,u,t.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var Ts=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}};const g2=(t,e)=>{if(Wl(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,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};function Hs(t){var e;const{editor:n,from:r,to:s,text:o,rules:i,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=bk(c)+o;return i.forEach(f=>{if(u)return;const h=g2(d,f.find);if(!h)return;const m=h[0].length-o.length;if(m>0){const N=c.parentOffset-m;if(N<0||c.parent.textBetween(N,c.parentOffset)!==h[0].slice(0,m))return}const y=l.state.tr,g=di({state:l.state,transaction:y}),x={from:r-(h[0].length-o.length),to:s},{commands:b,chain:v,can:k}=new hr({editor:n,state:g});f.handler({state:g,range:x,match:h,commands:b,chain:v,can:k})===null||!y.steps.length||(f.undoable&&y.setMeta(a,{transform:y,from:r,to:s,text:o}),l.dispatch(y),u=!0)}),u}function y2(t){const{editor:e,rules:n}=t,r=new pe({state:{init(){return null},apply(s,o,i){const a=s.getMeta(r);if(a)return a;const l=s.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:c}=l;typeof c=="string"?c=c:c=Kl($.from(c),i.schema);const{from:u}=l,d=u+c.length;Hs({editor:e,from:u,to:d,text:c,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,a){return Hs({editor:e,from:o,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&Hs({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?Hs({editor:e,from:i.pos,to:i.pos,text:`
|
|
24
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Gl=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...oe(U(this,"addOptions",{name:this.name}))}}get storage(){return{...oe(U(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Gp(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Jn=class Xp extends Gl{constructor(...e){super(...e),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Xp(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!o.find(a=>a?.type.name===n.name))return!1;const i=o.find(a=>a?.type.name===n.name);return i&&r.removeStoredMark(i),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Qp=class{constructor(t){this.find=t.find,this.handler=t.handler}};const x2=(t,e,n)=>{if(Wl(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=t,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function b2(t){const{editor:e,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:a}=t,{commands:l,chain:c,can:u}=new hr({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,h)=>{var m,y,g,x;if(!((m=f.type)===null||m===void 0||(m=m.spec)===null||m===void 0)&&m.code||!(f.isText||f.isTextblock||f.isInline))return;const b=(y=(g=(x=f.content)===null||x===void 0?void 0:x.size)!==null&&g!==void 0?g:f.nodeSize)!==null&&y!==void 0?y:0,v=Math.max(r,h),k=Math.min(s,h+b);if(v>=k)return;const N=f.isText?f.text||"":f.textBetween(v-h,k-h,void 0,"");x2(N,o.find,i).forEach(C=>{if(C.index===void 0)return;const S=v+C.index+1,w=S+C[0].length,M={from:n.tr.mapping.map(S),to:n.tr.mapping.map(w)},T=o.handler({state:n,range:M,match:C,commands:l,chain:c,can:u,pasteEvent:i,dropEvent:a});d.push(T)})}),d.every(f=>f!==null)}let Ws=null;const v2=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function k2(t){const{editor:e,rules:n}=t;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:c,from:u,to:d,rule:f,pasteEvt:h})=>{const m=c.tr,y=di({state:c,transaction:m});if(!(!b2({editor:e,state:y,from:Math.max(u-1,0),to:d.b-1,rule:f,pasteEvent:h,dropEvent:a})||!m.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(c=>new pe({view(u){const d=h=>{var m;r=!((m=u.dom.parentElement)===null||m===void 0)&&m.contains(h.target)?u.dom.parentElement:null,r&&(Ws=e)},f=()=>{Ws&&(Ws=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(o=r===u.dom.parentElement,a=d,!o){const f=Ws;f?.isEditable&&setTimeout(()=>{const h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var f;const h=(f=d.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return i=d,s=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(u,d,f)=>{const h=u[0],m=h.getMeta("uiEvent")==="paste"&&!s,y=h.getMeta("uiEvent")==="drop"&&!o,g=h.getMeta("applyPasteRules"),x=!!g;if(!m&&!y&&!x)return;if(x){let{text:k}=g;typeof k=="string"?k=k:k=Kl($.from(k),f.schema);const{from:N}=g,C=N+k.length,S=v2(k);return l({rule:c,state:f,from:N,to:{b:C},pasteEvt:S})}const b=d.doc.content.findDiffStart(f.doc.content),v=d.doc.content.findDiffEnd(f.doc.content);if(!(!h2(b)||!v||b===v.b))return l({rule:c,state:f,from:b,to:v,pasteEvt:i})}}))}var mi=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=t,this.extensions=Jl(t),this.schema=$p(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n=U(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:tr(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this,e=Jr([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:tr(r.name,this.schema)},o=[],i=U(r,"addKeyboardShortcuts",s);let a={};if(r.type==="mark"&&U(r,"exitable",s)&&(a.ArrowRight=()=>Jn.handleExit({editor:t,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,m])=>[h,()=>m({editor:t})]));a={...a,...f}}const l=pv(a);o.push(l);const c=U(r,"addInputRules",s);if(nd(r,t.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=y2({editor:t,rules:f}),m=Array.isArray(h)?h:[h];o.push(...m)}}const u=U(r,"addPasteRules",s);if(nd(r,t.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=k2({editor:t,rules:f});o.push(...h)}}const d=U(r,"addProseMirrorPlugins",s);if(d){const f=d();o.push(...f)}return o}),n=this.createDecorationPlugin();return n&&e.push(n),e}createDecorationPlugin(){var t;const{editor:e}=this;(t=this.decorationManager)===null||t===void 0||t.destroy();const n=[];return this.extensions.forEach(r=>{const s=U(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:tr(r.name,this.schema)});s&&n.push({name:r.name,addDecorations:s})}),this.decorationManager=new c2({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){return Lp(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=vr(this.extensions);return Object.fromEntries(e.filter(n=>!!U(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s=U(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ee(n.name,this.schema)});if(!s)return[];const o=s();if(!o)return[];const i=(a,l,c,u,d)=>{const f=kr(a,r);return o({node:a,view:l,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:f})};return[n.name,i]}))}dispatchTransaction(t){const{editor:e}=this;return Jr([...this.extensions].reverse()).reduceRight((n,r)=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:tr(r.name,this.schema)},o=U(r,"dispatchTransaction",s);return o?i=>{o.call(s,{transaction:i,next:n})}:n},t)}transformPastedHTML(t){const{editor:e}=this;return Jr([...this.extensions]).reduce((n,r)=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:tr(r.name,this.schema)},o=U(r,"transformPastedHTML",s);return o?(i,a)=>{const l=n(i,a);return o.call(s,l)}:n},t||(n=>n))}get markViews(){const{editor:t}=this,{markExtensions:e}=vr(this.extensions);return Object.fromEntries(e.filter(n=>!!U(n,"addMarkView")).map(n=>{const r=this.attributes.filter(i=>i.type===n.name),s=U(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Jt(n.name,this.schema)});if(!s)return[];const o=(i,a,l)=>{const c=kr(i,r);return s()({mark:i,view:a,inline:l,editor:t,extension:n,HTMLAttributes:c,updateAttributes:u=>{m2(i,t,u)}})};return[n.name,o]}))}destroy(){var t;(t=this.decorationManager)===null||t===void 0||t.destroy(),this.extensions.forEach(e=>{let n=e;for(;n.parent;){const r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:tr(e.name,this.schema)};if(e.type==="mark"){var r,s;(!((r=oe(U(e,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((s=oe(U(e,"clearable",n)))!==null&&s!==void 0)||s||this.nonClearableMarks.push(e.name)}const o=U(e,"onBeforeCreate",n),i=U(e,"onCreate",n),a=U(e,"onUpdate",n),l=U(e,"onSelectionUpdate",n),c=U(e,"onTransaction",n),u=U(e,"onFocus",n),d=U(e,"onBlur",n),f=U(e,"onDestroy",n);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),a&&this.editor.on("update",a),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};mi.resolve=Jl;mi.sort=Jr;mi.flatten=ql;var be=class Zp extends Gl{constructor(...e){super(...e),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Zp(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};const S2=be.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new pe({key:new Ce("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,o=Bp(n),{blockSeparator:i}=this.options,a={...i!==void 0?{blockSeparator:i}:{},textSerializers:o};return[...s.ranges].sort((l,c)=>l.$from.pos-c.$from.pos).map(({$from:l,$to:c})=>_p(r,{from:l.pos,to:c.pos},a)).join(i??`
|
|
25
|
-
|
|
26
|
-
`)}}})]}}),C2=be.create({name:"commands",addCommands(){return{...Yk}}}),w2=be.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r;const s=()=>{var o,i,a;if((o=(i=this.editor.options.coreExtensionOptions)===null||i===void 0||(i=i.delete)===null||i===void 0||(a=i.filterTransaction)===null||a===void 0?void 0:a.call(i,t))!==null&&o!==void 0?o:t.getMeta("y-sync$"))return;const l=Rp(t.before,[t,...e]);pi(l).forEach(u=>{l.mapping.mapResult(u.oldRange.from).deletedAfter&&l.mapping.mapResult(u.oldRange.to).deletedBefore&&l.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,f)=>{const h=f+d.nodeSize-2,m=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:f,to:h,newFrom:l.mapping.map(f),newTo:l.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!m,editor:this.editor,transaction:t,combinedTransform:l})})});const c=l.mapping;l.steps.forEach((u,d)=>{if(u instanceof pt){var f,h;const m=c.slice(d).map(u.from,-1),y=c.slice(d).map(u.to),g=c.invert().map(m,-1),x=c.invert().map(y),b=m>0?(f=l.doc.nodeAt(m-1))===null||f===void 0?void 0:f.marks.some(k=>k.eq(u.mark)):!1,v=(h=l.doc.nodeAt(y))===null||h===void 0?void 0:h.marks.some(k=>k.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:g,to:x},newRange:{from:m,to:y},partial:!!(v||b),editor:this.editor,transaction:t,combinedTransform:l})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(s,0):s()}}),N2=be.create({name:"drop",addProseMirrorPlugins(){return[new pe({key:new Ce("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),M2=be.create({name:"editable",addProseMirrorPlugins(){return[new pe({key:new Ce("editable"),props:{editable:()=>this.editor.options.editable}})]}}),T2=new Ce("focusEvents"),E2=be.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new pe({key:T2,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),D2=be.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:f,parent:h}=d,m=d.parent.isTextblock&&f>0?a.doc.resolve(f-1):d,y=m.parent.type.spec.isolating,g=d.pos-d.parentOffset,x=y&&m.parent.childCount===1?g===d.pos:Y.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!x||x&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return hs()||Ip()?o:s},addProseMirrorPlugins(){return[new pe({key:new Ce("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(h=>h.getMeta("composition")))return;const r=t.some(h=>h.docChanged)&&!e.doc.eq(n.doc),s=t.some(h=>h.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:a}=e.selection,l=Y.atStart(e.doc).from,c=Y.atEnd(e.doc).to;if(o||!(i===l&&a===c)||!Ms(n.doc))return;const u=n.tr,d=di({state:n,transaction:u}),{commands:f}=new hr({editor:this.editor,state:d});if(f.clearNodes(),!!u.steps.length)return u}})]}}),O2=be.create({name:"paste",addProseMirrorPlugins(){return[new pe({key:new Ce("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),A2=be.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new pe({key:new Ce("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:"0"}}}})]}}),I2=be.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=vr(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new pe({key:new Ce("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}});let cd=!1;function j2(t){if(cd)return;cd=!0;let e;try{e=ve.fromJSON(t,{from:0,to:0}).slice.content}catch{return}e instanceof $||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var R2=class Fr{get name(){return this.node.type.name}constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},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?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Fr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Fr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Fr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,i=n.isInline,a=this.pos+r+(o?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(a);if(!s&&!i&&l.depth<=this.depth)return;const c=new Fr(l,this.editor,s,s||i?n:null);s&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const o=s.node.attrs,i=Object.keys(n);for(let a=0;a<i.length;a+=1){const l=i[a];if(o[l]!==n[l])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(n);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>n[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}};const P2=`.ProseMirror {
|
|
27
|
-
position: relative;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.ProseMirror {
|
|
31
|
-
word-wrap: break-word;
|
|
32
|
-
white-space: pre-wrap;
|
|
33
|
-
white-space: break-spaces;
|
|
34
|
-
-webkit-font-variant-ligatures: none;
|
|
35
|
-
font-variant-ligatures: none;
|
|
36
|
-
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.ProseMirror [contenteditable="false"] {
|
|
40
|
-
white-space: normal;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
44
|
-
white-space: pre-wrap;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.ProseMirror pre {
|
|
48
|
-
white-space: pre-wrap;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
img.ProseMirror-separator {
|
|
52
|
-
display: inline !important;
|
|
53
|
-
border: none !important;
|
|
54
|
-
margin: 0 !important;
|
|
55
|
-
width: 0 !important;
|
|
56
|
-
height: 0 !important;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.ProseMirror-gapcursor {
|
|
60
|
-
display: none;
|
|
61
|
-
pointer-events: none;
|
|
62
|
-
position: absolute;
|
|
63
|
-
margin: 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.ProseMirror-gapcursor:after {
|
|
67
|
-
content: "";
|
|
68
|
-
display: block;
|
|
69
|
-
position: absolute;
|
|
70
|
-
top: -2px;
|
|
71
|
-
width: 20px;
|
|
72
|
-
border-top: 1px solid black;
|
|
73
|
-
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@keyframes ProseMirror-cursor-blink {
|
|
77
|
-
to {
|
|
78
|
-
visibility: hidden;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.ProseMirror-hideselection *::selection {
|
|
83
|
-
background: transparent;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.ProseMirror-hideselection *::-moz-selection {
|
|
87
|
-
background: transparent;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.ProseMirror-hideselection * {
|
|
91
|
-
caret-color: transparent;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
95
|
-
display: block;
|
|
96
|
-
}`;var L2=class extends Xk{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?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:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:wk,createMappablePosition:Nk},this.setOptions(t),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:n,slice:r,moved:s})=>this.options.onDrop(n,r,s)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);const e=this.createDoc();if(!this.editorState){const n=Pa(e,this.options.autofocus);this.editorState=Cn.create({doc:e,schema:this.schema,selection:n||void 0})}j2(this.schema),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():hr.createFakeChain()}can(){return this.commandManager?this.commandManager.can():hr.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=f2(P2,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&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:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Pp(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;n=n.filter(i=>!i.key.startsWith(o))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[M2,S2.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),C2,E2,D2,A2.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),N2,O2,w2,I2.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new mi(n,this)}createCommandManager(){this.commandManager=new hr({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=$a(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;const n=$a(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Cn.create({doc:n,schema:this.schema,selection:Pa(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,o=e.transformPastedHTML,i=this.extensionManager.transformPastedHTML(o);this.editorView=new Cp(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const l=this.view.dom;l.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(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=i?.getMeta("focus"),l=i?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:i}),l&&this.emit("blur",{editor:this,event:l.event,transaction:i}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return zp(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return vk(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Kl(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
|
|
97
|
-
|
|
98
|
-
`,textSerializers:n={}}=t||{};return hk(this.state.doc,{blockSeparator:e,textSerializers:{...Bp(this.schema),...n}})}get isEmpty(){return Ms(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new R2(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Un(t){return new Ts({find:t.find,handler:({state:e,range:n,match:r})=>{const s=oe(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],a=r[0];if(i){const l=a.search(/\S/),c=n.from+a.indexOf(i),u=c+i.length;if(Yl(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===t.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+l,c);const d=n.from+l+i.length;o.addMark(n.from+l,d,t.type.create(s||{})),o.removeStoredMark(t.type)}},undoable:t.undoable})}function $2(t){return new Ts({find:t.find,handler:({state:e,range:n,match:r})=>{const s=oe(t.getAttributes,void 0,r)||{},{tr:o}=e,i=n.from;let a=n.to;const l=t.type.create(s);if(r[1]){let c=i+r[0].lastIndexOf(r[1]);c>a?c=a:a=c+r[1].length;const u=r[0][r[0].length-1];o.insertText(u,i+r[0].length-1),o.replaceWith(c,a,l)}else if(r[0]){const c=t.type.isInline?i:i-1;o.insert(c,t.type.create(s)).delete(o.mapping.map(i),o.mapping.map(a))}o.scrollIntoView()},undoable:t.undoable})}function Ba(t){return new Ts({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),o=oe(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)},undoable:t.undoable})}function Sr(t){return new Ts({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const o=oe(t.getAttributes,void 0,r)||{},i=e.tr.delete(n.from,n.to),a=i.doc.resolve(n.from).blockRange(),l=a&&El(a,t.type,o);if(!l)return null;if(i.wrap(a,l),t.keepMarks&&t.editor){const{selection:u,storedMarks:d}=e,{splittableMarks:f}=t.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){const m=h.filter(y=>f.includes(y.type.name));i.ensureMarks(m)}}if(t.keepAttributes){const u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,o).run()}const c=i.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&pn(i.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&i.join(n.from-1)},undoable:t.undoable})}const _2=t=>"touches"in t;var rA=class{constructor(t){var e,n,r,s,o,i;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=a=>{if(!this.isResizing||!this.activeHandle)return;const l=a.clientX-this.startX,c=a.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=a=>{if(!this.isResizing||!this.activeHandle)return;const l=a.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const a=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(a,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,!((e=t.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...t.options.min}),!((n=t.options)===null||n===void 0)&&n.max&&(this.maxSize=t.options.max),!(t==null||(r=t.options)===null||r===void 0)&&r.directions&&(this.directions=t.options.directions),!((s=t.options)===null||s===void 0)&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),!((o=t.options)===null||o===void 0)&&o.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),!((i=t.options)===null||i===void 0)&&i.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!==null&&t!==void 0?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),o=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),o&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,_2(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),o=this.applyConstraints(r,s,n);this.element.style.width=`${o.width}px`,this.element.style.height=`${o.height}px`,this.onResize&&this.onResize(o.width,o.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const o=t.includes("right"),i=t.includes("left"),a=t.includes("bottom"),l=t.includes("top");return o?r=this.startWidth+e:i&&(r=this.startWidth-e),a?s=this.startHeight+n:l&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(o?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(a?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s;if(!n){var o,i;let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return!((o=this.maxSize)===null||o===void 0)&&o.width&&(c=Math.min(this.maxSize.width,c)),!((i=this.maxSize)===null||i===void 0)&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let a=t,l=e;return a<this.minSize.width&&(a=this.minSize.width,l=a/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,a=l*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&a>this.maxSize.width&&(a=this.maxSize.width,l=a/this.aspectRatio),!((s=this.maxSize)===null||s===void 0)&&s.height&&l>this.maxSize.height&&(l=this.maxSize.height,a=l*this.aspectRatio),{width:a,height:l}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}},qe=class em extends Gl{constructor(...e){super(...e),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new em(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},B2=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=()=>{try{return e.getPos()}catch{return}},this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n;const{view:r}=this.editor,s=t.target,o=s.nodeType===3?(e=s.parentElement)===null||e===void 0?void 0:e.closest("[data-drag-handle]"):s.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(s)||!o)return;let i=0,a=0;if(this.dom!==o){var l,c,u,d;const b=this.dom.getBoundingClientRect(),v=o.getBoundingClientRect(),k=(l=t.offsetX)!==null&&l!==void 0?l:(c=t.nativeEvent)===null||c===void 0?void 0:c.offsetX,N=(u=t.offsetY)!==null&&u!==void 0?u:(d=t.nativeEvent)===null||d===void 0?void 0:d.offsetY;i=v.x-b.x+k,a=v.y-b.y+N}const f=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();f.style.width=`${Math.round(b.width)}px`,f.style.height=`${Math.round(b.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let h=null;try{var m;h=document.createElement("div"),h.style.position="absolute",h.style.top="-9999px",h.style.left="-9999px",h.style.pointerEvents="none",h.appendChild(f),document.body.appendChild(h),(m=t.dataTransfer)===null||m===void 0||m.setDragImage(f,i,a)}finally{h&&setTimeout(()=>{try{h?.remove()}catch{}},0)}const y=this.getPos();if(typeof y!="number")return;const g=H.create(r.state.doc,y),x=r.state.tr.setSelection(g);r.dispatch(x)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!(!((e=this.contentDOM)===null||e===void 0)&&e.contains(n))))return!1;const r=t.type.startsWith("drag"),s=t.type==="dragover"||t.type==="dragenter",o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!r)return!0;const{isEditable:i}=this.editor,{isDragging:a}=this,l=!!this.node.type.spec.draggable,c=H.isSelectable(this.node),u=t.type==="copy",d=t.type==="paste",f=t.type==="cut",h=t.type==="mousedown";if(!l&&c&&r&&t.target===this.dom&&t.preventDefault(),l&&r&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(l&&i&&!a&&h){const m=n.closest("[data-drag-handle]");m&&(this.dom===m||this.dom.contains(m))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||s||o||u||d||f||h&&c)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(hs()||La())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(e=>e.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function hn(t){return new Qp({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const o=oe(t.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const u=l.search(/\S/),d=n.from+l.indexOf(a),f=d+a.length;if(Yl(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>d).length)return null;f<n.to&&i.delete(f,n.to),d>n.from&&i.delete(n.from+u,d),c=n.from+u+a.length,i.addMark(n.from+u,c,t.type.create(o||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||i.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:z2,getOwnPropertySymbols:F2}=Object,{hasOwnProperty:H2}=Object.prototype;function Wi(t,e){return function(r,s,o){return t(r,s,o)&&e(r,s,o)}}function Vs(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:o}=s,i=o.get(n),a=o.get(r);if(i&&a)return i===r&&a===n;o.set(n,r),o.set(r,n);const l=t(n,r,s);return o.delete(n),o.delete(r),l}}function W2(t){return t?.[Symbol.toStringTag]}function ud(t){return z2(t).concat(F2(t))}const V2=Object.hasOwn||((t,e)=>H2.call(t,e));function Yn(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const U2="__v",q2="__o",K2="_owner",{getOwnPropertyDescriptor:dd,keys:fd}=Object;function J2(t,e){return t.byteLength===e.byteLength&&yo(new Uint8Array(t),new Uint8Array(e))}function Y2(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function G2(t,e){return t.byteLength===e.byteLength&&yo(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function X2(t,e){return Yn(t.getTime(),e.getTime())}function Q2(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function Z2(t,e){return t===e}function hd(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=t.entries();let i,a,l=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let u=!1,d=0;for(;(a=c.next())&&!a.done;){if(s[d]){d++;continue}const f=i.value,h=a.value;if(n.equals(f[0],h[0],l,d,t,e,n)&&n.equals(f[1],h[1],f[0],h[0],t,e,n)){u=s[d]=!0;break}d++}if(!u)return!1;l++}return!0}const eS=Yn;function tS(t,e,n){const r=fd(t);let s=r.length;if(fd(e).length!==s)return!1;for(;s-- >0;)if(!tm(t,e,n,r[s]))return!1;return!0}function Ir(t,e,n){const r=ud(t);let s=r.length;if(ud(e).length!==s)return!1;let o,i,a;for(;s-- >0;)if(o=r[s],!tm(t,e,n,o)||(i=dd(t,o),a=dd(e,o),(i||a)&&(!i||!a||i.configurable!==a.configurable||i.enumerable!==a.enumerable||i.writable!==a.writable)))return!1;return!0}function nS(t,e){return Yn(t.valueOf(),e.valueOf())}function rS(t,e){return t.source===e.source&&t.flags===e.flags}function pd(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=t.values();let i,a;for(;(i=o.next())&&!i.done;){const l=e.values();let c=!1,u=0;for(;(a=l.next())&&!a.done;){if(!s[u]&&n.equals(i.value,a.value,i.value,a.value,t,e,n)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function yo(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function sS(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function tm(t,e,n,r){return(r===K2||r===q2||r===U2)&&(t.$$typeof||e.$$typeof)?!0:V2(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const oS="[object ArrayBuffer]",iS="[object Arguments]",aS="[object Boolean]",lS="[object DataView]",cS="[object Date]",uS="[object Error]",dS="[object Map]",fS="[object Number]",hS="[object Object]",pS="[object RegExp]",mS="[object Set]",gS="[object String]",yS={"[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},xS="[object URL]",bS=Object.prototype.toString;function vS({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:m}){return function(g,x,b){if(g===x)return!0;if(g==null||x==null)return!1;const v=typeof g;if(v!==typeof x)return!1;if(v!=="object")return v==="number"?a(g,x,b):v==="function"?o(g,x,b):!1;const k=g.constructor;if(k!==x.constructor)return!1;if(k===Object)return l(g,x,b);if(Array.isArray(g))return e(g,x,b);if(k===Date)return r(g,x,b);if(k===RegExp)return u(g,x,b);if(k===Map)return i(g,x,b);if(k===Set)return d(g,x,b);const N=bS.call(g);if(N===cS)return r(g,x,b);if(N===pS)return u(g,x,b);if(N===dS)return i(g,x,b);if(N===mS)return d(g,x,b);if(N===hS)return typeof g.then!="function"&&typeof x.then!="function"&&l(g,x,b);if(N===xS)return h(g,x,b);if(N===uS)return s(g,x,b);if(N===iS)return l(g,x,b);if(yS[N])return f(g,x,b);if(N===oS)return t(g,x,b);if(N===lS)return n(g,x,b);if(N===aS||N===fS||N===gS)return c(g,x,b);if(m){let C=m[N];if(!C){const S=W2(g);S&&(C=m[S])}if(C)return C(g,x,b)}return!1}}function kS({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:J2,areArraysEqual:n?Ir:Y2,areDataViewsEqual:G2,areDatesEqual:X2,areErrorsEqual:Q2,areFunctionsEqual:Z2,areMapsEqual:n?Wi(hd,Ir):hd,areNumbersEqual:eS,areObjectsEqual:n?Ir:tS,arePrimitiveWrappersEqual:nS,areRegExpsEqual:rS,areSetsEqual:n?Wi(pd,Ir):pd,areTypedArraysEqual:n?Wi(yo,Ir):yo,areUrlsEqual:sS,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=Vs(r.areArraysEqual),o=Vs(r.areMapsEqual),i=Vs(r.areObjectsEqual),a=Vs(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:a})}return r}function SS(t){return function(e,n,r,s,o,i,a){return t(e,n,a)}}function CS({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(a,l){const{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(a,l,{cache:c,equals:r,meta:u,strict:s})};if(t)return function(a,l){return e(a,l,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(a,l){return e(a,l,o)}}const wS=gn();gn({strict:!0});gn({circular:!0});gn({circular:!0,strict:!0});gn({createInternalComparator:()=>Yn});gn({strict:!0,createInternalComparator:()=>Yn});gn({circular:!0,createInternalComparator:()=>Yn});gn({circular:!0,createInternalComparator:()=>Yn,strict:!0});function gn(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,o=kS(t),i=vS(o),a=n?n(i):SS(i);return CS({circular:e,comparator:i,createState:r,equals:a,strict:s})}const NS=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},MS=({contentComponent:t})=>{const e=pf.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function TS(){const t=new Set;let e={},n=!1;const r=()=>{n||!t.size||(n=!0,queueMicrotask(()=>{n=!1,t.forEach(s=>s())}))};return{subscribe(s){return t.add(s),()=>{t.delete(s)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(s,o){e={...e,[s]:v1.createPortal(o.reactElement,o.element,s)},r()},removeRenderer(s){const o={...e};delete o[s],e=o,r()}}}var ES=class extends $n.Component{constructor(t){super(t),this.editorContentRef=$n.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&(!((t=e.view.dom)===null||t===void 0)&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=TS(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){const t=this.props.editor;if(t){t.isEditorContentInitialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),t.contentComponent=null;try{var e;if(!(!((e=t.view.dom)===null||e===void 0)&&e.parentNode))return;const n=document.createElement("div");n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:NS(e,this.editorContentRef),...n}),t?.contentComponent&&p.jsx(MS,{contentComponent:t.contentComponent})]})}};const DS=L.forwardRef((t,e)=>{const n=$n.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return $n.createElement(ES,{key:n,innerRef:e,...t})}),nm=$n.memo(DS),OS=typeof window<"u"?L.useLayoutEffect:L.useEffect;var AS=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,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.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){let e;const n=s=>{s?.transaction!==void 0&&s.transaction===e||(e=s?.transaction,this.transactionNumber+=1,this.subscribers.forEach(o=>o()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function IS(t){var e;const[n]=L.useState(()=>new AS(t.editor)),r=x1.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:wS);return OS(()=>n.watch(t.editor),[t.editor,n]),L.useDebugValue(r),r}const jS=!1,rm=typeof window>"u",RS=rm||!!(typeof window<"u"&&window.next);var PS=class sm{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(n=>n())}getInitialEditor(){const e=this.options.current.immediatelyRender;let n=e??!0;return rm?(n&&jS&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),n=!1):RS&&e===void 0&&(n=!1),n?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...n)=>{var r,s;return(r=(s=this.options.current).onBeforeCreate)===null||r===void 0?void 0:r.call(s,...n)},onBlur:(...n)=>{var r,s;return(r=(s=this.options.current).onBlur)===null||r===void 0?void 0:r.call(s,...n)},onCreate:(...n)=>{var r,s;return(r=(s=this.options.current).onCreate)===null||r===void 0?void 0:r.call(s,...n)},onDestroy:(...n)=>{var r,s;return(r=(s=this.options.current).onDestroy)===null||r===void 0?void 0:r.call(s,...n)},onFocus:(...n)=>{var r,s;return(r=(s=this.options.current).onFocus)===null||r===void 0?void 0:r.call(s,...n)},onSelectionUpdate:(...n)=>{var r,s;return(r=(s=this.options.current).onSelectionUpdate)===null||r===void 0?void 0:r.call(s,...n)},onTransaction:(...n)=>{var r,s;return(r=(s=this.options.current).onTransaction)===null||r===void 0?void 0:r.call(s,...n)},onUpdate:(...n)=>{var r,s;return(r=(s=this.options.current).onUpdate)===null||r===void 0?void 0:r.call(s,...n)},onContentError:(...n)=>{var r,s;return(r=(s=this.options.current).onContentError)===null||r===void 0?void 0:r.call(s,...n)},onDrop:(...n)=>{var r,s;return(r=(s=this.options.current).onDrop)===null||r===void 0?void 0:r.call(s,...n)},onPaste:(...n)=>{var r,s;return(r=(s=this.options.current).onPaste)===null||r===void 0?void 0:r.call(s,...n)},onDelete:(...n)=>{var r,s;return(r=(s=this.options.current).onDelete)===null||r===void 0?void 0:r.call(s,...n)},onMount:(...n)=>{var r,s;return(r=(s=this.options.current).onMount)===null||r===void 0?void 0:r.call(s,...n)},onUnmount:(...n)=>{var r,s;return(r=(s=this.options.current).onUnmount)===null||r===void 0?void 0:r.call(s,...n)}};return new L2(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=n.extensions)===null||i===void 0?void 0:i[o])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?sm.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((n,r)=>n===e[r]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function LS(t={},e=[]){const n=L.useRef(t);n.current=t;const[r]=L.useState(()=>new PS(n)),s=pf.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return L.useDebugValue(s),L.useEffect(r.onRender(e)),IS({editor:s,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&o===0?0:o+1}),s}const Xl=L.createContext({editor:null});Xl.Consumer;const sA=()=>L.useContext(Xl),om=L.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),$S=()=>L.useContext(om),im=$n.forwardRef((t,e)=>{const{onDragStart:n}=$S(),r=t.as||"div";return p.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function md(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function gd(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function _S(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function BS(t){if(md(t)||gd(t))return!0;if(_S(t)){const e=t.type;if(e)return md(e)||gd(e)}return!1}function zS(){try{if(L.version)return parseInt(L.version.split(".")[0],10)>=19}catch{}return!1}var FS=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isEditorContentInitialized?b1.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,s=zS(),o=BS(e),i={...n};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=a=>{this.ref=a}),this.reactElement=p.jsx(e,{...i}),r==null||(t=r.contentComponent)===null||t===void 0||t.setRenderer(this.id,this)}updateProps(t={}){if(this.destroyed)return;let e=!1;const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const s=n[r];if(t[s]!==this.props[s]){e=!0;break}}e&&(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;e==null||(t=e.contentComponent)===null||t===void 0||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};$n.createContext({markViewContentRef:()=>{}});function HS(t){var e;const n=t.getRootNode(),r=typeof n.getSelection=="function"?n.getSelection():(e=t.ownerDocument)===null||e===void 0||(e=e.defaultView)===null||e===void 0?void 0:e.getSelection();if(!r||r.rangeCount===0)return null;const{anchorNode:s,anchorOffset:o,focusNode:i,focusOffset:a}=r;return!s||!i||!t.contains(s)||!t.contains(i)?null:()=>{try{r.setBaseAndExtent(s,o,i,a)}catch{}}}var WS=class extends B2{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.handlePositionUpdate=()=>{const r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");r?r.appendChild(this.contentDOMElement):this.dom.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,s){if(r==="storage"){var o;return(o=t.storage[e.name])!==null&&o!==void 0?o:{}}return Reflect.get(n,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode(),ref:L.createRef()};if(!this.component.displayName){const l=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=l(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{if(l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement){l.hasAttribute("data-node-view-wrapper")&&l.removeAttribute("data-node-view-wrapper");const c=HS(this.contentDOMElement);l.appendChild(this.contentDOMElement),c?.()}}},s=this.component,o=L.memo(l=>p.jsx(om.Provider,{value:r,children:L.createElement(s,l)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new FS(o,{editor:this.editor,props:t,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var t;if(this.renderer.element.firstElementChild&&!(!((t=this.renderer.element.firstElementChild)===null||t===void 0)&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{var t;this.selectionRafId=null;const e=(t=this.getPos())!==null&&t!==void 0?t:this.currentPos;if(typeof e=="number")if(Ck({selection:this.editor.state.selection,pos:e,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,a=this.decorations,l=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:i,oldDecorations:a,newNode:t,newDecorations:e,oldInnerDecorations:l,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(t===this.node)return this.node=t,this.decorations=e,this.innerDecorations=n,!0;const s=this.getPos();this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=s;const o={node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(o.getPos=()=>this.getPos()),r(o),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=kr(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function am(t,e){return n=>n.editor.contentComponent?new WS(t,n,e):{dom:document.createElement("span"),contentDOM:null,update:()=>!1,destroy:()=>{},selectNode:()=>{},deselectNode:()=>{},stopEvent:()=>!1,ignoreMutation:()=>!0}}const Ql=L.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Ql.displayName="TiptapContext";const VS=()=>L.useContext(Ql);function lm({children:t,...e}){const n="editor"in e?e.editor:e.instance;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const r=L.useMemo(()=>({editor:n}),[n]),s=L.useMemo(()=>({editor:n}),[n]);return p.jsx(Xl.Provider,{value:s,children:p.jsx(Ql.Provider,{value:r,children:t})})}lm.displayName="Tiptap";function cm({...t}){const{editor:e}=VS();return p.jsx(nm,{editor:e,...t})}cm.displayName="Tiptap.Content";Object.assign(lm,{Content:cm});function US(t){return t.storage.mention}function oA(t,e,n){t.chain().focus().insertContentAt(e,[um(n),{type:"text",text:" "}]).run()}function um(t){return{type:"mention",attrs:t}}function iA(t,e,n){const r=t.state.doc.nodeAt(e);return r?.type.name==="mention"&&r.attrs.id===n}function qS(t){const e=_.c(34),{node:n,selected:r,view:s,editor:o,getPos:i}=t,{name:a,char:l,kind:c,id:u,args:d}=n.attrs,f=J(),h=r&&s.editable,m=c==="task",y=l==="@",g=s.editable&&l==="/"&&(c==="prompt"||c===void 0);let x;e[0]!==d||e[1]!==o||e[2]!==i||e[3]!==u||e[4]!==a?(x=()=>{const z=US(o)?.onEditChip;if(!z||typeof i!="function")return;const W=i();typeof W=="number"&&z({promptId:u,promptName:a,args:d??{},pos:W})},e[0]=d,e[1]=o,e[2]=i,e[3]=u,e[4]=a,e[5]=x):x=e[5];const b=x;let v;e[6]!==g||e[7]!==b?(v=R=>{g&&(R.preventDefault(),R.stopPropagation(),b())},e[6]=g,e[7]=b,e[8]=v):v=e[8];const k=v;let N;e[9]!==g||e[10]!==b?(N=R=>{g&&(R.key!=="Enter"&&R.key!==" "||(R.preventDefault(),R.stopPropagation(),b()))},e[9]=g,e[10]=b,e[11]=N):N=e[11];const C=N,S=g?"button":void 0,w=g?0:void 0;let M;e[12]!==g||e[13]!==a||e[14]!==f?(M=g?f("chat.mention.editPrompt",{name:a?ga(a):""}):void 0,e[12]=g,e[13]=a,e[14]=f,e[15]=M):M=e[15];const T=g?"cursor-pointer":"cursor-default",O=y?"bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",A=h&&"outline-2 outline-blue-300 outline-offset-0",P=g&&"hover:brightness-95",D=!m&&"capitalize";let E;e[16]!==D||e[17]!==T||e[18]!==O||e[19]!==A||e[20]!==P?(E=G("px-1 py-1 rounded","inline-flex items-center gap-1",T,"select-none","text-xs font-light",O,A,P,D),e[16]=D,e[17]=T,e[18]=O,e[19]=A,e[20]=P,e[21]=E):E=e[21];let j;e[22]!==m||e[23]!==a?(j=m?p.jsx("span",{className:"inline-block max-w-[220px] truncate align-bottom",children:a??""}):a?ga(a):"",e[22]=m,e[23]=a,e[24]=j):j=e[24];let I;return e[25]!==l||e[26]!==k||e[27]!==C||e[28]!==E||e[29]!==j||e[30]!==S||e[31]!==w||e[32]!==M?(I=p.jsxs(im,{onClick:k,onKeyDown:C,role:S,tabIndex:w,"aria-label":M,className:E,children:[l,j]}),e[25]=l,e[26]=k,e[27]=C,e[28]=E,e[29]=j,e[30]=S,e[31]=w,e[32]=M,e[33]=I):I=e[33],I}const KS=qe.create({name:"mention",group:"inline",inline:!0,atom:!0,addStorage(){return{onEditChip:null}},addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id")||null,renderHTML:t=>t.id?{"data-id":t.id}:{}},name:{default:null,parseHTML:t=>t.getAttribute("data-name")||null,renderHTML:t=>t.name?{"data-name":t.name}:{}},char:{default:"/",parseHTML:t=>t.getAttribute("data-char")||"/",renderHTML:t=>t.char?{"data-char":t.char}:{}},metadata:{default:null,parseHTML:t=>{try{return JSON.parse(t.getAttribute("data-metadata")||"null")}catch{return null}},renderHTML:t=>t.metadata?{"data-metadata":JSON.stringify(t.metadata)}:{}},kind:{default:void 0,parseHTML:t=>t.getAttribute("data-kind")||void 0,renderHTML:t=>t.kind?{"data-kind":t.kind}:{}},args:{default:null,parseHTML:t=>{try{return JSON.parse(t.getAttribute("data-args")||"null")}catch{return null}},renderHTML:t=>t.args?{"data-args":JSON.stringify(t.args)}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'}]},renderHTML({HTMLAttributes:t}){return["span",Se(t,{"data-type":"mention"})]},renderText({node:t}){const e=t.attrs.char??"@",n=t.attrs.name??"";return`${e}${n}`},addNodeView(){return am(qS)}}),JS=/^mcp__[a-zA-Z0-9_-]+__/;function dm(t){return t.replace(JS,"")}function gi(t){const e=_.c(19),{id:n,part:r,copyable:s,extraActions:o,alwaysShowActions:i,animate:a}=t,l=s===void 0?!1:s,c=i===void 0?!1:i,u=a===void 0?!1:a,{handleCopy:d}=$f(),f=J(),[h,m]=L.useState(!1);let y;e[0]!==d||e[1]!==n||e[2]!==r.text?(y=async()=>{k1("chat_message_copied",{message_id:n,chars:r.text.length}),await d(r.text),m(!0),setTimeout(()=>m(!1),2e3)},e[0]=d,e[1]=n,e[2]=r.text,e[3]=y):y=e[3];const g=y,x=l&&o,b=x||o;let v;e[4]!==u||e[5]!==n||e[6]!==r.text?(v=p.jsx(vl,{id:n,text:r.text,animate:u}),e[4]=u,e[5]=n,e[6]=r.text,e[7]=v):v=e[7];let k;e[8]!==c||e[9]!==o||e[10]!==g||e[11]!==h||e[12]!==b||e[13]!==x||e[14]!==f?(k=b&&p.jsxs("div",{className:G("flex w-full items-center gap-2 text-sm text-muted-foreground transition-all duration-200 mt-1 py-1",c?"opacity-100":"opacity-0 pointer-events-none group-hover/part:opacity-100 group-hover/part:pointer-events-auto"),children:[o,x&&o&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),x&&p.jsx("button",{type:"button",onClick:g,className:"text-muted-foreground [@media(hover:hover)]:hover:text-foreground transition-colors active:scale-[0.97]","aria-label":f("chat.textPart.copyMessage"),children:h?p.jsx(xl,{className:"size-4"}):p.jsx(Lf,{className:"size-4"})})]}),e[8]=c,e[9]=o,e[10]=g,e[11]=h,e[12]=b,e[13]=x,e[14]=f,e[15]=k):k=e[15];let N;return e[16]!==v||e[17]!==k?(N=p.jsxs("div",{className:"group/part relative",children:[v,k]}),e[16]=v,e[17]=k,e[18]=N):N=e[18],N}function aA(t,e,n){t.chain().focus().insertContentAt(e,[YS(n),{type:"text",text:" "}]).run()}function YS(t){return{type:"file",attrs:t}}function GS(t){const e=_.c(17),{node:n,selected:r,view:s}=t,{name:o,mimeType:i,data:a}=n.attrs,l=r&&s.editable;let c;e[0]!==i?(c=i.startsWith("image/"),e[0]=i,e[1]=c):c=e[1];const u=c,d=l&&"outline-2 outline-blue-300 outline-offset-0";let f;e[2]!==d?(f=G("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light","bg-muted text-muted-foreground",d),e[2]=d,e[3]=f):f=e[3];let h;e[4]!==o?(h=p.jsx(_n,{asChild:!0,children:p.jsx("span",{children:o})}),e[4]=o,e[5]=h):h=e[5];let m;e[6]!==a||e[7]!==u||e[8]!==i||e[9]!==o?(m=p.jsx(Bn,{side:"top",className:"max-w-sm p-1.5",children:u?p.jsx("img",{src:`data:${i};base64,${a}`,alt:o,className:"max-w-full max-h-64 object-contain rounded"}):p.jsxs("div",{className:"text-xs",children:[p.jsx("div",{className:"font-medium",children:o}),p.jsx("div",{className:"text-muted-foreground mt-1",children:i})]})}),e[6]=a,e[7]=u,e[8]=i,e[9]=o,e[10]=m):m=e[10];let y;e[11]!==h||e[12]!==m?(y=p.jsxs(zn,{children:[h,m]}),e[11]=h,e[12]=m,e[13]=y):y=e[13];let g;return e[14]!==f||e[15]!==y?(g=p.jsx(im,{className:f,children:y}),e[14]=f,e[15]=y,e[16]=g):g=e[16],g}const XS=qe.create({name:"file",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id")||null,renderHTML:t=>t.id?{"data-id":t.id}:{}},name:{default:null,parseHTML:t=>t.getAttribute("data-name")||null,renderHTML:t=>t.name?{"data-name":t.name}:{}},mimeType:{default:null,parseHTML:t=>t.getAttribute("data-mime-type")||null,renderHTML:t=>t.mimeType?{"data-mime-type":t.mimeType}:{}},size:{default:0,parseHTML:t=>{const e=t.getAttribute("data-size");return e?Number.parseInt(e,10):0},renderHTML:t=>t.size?{"data-size":String(t.size)}:{}},data:{default:null,parseHTML:t=>t.getAttribute("data-data")||null,renderHTML:t=>t.data?{"data-data":t.data}:{}}}},parseHTML(){return[{tag:'span[data-type="file"]'}]},renderHTML({node:t,HTMLAttributes:e}){const n={"data-type":"file"};return t.attrs.id&&(n["data-id"]=t.attrs.id),t.attrs.name&&(n["data-name"]=t.attrs.name),t.attrs.mimeType&&(n["data-mime-type"]=t.attrs.mimeType),t.attrs.size&&(n["data-size"]=String(t.attrs.size)),t.attrs.data&&(n["data-data"]=t.attrs.data),["span",{...e,...n}]},renderText({node:t}){return`[${t.attrs.name??""}]`},addNodeView(){return am(GS)}});function QS(t={}){return new pe({view(e){return new ZS(e,t)}})}class ZS{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,a=o.height/s.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),y=d?m.bottom:m.top;d&&f&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:m.left,right:m.right,top:y-g,bottom:y+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=l.getBoundingClientRect(),f=d.width/l.offsetWidth,h=d.height/l.offsetHeight;c=d.left-l.scrollLeft*f,u=d.top-l.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!o){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Dl(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Gn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},fm=function(t,e,n,r){return n&&(yd(t,e,n,r,-1)||yd(t,e,n,r,1))},eC=/^(img|br|input|textarea|hr)$/i;function yd(t,e,n,r,s){for(var o;;){if(t==n&&e==r)return!0;if(e==(s<0?0:xo(t))){let i=t.parentNode;if(!i||i.nodeType!=1||Zl(t)||eC.test(t.nodeName)||t.contentEditable=="false")return!1;e=Gn(t)+(s<0?0:1),t=i}else if(t.nodeType==1){let i=t.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else t=i,e=s<0?xo(t):0}else return!1}}function xo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function tC(t,e,n){for(let r=e==0,s=e==xo(t);r||s;){if(t==n)return!0;let o=Gn(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,s=s&&o==xo(t)}}function Zl(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const hm=function(t){return t.focusNode&&fm(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function pm(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Ot=typeof navigator<"u"?navigator:null,xd=typeof document<"u"?document:null,yn=Ot&&Ot.userAgent||"",za=/Edge\/(\d+)/.exec(yn),mm=/MSIE \d/.exec(yn),Fa=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yn),Es=!!(mm||Fa||za),gm=mm?document.documentMode:Fa?+Fa[1]:za?+za[1]:0,yi=!Es&&/gecko\/(\d+)/i.test(yn);yi&&+(/Firefox\/(\d+)/.exec(yn)||[0,0])[1];const Ha=!Es&&/Chrome\/(\d+)/.exec(yn),Yt=!!Ha,ym=Ha?+Ha[1]:0,Xn=!Es&&!!Ot&&/Apple Computer/.test(Ot.vendor),ec=Xn&&(/Mobile\/\w+/.test(yn)||!!Ot&&Ot.maxTouchPoints>2),it=ec||(Ot?/Mac/.test(Ot.platform):!1),xm=Ot?/Win/.test(Ot.platform):!1,Ds=/Android \d/.test(yn),tc=!!xd&&"webkitFontSmoothing"in xd.documentElement.style,nC=tc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function rC(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),o=s&&s.size==0,i=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let a=r.resolve(i),l,c;if(hm(n)){for(l=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&H.isSelectable(d)&&s.parent&&!(d.isInline&&tC(n.focusNode,n.focusOffset,s.dom))){let f=s.posBefore;c=new H(i==f?a:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,f=i;for(let h=0;h<n.rangeCount;h++){let m=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[l,i]=f==t.state.selection.anchor?[f,d]:[d,f],a=r.resolve(i)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let d=e=="pointer"||t.state.selection.head<a.pos&&!o?1:-1;c=vm(t,u,a,d)}return c}function bm(t){return t.editable?t.hasFocus():aC(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function nc(t,e=!1){let n=t.state.selection;if(iC(t,n),!!bm(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Yt){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&fm(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)oC(t);else{let{anchor:r,head:s}=n,o,i;bd&&!(n instanceof V)&&(n.$from.parent.inlineContent||(o=vd(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=vd(t,n.to))),t.docView.setSelection(r,s,t,e),bd&&(o&&kd(o),i&&kd(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&sC(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const bd=Xn||Yt&&ym<63;function vd(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(Xn&&s&&s.contentEditable=="false")return Vi(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Vi(s);if(o)return Vi(o)}}function Vi(t){return t.contentEditable="true",Xn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function kd(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function sC(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!bm(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function oC(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Gn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Es&&gm<=11&&(n.disabled=!0,n.disabled=!1)}function iC(t,e){if(e instanceof H){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Sd(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Sd(t)}function Sd(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function vm(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||V.between(e,n,r)}function aC(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Wa(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return o&&Y.findFrom(o,e)}function tn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Cd(t,e,n){let r=t.state.selection;if(r instanceof V)if(n.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=t.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return tn(t,new V(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Wa(t.state,e);return s&&s instanceof H?tn(t,s):!1}else if(!(it&&n.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let a=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=t.docView.descAt(a))&&!i.contentDOM?H.isSelectable(o)?tn(t,new H(e<0?t.state.doc.resolve(s.pos-o.nodeSize):s)):tc?tn(t,new V(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof H&&r.node.isInline)return tn(t,new V(e>0?r.$to:r.$from));{let s=Wa(t.state,e);return s?tn(t,s):!1}}}function bo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Yr(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function nr(t,e){return e<0?lC(t):cC(t)}function lC(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,o,i=!1;for(yi&&n.nodeType==1&&r<bo(n)&&Yr(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Yr(a,-1))s=n,o=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(km(n))break;{let a=n.previousSibling;for(;a&&Yr(a,-1);)s=n.parentNode,o=Gn(a),a=a.previousSibling;if(a)n=a,r=bo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?Va(t,n,r):s&&Va(t,s,o)}function cC(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=bo(n),o,i;for(;;)if(r<s){if(n.nodeType!=1)break;let a=n.childNodes[r];if(Yr(a,1))o=n,i=++r;else break}else{if(km(n))break;{let a=n.nextSibling;for(;a&&Yr(a,1);)o=a.parentNode,i=Gn(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=bo(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}o&&Va(t,o,i)}function km(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function uC(t,e){for(;t&&e==t.childNodes.length&&!Zl(t);)e=Gn(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function dC(t,e){for(;t&&!e&&!Zl(t);)e=Gn(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Va(t,e,n){if(e.nodeType!=3){let o,i;(i=uC(e,n))?(e=i,n=0):(o=dC(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(hm(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&nc(t)},50)}function wd(t,e){let n=t.state.doc.resolve(e);if(!(Yt||xm)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Nd(t,e,n){let r=t.state.selection;if(r instanceof V&&!r.empty||n.indexOf("s")>-1||it&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=Wa(t.state,e);if(i&&i instanceof H)return tn(t,i)}if(!s.parent.inlineContent){let i=e<0?s:o,a=r instanceof Xe?Y.near(i,e):Y.findFrom(i,e);return a?tn(t,a):!1}return!1}function Md(t,e){if(!(t.state.selection instanceof V))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=t.state.tr;return e<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),t.dispatch(i),!0}return!1}function Td(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function fC(t){if(!Xn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Td(t,r,"true"),setTimeout(()=>Td(t,r,"false"),20)}return!1}function hC(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function pC(t,e){let n=e.keyCode,r=hC(e);if(n==8||it&&n==72&&r=="c")return Md(t,-1)||nr(t,-1);if(n==46&&!e.shiftKey||it&&n==68&&r=="c")return Md(t,1)||nr(t,1);if(n==13||n==27)return!0;if(n==37||it&&n==66&&r=="c"){let s=n==37?wd(t,t.state.selection.from)=="ltr"?-1:1:-1;return Cd(t,s,r)||nr(t,s)}else if(n==39||it&&n==70&&r=="c"){let s=n==39?wd(t,t.state.selection.from)=="ltr"?1:-1:1;return Cd(t,s,r)||nr(t,s)}else{if(n==38||it&&n==80&&r=="c")return Nd(t,-1,r)||nr(t,-1);if(n==40||it&&n==78&&r=="c")return fC(t)||Nd(t,1,r)||nr(t,1);if(r==(it?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Sm(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=t.someProp("clipboardSerializer")||qt.fromSchema(t.state.schema),a=Em(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Tm[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=a.createElement(u[h]);for(;l.firstChild;)m.appendChild(l.firstChild);l.appendChild(m),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
99
|
-
|
|
100
|
-
`);return{dom:l,text:f,slice:e}}function Cm(t,e,n,r,s){let o=s.parent.type.spec.code,i,a;if(!n&&!e)return null;let l=!!e&&(r||o||!n);if(l){if(t.someProp("transformPastedText",f=>{e=f(e,o||r,t)}),o)return a=new F($.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
101
|
-
`))),0,0),t.someProp("transformPasted",f=>{a=f(a,t,!0)}),a;let d=t.someProp("clipboardTextParser",f=>f(e,s,r,t));if(d)a=d;else{let f=s.marks(),{schema:h}=t.state,m=qt.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let g=i.appendChild(document.createElement("p"));y&&g.appendChild(m.serializeNode(h.text(y,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=xC(n),tc&&bC(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||Et.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!mC.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=vC(Ed(a,+u[1],+u[2]),u[4]);else if(a=F.maxOpen(gC(a.content,s),!0),a.openStart||a.openEnd){let d=0,f=0;for(let h=a.content.firstChild;d<a.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=a.content.lastChild;f<a.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);a=Ed(a,d,f)}return t.someProp("transformPasted",d=>{a=d(a,t,l)}),a}const mC=/^(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 gC(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),o,i=[];if(t.forEach(a=>{if(!i)return;let l=s.findWrapping(a.type),c;if(!l)return i=null;if(c=i.length&&o.length&&Nm(l,o,a,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=Mm(i[i.length-1],o.length));let u=wm(a,l);i.push(u),s=s.matchType(u.type),o=l}}),i)return $.from(i)}return t}function wm(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,$.from(t));return t}function Nm(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let o=Nm(t,e,n,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append($.from(wm(n,t,s+1))))}}function Mm(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Mm(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore($.empty,!0);return t.copy(n.append(r))}function Ua(t,e,n,r,s,o){let i=e<0?t.firstChild:t.lastChild,a=i.content;return t.childCount>1&&(o=0),s<r-1&&(a=Ua(a,e,n,r,s+1,o)),s>=n&&(a=e<0?i.contentMatchAt(0).fillBefore(a,o<=s).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore($.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(a))}function Ed(t,e,n){return e<t.openStart&&(t=new F(Ua(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new F(Ua(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Tm={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Dd=null;function Em(){return Dd||(Dd=document.implementation.createHTMLDocument("title"))}let Ui=null;function yC(t){let e=window.trustedTypes;return e?(Ui||(Ui=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Ui.createHTML(t)):t}function xC(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Em().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&Tm[r[1].toLowerCase()])&&(t=s.map(o=>"<"+o+">").join("")+t+s.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=yC(t),s)for(let o=0;o<s.length;o++)n=n.querySelector(s[o])||n;return n}function bC(t){let e=t.querySelectorAll(Yt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function vC(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:o,openEnd:i}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;s=$.from(l.create(r[a+1],s)),o++,i++}return new F(s,o,i)}const bt={},tt={};function an(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}tt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Om(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ds&&Yt&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ec&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,pm(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||pC(t,n)?n.preventDefault():an(t,"key")};tt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};tt.keypress=(t,e)=>{let n=e;if(Om(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||it&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",i=>i(t,r.$from.pos,r.$to.pos,s,o))&&t.dispatch(o()),n.preventDefault()}};function xi(t){return{left:t.clientX,top:t.clientY}}function kC(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function rc(t,e,n,r,s){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(t.someProp(e,a=>i>o.depth?a(t,n,o.nodeAfter,o.before(i),s,!0):a(t,n,o.node(i),o.before(i),s,!1)))return!0;return!1}function pr(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function SC(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&H.isSelectable(r)?(pr(t,new H(n)),!0):!1}function CC(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof H&&(r=n.node);let o=t.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let a=i>o.depth?o.nodeAfter:o.node(i);if(H.isSelectable(a)){r&&n.$from.depth>0&&i>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?s=o.before(n.$from.depth):s=o.before(i);break}}return s!=null?(pr(t,H.create(t.state.doc,s)),!0):!1}function wC(t,e,n,r,s){return rc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(s?CC(t,n):SC(t,n))}function NC(t,e,n,r){return rc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function MC(t,e,n,r){return rc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||TC(t,n,r)}function TC(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(pr(t,V.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),a=s.before(o);if(i.inlineContent)pr(t,V.create(r,a+1,a+1+i.content.size));else if(H.isSelectable(i))pr(t,H.create(r,a));else continue;return!0}}function sc(t){return vo(t)}const Dm=it?"metaKey":"ctrlKey";bt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=sc(t),s=Date.now(),o="singleClick";s-t.input.lastClick.time<500&&kC(n,t.input.lastClick)&&!n[Dm]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:o,button:n.button};let i=t.posAtCoords(xi(n));i&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new EC(t,i,n,!!r)):(o=="doubleClick"?NC:MC)(t,i.pos,i.inside,n)?n.preventDefault():an(t,"pointer"))};class EC{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Dm],this.allowDefault=r.shiftKey;let o,i;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),i=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,i=u.depth?u.before():0}const a=s?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof H&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&yi&&!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)),an(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(()=>nc(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(xi(e))),this.updateAllowDefault(e),this.allowDefault||!n?an(this.view,"pointer"):wC(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Xn&&this.mightDrag&&!this.mightDrag.node.isAtom||Yt&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(pr(this.view,Y.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):an(this.view,"pointer")}move(e){this.updateAllowDefault(e),an(this.view,"pointer"),e.buttons==0&&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)}}bt.touchstart=t=>{t.input.lastTouch=Date.now(),sc(t),an(t,"pointer")};bt.touchmove=t=>{t.input.lastTouch=Date.now(),an(t,"pointer")};bt.contextmenu=t=>sc(t);function Om(t,e){return t.composing?!0:Xn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const DC=Ds?5e3:-1;tt.compositionstart=tt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Yt&&xm&&OC(t)))t.markCursor=t.state.storedMarks||n.marks(),vo(t,!0),t.markCursor=null;else if(vo(t,!e.selection.empty),yi&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let a=t.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}t.input.composing=!0}Am(t,DC)};function OC(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}tt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Am(t,20))};function Am(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>vo(t),e))}function AC(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=IC());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function IC(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function vo(t,e=!1){if(!(Ds&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),AC(t),e||t.docView&&t.docView.dirty){let n=rC(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function jC(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const ps=Es&&gm<15||ec&&nC<604;bt.copy=tt.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let o=ps?null:n.clipboardData,i=r.content(),{dom:a,text:l}=Sm(t,i);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):jC(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function RC(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function PC(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.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=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?qa(t,r.value,null,s,e):qa(t,r.textContent,r.innerHTML,s,e)},50)}function qa(t,e,n,r,s){let o=Cm(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,s,o||F.empty)))return!0;if(!o)return!1;let i=RC(o),a=i?t.state.tr.replaceSelectionWith(i,r):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Im(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}tt.paste=(t,e)=>{let n=e;if(t.composing&&!Ds)return;let r=ps?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&qa(t,Im(r),r.getData("text/html"),s,n)?n.preventDefault():PC(t,n)};class LC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const $C=it?"altKey":"ctrlKey";function jm(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[$C]}bt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,o=s.empty?null:t.posAtCoords(xi(n)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof H?s.to-1:s.to))){if(r&&r.mightDrag)i=H.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(i=H.create(t.state.doc,d.posBefore))}}let a=(i||t.state.selection).content(),{dom:l,text:c,slice:u}=Sm(t,a);(!n.dataTransfer.files.length||!Yt||ym>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ps?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",ps||n.dataTransfer.setData("text/plain",c),t.dragging=new LC(u,jm(t,n),i)};bt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};tt.dragover=tt.dragenter=(t,e)=>e.preventDefault();tt.drop=(t,e)=>{try{_C(t,e,t.dragging)}finally{t.dragging=null}};function _C(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(xi(e));if(!r)return;let s=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",h=>{o=h(o,t,!1)}):o=Cm(t,Im(e.dataTransfer),ps?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(n&&jm(t,e));if(t.someProp("handleDrop",h=>h(t,e,o||F.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?Dl(t.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let l=t.state.tr;if(i){let{node:h}=n;h?h.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,o.content.firstChild):l.replaceRange(c,c,o),l.doc.eq(d))return;let f=l.doc.resolve(c);if(u&&H.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new H(f));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((m,y,g,x)=>h=x),l.setSelection(vm(t,f,l.doc.resolve(h)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}bt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&nc(t)},20))};bt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};bt.beforeinput=(t,e)=>{if(Yt&&Ds&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,pm(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in tt)bt[t]=tt[t];function ms(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ko{constructor(e,n){this.toDOM=e,this.spec=n||jn,this.side=this.spec.side||0}map(e,n,r,s){let{pos:o,deleted:i}=e.mapResult(n.from+s,this.side<0?-1:1);return i?null:new Mt(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ko&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ms(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class dn{constructor(e,n){this.attrs=e,this.spec=n||jn}map(e,n,r,s){let o=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new Mt(o,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof dn&&ms(this.attrs,e.attrs)&&ms(this.spec,e.spec)}static is(e){return e.type instanceof dn}destroy(){}}class oc{constructor(e,n){this.attrs=e,this.spec=n||jn}map(e,n,r,s){let o=e.mapResult(n.from+s,1);if(o.deleted)return null;let i=e.mapResult(n.to+s,-1);return i.deleted||i.pos<=o.pos?null:new Mt(o.pos-r,i.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),o;return s==n.from&&!(o=e.child(r)).isText&&s+o.nodeSize==n.to}eq(e){return this==e||e instanceof oc&&ms(this.attrs,e.attrs)&&ms(this.spec,e.spec)}destroy(){}}class Mt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Mt(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Mt(e,e,new ko(n,r))}static inline(e,n,r,s){return new Mt(e,n,new dn(r,s))}static node(e,n,r,s){return new Mt(e,n,new oc(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof dn}get widget(){return this.type instanceof ko}}const lr=[],jn={};class De{constructor(e,n){this.local=e.length?e:lr,this.children=n.length?n:lr}static create(e,n){return n.length?So(n,e,0,jn):He}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,o){for(let i=0;i<this.local.length;i++){let a=this.local[i];a.from<=n&&a.to>=e&&(!o||o(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<n&&this.children[i+1]>e){let a=this.children[i]+1;this.children[i+2].findInner(e-a,n-a,r,s+a,o)}}map(e,n,r){return this==He||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jn)}mapInner(e,n,r,s,o){let i;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,s);l&&l.type.valid(n,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?BC(this.children,i||[],e,n,r,s,o):i?new De(i.sort(Rn),lr):He}add(e,n){return n.length?this==He?De.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,o=0;e.forEach((a,l)=>{let c=l+r,u;if(u=Pm(n,a,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<l;)o+=3;s[o]==l?s[o+2]=s[o+2].addInner(a,u,c+1):s.splice(o,0,l,l+a.nodeSize,So(u,a,c+1,jn)),o+=3}});let i=Rm(o?Lm(n):n,-r);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||i.splice(a--,1);return new De(i.length?this.local.concat(i).sort(Rn):this.local,s||this.children)}remove(e){return e.length==0||this==He?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,a=r[o]+n,l=r[o+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>a&&d.to<l&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,a+1);c!=He?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let a=0;a<s.length;a++)s[a].eq(i,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new De(s,r):He}forChild(e,n){if(this==He)return this;if(n.isLeaf)return De.empty;let r,s;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let o=e+1,i=o+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<i&&l.to>o&&l.type instanceof dn){let c=Math.max(o,l.from)-o,u=Math.min(i,l.to)-o;c<u&&(s||(s=[])).push(l.copy(c,u))}}if(s){let a=new De(s.sort(Rn),lr);return r?new Sn([a,r]):a}return r||He}eq(e){if(this==e)return!0;if(!(e instanceof De)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return ic(this.localsInner(e))}localsInner(e){if(this==He)return lr;if(e.inlineContent||!this.local.some(dn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof dn||n.push(this.local[r]);return n}forEachSet(e){e(this)}}De.empty=new De([],[]);De.removeOverlap=ic;const He=De.empty;class Sn{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,jn));return Sn.from(r)}forChild(e,n){if(n.isLeaf)return De.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,n);o!=He&&(o instanceof Sn?r=r.concat(o.members):r.push(o))}return Sn.from(r)}eq(e){if(!(e instanceof Sn)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let i=0;i<o.length;i++)n.push(o[i])}}return n?ic(r?n:n.sort(Rn)):lr}static from(e){switch(e.length){case 0:return He;case 1:return e[0];default:return new Sn(e.every(n=>n instanceof De)?e:e.reduce((n,r)=>n.concat(r instanceof De?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function BC(t,e,n,r,s,o,i){let a=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,m,y)=>{let g=y-m-(h-f);for(let x=0;x<a.length;x+=3){let b=a[x+1];if(b<0||f>b+u-d)continue;let v=a[x]+u-d;h>=v?a[x+1]=f<=v?-2:-1:f>=u&&g&&(a[x]+=g,a[x+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=n.map(t[c]+o),d=u-s;if(d<0||d>=r.content.size){l=!0;continue}let f=n.map(t[c+1]+o,-1),h=f-s,{index:m,offset:y}=r.content.findIndex(d),g=r.maybeChild(m);if(g&&y==d&&y+g.nodeSize==h){let x=a[c+2].mapInner(n,g,u+1,t[c]+o+1,i);x!=He?(a[c]=d,a[c+1]=h,a[c+2]=x):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=zC(a,t,e,n,s,o,i),u=So(c,r,0,i);e=u.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<a.length&&a[f]<h;)f+=3;a.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new De(e.sort(Rn),a)}function Rm(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Mt(s.from+e,s.to+e,s.type))}return n}function zC(t,e,n,r,s,o,i){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(r,s,c);d?n.push(d):i.onRemove&&i.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+o+1);return n}function Pm(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let o=0,i;o<t.length;o++)(i=t[o])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),t[o]=null);return s}function Lm(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function So(t,e,n,r){let s=[],o=!1;e.forEach((a,l)=>{let c=Pm(t,a,l+n);if(c){o=!0;let u=So(c,a,n+l+1,r);u!=He&&s.push(l,l+a.nodeSize,u)}});let i=Rm(o?Lm(t):t,-n).sort(Rn);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||s.length?new De(i,s):He}function Rn(t,e){return t.from-e.from||t.to-e.to}function ic(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[s]=o.copy(o.from,r.to),Od(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Od(e,s,r.copy(o.from,r.to)));break}}}return e}function Od(t,e,n){for(;e<t.length&&Rn(n,t[e])>0;)e++;t.splice(e,0,n)}class ye extends Y{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ye.valid(r)?new ye(r):Y.near(r)}content(){return F.empty}eq(e){return e instanceof ye&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ye(e.resolve(n.pos))}getBookmark(){return new ac(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!FC(e)||!HC(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ye.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let a=e.node(i);if(n>0?e.indexAfter(i)<a.childCount:e.index(i)>0){o=a.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=n;let l=e.doc.resolve(s);if(ye.valid(l))return l}for(;;){let i=n>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!H.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*n),r=!1;continue e}break}o=i,s+=n;let a=e.doc.resolve(s);if(ye.valid(a))return a}return null}}}ye.prototype.visible=!1;ye.findFrom=ye.findGapCursorFrom;Y.jsonID("gapcursor",ye);class ac{constructor(e){this.pos=e}map(e){return new ac(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ye.valid(n)?new ye(n):Y.near(n)}}function $m(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function FC(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||$m(s.type))return!0;if(s.inlineContent)return!1}}return!0}function HC(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||$m(s.type))return!0;if(s.inlineContent)return!1}}return!0}function WC(){return new pe({props:{decorations:KC,createSelectionBetween(t,e,n){return e.pos==n.pos&&ye.valid(n)?new ye(n):null},handleClick:UC,handleKeyDown:VC,handleDOMEvents:{beforeinput:qC}}})}const VC=wp({ArrowLeft:Us("horiz",-1),ArrowRight:Us("horiz",1),ArrowUp:Us("vert",-1),ArrowDown:Us("vert",1)});function Us(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,a=e>0?i.$to:i.$from,l=i.empty;if(i instanceof V){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=ye.findGapCursorFrom(a,e,l);return c?(s&&s(r.tr.setSelection(new ye(c))),!0):!1}}function UC(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ye.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&H.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ye(r))),!0)}function qC(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ye))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=$.empty;for(let i=r.length-1;i>=0;i--)s=$.from(r[i].createAndFill(null,s));let o=t.state.tr.replace(n.pos,n.pos,new F(s,0,0));return o.setSelection(V.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function KC(t){if(!(t.selection instanceof ye))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",De.create(t.doc,[Mt.widget(t.selection.head,e,{key:"gapcursor"})])}var Co=200,Ae=function(){};Ae.prototype.append=function(e){return e.length?(e=Ae.from(e),!this.length&&e||e.length<Co&&this.leafAppend(e)||this.length<Co&&e.leafPrepend(this)||this.appendInner(e)):this};Ae.prototype.prepend=function(e){return e.length?Ae.from(e).append(this):this};Ae.prototype.appendInner=function(e){return new JC(this,e)};Ae.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ae.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ae.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ae.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Ae.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},n,r),s};Ae.from=function(e){return e instanceof Ae?e:e&&e.length?new _m(e):Ae.empty};var _m=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,a){for(var l=o;l<i;l++)if(s(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,a){for(var l=o-1;l>=i;l--)if(s(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Co)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Co)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Ae);Ae.empty=new _m([]);var JC=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(o,a),i)===!1||o>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,o)-a,i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(o,a)-a,i+a)===!1||o<a&&this.left.forEachInvertedInner(r,Math.min(s,a),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ae);const YC=500;class ft{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;n&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,a,l,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new kt(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new kt(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return a=s?d.selection.map(s.slice(o)):d.selection,l=new ft(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:a}}addTransform(e,n,r,s){let o=[],i=this.eventCount,a=this.items,l=!s&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new kt(e.mapping.maps[u],d,n),h;(h=l&&l.merge(f))&&(f=h,u?o.pop():a=a.slice(0,a.length-1)),o.push(f),n&&(i++,n=void 0),s||(l=f)}let c=i-r.depth;return c>XC&&(a=GC(a,c),i-=c),new ft(a.append(o),i)}remapping(e,n){let r=new ls;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new ft(this.items.append(e.map(n=>new kt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),o=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},s);let l=n;this.items.forEach(f=>{let h=o.getMirror(--l);if(h==null)return;i=Math.min(i,h);let m=o.maps[h];if(f.step){let y=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(o.slice(l+1,h));g&&a++,r.push(new kt(m,y,g))}else r.push(new kt(m))},s);let c=[];for(let f=n;f<i;f++)c.push(new kt(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new ft(u,a);return d.emptyItemCount()>YC&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],o=0;return this.items.forEach((i,a)=>{if(a>=e)s.push(i),i.selection&&o++;else if(i.step){let l=i.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=i.selection&&i.selection.map(n.slice(r));u&&o++;let d=new kt(c.invert(),l,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new ft(Ae.from(s.reverse()),o)}}ft.empty=new ft(Ae.empty,0);function GC(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class kt{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new kt(n.getMap().invert(),n,this.selection)}}}class nn{constructor(e,n,r,s,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const XC=20;function QC(t,e,n,r){let s=n.getMeta(Pn),o;if(s)return s.historyState;n.getMeta(tw)&&(t=new nn(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(Pn))return i.getMeta(Pn).redo?new nn(t.done.addTransform(n,void 0,r,no(e)),t.undone,Ad(n.mapping.maps),t.prevTime,t.prevComposition):new nn(t.done,t.undone.addTransform(n,void 0,r,no(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!i&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!ZC(n,t.prevRanges)),c=i?qi(t.prevRanges,n.mapping):Ad(n.mapping.maps);return new nn(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,no(e)),ft.empty,c,n.time,a??t.prevComposition)}else return(o=n.getMeta("rebased"))?new nn(t.done.rebased(n,o),t.undone.rebased(n,o),qi(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new nn(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),qi(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function ZC(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(n=!0)}),n}function Ad(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,o,i)=>e.push(o,i));return e}function qi(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),o=e.map(t[r+1],-1);s<=o&&n.push(s,o)}return n}function ew(t,e,n){let r=no(e),s=Pn.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),a=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),l=new nn(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(i).setMeta(Pn,{redo:n,historyState:l})}let Ki=!1,Id=null;function no(t){let e=t.plugins;if(Id!=e){Ki=!1,Id=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ki=!0;break}}return Ki}const Pn=new Ce("history"),tw=new Ce("closeHistory");function nw(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new pe({key:Pn,state:{init(){return new nn(ft.empty,ft.empty,null,0,-1)},apply(e,n,r){return QC(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?zm:r=="historyRedo"?Fm:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Bm(t,e){return(n,r)=>{let s=Pn.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let o=ew(s,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const zm=Bm(!1,!0),Fm=Bm(!0,!0);be.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new pe({key:new Ce("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit,o=this.options.autoTrim;if(s==null||s===0||o===!1){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const a=i-s,l=0,c=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const i=e.selection.$head.pos,a=i-(o-r),l=i;return e.deleteRange(a,l),!(this.storage.characters({node:e.doc})>r)}})]}});const rw=be.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[QS(this.options)]}});be.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new pe({key:new Ce("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!n||!r)return xe.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(!l.isText){if(!(s>=c&&s<=c+l.nodeSize-1))return!1;i+=1}});let a=0;return t.descendants((l,c)=>{if(l.isText||!(s>=c&&s<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";o.push(Kt.node(c,c+l.nodeSize,{class:this.options.className}))}),xe.create(t,o)}}})]}});const sw=be.create({name:"gapCursor",addProseMirrorPlugins(){return[WC()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=oe(U(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),Hm="placeholder",jd=new Ce("tiptap__placeholder");function Wm(t){const{editor:e,placeholder:n,dataAttribute:r,pos:s,node:o,isEmptyDoc:i,hasAnchor:a,classes:{emptyNode:l,emptyEditor:c}}=t,u=[l];return i&&u.push(c),Kt.node(s,s+o.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:o,pos:s,hasAnchor:a}):n})}function Vm(t,e){return typeof t=="function"?t(e):t}function Um({editor:t,options:e,dataAttribute:n,doc:r,selection:s,from:o,to:i}){const{anchor:a}=s,l=[],c=t.isEmpty;return r.nodesBetween(o,i,(u,d)=>{const f=a>=d&&a<=d+u.nodeSize,h=!u.isLeaf&&Ms(u);return u.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&l.push(Wm({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Vm(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:f})},node:u,pos:d})),e.includeChildren}),l}function qm({editor:t,options:e,dataAttribute:n,doc:r,selection:s}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:o}=s,i=[],a=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const l=r.resolve(o),c=l.depth>0?l.node(1):l.nodeAfter,u=l.depth>0?l.before(1):o;if(c&&c.type.isTextblock&&Ms(c)){const d=o>=u&&o<=u+c.nodeSize;i.push(Wm({editor:t,isEmptyDoc:a,dataAttribute:n,hasAnchor:d,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Vm(e.emptyNodeClass,{editor:t,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else i.push(...Um({editor:t,options:e,dataAttribute:n,doc:r,selection:s,from:0,to:r.content.size}));return xe.create(r,i)}function Gr(t,e){const n=t.resolve(e);if(n.depth===0){var r;const o=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!o)return{from:e,to:e};const i=n.nodeAfter?e:e-o.nodeSize;return{from:i,to:i+o.nodeSize}}const s=n.before(1);return{from:s,to:s+n.node(1).nodeSize}}function Xr(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function ow(t,e,n){const r=[];return t.forEach((s,o)=>{const i=o,a=i+s.nodeSize,l=i+1,c=a+1;l<n&&c>e&&r.push({from:i,to:a})}),r}function iw(t){if(t.length===0)return[];const e=[...t].sort((r,s)=>r.from-s.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){const s=n[n.length-1],o=e[r];o.from<=s.to?s.to=Math.max(s.to,o.to):n.push({...o})}return n}function aw(t,e){const n=ow(t,e.from,e.to);return n.push(Xr(t,Gr(t,e.from))),e.to>e.from?n.push(Xr(t,Gr(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(Xr(t,Gr(t,Math.min(e.from+1,t.content.size)))),n}function lw(t,e,n){const r=[];if(t.docChanged){const s=pi(t);for(const o of s)r.push(...aw(n.doc,o.newRange))}return t.selectionSet&&(r.push(Xr(n.doc,Gr(n.doc,t.mapping.map(e.selection.anchor)))),r.push(Xr(n.doc,Gr(n.doc,n.selection.anchor)))),iw(r)}function cw(t,e,n){const r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function uw({decorations:t,ranges:e,editor:n,options:r,dataAttribute:s,doc:o,selection:i}){let a=t;for(const l of e){const{from:c,to:u}=cw(l.from,l.to,o),d=a.find(c,u).filter(h=>h.from>=c&&h.to<=u);d.length&&(a=a.remove(d));const f=Um({editor:n,options:r,dataAttribute:s,doc:o,selection:i,from:c,to:u});f.length&&(a=a.add(o,f))}return a}function dw({editor:t,options:e,dataAttribute:n}){return{init(r,s){const o=qm({editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection});return o??xe.empty},apply(r,s,o,i){return!r.docChanged&&!r.selectionSet?s:uw({decorations:s.map(r.mapping,r.doc),ranges:lw(r,o,i),editor:t,options:e,dataAttribute:n,doc:i.doc,selection:i.selection})}}}function fw(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function hw({editor:t,options:e}){const n=e.dataAttribute?`data-${fw(e.dataAttribute)}`:`data-${Hm}`,r=e.showOnlyCurrent&&!e.includeChildren;return new pe({key:jd,...r?{}:{state:dw({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:s,selection:o})=>qm({editor:t,options:e,dataAttribute:n,doc:s,selection:o}):s=>{var o;return e.showOnlyWhenEditable&&!t.isEditable?xe.empty:(o=jd.getState(s))!==null&&o!==void 0?o:xe.empty}}})}const lA=be.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Hm,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[hw({editor:this.editor,options:this.options})]}});function Ka(t,e){return!t.selection.empty&&!Fp(t.selection)&&e.isEditable}function pw(t,e){return Ka(t,e)&&!e.isFocused&&!e.view.dragging}function mw(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function gw(t){t.focus()}be.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new pe({key:new Ce("selection"),props:{decorations(n){return pw(n,t)?xe.create(n.doc,[Kt.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Ka(n.state,t)&&mw(),!1},focus(n){return Ka(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&gw(n)}),!1}}}})]}});function Rd({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}const yw=be.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ce(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new pe({key:e,appendTransaction:(s,o,i)=>{const{doc:a,tr:l,schema:c}=i,u=e.getState(i),d=a.content.size,f=c.nodes[n];if(!s.some(h=>h.getMeta("skipTrailingNode"))&&u)return l.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!Rd({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!Rd({node:i,types:r})}}})]}}),xw=be.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>zm(t,e),redo:()=>({state:t,dispatch:e})=>Fm(t,e)}},addProseMirrorPlugins(){return[nw(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()}}}),Km=new WeakSet,Jm=new WeakSet;function xn(t){const e=t;return Km.add(e),e}function Ja(t){return Array.isArray(t)&&Km.has(t)}function Ym(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&Jm.has(e)&&!Ja(e)?Ym(e):[e])}function bw(t,e){if(t==="slot")return 0;if(t instanceof Function){const s=t(e);return Array.isArray(s)&&!Ja(s)&&!Jm.has(s)?xn(s):s}const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(Ja(n))return xn([t,r,n]);if(n.length===0)return xn([t,r]);const s=Ym(n);return s.length===0?xn([t,r]):xn([t,r,...s])}return n!=null?xn([t,r,n]):xn([t,r])}const wo=(t,e)=>bw(t,e),vw=(t,e)=>{var n;const{state:r}=t,{selection:s}=r;if(!s.empty)return!1;const{$from:o}=s;if(o.parentOffset!==0)return!1;const i=o.depth-1;if(i<0)return!1;const a=o.node(i),l=o.index(i);if(l===0)return!1;if(a.type===e)return t.commands.lift(e.name);const c=a.child(l-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;const u=o.before()-1-1;return t.commands.command(({tr:d,dispatch:f})=>{if(!f)return!0;const h=o.parent.content,m=new F(h,0,0);return d.replace(u,o.after(),m),d.setSelection(V.create(d.doc,u+h.size)),d.scrollIntoView(),f(d),!0})},kw=/^\s*>\s$/,Sw=qe.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return wo("blockquote",{...Se(this.options.HTMLAttributes,t),children:wo("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((s,o)=>{var i,a;const l=((i=(a=e.renderChild)===null||a===void 0?void 0:a.call(e,s,o))!==null&&i!==void 0?i:e.renderChildren([s])).split(`
|
|
102
|
-
`).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
|
|
103
|
-
`))}),r.join(`
|
|
104
|
-
${n}
|
|
105
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>vw(this.editor,this.type)}},addInputRules(){return[Sr({find:kw,type:this.type})]}}),Cw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,ww=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Nw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Mw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Tw=Jn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return wo("strong",{...Se(this.options.HTMLAttributes,t),children:wo("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Un({find:Cw,type:this.type}),Un({find:Nw,type:this.type})]},addPasteRules(){return[hn({find:ww,type:this.type}),hn({find:Mw,type:this.type})]}}),Ew=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},Dw=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},Ow=Jn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Se(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Un({find:Ew,type:this.type})]},addPasteRules(){return[hn({find:Dw,type:this.type})]}}),Ji=4,Aw=/^```([a-z]+)?[\s\n]$/,Iw=/^~~~([a-z]+)?[\s\n]$/,jw=qe.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ji,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Se(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)===null||n===void 0?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
|
|
106
|
-
`):r=`\`\`\`${s}
|
|
107
|
-
|
|
108
|
-
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!==null&&e!==void 0?e:Ji,{state:r}=t,{selection:s}=r,{$from:o,empty:i}=s;if(o.parent.type!==this.type)return!1;const a=" ".repeat(n);return i?t.commands.insertContent(a):t.commands.command(({tr:l})=>{const{from:c,to:u}=s,d=r.doc.textBetween(c,u,`
|
|
109
|
-
`,`
|
|
110
|
-
`).split(`
|
|
111
|
-
`).map(f=>a+f).join(`
|
|
112
|
-
`);return l.replaceWith(c,u,r.schema.text(d)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!==null&&e!==void 0?e:Ji,{state:r}=t,{selection:s}=r,{$from:o,empty:i}=s;return o.parent.type!==this.type?!1:i?t.commands.command(({tr:a})=>{var l;const{pos:c}=o,u=o.start(),d=o.end(),f=r.doc.textBetween(u,d,`
|
|
113
|
-
`,`
|
|
114
|
-
`).split(`
|
|
115
|
-
`);let h=0,m=0;const y=c-u;for(let v=0;v<f.length;v+=1){if(m+f[v].length>=y){h=v;break}m+=f[v].length+1}const g=((l=f[h].match(/^ */))===null||l===void 0?void 0:l[0])||"",x=Math.min(g.length,n);if(x===0)return!0;let b=u;for(let v=0;v<h;v+=1)b+=f[v].length+1;return a.delete(b,b+x),c-b<=x&&a.setSelection(V.create(a.doc,b)),!0}):t.commands.command(({tr:a})=>{const{from:l,to:c}=s,u=r.doc.textBetween(l,c,`
|
|
116
|
-
`,`
|
|
117
|
-
`).split(`
|
|
118
|
-
`).map(d=>{var f;const h=((f=d.match(/^ */))===null||f===void 0?void 0:f[0])||"",m=Math.min(h.length,n);return d.slice(m)}).join(`
|
|
119
|
-
`);return a.replaceWith(l,c,r.schema.text(u)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
|
|
120
|
-
|
|
121
|
-
`);return!o||!i?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type||r.parentOffset!==0)return!1;const o=r.before();return o>0?!1:t.commands.insertDefaultBlock({pos:o})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:o}=n;if(!o||s.parent.type!==this.type||s.parentOffset!==s.parent.nodeSize-2)return!1;const i=s.after();return i===void 0?!1:r.nodeAt(i)?t.commands.command(({tr:a})=>(a.setSelection(Y.near(r.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[Ba({find:Aw,type:this.type,getAttributes:t=>({language:t[1]})}),Ba({find:Iw,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new pe({key:new Ce("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s?.mode;if(!n||!o)return!1;const{tr:i,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,`
|
|
122
|
-
`));return i.replaceSelectionWith(this.type.create({language:o},l)),i.selection.$from.parent.type!==this.type&&i.setSelection(V.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),t.dispatch(i),!0}}})]}}),Rw=qe.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
123
|
-
|
|
124
|
-
`):""}),Pw=qe.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Se(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
125
|
-
`},renderMarkdown:()=>`
|
|
126
|
-
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:o}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=r.extensionManager,l=o||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&i){const d=l.filter(f=>a.includes(f.type.name));c.ensureMarks(d)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Lw=qe.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Se(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Ba({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),$w=qe.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Se(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!d2(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Fp(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:o,tr:i,dispatch:a})=>{if(a){const{$to:l}=i.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(V.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(H.create(i.doc,l.pos)):i.setSelection(V.create(i.doc,l.pos));else{const u=o.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,d=u?.create();d&&(i.insert(c,d),i.setSelection(V.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[$2({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),_w=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Bw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,zw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Fw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Hw=Jn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Se(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Un({find:_w,type:this.type}),Un({find:zw,type:this.type})]},addPasteRules(){return[hn({find:Bw,type:this.type}),hn({find:Fw,type:this.type})]}}),Ww="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Vw="ελ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",Ya="numeric",Ga="ascii",Xa="alpha",Qr="asciinumeric",Hr="alphanumeric",Qa="domain",Gm="emoji",Uw="scheme",qw="slashscheme",Yi="whitespace";function Kw(t,e){return t in e||(e[t]=[]),e[t]}function Mn(t,e,n){e[Ya]&&(e[Qr]=!0,e[Hr]=!0),e[Ga]&&(e[Qr]=!0,e[Xa]=!0),e[Qr]&&(e[Hr]=!0),e[Xa]&&(e[Hr]=!0),e[Hr]&&(e[Qa]=!0),e[Gm]&&(e[Qa]=!0);for(const r in e){const s=Kw(r,n);s.indexOf(t)<0&&s.push(t)}}function Jw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ye(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ye.groups={};Ye.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(t))return o}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||Ye.groups;let s;return e&&e.j?s=e:(s=new Ye(e),n&&r&&Mn(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const o=t.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(t[i]);return s.tt(t[o-1],e,n,r)},tt(t,e,n,r){r=r||Ye.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const o=e;let i,a=s.go(t);if(a?(i=new Ye,Object.assign(i.j,a.j),i.jr.push.apply(i.jr,a.jr),i.jd=a.jd,i.t=a.t):i=new Ye,o){if(r)if(i.t&&typeof i.t=="string"){const l=Object.assign(Jw(i.t,r),n);Mn(o,l,r)}else n&&Mn(o,n,r);i.t=o}return s.j[t]=i,i}};const Z=(t,e,n,r,s)=>t.ta(e,n,r,s),ge=(t,e,n,r,s)=>t.tr(e,n,r,s),Pd=(t,e,n,r,s)=>t.ts(e,n,r,s),B=(t,e,n,r,s)=>t.tt(e,n,r,s),_t="WORD",Za="UWORD",Xm="ASCIINUMERICAL",Qm="ALPHANUMERICAL",gs="LOCALHOST",el="TLD",tl="UTLD",ro="SCHEME",cr="SLASH_SCHEME",lc="NUM",nl="WS",cc="NL",Zr="OPENBRACE",es="CLOSEBRACE",No="OPENBRACKET",Mo="CLOSEBRACKET",To="OPENPAREN",Eo="CLOSEPAREN",Do="OPENANGLEBRACKET",Oo="CLOSEANGLEBRACKET",Ao="FULLWIDTHLEFTPAREN",Io="FULLWIDTHRIGHTPAREN",jo="LEFTCORNERBRACKET",Ro="RIGHTCORNERBRACKET",Po="LEFTWHITECORNERBRACKET",Lo="RIGHTWHITECORNERBRACKET",$o="FULLWIDTHLESSTHAN",_o="FULLWIDTHGREATERTHAN",Bo="AMPERSAND",zo="APOSTROPHE",Fo="ASTERISK",rn="AT",Ho="BACKSLASH",Wo="BACKTICK",Vo="CARET",Tn="COLON",uc="COMMA",Uo="DOLLAR",St="DOT",qo="EQUALS",dc="EXCLAMATION",st="HYPHEN",ts="PERCENT",Ko="PIPE",Jo="PLUS",Yo="POUND",ns="QUERY",fc="QUOTE",Zm="FULLWIDTHMIDDLEDOT",hc="SEMI",Ct="SLASH",rs="TILDE",Go="UNDERSCORE",eg="EMOJI",Xo="SYM";var tg=Object.freeze({__proto__:null,ALPHANUMERICAL:Qm,AMPERSAND:Bo,APOSTROPHE:zo,ASCIINUMERICAL:Xm,ASTERISK:Fo,AT:rn,BACKSLASH:Ho,BACKTICK:Wo,CARET:Vo,CLOSEANGLEBRACKET:Oo,CLOSEBRACE:es,CLOSEBRACKET:Mo,CLOSEPAREN:Eo,COLON:Tn,COMMA:uc,DOLLAR:Uo,DOT:St,EMOJI:eg,EQUALS:qo,EXCLAMATION:dc,FULLWIDTHGREATERTHAN:_o,FULLWIDTHLEFTPAREN:Ao,FULLWIDTHLESSTHAN:$o,FULLWIDTHMIDDLEDOT:Zm,FULLWIDTHRIGHTPAREN:Io,HYPHEN:st,LEFTCORNERBRACKET:jo,LEFTWHITECORNERBRACKET:Po,LOCALHOST:gs,NL:cc,NUM:lc,OPENANGLEBRACKET:Do,OPENBRACE:Zr,OPENBRACKET:No,OPENPAREN:To,PERCENT:ts,PIPE:Ko,PLUS:Jo,POUND:Yo,QUERY:ns,QUOTE:fc,RIGHTCORNERBRACKET:Ro,RIGHTWHITECORNERBRACKET:Lo,SCHEME:ro,SEMI:hc,SLASH:Ct,SLASH_SCHEME:cr,SYM:Xo,TILDE:rs,TLD:el,UNDERSCORE:Go,UTLD:tl,UWORD:Za,WORD:_t,WS:nl});const Rt=/[a-z]/,jr=new RegExp("\\p{L}","u"),Gi=new RegExp("\\p{Emoji}","u"),Pt=/\d/,Xi=/\s/,Ld="\r",Qi=`
|
|
127
|
-
`,Yw="️",Gw="",Zi="";let qs=null,Ks=null;function Xw(t=[]){const e={};Ye.groups=e;const n=new Ye;qs==null&&(qs=$d(Ww)),Ks==null&&(Ks=$d(Vw)),B(n,"'",zo),B(n,"{",Zr),B(n,"}",es),B(n,"[",No),B(n,"]",Mo),B(n,"(",To),B(n,")",Eo),B(n,"<",Do),B(n,">",Oo),B(n,"(",Ao),B(n,")",Io),B(n,"「",jo),B(n,"」",Ro),B(n,"『",Po),B(n,"』",Lo),B(n,"<",$o),B(n,">",_o),B(n,"&",Bo),B(n,"*",Fo),B(n,"@",rn),B(n,"`",Wo),B(n,"^",Vo),B(n,":",Tn),B(n,",",uc),B(n,"$",Uo),B(n,".",St),B(n,"=",qo),B(n,"!",dc),B(n,"-",st),B(n,"%",ts),B(n,"|",Ko),B(n,"+",Jo),B(n,"#",Yo),B(n,"?",ns),B(n,'"',fc),B(n,"/",Ct),B(n,";",hc),B(n,"~",rs),B(n,"_",Go),B(n,"\\",Ho),B(n,"・",Zm);const r=ge(n,Pt,lc,{[Ya]:!0});ge(r,Pt,r);const s=ge(r,Rt,Xm,{[Qr]:!0}),o=ge(r,jr,Qm,{[Hr]:!0}),i=ge(n,Rt,_t,{[Ga]:!0});ge(i,Pt,s),ge(i,Rt,i),ge(s,Pt,s),ge(s,Rt,s);const a=ge(n,jr,Za,{[Xa]:!0});ge(a,Rt),ge(a,Pt,o),ge(a,jr,a),ge(o,Pt,o),ge(o,Rt),ge(o,jr,o);const l=B(n,Qi,cc,{[Yi]:!0}),c=B(n,Ld,nl,{[Yi]:!0}),u=ge(n,Xi,nl,{[Yi]:!0});B(n,Zi,u),B(c,Qi,l),B(c,Zi,u),ge(c,Xi,u),B(u,Ld),B(u,Qi),ge(u,Xi,u),B(u,Zi,u);const d=ge(n,Gi,eg,{[Gm]:!0});B(d,"#"),ge(d,Gi,d),B(d,Yw,d);const f=B(d,Gw);B(f,"#"),ge(f,Gi,d);const h=[[Rt,i],[Pt,s]],m=[[Rt,null],[jr,a],[Pt,o]];for(let y=0;y<qs.length;y++)Gt(n,qs[y],el,_t,h);for(let y=0;y<Ks.length;y++)Gt(n,Ks[y],tl,Za,m);Mn(el,{tld:!0,ascii:!0},e),Mn(tl,{utld:!0,alpha:!0},e),Gt(n,"file",ro,_t,h),Gt(n,"mailto",ro,_t,h),Gt(n,"http",cr,_t,h),Gt(n,"https",cr,_t,h),Gt(n,"ftp",cr,_t,h),Gt(n,"ftps",cr,_t,h),Mn(ro,{scheme:!0,ascii:!0},e),Mn(cr,{slashscheme:!0,ascii:!0},e),t=t.sort((y,g)=>y[0]>g[0]?1:-1);for(let y=0;y<t.length;y++){const g=t[y][0],b=t[y][1]?{[Uw]:!0}:{[qw]:!0};g.indexOf("-")>=0?b[Qa]=!0:Rt.test(g)?Pt.test(g)?b[Qr]=!0:b[Ga]=!0:b[Ya]=!0,Pd(n,g,g,b)}return Pd(n,"localhost",gs,{ascii:!0}),n.jd=new Ye(Xo),{start:n,tokens:Object.assign({groups:e},tg)}}function ng(t,e){const n=Qw(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,s=[];let o=0,i=0;for(;i<r;){let a=t,l=null,c=0,u=null,d=-1,f=-1;for(;i<r&&(l=a.go(n[i]));)a=l,a.accepts()?(d=0,f=0,u=a):d>=0&&(d+=n[i].length,f++),c+=n[i].length,o+=n[i].length,i++;o-=d,i-=f,c-=d,s.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function Qw(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),o,i=s<55296||s>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(i),r+=i.length}return e}function Gt(t,e,n,r,s){let o;const i=e.length;for(let a=0;a<i-1;a++){const l=e[a];t.j[l]?o=t.j[l]:(o=new Ye(r),o.jr=s.slice(),t.j[l]=o),t=o}return o=new Ye(n),o.jr=s.slice(),t.j[e[i-1]]=o,o}function $d(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let o=0;for(;s.indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let i=parseInt(t.substring(r,r+o),10);i>0;i--)n.pop();r+=o}else n.push(t[r]),r++}return e}const ys={defaultProtocol:"http",events:null,format:_d,formatHref:_d,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function pc(t,e=null){let n=Object.assign({},ys);t&&(n=Object.assign(n,t instanceof pc?t.o:t));const r=n.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}pc.prototype={o:ys,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:ys[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function _d(t){return t}function rg(t,e){this.t="token",this.v=t,this.tk=e}rg.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=ys.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),o=this.toFormattedString(t),i={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return i.href=r,a&&(i.class=a),l&&(i.target=l),c&&(i.rel=c),u&&Object.assign(i,u),{tagName:s,attributes:i,content:o,eventListeners:d}}};function bi(t,e){class n extends rg{constructor(s,o){super(s,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Zw=bi("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Bd=bi("text"),eN=bi("nl"),Js=bi("url",{isLink:!0,toHref(t=ys.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==gs&&t[1].t===Tn}}),rt=t=>new Ye(t);function tN({groups:t}){const e=t.domain.concat([Bo,Fo,rn,Ho,Wo,Vo,Uo,qo,st,lc,ts,Ko,Jo,Yo,Ct,Xo,rs,Go]),n=[zo,Tn,uc,St,dc,ts,ns,fc,hc,Do,Oo,Zr,es,Mo,No,To,Eo,Ao,Io,jo,Ro,Po,Lo,$o,_o],r=[Bo,zo,Fo,Ho,Wo,Vo,Uo,qo,st,Zr,es,ts,Ko,Jo,Yo,ns,Ct,Xo,rs,Go],s=rt(),o=B(s,rs);Z(o,r,o),Z(o,t.domain,o);const i=rt(),a=rt(),l=rt();Z(s,t.domain,i),Z(s,t.scheme,a),Z(s,t.slashscheme,l),Z(i,r,o),Z(i,t.domain,i);const c=B(i,rn);B(o,rn,c),B(a,rn,c),B(l,rn,c);const u=B(o,St);Z(u,r,o),Z(u,t.domain,o);const d=rt();Z(c,t.domain,d),Z(d,t.domain,d);const f=B(d,St);Z(f,t.domain,d);const h=rt(Zw);Z(f,t.tld,h),Z(f,t.utld,h),B(c,gs,h);const m=B(d,st);B(m,st,m),Z(m,t.domain,d),Z(h,t.domain,d),B(h,St,f),B(h,st,m);const y=B(i,st),g=B(i,St);B(y,st,y),Z(y,t.domain,i),Z(g,r,o),Z(g,t.domain,i);const x=rt(Js);Z(g,t.tld,x),Z(g,t.utld,x),Z(x,t.domain,i),Z(x,r,o),B(x,St,g),B(x,st,y),B(x,rn,c);const b=B(x,Tn),v=rt(Js);Z(b,t.numeric,v);const k=rt(Js),N=rt();Z(k,e,k),Z(k,n,N),Z(N,e,k),Z(N,n,N),B(x,Ct,k),B(v,Ct,k);const C=B(a,Tn),S=B(l,Tn),w=B(S,Ct),M=B(w,Ct);Z(a,t.domain,i),B(a,St,g),B(a,st,y),Z(l,t.domain,i),B(l,St,g),B(l,st,y),Z(C,t.domain,k),B(C,Ct,k),B(C,ns,k),Z(M,t.domain,k),Z(M,e,k),B(M,Ct,k);const T=[[Zr,es],[No,Mo],[To,Eo],[Do,Oo],[Ao,Io],[jo,Ro],[Po,Lo],[$o,_o]];for(let O=0;O<T.length;O++){const[A,P]=T[O],D=B(k,A);B(N,A,D);const E=rt(Js);Z(D,e,E);const j=rt();Z(D,n,j),B(D,P,k),Z(E,e,E),Z(E,n,j),Z(j,e,E),Z(j,n,j),B(E,P,k),B(j,P,k)}return B(s,gs,x),B(s,cc,eN),{start:s,tokens:tg}}function nN(t,e,n){let r=n.length,s=0,o=[],i=[];for(;s<r;){let a=t,l=null,c=null,u=0,d=null,f=-1;for(;s<r&&!(l=a.go(n[s].t));)i.push(n[s++]);for(;s<r&&(c=l||a.go(n[s].t));)l=null,a=c,a.accepts()?(f=0,d=a):f>=0&&f++,s++,u++;if(f<0)s-=u,s<r&&(i.push(n[s]),s++);else{i.length>0&&(o.push(ea(Bd,e,i)),i=[]),s-=f,u-=f;const h=d.t,m=n.slice(s-u,s);o.push(ea(h,e,m))}}return i.length>0&&o.push(ea(Bd,e,i)),o}function ea(t,e,n){const r=n[0].s,s=n[n.length-1].e,o=e.slice(r,s);return new t(o,n)}const rN=typeof console<"u"&&console&&console.warn||(()=>{}),sN="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",he={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function oN(){return Ye.groups={},he.scanner=null,he.parser=null,he.tokenQueue=[],he.pluginQueue=[],he.customSchemes=[],he.initialized=!1,he}function zd(t,e=!1){if(he.initialized&&rN(`linkifyjs: already initialized - will not register custom scheme "${t}" ${sN}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
128
|
-
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
129
|
-
2. Cannot start or end with "-"
|
|
130
|
-
3. "-" cannot repeat`);he.customSchemes.push([t,e])}function iN(){he.scanner=Xw(he.customSchemes);for(let t=0;t<he.tokenQueue.length;t++)he.tokenQueue[t][1]({scanner:he.scanner});he.parser=tN(he.scanner.tokens);for(let t=0;t<he.pluginQueue.length;t++)he.pluginQueue[t][1]({scanner:he.scanner,parser:he.parser});return he.initialized=!0,he}function mc(t){return he.initialized||iN(),nN(he.parser.start,t,ng(he.scanner.start,t))}mc.scan=ng;function sg(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new pc(n),s=mc(t),o=[];for(let i=0;i<s.length;i++){const a=s[i];a.isLink&&(!e||a.t===e)&&r.check(a)&&o.push(a.toFormattedObject(r))}return o}const gc="[\0- -\u2029 ]",aN=new RegExp(gc),lN=new RegExp(`${gc}$`),cN=new RegExp(gc,"g");function uN(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function dN(t){return new pe({key:new Ce("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(l=>l.docChanged)&&!n.doc.eq(r.doc),o=e.some(l=>l.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,a=Rp(n.doc,[...e]);if(pi(a).forEach(({newRange:l})=>{const c=ik(r.doc,l,f=>f.isTextblock);let u,d;if(c.length>1)u=c[0],d=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(c.length){const f=r.doc.textBetween(l.from,l.to," "," ");if(!lN.test(f))return;u=c[0],d=r.doc.textBetween(u.pos,l.to,void 0," ")}if(u&&d){const f=d.split(aN).filter(Boolean);if(f.length<=0)return!1;const h=f[f.length-1],m=u.pos+d.lastIndexOf(h);if(!h)return!1;const y=mc(h).map(g=>g.toObject(t.defaultProtocol));if(!uN(y))return!1;y.filter(g=>g.isLink).map(g=>({...g,from:m+g.start+1,to:m+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>t.validate(g.value)).filter(g=>t.shouldAutoLink(g.value)).forEach(g=>{Yl(g.from,g.to,r.doc).some(x=>x.mark.type===t.type)||i.addMark(g.from,g.to,t.type.create({href:g.href}))})}}),!!i.steps.length)return i}})}function fN(t){return new pe({key:new Ce("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{const l=r.target;if(!l)return!1;const c=t.editor.view.dom;s=l.closest("a"),s&&!c.contains(s)&&(s=null)}if(!s)return!1;let o=!1;if(t.enableClickSelection&&(o=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var i,a;const l=zp(e.state,t.type.name),c=(i=s.href)!==null&&i!==void 0?i:l.href,u=(a=s.target)!==null&&a!==void 0?a:l.target;c&&(window.open(c,u),o=!0)}return o}}})}const hN=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,pN=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function og(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function mN(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&og(t,r)){r+=1;continue}let s=0;for(;r<e&&t[r]==="`";)s+=1,r+=1;n===0?n=s:s===n&&(n=0)}return n>0}function ig(t,e,n){var r,s;const[,o,i]=e;return(e.index?t[e.index-1]:void 0)==="!"||og(t,(r=e.index)!==null&&r!==void 0?r:0)||mN(t,(s=e.index)!==null&&s!==void 0?s:0)?!1:!!o.trim()&&n(i)}function ag(t){var e,n;const[r,s,o,,i,a,l]=t,c=(e=i??a)!==null&&e!==void 0?e:l;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:s,data:{href:o,title:c||null,markdown:!0}}}function gN(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function lg(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function yN(t){const e=Un({find:n=>{const r=hN.exec(n);return!r||!ig(n,r,t.isAllowedHref)?null:ag(r)},type:t.type,getAttributes:lg});return new Ts({find:e.find,handler:n=>{const r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function xN(t){const e=hn({find:n=>{var r,s;const o=[];for(const a of n.matchAll(pN))ig(n,a,t.isAllowedHref)&&o.push(ag(a));const i=((r=(s=t.findPlainUrls)===null||s===void 0?void 0:s.call(t,n))!==null&&r!==void 0?r:[]).filter(a=>!o.some(l=>gN(l,a)));return[...o,...i]},type:t.type,getAttributes:lg});return new Qp({find:e.find,handler:n=>{var r;const s=e.handler(n);return s!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),s}})}function bN(t){return new pe({key:new Ce("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:o}=e,{selection:i}=o,{empty:a}=i;if(a)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});const c=sg(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||s!==void 0&&!s(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Lt(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(cN,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}const cg=Jn.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(t=>{if(typeof t=="string"){zd(t);return}zd(t.scheme,t.optionalSlashes)})},onDestroy(){oN()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Lt(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Lt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Lt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Se(this.options.HTMLAttributes,t),0]:["a",Se(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,o;const i=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",a=(s=(o=t.attrs)===null||o===void 0?void 0:o.title)!==null&&s!==void 0?s:"",l=e.renderChildren(t);return a?`[${l}](${i} "${a}")`:`[${l}](${i})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Lt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Lt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[yN({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!Lt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const t=e=>{const n=[];if(e){const{protocols:r,defaultProtocol:s}=this.options;sg(e).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!Lt(i,r),protocols:r,defaultProtocol:s})).forEach(o=>{this.options.shouldAutoLink(o.value)&&n.push({text:o.value,data:{href:o.href},index:o.start})})}return n};return this.options.markdownLinks?[xN({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!Lt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[hn({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(dN({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Lt(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(fN({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(bN({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}});var cA=cg;const vN="listItem",Fd="textStyle",Hd=/^\s*([-+*])\s$/,ug=qe.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Se(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
131
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vN,this.editor.getAttributes(Fd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Sr({find:Hd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Sr({find:Hd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Fd),editor:this.editor})),[t]}}),kN=(t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:s}=r;if(!s.parent.isTextblock||s.parentOffset!==s.parent.content.size)return null;let o=-1;for(let h=s.depth;h>0;h-=1)if(s.node(h).type.name===e){o=h;break}if(o<0)return null;const i=s.node(o),a=s.index(o);if(a+1>=i.childCount)return null;const l=i.child(a+1);if(!n.includes(l.type.name))return null;const c=t.schema.nodes[e];let u=!1;if(l.forEach(h=>{h.type===c&&h.childCount>1&&(u=!0)}),!u)return null;const d=t.doc.resolve(s.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;const f=[];return d.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:o,nestedList:d,nestedListPos:s.after(),insertPos:s.after(o),items:f}},SN=(t,e,n,r)=>{const s=kN(t,n,r);if(!s)return!1;const{selection:o}=t,{nestedList:i,nestedListPos:a,insertPos:l,items:c}=s,u=t.tr;u.delete(a,a+i.nodeSize);const d=u.mapping.map(l);return u.insert(d,$.from(c)),u.setSelection(o.map(u.doc,u.mapping)),e&&e(u),!0},CN=(t,e,n)=>SN(t.state,t.view.dispatch,e,n),dg=(t,e)=>be.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>CN(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),fg=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Ys="abcdefghijklmnopqrstuvwxyz",hg=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function vi(t){let e=t,n="";for(const[r,s]of fg)for(;e>=r;)n+=s,e-=r;return n}function yc(t){return vi(t).toUpperCase()}function pg(t){const e=t.toLowerCase();let n=0,r=0;for(;n<e.length;){let s=!1;for(const[o,i]of fg)if(e.startsWith(i,n)){r+=o,n+=i.length,s=!0;break}if(!s)return 0}return r}function wN(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=pg(t);return e<=0?!1:(t===t.toLowerCase()?vi(e):yc(e))===t}function NN(t){const e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){const n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function Qo(t){if(t<=26)return Ys[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Ys[n]:Ys[e]+Ys[n]}function ki(t){if(!(!t||/^\d+$/.test(t))){if(wN(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function xc(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=ki(t);if(e==="i"||e==="I")return pg(t);if(e==="a"||e==="A"){const r=NN(t);return r>0?r:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function MN(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Qo(e);case"A":return Qo(e).toUpperCase();case"i":return vi(e);case"I":return yc(e);default:return String(e)}}function TN(t){var e;if(t.length===0)return!1;const n=(e=ki(t[0]))!==null&&e!==void 0?e:"numeric",r=xc(t[0]);if(r<1)return!1;for(let s=0;s<t.length;s++){const o=MN(n,r+s);if(t[s]!==o)return!1}return!0}function EN(t){return{type:ki(t),start:xc(t)}}function DN(t){const{type:e,start:n}=EN(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function ON(t,e,n=". "){const r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Qo(r)}${n}`;case"A":return`${Qo(r).toUpperCase()}${n}`;case"i":return`${vi(r)}${n}`;case"I":return`${yc(r)}${n}`;default:return`${r}${n}`}}function AN(t){var e,n;const r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function IN(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}const mg=qe.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Se(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;let s=[];if(t.tokens&&t.tokens.length>0){if(AN(t))return{type:"listItem",content:[{type:"paragraph",content:IN(t.text||"",e)}]};if(t.tokens.some(o=>o.type==="paragraph"))s=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const i=r(t.tokens.slice(1));s.push(...i)}}else s=r(t.tokens)}}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,n)=>Yp(t,e,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var s,o;const i=((s=r.meta)===null||s===void 0||(s=s.parentAttrs)===null||s===void 0?void 0:s.start)||1;return ON((o=r.meta)===null||o===void 0||(o=o.parentAttrs)===null||o===void 0?void 0:o.type,i-1+(r.index||0),". ")}return"- "},n),addExtensions(){return[dg(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),bc=(t,e)=>{const{$from:n}=e.selection,r=Ee(t,e.schema);let s=null,o=n.depth,i=n.pos,a=null;for(;o>0&&a===null;)s=n.node(o),s.type===r?a=o:(o-=1,i-=1);return a===null?null:{$pos:e.doc.resolve(i),depth:a}},gg=(t,e)=>{const n=bc(t,e);if(!n)return!1;const[,r]=yk(e,t,n.$pos.pos+4);return r},jN=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),o=t.doc.resolve(s).node();return!(!o||!n.includes(o.type.name))},Wd=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ut(t.state,e)&&jN(t.state,e,n)){const{$anchor:o}=t.state.selection,i=t.state.doc.resolve(o.before()-1),a=[];i.node().descendants((u,d)=>{u.type.name===e&&a.push({node:u,pos:d})});const l=a.at(-1);if(!l)return!1;const c=t.state.doc.resolve(i.start()+l.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},c.end()).joinForward().run()}if(!Ut(t.state,e)||!Sk(t.state))return!1;const{$from:r}=t.state.selection,s=r.depth-1;return r.node(s).type!==t.schema.nodes[e]||r.index(s)!==0?!1:t.chain().liftListItem(e).run()},RN=(t,e)=>{const n=gg(t,e),r=bc(t,e);return!r||!n?!1:n>r.depth},PN=(t,e)=>{const n=gg(t,e),r=bc(t,e);return!r||!n?!1:n<r.depth},Vd=(t,e)=>{if(!Ut(t.state,e)||!kk(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:RN(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():PN(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},LN=(t,e,n)=>{const{state:r}=t,{selection:s}=r;if(!s.empty)return!1;const{$from:o}=s;if(o.parentOffset!==0||!o.parent.isTextblock||Ut(r,e))return!1;const i=xk(o);if(!i||!n.includes(i.type.name))return!1;const a=i.lastChild;if(!a||a.type.name!==e)return!1;const l=o.parent;if(!a.canReplace(a.childCount,a.childCount,$.from(l)))return!1;const c=o.before(),u=o.after(),d=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,u).insert(d,$.from(l)),f.setSelection(V.create(f.doc,d+1)),f.scrollIntoView()),!0))},yg=be.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Vd(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Vd(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Wd(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Wd(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(const{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&LN(t,e,n))return!0;return!1}}}}),rl=new RegExp(`^(\\s*)(${hg})([.)])\\s+(.*)$`),$N=/^\s/,ur={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function _N(t){return rl.test(t.trimStart())}function BN(t){const e=t.trimStart();return ur.bulletItem.test(e)||_N(e)||ur.heading.test(e)||ur.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||ur.codeFence.test(e)||ur.blockMath.test(e)}function zN(t){return Object.values(ur).some(e=>e.test(t))}function FN(t){const e=[],n=[];let r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&BN(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function HN(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],o=s.match(rl);if(!o)break;const[,i,a,l,c]=o,u=i.length,d=parseInt(a,10),f=isNaN(d)?ki(a):void 0,h=isNaN(d)?xc(a):d,m=[c];let y=n+1;const g=[s];let x=!1;for(;y<t.length;){const b=t[y];if(b.match(rl))break;if(b.trim()==="")g.push(b),m.push(""),x=!0,y+=1;else if(b.match($N)){const v=b.length-b.trimStart().length,k=u+a.length+1;g.push(b),m.push(b.slice(Math.min(v,k))),y+=1}else{if(x||zN(b))break;g.push(b),m.push(b),y+=1}}e.push({indent:u,number:h,type:f,content:m.join(`
|
|
132
|
-
`).trim(),contentLines:m,raw:g.join(`
|
|
133
|
-
`)}),r=y,n=y}return[e,r]}const WN=new RegExp(`^(${hg})([.)])\\s+(.+)$`);function VN(t){const e=t.split(`
|
|
134
|
-
`).filter(r=>r.trim().length>0);if(e.length===0)return null;const n=[];for(const r of e){const s=r.trim().match(WN);if(!s)return null;n.push({marker:s[1],content:s[3]})}return TN(n.map(r=>r.marker))?{type:"orderedList",attrs:DN(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function xg(t,e,n){const r=[];let s=0;for(;s<t.length;){const o=t[s];if(o.indent===e){const{paragraphLines:i,blockLines:a}=FN(o.contentLines),l=i.join(`
|
|
135
|
-
`).trim(),c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=a.join(`
|
|
136
|
-
`).trim();if(u){const h=n.blockTokens(u);c.push(...h)}let d=s+1;const f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){const h=xg(f,Math.min(...f.map(m=>m.indent)),n);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(m=>m.raw).join(`
|
|
137
|
-
`)})}r.push({type:"list_item",raw:o.raw,tokens:c}),s=d}else s+=1}return r}function UN(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const o=e.parseChildren([s]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([s]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}const qN="listItem",Ud="textStyle",qd=/^(\d+)\.\s$/;function Kd(t){const e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}const bg=qe.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{const e=t.getAttribute("type");if(e)return e;const n=t.getAttribute("style");if(n){const s=Kd(n);if(s)return s}const r=t.querySelector("li");if(r){const s=r.getAttribute("style");if(s){const o=Kd(s);if(o)return o}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,type:n,...r}=t,s=Se(this.options.HTMLAttributes,r);return e!==1&&(s.start=e),n&&n!=="1"&&(s.type=n),["ol",s,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.typeMarker,s=t.items?UN(t.items,e):[],o={};return n!==1&&(o.start=n),r&&(o.type=r),Object.keys(o).length>0?{type:"orderedList",attrs:o,content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
138
|
-
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,s;const o=t.split(`
|
|
139
|
-
`),[i,a]=HN(o);if(i.length===0)return;const l=xg(i,i[0].indent,n);if(l.length!==0)return{type:"list",ordered:!0,start:((r=i[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(s=i[0])===null||s===void 0?void 0:s.type,items:l,raw:o.slice(0,a).join(`
|
|
140
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(qN,this.editor.getAttributes(Ud)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new pe({props:{handlePaste:(t,e)=>{var n,r;const s=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(s?.trim())return!1;const o=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!o)return!1;const i=VN(o);if(!i)return!1;try{const a=t.state.schema.nodeFromJSON(i),l=t.state.tr.replaceSelectionWith(a);return t.dispatch(l),!0}catch{return!1}}}})]},addInputRules(){const t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1];let e=Sr({find:qd,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Sr({find:qd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Ud)}),joinPredicate:t,editor:this.editor})),[e]}}),KN=/^\s*(\[([( |x])?\])\s$/,JN="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",YN=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},GN=qe.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Se(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return Yp(t,e,r)},addExtensions(){return this.options.nested?[dg(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");i.style.cssText=JN;const c=d=>{const f=YN(d,d.attrs.checked,this.options.a11y);a.setAttribute("aria-label",f),i.textContent=f};c(t),o.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const m=n();if(typeof m!="number")return!1;const y=h.doc.nodeAt(m);return h.setNodeMarkup(m,void 0,{...y?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{s.setAttribute(d,f)}),s.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,o.append(a,i),s.append(o,l),Object.entries(e).forEach(([d,f])=>{s.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:l,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,c(d);const f=r.extensionManager.attributes,h=kr(d,f),m=new Set(Object.keys(h)),y=this.options.HTMLAttributes;return u.forEach(g=>{m.has(g)||(g in y?s.setAttribute(g,y[g]):s.removeAttribute(g))}),Object.entries(h).forEach(([g,x])=>{x==null?g in y?s.setAttribute(g,y[g]):s.removeAttribute(g):s.setAttribute(g,x)}),u=m,!0}}}},addInputRules(){return[Sr({find:KN,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),XN=qe.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Se(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
141
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=o=>{const i=ad(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},n);if(i){const a={type:"taskList",raw:i.raw,items:i.items},l=o.slice(i.raw.length);return l.trim()?[a,...n.blockTokens(l)]:[a]}return n.blockTokens(o)},s=ad(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});be.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(ug.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(mg.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(yg.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(bg.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(GN.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(XN.configure(this.options.taskList)),t}});const Gs=" ",ta=" ",QN=qe.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Se(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Gs||n[0].text===Gs||n[0].raw===ta||n[0].text===ta)&&r.length===1&&r[0].type==="text"&&(r[0].text===Gs||r[0].text===ta)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";const r=Array.isArray(t.content)?t.content:[];if(r.length===0){var s,o;const i=Array.isArray(n==null||(s=n.previousNode)===null||s===void 0?void 0:s.content)?n.previousNode.content:[];return(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.type)==="paragraph"&&i.length===0?Gs:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ZN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,eM=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,tM=Jn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Se(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Un({find:ZN,type:this.type})]},addPasteRules(){return[hn({find:eM,type:this.type})]}}),nM=qe.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),rM=Jn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Se(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;const s=r[2].trim();return{type:"underline",raw:r[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),sM=be.create({name:"starterKit",addExtensions(){const t=[];if(this.options.bold!==!1&&t.push(Tw.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(Sw.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(ug.configure(this.options.bulletList)),this.options.code!==!1&&t.push(Ow.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(jw.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Rw.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(rw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(sw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(Pw.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(Lw.configure(this.options.heading)),this.options.undoRedo!==!1&&t.push(xw.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&t.push($w.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Hw.configure(this.options.italic)),this.options.listItem!==!1&&t.push(mg.configure(this.options.listItem)),this.options.listKeymap!==!1){var e;t.push(yg.configure((e=this.options)===null||e===void 0?void 0:e.listKeymap))}if(this.options.link!==!1){var n;t.push(cg.configure((n=this.options)===null||n===void 0?void 0:n.link))}if(this.options.orderedList!==!1&&t.push(bg.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(QN.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(tM.configure(this.options.strike)),this.options.text!==!1&&t.push(nM.configure(this.options.text)),this.options.underline!==!1){var r;t.push(rM.configure((r=this.options)===null||r===void 0?void 0:r.underline))}if(this.options.trailingNode!==!1){var s;t.push(yw.configure((s=this.options)===null||s===void 0?void 0:s.trailingNode))}return t}});var oM=sM;const bn=16,sl=2.5,ol=(bn-sl)/2,na=2*Math.PI*ol;function vg(t){const e=_.c(29),{usage:n}=t;if(!n)return null;const{totalTokens:r,inputTokens:s,outputTokens:o,cost:i}=n;if(!r&&!s&&!o)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(P1,{size:12}),e[0]=a):a=e[0];let l;e[1]!==i||e[2]!==r?(l=i>0?`$${i.toFixed(4)}`:r.toLocaleString(),e[1]=i,e[2]=r,e[3]=l):l=e[3];let c;e[4]!==l?(c=p.jsx(_n,{asChild:!0,children:p.jsxs("span",{className:"inline-flex items-center text-muted-foreground [@media(hover:hover)]:hover:text-foreground pl-1 h-6 gap-1 whitespace-nowrap shrink-0 cursor-default",children:[a,p.jsx("span",{className:"text-sm font-mono tabular-nums",children:l})]})}),e[4]=l,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx("p",{className:"text-muted text-[10px] mb-1",children:"tokens"}),e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("span",{className:"text-muted",children:"in"}),e[7]=d):d=e[7];let f;e[8]!==s?(f=s.toLocaleString(),e[8]=s,e[9]=f):f=e[9];let h;e[10]!==f?(h=p.jsx("span",{className:"text-right tabular-nums",children:f}),e[10]=f,e[11]=h):h=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx("span",{className:"text-muted",children:"out"}),e[12]=m):m=e[12];const y=o-(n.reasoningTokens??0);let g;e[13]!==y?(g=y.toLocaleString(),e[13]=y,e[14]=g):g=e[14];let x;e[15]!==g?(x=p.jsx("span",{className:"text-right tabular-nums",children:g}),e[15]=g,e[16]=x):x=e[16];let b;e[17]!==n?(b=(n.cacheReadTokens>0||n.cacheWriteTokens>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:`${(Cl(n)*100).toFixed(0)}%`})]}),e[17]=n,e[18]=b):b=e[18];let v;e[19]!==i?(v=i>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",i.toFixed(4)]})]}),e[19]=i,e[20]=v):v=e[20];let k;e[21]!==x||e[22]!==b||e[23]!==v||e[24]!==h?(k=p.jsxs(Bn,{side:"top",className:"font-mono text-[11px]",children:[u,p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[d,h,m,x,b,v]})]}),e[21]=x,e[22]=b,e[23]=v,e[24]=h,e[25]=k):k=e[25];let N;return e[26]!==k||e[27]!==c?(N=p.jsxs(zn,{children:[c,k]}),e[26]=k,e[27]=c,e[28]=N):N=e[28],N}function iM(t){const e=_.c(19),{usage:n,duration:r}=t,s=r!=null&&r>0,o=n!=null&&(n.cost??0)>0,i=n!=null&&(n.totalTokens??0)>0;if(!s&&!o&&!i)return null;let a;e[0]!==r||e[1]!==s?(a=s?Fn(r/1e3):null,e[0]=r,e[1]=s,e[2]=a):a=e[2];const l=a;let c;e[3]!==r||e[4]!==l||e[5]!==n?(c=l&&p.jsxs(zn,{children:[p.jsx(_n,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:l})}),p.jsxs(Bn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"thinking"}),p.jsx("span",{className:"tabular-nums",children:Fn(r/1e3)}),(n?.reasoningTokens??0)>0&&p.jsxs("span",{className:"ml-2 opacity-50",children:[n.reasoningTokens.toLocaleString()," tok"]})]})]}),e[3]=r,e[4]=l,e[5]=n,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==s||e[9]!==i?(u=s&&(o||i)&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),e[7]=o,e[8]=s,e[9]=i,e[10]=u):u=e[10];let d;e[11]!==o||e[12]!==i||e[13]!==n?(d=(o||i)&&p.jsxs(zn,{children:[p.jsx(_n,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:o?`$${n.cost.toFixed(4)}`:`${n.totalTokens.toLocaleString()} tok`})}),p.jsxs(Bn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"tokens"}),p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[p.jsx("span",{className:"opacity-60",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:(n.inputTokens??0).toLocaleString()}),p.jsx("span",{className:"opacity-60",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:((n.outputTokens??0)-(n?.reasoningTokens??0)).toLocaleString()}),(n?.reasoningTokens??0)>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"think"}),p.jsx("span",{className:"text-right tabular-nums",children:n.reasoningTokens.toLocaleString()})]}),((n?.cacheReadTokens??0)>0||(n?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:`${(Cl(n)*100).toFixed(0)}%`})]})]})]})]}),e[11]=o,e[12]=i,e[13]=n,e[14]=d):d=e[14];let f;return e[15]!==c||e[16]!==u||e[17]!==d?(f=p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[c,u,d]}),e[15]=c,e[16]=u,e[17]=d,e[18]=f):f=e[18],f}function uA(t){const e=_.c(49),{usage:n,totalTokens:r,contextWindow:s,onOpenContextPanel:o}=t,i=Math.min(r/s*100,100),a=na-i/100*na,l=n?.cost??0,c=n?.inputTokens??0,u=n?.outputTokens??0;let d;e[0]!==i?(d=i.toFixed(0),e[0]=i,e[1]=d):d=e[1];let f;e[2]!==l?(f=l>0?`, $${l.toFixed(2)}`:"",e[2]=l,e[3]=f):f=e[3];const h=`Context usage: ${d}%${f}`,m=o?"cursor-pointer":"cursor-default";let y;e[4]!==m?(y=G("flex items-center gap-1.5 text-muted-foreground hover:text-foreground h-6 px-1 shrink-0",m),e[4]=m,e[5]=y):y=e[5];let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx("circle",{cx:bn/2,cy:bn/2,r:ol,fill:"none",stroke:"currentColor",strokeWidth:sl,className:"opacity-15"}),e[6]=g):g=e[6];const x=i>90?"text-destructive":i>70?"text-warning":"text-muted-foreground";let b;e[7]!==x?(b=G(x),e[7]=x,e[8]=b):b=e[8];let v;e[9]!==a||e[10]!==b?(v=p.jsxs("svg",{width:bn,height:bn,className:"-rotate-90","aria-hidden":"true",children:[g,p.jsx("circle",{cx:bn/2,cy:bn/2,r:ol,fill:"none",stroke:"currentColor",strokeWidth:sl,strokeDasharray:na,strokeDashoffset:a,strokeLinecap:"round",className:b})]}),e[9]=a,e[10]=b,e[11]=v):v=e[11];let k;e[12]!==i?(k=i.toFixed(0),e[12]=i,e[13]=k):k=e[13];let N;e[14]!==l?(N=l>0?` · $${l.toFixed(2)}`:"",e[14]=l,e[15]=N):N=e[15];let C;e[16]!==k||e[17]!==N?(C=p.jsxs("span",{className:"inline-block overflow-hidden whitespace-nowrap max-w-0 opacity-0 transition-[max-width,opacity] duration-200 ease-out @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100 text-[11px] font-mono tabular-nums",children:[k,"%",N]}),e[16]=k,e[17]=N,e[18]=C):C=e[18];let S;e[19]!==o||e[20]!==C||e[21]!==h||e[22]!==y||e[23]!==v?(S=p.jsx(_n,{asChild:!0,children:p.jsxs("button",{type:"button",onClick:o,"aria-label":h,className:y,children:[v,C]})}),e[19]=o,e[20]=C,e[21]=h,e[22]=y,e[23]=v,e[24]=S):S=e[24];let w;e[25]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx("span",{className:"text-muted",children:"context"}),e[25]=w):w=e[25];let M;e[26]!==r?(M=r.toLocaleString(),e[26]=r,e[27]=M):M=e[27];let T;e[28]!==s?(T=s.toLocaleString(),e[28]=s,e[29]=T):T=e[29];let O;e[30]!==i?(O=i.toFixed(1),e[30]=i,e[31]=O):O=e[31];let A;e[32]!==M||e[33]!==T||e[34]!==O?(A=p.jsxs("span",{className:"text-right tabular-nums",children:[M," / ",T," (",O,"%)"]}),e[32]=M,e[33]=T,e[34]=O,e[35]=A):A=e[35];let P;e[36]!==l||e[37]!==c||e[38]!==u?(P=l>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",l.toFixed(4)]}),p.jsx("span",{className:"text-muted",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:c.toLocaleString()}),p.jsx("span",{className:"text-muted",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:u.toLocaleString()})]}),e[36]=l,e[37]=c,e[38]=u,e[39]=P):P=e[39];let D;e[40]!==n?(D=((n?.cacheReadTokens??0)>0||(n?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:`${(Cl(n)*100).toFixed(0)}%`})]}),e[40]=n,e[41]=D):D=e[41];let E;e[42]!==A||e[43]!==P||e[44]!==D?(E=p.jsx(Bn,{side:"top",className:"font-mono text-[11px]",children:p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[w,A,P,D]})}),e[42]=A,e[43]=P,e[44]=D,e[45]=E):E=e[45];let j;return e[46]!==S||e[47]!==E?(j=p.jsxs(zn,{children:[S,E]}),e[46]=S,e[47]=E,e[48]=j):j=e[48],j}var Si="Collapsible",[aM,dA]=E1(Si),[lM,vc]=aM(Si),kg=L.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...a}=t,[l,c]=S1({prop:r,defaultProp:s??!1,onChange:i,caller:Si});return p.jsx(lM,{scope:n,disabled:o,contentId:C1(),open:l,onOpenToggle:L.useCallback(()=>c(u=>!u),[c]),children:p.jsx(pl.div,{"data-state":wc(l),"data-disabled":o?"":void 0,...a,ref:e})})});kg.displayName=Si;var Sg="CollapsibleTrigger",kc=L.forwardRef((t,e)=>{const{__scopeCollapsible:n,...r}=t,s=vc(Sg,n);return p.jsx(pl.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":wc(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:w1(t.onClick,s.onOpenToggle)})});kc.displayName=Sg;var Sc="CollapsibleContent",Cc=L.forwardRef((t,e)=>{const{forceMount:n,...r}=t,s=vc(Sc,t.__scopeCollapsible);return p.jsx(N1,{present:n||s.open,children:({present:o})=>p.jsx(cM,{...r,ref:e,present:o})})});Cc.displayName=Sc;var cM=L.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=t,i=vc(Sc,n),[a,l]=L.useState(r),c=L.useRef(null),u=M1(e,c),d=L.useRef(0),f=d.current,h=L.useRef(0),m=h.current,y=i.open||a,g=L.useRef(y),x=L.useRef(void 0);return L.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),T1(()=>{const b=c.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const v=b.getBoundingClientRect();d.current=v.height,h.current=v.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),p.jsx(pl.div,{"data-state":wc(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!y,...o,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...t.style},children:y&&s})});function wc(t){return t?"open":"closed"}var uM=kg,fA=kc,hA=Cc;function dM(t){const e=_.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=p.jsx(uM,{"data-slot":"collapsible",...n}),e[2]=n,e[3]=r):r=e[3],r}function fM(t){const e=_.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=p.jsx(kc,{"data-slot":"collapsible-trigger",...n}),e[2]=n,e[3]=r):r=e[3],r}function hM(t){const e=_.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n?(s=G("overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down motion-reduce:animate-none",n),e[3]=n,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=p.jsx(Cc,{"data-slot":"collapsible-content",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function ne({icon:t,title:e,usage:n,summary:r,state:s,detail:o,detailVariant:i="code",forceOpen:a,variant:l="default",trailing:c,iconDestructive:u,alwaysChevron:d,defaultOpen:f,children:h}){const m=J(),[y,g]=L.useState(f??!1),{handleCopy:x,copied:b}=$f(),v=s==="loading",k=s==="error",C=!!(o&&o.trim())||!!h,S=l==="subtask",w=(a??!1)||y,M=ny({initial:v?"instant":!1}),T=p.jsxs(dM,{open:w,onOpenChange:a?void 0:g,className:"min-w-0",children:[p.jsxs(fM,{disabled:!C,className:G("group/tool flex items-center gap-2 w-full py-2.5 text-left transition-colors",C&&"[@media(hover:hover)]:hover:bg-accent/30",!C&&"cursor-default",v&&"shimmer"),"aria-disabled":!C,children:[p.jsx("div",{className:"relative shrink-0 size-4 flex items-center justify-center",children:d?p.jsx(ma,{className:G("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",w&&"rotate-90")}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:G("absolute inset-0 flex items-center justify-center [&>svg]:size-4 transition-opacity duration-150",u?"[&>svg]:text-destructive/70":k?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75",C&&(w?"opacity-0":"[@media(hover:hover)]:group-hover/tool:opacity-0")),children:t}),C&&p.jsx("div",{className:G("absolute inset-0 flex items-center justify-center transition-opacity duration-150",w?"opacity-100":"opacity-0 [@media(hover:hover)]:group-hover/tool:opacity-100"),children:p.jsx(ma,{className:G("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",w&&"rotate-90")})})]})}),p.jsx("span",{className:G("shrink-0 text-[14px] font-normal",k?"text-warning/80":"text-foreground"),children:e}),r?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:r})}):p.jsx("div",{className:"flex-1"}),c&&p.jsx("div",{className:"shrink-0 flex items-center gap-1 [&_svg]:size-3.5 [&_svg]:text-muted-foreground/50",children:c}),p.jsx(vg,{usage:n})]}),C&&p.jsx(hM,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:h||(i==="prose"?p.jsx("div",{className:"mt-1 mb-1",children:p.jsx("div",{ref:M.scrollRef,className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:p.jsx("p",{ref:M.contentRef,className:"text-xs text-muted-foreground/70 whitespace-pre-wrap leading-relaxed wrap-break-word",children:o})})}):p.jsx("div",{className:"ml-[20px] pl-3 border-l border-border/30 mt-0.5 pb-1",children:p.jsx("div",{ref:M.scrollRef,className:"flex flex-col max-h-48 overflow-y-auto",children:p.jsxs("div",{ref:M.contentRef,className:"flex items-start justify-between gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:p.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:o})}),p.jsx("button",{type:"button",onClick:()=>x(o),className:"shrink-0 p-1.5 rounded-md text-muted-foreground/50 [@media(hover:hover)]:hover:text-foreground [@media(hover:hover)]:hover:bg-accent/50 transition-colors active:scale-[0.97]","aria-label":m("common.copy"),children:b?p.jsx(xl,{className:"size-3.5"}):p.jsx(Lf,{className:"size-3.5"})})]})})}))})]});return S?p.jsx("div",{className:"pl-4 border-l border-border/40 ml-1.5",children:T}):T}function Le(t){const e=_.c(4),{latency:n}=t;if(n==null||n<=0)return null;let r;e[0]!==n?(r=Fn(n),e[0]=n,e[1]=r):r=e[1];let s;return e[2]!==r?(s=p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground",children:r}),e[2]=r,e[3]=s):s=e[3],s}const Cg=4;function wg(t){const e=_.c(8),{count:n,noun:r,onClick:s}=t,o=J();let i;e[0]!==n||e[1]!==r||e[2]!==o?(i=o("common.seeAll",{count:n,noun:r}),e[0]=n,e[1]=r,e[2]=o,e[3]=i):i=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(Pf,{className:"size-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"}),e[4]=a):a=e[4];let l;return e[5]!==s||e[6]!==i?(l=p.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-center gap-1.5 rounded-lg border border-border bg-card px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:[i,a]}),e[5]=s,e[6]=i,e[7]=l):l=e[7],l}function Ng(t){const e=_.c(12),{message:n,className:r}=t,s=n.created_at??n.metadata?.created_at??null;let o,i,a,l;if(e[0]!==r||e[1]!==s){l=Symbol.for("react.early_return_sentinel");e:{const u=bl(s);if(u===null){l=null;break e}const d=new Date(u);o=d.toLocaleString(),e[6]!==r?(i=G("text-[11px] text-muted-foreground/60 select-none",r),e[6]=r,e[7]=i):i=e[7],a=d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}e[0]=r,e[1]=s,e[2]=o,e[3]=i,e[4]=a,e[5]=l}else o=e[2],i=e[3],a=e[4],l=e[5];if(l!==Symbol.for("react.early_return_sentinel"))return l;let c;return e[8]!==o||e[9]!==i||e[10]!==a?(c=p.jsx("span",{title:o,className:i,children:a}),e[8]=o,e[9]=i,e[10]=a,e[11]=c):c=e[11],c}function il(t){const e=_.c(9),{since:n}=t;let r;e[0]!==n?(r=()=>Yc(n,Date.now()),e[0]=n,e[1]=r):r=e[1];const[s,o]=L.useState(r);let i,a;e[2]!==n?(i=()=>{const d=setInterval(()=>o(Yc(n,Date.now())),100);return()=>clearInterval(d)},a=[n],e[2]=n,e[3]=i,e[4]=a):(i=e[3],a=e[4]),L.useEffect(i,a);const l=s/1e3;let c;e[5]!==l?(c=Fn(l),e[5]=l,e[6]=c):c=e[6];let u;return e[7]!==c?(u=p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground/50",children:c}),e[7]=c,e[8]=u):u=e[8],u}const Mg=[{delay:0},{delay:100},{delay:200},{delay:100},{delay:200},{delay:200},{delay:300},{delay:300},{delay:400}];function pM(){const t=_.c(5),[e]=L.useState(mM);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={gridTemplateColumns:"repeat(3, 3px)",gap:"1.5px",width:"fit-content"},t[0]=n):n=t[0];let r;t[1]!==e?(r=Mg.map((o,i)=>{const{delay:a}=o;return p.jsx("div",{className:"rounded-[1px]",style:{width:3,height:3,"--cell-color":e[i],animation:"grid-ripple 1s ease infinite",animationDelay:`${a}ms`}},i)}),t[1]=e,t[2]=r):r=t[2];let s;return t[3]!==r?(s=p.jsx("div",{className:"grid",style:n,children:r}),t[3]=r,t[4]=s):s=t[4],s}function mM(){const t=`var(--chart-${Math.ceil(Math.random()*5)})`;return Mg.map(()=>Math.random()<.6?"color-mix(in srgb, var(--muted-foreground) 25%, transparent)":t)}const Jd=new Map;function Tg(t){let e=Jd.get(t);return e||(e={tick:0,subscribers:new Set,intervalId:null},Jd.set(t,e)),e}function gM(t,e){const n=Tg(t);return n.subscribers.add(e),n.intervalId===null&&(n.intervalId=setInterval(()=>{n.tick+=1;for(const r of n.subscribers)r()},t)),()=>{n.subscribers.delete(e),n.subscribers.size===0&&n.intervalId!==null&&(clearInterval(n.intervalId),n.intervalId=null)}}function Nc(t){const e=_.c(3),n=t===void 0?6e4:t;let r,s;return e[0]!==n?(r=o=>gM(n,o),s=()=>Tg(n).tick,e[0]=n,e[1]=r,e[2]=s):(r=e[1],s=e[2]),L.useSyncExternalStore(r,s,yM)}function yM(){return 0}function xM(t){return{planning:{icon:p.jsx($1,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:t("chat.thinkingIndicator.planningLabel"),detail:t("chat.thinkingIndicator.planningDetail")},thinking:{icon:p.jsx(ri,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:t("chat.thinkingIndicator.thinkingLabel"),detail:t("chat.thinkingIndicator.thinkingDetail")}}}const bM=1200;function al(t){const e=_.c(8),{icon:n,title:r,summary:s,detail:o,state:i,detailVariant:a,trailing:l}=t,c=a===void 0?"prose":a;let u;return e[0]!==o||e[1]!==c||e[2]!==n||e[3]!==i||e[4]!==s||e[5]!==r||e[6]!==l?(u=p.jsx(ne,{icon:n,title:r,summary:s,detail:o,state:i,detailVariant:c,trailing:l}),e[0]=o,e[1]=c,e[2]=n,e[3]=i,e[4]=s,e[5]=r,e[6]=l,e[7]=u):u=e[7],u}function vM(t){const e=_.c(22),{startedAt:n}=t,r=J(),s=wr()?.runStatusStage??null,[o,i]=L.useState("planning");let a,l;if(e[0]!==s?(a=()=>{if(s!==null)return;const y=setTimeout(()=>{i("thinking")},bM);return()=>{clearTimeout(y)}},l=[s],e[0]=s,e[1]=a,e[2]=l):(a=e[1],l=e[2]),L.useEffect(a,l),s!==null){let y;e[3]!==s||e[4]!==r?(y=g0(r,s),e[3]=s,e[4]=r,e[5]=y):y=e[5];const g=y;let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx(ri,{className:"size-4"}),e[6]=x):x=e[6];const b=`${g.label}...`;let v;e[7]!==n?(v=n!==null&&p.jsx(il,{since:n}),e[7]=n,e[8]=v):v=e[8];let k;return e[9]!==g.detail||e[10]!==b||e[11]!==v?(k=p.jsx(al,{icon:x,title:b,summary:g.detail,state:"loading",trailing:v}),e[9]=g.detail,e[10]=b,e[11]=v,e[12]=k):k=e[12],k}let c;e[13]!==r?(c=xM(r),e[13]=r,e[14]=c):c=e[14];const d=c[o],f=`${d.label}...`;let h;e[15]!==n?(h=n!==null&&p.jsx(il,{since:n}),e[15]=n,e[16]=h):h=e[16];let m;return e[17]!==d.detail||e[18]!==d.icon||e[19]!==f||e[20]!==h?(m=p.jsx(al,{icon:d.icon,title:f,summary:d.detail,state:"loading",trailing:h}),e[17]=d.detail,e[18]=d.icon,e[19]=f,e[20]=h,e[21]=m):m=e[21],m}function kM(t){const e=_.c(3),{startedAt:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(pM,{}),e[0]=r):r=e[0];let s;return e[1]!==n?(s=p.jsxs("div",{className:"flex items-center gap-2.5 mt-1 pb-1 text-muted-foreground/40 select-none",children:[r,p.jsx(il,{since:n})]}),e[1]=n,e[2]=s):s=e[2],s}const SM=2e4;function CM(t){const e=_.c(9),{startedAt:n}=t,r=J();Nc(1e3);const s=wr(),i=(n!==null?Date.now()-n:0)>=SM;let a;e[0]!==n?(a=p.jsx(vM,{startedAt:n}),e[0]=n,e[1]=a):a=e[1];let l;e[2]!==i||e[3]!==s||e[4]!==r?(l=i&&s?.stop&&p.jsxs("div",{className:"flex items-center gap-2 pb-1 text-[13px] text-muted-foreground/60",children:[p.jsx("span",{children:r("chat.thinkingIndicator.takingLonger")}),p.jsx("button",{type:"button",onClick:()=>s.stop(),className:"text-muted-foreground hover:text-foreground underline underline-offset-2",children:r("chat.thinkingIndicator.cancel")})]}),e[2]=i,e[3]=s,e[4]=r,e[5]=l):l=e[5];let c;return e[6]!==a||e[7]!==l?(c=p.jsxs("div",{className:"flex flex-col gap-0.5",children:[a,l]}),e[6]=a,e[7]=l,e[8]=c):c=e[8],c}function wM(t){const e=_.c(24),{duration:n,parts:r,isStreaming:s}=t,o=J();let i;e[0]!==r?(i=r.every(TM),e[0]=r,e[1]=i):i=e[1];const a=i;let l;e[2]!==n||e[3]!==o?(l=n&&n/1e3>1?o("chat.thinkingIndicator.thoughtFor",{duration:Fn(n/1e3)}):o("chat.thinkingIndicator.thought"),e[2]=n,e[3]=o,e[4]=l):l=e[4];const c=l;let u;if(e[5]!==a||e[6]!==s||e[7]!==r){const v=r.map(MM).join(`
|
|
142
|
-
`).trim().split(`
|
|
143
|
-
`).filter(Boolean),k=s?v[v.length-1]??"":v[0]??"";u=!a&&k?k.length>100?k.slice(0,100)+"…":k:void 0,e[5]=a,e[6]=s,e[7]=r,e[8]=u}else u=e[8];const d=u;let f;if(e[9]!==a||e[10]!==r){const b=r.map(NM).join(`
|
|
144
|
-
|
|
145
|
-
`);f=!a&&b.trim()?b:null,e[9]=a,e[10]=r,e[11]=f}else f=e[11];const h=f;let m;e[12]!==s?(m=s?p.jsx(ri,{className:"size-4"}):p.jsx(L1,{className:"size-4"}),e[12]=s,e[13]=m):m=e[13];let y;e[14]!==s||e[15]!==o||e[16]!==c?(y=s?o("chat.thinkingIndicator.thinking"):c,e[14]=s,e[15]=o,e[16]=c,e[17]=y):y=e[17];const g=s?"loading":"idle";let x;return e[18]!==h||e[19]!==d||e[20]!==m||e[21]!==y||e[22]!==g?(x=p.jsx(al,{icon:m,title:y,summary:d,detail:h,state:g,detailVariant:"prose"}),e[18]=h,e[19]=d,e[20]=m,e[21]=y,e[22]=g,e[23]=x):x=e[23],x}function NM(t){return t.text??""}function MM(t){return t.text??""}function TM(t){return t.text?.includes("REDACTED")}function EM(t){const e={...t};return delete e.sandboxMap,e}function DM(t){const e=_.c(24),{org:n}=xt(),r=mf(),s=y0(),o=gf();let i;e[0]!==o||e[1]!==t?(i=async y=>{if(!t)throw new Error("useTaskExpandedTools: no task in context");const x=(await o.call("COLLECTION_THREADS_GET",{id:t})).item?.metadata??{},v=(x.expanded_tools??[]).filter(N=>N.toolName!==y.toolName);v.push({...y,expandedAt:new Date().toISOString()});const k={...EM(x),expanded_tools:v};return await o.call("COLLECTION_THREADS_UPDATE",{id:t,data:{metadata:k}}),v},e[0]=o,e[1]=t,e[2]=i):i=e[2];let a,l,c;e[3]!==n||e[4]!==r||e[5]!==t?(a=async y=>{const g=ht.ensureTask(n.id,t??"");await r.cancelQueries({queryKey:g});const x=r.getQueryData(g),v=(x?.metadata?.expanded_tools??[]).filter(k=>k.toolName!==y.toolName);return v.push({...y,expandedAt:new Date().toISOString()}),r.setQueryData(g,k=>k&&{...k,metadata:{...k.metadata??{},expanded_tools:v}}),{previous:x}},l=()=>{r.invalidateQueries({queryKey:ht.ensureTask(n.id,t??"")})},c=(y,g,x)=>{const b=ht.ensureTask(n.id,t??"");x?.previous===void 0?r.removeQueries({queryKey:b,exact:!0}):r.setQueryData(b,x.previous),fa.error(y instanceof Error?y.message:"Failed to expand tool")},e[3]=n,e[4]=r,e[5]=t,e[6]=a,e[7]=l,e[8]=c):(a=e[6],l=e[7],c=e[8]);let u;e[9]!==i||e[10]!==a||e[11]!==l||e[12]!==c?(u={mutationFn:i,onMutate:a,onSuccess:l,onError:c},e[9]=i,e[10]=a,e[11]=l,e[12]=c,e[13]=u):u=e[13];const d=D1(u);let f;e[14]!==s||e[15]!==d||e[16]!==n||e[17]!==r||e[18]!==t?(f=y=>{if(!t||!s)return;const g=ht.ensureTask(n.id,t),x=r.getQueryData(g),v=(x?.metadata?.expanded_tools??[]).filter(N=>N.toolName!==y.toolName);v.push({...y,expandedAt:new Date().toISOString()});const k={...x?.metadata??{},expanded_tools:v};r.setQueryData(g,N=>N&&{...N,metadata:k}),s.patchThread({id:t,metadata:k}),d.mutate(y)},e[14]=s,e[15]=d,e[16]=n,e[17]=r,e[18]=t,e[19]=f):f=e[19];const h=f;let m;return e[20]!==h||e[21]!==d.isPending||e[22]!==d.mutate?(m={addOrReplace:d.mutate,addOrReplaceEager:h,isPending:d.isPending},e[20]=h,e[21]=d.isPending,e[22]=d.mutate,e[23]=m):m=e[23],m}function OM(t){if(t<1024)return`${t} B`;if(t<1024*1024){const n=t/1024;return n<10?`${n.toFixed(1)} KB`:`${Math.round(n)} KB`}const e=t/(1024*1024);return e<10?`${e.toFixed(1)} MB`:`${Math.round(e)} MB`}function AM(t,e,n,r){const{data:s,isLoading:o}=ni({queryKey:ht.toolDefinitionLookup(e,n,t),queryFn:async()=>{if(!t||!e)return null;const i=await Z1({connectionId:e,orgId:n,orgSlug:r});try{const{tools:a}=await i.listTools(),l=dm(t);return a.find(c=>c.name===l)??null}finally{await i.close().catch(()=>{})}},enabled:!!t&&!!e,staleTime:6e4,gcTime:3e5,retry:!1});return{toolDef:s??void 0,isLoading:o}}const IM={read:{icon:Kc,labelKey:"chat.generic.tool.read"},write:{icon:E0,labelKey:"chat.generic.tool.write"},edit:{icon:H1,labelKey:"chat.generic.tool.edit"},grep:{icon:O0,labelKey:"chat.generic.tool.grep"},glob:{icon:D0,labelKey:"chat.generic.tool.glob"},bash:{icon:F1,labelKey:"chat.generic.tool.bash"},read_tool_output:{icon:Kc,labelKey:"chat.generic.tool.readToolOutput"},read_resource:{icon:z1,labelKey:"chat.generic.tool.readResource"},read_prompt:{icon:ha,labelKey:"chat.generic.tool.readPrompt"},skill:{icon:ha,labelKey:"chat.generic.tool.skill"},enable_tool:{icon:T0,labelKey:"chat.generic.tool.enableTool"},open_in_agent:{icon:B1,labelKey:"chat.generic.tool.openInAgent"},sandbox:{icon:_1,labelKey:"chat.generic.tool.sandbox"}},Eg="studio:bash-sleep-start:v1",jM=200;function RM(t,e,n,r=jM){const s=t.filter(([o])=>o!==e);for(s.push([e,n]);s.length>r;)s.shift();return s}function PM(){try{const t=sessionStorage.getItem(Eg);if(!t)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(n=>Array.isArray(n)&&n.length===2&&typeof n[0]=="string"&&Number.isFinite(n[1])):[]}catch{return[]}}function LM(t){try{const e=PM(),n=e.find(([s])=>s===t);if(n)return n[1];const r=Date.now();return sessionStorage.setItem(Eg,JSON.stringify(RM(e,t,r))),r}catch{return Date.now()}}function Dg(t,e){const n=_.c(2);let r;n[0]!==t?(r=()=>LM(t),n[0]=t,n[1]=r):r=n[1];const s=L.useState(r)[0];return e??s}function Og(t){const e=Math.ceil(t/1e3);if(e<60)return`${e}s`;const n=Math.floor(e/60),r=e%60;return r?`${n}m ${r}s`:`${n}m`}function $M(t){const e=_.c(4),{toolCallId:n,durationMs:r,anchorMs:s}=t;Nc(1e3);const i=Dg(n,s)+r-Date.now();let a;e[0]!==i?(a=i>0?`Waiting ${Og(i)}`:"Wrapping up…",e[0]=i,e[1]=a):a=e[1];let l;return e[2]!==a?(l=p.jsx("span",{className:"tabular-nums",children:a}),e[2]=a,e[3]=l):l=e[3],l}const _M=1e4;function BM(t){const e=_.c(7),{toolCallId:n,anchorMs:r}=t,s=J();Nc(1e3);const o=Dg(n,r),i=Date.now()-o;if(i<_M){let c;return e[0]!==s?(c=s("chat.generic.preparing"),e[0]=s,e[1]=c):c=e[1],c}let a;e[2]!==i||e[3]!==s?(a=s("chat.generic.runningFor",{elapsed:Og(i)}),e[2]=i,e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==a?(l=p.jsx("span",{className:"tabular-nums",children:a}),e[5]=a,e[6]=l):l=e[6],l}const zM={s:1e3,m:6e4,h:36e5,d:864e5};function FM(t){const e=/(?:^|[\s;&|(])sleep((?:\s+[\d.]+[smhd]?)+)/g;let n=0,r=!1;for(const s of t.matchAll(e))for(const o of s[1].trim().split(/\s+/)){const i=/^([\d.]+)([smhd]?)$/.exec(o);if(!i)continue;const a=Number.parseFloat(i[1]);Number.isFinite(a)&&(n+=a*(zM[i[2]||"s"]??1e3),r=!0)}return r?n:null}function Ci(t,e="An unknown error occurred"){return"errorText"in t&&typeof t.errorText=="string"?t.errorText:e}function dr(t){if(t==null)return"";try{return JSON.stringify(t)}catch{return"[Non-serializable value]"}}function Zo(t){const e=dr(t);if(e===""||e==="[Non-serializable value]")return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const HM=t=>t.type==="dynamic-tool"||t.type.startsWith("tool-");function WM(t){if(!t||typeof t!="object")return null;const e=t;if(!Array.isArray(e.parts))return null;const n=[];for(const r of e.parts)if(r.type==="text"&&typeof r.text=="string")n.push(r.text);else if(r.type==="reasoning")n.push(`## Reasoning
|
|
146
|
-
${r.text}`);else if(r.type==="source-url")n.push(`## Source URL
|
|
147
|
-
${r.url}`);else if(r.type==="source-document")n.push(`## Source Document
|
|
148
|
-
${r.title}`);else if(r.type==="file")n.push(`## File
|
|
149
|
-
${r.filename??r.url}`);else if(r.type!=="step-start"){if(HM(r)){const s=r.type.startsWith("tool-")?r.type.slice(5):r.toolName;if(r.state==="input-streaming")n.push(`## ${s}
|
|
150
|
-
Input streaming...`);else if(r.state==="input-available"){const o=dr(r.input).slice(0,20);n.push(`## ${s}
|
|
151
|
-
### Input
|
|
152
|
-
${o||"[No input]"}...`)}else if(r.state==="approval-requested")n.push(`## ${s}
|
|
153
|
-
Approval requested...`);else if(r.state==="approval-responded")n.push(`## ${s}
|
|
154
|
-
Approval responded...`);else if(r.state==="output-available"){const o=dr(r.input).slice(0,40),i=dr(r.output).slice(0,40);n.push(r.output!=null?`## ${s}
|
|
155
|
-
Input: ${o||"[No input]"}...
|
|
156
|
-
Output: ${i||"[No output]"}...`:`## ${s}
|
|
157
|
-
Input: ${o||"[No input]"}...
|
|
158
|
-
Output: Tool responded with no output`)}else if(r.state==="output-error"){const o=dr(r.input).slice(0,40);n.push(r.errorText?`## ${s}
|
|
159
|
-
Input: ${o||"[No input]"}...
|
|
160
|
-
Error: ${r.errorText}`:`## ${s}
|
|
161
|
-
Input: ${o||"[No input]"}...
|
|
162
|
-
Error: Tool responded with an error`)}else if(r.state==="output-denied"){const o=dr(r.input).slice(0,40);n.push(`## ${s}
|
|
163
|
-
Input: ${o||"[No input]"}...
|
|
164
|
-
Output: Tool execution was denied`)}}}return n.length>0?n.join(`
|
|
165
|
-
|
|
166
|
-
`):null}function Yd(t){const e=t&&typeof t=="object"&&"created_at"in t?t.created_at:void 0;return typeof e=="string"||e instanceof Date?bl(e):null}function VM(t){const e=t&&typeof t=="object"&&"timeout"in t?t.timeout:void 0;return Math.min(typeof e=="number"?e:3e4,12e4)}function Xs(t){const e=_.c(7),{icon:n,label:r}=t;let s;e[0]!==n?(s=p.jsx(_n,{asChild:!0,children:p.jsx("span",{className:"flex items-center",children:n})}),e[0]=n,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx(Bn,{side:"top",children:r}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsxs(zn,{children:[s,o]}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function UM(t){const e=_.c(19),{annotations:n,toolMeta:r}=t,s=J();let o;e[0]!==r?(o=_f(r),e[0]=r,e[1]=o):o=e[1];const i=!!o;if(!n&&!i)return null;let a;e[2]!==i||e[3]!==s?(a=i&&p.jsx(Xs,{icon:p.jsx(wf,{}),label:s("chat.generic.annotation.interactive")}),e[2]=i,e[3]=s,e[4]=a):a=e[4];let l;e[5]!==n?.readOnlyHint||e[6]!==s?(l=n?.readOnlyHint&&p.jsx(Xs,{icon:p.jsx(N0,{}),label:s("chat.generic.annotation.readOnly")}),e[5]=n?.readOnlyHint,e[6]=s,e[7]=l):l=e[7];let c;e[8]!==n?.destructiveHint||e[9]!==s?(c=n?.destructiveHint&&p.jsx(Xs,{icon:p.jsx(yl,{}),label:s("chat.generic.annotation.destructive")}),e[8]=n?.destructiveHint,e[9]=s,e[10]=c):c=e[10];let u;e[11]!==n?.openWorldHint||e[12]!==s?(u=n?.openWorldHint&&p.jsx(Xs,{icon:p.jsx(pa,{}),label:s("chat.generic.annotation.openWorld")}),e[11]=n?.openWorldHint,e[12]=s,e[13]=u):u=e[13];let d;return e[14]!==a||e[15]!==l||e[16]!==c||e[17]!==u?(d=p.jsxs(p.Fragment,{children:[a,l,c,u]}),e[14]=a,e[15]=l,e[16]=c,e[17]=u,e[18]=d):d=e[18],d}function qM(t){return t<1?`${Math.round(t*1e3)}ms`:t<10?`${t.toFixed(1)}s`:`${Math.round(t)}s`}function KM(t){const e=_.c(13),{latency:n,outputBytes:r}=t,s=typeof n=="number"&&n>0,o=typeof r=="number"&&r>=0;if(!s&&!o)return null;let i;e[0]!==s||e[1]!==n?(i=s&&p.jsx("span",{children:qM(n)}),e[0]=s,e[1]=n,e[2]=i):i=e[2];let a;e[3]!==o||e[4]!==s?(a=s&&o&&p.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[3]=o,e[4]=s,e[5]=a):a=e[5];let l;e[6]!==o||e[7]!==r?(l=o&&p.jsx("span",{children:OM(r)}),e[6]=o,e[7]=r,e[8]=l):l=e[8];let c;return e[9]!==i||e[10]!==a||e[11]!==l?(c=p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-mono tabular-nums text-muted-foreground/60 px-1 leading-none",children:[i,a,l]}),e[9]=i,e[10]=a,e[11]=l,e[12]=c):c=e[12],c}function JM(t,e,n,r){switch(t){case"input-streaming":case"input-available":return r?r("chat.generic.preparing"):"Preparing...";case"approval-requested":return r?r("chat.generic.waitingForApproval"):"Waiting for your approval";case"output-denied":return r?r("chat.generic.cancelled"):"Cancelled";case"output-error":return n??(r?r("chat.generic.failed"):"Failed");case"output-available":{if(e==null)return r?r("chat.generic.done"):"Done";if(typeof e=="string"){const s=e.trim();return s.length>100?s.slice(0,100)+"…":s}if(typeof e=="object"){for(const s of Object.keys(e)){const o=e[s];if(typeof o=="string"&&o.trim()){const i=o.trim();return i.length>100?i.slice(0,100)+"…":i}}return""}return String(e).slice(0,100)}default:return""}}function Gd(t){const e=_.c(76),{part:n,annotations:r,latency:s,outputBytes:o,isLastMessage:i,toolMeta:a}=t,l=J(),c="toolName"in n&&typeof n.toolName=="string"?n.toolName:n.type==="dynamic-tool"?l("chat.generic.dynamicTool"):n.type.replace("tool-","")||"Tool",u=dm(c),d=wr(),f=v0(),{org:h}=xt(),{openSidePanel:m}=A0(),y=vs()?.taskId??null,{addOrReplaceEager:g}=DM(y),{openPanel:x}=kl(),b=a&&typeof a=="object"&&a!==null&&"connectionId"in a&&a.connectionId!=null&&a.connectionId!==""?String(a.connectionId):f?.selectedVirtualMcp?.id??null,{toolDef:v}=AM(b?c:null,b,h.id,h.slug),k=v?._meta??a,N=wl(k),C=Nl(u,N),S=IM[C],w=v?.title??(S?.labelKey?l(S.labelKey):void 0)??ga(C);let M;e[0]!==k?(M=_f(k),e[0]=k,e[1]=M):M=e[1];const T=M,O=!!T&&n.state==="output-available",A=b?`${b}:${c}`:null,P=!!r?.destructiveHint,D=O&&!!b&&!P&&!!y;let E;e[2]!==g||e[3]!==b||e[4]!==x||e[5]!==n||e[6]!==c?(E=()=>{if(!b)return;const ue="input"in n&&n.input&&typeof n.input=="object"?n.input:{};g({toolName:c,appId:b,args:ue}),x(O1(b,c))},e[2]=g,e[3]=b,e[4]=x,e[5]=n,e[6]=c,e[7]=E):E=e[7];const j=E;let I;e[8]!==D||e[9]!==j?(I=ue=>ue==="fullscreen"&&D?(j(),"fullscreen"):"inline",e[8]=D,e[9]=j,e[10]=I):I=e[10];const R=I;let z;e[11]!==d||e[12]!==m?(z=ue=>{const Me=C0(ue.content);Me.content.length>0&&(m(),d?.sendMessage(Me))},e[11]=d,e[12]=m,e[13]=z):z=e[13];const W=z,q=n.state==="approval-requested"&&i===!1,X=n.state==="output-denied"||q,te=n.state==="output-available"&&typeof n.output=="object"&&n.output!=null&&"isError"in n.output&&n.output.isError===!0;let ae;e[14]!==n.state?(ae=It(n.state),e[14]=n.state,e[15]=ae):ae=e[15];const fe=ae,ce=q||fe==="approval"?"idle":te?"error":fe;let we,$e;if(e[16]!==ce||e[17]!==te||e[18]!==q||e[19]!==n||e[20]!==l||e[21]!==C){we=n.state==="output-error"?Ci(n):void 0;const ue=C==="bash"&&ce==="loading"&&n.input&&typeof n.input=="object"&&typeof n.input.command=="string"?n.input.command:null;let Me;e[24]!==ue?(Me=ue!==null?FM(ue):null,e[24]=ue,e[25]=Me):Me=e[25];const Te=Me;let Rs;e[26]!==n.input||e[27]!==Te?(Rs=Te!==null?Math.min(Te,VM(n.input)):null,e[26]=n.input,e[27]=Te,e[28]=Rs):Rs=e[28];const Wc=Rs,Vc="toolCallId"in n?n.toolCallId:"";$e=Wc!==null?p.jsx($M,{toolCallId:Vc,durationMs:Wc,anchorMs:Yd(n)}):ce==="loading"?p.jsx(BM,{toolCallId:Vc,anchorMs:Yd(n)}):q?l("chat.generic.cancelled"):te?l("chat.generic.failed"):JM(n.state,n.output,we,l),e[16]=ce,e[17]=te,e[18]=q,e[19]=n,e[20]=l,e[21]=C,e[22]=we,e[23]=$e}else we=e[22],$e=e[23];const Ne=$e;let me="";n.input!==void 0&&(me=`# Input
|
|
167
|
-
`+Zo(n.input)),n.state==="output-error"?(me&&(me=me+`
|
|
168
|
-
|
|
169
|
-
`),me=me+(`# Error
|
|
170
|
-
`+(we??""))):n.output!==void 0&&!O&&(me&&(me=me+`
|
|
171
|
-
|
|
172
|
-
`),me=me+(`# Output
|
|
173
|
-
`+Zo(n.output)));let Ke;e:{if(X){let Te;e[29]===Symbol.for("react.memo_cache_sentinel")?(Te=p.jsx(M0,{}),e[29]=Te):Te=e[29],Ke=Te;break e}if(O){let Te;e[30]===Symbol.for("react.memo_cache_sentinel")?(Te=p.jsx(wf,{className:"size-4 text-muted-foreground"}),e[30]=Te):Te=e[30],Ke=Te;break e}const ue=S?.icon;if(ue){let Te;e[31]!==ue?(Te=p.jsx(ue,{className:"size-4 text-muted-foreground"}),e[31]=ue,e[32]=Te):Te=e[32],Ke=Te;break e}let Me;e[33]===Symbol.for("react.memo_cache_sentinel")?(Me=p.jsx(V1,{className:"size-4 text-muted-foreground"}),e[33]=Me):Me=e[33],Ke=Me}let Q;e[34]!==r||e[35]!==a?(Q=p.jsx(UM,{annotations:r,toolMeta:a}),e[34]=r,e[35]=a,e[36]=Q):Q=e[36];let ee;e[37]!==s||e[38]!==o?(ee=p.jsx(KM,{latency:s,outputBytes:o}),e[37]=s,e[38]=o,e[39]=ee):ee=e[39];let se;e[40]!==Q||e[41]!==ee?(se=p.jsxs(p.Fragment,{children:[Q,ee]}),e[40]=Q,e[41]=ee,e[42]=se):se=e[42];const _e=me||null;let Je;e[43]!==ce||e[44]!==w||e[45]!==X||e[46]!==Ne||e[47]!==se||e[48]!==_e||e[49]!==Ke?(Je=p.jsx(ne,{icon:Ke,iconDestructive:X,trailing:se,title:w,summary:Ne,state:ce,detail:_e}),e[43]=ce,e[44]=w,e[45]=X,e[46]=Ne,e[47]=se,e[48]=_e,e[49]=Ke,e[50]=Je):Je=e[50];let vt;e[51]!==D||e[52]!==j||e[53]!==l?(vt=D&&p.jsx("div",{className:"flex justify-end mt-1.5 mb-1",children:p.jsxs("button",{type:"button",onClick:j,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground rounded-md [@media(hover:hover)]:hover:bg-accent/50 [@media(hover:hover)]:hover:text-foreground transition-colors",children:[p.jsx(W1,{className:"size-3.5"}),l("chat.generic.openInPanel")]})}),e[51]=D,e[52]=j,e[53]=l,e[54]=vt):vt=e[54];let ut;e[55]!==D||e[56]!==f||e[57]!==b||e[58]!==w||e[59]!==W||e[60]!==R||e[61]!==O||e[62]!==k||e[63]!==h.id||e[64]!==h.slug||e[65]!==n.input||e[66]!==n.output||e[67]!==A||e[68]!==l||e[69]!==C||e[70]!==T?(ut=O&&T&&b&&h?.id&&p.jsx(p.Fragment,{children:p.jsx(yf,{fallback:ue=>{const{resetError:Me}=ue;return p.jsxs("div",{className:"mt-2 flex items-center gap-2 px-3 py-2.5 border border-dashed border-destructive/30 bg-destructive/5 rounded-lg",children:[p.jsx(yl,{size:16,className:"shrink-0 text-destructive"}),p.jsx("span",{className:"flex-1 text-xs text-destructive font-medium",children:l("chat.generic.failedToLoad",{toolName:w})}),p.jsxs(Ln,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1.5 shrink-0",onClick:Me,children:[p.jsx(xf,{className:"size-3.5"}),l("chat.generic.retry")]})]})},children:p.jsx(L.Suspense,{fallback:p.jsx("div",{className:"mt-2 flex items-center justify-center h-12 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[p.jsx(hf,{className:"size-4"}),p.jsx("span",{className:"text-sm",children:l("chat.generic.loadingApp")})]})}),children:p.jsx(XM,{uiResourceUri:T,connectionId:b,orgId:h.id,orgSlug:h.slug,toolName:C,toolInput:n.input,toolResult:n.output,toolMeta:k,onMessage:W,onUpdateModelContext:A&&f?ue=>f.setAppContext(A,ue):void 0,onTeardown:A&&f?()=>f.clearAppContext(A):void 0,onRequestDisplayMode:D?R:void 0})})})}),e[55]=D,e[56]=f,e[57]=b,e[58]=w,e[59]=W,e[60]=R,e[61]=O,e[62]=k,e[63]=h.id,e[64]=h.slug,e[65]=n.input,e[66]=n.output,e[67]=A,e[68]=l,e[69]=C,e[70]=T,e[71]=ut):ut=e[71];let dt;return e[72]!==Je||e[73]!==vt||e[74]!==ut?(dt=p.jsxs("div",{children:[Je,vt,ut]}),e[72]=Je,e[73]=vt,e[74]=ut,e[75]=dt):dt=e[75],dt}function Ag(t){return typeof t=="object"&&t!=null&&"type"in t&&t.type==="mcpToolCall"}function YM(t){if(t!=null)return Ag(t)?t.arguments??void 0:t}function GM(t){if(t==null)return;if(Ag(t)&&t.result!=null)return t.result;if(typeof t=="object"&&"content"in t&&Array.isArray(t.content)){const n=t.content;if(n.length>0&&typeof n[0]=="object"&&n[0]!=null&&"type"in n[0])return t}const e=typeof t=="string"?t:JSON.stringify(t);return{structuredContent:typeof t=="object"&&!Array.isArray(t)?t:void 0,content:[{type:"text",text:e}]}}function XM(t){const e=_.c(27),{uiResourceUri:n,connectionId:r,orgId:s,orgSlug:o,toolName:i,toolInput:a,toolResult:l,toolMeta:c,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h}=t;let m;e[0]!==r||e[1]!==s||e[2]!==o?(m={connectionId:r,orgId:s,orgSlug:o},e[0]=r,e[1]=s,e[2]=o,e[3]=m):m=e[3];const y=gl(m);let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g={type:"object"},e[4]=g):g=e[4];let x;e[5]!==c?(x=c!=null&&{_meta:c},e[5]=c,e[6]=x):x=e[6];let b;e[7]!==x||e[8]!==i?(b={name:i,inputSchema:g,...x},e[7]=x,e[8]=i,e[9]=b):b=e[9];const v=b;let k;e[10]!==v?(k={tool:v},e[10]=v,e[11]=k):k=e[11];let N;e[12]!==a?(N=YM(a),e[12]=a,e[13]=N):N=e[13];let C;e[14]!==l?(C=GM(l),e[14]=l,e[15]=C):C=e[15];let S;return e[16]!==y||e[17]!==u||e[18]!==h||e[19]!==f||e[20]!==d||e[21]!==s||e[22]!==k||e[23]!==N||e[24]!==C||e[25]!==n?(S=p.jsx("div",{className:"mt-2 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsx(w0,{resourceURI:n,orgId:s,toolInfo:k,toolInput:N,toolResult:C,client:y,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h})}),e[16]=y,e[17]=u,e[18]=h,e[19]=f,e[20]=d,e[21]=s,e[22]=k,e[23]=N,e[24]=C,e[25]=n,e[26]=S):S=e[26],S}const Xd="studio-storage://",Qd="mesh-storage://";function Mc(t){return t.startsWith(Xd)?t.slice(Xd.length):t.startsWith(Qd)?t.slice(Qd.length):null}function Ig(t,e){const n=Mc(t);return n!==null?`/api/${e}/files/${n}`:t}function QM(t){return Array.isArray(t?.images)?t.images:void 0}function ZM(t){if(!t?.usage)return null;const e=t.usage.inputTokens??0,n=t.usage.outputTokens??0,r=e+n;return r?{inputTokens:e,outputTokens:n,reasoningTokens:0,totalTokens:r,cost:0,cacheReadTokens:0,cacheWriteTokens:0}:null}function eT(t){const e=_.c(14),{uri:n,orgSlug:r}=t,s=J();let o;e[0]!==r||e[1]!==n?(o=Ig(n,r),e[0]=r,e[1]=n,e[2]=o):o=e[2];const i=o;let a;e[3]!==s||e[4]!==n?(a=Mc(n)!==null?n.slice(n.lastIndexOf("/")+1):s("chat.generateImage.reference"),e[3]=s,e[4]=n,e[5]=a):a=e[5];const l=a;let c;e[6]!==l?(c=p.jsx(_n,{asChild:!0,children:p.jsx("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 rounded bg-muted text-muted-foreground text-xs cursor-default select-none",children:l})}),e[6]=l,e[7]=c):c=e[7];let u;e[8]!==l||e[9]!==i?(u=p.jsx(Bn,{side:"top",className:"max-w-sm p-1.5",children:p.jsx("img",{src:i,alt:l,className:"max-w-full max-h-64 object-contain rounded"})}),e[8]=l,e[9]=i,e[10]=u):u=e[10];let d;return e[11]!==c||e[12]!==u?(d=p.jsxs(zn,{children:[c,u]}),e[11]=c,e[12]=u,e[13]=d):d=e[13],d}function tT(t){const e=_.c(75),{part:n,latency:r}=t,s=J(),o=bf();let i;e[0]!==n.state?(i=It(n.state),e[0]=n.state,e[1]=i):i=e[1];const a=i,l=n.input,c=n.output;let u,d,f,h,m;if(e[2]!==l||e[3]!==r||e[4]!==o||e[5]!==n||e[6]!==c||e[7]!==a||e[8]!==s){m=Symbol.for("react.early_return_sentinel");e:{const x=QM(c);let b;e[14]!==c?(b=ZM(c),e[14]=c,e[15]=b):b=e[15];const v=b,k=c?.model,N=Array.isArray(l?.referenceImages)?l.referenceImages.filter(nT):void 0;let C;e[16]!==r?(C=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Fn(r)}):null,e[16]=r,e[17]=C):C=e[17];const S=C;if(a==="loading"){let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx(Ps,{size:14}),e[18]=D):D=e[18];let E;e[19]!==s?(E=s("chat.generateImage.generatingImage"),e[19]=s,e[20]=E):E=e[20];let j;e[21]!==l?(j=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[21]=l,e[22]=j):j=e[22];let I;e[23]!==E||e[24]!==j?(I=p.jsx(ne,{icon:D,title:E,summary:j,state:"loading"}),e[23]=E,e[24]=j,e[25]=I):I=e[25],m=I;break e}if(c?.background){let D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx(Ps,{size:14}),e[26]=D):D=e[26];let E;e[27]!==s?(E=s("chat.generateImage.imageQueuedGeneratingInBackground"),e[27]=s,e[28]=E):E=e[28];let j;e[29]!==l?(j=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[29]=l,e[30]=j):j=e[30];let I;e[31]!==E||e[32]!==j?(I=p.jsx(ne,{icon:D,title:E,summary:j,state:"idle"}),e[31]=E,e[32]=j,e[33]=I):I=e[33],m=I;break e}if(a==="error"||!x||x.length===0){let D;e[34]!==n||e[35]!==a?(D=a==="error"?Ci(n):void 0,e[34]=n,e[35]=a,e[36]=D):D=e[36];const E=D;let j="";l!==void 0&&(j=`# Input
|
|
174
|
-
`+Zo(l)),E?(j&&(j=j+`
|
|
175
|
-
|
|
176
|
-
`),j=j+(`# Error
|
|
177
|
-
`+E)):c!==void 0&&(j&&(j=j+`
|
|
178
|
-
|
|
179
|
-
`),j=j+(`# Output
|
|
180
|
-
`+Zo(c)));let I;e[37]===Symbol.for("react.memo_cache_sentinel")?(I=p.jsx(Ps,{size:14}),e[37]=I):I=e[37];let R;e[38]!==s?(R=s("chat.generateImage.imageGeneration"),e[38]=s,e[39]=R):R=e[39];let z;e[40]!==a||e[41]!==s?(z=s(a==="error"?"chat.generateImage.failed":"chat.generateImage.noImagesGenerated"),e[40]=a,e[41]=s,e[42]=z):z=e[42];const W=a==="error"?"error":"idle",q=j||null;let X;e[43]!==S||e[44]!==R||e[45]!==z||e[46]!==W||e[47]!==q||e[48]!==v?(X=p.jsx(ne,{icon:I,title:R,summary:z,state:W,usage:v,trailing:S,detail:q}),e[43]=S,e[44]=R,e[45]=z,e[46]=W,e[47]=q,e[48]=v,e[49]=X):X=e[49],m=X;break e}f="flex flex-col gap-2";let w;e[50]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Ps,{size:14,className:"text-pink-500"}),e[50]=w):w=e[50];let M;e[51]!==s?(M=s("chat.generateImage.generatedImage"),e[51]=s,e[52]=M):M=e[52];let T;e[53]!==l?(T=l?.prompt&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:l.prompt}),e[53]=l,e[54]=T):T=e[54];const O=N&&N.length>0&&p.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[p.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:s("chat.generateImage.references")}),N.map((D,E)=>{const j=D.uri??D.url;return p.jsx(eT,{uri:j,orgSlug:o.slug},E)})]});let A;e[55]!==T||e[56]!==O?(A=p.jsxs("div",{className:"flex flex-col gap-1 pb-2 pl-6",children:[T,O]}),e[55]=T,e[56]=O,e[57]=A):A=e[57],e[58]!==S||e[59]!==k||e[60]!==M||e[61]!==A||e[62]!==v?(h=p.jsx(ne,{icon:w,title:M,summary:k,state:"idle",usage:v,trailing:S,children:A}),e[58]=S,e[59]=k,e[60]=M,e[61]=A,e[62]=v,e[63]=h):h=e[63],u="flex flex-wrap gap-2";let P;e[64]!==l?.prompt||e[65]!==o||e[66]!==s?(P=(D,E)=>{const j=D.uri??D.url;if(!j)return null;const I=Ig(j,o.slug);return p.jsx(m0,{src:I,alt:l?.prompt??s("chat.generateImage.generatedImageAlt"),children:p.jsx("img",{src:I,alt:l?.prompt??s("chat.generateImage.generatedImageAlt"),className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"})},E)},e[64]=l?.prompt,e[65]=o,e[66]=s,e[67]=P):P=e[67],d=x.map(P)}e[2]=l,e[3]=r,e[4]=o,e[5]=n,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=h,e[13]=m}else u=e[9],d=e[10],f=e[11],h=e[12],m=e[13];if(m!==Symbol.for("react.early_return_sentinel"))return m;let y;e[68]!==u||e[69]!==d?(y=p.jsx("div",{className:u,children:d}),e[68]=u,e[69]=d,e[70]=y):y=e[70];let g;return e[71]!==f||e[72]!==h||e[73]!==y?(g=p.jsxs("div",{className:f,children:[h,y]}),e[71]=f,e[72]=h,e[73]=y,e[74]=g):g=e[74],g}function nT(t){return t.uri??t.url}function rT(t,e){const n=Mc(t);return n!==null?`/api/${e}/files/${n}`:t}function sT(t){if(!t?.usage)return null;const e=t.usage.inputTokens??0,n=t.usage.outputTokens??0,r=e+n;if(!r)return null;const s={providerMetadata:t.usage.providerMetadata};return{inputTokens:e,outputTokens:n,reasoningTokens:0,totalTokens:r,cost:Ff(s),cacheReadTokens:0,cacheWriteTokens:0}}function oT(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}}function iT(t){try{return`${new URL(t).origin}/favicon.ico`}catch{return""}}function aT(t){const e=_.c(16),{citation:n,index:r}=t;let s;e[0]!==n.url?(s=oT(n.url),e[0]=n.url,e[1]=s):s=e[1];const o=s;let i;e[2]!==n.url?(i=iT(n.url),e[2]=n.url,e[3]=i):i=e[3];const a=i,l=n.title||o;let c;e[4]!==a?(c=p.jsx("img",{src:a,alt:"",className:"size-3.5 rounded-sm shrink-0",onError:lT}),e[4]=a,e[5]=c):c=e[5];let u;e[6]!==l?(u=p.jsx("span",{className:"truncate max-w-[180px]",children:l}),e[6]=l,e[7]=u):u=e[7];const d=r+1;let f;e[8]!==d?(f=p.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0",children:["[",d,"]"]}),e[8]=d,e[9]=f):f=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Bf,{size:10,className:"shrink-0 opacity-0 group-hover/src:opacity-100 transition-opacity"}),e[10]=h):h=e[10];let m;return e[11]!==n.url||e[12]!==c||e[13]!==u||e[14]!==f?(m=p.jsxs("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"group/src inline-flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:[c,u,f,h]}),e[11]=n.url,e[12]=c,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function lT(t){t.target.style.display="none"}function cT(t,e){return t.replace(/\[(\d+)\]/g,(n,r)=>{const s=parseInt(r,10)-1,o=e[s];return o?`[\\[${r}\\]](${o.url})`:n})}const ra=5;function uT(t){const e=_.c(13),{citations:n}=t,r=J(),[s,o]=L.useState(!1),i=n.length>ra;let a;e[0]!==n||e[1]!==s?(a=s?n:n.slice(0,ra),e[0]=n,e[1]=s,e[2]=a):a=e[2];const l=a;let c;e[3]!==l?(c=l.map(fT),e[3]=l,e[4]=c):c=e[4];let u;e[5]!==n.length||e[6]!==s||e[7]!==i||e[8]!==r?(u=i&&p.jsx("button",{type:"button",onClick:()=>o(dT),className:"inline-flex items-center rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:s?r("chat.webSearch.showLess"):r("chat.webSearch.showMore",{count:n.length-ra})}),e[5]=n.length,e[6]=s,e[7]=i,e[8]=r,e[9]=u):u=e[9];let d;return e[10]!==c||e[11]!==u?(d=p.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[c,u]}),e[10]=c,e[11]=u,e[12]=d):d=e[12],d}function dT(t){return!t}function fT(t,e){return p.jsx(aT,{citation:t,index:e},t.url)}function hT(t){const e=_.c(60),{part:n,latency:r,streamingText:s}=t,o=J(),i=bf();let a;e[0]!==n.state?(a=It(n.state),e[0]=n.state,e[1]=a):a=e[1];const l=a,c=n.input,u=n.output;let d,f,h;e[2]!==i||e[3]!==u?(d=u?.uri?rT(u.uri,i.slug):void 0,h=ni,f=ht.webSearchBlob(d??""),e[2]=i,e[3]=u,e[4]=d,e[5]=f,e[6]=h):(d=e[4],f=e[5],h=e[6]);let m;e[7]!==d?(m=async()=>{const te=await fetch(d);if(!te.ok)throw new Error(`Failed to fetch: ${te.status}`);return te.text()},e[7]=d,e[8]=m):m=e[8];const y=!!d;let g;e[9]!==f||e[10]!==m||e[11]!==y?(g={queryKey:f,queryFn:m,enabled:y,staleTime:1/0},e[9]=f,e[10]=m,e[11]=y,e[12]=g):g=e[12];const{data:x}=h(g),b=l==="loading",v=l!=="loading"&&l!=="error",k=u?.citations;let N;e[13]!==u?(N=sT(u),e[13]=u,e[14]=N):N=e[14];const C=N,S=u?.content??x??s;let w;e[15]!==k||e[16]!==S?(w=S&&k?.length?cT(S,k):S,e[15]=k,e[16]=S,e[17]=w):w=e[17];const M=w;let T;e[18]!==r?(T=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Fn(r)}):null,e[18]=r,e[19]=T):T=e[19];const O=T;if(l==="error"){let te;e[20]===Symbol.for("react.memo_cache_sentinel")?(te=p.jsx(pa,{size:14}),e[20]=te):te=e[20];let ae;e[21]!==o?(ae=o("chat.webSearch.title"),e[21]=o,e[22]=ae):ae=e[22];let fe;e[23]!==o?(fe=o("chat.webSearch.failed"),e[23]=o,e[24]=fe):fe=e[24];let ce;return e[25]!==O||e[26]!==ae||e[27]!==fe||e[28]!==C?(ce=p.jsx(ne,{icon:te,title:ae,summary:fe,state:"error",usage:C,trailing:O}),e[25]=O,e[26]=ae,e[27]=fe,e[28]=C,e[29]=ce):ce=e[29],ce}const A=b?"animate-pulse":"text-blue-500";let P;e[30]!==A?(P=G(A),e[30]=A,e[31]=P):P=e[31];let D;e[32]!==P?(D=p.jsx(pa,{size:14,className:P}),e[32]=P,e[33]=D):D=e[33];let E;e[34]!==b||e[35]!==o?(E=o(b?"chat.webSearch.researching":"chat.webSearch.title"),e[34]=b,e[35]=o,e[36]=E):E=e[36];let j;e[37]!==c||e[38]!==v||e[39]!==u?.model?(j=v?u?.model??c?.query?.slice(0,60):c?.query?`"${c.query.slice(0,80)}"`:void 0,e[37]=c,e[38]=v,e[39]=u?.model,e[40]=j):j=e[40];const I=b?"loading":"idle";let R;e[41]!==c?(R=c?.query&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:c.query}),e[41]=c,e[42]=R):R=e[42];let z;e[43]!==M||e[44]!==n.toolCallId?(z=M?p.jsx("div",{className:"max-h-96 overflow-y-auto overflow-x-hidden rounded-lg border border-border/40 bg-muted/20 px-4 py-3 min-w-0",children:p.jsx("div",{className:"prose prose-sm prose-neutral dark:prose-invert max-w-none text-[13px] leading-relaxed break-words",children:p.jsx(vl,{id:n.toolCallId,text:M})})}):p.jsx("div",{className:"rounded-lg border border-border/40 bg-muted/20 px-4 py-3",children:p.jsxs("div",{className:"space-y-2 animate-pulse",children:[p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-3/4"}),p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-1/2"})]})}),e[43]=M,e[44]=n.toolCallId,e[45]=z):z=e[45];let W;e[46]!==k?(W=k&&k.length>0&&p.jsx(uT,{citations:k}),e[46]=k,e[47]=W):W=e[47];let q;e[48]!==R||e[49]!==z||e[50]!==W?(q=p.jsxs("div",{className:"pl-6 pb-3 flex flex-col gap-1 min-w-0",children:[R,z,W]}),e[48]=R,e[49]=z,e[50]=W,e[51]=q):q=e[51];let X;return e[52]!==O||e[53]!==D||e[54]!==E||e[55]!==j||e[56]!==I||e[57]!==q||e[58]!==C?(X=p.jsx(ne,{icon:D,title:E,summary:j,state:I,usage:C,trailing:O,defaultOpen:!0,children:q}),e[52]=O,e[53]=D,e[54]=E,e[55]=j,e[56]=I,e[57]=q,e[58]=C,e[59]=X):X=e[59],X}function pT(t){const e=_.c(16),{part:n}=t,r=J();if(!n.state.startsWith("output-"))return null;let s;e[0]!==n.input?.prompt||e[1]!==r?(s=n.input?.prompt?.trim()||r("chat.userAskQuestion.question"),e[0]=n.input?.prompt,e[1]=r,e[2]=s):s=e[2];const o=s,i=n.state==="output-error"||n.state==="output-denied",a=n.state==="output-denied";let l;e[3]!==a||e[4]!==n||e[5]!==r?(l=a?r("chat.userAskQuestion.skippedAnswer"):n.state==="output-error"?Ci(n)??r("chat.subtask.errorLabel"):n.output?.response??"",e[3]=a,e[4]=n,e[5]=r,e[6]=l):l=e[6];const c=l;let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(p0,{className:"size-4 text-muted-foreground/50 shrink-0 mt-0.5"}),e[7]=u):u=e[7];let d;e[8]!==o?(d=p.jsxs("div",{className:"flex items-start gap-2",children:[u,p.jsx("span",{className:"text-[14px] text-muted-foreground leading-snug",children:o})]}),e[8]=o,e[9]=d):d=e[9];let f;e[10]!==c||e[11]!==i?(f=c&&p.jsx("div",{className:"ml-6 pl-2 border-l border-border/50",children:p.jsx("span",{className:G("text-[14px] leading-snug",i?"text-muted-foreground/50 italic":"text-foreground/70"),children:c})}),e[10]=c,e[11]=i,e[12]=f):f=e[12];let h;return e[13]!==d||e[14]!==f?(h=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[d,f]}),e[13]=d,e[14]=f,e[15]=h):h=e[15],h}const jg=L.createContext(new Map);function pA(t){const e=_.c(5),{messages:n,children:r}=t;let s;if(e[0]!==n){s=new Map;for(const i of n){const a=i.metadata?.subtaskJobId;if(!a)continue;const l=s.get(a);l?l.push(i):s.set(a,[i])}e[0]=n,e[1]=s}else s=e[1];let o;return e[2]!==s||e[3]!==r?(o=p.jsx(jg.Provider,{value:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function mT(t){const e=_.c(3),n=L.useContext(jg);let r;return e[0]!==t||e[1]!==n?(r=t?n.get(t)??[]:[],e[0]=t,e[1]=n,e[2]=r):r=e[2],r}function gT(t){return new ReadableStream({async start(e){const n=t.getReader(),r=new TextDecoder;let s="";try{for(;;){const{done:o,value:i}=await n.read();if(o)break;s+=r.decode(i,{stream:!0});let a;for(;(a=s.indexOf(`
|
|
181
|
-
|
|
182
|
-
`))!==-1;){const l=s.slice(0,a);s=s.slice(a+2);const c=l.split(`
|
|
183
|
-
`).filter(u=>u.startsWith("data:")).map(u=>u.slice(5).trim()).join(`
|
|
184
|
-
`);if(c)try{e.enqueue(JSON.parse(c))}catch{}}}}finally{n.releaseLock(),e.close()}}})}function yT(t){const{orgSlug:e,threadId:n,jobId:r,enabled:s}=t,[o,i]=L.useState([]),[a,l]=L.useState(!1);return L.useEffect(()=>{if(!s||!r||!n)return;const c=new AbortController;return i([]),l(!0),(async()=>{try{const u=await fetch(`/api/${encodeURIComponent(e)}/decopilot/threads/${encodeURIComponent(n)}/jobs/${encodeURIComponent(r)}/stream`,{headers:{accept:"text/event-stream"},credentials:"include",signal:c.signal});if(!u.ok||!u.body)return;for await(const d of x0({stream:b0(gT(u.body),void 0)})){if(c.signal.aborted)return;i([d])}}catch{}finally{c.signal.aborted||l(!1)}})(),()=>c.abort()},[s,r,n,e]),{messages:o,streaming:a}}function xT(t,e){if(t&&typeof t=="object"&&!Array.isArray(t)){const n=t;if(typeof n.text=="string"||typeof n.error=="string"||typeof n.finishReason=="string"){if(typeof n.error=="string"&&n.error.length>0)return e("chat.subtask.failedWithError",{error:n.error});const s=typeof n.text=="string"?n.text.trim():"",o=n.finishReason==="length";return s?(o?`${e("chat.subtask.stepLimitPartial")}
|
|
185
|
-
|
|
186
|
-
`:"")+s:e(o?"chat.subtask.stepLimitNoOutput":"chat.subtask.completedNoOutput")}}return WM(t)}function Rg(t){return!!t&&typeof t=="object"&&t.background===!0}function Pg({part:t,subtaskMeta:e},n){const r=t.state==="input-streaming"||t.state==="input-available",s=t.state==="output-available"&&t.preliminary===!0,o=t.state==="output-available"&&!t.preliminary,i=t.state==="output-error",a=It(t.state,"preliminary"in t?t.preliminary:!1),l=a==="approval"?"idle":a,c=n(r?"chat.subtask.startingEllipsis":s?"chat.subtask.runningEllipsis":o?"chat.subtask.completedTitle":i?"chat.subtask.failedTitle":"chat.subtask.subtaskNoun"),u=t.input?.prompt??"",d=t.state==="approval-requested"?n("chat.subtask.awaitingApproval"):u.length>120?u.slice(0,120)+"…":u;return{fallbackTitle:c,summary:d,usage:e?.usage,state:l}}function Lg(t){return t.state==="input-available"?!0:t.state==="output-available"?"preliminary"in t&&t.preliminary===!0:!1}function $g(t){const e=_.c(4),n=vs()?.taskId??null,{org:r}=xt();if(!n)return null;let s;return e[0]!==r||e[1]!==n||e[2]!==t?(s=async()=>{if(n===null)return;const o=await fetch(`/api/${encodeURIComponent(r.slug)}/decopilot/flip/${encodeURIComponent(n)}`,{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({toolCallId:t})});if(!o.ok)throw new Error(`flip failed: ${o.status}`)},e[0]=r,e[1]=n,e[2]=t,e[3]=s):s=e[3],s}function bT(t){const e=_.c(10),{onFlip:n}=t,r=J(),[s,o]=L.useState(!1);let i;e[0]!==n?(i=async u=>{u.stopPropagation(),o(!0);try{await n()}catch{o(!1)}},e[0]=n,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=G("shrink-0 text-[12px] text-muted-foreground/70 px-2 py-1 rounded-md transition-colors","[@media(hover:hover)]:hover:text-foreground [@media(hover:hover)]:hover:bg-accent/40","disabled:opacity-50"),e[2]=a):a=e[2];let l;e[3]!==s||e[4]!==r?(l=r(s?"chat.subtask.flipping":"chat.subtask.flipToBackground"),e[3]=s,e[4]=r,e[5]=l):l=e[5];let c;return e[6]!==s||e[7]!==i||e[8]!==l?(c=p.jsx("button",{type:"button",disabled:s,onClick:i,className:a,children:l}),e[6]=s,e[7]=i,e[8]=l,e[9]=c):c=e[9],c}function Tc(t){const e=_.c(54),{icon:n,title:r,summary:s,state:o,usage:i,latency:a,onOpenChange:l,onFlip:c,children:u}=t,[d,f]=L.useState(!1);let h;e[0]!==l?(h=te=>{f(te),l?.(te)},e[0]=l,e[1]=h):h=e[1];const m=h,y=o==="loading",g=o==="error";let x;e[2]!==m?(x=()=>m(!0),e[2]=m,e[3]=x):x=e[3];const b=y&&"shimmer";let v;e[4]!==b?(v=G("group/tool flex items-center gap-2 flex-1 min-w-0 py-2.5 text-left rounded-md transition-colors","[@media(hover:hover)]:hover:bg-accent/30",b),e[4]=b,e[5]=v):v=e[5];const k=g?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75";let N;e[6]!==k?(N=G("relative shrink-0 size-4 flex items-center justify-center [&>svg]:size-4",k),e[6]=k,e[7]=N):N=e[7];let C;e[8]!==n||e[9]!==N?(C=p.jsx("div",{className:N,children:n}),e[8]=n,e[9]=N,e[10]=C):C=e[10];const S=g?"text-warning/80":"text-foreground";let w;e[11]!==S?(w=G("shrink-0 text-[14px] font-normal",S),e[11]=S,e[12]=w):w=e[12];let M;e[13]!==w||e[14]!==r?(M=p.jsx("span",{className:w,children:r}),e[13]=w,e[14]=r,e[15]=M):M=e[15];let T;e[16]!==s?(T=s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),e[16]=s,e[17]=T):T=e[17];let O;e[18]===Symbol.for("react.memo_cache_sentinel")?(O=p.jsx(A1,{className:"size-3.5 shrink-0 text-muted-foreground/40 opacity-0 transition-opacity [@media(hover:hover)]:group-hover/tool:opacity-100"}),e[18]=O):O=e[18];let A;e[19]!==a?(A=p.jsx(Le,{latency:a}),e[19]=a,e[20]=A):A=e[20];let P;e[21]!==i?(P=p.jsx(vg,{usage:i}),e[21]=i,e[22]=P):P=e[22];let D;e[23]!==M||e[24]!==T||e[25]!==A||e[26]!==P||e[27]!==x||e[28]!==v||e[29]!==C?(D=p.jsxs("button",{type:"button",onClick:x,className:v,children:[C,M,T,O,A,P]}),e[23]=M,e[24]=T,e[25]=A,e[26]=P,e[27]=x,e[28]=v,e[29]=C,e[30]=D):D=e[30];let E;e[31]!==y||e[32]!==c?(E=c&&y?p.jsx(bT,{onFlip:c}):null,e[31]=y,e[32]=c,e[33]=E):E=e[33];let j;e[34]!==D||e[35]!==E?(j=p.jsxs("div",{className:"flex items-center gap-1 w-full",children:[D,E]}),e[34]=D,e[35]=E,e[36]=j):j=e[36];let I;e[37]!==n?(I=p.jsx("span",{className:"flex items-center [&>svg]:size-4 [&>svg]:text-muted-foreground/75",children:n}),e[37]=n,e[38]=I):I=e[38];let R;e[39]!==I||e[40]!==r?(R=p.jsx(vf,{className:"px-4 py-3 border-b border-border shrink-0",children:p.jsxs(kf,{className:"flex items-center gap-2 text-sm font-medium",children:[I,r]})}),e[39]=I,e[40]=r,e[41]=R):R=e[41];let z;e[42]!==u?(z=p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-4",children:u}),e[42]=u,e[43]=z):z=e[43];let W;e[44]!==R||e[45]!==z?(W=p.jsxs(Sf,{side:"right",className:"w-full sm:max-w-2xl flex flex-col p-0 gap-0",children:[R,z]}),e[44]=R,e[45]=z,e[46]=W):W=e[46];let q;e[47]!==d||e[48]!==m||e[49]!==W?(q=p.jsx(Cf,{open:d,onOpenChange:m,children:W}),e[47]=d,e[48]=m,e[49]=W,e[50]=q):q=e[50];let X;return e[51]!==j||e[52]!==q?(X=p.jsxs(p.Fragment,{children:[j,q]}),e[51]=j,e[52]=q,e[53]=X):X=e[53],X}function _g(t){const e=_.c(22),{part:n}=t,r=J(),s=n.state==="output-error";let o;e[0]!==n.input?.prompt||e[1]!==r?(o=n.input?.prompt??r("chat.subtask.noPromptProvided"),e[0]=n.input?.prompt,e[1]=r,e[2]=o):o=e[2];const i=o;let a;if(e[3]!==s||e[4]!==n||e[5]!==i||e[6]!==r){const l=s?Ci(n):xT(n.output,r)??"";let c;e[8]!==r?(c=r("chat.subtask.taskLabel"),e[8]=r,e[9]=c):c=e[9];let u;e[10]!==c?(u=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:c}),e[10]=c,e[11]=u):u=e[11];let d;e[12]!==i?(d=p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:i}),e[12]=i,e[13]=d):d=e[13];let f;e[14]!==u||e[15]!==d?(f=p.jsxs("section",{children:[u,d]}),e[14]=u,e[15]=d,e[16]=f):f=e[16];let h;e[17]!==s||e[18]!==r?(h=r(s?"chat.subtask.errorLabel":"chat.subtask.resultLabel"),e[17]=s,e[18]=r,e[19]=h):h=e[19];let m;e[20]!==h?(m=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:h}),e[20]=h,e[21]=m):m=e[21],a=p.jsxs("div",{className:"flex flex-col gap-4",children:[f,p.jsxs("section",{children:[m,l.trim()?p.jsx(vl,{id:`${n.toolCallId}-result`,text:l}):p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic",children:r("chat.subtask.running")})]})]}),e[3]=s,e[4]=n,e[5]=i,e[6]=r,e[7]=a}else a=e[7];return a}const sa=600;function vT(t){const e=_.c(12),{part:n}=t,r=n.type??"";let s;e[0]!==n.toolName||e[1]!==r?(s=r==="dynamic-tool"?n.toolName??"tool":r.slice(5),e[0]=n.toolName,e[1]=r,e[2]=s):s=e[2];const o=s;let i;if(e[3]!==n.input){const f=n.input!=null?JSON.stringify(n.input):"";i=f.length>80?`${f.slice(0,80)}…`:f||void 0,e[3]=n.input,e[4]=i}else i=e[4];const a=i;let l;if(e[5]!==n.input){const f=n.input!=null?JSON.stringify(n.input,null,2):null;l=f&&f.length>sa?`${f.slice(0,sa)}
|
|
187
|
-
… (${f.length-sa} more characters)`:f,e[5]=n.input,e[6]=l}else l=e[6];const c=l;let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(jf,{}),e[7]=u):u=e[7];let d;return e[8]!==c||e[9]!==o||e[10]!==a?(d=p.jsx(ne,{icon:u,title:o,summary:a,state:"idle",detail:c,detailVariant:"code"}),e[8]=c,e[9]=o,e[10]=a,e[11]=d):d=e[11],d}function kT(t){const e=_.c(19),{jobId:n,prompt:r,items:s,streaming:o}=t,i=J();let a;e[0]!==i?(a=i("chat.subtask.taskLabel"),e[0]=i,e[1]=a):a=e[1];let l;e[2]!==a?(l=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:a}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==r?(c=p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:r}),e[4]=r,e[5]=c):c=e[5];let u;e[6]!==l||e[7]!==c?(u=p.jsxs("section",{children:[l,c]}),e[6]=l,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==s||e[10]!==n||e[11]!==o||e[12]!==i?(d=s.length===0?p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic py-1",children:i("chat.subtask.runningInBackground")}):s.map((m,y)=>{const g=m,x=g.type??"";return x==="text"?g.text?.trim()?p.jsx(gi,{id:`${n}-sub-${y}`,part:m,animate:o},`${n}-sub-${y}`):null:x==="dynamic-tool"||x.startsWith("tool-")&&x!=="tool-todo_write"&&x!=="tool-update_interests"?p.jsx(vT,{part:g},`${n}-sub-${y}`):null}),e[9]=s,e[10]=n,e[11]=o,e[12]=i,e[13]=d):d=e[13];let f;e[14]!==d?(f=p.jsx("section",{className:"flex flex-col gap-3 sm:gap-2",children:d}),e[14]=d,e[15]=f):f=e[15];let h;return e[16]!==u||e[17]!==f?(h=p.jsxs("div",{className:"flex flex-col gap-4",children:[u,f]}),e[16]=u,e[17]=f,e[18]=h):h=e[18],h}function Bg(t){const e=_.c(32),{part:n}=t,r=J(),s=n.output?.jobId,o=vs()?.taskId??null,{org:i}=xt(),[a,l]=L.useState(!1),c=mT(s),u=o??"",d=a&&!!o;let f;e[0]!==s||e[1]!==i.slug||e[2]!==u||e[3]!==d?(f={orgSlug:i.slug,threadId:u,jobId:s,enabled:d},e[0]=s,e[1]=i.slug,e[2]=u,e[3]=d,e[4]=f):f=e[4];const h=yT(f);let m;e[5]!==h.messages?(m=h.messages.flatMap(CT),e[5]=h.messages,e[6]=m):m=e[6];const y=m;let g;e[7]!==c?(g=c.flatMap(ST),e[7]=c,e[8]=g):g=e[8];const x=g,b=y.length>0?y:x;let v;e[9]!==n.input?.prompt||e[10]!==r?(v=n.input?.prompt??r("chat.subtask.noPromptProvided"),e[9]=n.input?.prompt,e[10]=r,e[11]=v):v=e[11];const k=v;let N;e[12]!==k?(N=k.length>120?`${k.slice(0,120)}…`:k,e[12]=k,e[13]=N):N=e[13];const C=N,S=c.length===0;let w;e[14]!==r?(w=r("chat.subtask.subtaskNoun"),e[14]=r,e[15]=w):w=e[15];let M;e[16]===Symbol.for("react.memo_cache_sentinel")?(M=p.jsx(Sl,{}),e[16]=M):M=e[16];let T;e[17]!==w?(T=p.jsx(Kn,{icon:void 0,name:w,size:"2xs",className:"rounded-xs",fallbackIcon:M}),e[17]=w,e[18]=T):T=e[18];let O;e[19]!==r?(O=r("chat.subtask.subtaskNoun"),e[19]=r,e[20]=O):O=e[20];const A=S?"loading":"idle",P=h.streaming||S;let D;e[21]!==b||e[22]!==s||e[23]!==k||e[24]!==P?(D=p.jsx(kT,{jobId:s,prompt:k,items:b,streaming:P}),e[21]=b,e[22]=s,e[23]=k,e[24]=P,e[25]=D):D=e[25];let E;return e[26]!==C||e[27]!==T||e[28]!==O||e[29]!==A||e[30]!==D?(E=p.jsx(Tc,{icon:T,title:O,summary:C,state:A,onOpenChange:l,children:D}),e[26]=C,e[27]=T,e[28]=O,e[29]=A,e[30]=D,e[31]=E):E=e[31],E}function ST(t){return t.parts??[]}function CT(t){return t.parts??[]}function wT(t){const e=_.c(24),n=J(),r=$g(t.part.toolCallId);if(Rg(t.part.output)){let y;return e[0]!==t?(y=p.jsx(Bg,{...t}),e[0]=t,e[1]=y):y=e[1],y}let s;e[2]!==t||e[3]!==n?(s=Pg(t,n),e[2]=t,e[3]=n,e[4]=s):s=e[4];const{fallbackTitle:o,summary:i,usage:a,state:l}=s;let c;e[5]!==n?(c=n("chat.subtask.subtaskNoun"),e[5]=n,e[6]=c):c=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Sl,{}),e[7]=u):u=e[7];let d;e[8]!==c?(d=p.jsx(Kn,{icon:void 0,name:c,size:"2xs",className:"rounded-xs",fallbackIcon:u}),e[8]=c,e[9]=d):d=e[9];let f;e[10]!==r||e[11]!==t.part?(f=r&&Lg(t.part)?r:void 0,e[10]=r,e[11]=t.part,e[12]=f):f=e[12];let h;e[13]!==t.part?(h=p.jsx(_g,{part:t.part}),e[13]=t.part,e[14]=h):h=e[14];let m;return e[15]!==o||e[16]!==t.latency||e[17]!==l||e[18]!==i||e[19]!==d||e[20]!==f||e[21]!==h||e[22]!==a?(m=p.jsx(Tc,{icon:d,title:o,summary:i,state:l,usage:a,latency:t.latency,onFlip:f,children:h}),e[15]=o,e[16]=t.latency,e[17]=l,e[18]=i,e[19]=d,e[20]=f,e[21]=h,e[22]=a,e[23]=m):m=e[23],m}function NT(t){const e=_.c(26),n=J(),r=Tf(t.part.input?.agent_id),s=$g(t.part.toolCallId);if(Rg(t.part.output)){let b;return e[0]!==t?(b=p.jsx(Bg,{...t}),e[0]=t,e[1]=b):b=e[1],b}let o;e[2]!==t||e[3]!==n?(o=Pg(t,n),e[2]=t,e[3]=n,e[4]=o):o=e[4];const{fallbackTitle:i,summary:a,usage:l,state:c}=o,u=r?.icon;let d;e[5]!==n||e[6]!==r?.title?(d=r?.title??n("chat.subtask.subtaskNoun"),e[5]=n,e[6]=r?.title,e[7]=d):d=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx(Sl,{}),e[8]=f):f=e[8];let h;e[9]!==u||e[10]!==d?(h=p.jsx(Kn,{icon:u,name:d,size:"2xs",className:"rounded-xs",fallbackIcon:f}),e[9]=u,e[10]=d,e[11]=h):h=e[11];const m=r?.title??i;let y;e[12]!==s||e[13]!==t.part?(y=s&&Lg(t.part)?s:void 0,e[12]=s,e[13]=t.part,e[14]=y):y=e[14];let g;e[15]!==t.part?(g=p.jsx(_g,{part:t.part}),e[15]=t.part,e[16]=g):g=e[16];let x;return e[17]!==t.latency||e[18]!==c||e[19]!==a||e[20]!==h||e[21]!==m||e[22]!==y||e[23]!==g||e[24]!==l?(x=p.jsx(Tc,{icon:h,title:m,summary:a,state:c,usage:l,latency:t.latency,onFlip:y,children:g}),e[17]=t.latency,e[18]=c,e[19]=a,e[20]=h,e[21]=m,e[22]=y,e[23]=g,e[24]=l,e[25]=x):x=e[25],x}function MT(t){const e=_.c(28),{part:n}=t,r=J();if(!n.state.startsWith("output-"))return null;const s=n.input?.plan??"",i=n.output?.approved===!0;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(ha,{className:"size-4 text-purple-500 shrink-0"}),e[0]=a):a=e[0];let l;e[1]!==r?(l=r("chat.proposePlan.implementationPlan"),e[1]=r,e[2]=l):l=e[2];let c;e[3]!==l?(c=p.jsx("span",{className:"text-[14px] font-medium text-foreground/80",children:l}),e[3]=l,e[4]=c):c=e[4];let u;e[5]!==i||e[6]!==r?(u=i&&p.jsxs("span",{className:"flex items-center gap-1 text-xs text-success bg-success/10 px-1.5 py-0.5 rounded-md",children:[p.jsx(xl,{size:12}),r("chat.proposePlan.approved")]}),e[5]=i,e[6]=r,e[7]=u):u=e[7];let d;e[8]!==i||e[9]!==n.state||e[10]!==r?(d=!i&&n.state==="output-available"&&p.jsx("span",{className:"text-xs text-muted-foreground/70 italic",children:r("chat.proposePlan.rejected")}),e[8]=i,e[9]=n.state,e[10]=r,e[11]=d):d=e[11];let f;e[12]!==c||e[13]!==u||e[14]!==d?(f=p.jsxs("div",{className:"flex items-center gap-2",children:[a,c,u,d]}),e[12]=c,e[13]=u,e[14]=d,e[15]=f):f=e[15];let h;e[16]!==r?(h=r("chat.proposePlan.viewPlan"),e[16]=r,e[17]=h):h=e[17];let m;e[18]!==h?(m=p.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:h}),e[18]=h,e[19]=m):m=e[19];let y;e[20]!==s?(y=p.jsx("div",{className:"mt-1 pl-2 border-l-2 border-purple-500/30 prose prose-sm max-w-none text-sm",children:p.jsx(gi,{id:"plan-content",part:{type:"text",text:s}})}),e[20]=s,e[21]=y):y=e[21];let g;e[22]!==m||e[23]!==y?(g=p.jsxs("details",{className:"ml-6",children:[m,y]}),e[22]=m,e[23]=y,e[24]=g):g=e[24];let x;return e[25]!==g||e[26]!==f?(x=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[f,g]}),e[25]=g,e[26]=f,e[27]=x):x=e[27],x}function Ec(t){return{primary:t("chat.brandContext.colorPrimary"),secondary:t("chat.brandContext.colorSecondary"),accent:t("chat.brandContext.colorAccent"),background:t("chat.brandContext.colorBackground"),foreground:t("chat.brandContext.colorForeground")}}function TT(t){try{const e=new URL(t.startsWith("http")?t:`https://${t}`);return e.protocol!=="http:"&&e.protocol!=="https:"?"about:blank":e.href}catch{return"about:blank"}}function Dc(t){return t?Object.entries(t).filter(([,e])=>typeof e=="string"&&e.trim().length>0):[]}function ET(t){return t?Object.entries(t).filter(([,e])=>typeof e=="string"&&e.trim().length>0):[]}function Zd(t){const e=_.c(2),{children:n}=t;let r;return e[0]!==n?(r=p.jsx("span",{className:"text-sm font-medium text-foreground",children:n}),e[0]=n,e[1]=r):r=e[1],r}function DT(t){const e=_.c(12),{name:n,value:r}=t;let s;e[0]!==r?(s=p.jsx("span",{className:"size-7 shrink-0 rounded-md border border-border",style:{backgroundColor:r},"aria-hidden":!0}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==n?(o=p.jsx("span",{className:"text-sm text-foreground",children:n}),e[2]=n,e[3]=o):o=e[3];let i;e[4]!==r?(i=p.jsx("span",{className:"text-xs font-mono tabular-nums text-muted-foreground",children:r}),e[4]=r,e[5]=i):i=e[5];let a;e[6]!==o||e[7]!==i?(a=p.jsxs("div",{className:"flex flex-col leading-tight min-w-0",children:[o,i]}),e[6]=o,e[7]=i,e[8]=a):a=e[8];let l;return e[9]!==s||e[10]!==a?(l=p.jsxs("div",{className:"flex items-center gap-2.5",children:[s,a]}),e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function OT(t){const e=_.c(15),{role:n,family:r}=t;let s;e[0]!==r?(s=p.jsx("span",{className:"text-2xl font-medium leading-none text-foreground shrink-0",style:{fontFamily:r},"aria-hidden":!0,children:"Aa"}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==n?(o=p.jsx("span",{className:"text-xs text-muted-foreground",children:n}),e[2]=n,e[3]=o):o=e[3];let i;e[4]!==r?(i={fontFamily:r},e[4]=r,e[5]=i):i=e[5];let a;e[6]!==r||e[7]!==i?(a=p.jsx("span",{className:"text-sm text-foreground",style:i,children:r}),e[6]=r,e[7]=i,e[8]=a):a=e[8];let l;e[9]!==o||e[10]!==a?(l=p.jsxs("div",{className:"flex flex-col leading-tight",children:[o,a]}),e[9]=o,e[10]=a,e[11]=l):l=e[11];let c;return e[12]!==s||e[13]!==l?(c=p.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted px-4 py-3",children:[s,l]}),e[12]=s,e[13]=l,e[14]=c):c=e[14],c}function AT(t){const e=_.c(3),{logo:n,favicon:r,name:s}=t,o=n??r;if(!o)return null;const i=s?`${s} logo`:"";let a;return e[0]!==o||e[1]!==i?(a=p.jsx("img",{src:o,alt:i,className:"size-16 shrink-0 rounded-lg border border-border bg-background object-contain p-2",onError:IT}),e[0]=o,e[1]=i,e[2]=a):a=e[2],a}function IT(t){t.target.style.display="none"}function zg(t){const e=_.c(12),{colors:n}=t,r=J();let s;e[0]!==r?(s=Ec(r),e[0]=r,e[1]=s):s=e[1];const o=s;let i,a,l;if(e[2]!==o||e[3]!==n){l=Symbol.for("react.early_return_sentinel");e:{const u=Dc(n);if(u.length===0){l=null;break e}i="flex h-1.5";let d;e[7]!==o?(d=f=>{const[h,m]=f;return p.jsx("span",{className:"flex-1",style:{backgroundColor:m},title:`${o[h]}: ${m}`,"aria-hidden":!0},h)},e[7]=o,e[8]=d):d=e[8],a=u.map(d)}e[2]=o,e[3]=n,e[4]=i,e[5]=a,e[6]=l}else i=e[4],a=e[5],l=e[6];if(l!==Symbol.for("react.early_return_sentinel"))return l;let c;return e[9]!==i||e[10]!==a?(c=p.jsx("div",{className:i,children:a}),e[9]=i,e[10]=a,e[11]=c):c=e[11],c}function Fg(t){const e=_.c(51),{logo:n,favicon:r,name:s,domain:o,overview:i,colors:a,fonts:l,showDefaultBadge:c,isDefault:u}=t,d=J();let f;e[0]!==d?(f=Ec(d),e[0]=d,e[1]=f):f=e[1];const h=f;let m,y,g,x,b,v,k;if(e[2]!==h||e[3]!==a||e[4]!==o||e[5]!==r||e[6]!==l||e[7]!==u||e[8]!==n||e[9]!==s||e[10]!==i||e[11]!==c||e[12]!==d){const S=Dc(a),w=ET(l);v="mt-2 rounded-lg overflow-hidden border border-border",e[20]!==a?(k=a&&p.jsx(zg,{colors:a}),e[20]=a,e[21]=k):k=e[21],m="p-5 flex flex-col gap-6";let M;e[22]!==r||e[23]!==n||e[24]!==s?(M=p.jsx(AT,{logo:n,favicon:r,name:s}),e[22]=r,e[23]=n,e[24]=s,e[25]=M):M=e[25];let T;e[26]!==u||e[27]!==s||e[28]!==c||e[29]!==d?(T=s&&p.jsxs("span",{className:"inline-flex items-center gap-2 text-lg font-semibold text-foreground truncate",children:[s,c&&u&&p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[p.jsx(Nf,{className:"size-3 text-amber-500"}),d("chat.brandContext.defaultBadge")]})]}),e[26]=u,e[27]=s,e[28]=c,e[29]=d,e[30]=T):T=e[30];let O;e[31]!==o?(O=o&&p.jsxs("a",{href:TT(o),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[o,p.jsx(Bf,{className:"size-3 shrink-0"})]}),e[31]=o,e[32]=O):O=e[32];let A;e[33]!==T||e[34]!==O?(A=p.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[T,O]}),e[33]=T,e[34]=O,e[35]=A):A=e[35],e[36]!==A||e[37]!==M?(y=p.jsxs("div",{className:"flex items-center gap-4",children:[M,A]}),e[36]=A,e[37]=M,e[38]=y):y=e[38],e[39]!==i?(g=i&&p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:i}),e[39]=i,e[40]=g):g=e[40],x=S.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Zd,{children:d("chat.brandContext.colorsSection")}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-3",children:S.map(P=>{const[D,E]=P;return p.jsx(DT,{name:h[D],value:E},D)})})]}),b=w.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Zd,{children:d("chat.brandContext.typographySection")}),p.jsx("div",{className:"flex flex-wrap gap-2.5",children:w.map(jT)})]}),e[2]=h,e[3]=a,e[4]=o,e[5]=r,e[6]=l,e[7]=u,e[8]=n,e[9]=s,e[10]=i,e[11]=c,e[12]=d,e[13]=m,e[14]=y,e[15]=g,e[16]=x,e[17]=b,e[18]=v,e[19]=k}else m=e[13],y=e[14],g=e[15],x=e[16],b=e[17],v=e[18],k=e[19];let N;e[41]!==m||e[42]!==y||e[43]!==g||e[44]!==x||e[45]!==b?(N=p.jsxs("div",{className:m,children:[y,g,x,b]}),e[41]=m,e[42]=y,e[43]=g,e[44]=x,e[45]=b,e[46]=N):N=e[46];let C;return e[47]!==v||e[48]!==k||e[49]!==N?(C=p.jsxs("div",{className:v,children:[k,N]}),e[47]=v,e[48]=k,e[49]=N,e[50]=C):C=e[50],C}function jT(t){const[e,n]=t;return p.jsx(OT,{role:e,family:n},e)}function RT(t){const e=_.c(46),{part:n,latency:r}=t,s=J();let o;e[0]!==n.state?(o=It(n.state),e[0]=n.state,e[1]=o):o=e[1];const i=o;let a,l,c,u,d;if(e[2]!==r||e[3]!==n.input||e[4]!==n.output||e[5]!==i||e[6]!==s){d=Symbol.for("react.early_return_sentinel");e:{l=Nr(n.output);const w=i==="loading",M=i==="error"||l&&l.success===!1;if(w){const T=n.input;let O;e[12]===Symbol.for("react.memo_cache_sentinel")?(O=p.jsx(Nt,{className:"animate-pulse"}),e[12]=O):O=e[12];let A;e[13]!==s?(A=s("chat.brandContext.extractingBrand"),e[13]=s,e[14]=A):A=e[14];let P;e[15]!==T||e[16]!==s?(P=T?.domain?s("chat.brandContext.fromDomain",{domain:T.domain}):void 0,e[15]=T,e[16]=s,e[17]=P):P=e[17];let D;e[18]!==A||e[19]!==P?(D=p.jsx(ne,{icon:O,title:A,summary:P,state:"loading",defaultOpen:!0}),e[18]=A,e[19]=P,e[20]=D):D=e[20],d=D;break e}if(M){let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(Nt,{}),e[21]=T):T=e[21];let O;e[22]!==s?(O=s("chat.brandContext.extractionFailed"),e[22]=s,e[23]=O):O=e[23];let A;e[24]!==r?(A=p.jsx(Le,{latency:r}),e[24]=r,e[25]=A):A=e[25],d=p.jsx(ne,{icon:T,title:O,summary:l?.error??s("chat.brandContext.unknownError"),state:"error",trailing:A});break e}a=ne,e[26]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(Nt,{className:"text-fuchsia-500"}),e[26]=c):c=e[26],u=l?.name?s("chat.brandContext.brandSet",{name:l.name}):s("chat.brandContext.brandContextSet")}e[2]=r,e[3]=n.input,e[4]=n.output,e[5]=i,e[6]=s,e[7]=a,e[8]=l,e[9]=c,e[10]=u,e[11]=d}else a=e[7],l=e[8],c=e[9],u=e[10],d=e[11];if(d!==Symbol.for("react.early_return_sentinel"))return d;const f=l?.domain;let h;e[27]!==r?(h=p.jsx(Le,{latency:r}),e[27]=r,e[28]=h):h=e[28];let m;e[29]!==a||e[30]!==c||e[31]!==u||e[32]!==f||e[33]!==h?(m=p.jsx(a,{icon:c,title:u,summary:f,state:"idle",trailing:h}),e[29]=a,e[30]=c,e[31]=u,e[32]=f,e[33]=h,e[34]=m):m=e[34];const y=l?.logo,g=l?.favicon,x=l?.name,b=l?.domain,v=l?.overview,k=l?.colors,N=l?.fonts;let C;e[35]!==x||e[36]!==b||e[37]!==v||e[38]!==k||e[39]!==N||e[40]!==y||e[41]!==g?(C=p.jsx(Fg,{logo:y,favicon:g,name:x,domain:b,overview:v,colors:k,fonts:N}),e[35]=x,e[36]=b,e[37]=v,e[38]=k,e[39]=N,e[40]=y,e[41]=g,e[42]=C):C=e[42];let S;return e[43]!==C||e[44]!==m?(S=p.jsxs(p.Fragment,{children:[m,C]}),e[43]=C,e[44]=m,e[45]=S):S=e[45],S}function PT(t){const e=_.c(45),{part:n,latency:r}=t,s=J();let o;e[0]!==n.state?(o=It(n.state),e[0]=n.state,e[1]=o):o=e[1];const i=o;let a,l,c,u,d;if(e[2]!==r||e[3]!==n.output||e[4]!==i||e[5]!==s){d=Symbol.for("react.early_return_sentinel");e:{l=Nr(n.output);const g=i==="loading",x=i==="error"||l&&l.success===!1;if(g){let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx(Nt,{className:"animate-pulse"}),e[11]=b):b=e[11];let v;e[12]!==s?(v=s("chat.brandContext.loadingBrand"),e[12]=s,e[13]=v):v=e[13];let k;e[14]!==v?(k=p.jsx(ne,{icon:b,title:v,state:"loading"}),e[14]=v,e[15]=k):k=e[15],d=k;break e}if(x||!l){let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx(Nt,{}),e[16]=b):b=e[16];let v;e[17]!==s?(v=s("chat.brandContext.couldNotLoadBrand"),e[17]=s,e[18]=v):v=e[18];let k;e[19]!==r?(k=p.jsx(Le,{latency:r}),e[19]=r,e[20]=k):k=e[20];let N;e[21]!==v||e[22]!==k?(N=p.jsx(ne,{icon:b,title:v,state:"error",trailing:k}),e[21]=v,e[22]=k,e[23]=N):N=e[23],d=N;break e}a=ne,e[24]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(Nt,{className:"text-fuchsia-500"}),e[24]=c):c=e[24],u=l.name?s("chat.brandContext.brandWithName",{name:l.name}):s("chat.brandContext.brand")}e[2]=r,e[3]=n.output,e[4]=i,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e[9]=u,e[10]=d}else a=e[6],l=e[7],c=e[8],u=e[9],d=e[10];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[25]!==r?(f=p.jsx(Le,{latency:r}),e[25]=r,e[26]=f):f=e[26];let h;e[27]!==a||e[28]!==l.domain||e[29]!==c||e[30]!==u||e[31]!==f?(h=p.jsx(a,{icon:c,title:u,summary:l.domain,state:"idle",trailing:f}),e[27]=a,e[28]=l.domain,e[29]=c,e[30]=u,e[31]=f,e[32]=h):h=e[32];let m;e[33]!==l.colors||e[34]!==l.domain||e[35]!==l.favicon||e[36]!==l.fonts||e[37]!==l.isDefault||e[38]!==l.logo||e[39]!==l.name||e[40]!==l.overview?(m=p.jsx(Fg,{logo:l.logo,favicon:l.favicon,name:l.name,domain:l.domain,overview:l.overview,colors:l.colors,fonts:l.fonts,showDefaultBadge:!0,isDefault:l.isDefault}),e[33]=l.colors,e[34]=l.domain,e[35]=l.favicon,e[36]=l.fonts,e[37]=l.isDefault,e[38]=l.logo,e[39]=l.name,e[40]=l.overview,e[41]=m):m=e[41];let y;return e[42]!==h||e[43]!==m?(y=p.jsxs(p.Fragment,{children:[h,m]}),e[42]=h,e[43]=m,e[44]=y):y=e[44],y}function LT(t){const e=_.c(49),{part:n,latency:r}=t,s=J();let o;e[0]!==s?(o=Ec(s),e[0]=s,e[1]=o):o=e[1];const i=o;let a;e[2]!==n.state?(a=It(n.state),e[2]=n.state,e[3]=a):a=e[3];const l=a;let c,u,d,f;if(e[4]!==i||e[5]!==r||e[6]!==n.output||e[7]!==l||e[8]!==s){f=Symbol.for("react.early_return_sentinel");e:{const y=Nr(n.output),g=Array.isArray(y?.items)?y.items:[],x=l==="loading",b=l==="error";if(x){let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Nt,{className:"animate-pulse"}),e[13]=C):C=e[13];let S;e[14]!==s?(S=s("chat.brandContext.loadingBrands"),e[14]=s,e[15]=S):S=e[15];let w;e[16]!==S?(w=p.jsx(ne,{icon:C,title:S,state:"loading"}),e[16]=S,e[17]=w):w=e[17],f=w;break e}if(b){let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Nt,{}),e[18]=C):C=e[18];let S;e[19]!==s?(S=s("chat.brandContext.couldNotLoadBrands"),e[19]=s,e[20]=S):S=e[20];let w;e[21]!==r?(w=p.jsx(Le,{latency:r}),e[21]=r,e[22]=w):w=e[22];let M;e[23]!==S||e[24]!==w?(M=p.jsx(ne,{icon:C,title:S,state:"error",trailing:w}),e[23]=S,e[24]=w,e[25]=M):M=e[25],f=M;break e}if(g.length===0){let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Nt,{}),e[26]=C):C=e[26];let S;e[27]!==s?(S=s("chat.brandContext.noBrandsYet"),e[27]=s,e[28]=S):S=e[28];let w;e[29]!==s?(w=s("chat.brandContext.noBrandsContext"),e[29]=s,e[30]=w):w=e[30];let M;e[31]!==r?(M=p.jsx(Le,{latency:r}),e[31]=r,e[32]=M):M=e[32];let T;e[33]!==M||e[34]!==S||e[35]!==w?(T=p.jsx(ne,{icon:C,title:S,summary:w,state:"idle",trailing:M}),e[33]=M,e[34]=S,e[35]=w,e[36]=T):T=e[36],f=T;break e}let v;e[37]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(Nt,{className:"text-fuchsia-500"}),e[37]=v):v=e[37];let k;e[38]!==r?(k=p.jsx(Le,{latency:r}),e[38]=r,e[39]=k):k=e[39],d=p.jsx(ne,{icon:v,title:g.length===1?s("chat.brandContext.oneBrand"):s("chat.brandContext.multipleBrands",{count:g.length}),state:"idle",trailing:k}),c="mt-2 flex flex-col gap-1.5";let N;e[40]!==i||e[41]!==s?(N=(C,S)=>{const w=Dc(C.colors);return p.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[C.colors&&p.jsx(zg,{colors:C.colors}),p.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[(C.logo||C.favicon)&&p.jsx("img",{src:C.logo??C.favicon??void 0,alt:"",className:"size-8 shrink-0 rounded-md border border-border bg-background object-contain p-0.5",onError:$T}),p.jsxs("div",{className:"flex flex-col leading-tight min-w-0 flex-1",children:[p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-foreground truncate",children:[C.name??s("chat.brandContext.untitled"),C.isDefault&&p.jsx(Nf,{className:"size-3 text-amber-500 shrink-0"})]}),C.domain&&p.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:C.domain})]}),w.length>0&&p.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:w.slice(0,5).map(M=>{const[T,O]=M;return p.jsx("span",{className:"size-3 rounded-full border border-border",style:{backgroundColor:O},title:`${i[T]}: ${O}`,"aria-hidden":!0},T)})})]})]},C.id??`${C.name}-${C.domain}-${S}`)},e[40]=i,e[41]=s,e[42]=N):N=e[42],u=g.map(N)}e[4]=i,e[5]=r,e[6]=n.output,e[7]=l,e[8]=s,e[9]=c,e[10]=u,e[11]=d,e[12]=f}else c=e[9],u=e[10],d=e[11],f=e[12];if(f!==Symbol.for("react.early_return_sentinel"))return f;let h;e[43]!==c||e[44]!==u?(h=p.jsx("div",{className:c,children:u}),e[43]=c,e[44]=u,e[45]=h):h=e[45];let m;return e[46]!==d||e[47]!==h?(m=p.jsxs(p.Fragment,{children:[d,h]}),e[46]=d,e[47]=h,e[48]=m):m=e[48],m}function $T(t){t.target.style.display="none"}function ll(t){const e=_.c(4),{connection_id:n,iconSize:r}=t,s=r===void 0?"xs":r,o=Tf(n);if(!o)return null;let i;return e[0]!==o.icon||e[1]!==o.title||e[2]!==s?(i=p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx(Kn,{icon:o.icon,name:o.title,size:s})}),e[0]=o.icon,e[1]=o.title,e[2]=s,e[3]=i):i=e[3],i}ll.Fallback=function({iconSize:e="xs"}){const n=e==="sm"?"size-6":"size-5";return p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:G(n,"rounded bg-muted animate-pulse")})})};function xs(t){const e=_.c(18),{connectionIds:n,maxVisibleIcons:r,iconSize:s,className:o}=t,i=r===void 0?2:r,a=s===void 0?"xs":s;if(n.length===0)return null;let l,c,u;if(e[0]!==o||e[1]!==n||e[2]!==a||e[3]!==i){const h=n.slice(0,i);l=n.length-i,e[7]!==o?(c=G("flex items-center justify-end -space-x-2",o),e[7]=o,e[8]=c):c=e[8];let m;e[9]!==a?(m=y=>p.jsx(L.Suspense,{fallback:p.jsx(ll.Fallback,{iconSize:a}),children:p.jsx(ll,{connection_id:y,iconSize:a})},y),e[9]=a,e[10]=m):m=e[10],u=h.map(m),e[0]=o,e[1]=n,e[2]=a,e[3]=i,e[4]=l,e[5]=c,e[6]=u}else l=e[4],c=e[5],u=e[6];let d;e[11]!==a||e[12]!==l?(d=l>0&&p.jsx("div",{className:G("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",a==="sm"?"size-8":"size-6"),children:p.jsxs("span",{className:G(a==="sm"?"text-sm":"text-xs","font-medium text-muted-foreground"),"aria-label":`and ${l} more`,children:["+",l]})}),e[11]=a,e[12]=l,e[13]=d):d=e[13];let f;return e[14]!==c||e[15]!==u||e[16]!==d?(f=p.jsxs("div",{className:c,children:[u,d]}),e[14]=c,e[15]=u,e[16]=d,e[17]=f):f=e[17],f}xs.Fallback=function({maxVisibleIcons:e=2,totalCount:n,iconSize:r="xs"}){const s=r==="sm"?"size-6":"size-5",o=r==="sm"?"size-8":"size-6",i=n!==void 0&&n>e;return p.jsxs("div",{className:"flex items-center -space-x-2",children:[Array.from({length:e}).map((a,l)=>p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:G(s,"rounded bg-muted animate-pulse")})},l)),i&&p.jsx("div",{className:G("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",o),children:p.jsx("div",{className:G(r==="sm"?"h-3.5 w-5":"h-3 w-4","rounded bg-muted animate-pulse")})})]})};const _T="This document certifies that the bearer agent has been granted authorized access to the tools and capabilities described herein. The agent is permitted to operate within the scope defined by its instructions and shall act in accordance with the constraints set forth by the issuing organization. This credential remains valid for the duration of the agent's active status. Unauthorized modification of this agent's permissions or scope is prohibited. The issuing authority reserves the right to revoke access at any time. All actions performed by this agent are subject to audit and review by the organization administrator. ",ef=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null;function BT(t){const e=_.c(105),{part:n,latency:r}=t,s=J(),o=zf(),i=It(n.state),a=L.useRef(null),l=L.useRef(null),c=L.useRef(null),u=L.useRef(null),d=L.useRef(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{ef?.matches||(d.current=a.current?.getBoundingClientRect()??null,a.current&&(a.current.style.willChange="transform"))},e[0]=f):f=e[0];const h=f;let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=Q=>{if(ef?.matches)return;const ee=d.current,se=a.current;if(!ee||!se)return;const _e=(Q.clientX-ee.left)/ee.width*100,Je=(Q.clientY-ee.top)/ee.height*100;se.style.transform=`perspective(800px) rotateY(${(_e-50)*.05}deg) rotateX(${(Je-50)*-.05}deg)`,l.current&&(l.current.style.opacity="1",l.current.style.transform=`translate(${(_e-50)*.15}px, ${(Je-50)*.15}px)`),c.current&&(c.current.style.opacity="0.45"),u.current&&(u.current.style.opacity="0.45")},e[1]=m):m=e[1];const y=m;let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const Q=a.current;Q&&(Q.style.transform="none",Q.style.willChange="auto"),l.current&&(l.current.style.opacity="0.4",l.current.style.transform="translate(0, 0)"),c.current&&(c.current.style.opacity="0.3"),u.current&&(u.current.style.opacity="0.3"),d.current=null},e[2]=g):g=e[2];const x=g;if(i==="loading"){let Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q=p.jsx(wt,{className:"animate-pulse"}),e[3]=Q):Q=e[3];let ee;e[4]!==s?(ee=s("chat.agentCreate.creating"),e[4]=s,e[5]=ee):ee=e[5];let se;return e[6]!==ee?(se=p.jsx(ne,{icon:Q,title:ee,state:"loading",defaultOpen:!0}),e[6]=ee,e[7]=se):se=e[7],se}if(i==="approval"){let Q;e[8]===Symbol.for("react.memo_cache_sentinel")?(Q=p.jsx(wt,{}),e[8]=Q):Q=e[8];let ee;e[9]!==s?(ee=s("chat.agentCreate.createAgent"),e[9]=s,e[10]=ee):ee=e[10];let se;return e[11]!==ee?(se=p.jsx(ne,{icon:Q,title:ee,state:"idle"}),e[11]=ee,e[12]=se):se=e[12],se}if(i==="error"){let Q;e[13]===Symbol.for("react.memo_cache_sentinel")?(Q=p.jsx(wt,{}),e[13]=Q):Q=e[13];let ee;e[14]!==n.state||e[15]!==s?(ee=n.state==="output-denied"?s("chat.agentCreate.cancelled"):s("chat.agentCreate.couldntCreate"),e[14]=n.state,e[15]=s,e[16]=ee):ee=e[16];let se;e[17]!==r?(se=p.jsx(Le,{latency:r}),e[17]=r,e[18]=se):se=e[18];let _e;return e[19]!==ee||e[20]!==se?(_e=p.jsx(ne,{icon:Q,title:ee,state:"error",trailing:se}),e[19]=ee,e[20]=se,e[21]=_e):_e=e[21],_e}let b,v,k,N,C,S,w,M,T,O,A,P,D,E,j,I,R,z,W,q,X,te,ae;if(e[22]!==r||e[23]!==o||e[24]!==n.output||e[25]!==s){R=Symbol.for("react.early_return_sentinel");e:{const Q=Nr(n.output)?.item;if(!Q?.id||!Q?.title){let ut;e[49]===Symbol.for("react.memo_cache_sentinel")?(ut=p.jsx(wt,{}),e[49]=ut):ut=e[49];let dt;e[50]!==s?(dt=s("chat.agentCreate.created"),e[50]=s,e[51]=dt):dt=e[51];let ue;e[52]!==r?(ue=p.jsx(Le,{latency:r}),e[52]=r,e[53]=ue):ue=e[53];let Me;e[54]!==dt||e[55]!==ue?(Me=p.jsx(ne,{icon:ut,title:dt,state:"idle",trailing:ue}),e[54]=dt,e[55]=ue,e[56]=Me):Me=e[56],R=Me;break e}const ee=(Q.connections??[]).map(zT);let se;e[57]===Symbol.for("react.memo_cache_sentinel")?(se=p.jsx(wt,{className:"text-success"}),e[57]=se):se=e[57];let _e;e[58]!==r?(_e=p.jsx(Le,{latency:r}),e[58]=r,e[59]=_e):_e=e[59],I=p.jsx(ne,{icon:se,title:s("chat.agentCreate.agentCreated",{name:Q.title}),state:"idle",trailing:_e}),j="mt-2 overflow-hidden rounded-xl border-[0.5px] border-border bg-card p-2.5",k=a,N="relative overflow-hidden rounded-lg bg-accent/25 p-2",e[60]===Symbol.for("react.memo_cache_sentinel")?(C={transition:"transform 0.3s ease-out"},e[60]=C):C=e[60],S=h,w=y,M=x,e[61]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx("div",{ref:l,className:"pointer-events-none absolute inset-[-20%] z-[1] select-none rounded-lg",style:{background:"linear-gradient(135deg, hsla(280, 60%, 80%, 0.35) 0%, transparent 35%), linear-gradient(315deg, hsla(190, 70%, 80%, 0.35) 0%, transparent 35%), linear-gradient(225deg, hsla(140, 55%, 80%, 0.3) 0%, transparent 30%), linear-gradient(45deg, hsla(320, 55%, 82%, 0.3) 0%, transparent 30%)",opacity:.4,transition:"opacity 0.3s ease, transform 0.3s ease-out"},"aria-hidden":"true"}),e[61]=T):T=e[61];let Je;e[62]===Symbol.for("react.memo_cache_sentinel")?(Je={textAlign:"justify",wordBreak:"break-all"},e[62]=Je):Je=e[62],e[63]===Symbol.for("react.memo_cache_sentinel")?(O=p.jsx("p",{className:"pointer-events-none absolute inset-0 z-[1] select-none overflow-hidden text-[6px] font-light leading-[1.5] tracking-[0.06px] text-background opacity-50 mix-blend-overlay",style:Je,"aria-hidden":"true",children:_T.repeat(6)}),A=p.jsx("img",{src:"/stamp.svg",alt:"",className:"pointer-events-none absolute -right-10 -top-10 size-[140px] opacity-50 select-none","aria-hidden":"true"}),e[63]=O,e[64]=A):(O=e[63],A=e[64]),e[65]===Symbol.for("react.memo_cache_sentinel")?(P=p.jsx("img",{ref:c,src:"/left-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 left-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[65]=P):P=e[65],e[66]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx("img",{ref:u,src:"/right-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 right-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[66]=D):D=e[66],E=p.jsxs("div",{className:"relative",children:[p.jsxs("div",{className:"flex items-center gap-2.5 p-2",children:[p.jsx(Mf,{icon:Q.icon,name:Q.title,size:"md"}),p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:Q.title})})]}),Q.description&&p.jsx("div",{className:"px-2 pt-1 pr-16",children:p.jsx("p",{className:"text-sm leading-snug text-muted-foreground line-clamp-2",children:Q.description})})]}),ae="relative z-[3] flex items-center gap-2.5 px-2 pt-6 pb-1";const vt=ee.length>0&&p.jsx(L.Suspense,{fallback:p.jsx(xs.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:ee.length}),children:p.jsx(xs,{connectionIds:ee,iconSize:"xs",maxVisibleIcons:3,className:"flex items-center justify-start -space-x-1"})});e[67]!==vt?(v=p.jsx("div",{className:"flex-1 min-w-0",children:vt}),e[67]=vt,e[68]=v):v=e[68],te="flex items-center gap-2 shrink-0",b=Ln,z="sm",W="h-7",q=()=>o(Q.id),X=s("chat.agentCreate.seeAgentLabel",{name:Q.title})}e[22]=r,e[23]=o,e[24]=n.output,e[25]=s,e[26]=b,e[27]=v,e[28]=k,e[29]=N,e[30]=C,e[31]=S,e[32]=w,e[33]=M,e[34]=T,e[35]=O,e[36]=A,e[37]=P,e[38]=D,e[39]=E,e[40]=j,e[41]=I,e[42]=R,e[43]=z,e[44]=W,e[45]=q,e[46]=X,e[47]=te,e[48]=ae}else b=e[26],v=e[27],k=e[28],N=e[29],C=e[30],S=e[31],w=e[32],M=e[33],T=e[34],O=e[35],A=e[36],P=e[37],D=e[38],E=e[39],j=e[40],I=e[41],R=e[42],z=e[43],W=e[44],q=e[45],X=e[46],te=e[47],ae=e[48];if(R!==Symbol.for("react.early_return_sentinel"))return R;let fe;e[69]!==s?(fe=s("chat.agentCreate.seeAgent"),e[69]=s,e[70]=fe):fe=e[70];let ce;e[71]!==b||e[72]!==fe||e[73]!==z||e[74]!==W||e[75]!==q||e[76]!==X?(ce=p.jsx(b,{size:z,className:W,onClick:q,"aria-label":X,children:fe}),e[71]=b,e[72]=fe,e[73]=z,e[74]=W,e[75]=q,e[76]=X,e[77]=ce):ce=e[77];let we;e[78]!==ce||e[79]!==te?(we=p.jsx("div",{className:te,children:ce}),e[78]=ce,e[79]=te,e[80]=we):we=e[80];let $e;e[81]!==v||e[82]!==we||e[83]!==ae?($e=p.jsxs("div",{className:ae,children:[v,we]}),e[81]=v,e[82]=we,e[83]=ae,e[84]=$e):$e=e[84];let Ne;e[85]!==k||e[86]!==N||e[87]!==C||e[88]!==S||e[89]!==w||e[90]!==M||e[91]!==T||e[92]!==O||e[93]!==A||e[94]!==P||e[95]!==D||e[96]!==E||e[97]!==$e?(Ne=p.jsxs("div",{ref:k,className:N,style:C,onMouseEnter:S,onMouseMove:w,onMouseLeave:M,children:[T,O,A,P,D,E,$e]}),e[85]=k,e[86]=N,e[87]=C,e[88]=S,e[89]=w,e[90]=M,e[91]=T,e[92]=O,e[93]=A,e[94]=P,e[95]=D,e[96]=E,e[97]=$e,e[98]=Ne):Ne=e[98];let me;e[99]!==j||e[100]!==Ne?(me=p.jsx("div",{className:j,children:Ne}),e[99]=j,e[100]=Ne,e[101]=me):me=e[101];let Ke;return e[102]!==I||e[103]!==me?(Ke=p.jsxs(p.Fragment,{children:[I,me]}),e[102]=I,e[103]=me,e[104]=Ke):Ke=e[104],Ke}function zT(t){return t.connection_id}function FT(t){const e=_.c(24),{agent:n}=t,r=zf();if(!n.id)return null;let s;e[0]!==n.connections?(s=n.connections??[],e[0]=n.connections,e[1]=s):s=e[1];let o;e[2]!==s?(o=s.map(HT),e[2]=s,e[3]=o):o=e[3];const i=o;let a;e[4]!==n.id||e[5]!==r?(a=()=>r(n.id),e[4]=n.id,e[5]=r,e[6]=a):a=e[6];let l;e[7]!==n.icon||e[8]!==n.title?(l=p.jsx(Mf,{icon:n.icon,name:n.title,size:"sm"}),e[7]=n.icon,e[8]=n.title,e[9]=l):l=e[9];let c;e[10]!==n.title?(c=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:n.title}),e[10]=n.title,e[11]=c):c=e[11];let u;e[12]!==n.description?(u=n.description&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.description}),e[12]=n.description,e[13]=u):u=e[13];let d;e[14]!==c||e[15]!==u?(d=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16];let f;e[17]!==i?(f=i.length>0&&p.jsx(L.Suspense,{fallback:p.jsx(xs.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:i.length}),children:p.jsx(xs,{connectionIds:i,iconSize:"xs",maxVisibleIcons:3})}),e[17]=i,e[18]=f):f=e[18];let h;return e[19]!==a||e[20]!==l||e[21]!==d||e[22]!==f?(h=p.jsxs("button",{type:"button",onClick:a,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[l,d,f]}),e[19]=a,e[20]=l,e[21]=d,e[22]=f,e[23]=h):h=e[23],h}function HT(t){return t.connection_id}function WT(t){const e=_.c(59),{part:n,latency:r}=t,s=J(),o=ml(),{org:i}=xt();let a;e[0]!==n.state?(a=It(n.state),e[0]=n.state,e[1]=a):a=e[1];const l=a;let c,u,d,f,h,m;if(e[2]!==r||e[3]!==n.output||e[4]!==n.state||e[5]!==l||e[6]!==s){m=Symbol.for("react.early_return_sentinel");e:{const b=Nr(n.output);if(u=Array.isArray(b?.items)?b.items:[],l==="loading"){let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(wt,{className:"animate-pulse"}),e[13]=C):C=e[13];let S;e[14]!==s?(S=s("chat.agentList.loading"),e[14]=s,e[15]=S):S=e[15];let w;e[16]!==S?(w=p.jsx(ne,{icon:C,title:S,state:"loading"}),e[16]=S,e[17]=w):w=e[17],m=w;break e}if(l==="approval"){let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(wt,{}),e[18]=C):C=e[18];let S;e[19]!==s?(S=s("chat.agentList.listAgents"),e[19]=s,e[20]=S):S=e[20];let w;e[21]!==S?(w=p.jsx(ne,{icon:C,title:S,state:"idle"}),e[21]=S,e[22]=w):w=e[22],m=w;break e}if(l==="error"){let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(wt,{}),e[23]=C):C=e[23];let S;e[24]!==n.state||e[25]!==s?(S=n.state==="output-denied"?s("chat.agentList.unavailable"):s("chat.agentList.couldntLoad"),e[24]=n.state,e[25]=s,e[26]=S):S=e[26];let w;e[27]!==r?(w=p.jsx(Le,{latency:r}),e[27]=r,e[28]=w):w=e[28];let M;e[29]!==S||e[30]!==w?(M=p.jsx(ne,{icon:C,title:S,state:"error",trailing:w}),e[29]=S,e[30]=w,e[31]=M):M=e[31],m=M;break e}if(u.length===0){let C;e[32]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(wt,{}),e[32]=C):C=e[32];let S;e[33]!==s?(S=s("chat.agentList.noAgents"),e[33]=s,e[34]=S):S=e[34];let w;e[35]!==s?(w=s("chat.agentList.noAgentsDesc"),e[35]=s,e[36]=w):w=e[36];let M;e[37]!==r?(M=p.jsx(Le,{latency:r}),e[37]=r,e[38]=M):M=e[38];let T;e[39]!==S||e[40]!==w||e[41]!==M?(T=p.jsx(ne,{icon:C,title:S,summary:w,state:"idle",trailing:M}),e[39]=S,e[40]=w,e[41]=M,e[42]=T):T=e[42],m=T;break e}const v=u.slice(0,Cg);c=u.length-v.length;let k;e[43]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(wt,{className:"text-success"}),e[43]=k):k=e[43];let N;e[44]!==r?(N=p.jsx(Le,{latency:r}),e[44]=r,e[45]=N):N=e[45],h=p.jsx(ne,{icon:k,title:u.length===1?s("chat.agentList.oneAgent"):s("chat.agentList.multiAgents",{count:u.length}),state:"idle",trailing:N}),d="mt-2 flex flex-col gap-1.5",f=v.map(VT)}e[2]=r,e[3]=n.output,e[4]=n.state,e[5]=l,e[6]=s,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h,e[12]=m}else c=e[7],u=e[8],d=e[9],f=e[10],h=e[11],m=e[12];if(m!==Symbol.for("react.early_return_sentinel"))return m;let y;e[46]!==c||e[47]!==u||e[48]!==o||e[49]!==i||e[50]!==s?(y=c>0&&p.jsx(wg,{count:u.length,noun:s("chat.agentList.agentsNoun"),onClick:()=>o({to:"/$org/settings/agents",params:{org:i.slug}})}),e[46]=c,e[47]=u,e[48]=o,e[49]=i,e[50]=s,e[51]=y):y=e[51];let g;e[52]!==d||e[53]!==f||e[54]!==y?(g=p.jsxs("div",{className:d,children:[f,y]}),e[52]=d,e[53]=f,e[54]=y,e[55]=g):g=e[55];let x;return e[56]!==h||e[57]!==g?(x=p.jsxs(p.Fragment,{children:[h,g]}),e[56]=h,e[57]=g,e[58]=x):x=e[58],x}function VT(t){return p.jsx(FT,{agent:t},t.id)}const UT={active:"bg-success",inactive:"bg-muted-foreground",error:"bg-destructive"};function qT(t){const e=_.c(27),{connection:n}=t,r=ml(),{org:s}=xt(),o=n.slug,i=n.description||n.app_name,a=!o||void 0;let l;e[0]!==r||e[1]!==s||e[2]!==o?(l=()=>o&&r({to:"/$org/settings/connections/$appSlug",params:{org:s.slug,appSlug:o}}),e[0]=r,e[1]=s,e[2]=o,e[3]=l):l=e[3];let c;e[4]!==n.icon||e[5]!==n.title?(c=p.jsx(Kn,{icon:n.icon,name:n.title,size:"sm"}),e[4]=n.icon,e[5]=n.title,e[6]=c):c=e[6];let u;e[7]!==n.title?(u=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:n.title}),e[7]=n.title,e[8]=u):u=e[8];let d;e[9]!==i?(d=i&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=d):d=e[10];let f;e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13];const h=UT[n.status]??"bg-muted-foreground";let m;e[14]!==h?(m=G("size-2 shrink-0 rounded-full",h),e[14]=h,e[15]=m):m=e[15];let y;e[16]!==m?(y=p.jsx("span",{className:m,"aria-hidden":"true"}),e[16]=m,e[17]=y):y=e[17];let g;e[18]!==n.status?(g=p.jsx("span",{className:"sr-only",children:n.status}),e[18]=n.status,e[19]=g):g=e[19];let x;return e[20]!==a||e[21]!==g||e[22]!==l||e[23]!==c||e[24]!==f||e[25]!==y?(x=p.jsxs("button",{type:"button","aria-disabled":a,onClick:l,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer aria-disabled:cursor-default aria-disabled:hover:bg-card",children:[c,f,y,g]}),e[20]=a,e[21]=g,e[22]=l,e[23]=c,e[24]=f,e[25]=y,e[26]=x):x=e[26],x}function KT(t){const e=_.c(54),{part:n,latency:r}=t,s=J(),o=ml(),{org:i}=xt();let a;e[0]!==n.state?(a=It(n.state),e[0]=n.state,e[1]=a):a=e[1];const l=a;let c,u,d,f,h,m;if(e[2]!==r||e[3]!==n.output||e[4]!==n.state||e[5]!==l||e[6]!==s){m=Symbol.for("react.early_return_sentinel");e:{const b=Nr(n.output);if(u=(Array.isArray(b?.items)?b.items:[]).filter(YT),l==="loading"||l==="approval"){let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Ls,{className:"animate-pulse"}),e[13]=C):C=e[13];let S;e[14]!==s?(S=s("chat.connectionList.loadingTitle"),e[14]=s,e[15]=S):S=e[15];let w;e[16]!==S?(w=p.jsx(ne,{icon:C,title:S,state:"loading"}),e[16]=S,e[17]=w):w=e[17],m=w;break e}if(l==="error"){let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Ls,{}),e[18]=C):C=e[18];let S;e[19]!==n.state||e[20]!==s?(S=n.state==="output-denied"?s("chat.connectionList.unavailableTitle"):s("chat.connectionList.errorTitle"),e[19]=n.state,e[20]=s,e[21]=S):S=e[21];let w;e[22]!==r?(w=p.jsx(Le,{latency:r}),e[22]=r,e[23]=w):w=e[23];let M;e[24]!==S||e[25]!==w?(M=p.jsx(ne,{icon:C,title:S,state:"error",trailing:w}),e[24]=S,e[25]=w,e[26]=M):M=e[26],m=M;break e}if(u.length===0){let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Ls,{}),e[27]=C):C=e[27];let S;e[28]!==s?(S=s("chat.connectionList.emptyTitle"),e[28]=s,e[29]=S):S=e[29];let w;e[30]!==s?(w=s("chat.connectionList.emptySummary"),e[30]=s,e[31]=w):w=e[31];let M;e[32]!==r?(M=p.jsx(Le,{latency:r}),e[32]=r,e[33]=M):M=e[33];let T;e[34]!==S||e[35]!==w||e[36]!==M?(T=p.jsx(ne,{icon:C,title:S,summary:w,state:"idle",trailing:M}),e[34]=S,e[35]=w,e[36]=M,e[37]=T):T=e[37],m=T;break e}const v=u.slice(0,Cg);c=u.length-v.length;let k;e[38]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Ls,{className:"text-success"}),e[38]=k):k=e[38];let N;e[39]!==r?(N=p.jsx(Le,{latency:r}),e[39]=r,e[40]=N):N=e[40],h=p.jsx(ne,{icon:k,title:u.length===1?s("chat.connectionList.singleConnection"):s("chat.connectionList.multipleConnections",{count:u.length}),state:"idle",trailing:N}),d="mt-2 flex flex-col gap-1.5",f=v.map(JT)}e[2]=r,e[3]=n.output,e[4]=n.state,e[5]=l,e[6]=s,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h,e[12]=m}else c=e[7],u=e[8],d=e[9],f=e[10],h=e[11],m=e[12];if(m!==Symbol.for("react.early_return_sentinel"))return m;let y;e[41]!==c||e[42]!==u||e[43]!==o||e[44]!==i||e[45]!==s?(y=c>0&&p.jsx(wg,{count:u.length,noun:s("chat.connectionList.connectionNoun"),onClick:()=>o({to:"/$org/settings/connections",params:{org:i.slug}})}),e[41]=c,e[42]=u,e[43]=o,e[44]=i,e[45]=s,e[46]=y):y=e[46];let g;e[47]!==d||e[48]!==f||e[49]!==y?(g=p.jsxs("div",{className:d,children:[f,y]}),e[47]=d,e[48]=f,e[49]=y,e[50]=g):g=e[50];let x;return e[51]!==h||e[52]!==g?(x=p.jsxs(p.Fragment,{children:[h,g]}),e[51]=h,e[52]=g,e[53]=x):x=e[53],x}function JT(t){return p.jsx(qT,{connection:t},t.id)}function YT(t){return t.connection_type!=="VIRTUAL"}function GT(){const t=_.c(42),e=J(),n=vs(),{sendMessage:r,isStreaming:s,messages:o}=k0(),{org:i}=xt(),a=n?.virtualMcpId,{prompts:l}=I0(i.slug),c=a??null;let u;t[0]!==i.id||t[1]!==i.slug||t[2]!==c?(u={connectionId:c,orgId:i.id,orgSlug:i.slug},t[0]=i.id,t[1]=i.slug,t[2]=c,t[3]=u):u=t[3];const d=gl(u),[f,h]=L.useState(null);if(!a||s||!e0(a)||!o.some(XT))return null;let y;if(t[4]!==l||t[5]!==a){let E;t[7]!==a?(E=j=>j.agentId===a&&j.promptName,t[7]=a,t[8]=E):E=t[8],y=l.find(E),t[4]=l,t[5]=a,t[6]=y}else y=t[6];const g=y;if(!g)return null;let x;t[9]!==d||t[10]!==r||t[11]!==e?(x=async(E,j)=>{if(!d){fa.error(e("chat.nextActionChip.mcpClientNotAvailable"));return}try{const I=await j0(d,E.name,j);await r({type:"doc",content:[{type:"paragraph",content:[um({id:E.name,name:Nl(E.name,wl(E._meta)),metadata:I.messages,char:"/",kind:"prompt",args:j}),{type:"text",text:" "}]}]})}catch(I){console.error("[next-action-chip] failed",I),fa.error(e("chat.nextActionChip.failedLoadPrompt"))}},t[9]=d,t[10]=r,t[11]=e,t[12]=x):x=t[12];const b=x;let v;t[13]!==g._meta||t[14]!==g.arguments||t[15]!==g.description||t[16]!==g.promptName||t[17]!==g.title||t[18]!==b?(v=()=>{const E={name:g.promptName,title:g.title,description:g.description,arguments:g.arguments,_meta:g._meta};if(E.arguments&&E.arguments.length>0){h(E);return}b(E)},t[13]=g._meta,t[14]=g.arguments,t[15]=g.description,t[16]=g.promptName,t[17]=g.title,t[18]=b,t[19]=v):v=t[19];const k=v;let N;t[20]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx(U1,{size:12,className:"shrink-0 text-purple-500"}),t[20]=N):N=t[20];let C;t[21]!==e?(C=e("chat.nextActionChip.next"),t[21]=e,t[22]=C):C=t[22];let S;t[23]!==C?(S=p.jsx("span",{className:"font-medium text-foreground/80",children:C}),t[23]=C,t[24]=S):S=t[24];let w;t[25]!==g.title?(w=p.jsx("span",{className:"truncate",children:g.title}),t[25]=g.title,t[26]=w):w=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M=p.jsx(Pf,{size:12,className:"shrink-0 transition-transform duration-150 group-hover:translate-x-0.5"}),t[27]=M):M=t[27];let T;t[28]!==k||t[29]!==S||t[30]!==w?(T=p.jsxs("button",{type:"button",onClick:k,className:"group mt-3 flex items-center gap-2 self-start rounded-full border border-border bg-background px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-border hover:bg-accent/40 hover:text-foreground",children:[N,S,w,M]}),t[28]=k,t[29]=S,t[30]=w,t[31]=T):T=t[31];let O;t[32]===Symbol.for("react.memo_cache_sentinel")?(O=E=>h(E),t[32]=O):O=t[32];let A;t[33]!==f||t[34]!==b?(A=async E=>{const j=f;h(null),j&&await b(j,E)},t[33]=f,t[34]=b,t[35]=A):A=t[35];let P;t[36]!==f||t[37]!==A?(P=p.jsx(ay,{prompt:f,setPrompt:O,onSubmit:A}),t[36]=f,t[37]=A,t[38]=P):P=t[38];let D;return t[39]!==T||t[40]!==P?(D=p.jsxs(p.Fragment,{children:[T,P]}),t[39]=T,t[40]=P,t[41]=D):D=t[41],D}function XT(t){return t.role==="user"||t.parts.some(QT)}function QT(t){return t.type==="tool-user_ask"&&t.state==="output-available"}function ZT(t){const e=new Map;for(let n=t.length-1;n>=0;n--){const r=t[n]?.parts;if(r)for(const s of r){const o=s;if(o.type!=="data-deck-updated")continue;const i=o.data;if(!i?.path)continue;const a=`deck:${i.path}`;e.has(a)||e.set(a,{tabId:I1(i.path),label:i.name||i.path,kind:i.kind==="page"?"page":"deck"})}}return Array.from(e.values())}function e3(){const t=_.c(9),{openPanel:e}=kl(),n=wr()?.messages??[],r=ZT(n);if(r.length===0)return null;const s=r.some(n3),o=r.some(t3),i=s?o?"Slides & pages in this chat":"Slides in this chat":"Pages in this chat",a="flex flex-col gap-1.5 py-2";let l;t[0]!==i?(l=p.jsx("div",{className:"text-[12px] text-muted-foreground/70 uppercase tracking-wide",children:i}),t[0]=i,t[1]=l):l=t[1];const c="flex flex-wrap gap-2";let u;t[2]!==e?(u=m=>p.jsxs("button",{type:"button",onClick:()=>e(m.tabId),className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-muted/30 hover:bg-muted/60 text-[13px] transition-colors",children:[m.kind==="deck"?p.jsx(K0,{className:"size-3.5 shrink-0 text-muted-foreground"}):p.jsx(q0,{className:"size-3.5 shrink-0 text-muted-foreground"}),p.jsx("span",{className:"font-medium text-foreground",children:m.label})]},m.tabId),t[2]=e,t[3]=u):u=t[3];const d=r.map(u);let f;t[4]!==d?(f=p.jsx("div",{className:c,children:d}),t[4]=d,t[5]=f):f=t[5];let h;return t[6]!==l||t[7]!==f?(h=p.jsxs("div",{className:a,children:[l,f]}),t[6]=l,t[7]=f,t[8]=h):h=t[8],h}function t3(t){return t.kind==="page"}function n3(t){return t.kind==="deck"}async function r3(t,e){const n=await fetch(`/api/${e}/threads/${encodeURIComponent(t)}/outputs`,{credentials:"include"});if(!n.ok)throw new Error(`Failed to fetch thread outputs: ${n.status}`);return(await n.json()).objects??[]}function mA(){const t=_.c(2),e=wr()?.messages??[];let n;return t[0]!==e?(n=e.some(s3),t[0]=e,t[1]=n):n=t[1],n}function s3(t){return t.parts?.some(o3)}function o3(t){const e=t;return(e.type==="tool-bash"||e.type==="tool-write")&&e.state==="output-available"}function i3(t,e){const n=_.c(9),{org:r}=xt();let s;n[0]!==t?(s=ht.threadOutputs(t??""),n[0]=t,n[1]=s):s=n[1];let o;n[2]!==r||n[3]!==t?(o=()=>r3(t??"",r.slug),n[2]=r,n[3]=t,n[4]=o):o=n[4];const i=!!t&&(e?.enabled??!0);let a;return n[5]!==s||n[6]!==o||n[7]!==i?(a={queryKey:s,queryFn:o,enabled:i,staleTime:0},n[5]=s,n[6]=o,n[7]=i,n[8]=a):a=n[8],ni(a)}function a3(t){const e=_.c(29),{file:n}=t,r=J(),{openPanel:s}=kl();let o;e[0]!==n.key||e[1]!==s?(o=()=>s(j1(n.key)),e[0]=n.key,e[1]=s,e[2]=o):o=e[2];const i=o;let a;e[3]!==n.filename?(a=p.jsx(Y0,{filename:n.filename,className:"h-5 w-4 shrink-0"}),e[3]=n.filename,e[4]=a):a=e[4];let l;e[5]!==n.filename||e[6]!==i?(l=p.jsx("button",{type:"button",onClick:i,className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-foreground hover:underline",title:n.filename,children:n.filename}),e[5]=n.filename,e[6]=i,e[7]=l):l=e[7];const c=n.downloadUrl,u=n.filename;let d;e[8]!==r?(d=r("chat.outputFileRow.download"),e[8]=r,e[9]=d):d=e[9];let f;e[10]!==n.filename||e[11]!==r?(f=r("chat.outputFileRow.downloadFile",{filename:n.filename}),e[10]=n.filename,e[11]=r,e[12]=f):f=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(J0,{className:"size-3.5"}),e[13]=h):h=e[13];let m;e[14]!==n.downloadUrl||e[15]!==n.filename||e[16]!==d||e[17]!==f?(m=p.jsx("a",{href:c,download:u,className:"hidden shrink-0 text-muted-foreground hover:text-foreground group-hover:block",title:d,"aria-label":f,children:h}),e[14]=n.downloadUrl,e[15]=n.filename,e[16]=d,e[17]=f,e[18]=m):m=e[18];let y;e[19]!==r?(y=r("chat.outputFileRow.open"),e[19]=r,e[20]=y):y=e[20];let g;e[21]!==i||e[22]!==y?(g=p.jsx(Ln,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:i,children:y}),e[21]=i,e[22]=y,e[23]=g):g=e[23];let x;return e[24]!==g||e[25]!==a||e[26]!==l||e[27]!==m?(x=p.jsxs("div",{className:"group flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2",children:[a,l,m,g]}),e[24]=g,e[25]=a,e[26]=l,e[27]=m,e[28]=x):x=e[28],x}function l3(t){return t.split("/").pop()??t}const c3=/(^|\/)output\//;function u3(t){const e=new Set;for(const n of t.parts??[]){const r=n;if(r.state==="output-available"&&r.type==="tool-write"){const s=r.input?.path;s&&c3.test(s)&&e.add(l3(s))}}return e}function d3(t){const e=_.c(4),{threadId:n,message:r}=t,s=u3(r),o=s.size>0;let i;e[0]!==o?(i={enabled:o},e[0]=o,e[1]=i):i=e[1];const{data:a}=i3(n,i);if(s.size===0)return null;const l=(a??[]).filter(f=>s.has(f.filename));if(l.length===0)return null;const c="flex flex-col gap-1.5 py-2",u=l.map(f3);let d;return e[2]!==u?(d=p.jsx("div",{className:c,children:u}),e[2]=u,e[3]=d):d=e[3],d}function f3(t){return p.jsx(a3,{file:t},t.key)}function h3(t){return t.type==="reasoning"}function p3(t){const e=[],n=new Set,r=new Map,s=new Map,o=new Map;if(t){let a=null;for(let l=0;l<t.parts.length;l++){const c=t.parts[l];if(h3(c)){a||(a={parts:[],startIndex:l},e.push(a)),a.parts.push(c),n.add(l);continue}if(a=null,c.type==="data-tool-metadata"&&"id"in c&&"data"in c){const u=c.data,d={};u.annotations&&(d.annotations=u.annotations),typeof u.latencyMs=="number"&&Number.isFinite(u.latencyMs)&&(d.latencySeconds=u.latencyMs/1e3),typeof u.outputBytes=="number"&&Number.isFinite(u.outputBytes)&&u.outputBytes>=0&&(d.outputBytes=u.outputBytes),u._meta&&typeof u._meta=="object"&&(d._meta=u._meta),r.set(c.id,d);continue}if(c.type==="data-tool-subtask-metadata"&&"id"in c){s.set(c.id,c.data);continue}if(c.type==="data-web-search"&&"id"in c&&"data"in c){const u=c.id,d=c.data;o.set(u,d.text??"");continue}}}const i=[];if(t)for(let a=0;a<t.parts.length;a++){const l=t.parts[a];if(l.type!=="step-start"){if(n.has(a)){const c=e.find(u=>u.startIndex===a);c&&i.push({kind:"reasoning-group",group:c});continue}l.type.startsWith("data-")||i.push({kind:"part",index:a})}}return{reasoningGroups:e,renderOrder:i,dataParts:{toolMetadata:r,toolSubtaskMetadata:s,webSearchStreaming:o}}}const m3=3;function g3(t,e){let n=-1;for(let r=t.length-1;r>=0;r--){const s=t[r];if(s.kind==="part"&&e[s.index]?.type==="text"){n=r;break}}return n===-1?{collapsed:[],tail:t}:{collapsed:t.slice(0,n),tail:t.slice(n)}}function y3(t,e){let n=0,r=0;for(const s of t)if(s.kind==="reasoning-group")r++;else{const o=e[s.index]?.type;o==="text"?r++:(o==="dynamic-tool"||o?.startsWith("tool-"))&&o!=="tool-todo_write"&&o!=="tool-update_interests"&&n++}return{toolCalls:n,messages:r}}function x3(t){const e=_.c(10),{toolCalls:n,messages:r}=t,s=J();let o;e[0]!==r||e[1]!==s||e[2]!==n?(o=n>0&&p.jsxs(p.Fragment,{children:[p.jsx(jf,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[s("chat.assistant.toolCallPlural",{count:n}),r>0?",":""]})]}),e[0]=r,e[1]=s,e[2]=n,e[3]=o):o=e[3];let i;e[4]!==r||e[5]!==s?(i=r>0&&p.jsxs(p.Fragment,{children:[p.jsx(q1,{className:"size-3.5 shrink-0"}),p.jsx("span",{children:s("chat.assistant.messagePlural",{count:r})})]}),e[4]=r,e[5]=s,e[6]=i):i=e[6];let a;return e[7]!==o||e[8]!==i?(a=p.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[o,i]}),e[7]=o,e[8]=i,e[9]=a):a=e[9],a}function b3(t){const e=_.c(28),{items:n,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:a,isLoading:l,isLast:c}=t;let u;e[0]!==n||e[1]!==r.parts?(u=y3(n,r.parts),e[0]=n,e[1]=r.parts,e[2]=u):u=e[2];const{toolCalls:d,messages:f}=u;if(d===0&&f===0)return null;let h;e[3]!==f||e[4]!==d?(h=p.jsx(x3,{toolCalls:d,messages:f}),e[3]=f,e[4]=d,e[5]=h):h=e[5];let m;if(e[6]!==a||e[7]!==c||e[8]!==l||e[9]!==o||e[10]!==n||e[11]!==r||e[12]!==s||e[13]!==i){let x;e[15]!==a||e[16]!==c||e[17]!==l||e[18]!==o||e[19]!==r||e[20]!==s||e[21]!==i?(x=(b,v)=>Hg({item:b,renderIndex:v,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:a,isLoading:l,isLast:c,isLastVisiblePart:!1}),e[15]=a,e[16]=c,e[17]=l,e[18]=o,e[19]=r,e[20]=s,e[21]=i,e[22]=x):x=e[22],m=n.map(x),e[6]=a,e[7]=c,e[8]=l,e[9]=o,e[10]=n,e[11]=r,e[12]=s,e[13]=i,e[14]=m}else m=e[14];let y;e[23]!==m?(y=p.jsx("div",{className:"flex flex-col gap-3 sm:gap-2 pt-1",children:m}),e[23]=m,e[24]=y):y=e[24];let g;return e[25]!==h||e[26]!==y?(g=p.jsx(ne,{icon:null,alwaysChevron:!0,title:h,state:"idle",children:y}),e[25]=h,e[26]=y,e[27]=g):g=e[27],g}function Hg({item:t,renderIndex:e,message:n,reasoningGroups:r,isReasoningActive:s,totalDuration:o,dataParts:i,isLoading:a,isLast:l,isLastVisiblePart:c,renderOrder:u}){if(t.kind==="reasoning-group"){const{group:m}=t,y=m===r[r.length-1],g=s&&y;if(!m.parts.some(v=>v.text?.trim())&&!g)return null;const b=r.length===1?o:null;return p.jsx(wM,{duration:b,parts:m.parts,isStreaming:g},`${n.id}-reasoning-${m.startIndex}`)}const d=n.parts[t.index],f=c||(u?u.findLastIndex(m=>m.kind==="part")===e:!1),h=f?Wf(Hf(),n.metadata?.usage):null;return p.jsx(v3,{part:d,id:n.id,usageStats:f&&p.jsx(iM,{usage:h,duration:o}),dataParts:i,isLoading:a,isLastMessage:l},`${n.id}-${t.index}`)}function v3(t){const e=_.c(115),{part:n,id:r,usageStats:s,dataParts:o,isLoading:i,isLastMessage:a}=t;let l;e[0]!==o.toolMetadata?(l=f=>o.toolMetadata.get(f),e[0]=o.toolMetadata,e[1]=l):l=e[1];const c=l;let u;e[2]!==o.toolSubtaskMetadata?(u=f=>o.toolSubtaskMetadata.get(f),e[2]=o.toolSubtaskMetadata,e[3]=u):u=e[3];const d=u;switch(n.type){case"dynamic-tool":{let f;e[4]!==c||e[5]!==n.toolCallId?(f=c(n.toolCallId)?.annotations,e[4]=c,e[5]=n.toolCallId,e[6]=f):f=e[6];let h;e[7]!==c||e[8]!==n.toolCallId?(h=c(n.toolCallId)?.latencySeconds,e[7]=c,e[8]=n.toolCallId,e[9]=h):h=e[9];let m;e[10]!==c||e[11]!==n.toolCallId?(m=c(n.toolCallId)?.outputBytes,e[10]=c,e[11]=n.toolCallId,e[12]=m):m=e[12];let y;e[13]!==c||e[14]!==n.toolCallId?(y=c(n.toolCallId)?._meta,e[13]=c,e[14]=n.toolCallId,e[15]=y):y=e[15];let g;return e[16]!==a||e[17]!==n||e[18]!==f||e[19]!==h||e[20]!==m||e[21]!==y?(g=p.jsx(Gd,{part:n,annotations:f,latency:h,outputBytes:m,isLastMessage:a,toolMeta:y}),e[16]=a,e[17]=n,e[18]=f,e[19]=h,e[20]=m,e[21]=y,e[22]=g):g=e[22],g}case"tool-todo_write":return null;case"tool-update_interests":return null;case"tool-user_ask":{let f;e[23]!==c||e[24]!==n.toolCallId?(f=c(n.toolCallId)?.latencySeconds,e[23]=c,e[24]=n.toolCallId,e[25]=f):f=e[25];let h;return e[26]!==n||e[27]!==f?(h=p.jsx(pT,{part:n,latency:f}),e[26]=n,e[27]=f,e[28]=h):h=e[28],h}case"tool-propose_plan":{let f;return e[29]!==n?(f=p.jsx(MT,{part:n}),e[29]=n,e[30]=f):f=e[30],f}case"tool-generate_image":{let f;e[31]!==c||e[32]!==n.toolCallId?(f=c(n.toolCallId)?.latencySeconds,e[31]=c,e[32]=n.toolCallId,e[33]=f):f=e[33];let h;return e[34]!==n||e[35]!==f?(h=p.jsx(tT,{part:n,latency:f}),e[34]=n,e[35]=f,e[36]=h):h=e[36],h}case"tool-web_search":case"tool-deep_research":{let f;e[37]!==c||e[38]!==n.toolCallId?(f=c(n.toolCallId)?.latencySeconds,e[37]=c,e[38]=n.toolCallId,e[39]=f):f=e[39];let h;e[40]!==o.webSearchStreaming||e[41]!==n.toolCallId?(h=o.webSearchStreaming.get(n.toolCallId),e[40]=o.webSearchStreaming,e[41]=n.toolCallId,e[42]=h):h=e[42];let m;return e[43]!==n||e[44]!==f||e[45]!==h?(m=p.jsx(hT,{part:n,latency:f,streamingText:h}),e[43]=n,e[44]=f,e[45]=h,e[46]=m):m=e[46],m}case"tool-subtask":{let f;e[47]!==d||e[48]!==n.toolCallId?(f=d(n.toolCallId),e[47]=d,e[48]=n.toolCallId,e[49]=f):f=e[49];let h;e[50]!==c||e[51]!==n.toolCallId?(h=c(n.toolCallId)?.annotations,e[50]=c,e[51]=n.toolCallId,e[52]=h):h=e[52];let m;e[53]!==c||e[54]!==n.toolCallId?(m=c(n.toolCallId)?.latencySeconds,e[53]=c,e[54]=n.toolCallId,e[55]=m):m=e[55];let y;e[56]!==n||e[57]!==f||e[58]!==h||e[59]!==m?(y={part:n,subtaskMeta:f,annotations:h,latency:m},e[56]=n,e[57]=f,e[58]=h,e[59]=m,e[60]=y):y=e[60];const g=y;let x;return e[61]!==g?(x=p.jsx(L.Suspense,{fallback:p.jsx(wT,{...g}),children:p.jsx(NT,{...g})}),e[61]=g,e[62]=x):x=e[62],x}case"text":{const f=!!s&&!i,h=i&&a;let m;return e[63]!==r||e[64]!==n||e[65]!==f||e[66]!==h||e[67]!==s?(m=p.jsx(gi,{id:r,part:n,extraActions:s,copyable:!0,alwaysShowActions:f,animate:h}),e[63]=r,e[64]=n,e[65]=f,e[66]=h,e[67]=s,e[68]=m):m=e[68],m}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;case"data-tool-metadata":case"data-tool-subtask-metadata":case"data-generate-image":case"data-web-search":return null;default:{const f=n;if(f.type==="tool-brand_context_setup"||f.type==="tool-BRAND_CONTEXT_EXTRACT"){let h;e[69]!==f.toolCallId||e[70]!==c?(h=c(f.toolCallId)?.latencySeconds,e[69]=f.toolCallId,e[70]=c,e[71]=h):h=e[71];let m;return e[72]!==f||e[73]!==h?(m=p.jsx(RT,{part:f,latency:h}),e[72]=f,e[73]=h,e[74]=m):m=e[74],m}if(f.type==="tool-BRAND_CONTEXT_GET"){let h;e[75]!==f.toolCallId||e[76]!==c?(h=c(f.toolCallId)?.latencySeconds,e[75]=f.toolCallId,e[76]=c,e[77]=h):h=e[77];let m;return e[78]!==f||e[79]!==h?(m=p.jsx(PT,{part:f,latency:h}),e[78]=f,e[79]=h,e[80]=m):m=e[80],m}if(f.type==="tool-BRAND_CONTEXT_LIST"){let h;e[81]!==f.toolCallId||e[82]!==c?(h=c(f.toolCallId)?.latencySeconds,e[81]=f.toolCallId,e[82]=c,e[83]=h):h=e[83];let m;return e[84]!==f||e[85]!==h?(m=p.jsx(LT,{part:f,latency:h}),e[84]=f,e[85]=h,e[86]=m):m=e[86],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_CREATE"){let h;e[87]!==f.toolCallId||e[88]!==c?(h=c(f.toolCallId)?.latencySeconds,e[87]=f.toolCallId,e[88]=c,e[89]=h):h=e[89];let m;return e[90]!==f||e[91]!==h?(m=p.jsx(BT,{part:f,latency:h}),e[90]=f,e[91]=h,e[92]=m):m=e[92],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_LIST"){let h;e[93]!==f.toolCallId||e[94]!==c?(h=c(f.toolCallId)?.latencySeconds,e[93]=f.toolCallId,e[94]=c,e[95]=h):h=e[95];let m;return e[96]!==f||e[97]!==h?(m=p.jsx(WT,{part:f,latency:h}),e[96]=f,e[97]=h,e[98]=m):m=e[98],m}if(f.type==="tool-COLLECTION_CONNECTIONS_LIST"){let h;e[99]!==f.toolCallId||e[100]!==c?(h=c(f.toolCallId)?.latencySeconds,e[99]=f.toolCallId,e[100]=c,e[101]=h):h=e[101];let m;return e[102]!==f||e[103]!==h?(m=p.jsx(KT,{part:f,latency:h}),e[102]=f,e[103]=h,e[104]=m):m=e[104],m}if(f.type.startsWith("tool-")){const h=f.toolCallId;let m;e[105]!==o.toolMetadata||e[106]!==h?(m=o.toolMetadata.get(h),e[105]=o.toolMetadata,e[106]=h,e[107]=m):m=e[107];const y=m,g=y?.annotations,x=y?.latencySeconds,b=y?.outputBytes,v=y?._meta;let k;return e[108]!==f||e[109]!==a||e[110]!==g||e[111]!==x||e[112]!==b||e[113]!==v?(k=p.jsx(Gd,{part:f,annotations:g,latency:x,outputBytes:b,isLastMessage:a,toolMeta:v}),e[108]=f,e[109]=a,e[110]=g,e[111]=x,e[112]=b,e[113]=v,e[114]=k):k=e[114],k}if(f.type.startsWith("data-"))return null;throw new Error(`Unknown part type: ${f.type}`)}}}function k3(t){const e=_.c(9),{isRunInProgress:n}=t,r=J();if(n){let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(ri,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),e[0]=i):i=e[0];let a;e[1]!==r?(a=r("chat.assistant.resumingTask"),e[1]=r,e[2]=a):a=e[2];let l;return e[3]!==a?(l=p.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:p.jsxs("span",{className:"flex items-center gap-1.5",children:[i,p.jsx("span",{className:"text-[14px] text-muted-foreground shimmer",children:a})]})}),e[3]=a,e[4]=l):l=e[4],l}let s;e[5]!==r?(s=r("chat.assistant.noResponseGenerated"),e[5]=r,e[6]=s):s=e[6];let o;return e[7]!==s?(o=p.jsx("div",{className:"text-[14px] text-muted-foreground/60 py-2",children:s}),e[7]=s,e[8]=o):o=e[8],o}function S3(t){const e=_.c(7),{className:n,children:r}=t;let s;e[0]!==n?(s=G("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",n),e[0]=n,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:p.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[14px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:r})}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function C3(t){const e=_.c(32),{message:n,turnStartedAt:r,status:s,className:o,isLast:i}=t,a=i===void 0?!1:i,l=J(),{isRunInProgress:c}=wr()??{},u=c===void 0?!1:c,d=vs()?.taskId??null,f=s==="streaming",m=f||s==="submitted";let y;e[0]!==r?(y=bl(r),e[0]=r,e[1]=y):y=e[1];const g=y;let x;e[2]!==m?(x=()=>m?Date.now():null,e[2]=m,e[3]=x):x=e[3];const[b,v]=L.useState(x),[k,N]=L.useState(m);k!==m&&(N(m),v(m?Date.now():null));const C=g??b,{reasoningGroups:S,renderOrder:w,dataParts:M}=p3(n),T=n!==null&&w.length>0,O=n&&n.parts.length>0?n.parts[n.parts.length-1]:null,A=f&&O?.type==="reasoning";let P;if(e[4]!==n){const W=n?.metadata?.reasoning_start_at?new Date(n.metadata.reasoning_start_at):null,q=n?.metadata?.reasoning_end_at?new Date(n.metadata.reasoning_end_at):new Date;P=W!==null?q.getTime()-W.getTime():null,e[4]=n,e[5]=P}else P=e[5];const D=P;let E;e[6]!==a||e[7]!==n?(E=!a||!n||!n.parts.some(N3),e[6]=a,e[7]=n,e[8]=E):E=e[8];const j=E;let I;e[9]!==T||e[10]!==m||e[11]!==j||e[12]!==n||e[13]!==w?(I=!m&&T&&j&&(()=>{let W=0;for(const q of w)if(q.kind==="part"){const X=n.parts[q.index]?.type;(X==="dynamic-tool"||X?.startsWith("tool-"))&&W++}return W>=m3})(),e[9]=T,e[10]=m,e[11]=j,e[12]=n,e[13]=w,e[14]=I):I=e[14];const R=I;let z;if(e[15]!==o||e[16]!==M||e[17]!==T||e[18]!==a||e[19]!==m||e[20]!==A||e[21]!==u||e[22]!==j||e[23]!==n||e[24]!==S||e[25]!==w||e[26]!==R||e[27]!==C||e[28]!==l||e[29]!==d||e[30]!==D){const{collapsed:W,tail:q}=R?g3(w,n.parts):{collapsed:[],tail:w};z=p.jsx(S3,{className:o,children:T?p.jsxs("div",{className:"flex flex-col gap-3 sm:gap-2",children:[n.metadata?.resumedFromBackground&&p.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-muted-foreground/60 select-none",children:[p.jsx(xf,{className:"size-3 shrink-0"}),p.jsx("span",{children:l("chat.assistant.resumedBackgroundTask")})]}),W.length>0&&p.jsx(b3,{items:W,message:n,reasoningGroups:S,isReasoningActive:A,totalDuration:D,dataParts:M,isLoading:m,isLast:a}),q.map((X,te)=>{const ae=W.length+te,fe=q.findLastIndex(w3)===te;return Hg({item:X,renderIndex:ae,message:n,reasoningGroups:S,isReasoningActive:A,totalDuration:D,dataParts:M,isLoading:m,isLast:a,isLastVisiblePart:fe,renderOrder:w})}),d&&p.jsx(d3,{threadId:d,message:n}),a&&m&&C!==null&&p.jsx(kM,{startedAt:C}),a&&!m&&d&&p.jsxs(p.Fragment,{children:[p.jsx(e3,{}),j&&p.jsx(GT,{})]}),!m&&p.jsx(Ng,{message:n})]}):m?p.jsx(CM,{startedAt:C}):p.jsx(k3,{isRunInProgress:a&&u})}),e[15]=o,e[16]=M,e[17]=T,e[18]=a,e[19]=m,e[20]=A,e[21]=u,e[22]=j,e[23]=n,e[24]=S,e[25]=w,e[26]=R,e[27]=C,e[28]=l,e[29]=d,e[30]=D,e[31]=z}else z=e[31];return z}function w3(t){return t.kind==="part"}function N3(t){const e=t.type;if(e!=="dynamic-tool"&&!e?.startsWith("tool-"))return!1;const n=t.state;return n==="input-streaming"||n==="input-available"||n==="approval-requested"}function M3(t){const e=_.c(25),{event:n}=t,r=J(),[s,o]=L.useState(!1);let i;e[0]!==n.data?(i=JSON.stringify(n.data,null,2),e[0]=n.data,e[1]=i):i=e[1];const a=i;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>o(T3),e[2]=l):l=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(K1,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=c):c=e[3];let u;e[4]!==r?(u=r("chat.triggerEventPart.triggeredByEvent"),e[4]=r,e[5]=u):u=e[5];let d;e[6]!==u?(d=p.jsx("span",{className:"font-medium",children:u}),e[6]=u,e[7]=d):d=e[7];let f;e[8]!==n.type?(f=p.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:n.type}),e[8]=n.type,e[9]=f):f=e[9];const h=s&&"rotate-180";let m;e[10]!==h?(m=G("ml-auto size-4 shrink-0 text-muted-foreground transition-transform",h),e[10]=h,e[11]=m):m=e[11];let y;e[12]!==m?(y=p.jsx(If,{className:m}),e[12]=m,e[13]=y):y=e[13];let g;e[14]!==d||e[15]!==f||e[16]!==y?(g=p.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-center gap-2 px-3 py-2 text-sm cursor-pointer",children:[c,d,f,y]}),e[14]=d,e[15]=f,e[16]=y,e[17]=g):g=e[17];let x;e[18]!==n.source||e[19]!==s||e[20]!==a?(x=s&&p.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[p.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:n.source}),p.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words text-xs text-foreground",children:a})]}),e[18]=n.source,e[19]=s,e[20]=a,e[21]=x):x=e[21];let b;return e[22]!==g||e[23]!==x?(b=p.jsxs("div",{className:"rounded-lg border border-border/60 bg-background overflow-hidden text-left",children:[g,x]}),e[22]=g,e[23]=x,e[24]=b):b=e[24],b}function T3(t){return!t}const E3=[oM.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),KS,XS];function D3(t){const e=_.c(5),{tiptapDoc:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={attributes:{class:"prose prose-sm max-w-none focus:outline-none"}},e[0]=r):r=e[0];let s;e[1]!==n?(s={extensions:E3,content:n,editable:!1,editorProps:r},e[1]=n,e[2]=s):s=e[2];const o=LS(s);if(!o)return null;let i;return e[3]!==o?(i=p.jsx(nm,{editor:o,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=o,e[4]=i):i=e[4],i}function O3(t){const e=_.c(38),{message:n,className:r,onScrollToPair:s}=t,{id:o,parts:i,metadata:a}=n,[l,c]=L.useState(!1),[u,d]=L.useState(!1),f=L.useRef(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=E=>{E&&!f.current&&(f.current=!0,d(E.scrollHeight>E.clientHeight))},e[0]=h):h=e[0];const m=h;if(!i||i.length===0)return null;let y;e[1]!==s?(y=()=>{c(!0),s?.()},e[1]=s,e[2]=y):y=e[2];const g=y,x=a?.tiptapDoc;let b;e[3]!==r?(b=G("message-block w-full min-w-0 relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[3]=r,e[4]=b):b=e[4];let v,k;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=()=>c(!0),k=()=>c(!1),e[5]=v,e[6]=k):(v=e[5],k=e[6]);let N;e[7]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx("div",{className:"absolute inset-0 bg-muted/75 rounded-lg pointer-events-none"}),e[7]=N):N=e[7];let C;e[8]!==l||e[9]!==u?(C=G("z-10 px-4 py-2 flex-1 transition-[max-height,opacity] duration-300 ease-out",l?"max-h-[50vh] overflow-auto opacity-100":G("max-h-[84px] overflow-hidden opacity-99",u&&"mask-b-from-1%")),e[8]=l,e[9]=u,e[10]=C):C=e[10];let S;if(e[11]!==o||e[12]!==i){let E;e[14]!==o?(E=(j,I)=>j.type==="data-trigger-event"?p.jsx(M3,{event:j.data},`${o}-${I}`):null,e[14]=o,e[15]=E):E=e[15],S=i.map(E),e[11]=o,e[12]=i,e[13]=S}else S=e[13];let w;e[16]!==x||e[17]!==o||e[18]!==a||e[19]!==i?(w=x?p.jsx(D3,{tiptapDoc:a.tiptapDoc}):i.map((E,j)=>E.type==="text"?i[j-1]?.type==="data-trigger-event"?null:p.jsx(gi,{id:o,part:E},`${o}-${j}`):null),e[16]=x,e[17]=o,e[18]=a,e[19]=i,e[20]=w):w=e[20];let M;e[21]!==S||e[22]!==w?(M=p.jsxs("div",{className:"flex flex-col gap-2",children:[S,w]}),e[21]=S,e[22]=w,e[23]=M):M=e[23];let T;e[24]!==M||e[25]!==C?(T=p.jsx("div",{ref:m,className:C,children:M}),e[24]=M,e[25]=C,e[26]=T):T=e[26];let O;e[27]!==g||e[28]!==T?(O=p.jsxs("div",{tabIndex:0,onClick:g,onFocus:v,onBlur:k,className:"w-full border border-border/60 min-w-0 shadow-xs rounded-lg text-[14px] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:[N,T]}),e[27]=g,e[28]=T,e[29]=O):O=e[29];let A;e[30]!==n?(A=p.jsx(Ng,{message:n,className:"mt-1 mr-1 self-end"}),e[30]=n,e[31]=A):A=e[31];let P;e[32]!==O||e[33]!==A?(P=p.jsxs("div",{className:"w-full min-w-0 flex flex-col",children:[O,A]}),e[32]=O,e[33]=A,e[34]=P):P=e[34];let D;return e[35]!==P||e[36]!==b?(D=p.jsx(p.Fragment,{children:p.jsx("div",{className:b,children:P})}),e[35]=P,e[36]=b,e[37]=D):D=e[37],D}function A3(t){const e=[],n=t.filter(r=>r.role!=="system"&&!r.metadata?.internal&&!r.metadata?.subtaskJobId);for(let r=0;r<n.length;r++){const s=n[r];if(s)if(s.role==="user"){const o=n[r+1];o&&o.role==="assistant"?(e.push({user:s,assistant:o}),r++):e.push({user:s,assistant:null})}else s.role==="assistant"&&e.push({user:null,assistant:s})}return e}function I3(t){const e=_.c(19),{pair:n,isLastPair:r,status:s}=t,o=L.useRef(null),i=L.useRef(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{o.current&&o.current.scrollIntoView({behavior:"smooth",block:"start"})},e[0]=a):a=e[0];const l=a;let c;e[1]!==r||e[2]!==n.assistant?.metadata?.resumedFromBackground||e[3]!==s?(c=x=>{if(o.current=x,!r||!x||i.current||(i.current=!0,n.assistant?.metadata?.resumedFromBackground))return;if(s==="submitted"||s==="streaming"){x.scrollIntoView({behavior:"smooth",block:"start"});return}const b=x.closest("[data-chat-scroller]");b?b.scrollTop=b.scrollHeight:x.scrollIntoView({behavior:"instant",block:"start"})},e[1]=r,e[2]=n.assistant?.metadata?.resumedFromBackground,e[3]=s,e[4]=c):c=e[4];const u=c,d=!n.user&&"pt-8 sm:pt-6";let f;e[5]!==d?(f=G("flex flex-col pb-2 sm:pb-2",d),e[5]=d,e[6]=f):f=e[6];let h;e[7]!==n.user?(h=n.user&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"sticky top-0 z-50 w-full h-4 bg-background"}),p.jsx("div",{className:"sticky mb-8 sm:mb-6 top-4 z-50",children:p.jsx(O3,{message:n.user,onScrollToPair:l})})]}),e[7]=n.user,e[8]=h):h=e[8];const m=n.user?.created_at??null;let y;e[9]!==r||e[10]!==n.assistant||e[11]!==s||e[12]!==m?(y=p.jsx(C3,{message:n.assistant,turnStartedAt:m,status:s,isLast:r}),e[9]=r,e[10]=n.assistant,e[11]=s,e[12]=m,e[13]=y):y=e[13];let g;return e[14]!==u||e[15]!==f||e[16]!==h||e[17]!==y?(g=p.jsxs("div",{ref:u,className:f,children:[h,y]}),e[14]=u,e[15]=f,e[16]=h,e[17]=y,e[18]=g):g=e[18],g}function re(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function nt(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function We(t,e){const n=re(t);return isNaN(e)?nt(t,NaN):(e&&n.setDate(n.getDate()+e),n)}function gt(t,e){const n=re(t);if(isNaN(e))return nt(t,NaN);if(!e)return n;const r=n.getDate(),s=nt(t,n.getTime());s.setMonth(n.getMonth()+e+1,0);const o=s.getDate();return r>=o?s:(n.setFullYear(s.getFullYear(),s.getMonth(),r),n)}const Oc=6048e5,j3=864e5;let R3={};function Os(){return R3}function At(t,e){const n=Os(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=re(t),o=s.getDay(),i=(o<r?7:0)+o-r;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function qn(t){return At(t,{weekStartsOn:1})}function Wg(t){const e=re(t),n=e.getFullYear(),r=nt(t,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const s=qn(r),o=nt(t,0);o.setFullYear(n,0,4),o.setHours(0,0,0,0);const i=qn(o);return e.getTime()>=s.getTime()?n+1:e.getTime()>=i.getTime()?n:n-1}function Cr(t){const e=re(t);return e.setHours(0,0,0,0),e}function ei(t){const e=re(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function Tt(t,e){const n=Cr(t),r=Cr(e),s=+n-ei(n),o=+r-ei(r);return Math.round((s-o)/j3)}function P3(t){const e=Wg(t),n=nt(t,0);return n.setFullYear(e,0,4),n.setHours(0,0,0,0),qn(n)}function cl(t,e){const n=e*7;return We(t,n)}function L3(t,e){return gt(t,e*12)}function $3(t){let e;return t.forEach(function(n){const r=re(n);(e===void 0||e<r||isNaN(Number(r)))&&(e=r)}),e||new Date(NaN)}function _3(t){let e;return t.forEach(n=>{const r=re(n);(!e||e>r||isNaN(+r))&&(e=r)}),e||new Date(NaN)}function Ge(t,e){const n=Cr(t),r=Cr(e);return+n==+r}function Ac(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function B3(t){if(!Ac(t)&&typeof t!="number")return!1;const e=re(t);return!isNaN(Number(e))}function bs(t,e){const n=re(t),r=re(e),s=n.getFullYear()-r.getFullYear(),o=n.getMonth()-r.getMonth();return s*12+o}function z3(t,e,n){const r=At(t,n),s=At(e,n),o=+r-ei(r),i=+s-ei(s);return Math.round((o-i)/Oc)}function Ic(t){const e=re(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function Ze(t){const e=re(t);return e.setDate(1),e.setHours(0,0,0,0),e}function Vg(t){const e=re(t),n=nt(t,0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}function jc(t,e){const n=Os(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=re(t),o=s.getDay(),i=(o<r?-7:0)+6-(o-r);return s.setDate(s.getDate()+i),s.setHours(23,59,59,999),s}function Ug(t){return jc(t,{weekStartsOn:1})}const F3={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},H3=(t,e,n)=>{let r;const s=F3[t];return typeof s=="string"?r=s:e===1?r=s.one:r=s.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function oa(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const W3={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},V3={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},U3={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},q3={date:oa({formats:W3,defaultWidth:"full"}),time:oa({formats:V3,defaultWidth:"full"}),dateTime:oa({formats:U3,defaultWidth:"full"})},K3={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},J3=(t,e,n,r)=>K3[t];function Rr(t){return(e,n)=>{const r=n?.context?String(n.context):"standalone";let s;if(r==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,a=n?.width?String(n.width):i;s=t.formattingValues[a]||t.formattingValues[i]}else{const i=t.defaultWidth,a=n?.width?String(n.width):t.defaultWidth;s=t.values[a]||t.values[i]}const o=t.argumentCallback?t.argumentCallback(e):e;return s[o]}}const Y3={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},G3={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},X3={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Q3={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Z3={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},eE={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},tE=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},nE={ordinalNumber:tE,era:Rr({values:Y3,defaultWidth:"wide"}),quarter:Rr({values:G3,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Rr({values:X3,defaultWidth:"wide"}),day:Rr({values:Q3,defaultWidth:"wide"}),dayPeriod:Rr({values:Z3,defaultWidth:"wide",formattingValues:eE,defaultFormattingWidth:"wide"})};function Pr(t){return(e,n={})=>{const r=n.width,s=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],o=e.match(s);if(!o)return null;const i=o[0],a=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(a)?sE(a,d=>d.test(i)):rE(a,d=>d.test(i));let c;c=t.valueCallback?t.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const u=e.slice(i.length);return{value:c,rest:u}}}function rE(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function sE(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function oE(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const s=r[0],o=e.match(t.parsePattern);if(!o)return null;let i=t.valueCallback?t.valueCallback(o[0]):o[0];i=n.valueCallback?n.valueCallback(i):i;const a=e.slice(s.length);return{value:i,rest:a}}}const iE=/^(\d+)(th|st|nd|rd)?/i,aE=/\d+/i,lE={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},cE={any:[/^b/i,/^(a|c)/i]},uE={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},dE={any:[/1/i,/2/i,/3/i,/4/i]},fE={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},hE={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},pE={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},mE={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},gE={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},yE={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},xE={ordinalNumber:oE({matchPattern:iE,parsePattern:aE,valueCallback:t=>parseInt(t,10)}),era:Pr({matchPatterns:lE,defaultMatchWidth:"wide",parsePatterns:cE,defaultParseWidth:"any"}),quarter:Pr({matchPatterns:uE,defaultMatchWidth:"wide",parsePatterns:dE,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Pr({matchPatterns:fE,defaultMatchWidth:"wide",parsePatterns:hE,defaultParseWidth:"any"}),day:Pr({matchPatterns:pE,defaultMatchWidth:"wide",parsePatterns:mE,defaultParseWidth:"any"}),dayPeriod:Pr({matchPatterns:gE,defaultMatchWidth:"any",parsePatterns:yE,defaultParseWidth:"any"})},qg={code:"en-US",formatDistance:H3,formatLong:q3,formatRelative:J3,localize:nE,match:xE,options:{weekStartsOn:0,firstWeekContainsDate:1}};function bE(t){const e=re(t);return Tt(e,Vg(e))+1}function Kg(t){const e=re(t),n=+qn(e)-+P3(e);return Math.round(n/Oc)+1}function Jg(t,e){const n=re(t),r=n.getFullYear(),s=Os(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,i=nt(t,0);i.setFullYear(r+1,0,o),i.setHours(0,0,0,0);const a=At(i,e),l=nt(t,0);l.setFullYear(r,0,o),l.setHours(0,0,0,0);const c=At(l,e);return n.getTime()>=a.getTime()?r+1:n.getTime()>=c.getTime()?r:r-1}function vE(t,e){const n=Os(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=Jg(t,e),o=nt(t,0);return o.setFullYear(s,0,r),o.setHours(0,0,0,0),At(o,e)}function Yg(t,e){const n=re(t),r=+At(n,e)-+vE(n,e);return Math.round(r/Oc)+1}function ie(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const Xt={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return ie(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):ie(n+1,2)},d(t,e){return ie(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,e){return ie(t.getHours()%12||12,e.length)},H(t,e){return ie(t.getHours(),e.length)},m(t,e){return ie(t.getMinutes(),e.length)},s(t,e){return ie(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return ie(s,e.length)}},rr={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},tf={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return Xt.y(t,e)},Y:function(t,e,n,r){const s=Jg(t,r),o=s>0?s:1-s;if(e==="YY"){const i=o%100;return ie(i,2)}return e==="Yo"?n.ordinalNumber(o,{unit:"year"}):ie(o,e.length)},R:function(t,e){const n=Wg(t);return ie(n,e.length)},u:function(t,e){const n=t.getFullYear();return ie(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return ie(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return ie(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return Xt.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return ie(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const s=Yg(t,r);return e==="wo"?n.ordinalNumber(s,{unit:"week"}):ie(s,e.length)},I:function(t,e,n){const r=Kg(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):ie(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):Xt.d(t,e)},D:function(t,e,n){const r=bE(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ie(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const s=t.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(o);case"ee":return ie(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const s=t.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(o);case"cc":return ie(o,e.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),s=r===0?7:r;switch(e){case"i":return String(s);case"ii":return ie(s,e.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const s=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let s;switch(r===12?s=rr.noon:r===0?s=rr.midnight:s=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let s;switch(r>=17?s=rr.evening:r>=12?s=rr.afternoon:r>=4?s=rr.morning:s=rr.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Xt.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):Xt.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ie(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):ie(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):Xt.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):Xt.s(t,e)},S:function(t,e){return Xt.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return rf(r);case"XXXX":case"XX":return vn(r);default:return vn(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return rf(r);case"xxxx":case"xx":return vn(r);default:return vn(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+nf(r,":");default:return"GMT"+vn(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+nf(r,":");default:return"GMT"+vn(r,":")}},t:function(t,e,n){const r=Math.trunc(t.getTime()/1e3);return ie(r,e.length)},T:function(t,e,n){const r=t.getTime();return ie(r,e.length)}};function nf(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),s=Math.trunc(r/60),o=r%60;return o===0?n+String(s):n+String(s)+e+ie(o,2)}function rf(t,e){return t%60===0?(t>0?"-":"+")+ie(Math.abs(t)/60,2):vn(t,e)}function vn(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),s=ie(Math.trunc(r/60),2),o=ie(r%60,2);return n+s+e+o}const sf=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},Gg=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},kE=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return sf(t,e);let o;switch(r){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;default:o=e.dateTime({width:"full"});break}return o.replace("{{date}}",sf(r,e)).replace("{{time}}",Gg(s,e))},SE={p:Gg,P:kE},CE=/^D+$/,wE=/^Y+$/,NE=["D","DD","YY","YYYY"];function ME(t){return CE.test(t)}function TE(t){return wE.test(t)}function EE(t,e,n){const r=DE(t,e,n);if(console.warn(r),NE.includes(t))throw new RangeError(r)}function DE(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const OE=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,AE=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,IE=/^'([^]*?)'?$/,jE=/''/g,RE=/[a-zA-Z]/;function Qn(t,e,n){const r=Os(),s=n?.locale??r.locale??qg,o=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=re(t);if(!B3(a))throw new RangeError("Invalid time value");let l=e.match(AE).map(u=>{const d=u[0];if(d==="p"||d==="P"){const f=SE[d];return f(u,s.formatLong)}return u}).join("").match(OE).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:PE(u)};if(tf[d])return{isToken:!0,value:u};if(d.match(RE))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:u}});s.localize.preprocessor&&(l=s.localize.preprocessor(a,l));const c={firstWeekContainsDate:o,weekStartsOn:i,locale:s};return l.map(u=>{if(!u.isToken)return u.value;const d=u.value;(!n?.useAdditionalWeekYearTokens&&TE(d)||!n?.useAdditionalDayOfYearTokens&&ME(d))&&EE(d,e,String(t));const f=tf[d[0]];return f(a,d,s.localize,c)}).join("")}function PE(t){const e=t.match(IE);return e?e[1].replace(jE,"'"):t}function LE(t){const e=re(t),n=e.getFullYear(),r=e.getMonth(),s=nt(t,0);return s.setFullYear(n,r+1,0),s.setHours(0,0,0,0),s.getDate()}function $E(t){return Math.trunc(+re(t)/1e3)}function _E(t){const e=re(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(0,0,0,0),e}function BE(t,e){return z3(_E(t),Ze(t),e)+1}function ul(t,e){const n=re(t),r=re(e);return n.getTime()>r.getTime()}function Xg(t,e){const n=re(t),r=re(e);return+n<+r}function Rc(t,e){const n=re(t),r=re(e);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function zE(t,e){const n=re(t),r=re(e);return n.getFullYear()===r.getFullYear()}function ia(t,e){return We(t,-e)}function aa(t,e){const n=re(t),r=n.getFullYear(),s=n.getDate(),o=nt(t,0);o.setFullYear(r,e,15),o.setHours(0,0,0,0);const i=LE(o);return n.setMonth(e,Math.min(s,i)),n}function of(t,e){const n=re(t);return isNaN(+n)?nt(t,NaN):(n.setFullYear(e),n)}var K=function(){return K=Object.assign||function(e){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},K.apply(this,arguments)};function FE(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}function Qg(t,e,n){for(var r=0,s=e.length,o;r<s;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function As(t){return t.mode==="multiple"}function Is(t){return t.mode==="range"}function wi(t){return t.mode==="single"}var HE={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function WE(t,e){return Qn(t,"LLLL y",e)}function VE(t,e){return Qn(t,"d",e)}function UE(t,e){return Qn(t,"LLLL",e)}function qE(t){return"".concat(t)}function KE(t,e){return Qn(t,"cccccc",e)}function JE(t,e){return Qn(t,"yyyy",e)}var YE=Object.freeze({__proto__:null,formatCaption:WE,formatDay:VE,formatMonthCaption:UE,formatWeekNumber:qE,formatWeekdayName:KE,formatYearCaption:JE}),GE=function(t,e,n){return Qn(t,"do MMMM (EEEE)",n)},XE=function(){return"Month: "},QE=function(){return"Go to next month"},ZE=function(){return"Go to previous month"},e4=function(t,e){return Qn(t,"cccc",e)},t4=function(t){return"Week n. ".concat(t)},n4=function(){return"Year: "},r4=Object.freeze({__proto__:null,labelDay:GE,labelMonthDropdown:XE,labelNext:QE,labelPrevious:ZE,labelWeekNumber:t4,labelWeekday:e4,labelYearDropdown:n4});function s4(){var t="buttons",e=HE,n=qg,r={},s={},o=1,i={},a=new Date;return{captionLayout:t,classNames:e,formatters:YE,labels:r4,locale:n,modifiersClassNames:r,modifiers:s,numberOfMonths:o,styles:i,today:a,mode:"default"}}function o4(t){var e=t.fromYear,n=t.toYear,r=t.fromMonth,s=t.toMonth,o=t.fromDate,i=t.toDate;return r?o=Ze(r):e&&(o=new Date(e,0,1)),s?i=Ic(s):n&&(i=new Date(n,11,31)),{fromDate:o?Cr(o):void 0,toDate:i?Cr(i):void 0}}var Zg=L.createContext(void 0);function i4(t){var e,n=t.initialProps,r=s4(),s=o4(n),o=s.fromDate,i=s.toDate,a=(e=n.captionLayout)!==null&&e!==void 0?e:r.captionLayout;a!=="buttons"&&(!o||!i)&&(a="buttons");var l;(wi(n)||As(n)||Is(n))&&(l=n.onSelect);var c=K(K(K({},r),n),{captionLayout:a,classNames:K(K({},r.classNames),n.classNames),components:K({},n.components),formatters:K(K({},r.formatters),n.formatters),fromDate:o,labels:K(K({},r.labels),n.labels),mode:n.mode||r.mode,modifiers:K(K({},r.modifiers),n.modifiers),modifiersClassNames:K(K({},r.modifiersClassNames),n.modifiersClassNames),onSelect:l,styles:K(K({},r.styles),n.styles),toDate:i});return p.jsx(Zg.Provider,{value:c,children:t.children})}function de(){var t=L.useContext(Zg);if(!t)throw new Error("useDayPicker must be used within a DayPickerProvider.");return t}function e1(t){var e=de(),n=e.locale,r=e.classNames,s=e.styles,o=e.formatters.formatCaption;return p.jsx("div",{className:r.caption_label,style:s.caption_label,"aria-live":"polite",role:"presentation",id:t.id,children:o(t.displayMonth,{locale:n})})}function a4(t){return p.jsx("svg",K({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},t,{children:p.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function t1(t){var e,n,r=t.onChange,s=t.value,o=t.children,i=t.caption,a=t.className,l=t.style,c=de(),u=(n=(e=c.components)===null||e===void 0?void 0:e.IconDropdown)!==null&&n!==void 0?n:a4;return p.jsxs("div",{className:a,style:l,children:[p.jsx("span",{className:c.classNames.vhidden,children:t["aria-label"]}),p.jsx("select",{name:t.name,"aria-label":t["aria-label"],className:c.classNames.dropdown,style:c.styles.dropdown,value:s,onChange:r,children:o}),p.jsxs("div",{className:c.classNames.caption_label,style:c.styles.caption_label,"aria-hidden":"true",children:[i,p.jsx(u,{className:c.classNames.dropdown_icon,style:c.styles.dropdown_icon})]})]})}function l4(t){var e,n=de(),r=n.fromDate,s=n.toDate,o=n.styles,i=n.locale,a=n.formatters.formatMonthCaption,l=n.classNames,c=n.components,u=n.labels.labelMonthDropdown;if(!r)return p.jsx(p.Fragment,{});if(!s)return p.jsx(p.Fragment,{});var d=[];if(zE(r,s))for(var f=Ze(r),h=r.getMonth();h<=s.getMonth();h++)d.push(aa(f,h));else for(var f=Ze(new Date),h=0;h<=11;h++)d.push(aa(f,h));var m=function(g){var x=Number(g.target.value),b=aa(Ze(t.displayMonth),x);t.onChange(b)},y=(e=c?.Dropdown)!==null&&e!==void 0?e:t1;return p.jsx(y,{name:"months","aria-label":u(),className:l.dropdown_month,style:o.dropdown_month,onChange:m,value:t.displayMonth.getMonth(),caption:a(t.displayMonth,{locale:i}),children:d.map(function(g){return p.jsx("option",{value:g.getMonth(),children:a(g,{locale:i})},g.getMonth())})})}function c4(t){var e,n=t.displayMonth,r=de(),s=r.fromDate,o=r.toDate,i=r.locale,a=r.styles,l=r.classNames,c=r.components,u=r.formatters.formatYearCaption,d=r.labels.labelYearDropdown,f=[];if(!s)return p.jsx(p.Fragment,{});if(!o)return p.jsx(p.Fragment,{});for(var h=s.getFullYear(),m=o.getFullYear(),y=h;y<=m;y++)f.push(of(Vg(new Date),y));var g=function(b){var v=of(Ze(n),Number(b.target.value));t.onChange(v)},x=(e=c?.Dropdown)!==null&&e!==void 0?e:t1;return p.jsx(x,{name:"years","aria-label":d(),className:l.dropdown_year,style:a.dropdown_year,onChange:g,value:n.getFullYear(),caption:u(n,{locale:i}),children:f.map(function(b){return p.jsx("option",{value:b.getFullYear(),children:u(b,{locale:i})},b.getFullYear())})})}function u4(t,e){var n=L.useState(t),r=n[0],s=n[1],o=e===void 0?r:e;return[o,s]}function d4(t){var e=t.month,n=t.defaultMonth,r=t.today,s=e||n||r||new Date,o=t.toDate,i=t.fromDate,a=t.numberOfMonths,l=a===void 0?1:a;if(o&&bs(o,s)<0){var c=-1*(l-1);s=gt(o,c)}return i&&bs(s,i)<0&&(s=i),Ze(s)}function f4(){var t=de(),e=d4(t),n=u4(e,t.month),r=n[0],s=n[1],o=function(i){var a;if(!t.disableNavigation){var l=Ze(i);s(l),(a=t.onMonthChange)===null||a===void 0||a.call(t,l)}};return[r,o]}function h4(t,e){for(var n=e.reverseMonths,r=e.numberOfMonths,s=Ze(t),o=Ze(gt(s,r)),i=bs(o,s),a=[],l=0;l<i;l++){var c=gt(s,l);a.push(c)}return n&&(a=a.reverse()),a}function p4(t,e){if(!e.disableNavigation){var n=e.toDate,r=e.pagedNavigation,s=e.numberOfMonths,o=s===void 0?1:s,i=r?o:1,a=Ze(t);if(!n)return gt(a,i);var l=bs(n,t);if(!(l<o))return gt(a,i)}}function m4(t,e){if(!e.disableNavigation){var n=e.fromDate,r=e.pagedNavigation,s=e.numberOfMonths,o=s===void 0?1:s,i=r?o:1,a=Ze(t);if(!n)return gt(a,-i);var l=bs(a,n);if(!(l<=0))return gt(a,-i)}}var n1=L.createContext(void 0);function g4(t){var e=de(),n=f4(),r=n[0],s=n[1],o=h4(r,e),i=p4(r,e),a=m4(r,e),l=function(d){return o.some(function(f){return Rc(d,f)})},c=function(d,f){l(d)||(f&&Xg(d,f)?s(gt(d,1+e.numberOfMonths*-1)):s(d))},u={currentMonth:r,displayMonths:o,goToMonth:s,goToDate:c,previousMonth:a,nextMonth:i,isDateDisplayed:l};return p.jsx(n1.Provider,{value:u,children:t.children})}function js(){var t=L.useContext(n1);if(!t)throw new Error("useNavigation must be used within a NavigationProvider");return t}function af(t){var e,n=de(),r=n.classNames,s=n.styles,o=n.components,i=js().goToMonth,a=function(u){i(gt(u,t.displayIndex?-t.displayIndex:0))},l=(e=o?.CaptionLabel)!==null&&e!==void 0?e:e1,c=p.jsx(l,{id:t.id,displayMonth:t.displayMonth});return p.jsxs("div",{className:r.caption_dropdowns,style:s.caption_dropdowns,children:[p.jsx("div",{className:r.vhidden,children:c}),p.jsx(l4,{onChange:a,displayMonth:t.displayMonth}),p.jsx(c4,{onChange:a,displayMonth:t.displayMonth})]})}function y4(t){return p.jsx("svg",K({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:p.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function x4(t){return p.jsx("svg",K({width:"16px",height:"16px",viewBox:"0 0 120 120"},t,{children:p.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var ti=L.forwardRef(function(t,e){var n=de(),r=n.classNames,s=n.styles,o=[r.button_reset,r.button];t.className&&o.push(t.className);var i=o.join(" "),a=K(K({},s.button_reset),s.button);return t.style&&Object.assign(a,t.style),p.jsx("button",K({},t,{ref:e,type:"button",className:i,style:a}))});function b4(t){var e,n,r=de(),s=r.dir,o=r.locale,i=r.classNames,a=r.styles,l=r.labels,c=l.labelPrevious,u=l.labelNext,d=r.components;if(!t.nextMonth&&!t.previousMonth)return p.jsx(p.Fragment,{});var f=c(t.previousMonth,{locale:o}),h=[i.nav_button,i.nav_button_previous].join(" "),m=u(t.nextMonth,{locale:o}),y=[i.nav_button,i.nav_button_next].join(" "),g=(e=d?.IconRight)!==null&&e!==void 0?e:x4,x=(n=d?.IconLeft)!==null&&n!==void 0?n:y4;return p.jsxs("div",{className:i.nav,style:a.nav,children:[!t.hidePrevious&&p.jsx(ti,{name:"previous-month","aria-label":f,className:h,style:a.nav_button_previous,disabled:!t.previousMonth,onClick:t.onPreviousClick,children:s==="rtl"?p.jsx(g,{className:i.nav_icon,style:a.nav_icon}):p.jsx(x,{className:i.nav_icon,style:a.nav_icon})}),!t.hideNext&&p.jsx(ti,{name:"next-month","aria-label":m,className:y,style:a.nav_button_next,disabled:!t.nextMonth,onClick:t.onNextClick,children:s==="rtl"?p.jsx(x,{className:i.nav_icon,style:a.nav_icon}):p.jsx(g,{className:i.nav_icon,style:a.nav_icon})})]})}function lf(t){var e=de().numberOfMonths,n=js(),r=n.previousMonth,s=n.nextMonth,o=n.goToMonth,i=n.displayMonths,a=i.findIndex(function(m){return Rc(t.displayMonth,m)}),l=a===0,c=a===i.length-1,u=e>1&&(l||!c),d=e>1&&(c||!l),f=function(){r&&o(r)},h=function(){s&&o(s)};return p.jsx(b4,{displayMonth:t.displayMonth,hideNext:u,hidePrevious:d,nextMonth:s,previousMonth:r,onPreviousClick:f,onNextClick:h})}function v4(t){var e,n=de(),r=n.classNames,s=n.disableNavigation,o=n.styles,i=n.captionLayout,a=n.components,l=(e=a?.CaptionLabel)!==null&&e!==void 0?e:e1,c;return s?c=p.jsx(l,{id:t.id,displayMonth:t.displayMonth}):i==="dropdown"?c=p.jsx(af,{displayMonth:t.displayMonth,id:t.id}):i==="dropdown-buttons"?c=p.jsxs(p.Fragment,{children:[p.jsx(af,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),p.jsx(lf,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):c=p.jsxs(p.Fragment,{children:[p.jsx(l,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),p.jsx(lf,{displayMonth:t.displayMonth,id:t.id})]}),p.jsx("div",{className:r.caption,style:o.caption,children:c})}function k4(t){var e=de(),n=e.footer,r=e.styles,s=e.classNames.tfoot;return n?p.jsx("tfoot",{className:s,style:r.tfoot,children:p.jsx("tr",{children:p.jsx("td",{colSpan:8,children:n})})}):p.jsx(p.Fragment,{})}function S4(t,e,n){for(var r=n?qn(new Date):At(new Date,{locale:t,weekStartsOn:e}),s=[],o=0;o<7;o++){var i=We(r,o);s.push(i)}return s}function C4(){var t=de(),e=t.classNames,n=t.styles,r=t.showWeekNumber,s=t.locale,o=t.weekStartsOn,i=t.ISOWeek,a=t.formatters.formatWeekdayName,l=t.labels.labelWeekday,c=S4(s,o,i);return p.jsxs("tr",{style:n.head_row,className:e.head_row,children:[r&&p.jsx("td",{style:n.head_cell,className:e.head_cell}),c.map(function(u,d){return p.jsx("th",{scope:"col",className:e.head_cell,style:n.head_cell,"aria-label":l(u,{locale:s}),children:a(u,{locale:s})},d)})]})}function w4(){var t,e=de(),n=e.classNames,r=e.styles,s=e.components,o=(t=s?.HeadRow)!==null&&t!==void 0?t:C4;return p.jsx("thead",{style:r.head,className:n.head,children:p.jsx(o,{})})}function N4(t){var e=de(),n=e.locale,r=e.formatters.formatDay;return p.jsx(p.Fragment,{children:r(t.date,{locale:n})})}var Pc=L.createContext(void 0);function M4(t){if(!As(t.initialProps)){var e={selected:void 0,modifiers:{disabled:[]}};return p.jsx(Pc.Provider,{value:e,children:t.children})}return p.jsx(T4,{initialProps:t.initialProps,children:t.children})}function T4(t){var e=t.initialProps,n=t.children,r=e.selected,s=e.min,o=e.max,i=function(c,u,d){var f,h;(f=e.onDayClick)===null||f===void 0||f.call(e,c,u,d);var m=!!(u.selected&&s&&r?.length===s);if(!m){var y=!!(!u.selected&&o&&r?.length===o);if(!y){var g=r?Qg([],r):[];if(u.selected){var x=g.findIndex(function(b){return Ge(c,b)});g.splice(x,1)}else g.push(c);(h=e.onSelect)===null||h===void 0||h.call(e,g,c,u,d)}}},a={disabled:[]};r&&a.disabled.push(function(c){var u=o&&r.length>o-1,d=r.some(function(f){return Ge(f,c)});return!!(u&&!d)});var l={selected:r,onDayClick:i,modifiers:a};return p.jsx(Pc.Provider,{value:l,children:n})}function Lc(){var t=L.useContext(Pc);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function E4(t,e){var n=e||{},r=n.from,s=n.to;return r&&s?Ge(s,t)&&Ge(r,t)?void 0:Ge(s,t)?{from:s,to:void 0}:Ge(r,t)?void 0:ul(r,t)?{from:t,to:s}:{from:r,to:t}:s?ul(t,s)?{from:s,to:t}:{from:t,to:s}:r?Xg(t,r)?{from:t,to:r}:{from:r,to:t}:{from:t,to:void 0}}var $c=L.createContext(void 0);function D4(t){if(!Is(t.initialProps)){var e={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return p.jsx($c.Provider,{value:e,children:t.children})}return p.jsx(O4,{initialProps:t.initialProps,children:t.children})}function O4(t){var e=t.initialProps,n=t.children,r=e.selected,s=r||{},o=s.from,i=s.to,a=e.min,l=e.max,c=function(h,m,y){var g,x;(g=e.onDayClick)===null||g===void 0||g.call(e,h,m,y);var b=E4(h,r);(x=e.onSelect)===null||x===void 0||x.call(e,b,h,m,y)},u={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(u.range_start=[o],i?(u.range_end=[i],Ge(o,i)||(u.range_middle=[{after:o,before:i}])):u.range_end=[o]):i&&(u.range_start=[i],u.range_end=[i]),a&&(o&&!i&&u.disabled.push({after:ia(o,a-1),before:We(o,a-1)}),o&&i&&u.disabled.push({after:o,before:We(o,a-1)}),!o&&i&&u.disabled.push({after:ia(i,a-1),before:We(i,a-1)})),l){if(o&&!i&&(u.disabled.push({before:We(o,-l+1)}),u.disabled.push({after:We(o,l-1)})),o&&i){var d=Tt(i,o)+1,f=l-d;u.disabled.push({before:ia(o,f)}),u.disabled.push({after:We(i,f)})}!o&&i&&(u.disabled.push({before:We(i,-l+1)}),u.disabled.push({after:We(i,l-1)}))}return p.jsx($c.Provider,{value:{selected:r,onDayClick:c,modifiers:u},children:n})}function _c(){var t=L.useContext($c);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function so(t){return Array.isArray(t)?Qg([],t):t!==void 0?[t]:[]}function A4(t){var e={};return Object.entries(t).forEach(function(n){var r=n[0],s=n[1];e[r]=so(s)}),e}var yt;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(yt||(yt={}));var I4=yt.Selected,$t=yt.Disabled,j4=yt.Hidden,R4=yt.Today,la=yt.RangeEnd,ca=yt.RangeMiddle,ua=yt.RangeStart,P4=yt.Outside;function L4(t,e,n){var r,s=(r={},r[I4]=so(t.selected),r[$t]=so(t.disabled),r[j4]=so(t.hidden),r[R4]=[t.today],r[la]=[],r[ca]=[],r[ua]=[],r[P4]=[],r);return t.fromDate&&s[$t].push({before:t.fromDate}),t.toDate&&s[$t].push({after:t.toDate}),As(t)?s[$t]=s[$t].concat(e.modifiers[$t]):Is(t)&&(s[$t]=s[$t].concat(n.modifiers[$t]),s[ua]=n.modifiers[ua],s[ca]=n.modifiers[ca],s[la]=n.modifiers[la]),s}var r1=L.createContext(void 0);function $4(t){var e=de(),n=Lc(),r=_c(),s=L4(e,n,r),o=A4(e.modifiers),i=K(K({},s),o);return p.jsx(r1.Provider,{value:i,children:t.children})}function s1(){var t=L.useContext(r1);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function _4(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function B4(t){return!!(t&&typeof t=="object"&&"from"in t)}function z4(t){return!!(t&&typeof t=="object"&&"after"in t)}function F4(t){return!!(t&&typeof t=="object"&&"before"in t)}function H4(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function W4(t,e){var n,r=e.from,s=e.to;if(r&&s){var o=Tt(s,r)<0;o&&(n=[s,r],r=n[0],s=n[1]);var i=Tt(t,r)>=0&&Tt(s,t)>=0;return i}return s?Ge(s,t):r?Ge(r,t):!1}function V4(t){return Ac(t)}function U4(t){return Array.isArray(t)&&t.every(Ac)}function q4(t,e){return e.some(function(n){if(typeof n=="boolean")return n;if(V4(n))return Ge(t,n);if(U4(n))return n.includes(t);if(B4(n))return W4(t,n);if(H4(n))return n.dayOfWeek.includes(t.getDay());if(_4(n)){var r=Tt(n.before,t),s=Tt(n.after,t),o=r>0,i=s<0,a=ul(n.before,n.after);return a?i&&o:o||i}return z4(n)?Tt(t,n.after)>0:F4(n)?Tt(n.before,t)>0:typeof n=="function"?n(t):!1})}function Bc(t,e,n){var r=Object.keys(e).reduce(function(o,i){var a=e[i];return q4(t,a)&&o.push(i),o},[]),s={};return r.forEach(function(o){return s[o]=!0}),n&&!Rc(t,n)&&(s.outside=!0),s}function K4(t,e){for(var n=Ze(t[0]),r=Ic(t[t.length-1]),s,o,i=n;i<=r;){var a=Bc(i,e),l=!a.disabled&&!a.hidden;if(!l){i=We(i,1);continue}if(a.selected)return i;a.today&&!o&&(o=i),s||(s=i),i=We(i,1)}return o||s}var J4=365;function o1(t,e){var n=e.moveBy,r=e.direction,s=e.context,o=e.modifiers,i=e.retry,a=i===void 0?{count:0,lastFocused:t}:i,l=s.weekStartsOn,c=s.fromDate,u=s.toDate,d=s.locale,f={day:We,week:cl,month:gt,year:L3,startOfWeek:function(g){return s.ISOWeek?qn(g):At(g,{locale:d,weekStartsOn:l})},endOfWeek:function(g){return s.ISOWeek?Ug(g):jc(g,{locale:d,weekStartsOn:l})}},h=f[n](t,r==="after"?1:-1);r==="before"&&c?h=$3([c,h]):r==="after"&&u&&(h=_3([u,h]));var m=!0;if(o){var y=Bc(h,o);m=!y.disabled&&!y.hidden}return m?h:a.count>J4?a.lastFocused:o1(h,{moveBy:n,direction:r,context:s,modifiers:o,retry:K(K({},a),{count:a.count+1})})}var i1=L.createContext(void 0);function Y4(t){var e=js(),n=s1(),r=L.useState(),s=r[0],o=r[1],i=L.useState(),a=i[0],l=i[1],c=K4(e.displayMonths,n),u=s??(a&&e.isDateDisplayed(a))?a:c,d=function(){l(s),o(void 0)},f=function(g){o(g)},h=de(),m=function(g,x){if(s){var b=o1(s,{moveBy:g,direction:x,context:h,modifiers:n});Ge(s,b)||(e.goToDate(b,s),f(b))}},y={focusedDay:s,focusTarget:u,blur:d,focus:f,focusDayAfter:function(){return m("day","after")},focusDayBefore:function(){return m("day","before")},focusWeekAfter:function(){return m("week","after")},focusWeekBefore:function(){return m("week","before")},focusMonthBefore:function(){return m("month","before")},focusMonthAfter:function(){return m("month","after")},focusYearBefore:function(){return m("year","before")},focusYearAfter:function(){return m("year","after")},focusStartOfWeek:function(){return m("startOfWeek","before")},focusEndOfWeek:function(){return m("endOfWeek","after")}};return p.jsx(i1.Provider,{value:y,children:t.children})}function zc(){var t=L.useContext(i1);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function G4(t,e){var n=s1(),r=Bc(t,n,e);return r}var Fc=L.createContext(void 0);function X4(t){if(!wi(t.initialProps)){var e={selected:void 0};return p.jsx(Fc.Provider,{value:e,children:t.children})}return p.jsx(Q4,{initialProps:t.initialProps,children:t.children})}function Q4(t){var e=t.initialProps,n=t.children,r=function(o,i,a){var l,c,u;if((l=e.onDayClick)===null||l===void 0||l.call(e,o,i,a),i.selected&&!e.required){(c=e.onSelect)===null||c===void 0||c.call(e,void 0,o,i,a);return}(u=e.onSelect)===null||u===void 0||u.call(e,o,o,i,a)},s={selected:e.selected,onDayClick:r};return p.jsx(Fc.Provider,{value:s,children:n})}function a1(){var t=L.useContext(Fc);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Z4(t,e){var n=de(),r=a1(),s=Lc(),o=_c(),i=zc(),a=i.focusDayAfter,l=i.focusDayBefore,c=i.focusWeekAfter,u=i.focusWeekBefore,d=i.blur,f=i.focus,h=i.focusMonthBefore,m=i.focusMonthAfter,y=i.focusYearBefore,g=i.focusYearAfter,x=i.focusStartOfWeek,b=i.focusEndOfWeek,v=function(I){var R,z,W,q;wi(n)?(R=r.onDayClick)===null||R===void 0||R.call(r,t,e,I):As(n)?(z=s.onDayClick)===null||z===void 0||z.call(s,t,e,I):Is(n)?(W=o.onDayClick)===null||W===void 0||W.call(o,t,e,I):(q=n.onDayClick)===null||q===void 0||q.call(n,t,e,I)},k=function(I){var R;f(t),(R=n.onDayFocus)===null||R===void 0||R.call(n,t,e,I)},N=function(I){var R;d(),(R=n.onDayBlur)===null||R===void 0||R.call(n,t,e,I)},C=function(I){var R;(R=n.onDayMouseEnter)===null||R===void 0||R.call(n,t,e,I)},S=function(I){var R;(R=n.onDayMouseLeave)===null||R===void 0||R.call(n,t,e,I)},w=function(I){var R;(R=n.onDayPointerEnter)===null||R===void 0||R.call(n,t,e,I)},M=function(I){var R;(R=n.onDayPointerLeave)===null||R===void 0||R.call(n,t,e,I)},T=function(I){var R;(R=n.onDayTouchCancel)===null||R===void 0||R.call(n,t,e,I)},O=function(I){var R;(R=n.onDayTouchEnd)===null||R===void 0||R.call(n,t,e,I)},A=function(I){var R;(R=n.onDayTouchMove)===null||R===void 0||R.call(n,t,e,I)},P=function(I){var R;(R=n.onDayTouchStart)===null||R===void 0||R.call(n,t,e,I)},D=function(I){var R;(R=n.onDayKeyUp)===null||R===void 0||R.call(n,t,e,I)},E=function(I){var R;switch(I.key){case"ArrowLeft":I.preventDefault(),I.stopPropagation(),n.dir==="rtl"?a():l();break;case"ArrowRight":I.preventDefault(),I.stopPropagation(),n.dir==="rtl"?l():a();break;case"ArrowDown":I.preventDefault(),I.stopPropagation(),c();break;case"ArrowUp":I.preventDefault(),I.stopPropagation(),u();break;case"PageUp":I.preventDefault(),I.stopPropagation(),I.shiftKey?y():h();break;case"PageDown":I.preventDefault(),I.stopPropagation(),I.shiftKey?g():m();break;case"Home":I.preventDefault(),I.stopPropagation(),x();break;case"End":I.preventDefault(),I.stopPropagation(),b();break}(R=n.onDayKeyDown)===null||R===void 0||R.call(n,t,e,I)},j={onClick:v,onFocus:k,onBlur:N,onKeyDown:E,onKeyUp:D,onMouseEnter:C,onMouseLeave:S,onPointerEnter:w,onPointerLeave:M,onTouchCancel:T,onTouchEnd:O,onTouchMove:A,onTouchStart:P};return j}function eD(){var t=de(),e=a1(),n=Lc(),r=_c(),s=wi(t)?e.selected:As(t)?n.selected:Is(t)?r.selected:void 0;return s}function tD(t){return Object.values(yt).includes(t)}function nD(t,e){var n=[t.classNames.day];return Object.keys(e).forEach(function(r){var s=t.modifiersClassNames[r];if(s)n.push(s);else if(tD(r)){var o=t.classNames["day_".concat(r)];o&&n.push(o)}}),n}function rD(t,e){var n=K({},t.styles.day);return Object.keys(e).forEach(function(r){var s;n=K(K({},n),(s=t.modifiersStyles)===null||s===void 0?void 0:s[r])}),n}function sD(t,e,n){var r,s,o,i=de(),a=zc(),l=G4(t,e),c=Z4(t,l),u=eD(),d=!!(i.onDayClick||i.mode!=="default");L.useEffect(function(){var C;l.outside||a.focusedDay&&d&&Ge(a.focusedDay,t)&&((C=n.current)===null||C===void 0||C.focus())},[a.focusedDay,t,n,d,l.outside]);var f=nD(i,l).join(" "),h=rD(i,l),m=!!(l.outside&&!i.showOutsideDays||l.hidden),y=(o=(s=i.components)===null||s===void 0?void 0:s.DayContent)!==null&&o!==void 0?o:N4,g=p.jsx(y,{date:t,displayMonth:e,activeModifiers:l}),x={style:h,className:f,children:g,role:"gridcell"},b=a.focusTarget&&Ge(a.focusTarget,t)&&!l.outside,v=a.focusedDay&&Ge(a.focusedDay,t),k=K(K(K({},x),(r={disabled:l.disabled,role:"gridcell"},r["aria-selected"]=l.selected,r.tabIndex=v||b?0:-1,r)),c),N={isButton:d,isHidden:m,activeModifiers:l,selectedDays:u,buttonProps:k,divProps:x};return N}function oD(t){var e=L.useRef(null),n=sD(t.date,t.displayMonth,e);return n.isHidden?p.jsx("div",{role:"gridcell"}):n.isButton?p.jsx(ti,K({name:"day",ref:e},n.buttonProps)):p.jsx("div",K({},n.divProps))}function iD(t){var e=t.number,n=t.dates,r=de(),s=r.onWeekNumberClick,o=r.styles,i=r.classNames,a=r.locale,l=r.labels.labelWeekNumber,c=r.formatters.formatWeekNumber,u=c(Number(e),{locale:a});if(!s)return p.jsx("span",{className:i.weeknumber,style:o.weeknumber,children:u});var d=l(Number(e),{locale:a}),f=function(h){s(e,n,h)};return p.jsx(ti,{name:"week-number","aria-label":d,className:i.weeknumber,style:o.weeknumber,onClick:f,children:u})}function aD(t){var e,n,r=de(),s=r.styles,o=r.classNames,i=r.showWeekNumber,a=r.components,l=(e=a?.Day)!==null&&e!==void 0?e:oD,c=(n=a?.WeekNumber)!==null&&n!==void 0?n:iD,u;return i&&(u=p.jsx("td",{className:o.cell,style:s.cell,children:p.jsx(c,{number:t.weekNumber,dates:t.dates})})),p.jsxs("tr",{className:o.row,style:s.row,children:[u,t.dates.map(function(d){return p.jsx("td",{className:o.cell,style:s.cell,role:"presentation",children:p.jsx(l,{displayMonth:t.displayMonth,date:d})},$E(d))})]})}function cf(t,e,n){for(var r=n?.ISOWeek?Ug(e):jc(e,n),s=n?.ISOWeek?qn(t):At(t,n),o=Tt(r,s),i=[],a=0;a<=o;a++)i.push(We(s,a));var l=i.reduce(function(c,u){var d=n?.ISOWeek?Kg(u):Yg(u,n),f=c.find(function(h){return h.weekNumber===d});return f?(f.dates.push(u),c):(c.push({weekNumber:d,dates:[u]}),c)},[]);return l}function lD(t,e){var n=cf(Ze(t),Ic(t),e);if(e?.useFixedWeeks){var r=BE(t,e);if(r<6){var s=n[n.length-1],o=s.dates[s.dates.length-1],i=cl(o,6-r),a=cf(cl(o,1),i,e);n.push.apply(n,a)}}return n}function cD(t){var e,n,r,s=de(),o=s.locale,i=s.classNames,a=s.styles,l=s.hideHead,c=s.fixedWeeks,u=s.components,d=s.weekStartsOn,f=s.firstWeekContainsDate,h=s.ISOWeek,m=lD(t.displayMonth,{useFixedWeeks:!!c,ISOWeek:h,locale:o,weekStartsOn:d,firstWeekContainsDate:f}),y=(e=u?.Head)!==null&&e!==void 0?e:w4,g=(n=u?.Row)!==null&&n!==void 0?n:aD,x=(r=u?.Footer)!==null&&r!==void 0?r:k4;return p.jsxs("table",{id:t.id,className:i.table,style:a.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!l&&p.jsx(y,{}),p.jsx("tbody",{className:i.tbody,style:a.tbody,children:m.map(function(b){return p.jsx(g,{displayMonth:t.displayMonth,dates:b.dates,weekNumber:b.weekNumber},b.weekNumber)})}),p.jsx(x,{displayMonth:t.displayMonth})]})}function uD(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var dD=uD()?L.useLayoutEffect:L.useEffect,da=!1,fD=0;function uf(){return"react-day-picker-".concat(++fD)}function hD(t){var e,n=t??(da?uf():null),r=L.useState(n),s=r[0],o=r[1];return dD(function(){s===null&&o(uf())},[]),L.useEffect(function(){da===!1&&(da=!0)},[]),(e=t??s)!==null&&e!==void 0?e:void 0}function pD(t){var e,n,r=de(),s=r.dir,o=r.classNames,i=r.styles,a=r.components,l=js().displayMonths,c=hD(r.id?"".concat(r.id,"-").concat(t.displayIndex):void 0),u=r.id?"".concat(r.id,"-grid-").concat(t.displayIndex):void 0,d=[o.month],f=i.month,h=t.displayIndex===0,m=t.displayIndex===l.length-1,y=!h&&!m;s==="rtl"&&(e=[h,m],m=e[0],h=e[1]),h&&(d.push(o.caption_start),f=K(K({},f),i.caption_start)),m&&(d.push(o.caption_end),f=K(K({},f),i.caption_end)),y&&(d.push(o.caption_between),f=K(K({},f),i.caption_between));var g=(n=a?.Caption)!==null&&n!==void 0?n:v4;return p.jsxs("div",{className:d.join(" "),style:f,children:[p.jsx(g,{id:c,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),p.jsx(cD,{id:u,"aria-labelledby":c,displayMonth:t.displayMonth})]},t.displayIndex)}function mD(t){var e=de(),n=e.classNames,r=e.styles;return p.jsx("div",{className:n.months,style:r.months,children:t.children})}function gD(t){var e,n,r=t.initialProps,s=de(),o=zc(),i=js(),a=L.useState(!1),l=a[0],c=a[1];L.useEffect(function(){s.initialFocus&&o.focusTarget&&(l||(o.focus(o.focusTarget),c(!0)))},[s.initialFocus,l,o.focus,o.focusTarget,o]);var u=[s.classNames.root,s.className];s.numberOfMonths>1&&u.push(s.classNames.multiple_months),s.showWeekNumber&&u.push(s.classNames.with_weeknumber);var d=K(K({},s.styles.root),s.style),f=Object.keys(r).filter(function(m){return m.startsWith("data-")}).reduce(function(m,y){var g;return K(K({},m),(g={},g[y]=r[y],g))},{}),h=(n=(e=r.components)===null||e===void 0?void 0:e.Months)!==null&&n!==void 0?n:mD;return p.jsx("div",K({className:u.join(" "),style:d,dir:s.dir,id:s.id,nonce:r.nonce,title:r.title,lang:r.lang},f,{children:p.jsx(h,{children:i.displayMonths.map(function(m,y){return p.jsx(pD,{displayIndex:y,displayMonth:m},y)})})}))}function yD(t){var e=t.children,n=FE(t,["children"]);return p.jsx(i4,{initialProps:n,children:p.jsx(g4,{children:p.jsx(X4,{initialProps:n,children:p.jsx(M4,{initialProps:n,children:p.jsx(D4,{initialProps:n,children:p.jsx($4,{children:p.jsx(Y4,{children:e})})})})})})})}function xD(t){return p.jsx(yD,K({},t,{children:p.jsx(gD,{initialProps:t})}))}function gA(t){const e=_.c(20);let n,r,s,o;e[0]!==t?({className:n,classNames:r,showOutsideDays:o,...s}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s,e[4]=o):(n=e[1],r=e[2],s=e[3],o=e[4]);const i=o===void 0?!0:o;let a;e[5]!==n?(a=G("p-3",n),e[5]=n,e[6]=a):a=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=G(qc({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),e[7]=l):l=e[7];const c=s.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md";let u;e[8]!==c?(u=G("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",c),e[8]=c,e[9]=u):u=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=G(qc({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),e[10]=d):d=e[10];let f;e[11]!==r||e[12]!==u?(f={months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:l,nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:u,day:d,day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...r},e[11]=r,e[12]=u,e[13]=f):f=e[13];let h;e[14]===Symbol.for("react.memo_cache_sentinel")?(h={IconLeft:vD,IconRight:bD},e[14]=h):h=e[14];let m;return e[15]!==s||e[16]!==i||e[17]!==a||e[18]!==f?(m=p.jsx(xD,{showOutsideDays:i,className:a,classNames:f,components:h,...s}),e[15]=s,e[16]=i,e[17]=a,e[18]=f,e[19]=m):m=e[19],m}function bD(t){const{className:e,...n}=t;return p.jsx(ma,{className:G("size-4",e),...n})}function vD(t){const{className:e,...n}=t;return p.jsx(J1,{className:G("size-4",e),...n})}const l1={requires_action:{labelKey:"common.taskStatus.requiresAction",icon:yl,iconClassName:"text-warning",labelColor:"text-warning"},failed:{labelKey:"common.taskStatus.failed",icon:c0,iconClassName:"text-destructive",labelColor:"text-destructive"},expired:{labelKey:"common.taskStatus.expired",icon:G1,iconClassName:"text-warning",labelColor:"text-warning"},in_progress:{labelKey:"common.taskStatus.inProgress",icon:Y1,iconClassName:"text-primary",labelColor:"text-primary"},completed:{labelKey:"common.taskStatus.completed",icon:a0,iconClassName:"text-muted-foreground/50",labelColor:"text-muted-foreground"}},df={labelKey:"common.taskStatus.unknown",icon:l0,iconClassName:"text-muted-foreground",labelColor:"text-muted-foreground"};function kD(t){return t in l1}function c1(t){if(t===null)return df;const e=t??"completed";return kD(e)?l1[e]:df}const oo=[{ms:6e4,label:"1m"},{ms:12e4,label:"2m"},{ms:3e5,label:"5m"},{ms:6e5,label:"10m"},{ms:9e5,label:"15m"},{ms:18e5,label:"30m"},{ms:36e5,label:"1h"},{ms:72e5,label:"2h"},{ms:216e5,label:"6h"},{ms:432e5,label:"12h"},{ms:864e5,label:"1d"},{ms:6048e5,label:"7d"}],SD=40;function yA(t){const n=(t.endDate.getTime()-t.startDate.getTime())/SD;return oo.find(s=>s.ms>=n)?.label??oo[oo.length-1].label}function Hc(t){const e=oo.find(o=>o.label===t);if(e)return e.ms;const n=/^(\d+)([mhd])$/.exec(t);if(!n)return 6e4;const r=parseInt(n[1],10),s=n[2];return s==="h"?r*36e5:s==="d"?r*864e5:r*6e4}function CD(t,e){const n=new Date(t);return Hc(e)>=864e5?n.toLocaleDateString([],{month:"short",day:"numeric"}):n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ff(t,e){const n=Hc(e);return new Date(Math.floor(t.getTime()/n)*n)}function wD(t){return t>=1e4?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function u1(t){return Number.isFinite(t)?t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:Math.round(t).toLocaleString():"0"}function d1(t){return Number.isFinite(t)?`$${t.toFixed(t<1?4:2)}`:"$0.00"}function xA(t,e,n){const r=Hc(n),s=ff(e.startDate,n).getTime(),o=e.endDate.getTime(),i=new Map(t.map(l=>[ff(new Date(l.timestamp),n).getTime(),l])),a=[];for(let l=s;l<=o;l+=r){const c=i.get(l),u=new Date(l).toISOString();a.push({t:u,ts:l,label:CD(u,n),calls:c?.calls??0,errors:c?.errors??0,errorRate:c?.errorRate??0,avg:c?.avg??0,p50:c?.p50??0,p95:c?.p95??0,inputTokens:c?.inputTokens??0,outputTokens:c?.outputTokens??0,totalTokens:c?.totalTokens??0,costUsd:c?.costUsd??0})}return a}function bA(t,e,n,r){const s=new Map;for(const d of t)s.set(d.toolName,(s.get(d.toolName)??0)+d[e]);const o=[...s.entries()].sort((d,f)=>f[1]-d[1]).slice(0,n).map(([d])=>d),i=new Set(o),a=new Map,l=new Map;for(const d of t){if(!i.has(d.toolName))continue;const f=d.virtualMcpId??"";a.set(f,(a.get(f)??0)+d[e]),l.set(`${f}::${d.toolName}`,{calls:d.calls,errors:d.errors,outputSize:d.outputSize})}const c=[...a.entries()].sort((d,f)=>f[1]-d[1]).slice(0,r).map(([d])=>d);let u=0;for(const d of c)for(const f of o){const h=l.get(`${d}::${f}`);h&&h[e]>u&&(u=h[e])}return{topTools:o,topAgentIds:c,cellMap:l,maxValue:u}}function vA(t,e){return e==="requests"?t.calls:e==="errors"?t.errorRate:t.avgDurationMs}function kA(t,e){return e==="requests"?t.calls.toLocaleString():e==="errors"?`${t.errorRate.toFixed(1)}%`:wD(t.avgDurationMs)}function f1(t){return(t.run_config??{}).agent?.id??(t.virtual_mcp_id||null)}function h1(t,e,n,r){if(!t)return r;const s=e.find(i=>i.id===t)??n?.find(i=>i.id===t);if(s?.title)return s.title;const o=Ef(t);return o?Df(o).title??r:t}function p1(t,e,n){if(!t)return null;const r=e.find(o=>o.id===t)??n?.find(o=>o.id===t);if(r?.icon)return r.icon;const s=Ef(t);return s?Df(s).icon??null:null}function ND(t){return t?.data?.members??[]}function dl(t){const e=_.c(32),{thread:n,connections:r,virtualMcps:s,nav:o}=t,i=J();let a,l;if(e[0]!==r||e[1]!==n||e[2]!==s){const k=f1(n);a=h1(k,s,r,""),l=p1(k,s,r),e[0]=r,e[1]=n,e[2]=s,e[3]=a,e[4]=l}else a=e[3],l=e[4];const c=l;let u;e[5]!==a||e[6]!==i||e[7]!==n.title?(u=a||n.title||i("orgs.threads.untitledChat"),e[5]=a,e[6]=i,e[7]=n.title,e[8]=u):u=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx(Rf,{}),e[9]=d):d=e[9];let f;e[10]!==c||e[11]!==u?(f=p.jsx(Kn,{icon:c,name:u,size:"sm",fallbackIcon:d,className:"shadow-sm shrink-0 rounded-md"}),e[10]=c,e[11]=u,e[12]=f):f=e[12];let h;e[13]!==i||e[14]!==n.title?(h=n.title||i("orgs.threads.untitledChat"),e[13]=i,e[14]=n.title,e[15]=h):h=e[15];let m;e[16]!==h?(m=p.jsx(kf,{className:"text-sm leading-snug truncate",children:h}),e[16]=h,e[17]=m):m=e[17];let y;e[18]!==a?(y=a&&p.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:a}),e[18]=a,e[19]=y):y=e[19];let g;e[20]!==m||e[21]!==y?(g=p.jsxs("div",{className:"min-w-0",children:[m,y]}),e[20]=m,e[21]=y,e[22]=g):g=e[22];let x;e[23]!==f||e[24]!==g?(x=p.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[f,g]}),e[23]=f,e[24]=g,e[25]=x):x=e[25];let b;e[26]!==o||e[27]!==i?(b=o&&p.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p.jsx(Ln,{size:"icon",variant:"ghost",onClick:o.onPrev,disabled:o.index===0,className:"h-7 w-7 text-muted-foreground","aria-label":i("orgs.threads.previousChat"),children:p.jsx(h0,{size:14})}),p.jsx(Ln,{size:"icon",variant:"ghost",onClick:o.onNext,disabled:o.index===o.total-1,className:"h-7 w-7 text-muted-foreground","aria-label":i("orgs.threads.nextChat"),children:p.jsx(If,{size:14})})]}),e[26]=o,e[27]=i,e[28]=b):b=e[28];let v;return e[29]!==b||e[30]!==x?(v=p.jsx(vf,{className:"px-5 md:px-6 pt-6 pb-5 border-b border-border shrink-0",children:p.jsxs("div",{className:"flex items-start justify-between gap-3 pr-8",children:[x,b]})}),e[29]=b,e[30]=x,e[31]=v):v=e[31],v}function MD(t){const e=_.c(62),{thread:n,connections:r,virtualMcps:s,members:o}=t,i=J();let a,l;if(e[0]!==r||e[1]!==n||e[2]!==s){const I=f1(n);a=h1(I,s,r,""),l=p1(I,s,r),e[0]=r,e[1]=n,e[2]=s,e[3]=a,e[4]=l}else a=e[3],l=e[4];const c=l;let u;if(e[5]!==o||e[6]!==n.created_by){const I=ND(o);let R;e[8]!==n.created_by?(R=z=>z.userId===n.created_by,e[8]=n.created_by,e[9]=R):R=e[9],u=I.find(R),e[5]=o,e[6]=n.created_by,e[7]=u}else u=e[7];const d=u;let f;e[10]!==d?.user.email||e[11]!==d?.user.name||e[12]!==n.created_by?(f=d?.user.name??d?.user.email??n.created_by?.substring(0,8)??"—",e[10]=d?.user.email,e[11]=d?.user.name,e[12]=n.created_by,e[13]=f):f=e[13];const h=f,m=d?.user.image??void 0;let y;e[14]!==n.created_at?(y=new Date(n.created_at).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e[14]=n.created_at,e[15]=y):y=e[15];const g=y;let x,b,v,k,N,C;if(e[16]!==i||e[17]!==n.status){const I=c1(n.status),R=I.icon;x="px-5 md:px-6 py-5 border-b border-border grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4 text-sm";let z;e[24]!==i?(z=i("orgs.threads.status"),e[24]=i,e[25]=z):z=e[25],e[26]!==z?(C=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:z}),e[26]=z,e[27]=C):C=e[27],k="flex items-center gap-1.5",N=p.jsx(R,{size:13,className:I.iconClassName}),b=G("text-sm",I.labelColor),v=i(I.labelKey),e[16]=i,e[17]=n.status,e[18]=x,e[19]=b,e[20]=v,e[21]=k,e[22]=N,e[23]=C}else x=e[18],b=e[19],v=e[20],k=e[21],N=e[22],C=e[23];let S;e[28]!==b||e[29]!==v?(S=p.jsx("span",{className:b,children:v}),e[28]=b,e[29]=v,e[30]=S):S=e[30];let w;e[31]!==S||e[32]!==k||e[33]!==N?(w=p.jsxs("div",{className:k,children:[N,S]}),e[31]=S,e[32]=k,e[33]=N,e[34]=w):w=e[34];let M;e[35]!==w||e[36]!==C?(M=p.jsxs("div",{children:[C,w]}),e[35]=w,e[36]=C,e[37]=M):M=e[37];let T;e[38]!==i?(T=i("orgs.threads.date"),e[38]=i,e[39]=T):T=e[39];let O;e[40]!==T?(O=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:T}),e[40]=T,e[41]=O):O=e[41];let A;e[42]!==g?(A=p.jsx("div",{className:"text-sm text-foreground",children:g}),e[42]=g,e[43]=A):A=e[43];let P;e[44]!==O||e[45]!==A?(P=p.jsxs("div",{children:[O,A]}),e[44]=O,e[45]=A,e[46]=P):P=e[46];let D;e[47]!==i||e[48]!==n.created_by||e[49]!==m||e[50]!==h?(D=n.created_by&&p.jsxs("div",{children:[p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:i("orgs.threads.user")}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(f0,{url:m,fallback:h,shape:"circle",size:"2xs",className:"shrink-0"}),p.jsx("span",{className:"text-sm text-foreground",children:h})]})]}),e[47]=i,e[48]=n.created_by,e[49]=m,e[50]=h,e[51]=D):D=e[51];let E;e[52]!==c||e[53]!==a||e[54]!==i?(E=a&&p.jsxs("div",{children:[p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:i("orgs.threads.agent")}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Kn,{icon:c,name:a,size:"xs",fallbackIcon:p.jsx(Rf,{}),className:"shrink-0 size-5! min-w-5! rounded-md"}),p.jsx("span",{className:"text-sm text-foreground",children:a})]})]}),e[52]=c,e[53]=a,e[54]=i,e[55]=E):E=e[55];let j;return e[56]!==x||e[57]!==M||e[58]!==P||e[59]!==D||e[60]!==E?(j=p.jsxs("div",{className:x,children:[M,P,D,E]}),e[56]=x,e[57]=M,e[58]=P,e[59]=D,e[60]=E,e[61]=j):j=e[61],j}const fl=100;function TD(){const t=_.c(4),e=J();let n;t[0]!==e?(n=e("orgs.threads.noMessagesInChat"),t[0]=e,t[1]=n):n=t[1];let r;return t[2]!==n?(r=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:n}),t[2]=n,t[3]=r):r=t[3],r}function ED(){const t=_.c(4),e=J();let n;t[0]!==e?(n=e("orgs.threads.loadingMore"),t[0]=e,t[1]=n):n=t[1];let r;return t[2]!==n?(r=p.jsx("div",{className:"py-4 text-center text-xs text-muted-foreground",children:n}),t[2]=n,t[3]=r):r=t[3],r}const DD=400,OD=5e3;function AD(t,e,n){const r=_.c(8),s=mf(),o=L.useRef(null);let i;r[0]!==e||r[1]!==s||r[2]!==n?(i=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,s.invalidateQueries({queryKey:ht.threadMessages(e,n)})},DD)},r[0]=e,r[1]=s,r[2]=n,r[3]=i):i=r[3];const a=i;let l;r[4]!==t||r[5]!==a||r[6]!==n?(l={orgSlug:t,taskId:n,onStep:a,onFinish:a,onReconnect:a},r[4]=t,r[5]=a,r[6]=n,r[7]=l):l=r[7],G0(l)}function ID(t){const e=_.c(36),{client:n,locator:r,thread:s,connections:o,virtualMcps:i,members:a,nav:l,meta:c}=t,{org:u}=xt();let d;e[0]!==r||e[1]!==s.id?(d=ht.threadMessages(r,s.id),e[0]=r,e[1]=s.id,e[2]=d):d=e[2];let f;e[3]!==n||e[4]!==s.id?(f=async O=>{const{pageParam:A}=O,P=A===void 0?0:A;if(!n)throw new Error("MCP client is not available");const D=await n.callTool({name:"COLLECTION_THREAD_MESSAGES_LIST",arguments:{thread_id:s.id,limit:fl,offset:P}});return D.structuredContent??D},e[3]=n,e[4]=s.id,e[5]=f):f=e[5];let h;e[6]!==d||e[7]!==f?(h={queryKey:d,queryFn:f,initialPageParam:0,getNextPageParam:PD,staleTime:0,refetchInterval:OD},e[6]=d,e[7]=f,e[8]=h):h=e[8];const{data:m,fetchNextPage:y,hasNextPage:g,isFetchingNextPage:x}=d0(h);AD(u.slug,r,s.id);let b;e[9]!==m.pages?(b=m.pages.flatMap(RD).filter(jD),e[9]=m.pages,e[10]=b):b=e[10];const v=b,k=A3(v);let N;e[11]!==y||e[12]!==g||e[13]!==x?(N=()=>{g&&!x&&y()},e[11]=y,e[12]=g,e[13]=x,e[14]=N):N=e[14];const C=Af(N,g??!1,x);let S;e[15]!==o||e[16]!==l||e[17]!==s||e[18]!==i?(S=p.jsx(dl,{thread:s,connections:o,virtualMcps:i,nav:l}),e[15]=o,e[16]=l,e[17]=s,e[18]=i,e[19]=S):S=e[19];let w;e[20]!==o||e[21]!==a||e[22]!==c||e[23]!==s||e[24]!==i?(w=c&&p.jsx(MD,{thread:s,connections:o,virtualMcps:i,members:a}),e[20]=o,e[21]=a,e[22]=c,e[23]=s,e[24]=i,e[25]=w):w=e[25];let M;e[26]!==x||e[27]!==C||e[28]!==k||e[29]!==v.length||e[30]!==s.status?(M=v.length===0?p.jsx(TD,{}):p.jsx("div",{"data-chat-scroller":!0,className:"flex-1 overflow-y-auto min-h-0",children:p.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[k.map((O,A)=>p.jsx("div",{ref:A===k.length-1?C:void 0,children:p.jsx(I3,{pair:O,isLastPair:A===k.length-1,status:A===k.length-1&&s.status==="in_progress"?"streaming":"ready"})},`pair-${O.user?.id??O.assistant?.id}`)),x&&p.jsx(ED,{})]})}),e[26]=x,e[27]=C,e[28]=k,e[29]=v.length,e[30]=s.status,e[31]=M):M=e[31];let T;return e[32]!==S||e[33]!==w||e[34]!==M?(T=p.jsxs(p.Fragment,{children:[S,w,M]}),e[32]=S,e[33]=w,e[34]=M,e[35]=T):T=e[35],T}function jD(t){return t.role==="user"||t.role==="assistant"}function RD(t){return t.items??[]}function PD(t,e){const n=t,r=e;if(!((n?.items?.length??0)<fl))return r.length*fl}function LD(){const t=_.c(4),e=J();let n;t[0]!==e?(n=e("orgs.threads.failedToLoadMessages"),t[0]=e,t[1]=n):n=t[1];let r;return t[2]!==n?(r=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:n}),t[2]=n,t[3]=r):r=t[3],r}function $D(){const t=_.c(4),e=J();let n;t[0]!==e?(n=e("orgs.threads.loadingConversation"),t[0]=e,t[1]=n):n=t[1];let r;return t[2]!==n?(r=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:n}),t[2]=n,t[3]=r):r=t[3],r}function _D(t){const e=_.c(31),{thread:n,client:r,locator:s,connections:o,virtualMcps:i,members:a,nav:l,meta:c}=t,u=c===void 0?!0:c;let d;e[0]!==o||e[1]!==l||e[2]!==n||e[3]!==i?(d=p.jsx(dl,{thread:n,connections:o,virtualMcps:i,nav:l}),e[0]=o,e[1]=l,e[2]=n,e[3]=i,e[4]=d):d=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx(LD,{}),e[5]=f):f=e[5];let h;e[6]!==d?(h=p.jsxs(p.Fragment,{children:[d,f]}),e[6]=d,e[7]=h):h=e[7];let m;e[8]!==o||e[9]!==l||e[10]!==n||e[11]!==i?(m=p.jsx(dl,{thread:n,connections:o,virtualMcps:i,nav:l}),e[8]=o,e[9]=l,e[10]=n,e[11]=i,e[12]=m):m=e[12];let y;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=p.jsx($D,{}),e[13]=y):y=e[13];let g;e[14]!==m?(g=p.jsxs(p.Fragment,{children:[m,y]}),e[14]=m,e[15]=g):g=e[15];let x;e[16]!==r||e[17]!==o||e[18]!==s||e[19]!==a||e[20]!==u||e[21]!==l||e[22]!==n||e[23]!==i?(x=p.jsx(ID,{client:r,locator:s,thread:n,connections:o,virtualMcps:i,members:a,nav:l,meta:u}),e[16]=r,e[17]=o,e[18]=s,e[19]=a,e[20]=u,e[21]=l,e[22]=n,e[23]=i,e[24]=x):x=e[24];let b;e[25]!==g||e[26]!==x?(b=p.jsx(L.Suspense,{fallback:g,children:x}),e[25]=g,e[26]=x,e[27]=b):b=e[27];let v;return e[28]!==h||e[29]!==b?(v=p.jsx(S0,{children:p.jsx(yf,{fallback:h,children:b})}),e[28]=h,e[29]=b,e[30]=v):v=e[30],v}function BD(t){const e=_.c(15),[n,r]=L.useState(null);let s;e[0]!==t||e[1]!==n?(s=n!==null?t.findIndex(h=>h.id===n):-1,e[0]=t,e[1]=n,e[2]=s):s=e[2];const o=s,i=o!==-1?t[o]:null,a=i!==null;let l,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=h=>r(h),c=()=>r(null),e[3]=l,e[4]=c):(l=e[3],c=e[4]);let u,d;e[5]!==o||e[6]!==t?(u=()=>{const h=t[o-1];o>0&&h&&r(h.id)},d=()=>{const h=t[o+1];o!==-1&&h&&r(h.id)},e[5]=o,e[6]=t,e[7]=u,e[8]=d):(u=e[7],d=e[8]);let f;return e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==u||e[13]!==d?(f={selected:i,index:o,isOpen:a,select:l,close:c,prev:u,next:d},e[9]=o,e[10]=i,e[11]=a,e[12]=u,e[13]=d,e[14]=f):f=e[14],f}const hl=50;function Qs(t){const e=_.c(10),{title:n,value:r,subtitle:s}=t;let o;e[0]!==n?(o=p.jsx("span",{className:"text-sm text-foreground/70",children:n}),e[0]=n,e[1]=o):o=e[1];let i;e[2]!==r?(i=p.jsx("span",{className:"text-3xl font-normal tabular-nums",children:r}),e[2]=r,e[3]=i):i=e[3];let a;e[4]!==s?(a=s&&p.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==i||e[8]!==a?(l=p.jsxs(R1,{className:"pt-4 px-4 pb-5 gap-1",children:[o,i,a]}),e[6]=o,e[7]=i,e[8]=a,e[9]=l):l=e[9],l}function zD(t){const e=_.c(45),{automationId:n,range:r}=t,s=J(),{data:o,isLoading:i}=u0(n,r),a=o?.runs,l=o?.usage;let c;e[0]!==a?(c=a&&a.total>0?`${Math.round(a.completed/a.total*100)}%`:"—",e[0]=a,e[1]=c):c=e[1];const u=c;let d;e[2]!==s||e[3]!==l?(d=l&&l.truncated?s("automations.automationRuns.lastRunsSubtitle",{count:l.sampledRuns}):void 0,e[2]=s,e[3]=l,e[4]=d):d=e[4];const f=d;let h;e[5]!==s?(h=s("automations.automationRuns.runsTitle"),e[5]=s,e[6]=h):h=e[6];let m;e[7]!==i||e[8]!==a?.total?(m=i?"…":a?.total.toLocaleString()??"0",e[7]=i,e[8]=a?.total,e[9]=m):m=e[9];let y;e[10]!==a||e[11]!==s?(y=a?`${a.completed} ${s("automations.automationRuns.ok")} · ${a.failed} ${s("automations.automationRuns.failed")}${a.inProgress>0?` · ${a.inProgress} ${s("automations.automationRuns.running")}`:""}`:void 0,e[10]=a,e[11]=s,e[12]=y):y=e[12];let g;e[13]!==h||e[14]!==m||e[15]!==y?(g=p.jsx(Qs,{title:h,value:m,subtitle:y}),e[13]=h,e[14]=m,e[15]=y,e[16]=g):g=e[16];let x;e[17]!==s?(x=s("automations.automationRuns.successRateTitle"),e[17]=s,e[18]=x):x=e[18];const b=i?"…":u;let v;e[19]!==x||e[20]!==b?(v=p.jsx(Qs,{title:x,value:b}),e[19]=x,e[20]=b,e[21]=v):v=e[21];let k;e[22]!==s?(k=s("automations.automationRuns.tokensTitle"),e[22]=s,e[23]=k):k=e[23];let N;e[24]!==i||e[25]!==l?.totalTokens?(N=i?"…":u1(l?.totalTokens??0),e[24]=i,e[25]=l?.totalTokens,e[26]=N):N=e[26];let C;e[27]!==k||e[28]!==N||e[29]!==f?(C=p.jsx(Qs,{title:k,value:N,subtitle:f}),e[27]=k,e[28]=N,e[29]=f,e[30]=C):C=e[30];let S;e[31]!==s?(S=s("automations.automationRuns.costTitle"),e[31]=s,e[32]=S):S=e[32];let w;e[33]!==i||e[34]!==l?(w=i?"…":l&&l.costUsd>0?d1(l.costUsd):"—",e[33]=i,e[34]=l,e[35]=w):w=e[35];let M;e[36]!==S||e[37]!==w||e[38]!==f?(M=p.jsx(Qs,{title:S,value:w,subtitle:f}),e[36]=S,e[37]=w,e[38]=f,e[39]=M):M=e[39];let T;return e[40]!==C||e[41]!==M||e[42]!==g||e[43]!==v?(T=p.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[g,v,C,M]}),e[40]=C,e[41]=M,e[42]=g,e[43]=v,e[44]=T):T=e[44],T}function FD(t){const e=_.c(57),{run:n,usage:r,onClick:s,lastRowRef:o}=t,i=J();let a,l;if(e[0]!==n.created_at){const j=new Date(n.created_at);a=j.toLocaleDateString("en-US",{month:"short",day:"numeric"}),l=j.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),e[0]=n.created_at,e[1]=a,e[2]=l}else a=e[1],l=e[2];const c=l;let u,d,f,h,m,y,g,x,b,v,k;if(e[3]!==o||e[4]!==s||e[5]!==n.status||e[6]!==n.title||e[7]!==i){const j=c1(n.status),I=j.icon;d=Of,b=o,v="h-14 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",k=s,e[19]!==n.title?(f=p.jsx(Er,{className:"min-w-0 pr-2 pl-4 md:pr-4",children:p.jsx("div",{className:"font-medium text-foreground truncate",children:n.title})}),e[19]=n.title,e[20]=f):f=e[20],u=Er,x="w-28 px-3",y="flex items-center gap-1.5",g=p.jsx(I,{size:14,className:j.iconClassName}),h=G("text-sm",j.labelColor),m=i(j.labelKey),e[3]=o,e[4]=s,e[5]=n.status,e[6]=n.title,e[7]=i,e[8]=u,e[9]=d,e[10]=f,e[11]=h,e[12]=m,e[13]=y,e[14]=g,e[15]=x,e[16]=b,e[17]=v,e[18]=k}else u=e[8],d=e[9],f=e[10],h=e[11],m=e[12],y=e[13],g=e[14],x=e[15],b=e[16],v=e[17],k=e[18];let N;e[21]!==h||e[22]!==m?(N=p.jsx("span",{className:h,children:m}),e[21]=h,e[22]=m,e[23]=N):N=e[23];let C;e[24]!==N||e[25]!==y||e[26]!==g?(C=p.jsxs("div",{className:y,children:[g,N]}),e[24]=N,e[25]=y,e[26]=g,e[27]=C):C=e[27];let S;e[28]!==u||e[29]!==C||e[30]!==x?(S=p.jsx(u,{className:x,children:C}),e[28]=u,e[29]=C,e[30]=x,e[31]=S):S=e[31];let w;e[32]!==r?(w=r?u1(r.totalTokens):"—",e[32]=r,e[33]=w):w=e[33];let M;e[34]!==w?(M=p.jsx(Er,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:w}),e[34]=w,e[35]=M):M=e[35];let T;e[36]!==r?(T=r&&r.costUsd>0?d1(r.costUsd):"—",e[36]=r,e[37]=T):T=e[37];let O;e[38]!==T?(O=p.jsx(Er,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:T}),e[38]=T,e[39]=O):O=e[39];let A;e[40]!==a?(A=p.jsx("div",{children:a}),e[40]=a,e[41]=A):A=e[41];let P;e[42]!==c?(P=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:c}),e[42]=c,e[43]=P):P=e[43];let D;e[44]!==A||e[45]!==P?(D=p.jsxs(Er,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[A,P]}),e[44]=A,e[45]=P,e[46]=D):D=e[46];let E;return e[47]!==d||e[48]!==f||e[49]!==S||e[50]!==M||e[51]!==O||e[52]!==D||e[53]!==b||e[54]!==v||e[55]!==k?(E=p.jsxs(d,{ref:b,className:v,onClick:k,children:[f,S,M,O,D]}),e[47]=d,e[48]=f,e[49]=S,e[50]=M,e[51]=O,e[52]=D,e[53]=b,e[54]=v,e[55]=k,e[56]=E):E=e[56],E}function SA(t){const e=_.c(73),{automationId:n,triggerIds:r,range:s}=t,o=J(),{org:i,locator:a}=xt();let l;e[0]!==i.id||e[1]!==i.slug?(l={connectionId:t0,orgId:i.id,orgSlug:i.slug},e[0]=i.id,e[1]=i.slug,e[2]=l):l=e[2];const c=gl(l),u=gf(),d=Q1(),f=n0(),{data:h}=i0(),m=r.length>0;let y;e[3]!==n||e[4]!==i.id||e[5]!==r?(y=ht.automationRuns(i.id,n,r),e[3]=n,e[4]=i.id,e[5]=r,e[6]=y):y=e[6];let g;e[7]!==u||e[8]!==r?(g=async Ne=>{const{pageParam:me}=Ne,Ke=me===void 0?0:me;return await u.call("COLLECTION_THREADS_LIST",{limit:hl,offset:Ke,where:{trigger_ids:r}})},e[7]=u,e[8]=r,e[9]=g):g=e[9];let x;e[10]!==m||e[11]!==y||e[12]!==g?(x={queryKey:y,queryFn:g,initialPageParam:0,getNextPageParam:UD,enabled:m,staleTime:3e4},e[10]=m,e[11]=y,e[12]=g,e[13]=x):x=e[13];const{data:b,fetchNextPage:v,hasNextPage:k,isFetchingNextPage:N,isLoading:C}=X1(x);let S,w,M,T;e[14]!==b?.pages||e[15]!==a||e[16]!==s?(S=(b?.pages??[]).flatMap(VD),T=S.map(WD),M=ni,w=ht.monitoringThreadUsage(a,JSON.stringify({ids:T,...s})),e[14]=b?.pages,e[15]=a,e[16]=s,e[17]=S,e[18]=w,e[19]=M,e[20]=T):(S=e[17],w=e[18],M=e[19],T=e[20]);let O;e[21]!==s||e[22]!==u||e[23]!==T?(O=async()=>await u.call("MONITORING_THREAD_USAGE",{threadIds:T,...s.startDate?{startDate:s.startDate}:{},...s.endDate?{endDate:s.endDate}:{}}),e[21]=s,e[22]=u,e[23]=T,e[24]=O):O=e[24];const A=T.length>0;let P;e[25]!==w||e[26]!==O||e[27]!==A?(P={queryKey:w,queryFn:O,enabled:A,staleTime:3e4},e[25]=w,e[26]=O,e[27]=A,e[28]=P):P=e[28];const{data:D}=M(P);let E;e[29]!==D?.items?(E=new Map((D?.items??[]).map(HD)),e[29]=D?.items,e[30]=E):E=e[30];const j=E;let I;e[31]!==v||e[32]!==k||e[33]!==N?(I=()=>{k&&!N&&v()},e[31]=v,e[32]=k,e[33]=N,e[34]=I):I=e[34];const R=Af(I,k??!1,N),z=BD(S),W=z.selected;let q;e[35]!==n||e[36]!==s?(q=p.jsx(zD,{automationId:n,range:s}),e[35]=n,e[36]=s,e[37]=q):q=e[37];let X;e[38]!==m||e[39]!==C||e[40]!==R||e[41]!==S||e[42]!==z||e[43]!==o||e[44]!==j?(X=m?C?p.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:o("automations.automationRuns.loadingRuns")}):S.length===0?p.jsx("div",{className:"py-16",children:p.jsx(Jc,{title:o("automations.automationRuns.noRunsTitle"),description:o("automations.automationRuns.noRunsDescription")})}):p.jsxs(r0,{className:"w-full border-collapse",children:[p.jsx(s0,{className:"border-b-0",children:p.jsxs(Of,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Tr,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:o("automations.automationRuns.runHeader")}),p.jsx(Tr,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:o("automations.automationRuns.statusHeader")}),p.jsx(Tr,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:o("automations.automationRuns.tokensHeader")}),p.jsx(Tr,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:o("automations.automationRuns.costHeader")}),p.jsx(Tr,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:o("automations.automationRuns.startedHeader")})]})}),p.jsx(o0,{children:S.map((Ne,me)=>p.jsx(FD,{run:Ne,usage:j.get(Ne.id),onClick:()=>z.select(Ne.id),lastRowRef:me===S.length-1?R:void 0},Ne.id))})]}):p.jsx("div",{className:"py-16",children:p.jsx(Jc,{title:o("automations.automationRuns.noStartersTitle"),description:o("automations.automationRuns.noStartersDescription")})}),e[38]=m,e[39]=C,e[40]=R,e[41]=S,e[42]=z,e[43]=o,e[44]=j,e[45]=X):X=e[45];let te;e[46]!==N||e[47]!==o?(te=N&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("automations.automationRuns.loadingMore")}),e[46]=N,e[47]=o,e[48]=te):te=e[48];let ae;e[49]!==z?(ae=Ne=>{Ne||z.close()},e[49]=z,e[50]=ae):ae=e[50];let fe;e[51]!==d||e[52]!==f||e[53]!==c||e[54]!==a||e[55]!==h||e[56]!==S||e[57]!==W||e[58]!==z.index||e[59]!==z.next||e[60]!==z.prev?(fe=W&&p.jsx(_D,{thread:W,client:c,locator:a,connections:d,virtualMcps:f,members:h,nav:{index:z.index,total:S.length,onPrev:z.prev,onNext:z.next}}),e[51]=d,e[52]=f,e[53]=c,e[54]=a,e[55]=h,e[56]=S,e[57]=W,e[58]=z.index,e[59]=z.next,e[60]=z.prev,e[61]=fe):fe=e[61];let ce;e[62]!==fe?(ce=p.jsx(Sf,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:fe}),e[62]=fe,e[63]=ce):ce=e[63];let we;e[64]!==z.isOpen||e[65]!==ae||e[66]!==ce?(we=p.jsx(Cf,{open:z.isOpen,onOpenChange:ae,children:ce}),e[64]=z.isOpen,e[65]=ae,e[66]=ce,e[67]=we):we=e[67];let $e;return e[68]!==q||e[69]!==X||e[70]!==te||e[71]!==we?($e=p.jsxs("div",{className:"flex flex-col gap-5",children:[q,X,te,we]}),e[68]=q,e[69]=X,e[70]=te,e[71]=we,e[72]=$e):$e=e[72],$e}function HD(t){return[t.threadId,{calls:t.calls,inputTokens:t.inputTokens,outputTokens:t.outputTokens,totalTokens:t.totalTokens,costUsd:t.costUsd}]}function WD(t){return t.id}function VD(t){return t.items??[]}function UD(t,e){const n=t,r=e;if(!((n?.items?.length??0)<hl))return r.length*hl}export{ql as $,i3 as A,EM as B,Y as C,xe as D,Xl as E,XS as F,wp as G,ex as H,$ as I,F as J,De as K,Mt as L,gi as M,H as N,a3 as O,ay as P,Sh as Q,XO as R,uA as S,V as T,Ul as U,be as V,hk as W,Bp as X,IS as Y,Yk as Z,Jr as _,dm as a,oe as a0,U as a1,eA as a2,nA as a3,GO as a4,fk as a5,tA as a6,u2 as a7,qe as a8,Se as a9,yA as aA,xA as aB,u1 as aC,wD as aD,d1 as aE,kA as aF,vA as aG,bA as aH,ND as aI,BD as aJ,f1 as aK,h1 as aL,p1 as aM,ak as aa,am as ab,im as ac,$2 as ad,rA as ae,kr as af,cA as ag,XN as ah,GN as ai,_D as aj,gA as ak,fM as al,hM as am,dM as an,fA as ao,dA as ap,uM as aq,hA as ar,pM as as,Jn as at,ZO as au,SA as av,c1 as aw,Nc as ax,l1 as ay,OM as az,Ce as b,um as c,sy as d,pe as e,lA as f,wl as g,Kt as h,aA as i,QO as j,oA as k,US as l,iA as m,sA as n,KS as o,oM as p,nm as q,KO as r,Nl as s,ga as t,LS as u,A3 as v,ny as w,pA as x,I3 as y,mA as z};
|