@decocms/mesh 1.0.14 → 1.0.16
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-DaEUMwle.js → AlertCircle-cYjr_0xB.js} +1 -1
- package/dist/client/assets/{ArrowLeft-CvFDkdiU.js → ArrowLeft-CBi8stO3.js} +1 -1
- package/dist/client/assets/{Calendar-DBqzL4c-.js → Calendar-cB-o1wit.js} +1 -1
- package/dist/client/assets/{ChevronDown-g4L12M9A.js → ChevronDown-7kPeUreU.js} +1 -1
- package/dist/client/assets/{Clock-C-uwthk9.js → Clock-D4OCvk0s.js} +1 -1
- package/dist/client/assets/{Copy01-CHjgpWtl.js → Copy01-DmZIDbuC.js} +1 -1
- package/dist/client/assets/{CpuChip02-DlCI7cQJ.js → CpuChip02-CvUOZekE.js} +1 -1
- package/dist/client/assets/{DotsVertical-CIfapH0j.js → DotsVertical-CugHspqx.js} +1 -1
- package/dist/client/assets/{File06-CBkqKj5m.js → File06-B9Csx588.js} +1 -1
- package/dist/client/assets/{GitBranch01-Ci5lqvRi.js → GitBranch01-DGYWk3k6.js} +1 -1
- package/dist/client/assets/{Inbox01-DCkU3Xgq.js → Inbox01-x47sKUjp.js} +1 -1
- package/dist/client/assets/{InfoCircle-BwNsGATl.js → InfoCircle-DXZ2AFmC.js} +1 -1
- package/dist/client/assets/{Key01-5nxXQgMM.js → Key01-BemiGYAL.js} +1 -1
- package/dist/client/assets/{LinkExternal01-ISpHuMJE.js → LinkExternal01-BrZUQjLP.js} +1 -1
- package/dist/client/assets/{Loading01-r04aEG5T.js → Loading01-CZ--C9o4.js} +1 -1
- package/dist/client/assets/{Plus-CS_Y2Vnc.js → Plus-B87V-eUk.js} +1 -1
- package/dist/client/assets/SearchMd-C_x78fQD.js +1 -0
- package/dist/client/assets/{Terminal-DYN6gEAz.js → Terminal-Bp8rdp_p.js} +1 -1
- package/dist/client/assets/{Trash01-DVxmznxT.js → Trash01-kv9nDzIp.js} +1 -1
- package/dist/client/assets/{Upload01-Da0sGkRE.js → Upload01-BkY8x2qR.js} +1 -1
- package/dist/client/assets/{X-BX0rl0N7.js → X-BI6-CrX0.js} +1 -1
- package/dist/client/assets/{XClose-BUuGHVgA.js → XClose-CPlecLXh.js} +1 -1
- package/dist/client/assets/{alert-dialog-DdP064l-.js → alert-dialog-DLlk9oGk.js} +3 -3
- package/dist/client/assets/{auth-AUS48lXs.js → auth-O7mzDtBv.js} +1 -1
- package/dist/client/assets/{auth-catchall-DqCIX1bA.js → auth-catchall-Cj2BmrFb.js} +1 -1
- package/dist/client/assets/avatar-yEkJ_N8H.js +1 -0
- package/dist/client/assets/badge-CzGd9Js-.js +1 -0
- package/dist/client/assets/button-RGWd1X_P.js +1 -0
- package/dist/client/assets/card-Bch45nKF.js +1 -0
- package/dist/client/assets/checkbox-Bkz-wJOC.js +1 -0
- package/dist/client/assets/collection-detail-BrxtwdmN.js +184 -0
- package/dist/client/assets/collection-display-button-s3SUZ2ky.js +1 -0
- package/dist/client/assets/{collection-header-DcpyPzrC.js → collection-header-g7B4v38B.js} +1 -1
- package/dist/client/assets/{collection-page-DpUZNbpd.js → collection-page-CXQu5PW5.js} +1 -1
- package/dist/client/assets/collection-search-B_ze9BPw.js +1 -0
- package/dist/client/assets/collection-table-wrapper-yPDs4QFo.js +1 -0
- package/dist/client/assets/connection-card-B2ZNmA6T.js +1 -0
- package/dist/client/assets/connection-detail-D98NZkPb.js +1 -0
- package/dist/client/assets/connections-CdxYZab0.js +1 -0
- package/dist/client/assets/{core-DJoPglro.js → core-GvCAeL42.js} +1 -1
- package/dist/client/assets/{create-organization-dialog-fbCy_hNu.js → create-organization-dialog-c2EjUvFE.js} +1 -1
- package/dist/client/assets/dialog-xbeC24qR.js +1 -0
- package/dist/client/assets/dropdown-menu-Dz-Cfe4c.js +1 -0
- package/dist/client/assets/{env-vars-editor-DEYac6H7.js → env-vars-editor-B-ADXMkg.js} +1 -1
- package/dist/client/assets/{error-boundary-CdmYlIj7.js → error-boundary-IlI5HY5C.js} +1 -1
- package/dist/client/assets/{extract-connection-data-Ty2DjF1e.js → extract-connection-data-3bWrIOWG.js} +1 -1
- package/dist/client/assets/form-C0miQmjx.js +1 -0
- package/dist/client/assets/formatDistanceToNow-BgvVIEk6.js +1 -0
- package/dist/client/assets/gateway-detail-C1Vlo23c.js +1 -0
- package/dist/client/assets/gateways-BphVjp-r.js +1 -0
- package/dist/client/assets/home-GBkZhhXc.js +1 -0
- package/dist/client/assets/{index-JV0IIYp6.js → index-CbrmpR2c.js} +1 -1
- package/dist/client/assets/index-Ce0bVa0I.js +155 -0
- package/dist/client/assets/index-FEm5nfEy.css +1 -0
- package/dist/client/assets/{index-DDiLOLYT.js → index-KVbZU2bI.js} +1 -1
- package/dist/client/assets/index-RUqw7d0T.js +25 -0
- package/dist/client/assets/input-Cc7Y8Lsj.js +1 -0
- package/dist/client/assets/{json-syntax-highlighter-i1hiMNnF.js → json-syntax-highlighter-Bc0wDiKJ.js} +2 -2
- package/dist/client/assets/json-zc228CLg.js +1 -0
- package/dist/client/assets/{layout-dxbGsEKV.js → layout-k5sx-zLk.js} +1 -1
- package/dist/client/assets/{lazy-highlighter-QDCjbXst.js → lazy-highlighter-tp_1h6Wp.js} +1 -1
- package/dist/client/assets/{localstorage-keys-D7pZSS7H.js → localstorage-keys-C2n4sqaz.js} +1 -1
- package/dist/client/assets/login-BI3qBB8Y.js +1 -0
- package/dist/client/assets/{mcp-oauth-D7V7V-GS.js → mcp-oauth-BrdcIayH.js} +1 -1
- package/dist/client/assets/members-ClQFNkDC.js +3 -0
- package/dist/client/assets/monitoring-BXnIcCQV.js +1 -0
- package/dist/client/assets/oauth-callback-uokDqdRF.js +1 -0
- package/dist/client/assets/{page-C8KGQPlY.js → page-D8Upjw8L.js} +2 -2
- package/dist/client/assets/popover-gYOPU7b5.js +1 -0
- package/dist/client/assets/prism-light-BmyQu-TG.js +1 -0
- package/dist/client/assets/{resizable-B3HA_CX4.js → resizable-0evkHPjb.js} +48 -48
- package/dist/client/assets/resource-tabs-Bp2LCK5n.js +1 -0
- package/dist/client/assets/select-B-74Vw7Q.js +1 -0
- package/dist/client/assets/settings-DZGZ9pQP.js +1 -0
- package/dist/client/assets/shell-layout-CmBAtkbZ.js +17 -0
- package/dist/client/assets/spinner-B6Gpa1lS.js +1 -0
- package/dist/client/assets/store-CZ1oyjvA.js +1 -0
- package/dist/client/assets/store-app-detail-Cr8HLsme.js +1 -0
- package/dist/client/assets/switch-C6VfIG9f.js +1 -0
- package/dist/client/assets/{tools-list-BsHebq88.js → tools-list-6PdjsEP-.js} +1 -1
- package/dist/client/assets/tooltip-B77piVwL.js +1 -0
- package/dist/client/assets/{types-D4T3qWDr.js → types-0U77q4OL.js} +5 -5
- package/dist/client/assets/{use-binding-CapMpNVF.js → use-binding-DOHpn0td.js} +6 -6
- package/dist/client/assets/use-connection-CcfriG4b.js +2 -0
- package/dist/client/assets/{use-connection-resources-FqHsvBSA.js → use-connection-resources-C-ecJARs.js} +1 -1
- package/dist/client/assets/{use-gateway-CseaalWF.js → use-gateway-CCphplYZ.js} +1 -1
- package/dist/client/assets/{use-list-state-7NLbXyOC.js → use-list-state-Bcpc0dEc.js} +1 -1
- package/dist/client/assets/{use-mcp-M6XXMHar.js → use-mcp-B7yS6xB_.js} +1 -1
- package/dist/client/assets/{use-members-DzZB15s9.js → use-members-ii7q5pxE.js} +1 -1
- package/dist/client/assets/{use-mobile-TpeNqylz.js → use-mobile-DYo2aQNt.js} +1 -1
- package/dist/client/assets/{use-organization-settings-BAhAEDx8.js → use-organization-settings-uQsDNKHC.js} +1 -1
- package/dist/client/assets/{use-tool-call-CQCb5PBf.js → use-tool-call-CI1nZAFC.js} +1 -1
- package/dist/client/assets/useQuery-CF3kr9sY.js +1 -0
- package/dist/client/assets/view-mode-toggle-BGpxvqYI.js +1 -0
- package/dist/client/assets/{well-known-mcp-BPQQU1v0.js → well-known-mcp-B16sbKCU.js} +1 -1
- package/dist/client/empty-state-error.svg +19 -0
- package/dist/client/empty-state-logs.svg +80 -0
- package/dist/client/empty-state-success-muted.svg +19 -0
- package/dist/client/empty-state-success.svg +19 -0
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +1 -1
- package/dist/server/migrate.js +45 -45
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/CheckCircle-CILz6OCh.js +0 -1
- package/dist/client/assets/SearchMd-1Gq7nypQ.js +0 -1
- package/dist/client/assets/avatar-bcdjVFyi.js +0 -1
- package/dist/client/assets/badge-1WraHGEG.js +0 -1
- package/dist/client/assets/button-DodNLkpL.js +0 -1
- package/dist/client/assets/card-BHz-BqEu.js +0 -1
- package/dist/client/assets/checkbox-Bj9jBMQF.js +0 -1
- package/dist/client/assets/collection-detail-QGbMDWA7.js +0 -184
- package/dist/client/assets/collection-display-button-475jHotV.js +0 -1
- package/dist/client/assets/collection-search-DVBnlN6E.js +0 -1
- package/dist/client/assets/collection-table-wrapper-DQ4F9pbh.js +0 -1
- package/dist/client/assets/connection-card-opsQBUfD.js +0 -1
- package/dist/client/assets/connection-detail-DpiL6xjK.js +0 -1
- package/dist/client/assets/connections-CeDc3J_o.js +0 -1
- package/dist/client/assets/dialog-BqvvzTa7.js +0 -1
- package/dist/client/assets/dropdown-menu-DrQKdl4f.js +0 -1
- package/dist/client/assets/form-Bus-fIfC.js +0 -1
- package/dist/client/assets/formatDistanceToNow-D46rGC8T.js +0 -1
- package/dist/client/assets/gateway-detail-fCVh3_nF.js +0 -1
- package/dist/client/assets/gateways-DQmZoxNy.js +0 -1
- package/dist/client/assets/home-heelYyW2.js +0 -1
- package/dist/client/assets/index-A52jfksK.js +0 -156
- package/dist/client/assets/index-DKrh5SL2.css +0 -1
- package/dist/client/assets/index-td_4XAxf.js +0 -25
- package/dist/client/assets/input-BXHWk19m.js +0 -1
- package/dist/client/assets/json-gPxhilNK.js +0 -1
- package/dist/client/assets/login-CcnR2b1q.js +0 -1
- package/dist/client/assets/members-D5QtYSzf.js +0 -3
- package/dist/client/assets/monitoring-Cp92YRPy.js +0 -1
- package/dist/client/assets/oauth-callback-1_PgXFG_.js +0 -1
- package/dist/client/assets/popover-MhzpcVkW.js +0 -1
- package/dist/client/assets/prism-light-C-ukkBST.js +0 -1
- package/dist/client/assets/resource-tabs-ru5yaRIE.js +0 -1
- package/dist/client/assets/select-Be0LRVWn.js +0 -1
- package/dist/client/assets/settings-gZFi_2QA.js +0 -1
- package/dist/client/assets/shell-layout-adVEIdhn.js +0 -17
- package/dist/client/assets/spinner-oZ2DO2-U.js +0 -1
- package/dist/client/assets/store-DzO4PTg0.js +0 -1
- package/dist/client/assets/store-app-detail-BIXt1EdE.js +0 -1
- package/dist/client/assets/switch-DsCvClV8.js +0 -1
- package/dist/client/assets/tooltip-BjhP6ibY.js +0 -1
- package/dist/client/assets/use-connection-BX5-4xHw.js +0 -2
- package/dist/client/assets/useQuery-ojqdZMTH.js +0 -1
- package/dist/client/assets/utils-DgLfrg3u.js +0 -1
- package/dist/client/assets/view-mode-toggle-DAXMt6ZW.js +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import{aw as It,r as N,c as P,d as jn,j as p,f as Us,av as Yi,x as ip,y as ru,v as lp,w as jo,i as ap,b as cp,t as up,F as Q,Q as dp,ax as Ro,ay as su,al as fp,ak as hp,az as pp,H as Xi,a5 as ou,a8 as mp,B as Rn,E as Ve,a2 as Qi,a9 as gp,z as Ks,a6 as yp,a1 as Zi,af as xp,ag as bp,ah as kp,aA as el,aB as vp,a7 as iu,a4 as wp,aC as Sp,L as Cp,aD as Np,aE as Ep}from"./index-Ce0bVa0I.js";import{U as dt,f as tl,d as Js,c as jt,b as nl,I as Gs,u as Tp,n as Mp}from"./use-connection-CcfriG4b.js";import{d as Op,C as dn,e as Ap,I as Ip,l as ca,G as lu,M as jp,m as Rp,R as ua,k as Dp}from"./resizable-0evkHPjb.js";import{E as kr,i as Pp}from"./SearchMd-C_x78fQD.js";import{E as lr}from"./error-boundary-IlI5HY5C.js";import{P as Ys}from"./formatDistanceToNow-BgvVIEk6.js";import{u as Lp,L as $p}from"./localstorage-keys-C2n4sqaz.js";import{u as _p,a as We,c as qe,b as Ue,T as Ke,i as rl}from"./tooltip-B77piVwL.js";import{B as ce,c as X}from"./button-RGWd1X_P.js";import{F as lt,a as au,b as Rt,c as vr,d as Dn}from"./form-C0miQmjx.js";import{I as Pn}from"./input-Cc7Y8Lsj.js";import{T as Qr,D as zp,a as Bp,b as Fp,f as Vp,c as Hp,d as Wp}from"./dialog-xbeC24qR.js";import{A as qp,D as Up,u as Kp}from"./use-binding-DOHpn0td.js";import{i as Gt}from"./Loading01-CZ--C9o4.js";import{s as sl}from"./Plus-B87V-eUk.js";import{i as Jp}from"./Upload01-BkY8x2qR.js";import{b as Cn,a as ol,V as Xs}from"./layout-k5sx-zLk.js";import{i as Gp}from"./AlertCircle-cYjr_0xB.js";import{s as Yp}from"./Clock-D4OCvk0s.js";import{a as Xp}from"./Copy01-DmZIDbuC.js";import{i as il,J as Qp}from"./json-syntax-highlighter-Bc0wDiKJ.js";import{s as ll,i as cu}from"./XClose-CPlecLXh.js";import{u as Zp,O as em,M as tm,F as nm,v as rm,E as sm}from"./index-RUqw7d0T.js";import{u as al}from"./use-mcp-B7yS6xB_.js";import{S as Ln}from"./spinner-B6Gpa1lS.js";import{V as om}from"./view-mode-toggle-BGpxvqYI.js";import{i as im}from"./GitBranch01-DGYWk3k6.js";import{a as uu,b as lm}from"./use-tool-call-CI1nZAFC.js";import"./index-KVbZU2bI.js";import{n as am}from"./Calendar-cB-o1wit.js";import{b as cm,D as um,a as dm,d as da,i as fm}from"./dropdown-menu-Dz-Cfe4c.js";import{B as fn}from"./badge-CzGd9Js-.js";import{i as du}from"./X-BI6-CrX0.js";import"./CpuChip02-CvUOZekE.js";import"./select-B-74Vw7Q.js";import"./ChevronDown-7kPeUreU.js";import"./use-mobile-DYo2aQNt.js";import"./use-gateway-CCphplYZ.js";import"./Terminal-Bp8rdp_p.js";import"./connection-card-B2ZNmA6T.js";import"./card-Bch45nKF.js";import"./LinkExternal01-BrZUQjLP.js";import"./File06-B9Csx588.js";import"./InfoCircle-DXZ2AFmC.js";import"./use-organization-settings-uQsDNKHC.js";import"./useQuery-CF3kr9sY.js";import"./auth-O7mzDtBv.js";import"./ArrowLeft-CBi8stO3.js";import"./mcp-oauth-BrdcIayH.js";import"./env-vars-editor-B-ADXMkg.js";import"./Trash01-kv9nDzIp.js";import"./Key01-BemiGYAL.js";import"./extract-connection-data-3bWrIOWG.js";import"./registry-utils-ulDDT0d8.js";import"./generate-id-Dyweu44Y.js";import"./index-CbrmpR2c.js";const fu=It("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 hu=It("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 hm=It("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const pm=It("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 pu=It("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 mu=It("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 gu=It("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 yu=It("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"}]]),cl=({size:n=24,color:e="currentColor",...t})=>N.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},N.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"}));cl.displayName="AlertOctagon";const xu=({size:n=24,color:e="currentColor",...t})=>N.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},N.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"}));xu.displayName="Box";const bu=({size:n=24,color:e="currentColor",...t})=>N.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},N.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));bu.displayName="ClockFastForward";const ku=({size:n=24,color:e="currentColor",...t})=>N.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},N.createElement("path",{d:"m16 18 6-6-6-6M8 6l-6 6 6 6"}));ku.displayName="Code01";const vu=({size:n=24,color:e="currentColor",...t})=>N.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},N.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));vu.displayName="Code02";const wu=({size:n=24,color:e="currentColor",...t})=>N.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},N.createElement("path",{d:"M12 17a5 5 0 1 0 10 0 5 5 0 0 0-10 0Zm0 0c0-1.126.372-2.165 1-3V5m-1 12c0 .825.2 1.604.554 2.29-.842.712-2.788 1.21-5.054 1.21-3.038 0-5.5-.895-5.5-2V5m11 0c0 1.105-2.462 2-5.5 2S2 6.105 2 5m11 0c0-1.105-2.462-2-5.5-2S2 3.895 2 5m0 9c0 1.105 2.462 2 5.5 2 2.189 0 4.08-.465 4.965-1.138M13 9.5c0 1.105-2.462 2-5.5 2S2 10.605 2 9.5"}));wu.displayName="CoinsStacked01";const qr=({size:n=24,color:e="currentColor",...t})=>N.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},N.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"}));qr.displayName="Columns01";const Su=({size:n=24,color:e="currentColor",...t})=>N.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},N.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"}));Su.displayName="CornerDownRight";const Cu=({size:n=24,color:e="currentColor",...t})=>N.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},N.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"}));Cu.displayName="Database01";const Nu=({size:n=24,color:e="currentColor",...t})=>N.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},N.createElement("path",{d:"M11 4H6.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C2 6.28 2 7.12 2 8.8v8.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C4.28 22 5.12 22 6.8 22h8.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C20 19.72 20 18.88 20 17.2V13M8 16h1.675c.489 0 .733 0 .963-.055.204-.05.4-.13.579-.24.201-.123.374-.296.72-.642L21.5 5.5a2.121 2.121 0 0 0-3-3l-9.563 9.563c-.346.346-.519.519-.642.72a2 2 0 0 0-.24.579c-.055.23-.055.474-.055.963V16Z"}));Nu.displayName="Edit05";const Qs=({size:n=24,color:e="currentColor",...t})=>N.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},N.createElement("path",{d:"M3 9h13.5a4.5 4.5 0 1 1 0 9H12M3 9l4-4M3 9l4 4"}));Qs.displayName="FlipBackward";const Eu=({size:n=24,color:e="currentColor",...t})=>N.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},N.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"}));Eu.displayName="Repeat03";const Zs=({size:n=24,color:e="currentColor",...t})=>N.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},N.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"}));Zs.displayName="Save02";const Tu=({size:n=24,color:e="currentColor",...t})=>N.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},N.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"}));Tu.displayName="Tool01";const eo=({size:n=24,color:e="currentColor",...t})=>N.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},N.createElement("path",{d:"M16 3.468a4.5 4.5 0 0 1 0 8.064m2 5.234c1.512.684 2.872 1.799 4 3.234M2 20c1.946-2.477 4.59-4 7.5-4s5.553 1.523 7.5 4M14 7.5a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Z"}));eo.displayName="Users02";const{getOwnPropertyNames:mm,getOwnPropertySymbols:gm}=Object,{hasOwnProperty:ym}=Object.prototype;function Do(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function Ar(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 xm(n){return n?.[Symbol.toStringTag]}function fa(n){return mm(n).concat(gm(n))}const bm=Object.hasOwn||((n,e)=>ym.call(n,e));function tn(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const km="__v",vm="__o",wm="_owner",{getOwnPropertyDescriptor:ha,keys:pa}=Object;function Sm(n,e){return n.byteLength===e.byteLength&&Zr(new Uint8Array(n),new Uint8Array(e))}function Cm(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 Nm(n,e){return n.byteLength===e.byteLength&&Zr(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Em(n,e){return tn(n.getTime(),e.getTime())}function Tm(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Mm(n,e){return n===e}function ma(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 u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,d,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const Om=tn;function Am(n,e,t){const r=pa(n);let s=r.length;if(pa(e).length!==s)return!1;for(;s-- >0;)if(!Mu(n,e,t,r[s]))return!1;return!0}function Vn(n,e,t){const r=fa(n);let s=r.length;if(fa(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!Mu(n,e,t,o)||(i=ha(n,o),l=ha(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function Im(n,e){return tn(n.valueOf(),e.valueOf())}function jm(n,e){return n.source===e.source&&n.flags===e.flags}function ga(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,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function Zr(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 Rm(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 Mu(n,e,t,r){return(r===wm||r===vm||r===km)&&(n.$$typeof||e.$$typeof)?!0:bm(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Dm="[object ArrayBuffer]",Pm="[object Arguments]",Lm="[object Boolean]",$m="[object DataView]",_m="[object Date]",zm="[object Error]",Bm="[object Map]",Fm="[object Number]",Vm="[object Object]",Hm="[object RegExp]",Wm="[object Set]",qm="[object String]",Um={"[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},Km="[object URL]",Jm=Object.prototype.toString;function Gm({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:m}){return function(y,x,b){if(y===x)return!0;if(y==null||x==null)return!1;const v=typeof y;if(v!==typeof x)return!1;if(v!=="object")return v==="number"?l(y,x,b):v==="function"?o(y,x,b):!1;const C=y.constructor;if(C!==x.constructor)return!1;if(C===Object)return a(y,x,b);if(Array.isArray(y))return e(y,x,b);if(C===Date)return r(y,x,b);if(C===RegExp)return u(y,x,b);if(C===Map)return i(y,x,b);if(C===Set)return d(y,x,b);const k=Jm.call(y);if(k===_m)return r(y,x,b);if(k===Hm)return u(y,x,b);if(k===Bm)return i(y,x,b);if(k===Wm)return d(y,x,b);if(k===Vm)return typeof y.then!="function"&&typeof x.then!="function"&&a(y,x,b);if(k===Km)return h(y,x,b);if(k===zm)return s(y,x,b);if(k===Pm)return a(y,x,b);if(Um[k])return f(y,x,b);if(k===Dm)return n(y,x,b);if(k===$m)return t(y,x,b);if(k===Lm||k===Fm||k===qm)return c(y,x,b);if(m){let w=m[k];if(!w){const S=xm(y);S&&(w=m[S])}if(w)return w(y,x,b)}return!1}}function Ym({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:Sm,areArraysEqual:t?Vn:Cm,areDataViewsEqual:Nm,areDatesEqual:Em,areErrorsEqual:Tm,areFunctionsEqual:Mm,areMapsEqual:t?Do(ma,Vn):ma,areNumbersEqual:Om,areObjectsEqual:t?Vn:Am,arePrimitiveWrappersEqual:Im,areRegExpsEqual:jm,areSetsEqual:t?Do(ga,Vn):ga,areTypedArraysEqual:t?Do(Zr,Vn):Zr,areUrlsEqual:Rm,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=Ar(r.areArraysEqual),o=Ar(r.areMapsEqual),i=Ar(r.areObjectsEqual),l=Ar(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function Xm(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function Qm({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:u}=t();return e(l,a,{cache:c,equals:r,meta:u,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 Zm=Dt();Dt({strict:!0});Dt({circular:!0});Dt({circular:!0,strict:!0});Dt({createInternalComparator:()=>tn});Dt({strict:!0,createInternalComparator:()=>tn});Dt({circular:!0,createInternalComparator:()=>tn});Dt({circular:!0,createInternalComparator:()=>tn,strict:!0});function Dt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=Ym(n),i=Gm(o),l=t?t(i):Xm(i);return Qm({circular:e,comparator:i,createState:r,equals:l,strict:s})}function eg(n){const e=P.c(3),{gatewayId:t,onSelect:r}=n,{data:s}=Ap(t);if(s.length===0)return null;let o;return e[0]!==r||e[1]!==s?(o=p.jsx(Ip,{prompts:s,onSelect:r,className:"mt-6"}),e[0]=r,e[1]=s,e[2]=o):o=e[2],o}function tg(n){const e=P.c(20),{form:t}=n;let r;e[0]!==t?(r=d=>{const{field:f}=d;return p.jsx(cg,{size:"md",value:f.value,onChange:f.onChange,alt:t.watch("title")})},e[0]=t,e[1]=r):r=e[1];let s;e[2]!==t.control||e[3]!==r?(s=p.jsx(lt,{control:t.control,name:"avatar",render:r}),e[2]=t.control,e[3]=r,e[4]=s):s=e[4];let o;e[5]!==t.control?(o=p.jsxs("div",{className:"flex flex-col gap-3 flex-1 min-w-0",children:[p.jsx(lt,{control:t.control,name:"title",render:ig}),p.jsx(lt,{control:t.control,name:"description",render:og})]}),e[5]=t.control,e[6]=o):o=e[6];let i;e[7]!==s||e[8]!==o?(i=p.jsxs("div",{className:"flex gap-4 items-start",children:[s,o]}),e[7]=s,e[8]=o,e[9]=i):i=e[9];let l,a;e[10]!==t.control?(l=p.jsxs("div",{className:"flex gap-4",children:[p.jsx(lt,{control:t.control,name:"gateway_id",render:sg}),p.jsx(lt,{control:t.control,name:"model",render:rg})]}),a=p.jsx(lt,{control:t.control,name:"system_prompt",render:ng}),e[10]=t.control,e[11]=l,e[12]=a):(l=e[11],a=e[12]);let c;e[13]!==i||e[14]!==l||e[15]!==a?(c=p.jsxs("div",{className:"h-full py-6 flex flex-col max-w-2xl mx-auto w-full min-w-0 gap-6 overflow-y-auto",children:[i,l,a]}),e[13]=i,e[14]=l,e[15]=a,e[16]=c):c=e[16];let u;return e[17]!==t||e[18]!==c?(u=p.jsx(au,{...t,children:c}),e[17]=t,e[18]=c,e[19]=u):u=e[19],u}function ng(n){const{field:e}=n;return p.jsxs(Rt,{className:"flex-1 flex flex-col min-h-0",children:[p.jsx(vr,{className:"text-xs text-muted-foreground",children:"System prompt"}),p.jsx(Dn,{children:p.jsx(Qr,{...e,placeholder:"You are a helpful assistant...",className:"flex-1 min-h-[200px] 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 rg(n){const{field:e}=n;return p.jsxs(Rt,{className:"flex-1",children:[p.jsx(vr,{className:"text-xs text-muted-foreground",children:"Model"}),p.jsx(jp,{selectedModel:e.value?{id:e.value.id,connectionId:e.value.connectionId}:void 0,onModelChange:t=>e.onChange({id:t.id,connectionId:t.connectionId}),placeholder:"Select model",variant:"bordered",className:"w-full"})]})}function sg(n){const{field:e}=n;return p.jsxs(Rt,{className:"flex-1",children:[p.jsx(vr,{className:"text-xs text-muted-foreground",children:"Gateway"}),p.jsx(lu,{selectedGatewayId:e.value,onGatewayChange:e.onChange,placeholder:"Select gateway",variant:"bordered",className:"w-full"})]})}function og(n){const{field:e}=n;return p.jsxs(Rt,{children:[p.jsx(vr,{className:"text-xs text-muted-foreground",children:"Description"}),p.jsx(Dn,{children:p.jsx(Pn,{...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 ig(n){const{field:e}=n;return p.jsxs(Rt,{children:[p.jsx(vr,{className:"text-xs text-muted-foreground",children:"Name"}),p.jsx(Dn,{children:p.jsx(Pn,{...e,placeholder:"Untitled assistant",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function lg(n){const e=P.c(62),{activeThreadId:t,mode:r,assistant:s,form:o}=n;let i;e[0]!==t||e[1]!==s.system_prompt?(i={threadId:t,systemPrompt:s.system_prompt},e[0]=t,e[1]=s.system_prompt,e[2]=i):i=e[2];const l=Op(i),a=!!s.gateway_id&&!!s.model?.id&&!!s.model?.connectionId;let c;e[3]!==t||e[4]!==s.gateway_id||e[5]!==s.model||e[6]!==l||e[7]!==a?(c=async H=>{if(!a)return;const K={created_at:new Date().toISOString(),thread_id:t,model:{id:s.model.id,connectionId:s.model.connectionId},gateway:{id:s.gateway_id??""},user:{name:"you"}};await l.sendMessage(H,K)},e[3]=t,e[4]=s.gateway_id,e[5]=s.model,e[6]=l,e[7]=a,e[8]=c):c=e[8];const u=c;let d;e[9]!==s.avatar||e[10]!==s.title?(d=s.avatar?p.jsx("div",{className:"size-[60px] rounded-[18px] border border-border shrink-0 overflow-hidden",children:p.jsx("img",{src:s.avatar,alt:s.title,className:"h-full w-full object-cover"})}):p.jsx("div",{className:"size-[60px] rounded-[18px] border border-border shrink-0 overflow-hidden bg-muted/20 flex items-center justify-center",children:p.jsx(eo,{size:28,className:"text-muted-foreground"})}),e[9]=s.avatar,e[10]=s.title,e[11]=d):d=e[11];let f;e[12]!==s.title?(f=p.jsx("h3",{className:"text-xl font-medium text-foreground",children:s.title}),e[12]=s.title,e[13]=f):f=e[13];let h;e[14]!==s.description?(h=s.description?p.jsx("div",{className:"text-muted-foreground text-center text-sm max-w-md",children:s.description}):null,e[14]=s.description,e[15]=h):h=e[15];let m;e[16]!==d||e[17]!==f||e[18]!==h?(m=p.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d,f,h]}),e[16]=d,e[17]=f,e[18]=h,e[19]=m):m=e[19];let g;e[20]!==s.gateway_id||e[21]!==u?(g=s.gateway_id&&p.jsx(lr,{fallback:null,children:p.jsx(N.Suspense,{fallback:p.jsx("div",{className:"flex justify-center mt-6",children:p.jsx(Gt,{size:20,className:"animate-spin text-muted-foreground"})}),children:p.jsx(eg,{gatewayId:s.gateway_id,onSelect:H=>{u(H.description??H.name)}})})}),e[20]=s.gateway_id,e[21]=u,e[22]=g):g=e[22];let y;e[23]!==m||e[24]!==g?(y=p.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-4 text-center",children:[m,g]}),e[23]=m,e[24]=g,e[25]=y):y=e[25];const x=y;let b;e[26]!==l.messages?(b=l.messages.filter(ag),e[26]=l.messages,e[27]=b):b=e[27];const v=b,C=r==="edit",k=C?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none";let w;e[28]!==k?(w=X("absolute inset-0 px-2 transition-opacity duration-200 ease-out",k),e[28]=k,e[29]=w):w=e[29];let S;e[30]!==o?(S=p.jsx(tg,{form:o}),e[30]=o,e[31]=S):S=e[31];let M;e[32]!==w||e[33]!==S?(M=p.jsx("div",{className:w,children:S}),e[32]=w,e[33]=S,e[34]=M):M=e[34];const T=C?"opacity-0 pointer-events-none":"opacity-100";let E;e[35]!==T?(E=X("h-full transition-opacity duration-200 ease-out",T),e[35]=T,e[36]=E):E=e[36];let R;e[37]!==l.messages||e[38]!==l.status||e[39]!==x||e[40]!==v.length?(R=v.length===0?p.jsx(dn.EmptyState,{children:x}):p.jsx(dn.Messages,{messages:l.messages,status:l.status,minHeightOffset:240}),e[37]=l.messages,e[38]=l.status,e[39]=x,e[40]=v.length,e[41]=R):R=e[41];let D;e[42]!==E||e[43]!==R?(D=p.jsx("div",{className:E,children:R}),e[42]=E,e[43]=R,e[44]=D):D=e[44];let B;e[45]!==M||e[46]!==D?(B=p.jsxs(dn.Main,{className:"h-full relative overflow-hidden",children:[M,D]}),e[45]=M,e[46]=D,e[47]=B):B=e[47];const _=C?"translate-y-full":"translate-y-0";let O;e[48]!==_?(O=X("transition-transform duration-300 ease-out",_),e[48]=_,e[49]=O):O=e[49];const A=!a,L=l.status==="submitted"||l.status==="streaming";let z;e[50]!==l.messages||e[51]!==l.stop||e[52]!==u||e[53]!==A||e[54]!==L?(z=p.jsx(dn.Footer,{children:p.jsx("div",{className:"max-w-2xl mx-auto w-full min-w-0",children:p.jsx(dn.Input,{onSubmit:u,onStop:l.stop,disabled:A,isStreaming:L,placeholder:"Ask anything or @ for context",usageMessages:l.messages})})}),e[50]=l.messages,e[51]=l.stop,e[52]=u,e[53]=A,e[54]=L,e[55]=z):z=e[55];let U;e[56]!==O||e[57]!==z?(U=p.jsx("div",{className:O,children:z}),e[56]=O,e[57]=z,e[58]=U):U=e[58];let W;return e[59]!==B||e[60]!==U?(W=p.jsxs(dn,{children:[B,U]}),e[59]=B,e[60]=U,e[61]=W):W=e[61],W}function ag(n){return n.role!=="system"}function cg(n){const e=P.c(18),{value:t,onChange:r,alt:s,size:o}=n,i=o===void 0?"md":o,l=N.useRef(null),a=i==="xs"?"h-6 w-6":i==="sm"?"h-8 w-8":"h-16 w-16",c=i==="xs"?"h-3 w-3":i==="sm"?"h-4 w-4":"h-6 w-6",u=i==="xs"?"h-3 w-3":i==="sm"?"h-3.5 w-3.5":"h-5 w-5";let d;e[0]!==r?(d=w=>{const S=w.target.files?.[0];if(!S)return;const M=new FileReader;M.onloadend=()=>{const T=M.result;r(T)},M.readAsDataURL(S)},e[0]=r,e[1]=d):d=e[1];const f=d;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{l.current?.click()},e[2]=h):h=e[2];const m=h,g=`relative ${a} shrink-0 cursor-pointer group`;let y;e[3]!==f?(y=p.jsx("input",{type:"file",ref:l,className:"hidden",accept:"image/*",onChange:f}),e[3]=f,e[4]=y):y=e[4];let x;e[5]!==s||e[6]!==c||e[7]!==t?(x=t?p.jsx("img",{src:t,alt:s||"Avatar",className:"w-full h-full object-cover"}):p.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:p.jsx(eo,{className:c})}),e[5]=s,e[6]=c,e[7]=t,e[8]=x):x=e[8];const b=`${u} text-white`;let v;e[9]!==b?(v=p.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center rounded-xl",children:p.jsx(Jp,{className:b})}),e[9]=b,e[10]=v):v=e[10];let C;e[11]!==x||e[12]!==v?(C=p.jsxs("div",{className:"h-full w-full rounded-xl border border-border bg-muted/20 overflow-hidden relative",children:[x,v]}),e[11]=x,e[12]=v,e[13]=C):C=e[13];let k;return e[14]!==g||e[15]!==y||e[16]!==C?(k=p.jsxs("div",{className:g,onClick:m,children:[y,C]}),e[14]=g,e[15]=y,e[16]=C,e[17]=k):k=e[17],k}function ug(n){const e=P.c(56),{providerId:t,assistantId:r,onBack:s}=n,i=Us().location.href,l=Yi();let a;e[0]!==s||e[1]!==l?(a=s??(()=>l.history.back()),e[0]=s,e[1]=l,e[2]=a):a=e[2];const c=a,{locator:u}=_p();let d;e[3]!==r||e[4]!==u?(d=$p.assistantChatActiveThread(u,r),e[3]=r,e[4]=u,e[5]=d):d=e[5];const[f,h]=Lp(d,dg),m=t||dt;let g;e[6]!==m?(g=jt(m),e[6]=m,e[7]=g):g=e[7];const y=g,x=tl(t,"ASSISTANT",r,y),b=Js(t,"ASSISTANT",y),v=b.update.isPending,[C,k]=N.useState(x?.model.id&&x?.gateway_id?"chat":"edit");let w;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=ip(qp),e[8]=w):w=e[8];const S=x??void 0;let M;e[9]!==S?(M={resolver:w,values:S},e[9]=S,e[10]=M):M=e[10];const T=ru(M);let E;e[11]!==b.update||e[12]!==r||e[13]!==T?(E=T.handleSubmit(async Y=>{const te=await b.update.mutateAsync({id:r,data:Y});T.reset(te),k("chat")}),e[11]=b.update,e[12]=r,e[13]=T,e[14]=E):E=e[14];const R=E;if(!x){let Y;e[15]===Symbol.for("react.memo_cache_sentinel")?(Y=p.jsx(ca,{}),e[15]=Y):Y=e[15];let te;e[16]===Symbol.for("react.memo_cache_sentinel")?(te=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(kr,{title:"Assistant not found",description:"This assistant may have been deleted or you may not have access to it."})}),e[16]=te):te=e[16];let fe;return e[17]!==c?(fe=p.jsx(lr,{children:p.jsx(N.Suspense,{fallback:Y,children:p.jsx(Cn,{onBack:c,children:te})})}),e[17]=c,e[18]=fe):fe=e[18],fe}let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx(ca,{}),e[19]=D):D=e[19];let B;e[20]!==x.avatar||e[21]!==x.title?(B=p.jsx("div",{className:"h-6 w-6 min-w-6 rounded-lg border border-border bg-muted/20 overflow-hidden shrink-0",children:x.avatar?p.jsx("img",{src:x.avatar,alt:x.title,className:"h-full w-full object-cover"}):p.jsx("div",{className:"h-full w-full flex items-center justify-center text-muted-foreground",children:p.jsx(eo,{size:12,className:"text-muted-foreground"})})}),e[20]=x.avatar,e[21]=x.title,e[22]=B):B=e[22];let _;e[23]!==x.title?(_=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:x.title}),e[23]=x.title,e[24]=_):_=e[24];let O;e[25]!==x.description?(O=x.description?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),p.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:x.description})]}):null,e[25]=x.description,e[26]=O):O=e[26];let A;e[27]!==_||e[28]!==O?(A=p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[_,O]}),e[27]=_,e[28]=O,e[29]=A):A=e[29];let L;e[30]!==B||e[31]!==A?(L=p.jsx(ol,{children:p.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[B,A]})}),e[30]=B,e[31]=A,e[32]=L):L=e[32];const z=x.avatar??"assistant";let U;e[33]!==x.title||e[34]!==z||e[35]!==i?(U=p.jsx(Ys,{title:x.title,url:i,icon:z}),e[33]=x.title,e[34]=z,e[35]=i,e[36]=U):U=e[36];let W;e[37]!==T.formState.isDirty||e[38]!==v||e[39]!==C||e[40]!==R||e[41]!==h?(W=C==="chat"?p.jsxs(p.Fragment,{children:[p.jsx(We,{children:p.jsxs(qe,{children:[p.jsx(Ue,{asChild:!0,children:p.jsx(ce,{type:"button",onClick:()=>h(crypto.randomUUID()),"aria-label":"New thread",variant:"outline",size:"icon",className:"size-7 border border-input",children:p.jsx(sl,{size:16})})}),p.jsx(Ke,{children:"New thread"})]})}),p.jsx(We,{children:p.jsxs(qe,{children:[p.jsx(Ue,{asChild:!0,children:p.jsx(ce,{type:"button",onClick:()=>k("edit"),"aria-label":"Edit",variant:"outline",size:"icon",className:"size-7 border border-input",children:p.jsx(Nu,{size:16})})}),p.jsx(Ke,{children:"Edit"})]})})]}):p.jsxs(p.Fragment,{children:[p.jsx(We,{children:p.jsxs(qe,{delayDuration:0,children:[p.jsx(Ue,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ce,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:v,onClick:()=>k("chat"),"aria-label":"Cancel",children:p.jsx(Qs,{size:14})})})}),p.jsx(Ke,{side:"bottom",children:"Cancel"})]})}),p.jsx(We,{children:p.jsxs(qe,{delayDuration:0,children:[p.jsx(Ue,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ce,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:!T.formState.isDirty||v,onClick:()=>{R()},"aria-label":"Save",children:v?p.jsx(Gt,{size:14,className:"animate-spin"}):p.jsx(Zs,{size:14})})})}),p.jsx(Ke,{side:"bottom",children:"Save"})]})})]}),e[37]=T.formState.isDirty,e[38]=v,e[39]=C,e[40]=R,e[41]=h,e[42]=W):W=e[42];let H;e[43]!==U||e[44]!==W?(H=p.jsxs(Xs,{children:[U,W]}),e[43]=U,e[44]=W,e[45]=H):H=e[45];let K;e[46]!==f||e[47]!==x||e[48]!==T||e[49]!==C?(K=p.jsx("div",{className:"h-full",children:p.jsx(lg,{activeThreadId:f,mode:C,assistant:x,form:T},T.formState.submitCount)}),e[46]=f,e[47]=x,e[48]=T,e[49]=C,e[50]=K):K=e[50];let Z;return e[51]!==c||e[52]!==L||e[53]!==H||e[54]!==K?(Z=p.jsx(lr,{children:p.jsx(N.Suspense,{fallback:D,children:p.jsxs(Cn,{onBack:c,children:[L,H,K]})})}),e[51]=c,e[52]=L,e[53]=H,e[54]=K,e[55]=Z):Z=e[55],Z}function dg(n){return n||crypto.randomUUID()}function fg(n){const e=P.c(6),{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=jn(s).connectionId??dt;if(!i||i===dt){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(kr,{title:"Assistant not found",description:"Missing connection information in the current route."})}),e[1]=a):a=e[1],a}let l;return e[2]!==i||e[3]!==t||e[4]!==r?(l=p.jsx(ug,{providerId:i,assistantId:t,onBack:r}),e[2]=i,e[3]=t,e[4]=r,e[5]=l):l=e[5],l}lp({title:jo().min(1),description:jo().nullable(),body:jo()});function Po(n){for(const e of n.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function hg(){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 pg(n){const e=P.c(13),{form:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"text-sm font-medium text-foreground",children:"Details"}),e[0]=r):r=e[0];let s;e[1]!==t.control?(s=p.jsxs("div",{className:"flex flex-col gap-4",children:[r,p.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[p.jsx(lt,{control:t.control,name:"title",render:yg}),p.jsx(lt,{control:t.control,name:"description",render:gg})]})]}),e[1]=t.control,e[2]=s):s=e[2];let o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx("div",{className:"text-sm font-medium text-foreground",children:"Message"}),i=p.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=p.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,p.jsx(lt,{control:t.control,name:"body",render:mg})]}),e[5]=t.control,e[6]=l):l=e[6];let a;e[7]!==s||e[8]!==l?(a=p.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=p.jsx(au,{...t,children:a}),e[10]=t,e[11]=a,e[12]=c):c=e[12],c}function mg(n){const{field:e}=n;return p.jsx(Rt,{children:p.jsx(Dn,{children:p.jsx(Qr,{...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 gg(n){const{field:e}=n;return p.jsxs(Rt,{children:[p.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),p.jsx(Dn,{children:p.jsx(Pn,{...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 yg(n){const{field:e}=n;return p.jsxs(Rt,{children:[p.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),p.jsx(Dn,{children:p.jsx(Pn,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function xg(n){const e=P.c(51),{providerId:t,promptId:r,onBack:s}=n,i=Us().location.href,l=t||dt;let a;e[0]!==l?(a=jt(l),e[0]=l,e[1]=a):a=e[1];const c=a,u=tl(t,"PROMPT",r,c),d=Js(t,"PROMPT",c),f=d.update.isPending;let h;e[2]!==u?(h=u?{title:u.title,description:u.description??null,body:Po(u)}:void 0,e[2]=u,e[3]=h):h=e[3];let m;e[4]!==h?(m={values:h},e[4]=h,e[5]=m):m=e[5];const g=ru(m);let y;e[6]!==g||e[7]!==u?(y=()=>{u&&g.reset({title:u.title,description:u.description??null,body:Po(u)})},e[6]=g,e[7]=u,e[8]=y):y=e[8];const x=y;let b;e[9]!==d.update||e[10]!==g||e[11]!==r?(b=g.handleSubmit(async K=>{const Z=await d.update.mutateAsync({id:r,data:{title:K.title,description:K.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:K.body}}]}});g.reset({title:Z.title,description:Z.description??null,body:Po(Z)})}),e[9]=d.update,e[10]=g,e[11]=r,e[12]=b):b=e[12];const v=b;if(!u){let K;return e[13]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(kr,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=K):K=e[13],K}let C;e[14]!==u.title?(C=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:u.title}),e[14]=u.title,e[15]=C):C=e[15];let k;e[16]!==u.description?(k=u.description?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),p.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:u.description})]}):null,e[16]=u.description,e[17]=k):k=e[17];let w;e[18]!==C||e[19]!==k?(w=p.jsx(ol,{children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[C,k]})}),e[18]=C,e[19]=k,e[20]=w):w=e[20];let S;e[21]!==u.title||e[22]!==i?(S=p.jsx(Ys,{title:u.title,url:i,icon:"description"}),e[21]=u.title,e[22]=i,e[23]=S):S=e[23];const M=!g.formState.isDirty||f;let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(Qs,{size:14}),e[24]=T):T=e[24];let E;e[25]!==x||e[26]!==M?(E=p.jsx(Ue,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ce,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:M,onClick:x,"aria-label":"Cancel",children:T})})}),e[25]=x,e[26]=M,e[27]=E):E=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx(Ke,{side:"bottom",children:"Cancel"}),e[28]=R):R=e[28];let D;e[29]!==E?(D=p.jsx(We,{children:p.jsxs(qe,{delayDuration:0,children:[E,R]})}),e[29]=E,e[30]=D):D=e[30];const B=!g.formState.isDirty||f;let _;e[31]!==v?(_=()=>{v()},e[31]=v,e[32]=_):_=e[32];let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=p.jsx(Zs,{size:14}),e[33]=O):O=e[33];let A;e[34]!==B||e[35]!==_?(A=p.jsx(Ue,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ce,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:B,onClick:_,"aria-label":"Save",children:O})})}),e[34]=B,e[35]=_,e[36]=A):A=e[36];let L;e[37]===Symbol.for("react.memo_cache_sentinel")?(L=p.jsx(Ke,{side:"bottom",children:"Save"}),e[37]=L):L=e[37];let z;e[38]!==A?(z=p.jsx(We,{children:p.jsxs(qe,{delayDuration:0,children:[A,L]})}),e[38]=A,e[39]=z):z=e[39];let U;e[40]!==S||e[41]!==D||e[42]!==z?(U=p.jsxs(Xs,{children:[S,D,z]}),e[40]=S,e[41]=D,e[42]=z,e[43]=U):U=e[43];let W;e[44]!==g?(W=p.jsx("div",{className:"h-full",children:p.jsx(pg,{form:g})}),e[44]=g,e[45]=W):W=e[45];let H;return e[46]!==s||e[47]!==U||e[48]!==W||e[49]!==w?(H=p.jsxs(Cn,{onBack:s,children:[w,U,W]}),e[46]=s,e[47]=U,e[48]=W,e[49]=w,e[50]=H):H=e[50],H}function bg(n){const e=P.c(5),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=hg()??dt,e[0]=s):s=e[0];const o=s;if(!o||o===dt){let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(kr,{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=p.jsx(lr,{children:p.jsx(N.Suspense,{fallback:null,children:p.jsx(xg,{providerId:o,promptId:t,onBack:r})})}),e[2]=t,e[3]=r,e[4]=i):i=e[4],i}const kg=ap("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 vg(n){const e=P.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=X(kg({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=p.jsx("div",{"data-slot":"alert",role:"alert",className:o,...r}),e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function wg(n){const e=P.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=X("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=p.jsx("div",{"data-slot":"alert-title",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function Sg(n){const e=P.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=X("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=p.jsx("div",{"data-slot":"alert-description",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}const Cg=n=>n.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function Ng(n){const e=P.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=Zp(a);if(!c.isAuthenticated){let f;return e[4]!==c.supportsOAuth||e[5]!==s?(f=p.jsx("div",{className:"flex h-full items-center justify-center",children:c.supportsOAuth?p.jsx(em,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):p.jsx(tm,{hasReadme:!1})}),e[4]=c.supportsOAuth,e[5]=s,e[6]=f):f=e[6],f}const u=`${r}:${t}`;let d;return e[7]!==r||e[8]!==l||e[9]!==s||e[10]!==u||e[11]!==t?(d=p.jsx(Eg,{toolName:t,connectionId:r,mcpProxyUrl:l,onBack:s},u),e[7]=r,e[8]=l,e[9]=s,e[10]=u,e[11]=t,e[12]=d):d=e[12],d}function Eg({toolName:n,connectionId:e,mcpProxyUrl:t,onBack:r}){const o=Us().location.href,{replayId:i}=cp({strict:!1}),l=(()=>{if(!i)return null;const A=`replay-${i}`,L=sessionStorage.getItem(A);if(!L)return null;sessionStorage.removeItem(A);try{return JSON.parse(L)}catch{return null}})(),a=(()=>{if(!l)return null;const A={};for(const[L,z]of Object.entries(l))z!==null&&typeof z=="object"?A[L]=JSON.stringify(z,null,2):A[L]=z;return A})(),[c,u]=N.useState(a??{}),[d,f]=N.useState(l?JSON.stringify(l,null,2):"{}"),[h,m]=N.useState(null),[g,y]=N.useState(null),[x,b]=N.useState(!1),[v,C]=N.useState(null),k=nl(e),w=al({url:t.href});N.useEffect(()=>{w.error&&console.error("MCP Error:",w.error)},[w.error]);const S=w.tools?.find(A=>A.name===n),M=S?.inputSchema?.properties,T=M?Object.keys(M):[],E=T.length>0,R={};if(E&&S?.inputSchema?.properties)for(const A of T)R[A]=S.inputSchema.required?.includes(A)?"":void 0;const D=A=>Object.prototype.hasOwnProperty.call(c,A),B=async()=>{b(!0),y(null),m(null),C(null);const A=performance.now(),L=jt(e);try{const z=E?{...R,...c}:(()=>{const Y=d.trim();if(!Y)return{};const te=JSON.parse(Y);if(te&&typeof te=="object")return te;throw new Error("Raw JSON input must be an object.")})();E&&S?.inputSchema?.properties&&Object.entries(S.inputSchema.properties).forEach(([Y,te])=>{if((te.type==="object"||te.type==="array")&&typeof z[Y]=="string")try{z[Y]=JSON.parse(z[Y])}catch{}});const U=await L(n,z),W=performance.now(),H=Math.round(W-A);m(U);const K=JSON.stringify(U),Z=new TextEncoder().encode(K).length;C({duration:`${H}ms`,bytes:`${Z} bytes`,tokens:`~${Math.ceil(Z/4)} tokens`,cost:"$0.0000"})}catch(z){const U=z instanceof Error?z.message:String(z);y(U||"Unknown error occurred");const W=performance.now();C({duration:`${Math.round(W-A)}ms`})}finally{b(!1)}},_=(A,L)=>{u(z=>({...z,[A]:L}))},O=()=>{m(null),y(null),C(null)};return p.jsxs(Cn,{onBack:r,children:[p.jsx(Xs,{children:p.jsx(Ys,{title:S?.name??Cg(n),url:o,icon:"build"})}),p.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 h-full",children:[p.jsx("div",{className:"flex flex-col border-r border-border overflow-hidden",children:p.jsxs("div",{className:"flex-1 overflow-auto",children:[p.jsx("div",{className:"flex flex-col gap-4 p-6 border-b border-border min-h-28",children:p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Gs,{icon:k?.icon||null,name:k?.title||n,size:"sm",className:"shadow-sm shrink-0"}),p.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:n}),p.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[w.state==="ready"?p.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):w.state==="connecting"?p.jsx(Gt,{size:10,className:"animate-spin text-yellow-500 shrink-0"}):p.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}),p.jsx("span",{className:"font-mono text-xs capitalize text-muted-foreground leading-none",children:w.state.replace("_"," ")})]})]}),p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:S?.description||"No description available"})]})}),p.jsxs("div",{className:"flex flex-col p-6 gap-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h2",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"Parameters"}),S?.inputSchema?.required&&S.inputSchema.required.length>0&&p.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.jsx("span",{className:"text-red-500",children:"*"})," Required"]})]}),p.jsx("div",{className:"space-y-4",children:E&&S?.inputSchema?.properties?Object.entries(S.inputSchema.properties).map(([A,L])=>p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("label",{className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[A,S.inputSchema?.required?.includes(A)&&p.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),p.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:L.type})]}),L.description&&p.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:L.description}),L.type==="object"||L.type==="array"?p.jsx(Qr,{className:"font-mono text-xs",value:D(A)?c[A]??"":R[A]??"",onChange:z=>_(A,z.target.value),placeholder:`Enter ${A} as JSON...`,rows:3}):p.jsx(Pn,{value:D(A)?c[A]??"":R[A]??"",onChange:z=>_(A,z.target.value),placeholder:`Enter ${A}...`})]},A)):S?.inputSchema&&!E?p.jsxs("div",{className:"space-y-2",children:[p.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),p.jsx(Qr,{className:"font-mono text-xs min-h-[120px]",value:d,onChange:A=>f(A.target.value),placeholder:'e.g. { "foo": "bar" }'})]}):p.jsx("div",{className:"flex items-center justify-center p-8 bg-muted/30 rounded-lg border border-dashed border-border",children:p.jsx("p",{className:"text-sm text-muted-foreground",children:"No parameters required"})})})]})]})}),p.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p.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:[p.jsx("h2",{className:"text-sm font-medium text-foreground uppercase tracking-wide",children:"Result"}),v&&p.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(Yp,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:v.duration})]}),v.tokens&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(xu,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:v.tokens})]}),v.bytes&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(Cu,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:v.bytes})]}),v.cost&&p.jsx("div",{className:"flex items-center gap-1.5",children:p.jsx("span",{className:"font-mono text-foreground",children:v.cost})})]})]}),p.jsx("div",{className:"flex items-center justify-end lg:justify-between px-4 h-14 border-b border-border bg-background",children:p.jsxs("div",{className:"flex items-center gap-2 w-full lg:w-auto",children:[p.jsx(ce,{size:"sm",variant:"default",className:"h-8 gap-2 flex-1 lg:flex-none",onClick:B,disabled:x,children:x?p.jsxs(p.Fragment,{children:[p.jsx(Gt,{size:14,className:"animate-spin"}),"Executing..."]}):p.jsxs(p.Fragment,{children:[p.jsx(il,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),p.jsx(We,{children:p.jsxs(qe,{children:[p.jsx(Ue,{asChild:!0,children:p.jsx(ce,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:O,disabled:!h&&!g,children:p.jsx(ll,{size:14})})}),p.jsx(Ke,{children:p.jsx("p",{children:"Clear results"})})]})})]})}),g&&p.jsx("div",{className:"px-6 py-4 bg-background",children:p.jsx(vg,{variant:"destructive",children:p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Gp,{className:"h-4 w-4"}),p.jsx(wg,{className:"mb-0",children:"Execution Failed"})]}),p.jsx(Sg,{className:"text-xs text-destructive",children:g})]})})}),p.jsx("div",{className:"relative flex-1 overflow-auto bg-muted/50",children:h?p.jsxs(p.Fragment,{children:[p.jsx(Qp,{jsonString:JSON.stringify(h,null,2),padding:"1.5rem"}),p.jsx(ce,{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)),up.success("Copied to clipboard")},children:p.jsx(Xp,{className:"h-3.5 w-3.5"})})]}):p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground",children:[p.jsx(ku,{className:"h-12 w-12 mb-3 opacity-40"}),p.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function Tg(n){const e=P.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=jn(s).connectionId??dt;if(!nl(i)){let u;return e[1]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx("div",{className:"flex h-full items-center justify-center",children:p.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[p.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),p.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=u):u=e[1],u}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx("div",{className:"flex h-full items-center justify-center",children:p.jsx(Gt,{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=p.jsx(N.Suspense,{fallback:a,children:p.jsx(Ng,{toolName:t,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=t,e[6]=c):c=e[6],c}const ya=n=>{let e;const t=new Set,r=(c,u)=>{const d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){const f=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),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},ul=(n=>n?ya(n):ya),Mg=n=>n;function yi(n,e=Mg){const t=Q.useSyncExternalStore(n.subscribe,Q.useCallback(()=>e(n.getState()),[n,e]),Q.useCallback(()=>e(n.getInitialState()),[n,e]));return Q.useDebugValue(t),t}const Og=n=>{const e=ul(n),t=r=>yi(e,r);return Object.assign(t,e),t},Ag=(n=>Og);function Ou(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 xi=n=>e=>{try{const t=n(e);return t instanceof Promise?t:{then(r){return xi(r)(t)},catch(r){return this}}}catch(t){return{then(r){return this},catch(r){return xi(r)(t)}}}},Ig=(n,e)=>(t,r,s)=>{let o={storage:Ou(()=>localStorage),partialize:g=>g,version:0,merge:(g,y)=>({...y,...g}),...e},i=!1;const l=new Set,a=new Set;let c=o.storage;if(!c)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 c.setItem(o.name,{state:g,version:o.version})},d=s.setState;s.setState=(g,y)=>(d(g,y),u());const f=n((...g)=>(t(...g),u()),r,s);s.getInitialState=()=>f;let h;const m=()=>{var g,y;if(!c)return;i=!1,l.forEach(b=>{var v;return b((v=r())!=null?v:f)});const x=((y=o.onRehydrateStorage)==null?void 0:y.call(o,(g=r())!=null?g:f))||void 0;return xi(c.getItem.bind(c))(o.name).then(b=>{if(b)if(typeof b.version=="number"&&b.version!==o.version){if(o.migrate){const v=o.migrate(b.state,b.version);return v instanceof Promise?v.then(C=>[!0,C]):[!0,v]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,b.state];return[!1,void 0]}).then(b=>{var v;const[C,k]=b;if(h=o.merge(k,(v=r())!=null?v:f),t(h,!0),C)return u()}).then(()=>{x?.(h,void 0),h=r(),i=!0,a.forEach(b=>b(h))}).catch(b=>{x?.(void 0,b)})};return s.persist={setOptions:g=>{o={...o,...g},g.storage&&(c=g.storage)},clearStorage:()=>{c?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>m(),hasHydrated:()=>i,onHydrate:g=>(l.add(g),()=>{l.delete(g)}),onFinishHydration:g=>(a.add(g),()=>{a.delete(g)})},o.skipHydration||m(),h||f},Au=Ig,{useSyncExternalStoreWithSelector:jg}=dp,Rg=n=>n;function Dg(n,e=Rg,t){const r=jg(n.subscribe,n.getState,n.getInitialState,e,t);return Q.useDebugValue(r),r}const xa=n=>Symbol.iterator in n,ba=n=>"entries"in n,ka=(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},Pg=(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 Lg(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:xa(n)&&xa(e)?ba(n)&&ba(e)?ka(n,e):Pg(n,e):ka({entries:()=>Object.entries(n)},{entries:()=>Object.entries(e)})}function $g(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
|
+
${Object.entries(i).map(([c,u])=>{const d=l.has(c)?"":"?";return`${u.description?` /** ${u.description} */
|
|
3
|
+
`:""} ${c}${d}: ${t(u)};`}).join(`
|
|
4
|
+
`)}
|
|
5
|
+
}`}return`interface ${e} ${t(n)}`}function Lo(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 _g(n,e){const t=n.match(/interface\s+Input\s*\{/);if(!t||t.index===void 0)return`${e}
|
|
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 $o(n,e){switch(n){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...Up,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${n}`)}}const Iu=N.createContext(null),zg=n=>ul()(Au(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??$o(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:Lo(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.originalWorkflow})),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 d of r)i[d]=`@${d}`;const l={};for(const d of r){const f=o.steps.find(h=>h.name===d);f?.outputSchema&&(l[d]=f.outputSchema)}const a=Object.keys(l).length>0?{type:"object",properties:l,required:Object.keys(l)}:void 0;let c=$o("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const d=$g(a,"Input"),f=c.action,h=_g(f.code,d);c={...c,action:{...f,code:h}}}const u=Lo(c.name,o.steps);return{...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],workflow:{...o,steps:[...o.steps,{...c,name:u}]},currentStepName:u}}),addToolStep:()=>e(t=>{let r=$o("tool",Number((Math.random()*1e6).toFixed(0)));const s=Lo(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,originalWorkflow: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).slice(0,200)}`,storage:Ou(()=>localStorage),partialize:e=>({workflow:e.workflow,trackingExecutionId:e.trackingExecutionId,currentStepName:e.currentStepName,currentStepTab:e.currentStepTab,originalWorkflow:e.originalWorkflow,isAddingStep:e.isAddingStep,addingStepType:e.addingStepType,selectedParentSteps:e.selectedParentSteps,replacingToolInfo:e.replacingToolInfo,selectedGatewayId:e.selectedGatewayId})}));function Bg(n){const e=P.c(6),{children:t,workflow:r,trackingExecutionId:s}=n;let o;e[0]!==s||e[1]!==r?(o=()=>zg({originalWorkflow:r,workflow:r,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],replacingToolInfo:null,currentStepName:void 0,trackingExecutionId:s,currentStepTab:"input",selectedGatewayId:void 0}),e[0]=s,e[1]=r,e[2]=o):o=e[2];const[i]=N.useState(o);let l;return e[3]!==t||e[4]!==i?(l=p.jsx(Iu.Provider,{value:i,children:t}),e[3]=t,e[4]=i,e[5]=l):l=e[5],l}function $n(n,e){const t=N.useContext(Iu);if(!t)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return Dg(t,n,Lg)}function _n(){return $n(Fg)}function Fg(n){return n.workflow}function Ge(){return $n(Vg)}function Vg(n){return n.actions}function ju(){const n=wr();return $n(Hg)??n[0]?.name}function Hg(n){return n.currentStepName}function to(){const n=P.c(5),e=ju(),t=wr();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 wr(){return _n().steps}function Ru(){const n=P.c(4),e=_n(),t=$n(Wg);let r;n[0]!==e?(r=JSON.stringify(e),n[0]=e,n[1]=r):r=n[1];let s;return n[2]!==t?(s=JSON.stringify(t),n[2]=t,n[3]=s):s=n[3],r!==s}function Wg(n){return n.originalWorkflow}function Pt(){return $n(qg)}function qg(n){return n.trackingExecutionId}function zn(){return $n(Ug)}function Ug(n){return n.selectedGatewayId}function va(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t<e;t++)r[t]=n[t];return r}function Kg(n){if(Array.isArray(n))return n}function Jg(n,e,t){return(e=t1(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Gg(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,s,o,i,l=[],a=!0,c=!1;try{if(o=(t=t.call(n)).next,e!==0)for(;!(a=(r=o.call(t)).done)&&(l.push(r.value),l.length!==e);a=!0);}catch(u){c=!0,s=u}finally{try{if(!a&&t.return!=null&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw s}}return l}}function Yg(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wa(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,r)}return t}function Sa(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?wa(Object(t),!0).forEach(function(r){Jg(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):wa(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function Xg(n,e){if(n==null)return{};var t,r,s=Qg(n,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(s[t]=n[t])}return s}function Qg(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}function Zg(n,e){return Kg(n)||Gg(n,e)||n1(n,e)||Yg()}function e1(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function t1(n){var e=e1(n,"string");return typeof e=="symbol"?e:e+""}function n1(n,e){if(n){if(typeof n=="string")return va(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?va(n,e):void 0}}function r1(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Ca(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,r)}return t}function Na(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ca(Object(t),!0).forEach(function(r){r1(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ca(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function s1(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return function(r){return e.reduceRight(function(s,o){return o(s)},r)}}function qn(n){return function e(){for(var t=this,r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return s.length>=n.length?n.apply(this,s):function(){for(var i=arguments.length,l=new Array(i),a=0;a<i;a++)l[a]=arguments[a];return e.apply(t,[].concat(s,l))}}}function es(n){return{}.toString.call(n).includes("Object")}function o1(n){return!Object.keys(n).length}function ar(n){return typeof n=="function"}function i1(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function l1(n,e){return es(e)||Ct("changeType"),Object.keys(e).some(function(t){return!i1(n,t)})&&Ct("changeField"),e}function a1(n){ar(n)||Ct("selectorType")}function c1(n){ar(n)||es(n)||Ct("handlerType"),es(n)&&Object.values(n).some(function(e){return!ar(e)})&&Ct("handlersType")}function u1(n){n||Ct("initialIsRequired"),es(n)||Ct("initialType"),o1(n)&&Ct("initialContent")}function d1(n,e){throw new Error(n[e]||n.default)}var f1={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ct=qn(d1)(f1),Ir={changes:l1,selector:a1,handler:c1,initial:u1};function h1(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ir.initial(n),Ir.handler(e);var t={current:n},r=qn(g1)(t,e),s=qn(m1)(t),o=qn(Ir.changes)(n),i=qn(p1)(t);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Ir.selector(c),c(t.current)}function a(c){s1(r,s,o,i)(c)}return[l,a]}function p1(n,e){return ar(e)?e(n.current):e}function m1(n,e){return n.current=Na(Na({},n.current),e),e}function g1(n,e,t){return ar(e)?e(n.current):Object.keys(t).forEach(function(r){var s;return(s=e[r])===null||s===void 0?void 0:s.call(e,n.current[r])}),t}var y1={create:h1},x1={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function b1(n){return function e(){for(var t=this,r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return s.length>=n.length?n.apply(this,s):function(){for(var i=arguments.length,l=new Array(i),a=0;a<i;a++)l[a]=arguments[a];return e.apply(t,[].concat(s,l))}}}function k1(n){return{}.toString.call(n).includes("Object")}function v1(n){return n||Ea("configIsRequired"),k1(n)||Ea("configType"),n.urls?(w1(),{paths:{vs:n.urls.monacoBase}}):n}function w1(){console.warn(Du.deprecation)}function S1(n,e){throw new Error(n[e]||n.default)}var Du={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
9
|
+
You are using deprecated way of configuration.
|
|
10
|
+
|
|
11
|
+
Instead of using
|
|
12
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
13
|
+
use
|
|
14
|
+
monaco.config({ paths: { vs: '...' } })
|
|
15
|
+
|
|
16
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
17
|
+
`},Ea=b1(S1)(Du),C1={config:v1},N1=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(s){return t.reduceRight(function(o,i){return i(o)},s)}};function Pu(n,e){return Object.keys(e).forEach(function(t){e[t]instanceof Object&&n[t]&&Object.assign(e[t],Pu(n[t],e[t]))}),Sa(Sa({},n),e)}var E1={type:"cancelation",msg:"operation is manually canceled"};function _o(n){var e=!1,t=new Promise(function(r,s){n.then(function(o){return e?s(E1):r(o)}),n.catch(s)});return t.cancel=function(){return e=!0},t}var T1=["monaco"],M1=y1.create({config:x1,isInitialized:!1,resolve:null,reject:null,monaco:null}),Lu=Zg(M1,2),Sr=Lu[0],no=Lu[1];function O1(n){var e=C1.config(n),t=e.monaco,r=Xg(e,T1);no(function(s){return{config:Pu(s.config,r),monaco:t}})}function A1(){var n=Sr(function(e){var t=e.monaco,r=e.isInitialized,s=e.resolve;return{monaco:t,isInitialized:r,resolve:s}});if(!n.isInitialized){if(no({isInitialized:!0}),n.monaco)return n.resolve(n.monaco),_o(zo);if(window.monaco&&window.monaco.editor)return $u(window.monaco),n.resolve(window.monaco),_o(zo);N1(I1,R1)(D1)}return _o(zo)}function I1(n){return document.body.appendChild(n)}function j1(n){var e=document.createElement("script");return n&&(e.src=n),e}function R1(n){var e=Sr(function(r){var s=r.config,o=r.reject;return{config:s,reject:o}}),t=j1("".concat(e.config.paths.vs,"/loader.js"));return t.onload=function(){return n()},t.onerror=e.reject,t}function D1(){var n=Sr(function(t){var r=t.config,s=t.resolve,o=t.reject;return{config:r,resolve:s,reject:o}}),e=window.require;e.config(n.config),e(["vs/editor/editor.main"],function(t){var r=t.m||t;$u(r),n.resolve(r)},function(t){n.reject(t)})}function $u(n){Sr().monaco||no({monaco:n})}function P1(){return Sr(function(n){var e=n.monaco;return e})}var zo=new Promise(function(n,e){return no({resolve:n,reject:e})}),ro={config:O1,init:A1,__getMonacoInstance:P1},L1={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Bo=L1,$1={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},_1=$1;function z1({children:n}){return Q.createElement("div",{style:_1.container},n)}var B1=z1,F1=B1;function V1({width:n,height:e,isEditorReady:t,loading:r,_ref:s,className:o,wrapperProps:i}){return Q.createElement("section",{style:{...Bo.wrapper,width:n,height:e},...i},!t&&Q.createElement(F1,null,r),Q.createElement("div",{ref:s,style:{...Bo.fullWidth,...!t&&Bo.hide},className:o}))}var H1=V1,_u=N.memo(H1);function W1(n){N.useEffect(n,[])}var zu=W1;function q1(n,e,t=!0){let r=N.useRef(!0);N.useEffect(r.current||!t?()=>{r.current=!1}:n,e)}var Ie=q1;function Yn(){}function bn(n,e,t,r){return U1(n,r)||K1(n,e,t,r)}function U1(n,e){return n.editor.getModel(Bu(n,e))}function K1(n,e,t,r){return n.editor.createModel(e,t,r?Bu(n,r):void 0)}function Bu(n,e){return n.Uri.parse(e)}function J1({original:n,modified:e,language:t,originalLanguage:r,modifiedLanguage:s,originalModelPath:o,modifiedModelPath:i,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:a=!1,theme:c="light",loading:u="Loading...",options:d={},height:f="100%",width:h="100%",className:m,wrapperProps:g={},beforeMount:y=Yn,onMount:x=Yn}){let[b,v]=N.useState(!1),[C,k]=N.useState(!0),w=N.useRef(null),S=N.useRef(null),M=N.useRef(null),T=N.useRef(x),E=N.useRef(y),R=N.useRef(!1);zu(()=>{let O=ro.init();return O.then(A=>(S.current=A)&&k(!1)).catch(A=>A?.type!=="cancelation"&&console.error("Monaco initialization: error:",A)),()=>w.current?_():O.cancel()}),Ie(()=>{if(w.current&&S.current){let O=w.current.getOriginalEditor(),A=bn(S.current,n||"",r||t||"text",o||"");A!==O.getModel()&&O.setModel(A)}},[o],b),Ie(()=>{if(w.current&&S.current){let O=w.current.getModifiedEditor(),A=bn(S.current,e||"",s||t||"text",i||"");A!==O.getModel()&&O.setModel(A)}},[i],b),Ie(()=>{let O=w.current.getModifiedEditor();O.getOption(S.current.editor.EditorOption.readOnly)?O.setValue(e||""):e!==O.getValue()&&(O.executeEdits("",[{range:O.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),O.pushUndoStop())},[e],b),Ie(()=>{w.current?.getModel()?.original.setValue(n||"")},[n],b),Ie(()=>{let{original:O,modified:A}=w.current.getModel();S.current.editor.setModelLanguage(O,r||t||"text"),S.current.editor.setModelLanguage(A,s||t||"text")},[t,r,s],b),Ie(()=>{S.current?.editor.setTheme(c)},[c],b),Ie(()=>{w.current?.updateOptions(d)},[d],b);let D=N.useCallback(()=>{if(!S.current)return;E.current(S.current);let O=bn(S.current,n||"",r||t||"text",o||""),A=bn(S.current,e||"",s||t||"text",i||"");w.current?.setModel({original:O,modified:A})},[t,e,s,n,r,o,i]),B=N.useCallback(()=>{!R.current&&M.current&&(w.current=S.current.editor.createDiffEditor(M.current,{automaticLayout:!0,...d}),D(),S.current?.editor.setTheme(c),v(!0),R.current=!0)},[d,c,D]);N.useEffect(()=>{b&&T.current(w.current,S.current)},[b]),N.useEffect(()=>{!C&&!b&&B()},[C,b,B]);function _(){let O=w.current?.getModel();l||O?.original?.dispose(),a||O?.modified?.dispose(),w.current?.dispose()}return Q.createElement(_u,{width:h,height:f,isEditorReady:b,loading:u,_ref:M,className:m,wrapperProps:g})}var G1=J1;N.memo(G1);function Y1(n){let e=N.useRef();return N.useEffect(()=>{e.current=n},[n]),e.current}var X1=Y1,jr=new Map;function Q1({defaultValue:n,defaultLanguage:e,defaultPath:t,value:r,language:s,path:o,theme:i="light",line:l,loading:a="Loading...",options:c={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:h="100%",height:m="100%",className:g,wrapperProps:y={},beforeMount:x=Yn,onMount:b=Yn,onChange:v,onValidate:C=Yn}){let[k,w]=N.useState(!1),[S,M]=N.useState(!0),T=N.useRef(null),E=N.useRef(null),R=N.useRef(null),D=N.useRef(b),B=N.useRef(x),_=N.useRef(),O=N.useRef(r),A=X1(o),L=N.useRef(!1),z=N.useRef(!1);zu(()=>{let H=ro.init();return H.then(K=>(T.current=K)&&M(!1)).catch(K=>K?.type!=="cancelation"&&console.error("Monaco initialization: error:",K)),()=>E.current?W():H.cancel()}),Ie(()=>{let H=bn(T.current,n||r||"",e||s||"",o||t||"");H!==E.current?.getModel()&&(d&&jr.set(A,E.current?.saveViewState()),E.current?.setModel(H),d&&E.current?.restoreViewState(jr.get(o)))},[o],k),Ie(()=>{E.current?.updateOptions(c)},[c],k),Ie(()=>{!E.current||r===void 0||(E.current.getOption(T.current.editor.EditorOption.readOnly)?E.current.setValue(r):r!==E.current.getValue()&&(z.current=!0,E.current.executeEdits("",[{range:E.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),E.current.pushUndoStop(),z.current=!1))},[r],k),Ie(()=>{let H=E.current?.getModel();H&&s&&T.current?.editor.setModelLanguage(H,s)},[s],k),Ie(()=>{l!==void 0&&E.current?.revealLine(l)},[l],k),Ie(()=>{T.current?.editor.setTheme(i)},[i],k);let U=N.useCallback(()=>{if(!(!R.current||!T.current)&&!L.current){B.current(T.current);let H=o||t,K=bn(T.current,r||n||"",e||s||"",H||"");E.current=T.current?.editor.create(R.current,{model:K,automaticLayout:!0,...c},u),d&&E.current.restoreViewState(jr.get(H)),T.current.editor.setTheme(i),l!==void 0&&E.current.revealLine(l),w(!0),L.current=!0}},[n,e,t,r,s,o,c,u,d,i,l]);N.useEffect(()=>{k&&D.current(E.current,T.current)},[k]),N.useEffect(()=>{!S&&!k&&U()},[S,k,U]),O.current=r,N.useEffect(()=>{k&&v&&(_.current?.dispose(),_.current=E.current?.onDidChangeModelContent(H=>{z.current||v(E.current.getValue(),H)}))},[k,v]),N.useEffect(()=>{if(k){let H=T.current.editor.onDidChangeMarkers(K=>{let Z=E.current.getModel()?.uri;if(Z&&K.find(Y=>Y.path===Z.path)){let Y=T.current.editor.getModelMarkers({resource:Z});C?.(Y)}});return()=>{H?.dispose()}}return()=>{}},[k,C]);function W(){_.current?.dispose(),f?d&&jr.set(o,E.current.saveViewState()):E.current.getModel()?.dispose(),E.current.dispose()}return Q.createElement(_u,{width:h,height:m,isEditorReady:k,loading:a,_ref:R,className:g,wrapperProps:y})}var Z1=Q1,e0=N.memo(Z1),t0=e0;async function n0(n){const e=n.getModel();if(!e)throw new Error("[Monaco] No model found in editor");const t=e.getValue(),s=t.replace(/export default (async )?function/,"export default $1function __default")+`
|
|
18
|
+
type __ExpandRecursively<T> = T extends (...args: infer A) => infer R
|
|
19
|
+
? (...args: __ExpandRecursively<A>) => __ExpandRecursively<R>
|
|
20
|
+
: T extends object
|
|
21
|
+
? T extends infer O ? { [K in keyof O]: __ExpandRecursively<O[K]> } : never
|
|
22
|
+
: T;
|
|
23
|
+
type __InferredOutput = __ExpandRecursively<Awaited<ReturnType<typeof __default>>>;
|
|
24
|
+
declare const __outputValue: __InferredOutput;
|
|
25
|
+
`;e.setValue(s);const o=e.findMatches("__outputValue",!1,!1,!1,null,!1);if(!o||o.length===0)return e.setValue(t),null;const i=o[0];if(!i)return e.setValue(t),null;const l={lineNumber:i.range.startLineNumber,column:i.range.startColumn+1};try{const c=await(await ro.init()).languages.typescript.getTypeScriptWorker();if(!c)return e.setValue(t),null;const u=await c(e.uri);await new Promise(h=>setTimeout(h,100));const d=e.getOffsetAt(l),f=await u.getQuickInfoAtPosition(e.uri.toString(),d);if(e.setValue(t),f){const m=f.displayParts.map(y=>y.text).join("").replace(/^const __outputValue:\s*/,"");return kn(m)}else return null}catch(a){return e.setValue(t),console.error("Error getting return type:",a),null}}function kn(n){if(n=n.trim(),n==="string")return{type:"string"};if(n==="number")return{type:"number"};if(n==="boolean")return{type:"boolean"};if(n==="null")return{type:"null"};if(n==="undefined")return{type:"null"};if(n==="unknown"||n==="any")return{};if(n==="never")return{not:{}};if(n.endsWith("[]")){const r=n.slice(0,-2);return{type:"array",items:kn(r)}}const e=n.match(/^Array<(.+)>$/);if(e&&e[1])return{type:"array",items:kn(e[1])};const t=n.match(/^Record<(.+),\s*(.+)>$/);if(t&&t[2])return{type:"object",additionalProperties:kn(t[2].trim())};if(n.includes("|")){const r=r0(n);if(r.length>1)return r.every(o=>/^["']/.test(o.trim()))?{type:"string",enum:r.map(o=>o.trim().replace(/^["']|["']$/g,""))}:{anyOf:r.map(o=>kn(o.trim()))}}return/^["'].*["']$/.test(n)?{type:"string",const:n.slice(1,-1)}:/^-?\d+(\.\d+)?$/.test(n)?{type:"number",const:parseFloat(n)}:n.startsWith("{")&&n.endsWith("}")?s0(n):{description:`TypeScript type: ${n}`}}function r0(n){const e=[];let t=0,r="";for(let s=0;s<n.length;s++){const o=n[s];if(o==="{"||o==="<"||o==="("||o==="[")t++;else if(o==="}"||o===">"||o===")"||o==="]")t--;else if(o==="|"&&t===0){e.push(r.trim()),r="";continue}r+=o}return r.trim()&&e.push(r.trim()),e}function s0(n){const e=n.slice(1,-1).trim();if(!e)return{type:"object",properties:{}};const t={},r=[];let s=0,o="";for(let l=0;l<e.length;l++){const a=e[l];if(a==="{"||a==="<"||a==="("||a==="[")s++;else if(a==="}"||a===">"||a===")"||a==="]")s--;else if(a===";"&&s===0){o.trim()&&Ta(o.trim(),t,r),o="";continue}o+=a}o.trim()&&Ta(o.trim(),t,r);const i={type:"object",properties:t};return r.length>0&&(i.required=r),i}function Ta(n,e,t){const r=n.match(/^(\w+)(\?)?:\s*(.+)$/s);if(r){const s=r[1],o=r[2],i=r[3];s&&i&&(e[s]=kn(i.trim()),o||t.push(s))}}class o0 extends N.Component{constructor(e){super(e),this.state={hasError:!1,mountKey:0}}static getDerivedStateFromError(e){if(e.message?.includes("InstantiationService has been disposed"))return{hasError:!0};throw e}componentDidCatch(e){e.message?.includes("InstantiationService has been disposed")&&this.setState(t=>({hasError:!1,mountKey:t.mountKey+1}))}render(){return this.state.hasError?p.jsx("div",{className:"flex items-center justify-center h-full w-full bg-[#1e1e1e] text-gray-400",children:p.jsx(Ln,{size:"sm"})}):N.cloneElement(this.props.children,{mountKey:this.state.mountKey})}}let Rr=null;const i0=async()=>{if(Rr)return Rr;const[n,e,t]=await Promise.all([Ro(()=>import("./standalone-Cva4pL7v.js"),[]),Ro(()=>import("./typescript-Ca_eWjgL.js"),[]),Ro(()=>import("./estree-CwOGYdhi.js"),[])]);return Rr={format:n.format,plugins:[e.default,t.default]},Rr};ro.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});const l0={parser:"typescript",semi:!0,singleQuote:!1,tabWidth:2,trailingComma:"es5",printWidth:80},Ma={fontSize:13,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,foldingStrategy:"auto",tabSize:2,wordWrap:"on",folding:!0,bracketPairColorization:{enabled:!0},formatOnPaste:!0,formatOnType:!0,suggestOnTriggerCharacters:!0,quickSuggestions:{other:!0,comments:!1,strings:!0},parameterHints:{enabled:!0},inlineSuggest:{enabled:!0},autoClosingBrackets:"always",autoClosingQuotes:"always",autoSurround:"languageDefined",padding:{top:12,bottom:12},scrollbar:{vertical:"auto",horizontal:"auto",verticalScrollbarSize:8,horizontalScrollbarSize:8},theme:"light"},a0=p.jsx("div",{className:"flex items-center justify-center h-full w-full text-gray-400",children:p.jsx(Ln,{size:"sm"})}),c0=N.memo(function({code:e,onChange:t,onSave:r,readOnly:s=!1,height:o=300,language:i="typescript",foldOnMount:l=!1,mountKey:a=0}){const c=N.useRef(null),u=N.useRef(null),d=N.useRef(r);d.current=r;const f=N.useRef(i);f.current=i;const h=N.useId(),m=`${h}-${a}`,g=i==="typescript"?`file:///workflow-${h.replace(/:/g,"-")}-${a}.tsx`:void 0,y=s?{...Ma,readOnly:!0}:Ma,x=async v=>{const C=v.getModel();if(!C){console.warn("No model found");return}const k=C.getValue();if(f.current==="json"){try{const S=JSON.parse(k),M=JSON.stringify(S,null,2);if(M!==k){const T=C.getFullModelRange();v.executeEdits("json-format",[{range:T,text:M}])}}catch(S){console.error("JSON formatting failed:",S)}return}try{const{format:S,plugins:M}=await i0(),T=await S(k,{...l0,plugins:M});if(T!==k){const E=C.getFullModelRange();v.executeEdits("prettier",[{range:E,text:T}])}}catch(S){console.error("Prettier formatting failed:",S)}},b=async(v,C)=>{c.current=v,l&&u.current&&(u.current.style.visibility="hidden",await v.getAction("editor.foldLevel2")?.run(),u.current.style.visibility="visible"),i==="typescript"&&(C.languages.typescript.typescriptDefaults.setCompilerOptions({target:C.languages.typescript.ScriptTarget.ESNext,module:C.languages.typescript.ModuleKind.ESNext,moduleResolution:C.languages.typescript.ModuleResolutionKind.NodeJs,allowNonTsExtensions:!0,allowJs:!0,strict:!1,noEmit:!0,esModuleInterop:!0,jsx:C.languages.typescript.JsxEmit.React,allowSyntheticDefaultImports:!0}),C.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!1,noSyntaxValidation:!1})),v.addCommand(C.KeyMod.CtrlCmd|C.KeyCode.KeyS,async()=>{await x(v);const k=await n0(v),w=v.getValue();console.log({value:w,returnType:k}),d.current?.(w,k)})};return p.jsx("div",{ref:u,className:"h-full",children:p.jsx(t0,{height:o,language:i,value:e,path:g,onChange:t,onMount:b,loading:a0,options:y},m)})}),dl=N.memo(function(e){const t=P.c(2);let r;return t[0]!==e?(r=p.jsx(o0,{children:p.jsx(c0,{...e})}),t[0]=e,t[1]=r):r=t[1],r});function fl(){const n=P.c(2),e=Tp();let t;n[0]!==e?(t={connections:e,binding:"WORKFLOW"},n[0]=e,n[1]=t):t=n[1];const r=Kp(t);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}function Cr(n){const e=P.c(14),t=fl();let r;e[0]!==t.id?(r=jt(t.id),e[0]=t.id,e[1]=r):r=e[1];const s=r;let o;e[2]!==n?(o={id:n},e[2]=n,e[3]=o):o=e[3];const i=!!n,l=n?u0:!1;let a;e[4]!==t.id||e[5]!==o||e[6]!==i||e[7]!==l||e[8]!==s?(a={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET",toolInputParams:o,scope:t.id,enabled:i,refetchInterval:l},e[4]=t.id,e[5]=o,e[6]=i,e[7]=l,e[8]=s,e[9]=a):a=e[9];const{data:c,isLoading:u}=uu(a),d=c?.item,f=c?.step_results;let h;return e[10]!==u||e[11]!==d||e[12]!==f?(h={item:d,step_results:f,isLoading:u},e[10]=u,e[11]=d,e[12]=f,e[13]=h):h=e[13],h}function u0(n){const e=n.state?.data?.item?.status;return e==="running"||e==="enqueued"?2e3:!1}function d0(){const n=P.c(19),e=fl(),t=_n();let r;n[0]!==e.id?(r=jt(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}`,u=!!t.id;let d;n[8]!==a||n[9]!==c||n[10]!==u||n[11]!==s?(d={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_LIST",toolInputParams:a,scope:c,enabled:u,staleTime:5e3},n[8]=a,n[9]=c,n[10]=u,n[11]=s,n[12]=d):d=n[12];const{data:f,isLoading:h,refetch:m}=uu(d),g=f;let y;n[13]!==g?.items?(y=g?.items??[],n[13]=g?.items,n[14]=y):y=n[14];let x;return n[15]!==h||n[16]!==m||n[17]!==y?(x={executions:y,isLoading:h,refetch:m},n[15]=h,n[16]=m,n[17]=y,n[18]=x):x=n[18],x}function Fu(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 f0(n){const e=[];for(const t of n){const r=Fu(t.input);e.push(...r)}return[...new Set(e)].filter(t=>t!=="__entire_input__")}function h0(n){for(const e of n)if(Fu(e.input).includes("__entire_input__"))return!0;return!1}function p0(n){const e=f0(n);if(e.length===0)return h0(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 m0(){const n=P.c(2),e=_n();let t;return n[0]!==e.steps?(t=p0(e.steps),n[0]=e.steps,n[1]=t):t=n[1],t}function g0(){const n=P.c(14),{id:e}=fl(),{setTrackingExecutionId:t}=Ge();let r;n[0]!==e?(r=jt(e),n[0]=e,n[1]=r):r=n[1];const s=r,o=_n(),i=zn(),l=m0();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:u}=lm(a);let d;n[4]!==i||n[5]!==t||n[6]!==c||n[7]!==o?(d=async g=>{const y=g===void 0?{}:g;if(!i)throw new Error("Please select a gateway before running the workflow");const x=Date.now(),b=await c({steps:o.steps,input:y,gateway_id:i,start_at_epoch_ms:x,workflow_collection_id:o.id,timeout_ms:3e4}),v=b.id??b.structuredContent.id;return t(v),v},n[4]=i,n[5]=t,n[6]=c,n[7]=o,n[8]=d):d=n[8];const f=d,h=l!==null;let m;return n[9]!==f||n[10]!==l||n[11]!==u||n[12]!==h?(m={handleRunWorkflow:f,isPending:u,requiresInput:h,inputSchema:l},n[9]=f,n[10]=l,n[11]=u,n[12]=h,n[13]=m):m=n[13],m}function y0(){const n=P.c(4),e=Pt(),{step_results:t,item:r}=Cr(e);let s;return n[0]!==r||n[1]!==t||n[2]!==e?(s=e&&t?(()=>{const i={};r?.input&&(i.input=r.input);for(const l of t)l.step_id&&l.output!==void 0&&(i[l.step_id]=l.output);return i})():void 0,n[0]=r,n[1]=t,n[2]=e,n[3]=s):s=n[3],s}function x0(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 hl=Ag()(Au(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"})),Vu=N.createContext([]);function Hu(){return N.useContext(Vu)}function be(n){this.content=n}be.prototype={constructor:be,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 be(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 be(t)},addToStart:function(n,e){return new be([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new be(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 be(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=be.from(n),n.size?new be(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=be.from(n),n.size?new be(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=be.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}};be.from=function(n){if(n instanceof be)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new be(e)};function Wu(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=Wu(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function qu(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,u=Math.min(i.text.length,l.text.length);for(;c<u&&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=qu(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class I{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 u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}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 I(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 I(r,s)}cutByIndex(e,t){return e==t?I.empty:e==0&&t==this.content.length?this:new I(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 I(s,o)}addToStart(e){return new I([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new I(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 Wu(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return qu(this,e,t,r)}findIndex(e){if(e==0)return Dr(0,e);if(e==this.size)return Dr(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?Dr(t+1,o):Dr(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 I.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new I(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return I.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 I(t||e,r)}static from(e){if(!e)return I.empty;if(e instanceof I)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new I([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}I.empty=new I([],0);const Fo={index:0,offset:0};function Dr(n,e){return Fo.index=n,Fo.offset=e,Fo}function ts(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(!ts(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ts(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let ne=class bi{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&&ts(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 bi.none;if(e instanceof bi)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};ne.none=[];class ns extends Error{}class ${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=Ku(this.content,e+this.openStart,t);return r&&new $(r,this.openStart,this.openEnd)}removeBetween(e,t){return new $(Uu(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 $.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 $(I.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 $(e,r,s)}}$.empty=new $(I.empty,0,0);function Uu(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(Uu(o.content,e-s-1,t-s-1)))}function Ku(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=Ku(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function b0(n,e,t){if(t.openStart>n.depth)throw new ns("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ns("Inconsistent open depths");return Ju(n,e,t,0)}function Ju(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=Ju(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 qt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=k0(t,n);return qt(o,Yu(n,i,l,e,r))}else return qt(o,rs(n,e,r))}function Gu(n,e){if(!e.type.compatibleContent(n.type))throw new ns("Cannot join "+e.type.name+" onto "+n.type.name)}function ki(n,e,t){let r=n.node(t);return Gu(r,e.node(t)),r}function Wt(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 Xn(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&&(Wt(n.nodeAfter,r),o++));for(let l=o;l<i;l++)Wt(s.child(l),r);e&&e.depth==t&&e.textOffset&&Wt(e.nodeBefore,r)}function qt(n,e){return n.type.checkContent(e),n.copy(e)}function Yu(n,e,t,r,s){let o=n.depth>s&&ki(n,e,s+1),i=r.depth>s&&ki(t,r,s+1),l=[];return Xn(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(Gu(o,i),Wt(qt(o,Yu(n,e,t,r,s+1)),l)):(o&&Wt(qt(o,rs(n,e,s+1)),l),Xn(e,t,s,l),i&&Wt(qt(i,rs(t,r,s+1)),l)),Xn(r,null,s,l),new I(l)}function rs(n,e,t){let r=[];if(Xn(null,n,t,r),n.depth>t){let s=ki(n,e,t+1);Wt(qt(s,rs(n,e,t+1)),r)}return Xn(e,null,t,r),new I(r)}function k0(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(I.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class cr{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 ne.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 ss(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 cr(t,r,o)}static resolveCached(e,t){let r=Oa.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 Oa.set(e,r=new v0);let s=r.elts[r.i]=cr.resolve(e,t);return r.i=(r.i+1)%w0,s}}class v0{constructor(){this.elts=[],this.i=0}}const w0=12,Oa=new WeakMap;class ss{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 S0=Object.create(null);class _e{constructor(e,t,r,s=ne.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||I.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&&ts(this.attrs,t||e.defaultAttrs||S0)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new _e(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _e(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 $.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 $(c,s.depth-i,o.depth-i)}replace(e,t,r){return b0(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 cr.resolveCached(this,e)}resolveNoCache(e){return cr.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()+")"),Xu(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=I.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=ne.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(!ne.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=I.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}_e.prototype.text=void 0;class is extends _e{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):Xu(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 is(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new is(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 Xu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Yt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new C0(e,t);if(r.next==null)return Yt.empty;let s=Qu(r);r.next&&r.err("Unexpected trailing text");let o=I0(A0(s));return j0(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 I.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let 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(`
|
|
26
|
+
`)}}Yt.empty=new Yt(!0);class C0{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 Qu(n){let e=[];do e.push(N0(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function N0(n){let e=[];do e.push(E0(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function E0(n){let e=O0(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=T0(n,e);else break;return e}function Aa(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function T0(n,e){let t=Aa(n),r=t;return n.eat(",")&&(n.next!="}"?r=Aa(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function M0(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 O0(n){if(n.eat("(")){let e=Qu(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=M0(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 A0(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 u=t();s(o(i.expr,a),u),a=u}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),s(o(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Zu(n,e){return e-n}function Ia(n,e){let t=[];return r(e),t.sort(Zu);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 I0(n){let e=Object.create(null);return t(Ia(n,0));function t(r){let s=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);Ia(n,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Yt(r.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(Zu);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function j0(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 ed(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 td(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 nd(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 rd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new D0(n,r,e[r]);return t}let ja=class sd{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=rd(e,r.attrs),this.defaultAttrs=ed(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==Yt.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:td(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new _e(this,this.computeAttrs(e),I.from(t),ne.setFrom(r))}createChecked(e=null,t,r){return t=I.from(t),this.checkContent(t),new _e(this,this.computeAttrs(e),t,ne.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=I.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(I.empty,!0);return o?new _e(this,e,t.append(o),ne.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){nd(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:ne.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,i)=>r[o]=new sd(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 R0(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 D0{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?R0(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class so{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=rd(e,s.attrs),this.excluded=null;let o=ed(this.attrs);this.instance=o?new ne(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,td(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new so(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){nd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class od{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=be.from(e.nodes),t.marks=be.from(e.marks||{}),this.nodes=ja.compile(this.spec.nodes,this),this.marks=so.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]=Yt.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?Ra(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==""?[]:Ra(this,i.split(" "))}this.nodeFromJSON=s=>_e.fromJSON(this,s),this.markFromJSON=s=>ne.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 ja){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 is(r,r.defaultAttrs,e,ne.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 Ra(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 P0(n){return n.tag!=null}function L0(n){return n.style!=null}class Nt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(P0(s))this.tags.push(s);else if(L0(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 Pa(this,t,!1);return r.addAll(e,ne.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Pa(this,t,!0);return r.addAll(e,ne.none,t.from,t.to),$.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(z0(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=La(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=La(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Nt(e,Nt.schemaRules(e)))}}const id={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},$0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ld={ol:!0,ul:!0},ur=1,vi=2,Qn=4;function Da(n,e,t){return e!=null?(e?ur:0)|(e==="full"?vi:0):n&&n.whitespace=="pre"?ur|vi:t&~Qn}class Pr{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=ne.none,this.match=o||(i&Qn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(I.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&ur)){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=I.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(I.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&&!id.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Pa{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=Da(null,t.preserveWhitespace,0)|(r?Qn:0);s?o=new Pr(s.type,s.attrs,ne.none,!0,t.topMatch||s.type.contentMatch,i):r?o=new Pr(null,null,ne.none,!0,null,i):o=new Pr(e.schema.topNodeType,null,ne.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&vi?"full":this.localPreserveWS||(s.options&ur)>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,`
|
|
27
|
+
`);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;ld.hasOwnProperty(i)&&this.parser.normalizeLists&&_0(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:$0.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,u=this.needsBlock;if(id.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 d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}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(`
|
|
28
|
+
`),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=ne.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):$a(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=Da(e,o,i.options);i.options&Qn&&i.content.length==0&&(l|=Qn);let a=ne.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):$a(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Pr(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|=ur)}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 u=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.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 _0(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ld.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function z0(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function La(n){let e={};for(let t in n)e[t]=n[t];return e}function $a(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:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class nn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Vo(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++],u=this.serializeMark(c,i.isInline,t);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Ur(Vo(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&&Ur(Vo(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Ur(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new nn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=_a(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return _a(e.marks)}}function _a(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Vo(n){return n.document||window.document}const za=new WeakMap;function B0(n){let e=za.get(n);return e===void 0&&za.set(n,e=F0(n)),e}function F0(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 Ur(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=B0(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],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:m}=Ur(n,f,t,r);if(a.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const ad=65535,cd=Math.pow(2,16);function V0(n,e){return n+e*cd}function Ba(n){return n&ad}function H0(n){return(n-(n&ad))/cd}const ud=1,dd=2,Kr=4,fd=8;class wi{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&fd)>0}get deletedBefore(){return(this.delInfo&(ud|Kr))>0}get deletedAfter(){return(this.delInfo&(dd|Kr))>0}get deletedAcross(){return(this.delInfo&Kr)>0}}class je{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&je.empty)return je.empty}recover(e){let t=0,r=Ba(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+H0(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],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+s+(f<0?0:u);if(r)return h;let m=e==(t<0?a:d)?null:V0(l/3,e-a),g=e==a?dd:e==d?ud:Kr;return(t<0?e!=a:e!=d)&&(g|=fd),new wi(h,g,m)}s+=u-c}return r?e+s:new wi(e+s,0,null)}touches(e,t){let r=0,s=Ba(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],u=a+c;if(e<=u&&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],u=this.ranges[s+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new je(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?je.empty:new je(e<0?[0,-e,0]:[0,0,e])}}je.empty=new je([]);class dr{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 dr(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 dr;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 wi(e,s,null)}}const Ho=Object.create(null);class Ne{getMap(){return je.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ho[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 Ho)throw new RangeError("Duplicate use of step JSON ID "+e);return Ho[e]=t,t.prototype.jsonID=e,t}}class he{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new he(e,null)}static fail(e){return new he(null,e)}static fromReplace(e,t,r,s){try{return he.ok(e.replace(t,r,s))}catch(o){if(o instanceof ns)return he.fail(o.message);throw o}}}function pl(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let o=n.child(s);o.content.size&&(o=o.copy(pl(o.content,e,o))),o.isInline&&(o=e(o,t,s)),r.push(o)}return I.fromArray(r)}class vt 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 $(pl(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 he.fromReplace(e,this.from,this.to,o)}invert(){return new Je(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 vt(t.pos,r.pos,this.mark)}merge(e){return e instanceof vt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new vt(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 vt(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("addMark",vt);class Je 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 $(pl(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return he.fromReplace(e,this.from,this.to,r)}invert(){return new vt(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 Je(t.pos,r.pos,this.mark)}merge(e){return e instanceof Je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Je(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 Je(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("removeMark",Je);class wt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return he.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return he.fromReplace(e,this.pos,this.pos+1,new $(I.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 wt(this.pos,t.marks[s]);return new wt(this.pos,this.mark)}}return new Xt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new wt(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 wt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("addNodeMark",wt);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 he.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return he.fromReplace(e,this.pos,this.pos+1,new $(I.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new wt(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:"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 Xt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("removeNodeMark",Xt);class me 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&&Si(e,this.from,this.to)?he.fail("Structure replace would overwrite content"):he.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new je([this.from,this.to-this.from,this.slice.size])}invert(e){return new me(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 me(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof me)||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?$.empty:new $(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new me(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?$.empty:new $(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new me(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 me(t.from,t.to,$.fromJSON(e,t.slice),!!t.structure)}}Ne.jsonID("replace",me);class ye 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&&(Si(e,this.from,this.gapFrom)||Si(e,this.gapTo,this.to)))return he.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return he.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?he.fromReplace(e,this.from,this.to,r):he.fail("Content does not fit in gap")}getMap(){return new je([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 ye(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 ye(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 ye(t.from,t.to,t.gapFrom,t.gapTo,$.fromJSON(e,t.slice),t.insert,!!t.structure)}}Ne.jsonID("replaceAround",ye);function Si(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 W0(n,e,t,r){let s=[],o=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(i&&i.to==f&&i.mark.eq(d[g])?i.to=h:s.push(i=new Je(f,h,d[g])));l&&l.to==f?l.to=h:o.push(l=new vt(f,h,r))}}),s.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function q0(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 so){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.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 u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let m=s[h];m.step==o-1&&d.eq(s[h].style)&&(f=m)}f?(f.to=c,f.step=o):s.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>n.step(new Je(i.from,i.to,i.style)))}function ml(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),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new me(l,u,$.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Je(l,u,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new $(I.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new me(l+f.index,l+f.index+f[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(I.empty,!0);n.replace(l,l,new $(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function U0(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Bn(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||!U0(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function K0(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,u=I.empty,d=0;for(let m=o,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,u=I.from(r.node(m).copy(u)),d++):a--;let f=I.empty,h=0;for(let m=o,g=!1;m>t;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=I.from(s.node(m).copy(f)),h++):c++;n.step(new ye(a,c,i,l,new $(u.append(f),d,h),u.size-d,!0))}function gl(n,e,t=null,r=n){let s=J0(n,e),o=s&&G0(r,e);return o?s.map(Fa).concat({type:e,attrs:t}).concat(o.map(Fa)):null}function Fa(n){return{type:n,attrs:null}}function J0(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 G0(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 Y0(n,e,t){let r=I.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=I.from(t[i].type.create(t[i].attrs,r))}let s=e.start,o=e.end;n.step(new ye(s,o,s,o,new $(r,0,0),t.length,!0))}function X0(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)&&Q0(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&pd(n,i,l,o),ml(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return n.step(new ye(d,f,d+1,f-1,new $(I.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&hd(n,i,l,o),!1}})}function hd(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 pd(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(`
|
|
29
|
+
`))}})}function Q0(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function Z0(n,e,t,r,s){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let i=t.create(r,null,s||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,i);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ye(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new $(I.from(i),0,0),1,!0))}function ct(n,e,t=1,r){let s=n.resolve(e),o=s.depth-t,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=t-2;c>o;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),m=r&&r[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=s.indexAfter(o),a=r&&r[0];return s.node(o).canReplaceWith(l,l,a?a.type:s.node(o+1).type)}function ey(n,e,t=1,r){let s=n.doc.resolve(e),o=I.empty,i=I.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){o=I.from(s.node(l).copy(o));let u=r&&r[c];i=I.from(u?u.type.create(u.attrs,i):s.node(l).copy(i))}n.step(new me(e,e,new $(o.append(i),t,t),!0))}function Lt(n,e){let t=n.resolve(e),r=t.index();return md(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function ty(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function md(n,e){return!!(n&&e&&!n.isLeaf&&ty(n,e))}function oo(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let o,i,l=r.index(s);if(s==r.depth?(o=r.nodeBefore,i=r.nodeAfter):t>0?(o=r.node(s+1),l++,i=r.node(s).maybeChild(l)):(o=r.node(s).maybeChild(l-1),i=r.node(s+1)),o&&!o.isTextblock&&md(o,i)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function ny(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,o=n.doc.resolve(e-t),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);pd(n,u.node(),u.before(),l)}i.inlineContent&&ml(n,e+t-1,i,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new me(c,a.map(e+t,-1),$.empty,!0)),r===!0){let u=n.doc.resolve(c);hd(n,u.node(),u.before(),n.steps.length)}return n}function ry(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,t))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,t))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function gd(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let o=0;o<t.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(o==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function io(n,e,t=e,r=$.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),o=n.resolve(t);return yd(s,o,r)?new me(e,t,r):new sy(s,o,r).fit()}function yd(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class sy{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=I.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=I.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let o=this.placed,i=r.depth,l=s.depth;for(;i&&l&&o.childCount==1;)o=o.firstChild.content,i--,l--;let a=new $(o,i,l);return e>-1?new ye(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new me(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=Wo(this.unplaced.content,r-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(i?c.matchType(i.type)||(d=c.fillBefore(I.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:d};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Wo(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new $(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Wo(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new $(Un(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new $(Un(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let g=0;g<o.length;g++)this.openFrontierNode(o[g]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));d=d.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let g=l.child(c),y=d.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(d=y,u.push(xd(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let m=c==l.childCount;m||(h=-1),this.placed=Kn(this.placed,t,I.from(u)),this.frontier[t].match=d,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let x=y.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),y=x.content}this.unplaced=m?e==0?$.empty:new $(Un(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new $(Un(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!qo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=qo(e,t,s,r,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=qo(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Kn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Kn(this.placed,this.depth,I.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(I.empty,!0);t.childCount&&(this.placed=Kn(this.placed,this.frontier.length,t))}}function Un(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Un(n.firstChild.content,e-1,t)))}function Kn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Kn(n.lastChild.content,e-1,t)))}function Wo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function xd(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,xd(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(I.empty,!0)))),n.copy(r)}function qo(n,e,t,r,s){let o=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,i);return l&&!oy(t,o.content,i)?l:null}function oy(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function iy(n){return n.spec.defining||n.spec.definingForContent}function ly(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),o=n.doc.resolve(t);if(yd(s,o,r))return n.step(new me(e,t,r));let i=kd(s,o);i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let m=s.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let m=f.firstChild;if(c.push(m),h==r.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let h=c[f],m=iy(h.type);if(m&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(m||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),m=c[h];if(m)for(let g=0;g<i.length;g++){let y=i[(g+a)%i.length],x=!0;y<0&&(x=!1,y=-y);let b=s.node(y-1),v=s.index(y-1);if(b.canReplaceWith(v,v,m.type,m.marks))return n.replace(s.before(y),x?o.after(y):t,new $(bd(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=i.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=i[f];h<0||(e=s.before(h),t=o.after(h))}}function bd(n,e,t,r,s){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(bd(o.content,e+1,t,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(n).append(n);n=i.append(o.matchFragment(i).fillBefore(I.empty,!0))}return n}function ay(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=ry(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new $(I.from(r),0,0))}function cy(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),o=kd(r,s);for(let i=0;i<o.length;i++){let l=o[i],a=i==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&s.end(i)-t!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function kd(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let o=n.start(s);if(o<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&t.push(s)}return t}class wn extends Ne{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return he.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return he.fromReplace(e,this.pos,this.pos+1,new $(I.from(s),0,t.isLeaf?0:1))}getMap(){return je.empty}invert(e){return new wn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new wn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new wn(t.pos,t.attr,t.value)}}Ne.jsonID("attr",wn);class fr extends Ne{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return he.ok(r)}getMap(){return je.empty}invert(e){return new fr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new fr(t.attr,t.value)}}Ne.jsonID("docAttr",fr);let Nn=class extends Error{};Nn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Nn.prototype=Object.create(Error.prototype);Nn.prototype.constructor=Nn;Nn.prototype.name="TransformError";class vd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new dr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Nn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=$.empty){let s=io(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new $(I.from(r),0,0))}delete(e,t){return this.replace(e,t,$.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return ly(this,e,t,r),this}replaceRangeWith(e,t,r){return ay(this,e,t,r),this}deleteRange(e,t){return cy(this,e,t),this}lift(e,t){return K0(this,e,t),this}join(e,t=1){return ny(this,e,t),this}wrap(e,t){return Y0(this,e,t),this}setBlockType(e,t=e,r,s=null){return X0(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return Z0(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new wn(e,t,r)),this}setDocAttribute(e,t){return this.step(new fr(e,t)),this}addNodeMark(e,t){return this.step(new wt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof ne)t.isInSet(r.marks)&&this.step(new Xt(e,t));else{let s=r.marks,o,i=[];for(;o=t.isInSet(s);)i.push(new Xt(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return ey(this,e,t,r),this}addMark(e,t,r){return W0(this,e,t,r),this}removeMark(e,t,r){return q0(this,e,t,r),this}clearIncompatible(e,t,r){return ml(this,e,t,r),this}}const Uo=Object.create(null);class G{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new uy(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=$.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?$.empty:t),l==0&&Wa(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:l}=s[o],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Wa(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new q(e):mn(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=t<0?mn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):mn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Re(e.node(0))}static atStart(e){return mn(e,e,0,0,1)||new Re(e)}static atEnd(e){return mn(e,e,e.content.size,e.childCount,-1)||new Re(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Uo[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Uo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Uo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}}G.prototype.visible=!0;class uy{constructor(e,t){this.$from=e,this.$to=t}}let Va=!1;function Ha(n){!Va&&!n.parent.inlineContent&&(Va=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class q extends G{constructor(e,t=e){Ha(e),Ha(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return G.near(r);let s=e.resolve(t.map(this.anchor));return new q(s.parent.inlineContent?s:r,r)}replace(e,t=$.empty){if(super.replace(e,t),t==$.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new lo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new q(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let o=G.findFrom(t,r,!0)||G.findFrom(t,-r,!0);if(o)t=o.$head;else return G.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(G.findFrom(e,-r,!0)||G.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new q(e,t)}}G.jsonID("text",q);class lo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new lo(e.map(this.anchor),e.map(this.head))}resolve(e){return q.between(e.resolve(this.anchor),e.resolve(this.head))}}class F extends G{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),o=e.resolve(s);return r?G.near(o):new F(o)}content(){return new $(I.from(this.node),0,0)}eq(e){return e instanceof F&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new yl(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new F(e.resolve(t.anchor))}static create(e,t){return new F(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}F.prototype.visible=!1;G.jsonID("node",F);class yl{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new lo(r,r):new yl(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&F.isSelectable(r)?new F(t):G.near(t)}}class Re extends G{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=$.empty){if(t==$.empty){e.delete(0,e.doc.content.size);let r=G.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Re(e)}map(e){return new Re(e)}eq(e){return e instanceof Re}getBookmark(){return dy}}G.jsonID("all",Re);const dy={map(){return this},resolve(n){return new Re(n)}};function mn(n,e,t,r,s,o=!1){if(e.inlineContent)return q.create(n,t);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!o&&F.isSelectable(l))return F.create(n,t-(s<0?l.nodeSize:0))}else{let a=mn(n,l,t+s,s<0?l.childCount:0,s,o);if(a)return a}t+=l.nodeSize*s}return null}function Wa(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof me||s instanceof ye))return;let o=n.mapping.maps[r],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(G.near(n.doc.resolve(i),t))}const qa=1,Lr=2,Ua=4;class fy extends vd{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|qa)&~Lr,this.storedMarks=null,this}get selectionSet(){return(this.updated&qa)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Lr,this}ensureMarks(e){return ne.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Lr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Lr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(t);o=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(G.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ua,this}get scrolledIntoView(){return(this.updated&Ua)>0}}function Ka(n,e){return!e||!n?n:n.bind(e)}class Jn{constructor(e,t,r){this.name=e,this.init=Ka(t.init,r),this.apply=Ka(t.apply,r)}}const hy=[new Jn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Jn("selection",{init(n,e){return n.selection||G.atStart(e.doc)},apply(n){return n.selection}}),new Jn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Jn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ko{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=hy.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Jn(r.key,r.spec.state,r))})}}class vn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<i?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),o=!0}s&&(s[i]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new vn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new fy(this)}static create(e){let t=new Ko(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new vn(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new Ko(this.schema,e.plugins),r=t.fields,s=new vn(t);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],o=s.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Ko(e.schema,e.plugins),o=new vn(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=_e.fromJSON(e.schema,t.doc);else if(i.name=="selection")o.selection=G.fromJSON(o.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[i.name]=c.fromJSON.call(a,e,t[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function wd(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=wd(s,e,{})),t[r]=s}return t}class ie{constructor(e){this.spec=e,this.props={},e.props&&wd(e.props,this,this.props),this.key=e.key?e.key.key:Sd("plugin")}getState(e){return e[this.key]}}const Jo=Object.create(null);function Sd(n){return n in Jo?n+"$"+ ++Jo[n]:(Jo[n]=0,n+"$")}class ue{constructor(e="key"){this.key=Sd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const xl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Cd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Nd=(n,e,t)=>{let r=Cd(n,t);if(!r)return!1;let s=bl(r);if(!s){let i=r.blockRange(),l=i&&Bn(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(Dd(n,s,e,-1))return!0;if(r.parent.content.size==0&&(En(o,"end")||F.isSelectable(o)))for(let i=r.depth;;i--){let l=io(n.doc,r.before(i),r.after(i),$.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(En(o,"end")?G.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):F.create(a.doc,s.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},py=(n,e,t)=>{let r=Cd(n,t);if(!r)return!1;let s=bl(r);return s?Ed(n,s,e):!1},my=(n,e,t)=>{let r=Md(n,t);if(!r)return!1;let s=kl(r);return s?Ed(n,s,e):!1};function Ed(n,e,t){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=io(n.doc,o,a,$.empty);if(!c||c.from!=o||c instanceof me&&c.slice.size>=a-o)return!1;if(t){let u=n.tr.step(c);u.setSelection(q.create(u.doc,o)),t(u.scrollIntoView())}return!0}function En(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Td=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=bl(r)}let i=o&&o.nodeBefore;return!i||!F.isSelectable(i)?!1:(e&&e(n.tr.setSelection(F.create(n.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function bl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Md(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Od=(n,e,t)=>{let r=Md(n,t);if(!r)return!1;let s=kl(r);if(!s)return!1;let o=s.nodeAfter;if(Dd(n,s,e,1))return!0;if(r.parent.content.size==0&&(En(o,"start")||F.isSelectable(o))){let i=io(n.doc,r.before(),r.after(),$.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(En(o,"start")?G.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):F.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},Ad=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=kl(r)}let i=o&&o.nodeAfter;return!i||!F.isSelectable(i)?!1:(e&&e(n.tr.setSelection(F.create(n.doc,o.pos)).scrollIntoView()),!0)};function kl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const gy=(n,e)=>{let t=n.selection,r=t instanceof F,s;if(r){if(t.node.isTextblock||!Lt(n.doc,t.from))return!1;s=t.from}else if(s=oo(n.doc,t.from,-1),s==null)return!1;if(e){let o=n.tr.join(s);r&&o.setSelection(F.create(o.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},yy=(n,e)=>{let t=n.selection,r;if(t instanceof F){if(t.node.isTextblock||!Lt(n.doc,t.to))return!1;r=t.to}else if(r=oo(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},xy=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),o=s&&Bn(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)},Id=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
30
|
+
`).scrollIntoView()),!0)};function vl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const by=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),o=t.indexAfter(-1),i=vl(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(G.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},jd=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof Re||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=vl(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(i,o.createAndFill());l.setSelection(q.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Rd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(ct(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),s=r&&Bn(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function ky(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof F&&e.selection.node.isBlock)return!r.parentOffset||!ct(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],i,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=vl(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),o.unshift(a&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof q||e.selection instanceof Re)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=ct(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=ct(u.doc,d,o.length,o)),!f)return!1;if(u.split(d,o.length,o),!a&&c&&r.node(i).type!=l){let h=u.mapping.map(r.before(i)),m=u.doc.resolve(h);l&&r.node(i-1).canReplaceWith(m.index(),m.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const vy=ky(),wy=(n,e)=>{let{$from:t,to:r}=n.selection,s,o=t.sharedDepth(r);return o==0?!1:(s=t.before(o),e&&e(n.tr.setSelection(F.create(n.doc,s))),!0)};function Sy(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,o=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||Lt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Dd(n,e,t,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&Sy(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&l.matchType(i[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,m=I.empty;for(let x=i.length-1;x>=0;x--)m=I.from(i[x].create(null,m));m=I.from(s.copy(m));let g=n.tr.step(new ye(e.pos-1,h,e.pos,h,new $(m,1,0),i.length,!0)),y=g.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==s.type&&Lt(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:G.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Bn(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&En(o,"start",!0)&&En(s,"end")){let h=s,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let g=o,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let x=I.empty;for(let v=m.length-1;v>=0;v--)x=I.from(m[v].copy(x));let b=n.tr.step(new ye(e.pos-m.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new $(x,m.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Pd(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(t&&t(e.tr.setSelection(q.create(e.doc,n<0?s.start(o):s.end(o)))),!0):!1}}const Cy=Pd(-1),Ny=Pd(1);function Ey(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&gl(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function Ja(n,e=null){return function(t,r){let s=!1;for(let o=0;o<t.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let u=t.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,n)}})}if(!s)return!1;if(r){let o=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];o.setBlockType(l,a,n,e)}r(o.scrollIntoView())}return!0}}function wl(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}wl(xl,Nd,Td);wl(xl,Od,Ad);wl(Id,jd,Rd,vy);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Ty(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o);if(!i)return!1;let l=r?t.tr:null;return My(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function My(n,e,t,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);o=new ss(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ss(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=gl(o,t,r,e);return l?(n&&Oy(n,e,l,s,t),!0):!1}function Oy(n,e,t,r,s){let o=I.empty;for(let u=t.length-1;u>=0;u--)o=I.from(t[u].type.create(t[u].attrs,o));n.step(new ye(e.start-(r?2:0),e.end,e.start,e.end,new $(o,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==s&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&ct(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Ay(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?Iy(e,t,n,o):jy(e,t,o):!0:!1}}function Iy(n,e,t,r){let s=n.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new ye(o-1,i,o,i,new $(I.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new ss(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=Bn(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Lt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function jy(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,m=t.endIndex-1,g=t.startIndex;m>g;m--)h-=s.child(m).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(t.start),i=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?I.empty:I.from(s))))return!1;let d=o.pos,f=d+i.nodeSize;return r.step(new ye(d-(l?1:0),f+(a?1:0),d+1,f-1,new $((l?I.empty:I.from(s.copy(I.empty))).append(a?I.empty:I.from(s.copy(I.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Ry(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=I.from(c?n.create():null),d=new $(I.from(n.create(null,I.from(l.type.create(null,u)))),c?3:1,0),f=o.start,h=o.end;t(e.tr.step(new ye(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const ke=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Tn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ci=null;const it=function(n,e,t){let r=Ci||(Ci=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Dy=function(){Ci=null},Qt=function(n,e,t,r){return t&&(Ga(n,e,t,r,-1)||Ga(n,e,t,r,1))},Py=/^(img|br|input|textarea|hr)$/i;function Ga(n,e,t,r,s){for(var o;;){if(n==t&&e==r)return!0;if(e==(s<0?0:$e(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Nr(n)||Py.test(n.nodeName)||n.contentEditable=="false")return!1;e=ke(n)+(s<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else n=i,e=s<0?$e(n):0}else return!1}}function $e(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ly(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=$e(n)}else if(n.parentNode&&!Nr(n))e=ke(n),n=n.parentNode;else return null}}function $y(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Nr(n))e=ke(n)+1,n=n.parentNode;else return null}}function _y(n,e,t){for(let r=e==0,s=e==$e(n);r||s;){if(n==t)return!0;let o=ke(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,s=s&&o==$e(n)}}function Nr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const ao=function(n){return n.focusNode&&Qt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function zt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function zy(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function By(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min($e(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min($e(r.startContainer),r.startOffset)}}}const et=typeof navigator<"u"?navigator:null,Ya=typeof document<"u"?document:null,$t=et&&et.userAgent||"",Ni=/Edge\/(\d+)/.exec($t),Ld=/MSIE \d/.exec($t),Ei=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($t),Oe=!!(Ld||Ei||Ni),Et=Ld?document.documentMode:Ei?+Ei[1]:Ni?+Ni[1]:0,ze=!Oe&&/gecko\/(\d+)/i.test($t);ze&&+(/Firefox\/(\d+)/.exec($t)||[0,0])[1];const Ti=!Oe&&/Chrome\/(\d+)/.exec($t),ge=!!Ti,$d=Ti?+Ti[1]:0,Ce=!Oe&&!!et&&/Apple Computer/.test(et.vendor),Mn=Ce&&(/Mobile\/\w+/.test($t)||!!et&&et.maxTouchPoints>2),Le=Mn||(et?/Mac/.test(et.platform):!1),_d=et?/Win/.test(et.platform):!1,at=/Android \d/.test($t),Er=!!Ya&&"webkitFontSmoothing"in Ya.documentElement.style,Fy=Er?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Vy(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function nt(n,e){return typeof n=="number"?n:n[e]}function Hy(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Xa(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=Tn(i);continue}let l=i,a=l==o.body,c=a?Vy(o):Hy(l),u=0,d=0;if(e.top<c.top+nt(r,"top")?d=-(c.top-e.top+nt(s,"top")):e.bottom>c.bottom-nt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+nt(s,"top")-c.top:e.bottom-c.bottom+nt(s,"bottom")),e.left<c.left+nt(r,"left")?u=-(c.left-e.left+nt(s,"left")):e.right>c.right-nt(r,"right")&&(u=e.right-c.right+nt(s,"right")),u||d)if(a)o.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,m=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-m;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:Tn(i)}}function Wy(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(o,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:zd(n.dom)}}function zd(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Tn(r));return e}function qy({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Bd(t,r==0?0:r-e)}function Bd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:o}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let hn=null;function Uy(n){if(n.setActive)return n.setActive();if(hn)return n.focus(hn);let e=zd(n);n.focus(hn==null?{get preventScroll(){return hn={preventScroll:!0},!0}}:void 0),hn||(hn=!1,Bd(e,0))}function Fd(n,e){let t,r=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=it(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let m=f[h];if(m.top<=i&&m.bottom>=l){i=Math.max(m.bottom,i),l=Math.min(m.top,l);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){t=u,r=g,s=g&&t.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(o=d+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!a&&m.left<=e.left&&m.right>=e.left&&(a=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!t&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=d+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?Ky(t,s):!t||r&&t.nodeType==1?{node:n,offset:o}:Fd(t,s)}function Ky(n,e){let t=n.nodeValue.length,r=document.createRange(),s;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let i=mt(r,1);if(i.top!=i.bottom&&Sl(e,i)){s={node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:n,offset:0}}function Sl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Jy(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Gy(n,e,t){let{node:r,offset:s}=Fd(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,s,o)}function Yy(n,e,t,r){let s=-1;for(let o=e,i=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!i&&a.left>r.left||a.top>r.top?s=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function Vd(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=s;;){let i=n.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Sl(e,c))return Vd(i,e,c)}}if((o=(o+1)%r)==s)break}return n}function Xy(n,e){let t=n.dom.ownerDocument,r,s=0,o=By(t,e.left,e.top);o&&({node:r,offset:s}=o);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Sl(e,c)||(i=Vd(n.dom,e,c),!i))return null}if(Ce)for(let c=i;r&&c;c=Tn(c))c.draggable&&(r=void 0);if(i=Jy(i,e),r){if(ze&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;Er&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=Yy(n,r,s,e))}l==null&&(l=Gy(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Qa(n){return n.top<n.bottom||n.left<n.right}function mt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Qa(r))return r}return Array.prototype.find.call(t,Qa)||n.getBoundingClientRect()}const Qy=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Hd(n,e,t){let{node:r,offset:s,atom:o}=n.docView.domFromPos(e,t<0?-1:1),i=Er||ze;if(r.nodeType==3)if(i&&(Qy.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=mt(it(r,s,s),t);if(ze&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=mt(it(r,s-1,s-1),-1);if(c.top==a.top){let u=mt(it(r,s,s+1),-1);if(u.top!=a.top)return Hn(u,u.left<c.left)}}return a}else{let a=s,c=s,u=t<0?1:-1;return t<0&&!s?(c++,u=-1):t>=0&&s==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Hn(mt(it(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(t<0||s==$e(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Go(a.getBoundingClientRect(),!1)}if(o==null&&s<$e(r)){let a=r.childNodes[s];if(a.nodeType==1)return Go(a.getBoundingClientRect(),!0)}return Go(r.getBoundingClientRect(),t>=0)}if(o==null&&s&&(t<0||s==$e(r))){let a=r.childNodes[s-1],c=a.nodeType==3?it(a,$e(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Hn(mt(c,1),!1)}if(o==null&&s<$e(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?it(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Hn(mt(c,-1),!0)}return Hn(mt(r.nodeType==3?it(r):r,-t),t>=0)}function Hn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Go(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Wd(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function Zy(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return Wd(n,e,()=>{let{node:o}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=Hd(n,s.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=it(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const ex=/[\u0590-\u08ac]/;function tx(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,l=n.domSelection();return l?!ex.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:i:Wd(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:m,focusOffset:g}=n.domSelectionRange(),y=m&&!h.contains(m.nodeType==1?m:m.parentNode)||a==m&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):r.pos==r.start()||r.pos==r.end()}let Za=null,ec=null,tc=!1;function nx(n,e,t){return Za==e&&ec==t?tc:(Za=e,ec=t,tc=t=="up"||t=="down"?Zy(n,e,t):tx(n,e,t))}const Be=0,nc=1,Bt=2,tt=3;class Tr{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=Be,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ke(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!t||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],o=r+s.size;if(r==e&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-r-s.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],l=o+i.size;if(l>e||i instanceof Ud){s=e-o;break}o=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof qd&&o.side>=0;r--);if(t<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?ke(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?ke(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ke(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=ke(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let h=0,m=0;h<this.children.length;h++){let g=this.children[h],y=m+g.size;if(o>m&&i<y)return g.setSelection(e-m-g.border,t-m-g.border,r,s);m=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((ze||Ce)&&e==t){let{node:h,offset:m}=l;if(h.nodeType==3){if(d=!!(m&&h.nodeValue[m-1]==`
|
|
31
|
+
`),d&&m==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:ke(y)+1});break}let x=g.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let g=h.childNodes[m-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(ze&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&Ce)&&Qt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Qt(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(d&&ze)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let m=l;l=a,a=m}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?Bt:nc,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=tt:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Bt:tt}r=i}this.dirty=Bt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Bt:nc;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class qd extends Tr{constructor(e,t,r,s){let o,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Be&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class rx extends Tr{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Zt extends Tr{constructor(e,t,r,s,o){super(e,[],r,s),this.mark=t,this.spec=o}static create(e,t,r,s){let o=s.nodeViews[t.type.name],i=o&&o(t,s,r);return(!i||!i.dom)&&(i=nn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Zt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&tt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=tt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Be){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Be}}slice(e,t,r){let s=Zt.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;t<i&&(o=Oi(o,t,i,r)),e>0&&(o=Oi(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Tt extends Tr{constructor(e,t,r,s,o,i,l,a,c){super(e,[],o,i),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,o,i){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=nn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Gd(u,r,t),c?a=new sx(e,t,r,s,u,d||null,f,c,o,i+1):t.isText?new co(e,t,r,s,u,f,o):new Tt(e,t,r,s,u,d||null,f,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>I.empty)}return e}matchesNode(e,t,r){return this.dirty==Be&&e.eq(this.node)&&ls(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new ix(this,i&&i.node,e);cx(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?ne.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,s)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Bt)&&(i&&this.protectLocalComposition(e,i),Kd(this.contentDOM,this.children,e),Mn&&ux(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof q)||r<t||s>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,l=dx(this.node.content,i,r-t,s-t);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new rx(this,o,t,s);e.input.compositionNodes.push(i),this.children=Oi(this.children,r,r+s.length,e,i)}update(e,t,r,s){return this.dirty==tt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Be}updateOuterDeco(e){if(ls(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Jd(this.dom,this.nodeDOM,Mi(this.outerDeco,this.node,t),Mi(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function rc(n,e,t,r,s){Gd(r,e,n);let o=new Tt(void 0,n,e,t,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class co extends Tt{constructor(e,t,r,s,o,i,l){super(e,t,r,s,o,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==tt||this.dirty!=Be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Be||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Be,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),o=document.createTextNode(s.text);return new co(this.parent,s,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=tt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ud extends Tr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class sx extends Tt{constructor(e,t,r,s,o,i,l,a,c,u){super(e,t,r,s,o,i,l,c,u),this.spec=a}update(e,t,r,s){if(this.dirty==tt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Kd(n,e,t){let r=n.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=sc(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(i instanceof Zt){let a=r?r.previousSibling:n.lastChild;Kd(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=sc(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Zn=function(n){n&&(this.nodeName=n)};Zn.prototype=Object.create(null);const Ft=[new Zn];function Mi(n,e,t){if(n.length==0)return Ft;let r=t?Ft[0]:new Zn,s=[r];for(let o=0;o<n.length;o++){let i=n[o].type.attrs;if(i){i.nodeName&&s.push(r=new Zn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(r=new Zn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function Jd(n,e,t,r){if(t==Ft&&r==Ft)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],l=t[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Ft[0]),s=a}ox(s,l||Ft[0],i)}return s}function ox(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&n.classList.add(s[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Gd(n,e,t){return Jd(n,n,Ft,Mi(e,t,n.nodeType!=1))}function ls(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function sc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ix{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=lx(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=Be,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Zt.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))o=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,s,o){let i=this.top.children[s];return i.dirty==tt&&i.dom==i.contentDOM&&(i.dirty=Bt),i.update(e,t,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Tt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=tt&&ls(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,r,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Bt,d.updateChildren(s,i+1),d.dirty=Be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ls(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Tt.create(this.top,t,r,s,o,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,o){let i=Tt.create(this.top,e,t,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new qd(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Zt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof co)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ce||ge)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Ud(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function lx(n,e){let t=e,r=t.children.length,s=n.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Zt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function ax(n,e){return n.type.side-e.type.side}function cx(n,e,t,r){let s=e.locals(n),o=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,s,e.forChild(o,u),c),o+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,d;for(;i<s.length&&s[i].to==o;){let y=s[i++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(ax);for(let y=0;y<d.length;y++)t(d[y],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let m=o+f.nodeSize;if(f.isText){let y=m;i<s.length&&s[i].from<y&&(y=s[i].from);for(let x=0;x<l.length;x++)l[x].to<y&&(y=l[x].to);y<m&&(a=f.cut(y-o),f=f.cut(0,y-o),m=y,h=-1)}else for(;i<s.length&&s[i].to<m;)i++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(o,f),h),o=m}}function ux(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function dx(n,e,t,r){for(let s=0,o=0;s<n.childCount&&o<=r;){let i=n.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Oi(n,e,t,r,s){let o=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,u=l+=a.size;c>=t||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),s&&(o.push(s),s=void 0),u>t&&o.push(a.slice(t-c,a.size,r)))}return o}function Cl(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),o=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(ao(t)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&F.isSelectable(d)&&s.parent&&!(d.isInline&&_y(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new F(i==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=i,f=i;for(let h=0;h<t.rangeCount;h++){let m=t.getRangeAt(h);d=Math.min(d,n.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[a,i]=f==n.state.selection.anchor?[f,d]:[d,f],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;c=Nl(n,u,l,d)}return c}function Yd(n){return n.editable?n.hasFocus():Qd(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ut(n,e=!1){let t=n.state.selection;if(Xd(n,t),!!Yd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ge){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Qt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)hx(n);else{let{anchor:r,head:s}=t,o,i;oc&&!(t instanceof q)&&(t.$from.parent.inlineContent||(o=ic(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=ic(n,t.to))),n.docView.setSelection(r,s,n,e),oc&&(o&&lc(o),i&&lc(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&fx(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const oc=Ce||ge&&$d<63;function ic(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(Ce&&s&&s.contentEditable=="false")return Yo(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Yo(s);if(o)return Yo(o)}}function Yo(n){return n.contentEditable="true",Ce&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function lc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function fx(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Yd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function hx(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,ke(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Oe&&Et<=11&&(t.disabled=!0,t.disabled=!1)}function Xd(n,e){if(e instanceof F){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ac(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ac(n)}function ac(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Nl(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||q.between(e,t,r)}function cc(n){return n.editable&&!n.hasFocus()?!1:Qd(n)}function Qd(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function px(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ai(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),o=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return o&&G.findFrom(o,e)}function gt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function uc(n,e,t){let r=n.state.selection;if(r instanceof q)if(t.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return gt(n,new q(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Ai(n.state,e);return s&&s instanceof F?gt(n,s):!1}else if(!(Le&&t.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?F.isSelectable(o)?gt(n,new F(e<0?n.state.doc.resolve(s.pos-o.nodeSize):s)):Er?gt(n,new q(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof F&&r.node.isInline)return gt(n,new q(e>0?r.$to:r.$from));{let s=Ai(n.state,e);return s?gt(n,s):!1}}}function as(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function er(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function pn(n,e){return e<0?mx(n):gx(n)}function mx(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,o,i=!1;for(ze&&t.nodeType==1&&r<as(t)&&er(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(er(l,-1))s=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Zd(t))break;{let l=t.previousSibling;for(;l&&er(l,-1);)s=t.parentNode,o=ke(l),l=l.previousSibling;if(l)t=l,r=as(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Ii(n,t,r):s&&Ii(n,s,o)}function gx(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=as(t),o,i;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(er(l,1))o=t,i=++r;else break}else{if(Zd(t))break;{let l=t.nextSibling;for(;l&&er(l,1);)o=l.parentNode,i=ke(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=as(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}o&&Ii(n,o,i)}function Zd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function yx(n,e){for(;n&&e==n.childNodes.length&&!Nr(n);)e=ke(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function xx(n,e){for(;n&&!e&&!Nr(n);)e=ke(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Ii(n,e,t){if(e.nodeType!=3){let o,i;(i=yx(e,t))?(e=i,t=0):(o=xx(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(ao(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&ut(n)},50)}function dc(n,e){let t=n.state.doc.resolve(e);if(!(ge||_d)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function fc(n,e,t){let r=n.state.selection;if(r instanceof q&&!r.empty||t.indexOf("s")>-1||Le&&t.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ai(n.state,e);if(i&&i instanceof F)return gt(n,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof Re?G.near(i,e):G.findFrom(i,e);return l?gt(n,l):!1}return!1}function hc(n,e){if(!(n.state.selection instanceof q))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let i=n.state.tr;return e<0?i.delete(t.pos-o.nodeSize,t.pos):i.delete(t.pos,t.pos+o.nodeSize),n.dispatch(i),!0}return!1}function pc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function bx(n){if(!Ce||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;pc(n,r,"true"),setTimeout(()=>pc(n,r,"false"),20)}return!1}function kx(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function vx(n,e){let t=e.keyCode,r=kx(e);if(t==8||Le&&t==72&&r=="c")return hc(n,-1)||pn(n,-1);if(t==46&&!e.shiftKey||Le&&t==68&&r=="c")return hc(n,1)||pn(n,1);if(t==13||t==27)return!0;if(t==37||Le&&t==66&&r=="c"){let s=t==37?dc(n,n.state.selection.from)=="ltr"?-1:1:-1;return uc(n,s,r)||pn(n,s)}else if(t==39||Le&&t==70&&r=="c"){let s=t==39?dc(n,n.state.selection.from)=="ltr"?1:-1:1;return uc(n,s,r)||pn(n,s)}else{if(t==38||Le&&t==80&&r=="c")return fc(n,-1,r)||pn(n,-1);if(t==40||Le&&t==78&&r=="c")return bx(n)||fc(n,1,r)||pn(n,1);if(r==(Le?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function El(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||nn.fromSchema(n.state.schema),l=of(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=sf[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=l.createElement(u[h]);for(;a.firstChild;)m.appendChild(a.firstChild);a.appendChild(m),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
32
|
+
|
|
33
|
+
`);return{dom:a,text:f,slice:e}}function ef(n,e,t,r,s){let o=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=!!e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,o||r,n)}),o)return l=new $(I.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
34
|
+
`))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(d)l=d;else{let f=s.marks(),{schema:h}=n.state,m=nn.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=i.appendChild(document.createElement("p"));g&&y.appendChild(m.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),i=Nx(t),Er&&Ex(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Nt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!wx.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Tx(mc(l,+u[1],+u[2]),u[4]);else if(l=$.maxOpen(Sx(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=mc(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n,a)}),l}const wx=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Sx(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),o,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&nf(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=rf(i[i.length-1],o.length));let u=tf(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return I.from(i)}return n}function tf(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,I.from(n));return n}function nf(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let o=nf(n,e,t,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(I.from(tf(t,n,s+1))))}}function rf(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,rf(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(I.empty,!0);return n.copy(t.append(r))}function ji(n,e,t,r,s,o){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(o=0),s<r-1&&(l=ji(l,e,t,r,s+1,o)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(I.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function mc(n,e,t){return e<n.openStart&&(n=new $(ji(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new $(ji(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const sf={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let gc=null;function of(){return gc||(gc=document.implementation.createHTMLDocument("title"))}let Xo=null;function Cx(n){let e=window.trustedTypes;return e?(Xo||(Xo=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Xo.createHTML(n)):n}function Nx(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=of().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&sf[r[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=Cx(n),s)for(let o=0;o<s.length;o++)t=t.querySelector(s[o])||t;return t}function Ex(n){let e=n.querySelectorAll(ge?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Tx(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:o,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=I.from(a.create(r[l+1],s)),o++,i++}return new $(s,o,i)}const Ee={},Te={},Mx={touchstart:!0,touchmove:!0};class Ox{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ax(n){for(let e in Ee){let t=Ee[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{jx(n,r)&&!Tl(n,r)&&(n.editable||!(r.type in Te))&&t(n,r)},Mx[e]?{passive:!0}:void 0)}Ce&&n.dom.addEventListener("input",()=>null),Ri(n)}function St(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Ix(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Ri(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Tl(n,r))})}function Tl(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function jx(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Rx(n,e){!Tl(n,e)&&Ee[e.type]&&(n.editable||!(e.type in Te))&&Ee[e.type](n,e)}Te.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!af(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(at&&ge&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Mn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,zt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||vx(n,t)?t.preventDefault():St(n,"key")};Te.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Te.keypress=(n,e)=>{let t=e;if(af(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Le&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s,o))&&n.dispatch(o()),t.preventDefault()}};function uo(n){return{left:n.clientX,top:n.clientY}}function Dx(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ml(n,e,t,r,s){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(n.someProp(e,l=>i>o.depth?l(n,t,o.nodeAfter,o.before(i),s,!0):l(n,t,o.node(i),o.before(i),s,!1)))return!0;return!1}function Sn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Px(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&F.isSelectable(r)?(Sn(n,new F(t)),!0):!1}function Lx(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof F&&(r=t.node);let o=n.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if(F.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?s=o.before(t.$from.depth):s=o.before(i);break}}return s!=null?(Sn(n,F.create(n.state.doc,s)),!0):!1}function $x(n,e,t,r,s){return Ml(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(s?Lx(n,t):Px(n,t))}function _x(n,e,t,r){return Ml(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function zx(n,e,t,r){return Ml(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||Bx(n,t,r)}function Bx(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Sn(n,q.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),l=s.before(o);if(i.inlineContent)Sn(n,q.create(r,l+1,l+1+i.content.size));else if(F.isSelectable(i))Sn(n,F.create(r,l));else continue;return!0}}function Ol(n){return cs(n)}const lf=Le?"metaKey":"ctrlKey";Ee.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Ol(n),s=Date.now(),o="singleClick";s-n.input.lastClick.time<500&&Dx(t,n.input.lastClick)&&!t[lf]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:o,button:t.button};let i=n.posAtCoords(uo(t));i&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Fx(n,i,t,!!r)):(o=="doubleClick"?_x:zx)(n,i.pos,i.inside,t)?t.preventDefault():St(n,"pointer"))};class Fx{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[lf],this.allowDefault=r.shiftKey;let o,i;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,i=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof F&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ze&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),St(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ut(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(uo(e))),this.updateAllowDefault(e),this.allowDefault||!t?St(this.view,"pointer"):$x(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ce&&this.mightDrag&&!this.mightDrag.node.isAtom||ge&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Sn(this.view,G.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):St(this.view,"pointer")}move(e){this.updateAllowDefault(e),St(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ee.touchstart=n=>{n.input.lastTouch=Date.now(),Ol(n),St(n,"pointer")};Ee.touchmove=n=>{n.input.lastTouch=Date.now(),St(n,"pointer")};Ee.contextmenu=n=>Ol(n);function af(n,e){return n.composing?!0:Ce&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Vx=at?5e3:-1;Te.compositionstart=Te.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof q&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ge&&_d&&Hx(n)))n.markCursor=n.state.storedMarks||t.marks(),cs(n,!0),n.markCursor=null;else if(cs(n,!e.selection.empty),ze&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}n.input.composing=!0}cf(n,Vx)};function Hx(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Te.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,cf(n,20))};function cf(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>cs(n),e))}function uf(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=qx());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Wx(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Ly(e.focusNode,e.focusOffset),r=$y(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function qx(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function cs(n,e=!1){if(!(at&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),uf(n),e||n.docView&&n.docView.dirty){let t=Cl(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ux(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const hr=Oe&&Et<15||Mn&&Fy<604;Ee.copy=Te.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let o=hr?null:t.clipboardData,i=r.content(),{dom:l,text:a}=El(n,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Ux(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Kx(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Jx(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?pr(n,r.value,null,s,e):pr(n,r.textContent,r.innerHTML,s,e)},50)}function pr(n,e,t,r,s){let o=ef(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,o||$.empty)))return!0;if(!o)return!1;let i=Kx(o),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function df(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Te.paste=(n,e)=>{let t=e;if(n.composing&&!at)return;let r=hr?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&pr(n,df(r),r.getData("text/html"),s,t)?t.preventDefault():Jx(n,t)};class ff{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Gx=Le?"altKey":"ctrlKey";function hf(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Gx]}Ee.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,o=s.empty?null:n.posAtCoords(uo(t)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof F?s.to-1:s.to))){if(r&&r.mightDrag)i=F.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(i=F.create(n.state.doc,d.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=El(n,l);(!t.dataTransfer.files.length||!ge||$d>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(hr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",hr||t.dataTransfer.setData("text/plain",c),n.dragging=new ff(u,hf(n,t),i)};Ee.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Te.dragover=Te.dragenter=(n,e)=>e.preventDefault();Te.drop=(n,e)=>{try{Yx(n,e,n.dragging)}finally{n.dragging=null}};function Yx(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(uo(e));if(!r)return;let s=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=ef(n,df(e.dataTransfer),hr?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(t&&hf(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||$.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?gd(n.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let a=n.state.tr;if(i){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&F.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new F(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((m,g,y,x)=>h=x),a.setSelection(Nl(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ee.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ut(n)},20))};Ee.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ee.beforeinput=(n,e)=>{if(ge&&at&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,zt(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Te)Ee[n]=Te[n];function mr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class us{constructor(e,t){this.toDOM=e,this.spec=t||Ut,this.side=this.spec.side||0}map(e,t,r,s){let{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new Se(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof us&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&mr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Mt{constructor(e,t){this.attrs=e,this.spec=t||Ut}map(e,t,r,s){let o=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new Se(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Mt&&mr(this.attrs,e.attrs)&&mr(this.spec,e.spec)}static is(e){return e.type instanceof Mt}destroy(){}}class Al{constructor(e,t){this.attrs=e,this.spec=t||Ut}map(e,t,r,s){let o=e.mapResult(t.from+s,1);if(o.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=o.pos?null:new Se(o.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),o;return s==t.from&&!(o=e.child(r)).isText&&s+o.nodeSize==t.to}eq(e){return this==e||e instanceof Al&&mr(this.attrs,e.attrs)&&mr(this.spec,e.spec)}destroy(){}}class Se{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Se(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Se(e,e,new us(t,r))}static inline(e,t,r,s){return new Se(e,t,new Mt(r,s))}static node(e,t,r,s){return new Se(e,t,new Al(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Mt}get widget(){return this.type instanceof us}}const gn=[],Ut={};class se{constructor(e,t){this.local=e.length?e:gn,this.children=t.length?t:gn}static create(e,t){return t.length?ds(t,e,0,Ut):we}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,s+l,o)}}map(e,t,r){return this==we||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ut)}mapInner(e,t,r,s,o){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?Xx(this.children,i||[],e,t,r,s,o):i?new se(i.sort(Kt),gn):we}add(e,t){return t.length?this==we?se.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=mf(t,l,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<a;)o+=3;s[o]==a?s[o+2]=s[o+2].addInner(l,u,c+1):s.splice(o,0,a,a+l.nodeSize,ds(u,l,c+1,Ut)),o+=3}});let i=pf(o?gf(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new se(i.length?this.local.concat(i).sort(Kt):this.local,s||this.children)}remove(e){return e.length==0||this==we?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,l=r[o]+t,a=r[o+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,l+1);c!=we?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new se(s,r):we}forChild(e,t){if(this==we)return this;if(t.isLeaf)return se.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,i=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>o&&a.type instanceof Mt){let c=Math.max(o,a.from)-o,u=Math.min(i,a.to)-o;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new se(s.sort(Kt),gn);return r?new bt([l,r]):l}return r||we}eq(e){if(this==e)return!0;if(!(e instanceof se)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Il(this.localsInner(e))}localsInner(e){if(this==we)return gn;if(e.inlineContent||!this.local.some(Mt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Mt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}se.empty=new se([],[]);se.removeOverlap=Il;const we=se.empty;class bt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,Ut));return bt.from(r)}forChild(e,t){if(t.isLeaf)return se.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,t);o!=we&&(o instanceof bt?r=r.concat(o.members):r.push(o))}return bt.from(r)}eq(e){if(!(e instanceof bt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?Il(r?t:t.sort(Kt)):gn}static from(e){switch(e.length){case 0:return we;case 1:return e[0];default:return new bt(e.every(t=>t instanceof se)?e:e.reduce((t,r)=>t.concat(r instanceof se?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Xx(n,e,t,r,s,o,i){let l=n.slice();for(let c=0,u=o;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,m,g)=>{let y=g-m-(h-f);for(let x=0;x<l.length;x+=3){let b=l[x+1];if(b<0||f>b+u-d)continue;let v=l[x]+u-d;h>=v?l[x+1]=f<=v?-2:-1:f>=u&&y&&(l[x]+=y,l[x+1]+=y)}d+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+o),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+o,-1),h=f-s,{index:m,offset:g}=r.content.findIndex(d),y=r.maybeChild(m);if(y&&g==d&&g+y.nodeSize==h){let x=l[c+2].mapInner(t,y,u+1,n[c]+o+1,i);x!=we?(l[c]=d,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Qx(l,n,e,t,s,o,i),u=ds(c,r,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new se(e.sort(Kt),l)}function pf(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new Se(s.from+e,s.to+e,s.type))}return t}function Qx(n,e,t,r,s,o,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?t.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function mf(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let o=0,i;o<n.length;o++)(i=n[o])&&i.from>t&&i.to<r&&((s||(s=[])).push(i),n[o]=null);return s}function gf(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function ds(n,e,t,r){let s=[],o=!1;e.forEach((l,a)=>{let c=mf(n,l,a+t);if(c){o=!0;let u=ds(c,l,t+a+1,r);u!=we&&s.push(a,a+l.nodeSize,u)}});let i=pf(o?gf(n):n,-t).sort(Kt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new se(i,s):we}function Kt(n,e){return n.from-e.from||n.to-e.to}function Il(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[s]=o.copy(o.from,r.to),yc(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),yc(e,s,r.copy(o.from,r.to)));break}}}return e}function yc(n,e,t){for(;e<n.length&&Kt(t,n[e])>0;)e++;n.splice(e,0,t)}function Qo(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=we&&e.push(r)}),n.cursorWrapper&&e.push(se.create(n.state.doc,[n.cursorWrapper.deco])),bt.from(e)}const Zx={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},eb=Oe&&Et<=11;class tb{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class nb{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new tb,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Oe&&Et<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),eb&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Zx)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(cc(this.view)){if(this.suppressingSelectionUpdates)return ut(this.view);if(Oe&&Et<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Tn(o))t.add(o);for(let o=e.anchorNode;o;o=Tn(o))if(t.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&cc(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(o=o<0?d.from:Math.min(d.from,o),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(l=!0))}if(ze&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||ob(e,d)!=h)&&f.remove()}}}else if((ge||Ce)&&a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;d&&d.nodeType==1&&d.contentEditable=="false"&&u.parentNode.removeChild(u)}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ao(r)&&(c=Cl(e))&&c.eq(G.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ut(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),rb(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ut(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,o=e.nextSibling;if(Oe&&Et<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?ke(s)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?ke(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let xc=new WeakMap,bc=!1;function rb(n){if(!xc.has(n)&&(xc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=ze,bc)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),bc=!0}}function kc(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Qt(i.node,i.offset,s,o)&&([t,r,s,o]=[s,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:o}}function sb(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return kc(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?kc(n,t):null}function ob(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function ib(n,e,t){let{node:r,fromOffset:s,toOffset:o,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],ao(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ge&&n.input.lastKeyCode===8)for(let y=o;y>s;y--){let x=r.childNodes[y-1],b=x.pmViewDesc;if(x.nodeName=="BR"&&!b){o=y;break}if(!b||b.size)break}let d=n.state.doc,f=n.someProp("domParser")||Nt.fromSchema(n.state.schema),h=d.resolve(i),m=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:lb,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=y),m={anchor:y+i,head:x+i}}return{doc:g,sel:m,from:i,to:l}}function lb(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Ce&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Ce&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ab=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function cb(n,e,t,r,s){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let S=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,M=Cl(n,S);if(M&&!n.state.selection.eq(M)){if(ge&&at&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",E=>E(n,zt(13,"Enter"))))return;let T=n.state.tr.setSelection(M);S=="pointer"?T.setMeta("pointer",!0):S=="key"&&T.scrollIntoView(),o&&T.setMeta("composition",o),n.dispatch(T)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=ib(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=fb(d.content,c.doc.content,c.from,f,h);if(m&&n.input.domChangeCount++,(Mn&&n.input.lastIOSEnter>Date.now()-225||at)&&s.some(S=>S.nodeType==1&&!ab.test(S.nodeName))&&(!m||m.endA>=m.endB)&&n.someProp("handleKeyDown",S=>S(n,zt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!m)if(r&&a instanceof q&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let S=vc(n,n.state.doc,c.sel);if(S&&!S.eq(n.state.selection)){let M=n.state.tr.setSelection(S);o&&M.setMeta("composition",o),n.dispatch(M)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof q&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to)),Oe&&Et<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)==" "&&(m.start--,m.endA--,m.endB--);let g=c.doc.resolveNoCache(m.start-c.from),y=c.doc.resolveNoCache(m.endB-c.from),x=u.resolve(m.start),b=g.sameParent(y)&&g.parent.inlineContent&&x.end()>=m.endA;if((Mn&&n.input.lastIOSEnter>Date.now()-225&&(!b||s.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!b&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&n.someProp("handleKeyDown",S=>S(n,zt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&db(u,m.start,m.endA,g,y)&&n.someProp("handleKeyDown",S=>S(n,zt(8,"Backspace")))){at&&ge&&n.domObserver.suppressSelectionUpdates();return}ge&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),at&&!b&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,y=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(S){return S(n,zt(13,"Enter"))})},20));let v=m.start,C=m.endA,k=S=>{let M=S||n.state.tr.replace(v,C,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let T=vc(n,M.doc,c.sel);T&&!(ge&&n.composing&&T.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(T.head==v||T.head==M.mapping.map(C)-1)||Oe&&T.empty&&T.head==v)&&M.setSelection(T)}return o&&M.setMeta("composition",o),M.scrollIntoView()},w;if(b)if(g.pos==y.pos){Oe&&Et<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ut(n),20));let S=k(n.state.tr.delete(v,C)),M=u.resolve(m.start).marksAcross(u.resolve(m.endA));M&&S.ensureMarks(M),n.dispatch(S)}else if(m.endA==m.endB&&(w=ub(g.parent.content.cut(g.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let S=k(n.state.tr);w.type=="add"?S.addMark(v,C,w.mark):S.removeMark(v,C,w.mark),n.dispatch(S)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let S=g.parent.textBetween(g.parentOffset,y.parentOffset),M=()=>k(n.state.tr.insertText(S,v,C));n.someProp("handleTextInput",T=>T(n,v,C,S,M))||n.dispatch(M())}else n.dispatch(k());else n.dispatch(k())}function vc(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Nl(n,e.resolve(t.anchor),e.resolve(t.head))}function ub(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,o=r,i,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(I.from(c).eq(n))return{mark:l,type:i}}function db(n,e,t,r,s){if(t-e<=s.pos-r.pos||Zo(r,!0,!1)<s.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=n.resolve(Zo(o,!0,!0));return!i.parent.isTextblock||i.pos>t||Zo(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Zo(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function fb(n,e,t,r,s){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));r-=i+a-o}if(i<o&&n.size<e.size){let a=r<=o&&r>=i?o-r:0;o-=a,o&&o<e.size&&wc(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-i),i=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<n.size&&wc(n.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function wc(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class yf{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ox,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Tc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Nc(this),Cc(this),this.nodeViews=Ec(this),this.docView=rc(this.state.doc,Sc(this),Qo(this),this.dom,this),this.domObserver=new nb(this,(r,s,o,i)=>cb(this,r,s,o,i)),this.domObserver.start(),Ax(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ri(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Tc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(uf(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ec(this);pb(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ri(this),this.editable=Nc(this),Cc(this);let a=Qo(this),c=Sc(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Wy(this);if(i){this.domObserver.stop();let h=d&&(Oe||ge)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&hb(s.selection,e.selection);if(d){let m=ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Wx(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=rc(e.doc,c,a,this.dom,this)),m&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&px(this))?ut(this,h):(Xd(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&qy(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof F){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Xa(this,t.getBoundingClientRect(),e)}else Xa(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new ff(e.slice,e.move,s<0?void 0:F.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let l=o[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(Oe){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Uy(this.dom),ut(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Xy(this,e)}coordsAtPos(e,t=1){return Hd(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return nx(this,t||this.state,e)}pasteHTML(e,t){return pr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return pr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return El(this,e)}destroy(){this.docView&&(Ix(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Dy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Rx(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ce&&this.root.nodeType===11&&zy(this.dom.ownerDocument)==this.dom&&sb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}yf.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Sc(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Se.node(0,n.state.doc.content.size,e)]}function Cc(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Se.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Nc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function hb(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ec(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function pb(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function Tc(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ot={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},fs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mb=typeof navigator<"u"&&/Mac/.test(navigator.platform),gb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ve=0;ve<10;ve++)Ot[48+ve]=Ot[96+ve]=String(ve);for(var ve=1;ve<=24;ve++)Ot[ve+111]="F"+ve;for(var ve=65;ve<=90;ve++)Ot[ve]=String.fromCharCode(ve+32),fs[ve]=String.fromCharCode(ve);for(var ei in Ot)fs.hasOwnProperty(ei)||(fs[ei]=Ot[ei]);function yb(n){var e=mb&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||gb&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?fs:Ot)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const xb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),bb=typeof navigator<"u"&&/Win/.test(navigator.platform);function kb(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))xb?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function vb(n){let e=Object.create(null);for(let t in n)e[kb(t)]=n[t];return e}function ti(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function wb(n){return new ie({props:{handleKeyDown:xf(n)}})}function xf(n){let e=vb(n);return function(t,r){let s=yb(r),o,i=e[ti(s,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[ti(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(bb&&r.ctrlKey&&r.altKey)&&(o=Ot[r.keyCode])&&o!=s){let l=e[ti(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Sb=Object.defineProperty,jl=(n,e)=>{for(var t in e)Sb(n,t,{get:e[t],enumerable:!0})};function fo(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,o=t.storedMarks,t}}}var ho=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:s}=t,o=this.buildProps(s);return Object.fromEntries(Object.entries(n).map(([i,l])=>[i,(...c)=>{const u=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i=[],l=!!n,a=n||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(a),i.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(t).map(([d,f])=>[d,(...m)=>{const g=this.buildProps(a,e),y=f(...m)(g);return i.push(y),u}])),run:c};return u}createCan(n){const{rawCommands:e,state:t}=this,r=!1,s=n||t.tr,o=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i={tr:n,editor:r,view:o,state:fo({state:s,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(i)]))}};return i}},bf={};jl(bf,{blur:()=>Cb,clearContent:()=>Nb,clearNodes:()=>Eb,command:()=>Tb,createParagraphNear:()=>Mb,cut:()=>Ob,deleteCurrentNode:()=>Ab,deleteNode:()=>Ib,deleteRange:()=>jb,deleteSelection:()=>Rb,enter:()=>Db,exitCode:()=>Pb,extendMarkRange:()=>Lb,first:()=>$b,focus:()=>_b,forEach:()=>zb,insertContent:()=>Bb,insertContentAt:()=>Hb,joinBackward:()=>Ub,joinDown:()=>qb,joinForward:()=>Kb,joinItemBackward:()=>Jb,joinItemForward:()=>Gb,joinTextblockBackward:()=>Yb,joinTextblockForward:()=>Xb,joinUp:()=>Wb,keyboardShortcut:()=>Zb,lift:()=>ek,liftEmptyBlock:()=>tk,liftListItem:()=>nk,newlineInCode:()=>rk,resetAttributes:()=>sk,scrollIntoView:()=>ok,selectAll:()=>ik,selectNodeBackward:()=>lk,selectNodeForward:()=>ak,selectParentNode:()=>ck,selectTextblockEnd:()=>uk,selectTextblockStart:()=>dk,setContent:()=>fk,setMark:()=>jk,setMeta:()=>Rk,setNode:()=>Dk,setNodeSelection:()=>Pk,setTextDirection:()=>Lk,setTextSelection:()=>$k,sinkListItem:()=>_k,splitBlock:()=>zk,splitListItem:()=>Bk,toggleList:()=>Fk,toggleMark:()=>Vk,toggleNode:()=>Hk,toggleWrap:()=>Wk,undoInputRule:()=>qk,unsetAllMarks:()=>Uk,unsetMark:()=>Kk,unsetTextDirection:()=>Jk,updateAttributes:()=>Gk,wrapIn:()=>Yk,wrapInList:()=>Xk});var Cb=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),Nb=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),Eb=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:o,$to:i})=>{n.doc.nodesBetween(o.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const m=Bn(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(m||m===0)&&e.lift(h,m)})}),!0},Tb=n=>e=>n(e),Mb=()=>({state:n,dispatch:e})=>jd(n,e),Ob=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,o=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new q(r.doc.resolve(Math.max(i-1,0)))),!0},Ab=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(e){const l=s.before(o),a=s.after(o);n.delete(l,a).scrollIntoView()}return!0}return!1};function pe(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var Ib=n=>({tr:e,state:t,dispatch:r})=>{const s=pe(n,t.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const a=o.before(i),c=o.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},jb=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},Rb=()=>({state:n,dispatch:e})=>xl(n,e),Db=()=>({commands:n})=>n.keyboardShortcut("Enter"),Pb=()=>({state:n,dispatch:e})=>by(n,e);function Rl(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function hs(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:Rl(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function kf(n,e,t={}){return n.find(r=>r.type===e&&hs(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function Mc(n,e,t={}){return!!kf(n,e,t)}function Dl(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(t=t||((r=s.node.marks[0])==null?void 0:r.attrs),!kf([...s.node.marks],e,t)))return;let i=s.index,l=n.start()+s.offset,a=i+1,c=l+s.node.nodeSize;for(;i>0&&Mc([...n.parent.child(i-1).marks],e,t);)i-=1,l-=n.parent.child(i).nodeSize;for(;a<n.parent.childCount&&Mc([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function ft(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var Lb=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const o=ft(n,r.schema),{doc:i,selection:l}=t,{$from:a,from:c,to:u}=l;if(s){const d=Dl(a,o,e);if(d&&d.from<=c&&d.to>=u){const f=q.create(i,d.from,d.to);t.setSelection(f)}}return!0},$b=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function vf(n){return n instanceof q}function Vt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function wf(n,e=null){if(!e)return null;const t=G.atStart(n),r=G.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,o=r.to;return e==="all"?q.create(n,Vt(0,s,o),Vt(n.content.size,s,o)):q.create(n,Vt(e,s,o),Vt(e,s,o))}function Sf(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function po(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var _b=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(po()||Sf())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!vf(t.state.selection))return i(),!0;const l=wf(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return o&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},zb=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),Bb=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Cf=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Cf(r)}return n};function $r(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Cf(t)}function gr(n,e,t){if(n instanceof _e||n instanceof I)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return I.fromArray(n.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),gr("",e,t)}if(s){if(t.errorOnInvalidContent){let i=!1,l="";const a=new od({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Nt.fromSchema(a).parseSlice($r(n),t.parseOptions):Nt.fromSchema(a).parse($r(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=Nt.fromSchema(e);return t.slice?o.parseSlice($r(n),t.parseOptions).content:o.parse($r(n),t.parseOptions)}return gr("",e,t)}function Fb(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof me||s instanceof ye))return;const o=n.mapping.maps[r];let i=0;o.forEach((l,a,c,u)=>{i===0&&(i=u)}),n.setSelection(G.near(n.doc.resolve(i),t))}var Vb=n=>!("type"in n),Hb=(n,e,t)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=y=>{o.emit("contentError",{editor:o,error:y,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{gr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=gr(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:o.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((Vb(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===d&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof I){let y="";e.forEach(x=>{x.text&&(y+=x.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else{g=l;const y=r.doc.resolve(u),x=y.node(),b=y.parentOffset===0,v=x.isText||x.isTextblock,C=x.content.size>0;b&&v&&C&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}t.updateSelection&&Fb(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},Wb=()=>({state:n,dispatch:e})=>gy(n,e),qb=()=>({state:n,dispatch:e})=>yy(n,e),Ub=()=>({state:n,dispatch:e})=>Nd(n,e),Kb=()=>({state:n,dispatch:e})=>Od(n,e),Jb=()=>({state:n,dispatch:e,tr:t})=>{try{const r=oo(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Gb=()=>({state:n,dispatch:e,tr:t})=>{try{const r=oo(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Yb=()=>({state:n,dispatch:e})=>py(n,e),Xb=()=>({state:n,dispatch:e})=>my(n,e);function Nf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Qb(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))po()||Nf()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),o&&(t=`Shift-${t}`),t}var Zb=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const o=Qb(n).split(/-(?!$)/),i=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function At(n,e,t={}){const{from:r,to:s,empty:o}=n.selection,i=e?pe(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),m=Math.min(s,f+d.nodeSize);l.push({node:d,from:h,to:m})});const a=s-r,c=l.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>hs(d.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}var ek=(n,e={})=>({state:t,dispatch:r})=>{const s=pe(n,t.schema);return At(t,s,e)?xy(t,r):!1},tk=()=>({state:n,dispatch:e})=>Rd(n,e),nk=n=>({state:e,dispatch:t})=>{const r=pe(n,e.schema);return Ay(r)(e,t)},rk=()=>({state:n,dispatch:e})=>Id(n,e);function mo(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Oc(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}var sk=(n,e)=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=mo(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=pe(n,r.schema)),l==="mark"&&(i=ft(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{o&&o===u.type&&(a=!0,s&&t.setNodeMarkup(d,void 0,Oc(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(f=>{i===f.type&&(a=!0,s&&t.addMark(d,d+u.nodeSize,i.create(Oc(f.attrs,e))))})})}),a},ok=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),ik=()=>({tr:n,dispatch:e})=>{if(e){const t=new Re(n.doc);n.setSelection(t)}return!0},lk=()=>({state:n,dispatch:e})=>Td(n,e),ak=()=>({state:n,dispatch:e})=>Ad(n,e),ck=()=>({state:n,dispatch:e})=>wy(n,e),uk=()=>({state:n,dispatch:e})=>Ny(n,e),dk=()=>({state:n,dispatch:e})=>Cy(n,e);function Di(n,e,t={},r={}){return gr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var fk=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=Di(n,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return i&&o.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return i&&o.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Ef(n,e){const t=ft(e,n.schema),{from:r,to:s,empty:o}=n.selection,i=[];o?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Tf(n,e){const t=new vd(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function hk(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function pk(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,o)=>{t(s)&&r.push({node:s,pos:o})}),r}function mk(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function go(n){return e=>mk(e.$from,n)}function V(n,e,t){return n.config[e]===void 0&&n.parent?V(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?V(n.parent,e,t):null}):n.config[e]}function Pl(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=V(e,"addExtensions",t);return r?[e,...Pl(r())]:e}).flat(10)}function Ll(n,e){const t=nn.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function Mf(n){return typeof n=="function"}function ee(n,e=void 0,...t){return Mf(n)?e?n.bind(e)(...t):n(...t):n}function gk(n={}){return Object.keys(n).length===0&&n.constructor===Object}function On(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Of(n){const e=[],{nodeExtensions:t,markExtensions:r}=On(n),s=[...t,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage,extensions:s},a=V(i,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...o,...h}})})})})}),s.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage},a=V(i,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const f={...o,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:i.name,name:u,attribute:f})})}),e}function oe(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,o])=>{if(!r[s]){r[s]=o;return}if(s==="class"){const l=o?String(o).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),l.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),r[s]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[s]=o}),r},{})}function yr(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>oe(t,r),{})}function yk(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Ac(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(t):yk(t.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function Ic(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&gk(t)?!1:t!=null))}function jc(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function xk(n,e){var t;const r=Of(n),{nodeExtensions:s,markExtensions:o}=On(n),i=(t=s.find(c=>V(c,"topNode")))==null?void 0:t.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(x=>x.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((x,b)=>{const v=V(b,"extendNodeSchema",d);return{...x,...v?v(c):{}}},{}),h=Ic({...f,content:ee(V(c,"content",d)),marks:ee(V(c,"marks",d)),group:ee(V(c,"group",d)),inline:ee(V(c,"inline",d)),atom:ee(V(c,"atom",d)),selectable:ee(V(c,"selectable",d)),draggable:ee(V(c,"draggable",d)),code:ee(V(c,"code",d)),whitespace:ee(V(c,"whitespace",d)),linebreakReplacement:ee(V(c,"linebreakReplacement",d)),defining:ee(V(c,"defining",d)),isolating:ee(V(c,"isolating",d)),attrs:Object.fromEntries(u.map(jc))}),m=ee(V(c,"parseHTML",d));m&&(h.parseDOM=m.map(x=>Ac(x,u)));const g=V(c,"renderHTML",d);g&&(h.toDOM=x=>g({node:x,HTMLAttributes:yr(x,u)}));const y=V(c,"renderText",d);return y&&(h.toText=y),[c.name,h]})),a=Object.fromEntries(o.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,x)=>{const b=V(x,"extendMarkSchema",d);return{...y,...b?b(c):{}}},{}),h=Ic({...f,inclusive:ee(V(c,"inclusive",d)),excludes:ee(V(c,"excludes",d)),group:ee(V(c,"group",d)),spanning:ee(V(c,"spanning",d)),code:ee(V(c,"code",d)),attrs:Object.fromEntries(u.map(jc))}),m=ee(V(c,"parseHTML",d));m&&(h.parseDOM=m.map(y=>Ac(y,u)));const g=V(c,"renderHTML",d);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:yr(y,u)})),[c.name,h]}));return new od({topNode:i,nodes:l,marks:a})}function bk(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function $l(n){return n.sort((t,r)=>{const s=V(t,"priority")||100,o=V(r,"priority")||100;return s>o?-1:s<o?1:0})}function Af(n){const e=$l(Pl(n)),t=bk(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function If(n,e,t){const{from:r,to:s}=e,{blockSeparator:o=`
|
|
35
|
+
|
|
36
|
+
`,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=o);const h=i?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function kk(n,e){const t={from:0,to:n.content.size};return If(n,t,e)}function jf(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function vk(n,e){const t=pe(e,n.schema),{from:r,to:s}=n.selection,o=[];n.doc.nodesBetween(r,s,l=>{o.push(l)});const i=o.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function Rf(n,e){const t=mo(typeof e=="string"?e:e.name,n.schema);return t==="node"?vk(n,e):t==="mark"?Ef(n,e):{}}function wk(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function Sk(n){const e=wk(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,i)=>i!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function Df(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((l,a)=>{i.push({from:l,to:a})});else{const{from:l,to:a}=t[o];if(l===void 0||a===void 0)return;i.push({from:l,to:a})}i.forEach(({from:l,to:a})=>{const c=e.slice(o).map(l,-1),u=e.slice(o).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),Sk(r)}function _l(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const o=t.resolve(n),i=Dl(o,s.type);i&&r.push({mark:s,...i})}):t.nodesBetween(n,e,(s,o)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}var Ck=(n,e,t,r=20)=>{const s=n.doc.resolve(t);let o=r,i=null;for(;o>0&&i===null;){const l=s.node(o);l?.type.name===e?i=l:o-=1}return[i,o]};function ni(n,e){return e.nodes[n]||e.marks[n]||null}function Jr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}var Nk=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,o,i,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:o,parent:i,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-o))}),t};function Pi(n,e,t={}){const{empty:r,ranges:s}=n.selection,o=e?ft(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>hs(d.attrs,t,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:d,$to:f})=>{const h=d.pos,m=f.pos;n.doc.nodesBetween(h,m,(g,y)=>{if(!g.isText&&!g.marks.length)return;const x=Math.max(h,y),b=Math.min(m,y+g.nodeSize),v=b-x;i+=v,l.push(...g.marks.map(C=>({mark:C,from:x,to:b})))})}),i===0)return!1;const a=l.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>hs(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>o?d.mark.type!==o&&d.mark.type.excludes(o):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=i}function Ek(n,e,t={}){if(!e)return At(n,null,t)||Pi(n,null,t);const r=mo(e,n.schema);return r==="node"?At(n,e,t):r==="mark"?Pi(n,e,t):!1}var Tk=(n,e)=>{const{$from:t,$to:r,$anchor:s}=n.selection;if(e){const o=go(l=>l.type.name===e)(n.selection);if(!o)return!1;const i=n.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},Mk=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Rc(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Dc(n,e){const{nodeExtensions:t}=On(e),r=t.find(i=>i.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=ee(V(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function yo(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(o=>{s!==!1&&(yo(o,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function Pf(n){return n instanceof F}var Lf=class $f{constructor(e){this.position=e}static fromJSON(e){return new $f(e.position)}toJSON(){return{position:this.position}}};function Ok(n,e){const t=e.mapping.mapResult(n.position);return{position:new Lf(t.pos),mapResult:t}}function Ak(n){return new Lf(n)}function Ik(n,e,t){var r;const{selection:s}=e;let o=null;if(vf(s)&&(o=s.$cursor),o){const l=(r=n.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:i}=s;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));c=h&&m}return!c}),c})}var jk=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=t,{empty:i,ranges:l}=o,a=ft(n,r.schema);if(s)if(i){const c=Ef(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const m=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(x=>x.type===a)?f.marks.forEach(x=>{a===x.type&&t.addMark(m,g,a.create({...x.attrs,...e}))}):t.addMark(m,g,a.create(e))})});return Ik(r,t,a)},Rk=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Dk=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const o=pe(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:l})=>Ja(o,{...i,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Ja(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Pk=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=Vt(n,0,r.content.size),o=F.create(r,s);e.setSelection(o)}return!0},Lk=(n,e)=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=r;let i,l;return typeof e=="number"?(i=e,l=e):e&&"from"in e&&"to"in e?(i=e.from,l=e.to):(i=o.from,l=o.to),s&&t.doc.nodesBetween(i,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},$k=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:o}=typeof n=="number"?{from:n,to:n}:n,i=q.atStart(r).from,l=q.atEnd(r).to,a=Vt(s,i,l),c=Vt(o,i,l),u=q.create(r,a,c);e.setSelection(u)}return!0},_k=n=>({state:e,dispatch:t})=>{const r=pe(n,e.schema);return Ry(r)(e,t)};function Pc(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}var zk=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:l,$to:a}=o,c=s.extensionManager.attributes,u=Jr(c,l.node().type.name,l.node().attrs);if(o instanceof F&&o.node.isBlock)return!l.parentOffset||!ct(i,l.pos)?!1:(r&&(n&&Pc(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:hk(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,m=ct(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!m&&ct(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(m=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(m&&(o instanceof q&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&Pc(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},Bk=(n,e={})=>({tr:t,state:r,dispatch:s,editor:o})=>{var i;const l=pe(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const f=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let x=I.empty;const b=a.index(-1)?1:a.index(-2)?2:3;for(let M=a.depth-b;M>=a.depth-3;M-=1)x=I.from(a.node(M).copy(x));const v=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,C={...Jr(f,a.node().type.name,a.node().attrs),...e},k=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(C))||void 0;x=x.append(I.from(l.createAndFill(null,k)||void 0));const w=a.before(a.depth-(b-1));t.replace(w,a.after(-v),new $(x,4-b,0));let S=-1;t.doc.nodesBetween(w,t.doc.content.size,(M,T)=>{if(S>-1)return!1;M.isTextblock&&M.content.size===0&&(S=T+1)}),S>-1&&t.setSelection(q.near(t.doc.resolve(S))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,m={...Jr(f,d.type.name,d.attrs),...e},g={...Jr(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=h?[{type:l,attrs:m},{type:h,attrs:g}]:[{type:l,attrs:m}];if(!ct(t.doc,a.pos,2))return!1;if(s){const{selection:x,storedMarks:b}=r,{splittableMarks:v}=o.extensionManager,C=b||x.$to.parentOffset&&x.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!C||!s)return!0;const k=C.filter(w=>v.includes(w.type.name));t.ensureMarks(k)}return!0},ri=(n,e)=>{const t=go(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Lt(n.doc,t.pos)&&n.join(t.pos),!0},si=(n,e)=>{const t=go(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Lt(n.doc,r)&&n.join(r),!0},Fk=(n,e,t,r={})=>({editor:s,tr:o,state:i,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=s.extensionManager,h=pe(n,i.schema),m=pe(e,i.schema),{selection:g,storedMarks:y}=i,{$from:x,$to:b}=g,v=x.blockRange(b),C=y||g.$to.parentOffset&&g.$from.marks();if(!v)return!1;const k=go(w=>Dc(w.type.name,d))(g);if(v.depth>=1&&k&&v.depth-k.depth<=1){if(k.node.type===h)return c.liftListItem(m);if(Dc(k.node.type.name,d)&&h.validContent(k.node.content)&&l)return a().command(()=>(o.setNodeMarkup(k.pos,h),!0)).command(()=>ri(o,h)).command(()=>si(o,h)).run()}return!t||!C||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>ri(o,h)).command(()=>si(o,h)).run():a().command(()=>{const w=u().wrapInList(h,r),S=C.filter(M=>f.includes(M.type.name));return o.ensureMarks(S),w?!0:c.clearNodes()}).wrapInList(h,r).command(()=>ri(o,h)).command(()=>si(o,h)).run()},Vk=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=t,i=ft(n,r.schema);return Pi(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},Hk=(n,e,t={})=>({state:r,commands:s})=>{const o=pe(n,r.schema),i=pe(e,r.schema),l=At(r,o,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(i,a):s.setNode(o,{...a,...t})},Wk=(n,e={})=>({state:t,commands:r})=>{const s=pe(n,t.schema);return At(t,s,e)?r.lift(s):r.wrapIn(s,e)},qk=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let o;if(s.spec.isInputRules&&(o=s.getState(n))){if(e){const i=n.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(o.text){const a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else i.delete(o.from,o.to)}return!0}}return!1},Uk=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},Kk=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,a=ft(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&i){let{from:f,to:h}=l;const m=(o=c.marks().find(y=>y.type===a))==null?void 0:o.attrs,g=Dl(c,a,m);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Jk=n=>({tr:e,state:t,dispatch:r})=>{const{selection:s}=t;let o,i;return typeof n=="number"?(o=n,i=n):n&&"from"in n&&"to"in n?(o=n.from,i=n.to):(o=s.from,i=s.to),r&&e.doc.nodesBetween(o,i,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Gk=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=mo(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=pe(n,r.schema)),l==="mark"&&(i=ft(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let f,h,m,g;t.selection.empty?r.doc.nodesBetween(u,d,(y,x)=>{o&&o===y.type&&(a=!0,m=Math.max(x,u),g=Math.min(x+y.nodeSize,d),f=x,h=y)}):r.doc.nodesBetween(u,d,(y,x)=>{x<u&&o&&o===y.type&&(a=!0,m=Math.max(x,u),g=Math.min(x+y.nodeSize,d),f=x,h=y),x>=u&&x<=d&&(o&&o===y.type&&(a=!0,s&&t.setNodeMarkup(x,void 0,{...y.attrs,...e})),i&&y.marks.length&&y.marks.forEach(b=>{if(i===b.type&&(a=!0,s)){const v=Math.max(x,u),C=Math.min(x+y.nodeSize,d);t.addMark(v,C,i.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&s&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(y=>{i===y.type&&s&&t.addMark(m,g,i.create({...y.attrs,...e}))}))}),a},Yk=(n,e={})=>({state:t,dispatch:r})=>{const s=pe(n,t.schema);return Ey(s,e)(t,r)},Xk=(n,e={})=>({state:t,dispatch:r})=>{const s=pe(n,t.schema);return Ty(s,e)(t,r)},Qk=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},xo=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},Zk=(n,e)=>{if(Rl(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function _r(n){var e;const{editor:t,from:r,to:s,text:o,rules:i,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=Nk(c)+o;return i.forEach(f=>{if(u)return;const h=Zk(d,f.find);if(!h)return;const m=a.state.tr,g=fo({state:a.state,transaction:m}),y={from:r-(h[0].length-o.length),to:s},{commands:x,chain:b,can:v}=new ho({editor:t,state:g});f.handler({state:g,range:y,match:h,commands:x,chain:b,can:v})===null||!m.steps.length||(f.undoable&&m.setMeta(l,{transform:m,from:r,to:s,text:o}),a.dispatch(m),u=!0)}),u}function ev(n){const{editor:e,rules:t}=n,r=new ie({state:{init(){return null},apply(s,o,i){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Ll(I.from(u),i.schema);const{from:d}=a,f=d+u.length;_r({editor:e,from:d,to:f,text:u,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,l){return _r({editor:e,from:o,to:i,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&_r({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?_r({editor:e,from:i.pos,to:i.pos,text:`
|
|
37
|
+
`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function tv(n){return Object.prototype.toString.call(n).slice(8,-1)}function zr(n){return tv(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function _f(n,e){const t={...n};return zr(n)&&zr(e)&&Object.keys(e).forEach(r=>{zr(e[r])&&zr(n[r])?t[r]=_f(n[r],e[r]):t[r]=e[r]}),t}var zl=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...ee(V(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ee(V(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>_f(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},rn=class zf extends zl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new zf(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(c=>c?.type.name===t.name))return!1;const a=i.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function nv(n){return typeof n=="number"}var rv=class{constructor(n){this.find=n.find,this.handler=n.handler}},sv=(n,e,t)=>{if(Rl(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=n,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function ov(n){const{editor:e,state:t,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=n,{commands:a,chain:c,can:u}=new ho({editor:e,state:t}),d=[];return t.doc.nodesBetween(r,s,(h,m)=>{var g,y,x,b,v;if((y=(g=h.type)==null?void 0:g.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const C=(v=(b=(x=h.content)==null?void 0:x.size)!=null?b:h.nodeSize)!=null?v:0,k=Math.max(r,m),w=Math.min(s,m+C);if(k>=w)return;const S=h.isText?h.text||"":h.textBetween(k-m,w-m,void 0,"");sv(S,o.find,i).forEach(T=>{if(T.index===void 0)return;const E=k+T.index+1,R=E+T[0].length,D={from:t.tr.mapping.map(E),to:t.tr.mapping.map(R)},B=o.handler({state:t,range:D,match:T,commands:a,chain:c,can:u,pasteEvent:i,dropEvent:l});d.push(B)})}),d.every(h=>h!==null)}var Br=null,iv=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function lv(n){const{editor:e,rules:t}=n;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:f,rule:h,pasteEvt:m})=>{const g=u.tr,y=fo({state:u,transaction:g});if(!(!ov({editor:e,state:y,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:m,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(u=>new ie({view(d){const f=m=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(m.target)?d.dom.parentElement:null,r&&(Br=e)},h=()=>{Br&&(Br=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(o=r===d.dom.parentElement,l=f,!o){const h=Br;h?.isEditable&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(d,f)=>{var h;const m=(h=f.clipboardData)==null?void 0:h.getData("text/html");return i=f,s=!!m?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{const m=d[0],g=m.getMeta("uiEvent")==="paste"&&!s,y=m.getMeta("uiEvent")==="drop"&&!o,x=m.getMeta("applyPasteRules"),b=!!x;if(!g&&!y&&!b)return;if(b){let{text:k}=x;typeof k=="string"?k=k:k=Ll(I.from(k),h.schema);const{from:w}=x,S=w+k.length,M=iv(k);return a({rule:u,state:h,from:w,to:{b:S},pasteEvt:M})}const v=f.doc.content.findDiffStart(h.doc.content),C=f.doc.content.findDiffEnd(h.doc.content);if(!(!nv(v)||!C||v===C.b))return a({rule:u,state:h,from:v,to:C,pasteEvt:i})}}))}var bo=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Af(n),this.schema=xk(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ni(e.name,this.schema)},r=V(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return $l([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:ni(r.name,this.schema)},o=[],i=V(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&V(r,"exitable",s)&&(l.ArrowRight=()=>rn.handleExit({editor:n,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,m])=>[h,()=>m({editor:n})]));l={...l,...f}}const a=wb(l);o.push(a);const c=V(r,"addInputRules",s);if(Rc(r,n.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=ev({editor:n,rules:f}),m=Array.isArray(h)?h:[h];o.push(...m)}}const u=V(r,"addPasteRules",s);if(Rc(r,n.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=lv({editor:n,rules:f});o.push(...h)}}const d=V(r,"addProseMirrorPlugins",s);if(d){const f=d();o.push(...f)}return o})}get attributes(){return Of(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=On(this.extensions);return Object.fromEntries(e.filter(t=>!!V(t,"addNodeView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:pe(t.name,this.schema)},o=V(t,"addNodeView",s);if(!o)return[];const i=o();if(!i)return[];const l=(a,c,u,d,f)=>{const h=yr(a,r);return i({node:a,view:c,getPos:u,decorations:d,innerDecorations:f,editor:n,extension:t,HTMLAttributes:h})};return[t.name,l]}))}get markViews(){const{editor:n}=this,{markExtensions:e}=On(this.extensions);return Object.fromEntries(e.filter(t=>!!V(t,"addMarkView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ft(t.name,this.schema)},o=V(t,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const u=yr(l,r);return o()({mark:l,view:a,inline:c,editor:n,extension:t,HTMLAttributes:u,updateAttributes:d=>{vv(l,n,d)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ni(e.name,this.schema)};e.type==="mark"&&((t=ee(V(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const s=V(e,"onBeforeCreate",r),o=V(e,"onCreate",r),i=V(e,"onUpdate",r),l=V(e,"onSelectionUpdate",r),a=V(e,"onTransaction",r),c=V(e,"onFocus",r),u=V(e,"onBlur",r),d=V(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),i&&this.editor.on("update",i),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};bo.resolve=Af;bo.sort=$l;bo.flatten=Pl;var av={};jl(av,{ClipboardTextSerializer:()=>Ff,Commands:()=>Vf,Delete:()=>Hf,Drop:()=>Wf,Editable:()=>qf,FocusEvents:()=>Kf,Keymap:()=>Jf,Paste:()=>Gf,Tabindex:()=>Yf,TextDirection:()=>Xf,focusEventsPluginKey:()=>Uf});var de=class Bf extends zl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new Bf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Ff=de.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ie({key:new ue("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:o}=s,i=Math.min(...o.map(u=>u.$from.pos)),l=Math.max(...o.map(u=>u.$to.pos)),a=jf(t);return If(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Vf=de.create({name:"commands",addCommands(){return{...bf}}}),Hf=de.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,s;const o=()=>{var i,l,a,c;if((c=(a=(l=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const u=Tf(n.before,[n,...e]);Df(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(m,g)=>{const y=g+m.nodeSize-2,x=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!x,editor:this.editor,transaction:n,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((h,m)=>{var g,y;if(h instanceof Je){const x=f.slice(m).map(h.from,-1),b=f.slice(m).map(h.to),v=f.invert().map(x,-1),C=f.invert().map(b),k=(g=u.doc.nodeAt(x-1))==null?void 0:g.marks.some(S=>S.eq(h.mark)),w=(y=u.doc.nodeAt(b))==null?void 0:y.marks.some(S=>S.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:v,to:C},newRange:{from:x,to:b},partial:!!(w||k),editor:this.editor,transaction:n,combinedTransform:u})}})};(s=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||s?setTimeout(o,0):o()}}),Wf=de.create({name:"drop",addProseMirrorPlugins(){return[new ie({key:new ue("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),qf=de.create({name:"editable",addProseMirrorPlugins(){return[new ie({key:new ue("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Uf=new ue("focusEvents"),Kf=de.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ie({key:Uf,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Jf=de.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,m=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=m.parent.type.spec.isolating,y=d.pos-d.parentOffset,x=g&&m.parent.childCount===1?y===d.pos:G.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!x||x&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return po()||Nf()?o:s},addProseMirrorPlugins(){return[new ie({key:new ue("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),s=n.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:l}=e.selection,a=G.atStart(e.doc).from,c=G.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!yo(t.doc))return;const f=t.tr,h=fo({state:t,transaction:f}),{commands:m}=new ho({editor:this.editor,state:h});if(m.clearNodes(),!!f.steps.length)return f}})]}}),Gf=de.create({name:"paste",addProseMirrorPlugins(){return[new ie({key:new ue("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Yf=de.create({name:"tabindex",addProseMirrorPlugins(){return[new ie({key:new ue("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Xf=de.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=On(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ie({key:new ue("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),cv=class yn{constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new yn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new yn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new yn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,i=this.pos+r+(o?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(i);if(!s&&l.depth<=this.depth)return;const a=new yn(l,this.editor,s,s?t:null);s&&(a.actualDepth=this.depth+1),e.push(new yn(l,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const o=s.node.attrs,i=Object.keys(t);for(let l=0;l<i.length;l+=1){const a=i[l];if(o[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(t);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>t[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},uv=`.ProseMirror {
|
|
38
|
+
position: relative;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ProseMirror {
|
|
42
|
+
word-wrap: break-word;
|
|
43
|
+
white-space: pre-wrap;
|
|
44
|
+
white-space: break-spaces;
|
|
45
|
+
-webkit-font-variant-ligatures: none;
|
|
46
|
+
font-variant-ligatures: none;
|
|
47
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.ProseMirror [contenteditable="false"] {
|
|
51
|
+
white-space: normal;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
55
|
+
white-space: pre-wrap;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ProseMirror pre {
|
|
59
|
+
white-space: pre-wrap;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
img.ProseMirror-separator {
|
|
63
|
+
display: inline !important;
|
|
64
|
+
border: none !important;
|
|
65
|
+
margin: 0 !important;
|
|
66
|
+
width: 0 !important;
|
|
67
|
+
height: 0 !important;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.ProseMirror-gapcursor {
|
|
71
|
+
display: none;
|
|
72
|
+
pointer-events: none;
|
|
73
|
+
position: absolute;
|
|
74
|
+
margin: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.ProseMirror-gapcursor:after {
|
|
78
|
+
content: "";
|
|
79
|
+
display: block;
|
|
80
|
+
position: absolute;
|
|
81
|
+
top: -2px;
|
|
82
|
+
width: 20px;
|
|
83
|
+
border-top: 1px solid black;
|
|
84
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@keyframes ProseMirror-cursor-blink {
|
|
88
|
+
to {
|
|
89
|
+
visibility: hidden;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.ProseMirror-hideselection *::selection {
|
|
94
|
+
background: transparent;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
98
|
+
background: transparent;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ProseMirror-hideselection * {
|
|
102
|
+
caret-color: transparent;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
106
|
+
display: block;
|
|
107
|
+
}`;function dv(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}var fv=class extends Qk{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Ok,createMappablePosition:Ak},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:o})=>this.options.onDrop(r,s,o)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=wf(e,this.options.autofocus);this.editorState=vn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=dv(uv,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=Mf(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;t=t.filter(i=>!i.key.startsWith(o))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const r=[...this.options.enableCoreExtensions?[qf,Ff.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Vf,Kf,Jf,Yf,Wf,Gf,Hf,Xf.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s?.type));this.extensionManager=new bo(r,this)}createCommandManager(){this.commandManager=new ho({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=Di(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=Di(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){var e;this.editorView=new yf(n,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const t=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(t),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),s=t.includes(n),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const i=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=i?.getMeta("focus"),a=i?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:i}),a&&this.emit("blur",{editor:this,event:a.event,transaction:i}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Rf(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return Ek(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ll(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
|
|
108
|
+
|
|
109
|
+
`,textSerializers:t={}}=n||{};return kk(this.state.doc,{blockSeparator:e,textSerializers:{...jf(this.schema),...t}})}get isEmpty(){return yo(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new cv(e,this)}get $doc(){return this.$pos(0)}};function An(n){return new xo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ee(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),u=c+i.length;if(_l(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&o.delete(u,t.to),c>t.from&&o.delete(t.from+a,c);const f=t.from+a+i.length;o.addMark(t.from+a,f,n.type.create(s||{})),o.removeStoredMark(n.type)}},undoable:n.undoable})}function hv(n){return new xo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ee(n.getAttributes,void 0,r)||{},{tr:o}=e,i=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;o.insert(c,n.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:n.undoable})}function Li(n){return new xo({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),o=ee(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)},undoable:n.undoable})}function In(n){return new xo({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const o=ee(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&gl(a,n.type,o);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,m=f||d.$to.parentOffset&&d.$from.marks();if(m){const g=m.filter(y=>h.includes(y.type.name));i.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Lt(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)},undoable:n.undoable})}function pv(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof F){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function mv(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var gv={};jl(gv,{createAtomBlockMarkdownSpec:()=>yv,createBlockMarkdownSpec:()=>xv,createInlineMarkdownSpec:()=>Qf,parseAttributes:()=>Bl,parseIndentedBlocks:()=>$i,renderNestedMarkdownContent:()=>Vl,serializeAttributes:()=>Fl});function Bl(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(e.id=o[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,c,u])=>{var d;const f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Fl(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function yv(n){const{nodeName:e,name:t,parseAttributes:r=Bl,serializeAttributes:s=Fl,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=n,a=t||e,c=u=>{if(!l)return u;const d={};return l.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{const f={...o,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(h);if(!m)return;const g=m[1]||"",y=r(g);if(!i.find(b=>!(b in y)))return{type:e,raw:m[0],attributes:y}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=s(d),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function xv(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Bl,serializeAttributes:o=Fl,defaultAttributes:i={},content:l="block",allowedAttributes:a}=n,c=t||e,u=d=>{if(!a)return d;const f={};return a.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){const g=r(d);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);const m={...i,...d.attributes};return f.createNode(e,m,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;const h=new RegExp(`^:::${c}`,"m"),m=(f=d.match(h))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,h){var m;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=d.match(g);if(!y)return;const[x,b=""]=y,v=s(b);let C=1;const k=x.length;let w="";const S=/^:::([\w-]*)(\s.*)?/gm,M=d.slice(k);for(S.lastIndex=0;;){const T=S.exec(M);if(T===null)break;const E=T.index,R=T[1];if(!((m=T[2])!=null&&m.endsWith(":::"))){if(R)C+=1;else if(C-=1,C===0){const D=M.slice(0,E);w=D.trim();const B=d.slice(0,k+E+T[0].length);let _=[];if(w)if(l==="block")for(_=h.blockTokens(D),_.forEach(O=>{O.text&&(!O.tokens||O.tokens.length===0)&&(O.tokens=h.inlineTokens(O.text))});_.length>0;){const O=_[_.length-1];if(O.type==="paragraph"&&(!O.text||O.text.trim()===""))_.pop();else break}else _=h.inlineTokens(w);return{type:e,raw:B,attributes:v,content:w,tokens:_}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),m=o(h),g=m?` {${m}}`:"",y=f.renderChildren(d.content||[],`
|
|
110
|
+
|
|
111
|
+
`);return`:::${c}${g}
|
|
112
|
+
|
|
113
|
+
${y}
|
|
114
|
+
|
|
115
|
+
:::`}}}function bv(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r;e[s]=o||i,r=t.exec(n)}return e}function kv(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function Qf(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=bv,serializeAttributes:o=kv,defaultAttributes:i={},selfClosing:l=!1,allowedAttributes:a}=n,c=t||e,u=f=>{if(!a)return f;const h={};return a.forEach(m=>{const g=typeof m=="string"?m:m.name,y=typeof m=="string"?void 0:m.skipIfDefault;if(g in f){const x=f[g];if(y!==void 0&&x===y)return;h[g]=x}}),h},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const m={...i,...f.attributes};if(l)return h.createNode(e,m);const g=r?r(f):f.content||"";return g?h.createNode(e,m,[h.createTextNode(g)]):h.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),m=f.match(h),g=m?.index;return g!==void 0?g:-1},tokenize(f,h,m){const g=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),y=f.match(g);if(!y)return;let x="",b="";if(l){const[,C]=y;b=C}else{const[,C,k]=y;b=C,x=k||""}const v=s(b.trim());return{type:e,raw:y[0],content:x.trim(),attributes:v}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const m=u(f.attrs||{}),g=o(m),y=g?` ${g}`:"";return l?`[${c}${y}]`:`[${c}${y}]${h}[/${c}]`}}}function $i(n,e,t){var r,s,o,i;const l=n.split(`
|
|
116
|
+
`),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const f=l[u],h=f.match(e.itemPattern);if(!h){if(a.length>0)break;if(f.trim()===""){u+=1,c=`${c}${f}
|
|
117
|
+
`;continue}else return}const m=e.extractItemData(h),{indentLevel:g,mainContent:y}=m;c=`${c}${f}
|
|
118
|
+
`;const x=[y];for(u+=1;u<l.length;){const k=l[u];if(k.trim()===""){const S=l.slice(u+1).findIndex(E=>E.trim()!=="");if(S===-1)break;if((((s=(r=l[u+1+S].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){x.push(k),c=`${c}${k}
|
|
119
|
+
`,u+=1;continue}else break}if((((i=(o=k.match(/^(\s*)/))==null?void 0:o[1])==null?void 0:i.length)||0)>g)x.push(k),c=`${c}${k}
|
|
120
|
+
`,u+=1;else break}let b;const v=x.slice(1);if(v.length>0){const k=v.map(w=>w.slice(g+d)).join(`
|
|
121
|
+
`);k.trim()&&(e.customNestedParser?b=e.customNestedParser(k):b=t.blockTokens(k))}const C=e.createToken(m,b);a.push(C)}if(a.length!==0)return{items:a,raw:c}}function Vl(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const s=typeof t=="function"?t(r):t,[o,...i]=n.content,l=e.renderChildren([o]),a=[`${s}${l}`];return i&&i.length>0&&i.forEach(c=>{const u=e.renderChildren([c]);if(u){const d=u.split(`
|
|
122
|
+
`).map(f=>f?e.indent(f):"").join(`
|
|
123
|
+
`);a.push(d)}}),a.join(`
|
|
124
|
+
`)}function vv(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,u,n.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var Ae=class Zf extends zl{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Zf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},wv=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const b=this.dom.getBoundingClientRect(),v=u.getBoundingClientRect(),C=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,k=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;d=v.x-b.x+C,f=v.y-b.y+k}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(h),document.body.appendChild(m),(l=n.dataTransfer)==null||l.setDragImage(h,d,f)}finally{m&&setTimeout(()=>{try{m?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=F.create(a.state.doc,g),x=a.state.tr.setSelection(y);a.dispatch(x)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=F.isSelectable(this.node),d=n.type==="copy",f=n.type==="paste",h=n.type==="cut",m=n.type==="mousedown";if(!c&&u&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&m){const g=t.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||d||f||h||m&&u)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(po()||Sf())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function en(n){return new rv({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=ee(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(_l(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===n.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;f<t.to&&i.delete(f,t.to),d>t.from&&i.delete(t.from+u,d),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}var Sv=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},Cv=({contentComponent:n})=>{const e=su.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function Nv(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:pp.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var Ev=class extends Q.Component{constructor(n){var e;super(n),this.editorContentRef=Q.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Nv(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:Sv(e,this.editorContentRef),...t}),n?.contentComponent&&p.jsx(Cv,{contentComponent:n.contentComponent})]})}},Tv=N.forwardRef((n,e)=>{const t=Q.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return Q.createElement(Ev,{key:t,innerRef:e,...n})}),Mv=Q.memo(Tv),Ov=typeof window<"u"?N.useLayoutEffect:N.useEffect,Av=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Iv(n){var e;const[t]=N.useState(()=>new Av(n.editor)),r=hp.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:Zm);return Ov(()=>t.watch(n.editor),[n.editor,t]),N.useDebugValue(r),r}var jv=!1,_i=typeof window>"u",Rv=_i||!!(typeof window<"u"&&window.next),Dv=class eh{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?_i||Rv?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new fv(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?eh.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Pv(n={},e=[]){const t=N.useRef(n);t.current=n;const[r]=N.useState(()=>new Dv(t)),s=su.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return N.useDebugValue(s),N.useEffect(r.onRender(e)),Iv({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var Lv=N.createContext({editor:null});Lv.Consumer;var th=N.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),$v=()=>N.useContext(th),Lc=Q.forwardRef((n,e)=>{const{onDragStart:t}=$v(),r=n.as||"div";return p.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function $c(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function _c(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function _v(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function zv(n){if($c(n)||_c(n))return!0;if(_v(n)){const e=n.type;if(e)return $c(e)||_c(e)}return!1}function Bv(){try{if(N.version)return parseInt(N.version.split(".")[0],10)>=19}catch{}return!1}var nh=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?fp.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var n;const e=this.component,t=this.props,r=this.editor,s=Bv(),o=zv(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.props={...this.props,...n},this.render()}destroy(){var n;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};Q.createContext({markViewContentRef:()=>{}});var Fv=class extends wv{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:N.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=N.memo(a=>p.jsx(th.Provider,{value:r,children:N.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new nh(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=yr(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Vv(n,e){return t=>t.editor.contentComponent?new Fv(n,t,e):{}}var ps=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},Hv=/^\s*>\s$/,Wv=Ae.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return ps("blockquote",{...oe(this.options.HTMLAttributes,n),children:ps("slot",{})})},parseMarkdown:(n,e)=>e.createNode("blockquote",void 0,e.parseChildren(n.tokens||[])),renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach(s=>{const l=e.renderChildren([s]).split(`
|
|
125
|
+
`).map(a=>a.trim()===""?t:`${t} ${a}`);r.push(l.join(`
|
|
126
|
+
`))}),r.join(`
|
|
127
|
+
${t}
|
|
128
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[In({find:Hv,type:this.type})]}}),qv=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Uv=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Kv=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Jv=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Gv=rn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return ps("strong",{...oe(this.options.HTMLAttributes,n),children:ps("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[An({find:qv,type:this.type}),An({find:Kv,type:this.type})]},addPasteRules(){return[en({find:Uv,type:this.type}),en({find:Jv,type:this.type})]}}),Yv=/(^|[^`])`([^`]+)`(?!`)$/,Xv=/(^|[^`])`([^`]+)`(?!`)/g,Qv=rn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",oe(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[An({find:Yv,type:this.type})]},addPasteRules(){return[en({find:Xv,type:this.type})]}}),oi=4,Zv=/^```([a-z]+)?[\s\n]$/,ew=/^~~~([a-z]+)?[\s\n]$/,tw=Ae.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:oi,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const o=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",oe(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const s=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${s}`,e.renderChildren(n.content),"```"].join(`
|
|
129
|
+
`):r=`\`\`\`${s}
|
|
130
|
+
|
|
131
|
+
\`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:oi,{state:r}=n,{selection:s}=r,{$from:o,empty:i}=s;if(o.parent.type!==this.type)return!1;const l=" ".repeat(t);return i?n.commands.insertContent(l):n.commands.command(({tr:a})=>{const{from:c,to:u}=s,h=r.doc.textBetween(c,u,`
|
|
132
|
+
`,`
|
|
133
|
+
`).split(`
|
|
134
|
+
`).map(m=>l+m).join(`
|
|
135
|
+
`);return a.replaceWith(c,u,r.schema.text(h)),!0})},"Shift-Tab":({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:oi,{state:r}=n,{selection:s}=r,{$from:o,empty:i}=s;return o.parent.type!==this.type?!1:i?n.commands.command(({tr:l})=>{var a;const{pos:c}=o,u=o.start(),d=o.end(),h=r.doc.textBetween(u,d,`
|
|
136
|
+
`,`
|
|
137
|
+
`).split(`
|
|
138
|
+
`);let m=0,g=0;const y=c-u;for(let w=0;w<h.length;w+=1){if(g+h[w].length>=y){m=w;break}g+=h[w].length+1}const b=((a=h[m].match(/^ */))==null?void 0:a[0])||"",v=Math.min(b.length,t);if(v===0)return!0;let C=u;for(let w=0;w<m;w+=1)C+=h[w].length+1;return l.delete(C,C+v),c-C<=v&&l.setSelection(q.create(l.doc,C)),!0}):n.commands.command(({tr:l})=>{const{from:a,to:c}=s,f=r.doc.textBetween(a,c,`
|
|
139
|
+
`,`
|
|
140
|
+
`).split(`
|
|
141
|
+
`).map(h=>{var m;const g=((m=h.match(/^ */))==null?void 0:m[0])||"",y=Math.min(g.length,t);return h.slice(y)}).join(`
|
|
142
|
+
`);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
|
|
143
|
+
|
|
144
|
+
`);return!o||!i?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:o}=t;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(G.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[Li({find:Zv,type:this.type,getAttributes:n=>({language:n[1]})}),Li({find:ew,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new ie({key:new ue("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s?.mode;if(!t||!o)return!1;const{tr:i,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
|
|
145
|
+
`));return i.replaceSelectionWith(this.type.create({language:o},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(q.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),nw=Ae.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
146
|
+
|
|
147
|
+
`):""}),rw=Ae.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",oe(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
148
|
+
`},renderMarkdown:()=>`
|
|
149
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:o}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=o||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&i){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),sw=Ae.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,oe(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,s="#".repeat(r);return n.content?`${s} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Li({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),ow=Ae.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",oe(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!pv(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,s=n();return Pf(t)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:o,tr:i,dispatch:l})=>{if(l){const{$to:a}=i.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(q.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(F.create(i.doc,a.pos)):i.setSelection(q.create(i.doc,a.pos));else{const u=o.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(i.insert(c,d),i.setSelection(q.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[hv({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),iw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,aw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,cw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,uw=rn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",oe(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[An({find:iw,type:this.type}),An({find:aw,type:this.type})]},addPasteRules(){return[en({find:lw,type:this.type}),en({find:cw,type:this.type})]}});const dw="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",fw="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",zi="numeric",Bi="ascii",Fi="alpha",tr="asciinumeric",Gn="alphanumeric",Vi="domain",rh="emoji",hw="scheme",pw="slashscheme",ii="whitespace";function mw(n,e){return n in e||(e[n]=[]),e[n]}function Ht(n,e,t){e[zi]&&(e[tr]=!0,e[Gn]=!0),e[Bi]&&(e[tr]=!0,e[Fi]=!0),e[tr]&&(e[Gn]=!0),e[Fi]&&(e[Gn]=!0),e[Gn]&&(e[Vi]=!0),e[rh]&&(e[Vi]=!0);for(const r in e){const s=mw(r,t);s.indexOf(n)<0&&s.push(n)}}function gw(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Me(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Me.groups={};Me.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(n))return o}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||Me.groups;let s;return e&&e.j?s=e:(s=new Me(e),t&&r&&Ht(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const o=n.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(n[i]);return s.tt(n[o-1],e,t,r)},tt(n,e,t,r){r=r||Me.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const o=e;let i,l=s.go(n);if(l?(i=new Me,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new Me,o){if(r)if(i.t&&typeof i.t=="string"){const a=Object.assign(gw(i.t,r),t);Ht(o,a,r)}else t&&Ht(o,t,r);i.t=o}return s.j[n]=i,i}};const J=(n,e,t,r,s)=>n.ta(e,t,r,s),le=(n,e,t,r,s)=>n.tr(e,t,r,s),zc=(n,e,t,r,s)=>n.ts(e,t,r,s),j=(n,e,t,r,s)=>n.tt(e,t,r,s),ot="WORD",Hi="UWORD",sh="ASCIINUMERICAL",oh="ALPHANUMERICAL",xr="LOCALHOST",Wi="TLD",qi="UTLD",Gr="SCHEME",xn="SLASH_SCHEME",Hl="NUM",Ui="WS",Wl="NL",nr="OPENBRACE",rr="CLOSEBRACE",ms="OPENBRACKET",gs="CLOSEBRACKET",ys="OPENPAREN",xs="CLOSEPAREN",bs="OPENANGLEBRACKET",ks="CLOSEANGLEBRACKET",vs="FULLWIDTHLEFTPAREN",ws="FULLWIDTHRIGHTPAREN",Ss="LEFTCORNERBRACKET",Cs="RIGHTCORNERBRACKET",Ns="LEFTWHITECORNERBRACKET",Es="RIGHTWHITECORNERBRACKET",Ts="FULLWIDTHLESSTHAN",Ms="FULLWIDTHGREATERTHAN",Os="AMPERSAND",As="APOSTROPHE",Is="ASTERISK",yt="AT",js="BACKSLASH",Rs="BACKTICK",Ds="CARET",kt="COLON",ql="COMMA",Ps="DOLLAR",Xe="DOT",Ls="EQUALS",Ul="EXCLAMATION",Pe="HYPHEN",sr="PERCENT",$s="PIPE",_s="PLUS",zs="POUND",or="QUERY",Kl="QUOTE",ih="FULLWIDTHMIDDLEDOT",Jl="SEMI",Qe="SLASH",ir="TILDE",Bs="UNDERSCORE",lh="EMOJI",Fs="SYM";var ah=Object.freeze({__proto__:null,ALPHANUMERICAL:oh,AMPERSAND:Os,APOSTROPHE:As,ASCIINUMERICAL:sh,ASTERISK:Is,AT:yt,BACKSLASH:js,BACKTICK:Rs,CARET:Ds,CLOSEANGLEBRACKET:ks,CLOSEBRACE:rr,CLOSEBRACKET:gs,CLOSEPAREN:xs,COLON:kt,COMMA:ql,DOLLAR:Ps,DOT:Xe,EMOJI:lh,EQUALS:Ls,EXCLAMATION:Ul,FULLWIDTHGREATERTHAN:Ms,FULLWIDTHLEFTPAREN:vs,FULLWIDTHLESSTHAN:Ts,FULLWIDTHMIDDLEDOT:ih,FULLWIDTHRIGHTPAREN:ws,HYPHEN:Pe,LEFTCORNERBRACKET:Ss,LEFTWHITECORNERBRACKET:Ns,LOCALHOST:xr,NL:Wl,NUM:Hl,OPENANGLEBRACKET:bs,OPENBRACE:nr,OPENBRACKET:ms,OPENPAREN:ys,PERCENT:sr,PIPE:$s,PLUS:_s,POUND:zs,QUERY:or,QUOTE:Kl,RIGHTCORNERBRACKET:Cs,RIGHTWHITECORNERBRACKET:Es,SCHEME:Gr,SEMI:Jl,SLASH:Qe,SLASH_SCHEME:xn,SYM:Fs,TILDE:ir,TLD:Wi,UNDERSCORE:Bs,UTLD:qi,UWORD:Hi,WORD:ot,WS:Ui});const rt=/[a-z]/,Wn=new RegExp("\\p{L}","u"),li=new RegExp("\\p{Emoji}","u"),st=/\d/,ai=/\s/,Bc="\r",ci=`
|
|
150
|
+
`,yw="️",xw="",ui="";let Fr=null,Vr=null;function bw(n=[]){const e={};Me.groups=e;const t=new Me;Fr==null&&(Fr=Fc(dw)),Vr==null&&(Vr=Fc(fw)),j(t,"'",As),j(t,"{",nr),j(t,"}",rr),j(t,"[",ms),j(t,"]",gs),j(t,"(",ys),j(t,")",xs),j(t,"<",bs),j(t,">",ks),j(t,"(",vs),j(t,")",ws),j(t,"「",Ss),j(t,"」",Cs),j(t,"『",Ns),j(t,"』",Es),j(t,"<",Ts),j(t,">",Ms),j(t,"&",Os),j(t,"*",Is),j(t,"@",yt),j(t,"`",Rs),j(t,"^",Ds),j(t,":",kt),j(t,",",ql),j(t,"$",Ps),j(t,".",Xe),j(t,"=",Ls),j(t,"!",Ul),j(t,"-",Pe),j(t,"%",sr),j(t,"|",$s),j(t,"+",_s),j(t,"#",zs),j(t,"?",or),j(t,'"',Kl),j(t,"/",Qe),j(t,";",Jl),j(t,"~",ir),j(t,"_",Bs),j(t,"\\",js),j(t,"・",ih);const r=le(t,st,Hl,{[zi]:!0});le(r,st,r);const s=le(r,rt,sh,{[tr]:!0}),o=le(r,Wn,oh,{[Gn]:!0}),i=le(t,rt,ot,{[Bi]:!0});le(i,st,s),le(i,rt,i),le(s,st,s),le(s,rt,s);const l=le(t,Wn,Hi,{[Fi]:!0});le(l,rt),le(l,st,o),le(l,Wn,l),le(o,st,o),le(o,rt),le(o,Wn,o);const a=j(t,ci,Wl,{[ii]:!0}),c=j(t,Bc,Ui,{[ii]:!0}),u=le(t,ai,Ui,{[ii]:!0});j(t,ui,u),j(c,ci,a),j(c,ui,u),le(c,ai,u),j(u,Bc),j(u,ci),le(u,ai,u),j(u,ui,u);const d=le(t,li,lh,{[rh]:!0});j(d,"#"),le(d,li,d),j(d,yw,d);const f=j(d,xw);j(f,"#"),le(f,li,d);const h=[[rt,i],[st,s]],m=[[rt,null],[Wn,l],[st,o]];for(let g=0;g<Fr.length;g++)ht(t,Fr[g],Wi,ot,h);for(let g=0;g<Vr.length;g++)ht(t,Vr[g],qi,Hi,m);Ht(Wi,{tld:!0,ascii:!0},e),Ht(qi,{utld:!0,alpha:!0},e),ht(t,"file",Gr,ot,h),ht(t,"mailto",Gr,ot,h),ht(t,"http",xn,ot,h),ht(t,"https",xn,ot,h),ht(t,"ftp",xn,ot,h),ht(t,"ftps",xn,ot,h),Ht(Gr,{scheme:!0,ascii:!0},e),Ht(xn,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],b=n[g][1]?{[hw]:!0}:{[pw]:!0};y.indexOf("-")>=0?b[Vi]=!0:rt.test(y)?st.test(y)?b[tr]=!0:b[Bi]=!0:b[zi]=!0,zc(t,y,y,b)}return zc(t,"localhost",xr,{ascii:!0}),t.jd=new Me(Fs),{start:t,tokens:Object.assign({groups:e},ah)}}function ch(n,e){const t=kw(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,u=null,d=-1,f=-1;for(;i<r&&(a=l.go(t[i]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[i].length,f++),c+=t[i].length,o+=t[i].length,i++;o-=d,i-=f,c-=d,s.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function kw(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 ht(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 Me(r),o.jr=s.slice(),n.j[a]=o),n=o}return o=new Me(t),o.jr=s.slice(),n.j[e[i-1]]=o,o}function Fc(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 br={defaultProtocol:"http",events:null,format:Vc,formatHref:Vc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Gl(n,e=null){let t=Object.assign({},br);n&&(t=Object.assign(t,n instanceof Gl?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}Gl.prototype={o:br,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]:br[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 Vc(n){return n}function uh(n,e){this.t="token",this.v=n,this.tk=e}uh.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=br.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),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),u&&Object.assign(i,u),{tagName:s,attributes:i,content:o,eventListeners:d}}};function ko(n,e){class t extends uh{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 Hc=ko("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Wc=ko("text"),vw=ko("nl"),Hr=ko("url",{isLink:!0,toHref(n=br.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==xr&&n[1].t===kt}}),De=n=>new Me(n);function ww({groups:n}){const e=n.domain.concat([Os,Is,yt,js,Rs,Ds,Ps,Ls,Pe,Hl,sr,$s,_s,zs,Qe,Fs,ir,Bs]),t=[As,kt,ql,Xe,Ul,sr,or,Kl,Jl,bs,ks,nr,rr,gs,ms,ys,xs,vs,ws,Ss,Cs,Ns,Es,Ts,Ms],r=[Os,As,Is,js,Rs,Ds,Ps,Ls,Pe,nr,rr,sr,$s,_s,zs,or,Qe,Fs,ir,Bs],s=De(),o=j(s,ir);J(o,r,o),J(o,n.domain,o);const i=De(),l=De(),a=De();J(s,n.domain,i),J(s,n.scheme,l),J(s,n.slashscheme,a),J(i,r,o),J(i,n.domain,i);const c=j(i,yt);j(o,yt,c),j(l,yt,c),j(a,yt,c);const u=j(o,Xe);J(u,r,o),J(u,n.domain,o);const d=De();J(c,n.domain,d),J(d,n.domain,d);const f=j(d,Xe);J(f,n.domain,d);const h=De(Hc);J(f,n.tld,h),J(f,n.utld,h),j(c,xr,h);const m=j(d,Pe);j(m,Pe,m),J(m,n.domain,d),J(h,n.domain,d),j(h,Xe,f),j(h,Pe,m);const g=j(h,kt);J(g,n.numeric,Hc);const y=j(i,Pe),x=j(i,Xe);j(y,Pe,y),J(y,n.domain,i),J(x,r,o),J(x,n.domain,i);const b=De(Hr);J(x,n.tld,b),J(x,n.utld,b),J(b,n.domain,i),J(b,r,o),j(b,Xe,x),j(b,Pe,y),j(b,yt,c);const v=j(b,kt),C=De(Hr);J(v,n.numeric,C);const k=De(Hr),w=De();J(k,e,k),J(k,t,w),J(w,e,k),J(w,t,w),j(b,Qe,k),j(C,Qe,k);const S=j(l,kt),M=j(a,kt),T=j(M,Qe),E=j(T,Qe);J(l,n.domain,i),j(l,Xe,x),j(l,Pe,y),J(a,n.domain,i),j(a,Xe,x),j(a,Pe,y),J(S,n.domain,k),j(S,Qe,k),j(S,or,k),J(E,n.domain,k),J(E,e,k),j(E,Qe,k);const R=[[nr,rr],[ms,gs],[ys,xs],[bs,ks],[vs,ws],[Ss,Cs],[Ns,Es],[Ts,Ms]];for(let D=0;D<R.length;D++){const[B,_]=R[D],O=j(k,B);j(w,B,O),j(O,_,k);const A=De(Hr);J(O,e,A);const L=De();J(O,t),J(A,e,A),J(A,t,L),J(L,e,A),J(L,t,L),j(A,_,k),j(L,_,k)}return j(s,xr,b),j(s,Wl,vw),{start:s,tokens:ah}}function Sw(n,e,t){let r=t.length,s=0,o=[],i=[];for(;s<r;){let l=n,a=null,c=null,u=0,d=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,d=l):f>=0&&f++,s++,u++;if(f<0)s-=u,s<r&&(i.push(t[s]),s++);else{i.length>0&&(o.push(di(Wc,e,i)),i=[]),s-=f,u-=f;const h=d.t,m=t.slice(s-u,s);o.push(di(h,e,m))}}return i.length>0&&o.push(di(Wc,e,i)),o}function di(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 Cw=typeof console<"u"&&console&&console.warn||(()=>{}),Nw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",re={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Ew(){return Me.groups={},re.scanner=null,re.parser=null,re.tokenQueue=[],re.pluginQueue=[],re.customSchemes=[],re.initialized=!1,re}function qc(n,e=!1){if(re.initialized&&Cw(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Nw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
151
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
152
|
+
2. Cannot start or end with "-"
|
|
153
|
+
3. "-" cannot repeat`);re.customSchemes.push([n,e])}function Tw(){re.scanner=bw(re.customSchemes);for(let n=0;n<re.tokenQueue.length;n++)re.tokenQueue[n][1]({scanner:re.scanner});re.parser=ww(re.scanner.tokens);for(let n=0;n<re.pluginQueue.length;n++)re.pluginQueue[n][1]({scanner:re.scanner,parser:re.parser});return re.initialized=!0,re}function Yl(n){return re.initialized||Tw(),Sw(re.parser.start,n,ch(re.scanner.start,n))}Yl.scan=ch;function dh(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 Gl(t),s=Yl(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 Xl="[\0- -\u2029 ]",Mw=new RegExp(Xl),Ow=new RegExp(`${Xl}$`),Aw=new RegExp(Xl,"g");function Iw(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function jw(n){return new ie({key:new ue("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=Tf(t.doc,[...e]);if(Df(l).forEach(({newRange:c})=>{const u=pk(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!Ow.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(Mw).filter(Boolean);if(h.length<=0)return!1;const m=h[h.length-1],g=d.pos+f.lastIndexOf(m);if(!m)return!1;const y=Yl(m).map(x=>x.toObject(n.defaultProtocol));if(!Iw(y))return!1;y.filter(x=>x.isLink).map(x=>({...x,from:g+x.start+1,to:g+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=>{_l(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 Rw(n){return new ie({key:new ue("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=!1;if(n.enableClickSelection&&(i=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;l=f.find(h=>h.nodeName==="A")}if(!l)return i;const a=Rf(e.state,n.type.name),c=(s=l?.href)!=null?s:a.href,u=(o=l?.target)!=null?o:a.target;l&&c&&(window.open(c,u),i=!0)}return i}}})}function Dw(n){return new ie({key:new ue("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(u=>{a+=u.textContent});const c=dh(a,{defaultProtocol:n.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.href)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function _t(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(Aw,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Pw=rn.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"){qc(n);return}qc(n.scheme,n.optionalSlashes)})},onDestroy(){Ew()},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)=>!!_t(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},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=>!!_t(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=>!!_t(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",oe(this.options.HTMLAttributes,n),0]:["a",oe(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=>!!_t(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=>!!_t(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[en({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=dh(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!_t(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(jw({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!_t(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(Rw({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(Dw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),Lw=Object.defineProperty,$w=(n,e)=>{for(var t in e)Lw(n,t,{get:e[t],enumerable:!0})},_w="listItem",Uc="textStyle",Kc=/^\s*([-+*])\s$/,fh=Ae.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",oe(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,`
|
|
154
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(_w,this.editor.getAttributes(Uc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=In({find:Kc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=In({find:Kc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Uc),editor:this.editor})),[n]}}),hh=Ae.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",oe(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)=>Vl(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)}}}),zw={};$w(zw,{findListItemPos:()=>Mr,getNextListDepth:()=>Ql,handleBackspace:()=>Ki,handleDelete:()=>Ji,hasListBefore:()=>ph,hasListItemAfter:()=>Bw,hasListItemBefore:()=>mh,listItemHasSubList:()=>gh,nextListIsDeeper:()=>yh,nextListIsHigher:()=>xh});var Mr=(n,e)=>{const{$from:t}=e.selection,r=pe(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}},Ql=(n,e)=>{const t=Mr(n,e);if(!t)return!1;const[,r]=Ck(e,n,t.$pos.pos+4);return r},ph=(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))},mh=(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)},gh=(n,e,t)=>{if(!t)return!1;const r=pe(n,e.schema);let s=!1;return t.descendants(o=>{o.type===r&&(s=!0)}),s},Ki=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!At(n.state,e)&&ph(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 u=c.at(-1);if(!u)return!1;const d=n.state.doc.resolve(a.start()+u.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!At(n.state,e)||!Mk(n.state))return!1;const r=Mr(e,n.state);if(!r)return!1;const o=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=gh(e,n.state,o);return mh(e,n.state)&&!i?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},yh=(n,e)=>{const t=Ql(n,e),r=Mr(n,e);return!r||!t?!1:t>r.depth},xh=(n,e)=>{const t=Ql(n,e),r=Mr(n,e);return!r||!t?!1:t<r.depth},Ji=(n,e)=>{if(!At(n.state,e)||!Tk(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:s}=t;return!t.empty&&r.sameParent(s)?!1:yh(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():xh(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},Bw=(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)},bh=de.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&&Ji(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&&Ji(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&&Ki(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&&Ki(n,t,r)&&(e=!0)}),e}}}}),Jc=/^(\s*)(\d+)\.\s+(.*)$/,Fw=/^\s/;function Vw(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t],o=s.match(Jc);if(!o)break;const[,i,l,a]=o,c=i.length;let u=a,d=t+1;const f=[s];for(;d<n.length;){const h=n[d];if(h.match(Jc))break;if(h.trim()==="")f.push(h),u+=`
|
|
155
|
+
`,d+=1;else if(h.match(Fw))f.push(h),u+=`
|
|
156
|
+
${h.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(l,10),content:u.trim(),raw:f.join(`
|
|
157
|
+
`)}),r=d,t=d}return[e,r]}function kh(n,e,t){var r;const s=[];let o=0;for(;o<n.length;){const i=n[o];if(i.indent===e){const l=i.content.split(`
|
|
158
|
+
`),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:t.inlineTokens(a)});const u=l.slice(1).join(`
|
|
159
|
+
`).trim();if(u){const h=t.blockTokens(u);c.push(...h)}let d=o+1;const f=[];for(;d<n.length&&n[d].indent>e;)f.push(n[d]),d+=1;if(f.length>0){const h=Math.min(...f.map(g=>g.indent)),m=kh(f,h,t);c.push({type:"list",ordered:!0,start:f[0].number,items:m,raw:f.map(g=>g.raw).join(`
|
|
160
|
+
`)})}s.push({type:"list_item",raw:i.raw,tokens:c}),o=d}else o+=1}return s}function Hw(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const o=e.parseChildren([s]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([s]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}var Ww="listItem",Gc="textStyle",Yc=/^(\d+)\.\s$/,vh=Ae.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",oe(this.options.HTMLAttributes,t),0]:["ol",oe(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?Hw(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
|
|
161
|
+
`):"",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(`
|
|
162
|
+
`),[o,i]=Vw(s);if(o.length===0)return;const l=kh(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(`
|
|
163
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ww,this.editor.getAttributes(Gc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=In({find:Yc,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=In({find:Yc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Gc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),qw=/^\s*(\[([( |x])?\])\s$/,Uw=Ae.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",oe(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 Vl(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 d,f;l.ariaLabel=((f=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:f.call(d,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return 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:d}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const h=t();if(typeof h!="number")return!1;const m=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...m?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{s.setAttribute(u,d)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([u,d])=>{s.setAttribute(u,d)}),{dom:s,contentDOM:a,update:u=>u.type!==this.type?!1:(s.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[In({find:qw,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),Kw=Ae.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",oe(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,`
|
|
164
|
+
`):"",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=$i(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=$i(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()}}});de.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(fh.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(hh.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(bh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(vh.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Uw.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(Kw.configure(this.options.taskList)),n}});var Jw=Ae.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",oe(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()}}}),Gw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Yw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Xw=rn.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",oe(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[An({find:Gw,type:this.type})]},addPasteRules(){return[en({find:Yw,type:this.type})]}}),Qw=Ae.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Zw=rn.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",oe(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 e2(n={}){return new ie({view(e){return new t2(e,n)}})}class t2{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 d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=d?m.bottom:m.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let 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,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/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=gd(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 ae extends G{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ae.valid(r)?new ae(r):G.near(r)}content(){return $.empty}eq(e){return e instanceof ae&&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 ae(e.resolve(t.pos))}getBookmark(){return new Zl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!n2(e)||!r2(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&&ae.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(ae.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!F.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(ae.valid(l))return l}return null}}}ae.prototype.visible=!1;ae.findFrom=ae.findGapCursorFrom;G.jsonID("gapcursor",ae);class Zl{constructor(e){this.pos=e}map(e){return new Zl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ae.valid(t)?new ae(t):G.near(t)}}function wh(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function n2(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||wh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function r2(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||wh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function s2(){return new ie({props:{decorations:a2,createSelectionBetween(n,e,t){return e.pos==t.pos&&ae.valid(t)?new ae(t):null},handleClick:i2,handleKeyDown:o2,handleDOMEvents:{beforeinput:l2}}})}const o2=xf({ArrowLeft:Wr("horiz",-1),ArrowRight:Wr("horiz",1),ArrowUp:Wr("vert",-1),ArrowDown:Wr("vert",1)});function Wr(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 q){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ae.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ae(c))),!0):!1}}function i2(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ae.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&F.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ae(r))),!0)}function l2(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ae))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=I.empty;for(let i=r.length-1;i>=0;i--)s=I.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new $(s,0,0));return o.setSelection(q.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function a2(n){if(!(n.selection instanceof ae))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",se.create(n.doc,[Se.widget(n.selection.head,e,{key:"gapcursor"})])}var Vs=200,xe=function(){};xe.prototype.append=function(e){return e.length?(e=xe.from(e),!this.length&&e||e.length<Vs&&this.leafAppend(e)||this.length<Vs&&e.leafPrepend(this)||this.appendInner(e)):this};xe.prototype.prepend=function(e){return e.length?xe.from(e).append(this):this};xe.prototype.appendInner=function(e){return new c2(this,e)};xe.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?xe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};xe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};xe.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)};xe.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};xe.from=function(e){return e instanceof xe?e:e&&e.length?new Sh(e):xe.empty};var Sh=(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<=Vs)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Vs)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})(xe);xe.empty=new Sh([]);var c2=(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})(xe);const u2=500;class He{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=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new pt(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new pt(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new He(this.items.slice(0,r).append(u.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 u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new pt(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?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>f2&&(l=d2(l,c),i-=c),new He(l.append(o),i)}remapping(e,t){let r=new dr;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 He(this.items.append(e.map(t=>new pt(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 m=o.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,r.push(new pt(m,g,y))}else r.push(new pt(m))},s);let c=[];for(let f=t;f<i;f++)c.push(new pt(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new He(u,l);return d.emptyItemCount()>u2&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),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 u=i.selection&&i.selection.map(t.slice(r));u&&o++;let d=new pt(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new He(xe.from(s.reverse()),o)}}He.empty=new He(xe.empty,0);function d2(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}let pt=class Ch{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 Ch(t.getMap().invert(),t,this.selection)}}};class xt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const f2=20;function h2(n,e,t,r){let s=t.getMeta(Jt),o;if(s)return s.historyState;t.getMeta(g2)&&(n=new xt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Jt))return i.getMeta(Jt).redo?new xt(n.done.addTransform(t,void 0,r,Yr(e)),n.undone,Xc(t.mapping.maps),n.prevTime,n.prevComposition):new xt(n.done,n.undone.addTransform(t,void 0,r,Yr(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||!p2(t,n.prevRanges)),c=i?fi(n.prevRanges,t.mapping):Xc(t.mapping.maps);return new xt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Yr(e)),He.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new xt(n.done.rebased(t,o),n.undone.rebased(t,o),fi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new xt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),fi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function p2(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 Xc(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 fi(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 m2(n,e,t){let r=Yr(e),s=Jt.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 xt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Jt,{redo:t,historyState:a})}let hi=!1,Qc=null;function Yr(n){let e=n.plugins;if(Qc!=e){hi=!1,Qc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){hi=!0;break}}return hi}const Jt=new ue("history"),g2=new ue("closeHistory");function y2(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ie({key:Jt,state:{init(){return new xt(He.empty,He.empty,null,0,-1)},apply(e,t,r){return h2(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Eh:r=="historyRedo"?Th:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Nh(n,e){return(t,r)=>{let s=Jt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=m2(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const Eh=Nh(!1,!0),Th=Nh(!0,!0);de.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 ie({key:new ue("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,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var x2=de.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[e2(this.options)]}});de.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ie({key:new ue("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return se.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(Se.node(c,c+a.nodeSize,{class:this.options.className}))}),se.create(n,o)}}})]}});var b2=de.create({name:"gapCursor",addProseMirrorPlugins(){return[s2()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ee(V(n,"allowGapCursor",t)))!=null?e:null}}});de.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new ie({key:new ue("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&&yo(i);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const d=Se.node(l,l+i.nodeSize,{class:u.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(d)}return this.options.includeChildren}),se.create(n,s)}}})]}});de.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new ie({key:new ue("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Pf(t.selection)||n.view.dragging?null:se.create(t.doc,[Se.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Zc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var k2=de.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ue(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 ie({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,u=e.getState(i),d=l.content.size,f=c.nodes[t];if(u)return a.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!Zc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!Zc({node:i,types:r})}}})]}}),v2=de.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Eh(n,e),redo:()=>({state:n,dispatch:e})=>Th(n,e)}},addProseMirrorPlugins(){return[y2(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()}}}),w2=de.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(Gv.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Wv.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(fh.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Qv.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(tw.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(nw.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(x2.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(b2.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(rw.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(sw.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(v2.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(ow.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(uw.configure(this.options.italic)),this.options.listItem!==!1&&s.push(hh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(bh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(Pw.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(vh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Jw.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Xw.configure(this.options.strike)),this.options.text!==!1&&s.push(Qw.configure(this.options.text)),this.options.underline!==!1&&s.push(Zw.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(k2.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),S2=w2;function C2(n){var e;const{char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=n,a=r&&!s,c=mv(t),u=new RegExp(`\\s${c}$`),d=i?"^":"",f=s?"":c,h=a?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),m=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!m)return null;const g=l.pos-m.length,y=Array.from(m.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const x=y.input.slice(Math.max(0,y.index-1),y.index),b=new RegExp(`^[${o?.join("")}\0]?$`).test(x);if(o!==null&&!b)return null;const v=g+y.index;let C=v+y[0].length;return a&&u.test(m.slice(C-1,C+1))&&(y[0]+=" ",C+=1),v<l.pos&&C>=l.pos?{range:{from:v,to:C},query:y[0].slice(t.length),text:y[0]}:null}var N2=new ue("suggestion");function E2({pluginKey:n=N2,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:h=()=>({}),allow:m=()=>!0,findSuggestionMatch:g=C2}){let y;const x=h?.(),b=()=>{const w=e.state.selection.$anchor.pos,S=e.view.coordsAtPos(w),{top:M,right:T,bottom:E,left:R}=S;try{return new DOMRect(R,M,T-R,E-M)}catch{return null}},v=(w,S)=>S?()=>{const M=n.getState(e.state),T=M?.decorationId,E=w.dom.querySelector(`[data-decoration-id="${T}"]`);return E?.getBoundingClientRect()||null}:b;function C(w,S){var M;try{const E=n.getState(w.state),R=E?.decorationId?w.dom.querySelector(`[data-decoration-id="${E.decorationId}"]`):null,D={editor:e,range:E?.range||{from:0,to:0},query:E?.query||null,text:E?.text||null,items:[],command:B=>d({editor:e,range:E?.range||{from:0,to:0},props:B}),decorationNode:R,clientRect:v(w,R)};(M=x?.onExit)==null||M.call(x,D)}catch{}const T=w.state.tr.setMeta(S,{exit:!0});w.dispatch(T)}const k=new ie({key:n,view(){return{update:async(w,S)=>{var M,T,E,R,D,B,_;const O=(M=this.key)==null?void 0:M.getState(S),A=(T=this.key)==null?void 0:T.getState(w.state),L=O.active&&A.active&&O.range.from!==A.range.from,z=!O.active&&A.active,U=O.active&&!A.active,W=!z&&!U&&O.query!==A.query,H=z||L&&W,K=W||L,Z=U||L&&W;if(!H&&!K&&!Z)return;const Y=Z&&!H?O:A,te=w.dom.querySelector(`[data-decoration-id="${Y.decorationId}"]`);y={editor:e,range:Y.range,query:Y.query,text:Y.text,items:[],command:fe=>d({editor:e,range:Y.range,props:fe}),decorationNode:te,clientRect:v(w,te)},H&&((E=x?.onBeforeStart)==null||E.call(x,y)),K&&((R=x?.onBeforeUpdate)==null||R.call(x,y)),(K||H)&&(y.items=await f({editor:e,query:Y.query})),Z&&((D=x?.onExit)==null||D.call(x,y)),K&&((B=x?.onUpdate)==null||B.call(x,y)),H&&((_=x?.onStart)==null||_.call(x,y))},destroy:()=>{var w;y&&((w=x?.onExit)==null||w.call(x,y))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(w,S,M,T){const{isEditable:E}=e,{composing:R}=e.view,{selection:D}=w,{empty:B,from:_}=D,O={...S},A=w.getMeta(n);if(A&&A.exit)return O.active=!1,O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null,O;if(O.composing=R,E&&(B||e.view.composing)){(_<S.range.from||_>S.range.to)&&!R&&!S.composing&&(O.active=!1);const L=g({char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:D.$from}),z=`id_${Math.floor(Math.random()*4294967295)}`;L&&m({editor:e,state:T,range:L.range,isActive:S.active})?(O.active=!0,O.decorationId=S.decorationId?S.decorationId:z,O.range=L.range,O.query=L.query,O.text=L.text):O.active=!1}else O.active=!1;return O.active||(O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null),O}},props:{handleKeyDown(w,S){var M,T,E,R;const{active:D,range:B}=k.getState(w.state);if(!D)return!1;if(S.key==="Escape"||S.key==="Esc"){const O=k.getState(w.state),A=(M=y?.decorationNode)!=null?M:null,L=A??(O?.decorationId?w.dom.querySelector(`[data-decoration-id="${O.decorationId}"]`):null);if(((T=x?.onKeyDown)==null?void 0:T.call(x,{view:w,event:S,range:O.range}))||!1)return!0;const U={editor:e,range:O.range,query:O.query,text:O.text,items:[],command:W=>d({editor:e,range:O.range,props:W}),decorationNode:L,clientRect:L?()=>L.getBoundingClientRect()||null:null};return(E=x?.onExit)==null||E.call(x,U),C(w,n),!0}return((R=x?.onKeyDown)==null?void 0:R.call(x,{view:w,event:S,range:B}))||!1},decorations(w){const{active:S,range:M,decorationId:T,query:E}=k.getState(w);if(!S)return null;const R=!E?.length,D=[a];return R&&D.push(u),se.create(w.doc,[Se.inline(M.from,M.to,{nodeName:l,class:D.join(" "),"data-decoration-id":T,"data-decoration-content":c})])}}});return k}function T2({editor:n,overrideSuggestionOptions:e,extensionName:t,char:r="@"}){const s=new ue;return{editor:n,char:r,pluginKey:s,command:({editor:o,range:i,props:l})=>{var a,c,u;const d=o.view.state.selection.$to.nodeAfter;(a=d?.text)!=null&&a.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:t,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(u=(c=o.view.dom.ownerDocument.defaultView)==null?void 0:c.getSelection())==null||u.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 Mh(n){return(n.options.suggestions.length?n.options.suggestions:[n.options.suggestion]).map(e=>T2({editor:n.editor,overrideSuggestionOptions:e,extensionName:n.name,char:e.char}))}function eu(n,e){const t=Mh(n),r=t.find(s=>s.char===e);return r||(t.length?t[0]:null)}var M2=Ae.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",oe(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=eu(this,n.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",oe({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n,suggestion:t})];const r={...this.options};r.HTMLAttributes=oe({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:n,suggestion:t});return typeof s=="string"?["span",oe({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...Qf({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:eu(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 _e,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 Mh(this).map(E2)}}),O2=M2,pi,vo="HoverCard",[Oh]=Xi(vo,[ou]),wo=ou(),[A2,So]=Oh(vo),Ah=n=>{const{__scopeHoverCard:e,children:t,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=n,a=wo(e),c=N.useRef(0),u=N.useRef(0),d=N.useRef(!1),f=N.useRef(!1),[h,m]=Ks({prop:r,defaultProp:s??!1,onChange:o,caller:vo}),g=N.useCallback(()=>{clearTimeout(u.current),c.current=window.setTimeout(()=>m(!0),i)},[i,m]),y=N.useCallback(()=>{clearTimeout(c.current),!d.current&&!f.current&&(u.current=window.setTimeout(()=>m(!1),l))},[l,m]),x=N.useCallback(()=>m(!1),[m]);return N.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(u.current)},[]),p.jsx(A2,{scope:e,open:h,onOpenChange:m,onOpen:g,onClose:y,onDismiss:x,hasSelectionRef:d,isPointerDownOnContentRef:f,children:p.jsx(yp,{...a,children:t})})};Ah.displayName=vo;var Ih="HoverCardTrigger",jh=N.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=So(Ih,t),o=wo(t);return p.jsx(mp,{asChild:!0,...o,children:p.jsx(Rn.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:Ve(n.onPointerEnter,Ws(s.onOpen)),onPointerLeave:Ve(n.onPointerLeave,Ws(s.onClose)),onFocus:Ve(n.onFocus,s.onOpen),onBlur:Ve(n.onBlur,s.onClose),onTouchStart:Ve(n.onTouchStart,i=>i.preventDefault())})})});jh.displayName=Ih;var ea="HoverCardPortal",[I2,j2]=Oh(ea,{forceMount:void 0}),Rh=n=>{const{__scopeHoverCard:e,forceMount:t,children:r,container:s}=n,o=So(ea,e);return p.jsx(I2,{scope:e,forceMount:t,children:p.jsx(Qi,{present:t||o.open,children:p.jsx(gp,{asChild:!0,container:s,children:r})})})};Rh.displayName=ea;var Hs="HoverCardContent",Dh=N.forwardRef((n,e)=>{const t=j2(Hs,n.__scopeHoverCard),{forceMount:r=t.forceMount,...s}=n,o=So(Hs,n.__scopeHoverCard);return p.jsx(Qi,{present:r||o.open,children:p.jsx(R2,{"data-state":o.open?"open":"closed",...s,onPointerEnter:Ve(n.onPointerEnter,Ws(o.onOpen)),onPointerLeave:Ve(n.onPointerLeave,Ws(o.onClose)),ref:e})})});Dh.displayName=Hs;var R2=N.forwardRef((n,e)=>{const{__scopeHoverCard:t,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=n,a=So(Hs,t),c=wo(t),u=N.useRef(null),d=Zi(e,u),[f,h]=N.useState(!1);return N.useEffect(()=>{if(f){const m=document.body;return pi=m.style.userSelect||m.style.webkitUserSelect,m.style.userSelect="none",m.style.webkitUserSelect="none",()=>{m.style.userSelect=pi,m.style.webkitUserSelect=pi}}},[f]),N.useEffect(()=>{if(u.current){const m=()=>{h(!1),a.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(a.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",m),()=>{document.removeEventListener("pointerup",m),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!1}}},[a.isPointerDownOnContentRef,a.hasSelectionRef]),N.useEffect(()=>{u.current&&L2(u.current).forEach(g=>g.setAttribute("tabindex","-1"))}),p.jsx(xp,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:Ve(o,m=>{m.preventDefault()}),onDismiss:a.onDismiss,children:p.jsx(bp,{...c,...l,onPointerDown:Ve(l.onPointerDown,m=>{m.currentTarget.contains(m.target)&&h(!0),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!0}),ref:d,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)"}})})}),D2="HoverCardArrow",P2=N.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=wo(t);return p.jsx(kp,{...s,...r,ref:e})});P2.displayName=D2;function Ws(n){return e=>e.pointerType==="touch"?void 0:n()}function L2(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 $2=Ah,_2=jh,z2=Rh,B2=Dh;function F2(n){const e=P.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=p.jsx($2,{"data-slot":"hover-card",...t}),e[2]=t,e[3]=r):r=e[3],r}function V2(n){const e=P.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=p.jsx(_2,{"data-slot":"hover-card-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function H2(n){const e=P.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=X("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=p.jsx(z2,{"data-slot":"hover-card-portal",children:p.jsx(B2,{"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 Ph=N.createContext(void 0);function W2(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 q2(n){const e=P.c(20),{node:t}=n,r=N.useContext(Ph),s=t.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const g=o?W2(r,s):void 0;i=g!==void 0?typeof g=="object"?JSON.stringify(g,null,2):String(g):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=p.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 g;return e[6]!==c?(g=p.jsx(Lc,{as:"span",children:c}),e[6]=c,e[7]=g):g=e[7],g}let u;e[8]!==c?(u=p.jsx(V2,{asChild:!0,children:c}),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==s?(d=p.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["@",s]}),e[10]=s,e[11]=d):d=e[11];let f;e[12]!==l?(f=p.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]!==d||e[15]!==f?(h=p.jsx(H2,{className:"w-auto max-w-[400px] p-3",side:"top",align:"start",children:p.jsxs("div",{className:"space-y-1.5",children:[d,f]})}),e[14]=d,e[15]=f,e[16]=h):h=e[16];let m;return e[17]!==u||e[18]!==h?(m=p.jsx(Lc,{as:"span",children:p.jsxs(F2,{openDelay:200,children:[u,h]})}),e[17]=u,e[18]=h,e[19]=m):m=e[19],m}function Lh(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 Ze=$h();function $h(){return ul(()=>({items:[],selectedIndex:0,command:null}))}function tu(n,e){Ze.setState({items:n,command:e,selectedIndex:0})}function U2(){const{items:n,selectedIndex:e}=Ze.getState();n.length&&Ze.setState({selectedIndex:(e-1+n.length)%n.length})}function K2(){const{items:n,selectedIndex:e}=Ze.getState();n.length&&Ze.setState({selectedIndex:(e+1)%n.length})}function _h(){const{items:n,selectedIndex:e,command:t}=Ze.getState(),r=n[e];return r?(t?.(r),!0):!1}function nu(){Ze=$h()}function J2(){const n=P.c(7),e=yi(Ze,Y2),t=yi(Ze,G2);if(!e.length)return null;let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==t?(o=(i,l)=>p.jsx("button",{type:"button",onClick:()=>{Ze.setState({selectedIndex:l}),_h()},className:X("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=p.jsx("div",{className:"bg-popover border border-border rounded-lg shadow-lg overflow-hidden min-w-[180px]",children:p.jsx("div",{className:"p-1",children:r})}),n[5]=r,n[6]=s):s=n[6],s}function G2(n){return n.selectedIndex}function Y2(n){return n.items}function X2(){let n=null,e=null;return{onStart:t=>{tu(t.items,t.command),n=new nh(J2,{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=>{tu(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(),nu(),!0):t.key==="ArrowUp"?(U2(),!0):t.key==="ArrowDown"?(K2(),!0):t.key==="Enter"?_h():!1,onExit:()=>{e?.remove(),n?.destroy(),nu()}}}const mi=/@([\w.]+)/g;function Q2(n,e){if(!n)return null;const t=Lh(e),r=new Map(t.map(a=>[a.id,a]));if(!mi.test(n))return n;mi.lastIndex=0;const o=[];let i=0,l;for(;(l=mi.exec(n))!==null;){const a=l[1]??"",c=l.index;c>i&&o.push({type:"text",text:n.slice(i,c)});const u=r.get(a);u?o.push({type:"mention",attrs:{id:u.id,label:u.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 ta(n){const e=P.c(31),{mentions:t,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=n,a=y0();let c;e[0]!==t||e[1]!==r?(c=Q2(r,t),e[0]=t,e[1]=r,e[2]=c):c=e[2];const u=c,d=a!==void 0,f=!l;let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=S2.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let m;if(e[4]!==t||e[5]!==d){let T;e[7]!==t?(T=E=>{const{query:R}=E;return Lh(t).filter(B=>B.label.toLowerCase().includes(R.toLowerCase())||B.id.toLowerCase().includes(R.toLowerCase()))},e[7]=t,e[8]=T):T=e[8],m=O2.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:nS,renderHTML:tS,suggestion:{items:T,render:X2,command:eS}}).extend(d?{addNodeView(){return Vv(q2)}}:{}),e[4]=t,e[5]=d,e[6]=m}else m=e[6];let g;e[9]!==m?(g=[h,m],e[9]=m,e[10]=g):g=e[10];const y=o??"";let x;e[11]!==y?(x={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full min-h-[20px]","data-placeholder":y},handleKeyDown:Z2},e[11]=y,e[12]=x):x=e[12];let b;e[13]!==s?(b=T=>{const{editor:E}=T;return s?.(E.getText().trim())},e[13]=s,e[14]=b):b=e[14];let v;e[15]!==u||e[16]!==f||e[17]!==g||e[18]!==x||e[19]!==b?(v={content:u,editable:f,extensions:g,editorProps:x,onUpdate:b},e[15]=u,e[16]=f,e[17]=g,e[18]=x,e[19]=b,e[20]=v):v=e[20];const C=Pv(v);let k;e[21]!==i?(k=X("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]!==C?(w=p.jsx(Mv,{editor:C}),e[23]=C,e[24]=w):w=e[24];let S;e[25]!==k||e[26]!==w?(S=p.jsx("div",{className:k,children:w}),e[25]=k,e[26]=w,e[27]=S):S=e[27];const M=S;if(a!==void 0){let T;return e[28]!==M||e[29]!==a?(T=p.jsx(Ph.Provider,{value:a,children:M}),e[28]=M,e[29]=a,e[30]=T):T=e[30],T}return M}function Z2(n,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function eS(n){const{editor:e,range:t,props:r}=n;e.chain().focus().insertContentAt(t,[{type:"mention",attrs:r}]).run()}function tS(n){const{options:e,node:t}=n;return["span",e.HTMLAttributes,`@${t.attrs.id}`]}function nS(n){const{node:e}=n;return`@${e.attrs.id}`}function rS(n){const e=P.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=Hu(),l=t??"";let a;e[0]!==r?(a=d=>r(d),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let u;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(u=p.jsx(ta,{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]=u):u=e[7],u}function sS(n){const e=P.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=Hu(),l=t??"";let a;e[0]!==r?(a=d=>r(d),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let u;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(u=p.jsx(ta,{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]=u):u=e[7],u}function oS(n){const e=P.c(8),{value:t,onChange:r,readonly:s,id:o}=n,i=t??"";let l;e[0]!==r?(l=u=>r(u.target.value===""?void 0:Number(u.target.value)),e[0]=r,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=X("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=p.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 iS(n){const e=P.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=p.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 u;e[7]!==i?(u=p.jsx("span",{className:"text-sm",children:i}),e[7]=i,e[8]=u):u=e[8];let d;return e[9]!==o||e[10]!==c||e[11]!==u?(d=p.jsxs("label",{htmlFor:o,className:"flex items-center gap-2 cursor-pointer",children:[c,u]}),e[9]=o,e[10]=c,e[11]=u,e[12]=d):d=e[12],d}function lS(n){const e=P.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 u;e[2]!==r?(u=g=>r(g.target.value),e[2]=r,e[3]=u):u=e[3];let d,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=X("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=p.jsx("option",{value:"",children:"Select..."}),e[4]=d,e[5]=f):(d=e[4],f=e[5]);let h;e[6]!==a?(h=a.map(aS),e[6]=a,e[7]=h):h=e[7];let m;return e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==u||e[12]!==h?(m=p.jsxs("select",{id:o,value:c,onChange:u,disabled:s,className:d,children:[f,h]}),e[8]=o,e[9]=s,e[10]=c,e[11]=u,e[12]=h,e[13]=m):m=e[13],m}function aS(n){return p.jsx("option",{value:String(n.value),children:String(n.label)},String(n.value))}const cS={TextWidget:rS,TextareaWidget:sS,NumberWidget:oS,CheckboxWidget:iS,SelectWidget:lS};function uS(n){switch(Array.isArray(n)?n[0]:n??"unknown"){case"string":return{Icon:yu,color:"text-blue-500"};case"number":case"integer":return{Icon:mu,color:"text-blue-500"};case"array":return{Icon:hu,color:"text-purple-500"};case"object":return{Icon:fu,color:"text-orange-500"};case"boolean":return{Icon:gu,color:"text-pink-500"};case"null":return{Icon:el,color:"text-gray-500"};default:return{Icon:pu,color:"text-muted-foreground"}}}function dS(n){const e=P.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=p.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=p.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 u,d,f,h,m,g,y;if(e[4]!==t||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:k,color:w}=uS(c);y="space-y-2",h="flex items-center gap-2",e[15]!==t||e[16]!==r?(m=p.jsx("label",{htmlFor:t,className:"text-sm font-medium leading-none",children:r}),e[15]=t,e[16]=r,e[17]=m):m=e[17],e[18]!==s?(g=s&&p.jsx("span",{className:"text-red-500 text-xs",children:"*"}),e[18]=s,e[19]=g):g=e[19],u=k,d=14,f=X(w,"ml-auto"),e[4]=t,e[5]=r,e[6]=s,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h,e[12]=m,e[13]=g,e[14]=y}else u=e[8],d=e[9],f=e[10],h=e[11],m=e[12],g=e[13],y=e[14];let x;e[20]!==u||e[21]!==d||e[22]!==f?(x=p.jsx(u,{size:d,className:f}),e[20]=u,e[21]=d,e[22]=f,e[23]=x):x=e[23];let b;e[24]!==h||e[25]!==m||e[26]!==g||e[27]!==x?(b=p.jsxs("div",{className:h,children:[m,g,x]}),e[24]=h,e[25]=m,e[26]=g,e[27]=x,e[28]=b):b=e[28];let v;e[29]!==o?(v=o&&p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=v):v=e[30];let C;return e[31]!==i||e[32]!==y||e[33]!==b||e[34]!==v?(C=p.jsxs("div",{className:y,children:[b,v,i]}),e[31]=i,e[32]=y,e[33]=b,e[34]=v,e[35]=C):C=e[35],C}function fS(n){const e=P.c(8),{properties:t,title:r}=n;if(!r||r==="Root"){let l;e[0]!==t?(l=t.map(pS),e[0]=t,e[1]=l):l=e[1];let a;return e[2]!==l?(a=p.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(hS),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==o?(i=p.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 hS(n){return p.jsx("div",{children:n.content},n.name)}function pS(n){return p.jsx("div",{children:n.content},n.name)}function mS(n){const e=P.c(11),{items:t,canAdd:r,onAddClick:s,title:o}=n;let i;e[0]!==t?(i=t.map(gS),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=p.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&&p.jsxs(ce,{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=p.jsxs("div",{className:"space-y-2",children:[l,a]}),e[8]=l,e[9]=a,e[10]=c):c=e[10],c}function gS(n){return p.jsx("div",{className:"flex gap-2 items-start",children:p.jsx("div",{className:"flex-1",children:n})},n.key||n.index)}function yS(){return null}function xS(){return null}const bS={FieldTemplate:dS,ObjectFieldTemplate:fS,ArrayFieldTemplate:mS,UnsupportedFieldTemplate:yS,ErrorListTemplate:xS};function kS(n){const e=P.c(6),{inputSchema:t,inputParams:r,mentions:s}=n;if(!t?.properties||!r)return null;let o;e[0]!==s?(o=(a,c,u)=>{const d=typeof c=="object"&&c!==null?JSON.stringify(c,null,2):String(c??""),f=Array.isArray(u.type)?u.type.join(" | "):u.type??"string";return p.jsxs("div",{className:"space-y-1.5",children:[p.jsxs("div",{className:"flex items-baseline gap-2",children:[p.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),p.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:f})]}),u.description&&p.jsx("div",{className:"text-xs text-muted-foreground",children:u.description}),p.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:p.jsx(ta,{mentions:s,value:d,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=p.jsx("div",{className:"space-y-4",children:Object.entries(t.properties).map(a=>{const[c,u]=a,d=r[c];return i(c,d,u)})}),e[2]=r,e[3]=t.properties,e[4]=i,e[5]=l):l=e[5],l}function zh({inputSchema:n,inputParams:e,setInputParams:t,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!n)return p.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return p.jsx(kS,{inputSchema:n,inputParams:e,mentions:i});const l=n,a=N.useRef(e??{}),c=u=>{const d=u.formData??{},f=a.current;if(t?.(d),r){for(const[h,m]of Object.entries(d))f[h]!==m&&r(h,m);for(const h of Object.keys(f))h in d||r(h,void 0)}a.current=d};return p.jsx(Vu.Provider,{value:i,children:p.jsx(nm,{schema:l,formData:e,onChange:c,validator:rm,widgets:cS,templates:bS,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:p.jsx(p.Fragment,{})})})}function vS(n){const e=P.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]=N.useState(l);let u;e[1]!==a||e[2]!==r||e[3]!==o?(u=async()=>{await o(a),r(!1),c({})},e[1]=a,e[2]=r,e[3]=o,e[4]=u):u=e[4];const d=u;let f;e[5]!==r?(f=M=>{M||c({}),r(M)},e[5]=r,e[6]=f):f=e[6];const h=f;let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsxs(zp,{children:[p.jsx(Bp,{children:"Workflow Input"}),p.jsx(Fp,{children:"This workflow requires input values to run. Fill in the fields below to start the execution."})]}),e[7]=m):m=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=[],e[8]=g):g=e[8];let y;e[9]!==a||e[10]!==s?(y=p.jsx("div",{className:"py-4",children:p.jsx(zh,{inputSchema:s,inputParams:a,setInputParams:c,mentions:g})}),e[9]=a,e[10]=s,e[11]=y):y=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=p.jsx(ce,{variant:"outline",onClick:x,disabled:i,children:"Cancel"}),e[14]=i,e[15]=x,e[16]=b):b=e[16];let v;e[17]!==i?(v=i?p.jsx(Ln,{size:"xs"}):p.jsx(il,{size:14}),e[17]=i,e[18]=v):v=e[18];let C;e[19]!==d||e[20]!==i||e[21]!==v?(C=p.jsxs(ce,{onClick:d,disabled:i,className:"gap-2",children:[v,"Run Workflow"]}),e[19]=d,e[20]=i,e[21]=v,e[22]=C):C=e[22];let k;e[23]!==C||e[24]!==b?(k=p.jsxs(Vp,{children:[b,C]}),e[23]=C,e[24]=b,e[25]=k):k=e[25];let w;e[26]!==k||e[27]!==y?(w=p.jsxs(Hp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[m,y,k]}),e[26]=k,e[27]=y,e[28]=w):w=e[28];let S;return e[29]!==h||e[30]!==t||e[31]!==w?(S=p.jsx(Wp,{open:t,onOpenChange:h,children:w}),e[29]=h,e[30]=t,e[31]=w,e[32]=S):S=e[32],S}function wS(n){const e=P.c(54),{title:t,description:r,onSave:s}=n,i=Us().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:u}=hl(),{resetToOriginalWorkflow:d,setSelectedGatewayId:f}=Ge(),h=Ru(),m=zn();let g;e[0]!==t?(g=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t}),e[0]=t,e[1]=g):g=e[1];let y;e[2]!==r?(y=r?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),p.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]=y):y=e[3];let x;e[4]!==g||e[5]!==y?(x=p.jsx(ol,{children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g,y]})}),e[4]=g,e[5]=y,e[6]=x):x=e[6];let b;e[7]!==t||e[8]!==i?(b=p.jsx(Ys,{title:t,url:i,icon:"workflow"}),e[7]=t,e[8]=i,e[9]=b):b=e[9];let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(Ln,{size:"xs"}),e[10]=v):v=e[10];let C;e[11]!==m||e[12]!==f?(C=p.jsx(N.Suspense,{fallback:v,children:p.jsx(lu,{selectedGatewayId:m,onGatewayChange:f,variant:"bordered",placeholder:"Select gateway"})}),e[11]=m,e[12]=f,e[13]=C):C=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k={value:"visual",icon:p.jsx(im,{})},e[14]=k):k=e[14];let w;e[15]===Symbol.for("react.memo_cache_sentinel")?(w=[k,{value:"code",icon:p.jsx(vu,{})}],e[15]=w):w=e[15];let S;e[16]!==a||e[17]!==l?(S=p.jsx(om,{value:l,onValueChange:a,size:"sm",options:w}),e[16]=a,e[17]=l,e[18]=S):S=e[18];const M=!h;let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(Qs,{size:14}),e[19]=T):T=e[19];let E;e[20]!==d||e[21]!==M?(E=p.jsx(Ue,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ce,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:d,disabled:M,"aria-label":"Reset changes",children:T})})}),e[20]=d,e[21]=M,e[22]=E):E=e[22];let R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx(Ke,{side:"bottom",children:"Reset changes"}),e[23]=R):R=e[23];let D;e[24]!==E?(D=p.jsx(We,{children:p.jsxs(qe,{delayDuration:0,children:[E,R]})}),e[24]=E,e[25]=D):D=e[25];const B=!h;let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=p.jsx(Zs,{size:14}),e[26]=_):_=e[26];let O;e[27]!==s||e[28]!==B?(O=p.jsx(Ue,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ce,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:B,"aria-label":"Save workflow",children:_})})}),e[27]=s,e[28]=B,e[29]=O):O=e[29];let A;e[30]===Symbol.for("react.memo_cache_sentinel")?(A=p.jsx(Ke,{side:"bottom",children:"Save workflow"}),e[30]=A):A=e[30];let L;e[31]!==O?(L=p.jsx(We,{children:p.jsxs(qe,{delayDuration:0,children:[O,A]})}),e[31]=O,e[32]=L):L=e[32];const z=c?"secondary":"outline",U=c?"Hide runs":"Show runs";let W;e[33]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(bu,{size:14}),e[33]=W):W=e[33];let H;e[34]!==z||e[35]!==U||e[36]!==u?(H=p.jsx(Ue,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ce,{variant:z,size:"icon",className:"size-7 border border-input",onClick:u,"aria-label":U,children:W})})}),e[34]=z,e[35]=U,e[36]=u,e[37]=H):H=e[37];const K=c?"Hide runs":"Show runs";let Z;e[38]!==K?(Z=p.jsx(Ke,{side:"bottom",children:K}),e[38]=K,e[39]=Z):Z=e[39];let Y;e[40]!==H||e[41]!==Z?(Y=p.jsx(We,{children:p.jsxs(qe,{delayDuration:0,children:[H,Z]})}),e[40]=H,e[41]=Z,e[42]=Y):Y=e[42];let te;e[43]===Symbol.for("react.memo_cache_sentinel")?(te=p.jsx(CS,{}),e[43]=te):te=e[43];let fe;e[44]!==D||e[45]!==L||e[46]!==Y||e[47]!==b||e[48]!==C||e[49]!==S?(fe=p.jsxs(Xs,{children:[b,C,S,D,L,Y,te]}),e[44]=D,e[45]=L,e[46]=Y,e[47]=b,e[48]=C,e[49]=S,e[50]=fe):fe=e[50];let Fe;return e[51]!==fe||e[52]!==x?(Fe=p.jsxs(p.Fragment,{children:[x,fe]}),e[51]=fe,e[52]=x,e[53]=Fe):Fe=e[53],Fe}function SS(){const n=Pt(),{item:e}=Cr(n);return e?.completed_at_epoch_ms!=null}function CS(){const n=P.c(38),e=Ru(),t=SS(),r=Pt(),s=zn(),{handleRunWorkflow:o,isPending:i,requiresInput:l,inputSchema:a}=g0(),c=wr(),[u,d]=N.useState(!1),f=r&&!t;let h;n[0]!==c?(h=c.some(NS),n[0]=c,n[1]=h):h=n[1];const m=h,g=!s,y=f||e||m||g;let x;n[2]!==m||n[3]!==g||n[4]!==e||n[5]!==f?(x=()=>f?"Workflow is currently running":e?"Save your changes before running":g?"Select a gateway first":m?"All steps must have a tool selected":null,n[2]=m,n[3]=g,n[4]=e,n[5]=f,n[6]=x):x=n[6];const v=x();let C;n[7]!==o||n[8]!==a||n[9]!==l?(C=()=>{l&&a?d(!0):o({})},n[7]=o,n[8]=a,n[9]=l,n[10]=C):C=n[10];const k=C;let w;n[11]!==o?(w=async U=>{await o(U)},n[11]=o,n[12]=w):w=n[12];const S=w,M=r?t?"Replay":"Running...":l?"Run with input...":"Run workflow",T=!f&&"bg-primary text-primary-foreground hover:bg-primary/90";let E;n[13]!==T?(E=X("gap-2 h-7 px-3",T),n[13]=T,n[14]=E):E=n[14];let R;n[15]!==f?(R=!f&&p.jsx(il,{size:14}),n[15]=f,n[16]=R):R=n[16];let D;n[17]!==f?(D=f&&p.jsx(Ln,{size:"xs"}),n[17]=f,n[18]=D):D=n[18];let B;n[19]!==M||n[20]!==k||n[21]!==y||n[22]!==E||n[23]!==R||n[24]!==D?(B=p.jsxs(ce,{variant:"default",size:"sm",className:E,disabled:y,onClick:k,children:[R,D,M]}),n[19]=M,n[20]=k,n[21]=y,n[22]=E,n[23]=R,n[24]=D,n[25]=B):B=n[25];const _=B;let O;n[26]!==_||n[27]!==v?(O=v?p.jsx(We,{children:p.jsxs(qe,{delayDuration:0,children:[p.jsx(Ue,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:_})}),p.jsx(Ke,{side:"bottom",children:v})]})}):_,n[26]=_,n[27]=v,n[28]=O):O=n[28];const A=O;let L;n[29]!==S||n[30]!==a||n[31]!==i||n[32]!==l||n[33]!==u?(L=l&&a&&p.jsx(vS,{open:u,onOpenChange:d,inputSchema:a,onSubmit:S,isPending:i}),n[29]=S,n[30]=a,n[31]=i,n[32]=l,n[33]=u,n[34]=L):L=n[34];let z;return n[35]!==A||n[36]!==L?(z=p.jsxs(p.Fragment,{children:[A,L]}),n[35]=A,n[36]=L,n[37]=z):z=n[37],z}function NS(n){return"toolName"in n.action&&(!n.action.toolName||n.action.toolName==="")}function ES(){const n=P.c(4),e=Pt(),t=wr(),{step_results:r,item:s}=Cr(e);if(!e||!s)return;let o;if(n[0]!==s||n[1]!==r||n[2]!==t){o={};const i=new Map;if(r)for(const a of r){const c=a.step_id;c&&i.set(c,{output:a.output,error:a.error})}let l=-1;t.forEach((a,c)=>{const u=i.get(a.name);(u?.output!==void 0||u?.error!==void 0)&&(l=c)}),t.forEach((a,c)=>{const u=i.get(a.name);let d="pending";u?.error!==void 0?d="error":u?.output!==void 0?d="success":s.status==="running"&&c===l+1&&(d="running"),o[a.name]={status:d,output:u?.output,error:typeof u?.error=="string"?u.error:void 0,stepIndex:c}}),n[0]=s,n[1]=r,n[2]=t,n[3]=o}else o=n[3];return o}function TS(n){const e=P.c(107),{step:t,index:r,isSelected:s,executionStatus:o,isSkipped:i,onSelect:l,onDelete:a,onDuplicate:c}=n,u=Pt(),{item:d}=Cr(u),f=d?.completed_at_epoch_ms,h="toolName"in t.action,m=h&&"connectionId"in t.action?t.action.connectionId:null,y=!!(h&&"toolName"in t.action?t.action.toolName:null);let x,b,v,C,k,w,S,M,T,E,R;if(e[0]!==m||e[1]!==o||e[2]!==y||e[3]!==r||e[4]!==s||e[5]!==i||e[6]!==h||e[7]!==a||e[8]!==c||e[9]!==l||e[10]!==t){const A=_S(t);x=o?.status;const L=o!==void 0,z=x==="success"||x==="error";let U=A.length>0?60:12;(x==="success"||x==="error")&&(U=U+32);let W,H,K;if(e[22]!==s||e[23]!==i||e[24]!==l||e[25]!==x){const Fn=AS(x);let Or;e[34]!==x?(Or=IS(x),e[34]=x,e[35]=Or):Or=e[35],W=Or;const Mo=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",Oo=x==="running"&&"bg-accent/50",Ao=i&&"opacity-50";e[36]!==Mo||e[37]!==Oo||e[38]!==Ao?(w=X("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",Mo,Oo,Ao),e[36]=Mo,e[37]=Oo,e[38]=Ao,e[39]=w):w=e[39],S=l,M="button",T=0,e[40]!==l?(E=Io=>{(Io.key==="Enter"||Io.key===" ")&&(Io.preventDefault(),l())},e[40]=l,e[41]=E):E=e[41],K="w-5 flex flex-col items-center justify-center shrink-0 pt-3",H=X("text-xs font-mono opacity-75 h-8 flex items-center",Fn),e[22]=s,e[23]=i,e[24]=l,e[25]=x,e[26]=W,e[27]=H,e[28]=K,e[29]=w,e[30]=S,e[31]=M,e[32]=T,e[33]=E}else W=e[26],H=e[27],K=e[28],w=e[29],S=e[30],M=e[31],T=e[32],E=e[33];const Z=r+1;let Y;e[42]!==H||e[43]!==Z?(Y=p.jsxs("span",{className:H,children:[Z,"."]}),e[42]=H,e[43]=Z,e[44]=Y):Y=e[44],e[45]!==K||e[46]!==Y?(R=p.jsx("div",{className:K,children:Y}),e[45]=K,e[46]=Y,e[47]=R):R=e[47];let te;e[48]!==W||e[49]!==r?(te=r>0?p.jsx(gi,{height:12,color:W}):p.jsx("div",{className:"h-3"}),e[48]=W,e[49]=r,e[50]=te):te=e[50];let fe;e[51]!==m||e[52]!==y||e[53]!==h||e[54]!==t.name?(fe=p.jsx(LS,{connectionId:m,isToolStep:h,hasToolSelected:y,stepName:t.name}),e[51]=m,e[52]=y,e[53]=h,e[54]=t.name,e[55]=fe):fe=e[55];let Fe;e[56]!==W||e[57]!==z||e[58]!==x?(Fe=z&&p.jsxs(p.Fragment,{children:[p.jsx(gi,{height:8,color:W}),p.jsx(jS,{status:x})]}),e[56]=W,e[57]=z,e[58]=x,e[59]=Fe):Fe=e[59];let sn;e[60]!==W||e[61]!==U?(sn=p.jsx(gi,{height:U,color:W}),e[60]=W,e[61]=U,e[62]=sn):sn=e[62],e[63]!==te||e[64]!==fe||e[65]!==Fe||e[66]!==sn?(v=p.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[te,fe,Fe,sn]}),e[63]=te,e[64]=fe,e[65]=Fe,e[66]=sn,e[67]=v):v=e[67],b="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const To=y?"font-medium text-foreground":"text-foreground";let on;e[68]!==To?(on=X("text-sm truncate flex-1",To),e[68]=To,e[69]=on):on=e[69];let ln;e[70]!==t?(ln=$S(t),e[70]=t,e[71]=ln):ln=e[71];let an;e[72]!==on||e[73]!==ln?(an=p.jsx("span",{className:on,children:ln}),e[72]=on,e[73]=ln,e[74]=an):an=e[74];let cn;e[75]!==L||e[76]!==x?(cn=L&&p.jsx(RS,{status:x}),e[75]=L,e[76]=x,e[77]=cn):cn=e[77];let un;e[78]!==L||e[79]!==a||e[80]!==c?(un=!L&&p.jsxs(cm,{children:[p.jsx(um,{asChild:!0,children:p.jsx(ce,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:OS,children:p.jsx(cu,{size:14})})}),p.jsxs(dm,{align:"end",children:[p.jsxs(da,{onClick:Fn=>{Fn.stopPropagation(),c()},children:[p.jsx(pm,{size:14}),"Duplicate"]}),p.jsxs(da,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:Fn=>{Fn.stopPropagation(),a()},children:[p.jsx(vp,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[78]=L,e[79]=a,e[80]=c,e[81]=un):un=e[81],e[82]!==an||e[83]!==cn||e[84]!==un?(C=p.jsxs("div",{className:"flex items-center h-8",children:[an,cn,un]}),e[82]=an,e[83]=cn,e[84]=un,e[85]=C):C=e[85],k=A.length>0&&p.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(MS)}),e[0]=m,e[1]=o,e[2]=y,e[3]=r,e[4]=s,e[5]=i,e[6]=h,e[7]=a,e[8]=c,e[9]=l,e[10]=t,e[11]=x,e[12]=b,e[13]=v,e[14]=C,e[15]=k,e[16]=w,e[17]=S,e[18]=M,e[19]=T,e[20]=E,e[21]=R}else x=e[11],b=e[12],v=e[13],C=e[14],k=e[15],w=e[16],S=e[17],M=e[18],T=e[19],E=e[20],R=e[21];let D;e[86]!==f||e[87]!==x?(D=x==="success"&&p.jsx(DS,{completedAtEpochMs:f}),e[86]=f,e[87]=x,e[88]=D):D=e[88];let B;e[89]!==o?.error||e[90]!==x?(B=x==="error"&&p.jsx(PS,{error:o?.error}),e[89]=o?.error,e[90]=x,e[91]=B):B=e[91];let _;e[92]!==b||e[93]!==D||e[94]!==B||e[95]!==C||e[96]!==k?(_=p.jsxs("div",{className:b,children:[C,k,D,B]}),e[92]=b,e[93]=D,e[94]=B,e[95]=C,e[96]=k,e[97]=_):_=e[97];let O;return e[98]!==v||e[99]!==_||e[100]!==w||e[101]!==S||e[102]!==M||e[103]!==T||e[104]!==E||e[105]!==R?(O=p.jsxs("div",{className:w,onClick:S,role:M,tabIndex:T,onKeyDown:E,children:[R,v,_]}),e[98]=v,e[99]=_,e[100]=w,e[101]=S,e[102]=M,e[103]=T,e[104]=E,e[105]=R,e[106]=O):O=e[106],O}function MS(n){return p.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:n},n)}function OS(n){return n.stopPropagation()}function AS(n){switch(n){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function IS(n){switch(n){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function jS(n){const e=P.c(2),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"size-4 rounded bg-success flex items-center justify-center",children:p.jsx(rl,{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=p.jsx("div",{className:"size-4 rounded bg-destructive flex items-center justify-center",children:p.jsx(ll,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function RS(n){const e=P.c(3),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"size-7 flex items-center justify-center",children:p.jsx(rl,{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=p.jsx("div",{className:"size-7 flex items-center justify-center",children:p.jsx(ll,{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=p.jsx("div",{className:"size-7 flex items-center justify-center",children:p.jsx(Gt,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function DS(n){const e=P.c(9),{completedAtEpochMs:t}=n;let r,s;if(e[0]!==t){const c=t!=null?new Date(t):null;r=c?c.toISOString().split("T")[0]:null,s=c?c.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&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(am,{size:16,className:"text-success"}),p.jsx("span",{className:"text-xs text-success",children:r}),p.jsx("span",{className:"text-xs text-success",children:o})]}),e[3]=r,e[4]=o,e[5]=i):i=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(wu,{size:16,className:"text-success"}),p.jsx("span",{className:"text-xs text-success",children:"—"})]}),e[6]=l):l=e[6];let a;return e[7]!==i?(a=p.jsxs("div",{className:"inline-flex items-center gap-3 px-1.5 py-1 bg-success-foreground rounded-lg w-fit",children:[i,l]}),e[7]=i,e[8]=a):a=e[8],a}function PS(n){const e=P.c(3),{error:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(cl,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=t||"Execution failed";let o;return e[1]!==s?(o=p.jsxs("div",{className:"inline-flex items-center gap-1.5 px-1.5 py-1 bg-destructive-foreground rounded-lg w-fit",children:[r,p.jsx("span",{className:"text-xs text-destructive",children:s})]}),e[1]=s,e[2]=o):o=e[2],o}function LS(n){const e=P.c(5),{connectionId:t,isToolStep:r,hasToolSelected:s,stepName:o}=n,i=nl(t??"");if(r&&s&&i?.icon){let a;return e[0]!==i.icon||e[1]!==o?(a=p.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center overflow-hidden",children:p.jsx(Gs,{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=p.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center",children:r?p.jsx(Tu,{size:16,className:"text-muted-foreground"}):p.jsx(hm,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function gi(n){const e=P.c(7),{height:t,color:r}=n,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=X("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=p.jsx("div",{className:o,style:i}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function $S(n){return"toolName"in n.action&&n.action.toolName?n.action.toolName:"code"in n.action?n.name||"Code Step":"Select tool..."}function _S(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 zS(n){const e=P.c(36),{className:t}=n,r=wr(),s=ju(),o=ES(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a,addToolStep:c}=Ge();let u;e[0]!==o||e[1]!==r?(u=o?r.findIndex(S=>o[S.name]?.status==="error"):-1,e[0]=o,e[1]=r,e[2]=u):u=e[2];const d=u;let f;e[3]!==t?(f=X("h-full flex flex-col p-8 overflow-auto",t),e[3]=t,e[4]=f):f=e[4];let h;if(e[5]!==s||e[6]!==l||e[7]!==a||e[8]!==d||e[9]!==i||e[10]!==o||e[11]!==r){let S;e[13]!==s||e[14]!==l||e[15]!==a||e[16]!==d||e[17]!==i||e[18]!==o?(S=(M,T)=>{const E=o?.[M.name],R=d!==-1&&T>d&&E?.status==="pending";return p.jsx(TS,{step:M,index:T,isSelected:M.name===s,executionStatus:E,isSkipped:R,onSelect:()=>i(M.name),onDelete:()=>l(M.name),onDuplicate:()=>a(M.name)},M.name)},e[13]=s,e[14]=l,e[15]=a,e[16]=d,e[17]=i,e[18]=o,e[19]=S):S=e[19],h=r.map(S),e[5]=s,e[6]=l,e[7]=a,e[8]=d,e[9]=i,e[10]=o,e[11]=r,e[12]=h}else h=e[12];let m;e[20]!==h?(m=p.jsx("div",{className:"pt-3 -space-y-1",children:h}),e[20]=h,e[21]=m):m=e[21];let g;e[22]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx("div",{className:"w-5 shrink-0"}),e[22]=g):g=e[22];let y;e[23]===Symbol.for("react.memo_cache_sentinel")?(y=p.jsx("div",{className:"w-px h-3 bg-border"}),e[23]=y):y=e[23];let x;e[24]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx(sl,{size:14}),e[24]=x):x=e[24];let b;e[25]!==c?(b=p.jsx(ce,{variant:"outline",size:"icon",className:"size-8 rounded-lg",onClick:c,children:x}),e[25]=c,e[26]=b):b=e[26];let v;e[27]===Symbol.for("react.memo_cache_sentinel")?(v=p.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%"}}),e[27]=v):v=e[27];let C;e[28]!==b?(C=p.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[g,p.jsxs("div",{className:"flex flex-col border-1 border-transparent items-center shrink-0",children:[y,b,v]})]}),e[28]=b,e[29]=C):C=e[29];let k;e[30]!==C||e[31]!==m?(k=p.jsxs("div",{className:"w-full -space-y-1",children:[m,C]}),e[30]=C,e[31]=m,e[32]=k):k=e[32];let w;return e[33]!==k||e[34]!==f?(w=p.jsx("div",{className:f,children:k}),e[33]=k,e[34]=f,e[35]=w):w=e[35],w}function BS(){const n=P.c(5),e=zn();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],al(o)}function FS(n){const e=P.c(7),{className:t}=n;if(!zn()){let o;e[0]!==t?(o=X("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=p.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=p.jsx("div",{className:o,children:i}),e[3]=o,e[4]=l):l=e[4],l}let s;return e[5]!==t?(s=p.jsx(VS,{className:t}),e[5]=t,e[6]=s):s=e[6],s}function VS(n){const e=P.c(38),{className:t}=n,{tools:r,isLoading:s,error:o}=BS(),i=to(),{updateStep:l}=Ge(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let u;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],u=r.find(k),e[0]=c,e[1]=r,e[2]=u}else u=e[2];const f=x0(r,u??null,WS,HS);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 m=h;if(s){let k;e[8]!==t?(k=X("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=p.jsx("div",{className:"flex-1 flex items-center justify-center",children:p.jsx(Ln,{size:"sm"})}),e[10]=w):w=e[10];let S;return e[11]!==k?(S=p.jsx("div",{className:k,children:w}),e[11]=k,e[12]=S):S=e[12],S}if(o){let k;e[13]!==t?(k=X("flex flex-col h-full bg-sidebar",t),e[13]=t,e[14]=k):k=e[14];let w;e[15]!==o.message?(w=p.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 S;return e[17]!==k||e[18]!==w?(S=p.jsx("div",{className:k,children:w}),e[17]=k,e[18]=w,e[19]=S):S=e[19],S}let g;e[20]!==t?(g=X("flex flex-col h-full bg-sidebar",t),e[20]=t,e[21]=g):g=e[21];let y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=p.jsx("span",{className:"text-base font-medium text-foreground",children:"Select tool"}),e[22]=y):y=e[22];let x;e[23]!==r.length?(x=p.jsx("div",{className:"flex items-start border-b border-border",children:p.jsxs("div",{className:"flex-1 flex items-center h-12 px-5",children:[y,p.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]!==m||e[26]!==f||e[27]!==c){let k;e[29]!==m||e[30]!==c?(k=w=>p.jsx(qS,{icon:null,title:w.name,description:w.description,isSelected:w.name===c,onClick:()=>m(w)},w.name),e[29]=m,e[30]=c,e[31]=k):k=e[31],b=f.map(k),e[25]=m,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let v;e[32]!==b?(v=p.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=v):v=e[33];let C;return e[34]!==g||e[35]!==x||e[36]!==v?(C=p.jsxs("div",{className:g,children:[x,v]}),e[34]=g,e[35]=x,e[36]=v,e[37]=C):C=e[37],C}function HS(n,e){return n.name.localeCompare(e.name)}function WS(n){return n.name}function qS(n){const e=P.c(20),{icon:t,title:r,description:s,isSelected:o,onClick:i}=n,l=o&&"bg-muted/50";let a;e[0]!==l?(a=X("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=g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),i())},e[2]=i,e[3]=c):c=e[3];let u;e[4]!==t||e[5]!==r?(u=p.jsx(Gs,{icon:t,name:r,size:"xs",className:"shadow-sm mt-0.5"}),e[4]=t,e[5]=r,e[6]=u):u=e[6];let d;e[7]!==r?(d=p.jsx("span",{className:"text-sm font-medium text-foreground truncate block",children:r}),e[7]=r,e[8]=d):d=e[8];let f;e[9]!==s?(f=s&&p.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]!==d||e[12]!==f?(h=p.jsxs("div",{className:"flex-1 min-w-0",children:[d,f]}),e[11]=d,e[12]=f,e[13]=h):h=e[13];let m;return e[14]!==i||e[15]!==a||e[16]!==c||e[17]!==u||e[18]!==h?(m=p.jsxs("div",{className:a,onClick:i,role:"button",tabIndex:0,onKeyDown:c,children:[u,h]}),e[14]=i,e[15]=a,e[16]=c,e[17]=u,e[18]=h,e[19]=m):m=e[19],m}var Co="Collapsible",[US,Bh]=Xi(Co),[KS,na]=US(Co),Fh=N.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=n,[a,c]=Ks({prop:r,defaultProp:s??!1,onChange:i,caller:Co});return p.jsx(KS,{scope:t,disabled:o,contentId:iu(),open:a,onOpenToggle:N.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Rn.div,{"data-state":sa(a),"data-disabled":o?"":void 0,...l,ref:e})})});Fh.displayName=Co;var Vh="CollapsibleTrigger",Hh=N.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=na(Vh,t);return p.jsx(Rn.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":sa(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:Ve(n.onClick,s.onOpenToggle)})});Hh.displayName=Vh;var ra="CollapsibleContent",Wh=N.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=na(ra,n.__scopeCollapsible);return p.jsx(Qi,{present:t||s.open,children:({present:o})=>p.jsx(JS,{...r,ref:e,present:o})})});Wh.displayName=ra;var JS=N.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...o}=n,i=na(ra,t),[l,a]=N.useState(r),c=N.useRef(null),u=Zi(e,c),d=N.useRef(0),f=d.current,h=N.useRef(0),m=h.current,g=i.open||l,y=N.useRef(g),x=N.useRef(void 0);return N.useEffect(()=>{const b=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(b)},[]),wp(()=>{const b=c.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const v=b.getBoundingClientRect();d.current=v.height,h.current=v.width,y.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),a(r)}},[i.open,r]),p.jsx(Rn.div,{"data-state":sa(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...n.style},children:g&&s})});function sa(n){return n?"open":"closed"}var GS=Fh,YS=Hh,XS=Wh,Ye="Accordion",QS=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[oa,ZS,eC]=Sp(Ye),[No]=Xi(Ye,[eC,Bh]),ia=Bh(),qh=Q.forwardRef((n,e)=>{const{type:t,...r}=n,s=r,o=r;return p.jsx(oa.Provider,{scope:n.__scopeAccordion,children:t==="multiple"?p.jsx(sC,{...o,ref:e}):p.jsx(rC,{...s,ref:e})})});qh.displayName=Ye;var[Uh,tC]=No(Ye),[Kh,nC]=No(Ye,{collapsible:!1}),rC=Q.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=n,[l,a]=Ks({prop:t,defaultProp:r??"",onChange:s,caller:Ye});return p.jsx(Uh,{scope:n.__scopeAccordion,value:Q.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:Q.useCallback(()=>o&&a(""),[o,a]),children:p.jsx(Kh,{scope:n.__scopeAccordion,collapsible:o,children:p.jsx(Jh,{...i,ref:e})})})}),sC=Q.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},...o}=n,[i,l]=Ks({prop:t,defaultProp:r??[],onChange:s,caller:Ye}),a=Q.useCallback(u=>l((d=[])=>[...d,u]),[l]),c=Q.useCallback(u=>l((d=[])=>d.filter(f=>f!==u)),[l]);return p.jsx(Uh,{scope:n.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:p.jsx(Kh,{scope:n.__scopeAccordion,collapsible:!0,children:p.jsx(Jh,{...o,ref:e})})})}),[oC,Eo]=No(Ye),Jh=Q.forwardRef((n,e)=>{const{__scopeAccordion:t,disabled:r,dir:s,orientation:o="vertical",...i}=n,l=Q.useRef(null),a=Zi(l,e),c=ZS(t),d=Cp(s)==="ltr",f=Ve(n.onKeyDown,h=>{if(!QS.includes(h.key))return;const m=h.target,g=c().filter(M=>!M.ref.current?.disabled),y=g.findIndex(M=>M.ref.current===m),x=g.length;if(y===-1)return;h.preventDefault();let b=y;const v=0,C=x-1,k=()=>{b=y+1,b>C&&(b=v)},w=()=>{b=y-1,b<v&&(b=C)};switch(h.key){case"Home":b=v;break;case"End":b=C;break;case"ArrowRight":o==="horizontal"&&(d?k():w());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(d?w():k());break;case"ArrowUp":o==="vertical"&&w();break}const S=b%x;g[S].ref.current?.focus()});return p.jsx(oC,{scope:t,disabled:r,direction:s,orientation:o,children:p.jsx(oa.Slot,{scope:t,children:p.jsx(Rn.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),qs="AccordionItem",[iC,la]=No(qs),Gh=Q.forwardRef((n,e)=>{const{__scopeAccordion:t,value:r,...s}=n,o=Eo(qs,t),i=tC(qs,t),l=ia(t),a=iu(),c=r&&i.value.includes(r)||!1,u=o.disabled||n.disabled;return p.jsx(iC,{scope:t,open:c,disabled:u,triggerId:a,children:p.jsx(GS,{"data-orientation":o.orientation,"data-state":tp(c),...l,...s,ref:e,disabled:u,open:c,onOpenChange:d=>{d?i.onItemOpen(r):i.onItemClose(r)}})})});Gh.displayName=qs;var Yh="AccordionHeader",Xh=Q.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=Eo(Ye,t),o=la(Yh,t);return p.jsx(Rn.h3,{"data-orientation":s.orientation,"data-state":tp(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});Xh.displayName=Yh;var Gi="AccordionTrigger",Qh=Q.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=Eo(Ye,t),o=la(Gi,t),i=nC(Gi,t),l=ia(t);return p.jsx(oa.ItemSlot,{scope:t,children:p.jsx(YS,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});Qh.displayName=Gi;var Zh="AccordionContent",ep=Q.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=Eo(Ye,t),o=la(Zh,t),i=ia(t);return p.jsx(XS,{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}})});ep.displayName=Zh;function tp(n){return n?"open":"closed"}var lC=qh,aC=Gh,cC=Xh,uC=Qh,dC=ep;function np(n){const e=P.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=p.jsx(lC,{"data-slot":"accordion",...t}),e[2]=t,e[3]=r):r=e[3],r}function rp(n){const e=P.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=X("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=p.jsx(aC,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function sp(n){const e=P.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=X("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=p.jsx(fm,{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=p.jsx(cC,{className:"flex",children:p.jsxs(uC,{"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 op(n){const e=P.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=X("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==t||e[7]!==o?(i=p.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=p.jsx(dC,{"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}function fC(n){const{updateStep:e}=Ge(),r=n&&"toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,{tool:s}=aa(r??"");n&&r&&s?.outputSchema&&(!n.outputSchema||Object.keys(n.outputSchema).length===0)&&queueMicrotask(()=>{e(n.name,{outputSchema:s.outputSchema})})}function hC(n){const e=P.c(23),{className:t}=n,r=to();if(fC(r),!r){let f;e[0]!==t?(f=X("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=f):f=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Select a step to configure"}),e[2]=h):h=e[2];let m;return e[3]!==f?(m=p.jsx("div",{className:f,children:h}),e[3]=f,e[4]=m):m=e[4],m}if(!("toolName"in r.action&&"toolName"in r.action&&r.action.toolName)){let f;e[5]!==t?(f=X("flex flex-col h-full bg-sidebar",t),e[5]=t,e[6]=f):f=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Select a tool to configure this step"}),e[7]=h):h=e[7];let m;return e[8]!==f?(m=p.jsx("div",{className:f,children:h}),e[8]=f,e[9]=m):m=e[9],m}let i;e[10]!==t?(i=X("flex flex-col h-full bg-sidebar overflow-auto",t),e[10]=t,e[11]=i):i=e[11];let l,a,c,u;e[12]!==r?(l=p.jsx(pC,{step:r}),a=p.jsx(mC,{step:r}),c=p.jsx(gC,{step:r}),u=p.jsx(vC,{step:r}),e[12]=r,e[13]=l,e[14]=a,e[15]=c,e[16]=u):(l=e[13],a=e[14],c=e[15],u=e[16]);let d;return e[17]!==i||e[18]!==l||e[19]!==a||e[20]!==c||e[21]!==u?(d=p.jsxs("div",{className:i,children:[l,a,c,u]}),e[17]=i,e[18]=l,e[19]=a,e[20]=c,e[21]=u,e[22]=d):d=e[22],d}function pC(n){const e=P.c(22),{step:t}=n,{updateStep:r,startReplacingTool:s}=Ge(),i="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null;let l;e[0]!==s||e[1]!==t.action||e[2]!==t.name||e[3]!==i||e[4]!==r?(l=()=>{i&&s(i),r(t.name,{action:{...t.action,toolName:""}})},e[0]=s,e[1]=t.action,e[2]=t.name,e[3]=i,e[4]=r,e[5]=l):l=e[5];const a=l,c=i??"";let u;e[6]!==c?(u=p.jsx(Gs,{icon:null,name:c,size:"xs",className:"shadow-sm"}),e[6]=c,e[7]=u):u=e[7];let d;e[8]!==i?(d=p.jsx("span",{className:"text-base font-medium text-foreground truncate flex-1",children:i}),e[8]=i,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx(Eu,{size:14}),e[10]=f):f=e[10];let h;e[11]!==a?(h=p.jsx(ce,{variant:"ghost",size:"icon",className:"size-7",onClick:a,title:"Replace tool",children:f}),e[11]=a,e[12]=h):h=e[12];let m;e[13]!==u||e[14]!==d||e[15]!==h?(m=p.jsxs("div",{className:"flex items-center gap-2",children:[u,d,h]}),e[13]=u,e[14]=d,e[15]=h,e[16]=m):m=e[16];let g;e[17]!==t.description?(g=t.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[17]=t.description,e[18]=g):g=e[18];let y;return e[19]!==m||e[20]!==g?(y=p.jsxs("div",{className:"border-b border-border p-5 shrink-0",children:[m,g]}),e[19]=m,e[20]=g,e[21]=y):y=e[21],y}function aa(n){const e=P.c(13),t=zn();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=al(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,u=l.state==="connecting",d=l.state==="ready";let f;return e[8]!==l.error||e[9]!==u||e[10]!==d||e[11]!==c?(f={tool:c,isLoading:u,isReady:d,error:l.error},e[8]=l.error,e[9]=u,e[10]=d,e[11]=c,e[12]=f):f=e[12],f}function mC(n){const e=P.c(9),{step:t}=n,{updateStep:r}=Ge(),o="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,{tool:i}=aa(o??"");if(!i||!i.inputSchema)return null;let l;e[0]!==t.name||e[1]!==r?(l=m=>{r(t.name,{input:m})},e[0]=t.name,e[1]=r,e[2]=l):l=e[2];const a=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(sp,{className:"px-5 py-5",children:p.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Input"})}),e[3]=c):c=e[3];const u=i.inputSchema,d=t.input;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[4]=f):f=e[4];let h;return e[5]!==a||e[6]!==u||e[7]!==d?(h=p.jsx(np,{type:"single",collapsible:!0,defaultValue:"input",className:"border-b border-border shrink-0",children:p.jsxs(rp,{value:"input",className:"border-b-0",children:[c,p.jsx(op,{className:"px-5 pt-2",children:p.jsx(zh,{inputSchema:u,inputParams:d,setInputParams:a,mentions:f})})]})}),e[5]=a,e[6]=u,e[7]=d,e[8]=h):h=e[8],h}function gC(n){const e=P.c(9),{step:t}=n,r=t.outputSchema,s=Pt(),{step_results:o}=Cr(s);let i;e[0]!==t.name||e[1]!==o?(i=o?.find(m=>m.step_id===t.name),e[0]=t.name,e[1]=o,e[2]=i):i=e[2];const a=i?.output,c=r&&typeof r=="object"?r.properties:void 0;let u;e[3]!==c?(u=c?Object.entries(c):[],e[3]=c,e[4]=u):u=e[4];const d=u;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx(sp,{className:"px-5 py-5",children:p.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Output"})}),e[5]=f):f=e[5];let h;return e[6]!==a||e[7]!==d?(h=p.jsx(np,{type:"single",collapsible:!0,defaultValue:"output",className:"border-b border-border shrink-0",children:p.jsxs(rp,{value:"output",className:"border-b-0",children:[f,p.jsx(op,{className:"px-5 pt-2",children:d.length===0?p.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No output schema defined"}):a?p.jsx(xC,{output:a}):p.jsx("div",{className:"space-y-2",children:d.map(yC)})})]})}),e[6]=a,e[7]=d,e[8]=h):h=e[8],h}function yC(n){const[e,t]=n;return p.jsx(kC,{name:e,schema:t},e)}function xC(n){const e=P.c(6),{output:t}=n;let r,s;e[0]!==t?(r=JSON.stringify(t,null,2),s=r.split(`
|
|
165
|
+
`),e[0]=t,e[1]=r,e[2]=s):(r=e[1],s=e[2]);const o=s.length,i=Math.min(Math.max(o*18+24,80),400);let l;return e[3]!==r||e[4]!==i?(l=p.jsx(dl,{code:r,language:"json",height:i,readOnly:!0}),e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function bC(n){switch(n){case"string":return{Icon:yu,color:"text-blue-500"};case"number":case"integer":return{Icon:mu,color:"text-blue-500"};case"array":return{Icon:hu,color:"text-purple-500"};case"object":return{Icon:fu,color:"text-orange-500"};case"boolean":return{Icon:gu,color:"text-pink-500"};case"null":return{Icon:el,color:"text-gray-500"};default:return{Icon:pu,color:"text-muted-foreground"}}}function kC(n){const e=P.c(28),{name:t,schema:r}=n,s=to(),o=r.type??"unknown";let i,l,a,c,u;if(e[0]!==o){const{Icon:C,color:k}=bC(o);u="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=C,l=14,a=X(k),e[0]=o,e[1]=i,e[2]=l,e[3]=a,e[4]=c,e[5]=u}else i=e[1],l=e[2],a=e[3],c=e[4],u=e[5];let d;e[6]!==i||e[7]!==l||e[8]!==a?(d=p.jsx(i,{size:l,className:a}),e[6]=i,e[7]=l,e[8]=a,e[9]=d):d=e[9];let f;e[10]!==t?(f=p.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]!==d||e[14]!==f?(h=p.jsxs("div",{className:c,children:[d,f]}),e[12]=c,e[13]=d,e[14]=f,e[15]=h):h=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(Su,{size:14,className:"opacity-50"}),e[16]=m):m=e[16];const g=s?.name;let y;e[17]!==g?(y=p.jsxs("span",{className:"text-muted-foreground",children:[g,"."]}),e[17]=g,e[18]=y):y=e[18];let x;e[19]!==t?(x=p.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]!==y||e[22]!==x?(b=p.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[m,y,x]}),e[21]=y,e[22]=x,e[23]=b):b=e[23];let v;return e[24]!==b||e[25]!==u||e[26]!==h?(v=p.jsxs("div",{className:u,children:[h,b]}),e[24]=b,e[25]=u,e[26]=h,e[27]=v):v=e[27],v}function vC(n){const e=P.c(27),{step:t}=n,{updateStep:r}=Ge(),s="toolName"in t.action,o=s&&"toolName"in t.action?t.action.toolName:null,{tool:i}=aa(o??""),l=s&&"transformCode"in t.action?t.action.transformCode??null:null,a=!!l;let c;e[0]!==i?(c=()=>{if(!i?.outputSchema)return`interface Input {
|
|
166
|
+
// Tool output schema not available
|
|
167
|
+
}`;const k=i.outputSchema,w=k.properties;return w?`interface Input {
|
|
168
|
+
${Object.entries(w).map(M=>{const[T,E]=M,R=Xr(E),D=!k.required?.includes(T);return` ${T}${D?"?":""}: ${R};`}).join(`
|
|
169
|
+
`)}
|
|
170
|
+
}`:`interface Input {
|
|
171
|
+
[key: string]: unknown;
|
|
172
|
+
}`},e[0]=i,e[1]=c):c=e[1];const u=c;let d;e[2]!==u||e[3]!==t.action||e[4]!==t.name||e[5]!==r?(d=()=>{const w=`${u()}
|
|
173
|
+
|
|
174
|
+
interface Output {
|
|
175
|
+
// Define your output type here
|
|
176
|
+
result: unknown;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default async function(input: Input): Promise<Output> {
|
|
180
|
+
// Transform the tool output
|
|
181
|
+
return {
|
|
182
|
+
result: input,
|
|
183
|
+
};
|
|
184
|
+
}`;r(t.name,{action:{...t.action,transformCode:w}})},e[2]=u,e[3]=t.action,e[4]=t.name,e[5]=r,e[6]=d):d=e[6];const f=d;let h;e[7]!==t.action||e[8]!==t.name||e[9]!==r?(h=()=>{r(t.name,{action:{...t.action,transformCode:void 0}})},e[7]=t.action,e[8]=t.name,e[9]=r,e[10]=h):h=e[10];const m=h;let g;e[11]!==t.action||e[12]!==t.name||e[13]!==r?(g=(k,w)=>{r(t.name,{action:{...t.action,transformCode:k},...w?{outputSchema:w}:{}})},e[11]=t.action,e[12]=t.name,e[13]=r,e[14]=g):g=e[14];const y=g;if(!a){let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),p.jsx(sl,{size:14,className:"text-muted-foreground"})]}),e[15]=k):k=e[15];let w;return e[16]!==f?(w=p.jsx("div",{className:"border-b border-border p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:f,children:k}),e[16]=f,e[17]=w):w=e[17],w}let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),p.jsx(Np,{size:14,className:"text-muted-foreground"})]}),e[18]=x):x=e[18];let b;e[19]!==m?(b=p.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:m,children:x}),e[19]=m,e[20]=b):b=e[20];let v;e[21]!==y||e[22]!==l?(v=p.jsx("div",{className:"flex-1 min-h-120",children:p.jsx(dl,{code:l,language:"typescript",onSave:y,height:"100%"})}),e[21]=y,e[22]=l,e[23]=v):v=e[23];let C;return e[24]!==b||e[25]!==v?(C=p.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[b,v]}),e[24]=b,e[25]=v,e[26]=C):C=e[26],C}function Xr(n){if(Array.isArray(n.type))return n.type.map(t=>Xr({...n,type:t})).join(" | ");switch(n.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return n.items?`${Xr(n.items)}[]`:"unknown[]";case"object":return n.properties?`{ ${Object.entries(n.properties).map(([r,s])=>{const o=Xr(s),i=!n.required?.includes(r);return`${r}${i?"?":""}: ${o}`}).join("; ")} }`:"Record<string, unknown>";case"null":return"null";default:return"unknown"}}function wC(n){switch(n){case"success":return p.jsxs(fn,{variant:"success",className:"gap-1",children:[p.jsx(rl,{size:11}),"Success"]});case"error":case"failed":return p.jsxs(fn,{variant:"destructive",className:"gap-1",children:[p.jsx(cl,{size:11}),"Error"]});case"running":return p.jsxs(fn,{variant:"secondary",className:"gap-1",children:[p.jsx(qr,{size:11}),"Running"]});case"enqueued":return p.jsxs(fn,{variant:"secondary",className:"gap-1",children:[p.jsx(qr,{size:11}),"On hold"]});case"cancelled":return p.jsxs(fn,{variant:"secondary",className:"gap-1",children:[p.jsx(du,{size:11}),"Cancelled"]});default:return p.jsxs(fn,{variant:"secondary",className:"gap-1",children:[p.jsx(qr,{size:11}),n]})}}function SC(n){return`Run #${n.slice(-4).toUpperCase()}`}function CC(n){const e=P.c(36),{className:t}=n,{executions:r,isLoading:s}=d0(),{setShowExecutionsList:o}=hl(),{setTrackingExecutionId:i}=Ge(),l=Pt(),[a,c]=N.useState("");let u,d,f,h,m;if(e[0]!==t||e[1]!==r||e[2]!==s||e[3]!==a||e[4]!==o||e[5]!==i||e[6]!==l){let x;e[12]!==a?(x=R=>{if(!a)return!0;const D=a.toLowerCase();return R.id.toLowerCase().includes(D)||R.status.toLowerCase().includes(D)},e[12]=a,e[13]=x):x=e[13];const b=r.filter(x);let v;e[14]!==i?(v=R=>{i(R)},e[14]=i,e[15]=v):v=e[15];const C=v;let k;e[16]!==o?(k=()=>{o(!1)},e[16]=o,e[17]=k):k=e[17];const w=k;e[18]!==t?(f=X("flex flex-col h-full bg-sidebar border-l border-border",t),e[18]=t,e[19]=f):f=e[19];let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:"Runs"}),e[20]=S):S=e[20];let M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=p.jsx(du,{size:11}),e[21]=M):M=e[21],e[22]!==w?(h=p.jsxs("div",{className:"flex items-center h-12 px-5 border-b border-border shrink-0",children:[S,p.jsx(ce,{variant:"ghost",size:"icon",className:"size-7",onClick:w,children:M})]}),e[22]=w,e[23]=h):h=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(Pp,{size:16,className:"text-muted-foreground shrink-0"}),e[24]=T):T=e[24];let E;e[25]===Symbol.for("react.memo_cache_sentinel")?(E=R=>c(R.target.value),e[25]=E):E=e[25],e[26]!==a?(m=p.jsxs("div",{className:"flex items-center gap-2.5 h-12 px-4 border-b border-border shrink-0",children:[T,p.jsx(Pn,{type:"text",placeholder:"Search for a run...",value:a,onChange:E,className:"flex-1 border-0 bg-transparent h-full text-sm placeholder:text-muted-foreground/50 focus-visible:ring-0 shadow-none px-0"})]}),e[26]=a,e[27]=m):m=e[27],u="flex-1 overflow-auto",d=s?p.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading executions..."}):b.length===0?p.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:a?"No matching runs found":"No runs yet"}):b.map((R,D)=>p.jsx(NC,{execution:R,isSelected:R.id===l,isFirst:D===0,onSelect:()=>C(R.id)},R.id)),e[0]=t,e[1]=r,e[2]=s,e[3]=a,e[4]=o,e[5]=i,e[6]=l,e[7]=u,e[8]=d,e[9]=f,e[10]=h,e[11]=m}else u=e[7],d=e[8],f=e[9],h=e[10],m=e[11];let g;e[28]!==u||e[29]!==d?(g=p.jsx("div",{className:u,children:d}),e[28]=u,e[29]=d,e[30]=g):g=e[30];let y;return e[31]!==f||e[32]!==h||e[33]!==m||e[34]!==g?(y=p.jsxs("div",{className:f,children:[h,m,g]}),e[31]=f,e[32]=h,e[33]=m,e[34]=g,e[35]=y):y=e[35],y}function NC(n){const e=P.c(20),{execution:t,isSelected:r,isFirst:s,onSelect:o}=n,i=r&&"bg-accent/50",l=s&&r&&"bg-accent/50",a=!r&&"hover:bg-accent/30";let c;e[0]!==i||e[1]!==l||e[2]!==a?(c=X("flex flex-col justify-center h-[60px] px-4 border-b border-border cursor-pointer transition-colors",i,l,a),e[0]=i,e[1]=l,e[2]=a,e[3]=c):c=e[3];let u;e[4]!==t.status?(u=wC(t.status),e[4]=t.status,e[5]=u):u=e[5];let d;e[6]!==t.id?(d=SC(t.id),e[6]=t.id,e[7]=d):d=e[7];let f;e[8]!==d?(f=p.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:d}),e[8]=d,e[9]=f):f=e[9];let h;e[10]!==r?(h=r&&p.jsx(ce,{variant:"ghost",size:"icon",className:"size-7",onClick:EC,children:p.jsx(cu,{size:11})}),e[10]=r,e[11]=h):h=e[11];let m;e[12]!==u||e[13]!==f||e[14]!==h?(m=p.jsxs("div",{className:"flex items-center gap-2 w-full",children:[u,f,h]}),e[12]=u,e[13]=f,e[14]=h,e[15]=m):m=e[15];let g;return e[16]!==o||e[17]!==c||e[18]!==m?(g=p.jsx("div",{className:c,onClick:o,children:m}),e[16]=o,e[17]=c,e[18]=m,e[19]=g):g=e[19],g}function EC(n){n.stopPropagation()}function TC(n){const e=P.c(18),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=s):s=e[0];const{connectionId:o}=jn(s),i=o??dt;let l;e[1]!==i?(l=jt(i),e[1]=i,e[2]=l):l=e[2];const a=l,c=tl(i,"WORKFLOW",t,a),u=Js(i,"WORKFLOW",a);let d;e[3]!==c?(d=JSON.stringify(c),e[3]=c,e[4]=d):d=e[4];const f=d;let h;e[5]!==u.update||e[6]!==t?(h=async x=>{await u.update.mutateAsync({id:t,data:x})},e[5]=u.update,e[6]=t,e[7]=h):h=e[7];const m=h;if(!c){let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(kr,{title:"Workflow not found",description:"This workflow may have been deleted or you may not have access to it."})}),e[8]=x):x=e[8];let b;return e[9]!==r?(b=p.jsx(Cn,{onBack:r,children:x}),e[9]=r,e[10]=b):b=e[10],b}let g;e[11]!==r||e[12]!==m?(g=p.jsx(OC,{onBack:r,onUpdate:m}),e[11]=r,e[12]=m,e[13]=g):g=e[13];let y;return e[14]!==c||e[15]!==f||e[16]!==g?(y=p.jsx(Bg,{workflow:c,children:g},f),e[14]=c,e[15]=f,e[16]=g,e[17]=y):y=e[17],y}function MC(n){const e=P.c(18),{workflow:t,onUpdate:r}=n,{setWorkflow:s}=Ge();let o,i,l,a;if(e[0]!==t.description||e[1]!==t.id||e[2]!==t.steps||e[3]!==t.title){const d={title:t.title,description:t.description,steps:t.steps};o=dl,i=`workflow-${t.id}`,l="100%",a=JSON.stringify(d,null,2),e[0]=t.description,e[1]=t.id,e[2]=t.steps,e[3]=t.title,e[4]=o,e[5]=i,e[6]=l,e[7]=a}else o=e[4],i=e[5],l=e[6],a=e[7];let c;e[8]!==r||e[9]!==s||e[10]!==t?(c=d=>{const f=JSON.parse(d);s({...t,...f}),r(f)},e[8]=r,e[9]=s,e[10]=t,e[11]=c):c=e[11];let u;return e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==a||e[16]!==c?(u=p.jsx(o,{height:l,code:a,language:"json",onSave:c},i),e[12]=o,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=u):u=e[17],u}function OC(n){const e=P.c(24),{onBack:t,onUpdate:r}=n,s=_n(),o=Pt(),{setTrackingExecutionId:i,setOriginalWorkflow:l}=Ge(),{viewMode:a,showExecutionsList:c}=hl(),u=to();let d;e[0]!==r||e[1]!==l||e[2]!==s?(d=async()=>{await r(s),l(s)},e[0]=r,e[1]=l,e[2]=s,e[3]=d):d=e[3];const f=d,g=u&&"toolName"in u.action&&"toolName"in u.action&&u.action.toolName;let y;e[4]!==f||e[5]!==s.description||e[6]!==s.title?(y=p.jsx(wS,{title:s.title,description:s.description,onSave:f}),e[4]=f,e[5]=s.description,e[6]=s.title,e[7]=y):y=e[7];let x;e[8]!==i||e[9]!==o?(x=o&&p.jsxs("div",{className:"h-10 bg-accent flex items-center justify-between border-b border-border",children:[p.jsx("div",{className:"flex",children:p.jsx("div",{className:"flex items-center justify-center h-full w-12",children:p.jsx(Ep,{className:"w-4 h-4 text-muted-foreground"})})}),p.jsx(ce,{variant:"ghost",size:"xs",onClick:()=>i(void 0),children:p.jsx(el,{className:"w-4 h-4 text-muted-foreground"})})]}),e[8]=i,e[9]=o,e[10]=x):x=e[10];let b;e[11]!==r||e[12]!==c||e[13]!==g||e[14]!==a||e[15]!==s?(b=p.jsx("div",{className:"flex-1 overflow-hidden",children:a==="code"?p.jsx(MC,{workflow:s,onUpdate:r}):p.jsxs(Rp,{direction:"horizontal",className:"flex w-full h-full",children:[p.jsx(ua,{defaultSize:50,minSize:30,children:p.jsx(zS,{})}),p.jsx(Dp,{}),p.jsx(ua,{defaultSize:50,minSize:25,children:c?p.jsx(CC,{}):g?p.jsx(hC,{className:"border-l border-border"}):p.jsx(FS,{className:"border-l border-border"})})]})}),e[11]=r,e[12]=c,e[13]=g,e[14]=a,e[15]=s,e[16]=b):b=e[16];let v;e[17]!==y||e[18]!==x||e[19]!==b?(v=p.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[y,x,b]}),e[17]=y,e[18]=x,e[19]=b,e[20]=v):v=e[20];let C;return e[21]!==t||e[22]!==v?(C=p.jsx(Cn,{onBack:t,children:v}),e[21]=t,e[22]=v,e[23]=C):C=e[23],C}const AC={workflow:TC,assistant:fg,prompt:bg};function IC(){const n=P.c(6),e=Yi();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=t):t=n[0];const r=jn(t),s=decodeURIComponent(r.itemId);let o;n[1]!==e.history?(o=()=>{e.history.back()},n[1]=e.history,n[2]=o):o=n[2];const i=o,l=jC;let a;return n[3]!==i||n[4]!==s?(a=p.jsx(Tg,{itemId:s,onBack:i,onUpdate:l}),n[3]=i,n[4]=s,n[5]=a):a=n[5],a}async function jC(n){return Promise.resolve()}function RC(){const n=P.c(18),e=Yi();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=t):t=n[0];const r=jn(t),s=r.connectionId,o=decodeURIComponent(r.collectionName),i=decodeURIComponent(r.itemId);let l;n[1]!==e.history?(l=()=>{e.history.back()},n[1]=e.history,n[2]=l):l=n[2];const a=l,c=s??dt;let u;n[3]!==c?(u=jt(c),n[3]=c,n[4]=u):u=n[4];const f=Js(c,o,u);let h;n[5]!==f||n[6]!==i?(h=async C=>{i&&await f.update.mutateAsync({id:i,data:C})},n[5]=f,n[6]=i,n[7]=h):h=n[7];const m=h;let g;n[8]!==o?(g=o?.toLowerCase(),n[8]=o,n[9]=g):g=n[9];const y=g,x=y&&AC[y];if(x){let C;return n[10]!==x||n[11]!==a||n[12]!==m||n[13]!==i?(C=p.jsx(x,{itemId:i,onBack:a,onUpdate:m}),n[10]=x,n[11]=a,n[12]=m,n[13]=i,n[14]=C):C=n[14],C}let b;n[15]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx(Mp,{size:36,className:"text-muted-foreground"}),n[15]=b):b=n[15];let v;return n[16]!==a?(v=p.jsx(sm,{icon:b,title:"No component defined",description:"No component for this collection was defined",buttonProps:{onClick:a,children:"Go back"}}),n[16]=a,n[17]=v):v=n[17],v}function DC(){const n=P.c(3);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=e):e=n[0];const t=jn(e);if(decodeURIComponent(t.collectionName)==="tools"){let i;return n[1]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(IC,{}),n[1]=i):i=n[1],i}let o;return n[2]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(RC,{}),n[2]=o):o=n[2],o}function $N(){const n=P.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=p.jsx(lr,{children:p.jsx(N.Suspense,{fallback:p.jsx("div",{className:"flex h-full items-center justify-center",children:p.jsx(Gt,{size:32,className:"animate-spin text-muted-foreground"})}),children:p.jsx(DC,{})})}),n[0]=e):e=n[0],e}export{$N as default};
|