@decocms/mesh 1.8.0 → 1.9.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.
Files changed (117) hide show
  1. package/dist/client/assets/{AlertCircle-CoA9j9_b.js → AlertCircle-BrGqb-qb.js} +1 -1
  2. package/dist/client/assets/{ArrowLeft-Bu1JR7vY.js → ArrowLeft-B6h573ak.js} +1 -1
  3. package/dist/client/assets/{ChevronDown-BmUd-Gap.js → ChevronDown-BuogCeI0.js} +1 -1
  4. package/dist/client/assets/{Clock-BGOqsAv_.js → Clock-LzAlJ-1R.js} +1 -1
  5. package/dist/client/assets/{Code01-C4I9q0rm.js → Code01-Wll8WS4F.js} +1 -1
  6. package/dist/client/assets/{Copy01-D_YhbDiF.js → Copy01-_s71W2Ph.js} +1 -1
  7. package/dist/client/assets/{CpuChip02-BkDt7iNK.js → CpuChip02-BwTl0fBj.js} +1 -1
  8. package/dist/client/assets/{DotsVertical-CxdZClGh.js → DotsVertical-BQk5hPxb.js} +1 -1
  9. package/dist/client/assets/{File06-BdMasDPT.js → File06-CpSSTggW.js} +1 -1
  10. package/dist/client/assets/{FlipBackward-B34yEzR2.js → FlipBackward-C0O2fx27.js} +1 -1
  11. package/dist/client/assets/{GitBranch01-D2Rua42v.js → GitBranch01-DjmPf135.js} +1 -1
  12. package/dist/client/assets/{Grid01-Bom2qqwm.js → Grid01-CmB5R6oU.js} +1 -1
  13. package/dist/client/assets/{Inbox01-Arx8J2Oq.js → Inbox01-Ct-8Lwpv.js} +1 -1
  14. package/dist/client/assets/{InfoCircle-BYXT4R1l.js → InfoCircle-D6JXYJn_.js} +1 -1
  15. package/dist/client/assets/{Key01-D0WGLaST.js → Key01-ZVAVplBN.js} +1 -1
  16. package/dist/client/assets/{LinkExternal01-LVkx-wZF.js → LinkExternal01-DfHTXuZ9.js} +1 -1
  17. package/dist/client/assets/{Loading01-Dw6V1r3u.js → Loading01-0wYmSKV6.js} +1 -1
  18. package/dist/client/assets/{Lock01-Dw2P1WZh.js → Lock01-D5nrmOSx.js} +1 -1
  19. package/dist/client/assets/{Play-BRRssd_q.js → Play-BedrzKsi.js} +1 -1
  20. package/dist/client/assets/{Plus-CQSfshmp.js → Plus-DofiSAMU.js} +1 -1
  21. package/dist/client/assets/{SearchMd-CGUWNVUr.js → SearchMd-D70t5LVP.js} +1 -1
  22. package/dist/client/assets/{Terminal-CIo_ltVk.js → Terminal-CStBCUAd.js} +1 -1
  23. package/dist/client/assets/{Trash01-BgGiU9JZ.js → Trash01-DnTS63e5.js} +1 -1
  24. package/dist/client/assets/{X-CsW5kmRT.js → X-DeVUfdHG.js} +1 -1
  25. package/dist/client/assets/{XClose-D2IdV8gs.js → XClose-5A0s2w1d.js} +1 -1
  26. package/dist/client/assets/{alert-dialog-rSIOP2OM.js → alert-dialog-BU8uTWb8.js} +1 -1
  27. package/dist/client/assets/{auth-D6vm_lfk.js → auth-DpA5_jth.js} +1 -1
  28. package/dist/client/assets/{auth-catchall-lDj0BXu4.js → auth-catchall-2WBu6I6H.js} +1 -1
  29. package/dist/client/assets/{avatar-C45Lgbwv.js → avatar-KDpJ2jsd.js} +1 -1
  30. package/dist/client/assets/{badge-Z-ujar-h.js → badge-CStgouQf.js} +1 -1
  31. package/dist/client/assets/{button-DMnSM5FV.js → button-IijH0wdI.js} +1 -1
  32. package/dist/client/assets/{card-DL_e-uTF.js → card-BnWpolEI.js} +1 -1
  33. package/dist/client/assets/{checkbox-SCLb_n1h.js → checkbox-BYeNlYdH.js} +1 -1
  34. package/dist/client/assets/collection-detail-DnxFiEu9.js +165 -0
  35. package/dist/client/assets/{collection-display-button-BbSV76WH.js → collection-display-button-2ZQ5sQTW.js} +1 -1
  36. package/dist/client/assets/{collection-header-CqO1LmKH.js → collection-header-DBUE7n6H.js} +1 -1
  37. package/dist/client/assets/{collection-page-DDVR6yeu.js → collection-page-BHk1uJKe.js} +1 -1
  38. package/dist/client/assets/{collection-search-BOBOP2ro.js → collection-search-CM9rltH6.js} +1 -1
  39. package/dist/client/assets/{collection-tab-CNlP707v.js → collection-tab-ClOnLgHC.js} +1 -1
  40. package/dist/client/assets/{collection-table-wrapper-ByX0J-nn.js → collection-table-wrapper-BRI7T6RJ.js} +1 -1
  41. package/dist/client/assets/{connection-card-CZFyOgeO.js → connection-card-DMv3uM_n.js} +1 -1
  42. package/dist/client/assets/{connection-detail-oL5IGO2h.js → connection-detail-Cs5NpuH7.js} +1 -1
  43. package/dist/client/assets/{connections-BKlzJU2y.js → connections-DSbytdP0.js} +1 -1
  44. package/dist/client/assets/constants-TKUQnnwA.js +1 -0
  45. package/dist/client/assets/{create-organization-dialog-lmQ3mepV.js → create-organization-dialog-DbNHSUuq.js} +1 -1
  46. package/dist/client/assets/{dialog-B1fXXmBI.js → dialog-CJsBFVDy.js} +1 -1
  47. package/dist/client/assets/{dropdown-menu-gRHakuHp.js → dropdown-menu-BvLCKekW.js} +1 -1
  48. package/dist/client/assets/{empty-state-BiqF__Lu.js → empty-state-Bg-FRZa4.js} +1 -1
  49. package/dist/client/assets/{env-vars-editor-Br0Q2jee.js → env-vars-editor-Z7SwcUr8.js} +1 -1
  50. package/dist/client/assets/{error-boundary-CUq8HVcH.js → error-boundary-CsEoagci.js} +1 -1
  51. package/dist/client/assets/{extract-connection-data-DsJuSGHU.js → extract-connection-data-BgA1QcA6.js} +1 -1
  52. package/dist/client/assets/{form-BbwJs-Od.js → form-BjarY-Jq.js} +1 -1
  53. package/dist/client/assets/{formatDistanceToNow-jHI_IOun.js → formatDistanceToNow-fhdySMxO.js} +1 -1
  54. package/dist/client/assets/gateway-detail-DeFxNps5.js +1 -0
  55. package/dist/client/assets/{gateways-BfCNNBIO.js → gateways-CXlSFkKr.js} +1 -1
  56. package/dist/client/assets/{home-oGaB9rtf.js → home-BXCs6vTQ.js} +1 -1
  57. package/dist/client/assets/index-9pHY4m3c.css +1 -0
  58. package/dist/client/assets/{index-B1eBXzBF.js → index-BGEzzv-W.js} +1 -1
  59. package/dist/client/assets/{index-BVHhSH8M.js → index-BLgTJ8o3.js} +2 -2
  60. package/dist/client/assets/{index-BbK2Byrj.js → index-B_OB0BCO.js} +1 -1
  61. package/dist/client/assets/{index-BMIizA12.js → index-CRGUNI2v.js} +1 -1
  62. package/dist/client/assets/{input-C6vwKKeq.js → input-BxywPo2X.js} +1 -1
  63. package/dist/client/assets/{layout-m8iq6RWE.js → layout-Dfp1nH3g.js} +1 -1
  64. package/dist/client/assets/lazy-highlighter-DYlTa9LA.js +9 -0
  65. package/dist/client/assets/{localstorage-keys-BB9xpX5T.js → localstorage-keys-Bj9V9Nbd.js} +1 -1
  66. package/dist/client/assets/{login-CevUioqo.js → login-BfaeBzql.js} +1 -1
  67. package/dist/client/assets/{mcp-oauth-CE6Gg3ul.js → mcp-oauth-Vd_yzV5S.js} +1 -1
  68. package/dist/client/assets/{members-CAJLI1Ui.js → members-fIe1QSNh.js} +1 -1
  69. package/dist/client/assets/monaco-editor-mQfzbJMr.js +19 -0
  70. package/dist/client/assets/monitoring-I1RqzeAN.js +4 -0
  71. package/dist/client/assets/{oauth-callback-DnSysdpG.js → oauth-callback-Cwog6Jzh.js} +1 -1
  72. package/dist/client/assets/{page-jzi_ERcf.js → page-BVptnX4j.js} +2 -2
  73. package/dist/client/assets/{pin-to-sidebar-button-DonhySMf.js → pin-to-sidebar-button-C8t5xznu.js} +1 -1
  74. package/dist/client/assets/{popover-BO5GT9tA.js → popover-CwHNob2q.js} +1 -1
  75. package/dist/client/assets/{resizable-DpISfhV6.js → resizable-DybyPt6-.js} +1 -1
  76. package/dist/client/assets/{resource-tabs-JMDBPJhv.js → resource-tabs-s0IiCCzU.js} +1 -1
  77. package/dist/client/assets/{responsive-select-BZGantuu.js → responsive-select-INSf3elv.js} +1 -1
  78. package/dist/client/assets/{select-mD7lFwRj.js → select-C0rvNlZx.js} +1 -1
  79. package/dist/client/assets/{settings-iXHGs-4V.js → settings-3Or8ShnF.js} +1 -1
  80. package/dist/client/assets/{shell-layout-C1VOF_px.js → shell-layout-4x0MHQQc.js} +1 -1
  81. package/dist/client/assets/{spinner-D7to-RHc.js → spinner-D7ZAVJCR.js} +1 -1
  82. package/dist/client/assets/{store-C7bepdKu.js → store-Bl_0XUq8.js} +1 -1
  83. package/dist/client/assets/{store-app-detail-dqrfmC2K.js → store-app-detail--3qLKygc.js} +1 -1
  84. package/dist/client/assets/{switch-CpJO-7Kf.js → switch-D37mVt_9.js} +1 -1
  85. package/dist/client/assets/{textarea-Dma5FaAA.js → textarea-DNeEC-Sl.js} +1 -1
  86. package/dist/client/assets/{thread-history-popover-DTmh-wTW.js → thread-history-popover-CykPOF9f.js} +14 -14
  87. package/dist/client/assets/{tools-list-DJTZFgWM.js → tools-list-CFmwpEf4.js} +1 -1
  88. package/dist/client/assets/{tooltip-DiQ9SlNX.js → tooltip-CSuczTFq.js} +1 -1
  89. package/dist/client/assets/{types-Bq0bBlbx.js → types-CJK7iTsI.js} +2 -2
  90. package/dist/client/assets/{use-binding-DQTEUjPl.js → use-binding-C5e_Y70M.js} +1 -1
  91. package/dist/client/assets/{use-connection-DUMeVexv.js → use-connection-CsPrFY0x.js} +1 -1
  92. package/dist/client/assets/{use-connection-resources-GqC2zg91.js → use-connection-resources-CjjFKWSM.js} +1 -1
  93. package/dist/client/assets/{use-gateway-pQG4iSzq.js → use-gateway-Bz_y7oh7.js} +1 -1
  94. package/dist/client/assets/{use-list-state-DKjekACN.js → use-list-state-B13SO1z3.js} +1 -1
  95. package/dist/client/assets/{use-mcp-CaAgRxkf.js → use-mcp-CPBDJGOj.js} +1 -1
  96. package/dist/client/assets/{use-members-Cxbw-nUt.js → use-members-b3tDRslY.js} +1 -1
  97. package/dist/client/assets/{use-mobile-C2teUdDI.js → use-mobile-VYFif8jU.js} +1 -1
  98. package/dist/client/assets/{use-organization-settings-B-bw0Nsb.js → use-organization-settings-i4aS_Egu.js} +1 -1
  99. package/dist/client/assets/{use-tool-call-BwHyofVZ.js → use-tool-call-BdbJ3oy8.js} +1 -1
  100. package/dist/client/assets/useQuery-DXchCtgN.js +1 -0
  101. package/dist/client/assets/{useSuspenseInfiniteQuery-WWHYgeeq.js → useSuspenseInfiniteQuery-BLpBJxLd.js} +1 -1
  102. package/dist/client/assets/{view-mode-toggle-DCDdw_zu.js → view-mode-toggle-BXo-WMnB.js} +1 -1
  103. package/dist/client/assets/{workflow-nViVDMOR.js → workflow-wGJTSVc-.js} +1 -1
  104. package/dist/client/index.html +2 -2
  105. package/package.json +1 -3
  106. package/dist/client/assets/collection-detail-DZRR92ph.js +0 -183
  107. package/dist/client/assets/constants-C4MXZrmv.js +0 -1
  108. package/dist/client/assets/core-D9xILP6l.js +0 -6
  109. package/dist/client/assets/gateway-detail-CvVf3uBW.js +0 -1
  110. package/dist/client/assets/index-B3GsxHkT.css +0 -1
  111. package/dist/client/assets/json-BESjz4hO.js +0 -1
  112. package/dist/client/assets/json-GXJs871j.js +0 -1
  113. package/dist/client/assets/json-syntax-highlighter-C3W2DACo.js +0 -2
  114. package/dist/client/assets/lazy-highlighter-C7qLCeM-.js +0 -4
  115. package/dist/client/assets/monitoring-_9gwma-O.js +0 -4
  116. package/dist/client/assets/prism-light-WCI-7yyK.js +0 -1
  117. package/dist/client/assets/useQuery-C3iXPPho.js +0 -1
