@baseline-ui/core 3.4.0 → 3.5.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 (265) hide show
  1. package/dist/Accordion.mjs +1 -1
  2. package/dist/ActionButton.mjs +1 -1
  3. package/dist/ActionGroup.mjs +1 -1
  4. package/dist/ActionIconButton.mjs +1 -1
  5. package/dist/Actionable.mjs +1 -1
  6. package/dist/AlertDialog.css +1 -1
  7. package/dist/AlertDialog.mjs +1 -1
  8. package/dist/AudioPlayer.css +1 -1
  9. package/dist/AudioPlayer.mjs +1 -1
  10. package/dist/Avatar.mjs +1 -1
  11. package/dist/ButtonSelect.mjs +1 -1
  12. package/dist/Calendar.mjs +1 -1
  13. package/dist/ColorInput.css +1 -1
  14. package/dist/ColorInput.mjs +1 -1
  15. package/dist/ColorSwatch.mjs +1 -1
  16. package/dist/ColorSwatchPicker.mjs +1 -1
  17. package/dist/ComboBox.mjs +1 -1
  18. package/dist/DateField.mjs +1 -1
  19. package/dist/Dialog.css +1 -1
  20. package/dist/Dialog.mjs +1 -1
  21. package/dist/Disclosure.mjs +1 -1
  22. package/dist/DomNodeRenderer.mjs +1 -1
  23. package/dist/Drawer.css +1 -1
  24. package/dist/Drawer.mjs +1 -1
  25. package/dist/Editor.css +1 -1
  26. package/dist/Editor.mjs +1 -1
  27. package/dist/FileInput.mjs +1 -1
  28. package/dist/FileList.mjs +1 -1
  29. package/dist/FileUploader.mjs +1 -1
  30. package/dist/FrameProvider.mjs +1 -1
  31. package/dist/FreehandCanvas.mjs +1 -1
  32. package/dist/GridList.mjs +1 -1
  33. package/dist/Icon.mjs +1 -1
  34. package/dist/ImageDropZone.mjs +1 -1
  35. package/dist/ImageGallery.css +1 -1
  36. package/dist/ImageGallery.mjs +1 -1
  37. package/dist/InlineAlert.mjs +1 -1
  38. package/dist/InlineToolbar.mjs +1 -1
  39. package/dist/Kbd.mjs +1 -1
  40. package/dist/Link.mjs +1 -1
  41. package/dist/ListBox.mjs +1 -1
  42. package/dist/Menu.mjs +1 -1
  43. package/dist/MessageFormat.mjs +1 -1
  44. package/dist/Modal.mjs +1 -1
  45. package/dist/NumberInput.mjs +1 -1
  46. package/dist/Pagination.mjs +1 -1
  47. package/dist/Panel.mjs +1 -1
  48. package/dist/PointPicker.mjs +1 -1
  49. package/dist/Popover.mjs +1 -1
  50. package/dist/Portal.mjs +1 -1
  51. package/dist/Preview.mjs +1 -1
  52. package/dist/RadioGroup.mjs +1 -1
  53. package/dist/ScrollControlButton.mjs +1 -1
  54. package/dist/SearchInput.mjs +1 -1
  55. package/dist/Select.mjs +1 -1
  56. package/dist/Slider.css +1 -1
  57. package/dist/Slider.mjs +1 -1
  58. package/dist/Stepper.mjs +1 -1
  59. package/dist/Table.css +1 -1
  60. package/dist/Table.mjs +1 -1
  61. package/dist/Tabs.mjs +1 -1
  62. package/dist/Tag.mjs +1 -1
  63. package/dist/TagGroup.mjs +1 -1
  64. package/dist/TaggedPagination.mjs +1 -1
  65. package/dist/TextInput.mjs +1 -1
  66. package/dist/ThemeProvider.mjs +1 -1
  67. package/dist/TimeField.mjs +1 -1
  68. package/dist/Toast.mjs +1 -1
  69. package/dist/ToggleButton.mjs +1 -1
  70. package/dist/ToggleIconButton.mjs +1 -1
  71. package/dist/Toolbar.mjs +1 -1
  72. package/dist/Tooltip.mjs +1 -1
  73. package/dist/TreeView.mjs +1 -1
  74. package/dist/UNSAFE_ListBox.mjs +1 -1
  75. package/dist/Virtualizer.mjs +1 -1
  76. package/dist/{chunk-LPI2NIDI.mjs → chunk-2AKHB7Y5.mjs} +1 -1
  77. package/dist/chunk-2M2LI4MI.mjs +10 -0
  78. package/dist/chunk-2WA3KB7H.mjs +10 -0
  79. package/dist/{chunk-KGS3UWPG.mjs → chunk-3KWSJRYK.mjs} +1 -1
  80. package/dist/{chunk-AM5FU4Y7.mjs → chunk-3M3WJHOI.mjs} +1 -1
  81. package/dist/{chunk-5KJF7IQN.mjs → chunk-3UC5V5E3.mjs} +1 -1
  82. package/dist/{chunk-QUQ4VYCN.mjs → chunk-43LOJ3SH.mjs} +1 -1
  83. package/dist/{chunk-MFB3SWO7.mjs → chunk-46RUOB4U.mjs} +11 -11
  84. package/dist/{chunk-AELTF2DE.mjs → chunk-4WVW4KEK.mjs} +1 -1
  85. package/dist/{chunk-BYDJXA5A.mjs → chunk-5G6JNQQR.mjs} +1 -1
  86. package/dist/{chunk-4EANTENO.mjs → chunk-5G7ABQYJ.mjs} +1 -1
  87. package/dist/{chunk-IUXXTORQ.mjs → chunk-5W67PVZQ.mjs} +1 -1
  88. package/dist/{chunk-CTSDHAAV.mjs → chunk-676DOXEK.mjs} +2 -2
  89. package/dist/{chunk-AD3MLX6G.mjs → chunk-6GMU63H2.mjs} +1 -1
  90. package/dist/chunk-6M7PJXEE.mjs +10 -0
  91. package/dist/chunk-6Q5PNIYZ.mjs +10 -0
  92. package/dist/{chunk-R7R7JDA3.mjs → chunk-7BE6MOPW.mjs} +1 -1
  93. package/dist/chunk-7EQIV4GX.mjs +10 -0
  94. package/dist/{chunk-DZDZZRWE.mjs → chunk-7MLFM55C.mjs} +1 -1
  95. package/dist/chunk-7XLBV46W.mjs +10 -0
  96. package/dist/{chunk-BHJCYKFJ.mjs → chunk-ABXTAFKP.mjs} +1 -1
  97. package/dist/{chunk-TUJLNJPJ.mjs → chunk-AFOW62QN.mjs} +2 -2
  98. package/dist/chunk-AMVX34SS.mjs +10 -0
  99. package/dist/{chunk-7TE4MFKC.mjs → chunk-AN26QORL.mjs} +1 -1
  100. package/dist/{chunk-OYSOPCTA.mjs → chunk-BA5OA5DY.mjs} +1 -1
  101. package/dist/{chunk-4W5VP4NV.mjs → chunk-BAIVRB2I.mjs} +1 -1
  102. package/dist/{chunk-K4TTZX4T.mjs → chunk-BET5GVGQ.mjs} +1 -1
  103. package/dist/{chunk-7L5UOGZA.mjs → chunk-BPW4QRPV.mjs} +2 -2
  104. package/dist/chunk-BSSLS6MF.mjs +10 -0
  105. package/dist/{chunk-UUTMZQQA.mjs → chunk-CENNHSIS.mjs} +3 -3
  106. package/dist/{chunk-W7OTSFZS.mjs → chunk-CTBCJZEG.mjs} +1 -1
  107. package/dist/chunk-D5VU5TED.mjs +11 -0
  108. package/dist/chunk-DAI7V4TE.mjs +10 -0
  109. package/dist/chunk-DO5YROCG.mjs +10 -0
  110. package/dist/{chunk-COHK4QQW.mjs → chunk-EGLD5KVP.mjs} +2 -2
  111. package/dist/{chunk-BXNNVZOQ.mjs → chunk-EL5OYHOX.mjs} +1 -1
  112. package/dist/{chunk-CLGLEEFO.mjs → chunk-FCKJCFMD.mjs} +1 -1
  113. package/dist/chunk-FGSVPRDN.mjs +10 -0
  114. package/dist/chunk-FNCHBVLF.mjs +10 -0
  115. package/dist/chunk-GFBRKKX4.mjs +10 -0
  116. package/dist/{chunk-QU34XSML.mjs → chunk-GLAMJIYO.mjs} +2 -2
  117. package/dist/{chunk-NRQSR3G7.mjs → chunk-HABKIEKC.mjs} +1 -1
  118. package/dist/{chunk-HI44JQA7.mjs → chunk-HPUUQKKH.mjs} +2 -2
  119. package/dist/chunk-HZM2XZP4.mjs +10 -0
  120. package/dist/{chunk-ZFGTKLCU.mjs → chunk-I7SMG6PT.mjs} +1 -1
  121. package/dist/{chunk-TH4XPZEO.mjs → chunk-IM3E5JL4.mjs} +1 -1
  122. package/dist/chunk-IROFSPEN.mjs +10 -0
  123. package/dist/chunk-JRCDMRIW.mjs +10 -0
  124. package/dist/{chunk-WHN2SEWO.mjs → chunk-KHDWTXGG.mjs} +2 -2
  125. package/dist/{chunk-SVTTHYTR.mjs → chunk-KW3BKIG4.mjs} +1 -1
  126. package/dist/{chunk-EUVUJQ2Z.mjs → chunk-LBHZV4BO.mjs} +1 -1
  127. package/dist/{chunk-QJYPCVSD.mjs → chunk-LKSUUT3M.mjs} +1 -1
  128. package/dist/chunk-LQ7PGSP4.mjs +10 -0
  129. package/dist/chunk-LQHFBXCW.mjs +10 -0
  130. package/dist/{chunk-MIF6BAPG.mjs → chunk-LSPDPDB6.mjs} +1 -1
  131. package/dist/chunk-MCN5JU6E.mjs +10 -0
  132. package/dist/chunk-MHAPHPNN.mjs +10 -0
  133. package/dist/{chunk-4AG2RUAZ.mjs → chunk-NMK4W6K3.mjs} +2 -2
  134. package/dist/chunk-O23QVPUT.mjs +10 -0
  135. package/dist/{chunk-WTAJLO6E.mjs → chunk-O6FPWOHR.mjs} +1 -1
  136. package/dist/chunk-OMWMNUTI.mjs +10 -0
  137. package/dist/{chunk-YU5NRJT6.mjs → chunk-ONBEVR2G.mjs} +1 -1
  138. package/dist/{chunk-XD43CVDT.mjs → chunk-OVJT5F2R.mjs} +1 -1
  139. package/dist/{chunk-YPEAGD2G.mjs → chunk-OWQRYRWF.mjs} +1 -1
  140. package/dist/{chunk-ZZIQF6XD.mjs → chunk-PLZ6ZFEO.mjs} +1 -1
  141. package/dist/{chunk-PD5ZXNGT.mjs → chunk-QMV2O57M.mjs} +2 -2
  142. package/dist/{chunk-C2VP5IEB.mjs → chunk-QWZBZ23U.mjs} +1 -1
  143. package/dist/{chunk-E22TWF63.mjs → chunk-QXXKOFWM.mjs} +2 -2
  144. package/dist/{chunk-SZN2J2ER.mjs → chunk-R6Q7UMQS.mjs} +1 -1
  145. package/dist/chunk-SI5WP6I7.mjs +10 -0
  146. package/dist/{chunk-36ZMHBG5.mjs → chunk-T6J7G3YL.mjs} +1 -1
  147. package/dist/chunk-TTVYMCU3.mjs +10 -0
  148. package/dist/chunk-TYKMNZJ4.mjs +11 -0
  149. package/dist/chunk-TZGK36KC.mjs +10 -0
  150. package/dist/chunk-UBLCUHRL.mjs +10 -0
  151. package/dist/{chunk-IVGNOQSQ.mjs → chunk-UH6QIGD3.mjs} +1 -1
  152. package/dist/chunk-UOWKAUCQ.mjs +10 -0
  153. package/dist/{chunk-OZMADP4Z.mjs → chunk-UPJHL37C.mjs} +2 -2
  154. package/dist/chunk-USUPPN73.mjs +10 -0
  155. package/dist/{chunk-XWJJ4V3O.mjs → chunk-UYAFH4CW.mjs} +2 -2
  156. package/dist/{chunk-KJ6ZSO3I.mjs → chunk-UYUYQFOW.mjs} +1 -1
  157. package/dist/chunk-VFO35ZLL.mjs +10 -0
  158. package/dist/chunk-VXZT2JR2.mjs +10 -0
  159. package/dist/{chunk-R3HHMCE5.mjs → chunk-WFYFHANE.mjs} +1 -1
  160. package/dist/{chunk-NYCG264A.mjs → chunk-X5ORCNAU.mjs} +2 -2
  161. package/dist/chunk-X5ZTXDQ4.mjs +10 -0
  162. package/dist/{chunk-BBYODNBO.mjs → chunk-X7CKWYUD.mjs} +1 -1
  163. package/dist/{chunk-6G7EUNZW.mjs → chunk-XAM3AXXK.mjs} +1 -1
  164. package/dist/{chunk-24R46WQW.mjs → chunk-XOS3JIQX.mjs} +1 -1
  165. package/dist/{chunk-TSHZ7JSR.mjs → chunk-XQC3DSTW.mjs} +1 -1
  166. package/dist/{chunk-VETO7WNN.mjs → chunk-Y3HXPORF.mjs} +2 -2
  167. package/dist/chunk-YDUKC7QS.mjs +10 -0
  168. package/dist/{chunk-P7BN7QDF.mjs → chunk-YFBMCK5O.mjs} +1 -1
  169. package/dist/{chunk-4RSUKS23.mjs → chunk-YYU46XNM.mjs} +2 -2
  170. package/dist/{chunk-Q6PGYMYI.mjs → chunk-Z3ZMWJSV.mjs} +1 -1
  171. package/dist/chunk-Z4QTH4TB.mjs +10 -0
  172. package/dist/{chunk-UNGYVWKZ.mjs → chunk-ZA2FH3MS.mjs} +1 -1
  173. package/dist/hooks/useContainerScopedRef.mjs +1 -1
  174. package/dist/hooks/useDevice.mjs +1 -1
  175. package/dist/hooks/useI18n.mjs +1 -1
  176. package/dist/hooks/useIntersectionObserver.mjs +1 -1
  177. package/dist/hooks/useLiveInteractionModality.mjs +1 -1
  178. package/dist/hooks/useMedia.mjs +1 -1
  179. package/dist/hooks/useMutationObserver.mjs +1 -1
  180. package/dist/hooks/usePortalContainer.mjs +1 -1
  181. package/dist/hooks/usePreventFocus.mjs +1 -1
  182. package/dist/hooks/useResizeObserver.mjs +1 -1
  183. package/dist/hooks/useTextSelection.mjs +1 -1
  184. package/dist/index.css +1 -1
  185. package/dist/index.d.ts +65 -22
  186. package/dist/index.js +21 -21
  187. package/dist/index.mjs +1 -1
  188. package/dist/messageIds.mjs +1 -1
  189. package/dist/utils/colors.mjs +1 -1
  190. package/dist/utils/dom.mjs +1 -1
  191. package/dist/utils/isInShadowDOM.mjs +1 -1
  192. package/dist/utils/keyboards.mjs +1 -1
  193. package/dist/utils/strings.mjs +1 -1
  194. package/intl/ar.json +1 -0
  195. package/intl/cs.json +1 -0
  196. package/intl/cy.json +1 -0
  197. package/intl/da.json +1 -0
  198. package/intl/de.json +1 -0
  199. package/intl/el.json +1 -0
  200. package/intl/en-GB.json +1 -0
  201. package/intl/en.json +1 -0
  202. package/intl/es.json +1 -0
  203. package/intl/fi.json +1 -0
  204. package/intl/fr-CA.json +1 -0
  205. package/intl/fr.json +1 -0
  206. package/intl/he.json +1 -0
  207. package/intl/hr.json +1 -0
  208. package/intl/id.json +1 -0
  209. package/intl/it.json +1 -0
  210. package/intl/ja.json +1 -0
  211. package/intl/ko.json +1 -0
  212. package/intl/ms.json +1 -0
  213. package/intl/nb-NO.json +1 -0
  214. package/intl/nl.json +1 -0
  215. package/intl/pl.json +1 -0
  216. package/intl/pt-PT.json +1 -0
  217. package/intl/pt.json +1 -0
  218. package/intl/ru.json +1 -0
  219. package/intl/sk.json +1 -0
  220. package/intl/sl.json +1 -0
  221. package/intl/sv.json +1 -0
  222. package/intl/th.json +1 -0
  223. package/intl/tr.json +1 -0
  224. package/intl/uk.json +1 -0
  225. package/intl/zh-Hans.json +1 -0
  226. package/intl/zh-Hant.json +1 -0
  227. package/messages.json +4 -0
  228. package/package.json +4 -4
  229. package/sbom.json +6 -6
  230. package/dist/chunk-2F3CFR22.mjs +0 -10
  231. package/dist/chunk-2LFMBQKQ.mjs +0 -10
  232. package/dist/chunk-3BEG3MEX.mjs +0 -10
  233. package/dist/chunk-3BG6K2G2.mjs +0 -10
  234. package/dist/chunk-3KCSUNRV.mjs +0 -10
  235. package/dist/chunk-4JQUB53Q.mjs +0 -10
  236. package/dist/chunk-4MHBLLHV.mjs +0 -11
  237. package/dist/chunk-5BKC373Y.mjs +0 -10
  238. package/dist/chunk-5FK5AJ7A.mjs +0 -10
  239. package/dist/chunk-5SHHWKFM.mjs +0 -10
  240. package/dist/chunk-76DKF2SK.mjs +0 -10
  241. package/dist/chunk-7MMO7S3R.mjs +0 -10
  242. package/dist/chunk-AK7XHUQW.mjs +0 -10
  243. package/dist/chunk-DAS5QGJX.mjs +0 -10
  244. package/dist/chunk-DSV6CCI6.mjs +0 -10
  245. package/dist/chunk-F7PGMOQF.mjs +0 -10
  246. package/dist/chunk-FOKMDEP7.mjs +0 -10
  247. package/dist/chunk-FPFGTGUC.mjs +0 -10
  248. package/dist/chunk-IEOHIOGL.mjs +0 -10
  249. package/dist/chunk-IWZXZ5LU.mjs +0 -10
  250. package/dist/chunk-IXRSSEHQ.mjs +0 -10
  251. package/dist/chunk-J4OPD7OL.mjs +0 -10
  252. package/dist/chunk-K7VOXFSK.mjs +0 -10
  253. package/dist/chunk-MDE2FQHX.mjs +0 -10
  254. package/dist/chunk-MYJ733MN.mjs +0 -10
  255. package/dist/chunk-NJKSUI2F.mjs +0 -10
  256. package/dist/chunk-O4DA3TPW.mjs +0 -11
  257. package/dist/chunk-ONEE6UCM.mjs +0 -10
  258. package/dist/chunk-Q4SEEMIX.mjs +0 -10
  259. package/dist/chunk-R4MOUAJW.mjs +0 -10
  260. package/dist/chunk-U3T5JTZ7.mjs +0 -10
  261. package/dist/chunk-UDMNDUBO.mjs +0 -10
  262. package/dist/chunk-VGFPT43C.mjs +0 -10
  263. package/dist/chunk-VJUBKX3W.mjs +0 -10
  264. /package/dist/{chunk-RXSX2RKA.mjs → chunk-SBGZCLF4.mjs} +0 -0
  265. /package/dist/{chunk-DAN62T2M.mjs → chunk-TIGGKOJQ.mjs} +0 -0
