@decocms/mesh 2.20.3 → 2.20.5
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-CI2U-jkN.js → AlertCircle-BRYxEd9U.js} +1 -1
- package/dist/client/assets/{ArrowLeft-B3km7toT.js → ArrowLeft-BQ7IVK5l.js} +1 -1
- package/dist/client/assets/{ArrowUp-BF7mM4C2.js → ArrowUp-BHV7fQvC.js} +1 -1
- package/dist/client/assets/{Check-BQkm1TiP.js → Check-01TyG8gs.js} +1 -1
- package/dist/client/assets/{ChevronDown-DP6jvip7.js → ChevronDown-Bk7OKoGa.js} +1 -1
- package/dist/client/assets/{Code01-qXTn9GK9.js → Code01-dW-GUA8c.js} +1 -1
- package/dist/client/assets/{Copy01-CEYn2daS.js → Copy01-Cci5IJlw.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-C2Nr-D-f.js → DotsHorizontal-B46rT1E7.js} +1 -1
- package/dist/client/assets/{DotsVertical-BPP4U4GQ.js → DotsVertical-BqUSftJK.js} +1 -1
- package/dist/client/assets/{Download01-BkDXja2z.js → Download01-DtRalfBM.js} +1 -1
- package/dist/client/assets/{Edit01-Cq0mQDLh.js → Edit01-gvkP_dl-.js} +1 -1
- package/dist/client/assets/{File06-KMD38I-q.js → File06-ByA_vTun.js} +1 -1
- package/dist/client/assets/{FilterLines-Bojt6HPl.js → FilterLines-GHP-QaK4.js} +1 -1
- package/dist/client/assets/{FlipBackward-C-K9FamE.js → FlipBackward-BS3V82bC.js} +1 -1
- package/dist/client/assets/{GitBranch01-DGTCzEh5.js → GitBranch01-tvqRSCfh.js} +1 -1
- package/dist/client/assets/{Grid01-D4lXvveX.js → Grid01-DlRq7T-9.js} +1 -1
- package/dist/client/assets/{Home02-DPdZvu8L.js → Home02-B_0su9RA.js} +1 -1
- package/dist/client/assets/{Image01-C0R6SF_P.js → Image01-CHyuHHfR.js} +1 -1
- package/dist/client/assets/{Inbox01-BsOUYwQZ.js → Inbox01-BT2JYivP.js} +1 -1
- package/dist/client/assets/{InfoCircle-BgIkbjJr.js → InfoCircle-CVbq8jCi.js} +1 -1
- package/dist/client/assets/{Key01-DTwk4FpG.js → Key01-CR3co8Y_.js} +1 -1
- package/dist/client/assets/{LinkExternal01-DmruqAb9.js → LinkExternal01-DKnd8nXA.js} +1 -1
- package/dist/client/assets/{List-BsSZz32j.js → List-BMChI4Jp.js} +1 -1
- package/dist/client/assets/{Loading01-Ae5ezbtD.js → Loading01-Ciunqme0.js} +1 -1
- package/dist/client/assets/{Lock01-BuQSktMF.js → Lock01-Z2BgitgI.js} +1 -1
- package/dist/client/assets/{Play-DKlNHVjf.js → Play-ftmsq5JK.js} +1 -1
- package/dist/client/assets/{Plus-CdG75X26.js → Plus-Dr1frakx.js} +1 -1
- package/dist/client/assets/{SearchMd-GFaonOaJ.js → SearchMd-BdgkqD1I.js} +1 -1
- package/dist/client/assets/{Terminal-C6mZx-5A.js → Terminal-C6MHBgjq.js} +1 -1
- package/dist/client/assets/{Trash01-BWIN9RL_.js → Trash01-O7XdHeVF.js} +1 -1
- package/dist/client/assets/{Upload01-CaBE4VYK.js → Upload01-oZYrY2i5.js} +1 -1
- package/dist/client/assets/{X-C18ho617.js → X-CBxJpjg0.js} +1 -1
- package/dist/client/assets/{XClose-CfwoKknl.js → XClose-CZV8y02_.js} +1 -1
- package/dist/client/assets/agent-detail-CZykGi9X.js +1 -0
- package/dist/client/assets/agents-C2xykK68.js +1 -0
- package/dist/client/assets/{alert-dialog-CCJCsKzK.js → alert-dialog-VCUJKSC8.js} +1 -1
- package/dist/client/assets/{auth-catchall-C33VWmDE.js → auth-catchall-eqWzQgEV.js} +1 -1
- package/dist/client/assets/{avatar-B7xnPXuk.js → avatar-BTpw67uu.js} +1 -1
- package/dist/client/assets/{badge-BVO6I0sW.js → badge-BBWbP67q.js} +1 -1
- package/dist/client/assets/{binder-By0LBK9Y.js → binder-C7ZGqrKK.js} +1 -1
- package/dist/client/assets/{button-CGmrzkpY.js → button-CSCVKnjE.js} +1 -1
- package/dist/client/assets/{card-DIjMh1NO.js → card-DIp7Pbbe.js} +1 -1
- package/dist/client/assets/{checkbox-DYViXeUc.js → checkbox-B4SYjdp8.js} +1 -1
- package/dist/client/assets/{collection-detail-DtlOJm8P.js → collection-detail-DjOL7Bjs.js} +4 -4
- package/dist/client/assets/{collection-display-button-CtkxsCB_.js → collection-display-button-DJ1AY12f.js} +1 -1
- package/dist/client/assets/{collection-header-B4qcjEt5.js → collection-header-BexgULaJ.js} +1 -1
- package/dist/client/assets/{collection-page-s-RR5fU6.js → collection-page-CFeLb91S.js} +1 -1
- package/dist/client/assets/{collection-search-BVb42O45.js → collection-search-BIaqbS2d.js} +1 -1
- package/dist/client/assets/{collection-tab-CvrhLJCU.js → collection-tab-B6gVlnp1.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-BohFZqii.js → collection-table-wrapper-D_9AP4Xy.js} +1 -1
- package/dist/client/assets/{connection-ChwHK0-S.js → connection-BOiZ4DhB.js} +1 -1
- package/dist/client/assets/{connection-card-DMMfNQUo.js → connection-card-B7L3EvSn.js} +1 -1
- package/dist/client/assets/connection-detail-C63xtruJ.js +1 -0
- package/dist/client/assets/{connections-CRhyn7eO.js → connections-bna1FNR4.js} +1 -1
- package/dist/client/assets/constants-CRHWvr6r.js +1 -0
- package/dist/client/assets/{create-organization-dialog-CtbMd6S_.js → create-organization-dialog-DrPDs6B5.js} +1 -1
- package/dist/client/assets/{dialog-DJJ2cvEE.js → dialog-BKcENWTv.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CAeD2aIb.js → dropdown-menu-6yOcAo_W.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-BeSg8wRq.js → dynamic-plugin-layout-DgPbTvHX.js} +1 -1
- package/dist/client/assets/{empty-state-BkAB-hls.js → empty-state-CKHPbxeg.js} +1 -1
- package/dist/client/assets/{empty-state-wP9uukGJ.js → empty-state-CaPNxgdS.js} +1 -1
- package/dist/client/assets/{env-vars-editor-DuH6BBdA.js → env-vars-editor-DB9sQiDh.js} +1 -1
- package/dist/client/assets/{error-boundary-BUvK8Sry.js → error-boundary-CZ-hRbTW.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BLs0SRok.js → extract-connection-data-xYehFtf9.js} +1 -1
- package/dist/client/assets/{file-browser-DuR45yyf.js → file-browser-BU2xrvlc.js} +2 -2
- package/dist/client/assets/{form-DiGzBnRK.js → form-D-QUdO0s.js} +1 -1
- package/dist/client/assets/{grid-view-Db741zGU.js → grid-view-D1lCA5Sx.js} +1 -1
- package/dist/client/assets/{home-BtJc_wcZ.js → home-B80k-FcM.js} +1 -1
- package/dist/client/assets/{index-Diww4UW3.js → index-BADGsnm_.js} +3 -3
- package/dist/client/assets/{index-DjRWdLI4.js → index-BEzz4Zqk.js} +9 -9
- package/dist/client/assets/{index-DUA-vRuy.js → index-CViGbTGN.js} +1 -1
- package/dist/client/assets/{index-D4QCsSzb.js → index-D4I3u5rj.js} +1 -1
- package/dist/client/assets/{index-CL_rL7XJ.js → index-DGVUoQ0k.js} +65 -65
- package/dist/client/assets/{infiniteQueryObserver-BmbQcWdI.js → infiniteQueryObserver-DoGEx2i9.js} +1 -1
- package/dist/client/assets/{input-CrURMEZe.js → input-BDWPxnpd.js} +1 -1
- package/dist/client/assets/{layout-kp8TTJc9.js → layout-DEupYEZG.js} +1 -1
- package/dist/client/assets/{lazy-highlighter-dN3WcL6s.js → lazy-highlighter-Bn9myoq9.js} +1 -1
- package/dist/client/assets/localstorage-keys-eASnOQ5z.js +1 -0
- package/dist/client/assets/{login-CnuJ6k4x.js → login-H-3KOz_a.js} +1 -1
- package/dist/client/assets/{mcp-oauth-CdcIczUJ.js → mcp-oauth-8-FuZodO.js} +1 -1
- package/dist/client/assets/{mcp-server-card-VZUBDTRj.js → mcp-server-card-jC-20C4W.js} +1 -1
- package/dist/client/assets/{mcp-server-detail-CIR0FKMd.js → mcp-server-detail-C4TwgL7p.js} +1 -1
- package/dist/client/assets/members-BF2WYhNd.js +3 -0
- package/dist/client/assets/{monaco-editor-CDRbE4GY.js → monaco-editor-BDsCepgw.js} +1 -1
- package/dist/client/assets/{monitoring-Cb41cf-X.js → monitoring-1Ei05IVG.js} +15 -15
- package/dist/client/assets/{oauth-callback-z6t0OToi.js → oauth-callback-UV6p5nJu.js} +1 -1
- package/dist/client/assets/page-BXvciBeM.js +21 -0
- package/dist/client/assets/{page-CcKdSzCp.js → page-IRt77uto.js} +1 -1
- package/dist/client/assets/{pin-to-sidebar-button-DIwkO0Tx.js → pin-to-sidebar-button-BfOZ995T.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-B-glkOMH.js → plugin-empty-state-CvCBkNU_.js} +1 -1
- package/dist/client/assets/{plugin-header-BA0z5mBU.js → plugin-header-CT5ofHVa.js} +1 -1
- package/dist/client/assets/{plugins-Cq62fkYj.js → plugins-BM-POIbA.js} +1 -1
- package/dist/client/assets/{popover-Bx7diZ86.js → popover-Bol-owE5.js} +1 -1
- package/dist/client/assets/{project-context-provider-DulCVL2k.js → project-context-provider-BrEPJG0C.js} +1 -1
- package/dist/client/assets/{registry-utils-8Lvx2XTy.js → registry-utils-qr2hWyuD.js} +1 -1
- package/dist/client/assets/{resizable-Gk1RjNnW.js → resizable-5YkDxOnG.js} +1 -1
- package/dist/client/assets/{resource-tabs-ACbF96qo.js → resource-tabs-CoVc7CCV.js} +1 -1
- package/dist/client/assets/{select-C8LOz7vA.js → select-CncHydKl.js} +1 -1
- package/dist/client/assets/{settings-BXJ6BGel.js → settings-DR5TOYQT.js} +1 -1
- package/dist/client/assets/shell-layout-BUa4VNmw.js +3 -0
- package/dist/client/assets/{spinner-BF56RAKQ.js → spinner-CVaIYhex.js} +1 -1
- package/dist/client/assets/{switch-DJBd8Fzb.js → switch-DXIwD9IB.js} +1 -1
- package/dist/client/assets/{textarea-C_zgj3Sp.js → textarea-CjiaCeZv.js} +1 -1
- package/dist/client/assets/{tool-set-selector-B9rTBahU.js → tool-set-selector-NKABlXdy.js} +1 -1
- package/dist/client/assets/{tools-list-mr-l2d8l.js → tools-list-Dlo-5MDO.js} +1 -1
- package/dist/client/assets/{tooltip-Suu_Gpqh.js → tooltip-Dh7pKOjr.js} +1 -1
- package/dist/client/assets/{typewriter-title-DM-oRxie.js → typewriter-title-D71dWYOo.js} +1 -1
- package/dist/client/assets/use-binding-CMrf28mD.js +23 -0
- package/dist/client/assets/{use-collections-CXETocKO.js → use-collections-BYXeN_Z5.js} +1 -1
- package/dist/client/assets/{use-connection-CCXutWLD.js → use-connection-CfZ0Vu4z.js} +1 -1
- package/dist/client/assets/{use-connection-resources-D0st76bP.js → use-connection-resources-DpopeA_b.js} +1 -1
- package/dist/client/assets/use-create-virtual-mcp-DLEcqdBk.js +1 -0
- package/dist/client/assets/{use-list-state-AndcW8aD.js → use-list-state-D02T_aKE.js} +1 -1
- package/dist/client/assets/{use-mcp-D9llr83X.js → use-mcp-BLkJq7bN.js} +1 -1
- package/dist/client/assets/{use-members-CB2ebBfn.js → use-members-v6U7Oi6B.js} +1 -1
- package/dist/client/assets/{use-mobile-DssCtDl6.js → use-mobile-BDBdLYs3.js} +1 -1
- package/dist/client/assets/{use-organization-settings-CQXtXtZs.js → use-organization-settings-BznzPQgX.js} +1 -1
- package/dist/client/assets/{use-tool-call-BmvKn7jp.js → use-tool-call-C-s97CRj.js} +1 -1
- package/dist/client/assets/use-virtual-mcp-BLBflG-l.js +1 -0
- package/dist/client/assets/use-virtual-mcp-system-prompt-XZLo_ZYW.js +1 -0
- package/dist/client/assets/useInfiniteQuery-B1vlCJEQ.js +1 -0
- package/dist/client/assets/{useMutation-Dl1MMkEC.js → useMutation-DX2iB0kT.js} +1 -1
- package/dist/client/assets/useQuery-BloC42s4.js +1 -0
- package/dist/client/assets/{value-DaPOjTmC.js → value-Dzu-joN0.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-BLClM-0g.js → view-mode-toggle-DSycgDld.js} +1 -1
- package/dist/client/assets/{workflow-CQ7PQ7Dg.js → workflow-DaenHlXi.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +156 -156
- package/dist/server/migrate.js +138 -138
- package/dist/server/server.js +152 -152
- package/package.json +1 -1
- package/dist/client/assets/connection-detail-D9bORT-_.js +0 -1
- package/dist/client/assets/constants-J0aH6mLs.js +0 -1
- package/dist/client/assets/gateway-detail-BCBmyW-G.js +0 -1
- package/dist/client/assets/gateways-BgSVXbfx.js +0 -1
- package/dist/client/assets/localstorage-keys-BVANkONM.js +0 -1
- package/dist/client/assets/members-bQTH1spX.js +0 -3
- package/dist/client/assets/page-SWPgLEpC.js +0 -21
- package/dist/client/assets/shell-layout-CFRw9Ru3.js +0 -3
- package/dist/client/assets/use-binding-D6wv_5fO.js +0 -23
- package/dist/client/assets/use-create-gateway-BlLsktgc.js +0 -1
- package/dist/client/assets/use-gateway-DD-xEZju.js +0 -1
- package/dist/client/assets/use-gateway-system-prompt-zGJSEzce.js +0 -1
- package/dist/client/assets/useInfiniteQuery-BttwTOfK.js +0 -1
- package/dist/client/assets/useQuery-Bvk0U2ed.js +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{ag as We,r as O,y as mh,z as lo,c as I,j as m,k as Ci,E as gh,h as yh,d as Et,b as xh,t as Ec,H as ee,F as bh,ah as Tc,$ as kh,Z as Sh,ai as wh,a5 as Mc,aj as Ac,ak as vh,a6 as Ni,a8 as Ge,a7 as Oc,al as Ch,aa as Ei,am as Nh,a3 as Ic,an as Eh,ao as Th,ap as Mh,aq as Ti,ar as Ah,as as Oh,at as Ih,a4 as Rh,au as jh,af as Rc}from"./index-Diww4UW3.js";import{U as qt,c as qe}from"./connection-ChwHK0-S.js";import{E as jc,I as js,n as Dh}from"./empty-state-wP9uukGJ.js";import{E as Dc}from"./error-boundary-BUvK8Sry.js";import{u as Mi,a as Ai}from"./use-collections-CXETocKO.js";import{P as Oi}from"./pin-to-sidebar-button-DIwkO0Tx.js";import{B as me,c as U}from"./button-CGmrzkpY.js";import{F as ao,a as Ph,b as Ii,d as Ri}from"./form-DiGzBnRK.js";import{I as ji}from"./input-CrURMEZe.js";import{T as Ho}from"./textarea-C_zgj3Sp.js";import{b as Lt,T as $t,a as zt,c as _t}from"./tooltip-Suu_Gpqh.js";import{i as Pc}from"./FlipBackward-C-K9FamE.js";import{a as Lc,V as Di,b as Sn}from"./layout-kp8TTJc9.js";import{b as Pi,u as Lh}from"./use-connection-CCXutWLD.js";import{i as $h}from"./AlertCircle-CI2U-jkN.js";import{s as zh,M as On}from"./monaco-editor-CDRbE4GY.js";import{i as _h}from"./Code01-qXTn9GK9.js";import{a as Bh}from"./Copy01-CEYn2daS.js";import{i as tr}from"./Loading01-Ae5ezbtD.js";import{i as Li,n as Fh}from"./Play-DKlNHVjf.js";import{s as $i}from"./XClose-CfwoKknl.js";import{u as Vh,O as Hh,M as Wh,F as qh,v as Uh}from"./index-DjRWdLI4.js";import{u as zi}from"./use-mcp-D9llr83X.js";import{E as _i}from"./empty-state-BkAB-hls.js";import{D as Kh,b as Jh}from"./use-binding-D6wv_5fO.js";import{u as Gh}from"./use-gateway-DD-xEZju.js";import{b as Xh,R as Bl,a as Yh}from"./resizable-Gk1RjNnW.js";import{a as Qh,b as Zh,c as $c,R as ep,d as tp,T as np}from"./index-CL_rL7XJ.js";import{d as rp,b as sp,a as op,c as ip,S as lp}from"./select-C8LOz7vA.js";import{S as Ds}from"./spinner-BF56RAKQ.js";import{V as ap}from"./view-mode-toggle-BLClM-0g.js";import{i as cp}from"./GitBranch01-DGTCzEh5.js";import{a as Bi,b as Fi}from"./use-tool-call-BmvKn7jp.js";import"./project-context-provider-DulCVL2k.js";import{a as dp,D as up,g as fp,f as hp,c as pp,d as mp}from"./dialog-DJJ2cvEE.js";import"./index-D4QCsSzb.js";import{s as zc}from"./Plus-CdG75X26.js";import{i as Vi}from"./Check-BQkm1TiP.js";import{i as gp}from"./DotsHorizontal-C2Nr-D-f.js";import{b as yp,D as xp,a as bp,c as Fl}from"./dropdown-menu-CAeD2aIb.js";import{i as kp}from"./Grid01-D4lXvveX.js";import{B as un}from"./badge-BVO6I0sW.js";import{i as _c}from"./X-C18ho617.js";import"./useMutation-Dl1MMkEC.js";import"./use-organization-settings-CQXtXtZs.js";import"./ArrowLeft-B3km7toT.js";import"./mcp-oauth-CdcIczUJ.js";import"./env-vars-editor-DuH6BBdA.js";import"./Trash01-BWIN9RL_.js";import"./File06-KMD38I-q.js";import"./Key01-DTwk4FpG.js";import"./extract-connection-data-BLs0SRok.js";import"./constants-J0aH6mLs.js";import"./github-icon-Dp3wHhYE.js";import"./registry-utils-8Lvx2XTy.js";import"./generate-id-Dyweu44Y.js";import"./Terminal-C6mZx-5A.js";import"./index-DUA-vRuy.js";import"./useQuery-Bvk0U2ed.js";import"./binder-By0LBK9Y.js";import"./popover-Bx7diZ86.js";import"./ArrowUp-BF7mM4C2.js";import"./ChevronDown-DP6jvip7.js";import"./Edit01-Cq0mQDLh.js";import"./use-gateway-system-prompt-zGJSEzce.js";import"./localstorage-keys-BVANkONM.js";import"./SearchMd-GFaonOaJ.js";import"./use-create-gateway-BlLsktgc.js";import"./Image01-C0R6SF_P.js";import"./alert-dialog-CCJCsKzK.js";import"./well-known-mcp-DOEdYmKO.js";const Bc=We("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);const Fc=We("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const Hi=We("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Wi=We("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const Sp=We("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const wp=We("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Vc=We("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const Hc=We("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const Wc=We("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const qc=We("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const Uc=We("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]),qi=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M12 8v4m0 4h.01M2 8.523v6.954c0 .245 0 .367.028.482a1 1 0 0 0 .12.29c.061.1.148.187.32.36l4.923 4.922c.173.173.26.26.36.322.09.054.188.095.29.12.115.027.237.027.482.027h6.954c.245 0 .367 0 .482-.028a.998.998 0 0 0 .29-.12c.1-.061.187-.148.36-.32l4.922-4.923c.173-.173.26-.26.322-.36a.998.998 0 0 0 .12-.29c.027-.115.027-.237.027-.482V8.523c0-.245 0-.367-.028-.482a.998.998 0 0 0-.12-.29c-.061-.1-.148-.187-.32-.36L16.608 2.47c-.173-.173-.26-.26-.36-.322a1 1 0 0 0-.29-.12C15.844 2 15.722 2 15.477 2H8.523c-.245 0-.367 0-.482.028a1 1 0 0 0-.29.12c-.1.061-.187.148-.36.32L2.47 7.392c-.173.173-.26.26-.322.36a1 1 0 0 0-.12.29C2 8.156 2 8.278 2 8.523Z"}));qi.displayName="AlertOctagon";const Kc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M20.5 8v8.2c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.22 21 17.38 21 15.7 21H8.3c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3.5 18.72 3.5 17.88 3.5 16.2V8m.1-5h16.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C22 3.76 22 4.04 22 4.6v1.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437C21.24 8 20.96 8 20.4 8H3.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C2 7.24 2 6.96 2 6.4V4.6c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C2.76 3 3.04 3 3.6 3Zm6 8.5h4.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C16 12.26 16 12.54 16 13.1v.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437c-.214.109-.494.109-1.054.109H9.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C8 14.74 8 14.46 8 13.9v-.8c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C8.76 11.5 9.04 11.5 9.6 11.5Z"}));Kc.displayName="Box";const Jc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));Jc.displayName="ClockFastForward";const Gc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));Gc.displayName="Code02";const jr=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M6.8 3h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C3 4.52 3 5.08 3 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C4.52 21 5.08 21 6.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C10 19.48 10 18.92 10 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C8.48 3 7.92 3 6.8 3Zm11 0h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C14 4.52 14 5.08 14 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C15.52 21 16.08 21 17.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C21 19.48 21 18.92 21 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C19.48 3 18.92 3 17.8 3Z"}));jr.displayName="Columns01";const Xc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M4 4v1.4c0 3.36 0 5.04.654 6.324a6 6 0 0 0 2.622 2.622C8.56 15 10.24 15 13.6 15H20m0 0-5-5m5 5-5 5"}));Xc.displayName="CornerDownRight";const Yc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M21 5c0 1.657-4.03 3-9 3S3 6.657 3 5m18 0c0-1.657-4.03-3-9-3S3 3.343 3 5m18 0v14c0 1.66-4 3-9 3s-9-1.34-9-3V5m18 7c0 1.66-4 3-9 3s-9-1.34-9-3"}));Yc.displayName="Database01";const Qc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m13 22-3-3m0 0 3-3m-3 3h5a7 7 0 0 0 3-13.326M6 18.326A7 7 0 0 1 9 5h5m0 0-3-3m3 3-3 3"}));Qc.displayName="Repeat03";const Ui=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M15 8H8.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C7 7.24 7 6.96 7 6.4V3m10 18v-6.4c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C16.24 13 15.96 13 15.4 13H8.6c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C7 13.76 7 14.04 7 14.6V21M21 9.325V16.2c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h6.875c.489 0 .733 0 .963.055.204.05.4.13.579.24.201.123.374.296.72.642l3.126 3.126c.346.346.519.519.642.72.11.18.19.374.24.579.055.23.055.474.055.963Z"}));Ui.displayName="Save02";const Zc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M15.631 7.631c-.396-.396-.594-.594-.668-.822a1 1 0 0 1 0-.618c.074-.228.272-.426.668-.822L18.47 2.53a6 6 0 0 0-8.3 6.895c.12.49.179.734.168.888a.849.849 0 0 1-.11.392c-.07.138-.207.274-.48.547L3.5 17.5a2.121 2.121 0 0 0 3 3l6.248-6.248c.273-.273.41-.41.547-.48a.849.849 0 0 1 .392-.11c.154-.011.399.049.888.168a6 6 0 0 0 6.895-8.3l-2.84 2.84c-.396.396-.594.594-.822.668a1 1 0 0 1-.618 0c-.228-.074-.426-.272-.822-.668l-.738-.738Z"}));Zc.displayName="Tool01";const{getOwnPropertyNames:vp,getOwnPropertySymbols:Cp}=Object,{hasOwnProperty:Np}=Object.prototype;function co(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function kr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function Ep(n){return n?.[Symbol.toStringTag]}function Vl(n){return vp(n).concat(Cp(n))}const Tp=Object.hasOwn||((n,e)=>Np.call(n,e));function Yt(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const Mp="__v",Ap="__o",Op="_owner",{getOwnPropertyDescriptor:Hl,keys:Wl}=Object;function Ip(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n),new Uint8Array(e))}function Rp(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function jp(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Dp(n,e){return Yt(n.getTime(),e.getTime())}function Pp(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Lp(n,e){return n===e}function ql(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let d=!1,u=0;for(;(l=c.next())&&!l.done;){if(s[u]){u++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,u,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){d=s[u]=!0;break}u++}if(!d)return!1;a++}return!0}const $p=Yt;function zp(n,e,t){const r=Wl(n);let s=r.length;if(Wl(e).length!==s)return!1;for(;s-- >0;)if(!ed(n,e,t,r[s]))return!1;return!0}function zn(n,e,t){const r=Vl(n);let s=r.length;if(Vl(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!ed(n,e,t,o)||(i=Hl(n,o),l=Hl(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function _p(n,e){return Yt(n.valueOf(),e.valueOf())}function Bp(n,e){return n.source===e.source&&n.flags===e.flags}function Ul(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,d=0;for(;(l=a.next())&&!l.done;){if(!s[d]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[d]=!0;break}d++}if(!c)return!1}return!0}function Br(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Fp(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function ed(n,e,t,r){return(r===Op||r===Ap||r===Mp)&&(n.$$typeof||e.$$typeof)?!0:Tp(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Vp="[object ArrayBuffer]",Hp="[object Arguments]",Wp="[object Boolean]",qp="[object DataView]",Up="[object Date]",Kp="[object Error]",Jp="[object Map]",Gp="[object Number]",Xp="[object Object]",Yp="[object RegExp]",Qp="[object Set]",Zp="[object String]",em={"[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},tm="[object URL]",nm=Object.prototype.toString;function rm({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(g,x,b){if(g===x)return!0;if(g==null||x==null)return!1;const S=typeof g;if(S!==typeof x)return!1;if(S!=="object")return S==="number"?l(g,x,b):S==="function"?o(g,x,b):!1;const v=g.constructor;if(v!==x.constructor)return!1;if(v===Object)return a(g,x,b);if(Array.isArray(g))return e(g,x,b);if(v===Date)return r(g,x,b);if(v===RegExp)return d(g,x,b);if(v===Map)return i(g,x,b);if(v===Set)return u(g,x,b);const k=nm.call(g);if(k===Up)return r(g,x,b);if(k===Yp)return d(g,x,b);if(k===Jp)return i(g,x,b);if(k===Qp)return u(g,x,b);if(k===Xp)return typeof g.then!="function"&&typeof x.then!="function"&&a(g,x,b);if(k===tm)return h(g,x,b);if(k===Kp)return s(g,x,b);if(k===Hp)return a(g,x,b);if(em[k])return f(g,x,b);if(k===Vp)return n(g,x,b);if(k===qp)return t(g,x,b);if(k===Wp||k===Gp||k===Zp)return c(g,x,b);if(p){let w=p[k];if(!w){const C=Ep(g);C&&(w=p[C])}if(w)return w(g,x,b)}return!1}}function sm({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:Ip,areArraysEqual:t?zn:Rp,areDataViewsEqual:jp,areDatesEqual:Dp,areErrorsEqual:Pp,areFunctionsEqual:Lp,areMapsEqual:t?co(ql,zn):ql,areNumbersEqual:$p,areObjectsEqual:t?zn:zp,arePrimitiveWrappersEqual:_p,areRegExpsEqual:Bp,areSetsEqual:t?co(Ul,zn):Ul,areTypedArraysEqual:t?co(Br,zn):Br,areUrlsEqual:Fp,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=kr(r.areArraysEqual),o=kr(r.areMapsEqual),i=kr(r.areObjectsEqual),l=kr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function om(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function im({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:d}=t();return e(l,a,{cache:c,equals:r,meta:d,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const lm=Tt();Tt({strict:!0});Tt({circular:!0});Tt({circular:!0,strict:!0});Tt({createInternalComparator:()=>Yt});Tt({strict:!0,createInternalComparator:()=>Yt});Tt({circular:!0,createInternalComparator:()=>Yt});Tt({circular:!0,createInternalComparator:()=>Yt,strict:!0});function Tt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=sm(n),i=rm(o),l=t?t(i):om(i);return im({circular:e,comparator:i,createState:r,equals:l,strict:s})}mh({title:lo().min(1),description:lo().nullable(),body:lo()});function uo(n){for(const e of n.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function am(){const n=window.location.pathname.split("/").filter(Boolean),e=n.findIndex(r=>r==="mcps"),t=e>=0?n[e+1]:void 0;return t?decodeURIComponent(t):void 0}function cm(n){const e=I.c(13),{form:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Details"}),e[0]=r):r=e[0];let s;e[1]!==t.control?(s=m.jsxs("div",{className:"flex flex-col gap-4",children:[r,m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[m.jsx(ao,{control:t.control,name:"title",render:fm}),m.jsx(ao,{control:t.control,name:"description",render:um})]})]}),e[1]=t.control,e[2]=s):s=e[2];let o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Message"}),i=m.jsx("div",{className:"text-xs text-muted-foreground",children:"This becomes the user message in the prompt."}),e[3]=o,e[4]=i):(o=e[3],i=e[4]);let l;e[5]!==t.control?(l=m.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,m.jsx(ao,{control:t.control,name:"body",render:dm})]}),e[5]=t.control,e[6]=l):l=e[6];let a;e[7]!==s||e[8]!==l?(a=m.jsxs("div",{className:"h-full py-6 flex flex-col max-w-3xl mx-auto w-full min-w-0 gap-8 overflow-y-auto px-4",children:[s,l]}),e[7]=s,e[8]=l,e[9]=a):a=e[9];let c;return e[10]!==t||e[11]!==a?(c=m.jsx(Ph,{...t,children:a}),e[10]=t,e[11]=a,e[12]=c):c=e[12],c}function dm(n){const{field:e}=n;return m.jsx(Ii,{children:m.jsx(Ri,{children:m.jsx(Ho,{...e,value:e.value??"",placeholder:"Write the prompt message…",className:"min-h-[240px] resize-none text-base leading-relaxed font-normal rounded-xl border border-border bg-muted/20 px-4 py-3 shadow-none focus-visible:ring-0"})})})}function um(n){const{field:e}=n;return m.jsxs(Ii,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),m.jsx(Ri,{children:m.jsx(ji,{...e,value:e.value??"",placeholder:"Add a description…",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function fm(n){const{field:e}=n;return m.jsxs(Ii,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),m.jsx(Ri,{children:m.jsx(ji,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function hm(n){const e=I.c(51),{providerId:t,promptId:r,onBack:s}=n,i=Ci().location.href,l=t||qt;let a;e[0]!==l?(a=qe(l),e[0]=l,e[1]=a):a=e[1];const c=a,d=Mi(t,"PROMPT",r,c),u=Ai(t,"PROMPT",c),f=u.update.isPending;let h;e[2]!==d?(h=d?{title:d.title,description:d.description??null,body:uo(d)}:void 0,e[2]=d,e[3]=h):h=e[3];let p;e[4]!==h?(p={values:h},e[4]=h,e[5]=p):p=e[5];const y=gh(p);let g;e[6]!==y||e[7]!==d?(g=()=>{d&&y.reset({title:d.title,description:d.description??null,body:uo(d)})},e[6]=y,e[7]=d,e[8]=g):g=e[8];const x=g;let b;e[9]!==u.update||e[10]!==y||e[11]!==r?(b=y.handleSubmit(async X=>{const fe=await u.update.mutateAsync({id:r,data:{title:X.title,description:X.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:X.body}}]}});y.reset({title:fe.title,description:fe.description??null,body:uo(fe)})}),e[9]=u.update,e[10]=y,e[11]=r,e[12]=b):b=e[12];const S=b;if(!d){let X;return e[13]===Symbol.for("react.memo_cache_sentinel")?(X=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(jc,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=X):X=e[13],X}let v;e[14]!==d.title?(v=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:d.title}),e[14]=d.title,e[15]=v):v=e[15];let k;e[16]!==d.description?(k=d.description?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:d.description})]}):null,e[16]=d.description,e[17]=k):k=e[17];let w;e[18]!==v||e[19]!==k?(w=m.jsx(Lc,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[v,k]})}),e[18]=v,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==d.title||e[22]!==i?(C=m.jsx(Oi,{title:d.title,url:i,icon:"description"}),e[21]=d.title,e[22]=i,e[23]=C):C=e[23];const T=!y.formState.isDirty||f;let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=m.jsx(Pc,{size:14}),e[24]=A):A=e[24];let D;e[25]!==x||e[26]!==T?(D=m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:T,onClick:x,"aria-label":"Cancel",children:A})})}),e[25]=x,e[26]=T,e[27]=D):D=e[27];let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=m.jsx($t,{side:"bottom",children:"Cancel"}),e[28]=j):j=e[28];let _;e[29]!==D?(_=m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[D,j]})}),e[29]=D,e[30]=_):_=e[30];const V=!y.formState.isDirty||f;let B;e[31]!==S?(B=()=>{S()},e[31]=S,e[32]=B):B=e[32];let H;e[33]===Symbol.for("react.memo_cache_sentinel")?(H=m.jsx(Ui,{size:14}),e[33]=H):H=e[33];let N;e[34]!==V||e[35]!==B?(N=m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:V,onClick:B,"aria-label":"Save",children:H})})}),e[34]=V,e[35]=B,e[36]=N):N=e[36];let z;e[37]===Symbol.for("react.memo_cache_sentinel")?(z=m.jsx($t,{side:"bottom",children:"Save"}),e[37]=z):z=e[37];let P;e[38]!==N?(P=m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[N,z]})}),e[38]=N,e[39]=P):P=e[39];let K;e[40]!==C||e[41]!==_||e[42]!==P?(K=m.jsxs(Di,{children:[C,_,P]}),e[40]=C,e[41]=_,e[42]=P,e[43]=K):K=e[43];let Q;e[44]!==y?(Q=m.jsx("div",{className:"h-full",children:m.jsx(cm,{form:y})}),e[44]=y,e[45]=Q):Q=e[45];let le;return e[46]!==s||e[47]!==K||e[48]!==Q||e[49]!==w?(le=m.jsxs(Sn,{onBack:s,children:[w,K,Q]}),e[46]=s,e[47]=K,e[48]=Q,e[49]=w,e[50]=le):le=e[50],le}function pm(n){const e=I.c(5),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=am()??qt,e[0]=s):s=e[0];const o=s;if(!o||o===qt){let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(jc,{title:"Prompt not found",description:"Missing connection information in the current route."})}),e[1]=l):l=e[1],l}let i;return e[2]!==t||e[3]!==r?(i=m.jsx(Dc,{children:m.jsx(O.Suspense,{fallback:null,children:m.jsx(hm,{providerId:o,promptId:t,onBack:r})})}),e[2]=t,e[3]=r,e[4]=i):i=e[4],i}const mm=yh("relative w-full rounded-lg border px-4 py-3 text-sm flex items-start gap-3 [&>svg]:size-4 [&>svg]:flex-shrink-0 [&>svg]:mt-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-destructive/5 text-destructive border-destructive/25 [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-warning/10 text-warning-foreground border-warning [&>svg]:text-current *:data-[slot=alert-description]:text-warning-foreground/90",success:"bg-success/10 text-success-foreground border-success [&>svg]:text-current *:data-[slot=alert-description]:text-success-foreground/90",info:"bg-card text-card-foreground border-border [&>svg]:text-current *:data-[slot=alert-description]:text-muted-foreground/90"}},defaultVariants:{variant:"default"}});function gm(n){const e=I.c(10);let t,r,s;e[0]!==n?({className:t,variant:s,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==t||e[5]!==s?(o=U(mm({variant:s}),t),e[4]=t,e[5]=s,e[6]=o):o=e[6];let i;return e[7]!==r||e[8]!==o?(i=m.jsx("div",{"data-slot":"alert",role:"alert",className:o,...r}),e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function ym(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("line-clamp-1 min-h-4 font-medium tracking-tight",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-title",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function xm(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("text-muted-foreground leading-relaxed",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-description",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}const bm=n=>n.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function km(n){const e=I.c(13),{toolName:t,connectionId:r,onBack:s}=n,o=`/mcp/${r}`;let i;e[0]!==o?(i=new URL(o,window.location.origin),e[0]=o,e[1]=i):i=e[1];const l=i;let a;e[2]!==r?(a={connectionId:r},e[2]=r,e[3]=a):a=e[3];const c=Vh(a);if(!c.isAuthenticated){let f;return e[4]!==c.supportsOAuth||e[5]!==s?(f=m.jsx("div",{className:"flex h-full items-center justify-center",children:c.supportsOAuth?m.jsx(Hh,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):m.jsx(Wh,{hasReadme:!1})}),e[4]=c.supportsOAuth,e[5]=s,e[6]=f):f=e[6],f}const d=`${r}:${t}`;let u;return e[7]!==r||e[8]!==l||e[9]!==s||e[10]!==d||e[11]!==t?(u=m.jsx(Sm,{toolName:t,connectionId:r,mcpProxyUrl:l,onBack:s},d),e[7]=r,e[8]=l,e[9]=s,e[10]=d,e[11]=t,e[12]=u):u=e[12],u}function Sm({toolName:n,connectionId:e,mcpProxyUrl:t,onBack:r}){const o=Ci().location.href,{replayId:i}=xh({strict:!1}),l=(()=>{if(!i)return null;const N=`replay-${i}`,z=sessionStorage.getItem(N);if(!z)return null;sessionStorage.removeItem(N);try{return JSON.parse(z)}catch{return null}})(),a=(()=>{if(!l)return null;const N={};for(const[z,P]of Object.entries(l))P!==null&&typeof P=="object"?N[z]=JSON.stringify(P,null,2):N[z]=P;return N})(),[c,d]=O.useState(a??{}),[u,f]=O.useState(l?JSON.stringify(l,null,2):"{}"),[h,p]=O.useState(null),[y,g]=O.useState(null),[x,b]=O.useState(!1),[S,v]=O.useState(null),k=Pi(e),w=zi({url:t.href});O.useEffect(()=>{w.error&&console.error("MCP Error:",w.error)},[w.error]);const C=w.tools?.find(N=>N.name===n),T=C?.inputSchema?.properties,A=T?Object.keys(T):[],D=A.length>0,j={};if(D&&C?.inputSchema?.properties)for(const N of A)j[N]=C.inputSchema.required?.includes(N)?"":void 0;const _=N=>Object.prototype.hasOwnProperty.call(c,N),V=async()=>{b(!0),g(null),p(null),v(null);const N=performance.now(),z=qe(e);try{const P=D?{...j,...c}:(()=>{const se=u.trim();if(!se)return{};const J=JSON.parse(se);if(J&&typeof J=="object")return J;throw new Error("Raw JSON input must be an object.")})();D&&C?.inputSchema?.properties&&Object.entries(C.inputSchema.properties).forEach(([se,J])=>{if((J.type==="object"||J.type==="array")&&typeof P[se]=="string")try{P[se]=JSON.parse(P[se])}catch{}});const K=await z(n,P),Q=performance.now(),le=Math.round(Q-N);p(K);const X=JSON.stringify(K),fe=new TextEncoder().encode(X).length;v({duration:`${le}ms`,bytes:`${fe} bytes`,tokens:`~${Math.ceil(fe/4)} tokens`,cost:"$0.0000"})}catch(P){const K=P instanceof Error?P.message:String(P);g(K||"Unknown error occurred");const Q=performance.now();v({duration:`${Math.round(Q-N)}ms`})}finally{b(!1)}},B=(N,z)=>{d(P=>({...P,[N]:z}))},H=()=>{p(null),g(null),v(null)};return m.jsxs(Sn,{onBack:r,children:[m.jsx(Di,{children:m.jsx(Oi,{title:C?.name??bm(n),url:o,icon:"build"})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 h-full",children:[m.jsx("div",{className:"flex flex-col border-r border-border overflow-hidden",children:m.jsxs("div",{className:"flex-1 overflow-auto",children:[m.jsx("div",{className:"flex flex-col gap-4 p-6 border-b border-border min-h-28",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(js,{icon:k?.icon||null,name:k?.title||n,size:"sm",className:"shadow-sm shrink-0"}),m.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:n}),m.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[w.state==="ready"?m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):w.state==="connecting"?m.jsx(tr,{size:10,className:"animate-spin text-yellow-500 shrink-0"}):m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}),m.jsx("span",{className:"font-mono text-xs capitalize text-muted-foreground leading-none",children:w.state.replace("_"," ")})]})]}),m.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:C?.description||"No description available"})]})}),m.jsxs("div",{className:"flex flex-col p-6 gap-4",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h2",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"Parameters"}),C?.inputSchema?.required&&C.inputSchema.required.length>0&&m.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.jsx("span",{className:"text-red-500",children:"*"})," Required"]})]}),m.jsx("div",{className:"space-y-4",children:D&&C?.inputSchema?.properties?Object.entries(C.inputSchema.properties).map(([N,z])=>m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("label",{className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[N,C.inputSchema?.required?.includes(N)&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),m.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:z.type})]}),z.description&&m.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:z.description}),z.type==="object"||z.type==="array"?m.jsx(Ho,{className:"font-mono text-xs",value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N} as JSON...`,rows:3}):m.jsx(ji,{value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N}...`})]},N)):C?.inputSchema&&!D?m.jsxs("div",{className:"space-y-2",children:[m.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),m.jsx(Ho,{className:"font-mono text-xs min-h-[120px]",value:u,onChange:N=>f(N.target.value),placeholder:'e.g. { "foo": "bar" }'})]}):m.jsx("div",{className:"flex items-center justify-center p-8 bg-muted/30 rounded-lg border border-dashed border-border",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No parameters required"})})})]})]})}),m.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-14 border-t lg:border-t-0 border-b border-border bg-background",children:[m.jsx("h2",{className:"text-sm font-medium text-foreground uppercase tracking-wide",children:"Result"}),S&&m.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(zh,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.duration})]}),S.tokens&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Kc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.tokens})]}),S.bytes&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Yc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.bytes})]}),S.cost&&m.jsx("div",{className:"flex items-center gap-1.5",children:m.jsx("span",{className:"font-mono text-foreground",children:S.cost})})]})]}),m.jsx("div",{className:"flex items-center justify-end lg:justify-between px-4 h-14 border-b border-border bg-background",children:m.jsxs("div",{className:"flex items-center gap-2 w-full lg:w-auto",children:[m.jsx(me,{size:"sm",variant:"default",className:"h-8 gap-2 flex-1 lg:flex-none",onClick:V,disabled:x,children:x?m.jsxs(m.Fragment,{children:[m.jsx(tr,{size:14,className:"animate-spin"}),"Executing..."]}):m.jsxs(m.Fragment,{children:[m.jsx(Li,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),m.jsx(zt,{children:m.jsxs(_t,{children:[m.jsx(Lt,{asChild:!0,children:m.jsx(me,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:H,disabled:!h&&!y,children:m.jsx($i,{size:14})})}),m.jsx($t,{children:m.jsx("p",{children:"Clear results"})})]})})]})}),y&&m.jsx("div",{className:"px-6 py-4 bg-background",children:m.jsx(gm,{variant:"destructive",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx($h,{className:"h-4 w-4"}),m.jsx(ym,{className:"mb-0",children:"Execution Failed"})]}),m.jsx(xm,{className:"text-xs text-destructive",children:y})]})})}),m.jsx("div",{className:"relative flex-1 overflow-auto bg-muted/50",children:h?m.jsxs(m.Fragment,{children:[m.jsx(On,{code:JSON.stringify(h,null,2),language:"json",height:"100%",readOnly:!0}),m.jsx(me,{size:"icon",variant:"ghost",className:"absolute top-4 right-4 h-8 w-8 bg-background/80 hover:bg-background border border-border shadow-sm",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(h,null,2)),Ec.success("Copied to clipboard")},children:m.jsx(Bh,{className:"h-3.5 w-3.5"})})]}):m.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground",children:[m.jsx(_h,{className:"h-12 w-12 mb-3 opacity-40"}),m.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function wm(n){const e=I.c(7),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=Et(s).connectionId??qt;if(!Pi(i)){let d;return e[1]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[m.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=d):d=e[1],d}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(tr,{size:32,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let c;return e[3]!==i||e[4]!==r||e[5]!==t?(c=m.jsx(O.Suspense,{fallback:a,children:m.jsx(km,{toolName:t,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=t,e[6]=c):c=e[6],c}const Kl=n=>{let e;const t=new Set,r=(c,d)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const f=e;e=d??(typeof u!="object"||u===null)?u:Object.assign({},e,u),t.forEach(h=>h(e,f))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>a,subscribe:c=>(t.add(c),()=>t.delete(c))},a=e=n(r,s,l);return l},Ki=(n=>n?Kl(n):Kl),vm=n=>n;function Wo(n,e=vm){const t=ee.useSyncExternalStore(n.subscribe,ee.useCallback(()=>e(n.getState()),[n,e]),ee.useCallback(()=>e(n.getInitialState()),[n,e]));return ee.useDebugValue(t),t}const Cm=n=>{const e=Ki(n),t=r=>Wo(e,r);return Object.assign(t,e),t},Nm=(n=>Cm);function td(n,e){let t;try{t=n()}catch{return}return{getItem:s=>{var o;const i=a=>a===null?null:JSON.parse(a,void 0),l=(o=t.getItem(s))!=null?o:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,o)=>t.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>t.removeItem(s)}}const qo=n=>e=>{try{const t=n(e);return t instanceof Promise?t:{then(r){return qo(r)(t)},catch(r){return this}}}catch(t){return{then(r){return this},catch(r){return qo(r)(t)}}}},Em=(n,e)=>(t,r,s)=>{let o={storage:td(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...e},i=!1,l=0;const a=new Set,c=new Set;let d=o.storage;if(!d)return n((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),t(...g)},r,s);const u=()=>{const g=o.partialize({...r()});return d.setItem(o.name,{state:g,version:o.version})},f=s.setState;s.setState=(g,x)=>(f(g,x),u());const h=n((...g)=>(t(...g),u()),r,s);s.getInitialState=()=>h;let p;const y=()=>{var g,x;if(!d)return;const b=++l;i=!1,a.forEach(v=>{var k;return v((k=r())!=null?k:h)});const S=((x=o.onRehydrateStorage)==null?void 0:x.call(o,(g=r())!=null?g:h))||void 0;return qo(d.getItem.bind(d))(o.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==o.version){if(o.migrate){const k=o.migrate(v.state,v.version);return k instanceof Promise?k.then(w=>[!0,w]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var k;if(b!==l)return;const[w,C]=v;if(p=o.merge(C,(k=r())!=null?k:h),t(p,!0),w)return u()}).then(()=>{b===l&&(S?.(p,void 0),p=r(),i=!0,c.forEach(v=>v(p)))}).catch(v=>{b===l&&S?.(void 0,v)})};return s.persist={setOptions:g=>{o={...o,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>y(),hasHydrated:()=>i,onHydrate:g=>(a.add(g),()=>{a.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},o.skipHydration||y(),p||h},nd=Em,{useSyncExternalStoreWithSelector:Tm}=bh,Mm=n=>n;function Am(n,e=Mm,t){const r=Tm(n.subscribe,n.getState,n.getInitialState,e,t);return ee.useDebugValue(r),r}const Jl=n=>Symbol.iterator in n,Gl=n=>"entries"in n,Xl=(n,e)=>{const t=n instanceof Map?n:new Map(n.entries()),r=e instanceof Map?e:new Map(e.entries());if(t.size!==r.size)return!1;for(const[s,o]of t)if(!r.has(s)||!Object.is(o,r.get(s)))return!1;return!0},Om=(n,e)=>{const t=n[Symbol.iterator](),r=e[Symbol.iterator]();let s=t.next(),o=r.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=t.next(),o=r.next()}return!!s.done&&!!o.done};function Im(n,e){return Object.is(n,e)?!0:typeof n!="object"||n===null||typeof e!="object"||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e)?!1:Jl(n)&&Jl(e)?Gl(n)&&Gl(e)?Xl(n,e):Om(n,e):Xl({entries:()=>Object.entries(n)},{entries:()=>Object.entries(e)})}function Rm(n,e="Output"){if(!n)return`interface ${e} {}`;function t(o){if(!o||typeof o!="object")return"unknown";const i=o.type;if(Array.isArray(i))return i.map(l=>r(l)).join(" | ");switch(i){case"string":return o.enum?o.enum.map(l=>`"${l}"`).join(" | "):"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":{const l=o.items;return l?`${t(l)}[]`:"unknown[]"}case"object":return s(o);default:return o.anyOf?o.anyOf.map(t).join(" | "):o.oneOf?o.oneOf.map(t).join(" | "):o.allOf?o.allOf.map(t).join(" & "):"unknown"}}function r(o){switch(o){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";default:return"unknown"}}function s(o){const i=o.properties;if(!i)return"Record<string, unknown>";const l=new Set(o.required||[]);return`{
|
|
1
|
+
import{ag as We,r as O,y as mh,z as lo,c as I,j as m,k as Ci,E as gh,h as yh,d as Et,b as xh,t as Ec,H as ee,F as bh,ah as Tc,$ as kh,Z as Sh,ai as wh,a5 as Mc,aj as Ac,ak as vh,a6 as Ni,a8 as Ge,a7 as Oc,al as Ch,aa as Ei,am as Nh,a3 as Ic,an as Eh,ao as Th,ap as Mh,aq as Ti,ar as Ah,as as Oh,at as Ih,a4 as Rh,au as jh,af as Rc}from"./index-BADGsnm_.js";import{U as qt,c as qe}from"./connection-BOiZ4DhB.js";import{E as jc,I as js,n as Dh}from"./empty-state-CaPNxgdS.js";import{E as Dc}from"./error-boundary-CZ-hRbTW.js";import{u as Mi,a as Ai}from"./use-collections-BYXeN_Z5.js";import{P as Oi}from"./pin-to-sidebar-button-BfOZ995T.js";import{B as me,c as U}from"./button-CSCVKnjE.js";import{F as ao,a as Ph,b as Ii,d as Ri}from"./form-D-QUdO0s.js";import{I as ji}from"./input-BDWPxnpd.js";import{T as Ho}from"./textarea-CjiaCeZv.js";import{b as Lt,T as $t,a as zt,c as _t}from"./tooltip-Dh7pKOjr.js";import{i as Pc}from"./FlipBackward-BS3V82bC.js";import{a as Lc,V as Di,b as Sn}from"./layout-DEupYEZG.js";import{b as Pi,u as Lh}from"./use-connection-CfZ0Vu4z.js";import{i as $h}from"./AlertCircle-BRYxEd9U.js";import{s as zh,M as On}from"./monaco-editor-BDsCepgw.js";import{i as _h}from"./Code01-dW-GUA8c.js";import{a as Bh}from"./Copy01-Cci5IJlw.js";import{i as tr}from"./Loading01-Ciunqme0.js";import{i as Li,n as Fh}from"./Play-ftmsq5JK.js";import{s as $i}from"./XClose-CZV8y02_.js";import{u as Vh,O as Hh,M as Wh,F as qh,v as Uh}from"./index-BEzz4Zqk.js";import{u as zi}from"./use-mcp-BLkJq7bN.js";import{E as _i}from"./empty-state-CKHPbxeg.js";import{D as Kh,b as Jh}from"./use-binding-CMrf28mD.js";import{u as Gh}from"./use-virtual-mcp-BLBflG-l.js";import{b as Xh,R as Bl,a as Yh}from"./resizable-5YkDxOnG.js";import{b as Qh,c as Zh,d as $c,R as ep,e as tp,T as np}from"./index-DGVUoQ0k.js";import{d as rp,b as sp,a as op,c as ip,S as lp}from"./select-CncHydKl.js";import{S as Ds}from"./spinner-CVaIYhex.js";import{V as ap}from"./view-mode-toggle-DSycgDld.js";import{i as cp}from"./GitBranch01-tvqRSCfh.js";import{a as Bi,b as Fi}from"./use-tool-call-C-s97CRj.js";import"./project-context-provider-BrEPJG0C.js";import{a as dp,D as up,g as fp,f as hp,c as pp,d as mp}from"./dialog-BKcENWTv.js";import"./index-D4I3u5rj.js";import{s as zc}from"./Plus-Dr1frakx.js";import{i as Vi}from"./Check-01TyG8gs.js";import{i as gp}from"./DotsHorizontal-B46rT1E7.js";import{b as yp,D as xp,a as bp,c as Fl}from"./dropdown-menu-6yOcAo_W.js";import{i as kp}from"./Grid01-DlRq7T-9.js";import{B as un}from"./badge-BBWbP67q.js";import{i as _c}from"./X-CBxJpjg0.js";import"./useMutation-DX2iB0kT.js";import"./use-organization-settings-BznzPQgX.js";import"./ArrowLeft-BQ7IVK5l.js";import"./mcp-oauth-8-FuZodO.js";import"./env-vars-editor-DB9sQiDh.js";import"./Trash01-O7XdHeVF.js";import"./File06-ByA_vTun.js";import"./Key01-CR3co8Y_.js";import"./extract-connection-data-xYehFtf9.js";import"./constants-CRHWvr6r.js";import"./github-icon-Dp3wHhYE.js";import"./registry-utils-qr2hWyuD.js";import"./generate-id-Dyweu44Y.js";import"./Terminal-C6MHBgjq.js";import"./index-CViGbTGN.js";import"./useQuery-BloC42s4.js";import"./binder-C7ZGqrKK.js";import"./popover-Bol-owE5.js";import"./ArrowUp-BHV7fQvC.js";import"./ChevronDown-Bk7OKoGa.js";import"./Edit01-gvkP_dl-.js";import"./use-virtual-mcp-system-prompt-XZLo_ZYW.js";import"./localstorage-keys-eASnOQ5z.js";import"./SearchMd-BdgkqD1I.js";import"./use-create-virtual-mcp-DLEcqdBk.js";import"./Image01-CHyuHHfR.js";import"./alert-dialog-VCUJKSC8.js";import"./well-known-mcp-DOEdYmKO.js";const Bc=We("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);const Fc=We("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const Hi=We("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Wi=We("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const Sp=We("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const wp=We("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Vc=We("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const Hc=We("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const Wc=We("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const qc=We("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const Uc=We("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]),qi=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M12 8v4m0 4h.01M2 8.523v6.954c0 .245 0 .367.028.482a1 1 0 0 0 .12.29c.061.1.148.187.32.36l4.923 4.922c.173.173.26.26.36.322.09.054.188.095.29.12.115.027.237.027.482.027h6.954c.245 0 .367 0 .482-.028a.998.998 0 0 0 .29-.12c.1-.061.187-.148.36-.32l4.922-4.923c.173-.173.26-.26.322-.36a.998.998 0 0 0 .12-.29c.027-.115.027-.237.027-.482V8.523c0-.245 0-.367-.028-.482a.998.998 0 0 0-.12-.29c-.061-.1-.148-.187-.32-.36L16.608 2.47c-.173-.173-.26-.26-.36-.322a1 1 0 0 0-.29-.12C15.844 2 15.722 2 15.477 2H8.523c-.245 0-.367 0-.482.028a1 1 0 0 0-.29.12c-.1.061-.187.148-.36.32L2.47 7.392c-.173.173-.26.26-.322.36a1 1 0 0 0-.12.29C2 8.156 2 8.278 2 8.523Z"}));qi.displayName="AlertOctagon";const Kc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M20.5 8v8.2c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.22 21 17.38 21 15.7 21H8.3c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3.5 18.72 3.5 17.88 3.5 16.2V8m.1-5h16.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C22 3.76 22 4.04 22 4.6v1.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437C21.24 8 20.96 8 20.4 8H3.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C2 7.24 2 6.96 2 6.4V4.6c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C2.76 3 3.04 3 3.6 3Zm6 8.5h4.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C16 12.26 16 12.54 16 13.1v.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437c-.214.109-.494.109-1.054.109H9.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C8 14.74 8 14.46 8 13.9v-.8c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C8.76 11.5 9.04 11.5 9.6 11.5Z"}));Kc.displayName="Box";const Jc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));Jc.displayName="ClockFastForward";const Gc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));Gc.displayName="Code02";const jr=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M6.8 3h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C3 4.52 3 5.08 3 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C4.52 21 5.08 21 6.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C10 19.48 10 18.92 10 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C8.48 3 7.92 3 6.8 3Zm11 0h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C14 4.52 14 5.08 14 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C15.52 21 16.08 21 17.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C21 19.48 21 18.92 21 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C19.48 3 18.92 3 17.8 3Z"}));jr.displayName="Columns01";const Xc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M4 4v1.4c0 3.36 0 5.04.654 6.324a6 6 0 0 0 2.622 2.622C8.56 15 10.24 15 13.6 15H20m0 0-5-5m5 5-5 5"}));Xc.displayName="CornerDownRight";const Yc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M21 5c0 1.657-4.03 3-9 3S3 6.657 3 5m18 0c0-1.657-4.03-3-9-3S3 3.343 3 5m18 0v14c0 1.66-4 3-9 3s-9-1.34-9-3V5m18 7c0 1.66-4 3-9 3s-9-1.34-9-3"}));Yc.displayName="Database01";const Qc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"m13 22-3-3m0 0 3-3m-3 3h5a7 7 0 0 0 3-13.326M6 18.326A7 7 0 0 1 9 5h5m0 0-3-3m3 3-3 3"}));Qc.displayName="Repeat03";const Ui=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M15 8H8.6c-.56 0-.84 0-1.054-.109a1 1 0 0 1-.437-.437C7 7.24 7 6.96 7 6.4V3m10 18v-6.4c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C16.24 13 15.96 13 15.4 13H8.6c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C7 13.76 7 14.04 7 14.6V21M21 9.325V16.2c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h6.875c.489 0 .733 0 .963.055.204.05.4.13.579.24.201.123.374.296.72.642l3.126 3.126c.346.346.519.519.642.72.11.18.19.374.24.579.055.23.055.474.055.963Z"}));Ui.displayName="Save02";const Zc=({size:n=24,color:e="currentColor",...t})=>O.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},O.createElement("path",{d:"M15.631 7.631c-.396-.396-.594-.594-.668-.822a1 1 0 0 1 0-.618c.074-.228.272-.426.668-.822L18.47 2.53a6 6 0 0 0-8.3 6.895c.12.49.179.734.168.888a.849.849 0 0 1-.11.392c-.07.138-.207.274-.48.547L3.5 17.5a2.121 2.121 0 0 0 3 3l6.248-6.248c.273-.273.41-.41.547-.48a.849.849 0 0 1 .392-.11c.154-.011.399.049.888.168a6 6 0 0 0 6.895-8.3l-2.84 2.84c-.396.396-.594.594-.822.668a1 1 0 0 1-.618 0c-.228-.074-.426-.272-.822-.668l-.738-.738Z"}));Zc.displayName="Tool01";const{getOwnPropertyNames:vp,getOwnPropertySymbols:Cp}=Object,{hasOwnProperty:Np}=Object.prototype;function co(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function kr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function Ep(n){return n?.[Symbol.toStringTag]}function Vl(n){return vp(n).concat(Cp(n))}const Tp=Object.hasOwn||((n,e)=>Np.call(n,e));function Yt(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const Mp="__v",Ap="__o",Op="_owner",{getOwnPropertyDescriptor:Hl,keys:Wl}=Object;function Ip(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n),new Uint8Array(e))}function Rp(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function jp(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Dp(n,e){return Yt(n.getTime(),e.getTime())}function Pp(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Lp(n,e){return n===e}function ql(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let d=!1,u=0;for(;(l=c.next())&&!l.done;){if(s[u]){u++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,u,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){d=s[u]=!0;break}u++}if(!d)return!1;a++}return!0}const $p=Yt;function zp(n,e,t){const r=Wl(n);let s=r.length;if(Wl(e).length!==s)return!1;for(;s-- >0;)if(!ed(n,e,t,r[s]))return!1;return!0}function zn(n,e,t){const r=Vl(n);let s=r.length;if(Vl(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!ed(n,e,t,o)||(i=Hl(n,o),l=Hl(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function _p(n,e){return Yt(n.valueOf(),e.valueOf())}function Bp(n,e){return n.source===e.source&&n.flags===e.flags}function Ul(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,d=0;for(;(l=a.next())&&!l.done;){if(!s[d]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[d]=!0;break}d++}if(!c)return!1}return!0}function Br(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Fp(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function ed(n,e,t,r){return(r===Op||r===Ap||r===Mp)&&(n.$$typeof||e.$$typeof)?!0:Tp(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Vp="[object ArrayBuffer]",Hp="[object Arguments]",Wp="[object Boolean]",qp="[object DataView]",Up="[object Date]",Kp="[object Error]",Jp="[object Map]",Gp="[object Number]",Xp="[object Object]",Yp="[object RegExp]",Qp="[object Set]",Zp="[object String]",em={"[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},tm="[object URL]",nm=Object.prototype.toString;function rm({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(g,x,b){if(g===x)return!0;if(g==null||x==null)return!1;const S=typeof g;if(S!==typeof x)return!1;if(S!=="object")return S==="number"?l(g,x,b):S==="function"?o(g,x,b):!1;const v=g.constructor;if(v!==x.constructor)return!1;if(v===Object)return a(g,x,b);if(Array.isArray(g))return e(g,x,b);if(v===Date)return r(g,x,b);if(v===RegExp)return d(g,x,b);if(v===Map)return i(g,x,b);if(v===Set)return u(g,x,b);const k=nm.call(g);if(k===Up)return r(g,x,b);if(k===Yp)return d(g,x,b);if(k===Jp)return i(g,x,b);if(k===Qp)return u(g,x,b);if(k===Xp)return typeof g.then!="function"&&typeof x.then!="function"&&a(g,x,b);if(k===tm)return h(g,x,b);if(k===Kp)return s(g,x,b);if(k===Hp)return a(g,x,b);if(em[k])return f(g,x,b);if(k===Vp)return n(g,x,b);if(k===qp)return t(g,x,b);if(k===Wp||k===Gp||k===Zp)return c(g,x,b);if(p){let w=p[k];if(!w){const C=Ep(g);C&&(w=p[C])}if(w)return w(g,x,b)}return!1}}function sm({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:Ip,areArraysEqual:t?zn:Rp,areDataViewsEqual:jp,areDatesEqual:Dp,areErrorsEqual:Pp,areFunctionsEqual:Lp,areMapsEqual:t?co(ql,zn):ql,areNumbersEqual:$p,areObjectsEqual:t?zn:zp,arePrimitiveWrappersEqual:_p,areRegExpsEqual:Bp,areSetsEqual:t?co(Ul,zn):Ul,areTypedArraysEqual:t?co(Br,zn):Br,areUrlsEqual:Fp,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=kr(r.areArraysEqual),o=kr(r.areMapsEqual),i=kr(r.areObjectsEqual),l=kr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function om(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function im({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:d}=t();return e(l,a,{cache:c,equals:r,meta:d,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const lm=Tt();Tt({strict:!0});Tt({circular:!0});Tt({circular:!0,strict:!0});Tt({createInternalComparator:()=>Yt});Tt({strict:!0,createInternalComparator:()=>Yt});Tt({circular:!0,createInternalComparator:()=>Yt});Tt({circular:!0,createInternalComparator:()=>Yt,strict:!0});function Tt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=sm(n),i=rm(o),l=t?t(i):om(i);return im({circular:e,comparator:i,createState:r,equals:l,strict:s})}mh({title:lo().min(1),description:lo().nullable(),body:lo()});function uo(n){for(const e of n.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function am(){const n=window.location.pathname.split("/").filter(Boolean),e=n.findIndex(r=>r==="mcps"),t=e>=0?n[e+1]:void 0;return t?decodeURIComponent(t):void 0}function cm(n){const e=I.c(13),{form:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Details"}),e[0]=r):r=e[0];let s;e[1]!==t.control?(s=m.jsxs("div",{className:"flex flex-col gap-4",children:[r,m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[m.jsx(ao,{control:t.control,name:"title",render:fm}),m.jsx(ao,{control:t.control,name:"description",render:um})]})]}),e[1]=t.control,e[2]=s):s=e[2];let o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Message"}),i=m.jsx("div",{className:"text-xs text-muted-foreground",children:"This becomes the user message in the prompt."}),e[3]=o,e[4]=i):(o=e[3],i=e[4]);let l;e[5]!==t.control?(l=m.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,m.jsx(ao,{control:t.control,name:"body",render:dm})]}),e[5]=t.control,e[6]=l):l=e[6];let a;e[7]!==s||e[8]!==l?(a=m.jsxs("div",{className:"h-full py-6 flex flex-col max-w-3xl mx-auto w-full min-w-0 gap-8 overflow-y-auto px-4",children:[s,l]}),e[7]=s,e[8]=l,e[9]=a):a=e[9];let c;return e[10]!==t||e[11]!==a?(c=m.jsx(Ph,{...t,children:a}),e[10]=t,e[11]=a,e[12]=c):c=e[12],c}function dm(n){const{field:e}=n;return m.jsx(Ii,{children:m.jsx(Ri,{children:m.jsx(Ho,{...e,value:e.value??"",placeholder:"Write the prompt message…",className:"min-h-[240px] resize-none text-base leading-relaxed font-normal rounded-xl border border-border bg-muted/20 px-4 py-3 shadow-none focus-visible:ring-0"})})})}function um(n){const{field:e}=n;return m.jsxs(Ii,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),m.jsx(Ri,{children:m.jsx(ji,{...e,value:e.value??"",placeholder:"Add a description…",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function fm(n){const{field:e}=n;return m.jsxs(Ii,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),m.jsx(Ri,{children:m.jsx(ji,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function hm(n){const e=I.c(51),{providerId:t,promptId:r,onBack:s}=n,i=Ci().location.href,l=t||qt;let a;e[0]!==l?(a=qe(l),e[0]=l,e[1]=a):a=e[1];const c=a,d=Mi(t,"PROMPT",r,c),u=Ai(t,"PROMPT",c),f=u.update.isPending;let h;e[2]!==d?(h=d?{title:d.title,description:d.description??null,body:uo(d)}:void 0,e[2]=d,e[3]=h):h=e[3];let p;e[4]!==h?(p={values:h},e[4]=h,e[5]=p):p=e[5];const y=gh(p);let g;e[6]!==y||e[7]!==d?(g=()=>{d&&y.reset({title:d.title,description:d.description??null,body:uo(d)})},e[6]=y,e[7]=d,e[8]=g):g=e[8];const x=g;let b;e[9]!==u.update||e[10]!==y||e[11]!==r?(b=y.handleSubmit(async X=>{const fe=await u.update.mutateAsync({id:r,data:{title:X.title,description:X.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:X.body}}]}});y.reset({title:fe.title,description:fe.description??null,body:uo(fe)})}),e[9]=u.update,e[10]=y,e[11]=r,e[12]=b):b=e[12];const S=b;if(!d){let X;return e[13]===Symbol.for("react.memo_cache_sentinel")?(X=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(jc,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=X):X=e[13],X}let v;e[14]!==d.title?(v=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:d.title}),e[14]=d.title,e[15]=v):v=e[15];let k;e[16]!==d.description?(k=d.description?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:d.description})]}):null,e[16]=d.description,e[17]=k):k=e[17];let w;e[18]!==v||e[19]!==k?(w=m.jsx(Lc,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[v,k]})}),e[18]=v,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==d.title||e[22]!==i?(C=m.jsx(Oi,{title:d.title,url:i,icon:"description"}),e[21]=d.title,e[22]=i,e[23]=C):C=e[23];const T=!y.formState.isDirty||f;let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=m.jsx(Pc,{size:14}),e[24]=A):A=e[24];let D;e[25]!==x||e[26]!==T?(D=m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:T,onClick:x,"aria-label":"Cancel",children:A})})}),e[25]=x,e[26]=T,e[27]=D):D=e[27];let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=m.jsx($t,{side:"bottom",children:"Cancel"}),e[28]=j):j=e[28];let _;e[29]!==D?(_=m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[D,j]})}),e[29]=D,e[30]=_):_=e[30];const V=!y.formState.isDirty||f;let B;e[31]!==S?(B=()=>{S()},e[31]=S,e[32]=B):B=e[32];let H;e[33]===Symbol.for("react.memo_cache_sentinel")?(H=m.jsx(Ui,{size:14}),e[33]=H):H=e[33];let N;e[34]!==V||e[35]!==B?(N=m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:V,onClick:B,"aria-label":"Save",children:H})})}),e[34]=V,e[35]=B,e[36]=N):N=e[36];let z;e[37]===Symbol.for("react.memo_cache_sentinel")?(z=m.jsx($t,{side:"bottom",children:"Save"}),e[37]=z):z=e[37];let P;e[38]!==N?(P=m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[N,z]})}),e[38]=N,e[39]=P):P=e[39];let K;e[40]!==C||e[41]!==_||e[42]!==P?(K=m.jsxs(Di,{children:[C,_,P]}),e[40]=C,e[41]=_,e[42]=P,e[43]=K):K=e[43];let Q;e[44]!==y?(Q=m.jsx("div",{className:"h-full",children:m.jsx(cm,{form:y})}),e[44]=y,e[45]=Q):Q=e[45];let le;return e[46]!==s||e[47]!==K||e[48]!==Q||e[49]!==w?(le=m.jsxs(Sn,{onBack:s,children:[w,K,Q]}),e[46]=s,e[47]=K,e[48]=Q,e[49]=w,e[50]=le):le=e[50],le}function pm(n){const e=I.c(5),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=am()??qt,e[0]=s):s=e[0];const o=s;if(!o||o===qt){let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(jc,{title:"Prompt not found",description:"Missing connection information in the current route."})}),e[1]=l):l=e[1],l}let i;return e[2]!==t||e[3]!==r?(i=m.jsx(Dc,{children:m.jsx(O.Suspense,{fallback:null,children:m.jsx(hm,{providerId:o,promptId:t,onBack:r})})}),e[2]=t,e[3]=r,e[4]=i):i=e[4],i}const mm=yh("relative w-full rounded-lg border px-4 py-3 text-sm flex items-start gap-3 [&>svg]:size-4 [&>svg]:flex-shrink-0 [&>svg]:mt-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-destructive/5 text-destructive border-destructive/25 [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-warning/10 text-warning-foreground border-warning [&>svg]:text-current *:data-[slot=alert-description]:text-warning-foreground/90",success:"bg-success/10 text-success-foreground border-success [&>svg]:text-current *:data-[slot=alert-description]:text-success-foreground/90",info:"bg-card text-card-foreground border-border [&>svg]:text-current *:data-[slot=alert-description]:text-muted-foreground/90"}},defaultVariants:{variant:"default"}});function gm(n){const e=I.c(10);let t,r,s;e[0]!==n?({className:t,variant:s,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==t||e[5]!==s?(o=U(mm({variant:s}),t),e[4]=t,e[5]=s,e[6]=o):o=e[6];let i;return e[7]!==r||e[8]!==o?(i=m.jsx("div",{"data-slot":"alert",role:"alert",className:o,...r}),e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function ym(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("line-clamp-1 min-h-4 font-medium tracking-tight",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-title",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function xm(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("text-muted-foreground leading-relaxed",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-description",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}const bm=n=>n.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function km(n){const e=I.c(13),{toolName:t,connectionId:r,onBack:s}=n,o=`/mcp/${r}`;let i;e[0]!==o?(i=new URL(o,window.location.origin),e[0]=o,e[1]=i):i=e[1];const l=i;let a;e[2]!==r?(a={connectionId:r},e[2]=r,e[3]=a):a=e[3];const c=Vh(a);if(!c.isAuthenticated){let f;return e[4]!==c.supportsOAuth||e[5]!==s?(f=m.jsx("div",{className:"flex h-full items-center justify-center",children:c.supportsOAuth?m.jsx(Hh,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):m.jsx(Wh,{hasReadme:!1})}),e[4]=c.supportsOAuth,e[5]=s,e[6]=f):f=e[6],f}const d=`${r}:${t}`;let u;return e[7]!==r||e[8]!==l||e[9]!==s||e[10]!==d||e[11]!==t?(u=m.jsx(Sm,{toolName:t,connectionId:r,mcpProxyUrl:l,onBack:s},d),e[7]=r,e[8]=l,e[9]=s,e[10]=d,e[11]=t,e[12]=u):u=e[12],u}function Sm({toolName:n,connectionId:e,mcpProxyUrl:t,onBack:r}){const o=Ci().location.href,{replayId:i}=xh({strict:!1}),l=(()=>{if(!i)return null;const N=`replay-${i}`,z=sessionStorage.getItem(N);if(!z)return null;sessionStorage.removeItem(N);try{return JSON.parse(z)}catch{return null}})(),a=(()=>{if(!l)return null;const N={};for(const[z,P]of Object.entries(l))P!==null&&typeof P=="object"?N[z]=JSON.stringify(P,null,2):N[z]=P;return N})(),[c,d]=O.useState(a??{}),[u,f]=O.useState(l?JSON.stringify(l,null,2):"{}"),[h,p]=O.useState(null),[y,g]=O.useState(null),[x,b]=O.useState(!1),[S,v]=O.useState(null),k=Pi(e),w=zi({url:t.href});O.useEffect(()=>{w.error&&console.error("MCP Error:",w.error)},[w.error]);const C=w.tools?.find(N=>N.name===n),T=C?.inputSchema?.properties,A=T?Object.keys(T):[],D=A.length>0,j={};if(D&&C?.inputSchema?.properties)for(const N of A)j[N]=C.inputSchema.required?.includes(N)?"":void 0;const _=N=>Object.prototype.hasOwnProperty.call(c,N),V=async()=>{b(!0),g(null),p(null),v(null);const N=performance.now(),z=qe(e);try{const P=D?{...j,...c}:(()=>{const se=u.trim();if(!se)return{};const J=JSON.parse(se);if(J&&typeof J=="object")return J;throw new Error("Raw JSON input must be an object.")})();D&&C?.inputSchema?.properties&&Object.entries(C.inputSchema.properties).forEach(([se,J])=>{if((J.type==="object"||J.type==="array")&&typeof P[se]=="string")try{P[se]=JSON.parse(P[se])}catch{}});const K=await z(n,P),Q=performance.now(),le=Math.round(Q-N);p(K);const X=JSON.stringify(K),fe=new TextEncoder().encode(X).length;v({duration:`${le}ms`,bytes:`${fe} bytes`,tokens:`~${Math.ceil(fe/4)} tokens`,cost:"$0.0000"})}catch(P){const K=P instanceof Error?P.message:String(P);g(K||"Unknown error occurred");const Q=performance.now();v({duration:`${Math.round(Q-N)}ms`})}finally{b(!1)}},B=(N,z)=>{d(P=>({...P,[N]:z}))},H=()=>{p(null),g(null),v(null)};return m.jsxs(Sn,{onBack:r,children:[m.jsx(Di,{children:m.jsx(Oi,{title:C?.name??bm(n),url:o,icon:"build"})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 h-full",children:[m.jsx("div",{className:"flex flex-col border-r border-border overflow-hidden",children:m.jsxs("div",{className:"flex-1 overflow-auto",children:[m.jsx("div",{className:"flex flex-col gap-4 p-6 border-b border-border min-h-28",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(js,{icon:k?.icon||null,name:k?.title||n,size:"sm",className:"shadow-sm shrink-0"}),m.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:n}),m.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[w.state==="ready"?m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):w.state==="connecting"?m.jsx(tr,{size:10,className:"animate-spin text-yellow-500 shrink-0"}):m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}),m.jsx("span",{className:"font-mono text-xs capitalize text-muted-foreground leading-none",children:w.state.replace("_"," ")})]})]}),m.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:C?.description||"No description available"})]})}),m.jsxs("div",{className:"flex flex-col p-6 gap-4",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h2",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"Parameters"}),C?.inputSchema?.required&&C.inputSchema.required.length>0&&m.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.jsx("span",{className:"text-red-500",children:"*"})," Required"]})]}),m.jsx("div",{className:"space-y-4",children:D&&C?.inputSchema?.properties?Object.entries(C.inputSchema.properties).map(([N,z])=>m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("label",{className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[N,C.inputSchema?.required?.includes(N)&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),m.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:z.type})]}),z.description&&m.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:z.description}),z.type==="object"||z.type==="array"?m.jsx(Ho,{className:"font-mono text-xs",value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N} as JSON...`,rows:3}):m.jsx(ji,{value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N}...`})]},N)):C?.inputSchema&&!D?m.jsxs("div",{className:"space-y-2",children:[m.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),m.jsx(Ho,{className:"font-mono text-xs min-h-[120px]",value:u,onChange:N=>f(N.target.value),placeholder:'e.g. { "foo": "bar" }'})]}):m.jsx("div",{className:"flex items-center justify-center p-8 bg-muted/30 rounded-lg border border-dashed border-border",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No parameters required"})})})]})]})}),m.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-14 border-t lg:border-t-0 border-b border-border bg-background",children:[m.jsx("h2",{className:"text-sm font-medium text-foreground uppercase tracking-wide",children:"Result"}),S&&m.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(zh,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.duration})]}),S.tokens&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Kc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.tokens})]}),S.bytes&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Yc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:S.bytes})]}),S.cost&&m.jsx("div",{className:"flex items-center gap-1.5",children:m.jsx("span",{className:"font-mono text-foreground",children:S.cost})})]})]}),m.jsx("div",{className:"flex items-center justify-end lg:justify-between px-4 h-14 border-b border-border bg-background",children:m.jsxs("div",{className:"flex items-center gap-2 w-full lg:w-auto",children:[m.jsx(me,{size:"sm",variant:"default",className:"h-8 gap-2 flex-1 lg:flex-none",onClick:V,disabled:x,children:x?m.jsxs(m.Fragment,{children:[m.jsx(tr,{size:14,className:"animate-spin"}),"Executing..."]}):m.jsxs(m.Fragment,{children:[m.jsx(Li,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),m.jsx(zt,{children:m.jsxs(_t,{children:[m.jsx(Lt,{asChild:!0,children:m.jsx(me,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:H,disabled:!h&&!y,children:m.jsx($i,{size:14})})}),m.jsx($t,{children:m.jsx("p",{children:"Clear results"})})]})})]})}),y&&m.jsx("div",{className:"px-6 py-4 bg-background",children:m.jsx(gm,{variant:"destructive",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx($h,{className:"h-4 w-4"}),m.jsx(ym,{className:"mb-0",children:"Execution Failed"})]}),m.jsx(xm,{className:"text-xs text-destructive",children:y})]})})}),m.jsx("div",{className:"relative flex-1 overflow-auto bg-muted/50",children:h?m.jsxs(m.Fragment,{children:[m.jsx(On,{code:JSON.stringify(h,null,2),language:"json",height:"100%",readOnly:!0}),m.jsx(me,{size:"icon",variant:"ghost",className:"absolute top-4 right-4 h-8 w-8 bg-background/80 hover:bg-background border border-border shadow-sm",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(h,null,2)),Ec.success("Copied to clipboard")},children:m.jsx(Bh,{className:"h-3.5 w-3.5"})})]}):m.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground",children:[m.jsx(_h,{className:"h-12 w-12 mb-3 opacity-40"}),m.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function wm(n){const e=I.c(7),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=Et(s).connectionId??qt;if(!Pi(i)){let d;return e[1]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[m.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=d):d=e[1],d}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(tr,{size:32,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let c;return e[3]!==i||e[4]!==r||e[5]!==t?(c=m.jsx(O.Suspense,{fallback:a,children:m.jsx(km,{toolName:t,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=t,e[6]=c):c=e[6],c}const Kl=n=>{let e;const t=new Set,r=(c,d)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const f=e;e=d??(typeof u!="object"||u===null)?u:Object.assign({},e,u),t.forEach(h=>h(e,f))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>a,subscribe:c=>(t.add(c),()=>t.delete(c))},a=e=n(r,s,l);return l},Ki=(n=>n?Kl(n):Kl),vm=n=>n;function Wo(n,e=vm){const t=ee.useSyncExternalStore(n.subscribe,ee.useCallback(()=>e(n.getState()),[n,e]),ee.useCallback(()=>e(n.getInitialState()),[n,e]));return ee.useDebugValue(t),t}const Cm=n=>{const e=Ki(n),t=r=>Wo(e,r);return Object.assign(t,e),t},Nm=(n=>Cm);function td(n,e){let t;try{t=n()}catch{return}return{getItem:s=>{var o;const i=a=>a===null?null:JSON.parse(a,void 0),l=(o=t.getItem(s))!=null?o:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,o)=>t.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>t.removeItem(s)}}const qo=n=>e=>{try{const t=n(e);return t instanceof Promise?t:{then(r){return qo(r)(t)},catch(r){return this}}}catch(t){return{then(r){return this},catch(r){return qo(r)(t)}}}},Em=(n,e)=>(t,r,s)=>{let o={storage:td(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...e},i=!1,l=0;const a=new Set,c=new Set;let d=o.storage;if(!d)return n((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),t(...g)},r,s);const u=()=>{const g=o.partialize({...r()});return d.setItem(o.name,{state:g,version:o.version})},f=s.setState;s.setState=(g,x)=>(f(g,x),u());const h=n((...g)=>(t(...g),u()),r,s);s.getInitialState=()=>h;let p;const y=()=>{var g,x;if(!d)return;const b=++l;i=!1,a.forEach(v=>{var k;return v((k=r())!=null?k:h)});const S=((x=o.onRehydrateStorage)==null?void 0:x.call(o,(g=r())!=null?g:h))||void 0;return qo(d.getItem.bind(d))(o.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==o.version){if(o.migrate){const k=o.migrate(v.state,v.version);return k instanceof Promise?k.then(w=>[!0,w]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var k;if(b!==l)return;const[w,C]=v;if(p=o.merge(C,(k=r())!=null?k:h),t(p,!0),w)return u()}).then(()=>{b===l&&(S?.(p,void 0),p=r(),i=!0,c.forEach(v=>v(p)))}).catch(v=>{b===l&&S?.(void 0,v)})};return s.persist={setOptions:g=>{o={...o,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>y(),hasHydrated:()=>i,onHydrate:g=>(a.add(g),()=>{a.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},o.skipHydration||y(),p||h},nd=Em,{useSyncExternalStoreWithSelector:Tm}=bh,Mm=n=>n;function Am(n,e=Mm,t){const r=Tm(n.subscribe,n.getState,n.getInitialState,e,t);return ee.useDebugValue(r),r}const Jl=n=>Symbol.iterator in n,Gl=n=>"entries"in n,Xl=(n,e)=>{const t=n instanceof Map?n:new Map(n.entries()),r=e instanceof Map?e:new Map(e.entries());if(t.size!==r.size)return!1;for(const[s,o]of t)if(!r.has(s)||!Object.is(o,r.get(s)))return!1;return!0},Om=(n,e)=>{const t=n[Symbol.iterator](),r=e[Symbol.iterator]();let s=t.next(),o=r.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=t.next(),o=r.next()}return!!s.done&&!!o.done};function Im(n,e){return Object.is(n,e)?!0:typeof n!="object"||n===null||typeof e!="object"||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e)?!1:Jl(n)&&Jl(e)?Gl(n)&&Gl(e)?Xl(n,e):Om(n,e):Xl({entries:()=>Object.entries(n)},{entries:()=>Object.entries(e)})}function Rm(n,e="Output"){if(!n)return`interface ${e} {}`;function t(o){if(!o||typeof o!="object")return"unknown";const i=o.type;if(Array.isArray(i))return i.map(l=>r(l)).join(" | ");switch(i){case"string":return o.enum?o.enum.map(l=>`"${l}"`).join(" | "):"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":{const l=o.items;return l?`${t(l)}[]`:"unknown[]"}case"object":return s(o);default:return o.anyOf?o.anyOf.map(t).join(" | "):o.oneOf?o.oneOf.map(t).join(" | "):o.allOf?o.allOf.map(t).join(" & "):"unknown"}}function r(o){switch(o){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";default:return"unknown"}}function s(o){const i=o.properties;if(!i)return"Record<string, unknown>";const l=new Set(o.required||[]);return`{
|
|
2
2
|
${Object.entries(i).map(([c,d])=>{const u=l.has(c)?"":"?";return`${d.description?` /** ${d.description} */
|
|
3
3
|
`:""} ${c}${u}: ${t(d)};`}).join(`
|
|
4
4
|
`)}
|
|
5
5
|
}`}return`interface ${e} ${t(n)}`}function fo(n,e){const t=n.trim();return e.some(s=>s.name.toLowerCase()===t.toLowerCase())?`${t}_${Math.random().toString(36).substring(2,6)}`:t}function jm(n,e){const t=n.match(/interface\s+Input\s*\{/);if(!t||t.index===void 0)return`${e}
|
|
6
6
|
|
|
7
|
-
${n.trimStart()}`;const r=t.index,s=r+t[0].length-1;let o=1,i=s+1;for(;i<n.length&&o>0;)n[i]==="{"?o++:n[i]==="}"&&o--,i++;return n.slice(0,r)+e+n.slice(i)}function ho(n,e){switch(n){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...Kh,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${n}`)}}const rd=O.createContext(null),Dm=n=>Ki()(nd(e=>({...n,actions:{setIsAddingStep:t=>e(r=>({...r,isAddingStep:t})),setCurrentStepTab:t=>e(r=>({...r,currentStepTab:t})),setToolAction:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.map(s=>"toolName"in s.action&&s.action.toolName===t.toolName?{...s,action:t}:s)}})),appendStep:({step:t,type:r})=>e(s=>{const o=t??ho(r,s.workflow.steps.length),i=s.workflow.steps.find(a=>a.name===o.name),l=i?`${o.name} ${parseInt(i.name.split(" ").pop()??Math.random().toString(36).substring(2,15))+1}`:o.name;return{workflow:{...s.workflow,steps:[...s.workflow.steps,{...o,name:l}]}}}),deleteStep:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.filter(s=>s.name!==t)}})),duplicateStep:t=>e(r=>{const s=r.workflow.steps.findIndex(a=>a.name===t);if(s===-1)return r;const o=r.workflow.steps[s];if(!o)return r;const i={...o,name:fo(o.name,r.workflow.steps)},l=[...r.workflow.steps];return l.splice(s+1,0,i),{workflow:{...r.workflow,steps:l},currentStepName:i.name}}),setCurrentStepName:t=>e(r=>({...r,currentStepName:t})),updateStep:(t,r)=>e(s=>({...s,workflow:{...s.workflow,steps:s.workflow.steps.map(o=>o.name===t?{...o,...r}:o)}})),setTrackingExecutionId:t=>e(r=>({...r,trackingExecutionId:t})),resetToOriginalWorkflow:()=>e(t=>({...t,workflow:t.localWorkflow})),startAddingStep:t=>e(r=>({...r,isAddingStep:!0,addingStepType:t})),cancelAddingStep:()=>e(t=>({...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[]})),toggleParentStepSelection:t=>e(r=>{const s=r.selectedParentSteps.includes(t);return{...r,selectedParentSteps:s?r.selectedParentSteps.filter(o=>o!==t):[...r.selectedParentSteps,t]}}),confirmAddCodeStep:()=>e(t=>{const{selectedParentSteps:r,addingStepType:s,workflow:o}=t;if(s!=="code"||r.length===0)return t;const i={};for(const u of r)i[u]=`@${u}`;const l={};for(const u of r){const f=o.steps.find(h=>h.name===u);f?.outputSchema&&(l[u]=f.outputSchema)}const a=Object.keys(l).length>0?{type:"object",properties:l,required:Object.keys(l)}:void 0;let c=ho("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const u=Rm(a,"Input"),f=c.action,h=jm(f.code,u);c={...c,action:{...f,code:h}}}const d=fo(c.name,o.steps);return{...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],workflow:{...o,steps:[...o.steps,{...c,name:d}]},currentStepName:d}}),addToolStep:()=>e(t=>{let r=ho("tool",Number((Math.random()*1e6).toFixed(0)));const s=fo(r.name,t.workflow.steps);return{...t,isAddingStep:!1,addingStepType:null,workflow:{...t.workflow,steps:[...t.workflow.steps,{...r,name:s}]},currentStepName:s}}),setOriginalWorkflow:t=>e(r=>({...r,localWorkflow:t})),setWorkflow:t=>e(r=>({...r,workflow:t})),startReplacingTool:t=>e(r=>({...r,replacingToolInfo:{toolName:t}})),cancelReplacingTool:()=>e(t=>({...t,replacingToolInfo:null})),setSelectedGatewayId:t=>e(r=>({...r,selectedGatewayId:t}))}}),{name:`workflow-store-${encodeURIComponent(n.workflow.id)}`,storage:td(()=>localStorage),version:1,partialize:e=>({trackingExecutionId:e.trackingExecutionId,currentStepName:e.currentStepName,currentStepTab:e.currentStepTab,localWorkflow:e.localWorkflow,isAddingStep:e.isAddingStep,addingStepType:e.addingStepType,selectedParentSteps:e.selectedParentSteps,replacingToolInfo:e.replacingToolInfo,selectedGatewayId:e.selectedGatewayId})}));function Pm(n){const e=I.c(8),{children:t,initialState:r}=n,s=Gh();let o;e[0]!==s?.[0]?.id||e[1]!==r.currentStepTab||e[2]!==r.trackingExecutionId||e[3]!==r.workflow?(o=()=>Dm({workflow:r.workflow,localWorkflow:r.workflow,selectedGatewayId:s?.[0]?.id,isAddingStep:!1,selectedParentSteps:[],trackingExecutionId:r.trackingExecutionId,currentStepName:r.workflow.steps[0]?.name,currentStepTab:r.currentStepTab??"input"}),e[0]=s?.[0]?.id,e[1]=r.currentStepTab,e[2]=r.trackingExecutionId,e[3]=r.workflow,e[4]=o):o=e[4];const[i]=O.useState(o);let l;return e[5]!==t||e[6]!==i?(l=m.jsx(rd.Provider,{value:i,children:t}),e[5]=t,e[6]=i,e[7]=l):l=e[7],l}function In(n,e){const t=O.useContext(rd);if(!t)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return Am(t,n,Im)}function Rn(){return In(Lm)}function Lm(n){return n.workflow}function Me(){return In($m)}function $m(n){return n.actions}function sd(){const n=pr();return In(zm)??n[0]?.name}function zm(n){return n.currentStepName}function hr(){const n=I.c(5),e=sd(),t=pr();let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==e?(o=i=>i.name===e,n[3]=e,n[4]=o):o=n[4],r=t.find(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];const s=r;return s||t[0]}function pr(){return Rn().steps}function od(){const n=I.c(8),e=Rn(),t=In(Fm);let r,s;if(n[0]!==t.description||n[1]!==t.steps||n[2]!==t.title||n[3]!==e.description||n[4]!==e.steps||n[5]!==e.title){const o={title:e.title,description:e.description,steps:e.steps.map(Bm)},i={title:t.title,description:t.description,steps:t.steps.map(_m)};r=JSON.stringify(o),s=JSON.stringify(i),n[0]=t.description,n[1]=t.steps,n[2]=t.title,n[3]=e.description,n[4]=e.steps,n[5]=e.title,n[6]=r,n[7]=s}else r=n[6],s=n[7];return r!==s}function _m(n){return{...n,outputSchema:void 0}}function Bm(n){return{...n,outputSchema:void 0}}function Fm(n){return n.localWorkflow}function we(){return In(Vm)}function Vm(n){return n.trackingExecutionId}function jn(){return In(Hm)}function Hm(n){return n.selectedGatewayId}function Wm(n){const e=I.c(18),{selectedGatewayId:t,onGatewayChange:r,className:s,placeholder:o}=n,i=o===void 0?"Select Agent":o,l=Qh(),a=t??void 0;let c;e[0]!==r?(c=g=>r(g===""?void 0:g),e[0]=r,e[1]=c):c=e[1];let d;e[2]!==s?(d=U("text-xs",s),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=m.jsx(sp,{placeholder:i}),e[4]=i,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==u?(f=m.jsx(op,{size:"sm",className:d,children:u}),e[6]=d,e[7]=u,e[8]=f):f=e[8];let h;e[9]!==l?(h=l.map(qm),e[9]=l,e[10]=h):h=e[10];let p;e[11]!==h?(p=m.jsx(ip,{children:h}),e[11]=h,e[12]=p):p=e[12];let y;return e[13]!==a||e[14]!==c||e[15]!==f||e[16]!==p?(y=m.jsxs(lp,{value:a,onValueChange:c,children:[f,p]}),e[13]=a,e[14]=c,e[15]=f,e[16]=p,e[17]=y):y=e[17],y}function qm(n){return m.jsx(rp,{value:n.id,children:n.title},n.id)}function Dn(){const n=I.c(2),e=Lh();let t;n[0]!==e?(t={connections:e,binding:"WORKFLOW"},n[0]=e,n[1]=t):t=n[1];const r=Jh(t);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}const Yl=[100,1e3,2e3];function Pn(n){const e=I.c(15),t=Dn();let r;e[0]!==t.id?(r=qe(t.id),e[0]=t.id,e[1]=r):r=e[1];const s=r,o=O.useRef(0);let i;e[2]!==n?(i={id:n},e[2]=n,e[3]=i):i=e[3];const l=!!n;let a;e[4]!==n?(a=n?p=>{const y=p.state?.data?.item?.status;if(y==="running"||y==="enqueued"){const g=Yl[o.current]??1;return o.current=(o.current+1)%Yl.length,g}return o.current=0,!1}:!1,e[4]=n,e[5]=a):a=e[5];let c;e[6]!==t.id||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==s?(c={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET",toolInputParams:i,scope:t.id,staleTime:0,gcTime:0,enabled:l,refetchInterval:a},e[6]=t.id,e[7]=i,e[8]=l,e[9]=a,e[10]=s,e[11]=c):c=e[11];const{data:d,isLoading:u}=Bi(c),f=d?.item;let h;return e[12]!==u||e[13]!==f?(h={item:f,isLoading:u},e[12]=u,e[13]=f,e[14]=h):h=e[14],h}function Um(n,e){const t=I.c(14),r=Dn();let s;t[0]!==r.id?(s=qe(r.id),t[0]=r.id,t[1]=s):s=t[1];const o=s;let i;t[2]!==n||t[3]!==e?(i={executionId:n,stepId:e},t[2]=n,t[3]=e,t[4]=i):i=t[4];const l=!!n&&!!e;let a;t[5]!==r.id||t[6]!==i||t[7]!==l||t[8]!==o?(a={toolCaller:o,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET_STEP_RESULT",toolInputParams:i,scope:r.id,enabled:l},t[5]=r.id,t[6]=i,t[7]=l,t[8]=o,t[9]=a):a=t[9];const{data:c,isLoading:d}=Bi(a),u=c?.output,f=c?.error;let h;return t[10]!==d||t[11]!==u||t[12]!==f?(h={output:u,error:f,isLoading:d},t[10]=d,t[11]=u,t[12]=f,t[13]=h):h=t[13],h}function Km(){const n=I.c(19),e=Dn(),t=Rn();let r;n[0]!==e.id?(r=qe(e.id),n[0]=e.id,n[1]=r):r=n[1];const s=r;let o;n[2]===Symbol.for("react.memo_cache_sentinel")?(o=["workflow"],n[2]=o):o=n[2];let i;n[3]!==t.id?(i={field:o,operator:"eq",value:t.id},n[3]=t.id,n[4]=i):i=n[4];let l;n[5]===Symbol.for("react.memo_cache_sentinel")?(l=[{field:["created_at"],direction:"desc"}],n[5]=l):l=n[5];let a;n[6]!==i?(a={where:i,orderBy:l,limit:100},n[6]=i,n[7]=a):a=n[7];const c=`${e.id}-executions-${t.id}`,d=!!t.id;let u;n[8]!==a||n[9]!==c||n[10]!==d||n[11]!==s?(u={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_LIST",toolInputParams:a,scope:c,enabled:d,staleTime:5e3},n[8]=a,n[9]=c,n[10]=d,n[11]=s,n[12]=u):u=n[12];const{data:f,isLoading:h,refetch:p}=Bi(u),y=f;let g;n[13]!==y?.items?(g=y?.items??[],n[13]=y?.items,n[14]=g):g=n[14];let x;return n[15]!==h||n[16]!==p||n[17]!==g?(x={executions:g,isLoading:h,refetch:p},n[15]=h,n[16]=p,n[17]=g,n[18]=x):x=n[18],x}function id(n){const e=[];function t(r){if(typeof r=="string"){const s=r.match(/@input(?:\.(\w+(?:\.\w+)*))?/g);if(s)for(const o of s)if(o==="@input")e.push("__entire_input__");else{const i=o.replace("@input.","");e.push(i)}}else Array.isArray(r)?r.forEach(t):typeof r=="object"&&r!==null&&Object.values(r).forEach(t)}return t(n),[...new Set(e)]}function Jm(n){const e=[];for(const t of n){const r=id(t.input);e.push(...r)}return[...new Set(e)].filter(t=>t!=="__entire_input__")}function Gm(n){for(const e of n)if(id(e.input).includes("__entire_input__"))return!0;return!1}function Xm(n){const e=Jm(n);if(e.length===0)return Gm(n)?{type:"object",additionalProperties:!0,description:"Workflow input data"}:null;const t={},r=[];for(const s of e){const o=s.split(".");if(o.length===1)t[s]={type:"string",description:`Input field: ${s}`},r.push(s);else{const i=o[0];i&&!t[i]&&(t[i]={type:"object",description:`Input object: ${i}`,additionalProperties:!0},r.push(i))}}return{type:"object",properties:t,required:r,description:"Workflow execution input"}}function Ym(){const n=I.c(2),e=Rn();let t;return n[0]!==e.steps?(t=Xm(e.steps),n[0]=e.steps,n[1]=t):t=n[1],t}function Qm(){const n=I.c(14),{id:e}=Dn(),{setTrackingExecutionId:t}=Me();let r;n[0]!==e?(r=qe(e),n[0]=e,n[1]=r):r=n[1];const s=r,o=Rn(),i=jn(),l=Ym();let a;n[2]!==s?(a={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_CREATE"},n[2]=s,n[3]=a):a=n[3];const{mutateAsync:c,isPending:d}=Fi(a);let u;n[4]!==i||n[5]!==t||n[6]!==c||n[7]!==o?(u=async y=>{const g=y===void 0?{}:y;if(!i)throw new Error("Please select an Agent before running the workflow");const x=Date.now(),b=await c({input:g,gateway_id:i,start_at_epoch_ms:x,workflow_collection_id:o.id}),S=b?.item?.id??b?.structuredContent?.item?.id;return t(S),S},n[4]=i,n[5]=t,n[6]=c,n[7]=o,n[8]=u):u=n[8];const f=u,h=l!==null;let p;return n[9]!==f||n[10]!==l||n[11]!==d||n[12]!==h?(p={handleRunWorkflow:f,isPending:d,requiresInput:h,inputSchema:l},n[9]=f,n[10]=l,n[11]=d,n[12]=h,n[13]=p):p=n[13],p}function Zm(){const n=I.c(9),{id:e}=Dn();let t;n[0]!==e?(t=qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"CANCEL_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=Fi(s);let l;n[4]!==o?(l=async d=>await o({executionId:d}),n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleCancelWorkflow:a,isCancelling:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function eg(){const n=I.c(9),{id:e}=Dn();let t;n[0]!==e?(t=qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"RESUME_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=Fi(s);let l;n[4]!==o?(l=async d=>(await o({executionId:d})).success,n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleResumeWorkflow:a,isResuming:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function tg(){const n=I.c(3),e=we(),{item:t}=Pn(e);let r;return n[0]!==t||n[1]!==e?(r=e&&t?(()=>{const o={};return t?.input&&(o.input=t.input),o})():void 0,n[0]=t,n[1]=e,n[2]=r):r=n[2],r}function ng(n,e,t,r){if(!e)return[...n].sort(r);const s=t(e);return[...n].sort((o,i)=>{const l=t(o),a=t(i);return l===s?-1:a===s?1:r?r(o,i):0})}const Ji=Nm()(nd(n=>({viewMode:"visual",setViewMode:e=>n({viewMode:e}),showExecutionsList:!1,setShowExecutionsList:e=>n({showExecutionsList:e}),toggleExecutionsList:()=>n(e=>({showExecutionsList:!e.showExecutionsList}))}),{name:"workflow-view-mode"})),ld=O.createContext([]);function ad(){return O.useContext(ld)}function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new xe(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xe(t)},addToStart:function(n,e){return new xe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new xe(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xe.from(n),n.size?new xe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xe.from(n),n.size?new xe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};function cd(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=cd(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function dd(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=dd(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class E{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new E(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new E(r,s)}cutByIndex(e,t){return e==t?E.empty:e==0&&t==this.content.length?this:new E(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new E(s,o)}addToStart(e){return new E([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new E(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return cd(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return dd(this,e,t,r)}findIndex(e){if(e==0)return Sr(0,e);if(e==this.size)return Sr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Sr(t+1,o):Sr(t,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,t){if(!t)return E.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new E(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return E.empty;let t,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)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new E(t||e,r)}static from(e){if(!e)return E.empty;if(e instanceof E)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new E([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}E.empty=new E([],0);const po={index:0,offset:0};function Sr(n,e){return po.index=n,po.offset=e,po}function Fr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Fr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Fr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Y=class Uo{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,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))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Uo.none;if(e instanceof Uo)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};Y.none=[];class Vr extends Error{}class R{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=fd(this.content,e+this.openStart,t);return r&&new R(r,this.openStart,this.openEnd)}removeBetween(e,t){return new R(ud(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return R.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new R(E.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new R(e,r,s)}}R.empty=new R(E.empty,0,0);function ud(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(ud(o.content,e-s-1,t-s-1)))}function fd(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=fd(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function rg(n,e,t){if(t.openStart>n.depth)throw new Vr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Vr("Inconsistent open depths");return hd(n,e,t,0)}function hd(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=hd(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Ft(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=sg(t,n);return Ft(o,md(n,i,l,e,r))}else return Ft(o,Hr(n,e,r))}function pd(n,e){if(!e.type.compatibleContent(n.type))throw new Vr("Cannot join "+e.type.name+" onto "+n.type.name)}function Ko(n,e,t){let r=n.node(t);return pd(r,e.node(t)),r}function Bt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function qn(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Bt(n.nodeAfter,r),o++));for(let l=o;l<i;l++)Bt(s.child(l),r);e&&e.depth==t&&e.textOffset&&Bt(e.nodeBefore,r)}function Ft(n,e){return n.type.checkContent(e),n.copy(e)}function md(n,e,t,r,s){let o=n.depth>s&&Ko(n,e,s+1),i=r.depth>s&&Ko(t,r,s+1),l=[];return qn(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(pd(o,i),Bt(Ft(o,md(n,e,t,r,s+1)),l)):(o&&Bt(Ft(o,Hr(n,e,s+1)),l),qn(e,t,s,l),i&&Bt(Ft(i,Hr(t,r,s+1)),l)),qn(r,null,s,l),new E(l)}function Hr(n,e,t){let r=[];if(qn(null,n,t,r),n.depth>t){let s=Ko(n,e,t+1);Bt(Ft(s,Hr(n,e,t+1)),r)}return qn(e,null,t,r),new E(r)}function sg(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(E.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class nr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.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,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Y.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}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 t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.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 t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Wr(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 t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new nr(t,r,o)}static resolveCached(e,t){let r=Ql.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else Ql.set(e,r=new og);let s=r.elts[r.i]=nr.resolve(e,t);return r.i=(r.i+1)%ig,s}}class og{constructor(){this.elts=[],this.i=0}}const ig=12,Ql=new WeakMap;class Wr{constructor(e,t,r){this.$from=e,this.$to=t,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 lg=Object.create(null);class ze{constructor(e,t,r,s=Y.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||E.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,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,t,r,s){return this.content.textBetween(e,t,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,t,r){return this.type==e&&Fr(this.attrs,t||e.defaultAttrs||lg)&&Y.sameSet(this.marks,r||Y.none)}copy(e=null){return e==this.content?this:new ze(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ze(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return R.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new R(c,s.depth-i,o.depth-i)}replace(e,t,r){return rg(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return nr.resolveCached(this,e)}resolveNoCache(e){return nr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,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()+")"),gd(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=E.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);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=Y.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Y.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=E.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}ze.prototype.text=void 0;class qr extends ze{constructor(e,t,r,s){if(super(e,t,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):gd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new qr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new qr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function gd(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ut{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ag(e,t);if(r.next==null)return Ut.empty;let s=yd(r);r.next&&r.err("Unexpected trailing text");let o=mg(pg(s));return gg(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return E.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let f=o(u,l.concat(d));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 t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=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 l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.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 t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(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(`
|
|
7
|
+
${n.trimStart()}`;const r=t.index,s=r+t[0].length-1;let o=1,i=s+1;for(;i<n.length&&o>0;)n[i]==="{"?o++:n[i]==="}"&&o--,i++;return n.slice(0,r)+e+n.slice(i)}function ho(n,e){switch(n){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...Kh,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${n}`)}}const rd=O.createContext(null),Dm=n=>Ki()(nd(e=>({...n,actions:{setIsAddingStep:t=>e(r=>({...r,isAddingStep:t})),setCurrentStepTab:t=>e(r=>({...r,currentStepTab:t})),setToolAction:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.map(s=>"toolName"in s.action&&s.action.toolName===t.toolName?{...s,action:t}:s)}})),appendStep:({step:t,type:r})=>e(s=>{const o=t??ho(r,s.workflow.steps.length),i=s.workflow.steps.find(a=>a.name===o.name),l=i?`${o.name} ${parseInt(i.name.split(" ").pop()??Math.random().toString(36).substring(2,15))+1}`:o.name;return{workflow:{...s.workflow,steps:[...s.workflow.steps,{...o,name:l}]}}}),deleteStep:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.filter(s=>s.name!==t)}})),duplicateStep:t=>e(r=>{const s=r.workflow.steps.findIndex(a=>a.name===t);if(s===-1)return r;const o=r.workflow.steps[s];if(!o)return r;const i={...o,name:fo(o.name,r.workflow.steps)},l=[...r.workflow.steps];return l.splice(s+1,0,i),{workflow:{...r.workflow,steps:l},currentStepName:i.name}}),setCurrentStepName:t=>e(r=>({...r,currentStepName:t})),updateStep:(t,r)=>e(s=>({...s,workflow:{...s.workflow,steps:s.workflow.steps.map(o=>o.name===t?{...o,...r}:o)}})),setTrackingExecutionId:t=>e(r=>({...r,trackingExecutionId:t})),resetToOriginalWorkflow:()=>e(t=>({...t,workflow:t.localWorkflow})),startAddingStep:t=>e(r=>({...r,isAddingStep:!0,addingStepType:t})),cancelAddingStep:()=>e(t=>({...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[]})),toggleParentStepSelection:t=>e(r=>{const s=r.selectedParentSteps.includes(t);return{...r,selectedParentSteps:s?r.selectedParentSteps.filter(o=>o!==t):[...r.selectedParentSteps,t]}}),confirmAddCodeStep:()=>e(t=>{const{selectedParentSteps:r,addingStepType:s,workflow:o}=t;if(s!=="code"||r.length===0)return t;const i={};for(const u of r)i[u]=`@${u}`;const l={};for(const u of r){const f=o.steps.find(h=>h.name===u);f?.outputSchema&&(l[u]=f.outputSchema)}const a=Object.keys(l).length>0?{type:"object",properties:l,required:Object.keys(l)}:void 0;let c=ho("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const u=Rm(a,"Input"),f=c.action,h=jm(f.code,u);c={...c,action:{...f,code:h}}}const d=fo(c.name,o.steps);return{...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],workflow:{...o,steps:[...o.steps,{...c,name:d}]},currentStepName:d}}),addToolStep:()=>e(t=>{let r=ho("tool",Number((Math.random()*1e6).toFixed(0)));const s=fo(r.name,t.workflow.steps);return{...t,isAddingStep:!1,addingStepType:null,workflow:{...t.workflow,steps:[...t.workflow.steps,{...r,name:s}]},currentStepName:s}}),setOriginalWorkflow:t=>e(r=>({...r,localWorkflow:t})),setWorkflow:t=>e(r=>({...r,workflow:t})),startReplacingTool:t=>e(r=>({...r,replacingToolInfo:{toolName:t}})),cancelReplacingTool:()=>e(t=>({...t,replacingToolInfo:null})),setSelectedVirtualMcpId:t=>e(r=>({...r,selectedVirtualMcpId:t}))}}),{name:`workflow-store-${encodeURIComponent(n.workflow.id)}`,storage:td(()=>localStorage),version:1,partialize:e=>({trackingExecutionId:e.trackingExecutionId,currentStepName:e.currentStepName,currentStepTab:e.currentStepTab,localWorkflow:e.localWorkflow,isAddingStep:e.isAddingStep,addingStepType:e.addingStepType,selectedParentSteps:e.selectedParentSteps,replacingToolInfo:e.replacingToolInfo,selectedVirtualMcpId:e.selectedVirtualMcpId})}));function Pm(n){const e=I.c(8),{children:t,initialState:r}=n,s=Gh();let o;e[0]!==r.currentStepTab||e[1]!==r.trackingExecutionId||e[2]!==r.workflow||e[3]!==s?.[0]?.id?(o=()=>Dm({workflow:r.workflow,localWorkflow:r.workflow,selectedVirtualMcpId:s?.[0]?.id,isAddingStep:!1,selectedParentSteps:[],trackingExecutionId:r.trackingExecutionId,currentStepName:r.workflow.steps[0]?.name,currentStepTab:r.currentStepTab??"input"}),e[0]=r.currentStepTab,e[1]=r.trackingExecutionId,e[2]=r.workflow,e[3]=s?.[0]?.id,e[4]=o):o=e[4];const[i]=O.useState(o);let l;return e[5]!==t||e[6]!==i?(l=m.jsx(rd.Provider,{value:i,children:t}),e[5]=t,e[6]=i,e[7]=l):l=e[7],l}function In(n,e){const t=O.useContext(rd);if(!t)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return Am(t,n,Im)}function Rn(){return In(Lm)}function Lm(n){return n.workflow}function Me(){return In($m)}function $m(n){return n.actions}function sd(){const n=pr();return In(zm)??n[0]?.name}function zm(n){return n.currentStepName}function hr(){const n=I.c(5),e=sd(),t=pr();let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==e?(o=i=>i.name===e,n[3]=e,n[4]=o):o=n[4],r=t.find(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];const s=r;return s||t[0]}function pr(){return Rn().steps}function od(){const n=I.c(8),e=Rn(),t=In(Fm);let r,s;if(n[0]!==t.description||n[1]!==t.steps||n[2]!==t.title||n[3]!==e.description||n[4]!==e.steps||n[5]!==e.title){const o={title:e.title,description:e.description,steps:e.steps.map(Bm)},i={title:t.title,description:t.description,steps:t.steps.map(_m)};r=JSON.stringify(o),s=JSON.stringify(i),n[0]=t.description,n[1]=t.steps,n[2]=t.title,n[3]=e.description,n[4]=e.steps,n[5]=e.title,n[6]=r,n[7]=s}else r=n[6],s=n[7];return r!==s}function _m(n){return{...n,outputSchema:void 0}}function Bm(n){return{...n,outputSchema:void 0}}function Fm(n){return n.localWorkflow}function we(){return In(Vm)}function Vm(n){return n.trackingExecutionId}function jn(){return In(Hm)}function Hm(n){return n.selectedVirtualMcpId}function Wm(n){const e=I.c(18),{selectedVirtualMcpId:t,onVirtualMcpChange:r,className:s,placeholder:o}=n,i=o===void 0?"Select Agent":o,l=Qh(),a=t??void 0;let c;e[0]!==r?(c=g=>r(g===""?void 0:g),e[0]=r,e[1]=c):c=e[1];let d;e[2]!==s?(d=U("text-xs",s),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=m.jsx(sp,{placeholder:i}),e[4]=i,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==u?(f=m.jsx(op,{size:"sm",className:d,children:u}),e[6]=d,e[7]=u,e[8]=f):f=e[8];let h;e[9]!==l?(h=l.map(qm),e[9]=l,e[10]=h):h=e[10];let p;e[11]!==h?(p=m.jsx(ip,{children:h}),e[11]=h,e[12]=p):p=e[12];let y;return e[13]!==a||e[14]!==c||e[15]!==f||e[16]!==p?(y=m.jsxs(lp,{value:a,onValueChange:c,children:[f,p]}),e[13]=a,e[14]=c,e[15]=f,e[16]=p,e[17]=y):y=e[17],y}function qm(n){return m.jsx(rp,{value:n.id,children:n.title},n.id)}function Dn(){const n=I.c(2),e=Lh();let t;n[0]!==e?(t={connections:e,binding:"WORKFLOW"},n[0]=e,n[1]=t):t=n[1];const r=Jh(t);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}const Yl=[100,1e3,2e3];function Pn(n){const e=I.c(15),t=Dn();let r;e[0]!==t.id?(r=qe(t.id),e[0]=t.id,e[1]=r):r=e[1];const s=r,o=O.useRef(0);let i;e[2]!==n?(i={id:n},e[2]=n,e[3]=i):i=e[3];const l=!!n;let a;e[4]!==n?(a=n?p=>{const y=p.state?.data?.item?.status;if(y==="running"||y==="enqueued"){const g=Yl[o.current]??1;return o.current=(o.current+1)%Yl.length,g}return o.current=0,!1}:!1,e[4]=n,e[5]=a):a=e[5];let c;e[6]!==t.id||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==s?(c={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET",toolInputParams:i,scope:t.id,staleTime:0,gcTime:0,enabled:l,refetchInterval:a},e[6]=t.id,e[7]=i,e[8]=l,e[9]=a,e[10]=s,e[11]=c):c=e[11];const{data:d,isLoading:u}=Bi(c),f=d?.item;let h;return e[12]!==u||e[13]!==f?(h={item:f,isLoading:u},e[12]=u,e[13]=f,e[14]=h):h=e[14],h}function Um(n,e){const t=I.c(14),r=Dn();let s;t[0]!==r.id?(s=qe(r.id),t[0]=r.id,t[1]=s):s=t[1];const o=s;let i;t[2]!==n||t[3]!==e?(i={executionId:n,stepId:e},t[2]=n,t[3]=e,t[4]=i):i=t[4];const l=!!n&&!!e;let a;t[5]!==r.id||t[6]!==i||t[7]!==l||t[8]!==o?(a={toolCaller:o,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET_STEP_RESULT",toolInputParams:i,scope:r.id,enabled:l},t[5]=r.id,t[6]=i,t[7]=l,t[8]=o,t[9]=a):a=t[9];const{data:c,isLoading:d}=Bi(a),u=c?.output,f=c?.error;let h;return t[10]!==d||t[11]!==u||t[12]!==f?(h={output:u,error:f,isLoading:d},t[10]=d,t[11]=u,t[12]=f,t[13]=h):h=t[13],h}function Km(){const n=I.c(19),e=Dn(),t=Rn();let r;n[0]!==e.id?(r=qe(e.id),n[0]=e.id,n[1]=r):r=n[1];const s=r;let o;n[2]===Symbol.for("react.memo_cache_sentinel")?(o=["workflow"],n[2]=o):o=n[2];let i;n[3]!==t.id?(i={field:o,operator:"eq",value:t.id},n[3]=t.id,n[4]=i):i=n[4];let l;n[5]===Symbol.for("react.memo_cache_sentinel")?(l=[{field:["created_at"],direction:"desc"}],n[5]=l):l=n[5];let a;n[6]!==i?(a={where:i,orderBy:l,limit:100},n[6]=i,n[7]=a):a=n[7];const c=`${e.id}-executions-${t.id}`,d=!!t.id;let u;n[8]!==a||n[9]!==c||n[10]!==d||n[11]!==s?(u={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_LIST",toolInputParams:a,scope:c,enabled:d,staleTime:5e3},n[8]=a,n[9]=c,n[10]=d,n[11]=s,n[12]=u):u=n[12];const{data:f,isLoading:h,refetch:p}=Bi(u),y=f;let g;n[13]!==y?.items?(g=y?.items??[],n[13]=y?.items,n[14]=g):g=n[14];let x;return n[15]!==h||n[16]!==p||n[17]!==g?(x={executions:g,isLoading:h,refetch:p},n[15]=h,n[16]=p,n[17]=g,n[18]=x):x=n[18],x}function id(n){const e=[];function t(r){if(typeof r=="string"){const s=r.match(/@input(?:\.(\w+(?:\.\w+)*))?/g);if(s)for(const o of s)if(o==="@input")e.push("__entire_input__");else{const i=o.replace("@input.","");e.push(i)}}else Array.isArray(r)?r.forEach(t):typeof r=="object"&&r!==null&&Object.values(r).forEach(t)}return t(n),[...new Set(e)]}function Jm(n){const e=[];for(const t of n){const r=id(t.input);e.push(...r)}return[...new Set(e)].filter(t=>t!=="__entire_input__")}function Gm(n){for(const e of n)if(id(e.input).includes("__entire_input__"))return!0;return!1}function Xm(n){const e=Jm(n);if(e.length===0)return Gm(n)?{type:"object",additionalProperties:!0,description:"Workflow input data"}:null;const t={},r=[];for(const s of e){const o=s.split(".");if(o.length===1)t[s]={type:"string",description:`Input field: ${s}`},r.push(s);else{const i=o[0];i&&!t[i]&&(t[i]={type:"object",description:`Input object: ${i}`,additionalProperties:!0},r.push(i))}}return{type:"object",properties:t,required:r,description:"Workflow execution input"}}function Ym(){const n=I.c(2),e=Rn();let t;return n[0]!==e.steps?(t=Xm(e.steps),n[0]=e.steps,n[1]=t):t=n[1],t}function Qm(){const n=I.c(14),{id:e}=Dn(),{setTrackingExecutionId:t}=Me();let r;n[0]!==e?(r=qe(e),n[0]=e,n[1]=r):r=n[1];const s=r,o=Rn(),i=jn(),l=Ym();let a;n[2]!==s?(a={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_CREATE"},n[2]=s,n[3]=a):a=n[3];const{mutateAsync:c,isPending:d}=Fi(a);let u;n[4]!==i||n[5]!==t||n[6]!==c||n[7]!==o?(u=async y=>{const g=y===void 0?{}:y;if(!i)throw new Error("Please select an Agent before running the workflow");const x=Date.now(),b=await c({input:g,virtual_mcp_id:i,start_at_epoch_ms:x,workflow_collection_id:o.id}),S=b?.item?.id??b?.structuredContent?.item?.id;return t(S),S},n[4]=i,n[5]=t,n[6]=c,n[7]=o,n[8]=u):u=n[8];const f=u,h=l!==null;let p;return n[9]!==f||n[10]!==l||n[11]!==d||n[12]!==h?(p={handleRunWorkflow:f,isPending:d,requiresInput:h,inputSchema:l},n[9]=f,n[10]=l,n[11]=d,n[12]=h,n[13]=p):p=n[13],p}function Zm(){const n=I.c(9),{id:e}=Dn();let t;n[0]!==e?(t=qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"CANCEL_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=Fi(s);let l;n[4]!==o?(l=async d=>await o({executionId:d}),n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleCancelWorkflow:a,isCancelling:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function eg(){const n=I.c(9),{id:e}=Dn();let t;n[0]!==e?(t=qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"RESUME_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=Fi(s);let l;n[4]!==o?(l=async d=>(await o({executionId:d})).success,n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleResumeWorkflow:a,isResuming:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function tg(){const n=I.c(3),e=we(),{item:t}=Pn(e);let r;return n[0]!==t||n[1]!==e?(r=e&&t?(()=>{const o={};return t?.input&&(o.input=t.input),o})():void 0,n[0]=t,n[1]=e,n[2]=r):r=n[2],r}function ng(n,e,t,r){if(!e)return[...n].sort(r);const s=t(e);return[...n].sort((o,i)=>{const l=t(o),a=t(i);return l===s?-1:a===s?1:r?r(o,i):0})}const Ji=Nm()(nd(n=>({viewMode:"visual",setViewMode:e=>n({viewMode:e}),showExecutionsList:!1,setShowExecutionsList:e=>n({showExecutionsList:e}),toggleExecutionsList:()=>n(e=>({showExecutionsList:!e.showExecutionsList}))}),{name:"workflow-view-mode"})),ld=O.createContext([]);function ad(){return O.useContext(ld)}function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new xe(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xe(t)},addToStart:function(n,e){return new xe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new xe(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xe.from(n),n.size?new xe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xe.from(n),n.size?new xe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};function cd(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=cd(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function dd(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=dd(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class E{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new E(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new E(r,s)}cutByIndex(e,t){return e==t?E.empty:e==0&&t==this.content.length?this:new E(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new E(s,o)}addToStart(e){return new E([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new E(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return cd(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return dd(this,e,t,r)}findIndex(e){if(e==0)return Sr(0,e);if(e==this.size)return Sr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Sr(t+1,o):Sr(t,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,t){if(!t)return E.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new E(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return E.empty;let t,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)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new E(t||e,r)}static from(e){if(!e)return E.empty;if(e instanceof E)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new E([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}E.empty=new E([],0);const po={index:0,offset:0};function Sr(n,e){return po.index=n,po.offset=e,po}function Fr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Fr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Fr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Y=class Uo{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,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))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Uo.none;if(e instanceof Uo)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};Y.none=[];class Vr extends Error{}class R{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=fd(this.content,e+this.openStart,t);return r&&new R(r,this.openStart,this.openEnd)}removeBetween(e,t){return new R(ud(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return R.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new R(E.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new R(e,r,s)}}R.empty=new R(E.empty,0,0);function ud(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(ud(o.content,e-s-1,t-s-1)))}function fd(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=fd(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function rg(n,e,t){if(t.openStart>n.depth)throw new Vr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Vr("Inconsistent open depths");return hd(n,e,t,0)}function hd(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=hd(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Ft(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=sg(t,n);return Ft(o,md(n,i,l,e,r))}else return Ft(o,Hr(n,e,r))}function pd(n,e){if(!e.type.compatibleContent(n.type))throw new Vr("Cannot join "+e.type.name+" onto "+n.type.name)}function Ko(n,e,t){let r=n.node(t);return pd(r,e.node(t)),r}function Bt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function qn(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Bt(n.nodeAfter,r),o++));for(let l=o;l<i;l++)Bt(s.child(l),r);e&&e.depth==t&&e.textOffset&&Bt(e.nodeBefore,r)}function Ft(n,e){return n.type.checkContent(e),n.copy(e)}function md(n,e,t,r,s){let o=n.depth>s&&Ko(n,e,s+1),i=r.depth>s&&Ko(t,r,s+1),l=[];return qn(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(pd(o,i),Bt(Ft(o,md(n,e,t,r,s+1)),l)):(o&&Bt(Ft(o,Hr(n,e,s+1)),l),qn(e,t,s,l),i&&Bt(Ft(i,Hr(t,r,s+1)),l)),qn(r,null,s,l),new E(l)}function Hr(n,e,t){let r=[];if(qn(null,n,t,r),n.depth>t){let s=Ko(n,e,t+1);Bt(Ft(s,Hr(n,e,t+1)),r)}return qn(e,null,t,r),new E(r)}function sg(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(E.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class nr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.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,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Y.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}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 t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.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 t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Wr(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 t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new nr(t,r,o)}static resolveCached(e,t){let r=Ql.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else Ql.set(e,r=new og);let s=r.elts[r.i]=nr.resolve(e,t);return r.i=(r.i+1)%ig,s}}class og{constructor(){this.elts=[],this.i=0}}const ig=12,Ql=new WeakMap;class Wr{constructor(e,t,r){this.$from=e,this.$to=t,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 lg=Object.create(null);class ze{constructor(e,t,r,s=Y.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||E.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,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,t,r,s){return this.content.textBetween(e,t,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,t,r){return this.type==e&&Fr(this.attrs,t||e.defaultAttrs||lg)&&Y.sameSet(this.marks,r||Y.none)}copy(e=null){return e==this.content?this:new ze(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ze(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return R.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new R(c,s.depth-i,o.depth-i)}replace(e,t,r){return rg(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return nr.resolveCached(this,e)}resolveNoCache(e){return nr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,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()+")"),gd(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=E.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);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=Y.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Y.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=E.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}ze.prototype.text=void 0;class qr extends ze{constructor(e,t,r,s){if(super(e,t,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):gd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new qr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new qr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function gd(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ut{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ag(e,t);if(r.next==null)return Ut.empty;let s=yd(r);r.next&&r.err("Unexpected trailing text");let o=mg(pg(s));return gg(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return E.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let f=o(u,l.concat(d));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 t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=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 l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.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 t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(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(`
|
|
8
8
|
`)}}Ut.empty=new Ut(!0);class ag{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function yd(n){let e=[];do e.push(cg(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function cg(n){let e=[];do e.push(dg(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function dg(n){let e=hg(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ug(n,e);else break;return e}function Zl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ug(n,e){let t=Zl(n),r=t;return n.eat(",")&&(n.next!="}"?r=Zl(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function fg(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function hg(n){if(n.eat("(")){let e=yd(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=fg(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function pg(n){let e=[[]];return s(o(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(o(i.expr,a),d),a=d}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();r(a,d),s(o(i.expr,a),d),a=d}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function xd(n,e){return e-n}function ea(n,e){let t=[];return r(e),t.sort(xd);function r(s){let o=n[s];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&r(a)}}}function mg(n){let e=Object.create(null);return t(ea(n,0));function t(r){let s=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);ea(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new Ut(r.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(xd);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function gg(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.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 bd(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function kd(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let o=n[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Sd(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let o=n[s];o.validate&&o.validate(e[s])}}function wd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new xg(n,r,e[r]);return t}let ta=class vd{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=wd(e,r.attrs),this.defaultAttrs=bd(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==Ut.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:kd(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ze(this,this.computeAttrs(e),E.from(t),Y.setFrom(r))}createChecked(e=null,t,r){return t=E.from(t),this.checkContent(t),new ze(this,this.computeAttrs(e),t,Y.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=E.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(E.empty,!0);return o?new ze(this,e,t.append(o),Y.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.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){Sd(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 t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Y.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,i)=>r[o]=new vd(o,t,i));let s=t.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 yg(n,e,t){let r=t.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 ${n}, got ${o}`)}}class xg{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?yg(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ps{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=wd(e,s.attrs),this.excluded=null;let o=bd(this.attrs);this.instance=o?new Y(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Y(this,kd(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new Ps(o,s++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Sd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Cd{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=xe.from(e.nodes),t.marks=xe.from(e.marks||{}),this.nodes=ta.compile(this.spec.nodes,this),this.marks=Ps.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||"",l=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=Ut.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=l=="_"?null:l?na(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:na(this,i.split(" "))}this.nodeFromJSON=s=>ze.fromJSON(this,s),this.markFromJSON=s=>Y.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ta){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(t,r,s)}text(e,t){let r=this.nodes.text;return new qr(r,r.defaultAttrs,e,Y.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function na(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],o=n.marks[s],i=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function bg(n){return n.tag!=null}function kg(n){return n.style!=null}class kt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(bg(s))this.tags.push(s);else if(kg(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,t={}){let r=new sa(this,t,!1);return r.addAll(e,Y.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new sa(this,t,!0);return r.addAll(e,Y.none,t.from,t.to),R.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(vg(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=oa(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=oa(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new kt(e,kt.schemaRules(e)))}}const Nd={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Sg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ed={ol:!0,ul:!0},rr=1,Jo=2,Un=4;function ra(n,e,t){return e!=null?(e?rr:0)|(e==="full"?Jo:0):n&&n.whitespace=="pre"?rr|Jo:t&~Un}class wr{constructor(e,t,r,s,o,i){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=Y.none,this.match=o||(i&Un?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(E.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);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&rr)){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 t=E.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(E.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Nd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class sa{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=ra(null,t.preserveWhitespace,0)|(r?Un:0);s?o=new wr(s.type,s.attrs,Y.none,!0,t.topMatch||s.type.contentMatch,i):r?o=new wr(null,null,Y.none,!0,null,i):o=new wr(e.schema.topNodeType,null,Y.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,o=s.options&Jo?"full":this.localPreserveWS||(s.options&rr)>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,`
|
|
9
9
|
`);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(i.text(l[a]),t,!/\S/.test(l[a]));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 l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,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(),l;Ed.hasOwnProperty(i)&&this.parser.normalizeLists&&wg(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Sg.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Nd.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,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(o),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
10
10
|
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){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 l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,r){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=Y.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):ia(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,s)),o}enterInner(e,t,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=ra(e,o,i.options);i.options&Un&&i.content.length==0&&(l|=Un);let a=Y.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):ia(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new wr(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=rr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&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)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),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=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function wg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ed.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function vg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function oa(n){let e={};for(let t in n)e[t]=n[t];return e}function ia(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||o.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Qt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=mo(t).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(o.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Dr(mo(t),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,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Dr(mo(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Dr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=la(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return la(e.marks)}}function la(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function mo(n){return n.document||window.document}const aa=new WeakMap;function Cg(n){let e=aa.get(n);return e===void 0&&aa.set(n,e=Ng(n)),e}function Ng(n){let e=null;function t(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++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Dr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Cg(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&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Dr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Td=65535,Md=Math.pow(2,16);function Eg(n,e){return n+e*Md}function ca(n){return n&Td}function Tg(n){return(n-(n&Td))/Md}const Ad=1,Od=2,Pr=4,Id=8;class Go{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Id)>0}get deletedBefore(){return(this.delInfo&(Ad|Pr))>0}get deletedAfter(){return(this.delInfo&(Od|Pr))>0}get deletedAcross(){return(this.delInfo&Pr)>0}}class Re{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Re.empty)return Re.empty}recover(e){let t=0,r=ca(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Tg(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],d=this.ranges[l+i],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:Eg(l/3,e-a),y=e==a?Od:e==u?Ad:Pr;return(t<0?e!=a:e!=u)&&(y|=Id),new Go(h,y,p)}s+=d-c}return r?e+s:new Go(e+s,0,null)}touches(e,t){let r=0,s=ca(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=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],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],d=this.ranges[s+r];e(l,l+c,a,a+d),o+=d-c}}invert(){return new Re(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Re.empty:new Re(e<0?[0,-e,0]:[0,0,e])}}Re.empty=new Re([]);class sr{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new sr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new sr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Go(e,s,null)}}const go=Object.create(null);class Ne{getMap(){return Re.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=go[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in go)throw new RangeError("Duplicate use of step JSON ID "+e);return go[e]=t,t.prototype.jsonID=e,t}}class de{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new de(e,null)}static fail(e){return new de(null,e)}static fromReplace(e,t,r,s){try{return de.ok(e.replace(t,r,s))}catch(o){if(o instanceof Vr)return de.fail(o.message);throw o}}}function Gi(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let o=n.child(s);o.content.size&&(o=o.copy(Gi(o.content,e,o))),o.isInline&&(o=e(o,t,s)),r.push(o)}return E.fromArray(r)}class yt extends Ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new R(Gi(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,o)}invert(){return new He(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new yt(t.pos,r.pos,this.mark)}merge(e){return e instanceof yt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new yt(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("addMark",yt);class He extends Ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new R(Gi(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new yt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new He(t.pos,r.pos,this.mark)}merge(e){return e instanceof He&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new He(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new He(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("removeMark",He);class xt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new R(E.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new xt(this.pos,t.marks[s]);return new xt(this.pos,this.mark)}}return new Kt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("addNodeMark",xt);class Kt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new R(E.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new xt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Kt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Kt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("removeNodeMark",Kt);class he extends Ne{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Xo(e,this.from,this.to)?de.fail("Structure replace would overwrite content"):de.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Re([this.from,this.to-this.from,this.slice.size])}invert(e){return new he(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new he(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof he)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?R.empty:new R(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new he(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?R.empty:new R(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new he(e.from,this.to,t,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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new he(t.from,t.to,R.fromJSON(e,t.slice),!!t.structure)}}Ne.jsonID("replace",he);class ge extends Ne{constructor(e,t,r,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Xo(e,this.from,this.gapFrom)||Xo(e,this.gapTo,this.to)))return de.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return de.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?de.fromReplace(e,this.from,this.to,r):de.fail("Content does not fit in gap")}getMap(){return new Re([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ge(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||o>r.pos?null:new ge(t.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,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ge(t.from,t.to,t.gapFrom,t.gapTo,R.fromJSON(e,t.slice),t.insert,!!t.structure)}}Ne.jsonID("replaceAround",ge);function Xo(n,e,t){let r=n.resolve(e),s=t-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 Mg(n,e,t,r){let s=[],o=[],i,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(u);for(let y=0;y<u.length;y++)u[y].isInSet(p)||(i&&i.to==f&&i.mark.eq(u[y])?i.to=h:s.push(i=new He(f,h,u[y])));l&&l.to==f?l.to=h:o.push(l=new yt(f,h,r))}}),s.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function Ag(n,e,t,r){let s=[],o=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof Ps){let c=i.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==o-1&&u.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=o):s.push({style:u,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>n.step(new He(i.from,i.to,i.style)))}function Xi(n,e,t,r=t.contentMatch,s=!0){let o=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)i.push(new he(l,d,R.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new He(l,d,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new R(E.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new he(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(E.empty,!0);n.replace(l,l,new R(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Og(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ln(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,o=0;;--r){let i=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-o;if(r<n.depth&&i.canReplace(l,a,t))return r;if(r==0||i.type.spec.isolating||!Og(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function Ig(n,e,t){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,d=E.empty,u=0;for(let p=o,y=!1;p>t;p--)y||r.index(p)>0?(y=!0,d=E.from(r.node(p).copy(d)),u++):a--;let f=E.empty,h=0;for(let p=o,y=!1;p>t;p--)y||s.after(p+1)<s.end(p)?(y=!0,f=E.from(s.node(p).copy(f)),h++):c++;n.step(new ge(a,c,i,l,new R(d.append(f),u,h),d.size-u,!0))}function Yi(n,e,t=null,r=n){let s=Rg(n,e),o=s&&jg(r,e);return o?s.map(da).concat({type:e,attrs:t}).concat(o.map(da)):null}function da(n){return{type:n,attrs:null}}function Rg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(r,s,i)?o:null}function jg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Dg(n,e,t){let r=E.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=E.from(t[i].type.create(t[i].attrs,r))}let s=e.start,o=e.end;n.step(new ge(s,o,s,o,new R(r,0,0),t.length,!0))}function Pg(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&Lg(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&jd(n,i,l,o),Xi(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let d=n.mapping.slice(o),u=d.map(l,1),f=d.map(l+i.nodeSize,1);return n.step(new ge(u,f,u+1,f-1,new R(E.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Rd(n,i,l,o),!1}})}function Rd(n,e,t,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+o+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function jd(n,e,t,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+o);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
@@ -132,7 +132,7 @@ ${t}
|
|
|
132
132
|
`,rk="️",sk="",Lo="";let Ar=null,Or=null;function ok(n=[]){const e={};Ae.groups=e;const t=new Ae;Ar==null&&(Ar=dc(Yb)),Or==null&&(Or=dc(Qb)),M(t,"'",ys),M(t,"{",Xn),M(t,"}",Yn),M(t,"[",ts),M(t,"]",ns),M(t,"(",rs),M(t,")",ss),M(t,"<",is),M(t,">",ls),M(t,"(",as),M(t,")",cs),M(t,"「",ds),M(t,"」",us),M(t,"『",fs),M(t,"』",hs),M(t,"<",ps),M(t,">",ms),M(t,"&",gs),M(t,"*",xs),M(t,"@",ht),M(t,"`",ks),M(t,"^",Ss),M(t,":",gt),M(t,",",Nl),M(t,"$",ws),M(t,".",Ke),M(t,"=",vs),M(t,"!",El),M(t,"-",Pe),M(t,"%",Qn),M(t,"|",Cs),M(t,"+",Ns),M(t,"#",Es),M(t,"?",Zn),M(t,'"',Tl),M(t,"/",Je),M(t,";",Ml),M(t,"~",er),M(t,"_",Ts),M(t,"\\",bs),M(t,"・",Cf);const r=oe(t,tt,vl,{[hi]:!0});oe(r,tt,r);const s=oe(r,et,wf,{[Gn]:!0}),o=oe(r,Bn,vf,{[Wn]:!0}),i=oe(t,et,nt,{[pi]:!0});oe(i,tt,s),oe(i,et,i),oe(s,tt,s),oe(s,et,s);const l=oe(t,Bn,yi,{[mi]:!0});oe(l,et),oe(l,tt,o),oe(l,Bn,l),oe(o,tt,o),oe(o,et),oe(o,Bn,o);const a=M(t,Po,Cl,{[Ro]:!0}),c=M(t,cc,ki,{[Ro]:!0}),d=oe(t,Do,ki,{[Ro]:!0});M(t,Lo,d),M(c,Po,a),M(c,Lo,d),oe(c,Do,d),M(d,cc),M(d,Po),oe(d,Do,d),M(d,Lo,d);const u=oe(t,jo,Nf,{[Sf]:!0});M(u,"#"),oe(u,jo,u),M(u,rk,u);const f=M(u,sk);M(f,"#"),oe(f,jo,u);const h=[[et,i],[tt,s]],p=[[et,null],[Bn,l],[tt,o]];for(let y=0;y<Ar.length;y++)ct(t,Ar[y],xi,nt,h);for(let y=0;y<Or.length;y++)ct(t,Or[y],bi,yi,p);Pt(xi,{tld:!0,ascii:!0},e),Pt(bi,{utld:!0,alpha:!0},e),ct(t,"file",$r,nt,h),ct(t,"mailto",$r,nt,h),ct(t,"http",yn,nt,h),ct(t,"https",yn,nt,h),ct(t,"ftp",yn,nt,h),ct(t,"ftps",yn,nt,h),Pt($r,{scheme:!0,ascii:!0},e),Pt(yn,{slashscheme:!0,ascii:!0},e),n=n.sort((y,g)=>y[0]>g[0]?1:-1);for(let y=0;y<n.length;y++){const g=n[y][0],b=n[y][1]?{[Zb]:!0}:{[ek]:!0};g.indexOf("-")>=0?b[gi]=!0:et.test(g)?tt.test(g)?b[Gn]=!0:b[pi]=!0:b[hi]=!0,ac(t,g,g,b)}return ac(t,"localhost",ur,{ascii:!0}),t.jd=new Ae(Ms),{start:t,tokens:Object.assign({groups:e},Ef)}}function Tf(n,e){const t=ik(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,s=[];let o=0,i=0;for(;i<r;){let l=n,a=null,c=0,d=null,u=-1,f=-1;for(;i<r&&(a=l.go(t[i]));)l=a,l.accepts()?(u=0,f=0,d=l):u>=0&&(u+=t[i].length,f++),c+=t[i].length,o+=t[i].length,i++;o-=u,i-=f,c-=u,s.push({t:d.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function ik(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),o,i=s<55296||s>56319||r+1===t||(o=n.charCodeAt(r+1))<56320||o>57343?n[r]:n.slice(r,r+2);e.push(i),r+=i.length}return e}function ct(n,e,t,r,s){let o;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];n.j[a]?o=n.j[a]:(o=new Ae(r),o.jr=s.slice(),n.j[a]=o),n=o}return o=new Ae(t),o.jr=s.slice(),n.j[e[i-1]]=o,o}function dc(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let o=0;for(;s.indexOf(n[r+o])>=0;)o++;if(o>0){e.push(t.join(""));for(let i=parseInt(n.substring(r,r+o),10);i>0;i--)t.pop();r+=o}else t.push(n[r]),r++}return e}const fr={defaultProtocol:"http",events:null,format:uc,formatHref:uc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Al(n,e=null){let t=Object.assign({},fr);n&&(t=Object.assign(t,n instanceof Al?n.o:n));const r=t.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}Al.prototype={o:fr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:fr[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function uc(n){return n}function Mf(n,e){this.t="token",this.v=n,this.tk=e}Mf.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=fr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),o=this.toFormattedString(n),i={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),d&&Object.assign(i,d),{tagName:s,attributes:i,content:o,eventListeners:u}}};function Gs(n,e){class t extends Mf{constructor(s,o){super(s,o),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const fc=Gs("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),hc=Gs("text"),lk=Gs("nl"),Ir=Gs("url",{isLink:!0,toHref(n=fr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==ur&&n[1].t===gt}}),De=n=>new Ae(n);function ak({groups:n}){const e=n.domain.concat([gs,xs,ht,bs,ks,Ss,ws,vs,Pe,vl,Qn,Cs,Ns,Es,Je,Ms,er,Ts]),t=[ys,gt,Nl,Ke,El,Qn,Zn,Tl,Ml,is,ls,Xn,Yn,ns,ts,rs,ss,as,cs,ds,us,fs,hs,ps,ms],r=[gs,ys,xs,bs,ks,Ss,ws,vs,Pe,Xn,Yn,Qn,Cs,Ns,Es,Zn,Je,Ms,er,Ts],s=De(),o=M(s,er);W(o,r,o),W(o,n.domain,o);const i=De(),l=De(),a=De();W(s,n.domain,i),W(s,n.scheme,l),W(s,n.slashscheme,a),W(i,r,o),W(i,n.domain,i);const c=M(i,ht);M(o,ht,c),M(l,ht,c),M(a,ht,c);const d=M(o,Ke);W(d,r,o),W(d,n.domain,o);const u=De();W(c,n.domain,u),W(u,n.domain,u);const f=M(u,Ke);W(f,n.domain,u);const h=De(fc);W(f,n.tld,h),W(f,n.utld,h),M(c,ur,h);const p=M(u,Pe);M(p,Pe,p),W(p,n.domain,u),W(h,n.domain,u),M(h,Ke,f),M(h,Pe,p);const y=M(h,gt);W(y,n.numeric,fc);const g=M(i,Pe),x=M(i,Ke);M(g,Pe,g),W(g,n.domain,i),W(x,r,o),W(x,n.domain,i);const b=De(Ir);W(x,n.tld,b),W(x,n.utld,b),W(b,n.domain,i),W(b,r,o),M(b,Ke,x),M(b,Pe,g),M(b,ht,c);const S=M(b,gt),v=De(Ir);W(S,n.numeric,v);const k=De(Ir),w=De();W(k,e,k),W(k,t,w),W(w,e,k),W(w,t,w),M(b,Je,k),M(v,Je,k);const C=M(l,gt),T=M(a,gt),A=M(T,Je),D=M(A,Je);W(l,n.domain,i),M(l,Ke,x),M(l,Pe,g),W(a,n.domain,i),M(a,Ke,x),M(a,Pe,g),W(C,n.domain,k),M(C,Je,k),M(C,Zn,k),W(D,n.domain,k),W(D,e,k),M(D,Je,k);const j=[[Xn,Yn],[ts,ns],[rs,ss],[is,ls],[as,cs],[ds,us],[fs,hs],[ps,ms]];for(let _=0;_<j.length;_++){const[V,B]=j[_],H=M(k,V);M(w,V,H),M(H,B,k);const N=De(Ir);W(H,e,N);const z=De();W(H,t),W(N,e,N),W(N,t,z),W(z,e,N),W(z,t,z),M(N,B,k),M(z,B,k)}return M(s,ur,b),M(s,Cl,lk),{start:s,tokens:Ef}}function ck(n,e,t){let r=t.length,s=0,o=[],i=[];for(;s<r;){let l=n,a=null,c=null,d=0,u=null,f=-1;for(;s<r&&!(a=l.go(t[s].t));)i.push(t[s++]);for(;s<r&&(c=a||l.go(t[s].t));)a=null,l=c,l.accepts()?(f=0,u=l):f>=0&&f++,s++,d++;if(f<0)s-=d,s<r&&(i.push(t[s]),s++);else{i.length>0&&(o.push($o(hc,e,i)),i=[]),s-=f,d-=f;const h=u.t,p=t.slice(s-d,s);o.push($o(h,e,p))}}return i.length>0&&o.push($o(hc,e,i)),o}function $o(n,e,t){const r=t[0].s,s=t[t.length-1].e,o=e.slice(r,s);return new n(o,t)}const dk=typeof console<"u"&&console&&console.warn||(()=>{}),uk="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Z={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function fk(){return Ae.groups={},Z.scanner=null,Z.parser=null,Z.tokenQueue=[],Z.pluginQueue=[],Z.customSchemes=[],Z.initialized=!1,Z}function pc(n,e=!1){if(Z.initialized&&dk(`linkifyjs: already initialized - will not register custom scheme "${n}" ${uk}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
133
133
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
134
134
|
2. Cannot start or end with "-"
|
|
135
|
-
3. "-" cannot repeat`);Z.customSchemes.push([n,e])}function hk(){Z.scanner=ok(Z.customSchemes);for(let n=0;n<Z.tokenQueue.length;n++)Z.tokenQueue[n][1]({scanner:Z.scanner});Z.parser=ak(Z.scanner.tokens);for(let n=0;n<Z.pluginQueue.length;n++)Z.pluginQueue[n][1]({scanner:Z.scanner,parser:Z.parser});return Z.initialized=!0,Z}function Ol(n){return Z.initialized||hk(),ck(Z.parser.start,n,Tf(Z.scanner.start,n))}Ol.scan=Tf;function Af(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Al(t),s=Ol(n),o=[];for(let i=0;i<s.length;i++){const l=s[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&o.push(l.toFormattedObject(r))}return o}var Il="[\0- -\u2029 ]",pk=new RegExp(Il),mk=new RegExp(`${Il}$`),gk=new RegExp(Il,"g");function yk(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function xk(n){return new re({key:new ae("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=Wu(t.doc,[...e]);if(Yu(l).forEach(({newRange:c})=>{const d=ex(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!mk.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){const h=f.split(pk).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],y=u.pos+f.lastIndexOf(p);if(!p)return!1;const g=Ol(p).map(x=>x.toObject(n.defaultProtocol));if(!yk(g))return!1;g.filter(x=>x.isLink).map(x=>({...x,from:y+x.start+1,to:y+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>n.validate(x.value)).filter(x=>n.shouldAutoLink(x.value)).forEach(x=>{xl(x.from,x.to,r.doc).some(b=>b.mark.type===n.type)||i.addMark(x.from,x.to,n.type.create({href:x.href}))})}}),!!i.steps.length)return i}})}function bk(n){return new re({key:new ae("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i
|
|
135
|
+
3. "-" cannot repeat`);Z.customSchemes.push([n,e])}function hk(){Z.scanner=ok(Z.customSchemes);for(let n=0;n<Z.tokenQueue.length;n++)Z.tokenQueue[n][1]({scanner:Z.scanner});Z.parser=ak(Z.scanner.tokens);for(let n=0;n<Z.pluginQueue.length;n++)Z.pluginQueue[n][1]({scanner:Z.scanner,parser:Z.parser});return Z.initialized=!0,Z}function Ol(n){return Z.initialized||hk(),ck(Z.parser.start,n,Tf(Z.scanner.start,n))}Ol.scan=Tf;function Af(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Al(t),s=Ol(n),o=[];for(let i=0;i<s.length;i++){const l=s[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&o.push(l.toFormattedObject(r))}return o}var Il="[\0- -\u2029 ]",pk=new RegExp(Il),mk=new RegExp(`${Il}$`),gk=new RegExp(Il,"g");function yk(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function xk(n){return new re({key:new ae("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=Wu(t.doc,[...e]);if(Yu(l).forEach(({newRange:c})=>{const d=ex(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!mk.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){const h=f.split(pk).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],y=u.pos+f.lastIndexOf(p);if(!p)return!1;const g=Ol(p).map(x=>x.toObject(n.defaultProtocol));if(!yk(g))return!1;g.filter(x=>x.isLink).map(x=>({...x,from:y+x.start+1,to:y+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>n.validate(x.value)).filter(x=>n.shouldAutoLink(x.value)).forEach(x=>{xl(x.from,x.to,r.doc).some(b=>b.mark.type===n.type)||i.addMark(x.from,x.to,n.type.create({href:x.href}))})}}),!!i.steps.length)return i}})}function bk(n){return new re({key:new ae("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{const a=r.target;if(!a)return!1;const c=n.editor.view.dom;i=a.closest("a"),i&&!c.contains(i)&&(i=null)}if(!i)return!1;let l=!1;if(n.enableClickSelection&&(l=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const a=Xu(e.state,n.type.name),c=(s=i.href)!=null?s:a.href,d=(o=i.target)!=null?o:a.target;c&&(window.open(c,d),l=!0)}return l}}})}function kk(n){return new re({key:new ae("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:s}=n,{state:o}=e,{selection:i}=o,{empty:l}=i;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});const c=Af(a,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Ot(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(gk,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Sk=Zt.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(n=>{if(typeof n=="string"){pc(n);return}pc(n.scheme,n.optionalSlashes)})},onDestroy(){fk()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!Ot(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const s=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Ot(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Ot(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ne(this.options.HTMLAttributes,n),0]:["a",ne(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t;const r=((t=n.attrs)==null?void 0:t.href)||"";return`[${e.renderChildren(n)}](${r})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Ot(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Ot(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Xt({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=Af(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!Ot(i,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(o=>{this.options.shouldAutoLink(o.value)&&e.push({text:o.value,data:{href:o.href},index:o.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(xk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ot(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(bk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(kk({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),wk=Object.defineProperty,vk=(n,e)=>{for(var t in e)wk(n,t,{get:e[t],enumerable:!0})},Ck="listItem",mc="textStyle",gc=/^\s*([-+*])\s$/,Of=Ie.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:n}){return["ul",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
136
136
|
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ck,this.editor.getAttributes(mc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=An({find:gc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=An({find:gc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(mc),editor:this.editor})),[n]}}),If=Ie.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{if(n.type!=="list_item")return[];let t=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(s=>s.type==="paragraph"))t=e.parseChildren(n.tokens);else{const s=n.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(t=[{type:"paragraph",content:e.parseInline(s.tokens)}],n.tokens.length>1){const i=n.tokens.slice(1),l=e.parseChildren(i);t.push(...l)}}else t=e.parseChildren(n.tokens)}return t.length===0&&(t=[{type:"paragraph",content:[]}]),{type:"listItem",content:t}},renderMarkdown:(n,e,t)=>wl(n,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Nk={};vk(Nk,{findListItemPos:()=>xr,getNextListDepth:()=>Rl,handleBackspace:()=>Si,handleDelete:()=>wi,hasListBefore:()=>Rf,hasListItemAfter:()=>Ek,hasListItemBefore:()=>jf,listItemHasSubList:()=>Df,nextListIsDeeper:()=>Pf,nextListIsHigher:()=>Lf});var xr=(n,e)=>{const{$from:t}=e.selection,r=ue(n,e.schema);let s=null,o=t.depth,i=t.pos,l=null;for(;o>0&&l===null;)s=t.node(o),s.type===r?l=o:(o-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},Rl=(n,e)=>{const t=xr(n,e);if(!t)return!1;const[,r]=dx(e,n,t.$pos.pos+4);return r},Rf=(n,e,t)=>{const{$anchor:r}=n.selection,s=Math.max(0,r.pos-2),o=n.doc.resolve(s).node();return!(!o||!t.includes(o.type.name))},jf=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((t=s.nodeBefore)==null?void 0:t.type.name)!==n)},Df=(n,e,t)=>{if(!t)return!1;const r=ue(n,e.schema);let s=!1;return t.descendants(o=>{o.type===r&&(s=!0)}),s},Si=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Nt(n.state,e)&&Rf(n.state,e,t)){const{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const d=c.at(-1);if(!d)return!1;const u=n.state.doc.resolve(a.start()+d.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!Nt(n.state,e)||!px(n.state))return!1;const r=xr(e,n.state);if(!r)return!1;const o=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=Df(e,n.state,o);return jf(e,n.state)&&!i?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},Pf=(n,e)=>{const t=Rl(n,e),r=xr(n,e);return!r||!t?!1:t>r.depth},Lf=(n,e)=>{const t=Rl(n,e),r=xr(n,e);return!r||!t?!1:t<r.depth},wi=(n,e)=>{if(!Nt(n.state,e)||!hx(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:s}=t;return!t.empty&&r.sameParent(s)?!1:Pf(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():Lf(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},Ek=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((t=s.nodeAfter)==null?void 0:t.type.name)!==n)},$f=ce.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&wi(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&wi(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Si(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Si(n,t,r)&&(e=!0)}),e}}}}),yc=/^(\s*)(\d+)\.\s+(.*)$/,Tk=/^\s/;function Mk(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t],o=s.match(yc);if(!o)break;const[,i,l,a]=o,c=i.length;let d=a,u=t+1;const f=[s];for(;u<n.length;){const h=n[u];if(h.match(yc))break;if(h.trim()==="")f.push(h),d+=`
|
|
137
137
|
`,u+=1;else if(h.match(Tk))f.push(h),d+=`
|
|
138
138
|
${h.slice(c+2)}`,u+=1;else break}e.push({indent:c,number:parseInt(l,10),content:d.trim(),raw:f.join(`
|
|
@@ -143,7 +143,7 @@ ${h.slice(c+2)}`,u+=1;else break}e.push({indent:c,number:parseInt(l,10),content:
|
|
|
143
143
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const s=n.split(`
|
|
144
144
|
`),[o,i]=Mk(s);if(o.length===0)return;const l=zf(o,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=o[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,i).join(`
|
|
145
145
|
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ok,this.editor.getAttributes(xc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=An({find:bc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=An({find:bc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(xc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Ik=/^\s*(\[([( |x])?\])\s$/,Rk=Ie.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:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ne(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return wl(n,e,s)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};c(n),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const y=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...y?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{s.setAttribute(u,f)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([u,f])=>{s.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;s.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);const f=r.extensionManager.attributes,h=Tn(u,f),p=new Set(Object.keys(h)),y=this.options.HTMLAttributes;return d.forEach(g=>{p.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)}),d=p,!0}}}},addInputRules(){return[An({find:Ik,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),jk=Ie.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:n}){return["ul",ne(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
146
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=ui(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=ui(n,{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:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ce.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Of.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(If.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push($f.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(_f.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Rk.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(jk.configure(this.options.taskList)),n}});var Dk=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ne(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];return t.length===1&&t[0].type==="image"?e.parseChildren([t[0]]):e.createNode("paragraph",void 0,e.parseInline(t))},renderMarkdown:(n,e)=>!n||!Array.isArray(n.content)?"":e.renderChildren(n.content),addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Pk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Lk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$k=Zt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Mn({find:Pk,type:this.type})]},addPasteRules(){return[Xt({find:Lk,type:this.type})]}}),zk=Ie.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),_k=Zt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ne(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Bk(n={}){return new re({view(e){return new Fk(e,n)}})}class Fk{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.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:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),y=u?p.bottom:p.top;u&&f&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:y-g,bottom:y+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Pd(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}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)}}class ie extends q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ie.valid(r)?new ie(r):q.near(r)}content(){return R.empty}eq(e){return e instanceof ie&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ie(e.resolve(t.pos))}getBookmark(){return new jl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Vk(e)||!Hk(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ie.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(ie.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!$.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(ie.valid(l))return l}return null}}}ie.prototype.visible=!1;ie.findFrom=ie.findGapCursorFrom;q.jsonID("gapcursor",ie);class jl{constructor(e){this.pos=e}map(e){return new jl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ie.valid(t)?new ie(t):q.near(t)}}function Bf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Vk(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Bf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Hk(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Bf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Wk(){return new re({props:{decorations:Jk,createSelectionBetween(n,e,t){return e.pos==t.pos&&ie.valid(t)?new ie(t):null},handleClick:Uk,handleKeyDown:qk,handleDOMEvents:{beforeinput:Kk}}})}const qk=Lu({ArrowLeft:Rr("horiz",-1),ArrowRight:Rr("horiz",1),ArrowUp:Rr("vert",-1),ArrowDown:Rr("vert",1)});function Rr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof F){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ie.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ie(c))),!0):!1}}function Uk(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ie.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&$.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ie(r))),!0)}function Kk(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ie))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=E.empty;for(let i=r.length-1;i>=0;i--)s=E.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new R(s,0,0));return o.setSelection(F.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Jk(n){if(!(n.selection instanceof ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",te.create(n.doc,[Ce.widget(n.selection.head,e,{key:"gapcursor"})])}var As=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<As&&this.leafAppend(e)||this.length<As&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new Gk(this,e)};ye.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ye.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};ye.from=function(e){return e instanceof ye?e:e&&e.length?new Ff(e):ye.empty};var Ff=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={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,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=As)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=As)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ye);ye.empty=new Ff([]);var Gk=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.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 l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),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})(ye);const Xk=500;class Ve{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){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;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,d.push(u);return}if(s){d.push(new dt(u.map));let h=u.step.map(s.slice(o)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new dt(p,void 0,void 0,c.length+d.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(o)):u.selection,a=new Ve(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new dt(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>Qk&&(l=Yk(l,c),i-=c),new Ve(l.append(o),i)}remapping(e,t){let r=new sr;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,t),r}addMaps(e){return this.eventCount==0?this:new Ve(this.items.append(e.map(t=>new dt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=o.maps[h];if(f.step){let y=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(o.slice(a+1,h));g&&l++,r.push(new dt(p,y,g))}else r.push(new dt(p))},s);let c=[];for(let f=t;f<i;f++)c.push(new dt(o.maps[f]));let d=this.items.slice(0,s).append(c).append(r),u=new Ve(d,l);return u.emptyItemCount()>Xk&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=i.selection&&i.selection.map(t.slice(r));d&&o++;let u=new dt(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else i.map&&r--},this.items.length,0),new Ve(ye.from(s.reverse()),o)}}Ve.empty=new Ve(ye.empty,0);function Yk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}let dt=class Vf{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Vf(t.getMap().invert(),t,this.selection)}}};class pt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const Qk=20;function Zk(n,e,t,r){let s=t.getMeta(Wt),o;if(s)return s.historyState;t.getMeta(nS)&&(n=new pt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Wt))return i.getMeta(Wt).redo?new pt(n.done.addTransform(t,void 0,r,zr(e)),n.undone,kc(t.mapping.maps),n.prevTime,n.prevComposition):new pt(n.done,n.undone.addTransform(t,void 0,r,zr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!eS(t,n.prevRanges)),c=i?zo(n.prevRanges,t.mapping):kc(t.mapping.maps);return new pt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,zr(e)),Ve.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new pt(n.done.rebased(t,o),n.undone.rebased(t,o),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new pt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function eS(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function kc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function zo(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function tS(n,e,t){let r=zr(e),s=Wt.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new pt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Wt,{redo:t,historyState:a})}let _o=!1,Sc=null;function zr(n){let e=n.plugins;if(Sc!=e){_o=!1,Sc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){_o=!0;break}}return _o}const Wt=new ae("history"),nS=new ae("closeHistory");function rS(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new re({key:Wt,state:{init(){return new pt(Ve.empty,Ve.empty,null,0,-1)},apply(e,t,r){return Zk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Wf:r=="historyRedo"?qf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Hf(n,e){return(t,r)=>{let s=Wt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=tS(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const Wf=Hf(!1,!0),qf=Hf(!0,!0);ce.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new re({key:new ae("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.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 l=e.selection.$head.pos,a=o-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});var sS=ce.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Bk(this.options)]}});ce.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new re({key:new ae("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return te.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(Ce.node(c,c+a.nodeSize,{class:this.options.className}))}),te.create(n,o)}}})]}});var oS=ce.create({name:"gapCursor",addProseMirrorPlugins(){return[Wk()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=G(L(n,"allowGapCursor",t)))!=null?e:null}}});ce.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new re({key:new ae("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const o=this.editor.isEmpty;return n.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&Us(i);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=Ce.node(l,l+i.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),te.create(n,s)}}})]}});ce.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new re({key:new ae("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Qu(t.selection)||n.view.dragging?null:te.create(t.doc,[Ce.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function wc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var iS=ce.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ae(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new re({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,d=e.getState(i),u=l.content.size,f=c.nodes[t];if(d)return a.insert(u,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!wc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!wc({node:i,types:r})}}})]}}),lS=ce.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Wf(n,e),redo:()=>({state:n,dispatch:e})=>qf(n,e)}},addProseMirrorPlugins(){return[rS(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()}}}),aS=ce.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(Pb.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Ob.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Of.configure(this.options.bulletList)),this.options.code!==!1&&s.push(zb.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Fb.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Vb.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(sS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(oS.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Hb.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Wb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(lS.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(qb.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Xb.configure(this.options.italic)),this.options.listItem!==!1&&s.push(If.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push($f.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(Sk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(_f.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Dk.configure(this.options.paragraph)),this.options.strike!==!1&&s.push($k.configure(this.options.strike)),this.options.text!==!1&&s.push(zk.configure(this.options.text)),this.options.underline!==!1&&s.push(_k.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(iS.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),cS=aS;function dS(n){var e;const{char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=n,a=r&&!s,c=tb(t),d=new RegExp(`\\s${c}$`),u=i?"^":"",f=s?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const y=l.pos-p.length,g=Array.from(p.matchAll(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;const x=g.input.slice(Math.max(0,g.index-1),g.index),b=new RegExp(`^[${o?.join("")}\0]?$`).test(x);if(o!==null&&!b)return null;const S=y+g.index;let v=S+g[0].length;return a&&d.test(p.slice(v-1,v+1))&&(g[0]+=" ",v+=1),S<l.pos&&v>=l.pos?{range:{from:S,to:v},query:g[0].slice(t.length),text:g[0]}:null}var uS=new ae("suggestion");function fS({pluginKey:n=uS,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:y=dS,shouldShow:g}){let x;const b=h?.(),S=()=>{const C=e.state.selection.$anchor.pos,T=e.view.coordsAtPos(C),{top:A,right:D,bottom:j,left:_}=T;try{return new DOMRect(_,A,D-_,j-A)}catch{return null}},v=(C,T)=>T?()=>{const A=n.getState(e.state),D=A?.decorationId,j=C.dom.querySelector(`[data-decoration-id="${D}"]`);return j?.getBoundingClientRect()||null}:S;function k(C,T){var A;try{const j=n.getState(C.state),_=j?.decorationId?C.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null,V={editor:e,range:j?.range||{from:0,to:0},query:j?.query||null,text:j?.text||null,items:[],command:B=>u({editor:e,range:j?.range||{from:0,to:0},props:B}),decorationNode:_,clientRect:v(C,_)};(A=b?.onExit)==null||A.call(b,V)}catch{}const D=C.state.tr.setMeta(T,{exit:!0});C.dispatch(D)}const w=new re({key:n,view(){return{update:async(C,T)=>{var A,D,j,_,V,B,H;const N=(A=this.key)==null?void 0:A.getState(T),z=(D=this.key)==null?void 0:D.getState(C.state),P=N.active&&z.active&&N.range.from!==z.range.from,K=!N.active&&z.active,Q=N.active&&!z.active,le=!K&&!Q&&N.query!==z.query,X=K||P&&le,fe=le||P,se=Q||P&≤if(!X&&!fe&&!se)return;const J=se&&!X?N:z,Fe=C.dom.querySelector(`[data-decoration-id="${J.decorationId}"]`);x={editor:e,range:J.range,query:J.query,text:J.text,items:[],command:at=>u({editor:e,range:J.range,props:at}),decorationNode:Fe,clientRect:v(C,Fe)},X&&((j=b?.onBeforeStart)==null||j.call(b,x)),fe&&((_=b?.onBeforeUpdate)==null||_.call(b,x)),(fe||X)&&(x.items=await f({editor:e,query:J.query})),se&&((V=b?.onExit)==null||V.call(b,x)),fe&&((B=b?.onUpdate)==null||B.call(b,x)),X&&((H=b?.onStart)==null||H.call(b,x))},destroy:()=>{var C;x&&((C=b?.onExit)==null||C.call(b,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(C,T,A,D){const{isEditable:j}=e,{composing:_}=e.view,{selection:V}=C,{empty:B,from:H}=V,N={...T},z=C.getMeta(n);if(z&&z.exit)return N.active=!1,N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null,N;if(N.composing=_,j&&(B||e.view.composing)){(H<T.range.from||H>T.range.to)&&!_&&!T.composing&&(N.active=!1);const P=y({char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:V.$from}),K=`id_${Math.floor(Math.random()*4294967295)}`;P&&p({editor:e,state:D,range:P.range,isActive:T.active})&&(!g||g({editor:e,range:P.range,query:P.query,text:P.text,transaction:C}))?(N.active=!0,N.decorationId=T.decorationId?T.decorationId:K,N.range=P.range,N.query=P.query,N.text=P.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(C,T){var A,D,j,_;const{active:V,range:B}=w.getState(C.state);if(!V)return!1;if(T.key==="Escape"||T.key==="Esc"){const N=w.getState(C.state),z=(A=x?.decorationNode)!=null?A:null,P=z??(N?.decorationId?C.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null);if(((D=b?.onKeyDown)==null?void 0:D.call(b,{view:C,event:T,range:N.range}))||!1)return!0;const Q={editor:e,range:N.range,query:N.query,text:N.text,items:[],command:le=>u({editor:e,range:N.range,props:le}),decorationNode:P,clientRect:P?()=>P.getBoundingClientRect()||null:null};return(j=b?.onExit)==null||j.call(b,Q),k(C,n),!0}return((_=b?.onKeyDown)==null?void 0:_.call(b,{view:C,event:T,range:B}))||!1},decorations(C){const{active:T,range:A,decorationId:D,query:j}=w.getState(C);if(!T)return null;const _=!j?.length,V=[a];return _&&V.push(d),te.create(C.doc,[Ce.inline(A.from,A.to,{nodeName:l,class:V.join(" "),"data-decoration-id":D,"data-decoration-content":c})])}}});return w}function hS({editor:n,overrideSuggestionOptions:e,extensionName:t,char:r="@"}){const s=new ae;return{editor:n,char:r,pluginKey:s,command:({editor:o,range:i,props:l})=>{var a,c,d;const u=o.view.state.selection.$to.nodeAfter;(a=u?.text)!=null&&a.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:t,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(d=(c=o.view.dom.ownerDocument.defaultView)==null?void 0:c.getSelection())==null||d.collapseToEnd()},allow:({state:o,range:i})=>{const l=o.doc.resolve(i.from),a=o.schema.nodes[t];return!!l.parent.type.contentMatch.matchType(a)},...e}}function Uf(n){return(n.options.suggestions.length?n.options.suggestions:[n.options.suggestion]).map(e=>hS({editor:n.editor,overrideSuggestionOptions:e,extensionName:n.name,char:e.char}))}function vc(n,e){const t=Uf(n),r=t.find(s=>s.char===e);return r||(t.length?t[0]:null)}var pS=Ie.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:n,suggestion:e}){var t,r;return`${(t=e?.char)!=null?t:"@"}${(r=n.attrs.label)!=null?r:n.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:n,node:e,suggestion:t}){var r,s;return["span",ne(this.HTMLAttributes,n.HTMLAttributes),`${(r=t?.char)!=null?r:"@"}${(s=e.attrs.label)!=null?s:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:n=>n.getAttribute("data-mention-suggestion-char"),renderHTML:n=>({"data-mention-suggestion-char":n.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){const t=vc(this,n.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n,suggestion:t})];const r={...this.options};r.HTMLAttributes=ne({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:n,suggestion:t});return typeof s=="string"?["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...gf({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:n=>{const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r,l=o??i;e[s==="char"?"mentionSuggestionChar":s]=l,r=t.exec(n)}return e},serializeAttributes:n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e==="mentionSuggestionChar"?"char":e}="${t}"`).join(" ")}),renderText({node:n}){const e={options:this.options,node:n,suggestion:vc(this,n.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1;const{selection:r}=e,{empty:s,anchor:o}=r;if(!s)return!1;let i=new ze,l=0;return e.doc.nodesBetween(o-1,o,(a,c)=>{if(a.type.name===this.name)return t=!0,i=a,l=c,!1}),t&&n.insertText(this.options.deleteTriggerWithBackspace?"":i.attrs.mentionSuggestionChar,l,l+i.nodeSize),t})}},addProseMirrorPlugins(){return Uf(this).map(fS)}}),mS=pS,Bo,Xs="HoverCard",[Kf]=Mc(Xs,[Ac]),Ys=Ac(),[gS,Qs]=Kf(Xs),Jf=n=>{const{__scopeHoverCard:e,children:t,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=n,a=Ys(e),c=O.useRef(0),d=O.useRef(0),u=O.useRef(!1),f=O.useRef(!1),[h,p]=Ei({prop:r,defaultProp:s??!1,onChange:o,caller:Xs}),y=O.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>p(!0),i)},[i,p]),g=O.useCallback(()=>{clearTimeout(c.current),!u.current&&!f.current&&(d.current=window.setTimeout(()=>p(!1),l))},[l,p]),x=O.useCallback(()=>p(!1),[p]);return O.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),m.jsx(gS,{scope:e,open:h,onOpenChange:p,onOpen:y,onClose:g,onDismiss:x,hasSelectionRef:u,isPointerDownOnContentRef:f,children:m.jsx(Nh,{...a,children:t})})};Jf.displayName=Xs;var Gf="HoverCardTrigger",Xf=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Qs(Gf,t),o=Ys(t);return m.jsx(vh,{asChild:!0,...o,children:m.jsx(Ni.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:Ge(n.onPointerEnter,Is(s.onOpen)),onPointerLeave:Ge(n.onPointerLeave,Is(s.onClose)),onFocus:Ge(n.onFocus,s.onOpen),onBlur:Ge(n.onBlur,s.onClose),onTouchStart:Ge(n.onTouchStart,i=>i.preventDefault())})})});Xf.displayName=Gf;var Dl="HoverCardPortal",[yS,xS]=Kf(Dl,{forceMount:void 0}),Yf=n=>{const{__scopeHoverCard:e,forceMount:t,children:r,container:s}=n,o=Qs(Dl,e);return m.jsx(yS,{scope:e,forceMount:t,children:m.jsx(Oc,{present:t||o.open,children:m.jsx(Ch,{asChild:!0,container:s,children:r})})})};Yf.displayName=Dl;var Os="HoverCardContent",Qf=O.forwardRef((n,e)=>{const t=xS(Os,n.__scopeHoverCard),{forceMount:r=t.forceMount,...s}=n,o=Qs(Os,n.__scopeHoverCard);return m.jsx(Oc,{present:r||o.open,children:m.jsx(bS,{"data-state":o.open?"open":"closed",...s,onPointerEnter:Ge(n.onPointerEnter,Is(o.onOpen)),onPointerLeave:Ge(n.onPointerLeave,Is(o.onClose)),ref:e})})});Qf.displayName=Os;var bS=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=n,a=Qs(Os,t),c=Ys(t),d=O.useRef(null),u=Ic(e,d),[f,h]=O.useState(!1);return O.useEffect(()=>{if(f){const p=document.body;return Bo=p.style.userSelect||p.style.webkitUserSelect,p.style.userSelect="none",p.style.webkitUserSelect="none",()=>{p.style.userSelect=Bo,p.style.webkitUserSelect=Bo}}},[f]),O.useEffect(()=>{if(d.current){const p=()=>{h(!1),a.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(a.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",p),()=>{document.removeEventListener("pointerup",p),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!1}}},[a.isPointerDownOnContentRef,a.hasSelectionRef]),O.useEffect(()=>{d.current&&wS(d.current).forEach(y=>y.setAttribute("tabindex","-1"))}),m.jsx(Eh,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:Ge(o,p=>{p.preventDefault()}),onDismiss:a.onDismiss,children:m.jsx(Th,{...c,...l,onPointerDown:Ge(l.onPointerDown,p=>{p.currentTarget.contains(p.target)&&h(!0),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!0}),ref:u,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),kS="HoverCardArrow",SS=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Ys(t);return m.jsx(Mh,{...s,...r,ref:e})});SS.displayName=kS;function Is(n){return e=>e.pointerType==="touch"?void 0:n()}function wS(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)e.push(t.currentNode);return e}var vS=Jf,CS=Xf,NS=Yf,ES=Qf;function TS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(vS,{"data-slot":"hover-card",...t}),e[2]=t,e[3]=r):r=e[3],r}function MS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(CS,{"data-slot":"hover-card-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function AS(n){const e=I.c(12);let t,r,s,o;e[0]!==n?({className:t,align:s,sideOffset:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"center":s,l=o===void 0?4:o;let a;e[5]!==t?(a=U("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),e[5]=t,e[6]=a):a=e[6];let c;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==a?(c=m.jsx(NS,{"data-slot":"hover-card-portal",children:m.jsx(ES,{"data-slot":"hover-card-content",align:i,sideOffset:l,className:a,...r})}),e[7]=i,e[8]=r,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}const Zf=O.createContext(void 0);function OS(n,e){const t=e.split("."),r=t[0];if(!r)return;let s=n[r];for(let o=1;o<t.length&&s!==void 0;o++){const i=t[o];if(i)if(typeof s=="object"&&s!==null)s=s[i];else return}return s}function IS(n){const e=I.c(20),{node:t}=n,r=O.useContext(Zf),s=t.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const y=o?OS(r,s):void 0;i=y!==void 0?typeof y=="object"?JSON.stringify(y,null,2):String(y):void 0,e[0]=o,e[1]=s,e[2]=r,e[3]=i}else i=e[3];const l=i;let a;e[4]!==s?(a=m.jsxs("span",{className:"bg-primary/20 text-primary px-1 rounded font-medium cursor-pointer",children:["@",s]}),e[4]=s,e[5]=a):a=e[5];const c=a;if(!o||l===void 0){let y;return e[6]!==c?(y=m.jsx(oc,{as:"span",children:c}),e[6]=c,e[7]=y):y=e[7],y}let d;e[8]!==c?(d=m.jsx(MS,{asChild:!0,children:c}),e[8]=c,e[9]=d):d=e[9];let u;e[10]!==s?(u=m.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["@",s]}),e[10]=s,e[11]=u):u=e[11];let f;e[12]!==l?(f=m.jsx("pre",{className:"text-xs font-mono bg-muted/50 p-2 rounded overflow-auto max-h-[200px] whitespace-pre-wrap break-all",children:l}),e[12]=l,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==f?(h=m.jsx(AS,{className:"w-auto max-w-[400px] p-3",side:"top",align:"start",children:m.jsxs("div",{className:"space-y-1.5",children:[u,f]})}),e[14]=u,e[15]=f,e[16]=h):h=e[16];let p;return e[17]!==d||e[18]!==h?(p=m.jsx(oc,{as:"span",children:m.jsxs(TS,{openDelay:200,children:[d,h]})}),e[17]=d,e[18]=h,e[19]=p):p=e[19],p}function eh(n){const e=[];function t(r){for(const s of r)s.children?.length||e.push(s),s.children&&t(s.children)}return t(n),e}let Xe=th();function th(){return Ki(()=>({items:[],selectedIndex:0,command:null}))}function Cc(n,e){Xe.setState({items:n,command:e,selectedIndex:0})}function RS(){const{items:n,selectedIndex:e}=Xe.getState();n.length&&Xe.setState({selectedIndex:(e-1+n.length)%n.length})}function jS(){const{items:n,selectedIndex:e}=Xe.getState();n.length&&Xe.setState({selectedIndex:(e+1)%n.length})}function nh(){const{items:n,selectedIndex:e,command:t}=Xe.getState(),r=n[e];return r?(t?.(r),!0):!1}function Nc(){Xe=th()}function DS(){const n=I.c(7),e=Wo(Xe,LS),t=Wo(Xe,PS);if(!e.length)return null;let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==t?(o=(i,l)=>m.jsx("button",{type:"button",onClick:()=>{Xe.setState({selectedIndex:l}),nh()},className:U("flex items-center w-full text-left px-3 py-1.5 text-sm rounded-md transition-colors",l===t?"bg-accent text-accent-foreground":"hover:bg-muted"),children:i.label},i.id),n[3]=t,n[4]=o):o=n[4],r=e.map(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];let s;return n[5]!==r?(s=m.jsx("div",{className:"bg-popover border border-border rounded-lg shadow-lg overflow-hidden min-w-[180px]",children:m.jsx("div",{className:"p-1",children:r})}),n[5]=r,n[6]=s):s=n[6],s}function PS(n){return n.selectedIndex}function LS(n){return n.items}function $S(){let n=null,e=null;return{onStart:t=>{Cc(t.items,t.command),n=new kf(DS,{editor:t.editor}),e=document.createElement("div"),e.style.cssText="position:absolute;z-index:9999";const r=t.clientRect?.();r&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`),e.appendChild(n.element),document.body.appendChild(e)},onUpdate:t=>{Cc(t.items,t.command);const r=t.clientRect?.();r&&e&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`)},onKeyDown:({event:t})=>t.key==="Escape"?(e?.remove(),n?.destroy(),Nc(),!0):t.key==="ArrowUp"?(RS(),!0):t.key==="ArrowDown"?(jS(),!0):t.key==="Enter"?nh():!1,onExit:()=>{e?.remove(),n?.destroy(),Nc()}}}const Fo=/@([\w.]+)/g;function zS(n,e){if(!n)return null;const t=eh(e),r=new Map(t.map(a=>[a.id,a]));if(!Fo.test(n))return n;Fo.lastIndex=0;const o=[];let i=0,l;for(;(l=Fo.exec(n))!==null;){const a=l[1]??"",c=l.index;c>i&&o.push({type:"text",text:n.slice(i,c)});const d=r.get(a);d?o.push({type:"mention",attrs:{id:d.id,label:d.label}}):o.push({type:"text",text:l[0]}),i=c+l[0].length}return i<n.length&&o.push({type:"text",text:n.slice(i)}),{type:"doc",content:[{type:"paragraph",content:o.length>0?o:void 0}]}}function Pl(n){const e=I.c(31),{mentions:t,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=n,a=tg();let c;e[0]!==t||e[1]!==r?(c=zS(r,t),e[0]=t,e[1]=r,e[2]=c):c=e[2];const d=c,u=a!==void 0,f=!l;let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=cS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let p;if(e[4]!==t||e[5]!==u){let A;e[7]!==t?(A=D=>{const{query:j}=D;return eh(t).filter(V=>V.label.toLowerCase().includes(j.toLowerCase())||V.id.toLowerCase().includes(j.toLowerCase()))},e[7]=t,e[8]=A):A=e[8],p=mS.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:VS,renderHTML:FS,suggestion:{items:A,render:$S,command:BS}}).extend(u?{addNodeView(){return Mb(IS)}}:{}),e[4]=t,e[5]=u,e[6]=p}else p=e[6];let y;e[9]!==p?(y=[h,p],e[9]=p,e[10]=y):y=e[10];const g=o??"";let x;e[11]!==g?(x={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full min-h-[20px]","data-placeholder":g},handleKeyDown:_S},e[11]=g,e[12]=x):x=e[12];let b;e[13]!==s?(b=A=>{const{editor:D}=A;return s?.(D.getText().trim())},e[13]=s,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==f||e[17]!==y||e[18]!==x||e[19]!==b?(S={content:d,editable:f,extensions:y,editorProps:x,onUpdate:b},e[15]=d,e[16]=f,e[17]=y,e[18]=x,e[19]=b,e[20]=S):S=e[20];const v=Sb(S);let k;e[21]!==i?(k=U("rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",i),e[21]=i,e[22]=k):k=e[22];let w;e[23]!==v?(w=m.jsx(pb,{editor:v}),e[23]=v,e[24]=w):w=e[24];let C;e[25]!==k||e[26]!==w?(C=m.jsx("div",{className:k,children:w}),e[25]=k,e[26]=w,e[27]=C):C=e[27];const T=C;if(a!==void 0){let A;return e[28]!==T||e[29]!==a?(A=m.jsx(Zf.Provider,{value:a,children:T}),e[28]=T,e[29]=a,e[30]=A):A=e[30],A}return T}function _S(n,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function BS(n){const{editor:e,range:t,props:r}=n;e.chain().focus().insertContentAt(t,[{type:"mention",attrs:r}]).run()}function FS(n){const{options:e,node:t}=n;return["span",e.HTMLAttributes,`@${t.attrs.id}`]}function VS(n){const{node:e}=n;return`@${e.attrs.id}`}function HS(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=ad(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx(Pl,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function WS(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=ad(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx(Pl,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o,className:"min-h-[80px]"}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function qS(n){const e=I.c(8),{value:t,onChange:r,readonly:s,id:o}=n,i=t??"";let l;e[0]!==r?(l=d=>r(d.target.value===""?void 0:Number(d.target.value)),e[0]=r,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=U("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),e[2]=a):a=e[2];let c;return e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==l?(c=m.jsx("input",{id:o,type:"number",value:i,onChange:l,disabled:s,className:a}),e[3]=o,e[4]=s,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function US(n){const e=I.c(13),{value:t,onChange:r,readonly:s,id:o,label:i}=n,l=t??!1;let a;e[0]!==r?(a=f=>r(f.target.checked),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==o||e[3]!==s||e[4]!==l||e[5]!==a?(c=m.jsx("input",{id:o,type:"checkbox",checked:l,onChange:a,disabled:s,className:"h-4 w-4 rounded border-input"}),e[2]=o,e[3]=s,e[4]=l,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==i?(d=m.jsx("span",{className:"text-sm",children:i}),e[7]=i,e[8]=d):d=e[8];let u;return e[9]!==o||e[10]!==c||e[11]!==d?(u=m.jsxs("label",{htmlFor:o,className:"flex items-center gap-2 cursor-pointer",children:[c,d]}),e[9]=o,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function KS(n){const e=I.c(14),{value:t,onChange:r,readonly:s,id:o,options:i}=n;let l;e[0]!==i.enumOptions?(l=i.enumOptions??[],e[0]=i.enumOptions,e[1]=l):l=e[1];const a=l,c=t??"";let d;e[2]!==r?(d=y=>r(y.target.value),e[2]=r,e[3]=d):d=e[3];let u,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=U("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),f=m.jsx("option",{value:"",children:"Select..."}),e[4]=u,e[5]=f):(u=e[4],f=e[5]);let h;e[6]!==a?(h=a.map(JS),e[6]=a,e[7]=h):h=e[7];let p;return e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==d||e[12]!==h?(p=m.jsxs("select",{id:o,value:c,onChange:d,disabled:s,className:u,children:[f,h]}),e[8]=o,e[9]=s,e[10]=c,e[11]=d,e[12]=h,e[13]=p):p=e[13],p}function JS(n){return m.jsx("option",{value:String(n.value),children:String(n.label)},String(n.value))}const GS={TextWidget:HS,TextareaWidget:WS,NumberWidget:qS,CheckboxWidget:US,SelectWidget:KS};function XS(n){switch(Array.isArray(n)?n[0]:n??"unknown"){case"string":return{Icon:Uc,color:"text-blue-500"};case"number":case"integer":return{Icon:Wc,color:"text-blue-500"};case"array":return{Icon:Fc,color:"text-purple-500"};case"object":return{Icon:Bc,color:"text-orange-500"};case"boolean":return{Icon:qc,color:"text-pink-500"};case"null":return{Icon:Ti,color:"text-gray-500"};default:return{Icon:Vc,color:"text-muted-foreground"}}}function YS(n){const e=I.c(36),{id:t,label:r,required:s,description:o,children:i,schema:l,hidden:a}=n;if(a){let k;return e[0]!==i?(k=m.jsx("div",{className:"hidden",children:i}),e[0]=i,e[1]=k):k=e[1],k}if(t==="root"){let k;return e[2]!==i?(k=m.jsx("div",{className:"space-y-4",children:i}),e[2]=i,e[3]=k):k=e[3],k}const c=Array.isArray(l.type)?l.type[0]:l.type??"string";let d,u,f,h,p,y,g;if(e[4]!==t||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:k,color:w}=XS(c);g="space-y-2",h="flex items-center gap-2",e[15]!==t||e[16]!==r?(p=m.jsx("label",{htmlFor:t,className:"text-sm font-medium leading-none",children:r}),e[15]=t,e[16]=r,e[17]=p):p=e[17],e[18]!==s?(y=s&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"}),e[18]=s,e[19]=y):y=e[19],d=k,u=14,f=U(w,"ml-auto"),e[4]=t,e[5]=r,e[6]=s,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=h,e[12]=p,e[13]=y,e[14]=g}else d=e[8],u=e[9],f=e[10],h=e[11],p=e[12],y=e[13],g=e[14];let x;e[20]!==d||e[21]!==u||e[22]!==f?(x=m.jsx(d,{size:u,className:f}),e[20]=d,e[21]=u,e[22]=f,e[23]=x):x=e[23];let b;e[24]!==h||e[25]!==p||e[26]!==y||e[27]!==x?(b=m.jsxs("div",{className:h,children:[p,y,x]}),e[24]=h,e[25]=p,e[26]=y,e[27]=x,e[28]=b):b=e[28];let S;e[29]!==o?(S=o&&m.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=S):S=e[30];let v;return e[31]!==i||e[32]!==g||e[33]!==b||e[34]!==S?(v=m.jsxs("div",{className:g,children:[b,S,i]}),e[31]=i,e[32]=g,e[33]=b,e[34]=S,e[35]=v):v=e[35],v}function QS(n){const e=I.c(8),{properties:t,title:r}=n;if(!r||r==="Root"){let l;e[0]!==t?(l=t.map(ew),e[0]=t,e[1]=l):l=e[1];let a;return e[2]!==l?(a=m.jsx("div",{className:"space-y-4",children:l}),e[2]=l,e[3]=a):a=e[3],a}let o;e[4]!==t?(o=t.map(ZS),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==o?(i=m.jsx("div",{className:"pl-4 border-l-2 border-border/50 space-y-4",children:o}),e[6]=o,e[7]=i):i=e[7],i}function ZS(n){return m.jsx("div",{children:n.content},n.name)}function ew(n){return m.jsx("div",{children:n.content},n.name)}function tw(n){const e=I.c(11),{items:t,canAdd:r,onAddClick:s,title:o}=n;let i;e[0]!==t?(i=t.map(nw),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=m.jsx("div",{className:"space-y-2",children:i}),e[2]=i,e[3]=l):l=e[3];let a;e[4]!==r||e[5]!==s||e[6]!==o?(a=r&&m.jsxs(me,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:s,children:["+ Add ",o||"item"]}),e[4]=r,e[5]=s,e[6]=o,e[7]=a):a=e[7];let c;return e[8]!==l||e[9]!==a?(c=m.jsxs("div",{className:"space-y-2",children:[l,a]}),e[8]=l,e[9]=a,e[10]=c):c=e[10],c}function nw(n){return m.jsx("div",{className:"flex gap-2 items-start",children:m.jsx("div",{className:"flex-1",children:n})},n.key||n.index)}function rw(){return null}function sw(){return null}const ow={FieldTemplate:YS,ObjectFieldTemplate:QS,ArrayFieldTemplate:tw,UnsupportedFieldTemplate:rw,ErrorListTemplate:sw};function iw(n){const e=I.c(6),{inputSchema:t,inputParams:r,mentions:s}=n;if(!t?.properties||!r)return null;let o;e[0]!==s?(o=(a,c,d)=>{const u=typeof c=="object"&&c!==null?JSON.stringify(c,null,2):String(c??""),f=Array.isArray(d.type)?d.type.join(" | "):d.type??"string";return m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),m.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:f})]}),d.description&&m.jsx("div",{className:"text-xs text-muted-foreground",children:d.description}),m.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:m.jsx(Pl,{mentions:s,value:u,readOnly:!0,className:"border-0 bg-transparent p-0"})})]},a)},e[0]=s,e[1]=o):o=e[1];const i=o;let l;return e[2]!==r||e[3]!==t.properties||e[4]!==i?(l=m.jsx("div",{className:"space-y-4",children:Object.entries(t.properties).map(a=>{const[c,d]=a,u=r[c];return i(c,u,d)})}),e[2]=r,e[3]=t.properties,e[4]=i,e[5]=l):l=e[5],l}function rh({inputSchema:n,inputParams:e,setInputParams:t,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!n)return m.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return m.jsx(iw,{inputSchema:n,inputParams:e,mentions:i});const l=n,a=O.useRef(e??{}),c=d=>{const u=d.formData??{},f=a.current;if(t?.(u),r){for(const[h,p]of Object.entries(u))f[h]!==p&&r(h,p);for(const h of Object.keys(f))h in u||r(h,void 0)}a.current=u};return m.jsx(ld.Provider,{value:i,children:m.jsx(qh,{schema:l,formData:e,onChange:c,validator:Uh,widgets:GS,templates:ow,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:m.jsx(m.Fragment,{})})})}function lw(n){const e=I.c(33),{open:t,onOpenChange:r,inputSchema:s,onSubmit:o,isPending:i}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[a,c]=O.useState(l);let d;e[1]!==a||e[2]!==r||e[3]!==o?(d=async()=>{await o(a),r(!1),c({})},e[1]=a,e[2]=r,e[3]=o,e[4]=d):d=e[4];const u=d;let f;e[5]!==r?(f=T=>{T||c({}),r(T)},e[5]=r,e[6]=f):f=e[6];const h=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsxs(dp,{children:[m.jsx(up,{children:"Workflow Input"}),m.jsx(fp,{children:"This workflow requires input values to run. Fill in the fields below to start the execution."})]}),e[7]=p):p=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[8]=y):y=e[8];let g;e[9]!==a||e[10]!==s?(g=m.jsx("div",{className:"py-4",children:m.jsx(rh,{inputSchema:s,inputParams:a,setInputParams:c,mentions:y})}),e[9]=a,e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h?(x=()=>h(!1),e[12]=h,e[13]=x):x=e[13];let b;e[14]!==i||e[15]!==x?(b=m.jsx(me,{variant:"outline",onClick:x,disabled:i,children:"Cancel"}),e[14]=i,e[15]=x,e[16]=b):b=e[16];let S;e[17]!==i?(S=i?m.jsx(Ds,{size:"xs"}):m.jsx(Li,{size:14}),e[17]=i,e[18]=S):S=e[18];let v;e[19]!==u||e[20]!==i||e[21]!==S?(v=m.jsxs(me,{onClick:u,disabled:i,className:"gap-2",children:[S,"Run Workflow"]}),e[19]=u,e[20]=i,e[21]=S,e[22]=v):v=e[22];let k;e[23]!==v||e[24]!==b?(k=m.jsxs(hp,{children:[b,v]}),e[23]=v,e[24]=b,e[25]=k):k=e[25];let w;e[26]!==k||e[27]!==g?(w=m.jsxs(pp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[p,g,k]}),e[26]=k,e[27]=g,e[28]=w):w=e[28];let C;return e[29]!==h||e[30]!==t||e[31]!==w?(C=m.jsx(mp,{open:t,onOpenChange:h,children:w}),e[29]=h,e[30]=t,e[31]=w,e[32]=C):C=e[32],C}function aw(n){const e=I.c(26),{title:t,description:r,onSave:s}=n,i=Ci().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:d}=Ji(),{resetToOriginalWorkflow:u,setSelectedGatewayId:f}=Me(),h=od(),p=jn(),y=we();let g;e[0]!==t?(g=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t}),e[0]=t,e[1]=g):g=e[1];let x;e[2]!==r?(x=r?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:r})]}):null,e[2]=r,e[3]=x):x=e[3];let b;e[4]!==g||e[5]!==x?(b=m.jsx(Lc,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g,x]})}),e[4]=g,e[5]=x,e[6]=b):b=e[6];let S;e[7]!==h||e[8]!==s||e[9]!==u||e[10]!==p||e[11]!==f||e[12]!==a||e[13]!==c||e[14]!==t||e[15]!==d||e[16]!==y||e[17]!==i||e[18]!==l?(S=!y&&m.jsxs(m.Fragment,{children:[m.jsx(Oi,{title:t,url:i,icon:"workflow"}),m.jsx(O.Suspense,{fallback:m.jsx(Ds,{size:"xs"}),children:m.jsx(Wm,{selectedGatewayId:p,onGatewayChange:f,placeholder:"Select Agent"})}),m.jsx(ap,{value:l,onValueChange:a,size:"sm",options:[{value:"visual",icon:m.jsx(cp,{})},{value:"code",icon:m.jsx(Gc,{})}]}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:u,disabled:!h,"aria-label":"Reset changes",children:m.jsx(Pc,{size:14})})})}),m.jsx($t,{side:"bottom",children:"Reset changes"})]})}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:!h,"aria-label":"Save workflow",children:m.jsx(Ui,{size:14})})})}),m.jsx($t,{side:"bottom",children:"Save workflow"})]})}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:c?"secondary":"outline",size:"icon",className:"size-7 border border-input",onClick:d,"aria-label":c?"Hide runs":"Show runs",children:m.jsx(Jc,{size:14})})})}),m.jsx($t,{side:"bottom",children:c?"Hide runs":"Show runs"})]})})]}),e[7]=h,e[8]=s,e[9]=u,e[10]=p,e[11]=f,e[12]=a,e[13]=c,e[14]=t,e[15]=d,e[16]=y,e[17]=i,e[18]=l,e[19]=S):S=e[19];let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=m.jsx(uw,{}),e[20]=v):v=e[20];let k;e[21]!==S?(k=m.jsxs(Di,{children:[S,v]}),e[21]=S,e[22]=k):k=e[22];let w;return e[23]!==b||e[24]!==k?(w=m.jsxs(m.Fragment,{children:[b,k]}),e[23]=b,e[24]=k,e[25]=w):w=e[25],w}function cw(){const n=we(),{item:e}=Pn(n);return e?.completed_at_epoch_ms!=null}function dw(){const n=we(),{item:e}=Pn(n);return e?.status==="cancelled"}function uw(){const n=I.c(57),e=od(),t=cw(),r=dw(),s=we(),o=jn(),{handleRunWorkflow:i,isPending:l,requiresInput:a,inputSchema:c}=Qm(),d=pr(),[u,f]=O.useState(!1),{handleCancelWorkflow:h,isCancelling:p}=Zm(),{handleResumeWorkflow:y,isResuming:g}=eg(),x=s&&!t;let b;n[0]!==d?(b=d.some(fw),n[0]=d,n[1]=b):b=n[1];const S=b,v=!o,k=e||S||v||l||p,w=x||l;let C;n[2]!==S||n[3]!==v||n[4]!==e||n[5]!==r||n[6]!==w?(C=()=>r?"Workflow is currently cancelled":w?"Workflow is currently running":e?"Save your changes before running":v?"Select an Agent first":S?"Add at least one step to the workflow":null,n[2]=S,n[3]=v,n[4]=e,n[5]=r,n[6]=w,n[7]=C):C=n[7];const A=C();let D;n[8]!==h||n[9]!==y||n[10]!==i||n[11]!==c||n[12]!==r||n[13]!==w||n[14]!==a||n[15]!==s?(D=async()=>{if(a&&c){f(!0);return}if(r&&s){await y(s);return}if(w&&s){await h(s);return}await i({})},n[8]=h,n[9]=y,n[10]=i,n[11]=c,n[12]=r,n[13]=w,n[14]=a,n[15]=s,n[16]=D):D=n[16];const j=D;let _;n[17]!==i?(_=async Fe=>{await i(Fe)},n[17]=i,n[18]=_):_=n[18];const V=_,B=r?"Resume":s?t?"Replay":"Running...":a?"Run with input...":"Run workflow",H=!x&&"bg-primary text-primary-foreground hover:bg-primary/90";let N;n[19]!==H?(N=U("gap-2 h-7 px-3",H),n[19]=H,n[20]=N):N=n[20];let z;n[21]!==p||n[22]!==r||n[23]!==l||n[24]!==g||n[25]!==x?(z=(!x&&!l&&!p&&!g||r)&&m.jsx(Li,{size:14}),n[21]=p,n[22]=r,n[23]=l,n[24]=g,n[25]=x,n[26]=z):z=n[26];let P;n[27]!==p||n[28]!==r||n[29]!==l||n[30]!==g||n[31]!==x?(P=x&&!l&&!p&&!g&&!r&&m.jsx(Zh,{size:14}),n[27]=p,n[28]=r,n[29]=l,n[30]=g,n[31]=x,n[32]=P):P=n[32];let K;n[33]!==p||n[34]!==l||n[35]!==g?(K=(l||p||g)&&m.jsx(Ds,{size:"xs"}),n[33]=p,n[34]=l,n[35]=g,n[36]=K):K=n[36];let Q;n[37]!==B||n[38]!==j||n[39]!==k||n[40]!==N||n[41]!==z||n[42]!==P||n[43]!==K?(Q=m.jsxs(me,{variant:"default",size:"sm",className:N,disabled:k,onClick:j,children:[z,P,K,B]}),n[37]=B,n[38]=j,n[39]=k,n[40]=N,n[41]=z,n[42]=P,n[43]=K,n[44]=Q):Q=n[44];const le=Q;let X;n[45]!==le||n[46]!==A?(X=A?m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:le})}),m.jsx($t,{side:"bottom",children:A})]})}):le,n[45]=le,n[46]=A,n[47]=X):X=n[47];const fe=X;let se;n[48]!==V||n[49]!==c||n[50]!==l||n[51]!==a||n[52]!==u?(se=a&&c&&m.jsx(lw,{open:u,onOpenChange:f,inputSchema:c,onSubmit:V,isPending:l}),n[48]=V,n[49]=c,n[50]=l,n[51]=a,n[52]=u,n[53]=se):se=n[53];let J;return n[54]!==fe||n[55]!==se?(J=m.jsxs(m.Fragment,{children:[fe,se]}),n[54]=fe,n[55]=se,n[56]=J):J=n[56],J}function fw(n){return"toolName"in n.action&&(!n.action.toolName||n.action.toolName==="")}function hw(){const n=I.c(17),e=we(),t=pr(),{item:r}=Pn(e);if(!e||!r)return;let s;if(n[0]!==r.completed_steps?.error||n[1]!==r.completed_steps?.success||n[2]!==r.status||n[3]!==t){s={};let o;n[5]!==r.completed_steps?.success?(o=r.completed_steps?.success??[],n[5]=r.completed_steps?.success,n[6]=o):o=n[6];let i;n[7]!==o?(i=new Set(o),n[7]=o,n[8]=i):i=n[8];const l=i;let a;n[9]!==r.completed_steps?.error?(a=r.completed_steps?.error??[],n[9]=r.completed_steps?.error,n[10]=a):a=n[10];let c;n[11]!==a?(c=new Set(a),n[11]=a,n[12]=c):c=n[12];const d=c;let u;n[13]!==d||n[14]!==t||n[15]!==l?(u=-1,t.forEach((f,h)=>{(l.has(f.name)||d.has(f.name))&&(u=h)}),n[13]=d,n[14]=t,n[15]=l,n[16]=u):u=n[16],t.forEach((f,h)=>{let p="pending";d.has(f.name)?p="error":l.has(f.name)?p="success":r.status==="running"&&h===u+1&&(p="running"),s[f.name]={status:p,output:void 0,error:void 0,stepIndex:h}}),n[0]=r.completed_steps?.error,n[1]=r.completed_steps?.success,n[2]=r.status,n[3]=t,n[4]=s}else s=n[4];return s}function pw(n){const e=I.c(119),{step:t,index:r,isSelected:s,executionStatus:o,isSkipped:i,isLastStep:l,onSelect:a,onDelete:c,onDuplicate:d}=n,u=we(),{item:f}=Pn(u),h=f?.completed_at_epoch_ms;let p;e[0]!==f?.completed_steps?.success||e[1]!==t.name?(p=f?.completed_steps?.success?.includes(t.name)??!1,e[0]=f?.completed_steps?.success,e[1]=t.name,e[2]=p):p=e[2];const y=p;let g;e[3]!==f?.completed_steps?.error||e[4]!==t.name?(g=f?.completed_steps?.error?.includes(t.name)??!1,e[3]=f?.completed_steps?.error,e[4]=t.name,e[5]=g):g=e[5];const x=g,b="toolName"in t.action,S=b&&"connectionId"in t.action?t.action.connectionId:null,k=!!(b&&"toolName"in t.action?t.action.toolName:null);let w,C,T,A,D,j,_,V,B,H,N;if(e[6]!==S||e[7]!==o||e[8]!==k||e[9]!==r||e[10]!==y||e[11]!==x||e[12]!==l||e[13]!==s||e[14]!==i||e[15]!==b||e[16]!==c||e[17]!==d||e[18]!==a||e[19]!==t||e[20]!==u){const le=Nw(t);w=y?"success":x?"error":o?.status;const X=o!==void 0,fe=w==="success"||w==="error";let se=le.length>0?60:12;(w==="success"||w==="error")&&(se=se+32);let J,Fe,at;if(e[32]!==s||e[33]!==i||e[34]!==a||e[35]!==w){const $n=yw(w);let br;e[44]!==w?(br=xw(w),e[44]=w,e[45]=br):br=e[45],J=br;const ro=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",so=w==="running"&&"bg-accent/50",oo=i&&"opacity-50";e[46]!==ro||e[47]!==so||e[48]!==oo?(V=U("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",ro,so,oo),e[46]=ro,e[47]=so,e[48]=oo,e[49]=V):V=e[49],B=a,H="button",N=0,e[50]!==a?(C=io=>{(io.key==="Enter"||io.key===" ")&&(io.preventDefault(),a())},e[50]=a,e[51]=C):C=e[51],at="w-5 flex flex-col items-center justify-center shrink-0 pt-3",Fe=U("text-xs font-mono opacity-75 h-8 flex items-center",$n),e[32]=s,e[33]=i,e[34]=a,e[35]=w,e[36]=J,e[37]=C,e[38]=Fe,e[39]=at,e[40]=V,e[41]=B,e[42]=H,e[43]=N}else J=e[36],C=e[37],Fe=e[38],at=e[39],V=e[40],B=e[41],H=e[42],N=e[43];const to=r+1;let en;e[52]!==Fe||e[53]!==to?(en=m.jsxs("span",{className:Fe,children:[to,"."]}),e[52]=Fe,e[53]=to,e[54]=en):en=e[54],e[55]!==at||e[56]!==en?(T=m.jsx("div",{className:at,children:en}),e[55]=at,e[56]=en,e[57]=T):T=e[57];let tn;e[58]!==J||e[59]!==r?(tn=r>0?m.jsx(Vo,{height:12,color:J}):m.jsx("div",{className:"h-3"}),e[58]=J,e[59]=r,e[60]=tn):tn=e[60];let nn;e[61]!==S||e[62]!==k||e[63]!==b||e[64]!==t.name?(nn=m.jsx(vw,{connectionId:S,isToolStep:b,hasToolSelected:k,stepName:t.name}),e[61]=S,e[62]=k,e[63]=b,e[64]=t.name,e[65]=nn):nn=e[65];let rn;e[66]!==J||e[67]!==fe||e[68]!==w?(rn=fe&&m.jsxs(m.Fragment,{children:[m.jsx(Vo,{height:8,color:J}),m.jsx(bw,{status:w})]}),e[66]=J,e[67]=fe,e[68]=w,e[69]=rn):rn=e[69];let sn;e[70]!==J||e[71]!==se||e[72]!==l||e[73]!==u?(sn=l&&u?null:m.jsx(Vo,{height:se,color:J}),e[70]=J,e[71]=se,e[72]=l,e[73]=u,e[74]=sn):sn=e[74],e[75]!==tn||e[76]!==nn||e[77]!==rn||e[78]!==sn?(A=m.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[tn,nn,rn,sn]}),e[75]=tn,e[76]=nn,e[77]=rn,e[78]=sn,e[79]=A):A=e[79],D="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const no=k?"font-medium text-foreground":"text-foreground";let on;e[80]!==no?(on=U("text-sm truncate flex-1",no),e[80]=no,e[81]=on):on=e[81];let ln;e[82]!==t?(ln=Cw(t),e[82]=t,e[83]=ln):ln=e[83];let an;e[84]!==on||e[85]!==ln?(an=m.jsx("span",{className:on,children:ln}),e[84]=on,e[85]=ln,e[86]=an):an=e[86];let cn;e[87]!==X||e[88]!==w?(cn=X&&m.jsx(kw,{status:w}),e[87]=X,e[88]=w,e[89]=cn):cn=e[89];let dn;e[90]!==X||e[91]!==c||e[92]!==d?(dn=!X&&m.jsxs(yp,{children:[m.jsx(xp,{asChild:!0,children:m.jsx(me,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:gw,children:m.jsx(gp,{size:14})})}),m.jsxs(bp,{align:"end",children:[m.jsxs(Fl,{onClick:$n=>{$n.stopPropagation(),d()},children:[m.jsx(wp,{size:14}),"Duplicate"]}),m.jsxs(Fl,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:$n=>{$n.stopPropagation(),c()},children:[m.jsx(Ah,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[90]=X,e[91]=c,e[92]=d,e[93]=dn):dn=e[93],e[94]!==an||e[95]!==cn||e[96]!==dn?(j=m.jsxs("div",{className:"flex items-center h-8",children:[an,cn,dn]}),e[94]=an,e[95]=cn,e[96]=dn,e[97]=j):j=e[97],_=le.length>0&&m.jsx("div",{className:"flex flex-wrap gap-1.5",children:le.map(mw)}),e[6]=S,e[7]=o,e[8]=k,e[9]=r,e[10]=y,e[11]=x,e[12]=l,e[13]=s,e[14]=i,e[15]=b,e[16]=c,e[17]=d,e[18]=a,e[19]=t,e[20]=u,e[21]=w,e[22]=C,e[23]=T,e[24]=A,e[25]=D,e[26]=j,e[27]=_,e[28]=V,e[29]=B,e[30]=H,e[31]=N}else w=e[21],C=e[22],T=e[23],A=e[24],D=e[25],j=e[26],_=e[27],V=e[28],B=e[29],H=e[30],N=e[31];let z;e[98]!==h||e[99]!==w?(z=w==="success"&&m.jsx(Sw,{completedAtEpochMs:h}),e[98]=h,e[99]=w,e[100]=z):z=e[100];let P;e[101]!==o?.error||e[102]!==w?(P=w==="error"&&m.jsx(ww,{error:o?.error}),e[101]=o?.error,e[102]=w,e[103]=P):P=e[103];let K;e[104]!==z||e[105]!==P||e[106]!==D||e[107]!==j||e[108]!==_?(K=m.jsxs("div",{className:D,children:[j,_,z,P]}),e[104]=z,e[105]=P,e[106]=D,e[107]=j,e[108]=_,e[109]=K):K=e[109];let Q;return e[110]!==C||e[111]!==T||e[112]!==A||e[113]!==K||e[114]!==V||e[115]!==B||e[116]!==H||e[117]!==N?(Q=m.jsxs("div",{className:V,onClick:B,role:H,tabIndex:N,onKeyDown:C,children:[T,A,K]}),e[110]=C,e[111]=T,e[112]=A,e[113]=K,e[114]=V,e[115]=B,e[116]=H,e[117]=N,e[118]=Q):Q=e[118],Q}function mw(n){return m.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:n},n)}function gw(n){return n.stopPropagation()}function yw(n){switch(n){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function xw(n){switch(n){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function bw(n){const e=I.c(2),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-success flex items-center justify-center",children:m.jsx(Vi,{size:8,className:"text-success-foreground"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-destructive flex items-center justify-center",children:m.jsx($i,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function kw(n){const e=I.c(3),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(Vi,{size:11,className:"text-success"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx($i,{size:11,className:"text-destructive"})}),e[1]=r):r=e[1],r}if(t==="running"){let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(tr,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function Sw(n){const e=I.c(8),{completedAtEpochMs:t}=n;let r,s;if(e[0]!==t){const a=t!=null?new Date(t):null;r=a?a.toISOString().split("T")[0]:null,s=a?a.toTimeString().split(" ")[0]:null,e[0]=t,e[1]=r,e[2]=s}else r=e[1],s=e[2];const o=s;let i;e[3]!==r||e[4]!==o?(i=r&&o&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Fh,{size:16,className:"text-success"}),m.jsx("span",{className:"text-xs text-success",children:r}),m.jsx("span",{className:"text-xs text-success",children:o})]}),e[3]=r,e[4]=o,e[5]=i):i=e[5];let l;return e[6]!==i?(l=m.jsx("div",{className:"inline-flex items-center gap-3 px-1.5 py-1 bg-success-foreground rounded-lg w-fit",children:i}),e[6]=i,e[7]=l):l=e[7],l}function ww(n){const e=I.c(3),{error:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx(qi,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=t||"Execution failed";let o;return e[1]!==s?(o=m.jsxs("div",{className:"inline-flex items-center gap-1.5 px-1.5 py-1 bg-destructive-foreground rounded-lg w-fit",children:[r,m.jsx("span",{className:"text-xs text-destructive",children:s})]}),e[1]=s,e[2]=o):o=e[2],o}function vw(n){const e=I.c(5),{connectionId:t,isToolStep:r,hasToolSelected:s,stepName:o}=n,i=Pi(t??"");if(r&&s&&i?.icon){let a;return e[0]!==i.icon||e[1]!==o?(a=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center overflow-hidden",children:m.jsx(js,{icon:i.icon,name:o,size:"xs",className:"border-0 rounded-none"})}),e[0]=i.icon,e[1]=o,e[2]=a):a=e[2],a}let l;return e[3]!==r?(l=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center",children:r?m.jsx(Zc,{size:16,className:"text-muted-foreground"}):m.jsx(Sp,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function Vo(n){const e=I.c(7),{height:t,color:r}=n,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=U("w-px",s),e[0]=s,e[1]=o):o=e[1];let i;e[2]!==t?(i={height:t},e[2]=t,e[3]=i):i=e[3];let l;return e[4]!==o||e[5]!==i?(l=m.jsx("div",{className:o,style:i}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function Cw(n){return n.name?n.name:"toolName"in n.action&&n.action.toolName?n.action.toolName:"code"in n.action?n.name||"Code Step":"Select tool..."}function Nw(n){const e=n.outputSchema;if(!e||typeof e!="object")return[];const t=e.properties;return!t||typeof t!="object"?[]:Object.keys(t).slice(0,5)}function Ew(n){const e=I.c(32),{className:t}=n,r=pr(),s=sd(),o=hw(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a}=Me(),c=we();let d;e[0]!==o||e[1]!==r?(d=o?r.findIndex(S=>o[S.name]?.status==="error"):-1,e[0]=o,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=m.jsx("div",{children:"Loading..."}),e[3]=f):f=e[3];let h;e[4]!==t?(h=U("h-full flex flex-col p-8 overflow-auto",t),e[4]=t,e[5]=h):h=e[5];let p;if(e[6]!==s||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==i||e[11]!==o||e[12]!==r){let S;e[14]!==s||e[15]!==l||e[16]!==a||e[17]!==u||e[18]!==i||e[19]!==o||e[20]!==r.length?(S=(v,k)=>{const w=o?.[v.name],C=u!==-1&&k>u&&w?.status==="pending",T=k===r.length-1;return m.jsx(pw,{step:v,index:k,isSelected:v.name===s,executionStatus:w,isSkipped:C,isLastStep:T,onSelect:()=>i(v.name),onDelete:()=>l(v.name),onDuplicate:()=>a(v.name)},v.name)},e[14]=s,e[15]=l,e[16]=a,e[17]=u,e[18]=i,e[19]=o,e[20]=r.length,e[21]=S):S=e[21],p=r.map(S),e[6]=s,e[7]=l,e[8]=a,e[9]=u,e[10]=i,e[11]=o,e[12]=r,e[13]=p}else p=e[13];let y;e[22]!==p?(y=m.jsx("div",{className:"pt-3 -space-y-1",children:p}),e[22]=p,e[23]=y):y=e[23];let g;e[24]!==c?(g=c?null:m.jsx(Tw,{}),e[24]=c,e[25]=g):g=e[25];let x;e[26]!==y||e[27]!==g?(x=m.jsxs("div",{className:"w-full -space-y-1",children:[y,g]}),e[26]=y,e[27]=g,e[28]=x):x=e[28];let b;return e[29]!==h||e[30]!==x?(b=m.jsx(O.Suspense,{fallback:f,children:m.jsx("div",{className:h,children:x})}),e[29]=h,e[30]=x,e[31]=b):b=e[31],b}function Tw(){const n=I.c(8),{addToolStep:e}=Me();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=m.jsx("div",{className:"w-5 shrink-0"}),n[0]=t):t=n[0];let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"w-px h-3 bg-border"}),n[1]=r):r=n[1];let s;n[2]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx(zc,{size:14}),n[2]=s):s=n[2];let o;n[3]!==e?(o=m.jsx(me,{variant:"outline",size:"icon",className:"size-8 rounded-lg",onClick:e,children:s}),n[3]=e,n[4]=o):o=n[4];let i;n[5]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"w-px h-8",style:{backgroundImage:"repeating-linear-gradient(180deg, var(--border), var(--border) 4px, transparent 4px, transparent 8px)",backgroundPosition:"left top",backgroundRepeat:"repeat-y",backgroundSize:"2px 100%"}}),n[5]=i):i=n[5];let l;return n[6]!==o?(l=m.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[t,m.jsxs("div",{className:"flex flex-col border-1 border-transparent items-center shrink-0",children:[r,o,i]})]}),n[6]=o,n[7]=l):l=n[7],l}function Mw(){const n=I.c(5),e=jn();let t;n[0]!==e?(t=e?new URL(`/mcp/gateway/${e}`,window.location.origin).href:"",n[0]=e,n[1]=t):t=n[1];const r=t,s=!!e;let o;return n[2]!==r||n[3]!==s?(o={url:r,enabled:s},n[2]=r,n[3]=s,n[4]=o):o=n[4],zi(o)}function Aw(n){const e=I.c(7),{className:t}=n;if(!jn()){let o;e[0]!==t?(o=U("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground p-4 text-center",children:"Select a gateway to see available tools"}),e[2]=i):i=e[2];let l;return e[3]!==o?(l=m.jsx("div",{className:o,children:i}),e[3]=o,e[4]=l):l=e[4],l}let s;return e[5]!==t?(s=m.jsx(Ow,{className:t}),e[5]=t,e[6]=s):s=e[6],s}function Ow(n){const e=I.c(38),{className:t}=n,{tools:r,isLoading:s,error:o}=Mw(),i=hr(),{updateStep:l}=Me(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let d;if(e[0]!==c||e[1]!==r){let k;e[3]!==c?(k=w=>w.name===c,e[3]=c,e[4]=k):k=e[4],d=r.find(k),e[0]=c,e[1]=r,e[2]=d}else d=e[2];const f=ng(r,d??null,Rw,Iw);let h;e[5]!==i||e[6]!==l?(h=k=>{i&&l(i.name,{action:{...i.action,toolName:k.name},outputSchema:k.outputSchema??{}})},e[5]=i,e[6]=l,e[7]=h):h=e[7];const p=h;if(s){let k;e[8]!==t?(k=U("flex flex-col h-full bg-sidebar",t),e[8]=t,e[9]=k):k=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=m.jsx("div",{className:"flex-1 flex items-center justify-center",children:m.jsx(Ds,{size:"sm"})}),e[10]=w):w=e[10];let C;return e[11]!==k?(C=m.jsx("div",{className:k,children:w}),e[11]=k,e[12]=C):C=e[12],C}if(o){let k;e[13]!==t?(k=U("flex flex-col h-full bg-sidebar",t),e[13]=t,e[14]=k):k=e[14];let w;e[15]!==o.message?(w=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-destructive p-4 text-center",children:["Failed to load tools: ",o.message]}),e[15]=o.message,e[16]=w):w=e[16];let C;return e[17]!==k||e[18]!==w?(C=m.jsx("div",{className:k,children:w}),e[17]=k,e[18]=w,e[19]=C):C=e[19],C}let y;e[20]!==t?(y=U("flex flex-col h-full bg-sidebar",t),e[20]=t,e[21]=y):y=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=m.jsx("span",{className:"text-base font-medium text-foreground",children:"Select tool"}),e[22]=g):g=e[22];let x;e[23]!==r.length?(x=m.jsx("div",{className:"flex items-start border-b border-border",children:m.jsxs("div",{className:"flex-1 flex items-center h-12 px-5",children:[g,m.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:["(",r.length,")"]})]})}),e[23]=r.length,e[24]=x):x=e[24];let b;if(e[25]!==p||e[26]!==f||e[27]!==c){let k;e[29]!==p||e[30]!==c?(k=w=>m.jsx(jw,{icon:null,title:w.name,description:w.description,isSelected:w.name===c,onClick:()=>p(w)},w.name),e[29]=p,e[30]=c,e[31]=k):k=e[31],b=f.map(k),e[25]=p,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let S;e[32]!==b?(S=m.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=S):S=e[33];let v;return e[34]!==y||e[35]!==x||e[36]!==S?(v=m.jsxs("div",{className:y,children:[x,S]}),e[34]=y,e[35]=x,e[36]=S,e[37]=v):v=e[37],v}function Iw(n,e){return n.name.localeCompare(e.name)}function Rw(n){return n.name}function jw(n){const e=I.c(20),{icon:t,title:r,description:s,isSelected:o,onClick:i}=n,l=o&&"bg-muted/50";let a;e[0]!==l?(a=U("flex items-start gap-2.5 min-h-14 px-5 py-4 cursor-pointer transition-colors","hover:bg-muted/50",l),e[0]=l,e[1]=a):a=e[1];let c;e[2]!==i?(c=y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),i())},e[2]=i,e[3]=c):c=e[3];let d;e[4]!==t||e[5]!==r?(d=m.jsx(js,{icon:t,name:r,size:"xs",className:"shadow-sm mt-0.5"}),e[4]=t,e[5]=r,e[6]=d):d=e[6];let u;e[7]!==r?(u=m.jsx("span",{className:"text-sm font-medium text-foreground truncate block",children:r}),e[7]=r,e[8]=u):u=e[8];let f;e[9]!==s?(f=s&&m.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s}),e[9]=s,e[10]=f):f=e[10];let h;e[11]!==u||e[12]!==f?(h=m.jsxs("div",{className:"flex-1 min-w-0",children:[u,f]}),e[11]=u,e[12]=f,e[13]=h):h=e[13];let p;return e[14]!==i||e[15]!==a||e[16]!==c||e[17]!==d||e[18]!==h?(p=m.jsxs("div",{className:a,onClick:i,role:"button",tabIndex:0,onKeyDown:c,children:[d,h]}),e[14]=i,e[15]=a,e[16]=c,e[17]=d,e[18]=h,e[19]=p):p=e[19],p}var Ue="Accordion",Dw=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ll,Pw,Lw]=Ih(Ue),[Zs]=Mc(Ue,[Lw,$c]),$l=$c(),sh=ee.forwardRef((n,e)=>{const{type:t,...r}=n,s=r,o=r;return m.jsx(Ll.Provider,{scope:n.__scopeAccordion,children:t==="multiple"?m.jsx(Bw,{...o,ref:e}):m.jsx(_w,{...s,ref:e})})});sh.displayName=Ue;var[oh,$w]=Zs(Ue),[ih,zw]=Zs(Ue,{collapsible:!1}),_w=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=n,[l,a]=Ei({prop:t,defaultProp:r??"",onChange:s,caller:Ue});return m.jsx(oh,{scope:n.__scopeAccordion,value:ee.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:ee.useCallback(()=>o&&a(""),[o,a]),children:m.jsx(ih,{scope:n.__scopeAccordion,collapsible:o,children:m.jsx(lh,{...i,ref:e})})})}),Bw=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},...o}=n,[i,l]=Ei({prop:t,defaultProp:r??[],onChange:s,caller:Ue}),a=ee.useCallback(d=>l((u=[])=>[...u,d]),[l]),c=ee.useCallback(d=>l((u=[])=>u.filter(f=>f!==d)),[l]);return m.jsx(oh,{scope:n.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:m.jsx(ih,{scope:n.__scopeAccordion,collapsible:!0,children:m.jsx(lh,{...o,ref:e})})})}),[Fw,eo]=Zs(Ue),lh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,disabled:r,dir:s,orientation:o="vertical",...i}=n,l=ee.useRef(null),a=Ic(l,e),c=Pw(t),u=Rh(s)==="ltr",f=Ge(n.onKeyDown,h=>{if(!Dw.includes(h.key))return;const p=h.target,y=c().filter(T=>!T.ref.current?.disabled),g=y.findIndex(T=>T.ref.current===p),x=y.length;if(g===-1)return;h.preventDefault();let b=g;const S=0,v=x-1,k=()=>{b=g+1,b>v&&(b=S)},w=()=>{b=g-1,b<S&&(b=v)};switch(h.key){case"Home":b=S;break;case"End":b=v;break;case"ArrowRight":o==="horizontal"&&(u?k():w());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(u?w():k());break;case"ArrowUp":o==="vertical"&&w();break}const C=b%x;y[C].ref.current?.focus()});return m.jsx(Fw,{scope:t,disabled:r,direction:s,orientation:o,children:m.jsx(Ll.Slot,{scope:t,children:m.jsx(Ni.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),Rs="AccordionItem",[Vw,zl]=Zs(Rs),ah=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,value:r,...s}=n,o=eo(Rs,t),i=$w(Rs,t),l=$l(t),a=Oh(),c=r&&i.value.includes(r)||!1,d=o.disabled||n.disabled;return m.jsx(Vw,{scope:t,open:c,disabled:d,triggerId:a,children:m.jsx(ep,{"data-orientation":o.orientation,"data-state":ph(c),...l,...s,ref:e,disabled:d,open:c,onOpenChange:u=>{u?i.onItemOpen(r):i.onItemClose(r)}})})});ah.displayName=Rs;var ch="AccordionHeader",dh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(ch,t);return m.jsx(Ni.h3,{"data-orientation":s.orientation,"data-state":ph(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});dh.displayName=ch;var vi="AccordionTrigger",uh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(vi,t),i=zw(vi,t),l=$l(t);return m.jsx(Ll.ItemSlot,{scope:t,children:m.jsx(np,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});uh.displayName=vi;var fh="AccordionContent",hh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(fh,t),i=$l(t);return m.jsx(tp,{role:"region","aria-labelledby":o.triggerId,"data-orientation":s.orientation,...i,...r,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...n.style}})});hh.displayName=fh;function ph(n){return n?"open":"closed"}var Hw=sh,Ww=ah,qw=dh,Uw=uh,Kw=hh;function Jw(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(Hw,{"data-slot":"accordion",...t}),e[2]=t,e[3]=r):r=e[3],r}function Gw(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("border-b last:border-b-0",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx(Ww,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function Xw(n){const e=I.c(11);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=U("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(kp,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==s||e[9]!==o?(l=m.jsx(qw,{className:"flex",children:m.jsxs(Uw,{"data-slot":"accordion-trigger",className:o,...s,children:[t,i]})}),e[7]=t,e[8]=s,e[9]=o,e[10]=l):l=e[10],l}function Yw(n){const e=I.c(12);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=U("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==t||e[7]!==o?(i=m.jsx("div",{className:o,children:t}),e[6]=t,e[7]=o,e[8]=i):i=e[8];let l;return e[9]!==s||e[10]!==i?(l=m.jsx(Kw,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...s,children:i}),e[9]=s,e[10]=i,e[11]=l):l=e[11],l}var Qw=(n,e,t,r,s,o,i,l)=>{let a=document.documentElement,c=["light","dark"];function d(h){(Array.isArray(n)?n:[n]).forEach(p=>{let y=p==="class",g=y&&o?s.map(x=>o[x]||x):s;y?(a.classList.remove(...g),a.classList.add(o&&o[h]?o[h]:h)):a.setAttribute(p,h)}),u(h)}function u(h){l&&c.includes(h)&&(a.style.colorScheme=h)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let h=localStorage.getItem(e)||t,p=i&&h==="system"?f():h;d(p)}catch{}};O.createContext(void 0);O.memo(({forcedTheme:n,storageKey:e,attribute:t,enableSystem:r,enableColorScheme:s,defaultTheme:o,value:i,themes:l,nonce:a,scriptProps:c})=>{let d=JSON.stringify([t,e,o,n,l,i,r,s]).slice(1,-1);return O.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?a:"",dangerouslySetInnerHTML:{__html:`(${Qw.toString()})(${d})`}})});function Zw(n){const{updateStep:e}=Me(),r=n&&"toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,{tool:s}=_l(r??"");n&&r&&s?.outputSchema&&(!n.outputSchema||Object.keys(n.outputSchema).length===0)&&queueMicrotask(()=>{e(n.name,{outputSchema:s.outputSchema})})}function ev(n){const e=I.c(25),{className:t}=n,r=hr(),{appendStep:s}=Me();if(Zw(r),!r){let f;e[0]!==t?(f=U("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=f):f=e[1];let h;e[2]!==s?(h=()=>{s({type:"tool"})},e[2]=s,e[3]=h):h=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(zc,{size:14}),e[4]=p):p=e[4];let y;e[5]!==h?(y=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground gap-2 flex-col",children:["Select or create a step to configure",m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:h,children:p})]}),e[5]=h,e[6]=y):y=e[6];let g;return e[7]!==f||e[8]!==y?(g=m.jsx("div",{className:f,children:y}),e[7]=f,e[8]=y,e[9]=g):g=e[9],g}let o;e[10]!==t?(o=U("flex flex-col h-full bg-sidebar overflow-scroll",t),e[10]=t,e[11]=o):o=e[11];let i,l,a,c,d;e[12]!==r?(i=m.jsx(tv,{step:r}),l=m.jsx(rv,{step:r}),a=m.jsx(sv,{step:r}),c=m.jsx(av,{step:r}),d=m.jsx(uv,{step:r}),e[12]=r,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=d):(i=e[13],l=e[14],a=e[15],c=e[16],d=e[17]);let u;return e[18]!==o||e[19]!==i||e[20]!==l||e[21]!==a||e[22]!==c||e[23]!==d?(u=m.jsxs("div",{className:o,children:[i,l,a,c,d]}),e[18]=o,e[19]=i,e[20]=l,e[21]=a,e[22]=c,e[23]=d,e[24]=u):u=e[24],u}function tv(n){const e=I.c(15),{step:t}=n,s="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,o=we(),i=s??"";let l;e[0]!==i?(l=m.jsx(js,{icon:null,name:i,size:"xs",className:"shadow-sm"}),e[0]=i,e[1]=l):l=e[1];let a;e[2]!==s?(a=m.jsx("span",{className:"text-base font-medium text-foreground truncate flex-1",children:s}),e[2]=s,e[3]=a):a=e[3];let c;e[4]!==o?(c=o?null:m.jsx(nv,{}),e[4]=o,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==a||e[8]!==c?(d=m.jsxs("div",{className:"flex items-center gap-2",children:[l,a,c]}),e[6]=l,e[7]=a,e[8]=c,e[9]=d):d=e[9];let u;e[10]!==t.description?(u=t.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[10]=t.description,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=m.jsxs("div",{className:"border-b border-border p-5 shrink-0 flex flex-col gap-2",children:[d,u]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function nv(){const n=I.c(9),e=hr(),{updateStep:t,startReplacingTool:r}=Me(),s=we(),i=e&&"toolName"in e.action?e.action.toolName:null;let l;n[0]!==e||n[1]!==r||n[2]!==i||n[3]!==s||n[4]!==t?(l=()=>{if(e){if(s){Ec.error("You cannot replace a tool while a workflow is executing.");return}i&&r(i),t(e.name,{action:{...e.action,toolName:""}})}},n[0]=e,n[1]=r,n[2]=i,n[3]=s,n[4]=t,n[5]=l):l=n[5];const a=l;let c;n[6]===Symbol.for("react.memo_cache_sentinel")?(c=m.jsx(Qc,{size:14}),n[6]=c):c=n[6];let d;return n[7]!==a?(d=m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:a,title:"Replace tool",children:c}),n[7]=a,n[8]=d):d=n[8],d}function _l(n){const e=I.c(13),t=jn();let r;e[0]!==t?(r=t?new URL(`/mcp/gateway/${t}`,window.location.origin).href:"",e[0]=t,e[1]=r):r=e[1];const s=r,o=!!t;let i;e[2]!==s||e[3]!==o?(i={url:s,enabled:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const l=zi(i);let a;e[5]!==l.tools||e[6]!==n?(a=l.tools?.find(h=>h.name===n),e[5]=l.tools,e[6]=n,e[7]=a):a=e[7];const c=a,d=l.state==="connecting",u=l.state==="ready";let f;return e[8]!==l.error||e[9]!==d||e[10]!==u||e[11]!==c?(f={tool:c,isLoading:d,isReady:u,error:l.error},e[8]=l.error,e[9]=d,e[10]=u,e[11]=c,e[12]=f):f=e[12],f}function rv(n){const e=I.c(13),{step:t}=n,{updateStep:r}=Me(),o="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,i=we(),{tool:l}=_l(o??"");if(!l||!l.inputSchema)return null;let a;e[0]!==t.name||e[1]!==r?(a=x=>{r(t.name,{input:x})},e[0]=t.name,e[1]=r,e[2]=a):a=e[2];const c=a,d=i?"output":"input";let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx(Xw,{className:"px-5 py-5",children:m.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Input"})}),e[3]=u):u=e[3];const f=l.inputSchema,h=t.input;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[4]=p):p=e[4];let y;e[5]!==c||e[6]!==t.name||e[7]!==f||e[8]!==h?(y=m.jsxs(Gw,{value:"input",className:"border-b-0",children:[u,m.jsx(Yw,{className:"px-5 pt-2",children:m.jsx(rh,{inputSchema:f,inputParams:h,setInputParams:c,mentions:p},t.name)})]}),e[5]=c,e[6]=t.name,e[7]=f,e[8]=h,e[9]=y):y=e[9];let g;return e[10]!==d||e[11]!==y?(g=m.jsx(Jw,{type:"single",collapsible:!0,defaultValue:d,className:"border-b border-border shrink-0",children:y}),e[10]=d,e[11]=y,e[12]=g):g=e[12],g}function sv(n){const e=I.c(24),{step:t}=n,r=t.outputSchema,[s,o]=O.useState(!1),i=we(),{item:l}=Pn(i),a=!!(l?.completed_steps?.success?.includes(t.name)||l?.completed_steps?.error?.includes(t.name)),{output:c,error:d}=Um(i,a?t.name:void 0);let u;e[0]!==d||e[1]!==c?(u=c||(d?{error:d}:void 0),e[0]=d,e[1]=c,e[2]=u):u=e[2];const f=u,h=r&&typeof r=="object"?r.properties:void 0;let p;e[3]!==h?(p=h?Object.entries(h):[],e[3]=h,e[4]=p):p=e[4];const y=p,g=s?"flex-1 min-h-0 overflow-hidden":"shrink-0";let x;e[5]!==g?(x=U("flex flex-col border-b border-border",g),e[5]=g,e[6]=x):x=e[6];let b;e[7]!==s?(b=()=>o(!s),e[7]=s,e[8]=b):b=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Output"}),e[9]=S):S=e[9];let v;e[10]!==s?(v=m.jsxs("div",{className:"flex items-center justify-between",children:[S,s?m.jsx(Wi,{size:14,className:"text-muted-foreground"}):m.jsx(Hi,{size:14,className:"text-muted-foreground"})]}),e[10]=s,e[11]=v):v=e[11];let k;e[12]!==b||e[13]!==v?(k=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:b,children:v}),e[12]=b,e[13]=v,e[14]=k):k=e[14];let w;e[15]!==f||e[16]!==s||e[17]!==y||e[18]!==i?(w=s&&m.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5",children:[i&&f?m.jsx(On,{code:JSON.stringify(f,null,2),language:"json",height:"100%",readOnly:!0}):null,!i&&y.map(ov)]}),e[15]=f,e[16]=s,e[17]=y,e[18]=i,e[19]=w):w=e[19];let C;return e[20]!==x||e[21]!==k||e[22]!==w?(C=m.jsxs("div",{className:x,children:[k,w]}),e[20]=x,e[21]=k,e[22]=w,e[23]=C):C=e[23],C}function ov(n){const[e,t]=n;return m.jsx(lv,{name:e,schema:t},e)}function iv(n){switch(n){case"string":return{Icon:Uc,color:"text-blue-500"};case"number":case"integer":return{Icon:Wc,color:"text-blue-500"};case"array":return{Icon:Fc,color:"text-purple-500"};case"object":return{Icon:Bc,color:"text-orange-500"};case"boolean":return{Icon:qc,color:"text-pink-500"};case"null":return{Icon:Ti,color:"text-gray-500"};default:return{Icon:Vc,color:"text-muted-foreground"}}}function lv(n){const e=I.c(28),{name:t,schema:r}=n,s=hr(),o=r.type??"unknown";let i,l,a,c,d;if(e[0]!==o){const{Icon:v,color:k}=iv(o);d="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=v,l=14,a=U(k),e[0]=o,e[1]=i,e[2]=l,e[3]=a,e[4]=c,e[5]=d}else i=e[1],l=e[2],a=e[3],c=e[4],d=e[5];let u;e[6]!==i||e[7]!==l||e[8]!==a?(u=m.jsx(i,{size:l,className:a}),e[6]=i,e[7]=l,e[8]=a,e[9]=u):u=e[9];let f;e[10]!==t?(f=m.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[10]=t,e[11]=f):f=e[11];let h;e[12]!==c||e[13]!==u||e[14]!==f?(h=m.jsxs("div",{className:c,children:[u,f]}),e[12]=c,e[13]=u,e[14]=f,e[15]=h):h=e[15];let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Xc,{size:14,className:"opacity-50"}),e[16]=p):p=e[16];const y=s?.name;let g;e[17]!==y?(g=m.jsxs("span",{className:"text-muted-foreground",children:[y,"."]}),e[17]=y,e[18]=g):g=e[18];let x;e[19]!==t?(x=m.jsx("div",{className:"bg-blue-500/10 text-blue-500 px-1 py-0.5 rounded",children:t}),e[19]=t,e[20]=x):x=e[20];let b;e[21]!==g||e[22]!==x?(b=m.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[p,g,x]}),e[21]=g,e[22]=x,e[23]=b):b=e[23];let S;return e[24]!==b||e[25]!==d||e[26]!==h?(S=m.jsxs("div",{className:d,children:[h,b]}),e[24]=b,e[25]=d,e[26]=h,e[27]=S):S=e[27],S}function av(n){const e=I.c(29),{step:t}=n,{updateStep:r}=Me(),s=we(),[o,i]=O.useState(!1),l="toolName"in t.action,a=l&&"toolName"in t.action?t.action.toolName:null,{tool:c}=_l(a??""),d=l&&"transformCode"in t.action?t.action.transformCode??null:null;let u;e[0]!==c?(u=()=>{if(!c?.outputSchema)return`interface Input {
|
|
146
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=ui(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=ui(n,{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:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ce.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Of.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(If.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push($f.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(_f.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Rk.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(jk.configure(this.options.taskList)),n}});var Dk=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ne(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];return t.length===1&&t[0].type==="image"?e.parseChildren([t[0]]):e.createNode("paragraph",void 0,e.parseInline(t))},renderMarkdown:(n,e)=>!n||!Array.isArray(n.content)?"":e.renderChildren(n.content),addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Pk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Lk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$k=Zt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Mn({find:Pk,type:this.type})]},addPasteRules(){return[Xt({find:Lk,type:this.type})]}}),zk=Ie.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),_k=Zt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ne(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Bk(n={}){return new re({view(e){return new Fk(e,n)}})}class Fk{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.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:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),y=u?p.bottom:p.top;u&&f&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:y-g,bottom:y+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Pd(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}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)}}class ie extends q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ie.valid(r)?new ie(r):q.near(r)}content(){return R.empty}eq(e){return e instanceof ie&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ie(e.resolve(t.pos))}getBookmark(){return new jl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Vk(e)||!Hk(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ie.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(ie.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!$.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(ie.valid(l))return l}return null}}}ie.prototype.visible=!1;ie.findFrom=ie.findGapCursorFrom;q.jsonID("gapcursor",ie);class jl{constructor(e){this.pos=e}map(e){return new jl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ie.valid(t)?new ie(t):q.near(t)}}function Bf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Vk(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Bf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Hk(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Bf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Wk(){return new re({props:{decorations:Jk,createSelectionBetween(n,e,t){return e.pos==t.pos&&ie.valid(t)?new ie(t):null},handleClick:Uk,handleKeyDown:qk,handleDOMEvents:{beforeinput:Kk}}})}const qk=Lu({ArrowLeft:Rr("horiz",-1),ArrowRight:Rr("horiz",1),ArrowUp:Rr("vert",-1),ArrowDown:Rr("vert",1)});function Rr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof F){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ie.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ie(c))),!0):!1}}function Uk(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ie.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&$.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ie(r))),!0)}function Kk(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ie))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=E.empty;for(let i=r.length-1;i>=0;i--)s=E.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new R(s,0,0));return o.setSelection(F.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Jk(n){if(!(n.selection instanceof ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",te.create(n.doc,[Ce.widget(n.selection.head,e,{key:"gapcursor"})])}var As=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<As&&this.leafAppend(e)||this.length<As&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new Gk(this,e)};ye.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ye.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};ye.from=function(e){return e instanceof ye?e:e&&e.length?new Ff(e):ye.empty};var Ff=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={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,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=As)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=As)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ye);ye.empty=new Ff([]);var Gk=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.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 l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),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})(ye);const Xk=500;class Ve{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){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;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,d.push(u);return}if(s){d.push(new dt(u.map));let h=u.step.map(s.slice(o)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new dt(p,void 0,void 0,c.length+d.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(o)):u.selection,a=new Ve(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new dt(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>Qk&&(l=Yk(l,c),i-=c),new Ve(l.append(o),i)}remapping(e,t){let r=new sr;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,t),r}addMaps(e){return this.eventCount==0?this:new Ve(this.items.append(e.map(t=>new dt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=o.maps[h];if(f.step){let y=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(o.slice(a+1,h));g&&l++,r.push(new dt(p,y,g))}else r.push(new dt(p))},s);let c=[];for(let f=t;f<i;f++)c.push(new dt(o.maps[f]));let d=this.items.slice(0,s).append(c).append(r),u=new Ve(d,l);return u.emptyItemCount()>Xk&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=i.selection&&i.selection.map(t.slice(r));d&&o++;let u=new dt(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else i.map&&r--},this.items.length,0),new Ve(ye.from(s.reverse()),o)}}Ve.empty=new Ve(ye.empty,0);function Yk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}let dt=class Vf{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Vf(t.getMap().invert(),t,this.selection)}}};class pt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const Qk=20;function Zk(n,e,t,r){let s=t.getMeta(Wt),o;if(s)return s.historyState;t.getMeta(nS)&&(n=new pt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Wt))return i.getMeta(Wt).redo?new pt(n.done.addTransform(t,void 0,r,zr(e)),n.undone,kc(t.mapping.maps),n.prevTime,n.prevComposition):new pt(n.done,n.undone.addTransform(t,void 0,r,zr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!eS(t,n.prevRanges)),c=i?zo(n.prevRanges,t.mapping):kc(t.mapping.maps);return new pt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,zr(e)),Ve.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new pt(n.done.rebased(t,o),n.undone.rebased(t,o),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new pt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),zo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function eS(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function kc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function zo(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function tS(n,e,t){let r=zr(e),s=Wt.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new pt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Wt,{redo:t,historyState:a})}let _o=!1,Sc=null;function zr(n){let e=n.plugins;if(Sc!=e){_o=!1,Sc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){_o=!0;break}}return _o}const Wt=new ae("history"),nS=new ae("closeHistory");function rS(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new re({key:Wt,state:{init(){return new pt(Ve.empty,Ve.empty,null,0,-1)},apply(e,t,r){return Zk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Wf:r=="historyRedo"?qf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Hf(n,e){return(t,r)=>{let s=Wt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=tS(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const Wf=Hf(!1,!0),qf=Hf(!0,!0);ce.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new re({key:new ae("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.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 l=e.selection.$head.pos,a=o-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});var sS=ce.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Bk(this.options)]}});ce.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new re({key:new ae("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return te.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(Ce.node(c,c+a.nodeSize,{class:this.options.className}))}),te.create(n,o)}}})]}});var oS=ce.create({name:"gapCursor",addProseMirrorPlugins(){return[Wk()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=G(L(n,"allowGapCursor",t)))!=null?e:null}}});ce.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new re({key:new ae("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const o=this.editor.isEmpty;return n.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&Us(i);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=Ce.node(l,l+i.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),te.create(n,s)}}})]}});ce.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new re({key:new ae("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Qu(t.selection)||n.view.dragging?null:te.create(t.doc,[Ce.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function wc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var iS=ce.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ae(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new re({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,d=e.getState(i),u=l.content.size,f=c.nodes[t];if(d)return a.insert(u,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!wc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!wc({node:i,types:r})}}})]}}),lS=ce.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Wf(n,e),redo:()=>({state:n,dispatch:e})=>qf(n,e)}},addProseMirrorPlugins(){return[rS(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()}}}),aS=ce.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(Pb.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Ob.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Of.configure(this.options.bulletList)),this.options.code!==!1&&s.push(zb.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Fb.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Vb.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(sS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(oS.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Hb.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Wb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(lS.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(qb.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Xb.configure(this.options.italic)),this.options.listItem!==!1&&s.push(If.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push($f.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(Sk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(_f.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Dk.configure(this.options.paragraph)),this.options.strike!==!1&&s.push($k.configure(this.options.strike)),this.options.text!==!1&&s.push(zk.configure(this.options.text)),this.options.underline!==!1&&s.push(_k.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(iS.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),cS=aS;function dS(n){var e;const{char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=n,a=r&&!s,c=tb(t),d=new RegExp(`\\s${c}$`),u=i?"^":"",f=s?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const y=l.pos-p.length,g=Array.from(p.matchAll(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;const x=g.input.slice(Math.max(0,g.index-1),g.index),b=new RegExp(`^[${o?.join("")}\0]?$`).test(x);if(o!==null&&!b)return null;const S=y+g.index;let v=S+g[0].length;return a&&d.test(p.slice(v-1,v+1))&&(g[0]+=" ",v+=1),S<l.pos&&v>=l.pos?{range:{from:S,to:v},query:g[0].slice(t.length),text:g[0]}:null}var uS=new ae("suggestion");function fS({pluginKey:n=uS,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:y=dS,shouldShow:g}){let x;const b=h?.(),S=()=>{const C=e.state.selection.$anchor.pos,T=e.view.coordsAtPos(C),{top:A,right:D,bottom:j,left:_}=T;try{return new DOMRect(_,A,D-_,j-A)}catch{return null}},v=(C,T)=>T?()=>{const A=n.getState(e.state),D=A?.decorationId,j=C.dom.querySelector(`[data-decoration-id="${D}"]`);return j?.getBoundingClientRect()||null}:S;function k(C,T){var A;try{const j=n.getState(C.state),_=j?.decorationId?C.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null,V={editor:e,range:j?.range||{from:0,to:0},query:j?.query||null,text:j?.text||null,items:[],command:B=>u({editor:e,range:j?.range||{from:0,to:0},props:B}),decorationNode:_,clientRect:v(C,_)};(A=b?.onExit)==null||A.call(b,V)}catch{}const D=C.state.tr.setMeta(T,{exit:!0});C.dispatch(D)}const w=new re({key:n,view(){return{update:async(C,T)=>{var A,D,j,_,V,B,H;const N=(A=this.key)==null?void 0:A.getState(T),z=(D=this.key)==null?void 0:D.getState(C.state),P=N.active&&z.active&&N.range.from!==z.range.from,K=!N.active&&z.active,Q=N.active&&!z.active,le=!K&&!Q&&N.query!==z.query,X=K||P&&le,fe=le||P,se=Q||P&≤if(!X&&!fe&&!se)return;const J=se&&!X?N:z,Fe=C.dom.querySelector(`[data-decoration-id="${J.decorationId}"]`);x={editor:e,range:J.range,query:J.query,text:J.text,items:[],command:at=>u({editor:e,range:J.range,props:at}),decorationNode:Fe,clientRect:v(C,Fe)},X&&((j=b?.onBeforeStart)==null||j.call(b,x)),fe&&((_=b?.onBeforeUpdate)==null||_.call(b,x)),(fe||X)&&(x.items=await f({editor:e,query:J.query})),se&&((V=b?.onExit)==null||V.call(b,x)),fe&&((B=b?.onUpdate)==null||B.call(b,x)),X&&((H=b?.onStart)==null||H.call(b,x))},destroy:()=>{var C;x&&((C=b?.onExit)==null||C.call(b,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(C,T,A,D){const{isEditable:j}=e,{composing:_}=e.view,{selection:V}=C,{empty:B,from:H}=V,N={...T},z=C.getMeta(n);if(z&&z.exit)return N.active=!1,N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null,N;if(N.composing=_,j&&(B||e.view.composing)){(H<T.range.from||H>T.range.to)&&!_&&!T.composing&&(N.active=!1);const P=y({char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:V.$from}),K=`id_${Math.floor(Math.random()*4294967295)}`;P&&p({editor:e,state:D,range:P.range,isActive:T.active})&&(!g||g({editor:e,range:P.range,query:P.query,text:P.text,transaction:C}))?(N.active=!0,N.decorationId=T.decorationId?T.decorationId:K,N.range=P.range,N.query=P.query,N.text=P.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(C,T){var A,D,j,_;const{active:V,range:B}=w.getState(C.state);if(!V)return!1;if(T.key==="Escape"||T.key==="Esc"){const N=w.getState(C.state),z=(A=x?.decorationNode)!=null?A:null,P=z??(N?.decorationId?C.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null);if(((D=b?.onKeyDown)==null?void 0:D.call(b,{view:C,event:T,range:N.range}))||!1)return!0;const Q={editor:e,range:N.range,query:N.query,text:N.text,items:[],command:le=>u({editor:e,range:N.range,props:le}),decorationNode:P,clientRect:P?()=>P.getBoundingClientRect()||null:null};return(j=b?.onExit)==null||j.call(b,Q),k(C,n),!0}return((_=b?.onKeyDown)==null?void 0:_.call(b,{view:C,event:T,range:B}))||!1},decorations(C){const{active:T,range:A,decorationId:D,query:j}=w.getState(C);if(!T)return null;const _=!j?.length,V=[a];return _&&V.push(d),te.create(C.doc,[Ce.inline(A.from,A.to,{nodeName:l,class:V.join(" "),"data-decoration-id":D,"data-decoration-content":c})])}}});return w}function hS({editor:n,overrideSuggestionOptions:e,extensionName:t,char:r="@"}){const s=new ae;return{editor:n,char:r,pluginKey:s,command:({editor:o,range:i,props:l})=>{var a,c,d;const u=o.view.state.selection.$to.nodeAfter;(a=u?.text)!=null&&a.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:t,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(d=(c=o.view.dom.ownerDocument.defaultView)==null?void 0:c.getSelection())==null||d.collapseToEnd()},allow:({state:o,range:i})=>{const l=o.doc.resolve(i.from),a=o.schema.nodes[t];return!!l.parent.type.contentMatch.matchType(a)},...e}}function Uf(n){return(n.options.suggestions.length?n.options.suggestions:[n.options.suggestion]).map(e=>hS({editor:n.editor,overrideSuggestionOptions:e,extensionName:n.name,char:e.char}))}function vc(n,e){const t=Uf(n),r=t.find(s=>s.char===e);return r||(t.length?t[0]:null)}var pS=Ie.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:n,suggestion:e}){var t,r;return`${(t=e?.char)!=null?t:"@"}${(r=n.attrs.label)!=null?r:n.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:n,node:e,suggestion:t}){var r,s;return["span",ne(this.HTMLAttributes,n.HTMLAttributes),`${(r=t?.char)!=null?r:"@"}${(s=e.attrs.label)!=null?s:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:n=>n.getAttribute("data-mention-suggestion-char"),renderHTML:n=>({"data-mention-suggestion-char":n.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){const t=vc(this,n.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n,suggestion:t})];const r={...this.options};r.HTMLAttributes=ne({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:n,suggestion:t});return typeof s=="string"?["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...gf({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:n=>{const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r,l=o??i;e[s==="char"?"mentionSuggestionChar":s]=l,r=t.exec(n)}return e},serializeAttributes:n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e==="mentionSuggestionChar"?"char":e}="${t}"`).join(" ")}),renderText({node:n}){const e={options:this.options,node:n,suggestion:vc(this,n.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1;const{selection:r}=e,{empty:s,anchor:o}=r;if(!s)return!1;let i=new ze,l=0;return e.doc.nodesBetween(o-1,o,(a,c)=>{if(a.type.name===this.name)return t=!0,i=a,l=c,!1}),t&&n.insertText(this.options.deleteTriggerWithBackspace?"":i.attrs.mentionSuggestionChar,l,l+i.nodeSize),t})}},addProseMirrorPlugins(){return Uf(this).map(fS)}}),mS=pS,Bo,Xs="HoverCard",[Kf]=Mc(Xs,[Ac]),Ys=Ac(),[gS,Qs]=Kf(Xs),Jf=n=>{const{__scopeHoverCard:e,children:t,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=n,a=Ys(e),c=O.useRef(0),d=O.useRef(0),u=O.useRef(!1),f=O.useRef(!1),[h,p]=Ei({prop:r,defaultProp:s??!1,onChange:o,caller:Xs}),y=O.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>p(!0),i)},[i,p]),g=O.useCallback(()=>{clearTimeout(c.current),!u.current&&!f.current&&(d.current=window.setTimeout(()=>p(!1),l))},[l,p]),x=O.useCallback(()=>p(!1),[p]);return O.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),m.jsx(gS,{scope:e,open:h,onOpenChange:p,onOpen:y,onClose:g,onDismiss:x,hasSelectionRef:u,isPointerDownOnContentRef:f,children:m.jsx(Nh,{...a,children:t})})};Jf.displayName=Xs;var Gf="HoverCardTrigger",Xf=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Qs(Gf,t),o=Ys(t);return m.jsx(vh,{asChild:!0,...o,children:m.jsx(Ni.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:Ge(n.onPointerEnter,Is(s.onOpen)),onPointerLeave:Ge(n.onPointerLeave,Is(s.onClose)),onFocus:Ge(n.onFocus,s.onOpen),onBlur:Ge(n.onBlur,s.onClose),onTouchStart:Ge(n.onTouchStart,i=>i.preventDefault())})})});Xf.displayName=Gf;var Dl="HoverCardPortal",[yS,xS]=Kf(Dl,{forceMount:void 0}),Yf=n=>{const{__scopeHoverCard:e,forceMount:t,children:r,container:s}=n,o=Qs(Dl,e);return m.jsx(yS,{scope:e,forceMount:t,children:m.jsx(Oc,{present:t||o.open,children:m.jsx(Ch,{asChild:!0,container:s,children:r})})})};Yf.displayName=Dl;var Os="HoverCardContent",Qf=O.forwardRef((n,e)=>{const t=xS(Os,n.__scopeHoverCard),{forceMount:r=t.forceMount,...s}=n,o=Qs(Os,n.__scopeHoverCard);return m.jsx(Oc,{present:r||o.open,children:m.jsx(bS,{"data-state":o.open?"open":"closed",...s,onPointerEnter:Ge(n.onPointerEnter,Is(o.onOpen)),onPointerLeave:Ge(n.onPointerLeave,Is(o.onClose)),ref:e})})});Qf.displayName=Os;var bS=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=n,a=Qs(Os,t),c=Ys(t),d=O.useRef(null),u=Ic(e,d),[f,h]=O.useState(!1);return O.useEffect(()=>{if(f){const p=document.body;return Bo=p.style.userSelect||p.style.webkitUserSelect,p.style.userSelect="none",p.style.webkitUserSelect="none",()=>{p.style.userSelect=Bo,p.style.webkitUserSelect=Bo}}},[f]),O.useEffect(()=>{if(d.current){const p=()=>{h(!1),a.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(a.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",p),()=>{document.removeEventListener("pointerup",p),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!1}}},[a.isPointerDownOnContentRef,a.hasSelectionRef]),O.useEffect(()=>{d.current&&wS(d.current).forEach(y=>y.setAttribute("tabindex","-1"))}),m.jsx(Eh,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:Ge(o,p=>{p.preventDefault()}),onDismiss:a.onDismiss,children:m.jsx(Th,{...c,...l,onPointerDown:Ge(l.onPointerDown,p=>{p.currentTarget.contains(p.target)&&h(!0),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!0}),ref:u,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),kS="HoverCardArrow",SS=O.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Ys(t);return m.jsx(Mh,{...s,...r,ref:e})});SS.displayName=kS;function Is(n){return e=>e.pointerType==="touch"?void 0:n()}function wS(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)e.push(t.currentNode);return e}var vS=Jf,CS=Xf,NS=Yf,ES=Qf;function TS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(vS,{"data-slot":"hover-card",...t}),e[2]=t,e[3]=r):r=e[3],r}function MS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(CS,{"data-slot":"hover-card-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function AS(n){const e=I.c(12);let t,r,s,o;e[0]!==n?({className:t,align:s,sideOffset:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"center":s,l=o===void 0?4:o;let a;e[5]!==t?(a=U("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),e[5]=t,e[6]=a):a=e[6];let c;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==a?(c=m.jsx(NS,{"data-slot":"hover-card-portal",children:m.jsx(ES,{"data-slot":"hover-card-content",align:i,sideOffset:l,className:a,...r})}),e[7]=i,e[8]=r,e[9]=l,e[10]=a,e[11]=c):c=e[11],c}const Zf=O.createContext(void 0);function OS(n,e){const t=e.split("."),r=t[0];if(!r)return;let s=n[r];for(let o=1;o<t.length&&s!==void 0;o++){const i=t[o];if(i)if(typeof s=="object"&&s!==null)s=s[i];else return}return s}function IS(n){const e=I.c(20),{node:t}=n,r=O.useContext(Zf),s=t.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const y=o?OS(r,s):void 0;i=y!==void 0?typeof y=="object"?JSON.stringify(y,null,2):String(y):void 0,e[0]=o,e[1]=s,e[2]=r,e[3]=i}else i=e[3];const l=i;let a;e[4]!==s?(a=m.jsxs("span",{className:"bg-primary/20 text-primary px-1 rounded font-medium cursor-pointer",children:["@",s]}),e[4]=s,e[5]=a):a=e[5];const c=a;if(!o||l===void 0){let y;return e[6]!==c?(y=m.jsx(oc,{as:"span",children:c}),e[6]=c,e[7]=y):y=e[7],y}let d;e[8]!==c?(d=m.jsx(MS,{asChild:!0,children:c}),e[8]=c,e[9]=d):d=e[9];let u;e[10]!==s?(u=m.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["@",s]}),e[10]=s,e[11]=u):u=e[11];let f;e[12]!==l?(f=m.jsx("pre",{className:"text-xs font-mono bg-muted/50 p-2 rounded overflow-auto max-h-[200px] whitespace-pre-wrap break-all",children:l}),e[12]=l,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==f?(h=m.jsx(AS,{className:"w-auto max-w-[400px] p-3",side:"top",align:"start",children:m.jsxs("div",{className:"space-y-1.5",children:[u,f]})}),e[14]=u,e[15]=f,e[16]=h):h=e[16];let p;return e[17]!==d||e[18]!==h?(p=m.jsx(oc,{as:"span",children:m.jsxs(TS,{openDelay:200,children:[d,h]})}),e[17]=d,e[18]=h,e[19]=p):p=e[19],p}function eh(n){const e=[];function t(r){for(const s of r)s.children?.length||e.push(s),s.children&&t(s.children)}return t(n),e}let Xe=th();function th(){return Ki(()=>({items:[],selectedIndex:0,command:null}))}function Cc(n,e){Xe.setState({items:n,command:e,selectedIndex:0})}function RS(){const{items:n,selectedIndex:e}=Xe.getState();n.length&&Xe.setState({selectedIndex:(e-1+n.length)%n.length})}function jS(){const{items:n,selectedIndex:e}=Xe.getState();n.length&&Xe.setState({selectedIndex:(e+1)%n.length})}function nh(){const{items:n,selectedIndex:e,command:t}=Xe.getState(),r=n[e];return r?(t?.(r),!0):!1}function Nc(){Xe=th()}function DS(){const n=I.c(7),e=Wo(Xe,LS),t=Wo(Xe,PS);if(!e.length)return null;let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==t?(o=(i,l)=>m.jsx("button",{type:"button",onClick:()=>{Xe.setState({selectedIndex:l}),nh()},className:U("flex items-center w-full text-left px-3 py-1.5 text-sm rounded-md transition-colors",l===t?"bg-accent text-accent-foreground":"hover:bg-muted"),children:i.label},i.id),n[3]=t,n[4]=o):o=n[4],r=e.map(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];let s;return n[5]!==r?(s=m.jsx("div",{className:"bg-popover border border-border rounded-lg shadow-lg overflow-hidden min-w-[180px]",children:m.jsx("div",{className:"p-1",children:r})}),n[5]=r,n[6]=s):s=n[6],s}function PS(n){return n.selectedIndex}function LS(n){return n.items}function $S(){let n=null,e=null;return{onStart:t=>{Cc(t.items,t.command),n=new kf(DS,{editor:t.editor}),e=document.createElement("div"),e.style.cssText="position:absolute;z-index:9999";const r=t.clientRect?.();r&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`),e.appendChild(n.element),document.body.appendChild(e)},onUpdate:t=>{Cc(t.items,t.command);const r=t.clientRect?.();r&&e&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`)},onKeyDown:({event:t})=>t.key==="Escape"?(e?.remove(),n?.destroy(),Nc(),!0):t.key==="ArrowUp"?(RS(),!0):t.key==="ArrowDown"?(jS(),!0):t.key==="Enter"?nh():!1,onExit:()=>{e?.remove(),n?.destroy(),Nc()}}}const Fo=/@([\w.]+)/g;function zS(n,e){if(!n)return null;const t=eh(e),r=new Map(t.map(a=>[a.id,a]));if(!Fo.test(n))return n;Fo.lastIndex=0;const o=[];let i=0,l;for(;(l=Fo.exec(n))!==null;){const a=l[1]??"",c=l.index;c>i&&o.push({type:"text",text:n.slice(i,c)});const d=r.get(a);d?o.push({type:"mention",attrs:{id:d.id,label:d.label}}):o.push({type:"text",text:l[0]}),i=c+l[0].length}return i<n.length&&o.push({type:"text",text:n.slice(i)}),{type:"doc",content:[{type:"paragraph",content:o.length>0?o:void 0}]}}function Pl(n){const e=I.c(31),{mentions:t,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=n,a=tg();let c;e[0]!==t||e[1]!==r?(c=zS(r,t),e[0]=t,e[1]=r,e[2]=c):c=e[2];const d=c,u=a!==void 0,f=!l;let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=cS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let p;if(e[4]!==t||e[5]!==u){let A;e[7]!==t?(A=D=>{const{query:j}=D;return eh(t).filter(V=>V.label.toLowerCase().includes(j.toLowerCase())||V.id.toLowerCase().includes(j.toLowerCase()))},e[7]=t,e[8]=A):A=e[8],p=mS.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:VS,renderHTML:FS,suggestion:{items:A,render:$S,command:BS}}).extend(u?{addNodeView(){return Mb(IS)}}:{}),e[4]=t,e[5]=u,e[6]=p}else p=e[6];let y;e[9]!==p?(y=[h,p],e[9]=p,e[10]=y):y=e[10];const g=o??"";let x;e[11]!==g?(x={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full min-h-[20px]","data-placeholder":g},handleKeyDown:_S},e[11]=g,e[12]=x):x=e[12];let b;e[13]!==s?(b=A=>{const{editor:D}=A;return s?.(D.getText().trim())},e[13]=s,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==f||e[17]!==y||e[18]!==x||e[19]!==b?(S={content:d,editable:f,extensions:y,editorProps:x,onUpdate:b},e[15]=d,e[16]=f,e[17]=y,e[18]=x,e[19]=b,e[20]=S):S=e[20];const v=Sb(S);let k;e[21]!==i?(k=U("rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",i),e[21]=i,e[22]=k):k=e[22];let w;e[23]!==v?(w=m.jsx(pb,{editor:v}),e[23]=v,e[24]=w):w=e[24];let C;e[25]!==k||e[26]!==w?(C=m.jsx("div",{className:k,children:w}),e[25]=k,e[26]=w,e[27]=C):C=e[27];const T=C;if(a!==void 0){let A;return e[28]!==T||e[29]!==a?(A=m.jsx(Zf.Provider,{value:a,children:T}),e[28]=T,e[29]=a,e[30]=A):A=e[30],A}return T}function _S(n,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function BS(n){const{editor:e,range:t,props:r}=n;e.chain().focus().insertContentAt(t,[{type:"mention",attrs:r}]).run()}function FS(n){const{options:e,node:t}=n;return["span",e.HTMLAttributes,`@${t.attrs.id}`]}function VS(n){const{node:e}=n;return`@${e.attrs.id}`}function HS(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=ad(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx(Pl,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function WS(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=ad(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx(Pl,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o,className:"min-h-[80px]"}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function qS(n){const e=I.c(8),{value:t,onChange:r,readonly:s,id:o}=n,i=t??"";let l;e[0]!==r?(l=d=>r(d.target.value===""?void 0:Number(d.target.value)),e[0]=r,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=U("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),e[2]=a):a=e[2];let c;return e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==l?(c=m.jsx("input",{id:o,type:"number",value:i,onChange:l,disabled:s,className:a}),e[3]=o,e[4]=s,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function US(n){const e=I.c(13),{value:t,onChange:r,readonly:s,id:o,label:i}=n,l=t??!1;let a;e[0]!==r?(a=f=>r(f.target.checked),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==o||e[3]!==s||e[4]!==l||e[5]!==a?(c=m.jsx("input",{id:o,type:"checkbox",checked:l,onChange:a,disabled:s,className:"h-4 w-4 rounded border-input"}),e[2]=o,e[3]=s,e[4]=l,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==i?(d=m.jsx("span",{className:"text-sm",children:i}),e[7]=i,e[8]=d):d=e[8];let u;return e[9]!==o||e[10]!==c||e[11]!==d?(u=m.jsxs("label",{htmlFor:o,className:"flex items-center gap-2 cursor-pointer",children:[c,d]}),e[9]=o,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function KS(n){const e=I.c(14),{value:t,onChange:r,readonly:s,id:o,options:i}=n;let l;e[0]!==i.enumOptions?(l=i.enumOptions??[],e[0]=i.enumOptions,e[1]=l):l=e[1];const a=l,c=t??"";let d;e[2]!==r?(d=y=>r(y.target.value),e[2]=r,e[3]=d):d=e[3];let u,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=U("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),f=m.jsx("option",{value:"",children:"Select..."}),e[4]=u,e[5]=f):(u=e[4],f=e[5]);let h;e[6]!==a?(h=a.map(JS),e[6]=a,e[7]=h):h=e[7];let p;return e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==d||e[12]!==h?(p=m.jsxs("select",{id:o,value:c,onChange:d,disabled:s,className:u,children:[f,h]}),e[8]=o,e[9]=s,e[10]=c,e[11]=d,e[12]=h,e[13]=p):p=e[13],p}function JS(n){return m.jsx("option",{value:String(n.value),children:String(n.label)},String(n.value))}const GS={TextWidget:HS,TextareaWidget:WS,NumberWidget:qS,CheckboxWidget:US,SelectWidget:KS};function XS(n){switch(Array.isArray(n)?n[0]:n??"unknown"){case"string":return{Icon:Uc,color:"text-blue-500"};case"number":case"integer":return{Icon:Wc,color:"text-blue-500"};case"array":return{Icon:Fc,color:"text-purple-500"};case"object":return{Icon:Bc,color:"text-orange-500"};case"boolean":return{Icon:qc,color:"text-pink-500"};case"null":return{Icon:Ti,color:"text-gray-500"};default:return{Icon:Vc,color:"text-muted-foreground"}}}function YS(n){const e=I.c(36),{id:t,label:r,required:s,description:o,children:i,schema:l,hidden:a}=n;if(a){let k;return e[0]!==i?(k=m.jsx("div",{className:"hidden",children:i}),e[0]=i,e[1]=k):k=e[1],k}if(t==="root"){let k;return e[2]!==i?(k=m.jsx("div",{className:"space-y-4",children:i}),e[2]=i,e[3]=k):k=e[3],k}const c=Array.isArray(l.type)?l.type[0]:l.type??"string";let d,u,f,h,p,y,g;if(e[4]!==t||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:k,color:w}=XS(c);g="space-y-2",h="flex items-center gap-2",e[15]!==t||e[16]!==r?(p=m.jsx("label",{htmlFor:t,className:"text-sm font-medium leading-none",children:r}),e[15]=t,e[16]=r,e[17]=p):p=e[17],e[18]!==s?(y=s&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"}),e[18]=s,e[19]=y):y=e[19],d=k,u=14,f=U(w,"ml-auto"),e[4]=t,e[5]=r,e[6]=s,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=h,e[12]=p,e[13]=y,e[14]=g}else d=e[8],u=e[9],f=e[10],h=e[11],p=e[12],y=e[13],g=e[14];let x;e[20]!==d||e[21]!==u||e[22]!==f?(x=m.jsx(d,{size:u,className:f}),e[20]=d,e[21]=u,e[22]=f,e[23]=x):x=e[23];let b;e[24]!==h||e[25]!==p||e[26]!==y||e[27]!==x?(b=m.jsxs("div",{className:h,children:[p,y,x]}),e[24]=h,e[25]=p,e[26]=y,e[27]=x,e[28]=b):b=e[28];let S;e[29]!==o?(S=o&&m.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=S):S=e[30];let v;return e[31]!==i||e[32]!==g||e[33]!==b||e[34]!==S?(v=m.jsxs("div",{className:g,children:[b,S,i]}),e[31]=i,e[32]=g,e[33]=b,e[34]=S,e[35]=v):v=e[35],v}function QS(n){const e=I.c(8),{properties:t,title:r}=n;if(!r||r==="Root"){let l;e[0]!==t?(l=t.map(ew),e[0]=t,e[1]=l):l=e[1];let a;return e[2]!==l?(a=m.jsx("div",{className:"space-y-4",children:l}),e[2]=l,e[3]=a):a=e[3],a}let o;e[4]!==t?(o=t.map(ZS),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==o?(i=m.jsx("div",{className:"pl-4 border-l-2 border-border/50 space-y-4",children:o}),e[6]=o,e[7]=i):i=e[7],i}function ZS(n){return m.jsx("div",{children:n.content},n.name)}function ew(n){return m.jsx("div",{children:n.content},n.name)}function tw(n){const e=I.c(11),{items:t,canAdd:r,onAddClick:s,title:o}=n;let i;e[0]!==t?(i=t.map(nw),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=m.jsx("div",{className:"space-y-2",children:i}),e[2]=i,e[3]=l):l=e[3];let a;e[4]!==r||e[5]!==s||e[6]!==o?(a=r&&m.jsxs(me,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:s,children:["+ Add ",o||"item"]}),e[4]=r,e[5]=s,e[6]=o,e[7]=a):a=e[7];let c;return e[8]!==l||e[9]!==a?(c=m.jsxs("div",{className:"space-y-2",children:[l,a]}),e[8]=l,e[9]=a,e[10]=c):c=e[10],c}function nw(n){return m.jsx("div",{className:"flex gap-2 items-start",children:m.jsx("div",{className:"flex-1",children:n})},n.key||n.index)}function rw(){return null}function sw(){return null}const ow={FieldTemplate:YS,ObjectFieldTemplate:QS,ArrayFieldTemplate:tw,UnsupportedFieldTemplate:rw,ErrorListTemplate:sw};function iw(n){const e=I.c(6),{inputSchema:t,inputParams:r,mentions:s}=n;if(!t?.properties||!r)return null;let o;e[0]!==s?(o=(a,c,d)=>{const u=typeof c=="object"&&c!==null?JSON.stringify(c,null,2):String(c??""),f=Array.isArray(d.type)?d.type.join(" | "):d.type??"string";return m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),m.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:f})]}),d.description&&m.jsx("div",{className:"text-xs text-muted-foreground",children:d.description}),m.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:m.jsx(Pl,{mentions:s,value:u,readOnly:!0,className:"border-0 bg-transparent p-0"})})]},a)},e[0]=s,e[1]=o):o=e[1];const i=o;let l;return e[2]!==r||e[3]!==t.properties||e[4]!==i?(l=m.jsx("div",{className:"space-y-4",children:Object.entries(t.properties).map(a=>{const[c,d]=a,u=r[c];return i(c,u,d)})}),e[2]=r,e[3]=t.properties,e[4]=i,e[5]=l):l=e[5],l}function rh({inputSchema:n,inputParams:e,setInputParams:t,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!n)return m.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return m.jsx(iw,{inputSchema:n,inputParams:e,mentions:i});const l=n,a=O.useRef(e??{}),c=d=>{const u=d.formData??{},f=a.current;if(t?.(u),r){for(const[h,p]of Object.entries(u))f[h]!==p&&r(h,p);for(const h of Object.keys(f))h in u||r(h,void 0)}a.current=u};return m.jsx(ld.Provider,{value:i,children:m.jsx(qh,{schema:l,formData:e,onChange:c,validator:Uh,widgets:GS,templates:ow,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:m.jsx(m.Fragment,{})})})}function lw(n){const e=I.c(33),{open:t,onOpenChange:r,inputSchema:s,onSubmit:o,isPending:i}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[a,c]=O.useState(l);let d;e[1]!==a||e[2]!==r||e[3]!==o?(d=async()=>{await o(a),r(!1),c({})},e[1]=a,e[2]=r,e[3]=o,e[4]=d):d=e[4];const u=d;let f;e[5]!==r?(f=T=>{T||c({}),r(T)},e[5]=r,e[6]=f):f=e[6];const h=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsxs(dp,{children:[m.jsx(up,{children:"Workflow Input"}),m.jsx(fp,{children:"This workflow requires input values to run. Fill in the fields below to start the execution."})]}),e[7]=p):p=e[7];let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[8]=y):y=e[8];let g;e[9]!==a||e[10]!==s?(g=m.jsx("div",{className:"py-4",children:m.jsx(rh,{inputSchema:s,inputParams:a,setInputParams:c,mentions:y})}),e[9]=a,e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h?(x=()=>h(!1),e[12]=h,e[13]=x):x=e[13];let b;e[14]!==i||e[15]!==x?(b=m.jsx(me,{variant:"outline",onClick:x,disabled:i,children:"Cancel"}),e[14]=i,e[15]=x,e[16]=b):b=e[16];let S;e[17]!==i?(S=i?m.jsx(Ds,{size:"xs"}):m.jsx(Li,{size:14}),e[17]=i,e[18]=S):S=e[18];let v;e[19]!==u||e[20]!==i||e[21]!==S?(v=m.jsxs(me,{onClick:u,disabled:i,className:"gap-2",children:[S,"Run Workflow"]}),e[19]=u,e[20]=i,e[21]=S,e[22]=v):v=e[22];let k;e[23]!==v||e[24]!==b?(k=m.jsxs(hp,{children:[b,v]}),e[23]=v,e[24]=b,e[25]=k):k=e[25];let w;e[26]!==k||e[27]!==g?(w=m.jsxs(pp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[p,g,k]}),e[26]=k,e[27]=g,e[28]=w):w=e[28];let C;return e[29]!==h||e[30]!==t||e[31]!==w?(C=m.jsx(mp,{open:t,onOpenChange:h,children:w}),e[29]=h,e[30]=t,e[31]=w,e[32]=C):C=e[32],C}function aw(n){const e=I.c(26),{title:t,description:r,onSave:s}=n,i=Ci().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:d}=Ji(),{resetToOriginalWorkflow:u,setSelectedVirtualMcpId:f}=Me(),h=od(),p=jn(),y=we();let g;e[0]!==t?(g=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t}),e[0]=t,e[1]=g):g=e[1];let x;e[2]!==r?(x=r?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:r})]}):null,e[2]=r,e[3]=x):x=e[3];let b;e[4]!==g||e[5]!==x?(b=m.jsx(Lc,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g,x]})}),e[4]=g,e[5]=x,e[6]=b):b=e[6];let S;e[7]!==h||e[8]!==s||e[9]!==u||e[10]!==p||e[11]!==f||e[12]!==a||e[13]!==c||e[14]!==t||e[15]!==d||e[16]!==y||e[17]!==i||e[18]!==l?(S=!y&&m.jsxs(m.Fragment,{children:[m.jsx(Oi,{title:t,url:i,icon:"workflow"}),m.jsx(O.Suspense,{fallback:m.jsx(Ds,{size:"xs"}),children:m.jsx(Wm,{selectedVirtualMcpId:p,onVirtualMcpChange:f,placeholder:"Select Agent"})}),m.jsx(ap,{value:l,onValueChange:a,size:"sm",options:[{value:"visual",icon:m.jsx(cp,{})},{value:"code",icon:m.jsx(Gc,{})}]}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:u,disabled:!h,"aria-label":"Reset changes",children:m.jsx(Pc,{size:14})})})}),m.jsx($t,{side:"bottom",children:"Reset changes"})]})}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:!h,"aria-label":"Save workflow",children:m.jsx(Ui,{size:14})})})}),m.jsx($t,{side:"bottom",children:"Save workflow"})]})}),m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:c?"secondary":"outline",size:"icon",className:"size-7 border border-input",onClick:d,"aria-label":c?"Hide runs":"Show runs",children:m.jsx(Jc,{size:14})})})}),m.jsx($t,{side:"bottom",children:c?"Hide runs":"Show runs"})]})})]}),e[7]=h,e[8]=s,e[9]=u,e[10]=p,e[11]=f,e[12]=a,e[13]=c,e[14]=t,e[15]=d,e[16]=y,e[17]=i,e[18]=l,e[19]=S):S=e[19];let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=m.jsx(uw,{}),e[20]=v):v=e[20];let k;e[21]!==S?(k=m.jsxs(Di,{children:[S,v]}),e[21]=S,e[22]=k):k=e[22];let w;return e[23]!==b||e[24]!==k?(w=m.jsxs(m.Fragment,{children:[b,k]}),e[23]=b,e[24]=k,e[25]=w):w=e[25],w}function cw(){const n=we(),{item:e}=Pn(n);return e?.completed_at_epoch_ms!=null}function dw(){const n=we(),{item:e}=Pn(n);return e?.status==="cancelled"}function uw(){const n=I.c(57),e=od(),t=cw(),r=dw(),s=we(),o=jn(),{handleRunWorkflow:i,isPending:l,requiresInput:a,inputSchema:c}=Qm(),d=pr(),[u,f]=O.useState(!1),{handleCancelWorkflow:h,isCancelling:p}=Zm(),{handleResumeWorkflow:y,isResuming:g}=eg(),x=s&&!t;let b;n[0]!==d?(b=d.some(fw),n[0]=d,n[1]=b):b=n[1];const S=b,v=!o,k=e||S||v||l||p,w=x||l;let C;n[2]!==S||n[3]!==v||n[4]!==e||n[5]!==r||n[6]!==w?(C=()=>r?"Workflow is currently cancelled":w?"Workflow is currently running":e?"Save your changes before running":v?"Select an Agent first":S?"Add at least one step to the workflow":null,n[2]=S,n[3]=v,n[4]=e,n[5]=r,n[6]=w,n[7]=C):C=n[7];const A=C();let D;n[8]!==h||n[9]!==y||n[10]!==i||n[11]!==c||n[12]!==r||n[13]!==w||n[14]!==a||n[15]!==s?(D=async()=>{if(a&&c){f(!0);return}if(r&&s){await y(s);return}if(w&&s){await h(s);return}await i({})},n[8]=h,n[9]=y,n[10]=i,n[11]=c,n[12]=r,n[13]=w,n[14]=a,n[15]=s,n[16]=D):D=n[16];const j=D;let _;n[17]!==i?(_=async Fe=>{await i(Fe)},n[17]=i,n[18]=_):_=n[18];const V=_,B=r?"Resume":s?t?"Replay":"Running...":a?"Run with input...":"Run workflow",H=!x&&"bg-primary text-primary-foreground hover:bg-primary/90";let N;n[19]!==H?(N=U("gap-2 h-7 px-3",H),n[19]=H,n[20]=N):N=n[20];let z;n[21]!==p||n[22]!==r||n[23]!==l||n[24]!==g||n[25]!==x?(z=(!x&&!l&&!p&&!g||r)&&m.jsx(Li,{size:14}),n[21]=p,n[22]=r,n[23]=l,n[24]=g,n[25]=x,n[26]=z):z=n[26];let P;n[27]!==p||n[28]!==r||n[29]!==l||n[30]!==g||n[31]!==x?(P=x&&!l&&!p&&!g&&!r&&m.jsx(Zh,{size:14}),n[27]=p,n[28]=r,n[29]=l,n[30]=g,n[31]=x,n[32]=P):P=n[32];let K;n[33]!==p||n[34]!==l||n[35]!==g?(K=(l||p||g)&&m.jsx(Ds,{size:"xs"}),n[33]=p,n[34]=l,n[35]=g,n[36]=K):K=n[36];let Q;n[37]!==B||n[38]!==j||n[39]!==k||n[40]!==N||n[41]!==z||n[42]!==P||n[43]!==K?(Q=m.jsxs(me,{variant:"default",size:"sm",className:N,disabled:k,onClick:j,children:[z,P,K,B]}),n[37]=B,n[38]=j,n[39]=k,n[40]=N,n[41]=z,n[42]=P,n[43]=K,n[44]=Q):Q=n[44];const le=Q;let X;n[45]!==le||n[46]!==A?(X=A?m.jsx(zt,{children:m.jsxs(_t,{delayDuration:0,children:[m.jsx(Lt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:le})}),m.jsx($t,{side:"bottom",children:A})]})}):le,n[45]=le,n[46]=A,n[47]=X):X=n[47];const fe=X;let se;n[48]!==V||n[49]!==c||n[50]!==l||n[51]!==a||n[52]!==u?(se=a&&c&&m.jsx(lw,{open:u,onOpenChange:f,inputSchema:c,onSubmit:V,isPending:l}),n[48]=V,n[49]=c,n[50]=l,n[51]=a,n[52]=u,n[53]=se):se=n[53];let J;return n[54]!==fe||n[55]!==se?(J=m.jsxs(m.Fragment,{children:[fe,se]}),n[54]=fe,n[55]=se,n[56]=J):J=n[56],J}function fw(n){return"toolName"in n.action&&(!n.action.toolName||n.action.toolName==="")}function hw(){const n=I.c(17),e=we(),t=pr(),{item:r}=Pn(e);if(!e||!r)return;let s;if(n[0]!==r.completed_steps?.error||n[1]!==r.completed_steps?.success||n[2]!==r.status||n[3]!==t){s={};let o;n[5]!==r.completed_steps?.success?(o=r.completed_steps?.success??[],n[5]=r.completed_steps?.success,n[6]=o):o=n[6];let i;n[7]!==o?(i=new Set(o),n[7]=o,n[8]=i):i=n[8];const l=i;let a;n[9]!==r.completed_steps?.error?(a=r.completed_steps?.error??[],n[9]=r.completed_steps?.error,n[10]=a):a=n[10];let c;n[11]!==a?(c=new Set(a),n[11]=a,n[12]=c):c=n[12];const d=c;let u;n[13]!==d||n[14]!==t||n[15]!==l?(u=-1,t.forEach((f,h)=>{(l.has(f.name)||d.has(f.name))&&(u=h)}),n[13]=d,n[14]=t,n[15]=l,n[16]=u):u=n[16],t.forEach((f,h)=>{let p="pending";d.has(f.name)?p="error":l.has(f.name)?p="success":r.status==="running"&&h===u+1&&(p="running"),s[f.name]={status:p,output:void 0,error:void 0,stepIndex:h}}),n[0]=r.completed_steps?.error,n[1]=r.completed_steps?.success,n[2]=r.status,n[3]=t,n[4]=s}else s=n[4];return s}function pw(n){const e=I.c(119),{step:t,index:r,isSelected:s,executionStatus:o,isSkipped:i,isLastStep:l,onSelect:a,onDelete:c,onDuplicate:d}=n,u=we(),{item:f}=Pn(u),h=f?.completed_at_epoch_ms;let p;e[0]!==f?.completed_steps?.success||e[1]!==t.name?(p=f?.completed_steps?.success?.includes(t.name)??!1,e[0]=f?.completed_steps?.success,e[1]=t.name,e[2]=p):p=e[2];const y=p;let g;e[3]!==f?.completed_steps?.error||e[4]!==t.name?(g=f?.completed_steps?.error?.includes(t.name)??!1,e[3]=f?.completed_steps?.error,e[4]=t.name,e[5]=g):g=e[5];const x=g,b="toolName"in t.action,S=b&&"connectionId"in t.action?t.action.connectionId:null,k=!!(b&&"toolName"in t.action?t.action.toolName:null);let w,C,T,A,D,j,_,V,B,H,N;if(e[6]!==S||e[7]!==o||e[8]!==k||e[9]!==r||e[10]!==y||e[11]!==x||e[12]!==l||e[13]!==s||e[14]!==i||e[15]!==b||e[16]!==c||e[17]!==d||e[18]!==a||e[19]!==t||e[20]!==u){const le=Nw(t);w=y?"success":x?"error":o?.status;const X=o!==void 0,fe=w==="success"||w==="error";let se=le.length>0?60:12;(w==="success"||w==="error")&&(se=se+32);let J,Fe,at;if(e[32]!==s||e[33]!==i||e[34]!==a||e[35]!==w){const $n=yw(w);let br;e[44]!==w?(br=xw(w),e[44]=w,e[45]=br):br=e[45],J=br;const ro=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",so=w==="running"&&"bg-accent/50",oo=i&&"opacity-50";e[46]!==ro||e[47]!==so||e[48]!==oo?(V=U("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",ro,so,oo),e[46]=ro,e[47]=so,e[48]=oo,e[49]=V):V=e[49],B=a,H="button",N=0,e[50]!==a?(C=io=>{(io.key==="Enter"||io.key===" ")&&(io.preventDefault(),a())},e[50]=a,e[51]=C):C=e[51],at="w-5 flex flex-col items-center justify-center shrink-0 pt-3",Fe=U("text-xs font-mono opacity-75 h-8 flex items-center",$n),e[32]=s,e[33]=i,e[34]=a,e[35]=w,e[36]=J,e[37]=C,e[38]=Fe,e[39]=at,e[40]=V,e[41]=B,e[42]=H,e[43]=N}else J=e[36],C=e[37],Fe=e[38],at=e[39],V=e[40],B=e[41],H=e[42],N=e[43];const to=r+1;let en;e[52]!==Fe||e[53]!==to?(en=m.jsxs("span",{className:Fe,children:[to,"."]}),e[52]=Fe,e[53]=to,e[54]=en):en=e[54],e[55]!==at||e[56]!==en?(T=m.jsx("div",{className:at,children:en}),e[55]=at,e[56]=en,e[57]=T):T=e[57];let tn;e[58]!==J||e[59]!==r?(tn=r>0?m.jsx(Vo,{height:12,color:J}):m.jsx("div",{className:"h-3"}),e[58]=J,e[59]=r,e[60]=tn):tn=e[60];let nn;e[61]!==S||e[62]!==k||e[63]!==b||e[64]!==t.name?(nn=m.jsx(vw,{connectionId:S,isToolStep:b,hasToolSelected:k,stepName:t.name}),e[61]=S,e[62]=k,e[63]=b,e[64]=t.name,e[65]=nn):nn=e[65];let rn;e[66]!==J||e[67]!==fe||e[68]!==w?(rn=fe&&m.jsxs(m.Fragment,{children:[m.jsx(Vo,{height:8,color:J}),m.jsx(bw,{status:w})]}),e[66]=J,e[67]=fe,e[68]=w,e[69]=rn):rn=e[69];let sn;e[70]!==J||e[71]!==se||e[72]!==l||e[73]!==u?(sn=l&&u?null:m.jsx(Vo,{height:se,color:J}),e[70]=J,e[71]=se,e[72]=l,e[73]=u,e[74]=sn):sn=e[74],e[75]!==tn||e[76]!==nn||e[77]!==rn||e[78]!==sn?(A=m.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[tn,nn,rn,sn]}),e[75]=tn,e[76]=nn,e[77]=rn,e[78]=sn,e[79]=A):A=e[79],D="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const no=k?"font-medium text-foreground":"text-foreground";let on;e[80]!==no?(on=U("text-sm truncate flex-1",no),e[80]=no,e[81]=on):on=e[81];let ln;e[82]!==t?(ln=Cw(t),e[82]=t,e[83]=ln):ln=e[83];let an;e[84]!==on||e[85]!==ln?(an=m.jsx("span",{className:on,children:ln}),e[84]=on,e[85]=ln,e[86]=an):an=e[86];let cn;e[87]!==X||e[88]!==w?(cn=X&&m.jsx(kw,{status:w}),e[87]=X,e[88]=w,e[89]=cn):cn=e[89];let dn;e[90]!==X||e[91]!==c||e[92]!==d?(dn=!X&&m.jsxs(yp,{children:[m.jsx(xp,{asChild:!0,children:m.jsx(me,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:gw,children:m.jsx(gp,{size:14})})}),m.jsxs(bp,{align:"end",children:[m.jsxs(Fl,{onClick:$n=>{$n.stopPropagation(),d()},children:[m.jsx(wp,{size:14}),"Duplicate"]}),m.jsxs(Fl,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:$n=>{$n.stopPropagation(),c()},children:[m.jsx(Ah,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[90]=X,e[91]=c,e[92]=d,e[93]=dn):dn=e[93],e[94]!==an||e[95]!==cn||e[96]!==dn?(j=m.jsxs("div",{className:"flex items-center h-8",children:[an,cn,dn]}),e[94]=an,e[95]=cn,e[96]=dn,e[97]=j):j=e[97],_=le.length>0&&m.jsx("div",{className:"flex flex-wrap gap-1.5",children:le.map(mw)}),e[6]=S,e[7]=o,e[8]=k,e[9]=r,e[10]=y,e[11]=x,e[12]=l,e[13]=s,e[14]=i,e[15]=b,e[16]=c,e[17]=d,e[18]=a,e[19]=t,e[20]=u,e[21]=w,e[22]=C,e[23]=T,e[24]=A,e[25]=D,e[26]=j,e[27]=_,e[28]=V,e[29]=B,e[30]=H,e[31]=N}else w=e[21],C=e[22],T=e[23],A=e[24],D=e[25],j=e[26],_=e[27],V=e[28],B=e[29],H=e[30],N=e[31];let z;e[98]!==h||e[99]!==w?(z=w==="success"&&m.jsx(Sw,{completedAtEpochMs:h}),e[98]=h,e[99]=w,e[100]=z):z=e[100];let P;e[101]!==o?.error||e[102]!==w?(P=w==="error"&&m.jsx(ww,{error:o?.error}),e[101]=o?.error,e[102]=w,e[103]=P):P=e[103];let K;e[104]!==z||e[105]!==P||e[106]!==D||e[107]!==j||e[108]!==_?(K=m.jsxs("div",{className:D,children:[j,_,z,P]}),e[104]=z,e[105]=P,e[106]=D,e[107]=j,e[108]=_,e[109]=K):K=e[109];let Q;return e[110]!==C||e[111]!==T||e[112]!==A||e[113]!==K||e[114]!==V||e[115]!==B||e[116]!==H||e[117]!==N?(Q=m.jsxs("div",{className:V,onClick:B,role:H,tabIndex:N,onKeyDown:C,children:[T,A,K]}),e[110]=C,e[111]=T,e[112]=A,e[113]=K,e[114]=V,e[115]=B,e[116]=H,e[117]=N,e[118]=Q):Q=e[118],Q}function mw(n){return m.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:n},n)}function gw(n){return n.stopPropagation()}function yw(n){switch(n){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function xw(n){switch(n){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function bw(n){const e=I.c(2),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-success flex items-center justify-center",children:m.jsx(Vi,{size:8,className:"text-success-foreground"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-destructive flex items-center justify-center",children:m.jsx($i,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function kw(n){const e=I.c(3),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(Vi,{size:11,className:"text-success"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx($i,{size:11,className:"text-destructive"})}),e[1]=r):r=e[1],r}if(t==="running"){let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(tr,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function Sw(n){const e=I.c(8),{completedAtEpochMs:t}=n;let r,s;if(e[0]!==t){const a=t!=null?new Date(t):null;r=a?a.toISOString().split("T")[0]:null,s=a?a.toTimeString().split(" ")[0]:null,e[0]=t,e[1]=r,e[2]=s}else r=e[1],s=e[2];const o=s;let i;e[3]!==r||e[4]!==o?(i=r&&o&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Fh,{size:16,className:"text-success"}),m.jsx("span",{className:"text-xs text-success",children:r}),m.jsx("span",{className:"text-xs text-success",children:o})]}),e[3]=r,e[4]=o,e[5]=i):i=e[5];let l;return e[6]!==i?(l=m.jsx("div",{className:"inline-flex items-center gap-3 px-1.5 py-1 bg-success-foreground rounded-lg w-fit",children:i}),e[6]=i,e[7]=l):l=e[7],l}function ww(n){const e=I.c(3),{error:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx(qi,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=t||"Execution failed";let o;return e[1]!==s?(o=m.jsxs("div",{className:"inline-flex items-center gap-1.5 px-1.5 py-1 bg-destructive-foreground rounded-lg w-fit",children:[r,m.jsx("span",{className:"text-xs text-destructive",children:s})]}),e[1]=s,e[2]=o):o=e[2],o}function vw(n){const e=I.c(5),{connectionId:t,isToolStep:r,hasToolSelected:s,stepName:o}=n,i=Pi(t??"");if(r&&s&&i?.icon){let a;return e[0]!==i.icon||e[1]!==o?(a=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center overflow-hidden",children:m.jsx(js,{icon:i.icon,name:o,size:"xs",className:"border-0 rounded-none"})}),e[0]=i.icon,e[1]=o,e[2]=a):a=e[2],a}let l;return e[3]!==r?(l=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center",children:r?m.jsx(Zc,{size:16,className:"text-muted-foreground"}):m.jsx(Sp,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function Vo(n){const e=I.c(7),{height:t,color:r}=n,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=U("w-px",s),e[0]=s,e[1]=o):o=e[1];let i;e[2]!==t?(i={height:t},e[2]=t,e[3]=i):i=e[3];let l;return e[4]!==o||e[5]!==i?(l=m.jsx("div",{className:o,style:i}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function Cw(n){return n.name?n.name:"toolName"in n.action&&n.action.toolName?n.action.toolName:"code"in n.action?n.name||"Code Step":"Select tool..."}function Nw(n){const e=n.outputSchema;if(!e||typeof e!="object")return[];const t=e.properties;return!t||typeof t!="object"?[]:Object.keys(t).slice(0,5)}function Ew(n){const e=I.c(32),{className:t}=n,r=pr(),s=sd(),o=hw(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a}=Me(),c=we();let d;e[0]!==o||e[1]!==r?(d=o?r.findIndex(S=>o[S.name]?.status==="error"):-1,e[0]=o,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=m.jsx("div",{children:"Loading..."}),e[3]=f):f=e[3];let h;e[4]!==t?(h=U("h-full flex flex-col p-8 overflow-auto",t),e[4]=t,e[5]=h):h=e[5];let p;if(e[6]!==s||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==i||e[11]!==o||e[12]!==r){let S;e[14]!==s||e[15]!==l||e[16]!==a||e[17]!==u||e[18]!==i||e[19]!==o||e[20]!==r.length?(S=(v,k)=>{const w=o?.[v.name],C=u!==-1&&k>u&&w?.status==="pending",T=k===r.length-1;return m.jsx(pw,{step:v,index:k,isSelected:v.name===s,executionStatus:w,isSkipped:C,isLastStep:T,onSelect:()=>i(v.name),onDelete:()=>l(v.name),onDuplicate:()=>a(v.name)},v.name)},e[14]=s,e[15]=l,e[16]=a,e[17]=u,e[18]=i,e[19]=o,e[20]=r.length,e[21]=S):S=e[21],p=r.map(S),e[6]=s,e[7]=l,e[8]=a,e[9]=u,e[10]=i,e[11]=o,e[12]=r,e[13]=p}else p=e[13];let y;e[22]!==p?(y=m.jsx("div",{className:"pt-3 -space-y-1",children:p}),e[22]=p,e[23]=y):y=e[23];let g;e[24]!==c?(g=c?null:m.jsx(Tw,{}),e[24]=c,e[25]=g):g=e[25];let x;e[26]!==y||e[27]!==g?(x=m.jsxs("div",{className:"w-full -space-y-1",children:[y,g]}),e[26]=y,e[27]=g,e[28]=x):x=e[28];let b;return e[29]!==h||e[30]!==x?(b=m.jsx(O.Suspense,{fallback:f,children:m.jsx("div",{className:h,children:x})}),e[29]=h,e[30]=x,e[31]=b):b=e[31],b}function Tw(){const n=I.c(8),{addToolStep:e}=Me();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=m.jsx("div",{className:"w-5 shrink-0"}),n[0]=t):t=n[0];let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"w-px h-3 bg-border"}),n[1]=r):r=n[1];let s;n[2]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx(zc,{size:14}),n[2]=s):s=n[2];let o;n[3]!==e?(o=m.jsx(me,{variant:"outline",size:"icon",className:"size-8 rounded-lg",onClick:e,children:s}),n[3]=e,n[4]=o):o=n[4];let i;n[5]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"w-px h-8",style:{backgroundImage:"repeating-linear-gradient(180deg, var(--border), var(--border) 4px, transparent 4px, transparent 8px)",backgroundPosition:"left top",backgroundRepeat:"repeat-y",backgroundSize:"2px 100%"}}),n[5]=i):i=n[5];let l;return n[6]!==o?(l=m.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[t,m.jsxs("div",{className:"flex flex-col border-1 border-transparent items-center shrink-0",children:[r,o,i]})]}),n[6]=o,n[7]=l):l=n[7],l}function Mw(){const n=I.c(5),e=jn();let t;n[0]!==e?(t=e?new URL(`/mcp/gateway/${e}`,window.location.origin).href:"",n[0]=e,n[1]=t):t=n[1];const r=t,s=!!e;let o;return n[2]!==r||n[3]!==s?(o={url:r,enabled:s},n[2]=r,n[3]=s,n[4]=o):o=n[4],zi(o)}function Aw(n){const e=I.c(7),{className:t}=n;if(!jn()){let o;e[0]!==t?(o=U("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground p-4 text-center",children:"Select an agent to see available tools"}),e[2]=i):i=e[2];let l;return e[3]!==o?(l=m.jsx("div",{className:o,children:i}),e[3]=o,e[4]=l):l=e[4],l}let s;return e[5]!==t?(s=m.jsx(Ow,{className:t}),e[5]=t,e[6]=s):s=e[6],s}function Ow(n){const e=I.c(38),{className:t}=n,{tools:r,isLoading:s,error:o}=Mw(),i=hr(),{updateStep:l}=Me(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let d;if(e[0]!==c||e[1]!==r){let k;e[3]!==c?(k=w=>w.name===c,e[3]=c,e[4]=k):k=e[4],d=r.find(k),e[0]=c,e[1]=r,e[2]=d}else d=e[2];const f=ng(r,d??null,Rw,Iw);let h;e[5]!==i||e[6]!==l?(h=k=>{i&&l(i.name,{action:{...i.action,toolName:k.name},outputSchema:k.outputSchema??{}})},e[5]=i,e[6]=l,e[7]=h):h=e[7];const p=h;if(s){let k;e[8]!==t?(k=U("flex flex-col h-full bg-sidebar",t),e[8]=t,e[9]=k):k=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=m.jsx("div",{className:"flex-1 flex items-center justify-center",children:m.jsx(Ds,{size:"sm"})}),e[10]=w):w=e[10];let C;return e[11]!==k?(C=m.jsx("div",{className:k,children:w}),e[11]=k,e[12]=C):C=e[12],C}if(o){let k;e[13]!==t?(k=U("flex flex-col h-full bg-sidebar",t),e[13]=t,e[14]=k):k=e[14];let w;e[15]!==o.message?(w=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-destructive p-4 text-center",children:["Failed to load tools: ",o.message]}),e[15]=o.message,e[16]=w):w=e[16];let C;return e[17]!==k||e[18]!==w?(C=m.jsx("div",{className:k,children:w}),e[17]=k,e[18]=w,e[19]=C):C=e[19],C}let y;e[20]!==t?(y=U("flex flex-col h-full bg-sidebar",t),e[20]=t,e[21]=y):y=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=m.jsx("span",{className:"text-base font-medium text-foreground",children:"Select tool"}),e[22]=g):g=e[22];let x;e[23]!==r.length?(x=m.jsx("div",{className:"flex items-start border-b border-border",children:m.jsxs("div",{className:"flex-1 flex items-center h-12 px-5",children:[g,m.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:["(",r.length,")"]})]})}),e[23]=r.length,e[24]=x):x=e[24];let b;if(e[25]!==p||e[26]!==f||e[27]!==c){let k;e[29]!==p||e[30]!==c?(k=w=>m.jsx(jw,{icon:null,title:w.name,description:w.description,isSelected:w.name===c,onClick:()=>p(w)},w.name),e[29]=p,e[30]=c,e[31]=k):k=e[31],b=f.map(k),e[25]=p,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let S;e[32]!==b?(S=m.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=S):S=e[33];let v;return e[34]!==y||e[35]!==x||e[36]!==S?(v=m.jsxs("div",{className:y,children:[x,S]}),e[34]=y,e[35]=x,e[36]=S,e[37]=v):v=e[37],v}function Iw(n,e){return n.name.localeCompare(e.name)}function Rw(n){return n.name}function jw(n){const e=I.c(20),{icon:t,title:r,description:s,isSelected:o,onClick:i}=n,l=o&&"bg-muted/50";let a;e[0]!==l?(a=U("flex items-start gap-2.5 min-h-14 px-5 py-4 cursor-pointer transition-colors","hover:bg-muted/50",l),e[0]=l,e[1]=a):a=e[1];let c;e[2]!==i?(c=y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),i())},e[2]=i,e[3]=c):c=e[3];let d;e[4]!==t||e[5]!==r?(d=m.jsx(js,{icon:t,name:r,size:"xs",className:"shadow-sm mt-0.5"}),e[4]=t,e[5]=r,e[6]=d):d=e[6];let u;e[7]!==r?(u=m.jsx("span",{className:"text-sm font-medium text-foreground truncate block",children:r}),e[7]=r,e[8]=u):u=e[8];let f;e[9]!==s?(f=s&&m.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s}),e[9]=s,e[10]=f):f=e[10];let h;e[11]!==u||e[12]!==f?(h=m.jsxs("div",{className:"flex-1 min-w-0",children:[u,f]}),e[11]=u,e[12]=f,e[13]=h):h=e[13];let p;return e[14]!==i||e[15]!==a||e[16]!==c||e[17]!==d||e[18]!==h?(p=m.jsxs("div",{className:a,onClick:i,role:"button",tabIndex:0,onKeyDown:c,children:[d,h]}),e[14]=i,e[15]=a,e[16]=c,e[17]=d,e[18]=h,e[19]=p):p=e[19],p}var Ue="Accordion",Dw=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ll,Pw,Lw]=Ih(Ue),[Zs]=Mc(Ue,[Lw,$c]),$l=$c(),sh=ee.forwardRef((n,e)=>{const{type:t,...r}=n,s=r,o=r;return m.jsx(Ll.Provider,{scope:n.__scopeAccordion,children:t==="multiple"?m.jsx(Bw,{...o,ref:e}):m.jsx(_w,{...s,ref:e})})});sh.displayName=Ue;var[oh,$w]=Zs(Ue),[ih,zw]=Zs(Ue,{collapsible:!1}),_w=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=n,[l,a]=Ei({prop:t,defaultProp:r??"",onChange:s,caller:Ue});return m.jsx(oh,{scope:n.__scopeAccordion,value:ee.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:ee.useCallback(()=>o&&a(""),[o,a]),children:m.jsx(ih,{scope:n.__scopeAccordion,collapsible:o,children:m.jsx(lh,{...i,ref:e})})})}),Bw=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},...o}=n,[i,l]=Ei({prop:t,defaultProp:r??[],onChange:s,caller:Ue}),a=ee.useCallback(d=>l((u=[])=>[...u,d]),[l]),c=ee.useCallback(d=>l((u=[])=>u.filter(f=>f!==d)),[l]);return m.jsx(oh,{scope:n.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:m.jsx(ih,{scope:n.__scopeAccordion,collapsible:!0,children:m.jsx(lh,{...o,ref:e})})})}),[Fw,eo]=Zs(Ue),lh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,disabled:r,dir:s,orientation:o="vertical",...i}=n,l=ee.useRef(null),a=Ic(l,e),c=Pw(t),u=Rh(s)==="ltr",f=Ge(n.onKeyDown,h=>{if(!Dw.includes(h.key))return;const p=h.target,y=c().filter(T=>!T.ref.current?.disabled),g=y.findIndex(T=>T.ref.current===p),x=y.length;if(g===-1)return;h.preventDefault();let b=g;const S=0,v=x-1,k=()=>{b=g+1,b>v&&(b=S)},w=()=>{b=g-1,b<S&&(b=v)};switch(h.key){case"Home":b=S;break;case"End":b=v;break;case"ArrowRight":o==="horizontal"&&(u?k():w());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(u?w():k());break;case"ArrowUp":o==="vertical"&&w();break}const C=b%x;y[C].ref.current?.focus()});return m.jsx(Fw,{scope:t,disabled:r,direction:s,orientation:o,children:m.jsx(Ll.Slot,{scope:t,children:m.jsx(Ni.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),Rs="AccordionItem",[Vw,zl]=Zs(Rs),ah=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,value:r,...s}=n,o=eo(Rs,t),i=$w(Rs,t),l=$l(t),a=Oh(),c=r&&i.value.includes(r)||!1,d=o.disabled||n.disabled;return m.jsx(Vw,{scope:t,open:c,disabled:d,triggerId:a,children:m.jsx(ep,{"data-orientation":o.orientation,"data-state":ph(c),...l,...s,ref:e,disabled:d,open:c,onOpenChange:u=>{u?i.onItemOpen(r):i.onItemClose(r)}})})});ah.displayName=Rs;var ch="AccordionHeader",dh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(ch,t);return m.jsx(Ni.h3,{"data-orientation":s.orientation,"data-state":ph(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});dh.displayName=ch;var vi="AccordionTrigger",uh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(vi,t),i=zw(vi,t),l=$l(t);return m.jsx(Ll.ItemSlot,{scope:t,children:m.jsx(np,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});uh.displayName=vi;var fh="AccordionContent",hh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=eo(Ue,t),o=zl(fh,t),i=$l(t);return m.jsx(tp,{role:"region","aria-labelledby":o.triggerId,"data-orientation":s.orientation,...i,...r,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...n.style}})});hh.displayName=fh;function ph(n){return n?"open":"closed"}var Hw=sh,Ww=ah,qw=dh,Uw=uh,Kw=hh;function Jw(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(Hw,{"data-slot":"accordion",...t}),e[2]=t,e[3]=r):r=e[3],r}function Gw(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=U("border-b last:border-b-0",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx(Ww,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function Xw(n){const e=I.c(11);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=U("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(kp,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==s||e[9]!==o?(l=m.jsx(qw,{className:"flex",children:m.jsxs(Uw,{"data-slot":"accordion-trigger",className:o,...s,children:[t,i]})}),e[7]=t,e[8]=s,e[9]=o,e[10]=l):l=e[10],l}function Yw(n){const e=I.c(12);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=U("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==t||e[7]!==o?(i=m.jsx("div",{className:o,children:t}),e[6]=t,e[7]=o,e[8]=i):i=e[8];let l;return e[9]!==s||e[10]!==i?(l=m.jsx(Kw,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...s,children:i}),e[9]=s,e[10]=i,e[11]=l):l=e[11],l}var Qw=(n,e,t,r,s,o,i,l)=>{let a=document.documentElement,c=["light","dark"];function d(h){(Array.isArray(n)?n:[n]).forEach(p=>{let y=p==="class",g=y&&o?s.map(x=>o[x]||x):s;y?(a.classList.remove(...g),a.classList.add(o&&o[h]?o[h]:h)):a.setAttribute(p,h)}),u(h)}function u(h){l&&c.includes(h)&&(a.style.colorScheme=h)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let h=localStorage.getItem(e)||t,p=i&&h==="system"?f():h;d(p)}catch{}};O.createContext(void 0);O.memo(({forcedTheme:n,storageKey:e,attribute:t,enableSystem:r,enableColorScheme:s,defaultTheme:o,value:i,themes:l,nonce:a,scriptProps:c})=>{let d=JSON.stringify([t,e,o,n,l,i,r,s]).slice(1,-1);return O.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?a:"",dangerouslySetInnerHTML:{__html:`(${Qw.toString()})(${d})`}})});function Zw(n){const{updateStep:e}=Me(),r=n&&"toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,{tool:s}=_l(r??"");n&&r&&s?.outputSchema&&(!n.outputSchema||Object.keys(n.outputSchema).length===0)&&queueMicrotask(()=>{e(n.name,{outputSchema:s.outputSchema})})}function ev(n){const e=I.c(25),{className:t}=n,r=hr(),{appendStep:s}=Me();if(Zw(r),!r){let f;e[0]!==t?(f=U("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=f):f=e[1];let h;e[2]!==s?(h=()=>{s({type:"tool"})},e[2]=s,e[3]=h):h=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(zc,{size:14}),e[4]=p):p=e[4];let y;e[5]!==h?(y=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground gap-2 flex-col",children:["Select or create a step to configure",m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:h,children:p})]}),e[5]=h,e[6]=y):y=e[6];let g;return e[7]!==f||e[8]!==y?(g=m.jsx("div",{className:f,children:y}),e[7]=f,e[8]=y,e[9]=g):g=e[9],g}let o;e[10]!==t?(o=U("flex flex-col h-full bg-sidebar overflow-scroll",t),e[10]=t,e[11]=o):o=e[11];let i,l,a,c,d;e[12]!==r?(i=m.jsx(tv,{step:r}),l=m.jsx(rv,{step:r}),a=m.jsx(sv,{step:r}),c=m.jsx(av,{step:r}),d=m.jsx(uv,{step:r}),e[12]=r,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=d):(i=e[13],l=e[14],a=e[15],c=e[16],d=e[17]);let u;return e[18]!==o||e[19]!==i||e[20]!==l||e[21]!==a||e[22]!==c||e[23]!==d?(u=m.jsxs("div",{className:o,children:[i,l,a,c,d]}),e[18]=o,e[19]=i,e[20]=l,e[21]=a,e[22]=c,e[23]=d,e[24]=u):u=e[24],u}function tv(n){const e=I.c(15),{step:t}=n,s="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,o=we(),i=s??"";let l;e[0]!==i?(l=m.jsx(js,{icon:null,name:i,size:"xs",className:"shadow-sm"}),e[0]=i,e[1]=l):l=e[1];let a;e[2]!==s?(a=m.jsx("span",{className:"text-base font-medium text-foreground truncate flex-1",children:s}),e[2]=s,e[3]=a):a=e[3];let c;e[4]!==o?(c=o?null:m.jsx(nv,{}),e[4]=o,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==a||e[8]!==c?(d=m.jsxs("div",{className:"flex items-center gap-2",children:[l,a,c]}),e[6]=l,e[7]=a,e[8]=c,e[9]=d):d=e[9];let u;e[10]!==t.description?(u=t.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[10]=t.description,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=m.jsxs("div",{className:"border-b border-border p-5 shrink-0 flex flex-col gap-2",children:[d,u]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function nv(){const n=I.c(9),e=hr(),{updateStep:t,startReplacingTool:r}=Me(),s=we(),i=e&&"toolName"in e.action?e.action.toolName:null;let l;n[0]!==e||n[1]!==r||n[2]!==i||n[3]!==s||n[4]!==t?(l=()=>{if(e){if(s){Ec.error("You cannot replace a tool while a workflow is executing.");return}i&&r(i),t(e.name,{action:{...e.action,toolName:""}})}},n[0]=e,n[1]=r,n[2]=i,n[3]=s,n[4]=t,n[5]=l):l=n[5];const a=l;let c;n[6]===Symbol.for("react.memo_cache_sentinel")?(c=m.jsx(Qc,{size:14}),n[6]=c):c=n[6];let d;return n[7]!==a?(d=m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:a,title:"Replace tool",children:c}),n[7]=a,n[8]=d):d=n[8],d}function _l(n){const e=I.c(13),t=jn();let r;e[0]!==t?(r=t?new URL(`/mcp/gateway/${t}`,window.location.origin).href:"",e[0]=t,e[1]=r):r=e[1];const s=r,o=!!t;let i;e[2]!==s||e[3]!==o?(i={url:s,enabled:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const l=zi(i);let a;e[5]!==l.tools||e[6]!==n?(a=l.tools?.find(h=>h.name===n),e[5]=l.tools,e[6]=n,e[7]=a):a=e[7];const c=a,d=l.state==="connecting",u=l.state==="ready";let f;return e[8]!==l.error||e[9]!==d||e[10]!==u||e[11]!==c?(f={tool:c,isLoading:d,isReady:u,error:l.error},e[8]=l.error,e[9]=d,e[10]=u,e[11]=c,e[12]=f):f=e[12],f}function rv(n){const e=I.c(13),{step:t}=n,{updateStep:r}=Me(),o="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,i=we(),{tool:l}=_l(o??"");if(!l||!l.inputSchema)return null;let a;e[0]!==t.name||e[1]!==r?(a=x=>{r(t.name,{input:x})},e[0]=t.name,e[1]=r,e[2]=a):a=e[2];const c=a,d=i?"output":"input";let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx(Xw,{className:"px-5 py-5",children:m.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Input"})}),e[3]=u):u=e[3];const f=l.inputSchema,h=t.input;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[4]=p):p=e[4];let y;e[5]!==c||e[6]!==t.name||e[7]!==f||e[8]!==h?(y=m.jsxs(Gw,{value:"input",className:"border-b-0",children:[u,m.jsx(Yw,{className:"px-5 pt-2",children:m.jsx(rh,{inputSchema:f,inputParams:h,setInputParams:c,mentions:p},t.name)})]}),e[5]=c,e[6]=t.name,e[7]=f,e[8]=h,e[9]=y):y=e[9];let g;return e[10]!==d||e[11]!==y?(g=m.jsx(Jw,{type:"single",collapsible:!0,defaultValue:d,className:"border-b border-border shrink-0",children:y}),e[10]=d,e[11]=y,e[12]=g):g=e[12],g}function sv(n){const e=I.c(24),{step:t}=n,r=t.outputSchema,[s,o]=O.useState(!1),i=we(),{item:l}=Pn(i),a=!!(l?.completed_steps?.success?.includes(t.name)||l?.completed_steps?.error?.includes(t.name)),{output:c,error:d}=Um(i,a?t.name:void 0);let u;e[0]!==d||e[1]!==c?(u=c||(d?{error:d}:void 0),e[0]=d,e[1]=c,e[2]=u):u=e[2];const f=u,h=r&&typeof r=="object"?r.properties:void 0;let p;e[3]!==h?(p=h?Object.entries(h):[],e[3]=h,e[4]=p):p=e[4];const y=p,g=s?"flex-1 min-h-0 overflow-hidden":"shrink-0";let x;e[5]!==g?(x=U("flex flex-col border-b border-border",g),e[5]=g,e[6]=x):x=e[6];let b;e[7]!==s?(b=()=>o(!s),e[7]=s,e[8]=b):b=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Output"}),e[9]=S):S=e[9];let v;e[10]!==s?(v=m.jsxs("div",{className:"flex items-center justify-between",children:[S,s?m.jsx(Wi,{size:14,className:"text-muted-foreground"}):m.jsx(Hi,{size:14,className:"text-muted-foreground"})]}),e[10]=s,e[11]=v):v=e[11];let k;e[12]!==b||e[13]!==v?(k=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:b,children:v}),e[12]=b,e[13]=v,e[14]=k):k=e[14];let w;e[15]!==f||e[16]!==s||e[17]!==y||e[18]!==i?(w=s&&m.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5",children:[i&&f?m.jsx(On,{code:JSON.stringify(f,null,2),language:"json",height:"100%",readOnly:!0}):null,!i&&y.map(ov)]}),e[15]=f,e[16]=s,e[17]=y,e[18]=i,e[19]=w):w=e[19];let C;return e[20]!==x||e[21]!==k||e[22]!==w?(C=m.jsxs("div",{className:x,children:[k,w]}),e[20]=x,e[21]=k,e[22]=w,e[23]=C):C=e[23],C}function ov(n){const[e,t]=n;return m.jsx(lv,{name:e,schema:t},e)}function iv(n){switch(n){case"string":return{Icon:Uc,color:"text-blue-500"};case"number":case"integer":return{Icon:Wc,color:"text-blue-500"};case"array":return{Icon:Fc,color:"text-purple-500"};case"object":return{Icon:Bc,color:"text-orange-500"};case"boolean":return{Icon:qc,color:"text-pink-500"};case"null":return{Icon:Ti,color:"text-gray-500"};default:return{Icon:Vc,color:"text-muted-foreground"}}}function lv(n){const e=I.c(28),{name:t,schema:r}=n,s=hr(),o=r.type??"unknown";let i,l,a,c,d;if(e[0]!==o){const{Icon:v,color:k}=iv(o);d="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=v,l=14,a=U(k),e[0]=o,e[1]=i,e[2]=l,e[3]=a,e[4]=c,e[5]=d}else i=e[1],l=e[2],a=e[3],c=e[4],d=e[5];let u;e[6]!==i||e[7]!==l||e[8]!==a?(u=m.jsx(i,{size:l,className:a}),e[6]=i,e[7]=l,e[8]=a,e[9]=u):u=e[9];let f;e[10]!==t?(f=m.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[10]=t,e[11]=f):f=e[11];let h;e[12]!==c||e[13]!==u||e[14]!==f?(h=m.jsxs("div",{className:c,children:[u,f]}),e[12]=c,e[13]=u,e[14]=f,e[15]=h):h=e[15];let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Xc,{size:14,className:"opacity-50"}),e[16]=p):p=e[16];const y=s?.name;let g;e[17]!==y?(g=m.jsxs("span",{className:"text-muted-foreground",children:[y,"."]}),e[17]=y,e[18]=g):g=e[18];let x;e[19]!==t?(x=m.jsx("div",{className:"bg-blue-500/10 text-blue-500 px-1 py-0.5 rounded",children:t}),e[19]=t,e[20]=x):x=e[20];let b;e[21]!==g||e[22]!==x?(b=m.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[p,g,x]}),e[21]=g,e[22]=x,e[23]=b):b=e[23];let S;return e[24]!==b||e[25]!==d||e[26]!==h?(S=m.jsxs("div",{className:d,children:[h,b]}),e[24]=b,e[25]=d,e[26]=h,e[27]=S):S=e[27],S}function av(n){const e=I.c(29),{step:t}=n,{updateStep:r}=Me(),s=we(),[o,i]=O.useState(!1),l="toolName"in t.action,a=l&&"toolName"in t.action?t.action.toolName:null,{tool:c}=_l(a??""),d=l&&"transformCode"in t.action?t.action.transformCode??null:null;let u;e[0]!==c?(u=()=>{if(!c?.outputSchema)return`interface Input {
|
|
147
147
|
// Tool output schema not available
|
|
148
148
|
}`;const T=c.outputSchema,A=T.properties;return A?`interface Input {
|
|
149
149
|
${Object.entries(A).map(j=>{const[_,V]=j,B=_r(V),H=!T.required?.includes(_);return` ${_}${H?"?":""}: ${B};`}).join(`
|