@@ -0,0 +1,165 @@
1
+ import{aj as Ye,r as A,v as vh,w as uo,c as I,j as m,g as Ti,y as Ch,i as Nh,d as dr,b as Eh,t as Ic,F as ee,Q as Th,ak as Rc,a5 as Mh,a4 as Ah,al as Oh,H as Mi,am as jc,an as Ih,B as Mn,E as He,$ as Ai,ao as Rh,z as js,ap as jh,Z as Oi,aq as Dh,ar as Ph,as as Lh,at as Ii,au as $h,av as Dc,a1 as zh,aw as _h,L as Bh,ax as Fh,ay as Hh,af as Pc}from"./index-BLgTJ8o3.js";import{U as bn,f as Lc,d as Ri,c as Qe,b as ji,I as Ds,u as Vh,n as Wh}from"./use-connection-CsPrFY0x.js";import{E as Di}from"./SearchMd-D70t5LVP.js";import{E as $c}from"./error-boundary-CsEoagci.js";import{P as Pi}from"./pin-to-sidebar-button-C8t5xznu.js";import{B as me,c as J}from"./button-IijH0wdI.js";import{F as fo,a as qh,b as Li,d as $i}from"./form-BjarY-Jq.js";import{I as zi}from"./input-BxywPo2X.js";import{T as Uo}from"./textarea-DNeEC-Sl.js";import{b as Pt,T as Lt,a as $t,c as zt,i as _i,d as Uh}from"./tooltip-CSuczTFq.js";import{i as zc}from"./FlipBackward-C0O2fx27.js";import{a as _c,V as Bi,b as Ps}from"./layout-Dfp1nH3g.js";import{i as Kh}from"./AlertCircle-BrGqb-qb.js";import{s as Jh}from"./Clock-LzAlJ-1R.js";import{i as Gh,n as Xh}from"./Code01-Wll8WS4F.js";import{a as Yh}from"./Copy01-_s71W2Ph.js";import{i as Qn}from"./Loading01-0wYmSKV6.js";import{i as Fi}from"./Play-BedrzKsi.js";import{s as Hi,i as Qh}from"./XClose-5A0s2w1d.js";import{u as Zh,O as ep,M as tp,F as np,v as rp}from"./index-CRGUNI2v.js";import{u as Vi}from"./use-mcp-CPBDJGOj.js";import{M as ur}from"./monaco-editor-mQfzbJMr.js";import{E as sp}from"./empty-state-Bg-FRZa4.js";import{D as op,u as ip}from"./use-binding-C5e_Y70M.js";import{u as lp}from"./use-gateway-Bz_y7oh7.js";import{G as ap,b as cp,R as ql,a as dp}from"./resizable-DybyPt6-.js";import{S as Ls}from"./spinner-D7ZAVJCR.js";import{V as up}from"./view-mode-toggle-BXo-WMnB.js";import{i as fp}from"./GitBranch01-DjmPf135.js";import{i as hp}from"./responsive-select-INSf3elv.js";import{a as Wi,b as qi}from"./use-tool-call-BdbJ3oy8.js";import{D as pp,a as mp,b as gp,f as yp,c as xp,d as bp}from"./dialog-CJsBFVDy.js";import"./index-BGEzzv-W.js";import{s as Ui}from"./Plus-DofiSAMU.js";import{b as kp,D as wp,a as Sp,c as Ul}from"./dropdown-menu-BvLCKekW.js";import{B as cn}from"./badge-CStgouQf.js";import{i as Bc}from"./X-DeVUfdHG.js";import"./use-organization-settings-i4aS_Egu.js";import"./ArrowLeft-B6h573ak.js";import"./mcp-oauth-Vd_yzV5S.js";import"./auth-DpA5_jth.js";import"./env-vars-editor-Z7SwcUr8.js";import"./Trash01-DnTS63e5.js";import"./File06-CpSSTggW.js";import"./Key01-ZVAVplBN.js";import"./select-C0rvNlZx.js";import"./ChevronDown-BuogCeI0.js";import"./Terminal-CStBCUAd.js";import"./CpuChip02-BwTl0fBj.js";import"./formatDistanceToNow-fhdySMxO.js";import"./constants-TKUQnnwA.js";import"./registry-utils-ulDDT0d8.js";import"./extract-connection-data-BgA1QcA6.js";import"./generate-id-Dyweu44Y.js";import"./index-B_OB0BCO.js";import"./useQuery-DXchCtgN.js";import"./use-mobile-VYFif8jU.js";const Fc=Ye("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 Hc=Ye("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 Vc=Ye("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Wc=Ye("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const vp=Ye("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const Cp=Ye("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 qc=Ye("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 Uc=Ye("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 Kc=Ye("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 Jc=Ye("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"}]]),Ki=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.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"}));Ki.displayName="AlertOctagon";const Gc=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.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"}));Gc.displayName="Box";const Xc=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));Xc.displayName="ClockFastForward";const Yc=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));Yc.displayName="Code02";const jr=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.createElement("path",{d:"M6.8 3h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C3 4.52 3 5.08 3 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C4.52 21 5.08 21 6.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C10 19.48 10 18.92 10 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C8.48 3 7.92 3 6.8 3Zm11 0h-.6c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C14 4.52 14 5.08 14 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C15.52 21 16.08 21 17.2 21h.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C21 19.48 21 18.92 21 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C19.48 3 18.92 3 17.8 3Z"}));jr.displayName="Columns01";const Qc=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.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"}));Qc.displayName="CornerDownRight";const Zc=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.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"}));Zc.displayName="Database01";const ed=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.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"}));ed.displayName="Repeat03";const Ji=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.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"}));Ji.displayName="Save02";const td=({size:n=24,color:e="currentColor",...t})=>A.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t},A.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"}));td.displayName="Tool01";const{getOwnPropertyNames:Np,getOwnPropertySymbols:Ep}=Object,{hasOwnProperty:Tp}=Object.prototype;function ho(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function kr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function Mp(n){return n?.[Symbol.toStringTag]}function Kl(n){return Np(n).concat(Ep(n))}const Ap=Object.hasOwn||((n,e)=>Tp.call(n,e));function Gt(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const Op="__v",Ip="__o",Rp="_owner",{getOwnPropertyDescriptor:Jl,keys:Gl}=Object;function jp(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n),new Uint8Array(e))}function Dp(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function Pp(n,e){return n.byteLength===e.byteLength&&Br(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Lp(n,e){return Gt(n.getTime(),e.getTime())}function $p(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function zp(n,e){return n===e}function Xl(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let d=!1,u=0;for(;(l=c.next())&&!l.done;){if(s[u]){u++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,u,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){d=s[u]=!0;break}u++}if(!d)return!1;a++}return!0}const _p=Gt;function Bp(n,e,t){const r=Gl(n);let s=r.length;if(Gl(e).length!==s)return!1;for(;s-- >0;)if(!nd(n,e,t,r[s]))return!1;return!0}function Pn(n,e,t){const r=Kl(n);let s=r.length;if(Kl(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!nd(n,e,t,o)||(i=Jl(n,o),l=Jl(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function Fp(n,e){return Gt(n.valueOf(),e.valueOf())}function Hp(n,e){return n.source===e.source&&n.flags===e.flags}function Yl(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,d=0;for(;(l=a.next())&&!l.done;){if(!s[d]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[d]=!0;break}d++}if(!c)return!1}return!0}function Br(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Vp(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function nd(n,e,t,r){return(r===Rp||r===Ip||r===Op)&&(n.$$typeof||e.$$typeof)?!0:Ap(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Wp="[object ArrayBuffer]",qp="[object Arguments]",Up="[object Boolean]",Kp="[object DataView]",Jp="[object Date]",Gp="[object Error]",Xp="[object Map]",Yp="[object Number]",Qp="[object Object]",Zp="[object RegExp]",em="[object Set]",tm="[object String]",nm={"[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},rm="[object URL]",sm=Object.prototype.toString;function om({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(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 C=y.constructor;if(C!==x.constructor)return!1;if(C===Object)return a(y,x,b);if(Array.isArray(y))return e(y,x,b);if(C===Date)return r(y,x,b);if(C===RegExp)return d(y,x,b);if(C===Map)return i(y,x,b);if(C===Set)return u(y,x,b);const w=sm.call(y);if(w===Jp)return r(y,x,b);if(w===Zp)return d(y,x,b);if(w===Xp)return i(y,x,b);if(w===em)return u(y,x,b);if(w===Qp)return typeof y.then!="function"&&typeof x.then!="function"&&a(y,x,b);if(w===rm)return h(y,x,b);if(w===Gp)return s(y,x,b);if(w===qp)return a(y,x,b);if(nm[w])return f(y,x,b);if(w===Wp)return n(y,x,b);if(w===Kp)return t(y,x,b);if(w===Up||w===Yp||w===tm)return c(y,x,b);if(p){let S=p[w];if(!S){const v=Mp(y);v&&(S=p[v])}if(S)return S(y,x,b)}return!1}}function im({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:jp,areArraysEqual:t?Pn:Dp,areDataViewsEqual:Pp,areDatesEqual:Lp,areErrorsEqual:$p,areFunctionsEqual:zp,areMapsEqual:t?ho(Xl,Pn):Xl,areNumbersEqual:_p,areObjectsEqual:t?Pn:Bp,arePrimitiveWrappersEqual:Fp,areRegExpsEqual:Hp,areSetsEqual:t?ho(Yl,Pn):Yl,areTypedArraysEqual:t?ho(Br,Pn):Br,areUrlsEqual:Vp,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=kr(r.areArraysEqual),o=kr(r.areMapsEqual),i=kr(r.areObjectsEqual),l=kr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function lm(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function am({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:d}=t();return e(l,a,{cache:c,equals:r,meta:d,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const cm=Et();Et({strict:!0});Et({circular:!0});Et({circular:!0,strict:!0});Et({createInternalComparator:()=>Gt});Et({strict:!0,createInternalComparator:()=>Gt});Et({circular:!0,createInternalComparator:()=>Gt});Et({circular:!0,createInternalComparator:()=>Gt,strict:!0});function Et(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=im(n),i=om(o),l=t?t(i):lm(i);return am({circular:e,comparator:i,createState:r,equals:l,strict:s})}vh({title:uo().min(1),description:uo().nullable(),body:uo()});function po(n){for(const e of n.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function dm(){const n=window.location.pathname.split("/").filter(Boolean),e=n.findIndex(r=>r==="mcps"),t=e>=0?n[e+1]:void 0;return t?decodeURIComponent(t):void 0}function um(n){const e=I.c(13),{form:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Details"}),e[0]=r):r=e[0];let s;e[1]!==t.control?(s=m.jsxs("div",{className:"flex flex-col gap-4",children:[r,m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[m.jsx(fo,{control:t.control,name:"title",render:pm}),m.jsx(fo,{control:t.control,name:"description",render:hm})]})]}),e[1]=t.control,e[2]=s):s=e[2];let o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Message"}),i=m.jsx("div",{className:"text-xs text-muted-foreground",children:"This becomes the user message in the prompt."}),e[3]=o,e[4]=i):(o=e[3],i=e[4]);let l;e[5]!==t.control?(l=m.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,m.jsx(fo,{control:t.control,name:"body",render:fm})]}),e[5]=t.control,e[6]=l):l=e[6];let a;e[7]!==s||e[8]!==l?(a=m.jsxs("div",{className:"h-full py-6 flex flex-col max-w-3xl mx-auto w-full min-w-0 gap-8 overflow-y-auto px-4",children:[s,l]}),e[7]=s,e[8]=l,e[9]=a):a=e[9];let c;return e[10]!==t||e[11]!==a?(c=m.jsx(qh,{...t,children:a}),e[10]=t,e[11]=a,e[12]=c):c=e[12],c}function fm(n){const{field:e}=n;return m.jsx(Li,{children:m.jsx($i,{children:m.jsx(Uo,{...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 hm(n){const{field:e}=n;return m.jsxs(Li,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),m.jsx($i,{children:m.jsx(zi,{...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 pm(n){const{field:e}=n;return m.jsxs(Li,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),m.jsx($i,{children:m.jsx(zi,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function mm(n){const e=I.c(51),{providerId:t,promptId:r,onBack:s}=n,i=Ti().location.href,l=t||bn;let a;e[0]!==l?(a=Qe(l),e[0]=l,e[1]=a):a=e[1];const c=a,d=Lc(t,"PROMPT",r,c),u=Ri(t,"PROMPT",c),f=u.update.isPending;let h;e[2]!==d?(h=d?{title:d.title,description:d.description??null,body:po(d)}:void 0,e[2]=d,e[3]=h):h=e[3];let p;e[4]!==h?(p={values:h},e[4]=h,e[5]=p):p=e[5];const g=Ch(p);let y;e[6]!==g||e[7]!==d?(y=()=>{d&&g.reset({title:d.title,description:d.description??null,body:po(d)})},e[6]=g,e[7]=d,e[8]=y):y=e[8];const x=y;let b;e[9]!==u.update||e[10]!==g||e[11]!==r?(b=g.handleSubmit(async X=>{const fe=await u.update.mutateAsync({id:r,data:{title:X.title,description:X.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:X.body}}]}});g.reset({title:fe.title,description:fe.description??null,body:po(fe)})}),e[9]=u.update,e[10]=g,e[11]=r,e[12]=b):b=e[12];const k=b;if(!d){let X;return e[13]===Symbol.for("react.memo_cache_sentinel")?(X=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(Di,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=X):X=e[13],X}let C;e[14]!==d.title?(C=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:d.title}),e[14]=d.title,e[15]=C):C=e[15];let w;e[16]!==d.description?(w=d.description?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:d.description})]}):null,e[16]=d.description,e[17]=w):w=e[17];let S;e[18]!==C||e[19]!==w?(S=m.jsx(_c,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[C,w]})}),e[18]=C,e[19]=w,e[20]=S):S=e[20];let v;e[21]!==d.title||e[22]!==i?(v=m.jsx(Pi,{title:d.title,url:i,icon:"description"}),e[21]=d.title,e[22]=i,e[23]=v):v=e[23];const E=!g.formState.isDirty||f;let M;e[24]===Symbol.for("react.memo_cache_sentinel")?(M=m.jsx(zc,{size:14}),e[24]=M):M=e[24];let D;e[25]!==x||e[26]!==E?(D=m.jsx(Pt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:E,onClick:x,"aria-label":"Cancel",children:M})})}),e[25]=x,e[26]=E,e[27]=D):D=e[27];let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=m.jsx(Lt,{side:"bottom",children:"Cancel"}),e[28]=j):j=e[28];let _;e[29]!==D?(_=m.jsx($t,{children:m.jsxs(zt,{delayDuration:0,children:[D,j]})}),e[29]=D,e[30]=_):_=e[30];const H=!g.formState.isDirty||f;let B;e[31]!==k?(B=()=>{k()},e[31]=k,e[32]=B):B=e[32];let V;e[33]===Symbol.for("react.memo_cache_sentinel")?(V=m.jsx(Ji,{size:14}),e[33]=V):V=e[33];let N;e[34]!==H||e[35]!==B?(N=m.jsx(Pt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:H,onClick:B,"aria-label":"Save",children:V})})}),e[34]=H,e[35]=B,e[36]=N):N=e[36];let z;e[37]===Symbol.for("react.memo_cache_sentinel")?(z=m.jsx(Lt,{side:"bottom",children:"Save"}),e[37]=z):z=e[37];let P;e[38]!==N?(P=m.jsx($t,{children:m.jsxs(zt,{delayDuration:0,children:[N,z]})}),e[38]=N,e[39]=P):P=e[39];let U;e[40]!==v||e[41]!==_||e[42]!==P?(U=m.jsxs(Bi,{children:[v,_,P]}),e[40]=v,e[41]=_,e[42]=P,e[43]=U):U=e[43];let Q;e[44]!==g?(Q=m.jsx("div",{className:"h-full",children:m.jsx(um,{form:g})}),e[44]=g,e[45]=Q):Q=e[45];let le;return e[46]!==s||e[47]!==U||e[48]!==Q||e[49]!==S?(le=m.jsxs(Ps,{onBack:s,children:[S,U,Q]}),e[46]=s,e[47]=U,e[48]=Q,e[49]=S,e[50]=le):le=e[50],le}function gm(n){const e=I.c(5),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=dm()??bn,e[0]=s):s=e[0];const o=s;if(!o||o===bn){let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(Di,{title:"Prompt not found",description:"Missing connection information in the current route."})}),e[1]=l):l=e[1],l}let i;return e[2]!==t||e[3]!==r?(i=m.jsx($c,{children:m.jsx(A.Suspense,{fallback:null,children:m.jsx(mm,{providerId:o,promptId:t,onBack:r})})}),e[2]=t,e[3]=r,e[4]=i):i=e[4],i}const ym=Nh("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 xm(n){const e=I.c(10);let t,r,s;e[0]!==n?({className:t,variant:s,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==t||e[5]!==s?(o=J(ym({variant:s}),t),e[4]=t,e[5]=s,e[6]=o):o=e[6];let i;return e[7]!==r||e[8]!==o?(i=m.jsx("div",{"data-slot":"alert",role:"alert",className:o,...r}),e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function bm(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=J("line-clamp-1 min-h-4 font-medium tracking-tight",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-title",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function km(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=J("text-muted-foreground leading-relaxed",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx("div",{"data-slot":"alert-description",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}const wm=n=>n.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function Sm(n){const e=I.c(13),{toolName:t,connectionId:r,onBack:s}=n,o=`/mcp/${r}`;let i;e[0]!==o?(i=new URL(o,window.location.origin),e[0]=o,e[1]=i):i=e[1];const l=i;let a;e[2]!==r?(a={connectionId:r},e[2]=r,e[3]=a):a=e[3];const c=Zh(a);if(!c.isAuthenticated){let f;return e[4]!==c.supportsOAuth||e[5]!==s?(f=m.jsx("div",{className:"flex h-full items-center justify-center",children:c.supportsOAuth?m.jsx(ep,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):m.jsx(tp,{hasReadme:!1})}),e[4]=c.supportsOAuth,e[5]=s,e[6]=f):f=e[6],f}const d=`${r}:${t}`;let u;return e[7]!==r||e[8]!==l||e[9]!==s||e[10]!==d||e[11]!==t?(u=m.jsx(vm,{toolName:t,connectionId:r,mcpProxyUrl:l,onBack:s},d),e[7]=r,e[8]=l,e[9]=s,e[10]=d,e[11]=t,e[12]=u):u=e[12],u}function vm({toolName:n,connectionId:e,mcpProxyUrl:t,onBack:r}){const o=Ti().location.href,{replayId:i}=Eh({strict:!1}),l=(()=>{if(!i)return null;const N=`replay-${i}`,z=sessionStorage.getItem(N);if(!z)return null;sessionStorage.removeItem(N);try{return JSON.parse(z)}catch{return null}})(),a=(()=>{if(!l)return null;const N={};for(const[z,P]of Object.entries(l))P!==null&&typeof P=="object"?N[z]=JSON.stringify(P,null,2):N[z]=P;return N})(),[c,d]=A.useState(a??{}),[u,f]=A.useState(l?JSON.stringify(l,null,2):"{}"),[h,p]=A.useState(null),[g,y]=A.useState(null),[x,b]=A.useState(!1),[k,C]=A.useState(null),w=ji(e),S=Vi({url:t.href});A.useEffect(()=>{S.error&&console.error("MCP Error:",S.error)},[S.error]);const v=S.tools?.find(N=>N.name===n),E=v?.inputSchema?.properties,M=E?Object.keys(E):[],D=M.length>0,j={};if(D&&v?.inputSchema?.properties)for(const N of M)j[N]=v.inputSchema.required?.includes(N)?"":void 0;const _=N=>Object.prototype.hasOwnProperty.call(c,N),H=async()=>{b(!0),y(null),p(null),C(null);const N=performance.now(),z=Qe(e);try{const P=D?{...j,...c}:(()=>{const se=u.trim();if(!se)return{};const K=JSON.parse(se);if(K&&typeof K=="object")return K;throw new Error("Raw JSON input must be an object.")})();D&&v?.inputSchema?.properties&&Object.entries(v.inputSchema.properties).forEach(([se,K])=>{if((K.type==="object"||K.type==="array")&&typeof P[se]=="string")try{P[se]=JSON.parse(P[se])}catch{}});const U=await z(n,P),Q=performance.now(),le=Math.round(Q-N);p(U);const X=JSON.stringify(U),fe=new TextEncoder().encode(X).length;C({duration:`${le}ms`,bytes:`${fe} bytes`,tokens:`~${Math.ceil(fe/4)} tokens`,cost:"$0.0000"})}catch(P){const U=P instanceof Error?P.message:String(P);y(U||"Unknown error occurred");const Q=performance.now();C({duration:`${Math.round(Q-N)}ms`})}finally{b(!1)}},B=(N,z)=>{d(P=>({...P,[N]:z}))},V=()=>{p(null),y(null),C(null)};return m.jsxs(Ps,{onBack:r,children:[m.jsx(Bi,{children:m.jsx(Pi,{title:v?.name??wm(n),url:o,icon:"build"})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 h-full",children:[m.jsx("div",{className:"flex flex-col border-r border-border overflow-hidden",children:m.jsxs("div",{className:"flex-1 overflow-auto",children:[m.jsx("div",{className:"flex flex-col gap-4 p-6 border-b border-border min-h-28",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(Ds,{icon:w?.icon||null,name:w?.title||n,size:"sm",className:"shadow-sm shrink-0"}),m.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:n}),m.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[S.state==="ready"?m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):S.state==="connecting"?m.jsx(Qn,{size:10,className:"animate-spin text-yellow-500 shrink-0"}):m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}),m.jsx("span",{className:"font-mono text-xs capitalize text-muted-foreground leading-none",children:S.state.replace("_"," ")})]})]}),m.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:v?.description||"No description available"})]})}),m.jsxs("div",{className:"flex flex-col p-6 gap-4",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h2",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"Parameters"}),v?.inputSchema?.required&&v.inputSchema.required.length>0&&m.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.jsx("span",{className:"text-red-500",children:"*"})," Required"]})]}),m.jsx("div",{className:"space-y-4",children:D&&v?.inputSchema?.properties?Object.entries(v.inputSchema.properties).map(([N,z])=>m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("label",{className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[N,v.inputSchema?.required?.includes(N)&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),m.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:z.type})]}),z.description&&m.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:z.description}),z.type==="object"||z.type==="array"?m.jsx(Uo,{className:"font-mono text-xs",value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N} as JSON...`,rows:3}):m.jsx(zi,{value:_(N)?c[N]??"":j[N]??"",onChange:P=>B(N,P.target.value),placeholder:`Enter ${N}...`})]},N)):v?.inputSchema&&!D?m.jsxs("div",{className:"space-y-2",children:[m.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),m.jsx(Uo,{className:"font-mono text-xs min-h-[120px]",value:u,onChange:N=>f(N.target.value),placeholder:'e.g. { "foo": "bar" }'})]}):m.jsx("div",{className:"flex items-center justify-center p-8 bg-muted/30 rounded-lg border border-dashed border-border",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No parameters required"})})})]})]})}),m.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-14 border-t lg:border-t-0 border-b border-border bg-background",children:[m.jsx("h2",{className:"text-sm font-medium text-foreground uppercase tracking-wide",children:"Result"}),k&&m.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Jh,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:k.duration})]}),k.tokens&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Gc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:k.tokens})]}),k.bytes&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Zc,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:k.bytes})]}),k.cost&&m.jsx("div",{className:"flex items-center gap-1.5",children:m.jsx("span",{className:"font-mono text-foreground",children:k.cost})})]})]}),m.jsx("div",{className:"flex items-center justify-end lg:justify-between px-4 h-14 border-b border-border bg-background",children:m.jsxs("div",{className:"flex items-center gap-2 w-full lg:w-auto",children:[m.jsx(me,{size:"sm",variant:"default",className:"h-8 gap-2 flex-1 lg:flex-none",onClick:H,disabled:x,children:x?m.jsxs(m.Fragment,{children:[m.jsx(Qn,{size:14,className:"animate-spin"}),"Executing..."]}):m.jsxs(m.Fragment,{children:[m.jsx(Fi,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),m.jsx($t,{children:m.jsxs(zt,{children:[m.jsx(Pt,{asChild:!0,children:m.jsx(me,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:V,disabled:!h&&!g,children:m.jsx(Hi,{size:14})})}),m.jsx(Lt,{children:m.jsx("p",{children:"Clear results"})})]})})]})}),g&&m.jsx("div",{className:"px-6 py-4 bg-background",children:m.jsx(xm,{variant:"destructive",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Kh,{className:"h-4 w-4"}),m.jsx(bm,{className:"mb-0",children:"Execution Failed"})]}),m.jsx(km,{className:"text-xs text-destructive",children:g})]})})}),m.jsx("div",{className:"relative flex-1 overflow-auto bg-muted/50",children:h?m.jsxs(m.Fragment,{children:[m.jsx(ur,{code:JSON.stringify(h,null,2),language:"json",height:"100%",readOnly:!0}),m.jsx(me,{size:"icon",variant:"ghost",className:"absolute top-4 right-4 h-8 w-8 bg-background/80 hover:bg-background border border-border shadow-sm",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(h,null,2)),Ic.success("Copied to clipboard")},children:m.jsx(Yh,{className:"h-3.5 w-3.5"})})]}):m.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground",children:[m.jsx(Gh,{className:"h-12 w-12 mb-3 opacity-40"}),m.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function Cm(n){const e=I.c(7),{itemId:t,onBack:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=dr(s).connectionId??bn;if(!ji(i)){let d;return e[1]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[m.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=d):d=e[1],d}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(Qn,{size:32,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let c;return e[3]!==i||e[4]!==r||e[5]!==t?(c=m.jsx(A.Suspense,{fallback:a,children:m.jsx(Sm,{toolName:t,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=t,e[6]=c):c=e[6],c}const Ql=n=>{let e;const t=new Set,r=(c,d)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const f=e;e=d??(typeof u!="object"||u===null)?u:Object.assign({},e,u),t.forEach(h=>h(e,f))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>a,subscribe:c=>(t.add(c),()=>t.delete(c))},a=e=n(r,s,l);return l},Gi=(n=>n?Ql(n):Ql),Nm=n=>n;function Ko(n,e=Nm){const t=ee.useSyncExternalStore(n.subscribe,ee.useCallback(()=>e(n.getState()),[n,e]),ee.useCallback(()=>e(n.getInitialState()),[n,e]));return ee.useDebugValue(t),t}const Em=n=>{const e=Gi(n),t=r=>Ko(e,r);return Object.assign(t,e),t},Tm=(n=>Em);function rd(n,e){let t;try{t=n()}catch{return}return{getItem:s=>{var o;const i=a=>a===null?null:JSON.parse(a,void 0),l=(o=t.getItem(s))!=null?o:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,o)=>t.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>t.removeItem(s)}}const Jo=n=>e=>{try{const t=n(e);return t instanceof Promise?t:{then(r){return Jo(r)(t)},catch(r){return this}}}catch(t){return{then(r){return this},catch(r){return Jo(r)(t)}}}},Mm=(n,e)=>(t,r,s)=>{let o={storage:rd(()=>localStorage),partialize:g=>g,version:0,merge:(g,y)=>({...y,...g}),...e},i=!1;const l=new Set,a=new Set;let c=o.storage;if(!c)return n((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),t(...g)},r,s);const d=()=>{const g=o.partialize({...r()});return c.setItem(o.name,{state:g,version:o.version})},u=s.setState;s.setState=(g,y)=>(u(g,y),d());const f=n((...g)=>(t(...g),d()),r,s);s.getInitialState=()=>f;let h;const p=()=>{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 Jo(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(C=>[!0,C]):[!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[C,w]=b;if(h=o.merge(w,(k=r())!=null?k:f),t(h,!0),C)return d()}).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:()=>p(),hasHydrated:()=>i,onHydrate:g=>(l.add(g),()=>{l.delete(g)}),onFinishHydration:g=>(a.add(g),()=>{a.delete(g)})},o.skipHydration||p(),h||f},sd=Mm,{useSyncExternalStoreWithSelector:Am}=Th,Om=n=>n;function Im(n,e=Om,t){const r=Am(n.subscribe,n.getState,n.getInitialState,e,t);return ee.useDebugValue(r),r}const Zl=n=>Symbol.iterator in n,ea=n=>"entries"in n,ta=(n,e)=>{const t=n instanceof Map?n:new Map(n.entries()),r=e instanceof Map?e:new Map(e.entries());if(t.size!==r.size)return!1;for(const[s,o]of t)if(!r.has(s)||!Object.is(o,r.get(s)))return!1;return!0},Rm=(n,e)=>{const t=n[Symbol.iterator](),r=e[Symbol.iterator]();let s=t.next(),o=r.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=t.next(),o=r.next()}return!!s.done&&!!o.done};function jm(n,e){return Object.is(n,e)?!0:typeof n!="object"||n===null||typeof e!="object"||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e)?!1:Zl(n)&&Zl(e)?ea(n)&&ea(e)?ta(n,e):Rm(n,e):ta({entries:()=>Object.entries(n)},{entries:()=>Object.entries(e)})}function Dm(n,e="Output"){if(!n)return`interface ${e} {}`;function t(o){if(!o||typeof o!="object")return"unknown";const i=o.type;if(Array.isArray(i))return i.map(l=>r(l)).join(" | ");switch(i){case"string":return o.enum?o.enum.map(l=>`"${l}"`).join(" | "):"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":{const l=o.items;return l?`${t(l)}[]`:"unknown[]"}case"object":return s(o);default:return o.anyOf?o.anyOf.map(t).join(" | "):o.oneOf?o.oneOf.map(t).join(" | "):o.allOf?o.allOf.map(t).join(" & "):"unknown"}}function r(o){switch(o){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";default:return"unknown"}}function s(o){const i=o.properties;if(!i)return"Record<string, unknown>";const l=new Set(o.required||[]);return`{
2
+ ${Object.entries(i).map(([c,d])=>{const u=l.has(c)?"":"?";return`${d.description?` /** ${d.description} */
3
+ `:""} ${c}${u}: ${t(d)};`}).join(`
4
+ `)}
5
+ }`}return`interface ${e} ${t(n)}`}function mo(n,e){const t=n.trim();return e.some(s=>s.name.toLowerCase()===t.toLowerCase())?`${t}_${Math.random().toString(36).substring(2,6)}`:t}function Pm(n,e){const t=n.match(/interface\s+Input\s*\{/);if(!t||t.index===void 0)return`${e}
6
+
7
+ ${n.trimStart()}`;const r=t.index,s=r+t[0].length-1;let o=1,i=s+1;for(;i<n.length&&o>0;)n[i]==="{"?o++:n[i]==="}"&&o--,i++;return n.slice(0,r)+e+n.slice(i)}function go(n,e){switch(n){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...op,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${n}`)}}const od=A.createContext(null),Lm=n=>Gi()(sd(e=>({...n,actions:{setIsAddingStep:t=>e(r=>({...r,isAddingStep:t})),setCurrentStepTab:t=>e(r=>({...r,currentStepTab:t})),setToolAction:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.map(s=>"toolName"in s.action&&s.action.toolName===t.toolName?{...s,action:t}:s)}})),appendStep:({step:t,type:r})=>e(s=>{const o=t??go(r,s.workflow.steps.length),i=s.workflow.steps.find(a=>a.name===o.name),l=i?`${o.name} ${parseInt(i.name.split(" ").pop()??Math.random().toString(36).substring(2,15))+1}`:o.name;return{workflow:{...s.workflow,steps:[...s.workflow.steps,{...o,name:l}]}}}),deleteStep:t=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.filter(s=>s.name!==t)}})),duplicateStep:t=>e(r=>{const s=r.workflow.steps.findIndex(a=>a.name===t);if(s===-1)return r;const o=r.workflow.steps[s];if(!o)return r;const i={...o,name:mo(o.name,r.workflow.steps)},l=[...r.workflow.steps];return l.splice(s+1,0,i),{workflow:{...r.workflow,steps:l},currentStepName:i.name}}),setCurrentStepName:t=>e(r=>({...r,currentStepName:t})),updateStep:(t,r)=>e(s=>({...s,workflow:{...s.workflow,steps:s.workflow.steps.map(o=>o.name===t?{...o,...r}:o)}})),setTrackingExecutionId:t=>e(r=>({...r,trackingExecutionId:t})),resetToOriginalWorkflow:()=>e(t=>({...t,workflow:t.originalWorkflow})),startAddingStep:t=>e(r=>({...r,isAddingStep:!0,addingStepType:t})),cancelAddingStep:()=>e(t=>({...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[]})),toggleParentStepSelection:t=>e(r=>{const s=r.selectedParentSteps.includes(t);return{...r,selectedParentSteps:s?r.selectedParentSteps.filter(o=>o!==t):[...r.selectedParentSteps,t]}}),confirmAddCodeStep:()=>e(t=>{const{selectedParentSteps:r,addingStepType:s,workflow:o}=t;if(s!=="code"||r.length===0)return t;const i={};for(const u of r)i[u]=`@${u}`;const l={};for(const u of r){const f=o.steps.find(h=>h.name===u);f?.outputSchema&&(l[u]=f.outputSchema)}const a=Object.keys(l).length>0?{type:"object",properties:l,required:Object.keys(l)}:void 0;let c=go("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const u=Dm(a,"Input"),f=c.action,h=Pm(f.code,u);c={...c,action:{...f,code:h}}}const d=mo(c.name,o.steps);return{...t,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],workflow:{...o,steps:[...o.steps,{...c,name:d}]},currentStepName:d}}),addToolStep:()=>e(t=>{let r=go("tool",Number((Math.random()*1e6).toFixed(0)));const s=mo(r.name,t.workflow.steps);return{...t,isAddingStep:!1,addingStepType:null,workflow:{...t.workflow,steps:[...t.workflow.steps,{...r,name:s}]},currentStepName:s}}),setOriginalWorkflow:t=>e(r=>({...r,originalWorkflow:t})),setWorkflow:t=>e(r=>({...r,workflow:t})),startReplacingTool:t=>e(r=>({...r,replacingToolInfo:{toolName:t}})),cancelReplacingTool:()=>e(t=>({...t,replacingToolInfo:null})),setSelectedGatewayId:t=>e(r=>({...r,selectedGatewayId:t}))}}),{name:`workflow-store-${encodeURIComponent(n.workflow.id)}`,storage:rd(()=>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 $m(n){const e=I.c(8),{children:t,initialState:r}=n,s=lp();let o;e[0]!==s?.[0]?.id||e[1]!==r.currentStepTab||e[2]!==r.trackingExecutionId||e[3]!==r.workflow?(o=()=>Lm({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]=A.useState(o);let l;return e[5]!==t||e[6]!==i?(l=m.jsx(od.Provider,{value:i,children:t}),e[5]=t,e[6]=i,e[7]=l):l=e[7],l}function An(n,e){const t=A.useContext(od);if(!t)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return Im(t,n,jm)}function On(){return An(zm)}function zm(n){return n.workflow}function Me(){return An(_m)}function _m(n){return n.actions}function id(){const n=hr();return An(Bm)??n[0]?.name}function Bm(n){return n.currentStepName}function fr(){const n=I.c(5),e=id(),t=hr();let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==e?(o=i=>i.name===e,n[3]=e,n[4]=o):o=n[4],r=t.find(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];const s=r;return s||t[0]}function hr(){return On().steps}function ld(){const n=I.c(4),e=On(),t=An(Fm);let r;n[0]!==e?(r=JSON.stringify(e),n[0]=e,n[1]=r):r=n[1];let s;return n[2]!==t?(s=JSON.stringify(t),n[2]=t,n[3]=s):s=n[3],r!==s}function Fm(n){return n.originalWorkflow}function we(){return An(Hm)}function Hm(n){return n.trackingExecutionId}function In(){return An(Vm)}function Vm(n){return n.selectedGatewayId}function Rn(){const n=I.c(2),e=Vh();let t;n[0]!==e?(t={connections:e,binding:"WORKFLOW"},n[0]=e,n[1]=t):t=n[1];const r=ip(t);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}const na=[1,1e3,2e3,3e3,5e3,1e4];function pr(n){const e=I.c(15),t=Rn();let r;e[0]!==t.id?(r=Qe(t.id),e[0]=t.id,e[1]=r):r=e[1];const s=r,o=A.useRef(0);let i;e[2]!==n?(i={id:n},e[2]=n,e[3]=i):i=e[3];const l=!!n;let a;e[4]!==n?(a=n?p=>{const g=p.state?.data?.item?.status;if(g==="running"||g==="enqueued"){const y=na[o.current]??1;return o.current=(o.current+1)%na.length,y}return o.current=0,!1}:!1,e[4]=n,e[5]=a):a=e[5];let c;e[6]!==t.id||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==s?(c={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET",toolInputParams:i,scope:t.id,enabled:l,refetchInterval:a},e[6]=t.id,e[7]=i,e[8]=l,e[9]=a,e[10]=s,e[11]=c):c=e[11];const{data:d,isLoading:u}=Wi(c),f=d?.item;let h;return e[12]!==u||e[13]!==f?(h={item:f,isLoading:u},e[12]=u,e[13]=f,e[14]=h):h=e[14],h}function Wm(n,e){const t=I.c(14),r=Rn();let s;t[0]!==r.id?(s=Qe(r.id),t[0]=r.id,t[1]=s):s=t[1];const o=s;let i;t[2]!==n||t[3]!==e?(i={executionId:n,stepId:e},t[2]=n,t[3]=e,t[4]=i):i=t[4];const l=!!n&&!!e;let a;t[5]!==r.id||t[6]!==i||t[7]!==l||t[8]!==o?(a={toolCaller:o,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET_STEP_RESULT",toolInputParams:i,scope:r.id,enabled:l},t[5]=r.id,t[6]=i,t[7]=l,t[8]=o,t[9]=a):a=t[9];const{data:c,isLoading:d}=Wi(a),u=c?.output,f=c?.error;let h;return t[10]!==d||t[11]!==u||t[12]!==f?(h={output:u,error:f,isLoading:d},t[10]=d,t[11]=u,t[12]=f,t[13]=h):h=t[13],h}function qm(){const n=I.c(19),e=Rn(),t=On();let r;n[0]!==e.id?(r=Qe(e.id),n[0]=e.id,n[1]=r):r=n[1];const s=r;let o;n[2]===Symbol.for("react.memo_cache_sentinel")?(o=["workflow"],n[2]=o):o=n[2];let i;n[3]!==t.id?(i={field:o,operator:"eq",value:t.id},n[3]=t.id,n[4]=i):i=n[4];let l;n[5]===Symbol.for("react.memo_cache_sentinel")?(l=[{field:["created_at"],direction:"desc"}],n[5]=l):l=n[5];let a;n[6]!==i?(a={where:i,orderBy:l,limit:100},n[6]=i,n[7]=a):a=n[7];const c=`${e.id}-executions-${t.id}`,d=!!t.id;let u;n[8]!==a||n[9]!==c||n[10]!==d||n[11]!==s?(u={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_LIST",toolInputParams:a,scope:c,enabled:d,staleTime:5e3},n[8]=a,n[9]=c,n[10]=d,n[11]=s,n[12]=u):u=n[12];const{data:f,isLoading:h,refetch:p}=Wi(u),g=f;let y;n[13]!==g?.items?(y=g?.items??[],n[13]=g?.items,n[14]=y):y=n[14];let x;return n[15]!==h||n[16]!==p||n[17]!==y?(x={executions:y,isLoading:h,refetch:p},n[15]=h,n[16]=p,n[17]=y,n[18]=x):x=n[18],x}function ad(n){const e=[];function t(r){if(typeof r=="string"){const s=r.match(/@input(?:\.(\w+(?:\.\w+)*))?/g);if(s)for(const o of s)if(o==="@input")e.push("__entire_input__");else{const i=o.replace("@input.","");e.push(i)}}else Array.isArray(r)?r.forEach(t):typeof r=="object"&&r!==null&&Object.values(r).forEach(t)}return t(n),[...new Set(e)]}function Um(n){const e=[];for(const t of n){const r=ad(t.input);e.push(...r)}return[...new Set(e)].filter(t=>t!=="__entire_input__")}function Km(n){for(const e of n)if(ad(e.input).includes("__entire_input__"))return!0;return!1}function Jm(n){const e=Um(n);if(e.length===0)return Km(n)?{type:"object",additionalProperties:!0,description:"Workflow input data"}:null;const t={},r=[];for(const s of e){const o=s.split(".");if(o.length===1)t[s]={type:"string",description:`Input field: ${s}`},r.push(s);else{const i=o[0];i&&!t[i]&&(t[i]={type:"object",description:`Input object: ${i}`,additionalProperties:!0},r.push(i))}}return{type:"object",properties:t,required:r,description:"Workflow execution input"}}function Gm(){const n=I.c(2),e=On();let t;return n[0]!==e.steps?(t=Jm(e.steps),n[0]=e.steps,n[1]=t):t=n[1],t}function Xm(){const n=I.c(14),{id:e}=Rn(),{setTrackingExecutionId:t}=Me();let r;n[0]!==e?(r=Qe(e),n[0]=e,n[1]=r):r=n[1];const s=r,o=On(),i=In(),l=Gm();let a;n[2]!==s?(a={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_CREATE"},n[2]=s,n[3]=a):a=n[3];const{mutateAsync:c,isPending:d}=qi(a);let u;n[4]!==i||n[5]!==t||n[6]!==c||n[7]!==o?(u=async g=>{const y=g===void 0?{}:g;if(!i)throw new Error("Please select a Hub 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 t(k),k},n[4]=i,n[5]=t,n[6]=c,n[7]=o,n[8]=u):u=n[8];const f=u,h=l!==null;let p;return n[9]!==f||n[10]!==l||n[11]!==d||n[12]!==h?(p={handleRunWorkflow:f,isPending:d,requiresInput:h,inputSchema:l},n[9]=f,n[10]=l,n[11]=d,n[12]=h,n[13]=p):p=n[13],p}function Ym(){const n=I.c(9),{id:e}=Rn();let t;n[0]!==e?(t=Qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"CANCEL_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=qi(s);let l;n[4]!==o?(l=async d=>await o({executionId:d}),n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleCancelWorkflow:a,isCancelling:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function Qm(){const n=I.c(9),{id:e}=Rn();let t;n[0]!==e?(t=Qe(e),n[0]=e,n[1]=t):t=n[1];const r=t;let s;n[2]!==r?(s={toolCaller:r,toolName:"RESUME_EXECUTION"},n[2]=r,n[3]=s):s=n[3];const{mutateAsync:o,isPending:i}=qi(s);let l;n[4]!==o?(l=async d=>(await o({executionId:d})).success,n[4]=o,n[5]=l):l=n[5];const a=l;let c;return n[6]!==a||n[7]!==i?(c={handleResumeWorkflow:a,isResuming:i},n[6]=a,n[7]=i,n[8]=c):c=n[8],c}function Zm(){const n=I.c(3),e=we(),{item:t}=pr(e);let r;return n[0]!==t||n[1]!==e?(r=e&&t?(()=>{const o={};return t?.input&&(o.input=t.input),o})():void 0,n[0]=t,n[1]=e,n[2]=r):r=n[2],r}function eg(n,e,t,r){if(!e)return[...n].sort(r);const s=t(e);return[...n].sort((o,i)=>{const l=t(o),a=t(i);return l===s?-1:a===s?1:r?r(o,i):0})}const Xi=Tm()(sd(n=>({viewMode:"visual",setViewMode:e=>n({viewMode:e}),showExecutionsList:!1,setShowExecutionsList:e=>n({showExecutionsList:e}),toggleExecutionsList:()=>n(e=>({showExecutionsList:!e.showExecutionsList}))}),{name:"workflow-view-mode"})),cd=A.createContext([]);function dd(){return A.useContext(cd)}function xe(n){this.content=n}xe.prototype={constructor:xe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new xe(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xe(t)},addToStart:function(n,e){return new xe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new xe(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xe.from(n),n.size?new xe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xe.from(n),n.size?new xe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};xe.from=function(n){if(n instanceof xe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xe(e)};function ud(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=ud(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function fd(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=fd(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class T{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new T(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new T(r,s)}cutByIndex(e,t){return e==t?T.empty:e==0&&t==this.content.length?this:new T(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new T(s,o)}addToStart(e){return new T([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new T(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return ud(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return fd(this,e,t,r)}findIndex(e){if(e==0)return wr(0,e);if(e==this.size)return wr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?wr(t+1,o):wr(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return T.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new T(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return T.empty;let t,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new T(t||e,r)}static from(e){if(!e)return T.empty;if(e instanceof T)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new T([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}T.empty=new T([],0);const yo={index:0,offset:0};function wr(n,e){return yo.index=n,yo.offset=e,yo}function Fr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Fr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Fr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Y=class Go{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Go.none;if(e instanceof Go)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};Y.none=[];class Hr extends Error{}class R{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=pd(this.content,e+this.openStart,t);return r&&new R(r,this.openStart,this.openEnd)}removeBetween(e,t){return new R(hd(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return R.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new R(T.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new R(e,r,s)}}R.empty=new R(T.empty,0,0);function hd(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(hd(o.content,e-s-1,t-s-1)))}function pd(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=pd(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function tg(n,e,t){if(t.openStart>n.depth)throw new Hr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Hr("Inconsistent open depths");return md(n,e,t,0)}function md(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=md(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Bt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=ng(t,n);return Bt(o,yd(n,i,l,e,r))}else return Bt(o,Vr(n,e,r))}function gd(n,e){if(!e.type.compatibleContent(n.type))throw new Hr("Cannot join "+e.type.name+" onto "+n.type.name)}function Xo(n,e,t){let r=n.node(t);return gd(r,e.node(t)),r}function _t(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hn(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(_t(n.nodeAfter,r),o++));for(let l=o;l<i;l++)_t(s.child(l),r);e&&e.depth==t&&e.textOffset&&_t(e.nodeBefore,r)}function Bt(n,e){return n.type.checkContent(e),n.copy(e)}function yd(n,e,t,r,s){let o=n.depth>s&&Xo(n,e,s+1),i=r.depth>s&&Xo(t,r,s+1),l=[];return Hn(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(gd(o,i),_t(Bt(o,yd(n,e,t,r,s+1)),l)):(o&&_t(Bt(o,Vr(n,e,s+1)),l),Hn(e,t,s,l),i&&_t(Bt(i,Vr(t,r,s+1)),l)),Hn(r,null,s,l),new T(l)}function Vr(n,e,t){let r=[];if(Hn(null,n,t,r),n.depth>t){let s=Xo(n,e,t+1);_t(Bt(s,Vr(n,e,t+1)),r)}return Hn(e,null,t,r),new T(r)}function ng(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(T.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Zn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Y.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Wr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new Zn(t,r,o)}static resolveCached(e,t){let r=ra.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else ra.set(e,r=new rg);let s=r.elts[r.i]=Zn.resolve(e,t);return r.i=(r.i+1)%sg,s}}class rg{constructor(){this.elts=[],this.i=0}}const sg=12,ra=new WeakMap;class Wr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const og=Object.create(null);class ze{constructor(e,t,r,s=Y.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||T.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Fr(this.attrs,t||e.defaultAttrs||og)&&Y.sameSet(this.marks,r||Y.none)}copy(e=null){return e==this.content?this:new ze(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ze(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return R.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new R(c,s.depth-i,o.depth-i)}replace(e,t,r){return tg(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return Zn.resolveCached(this,e)}resolveNoCache(e){return Zn.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),xd(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=T.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Y.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Y.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=T.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}ze.prototype.text=void 0;class qr extends ze{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):xd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new qr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new qr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function xd(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Wt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ig(e,t);if(r.next==null)return Wt.empty;let s=bd(r);r.next&&r.err("Unexpected trailing text");let o=hg(fg(s));return pg(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let f=o(u,l.concat(d));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
8
+ `)}}Wt.empty=new Wt(!0);class ig{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function bd(n){let e=[];do e.push(lg(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function lg(n){let e=[];do e.push(ag(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ag(n){let e=ug(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=cg(n,e);else break;return e}function sa(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function cg(n,e){let t=sa(n),r=t;return n.eat(",")&&(n.next!="}"?r=sa(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function dg(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function ug(n){if(n.eat("(")){let e=bd(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=dg(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function fg(n){let e=[[]];return s(o(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let d=t();s(o(i.expr,a),d),a=d}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let d=t();r(a,d),s(o(i.expr,a),d),a=d}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function kd(n,e){return e-n}function oa(n,e){let t=[];return r(e),t.sort(kd);function r(s){let o=n[s];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&r(a)}}}function hg(n){let e=Object.create(null);return t(oa(n,0));function t(r){let s=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);oa(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[r.join(",")]=new Wt(r.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(kd);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function pg(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function wd(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Sd(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let o=n[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function vd(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let o=n[s];o.validate&&o.validate(e[s])}}function Cd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new gg(n,r,e[r]);return t}let ia=class Nd{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Cd(e,r.attrs),this.defaultAttrs=wd(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==Wt.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:Sd(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ze(this,this.computeAttrs(e),T.from(t),Y.setFrom(r))}createChecked(e=null,t,r){return t=T.from(t),this.checkContent(t),new ze(this,this.computeAttrs(e),t,Y.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=T.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(T.empty,!0);return o?new ze(this,e,t.append(o),Y.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){vd(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Y.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,i)=>r[o]=new Nd(o,t,i));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function mg(n,e,t){let r=t.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class gg{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?mg(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class $s{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=Cd(e,s.attrs),this.excluded=null;let o=wd(this.attrs);this.instance=o?new Y(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Y(this,Sd(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new $s(o,s++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){vd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ed{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=xe.from(e.nodes),t.marks=xe.from(e.marks||{}),this.nodes=ia.compile(this.spec.nodes,this),this.marks=$s.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]=Wt.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=>ze.fromJSON(this,s),this.markFromJSON=s=>Y.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ia){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new qr(r,r.defaultAttrs,e,Y.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function la(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],o=n.marks[s],i=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function yg(n){return n.tag!=null}function xg(n){return n.style!=null}class kt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(yg(s))this.tags.push(s);else if(xg(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new ca(this,t,!1);return r.addAll(e,Y.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ca(this,t,!0);return r.addAll(e,Y.none,t.from,t.to),R.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(wg(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=da(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=da(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new kt(e,kt.schemaRules(e)))}}const Td={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},bg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Md={ol:!0,ul:!0},er=1,Yo=2,Vn=4;function aa(n,e,t){return e!=null?(e?er:0)|(e==="full"?Yo:0):n&&n.whitespace=="pre"?er|Yo:t&~Vn}class Sr{constructor(e,t,r,s,o,i){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=Y.none,this.match=o||(i&Vn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&er)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Td.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ca{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=aa(null,t.preserveWhitespace,0)|(r?Vn:0);s?o=new Sr(s.type,s.attrs,Y.none,!0,t.topMatch||s.type.contentMatch,i):r?o=new Sr(null,null,Y.none,!0,null,i):o=new Sr(e.schema.topNodeType,null,Y.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,o=s.options&Yo?"full":this.localPreserveWS||(s.options&er)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
9
+ `);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(i.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;Md.hasOwnProperty(i)&&this.parser.normalizeLists&&kg(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:bg.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Td.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(o),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
10
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,r){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=Y.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):ua(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,s)),o}enterInner(e,t,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=aa(e,o,i.options);i.options&Vn&&i.content.length==0&&(l|=Vn);let a=Y.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):ua(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Sr(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=er)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function kg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Md.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function wg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function da(n){let e={};for(let t in n)e[t]=n[t];return e}function ua(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||o.indexOf(d)<0&&i(d))return!0}};if(i(s.contentMatch))return!0}}class Xt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=xo(t).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(o.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Dr(xo(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Dr(xo(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Dr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Xt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=fa(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return fa(e.marks)}}function fa(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function xo(n){return n.document||window.document}const ha=new WeakMap;function Sg(n){let e=ha.get(n);return e===void 0&&ha.set(n,e=vg(n)),e}function vg(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Dr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Sg(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Dr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Ad=65535,Od=Math.pow(2,16);function Cg(n,e){return n+e*Od}function pa(n){return n&Ad}function Ng(n){return(n-(n&Ad))/Od}const Id=1,Rd=2,Pr=4,jd=8;class Qo{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&jd)>0}get deletedBefore(){return(this.delInfo&(Id|Pr))>0}get deletedAfter(){return(this.delInfo&(Rd|Pr))>0}get deletedAcross(){return(this.delInfo&Pr)>0}}class Re{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Re.empty)return Re.empty}recover(e){let t=0,r=pa(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Ng(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],d=this.ranges[l+i],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:Cg(l/3,e-a),g=e==a?Rd:e==u?Id:Pr;return(t<0?e!=a:e!=u)&&(g|=jd),new Qo(h,g,p)}s+=d-c}return r?e+s:new Qo(e+s,0,null)}touches(e,t){let r=0,s=pa(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],d=this.ranges[s+r];e(l,l+c,a,a+d),o+=d-c}}invert(){return new Re(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Re.empty:new Re(e<0?[0,-e,0]:[0,0,e])}}Re.empty=new Re([]);class tr{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new tr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new tr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Qo(e,s,null)}}const bo=Object.create(null);class Ne{getMap(){return Re.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=bo[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in bo)throw new RangeError("Duplicate use of step JSON ID "+e);return bo[e]=t,t.prototype.jsonID=e,t}}class de{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new de(e,null)}static fail(e){return new de(null,e)}static fromReplace(e,t,r,s){try{return de.ok(e.replace(t,r,s))}catch(o){if(o instanceof Hr)return de.fail(o.message);throw o}}}function Yi(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let o=n.child(s);o.content.size&&(o=o.copy(Yi(o.content,e,o))),o.isInline&&(o=e(o,t,s)),r.push(o)}return T.fromArray(r)}class yt extends Ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new R(Yi(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,o)}invert(){return new We(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new yt(t.pos,r.pos,this.mark)}merge(e){return e instanceof yt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new yt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new yt(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("addMark",yt);class We extends Ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new R(Yi(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new yt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new We(t.pos,r.pos,this.mark)}merge(e){return e instanceof We&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new We(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new We(t.from,t.to,e.markFromJSON(t.mark))}}Ne.jsonID("removeMark",We);class xt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new R(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new xt(this.pos,t.marks[s]);return new xt(this.pos,this.mark)}}return new qt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("addNodeMark",xt);class qt extends Ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new R(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new xt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new qt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new qt(t.pos,e.markFromJSON(t.mark))}}Ne.jsonID("removeNodeMark",qt);class he extends Ne{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Zo(e,this.from,this.to)?de.fail("Structure replace would overwrite content"):de.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Re([this.from,this.to-this.from,this.slice.size])}invert(e){return new he(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new he(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof he)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?R.empty:new R(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new he(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?R.empty:new R(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new he(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new he(t.from,t.to,R.fromJSON(e,t.slice),!!t.structure)}}Ne.jsonID("replace",he);class ge extends Ne{constructor(e,t,r,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(Zo(e,this.from,this.gapFrom)||Zo(e,this.gapTo,this.to)))return de.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return de.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?de.fromReplace(e,this.from,this.to,r):de.fail("Content does not fit in gap")}getMap(){return new Re([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ge(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||o>r.pos?null:new ge(t.pos,r.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ge(t.from,t.to,t.gapFrom,t.gapTo,R.fromJSON(e,t.slice),t.insert,!!t.structure)}}Ne.jsonID("replaceAround",ge);function Zo(n,e,t){let r=n.resolve(e),s=t-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Eg(n,e,t,r){let s=[],o=[],i,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(p)||(i&&i.to==f&&i.mark.eq(u[g])?i.to=h:s.push(i=new We(f,h,u[g])));l&&l.to==f?l.to=h:o.push(l=new yt(f,h,r))}}),s.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function Tg(n,e,t,r){let s=[],o=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof $s){let c=i.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==o-1&&u.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=o):s.push({style:u,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>n.step(new We(i.from,i.to,i.style)))}function Qi(n,e,t,r=t.contentMatch,s=!0){let o=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)i.push(new he(l,d,R.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new We(l,d,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new R(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new he(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(T.empty,!0);n.replace(l,l,new R(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Mg(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function jn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,o=0;;--r){let i=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-o;if(r<n.depth&&i.canReplace(l,a,t))return r;if(r==0||i.type.spec.isolating||!Mg(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function Ag(n,e,t){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,d=T.empty,u=0;for(let p=o,g=!1;p>t;p--)g||r.index(p)>0?(g=!0,d=T.from(r.node(p).copy(d)),u++):a--;let f=T.empty,h=0;for(let p=o,g=!1;p>t;p--)g||s.after(p+1)<s.end(p)?(g=!0,f=T.from(s.node(p).copy(f)),h++):c++;n.step(new ge(a,c,i,l,new R(d.append(f),u,h),d.size-u,!0))}function Zi(n,e,t=null,r=n){let s=Og(n,e),o=s&&Ig(r,e);return o?s.map(ma).concat({type:e,attrs:t}).concat(o.map(ma)):null}function ma(n){return{type:n,attrs:null}}function Og(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(r,s,i)?o:null}function Ig(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Rg(n,e,t){let r=T.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=T.from(t[i].type.create(t[i].attrs,r))}let s=e.start,o=e.end;n.step(new ge(s,o,s,o,new R(r,0,0),t.length,!0))}function jg(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&Dg(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Pd(n,i,l,o),Qi(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let d=n.mapping.slice(o),u=d.map(l,1),f=d.map(l+i.nodeSize,1);return n.step(new ge(u,f,u+1,f-1,new R(T.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Dd(n,i,l,o),!1}})}function Dd(n,e,t,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+o+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Pd(n,e,t,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+o);n.replaceWith(i,i+1,e.type.schema.text(`
11
+ `))}})}function Dg(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function Pg(n,e,t,r,s){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let i=t.create(r,null,s||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,i);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ge(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new R(T.from(i),0,0),1,!0))}function ot(n,e,t=1,r){let s=n.resolve(e),o=s.depth-t,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>o;c--,d--){let u=s.node(c),f=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[d]||u;if(!u.canReplace(f+1,u.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 Lg(n,e,t=1,r){let s=n.doc.resolve(e),o=T.empty,i=T.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){o=T.from(s.node(l).copy(o));let d=r&&r[c];i=T.from(d?d.type.create(d.attrs,i):s.node(l).copy(i))}n.step(new he(e,e,new R(o.append(i),t,t),!0))}function Tt(n,e){let t=n.resolve(e),r=t.index();return Ld(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function $g(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?n.type.schema.nodes.text:o.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(o.marks))return!1}return t.validEnd}function Ld(n,e){return!!(n&&e&&!n.isLeaf&&$g(n,e))}function zs(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let o,i,l=r.index(s);if(s==r.depth?(o=r.nodeBefore,i=r.nodeAfter):t>0?(o=r.node(s+1),l++,i=r.node(s).maybeChild(l)):(o=r.node(s).maybeChild(l-1),i=r.node(s+1)),o&&!o.isTextblock&&Ld(o,i)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function zg(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,o=n.doc.resolve(e-t),i=o.node().type;if(s&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);Pd(n,d.node(),d.before(),l)}i.inlineContent&&Qi(n,e+t-1,i,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new he(c,a.map(e+t,-1),R.empty,!0)),r===!0){let d=n.doc.resolve(c);Dd(n,d.node(),d.before(),n.steps.length)}return n}function _g(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,t))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,t))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function $d(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let o=0;o<t.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),d=!1;if(o==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function _s(n,e,t=e,r=R.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),o=n.resolve(t);return zd(s,o,r)?new he(e,t,r):new Bg(s,o,r).fit()}function zd(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Bg{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=T.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=T.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let o=this.placed,i=r.depth,l=s.depth;for(;i&&l&&o.childCount==1;)o=o.firstChild.content,i--,l--;let a=new R(o,i,l);return e>-1?new ge(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new he(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=t.firstChild;if(t.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=ko(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],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(T.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=ko(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new R(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=ko(e,t);if(s.childCount<=1&&t>0){let o=e.size-t<=t+s.size;this.unplaced=new R(zn(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new R(zn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let g=0;g<o.length;g++)this.openFrontierNode(o[g]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(s){for(let g=0;g<s.childCount;g++)d.push(s.child(g));u=u.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let g=l.child(c),y=u.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(u=y,d.push(_d(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=_n(this.placed,t,T.from(d)),this.frontier[t].match=u,p&&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=p?e==0?R.empty:new R(zn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new R(zn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!wo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=wo(e,t,s,r,o);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=wo(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=_n(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=_n(this.placed,this.depth,T.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=_n(this.placed,this.frontier.length,t))}}function zn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(zn(n.firstChild.content,e-1,t)))}function _n(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(_n(n.lastChild.content,e-1,t)))}function ko(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function _d(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,_d(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(T.empty,!0)))),n.copy(r)}function wo(n,e,t,r,s){let o=n.node(e),i=s?n.indexAfter(e):n.index(e);if(i==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,i);return l&&!Fg(t,o.content,i)?l:null}function Fg(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Hg(n){return n.spec.defining||n.spec.definingForContent}function Vg(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),o=n.doc.resolve(t);if(zd(s,o,r))return n.step(new he(e,t,r));let i=Fd(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 p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=Hg(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)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,p.type,p.marks))return n.replace(s.before(y),x?o.after(y):t,new R(Bd(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=i.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=i[f];h<0||(e=s.before(h),t=o.after(h))}}function Bd(n,e,t,r,s){if(e<t){let o=n.firstChild;n=n.replaceChild(0,o.copy(Bd(o.content,e+1,t,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(n).append(n);n=i.append(o.matchFragment(i).fillBefore(T.empty,!0))}return n}function Wg(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=_g(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new R(T.from(r),0,0))}function qg(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),o=Fd(r,s);for(let i=0;i<o.length;i++){let l=o[i],a=i==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&s.end(i)-t!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function Fd(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let o=n.start(s);if(o<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&t.push(s)}return t}class yn extends Ne{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return de.fromReplace(e,this.pos,this.pos+1,new R(T.from(s),0,t.isLeaf?0:1))}getMap(){return Re.empty}invert(e){return new yn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new yn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new yn(t.pos,t.attr,t.value)}}Ne.jsonID("attr",yn);class nr extends Ne{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return de.ok(r)}getMap(){return Re.empty}invert(e){return new nr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new nr(t.attr,t.value)}}Ne.jsonID("docAttr",nr);let kn=class extends Error{};kn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};kn.prototype=Object.create(Error.prototype);kn.prototype.constructor=kn;kn.prototype.name="TransformError";class Hd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new kn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=R.empty){let s=_s(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new R(T.from(r),0,0))}delete(e,t){return this.replace(e,t,R.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Vg(this,e,t,r),this}replaceRangeWith(e,t,r){return Wg(this,e,t,r),this}deleteRange(e,t){return qg(this,e,t),this}lift(e,t){return Ag(this,e,t),this}join(e,t=1){return zg(this,e,t),this}wrap(e,t){return Rg(this,e,t),this}setBlockType(e,t=e,r,s=null){return jg(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return Pg(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new yn(e,t,r)),this}setDocAttribute(e,t){return this.step(new nr(e,t)),this}addNodeMark(e,t){return this.step(new xt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Y)t.isInSet(r.marks)&&this.step(new qt(e,t));else{let s=r.marks,o,i=[];for(;o=t.isInSet(s);)i.push(new qt(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return Lg(this,e,t,r),this}addMark(e,t,r){return Eg(this,e,t,r),this}removeMark(e,t,r){return Tg(this,e,t,r),this}clearIncompatible(e,t,r){return Qi(this,e,t,r),this}}const So=Object.create(null);class q{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Ug(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=R.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(o);e.replaceRange(d.map(a.pos),d.map(c.pos),l?R.empty:t),l==0&&xa(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:l}=s[o],a=e.mapping.slice(r),c=a.map(i.pos),d=a.map(l.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),xa(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new F(e):fn(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=t<0?fn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):fn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new je(e.node(0))}static atStart(e){return fn(e,e,0,0,1)||new je(e)}static atEnd(e){return fn(e,e,e.content.size,e.childCount,-1)||new je(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=So[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in So)throw new RangeError("Duplicate use of selection JSON ID "+e);return So[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class Ug{constructor(e,t){this.$from=e,this.$to=t}}let ga=!1;function ya(n){!ga&&!n.parent.inlineContent&&(ga=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class F extends q{constructor(e,t=e){ya(e),ya(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return q.near(r);let s=e.resolve(t.map(this.anchor));return new F(s.parent.inlineContent?s:r,r)}replace(e,t=R.empty){if(super.replace(e,t),t==R.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof F&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Bs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new F(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let o=q.findFrom(t,r,!0)||q.findFrom(t,-r,!0);if(o)t=o.$head;else return q.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new F(e,t)}}q.jsonID("text",F);class Bs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Bs(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}}class $ extends q{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),o=e.resolve(s);return r?q.near(o):new $(o)}content(){return new R(T.from(this.node),0,0)}eq(e){return e instanceof $&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new el(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $(e.resolve(t.anchor))}static create(e,t){return new $(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}$.prototype.visible=!1;q.jsonID("node",$);class el{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Bs(r,r):new el(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&$.isSelectable(r)?new $(t):q.near(t)}}class je extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=R.empty){if(t==R.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new je(e)}map(e){return new je(e)}eq(e){return e instanceof je}getBookmark(){return Kg}}q.jsonID("all",je);const Kg={map(){return this},resolve(n){return new je(n)}};function fn(n,e,t,r,s,o=!1){if(e.inlineContent)return F.create(n,t);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!o&&$.isSelectable(l))return $.create(n,t-(s<0?l.nodeSize:0))}else{let a=fn(n,l,t+s,s<0?l.childCount:0,s,o);if(a)return a}t+=l.nodeSize*s}return null}function xa(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof he||s instanceof ge))return;let o=n.mapping.maps[r],i;o.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(q.near(n.doc.resolve(i),t))}const ba=1,vr=2,ka=4;class Jg extends Hd{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|ba)&~vr,this.storedMarks=null,this}get selectionSet(){return(this.updated&ba)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=vr,this}ensureMarks(e){return Y.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&vr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~vr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Y.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(t);o=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(q.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ka,this}get scrolledIntoView(){return(this.updated&ka)>0}}function wa(n,e){return!e||!n?n:n.bind(e)}class Bn{constructor(e,t,r){this.name=e,this.init=wa(t.init,r),this.apply=wa(t.apply,r)}}const Gg=[new Bn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Bn("selection",{init(n,e){return n.selection||q.atStart(e.doc)},apply(n){return n.selection}}),new Bn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Bn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class vo{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Gg.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Bn(r.key,r.spec.state,r))})}}class gn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(d&&r.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<i?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),o=!0}s&&(s[i]={state:r,n:t.length})}}if(!o)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new gn(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Jg(this)}static create(e){let t=new vo(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new gn(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new vo(this.schema,e.plugins),r=t.fields,s=new gn(t);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],o=s.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new vo(e.schema,e.plugins),o=new gn(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=ze.fromJSON(e.schema,t.doc);else if(i.name=="selection")o.selection=q.fromJSON(o.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[i.name]=c.fromJSON.call(a,e,t[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function Vd(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Vd(s,e,{})),t[r]=s}return t}class re{constructor(e){this.spec=e,this.props={},e.props&&Vd(e.props,this,this.props),this.key=e.key?e.key.key:Wd("plugin")}getState(e){return e[this.key]}}const Co=Object.create(null);function Wd(n){return n in Co?n+"$"+ ++Co[n]:(Co[n]=0,n+"$")}class ae{constructor(e="key"){this.key=Wd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const tl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function qd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Ud=(n,e,t)=>{let r=qd(n,t);if(!r)return!1;let s=nl(r);if(!s){let i=r.blockRange(),l=i&&jn(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(tu(n,s,e,-1))return!0;if(r.parent.content.size==0&&(wn(o,"end")||$.isSelectable(o)))for(let i=r.depth;;i--){let l=_s(n.doc,r.before(i),r.after(i),R.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(wn(o,"end")?q.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):$.create(a.doc,s.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},Xg=(n,e,t)=>{let r=qd(n,t);if(!r)return!1;let s=nl(r);return s?Kd(n,s,e):!1},Yg=(n,e,t)=>{let r=Gd(n,t);if(!r)return!1;let s=rl(r);return s?Kd(n,s,e):!1};function Kd(n,e,t){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=_s(n.doc,o,a,R.empty);if(!c||c.from!=o||c instanceof he&&c.slice.size>=a-o)return!1;if(t){let d=n.tr.step(c);d.setSelection(F.create(d.doc,o)),t(d.scrollIntoView())}return!0}function wn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Jd=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=nl(r)}let i=o&&o.nodeBefore;return!i||!$.isSelectable(i)?!1:(e&&e(n.tr.setSelection($.create(n.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function nl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Gd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Xd=(n,e,t)=>{let r=Gd(n,t);if(!r)return!1;let s=rl(r);if(!s)return!1;let o=s.nodeAfter;if(tu(n,s,e,1))return!0;if(r.parent.content.size==0&&(wn(o,"start")||$.isSelectable(o))){let i=_s(n.doc,r.before(),r.after(),R.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(wn(o,"start")?q.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):$.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},Yd=(n,e,t)=>{let{$head:r,empty:s}=n.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;o=rl(r)}let i=o&&o.nodeAfter;return!i||!$.isSelectable(i)?!1:(e&&e(n.tr.setSelection($.create(n.doc,o.pos)).scrollIntoView()),!0)};function rl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Qg=(n,e)=>{let t=n.selection,r=t instanceof $,s;if(r){if(t.node.isTextblock||!Tt(n.doc,t.from))return!1;s=t.from}else if(s=zs(n.doc,t.from,-1),s==null)return!1;if(e){let o=n.tr.join(s);r&&o.setSelection($.create(o.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Zg=(n,e)=>{let t=n.selection,r;if(t instanceof $){if(t.node.isTextblock||!Tt(n.doc,t.to))return!1;r=t.to}else if(r=zs(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},e1=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),o=s&&jn(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)},Qd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
12
+ `).scrollIntoView()),!0)};function sl(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const t1=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),o=t.indexAfter(-1),i=sl(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(q.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Zd=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof je||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=sl(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(i,o.createAndFill());l.setSelection(F.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},eu=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(ot(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),s=r&&jn(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function n1(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof $&&e.selection.node.isBlock)return!r.parentOffset||!ot(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],i,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=sl(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 d=e.tr;(e.selection instanceof F||e.selection instanceof je)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=ot(d.doc,u,o.length,o);if(f||(o[0]=l?{type:l}:null,f=ot(d.doc,u,o.length,o)),!f)return!1;if(d.split(u,o.length,o),!a&&c&&r.node(i).type!=l){let h=d.mapping.map(r.before(i)),p=d.doc.resolve(h);l&&r.node(i-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(i)),l)}return t&&t(d.scrollIntoView()),!0}}const r1=n1(),s1=(n,e)=>{let{$from:t,to:r}=n.selection,s,o=t.sharedDepth(r);return o==0?!1:(s=t.before(o),e&&e(n.tr.setSelection($.create(n.doc,s))),!0)};function o1(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,o=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||Tt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function tu(n,e,t,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&o1(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&l.matchType(i[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=T.empty;for(let x=i.length-1;x>=0;x--)p=T.from(i[x].create(null,p));p=T.from(s.copy(p));let g=n.tr.step(new ge(e.pos-1,h,e.pos,h,new R(p,1,0),i.length,!0)),y=g.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==s.type&&Tt(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let d=o.type.spec.isolating||r>0&&a?null:q.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&jn(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&wn(o,"start",!0)&&wn(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let g=o,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let x=T.empty;for(let k=p.length-1;k>=0;k--)x=T.from(p[k].copy(x));let b=n.tr.step(new ge(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new R(x,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function nu(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(t&&t(e.tr.setSelection(F.create(e.doc,n<0?s.start(o):s.end(o)))),!0):!1}}const i1=nu(-1),l1=nu(1);function a1(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o),l=i&&Zi(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function Sa(n,e=null){return function(t,r){let s=!1;for(let o=0;o<t.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let o=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];o.setBlockType(l,a,n,e)}r(o.scrollIntoView())}return!0}}function ol(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}ol(tl,Ud,Jd);ol(tl,Xd,Yd);ol(Qd,Zd,eu,r1);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function c1(n,e=null){return function(t,r){let{$from:s,$to:o}=t.selection,i=s.blockRange(o);if(!i)return!1;let l=r?t.tr:null;return d1(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function d1(n,e,t,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);o=new Wr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Wr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Zi(o,t,r,e);return l?(n&&u1(n,e,l,s,t),!0):!1}function u1(n,e,t,r,s){let o=T.empty;for(let d=t.length-1;d>=0;d--)o=T.from(t[d].type.create(t[d].attrs,o));n.step(new ge(e.start-(r?2:0),e.end,e.start,e.end,new R(o,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==s&&(i=d+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&ot(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function f1(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?h1(e,t,n,o):p1(e,t,o):!0:!1}}function h1(n,e,t,r){let s=n.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new ge(o-1,i,o,i,new R(T.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Wr(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=jn(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Tt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function p1(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,p=t.endIndex-1,g=t.startIndex;p>g;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(t.start),i=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+(l?0:1),d+1,i.content.append(a?T.empty:T.from(s))))return!1;let u=o.pos,f=u+i.nodeSize;return r.step(new ge(u-(l?1:0),f+(a?1:0),u+1,f-1,new R((l?T.empty:T.from(s.copy(T.empty))).append(a?T.empty:T.from(s.copy(T.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function m1(n){return function(e,t){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=T.from(c?n.create():null),u=new R(T.from(n.create(null,T.from(l.type.create(null,d)))),c?3:1,0),f=o.start,h=o.end;t(e.tr.step(new ge(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}const be=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Sn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let ei=null;const rt=function(n,e,t){let r=ei||(ei=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},g1=function(){ei=null},Ut=function(n,e,t,r){return t&&(va(n,e,t,r,-1)||va(n,e,t,r,1))},y1=/^(img|br|input|textarea|hr)$/i;function va(n,e,t,r,s){for(var o;;){if(n==t&&e==r)return!0;if(e==(s<0?0:$e(n))){let i=n.parentNode;if(!i||i.nodeType!=1||mr(n)||y1.test(n.nodeName)||n.contentEditable=="false")return!1;e=be(n)+(s<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else n=i,e=s<0?$e(n):0}else return!1}}function $e(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function x1(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=$e(n)}else if(n.parentNode&&!mr(n))e=be(n),n=n.parentNode;else return null}}function b1(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!mr(n))e=be(n)+1,n=n.parentNode;else return null}}function k1(n,e,t){for(let r=e==0,s=e==$e(n);r||s;){if(n==t)return!0;let o=be(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,s=s&&o==$e(n)}}function mr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Fs=function(n){return n.focusNode&&Ut(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ot(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function w1(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function S1(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min($e(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min($e(r.startContainer),r.startOffset)}}}const Ge=typeof navigator<"u"?navigator:null,Ca=typeof document<"u"?document:null,Mt=Ge&&Ge.userAgent||"",ti=/Edge\/(\d+)/.exec(Mt),ru=/MSIE \d/.exec(Mt),ni=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Mt),Oe=!!(ru||ni||ti),wt=ru?document.documentMode:ni?+ni[1]:ti?+ti[1]:0,_e=!Oe&&/gecko\/(\d+)/i.test(Mt);_e&&+(/Firefox\/(\d+)/.exec(Mt)||[0,0])[1];const ri=!Oe&&/Chrome\/(\d+)/.exec(Mt),pe=!!ri,su=ri?+ri[1]:0,Ce=!Oe&&!!Ge&&/Apple Computer/.test(Ge.vendor),vn=Ce&&(/Mobile\/\w+/.test(Mt)||!!Ge&&Ge.maxTouchPoints>2),Le=vn||(Ge?/Mac/.test(Ge.platform):!1),ou=Ge?/Win/.test(Ge.platform):!1,st=/Android \d/.test(Mt),gr=!!Ca&&"webkitFontSmoothing"in Ca.documentElement.style,v1=gr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function C1(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ze(n,e){return typeof n=="number"?n:n[e]}function N1(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Na(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=Sn(i);continue}let l=i,a=l==o.body,c=a?C1(o):N1(l),d=0,u=0;if(e.top<c.top+Ze(r,"top")?u=-(c.top-e.top+Ze(s,"top")):e.bottom>c.bottom-Ze(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Ze(s,"top")-c.top:e.bottom-c.bottom+Ze(s,"bottom")),e.left<c.left+Ze(r,"left")?d=-(c.left-e.left+Ze(s,"left")):e.right>c.right-Ze(r,"right")&&(d=e.right-c.right+Ze(s,"right")),d||u)if(a)o.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let g=l.scrollLeft-h,y=l.scrollTop-p;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:Sn(i)}}function E1(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(o,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:iu(n.dom)}}function iu(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Sn(r));return e}function T1({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;lu(t,r==0?0:r-e)}function lu(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:o}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let dn=null;function M1(n){if(n.setActive)return n.setActive();if(dn)return n.focus(dn);let e=iu(n);n.focus(dn==null?{get preventScroll(){return dn={preventScroll:!0},!0}}:void 0),dn||(dn=!1,lu(e,0))}function au(n,e){let t,r=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=rt(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){t=d,r=g,s=g&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&g&&(o=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=u+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?A1(t,s):!t||r&&t.nodeType==1?{node:n,offset:o}:au(t,s)}function A1(n,e){let t=n.nodeValue.length,r=document.createRange(),s;for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let i=ut(r,1);if(i.top!=i.bottom&&il(e,i)){s={node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:n,offset:0}}function il(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function O1(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function I1(n,e,t){let{node:r,offset:s}=au(e,t),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,s,o)}function R1(n,e,t,r){let s=-1;for(let o=e,i=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!i&&a.left>r.left||a.top>r.top?s=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function cu(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),o=s;;){let i=n.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(il(e,c))return cu(i,e,c)}}if((o=(o+1)%r)==s)break}return n}function j1(n,e){let t=n.dom.ownerDocument,r,s=0,o=S1(t,e.left,e.top);o&&({node:r,offset:s}=o);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!il(e,c)||(i=cu(n.dom,e,c),!i))return null}if(Ce)for(let c=i;r&&c;c=Sn(c))c.draggable&&(r=void 0);if(i=O1(i,e),r){if(_e&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;gr&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=R1(n,r,s,e))}l==null&&(l=I1(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ea(n){return n.top<n.bottom||n.left<n.right}function ut(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Ea(r))return r}return Array.prototype.find.call(t,Ea)||n.getBoundingClientRect()}const D1=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function du(n,e,t){let{node:r,offset:s,atom:o}=n.docView.domFromPos(e,t<0?-1:1),i=gr||_e;if(r.nodeType==3)if(i&&(D1.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=ut(rt(r,s,s),t);if(_e&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=ut(rt(r,s-1,s-1),-1);if(c.top==a.top){let d=ut(rt(r,s,s+1),-1);if(d.top!=a.top)return Ln(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==r.nodeValue.length?(a--,d=1):t<0?a--:c++,Ln(ut(rt(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(t<0||s==$e(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return No(a.getBoundingClientRect(),!1)}if(o==null&&s<$e(r)){let a=r.childNodes[s];if(a.nodeType==1)return No(a.getBoundingClientRect(),!0)}return No(r.getBoundingClientRect(),t>=0)}if(o==null&&s&&(t<0||s==$e(r))){let a=r.childNodes[s-1],c=a.nodeType==3?rt(a,$e(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Ln(ut(c,1),!1)}if(o==null&&s<$e(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?rt(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Ln(ut(c,-1),!0)}return Ln(ut(r.nodeType==3?rt(r):r,-t),t>=0)}function Ln(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function No(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function uu(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function P1(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return uu(n,e,()=>{let{node:o}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=du(n,s.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=rt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const L1=/[\u0590-\u08ac]/;function $1(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,l=n.domSelection();return l?!L1.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:i:uu(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:g}=n.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):r.pos==r.start()||r.pos==r.end()}let Ta=null,Ma=null,Aa=!1;function z1(n,e,t){return Ta==e&&Ma==t?Aa:(Ta=e,Ma=t,Aa=t=="up"||t=="down"?P1(n,e,t):$1(n,e,t))}const Be=0,Oa=1,It=2,Xe=3;class yr{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=Be,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>be(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!t||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],o=r+s.size;if(r==e&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-r-s.border);r=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],l=o+i.size;if(l>e||i instanceof hu){s=e-o;break}o=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof fu&&o.side>=0;r--);if(t<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&t&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?be(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?be(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let d=i+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=i;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=be(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=be(u.dom);break}t+=u.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let g=this.children[h],y=p+g.size;if(o>p&&i<y)return g.setSelection(e-p-g.border,t-p-g.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((_e||Ce)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
13
+ `),u&&p==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:be(y)+1});break}let x=g.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let g=h.childNodes[p-1];u=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(_e&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&Ce)&&Ut(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Ut(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&_e)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+o.border,a=i-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?It:Oa,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Xe:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?It:Xe}r=i}this.dirty=It}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?It:Oa;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class fu extends yr{constructor(e,t,r,s){let o,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Be&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class _1 extends yr{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Kt extends yr{constructor(e,t,r,s,o){super(e,[],r,s),this.mark=t,this.spec=o}static create(e,t,r,s){let o=s.nodeViews[t.type.name],i=o&&o(t,s,r);return(!i||!i.dom)&&(i=Xt.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Kt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Xe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Xe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Be){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Be}}slice(e,t,r){let s=Kt.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;t<i&&(o=oi(o,t,i,r)),e>0&&(o=oi(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class St extends yr{constructor(e,t,r,s,o,i,l,a,c){super(e,[],o,i),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,o,i){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Xt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=gu(d,r,t),c?a=new B1(e,t,r,s,d,u||null,f,c,o,i+1):t.isText?new Hs(e,t,r,s,d,f,o):new St(e,t,r,s,d,u||null,f,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,t,r){return this.dirty==Be&&e.eq(this.node)&&Ur(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new H1(this,i&&i.node,e);q1(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?Y.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,s)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==It)&&(i&&this.protectLocalComposition(e,i),pu(this.contentDOM,this.children,e),vn&&U1(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof F)||r<t||s>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,l=K1(this.node.content,i,r-t,s-t);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new _1(this,o,t,s);e.input.compositionNodes.push(i),this.children=oi(this.children,r,r+s.length,e,i)}update(e,t,r,s){return this.dirty==Xe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Be}updateOuterDeco(e){if(Ur(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=mu(this.dom,this.nodeDOM,si(this.outerDeco,this.node,t),si(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ia(n,e,t,r,s){gu(r,e,n);let o=new St(void 0,n,e,t,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class Hs extends St{constructor(e,t,r,s,o,i,l){super(e,t,r,s,o,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==Xe||this.dirty!=Be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Be||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Be,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),o=document.createTextNode(s.text);return new Hs(this.parent,s,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Xe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class hu extends yr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class B1 extends St{constructor(e,t,r,s,o,i,l,a,c,d){super(e,t,r,s,o,i,l,c,d),this.spec=a}update(e,t,r,s){if(this.dirty==Xe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function pu(n,e,t){let r=n.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=Ra(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(i instanceof Kt){let a=r?r.previousSibling:n.lastChild;pu(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Ra(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const Wn=function(n){n&&(this.nodeName=n)};Wn.prototype=Object.create(null);const Rt=[new Wn];function si(n,e,t){if(n.length==0)return Rt;let r=t?Rt[0]:new Wn,s=[r];for(let o=0;o<n.length;o++){let i=n[o].type.attrs;if(i){i.nodeName&&s.push(r=new Wn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&s.length==1&&s.push(r=new Wn(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 mu(n,e,t,r){if(t==Rt&&r==Rt)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],l=t[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Rt[0]),s=a}F1(s,l||Rt[0],i)}return s}function F1(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&n.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&n.classList.add(s[o]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function gu(n,e,t){return mu(n,n,Rt,si(e,t,n.nodeType!=1))}function Ur(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ra(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class H1{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=V1(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=Be,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Kt.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))o=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,r,s,o){let i=this.top.children[s];return i.dirty==Xe&&i.dom==i.contentDOM&&(i.dirty=It),i.update(e,t,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof St){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Xe&&Ur(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=It,u.updateChildren(s,i+1),u.dirty=Be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ur(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=St.create(this.top,t,r,s,o,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,o){let i=St.create(this.top,e,t,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new fu(this.top,e,t,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Kt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Hs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ce||pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new hu(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function V1(n,e){let t=e,r=t.children.length,s=n.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Kt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function W1(n,e){return n.type.side-e.type.side}function q1(n,e,t,r){let s=e.locals(n),o=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,s,e.forChild(o,d),c),o+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<s.length&&s[i].to==o;){let y=s[i++];y.widget&&(d?(u||(u=[d])).push(y):d=y)}if(d)if(u){u.sort(W1);for(let y=0;y<u.length;y++)t(u[y],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let p=o+f.nodeSize;if(f.isText){let y=p;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<p&&(a=f.cut(y-o),f=f.cut(0,y-o),p=y,h=-1)}else for(;i<s.length&&s[i].to<p;)i++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(o,f),h),o=p}}function U1(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function K1(n,e,t,r){for(let s=0,o=0;s<n.childCount&&o<=r;){let i=n.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<n.childCount;){let c=n.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function oi(n,e,t,r,s){let o=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),s&&(o.push(s),s=void 0),d>t&&o.push(a.slice(t-c,a.size,r)))}return o}function ll(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),o=s&&s.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Fs(t)){for(a=i;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&$.isSelectable(u)&&s.parent&&!(u.isInline&&k1(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new $(i==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,f=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,i]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!o?1:-1;c=al(n,d,l,u)}return c}function yu(n){return n.editable?n.hasFocus():bu(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function it(n,e=!1){let t=n.state.selection;if(xu(n,t),!!yu(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&pe){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Ut(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)G1(n);else{let{anchor:r,head:s}=t,o,i;ja&&!(t instanceof F)&&(t.$from.parent.inlineContent||(o=Da(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Da(n,t.to))),n.docView.setSelection(r,s,n,e),ja&&(o&&Pa(o),i&&Pa(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&J1(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const ja=Ce||pe&&su<63;function Da(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,o=r?t.childNodes[r-1]:null;if(Ce&&s&&s.contentEditable=="false")return Eo(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Eo(s);if(o)return Eo(o)}}function Eo(n){return n.contentEditable="true",Ce&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Pa(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function J1(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!yu(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function G1(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,be(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&Oe&&wt<=11&&(t.disabled=!0,t.disabled=!1)}function xu(n,e){if(e instanceof $){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(La(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else La(n)}function La(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function al(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||F.between(e,t,r)}function $a(n){return n.editable&&!n.hasFocus()?!1:bu(n)}function bu(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function X1(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ut(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ii(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),o=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return o&&q.findFrom(o,e)}function ft(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function za(n,e,t){let r=n.state.selection;if(r instanceof F)if(t.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=n.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return ft(n,new F(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=ii(n.state,e);return s&&s instanceof $?ft(n,s):!1}else if(!(Le&&t.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?$.isSelectable(o)?ft(n,new $(e<0?n.state.doc.resolve(s.pos-o.nodeSize):s)):gr?ft(n,new F(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof $&&r.node.isInline)return ft(n,new F(e>0?r.$to:r.$from));{let s=ii(n.state,e);return s?ft(n,s):!1}}}function Kr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function qn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function un(n,e){return e<0?Y1(n):Q1(n)}function Y1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,o,i=!1;for(_e&&t.nodeType==1&&r<Kr(t)&&qn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(qn(l,-1))s=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(ku(t))break;{let l=t.previousSibling;for(;l&&qn(l,-1);)s=t.parentNode,o=be(l),l=l.previousSibling;if(l)t=l,r=Kr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?li(n,t,r):s&&li(n,s,o)}function Q1(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=Kr(t),o,i;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(qn(l,1))o=t,i=++r;else break}else{if(ku(t))break;{let l=t.nextSibling;for(;l&&qn(l,1);)o=l.parentNode,i=be(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=Kr(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}o&&li(n,o,i)}function ku(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Z1(n,e){for(;n&&e==n.childNodes.length&&!mr(n);)e=be(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function e0(n,e){for(;n&&!e&&!mr(n);)e=be(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function li(n,e,t){if(e.nodeType!=3){let o,i;(i=Z1(e,t))?(e=i,t=0):(o=e0(e,t))&&(e=o,t=o.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Fs(r)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&it(n)},50)}function _a(n,e){let t=n.state.doc.resolve(e);if(!(pe||ou)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ba(n,e,t){let r=n.state.selection;if(r instanceof F&&!r.empty||t.indexOf("s")>-1||Le&&t.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=ii(n.state,e);if(i&&i instanceof $)return ft(n,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof je?q.near(i,e):q.findFrom(i,e);return l?ft(n,l):!1}return!1}function Fa(n,e){if(!(n.state.selection instanceof F))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let i=n.state.tr;return e<0?i.delete(t.pos-o.nodeSize,t.pos):i.delete(t.pos,t.pos+o.nodeSize),n.dispatch(i),!0}return!1}function Ha(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function t0(n){if(!Ce||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ha(n,r,"true"),setTimeout(()=>Ha(n,r,"false"),20)}return!1}function n0(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function r0(n,e){let t=e.keyCode,r=n0(e);if(t==8||Le&&t==72&&r=="c")return Fa(n,-1)||un(n,-1);if(t==46&&!e.shiftKey||Le&&t==68&&r=="c")return Fa(n,1)||un(n,1);if(t==13||t==27)return!0;if(t==37||Le&&t==66&&r=="c"){let s=t==37?_a(n,n.state.selection.from)=="ltr"?-1:1:-1;return za(n,s,r)||un(n,s)}else if(t==39||Le&&t==70&&r=="c"){let s=t==39?_a(n,n.state.selection.from)=="ltr"?1:-1:1;return za(n,s,r)||un(n,s)}else{if(t==38||Le&&t==80&&r=="c")return Ba(n,-1,r)||un(n,-1);if(t==40||Le&&t==78&&r=="c")return t0(n)||Ba(n,1,r)||un(n,1);if(r==(Le?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function cl(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||Xt.fromSchema(n.state.schema),l=Eu(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Nu[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
14
+
15
+ `);return{dom:a,text:f,slice:e}}function wu(n,e,t,r,s){let o=s.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=!!e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,o||r,n)}),o)return l=new R(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
16
+ `))),0,0),n.someProp("transformPasted",f=>{l=f(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(u)l=u;else{let f=s.marks(),{schema:h}=n.state,p=Xt.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=i.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(h.text(g,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=l0(t),gr&&a0(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||kt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!s0.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=c0(Va(l,+d[1],+d[2]),d[4]);else if(l=R.maxOpen(o0(l.content,s),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Va(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n,a)}),l}const s0=/^(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 o0(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),o,i=[];if(n.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&vu(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=Cu(i[i.length-1],o.length));let d=Su(l,a);i.push(d),s=s.matchType(d.type),o=a}}),i)return T.from(i)}return n}function Su(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,T.from(n));return n}function vu(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let o=vu(n,e,t,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(T.from(Su(t,n,s+1))))}}function Cu(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Cu(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(r))}function ai(n,e,t,r,s,o){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(o=0),s<r-1&&(l=ai(l,e,t,r,s+1,o)),s>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function Va(n,e,t){return e<n.openStart&&(n=new R(ai(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new R(ai(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Nu={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 Wa=null;function Eu(){return Wa||(Wa=document.implementation.createHTMLDocument("title"))}let To=null;function i0(n){let e=window.trustedTypes;return e?(To||(To=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),To.createHTML(n)):n}function l0(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Eu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&Nu[r[1].toLowerCase()])&&(n=s.map(o=>"<"+o+">").join("")+n+s.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=i0(n),s)for(let o=0;o<s.length;o++)t=t.querySelector(s[o])||t;return t}function a0(n){let e=n.querySelectorAll(pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function c0(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:o,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=T.from(a.create(r[l+1],s)),o++,i++}return new R(s,o,i)}const Ee={},Te={},d0={touchstart:!0,touchmove:!0};class u0{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 f0(n){for(let e in Ee){let t=Ee[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{p0(n,r)&&!dl(n,r)&&(n.editable||!(r.type in Te))&&t(n,r)},d0[e]?{passive:!0}:void 0)}Ce&&n.dom.addEventListener("input",()=>null),ci(n)}function bt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function h0(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ci(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>dl(n,r))})}function dl(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function p0(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function m0(n,e){!dl(n,e)&&Ee[e.type]&&(n.editable||!(e.type in Te))&&Ee[e.type](n,e)}Te.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Mu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(st&&pe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),vn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,Ot(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||r0(n,t)?t.preventDefault():bt(n,"key")};Te.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Te.keypress=(n,e)=>{let t=e;if(Mu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Le&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof F)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode),o=()=>n.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s,o))&&n.dispatch(o()),t.preventDefault()}};function Vs(n){return{left:n.clientX,top:n.clientY}}function g0(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ul(n,e,t,r,s){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(n.someProp(e,l=>i>o.depth?l(n,t,o.nodeAfter,o.before(i),s,!0):l(n,t,o.node(i),o.before(i),s,!1)))return!0;return!1}function xn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function y0(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&$.isSelectable(r)?(xn(n,new $(t)),!0):!1}function x0(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof $&&(r=t.node);let o=n.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if($.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?s=o.before(t.$from.depth):s=o.before(i);break}}return s!=null?(xn(n,$.create(n.state.doc,s)),!0):!1}function b0(n,e,t,r,s){return ul(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(s?x0(n,t):y0(n,t))}function k0(n,e,t,r){return ul(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function w0(n,e,t,r){return ul(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||S0(n,t,r)}function S0(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(xn(n,F.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)xn(n,F.create(r,l+1,l+1+i.content.size));else if($.isSelectable(i))xn(n,$.create(r,l));else continue;return!0}}function fl(n){return Jr(n)}const Tu=Le?"metaKey":"ctrlKey";Ee.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=fl(n),s=Date.now(),o="singleClick";s-n.input.lastClick.time<500&&g0(t,n.input.lastClick)&&!t[Tu]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:o,button:t.button};let i=n.posAtCoords(Vs(t));i&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new v0(n,i,t,!!r)):(o=="doubleClick"?k0:w0)(n,i.pos,i.inside,t)?t.preventDefault():bt(n,"pointer"))};class v0{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Tu],this.allowDefault=r.shiftKey;let o,i;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);o=d.parent,i=d.depth?d.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 $&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&_e&&!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)),bt(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(()=>it(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Vs(e))),this.updateAllowDefault(e),this.allowDefault||!t?bt(this.view,"pointer"):b0(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ce&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(xn(this.view,q.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):bt(this.view,"pointer")}move(e){this.updateAllowDefault(e),bt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ee.touchstart=n=>{n.input.lastTouch=Date.now(),fl(n),bt(n,"pointer")};Ee.touchmove=n=>{n.input.lastTouch=Date.now(),bt(n,"pointer")};Ee.contextmenu=n=>fl(n);function Mu(n,e){return n.composing?!0:Ce&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const C0=st?5e3:-1;Te.compositionstart=Te.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof F&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||pe&&ou&&N0(n)))n.markCursor=n.state.storedMarks||t.marks(),Jr(n,!0),n.markCursor=null;else if(Jr(n,!e.selection.empty),_e&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}n.input.composing=!0}Au(n,C0)};function N0(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}Te.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Au(n,20))};function Au(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jr(n),e))}function Ou(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=T0());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function E0(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=x1(e.focusNode,e.focusOffset),r=b1(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function T0(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Jr(n,e=!1){if(!(st&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ou(n),e||n.docView&&n.docView.dirty){let t=ll(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function M0(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const rr=Oe&&wt<15||vn&&v1<604;Ee.copy=Te.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let o=rr?null:t.clipboardData,i=r.content(),{dom:l,text:a}=cl(n,i);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):M0(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function A0(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function O0(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?sr(n,r.value,null,s,e):sr(n,r.textContent,r.innerHTML,s,e)},50)}function sr(n,e,t,r,s){let o=wu(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,o||R.empty)))return!0;if(!o)return!1;let i=A0(o),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Iu(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Te.paste=(n,e)=>{let t=e;if(n.composing&&!st)return;let r=rr?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&sr(n,Iu(r),r.getData("text/html"),s,t)?t.preventDefault():O0(n,t)};class Ru{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const I0=Le?"altKey":"ctrlKey";function ju(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[I0]}Ee.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,o=s.empty?null:n.posAtCoords(Vs(t)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof $?s.to-1:s.to))){if(r&&r.mightDrag)i=$.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=$.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=cl(n,l);(!t.dataTransfer.files.length||!pe||su>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(rr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",rr||t.dataTransfer.setData("text/plain",c),n.dragging=new Ru(d,ju(n,t),i)};Ee.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Te.dragover=Te.dragenter=(n,e)=>e.preventDefault();Te.drop=(n,e)=>{try{R0(n,e,n.dragging)}finally{n.dragging=null}};function R0(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Vs(e));if(!r)return;let s=n.state.doc.resolve(r.pos),o=t&&t.slice;o?n.someProp("transformPasted",h=>{o=h(o,n,!1)}):o=wu(n,Iu(e.dataTransfer),rr?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(t&&ju(n,e));if(n.someProp("handleDrop",h=>h(n,e,o||R.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?$d(n.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let a=n.state.tr;if(i){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&$.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new $(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,g,y,x)=>h=x),a.setSelection(al(n,f,a.doc.resolve(h)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ee.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&it(n)},20))};Ee.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ee.beforeinput=(n,e)=>{if(pe&&st&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,Ot(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in Te)Ee[n]=Te[n];function or(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Gr{constructor(e,t){this.toDOM=e,this.spec=t||Ft,this.side=this.spec.side||0}map(e,t,r,s){let{pos:o,deleted:i}=e.mapResult(t.from+s,this.side<0?-1:1);return i?null:new ve(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Gr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&or(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class vt{constructor(e,t){this.attrs=e,this.spec=t||Ft}map(e,t,r,s){let o=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new ve(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof vt&&or(this.attrs,e.attrs)&&or(this.spec,e.spec)}static is(e){return e.type instanceof vt}destroy(){}}class hl{constructor(e,t){this.attrs=e,this.spec=t||Ft}map(e,t,r,s){let o=e.mapResult(t.from+s,1);if(o.deleted)return null;let i=e.mapResult(t.to+s,-1);return i.deleted||i.pos<=o.pos?null:new ve(o.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),o;return s==t.from&&!(o=e.child(r)).isText&&s+o.nodeSize==t.to}eq(e){return this==e||e instanceof hl&&or(this.attrs,e.attrs)&&or(this.spec,e.spec)}destroy(){}}class ve{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ve(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ve(e,e,new Gr(t,r))}static inline(e,t,r,s){return new ve(e,t,new vt(r,s))}static node(e,t,r,s){return new ve(e,t,new hl(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof vt}get widget(){return this.type instanceof Gr}}const hn=[],Ft={};class te{constructor(e,t){this.local=e.length?e:hn,this.children=t.length?t:hn}static create(e,t){return t.length?Xr(t,e,0,Ft):Se}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,s+l,o)}}map(e,t,r){return this==Se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Ft)}mapInner(e,t,r,s,o){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?j0(this.children,i||[],e,t,r,s,o):i?new te(i.sort(Ht),hn):Se}add(e,t){return t.length?this==Se?te.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,o=0;e.forEach((l,a)=>{let c=a+r,d;if(d=Pu(t,l,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<a;)o+=3;s[o]==a?s[o+2]=s[o+2].addInner(l,d,c+1):s.splice(o,0,a,a+l.nodeSize,Xr(d,l,c+1,Ft)),o+=3}});let i=Du(o?Lu(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new te(i.length?this.local.concat(i).sort(Ht):this.local,s||this.children)}remove(e){return e.length==0||this==Se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,l=r[o]+t,a=r[o+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,l+1);c!=Se?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new te(s,r):Se}forChild(e,t){if(this==Se)return this;if(t.isLeaf)return te.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,i=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>o&&a.type instanceof vt){let c=Math.max(o,a.from)-o,d=Math.min(i,a.to)-o;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new te(s.sort(Ht),hn);return r?new mt([l,r]):l}return r||Se}eq(e){if(this==e)return!0;if(!(e instanceof te)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return pl(this.localsInner(e))}localsInner(e){if(this==Se)return hn;if(e.inlineContent||!this.local.some(vt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof vt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}te.empty=new te([],[]);te.removeOverlap=pl;const Se=te.empty;class mt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,Ft));return mt.from(r)}forChild(e,t){if(t.isLeaf)return te.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,t);o!=Se&&(o instanceof mt?r=r.concat(o.members):r.push(o))}return mt.from(r)}eq(e){if(!(e instanceof mt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!t)t=o;else{r&&(t=t.slice(),r=!1);for(let i=0;i<o.length;i++)t.push(o[i])}}return t?pl(r?t:t.sort(Ht)):hn}static from(e){switch(e.length){case 0:return Se;case 1:return e[0];default:return new mt(e.every(t=>t instanceof te)?e:e.reduce((t,r)=>t.concat(r instanceof te?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function j0(n,e,t,r,s,o,i){let l=n.slice();for(let c=0,d=o;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,g)=>{let y=g-p-(h-f);for(let x=0;x<l.length;x+=3){let b=l[x+1];if(b<0||f>b+d-u)continue;let k=l[x]+d-u;h>=k?l[x+1]=f<=k?-2:-1:f>=d&&y&&(l[x]+=y,l[x+1]+=y)}u+=y}),d=t.maps[c].map(d,-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 d=t.map(n[c]+o),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+o,-1),h=f-s,{index:p,offset:g}=r.content.findIndex(u),y=r.maybeChild(p);if(y&&g==u&&g+y.nodeSize==h){let x=l[c+2].mapInner(t,y,d+1,n[c]+o+1,i);x!=Se?(l[c]=u,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=D0(l,n,e,t,s,o,i),d=Xr(c,r,0,i);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new te(e.sort(Ht),l)}function Du(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new ve(s.from+e,s.to+e,s.type))}return t}function D0(n,e,t,r,s,o,i){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?t.push(u):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+o+1);return t}function Pu(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let o=0,i;o<n.length;o++)(i=n[o])&&i.from>t&&i.to<r&&((s||(s=[])).push(i),n[o]=null);return s}function Lu(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Xr(n,e,t,r){let s=[],o=!1;e.forEach((l,a)=>{let c=Pu(n,l,a+t);if(c){o=!0;let d=Xr(c,l,t+a+1,r);d!=Se&&s.push(a,a+l.nodeSize,d)}});let i=Du(o?Lu(n):n,-t).sort(Ht);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 te(i,s):Se}function Ht(n,e){return n.from-e.from||n.to-e.to}function pl(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==n&&(e=n.slice()),e[s]=o.copy(o.from,r.to),qa(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,o.from),qa(e,s,r.copy(o.from,r.to)));break}}}return e}function qa(n,e,t){for(;e<n.length&&Ht(t,n[e])>0;)e++;n.splice(e,0,t)}function Mo(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Se&&e.push(r)}),n.cursorWrapper&&e.push(te.create(n.state.doc,[n.cursorWrapper.deco])),mt.from(e)}const P0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},L0=Oe&&wt<=11;class $0{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 z0{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $0,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Oe&&wt<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),L0&&(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,P0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if($a(this.view)){if(this.suppressingSelectionUpdates)return it(this.view);if(Oe&&wt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ut(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let o=e.focusNode;o;o=Sn(o))t.add(o);for(let o=e.anchorNode;o;o=Sn(o))if(t.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&$a(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(o=o<0?u.from:Math.min(u.from,o),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(_e&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||F0(e,u)!=h)&&f.remove()}}}else if((pe||Ce)&&a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;u&&u.nodeType==1&&u.contentEditable=="false"&&d.parentNode.removeChild(d)}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fs(r)&&(c=ll(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,it(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),_0(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||it(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,o=e.nextSibling;if(Oe&&wt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?be(s)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?be(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 Ua=new WeakMap,Ka=!1;function _0(n){if(!Ua.has(n)&&(Ua.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=_e,Ka)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."),Ka=!0}}function Ja(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Ut(i.node,i.offset,s,o)&&([t,r,s,o]=[s,o,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:o}}function B0(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Ja(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ja(n,t):null}function F0(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function H0(n,e,t){let{node:r,fromOffset:s,toOffset:o,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Fs(a)||c.push({node:a.focusNode,offset:a.focusOffset})),pe&&n.input.lastKeyCode===8)for(let y=o;y>s;y--){let x=r.childNodes[y-1],b=x.pmViewDesc;if(x.nodeName=="BR"&&!b){o=y;break}if(!b||b.size)break}let u=n.state.doc,f=n.someProp("domParser")||kt.fromSchema(n.state.schema),h=u.resolve(i),p=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:V0,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=y),p={anchor:y+i,head:x+i}}return{doc:g,sel:p,from:i,to:l}}function V0(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Ce&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Ce&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const W0=/^(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 q0(n,e,t,r,s){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let v=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,E=ll(n,v);if(E&&!n.state.selection.eq(E)){if(pe&&st&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,Ot(13,"Enter"))))return;let M=n.state.tr.setSelection(E);v=="pointer"?M.setMeta("pointer",!0):v=="key"&&M.scrollIntoView(),o&&M.setMeta("composition",o),n.dispatch(M)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=H0(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=J0(u.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(vn&&n.input.lastIOSEnter>Date.now()-225||st)&&s.some(v=>v.nodeType==1&&!W0.test(v.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",v=>v(n,Ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof F&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let v=Ga(n,n.state.doc,c.sel);if(v&&!v.eq(n.state.selection)){let E=n.state.tr.setSelection(v);o&&E.setMeta("composition",o),n.dispatch(E)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof F&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),Oe&&wt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),x=d.resolve(p.start),b=g.sameParent(y)&&g.parent.inlineContent&&x.end()>=p.endA;if((vn&&n.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,"","")))&&n.someProp("handleKeyDown",v=>v(n,Ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&K0(d,p.start,p.endA,g,y)&&n.someProp("handleKeyDown",v=>v(n,Ot(8,"Backspace")))){st&&pe&&n.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),st&&!b&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(v){return v(n,Ot(13,"Enter"))})},20));let k=p.start,C=p.endA,w=v=>{let E=v||n.state.tr.replace(k,C,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let M=Ga(n,E.doc,c.sel);M&&!(pe&&n.composing&&M.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(M.head==k||M.head==E.mapping.map(C)-1)||Oe&&M.empty&&M.head==k)&&E.setSelection(M)}return o&&E.setMeta("composition",o),E.scrollIntoView()},S;if(b)if(g.pos==y.pos){Oe&&wt<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>it(n),20));let v=w(n.state.tr.delete(k,C)),E=d.resolve(p.start).marksAcross(d.resolve(p.endA));E&&v.ensureMarks(E),n.dispatch(v)}else if(p.endA==p.endB&&(S=U0(g.parent.content.cut(g.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start())))){let v=w(n.state.tr);S.type=="add"?v.addMark(k,C,S.mark):v.removeMark(k,C,S.mark),n.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),E=()=>w(n.state.tr.insertText(v,k,C));n.someProp("handleTextInput",M=>M(n,k,C,v,E))||n.dispatch(E())}else n.dispatch(w());else n.dispatch(w())}function Ga(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:al(n,e.resolve(t.anchor),e.resolve(t.head))}function U0(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,o=r,i,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<t.length;d++)o=t[d].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(T.from(c).eq(n))return{mark:l,type:i}}function K0(n,e,t,r,s){if(t-e<=s.pos-r.pos||Ao(r,!0,!1)<s.pos)return!1;let o=n.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=n.resolve(Ao(o,!0,!0));return!i.parent.isTextblock||i.pos>t||Ao(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Ao(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function J0(n,e,t,r,s){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));r-=i+a-o}if(i<o&&n.size<e.size){let a=r<=o&&r>=i?o-r:0;o-=a,o&&o<e.size&&Xa(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-i),i=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<n.size&&Xa(n.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function Xa(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class $u{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new u0,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(tc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Za(this),Qa(this),this.nodeViews=ec(this),this.docView=Ia(this.state.doc,Ya(this),Mo(this),this.dom,this),this.domObserver=new z0(this,(r,s,o,i)=>q0(this,r,s,o,i)),this.domObserver.start(),f0(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ci(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(tc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(Ou(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=ec(this);X0(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ci(this),this.editable=Za(this),Qa(this);let a=Mo(this),c=Ya(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=o||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(i=!0);let f=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&E1(this);if(i){this.domObserver.stop();let h=u&&(Oe||pe)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&G0(s.selection,e.selection);if(u){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=E0(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ia(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&X1(this))?it(this,h):(xu(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),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&T1(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof $){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Na(this,t.getBoundingClientRect(),e)}else Na(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new Ru(e.slice,e.move,s<0?void 0:$.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=t?t(l):l))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let l=o[i].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(Oe){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&M1(this.dom),it(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return j1(this,e)}coordsAtPos(e,t=1){return du(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return z1(this,t||this.state,e)}pasteHTML(e,t){return sr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return sr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return cl(this,e)}destroy(){this.docView&&(h0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Mo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,g1())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return m0(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ce&&this.root.nodeType===11&&w1(this.dom.ownerDocument)==this.dom&&B0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}$u.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Ya(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ve.node(0,n.state.doc.content.size,e)]}function Qa(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ve.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Za(n){return!n.someProp("editable",e=>e(n.state)===!1)}function G0(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function ec(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function X0(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function tc(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ct={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:"'"},Yr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Y0=typeof navigator<"u"&&/Mac/.test(navigator.platform),Q0=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ke=0;ke<10;ke++)Ct[48+ke]=Ct[96+ke]=String(ke);for(var ke=1;ke<=24;ke++)Ct[ke+111]="F"+ke;for(var ke=65;ke<=90;ke++)Ct[ke]=String.fromCharCode(ke+32),Yr[ke]=String.fromCharCode(ke);for(var Oo in Ct)Yr.hasOwnProperty(Oo)||(Yr[Oo]=Ct[Oo]);function Z0(n){var e=Y0&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Q0&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Yr:Ct)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const ey=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ty=typeof navigator<"u"&&/Win/.test(navigator.platform);function ny(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))ey?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),i&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function ry(n){let e=Object.create(null);for(let t in n)e[ny(t)]=n[t];return e}function Io(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function sy(n){return new re({props:{handleKeyDown:zu(n)}})}function zu(n){let e=ry(n);return function(t,r){let s=Z0(r),o,i=e[Io(s,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Io(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ty&&r.ctrlKey&&r.altKey)&&(o=Ct[r.keyCode])&&o!=s){let l=e[Io(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var oy=Object.defineProperty,ml=(n,e)=>{for(var t in e)oy(n,t,{get:e[t],enumerable:!0})};function Ws(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,o=t.storedMarks,t}}}var qs=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:s}=t,o=this.buildProps(s);return Object.fromEntries(Object.entries(n).map(([i,l])=>[i,(...c)=>{const d=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i=[],l=!!n,a=n||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(a),i.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(t).map(([u,f])=>[u,(...p)=>{const g=this.buildProps(a,e),y=f(...p)(g);return i.push(y),d}])),run:c};return d}createCan(n){const{rawCommands:e,state:t}=this,r=!1,s=n||t.tr,o=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:s}=this,{view:o}=r,i={tr:n,editor:r,view:o,state:Ws({state:s,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(i)]))}};return i}},_u={};ml(_u,{blur:()=>iy,clearContent:()=>ly,clearNodes:()=>ay,command:()=>cy,createParagraphNear:()=>dy,cut:()=>uy,deleteCurrentNode:()=>fy,deleteNode:()=>hy,deleteRange:()=>py,deleteSelection:()=>my,enter:()=>gy,exitCode:()=>yy,extendMarkRange:()=>xy,first:()=>by,focus:()=>wy,forEach:()=>Sy,insertContent:()=>vy,insertContentAt:()=>Ey,joinBackward:()=>Ay,joinDown:()=>My,joinForward:()=>Oy,joinItemBackward:()=>Iy,joinItemForward:()=>Ry,joinTextblockBackward:()=>jy,joinTextblockForward:()=>Dy,joinUp:()=>Ty,keyboardShortcut:()=>Ly,lift:()=>$y,liftEmptyBlock:()=>zy,liftListItem:()=>_y,newlineInCode:()=>By,resetAttributes:()=>Fy,scrollIntoView:()=>Hy,selectAll:()=>Vy,selectNodeBackward:()=>Wy,selectNodeForward:()=>qy,selectParentNode:()=>Uy,selectTextblockEnd:()=>Ky,selectTextblockStart:()=>Jy,setContent:()=>Gy,setMark:()=>mx,setMeta:()=>gx,setNode:()=>yx,setNodeSelection:()=>xx,setTextDirection:()=>bx,setTextSelection:()=>kx,sinkListItem:()=>wx,splitBlock:()=>Sx,splitListItem:()=>vx,toggleList:()=>Cx,toggleMark:()=>Nx,toggleNode:()=>Ex,toggleWrap:()=>Tx,undoInputRule:()=>Mx,unsetAllMarks:()=>Ax,unsetMark:()=>Ox,unsetTextDirection:()=>Ix,updateAttributes:()=>Rx,wrapIn:()=>jx,wrapInList:()=>Dx});var iy=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),ly=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),ay=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:o,$to:i})=>{n.doc.nodesBetween(o.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const p=jn(h);if(l.type.isTextblock){const{defaultType:g}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},cy=n=>e=>n(e),dy=()=>({state:n,dispatch:e})=>Zd(n,e),uy=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,o=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new F(r.doc.resolve(Math.max(i-1,0)))),!0},fy=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(e){const l=s.before(o),a=s.after(o);n.delete(l,a).scrollIntoView()}return!0}return!1};function ue(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var hy=n=>({tr:e,state:t,dispatch:r})=>{const s=ue(n,t.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const a=o.before(i),c=o.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},py=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},my=()=>({state:n,dispatch:e})=>tl(n,e),gy=()=>({commands:n})=>n.keyboardShortcut("Enter"),yy=()=>({state:n,dispatch:e})=>t1(n,e);function gl(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Qr(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:gl(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function Bu(n,e,t={}){return n.find(r=>r.type===e&&Qr(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function nc(n,e,t={}){return!!Bu(n,e,t)}function yl(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(t=t||((r=s.node.marks[0])==null?void 0:r.attrs),!Bu([...s.node.marks],e,t)))return;let i=s.index,l=n.start()+s.offset,a=i+1,c=l+s.node.nodeSize;for(;i>0&&nc([...n.parent.child(i-1).marks],e,t);)i-=1,l-=n.parent.child(i).nodeSize;for(;a<n.parent.childCount&&nc([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function lt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var xy=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const o=lt(n,r.schema),{doc:i,selection:l}=t,{$from:a,from:c,to:d}=l;if(s){const u=yl(a,o,e);if(u&&u.from<=c&&u.to>=d){const f=F.create(i,u.from,u.to);t.setSelection(f)}}return!0},by=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function Fu(n){return n instanceof F}function jt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Hu(n,e=null){if(!e)return null;const t=q.atStart(n),r=q.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,o=r.to;return e==="all"?F.create(n,jt(0,s,o),jt(n.content.size,s,o)):F.create(n,jt(e,s,o),jt(e,s,o))}function di(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function ir(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function ky(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var wy=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(ir()||di())&&r.dom.focus(),ky()&&!ir()&&!di()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!Fu(t.state.selection))return i(),!0;const l=Hu(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return o&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},Sy=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),vy=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Vu=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Vu(r)}return n};function Cr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Vu(t)}function lr(n,e,t){if(n instanceof ze||n instanceof T)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return T.fromArray(n.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),lr("",e,t)}if(s){if(t.errorOnInvalidContent){let i=!1,l="";const a=new Ed({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?kt.fromSchema(a).parseSlice(Cr(n),t.parseOptions):kt.fromSchema(a).parse(Cr(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=kt.fromSchema(e);return t.slice?o.parseSlice(Cr(n),t.parseOptions).content:o.parse(Cr(n),t.parseOptions)}return lr("",e,t)}function Cy(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof he||s instanceof ge))return;const o=n.mapping.maps[r];let i=0;o.forEach((l,a,c,d)=>{i===0&&(i=d)}),n.setSelection(q.near(n.doc.resolve(i),t))}var Ny=n=>!("type"in n),Ey=(n,e,t)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=y=>{o.emit("contentError",{editor:o,error:y,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{lr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=lr(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:o.options.enableContentCheck})}catch(y){return a(y),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((Ny(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),d===u&&h){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,u+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof T){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,d,u)}else{g=l;const y=r.doc.resolve(d),x=y.node(),b=y.parentOffset===0,k=x.isText||x.isTextblock,C=x.content.size>0;b&&k&&C&&(d=Math.max(0,d-1)),r.replaceWith(d,u,g)}t.updateSelection&&Cy(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:g})}return!0},Ty=()=>({state:n,dispatch:e})=>Qg(n,e),My=()=>({state:n,dispatch:e})=>Zg(n,e),Ay=()=>({state:n,dispatch:e})=>Ud(n,e),Oy=()=>({state:n,dispatch:e})=>Xd(n,e),Iy=()=>({state:n,dispatch:e,tr:t})=>{try{const r=zs(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Ry=()=>({state:n,dispatch:e,tr:t})=>{try{const r=zs(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},jy=()=>({state:n,dispatch:e})=>Xg(n,e),Dy=()=>({state:n,dispatch:e})=>Yg(n,e);function Wu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Py(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,o,i;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))ir()||Wu()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),o&&(t=`Shift-${t}`),t}var Ly=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const o=Py(n).split(/-(?!$)/),i=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Nt(n,e,t={}){const{from:r,to:s,empty:o}=n.selection,i=e?ue(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(s,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=s-r,c=l.filter(u=>i?i.name===u.node.type.name:!0).filter(u=>Qr(u.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}var $y=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return Nt(t,s,e)?e1(t,r):!1},zy=()=>({state:n,dispatch:e})=>eu(n,e),_y=n=>({state:e,dispatch:t})=>{const r=ue(n,e.schema);return f1(r)(e,t)},By=()=>({state:n,dispatch:e})=>Qd(n,e);function Us(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function rc(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}var Fy=(n,e)=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=Us(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=ue(n,r.schema)),l==="mark"&&(i=lt(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{o&&o===d.type&&(a=!0,s&&t.setNodeMarkup(u,void 0,rc(d.attrs,e))),i&&d.marks.length&&d.marks.forEach(f=>{i===f.type&&(a=!0,s&&t.addMark(u,u+d.nodeSize,i.create(rc(f.attrs,e))))})})}),a},Hy=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Vy=()=>({tr:n,dispatch:e})=>{if(e){const t=new je(n.doc);n.setSelection(t)}return!0},Wy=()=>({state:n,dispatch:e})=>Jd(n,e),qy=()=>({state:n,dispatch:e})=>Yd(n,e),Uy=()=>({state:n,dispatch:e})=>s1(n,e),Ky=()=>({state:n,dispatch:e})=>l1(n,e),Jy=()=>({state:n,dispatch:e})=>i1(n,e);function ui(n,e,t={},r={}){return lr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Gy=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=ui(n,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return i&&o.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return i&&o.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function qu(n,e){const t=lt(e,n.schema),{from:r,to:s,empty:o}=n.selection,i=[];o?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Uu(n,e){const t=new Hd(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function Xy(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Yy(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,o)=>{t(s)&&r.push({node:s,pos:o})}),r}function Qy(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Ks(n){return e=>Qy(e.$from,n)}function L(n,e,t){return n.config[e]===void 0&&n.parent?L(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?L(n.parent,e,t):null}):n.config[e]}function xl(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=L(e,"addExtensions",t);return r?[e,...xl(r())]:e}).flat(10)}function bl(n,e){const t=Xt.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}function Ku(n){return typeof n=="function"}function G(n,e=void 0,...t){return Ku(n)?e?n.bind(e)(...t):n(...t):n}function Zy(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Cn(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Ju(n){const e=[],{nodeExtensions:t,markExtensions:r}=Cn(n),s=[...t,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage,extensions:s},a=L(i,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...o,...h}})})})})}),s.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage},a=L(i,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...o,...u};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:i.name,name:d,attribute:f})})}),e}function ne(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,o])=>{if(!r[s]){r[s]=o;return}if(s==="class"){const l=o?String(o).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=o?o.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=o}),r},{})}function Nn(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>ne(t,r),{})}function ex(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function sc(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(t):ex(t.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function oc(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Zy(t)?!1:t!=null))}function ic(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function tx(n,e){var t;const r=Ju(n),{nodeExtensions:s,markExtensions:o}=Cn(n),i=(t=s.find(c=>L(c,"topNode")))==null?void 0:t.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(x=>x.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((x,b)=>{const k=L(b,"extendNodeSchema",u);return{...x,...k?k(c):{}}},{}),h=oc({...f,content:G(L(c,"content",u)),marks:G(L(c,"marks",u)),group:G(L(c,"group",u)),inline:G(L(c,"inline",u)),atom:G(L(c,"atom",u)),selectable:G(L(c,"selectable",u)),draggable:G(L(c,"draggable",u)),code:G(L(c,"code",u)),whitespace:G(L(c,"whitespace",u)),linebreakReplacement:G(L(c,"linebreakReplacement",u)),defining:G(L(c,"defining",u)),isolating:G(L(c,"isolating",u)),attrs:Object.fromEntries(d.map(ic))}),p=G(L(c,"parseHTML",u));p&&(h.parseDOM=p.map(x=>sc(x,d)));const g=L(c,"renderHTML",u);g&&(h.toDOM=x=>g({node:x,HTMLAttributes:Nn(x,d)}));const y=L(c,"renderText",u);return y&&(h.toText=y),[c.name,h]})),a=Object.fromEntries(o.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,x)=>{const b=L(x,"extendMarkSchema",u);return{...y,...b?b(c):{}}},{}),h=oc({...f,inclusive:G(L(c,"inclusive",u)),excludes:G(L(c,"excludes",u)),group:G(L(c,"group",u)),spanning:G(L(c,"spanning",u)),code:G(L(c,"code",u)),attrs:Object.fromEntries(d.map(ic))}),p=G(L(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>sc(y,d)));const g=L(c,"renderHTML",u);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:Nn(y,d)})),[c.name,h]}));return new Ed({topNode:i,nodes:l,marks:a})}function nx(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function Zr(n){return n.sort((t,r)=>{const s=L(t,"priority")||100,o=L(r,"priority")||100;return s>o?-1:s<o?1:0})}function Gu(n){const e=Zr(xl(n)),t=nx(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Xu(n,e,t){const{from:r,to:s}=e,{blockSeparator:o=`
17
+
18
+ `,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=o);const h=i?.[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function rx(n,e){const t={from:0,to:n.content.size};return Xu(n,t,e)}function Yu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function sx(n,e){const t=ue(e,n.schema),{from:r,to:s}=n.selection,o=[];n.doc.nodesBetween(r,s,l=>{o.push(l)});const i=o.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function Qu(n,e){const t=Us(typeof e=="string"?e:e.name,n.schema);return t==="node"?sx(n,e):t==="mark"?qu(n,e):{}}function ox(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function ix(n){const e=ox(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,i)=>i!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function Zu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((l,a)=>{i.push({from:l,to:a})});else{const{from:l,to:a}=t[o];if(l===void 0||a===void 0)return;i.push({from:l,to:a})}i.forEach(({from:l,to:a})=>{const c=e.slice(o).map(l,-1),d=e.slice(o).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),ix(r)}function kl(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const o=t.resolve(n),i=yl(o,s.type);i&&r.push({mark:s,...i})}):t.nodesBetween(n,e,(s,o)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}var lx=(n,e,t,r=20)=>{const s=n.doc.resolve(t);let o=r,i=null;for(;o>0&&i===null;){const l=s.node(o);l?.type.name===e?i=l:o-=1}return[i,o]};function Nr(n,e){return e.nodes[n]||e.marks[n]||null}function Lr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}var ax=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,o,i,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:o,parent:i,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-o))}),t};function fi(n,e,t={}){const{empty:r,ranges:s}=n.selection,o=e?lt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>Qr(u.attrs,t,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const x=Math.max(h,y),b=Math.min(p,y+g.nodeSize),k=b-x;i+=k,l.push(...g.marks.map(C=>({mark:C,from:x,to:b})))})}),i===0)return!1;const a=l.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>Qr(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>o?u.mark.type!==o&&u.mark.type.excludes(o):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=i}function cx(n,e,t={}){if(!e)return Nt(n,null,t)||fi(n,null,t);const r=Us(e,n.schema);return r==="node"?Nt(n,e,t):r==="mark"?fi(n,e,t):!1}var dx=(n,e)=>{const{$from:t,$to:r,$anchor:s}=n.selection;if(e){const o=Ks(l=>l.type.name===e)(n.selection);if(!o)return!1;const i=n.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},ux=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function lc(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function ac(n,e){const{nodeExtensions:t}=Cn(e),r=t.find(i=>i.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=G(L(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function Js(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(o=>{s!==!1&&(Js(o,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function ef(n){return n instanceof $}var tf=class nf{constructor(e){this.position=e}static fromJSON(e){return new nf(e.position)}toJSON(){return{position:this.position}}};function fx(n,e){const t=e.mapping.mapResult(n.position);return{position:new tf(t.pos),mapResult:t}}function hx(n){return new tf(n)}function px(n,e,t){var r;const{selection:s}=e;let o=null;if(Fu(s)&&(o=s.$cursor),o){const l=(r=n.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:i}=s;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(g=>g.type.excludes(t));c=h&&p}return!c}),c})}var mx=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=t,{empty:i,ranges:l}=o,a=lt(n,r.schema);if(s)if(i){const c=qu(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),g=Math.min(h+f.nodeSize,u);f.marks.find(x=>x.type===a)?f.marks.forEach(x=>{a===x.type&&t.addMark(p,g,a.create({...x.attrs,...e}))}):t.addMark(p,g,a.create(e))})});return px(r,t,a)},gx=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),yx=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const o=ue(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:l})=>Sa(o,{...i,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Sa(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},xx=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=jt(n,0,r.content.size),o=$.create(r,s);e.setSelection(o)}return!0},bx=(n,e)=>({tr:t,state:r,dispatch:s})=>{const{selection:o}=r;let i,l;return typeof e=="number"?(i=e,l=e):e&&"from"in e&&"to"in e?(i=e.from,l=e.to):(i=o.from,l=o.to),s&&t.doc.nodesBetween(i,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},kx=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:o}=typeof n=="number"?{from:n,to:n}:n,i=F.atStart(r).from,l=F.atEnd(r).to,a=jt(s,i,l),c=jt(o,i,l),d=F.create(r,a,c);e.setSelection(d)}return!0},wx=n=>({state:e,dispatch:t})=>{const r=ue(n,e.schema);return m1(r)(e,t)};function cc(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}var Sx=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:l,$to:a}=o,c=s.extensionManager.attributes,d=Lr(c,l.node().type.name,l.node().attrs);if(o instanceof $&&o.node.isBlock)return!l.parentOffset||!ot(i,l.pos)?!1:(r&&(n&&cc(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Xy(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=ot(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&ot(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(o instanceof F&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&cc(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},vx=(n,e={})=>({tr:t,state:r,dispatch:s,editor:o})=>{var i;const l=ue(n,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.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=T.empty;const b=a.index(-1)?1:a.index(-2)?2:3;for(let E=a.depth-b;E>=a.depth-3;E-=1)x=T.from(a.node(E).copy(x));const k=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,C={...Lr(f,a.node().type.name,a.node().attrs),...e},w=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(C))||void 0;x=x.append(T.from(l.createAndFill(null,w)||void 0));const S=a.before(a.depth-(b-1));t.replace(S,a.after(-k),new R(x,4-b,0));let v=-1;t.doc.nodesBetween(S,t.doc.content.size,(E,M)=>{if(v>-1)return!1;E.isTextblock&&E.content.size===0&&(v=M+1)}),v>-1&&t.setSelection(F.near(t.doc.resolve(v))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Lr(f,u.type.name,u.attrs),...e},g={...Lr(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=h?[{type:l,attrs:p},{type:h,attrs:g}]:[{type:l,attrs:p}];if(!ot(t.doc,a.pos,2))return!1;if(s){const{selection:x,storedMarks:b}=r,{splittableMarks:k}=o.extensionManager,C=b||x.$to.parentOffset&&x.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!C||!s)return!0;const w=C.filter(S=>k.includes(S.type.name));t.ensureMarks(w)}return!0},Ro=(n,e)=>{const t=Ks(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Tt(n.doc,t.pos)&&n.join(t.pos),!0},jo=(n,e)=>{const t=Ks(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Tt(n.doc,r)&&n.join(r),!0},Cx=(n,e,t,r={})=>({editor:s,tr:o,state:i,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=s.extensionManager,h=ue(n,i.schema),p=ue(e,i.schema),{selection:g,storedMarks:y}=i,{$from:x,$to:b}=g,k=x.blockRange(b),C=y||g.$to.parentOffset&&g.$from.marks();if(!k)return!1;const w=Ks(S=>ac(S.type.name,u))(g);if(k.depth>=1&&w&&k.depth-w.depth<=1){if(w.node.type===h)return c.liftListItem(p);if(ac(w.node.type.name,u)&&h.validContent(w.node.content)&&l)return a().command(()=>(o.setNodeMarkup(w.pos,h),!0)).command(()=>Ro(o,h)).command(()=>jo(o,h)).run()}return!t||!C||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Ro(o,h)).command(()=>jo(o,h)).run():a().command(()=>{const S=d().wrapInList(h,r),v=C.filter(E=>f.includes(E.type.name));return o.ensureMarks(v),S?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Ro(o,h)).command(()=>jo(o,h)).run()},Nx=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=t,i=lt(n,r.schema);return fi(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},Ex=(n,e,t={})=>({state:r,commands:s})=>{const o=ue(n,r.schema),i=ue(e,r.schema),l=Nt(r,o,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(i,a):s.setNode(o,{...a,...t})},Tx=(n,e={})=>({state:t,commands:r})=>{const s=ue(n,t.schema);return Nt(t,s,e)?r.lift(s):r.wrapIn(s,e)},Mx=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let o;if(s.spec.isInputRules&&(o=s.getState(n))){if(e){const i=n.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(o.text){const a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else i.delete(o.from,o.to)}return!0}}return!1},Ax=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},Ox=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,a=lt(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&i){let{from:f,to:h}=l;const p=(o=c.marks().find(y=>y.type===a))==null?void 0:o.attrs,g=yl(c,a,p);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Ix=n=>({tr:e,state:t,dispatch:r})=>{const{selection:s}=t;let o,i;return typeof n=="number"?(o=n,i=n):n&&"from"in n&&"to"in n?(o=n.from,i=n.to):(o=s.from,i=s.to),r&&e.doc.nodesBetween(o,i,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Rx=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let o=null,i=null;const l=Us(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(o=ue(n,r.schema)),l==="mark"&&(i=lt(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let f,h,p,g;t.selection.empty?r.doc.nodesBetween(d,u,(y,x)=>{o&&o===y.type&&(a=!0,p=Math.max(x,d),g=Math.min(x+y.nodeSize,u),f=x,h=y)}):r.doc.nodesBetween(d,u,(y,x)=>{x<d&&o&&o===y.type&&(a=!0,p=Math.max(x,d),g=Math.min(x+y.nodeSize,u),f=x,h=y),x>=d&&x<=u&&(o&&o===y.type&&(a=!0,s&&t.setNodeMarkup(x,void 0,{...y.attrs,...e})),i&&y.marks.length&&y.marks.forEach(b=>{if(i===b.type&&(a=!0,s)){const k=Math.max(x,d),C=Math.min(x+y.nodeSize,u);t.addMark(k,C,i.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&s&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(y=>{i===y.type&&s&&t.addMark(p,g,i.create({...y.attrs,...e}))}))}),a},jx=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return a1(s,e)(t,r)},Dx=(n,e={})=>({state:t,dispatch:r})=>{const s=ue(n,t.schema);return c1(s,e)(t,r)},Px=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Gs=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},Lx=(n,e)=>{if(gl(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Er(n){var e;const{editor:t,from:r,to:s,text:o,rules:i,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=ax(c)+o;return i.forEach(f=>{if(d)return;const h=Lx(u,f.find);if(!h)return;const p=a.state.tr,g=Ws({state:a.state,transaction:p}),y={from:r-(h[0].length-o.length),to:s},{commands:x,chain:b,can:k}=new qs({editor:t,state:g});f.handler({state:g,range:y,match:h,commands:x,chain:b,can:k})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:o}),a.dispatch(p),d=!0)}),d}function $x(n){const{editor:e,rules:t}=n,r=new re({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:d}=a;typeof d=="string"?d=d:d=bl(T.from(d),i.schema);const{from:u}=a,f=u+d.length;Er({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,l){return Er({editor:e,from:o,to:i,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&Er({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?Er({editor:e,from:i.pos,to:i.pos,text:`
19
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function zx(n){return Object.prototype.toString.call(n).slice(8,-1)}function Tr(n){return zx(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function rf(n,e){const t={...n};return Tr(n)&&Tr(e)&&Object.keys(e).forEach(r=>{Tr(e[r])&&Tr(n[r])?t[r]=rf(n[r],e[r]):t[r]=e[r]}),t}var wl=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...G(L(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...G(L(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>rf(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},Yt=class sf extends wl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new sf(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(c=>c?.type.name===t.name))return!1;const a=i.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function _x(n){return typeof n=="number"}var Bx=class{constructor(n){this.find=n.find,this.handler=n.handler}},Fx=(n,e,t)=>{if(gl(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=n,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function Hx(n){const{editor:e,state:t,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=n,{commands:a,chain:c,can:d}=new qs({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(h,p)=>{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 C=(k=(b=(x=h.content)==null?void 0:x.size)!=null?b:h.nodeSize)!=null?k:0,w=Math.max(r,p),S=Math.min(s,p+C);if(w>=S)return;const v=h.isText?h.text||"":h.textBetween(w-p,S-p,void 0,"");Fx(v,o.find,i).forEach(M=>{if(M.index===void 0)return;const D=w+M.index+1,j=D+M[0].length,_={from:t.tr.mapping.map(D),to:t.tr.mapping.map(j)},H=o.handler({state:t,range:_,match:M,commands:a,chain:c,can:d,pasteEvent:i,dropEvent:l});u.push(H)})}),u.every(h=>h!==null)}var Mr=null,Vx=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function Wx(n){const{editor:e,rules:t}=n;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const g=d.tr,y=Ws({state:d,transaction:g});if(!(!Hx({editor:e,state:y,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return t.map(d=>new re({view(u){const f=p=>{var g;r=(g=u.dom.parentElement)!=null&&g.contains(p.target)?u.dom.parentElement:null,r&&(Mr=e)},h=()=>{Mr&&(Mr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(o=r===u.dom.parentElement,l=f,!o){const h=Mr;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return i=f,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],g=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!o,x=p.getMeta("applyPasteRules"),b=!!x;if(!g&&!y&&!b)return;if(b){let{text:w}=x;typeof w=="string"?w=w:w=bl(T.from(w),h.schema);const{from:S}=x,v=S+w.length,E=Vx(w);return a({rule:d,state:h,from:S,to:{b:v},pasteEvt:E})}const k=f.doc.content.findDiffStart(h.doc.content),C=f.doc.content.findDiffEnd(h.doc.content);if(!(!_x(k)||!C||k===C.b))return a({rule:d,state:h,from:k,to:C,pasteEvt:i})}}))}var Xs=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Gu(n),this.schema=tx(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Nr(e.name,this.schema)},r=L(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return Zr([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:Nr(r.name,this.schema)},o=[],i=L(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&L(r,"exitable",s)&&(l.ArrowRight=()=>Yt.handleExit({editor:n,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,p])=>[h,()=>p({editor:n})]));l={...l,...f}}const a=sy(l);o.push(a);const c=L(r,"addInputRules",s);if(lc(r,n.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=$x({editor:n,rules:f}),p=Array.isArray(h)?h:[h];o.push(...p)}}const d=L(r,"addPasteRules",s);if(lc(r,n.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const h=Wx({editor:n,rules:f});o.push(...h)}}const u=L(r,"addProseMirrorPlugins",s);if(u){const f=u();o.push(...f)}return o})}get attributes(){return Ju(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=Cn(this.extensions);return Object.fromEntries(e.filter(t=>!!L(t,"addNodeView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:ue(t.name,this.schema)},o=L(t,"addNodeView",s);if(!o)return[];const i=o();if(!i)return[];const l=(a,c,d,u,f)=>{const h=Nn(a,r);return i({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:n,extension:t,HTMLAttributes:h})};return[t.name,l]}))}dispatchTransaction(n){const{editor:e}=this;return Zr([...this.extensions].reverse()).reduceRight((r,s)=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Nr(s.name,this.schema)},i=L(s,"dispatchTransaction",o);return i?l=>{i.call(o,{transaction:l,next:r})}:r},n)}get markViews(){const{editor:n}=this,{markExtensions:e}=Cn(this.extensions);return Object.fromEntries(e.filter(t=>!!L(t,"addMarkView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),s={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:lt(t.name,this.schema)},o=L(t,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const d=Nn(l,r);return o()({mark:l,view:a,inline:c,editor:n,extension:t,HTMLAttributes:d,updateAttributes:u=>{sb(l,n,u)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Nr(e.name,this.schema)};e.type==="mark"&&((t=G(L(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const s=L(e,"onBeforeCreate",r),o=L(e,"onCreate",r),i=L(e,"onUpdate",r),l=L(e,"onSelectionUpdate",r),a=L(e,"onTransaction",r),c=L(e,"onFocus",r),d=L(e,"onBlur",r),u=L(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),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};Xs.resolve=Gu;Xs.sort=Zr;Xs.flatten=xl;var qx={};ml(qx,{ClipboardTextSerializer:()=>lf,Commands:()=>af,Delete:()=>cf,Drop:()=>df,Editable:()=>uf,FocusEvents:()=>hf,Keymap:()=>pf,Paste:()=>mf,Tabindex:()=>gf,TextDirection:()=>yf,focusEventsPluginKey:()=>ff});var ce=class of extends wl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new of(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},lf=ce.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new re({key:new ae("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:o}=s,i=Math.min(...o.map(d=>d.$from.pos)),l=Math.max(...o.map(d=>d.$to.pos)),a=Yu(t);return Xu(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),af=ce.create({name:"commands",addCommands(){return{..._u}}}),cf=ce.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,s;const o=()=>{var i,l,a,c;if((c=(a=(l=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const d=Uu(n.before,[n,...e]);Zu(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,g)=>{const y=g+p.nodeSize-2,x=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:y,newFrom:d.mapping.map(g),newTo:d.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!x,editor:this.editor,transaction:n,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((h,p)=>{var g,y;if(h instanceof We){const x=f.slice(p).map(h.from,-1),b=f.slice(p).map(h.to),k=f.invert().map(x,-1),C=f.invert().map(b),w=(g=d.doc.nodeAt(x-1))==null?void 0:g.marks.some(v=>v.eq(h.mark)),S=(y=d.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:C},newRange:{from:x,to:b},partial:!!(S||w),editor:this.editor,transaction:n,combinedTransform:d})}})};(s=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||s?setTimeout(o,0):o()}}),df=ce.create({name:"drop",addProseMirrorPlugins(){return[new re({key:new ae("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),uf=ce.create({name:"editable",addProseMirrorPlugins(){return[new re({key:new ae("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ff=new ae("focusEvents"),hf=ce.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new re({key:ff,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),pf=ce.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,g=p.parent.type.spec.isolating,y=u.pos-u.parentOffset,x=g&&p.parent.childCount===1?y===u.pos:q.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!x||x&&u.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ir()||Wu()?o:s},addProseMirrorPlugins(){return[new re({key:new ae("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(g=>g.getMeta("composition")))return;const r=n.some(g=>g.docChanged)&&!e.doc.eq(t.doc),s=n.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:l}=e.selection,a=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!Js(t.doc))return;const f=t.tr,h=Ws({state:t,transaction:f}),{commands:p}=new qs({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),mf=ce.create({name:"paste",addProseMirrorPlugins(){return[new re({key:new ae("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),gf=ce.create({name:"tabindex",addProseMirrorPlugins(){return[new re({key:new ae("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),yf=ce.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=Cn(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new re({key:new ae("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),Ux=class pn{constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new pn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new pn(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 pn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,i=this.pos+r+(o?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(i);if(!s&&l.depth<=this.depth)return;const a=new pn(l,this.editor,s,s?t:null);s&&(a.actualDepth=this.depth+1),e.push(new pn(l,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const o=s.node.attrs,i=Object.keys(t);for(let l=0;l<i.length;l+=1){const a=i[l];if(o[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(t);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>t[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Kx=`.ProseMirror {
20
+ position: relative;
21
+ }
22
+
23
+ .ProseMirror {
24
+ word-wrap: break-word;
25
+ white-space: pre-wrap;
26
+ white-space: break-spaces;
27
+ -webkit-font-variant-ligatures: none;
28
+ font-variant-ligatures: none;
29
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
30
+ }
31
+
32
+ .ProseMirror [contenteditable="false"] {
33
+ white-space: normal;
34
+ }
35
+
36
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
37
+ white-space: pre-wrap;
38
+ }
39
+
40
+ .ProseMirror pre {
41
+ white-space: pre-wrap;
42
+ }
43
+
44
+ img.ProseMirror-separator {
45
+ display: inline !important;
46
+ border: none !important;
47
+ margin: 0 !important;
48
+ width: 0 !important;
49
+ height: 0 !important;
50
+ }
51
+
52
+ .ProseMirror-gapcursor {
53
+ display: none;
54
+ pointer-events: none;
55
+ position: absolute;
56
+ margin: 0;
57
+ }
58
+
59
+ .ProseMirror-gapcursor:after {
60
+ content: "";
61
+ display: block;
62
+ position: absolute;
63
+ top: -2px;
64
+ width: 20px;
65
+ border-top: 1px solid black;
66
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
67
+ }
68
+
69
+ @keyframes ProseMirror-cursor-blink {
70
+ to {
71
+ visibility: hidden;
72
+ }
73
+ }
74
+
75
+ .ProseMirror-hideselection *::selection {
76
+ background: transparent;
77
+ }
78
+
79
+ .ProseMirror-hideselection *::-moz-selection {
80
+ background: transparent;
81
+ }
82
+
83
+ .ProseMirror-hideselection * {
84
+ caret-color: transparent;
85
+ }
86
+
87
+ .ProseMirror-focused .ProseMirror-gapcursor {
88
+ display: block;
89
+ }`;function Jx(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}var Gx=class extends Px{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:fx,createMappablePosition:hx},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:o})=>this.options.onDrop(r,s,o)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=Hu(e,this.options.autofocus);this.editorState=gn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Jx(Kx,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=Ku(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;t=t.filter(i=>!i.key.startsWith(o))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const r=[...this.options.enableCoreExtensions?[uf,lf.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),af,hf,pf,gf,df,mf,cf,yf.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 Xs(r,this)}createCommandManager(){this.commandManager=new qs({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=ui(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=ui(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=t?this.extensionManager.dispatchTransaction(r):r;this.editorView=new $u(n,{...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(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),s=t.includes(n),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const i=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=i?.getMeta("focus"),a=i?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:i}),a&&this.emit("blur",{editor:this,event:a.event,transaction:i}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Qu(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return cx(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return bl(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
90
+
91
+ `,textSerializers:t={}}=n||{};return rx(this.state.doc,{blockSeparator:e,textSerializers:{...Yu(this.schema),...t}})}get isEmpty(){return Js(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new Ux(e,this)}get $doc(){return this.$pos(0)}};function En(n){return new Gs({find:n.find,handler:({state:e,range:t,match:r})=>{const s=G(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),d=c+i.length;if(kl(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&o.delete(d,t.to),c>t.from&&o.delete(t.from+a,c);const f=t.from+a+i.length;o.addMark(t.from+a,f,n.type.create(s||{})),o.removeStoredMark(n.type)}},undoable:n.undoable})}function Xx(n){return new Gs({find:n.find,handler:({state:e,range:t,match:r})=>{const s=G(n.getAttributes,void 0,r)||{},{tr:o}=e,i=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=i+c;d>l?d=l:l=d+r[1].length;const u=r[0][r[0].length-1];o.insertText(u,i+r[0].length-1),o.replaceWith(d,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;o.insert(c,n.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:n.undoable})}function hi(n){return new Gs({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),o=G(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)},undoable:n.undoable})}function Tn(n){return new Gs({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const o=G(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&Zi(a,n.type,o);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const g=p.filter(y=>h.includes(y.type.name));i.ensureMarks(g)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,o).run()}const d=i.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Tt(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&i.join(t.from-1)},undoable:n.undoable})}function Yx(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof $){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 Qx(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Zx={};ml(Zx,{createAtomBlockMarkdownSpec:()=>eb,createBlockMarkdownSpec:()=>tb,createInlineMarkdownSpec:()=>xf,parseAttributes:()=>Sl,parseIndentedBlocks:()=>pi,renderNestedMarkdownContent:()=>Cl,serializeAttributes:()=>vl});function Sl(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(d=>d.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,d])=>{var u;const f=parseInt(((u=d.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function vl(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function eb(n){const{nodeName:e,name:t,parseAttributes:r=Sl,serializeAttributes:s=vl,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=n,a=t||e,c=d=>{if(!l)return d;const u={};return l.forEach(f=>{f in d&&(u[f]=d[f])}),u};return{parseMarkdown:(d,u)=>{const f={...o,...d.attributes};return u.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(u=d.match(f))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(d,u,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=d.match(h);if(!p)return;const g=p[1]||"",y=r(g);if(!i.find(b=>!(b in y)))return{type:e,raw:p[0],attributes:y}}},renderMarkdown:d=>{const u=c(d.attrs||{}),f=s(u),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function tb(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Sl,serializeAttributes:o=vl,defaultAttributes:i={},content:l="block",allowedAttributes:a}=n,c=t||e,d=u=>{if(!a)return u;const f={};return a.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{let h;if(r){const g=r(u);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=f.parseChildren(u.tokens||[]):h=f.parseInline(u.tokens||[]);const p={...i,...u.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var f;const h=new RegExp(`^:::${c}`,"m"),p=(f=u.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(u,f,h){var p;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=u.match(g);if(!y)return;const[x,b=""]=y,k=s(b);let C=1;const w=x.length;let S="";const v=/^:::([\w-]*)(\s.*)?/gm,E=u.slice(w);for(v.lastIndex=0;;){const M=v.exec(E);if(M===null)break;const D=M.index,j=M[1];if(!((p=M[2])!=null&&p.endsWith(":::"))){if(j)C+=1;else if(C-=1,C===0){const _=E.slice(0,D);S=_.trim();const H=u.slice(0,w+D+M[0].length);let B=[];if(S)if(l==="block")for(B=h.blockTokens(_),B.forEach(V=>{V.text&&(!V.tokens||V.tokens.length===0)&&(V.tokens=h.inlineTokens(V.text))});B.length>0;){const V=B[B.length-1];if(V.type==="paragraph"&&(!V.text||V.text.trim()===""))B.pop();else break}else B=h.inlineTokens(S);return{type:e,raw:H,attributes:k,content:S,tokens:B}}}}}},renderMarkdown:(u,f)=>{const h=d(u.attrs||{}),p=o(h),g=p?` {${p}}`:"",y=f.renderChildren(u.content||[],`
92
+
93
+ `);return`:::${c}${g}
94
+
95
+ ${y}
96
+
97
+ :::`}}}function nb(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r;e[s]=o||i,r=t.exec(n)}return e}function rb(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function xf(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=nb,serializeAttributes:o=rb,defaultAttributes:i={},selfClosing:l=!1,allowedAttributes:a}=n,c=t||e,d=f=>{if(!a)return f;const h={};return a.forEach(p=>{const g=typeof p=="string"?p:p.name,y=typeof p=="string"?void 0:p.skipIfDefault;if(g in f){const x=f[g];if(y!==void 0&&x===y)return;h[g]=x}}),h},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const p={...i,...f.attributes};if(l)return h.createNode(e,p);const g=r?r(f):f.content||"";return g?h.createNode(e,p,[h.createTextNode(g)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=l?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=f.match(h),g=p?.index;return g!==void 0?g:-1},tokenize(f,h,p){const g=l?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),y=f.match(g);if(!y)return;let x="",b="";if(l){const[,C]=y;b=C}else{const[,C,w]=y;b=C,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 p=d(f.attrs||{}),g=o(p),y=g?` ${g}`:"";return l?`[${c}${y}]`:`[${c}${y}]${h}[/${c}]`}}}function pi(n,e,t){var r,s,o,i;const l=n.split(`
98
+ `),a=[];let c="",d=0;const u=e.baseIndentSize||2;for(;d<l.length;){const f=l[d],h=f.match(e.itemPattern);if(!h){if(a.length>0)break;if(f.trim()===""){d+=1,c=`${c}${f}
99
+ `;continue}else return}const p=e.extractItemData(h),{indentLevel:g,mainContent:y}=p;c=`${c}${f}
100
+ `;const x=[y];for(d+=1;d<l.length;){const w=l[d];if(w.trim()===""){const v=l.slice(d+1).findIndex(D=>D.trim()!=="");if(v===-1)break;if((((s=(r=l[d+1+v].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){x.push(w),c=`${c}${w}
101
+ `,d+=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}
102
+ `,d+=1;else break}let b;const k=x.slice(1);if(k.length>0){const w=k.map(S=>S.slice(g+u)).join(`
103
+ `);w.trim()&&(e.customNestedParser?b=e.customNestedParser(w):b=t.blockTokens(w))}const C=e.createToken(p,b);a.push(C)}if(a.length!==0)return{items:a,raw:c}}function Cl(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const s=typeof t=="function"?t(r):t,[o,...i]=n.content,l=e.renderChildren([o]),a=[`${s}${l}`];return i&&i.length>0&&i.forEach(c=>{const d=e.renderChildren([c]);if(d){const u=d.split(`
104
+ `).map(f=>f?e.indent(f):"").join(`
105
+ `);a.push(u)}}),a.join(`
106
+ `)}function sb(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),d=o.mapping.map(a)+l.nodeSize;let u=null;if(l.marks.forEach(h=>{if(h!==i)return!1;u=h}),!u)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==u.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,d,n.type),o.addMark(c,d,h)}}),o.docChanged&&e.view.dispatch(o)}var Ie=class bf extends wl{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new bf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},ob=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!d)return;let u=0,f=0;if(this.dom!==d){const b=this.dom.getBoundingClientRect(),k=d.getBoundingClientRect(),C=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,w=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;u=k.x-b.x+C,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 p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(l=n.dataTransfer)==null||l.setDragImage(h,u,f)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=$.create(a.state.doc,g),x=a.state.tr.setSelection(y);a.dispatch(x)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,d=$.isSelectable(this.node),u=n.type==="copy",f=n.type==="paste",h=n.type==="cut",p=n.type==="mousedown";if(!c&&d&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&p){const g=t.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||u||f||h||p&&d)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(ir()||di())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function Jt(n){return new Bx({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=G(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(kl(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===n.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;f<t.to&&i.delete(f,t.to),u>t.from&&i.delete(t.from+d,u),c=t.from+d+l.length,i.addMark(t.from+d,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}var ib=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},lb=({contentComponent:n})=>{const e=Rc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function ab(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:Oh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var cb=class extends ee.Component{constructor(n){var e;super(n),this.editorContentRef=ee.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=ab(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:ib(e,this.editorContentRef),...t}),n?.contentComponent&&m.jsx(lb,{contentComponent:n.contentComponent})]})}},db=A.forwardRef((n,e)=>{const t=ee.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return ee.createElement(cb,{key:t,innerRef:e,...n})}),ub=ee.memo(db),fb=typeof window<"u"?A.useLayoutEffect:A.useEffect,hb=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function pb(n){var e;const[t]=A.useState(()=>new hb(n.editor)),r=Ah.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:cm);return fb(()=>t.watch(n.editor),[n.editor,t]),A.useDebugValue(r),r}var mb=!1,mi=typeof window>"u",gb=mi||!!(typeof window<"u"&&window.next),yb=class kf{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?mi||gb?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 Gx(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?kf.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function xb(n={},e=[]){const t=A.useRef(n);t.current=n;const[r]=A.useState(()=>new yb(t)),s=Rc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return A.useDebugValue(s),A.useEffect(r.onRender(e)),pb({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var bb=A.createContext({editor:null});bb.Consumer;var wf=A.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),kb=()=>A.useContext(wf),dc=ee.forwardRef((n,e)=>{const{onDragStart:t}=kb(),r=n.as||"div";return m.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function uc(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function fc(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function wb(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Sb(n){if(uc(n)||fc(n))return!0;if(wb(n)){const e=n.type;if(e)return uc(e)||fc(e)}return!1}function vb(){try{if(A.version)return parseInt(A.version.split(".")[0],10)>=19}catch{}return!1}var Sf=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?Mh.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var n;if(this.destroyed)return;const e=this.component,t=this.props,r=this.editor,s=vb(),o=Sb(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.destroyed||(this.props={...this.props,...n},this.render())}destroy(){var n;this.destroyed=!0;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};ee.createContext({markViewContentRef:()=>{}});var Cb=class extends ob{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:A.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=A.memo(a=>m.jsx(wf.Provider,{value:r,children:A.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 Sf(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=Nn(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Nb(n,e){return t=>t.editor.contentComponent?new Cb(n,t,e):{}}var es=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},Eb=/^\s*>\s$/,Tb=Ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return es("blockquote",{...ne(this.options.HTMLAttributes,n),children:es("slot",{})})},parseMarkdown:(n,e)=>e.createNode("blockquote",void 0,e.parseChildren(n.tokens||[])),renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach(s=>{const l=e.renderChildren([s]).split(`
107
+ `).map(a=>a.trim()===""?t:`${t} ${a}`);r.push(l.join(`
108
+ `))}),r.join(`
109
+ ${t}
110
+ `)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Tn({find:Eb,type:this.type})]}}),Mb=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ab=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ob=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ib=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Rb=Yt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return es("strong",{...ne(this.options.HTMLAttributes,n),children:es("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[En({find:Mb,type:this.type}),En({find:Ob,type:this.type})]},addPasteRules(){return[Jt({find:Ab,type:this.type}),Jt({find:Ib,type:this.type})]}}),jb=/(^|[^`])`([^`]+)`(?!`)$/,Db=/(^|[^`])`([^`]+)`(?!`)/g,Pb=Yt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[En({find:jb,type:this.type})]},addPasteRules(){return[Jt({find:Db,type:this.type})]}}),Do=4,Lb=/^```([a-z]+)?[\s\n]$/,$b=/^~~~([a-z]+)?[\s\n]$/,zb=Ie.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Do,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const o=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ne(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const s=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${s}`,e.renderChildren(n.content),"```"].join(`
111
+ `):r=`\`\`\`${s}
112
+
113
+ \`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Do,{state:r}=n,{selection:s}=r,{$from:o,empty:i}=s;if(o.parent.type!==this.type)return!1;const l=" ".repeat(t);return i?n.commands.insertContent(l):n.commands.command(({tr:a})=>{const{from:c,to:d}=s,h=r.doc.textBetween(c,d,`
114
+ `,`
115
+ `).split(`
116
+ `).map(p=>l+p).join(`
117
+ `);return a.replaceWith(c,d,r.schema.text(h)),!0})},"Shift-Tab":({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Do,{state:r}=n,{selection:s}=r,{$from:o,empty:i}=s;return o.parent.type!==this.type?!1:i?n.commands.command(({tr:l})=>{var a;const{pos:c}=o,d=o.start(),u=o.end(),h=r.doc.textBetween(d,u,`
118
+ `,`
119
+ `).split(`
120
+ `);let p=0,g=0;const y=c-d;for(let S=0;S<h.length;S+=1){if(g+h[S].length>=y){p=S;break}g+=h[S].length+1}const b=((a=h[p].match(/^ */))==null?void 0:a[0])||"",k=Math.min(b.length,t);if(k===0)return!0;let C=d;for(let S=0;S<p;S+=1)C+=h[S].length+1;return l.delete(C,C+k),c-C<=k&&l.setSelection(F.create(l.doc,C)),!0}):n.commands.command(({tr:l})=>{const{from:a,to:c}=s,f=r.doc.textBetween(a,c,`
121
+ `,`
122
+ `).split(`
123
+ `).map(h=>{var p;const g=((p=h.match(/^ */))==null?void 0:p[0])||"",y=Math.min(g.length,t);return h.slice(y)}).join(`
124
+ `);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
125
+
126
+ `);return!o||!i?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:o}=t;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(q.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[hi({find:Lb,type:this.type,getAttributes:n=>({language:n[1]})}),hi({find:$b,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new re({key:new ae("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s?.mode;if(!t||!o)return!1;const{tr:i,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
127
+ `));return i.replaceSelectionWith(this.type.create({language:o},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(F.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),_b=Ie.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
128
+
129
+ `):""}),Bb=Ie.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",ne(this.options.HTMLAttributes,n)]},renderText(){return`
130
+ `},renderMarkdown:()=>`
131
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:o}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=o||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&i){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Fb=Ie.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ne(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,s="#".repeat(r);return n.content?`${s} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>hi({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),Hb=Ie.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ne(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Yx(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,s=n();return ef(t)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:o,tr:i,dispatch:l})=>{if(l){const{$to:a}=i.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(F.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection($.create(i.doc,a.pos)):i.setSelection(F.create(i.doc,a.pos));else{const d=o.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(i.insert(c,u),i.setSelection(F.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Xx({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Vb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Wb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,qb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ub=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Kb=Yt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ne(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[En({find:Vb,type:this.type}),En({find:qb,type:this.type})]},addPasteRules(){return[Jt({find:Wb,type:this.type}),Jt({find:Ub,type:this.type})]}});const Jb="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Gb="ελ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",gi="numeric",yi="ascii",xi="alpha",Un="asciinumeric",Fn="alphanumeric",bi="domain",vf="emoji",Xb="scheme",Yb="slashscheme",Po="whitespace";function Qb(n,e){return n in e||(e[n]=[]),e[n]}function Dt(n,e,t){e[gi]&&(e[Un]=!0,e[Fn]=!0),e[yi]&&(e[Un]=!0,e[xi]=!0),e[Un]&&(e[Fn]=!0),e[xi]&&(e[Fn]=!0),e[Fn]&&(e[bi]=!0),e[vf]&&(e[bi]=!0);for(const r in e){const s=Qb(r,t);s.indexOf(n)<0&&s.push(n)}}function Zb(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Ae(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Ae.groups={};Ae.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(n))return o}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||Ae.groups;let s;return e&&e.j?s=e:(s=new Ae(e),t&&r&&Dt(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const o=n.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(n[i]);return s.tt(n[o-1],e,t,r)},tt(n,e,t,r){r=r||Ae.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const o=e;let i,l=s.go(n);if(l?(i=new 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(Zb(i.t,r),t);Dt(o,a,r)}else t&&Dt(o,t,r);i.t=o}return s.j[n]=i,i}};const W=(n,e,t,r,s)=>n.ta(e,t,r,s),oe=(n,e,t,r,s)=>n.tr(e,t,r,s),hc=(n,e,t,r,s)=>n.ts(e,t,r,s),O=(n,e,t,r,s)=>n.tt(e,t,r,s),nt="WORD",ki="UWORD",Cf="ASCIINUMERICAL",Nf="ALPHANUMERICAL",ar="LOCALHOST",wi="TLD",Si="UTLD",$r="SCHEME",mn="SLASH_SCHEME",Nl="NUM",vi="WS",El="NL",Kn="OPENBRACE",Jn="CLOSEBRACE",ts="OPENBRACKET",ns="CLOSEBRACKET",rs="OPENPAREN",ss="CLOSEPAREN",is="OPENANGLEBRACKET",ls="CLOSEANGLEBRACKET",as="FULLWIDTHLEFTPAREN",cs="FULLWIDTHRIGHTPAREN",ds="LEFTCORNERBRACKET",us="RIGHTCORNERBRACKET",fs="LEFTWHITECORNERBRACKET",hs="RIGHTWHITECORNERBRACKET",ps="FULLWIDTHLESSTHAN",ms="FULLWIDTHGREATERTHAN",gs="AMPERSAND",ys="APOSTROPHE",xs="ASTERISK",ht="AT",bs="BACKSLASH",ks="BACKTICK",ws="CARET",gt="COLON",Tl="COMMA",Ss="DOLLAR",Ue="DOT",vs="EQUALS",Ml="EXCLAMATION",Pe="HYPHEN",Gn="PERCENT",Cs="PIPE",Ns="PLUS",Es="POUND",Xn="QUERY",Al="QUOTE",Ef="FULLWIDTHMIDDLEDOT",Ol="SEMI",Ke="SLASH",Yn="TILDE",Ts="UNDERSCORE",Tf="EMOJI",Ms="SYM";var Mf=Object.freeze({__proto__:null,ALPHANUMERICAL:Nf,AMPERSAND:gs,APOSTROPHE:ys,ASCIINUMERICAL:Cf,ASTERISK:xs,AT:ht,BACKSLASH:bs,BACKTICK:ks,CARET:ws,CLOSEANGLEBRACKET:ls,CLOSEBRACE:Jn,CLOSEBRACKET:ns,CLOSEPAREN:ss,COLON:gt,COMMA:Tl,DOLLAR:Ss,DOT:Ue,EMOJI:Tf,EQUALS:vs,EXCLAMATION:Ml,FULLWIDTHGREATERTHAN:ms,FULLWIDTHLEFTPAREN:as,FULLWIDTHLESSTHAN:ps,FULLWIDTHMIDDLEDOT:Ef,FULLWIDTHRIGHTPAREN:cs,HYPHEN:Pe,LEFTCORNERBRACKET:ds,LEFTWHITECORNERBRACKET:fs,LOCALHOST:ar,NL:El,NUM:Nl,OPENANGLEBRACKET:is,OPENBRACE:Kn,OPENBRACKET:ts,OPENPAREN:rs,PERCENT:Gn,PIPE:Cs,PLUS:Ns,POUND:Es,QUERY:Xn,QUOTE:Al,RIGHTCORNERBRACKET:us,RIGHTWHITECORNERBRACKET:hs,SCHEME:$r,SEMI:Ol,SLASH:Ke,SLASH_SCHEME:mn,SYM:Ms,TILDE:Yn,TLD:wi,UNDERSCORE:Ts,UTLD:Si,UWORD:ki,WORD:nt,WS:vi});const et=/[a-z]/,$n=new RegExp("\\p{L}","u"),Lo=new RegExp("\\p{Emoji}","u"),tt=/\d/,$o=/\s/,pc="\r",zo=`
132
+ `,ek="️",tk="‍",_o="";let Ar=null,Or=null;function nk(n=[]){const e={};Ae.groups=e;const t=new Ae;Ar==null&&(Ar=mc(Jb)),Or==null&&(Or=mc(Gb)),O(t,"'",ys),O(t,"{",Kn),O(t,"}",Jn),O(t,"[",ts),O(t,"]",ns),O(t,"(",rs),O(t,")",ss),O(t,"<",is),O(t,">",ls),O(t,"(",as),O(t,")",cs),O(t,"「",ds),O(t,"」",us),O(t,"『",fs),O(t,"』",hs),O(t,"<",ps),O(t,">",ms),O(t,"&",gs),O(t,"*",xs),O(t,"@",ht),O(t,"`",ks),O(t,"^",ws),O(t,":",gt),O(t,",",Tl),O(t,"$",Ss),O(t,".",Ue),O(t,"=",vs),O(t,"!",Ml),O(t,"-",Pe),O(t,"%",Gn),O(t,"|",Cs),O(t,"+",Ns),O(t,"#",Es),O(t,"?",Xn),O(t,'"',Al),O(t,"/",Ke),O(t,";",Ol),O(t,"~",Yn),O(t,"_",Ts),O(t,"\\",bs),O(t,"・",Ef);const r=oe(t,tt,Nl,{[gi]:!0});oe(r,tt,r);const s=oe(r,et,Cf,{[Un]:!0}),o=oe(r,$n,Nf,{[Fn]:!0}),i=oe(t,et,nt,{[yi]:!0});oe(i,tt,s),oe(i,et,i),oe(s,tt,s),oe(s,et,s);const l=oe(t,$n,ki,{[xi]:!0});oe(l,et),oe(l,tt,o),oe(l,$n,l),oe(o,tt,o),oe(o,et),oe(o,$n,o);const a=O(t,zo,El,{[Po]:!0}),c=O(t,pc,vi,{[Po]:!0}),d=oe(t,$o,vi,{[Po]:!0});O(t,_o,d),O(c,zo,a),O(c,_o,d),oe(c,$o,d),O(d,pc),O(d,zo),oe(d,$o,d),O(d,_o,d);const u=oe(t,Lo,Tf,{[vf]:!0});O(u,"#"),oe(u,Lo,u),O(u,ek,u);const f=O(u,tk);O(f,"#"),oe(f,Lo,u);const h=[[et,i],[tt,s]],p=[[et,null],[$n,l],[tt,o]];for(let g=0;g<Ar.length;g++)ct(t,Ar[g],wi,nt,h);for(let g=0;g<Or.length;g++)ct(t,Or[g],Si,ki,p);Dt(wi,{tld:!0,ascii:!0},e),Dt(Si,{utld:!0,alpha:!0},e),ct(t,"file",$r,nt,h),ct(t,"mailto",$r,nt,h),ct(t,"http",mn,nt,h),ct(t,"https",mn,nt,h),ct(t,"ftp",mn,nt,h),ct(t,"ftps",mn,nt,h),Dt($r,{scheme:!0,ascii:!0},e),Dt(mn,{slashscheme:!0,ascii:!0},e),n=n.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<n.length;g++){const y=n[g][0],b=n[g][1]?{[Xb]:!0}:{[Yb]:!0};y.indexOf("-")>=0?b[bi]=!0:et.test(y)?tt.test(y)?b[Un]=!0:b[yi]=!0:b[gi]=!0,hc(t,y,y,b)}return hc(t,"localhost",ar,{ascii:!0}),t.jd=new Ae(Ms),{start:t,tokens:Object.assign({groups:e},Mf)}}function Af(n,e){const t=rk(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,s=[];let o=0,i=0;for(;i<r;){let l=n,a=null,c=0,d=null,u=-1,f=-1;for(;i<r&&(a=l.go(t[i]));)l=a,l.accepts()?(u=0,f=0,d=l):u>=0&&(u+=t[i].length,f++),c+=t[i].length,o+=t[i].length,i++;o-=u,i-=f,c-=u,s.push({t:d.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function rk(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),o,i=s<55296||s>56319||r+1===t||(o=n.charCodeAt(r+1))<56320||o>57343?n[r]:n.slice(r,r+2);e.push(i),r+=i.length}return e}function ct(n,e,t,r,s){let o;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];n.j[a]?o=n.j[a]:(o=new Ae(r),o.jr=s.slice(),n.j[a]=o),n=o}return o=new Ae(t),o.jr=s.slice(),n.j[e[i-1]]=o,o}function mc(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let o=0;for(;s.indexOf(n[r+o])>=0;)o++;if(o>0){e.push(t.join(""));for(let i=parseInt(n.substring(r,r+o),10);i>0;i--)t.pop();r+=o}else t.push(n[r]),r++}return e}const cr={defaultProtocol:"http",events:null,format:gc,formatHref:gc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Il(n,e=null){let t=Object.assign({},cr);n&&(t=Object.assign(t,n instanceof Il?n.o:n));const r=t.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}Il.prototype={o:cr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:cr[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function gc(n){return n}function Of(n,e){this.t="token",this.v=n,this.tk=e}Of.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=cr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),o=this.toFormattedString(n),i={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),d&&Object.assign(i,d),{tagName:s,attributes:i,content:o,eventListeners:u}}};function Ys(n,e){class t extends Of{constructor(s,o){super(s,o),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const yc=Ys("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),xc=Ys("text"),sk=Ys("nl"),Ir=Ys("url",{isLink:!0,toHref(n=cr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==ar&&n[1].t===gt}}),De=n=>new Ae(n);function ok({groups:n}){const e=n.domain.concat([gs,xs,ht,bs,ks,ws,Ss,vs,Pe,Nl,Gn,Cs,Ns,Es,Ke,Ms,Yn,Ts]),t=[ys,gt,Tl,Ue,Ml,Gn,Xn,Al,Ol,is,ls,Kn,Jn,ns,ts,rs,ss,as,cs,ds,us,fs,hs,ps,ms],r=[gs,ys,xs,bs,ks,ws,Ss,vs,Pe,Kn,Jn,Gn,Cs,Ns,Es,Xn,Ke,Ms,Yn,Ts],s=De(),o=O(s,Yn);W(o,r,o),W(o,n.domain,o);const i=De(),l=De(),a=De();W(s,n.domain,i),W(s,n.scheme,l),W(s,n.slashscheme,a),W(i,r,o),W(i,n.domain,i);const c=O(i,ht);O(o,ht,c),O(l,ht,c),O(a,ht,c);const d=O(o,Ue);W(d,r,o),W(d,n.domain,o);const u=De();W(c,n.domain,u),W(u,n.domain,u);const f=O(u,Ue);W(f,n.domain,u);const h=De(yc);W(f,n.tld,h),W(f,n.utld,h),O(c,ar,h);const p=O(u,Pe);O(p,Pe,p),W(p,n.domain,u),W(h,n.domain,u),O(h,Ue,f),O(h,Pe,p);const g=O(h,gt);W(g,n.numeric,yc);const y=O(i,Pe),x=O(i,Ue);O(y,Pe,y),W(y,n.domain,i),W(x,r,o),W(x,n.domain,i);const b=De(Ir);W(x,n.tld,b),W(x,n.utld,b),W(b,n.domain,i),W(b,r,o),O(b,Ue,x),O(b,Pe,y),O(b,ht,c);const k=O(b,gt),C=De(Ir);W(k,n.numeric,C);const w=De(Ir),S=De();W(w,e,w),W(w,t,S),W(S,e,w),W(S,t,S),O(b,Ke,w),O(C,Ke,w);const v=O(l,gt),E=O(a,gt),M=O(E,Ke),D=O(M,Ke);W(l,n.domain,i),O(l,Ue,x),O(l,Pe,y),W(a,n.domain,i),O(a,Ue,x),O(a,Pe,y),W(v,n.domain,w),O(v,Ke,w),O(v,Xn,w),W(D,n.domain,w),W(D,e,w),O(D,Ke,w);const j=[[Kn,Jn],[ts,ns],[rs,ss],[is,ls],[as,cs],[ds,us],[fs,hs],[ps,ms]];for(let _=0;_<j.length;_++){const[H,B]=j[_],V=O(w,H);O(S,H,V),O(V,B,w);const N=De(Ir);W(V,e,N);const z=De();W(V,t),W(N,e,N),W(N,t,z),W(z,e,N),W(z,t,z),O(N,B,w),O(z,B,w)}return O(s,ar,b),O(s,El,sk),{start:s,tokens:Mf}}function ik(n,e,t){let r=t.length,s=0,o=[],i=[];for(;s<r;){let l=n,a=null,c=null,d=0,u=null,f=-1;for(;s<r&&!(a=l.go(t[s].t));)i.push(t[s++]);for(;s<r&&(c=a||l.go(t[s].t));)a=null,l=c,l.accepts()?(f=0,u=l):f>=0&&f++,s++,d++;if(f<0)s-=d,s<r&&(i.push(t[s]),s++);else{i.length>0&&(o.push(Bo(xc,e,i)),i=[]),s-=f,d-=f;const h=u.t,p=t.slice(s-d,s);o.push(Bo(h,e,p))}}return i.length>0&&o.push(Bo(xc,e,i)),o}function Bo(n,e,t){const r=t[0].s,s=t[t.length-1].e,o=e.slice(r,s);return new n(o,t)}const lk=typeof console<"u"&&console&&console.warn||(()=>{}),ak="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Z={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ck(){return Ae.groups={},Z.scanner=null,Z.parser=null,Z.tokenQueue=[],Z.pluginQueue=[],Z.customSchemes=[],Z.initialized=!1,Z}function bc(n,e=!1){if(Z.initialized&&lk(`linkifyjs: already initialized - will not register custom scheme "${n}" ${ak}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
133
+ 1. Must only contain digits, lowercase ASCII letters or "-"
134
+ 2. Cannot start or end with "-"
135
+ 3. "-" cannot repeat`);Z.customSchemes.push([n,e])}function dk(){Z.scanner=nk(Z.customSchemes);for(let n=0;n<Z.tokenQueue.length;n++)Z.tokenQueue[n][1]({scanner:Z.scanner});Z.parser=ok(Z.scanner.tokens);for(let n=0;n<Z.pluginQueue.length;n++)Z.pluginQueue[n][1]({scanner:Z.scanner,parser:Z.parser});return Z.initialized=!0,Z}function Rl(n){return Z.initialized||dk(),ik(Z.parser.start,n,Af(Z.scanner.start,n))}Rl.scan=Af;function If(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Il(t),s=Rl(n),o=[];for(let i=0;i<s.length;i++){const l=s[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&o.push(l.toFormattedObject(r))}return o}var jl="[\0-   ᠎ -\u2029  ]",uk=new RegExp(jl),fk=new RegExp(`${jl}$`),hk=new RegExp(jl,"g");function pk(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function mk(n){return new re({key:new ae("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=Uu(t.doc,[...e]);if(Zu(l).forEach(({newRange:c})=>{const d=Yy(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!fk.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){const h=f.split(uk).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],g=u.pos+f.lastIndexOf(p);if(!p)return!1;const y=Rl(p).map(x=>x.toObject(n.defaultProtocol));if(!pk(y))return!1;y.filter(x=>x.isLink).map(x=>({...x,from:g+x.start+1,to:g+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>n.validate(x.value)).filter(x=>n.shouldAutoLink(x.value)).forEach(x=>{kl(x.from,x.to,r.doc).some(b=>b.mark.type===n.type)||i.addMark(x.from,x.to,n.type.create({href:x.href}))})}}),!!i.steps.length)return i}})}function gk(n){return new re({key:new ae("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=!1;if(n.enableClickSelection&&(i=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{let u=r.target;const f=[];for(;u.nodeName!=="DIV";)f.push(u),u=u.parentNode;l=f.find(h=>h.nodeName==="A")}if(!l)return i;const a=Qu(e.state,n.type.name),c=(s=l?.href)!=null?s:a.href,d=(o=l?.target)!=null?o:a.target;l&&c&&(window.open(c,d),i=!0)}return i}}})}function yk(n){return new re({key:new ae("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:s}=n,{state:o}=e,{selection:i}=o,{empty:l}=i;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});const c=If(a,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function At(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(hk,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var xk=Yt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){bc(n);return}bc(n.scheme,n.optionalSlashes)})},onDestroy(){ck()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!At(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const s=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!At(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!At(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ne(this.options.HTMLAttributes,n),0]:["a",ne(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t;const r=((t=n.attrs)==null?void 0:t.href)||"";return`[${e.renderChildren(n)}](${r})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!At(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!At(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Jt({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=If(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!At(i,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(o=>{this.options.shouldAutoLink(o.value)&&e.push({text:o.value,data:{href:o.href},index:o.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(mk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!At(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(gk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(yk({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),bk=Object.defineProperty,kk=(n,e)=>{for(var t in e)bk(n,t,{get:e[t],enumerable:!0})},wk="listItem",kc="textStyle",wc=/^\s*([-+*])\s$/,Rf=Ie.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
136
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(wk,this.editor.getAttributes(kc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Tn({find:wc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Tn({find:wc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kc),editor:this.editor})),[n]}}),jf=Ie.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{if(n.type!=="list_item")return[];let t=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(s=>s.type==="paragraph"))t=e.parseChildren(n.tokens);else{const s=n.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(t=[{type:"paragraph",content:e.parseInline(s.tokens)}],n.tokens.length>1){const i=n.tokens.slice(1),l=e.parseChildren(i);t.push(...l)}}else t=e.parseChildren(n.tokens)}return t.length===0&&(t=[{type:"paragraph",content:[]}]),{type:"listItem",content:t}},renderMarkdown:(n,e,t)=>Cl(n,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Sk={};kk(Sk,{findListItemPos:()=>xr,getNextListDepth:()=>Dl,handleBackspace:()=>Ci,handleDelete:()=>Ni,hasListBefore:()=>Df,hasListItemAfter:()=>vk,hasListItemBefore:()=>Pf,listItemHasSubList:()=>Lf,nextListIsDeeper:()=>$f,nextListIsHigher:()=>zf});var xr=(n,e)=>{const{$from:t}=e.selection,r=ue(n,e.schema);let s=null,o=t.depth,i=t.pos,l=null;for(;o>0&&l===null;)s=t.node(o),s.type===r?l=o:(o-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},Dl=(n,e)=>{const t=xr(n,e);if(!t)return!1;const[,r]=lx(e,n,t.$pos.pos+4);return r},Df=(n,e,t)=>{const{$anchor:r}=n.selection,s=Math.max(0,r.pos-2),o=n.doc.resolve(s).node();return!(!o||!t.includes(o.type.name))},Pf=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((t=s.nodeBefore)==null?void 0:t.type.name)!==n)},Lf=(n,e,t)=>{if(!t)return!1;const r=ue(n,e.schema);let s=!1;return t.descendants(o=>{o.type===r&&(s=!0)}),s},Ci=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Nt(n.state,e)&&Df(n.state,e,t)){const{$anchor:l}=n.state.selection,a=n.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const d=c.at(-1);if(!d)return!1;const u=n.state.doc.resolve(a.start()+d.pos+1);return n.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!Nt(n.state,e)||!ux(n.state))return!1;const r=xr(e,n.state);if(!r)return!1;const o=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=Lf(e,n.state,o);return Pf(e,n.state)&&!i?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},$f=(n,e)=>{const t=Dl(n,e),r=xr(n,e);return!r||!t?!1:t>r.depth},zf=(n,e)=>{const t=Dl(n,e),r=xr(n,e);return!r||!t?!1:t<r.depth},Ni=(n,e)=>{if(!Nt(n.state,e)||!dx(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:s}=t;return!t.empty&&r.sameParent(s)?!1:$f(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():zf(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},vk=(n,e)=>{var t;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((t=s.nodeAfter)==null?void 0:t.type.name)!==n)},_f=ce.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Ni(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&Ni(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ci(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Ci(n,t,r)&&(e=!0)}),e}}}}),Sc=/^(\s*)(\d+)\.\s+(.*)$/,Ck=/^\s/;function Nk(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t],o=s.match(Sc);if(!o)break;const[,i,l,a]=o,c=i.length;let d=a,u=t+1;const f=[s];for(;u<n.length;){const h=n[u];if(h.match(Sc))break;if(h.trim()==="")f.push(h),d+=`
137
+ `,u+=1;else if(h.match(Ck))f.push(h),d+=`
138
+ ${h.slice(c+2)}`,u+=1;else break}e.push({indent:c,number:parseInt(l,10),content:d.trim(),raw:f.join(`
139
+ `)}),r=u,t=u}return[e,r]}function Bf(n,e,t){var r;const s=[];let o=0;for(;o<n.length;){const i=n[o];if(i.indent===e){const l=i.content.split(`
140
+ `),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:t.inlineTokens(a)});const d=l.slice(1).join(`
141
+ `).trim();if(d){const h=t.blockTokens(d);c.push(...h)}let u=o+1;const f=[];for(;u<n.length&&n[u].indent>e;)f.push(n[u]),u+=1;if(f.length>0){const h=Math.min(...f.map(g=>g.indent)),p=Bf(f,h,t);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(g=>g.raw).join(`
142
+ `)})}s.push({type:"list_item",raw:i.raw,tokens:c}),o=u}else o+=1}return s}function Ek(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const o=e.parseChildren([s]);r.push({type:"paragraph",content:o})}else{const o=e.parseChildren([s]);o.length>0&&r.push(...o)}}),{type:"listItem",content:r}})}var Tk="listItem",vc="textStyle",Cc=/^(\d+)\.\s$/,Ff=Ie.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",ne(this.options.HTMLAttributes,t),0]:["ol",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?Ek(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
143
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const s=n.split(`
144
+ `),[o,i]=Nk(s);if(o.length===0)return;const l=Bf(o,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=o[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,i).join(`
145
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Tk,this.editor.getAttributes(vc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Tn({find:Cc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Tn({find:Cc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(vc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Mk=/^\s*(\[([( |x])?\])\s$/,Ak=Ie.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",ne(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return Cl(n,e,s)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};c(n),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const g=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{s.setAttribute(u,f)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([u,f])=>{s.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;s.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);const f=r.extensionManager.attributes,h=Nn(u,f),p=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return d.forEach(y=>{p.has(y)||(y in g?s.setAttribute(y,g[y]):s.removeAttribute(y))}),Object.entries(h).forEach(([y,x])=>{x==null?y in g?s.setAttribute(y,g[y]):s.removeAttribute(y):s.setAttribute(y,x)}),d=p,!0}}}},addInputRules(){return[Tn({find:Mk,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),Ok=Ie.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",ne(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
146
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=pi(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=pi(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ce.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(Rf.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(jf.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(_f.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(Ff.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Ak.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(Ok.configure(this.options.taskList)),n}});var Ik=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ne(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];return t.length===1&&t[0].type==="image"?e.parseChildren([t[0]]):e.createNode("paragraph",void 0,e.parseInline(t))},renderMarkdown:(n,e)=>!n||!Array.isArray(n.content)?"":e.renderChildren(n.content),addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Rk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,jk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Dk=Yt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ne(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[En({find:Rk,type:this.type})]},addPasteRules(){return[Jt({find:jk,type:this.type})]}}),Pk=Ie.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Lk=Yt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ne(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function $k(n={}){return new re({view(e){return new zk(e,n)}})}class zk{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=u?p.bottom:p.top;u&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=$d(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ie extends q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return ie.valid(r)?new ie(r):q.near(r)}content(){return R.empty}eq(e){return e instanceof ie&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ie(e.resolve(t.pos))}getBookmark(){return new Pl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!_k(e)||!Bk(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ie.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(ie.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!$.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(ie.valid(l))return l}return null}}}ie.prototype.visible=!1;ie.findFrom=ie.findGapCursorFrom;q.jsonID("gapcursor",ie);class Pl{constructor(e){this.pos=e}map(e){return new Pl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ie.valid(t)?new ie(t):q.near(t)}}function Hf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function _k(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Hf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Bk(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Hf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Fk(){return new re({props:{decorations:qk,createSelectionBetween(n,e,t){return e.pos==t.pos&&ie.valid(t)?new ie(t):null},handleClick:Vk,handleKeyDown:Hk,handleDOMEvents:{beforeinput:Wk}}})}const Hk=zu({ArrowLeft:Rr("horiz",-1),ArrowRight:Rr("horiz",1),ArrowUp:Rr("vert",-1),ArrowDown:Rr("vert",1)});function Rr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof F){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ie.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ie(c))),!0):!1}}function Vk(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ie.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&$.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ie(r))),!0)}function Wk(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ie))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=T.empty;for(let i=r.length-1;i>=0;i--)s=T.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new R(s,0,0));return o.setSelection(F.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function qk(n){if(!(n.selection instanceof ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",te.create(n.doc,[ve.widget(n.selection.head,e,{key:"gapcursor"})])}var As=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<As&&this.leafAppend(e)||this.length<As&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new Uk(this,e)};ye.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ye.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};ye.from=function(e){return e instanceof ye?e:e&&e.length?new Vf(e):ye.empty};var Vf=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=As)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=As)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ye);ye.empty=new Vf([]);var Uk=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ye);const Kk=500;class Ve{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,d.push(u);return}if(s){d.push(new dt(u.map));let h=u.step.map(s.slice(o)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new dt(p,void 0,void 0,c.length+d.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(o)):u.selection,a=new Ve(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new dt(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>Gk&&(l=Jk(l,c),i-=c),new Ve(l.append(o),i)}remapping(e,t){let r=new tr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Ve(this.items.append(e.map(t=>new dt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=o.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,r.push(new dt(p,g,y))}else r.push(new dt(p))},s);let c=[];for(let f=t;f<i;f++)c.push(new dt(o.maps[f]));let d=this.items.slice(0,s).append(c).append(r),u=new Ve(d,l);return u.emptyItemCount()>Kk&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=i.selection&&i.selection.map(t.slice(r));d&&o++;let u=new dt(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else i.map&&r--},this.items.length,0),new Ve(ye.from(s.reverse()),o)}}Ve.empty=new Ve(ye.empty,0);function Jk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}let dt=class Wf{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Wf(t.getMap().invert(),t,this.selection)}}};class pt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const Gk=20;function Xk(n,e,t,r){let s=t.getMeta(Vt),o;if(s)return s.historyState;t.getMeta(Zk)&&(n=new pt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(Vt))return i.getMeta(Vt).redo?new pt(n.done.addTransform(t,void 0,r,zr(e)),n.undone,Nc(t.mapping.maps),n.prevTime,n.prevComposition):new pt(n.done,n.undone.addTransform(t,void 0,r,zr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Yk(t,n.prevRanges)),c=i?Fo(n.prevRanges,t.mapping):Nc(t.mapping.maps);return new pt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,zr(e)),Ve.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new pt(n.done.rebased(t,o),n.undone.rebased(t,o),Fo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new pt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Fo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Yk(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function Nc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function Fo(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function Qk(n,e,t){let r=zr(e),s=Vt.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new pt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(Vt,{redo:t,historyState:a})}let Ho=!1,Ec=null;function zr(n){let e=n.plugins;if(Ec!=e){Ho=!1,Ec=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ho=!0;break}}return Ho}const Vt=new ae("history"),Zk=new ae("closeHistory");function ew(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new re({key:Vt,state:{init(){return new pt(Ve.empty,Ve.empty,null,0,-1)},apply(e,t,r){return Xk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Uf:r=="historyRedo"?Kf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function qf(n,e){return(t,r)=>{let s=Vt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=Qk(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const Uf=qf(!1,!0),Kf=qf(!0,!0);ce.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new re({key:new ae("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});var tw=ce.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[$k(this.options)]}});ce.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new re({key:new ae("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return te.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(ve.node(c,c+a.nodeSize,{class:this.options.className}))}),te.create(n,o)}}})]}});var nw=ce.create({name:"gapCursor",addProseMirrorPlugins(){return[Fk()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=G(L(n,"allowGapCursor",t)))!=null?e:null}}});ce.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new re({key:new ae("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const o=this.editor.isEmpty;return n.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&Js(i);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const u=ve.node(l,l+i.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),te.create(n,s)}}})]}});ce.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new re({key:new ae("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||ef(t.selection)||n.view.dragging?null:te.create(t.doc,[ve.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Tc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var rw=ce.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ae(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new re({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,d=e.getState(i),u=l.content.size,f=c.nodes[t];if(d)return a.insert(u,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!Tc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!Tc({node:i,types:r})}}})]}}),sw=ce.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Uf(n,e),redo:()=>({state:n,dispatch:e})=>Kf(n,e)}},addProseMirrorPlugins(){return[ew(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()}}}),ow=ce.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(Rb.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Tb.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Rf.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Pb.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(zb.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(_b.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(tw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(nw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Bb.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Fb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(sw.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(Hb.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Kb.configure(this.options.italic)),this.options.listItem!==!1&&s.push(jf.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(_f.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(xk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Ff.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Ik.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Dk.configure(this.options.strike)),this.options.text!==!1&&s.push(Pk.configure(this.options.text)),this.options.underline!==!1&&s.push(Lk.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(rw.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),iw=ow;function lw(n){var e;const{char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=n,a=r&&!s,c=Qx(t),d=new RegExp(`\\s${c}$`),u=i?"^":"",f=s?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.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 C=k+y[0].length;return a&&d.test(p.slice(C-1,C+1))&&(y[0]+=" ",C+=1),k<l.pos&&C>=l.pos?{range:{from:k,to:C},query:y[0].slice(t.length),text:y[0]}:null}var aw=new ae("suggestion");function cw({pluginKey:n=aw,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=lw,shouldShow:y}){let x;const b=h?.(),k=()=>{const v=e.state.selection.$anchor.pos,E=e.view.coordsAtPos(v),{top:M,right:D,bottom:j,left:_}=E;try{return new DOMRect(_,M,D-_,j-M)}catch{return null}},C=(v,E)=>E?()=>{const M=n.getState(e.state),D=M?.decorationId,j=v.dom.querySelector(`[data-decoration-id="${D}"]`);return j?.getBoundingClientRect()||null}:k;function w(v,E){var M;try{const j=n.getState(v.state),_=j?.decorationId?v.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null,H={editor:e,range:j?.range||{from:0,to:0},query:j?.query||null,text:j?.text||null,items:[],command:B=>u({editor:e,range:j?.range||{from:0,to:0},props:B}),decorationNode:_,clientRect:C(v,_)};(M=b?.onExit)==null||M.call(b,H)}catch{}const D=v.state.tr.setMeta(E,{exit:!0});v.dispatch(D)}const S=new re({key:n,view(){return{update:async(v,E)=>{var M,D,j,_,H,B,V;const N=(M=this.key)==null?void 0:M.getState(E),z=(D=this.key)==null?void 0:D.getState(v.state),P=N.active&&z.active&&N.range.from!==z.range.from,U=!N.active&&z.active,Q=N.active&&!z.active,le=!U&&!Q&&N.query!==z.query,X=U||P&&le,fe=le||P,se=Q||P&&le;if(!X&&!fe&&!se)return;const K=se&&!X?N:z,Fe=v.dom.querySelector(`[data-decoration-id="${K.decorationId}"]`);x={editor:e,range:K.range,query:K.query,text:K.text,items:[],command:at=>u({editor:e,range:K.range,props:at}),decorationNode:Fe,clientRect:C(v,Fe)},X&&((j=b?.onBeforeStart)==null||j.call(b,x)),fe&&((_=b?.onBeforeUpdate)==null||_.call(b,x)),(fe||X)&&(x.items=await f({editor:e,query:K.query})),se&&((H=b?.onExit)==null||H.call(b,x)),fe&&((B=b?.onUpdate)==null||B.call(b,x)),X&&((V=b?.onStart)==null||V.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,E,M,D){const{isEditable:j}=e,{composing:_}=e.view,{selection:H}=v,{empty:B,from:V}=H,N={...E},z=v.getMeta(n);if(z&&z.exit)return N.active=!1,N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null,N;if(N.composing=_,j&&(B||e.view.composing)){(V<E.range.from||V>E.range.to)&&!_&&!E.composing&&(N.active=!1);const P=g({char:t,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:H.$from}),U=`id_${Math.floor(Math.random()*4294967295)}`;P&&p({editor:e,state:D,range:P.range,isActive:E.active})&&(!y||y({editor:e,range:P.range,query:P.query,text:P.text,transaction:v}))?(N.active=!0,N.decorationId=E.decorationId?E.decorationId:U,N.range=P.range,N.query=P.query,N.text=P.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(v,E){var M,D,j,_;const{active:H,range:B}=S.getState(v.state);if(!H)return!1;if(E.key==="Escape"||E.key==="Esc"){const N=S.getState(v.state),z=(M=x?.decorationNode)!=null?M:null,P=z??(N?.decorationId?v.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null);if(((D=b?.onKeyDown)==null?void 0:D.call(b,{view:v,event:E,range:N.range}))||!1)return!0;const Q={editor:e,range:N.range,query:N.query,text:N.text,items:[],command:le=>u({editor:e,range:N.range,props:le}),decorationNode:P,clientRect:P?()=>P.getBoundingClientRect()||null:null};return(j=b?.onExit)==null||j.call(b,Q),w(v,n),!0}return((_=b?.onKeyDown)==null?void 0:_.call(b,{view:v,event:E,range:B}))||!1},decorations(v){const{active:E,range:M,decorationId:D,query:j}=S.getState(v);if(!E)return null;const _=!j?.length,H=[a];return _&&H.push(d),te.create(v.doc,[ve.inline(M.from,M.to,{nodeName:l,class:H.join(" "),"data-decoration-id":D,"data-decoration-content":c})])}}});return S}function dw({editor:n,overrideSuggestionOptions:e,extensionName:t,char:r="@"}){const s=new ae;return{editor:n,char:r,pluginKey:s,command:({editor:o,range:i,props:l})=>{var a,c,d;const u=o.view.state.selection.$to.nodeAfter;(a=u?.text)!=null&&a.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:t,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(d=(c=o.view.dom.ownerDocument.defaultView)==null?void 0:c.getSelection())==null||d.collapseToEnd()},allow:({state:o,range:i})=>{const l=o.doc.resolve(i.from),a=o.schema.nodes[t];return!!l.parent.type.contentMatch.matchType(a)},...e}}function Jf(n){return(n.options.suggestions.length?n.options.suggestions:[n.options.suggestion]).map(e=>dw({editor:n.editor,overrideSuggestionOptions:e,extensionName:n.name,char:e.char}))}function Mc(n,e){const t=Jf(n),r=t.find(s=>s.char===e);return r||(t.length?t[0]:null)}var uw=Ie.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:n,suggestion:e}){var t,r;return`${(t=e?.char)!=null?t:"@"}${(r=n.attrs.label)!=null?r:n.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:n,node:e,suggestion:t}){var r,s;return["span",ne(this.HTMLAttributes,n.HTMLAttributes),`${(r=t?.char)!=null?r:"@"}${(s=e.attrs.label)!=null?s:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:n=>n.getAttribute("data-mention-suggestion-char"),renderHTML:n=>({"data-mention-suggestion-char":n.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){const t=Mc(this,n.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n,suggestion:t})];const r={...this.options};r.HTMLAttributes=ne({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:n,suggestion:t});return typeof s=="string"?["span",ne({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...xf({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:n=>{const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,s,o,i]=r,l=o??i;e[s==="char"?"mentionSuggestionChar":s]=l,r=t.exec(n)}return e},serializeAttributes:n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e==="mentionSuggestionChar"?"char":e}="${t}"`).join(" ")}),renderText({node:n}){const e={options:this.options,node:n,suggestion:Mc(this,n.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1;const{selection:r}=e,{empty:s,anchor:o}=r;if(!s)return!1;let i=new ze,l=0;return e.doc.nodesBetween(o-1,o,(a,c)=>{if(a.type.name===this.name)return t=!0,i=a,l=c,!1}),t&&n.insertText(this.options.deleteTriggerWithBackspace?"":i.attrs.mentionSuggestionChar,l,l+i.nodeSize),t})}},addProseMirrorPlugins(){return Jf(this).map(cw)}}),fw=uw,Vo,Qs="HoverCard",[Gf]=Mi(Qs,[jc]),Zs=jc(),[hw,eo]=Gf(Qs),Xf=n=>{const{__scopeHoverCard:e,children:t,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=n,a=Zs(e),c=A.useRef(0),d=A.useRef(0),u=A.useRef(!1),f=A.useRef(!1),[h,p]=js({prop:r,defaultProp:s??!1,onChange:o,caller:Qs}),g=A.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>p(!0),i)},[i,p]),y=A.useCallback(()=>{clearTimeout(c.current),!u.current&&!f.current&&(d.current=window.setTimeout(()=>p(!1),l))},[l,p]),x=A.useCallback(()=>p(!1),[p]);return A.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),m.jsx(hw,{scope:e,open:h,onOpenChange:p,onOpen:g,onClose:y,onDismiss:x,hasSelectionRef:u,isPointerDownOnContentRef:f,children:m.jsx(jh,{...a,children:t})})};Xf.displayName=Qs;var Yf="HoverCardTrigger",Qf=A.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=eo(Yf,t),o=Zs(t);return m.jsx(Ih,{asChild:!0,...o,children:m.jsx(Mn.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:He(n.onPointerEnter,Is(s.onOpen)),onPointerLeave:He(n.onPointerLeave,Is(s.onClose)),onFocus:He(n.onFocus,s.onOpen),onBlur:He(n.onBlur,s.onClose),onTouchStart:He(n.onTouchStart,i=>i.preventDefault())})})});Qf.displayName=Yf;var Ll="HoverCardPortal",[pw,mw]=Gf(Ll,{forceMount:void 0}),Zf=n=>{const{__scopeHoverCard:e,forceMount:t,children:r,container:s}=n,o=eo(Ll,e);return m.jsx(pw,{scope:e,forceMount:t,children:m.jsx(Ai,{present:t||o.open,children:m.jsx(Rh,{asChild:!0,container:s,children:r})})})};Zf.displayName=Ll;var Os="HoverCardContent",eh=A.forwardRef((n,e)=>{const t=mw(Os,n.__scopeHoverCard),{forceMount:r=t.forceMount,...s}=n,o=eo(Os,n.__scopeHoverCard);return m.jsx(Ai,{present:r||o.open,children:m.jsx(gw,{"data-state":o.open?"open":"closed",...s,onPointerEnter:He(n.onPointerEnter,Is(o.onOpen)),onPointerLeave:He(n.onPointerLeave,Is(o.onClose)),ref:e})})});eh.displayName=Os;var gw=A.forwardRef((n,e)=>{const{__scopeHoverCard:t,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=n,a=eo(Os,t),c=Zs(t),d=A.useRef(null),u=Oi(e,d),[f,h]=A.useState(!1);return A.useEffect(()=>{if(f){const p=document.body;return Vo=p.style.userSelect||p.style.webkitUserSelect,p.style.userSelect="none",p.style.webkitUserSelect="none",()=>{p.style.userSelect=Vo,p.style.webkitUserSelect=Vo}}},[f]),A.useEffect(()=>{if(d.current){const p=()=>{h(!1),a.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(a.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",p),()=>{document.removeEventListener("pointerup",p),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!1}}},[a.isPointerDownOnContentRef,a.hasSelectionRef]),A.useEffect(()=>{d.current&&bw(d.current).forEach(g=>g.setAttribute("tabindex","-1"))}),m.jsx(Dh,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:He(o,p=>{p.preventDefault()}),onDismiss:a.onDismiss,children:m.jsx(Ph,{...c,...l,onPointerDown:He(l.onPointerDown,p=>{p.currentTarget.contains(p.target)&&h(!0),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!0}),ref:u,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),yw="HoverCardArrow",xw=A.forwardRef((n,e)=>{const{__scopeHoverCard:t,...r}=n,s=Zs(t);return m.jsx(Lh,{...s,...r,ref:e})});xw.displayName=yw;function Is(n){return e=>e.pointerType==="touch"?void 0:n()}function bw(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)e.push(t.currentNode);return e}var kw=Xf,ww=Qf,Sw=Zf,vw=eh;function Cw(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(kw,{"data-slot":"hover-card",...t}),e[2]=t,e[3]=r):r=e[3],r}function Nw(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(ww,{"data-slot":"hover-card-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function Ew(n){const e=I.c(12);let t,r,s,o;e[0]!==n?({className:t,align:s,sideOffset:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"center":s,l=o===void 0?4:o;let a;e[5]!==t?(a=J("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),e[5]=t,e[6]=a):a=e[6];let c;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==a?(c=m.jsx(Sw,{"data-slot":"hover-card-portal",children:m.jsx(vw,{"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 th=A.createContext(void 0);function Tw(n,e){const t=e.split("."),r=t[0];if(!r)return;let s=n[r];for(let o=1;o<t.length&&s!==void 0;o++){const i=t[o];if(i)if(typeof s=="object"&&s!==null)s=s[i];else return}return s}function Mw(n){const e=I.c(20),{node:t}=n,r=A.useContext(th),s=t.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const g=o?Tw(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=m.jsxs("span",{className:"bg-primary/20 text-primary px-1 rounded font-medium cursor-pointer",children:["@",s]}),e[4]=s,e[5]=a):a=e[5];const c=a;if(!o||l===void 0){let g;return e[6]!==c?(g=m.jsx(dc,{as:"span",children:c}),e[6]=c,e[7]=g):g=e[7],g}let d;e[8]!==c?(d=m.jsx(Nw,{asChild:!0,children:c}),e[8]=c,e[9]=d):d=e[9];let u;e[10]!==s?(u=m.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["@",s]}),e[10]=s,e[11]=u):u=e[11];let f;e[12]!==l?(f=m.jsx("pre",{className:"text-xs font-mono bg-muted/50 p-2 rounded overflow-auto max-h-[200px] whitespace-pre-wrap break-all",children:l}),e[12]=l,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==f?(h=m.jsx(Ew,{className:"w-auto max-w-[400px] p-3",side:"top",align:"start",children:m.jsxs("div",{className:"space-y-1.5",children:[u,f]})}),e[14]=u,e[15]=f,e[16]=h):h=e[16];let p;return e[17]!==d||e[18]!==h?(p=m.jsx(dc,{as:"span",children:m.jsxs(Cw,{openDelay:200,children:[d,h]})}),e[17]=d,e[18]=h,e[19]=p):p=e[19],p}function nh(n){const e=[];function t(r){for(const s of r)s.children?.length||e.push(s),s.children&&t(s.children)}return t(n),e}let Je=rh();function rh(){return Gi(()=>({items:[],selectedIndex:0,command:null}))}function Ac(n,e){Je.setState({items:n,command:e,selectedIndex:0})}function Aw(){const{items:n,selectedIndex:e}=Je.getState();n.length&&Je.setState({selectedIndex:(e-1+n.length)%n.length})}function Ow(){const{items:n,selectedIndex:e}=Je.getState();n.length&&Je.setState({selectedIndex:(e+1)%n.length})}function sh(){const{items:n,selectedIndex:e,command:t}=Je.getState(),r=n[e];return r?(t?.(r),!0):!1}function Oc(){Je=rh()}function Iw(){const n=I.c(7),e=Ko(Je,jw),t=Ko(Je,Rw);if(!e.length)return null;let r;if(n[0]!==e||n[1]!==t){let o;n[3]!==t?(o=(i,l)=>m.jsx("button",{type:"button",onClick:()=>{Je.setState({selectedIndex:l}),sh()},className:J("flex items-center w-full text-left px-3 py-1.5 text-sm rounded-md transition-colors",l===t?"bg-accent text-accent-foreground":"hover:bg-muted"),children:i.label},i.id),n[3]=t,n[4]=o):o=n[4],r=e.map(o),n[0]=e,n[1]=t,n[2]=r}else r=n[2];let s;return n[5]!==r?(s=m.jsx("div",{className:"bg-popover border border-border rounded-lg shadow-lg overflow-hidden min-w-[180px]",children:m.jsx("div",{className:"p-1",children:r})}),n[5]=r,n[6]=s):s=n[6],s}function Rw(n){return n.selectedIndex}function jw(n){return n.items}function Dw(){let n=null,e=null;return{onStart:t=>{Ac(t.items,t.command),n=new Sf(Iw,{editor:t.editor}),e=document.createElement("div"),e.style.cssText="position:absolute;z-index:9999";const r=t.clientRect?.();r&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`),e.appendChild(n.element),document.body.appendChild(e)},onUpdate:t=>{Ac(t.items,t.command);const r=t.clientRect?.();r&&e&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`)},onKeyDown:({event:t})=>t.key==="Escape"?(e?.remove(),n?.destroy(),Oc(),!0):t.key==="ArrowUp"?(Aw(),!0):t.key==="ArrowDown"?(Ow(),!0):t.key==="Enter"?sh():!1,onExit:()=>{e?.remove(),n?.destroy(),Oc()}}}const Wo=/@([\w.]+)/g;function Pw(n,e){if(!n)return null;const t=nh(e),r=new Map(t.map(a=>[a.id,a]));if(!Wo.test(n))return n;Wo.lastIndex=0;const o=[];let i=0,l;for(;(l=Wo.exec(n))!==null;){const a=l[1]??"",c=l.index;c>i&&o.push({type:"text",text:n.slice(i,c)});const d=r.get(a);d?o.push({type:"mention",attrs:{id:d.id,label:d.label}}):o.push({type:"text",text:l[0]}),i=c+l[0].length}return i<n.length&&o.push({type:"text",text:n.slice(i)}),{type:"doc",content:[{type:"paragraph",content:o.length>0?o:void 0}]}}function $l(n){const e=I.c(31),{mentions:t,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=n,a=Zm();let c;e[0]!==t||e[1]!==r?(c=Pw(r,t),e[0]=t,e[1]=r,e[2]=c):c=e[2];const d=c,u=a!==void 0,f=!l;let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=iw.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let p;if(e[4]!==t||e[5]!==u){let M;e[7]!==t?(M=D=>{const{query:j}=D;return nh(t).filter(H=>H.label.toLowerCase().includes(j.toLowerCase())||H.id.toLowerCase().includes(j.toLowerCase()))},e[7]=t,e[8]=M):M=e[8],p=fw.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:_w,renderHTML:zw,suggestion:{items:M,render:Dw,command:$w}}).extend(u?{addNodeView(){return Nb(Mw)}}:{}),e[4]=t,e[5]=u,e[6]=p}else p=e[6];let g;e[9]!==p?(g=[h,p],e[9]=p,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:Lw},e[11]=y,e[12]=x):x=e[12];let b;e[13]!==s?(b=M=>{const{editor:D}=M;return s?.(D.getText().trim())},e[13]=s,e[14]=b):b=e[14];let k;e[15]!==d||e[16]!==f||e[17]!==g||e[18]!==x||e[19]!==b?(k={content:d,editable:f,extensions:g,editorProps:x,onUpdate:b},e[15]=d,e[16]=f,e[17]=g,e[18]=x,e[19]=b,e[20]=k):k=e[20];const C=xb(k);let w;e[21]!==i?(w=J("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 S;e[23]!==C?(S=m.jsx(ub,{editor:C}),e[23]=C,e[24]=S):S=e[24];let v;e[25]!==w||e[26]!==S?(v=m.jsx("div",{className:w,children:S}),e[25]=w,e[26]=S,e[27]=v):v=e[27];const E=v;if(a!==void 0){let M;return e[28]!==E||e[29]!==a?(M=m.jsx(th.Provider,{value:a,children:E}),e[28]=E,e[29]=a,e[30]=M):M=e[30],M}return E}function Lw(n,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function $w(n){const{editor:e,range:t,props:r}=n;e.chain().focus().insertContentAt(t,[{type:"mention",attrs:r}]).run()}function zw(n){const{options:e,node:t}=n;return["span",e.HTMLAttributes,`@${t.attrs.id}`]}function _w(n){const{node:e}=n;return`@${e.attrs.id}`}function Bw(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=dd(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx($l,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function Fw(n){const e=I.c(8),{value:t,onChange:r,placeholder:s,readonly:o}=n,i=dd(),l=t??"";let a;e[0]!==r?(a=u=>r(u),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let d;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(d=m.jsx($l,{mentions:i,value:l,onChange:a,placeholder:c,readOnly:o,className:"min-h-[80px]"}),e[2]=i,e[3]=o,e[4]=l,e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function Hw(n){const e=I.c(8),{value:t,onChange:r,readonly:s,id:o}=n,i=t??"";let l;e[0]!==r?(l=d=>r(d.target.value===""?void 0:Number(d.target.value)),e[0]=r,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=J("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),e[2]=a):a=e[2];let c;return e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==l?(c=m.jsx("input",{id:o,type:"number",value:i,onChange:l,disabled:s,className:a}),e[3]=o,e[4]=s,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function Vw(n){const e=I.c(13),{value:t,onChange:r,readonly:s,id:o,label:i}=n,l=t??!1;let a;e[0]!==r?(a=f=>r(f.target.checked),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==o||e[3]!==s||e[4]!==l||e[5]!==a?(c=m.jsx("input",{id:o,type:"checkbox",checked:l,onChange:a,disabled:s,className:"h-4 w-4 rounded border-input"}),e[2]=o,e[3]=s,e[4]=l,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==i?(d=m.jsx("span",{className:"text-sm",children:i}),e[7]=i,e[8]=d):d=e[8];let u;return e[9]!==o||e[10]!==c||e[11]!==d?(u=m.jsxs("label",{htmlFor:o,className:"flex items-center gap-2 cursor-pointer",children:[c,d]}),e[9]=o,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function Ww(n){const e=I.c(14),{value:t,onChange:r,readonly:s,id:o,options:i}=n;let l;e[0]!==i.enumOptions?(l=i.enumOptions??[],e[0]=i.enumOptions,e[1]=l):l=e[1];const a=l,c=t??"";let d;e[2]!==r?(d=g=>r(g.target.value),e[2]=r,e[3]=d):d=e[3];let u,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=J("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),f=m.jsx("option",{value:"",children:"Select..."}),e[4]=u,e[5]=f):(u=e[4],f=e[5]);let h;e[6]!==a?(h=a.map(qw),e[6]=a,e[7]=h):h=e[7];let p;return e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==d||e[12]!==h?(p=m.jsxs("select",{id:o,value:c,onChange:d,disabled:s,className:u,children:[f,h]}),e[8]=o,e[9]=s,e[10]=c,e[11]=d,e[12]=h,e[13]=p):p=e[13],p}function qw(n){return m.jsx("option",{value:String(n.value),children:String(n.label)},String(n.value))}const Uw={TextWidget:Bw,TextareaWidget:Fw,NumberWidget:Hw,CheckboxWidget:Vw,SelectWidget:Ww};function Kw(n){switch(Array.isArray(n)?n[0]:n??"unknown"){case"string":return{Icon:Jc,color:"text-blue-500"};case"number":case"integer":return{Icon:Uc,color:"text-blue-500"};case"array":return{Icon:Hc,color:"text-purple-500"};case"object":return{Icon:Fc,color:"text-orange-500"};case"boolean":return{Icon:Kc,color:"text-pink-500"};case"null":return{Icon:Ii,color:"text-gray-500"};default:return{Icon:qc,color:"text-muted-foreground"}}}function Jw(n){const e=I.c(36),{id:t,label:r,required:s,description:o,children:i,schema:l,hidden:a}=n;if(a){let w;return e[0]!==i?(w=m.jsx("div",{className:"hidden",children:i}),e[0]=i,e[1]=w):w=e[1],w}if(t==="root"){let w;return e[2]!==i?(w=m.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 d,u,f,h,p,g,y;if(e[4]!==t||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:w,color:S}=Kw(c);y="space-y-2",h="flex items-center gap-2",e[15]!==t||e[16]!==r?(p=m.jsx("label",{htmlFor:t,className:"text-sm font-medium leading-none",children:r}),e[15]=t,e[16]=r,e[17]=p):p=e[17],e[18]!==s?(g=s&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"}),e[18]=s,e[19]=g):g=e[19],d=w,u=14,f=J(S,"ml-auto"),e[4]=t,e[5]=r,e[6]=s,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=h,e[12]=p,e[13]=g,e[14]=y}else d=e[8],u=e[9],f=e[10],h=e[11],p=e[12],g=e[13],y=e[14];let x;e[20]!==d||e[21]!==u||e[22]!==f?(x=m.jsx(d,{size:u,className:f}),e[20]=d,e[21]=u,e[22]=f,e[23]=x):x=e[23];let b;e[24]!==h||e[25]!==p||e[26]!==g||e[27]!==x?(b=m.jsxs("div",{className:h,children:[p,g,x]}),e[24]=h,e[25]=p,e[26]=g,e[27]=x,e[28]=b):b=e[28];let k;e[29]!==o?(k=o&&m.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=k):k=e[30];let C;return e[31]!==i||e[32]!==y||e[33]!==b||e[34]!==k?(C=m.jsxs("div",{className:y,children:[b,k,i]}),e[31]=i,e[32]=y,e[33]=b,e[34]=k,e[35]=C):C=e[35],C}function Gw(n){const e=I.c(8),{properties:t,title:r}=n;if(!r||r==="Root"){let l;e[0]!==t?(l=t.map(Yw),e[0]=t,e[1]=l):l=e[1];let a;return e[2]!==l?(a=m.jsx("div",{className:"space-y-4",children:l}),e[2]=l,e[3]=a):a=e[3],a}let o;e[4]!==t?(o=t.map(Xw),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==o?(i=m.jsx("div",{className:"pl-4 border-l-2 border-border/50 space-y-4",children:o}),e[6]=o,e[7]=i):i=e[7],i}function Xw(n){return m.jsx("div",{children:n.content},n.name)}function Yw(n){return m.jsx("div",{children:n.content},n.name)}function Qw(n){const e=I.c(11),{items:t,canAdd:r,onAddClick:s,title:o}=n;let i;e[0]!==t?(i=t.map(Zw),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=m.jsx("div",{className:"space-y-2",children:i}),e[2]=i,e[3]=l):l=e[3];let a;e[4]!==r||e[5]!==s||e[6]!==o?(a=r&&m.jsxs(me,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:s,children:["+ Add ",o||"item"]}),e[4]=r,e[5]=s,e[6]=o,e[7]=a):a=e[7];let c;return e[8]!==l||e[9]!==a?(c=m.jsxs("div",{className:"space-y-2",children:[l,a]}),e[8]=l,e[9]=a,e[10]=c):c=e[10],c}function Zw(n){return m.jsx("div",{className:"flex gap-2 items-start",children:m.jsx("div",{className:"flex-1",children:n})},n.key||n.index)}function eS(){return null}function tS(){return null}const nS={FieldTemplate:Jw,ObjectFieldTemplate:Gw,ArrayFieldTemplate:Qw,UnsupportedFieldTemplate:eS,ErrorListTemplate:tS};function rS(n){const e=I.c(6),{inputSchema:t,inputParams:r,mentions:s}=n;if(!t?.properties||!r)return null;let o;e[0]!==s?(o=(a,c,d)=>{const u=typeof c=="object"&&c!==null?JSON.stringify(c,null,2):String(c??""),f=Array.isArray(d.type)?d.type.join(" | "):d.type??"string";return m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),m.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:f})]}),d.description&&m.jsx("div",{className:"text-xs text-muted-foreground",children:d.description}),m.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:m.jsx($l,{mentions:s,value:u,readOnly:!0,className:"border-0 bg-transparent p-0"})})]},a)},e[0]=s,e[1]=o):o=e[1];const i=o;let l;return e[2]!==r||e[3]!==t.properties||e[4]!==i?(l=m.jsx("div",{className:"space-y-4",children:Object.entries(t.properties).map(a=>{const[c,d]=a,u=r[c];return i(c,u,d)})}),e[2]=r,e[3]=t.properties,e[4]=i,e[5]=l):l=e[5],l}function oh({inputSchema:n,inputParams:e,setInputParams:t,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!n)return m.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return m.jsx(rS,{inputSchema:n,inputParams:e,mentions:i});const l=n,a=A.useRef(e??{}),c=d=>{const u=d.formData??{},f=a.current;if(t?.(u),r){for(const[h,p]of Object.entries(u))f[h]!==p&&r(h,p);for(const h of Object.keys(f))h in u||r(h,void 0)}a.current=u};return m.jsx(cd.Provider,{value:i,children:m.jsx(np,{schema:l,formData:e,onChange:c,validator:rp,widgets:Uw,templates:nS,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:m.jsx(m.Fragment,{})})})}function sS(n){const e=I.c(33),{open:t,onOpenChange:r,inputSchema:s,onSubmit:o,isPending:i}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[a,c]=A.useState(l);let d;e[1]!==a||e[2]!==r||e[3]!==o?(d=async()=>{await o(a),r(!1),c({})},e[1]=a,e[2]=r,e[3]=o,e[4]=d):d=e[4];const u=d;let f;e[5]!==r?(f=E=>{E||c({}),r(E)},e[5]=r,e[6]=f):f=e[6];const h=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsxs(pp,{children:[m.jsx(mp,{children:"Workflow Input"}),m.jsx(gp,{children:"This workflow requires input values to run. Fill in the fields below to start the execution."})]}),e[7]=p):p=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=m.jsx("div",{className:"py-4",children:m.jsx(oh,{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=m.jsx(me,{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?m.jsx(Ls,{size:"xs"}):m.jsx(Fi,{size:14}),e[17]=i,e[18]=k):k=e[18];let C;e[19]!==u||e[20]!==i||e[21]!==k?(C=m.jsxs(me,{onClick:u,disabled:i,className:"gap-2",children:[k,"Run Workflow"]}),e[19]=u,e[20]=i,e[21]=k,e[22]=C):C=e[22];let w;e[23]!==C||e[24]!==b?(w=m.jsxs(yp,{children:[b,C]}),e[23]=C,e[24]=b,e[25]=w):w=e[25];let S;e[26]!==w||e[27]!==y?(S=m.jsxs(xp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[p,y,w]}),e[26]=w,e[27]=y,e[28]=S):S=e[28];let v;return e[29]!==h||e[30]!==t||e[31]!==S?(v=m.jsx(bp,{open:t,onOpenChange:h,children:S}),e[29]=h,e[30]=t,e[31]=S,e[32]=v):v=e[32],v}function oS(n){const e=I.c(26),{title:t,description:r,onSave:s}=n,i=Ti().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:d}=Xi(),{resetToOriginalWorkflow:u,setSelectedGatewayId:f}=Me(),h=ld(),p=In(),g=we();let y;e[0]!==t?(y=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t}),e[0]=t,e[1]=y):y=e[1];let x;e[2]!==r?(x=r?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:r})]}):null,e[2]=r,e[3]=x):x=e[3];let b;e[4]!==y||e[5]!==x?(b=m.jsx(_c,{children:m.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]!==u||e[10]!==p||e[11]!==f||e[12]!==a||e[13]!==c||e[14]!==t||e[15]!==d||e[16]!==g||e[17]!==i||e[18]!==l?(k=!g&&m.jsxs(m.Fragment,{children:[m.jsx(Pi,{title:t,url:i,icon:"workflow"}),m.jsx(A.Suspense,{fallback:m.jsx(Ls,{size:"xs"}),children:m.jsx(ap,{selectedGatewayId:p??void 0,onGatewayChange:f,variant:"bordered",placeholder:"Select Hub"})}),m.jsx(up,{value:l,onValueChange:a,size:"sm",options:[{value:"visual",icon:m.jsx(fp,{})},{value:"code",icon:m.jsx(Yc,{})}]}),m.jsx($t,{children:m.jsxs(zt,{delayDuration:0,children:[m.jsx(Pt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:u,disabled:!h,"aria-label":"Reset changes",children:m.jsx(zc,{size:14})})})}),m.jsx(Lt,{side:"bottom",children:"Reset changes"})]})}),m.jsx($t,{children:m.jsxs(zt,{delayDuration:0,children:[m.jsx(Pt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:!h,"aria-label":"Save workflow",children:m.jsx(Ji,{size:14})})})}),m.jsx(Lt,{side:"bottom",children:"Save workflow"})]})}),m.jsx($t,{children:m.jsxs(zt,{delayDuration:0,children:[m.jsx(Pt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:c?"secondary":"outline",size:"icon",className:"size-7 border border-input",onClick:d,"aria-label":c?"Hide runs":"Show runs",children:m.jsx(Xc,{size:14})})})}),m.jsx(Lt,{side:"bottom",children:c?"Hide runs":"Show runs"})]})})]}),e[7]=h,e[8]=s,e[9]=u,e[10]=p,e[11]=f,e[12]=a,e[13]=c,e[14]=t,e[15]=d,e[16]=g,e[17]=i,e[18]=l,e[19]=k):k=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=m.jsx(aS,{}),e[20]=C):C=e[20];let w;e[21]!==k?(w=m.jsxs(Bi,{children:[k,C]}),e[21]=k,e[22]=w):w=e[22];let S;return e[23]!==b||e[24]!==w?(S=m.jsxs(m.Fragment,{children:[b,w]}),e[23]=b,e[24]=w,e[25]=S):S=e[25],S}function iS(){const n=we(),{item:e}=pr(n);return e?.completed_at_epoch_ms!=null}function lS(){const n=we(),{item:e}=pr(n);return e?.status==="cancelled"}function aS(){const n=I.c(57),e=ld(),t=iS(),r=lS(),s=we(),o=In(),{handleRunWorkflow:i,isPending:l,requiresInput:a,inputSchema:c}=Xm(),d=hr(),[u,f]=A.useState(!1),{handleCancelWorkflow:h,isCancelling:p}=Ym(),{handleResumeWorkflow:g,isResuming:y}=Qm(),x=s&&!t;let b;n[0]!==d?(b=d.some(cS),n[0]=d,n[1]=b):b=n[1];const k=b,C=!o,w=e||k||C||l||p,S=x||l;let v;n[2]!==k||n[3]!==C||n[4]!==e||n[5]!==r||n[6]!==S?(v=()=>r?"Workflow is currently cancelled":S?"Workflow is currently running":e?"Save your changes before running":C?"Select a Hub first":k?"Add at least one step to the workflow":null,n[2]=k,n[3]=C,n[4]=e,n[5]=r,n[6]=S,n[7]=v):v=n[7];const M=v();let D;n[8]!==h||n[9]!==g||n[10]!==i||n[11]!==c||n[12]!==r||n[13]!==S||n[14]!==a||n[15]!==s?(D=async()=>{if(a&&c){f(!0);return}if(r&&s){await g(s);return}if(S&&s){await h(s);return}await i({})},n[8]=h,n[9]=g,n[10]=i,n[11]=c,n[12]=r,n[13]=S,n[14]=a,n[15]=s,n[16]=D):D=n[16];const j=D;let _;n[17]!==i?(_=async Fe=>{await i(Fe)},n[17]=i,n[18]=_):_=n[18];const H=_,B=r?"Resume":s?t?"Replay":"Running...":a?"Run with input...":"Run workflow",V=!x&&"bg-primary text-primary-foreground hover:bg-primary/90";let N;n[19]!==V?(N=J("gap-2 h-7 px-3",V),n[19]=V,n[20]=N):N=n[20];let z;n[21]!==p||n[22]!==r||n[23]!==l||n[24]!==y||n[25]!==x?(z=(!x&&!l&&!p&&!y||r)&&m.jsx(Fi,{size:14}),n[21]=p,n[22]=r,n[23]=l,n[24]=y,n[25]=x,n[26]=z):z=n[26];let P;n[27]!==p||n[28]!==r||n[29]!==l||n[30]!==y||n[31]!==x?(P=x&&!l&&!p&&!y&&!r&&m.jsx(hp,{size:14}),n[27]=p,n[28]=r,n[29]=l,n[30]=y,n[31]=x,n[32]=P):P=n[32];let U;n[33]!==p||n[34]!==l||n[35]!==y?(U=(l||p||y)&&m.jsx(Ls,{size:"xs"}),n[33]=p,n[34]=l,n[35]=y,n[36]=U):U=n[36];let Q;n[37]!==B||n[38]!==j||n[39]!==w||n[40]!==N||n[41]!==z||n[42]!==P||n[43]!==U?(Q=m.jsxs(me,{variant:"default",size:"sm",className:N,disabled:w,onClick:j,children:[z,P,U,B]}),n[37]=B,n[38]=j,n[39]=w,n[40]=N,n[41]=z,n[42]=P,n[43]=U,n[44]=Q):Q=n[44];const le=Q;let X;n[45]!==le||n[46]!==M?(X=M?m.jsx($t,{children:m.jsxs(zt,{delayDuration:0,children:[m.jsx(Pt,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:le})}),m.jsx(Lt,{side:"bottom",children:M})]})}):le,n[45]=le,n[46]=M,n[47]=X):X=n[47];const fe=X;let se;n[48]!==H||n[49]!==c||n[50]!==l||n[51]!==a||n[52]!==u?(se=a&&c&&m.jsx(sS,{open:u,onOpenChange:f,inputSchema:c,onSubmit:H,isPending:l}),n[48]=H,n[49]=c,n[50]=l,n[51]=a,n[52]=u,n[53]=se):se=n[53];let K;return n[54]!==fe||n[55]!==se?(K=m.jsxs(m.Fragment,{children:[fe,se]}),n[54]=fe,n[55]=se,n[56]=K):K=n[56],K}function cS(n){return"toolName"in n.action&&(!n.action.toolName||n.action.toolName==="")}function dS(){const n=I.c(17),e=we(),t=hr(),{item:r}=pr(e);if(!e||!r)return;let s;if(n[0]!==r.completed_steps?.error||n[1]!==r.completed_steps?.success||n[2]!==r.status||n[3]!==t){s={};let o;n[5]!==r.completed_steps?.success?(o=r.completed_steps?.success??[],n[5]=r.completed_steps?.success,n[6]=o):o=n[6];let i;n[7]!==o?(i=new Set(o),n[7]=o,n[8]=i):i=n[8];const l=i;let a;n[9]!==r.completed_steps?.error?(a=r.completed_steps?.error??[],n[9]=r.completed_steps?.error,n[10]=a):a=n[10];let c;n[11]!==a?(c=new Set(a),n[11]=a,n[12]=c):c=n[12];const d=c;let u;n[13]!==d||n[14]!==t||n[15]!==l?(u=-1,t.forEach((f,h)=>{(l.has(f.name)||d.has(f.name))&&(u=h)}),n[13]=d,n[14]=t,n[15]=l,n[16]=u):u=n[16],t.forEach((f,h)=>{let p="pending";d.has(f.name)?p="error":l.has(f.name)?p="success":r.status==="running"&&h===u+1&&(p="running"),s[f.name]={status:p,output:void 0,error:void 0,stepIndex:h}}),n[0]=r.completed_steps?.error,n[1]=r.completed_steps?.success,n[2]=r.status,n[3]=t,n[4]=s}else s=n[4];return s}function uS(n){const e=I.c(119),{step:t,index:r,isSelected:s,executionStatus:o,isSkipped:i,isLastStep:l,onSelect:a,onDelete:c,onDuplicate:d}=n,u=we(),{item:f}=pr(u),h=f?.completed_at_epoch_ms;let p;e[0]!==f?.completed_steps?.success||e[1]!==t.name?(p=f?.completed_steps?.success?.includes(t.name)??!1,e[0]=f?.completed_steps?.success,e[1]=t.name,e[2]=p):p=e[2];const g=p;let y;e[3]!==f?.completed_steps?.error||e[4]!==t.name?(y=f?.completed_steps?.error?.includes(t.name)??!1,e[3]=f?.completed_steps?.error,e[4]=t.name,e[5]=y):y=e[5];const x=y,b="toolName"in t.action,k=b&&"connectionId"in t.action?t.action.connectionId:null,w=!!(b&&"toolName"in t.action?t.action.toolName:null);let S,v,E,M,D,j,_,H,B,V,N;if(e[6]!==k||e[7]!==o||e[8]!==w||e[9]!==r||e[10]!==g||e[11]!==x||e[12]!==l||e[13]!==s||e[14]!==i||e[15]!==b||e[16]!==c||e[17]!==d||e[18]!==a||e[19]!==t||e[20]!==u){const le=SS(t);S=g?"success":x?"error":o?.status;const X=o!==void 0,fe=S==="success"||S==="error";let se=le.length>0?60:12;(S==="success"||S==="error")&&(se=se+32);let K,Fe,at;if(e[32]!==s||e[33]!==i||e[34]!==a||e[35]!==S){const Dn=pS(S);let br;e[44]!==S?(br=mS(S),e[44]=S,e[45]=br):br=e[45],K=br;const io=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",lo=S==="running"&&"bg-accent/50",ao=i&&"opacity-50";e[46]!==io||e[47]!==lo||e[48]!==ao?(H=J("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",io,lo,ao),e[46]=io,e[47]=lo,e[48]=ao,e[49]=H):H=e[49],B=a,V="button",N=0,e[50]!==a?(v=co=>{(co.key==="Enter"||co.key===" ")&&(co.preventDefault(),a())},e[50]=a,e[51]=v):v=e[51],at="w-5 flex flex-col items-center justify-center shrink-0 pt-3",Fe=J("text-xs font-mono opacity-75 h-8 flex items-center",Dn),e[32]=s,e[33]=i,e[34]=a,e[35]=S,e[36]=K,e[37]=v,e[38]=Fe,e[39]=at,e[40]=H,e[41]=B,e[42]=V,e[43]=N}else K=e[36],v=e[37],Fe=e[38],at=e[39],H=e[40],B=e[41],V=e[42],N=e[43];const so=r+1;let Qt;e[52]!==Fe||e[53]!==so?(Qt=m.jsxs("span",{className:Fe,children:[so,"."]}),e[52]=Fe,e[53]=so,e[54]=Qt):Qt=e[54],e[55]!==at||e[56]!==Qt?(E=m.jsx("div",{className:at,children:Qt}),e[55]=at,e[56]=Qt,e[57]=E):E=e[57];let Zt;e[58]!==K||e[59]!==r?(Zt=r>0?m.jsx(qo,{height:12,color:K}):m.jsx("div",{className:"h-3"}),e[58]=K,e[59]=r,e[60]=Zt):Zt=e[60];let en;e[61]!==k||e[62]!==w||e[63]!==b||e[64]!==t.name?(en=m.jsx(kS,{connectionId:k,isToolStep:b,hasToolSelected:w,stepName:t.name}),e[61]=k,e[62]=w,e[63]=b,e[64]=t.name,e[65]=en):en=e[65];let tn;e[66]!==K||e[67]!==fe||e[68]!==S?(tn=fe&&m.jsxs(m.Fragment,{children:[m.jsx(qo,{height:8,color:K}),m.jsx(gS,{status:S})]}),e[66]=K,e[67]=fe,e[68]=S,e[69]=tn):tn=e[69];let nn;e[70]!==K||e[71]!==se||e[72]!==l||e[73]!==u?(nn=l&&u?null:m.jsx(qo,{height:se,color:K}),e[70]=K,e[71]=se,e[72]=l,e[73]=u,e[74]=nn):nn=e[74],e[75]!==Zt||e[76]!==en||e[77]!==tn||e[78]!==nn?(M=m.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[Zt,en,tn,nn]}),e[75]=Zt,e[76]=en,e[77]=tn,e[78]=nn,e[79]=M):M=e[79],D="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const oo=w?"font-medium text-foreground":"text-foreground";let rn;e[80]!==oo?(rn=J("text-sm truncate flex-1",oo),e[80]=oo,e[81]=rn):rn=e[81];let sn;e[82]!==t?(sn=wS(t),e[82]=t,e[83]=sn):sn=e[83];let on;e[84]!==rn||e[85]!==sn?(on=m.jsx("span",{className:rn,children:sn}),e[84]=rn,e[85]=sn,e[86]=on):on=e[86];let ln;e[87]!==X||e[88]!==S?(ln=X&&m.jsx(yS,{status:S}),e[87]=X,e[88]=S,e[89]=ln):ln=e[89];let an;e[90]!==X||e[91]!==c||e[92]!==d?(an=!X&&m.jsxs(kp,{children:[m.jsx(wp,{asChild:!0,children:m.jsx(me,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:hS,children:m.jsx(Qh,{size:14})})}),m.jsxs(Sp,{align:"end",children:[m.jsxs(Ul,{onClick:Dn=>{Dn.stopPropagation(),d()},children:[m.jsx(Cp,{size:14}),"Duplicate"]}),m.jsxs(Ul,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:Dn=>{Dn.stopPropagation(),c()},children:[m.jsx($h,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[90]=X,e[91]=c,e[92]=d,e[93]=an):an=e[93],e[94]!==on||e[95]!==ln||e[96]!==an?(j=m.jsxs("div",{className:"flex items-center h-8",children:[on,ln,an]}),e[94]=on,e[95]=ln,e[96]=an,e[97]=j):j=e[97],_=le.length>0&&m.jsx("div",{className:"flex flex-wrap gap-1.5",children:le.map(fS)}),e[6]=k,e[7]=o,e[8]=w,e[9]=r,e[10]=g,e[11]=x,e[12]=l,e[13]=s,e[14]=i,e[15]=b,e[16]=c,e[17]=d,e[18]=a,e[19]=t,e[20]=u,e[21]=S,e[22]=v,e[23]=E,e[24]=M,e[25]=D,e[26]=j,e[27]=_,e[28]=H,e[29]=B,e[30]=V,e[31]=N}else S=e[21],v=e[22],E=e[23],M=e[24],D=e[25],j=e[26],_=e[27],H=e[28],B=e[29],V=e[30],N=e[31];let z;e[98]!==h||e[99]!==S?(z=S==="success"&&m.jsx(xS,{completedAtEpochMs:h}),e[98]=h,e[99]=S,e[100]=z):z=e[100];let P;e[101]!==o?.error||e[102]!==S?(P=S==="error"&&m.jsx(bS,{error:o?.error}),e[101]=o?.error,e[102]=S,e[103]=P):P=e[103];let U;e[104]!==z||e[105]!==P||e[106]!==D||e[107]!==j||e[108]!==_?(U=m.jsxs("div",{className:D,children:[j,_,z,P]}),e[104]=z,e[105]=P,e[106]=D,e[107]=j,e[108]=_,e[109]=U):U=e[109];let Q;return e[110]!==v||e[111]!==E||e[112]!==M||e[113]!==U||e[114]!==H||e[115]!==B||e[116]!==V||e[117]!==N?(Q=m.jsxs("div",{className:H,onClick:B,role:V,tabIndex:N,onKeyDown:v,children:[E,M,U]}),e[110]=v,e[111]=E,e[112]=M,e[113]=U,e[114]=H,e[115]=B,e[116]=V,e[117]=N,e[118]=Q):Q=e[118],Q}function fS(n){return m.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:n},n)}function hS(n){return n.stopPropagation()}function pS(n){switch(n){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function mS(n){switch(n){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function gS(n){const e=I.c(2),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-success flex items-center justify-center",children:m.jsx(_i,{size:8,className:"text-success-foreground"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-destructive flex items-center justify-center",children:m.jsx(Hi,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function yS(n){const e=I.c(3),{status:t}=n;if(t==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(_i,{size:11,className:"text-success"})}),e[0]=r):r=e[0],r}if(t==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(Hi,{size:11,className:"text-destructive"})}),e[1]=r):r=e[1],r}if(t==="running"){let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(Qn,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function xS(n){const e=I.c(8),{completedAtEpochMs:t}=n;let r,s;if(e[0]!==t){const a=t!=null?new Date(t):null;r=a?a.toISOString().split("T")[0]:null,s=a?a.toTimeString().split(" ")[0]:null,e[0]=t,e[1]=r,e[2]=s}else r=e[1],s=e[2];const o=s;let i;e[3]!==r||e[4]!==o?(i=r&&o&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Xh,{size:16,className:"text-success"}),m.jsx("span",{className:"text-xs text-success",children:r}),m.jsx("span",{className:"text-xs text-success",children:o})]}),e[3]=r,e[4]=o,e[5]=i):i=e[5];let l;return e[6]!==i?(l=m.jsx("div",{className:"inline-flex items-center gap-3 px-1.5 py-1 bg-success-foreground rounded-lg w-fit",children:i}),e[6]=i,e[7]=l):l=e[7],l}function bS(n){const e=I.c(3),{error:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx(Ki,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=t||"Execution failed";let o;return e[1]!==s?(o=m.jsxs("div",{className:"inline-flex items-center gap-1.5 px-1.5 py-1 bg-destructive-foreground rounded-lg w-fit",children:[r,m.jsx("span",{className:"text-xs text-destructive",children:s})]}),e[1]=s,e[2]=o):o=e[2],o}function kS(n){const e=I.c(5),{connectionId:t,isToolStep:r,hasToolSelected:s,stepName:o}=n,i=ji(t??"");if(r&&s&&i?.icon){let a;return e[0]!==i.icon||e[1]!==o?(a=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center overflow-hidden",children:m.jsx(Ds,{icon:i.icon,name:o,size:"xs",className:"border-0 rounded-none"})}),e[0]=i.icon,e[1]=o,e[2]=a):a=e[2],a}let l;return e[3]!==r?(l=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center",children:r?m.jsx(td,{size:16,className:"text-muted-foreground"}):m.jsx(vp,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function qo(n){const e=I.c(7),{height:t,color:r}=n,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=J("w-px",s),e[0]=s,e[1]=o):o=e[1];let i;e[2]!==t?(i={height:t},e[2]=t,e[3]=i):i=e[3];let l;return e[4]!==o||e[5]!==i?(l=m.jsx("div",{className:o,style:i}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function wS(n){return n.name?n.name:"toolName"in n.action&&n.action.toolName?n.action.toolName:"code"in n.action?n.name||"Code Step":"Select tool..."}function SS(n){const e=n.outputSchema;if(!e||typeof e!="object")return[];const t=e.properties;return!t||typeof t!="object"?[]:Object.keys(t).slice(0,5)}function vS(n){const e=I.c(32),{className:t}=n,r=hr(),s=id(),o=dS(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a}=Me(),c=we();let d;e[0]!==o||e[1]!==r?(d=o?r.findIndex(k=>o[k.name]?.status==="error"):-1,e[0]=o,e[1]=r,e[2]=d):d=e[2];const u=d;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=m.jsx("div",{children:"Loading..."}),e[3]=f):f=e[3];let h;e[4]!==t?(h=J("h-full flex flex-col p-8 overflow-auto",t),e[4]=t,e[5]=h):h=e[5];let p;if(e[6]!==s||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==i||e[11]!==o||e[12]!==r){let k;e[14]!==s||e[15]!==l||e[16]!==a||e[17]!==u||e[18]!==i||e[19]!==o||e[20]!==r.length?(k=(C,w)=>{const S=o?.[C.name],v=u!==-1&&w>u&&S?.status==="pending",E=w===r.length-1;return m.jsx(uS,{step:C,index:w,isSelected:C.name===s,executionStatus:S,isSkipped:v,isLastStep:E,onSelect:()=>i(C.name),onDelete:()=>l(C.name),onDuplicate:()=>a(C.name)},C.name)},e[14]=s,e[15]=l,e[16]=a,e[17]=u,e[18]=i,e[19]=o,e[20]=r.length,e[21]=k):k=e[21],p=r.map(k),e[6]=s,e[7]=l,e[8]=a,e[9]=u,e[10]=i,e[11]=o,e[12]=r,e[13]=p}else p=e[13];let g;e[22]!==p?(g=m.jsx("div",{className:"pt-3 -space-y-1",children:p}),e[22]=p,e[23]=g):g=e[23];let y;e[24]!==c?(y=c?null:m.jsx(CS,{}),e[24]=c,e[25]=y):y=e[25];let x;e[26]!==g||e[27]!==y?(x=m.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=m.jsx(A.Suspense,{fallback:f,children:m.jsx("div",{className:h,children:x})}),e[29]=h,e[30]=x,e[31]=b):b=e[31],b}function CS(){const n=I.c(8),{addToolStep:e}=Me();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=m.jsx("div",{className:"w-5 shrink-0"}),n[0]=t):t=n[0];let r;n[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"w-px h-3 bg-border"}),n[1]=r):r=n[1];let s;n[2]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx(Ui,{size:14}),n[2]=s):s=n[2];let o;n[3]!==e?(o=m.jsx(me,{variant:"outline",size:"icon",className:"size-8 rounded-lg",onClick:e,children:s}),n[3]=e,n[4]=o):o=n[4];let i;n[5]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"w-px h-8",style:{backgroundImage:"repeating-linear-gradient(180deg, var(--border), var(--border) 4px, transparent 4px, transparent 8px)",backgroundPosition:"left top",backgroundRepeat:"repeat-y",backgroundSize:"2px 100%"}}),n[5]=i):i=n[5];let l;return n[6]!==o?(l=m.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[t,m.jsxs("div",{className:"flex flex-col border-1 border-transparent items-center shrink-0",children:[r,o,i]})]}),n[6]=o,n[7]=l):l=n[7],l}function NS(){const n=I.c(5),e=In();let t;n[0]!==e?(t=e?new URL(`/mcp/gateway/${e}`,window.location.origin).href:"",n[0]=e,n[1]=t):t=n[1];const r=t,s=!!e;let o;return n[2]!==r||n[3]!==s?(o={url:r,enabled:s},n[2]=r,n[3]=s,n[4]=o):o=n[4],Vi(o)}function ES(n){const e=I.c(7),{className:t}=n;if(!In()){let o;e[0]!==t?(o=J("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground p-4 text-center",children:"Select a gateway to see available tools"}),e[2]=i):i=e[2];let l;return e[3]!==o?(l=m.jsx("div",{className:o,children:i}),e[3]=o,e[4]=l):l=e[4],l}let s;return e[5]!==t?(s=m.jsx(TS,{className:t}),e[5]=t,e[6]=s):s=e[6],s}function TS(n){const e=I.c(38),{className:t}=n,{tools:r,isLoading:s,error:o}=NS(),i=fr(),{updateStep:l}=Me(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let d;if(e[0]!==c||e[1]!==r){let w;e[3]!==c?(w=S=>S.name===c,e[3]=c,e[4]=w):w=e[4],d=r.find(w),e[0]=c,e[1]=r,e[2]=d}else d=e[2];const f=eg(r,d??null,AS,MS);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 p=h;if(s){let w;e[8]!==t?(w=J("flex flex-col h-full bg-sidebar",t),e[8]=t,e[9]=w):w=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx("div",{className:"flex-1 flex items-center justify-center",children:m.jsx(Ls,{size:"sm"})}),e[10]=S):S=e[10];let v;return e[11]!==w?(v=m.jsx("div",{className:w,children:S}),e[11]=w,e[12]=v):v=e[12],v}if(o){let w;e[13]!==t?(w=J("flex flex-col h-full bg-sidebar",t),e[13]=t,e[14]=w):w=e[14];let S;e[15]!==o.message?(S=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-destructive p-4 text-center",children:["Failed to load tools: ",o.message]}),e[15]=o.message,e[16]=S):S=e[16];let v;return e[17]!==w||e[18]!==S?(v=m.jsx("div",{className:w,children:S}),e[17]=w,e[18]=S,e[19]=v):v=e[19],v}let g;e[20]!==t?(g=J("flex flex-col h-full bg-sidebar",t),e[20]=t,e[21]=g):g=e[21];let y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=m.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=m.jsx("div",{className:"flex items-start border-b border-border",children:m.jsxs("div",{className:"flex-1 flex items-center h-12 px-5",children:[y,m.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:["(",r.length,")"]})]})}),e[23]=r.length,e[24]=x):x=e[24];let b;if(e[25]!==p||e[26]!==f||e[27]!==c){let w;e[29]!==p||e[30]!==c?(w=S=>m.jsx(OS,{icon:null,title:S.name,description:S.description,isSelected:S.name===c,onClick:()=>p(S)},S.name),e[29]=p,e[30]=c,e[31]=w):w=e[31],b=f.map(w),e[25]=p,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let k;e[32]!==b?(k=m.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=k):k=e[33];let C;return e[34]!==g||e[35]!==x||e[36]!==k?(C=m.jsxs("div",{className:g,children:[x,k]}),e[34]=g,e[35]=x,e[36]=k,e[37]=C):C=e[37],C}function MS(n,e){return n.name.localeCompare(e.name)}function AS(n){return n.name}function OS(n){const e=I.c(20),{icon:t,title:r,description:s,isSelected:o,onClick:i}=n,l=o&&"bg-muted/50";let a;e[0]!==l?(a=J("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 d;e[4]!==t||e[5]!==r?(d=m.jsx(Ds,{icon:t,name:r,size:"xs",className:"shadow-sm mt-0.5"}),e[4]=t,e[5]=r,e[6]=d):d=e[6];let u;e[7]!==r?(u=m.jsx("span",{className:"text-sm font-medium text-foreground truncate block",children:r}),e[7]=r,e[8]=u):u=e[8];let f;e[9]!==s?(f=s&&m.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s}),e[9]=s,e[10]=f):f=e[10];let h;e[11]!==u||e[12]!==f?(h=m.jsxs("div",{className:"flex-1 min-w-0",children:[u,f]}),e[11]=u,e[12]=f,e[13]=h):h=e[13];let p;return e[14]!==i||e[15]!==a||e[16]!==c||e[17]!==d||e[18]!==h?(p=m.jsxs("div",{className:a,onClick:i,role:"button",tabIndex:0,onKeyDown:c,children:[d,h]}),e[14]=i,e[15]=a,e[16]=c,e[17]=d,e[18]=h,e[19]=p):p=e[19],p}var to="Collapsible",[IS,ih]=Mi(to),[RS,zl]=IS(to),lh=A.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=n,[a,c]=js({prop:r,defaultProp:s??!1,onChange:i,caller:to});return m.jsx(RS,{scope:t,disabled:o,contentId:Dc(),open:a,onOpenToggle:A.useCallback(()=>c(d=>!d),[c]),children:m.jsx(Mn.div,{"data-state":Bl(a),"data-disabled":o?"":void 0,...l,ref:e})})});lh.displayName=to;var ah="CollapsibleTrigger",ch=A.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=zl(ah,t);return m.jsx(Mn.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Bl(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:He(n.onClick,s.onOpenToggle)})});ch.displayName=ah;var _l="CollapsibleContent",dh=A.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=zl(_l,n.__scopeCollapsible);return m.jsx(Ai,{present:t||s.open,children:({present:o})=>m.jsx(jS,{...r,ref:e,present:o})})});dh.displayName=_l;var jS=A.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...o}=n,i=zl(_l,t),[l,a]=A.useState(r),c=A.useRef(null),d=Oi(e,c),u=A.useRef(0),f=u.current,h=A.useRef(0),p=h.current,g=i.open||l,y=A.useRef(g),x=A.useRef(void 0);return A.useEffect(()=>{const b=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(b)},[]),zh(()=>{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();u.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]),m.jsx(Mn.div,{"data-state":Bl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":p?`${p}px`:void 0,...n.style},children:g&&s})});function Bl(n){return n?"open":"closed"}var DS=lh,PS=ch,LS=dh,qe="Accordion",$S=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Fl,zS,_S]=_h(qe),[no]=Mi(qe,[_S,ih]),Hl=ih(),uh=ee.forwardRef((n,e)=>{const{type:t,...r}=n,s=r,o=r;return m.jsx(Fl.Provider,{scope:n.__scopeAccordion,children:t==="multiple"?m.jsx(VS,{...o,ref:e}):m.jsx(HS,{...s,ref:e})})});uh.displayName=qe;var[fh,BS]=no(qe),[hh,FS]=no(qe,{collapsible:!1}),HS=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=n,[l,a]=js({prop:t,defaultProp:r??"",onChange:s,caller:qe});return m.jsx(fh,{scope:n.__scopeAccordion,value:ee.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:ee.useCallback(()=>o&&a(""),[o,a]),children:m.jsx(hh,{scope:n.__scopeAccordion,collapsible:o,children:m.jsx(ph,{...i,ref:e})})})}),VS=ee.forwardRef((n,e)=>{const{value:t,defaultValue:r,onValueChange:s=()=>{},...o}=n,[i,l]=js({prop:t,defaultProp:r??[],onChange:s,caller:qe}),a=ee.useCallback(d=>l((u=[])=>[...u,d]),[l]),c=ee.useCallback(d=>l((u=[])=>u.filter(f=>f!==d)),[l]);return m.jsx(fh,{scope:n.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:m.jsx(hh,{scope:n.__scopeAccordion,collapsible:!0,children:m.jsx(ph,{...o,ref:e})})})}),[WS,ro]=no(qe),ph=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,disabled:r,dir:s,orientation:o="vertical",...i}=n,l=ee.useRef(null),a=Oi(l,e),c=zS(t),u=Bh(s)==="ltr",f=He(n.onKeyDown,h=>{if(!$S.includes(h.key))return;const p=h.target,g=c().filter(E=>!E.ref.current?.disabled),y=g.findIndex(E=>E.ref.current===p),x=g.length;if(y===-1)return;h.preventDefault();let b=y;const k=0,C=x-1,w=()=>{b=y+1,b>C&&(b=k)},S=()=>{b=y-1,b<k&&(b=C)};switch(h.key){case"Home":b=k;break;case"End":b=C;break;case"ArrowRight":o==="horizontal"&&(u?w():S());break;case"ArrowDown":o==="vertical"&&w();break;case"ArrowLeft":o==="horizontal"&&(u?S():w());break;case"ArrowUp":o==="vertical"&&S();break}const v=b%x;g[v].ref.current?.focus()});return m.jsx(WS,{scope:t,disabled:r,direction:s,orientation:o,children:m.jsx(Fl.Slot,{scope:t,children:m.jsx(Mn.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),Rs="AccordionItem",[qS,Vl]=no(Rs),mh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,value:r,...s}=n,o=ro(Rs,t),i=BS(Rs,t),l=Hl(t),a=Dc(),c=r&&i.value.includes(r)||!1,d=o.disabled||n.disabled;return m.jsx(qS,{scope:t,open:c,disabled:d,triggerId:a,children:m.jsx(DS,{"data-orientation":o.orientation,"data-state":wh(c),...l,...s,ref:e,disabled:d,open:c,onOpenChange:u=>{u?i.onItemOpen(r):i.onItemClose(r)}})})});mh.displayName=Rs;var gh="AccordionHeader",yh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=ro(qe,t),o=Vl(gh,t);return m.jsx(Mn.h3,{"data-orientation":s.orientation,"data-state":wh(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});yh.displayName=gh;var Ei="AccordionTrigger",xh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=ro(qe,t),o=Vl(Ei,t),i=FS(Ei,t),l=Hl(t);return m.jsx(Fl.ItemSlot,{scope:t,children:m.jsx(PS,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});xh.displayName=Ei;var bh="AccordionContent",kh=ee.forwardRef((n,e)=>{const{__scopeAccordion:t,...r}=n,s=ro(qe,t),o=Vl(bh,t),i=Hl(t);return m.jsx(LS,{role:"region","aria-labelledby":o.triggerId,"data-orientation":s.orientation,...i,...r,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...n.style}})});kh.displayName=bh;function wh(n){return n?"open":"closed"}var US=uh,KS=mh,JS=yh,GS=xh,XS=kh;function YS(n){const e=I.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=m.jsx(US,{"data-slot":"accordion",...t}),e[2]=t,e[3]=r):r=e[3],r}function QS(n){const e=I.c(8);let t,r;e[0]!==n?({className:t,...r}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t?(s=J("border-b last:border-b-0",t),e[3]=t,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=m.jsx(KS,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function ZS(n){const e=I.c(11);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=J("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(Uh,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==s||e[9]!==o?(l=m.jsx(JS,{className:"flex",children:m.jsxs(GS,{"data-slot":"accordion-trigger",className:o,...s,children:[t,i]})}),e[7]=t,e[8]=s,e[9]=o,e[10]=l):l=e[10],l}function ev(n){const e=I.c(12);let t,r,s;e[0]!==n?({className:r,children:t,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=J("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==t||e[7]!==o?(i=m.jsx("div",{className:o,children:t}),e[6]=t,e[7]=o,e[8]=i):i=e[8];let l;return e[9]!==s||e[10]!==i?(l=m.jsx(XS,{"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 tv=(n,e,t,r,s,o,i,l)=>{let a=document.documentElement,c=["light","dark"];function d(h){(Array.isArray(n)?n:[n]).forEach(p=>{let g=p==="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(p,h)}),u(h)}function u(h){l&&c.includes(h)&&(a.style.colorScheme=h)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let h=localStorage.getItem(e)||t,p=i&&h==="system"?f():h;d(p)}catch{}};A.createContext(void 0);A.memo(({forcedTheme:n,storageKey:e,attribute:t,enableSystem:r,enableColorScheme:s,defaultTheme:o,value:i,themes:l,nonce:a,scriptProps:c})=>{let d=JSON.stringify([t,e,o,n,l,i,r,s]).slice(1,-1);return A.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?a:"",dangerouslySetInnerHTML:{__html:`(${tv.toString()})(${d})`}})});function nv(n){const{updateStep:e}=Me(),r=n&&"toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,{tool:s}=Wl(r??"");n&&r&&s?.outputSchema&&(!n.outputSchema||Object.keys(n.outputSchema).length===0)&&queueMicrotask(()=>{e(n.name,{outputSchema:s.outputSchema})})}function rv(n){const e=I.c(25),{className:t}=n,r=fr(),{appendStep:s}=Me();if(nv(r),!r){let f;e[0]!==t?(f=J("flex flex-col h-full bg-sidebar",t),e[0]=t,e[1]=f):f=e[1];let h;e[2]!==s?(h=()=>{s({type:"tool"})},e[2]=s,e[3]=h):h=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Ui,{size:14}),e[4]=p):p=e[4];let g;e[5]!==h?(g=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground gap-2 flex-col",children:["Select or create a step to configure",m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:h,children:p})]}),e[5]=h,e[6]=g):g=e[6];let y;return e[7]!==f||e[8]!==g?(y=m.jsx("div",{className:f,children:g}),e[7]=f,e[8]=g,e[9]=y):y=e[9],y}let o;e[10]!==t?(o=J("flex flex-col h-full bg-sidebar overflow-hidden",t),e[10]=t,e[11]=o):o=e[11];let i,l,a,c,d;e[12]!==r?(i=m.jsx(sv,{step:r}),l=m.jsx(iv,{step:r}),a=m.jsx(lv,{step:r}),c=m.jsx(uv,{step:r}),d=m.jsx(fv,{step:r}),e[12]=r,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=d):(i=e[13],l=e[14],a=e[15],c=e[16],d=e[17]);let u;return e[18]!==o||e[19]!==i||e[20]!==l||e[21]!==a||e[22]!==c||e[23]!==d?(u=m.jsxs("div",{className:o,children:[i,l,a,c,d]}),e[18]=o,e[19]=i,e[20]=l,e[21]=a,e[22]=c,e[23]=d,e[24]=u):u=e[24],u}function sv(n){const e=I.c(15),{step:t}=n,s="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,o=we(),i=s??"";let l;e[0]!==i?(l=m.jsx(Ds,{icon:null,name:i,size:"xs",className:"shadow-sm"}),e[0]=i,e[1]=l):l=e[1];let a;e[2]!==s?(a=m.jsx("span",{className:"text-base font-medium text-foreground truncate flex-1",children:s}),e[2]=s,e[3]=a):a=e[3];let c;e[4]!==o?(c=o?null:m.jsx(ov,{}),e[4]=o,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==a||e[8]!==c?(d=m.jsxs("div",{className:"flex items-center gap-2",children:[l,a,c]}),e[6]=l,e[7]=a,e[8]=c,e[9]=d):d=e[9];let u;e[10]!==t.description?(u=t.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[10]=t.description,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=m.jsxs("div",{className:"border-b border-border p-5 shrink-0 flex flex-col gap-2",children:[d,u]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function ov(){const n=I.c(9),e=fr(),{updateStep:t,startReplacingTool:r}=Me(),s=we(),i=e&&"toolName"in e.action?e.action.toolName:null;let l;n[0]!==e||n[1]!==r||n[2]!==i||n[3]!==s||n[4]!==t?(l=()=>{if(e){if(s){Ic.error("You cannot replace a tool while a workflow is executing.");return}i&&r(i),t(e.name,{action:{...e.action,toolName:""}})}},n[0]=e,n[1]=r,n[2]=i,n[3]=s,n[4]=t,n[5]=l):l=n[5];const a=l;let c;n[6]===Symbol.for("react.memo_cache_sentinel")?(c=m.jsx(ed,{size:14}),n[6]=c):c=n[6];let d;return n[7]!==a?(d=m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:a,title:"Replace tool",children:c}),n[7]=a,n[8]=d):d=n[8],d}function Wl(n){const e=I.c(13),t=In();let r;e[0]!==t?(r=t?new URL(`/mcp/gateway/${t}`,window.location.origin).href:"",e[0]=t,e[1]=r):r=e[1];const s=r,o=!!t;let i;e[2]!==s||e[3]!==o?(i={url:s,enabled:o},e[2]=s,e[3]=o,e[4]=i):i=e[4];const l=Vi(i);let a;e[5]!==l.tools||e[6]!==n?(a=l.tools?.find(h=>h.name===n),e[5]=l.tools,e[6]=n,e[7]=a):a=e[7];const c=a,d=l.state==="connecting",u=l.state==="ready";let f;return e[8]!==l.error||e[9]!==d||e[10]!==u||e[11]!==c?(f={tool:c,isLoading:d,isReady:u,error:l.error},e[8]=l.error,e[9]=d,e[10]=u,e[11]=c,e[12]=f):f=e[12],f}function iv(n){const e=I.c(13),{step:t}=n,{updateStep:r}=Me(),o="toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,i=we(),{tool:l}=Wl(o??"");if(!l||!l.inputSchema)return null;let a;e[0]!==t.name||e[1]!==r?(a=x=>{r(t.name,{input:x})},e[0]=t.name,e[1]=r,e[2]=a):a=e[2];const c=a,d=i?"output":"input";let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx(ZS,{className:"px-5 py-5",children:m.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Input"})}),e[3]=u):u=e[3];const f=l.inputSchema,h=t.input;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[4]=p):p=e[4];let g;e[5]!==c||e[6]!==t.name||e[7]!==f||e[8]!==h?(g=m.jsxs(QS,{value:"input",className:"border-b-0",children:[u,m.jsx(ev,{className:"px-5 pt-2",children:m.jsx(oh,{inputSchema:f,inputParams:h,setInputParams:c,mentions:p},t.name)})]}),e[5]=c,e[6]=t.name,e[7]=f,e[8]=h,e[9]=g):g=e[9];let y;return e[10]!==d||e[11]!==g?(y=m.jsx(YS,{type:"single",collapsible:!0,defaultValue:d,className:"border-b border-border shrink-0",children:g}),e[10]=d,e[11]=g,e[12]=y):y=e[12],y}function lv(n){const e=I.c(24),{step:t}=n,r=t.outputSchema,[s,o]=A.useState(!1),i=we(),{output:l,error:a}=Wm(i,t.name);let c;e[0]!==a||e[1]!==l?(c=l||(a?{error:a}:null),e[0]=a,e[1]=l,e[2]=c):c=e[2];const d=c,u=r&&typeof r=="object"?r.properties:void 0;let f;e[3]!==u?(f=u?Object.entries(u):[],e[3]=u,e[4]=f):f=e[4];const h=f,p=s?"flex-1 min-h-0 overflow-hidden":"shrink-0";let g;e[5]!==p?(g=J("flex flex-col border-b border-border",p),e[5]=p,e[6]=g):g=e[6];let y;e[7]!==s?(y=()=>o(!s),e[7]=s,e[8]=y):y=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Output"}),e[9]=x):x=e[9];let b;e[10]!==s?(b=m.jsxs("div",{className:"flex items-center justify-between",children:[x,s?m.jsx(Wc,{size:14,className:"text-muted-foreground"}):m.jsx(Vc,{size:14,className:"text-muted-foreground"})]}),e[10]=s,e[11]=b):b=e[11];let k;e[12]!==y||e[13]!==b?(k=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:y,children:b}),e[12]=y,e[13]=b,e[14]=k):k=e[14];let C;e[15]!==d||e[16]!==s||e[17]!==h||e[18]!==i?(C=s&&m.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5",children:[i?m.jsx(ur,{code:JSON.stringify(d,null,2),language:"json",height:"100%",readOnly:!0}):null,!i&&h.map(av)]}),e[15]=d,e[16]=s,e[17]=h,e[18]=i,e[19]=C):C=e[19];let w;return e[20]!==g||e[21]!==k||e[22]!==C?(w=m.jsxs("div",{className:g,children:[k,C]}),e[20]=g,e[21]=k,e[22]=C,e[23]=w):w=e[23],w}function av(n){const[e,t]=n;return m.jsx(dv,{name:e,schema:t},e)}function cv(n){switch(n){case"string":return{Icon:Jc,color:"text-blue-500"};case"number":case"integer":return{Icon:Uc,color:"text-blue-500"};case"array":return{Icon:Hc,color:"text-purple-500"};case"object":return{Icon:Fc,color:"text-orange-500"};case"boolean":return{Icon:Kc,color:"text-pink-500"};case"null":return{Icon:Ii,color:"text-gray-500"};default:return{Icon:qc,color:"text-muted-foreground"}}}function dv(n){const e=I.c(28),{name:t,schema:r}=n,s=fr(),o=r.type??"unknown";let i,l,a,c,d;if(e[0]!==o){const{Icon:C,color:w}=cv(o);d="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=C,l=14,a=J(w),e[0]=o,e[1]=i,e[2]=l,e[3]=a,e[4]=c,e[5]=d}else i=e[1],l=e[2],a=e[3],c=e[4],d=e[5];let u;e[6]!==i||e[7]!==l||e[8]!==a?(u=m.jsx(i,{size:l,className:a}),e[6]=i,e[7]=l,e[8]=a,e[9]=u):u=e[9];let f;e[10]!==t?(f=m.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[10]=t,e[11]=f):f=e[11];let h;e[12]!==c||e[13]!==u||e[14]!==f?(h=m.jsxs("div",{className:c,children:[u,f]}),e[12]=c,e[13]=u,e[14]=f,e[15]=h):h=e[15];let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Qc,{size:14,className:"opacity-50"}),e[16]=p):p=e[16];const g=s?.name;let y;e[17]!==g?(y=m.jsxs("span",{className:"text-muted-foreground",children:[g,"."]}),e[17]=g,e[18]=y):y=e[18];let x;e[19]!==t?(x=m.jsx("div",{className:"bg-blue-500/10 text-blue-500 px-1 py-0.5 rounded",children:t}),e[19]=t,e[20]=x):x=e[20];let b;e[21]!==y||e[22]!==x?(b=m.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[p,y,x]}),e[21]=y,e[22]=x,e[23]=b):b=e[23];let k;return e[24]!==b||e[25]!==d||e[26]!==h?(k=m.jsxs("div",{className:d,children:[h,b]}),e[24]=b,e[25]=d,e[26]=h,e[27]=k):k=e[27],k}function uv(n){const e=I.c(29),{step:t}=n,{updateStep:r}=Me(),s=we(),o="toolName"in t.action,i=o&&"toolName"in t.action?t.action.toolName:null,{tool:l}=Wl(i??""),a=o&&"transformCode"in t.action?t.action.transformCode??null:null,c=!!a;let d;e[0]!==l?(d=()=>{if(!l?.outputSchema)return`interface Input {
147
+ // Tool output schema not available
148
+ }`;const E=l.outputSchema,M=E.properties;return M?`interface Input {
149
+ ${Object.entries(M).map(j=>{const[_,H]=j,B=_r(H),V=!E.required?.includes(_);return` ${_}${V?"?":""}: ${B};`}).join(`
150
+ `)}
151
+ }`:`interface Input {
152
+ [key: string]: unknown;
153
+ }`},e[0]=l,e[1]=d):d=e[1];const u=d;let f;e[2]!==u||e[3]!==t.action||e[4]!==t.name||e[5]!==r?(f=()=>{const M=`${u()}
154
+
155
+ interface Output {
156
+ // Define your output type here
157
+ result: unknown;
158
+ }
159
+
160
+ export default async function(input: Input): Promise<Output> {
161
+ // Transform the tool output
162
+ return {
163
+ result: input,
164
+ };
165
+ }`;r(t.name,{action:{...t.action,transformCode:M}})},e[2]=u,e[3]=t.action,e[4]=t.name,e[5]=r,e[6]=f):f=e[6];const h=f;let p;e[7]!==t.action||e[8]!==t.name||e[9]!==r?(p=()=>{r(t.name,{action:{...t.action,transformCode:void 0}})},e[7]=t.action,e[8]=t.name,e[9]=r,e[10]=p):p=e[10];const g=p;let y;e[11]!==t.action||e[12]!==t.name||e[13]!==r?(y=(E,M)=>{r(t.name,{action:{...t.action,transformCode:E},...M?{outputSchema:M}:{}})},e[11]=t.action,e[12]=t.name,e[13]=r,e[14]=y):y=e[14];const x=y;if("code"in t.action&&t.action.code)return null;if(!c){let E;e[15]===Symbol.for("react.memo_cache_sentinel")?(E=m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),m.jsx(Ui,{size:14,className:"text-muted-foreground"})]}),e[15]=E):E=e[15];let M;return e[16]!==h?(M=m.jsx("div",{className:"border-b border-border p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:h,children:E}),e[16]=h,e[17]=M):M=e[17],M}let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),m.jsx(Fh,{size:14,className:"text-muted-foreground"})]}),e[18]=b):b=e[18];let k;e[19]!==g?(k=m.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 C=`transform-code-${t.name}-${s}`,w=s!==void 0;let S;e[21]!==x||e[22]!==C||e[23]!==w||e[24]!==a?(S=m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(ur,{code:a,language:"typescript",readOnly:w,onSave:x,height:"100%"},C)}),e[21]=x,e[22]=C,e[23]=w,e[24]=a,e[25]=S):S=e[25];let v;return e[26]!==k||e[27]!==S?(v=m.jsxs("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden border-b border-border",children:[k,S]}),e[26]=k,e[27]=S,e[28]=v):v=e[28],v}function fv(n){const e=I.c(24),{step:t}=n,[r,s]=A.useState(!1),{updateStep:o}=Me(),i="code"in t.action&&t.action.code?t.action.code:null,l=we();let a;e[0]!==t.action||e[1]!==t.name||e[2]!==o?(a=(b,k)=>{o(t.name,{action:{...t.action,code:b},...k?{outputSchema:k}:{}})},e[0]=t.action,e[1]=t.name,e[2]=o,e[3]=a):a=e[3];const c=a;if(!i)return null;const d=r?"flex-1 min-h-0 overflow-hidden":"shrink-0";let u;e[4]!==d?(u=J("flex flex-col border-b border-border",d),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==r?(f=()=>s(!r),e[6]=r,e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Step Code"}),e[8]=h):h=e[8];let p;e[9]!==r?(p=m.jsxs("div",{className:"flex items-center justify-between",children:[h,r?m.jsx(Wc,{size:14,className:"text-muted-foreground"}):m.jsx(Vc,{size:14,className:"text-muted-foreground"})]}),e[9]=r,e[10]=p):p=e[10];let g;e[11]!==f||e[12]!==p?(g=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:f,children:p}),e[11]=f,e[12]=p,e[13]=g):g=e[13];let y;e[14]!==i||e[15]!==c||e[16]!==r||e[17]!==t.name||e[18]!==l?(y=r&&m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(ur,{onSave:(b,k)=>c(b,k),code:i,language:"typescript",height:"100%",readOnly:l!==void 0},`step-code-${t.name}-${l}`)}),e[14]=i,e[15]=c,e[16]=r,e[17]=t.name,e[18]=l,e[19]=y):y=e[19];let x;return e[20]!==u||e[21]!==g||e[22]!==y?(x=m.jsxs("div",{className:u,children:[g,y]}),e[20]=u,e[21]=g,e[22]=y,e[23]=x):x=e[23],x}function _r(n){if(Array.isArray(n.type))return n.type.map(t=>_r({...n,type:t})).join(" | ");switch(n.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return n.items?`${_r(n.items)}[]`:"unknown[]";case"object":return n.properties?`{ ${Object.entries(n.properties).map(([r,s])=>{const o=_r(s),i=!n.required?.includes(r);return`${r}${i?"?":""}: ${o}`}).join("; ")} }`:"Record<string, unknown>";case"null":return"null";default:return"unknown"}}function hv(n){switch(n){case"success":return m.jsxs(cn,{variant:"success",className:"gap-1",children:[m.jsx(_i,{size:11}),"Success"]});case"error":case"failed":return m.jsxs(cn,{variant:"destructive",className:"gap-1",children:[m.jsx(Ki,{size:11}),"Error"]});case"running":return m.jsxs(cn,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),"Running"]});case"enqueued":return m.jsxs(cn,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),"On hold"]});case"cancelled":return m.jsxs(cn,{variant:"secondary",className:"gap-1",children:[m.jsx(Bc,{size:11}),"Cancelled"]});default:return m.jsxs(cn,{variant:"secondary",className:"gap-1",children:[m.jsx(jr,{size:11}),n]})}}function pv(n){return`Run #${n.slice(-4).toUpperCase()}`}function mv(n){const e=I.c(21),{className:t}=n,{executions:r,isLoading:s}=qm(),{setShowExecutionsList:o}=Xi(),{setTrackingExecutionId:i}=Me(),l=we();let a;e[0]!==i?(a=k=>{i(k)},e[0]=i,e[1]=a):a=e[1];const c=a;let d;e[2]!==o?(d=()=>{o(!1)},e[2]=o,e[3]=d):d=e[3];const u=d;let f;e[4]!==t?(f=J("flex flex-col h-full bg-sidebar border-l border-border",t),e[4]=t,e[5]=f):f=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:"Runs"}),e[6]=h):h=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Bc,{size:11}),e[7]=p):p=e[7];let g;e[8]!==u?(g=m.jsxs("div",{className:"flex items-center h-12 px-5 border-b border-border shrink-0",children:[h,m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:u,children:p})]}),e[8]=u,e[9]=g):g=e[9];let y;e[10]!==r||e[11]!==c||e[12]!==s||e[13]!==l?(y=s?m.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading executions..."}):r.map((k,C)=>m.jsx(gv,{execution:k,isSelected:k.id===l,isFirst:C===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=m.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=m.jsxs("div",{className:f,children:[g,x]}),e[17]=f,e[18]=g,e[19]=x,e[20]=b):b=e[20],b}function gv(n){const e=I.c(17),{execution:t,isSelected:r,isFirst:s,onSelect:o}=n,i=r&&"bg-accent/50",l=s&&r&&"bg-accent/50",a=!r&&"hover:bg-accent/30";let c;e[0]!==i||e[1]!==l||e[2]!==a?(c=J("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 d;e[4]!==t.status?(d=hv(t.status),e[4]=t.status,e[5]=d):d=e[5];let u;e[6]!==t.id?(u=pv(t.id),e[6]=t.id,e[7]=u):u=e[7];let f;e[8]!==u?(f=m.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:u}),e[8]=u,e[9]=f):f=e[9];let h;e[10]!==d||e[11]!==f?(h=m.jsxs("div",{className:"flex items-center gap-2 w-full",children:[d,f]}),e[10]=d,e[11]=f,e[12]=h):h=e[12];let p;return e[13]!==o||e[14]!==c||e[15]!==h?(p=m.jsx("div",{className:c,onClick:o,children:h}),e[13]=o,e[14]=c,e[15]=h,e[16]=p):p=e[16],p}function yv(n){const e=I.c(10),{itemId:t,mode:r}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=s):s=e[0];const{connectionId:o}=dr(s),i=o??bn;let l;e[1]!==i?(l=Qe(i),e[1]=i,e[2]=l):l=e[2];const a=l,c=r==="workflow"?"WORKFLOW":"WORKFLOW_EXECUTION",d=Lc(i,c,t,a),u=Ri(i,c,a);let f;e[3]!==u||e[4]!==t?(f=async y=>{await u.update.mutateAsync({id:t,data:y})},e[3]=u,e[4]=t,e[5]=f):f=e[5];const h=f,p=r==="execution"?t:void 0;let g;return e[6]!==d||e[7]!==p||e[8]!==h?(g={item:d,update:h,trackingExecutionId:p},e[6]=d,e[7]=p,e[8]=h,e[9]=g):g=e[9],g}function Sh(n){const e=I.c(22),{itemId:t,onBack:r,mode:s}=n;let o;e[0]!==t||e[1]!==s?(o={itemId:t,mode:s},e[0]=t,e[1]=s,e[2]=o):o=e[2];const{item:i,update:l,trackingExecutionId:a}=yv(o);let c;e[3]!==i?(c=JSON.stringify(i),e[3]=i,e[4]=c):c=e[4];const d=c;if(!i){let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(Di,{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=m.jsx(Ps,{onBack:r,children:b}),e[6]=r,e[7]=k):k=e[7],k}const u=i.description??void 0;let f;e[8]!==i||e[9]!==u?(f={...i,description:u},e[8]=i,e[9]=u,e[10]=f):f=e[10];const h=f,p=s==="execution"?"action":"executions";let g;e[11]!==p||e[12]!==a||e[13]!==h?(g={workflow:h,trackingExecutionId:a,currentStepTab:p},e[11]=p,e[12]=a,e[13]=h,e[14]=g):g=e[14];let y;e[15]!==r||e[16]!==l?(y=m.jsx(wv,{onBack:r,onUpdate:l}),e[15]=r,e[16]=l,e[17]=y):y=e[17];let x;return e[18]!==d||e[19]!==g||e[20]!==y?(x=m.jsx($m,{initialState:g,children:y},d),e[18]=d,e[19]=g,e[20]=y,e[21]=x):x=e[21],x}function xv(n){const e=I.c(2);let t;return e[0]!==n?(t=m.jsx(Sh,{...n,mode:"workflow"}),e[0]=n,e[1]=t):t=e[1],t}function bv(n){const e=I.c(18),{workflow:t,onUpdate:r}=n,{setWorkflow:s}=Me();let o,i,l,a;if(e[0]!==t.description||e[1]!==t.id||e[2]!==t.steps||e[3]!==t.title){const u={title:t.title,description:t.description,steps:t.steps};o=ur,i=`workflow-${t.id}`,l="100%",a=JSON.stringify(u,null,2),e[0]=t.description,e[1]=t.id,e[2]=t.steps,e[3]=t.title,e[4]=o,e[5]=i,e[6]=l,e[7]=a}else o=e[4],i=e[5],l=e[6],a=e[7];let c;e[8]!==r||e[9]!==s||e[10]!==t?(c=u=>{const f=JSON.parse(u);s({...t,...f}),r(f)},e[8]=r,e[9]=s,e[10]=t,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==a||e[16]!==c?(d=m.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]=d):d=e[17],d}function kv(){const n=I.c(12),{setTrackingExecutionId:e}=Me(),t=we();let r;n[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"flex items-center justify-center h-full w-12",children:m.jsx(Hh,{className:"w-4 h-4 text-muted-foreground"})}),n[0]=r):r=n[0];let s;n[1]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("strong",{className:"text-base text-foreground",children:"Run"}),n[1]=s):s=n[1];let o;n[2]!==t?(o=m.jsxs("div",{className:"flex items-center h-full",children:[r,m.jsxs("p",{className:"flex gap-3 items-center h-full",children:[s,m.jsxs("span",{className:"text-sm text-muted-foreground",children:["#",t]})]})]}),n[2]=t,n[3]=o):o=n[3];let i;n[4]!==e?(i=()=>e(void 0),n[4]=e,n[5]=i):i=n[5];let l;n[6]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx(Ii,{className:"w-4 h-4 text-muted-foreground"}),n[6]=l):l=n[6];let a;n[7]!==i?(a=m.jsx(me,{variant:"ghost",size:"xs",onClick:i,children:l}),n[7]=i,n[8]=a):a=n[8];let c;return n[9]!==o||n[10]!==a?(c=m.jsxs("div",{className:"h-10 bg-accent flex items-center justify-between border-b border-border",children:[o,a]}),n[9]=o,n[10]=a,n[11]=c):c=n[11],c}function wv(n){const e=I.c(24),{onBack:t,onUpdate:r}=n,s=On(),o=we(),{setOriginalWorkflow:i}=Me(),{viewMode:l,showExecutionsList:a}=Xi(),c=fr();let d;e[0]!==r||e[1]!==i||e[2]!==s?(d=async()=>{await r(s),i(s)},e[0]=r,e[1]=i,e[2]=s,e[3]=d):d=e[3];const u=d,f=c&&"toolName"in c.action,h=f?c.action.toolName:null,p=f&&!h&&!o,g=!p&&(c||o||!a);let y;e[4]!==u||e[5]!==s.description||e[6]!==s.title?(y=m.jsx(oS,{title:s.title,description:s.description,onSave:u}),e[4]=u,e[5]=s.description,e[6]=s.title,e[7]=y):y=e[7];let x;e[8]!==o?(x=o&&m.jsx(kv,{}),e[8]=o,e[9]=x):x=e[9];let b;e[10]!==r||e[11]!==a||e[12]!==g||e[13]!==p||e[14]!==l||e[15]!==s?(b=m.jsx("div",{className:"flex-1 overflow-hidden",children:l==="code"?m.jsx(bv,{workflow:s,onUpdate:r}):m.jsxs(cp,{direction:"horizontal",className:"flex w-full h-full",children:[m.jsx(ql,{defaultSize:50,minSize:30,children:m.jsx(vS,{})}),m.jsx(dp,{}),m.jsxs(ql,{defaultSize:50,minSize:25,children:[p&&m.jsx(ES,{className:"border-l border-border"}),a&&m.jsx(mv,{}),g&&m.jsx(rv,{className:"border-l border-border"})]})]})}),e[10]=r,e[11]=a,e[12]=g,e[13]=p,e[14]=l,e[15]=s,e[16]=b):b=e[16];let k;e[17]!==y||e[18]!==x||e[19]!==b?(k=m.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 C;return e[21]!==t||e[22]!==k?(C=m.jsx(Ps,{onBack:t,children:k}),e[21]=t,e[22]=k,e[23]=C):C=e[23],C}function Sv(n){const e=I.c(2);let t;return e[0]!==n?(t=m.jsx(Sh,{...n,mode:"execution"}),e[0]=n,e[1]=t):t=e[1],t}const vv={workflow:xv,workflow_execution:Sv,prompt:gm};function Cv(){const n=I.c(6),e=Pc();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=t):t=n[0];const r=dr(t),s=decodeURIComponent(r.itemId);let o;n[1]!==e.history?(o=()=>{e.history.back()},n[1]=e.history,n[2]=o):o=n[2];const i=o,l=Nv;let a;return n[3]!==i||n[4]!==s?(a=m.jsx(Cm,{itemId:s,onBack:i,onUpdate:l}),n[3]=i,n[4]=s,n[5]=a):a=n[5],a}async function Nv(n){return Promise.resolve()}function Ev(){const n=I.c(18),e=Pc();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=t):t=n[0];const r=dr(t),s=r.connectionId,o=decodeURIComponent(r.collectionName),i=decodeURIComponent(r.itemId);let l;n[1]!==e.history?(l=()=>{e.history.back()},n[1]=e.history,n[2]=l):l=n[2];const a=l,c=s??bn;let d;n[3]!==c?(d=Qe(c),n[3]=c,n[4]=d):d=n[4];const f=Ri(c,o,d);let h;n[5]!==f||n[6]!==i?(h=async C=>{i&&await f.update.mutateAsync({id:i,data:C})},n[5]=f,n[6]=i,n[7]=h):h=n[7];const p=h;let g;n[8]!==o?(g=o?.toLowerCase(),n[8]=o,n[9]=g):g=n[9];const y=g,x=y&&vv[y];if(x){let C;return n[10]!==x||n[11]!==a||n[12]!==p||n[13]!==i?(C=m.jsx(x,{itemId:i,onBack:a,onUpdate:p}),n[10]=x,n[11]=a,n[12]=p,n[13]=i,n[14]=C):C=n[14],C}let b;n[15]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsx(Wh,{size:36,className:"text-muted-foreground"}),n[15]=b):b=n[15];let k;return n[16]!==a?(k=m.jsx(sp,{icon:b,title:"No component defined",description:"No component for this collection was defined",buttonProps:{onClick:a,children:"Go back"}}),n[16]=a,n[17]=k):k=n[17],k}function Tv(){const n=I.c(3);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},n[0]=e):e=n[0];const t=dr(e);if(decodeURIComponent(t.collectionName)==="tools"){let i;return n[1]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(Cv,{}),n[1]=i):i=n[1],i}let o;return n[2]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx(Ev,{}),n[2]=o):o=n[2],o}function I2(){const n=I.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx($c,{children:m.jsx(A.Suspense,{fallback:m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(Qn,{size:32,className:"animate-spin text-muted-foreground"})}),children:m.jsx(Tv,{})})}),n[0]=e):e=n[0],e}export{I2 as default};