@@ -1,4 +1,4 @@
1
- import {c}from'./chunk-L3SNGDBH.mjs';import {b}from'./chunk-DF2D7NE6.mjs';import {a as a$2}from'./chunk-O7XK2WIX.mjs';import {a as a$5}from'./chunk-VGFPT43C.mjs';import {a as a$4}from'./chunk-3BG6K2G2.mjs';import {b as b$1}from'./chunk-OQPYPKZV.mjs';import {e}from'./chunk-GMALMQWI.mjs';import {b as b$2}from'./chunk-N2XGJKZG.mjs';import {a as a$1}from'./chunk-66CUIXA6.mjs';import {j}from'./chunk-KUDCYGII.mjs';import {a}from'./chunk-RT4LMB6X.mjs';import {u}from'./chunk-PPHSLODC.mjs';import {c as c$1}from'./chunk-3WKDIXCM.mjs';import {a as a$7}from'./chunk-SVIYLH7R.mjs';import {a as a$6}from'./chunk-ETM4MNG4.mjs';import {a as a$3}from'./chunk-4QEH5CGK.mjs';import z,{useMemo,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';/**
1
+ import {c}from'./chunk-L3SNGDBH.mjs';import {b}from'./chunk-DF2D7NE6.mjs';import {a as a$2}from'./chunk-O7XK2WIX.mjs';import {a as a$5}from'./chunk-DAI7V4TE.mjs';import {a as a$4}from'./chunk-VXZT2JR2.mjs';import {b as b$1}from'./chunk-OQPYPKZV.mjs';import {e}from'./chunk-GMALMQWI.mjs';import {b as b$2}from'./chunk-N2XGJKZG.mjs';import {a as a$1}from'./chunk-66CUIXA6.mjs';import {j}from'./chunk-KUDCYGII.mjs';import {a}from'./chunk-RT4LMB6X.mjs';import {u}from'./chunk-PPHSLODC.mjs';import {c as c$1}from'./chunk-3WKDIXCM.mjs';import {a as a$7}from'./chunk-SVIYLH7R.mjs';import {a as a$6}from'./chunk-ETM4MNG4.mjs';import {a as a$3}from'./chunk-4QEH5CGK.mjs';import z,{useMemo,useState,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -1,4 +1,4 @@
1
- import {a,b as b$1,c as c$1,d}from'./chunk-QU34XSML.mjs';import {c}from'./chunk-L3SNGDBH.mjs';import {b}from'./chunk-DF2D7NE6.mjs';import {b as b$2}from'./chunk-3WKDIXCM.mjs';import {a as a$1}from'./chunk-4QEH5CGK.mjs';import v,{useMemo}from'react';import {jsx}from'react/jsx-runtime';/**
1
+ import {a,b as b$1,c as c$1,d}from'./chunk-GLAMJIYO.mjs';import {c}from'./chunk-L3SNGDBH.mjs';import {b}from'./chunk-DF2D7NE6.mjs';import {b as b$2}from'./chunk-3WKDIXCM.mjs';import {a as a$1}from'./chunk-4QEH5CGK.mjs';import v,{useMemo}from'react';import {jsx}from'react/jsx-runtime';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -1,4 +1,4 @@
1
- import {b}from'./chunk-DZDZZRWE.mjs';import {a}from'./chunk-66CUIXA6.mjs';import {Fragment}from'react';import {jsx}from'react/jsx-runtime';/**
1
+ import {b}from'./chunk-7MLFM55C.mjs';import {a}from'./chunk-66CUIXA6.mjs';import {Fragment}from'react';import {jsx}from'react/jsx-runtime';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -1,4 +1,4 @@
1
- import {a as a$1,b as b$1}from'./chunk-5ZC64ZG7.mjs';import {b as b$2}from'./chunk-SZTFMBPY.mjs';import {e,f,c,d,h as h$1,g}from'./chunk-PG3WDHSK.mjs';import {a as a$7}from'./chunk-JZXLV6JU.mjs';import {a as a$6}from'./chunk-VGFPT43C.mjs';import {c as c$2}from'./chunk-4EAXDHSV.mjs';import {b}from'./chunk-N2XGJKZG.mjs';import {a as a$4}from'./chunk-RSKKEGJZ.mjs';import {a as a$3}from'./chunk-STMDFIUL.mjs';import {a as a$2}from'./chunk-B3EZOXNU.mjs';import {c as c$1}from'./chunk-3WKDIXCM.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$5}from'./chunk-4QEH5CGK.mjs';import {MinusIcon,PlusIcon}from'@baseline-ui/icons/8';import {ReadOnlyIcon,ErrorCircleFilledIcon}from'@baseline-ui/icons/16';import M,{useMemo}from'react';import {jsxs,jsx}from'react/jsx-runtime';/**
1
+ import {a as a$1,b as b$1}from'./chunk-5ZC64ZG7.mjs';import {b as b$2}from'./chunk-SZTFMBPY.mjs';import {e,f,c,d,h as h$1,g}from'./chunk-PG3WDHSK.mjs';import {a as a$7}from'./chunk-JZXLV6JU.mjs';import {a as a$6}from'./chunk-DAI7V4TE.mjs';import {c as c$2}from'./chunk-4EAXDHSV.mjs';import {b}from'./chunk-N2XGJKZG.mjs';import {a as a$4}from'./chunk-RSKKEGJZ.mjs';import {a as a$3}from'./chunk-STMDFIUL.mjs';import {a as a$2}from'./chunk-B3EZOXNU.mjs';import {c as c$1}from'./chunk-3WKDIXCM.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$5}from'./chunk-4QEH5CGK.mjs';import {MinusIcon,PlusIcon}from'@baseline-ui/icons/8';import {ReadOnlyIcon,ErrorCircleFilledIcon}from'@baseline-ui/icons/16';import M,{useMemo}from'react';import {jsxs,jsx}from'react/jsx-runtime';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -1,4 +1,4 @@
1
- import {a as a$p}from'./chunk-JI4SJ53O.mjs';import {b as b$a}from'./chunk-VJUBKX3W.mjs';import {a as a$8}from'./chunk-FPFGTGUC.mjs';import {b as b$3}from'./chunk-HI44JQA7.mjs';import {a as a$n}from'./chunk-O7IU5NHN.mjs';import {a as a$q}from'./chunk-TDYBXLYP.mjs';import {b as b$6,a as a$l}from'./chunk-7TE4MFKC.mjs';import {b as b$4}from'./chunk-2F3CFR22.mjs';import {f}from'./chunk-AD3MLX6G.mjs';import {a as a$i}from'./chunk-5BAHJXOI.mjs';import {b as b$8,c as c$2}from'./chunk-TSHZ7JSR.mjs';import {a as a$6}from'./chunk-CLGLEEFO.mjs';import {a as a$j}from'./chunk-NGZRN4SF.mjs';import {a as a$o}from'./chunk-AK7XHUQW.mjs';import {a as a$f}from'./chunk-E22TWF63.mjs';import {a as a$g}from'./chunk-WTAJLO6E.mjs';import {a as a$h}from'./chunk-UDMNDUBO.mjs';import {b as b$9,e as e$1}from'./chunk-4RSUKS23.mjs';import {b as b$7,f as f$1}from'./chunk-UZ672WDX.mjs';import {a as a$m}from'./chunk-3DWFAHR2.mjs';import {a as a$a}from'./chunk-JZXLV6JU.mjs';import {a as a$d}from'./chunk-R6TFTLMV.mjs';import {c as c$1,b as b$1}from'./chunk-DZDZZRWE.mjs';import {b as b$b}from'./chunk-TUJLNJPJ.mjs';import {a as a$9}from'./chunk-O7XK2WIX.mjs';import {a as a$b}from'./chunk-VGFPT43C.mjs';import {a as a$k}from'./chunk-CIPPPD6E.mjs';import {a as a$c}from'./chunk-5IC46G5J.mjs';import {b as b$5,j as j$1}from'./chunk-MBRNO6IW.mjs';import {a as a$1}from'./chunk-FPM5UJRF.mjs';import {a as a$4}from'./chunk-RSKKEGJZ.mjs';import {a as a$2}from'./chunk-STMDFIUL.mjs';import {j}from'./chunk-KUDCYGII.mjs';import {a as a$3}from'./chunk-B3EZOXNU.mjs';import {e}from'./chunk-PPHSLODC.mjs';import {b,c}from'./chunk-3WKDIXCM.mjs';import {c as c$3}from'./chunk-ETM4MNG4.mjs';import {a as a$7,b as b$2,j as j$2,h}from'./chunk-SD43KVTU.mjs';import {a as a$e}from'./chunk-IXRSSEHQ.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$5}from'./chunk-4QEH5CGK.mjs';import {BoldIcon,ItalicIcon,UnderlineIcon,ArrowUpCircleFilledIcon,AtIcon,XCircleFilledIcon,LinkIcon,XIcon}from'@baseline-ui/icons/20';import {layoutSprinkleValues,sprinkles}from'@baseline-ui/tokens';import mt,{useCallback,useImperativeHandle,useEffect,useRef,useState,useMemo,useLayoutEffect,useId,useContext,Fragment as Fragment$1}from'react';import {useGranularLayoutEffect}from'granular-hooks';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Kr from'just-camel-case';import {QuestionmarkCircleIcon,TextIcon,HighlightTextIcon}from'@baseline-ui/icons/24';import*as Fo from'dompurify';import ti from'just-kebab-case';import {createPortal}from'react-dom';/**
1
+ import {a as a$p}from'./chunk-JI4SJ53O.mjs';import {a as a$8}from'./chunk-USUPPN73.mjs';import {b as b$3}from'./chunk-BPW4QRPV.mjs';import {a as a$n}from'./chunk-O7IU5NHN.mjs';import {a as a$q}from'./chunk-TDYBXLYP.mjs';import {b as b$6,a as a$l}from'./chunk-AN26QORL.mjs';import {b as b$4}from'./chunk-TTVYMCU3.mjs';import {f}from'./chunk-6GMU63H2.mjs';import {a as a$i}from'./chunk-5BAHJXOI.mjs';import {b as b$a}from'./chunk-HZM2XZP4.mjs';import {b as b$8,c as c$2}from'./chunk-XQC3DSTW.mjs';import {a as a$6}from'./chunk-FCKJCFMD.mjs';import {a as a$j}from'./chunk-NGZRN4SF.mjs';import {a as a$o}from'./chunk-7EQIV4GX.mjs';import {a as a$f}from'./chunk-QXXKOFWM.mjs';import {a as a$g}from'./chunk-O6FPWOHR.mjs';import {a as a$h}from'./chunk-DO5YROCG.mjs';import {b as b$9,e as e$1}from'./chunk-YYU46XNM.mjs';import {b as b$7,f as f$1}from'./chunk-UZ672WDX.mjs';import {a as a$m}from'./chunk-3DWFAHR2.mjs';import {a as a$a}from'./chunk-JZXLV6JU.mjs';import {a as a$d}from'./chunk-R6TFTLMV.mjs';import {c as c$1,b as b$1}from'./chunk-7MLFM55C.mjs';import {b as b$b}from'./chunk-AFOW62QN.mjs';import {a as a$9}from'./chunk-O7XK2WIX.mjs';import {a as a$b}from'./chunk-DAI7V4TE.mjs';import {a as a$k}from'./chunk-CIPPPD6E.mjs';import {a as a$c}from'./chunk-5IC46G5J.mjs';import {b as b$5,j as j$1}from'./chunk-MBRNO6IW.mjs';import {a as a$1}from'./chunk-FPM5UJRF.mjs';import {a as a$4}from'./chunk-RSKKEGJZ.mjs';import {a as a$2}from'./chunk-STMDFIUL.mjs';import {j}from'./chunk-KUDCYGII.mjs';import {a as a$3}from'./chunk-B3EZOXNU.mjs';import {e}from'./chunk-PPHSLODC.mjs';import {b,c}from'./chunk-3WKDIXCM.mjs';import {c as c$3}from'./chunk-ETM4MNG4.mjs';import {a as a$7,b as b$2,j as j$2,h}from'./chunk-SD43KVTU.mjs';import {a as a$e}from'./chunk-UBLCUHRL.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$5}from'./chunk-4QEH5CGK.mjs';import {BoldIcon,ItalicIcon,UnderlineIcon,ArrowUpCircleFilledIcon,AtIcon,XCircleFilledIcon,LinkIcon,XIcon}from'@baseline-ui/icons/20';import {layoutSprinkleValues,sprinkles}from'@baseline-ui/tokens';import mt,{useCallback,useImperativeHandle,useEffect,useRef,useState,useMemo,useLayoutEffect,useId,useContext,Fragment as Fragment$1}from'react';import {useGranularLayoutEffect}from'granular-hooks';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Kr from'just-camel-case';import {QuestionmarkCircleIcon,TextIcon,HighlightTextIcon}from'@baseline-ui/icons/24';import*as Fo from'dompurify';import ti from'just-kebab-case';import {createPortal}from'react-dom';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -7,23 +7,23 @@ import {a as a$p}from'./chunk-JI4SJ53O.mjs';import {b as b$a}from'./chunk-VJUBKX
7
7
  * This notice may not be removed from this file.
8
8
  *
9
9
  */
10
- var yo="f6jv6bm",Eo="_1yep5z64u _1yep5z64v _1yep5z64w _1yep5z676 _1yep5z677 _1yep5z678 _1yep5z6k8 _1yep5z6k9 _1yep5z6ka",Be="_1yep5z689 _1yep5z68a _1yep5z68b _1yep5z65x _1yep5z65y _1yep5z65z",vo=a({defaultClassName:"f6jv6b0 _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6g9",variantClassNames:{isInline:{true:"f6jv6b1"},isMinimal:{true:"_1yep5z6160 _1yep5z6161 _1yep5z6162 _1yep5z6w4 _1yep5z6w5 _1yep5z6w6 _1yep5z616i _1yep5z616j _1yep5z616k",false:"_1yep5z6163 _1yep5z6164 _1yep5z6165"}},defaultVariants:{},compoundVariants:[[{isInline:true,isMinimal:false},"_1yep5z61jn _1yep5z61jo _1yep5z61jp _1yep5z61kb _1yep5z61kc _1yep5z61kd _1yep5z61kz _1yep5z61l0 _1yep5z61l1 _1yep5z61ln _1yep5z61lo _1yep5z61lp _1yep5z61vj _1yep5z61vh _1yep5z61qi"]]}),ot=a({defaultClassName:"f6jv6b4 _1yep5z69 _1yep5z6a _1yep5z6b _1yep5z62l _1yep5z62m _1yep5z62n _1yep5z63r _1yep5z63s _1yep5z63t _1yep5z61f _1yep5z61g _1yep5z61h _1yep5z6e3 _1yep5z6ey _1yep5z6m6",variantClassNames:{isDisabled:{true:"f6jv6b5 _1yep5z611l"}},defaultVariants:{},compoundVariants:[]}),Ro="f6jv6b6",To="f6jv6bj _1yep5z6x7 _1yep5z6x8 _1yep5z6x9 _1yep5z6xv _1yep5z6xw _1yep5z6xx _1yep5z6yj _1yep5z6yk _1yep5z6yl _1yep5z6z7 _1yep5z6z8 _1yep5z6z9",ko="f6jv6bk";var Co="f6jv6bn _1yep5z63l _1yep5z63m _1yep5z63n _1yep5z619 _1yep5z61a _1yep5z61b _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6jb _1yep5z6jc _1yep5z6jd _1yep5z6me _1yep5z6m9 _1yep5z6m7 _1yep5z6id _1yep5z6ey",Mo=a({defaultClassName:"f6jv6bg _1yep5z63r _1yep5z63s _1yep5z63t _1yep5z61f _1yep5z61g _1yep5z61h _1yep5z63 _1yep5z64 _1yep5z65 _1yep5z62f _1yep5z62g _1yep5z62h _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z6jz _1yep5z6k0 _1yep5z6k1 _1yep5z69l _1yep5z69m _1yep5z69n _1yep5z6m6 _1yep5z6lq _1yep5z6lt _1yep5z6m5",variantClassNames:{isHovered:{true:"_1yep5z612u"},isDisabled:{true:"_1yep5z6zt"}},defaultVariants:{},compoundVariants:[]}),Lo="_1yep5z6ke _1yep5z6kf _1yep5z6kg",So="f6jv6bf f6jv6bb _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6j5 _1yep5z6j6 _1yep5z6j7 _1yep5z6ey _1yep5z6e3 _1yep5z6m3",zo=a({defaultClassName:"f6jv6bc _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z69l _1yep5z69m _1yep5z69n _1yep5z6kk _1yep5z6kl _1yep5z6km",variantClassNames:{isInline:{true:"_1yep5z6q7 _1yep5z6q8 _1yep5z6q9 _1yep5z6190 _1yep5z618y _1yep5z613z",false:"_1yep5z6qa _1yep5z6qb _1yep5z6qc _1yep5z6xm _1yep5z6xn _1yep5z6xo _1yep5z6ya _1yep5z6yb _1yep5z6yc _1yep5z6yy _1yep5z6yz _1yep5z6z0 _1yep5z6zm _1yep5z6zn _1yep5z6zo"}},defaultVariants:{},compoundVariants:[]}),Po="f6jv6bl",Do="f6jv6bb _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6j5 _1yep5z6j6 _1yep5z6j7 _1yep5z6ey",_t=a({defaultClassName:"f6jv6b7",variantClassNames:{isInline:{true:"f6jv6b8",false:"f6jv6b9"}},defaultVariants:{},compoundVariants:[]}),It="f6jv6ba _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z6jz _1yep5z6k0 _1yep5z6k1",rt="f6jv6bo";var Nt=mt.forwardRef(({value:t,defaultValue:e,onChange:n,placeholder:o,spellCheck:r,textBoxRef:i,isInline:l,isMinimal:s,isDisabled:a,editableContentAriaLabel:c$1,editorHandle:u,autoFocus:d,saveOnEnter:f,onSave:p},m)=>{let h=mt.useRef(null),[C,S]=a$1(t,e||"",n),U=useCallback(b=>{S(b.currentTarget.value||"");},[S]),M=useCallback(b=>{(f&&b.key==="Enter"&&!b.shiftKey||(b.ctrlKey||b.metaKey)&&b.key==="Enter")&&(b.preventDefault(),p());},[f,p]);useImperativeHandle(m,()=>({clear:()=>{S("");}}));let O=useCallback(b=>{b.currentTarget.style.height="16px",b.currentTarget.style.height=b.currentTarget.scrollHeight+"px";},[]);useGranularLayoutEffect(()=>{let b=h.current;b&&(b.style.height="16px",b.style.height=b.scrollHeight+"px");},[s],[C]),useImperativeHandle(u,()=>({setCaretPosition:b=>{h.current&&(h.current.focus(),h.current.setSelectionRange(b,b));},focus:()=>{h.current&&h.current.focus();}}));let z=d===true||d==="start"||d==="end",L=typeof d=="string"?d:void 0;useEffect(()=>{if(L&&h.current){let b=L==="start"?0:L==="end"?h.current.value.length:void 0;b!==void 0&&h.current.setSelectionRange(b,b);}},[L]);let{focusProps:q,isFocused:$,isFocusVisible:te}=a$2(),{hoverProps:g,isHovered:y}=a$3({}),v=a$4({"data-focus-visible":te,"data-hovered":y,"data-focused":$});return jsx("textarea",{...c(q,g,v),ref:b(h,i),className:a$5({[ot()]:!s,[_t({isInline:l})]:!s,[Do]:!s,[So]:s},"BaselineUI-Editor-PlainEditorEditingArea"),autoFocus:z,onChange:U,disabled:a,onInput:O,value:C,placeholder:o,spellCheck:r,"aria-label":c$1,onKeyDown:M})});Nt.displayName="PlainEditor";var wo=[["Toolbar Focus","Alt+F10"],["Bold","Ctrl+B"],["Italic","Ctrl+I"],["Underline","Ctrl+U"],["Select All","Ctrl+A"],["Cut","Ctrl+X"],["Copy","Ctrl+C"],["Paste","Ctrl+V"],["Undo","Ctrl+Z"],["Redo","Ctrl+Shift+Z"],["Submit","Ctrl+Enter"],["Open Help Dialog","Ctrl+Shift+H"]],{dialog:{row:it}}=layoutSprinkleValues,Ao=({isOpen:t,onClose:e,toolbarFocusLabel:n,helpLabel:o,closeLabel:r,actionLabel:i,shortcutLabel:l,boldLabel:s,italicLabel:a,underlineLabel:c,selectAllLabel:u,cutLabel:d,copyLabel:f,pasteLabel:p,undoLabel:m,redoLabel:h,openHelpDialogLabel:C,submitLabel:S})=>{let{formatMessage:U}=b$1(),M=c$3(),O={toolbarFocus:n,help:o,close:r,action:i,shortcut:l,bold:s,italic:a,underline:c,selectAll:u,cut:d,copy:f,paste:p,undo:m,redo:h,openHelpDialog:C,submit:S},z=L=>O[L]??U(Ur[L]);return jsx(b$9,{isOpen:t,onOpenChange:L=>{L||e();},children:jsx(e$1,{enableDrawer:"auto",style:{zIndex:999999},children:jsxs(a$h,{"aria-labelledby":M,className:To,drawerBackground:"subtle",children:[jsxs(a$9,{paddingLeft:it.padding.horizontal.lg,paddingRight:it.padding.horizontal.sm,display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",backgroundColor:"background.primary.subtle",className:ko,children:[jsx(a$m,{id:M,elementType:"h3",type:"title",size:"md",children:z("help")}),jsx(a$b,{icon:XIcon,size:"md",variant:"secondary","aria-label":z("close"),"data-testid":"editor-help-dialog-close-button",onPress:e})]}),jsx(a$a,{className:Po}),jsxs(a$9,{paddingX:it.padding.horizontal.lg,role:"table","aria-labelledby":M,backgroundColor:"background.primary.subtle",children:[jsx("div",{role:"rowgroup",children:jsxs(a$9,{role:"row",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingY:it.padding.vertical.md,color:"text.primary",children:[jsx("h6",{className:sprinkles({typography:"heading.h6.semibold"}),role:"columnheader",children:z("action")}),jsx("h6",{className:sprinkles({typography:"heading.h6.semibold"}),role:"columnheader",style:{textTransform:"capitalize"},children:z("shortcut")})]})}),jsx("div",{role:"rowgroup",children:wo.map(([L,q],$)=>jsxs(Fragment$1,{children:[jsxs(a$9,{role:"row",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingY:it.padding.vertical.xs,style:{minHeight:40},children:[jsx(a$m,{type:"subtitle",size:"sm",role:"cell",children:z(Kr(L))}),jsx(a$m,{elementType:"kbd",type:"subtitle",size:"sm",role:"cell",children:a$n(q,true)})]}),$!==wo.length-1&&jsx(a$a,{})]},L))})]})]})})})},Ur=c$1({toolbarFocus:{id:"bui.editor.toolbarFocus",defaultMessage:"Toolbar Focus"},help:{id:"bui.editor.help",defaultMessage:"Help"},close:{id:"bui.editor.close",defaultMessage:"Close"},action:{id:"bui.editor.action",defaultMessage:"Action"},shortcut:{id:"bui.editor.shortcut",defaultMessage:"Shortcut"},bold:{id:"bui.editor.bold",defaultMessage:"Bold"},italic:{id:"bui.editor.italic",defaultMessage:"Italic"},underline:{id:"bui.editor.underline",defaultMessage:"Underline"},selectAll:{id:"bui.editor.selectAll",defaultMessage:"Select All"},cut:{id:"bui.editor.cut",defaultMessage:"Cut"},copy:{id:"bui.editor.copy",defaultMessage:"Copy"},paste:{id:"bui.editor.paste",defaultMessage:"Paste"},undo:{id:"bui.editor.undo",defaultMessage:"Undo"},redo:{id:"bui.editor.redo",defaultMessage:"Redo"},openHelpDialog:{id:"bui.editor.openHelpDialog",defaultMessage:"Open Help Dialog"},submit:{id:"bui.editor.submit",defaultMessage:"Submit"}});var Vr=a$6("#ffffff00").toString("hexa"),cn=[{label:"Red",color:"#ff0000"},{label:"Green",color:"#00ff00"},{label:"Blue",color:"#0000ff"},{label:"Yellow",color:"#ffff00"},{label:"Cyan",color:"#00ffff"},{label:"Magenta",color:"#ff00ff"},{label:"Black",color:"#000000"},{label:"White",color:"#ffffff"},{label:"Gray",color:"#808080"},{label:"Orange",color:"#ffa500"},{label:"Brown",color:"#a52a2a"},{label:"Purple",color:"#800080"}];[...cn,{label:"Transparent",color:Vr}];var je="p",Z="a",ae="mention",Ee="mention_input";function dn(t,e){return typeof t=="object"&&t!==null&&"type"in t&&t.type===e}function x(t){return typeof t=="object"&&t!==null&&"text"in t&&!("type"in t)}function k(t){return dn(t,Z)}function ce(t){return dn(t,ae)}function he(t){return dn(t,Ee)}function J(t){return ce(t)||he(t)}function Ke(){return [{type:je,children:[{text:""}]}]}function wt(t,e){return t.bold===e.bold&&t.italic===e.italic&&t.underline===e.underline&&b$a(t.color,e.color)&&b$a(t.backgroundColor,e.backgroundColor)}function At(t,e){let n=false;for(let i=0;i<t.length;i++){let l=t[i];if(l.text===""&&!(e&&t.length===1)){n=true;break}if(i>0&&wt(t[i-1],l)){n=true;break}}if(!n)return t;let o=t.filter(i=>i.text!==""),r=[];for(let i of o){let l=r.at(-1);l!==void 0&&wt(l,i)?r[r.length-1]={...l,text:l.text+i.text}:r.push(i);}return r}function Wr(t){let e=(i,l)=>i===0&&l===t.length||i>0&&J(t[i-1]),n=false,o=-1;for(let i=0;i<=t.length;i++){let l=t[i],s=i<t.length&&x(l);if(s&&o===-1)o=i;else if(!s&&o!==-1){let a=t.slice(o,i);if(At(a,e(o,i))!==a){n=true;break}o=-1;}}if(!n)return t;let r=[];o=-1;for(let i=0;i<=t.length;i++){let l=t[i],s=i<t.length&&x(l);if(s&&o===-1)o=i;else if(!s&&o!==-1){let a=t.slice(o,i),c=At(a,e(o,i));for(let u of c)r.push(u);o=-1;}!s&&i<t.length&&r.push(l);}return r}function qr(t){let e=false;for(let o=1;o<t.length;o++){let r=t[o-1],i=t[o];if(k(r)&&k(i)&&r.url===i.url){e=true;break}}if(!e)return t;let n=[];for(let o of t){let r=n.at(-1);if(k(o)&&r!==void 0&&k(r)&&r.url===o.url){let i=At([...r.children,...o.children],false);n[n.length-1]={...r,children:i};}else n.push(o);}return n}function $r(t){let e=At(t.children,t.children.length===1);return e.reduce((o,r)=>o+r.text,"")===""?null:e===t.children?t:{...t,children:e}}function Gr(t){let e=false,n=[];for(let a of t)if(k(a)){let c=$r(a);c===null?e=true:(n.push(c),c!==a&&(e=true));}else n.push(a);let o=e?n:t,r=Wr(o),i=qr(r),l=(a,c)=>J(a[c])&&(c===a.length-1||!x(a[c+1])),s=i;if(i.some((a,c)=>l(i,c))){s=[];for(let[a,c]of i.entries())s.push(c),l(i,a)&&s.push({text:""});}return s.length===0?[{text:""}]:s===o&&!e?t:s}function _(t){if(t.length===0)return Ke();let e=false,n=t.map(o=>{let r=Gr(o.children);return r===o.children?o:(e=true,{...o,children:r})});return e?n:t}function F(t){if(x(t))return t.text.length;switch(t.type){case Z:{let e=0;for(let n=0;n<t.children.length;n++)e+=t.children[n].text.length;return e}case ae:return t.displayName.length;case Ee:return t.children[0].text.length;default:return t}}function Fe(t){if(t.length===0)return 0;let e=t.length-1;for(let n of t)for(let o of n.children)e+=F(o);return e}var Xr=1,fn=3;function st(t){return t.nodeType===Xr}function Ue(t,e){return t.tagName.toLowerCase()===e}function Yr(t){if(!st(t))return false;let e=t.tagName.toLowerCase();return e==="p"||e==="div"}function Zr(t){return st(t)&&t.querySelector("p, div")!==null}var Jr=new RegExp("["+String.fromCodePoint(8203)+String.fromCodePoint(65279)+"]","g"),Qr=String.fromCodePoint(160);function Le(t){return t.replaceAll(Jr,"").replaceAll(Qr," ")}function Bo(t,e){let n={...e},o=t.tagName.toLowerCase();(o==="b"||o==="strong")&&(n.bold=true),(o==="i"||o==="em")&&(n.italic=true),o==="u"&&(n.underline=true);let r=t.style;if(r){let i=r.fontWeight;(i==="bold"||Number.parseInt(i,10)>=600&&i!=="")&&(n.bold=true),r.fontStyle==="italic"&&(n.italic=true),r.textDecoration?.includes("underline")&&(n.underline=true);let l=r.color;l&&(n.color=l);let s=r.backgroundColor;s&&(n.backgroundColor=s);}return n}function Ot(t,e,n,o){for(let r=0;r<t.childNodes.length;r++){let i=t.childNodes[r];if(i.nodeType===fn){let s=i.nodeValue??"",a=Le(s);a.length>0&&o.push(jo(a,e));continue}if(!st(i))continue;if(Ue(i,"span")&&i.dataset.userId!==void 0){let s=i.dataset.userId??"",a=i.textContent??"",c=a.startsWith("@")?a.slice(1):a;o.push({type:ae,value:s,displayName:c,children:[{text:""}]});continue}if(Ue(i,"span")&&i.dataset.mentionAnchor!==void 0){let s=i.textContent??"";o.push({type:Ee,children:[{text:s}]});continue}if(Ue(i,"a")){{let s=i.getAttribute("href")??"",a=[];Ho(i,e,a);let c=pn(a);c.some(d=>d.text.length>0)&&o.push({type:Z,url:s,children:c});}continue}if(Ue(i,"br")){o.push({text:"\0BR\0"});continue}let l=Bo(i,e);Ot(i,l,n,o);}}function Ho(t,e,n){for(let o=0;o<t.childNodes.length;o++){let r=t.childNodes[o];if(r.nodeType===fn){let l=r.nodeValue??"",s=Le(l);s.length>0&&n.push(jo(s,e));continue}if(!st(r))continue;if(Ue(r,"br")){n.push({text:"\0BR\0"});continue}let i=Bo(r,e);Ho(r,i,n);}}function jo(t,e){let n={text:t};return e.bold&&(n.bold=true),e.italic&&(n.italic=true),e.underline&&(n.underline=true),e.color&&(n.color=e.color),e.backgroundColor&&(n.backgroundColor=e.backgroundColor),n}var Ko="\0BR\0";function pn(t){let e=[...t];if(e.length===1&&un(e[0]))return [{text:""}];let n=e.length,o=0;for(;o<n&&un(e[n-1-o]);)o+=1;let r=o>=2?o-1:0;n-=o;let i=[];for(let l=0;l<n;l++){let s=e[l];un(s)?Oo(i):i.push(s);}for(let l=0;l<r;l++)Oo(i);return i}function un(t){return "text"in t&&t.text===Ko}function Oo(t){let e=t.at(-1);e!==void 0&&"text"in e&&!("type"in e)?e.text+=`
10
+ var yo="f6jv6bm",Eo="_1yep5z64u _1yep5z64v _1yep5z64w _1yep5z676 _1yep5z677 _1yep5z678 _1yep5z6k8 _1yep5z6k9 _1yep5z6ka",He="_1yep5z689 _1yep5z68a _1yep5z68b _1yep5z65x _1yep5z65y _1yep5z65z",vo=a({defaultClassName:"f6jv6b0 _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6g9",variantClassNames:{isInline:{true:"f6jv6b1"},isMinimal:{true:"_1yep5z6160 _1yep5z6161 _1yep5z6162 _1yep5z6w4 _1yep5z6w5 _1yep5z6w6 _1yep5z616i _1yep5z616j _1yep5z616k",false:"_1yep5z6163 _1yep5z6164 _1yep5z6165"}},defaultVariants:{},compoundVariants:[[{isInline:true,isMinimal:false},"_1yep5z61jn _1yep5z61jo _1yep5z61jp _1yep5z61kb _1yep5z61kc _1yep5z61kd _1yep5z61kz _1yep5z61l0 _1yep5z61l1 _1yep5z61ln _1yep5z61lo _1yep5z61lp _1yep5z61vj _1yep5z61vh _1yep5z61qi"]]}),ot=a({defaultClassName:"f6jv6b4 _1yep5z69 _1yep5z6a _1yep5z6b _1yep5z62l _1yep5z62m _1yep5z62n _1yep5z63r _1yep5z63s _1yep5z63t _1yep5z61f _1yep5z61g _1yep5z61h _1yep5z6e3 _1yep5z6ey _1yep5z6m6",variantClassNames:{isDisabled:{true:"f6jv6b5 _1yep5z611l"}},defaultVariants:{},compoundVariants:[]}),Ro="f6jv6b6",To="f6jv6bj _1yep5z6x7 _1yep5z6x8 _1yep5z6x9 _1yep5z6xv _1yep5z6xw _1yep5z6xx _1yep5z6yj _1yep5z6yk _1yep5z6yl _1yep5z6z7 _1yep5z6z8 _1yep5z6z9",ko="f6jv6bk";var Co="f6jv6bn _1yep5z63l _1yep5z63m _1yep5z63n _1yep5z619 _1yep5z61a _1yep5z61b _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6jb _1yep5z6jc _1yep5z6jd _1yep5z6me _1yep5z6m9 _1yep5z6m7 _1yep5z6id _1yep5z6ey",Mo=a({defaultClassName:"f6jv6bg _1yep5z63r _1yep5z63s _1yep5z63t _1yep5z61f _1yep5z61g _1yep5z61h _1yep5z63 _1yep5z64 _1yep5z65 _1yep5z62f _1yep5z62g _1yep5z62h _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z6jz _1yep5z6k0 _1yep5z6k1 _1yep5z69l _1yep5z69m _1yep5z69n _1yep5z6m6 _1yep5z6lq _1yep5z6lt _1yep5z6m5",variantClassNames:{isHovered:{true:"_1yep5z612u"},isDisabled:{true:"_1yep5z6zt"}},defaultVariants:{},compoundVariants:[]}),Lo="_1yep5z6ke _1yep5z6kf _1yep5z6kg",So="f6jv6bf f6jv6bb _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6j5 _1yep5z6j6 _1yep5z6j7 _1yep5z6ey _1yep5z6e3 _1yep5z6m3",zo=a({defaultClassName:"f6jv6bc _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6bu _1yep5z6bv _1yep5z6bw _1yep5z6ci _1yep5z6cj _1yep5z6ck _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z69l _1yep5z69m _1yep5z69n _1yep5z6kk _1yep5z6kl _1yep5z6km",variantClassNames:{isInline:{true:"_1yep5z6q7 _1yep5z6q8 _1yep5z6q9 _1yep5z6190 _1yep5z618y _1yep5z613z",false:"_1yep5z6qa _1yep5z6qb _1yep5z6qc _1yep5z6xm _1yep5z6xn _1yep5z6xo _1yep5z6ya _1yep5z6yb _1yep5z6yc _1yep5z6yy _1yep5z6yz _1yep5z6z0 _1yep5z6zm _1yep5z6zn _1yep5z6zo"}},defaultVariants:{},compoundVariants:[]}),Po="f6jv6bl",Do="f6jv6bb _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6j5 _1yep5z6j6 _1yep5z6j7 _1yep5z6ey",_t=a({defaultClassName:"f6jv6b7",variantClassNames:{isInline:{true:"f6jv6b8",false:"f6jv6b9"}},defaultVariants:{},compoundVariants:[]}),It="f6jv6ba _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z6jz _1yep5z6k0 _1yep5z6k1",rt="f6jv6bo";var Nt=mt.forwardRef(({value:t,defaultValue:e,onChange:n,placeholder:o,spellCheck:r,textBoxRef:i,isInline:l,isMinimal:s,isDisabled:a,editableContentAriaLabel:c$1,editorHandle:u,autoFocus:d,saveOnEnter:f,onSave:p},m)=>{let h=mt.useRef(null),[C,D]=a$1(t,e||"",n),V=useCallback(b=>{D(b.currentTarget.value||"");},[D]),M=useCallback(b=>{(f&&b.key==="Enter"&&!b.shiftKey||(b.ctrlKey||b.metaKey)&&b.key==="Enter")&&(b.preventDefault(),p());},[f,p]);useImperativeHandle(m,()=>({clear:()=>{D("");}}));let B=useCallback(b=>{b.currentTarget.style.height="16px",b.currentTarget.style.height=b.currentTarget.scrollHeight+"px";},[]);useGranularLayoutEffect(()=>{let b=h.current;b&&(b.style.height="16px",b.style.height=b.scrollHeight+"px");},[s],[C]),useImperativeHandle(u,()=>({setCaretPosition:b=>{h.current&&(h.current.focus(),h.current.setSelectionRange(b,b));},focus:()=>{h.current&&h.current.focus();}}));let S=d===true||d==="start"||d==="end",L=typeof d=="string"?d:void 0;useEffect(()=>{if(L&&h.current){let b=L==="start"?0:L==="end"?h.current.value.length:void 0;b!==void 0&&h.current.setSelectionRange(b,b);}},[L]);let{focusProps:q,isFocused:$,isFocusVisible:te}=a$2(),{hoverProps:g,isHovered:y}=a$3({}),R=a$4({"data-focus-visible":te,"data-hovered":y,"data-focused":$});return jsx("textarea",{...c(q,g,R),ref:b(h,i),className:a$5({[ot()]:!s,[_t({isInline:l})]:!s,[Do]:!s,[So]:s},"BaselineUI-Editor-PlainEditorEditingArea"),autoFocus:S,onChange:V,disabled:a,onInput:B,value:C,placeholder:o,spellCheck:r,"aria-label":c$1,onKeyDown:M})});Nt.displayName="PlainEditor";var wo=[["Toolbar Focus","Alt+F10"],["Bold","Ctrl+B"],["Italic","Ctrl+I"],["Underline","Ctrl+U"],["Select All","Ctrl+A"],["Cut","Ctrl+X"],["Copy","Ctrl+C"],["Paste","Ctrl+V"],["Undo","Ctrl+Z"],["Redo","Ctrl+Shift+Z"],["Submit","Ctrl+Enter"],["Open Help Dialog","Ctrl+Shift+H"]],{dialog:{row:it}}=layoutSprinkleValues,Ao=({isOpen:t,onClose:e,toolbarFocusLabel:n,helpLabel:o,closeLabel:r,actionLabel:i,shortcutLabel:l,boldLabel:s,italicLabel:a,underlineLabel:c,selectAllLabel:u,cutLabel:d,copyLabel:f,pasteLabel:p,undoLabel:m,redoLabel:h,openHelpDialogLabel:C,submitLabel:D})=>{let{formatMessage:V}=b$1(),M=c$3(),B={toolbarFocus:n,help:o,close:r,action:i,shortcut:l,bold:s,italic:a,underline:c,selectAll:u,cut:d,copy:f,paste:p,undo:m,redo:h,openHelpDialog:C,submit:D},S=L=>B[L]??V(Ur[L]);return jsx(b$9,{isOpen:t,onOpenChange:L=>{L||e();},children:jsx(e$1,{enableDrawer:"auto",style:{zIndex:999999},children:jsxs(a$h,{"aria-labelledby":M,className:To,drawerBackground:"subtle",children:[jsxs(a$9,{paddingLeft:it.padding.horizontal.lg,paddingRight:it.padding.horizontal.sm,display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",backgroundColor:"background.primary.subtle",className:ko,children:[jsx(a$m,{id:M,elementType:"h3",type:"title",size:"md",children:S("help")}),jsx(a$b,{icon:XIcon,size:"md",variant:"secondary","aria-label":S("close"),"data-testid":"editor-help-dialog-close-button",onPress:e})]}),jsx(a$a,{className:Po}),jsxs(a$9,{paddingX:it.padding.horizontal.lg,role:"table","aria-labelledby":M,backgroundColor:"background.primary.subtle",children:[jsx("div",{role:"rowgroup",children:jsxs(a$9,{role:"row",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingY:it.padding.vertical.md,color:"text.primary",children:[jsx("h6",{className:sprinkles({typography:"heading.h6.semibold"}),role:"columnheader",children:S("action")}),jsx("h6",{className:sprinkles({typography:"heading.h6.semibold"}),role:"columnheader",style:{textTransform:"capitalize"},children:S("shortcut")})]})}),jsx("div",{role:"rowgroup",children:wo.map(([L,q],$)=>jsxs(Fragment$1,{children:[jsxs(a$9,{role:"row",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingY:it.padding.vertical.xs,style:{minHeight:40},children:[jsx(a$m,{type:"subtitle",size:"sm",role:"cell",children:S(Kr(L))}),jsx(a$m,{elementType:"kbd",type:"subtitle",size:"sm",role:"cell",children:a$n(q,true)})]}),$!==wo.length-1&&jsx(a$a,{})]},L))})]})]})})})},Ur=c$1({toolbarFocus:{id:"bui.editor.toolbarFocus",defaultMessage:"Toolbar Focus"},help:{id:"bui.editor.help",defaultMessage:"Help"},close:{id:"bui.editor.close",defaultMessage:"Close"},action:{id:"bui.editor.action",defaultMessage:"Action"},shortcut:{id:"bui.editor.shortcut",defaultMessage:"Shortcut"},bold:{id:"bui.editor.bold",defaultMessage:"Bold"},italic:{id:"bui.editor.italic",defaultMessage:"Italic"},underline:{id:"bui.editor.underline",defaultMessage:"Underline"},selectAll:{id:"bui.editor.selectAll",defaultMessage:"Select All"},cut:{id:"bui.editor.cut",defaultMessage:"Cut"},copy:{id:"bui.editor.copy",defaultMessage:"Copy"},paste:{id:"bui.editor.paste",defaultMessage:"Paste"},undo:{id:"bui.editor.undo",defaultMessage:"Undo"},redo:{id:"bui.editor.redo",defaultMessage:"Redo"},openHelpDialog:{id:"bui.editor.openHelpDialog",defaultMessage:"Open Help Dialog"},submit:{id:"bui.editor.submit",defaultMessage:"Submit"}});var Vr=a$6("#ffffff00").toString("hexa"),cn=[{label:"Red",color:"#ff0000"},{label:"Green",color:"#00ff00"},{label:"Blue",color:"#0000ff"},{label:"Yellow",color:"#ffff00"},{label:"Cyan",color:"#00ffff"},{label:"Magenta",color:"#ff00ff"},{label:"Black",color:"#000000"},{label:"White",color:"#ffffff"},{label:"Gray",color:"#808080"},{label:"Orange",color:"#ffa500"},{label:"Brown",color:"#a52a2a"},{label:"Purple",color:"#800080"}];[...cn,{label:"Transparent",color:Vr}];var Ke="p",Z="a",ae="mention",Ee="mention_input";function dn(t,e){return typeof t=="object"&&t!==null&&"type"in t&&t.type===e}function x(t){return typeof t=="object"&&t!==null&&"text"in t&&!("type"in t)}function k(t){return dn(t,Z)}function ce(t){return dn(t,ae)}function me(t){return dn(t,Ee)}function J(t){return ce(t)||me(t)}function Fe(){return [{type:Ke,children:[{text:""}]}]}function wt(t,e){return t.bold===e.bold&&t.italic===e.italic&&t.underline===e.underline&&b$a(t.color,e.color)&&b$a(t.backgroundColor,e.backgroundColor)}function At(t,e){let n=false;for(let i=0;i<t.length;i++){let l=t[i];if(l.text===""&&!(e&&t.length===1)){n=true;break}if(i>0&&wt(t[i-1],l)){n=true;break}}if(!n)return t;let o=t.filter(i=>i.text!==""),r=[];for(let i of o){let l=r.at(-1);l!==void 0&&wt(l,i)?r[r.length-1]={...l,text:l.text+i.text}:r.push(i);}return r}function Wr(t){let e=(i,l)=>i===0&&l===t.length||i>0&&J(t[i-1]),n=false,o=-1;for(let i=0;i<=t.length;i++){let l=t[i],s=i<t.length&&x(l);if(s&&o===-1)o=i;else if(!s&&o!==-1){let a=t.slice(o,i);if(At(a,e(o,i))!==a){n=true;break}o=-1;}}if(!n)return t;let r=[];o=-1;for(let i=0;i<=t.length;i++){let l=t[i],s=i<t.length&&x(l);if(s&&o===-1)o=i;else if(!s&&o!==-1){let a=t.slice(o,i),c=At(a,e(o,i));for(let u of c)r.push(u);o=-1;}!s&&i<t.length&&r.push(l);}return r}function qr(t){let e=false;for(let o=1;o<t.length;o++){let r=t[o-1],i=t[o];if(k(r)&&k(i)&&r.url===i.url){e=true;break}}if(!e)return t;let n=[];for(let o of t){let r=n.at(-1);if(k(o)&&r!==void 0&&k(r)&&r.url===o.url){let i=At([...r.children,...o.children],false);n[n.length-1]={...r,children:i};}else n.push(o);}return n}function $r(t){let e=At(t.children,t.children.length===1);return e.reduce((o,r)=>o+r.text,"")===""?null:e===t.children?t:{...t,children:e}}function Gr(t){let e=false,n=[];for(let a of t)if(k(a)){let c=$r(a);c===null?e=true:(n.push(c),c!==a&&(e=true));}else n.push(a);let o=e?n:t,r=Wr(o),i=qr(r),l=(a,c)=>J(a[c])&&(c===a.length-1||!x(a[c+1])),s=i;if(i.some((a,c)=>l(i,c))){s=[];for(let[a,c]of i.entries())s.push(c),l(i,a)&&s.push({text:""});}return s.length===0?[{text:""}]:s===o&&!e?t:s}function _(t){if(t.length===0)return Fe();let e=false,n=t.map(o=>{let r=Gr(o.children);return r===o.children?o:(e=true,{...o,children:r})});return e?n:t}function U(t){if(x(t))return t.text.length;switch(t.type){case Z:{let e=0;for(let n=0;n<t.children.length;n++)e+=t.children[n].text.length;return e}case ae:return t.displayName.length;case Ee:return t.children[0].text.length;default:return t}}function Ue(t){if(t.length===0)return 0;let e=t.length-1;for(let n of t)for(let o of n.children)e+=U(o);return e}var Xr=1,fn=3;function st(t){return t.nodeType===Xr}function Ve(t,e){return t.tagName.toLowerCase()===e}function Yr(t){if(!st(t))return false;let e=t.tagName.toLowerCase();return e==="p"||e==="div"}function Zr(t){return st(t)&&t.querySelector("p, div")!==null}var Jr=new RegExp("["+String.fromCodePoint(8203)+String.fromCodePoint(65279)+"]","g"),Qr=String.fromCodePoint(160);function Le(t){return t.replaceAll(Jr,"").replaceAll(Qr," ")}function Bo(t,e){let n={...e},o=t.tagName.toLowerCase();(o==="b"||o==="strong")&&(n.bold=true),(o==="i"||o==="em")&&(n.italic=true),o==="u"&&(n.underline=true);let r=t.style;if(r){let i=r.fontWeight;(i==="bold"||Number.parseInt(i,10)>=600&&i!=="")&&(n.bold=true),r.fontStyle==="italic"&&(n.italic=true),r.textDecoration?.includes("underline")&&(n.underline=true);let l=r.color;l&&(n.color=l);let s=r.backgroundColor;s&&(n.backgroundColor=s);}return n}function Ot(t,e,n,o){for(let r=0;r<t.childNodes.length;r++){let i=t.childNodes[r];if(i.nodeType===fn){let s=i.nodeValue??"",a=Le(s);a.length>0&&o.push(jo(a,e));continue}if(!st(i))continue;if(Ve(i,"span")&&i.dataset.userId!==void 0){let s=i.dataset.userId??"",a=i.textContent??"",c=a.startsWith("@")?a.slice(1):a;o.push({type:ae,value:s,displayName:c,children:[{text:""}]});continue}if(Ve(i,"span")&&i.dataset.mentionAnchor!==void 0){let s=i.textContent??"";o.push({type:Ee,children:[{text:s}]});continue}if(Ve(i,"a")){{let s=i.getAttribute("href")??"",a=[];Ho(i,e,a);let c=pn(a);c.some(d=>d.text.length>0)&&o.push({type:Z,url:s,children:c});}continue}if(Ve(i,"br")){o.push({text:"\0BR\0"});continue}let l=Bo(i,e);Ot(i,l,n,o);}}function Ho(t,e,n){for(let o=0;o<t.childNodes.length;o++){let r=t.childNodes[o];if(r.nodeType===fn){let l=r.nodeValue??"",s=Le(l);s.length>0&&n.push(jo(s,e));continue}if(!st(r))continue;if(Ve(r,"br")){n.push({text:"\0BR\0"});continue}let i=Bo(r,e);Ho(r,i,n);}}function jo(t,e){let n={text:t};return e.bold&&(n.bold=true),e.italic&&(n.italic=true),e.underline&&(n.underline=true),e.color&&(n.color=e.color),e.backgroundColor&&(n.backgroundColor=e.backgroundColor),n}var Ko="\0BR\0";function pn(t){let e=[...t];if(e.length===1&&un(e[0]))return [{text:""}];let n=e.length,o=0;for(;o<n&&un(e[n-1-o]);)o+=1;let r=o>=2?o-1:0;n-=o;let i=[];for(let l=0;l<n;l++){let s=e[l];un(s)?Oo(i):i.push(s);}for(let l=0;l<r;l++)Oo(i);return i}function un(t){return "text"in t&&t.text===Ko}function Oo(t){let e=t.at(-1);e!==void 0&&"text"in e&&!("type"in e)?e.text+=`
11
11
  `:t.push({text:`
12
- `});}function ei(t){let e=[];Ot(t,{},false,e);let n=pn(e);return {type:je,children:n.length>0?n:[{text:""}]}}function Bt(t){let e=t.childNodes;if(e.length===0)return Ke();let n=[],o=[];function r(){if(o.length===0)return;let l=pn(o);n.push({type:je,children:l.length>0?l:[{text:""}]}),o=[];}function i(l){for(let s of l)if(Yr(s))r(),n.push(ei(s));else if(s.nodeType===fn){let a=s.nodeValue??"",c=Le(a);c.trim().length>0&&o.push({text:c});}else st(s)&&(Ue(s,"br")?o.push({text:Ko}):Zr(s)?(r(),i(s.childNodes)):Ot(s,{},false,o));}return i(e),r(),n.length===0?Ke():_(n)}function ni(t){return Object.entries(t).map(([e,n])=>`${ti(e)}:${n}`).filter(([,e])=>!!e).join(";")}function Uo(t){return "text"in t}function lt(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function de(t){let e=t.trim(),n=e.replaceAll(/[\u0000- ]/g,""),o=/^([a-z][a-z0-9+.-]*):/i.exec(n);if(!o)return e;let r=o[1].toLowerCase();return new Set(["javascript","data","vbscript"]).has(r)?"":e}function hn(t){let e=t.trim();if(/^[/#?.]/.test(e))return e;let n=/^([^/:?#]+):\d+(?:[/?#]|$)/.exec(e)?.[1];if(n==="localhost"||n?.includes("."))return `https://${e}`;try{return new URL(e),e}catch{return `https://${e}`}}function Vo(t,e){if(!(e.mac?e.metaKey:e.ctrlKey))return {isLinkClick:false,url:null};let o=t?.closest?.("a")??null;if(!o)return {isLinkClick:false,url:null};let r=de(o.getAttribute("href")??"");return {isLinkClick:true,url:r===""?null:r}}function oi(t){return t.text.includes(`
12
+ `});}function ei(t){let e=[];Ot(t,{},false,e);let n=pn(e);return {type:Ke,children:n.length>0?n:[{text:""}]}}function Bt(t){let e=t.childNodes;if(e.length===0)return Fe();let n=[],o=[];function r(){if(o.length===0)return;let l=pn(o);n.push({type:Ke,children:l.length>0?l:[{text:""}]}),o=[];}function i(l){for(let s of l)if(Yr(s))r(),n.push(ei(s));else if(s.nodeType===fn){let a=s.nodeValue??"",c=Le(a);c.trim().length>0&&o.push({text:c});}else st(s)&&(Ve(s,"br")?o.push({text:Ko}):Zr(s)?(r(),i(s.childNodes)):Ot(s,{},false,o));}return i(e),r(),n.length===0?Fe():_(n)}function ni(t){return Object.entries(t).map(([e,n])=>`${ti(e)}:${n}`).filter(([,e])=>!!e).join(";")}function Uo(t){return "text"in t}function lt(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function de(t){let e=t.trim(),n=e.replaceAll(/[\u0000- ]/g,""),o=/^([a-z][a-z0-9+.-]*):/i.exec(n);if(!o)return e;let r=o[1].toLowerCase();return new Set(["javascript","data","vbscript"]).has(r)?"":e}function hn(t){let e=t.trim();if(/^[/#?.]/.test(e))return e;let n=/^([^/:?#]+):\d+(?:[/?#]|$)/.exec(e)?.[1];if(n==="localhost"||n?.includes("."))return `https://${e}`;try{return new URL(e),e}catch{return `https://${e}`}}function Vo(t,e){if(!(e.mac?e.metaKey:e.ctrlKey))return {isLinkClick:false,url:null};let o=t?.closest?.("a")??null;if(!o)return {isLinkClick:false,url:null};let r=de(o.getAttribute("href")??"");return {isLinkClick:true,url:r===""?null:r}}function oi(t){return t.text.includes(`
13
13
  `)?t.text.split(`
14
- `).map(n=>{let o={text:n};return n.length>0&&(t.bold!==void 0&&(o.bold=t.bold),t.italic!==void 0&&(o.italic=t.italic),t.underline!==void 0&&(o.underline=t.underline),t.color!==void 0&&(o.color=t.color),t.backgroundColor!==void 0&&(o.backgroundColor=t.backgroundColor)),o}):[t]}function ri(t){let e=[[]],n=0;for(let o of t)if(Uo(o)){let r=oi(o);for(let i=0;i<r.length;i++)e[n].push(r[i]),i<r.length-1&&(n++,e[n]=[]);}else e[n].push(o);return e}function me(t){if(!t)return "";function e(n){if(Uo(n)){if(n.text==="")return "";let r=lt(n.text);if(n.bold&&(r=`<b>${r}</b>`),n.italic&&(r=`<i>${r}</i>`),n.underline&&(r=`<u>${r}</u>`),n.color||n.backgroundColor){let i=ni(a$4({color:n.color||void 0,backgroundColor:n.backgroundColor||void 0}));r=`<span style="${lt(i)}">${r}</span>`;}return r}let o=n.children?.map(r=>me(r)).join("");switch(n.type){case je:return ri(n.children).map(i=>`<p>${i.map(s=>me(s)).join("")}</p>`).join("");case Z:return `<a href="${lt(de(n.url))}">${o}</a>`;case ae:return `<span data-user-id="${lt(n.value)}">${lt(n.displayName)}</span>`;default:return o}}return Array.isArray(t)?t.map(n=>e(n)).join(""):e(t)}function mn(t){let e=new DOMParser().parseFromString(Fo.default.sanitize(t),"text/html");if(!e.body.querySelector("p, div")){let n=e.createElement("p");n.append(...e.body.childNodes),e.body.append(n);}return Bt(e.body)}var ii=new Set(["(","[","{","<",'"',"'","`","\xAB"]),si=new Set([".",",","!","?",":",";",'"',"'","`","\xBB"]),li=new Map([[")","("],["]","["],["}","{"]]);function Wo(t,e){let n=0;for(let o of t)o===e&&n++;return n}function Ht(t){let e=0,n=t.length;for(;e<n&&ii.has(t[e]);)e++;for(;n>e;){let l=t[n-1];if(si.has(l)){n--;continue}let s=li.get(l);if(s!==void 0){let a=t.slice(e,n);if(Wo(a,l)>Wo(a,s)){n--;continue}}break}if(n<=e)return null;let o=t.slice(e,n),r;if(/^https?:\/\//i.test(o))r=o;else if(/^www\./i.test(o)){if(o.length<=4)return null;r=`https://${o}`;}else return null;let i;try{i=new URL(r);}catch{return null}return i.hostname===""?null:{start:e,end:n,url:r}}function ai(t){let e=[],n=/\S+/g,o;for(;(o=n.exec(t))!==null;){let r=Ht(o[0]);if(r){let i=o.index+r.start,l=o.index+r.end;e.push({start:i,end:l,text:t.slice(i,l),url:r.url});}}return e}function qo(t){let e=t.trim();if(e===""||/\s/.test(e))return null;let n=Ht(e);return n&&n.start===0&&n.end===e.length?n.url:null}function ci(t){let e=ai(t.text);if(e.length===0)return null;let n=[],o=0;for(let r of e)r.start>o&&n.push({...t,text:t.text.slice(o,r.start)}),n.push({type:Z,url:r.url,children:[{...t,text:r.text}]}),o=r.end;return o<t.text.length&&n.push({...t,text:t.text.slice(o)}),n}function gn(t){let e=false,n=t.map(o=>{let r=false,i=[];for(let l of o.children){let s=x(l)?ci(l):null;s?(i.push(...s),r=true):i.push(l);}return r?(e=true,{...o,children:i}):o});return e?n:t}function $o(t){return ce(t)?0:F(t)}function Go(t){return t.children.reduce((e,n)=>e+F(n),0)}function xn(t,e,n){return Math.min(Math.max(t,e),n)}function ve(t,e){return t.path[0]!==e.path[0]?t.path[0]<e.path[0]?-1:1:t.path[1]!==e.path[1]?t.path[1]<e.path[1]?-1:1:t.offset!==e.offset?t.offset<e.offset?-1:1:0}function N(t){return ve(t.anchor,t.focus)===0}function bn(t){return ve(t.anchor,t.focus)<=0?t:{anchor:t.focus,focus:t.anchor}}function oe(t,e){let n=xn(e.path[0],0,t.length-1),o=t[n].children,r=xn(e.path[1],0,o.length-1),i=xn(e.offset,0,$o(o[r]));return {path:[n,r],offset:i}}function Ve(t){let e=t.length-1,n=t[e].children,o=n.length-1;return {path:[e,o],offset:$o(n[o])}}function I(t,e){let n=Math.max(e,0);for(let o=0;o<t.length;o++){let r=t[o],i=Go(r);if(n>i){n-=i+1;continue}let l=r.children;for(let s=0;s<l.length;s++){let a=l[s],c=F(a);if(ce(a)){if(n===0)return {path:[o,s],offset:0};if(n<c)return {path:[o,s+1],offset:0}}else if(n<=c)return {path:[o,s],offset:n};n-=c;}}return Ve(t)}function P(t,e){let[n,o]=e.path,r=0;for(let l=0;l<n;l++)r+=Go(t[l])+1;let i=t[n].children;for(let l=0;l<o;l++)r+=F(i[l]);return r+e.offset}function Re(t,e,n,o,r){let i=n==="atomic";if(t<o.path[0]||t>r.path[0])return null;let l=0;if(t===o.path[0]){if(e<o.path[1])return null;e===o.path[1]&&(l=i?0:o.offset);}let s=i?1:n;if(t===r.path[0]){if(e>r.path[1])return null;e===r.path[1]&&(s=i?r.offset>0?1:0:r.offset);}return l>=s?null:{from:l,to:s}}function yn(t,e,n){let o=0;for(let r of t.children)n(r,Math.max(e.from-o,0),Math.min(e.to-o,r.text.length)),o+=r.text.length;}function Yo(t,e,n,o){for(let r=e.path[0];r<=n.path[0]&&r<t.length;r++){let i=t[r].children;for(let[l,s]of i.entries())if(!J(s)){if(x(s)){let a=Re(r,l,s.text.length,e,n);a&&o(s,a.from,a.to);}else if(k(s)){let a=Re(r,l,F(s),e,n);a&&yn(s,a,(c,u,d)=>{u<d&&o(c,u,d);});}}}}function Zo(t){return x(t)?t:k(t)?t.children.at(-1)??null:null}function Jo(t,e){let n=oe(t,e),o=t[n.path[0]].children,r=o[n.path[1]],i=n.path[1]>0?Zo(o[n.path[1]-1]):null;if(x(r))return n.offset>0?r:i??r;if(k(r)){if(n.offset===0)return i??r.children[0]??null;let l=0;for(let s of r.children)if(l+=s.text.length,n.offset<=l)return s;return r.children.at(-1)??null}return he(r)?n.offset>0?r.children[0]:i??r.children[0]:i}function Xo(t){let e={};return t.bold&&(e.bold=true),t.italic&&(e.italic=true),t.underline&&(e.underline=true),t.color!==void 0&&(e.color=t.color),t.backgroundColor!==void 0&&(e.backgroundColor=t.backgroundColor),e}function di(t,e){let n={};return t.bold&&e.bold&&(n.bold=true),t.italic&&e.italic&&(n.italic=true),t.underline&&e.underline&&(n.underline=true),t.color!==void 0&&b$a(t.color,e.color)&&(n.color=t.color),t.backgroundColor!==void 0&&b$a(t.backgroundColor,e.backgroundColor)&&(n.backgroundColor=t.backgroundColor),n}function ze(t,e){if(N(e)){let l=Jo(t,e.focus);return l?Xo(l):{}}let n=bn(e),o=oe(t,n.anchor),r=oe(t,n.focus),i=null;return Yo(t,o,r,l=>{let s=Xo(l);i=i===null?s:di(i,s);}),i??{}}function jt(t,e,n){if(n===t)return {doc:t,range:e};let o=_(n);return {doc:o,range:{anchor:I(o,P(t,oe(t,e.anchor))),focus:I(o,P(t,oe(t,e.focus)))}}}function Qo(t,e,n,o){let r={...t,text:t.text.slice(e,n)},i=o(r);if(wt(i,r))return null;let l=[];return e>0&&l.push({...t,text:t.text.slice(0,e)}),l.push(i),n<t.text.length&&l.push({...t,text:t.text.slice(n)}),l}function ui(t,e,n){let o=false,r=[];return yn(t,e,(i,l,s)=>{let a=l<s?Qo(i,l,s,n):null;a?(r.push(...a),o=true):r.push(i);}),o?{...t,children:r}:null}function er(t,e,n,o){let r=false,i=t.map((l,s)=>{if(s<e.path[0]||s>n.path[0])return l;let a=false,c=[];for(let[u,d]of l.children.entries())if(x(d)){let f=Re(s,u,d.text.length,e,n),p=f?Qo(d,f.from,f.to,o):null;p?(c.push(...p),a=true):c.push(d);}else if(k(d)){let f=Re(s,u,F(d),e,n),p=f?ui(d,f,o):null;p?(c.push(p),a=true):c.push(d);}else c.push(d);return a?(r=true,{...l,children:c}):l});return r?i:t}function We(t,e){let n=bn(e);return [oe(t,n.anchor),oe(t,n.focus)]}function En(t,e,n){if(N(e))return {doc:t,range:e};let[o,r]=We(t,e),i=false,l=true;return Yo(t,o,r,a=>{i=true,a[n]||(l=false);}),i?jt(t,e,er(t,o,r,l?a=>{let c={...a};return delete c[n],c}:a=>a[n]?a:{...a,[n]:true})):{doc:t,range:e}}function vn(t,e,n,o){if(N(e))return {doc:t,range:e};let[r,i]=We(t,e);return jt(t,e,er(t,r,i,s=>{if(s[n]===o)return s;let a={...s};return o===void 0?delete a[n]:a[n]=o,a}))}function tr(t,e){let n=[],o=[],r=0;for(let i of t){let l=r+i.text.length;l<=e?n.push(i):r>=e?o.push(i):(n.push({...i,text:i.text.slice(0,e-r)}),o.push({...i,text:i.text.slice(e-r)})),r=l;}return [n,o]}function Se(t,e,n){if(e>=t.length)return [[...t],[]];let o=t.slice(0,e),r=t.slice(e+1),i=t[e];if(x(i))o.push({...i,text:i.text.slice(0,n)}),r.unshift({...i,text:i.text.slice(n)});else if(k(i)){let[l,s]=tr(i.children,n);o.push({...i,children:l}),r.unshift({...i,children:s});}else n===0?r.unshift(i):o.push(i);return [o,r]}function Rn(t,e){let[n,o]=We(t,e);for(let r=n.path[0];r<=o.path[0]&&r<t.length;r++)for(let[i,l]of t[r].children.entries()){if(!k(l))continue;let s={path:[r,i],offset:0},a={path:[r,i],offset:F(l)};if(ve(n,a)<=0&&ve(o,s)>=0)return {paragraphIndex:r,inlineIndex:i,link:l}}return null}function nr(t,e){let n=Rn(t,e);if(!n)return null;let{paragraphIndex:o,inlineIndex:r,link:i}=n;return {url:i.url,range:{anchor:{path:[o,r],offset:0},focus:{path:[o,r],offset:F(i)}}}}function or(t,e){let[n,o]=We(t,e);for(let r=n.path[0];r<=o.path[0]&&r<t.length;r++)for(let[i,l]of t[r].children.entries()){if(x(l))continue;let s=J(l)?"atomic":F(l);if(Re(r,i,s,n,o))return true}return false}function fi(t,e,n,o){let r=[],i=(l,s,a)=>{s<a&&r.push({...l,text:l.text.slice(s,a)});};for(let[l,s]of t[e].children.entries())if(!J(s)){if(x(s)){let a=Re(e,l,s.text.length,n,o);a&&i(s,a.from,a.to);}else if(k(s)){let a=Re(e,l,F(s),n,o);a&&yn(s,a,i);}}return r}function Tn(t,e,n){if(N(e))return {doc:t,range:e};let[o,r]=We(t,e);for(let s=o.path[0];s<=r.path[0]&&s<t.length;s++)for(let[a,c]of t[s].children.entries())if(J(c)&&Re(s,a,"atomic",o,r))return {doc:t,range:e};let i=false,l=t.map((s,a)=>{if(a<o.path[0]||a>r.path[0])return s;let c=fi(t,a,o,r);if(c.length===0)return s;let u=s.children,[d]=a===o.path[0]?Se(u,o.path[1],o.offset):[[]],f=a===r.path[0]?Se(u,r.path[1],r.offset)[1]:[];return i=true,{...s,children:[...d,{type:Z,url:n,children:c},...f]}});return i?jt(t,e,l):{doc:t,range:e}}function rr(t,e,n){let o=Rn(t,e);if(!o||o.link.url===n)return {doc:t,range:e};let{paragraphIndex:r,inlineIndex:i,link:l}=o,s=t.map((a,c)=>c!==r?a:{...a,children:a.children.map((u,d)=>d===i?{...l,url:n}:u)});return {doc:_(s),range:e}}function ir(t,e){let n=Rn(t,e);if(!n)return {doc:t,range:e};let{paragraphIndex:o,inlineIndex:r,link:i}=n,l=t.map((s,a)=>a!==o?s:{...s,children:s.children.flatMap((c,u)=>u===r?i.children:[c])});return jt(t,e,l)}function qe(t,e){if(N(e))return {doc:t,range:e};let[n,o]=We(t,e);if(ve(n,o)===0)return {doc:t,range:e};let r=P(t,n),i=Se(t[n.path[0]].children,n.path[1],n.offset)[0],l=Se(t[o.path[0]].children,o.path[1],o.offset)[1],s={...t[n.path[0]],children:[...i,...l]},a=_([...t.slice(0,n.path[0]),s,...t.slice(o.path[0]+1)]),c=I(a,r);return {doc:a,range:{anchor:c,focus:c}}}function at(t,e,n){let o=oe(t,e);if(n==="")return {doc:t,range:{anchor:o,focus:o}};let r=Jo(t,o),i=r?{...r,text:n}:{text:n},l=o.path[0],s=t[l].children,a=s[o.path[1]],c;if(k(a)&&o.offset>0&&o.offset<F(a)){let[f,p]=tr(a.children,o.offset),m={...a,children:[...f,i,...p]};c=s.map((h,C)=>C===o.path[1]?m:h);}else {let[f,p]=Se(s,o.path[1],o.offset);c=[...f,i,...p];}let u=_(t.map((f,p)=>p===l?{...f,children:c}:f)),d=I(u,P(t,o)+n.length);return {doc:u,range:{anchor:d,focus:d}}}function sr(t,e,n){let o=_(n),r=Fe(o),i=t,l;if(N(e))l=oe(t,e.focus);else {let p=qe(t,e);i=p.doc,l=p.range.focus;}if(o.length===1&&r===0)return {doc:i,range:{anchor:l,focus:l}};let s=l.path[0],[a,c]=Se(i[s].children,l.path[1],l.offset),u=o.length===1?[{...i[s],children:[...a,...o[0].children,...c]}]:[{...i[s],children:[...a,...o[0].children]},...o.slice(1,-1),{...o.at(-1),children:[...o.at(-1).children,...c]}],d=_([...i.slice(0,s),...u,...i.slice(s+1)]),f=I(d,P(i,l)+r);return {doc:d,range:{anchor:f,focus:f}}}function lr(t,e){if(N(e))return at(t,e.focus,`
15
- `);let n=qe(t,e);return at(n.doc,n.range.focus,`
16
- `)}function ar(t,e){for(let[n,o]of t.entries()){let r=o.children.indexOf(e);if(r!==-1)return [n,r]}return null}function cr(t){for(let[e,n]of t.entries())for(let[o,r]of n.children.entries())if(he(r))return [e,o];return null}function dr(t){let e=Ve(t);return {anchor:e,focus:e}}function ur(t,e){let n=t,o;if(N(e))o=oe(t,e.focus);else {let d=qe(t,e);n=d.doc,o=d.range.focus;}let r={type:Ee,children:[{text:""}]},i=o.path[0],[l,s]=Se(n[i].children,o.path[1],o.offset),a=_(n.map((d,f)=>f===i?{...d,children:[...l,r,...s]}:d)),u={path:ar(a,r)??[0,0],offset:0};return {doc:a,range:{anchor:u,focus:u}}}function fr(t,e){let n=cr(t);if(!n)return {doc:t,range:dr(t)};let[o,r]=n,i={type:ae,value:e.id,displayName:e.displayName,children:[{text:""}]},l=_(t.map((u,d)=>d===o?{...u,children:u.children.map((f,p)=>p===r?i:f)}:u)),[s,a]=ar(l,i)??[o,r],c={path:[s,a+1],offset:0};return {doc:l,range:{anchor:c,focus:c}}}function pr(t,e){let n=cr(t);if(!n)return {doc:t,range:dr(t)};let[o,r]=n,i=t[o].children,l=r>0?Zo(i[r-1]):null,s=l?{...l,text:e}:{text:e},a=P(t,{path:[o,r],offset:0})+e.length,c=_(t.map((d,f)=>f===o?{...d,children:i.map((p,m)=>m===r?s:p)}:d)),u=I(c,a);return {doc:c,range:{anchor:u,focus:u}}}function pi(t){let e=[];return t.color&&e.push(`color:${t.color}`),t.backgroundColor&&e.push(`background-color:${t.backgroundColor}`),e.join(";")}function hi(t){for(let e of t.children)if(J(e)||k(e)&&e.children.map(o=>o.text).join("").length>0||x(e)&&e.text.length>0)return false;return true}function hr(t,e,n,o){if(n.text==="")return;let r=n.text.split(`
17
- `);for(let i=0;i<r.length;i++){let l=r[i],s=i===r.length-1;if(l.length>0){let c=t.createTextNode(l);if(n.underline){let d=t.createElement("u");d.append(c),c=d;}if(n.italic){let d=t.createElement("i");d.append(c),c=d;}if(n.bold){let d=t.createElement("b");d.append(c),c=d;}let u=pi(n);if(u){let d=t.createElement("span");d.setAttribute("style",u),d.append(c),c=d;}e.append(c);}(!s||l===""&&r.length>1&&o)&&e.append(t.createElement("br"));}}function mi(t,e,n,o){if(x(n)){hr(t,e,n,o);return}switch(n.type){case Z:{let r=t.createElement("a");r.setAttribute("href",de(n.url)),r.className=a$q({size:"sm",variant:"inline"});for(let i of n.children)hr(t,r,i,false);e.append(r);break}case ae:{let r=t.createElement("span");r.setAttribute("contenteditable","false"),r.dataset.userId=n.value,r.textContent=`@${n.displayName}`,e.append(r);break}case Ee:{let r=t.createElement("span");r.setAttribute("contenteditable","false"),r.dataset.mentionAnchor="true",r.textContent=n.children[0].text,e.append(r);break}}}function kn(t){return x(t)?t.text!=="":k(t)?t.children.some(e=>e.text!==""):true}function gi(t,e){let n=t.createElement("p");if(hi(e))return n.append(t.createElement("br")),n;let o=-1;for(let r=e.children.length-1;r>=0;r--)if(kn(e.children[r])){o=r;break}for(let[r,i]of e.children.entries())mi(t,n,i,r===o);return n}function ct(t,e){let n=e.ownerDocument,o=n.createDocumentFragment();for(let r of t)o.append(gi(n,r));e.replaceChildren(o);}var xi=1,bi=3,yi=11;function re(t){return t.nodeType===xi}function gr(t){return t.nodeType===yi&&"host"in t}function Ft(t){return t.nodeType===bi}function dt(t,e){return t.tagName.toLowerCase()===e}function Ei(t){return dt(t,"span")?t.getAttribute("contenteditable")==="false":false}function vi(t,e,n,o,r){if(o===t){let s=t.childNodes,a=Math.min(r,s.length);return a===0?{found:true,point:{path:[n,0],offset:0}}:Ri(e,n,a)}let i=t.childNodes,l=0;for(let s=0;s<e.children.length;s++){let a=e.children[s];if(x(a)){let c=Ut(e.children,s),u=br(a.text,i,l,n,s,o,r,c);if(u.found)return u;l+=Pe(a.text,c);}else if(k(a)){if(l>=i.length)continue;let c=i[l];if(!re(c)||!dt(c,"a")){l++;continue}let u=Ti(a,c,n,s,o,r);if(u.found)return u;l++;}else if(ce(a)||he(a)){if(l>=i.length)continue;let c=i[l];if(!re(c)||!Ei(c)){l++;continue}if(o===c||(re(o)||Ft(o))&&h(c,o))return {found:true,point:{path:[n,s+1],offset:0}};l++;}}return {found:false}}function Ri(t,e,n){let o=0;for(let l=0;l<t.children.length;l++){let s=t.children[l],a=x(s)?Pe(s.text,Ut(t.children,l)):1;if(o+a>=n){if(x(s))return {found:true,point:{path:[e,l],offset:xr(s.text,n-o)}};if(J(s))return {found:true,point:{path:[e,l+1],offset:0}};{let c=s.children.reduce((u,d)=>u+d.text.length,0);return {found:true,point:{path:[e,l],offset:c}}}}o+=a;}let r=t.children.length-1,i=t.children[r];if(x(i))return {found:true,point:{path:[e,r],offset:i.text.length}};if(J(i))return {found:true,point:{path:[e,r+1],offset:0}};if(k(i)){let l=i.children.reduce((s,a)=>s+a.text.length,0);return {found:true,point:{path:[e,r],offset:l}}}return {found:false}}function Ut(t,e){for(let n=e+1;n<t.length;n++)if(kn(t[n]))return false;return true}function Pe(t,e){if(t==="")return 0;let n=t.split(`
14
+ `).map(n=>{let o={text:n};return n.length>0&&(t.bold!==void 0&&(o.bold=t.bold),t.italic!==void 0&&(o.italic=t.italic),t.underline!==void 0&&(o.underline=t.underline),t.color!==void 0&&(o.color=t.color),t.backgroundColor!==void 0&&(o.backgroundColor=t.backgroundColor)),o}):[t]}function ri(t){let e=[[]],n=0;for(let o of t)if(Uo(o)){let r=oi(o);for(let i=0;i<r.length;i++)e[n].push(r[i]),i<r.length-1&&(n++,e[n]=[]);}else e[n].push(o);return e}function ge(t){if(!t)return "";function e(n){if(Uo(n)){if(n.text==="")return "";let r=lt(n.text);if(n.bold&&(r=`<b>${r}</b>`),n.italic&&(r=`<i>${r}</i>`),n.underline&&(r=`<u>${r}</u>`),n.color||n.backgroundColor){let i=ni(a$4({color:n.color||void 0,backgroundColor:n.backgroundColor||void 0}));r=`<span style="${lt(i)}">${r}</span>`;}return r}let o=n.children?.map(r=>ge(r)).join("");switch(n.type){case Ke:return ri(n.children).map(i=>`<p>${i.map(s=>ge(s)).join("")}</p>`).join("");case Z:return `<a href="${lt(de(n.url))}">${o}</a>`;case ae:return `<span data-user-id="${lt(n.value)}">${lt(n.displayName)}</span>`;default:return o}}return Array.isArray(t)?t.map(n=>e(n)).join(""):e(t)}function mn(t){let e=new DOMParser().parseFromString(Fo.default.sanitize(t),"text/html");if(!e.body.querySelector("p, div")){let n=e.createElement("p");n.append(...e.body.childNodes),e.body.append(n);}return Bt(e.body)}var ii=new Set(["(","[","{","<",'"',"'","`","\xAB"]),si=new Set([".",",","!","?",":",";",'"',"'","`","\xBB"]),li=new Map([[")","("],["]","["],["}","{"]]);function Wo(t,e){let n=0;for(let o of t)o===e&&n++;return n}function Ht(t){let e=0,n=t.length;for(;e<n&&ii.has(t[e]);)e++;for(;n>e;){let l=t[n-1];if(si.has(l)){n--;continue}let s=li.get(l);if(s!==void 0){let a=t.slice(e,n);if(Wo(a,l)>Wo(a,s)){n--;continue}}break}if(n<=e)return null;let o=t.slice(e,n),r;if(/^https?:\/\//i.test(o))r=o;else if(/^www\./i.test(o)){if(o.length<=4)return null;r=`https://${o}`;}else return null;let i;try{i=new URL(r);}catch{return null}return i.hostname===""?null:{start:e,end:n,url:r}}function ai(t){let e=[],n=/\S+/g,o;for(;(o=n.exec(t))!==null;){let r=Ht(o[0]);if(r){let i=o.index+r.start,l=o.index+r.end;e.push({start:i,end:l,text:t.slice(i,l),url:r.url});}}return e}function qo(t){let e=t.trim();if(e===""||/\s/.test(e))return null;let n=Ht(e);return n&&n.start===0&&n.end===e.length?n.url:null}function ci(t){let e=ai(t.text);if(e.length===0)return null;let n=[],o=0;for(let r of e)r.start>o&&n.push({...t,text:t.text.slice(o,r.start)}),n.push({type:Z,url:r.url,children:[{...t,text:r.text}]}),o=r.end;return o<t.text.length&&n.push({...t,text:t.text.slice(o)}),n}function gn(t){let e=false,n=t.map(o=>{let r=false,i=[];for(let l of o.children){let s=x(l)?ci(l):null;s?(i.push(...s),r=true):i.push(l);}return r?(e=true,{...o,children:i}):o});return e?n:t}function $o(t){return ce(t)?0:U(t)}function Go(t){return t.children.reduce((e,n)=>e+U(n),0)}function xn(t,e,n){return Math.min(Math.max(t,e),n)}function ve(t,e){return t.path[0]!==e.path[0]?t.path[0]<e.path[0]?-1:1:t.path[1]!==e.path[1]?t.path[1]<e.path[1]?-1:1:t.offset!==e.offset?t.offset<e.offset?-1:1:0}function w(t){return ve(t.anchor,t.focus)===0}function bn(t){return ve(t.anchor,t.focus)<=0?t:{anchor:t.focus,focus:t.anchor}}function oe(t,e){let n=xn(e.path[0],0,t.length-1),o=t[n].children,r=xn(e.path[1],0,o.length-1),i=xn(e.offset,0,$o(o[r]));return {path:[n,r],offset:i}}function We(t){let e=t.length-1,n=t[e].children,o=n.length-1;return {path:[e,o],offset:$o(n[o])}}function N(t,e){let n=Math.max(e,0);for(let o=0;o<t.length;o++){let r=t[o],i=Go(r);if(n>i){n-=i+1;continue}let l=r.children;for(let s=0;s<l.length;s++){let a=l[s],c=U(a);if(ce(a)){if(n===0)return {path:[o,s],offset:0};if(n<c)return {path:[o,s+1],offset:0}}else if(n<=c)return {path:[o,s],offset:n};n-=c;}}return We(t)}function P(t,e){let[n,o]=e.path,r=0;for(let l=0;l<n;l++)r+=Go(t[l])+1;let i=t[n].children;for(let l=0;l<o;l++)r+=U(i[l]);return r+e.offset}function Re(t,e,n,o,r){let i=n==="atomic";if(t<o.path[0]||t>r.path[0])return null;let l=0;if(t===o.path[0]){if(e<o.path[1])return null;e===o.path[1]&&(l=i?0:o.offset);}let s=i?1:n;if(t===r.path[0]){if(e>r.path[1])return null;e===r.path[1]&&(s=i?r.offset>0?1:0:r.offset);}return l>=s?null:{from:l,to:s}}function yn(t,e,n){let o=0;for(let r of t.children)n(r,Math.max(e.from-o,0),Math.min(e.to-o,r.text.length)),o+=r.text.length;}function Yo(t,e,n,o){for(let r=e.path[0];r<=n.path[0]&&r<t.length;r++){let i=t[r].children;for(let[l,s]of i.entries())if(!J(s)){if(x(s)){let a=Re(r,l,s.text.length,e,n);a&&o(s,a.from,a.to);}else if(k(s)){let a=Re(r,l,U(s),e,n);a&&yn(s,a,(c,u,d)=>{u<d&&o(c,u,d);});}}}}function Zo(t){return x(t)?t:k(t)?t.children.at(-1)??null:null}function Jo(t,e){let n=oe(t,e),o=t[n.path[0]].children,r=o[n.path[1]],i=n.path[1]>0?Zo(o[n.path[1]-1]):null;if(x(r))return n.offset>0?r:i??r;if(k(r)){if(n.offset===0)return i??r.children[0]??null;let l=0;for(let s of r.children)if(l+=s.text.length,n.offset<=l)return s;return r.children.at(-1)??null}return me(r)?n.offset>0?r.children[0]:i??r.children[0]:i}function Xo(t){let e={};return t.bold&&(e.bold=true),t.italic&&(e.italic=true),t.underline&&(e.underline=true),t.color!==void 0&&(e.color=t.color),t.backgroundColor!==void 0&&(e.backgroundColor=t.backgroundColor),e}function di(t,e){let n={};return t.bold&&e.bold&&(n.bold=true),t.italic&&e.italic&&(n.italic=true),t.underline&&e.underline&&(n.underline=true),t.color!==void 0&&b$a(t.color,e.color)&&(n.color=t.color),t.backgroundColor!==void 0&&b$a(t.backgroundColor,e.backgroundColor)&&(n.backgroundColor=t.backgroundColor),n}function ze(t,e){if(w(e)){let l=Jo(t,e.focus);return l?Xo(l):{}}let n=bn(e),o=oe(t,n.anchor),r=oe(t,n.focus),i=null;return Yo(t,o,r,l=>{let s=Xo(l);i=i===null?s:di(i,s);}),i??{}}function jt(t,e,n){if(n===t)return {doc:t,range:e};let o=_(n);return {doc:o,range:{anchor:N(o,P(t,oe(t,e.anchor))),focus:N(o,P(t,oe(t,e.focus)))}}}function Qo(t,e,n,o){let r={...t,text:t.text.slice(e,n)},i=o(r);if(wt(i,r))return null;let l=[];return e>0&&l.push({...t,text:t.text.slice(0,e)}),l.push(i),n<t.text.length&&l.push({...t,text:t.text.slice(n)}),l}function ui(t,e,n){let o=false,r=[];return yn(t,e,(i,l,s)=>{let a=l<s?Qo(i,l,s,n):null;a?(r.push(...a),o=true):r.push(i);}),o?{...t,children:r}:null}function er(t,e,n,o){let r=false,i=t.map((l,s)=>{if(s<e.path[0]||s>n.path[0])return l;let a=false,c=[];for(let[u,d]of l.children.entries())if(x(d)){let f=Re(s,u,d.text.length,e,n),p=f?Qo(d,f.from,f.to,o):null;p?(c.push(...p),a=true):c.push(d);}else if(k(d)){let f=Re(s,u,U(d),e,n),p=f?ui(d,f,o):null;p?(c.push(p),a=true):c.push(d);}else c.push(d);return a?(r=true,{...l,children:c}):l});return r?i:t}function qe(t,e){let n=bn(e);return [oe(t,n.anchor),oe(t,n.focus)]}function En(t,e,n){if(w(e))return {doc:t,range:e};let[o,r]=qe(t,e),i=false,l=true;return Yo(t,o,r,a=>{i=true,a[n]||(l=false);}),i?jt(t,e,er(t,o,r,l?a=>{let c={...a};return delete c[n],c}:a=>a[n]?a:{...a,[n]:true})):{doc:t,range:e}}function vn(t,e,n,o){if(w(e))return {doc:t,range:e};let[r,i]=qe(t,e);return jt(t,e,er(t,r,i,s=>{if(s[n]===o)return s;let a={...s};return o===void 0?delete a[n]:a[n]=o,a}))}function tr(t,e){let n=[],o=[],r=0;for(let i of t){let l=r+i.text.length;l<=e?n.push(i):r>=e?o.push(i):(n.push({...i,text:i.text.slice(0,e-r)}),o.push({...i,text:i.text.slice(e-r)})),r=l;}return [n,o]}function Se(t,e,n){if(e>=t.length)return [[...t],[]];let o=t.slice(0,e),r=t.slice(e+1),i=t[e];if(x(i))o.push({...i,text:i.text.slice(0,n)}),r.unshift({...i,text:i.text.slice(n)});else if(k(i)){let[l,s]=tr(i.children,n);o.push({...i,children:l}),r.unshift({...i,children:s});}else n===0?r.unshift(i):o.push(i);return [o,r]}function Rn(t,e){let[n,o]=qe(t,e);for(let r=n.path[0];r<=o.path[0]&&r<t.length;r++)for(let[i,l]of t[r].children.entries()){if(!k(l))continue;let s={path:[r,i],offset:0},a={path:[r,i],offset:U(l)};if(ve(n,a)<=0&&ve(o,s)>=0)return {paragraphIndex:r,inlineIndex:i,link:l}}return null}function nr(t,e){let n=Rn(t,e);if(!n)return null;let{paragraphIndex:o,inlineIndex:r,link:i}=n;return {url:i.url,range:{anchor:{path:[o,r],offset:0},focus:{path:[o,r],offset:U(i)}}}}function or(t,e){let[n,o]=qe(t,e);for(let r=n.path[0];r<=o.path[0]&&r<t.length;r++)for(let[i,l]of t[r].children.entries()){if(x(l))continue;let s=J(l)?"atomic":U(l);if(Re(r,i,s,n,o))return true}return false}function fi(t,e,n,o){let r=[],i=(l,s,a)=>{s<a&&r.push({...l,text:l.text.slice(s,a)});};for(let[l,s]of t[e].children.entries())if(!J(s)){if(x(s)){let a=Re(e,l,s.text.length,n,o);a&&i(s,a.from,a.to);}else if(k(s)){let a=Re(e,l,U(s),n,o);a&&yn(s,a,i);}}return r}function Tn(t,e,n){if(w(e))return {doc:t,range:e};let[o,r]=qe(t,e);for(let s=o.path[0];s<=r.path[0]&&s<t.length;s++)for(let[a,c]of t[s].children.entries())if(J(c)&&Re(s,a,"atomic",o,r))return {doc:t,range:e};let i=false,l=t.map((s,a)=>{if(a<o.path[0]||a>r.path[0])return s;let c=fi(t,a,o,r);if(c.length===0)return s;let u=s.children,[d]=a===o.path[0]?Se(u,o.path[1],o.offset):[[]],f=a===r.path[0]?Se(u,r.path[1],r.offset)[1]:[];return i=true,{...s,children:[...d,{type:Z,url:n,children:c},...f]}});return i?jt(t,e,l):{doc:t,range:e}}function rr(t,e,n){let o=Rn(t,e);if(!o||o.link.url===n)return {doc:t,range:e};let{paragraphIndex:r,inlineIndex:i,link:l}=o,s=t.map((a,c)=>c!==r?a:{...a,children:a.children.map((u,d)=>d===i?{...l,url:n}:u)});return {doc:_(s),range:e}}function ir(t,e){let n=Rn(t,e);if(!n)return {doc:t,range:e};let{paragraphIndex:o,inlineIndex:r,link:i}=n,l=t.map((s,a)=>a!==o?s:{...s,children:s.children.flatMap((c,u)=>u===r?i.children:[c])});return jt(t,e,l)}function $e(t,e){if(w(e))return {doc:t,range:e};let[n,o]=qe(t,e);if(ve(n,o)===0)return {doc:t,range:e};let r=P(t,n),i=Se(t[n.path[0]].children,n.path[1],n.offset)[0],l=Se(t[o.path[0]].children,o.path[1],o.offset)[1],s={...t[n.path[0]],children:[...i,...l]},a=_([...t.slice(0,n.path[0]),s,...t.slice(o.path[0]+1)]),c=N(a,r);return {doc:a,range:{anchor:c,focus:c}}}function at(t,e,n){let o=oe(t,e);if(n==="")return {doc:t,range:{anchor:o,focus:o}};let r=Jo(t,o),i=r?{...r,text:n}:{text:n},l=o.path[0],s=t[l].children,a=s[o.path[1]],c;if(k(a)&&o.offset>0&&o.offset<U(a)){let[f,p]=tr(a.children,o.offset),m={...a,children:[...f,i,...p]};c=s.map((h,C)=>C===o.path[1]?m:h);}else {let[f,p]=Se(s,o.path[1],o.offset);c=[...f,i,...p];}let u=_(t.map((f,p)=>p===l?{...f,children:c}:f)),d=N(u,P(t,o)+n.length);return {doc:u,range:{anchor:d,focus:d}}}function sr(t,e,n){let o=_(n),r=Ue(o),i=t,l;if(w(e))l=oe(t,e.focus);else {let p=$e(t,e);i=p.doc,l=p.range.focus;}if(o.length===1&&r===0)return {doc:i,range:{anchor:l,focus:l}};let s=l.path[0],[a,c]=Se(i[s].children,l.path[1],l.offset),u=o.length===1?[{...i[s],children:[...a,...o[0].children,...c]}]:[{...i[s],children:[...a,...o[0].children]},...o.slice(1,-1),{...o.at(-1),children:[...o.at(-1).children,...c]}],d=_([...i.slice(0,s),...u,...i.slice(s+1)]),f=N(d,P(i,l)+r);return {doc:d,range:{anchor:f,focus:f}}}function lr(t,e){if(w(e))return at(t,e.focus,`
15
+ `);let n=$e(t,e);return at(n.doc,n.range.focus,`
16
+ `)}function ar(t,e){for(let[n,o]of t.entries()){let r=o.children.indexOf(e);if(r!==-1)return [n,r]}return null}function cr(t){for(let[e,n]of t.entries())for(let[o,r]of n.children.entries())if(me(r))return [e,o];return null}function dr(t){let e=We(t);return {anchor:e,focus:e}}function ur(t,e){let n=t,o;if(w(e))o=oe(t,e.focus);else {let d=$e(t,e);n=d.doc,o=d.range.focus;}let r={type:Ee,children:[{text:""}]},i=o.path[0],[l,s]=Se(n[i].children,o.path[1],o.offset),a=_(n.map((d,f)=>f===i?{...d,children:[...l,r,...s]}:d)),u={path:ar(a,r)??[0,0],offset:0};return {doc:a,range:{anchor:u,focus:u}}}function fr(t,e){let n=cr(t);if(!n)return {doc:t,range:dr(t)};let[o,r]=n,i={type:ae,value:e.id,displayName:e.displayName,children:[{text:""}]},l=_(t.map((u,d)=>d===o?{...u,children:u.children.map((f,p)=>p===r?i:f)}:u)),[s,a]=ar(l,i)??[o,r],c={path:[s,a+1],offset:0};return {doc:l,range:{anchor:c,focus:c}}}function pr(t,e,n="end"){let o=cr(t);if(!o)return {doc:t,range:dr(t)};let[r,i]=o,l=t[r].children,s=i>0?Zo(l[i-1]):null,a=s?{...s,text:e}:{text:e},c=P(t,{path:[r,i],offset:0})+(n==="end"?e.length:0),u=_(t.map((f,p)=>p===r?{...f,children:l.map((m,h)=>h===i?a:m)}:f)),d=N(u,c);return {doc:u,range:{anchor:d,focus:d}}}function pi(t){let e=[];return t.color&&e.push(`color:${t.color}`),t.backgroundColor&&e.push(`background-color:${t.backgroundColor}`),e.join(";")}function hi(t){for(let e of t.children)if(J(e)||k(e)&&e.children.map(o=>o.text).join("").length>0||x(e)&&e.text.length>0)return false;return true}function hr(t,e,n,o){if(n.text==="")return;let r=n.text.split(`
17
+ `);for(let i=0;i<r.length;i++){let l=r[i],s=i===r.length-1;if(l.length>0){let c=t.createTextNode(l);if(n.underline){let d=t.createElement("u");d.append(c),c=d;}if(n.italic){let d=t.createElement("i");d.append(c),c=d;}if(n.bold){let d=t.createElement("b");d.append(c),c=d;}let u=pi(n);if(u){let d=t.createElement("span");d.setAttribute("style",u),d.append(c),c=d;}e.append(c);}(!s||l===""&&r.length>1&&o)&&e.append(t.createElement("br"));}}function mi(t,e,n,o){if(x(n)){hr(t,e,n,o);return}switch(n.type){case Z:{let r=t.createElement("a");r.setAttribute("href",de(n.url)),r.className=a$q({size:"sm",variant:"inline"});for(let i of n.children)hr(t,r,i,false);e.append(r);break}case ae:{let r=t.createElement("span");r.setAttribute("contenteditable","false"),r.dataset.userId=n.value,r.textContent=`@${n.displayName}`,e.append(r);break}case Ee:{let r=t.createElement("span");r.setAttribute("contenteditable","false"),r.dataset.mentionAnchor="true",r.textContent=n.children[0].text,e.append(r);break}}}function kn(t){return x(t)?t.text!=="":k(t)?t.children.some(e=>e.text!==""):true}function gi(t,e){let n=t.createElement("p");if(hi(e))return n.append(t.createElement("br")),n;let o=-1;for(let r=e.children.length-1;r>=0;r--)if(kn(e.children[r])){o=r;break}for(let[r,i]of e.children.entries())mi(t,n,i,r===o);return n}function ct(t,e){let n=e.ownerDocument,o=n.createDocumentFragment();for(let r of t)o.append(gi(n,r));e.replaceChildren(o);}var xi=1,bi=3,yi=11;function re(t){return t.nodeType===xi}function gr(t){return t.nodeType===yi&&"host"in t}function Ft(t){return t.nodeType===bi}function dt(t,e){return t.tagName.toLowerCase()===e}function Ei(t){return dt(t,"span")?t.getAttribute("contenteditable")==="false":false}function vi(t,e,n,o,r){if(o===t){let s=t.childNodes,a=Math.min(r,s.length);return a===0?{found:true,point:{path:[n,0],offset:0}}:Ri(e,n,a)}let i=t.childNodes,l=0;for(let s=0;s<e.children.length;s++){let a=e.children[s];if(x(a)){let c=Ut(e.children,s),u=br(a.text,i,l,n,s,o,r,c);if(u.found)return u;l+=Pe(a.text,c);}else if(k(a)){if(l>=i.length)continue;let c=i[l];if(!re(c)||!dt(c,"a")){l++;continue}let u=Ti(a,c,n,s,o,r);if(u.found)return u;l++;}else if(ce(a)||me(a)){if(l>=i.length)continue;let c=i[l];if(!re(c)||!Ei(c)){l++;continue}if(o===c||(re(o)||Ft(o))&&h(c,o))return {found:true,point:{path:[n,s+1],offset:0}};l++;}}return {found:false}}function Ri(t,e,n){let o=0;for(let l=0;l<t.children.length;l++){let s=t.children[l],a=x(s)?Pe(s.text,Ut(t.children,l)):1;if(o+a>=n){if(x(s))return {found:true,point:{path:[e,l],offset:xr(s.text,n-o)}};if(J(s))return {found:true,point:{path:[e,l+1],offset:0}};{let c=s.children.reduce((u,d)=>u+d.text.length,0);return {found:true,point:{path:[e,l],offset:c}}}}o+=a;}let r=t.children.length-1,i=t.children[r];if(x(i))return {found:true,point:{path:[e,r],offset:i.text.length}};if(J(i))return {found:true,point:{path:[e,r+1],offset:0}};if(k(i)){let l=i.children.reduce((s,a)=>s+a.text.length,0);return {found:true,point:{path:[e,r],offset:l}}}return {found:false}}function Ut(t,e){for(let n=e+1;n<t.length;n++)if(kn(t[n]))return false;return true}function Pe(t,e){if(t==="")return 0;let n=t.split(`
18
18
  `),o=0;for(let r=0;r<n.length;r++)n[r].length>0&&o++,r<n.length-1&&o++;return e&&t.endsWith(`
19
19
  `)&&o++,o}function xr(t,e){if(t==="")return 0;let n=t.split(`
20
20
  `),o=0,r=0;for(let i=0;i<n.length&&!(o>=e);i++){if(n[i].length>0){if(o+1>=e){r+=n[i].length,o++;break}r+=n[i].length,o++;}if(i<n.length-1){if(o+1>=e){r++,o++;break}r++,o++;}}return t.endsWith(`
21
21
  `)&&o<e&&(r=t.length),Math.min(r,t.length)}function br(t,e,n,o,r,i,l,s=false){if(t==="")return {found:false};let a=t.split(`
22
22
  `),c=n,u=0;for(let d=0;d<a.length;d++){let f=a[d],p=d===a.length-1;if(f.length>0&&c<e.length){let m=e[c],h$1=Vt(m);if(h$1!==null){if(i===h$1){let C=Math.min(l,f.length);return {found:true,point:{path:[o,r],offset:u+C}}}if(re(i)&&h(i,h$1))return {found:true,point:{path:[o,r],offset:u+(l===0?0:f.length)}}}u+=f.length,c++;}if(p){if(p&&s&&t.endsWith(`
23
- `)&&f===""&&c<e.length){let m=e[c];if(re(m)&&dt(m,"br")&&i===m)return {found:true,point:{path:[o,r],offset:u}};c++;}}else if(c<e.length){let m=e[c];if(re(m)&&dt(m,"br")&&i===m)return {found:true,point:{path:[o,r],offset:u+(l===0?0:1)}};u++,c++;}}return {found:false}}function Ti(t,e,n,o,r,i){if(!re(e))return {found:false};if(r===e){let c=e.childNodes,u=Math.min(i,c.length),d=0,f=0,p=0;for(let m of t.children){let h=Pe(m.text,false);if(p+h>=u){f=d+xr(m.text,u-p);break}d+=m.text.length,p+=h;}return p>=t.children.reduce((m,h)=>m+Pe(h.text,false),0)&&(f=t.children.reduce((m,h)=>m+h.text.length,0)),{found:true,point:{path:[n,o],offset:f}}}if(!h(e,r))return {found:false};let l=e.childNodes,s=0,a=0;for(let c of t.children){let u=br(c.text,l,a,n,o,r,i);if(u.found)return {found:true,point:{path:[n,o],offset:s+u.point.offset}};s+=c.text.length,a+=Pe(c.text,false);}return {found:false}}function Vt(t){if(Ft(t))return t;if(re(t)){let e=t;for(;re(e)&&e.childNodes.length===1;){let n=e.childNodes[0];if(Ft(n))return n;if(re(n))e=n;else break}}return null}function Kt(t,e,n,o){try{if(n!==t&&!h(t,n)||e.length===0)return null;if(n===t){let i=Math.min(o,t.childNodes.length);if(i===0)return {path:[0,0],offset:0};let l=Math.min(i,e.length)-1,s=e[l];if(!s)return null;let a=s.children.length-1,c=s.children[a];if(!c)return null;let u=x(c)?c.text.length:k(c)?c.children.reduce((d,f)=>d+f.text.length,0):0;return {path:[l,a],offset:u}}let r=t.children;for(let i=0;i<e.length;i++){let l=r[i];if(!l)return null;let s=e[i];if(n!==l&&!h(l,n))continue;let a=vi(l,s,i,n,o);return a.found?a.point:null}return null}catch{return null}}function mr(t,e,n){try{let[o,r]=n.path,i=n.offset;if(o<0||o>=e.length)return null;let l=e[o];if(r<0||r>=l.children.length)return null;let s=l.children[r],a=t.children[o];if(!a)return null;let c=a.childNodes,u=0;for(let d=0;d<r;d++){let f=l.children[d];x(f)?u+=Pe(f.text,Ut(l.children,d)):u++;}if(x(s))return yr(s.text,i,c,u,a,Ut(l.children,r));if(k(s)){if(u>=c.length)return null;let d=c[u];return !re(d)||!dt(d,"a")?null:ki(s,i,d)}else if(ce(s)||he(s)){let d=u+1;if(d<c.length){let f=c[d];if(Ft(f))return {node:f,offset:0}}return {node:a,offset:Math.min(d,a.childNodes.length)}}return null}catch{return null}}function yr(t,e,n,o,r,i=false){if(t==="")return {node:r,offset:o};let l=t.split(`
23
+ `)&&f===""&&c<e.length){let m=e[c];if(re(m)&&dt(m,"br")&&i===m)return {found:true,point:{path:[o,r],offset:u}};c++;}}else if(c<e.length){let m=e[c];if(re(m)&&dt(m,"br")&&i===m)return {found:true,point:{path:[o,r],offset:u+(l===0?0:1)}};u++,c++;}}return {found:false}}function Ti(t,e,n,o,r,i){if(!re(e))return {found:false};if(r===e){let c=e.childNodes,u=Math.min(i,c.length),d=0,f=0,p=0;for(let m of t.children){let h=Pe(m.text,false);if(p+h>=u){f=d+xr(m.text,u-p);break}d+=m.text.length,p+=h;}return p>=t.children.reduce((m,h)=>m+Pe(h.text,false),0)&&(f=t.children.reduce((m,h)=>m+h.text.length,0)),{found:true,point:{path:[n,o],offset:f}}}if(!h(e,r))return {found:false};let l=e.childNodes,s=0,a=0;for(let c of t.children){let u=br(c.text,l,a,n,o,r,i);if(u.found)return {found:true,point:{path:[n,o],offset:s+u.point.offset}};s+=c.text.length,a+=Pe(c.text,false);}return {found:false}}function Vt(t){if(Ft(t))return t;if(re(t)){let e=t;for(;re(e)&&e.childNodes.length===1;){let n=e.childNodes[0];if(Ft(n))return n;if(re(n))e=n;else break}}return null}function Kt(t,e,n,o){try{if(n!==t&&!h(t,n)||e.length===0)return null;if(n===t){let i=Math.min(o,t.childNodes.length);if(i===0)return {path:[0,0],offset:0};let l=Math.min(i,e.length)-1,s=e[l];if(!s)return null;let a=s.children.length-1,c=s.children[a];if(!c)return null;let u=x(c)?c.text.length:k(c)?c.children.reduce((d,f)=>d+f.text.length,0):0;return {path:[l,a],offset:u}}let r=t.children;for(let i=0;i<e.length;i++){let l=r[i];if(!l)return null;let s=e[i];if(n!==l&&!h(l,n))continue;let a=vi(l,s,i,n,o);return a.found?a.point:null}return null}catch{return null}}function mr(t,e,n){try{let[o,r]=n.path,i=n.offset;if(o<0||o>=e.length)return null;let l=e[o];if(r<0||r>=l.children.length)return null;let s=l.children[r],a=t.children[o];if(!a)return null;let c=a.childNodes,u=0;for(let d=0;d<r;d++){let f=l.children[d];x(f)?u+=Pe(f.text,Ut(l.children,d)):u++;}if(x(s))return yr(s.text,i,c,u,a,Ut(l.children,r));if(k(s)){if(u>=c.length)return null;let d=c[u];return !re(d)||!dt(d,"a")?null:ki(s,i,d)}else if(ce(s)||me(s)){let d=u+1;if(d<c.length){let f=c[d];if(Ft(f))return {node:f,offset:0}}return {node:a,offset:Math.min(d,a.childNodes.length)}}return null}catch{return null}}function yr(t,e,n,o,r,i=false){if(t==="")return {node:r,offset:o};let l=t.split(`
24
24
  `),s=o,a=0;for(let c=0;c<l.length;c++){let u=l[c],d=c===l.length-1;if(u.length>0&&s<n.length){let f=n[s];if(e>=a&&e<=a+u.length){let p=Vt(f);return p!==null?{node:p,offset:e-a}:{node:r,offset:s}}a+=u.length,s++;}if(d){if(d&&t.endsWith(`
25
- `)&&u===""&&s<=n.length){if(e===a)return {node:r,offset:Math.min(s,r.childNodes.length)};i&&s++;}}else if(s<n.length){if(e===a)return {node:r,offset:s};a++,s++;}}if(s>o&&s-1<n.length){let c=n[s-1],u=Vt(c);return u!==null?{node:u,offset:u.length}:{node:r,offset:s}}return {node:r,offset:Math.min(s,r.childNodes.length)}}function ki(t,e,n){let o=n.childNodes,r=0,i=0;for(let l of t.children){let s=l.text.length;if(e<=r+s)return yr(l.text,e-r,o,i,n);r+=s,i+=Pe(l.text,false);}if(o.length>0){let l=n.lastChild,s=l===null?null:Vt(l);return s!==null?{node:s,offset:s.length}:{node:n,offset:o.length}}return {node:n,offset:0}}function Wt(t){let e=t.getRootNode();if(typeof e.getSelection=="function")return e.getSelection();let n=t.ownerDocument;if(!n)return null;let o=n.defaultView;return o?o.getSelection():null}function Ci(t,e){let n=t.getComposedRanges;if(typeof n!="function")return null;let o;try{o=n.call(t,{shadowRoots:[e]});}catch{try{o=n.call(t,e);}catch{return null}}let r=o?.[0];return r?{startContainer:r.startContainer,startOffset:r.startOffset,endContainer:r.endContainer,endOffset:r.endOffset}:null}function Cn(t,e){let n=e.rangeCount>0?e.getRangeAt(0):null,o=n?{startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}:null;if(o&&h(t,o.startContainer))return o;let r=t.getRootNode();if(gr(r)){let i=Ci(e,r);if(i&&h(t,i.startContainer))return i}return o}function qt(t,e){try{let n=Wt(t);if(!n)return null;let{anchorNode:o,focusNode:r}=n;if(o&&r&&h(t,o)&&h(t,r)){let a=Kt(t,e,o,n.anchorOffset),c=Kt(t,e,r,n.focusOffset);if(a!==null&&c!==null)return {anchor:a,focus:c}}let i=Cn(t,n);if(!i)return null;let l=Kt(t,e,i.startContainer,i.startOffset);if(l===null)return null;let s=Kt(t,e,i.endContainer,i.endOffset);return s===null?null:{anchor:l,focus:s}}catch{return null}}function De(t,e,n){try{let o=mr(t,e,n.anchor);if(o===null)return;let r=mr(t,e,n.focus);if(r===null)return;let i=t.ownerDocument;if(!i)return;let l=Wt(t);if(!l)return;if(ve(n.anchor,n.focus)>0||gr(t.getRootNode())){l.setBaseAndExtent(o.node,o.offset,r.node,r.offset);return}let a=i.createRange();a.setStart(o.node,o.offset),a.setEnd(r.node,r.offset),l.removeAllRanges(),l.addRange(a);}catch{}}var Er="typing";var $t=class{undoStack=[];redoStack=[];now;maxDepth;lastKind=null;lastTime=null;constructor(e={}){this.now=e.now??Date.now,this.maxDepth=e.maxDepth??100;}record(e,n){let o=this.now();this.redoStack.length>0&&(this.redoStack=[]);let r=n===Er&&this.lastKind===Er&&this.lastTime!==null&&o-this.lastTime<=1e3;this.lastKind=n,this.lastTime=o,!r&&(this.undoStack.push(e),this.undoStack.length>this.maxDepth&&this.undoStack.shift());}undo(e){let n=this.undoStack.pop();return n?(this.redoStack.push(e),this.lastKind=null,this.lastTime=null,n):null}redo(e){let n=this.redoStack.pop();return n?(this.undoStack.push(e),this.lastKind=null,this.lastTime=null,n):null}clear(){this.undoStack=[],this.redoStack=[],this.lastKind=null,this.lastTime=null;}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}};var Mi=1,ut=class t{doc=Ke();lastKnownHtml="";lastAppliedValue=null;cachedRange=null;needsSelectionRestore=false;composing=false;pending=null;preservePendingSelectionChanges=0;history=new $t;opts;el=null;pendingExternalRender=null;keyboardShortcutsOverride=void 0;constructor(e={}){this.opts=e,this.lastKnownHtml=me(this.doc);}setKeyboardShortcutsEnabled(e){this.keyboardShortcutsOverride=e;}attach(e){this.el=e,ct(this.doc,e),this.cachedRange&&De(e,this.doc,this.cachedRange);let n=this.handleBeforeInputBound,o=this.handleInputBound,r=this.handlePasteBound,i=this.handleCompositionStartBound,l=this.handleCompositionEndBound,s=this.handleSelectionChangeBound,a=this.handlePointerDownBound,c=this.handleFocusBound,u=e.ownerDocument;return e.addEventListener("beforeinput",n),e.addEventListener("input",o),e.addEventListener("paste",r),e.addEventListener("compositionstart",i),e.addEventListener("compositionend",l),e.addEventListener("pointerdown",a),e.addEventListener("focus",c),u.addEventListener("selectionchange",s),()=>{e.removeEventListener("beforeinput",n),e.removeEventListener("input",o),e.removeEventListener("paste",r),e.removeEventListener("compositionstart",i),e.removeEventListener("compositionend",l),e.removeEventListener("pointerdown",a),e.removeEventListener("focus",c),u.removeEventListener("selectionchange",s),this.el===e&&(this.el=null);}}handleBeforeInputBound=e=>{let n=e;if(j$2(n)===this.el){if(this.opts.isReadOnly?.()){n.preventDefault();return}this.refreshSelectionFromDom(),this.handleBeforeInput(n);}};handleInputBound=e=>{j$2(e)===this.el&&(this.composing||this.syncFromDom());};handlePasteBound=e=>{let n=e,o=j$2(n);!o||!h(this.el,o)||(o.nodeType===Mi?o:o.parentElement)?.closest('input, [contenteditable="false"]')||(n.preventDefault(),!this.opts.isReadOnly?.()&&(this.composing||(this.refreshSelectionFromDom(),this.insertPastedData(n.clipboardData))));};handlePointerDownBound=()=>{this.preservePendingSelectionChanges=0,this.needsSelectionRestore=false;};handleFocusBound=()=>{this.needsSelectionRestore&&(this.needsSelectionRestore=false,!(!this.el||!this.cachedRange)&&De(this.el,this.doc,this.cachedRange));};handleCompositionStartBound=()=>{this.composing=true;};handleCompositionEndBound=()=>{if(this.composing=false,this.pendingExternalRender){let e=this.pendingExternalRender;this.pendingExternalRender=null,e();return}this.syncFromDom();};handleSelectionChangeBound=()=>{this.el&&this.handleSelectionChange();};refreshSelectionFromDom(){if(!this.el)return;let e=qt(this.el,this.doc);e&&(this.cachedRange=e);}getDoc(){return this.doc}getValue(){return me(this.doc)}setValue(e,n={}){if(e===this.lastKnownHtml||e===this.lastAppliedValue)return;let o,r;try{o=_(mn(e)),r=me(o);}catch(a){process.env.NODE_ENV!=="production"&&console.error("[Editor] setValue failed to parse value:",a);return}let i=this.cachedRange?P(this.doc,this.cachedRange.anchor):null,l=t.docHasMentionInput(this.doc);this.doc=o,this.lastKnownHtml=r,this.lastAppliedValue=e,this.pending=null,this.history.clear();let s=()=>{if(this.el&&(ct(o,this.el),i!==null)){let a=Math.min(i,Fe(o)),c=I(o,a),u={anchor:c,focus:c};this.cachedRange=u,this.hasFocus()?De(this.el,o,u):(this.needsSelectionRestore=true,n.emit||this.emitSelectionChange());}};this.el&&(this.composing?this.pendingExternalRender=s:s()),l&&!t.docHasMentionInput(o)&&this.opts.onMentionInputRemoved?.(),n.emit&&(this.opts.onChange?.(r),this.emitSelectionChange());}static docHasMentionInput(e){return e.some(n=>n.children.some(o=>he(o)))}exec(e,...n){this.refreshSelectionFromDom();let o=this.cachedRange,r=this.doc,i=o??this.collapsedAtDocEnd(),l={doc:r,range:o},s;try{s=this.dispatchCommand(e,n);}catch(a){process.env.NODE_ENV!=="production"&&console.error(`[Editor] command "${e}" threw:`,a);return}if(s.doc===r){if(e==="toggleMark"&&N(i)){let[a]=n;this.setPendingMark(a,i),this.emitSelectionChange();return}if(e==="setMarkValue"&&N(i)){let[a,c]=n;this.setPendingColorMark(a,c,i),this.emitSelectionChange();return}this.pending=null;return}if(this.pending=null,e==="insertSoftBreak"){let a=this.mergePendingMarks(ze(r,i));if(Object.keys(a).length>0){let c=P(s.doc,s.range.anchor);this.pending={marks:a,caretOffset:c},this.preservePendingSelectionChanges=10;}}this.history.record(l,e),this.applyDocChange(s.doc,s.range,true);}undo(){if(!this.history.canUndo)return;let e={doc:this.doc,range:this.cachedRange},n=this.history.undo(e);n&&(this.pending=null,this.applyDocChange(n.doc,n.range,true));}redo(){if(!this.history.canRedo)return;let e={doc:this.doc,range:this.cachedRange},n=this.history.redo(e);n&&(this.pending=null,this.applyDocChange(n.doc,n.range,true));}canUndo(){return this.history.canUndo}canRedo(){return this.history.canRedo}focus(){this.el?.focus();}hasFocus(){return this.el?h(this.el,f$1(this.el)):false}setCaretPosition(e){if(!this.el)return;let n=I(this.doc,e);this.select({anchor:n,focus:n});}select(e){this.el&&(this.el.focus(),this.cachedRange=e,De(this.el,this.doc,e));}selectStart(){this.setCaretPosition(0);}selectEnd(){let e=Ve(this.doc);this.select({anchor:e,focus:e});}getSelectionState(){return this.buildSelectionState(this.cachedRange)}buildSelectionState(e){let n=e?ze(this.doc,e):{},o=this.mergePendingMarks(n),r=e?nr(this.doc,e):null;return {marks:o,link:r,range:e}}mergePendingMarks(e){return this.pending?this.pending.marks:e}setPendingMark(e,n){let o=P(this.doc,n.anchor),r=ze(this.doc,n),i=this.pending?{...this.pending.marks}:{...r};i[e]?delete i[e]:i[e]=true,this.pending={marks:i,caretOffset:o};}setPendingColorMark(e,n,o){let r=P(this.doc,o.anchor),i=ze(this.doc,o),l=this.pending?{...this.pending.marks}:{...i};n===void 0?delete l[e]:l[e]=n,this.pending={marks:l,caretOffset:r};}emitSelectionChange(){this.opts.onSelectionChange&&this.opts.onSelectionChange(this.buildSelectionState(this.cachedRange));}applyDocChange(e,n,o){if(this.doc=e,this.cachedRange=n,this.lastAppliedValue=null,this.el&&!this.composing&&(ct(e,this.el),n&&De(this.el,e,n)),o){let r=me(e);this.lastKnownHtml=r,this.opts.onChange?.(r),this.emitSelectionChange();}}handleBeforeInput(e){let{inputType:n}=e;if(n==="insertParagraph"||n==="insertLineBreak"){e.preventDefault();let r=this.detectAutoLinkBeforeCaret();this.exec("insertSoftBreak"),r&&this.applyAutoLink(r);return}if(n==="insertText"&&e.data===" "){let r=this.detectAutoLinkBeforeCaret();if(r){e.preventDefault(),this.exec("insertText"," "),this.applyAutoLink(r);return}}if(n==="insertFromPaste"||n==="insertFromDrop"){e.preventDefault(),this.handlePasteInput(e);return}let o=this.keyboardShortcutsOverride??this.opts.areKeyboardShortcutsEnabled?.()??true;if(n==="formatBold"){e.preventDefault(),o&&this.exec("toggleMark","bold");return}if(n==="formatItalic"){e.preventDefault(),o&&this.exec("toggleMark","italic");return}if(n==="formatUnderline"){e.preventDefault(),o&&this.exec("toggleMark","underline");return}if(n==="historyUndo"){e.preventDefault(),o&&this.undo();return}if(n==="historyRedo"){e.preventDefault(),o&&this.redo();return}if(n==="insertText"&&e.data==="@"&&this.shouldTriggerMention()&&this.opts.canStartMention?.()!==false){e.preventDefault();let r=this.doc;this.exec("insertMentionInput"),this.doc===r?this.exec("insertText","@"):this.opts.onMentionTrigger?.();}}shouldTriggerMention(){if(!this.cachedRange)return true;if(!N(this.cachedRange))return false;let e=this.cachedRange,[n,o]=e.anchor.path,r=e.anchor.offset,i=this.doc;if(n>=i.length)return true;let l=i[n];if(o>=l.children.length)return true;let s=l.children[o];if(r===0&&o===0)return true;let a=null;if(x(s)){let c=s.text;if(r>0)a=c[r-1];else if(o>0)a=this.lastCharOf(l.children[o-1]);else return true}else if(k(s)){let c=s.children.map(u=>u.text).join("");if(r>0)a=c[r-1]??null;else if(o>0)a=this.lastCharOf(l.children[o-1]);else return true}else if(r===0&&o>0)a=this.lastCharOf(l.children[o-1]);else return true;return a===null?true:/^[\s"']$/.test(a)}lastCharOf(e){if(x(e)){let n=e.text;return n.length>0?n.at(-1)??null:null}if(k(e)){let o=(e.children??[]).at(-1);return o&&o.text.length>0?o.text.at(-1)??null:null}if(ce(e)){let n=e.displayName??"";return n.length>0?n.at(-1)??null:null}return null}autoLinkEnabled(){return this.opts.autoLink?.()??true}detectAutoLinkBeforeCaret(){return !this.autoLinkEnabled()||this.composing?null:this.findAutoLinkBeforeCaret()}findAutoLinkBeforeCaret(){let e=this.cachedRange;if(!e||!N(e))return null;let n=e.anchor,o=this.doc,r=n.path[0];if(r>=o.length)return null;let i=o[r].children,l=n.path[1],s=n.offset;if(l>=i.length){l=i.length-1;let f=i[l];if(!f||!x(f))return null;s=f.text.length;}else {let f=i[l];x(f)&&s>f.text.length&&(s=f.text.length);}let a=i[l];if(x(a)&&s<a.text.length&&!/\s/.test(a.text[s]))return null;let c="";for(;;){let f=i[l];if(!f||!x(f))break;if(s>0){let p=f.text[s-1];if(/\s/.test(p))break;c=p+c,s-=1;}else {if(l===0)break;let p=i[l-1];if(!x(p))break;l-=1,s=p.text.length;}}if(c==="")return null;let u=Ht(c);if(!u)return null;let d=P(o,{path:[r,l],offset:s});return {startAbs:d+u.start,endAbs:d+u.end,url:u.url}}applyAutoLink(e){let n=de(e.url);if(n==="")return;let o=this.doc,r={anchor:I(o,e.startAbs),focus:I(o,e.endAbs)},i={doc:o,range:this.cachedRange},l=Tn(o,r,n);if(l.doc===o)return;let s=this.cachedRange?P(o,this.cachedRange.anchor):e.endAbs;this.history.record(i,"wrapLink");let a=I(l.doc,s);this.applyDocChange(l.doc,{anchor:a,focus:a},true);}handlePasteInput(e){this.insertPastedData(e.dataTransfer);}resolvePastedMentions(e){let n=this.opts.resolveMention;return n?e.map(o=>({...o,children:o.children.map(r=>{if(!ce(r))return r;let i=n(r.value);return i===void 0?{text:`@${r.displayName}`}:{...r,displayName:i}})})):e}insertPastedData(e){if(!e)return;let n=this.autoLinkEnabled(),o=e.getData("text/plain");if(n&&o){let i=this.cachedRange;if(i&&!N(i)&&i.anchor.path[0]===i.focus.path[0]){let l=qo(o),s=l?de(l):"";if(s&&!or(this.doc,i)){this.exec("wrapLink",s);return}}}let r=e.getData("text/html");if(r)try{let i=_(this.resolvePastedMentions(mn(r)));n&&(i=_(gn(i))),this.exec("insertFragment",i);return}catch(i){process.env.NODE_ENV!=="production"&&console.error("[Editor] failed to parse pasted HTML:",i);}if(o){let i=Le(o.replaceAll(`\r
25
+ `)&&u===""&&s<=n.length){if(e===a)return {node:r,offset:Math.min(s,r.childNodes.length)};i&&s++;}}else if(s<n.length){if(e===a)return {node:r,offset:s};a++,s++;}}if(s>o&&s-1<n.length){let c=n[s-1],u=Vt(c);return u!==null?{node:u,offset:u.length}:{node:r,offset:s}}return {node:r,offset:Math.min(s,r.childNodes.length)}}function ki(t,e,n){let o=n.childNodes,r=0,i=0;for(let l of t.children){let s=l.text.length;if(e<=r+s)return yr(l.text,e-r,o,i,n);r+=s,i+=Pe(l.text,false);}if(o.length>0){let l=n.lastChild,s=l===null?null:Vt(l);return s!==null?{node:s,offset:s.length}:{node:n,offset:o.length}}return {node:n,offset:0}}function Wt(t){let e=t.getRootNode();if(typeof e.getSelection=="function")return e.getSelection();let n=t.ownerDocument;if(!n)return null;let o=n.defaultView;return o?o.getSelection():null}function Ci(t,e){let n=t.getComposedRanges;if(typeof n!="function")return null;let o;try{o=n.call(t,{shadowRoots:[e]});}catch{try{o=n.call(t,e);}catch{return null}}let r=o?.[0];return r?{startContainer:r.startContainer,startOffset:r.startOffset,endContainer:r.endContainer,endOffset:r.endOffset}:null}function Cn(t,e){let n=e.rangeCount>0?e.getRangeAt(0):null,o=n?{startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}:null;if(o&&h(t,o.startContainer))return o;let r=t.getRootNode();if(gr(r)){let i=Ci(e,r);if(i&&h(t,i.startContainer))return i}return o}function qt(t,e){try{let n=Wt(t);if(!n)return null;let{anchorNode:o,focusNode:r}=n;if(o&&r&&h(t,o)&&h(t,r)){let a=Kt(t,e,o,n.anchorOffset),c=Kt(t,e,r,n.focusOffset);if(a!==null&&c!==null)return {anchor:a,focus:c}}let i=Cn(t,n);if(!i)return null;let l=Kt(t,e,i.startContainer,i.startOffset);if(l===null)return null;let s=Kt(t,e,i.endContainer,i.endOffset);return s===null?null:{anchor:l,focus:s}}catch{return null}}function De(t,e,n){try{let o=mr(t,e,n.anchor);if(o===null)return;let r=mr(t,e,n.focus);if(r===null)return;let i=t.ownerDocument;if(!i)return;let l=Wt(t);if(!l)return;if(ve(n.anchor,n.focus)>0||gr(t.getRootNode())){l.setBaseAndExtent(o.node,o.offset,r.node,r.offset);return}let a=i.createRange();a.setStart(o.node,o.offset),a.setEnd(r.node,r.offset),l.removeAllRanges(),l.addRange(a);}catch{}}var Er="typing";var $t=class{undoStack=[];redoStack=[];now;maxDepth;lastKind=null;lastTime=null;constructor(e={}){this.now=e.now??Date.now,this.maxDepth=e.maxDepth??100;}record(e,n){let o=this.now();this.redoStack.length>0&&(this.redoStack=[]);let r=n===Er&&this.lastKind===Er&&this.lastTime!==null&&o-this.lastTime<=1e3;this.lastKind=n,this.lastTime=o,!r&&(this.undoStack.push(e),this.undoStack.length>this.maxDepth&&this.undoStack.shift());}undo(e){let n=this.undoStack.pop();return n?(this.redoStack.push(e),this.lastKind=null,this.lastTime=null,n):null}redo(e){let n=this.redoStack.pop();return n?(this.undoStack.push(e),this.lastKind=null,this.lastTime=null,n):null}clear(){this.undoStack=[],this.redoStack=[],this.lastKind=null,this.lastTime=null;}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}};var Mi=1,ut=class t{doc=Fe();lastKnownHtml="";lastAppliedValue=null;cachedRange=null;needsSelectionRestore=false;composing=false;pending=null;preservePendingSelectionChanges=0;history=new $t;opts;el=null;pendingExternalRender=null;keyboardShortcutsOverride=void 0;constructor(e={}){this.opts=e,this.lastKnownHtml=ge(this.doc);}setKeyboardShortcutsEnabled(e){this.keyboardShortcutsOverride=e;}attach(e){this.el=e,ct(this.doc,e),this.cachedRange&&De(e,this.doc,this.cachedRange);let n=this.handleBeforeInputBound,o=this.handleInputBound,r=this.handlePasteBound,i=this.handleCompositionStartBound,l=this.handleCompositionEndBound,s=this.handleSelectionChangeBound,a=this.handlePointerDownBound,c=this.handleFocusBound,u=e.ownerDocument;return e.addEventListener("beforeinput",n),e.addEventListener("input",o),e.addEventListener("paste",r),e.addEventListener("compositionstart",i),e.addEventListener("compositionend",l),e.addEventListener("pointerdown",a),e.addEventListener("focus",c),u.addEventListener("selectionchange",s),()=>{e.removeEventListener("beforeinput",n),e.removeEventListener("input",o),e.removeEventListener("paste",r),e.removeEventListener("compositionstart",i),e.removeEventListener("compositionend",l),e.removeEventListener("pointerdown",a),e.removeEventListener("focus",c),u.removeEventListener("selectionchange",s),this.el===e&&(this.el=null);}}handleBeforeInputBound=e=>{let n=e;if(j$2(n)===this.el){if(this.opts.isReadOnly?.()){n.preventDefault();return}this.refreshSelectionFromDom(),this.handleBeforeInput(n);}};handleInputBound=e=>{j$2(e)===this.el&&(this.composing||this.syncFromDom());};handlePasteBound=e=>{let n=e,o=j$2(n);!o||!h(this.el,o)||(o.nodeType===Mi?o:o.parentElement)?.closest('input, [contenteditable="false"]')||(n.preventDefault(),!this.opts.isReadOnly?.()&&(this.composing||(this.refreshSelectionFromDom(),this.insertPastedData(n.clipboardData))));};handlePointerDownBound=()=>{this.preservePendingSelectionChanges=0,this.needsSelectionRestore=false;};handleFocusBound=()=>{this.needsSelectionRestore&&(this.needsSelectionRestore=false,!(!this.el||!this.cachedRange)&&De(this.el,this.doc,this.cachedRange));};handleCompositionStartBound=()=>{this.composing=true;};handleCompositionEndBound=()=>{if(this.composing=false,this.pendingExternalRender){let e=this.pendingExternalRender;this.pendingExternalRender=null,e();return}this.syncFromDom();};handleSelectionChangeBound=()=>{this.el&&this.handleSelectionChange();};refreshSelectionFromDom(){if(!this.el)return;let e=qt(this.el,this.doc);e&&(this.cachedRange=e);}getDoc(){return this.doc}getValue(){return ge(this.doc)}setValue(e,n={}){if(e===this.lastKnownHtml||e===this.lastAppliedValue)return;let o,r;try{o=_(mn(e)),r=ge(o);}catch(a){process.env.NODE_ENV!=="production"&&console.error("[Editor] setValue failed to parse value:",a);return}let i=this.cachedRange?P(this.doc,this.cachedRange.anchor):null,l=t.docHasMentionInput(this.doc);this.doc=o,this.lastKnownHtml=r,this.lastAppliedValue=e,this.pending=null,this.history.clear();let s=()=>{if(this.el&&(ct(o,this.el),i!==null)){let a=Math.min(i,Ue(o)),c=N(o,a),u={anchor:c,focus:c};this.cachedRange=u,this.hasFocus()?De(this.el,o,u):(this.needsSelectionRestore=true,n.emit||this.emitSelectionChange());}};this.el&&(this.composing?this.pendingExternalRender=s:s()),l&&!t.docHasMentionInput(o)&&this.opts.onMentionInputRemoved?.(),n.emit&&(this.opts.onChange?.(r),this.emitSelectionChange());}static docHasMentionInput(e){return e.some(n=>n.children.some(o=>me(o)))}exec(e,...n){this.refreshSelectionFromDom();let o=this.cachedRange,r=this.doc,i=o??this.collapsedAtDocEnd(),l={doc:r,range:o},s;try{s=this.dispatchCommand(e,n);}catch(a){process.env.NODE_ENV!=="production"&&console.error(`[Editor] command "${e}" threw:`,a);return}if(s.doc===r){if(e==="toggleMark"&&w(i)){let[a]=n;this.setPendingMark(a,i),this.emitSelectionChange();return}if(e==="setMarkValue"&&w(i)){let[a,c]=n;this.setPendingColorMark(a,c,i),this.emitSelectionChange();return}this.pending=null;return}if(this.pending=null,e==="insertSoftBreak"){let a=this.mergePendingMarks(ze(r,i));if(Object.keys(a).length>0){let c=P(s.doc,s.range.anchor);this.pending={marks:a,caretOffset:c},this.preservePendingSelectionChanges=10;}}this.history.record(l,e),this.applyDocChange(s.doc,s.range,true);}undo(){if(!this.history.canUndo)return;let e={doc:this.doc,range:this.cachedRange},n=this.history.undo(e);n&&(this.pending=null,this.applyDocChange(n.doc,n.range,true));}redo(){if(!this.history.canRedo)return;let e={doc:this.doc,range:this.cachedRange},n=this.history.redo(e);n&&(this.pending=null,this.applyDocChange(n.doc,n.range,true));}canUndo(){return this.history.canUndo}canRedo(){return this.history.canRedo}focus(){this.el?.focus();}hasFocus(){return this.el?h(this.el,f$1(this.el)):false}setCaretPosition(e){if(!this.el)return;let n=N(this.doc,e);this.select({anchor:n,focus:n});}select(e){this.el&&(this.el.focus(),this.cachedRange=e,De(this.el,this.doc,e));}selectStart(){this.setCaretPosition(0);}selectEnd(){let e=We(this.doc);this.select({anchor:e,focus:e});}getSelectionState(){return this.buildSelectionState(this.cachedRange)}buildSelectionState(e){let n=e?ze(this.doc,e):{},o=this.mergePendingMarks(n),r=e?nr(this.doc,e):null;return {marks:o,link:r,range:e}}mergePendingMarks(e){return this.pending?this.pending.marks:e}setPendingMark(e,n){let o=P(this.doc,n.anchor),r=ze(this.doc,n),i=this.pending?{...this.pending.marks}:{...r};i[e]?delete i[e]:i[e]=true,this.pending={marks:i,caretOffset:o};}setPendingColorMark(e,n,o){let r=P(this.doc,o.anchor),i=ze(this.doc,o),l=this.pending?{...this.pending.marks}:{...i};n===void 0?delete l[e]:l[e]=n,this.pending={marks:l,caretOffset:r};}emitSelectionChange(){this.opts.onSelectionChange&&this.opts.onSelectionChange(this.buildSelectionState(this.cachedRange));}applyDocChange(e,n,o){if(this.doc=e,this.cachedRange=n,this.lastAppliedValue=null,this.el&&!this.composing&&(ct(e,this.el),n&&De(this.el,e,n)),o){let r=ge(e);this.lastKnownHtml=r,this.opts.onChange?.(r),this.emitSelectionChange();}}handleBeforeInput(e){let{inputType:n}=e;if(n==="insertParagraph"||n==="insertLineBreak"){e.preventDefault();let r=this.detectAutoLinkBeforeCaret();this.exec("insertSoftBreak"),r&&this.applyAutoLink(r);return}if(n==="insertText"&&e.data===" "){let r=this.detectAutoLinkBeforeCaret();if(r){e.preventDefault(),this.exec("insertText"," "),this.applyAutoLink(r);return}}if(n==="insertFromPaste"||n==="insertFromDrop"){e.preventDefault(),this.handlePasteInput(e);return}let o=this.keyboardShortcutsOverride??this.opts.areKeyboardShortcutsEnabled?.()??true;if(n==="formatBold"){e.preventDefault(),o&&this.exec("toggleMark","bold");return}if(n==="formatItalic"){e.preventDefault(),o&&this.exec("toggleMark","italic");return}if(n==="formatUnderline"){e.preventDefault(),o&&this.exec("toggleMark","underline");return}if(n==="historyUndo"){e.preventDefault(),o&&this.undo();return}if(n==="historyRedo"){e.preventDefault(),o&&this.redo();return}if(n==="insertText"&&e.data==="@"&&this.shouldTriggerMention()&&this.opts.canStartMention?.()!==false){e.preventDefault();let r=this.doc;this.exec("insertMentionInput"),this.doc===r?this.exec("insertText","@"):this.opts.onMentionTrigger?.();}}shouldTriggerMention(){if(!this.cachedRange)return true;if(!w(this.cachedRange))return false;let e=this.cachedRange,[n,o]=e.anchor.path,r=e.anchor.offset,i=this.doc;if(n>=i.length)return true;let l=i[n];if(o>=l.children.length)return true;let s=l.children[o];if(r===0&&o===0)return true;let a=null;if(x(s)){let c=s.text;if(r>0)a=c[r-1];else if(o>0)a=this.lastCharOf(l.children[o-1]);else return true}else if(k(s)){let c=s.children.map(u=>u.text).join("");if(r>0)a=c[r-1]??null;else if(o>0)a=this.lastCharOf(l.children[o-1]);else return true}else if(r===0&&o>0)a=this.lastCharOf(l.children[o-1]);else return true;return a===null?true:/^[\s"']$/.test(a)}lastCharOf(e){if(x(e)){let n=e.text;return n.length>0?n.at(-1)??null:null}if(k(e)){let o=(e.children??[]).at(-1);return o&&o.text.length>0?o.text.at(-1)??null:null}if(ce(e)){let n=e.displayName??"";return n.length>0?n.at(-1)??null:null}return null}autoLinkEnabled(){return this.opts.autoLink?.()??true}detectAutoLinkBeforeCaret(){return !this.autoLinkEnabled()||this.composing?null:this.findAutoLinkBeforeCaret()}findAutoLinkBeforeCaret(){let e=this.cachedRange;if(!e||!w(e))return null;let n=e.anchor,o=this.doc,r=n.path[0];if(r>=o.length)return null;let i=o[r].children,l=n.path[1],s=n.offset;if(l>=i.length){l=i.length-1;let f=i[l];if(!f||!x(f))return null;s=f.text.length;}else {let f=i[l];x(f)&&s>f.text.length&&(s=f.text.length);}let a=i[l];if(x(a)&&s<a.text.length&&!/\s/.test(a.text[s]))return null;let c="";for(;;){let f=i[l];if(!f||!x(f))break;if(s>0){let p=f.text[s-1];if(/\s/.test(p))break;c=p+c,s-=1;}else {if(l===0)break;let p=i[l-1];if(!x(p))break;l-=1,s=p.text.length;}}if(c==="")return null;let u=Ht(c);if(!u)return null;let d=P(o,{path:[r,l],offset:s});return {startAbs:d+u.start,endAbs:d+u.end,url:u.url}}applyAutoLink(e){let n=de(e.url);if(n==="")return;let o=this.doc,r={anchor:N(o,e.startAbs),focus:N(o,e.endAbs)},i={doc:o,range:this.cachedRange},l=Tn(o,r,n);if(l.doc===o)return;let s=this.cachedRange?P(o,this.cachedRange.anchor):e.endAbs;this.history.record(i,"wrapLink");let a=N(l.doc,s);this.applyDocChange(l.doc,{anchor:a,focus:a},true);}handlePasteInput(e){this.insertPastedData(e.dataTransfer);}resolvePastedMentions(e){let n=this.opts.resolveMention;return n?e.map(o=>({...o,children:o.children.map(r=>{if(!ce(r))return r;let i=n(r.value);return i===void 0?{text:`@${r.displayName}`}:{...r,displayName:i}})})):e}insertPastedData(e){if(!e)return;let n=this.autoLinkEnabled(),o=e.getData("text/plain");if(n&&o){let i=this.cachedRange;if(i&&!w(i)&&i.anchor.path[0]===i.focus.path[0]){let l=qo(o),s=l?de(l):"";if(s&&!or(this.doc,i)){this.exec("wrapLink",s);return}}}let r=e.getData("text/html");if(r)try{let i=_(this.resolvePastedMentions(mn(r)));n&&(i=_(gn(i))),this.exec("insertFragment",i);return}catch(i){process.env.NODE_ENV!=="production"&&console.error("[Editor] failed to parse pasted HTML:",i);}if(o){let i=Le(o.replaceAll(`\r
26
26
  `,`
27
27
  `).replaceAll("\r",`
28
- `)),l=_([{type:"p",children:[{text:i}]}]);n&&(l=_(gn(l))),this.exec("insertFragment",l);}}syncFromDom(){if(!this.el||this.composing)return;let e=this.doc,n={doc:e,range:this.cachedRange},o=Bt(this.el),r=qt(this.el,o);if(!(me(o)!==this.lastKnownHtml)){if(r){let d=this.cachedRange;this.cachedRange=r,(!d||!this.rangesEqual(d,r))&&this.emitSelectionChange();}return}this.history.record(n,"typing");let s=o,a=r,c=false;if(!a&&n.range){let d=Math.max(Fe(o)-Fe(e),0),f=this.pending?this.pending.caretOffset:P(e,n.range.anchor),p=I(o,f+d);a={anchor:p,focus:p};}if(this.pending){let d=this.pending.marks,f=a;if(f){let p=this.applyPendingMarks(o,n.range,f);p.doc!==o&&(s=p.doc,a=p.range,c=true),this.pending=a?{marks:d,caretOffset:P(s,a.anchor)}:null,a&&(this.preservePendingSelectionChanges=10);}else this.pending=null;}this.doc=s,this.cachedRange=a;let u=me(s);this.lastKnownHtml=u,this.lastAppliedValue=null,c&&(ct(s,this.el),a&&De(this.el,s,a)),this.opts.onChange?.(u),this.emitSelectionChange();}applyPendingMarks(e,n,o){if(!this.pending||!n||!o)return {doc:e,range:o??{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}};let r=this.pending.caretOffset,i=o?P(e,o.anchor):r;if(i<=r)return {doc:e,range:o??{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}};let l=this.applyPendingMarkSnapshot(e,this.pending.marks,r,i),s=I(l,i);return {doc:l,range:{anchor:s,focus:s}}}applyPendingMarkSnapshot(e,n,o,r){let i=e,l=()=>({anchor:I(i,o),focus:I(i,r)});for(let s of ["bold","italic","underline"]){let a=l(),c=!!n[s],u=!!ze(i,a)[s];if(c!==u){let d=En(i,a,s);d.doc!==i&&(i=d.doc);}}for(let s of ["color","backgroundColor"]){let a=l(),c=n[s],u=ze(i,a)[s];if(!b$a(c,u)){let d=vn(i,a,s,c);d.doc!==i&&(i=d.doc);}}return i}handleSelectionChange(){if(!this.el)return;let e=Wt(this.el);if(!e)return;let n=Cn(this.el,e);if(!n||!h(this.el,n.startContainer))return;let o=qt(this.el,this.doc),r=this.cachedRange;this.preservePendingSelectionChanges>0?(this.preservePendingSelectionChanges-=1,this.pending&&o&&(this.pending={...this.pending,caretOffset:P(this.doc,o.anchor)})):this.pending&&o&&P(this.doc,o.anchor)!==this.pending.caretOffset&&(this.pending=null),o!==null&&(this.cachedRange=o),(!r||!o||!this.rangesEqual(r,o))&&this.emitSelectionChange();}dispatchCommand(e,n){let o=this.doc,r=this.cachedRange??this.collapsedAtDocEnd();switch(e){case "toggleMark":{let[i]=n;return En(o,r,i)}case "setMarkValue":{let[i,l]=n;return vn(o,r,i,l)}case "wrapLink":{let[i]=n;return Tn(o,r,i)}case "updateLinkUrl":{let[i]=n;return rr(o,r,i)}case "unwrapLink":return ir(o,r);case "deleteRange":return qe(o,r);case "insertText":{let[i]=n;if(!N(r)){let l=qe(o,r);return at(l.doc,l.range.focus,i)}return at(o,r.anchor,i)}case "insertFragment":{let[i]=n;return sr(o,r,i)}case "insertSoftBreak":return lr(o,r);case "insertMentionInput":return ur(o,r);case "confirmMention":{let[i]=n;return fr(o,i)}case "removeMentionInput":{let[i]=n;return pr(o,i)}default:return {doc:o,range:r}}}collapsedAtDocEnd(){let e=Ve(this.doc);return {anchor:e,focus:e}}rangesEqual(e,n){return e.anchor.path[0]===n.anchor.path[0]&&e.anchor.path[1]===n.anchor.path[1]&&e.anchor.offset===n.anchor.offset&&e.focus.path[0]===n.focus.path[0]&&e.focus.path[1]===n.focus.path[1]&&e.focus.offset===n.focus.offset}};var ft=mt.createContext(null);function ge(){let t=mt.useContext(ft);if(!t)throw new Error("useEditorContext must be used within an EditorProvider");return t}var Gt=Object.freeze({marks:{},link:null,range:null});function zi(t){let e=Le(t.replaceAll(/<br\s*\/?>/gi,""));return e==="<p></p>"||e===""||e==="<p> </p>"}function Mn(t={}){let{value:e,defaultValue:n,onChange:o,isDisabled:r,keyboardShortcuts:i,onSelectionChange:l,onMentionTrigger:s,onMentionInputRemoved:a,canStartMention:c,resolveMention:u,isReadOnly:d,autoLink:f}=t;e!==void 0&&o===void 0&&a$c("use-editor-value-without-onchange","useEditor: `value` without `onChange` is controlled but cannot reflect edits \u2014 they are discarded on the next render. Use `defaultValue` for initial content, or add `onChange`.");let[p,m]=useState(Gt),[h,C]=useState(()=>e??n??""),S=useRef(o);S.current=o;let U=useRef(l);U.current=l;let M=useRef(s);M.current=s;let O=useRef(a);O.current=a;let z=useRef(c);z.current=c;let L=useRef(u);L.current=u;let q=useRef(d);q.current=d;let $=useRef(r);$.current=r;let te=useRef(i);te.current=i;let g=useRef(f);g.current=f;let y=useRef(null);y.current===null&&(y.current=new ut({onChange:T=>{C(T),S.current?.(T);},onSelectionChange:T=>{m(T),U.current?.(T);},onMentionTrigger:()=>{M.current?.();},onMentionInputRemoved:()=>{O.current?.();},canStartMention:()=>z.current?.()??false,get resolveMention(){return L.current},autoLink:()=>g.current!==false,isReadOnly:()=>q.current?.()??!!$.current,areKeyboardShortcutsEnabled:()=>te.current!==false}));let v=y.current;useLayoutEffect(()=>{e!==void 0&&v.setValue(e);});let b=useRef(false);useEffect(()=>{if(!b.current){b.current=true;let T=e??n;T&&v.setValue(T);}},[v]),useEffect(()=>{r&&m(Gt);},[r]);let ie=e??h,se=zi(ie),ue=v.canUndo(),fe=v.canRedo();return useMemo(()=>({core:v,selectionState:p,value:ie,isEmpty:se,isDisabled:!!r,keyboardShortcuts:i!==false,canUndo:ue,canRedo:fe,focus:()=>{v.focus();},selectStart:()=>{v.selectStart();},selectEnd:()=>{v.selectEnd();},setCaretPosition:T=>{v.setCaretPosition(T);},undo:()=>{v.undo();},redo:()=>{v.redo();},getValue:()=>v.getValue(),setValue:(T,B)=>{v.setValue(T,B);},exec:(T,...B)=>{v.exec(T,...B);},isMarkActive:T=>!!p.marks[T],toggleMark:T=>{v.exec("toggleMark",T);},setMark:(T,B)=>{v.exec("setMarkValue",T,B);}}),[v,p,ie,se,r,i,ue,fe])}function Cr(t,e){let n=t.ctrlKey||t.metaKey,o=t.key.toLowerCase();if(n&&!t.altKey&&o==="z")return t.preventDefault(),t.shiftKey?e.redo():e.undo(),true;if(t.ctrlKey&&!t.altKey&&!t.shiftKey&&o==="y")return t.preventDefault(),e.redo(),true;if(n&&!t.shiftKey&&!t.altKey){if(o==="b")return t.preventDefault(),e.toggleMark("bold"),true;if(o==="i")return t.preventDefault(),e.toggleMark("italic"),true;if(o==="u")return t.preventDefault(),e.toggleMark("underline"),true}return false}function Sn(t,e={}){let n=Ni(t),{ref:o,autoFocus:r,onKeyDown:i,keyboardShortcuts:l}=e,s=l??n.keyboardShortcuts,a=useId(),c=useRef(null),u=useRef(null),d=useCallback(h=>{u.current&&(u.current(),u.current=null),h&&(u.current=n.core.attach(h));},[n.core]),f=useMemo(()=>b(c,d,o??null),[d,o]);useEffect(()=>(n.core.setKeyboardShortcutsEnabled(l),()=>{n.core.setKeyboardShortcutsEnabled(void 0);}),[n.core,l]);let p=useRef(false);useEffect(()=>{if(!p.current)switch(p.current=true,r){case true:{n.focus();break}case "start":{n.selectStart();break}case "end":{n.selectEnd();break}}},[n.core]);let{keyboardProps:m}=j({onKeyDown:h=>{i?.(h)||s&&Cr(h,n)||h.continuePropagation();}});return {editableProps:{...m,id:a,ref:f,contentEditable:!n.isDisabled,suppressContentEditableWarning:true,role:"textbox","aria-multiline":true}}}function Ni(t){let e=useContext(ft);if(t)return t;if(!e)throw new Error("useEditable must be passed an editor or used within an EditorProvider");return e}var zn=({editor:t,children:e})=>jsx(ft.Provider,{value:t,children:e});var Xt=({markName:t,icon:e,ariaLabel:n,isDisabled:o})=>{let{core:r,selectionState:i}=ge(),l=!!i.marks[t];return jsx(a$f,{variant:"tertiary",isSelected:l,size:"sm",icon:e,"aria-label":n,"data-testid":`editor-${t}-button`,isDisabled:o,onPress:()=>{r.exec("toggleMark",t),r.focus();},preventFocusOnPress:true})},Dn=({colorKey:t,"aria-label":e,isDisabled:n})=>{let{core:o,selectionState:r}=ge(),i=t==="color"?r.marks.color:r.marks.backgroundColor,l=mt.useRef(null),s=useCallback(()=>{l.current=r.range;},[r.range]),a=useCallback(p=>{setTimeout(()=>{let m=o.getSelectionState().range??l.current;m&&o.select(m),o.exec("setMarkValue",t,p);},0);},[o,t]),c=useCallback(p=>{a(p);},[a]),u=useCallback(()=>{a();},[a]),d=useCallback(({ref:p,triggerProps:m})=>jsx(a$b,{icon:t==="color"?TextIcon:HighlightTextIcon,"aria-label":e,"data-testid":t==="color"?"editor-font-color-button":"editor-background-color-button",size:"md",variant:"popover",isDisabled:n,className:Be,preventFocusOnPress:true,...m,ref:p}),[t,e,n]),f=useCallback(p=>{p?c(p.toString("rgba")):u();},[u,c]);return jsx(b$4,{presets:cn,allowRemoval:true,pickerMode:"lazy",placement:"top end",colorLabel:false,renderTriggerButton:d,onTriggerPress:s,value:i||"#000000",onChange:f,isDisabled:n})};var _e={Add:"add",Edit:"edit",Show:"show"},Lr=({isDisabled:t,addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:l})=>{let{formatMessage:s}=b$1(),{core:a}=ge();return jsxs(b$5,{type:"dialog",children:[jsx(j$1,{children:jsx(a$b,{icon:LinkIcon,size:"sm",isDisabled:t,"aria-label":e??s(Ie.addLink),"data-testid":"editor-add-link-button",className:Be,preventFocusOnPress:true})}),jsx(a$g,{className:sprinkles({boxShadow:"medium"}),placement:"top end",children:({close:c})=>jsx(a$h,{size:"content",style:{minWidth:240},children:jsx(Ki,{addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:l,close:()=>{c(),setTimeout(()=>{a.focus();},0);}})})})]})},Ki=({close:t,addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:l})=>{let{core:s,selectionState:a}=ge(),{formatMessage:c}=b$1(),u=a.link?.url,[d,f]=mt.useState(u?_e.Show:_e.Add),[p,m]=mt.useState(u||""),h=jsx(a$9,{padding:"lg",children:jsx(a$o,{label:r??c(Ie.link),value:p,autoFocus:true,onChange:m,placeholder:"https://yourdomain.com","data-testid":"editor-link-input"})});return jsxs(Fragment,{children:[d===_e.Add&&jsxs(Fragment,{children:[h,jsx(a$9,{display:"flex",justifyContent:"flex-end",padding:"lg",className:yo,children:jsx(b$b,{isDisabled:!a$p(p,true)||de(p)==="",label:e??c(Ie.addLink),"data-testid":"editor-link-add-button",size:"sm",onPress:()=>{s.exec("wrapLink",hn(p)),t?.();},preventFocusOnPress:true})})]}),d===_e.Show&&jsxs(Fragment,{children:[jsx(a$9,{padding:"lg",children:jsx(a$m,{type:"subtitle",size:"sm",children:u})}),jsxs(a$9,{display:"flex",justifyContent:"flex-end",padding:"lg",gap:"lg",borderColor:"border.subtle",borderWidth:1,borderStyle:"solid",children:[jsx(b$b,{label:n??c(Ie.editLink),"data-testid":"editor-link-edit-button",size:"sm",variant:"secondary",onPress:()=>{f(_e.Edit);},style:{flex:1,justifyContent:"center"}}),jsx(b$b,{label:o??c(Ie.removeLink),"data-testid":"editor-link-remove-button",size:"sm",onPress:()=>{s.exec("unwrapLink"),t?.();},preventFocusOnPress:true,style:{flex:1,justifyContent:"center"}})]})]}),d===_e.Edit&&jsxs(Fragment,{children:[h,jsxs(a$9,{display:"flex",justifyContent:"flex-end",padding:"lg",gap:"lg",borderColor:"border.subtle",borderWidth:1,borderStyle:"solid",children:[jsx(b$b,{label:i??c(Ie.cancel),"data-testid":"editor-link-cancel-button",size:"sm",variant:"secondary",onPress:()=>{f(_e.Show),t?.();}}),jsx(b$b,{label:l??c(Ie.save),"data-testid":"editor-link-save-button",size:"sm",isDisabled:!a$p(p,true)||de(p)==="",onPress:()=>{s.exec("updateLinkUrl",hn(p)),t?.();}})]})]})]})},Ie=c$1({addLink:{id:"bui.editor.addLink",defaultMessage:"Add Link"},editLink:{id:"bui.editor.editLink",defaultMessage:"Edit Link"},removeLink:{id:"bui.editor.removeLink",defaultMessage:"Remove Link"},cancel:{id:"bui.editor.cancel",defaultMessage:"Cancel"},save:{id:"bui.editor.save",defaultMessage:"Save"},link:{id:"bui.editor.linkAnnotation",defaultMessage:"Link"}});var In=mt.createContext({items:[],containerRef:{current:null},maxMentionableUsersSuggestions:10}),Gi=({key:t,value:e},{isDisabled:n,optionProps:o,isFocused:r,_state:i},l)=>{let{hoverProps:s}=a$3({isDisabled:n}),{label:a,data:c$1}=e;return jsxs(Fragment,{children:[jsxs("li",{...c(o,s),className:Mo({isDisabled:n,isHovered:r}),"data-active":r,ref:l,children:[jsx(a$e,{name:a,...c$1?.avatar}),jsxs(a$9,{display:"flex",flexDirection:"column",children:[jsx(a$m,{type:"subtitle",size:"sm",children:a}),jsx(a$m,{type:"helper",size:"sm",children:c$1?.description})]})]}),t===i.collection.getLastKey()?null:jsx(a$a,{})]})};function _n(t){return t.displayName?.trim()||t.name?.trim()||t.id}function Nn(t){return t.displayName??_n(t)}function wn({anchor:t,onClose:e,mentionLabel:n}){let{core:o}=ge(),{containerRef:r,items:i,maxMentionableUsersSuggestions:l}=useContext(In),[s,a]=useState(""),{contains:c$1}=a$i({sensitivity:"base"}),{formatMessage:u}=b$1(),d=useRef(false),f$1=useCallback(()=>{d.current=true,e();},[e]),p=useMemo(()=>{let g=i.filter(y=>s===""||c$1(_n(y),s)).map(y=>({id:y.id,label:_n(y),data:y}));return l?g.slice(0,l):g},[i,l,s,c$1]),m=useCallback(g=>jsx(a$j,{textValue:g.label,children:g.label},g.id),[]),h=useCallback(g=>{if(d.current||g==null)return;let y=i.find(v=>v.id===g);y&&(f$1(),o.exec("confirmMention",{id:y.id,displayName:Nn(y)}),o.exec("insertText"," "),o.focus());},[f$1,o,i]),C=b$6({items:p,children:m,menuTrigger:"focus",onSelectionChange:h}),S=useCallback(g=>{if(d.current)return;f$1();let y=g==="backspace"?"":`@${C.inputValue}`;o.exec("removeMentionInput",y),o.focus();},[f$1,o,C.inputValue]),U=useRef(null),M=useRef(null),O=useRef(null),z=useRef(null);a$k({ref:z,onInteractOutside:()=>{C.close();}});let{inputProps:L,listBoxProps:q}=a$l({defaultItems:p,inputRef:M,buttonRef:U,listBoxRef:O,popoverRef:z,menuTrigger:"focus","aria-label":n??u(Xi.mention)},C);useLayoutEffect(()=>{M.current?.focus(),setTimeout(()=>{M.current?.focus();});},[]);let $=useCallback(g=>{let y=g.currentTarget,v=y.selectionStart===0&&y.selectionEnd===0,b=y.selectionStart===y.value.length&&y.selectionEnd===y.value.length;g.key==="Backspace"&&v?(g.preventDefault(),S("backspace")):g.key==="Escape"?S("escape"):g.key==="ArrowLeft"&&v?(g.preventDefault(),S("arrowLeft")):g.key==="ArrowRight"&&b&&(g.preventDefault(),S("arrowRight"));let ie=g.metaKey||g.ctrlKey,se=g.key.toLowerCase(),ue=ie&&!g.shiftKey&&se==="z"&&o.canUndo(),fe=(ie&&g.shiftKey&&se==="z"||g.ctrlKey&&se==="y")&&o.canRedo();(ue||fe)&&(g.preventDefault(),ue?o.undo():o.redo(),f$1(),o.focus());},[S,f$1,o]),te=useMemo(()=>{if(!CSS.supports("field-sizing","content")){let g=b$2(M.current),y=M.current?g?.getComputedStyle(M.current).font:void 0;return {width:y?b$7({text:C.inputValue,font:y,element:M.current}).width+10:"4ch"}}},[C.inputValue]);return jsxs(Fragment,{children:[createPortal(jsx("input",{...c(L,{onKeyDown:$,onBlur:()=>{S("blur");},onChange:g=>{a(g.target.value);}}),style:te,className:Co,ref:M}),t),jsx(b$8.Provider,{value:C,children:jsx(a$g,{triggerRef:r,isNonModal:true,ref:z,state:C,crossOffset:-2,children:jsx(c$2,{...q,items:void 0,ref:O,"data-testid":"editor-mention-listbox",className:a$5(f,sprinkles({width:"full"})),renderOption:Gi})})})]})}wn.displayName="MentionInputOverlay";var Xi=c$1({mention:{defaultMessage:"Mention",id:"bui.editor.mention"}});var Bn=mt.forwardRef(({value:t,defaultValue:e$1,onChange:n,style:o,spellCheck:r,placeholder:i,isInline:l,isDisabled:s,editableContentAriaLabel:a,containerRef:c,onHelpDialogOpenRequest:u,mentionableUsers:d,editorHandle:f,maxMentionableUsersSuggestions:p,autoFocus:m,editorRef:h,saveOnEnter:C,onSave:S,autoLink:U,mentionLabel:M,boldLabel:O,italicLabel:z,underlineLabel:L,fontColorLabel:q,backgroundColorLabel:$,helpLabel:te,addLinkLabel:g,editLinkLabel:y,removeLinkLabel:v,linkAnnotationLabel:b,linkCancelLabel:ie,linkSaveLabel:se},ue)=>{let fe=useRef(null),T=useRef(null),{formatMessage:B}=b$1(),[Xe,Ye]=useState(null),xt=useRef(0),[Qt,bt]=useState(false),yt=()=>{let E=T.current?.querySelector("[data-mention-anchor]");E&&(xt.current+=1,Ye({anchor:E,id:xt.current}));},be=Mn({value:t,defaultValue:e$1,onChange:n,isDisabled:s,onMentionTrigger:yt,onMentionInputRemoved:()=>{Ye(null);},canStartMention:()=>(d?.length??0)>0,resolveMention:E=>{let G=d?.find(H=>H.id===E);return G&&Nn(G)},autoLink:U}),Ze=be.core;mt.useEffect(()=>{h&&(h.current=Ze);},[Ze,h]);let R=E=>C&&E.key==="Enter"&&!E.shiftKey||(E.ctrlKey||E.metaKey)&&E.key==="Enter"?(E.preventDefault(),S(),true):E.altKey&&E.key==="F10"?(E.preventDefault(),fe.current?.querySelector("button")?.focus(),true):false,{editableProps:Et}=Sn(be,{ref:T,autoFocus:m,onKeyDown:R}),Je=E=>{if(s)return;let{isLinkClick:G,url:H}=Vo(E.target,{metaKey:E.metaKey,ctrlKey:E.ctrlKey,mac:e()});G&&(E.preventDefault(),H&&b$2(E.currentTarget).open(H,"_blank","noopener,noreferrer"));};mt.useEffect(()=>{let E=T.current;if(!E||s)return;let G=a$7(E),H=b$2(E),ke=Ce=>{bt(e()?Ce.metaKey:Ce.ctrlKey);},tt=()=>{bt(false);};return G.addEventListener("keydown",ke),G.addEventListener("keyup",ke),H.addEventListener("blur",tt),()=>{G.removeEventListener("keydown",ke),G.removeEventListener("keyup",ke),H.removeEventListener("blur",tt),tt();}},[s]),useImperativeHandle(ue,()=>({startMention:()=>{d?.length&&(T.current?.querySelector("input[role='combobox']")||(Ze.exec("insertMentionInput"),yt()));}})),useImperativeHandle(f,()=>({setCaretPosition:E=>{be.setCaretPosition(E);},focus:()=>{be.focus();}}));let Qe=useMemo(()=>({items:d||[],containerRef:c,maxMentionableUsersSuggestions:p}),[d,c,p]),et=be.isEmpty;return jsx(In.Provider,{value:Qe,children:jsxs(zn,{editor:be,children:[jsxs(a$8,{className:a$5(It,"BaselineUI-Editor-RichEditorToolbar"),"aria-controls":Et.id,ref:fe,children:[jsxs(a$9,{display:"flex",flexDirection:"row",role:"group",gap:"xs",paddingX:"sm",children:[jsx(Xt,{markName:"bold",icon:BoldIcon,ariaLabel:O??B(Ge.bold),isDisabled:s}),jsx(Xt,{markName:"italic",icon:ItalicIcon,ariaLabel:z??B(Ge.italic),isDisabled:s}),jsx(Xt,{markName:"underline",icon:UnderlineIcon,ariaLabel:L??B(Ge.underline),isDisabled:s})]}),jsx(a$a,{orientation:"vertical",className:rt}),jsx(Dn,{colorKey:"color","aria-label":q??B(Ge.fontColor),isDisabled:s}),jsx(a$a,{orientation:"vertical",className:rt}),jsx(Dn,{colorKey:"backgroundColor","aria-label":$??B(Ge.backgroundColor),isDisabled:s}),jsx(a$a,{orientation:"vertical",className:rt}),jsx(Lr,{isDisabled:s,addLinkLabel:g,editLinkLabel:y,removeLinkLabel:v,linkAnnotationLabel:b,linkCancelLabel:ie,linkSaveLabel:se}),jsx(a$a,{orientation:"vertical",className:rt}),jsx(a$b,{className:Be,icon:QuestionmarkCircleIcon,size:"sm","aria-label":te??B(Ge.help),"data-testid":"editor-help-button",onPress:u})]}),jsx(a$a,{variant:"secondary"}),jsxs("div",{style:{position:"relative"},children:[!!(i&&et)&&jsx("span",{"aria-hidden":true,"aria-disabled":true,"data-testid":"editor-placeholder",style:{position:"absolute",pointerEvents:"none",userSelect:"none",top:0,left:0,right:0},className:a$5(ot({isDisabled:s}),Ro,"BaselineUI-Editor-RichEditorPlaceholder"),children:i}),jsx("div",{...Et,onClick:Je,"data-mod-held":Qt?"":void 0,"aria-label":a,"aria-placeholder":i,spellCheck:r,style:o,className:a$5(ot({isDisabled:s}),_t({isInline:l}),"BaselineUI-Editor-RichEditorEditingArea")})]}),Xe!==null&&jsx(wn,{anchor:Xe.anchor,mentionLabel:M,onClose:()=>{Ye(null);}},Xe.id)]})})});Bn.displayName="RichEditor";var Ge=c$1({bold:{defaultMessage:"Bold",id:"bui.editor.bold"},italic:{defaultMessage:"Italic",id:"bui.editor.italic"},underline:{defaultMessage:"Underline",id:"bui.editor.underline"},backgroundColor:{defaultMessage:"Background Color",id:"bui.editor.backgroundColor"},fontColor:{defaultMessage:"Font Color",id:"bui.editor.fontColor"},help:{defaultMessage:"Help",id:"bui.editor.help"}});var _r=mt.memo(mt.forwardRef(({className:t,style:e,"data-block-id":n,"data-block-class":o,enableRichText:r=false,onCancel:i,onSave:l,isInline:s=true,submitButtonIcon:a=ArrowUpCircleFilledIcon,submitButtonAriaLabel:c$1,cancelButtonAriaLabel:u,"aria-label":d,"aria-describedby":f,"aria-labelledby":p,"aria-details":m,editableContentAriaLabel:h="Editing Area",footerButtons:C,clearOnCancel:S,clearOnSave:U,mentionLabel:M,boldLabel:O,italicLabel:z,underlineLabel:L,fontColorLabel:q,backgroundColorLabel:$,helpLabel:te,closeLabel:g,actionLabel:y,shortcutLabel:v,toolbarFocusLabel:b$2,selectAllLabel:ie,cutLabel:se,copyLabel:ue,pasteLabel:fe,undoLabel:T,redoLabel:B,openHelpDialogLabel:Xe,submitLabel:Ye,addLinkLabel:xt,editLinkLabel:Qt,removeLinkLabel:bt,linkAnnotationLabel:yt,linkCancelLabel:be,linkSaveLabel:Ze,...R},Et)=>{let Je=useRef(null),{formatMessage:Qe}=b$1(),et=useRef(null),E=useRef(null),G=useRef(null),H=!r&&R.variant==="minimal",ke=useRef(null),[tt,Ce]=mt.useState(R.value||R.defaultValue),en=R.value!==void 0&&R.onChange!==void 0;r&&R.value!==void 0&&!R.onChange&&a$c("editor-rich-value-uncontrolled","Editor: `value` without `onChange` in rich text mode sets the initial content only. Use `defaultValue` for uncontrolled content, or add `onChange` to control the value.");let Fn=R.value!==void 0&&(!r||en),tn=R.value;mt.useEffect(()=>{Fn&&tn!==void 0&&Ce(tn);},[Fn,tn]);let nn=R.isDisabled||R.isSaveDisabled||!b$3(tt||""),{fieldProps:Ir}=a$d({"aria-label":d,"aria-labelledby":p,"aria-describedby":f,"aria-details":m,labelElementType:"div"});H&&!R.avatarName&&console.warn("Editor: When using the minimal `variant` and `enableRichText` is `false`, you should provide an `avatarName`.");let on=useCallback(()=>{Ce(""),r?Je.current?.setValue("<p></p>",{emit:true}):E.current?.clear();},[r]),vt=useCallback(()=>{nn||(l?.(r?Je.current?.getValue()??"":et.current.value),U&&on());},[on,U,r,l,nn]),Un=jsx(a$b,{variant:"ghost","aria-label":c$1||Qe(jn.save),icon:a,isDisabled:nn,"data-testid":"editor-save-button",size:"md",excludeFromTabOrder:H,className:a$5({[Lo]:H},"BaselineUI-Editor-Save"),onPress:vt,preventFocusOnPress:true}),[Nr,rn]=mt.useState(false),{keyboardProps:wr}=j({onKeyDown:V=>{(V.metaKey||V.ctrlKey)&&V.shiftKey&&V.key==="h"&&(V.preventDefault(),rn(true));}}),Vn=useCallback(V=>{Ce(V),R.onChange?.(V);},[R]);return jsxs("div",{...c(Ir,r?wr:{}),role:"application",ref:b(G,Et),style:e,"data-block-id":n,"data-block-class":o,className:a$5(vo({isInline:s,isMinimal:H}),"BaselineUI-Editor",t),"aria-disabled":R.isDisabled,children:[H?jsxs(Fragment,{children:[s?jsx(a$e,{className:Eo,name:R.avatarName||""}):null,jsxs("div",{className:zo({isInline:s}),children:[jsx(Nt,{isMinimal:H,textBoxRef:et,ref:E,isInline:s,editableContentAriaLabel:h,...R,onChange:Vn,onSave:vt}),Un]})]}):jsxs(Fragment,{children:[r?jsx(Bn,{containerRef:G,ref:ke,editorRef:Je,isInline:s,editableContentAriaLabel:h,onHelpDialogOpenRequest:()=>{rn(true);},mentionLabel:M,boldLabel:O,italicLabel:z,underlineLabel:L,fontColorLabel:q,backgroundColorLabel:$,helpLabel:te,addLinkLabel:xt,editLinkLabel:Qt,removeLinkLabel:bt,linkAnnotationLabel:yt,linkCancelLabel:be,linkSaveLabel:Ze,...R,value:en?R.value:void 0,defaultValue:R.defaultValue??(en?void 0:R.value),onChange:Vn,onSave:vt}):jsxs(Fragment,{children:[!s&&jsx(a$a,{variant:"secondary"}),jsx(Nt,{onCancel:i,textBoxRef:et,ref:E,isInline:s,editableContentAriaLabel:h,...R,onChange:V=>{Ce(V),R.onChange?.(V);},onSave:vt})]}),jsx(a$a,{variant:"secondary"}),jsxs("div",{className:a$5(It,sprinkles({justifyContent:"space-between"}),"BaselineUI-Editor-Footer"),children:[jsxs(a$9,{paddingX:"sm",gap:"sm",display:"flex",children:[r&&R.mentionableUsers?jsx(a$b,{icon:AtIcon,size:"sm","aria-label":M??Qe(jn.mention),"data-testid":"editor-mention-button",onPress:()=>ke.current?.startMention(),preventFocusOnPress:true,className:"BaselineUI-Editor-Mention"}):null,C?.map(({type:V,props:Rt},Wn)=>V==="action"?jsx(a$b,{...Rt,size:"sm",isDisabled:R.isDisabled||Rt.isDisabled},Wn):jsx(a$f,{...Rt,size:"sm",variant:"tertiary",isDisabled:R.isDisabled||Rt.isDisabled},Wn))]}),jsxs(a$9,{children:[!!i&&jsx(a$b,{variant:"secondary",icon:XCircleFilledIcon,isDisabled:R.isDisabled,"data-testid":"editor-cancel-button",size:"md",onPress:()=>{i(),S&&on();},"aria-label":u||Qe(jn.cancel),className:"BaselineUI-Editor-Cancel"}),Un]})]})]}),jsx(Ao,{isOpen:Nr,onClose:()=>{rn(false);},toolbarFocusLabel:b$2,helpLabel:te,closeLabel:g,actionLabel:y,shortcutLabel:v,boldLabel:O,italicLabel:z,underlineLabel:L,selectAllLabel:ie,cutLabel:se,copyLabel:ue,pasteLabel:fe,undoLabel:T,redoLabel:B,openHelpDialogLabel:Xe,submitLabel:Ye})]})}));_r.displayName="Editor";var jn=c$1({cancel:{defaultMessage:"Cancel",id:"bui.editor.cancel"},save:{defaultMessage:"Save",id:"bui.editor.save"},mention:{defaultMessage:"Mention",id:"bui.editor.mention"}});
29
- export{ut as a,ge as b,Gt as c,Mn as d,Cr as e,Sn as f,zn as g,_r as h};
28
+ `)),l=_([{type:"p",children:[{text:i}]}]);n&&(l=_(gn(l))),this.exec("insertFragment",l);}}syncFromDom(){if(!this.el||this.composing)return;let e=this.doc,n={doc:e,range:this.cachedRange},o=Bt(this.el),r=qt(this.el,o);if(!(ge(o)!==this.lastKnownHtml)){if(r){let d=this.cachedRange;this.cachedRange=r,(!d||!this.rangesEqual(d,r))&&this.emitSelectionChange();}return}this.history.record(n,"typing");let s=o,a=r,c=false;if(!a&&n.range){let d=Math.max(Ue(o)-Ue(e),0),f=this.pending?this.pending.caretOffset:P(e,n.range.anchor),p=N(o,f+d);a={anchor:p,focus:p};}if(this.pending){let d=this.pending.marks,f=a;if(f){let p=this.applyPendingMarks(o,n.range,f);p.doc!==o&&(s=p.doc,a=p.range,c=true),this.pending=a?{marks:d,caretOffset:P(s,a.anchor)}:null,a&&(this.preservePendingSelectionChanges=10);}else this.pending=null;}this.doc=s,this.cachedRange=a;let u=ge(s);this.lastKnownHtml=u,this.lastAppliedValue=null,c&&(ct(s,this.el),a&&De(this.el,s,a)),this.opts.onChange?.(u),this.emitSelectionChange();}applyPendingMarks(e,n,o){if(!this.pending||!n||!o)return {doc:e,range:o??{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}};let r=this.pending.caretOffset,i=o?P(e,o.anchor):r;if(i<=r)return {doc:e,range:o??{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}};let l=this.applyPendingMarkSnapshot(e,this.pending.marks,r,i),s=N(l,i);return {doc:l,range:{anchor:s,focus:s}}}applyPendingMarkSnapshot(e,n,o,r){let i=e,l=()=>({anchor:N(i,o),focus:N(i,r)});for(let s of ["bold","italic","underline"]){let a=l(),c=!!n[s],u=!!ze(i,a)[s];if(c!==u){let d=En(i,a,s);d.doc!==i&&(i=d.doc);}}for(let s of ["color","backgroundColor"]){let a=l(),c=n[s],u=ze(i,a)[s];if(!b$a(c,u)){let d=vn(i,a,s,c);d.doc!==i&&(i=d.doc);}}return i}handleSelectionChange(){if(!this.el)return;let e=Wt(this.el);if(!e)return;let n=Cn(this.el,e);if(!n||!h(this.el,n.startContainer))return;let o=qt(this.el,this.doc),r=this.cachedRange;this.preservePendingSelectionChanges>0?(this.preservePendingSelectionChanges-=1,this.pending&&o&&(this.pending={...this.pending,caretOffset:P(this.doc,o.anchor)})):this.pending&&o&&P(this.doc,o.anchor)!==this.pending.caretOffset&&(this.pending=null),o!==null&&(this.cachedRange=o),(!r||!o||!this.rangesEqual(r,o))&&this.emitSelectionChange();}dispatchCommand(e,n){let o=this.doc,r=this.cachedRange??this.collapsedAtDocEnd();switch(e){case "toggleMark":{let[i]=n;return En(o,r,i)}case "setMarkValue":{let[i,l]=n;return vn(o,r,i,l)}case "wrapLink":{let[i]=n;return Tn(o,r,i)}case "updateLinkUrl":{let[i]=n;return rr(o,r,i)}case "unwrapLink":return ir(o,r);case "deleteRange":return $e(o,r);case "insertText":{let[i]=n;if(!w(r)){let l=$e(o,r);return at(l.doc,l.range.focus,i)}return at(o,r.anchor,i)}case "insertFragment":{let[i]=n;return sr(o,r,i)}case "insertSoftBreak":return lr(o,r);case "insertMentionInput":return ur(o,r);case "confirmMention":{let[i]=n;return fr(o,i)}case "removeMentionInput":{let[i,l]=n;return pr(o,i,l)}default:return {doc:o,range:r}}}collapsedAtDocEnd(){let e=We(this.doc);return {anchor:e,focus:e}}rangesEqual(e,n){return e.anchor.path[0]===n.anchor.path[0]&&e.anchor.path[1]===n.anchor.path[1]&&e.anchor.offset===n.anchor.offset&&e.focus.path[0]===n.focus.path[0]&&e.focus.path[1]===n.focus.path[1]&&e.focus.offset===n.focus.offset}};var ft=mt.createContext(null);function xe(){let t=mt.useContext(ft);if(!t)throw new Error("useEditorContext must be used within an EditorProvider");return t}var Gt=Object.freeze({marks:{},link:null,range:null});function zi(t){let e=Le(t.replaceAll(/<br\s*\/?>/gi,""));return e==="<p></p>"||e===""||e==="<p> </p>"}function Mn(t={}){let{value:e,defaultValue:n,onChange:o,isDisabled:r,keyboardShortcuts:i,onSelectionChange:l,onMentionTrigger:s,onMentionInputRemoved:a,canStartMention:c,resolveMention:u,isReadOnly:d,autoLink:f}=t;e!==void 0&&o===void 0&&a$c("use-editor-value-without-onchange","useEditor: `value` without `onChange` is controlled but cannot reflect edits \u2014 they are discarded on the next render. Use `defaultValue` for initial content, or add `onChange`.");let[p,m]=useState(Gt),[h,C]=useState(()=>e??n??""),D=useRef(o);D.current=o;let V=useRef(l);V.current=l;let M=useRef(s);M.current=s;let B=useRef(a);B.current=a;let S=useRef(c);S.current=c;let L=useRef(u);L.current=u;let q=useRef(d);q.current=d;let $=useRef(r);$.current=r;let te=useRef(i);te.current=i;let g=useRef(f);g.current=f;let y=useRef(null);y.current===null&&(y.current=new ut({onChange:E=>{C(E),D.current?.(E);},onSelectionChange:E=>{m(E),V.current?.(E);},onMentionTrigger:()=>{M.current?.();},onMentionInputRemoved:()=>{B.current?.();},canStartMention:()=>S.current?.()??false,get resolveMention(){return L.current},autoLink:()=>g.current!==false,isReadOnly:()=>q.current?.()??!!$.current,areKeyboardShortcutsEnabled:()=>te.current!==false}));let R=y.current;useLayoutEffect(()=>{e!==void 0&&R.setValue(e);});let b=useRef(false);useEffect(()=>{if(!b.current){b.current=true;let E=e??n;E&&R.setValue(E);}},[R]),useEffect(()=>{r&&m(Gt);},[r]);let ie=e??h,se=zi(ie),fe=R.canUndo(),pe=R.canRedo();return useMemo(()=>({core:R,selectionState:p,value:ie,isEmpty:se,isDisabled:!!r,keyboardShortcuts:i!==false,canUndo:fe,canRedo:pe,focus:()=>{R.focus();},selectStart:()=>{R.selectStart();},selectEnd:()=>{R.selectEnd();},setCaretPosition:E=>{R.setCaretPosition(E);},undo:()=>{R.undo();},redo:()=>{R.redo();},getValue:()=>R.getValue(),setValue:(E,I)=>{R.setValue(E,I);},exec:(E,...I)=>{R.exec(E,...I);},isMarkActive:E=>!!p.marks[E],toggleMark:E=>{R.exec("toggleMark",E);},setMark:(E,I)=>{R.exec("setMarkValue",E,I);}}),[R,p,ie,se,r,i,fe,pe])}function Cr(t,e){let n=t.ctrlKey||t.metaKey,o=t.key.toLowerCase();if(n&&!t.altKey&&o==="z")return t.preventDefault(),t.shiftKey?e.redo():e.undo(),true;if(t.ctrlKey&&!t.altKey&&!t.shiftKey&&o==="y")return t.preventDefault(),e.redo(),true;if(n&&!t.shiftKey&&!t.altKey){if(o==="b")return t.preventDefault(),e.toggleMark("bold"),true;if(o==="i")return t.preventDefault(),e.toggleMark("italic"),true;if(o==="u")return t.preventDefault(),e.toggleMark("underline"),true}return false}function Sn(t,e={}){let n=Ni(t),{ref:o,autoFocus:r,onKeyDown:i,keyboardShortcuts:l}=e,s=l??n.keyboardShortcuts,a=useId(),c=useRef(null),u=useRef(null),d=useCallback(h=>{u.current&&(u.current(),u.current=null),h&&(u.current=n.core.attach(h));},[n.core]),f=useMemo(()=>b(c,d,o??null),[d,o]);useEffect(()=>(n.core.setKeyboardShortcutsEnabled(l),()=>{n.core.setKeyboardShortcutsEnabled(void 0);}),[n.core,l]);let p=useRef(false);useEffect(()=>{if(!p.current)switch(p.current=true,r){case true:{n.focus();break}case "start":{n.selectStart();break}case "end":{n.selectEnd();break}}},[n.core]);let{keyboardProps:m}=j({onKeyDown:h=>{i?.(h)||s&&Cr(h,n)||h.continuePropagation();}});return {editableProps:{...m,id:a,ref:f,contentEditable:!n.isDisabled,suppressContentEditableWarning:true,role:"textbox","aria-multiline":true}}}function Ni(t){let e=useContext(ft);if(t)return t;if(!e)throw new Error("useEditable must be passed an editor or used within an EditorProvider");return e}var zn=({editor:t,children:e})=>jsx(ft.Provider,{value:t,children:e});var Xt=({markName:t,icon:e,ariaLabel:n,isDisabled:o})=>{let{core:r,selectionState:i}=xe(),l=!!i.marks[t];return jsx(a$f,{variant:"tertiary",isSelected:l,size:"sm",icon:e,"aria-label":n,"data-testid":`editor-${t}-button`,isDisabled:o,onPress:()=>{r.exec("toggleMark",t),r.focus();},preventFocusOnPress:true})},Dn=({colorKey:t,"aria-label":e,isDisabled:n})=>{let{core:o,selectionState:r}=xe(),i=t==="color"?r.marks.color:r.marks.backgroundColor,l=mt.useRef(null),s=useCallback(()=>{l.current=r.range;},[r.range]),a=useCallback(p=>{setTimeout(()=>{let m=o.getSelectionState().range??l.current;m&&o.select(m),o.exec("setMarkValue",t,p);},0);},[o,t]),c=useCallback(p=>{a(p);},[a]),u=useCallback(()=>{a();},[a]),d=useCallback(({ref:p,triggerProps:m})=>jsx(a$b,{icon:t==="color"?TextIcon:HighlightTextIcon,"aria-label":e,"data-testid":t==="color"?"editor-font-color-button":"editor-background-color-button",size:"md",variant:"popover",isDisabled:n,className:He,preventFocusOnPress:true,...m,ref:p}),[t,e,n]),f=useCallback(p=>{p?c(p.toString("rgba")):u();},[u,c]);return jsx(b$4,{presets:cn,allowRemoval:true,pickerMode:"lazy",placement:"top end",colorLabel:false,renderTriggerButton:d,onTriggerPress:s,value:i||"#000000",onChange:f,isDisabled:n})};var _e={Add:"add",Edit:"edit",Show:"show"},Lr=({isDisabled:t,addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:l})=>{let{formatMessage:s}=b$1(),{core:a}=xe();return jsxs(b$5,{type:"dialog",children:[jsx(j$1,{children:jsx(a$b,{icon:LinkIcon,size:"sm",isDisabled:t,"aria-label":e??s(Ie.addLink),"data-testid":"editor-add-link-button",className:He,preventFocusOnPress:true})}),jsx(a$g,{className:sprinkles({boxShadow:"medium"}),placement:"top end",children:({close:c})=>jsx(a$h,{size:"content",style:{minWidth:240},children:jsx(Ki,{addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:l,close:()=>{c(),setTimeout(()=>{a.focus();},0);}})})})]})},Ki=({close:t,addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:l})=>{let{core:s,selectionState:a}=xe(),{formatMessage:c}=b$1(),u=a.link?.url,[d,f]=mt.useState(u?_e.Show:_e.Add),[p,m]=mt.useState(u||""),h=jsx(a$9,{padding:"lg",children:jsx(a$o,{label:r??c(Ie.link),value:p,autoFocus:true,onChange:m,placeholder:"https://yourdomain.com","data-testid":"editor-link-input"})});return jsxs(Fragment,{children:[d===_e.Add&&jsxs(Fragment,{children:[h,jsx(a$9,{display:"flex",justifyContent:"flex-end",padding:"lg",className:yo,children:jsx(b$b,{isDisabled:!a$p(p,true)||de(p)==="",label:e??c(Ie.addLink),"data-testid":"editor-link-add-button",size:"sm",onPress:()=>{s.exec("wrapLink",hn(p)),t?.();},preventFocusOnPress:true})})]}),d===_e.Show&&jsxs(Fragment,{children:[jsx(a$9,{padding:"lg",children:jsx(a$m,{type:"subtitle",size:"sm",children:u})}),jsxs(a$9,{display:"flex",justifyContent:"flex-end",padding:"lg",gap:"lg",borderColor:"border.subtle",borderWidth:1,borderStyle:"solid",children:[jsx(b$b,{label:n??c(Ie.editLink),"data-testid":"editor-link-edit-button",size:"sm",variant:"secondary",onPress:()=>{f(_e.Edit);},style:{flex:1,justifyContent:"center"}}),jsx(b$b,{label:o??c(Ie.removeLink),"data-testid":"editor-link-remove-button",size:"sm",onPress:()=>{s.exec("unwrapLink"),t?.();},preventFocusOnPress:true,style:{flex:1,justifyContent:"center"}})]})]}),d===_e.Edit&&jsxs(Fragment,{children:[h,jsxs(a$9,{display:"flex",justifyContent:"flex-end",padding:"lg",gap:"lg",borderColor:"border.subtle",borderWidth:1,borderStyle:"solid",children:[jsx(b$b,{label:i??c(Ie.cancel),"data-testid":"editor-link-cancel-button",size:"sm",variant:"secondary",onPress:()=>{f(_e.Show),t?.();}}),jsx(b$b,{label:l??c(Ie.save),"data-testid":"editor-link-save-button",size:"sm",isDisabled:!a$p(p,true)||de(p)==="",onPress:()=>{s.exec("updateLinkUrl",hn(p)),t?.();}})]})]})]})},Ie=c$1({addLink:{id:"bui.editor.addLink",defaultMessage:"Add Link"},editLink:{id:"bui.editor.editLink",defaultMessage:"Edit Link"},removeLink:{id:"bui.editor.removeLink",defaultMessage:"Remove Link"},cancel:{id:"bui.editor.cancel",defaultMessage:"Cancel"},save:{id:"bui.editor.save",defaultMessage:"Save"},link:{id:"bui.editor.linkAnnotation",defaultMessage:"Link"}});var In=mt.createContext({items:[],containerRef:{current:null},maxMentionableUsersSuggestions:10}),Gi=({key:t,value:e},{isDisabled:n,optionProps:o,isFocused:r,_state:i},l)=>{let{hoverProps:s}=a$3({isDisabled:n}),{label:a,data:c$1}=e;return jsxs(Fragment,{children:[jsxs("li",{...c(o,s),className:Mo({isDisabled:n,isHovered:r}),"data-active":r||void 0,ref:l,children:[jsx(a$9,{elementType:"span",display:"flex","aria-hidden":true,children:jsx(a$e,{name:a,...c$1?.avatar})}),jsxs(a$9,{display:"flex",flexDirection:"column",children:[jsx(a$m,{type:"subtitle",size:"sm",children:a}),jsx(a$m,{type:"helper",size:"sm",children:c$1?.description})]})]}),t===i.collection.getLastKey()?null:jsx(a$a,{})]})};function _n(t){return t.displayName?.trim()||t.name?.trim()||t.id}function Nn(t){return t.displayName??_n(t)}function wn({anchor:t,onClose:e,mentionLabel:n}){let{core:o}=xe(),{containerRef:r,items:i,maxMentionableUsersSuggestions:l}=useContext(In),[s,a]=useState(""),{contains:c$1}=a$i({sensitivity:"base"}),{formatMessage:u}=b$1(),d=useRef(false),f$1=useCallback(()=>{d.current=true,e();},[e]),p=useMemo(()=>{let g=i.filter(y=>s===""||c$1(_n(y),s)).map(y=>({id:y.id,label:_n(y),data:y}));return l?g.slice(0,l):g},[i,l,s,c$1]),m=useCallback(g=>jsx(a$j,{textValue:g.label,children:g.label},g.id),[]),h=useCallback(g=>{if(d.current||g==null)return;let y=i.find(R=>R.id===g);y&&(f$1(),o.exec("confirmMention",{id:y.id,displayName:Nn(y)}),o.exec("insertText"," "),o.focus());},[f$1,o,i]),C=b$6({items:p,children:m,menuTrigger:"focus",onSelectionChange:h}),D=useCallback(g=>{if(d.current)return;f$1();let y=g==="backspace"?"":`@${C.inputValue}`;o.exec("removeMentionInput",y,g==="arrowStart"?"start":"end"),o.focus();},[f$1,o,C.inputValue]),V=useRef(null),M=useRef(null),B=useRef(null),S=useRef(null);a$k({ref:S,onInteractOutside:()=>{C.close();}});let{inputProps:L,listBoxProps:q}=a$l({defaultItems:p,inputRef:M,buttonRef:V,listBoxRef:B,popoverRef:S,menuTrigger:"focus","aria-label":n??u(Xi.mention)},C);useLayoutEffect(()=>{M.current?.focus(),setTimeout(()=>{M.current?.focus();});},[]);let $=useCallback(g=>{let y=g.currentTarget,R=y.selectionStart===0&&y.selectionEnd===0,b=y.selectionStart===y.value.length&&y.selectionEnd===y.value.length;if(g.key==="Backspace"&&R)g.preventDefault(),D("backspace");else if(g.key==="Escape")D("escape");else if(g.key==="ArrowLeft"||g.key==="ArrowRight"){let E=I=>g.key==="ArrowLeft"!=(b$2(I).getComputedStyle(I).direction==="rtl");(E(y)?R:b)&&(g.preventDefault(),D(E(t)?"arrowStart":"arrowEnd"));}let ie=g.metaKey||g.ctrlKey,se=g.key.toLowerCase(),fe=ie&&!g.shiftKey&&se==="z"&&o.canUndo(),pe=(ie&&g.shiftKey&&se==="z"||g.ctrlKey&&se==="y")&&o.canRedo();(fe||pe)&&(g.preventDefault(),fe?o.undo():o.redo(),f$1(),o.focus());},[t,D,f$1,o]),te=useMemo(()=>{if(!CSS.supports("field-sizing","content")){let g=b$2(M.current),y=M.current?g?.getComputedStyle(M.current).font:void 0;return {width:y?b$7({text:C.inputValue,font:y,element:M.current}).width+10:"4ch"}}},[C.inputValue]);return jsxs(Fragment,{children:[createPortal(jsx("input",{...c(L,{onKeyDown:$,onBlur:()=>{D("blur");},onChange:g=>{a(g.target.value);}}),style:te,dir:/\p{L}/u.test(C.inputValue)?"auto":void 0,className:Co,ref:M}),t),jsx(b$8.Provider,{value:C,children:jsx(a$g,{triggerRef:r,isNonModal:true,ref:S,state:C,crossOffset:-2,children:jsx(c$2,{...q,items:void 0,ref:B,"data-testid":"editor-mention-listbox",className:a$5(f,sprinkles({width:"full"})),renderOption:Gi})})})]})}wn.displayName="MentionInputOverlay";var Xi=c$1({mention:{defaultMessage:"Mention",id:"bui.editor.mention"}});var Bn=mt.forwardRef(({value:t,defaultValue:e$1,onChange:n,style:o,spellCheck:r,placeholder:i,isInline:l,isDisabled:s,editableContentAriaLabel:a,containerRef:c,onHelpDialogOpenRequest:u,mentionableUsers:d,editorHandle:f,maxMentionableUsersSuggestions:p,autoFocus:m,editorRef:h,saveOnEnter:C,onSave:D,autoLink:V,mentionLabel:M,boldLabel:B,italicLabel:S,underlineLabel:L,fontColorLabel:q,backgroundColorLabel:$,helpLabel:te,addLinkLabel:g,editLinkLabel:y,removeLinkLabel:R,linkAnnotationLabel:b,linkCancelLabel:ie,linkSaveLabel:se},fe)=>{let pe=useRef(null),E=useRef(null),{formatMessage:I}=b$1(),[Ye,Ze]=useState(null),xt=useRef(0),[Qt,bt]=useState(false),yt=()=>{let v=E.current?.querySelector("[data-mention-anchor]");v&&(xt.current+=1,Ze({anchor:v,id:xt.current}));},be=Mn({value:t,defaultValue:e$1,onChange:n,isDisabled:s,onMentionTrigger:yt,onMentionInputRemoved:()=>{Ze(null);},canStartMention:()=>(d?.length??0)>0,resolveMention:v=>{let G=d?.find(H=>H.id===v);return G&&Nn(G)},autoLink:V}),Je=be.core;mt.useEffect(()=>{h&&(h.current=Je);},[Je,h]);let T=v=>C&&v.key==="Enter"&&!v.shiftKey||(v.ctrlKey||v.metaKey)&&v.key==="Enter"?(v.preventDefault(),D(),true):v.altKey&&v.key==="F10"?(v.preventDefault(),pe.current?.querySelector("button")?.focus(),true):false,{editableProps:Et}=Sn(be,{ref:E,autoFocus:m,onKeyDown:T}),Qe=v=>{if(s)return;let{isLinkClick:G,url:H}=Vo(v.target,{metaKey:v.metaKey,ctrlKey:v.ctrlKey,mac:e()});G&&(v.preventDefault(),H&&b$2(v.currentTarget).open(H,"_blank","noopener,noreferrer"));};mt.useEffect(()=>{let v=E.current;if(!v||s)return;let G=a$7(v),H=b$2(v),ke=Ce=>{bt(e()?Ce.metaKey:Ce.ctrlKey);},nt=()=>{bt(false);};return G.addEventListener("keydown",ke),G.addEventListener("keyup",ke),H.addEventListener("blur",nt),()=>{G.removeEventListener("keydown",ke),G.removeEventListener("keyup",ke),H.removeEventListener("blur",nt),nt();}},[s]),useImperativeHandle(fe,()=>({startMention:()=>{d?.length&&(E.current?.querySelector("input[role='combobox']")||(Je.exec("insertMentionInput"),yt()));}})),useImperativeHandle(f,()=>({setCaretPosition:v=>{be.setCaretPosition(v);},focus:()=>{be.focus();}}));let et=useMemo(()=>({items:d||[],containerRef:c,maxMentionableUsersSuggestions:p}),[d,c,p]),tt=be.isEmpty;return jsx(In.Provider,{value:et,children:jsxs(zn,{editor:be,children:[jsxs(a$8,{className:a$5(It,"BaselineUI-Editor-RichEditorToolbar"),"aria-controls":Et.id,ref:pe,children:[jsxs(a$9,{display:"flex",flexDirection:"row",role:"group",gap:"xs",paddingX:"sm",children:[jsx(Xt,{markName:"bold",icon:BoldIcon,ariaLabel:B??I(Xe.bold),isDisabled:s}),jsx(Xt,{markName:"italic",icon:ItalicIcon,ariaLabel:S??I(Xe.italic),isDisabled:s}),jsx(Xt,{markName:"underline",icon:UnderlineIcon,ariaLabel:L??I(Xe.underline),isDisabled:s})]}),jsx(a$a,{orientation:"vertical",className:rt}),jsx(Dn,{colorKey:"color","aria-label":q??I(Xe.fontColor),isDisabled:s}),jsx(a$a,{orientation:"vertical",className:rt}),jsx(Dn,{colorKey:"backgroundColor","aria-label":$??I(Xe.backgroundColor),isDisabled:s}),jsx(a$a,{orientation:"vertical",className:rt}),jsx(Lr,{isDisabled:s,addLinkLabel:g,editLinkLabel:y,removeLinkLabel:R,linkAnnotationLabel:b,linkCancelLabel:ie,linkSaveLabel:se}),jsx(a$a,{orientation:"vertical",className:rt}),jsx(a$b,{className:He,icon:QuestionmarkCircleIcon,size:"sm","aria-label":te??I(Xe.help),"data-testid":"editor-help-button",onPress:u})]}),jsx(a$a,{variant:"secondary"}),jsxs("div",{style:{position:"relative"},children:[!!(i&&tt)&&jsx("span",{"aria-hidden":true,"aria-disabled":true,"data-testid":"editor-placeholder",style:{position:"absolute",pointerEvents:"none",userSelect:"none",top:0,left:0,right:0},className:a$5(ot({isDisabled:s}),Ro,"BaselineUI-Editor-RichEditorPlaceholder"),children:i}),jsx("div",{...Et,onClick:Qe,"data-mod-held":Qt?"":void 0,"aria-label":a,"aria-placeholder":i,spellCheck:r,style:o,className:a$5(ot({isDisabled:s}),_t({isInline:l}),"BaselineUI-Editor-RichEditorEditingArea")})]}),Ye!==null&&jsx(wn,{anchor:Ye.anchor,mentionLabel:M,onClose:()=>{Ze(null);}},Ye.id)]})})});Bn.displayName="RichEditor";var Xe=c$1({bold:{defaultMessage:"Bold",id:"bui.editor.bold"},italic:{defaultMessage:"Italic",id:"bui.editor.italic"},underline:{defaultMessage:"Underline",id:"bui.editor.underline"},backgroundColor:{defaultMessage:"Background Color",id:"bui.editor.backgroundColor"},fontColor:{defaultMessage:"Font Color",id:"bui.editor.fontColor"},help:{defaultMessage:"Help",id:"bui.editor.help"}});var _r=mt.memo(mt.forwardRef(({className:t,style:e,"data-block-id":n,"data-block-class":o,enableRichText:r=false,onCancel:i,onSave:l,isInline:s=true,submitButtonIcon:a=ArrowUpCircleFilledIcon,submitButtonAriaLabel:c$1,cancelButtonAriaLabel:u,"aria-label":d,"aria-describedby":f,"aria-labelledby":p,"aria-details":m,editableContentAriaLabel:h="Editing Area",footerButtons:C,clearOnCancel:D,clearOnSave:V,mentionLabel:M,boldLabel:B,italicLabel:S,underlineLabel:L,fontColorLabel:q,backgroundColorLabel:$,helpLabel:te,closeLabel:g,actionLabel:y,shortcutLabel:R,toolbarFocusLabel:b$2,selectAllLabel:ie,cutLabel:se,copyLabel:fe,pasteLabel:pe,undoLabel:E,redoLabel:I,openHelpDialogLabel:Ye,submitLabel:Ze,addLinkLabel:xt,editLinkLabel:Qt,removeLinkLabel:bt,linkAnnotationLabel:yt,linkCancelLabel:be,linkSaveLabel:Je,...T},Et)=>{let Qe=useRef(null),{formatMessage:et}=b$1(),tt=useRef(null),v=useRef(null),G=useRef(null),H=!r&&T.variant==="minimal",ke=useRef(null),[nt,Ce]=mt.useState(T.value||T.defaultValue),en=T.value!==void 0&&T.onChange!==void 0;r&&T.value!==void 0&&!T.onChange&&a$c("editor-rich-value-uncontrolled","Editor: `value` without `onChange` in rich text mode sets the initial content only. Use `defaultValue` for uncontrolled content, or add `onChange` to control the value.");let Fn=T.value!==void 0&&(!r||en),tn=T.value;mt.useEffect(()=>{Fn&&tn!==void 0&&Ce(tn);},[Fn,tn]);let nn=T.isDisabled||T.isSaveDisabled||!b$3(nt||""),{fieldProps:Ir}=a$d({"aria-label":d,"aria-labelledby":p,"aria-describedby":f,"aria-details":m,labelElementType:"div"});H&&!T.avatarName&&console.warn("Editor: When using the minimal `variant` and `enableRichText` is `false`, you should provide an `avatarName`.");let on=useCallback(()=>{Ce(""),r?Qe.current?.setValue("<p></p>",{emit:true}):v.current?.clear();},[r]),vt=useCallback(()=>{nn||(l?.(r?Qe.current?.getValue()??"":tt.current.value),V&&on());},[on,V,r,l,nn]),Un=jsx(a$b,{variant:"ghost","aria-label":c$1||et(jn.save),icon:a,isDisabled:nn,"data-testid":"editor-save-button",size:"md",excludeFromTabOrder:H,className:a$5({[Lo]:H},"BaselineUI-Editor-Save"),onPress:vt,preventFocusOnPress:true}),[Nr,rn]=mt.useState(false),{keyboardProps:wr}=j({onKeyDown:j=>{(j.metaKey||j.ctrlKey)&&j.shiftKey&&j.key==="h"?(j.preventDefault(),rn(true)):j.continuePropagation();}}),Vn=useCallback(j=>{Ce(j),T.onChange?.(j);},[T]);return jsxs("div",{...c(Ir,r?wr:{}),role:"application",ref:b(G,Et),style:e,"data-block-id":n,"data-block-class":o,className:a$5(vo({isInline:s,isMinimal:H}),"BaselineUI-Editor",t),"aria-disabled":T.isDisabled,children:[H?jsxs(Fragment,{children:[s?jsx(a$e,{className:Eo,name:T.avatarName||""}):null,jsxs("div",{className:zo({isInline:s}),children:[jsx(Nt,{isMinimal:H,textBoxRef:tt,ref:v,isInline:s,editableContentAriaLabel:h,...T,onChange:Vn,onSave:vt}),Un]})]}):jsxs(Fragment,{children:[r?jsx(Bn,{containerRef:G,ref:ke,editorRef:Qe,isInline:s,editableContentAriaLabel:h,onHelpDialogOpenRequest:()=>{rn(true);},mentionLabel:M,boldLabel:B,italicLabel:S,underlineLabel:L,fontColorLabel:q,backgroundColorLabel:$,helpLabel:te,addLinkLabel:xt,editLinkLabel:Qt,removeLinkLabel:bt,linkAnnotationLabel:yt,linkCancelLabel:be,linkSaveLabel:Je,...T,value:en?T.value:void 0,defaultValue:T.defaultValue??(en?void 0:T.value),onChange:Vn,onSave:vt}):jsxs(Fragment,{children:[!s&&jsx(a$a,{variant:"secondary"}),jsx(Nt,{onCancel:i,textBoxRef:tt,ref:v,isInline:s,editableContentAriaLabel:h,...T,onChange:j=>{Ce(j),T.onChange?.(j);},onSave:vt})]}),jsx(a$a,{variant:"secondary"}),jsxs("div",{className:a$5(It,sprinkles({justifyContent:"space-between"}),"BaselineUI-Editor-Footer"),children:[jsxs(a$9,{paddingX:"sm",gap:"sm",display:"flex",children:[r&&T.mentionableUsers?jsx(a$b,{icon:AtIcon,size:"sm","aria-label":M??et(jn.mention),"data-testid":"editor-mention-button",onPress:()=>ke.current?.startMention(),preventFocusOnPress:true,className:"BaselineUI-Editor-Mention"}):null,C?.map(({type:j,props:Rt},Wn)=>j==="action"?jsx(a$b,{...Rt,size:"sm",isDisabled:T.isDisabled||Rt.isDisabled},Wn):jsx(a$f,{...Rt,size:"sm",variant:"tertiary",isDisabled:T.isDisabled||Rt.isDisabled},Wn))]}),jsxs(a$9,{children:[!!i&&jsx(a$b,{variant:"secondary",icon:XCircleFilledIcon,isDisabled:T.isDisabled,"data-testid":"editor-cancel-button",size:"md",onPress:()=>{i(),D&&on();},"aria-label":u||et(jn.cancel),className:"BaselineUI-Editor-Cancel"}),Un]})]})]}),jsx(Ao,{isOpen:Nr,onClose:()=>{rn(false);},toolbarFocusLabel:b$2,helpLabel:te,closeLabel:g,actionLabel:y,shortcutLabel:R,boldLabel:B,italicLabel:S,underlineLabel:L,selectAllLabel:ie,cutLabel:se,copyLabel:fe,pasteLabel:pe,undoLabel:E,redoLabel:I,openHelpDialogLabel:Ye,submitLabel:Ze})]})}));_r.displayName="Editor";var jn=c$1({cancel:{defaultMessage:"Cancel",id:"bui.editor.cancel"},save:{defaultMessage:"Save",id:"bui.editor.save"},mention:{defaultMessage:"Mention",id:"bui.editor.mention"}});
29
+ export{ut as a,xe as b,Gt as c,Mn as d,Cr as e,Sn as f,zn as g,_r as h};
@@ -1,4 +1,4 @@
1
- import {j as j$1,k}from'./chunk-4MHBLLHV.mjs';import {a}from'./chunk-4S4GGUSH.mjs';import {u}from'./chunk-PPHSLODC.mjs';import {a as a$2}from'./chunk-3WKDIXCM.mjs';import {a as a$1,j}from'./chunk-SD43KVTU.mjs';import {useRef,useState,useEffect}from'react';/**
1
+ import {j as j$1,k}from'./chunk-TYKMNZJ4.mjs';import {a}from'./chunk-4S4GGUSH.mjs';import {u}from'./chunk-PPHSLODC.mjs';import {a as a$2}from'./chunk-3WKDIXCM.mjs';import {a as a$1,j}from'./chunk-SD43KVTU.mjs';import {useRef,useState,useEffect}from'react';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -1,4 +1,4 @@
1
- import {j,l,m,k,o,i,h}from'./chunk-K7VOXFSK.mjs';import {a as a$3}from'./chunk-WTAJLO6E.mjs';import {a as a$2}from'./chunk-KCHAWPUN.mjs';import {b}from'./chunk-TUJLNJPJ.mjs';import {a}from'./chunk-OYSOPCTA.mjs';import {e}from'./chunk-AYQN3OH2.mjs';import {a as a$1}from'./chunk-4QEH5CGK.mjs';import z,{useEffect,useContext}from'react';import {jsxs,jsx}from'react/jsx-runtime';/**
1
+ import {j,l,m,k,o,i,h}from'./chunk-OMWMNUTI.mjs';import {a as a$3}from'./chunk-O6FPWOHR.mjs';import {a as a$2}from'./chunk-KCHAWPUN.mjs';import {b}from'./chunk-AFOW62QN.mjs';import {a}from'./chunk-BA5OA5DY.mjs';import {e}from'./chunk-AYQN3OH2.mjs';import {a as a$1}from'./chunk-4QEH5CGK.mjs';import z,{useEffect,useContext}from'react';import {jsxs,jsx}from'react/jsx-runtime';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -1,4 +1,4 @@
1
- import {b,c}from'./chunk-DZDZZRWE.mjs';import {b as b$1}from'./chunk-TUJLNJPJ.mjs';import {a as a$1}from'./chunk-VGFPT43C.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$2}from'./chunk-4QEH5CGK.mjs';import {WarningFilledIcon as WarningFilledIcon$1,CheckmarkCircleFilledIcon,InfoCircleFilledIcon as InfoCircleFilledIcon$1,ErrorAltCircleFilledIcon as ErrorAltCircleFilledIcon$1,XIcon}from'@baseline-ui/icons/16';import {WarningFilledIcon,CheckCircleFilledIcon,InfoCircleFilledIcon,ErrorAltCircleFilledIcon}from'@baseline-ui/icons/20';import U from'react';import {jsx,jsxs}from'react/jsx-runtime';/**
1
+ import {b,c}from'./chunk-7MLFM55C.mjs';import {b as b$1}from'./chunk-AFOW62QN.mjs';import {a as a$1}from'./chunk-DAI7V4TE.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$2}from'./chunk-4QEH5CGK.mjs';import {WarningFilledIcon as WarningFilledIcon$1,CheckmarkCircleFilledIcon,InfoCircleFilledIcon as InfoCircleFilledIcon$1,ErrorAltCircleFilledIcon as ErrorAltCircleFilledIcon$1,XIcon}from'@baseline-ui/icons/16';import {WarningFilledIcon,CheckCircleFilledIcon,InfoCircleFilledIcon,ErrorAltCircleFilledIcon}from'@baseline-ui/icons/20';import U from'react';import {jsx,jsxs}from'react/jsx-runtime';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
@@ -1,4 +1,4 @@
1
- import {a as a$8}from'./chunk-E3FP4B25.mjs';import {a as a$1,b as b$2}from'./chunk-5ZC64ZG7.mjs';import {a as a$6}from'./chunk-JZXLV6JU.mjs';import {b as b$1,c as c$1}from'./chunk-DZDZZRWE.mjs';import {a as a$5}from'./chunk-VGFPT43C.mjs';import {b}from'./chunk-N2XGJKZG.mjs';import {a as a$4}from'./chunk-RSKKEGJZ.mjs';import {a as a$3}from'./chunk-STMDFIUL.mjs';import {a as a$2}from'./chunk-B3EZOXNU.mjs';import {c}from'./chunk-3WKDIXCM.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$7}from'./chunk-4QEH5CGK.mjs';import {CaretLeftIcon as CaretLeftIcon$3,CaretRightIcon as CaretRightIcon$3}from'@baseline-ui/icons/12';import {CaretLeftIcon as CaretLeftIcon$2,CaretRightIcon as CaretRightIcon$2}from'@baseline-ui/icons/16';import {CaretLeftIcon as CaretLeftIcon$1,CaretRightIcon as CaretRightIcon$1}from'@baseline-ui/icons/20';import {CaretLeftIcon,CaretRightIcon}from'@baseline-ui/icons/24';import w from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';/**
1
+ import {a as a$8}from'./chunk-E3FP4B25.mjs';import {a as a$1,b as b$2}from'./chunk-5ZC64ZG7.mjs';import {a as a$6}from'./chunk-JZXLV6JU.mjs';import {b as b$1,c as c$1}from'./chunk-7MLFM55C.mjs';import {a as a$5}from'./chunk-DAI7V4TE.mjs';import {b}from'./chunk-N2XGJKZG.mjs';import {a as a$4}from'./chunk-RSKKEGJZ.mjs';import {a as a$3}from'./chunk-STMDFIUL.mjs';import {a as a$2}from'./chunk-B3EZOXNU.mjs';import {c}from'./chunk-3WKDIXCM.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$7}from'./chunk-4QEH5CGK.mjs';import {CaretLeftIcon as CaretLeftIcon$3,CaretRightIcon as CaretRightIcon$3}from'@baseline-ui/icons/12';import {CaretLeftIcon as CaretLeftIcon$2,CaretRightIcon as CaretRightIcon$2}from'@baseline-ui/icons/16';import {CaretLeftIcon as CaretLeftIcon$1,CaretRightIcon as CaretRightIcon$1}from'@baseline-ui/icons/20';import {CaretLeftIcon,CaretRightIcon}from'@baseline-ui/icons/24';import w from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';/**
2
2
  * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
3
  *
4
4
  * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW