@decocms/mesh 1.0.22 → 1.1.0
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-Du1WT751.js → AlertCircle-CRDUE68O.js} +1 -1
- package/dist/client/assets/{ArrowLeft-D2XEhobZ.js → ArrowLeft-Iy4pjcqu.js} +1 -1
- package/dist/client/assets/{ChevronDown-BTsoCUlX.js → ChevronDown-Dj0YzNJ5.js} +1 -1
- package/dist/client/assets/{Clock-DaV6oMqF.js → Clock-BGo4abZy.js} +1 -1
- package/dist/client/assets/{Calendar-Co6ako3r.js → Code01-C2mtSXCH.js} +1 -1
- package/dist/client/assets/{Copy01-DK5159Rb.js → Copy01-08G580G9.js} +1 -1
- package/dist/client/assets/{CpuChip02-DG7E5vjX.js → CpuChip02-vo-KC-ou.js} +1 -1
- package/dist/client/assets/{DotsVertical-ATvueeDl.js → DotsVertical-CDfNa7KY.js} +1 -1
- package/dist/client/assets/{File06-CCcPYdcS.js → File06-BwkobN1x.js} +1 -1
- package/dist/client/assets/{GitBranch01-DdBZ2zon.js → GitBranch01-Dus6D2gU.js} +1 -1
- package/dist/client/assets/{Inbox01-FsIho9ps.js → Inbox01-DrIFHYCY.js} +1 -1
- package/dist/client/assets/{InfoCircle-z9SmeZ2K.js → InfoCircle-B76kcv1L.js} +1 -1
- package/dist/client/assets/{Key01-PJxsN9f2.js → Key01-RxQv3BJR.js} +1 -1
- package/dist/client/assets/{LinkExternal01-UPDE0V2O.js → LinkExternal01-BdHgX43H.js} +1 -1
- package/dist/client/assets/{Loading01-CH6mw7mn.js → Loading01-BtznjYdD.js} +1 -1
- package/dist/client/assets/{Lock01-DfYPtjUw.js → Lock01-DGk0NR9v.js} +1 -1
- package/dist/client/assets/Play-D_dkbQEF.js +1 -0
- package/dist/client/assets/{Plus-D2stpxr4.js → Plus-Cmmt6kdX.js} +1 -1
- package/dist/client/assets/{SearchMd-CwAqtJqG.js → SearchMd-Csv5Q_gT.js} +1 -1
- package/dist/client/assets/{Terminal-zrKj2_VN.js → Terminal-mFLPBz-Y.js} +1 -1
- package/dist/client/assets/{Trash01-BRxmwmD1.js → Trash01-ZjdY9Thx.js} +1 -1
- package/dist/client/assets/{Upload01-CGDUyeg3.js → Upload01-BL_smb86.js} +1 -1
- package/dist/client/assets/{X-E7J_uWRT.js → X-DBHfQHAW.js} +1 -1
- package/dist/client/assets/{XClose-BGxDstvO.js → XClose-BjfF1u26.js} +1 -1
- package/dist/client/assets/{alert-dialog-CxYBxRCI.js → alert-dialog-CLKrwazh.js} +1 -1
- package/dist/client/assets/{auth-catchall-DkkFwJAm.js → auth-catchall-L5hNy_48.js} +1 -1
- package/dist/client/assets/{auth-TMT6XsET.js → auth-xselgzK2.js} +1 -1
- package/dist/client/assets/{avatar-F70el86e.js → avatar-D3l3SwY5.js} +1 -1
- package/dist/client/assets/{badge-BcTlBuEb.js → badge-6daA1Xk-.js} +1 -1
- package/dist/client/assets/{button-Dj8ueofv.js → button-CFHFP204.js} +1 -1
- package/dist/client/assets/{card-66QSeiOF.js → card-DhbXb2hL.js} +1 -1
- package/dist/client/assets/{checkbox-CVcef9O7.js → checkbox-BUzjaLuN.js} +1 -1
- package/dist/client/assets/collection-detail-D-1rhDCF.js +184 -0
- package/dist/client/assets/{collection-display-button-C193PAy9.js → collection-display-button-s533wXMW.js} +1 -1
- package/dist/client/assets/{collection-header-BuFCeK4g.js → collection-header-BTy0NEKS.js} +1 -1
- package/dist/client/assets/{collection-page-M_cHcDoQ.js → collection-page-CVrAS9E8.js} +1 -1
- package/dist/client/assets/{collection-search-Vq1GfSWB.js → collection-search-CF2FAa9j.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-BCXAi-BN.js → collection-table-wrapper-CIM6pfWy.js} +1 -1
- package/dist/client/assets/{connection-card-BsnAC2N8.js → connection-card-CoYgiSAy.js} +1 -1
- package/dist/client/assets/{connection-detail-R_iXfPNX.js → connection-detail-D9Nx3j__.js} +1 -1
- package/dist/client/assets/connections-DwXpLEQ7.js +1 -0
- package/dist/client/assets/{core-DKy85ot6.js → core-UzwkWBsa.js} +1 -1
- package/dist/client/assets/{create-organization-dialog-Dc45BpM3.js → create-organization-dialog-DPCOgwS8.js} +1 -1
- package/dist/client/assets/dialog-DDJjJiXv.js +1 -0
- package/dist/client/assets/{dropdown-menu-BUANjhM2.js → dropdown-menu-BVDy9llW.js} +1 -1
- package/dist/client/assets/{env-vars-editor-Cmi8ii-i.js → env-vars-editor-CSYlB5et.js} +1 -1
- package/dist/client/assets/{error-boundary-BaDP7Z4Q.js → error-boundary-BxGgxrSw.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BD7XgNcV.js → extract-connection-data-DYIo3urs.js} +1 -1
- package/dist/client/assets/{form-D1QOQ8Im.js → form-O3ENwuWy.js} +1 -1
- package/dist/client/assets/{formatDistanceToNow-BZKDch9X.js → formatDistanceToNow-DbTeYEPs.js} +1 -1
- package/dist/client/assets/{gateway-detail-BruHhfdQ.js → gateway-detail-4NLA7mwB.js} +1 -1
- package/dist/client/assets/{gateways-MFtOEWry.js → gateways-Chp0OiTi.js} +1 -1
- package/dist/client/assets/{home-CfjYes5U.js → home-C7yAtry6.js} +1 -1
- package/dist/client/assets/{index-D7vBid7X.js → index-B9tJom0a.js} +2 -2
- package/dist/client/assets/index-BFYCiRaa.css +1 -0
- package/dist/client/assets/{index-CXfjFAB2.js → index-C6fnPeNc.js} +1 -1
- package/dist/client/assets/{index-DkE856zJ.js → index-CiPLnea-.js} +21 -21
- package/dist/client/assets/{index-B-Y0sZwN.js → index-DIWvfi3d.js} +1 -1
- package/dist/client/assets/{input-C2Ph-V5_.js → input-iugRl47V.js} +1 -1
- package/dist/client/assets/json-BJR-gxzf.js +1 -0
- package/dist/client/assets/json-syntax-highlighter-o9Q8Bpjl.js +2 -0
- package/dist/client/assets/{layout-DqSCBByW.js → layout-pV-LEIdm.js} +1 -1
- package/dist/client/assets/{lazy-highlighter-BZxAEkAn.js → lazy-highlighter-Czs-NOYe.js} +1 -1
- package/dist/client/assets/{localstorage-keys-BdgFgIfr.js → localstorage-keys-0rhjy_fp.js} +1 -1
- package/dist/client/assets/{login-CjvCnOTd.js → login-CwJiA9wL.js} +1 -1
- package/dist/client/assets/{mcp-oauth-BRLf6SSt.js → mcp-oauth-BKyHMwxJ.js} +1 -1
- package/dist/client/assets/members-tsvd98Wp.js +3 -0
- package/dist/client/assets/monitoring-DqS96I2Z.js +4 -0
- package/dist/client/assets/{oauth-callback-DRBgoMZ7.js → oauth-callback-DrBJtf1G.js} +1 -1
- package/dist/client/assets/{page-BQFA7pBB.js → page-CIddjpQi.js} +2 -2
- package/dist/client/assets/{popover-B5X6Vli5.js → popover-B_NyiW1Q.js} +1 -1
- package/dist/client/assets/prism-light-CEisnFKn.js +1 -0
- package/dist/client/assets/resizable-DR6TRvc0.js +98 -0
- package/dist/client/assets/{resource-tabs-BeL7wdCw.js → resource-tabs-tnRJokpH.js} +1 -1
- package/dist/client/assets/{select-DIsljPdj.js → select-DfammiWD.js} +1 -1
- package/dist/client/assets/{settings-D0j6CjB5.js → settings-eYWaSfqs.js} +1 -1
- package/dist/client/assets/shell-layout-CuchTujm.js +19 -0
- package/dist/client/assets/{spinner-TVmB-5qD.js → spinner-D4EsgSmE.js} +1 -1
- package/dist/client/assets/store-BbbKGxbw.js +1 -0
- package/dist/client/assets/{store-app-detail-BaLRva6m.js → store-app-detail-N830c_Ks.js} +1 -1
- package/dist/client/assets/{switch-Zc7AToJx.js → switch-BXWlo3EE.js} +1 -1
- package/dist/client/assets/textarea-D1hQDzao.js +1 -0
- package/dist/client/assets/{tools-list-D_OD1vn5.js → tools-list-Bwj-fDqE.js} +1 -1
- package/dist/client/assets/{tooltip-CNuF1S13.js → tooltip-BsevTbJB.js} +1 -1
- package/dist/client/assets/types-j-TFLOzi.js +46 -0
- package/dist/client/assets/{use-binding-Dx0VfUue.js → use-binding-CXIqq1bv.js} +7 -7
- package/dist/client/assets/{use-connection-B9P3V0a0.js → use-connection-jCRGwpV6.js} +1 -1
- package/dist/client/assets/{use-connection-resources-BzPnvL0L.js → use-connection-resources-DJbpQoWM.js} +1 -1
- package/dist/client/assets/{use-gateway-DynzgasG.js → use-gateway-J9ygFzp4.js} +1 -1
- package/dist/client/assets/{use-list-state-DLhjJXJo.js → use-list-state-BGC5b0Pz.js} +1 -1
- package/dist/client/assets/{use-mcp-B4HuTx_L.js → use-mcp-xRGeWjGX.js} +1 -1
- package/dist/client/assets/{use-members-8RC-uoxQ.js → use-members-D3_MeK6r.js} +1 -1
- package/dist/client/assets/{use-mobile-BtxRZpBG.js → use-mobile-zZh9WHEY.js} +1 -1
- package/dist/client/assets/{use-organization-settings-D16HeZQR.js → use-organization-settings-_KK3dEko.js} +1 -1
- package/dist/client/assets/{use-tool-call-Betk01yc.js → use-tool-call-Bukcla53.js} +1 -1
- package/dist/client/assets/useQuery-DDngHzZ8.js +1 -0
- package/dist/client/assets/{useSuspenseInfiniteQuery-DHmfnsAy.js → useSuspenseInfiniteQuery-Cdb8QUCh.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-CIqr2uxV.js → view-mode-toggle-CCJ4Oh3w.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +143 -143
- package/dist/server/migrate.js +85 -85
- package/dist/server/server.js +138 -138
- package/package.json +1 -1
- package/dist/client/assets/collection-detail-D8wVTEqX.js +0 -184
- package/dist/client/assets/connections-DYIPJTN9.js +0 -1
- package/dist/client/assets/dialog-Dcux2Ttt.js +0 -1
- package/dist/client/assets/index-BdkjLo3e.css +0 -1
- package/dist/client/assets/json-DVnNOwmi.js +0 -1
- package/dist/client/assets/json-syntax-highlighter-B4SQlh57.js +0 -2
- package/dist/client/assets/members-qDc7lURh.js +0 -3
- package/dist/client/assets/monitoring-B3MEXlZy.js +0 -1
- package/dist/client/assets/prism-light-BeJZ3zKA.js +0 -1
- package/dist/client/assets/resizable-D_GRD1gk.js +0 -98
- package/dist/client/assets/shell-layout-CdA9l5Mv.js +0 -17
- package/dist/client/assets/store-Dg8rXQqH.js +0 -1
- package/dist/client/assets/types-BFTKKK_w.js +0 -44
- package/dist/client/assets/useQuery-BDcaqn5m.js +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import{aw as Lt,r as N,c as j,d as Rn,j as p,g as Qs,as as el,x as ap,y as iu,v as cp,w as $o,i as up,b as dp,t as lu,F as Z,Q as fp,ax as _o,ay as au,a5 as hp,a4 as pp,az as mp,H as tl,a9 as cu,ac as gp,B as Dn,E as Ue,$ as nl,ad as yp,z as Zs,aa as xp,Z as rl,aj as bp,ak as kp,al as wp,aA as sl,aB as vp,ab as uu,a1 as Sp,aC as Cp,L as Np,aD as Ep,aE as Tp}from"./index-CiPLnea-.js";import{U as mt,f as ol,d as eo,c as ot,b as il,I as to,u as Mp,n as Op}from"./use-connection-jCRGwpV6.js";import{C as kt,d as Ap,u as Ip,e as jp,I as Rp,U as Dp,l as da,G as du,M as Pp,n as Lp,m as $p,R as fa,k as _p}from"./resizable-DR6TRvc0.js";import{E as vr}from"./SearchMd-Csv5Q_gT.js";import{E as cr}from"./error-boundary-BxGgxrSw.js";import{P as no}from"./formatDistanceToNow-DbTeYEPs.js";import{u as zp,L as Bp}from"./localstorage-keys-0rhjy_fp.js";import{u as Fp,a as Je,c as Ge,b as Ye,T as Xe,i as ll}from"./tooltip-BsevTbJB.js";import{B as ue,c as ee}from"./button-CFHFP204.js";import{F as dt,a as fu,b as $t,c as Sr,d as Pn}from"./form-O3ENwuWy.js";import{I as Cr}from"./input-iugRl47V.js";import{T as rs}from"./textarea-D1hQDzao.js";import{A as Vp,D as Hp,u as Wp}from"./use-binding-CXIqq1bv.js";import{i as Qt}from"./Loading01-BtznjYdD.js";import{s as ro}from"./Plus-Cmmt6kdX.js";import{i as qp}from"./Upload01-BL_smb86.js";import{b as Nn,a as al,V as so}from"./layout-pV-LEIdm.js";import{i as Up}from"./AlertCircle-CRDUE68O.js";import{s as Kp}from"./Clock-BGo4abZy.js";import{i as Jp,n as Gp}from"./Code01-C2mtSXCH.js";import{a as Yp}from"./Copy01-08G580G9.js";import{i as cl}from"./Play-D_dkbQEF.js";import{s as ul,i as Xp}from"./XClose-BjfF1u26.js";import{u as Qp,O as Zp,M as em,F as tm,v as nm,E as rm}from"./index-B9tJom0a.js";import{u as dl}from"./use-mcp-xRGeWjGX.js";import{J as sm}from"./json-syntax-highlighter-o9Q8Bpjl.js";import{u as om}from"./use-gateway-J9ygFzp4.js";import{S as Ln}from"./spinner-D4EsgSmE.js";import{V as im}from"./view-mode-toggle-CCJ4Oh3w.js";import{i as lm}from"./GitBranch01-Dus6D2gU.js";import{a as hu,b as fl}from"./use-tool-call-Bukcla53.js";import{D as am,a as cm,b as um,f as dm,c as fm,d as hm}from"./dialog-DDJjJiXv.js";import"./index-C6fnPeNc.js";import{b as pm,D as mm,a as gm,d as ha,i as ym}from"./dropdown-menu-BVDy9llW.js";import{B as hn}from"./badge-6daA1Xk-.js";import{i as pu}from"./X-DBHfQHAW.js";import"./CpuChip02-vo-KC-ou.js";import"./Terminal-mFLPBz-Y.js";import"./connection-card-CoYgiSAy.js";import"./card-DhbXb2hL.js";import"./LinkExternal01-BdHgX43H.js";import"./alert-dialog-CLKrwazh.js";import"./select-DfammiWD.js";import"./ChevronDown-Dj0YzNJ5.js";import"./use-mobile-zZh9WHEY.js";import"./File06-BwkobN1x.js";import"./InfoCircle-B76kcv1L.js";import"./use-organization-settings-_KK3dEko.js";import"./useQuery-DDngHzZ8.js";import"./auth-xselgzK2.js";import"./ArrowLeft-Iy4pjcqu.js";import"./mcp-oauth-BKyHMwxJ.js";import"./env-vars-editor-CSYlB5et.js";import"./Trash01-ZjdY9Thx.js";import"./Key01-RxQv3BJR.js";import"./extract-connection-data-DYIo3urs.js";import"./registry-utils-ulDDT0d8.js";import"./generate-id-Dyweu44Y.js";import"./index-DIWvfi3d.js";const mu=Lt("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 gu=Lt("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 xm=Lt("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const bm=Lt("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 yu=Lt("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 xu=Lt("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 bu=Lt("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 ku=Lt("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"}]]),hl=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));hl.displayName="AlertOctagon";const wu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));wu.displayName="Box";const vu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));vu.displayName="ClockFastForward";const Su=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));Su.displayName="Code02";const Yr=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));Yr.displayName="Columns01";const Cu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));Cu.displayName="CornerDownRight";const Nu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));Nu.displayName="Database01";const Eu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));Eu.displayName="Edit05";const oo=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.createElement("path",{d:"M3 9h13.5a4.5 4.5 0 1 1 0 9H12M3 9l4-4M3 9l4 4"}));oo.displayName="FlipBackward";const Tu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));Tu.displayName="Repeat03";const io=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));io.displayName="Save02";const Mu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));Mu.displayName="Tool01";const lo=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},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"}));lo.displayName="Users02";const{getOwnPropertyNames:km,getOwnPropertySymbols:wm}=Object,{hasOwnProperty:vm}=Object.prototype;function zo(t,e){return function(r,s,o){return t(r,s,o)&&e(r,s,o)}}function Dr(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:o}=s,i=o.get(n),l=o.get(r);if(i&&l)return i===r&&l===n;o.set(n,r),o.set(r,n);const a=t(n,r,s);return o.delete(n),o.delete(r),a}}function Sm(t){return t?.[Symbol.toStringTag]}function pa(t){return km(t).concat(wm(t))}const Cm=Object.hasOwn||((t,e)=>vm.call(t,e));function sn(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const Nm="__v",Em="__o",Tm="_owner",{getOwnPropertyDescriptor:ma,keys:ga}=Object;function Mm(t,e){return t.byteLength===e.byteLength&&ss(new Uint8Array(t),new Uint8Array(e))}function Om(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function Am(t,e){return t.byteLength===e.byteLength&&ss(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Im(t,e){return sn(t.getTime(),e.getTime())}function jm(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function Rm(t,e){return t===e}function ya(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=t.entries();let i,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(n.equals(f[0],h[0],a,d,t,e,n)&&n.equals(f[1],h[1],f[0],h[0],t,e,n)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const Dm=sn;function Pm(t,e,n){const r=ga(t);let s=r.length;if(ga(e).length!==s)return!1;for(;s-- >0;)if(!Ou(t,e,n,r[s]))return!1;return!0}function Wn(t,e,n){const r=pa(t);let s=r.length;if(pa(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!Ou(t,e,n,o)||(i=ma(t,o),l=ma(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function Lm(t,e){return sn(t.valueOf(),e.valueOf())}function $m(t,e){return t.source===e.source&&t.flags===e.flags}function xa(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=t.values();let i,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]&&n.equals(i.value,l.value,i.value,l.value,t,e,n)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ss(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function _m(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Ou(t,e,n,r){return(r===Tm||r===Em||r===Nm)&&(t.$$typeof||e.$$typeof)?!0:Cm(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const zm="[object ArrayBuffer]",Bm="[object Arguments]",Fm="[object Boolean]",Vm="[object DataView]",Hm="[object Date]",Wm="[object Error]",qm="[object Map]",Um="[object Number]",Km="[object Object]",Jm="[object RegExp]",Gm="[object Set]",Ym="[object String]",Xm={"[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},Qm="[object URL]",Zm=Object.prototype.toString;function eg({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,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 k=typeof y;if(k!==typeof x)return!1;if(k!=="object")return k==="number"?l(y,x,b):k==="function"?o(y,x,b):!1;const S=y.constructor;if(S!==x.constructor)return!1;if(S===Object)return a(y,x,b);if(Array.isArray(y))return e(y,x,b);if(S===Date)return r(y,x,b);if(S===RegExp)return u(y,x,b);if(S===Map)return i(y,x,b);if(S===Set)return d(y,x,b);const w=Zm.call(y);if(w===Hm)return r(y,x,b);if(w===Jm)return u(y,x,b);if(w===qm)return i(y,x,b);if(w===Gm)return d(y,x,b);if(w===Km)return typeof y.then!="function"&&typeof x.then!="function"&&a(y,x,b);if(w===Qm)return h(y,x,b);if(w===Wm)return s(y,x,b);if(w===Bm)return a(y,x,b);if(Xm[w])return f(y,x,b);if(w===zm)return t(y,x,b);if(w===Vm)return n(y,x,b);if(w===Fm||w===Um||w===Ym)return c(y,x,b);if(m){let C=m[w];if(!C){const v=Sm(y);v&&(C=m[v])}if(C)return C(y,x,b)}return!1}}function tg({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:Mm,areArraysEqual:n?Wn:Om,areDataViewsEqual:Am,areDatesEqual:Im,areErrorsEqual:jm,areFunctionsEqual:Rm,areMapsEqual:n?zo(ya,Wn):ya,areNumbersEqual:Dm,areObjectsEqual:n?Wn:Pm,arePrimitiveWrappersEqual:Lm,areRegExpsEqual:$m,areSetsEqual:n?zo(xa,Wn):xa,areTypedArraysEqual:n?zo(ss,Wn):ss,areUrlsEqual:_m,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=Dr(r.areArraysEqual),o=Dr(r.areMapsEqual),i=Dr(r.areObjectsEqual),l=Dr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function ng(t){return function(e,n,r,s,o,i,l){return t(e,n,l)}}function rg({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,a){const{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(t)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 sg=_t();_t({strict:!0});_t({circular:!0});_t({circular:!0,strict:!0});_t({createInternalComparator:()=>sn});_t({strict:!0,createInternalComparator:()=>sn});_t({circular:!0,createInternalComparator:()=>sn});_t({circular:!0,createInternalComparator:()=>sn,strict:!0});function _t(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,o=tg(t),i=eg(o),l=n?n(i):ng(i);return rg({circular:e,comparator:i,createState:r,equals:l,strict:s})}function og(t){const e=j.c(3),{gatewayId:n,onSelect:r}=t,{data:s}=jp(n);if(s.length===0)return null;let o;return e[0]!==r||e[1]!==s?(o=p.jsx(Rp,{prompts:s,onSelect:r,className:"mt-6"}),e[0]=r,e[1]=s,e[2]=o):o=e[2],o}function ig(t){const e=j.c(20),{form:n}=t;let r;e[0]!==n?(r=d=>{const{field:f}=d;return p.jsx(mg,{size:"md",value:f.value,onChange:f.onChange,alt:n.watch("title")})},e[0]=n,e[1]=r):r=e[1];let s;e[2]!==n.control||e[3]!==r?(s=p.jsx(dt,{control:n.control,name:"avatar",render:r}),e[2]=n.control,e[3]=r,e[4]=s):s=e[4];let o;e[5]!==n.control?(o=p.jsxs("div",{className:"flex flex-col gap-3 flex-1 min-w-0",children:[p.jsx(dt,{control:n.control,name:"title",render:dg}),p.jsx(dt,{control:n.control,name:"description",render:ug})]}),e[5]=n.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]!==n.control?(l=p.jsxs("div",{className:"flex gap-4",children:[p.jsx(dt,{control:n.control,name:"gateway_id",render:cg}),p.jsx(dt,{control:n.control,name:"model",render:ag})]}),a=p.jsx(dt,{control:n.control,name:"system_prompt",render:lg}),e[10]=n.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]!==n||e[18]!==c?(u=p.jsx(fu,{...n,children:c}),e[17]=n,e[18]=c,e[19]=u):u=e[19],u}function lg(t){const{field:e}=t;return p.jsxs($t,{className:"flex-1 flex flex-col min-h-0",children:[p.jsx(Sr,{className:"text-xs text-muted-foreground",children:"System prompt"}),p.jsx(Pn,{children:p.jsx(rs,{...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 ag(t){const{field:e}=t;return p.jsxs($t,{className:"flex-1",children:[p.jsx(Sr,{className:"text-xs text-muted-foreground",children:"Model"}),p.jsx(Pp,{selectedModel:e.value?{id:e.value.id,connectionId:e.value.connectionId}:void 0,onModelChange:n=>e.onChange({id:n.id,connectionId:n.connectionId}),placeholder:"Select model",variant:"bordered",className:"w-full"})]})}function cg(t){const{field:e}=t;return p.jsxs($t,{className:"flex-1",children:[p.jsx(Sr,{className:"text-xs text-muted-foreground",children:"Gateway"}),p.jsx(du,{selectedGatewayId:e.value,onGatewayChange:e.onChange,placeholder:"Select gateway",variant:"bordered",className:"w-full"})]})}function ug(t){const{field:e}=t;return p.jsxs($t,{children:[p.jsx(Sr,{className:"text-xs text-muted-foreground",children:"Description"}),p.jsx(Pn,{children:p.jsx(Cr,{...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 dg(t){const{field:e}=t;return p.jsxs($t,{children:[p.jsx(Sr,{className:"text-xs text-muted-foreground",children:"Name"}),p.jsx(Pn,{children:p.jsx(Cr,{...e,placeholder:"Untitled assistant",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function fg(t){const e=j.c(14),{onSubmit:n,onStop:r,isStreaming:s,disabled:o,usageMessages:i,inputValue:l,setInputValue:a}=t;let c;e[0]!==l||e[1]!==n?(c=async()=>{l.trim()&&await n(l.trim())},e[0]=l,e[1]=n,e[2]=c):c=e[2];const u=o?"Configure model and gateway to start chatting":"Ask anything or @ for context";let d;e[3]!==i?(d=p.jsx(Dp,{messages:i}),e[3]=i,e[4]=d):d=e[4];let f;return e[5]!==o||e[6]!==l||e[7]!==s||e[8]!==r||e[9]!==a||e[10]!==c||e[11]!==u||e[12]!==d?(f=p.jsx(kt.Input,{value:l,onChange:a,onSubmit:c,onStop:r,disabled:o,isStreaming:s,placeholder:u,children:d}),e[5]=o,e[6]=l,e[7]=s,e[8]=r,e[9]=a,e[10]=c,e[11]=u,e[12]=d,e[13]=f):f=e[13],f}function hg(t){const e=j.c(77),{activeThreadId:n,setActiveThreadId:r,mode:s,assistant:o,form:i}=t;let l;e[0]!==n||e[1]!==o.system_prompt?(l={threadId:n,systemPrompt:o.system_prompt},e[0]=n,e[1]=o.system_prompt,e[2]=l):l=e[2];const a=Ap(l),{inputValue:c,setInputValue:u,branchContext:d,clearBranch:f}=Ip(),{isEmpty:h}=a,m=!!o.gateway_id&&!!o.model?.id&&!!o.model?.connectionId;let g;e[3]!==n||e[4]!==o.gateway_id||e[5]!==o.model||e[6]!==a||e[7]!==f||e[8]!==m||e[9]!==u?(g=async qe=>{if(!m)return;u(""),f();const Vn={created_at:new Date().toISOString(),thread_id:n,model:{id:o.model.id,connectionId:o.model.connectionId},gateway:{id:o.gateway_id??""},user:{name:"you"}};await a.sendMessage(qe,Vn)},e[3]=n,e[4]=o.gateway_id,e[5]=o.model,e[6]=a,e[7]=f,e[8]=m,e[9]=u,e[10]=g):g=e[10];const y=g;let x;e[11]!==d||e[12]!==f||e[13]!==r||e[14]!==u?(x=()=>{d&&(r(d.originalThreadId),f(),u(""))},e[11]=d,e[12]=f,e[13]=r,e[14]=u,e[15]=x):x=e[15];const b=x;let k;e[16]!==o.avatar||e[17]!==o.title?(k=o.avatar?p.jsx("div",{className:"size-[60px] rounded-[18px] border border-border shrink-0 overflow-hidden",children:p.jsx("img",{src:o.avatar,alt:o.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(lo,{size:28,className:"text-muted-foreground"})}),e[16]=o.avatar,e[17]=o.title,e[18]=k):k=e[18];let S;e[19]!==o.title?(S=p.jsx("h3",{className:"text-xl font-medium text-foreground",children:o.title}),e[19]=o.title,e[20]=S):S=e[20];let w;e[21]!==o.description?(w=o.description?p.jsx("div",{className:"text-muted-foreground text-center text-sm max-w-md",children:o.description}):null,e[21]=o.description,e[22]=w):w=e[22];let C;e[23]!==k||e[24]!==S||e[25]!==w?(C=p.jsxs("div",{className:"flex flex-col items-center gap-4",children:[k,S,w]}),e[23]=k,e[24]=S,e[25]=w,e[26]=C):C=e[26];let v;e[27]!==o.gateway_id||e[28]!==y?(v=o.gateway_id&&p.jsx(cr,{fallback:null,children:p.jsx(N.Suspense,{fallback:p.jsx("div",{className:"flex justify-center mt-6",children:p.jsx(Qt,{size:20,className:"animate-spin text-muted-foreground"})}),children:p.jsx(og,{gatewayId:o.gateway_id,onSelect:qe=>{y(qe.description??qe.name)}})})}),e[27]=o.gateway_id,e[28]=y,e[29]=v):v=e[29];let M;e[30]!==C||e[31]!==v?(M=p.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-4 text-center",children:[C,v]}),e[30]=C,e[31]=v,e[32]=M):M=e[32];const E=M,O=s==="edit",R=O?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none";let L;e[33]!==R?(L=ee("absolute inset-0 px-2 transition-opacity duration-200 ease-out",R),e[33]=R,e[34]=L):L=e[34];let B;e[35]!==i?(B=p.jsx(ig,{form:i}),e[35]=i,e[36]=B):B=e[36];let z;e[37]!==L||e[38]!==B?(z=p.jsx("div",{className:L,children:B}),e[37]=L,e[38]=B,e[39]=z):z=e[39];const D=O?"opacity-0 pointer-events-none":"opacity-100";let T;e[40]!==D?(T=ee("h-full transition-opacity duration-200 ease-out",D),e[40]=D,e[41]=T):T=e[41];let _;e[42]!==a.messages||e[43]!==a.status||e[44]!==E||e[45]!==h?(_=h?p.jsx(kt.EmptyState,{children:E}):p.jsx(kt.Messages,{messages:a.messages,status:a.status,minHeightOffset:240}),e[42]=a.messages,e[43]=a.status,e[44]=E,e[45]=h,e[46]=_):_=e[46];let P;e[47]!==T||e[48]!==_?(P=p.jsx("div",{className:T,children:_}),e[47]=T,e[48]=_,e[49]=P):P=e[49];let U;e[50]!==z||e[51]!==P?(U=p.jsxs(kt.Main,{className:"h-full relative overflow-hidden",children:[z,P]}),e[50]=z,e[51]=P,e[52]=U):U=e[52];const G=O?"translate-y-full":"translate-y-0";let F;e[53]!==G?(F=ee("transition-transform duration-300 ease-out",G),e[53]=G,e[54]=F):F=e[54];let W;e[55]!==d||e[56]!==f||e[57]!==b||e[58]!==u?(W=p.jsx(kt.BranchPreview,{branchContext:d,clearBranchContext:f,onGoToOriginalMessage:b,setInputValue:u}),e[55]=d,e[56]=f,e[57]=b,e[58]=u,e[59]=W):W=e[59];const Q=a.status==="submitted"||a.status==="streaming",X=!m;let Y;e[60]!==a.messages||e[61]!==a.stop||e[62]!==y||e[63]!==c||e[64]!==u||e[65]!==Q||e[66]!==X?(Y=p.jsx(fg,{onSubmit:y,onStop:a.stop,isStreaming:Q,disabled:X,usageMessages:a.messages,inputValue:c,setInputValue:u}),e[60]=a.messages,e[61]=a.stop,e[62]=y,e[63]=c,e[64]=u,e[65]=Q,e[66]=X,e[67]=Y):Y=e[67];let le;e[68]!==W||e[69]!==Y?(le=p.jsx(kt.Footer,{children:p.jsxs("div",{className:"max-w-2xl mx-auto w-full min-w-0 flex flex-col gap-2",children:[W,Y]})}),e[68]=W,e[69]=Y,e[70]=le):le=e[70];let Ee;e[71]!==F||e[72]!==le?(Ee=p.jsx("div",{className:F,children:le}),e[71]=F,e[72]=le,e[73]=Ee):Ee=e[73];let We;return e[74]!==U||e[75]!==Ee?(We=p.jsxs(kt,{children:[U,Ee]}),e[74]=U,e[75]=Ee,e[76]=We):We=e[76],We}function pg(t){const e=j.c(6),{activeThreadId:n,setActiveThreadId:r,mode:s,assistant:o,form:i}=t;let l;return e[0]!==n||e[1]!==o||e[2]!==i||e[3]!==s||e[4]!==r?(l=p.jsx(kt.Provider,{children:p.jsx(hg,{activeThreadId:n,setActiveThreadId:r,mode:s,assistant:o,form:i})}),e[0]=n,e[1]=o,e[2]=i,e[3]=s,e[4]=r,e[5]=l):l=e[5],l}function mg(t){const e=j.c(18),{value:n,onChange:r,alt:s,size:o}=t,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=C=>{const v=C.target.files?.[0];if(!v)return;const M=new FileReader;M.onloadend=()=>{const E=M.result;r(E)},M.readAsDataURL(v)},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]!==n?(x=n?p.jsx("img",{src:n,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(lo,{className:c})}),e[5]=s,e[6]=c,e[7]=n,e[8]=x):x=e[8];const b=`${u} text-white`;let k;e[9]!==b?(k=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(qp,{className:b})}),e[9]=b,e[10]=k):k=e[10];let S;e[11]!==x||e[12]!==k?(S=p.jsxs("div",{className:"h-full w-full rounded-xl border border-border bg-muted/20 overflow-hidden relative",children:[x,k]}),e[11]=x,e[12]=k,e[13]=S):S=e[13];let w;return e[14]!==g||e[15]!==y||e[16]!==S?(w=p.jsxs("div",{className:g,onClick:m,children:[y,S]}),e[14]=g,e[15]=y,e[16]=S,e[17]=w):w=e[17],w}function gg(t){const e=j.c(57),{providerId:n,assistantId:r,onBack:s}=t,i=Qs().location.href,l=el();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}=Fp();let d;e[3]!==r||e[4]!==u?(d=Bp.assistantChatActiveThread(u,r),e[3]=r,e[4]=u,e[5]=d):d=e[5];const[f,h]=zp(d,yg),m=n||mt;let g;e[6]!==m?(g=ot(m),e[6]=m,e[7]=g):g=e[7];const y=g,x=ol(n,"ASSISTANT",r,y),b=eo(n,"ASSISTANT",y),k=b.update.isPending,[S,w]=N.useState(x?.model.id&&x?.gateway_id?"chat":"edit");let C;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=ap(Vp),e[8]=C):C=e[8];const v=x??void 0;let M;e[9]!==v?(M={resolver:C,values:v},e[9]=v,e[10]=M):M=e[10];const E=iu(M);let O;e[11]!==b.update||e[12]!==r||e[13]!==E?(O=E.handleSubmit(async X=>{const Y=await b.update.mutateAsync({id:r,data:X});E.reset(Y),w("chat")}),e[11]=b.update,e[12]=r,e[13]=E,e[14]=O):O=e[14];const R=O;if(!x){let X;e[15]===Symbol.for("react.memo_cache_sentinel")?(X=p.jsx(da,{}),e[15]=X):X=e[15];let Y;e[16]===Symbol.for("react.memo_cache_sentinel")?(Y=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(vr,{title:"Assistant not found",description:"This assistant may have been deleted or you may not have access to it."})}),e[16]=Y):Y=e[16];let le;return e[17]!==c?(le=p.jsx(cr,{children:p.jsx(N.Suspense,{fallback:X,children:p.jsx(Nn,{onBack:c,children:Y})})}),e[17]=c,e[18]=le):le=e[18],le}let L;e[19]===Symbol.for("react.memo_cache_sentinel")?(L=p.jsx(da,{}),e[19]=L):L=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(lo,{size:12,className:"text-muted-foreground"})})}),e[20]=x.avatar,e[21]=x.title,e[22]=B):B=e[22];let z;e[23]!==x.title?(z=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:x.title}),e[23]=x.title,e[24]=z):z=e[24];let D;e[25]!==x.description?(D=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]=D):D=e[26];let T;e[27]!==z||e[28]!==D?(T=p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[z,D]}),e[27]=z,e[28]=D,e[29]=T):T=e[29];let _;e[30]!==B||e[31]!==T?(_=p.jsx(al,{children:p.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[B,T]})}),e[30]=B,e[31]=T,e[32]=_):_=e[32];const P=x.avatar??"assistant";let U;e[33]!==x.title||e[34]!==P||e[35]!==i?(U=p.jsx(no,{title:x.title,url:i,icon:P}),e[33]=x.title,e[34]=P,e[35]=i,e[36]=U):U=e[36];let G;e[37]!==E.formState.isDirty||e[38]!==k||e[39]!==S||e[40]!==R||e[41]!==h?(G=S==="chat"?p.jsxs(p.Fragment,{children:[p.jsx(Je,{children:p.jsxs(Ge,{children:[p.jsx(Ye,{asChild:!0,children:p.jsx(ue,{type:"button",onClick:()=>h(crypto.randomUUID()),"aria-label":"New thread",variant:"outline",size:"icon",className:"size-7 border border-input",children:p.jsx(ro,{size:16})})}),p.jsx(Xe,{children:"New thread"})]})}),p.jsx(Je,{children:p.jsxs(Ge,{children:[p.jsx(Ye,{asChild:!0,children:p.jsx(ue,{type:"button",onClick:()=>w("edit"),"aria-label":"Edit",variant:"outline",size:"icon",className:"size-7 border border-input",children:p.jsx(Eu,{size:16})})}),p.jsx(Xe,{children:"Edit"})]})})]}):p.jsxs(p.Fragment,{children:[p.jsx(Je,{children:p.jsxs(Ge,{delayDuration:0,children:[p.jsx(Ye,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:k,onClick:()=>w("chat"),"aria-label":"Cancel",children:p.jsx(oo,{size:14})})})}),p.jsx(Xe,{side:"bottom",children:"Cancel"})]})}),p.jsx(Je,{children:p.jsxs(Ge,{delayDuration:0,children:[p.jsx(Ye,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:!E.formState.isDirty||k,onClick:()=>{R()},"aria-label":"Save",children:k?p.jsx(Qt,{size:14,className:"animate-spin"}):p.jsx(io,{size:14})})})}),p.jsx(Xe,{side:"bottom",children:"Save"})]})})]}),e[37]=E.formState.isDirty,e[38]=k,e[39]=S,e[40]=R,e[41]=h,e[42]=G):G=e[42];let F;e[43]!==U||e[44]!==G?(F=p.jsxs(so,{children:[U,G]}),e[43]=U,e[44]=G,e[45]=F):F=e[45];let W;e[46]!==f||e[47]!==x||e[48]!==E||e[49]!==S||e[50]!==h?(W=p.jsx("div",{className:"h-full",children:p.jsx(pg,{activeThreadId:f,setActiveThreadId:h,mode:S,assistant:x,form:E},E.formState.submitCount)}),e[46]=f,e[47]=x,e[48]=E,e[49]=S,e[50]=h,e[51]=W):W=e[51];let Q;return e[52]!==c||e[53]!==_||e[54]!==F||e[55]!==W?(Q=p.jsx(cr,{children:p.jsx(N.Suspense,{fallback:L,children:p.jsxs(Nn,{onBack:c,children:[_,F,W]})})}),e[52]=c,e[53]=_,e[54]=F,e[55]=W,e[56]=Q):Q=e[56],Q}function yg(t){return t||crypto.randomUUID()}function xg(t){const e=j.c(6),{itemId:n,onBack:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=Rn(s).connectionId??mt;if(!i||i===mt){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(vr,{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]!==n||e[4]!==r?(l=p.jsx(gg,{providerId:i,assistantId:n,onBack:r}),e[2]=i,e[3]=n,e[4]=r,e[5]=l):l=e[5],l}cp({title:$o().min(1),description:$o().nullable(),body:$o()});function Bo(t){for(const e of t.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function bg(){const t=window.location.pathname.split("/").filter(Boolean),e=t.findIndex(r=>r==="mcps"),n=e>=0?t[e+1]:void 0;return n?decodeURIComponent(n):void 0}function kg(t){const e=j.c(13),{form:n}=t;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]!==n.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(dt,{control:n.control,name:"title",render:Sg}),p.jsx(dt,{control:n.control,name:"description",render:vg})]})]}),e[1]=n.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]!==n.control?(l=p.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,p.jsx(dt,{control:n.control,name:"body",render:wg})]}),e[5]=n.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]!==n||e[11]!==a?(c=p.jsx(fu,{...n,children:a}),e[10]=n,e[11]=a,e[12]=c):c=e[12],c}function wg(t){const{field:e}=t;return p.jsx($t,{children:p.jsx(Pn,{children:p.jsx(rs,{...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 vg(t){const{field:e}=t;return p.jsxs($t,{children:[p.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),p.jsx(Pn,{children:p.jsx(Cr,{...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 Sg(t){const{field:e}=t;return p.jsxs($t,{children:[p.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),p.jsx(Pn,{children:p.jsx(Cr,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function Cg(t){const e=j.c(51),{providerId:n,promptId:r,onBack:s}=t,i=Qs().location.href,l=n||mt;let a;e[0]!==l?(a=ot(l),e[0]=l,e[1]=a):a=e[1];const c=a,u=ol(n,"PROMPT",r,c),d=eo(n,"PROMPT",c),f=d.update.isPending;let h;e[2]!==u?(h=u?{title:u.title,description:u.description??null,body:Bo(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=iu(m);let y;e[6]!==g||e[7]!==u?(y=()=>{u&&g.reset({title:u.title,description:u.description??null,body:Bo(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 W=>{const Q=await d.update.mutateAsync({id:r,data:{title:W.title,description:W.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:W.body}}]}});g.reset({title:Q.title,description:Q.description??null,body:Bo(Q)})}),e[9]=d.update,e[10]=g,e[11]=r,e[12]=b):b=e[12];const k=b;if(!u){let W;return e[13]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(vr,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=W):W=e[13],W}let S;e[14]!==u.title?(S=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:u.title}),e[14]=u.title,e[15]=S):S=e[15];let w;e[16]!==u.description?(w=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]=w):w=e[17];let C;e[18]!==S||e[19]!==w?(C=p.jsx(al,{children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[S,w]})}),e[18]=S,e[19]=w,e[20]=C):C=e[20];let v;e[21]!==u.title||e[22]!==i?(v=p.jsx(no,{title:u.title,url:i,icon:"description"}),e[21]=u.title,e[22]=i,e[23]=v):v=e[23];const M=!g.formState.isDirty||f;let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=p.jsx(oo,{size:14}),e[24]=E):E=e[24];let O;e[25]!==x||e[26]!==M?(O=p.jsx(Ye,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:M,onClick:x,"aria-label":"Cancel",children:E})})}),e[25]=x,e[26]=M,e[27]=O):O=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx(Xe,{side:"bottom",children:"Cancel"}),e[28]=R):R=e[28];let L;e[29]!==O?(L=p.jsx(Je,{children:p.jsxs(Ge,{delayDuration:0,children:[O,R]})}),e[29]=O,e[30]=L):L=e[30];const B=!g.formState.isDirty||f;let z;e[31]!==k?(z=()=>{k()},e[31]=k,e[32]=z):z=e[32];let D;e[33]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx(io,{size:14}),e[33]=D):D=e[33];let T;e[34]!==B||e[35]!==z?(T=p.jsx(Ye,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:B,onClick:z,"aria-label":"Save",children:D})})}),e[34]=B,e[35]=z,e[36]=T):T=e[36];let _;e[37]===Symbol.for("react.memo_cache_sentinel")?(_=p.jsx(Xe,{side:"bottom",children:"Save"}),e[37]=_):_=e[37];let P;e[38]!==T?(P=p.jsx(Je,{children:p.jsxs(Ge,{delayDuration:0,children:[T,_]})}),e[38]=T,e[39]=P):P=e[39];let U;e[40]!==v||e[41]!==L||e[42]!==P?(U=p.jsxs(so,{children:[v,L,P]}),e[40]=v,e[41]=L,e[42]=P,e[43]=U):U=e[43];let G;e[44]!==g?(G=p.jsx("div",{className:"h-full",children:p.jsx(kg,{form:g})}),e[44]=g,e[45]=G):G=e[45];let F;return e[46]!==s||e[47]!==U||e[48]!==G||e[49]!==C?(F=p.jsxs(Nn,{onBack:s,children:[C,U,G]}),e[46]=s,e[47]=U,e[48]=G,e[49]=C,e[50]=F):F=e[50],F}function Ng(t){const e=j.c(5),{itemId:n,onBack:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=bg()??mt,e[0]=s):s=e[0];const o=s;if(!o||o===mt){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(vr,{title:"Prompt not found",description:"Missing connection information in the current route."})}),e[1]=l):l=e[1],l}let i;return e[2]!==n||e[3]!==r?(i=p.jsx(cr,{children:p.jsx(N.Suspense,{fallback:null,children:p.jsx(Cg,{providerId:o,promptId:n,onBack:r})})}),e[2]=n,e[3]=r,e[4]=i):i=e[4],i}const Eg=up("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 Tg(t){const e=j.c(10);let n,r,s;e[0]!==t?({className:n,variant:s,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s):(n=e[1],r=e[2],s=e[3]);let o;e[4]!==n||e[5]!==s?(o=ee(Eg({variant:s}),n),e[4]=n,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 Mg(t){const e=j.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n?(s=ee("line-clamp-1 min-h-4 font-medium tracking-tight",n),e[3]=n,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 Og(t){const e=j.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n?(s=ee("text-muted-foreground leading-relaxed",n),e[3]=n,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 Ag=t=>t.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function Ig(t){const e=j.c(13),{toolName:n,connectionId:r,onBack:s}=t,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=Qp(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(Zp,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):p.jsx(em,{hasReadme:!1})}),e[4]=c.supportsOAuth,e[5]=s,e[6]=f):f=e[6],f}const u=`${r}:${n}`;let d;return e[7]!==r||e[8]!==l||e[9]!==s||e[10]!==u||e[11]!==n?(d=p.jsx(jg,{toolName:n,connectionId:r,mcpProxyUrl:l,onBack:s},u),e[7]=r,e[8]=l,e[9]=s,e[10]=u,e[11]=n,e[12]=d):d=e[12],d}function jg({toolName:t,connectionId:e,mcpProxyUrl:n,onBack:r}){const o=Qs().location.href,{replayId:i}=dp({strict:!1}),l=(()=>{if(!i)return null;const T=`replay-${i}`,_=sessionStorage.getItem(T);if(!_)return null;sessionStorage.removeItem(T);try{return JSON.parse(_)}catch{return null}})(),a=(()=>{if(!l)return null;const T={};for(const[_,P]of Object.entries(l))P!==null&&typeof P=="object"?T[_]=JSON.stringify(P,null,2):T[_]=P;return T})(),[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),[k,S]=N.useState(null),w=il(e),C=dl({url:n.href});N.useEffect(()=>{C.error&&console.error("MCP Error:",C.error)},[C.error]);const v=C.tools?.find(T=>T.name===t),M=v?.inputSchema?.properties,E=M?Object.keys(M):[],O=E.length>0,R={};if(O&&v?.inputSchema?.properties)for(const T of E)R[T]=v.inputSchema.required?.includes(T)?"":void 0;const L=T=>Object.prototype.hasOwnProperty.call(c,T),B=async()=>{b(!0),y(null),m(null),S(null);const T=performance.now(),_=ot(e);try{const P=O?{...R,...c}:(()=>{const X=d.trim();if(!X)return{};const Y=JSON.parse(X);if(Y&&typeof Y=="object")return Y;throw new Error("Raw JSON input must be an object.")})();O&&v?.inputSchema?.properties&&Object.entries(v.inputSchema.properties).forEach(([X,Y])=>{if((Y.type==="object"||Y.type==="array")&&typeof P[X]=="string")try{P[X]=JSON.parse(P[X])}catch{}});const U=await _(t,P),G=performance.now(),F=Math.round(G-T);m(U);const W=JSON.stringify(U),Q=new TextEncoder().encode(W).length;S({duration:`${F}ms`,bytes:`${Q} bytes`,tokens:`~${Math.ceil(Q/4)} tokens`,cost:"$0.0000"})}catch(P){const U=P instanceof Error?P.message:String(P);y(U||"Unknown error occurred");const G=performance.now();S({duration:`${Math.round(G-T)}ms`})}finally{b(!1)}},z=(T,_)=>{u(P=>({...P,[T]:_}))},D=()=>{m(null),y(null),S(null)};return p.jsxs(Nn,{onBack:r,children:[p.jsx(so,{children:p.jsx(no,{title:v?.name??Ag(t),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(to,{icon:w?.icon||null,name:w?.title||t,size:"sm",className:"shadow-sm shrink-0"}),p.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:t}),p.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[C.state==="ready"?p.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):C.state==="connecting"?p.jsx(Qt,{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:C.state.replace("_"," ")})]})]}),p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:v?.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"}),v?.inputSchema?.required&&v.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:O&&v?.inputSchema?.properties?Object.entries(v.inputSchema.properties).map(([T,_])=>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:[T,v.inputSchema?.required?.includes(T)&&p.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),p.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:_.type})]}),_.description&&p.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:_.description}),_.type==="object"||_.type==="array"?p.jsx(rs,{className:"font-mono text-xs",value:L(T)?c[T]??"":R[T]??"",onChange:P=>z(T,P.target.value),placeholder:`Enter ${T} as JSON...`,rows:3}):p.jsx(Cr,{value:L(T)?c[T]??"":R[T]??"",onChange:P=>z(T,P.target.value),placeholder:`Enter ${T}...`})]},T)):v?.inputSchema&&!O?p.jsxs("div",{className:"space-y-2",children:[p.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),p.jsx(rs,{className:"font-mono text-xs min-h-[120px]",value:d,onChange:T=>f(T.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"}),k&&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(Kp,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:k.duration})]}),k.tokens&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(wu,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:k.tokens})]}),k.bytes&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(Nu,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:k.bytes})]}),k.cost&&p.jsx("div",{className:"flex items-center gap-1.5",children:p.jsx("span",{className:"font-mono text-foreground",children:k.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(ue,{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(Qt,{size:14,className:"animate-spin"}),"Executing..."]}):p.jsxs(p.Fragment,{children:[p.jsx(cl,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),p.jsx(Je,{children:p.jsxs(Ge,{children:[p.jsx(Ye,{asChild:!0,children:p.jsx(ue,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:D,disabled:!h&&!g,children:p.jsx(ul,{size:14})})}),p.jsx(Xe,{children:p.jsx("p",{children:"Clear results"})})]})})]})}),g&&p.jsx("div",{className:"px-6 py-4 bg-background",children:p.jsx(Tg,{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(Up,{className:"h-4 w-4"}),p.jsx(Mg,{className:"mb-0",children:"Execution Failed"})]}),p.jsx(Og,{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(sm,{jsonString:JSON.stringify(h,null,2),padding:"1.5rem"}),p.jsx(ue,{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)),lu.success("Copied to clipboard")},children:p.jsx(Yp,{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(Jp,{className:"h-12 w-12 mb-3 opacity-40"}),p.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function Rg(t){const e=j.c(7),{itemId:n,onBack:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=Rn(s).connectionId??mt;if(!il(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(Qt,{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]!==n?(c=p.jsx(N.Suspense,{fallback:a,children:p.jsx(Ig,{toolName:n,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=n,e[6]=c):c=e[6],c}const ba=t=>{let e;const n=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),n.forEach(h=>h(e,f))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>a,subscribe:c=>(n.add(c),()=>n.delete(c))},a=e=t(r,s,l);return l},pl=(t=>t?ba(t):ba),Dg=t=>t;function wi(t,e=Dg){const n=Z.useSyncExternalStore(t.subscribe,Z.useCallback(()=>e(t.getState()),[t,e]),Z.useCallback(()=>e(t.getInitialState()),[t,e]));return Z.useDebugValue(n),n}const Pg=t=>{const e=pl(t),n=r=>wi(e,r);return Object.assign(n,e),n},Lg=(t=>Pg);function Au(t,e){let n;try{n=t()}catch{return}return{getItem:s=>{var o;const i=a=>a===null?null:JSON.parse(a,void 0),l=(o=n.getItem(s))!=null?o:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,o)=>n.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>n.removeItem(s)}}const vi=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then(r){return vi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return vi(r)(n)}}}},$g=(t,e)=>(n,r,s)=>{let o={storage:Au(()=>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 t((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...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=t((...g)=>(n(...g),u()),r,s);s.getInitialState=()=>f;let h;const m=()=>{var g,y;if(!c)return;i=!1,l.forEach(b=>{var k;return b((k=r())!=null?k:f)});const x=((y=o.onRehydrateStorage)==null?void 0:y.call(o,(g=r())!=null?g:f))||void 0;return vi(c.getItem.bind(c))(o.name).then(b=>{if(b)if(typeof b.version=="number"&&b.version!==o.version){if(o.migrate){const k=o.migrate(b.state,b.version);return k instanceof Promise?k.then(S=>[!0,S]):[!0,k]}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 k;const[S,w]=b;if(h=o.merge(w,(k=r())!=null?k:f),n(h,!0),S)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},Iu=$g,{useSyncExternalStoreWithSelector:_g}=fp,zg=t=>t;function Bg(t,e=zg,n){const r=_g(t.subscribe,t.getState,t.getInitialState,e,n);return Z.useDebugValue(r),r}const ka=t=>Symbol.iterator in t,wa=t=>"entries"in t,va=(t,e)=>{const n=t instanceof Map?t:new Map(t.entries()),r=e instanceof Map?e:new Map(e.entries());if(n.size!==r.size)return!1;for(const[s,o]of n)if(!r.has(s)||!Object.is(o,r.get(s)))return!1;return!0},Fg=(t,e)=>{const n=t[Symbol.iterator](),r=e[Symbol.iterator]();let s=n.next(),o=r.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=n.next(),o=r.next()}return!!s.done&&!!o.done};function Vg(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:ka(t)&&ka(e)?wa(t)&&wa(e)?va(t,e):Fg(t,e):va({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function Hg(t,e="Output"){if(!t)return`interface ${e} {}`;function n(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?`${n(l)}[]`:"unknown[]"}case"object":return s(o);default:return o.anyOf?o.anyOf.map(n).join(" | "):o.oneOf?o.oneOf.map(n).join(" | "):o.allOf?o.allOf.map(n).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}: ${n(u)};`}).join(`
|
|
4
|
+
`)}
|
|
5
|
+
}`}return`interface ${e} ${n(t)}`}function Fo(t,e){const n=t.trim();return e.some(s=>s.name.toLowerCase()===n.toLowerCase())?`${n}_${Math.random().toString(36).substring(2,6)}`:n}function Wg(t,e){const n=t.match(/interface\s+Input\s*\{/);if(!n||n.index===void 0)return`${e}
|
|
6
|
+
|
|
7
|
+
${t.trimStart()}`;const r=n.index,s=r+n[0].length-1;let o=1,i=s+1;for(;i<t.length&&o>0;)t[i]==="{"?o++:t[i]==="}"&&o--,i++;return t.slice(0,r)+e+t.slice(i)}function Vo(t,e){switch(t){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...Hp,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${t}`)}}const ju=N.createContext(null),qg=t=>pl()(Iu(e=>({...t,actions:{setIsAddingStep:n=>e(r=>({...r,isAddingStep:n})),setCurrentStepTab:n=>e(r=>({...r,currentStepTab:n})),setToolAction:n=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.map(s=>"toolName"in s.action&&s.action.toolName===n.toolName?{...s,action:n}:s)}})),appendStep:({step:n,type:r})=>e(s=>{const o=n??Vo(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:n=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.filter(s=>s.name!==n)}})),duplicateStep:n=>e(r=>{const s=r.workflow.steps.findIndex(a=>a.name===n);if(s===-1)return r;const o=r.workflow.steps[s];if(!o)return r;const i={...o,name:Fo(o.name,r.workflow.steps)},l=[...r.workflow.steps];return l.splice(s+1,0,i),{workflow:{...r.workflow,steps:l},currentStepName:i.name}}),setCurrentStepName:n=>e(r=>({...r,currentStepName:n})),updateStep:(n,r)=>e(s=>({...s,workflow:{...s.workflow,steps:s.workflow.steps.map(o=>o.name===n?{...o,...r}:o)}})),setTrackingExecutionId:n=>e(r=>({...r,trackingExecutionId:n})),resetToOriginalWorkflow:()=>e(n=>({...n,workflow:n.originalWorkflow})),startAddingStep:n=>e(r=>({...r,isAddingStep:!0,addingStepType:n})),cancelAddingStep:()=>e(n=>({...n,isAddingStep:!1,addingStepType:null,selectedParentSteps:[]})),toggleParentStepSelection:n=>e(r=>{const s=r.selectedParentSteps.includes(n);return{...r,selectedParentSteps:s?r.selectedParentSteps.filter(o=>o!==n):[...r.selectedParentSteps,n]}}),confirmAddCodeStep:()=>e(n=>{const{selectedParentSteps:r,addingStepType:s,workflow:o}=n;if(s!=="code"||r.length===0)return n;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=Vo("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const d=Hg(a,"Input"),f=c.action,h=Wg(f.code,d);c={...c,action:{...f,code:h}}}const u=Fo(c.name,o.steps);return{...n,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],workflow:{...o,steps:[...o.steps,{...c,name:u}]},currentStepName:u}}),addToolStep:()=>e(n=>{let r=Vo("tool",Number((Math.random()*1e6).toFixed(0)));const s=Fo(r.name,n.workflow.steps);return{...n,isAddingStep:!1,addingStepType:null,workflow:{...n.workflow,steps:[...n.workflow.steps,{...r,name:s}]},currentStepName:s}}),setOriginalWorkflow:n=>e(r=>({...r,originalWorkflow:n})),setWorkflow:n=>e(r=>({...r,workflow:n})),startReplacingTool:n=>e(r=>({...r,replacingToolInfo:{toolName:n}})),cancelReplacingTool:()=>e(n=>({...n,replacingToolInfo:null})),setSelectedGatewayId:n=>e(r=>({...r,selectedGatewayId:n}))}}),{name:`workflow-store-${encodeURIComponent(t.workflow.id)}`,storage:Au(()=>localStorage),version:1,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 Ug(t){const e=j.c(8),{children:n,initialState:r}=t,s=om();let o;e[0]!==s?.[0]?.id||e[1]!==r.currentStepTab||e[2]!==r.trackingExecutionId||e[3]!==r.workflow?(o=()=>qg({workflow:r.workflow,originalWorkflow:r.workflow,selectedGatewayId:s?.[0]?.id,isAddingStep:!1,selectedParentSteps:[],trackingExecutionId:r.trackingExecutionId,currentStepName:r.workflow.steps[0]?.name,currentStepTab:r.currentStepTab??"input"}),e[0]=s?.[0]?.id,e[1]=r.currentStepTab,e[2]=r.trackingExecutionId,e[3]=r.workflow,e[4]=o):o=e[4];const[i]=N.useState(o);let l;return e[5]!==n||e[6]!==i?(l=p.jsx(ju.Provider,{value:i,children:n}),e[5]=n,e[6]=i,e[7]=l):l=e[7],l}function $n(t,e){const n=N.useContext(ju);if(!n)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return Bg(n,t,Vg)}function _n(){return $n(Kg)}function Kg(t){return t.workflow}function je(){return $n(Jg)}function Jg(t){return t.actions}function Ru(){const t=Er();return $n(Gg)??t[0]?.name}function Gg(t){return t.currentStepName}function Nr(){const t=j.c(5),e=Ru(),n=Er();let r;if(t[0]!==e||t[1]!==n){let o;t[3]!==e?(o=i=>i.name===e,t[3]=e,t[4]=o):o=t[4],r=n.find(o),t[0]=e,t[1]=n,t[2]=r}else r=t[2];const s=r;return s||n[0]}function Er(){return _n().steps}function Du(){const t=j.c(4),e=_n(),n=$n(Yg);let r;t[0]!==e?(r=JSON.stringify(e),t[0]=e,t[1]=r):r=t[1];let s;return t[2]!==n?(s=JSON.stringify(n),t[2]=n,t[3]=s):s=t[3],r!==s}function Yg(t){return t.originalWorkflow}function Oe(){return $n(Xg)}function Xg(t){return t.trackingExecutionId}function zn(){return $n(Qg)}function Qg(t){return t.selectedGatewayId}function Sa(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Zg(t){if(Array.isArray(t))return t}function e1(t,e,n){return(e=l1(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function t1(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,s,o,i,l=[],a=!0,c=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(a=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);a=!0);}catch(u){c=!0,s=u}finally{try{if(!a&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw s}}return l}}function n1(){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 Ca(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Na(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ca(Object(n),!0).forEach(function(r){e1(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ca(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r1(t,e){if(t==null)return{};var n,r,s=s1(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(s[n]=t[n])}return s}function s1(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function o1(t,e){return Zg(t)||t1(t,e)||a1(t,e)||n1()}function i1(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function l1(t){var e=i1(t,"string");return typeof e=="symbol"?e:e+""}function a1(t,e){if(t){if(typeof t=="string")return Sa(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Sa(t,e):void 0}}function c1(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ea(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Ta(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ea(Object(n),!0).forEach(function(r){c1(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ea(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u1(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(r){return e.reduceRight(function(s,o){return o(s)},r)}}function Kn(t){return function e(){for(var n=this,r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return s.length>=t.length?t.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(n,[].concat(s,l))}}}function is(t){return{}.toString.call(t).includes("Object")}function d1(t){return!Object.keys(t).length}function ur(t){return typeof t=="function"}function f1(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function h1(t,e){return is(e)||Ot("changeType"),Object.keys(e).some(function(n){return!f1(t,n)})&&Ot("changeField"),e}function p1(t){ur(t)||Ot("selectorType")}function m1(t){ur(t)||is(t)||Ot("handlerType"),is(t)&&Object.values(t).some(function(e){return!ur(e)})&&Ot("handlersType")}function g1(t){t||Ot("initialIsRequired"),is(t)||Ot("initialType"),d1(t)&&Ot("initialContent")}function y1(t,e){throw new Error(t[e]||t.default)}var x1={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"},Ot=Kn(y1)(x1),Pr={changes:h1,selector:p1,handler:m1,initial:g1};function b1(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Pr.initial(t),Pr.handler(e);var n={current:t},r=Kn(v1)(n,e),s=Kn(w1)(n),o=Kn(Pr.changes)(t),i=Kn(k1)(n);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Pr.selector(c),c(n.current)}function a(c){u1(r,s,o,i)(c)}return[l,a]}function k1(t,e){return ur(e)?e(t.current):e}function w1(t,e){return t.current=Ta(Ta({},t.current),e),e}function v1(t,e,n){return ur(e)?e(t.current):Object.keys(n).forEach(function(r){var s;return(s=e[r])===null||s===void 0?void 0:s.call(e,t.current[r])}),n}var S1={create:b1},C1={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function N1(t){return function e(){for(var n=this,r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return s.length>=t.length?t.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(n,[].concat(s,l))}}}function E1(t){return{}.toString.call(t).includes("Object")}function T1(t){return t||Ma("configIsRequired"),E1(t)||Ma("configType"),t.urls?(M1(),{paths:{vs:t.urls.monacoBase}}):t}function M1(){console.warn(Pu.deprecation)}function O1(t,e){throw new Error(t[e]||t.default)}var Pu={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
|
+
`},Ma=N1(O1)(Pu),A1={config:T1},I1=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return function(s){return n.reduceRight(function(o,i){return i(o)},s)}};function Lu(t,e){return Object.keys(e).forEach(function(n){e[n]instanceof Object&&t[n]&&Object.assign(e[n],Lu(t[n],e[n]))}),Na(Na({},t),e)}var j1={type:"cancelation",msg:"operation is manually canceled"};function Ho(t){var e=!1,n=new Promise(function(r,s){t.then(function(o){return e?s(j1):r(o)}),t.catch(s)});return n.cancel=function(){return e=!0},n}var R1=["monaco"],D1=S1.create({config:C1,isInitialized:!1,resolve:null,reject:null,monaco:null}),$u=o1(D1,2),Tr=$u[0],ao=$u[1];function P1(t){var e=A1.config(t),n=e.monaco,r=r1(e,R1);ao(function(s){return{config:Lu(s.config,r),monaco:n}})}function L1(){var t=Tr(function(e){var n=e.monaco,r=e.isInitialized,s=e.resolve;return{monaco:n,isInitialized:r,resolve:s}});if(!t.isInitialized){if(ao({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Ho(Wo);if(window.monaco&&window.monaco.editor)return _u(window.monaco),t.resolve(window.monaco),Ho(Wo);I1($1,z1)(B1)}return Ho(Wo)}function $1(t){return document.body.appendChild(t)}function _1(t){var e=document.createElement("script");return t&&(e.src=t),e}function z1(t){var e=Tr(function(r){var s=r.config,o=r.reject;return{config:s,reject:o}}),n=_1("".concat(e.config.paths.vs,"/loader.js"));return n.onload=function(){return t()},n.onerror=e.reject,n}function B1(){var t=Tr(function(n){var r=n.config,s=n.resolve,o=n.reject;return{config:r,resolve:s,reject:o}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(n){var r=n.m||n;_u(r),t.resolve(r)},function(n){t.reject(n)})}function _u(t){Tr().monaco||ao({monaco:t})}function F1(){return Tr(function(t){var e=t.monaco;return e})}var Wo=new Promise(function(t,e){return ao({resolve:t,reject:e})}),co={config:P1,init:L1,__getMonacoInstance:F1},V1={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},qo=V1,H1={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},W1=H1;function q1({children:t}){return Z.createElement("div",{style:W1.container},t)}var U1=q1,K1=U1;function J1({width:t,height:e,isEditorReady:n,loading:r,_ref:s,className:o,wrapperProps:i}){return Z.createElement("section",{style:{...qo.wrapper,width:t,height:e},...i},!n&&Z.createElement(K1,null,r),Z.createElement("div",{ref:s,style:{...qo.fullWidth,...!n&&qo.hide},className:o}))}var G1=J1,zu=N.memo(G1);function Y1(t){N.useEffect(t,[])}var Bu=Y1;function X1(t,e,n=!0){let r=N.useRef(!0);N.useEffect(r.current||!n?()=>{r.current=!1}:t,e)}var De=X1;function Qn(){}function kn(t,e,n,r){return Q1(t,r)||Z1(t,e,n,r)}function Q1(t,e){return t.editor.getModel(Fu(t,e))}function Z1(t,e,n,r){return t.editor.createModel(e,n,r?Fu(t,r):void 0)}function Fu(t,e){return t.Uri.parse(e)}function e0({original:t,modified:e,language:n,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=Qn,onMount:x=Qn}){let[b,k]=N.useState(!1),[S,w]=N.useState(!0),C=N.useRef(null),v=N.useRef(null),M=N.useRef(null),E=N.useRef(x),O=N.useRef(y),R=N.useRef(!1);Bu(()=>{let D=co.init();return D.then(T=>(v.current=T)&&w(!1)).catch(T=>T?.type!=="cancelation"&&console.error("Monaco initialization: error:",T)),()=>C.current?z():D.cancel()}),De(()=>{if(C.current&&v.current){let D=C.current.getOriginalEditor(),T=kn(v.current,t||"",r||n||"text",o||"");T!==D.getModel()&&D.setModel(T)}},[o],b),De(()=>{if(C.current&&v.current){let D=C.current.getModifiedEditor(),T=kn(v.current,e||"",s||n||"text",i||"");T!==D.getModel()&&D.setModel(T)}},[i],b),De(()=>{let D=C.current.getModifiedEditor();D.getOption(v.current.editor.EditorOption.readOnly)?D.setValue(e||""):e!==D.getValue()&&(D.executeEdits("",[{range:D.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),D.pushUndoStop())},[e],b),De(()=>{C.current?.getModel()?.original.setValue(t||"")},[t],b),De(()=>{let{original:D,modified:T}=C.current.getModel();v.current.editor.setModelLanguage(D,r||n||"text"),v.current.editor.setModelLanguage(T,s||n||"text")},[n,r,s],b),De(()=>{v.current?.editor.setTheme(c)},[c],b),De(()=>{C.current?.updateOptions(d)},[d],b);let L=N.useCallback(()=>{if(!v.current)return;O.current(v.current);let D=kn(v.current,t||"",r||n||"text",o||""),T=kn(v.current,e||"",s||n||"text",i||"");C.current?.setModel({original:D,modified:T})},[n,e,s,t,r,o,i]),B=N.useCallback(()=>{!R.current&&M.current&&(C.current=v.current.editor.createDiffEditor(M.current,{automaticLayout:!0,...d}),L(),v.current?.editor.setTheme(c),k(!0),R.current=!0)},[d,c,L]);N.useEffect(()=>{b&&E.current(C.current,v.current)},[b]),N.useEffect(()=>{!S&&!b&&B()},[S,b,B]);function z(){let D=C.current?.getModel();l||D?.original?.dispose(),a||D?.modified?.dispose(),C.current?.dispose()}return Z.createElement(zu,{width:h,height:f,isEditorReady:b,loading:u,_ref:M,className:m,wrapperProps:g})}var t0=e0;N.memo(t0);function n0(t){let e=N.useRef();return N.useEffect(()=>{e.current=t},[t]),e.current}var r0=n0,Lr=new Map;function s0({defaultValue:t,defaultLanguage:e,defaultPath:n,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=Qn,onMount:b=Qn,onChange:k,onValidate:S=Qn}){let[w,C]=N.useState(!1),[v,M]=N.useState(!0),E=N.useRef(null),O=N.useRef(null),R=N.useRef(null),L=N.useRef(b),B=N.useRef(x),z=N.useRef(),D=N.useRef(r),T=r0(o),_=N.useRef(!1),P=N.useRef(!1);Bu(()=>{let F=co.init();return F.then(W=>(E.current=W)&&M(!1)).catch(W=>W?.type!=="cancelation"&&console.error("Monaco initialization: error:",W)),()=>O.current?G():F.cancel()}),De(()=>{let F=kn(E.current,t||r||"",e||s||"",o||n||"");F!==O.current?.getModel()&&(d&&Lr.set(T,O.current?.saveViewState()),O.current?.setModel(F),d&&O.current?.restoreViewState(Lr.get(o)))},[o],w),De(()=>{O.current?.updateOptions(c)},[c],w),De(()=>{!O.current||r===void 0||(O.current.getOption(E.current.editor.EditorOption.readOnly)?O.current.setValue(r):r!==O.current.getValue()&&(P.current=!0,O.current.executeEdits("",[{range:O.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),O.current.pushUndoStop(),P.current=!1))},[r],w),De(()=>{let F=O.current?.getModel();F&&s&&E.current?.editor.setModelLanguage(F,s)},[s],w),De(()=>{l!==void 0&&O.current?.revealLine(l)},[l],w),De(()=>{E.current?.editor.setTheme(i)},[i],w);let U=N.useCallback(()=>{if(!(!R.current||!E.current)&&!_.current){B.current(E.current);let F=o||n,W=kn(E.current,r||t||"",e||s||"",F||"");O.current=E.current?.editor.create(R.current,{model:W,automaticLayout:!0,...c},u),d&&O.current.restoreViewState(Lr.get(F)),E.current.editor.setTheme(i),l!==void 0&&O.current.revealLine(l),C(!0),_.current=!0}},[t,e,n,r,s,o,c,u,d,i,l]);N.useEffect(()=>{w&&L.current(O.current,E.current)},[w]),N.useEffect(()=>{!v&&!w&&U()},[v,w,U]),D.current=r,N.useEffect(()=>{w&&k&&(z.current?.dispose(),z.current=O.current?.onDidChangeModelContent(F=>{P.current||k(O.current.getValue(),F)}))},[w,k]),N.useEffect(()=>{if(w){let F=E.current.editor.onDidChangeMarkers(W=>{let Q=O.current.getModel()?.uri;if(Q&&W.find(X=>X.path===Q.path)){let X=E.current.editor.getModelMarkers({resource:Q});S?.(X)}});return()=>{F?.dispose()}}return()=>{}},[w,S]);function G(){z.current?.dispose(),f?d&&Lr.set(o,O.current.saveViewState()):O.current.getModel()?.dispose(),O.current.dispose()}return Z.createElement(zu,{width:h,height:m,isEditorReady:w,loading:a,_ref:R,className:g,wrapperProps:y})}var o0=s0,i0=N.memo(o0),l0=i0;async function a0(t){const e=t.getModel();if(!e)throw new Error("[Monaco] No model found in editor");const n=e.getValue(),s=n.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(n),null;const i=o[0];if(!i)return e.setValue(n),null;const l={lineNumber:i.range.startLineNumber,column:i.range.startColumn+1};try{const c=await(await co.init()).languages.typescript.getTypeScriptWorker();if(!c)return e.setValue(n),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(n),f){const m=f.displayParts.map(y=>y.text).join("").replace(/^const __outputValue:\s*/,"");return wn(m)}else return null}catch(a){return e.setValue(n),console.error("Error getting return type:",a),null}}function wn(t){if(t=t.trim(),t==="string")return{type:"string"};if(t==="number")return{type:"number"};if(t==="boolean")return{type:"boolean"};if(t==="null")return{type:"null"};if(t==="undefined")return{type:"null"};if(t==="unknown"||t==="any")return{};if(t==="never")return{not:{}};if(t.endsWith("[]")){const r=t.slice(0,-2);return{type:"array",items:wn(r)}}const e=t.match(/^Array<(.+)>$/);if(e&&e[1])return{type:"array",items:wn(e[1])};const n=t.match(/^Record<(.+),\s*(.+)>$/);if(n&&n[2])return{type:"object",additionalProperties:wn(n[2].trim())};if(t.includes("|")){const r=c0(t);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=>wn(o.trim()))}}return/^["'].*["']$/.test(t)?{type:"string",const:t.slice(1,-1)}:/^-?\d+(\.\d+)?$/.test(t)?{type:"number",const:parseFloat(t)}:t.startsWith("{")&&t.endsWith("}")?u0(t):{description:`TypeScript type: ${t}`}}function c0(t){const e=[];let n=0,r="";for(let s=0;s<t.length;s++){const o=t[s];if(o==="{"||o==="<"||o==="("||o==="[")n++;else if(o==="}"||o===">"||o===")"||o==="]")n--;else if(o==="|"&&n===0){e.push(r.trim()),r="";continue}r+=o}return r.trim()&&e.push(r.trim()),e}function u0(t){const e=t.slice(1,-1).trim();if(!e)return{type:"object",properties:{}};const n={},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()&&Oa(o.trim(),n,r),o="";continue}o+=a}o.trim()&&Oa(o.trim(),n,r);const i={type:"object",properties:n};return r.length>0&&(i.required=r),i}function Oa(t,e,n){const r=t.match(/^(\w+)(\?)?:\s*(.+)$/s);if(r){const s=r[1],o=r[2],i=r[3];s&&i&&(e[s]=wn(i.trim()),o||n.push(s))}}class d0 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(n=>({hasError:!1,mountKey:n.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 $r=null;const f0=async()=>{if($r)return $r;const[t,e,n]=await Promise.all([_o(()=>import("./standalone-Cva4pL7v.js"),[]),_o(()=>import("./typescript-Ca_eWjgL.js"),[]),_o(()=>import("./estree-CwOGYdhi.js"),[])]);return $r={format:t.format,plugins:[e.default,n.default]},$r};co.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});const h0={parser:"typescript",semi:!0,singleQuote:!1,tabWidth:2,trailingComma:"es5",printWidth:80},Aa={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"},p0=p.jsx("div",{className:"flex items-center justify-center h-full w-full text-gray-400",children:p.jsx(Ln,{size:"sm"})}),m0=N.memo(function({code:e,onChange:n,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?{...Aa,readOnly:!0}:Aa,x=async k=>{const S=k.getModel();if(!S){console.warn("No model found");return}const w=S.getValue();if(f.current==="json"){try{const v=JSON.parse(w),M=JSON.stringify(v,null,2);if(M!==w){const E=S.getFullModelRange();k.executeEdits("json-format",[{range:E,text:M}])}}catch(v){console.error("JSON formatting failed:",v)}return}try{const{format:v,plugins:M}=await f0(),E=await v(w,{...h0,plugins:M});if(E!==w){const O=S.getFullModelRange();k.executeEdits("prettier",[{range:O,text:E}])}}catch(v){console.error("Prettier formatting failed:",v)}},b=async(k,S)=>{c.current=k,l&&u.current&&(u.current.style.visibility="hidden",await k.getAction("editor.foldLevel2")?.run(),u.current.style.visibility="visible"),i==="typescript"&&(S.languages.typescript.typescriptDefaults.setCompilerOptions({target:S.languages.typescript.ScriptTarget.ESNext,module:S.languages.typescript.ModuleKind.ESNext,moduleResolution:S.languages.typescript.ModuleResolutionKind.NodeJs,allowNonTsExtensions:!0,allowJs:!0,strict:!1,noEmit:!0,esModuleInterop:!0,jsx:S.languages.typescript.JsxEmit.React,allowSyntheticDefaultImports:!0}),S.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!1,noSyntaxValidation:!1})),k.addCommand(S.KeyMod.CtrlCmd|S.KeyCode.KeyS,async()=>{await x(k);const w=await a0(k),C=k.getValue();console.log({value:C,returnType:w}),d.current?.(C,w)})};return p.jsx("div",{ref:u,className:"h-full",children:p.jsx(l0,{height:o,language:i,value:e,path:g,onChange:n,onMount:b,loading:p0,options:y},m)})}),ml=N.memo(function(e){const n=j.c(2);let r;return n[0]!==e?(r=p.jsx(d0,{children:p.jsx(m0,{...e})}),n[0]=e,n[1]=r):r=n[1],r});function Mr(){const t=j.c(2),e=Mp();let n;t[0]!==e?(n={connections:e,binding:"WORKFLOW"},t[0]=e,t[1]=n):n=t[1];const r=Wp(n);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}const Ia=[1,500,1e3,2e3,3e3];function Bn(t){const e=j.c(16),n=Mr();let r;e[0]!==n.id?(r=ot(n.id),e[0]=n.id,e[1]=r):r=e[1];const s=r,o=N.useRef(0);let i;e[2]!==t?(i={id:t},e[2]=t,e[3]=i):i=e[3];const l=!!t;let a;e[4]!==t?(a=t?g=>{const y=g.state?.data?.item?.status;if(y==="running"||y==="enqueued"){const x=Ia[o.current]??1;return o.current=(o.current+1)%Ia.length,x}return o.current=0,!1}:!1,e[4]=t,e[5]=a):a=e[5];let c;e[6]!==n.id||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==s?(c={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET",toolInputParams:i,scope:n.id,enabled:l,refetchInterval:a},e[6]=n.id,e[7]=i,e[8]=l,e[9]=a,e[10]=s,e[11]=c):c=e[11];const{data:u,isLoading:d}=hu(c),f=u?.item,h=u?.step_results;let m;return e[12]!==d||e[13]!==f||e[14]!==h?(m={item:f,step_results:h,isLoading:d},e[12]=d,e[13]=f,e[14]=h,e[15]=m):m=e[15],m}function g0(){const t=j.c(19),e=Mr(),n=_n();let r;t[0]!==e.id?(r=ot(e.id),t[0]=e.id,t[1]=r):r=t[1];const s=r;let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=["workflow"],t[2]=o):o=t[2];let i;t[3]!==n.id?(i={field:o,operator:"eq",value:n.id},t[3]=n.id,t[4]=i):i=t[4];let l;t[5]===Symbol.for("react.memo_cache_sentinel")?(l=[{field:["created_at"],direction:"desc"}],t[5]=l):l=t[5];let a;t[6]!==i?(a={where:i,orderBy:l,limit:100},t[6]=i,t[7]=a):a=t[7];const c=`${e.id}-executions-${n.id}`,u=!!n.id;let d;t[8]!==a||t[9]!==c||t[10]!==u||t[11]!==s?(d={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_LIST",toolInputParams:a,scope:c,enabled:u,staleTime:5e3},t[8]=a,t[9]=c,t[10]=u,t[11]=s,t[12]=d):d=t[12];const{data:f,isLoading:h,refetch:m}=hu(d),g=f;let y;t[13]!==g?.items?(y=g?.items??[],t[13]=g?.items,t[14]=y):y=t[14];let x;return t[15]!==h||t[16]!==m||t[17]!==y?(x={executions:y,isLoading:h,refetch:m},t[15]=h,t[16]=m,t[17]=y,t[18]=x):x=t[18],x}function Vu(t){const e=[];function n(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(n):typeof r=="object"&&r!==null&&Object.values(r).forEach(n)}return n(t),[...new Set(e)]}function y0(t){const e=[];for(const n of t){const r=Vu(n.input);e.push(...r)}return[...new Set(e)].filter(n=>n!=="__entire_input__")}function x0(t){for(const e of t)if(Vu(e.input).includes("__entire_input__"))return!0;return!1}function b0(t){const e=y0(t);if(e.length===0)return x0(t)?{type:"object",additionalProperties:!0,description:"Workflow input data"}:null;const n={},r=[];for(const s of e){const o=s.split(".");if(o.length===1)n[s]={type:"string",description:`Input field: ${s}`},r.push(s);else{const i=o[0];i&&!n[i]&&(n[i]={type:"object",description:`Input object: ${i}`,additionalProperties:!0},r.push(i))}}return{type:"object",properties:n,required:r,description:"Workflow execution input"}}function k0(){const t=j.c(2),e=_n();let n;return t[0]!==e.steps?(n=b0(e.steps),t[0]=e.steps,t[1]=n):n=t[1],n}function w0(){const t=j.c(14),{id:e}=Mr(),{setTrackingExecutionId:n}=je();let r;t[0]!==e?(r=ot(e),t[0]=e,t[1]=r):r=t[1];const s=r,o=_n(),i=zn(),l=k0();let a;t[2]!==s?(a={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_CREATE"},t[2]=s,t[3]=a):a=t[3];const{mutateAsync:c,isPending:u}=fl(a);let d;t[4]!==i||t[5]!==n||t[6]!==c||t[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}),k=b.id??b.structuredContent.id;return n(k),k},t[4]=i,t[5]=n,t[6]=c,t[7]=o,t[8]=d):d=t[8];const f=d,h=l!==null;let m;return t[9]!==f||t[10]!==l||t[11]!==u||t[12]!==h?(m={handleRunWorkflow:f,isPending:u,requiresInput:h,inputSchema:l},t[9]=f,t[10]=l,t[11]=u,t[12]=h,t[13]=m):m=t[13],m}function v0(){const t=j.c(9),{id:e}=Mr();let n;t[0]!==e?(n=ot(e),t[0]=e,t[1]=n):n=t[1];const r=n;let s;t[2]!==r?(s={toolCaller:r,toolName:"CANCEL_EXECUTION"},t[2]=r,t[3]=s):s=t[3];const{mutateAsync:o,isPending:i}=fl(s);let l;t[4]!==o?(l=async u=>await o({executionId:u}),t[4]=o,t[5]=l):l=t[5];const a=l;let c;return t[6]!==a||t[7]!==i?(c={handleCancelWorkflow:a,isCancelling:i},t[6]=a,t[7]=i,t[8]=c):c=t[8],c}function S0(){const t=j.c(9),{id:e}=Mr();let n;t[0]!==e?(n=ot(e),t[0]=e,t[1]=n):n=t[1];const r=n;let s;t[2]!==r?(s={toolCaller:r,toolName:"RESUME_EXECUTION"},t[2]=r,t[3]=s):s=t[3];const{mutateAsync:o,isPending:i}=fl(s);let l;t[4]!==o?(l=async u=>(await o({executionId:u})).success,t[4]=o,t[5]=l):l=t[5];const a=l;let c;return t[6]!==a||t[7]!==i?(c={handleResumeWorkflow:a,isResuming:i},t[6]=a,t[7]=i,t[8]=c):c=t[8],c}function C0(){const t=j.c(4),e=Oe(),{step_results:n,item:r}=Bn(e);let s;return t[0]!==r||t[1]!==n||t[2]!==e?(s=e&&n?(()=>{const i={};r?.input&&(i.input=r.input);for(const l of n)l.step_id&&l.output!==void 0&&(i[l.step_id]=l.output);return i})():void 0,t[0]=r,t[1]=n,t[2]=e,t[3]=s):s=t[3],s}function N0(t,e,n,r){if(!e)return[...t].sort(r);const s=n(e);return[...t].sort((o,i)=>{const l=n(o),a=n(i);return l===s?-1:a===s?1:r?r(o,i):0})}const gl=Lg()(Iu(t=>({viewMode:"visual",setViewMode:e=>t({viewMode:e}),showExecutionsList:!1,setShowExecutionsList:e=>t({showExecutionsList:e}),toggleExecutionsList:()=>t(e=>({showExecutionsList:!e.showExecutionsList}))}),{name:"workflow-view-mode"})),Hu=N.createContext([]);function Wu(){return N.useContext(Hu)}function be(t){this.content=t}be.prototype={constructor:be,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),o=r.content.slice();return s==-1?o.push(n||t,e):(o[s+1]=e,n&&(o[s]=n)),new be(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new be(n)},addToStart:function(t,e){return new be([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new be(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),o=r.find(t);return s.splice(o==-1?s.length:o,0,e,n),new be(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=be.from(t),t.size?new be(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=be.from(t),t.size?new be(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=be.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};be.from=function(t){if(t instanceof be)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new be(e)};function qu(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),o=e.child(r);if(s==o){n+=s.nodeSize;continue}if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)n++;return n}if(s.content.size||o.content.size){let i=qu(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function Uu(t,e,n,r){for(let s=t.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:n,b:r};let i=t.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){n-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:n,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++,n--,r--;return{a:n,b:r}}if(i.content.size||l.content.size){let c=Uu(i.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class A{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,o){for(let i=0,l=0;l<n;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,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let o="",i=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-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 n=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new A(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let o=0,i=0;i<n;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,n-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,n-i-1))),r.push(l),s+=l.nodeSize),i=a}return new A(r,s)}cutByIndex(e,n){return e==n?A.empty:e==0&&n==this.content.length?this:new A(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new A(s,o)}addToStart(e){return new A([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new A(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return qu(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Uu(this,e,n,r)}findIndex(e){if(e==0)return _r(0,e);if(e==this.size)return _r(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),o=r+s.nodeSize;if(o>=e)return o==e?_r(n+1,o):_r(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return A.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new A(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return A.empty;let n,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(n||(n=e.slice(0,s)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new A(n||e,r)}static from(e){if(!e)return A.empty;if(e instanceof A)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new A([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}A.empty=new A([],0);const Uo={index:0,offset:0};function _r(t,e){return Uo.index=t,Uo.offset=e,Uo}function ls(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ls(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ls(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ne=class Si{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ls(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Si.none;if(e instanceof Si)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};ne.none=[];class as extends Error{}class ${constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Ju(this.content,e+this.openStart,n);return r&&new $(r,this.openStart,this.openEnd)}removeBetween(e,n){return new $(Ku(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return $.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new $(A.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)s++;return new $(e,r,s)}}$.empty=new $(A.empty,0,0);function Ku(t,e,n){let{index:r,offset:s}=t.findIndex(e),o=t.maybeChild(r),{index:i,offset:l}=t.findIndex(n);if(s==e||o.isText){if(l!=n&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(Ku(o.content,e-s-1,n-s-1)))}function Ju(t,e,n,r){let{index:s,offset:o}=t.findIndex(e),i=t.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=Ju(i.content,e-o-1,n,i);return l&&t.replaceChild(s,i.copy(l))}function E0(t,e,n){if(n.openStart>t.depth)throw new as("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new as("Inconsistent open depths");return Gu(t,e,n,0)}function Gu(t,e,n,r){let s=t.index(r),o=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let i=Gu(t,e,n,r+1);return o.copy(o.content.replaceChild(s,i))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let i=t.parent,l=i.content;return Jt(i,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=T0(n,t);return Jt(o,Xu(t,i,l,e,r))}else return Jt(o,cs(t,e,r))}function Yu(t,e){if(!e.type.compatibleContent(t.type))throw new as("Cannot join "+e.type.name+" onto "+t.type.name)}function Ci(t,e,n){let r=t.node(n);return Yu(r,e.node(n)),r}function Kt(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Zn(t,e,n,r){let s=(e||t).node(n),o=0,i=e?e.index(n):s.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Kt(t.nodeAfter,r),o++));for(let l=o;l<i;l++)Kt(s.child(l),r);e&&e.depth==n&&e.textOffset&&Kt(e.nodeBefore,r)}function Jt(t,e){return t.type.checkContent(e),t.copy(e)}function Xu(t,e,n,r,s){let o=t.depth>s&&Ci(t,e,s+1),i=r.depth>s&&Ci(n,r,s+1),l=[];return Zn(null,t,s,l),o&&i&&e.index(s)==n.index(s)?(Yu(o,i),Kt(Jt(o,Xu(t,e,n,r,s+1)),l)):(o&&Kt(Jt(o,cs(t,e,s+1)),l),Zn(e,n,s,l),i&&Kt(Jt(i,cs(n,r,s+1)),l)),Zn(r,null,s,l),new A(l)}function cs(t,e,n){let r=[];if(Zn(null,t,n,r),t.depth>n){let s=Ci(t,e,n+1);Kt(Jt(s,cs(t,e,n+1)),r)}return Zn(e,null,n,r),new A(r)}function T0(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)s=e.node(o).copy(A.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class dr{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ne.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);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 n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new us(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,o=n;for(let i=e;;){let{index: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 dr(n,r,o)}static resolveCached(e,n){let r=ja.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==n)return i}else ja.set(e,r=new M0);let s=r.elts[r.i]=dr.resolve(e,n);return r.i=(r.i+1)%O0,s}}class M0{constructor(){this.elts=[],this.i=0}}const O0=12,ja=new WeakMap;class us{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const A0=Object.create(null);class Fe{constructor(e,n,r,s=ne.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ls(this.attrs,n||e.defaultAttrs||A0)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new Fe(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Fe(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return $.empty;let s=this.resolve(e),o=this.resolve(n),i=r?0:s.sharedDepth(n),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,n,r){return E0(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return dr.resolveCached(this,e)}resolveNoCache(e){return dr.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Qu(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=A.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,n);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,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,n);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ne.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ne.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=A.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}Fe.prototype.text=void 0;class ds extends Fe{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Qu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new ds(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ds(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Qu(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Zt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new I0(e,n);if(r.next==null)return Zt.empty;let s=Zu(r);r.next&&r.err("Unexpected trailing text");let o=_0($0(s));return z0(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let o=n;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!n||a.validEnd))return A.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 n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let 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 n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[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 n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
|
|
26
|
+
`)}}Zt.empty=new Zt(!0);class I0{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Zu(t){let e=[];do e.push(j0(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function j0(t){let e=[];do e.push(R0(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function R0(t){let e=L0(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=D0(t,e);else break;return e}function Ra(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function D0(t,e){let n=Ra(t),r=n;return t.eat(",")&&(t.next!="}"?r=Ra(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function P0(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let o in n){let i=n[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function L0(t){if(t.eat("(")){let e=Zu(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=P0(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function $0(t){let e=[[]];return s(o(t,0),n()),e;function n(){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=n())}else if(i.type=="star"){let a=n();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=n();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=n();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=n();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 ed(t,e){return e-t}function Da(t,e){let n=[];return r(e),n.sort(ed);function r(s){let o=t[s];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&n.indexOf(a)==-1&&r(a)}}}function _0(t){let e=Object.create(null);return n(Da(t,0));function n(r){let s=[];r.forEach(i=>{t[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]);Da(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Zt(r.indexOf(t.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(ed);o.next.push({type:s[i][0],next:e[l.join(",")]||n(l)})}return o}}function z0(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],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 td(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function nd(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let o=t[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function rd(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let o=t[s];o.validate&&o.validate(e[s])}}function sd(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new F0(t,r,e[r]);return n}let Pa=class od{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=sd(e,r.attrs),this.defaultAttrs=td(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==Zt.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:nd(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Fe(this,this.computeAttrs(e),A.from(n),ne.setFrom(r))}createChecked(e=null,n,r){return n=A.from(n),this.checkContent(n),new Fe(this,this.computeAttrs(e),n,ne.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=A.from(n),n.size){let i=this.contentMatch.fillBefore(n);if(!i)return null;n=i.append(n)}let s=this.contentMatch.matchFragment(n),o=s&&s.fillBefore(A.empty,!0);return o?new Fe(this,e,n.append(o),ne.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){rd(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:ne.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,i)=>r[o]=new od(o,n,i));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function B0(t,e,n){let r=n.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class F0{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?B0(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class uo{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=sd(e,s.attrs),this.excluded=null;let o=td(this.attrs);this.instance=o?new ne(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,nd(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new uo(o,s++,n,i)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){rd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class id{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=be.from(e.nodes),n.marks=be.from(e.marks||{}),this.nodes=Pa.compile(this.spec.nodes,this),this.marks=uo.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]=Zt.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?La(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==""?[]:La(this,i.split(" "))}this.nodeFromJSON=s=>Fe.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,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Pa){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new ds(r,r.defaultAttrs,e,ne.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function La(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],o=t.marks[s],i=o;if(o)n.push(o);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function V0(t){return t.tag!=null}function H0(t){return t.style!=null}class At{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(V0(s))this.tags.push(s);else if(H0(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new _a(this,n,!1);return r.addAll(e,ne.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new _a(this,n,!0);return r.addAll(e,ne.none,n.from,n.to),$.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(U0(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,n,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],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)!=n))){if(i.getAttrs){let a=i.getAttrs(n);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let n=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<n.length;i++){let l=n[i];if((l.priority==null?50:l.priority)<o)break}n.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=za(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=za(i)),i.node||i.ignore||i.mark||(i.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new At(e,At.schemaRules(e)))}}const ld={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},W0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ad={ol:!0,ul:!0},fr=1,Ni=2,er=4;function $a(t,e,n){return e!=null?(e?fr:0)|(e==="full"?Ni:0):t&&t.whitespace=="pre"?fr|Ni:n&~er}class zr{constructor(e,n,r,s,o,i){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=ne.none,this.match=o||(i&er?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(A.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&fr)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let n=A.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(A.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ld.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _a{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,o,i=$a(null,n.preserveWhitespace,0)|(r?er:0);s?o=new zr(s.type,s.attrs,ne.none,!0,n.topMatch||s.type.contentMatch,i):r?o=new zr(null,null,ne.none,!0,null,i):o=new zr(e.schema.topNodeType,null,ne.none,!0,null,i),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,o=s.options&Ni?"full":this.localPreserveWS||(s.options&fr)>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(),n,!0),l[a]&&this.insertNode(i.text(l[a]),n,!/\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),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;ad.hasOwnProperty(i)&&this.parser.normalizeLists&&q0(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:W0.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,n);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(ld.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
28
|
+
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let o,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,n.attrs||null,r,n.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,n,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,n);this.findAtPoint(e,o)}findPlace(e,n,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++)n=this.enterInner(s[i],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=ne.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Ba(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,n,r,s){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,s)),o}enterInner(e,n,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=$a(e,o,i.options);i.options&er&&i.content.length==0&&(l|=er);let a=ne.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Ba(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new zr(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=fr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.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(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function q0(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ad.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function U0(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function za(t){let e={};for(let n in t)e[n]=t[n];return e}function Ba(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))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 on{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ko(n).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,n);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Xr(Ko(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Xr(Ko(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Xr(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new on(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Fa(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Fa(e.marks)}}function Fa(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ko(t){return t.document||window.document}const Va=new WeakMap;function K0(t){let e=Va.get(t);return e===void 0&&Va.set(t,e=J0(t)),e}function J0(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Xr(t,e,n,r){if(typeof e=="string")return{dom:t.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=K0(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(n=s.slice(0,i),s=s.slice(i+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?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}=Xr(t,f,n,r);if(a.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const cd=65535,ud=Math.pow(2,16);function G0(t,e){return t+e*ud}function Ha(t){return t&cd}function Y0(t){return(t-(t&cd))/ud}const dd=1,fd=2,Qr=4,hd=8;class Ei{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&hd)>0}get deletedBefore(){return(this.delInfo&(dd|Qr))>0}get deletedAfter(){return(this.delInfo&(fd|Qr))>0}get deletedAcross(){return(this.delInfo&Qr)>0}}class Pe{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Pe.empty)return Pe.empty}recover(e){let n=0,r=Ha(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Y0(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let 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:n:n,h=a+s+(f<0?0:u);if(r)return h;let m=e==(n<0?a:d)?null:G0(l/3,e-a),g=e==a?fd:e==d?dd:Qr;return(n<0?e!=a:e!=d)&&(g|=hd),new Ei(h,g,m)}s+=u-c}return r?e+s:new Ei(e+s,0,null)}touches(e,n){let r=0,s=Ha(n),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 n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new Pe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Pe.empty:new Pe(e<0?[0,-e,0]:[0,0,e])}}Pe.empty=new Pe([]);class hr{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new hr(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new hr;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,n);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 Ei(e,s,null)}}const Jo=Object.create(null);class Ne{getMap(){return Pe.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Jo[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Jo)throw new RangeError("Duplicate use of step JSON ID "+e);return Jo[e]=n,n.prototype.jsonID=e,n}}class he{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new he(e,null)}static fail(e){return new he(null,e)}static fromReplace(e,n,r,s){try{return he.ok(e.replace(n,r,s))}catch(o){if(o instanceof as)return he.fail(o.message);throw o}}}function yl(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let o=t.child(s);o.content.size&&(o=o.copy(yl(o.content,e,o))),o.isInline&&(o=e(o,n,s)),r.push(o)}return A.fromArray(r)}class Et extends Ne{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new $(yl(n.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,o)}invert(){return new Qe(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Et(n.pos,r.pos,this.mark)}merge(e){return e instanceof Et&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Et(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Et(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("addMark",Et);class Qe extends Ne{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new $(yl(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,r)}invert(){return new Et(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Qe(n.pos,r.pos,this.mark)}merge(e){return e instanceof Qe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Qe(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Qe(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("removeMark",Qe);class Tt extends Ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new $(A.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Tt(this.pos,n.marks[s]);return new Tt(this.pos,this.mark)}}return new en(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Tt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Tt(n.pos,e.markFromJSON(n.mark))}}Ne.jsonID("addNodeMark",Tt);class en extends Ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new $(A.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Tt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new en(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new en(n.pos,e.markFromJSON(n.mark))}}Ne.jsonID("removeNodeMark",en);class me extends Ne{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Ti(e,this.from,this.to)?he.fail("Structure replace would overwrite content"):he.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Pe([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 n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new me(n.pos,Math.max(n.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 n=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),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=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,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new me(n.from,n.to,$.fromJSON(e,n.slice),!!n.structure)}}Ne.jsonID("replace",me);class ye extends Ne{constructor(e,n,r,s,o,i,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Ti(e,this.from,this.gapFrom)||Ti(e,this.gapTo,this.to)))return he.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return he.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?he.fromReplace(e,this.from,this.to,r):he.fail("Content does not fit in gap")}getMap(){return new Pe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new ye(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||o>r.pos?null:new ye(n.pos,r.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ye(n.from,n.to,n.gapFrom,n.gapTo,$.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ne.jsonID("replaceAround",ye);function Ti(t,e,n){let r=t.resolve(e),s=n-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function X0(t,e,n,r){let s=[],o=[],i,l;t.doc.nodesBetween(e,n,(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,n),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 Qe(f,h,d[g])));l&&l.to==f?l.to=h:o.push(l=new Et(f,h,r))}}),s.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function Q0(t,e,n,r){let s=[],o=0;t.doc.nodesBetween(e,n,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof uo){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,n);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=>t.step(new Qe(i.from,i.to,i.style)))}function xl(t,e,n,r=n.contentMatch,s=!0){let o=t.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++)n.allowsMarkType(c.marks[f].type)||t.step(new Qe(l,u,c.marks[f]));if(s&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new $(A.from(n.schema.text(" ",n.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(A.empty,!0);t.replace(l,l,new $(a,0,0))}for(let a=i.length-1;a>=0;a--)t.step(i[a])}function Z0(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Fn(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,o=0;;--r){let i=t.$from.node(r),l=t.$from.index(r)+s,a=t.$to.indexAfter(r)-o;if(r<t.depth&&i.canReplace(l,a,n))return r;if(r==0||i.type.spec.isolating||!Z0(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function ey(t,e,n){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,u=A.empty,d=0;for(let m=o,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,u=A.from(r.node(m).copy(u)),d++):a--;let f=A.empty,h=0;for(let m=o,g=!1;m>n;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=A.from(s.node(m).copy(f)),h++):c++;t.step(new ye(a,c,i,l,new $(u.append(f),d,h),u.size-d,!0))}function bl(t,e,n=null,r=t){let s=ty(t,e),o=s&&ny(r,e);return o?s.map(Wa).concat({type:e,attrs:n}).concat(o.map(Wa)):null}function Wa(t){return{type:t,attrs:null}}function ty(t,e){let{parent:n,startIndex:r,endIndex:s}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return n.canReplaceWith(r,s,i)?o:null}function ny(t,e){let{parent:n,startIndex:r,endIndex:s}=t,o=n.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:i}function ry(t,e,n){let r=A.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let l=n[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=A.from(n[i].type.create(n[i].attrs,r))}let s=e.start,o=e.end;t.step(new ye(s,o,s,o,new $(r,0,0),n.length,!0))}function sy(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&oy(t.doc,t.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&&md(t,i,l,o),xl(t,t.mapping.slice(o).map(l,1),r,void 0,c===null);let u=t.mapping.slice(o),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return t.step(new ye(d,f,d+1,f-1,new $(A.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&pd(t,i,l,o),!1}})}function pd(t,e,n,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+o+i.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function md(t,e,n,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=t.mapping.slice(r).map(n+1+o);t.replaceWith(i,i+1,e.type.schema.text(`
|
|
29
|
+
`))}})}function oy(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function iy(t,e,n,r,s){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let i=n.create(r,null,s||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,i);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new ye(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new $(A.from(i),0,0),1,!0))}function ht(t,e,n=1,r){let s=t.resolve(e),o=s.depth-n,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>o;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),m=r&&r[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let 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 ly(t,e,n=1,r){let s=t.doc.resolve(e),o=A.empty,i=A.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){o=A.from(s.node(l).copy(o));let u=r&&r[c];i=A.from(u?u.type.create(u.attrs,i):s.node(l).copy(i))}t.step(new me(e,e,new $(o.append(i),n,n),!0))}function zt(t,e){let n=t.resolve(e),r=n.index();return gd(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function ay(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(i),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function gd(t,e){return!!(t&&e&&!t.isLeaf&&ay(t,e))}function fo(t,e,n=-1){let r=t.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):n>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&&gd(o,i)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function cy(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,o=t.doc.resolve(e-n),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);md(t,u.node(),u.before(),l)}i.inlineContent&&xl(t,e+n-1,i,o.node().contentMatchAt(o.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new me(c,a.map(e+n,-1),$.empty,!0)),r===!0){let u=t.doc.resolve(c);pd(t,u.node(),u.before(),t.steps.length)}return t}function uy(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,n))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,n))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function yd(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let o=0;o<n.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let i=r.depth;i>=0;i--){let 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 ho(t,e,n=e,r=$.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),o=t.resolve(n);return xd(s,o,r)?new me(e,n,r):new dy(s,o,r).fit()}function xd(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class dy{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=A.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=A.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let o=this.placed,i=r.depth,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,n):a.size||r.pos!=this.$to.pos?new me(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=Go(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(n==1&&(i?c.matchType(i.type)||(d=c.fillBefore(A.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:d};if(n==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:n,openEnd:r}=this.unplaced,s=Go(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new $(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Go(e,n);if(s.childCount<=1&&n>0){let o=e.size-n<=n+s.size;this.unplaced=new $(Jn(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new $(Jn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let 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[n];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(bd(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=Gn(this.placed,n,A.from(u)),this.frontier[n].match=d,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let 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 $(Jn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new $(Jn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Yo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),i=Yo(e,n,s,r,o);if(i){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Yo(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:i,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Gn(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Gn(this.placed,this.depth,A.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(A.empty,!0);n.childCount&&(this.placed=Gn(this.placed,this.frontier.length,n))}}function Jn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Jn(t.firstChild.content,e-1,n)))}function Gn(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Gn(t.lastChild.content,e-1,n)))}function Go(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function bd(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,bd(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(A.empty,!0)))),t.copy(r)}function Yo(t,e,n,r,s){let o=t.node(e),i=s?t.indexAfter(e):t.index(e);if(i==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,i);return l&&!fy(n,o.content,i)?l:null}function fy(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function hy(t){return t.spec.defining||t.spec.definingForContent}function py(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),o=t.doc.resolve(n);if(xd(s,o,r))return t.step(new me(e,n,r));let i=wd(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=hy(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),k=s.index(y-1);if(b.canReplaceWith(k,k,m.type,m.marks))return t.replace(s.before(y),x?o.after(y):n,new $(kd(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=i.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=i[f];h<0||(e=s.before(h),n=o.after(h))}}function kd(t,e,n,r,s){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(kd(o.content,e+1,n,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(t).append(t);t=i.append(o.matchFragment(i).fillBefore(A.empty,!0))}return t}function my(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=uy(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new $(A.from(r),0,0))}function gy(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),o=wd(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 t.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 t.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&&n>r.end(i)&&s.end(i)-n!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return t.delete(r.before(i),n);t.delete(e,n)}function wd(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let o=t.start(s);if(o<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&n.push(s)}return n}class Sn extends Ne{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return he.fromReplace(e,this.pos,this.pos+1,new $(A.from(s),0,n.isLeaf?0:1))}getMap(){return Pe.empty}invert(e){return new Sn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Sn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Sn(n.pos,n.attr,n.value)}}Ne.jsonID("attr",Sn);class pr extends Ne{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return he.ok(r)}getMap(){return Pe.empty}invert(e){return new pr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new pr(n.attr,n.value)}}Ne.jsonID("docAttr",pr);let En=class extends Error{};En=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};En.prototype=Object.create(Error.prototype);En.prototype.constructor=En;En.prototype.name="TransformError";class vd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new hr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new En(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=$.empty){let s=ho(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new $(A.from(r),0,0))}delete(e,n){return this.replace(e,n,$.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return py(this,e,n,r),this}replaceRangeWith(e,n,r){return my(this,e,n,r),this}deleteRange(e,n){return gy(this,e,n),this}lift(e,n){return ey(this,e,n),this}join(e,n=1){return cy(this,e,n),this}wrap(e,n){return ry(this,e,n),this}setBlockType(e,n=e,r,s=null){return sy(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return iy(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Sn(e,n,r)),this}setDocAttribute(e,n){return this.step(new pr(e,n)),this}addNodeMark(e,n){return this.step(new Tt(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ne)n.isInSet(r.marks)&&this.step(new en(e,n));else{let s=r.marks,o,i=[];for(;o=n.isInSet(s);)i.push(new en(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,n=1,r){return ly(this,e,n,r),this}addMark(e,n,r){return X0(this,e,n,r),this}removeMark(e,n,r){return Q0(this,e,n,r),this}clearIncompatible(e,n,r){return xl(this,e,n,r),this}}const Xo=Object.create(null);class J{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new yy(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=$.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.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:n),l==0&&Ka(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to: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,n),Ka(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new q(e):gn(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=n<0?gn(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):gn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(i)return i}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Le(e.node(0))}static atStart(e){return gn(e,e,0,0,1)||new Le(e)}static atEnd(e){return gn(e,e,e.content.size,e.childCount,-1)||new Le(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Xo[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Xo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Xo[e]=n,n.prototype.jsonID=e,n}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}}J.prototype.visible=!0;class yy{constructor(e,n){this.$from=e,this.$to=n}}let qa=!1;function Ua(t){!qa&&!t.parent.inlineContent&&(qa=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class q extends J{constructor(e,n=e){Ua(e),Ua(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return J.near(r);let s=e.resolve(n.map(this.anchor));return new q(s.parent.inlineContent?s:r,r)}replace(e,n=$.empty){if(super.replace(e,n),n==$.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 po(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new q(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let o=J.findFrom(n,r,!0)||J.findFrom(n,-r,!0);if(o)n=o.$head;else return J.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(J.findFrom(e,-r,!0)||J.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new q(e,n)}}J.jsonID("text",q);class po{constructor(e,n){this.anchor=e,this.head=n}map(e){return new po(e.map(this.anchor),e.map(this.head))}resolve(e){return q.between(e.resolve(this.anchor),e.resolve(this.head))}}class H extends J{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),o=e.resolve(s);return r?J.near(o):new H(o)}content(){return new $(A.from(this.node),0,0)}eq(e){return e instanceof H&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new kl(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new H(e.resolve(n.anchor))}static create(e,n){return new H(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}H.prototype.visible=!1;J.jsonID("node",H);class kl{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new po(r,r):new kl(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&H.isSelectable(r)?new H(n):J.near(n)}}class Le extends J{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=$.empty){if(n==$.empty){e.delete(0,e.doc.content.size);let r=J.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Le(e)}map(e){return new Le(e)}eq(e){return e instanceof Le}getBookmark(){return xy}}J.jsonID("all",Le);const xy={map(){return this},resolve(t){return new Le(t)}};function gn(t,e,n,r,s,o=!1){if(e.inlineContent)return q.create(t,n);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&&H.isSelectable(l))return H.create(t,n-(s<0?l.nodeSize:0))}else{let a=gn(t,l,n+s,s<0?l.childCount:0,s,o);if(a)return a}n+=l.nodeSize*s}return null}function Ka(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof me||s instanceof ye))return;let o=t.mapping.maps[r],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),t.setSelection(J.near(t.doc.resolve(i),n))}const Ja=1,Br=2,Ga=4;class by 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|Ja)&~Br,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ja)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Br,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&Br)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Br,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(n);o=r==n?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(J.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ga,this}get scrolledIntoView(){return(this.updated&Ga)>0}}function Ya(t,e){return!e||!t?t:t.bind(e)}class Yn{constructor(e,n,r){this.name=e,this.init=Ya(n.init,r),this.apply=Ya(n.apply,r)}}const ky=[new Yn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Yn("selection",{init(t,e){return t.selection||J.atStart(e.doc)},apply(t){return t.selection}}),new Yn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Yn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qo{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ky.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Yn(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,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<i?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}s&&(s[i]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new vn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new by(this)}static create(e){let n=new Qo(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new vn(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Qo(this.schema,e.plugins),r=n.fields,s=new vn(n);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],o=s.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Qo(e.schema,e.plugins),o=new vn(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=Fe.fromJSON(e.schema,n.doc);else if(i.name=="selection")o.selection=J.fromJSON(o.doc,n.selection);else if(i.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[i.name]=c.fromJSON.call(a,e,n[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function Sd(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Sd(s,e,{})),n[r]=s}return n}class ie{constructor(e){this.spec=e,this.props={},e.props&&Sd(e.props,this,this.props),this.key=e.key?e.key.key:Cd("plugin")}getState(e){return e[this.key]}}const Zo=Object.create(null);function Cd(t){return t in Zo?t+"$"+ ++Zo[t]:(Zo[t]=0,t+"$")}class de{constructor(e="key"){this.key=Cd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const wl=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Nd(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Ed=(t,e,n)=>{let r=Nd(t,n);if(!r)return!1;let s=vl(r);if(!s){let i=r.blockRange(),l=i&&Fn(i);return l==null?!1:(e&&e(t.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(Pd(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Tn(o,"end")||H.isSelectable(o)))for(let i=r.depth;;i--){let l=ho(t.doc,r.before(i),r.after(i),$.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Tn(o,"end")?J.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):H.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(t.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},wy=(t,e,n)=>{let r=Nd(t,n);if(!r)return!1;let s=vl(r);return s?Td(t,s,e):!1},vy=(t,e,n)=>{let r=Od(t,n);if(!r)return!1;let s=Sl(r);return s?Td(t,s,e):!1};function Td(t,e,n){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let i=e.nodeAfter,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=ho(t.doc,o,a,$.empty);if(!c||c.from!=o||c instanceof me&&c.slice.size>=a-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(q.create(u.doc,o)),n(u.scrollIntoView())}return!0}function Tn(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Md=(t,e,n)=>{let{$head:r,empty:s}=t.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=vl(r)}let i=o&&o.nodeBefore;return!i||!H.isSelectable(i)?!1:(e&&e(t.tr.setSelection(H.create(t.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function vl(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Od(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Ad=(t,e,n)=>{let r=Od(t,n);if(!r)return!1;let s=Sl(r);if(!s)return!1;let o=s.nodeAfter;if(Pd(t,s,e,1))return!0;if(r.parent.content.size==0&&(Tn(o,"start")||H.isSelectable(o))){let i=ho(t.doc,r.before(),r.after(),$.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=t.tr.step(i);l.setSelection(Tn(o,"start")?J.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):H.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},Id=(t,e,n)=>{let{$head:r,empty:s}=t.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=Sl(r)}let i=o&&o.nodeAfter;return!i||!H.isSelectable(i)?!1:(e&&e(t.tr.setSelection(H.create(t.doc,o.pos)).scrollIntoView()),!0)};function Sl(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const Sy=(t,e)=>{let n=t.selection,r=n instanceof H,s;if(r){if(n.node.isTextblock||!zt(t.doc,n.from))return!1;s=n.from}else if(s=fo(t.doc,n.from,-1),s==null)return!1;if(e){let o=t.tr.join(s);r&&o.setSelection(H.create(o.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Cy=(t,e)=>{let n=t.selection,r;if(n instanceof H){if(n.node.isTextblock||!zt(t.doc,n.to))return!1;r=n.to}else if(r=fo(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Ny=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),o=s&&Fn(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)},jd=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
30
|
+
`).scrollIntoView()),!0)};function Cl(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Ey=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),o=n.indexAfter(-1),i=Cl(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,i.createAndFill());a.setSelection(J.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Rd=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof Le||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=Cl(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=t.tr.insert(i,o.createAndFill());l.setSelection(q.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Dd=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(ht(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Fn(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function Ty(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof H&&e.selection.node.isBlock)return!r.parentOffset||!ht(e.doc,r.pos)?!1:(n&&n(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=Cl(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 Le)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=ht(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=ht(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 n&&n(u.scrollIntoView()),!0}}const My=Ty(),Oy=(t,e)=>{let{$from:n,to:r}=t.selection,s,o=n.sharedDepth(r);return o==0?!1:(s=n.before(o),e&&e(t.tr.setSelection(H.create(t.doc,s))),!0)};function Ay(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,o=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||zt(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Pd(t,e,n,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&Ay(t,e,n))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(n){let h=e.pos+o.nodeSize,m=A.empty;for(let x=i.length-1;x>=0;x--)m=A.from(i[x].create(null,m));m=A.from(s.copy(m));let g=t.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&&zt(g.doc,y.pos)&&g.join(y.pos),n(g.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:J.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Fn(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&Tn(o,"start",!0)&&Tn(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(n){let x=A.empty;for(let k=m.length-1;k>=0;k--)x=A.from(m[k].copy(x));let b=t.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));n(b.scrollIntoView())}return!0}}return!1}function Ld(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(n&&n(e.tr.setSelection(q.create(e.doc,t<0?s.start(o):s.end(o)))),!0):!1}}const Iy=Ld(-1),jy=Ld(1);function Ry(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o),l=i&&bl(i,t,e);return l?(r&&r(n.tr.wrap(i,l).scrollIntoView()),!0):!1}}function Xa(t,e=null){return function(n,r){let s=!1;for(let o=0;o<n.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let o=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[i];o.setBlockType(l,a,t,e)}r(o.scrollIntoView())}return!0}}function Nl(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Nl(wl,Ed,Md);Nl(wl,Ad,Id);Nl(jd,Rd,Dd,My);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Dy(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o);if(!i)return!1;let l=r?n.tr:null;return Py(l,i,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Py(t,e,n,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);o=new us(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new us(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=bl(o,n,r,e);return l?(t&&Ly(t,e,l,s,n),!0):!1}function Ly(t,e,n,r,s){let o=A.empty;for(let u=n.length-1;u>=0;u--)o=A.from(n[u].type.create(n[u].attrs,o));t.step(new ye(e.start-(r?2:0),e.end,e.start,e.end,new $(o,0,0),n.length,!0));let i=0;for(let u=0;u<n.length;u++)n[u].type==s&&(i=u+1);let l=n.length-i,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&ht(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function $y(t){return function(e,n){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?_y(e,n,t,o):zy(e,n,o):!0:!1}}function _y(t,e,n,r){let s=t.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new ye(o-1,i,o,i,new $(A.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new us(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=Fn(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return zt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function zy(t,e,n){let r=t.tr,s=n.parent;for(let h=n.end,m=n.endIndex-1,g=n.startIndex;m>g;m--)h-=s.child(m).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(n.start),i=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?A.empty:A.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?A.empty:A.from(s.copy(A.empty))).append(a?A.empty:A.from(s.copy(A.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function By(t){return function(e,n){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=A.from(c?t.create():null),d=new $(A.from(t.create(null,A.from(l.type.create(null,u)))),c?3:1,0),f=o.start,h=o.end;n(e.tr.step(new ye(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const ke=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Mn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Mi=null;const ut=function(t,e,n){let r=Mi||(Mi=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Fy=function(){Mi=null},tn=function(t,e,n,r){return n&&(Qa(t,e,n,r,-1)||Qa(t,e,n,r,1))},Vy=/^(img|br|input|textarea|hr)$/i;function Qa(t,e,n,r,s){for(var o;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Be(t))){let i=t.parentNode;if(!i||i.nodeType!=1||Or(t)||Vy.test(t.nodeName)||t.contentEditable=="false")return!1;e=ke(t)+(s<0?0:1),t=i}else if(t.nodeType==1){let i=t.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else t=i,e=s<0?Be(t):0}else return!1}}function Be(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Hy(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Be(t)}else if(t.parentNode&&!Or(t))e=ke(t),t=t.parentNode;else return null}}function Wy(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Or(t))e=ke(t)+1,t=t.parentNode;else return null}}function qy(t,e,n){for(let r=e==0,s=e==Be(t);r||s;){if(t==n)return!0;let o=ke(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,s=s&&o==Be(t)}}function Or(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const mo=function(t){return t.focusNode&&tn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Vt(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Uy(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ky(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Be(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Be(r.startContainer),r.startOffset)}}}const rt=typeof navigator<"u"?navigator:null,Za=typeof document<"u"?document:null,Bt=rt&&rt.userAgent||"",Oi=/Edge\/(\d+)/.exec(Bt),$d=/MSIE \d/.exec(Bt),Ai=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bt),Ie=!!($d||Ai||Oi),It=$d?document.documentMode:Ai?+Ai[1]:Oi?+Oi[1]:0,Ve=!Ie&&/gecko\/(\d+)/i.test(Bt);Ve&&+(/Firefox\/(\d+)/.exec(Bt)||[0,0])[1];const Ii=!Ie&&/Chrome\/(\d+)/.exec(Bt),ge=!!Ii,_d=Ii?+Ii[1]:0,Ce=!Ie&&!!rt&&/Apple Computer/.test(rt.vendor),On=Ce&&(/Mobile\/\w+/.test(Bt)||!!rt&&rt.maxTouchPoints>2),ze=On||(rt?/Mac/.test(rt.platform):!1),zd=rt?/Win/.test(rt.platform):!1,ft=/Android \d/.test(Bt),Ar=!!Za&&"webkitFontSmoothing"in Za.documentElement.style,Jy=Ar?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Gy(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function it(t,e){return typeof t=="number"?t:t[e]}function Yy(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function ec(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let i=n||t.dom;i;){if(i.nodeType!=1){i=Mn(i);continue}let l=i,a=l==o.body,c=a?Gy(o):Yy(l),u=0,d=0;if(e.top<c.top+it(r,"top")?d=-(c.top-e.top+it(s,"top")):e.bottom>c.bottom-it(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+it(s,"top")-c.top:e.bottom-c.bottom+it(s,"bottom")),e.left<c.left+it(r,"left")?u=-(c.left-e.left+it(s,"left")):e.right>c.right-it(r,"right")&&(u=e.right-c.right+it(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:Mn(i)}}function Xy(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=n+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=t.root.elementFromPoint(o,i);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Bd(t.dom)}}function Bd(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Mn(r));return e}function Qy({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Fd(n,r==0?0:r-e)}function Fd(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:o}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let pn=null;function Zy(t){if(t.setActive)return t.setActive();if(pn)return t.focus(pn);let e=Bd(t);t.focus(pn==null?{get preventScroll(){return pn={preventScroll:!0},!0}}:void 0),pn||(pn=!1,Fd(e,0))}function Vd(t,e){let n,r=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=ut(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){n=u,r=g,s=g&&n.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});!n&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?ex(n,s):!n||r&&n.nodeType==1?{node:t,offset:o}:Vd(n,s)}function ex(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let i=bt(r,1);if(i.top!=i.bottom&&El(e,i)){s={node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function El(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function tx(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function nx(t,e,n){let{node:r,offset:s}=Vd(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return t.docView.posFromDOM(r,s,o)}function rx(t,e,n,r){let s=-1;for(let o=e,i=!1;o!=t.dom;){let l=t.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:t.docView.posFromDOM(e,n,-1)}function Hd(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=s;;){let i=t.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(El(e,c))return Hd(i,e,c)}}if((o=(o+1)%r)==s)break}return t}function sx(t,e){let n=t.dom.ownerDocument,r,s=0,o=Ky(n,e.left,e.top);o&&({node:r,offset:s}=o);let i=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!i||!t.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=t.dom.getBoundingClientRect();if(!El(e,c)||(i=Hd(t.dom,e,c),!i))return null}if(Ce)for(let c=i;r&&c;c=Mn(c))c.draggable&&(r=void 0);if(i=tx(i,e),r){if(Ve&&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;Ar&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=rx(t,r,s,e))}l==null&&(l=nx(t,i,e));let a=t.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function tc(t){return t.top<t.bottom||t.left<t.right}function bt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(tc(r))return r}return Array.prototype.find.call(n,tc)||t.getBoundingClientRect()}const ox=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Wd(t,e,n){let{node:r,offset:s,atom:o}=t.docView.domFromPos(e,n<0?-1:1),i=Ar||Ve;if(r.nodeType==3)if(i&&(ox.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=bt(ut(r,s,s),n);if(Ve&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=bt(ut(r,s-1,s-1),-1);if(c.top==a.top){let u=bt(ut(r,s,s+1),-1);if(u.top!=a.top)return qn(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,qn(bt(ut(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(n<0||s==Be(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return ei(a.getBoundingClientRect(),!1)}if(o==null&&s<Be(r)){let a=r.childNodes[s];if(a.nodeType==1)return ei(a.getBoundingClientRect(),!0)}return ei(r.getBoundingClientRect(),n>=0)}if(o==null&&s&&(n<0||s==Be(r))){let a=r.childNodes[s-1],c=a.nodeType==3?ut(a,Be(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return qn(bt(c,1),!1)}if(o==null&&s<Be(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?ut(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return qn(bt(c,-1),!0)}return qn(bt(r.nodeType==3?ut(r):r,-n),n>=0)}function qn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function ei(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function qd(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function ix(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return qd(t,e,()=>{let{node:o}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=Wd(t,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=ut(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&&(n=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const lx=/[\u0590-\u08ac]/;function ax(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,l=t.domSelection();return l?!lx.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:i:qd(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:m,focusOffset:g}=t.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 nc=null,rc=null,sc=!1;function cx(t,e,n){return nc==e&&rc==n?sc:(nc=e,rc=n,sc=n=="up"||n=="down"?ix(t,e,n):ax(t,e,n))}const He=0,oc=1,Ht=2,st=3;class Ir{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=He,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,i;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>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(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!n||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],o=r+s.size;if(r==e&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let 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,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],l=o+i.size;if(l>e||i instanceof Kd){s=e-o;break}o=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Ud&&o.side>=0;r--);if(n<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&n&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?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,n):{node:this.contentDOM,offset:o?ke(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,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&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,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>n||l==this.children.length-1)){n=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}n+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let o=Math.min(e,n),i=Math.max(e,n);for(let h=0,m=0;h<this.children.length;h++){let g=this.children[h],y=m+g.size;if(o>m&&i<y)return g.setSelection(e-m-g.border,n-m-g.border,r,s);m=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Ve||Ce)&&e==n){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(Ve&&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)&&tn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&tn(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&Ve)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){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,n){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?e<=i&&n>=r:e<i&&n>r){let l=r+o.border,a=i-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==i?Ht:oc,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=st:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ht:st}r=i}this.dirty=Ht}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ht:oc;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ud extends Ir{constructor(e,n,r,s){let o,i=n.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==He&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ux extends Ir{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class nn extends Ir{constructor(e,n,r,s,o){super(e,[],r,s),this.mark=n,this.spec=o}static create(e,n,r,s){let o=s.nodeViews[n.type.name],i=o&&o(n,s,r);return(!i||!i.dom)&&(i=on.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new nn(e,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&st||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=st&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=He){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=He}}slice(e,n,r){let s=nn.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;n<i&&(o=Ri(o,n,i,r)),e>0&&(o=Ri(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 jt extends Ir{constructor(e,n,r,s,o,i,l,a,c){super(e,[],o,i),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,o,i){let l=o.nodeViews[n.type.name],a,c=l&&l(n,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=on.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Yd(u,r,n),c?a=new dx(e,n,r,s,u,d||null,f,c,o,i+1):n.isText?new go(e,n,r,s,u,f,o):new jt(e,n,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 n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>A.empty)}return e}matchesNode(e,n,r){return this.dirty==He&&e.eq(this.node)&&fs(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,o=e.composing?this.localCompositionInfo(e,n):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new hx(this,i&&i.node,e);gx(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==Ht)&&(i&&this.protectLocalComposition(e,i),Jd(this.contentDOM,this.children,e),On&&yx(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof q)||r<n||s>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,l=xx(this.node.content,i,r-n,s-n);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new ux(this,o,n,s);e.input.compositionNodes.push(i),this.children=Ri(this.children,r,r+s.length,e,i)}update(e,n,r,s){return this.dirty==st||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=He}updateOuterDeco(e){if(fs(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Gd(this.dom,this.nodeDOM,ji(this.outerDeco,this.node,n),ji(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ic(t,e,n,r,s){Yd(r,e,t);let o=new jt(void 0,t,e,n,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class go extends jt{constructor(e,n,r,s,o,i,l){super(e,n,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,n,r,s){return this.dirty==st||this.dirty!=He&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=He||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=He,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),o=document.createTextNode(s.text);return new go(this.parent,s,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=st)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Kd extends Ir{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==He&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class dx extends jt{constructor(e,n,r,s,o,i,l,a,c,u){super(e,n,r,s,o,i,l,c,u),this.spec=a}update(e,n,r,s){if(this.dirty==st)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Jd(t,e,n){let r=t.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==t){for(;l!=r;)r=lc(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(i instanceof nn){let a=r?r.previousSibling:t.lastChild;Jd(i.contentDOM,i.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=lc(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const tr=function(t){t&&(this.nodeName=t)};tr.prototype=Object.create(null);const Wt=[new tr];function ji(t,e,n){if(t.length==0)return Wt;let r=n?Wt[0]:new tr,s=[r];for(let o=0;o<t.length;o++){let i=t[o].type.attrs;if(i){i.nodeName&&s.push(r=new tr(i.nodeName));for(let l in i){let a=i[l];a!=null&&(n&&s.length==1&&s.push(r=new tr(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 Gd(t,e,n,r){if(n==Wt&&r==Wt)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],l=n[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Wt[0]),s=a}fx(s,l||Wt[0],i)}return s}function fx(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&t.classList.add(s[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function Yd(t,e,n){return Gd(t,t,Wt,ji(e,n,t.nodeType!=1))}function fs(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function lc(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hx{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=px(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){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=He,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=nn.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,n,r))o=this.top.children.indexOf(i,this.index);else for(let 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,n,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,s,o){let i=this.top.children[s];return i.dirty==st&&i.dom==i.contentDOM&&(i.dirty=Ht),i.update(e,n,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof jt){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!=st&&fs(n,a.outerDeco));if(!f&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Ht,d.updateChildren(s,i+1),d.dirty=He),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,o,i){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!fs(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=jt.create(this.top,n,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,n,r,s,o){let i=jt.create(this.top,e,n,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new Ud(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof nn;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof go)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ce||ge)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Kd(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function px(t,e){let n=e,r=n.children.length,s=t.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof nn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function mx(t,e){return t.type.side-e.type.side}function gx(t,e,n,r){let s=e.locals(t),o=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(o,u),c),o+=u.nodeSize}return}let i=0,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(mx);for(let y=0;y<d.length;y++)n(d[y],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.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 yx(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function xx(t,e,n,r){for(let s=0,o=0;s<t.childCount&&o<=r;){let i=t.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<t.childCount;){let c=t.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=n){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>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ri(t,e,n,r,s){let o=[];for(let i=0,l=0;i<t.length;i++){let a=t[i],c=l,u=l+=a.size;c>=n||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),s&&(o.push(s),s=void 0),u>n&&o.push(a.slice(n-c,a.size,r)))}return o}function Tl(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),o=s&&s.size==0,i=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(mo(n)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&H.isSelectable(d)&&s.parent&&!(d.isInline&&qy(n.focusNode,n.focusOffset,s.dom))){let f=s.posBefore;c=new H(i==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,f=i;for(let h=0;h<n.rangeCount;h++){let m=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[a,i]=f==t.state.selection.anchor?[f,d]:[d,f],l=r.resolve(i)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!o?1:-1;c=Ml(t,u,l,d)}return c}function Xd(t){return t.editable?t.hasFocus():Zd(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function pt(t,e=!1){let n=t.state.selection;if(Qd(t,n),!!Xd(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ge){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&tn(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)kx(t);else{let{anchor:r,head:s}=n,o,i;ac&&!(n instanceof q)&&(n.$from.parent.inlineContent||(o=cc(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=cc(t,n.to))),t.docView.setSelection(r,s,t,e),ac&&(o&&uc(o),i&&uc(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&bx(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ac=Ce||ge&&_d<63;function cc(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(Ce&&s&&s.contentEditable=="false")return ti(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return ti(s);if(o)return ti(o)}}function ti(t){return t.contentEditable="true",Ce&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function uc(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function bx(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Xd(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function kx(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ke(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ie&&It<=11&&(n.disabled=!0,n.disabled=!1)}function Qd(t,e){if(e instanceof H){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(dc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else dc(t)}function dc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ml(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||q.between(e,n,r)}function fc(t){return t.editable&&!t.hasFocus()?!1:Zd(t)}function Zd(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function wx(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return tn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Di(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return o&&J.findFrom(o,e)}function wt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function hc(t,e,n){let r=t.state.selection;if(r instanceof q)if(n.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=t.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return wt(t,new q(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Di(t.state,e);return s&&s instanceof H?wt(t,s):!1}else if(!(ze&&n.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=t.docView.descAt(l))&&!i.contentDOM?H.isSelectable(o)?wt(t,new H(e<0?t.state.doc.resolve(s.pos-o.nodeSize):s)):Ar?wt(t,new q(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof H&&r.node.isInline)return wt(t,new q(e>0?r.$to:r.$from));{let s=Di(t.state,e);return s?wt(t,s):!1}}}function hs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function nr(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mn(t,e){return e<0?vx(t):Sx(t)}function vx(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,o,i=!1;for(Ve&&n.nodeType==1&&r<hs(n)&&nr(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(nr(l,-1))s=n,o=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(ef(n))break;{let l=n.previousSibling;for(;l&&nr(l,-1);)s=n.parentNode,o=ke(l),l=l.previousSibling;if(l)n=l,r=hs(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?Pi(t,n,r):s&&Pi(t,s,o)}function Sx(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=hs(n),o,i;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(nr(l,1))o=n,i=++r;else break}else{if(ef(n))break;{let l=n.nextSibling;for(;l&&nr(l,1);)o=l.parentNode,i=ke(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=hs(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}o&&Pi(t,o,i)}function ef(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Cx(t,e){for(;t&&e==t.childNodes.length&&!Or(t);)e=ke(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Nx(t,e){for(;t&&!e&&!Or(t);)e=ke(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Pi(t,e,n){if(e.nodeType!=3){let o,i;(i=Cx(e,n))?(e=i,n=0):(o=Nx(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(mo(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&pt(t)},50)}function pc(t,e){let n=t.state.doc.resolve(e);if(!(ge||zd)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function mc(t,e,n){let r=t.state.selection;if(r instanceof q&&!r.empty||n.indexOf("s")>-1||ze&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=Di(t.state,e);if(i&&i instanceof H)return wt(t,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof Le?J.near(i,e):J.findFrom(i,e);return l?wt(t,l):!1}return!1}function gc(t,e){if(!(t.state.selection instanceof q))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=t.state.tr;return e<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),t.dispatch(i),!0}return!1}function yc(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ex(t){if(!Ce||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;yc(t,r,"true"),setTimeout(()=>yc(t,r,"false"),20)}return!1}function Tx(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Mx(t,e){let n=e.keyCode,r=Tx(e);if(n==8||ze&&n==72&&r=="c")return gc(t,-1)||mn(t,-1);if(n==46&&!e.shiftKey||ze&&n==68&&r=="c")return gc(t,1)||mn(t,1);if(n==13||n==27)return!0;if(n==37||ze&&n==66&&r=="c"){let s=n==37?pc(t,t.state.selection.from)=="ltr"?-1:1:-1;return hc(t,s,r)||mn(t,s)}else if(n==39||ze&&n==70&&r=="c"){let s=n==39?pc(t,t.state.selection.from)=="ltr"?1:-1:1;return hc(t,s,r)||mn(t,s)}else{if(n==38||ze&&n==80&&r=="c")return mc(t,-1,r)||mn(t,-1);if(n==40||ze&&n==78&&r=="c")return Ex(t)||mc(t,1,r)||mn(t,1);if(r==(ze?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ol(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=t.someProp("clipboardSerializer")||on.fromSchema(t.state.schema),l=lf(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=of[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(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
|
32
|
+
|
|
33
|
+
`);return{dom:a,text:f,slice:e}}function tf(t,e,n,r,s){let o=s.parent.type.spec.code,i,l;if(!n&&!e)return null;let a=!!e&&(r||o||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,o||r,t)}),o)return l=new $(A.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
34
|
+
`))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",f=>f(e,s,r,t));if(d)l=d;else{let f=s.marks(),{schema:h}=t.state,m=on.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 t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=jx(n),Ar&&Rx(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=(t.someProp("clipboardParser")||t.someProp("domParser")||At.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Ox.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Dx(xc(l,+u[1],+u[2]),u[4]);else if(l=$.maxOpen(Ax(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=xc(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const Ox=/^(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 Ax(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),o,i=[];if(t.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&rf(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=sf(i[i.length-1],o.length));let u=nf(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return A.from(i)}return t}function nf(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,A.from(t));return t}function rf(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let o=rf(t,e,n,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(A.from(nf(n,t,s+1))))}}function sf(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,sf(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(A.empty,!0);return t.copy(n.append(r))}function Li(t,e,n,r,s,o){let i=e<0?t.firstChild:t.lastChild,l=i.content;return t.childCount>1&&(o=0),s<r-1&&(l=Li(l,e,n,r,s+1,o)),s>=n&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(A.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(l))}function xc(t,e,n){return e<t.openStart&&(t=new $(Li(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new $(Li(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const of={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 bc=null;function lf(){return bc||(bc=document.implementation.createHTMLDocument("title"))}let ni=null;function Ix(t){let e=window.trustedTypes;return e?(ni||(ni=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ni.createHTML(t)):t}function jx(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=lf().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&of[r[1].toLowerCase()])&&(t=s.map(o=>"<"+o+">").join("")+t+s.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=Ix(t),s)for(let o=0;o<s.length;o++)n=n.querySelector(s[o])||n;return n}function Rx(t){let e=t.querySelectorAll(ge?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Dx(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:o,openEnd:i}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=A.from(a.create(r[l+1],s)),o++,i++}return new $(s,o,i)}const Te={},Me={},Px={touchstart:!0,touchmove:!0};class Lx{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 $x(t){for(let e in Te){let n=Te[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{zx(t,r)&&!Al(t,r)&&(t.editable||!(r.type in Me))&&n(t,r)},Px[e]?{passive:!0}:void 0)}Ce&&t.dom.addEventListener("input",()=>null),$i(t)}function Mt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function _x(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function $i(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Al(t,r))})}function Al(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function zx(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Bx(t,e){!Al(t,e)&&Te[e.type]&&(t.editable||!(e.type in Me))&&Te[e.type](t,e)}Me.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!cf(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ft&&ge&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),On&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Vt(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Mx(t,n)?n.preventDefault():Mt(t,"key")};Me.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Me.keypress=(t,e)=>{let n=e;if(cf(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ze&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",i=>i(t,r.$from.pos,r.$to.pos,s,o))&&t.dispatch(o()),n.preventDefault()}};function yo(t){return{left:t.clientX,top:t.clientY}}function Fx(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Il(t,e,n,r,s){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(t.someProp(e,l=>i>o.depth?l(t,n,o.nodeAfter,o.before(i),s,!0):l(t,n,o.node(i),o.before(i),s,!1)))return!0;return!1}function Cn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Vx(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&H.isSelectable(r)?(Cn(t,new H(n)),!0):!1}function Hx(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof H&&(r=n.node);let o=t.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if(H.isSelectable(l)){r&&n.$from.depth>0&&i>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?s=o.before(n.$from.depth):s=o.before(i);break}}return s!=null?(Cn(t,H.create(t.state.doc,s)),!0):!1}function Wx(t,e,n,r,s){return Il(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(s?Hx(t,n):Vx(t,n))}function qx(t,e,n,r){return Il(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Ux(t,e,n,r){return Il(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Kx(t,n,r)}function Kx(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Cn(t,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)Cn(t,q.create(r,l+1,l+1+i.content.size));else if(H.isSelectable(i))Cn(t,H.create(r,l));else continue;return!0}}function jl(t){return ps(t)}const af=ze?"metaKey":"ctrlKey";Te.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=jl(t),s=Date.now(),o="singleClick";s-t.input.lastClick.time<500&&Fx(n,t.input.lastClick)&&!n[af]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:o,button:n.button};let i=t.posAtCoords(yo(n));i&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Jx(t,i,n,!!r)):(o=="doubleClick"?qx:Ux)(t,i.pos,i.inside,n)?n.preventDefault():Mt(t,"pointer"))};class Jx{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[af],this.allowDefault=r.shiftKey;let o,i;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),i=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,i=u.depth?u.before():0}const 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 H&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ve&&!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)),Mt(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(()=>pt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(yo(e))),this.updateAllowDefault(e),this.allowDefault||!n?Mt(this.view,"pointer"):Wx(this.view,n.pos,n.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(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Cn(this.view,J.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Mt(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)}}Te.touchstart=t=>{t.input.lastTouch=Date.now(),jl(t),Mt(t,"pointer")};Te.touchmove=t=>{t.input.lastTouch=Date.now(),Mt(t,"pointer")};Te.contextmenu=t=>jl(t);function cf(t,e){return t.composing?!0:Ce&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Gx=ft?5e3:-1;Me.compositionstart=Me.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof q&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ge&&zd&&Yx(t)))t.markCursor=t.state.storedMarks||n.marks(),ps(t,!0),t.markCursor=null;else if(ps(t,!e.selection.empty),Ve&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=t.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}t.input.composing=!0}uf(t,Gx)};function Yx(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Me.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,uf(t,20))};function uf(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ps(t),e))}function df(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Qx());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Xx(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Hy(e.focusNode,e.focusOffset),r=Wy(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let i=n.pmViewDesc;if(!(!i||!i.isText(n.nodeValue)))return r}}return n||r}function Qx(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ps(t,e=!1){if(!(ft&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),df(t),e||t.docView&&t.docView.dirty){let n=Tl(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Zx(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const mr=Ie&&It<15||On&&Jy<604;Te.copy=Me.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let o=mr?null:n.clipboardData,i=r.content(),{dom:l,text:a}=Ol(t,i);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Zx(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function eb(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function tb(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?gr(t,r.value,null,s,e):gr(t,r.textContent,r.innerHTML,s,e)},50)}function gr(t,e,n,r,s){let o=tf(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,o||$.empty)))return!0;if(!o)return!1;let i=eb(o),l=i?t.state.tr.replaceSelectionWith(i,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ff(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Me.paste=(t,e)=>{let n=e;if(t.composing&&!ft)return;let r=mr?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&gr(t,ff(r),r.getData("text/html"),s,n)?n.preventDefault():tb(t,n)};class hf{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const nb=ze?"altKey":"ctrlKey";function pf(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[nb]}Te.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,o=s.empty?null:t.posAtCoords(yo(n)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof H?s.to-1:s.to))){if(r&&r.mightDrag)i=H.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(i=H.create(t.state.doc,d.posBefore))}}let l=(i||t.state.selection).content(),{dom:a,text:c,slice:u}=Ol(t,l);(!n.dataTransfer.files.length||!ge||_d>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(mr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",mr||n.dataTransfer.setData("text/plain",c),t.dragging=new hf(u,pf(t,n),i)};Te.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Me.dragover=Me.dragenter=(t,e)=>e.preventDefault();Me.drop=(t,e)=>{try{rb(t,e,t.dragging)}finally{t.dragging=null}};function rb(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(yo(e));if(!r)return;let s=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",h=>{o=h(o,t,!1)}):o=tf(t,ff(e.dataTransfer),mr?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(n&&pf(t,e));if(t.someProp("handleDrop",h=>h(t,e,o||$.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?yd(t.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(i){let{node:h}=n;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&&H.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new H(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(Ml(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Te.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&pt(t)},20))};Te.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Te.beforeinput=(t,e)=>{if(ge&&ft&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Vt(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Me)Te[t]=Me[t];function yr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ms{constructor(e,n){this.toDOM=e,this.spec=n||Gt,this.side=this.spec.side||0}map(e,n,r,s){let{pos:o,deleted:i}=e.mapResult(n.from+s,this.side<0?-1:1);return i?null:new Se(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ms&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&yr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Rt{constructor(e,n){this.attrs=e,this.spec=n||Gt}map(e,n,r,s){let o=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new Se(o,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Rt&&yr(this.attrs,e.attrs)&&yr(this.spec,e.spec)}static is(e){return e.type instanceof Rt}destroy(){}}class Rl{constructor(e,n){this.attrs=e,this.spec=n||Gt}map(e,n,r,s){let o=e.mapResult(n.from+s,1);if(o.deleted)return null;let i=e.mapResult(n.to+s,-1);return i.deleted||i.pos<=o.pos?null:new Se(o.pos-r,i.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),o;return s==n.from&&!(o=e.child(r)).isText&&s+o.nodeSize==n.to}eq(e){return this==e||e instanceof Rl&&yr(this.attrs,e.attrs)&&yr(this.spec,e.spec)}destroy(){}}class Se{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Se(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Se(e,e,new ms(n,r))}static inline(e,n,r,s){return new Se(e,n,new Rt(r,s))}static node(e,n,r,s){return new Se(e,n,new Rl(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Rt}get widget(){return this.type instanceof ms}}const yn=[],Gt={};class se{constructor(e,n){this.local=e.length?e:yn,this.children=n.length?n:yn}static create(e,n){return n.length?gs(n,e,0,Gt):ve}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=n&&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]<n&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,n-l,r,s+l,o)}}map(e,n,r){return this==ve||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Gt)}mapInner(e,n,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(n,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?sb(this.children,i||[],e,n,r,s,o):i?new se(i.sort(Yt),yn):ve}add(e,n){return n.length?this==ve?se.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=gf(n,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,gs(u,l,c+1,Gt)),o+=3}});let i=mf(o?yf(n):n,-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(Yt):this.local,s||this.children)}remove(e){return e.length==0||this==ve?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,l=r[o]+n,a=r[o+1]+n;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!=ve?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,n)&&(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):ve}forChild(e,n){if(this==ve)return this;if(n.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+n.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 Rt){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(Yt),yn);return r?new Ct([l,r]):l}return r||ve}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 n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Dl(this.localsInner(e))}localsInner(e){if(this==ve)return yn;if(e.inlineContent||!this.local.some(Rt.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Rt||n.push(this.local[r]);return n}forEachSet(e){e(this)}}se.empty=new se([],[]);se.removeOverlap=Dl;const ve=se.empty;class Ct{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Gt));return Ct.from(r)}forChild(e,n){if(n.isLeaf)return se.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,n);o!=ve&&(o instanceof Ct?r=r.concat(o.members):r.push(o))}return Ct.from(r)}eq(e){if(!(e instanceof Ct)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let i=0;i<o.length;i++)n.push(o[i])}}return n?Dl(r?n:n.sort(Yt)):yn}static from(e){switch(e.length){case 0:return ve;case 1:return e[0];default:return new Ct(e.every(n=>n instanceof se)?e:e.reduce((n,r)=>n.concat(r instanceof se?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function sb(t,e,n,r,s,o,i){let l=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let d=0;n.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 k=l[x]+u-d;h>=k?l[x+1]=f<=k?-2:-1:f>=u&&y&&(l[x]+=y,l[x+1]+=y)}d+=y}),u=n.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=n.map(t[c]+o),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[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(n,y,u+1,t[c]+o+1,i);x!=ve?(l[c]=d,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ob(l,t,e,n,s,o,i),u=gs(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(Yt),l)}function mf(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Se(s.from+e,s.to+e,s.type))}return n}function ob(t,e,n,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?n.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<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+o+1);return n}function gf(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let o=0,i;o<t.length;o++)(i=t[o])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),t[o]=null);return s}function yf(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function gs(t,e,n,r){let s=[],o=!1;e.forEach((l,a)=>{let c=gf(t,l,a+n);if(c){o=!0;let u=gs(c,l,n+a+1,r);u!=ve&&s.push(a,a+l.nodeSize,u)}});let i=mf(o?yf(t):t,-n).sort(Yt);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):ve}function Yt(t,e){return t.from-e.from||t.to-e.to}function Dl(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[s]=o.copy(o.from,r.to),kc(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),kc(e,s,r.copy(o.from,r.to)));break}}}return e}function kc(t,e,n){for(;e<t.length&&Yt(n,t[e])>0;)e++;t.splice(e,0,n)}function ri(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ve&&e.push(r)}),t.cursorWrapper&&e.push(se.create(t.state.doc,[t.cursorWrapper.deco])),Ct.from(e)}const ib={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},lb=Ie&&It<=11;class ab{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 cb{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ab,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]);Ie&&It<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),lb&&(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,ib)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(fc(this.view)){if(this.suppressingSelectionUpdates)return pt(this.view);if(Ie&&It<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&tn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Mn(o))n.add(o);for(let o=e.anchorNode;o;o=Mn(o))if(n.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&fc(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[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(Ve&&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||fb(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&&mo(r)&&(c=Tl(e))&&c.eq(J.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,pt(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),ub(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||pt(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,o=e.nextSibling;if(Ie&&It<=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 wc=new WeakMap,vc=!1;function ub(t){if(!wc.has(t)&&(wc.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Ve,vc)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."),vc=!0}}function Sc(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=t.domAtPos(t.state.selection.anchor);return tn(i.node,i.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function db(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Sc(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Sc(t,n):null}function fb(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function hb(t,e,n){let{node:r,fromOffset:s,toOffset:o,from:i,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],mo(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ge&&t.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=t.state.doc,f=t.someProp("domParser")||At.fromSchema(t.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:pb,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 pb(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ce&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Ce&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const mb=/^(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 gb(t,e,n,r,s){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let v=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=Tl(t,v);if(M&&!t.state.selection.eq(M)){if(ge&&ft&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",O=>O(t,Vt(13,"Enter"))))return;let E=t.state.tr.setSelection(M);v=="pointer"?E.setMeta("pointer",!0):v=="key"&&E.scrollIntoView(),o&&E.setMeta("composition",o),t.dispatch(E)}return}let i=t.state.doc.resolve(e),l=i.sharedDepth(n);e=i.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=hb(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let m=bb(d.content,c.doc.content,c.from,f,h);if(m&&t.input.domChangeCount++,(On&&t.input.lastIOSEnter>Date.now()-225||ft)&&s.some(v=>v.nodeType==1&&!mb.test(v.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",v=>v(t,Vt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&a instanceof q&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let v=Cc(t,t.state.doc,c.sel);if(v&&!v.eq(t.state.selection)){let M=t.state.tr.setSelection(v);o&&M.setMeta("composition",o),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof q&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Ie&&It<=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((On&&t.input.lastIOSEnter>Date.now()-225&&(!b||s.some(v=>v.nodeName=="DIV"||v.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,"","")))&&t.someProp("handleKeyDown",v=>v(t,Vt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&xb(u,m.start,m.endA,g,y)&&t.someProp("handleKeyDown",v=>v(t,Vt(8,"Backspace")))){ft&&ge&&t.domObserver.suppressSelectionUpdates();return}ge&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),ft&&!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(()=>{t.someProp("handleKeyDown",function(v){return v(t,Vt(13,"Enter"))})},20));let k=m.start,S=m.endA,w=v=>{let M=v||t.state.tr.replace(k,S,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let E=Cc(t,M.doc,c.sel);E&&!(ge&&t.composing&&E.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(E.head==k||E.head==M.mapping.map(S)-1)||Ie&&E.empty&&E.head==k)&&M.setSelection(E)}return o&&M.setMeta("composition",o),M.scrollIntoView()},C;if(b)if(g.pos==y.pos){Ie&&It<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>pt(t),20));let v=w(t.state.tr.delete(k,S)),M=u.resolve(m.start).marksAcross(u.resolve(m.endA));M&&v.ensureMarks(M),t.dispatch(v)}else if(m.endA==m.endB&&(C=yb(g.parent.content.cut(g.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let v=w(t.state.tr);C.type=="add"?v.addMark(k,S,C.mark):v.removeMark(k,S,C.mark),t.dispatch(v)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let v=g.parent.textBetween(g.parentOffset,y.parentOffset),M=()=>w(t.state.tr.insertText(v,k,S));t.someProp("handleTextInput",E=>E(t,k,S,v,M))||t.dispatch(M())}else t.dispatch(w());else t.dispatch(w())}function Cc(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ml(t,e.resolve(n.anchor),e.resolve(n.head))}function yb(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,o=r,i,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(s.length==1&&o.length==0)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(A.from(c).eq(t))return{mark:l,type:i}}function xb(t,e,n,r,s){if(n-e<=s.pos-r.pos||si(r,!0,!1)<s.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&n==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=t.resolve(si(o,!0,!0));return!i.parent.isTextblock||i.pos>n||si(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function si(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function bb(t,e,n,r,s){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:i,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));r-=i+a-o}if(i<o&&t.size<e.size){let a=r<=o&&r>=i?o-r:0;o-=a,o&&o<e.size&&Nc(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<t.size&&Nc(t.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function Nc(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class xf{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Lx,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Ac),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=Mc(this),Tc(this),this.nodeViews=Oc(this),this.docView=ic(this.state.doc,Ec(this),ri(this),this.dom,this),this.domObserver=new cb(this,(r,s,o,i)=>gb(this,r,s,o,i)),this.domObserver.start(),$x(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&$i(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ac),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(df(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Oc(this);wb(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&$i(this),this.editable=Mc(this),Tc(this);let a=ri(this),c=Ec(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&&Xy(this);if(i){this.domObserver.stop();let h=d&&(Ie||ge)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&kb(s.selection,e.selection);if(d){let m=ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Xx(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ic(e.doc,c,a,this.dom,this)),m&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&wx(this))?pt(this,h):(Qd(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",n=>n(this)))if(this.state.selection instanceof H){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&ec(this,n.getBoundingClientRect(),e)}else ec(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new hf(e.slice,e.move,s<0?void 0:H.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=n?n(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=n?n(l):l))return s}}hasFocus(){if(Ie){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&&Zy(this.dom),pt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return sx(this,e)}coordsAtPos(e,n=1){return Wd(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return cx(this,n||this.state,e)}pasteHTML(e,n){return gr(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return gr(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ol(this,e)}destroy(){this.docView&&(_x(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ri(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Fy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Bx(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ce&&this.root.nodeType===11&&Uy(this.dom.ownerDocument)==this.dom&&db(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}xf.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Ec(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Se.node(0,t.state.doc.content.size,e)]}function Tc(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Se.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Mc(t){return!t.someProp("editable",e=>e(t.state)===!1)}function kb(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Oc(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function wb(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function Ac(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Dt={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:"'"},ys={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},vb=typeof navigator<"u"&&/Mac/.test(navigator.platform),Sb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var we=0;we<10;we++)Dt[48+we]=Dt[96+we]=String(we);for(var we=1;we<=24;we++)Dt[we+111]="F"+we;for(var we=65;we<=90;we++)Dt[we]=String.fromCharCode(we+32),ys[we]=String.fromCharCode(we);for(var oi in Dt)ys.hasOwnProperty(oi)||(ys[oi]=Dt[oi]);function Cb(t){var e=vb&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Sb&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ys:Dt)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Nb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Eb=typeof navigator<"u"&&/Win/.test(navigator.platform);function Tb(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");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))Nb?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),i&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Mb(t){let e=Object.create(null);for(let n in t)e[Tb(n)]=t[n];return e}function ii(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Ob(t){return new ie({props:{handleKeyDown:bf(t)}})}function bf(t){let e=Mb(t);return function(n,r){let s=Cb(r),o,i=e[ii(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[ii(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Eb&&r.ctrlKey&&r.altKey)&&(o=Dt[r.keyCode])&&o!=s){let l=e[ii(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Ab=Object.defineProperty,Pl=(t,e)=>{for(var n in e)Ab(t,n,{get:e[n],enumerable:!0})};function xo(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,o=n.storedMarks,n}}}var bo=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(t).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(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:o}=r,i=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(a),i.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).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(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.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(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:o}=r,i={tr:t,editor:r,view:o,state:xo({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(i)]))}};return i}},kf={};Pl(kf,{blur:()=>Ib,clearContent:()=>jb,clearNodes:()=>Rb,command:()=>Db,createParagraphNear:()=>Pb,cut:()=>Lb,deleteCurrentNode:()=>$b,deleteNode:()=>_b,deleteRange:()=>zb,deleteSelection:()=>Bb,enter:()=>Fb,exitCode:()=>Vb,extendMarkRange:()=>Hb,first:()=>Wb,focus:()=>qb,forEach:()=>Ub,insertContent:()=>Kb,insertContentAt:()=>Yb,joinBackward:()=>Zb,joinDown:()=>Qb,joinForward:()=>ek,joinItemBackward:()=>tk,joinItemForward:()=>nk,joinTextblockBackward:()=>rk,joinTextblockForward:()=>sk,joinUp:()=>Xb,keyboardShortcut:()=>ik,lift:()=>lk,liftEmptyBlock:()=>ak,liftListItem:()=>ck,newlineInCode:()=>uk,resetAttributes:()=>dk,scrollIntoView:()=>fk,selectAll:()=>hk,selectNodeBackward:()=>pk,selectNodeForward:()=>mk,selectParentNode:()=>gk,selectTextblockEnd:()=>yk,selectTextblockStart:()=>xk,setContent:()=>bk,setMark:()=>zk,setMeta:()=>Bk,setNode:()=>Fk,setNodeSelection:()=>Vk,setTextDirection:()=>Hk,setTextSelection:()=>Wk,sinkListItem:()=>qk,splitBlock:()=>Uk,splitListItem:()=>Kk,toggleList:()=>Jk,toggleMark:()=>Gk,toggleNode:()=>Yk,toggleWrap:()=>Xk,undoInputRule:()=>Qk,unsetAllMarks:()=>Zk,unsetMark:()=>ew,unsetTextDirection:()=>tw,updateAttributes:()=>nw,wrapIn:()=>rw,wrapInList:()=>sw});var Ib=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),jb=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Rb=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:o,$to:i})=>{t.doc.nodesBetween(o.pos,i.pos,(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=Fn(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},Db=t=>e=>t(e),Pb=()=>({state:t,dispatch:e})=>Rd(t,e),Lb=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,o=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new q(r.doc.resolve(Math.max(i-1,0)))),!0},$b=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(e){const l=s.before(o),a=s.after(o);t.delete(l,a).scrollIntoView()}return!0}return!1};function pe(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var _b=t=>({tr:e,state:n,dispatch:r})=>{const s=pe(t,n.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const a=o.before(i),c=o.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},zb=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},Bb=()=>({state:t,dispatch:e})=>wl(t,e),Fb=()=>({commands:t})=>t.keyboardShortcut("Enter"),Vb=()=>({state:t,dispatch:e})=>Ey(t,e);function Ll(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function xs(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Ll(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function wf(t,e,n={}){return t.find(r=>r.type===e&&xs(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function Ic(t,e,n={}){return!!wf(t,e,n)}function $l(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!wf([...s.node.marks],e,n)))return;let i=s.index,l=t.start()+s.offset,a=i+1,c=l+s.node.nodeSize;for(;i>0&&Ic([...t.parent.child(i-1).marks],e,n);)i-=1,l-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&Ic([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function gt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var Hb=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const o=gt(t,r.schema),{doc:i,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){const d=$l(a,o,e);if(d&&d.from<=c&&d.to>=u){const f=q.create(i,d.from,d.to);n.setSelection(f)}}return!0},Wb=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function vf(t){return t instanceof q}function qt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Sf(t,e=null){if(!e)return null;const n=J.atStart(t),r=J.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,o=r.to;return e==="all"?q.create(t,qt(0,s,o),qt(t.content.size,s,o)):q.create(t,qt(e,s,o),qt(e,s,o))}function Cf(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function ko(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var qb=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(ko()||Cf())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!vf(n.state.selection))return i(),!0;const l=Sf(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return o&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},Ub=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),Kb=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Nf=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Nf(r)}return t};function Fr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Nf(n)}function xr(t,e,n){if(t instanceof Fe||t instanceof A)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return A.fromArray(t.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),xr("",e,n)}if(s){if(n.errorOnInvalidContent){let i=!1,l="";const a=new id({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(n.slice?At.fromSchema(a).parseSlice(Fr(t),n.parseOptions):At.fromSchema(a).parse(Fr(t),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=At.fromSchema(e);return n.slice?o.parseSlice(Fr(t),n.parseOptions).content:o.parse(Fr(t),n.parseOptions)}return xr("",e,n)}function Jb(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof me||s instanceof ye))return;const o=t.mapping.maps[r];let i=0;o.forEach((l,a,c,u)=>{i===0&&(i=u)}),t.setSelection(J.near(t.doc.resolve(i),n))}var Gb=t=>!("type"in t),Yb=(t,e,n)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};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",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{xr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=xr(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=n.errorOnInvalidContent)!=null?i:o.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((Gb(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 A){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,k=x.isText||x.isTextblock,S=x.content.size>0;b&&k&&S&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&Jb(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},Xb=()=>({state:t,dispatch:e})=>Sy(t,e),Qb=()=>({state:t,dispatch:e})=>Cy(t,e),Zb=()=>({state:t,dispatch:e})=>Ed(t,e),ek=()=>({state:t,dispatch:e})=>Ad(t,e),tk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=fo(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},nk=()=>({state:t,dispatch:e,tr:n})=>{try{const r=fo(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},rk=()=>({state:t,dispatch:e})=>wy(t,e),sk=()=>({state:t,dispatch:e})=>vy(t,e);function Ef(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ok(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");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))ko()||Ef()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}var ik=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const o=ok(t).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(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function Pt(t,e,n={}){const{from:r,to:s,empty:o}=t.selection,i=e?pe(e,t.schema):null,l=[];t.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=>xs(d.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}var lk=(t,e={})=>({state:n,dispatch:r})=>{const s=pe(t,n.schema);return Pt(n,s,e)?Ny(n,r):!1},ak=()=>({state:t,dispatch:e})=>Dd(t,e),ck=t=>({state:e,dispatch:n})=>{const r=pe(t,e.schema);return $y(r)(e,n)},uk=()=>({state:t,dispatch:e})=>jd(t,e);function wo(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function jc(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var dk=(t,e)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const l=wo(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(o=pe(t,r.schema)),l==="mark"&&(i=gt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{o&&o===u.type&&(a=!0,s&&n.setNodeMarkup(d,void 0,jc(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(f=>{i===f.type&&(a=!0,s&&n.addMark(d,d+u.nodeSize,i.create(jc(f.attrs,e))))})})}),a},fk=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),hk=()=>({tr:t,dispatch:e})=>{if(e){const n=new Le(t.doc);t.setSelection(n)}return!0},pk=()=>({state:t,dispatch:e})=>Md(t,e),mk=()=>({state:t,dispatch:e})=>Id(t,e),gk=()=>({state:t,dispatch:e})=>Oy(t,e),yk=()=>({state:t,dispatch:e})=>jy(t,e),xk=()=>({state:t,dispatch:e})=>Iy(t,e);function _i(t,e,n={},r={}){return xr(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var bk=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=_i(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return i&&o.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return i&&o.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Tf(t,e){const n=gt(e,t.schema),{from:r,to:s,empty:o}=t.selection,i=[];o?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Mf(t,e){const n=new vd(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function kk(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function wk(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,o)=>{n(s)&&r.push({node:s,pos:o})}),r}function vk(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function vo(t){return e=>vk(e.$from,t)}function V(t,e,n){return t.config[e]===void 0&&t.parent?V(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?V(t.parent,e,n):null}):t.config[e]}function _l(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=V(e,"addExtensions",n);return r?[e,..._l(r())]:e}).flat(10)}function zl(t,e){const n=on.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Of(t){return typeof t=="function"}function te(t,e=void 0,...n){return Of(t)?e?t.bind(e)(...n):t(...n):t}function Sk(t={}){return Object.keys(t).length===0&&t.constructor===Object}function An(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Af(t){const e=[],{nodeExtensions:n,markExtensions:r}=An(t),s=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.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(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).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 br(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>oe(n,r),{})}function Ck(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Rc(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(n):Ck(n.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function Dc(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Sk(n)?!1:n!=null))}function Pc(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function Nk(t,e){var n;const r=Af(t),{nodeExtensions:s,markExtensions:o}=An(t),i=(n=s.find(c=>V(c,"topNode")))==null?void 0:n.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=t.reduce((x,b)=>{const k=V(b,"extendNodeSchema",d);return{...x,...k?k(c):{}}},{}),h=Dc({...f,content:te(V(c,"content",d)),marks:te(V(c,"marks",d)),group:te(V(c,"group",d)),inline:te(V(c,"inline",d)),atom:te(V(c,"atom",d)),selectable:te(V(c,"selectable",d)),draggable:te(V(c,"draggable",d)),code:te(V(c,"code",d)),whitespace:te(V(c,"whitespace",d)),linebreakReplacement:te(V(c,"linebreakReplacement",d)),defining:te(V(c,"defining",d)),isolating:te(V(c,"isolating",d)),attrs:Object.fromEntries(u.map(Pc))}),m=te(V(c,"parseHTML",d));m&&(h.parseDOM=m.map(x=>Rc(x,u)));const g=V(c,"renderHTML",d);g&&(h.toDOM=x=>g({node:x,HTMLAttributes:br(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=t.reduce((y,x)=>{const b=V(x,"extendMarkSchema",d);return{...y,...b?b(c):{}}},{}),h=Dc({...f,inclusive:te(V(c,"inclusive",d)),excludes:te(V(c,"excludes",d)),group:te(V(c,"group",d)),spanning:te(V(c,"spanning",d)),code:te(V(c,"code",d)),attrs:Object.fromEntries(u.map(Pc))}),m=te(V(c,"parseHTML",d));m&&(h.parseDOM=m.map(y=>Rc(y,u)));const g=V(c,"renderHTML",d);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:br(y,u)})),[c.name,h]}));return new id({topNode:i,nodes:l,marks:a})}function Ek(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function bs(t){return t.sort((n,r)=>{const s=V(n,"priority")||100,o=V(r,"priority")||100;return s>o?-1:s<o?1:0})}function If(t){const e=bs(_l(t)),n=Ek(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function jf(t,e,n){const{from:r,to:s}=e,{blockSeparator:o=`
|
|
35
|
+
|
|
36
|
+
`,textSerializers:i={}}=n||{};let l="";return t.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 Tk(t,e){const n={from:0,to:t.content.size};return jf(t,n,e)}function Rf(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Mk(t,e){const n=pe(e,t.schema),{from:r,to:s}=t.selection,o=[];t.doc.nodesBetween(r,s,l=>{o.push(l)});const i=o.reverse().find(l=>l.type.name===n.name);return i?{...i.attrs}:{}}function Df(t,e){const n=wo(typeof e=="string"?e:e.name,t.schema);return n==="node"?Mk(t,e):n==="mark"?Tf(t,e):{}}function Ok(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function Ak(t){const e=Ok(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function Pf(t){const{mapping:e,steps:n}=t,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}=n[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}})})}),Ak(r)}function Bl(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const o=n.resolve(t),i=$l(o,s.type);i&&r.push({mark:s,...i})}):n.nodesBetween(t,e,(s,o)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}var Ik=(t,e,n,r=20)=>{const s=t.doc.resolve(n);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 Vr(t,e){return e.nodes[t]||e.marks[t]||null}function Zr(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}var jk=(t,e=500)=>{let n="";const r=t.parentOffset;return t.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%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-o))}),n};function zi(t,e,n={}){const{empty:r,ranges:s}=t.selection,o=e?gt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>xs(d.attrs,n,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:d,$to:f})=>{const h=d.pos,m=f.pos;t.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),k=b-x;i+=k,l.push(...g.marks.map(S=>({mark:S,from:x,to:b})))})}),i===0)return!1;const a=l.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>xs(d.mark.attrs,n,{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 Rk(t,e,n={}){if(!e)return Pt(t,null,n)||zi(t,null,n);const r=wo(e,t.schema);return r==="node"?Pt(t,e,n):r==="mark"?zi(t,e,n):!1}var Dk=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const o=vo(l=>l.type.name===e)(t.selection);if(!o)return!1;const i=t.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Pk=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Lc(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function $c(t,e){const{nodeExtensions:n}=An(e),r=n.find(i=>i.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=te(V(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function So(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(o=>{s!==!1&&(So(o,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Lf(t){return t instanceof H}var $f=class _f{constructor(e){this.position=e}static fromJSON(e){return new _f(e.position)}toJSON(){return{position:this.position}}};function Lk(t,e){const n=e.mapping.mapResult(t.position);return{position:new $f(n.pos),mapResult:n}}function $k(t){return new $f(t)}function _k(t,e,n){var r;const{selection:s}=e;let o=null;if(vf(s)&&(o=s.$cursor),o){const l=(r=t.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:i}=s;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(n),m=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=h&&m}return!c}),c})}var zk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=n,{empty:i,ranges:l}=o,a=gt(t,r.schema);if(s)if(i){const c=Tf(r,a);n.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&&n.addMark(m,g,a.create({...x.attrs,...e}))}):n.addMark(m,g,a.create(e))})});return _k(r,n,a)},Bk=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Fk=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const o=pe(t,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:l})=>Xa(o,{...i,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Xa(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Vk=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=qt(t,0,r.content.size),o=H.create(r,s);e.setSelection(o)}return!0},Hk=(t,e)=>({tr:n,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&&n.doc.nodesBetween(i,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},Wk=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:o}=typeof t=="number"?{from:t,to:t}:t,i=q.atStart(r).from,l=q.atEnd(r).to,a=qt(s,i,l),c=qt(o,i,l),u=q.create(r,a,c);e.setSelection(u)}return!0},qk=t=>({state:e,dispatch:n})=>{const r=pe(t,e.schema);return By(r)(e,n)};function _c(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var Uk=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:l,$to:a}=o,c=s.extensionManager.attributes,u=Zr(c,l.node().type.name,l.node().attrs);if(o instanceof H&&o.node.isBlock)return!l.parentOffset||!ht(i,l.pos)?!1:(r&&(t&&_c(n,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:kk(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,m=ht(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!m&&ht(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)}t&&_c(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},Kk=(t,e={})=>({tr:n,state:r,dispatch:s,editor:o})=>{var i;const l=pe(t,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=A.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=A.from(a.node(M).copy(x));const k=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,S={...Zr(f,a.node().type.name,a.node().attrs),...e},w=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(S))||void 0;x=x.append(A.from(l.createAndFill(null,w)||void 0));const C=a.before(a.depth-(b-1));n.replace(C,a.after(-k),new $(x,4-b,0));let v=-1;n.doc.nodesBetween(C,n.doc.content.size,(M,E)=>{if(v>-1)return!1;M.isTextblock&&M.content.size===0&&(v=E+1)}),v>-1&&n.setSelection(q.near(n.doc.resolve(v))),n.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,m={...Zr(f,d.type.name,d.attrs),...e},g={...Zr(f,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=h?[{type:l,attrs:m},{type:h,attrs:g}]:[{type:l,attrs:m}];if(!ht(n.doc,a.pos,2))return!1;if(s){const{selection:x,storedMarks:b}=r,{splittableMarks:k}=o.extensionManager,S=b||x.$to.parentOffset&&x.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!S||!s)return!0;const w=S.filter(C=>k.includes(C.type.name));n.ensureMarks(w)}return!0},li=(t,e)=>{const n=vo(i=>i.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&zt(t.doc,n.pos)&&t.join(n.pos),!0},ai=(t,e)=>{const n=vo(i=>i.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&zt(t.doc,r)&&t.join(r),!0},Jk=(t,e,n,r={})=>({editor:s,tr:o,state:i,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=s.extensionManager,h=pe(t,i.schema),m=pe(e,i.schema),{selection:g,storedMarks:y}=i,{$from:x,$to:b}=g,k=x.blockRange(b),S=y||g.$to.parentOffset&&g.$from.marks();if(!k)return!1;const w=vo(C=>$c(C.type.name,d))(g);if(k.depth>=1&&w&&k.depth-w.depth<=1){if(w.node.type===h)return c.liftListItem(m);if($c(w.node.type.name,d)&&h.validContent(w.node.content)&&l)return a().command(()=>(o.setNodeMarkup(w.pos,h),!0)).command(()=>li(o,h)).command(()=>ai(o,h)).run()}return!n||!S||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>li(o,h)).command(()=>ai(o,h)).run():a().command(()=>{const C=u().wrapInList(h,r),v=S.filter(M=>f.includes(M.type.name));return o.ensureMarks(v),C?!0:c.clearNodes()}).wrapInList(h,r).command(()=>li(o,h)).command(()=>ai(o,h)).run()},Gk=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=n,i=gt(t,r.schema);return zi(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},Yk=(t,e,n={})=>({state:r,commands:s})=>{const o=pe(t,r.schema),i=pe(e,r.schema),l=Pt(r,o,n);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,...n})},Xk=(t,e={})=>({state:n,commands:r})=>{const s=pe(t,n.schema);return Pt(n,s,e)?r.lift(s):r.wrapIn(s,e)},Qk=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let o;if(s.spec.isInputRules&&(o=s.getState(t))){if(e){const i=t.tr,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,t.schema.text(o.text,a))}else i.delete(o.from,o.to)}return!0}}return!1},Zk=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},ew=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=n,a=gt(t,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=$l(c,a,m);g&&(f=g.from,h=g.to),n.removeMark(f,h,a)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},tw=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let o,i;return typeof t=="number"?(o=t,i=t):t&&"from"in t&&"to"in t?(o=t.from,i=t.to):(o=s.from,i=s.to),r&&e.doc.nodesBetween(o,i,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},nw=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const l=wo(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(o=pe(t,r.schema)),l==="mark"&&(i=gt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let f,h,m,g;n.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&&n.setNodeMarkup(x,void 0,{...y.attrs,...e})),i&&y.marks.length&&y.marks.forEach(b=>{if(i===b.type&&(a=!0,s)){const k=Math.max(x,u),S=Math.min(x+y.nodeSize,d);n.addMark(k,S,i.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&s&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(y=>{i===y.type&&s&&n.addMark(m,g,i.create({...y.attrs,...e}))}))}),a},rw=(t,e={})=>({state:n,dispatch:r})=>{const s=pe(t,n.schema);return Ry(s,e)(n,r)},sw=(t,e={})=>({state:n,dispatch:r})=>{const s=pe(t,n.schema);return Dy(s,e)(n,r)},ow=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Co=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},iw=(t,e)=>{if(Ll(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Hr(t){var e;const{editor:n,from:r,to:s,text:o,rules:i,plugin:l}=t,{view:a}=n;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=jk(c)+o;return i.forEach(f=>{if(u)return;const h=iw(d,f.find);if(!h)return;const m=a.state.tr,g=xo({state:a.state,transaction:m}),y={from:r-(h[0].length-o.length),to:s},{commands:x,chain:b,can:k}=new bo({editor:n,state:g});f.handler({state:g,range:y,match:h,commands:x,chain:b,can:k})===null||!m.steps.length||(f.undoable&&m.setMeta(l,{transform:m,from:r,to:s,text:o}),a.dispatch(m),u=!0)}),u}function lw(t){const{editor:e,rules:n}=t,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=zl(A.from(u),i.schema);const{from:d}=a,f=d+u.length;Hr({editor:e,from:d,to:f,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,l){return Hr({editor:e,from:o,to:i,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&Hr({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?Hr({editor:e,from:i.pos,to:i.pos,text:`
|
|
37
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function aw(t){return Object.prototype.toString.call(t).slice(8,-1)}function Wr(t){return aw(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function zf(t,e){const n={...t};return Wr(t)&&Wr(e)&&Object.keys(e).forEach(r=>{Wr(e[r])&&Wr(t[r])?n[r]=zf(t[r],e[r]):n[r]=e[r]}),n}var Fl=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...te(V(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...te(V(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>zf(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},ln=class Bf extends Fl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Bf(n)}static handleExit({editor:e,mark:n}){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===n.name))return!1;const a=i.find(c=>c?.type.name===n.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 n=typeof e=="function"?e():e;return super.extend(n)}};function cw(t){return typeof t=="number"}var uw=class{constructor(t){this.find=t.find,this.handler=t.handler}},dw=(t,e,n)=>{if(Ll(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=t,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function fw(t){const{editor:e,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=t,{commands:a,chain:c,can:u}=new bo({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(h,m)=>{var g,y,x,b,k;if((y=(g=h.type)==null?void 0:g.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const S=(k=(b=(x=h.content)==null?void 0:x.size)!=null?b:h.nodeSize)!=null?k:0,w=Math.max(r,m),C=Math.min(s,m+S);if(w>=C)return;const v=h.isText?h.text||"":h.textBetween(w-m,C-m,void 0,"");dw(v,o.find,i).forEach(E=>{if(E.index===void 0)return;const O=w+E.index+1,R=O+E[0].length,L={from:n.tr.mapping.map(O),to:n.tr.mapping.map(R)},B=o.handler({state:n,range:L,match:E,commands:a,chain:c,can:u,pasteEvent:i,dropEvent:l});d.push(B)})}),d.every(h=>h!==null)}var qr=null,hw=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function pw(t){const{editor:e,rules:n}=t;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=xo({state:u,transaction:g});if(!(!fw({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 n.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&&(qr=e)},h=()=>{qr&&(qr=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=qr;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:w}=x;typeof w=="string"?w=w:w=zl(A.from(w),h.schema);const{from:C}=x,v=C+w.length,M=hw(w);return a({rule:u,state:h,from:C,to:{b:v},pasteEvt:M})}const k=f.doc.content.findDiffStart(h.doc.content),S=f.doc.content.findDiffEnd(h.doc.content);if(!(!cw(k)||!S||k===S.b))return a({rule:u,state:h,from:k,to:S,pasteEvt:i})}}))}var No=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=If(t),this.schema=Nk(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Vr(e.name,this.schema)},r=V(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return bs([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Vr(r.name,this.schema)},o=[],i=V(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&V(r,"exitable",s)&&(l.ArrowRight=()=>ln.handleExit({editor:t,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,m])=>[h,()=>m({editor:t})]));l={...l,...f}}const a=Ob(l);o.push(a);const c=V(r,"addInputRules",s);if(Lc(r,t.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=lw({editor:t,rules:f}),m=Array.isArray(h)?h:[h];o.push(...m)}}const u=V(r,"addPasteRules",s);if(Lc(r,t.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=pw({editor:t,rules:f});o.push(...h)}}const d=V(r,"addProseMirrorPlugins",s);if(d){const f=d();o.push(...f)}return o})}get attributes(){return Af(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=An(this.extensions);return Object.fromEntries(e.filter(n=>!!V(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pe(n.name,this.schema)},o=V(n,"addNodeView",s);if(!o)return[];const i=o();if(!i)return[];const l=(a,c,u,d,f)=>{const h=br(a,r);return i({node:a,view:c,getPos:u,decorations:d,innerDecorations:f,editor:t,extension:n,HTMLAttributes:h})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return bs([...this.extensions].reverse()).reduceRight((r,s)=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Vr(s.name,this.schema)},i=V(s,"dispatchTransaction",o);return i?l=>{i.call(o,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=An(this.extensions);return Object.fromEntries(e.filter(n=>!!V(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:gt(n.name,this.schema)},o=V(n,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const u=br(l,r);return o()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{Mw(l,t,d)}})};return[n.name,i]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Vr(e.name,this.schema)};e.type==="mark"&&((n=te(V(e,"keepOnSplit",r)))==null||n)&&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)})}};No.resolve=If;No.sort=bs;No.flatten=_l;var mw={};Pl(mw,{ClipboardTextSerializer:()=>Vf,Commands:()=>Hf,Delete:()=>Wf,Drop:()=>qf,Editable:()=>Uf,FocusEvents:()=>Jf,Keymap:()=>Gf,Paste:()=>Yf,Tabindex:()=>Xf,TextDirection:()=>Qf,focusEventsPluginKey:()=>Kf});var fe=class Ff extends Fl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Ff(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Vf=fe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ie({key:new de("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{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=Rf(n);return jf(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Hf=fe.create({name:"commands",addCommands(){return{...kf}}}),Wf=fe.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,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,t))!=null?c:t.getMeta("y-sync$"))return;const u=Mf(t.before,[t,...e]);Pf(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:t,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((h,m)=>{var g,y;if(h instanceof Qe){const x=f.slice(m).map(h.from,-1),b=f.slice(m).map(h.to),k=f.invert().map(x,-1),S=f.invert().map(b),w=(g=u.doc.nodeAt(x-1))==null?void 0:g.marks.some(v=>v.eq(h.mark)),C=(y=u.doc.nodeAt(b))==null?void 0:y.marks.some(v=>v.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:k,to:S},newRange:{from:x,to:b},partial:!!(C||w),editor:this.editor,transaction:t,combinedTransform:u})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(o,0):o()}}),qf=fe.create({name:"drop",addProseMirrorPlugins(){return[new ie({key:new de("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Uf=fe.create({name:"editable",addProseMirrorPlugins(){return[new ie({key:new de("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Kf=new de("focusEvents"),Jf=fe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ie({key:Kf,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Gf=fe.create({name:"keymap",addKeyboardShortcuts(){const t=()=>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:J.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!x||x&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ko()||Ef()?o:s},addProseMirrorPlugins(){return[new ie({key:new de("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:l}=e.selection,a=J.atStart(e.doc).from,c=J.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!So(n.doc))return;const f=n.tr,h=xo({state:n,transaction:f}),{commands:m}=new bo({editor:this.editor,state:h});if(m.clearNodes(),!!f.steps.length)return f}})]}}),Yf=fe.create({name:"paste",addProseMirrorPlugins(){return[new ie({key:new de("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Xf=fe.create({name:"tabindex",addProseMirrorPlugins(){return[new ie({key:new de("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Qf=fe.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=An(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ie({key:new de("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),gw=class xn{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get 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 n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new xn(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new xn(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 xn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,i=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 xn(l,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),e.push(new xn(l,this.editor,s,s?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const o=s.node.attrs,i=Object.keys(n);for(let l=0;l<i.length;l+=1){const a=i[l];if(o[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(n);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>n[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},yw=`.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 xw(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var bw=class extends ow{constructor(t={}){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,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Lk,createMappablePosition:$k},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event: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(),n=Sf(e,this.options.autofocus);this.editorState=vn.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=xw(yw,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Of(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;n=n.filter(i=>!i.key.startsWith(o))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Uf,Vf.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Hf,Jf,Gf,Xf,qf,Yf,Wf,Qf.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 No(r,this)}createCommandManager(){this.commandManager=new bo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=_i(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(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=_i(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new xf(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.prependClass(),this.injectCSS();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),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}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Df(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Rk(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return zl(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
|
|
108
|
+
|
|
109
|
+
`,textSerializers:n={}}=t||{};return Tk(this.state.doc,{blockSeparator:e,textSerializers:{...Rf(this.schema),...n}})}get isEmpty(){return So(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new gw(e,this)}get $doc(){return this.$pos(0)}};function In(t){return new Co({find:t.find,handler:({state:e,range:n,match:r})=>{const s=te(t.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=n.from+l.indexOf(i),u=c+i.length;if(Bl(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===t.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+a,c);const f=n.from+a+i.length;o.addMark(n.from+a,f,t.type.create(s||{})),o.removeStoredMark(t.type)}},undoable:t.undoable})}function kw(t){return new Co({find:t.find,handler:({state:e,range:n,match:r})=>{const s=te(t.getAttributes,void 0,r)||{},{tr:o}=e,i=n.from;let l=n.to;const a=t.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=t.type.isInline?i:i-1;o.insert(c,t.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:t.undoable})}function Bi(t){return new Co({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),o=te(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)},undoable:t.undoable})}function jn(t){return new Co({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const o=te(t.getAttributes,void 0,r)||{},i=e.tr.delete(n.from,n.to),a=i.doc.resolve(n.from).blockRange(),c=a&&bl(a,t.type,o);if(!c)return null;if(i.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.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(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&zt(i.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&i.join(n.from-1)},undoable:t.undoable})}function ww(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof H){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function vw(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Sw={};Pl(Sw,{createAtomBlockMarkdownSpec:()=>Cw,createBlockMarkdownSpec:()=>Nw,createInlineMarkdownSpec:()=>Zf,parseAttributes:()=>Vl,parseIndentedBlocks:()=>Fi,renderNestedMarkdownContent:()=>Wl,serializeAttributes:()=>Hl});function Vl(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.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=n[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 Hl(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function Cw(t){const{nodeName:e,name:n,parseAttributes:r=Vl,serializeAttributes:s=Hl,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=t,a=n||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 Nw(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Vl,serializeAttributes:o=Hl,defaultAttributes:i={},content:l="block",allowedAttributes:a}=t,c=n||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,k=s(b);let S=1;const w=x.length;let C="";const v=/^:::([\w-]*)(\s.*)?/gm,M=d.slice(w);for(v.lastIndex=0;;){const E=v.exec(M);if(E===null)break;const O=E.index,R=E[1];if(!((m=E[2])!=null&&m.endsWith(":::"))){if(R)S+=1;else if(S-=1,S===0){const L=M.slice(0,O);C=L.trim();const B=d.slice(0,w+O+E[0].length);let z=[];if(C)if(l==="block")for(z=h.blockTokens(L),z.forEach(D=>{D.text&&(!D.tokens||D.tokens.length===0)&&(D.tokens=h.inlineTokens(D.text))});z.length>0;){const D=z[z.length-1];if(D.type==="paragraph"&&(!D.text||D.text.trim()===""))z.pop();else break}else z=h.inlineTokens(C);return{type:e,raw:B,attributes:k,content:C,tokens:z}}}}}},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 Ew(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,o,i]=r;e[s]=o||i,r=n.exec(t)}return e}function Tw(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function Zf(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Ew,serializeAttributes:o=Tw,defaultAttributes:i={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||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[,S]=y;b=S}else{const[,S,w]=y;b=S,x=w||""}const k=s(b.trim());return{type:e,raw:y[0],content:x.trim(),attributes:k}}},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 Fi(t,e,n){var r,s,o,i;const l=t.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 w=l[u];if(w.trim()===""){const v=l.slice(u+1).findIndex(O=>O.trim()!=="");if(v===-1)break;if((((s=(r=l[u+1+v].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){x.push(w),c=`${c}${w}
|
|
119
|
+
`,u+=1;continue}else break}if((((i=(o=w.match(/^(\s*)/))==null?void 0:o[1])==null?void 0:i.length)||0)>g)x.push(w),c=`${c}${w}
|
|
120
|
+
`,u+=1;else break}let b;const k=x.slice(1);if(k.length>0){const w=k.map(C=>C.slice(g+d)).join(`
|
|
121
|
+
`);w.trim()&&(e.customNestedParser?b=e.customNestedParser(w):b=n.blockTokens(w))}const S=e.createToken(m,b);a.push(S)}if(a.length!==0)return{items:a,raw:c}}function Wl(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[o,...i]=t.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 Mw(t,e,n={}){const{state:r}=e,{doc:s,tr:o}=r,i=t;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(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){const h=t.type.create({...t.attrs,...n});o.removeMark(c,u,t.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var Re=class eh extends Fl{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new eh(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Ow=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,o,i,l;const{view:a}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const b=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),S=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,w=(i=t.offsetY)!=null?i:(o=t.nativeEvent)==null?void 0:o.offsetY;d=k.x-b.x+S,f=k.y-b.y+w}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=t.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=H.create(a.state.doc,g),x=a.state.tr.setSelection(y);a.dispatch(x)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=H.isSelectable(this.node),d=t.type==="copy",f=t.type==="paste",h=t.type==="cut",m=t.type==="mousedown";if(!c&&u&&s&&t.target===this.dom&&t.preventDefault(),c&&s&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(c&&l&&!a&&m){const g=n.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(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(ko()||Cf())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function rn(t){return new uw({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const o=te(t.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=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(Bl(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;f<n.to&&i.delete(f,n.to),d>n.from&&i.delete(n.from+u,d),c=n.from+u+l.length,i.addMark(n.from+u,c,t.type.create(o||{})),i.removeStoredMark(t.type)}}})}var Aw=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},Iw=({contentComponent:t})=>{const e=au.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function jw(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:mp.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var Rw=class extends Z.Component{constructor(t){var e;super(t),this.editorContentRef=Z.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=jw(),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 t;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(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:Aw(e,this.editorContentRef),...n}),t?.contentComponent&&p.jsx(Iw,{contentComponent:t.contentComponent})]})}},Dw=N.forwardRef((t,e)=>{const n=Z.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Z.createElement(Rw,{key:n,innerRef:e,...t})}),Pw=Z.memo(Dw),Lw=typeof window<"u"?N.useLayoutEffect:N.useEffect,$w=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function _w(t){var e;const[n]=N.useState(()=>new $w(t.editor)),r=pp.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:sg);return Lw(()=>n.watch(t.editor),[t.editor,n]),N.useDebugValue(r),r}var zw=!1,Vi=typeof window>"u",Bw=Vi||!!(typeof window<"u"&&window.next),Fw=class th{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Vi||Bw?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 bw(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=n.extensions)==null?void 0:i[o])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?th.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,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Vw(t={},e=[]){const n=N.useRef(t);n.current=t;const[r]=N.useState(()=>new Fw(n)),s=au.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return N.useDebugValue(s),N.useEffect(r.onRender(e)),_w({editor:s,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&o===0?0:o+1}),s}var Hw=N.createContext({editor:null});Hw.Consumer;var nh=N.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Ww=()=>N.useContext(nh),zc=Z.forwardRef((t,e)=>{const{onDragStart:n}=Ww(),r=t.as||"div";return p.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function Bc(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function Fc(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function qw(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function Uw(t){if(Bc(t)||Fc(t))return!0;if(qw(t)){const e=t.type;if(e)return Bc(e)||Fc(e)}return!1}function Kw(){try{if(N.version)return parseInt(N.version.split(".")[0],10)>=19}catch{}return!1}var rh=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?hp.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,s=Kw(),o=Uw(e),i={...n};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...i}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};Z.createContext({markViewContentRef:()=>{}});var Jw=class extends Ow{constructor(t,e,n){if(super(t,e,n),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 t={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(nh.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 rh(o,{editor:this.editor,props:t,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.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=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:o,newNode:t,newDecorations:e,oldInnerDecorations:i,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!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 t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=br(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function Gw(t,e){return n=>n.editor.contentComponent?new Jw(t,n,e):{}}var ks=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},Yw=/^\s*>\s$/,Xw=Re.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ks("blockquote",{...oe(this.options.HTMLAttributes,t),children:ks("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(s=>{const l=e.renderChildren([s]).split(`
|
|
125
|
+
`).map(a=>a.trim()===""?n:`${n} ${a}`);r.push(l.join(`
|
|
126
|
+
`))}),r.join(`
|
|
127
|
+
${n}
|
|
128
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[jn({find:Yw,type:this.type})]}}),Qw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Zw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ev=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,tv=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,nv=ln.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return ks("strong",{...oe(this.options.HTMLAttributes,t),children:ks("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[In({find:Qw,type:this.type}),In({find:ev,type:this.type})]},addPasteRules(){return[rn({find:Zw,type:this.type}),rn({find:tv,type:this.type})]}}),rv=/(^|[^`])`([^`]+)`(?!`)$/,sv=/(^|[^`])`([^`]+)`(?!`)/g,ov=ln.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[In({find:rv,type:this.type})]},addPasteRules(){return[rn({find:sv,type:this.type})]}}),ci=4,iv=/^```([a-z]+)?[\s\n]$/,lv=/^~~~([a-z]+)?[\s\n]$/,av=Re.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ci,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const o=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",oe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
|
|
129
|
+
`):r=`\`\`\`${s}
|
|
130
|
+
|
|
131
|
+
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:ci,{state:r}=t,{selection:s}=r,{$from:o,empty:i}=s;if(o.parent.type!==this.type)return!1;const l=" ".repeat(n);return i?t.commands.insertContent(l):t.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:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:ci,{state:r}=t,{selection:s}=r,{$from:o,empty:i}=s;return o.parent.type!==this.type?!1:i?t.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 C=0;C<h.length;C+=1){if(g+h[C].length>=y){m=C;break}g+=h[C].length+1}const b=((a=h[m].match(/^ */))==null?void 0:a[0])||"",k=Math.min(b.length,n);if(k===0)return!0;let S=u;for(let C=0;C<m;C+=1)S+=h[C].length+1;return l.delete(S,S+k),c-S<=k&&l.setSelection(q.create(l.doc,S)),!0}):t.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,n);return h.slice(y)}).join(`
|
|
142
|
+
`);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
|
|
143
|
+
|
|
144
|
+
`);return!o||!i?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:o}=n;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(J.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Bi({find:iv,type:this.type,getAttributes:t=>({language:t[1]})}),Bi({find:lv,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ie({key:new de("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s?.mode;if(!n||!o)return!1;const{tr:i,schema:l}=t.state,a=l.text(n.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),t.dispatch(i),!0}}})]}}),cv=Re.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
146
|
+
|
|
147
|
+
`):""}),uv=Re.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",oe(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
148
|
+
`},renderMarkdown:()=>`
|
|
149
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:o}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks: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()}}}),dv=Re.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,oe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Bi({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),fv=Re.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",oe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!ww(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Lf(n)?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(H.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[kw({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),hv=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,pv=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,mv=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,gv=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,yv=ln.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",oe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[In({find:hv,type:this.type}),In({find:mv,type:this.type})]},addPasteRules(){return[rn({find:pv,type:this.type}),rn({find:gv,type:this.type})]}});const xv="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",bv="ελ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",Hi="numeric",Wi="ascii",qi="alpha",rr="asciinumeric",Xn="alphanumeric",Ui="domain",sh="emoji",kv="scheme",wv="slashscheme",ui="whitespace";function vv(t,e){return t in e||(e[t]=[]),e[t]}function Ut(t,e,n){e[Hi]&&(e[rr]=!0,e[Xn]=!0),e[Wi]&&(e[rr]=!0,e[qi]=!0),e[rr]&&(e[Xn]=!0),e[qi]&&(e[Xn]=!0),e[Xn]&&(e[Ui]=!0),e[sh]&&(e[Ui]=!0);for(const r in e){const s=vv(r,n);s.indexOf(t)<0&&s.push(t)}}function Sv(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ae(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ae.groups={};Ae.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(t))return o}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||Ae.groups;let s;return e&&e.j?s=e:(s=new Ae(e),n&&r&&Ut(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const o=t.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(t[i]);return s.tt(t[o-1],e,n,r)},tt(t,e,n,r){r=r||Ae.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const o=e;let i,l=s.go(t);if(l?(i=new Ae,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new Ae,o){if(r)if(i.t&&typeof i.t=="string"){const a=Object.assign(Sv(i.t,r),n);Ut(o,a,r)}else n&&Ut(o,n,r);i.t=o}return s.j[t]=i,i}};const K=(t,e,n,r,s)=>t.ta(e,n,r,s),ae=(t,e,n,r,s)=>t.tr(e,n,r,s),Vc=(t,e,n,r,s)=>t.ts(e,n,r,s),I=(t,e,n,r,s)=>t.tt(e,n,r,s),ct="WORD",Ki="UWORD",oh="ASCIINUMERICAL",ih="ALPHANUMERICAL",kr="LOCALHOST",Ji="TLD",Gi="UTLD",es="SCHEME",bn="SLASH_SCHEME",ql="NUM",Yi="WS",Ul="NL",sr="OPENBRACE",or="CLOSEBRACE",ws="OPENBRACKET",vs="CLOSEBRACKET",Ss="OPENPAREN",Cs="CLOSEPAREN",Ns="OPENANGLEBRACKET",Es="CLOSEANGLEBRACKET",Ts="FULLWIDTHLEFTPAREN",Ms="FULLWIDTHRIGHTPAREN",Os="LEFTCORNERBRACKET",As="RIGHTCORNERBRACKET",Is="LEFTWHITECORNERBRACKET",js="RIGHTWHITECORNERBRACKET",Rs="FULLWIDTHLESSTHAN",Ds="FULLWIDTHGREATERTHAN",Ps="AMPERSAND",Ls="APOSTROPHE",$s="ASTERISK",vt="AT",_s="BACKSLASH",zs="BACKTICK",Bs="CARET",Nt="COLON",Kl="COMMA",Fs="DOLLAR",et="DOT",Vs="EQUALS",Jl="EXCLAMATION",_e="HYPHEN",ir="PERCENT",Hs="PIPE",Ws="PLUS",qs="POUND",lr="QUERY",Gl="QUOTE",lh="FULLWIDTHMIDDLEDOT",Yl="SEMI",tt="SLASH",ar="TILDE",Us="UNDERSCORE",ah="EMOJI",Ks="SYM";var ch=Object.freeze({__proto__:null,ALPHANUMERICAL:ih,AMPERSAND:Ps,APOSTROPHE:Ls,ASCIINUMERICAL:oh,ASTERISK:$s,AT:vt,BACKSLASH:_s,BACKTICK:zs,CARET:Bs,CLOSEANGLEBRACKET:Es,CLOSEBRACE:or,CLOSEBRACKET:vs,CLOSEPAREN:Cs,COLON:Nt,COMMA:Kl,DOLLAR:Fs,DOT:et,EMOJI:ah,EQUALS:Vs,EXCLAMATION:Jl,FULLWIDTHGREATERTHAN:Ds,FULLWIDTHLEFTPAREN:Ts,FULLWIDTHLESSTHAN:Rs,FULLWIDTHMIDDLEDOT:lh,FULLWIDTHRIGHTPAREN:Ms,HYPHEN:_e,LEFTCORNERBRACKET:Os,LEFTWHITECORNERBRACKET:Is,LOCALHOST:kr,NL:Ul,NUM:ql,OPENANGLEBRACKET:Ns,OPENBRACE:sr,OPENBRACKET:ws,OPENPAREN:Ss,PERCENT:ir,PIPE:Hs,PLUS:Ws,POUND:qs,QUERY:lr,QUOTE:Gl,RIGHTCORNERBRACKET:As,RIGHTWHITECORNERBRACKET:js,SCHEME:es,SEMI:Yl,SLASH:tt,SLASH_SCHEME:bn,SYM:Ks,TILDE:ar,TLD:Ji,UNDERSCORE:Us,UTLD:Gi,UWORD:Ki,WORD:ct,WS:Yi});const lt=/[a-z]/,Un=new RegExp("\\p{L}","u"),di=new RegExp("\\p{Emoji}","u"),at=/\d/,fi=/\s/,Hc="\r",hi=`
|
|
150
|
+
`,Cv="️",Nv="",pi="";let Ur=null,Kr=null;function Ev(t=[]){const e={};Ae.groups=e;const n=new Ae;Ur==null&&(Ur=Wc(xv)),Kr==null&&(Kr=Wc(bv)),I(n,"'",Ls),I(n,"{",sr),I(n,"}",or),I(n,"[",ws),I(n,"]",vs),I(n,"(",Ss),I(n,")",Cs),I(n,"<",Ns),I(n,">",Es),I(n,"(",Ts),I(n,")",Ms),I(n,"「",Os),I(n,"」",As),I(n,"『",Is),I(n,"』",js),I(n,"<",Rs),I(n,">",Ds),I(n,"&",Ps),I(n,"*",$s),I(n,"@",vt),I(n,"`",zs),I(n,"^",Bs),I(n,":",Nt),I(n,",",Kl),I(n,"$",Fs),I(n,".",et),I(n,"=",Vs),I(n,"!",Jl),I(n,"-",_e),I(n,"%",ir),I(n,"|",Hs),I(n,"+",Ws),I(n,"#",qs),I(n,"?",lr),I(n,'"',Gl),I(n,"/",tt),I(n,";",Yl),I(n,"~",ar),I(n,"_",Us),I(n,"\\",_s),I(n,"・",lh);const r=ae(n,at,ql,{[Hi]:!0});ae(r,at,r);const s=ae(r,lt,oh,{[rr]:!0}),o=ae(r,Un,ih,{[Xn]:!0}),i=ae(n,lt,ct,{[Wi]:!0});ae(i,at,s),ae(i,lt,i),ae(s,at,s),ae(s,lt,s);const l=ae(n,Un,Ki,{[qi]:!0});ae(l,lt),ae(l,at,o),ae(l,Un,l),ae(o,at,o),ae(o,lt),ae(o,Un,o);const a=I(n,hi,Ul,{[ui]:!0}),c=I(n,Hc,Yi,{[ui]:!0}),u=ae(n,fi,Yi,{[ui]:!0});I(n,pi,u),I(c,hi,a),I(c,pi,u),ae(c,fi,u),I(u,Hc),I(u,hi),ae(u,fi,u),I(u,pi,u);const d=ae(n,di,ah,{[sh]:!0});I(d,"#"),ae(d,di,d),I(d,Cv,d);const f=I(d,Nv);I(f,"#"),ae(f,di,d);const h=[[lt,i],[at,s]],m=[[lt,null],[Un,l],[at,o]];for(let g=0;g<Ur.length;g++)yt(n,Ur[g],Ji,ct,h);for(let g=0;g<Kr.length;g++)yt(n,Kr[g],Gi,Ki,m);Ut(Ji,{tld:!0,ascii:!0},e),Ut(Gi,{utld:!0,alpha:!0},e),yt(n,"file",es,ct,h),yt(n,"mailto",es,ct,h),yt(n,"http",bn,ct,h),yt(n,"https",bn,ct,h),yt(n,"ftp",bn,ct,h),yt(n,"ftps",bn,ct,h),Ut(es,{scheme:!0,ascii:!0},e),Ut(bn,{slashscheme:!0,ascii:!0},e),t=t.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<t.length;g++){const y=t[g][0],b=t[g][1]?{[kv]:!0}:{[wv]:!0};y.indexOf("-")>=0?b[Ui]=!0:lt.test(y)?at.test(y)?b[rr]=!0:b[Wi]=!0:b[Hi]=!0,Vc(n,y,y,b)}return Vc(n,"localhost",kr,{ascii:!0}),n.jd=new Ae(Ks),{start:n,tokens:Object.assign({groups:e},ch)}}function uh(t,e){const n=Tv(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let o=0,i=0;for(;i<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;i<r&&(a=l.go(n[i]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[i].length,f++),c+=n[i].length,o+=n[i].length,i++;o-=d,i-=f,c-=d,s.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function Tv(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),o,i=s<55296||s>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(i),r+=i.length}return e}function yt(t,e,n,r,s){let o;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];t.j[a]?o=t.j[a]:(o=new Ae(r),o.jr=s.slice(),t.j[a]=o),t=o}return o=new Ae(n),o.jr=s.slice(),t.j[e[i-1]]=o,o}function Wc(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let o=0;for(;s.indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let i=parseInt(t.substring(r,r+o),10);i>0;i--)n.pop();r+=o}else n.push(t[r]),r++}return e}const wr={defaultProtocol:"http",events:null,format:qc,formatHref:qc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Xl(t,e=null){let n=Object.assign({},wr);t&&(n=Object.assign(n,t instanceof Xl?t.o:t));const r=n.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}Xl.prototype={o:wr,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:wr[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function qc(t){return t}function dh(t,e){this.t="token",this.v=t,this.tk=e}dh.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=wr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),o=this.toFormattedString(t),i={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return i.href=r,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 Eo(t,e){class n extends dh{constructor(s,o){super(s,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Uc=Eo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Kc=Eo("text"),Mv=Eo("nl"),Jr=Eo("url",{isLink:!0,toHref(t=wr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==kr&&t[1].t===Nt}}),$e=t=>new Ae(t);function Ov({groups:t}){const e=t.domain.concat([Ps,$s,vt,_s,zs,Bs,Fs,Vs,_e,ql,ir,Hs,Ws,qs,tt,Ks,ar,Us]),n=[Ls,Nt,Kl,et,Jl,ir,lr,Gl,Yl,Ns,Es,sr,or,vs,ws,Ss,Cs,Ts,Ms,Os,As,Is,js,Rs,Ds],r=[Ps,Ls,$s,_s,zs,Bs,Fs,Vs,_e,sr,or,ir,Hs,Ws,qs,lr,tt,Ks,ar,Us],s=$e(),o=I(s,ar);K(o,r,o),K(o,t.domain,o);const i=$e(),l=$e(),a=$e();K(s,t.domain,i),K(s,t.scheme,l),K(s,t.slashscheme,a),K(i,r,o),K(i,t.domain,i);const c=I(i,vt);I(o,vt,c),I(l,vt,c),I(a,vt,c);const u=I(o,et);K(u,r,o),K(u,t.domain,o);const d=$e();K(c,t.domain,d),K(d,t.domain,d);const f=I(d,et);K(f,t.domain,d);const h=$e(Uc);K(f,t.tld,h),K(f,t.utld,h),I(c,kr,h);const m=I(d,_e);I(m,_e,m),K(m,t.domain,d),K(h,t.domain,d),I(h,et,f),I(h,_e,m);const g=I(h,Nt);K(g,t.numeric,Uc);const y=I(i,_e),x=I(i,et);I(y,_e,y),K(y,t.domain,i),K(x,r,o),K(x,t.domain,i);const b=$e(Jr);K(x,t.tld,b),K(x,t.utld,b),K(b,t.domain,i),K(b,r,o),I(b,et,x),I(b,_e,y),I(b,vt,c);const k=I(b,Nt),S=$e(Jr);K(k,t.numeric,S);const w=$e(Jr),C=$e();K(w,e,w),K(w,n,C),K(C,e,w),K(C,n,C),I(b,tt,w),I(S,tt,w);const v=I(l,Nt),M=I(a,Nt),E=I(M,tt),O=I(E,tt);K(l,t.domain,i),I(l,et,x),I(l,_e,y),K(a,t.domain,i),I(a,et,x),I(a,_e,y),K(v,t.domain,w),I(v,tt,w),I(v,lr,w),K(O,t.domain,w),K(O,e,w),I(O,tt,w);const R=[[sr,or],[ws,vs],[Ss,Cs],[Ns,Es],[Ts,Ms],[Os,As],[Is,js],[Rs,Ds]];for(let L=0;L<R.length;L++){const[B,z]=R[L],D=I(w,B);I(C,B,D),I(D,z,w);const T=$e(Jr);K(D,e,T);const _=$e();K(D,n),K(T,e,T),K(T,n,_),K(_,e,T),K(_,n,_),I(T,z,w),I(_,z,w)}return I(s,kr,b),I(s,Ul,Mv),{start:s,tokens:ch}}function Av(t,e,n){let r=n.length,s=0,o=[],i=[];for(;s<r;){let l=t,a=null,c=null,u=0,d=null,f=-1;for(;s<r&&!(a=l.go(n[s].t));)i.push(n[s++]);for(;s<r&&(c=a||l.go(n[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(n[s]),s++);else{i.length>0&&(o.push(mi(Kc,e,i)),i=[]),s-=f,u-=f;const h=d.t,m=n.slice(s-u,s);o.push(mi(h,e,m))}}return i.length>0&&o.push(mi(Kc,e,i)),o}function mi(t,e,n){const r=n[0].s,s=n[n.length-1].e,o=e.slice(r,s);return new t(o,n)}const Iv=typeof console<"u"&&console&&console.warn||(()=>{}),jv="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 Rv(){return Ae.groups={},re.scanner=null,re.parser=null,re.tokenQueue=[],re.pluginQueue=[],re.customSchemes=[],re.initialized=!1,re}function Jc(t,e=!1){if(re.initialized&&Iv(`linkifyjs: already initialized - will not register custom scheme "${t}" ${jv}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))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([t,e])}function Dv(){re.scanner=Ev(re.customSchemes);for(let t=0;t<re.tokenQueue.length;t++)re.tokenQueue[t][1]({scanner:re.scanner});re.parser=Ov(re.scanner.tokens);for(let t=0;t<re.pluginQueue.length;t++)re.pluginQueue[t][1]({scanner:re.scanner,parser:re.parser});return re.initialized=!0,re}function Ql(t){return re.initialized||Dv(),Av(re.parser.start,t,uh(re.scanner.start,t))}Ql.scan=uh;function fh(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Xl(n),s=Ql(t),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 Zl="[\0- -\u2029 ]",Pv=new RegExp(Zl),Lv=new RegExp(`${Zl}$`),$v=new RegExp(Zl,"g");function _v(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function zv(t){return new ie({key:new de("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=Mf(n.doc,[...e]);if(Pf(l).forEach(({newRange:c})=>{const u=wk(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(!Lv.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(Pv).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=Ql(m).map(x=>x.toObject(t.defaultProtocol));if(!_v(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=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{Bl(x.from,x.to,r.doc).some(b=>b.mark.type===t.type)||i.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!i.steps.length)return i}})}function Bv(t){return new ie({key:new de("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.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=Df(e.state,t.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 Fv(t){return new ie({key:new de("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:o}=e,{selection:i}=o,{empty:l}=i;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=fh(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Ft(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace($v,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Vv=ln.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Jc(t);return}Jc(t.scheme,t.optionalSlashes)})},onDestroy(){Rv()},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:(t,e)=>!!Ft(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.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:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ft(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ft(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",oe(this.options.HTMLAttributes,t),0]:["a",oe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ft(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Ft(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[rn({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=fh(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!Ft(i,n),protocols:n,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:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(zv({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ft(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Bv({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Fv({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Hv=Object.defineProperty,Wv=(t,e)=>{for(var n in e)Hv(t,n,{get:e[n],enumerable:!0})},qv="listItem",Gc="textStyle",Yc=/^\s*([-+*])\s$/,hh=Re.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
154
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(qv,this.editor.getAttributes(Gc)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=jn({find:Yc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=jn({find:Yc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Gc),editor:this.editor})),[t]}}),ph=Re.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const i=t.tokens.slice(1),l=e.parseChildren(i);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Wl(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Uv={};Wv(Uv,{findListItemPos:()=>jr,getNextListDepth:()=>ea,handleBackspace:()=>Xi,handleDelete:()=>Qi,hasListBefore:()=>mh,hasListItemAfter:()=>Kv,hasListItemBefore:()=>gh,listItemHasSubList:()=>yh,nextListIsDeeper:()=>xh,nextListIsHigher:()=>bh});var jr=(t,e)=>{const{$from:n}=e.selection,r=pe(t,e.schema);let s=null,o=n.depth,i=n.pos,l=null;for(;o>0&&l===null;)s=n.node(o),s.type===r?l=o:(o-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},ea=(t,e)=>{const n=jr(t,e);if(!n)return!1;const[,r]=Ik(e,t,n.$pos.pos+4);return r},mh=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),o=t.doc.resolve(s).node();return!(!o||!n.includes(o.type.name))},gh=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},yh=(t,e,n)=>{if(!n)return!1;const r=pe(t,e.schema);let s=!1;return n.descendants(o=>{o.type===r&&(s=!0)}),s},Xi=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Pt(t.state,e)&&mh(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.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=t.state.doc.resolve(a.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!Pt(t.state,e)||!Pk(t.state))return!1;const r=jr(e,t.state);if(!r)return!1;const o=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=yh(e,t.state,o);return gh(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},xh=(t,e)=>{const n=ea(t,e),r=jr(t,e);return!r||!n?!1:n>r.depth},bh=(t,e)=>{const n=ea(t,e),r=jr(t,e);return!r||!n?!1:n<r.depth},Qi=(t,e)=>{if(!Pt(t.state,e)||!Dk(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:xh(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():bh(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Kv=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},kh=fe.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Qi(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Qi(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Xi(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Xi(t,n,r)&&(e=!0)}),e}}}}),Xc=/^(\s*)(\d+)\.\s+(.*)$/,Jv=/^\s/;function Gv(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],o=s.match(Xc);if(!o)break;const[,i,l,a]=o,c=i.length;let u=a,d=n+1;const f=[s];for(;d<t.length;){const h=t[d];if(h.match(Xc))break;if(h.trim()==="")f.push(h),u+=`
|
|
155
|
+
`,d+=1;else if(h.match(Jv))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,n=d}return[e,r]}function wh(t,e,n){var r;const s=[];let o=0;for(;o<t.length;){const i=t[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:n.inlineTokens(a)});const u=l.slice(1).join(`
|
|
159
|
+
`).trim();if(u){const h=n.blockTokens(u);c.push(...h)}let d=o+1;const f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){const h=Math.min(...f.map(g=>g.indent)),m=wh(f,h,n);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 Yv(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const o=e.parseChildren([s]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([s]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}var Xv="listItem",Qc="textStyle",Zc=/^(\d+)\.\s$/,vh=Re.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",oe(this.options.HTMLAttributes,n),0]:["ol",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?Yv(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
161
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
|
|
162
|
+
`),[o,i]=Gv(s);if(o.length===0)return;const l=wh(o,0,n);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:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Xv,this.editor.getAttributes(Qc)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=jn({find:Zc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=jn({find:Zc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Qc)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Qv=/^\s*(\[([( |x])?\])\s$/,Zv=Re.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",oe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Wl(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),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(t),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 n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const h=n();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(t,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{s.setAttribute(u,d)}),s.dataset.checked=t.attrs.checked,l.checked=t.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[jn({find:Qv,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),eS=Re.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",oe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
164
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=o=>{const i=Fi(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:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return i?[{type:"taskList",raw:i.raw,items:i.items}]:n.blockTokens(o)},s=Fi(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});fe.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(hh.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(ph.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(kh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(vh.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Zv.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(eS.configure(this.options.taskList)),t}});var tS=Re.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",oe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),nS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,rS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,sS=ln.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[In({find:nS,type:this.type})]},addPasteRules(){return[rn({find:rS,type:this.type})]}}),oS=Re.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),iS=ln.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",oe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function lS(t={}){return new ie({view(e){return new aS(e,t)}})}class aS{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);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 n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!o){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=yd(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 ce extends J{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ce.valid(r)?new ce(r):J.near(r)}content(){return $.empty}eq(e){return e instanceof ce&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ce(e.resolve(n.pos))}getBookmark(){return new ta(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!cS(e)||!uS(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ce.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(n>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=n;let a=e.doc.resolve(s);if(ce.valid(a))return a}for(;;){let i=n>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!H.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*n),r=!1;continue e}break}o=i,s+=n;let l=e.doc.resolve(s);if(ce.valid(l))return l}return null}}}ce.prototype.visible=!1;ce.findFrom=ce.findGapCursorFrom;J.jsonID("gapcursor",ce);class ta{constructor(e){this.pos=e}map(e){return new ta(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ce.valid(n)?new ce(n):J.near(n)}}function Sh(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function cS(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Sh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function uS(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Sh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function dS(){return new ie({props:{decorations:mS,createSelectionBetween(t,e,n){return e.pos==n.pos&&ce.valid(n)?new ce(n):null},handleClick:hS,handleKeyDown:fS,handleDOMEvents:{beforeinput:pS}}})}const fS=bf({ArrowLeft:Gr("horiz",-1),ArrowRight:Gr("horiz",1),ArrowUp:Gr("vert",-1),ArrowDown:Gr("vert",1)});function Gr(t,e){const n=t=="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(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ce.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ce(c))),!0):!1}}function hS(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ce.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&H.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ce(r))),!0)}function pS(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ce))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=A.empty;for(let i=r.length-1;i>=0;i--)s=A.from(r[i].createAndFill(null,s));let o=t.state.tr.replace(n.pos,n.pos,new $(s,0,0));return o.setSelection(q.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function mS(t){if(!(t.selection instanceof ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",se.create(t.doc,[Se.widget(t.selection.head,e,{key:"gapcursor"})])}var Js=200,xe=function(){};xe.prototype.append=function(e){return e.length?(e=xe.from(e),!this.length&&e||e.length<Js&&this.leafAppend(e)||this.length<Js&&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 gS(this,e)};xe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?xe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};xe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};xe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};xe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},n,r),s};xe.from=function(e){return e instanceof xe?e:e&&e.length?new Ch(e):xe.empty};var Ch=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,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<=Js)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Js)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(xe);xe.empty=new Ch([]);var gS=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var 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 yS=500;class Ke{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;n&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,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 xt(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 xt(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 Ke(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,n,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 xt(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),n&&(i++,n=void 0),s||(a=f)}let c=i-r.depth;return c>bS&&(l=xS(l,c),i-=c),new Ke(l.append(o),i)}remapping(e,n){let r=new hr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ke(this.items.append(e.map(n=>new xt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=n;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 xt(m,g,y))}else r.push(new xt(m))},s);let c=[];for(let f=n;f<i;f++)c.push(new xt(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new Ke(u,l);return d.emptyItemCount()>yS&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=i.selection&&i.selection.map(n.slice(r));u&&o++;let d=new xt(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 Ke(xe.from(s.reverse()),o)}}Ke.empty=new Ke(xe.empty,0);function xS(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let xt=class Nh{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Nh(n.getMap().invert(),n,this.selection)}}};class St{constructor(e,n,r,s,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const bS=20;function kS(t,e,n,r){let s=n.getMeta(Xt),o;if(s)return s.historyState;n.getMeta(SS)&&(t=new St(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(Xt))return i.getMeta(Xt).redo?new St(t.done.addTransform(n,void 0,r,ts(e)),t.undone,eu(n.mapping.maps),t.prevTime,t.prevComposition):new St(t.done,t.undone.addTransform(n,void 0,r,ts(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!i&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!wS(n,t.prevRanges)),c=i?gi(t.prevRanges,n.mapping):eu(n.mapping.maps);return new St(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,ts(e)),Ke.empty,c,n.time,l??t.prevComposition)}else return(o=n.getMeta("rebased"))?new St(t.done.rebased(n,o),t.undone.rebased(n,o),gi(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new St(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),gi(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function wS(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(n=!0)}),n}function eu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,o,i)=>e.push(o,i));return e}function gi(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),o=e.map(t[r+1],-1);s<=o&&n.push(s,o)}return n}function vS(t,e,n){let r=ts(e),s=Xt.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new St(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Xt,{redo:n,historyState:a})}let yi=!1,tu=null;function ts(t){let e=t.plugins;if(tu!=e){yi=!1,tu=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){yi=!0;break}}return yi}const Xt=new de("history"),SS=new de("closeHistory");function CS(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ie({key:Xt,state:{init(){return new St(Ke.empty,Ke.empty,null,0,-1)},apply(e,n,r){return kS(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Th:r=="historyRedo"?Mh:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Eh(t,e){return(n,r)=>{let s=Xt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let o=vS(s,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const Th=Eh(!1,!0),Mh=Eh(!0,!0);fe.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ie({key:new de("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!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 t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const 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 NS=fe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[lS(this.options)]}});fe.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ie({key:new de("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!n||!r)return se.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return t.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(t,o)}}})]}});var ES=fe.create({name:"gapCursor",addProseMirrorPlugins(){return[dS()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=te(V(t,"allowGapCursor",n)))!=null?e:null}}});fe.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 de("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&So(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(t,s)}}})]}});fe.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ie({key:new de("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Lf(n.selection)||t.view.dragging?null:se.create(n.doc,[Se.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function nu({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var TS=fe.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new de(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new 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[n];if(u)return a.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!nu({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!nu({node:i,types:r})}}})]}}),MS=fe.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Th(t,e),redo:()=>({state:t,dispatch:e})=>Mh(t,e)}},addProseMirrorPlugins(){return[CS(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()}}}),OS=fe.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(nv.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Xw.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(hh.configure(this.options.bulletList)),this.options.code!==!1&&s.push(ov.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(av.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(cv.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(NS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(ES.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(uv.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(dv.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(MS.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(fv.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(yv.configure(this.options.italic)),this.options.listItem!==!1&&s.push(ph.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(kh.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(Vv.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(tS.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(sS.configure(this.options.strike)),this.options.text!==!1&&s.push(oS.configure(this.options.text)),this.options.underline!==!1&&s.push(iS.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(TS.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),AS=OS;function IS(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=t,a=r&&!s,c=vw(n),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 k=g+y.index;let S=k+y[0].length;return a&&u.test(m.slice(S-1,S+1))&&(y[0]+=" ",S+=1),k<l.pos&&S>=l.pos?{range:{from:k,to:S},query:y[0].slice(n.length),text:y[0]}:null}var jS=new de("suggestion");function RS({pluginKey:t=jS,editor:e,char:n="@",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=IS,shouldShow:y}){let x;const b=h?.(),k=()=>{const v=e.state.selection.$anchor.pos,M=e.view.coordsAtPos(v),{top:E,right:O,bottom:R,left:L}=M;try{return new DOMRect(L,E,O-L,R-E)}catch{return null}},S=(v,M)=>M?()=>{const E=t.getState(e.state),O=E?.decorationId,R=v.dom.querySelector(`[data-decoration-id="${O}"]`);return R?.getBoundingClientRect()||null}:k;function w(v,M){var E;try{const R=t.getState(v.state),L=R?.decorationId?v.dom.querySelector(`[data-decoration-id="${R.decorationId}"]`):null,B={editor:e,range:R?.range||{from:0,to:0},query:R?.query||null,text:R?.text||null,items:[],command:z=>d({editor:e,range:R?.range||{from:0,to:0},props:z}),decorationNode:L,clientRect:S(v,L)};(E=b?.onExit)==null||E.call(b,B)}catch{}const O=v.state.tr.setMeta(M,{exit:!0});v.dispatch(O)}const C=new ie({key:t,view(){return{update:async(v,M)=>{var E,O,R,L,B,z,D;const T=(E=this.key)==null?void 0:E.getState(M),_=(O=this.key)==null?void 0:O.getState(v.state),P=T.active&&_.active&&T.range.from!==_.range.from,U=!T.active&&_.active,G=T.active&&!_.active,F=!U&&!G&&T.query!==_.query,W=U||P&&F,Q=F||P,X=G||P&&F;if(!W&&!Q&&!X)return;const Y=X&&!W?T:_,le=v.dom.querySelector(`[data-decoration-id="${Y.decorationId}"]`);x={editor:e,range:Y.range,query:Y.query,text:Y.text,items:[],command:Ee=>d({editor:e,range:Y.range,props:Ee}),decorationNode:le,clientRect:S(v,le)},W&&((R=b?.onBeforeStart)==null||R.call(b,x)),Q&&((L=b?.onBeforeUpdate)==null||L.call(b,x)),(Q||W)&&(x.items=await f({editor:e,query:Y.query})),X&&((B=b?.onExit)==null||B.call(b,x)),Q&&((z=b?.onUpdate)==null||z.call(b,x)),W&&((D=b?.onStart)==null||D.call(b,x))},destroy:()=>{var v;x&&((v=b?.onExit)==null||v.call(b,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,M,E,O){const{isEditable:R}=e,{composing:L}=e.view,{selection:B}=v,{empty:z,from:D}=B,T={...M},_=v.getMeta(t);if(_&&_.exit)return T.active=!1,T.decorationId=null,T.range={from:0,to:0},T.query=null,T.text=null,T;if(T.composing=L,R&&(z||e.view.composing)){(D<M.range.from||D>M.range.to)&&!L&&!M.composing&&(T.active=!1);const P=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:B.$from}),U=`id_${Math.floor(Math.random()*4294967295)}`;P&&m({editor:e,state:O,range:P.range,isActive:M.active})&&(!y||y({editor:e,range:P.range,query:P.query,text:P.text,transaction:v}))?(T.active=!0,T.decorationId=M.decorationId?M.decorationId:U,T.range=P.range,T.query=P.query,T.text=P.text):T.active=!1}else T.active=!1;return T.active||(T.decorationId=null,T.range={from:0,to:0},T.query=null,T.text=null),T}},props:{handleKeyDown(v,M){var E,O,R,L;const{active:B,range:z}=C.getState(v.state);if(!B)return!1;if(M.key==="Escape"||M.key==="Esc"){const T=C.getState(v.state),_=(E=x?.decorationNode)!=null?E:null,P=_??(T?.decorationId?v.dom.querySelector(`[data-decoration-id="${T.decorationId}"]`):null);if(((O=b?.onKeyDown)==null?void 0:O.call(b,{view:v,event:M,range:T.range}))||!1)return!0;const G={editor:e,range:T.range,query:T.query,text:T.text,items:[],command:F=>d({editor:e,range:T.range,props:F}),decorationNode:P,clientRect:P?()=>P.getBoundingClientRect()||null:null};return(R=b?.onExit)==null||R.call(b,G),w(v,t),!0}return((L=b?.onKeyDown)==null?void 0:L.call(b,{view:v,event:M,range:z}))||!1},decorations(v){const{active:M,range:E,decorationId:O,query:R}=C.getState(v);if(!M)return null;const L=!R?.length,B=[a];return L&&B.push(u),se.create(v.doc,[Se.inline(E.from,E.to,{nodeName:l,class:B.join(" "),"data-decoration-id":O,"data-decoration-content":c})])}}});return C}function DS({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const s=new de;return{editor:t,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:n,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[n];return!!l.parent.type.contentMatch.matchType(a)},...e}}function Oh(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>DS({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function ru(t,e){const n=Oh(t),r=n.find(s=>s.char===e);return r||(n.length?n[0]:null)}var PS=Re.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e?.char)!=null?n:"@"}${(r=t.attrs.label)!=null?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,s;return["span",oe(this.HTMLAttributes,t.HTMLAttributes),`${(r=n?.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:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=ru(this,t.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:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=oe({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof s=="string"?["span",oe({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...Zf({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:t=>{const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,o,i]=r,l=o??i;e[s==="char"?"mentionSuggestionChar":s]=l,r=n.exec(t)}return e},serializeAttributes:t=>Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e==="mentionSuggestionChar"?"char":e}="${n}"`).join(" ")}),renderText({node:t}){const e={options:this.options,node:t,suggestion:ru(this,t.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:t,state:e})=>{let n=!1;const{selection:r}=e,{empty:s,anchor:o}=r;if(!s)return!1;let i=new Fe,l=0;return e.doc.nodesBetween(o-1,o,(a,c)=>{if(a.type.name===this.name)return n=!0,i=a,l=c,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":i.attrs.mentionSuggestionChar,l,l+i.nodeSize),n})}},addProseMirrorPlugins(){return Oh(this).map(RS)}}),LS=PS,xi,To="HoverCard",[Ah]=tl(To,[cu]),Mo=cu(),[$S,Oo]=Ah(To),Ih=t=>{const{__scopeHoverCard:e,children:n,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=t,a=Mo(e),c=N.useRef(0),u=N.useRef(0),d=N.useRef(!1),f=N.useRef(!1),[h,m]=Zs({prop:r,defaultProp:s??!1,onChange:o,caller:To}),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($S,{scope:e,open:h,onOpenChange:m,onOpen:g,onClose:y,onDismiss:x,hasSelectionRef:d,isPointerDownOnContentRef:f,children:p.jsx(xp,{...a,children:n})})};Ih.displayName=To;var jh="HoverCardTrigger",Rh=N.forwardRef((t,e)=>{const{__scopeHoverCard:n,...r}=t,s=Oo(jh,n),o=Mo(n);return p.jsx(gp,{asChild:!0,...o,children:p.jsx(Dn.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:Ue(t.onPointerEnter,Ys(s.onOpen)),onPointerLeave:Ue(t.onPointerLeave,Ys(s.onClose)),onFocus:Ue(t.onFocus,s.onOpen),onBlur:Ue(t.onBlur,s.onClose),onTouchStart:Ue(t.onTouchStart,i=>i.preventDefault())})})});Rh.displayName=jh;var na="HoverCardPortal",[_S,zS]=Ah(na,{forceMount:void 0}),Dh=t=>{const{__scopeHoverCard:e,forceMount:n,children:r,container:s}=t,o=Oo(na,e);return p.jsx(_S,{scope:e,forceMount:n,children:p.jsx(nl,{present:n||o.open,children:p.jsx(yp,{asChild:!0,container:s,children:r})})})};Dh.displayName=na;var Gs="HoverCardContent",Ph=N.forwardRef((t,e)=>{const n=zS(Gs,t.__scopeHoverCard),{forceMount:r=n.forceMount,...s}=t,o=Oo(Gs,t.__scopeHoverCard);return p.jsx(nl,{present:r||o.open,children:p.jsx(BS,{"data-state":o.open?"open":"closed",...s,onPointerEnter:Ue(t.onPointerEnter,Ys(o.onOpen)),onPointerLeave:Ue(t.onPointerLeave,Ys(o.onClose)),ref:e})})});Ph.displayName=Gs;var BS=N.forwardRef((t,e)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=t,a=Oo(Gs,n),c=Mo(n),u=N.useRef(null),d=rl(e,u),[f,h]=N.useState(!1);return N.useEffect(()=>{if(f){const m=document.body;return xi=m.style.userSelect||m.style.webkitUserSelect,m.style.userSelect="none",m.style.webkitUserSelect="none",()=>{m.style.userSelect=xi,m.style.webkitUserSelect=xi}}},[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&&HS(u.current).forEach(g=>g.setAttribute("tabindex","-1"))}),p.jsx(bp,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:Ue(o,m=>{m.preventDefault()}),onDismiss:a.onDismiss,children:p.jsx(kp,{...c,...l,onPointerDown:Ue(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)"}})})}),FS="HoverCardArrow",VS=N.forwardRef((t,e)=>{const{__scopeHoverCard:n,...r}=t,s=Mo(n);return p.jsx(wp,{...s,...r,ref:e})});VS.displayName=FS;function Ys(t){return e=>e.pointerType==="touch"?void 0:t()}function HS(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)e.push(n.currentNode);return e}var WS=Ih,qS=Rh,US=Dh,KS=Ph;function JS(t){const e=j.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=p.jsx(WS,{"data-slot":"hover-card",...n}),e[2]=n,e[3]=r):r=e[3],r}function GS(t){const e=j.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=p.jsx(qS,{"data-slot":"hover-card-trigger",...n}),e[2]=n,e[3]=r):r=e[3],r}function YS(t){const e=j.c(12);let n,r,s,o;e[0]!==t?({className:n,align:s,sideOffset:o,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s,e[4]=o):(n=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"center":s,l=o===void 0?4:o;let a;e[5]!==n?(a=ee("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",n),e[5]=n,e[6]=a):a=e[6];let c;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==a?(c=p.jsx(US,{"data-slot":"hover-card-portal",children:p.jsx(KS,{"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 Lh=N.createContext(void 0);function XS(t,e){const n=e.split("."),r=n[0];if(!r)return;let s=t[r];for(let o=1;o<n.length&&s!==void 0;o++){const i=n[o];if(i)if(typeof s=="object"&&s!==null)s=s[i];else return}return s}function QS(t){const e=j.c(20),{node:n}=t,r=N.useContext(Lh),s=n.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const g=o?XS(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(zc,{as:"span",children:c}),e[6]=c,e[7]=g):g=e[7],g}let u;e[8]!==c?(u=p.jsx(GS,{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(YS,{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(zc,{as:"span",children:p.jsxs(JS,{openDelay:200,children:[u,h]})}),e[17]=u,e[18]=h,e[19]=m):m=e[19],m}function $h(t){const e=[];function n(r){for(const s of r)s.children?.length||e.push(s),s.children&&n(s.children)}return n(t),e}let nt=_h();function _h(){return pl(()=>({items:[],selectedIndex:0,command:null}))}function su(t,e){nt.setState({items:t,command:e,selectedIndex:0})}function ZS(){const{items:t,selectedIndex:e}=nt.getState();t.length&&nt.setState({selectedIndex:(e-1+t.length)%t.length})}function e2(){const{items:t,selectedIndex:e}=nt.getState();t.length&&nt.setState({selectedIndex:(e+1)%t.length})}function zh(){const{items:t,selectedIndex:e,command:n}=nt.getState(),r=t[e];return r?(n?.(r),!0):!1}function ou(){nt=_h()}function t2(){const t=j.c(7),e=wi(nt,r2),n=wi(nt,n2);if(!e.length)return null;let r;if(t[0]!==e||t[1]!==n){let o;t[3]!==n?(o=(i,l)=>p.jsx("button",{type:"button",onClick:()=>{nt.setState({selectedIndex:l}),zh()},className:ee("flex items-center w-full text-left px-3 py-1.5 text-sm rounded-md transition-colors",l===n?"bg-accent text-accent-foreground":"hover:bg-muted"),children:i.label},i.id),t[3]=n,t[4]=o):o=t[4],r=e.map(o),t[0]=e,t[1]=n,t[2]=r}else r=t[2];let s;return t[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})}),t[5]=r,t[6]=s):s=t[6],s}function n2(t){return t.selectedIndex}function r2(t){return t.items}function s2(){let t=null,e=null;return{onStart:n=>{su(n.items,n.command),t=new rh(t2,{editor:n.editor}),e=document.createElement("div"),e.style.cssText="position:absolute;z-index:9999";const r=n.clientRect?.();r&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`),e.appendChild(t.element),document.body.appendChild(e)},onUpdate:n=>{su(n.items,n.command);const r=n.clientRect?.();r&&e&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`)},onKeyDown:({event:n})=>n.key==="Escape"?(e?.remove(),t?.destroy(),ou(),!0):n.key==="ArrowUp"?(ZS(),!0):n.key==="ArrowDown"?(e2(),!0):n.key==="Enter"?zh():!1,onExit:()=>{e?.remove(),t?.destroy(),ou()}}}const bi=/@([\w.]+)/g;function o2(t,e){if(!t)return null;const n=$h(e),r=new Map(n.map(a=>[a.id,a]));if(!bi.test(t))return t;bi.lastIndex=0;const o=[];let i=0,l;for(;(l=bi.exec(t))!==null;){const a=l[1]??"",c=l.index;c>i&&o.push({type:"text",text:t.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<t.length&&o.push({type:"text",text:t.slice(i)}),{type:"doc",content:[{type:"paragraph",content:o.length>0?o:void 0}]}}function ra(t){const e=j.c(31),{mentions:n,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=t,a=C0();let c;e[0]!==n||e[1]!==r?(c=o2(r,n),e[0]=n,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=AS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let m;if(e[4]!==n||e[5]!==d){let E;e[7]!==n?(E=O=>{const{query:R}=O;return $h(n).filter(B=>B.label.toLowerCase().includes(R.toLowerCase())||B.id.toLowerCase().includes(R.toLowerCase()))},e[7]=n,e[8]=E):E=e[8],m=LS.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:c2,renderHTML:a2,suggestion:{items:E,render:s2,command:l2}}).extend(d?{addNodeView(){return Gw(QS)}}:{}),e[4]=n,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:i2},e[11]=y,e[12]=x):x=e[12];let b;e[13]!==s?(b=E=>{const{editor:O}=E;return s?.(O.getText().trim())},e[13]=s,e[14]=b):b=e[14];let k;e[15]!==u||e[16]!==f||e[17]!==g||e[18]!==x||e[19]!==b?(k={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]=k):k=e[20];const S=Vw(k);let w;e[21]!==i?(w=ee("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]=w):w=e[22];let C;e[23]!==S?(C=p.jsx(Pw,{editor:S}),e[23]=S,e[24]=C):C=e[24];let v;e[25]!==w||e[26]!==C?(v=p.jsx("div",{className:w,children:C}),e[25]=w,e[26]=C,e[27]=v):v=e[27];const M=v;if(a!==void 0){let E;return e[28]!==M||e[29]!==a?(E=p.jsx(Lh.Provider,{value:a,children:M}),e[28]=M,e[29]=a,e[30]=E):E=e[30],E}return M}function i2(t,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function l2(t){const{editor:e,range:n,props:r}=t;e.chain().focus().insertContentAt(n,[{type:"mention",attrs:r}]).run()}function a2(t){const{options:e,node:n}=t;return["span",e.HTMLAttributes,`@${n.attrs.id}`]}function c2(t){const{node:e}=t;return`@${e.attrs.id}`}function u2(t){const e=j.c(8),{value:n,onChange:r,placeholder:s,readonly:o}=t,i=Wu(),l=n??"";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(ra,{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 d2(t){const e=j.c(8),{value:n,onChange:r,placeholder:s,readonly:o}=t,i=Wu(),l=n??"";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(ra,{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 f2(t){const e=j.c(8),{value:n,onChange:r,readonly:s,id:o}=t,i=n??"";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=ee("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 h2(t){const e=j.c(13),{value:n,onChange:r,readonly:s,id:o,label:i}=t,l=n??!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 p2(t){const e=j.c(14),{value:n,onChange:r,readonly:s,id:o,options:i}=t;let l;e[0]!==i.enumOptions?(l=i.enumOptions??[],e[0]=i.enumOptions,e[1]=l):l=e[1];const a=l,c=n??"";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=ee("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(m2),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 m2(t){return p.jsx("option",{value:String(t.value),children:String(t.label)},String(t.value))}const g2={TextWidget:u2,TextareaWidget:d2,NumberWidget:f2,CheckboxWidget:h2,SelectWidget:p2};function y2(t){switch(Array.isArray(t)?t[0]:t??"unknown"){case"string":return{Icon:ku,color:"text-blue-500"};case"number":case"integer":return{Icon:xu,color:"text-blue-500"};case"array":return{Icon:gu,color:"text-purple-500"};case"object":return{Icon:mu,color:"text-orange-500"};case"boolean":return{Icon:bu,color:"text-pink-500"};case"null":return{Icon:sl,color:"text-gray-500"};default:return{Icon:yu,color:"text-muted-foreground"}}}function x2(t){const e=j.c(36),{id:n,label:r,required:s,description:o,children:i,schema:l,hidden:a}=t;if(a){let w;return e[0]!==i?(w=p.jsx("div",{className:"hidden",children:i}),e[0]=i,e[1]=w):w=e[1],w}if(n==="root"){let w;return e[2]!==i?(w=p.jsx("div",{className:"space-y-4",children:i}),e[2]=i,e[3]=w):w=e[3],w}const c=Array.isArray(l.type)?l.type[0]:l.type??"string";let u,d,f,h,m,g,y;if(e[4]!==n||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:w,color:C}=y2(c);y="space-y-2",h="flex items-center gap-2",e[15]!==n||e[16]!==r?(m=p.jsx("label",{htmlFor:n,className:"text-sm font-medium leading-none",children:r}),e[15]=n,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=w,d=14,f=ee(C,"ml-auto"),e[4]=n,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 k;e[29]!==o?(k=o&&p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=k):k=e[30];let S;return e[31]!==i||e[32]!==y||e[33]!==b||e[34]!==k?(S=p.jsxs("div",{className:y,children:[b,k,i]}),e[31]=i,e[32]=y,e[33]=b,e[34]=k,e[35]=S):S=e[35],S}function b2(t){const e=j.c(8),{properties:n,title:r}=t;if(!r||r==="Root"){let l;e[0]!==n?(l=n.map(w2),e[0]=n,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]!==n?(o=n.map(k2),e[4]=n,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 k2(t){return p.jsx("div",{children:t.content},t.name)}function w2(t){return p.jsx("div",{children:t.content},t.name)}function v2(t){const e=j.c(11),{items:n,canAdd:r,onAddClick:s,title:o}=t;let i;e[0]!==n?(i=n.map(S2),e[0]=n,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(ue,{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 S2(t){return p.jsx("div",{className:"flex gap-2 items-start",children:p.jsx("div",{className:"flex-1",children:t})},t.key||t.index)}function C2(){return null}function N2(){return null}const E2={FieldTemplate:x2,ObjectFieldTemplate:b2,ArrayFieldTemplate:v2,UnsupportedFieldTemplate:C2,ErrorListTemplate:N2};function T2(t){const e=j.c(6),{inputSchema:n,inputParams:r,mentions:s}=t;if(!n?.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(ra,{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]!==n.properties||e[4]!==i?(l=p.jsx("div",{className:"space-y-4",children:Object.entries(n.properties).map(a=>{const[c,u]=a,d=r[c];return i(c,d,u)})}),e[2]=r,e[3]=n.properties,e[4]=i,e[5]=l):l=e[5],l}function Bh({inputSchema:t,inputParams:e,setInputParams:n,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!t)return p.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return p.jsx(T2,{inputSchema:t,inputParams:e,mentions:i});const l=t,a=N.useRef(e??{}),c=u=>{const d=u.formData??{},f=a.current;if(n?.(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(Hu.Provider,{value:i,children:p.jsx(tm,{schema:l,formData:e,onChange:c,validator:nm,widgets:g2,templates:E2,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:p.jsx(p.Fragment,{})})})}function M2(t){const e=j.c(33),{open:n,onOpenChange:r,inputSchema:s,onSubmit:o,isPending:i}=t;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(am,{children:[p.jsx(cm,{children:"Workflow Input"}),p.jsx(um,{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(Bh,{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(ue,{variant:"outline",onClick:x,disabled:i,children:"Cancel"}),e[14]=i,e[15]=x,e[16]=b):b=e[16];let k;e[17]!==i?(k=i?p.jsx(Ln,{size:"xs"}):p.jsx(cl,{size:14}),e[17]=i,e[18]=k):k=e[18];let S;e[19]!==d||e[20]!==i||e[21]!==k?(S=p.jsxs(ue,{onClick:d,disabled:i,className:"gap-2",children:[k,"Run Workflow"]}),e[19]=d,e[20]=i,e[21]=k,e[22]=S):S=e[22];let w;e[23]!==S||e[24]!==b?(w=p.jsxs(dm,{children:[b,S]}),e[23]=S,e[24]=b,e[25]=w):w=e[25];let C;e[26]!==w||e[27]!==y?(C=p.jsxs(fm,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[m,y,w]}),e[26]=w,e[27]=y,e[28]=C):C=e[28];let v;return e[29]!==h||e[30]!==n||e[31]!==C?(v=p.jsx(hm,{open:n,onOpenChange:h,children:C}),e[29]=h,e[30]=n,e[31]=C,e[32]=v):v=e[32],v}function O2(t){const e=j.c(26),{title:n,description:r,onSave:s}=t,i=Qs().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:u}=gl(),{resetToOriginalWorkflow:d,setSelectedGatewayId:f}=je(),h=Du(),m=zn(),g=Oe();let y;e[0]!==n?(y=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:n}),e[0]=n,e[1]=y):y=e[1];let x;e[2]!==r?(x=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]=x):x=e[3];let b;e[4]!==y||e[5]!==x?(b=p.jsx(al,{children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[y,x]})}),e[4]=y,e[5]=x,e[6]=b):b=e[6];let k;e[7]!==h||e[8]!==s||e[9]!==d||e[10]!==m||e[11]!==f||e[12]!==a||e[13]!==c||e[14]!==n||e[15]!==u||e[16]!==g||e[17]!==i||e[18]!==l?(k=!g&&p.jsxs(p.Fragment,{children:[p.jsx(no,{title:n,url:i,icon:"workflow"}),p.jsx(N.Suspense,{fallback:p.jsx(Ln,{size:"xs"}),children:p.jsx(du,{selectedGatewayId:m??void 0,onGatewayChange:f,variant:"bordered",placeholder:"Select gateway"})}),p.jsx(im,{value:l,onValueChange:a,size:"sm",options:[{value:"visual",icon:p.jsx(lm,{})},{value:"code",icon:p.jsx(Su,{})}]}),p.jsx(Je,{children:p.jsxs(Ge,{delayDuration:0,children:[p.jsx(Ye,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:d,disabled:!h,"aria-label":"Reset changes",children:p.jsx(oo,{size:14})})})}),p.jsx(Xe,{side:"bottom",children:"Reset changes"})]})}),p.jsx(Je,{children:p.jsxs(Ge,{delayDuration:0,children:[p.jsx(Ye,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:!h,"aria-label":"Save workflow",children:p.jsx(io,{size:14})})})}),p.jsx(Xe,{side:"bottom",children:"Save workflow"})]})}),p.jsx(Je,{children:p.jsxs(Ge,{delayDuration:0,children:[p.jsx(Ye,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:c?"secondary":"outline",size:"icon",className:"size-7 border border-input",onClick:u,"aria-label":c?"Hide runs":"Show runs",children:p.jsx(vu,{size:14})})})}),p.jsx(Xe,{side:"bottom",children:c?"Hide runs":"Show runs"})]})})]}),e[7]=h,e[8]=s,e[9]=d,e[10]=m,e[11]=f,e[12]=a,e[13]=c,e[14]=n,e[15]=u,e[16]=g,e[17]=i,e[18]=l,e[19]=k):k=e[19];let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(j2,{}),e[20]=S):S=e[20];let w;e[21]!==k?(w=p.jsxs(so,{children:[k,S]}),e[21]=k,e[22]=w):w=e[22];let C;return e[23]!==b||e[24]!==w?(C=p.jsxs(p.Fragment,{children:[b,w]}),e[23]=b,e[24]=w,e[25]=C):C=e[25],C}function A2(){const t=Oe(),{item:e}=Bn(t);return e?.completed_at_epoch_ms!=null}function I2(){const t=Oe(),{item:e}=Bn(t);return e?.status==="cancelled"}function j2(){const t=j.c(57),e=Du(),n=A2(),r=I2(),s=Oe(),o=zn(),{handleRunWorkflow:i,isPending:l,requiresInput:a,inputSchema:c}=w0(),u=Er(),[d,f]=N.useState(!1),{handleCancelWorkflow:h,isCancelling:m}=v0(),{handleResumeWorkflow:g,isResuming:y}=S0(),x=s&&!n;let b;t[0]!==u?(b=u.some(R2),t[0]=u,t[1]=b):b=t[1];const k=b,S=!o,w=e||k||S||l||m,C=x||l;let v;t[2]!==k||t[3]!==S||t[4]!==e||t[5]!==r||t[6]!==C?(v=()=>r?"Workflow is currently cancelled":C?"Workflow is currently running":e?"Save your changes before running":S?"Select a gateway first":k?"Add at least one step to the workflow":null,t[2]=k,t[3]=S,t[4]=e,t[5]=r,t[6]=C,t[7]=v):v=t[7];const E=v();let O;t[8]!==h||t[9]!==g||t[10]!==i||t[11]!==c||t[12]!==r||t[13]!==C||t[14]!==a||t[15]!==s?(O=async()=>{if(a&&c){f(!0);return}if(r&&s){await g(s);return}if(C&&s){await h(s);return}await i({})},t[8]=h,t[9]=g,t[10]=i,t[11]=c,t[12]=r,t[13]=C,t[14]=a,t[15]=s,t[16]=O):O=t[16];const R=O;let L;t[17]!==i?(L=async le=>{await i(le)},t[17]=i,t[18]=L):L=t[18];const B=L,z=r?"Resume":s?n?"Replay":"Running...":a?"Run with input...":"Run workflow",D=!x&&"bg-primary text-primary-foreground hover:bg-primary/90";let T;t[19]!==D?(T=ee("gap-2 h-7 px-3",D),t[19]=D,t[20]=T):T=t[20];let _;t[21]!==m||t[22]!==r||t[23]!==l||t[24]!==y||t[25]!==x?(_=(!x&&!l&&!m&&!y||r)&&p.jsx(cl,{size:14}),t[21]=m,t[22]=r,t[23]=l,t[24]=y,t[25]=x,t[26]=_):_=t[26];let P;t[27]!==m||t[28]!==r||t[29]!==l||t[30]!==y||t[31]!==x?(P=x&&!l&&!m&&!y&&!r&&p.jsx(Lp,{size:14}),t[27]=m,t[28]=r,t[29]=l,t[30]=y,t[31]=x,t[32]=P):P=t[32];let U;t[33]!==m||t[34]!==l||t[35]!==y?(U=(l||m||y)&&p.jsx(Ln,{size:"xs"}),t[33]=m,t[34]=l,t[35]=y,t[36]=U):U=t[36];let G;t[37]!==z||t[38]!==R||t[39]!==w||t[40]!==T||t[41]!==_||t[42]!==P||t[43]!==U?(G=p.jsxs(ue,{variant:"default",size:"sm",className:T,disabled:w,onClick:R,children:[_,P,U,z]}),t[37]=z,t[38]=R,t[39]=w,t[40]=T,t[41]=_,t[42]=P,t[43]=U,t[44]=G):G=t[44];const F=G;let W;t[45]!==F||t[46]!==E?(W=E?p.jsx(Je,{children:p.jsxs(Ge,{delayDuration:0,children:[p.jsx(Ye,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:F})}),p.jsx(Xe,{side:"bottom",children:E})]})}):F,t[45]=F,t[46]=E,t[47]=W):W=t[47];const Q=W;let X;t[48]!==B||t[49]!==c||t[50]!==l||t[51]!==a||t[52]!==d?(X=a&&c&&p.jsx(M2,{open:d,onOpenChange:f,inputSchema:c,onSubmit:B,isPending:l}),t[48]=B,t[49]=c,t[50]=l,t[51]=a,t[52]=d,t[53]=X):X=t[53];let Y;return t[54]!==Q||t[55]!==X?(Y=p.jsxs(p.Fragment,{children:[Q,X]}),t[54]=Q,t[55]=X,t[56]=Y):Y=t[56],Y}function R2(t){return"toolName"in t.action&&(!t.action.toolName||t.action.toolName==="")}function D2(){const t=j.c(4),e=Oe(),n=Er(),{step_results:r,item:s}=Bn(e);if(!e||!s)return;let o;if(t[0]!==s||t[1]!==r||t[2]!==n){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;n.forEach((a,c)=>{const u=i.get(a.name);(u?.output!==void 0||u?.error!==void 0)&&(l=c)}),n.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}}),t[0]=s,t[1]=r,t[2]=n,t[3]=o}else o=t[3];return o}function P2(t){const e=j.c(111),{step:n,index:r,isSelected:s,executionStatus:o,isSkipped:i,isLastStep:l,onSelect:a,onDelete:c,onDuplicate:u}=t,d=Oe(),{item:f}=Bn(d),h=f?.completed_at_epoch_ms,m="toolName"in n.action,g=m&&"connectionId"in n.action?n.action.connectionId:null,x=!!(m&&"toolName"in n.action?n.action.toolName:null);let b,k,S,w,C,v,M,E,O,R,L;if(e[0]!==g||e[1]!==o||e[2]!==x||e[3]!==r||e[4]!==l||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==c||e[9]!==u||e[10]!==a||e[11]!==n||e[12]!==d){const _=U2(n);b=o?.status;const P=o!==void 0,U=b==="success"||b==="error";let G=_.length>0?60:12;(b==="success"||b==="error")&&(G=G+32);let F,W,Q;if(e[24]!==s||e[25]!==i||e[26]!==a||e[27]!==b){const Hn=_2(b);let Rr;e[36]!==b?(Rr=z2(b),e[36]=b,e[37]=Rr):Rr=e[37],F=Rr;const Ro=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",Do=b==="running"&&"bg-accent/50",Po=i&&"opacity-50";e[38]!==Ro||e[39]!==Do||e[40]!==Po?(v=ee("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",Ro,Do,Po),e[38]=Ro,e[39]=Do,e[40]=Po,e[41]=v):v=e[41],M=a,E="button",O=0,e[42]!==a?(R=Lo=>{(Lo.key==="Enter"||Lo.key===" ")&&(Lo.preventDefault(),a())},e[42]=a,e[43]=R):R=e[43],Q="w-5 flex flex-col items-center justify-center shrink-0 pt-3",W=ee("text-xs font-mono opacity-75 h-8 flex items-center",Hn),e[24]=s,e[25]=i,e[26]=a,e[27]=b,e[28]=F,e[29]=W,e[30]=Q,e[31]=v,e[32]=M,e[33]=E,e[34]=O,e[35]=R}else F=e[28],W=e[29],Q=e[30],v=e[31],M=e[32],E=e[33],O=e[34],R=e[35];const X=r+1;let Y;e[44]!==W||e[45]!==X?(Y=p.jsxs("span",{className:W,children:[X,"."]}),e[44]=W,e[45]=X,e[46]=Y):Y=e[46],e[47]!==Q||e[48]!==Y?(L=p.jsx("div",{className:Q,children:Y}),e[47]=Q,e[48]=Y,e[49]=L):L=e[49];let le;e[50]!==F||e[51]!==r?(le=r>0?p.jsx(ki,{height:12,color:F}):p.jsx("div",{className:"h-3"}),e[50]=F,e[51]=r,e[52]=le):le=e[52];let Ee;e[53]!==g||e[54]!==x||e[55]!==m||e[56]!==n.name?(Ee=p.jsx(W2,{connectionId:g,isToolStep:m,hasToolSelected:x,stepName:n.name}),e[53]=g,e[54]=x,e[55]=m,e[56]=n.name,e[57]=Ee):Ee=e[57];let We;e[58]!==F||e[59]!==U||e[60]!==b?(We=U&&p.jsxs(p.Fragment,{children:[p.jsx(ki,{height:8,color:F}),p.jsx(B2,{status:b})]}),e[58]=F,e[59]=U,e[60]=b,e[61]=We):We=e[61];let qe;e[62]!==F||e[63]!==G||e[64]!==l||e[65]!==d?(qe=l&&d?null:p.jsx(ki,{height:G,color:F}),e[62]=F,e[63]=G,e[64]=l,e[65]=d,e[66]=qe):qe=e[66],e[67]!==le||e[68]!==Ee||e[69]!==We||e[70]!==qe?(S=p.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[le,Ee,We,qe]}),e[67]=le,e[68]=Ee,e[69]=We,e[70]=qe,e[71]=S):S=e[71],k="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const Vn=x?"font-medium text-foreground":"text-foreground";let an;e[72]!==Vn?(an=ee("text-sm truncate flex-1",Vn),e[72]=Vn,e[73]=an):an=e[73];let cn;e[74]!==n?(cn=q2(n),e[74]=n,e[75]=cn):cn=e[75];let un;e[76]!==an||e[77]!==cn?(un=p.jsx("span",{className:an,children:cn}),e[76]=an,e[77]=cn,e[78]=un):un=e[78];let dn;e[79]!==P||e[80]!==b?(dn=P&&p.jsx(F2,{status:b}),e[79]=P,e[80]=b,e[81]=dn):dn=e[81];let fn;e[82]!==P||e[83]!==c||e[84]!==u?(fn=!P&&p.jsxs(pm,{children:[p.jsx(mm,{asChild:!0,children:p.jsx(ue,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:$2,children:p.jsx(Xp,{size:14})})}),p.jsxs(gm,{align:"end",children:[p.jsxs(ha,{onClick:Hn=>{Hn.stopPropagation(),u()},children:[p.jsx(bm,{size:14}),"Duplicate"]}),p.jsxs(ha,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:Hn=>{Hn.stopPropagation(),c()},children:[p.jsx(vp,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[82]=P,e[83]=c,e[84]=u,e[85]=fn):fn=e[85],e[86]!==un||e[87]!==dn||e[88]!==fn?(w=p.jsxs("div",{className:"flex items-center h-8",children:[un,dn,fn]}),e[86]=un,e[87]=dn,e[88]=fn,e[89]=w):w=e[89],C=_.length>0&&p.jsx("div",{className:"flex flex-wrap gap-1.5",children:_.map(L2)}),e[0]=g,e[1]=o,e[2]=x,e[3]=r,e[4]=l,e[5]=s,e[6]=i,e[7]=m,e[8]=c,e[9]=u,e[10]=a,e[11]=n,e[12]=d,e[13]=b,e[14]=k,e[15]=S,e[16]=w,e[17]=C,e[18]=v,e[19]=M,e[20]=E,e[21]=O,e[22]=R,e[23]=L}else b=e[13],k=e[14],S=e[15],w=e[16],C=e[17],v=e[18],M=e[19],E=e[20],O=e[21],R=e[22],L=e[23];let B;e[90]!==h||e[91]!==b?(B=b==="success"&&p.jsx(V2,{completedAtEpochMs:h}),e[90]=h,e[91]=b,e[92]=B):B=e[92];let z;e[93]!==o?.error||e[94]!==b?(z=b==="error"&&p.jsx(H2,{error:o?.error}),e[93]=o?.error,e[94]=b,e[95]=z):z=e[95];let D;e[96]!==k||e[97]!==B||e[98]!==z||e[99]!==w||e[100]!==C?(D=p.jsxs("div",{className:k,children:[w,C,B,z]}),e[96]=k,e[97]=B,e[98]=z,e[99]=w,e[100]=C,e[101]=D):D=e[101];let T;return e[102]!==S||e[103]!==D||e[104]!==v||e[105]!==M||e[106]!==E||e[107]!==O||e[108]!==R||e[109]!==L?(T=p.jsxs("div",{className:v,onClick:M,role:E,tabIndex:O,onKeyDown:R,children:[L,S,D]}),e[102]=S,e[103]=D,e[104]=v,e[105]=M,e[106]=E,e[107]=O,e[108]=R,e[109]=L,e[110]=T):T=e[110],T}function L2(t){return p.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:t},t)}function $2(t){return t.stopPropagation()}function _2(t){switch(t){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function z2(t){switch(t){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function B2(t){const e=j.c(2),{status:n}=t;if(n==="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(ll,{size:8,className:"text-success-foreground"})}),e[0]=r):r=e[0],r}if(n==="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(ul,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function F2(t){const e=j.c(3),{status:n}=t;if(n==="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(ll,{size:11,className:"text-success"})}),e[0]=r):r=e[0],r}if(n==="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(ul,{size:11,className:"text-destructive"})}),e[1]=r):r=e[1],r}if(n==="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(Qt,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function V2(t){const e=j.c(8),{completedAtEpochMs:n}=t;let r,s;if(e[0]!==n){const a=n!=null?new Date(n):null;r=a?a.toISOString().split("T")[0]:null,s=a?a.toTimeString().split(" ")[0]:null,e[0]=n,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(Gp,{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;return e[6]!==i?(l=p.jsx("div",{className:"inline-flex items-center gap-3 px-1.5 py-1 bg-success-foreground rounded-lg w-fit",children:i}),e[6]=i,e[7]=l):l=e[7],l}function H2(t){const e=j.c(3),{error:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(hl,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=n||"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 W2(t){const e=j.c(5),{connectionId:n,isToolStep:r,hasToolSelected:s,stepName:o}=t,i=il(n??"");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(to,{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(Mu,{size:16,className:"text-muted-foreground"}):p.jsx(xm,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function ki(t){const e=j.c(7),{height:n,color:r}=t,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=ee("w-px",s),e[0]=s,e[1]=o):o=e[1];let i;e[2]!==n?(i={height:n},e[2]=n,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 q2(t){return t.name?t.name:"toolName"in t.action&&t.action.toolName?t.action.toolName:"code"in t.action?t.name||"Code Step":"Select tool..."}function U2(t){const e=t.outputSchema;if(!e||typeof e!="object")return[];const n=e.properties;return!n||typeof n!="object"?[]:Object.keys(n).slice(0,5)}function K2(t){const e=j.c(32),{className:n}=t,r=Er(),s=Ru(),o=D2(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a}=je(),c=Oe();let u;e[0]!==o||e[1]!==r?(u=o?r.findIndex(k=>o[k.name]?.status==="error"):-1,e[0]=o,e[1]=r,e[2]=u):u=e[2];const d=u;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx("div",{children:"Loading..."}),e[3]=f):f=e[3];let h;e[4]!==n?(h=ee("h-full flex flex-col p-8 overflow-auto",n),e[4]=n,e[5]=h):h=e[5];let m;if(e[6]!==s||e[7]!==l||e[8]!==a||e[9]!==d||e[10]!==i||e[11]!==o||e[12]!==r){let k;e[14]!==s||e[15]!==l||e[16]!==a||e[17]!==d||e[18]!==i||e[19]!==o||e[20]!==r.length?(k=(S,w)=>{const C=o?.[S.name],v=d!==-1&&w>d&&C?.status==="pending",M=w===r.length-1;return p.jsx(P2,{step:S,index:w,isSelected:S.name===s,executionStatus:C,isSkipped:v,isLastStep:M,onSelect:()=>i(S.name),onDelete:()=>l(S.name),onDuplicate:()=>a(S.name)},S.name)},e[14]=s,e[15]=l,e[16]=a,e[17]=d,e[18]=i,e[19]=o,e[20]=r.length,e[21]=k):k=e[21],m=r.map(k),e[6]=s,e[7]=l,e[8]=a,e[9]=d,e[10]=i,e[11]=o,e[12]=r,e[13]=m}else m=e[13];let g;e[22]!==m?(g=p.jsx("div",{className:"pt-3 -space-y-1",children:m}),e[22]=m,e[23]=g):g=e[23];let y;e[24]!==c?(y=c?null:p.jsx(J2,{}),e[24]=c,e[25]=y):y=e[25];let x;e[26]!==g||e[27]!==y?(x=p.jsxs("div",{className:"w-full -space-y-1",children:[g,y]}),e[26]=g,e[27]=y,e[28]=x):x=e[28];let b;return e[29]!==h||e[30]!==x?(b=p.jsx(N.Suspense,{fallback:f,children:p.jsx("div",{className:h,children:x})}),e[29]=h,e[30]=x,e[31]=b):b=e[31],b}function J2(){const t=j.c(8),{addToolStep:e}=je();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=p.jsx("div",{className:"w-5 shrink-0"}),t[0]=n):n=t[0];let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"w-px h-3 bg-border"}),t[1]=r):r=t[1];let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx(ro,{size:14}),t[2]=s):s=t[2];let o;t[3]!==e?(o=p.jsx(ue,{variant:"outline",size:"icon",className:"size-8 rounded-lg",onClick:e,children:s}),t[3]=e,t[4]=o):o=t[4];let i;t[5]===Symbol.for("react.memo_cache_sentinel")?(i=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%"}}),t[5]=i):i=t[5];let l;return t[6]!==o?(l=p.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[n,p.jsxs("div",{className:"flex flex-col border-1 border-transparent items-center shrink-0",children:[r,o,i]})]}),t[6]=o,t[7]=l):l=t[7],l}function G2(){const t=j.c(5),e=zn();let n;t[0]!==e?(n=e?new URL(`/mcp/gateway/${e}`,window.location.origin).href:"",t[0]=e,t[1]=n):n=t[1];const r=n,s=!!e;let o;return t[2]!==r||t[3]!==s?(o={url:r,enabled:s},t[2]=r,t[3]=s,t[4]=o):o=t[4],dl(o)}function Y2(t){const e=j.c(7),{className:n}=t;if(!zn()){let o;e[0]!==n?(o=ee("flex flex-col h-full bg-sidebar",n),e[0]=n,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]!==n?(s=p.jsx(X2,{className:n}),e[5]=n,e[6]=s):s=e[6],s}function X2(t){const e=j.c(38),{className:n}=t,{tools:r,isLoading:s,error:o}=G2(),i=Nr(),{updateStep:l}=je(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let u;if(e[0]!==c||e[1]!==r){let w;e[3]!==c?(w=C=>C.name===c,e[3]=c,e[4]=w):w=e[4],u=r.find(w),e[0]=c,e[1]=r,e[2]=u}else u=e[2];const f=N0(r,u??null,Z2,Q2);let h;e[5]!==i||e[6]!==l?(h=w=>{i&&l(i.name,{action:{...i.action,toolName:w.name},outputSchema:w.outputSchema??{}})},e[5]=i,e[6]=l,e[7]=h):h=e[7];const m=h;if(s){let w;e[8]!==n?(w=ee("flex flex-col h-full bg-sidebar",n),e[8]=n,e[9]=w):w=e[9];let C;e[10]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx("div",{className:"flex-1 flex items-center justify-center",children:p.jsx(Ln,{size:"sm"})}),e[10]=C):C=e[10];let v;return e[11]!==w?(v=p.jsx("div",{className:w,children:C}),e[11]=w,e[12]=v):v=e[12],v}if(o){let w;e[13]!==n?(w=ee("flex flex-col h-full bg-sidebar",n),e[13]=n,e[14]=w):w=e[14];let C;e[15]!==o.message?(C=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]=C):C=e[16];let v;return e[17]!==w||e[18]!==C?(v=p.jsx("div",{className:w,children:C}),e[17]=w,e[18]=C,e[19]=v):v=e[19],v}let g;e[20]!==n?(g=ee("flex flex-col h-full bg-sidebar",n),e[20]=n,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 w;e[29]!==m||e[30]!==c?(w=C=>p.jsx(eC,{icon:null,title:C.name,description:C.description,isSelected:C.name===c,onClick:()=>m(C)},C.name),e[29]=m,e[30]=c,e[31]=w):w=e[31],b=f.map(w),e[25]=m,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let k;e[32]!==b?(k=p.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=k):k=e[33];let S;return e[34]!==g||e[35]!==x||e[36]!==k?(S=p.jsxs("div",{className:g,children:[x,k]}),e[34]=g,e[35]=x,e[36]=k,e[37]=S):S=e[37],S}function Q2(t,e){return t.name.localeCompare(e.name)}function Z2(t){return t.name}function eC(t){const e=j.c(20),{icon:n,title:r,description:s,isSelected:o,onClick:i}=t,l=o&&"bg-muted/50";let a;e[0]!==l?(a=ee("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]!==n||e[5]!==r?(u=p.jsx(to,{icon:n,name:r,size:"xs",className:"shadow-sm mt-0.5"}),e[4]=n,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 Ao="Collapsible",[tC,Fh]=tl(Ao),[nC,sa]=tC(Ao),Vh=N.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=t,[a,c]=Zs({prop:r,defaultProp:s??!1,onChange:i,caller:Ao});return p.jsx(nC,{scope:n,disabled:o,contentId:uu(),open:a,onOpenToggle:N.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Dn.div,{"data-state":ia(a),"data-disabled":o?"":void 0,...l,ref:e})})});Vh.displayName=Ao;var Hh="CollapsibleTrigger",Wh=N.forwardRef((t,e)=>{const{__scopeCollapsible:n,...r}=t,s=sa(Hh,n);return p.jsx(Dn.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":ia(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:Ue(t.onClick,s.onOpenToggle)})});Wh.displayName=Hh;var oa="CollapsibleContent",qh=N.forwardRef((t,e)=>{const{forceMount:n,...r}=t,s=sa(oa,t.__scopeCollapsible);return p.jsx(nl,{present:n||s.open,children:({present:o})=>p.jsx(rC,{...r,ref:e,present:o})})});qh.displayName=oa;var rC=N.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=t,i=sa(oa,n),[l,a]=N.useState(r),c=N.useRef(null),u=rl(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)},[]),Sp(()=>{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 k=b.getBoundingClientRect();d.current=k.height,h.current=k.width,y.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),a(r)}},[i.open,r]),p.jsx(Dn.div,{"data-state":ia(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,...t.style},children:g&&s})});function ia(t){return t?"open":"closed"}var sC=Vh,oC=Wh,iC=qh,Ze="Accordion",lC=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[la,aC,cC]=Cp(Ze),[Io]=tl(Ze,[cC,Fh]),aa=Fh(),Uh=Z.forwardRef((t,e)=>{const{type:n,...r}=t,s=r,o=r;return p.jsx(la.Provider,{scope:t.__scopeAccordion,children:n==="multiple"?p.jsx(hC,{...o,ref:e}):p.jsx(fC,{...s,ref:e})})});Uh.displayName=Ze;var[Kh,uC]=Io(Ze),[Jh,dC]=Io(Ze,{collapsible:!1}),fC=Z.forwardRef((t,e)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=t,[l,a]=Zs({prop:n,defaultProp:r??"",onChange:s,caller:Ze});return p.jsx(Kh,{scope:t.__scopeAccordion,value:Z.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:Z.useCallback(()=>o&&a(""),[o,a]),children:p.jsx(Jh,{scope:t.__scopeAccordion,collapsible:o,children:p.jsx(Gh,{...i,ref:e})})})}),hC=Z.forwardRef((t,e)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},...o}=t,[i,l]=Zs({prop:n,defaultProp:r??[],onChange:s,caller:Ze}),a=Z.useCallback(u=>l((d=[])=>[...d,u]),[l]),c=Z.useCallback(u=>l((d=[])=>d.filter(f=>f!==u)),[l]);return p.jsx(Kh,{scope:t.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:p.jsx(Jh,{scope:t.__scopeAccordion,collapsible:!0,children:p.jsx(Gh,{...o,ref:e})})})}),[pC,jo]=Io(Ze),Gh=Z.forwardRef((t,e)=>{const{__scopeAccordion:n,disabled:r,dir:s,orientation:o="vertical",...i}=t,l=Z.useRef(null),a=rl(l,e),c=aC(n),d=Np(s)==="ltr",f=Ue(t.onKeyDown,h=>{if(!lC.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 k=0,S=x-1,w=()=>{b=y+1,b>S&&(b=k)},C=()=>{b=y-1,b<k&&(b=S)};switch(h.key){case"Home":b=k;break;case"End":b=S;break;case"ArrowRight":o==="horizontal"&&(d?w():C());break;case"ArrowDown":o==="vertical"&&w();break;case"ArrowLeft":o==="horizontal"&&(d?C():w());break;case"ArrowUp":o==="vertical"&&C();break}const v=b%x;g[v].ref.current?.focus()});return p.jsx(pC,{scope:n,disabled:r,direction:s,orientation:o,children:p.jsx(la.Slot,{scope:n,children:p.jsx(Dn.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),Xs="AccordionItem",[mC,ca]=Io(Xs),Yh=Z.forwardRef((t,e)=>{const{__scopeAccordion:n,value:r,...s}=t,o=jo(Xs,n),i=uC(Xs,n),l=aa(n),a=uu(),c=r&&i.value.includes(r)||!1,u=o.disabled||t.disabled;return p.jsx(mC,{scope:n,open:c,disabled:u,triggerId:a,children:p.jsx(sC,{"data-orientation":o.orientation,"data-state":np(c),...l,...s,ref:e,disabled:u,open:c,onOpenChange:d=>{d?i.onItemOpen(r):i.onItemClose(r)}})})});Yh.displayName=Xs;var Xh="AccordionHeader",Qh=Z.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=jo(Ze,n),o=ca(Xh,n);return p.jsx(Dn.h3,{"data-orientation":s.orientation,"data-state":np(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});Qh.displayName=Xh;var Zi="AccordionTrigger",Zh=Z.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=jo(Ze,n),o=ca(Zi,n),i=dC(Zi,n),l=aa(n);return p.jsx(la.ItemSlot,{scope:n,children:p.jsx(oC,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});Zh.displayName=Zi;var ep="AccordionContent",tp=Z.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=jo(Ze,n),o=ca(ep,n),i=aa(n);return p.jsx(iC,{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)",...t.style}})});tp.displayName=ep;function np(t){return t?"open":"closed"}var gC=Uh,yC=Yh,xC=Qh,bC=Zh,kC=tp;function rp(t){const e=j.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=p.jsx(gC,{"data-slot":"accordion",...n}),e[2]=n,e[3]=r):r=e[3],r}function sp(t){const e=j.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n?(s=ee("border-b last:border-b-0",n),e[3]=n,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=p.jsx(yC,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function op(t){const e=j.c(11);let n,r,s;e[0]!==t?({className:r,children:n,...s}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s):(n=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=ee("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(ym,{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]!==n||e[8]!==s||e[9]!==o?(l=p.jsx(xC,{className:"flex",children:p.jsxs(bC,{"data-slot":"accordion-trigger",className:o,...s,children:[n,i]})}),e[7]=n,e[8]=s,e[9]=o,e[10]=l):l=e[10],l}function ip(t){const e=j.c(12);let n,r,s;e[0]!==t?({className:r,children:n,...s}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s):(n=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=ee("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==n||e[7]!==o?(i=p.jsx("div",{className:o,children:n}),e[6]=n,e[7]=o,e[8]=i):i=e[8];let l;return e[9]!==s||e[10]!==i?(l=p.jsx(kC,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...s,children:i}),e[9]=s,e[10]=i,e[11]=l):l=e[11],l}var wC=(t,e,n,r,s,o,i,l)=>{let a=document.documentElement,c=["light","dark"];function u(h){(Array.isArray(t)?t:[t]).forEach(m=>{let g=m==="class",y=g&&o?s.map(x=>o[x]||x):s;g?(a.classList.remove(...y),a.classList.add(o&&o[h]?o[h]:h)):a.setAttribute(m,h)}),d(h)}function d(h){l&&c.includes(h)&&(a.style.colorScheme=h)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)u(r);else try{let h=localStorage.getItem(e)||n,m=i&&h==="system"?f():h;u(m)}catch{}};N.createContext(void 0);N.memo(({forcedTheme:t,storageKey:e,attribute:n,enableSystem:r,enableColorScheme:s,defaultTheme:o,value:i,themes:l,nonce:a,scriptProps:c})=>{let u=JSON.stringify([n,e,o,t,l,i,r,s]).slice(1,-1);return N.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?a:"",dangerouslySetInnerHTML:{__html:`(${wC.toString()})(${u})`}})});function vC(t){const{updateStep:e}=je(),r=t&&"toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,{tool:s}=ua(r??"");t&&r&&s?.outputSchema&&(!t.outputSchema||Object.keys(t.outputSchema).length===0)&&queueMicrotask(()=>{e(t.name,{outputSchema:s.outputSchema})})}function SC(t){const e=j.c(23),{className:n}=t,r=Nr(),{appendStep:s}=je();if(vC(r),!r){let d;e[0]!==n?(d=ee("flex flex-col h-full bg-sidebar",n),e[0]=n,e[1]=d):d=e[1];let f;e[2]!==s?(f=()=>{s({type:"tool"})},e[2]=s,e[3]=f):f=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(ro,{size:14}),e[4]=h):h=e[4];let m;e[5]!==f?(m=p.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground gap-2 flex-col",children:["Select or create a step to configure",p.jsx(ue,{variant:"ghost",size:"icon",className:"size-7",onClick:f,children:h})]}),e[5]=f,e[6]=m):m=e[6];let g;return e[7]!==d||e[8]!==m?(g=p.jsx("div",{className:d,children:m}),e[7]=d,e[8]=m,e[9]=g):g=e[9],g}let o;e[10]!==n?(o=ee("flex flex-col h-full bg-sidebar overflow-auto",n),e[10]=n,e[11]=o):o=e[11];let i,l,a,c;e[12]!==r?(i=p.jsx(CC,{step:r}),l=p.jsx(EC,{step:r}),a=p.jsx(TC,{step:r}),c=p.jsx(jC,{step:r}),e[12]=r,e[13]=i,e[14]=l,e[15]=a,e[16]=c):(i=e[13],l=e[14],a=e[15],c=e[16]);let u;return e[17]!==o||e[18]!==i||e[19]!==l||e[20]!==a||e[21]!==c?(u=p.jsxs("div",{className:o,children:[i,l,a,c]}),e[17]=o,e[18]=i,e[19]=l,e[20]=a,e[21]=c,e[22]=u):u=e[22],u}function CC(t){const e=j.c(15),{step:n}=t,s="toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,o=Oe(),i=s??"";let l;e[0]!==i?(l=p.jsx(to,{icon:null,name:i,size:"xs",className:"shadow-sm"}),e[0]=i,e[1]=l):l=e[1];let a;e[2]!==s?(a=p.jsx("span",{className:"text-base font-medium text-foreground truncate flex-1",children:s}),e[2]=s,e[3]=a):a=e[3];let c;e[4]!==o?(c=o?null:p.jsx(NC,{}),e[4]=o,e[5]=c):c=e[5];let u;e[6]!==l||e[7]!==a||e[8]!==c?(u=p.jsxs("div",{className:"flex items-center gap-2",children:[l,a,c]}),e[6]=l,e[7]=a,e[8]=c,e[9]=u):u=e[9];let d;e[10]!==n.description?(d=n.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[10]=n.description,e[11]=d):d=e[11];let f;return e[12]!==u||e[13]!==d?(f=p.jsxs("div",{className:"border-b border-border p-5 shrink-0",children:[u,d]}),e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function NC(){const t=j.c(9),e=Nr(),{updateStep:n,startReplacingTool:r}=je(),s=Oe(),i=e&&"toolName"in e.action?e.action.toolName:null;let l;t[0]!==e||t[1]!==r||t[2]!==i||t[3]!==s||t[4]!==n?(l=()=>{if(e){if(s){lu.error("You cannot replace a tool while a workflow is executing.");return}i&&r(i),n(e.name,{action:{...e.action,toolName:""}})}},t[0]=e,t[1]=r,t[2]=i,t[3]=s,t[4]=n,t[5]=l):l=t[5];const a=l;let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(Tu,{size:14}),t[6]=c):c=t[6];let u;return t[7]!==a?(u=p.jsx(ue,{variant:"ghost",size:"icon",className:"size-7",onClick:a,title:"Replace tool",children:c}),t[7]=a,t[8]=u):u=t[8],u}function ua(t){const e=j.c(13),n=zn();let r;e[0]!==n?(r=n?new URL(`/mcp/gateway/${n}`,window.location.origin).href:"",e[0]=n,e[1]=r):r=e[1];const s=r,o=!!n;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=dl(i);let a;e[5]!==l.tools||e[6]!==t?(a=l.tools?.find(h=>h.name===t),e[5]=l.tools,e[6]=t,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 EC(t){const e=j.c(9),{step:n}=t,{updateStep:r}=je(),o="toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,{tool:i}=ua(o??"");if(!i||!i.inputSchema)return null;let l;e[0]!==n.name||e[1]!==r?(l=m=>{r(n.name,{input:m})},e[0]=n.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(op,{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=n.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(rp,{type:"single",collapsible:!0,defaultValue:"input",className:"border-b border-border shrink-0",children:p.jsxs(sp,{value:"input",className:"border-b-0",children:[c,p.jsx(ip,{className:"px-5 pt-2",children:p.jsx(Bh,{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 TC(t){const e=j.c(9),{step:n}=t,r=n.outputSchema,s=Oe(),{step_results:o}=Bn(s);let i;e[0]!==n.name||e[1]!==o?(i=o?.find(m=>m.step_id===n.name),e[0]=n.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(op,{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(rp,{type:"single",collapsible:!0,defaultValue:"output",className:"border-b border-border shrink-0",children:p.jsxs(sp,{value:"output",className:"border-b-0",children:[f,p.jsx(ip,{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(OC,{output:a}):p.jsx("div",{className:"space-y-2",children:d.map(MC)})})]})}),e[6]=a,e[7]=d,e[8]=h):h=e[8],h}function MC(t){const[e,n]=t;return p.jsx(IC,{name:e,schema:n},e)}function OC(t){const e=j.c(6),{output:n}=t;let r,s;e[0]!==n?(r=JSON.stringify(n,null,2),s=r.split(`
|
|
165
|
+
`),e[0]=n,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(ml,{code:r,language:"json",height:i,readOnly:!0}),e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function AC(t){switch(t){case"string":return{Icon:ku,color:"text-blue-500"};case"number":case"integer":return{Icon:xu,color:"text-blue-500"};case"array":return{Icon:gu,color:"text-purple-500"};case"object":return{Icon:mu,color:"text-orange-500"};case"boolean":return{Icon:bu,color:"text-pink-500"};case"null":return{Icon:sl,color:"text-gray-500"};default:return{Icon:yu,color:"text-muted-foreground"}}}function IC(t){const e=j.c(28),{name:n,schema:r}=t,s=Nr(),o=r.type??"unknown";let i,l,a,c,u;if(e[0]!==o){const{Icon:S,color:w}=AC(o);u="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=S,l=14,a=ee(w),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]!==n?(f=p.jsx("span",{className:"text-sm font-medium text-foreground",children:n}),e[10]=n,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(Cu,{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]!==n?(x=p.jsx("div",{className:"bg-blue-500/10 text-blue-500 px-1 py-0.5 rounded",children:n}),e[19]=n,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 k;return e[24]!==b||e[25]!==u||e[26]!==h?(k=p.jsxs("div",{className:u,children:[h,b]}),e[24]=b,e[25]=u,e[26]=h,e[27]=k):k=e[27],k}function jC(t){const e=j.c(29),{step:n}=t,{updateStep:r}=je(),s=Oe(),o="toolName"in n.action,i=o&&"toolName"in n.action?n.action.toolName:null,{tool:l}=ua(i??""),a=o&&"transformCode"in n.action?n.action.transformCode??null:null,c=!!a;let u;e[0]!==l?(u=()=>{if(!l?.outputSchema)return`interface Input {
|
|
166
|
+
// Tool output schema not available
|
|
167
|
+
}`;const M=l.outputSchema,E=M.properties;return E?`interface Input {
|
|
168
|
+
${Object.entries(E).map(R=>{const[L,B]=R,z=ns(B),D=!M.required?.includes(L);return` ${L}${D?"?":""}: ${z};`}).join(`
|
|
169
|
+
`)}
|
|
170
|
+
}`:`interface Input {
|
|
171
|
+
[key: string]: unknown;
|
|
172
|
+
}`},e[0]=l,e[1]=u):u=e[1];const d=u;let f;e[2]!==d||e[3]!==n.action||e[4]!==n.name||e[5]!==r?(f=()=>{const E=`${d()}
|
|
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(n.name,{action:{...n.action,transformCode:E}})},e[2]=d,e[3]=n.action,e[4]=n.name,e[5]=r,e[6]=f):f=e[6];const h=f;let m;e[7]!==n.action||e[8]!==n.name||e[9]!==r?(m=()=>{r(n.name,{action:{...n.action,transformCode:void 0}})},e[7]=n.action,e[8]=n.name,e[9]=r,e[10]=m):m=e[10];const g=m;let y;e[11]!==n.action||e[12]!==n.name||e[13]!==r?(y=(M,E)=>{r(n.name,{action:{...n.action,transformCode:M},...E?{outputSchema:E}:{}})},e[11]=n.action,e[12]=n.name,e[13]=r,e[14]=y):y=e[14];const x=y;if(!c){let M;e[15]===Symbol.for("react.memo_cache_sentinel")?(M=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(ro,{size:14,className:"text-muted-foreground"})]}),e[15]=M):M=e[15];let E;return e[16]!==h?(E=p.jsx("div",{className:"border-b border-border p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:h,children:M}),e[16]=h,e[17]=E):E=e[17],E}let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=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(Ep,{size:14,className:"text-muted-foreground"})]}),e[18]=b):b=e[18];let k;e[19]!==g?(k=p.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:g,children:b}),e[19]=g,e[20]=k):k=e[20];const S=`transform-code-${n.name}-${s}`,w=s!==void 0;let C;e[21]!==x||e[22]!==S||e[23]!==w||e[24]!==a?(C=p.jsx("div",{className:"flex-1 min-h-120",children:p.jsx(ml,{code:a,language:"typescript",readOnly:w,onSave:x,height:"100%"},S)}),e[21]=x,e[22]=S,e[23]=w,e[24]=a,e[25]=C):C=e[25];let v;return e[26]!==k||e[27]!==C?(v=p.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[k,C]}),e[26]=k,e[27]=C,e[28]=v):v=e[28],v}function ns(t){if(Array.isArray(t.type))return t.type.map(n=>ns({...t,type:n})).join(" | ");switch(t.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return t.items?`${ns(t.items)}[]`:"unknown[]";case"object":return t.properties?`{ ${Object.entries(t.properties).map(([r,s])=>{const o=ns(s),i=!t.required?.includes(r);return`${r}${i?"?":""}: ${o}`}).join("; ")} }`:"Record<string, unknown>";case"null":return"null";default:return"unknown"}}function RC(t){switch(t){case"success":return p.jsxs(hn,{variant:"success",className:"gap-1",children:[p.jsx(ll,{size:11}),"Success"]});case"error":case"failed":return p.jsxs(hn,{variant:"destructive",className:"gap-1",children:[p.jsx(hl,{size:11}),"Error"]});case"running":return p.jsxs(hn,{variant:"secondary",className:"gap-1",children:[p.jsx(Yr,{size:11}),"Running"]});case"enqueued":return p.jsxs(hn,{variant:"secondary",className:"gap-1",children:[p.jsx(Yr,{size:11}),"On hold"]});case"cancelled":return p.jsxs(hn,{variant:"secondary",className:"gap-1",children:[p.jsx(pu,{size:11}),"Cancelled"]});default:return p.jsxs(hn,{variant:"secondary",className:"gap-1",children:[p.jsx(Yr,{size:11}),t]})}}function DC(t){return`Run #${t.slice(-4).toUpperCase()}`}function PC(t){const e=j.c(21),{className:n}=t,{executions:r,isLoading:s}=g0(),{setShowExecutionsList:o}=gl(),{setTrackingExecutionId:i}=je(),l=Oe();let a;e[0]!==i?(a=k=>{i(k)},e[0]=i,e[1]=a):a=e[1];const c=a;let u;e[2]!==o?(u=()=>{o(!1)},e[2]=o,e[3]=u):u=e[3];const d=u;let f;e[4]!==n?(f=ee("flex flex-col h-full bg-sidebar border-l border-border",n),e[4]=n,e[5]=f):f=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:"Runs"}),e[6]=h):h=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(pu,{size:11}),e[7]=m):m=e[7];let g;e[8]!==d?(g=p.jsxs("div",{className:"flex items-center h-12 px-5 border-b border-border shrink-0",children:[h,p.jsx(ue,{variant:"ghost",size:"icon",className:"size-7",onClick:d,children:m})]}),e[8]=d,e[9]=g):g=e[9];let y;e[10]!==r||e[11]!==c||e[12]!==s||e[13]!==l?(y=s?p.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading executions..."}):r.map((k,S)=>p.jsx(LC,{execution:k,isSelected:k.id===l,isFirst:S===0,onSelect:()=>c(k.id)},k.id)),e[10]=r,e[11]=c,e[12]=s,e[13]=l,e[14]=y):y=e[14];let x;e[15]!==y?(x=p.jsx("div",{className:"flex-1 overflow-auto",children:y}),e[15]=y,e[16]=x):x=e[16];let b;return e[17]!==f||e[18]!==g||e[19]!==x?(b=p.jsxs("div",{className:f,children:[g,x]}),e[17]=f,e[18]=g,e[19]=x,e[20]=b):b=e[20],b}function LC(t){const e=j.c(17),{execution:n,isSelected:r,isFirst:s,onSelect:o}=t,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=ee("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]!==n.status?(u=RC(n.status),e[4]=n.status,e[5]=u):u=e[5];let d;e[6]!==n.id?(d=DC(n.id),e[6]=n.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]!==u||e[11]!==f?(h=p.jsxs("div",{className:"flex items-center gap-2 w-full",children:[u,f]}),e[10]=u,e[11]=f,e[12]=h):h=e[12];let m;return e[13]!==o||e[14]!==c||e[15]!==h?(m=p.jsx("div",{className:c,onClick:o,children:h}),e[13]=o,e[14]=c,e[15]=h,e[16]=m):m=e[16],m}function $C(t){const e=j.c(10),{itemId:n,mode:r}=t;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}=Rn(s),i=o??mt;let l;e[1]!==i?(l=ot(i),e[1]=i,e[2]=l):l=e[2];const a=l,c=r==="workflow"?"WORKFLOW":"WORKFLOW_EXECUTION",u=ol(i,c,n,a),d=eo(i,c,a);let f;e[3]!==d||e[4]!==n?(f=async y=>{await d.update.mutateAsync({id:n,data:y})},e[3]=d,e[4]=n,e[5]=f):f=e[5];const h=f,m=r==="execution"?n:void 0;let g;return e[6]!==u||e[7]!==m||e[8]!==h?(g={item:u,update:h,trackingExecutionId:m},e[6]=u,e[7]=m,e[8]=h,e[9]=g):g=e[9],g}function lp(t){const e=j.c(22),{itemId:n,onBack:r,mode:s}=t;let o;e[0]!==n||e[1]!==s?(o={itemId:n,mode:s},e[0]=n,e[1]=s,e[2]=o):o=e[2];const{item:i,update:l,trackingExecutionId:a}=$C(o);let c;e[3]!==i?(c=JSON.stringify(i),e[3]=i,e[4]=c):c=e[4];const u=c;if(!i){let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(vr,{title:"Workflow not found",description:"This workflow may have been deleted or you may not have access to it."})}),e[5]=b):b=e[5];let k;return e[6]!==r?(k=p.jsx(Nn,{onBack:r,children:b}),e[6]=r,e[7]=k):k=e[7],k}const d=i.description??void 0;let f;e[8]!==i||e[9]!==d?(f={...i,description:d},e[8]=i,e[9]=d,e[10]=f):f=e[10];const h=f,m=s==="execution"?"action":"executions";let g;e[11]!==m||e[12]!==a||e[13]!==h?(g={workflow:h,trackingExecutionId:a,currentStepTab:m},e[11]=m,e[12]=a,e[13]=h,e[14]=g):g=e[14];let y;e[15]!==r||e[16]!==l?(y=p.jsx(FC,{onBack:r,onUpdate:l}),e[15]=r,e[16]=l,e[17]=y):y=e[17];let x;return e[18]!==u||e[19]!==g||e[20]!==y?(x=p.jsx(Ug,{initialState:g,children:y},u),e[18]=u,e[19]=g,e[20]=y,e[21]=x):x=e[21],x}function _C(t){const e=j.c(2);let n;return e[0]!==t?(n=p.jsx(lp,{...t,mode:"workflow"}),e[0]=t,e[1]=n):n=e[1],n}function zC(t){const e=j.c(18),{workflow:n,onUpdate:r}=t,{setWorkflow:s}=je();let o,i,l,a;if(e[0]!==n.description||e[1]!==n.id||e[2]!==n.steps||e[3]!==n.title){const d={title:n.title,description:n.description,steps:n.steps};o=ml,i=`workflow-${n.id}`,l="100%",a=JSON.stringify(d,null,2),e[0]=n.description,e[1]=n.id,e[2]=n.steps,e[3]=n.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]!==n?(c=d=>{const f=JSON.parse(d);s({...n,...f}),r(f)},e[8]=r,e[9]=s,e[10]=n,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 BC(){const t=j.c(12),{setTrackingExecutionId:e}=je(),n=Oe();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"flex items-center justify-center h-full w-12",children:p.jsx(Tp,{className:"w-4 h-4 text-muted-foreground"})}),t[0]=r):r=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx("strong",{className:"text-base text-foreground",children:"Run"}),t[1]=s):s=t[1];let o;t[2]!==n?(o=p.jsxs("div",{className:"flex items-center h-full",children:[r,p.jsxs("p",{className:"flex gap-3 items-center h-full",children:[s,p.jsxs("span",{className:"text-sm text-muted-foreground",children:["#",n]})]})]}),t[2]=n,t[3]=o):o=t[3];let i;t[4]!==e?(i=()=>e(void 0),t[4]=e,t[5]=i):i=t[5];let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(sl,{className:"w-4 h-4 text-muted-foreground"}),t[6]=l):l=t[6];let a;t[7]!==i?(a=p.jsx(ue,{variant:"ghost",size:"xs",onClick:i,children:l}),t[7]=i,t[8]=a):a=t[8];let c;return t[9]!==o||t[10]!==a?(c=p.jsxs("div",{className:"h-10 bg-accent flex items-center justify-between border-b border-border",children:[o,a]}),t[9]=o,t[10]=a,t[11]=c):c=t[11],c}function FC(t){const e=j.c(24),{onBack:n,onUpdate:r}=t,s=_n(),o=Oe(),{setOriginalWorkflow:i}=je(),{viewMode:l,showExecutionsList:a}=gl(),c=Nr();let u;e[0]!==r||e[1]!==i||e[2]!==s?(u=async()=>{await r(s),i(s)},e[0]=r,e[1]=i,e[2]=s,e[3]=u):u=e[3];const d=u,f=c&&"toolName"in c.action,h=f?c.action.toolName:null,m=f&&!h&&!o,g=!m&&(c||o||!a);let y;e[4]!==d||e[5]!==s.description||e[6]!==s.title?(y=p.jsx(O2,{title:s.title,description:s.description,onSave:d}),e[4]=d,e[5]=s.description,e[6]=s.title,e[7]=y):y=e[7];let x;e[8]!==o?(x=o&&p.jsx(BC,{}),e[8]=o,e[9]=x):x=e[9];let b;e[10]!==r||e[11]!==a||e[12]!==g||e[13]!==m||e[14]!==l||e[15]!==s?(b=p.jsx("div",{className:"flex-1 overflow-hidden",children:l==="code"?p.jsx(zC,{workflow:s,onUpdate:r}):p.jsxs($p,{direction:"horizontal",className:"flex w-full h-full",children:[p.jsx(fa,{defaultSize:50,minSize:30,children:p.jsx(K2,{})}),p.jsx(_p,{}),p.jsxs(fa,{defaultSize:50,minSize:25,children:[m&&p.jsx(Y2,{className:"border-l border-border"}),a&&p.jsx(PC,{}),g&&p.jsx(SC,{className:"border-l border-border"})]})]})}),e[10]=r,e[11]=a,e[12]=g,e[13]=m,e[14]=l,e[15]=s,e[16]=b):b=e[16];let k;e[17]!==y||e[18]!==x||e[19]!==b?(k=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]=k):k=e[20];let S;return e[21]!==n||e[22]!==k?(S=p.jsx(Nn,{onBack:n,children:k}),e[21]=n,e[22]=k,e[23]=S):S=e[23],S}function VC(t){const e=j.c(2);let n;return e[0]!==t?(n=p.jsx(lp,{...t,mode:"execution"}),e[0]=t,e[1]=n):n=e[1],n}const HC={workflow:_C,workflow_execution:VC,assistant:xg,prompt:Ng};function WC(){const t=j.c(6),e=el();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},t[0]=n):n=t[0];const r=Rn(n),s=decodeURIComponent(r.itemId);let o;t[1]!==e.history?(o=()=>{e.history.back()},t[1]=e.history,t[2]=o):o=t[2];const i=o,l=qC;let a;return t[3]!==i||t[4]!==s?(a=p.jsx(Rg,{itemId:s,onBack:i,onUpdate:l}),t[3]=i,t[4]=s,t[5]=a):a=t[5],a}async function qC(t){return Promise.resolve()}function UC(){const t=j.c(18),e=el();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},t[0]=n):n=t[0];const r=Rn(n),s=r.connectionId,o=decodeURIComponent(r.collectionName),i=decodeURIComponent(r.itemId);let l;t[1]!==e.history?(l=()=>{e.history.back()},t[1]=e.history,t[2]=l):l=t[2];const a=l,c=s??mt;let u;t[3]!==c?(u=ot(c),t[3]=c,t[4]=u):u=t[4];const f=eo(c,o,u);let h;t[5]!==f||t[6]!==i?(h=async S=>{i&&await f.update.mutateAsync({id:i,data:S})},t[5]=f,t[6]=i,t[7]=h):h=t[7];const m=h;let g;t[8]!==o?(g=o?.toLowerCase(),t[8]=o,t[9]=g):g=t[9];const y=g,x=y&&HC[y];if(x){let S;return t[10]!==x||t[11]!==a||t[12]!==m||t[13]!==i?(S=p.jsx(x,{itemId:i,onBack:a,onUpdate:m}),t[10]=x,t[11]=a,t[12]=m,t[13]=i,t[14]=S):S=t[14],S}let b;t[15]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx(Op,{size:36,className:"text-muted-foreground"}),t[15]=b):b=t[15];let k;return t[16]!==a?(k=p.jsx(rm,{icon:b,title:"No component defined",description:"No component for this collection was defined",buttonProps:{onClick:a,children:"Go back"}}),t[16]=a,t[17]=k):k=t[17],k}function KC(){const t=j.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},t[0]=e):e=t[0];const n=Rn(e);if(decodeURIComponent(n.collectionName)==="tools"){let i;return t[1]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(WC,{}),t[1]=i):i=t[1],i}let o;return t[2]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(UC,{}),t[2]=o):o=t[2],o}function ZN(){const t=j.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=p.jsx(cr,{children:p.jsx(N.Suspense,{fallback:p.jsx("div",{className:"flex h-full items-center justify-center",children:p.jsx(Qt,{size:32,className:"animate-spin text-muted-foreground"})}),children:p.jsx(KC,{})})}),t[0]=e):e=t[0],e}export{ZN as default};
|