@baseline-ui/core 3.10.0 → 3.11.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 (228) hide show
  1. package/dist/Accordion.css +1 -1
  2. package/dist/Accordion.mjs +1 -1
  3. package/dist/ActionButton.mjs +1 -1
  4. package/dist/ActionGroup.mjs +1 -1
  5. package/dist/ActionIconButton.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.css +1 -1
  11. package/dist/Avatar.mjs +1 -1
  12. package/dist/Breadcrumbs.mjs +1 -1
  13. package/dist/ButtonSelect.css +1 -1
  14. package/dist/ButtonSelect.mjs +1 -1
  15. package/dist/Calendar.css +1 -1
  16. package/dist/Calendar.mjs +1 -1
  17. package/dist/ColorInput.css +1 -1
  18. package/dist/ColorInput.mjs +1 -1
  19. package/dist/ColorSwatch.mjs +1 -1
  20. package/dist/ColorSwatchPicker.mjs +1 -1
  21. package/dist/ComboBox.css +1 -1
  22. package/dist/ComboBox.mjs +1 -1
  23. package/dist/DateField.css +1 -1
  24. package/dist/DateField.mjs +1 -1
  25. package/dist/Dialog.mjs +1 -1
  26. package/dist/Drawer.mjs +1 -1
  27. package/dist/Editor.css +1 -1
  28. package/dist/Editor.mjs +1 -1
  29. package/dist/FileInput.css +1 -1
  30. package/dist/FileInput.mjs +1 -1
  31. package/dist/FileList.mjs +1 -1
  32. package/dist/FileUploader.mjs +1 -1
  33. package/dist/FrameProvider.mjs +1 -1
  34. package/dist/FreehandCanvas.mjs +1 -1
  35. package/dist/GridList.mjs +1 -1
  36. package/dist/I18nProvider.mjs +1 -1
  37. package/dist/ImageDropZone.mjs +1 -1
  38. package/dist/ImageGallery.css +1 -1
  39. package/dist/ImageGallery.mjs +1 -1
  40. package/dist/InlineAlert.mjs +1 -1
  41. package/dist/InlineToolbar.mjs +2 -2
  42. package/dist/ListBox.mjs +1 -1
  43. package/dist/Menu.mjs +1 -1
  44. package/dist/MessageFormat.mjs +1 -1
  45. package/dist/Modal.mjs +1 -1
  46. package/dist/NumberInput.css +1 -1
  47. package/dist/NumberInput.mjs +1 -1
  48. package/dist/Pagination.mjs +1 -1
  49. package/dist/PointPicker.mjs +1 -1
  50. package/dist/Popover.mjs +1 -1
  51. package/dist/Portal.mjs +1 -1
  52. package/dist/Preview.css +1 -1
  53. package/dist/Preview.mjs +1 -1
  54. package/dist/ProgressBar.css +1 -1
  55. package/dist/ProgressBar.mjs +1 -1
  56. package/dist/RadioGroup.css +1 -1
  57. package/dist/RadioGroup.mjs +1 -1
  58. package/dist/ScrollControlButton.mjs +1 -1
  59. package/dist/SearchInput.mjs +1 -1
  60. package/dist/Select.css +1 -1
  61. package/dist/Select.mjs +1 -1
  62. package/dist/Slider.css +1 -1
  63. package/dist/Slider.mjs +1 -1
  64. package/dist/Stepper.mjs +1 -1
  65. package/dist/Table.mjs +1 -1
  66. package/dist/Tabs.mjs +1 -1
  67. package/dist/Tag.mjs +1 -1
  68. package/dist/TagGroup.mjs +1 -1
  69. package/dist/TaggedPagination.mjs +1 -1
  70. package/dist/TextInput.css +1 -1
  71. package/dist/TextInput.mjs +1 -1
  72. package/dist/ThemeProvider.mjs +1 -1
  73. package/dist/TimeField.css +1 -1
  74. package/dist/TimeField.mjs +1 -1
  75. package/dist/Toast.mjs +1 -1
  76. package/dist/ToggleButton.mjs +1 -1
  77. package/dist/ToggleIconButton.mjs +1 -1
  78. package/dist/Toolbar.mjs +1 -1
  79. package/dist/Tooltip.mjs +1 -1
  80. package/dist/TreeView.css +1 -1
  81. package/dist/TreeView.mjs +1 -1
  82. package/dist/UNSAFE_ListBox.mjs +1 -1
  83. package/dist/VideoPlayer.css +10 -0
  84. package/dist/VideoPlayer.mjs +1 -0
  85. package/dist/Virtualizer.mjs +1 -1
  86. package/dist/{chunk-A52PIXOO.mjs → chunk-2FKVQSXF.mjs} +1 -1
  87. package/dist/{chunk-QPWBJW2X.mjs → chunk-4ATAOS5R.mjs} +1 -1
  88. package/dist/{chunk-5B6263RO.mjs → chunk-4JSIG3XV.mjs} +16 -16
  89. package/dist/chunk-5GTM4EJO.mjs +10 -0
  90. package/dist/{chunk-6IK2TDLH.mjs → chunk-5I4MVN7X.mjs} +1 -1
  91. package/dist/chunk-5OWMDF6S.mjs +10 -0
  92. package/dist/{chunk-UXAMVDQ4.mjs → chunk-5TRRBR6N.mjs} +1 -1
  93. package/dist/{chunk-S2MA4MRM.mjs → chunk-5Z4XSXFW.mjs} +1 -1
  94. package/dist/{chunk-QVXIFV7W.mjs → chunk-65J43PGI.mjs} +1 -1
  95. package/dist/{chunk-HOZPCWCF.mjs → chunk-667TGPFX.mjs} +1 -1
  96. package/dist/{chunk-ACHYZYVA.mjs → chunk-6VKDP37C.mjs} +1 -1
  97. package/dist/{chunk-UBLCUHRL.mjs → chunk-7GXVKCFC.mjs} +1 -1
  98. package/dist/chunk-7P6YVPSY.mjs +10 -0
  99. package/dist/chunk-7YHC33LQ.mjs +10 -0
  100. package/dist/{chunk-JGKBJHX2.mjs → chunk-ABMYMS6P.mjs} +2 -2
  101. package/dist/chunk-AQGAGABL.mjs +10 -0
  102. package/dist/{chunk-LJM26E7W.mjs → chunk-BNTMAM3S.mjs} +1 -1
  103. package/dist/{chunk-HVSDXCZP.mjs → chunk-CFU5AQZ4.mjs} +1 -1
  104. package/dist/{chunk-EPWWEFTP.mjs → chunk-D4P3YVSV.mjs} +1 -1
  105. package/dist/chunk-DD2TRFO4.mjs +10 -0
  106. package/dist/{chunk-HOG4QRLG.mjs → chunk-EEW7GTPE.mjs} +1 -1
  107. package/dist/{chunk-7EOAYPSZ.mjs → chunk-EOOQLRV5.mjs} +1 -1
  108. package/dist/{chunk-6VKIT2PF.mjs → chunk-FDFERRJ3.mjs} +2 -2
  109. package/dist/{chunk-QYU7CWJD.mjs → chunk-FKMXBSV2.mjs} +1 -1
  110. package/dist/{chunk-G2RVM2KB.mjs → chunk-FOCVZZPT.mjs} +1 -1
  111. package/dist/{chunk-LGE4377M.mjs → chunk-G5JW7B2K.mjs} +1 -1
  112. package/dist/chunk-G67TAFNZ.mjs +10 -0
  113. package/dist/chunk-GJYCSAXU.mjs +10 -0
  114. package/dist/{chunk-AANAI2XF.mjs → chunk-GW2COPW6.mjs} +1 -1
  115. package/dist/{chunk-QMFL5BMI.mjs → chunk-GZS3IPK5.mjs} +1 -1
  116. package/dist/{chunk-L7GYT3MC.mjs → chunk-HN2XJOQL.mjs} +1 -1
  117. package/dist/{chunk-CWPFUB7B.mjs → chunk-IRTS2NKL.mjs} +2 -2
  118. package/dist/chunk-IX5XTUKY.mjs +10 -0
  119. package/dist/{chunk-GJVQMTGA.mjs → chunk-J5OHLCGT.mjs} +1 -1
  120. package/dist/{chunk-TUSG5ZRW.mjs → chunk-JVBUNQEI.mjs} +1 -1
  121. package/dist/{chunk-VOWLLVPD.mjs → chunk-JY4FZPOK.mjs} +1 -1
  122. package/dist/{chunk-DP76DMVO.mjs → chunk-KF6Q3PUU.mjs} +1 -1
  123. package/dist/{chunk-S3LWWMMQ.mjs → chunk-KPNRHAG6.mjs} +1 -1
  124. package/dist/{chunk-IQ3Z6ZO2.mjs → chunk-LDF2ZF7V.mjs} +1 -1
  125. package/dist/{chunk-GAKWWL3Y.mjs → chunk-LM3YM7P3.mjs} +1 -1
  126. package/dist/{chunk-64Y62MDR.mjs → chunk-LQ54FC6R.mjs} +1 -1
  127. package/dist/chunk-MM7BYXUH.mjs +11 -0
  128. package/dist/{chunk-ZZGRLSEK.mjs → chunk-N5BFSM4K.mjs} +1 -1
  129. package/dist/{chunk-3P25UGHE.mjs → chunk-NEJXDGP5.mjs} +1 -1
  130. package/dist/{chunk-YI5VNFT4.mjs → chunk-NHVS56EF.mjs} +1 -1
  131. package/dist/{chunk-24WOG72O.mjs → chunk-NNGNZKM5.mjs} +1 -1
  132. package/dist/chunk-NPU6O7FH.mjs +10 -0
  133. package/dist/{chunk-QMSBDXK6.mjs → chunk-NVMFITUK.mjs} +1 -1
  134. package/dist/chunk-O55OXQQW.mjs +10 -0
  135. package/dist/{chunk-JQSZFPWJ.mjs → chunk-OC3YS6SE.mjs} +1 -1
  136. package/dist/{chunk-LZOXWIAS.mjs → chunk-OMGTKXQP.mjs} +1 -1
  137. package/dist/chunk-OQSEPK4W.mjs +10 -0
  138. package/dist/chunk-OTJ22ZQT.mjs +10 -0
  139. package/dist/chunk-OXTTKEGF.mjs +10 -0
  140. package/dist/{chunk-CBQO7JUC.mjs → chunk-Q2JOERVZ.mjs} +1 -1
  141. package/dist/{chunk-G2IYZES5.mjs → chunk-QARYQDRQ.mjs} +1 -1
  142. package/dist/{chunk-OWXMAVXI.mjs → chunk-QRHVS6JA.mjs} +1 -1
  143. package/dist/{chunk-C6TD53KY.mjs → chunk-RCX7NNM3.mjs} +1 -1
  144. package/dist/{chunk-AU3GNNEG.mjs → chunk-RD5DYYWA.mjs} +1 -1
  145. package/dist/{chunk-ZY3ZKJVD.mjs → chunk-RE7M6EBB.mjs} +1 -1
  146. package/dist/{chunk-6RN7DKRF.mjs → chunk-RIX32JXL.mjs} +1 -1
  147. package/dist/chunk-RTKSIESZ.mjs +10 -0
  148. package/dist/{chunk-AFJ3QV2Q.mjs → chunk-SKKISVY6.mjs} +1 -1
  149. package/dist/{chunk-WSDEMATI.mjs → chunk-U6252C5R.mjs} +1 -1
  150. package/dist/chunk-U6K54GAE.mjs +10 -0
  151. package/dist/{chunk-RM64ROGL.mjs → chunk-UJWWCOY3.mjs} +2 -2
  152. package/dist/{chunk-P3RRGPNM.mjs → chunk-ULARAZ62.mjs} +1 -1
  153. package/dist/chunk-W4SU2CES.mjs +10 -0
  154. package/dist/{chunk-JYWJE6L5.mjs → chunk-WBLMAN7U.mjs} +1 -1
  155. package/dist/{chunk-IIYP5UE7.mjs → chunk-X6RWEBD6.mjs} +1 -1
  156. package/dist/{chunk-GZTF5YE3.mjs → chunk-XBIE4AD2.mjs} +1 -1
  157. package/dist/chunk-XVLQWX2M.mjs +10 -0
  158. package/dist/chunk-XY5S6U26.mjs +11 -0
  159. package/dist/{chunk-EGSNIMDP.mjs → chunk-YJF3BHGB.mjs} +1 -1
  160. package/dist/{chunk-U6W7D7TT.mjs → chunk-ZAYG54JO.mjs} +1 -1
  161. package/dist/{chunk-UC6WAEPH.mjs → chunk-ZLG42OHF.mjs} +1 -1
  162. package/dist/{chunk-HOV7MM7M.mjs → chunk-ZTMBDIZH.mjs} +1 -1
  163. package/dist/hooks/useI18n.mjs +1 -1
  164. package/dist/hooks/useIsTouchDevice.mjs +1 -1
  165. package/dist/hooks/useLiveInteractionModality.mjs +1 -1
  166. package/dist/hooks/useLocalStorage.mjs +1 -1
  167. package/dist/hooks/useMedia.mjs +1 -1
  168. package/dist/hooks/useMediaQuery.mjs +1 -0
  169. package/dist/hooks/usePortalContainer.mjs +1 -1
  170. package/dist/index.css +1 -1
  171. package/dist/index.d.ts +183 -36
  172. package/dist/index.js +22 -22
  173. package/dist/index.mjs +1 -1
  174. package/dist/messageIds.mjs +1 -1
  175. package/intl/ar.json +18 -1
  176. package/intl/cs.json +18 -1
  177. package/intl/cy.json +18 -1
  178. package/intl/da.json +18 -1
  179. package/intl/de.json +18 -1
  180. package/intl/el.json +18 -1
  181. package/intl/en-GB.json +18 -1
  182. package/intl/en.json +18 -1
  183. package/intl/es.json +18 -1
  184. package/intl/fi.json +18 -1
  185. package/intl/fr-CA.json +18 -1
  186. package/intl/fr.json +18 -1
  187. package/intl/he.json +18 -1
  188. package/intl/hr.json +18 -1
  189. package/intl/id.json +18 -1
  190. package/intl/it.json +18 -1
  191. package/intl/ja.json +18 -1
  192. package/intl/ko.json +18 -1
  193. package/intl/ms.json +18 -1
  194. package/intl/nb-NO.json +18 -1
  195. package/intl/nl.json +18 -1
  196. package/intl/pl.json +18 -1
  197. package/intl/pt-PT.json +18 -1
  198. package/intl/pt.json +18 -1
  199. package/intl/ru.json +18 -1
  200. package/intl/sk.json +18 -1
  201. package/intl/sl.json +18 -1
  202. package/intl/sv.json +18 -1
  203. package/intl/th.json +18 -1
  204. package/intl/tr.json +18 -1
  205. package/intl/uk.json +18 -1
  206. package/intl/zh-Hans.json +18 -1
  207. package/intl/zh-Hant.json +18 -1
  208. package/messages.json +68 -0
  209. package/package.json +4 -4
  210. package/sbom.json +6 -6
  211. package/dist/chunk-23OLSA2X.mjs +0 -10
  212. package/dist/chunk-2CFMM7MZ.mjs +0 -10
  213. package/dist/chunk-2KRVQJDA.mjs +0 -10
  214. package/dist/chunk-2TMQUHHU.mjs +0 -10
  215. package/dist/chunk-5YV74V36.mjs +0 -10
  216. package/dist/chunk-A455VRNY.mjs +0 -10
  217. package/dist/chunk-AYBI4SQV.mjs +0 -10
  218. package/dist/chunk-CMM5JW7L.mjs +0 -10
  219. package/dist/chunk-CPX5CB4L.mjs +0 -10
  220. package/dist/chunk-GHKMHXQ3.mjs +0 -10
  221. package/dist/chunk-LNEOOIXS.mjs +0 -10
  222. package/dist/chunk-MQCTOCK2.mjs +0 -10
  223. package/dist/chunk-OJIOLYTM.mjs +0 -11
  224. package/dist/chunk-Q5SN5AQT.mjs +0 -10
  225. package/dist/chunk-SUJD4QFW.mjs +0 -10
  226. package/dist/chunk-TDRN6VLD.mjs +0 -10
  227. package/dist/chunk-W4DOEGYH.mjs +0 -10
  228. /package/dist/{chunk-XF65LVBQ.mjs → chunk-JFS73ERR.mjs} +0 -0
@@ -1,4 +1,4 @@
1
- import {a as a$t}from'./chunk-JI4SJ53O.mjs';import {a as a$9}from'./chunk-AFJ3QV2Q.mjs';import {a as a$2}from'./chunk-WDWBYTJG.mjs';import {b as b$2}from'./chunk-BPW4QRPV.mjs';import {a as a$q}from'./chunk-U5XI3CZD.mjs';import {a as a$u}from'./chunk-TDYBXLYP.mjs';import {a as a$r}from'./chunk-K3WFKO7R.mjs';import {b as b$a}from'./chunk-HZM2XZP4.mjs';import {b as b$5,a as a$o}from'./chunk-HOZPCWCF.mjs';import {a as a$f}from'./chunk-PPGEEMZ2.mjs';import {b as b$3}from'./chunk-LNEOOIXS.mjs';import {b as b$7,c as c$1}from'./chunk-U6W7D7TT.mjs';import {f as f$1}from'./chunk-V6ZIMZ53.mjs';import {a as a$l}from'./chunk-5BAHJXOI.mjs';import {a as a$7}from'./chunk-FCKJCFMD.mjs';import {a as a$m}from'./chunk-NGZRN4SF.mjs';import {a as a$s}from'./chunk-YI5VNFT4.mjs';import {a as a$h}from'./chunk-ACHYZYVA.mjs';import {a as a$j}from'./chunk-C6TD53KY.mjs';import {a as a$k}from'./chunk-UC6WAEPH.mjs';import {a as a$p}from'./chunk-QMP72J5L.mjs';import {b as b$8,e as e$1}from'./chunk-G2RVM2KB.mjs';import {a as a$b}from'./chunk-JZXLV6JU.mjs';import {a as a$e}from'./chunk-EJGGWOY5.mjs';import {c,b}from'./chunk-JYWJE6L5.mjs';import {b as b$9}from'./chunk-P3RRGPNM.mjs';import {a as a$a}from'./chunk-DIL5HL6K.mjs';import {a as a$c}from'./chunk-L7GYT3MC.mjs';import {b as b$6,f as f$2}from'./chunk-CFDIUF4H.mjs';import {a as a$n}from'./chunk-NIGOM3FD.mjs';import {a as a$d}from'./chunk-5IC46G5J.mjs';import {b as b$4,j as j$1}from'./chunk-QDMG3P5Z.mjs';import {a as a$1}from'./chunk-FPM5UJRF.mjs';import {a as a$5}from'./chunk-3K6XNSYE.mjs';import {a as a$3}from'./chunk-ELW6SXDM.mjs';import {a as a$4}from'./chunk-LRFFL765.mjs';import {j}from'./chunk-AIG23SN5.mjs';import {e}from'./chunk-2MNK24YJ.mjs';import {f,g as g$1,a as a$i,c as c$2}from'./chunk-V2C4UDOC.mjs';import {a as a$8,b as b$1,j as j$2,h}from'./chunk-TYOEGCPS.mjs';import {a as a$g}from'./chunk-UBLCUHRL.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$6}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 wt,{useCallback,useImperativeHandle,useEffect,useRef,useState,useMemo,useId,useContext,useLayoutEffect,Fragment as Fragment$1}from'react';import {useGranularLayoutEffect}from'granular-hooks';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import vi from'just-camel-case';import {QuestionmarkCircleIcon,TextIcon,HighlightTextIcon}from'@baseline-ui/icons/24';import*as br from'dompurify';import Ki from'just-kebab-case';import {createPortal}from'react-dom';/**
1
+ import {a as a$t}from'./chunk-JI4SJ53O.mjs';import {a as a$9}from'./chunk-SKKISVY6.mjs';import {a as a$2}from'./chunk-WDWBYTJG.mjs';import {b as b$2}from'./chunk-BPW4QRPV.mjs';import {a as a$q}from'./chunk-U5XI3CZD.mjs';import {a as a$u}from'./chunk-TDYBXLYP.mjs';import {a as a$r}from'./chunk-K3WFKO7R.mjs';import {b as b$a}from'./chunk-HZM2XZP4.mjs';import {b as b$5,a as a$o}from'./chunk-667TGPFX.mjs';import {a as a$f}from'./chunk-PPGEEMZ2.mjs';import {b as b$3}from'./chunk-NPU6O7FH.mjs';import {b as b$7,c as c$1}from'./chunk-ZAYG54JO.mjs';import {f as f$1}from'./chunk-V6ZIMZ53.mjs';import {a as a$l}from'./chunk-5BAHJXOI.mjs';import {a as a$7}from'./chunk-FCKJCFMD.mjs';import {a as a$m}from'./chunk-NGZRN4SF.mjs';import {a as a$s}from'./chunk-NHVS56EF.mjs';import {a as a$h}from'./chunk-6VKDP37C.mjs';import {a as a$j}from'./chunk-RCX7NNM3.mjs';import {a as a$k}from'./chunk-ZLG42OHF.mjs';import {a as a$p}from'./chunk-QMP72J5L.mjs';import {b as b$8,e as e$1}from'./chunk-FOCVZZPT.mjs';import {a as a$b}from'./chunk-JZXLV6JU.mjs';import {a as a$e}from'./chunk-EJGGWOY5.mjs';import {c,b}from'./chunk-WBLMAN7U.mjs';import {b as b$9}from'./chunk-ULARAZ62.mjs';import {a as a$a}from'./chunk-DIL5HL6K.mjs';import {a as a$c}from'./chunk-HN2XJOQL.mjs';import {b as b$6,f as f$2}from'./chunk-CFDIUF4H.mjs';import {a as a$n}from'./chunk-NIGOM3FD.mjs';import {a as a$d}from'./chunk-5IC46G5J.mjs';import {b as b$4,j as j$1}from'./chunk-QDMG3P5Z.mjs';import {a as a$1}from'./chunk-FPM5UJRF.mjs';import {a as a$5}from'./chunk-3K6XNSYE.mjs';import {a as a$3}from'./chunk-ELW6SXDM.mjs';import {a as a$4}from'./chunk-LRFFL765.mjs';import {j}from'./chunk-AIG23SN5.mjs';import {e}from'./chunk-2MNK24YJ.mjs';import {f,g as g$1,a as a$i,c as c$2}from'./chunk-V2C4UDOC.mjs';import {a as a$8,b as b$1,j as j$2,h}from'./chunk-TYOEGCPS.mjs';import {a as a$g}from'./chunk-7GXVKCFC.mjs';import {a}from'./chunk-JQQGRJ5J.mjs';import {a as a$6}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 Pt,{useCallback,useImperativeHandle,useEffect,useRef,useState,useMemo,useId,useContext,useLayoutEffect,Fragment as Fragment$1}from'react';import {useGranularLayoutEffect}from'granular-hooks';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Ri from'just-camel-case';import {QuestionmarkCircleIcon,TextIcon,HighlightTextIcon}from'@baseline-ui/icons/24';import*as Er from'dompurify';import Hi 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,24 +7,24 @@ import {a as a$t}from'./chunk-JI4SJ53O.mjs';import {a as a$9}from'./chunk-AFJ3QV
7
7
  * This notice may not be removed from this file.
8
8
  *
9
9
  */
10
- var qo="f6jv6bm",$o="_1yep5z64u _1yep5z64v _1yep5z64w _1yep5z676 _1yep5z677 _1yep5z678 _1yep5z6k8 _1yep5z6k9 _1yep5z6ka",it="_1yep5z689 _1yep5z68a _1yep5z68b _1yep5z65x _1yep5z65y _1yep5z65z",Go=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"]]}),xt=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:[]}),Yo="f6jv6b6",Xo="f6jv6bj _1yep5z6x7 _1yep5z6x8 _1yep5z6x9 _1yep5z6xv _1yep5z6xw _1yep5z6xx _1yep5z6yj _1yep5z6yk _1yep5z6yl _1yep5z6z7 _1yep5z6z8 _1yep5z6z9",Zo="f6jv6bk";var Jo="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",Qo=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:[]}),er="_1yep5z6ke _1yep5z6kf _1yep5z6kg",tr="f6jv6bf f6jv6bb _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6j5 _1yep5z6j6 _1yep5z6j7 _1yep5z6ey _1yep5z6e3 _1yep5z6m3",nr=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:[]}),or="f6jv6bl",rr="f6jv6bb _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6j5 _1yep5z6j6 _1yep5z6j7 _1yep5z6ey",Wt=a({defaultClassName:"f6jv6b7",variantClassNames:{isInline:{true:"f6jv6b8",false:"f6jv6b9"}},defaultVariants:{},compoundVariants:[]}),qt="f6jv6ba _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z6jz _1yep5z6k0 _1yep5z6k1",yt="f6jv6bo";var $t=wt.forwardRef(({value:t,defaultValue:e,onChange:n,placeholder:o,spellCheck:r,textBoxRef:i,isInline:s,isMinimal:l,isDisabled:a,editableContentAriaLabel:c,editorHandle:d,autoFocus:u,saveOnEnter:f$1,onSave:p},h)=>{let m=wt.useRef(null),[k,I]=a$1(t,e||"",n),$=useCallback(E=>{I(E.currentTarget.value||"");},[I]),w=useCallback(E=>{a$2(E)||(f$1&&E.key==="Enter"&&!E.shiftKey||(E.ctrlKey||E.metaKey)&&E.key==="Enter")&&(E.preventDefault(),p());},[f$1,p]);useImperativeHandle(h,()=>({clear:()=>{I("");}}));let j=useCallback(E=>{E.currentTarget.style.height="16px",E.currentTarget.style.height=E.currentTarget.scrollHeight+"px";},[]);useGranularLayoutEffect(()=>{let E=m.current;E&&(E.style.height="16px",E.style.height=E.scrollHeight+"px");},[l],[k]),useImperativeHandle(d,()=>({setCaretPosition:E=>{m.current&&(m.current.focus(),m.current.setSelectionRange(E,E));},focus:()=>{m.current&&m.current.focus();}}));let N=u===true||u==="start"||u==="end",D=typeof u=="string"?u:void 0;useEffect(()=>{if(D&&m.current){let E=D==="start"?0:D==="end"?m.current.value.length:void 0;E!==void 0&&m.current.setSelectionRange(E,E);}},[D]);let{focusProps:Q,isFocused:U,isFocusVisible:pe}=a$3(),{hoverProps:x,isHovered:M}=a$4({isDisabled:a}),G=a$5({"data-focus-visible":pe,"data-hovered":M,"data-focused":U});return jsx("textarea",{...g$1(Q,x,G),ref:f(m,i),className:a$6({[xt()]:!l,[Wt({isInline:s})]:!l,[rr]:!l,[tr]:l},"BaselineUI-Editor-PlainEditorEditingArea"),autoFocus:N,onChange:$,disabled:a,onInput:j,value:k,placeholder:o,spellCheck:r,"aria-label":c,onKeyDown:w})});$t.displayName="PlainEditor";var ar=[["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:bt}}=layoutSprinkleValues,cr=({isOpen:t,onClose:e,toolbarFocusLabel:n,helpLabel:o,closeLabel:r,actionLabel:i,shortcutLabel:s,boldLabel:l,italicLabel:a,underlineLabel:c,selectAllLabel:d,cutLabel:u,copyLabel:f,pasteLabel:p,undoLabel:h,redoLabel:m,openHelpDialogLabel:k,submitLabel:I})=>{let{formatMessage:$}=b(),w=c$2(),j={toolbarFocus:n,help:o,close:r,action:i,shortcut:s,bold:l,italic:a,underline:c,selectAll:d,cut:u,copy:f,paste:p,undo:h,redo:m,openHelpDialog:k,submit:I},N=D=>j[D]??$(ki[D]);return jsx(b$8,{isOpen:t,onOpenChange:D=>{D||e();},children:jsx(e$1,{enableDrawer:"auto",style:{zIndex:999999},children:jsxs(a$k,{"aria-labelledby":w,className:Xo,drawerBackground:"subtle",children:[jsxs(a$a,{paddingLeft:bt.padding.horizontal.lg,paddingRight:bt.padding.horizontal.sm,display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",backgroundColor:"background.primary.subtle",className:Zo,children:[jsx(a$p,{id:w,elementType:"h3",type:"title",size:"md",children:N("help")}),jsx(a$c,{icon:XIcon,size:"md",variant:"secondary","aria-label":N("close"),"data-testid":"editor-help-dialog-close-button",onPress:e})]}),jsx(a$b,{className:or}),jsxs(a$a,{paddingX:bt.padding.horizontal.lg,role:"table","aria-labelledby":w,backgroundColor:"background.primary.subtle",children:[jsx("div",{role:"rowgroup",children:jsxs(a$a,{role:"row",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingY:bt.padding.vertical.md,color:"text.primary",children:[jsx("h6",{className:sprinkles({typography:"heading.h6.semibold"}),role:"columnheader",children:N("action")}),jsx("h6",{className:sprinkles({typography:"heading.h6.semibold"}),role:"columnheader",style:{textTransform:"capitalize"},children:N("shortcut")})]})}),jsx("div",{role:"rowgroup",children:ar.map(([D,Q],U)=>jsxs(Fragment$1,{children:[jsxs(a$a,{role:"row",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingY:bt.padding.vertical.xs,style:{minHeight:40},children:[jsx(a$p,{type:"subtitle",size:"sm",role:"cell",children:N(vi(D))}),jsx(a$p,{elementType:"kbd",type:"subtitle",size:"sm",role:"cell",children:a$q(Q,true)})]}),U!==ar.length-1&&jsx(a$b,{})]},D))})]})]})})})},ki=c({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 Mi=a$7("#ffffff00").toString("hexa"),Mn=[{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"}];[...Mn,{label:"Transparent",color:Mi}];var lt="p",X="a",ce="mention",Ce="mention_input";function Ln(t,e){return typeof t=="object"&&t!==null&&"type"in t&&t.type===e}function g(t){return typeof t=="object"&&t!==null&&"text"in t&&!("type"in t)}function R(t){return Ln(t,X)}function oe(t){return Ln(t,ce)}function Z(t){return Ln(t,Ce)}function re(t){return oe(t)||Z(t)}function xe(){return [{type:lt,children:[{text:""}]}]}function Et(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)&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize}function dr(t,e){return t.text===e.text&&Et(t,e)}function Ci(t,e){return g(t)?g(e)&&dr(t,e):g(e)||t.type!==e.type||t.children.length!==e.children.length||R(t)&&R(e)&&t.url!==e.url||oe(t)&&oe(e)&&(t.value!==e.value||t.displayName!==e.displayName)?false:t.children.every((n,o)=>dr(n,e.children[o]))}function fr(t,e){return t.length===e.length&&t.every((n,o)=>Sn(n,e[o]))}function Sn(t,e){return t.textAlign===e.textAlign&&t.children.length===e.children.length&&t.children.every((n,o)=>Ci(n,e.children[o]))}function Cn(t){let[e]=t.children;return t.children.length===1&&g(e)&&e.text===""}function pr(t,e){let n=(a,c)=>Sn(a,c)||Cn(a)&&Cn(c)&&a.textAlign===c.textAlign,o=Math.min(t.length,e.length),r=0;for(;r<o&&n(t[r],e[r]);)r+=1;let i=0;for(;i<o-r&&n(t[t.length-1-i],e[e.length-1-i]);)i+=1;let s=null,l=(a,c)=>{let d=e[c];!Cn(d)||Sn(t[a],d)||(s??=[...t],s[a]=d);};for(let a=0;a<r;a++)l(a,a);for(let a=0;a<i;a++)l(t.length-1-a,e.length-1-a);return s??t}function Gt(t,e){let n=false;for(let i=0;i<t.length;i++){let s=t[i];if(s.text===""&&!(e&&t.length===1)){n=true;break}if(i>0&&Et(t[i-1],s)){n=true;break}}if(!n)return t;let o=t.filter(i=>i.text!==""),r=[];for(let i of o){let s=r.at(-1);s!==void 0&&Et(s,i)?r[r.length-1]={...s,text:s.text+i.text}:r.push(i);}return r}function Si(t){let e=(i,s)=>i===0&&s===t.length||i>0&&re(t[i-1]),n=false,o=-1;for(let i=0;i<=t.length;i++){let s=t[i],l=i<t.length&&g(s);if(l&&o===-1)o=i;else if(!l&&o!==-1){let a=t.slice(o,i);if(Gt(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 s=t[i],l=i<t.length&&g(s);if(l&&o===-1)o=i;else if(!l&&o!==-1){let a=t.slice(o,i),c=Gt(a,e(o,i));for(let d of c)r.push(d);o=-1;}!l&&i<t.length&&r.push(s);}return r}function Li(t){let e=false;for(let o=1;o<t.length;o++){let r=t[o-1],i=t[o];if(R(r)&&R(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(R(o)&&r!==void 0&&R(r)&&r.url===o.url){let i=Gt([...r.children,...o.children],false);n[n.length-1]={...r,children:i};}else n.push(o);}return n}function Di(t){let e=Gt(t.children,t.children.length===1);return e.reduce((o,r)=>o+r.text,"")===""?null:e===t.children?t:{...t,children:e}}function zi(t){let e=false,n=[];for(let a of t)if(R(a)){let c=Di(a);c===null?e=true:(n.push(c),c!==a&&(e=true));}else n.push(a);let o=e?n:t,r=Si(o),i=Li(r),s=(a,c)=>re(a[c])&&(c===a.length-1||!g(a[c+1])),l=i;if(i.some((a,c)=>s(i,c))){l=[];for(let[a,c]of i.entries())l.push(c),s(i,a)&&l.push({text:""});}return l.length===0?[{text:""}]:l===o&&!e?t:l}function L(t){if(t.length===0)return xe();let e=false,n=t.map(o=>{let r=zi(o.children);return r===o.children?o:(e=true,{...o,children:r})});return e?n:t}function Tt(t,e){let n=e>0&&e<t.length&&/[\uD800-\uDBFF]/.test(t[e-1]);return t.slice(0,n?e-1:e)}function Pi(t,e){let n=[],o=e;for(let r of t){if(o<=0)break;n.push(r.text.length>o?{...r,text:Tt(r.text,o)}:r),o-=r.text.length;}return n}function wi(t,e){let n=[],o=e;for(let r of t){let i=B(r);if(i<=o)n.push(r),o-=i;else if(g(r)){n.push({...r,text:Tt(r.text,o)});break}else if(R(r)){n.push({...r,children:Pi(r.children,o)});break}else break}return n}function ur(t){return t.reduce((e,n)=>e+B(n),0)}function Dn(t,e){if(A(t)<=e)return t;let n=[],o=e;for(let[r,i]of t.entries()){if(r>0){if(o===0)break;o-=1;}let s=wi(i.children,o);n.push({...i,children:s});let l=ur(s);if(l<ur(i.children))break;o-=l;}return L(n)}function hr(t){throw new Error(`Editor: unknown inline node "${String(t.type)}".`)}function Ai(t){if(g(t))return t.text;switch(t.type){case X:return t.children.map(e=>e.text).join("");case ce:return t.displayName;case Ce:return t.children[0].text;default:return hr(t)}}function zn(t){return t.map(e=>e.children.map(n=>Ai(n)).join("")).join(`
11
- `)}function B(t){if(g(t))return t.text.length;switch(t.type){case X:{let e=0;for(let n=0;n<t.children.length;n++)e+=t.children[n].text.length;return e}case ce:return t.displayName.length;case Ce:return t.children[0].text.length;default:return hr(t)}}function A(t){if(t.length===0)return 0;let e=t.length-1;for(let n of t)for(let o of n.children)e+=B(o);return e}var vt=["color","backgroundColor"],gr=["color","backgroundColor","fontFamily","fontSize","textAlign"],Ii=1,wn=3;function Rt(t){return t.nodeType===Ii}function at(t,e){return t.tagName.toLowerCase()===e}function _i(t){if(!Rt(t))return false;let e=t.tagName.toLowerCase();return e==="p"||e==="div"}function Ni(t){return Rt(t)&&t.querySelector("p, div")!==null}var Oi=new RegExp("["+String.fromCodePoint(8203)+String.fromCodePoint(65279)+"]","g"),Bi=String.fromCodePoint(160);function Ue(t){return t.replaceAll(Oi,"").replaceAll(Bi," ")}function Yt(t,e,n){let o={...e},r=t.tagName.toLowerCase();(r==="b"||r==="strong")&&(o.bold=true),(r==="i"||r==="em")&&(o.italic=true),r==="u"&&(o.underline=true);let i=t.style;if(i){let s=i.fontWeight;(s==="bold"||Number.parseInt(s,10)>=600&&s!=="")&&(o.bold=true),i.fontStyle==="italic"&&(o.italic=true),i.textDecoration?.includes("underline")&&(o.underline=true);let l=i.color;l&&n.includes("color")&&(o.color=l);let a=i.backgroundColor;a&&n.includes("backgroundColor")&&(o.backgroundColor=a);let c=i.fontFamily;c&&n.includes("fontFamily")&&(o.fontFamily=c);let d=i.fontSize;d&&n.includes("fontSize")&&(o.fontSize=d);}return o}function Xt(t,e,n,o,r){for(let i=0;i<t.childNodes.length;i++){let s=t.childNodes[i];if(s.nodeType===wn){let a=s.nodeValue??"",c=Ue(a);c.length>0&&o.push(kt(c,e));continue}if(!Rt(s))continue;if(at(s,"span")&&s.dataset.userId!==void 0){let a=s.dataset.userId??"",c=s.textContent??"",d=c.startsWith("@")?c.slice(1):c;o.push({type:ce,value:a,displayName:d,children:[{text:""}]});continue}if(at(s,"span")&&s.dataset.mentionAnchor!==void 0){let a=s.textContent??"";o.push({type:Ce,children:[{text:a}]});continue}if(at(s,"a")){let a=Yt(s,e,r);{let c=s.getAttribute("href")??"",d=[];xr(s,a,d,r);let u=An(d);u.some(p=>p.text.length>0)&&o.push({type:X,url:c,children:u});}continue}if(at(s,"br")){o.push({text:"\0BR\0"});continue}let l=Yt(s,e,r);Xt(s,l,n,o,r);}}function xr(t,e,n,o){for(let r=0;r<t.childNodes.length;r++){let i=t.childNodes[r];if(i.nodeType===wn){let l=i.nodeValue??"",a=Ue(l);a.length>0&&n.push(kt(a,e));continue}if(!Rt(i))continue;if(at(i,"br")){n.push({text:"\0BR\0"});continue}let s=Yt(i,e,o);xr(i,s,n,o);}}function kt(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),e.fontFamily&&(n.fontFamily=e.fontFamily),e.fontSize&&(n.fontSize=e.fontSize),n}var yr="\0BR\0";function An(t){let e=[...t];if(e.length===1&&Pn(e[0]))return [{text:""}];let n=e.length,o=0;for(;o<n&&Pn(e[n-1-o]);)o+=1;let r=o>=2?o-1:0;n-=o;let i=[];for(let s=0;s<n;s++){let l=e[s];Pn(l)?mr(i):i.push(l);}for(let s=0;s<r;s++)mr(i);return i}function Pn(t){return "text"in t&&t.text===yr}function mr(t){let e=t.at(-1);e!==void 0&&"text"in e&&!("type"in e)?e.text+=`
10
+ var $o="f6jv6bm",Go="_1yep5z64u _1yep5z64v _1yep5z64w _1yep5z676 _1yep5z677 _1yep5z678 _1yep5z6k8 _1yep5z6k9 _1yep5z6ka",it="_1yep5z689 _1yep5z68a _1yep5z68b _1yep5z65x _1yep5z65y _1yep5z65z",Yo=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"]]}),gt=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:[]}),Xo="f6jv6b6",Zo="f6jv6bj _1yep5z6x7 _1yep5z6x8 _1yep5z6x9 _1yep5z6xv _1yep5z6xw _1yep5z6xx _1yep5z6yj _1yep5z6yk _1yep5z6yl _1yep5z6z7 _1yep5z6z8 _1yep5z6z9",Jo="f6jv6bk";var Qo="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",er=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:[]}),tr="_1yep5z6ke _1yep5z6kf _1yep5z6kg",nr="f6jv6bf f6jv6bb _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6j5 _1yep5z6j6 _1yep5z6j7 _1yep5z6ey _1yep5z6e3 _1yep5z6m3",or=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:[]}),rr="f6jv6bl",ir="f6jv6bb _1yep5z6ai _1yep5z6aj _1yep5z6ak _1yep5z6b6 _1yep5z6b7 _1yep5z6b8 _1yep5z6j5 _1yep5z6j6 _1yep5z6j7 _1yep5z6ey",qt=a({defaultClassName:"f6jv6b7",variantClassNames:{isInline:{true:"f6jv6b8",false:"f6jv6b9"}},defaultVariants:{},compoundVariants:[]}),$t="f6jv6ba _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z6jz _1yep5z6k0 _1yep5z6k1",xt="f6jv6bo";var Gt=Pt.forwardRef(({value:t,defaultValue:e,onChange:n,placeholder:o,spellCheck:r,textBoxRef:i,isInline:s,isMinimal:l,isDisabled:a,editableContentAriaLabel:c,editorHandle:d,autoFocus:u,saveOnEnter:f$1,onSave:p},h)=>{let m=Pt.useRef(null),[R,I]=a$1(t,e||"",n),$=useCallback(T=>{I(T.currentTarget.value||"");},[I]),w=useCallback(T=>{a$2(T)||(f$1&&T.key==="Enter"&&!T.shiftKey||(T.ctrlKey||T.metaKey)&&T.key==="Enter")&&(T.preventDefault(),p());},[f$1,p]);useImperativeHandle(h,()=>({clear:()=>{I("");}}));let j=useCallback(T=>{T.currentTarget.style.height="16px",T.currentTarget.style.height=T.currentTarget.scrollHeight+"px";},[]);useGranularLayoutEffect(()=>{let T=m.current;T&&(T.style.height="16px",T.style.height=T.scrollHeight+"px");},[l],[R]),useImperativeHandle(d,()=>({setCaretPosition:T=>{m.current&&(m.current.focus(),m.current.setSelectionRange(T,T));},focus:()=>{m.current&&m.current.focus();}}));let N=u===true||u==="start"||u==="end",D=typeof u=="string"?u:void 0;useEffect(()=>{if(D&&m.current){let T=D==="start"?0:D==="end"?m.current.value.length:void 0;T!==void 0&&m.current.setSelectionRange(T,T);}},[D]);let{focusProps:Q,isFocused:U,isFocusVisible:he}=a$3(),{hoverProps:x,isHovered:k}=a$4({isDisabled:a}),G=a$5({"data-focus-visible":he,"data-hovered":k,"data-focused":U});return jsx("textarea",{...g$1(Q,x,G),ref:f(m,i),className:a$6({[gt()]:!l,[qt({isInline:s})]:!l,[ir]:!l,[nr]:l},"BaselineUI-Editor-PlainEditorEditingArea"),autoFocus:N,onChange:$,disabled:a,onInput:j,value:R,placeholder:o,spellCheck:r,"aria-label":c,onKeyDown:w})});Gt.displayName="PlainEditor";var cr=[["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:yt}}=layoutSprinkleValues,dr=({isOpen:t,onClose:e,toolbarFocusLabel:n,helpLabel:o,closeLabel:r,actionLabel:i,shortcutLabel:s,boldLabel:l,italicLabel:a,underlineLabel:c,selectAllLabel:d,cutLabel:u,copyLabel:f,pasteLabel:p,undoLabel:h,redoLabel:m,openHelpDialogLabel:R,submitLabel:I})=>{let{formatMessage:$}=b(),w=c$2(),j={toolbarFocus:n,help:o,close:r,action:i,shortcut:s,bold:l,italic:a,underline:c,selectAll:d,cut:u,copy:f,paste:p,undo:h,redo:m,openHelpDialog:R,submit:I},N=D=>j[D]??$(Mi[D]);return jsx(b$8,{isOpen:t,onOpenChange:D=>{D||e();},children:jsx(e$1,{enableDrawer:"auto",style:{zIndex:999999},children:jsxs(a$k,{"aria-labelledby":w,className:Zo,drawerBackground:"subtle",children:[jsxs(a$a,{paddingLeft:yt.padding.horizontal.lg,paddingRight:yt.padding.horizontal.sm,display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",backgroundColor:"background.primary.subtle",className:Jo,children:[jsx(a$p,{id:w,elementType:"h3",type:"title",size:"md",children:N("help")}),jsx(a$c,{icon:XIcon,size:"md",variant:"secondary","aria-label":N("close"),"data-testid":"editor-help-dialog-close-button",onPress:e})]}),jsx(a$b,{className:rr}),jsxs(a$a,{paddingX:yt.padding.horizontal.lg,role:"table","aria-labelledby":w,backgroundColor:"background.primary.subtle",children:[jsx("div",{role:"rowgroup",children:jsxs(a$a,{role:"row",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingY:yt.padding.vertical.md,color:"text.primary",children:[jsx("h6",{className:sprinkles({typography:"heading.h6.semibold"}),role:"columnheader",children:N("action")}),jsx("h6",{className:sprinkles({typography:"heading.h6.semibold"}),role:"columnheader",style:{textTransform:"capitalize"},children:N("shortcut")})]})}),jsx("div",{role:"rowgroup",children:cr.map(([D,Q],U)=>jsxs(Fragment$1,{children:[jsxs(a$a,{role:"row",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingY:yt.padding.vertical.xs,style:{minHeight:40},children:[jsx(a$p,{type:"subtitle",size:"sm",role:"cell",children:N(Ri(D))}),jsx(a$p,{elementType:"kbd",type:"subtitle",size:"sm",role:"cell",children:a$q(Q,true)})]}),U!==cr.length-1&&jsx(a$b,{})]},D))})]})]})})})},Mi=c({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 Ci=a$7("#ffffff00").toString("hexa"),Sn=[{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"}];[...Sn,{label:"Transparent",color:Ci}];var lt="p",X="a",de="mention",Se="mention_input";function zn(t,e){return typeof t=="object"&&t!==null&&"type"in t&&t.type===e}function g(t){return typeof t=="object"&&t!==null&&"text"in t&&!("type"in t)}function v(t){return zn(t,X)}function oe(t){return zn(t,de)}function Z(t){return zn(t,Se)}function re(t){return oe(t)||Z(t)}function ye(){return [{type:lt,children:[{text:""}]}]}function bt(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)&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize}function ur(t,e){return t.text===e.text&&bt(t,e)}function Si(t,e){return g(t)?g(e)&&ur(t,e):g(e)||t.type!==e.type||t.children.length!==e.children.length||v(t)&&v(e)&&t.url!==e.url||oe(t)&&oe(e)&&(t.value!==e.value||t.displayName!==e.displayName)?false:t.children.every((n,o)=>ur(n,e.children[o]))}function pr(t,e){return t.length===e.length&&t.every((n,o)=>Dn(n,e[o]))}function Dn(t,e){return t.textAlign===e.textAlign&&t.children.length===e.children.length&&t.children.every((n,o)=>Si(n,e.children[o]))}function Ln(t){let[e]=t.children;return t.children.length===1&&g(e)&&e.text===""}function hr(t,e){let n=(a,c)=>Dn(a,c)||Ln(a)&&Ln(c)&&a.textAlign===c.textAlign,o=Math.min(t.length,e.length),r=0;for(;r<o&&n(t[r],e[r]);)r+=1;let i=0;for(;i<o-r&&n(t[t.length-1-i],e[e.length-1-i]);)i+=1;let s=null,l=(a,c)=>{let d=e[c];!Ln(d)||Dn(t[a],d)||(s??=[...t],s[a]=d);};for(let a=0;a<r;a++)l(a,a);for(let a=0;a<i;a++)l(t.length-1-a,e.length-1-a);return s??t}function Yt(t,e){let n=false;for(let i=0;i<t.length;i++){let s=t[i];if(s.text===""&&!(e&&t.length===1)){n=true;break}if(i>0&&bt(t[i-1],s)){n=true;break}}if(!n)return t;let o=t.filter(i=>i.text!==""),r=[];for(let i of o){let s=r.at(-1);s!==void 0&&bt(s,i)?r[r.length-1]={...s,text:s.text+i.text}:r.push(i);}return r}function Li(t){let e=(i,s)=>i===0&&s===t.length||i>0&&re(t[i-1]),n=false,o=-1;for(let i=0;i<=t.length;i++){let s=t[i],l=i<t.length&&g(s);if(l&&o===-1)o=i;else if(!l&&o!==-1){let a=t.slice(o,i);if(Yt(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 s=t[i],l=i<t.length&&g(s);if(l&&o===-1)o=i;else if(!l&&o!==-1){let a=t.slice(o,i),c=Yt(a,e(o,i));for(let d of c)r.push(d);o=-1;}!l&&i<t.length&&r.push(s);}return r}function Di(t){let e=false;for(let o=1;o<t.length;o++){let r=t[o-1],i=t[o];if(v(r)&&v(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(v(o)&&r!==void 0&&v(r)&&r.url===o.url){let i=Yt([...r.children,...o.children],false);n[n.length-1]={...r,children:i};}else n.push(o);}return n}function zi(t){let e=Yt(t.children,t.children.length===1);return e.reduce((o,r)=>o+r.text,"")===""?null:e===t.children?t:{...t,children:e}}function Pi(t){let e=false,n=[];for(let a of t)if(v(a)){let c=zi(a);c===null?e=true:(n.push(c),c!==a&&(e=true));}else n.push(a);let o=e?n:t,r=Li(o),i=Di(r),s=(a,c)=>re(a[c])&&(c===a.length-1||!g(a[c+1])),l=i;if(i.some((a,c)=>s(i,c))){l=[];for(let[a,c]of i.entries())l.push(c),s(i,a)&&l.push({text:""});}return l.length===0?[{text:""}]:l===o&&!e?t:l}function L(t){if(t.length===0)return ye();let e=false,n=t.map(o=>{let r=Pi(o.children);return r===o.children?o:(e=true,{...o,children:r})});return e?n:t}function Et(t,e){let n=e>0&&e<t.length&&/[\uD800-\uDBFF]/.test(t[e-1]);return t.slice(0,n?e-1:e)}function wi(t,e){let n=[],o=e;for(let r of t){if(o<=0)break;n.push(r.text.length>o?{...r,text:Et(r.text,o)}:r),o-=r.text.length;}return n}function Ai(t,e){let n=[],o=e;for(let r of t){let i=B(r);if(i<=o)n.push(r),o-=i;else if(g(r)){n.push({...r,text:Et(r.text,o)});break}else if(v(r)){n.push({...r,children:wi(r.children,o)});break}else break}return n}function fr(t){return t.reduce((e,n)=>e+B(n),0)}function Pn(t,e){if(A(t)<=e)return t;let n=[],o=e;for(let[r,i]of t.entries()){if(r>0){if(o===0)break;o-=1;}let s=Ai(i.children,o);n.push({...i,children:s});let l=fr(s);if(l<fr(i.children))break;o-=l;}return L(n)}function mr(t){throw new Error(`Editor: unknown inline node "${String(t.type)}".`)}function Ii(t){if(g(t))return t.text;switch(t.type){case X:return t.children.map(e=>e.text).join("");case de:return t.displayName;case Se:return t.children[0].text;default:return mr(t)}}function wn(t){return t.map(e=>e.children.map(n=>Ii(n)).join("")).join(`
11
+ `)}function B(t){if(g(t))return t.text.length;switch(t.type){case X:{let e=0;for(let n=0;n<t.children.length;n++)e+=t.children[n].text.length;return e}case de:return t.displayName.length;case Se:return t.children[0].text.length;default:return mr(t)}}function A(t){if(t.length===0)return 0;let e=t.length-1;for(let n of t)for(let o of n.children)e+=B(o);return e}var Tt=["color","backgroundColor"],xr=["color","backgroundColor","fontFamily","fontSize","textAlign"],_i=1,In=3;function vt(t){return t.nodeType===_i}function at(t,e){return t.tagName.toLowerCase()===e}function Ni(t){if(!vt(t))return false;let e=t.tagName.toLowerCase();return e==="p"||e==="div"}function Oi(t){return vt(t)&&t.querySelector("p, div")!==null}var Bi=new RegExp("["+String.fromCodePoint(8203)+String.fromCodePoint(65279)+"]","g"),Fi=String.fromCodePoint(160);function je(t){return t.replaceAll(Bi,"").replaceAll(Fi," ")}function Xt(t,e,n){let o={...e},r=t.tagName.toLowerCase();(r==="b"||r==="strong")&&(o.bold=true),(r==="i"||r==="em")&&(o.italic=true),r==="u"&&(o.underline=true);let i=t.style;if(i){let s=i.fontWeight;(s==="bold"||Number.parseInt(s,10)>=600&&s!=="")&&(o.bold=true),i.fontStyle==="italic"&&(o.italic=true),i.textDecoration?.includes("underline")&&(o.underline=true);let l=i.color;l&&n.includes("color")&&(o.color=l);let a=i.backgroundColor;a&&n.includes("backgroundColor")&&(o.backgroundColor=a);let c=i.fontFamily;c&&n.includes("fontFamily")&&(o.fontFamily=c);let d=i.fontSize;d&&n.includes("fontSize")&&(o.fontSize=d);}return o}function Zt(t,e,n,o,r){for(let i=0;i<t.childNodes.length;i++){let s=t.childNodes[i];if(s.nodeType===In){let a=s.nodeValue??"",c=je(a);c.length>0&&o.push(Rt(c,e));continue}if(!vt(s))continue;if(at(s,"span")&&s.dataset.userId!==void 0){let a=s.dataset.userId??"",c=s.textContent??"",d=c.startsWith("@")?c.slice(1):c;o.push({type:de,value:a,displayName:d,children:[{text:""}]});continue}if(at(s,"span")&&s.dataset.mentionAnchor!==void 0){let a=s.textContent??"";o.push({type:Se,children:[{text:a}]});continue}if(at(s,"a")){let a=Xt(s,e,r);{let c=s.getAttribute("href")??"",d=[];yr(s,a,d,r);let u=_n(d);u.some(p=>p.text.length>0)&&o.push({type:X,url:c,children:u});}continue}if(at(s,"br")){o.push({text:"\0BR\0"});continue}let l=Xt(s,e,r);Zt(s,l,n,o,r);}}function yr(t,e,n,o){for(let r=0;r<t.childNodes.length;r++){let i=t.childNodes[r];if(i.nodeType===In){let l=i.nodeValue??"",a=je(l);a.length>0&&n.push(Rt(a,e));continue}if(!vt(i))continue;if(at(i,"br")){n.push({text:"\0BR\0"});continue}let s=Xt(i,e,o);yr(i,s,n,o);}}function Rt(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),e.fontFamily&&(n.fontFamily=e.fontFamily),e.fontSize&&(n.fontSize=e.fontSize),n}var br="\0BR\0";function _n(t){let e=[...t];if(e.length===1&&An(e[0]))return [{text:""}];let n=e.length,o=0;for(;o<n&&An(e[n-1-o]);)o+=1;let r=o>=2?o-1:0;n-=o;let i=[];for(let s=0;s<n;s++){let l=e[s];An(l)?gr(i):i.push(l);}for(let s=0;s<r;s++)gr(i);return i}function An(t){return "text"in t&&t.text===br}function gr(t){let e=t.at(-1);e!==void 0&&"text"in e&&!("type"in e)?e.text+=`
12
12
  `:t.push({text:`
13
- `});}function Fi(t,e){let n=[];Xt(t,Yt(t,{},e),false,n,e);let o=An(n),r=e.includes("textAlign")?t.style?.textAlign:void 0;return {type:lt,...r?{textAlign:r}:{},children:o.length>0?o:[{text:""}]}}function Zt(t,e=vt){let n=t.childNodes;if(n.length===0)return xe();let o=[],r=[];function i(){if(r.length===0)return;let l=An(r);o.push({type:lt,children:l.length>0?l:[{text:""}]}),r=[];}function s(l){for(let a of l)if(_i(a))i(),o.push(Fi(a,e));else if(a.nodeType===wn){let c=a.nodeValue??"",d=Ue(c);d.trim().length>0&&r.push({text:d});}else Rt(a)&&(at(a,"br")?r.push({text:yr}):Ni(a)?(i(),s(a.childNodes)):Xt(a,{},false,r,e));}return s(n),i(),o.length===0?xe():L(o)}function Hi(t){return Object.entries(t).map(([e,n])=>`${Ki(e)}:${n}`).filter(([,e])=>!!e).join(";")}function In(t){return !t.color&&!t.backgroundColor&&!t.fontFamily&&!t.fontSize?"":Hi(a$5({color:Ve(t.color),backgroundColor:Ve(t.backgroundColor),fontFamily:Ve(t.fontFamily),fontSize:Ve(t.fontSize)}))}function Er(t){return "text"in t}function Ve(t){if(!(t===void 0||/[;{}]|url\(/i.test(t)))return t}function ct(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function ye(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 _n(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 Tr(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=ye(o.getAttribute("href")??"");return {isLinkClick:true,url:r===""?null:r}}function ji(t){return t.text.includes(`
13
+ `});}function Ki(t,e){let n=[];Zt(t,Xt(t,{},e),false,n,e);let o=_n(n),r=e.includes("textAlign")?t.style?.textAlign:void 0;return {type:lt,...r?{textAlign:r}:{},children:o.length>0?o:[{text:""}]}}function Jt(t,e=Tt){let n=t.childNodes;if(n.length===0)return ye();let o=[],r=[];function i(){if(r.length===0)return;let l=_n(r);o.push({type:lt,children:l.length>0?l:[{text:""}]}),r=[];}function s(l){for(let a of l)if(Ni(a))i(),o.push(Ki(a,e));else if(a.nodeType===In){let c=a.nodeValue??"",d=je(c);d.trim().length>0&&r.push({text:d});}else vt(a)&&(at(a,"br")?r.push({text:br}):Oi(a)?(i(),s(a.childNodes)):Zt(a,{},false,r,e));}return s(n),i(),o.length===0?ye():L(o)}function ji(t){return Object.entries(t).map(([e,n])=>`${Hi(e)}:${n}`).filter(([,e])=>!!e).join(";")}function Nn(t){return !t.color&&!t.backgroundColor&&!t.fontFamily&&!t.fontSize?"":ji(a$5({color:Ue(t.color),backgroundColor:Ue(t.backgroundColor),fontFamily:Ue(t.fontFamily),fontSize:Ue(t.fontSize)}))}function Tr(t){return "text"in t}function Ue(t){if(!(t===void 0||/[;{}]|url\(/i.test(t)))return t}function ct(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function be(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 On(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 vr(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=be(o.getAttribute("href")??"");return {isLinkClick:true,url:r===""?null:r}}function Ui(t){return t.text.includes(`
14
14
  `)?t.text.split(`
15
- `).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),t.fontFamily!==void 0&&(o.fontFamily=t.fontFamily),t.fontSize!==void 0&&(o.fontSize=t.fontSize)),o}):[t]}function Ui(t){let e=[[]],n=0;for(let o of t)if(Er(o)){let r=ji(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 ie(t){if(!t)return "";function e(n){if(Er(n)){if(n.text==="")return "";let r=ct(n.text);n.bold&&(r=`<b>${r}</b>`),n.italic&&(r=`<i>${r}</i>`),n.underline&&(r=`<u>${r}</u>`);let i=In(n);return i&&(r=`<span style="${ct(i)}">${r}</span>`),r}let o=n.children?.map(r=>ie(r)).join("");switch(n.type){case lt:{let r=Ui(n.children),i=Ve(n.textAlign),s=i?`<p style="text-align:${ct(i)}">`:"<p>";return r.map(l=>{let a=l.map(c=>ie(c)).join("");return `${s}${a}</p>`}).join("")}case X:return `<a href="${ct(ye(n.url))}">${o}</a>`;case ce:return `<span data-user-id="${ct(n.value)}">${ct(n.displayName)}</span>`;default:return o}}return Array.isArray(t)?t.map(n=>e(n)).join(""):e(t)}function Nn(t,e=vt){let n=new DOMParser().parseFromString(br.default.sanitize(t),"text/html");if(!n.body.querySelector("p, div")){let o=n.createElement("p");o.append(...n.body.childNodes),n.body.append(o);}return Zt(n.body,e)}var Vi=new Set(["(","[","{","<",'"',"'","`","\xAB"]),Wi=new Set([".",",","!","?",":",";",'"',"'","`","\xBB"]),qi=new Map([[")","("],["]","["],["}","{"]]);function vr(t,e){let n=0;for(let o of t)o===e&&n++;return n}function Jt(t){let e=0,n=t.length;for(;e<n&&Vi.has(t[e]);)e++;for(;n>e;){let s=t[n-1];if(Wi.has(s)){n--;continue}let l=qi.get(s);if(l!==void 0){let a=t.slice(e,n);if(vr(a,s)>vr(a,l)){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 $i(t){let e=[],n=/\S+/g,o;for(;(o=n.exec(t))!==null;){let r=Jt(o[0]);if(r){let i=o.index+r.start,s=o.index+r.end;e.push({start:i,end:s,text:t.slice(i,s),url:r.url});}}return e}function Rr(t){let e=t.trim();if(e===""||/\s/.test(e))return null;let n=Jt(e);return n&&n.start===0&&n.end===e.length?n.url:null}function Gi(t){let e=$i(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:X,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 On(t){let e=false,n=t.map(o=>{let r=false,i=[];for(let s of o.children){let l=g(s)?Gi(s):null;l?(i.push(...l),r=true):i.push(s);}return r?(e=true,{...o,children:i}):o});return e?n:t}function kr(t){return oe(t)?0:B(t)}function Mr(t){return t.children.reduce((e,n)=>e+B(n),0)}function Bn(t,e,n){return Math.min(Math.max(t,e),n)}function J(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 z(t){return J(t.anchor,t.focus)===0}function Fn(t){return J(t.anchor,t.focus)<=0?t:{anchor:t.focus,focus:t.anchor}}function de(t,e){let n=Bn(e.path[0],0,t.length-1),o=t[n].children,r=Bn(e.path[1],0,o.length-1),i=Bn(e.offset,0,kr(o[r]));return {path:[n,r],offset:i}}function we(t){return {path:[0,0],offset:0}}function Ae(t){let e=t.length-1,n=t[e].children,o=n.length-1;return {path:[e,o],offset:kr(n[o])}}function P(t,e){let n=Math.max(e,0);for(let o=0;o<t.length;o++){let r=t[o],i=Mr(r);if(n>i){n-=i+1;continue}let s=r.children;for(let l=0;l<s.length;l++){let a=s[l],c=B(a);if(oe(a)){if(n===0)return {path:[o,l],offset:0};if(n<c)return {path:[o,l+1],offset:0}}else if(n<=c)return {path:[o,l],offset:n};n-=c;}}return Ae(t)}function C(t,e){let[n,o]=e.path,r=0;for(let s=0;s<n;s++)r+=Mr(t[s])+1;let i=t[n].children;for(let s=0;s<o;s++)r+=B(i[s]);return r+e.offset}function We(t){let e={};for(let[n,o]of Object.entries(t))o!==null&&Object.assign(e,{[n]:o});return e}var dt=Object.freeze({bold:false,italic:false,underline:false}),Kn=["color","backgroundColor","fontFamily","fontSize"];function Ie(t,e,n,o,r){let i=n==="atomic";if(t<o.path[0]||t>r.path[0])return null;let s=0;if(t===o.path[0]){if(e<o.path[1])return null;e===o.path[1]&&(s=i?0:o.offset);}let l=i?1:n;if(t===r.path[0]){if(e>r.path[1])return null;e===r.path[1]&&(l=i?r.offset>0?1:0:r.offset);}return s>=l?null:{from:s,to:l}}function Hn(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 Sr(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[s,l]of i.entries())if(!re(l)){if(g(l)){let a=Ie(r,s,l.text.length,e,n);a&&o(l,a.from,a.to);}else if(R(l)){let a=Ie(r,s,B(l),e,n);a&&Hn(l,a,(c,d,u)=>{d<u&&o(c,d,u);});}}}}function Lr(t){return g(t)?t:R(t)?t.children.at(-1)??null:null}function Dr(t,e){let n=de(t,e),o=t[n.path[0]].children,r=o[n.path[1]],i=n.path[1]>0?Lr(o[n.path[1]-1]):null;if(g(r))return n.offset>0?r:i??r;if(R(r)){if(n.offset===0)return i??r.children[0]??null;let s=0;for(let l of r.children)if(s+=l.text.length,n.offset<=s)return l;return r.children.at(-1)??null}return Z(r)?n.offset>0?r.children[0]:i??r.children[0]:i}function Cr(t){let e={bold:!!t.bold,italic:!!t.italic,underline:!!t.underline};return t.color!==void 0&&(e.color=t.color),t.backgroundColor!==void 0&&(e.backgroundColor=t.backgroundColor),t.fontFamily!==void 0&&(e.fontFamily=t.fontFamily),t.fontSize!==void 0&&(e.fontSize=t.fontSize),e}function Yi(t,e){let n={};t.bold!==void 0&&t.bold===e.bold&&(n.bold=t.bold),t.italic!==void 0&&t.italic===e.italic&&(n.italic=t.italic),t.underline!==void 0&&t.underline===e.underline&&(n.underline=t.underline);for(let o of Kn){let r=t[o],i=e[o];if(r===void 0&&i===void 0)continue;let s=o==="color"||o==="backgroundColor"?b$a(r??void 0,i??void 0):r===i;n[o]=s&&r!=null?r:null;}return n}function be(t,e){if(z(e)){let s=Dr(t,e.focus);return s?Cr(s):{...dt}}let n=Fn(e),o=de(t,n.anchor),r=de(t,n.focus),i=null;return Sr(t,o,r,s=>{let l=Cr(s);i=i===null?l:Yi(i,l);}),i??{...dt}}function Qt(t,e,n){if(n===t)return {doc:t,range:e};let o=L(n);return {doc:o,range:{anchor:P(o,C(t,de(t,e.anchor))),focus:P(o,C(t,de(t,e.focus)))}}}function zr(t,e,n,o){let r={...t,text:t.text.slice(e,n)},i=o(r);if(Et(i,r))return null;let s=[];return e>0&&s.push({...t,text:t.text.slice(0,e)}),s.push(i),n<t.text.length&&s.push({...t,text:t.text.slice(n)}),s}function Xi(t,e,n){let o=false,r=[];return Hn(t,e,(i,s,l)=>{let a=s<l?zr(i,s,l,n):null;a?(r.push(...a),o=true):r.push(i);}),o?{...t,children:r}:null}function Pr(t,e,n,o){let r=false,i=t.map((s,l)=>{if(l<e.path[0]||l>n.path[0])return s;let a=false,c=[];for(let[d,u]of s.children.entries())if(g(u)){let f=Ie(l,d,u.text.length,e,n),p=f?zr(u,f.from,f.to,o):null;p?(c.push(...p),a=true):c.push(u);}else if(R(u)){let f=Ie(l,d,B(u),e,n),p=f?Xi(u,f,o):null;p?(c.push(p),a=true):c.push(u);}else c.push(u);return a?(r=true,{...s,children:c}):s});return r?i:t}function qe(t,e){let n=Fn(e);return [de(t,n.anchor),de(t,n.focus)]}function en(t,e,n){if(z(e))return {doc:t,range:e};let[o,r]=qe(t,e),i=false,s=true;return Sr(t,o,r,a=>{i=true,a[n]||(s=false);}),i?Qt(t,e,Pr(t,o,r,s?a=>{let c={...a};return delete c[n],c}:a=>a[n]?a:{...a,[n]:true})):{doc:t,range:e}}function tn(t,e,n,o){if(z(e))return {doc:t,range:e};let[r,i]=qe(t,e);return Qt(t,e,Pr(t,r,i,l=>{if(l[n]===o)return l;let a={...l};return o===void 0?delete a[n]:a[n]=o,a}))}function wr(t,e){let n=[],o=[],r=0;for(let i of t){let s=r+i.text.length;s<=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=s;}return [n,o]}function ue(t,e,n){if(e>=t.length)return [[...t],[]];let o=t.slice(0,e),r=t.slice(e+1),i=t[e];if(g(i))o.push({...i,text:i.text.slice(0,n)}),r.unshift({...i,text:i.text.slice(n)});else if(R(i)){let[s,l]=wr(i.children,n);o.push({...i,children:s}),r.unshift({...i,children:l});}else n===0?r.unshift(i):o.push(i);return [o,r]}function jn(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,s]of t[r].children.entries()){if(!R(s))continue;let l={path:[r,i],offset:0},a={path:[r,i],offset:B(s)};if(J(n,a)<=0&&J(o,l)>=0)return {paragraphIndex:r,inlineIndex:i,link:s}}return null}function Ar(t,e){let n=jn(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:B(i)}}}}function Ir(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,s]of t[r].children.entries()){if(g(s))continue;let l=re(s)?"atomic":B(s);if(Ie(r,i,l,n,o))return true}return false}function Zi(t,e,n,o){let r=[],i=(s,l,a)=>{l<a&&r.push({...s,text:s.text.slice(l,a)});};for(let[s,l]of t[e].children.entries())if(!re(l)){if(g(l)){let a=Ie(e,s,l.text.length,n,o);a&&i(l,a.from,a.to);}else if(R(l)){let a=Ie(e,s,B(l),n,o);a&&Hn(l,a,i);}}return r}function Un(t,e,n){if(z(e))return {doc:t,range:e};let[o,r]=qe(t,e);for(let l=o.path[0];l<=r.path[0]&&l<t.length;l++)for(let[a,c]of t[l].children.entries())if(re(c)&&Ie(l,a,"atomic",o,r))return {doc:t,range:e};let i=false,s=t.map((l,a)=>{if(a<o.path[0]||a>r.path[0])return l;let c=Zi(t,a,o,r);if(c.length===0)return l;let d=l.children,[u]=a===o.path[0]?ue(d,o.path[1],o.offset):[[]],f=a===r.path[0]?ue(d,r.path[1],r.offset)[1]:[];return i=true,{...l,children:[...u,{type:X,url:n,children:c},...f]}});return i?Qt(t,e,s):{doc:t,range:e}}function _r(t,e,n){let o=jn(t,e);if(!o||o.link.url===n)return {doc:t,range:e};let{paragraphIndex:r,inlineIndex:i,link:s}=o,l=t.map((a,c)=>c!==r?a:{...a,children:a.children.map((d,u)=>u===i?{...s,url:n}:d)});return {doc:L(l),range:e}}function Nr(t,e){let n=jn(t,e);if(!n)return {doc:t,range:e};let{paragraphIndex:o,inlineIndex:r,link:i}=n,s=t.map((l,a)=>a!==o?l:{...l,children:l.children.flatMap((c,d)=>d===r?i.children:[c])});return Qt(t,e,s)}function $e(t,e){if(z(e))return {doc:t,range:e};let[n,o]=qe(t,e);if(J(n,o)===0)return {doc:t,range:e};let r=C(t,n),i=ue(t[n.path[0]].children,n.path[1],n.offset)[0],s=ue(t[o.path[0]].children,o.path[1],o.offset)[1],l={...t[n.path[0]],children:[...i,...s]},a=L([...t.slice(0,n.path[0]),l,...t.slice(o.path[0]+1)]),c=P(a,r);return {doc:a,range:{anchor:c,focus:c}}}function Vn(t,e){if(z(e))return xe();let[n,o]=qe(t,e);if(J(n,o)===0)return xe();let r=t[n.path[0]],i=t[o.path[0]],s;if(r===i){let l=ue(r.children,o.path[1],o.offset)[0];s=[{...r,children:ue(l,n.path[1],n.offset)[1]}];}else s=[{...r,children:ue(r.children,n.path[1],n.offset)[1]},...t.slice(n.path[0]+1,o.path[0]),{...i,children:ue(i.children,o.path[1],o.offset)[0]}];return structuredClone(L(s.map(l=>({...l,children:l.children.map(a=>Z(a)?{text:a.children[0].text}:a)}))))}function Mt(t,e,n){let o=de(t,e);if(n==="")return {doc:t,range:{anchor:o,focus:o}};let r=Dr(t,o),i=r?{...r,text:n}:{text:n},s=o.path[0],l=t[s].children,a=l[o.path[1]],c;if(R(a)&&o.offset>0&&o.offset<B(a)){let[f,p]=wr(a.children,o.offset),h={...a,children:[...f,i,...p]};c=l.map((m,k)=>k===o.path[1]?h:m);}else {let[f,p]=ue(l,o.path[1],o.offset);c=[...f,i,...p];}let d=L(t.map((f,p)=>p===s?{...f,children:c}:f)),u=P(d,C(t,o)+n.length);return {doc:d,range:{anchor:u,focus:u}}}function Wn(t,e,n){let o=L(n),r=A(o),i=t,s;if(z(e))s=de(t,e.focus);else {let p=$e(t,e);i=p.doc,s=p.range.focus;}if(o.length===1&&r===0)return {doc:i,range:{anchor:s,focus:s}};let l=s.path[0],[a,c]=ue(i[l].children,s.path[1],s.offset),d=o.length===1?[{...i[l],children:[...a,...o[0].children,...c]}]:[{...i[l],children:[...a,...o[0].children]},...o.slice(1,-1),{...i[l],children:[...o.at(-1).children,...c]}],u=L([...i.slice(0,l),...d,...i.slice(l+1)]),f=P(u,C(i,s)+r);return {doc:u,range:{anchor:f,focus:f}}}function Or(t,e){if(z(e))return Mt(t,e.focus,`
16
- `);let n=$e(t,e);return Mt(n.doc,n.range.focus,`
17
- `)}function Br(t,e){return Wn(t,e,[{type:"p",children:[{text:""}]},{type:"p",children:[{text:""}]}])}function Fr(t,e){for(let[n,o]of t.entries()){let r=o.children.indexOf(e);if(r!==-1)return [n,r]}return null}function Kr(t){for(let[e,n]of t.entries())for(let[o,r]of n.children.entries())if(Z(r))return [e,o];return null}function Hr(t){let e=Ae(t);return {anchor:e,focus:e}}function jr(t,e){let n=t,o;if(z(e))o=de(t,e.focus);else {let u=$e(t,e);n=u.doc,o=u.range.focus;}let r={type:Ce,children:[{text:""}]},i=o.path[0],[s,l]=ue(n[i].children,o.path[1],o.offset),a=L(n.map((u,f)=>f===i?{...u,children:[...s,r,...l]}:u)),d={path:Fr(a,r)??[0,0],offset:0};return {doc:a,range:{anchor:d,focus:d}}}function Ur(t,e){let n=Kr(t);if(!n)return {doc:t,range:Hr(t)};let[o,r]=n,i={type:ce,value:e.id,displayName:e.displayName,children:[{text:""}]},s=L(t.map((d,u)=>u===o?{...d,children:d.children.map((f,p)=>p===r?i:f)}:d)),[l,a]=Fr(s,i)??[o,r],c={path:[l,a+1],offset:0};return {doc:s,range:{anchor:c,focus:c}}}function qn(t,e,n="end"){let o=Kr(t);if(!o)return {doc:t,range:Hr(t)};let[r,i]=o,s=t[r].children,l=i>0?Lr(s[i-1]):null,a=l?{...l,text:e}:{text:e},c=C(t,{path:[r,i],offset:0})+(n==="end"?e.length:0),d=L(t.map((f,p)=>p===r?{...f,children:s.map((h,m)=>m===i?a:h)}:f)),u=P(d,c);return {doc:d,range:{anchor:u,focus:u}}}function Ji(t){for(let e of t.children)if(re(e)||R(e)&&e.children.map(o=>o.text).join("").length>0||g(e)&&e.text.length>0)return false;return true}function $n(t,e){let n=t.createElement("br");return e==="break"?n.dataset.editorNode="break":n.dataset.editorFiller="true",n}function Vr(t,e,n,o){if(n.text==="")return;let r=n.text.split(`
18
- `);for(let i=0;i<r.length;i++){let s=r[i],l=i===r.length-1;if(s.length>0){let c=t.createTextNode(s);if(n.underline){let f=t.createElement("u");f.append(c),c=f;}if(n.italic){let f=t.createElement("i");f.append(c),c=f;}if(n.bold){let f=t.createElement("b");f.append(c),c=f;}let d=t.createElement("span");d.dataset.editorNode="text";let u=In(n);u&&d.setAttribute("style",u),d.append(c),e.append(d);}l?s===""&&r.length>1&&o&&e.append($n(t,"filler")):e.append($n(t,"break"));}}function Qi(t,e,n,o){if(g(n)){Vr(t,e,n,o);return}switch(n.type){case X:{let r=t.createElement("a");r.dataset.editorNode="link",r.setAttribute("href",ye(n.url)),r.className=a$u({size:"sm",variant:"inline"});for(let i of n.children)Vr(t,r,i,false);e.append(r);break}case ce:{let r=t.createElement("span");r.setAttribute("contenteditable","false"),r.dataset.userId=n.value,r.dataset.editorNode="mention",r.textContent=`@${n.displayName}`,e.append(r);break}case Ce:{let r=t.createElement("span");r.setAttribute("contenteditable","false"),r.dataset.mentionAnchor="true",r.dataset.editorNode="mention-input",r.textContent=n.children[0].text,e.append(r);break}}}function nn(t){return g(t)?t.text!=="":R(t)?t.children.some(e=>e.text!==""):true}function es(t,e){let n=t.createElement("p");n.dataset.editorNode="paragraph";let o=Ve(e.textAlign);if(o&&(n.style.textAlign=o),Ji(e)){let i=t.createElement("span");return i.dataset.editorNode="text",i.append($n(t,"filler")),n.append(i),n}let r=-1;for(let i=e.children.length-1;i>=0;i--)if(nn(e.children[i])){r=i;break}for(let[i,s]of e.children.entries())Qi(t,n,s,i===r);return n}function Ct(t,e){let n=e.ownerDocument,o=n.createDocumentFragment();for(let r of t)o.append(es(n,r));e.replaceChildren(o);}var ts=1,ns=3,os=11;function fe(t){return t.nodeType===ts}function qr(t){return t.nodeType===os&&"host"in t}function on(t){return t.nodeType===ns}function St(t,e){return t.tagName.toLowerCase()===e}function rs(t){return St(t,"span")?t.getAttribute("contenteditable")==="false":false}function is(t,e,n,o,r){if(o===t){let l=t.childNodes,a=Math.min(r,l.length);return a===0?{found:true,point:{path:[n,0],offset:0}}:ss(e,n,a)}let i=t.childNodes,s=0;for(let l=0;l<e.children.length;l++){let a=e.children[l];if(g(a)){let c=rn(e.children,l),d=Yr(a.text,i,s,n,l,o,r,c);if(d.found)return d;s+=Ye(a.text,c);}else if(R(a)){if(s>=i.length)continue;let c=i[s];if(!fe(c)||!St(c,"a")){s++;continue}let d=ls(a,c,n,l,o,r);if(d.found)return d;s++;}else if(oe(a)||Z(a)){if(s>=i.length)continue;let c=i[s];if(!fe(c)||!rs(c)){s++;continue}if(o===c||(fe(o)||on(o))&&h(c,o))return {found:true,point:{path:[n,l+1],offset:0}};s++;}}return {found:false}}function ss(t,e,n){let o=0;for(let s=0;s<t.children.length;s++){let l=t.children[s],a=g(l)?Ye(l.text,rn(t.children,s)):1;if(o+a>=n){if(g(l))return {found:true,point:{path:[e,s],offset:Gr(l.text,n-o)}};if(re(l))return {found:true,point:{path:[e,s+1],offset:0}};{let c=l.children.reduce((d,u)=>d+u.text.length,0);return {found:true,point:{path:[e,s],offset:c}}}}o+=a;}let r=t.children.length-1,i=t.children[r];if(g(i))return {found:true,point:{path:[e,r],offset:i.text.length}};if(re(i))return {found:true,point:{path:[e,r+1],offset:0}};if(R(i)){let s=i.children.reduce((l,a)=>l+a.text.length,0);return {found:true,point:{path:[e,r],offset:s}}}return {found:false}}function $r(t){return !t.children.some(e=>nn(e))}function rn(t,e){for(let n=e+1;n<t.length;n++)if(nn(t[n]))return false;return true}function Ye(t,e){if(t==="")return 0;let n=t.split(`
15
+ `).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),t.fontFamily!==void 0&&(o.fontFamily=t.fontFamily),t.fontSize!==void 0&&(o.fontSize=t.fontSize)),o}):[t]}function Vi(t){let e=[[]],n=0;for(let o of t)if(Tr(o)){let r=Ui(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 ie(t){if(!t)return "";function e(n){if(Tr(n)){if(n.text==="")return "";let r=ct(n.text);n.bold&&(r=`<b>${r}</b>`),n.italic&&(r=`<i>${r}</i>`),n.underline&&(r=`<u>${r}</u>`);let i=Nn(n);return i&&(r=`<span style="${ct(i)}">${r}</span>`),r}let o=n.children?.map(r=>ie(r)).join("");switch(n.type){case lt:{let r=Vi(n.children),i=Ue(n.textAlign),s=i?`<p style="text-align:${ct(i)}">`:"<p>";return r.map(l=>{let a=l.map(c=>ie(c)).join("");return `${s}${a}</p>`}).join("")}case X:return `<a href="${ct(be(n.url))}">${o}</a>`;case de:return `<span data-user-id="${ct(n.value)}">${ct(n.displayName)}</span>`;default:return o}}return Array.isArray(t)?t.map(n=>e(n)).join(""):e(t)}function Bn(t,e=Tt){let n=new DOMParser().parseFromString(Er.default.sanitize(t),"text/html");if(!n.body.querySelector("p, div")){let o=n.createElement("p");o.append(...n.body.childNodes),n.body.append(o);}return Jt(n.body,e)}var Wi=new Set(["(","[","{","<",'"',"'","`","\xAB"]),qi=new Set([".",",","!","?",":",";",'"',"'","`","\xBB"]),$i=new Map([[")","("],["]","["],["}","{"]]);function Rr(t,e){let n=0;for(let o of t)o===e&&n++;return n}function Qt(t){let e=0,n=t.length;for(;e<n&&Wi.has(t[e]);)e++;for(;n>e;){let s=t[n-1];if(qi.has(s)){n--;continue}let l=$i.get(s);if(l!==void 0){let a=t.slice(e,n);if(Rr(a,s)>Rr(a,l)){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 Gi(t){let e=[],n=/\S+/g,o;for(;(o=n.exec(t))!==null;){let r=Qt(o[0]);if(r){let i=o.index+r.start,s=o.index+r.end;e.push({start:i,end:s,text:t.slice(i,s),url:r.url});}}return e}function kr(t){let e=t.trim();if(e===""||/\s/.test(e))return null;let n=Qt(e);return n&&n.start===0&&n.end===e.length?n.url:null}function Yi(t){let e=Gi(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:X,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 Fn(t){let e=false,n=t.map(o=>{let r=false,i=[];for(let s of o.children){let l=g(s)?Yi(s):null;l?(i.push(...l),r=true):i.push(s);}return r?(e=true,{...o,children:i}):o});return e?n:t}function Mr(t){return oe(t)?0:B(t)}function Cr(t){return t.children.reduce((e,n)=>e+B(n),0)}function Kn(t,e,n){return Math.min(Math.max(t,e),n)}function J(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 z(t){return J(t.anchor,t.focus)===0}function Hn(t){return J(t.anchor,t.focus)<=0?t:{anchor:t.focus,focus:t.anchor}}function ue(t,e){let n=Kn(e.path[0],0,t.length-1),o=t[n].children,r=Kn(e.path[1],0,o.length-1),i=Kn(e.offset,0,Mr(o[r]));return {path:[n,r],offset:i}}function Ae(t){return {path:[0,0],offset:0}}function Ie(t){let e=t.length-1,n=t[e].children,o=n.length-1;return {path:[e,o],offset:Mr(n[o])}}function P(t,e){let n=Math.max(e,0);for(let o=0;o<t.length;o++){let r=t[o],i=Cr(r);if(n>i){n-=i+1;continue}let s=r.children;for(let l=0;l<s.length;l++){let a=s[l],c=B(a);if(oe(a)){if(n===0)return {path:[o,l],offset:0};if(n<c)return {path:[o,l+1],offset:0}}else if(n<=c)return {path:[o,l],offset:n};n-=c;}}return Ie(t)}function M(t,e){let[n,o]=e.path,r=0;for(let s=0;s<n;s++)r+=Cr(t[s])+1;let i=t[n].children;for(let s=0;s<o;s++)r+=B(i[s]);return r+e.offset}function Ve(t){let e={};for(let[n,o]of Object.entries(t))o!==null&&Object.assign(e,{[n]:o});return e}var dt=Object.freeze({bold:false,italic:false,underline:false}),jn=["color","backgroundColor","fontFamily","fontSize"];function _e(t,e,n,o,r){let i=n==="atomic";if(t<o.path[0]||t>r.path[0])return null;let s=0;if(t===o.path[0]){if(e<o.path[1])return null;e===o.path[1]&&(s=i?0:o.offset);}let l=i?1:n;if(t===r.path[0]){if(e>r.path[1])return null;e===r.path[1]&&(l=i?r.offset>0?1:0:r.offset);}return s>=l?null:{from:s,to:l}}function Un(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 Lr(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[s,l]of i.entries())if(!re(l)){if(g(l)){let a=_e(r,s,l.text.length,e,n);a&&o(l,a.from,a.to);}else if(v(l)){let a=_e(r,s,B(l),e,n);a&&Un(l,a,(c,d,u)=>{d<u&&o(c,d,u);});}}}}function Dr(t){return g(t)?t:v(t)?t.children.at(-1)??null:null}function zr(t,e){let n=ue(t,e),o=t[n.path[0]].children,r=o[n.path[1]],i=n.path[1]>0?Dr(o[n.path[1]-1]):null;if(g(r))return n.offset>0?r:i??r;if(v(r)){if(n.offset===0)return i??r.children[0]??null;let s=0;for(let l of r.children)if(s+=l.text.length,n.offset<=s)return l;return r.children.at(-1)??null}return Z(r)?n.offset>0?r.children[0]:i??r.children[0]:i}function Sr(t){let e={bold:!!t.bold,italic:!!t.italic,underline:!!t.underline};return t.color!==void 0&&(e.color=t.color),t.backgroundColor!==void 0&&(e.backgroundColor=t.backgroundColor),t.fontFamily!==void 0&&(e.fontFamily=t.fontFamily),t.fontSize!==void 0&&(e.fontSize=t.fontSize),e}function Xi(t,e){let n={};t.bold!==void 0&&t.bold===e.bold&&(n.bold=t.bold),t.italic!==void 0&&t.italic===e.italic&&(n.italic=t.italic),t.underline!==void 0&&t.underline===e.underline&&(n.underline=t.underline);for(let o of jn){let r=t[o],i=e[o];if(r===void 0&&i===void 0)continue;let s=o==="color"||o==="backgroundColor"?b$a(r??void 0,i??void 0):r===i;n[o]=s&&r!=null?r:null;}return n}function Ee(t,e){if(z(e)){let s=zr(t,e.focus);return s?Sr(s):{...dt}}let n=Hn(e),o=ue(t,n.anchor),r=ue(t,n.focus),i=null;return Lr(t,o,r,s=>{let l=Sr(s);i=i===null?l:Xi(i,l);}),i??{...dt}}function en(t,e,n){if(n===t)return {doc:t,range:e};let o=L(n);return {doc:o,range:{anchor:P(o,M(t,ue(t,e.anchor))),focus:P(o,M(t,ue(t,e.focus)))}}}function Pr(t,e,n,o){let r={...t,text:t.text.slice(e,n)},i=o(r);if(bt(i,r))return null;let s=[];return e>0&&s.push({...t,text:t.text.slice(0,e)}),s.push(i),n<t.text.length&&s.push({...t,text:t.text.slice(n)}),s}function Zi(t,e,n){let o=false,r=[];return Un(t,e,(i,s,l)=>{let a=s<l?Pr(i,s,l,n):null;a?(r.push(...a),o=true):r.push(i);}),o?{...t,children:r}:null}function wr(t,e,n,o){let r=false,i=t.map((s,l)=>{if(l<e.path[0]||l>n.path[0])return s;let a=false,c=[];for(let[d,u]of s.children.entries())if(g(u)){let f=_e(l,d,u.text.length,e,n),p=f?Pr(u,f.from,f.to,o):null;p?(c.push(...p),a=true):c.push(u);}else if(v(u)){let f=_e(l,d,B(u),e,n),p=f?Zi(u,f,o):null;p?(c.push(p),a=true):c.push(u);}else c.push(u);return a?(r=true,{...s,children:c}):s});return r?i:t}function We(t,e){let n=Hn(e);return [ue(t,n.anchor),ue(t,n.focus)]}function tn(t,e,n){if(z(e))return {doc:t,range:e};let[o,r]=We(t,e),i=false,s=true;return Lr(t,o,r,a=>{i=true,a[n]||(s=false);}),i?en(t,e,wr(t,o,r,s?a=>{let c={...a};return delete c[n],c}:a=>a[n]?a:{...a,[n]:true})):{doc:t,range:e}}function nn(t,e,n,o){if(z(e))return {doc:t,range:e};let[r,i]=We(t,e);return en(t,e,wr(t,r,i,l=>{if(l[n]===o)return l;let a={...l};return o===void 0?delete a[n]:a[n]=o,a}))}function Ar(t,e){let n=[],o=[],r=0;for(let i of t){let s=r+i.text.length;s<=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=s;}return [n,o]}function fe(t,e,n){if(e>=t.length)return [[...t],[]];let o=t.slice(0,e),r=t.slice(e+1),i=t[e];if(g(i))o.push({...i,text:i.text.slice(0,n)}),r.unshift({...i,text:i.text.slice(n)});else if(v(i)){let[s,l]=Ar(i.children,n);o.push({...i,children:s}),r.unshift({...i,children:l});}else n===0?r.unshift(i):o.push(i);return [o,r]}function Vn(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,s]of t[r].children.entries()){if(!v(s))continue;let l={path:[r,i],offset:0},a={path:[r,i],offset:B(s)};if(J(n,a)<=0&&J(o,l)>=0)return {paragraphIndex:r,inlineIndex:i,link:s}}return null}function Ir(t,e){let n=Vn(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:B(i)}}}}function _r(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,s]of t[r].children.entries()){if(g(s))continue;let l=re(s)?"atomic":B(s);if(_e(r,i,l,n,o))return true}return false}function Ji(t,e,n,o){let r=[],i=(s,l,a)=>{l<a&&r.push({...s,text:s.text.slice(l,a)});};for(let[s,l]of t[e].children.entries())if(!re(l)){if(g(l)){let a=_e(e,s,l.text.length,n,o);a&&i(l,a.from,a.to);}else if(v(l)){let a=_e(e,s,B(l),n,o);a&&Un(l,a,i);}}return r}function Wn(t,e,n){if(z(e))return {doc:t,range:e};let[o,r]=We(t,e);for(let l=o.path[0];l<=r.path[0]&&l<t.length;l++)for(let[a,c]of t[l].children.entries())if(re(c)&&_e(l,a,"atomic",o,r))return {doc:t,range:e};let i=false,s=t.map((l,a)=>{if(a<o.path[0]||a>r.path[0])return l;let c=Ji(t,a,o,r);if(c.length===0)return l;let d=l.children,[u]=a===o.path[0]?fe(d,o.path[1],o.offset):[[]],f=a===r.path[0]?fe(d,r.path[1],r.offset)[1]:[];return i=true,{...l,children:[...u,{type:X,url:n,children:c},...f]}});return i?en(t,e,s):{doc:t,range:e}}function Nr(t,e,n){let o=Vn(t,e);if(!o||o.link.url===n)return {doc:t,range:e};let{paragraphIndex:r,inlineIndex:i,link:s}=o,l=t.map((a,c)=>c!==r?a:{...a,children:a.children.map((d,u)=>u===i?{...s,url:n}:d)});return {doc:L(l),range:e}}function Or(t,e){let n=Vn(t,e);if(!n)return {doc:t,range:e};let{paragraphIndex:o,inlineIndex:r,link:i}=n,s=t.map((l,a)=>a!==o?l:{...l,children:l.children.flatMap((c,d)=>d===r?i.children:[c])});return en(t,e,s)}function qe(t,e){if(z(e))return {doc:t,range:e};let[n,o]=We(t,e);if(J(n,o)===0)return {doc:t,range:e};let r=M(t,n),i=fe(t[n.path[0]].children,n.path[1],n.offset)[0],s=fe(t[o.path[0]].children,o.path[1],o.offset)[1],l={...t[n.path[0]],children:[...i,...s]},a=L([...t.slice(0,n.path[0]),l,...t.slice(o.path[0]+1)]),c=P(a,r);return {doc:a,range:{anchor:c,focus:c}}}function qn(t,e){if(z(e))return ye();let[n,o]=We(t,e);if(J(n,o)===0)return ye();let r=t[n.path[0]],i=t[o.path[0]],s;if(r===i){let l=fe(r.children,o.path[1],o.offset)[0];s=[{...r,children:fe(l,n.path[1],n.offset)[1]}];}else s=[{...r,children:fe(r.children,n.path[1],n.offset)[1]},...t.slice(n.path[0]+1,o.path[0]),{...i,children:fe(i.children,o.path[1],o.offset)[0]}];return structuredClone(L(s.map(l=>({...l,children:l.children.map(a=>Z(a)?{text:a.children[0].text}:a)}))))}function kt(t,e,n){let o=ue(t,e);if(n==="")return {doc:t,range:{anchor:o,focus:o}};let r=zr(t,o),i=r?{...r,text:n}:{text:n},s=o.path[0],l=t[s].children,a=l[o.path[1]],c;if(v(a)&&o.offset>0&&o.offset<B(a)){let[f,p]=Ar(a.children,o.offset),h={...a,children:[...f,i,...p]};c=l.map((m,R)=>R===o.path[1]?h:m);}else {let[f,p]=fe(l,o.path[1],o.offset);c=[...f,i,...p];}let d=L(t.map((f,p)=>p===s?{...f,children:c}:f)),u=P(d,M(t,o)+n.length);return {doc:d,range:{anchor:u,focus:u}}}function $n(t,e,n){let o=L(n),r=A(o),i=t,s;if(z(e))s=ue(t,e.focus);else {let p=qe(t,e);i=p.doc,s=p.range.focus;}if(o.length===1&&r===0)return {doc:i,range:{anchor:s,focus:s}};let l=s.path[0],[a,c]=fe(i[l].children,s.path[1],s.offset),d=o.length===1?[{...i[l],children:[...a,...o[0].children,...c]}]:[{...i[l],children:[...a,...o[0].children]},...o.slice(1,-1),{...i[l],children:[...o.at(-1).children,...c]}],u=L([...i.slice(0,l),...d,...i.slice(l+1)]),f=P(u,M(i,s)+r);return {doc:u,range:{anchor:f,focus:f}}}function Br(t,e){if(z(e))return kt(t,e.focus,`
16
+ `);let n=qe(t,e);return kt(n.doc,n.range.focus,`
17
+ `)}function Fr(t,e){return $n(t,e,[{type:"p",children:[{text:""}]},{type:"p",children:[{text:""}]}])}function Kr(t,e){for(let[n,o]of t.entries()){let r=o.children.indexOf(e);if(r!==-1)return [n,r]}return null}function Hr(t){for(let[e,n]of t.entries())for(let[o,r]of n.children.entries())if(Z(r))return [e,o];return null}function jr(t){let e=Ie(t);return {anchor:e,focus:e}}function Ur(t,e){let n=t,o;if(z(e))o=ue(t,e.focus);else {let u=qe(t,e);n=u.doc,o=u.range.focus;}let r={type:Se,children:[{text:""}]},i=o.path[0],[s,l]=fe(n[i].children,o.path[1],o.offset),a=L(n.map((u,f)=>f===i?{...u,children:[...s,r,...l]}:u)),d={path:Kr(a,r)??[0,0],offset:0};return {doc:a,range:{anchor:d,focus:d}}}function Vr(t,e){let n=Hr(t);if(!n)return {doc:t,range:jr(t)};let[o,r]=n,i={type:de,value:e.id,displayName:e.displayName,children:[{text:""}]},s=L(t.map((d,u)=>u===o?{...d,children:d.children.map((f,p)=>p===r?i:f)}:d)),[l,a]=Kr(s,i)??[o,r],c={path:[l,a+1],offset:0};return {doc:s,range:{anchor:c,focus:c}}}function Gn(t,e,n="end"){let o=Hr(t);if(!o)return {doc:t,range:jr(t)};let[r,i]=o,s=t[r].children,l=i>0?Dr(s[i-1]):null,a=l?{...l,text:e}:{text:e},c=M(t,{path:[r,i],offset:0})+(n==="end"?e.length:0),d=L(t.map((f,p)=>p===r?{...f,children:s.map((h,m)=>m===i?a:h)}:f)),u=P(d,c);return {doc:d,range:{anchor:u,focus:u}}}function Qi(t){for(let e of t.children)if(re(e)||v(e)&&e.children.map(o=>o.text).join("").length>0||g(e)&&e.text.length>0)return false;return true}function Yn(t,e){let n=t.createElement("br");return e==="break"?n.dataset.editorNode="break":n.dataset.editorFiller="true",n}function Wr(t,e,n,o){if(n.text==="")return;let r=n.text.split(`
18
+ `);for(let i=0;i<r.length;i++){let s=r[i],l=i===r.length-1;if(s.length>0){let c=t.createTextNode(s);if(n.underline){let f=t.createElement("u");f.append(c),c=f;}if(n.italic){let f=t.createElement("i");f.append(c),c=f;}if(n.bold){let f=t.createElement("b");f.append(c),c=f;}let d=t.createElement("span");d.dataset.editorNode="text";let u=Nn(n);u&&d.setAttribute("style",u),d.append(c),e.append(d);}l?s===""&&r.length>1&&o&&e.append(Yn(t,"filler")):e.append(Yn(t,"break"));}}function es(t,e,n,o){if(g(n)){Wr(t,e,n,o);return}switch(n.type){case X:{let r=t.createElement("a");r.dataset.editorNode="link",r.setAttribute("href",be(n.url)),r.className=a$u({size:"sm",variant:"inline"});for(let i of n.children)Wr(t,r,i,false);e.append(r);break}case de:{let r=t.createElement("span");r.setAttribute("contenteditable","false"),r.dataset.userId=n.value,r.dataset.editorNode="mention",r.textContent=`@${n.displayName}`,e.append(r);break}case Se:{let r=t.createElement("span");r.setAttribute("contenteditable","false"),r.dataset.mentionAnchor="true",r.dataset.editorNode="mention-input",r.textContent=n.children[0].text,e.append(r);break}}}function on(t){return g(t)?t.text!=="":v(t)?t.children.some(e=>e.text!==""):true}function ts(t,e){let n=t.createElement("p");n.dataset.editorNode="paragraph";let o=Ue(e.textAlign);if(o&&(n.style.textAlign=o),Qi(e)){let i=t.createElement("span");return i.dataset.editorNode="text",i.append(Yn(t,"filler")),n.append(i),n}let r=-1;for(let i=e.children.length-1;i>=0;i--)if(on(e.children[i])){r=i;break}for(let[i,s]of e.children.entries())es(t,n,s,i===r);return n}function Mt(t,e){let n=e.ownerDocument,o=n.createDocumentFragment();for(let r of t)o.append(ts(n,r));e.replaceChildren(o);}var ns=1,os=3,rs=11;function pe(t){return t.nodeType===ns}function $r(t){return t.nodeType===rs&&"host"in t}function rn(t){return t.nodeType===os}function Ct(t,e){return t.tagName.toLowerCase()===e}function is(t){return Ct(t,"span")?t.getAttribute("contenteditable")==="false":false}function ss(t,e,n,o,r){if(o===t){let l=t.childNodes,a=Math.min(r,l.length);return a===0?{found:true,point:{path:[n,0],offset:0}}:ls(e,n,a)}let i=t.childNodes,s=0;for(let l=0;l<e.children.length;l++){let a=e.children[l];if(g(a)){let c=sn(e.children,l),d=Xr(a.text,i,s,n,l,o,r,c);if(d.found)return d;s+=Ge(a.text,c);}else if(v(a)){if(s>=i.length)continue;let c=i[s];if(!pe(c)||!Ct(c,"a")){s++;continue}let d=as(a,c,n,l,o,r);if(d.found)return d;s++;}else if(oe(a)||Z(a)){if(s>=i.length)continue;let c=i[s];if(!pe(c)||!is(c)){s++;continue}if(o===c||(pe(o)||rn(o))&&h(c,o))return {found:true,point:{path:[n,l+1],offset:0}};s++;}}return {found:false}}function ls(t,e,n){let o=0;for(let s=0;s<t.children.length;s++){let l=t.children[s],a=g(l)?Ge(l.text,sn(t.children,s)):1;if(o+a>=n){if(g(l))return {found:true,point:{path:[e,s],offset:Yr(l.text,n-o)}};if(re(l))return {found:true,point:{path:[e,s+1],offset:0}};{let c=l.children.reduce((d,u)=>d+u.text.length,0);return {found:true,point:{path:[e,s],offset:c}}}}o+=a;}let r=t.children.length-1,i=t.children[r];if(g(i))return {found:true,point:{path:[e,r],offset:i.text.length}};if(re(i))return {found:true,point:{path:[e,r+1],offset:0}};if(v(i)){let s=i.children.reduce((l,a)=>l+a.text.length,0);return {found:true,point:{path:[e,r],offset:s}}}return {found:false}}function Gr(t){return !t.children.some(e=>on(e))}function sn(t,e){for(let n=e+1;n<t.length;n++)if(on(t[n]))return false;return true}function Ge(t,e){if(t==="")return 0;let n=t.split(`
19
19
  `),o=0;for(let r=0;r<n.length;r++)n[r].length>0&&o++,r<n.length-1&&o++;return e&&t.endsWith(`
20
- `)&&o++,o}function Gr(t,e){if(t==="")return 0;let n=t.split(`
20
+ `)&&o++,o}function Yr(t,e){if(t==="")return 0;let n=t.split(`
21
21
  `),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(`
22
- `)&&o<e&&(r=t.length),Math.min(r,t.length)}function Yr(t,e,n,o,r,i,s,l=false){if(t==="")return {found:false};let a=t.split(`
23
- `),c=n,d=0;for(let u=0;u<a.length;u++){let f=a[u],p=u===a.length-1;if(f.length>0&&c<e.length){let h$1=e[c],m=sn(h$1);if(m!==null){if(i===m){let k=Math.min(s,f.length);return {found:true,point:{path:[o,r],offset:d+k}}}if(fe(i)&&h(i,m))return {found:true,point:{path:[o,r],offset:d+(s===0?0:f.length)}}}d+=f.length,c++;}if(p){if(p&&l&&t.endsWith(`
24
- `)&&f===""&&c<e.length){let h=e[c];if(fe(h)&&St(h,"br")&&i===h)return {found:true,point:{path:[o,r],offset:d}};c++;}}else if(c<e.length){let h=e[c];if(fe(h)&&St(h,"br")&&i===h)return {found:true,point:{path:[o,r],offset:d+(s===0?0:1)}};d++,c++;}}return {found:false}}function ls(t,e,n,o,r,i){if(!fe(e))return {found:false};if(r===e){let c=e.childNodes,d=Math.min(i,c.length),u=0,f=0,p=0;for(let h of t.children){let m=Ye(h.text,false);if(p+m>=d){f=u+Gr(h.text,d-p);break}u+=h.text.length,p+=m;}return p>=t.children.reduce((h,m)=>h+Ye(m.text,false),0)&&(f=t.children.reduce((h,m)=>h+m.text.length,0)),{found:true,point:{path:[n,o],offset:f}}}if(!h(e,r))return {found:false};let s=e.childNodes,l=0,a=0;for(let c of t.children){let d=Yr(c.text,s,a,n,o,r,i);if(d.found)return {found:true,point:{path:[n,o],offset:l+d.point.offset}};l+=c.text.length,a+=Ye(c.text,false);}return {found:false}}function sn(t){if(on(t))return t;if(fe(t)){let e=t;for(;fe(e)&&e.childNodes.length===1;){let n=e.childNodes[0];if(on(n))return n;if(fe(n))e=n;else break}}return null}function Ge(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 s=Math.min(i,e.length)-1,l=e[s];if(!l)return null;let a=l.children.length-1,c=l.children[a];if(!c)return null;let d=g(c)?c.text.length:R(c)?c.children.reduce((u,f)=>u+f.text.length,0):0;return {path:[s,a],offset:d}}let r=t.children;for(let i=0;i<e.length;i++){let s=r[i];if(!s)return null;let l=e[i];if(n!==s&&!h(s,n))continue;if($r(l))return {path:[i,0],offset:0};let a=is(s,l,i,n,o);return a.found?a.point:null}return null}catch{return null}}function Wr(t,e,n){try{let[o,r]=n.path,i=n.offset;if(o<0||o>=e.length)return null;let s=e[o];if(r<0||r>=s.children.length)return null;let l=s.children[r],a=t.children[o];if(!a)return null;if($r(s))return {node:a.firstChild??a,offset:0};let c=a.childNodes,d=0;for(let u=0;u<r;u++){let f=s.children[u];g(f)?d+=Ye(f.text,rn(s.children,u)):d++;}if(g(l))return Xr(l.text,i,c,d,a,rn(s.children,r));if(R(l)){if(d>=c.length)return null;let u=c[d];return !fe(u)||!St(u,"a")?null:as(l,i,u)}else if(oe(l)||Z(l)){let u=d+1;if(u<c.length){let f=c[u];if(on(f))return {node:f,offset:0}}return {node:a,offset:Math.min(u,a.childNodes.length)}}return null}catch{return null}}function Xr(t,e,n,o,r,i=false){if(t==="")return {node:r,offset:o};let s=t.split(`
25
- `),l=o,a=0;for(let c=0;c<s.length;c++){let d=s[c],u=c===s.length-1;if(d.length>0&&l<n.length){let f=n[l];if(e>=a&&e<=a+d.length){let p=sn(f);return p!==null?{node:p,offset:e-a}:{node:r,offset:l}}a+=d.length,l++;}if(u){if(u&&t.endsWith(`
26
- `)&&d===""&&l<=n.length){if(e===a)return {node:r,offset:Math.min(l,r.childNodes.length)};i&&l++;}}else if(l<n.length){if(e===a)return {node:r,offset:l};a++,l++;}}if(l>o&&l-1<n.length){let c=n[l-1],d=sn(c);return d!==null?{node:d,offset:d.length}:{node:r,offset:l}}return {node:r,offset:Math.min(l,r.childNodes.length)}}function as(t,e,n){let o=n.childNodes,r=0,i=0;for(let s of t.children){let l=s.text.length;if(e<=r+l)return Xr(s.text,e-r,o,i,n);r+=l,i+=Ye(s.text,false);}if(o.length>0){let s=n.lastChild,l=s===null?null:sn(s);return l!==null?{node:l,offset:l.length}:{node:n,offset:o.length}}return {node:n,offset:0}}function cs(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 Gn(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(qr(r)){let i=cs(e,r);if(i&&h(t,i.startContainer))return i}return o}function ut(t,e){try{let n=a$r(t);if(!n)return null;let{anchorNode:o,focusNode:r}=n;if(o&&r&&h(t,o)&&h(t,r)){let a=Ge(t,e,o,n.anchorOffset),c=Ge(t,e,r,n.focusOffset);if(a!==null&&c!==null)return {anchor:a,focus:c}}let i=Gn(t,n);if(!i)return null;let s=Ge(t,e,i.startContainer,i.startOffset);if(s===null)return null;let l=Ge(t,e,i.endContainer,i.endOffset);return l===null?null:{anchor:s,focus:l}}catch{return null}}function ft(t,e,n){try{let o=Wr(t,e,n.anchor);if(o===null)return;let r=Wr(t,e,n.focus);if(r===null)return;let i=t.ownerDocument;if(!i)return;let s=a$r(t);if(!s)return;if(J(n.anchor,n.focus)>0||qr(t.getRootNode())){s.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),s.removeAllRanges(),s.addRange(a);}catch{}}var an=class{constructor(e,n){this.getEl=e;this.getDoc=n;}getEl;getDoc;remembered=null;lastEmitted=null;writeDeferred=null;focusFromPointer=false;get range(){return this.remembered}set(e,n){if(this.remembered=e,!e||n==="remember")return false;if(n==="place"&&!this.hasFocus())return this.writeDeferred="render",false;let o=this.getEl();return o?(ft(o,this.getDoc(),e),true):false}markEmitted(){this.lastEmitted=this.remembered;}hasFocus(){let e=this.getEl();return e?h(e,f$2(e)):false}select(e,n){let o=this.getEl();if(!o)return false;let r=!this.remembered||!ln(this.remembered,e);return this.remembered=e,r&&(this.lastEmitted=e),this.writeDeferred="select",!n&&!this.hasFocus()||(o.focus(),this.writeDeferred=null,ft(o,this.getDoc(),e)),r}collapseToFocus(){if(!this.getEl())return false;let e=this.current();return !e||z(e)?false:this.select({anchor:e.focus,focus:e.focus},true)}onPointerDown(){this.writeDeferred=null,this.focusFromPointer=!this.hasFocus();}onFocus(){let e=this.focusFromPointer,n=this.writeDeferred;this.focusFromPointer=false,this.writeDeferred=null;let o=this.getEl();if(e||!o||!this.remembered)return;let r=this.getDoc(),i=n===null?ut(o,r):null;if(i&&!ds(r,i)){this.remembered=i;return}ft(o,r,this.remembered);}current(){let e=this.getEl();if(!e)return this.remembered;let n=ut(e,this.getDoc());return n&&this.adoptsLiveSelection(n)&&(this.remembered=n),this.remembered}adoptsLiveSelection(e){return this.writeDeferred===null?true:this.writeDeferred==="select"||z(e)?false:(this.writeDeferred=null,true)}adopt(e){let n=this.remembered;return this.remembered=e,!n||!ln(n,e)}follow(e){if(e&&!this.adoptsLiveSelection(e))return "ignored";if(e===null)return "silent";let n=this.remembered;return this.remembered=e,!n||!ln(n,e)||!this.lastEmitted||!ln(this.lastEmitted,e)?"changed":"silent"}};function ds(t,e){let n=we();return J(e.anchor,n)===0&&J(e.focus,n)===0}function ln(t,e){return t.anchor.path[0]===e.anchor.path[0]&&t.anchor.path[1]===e.anchor.path[1]&&t.anchor.offset===e.anchor.offset&&t.focus.path[0]===e.focus.path[0]&&t.focus.path[1]===e.focus.path[1]&&t.focus.offset===e.focus.offset}var Zr="typing";var cn=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===Zr&&this.lastKind===Zr&&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 dn=10,un=class{pending=null;preserveSelectionChanges=0;get marks(){return this.pending?.marks}get caretOffset(){return this.pending?.caretOffset}merge(e){return this.pending?.marks??e}clear(){this.pending=null;}toggle(e,n,o){let r=this.effectiveMarks(e,n);r[o]=!r[o],this.pending={marks:r,caretOffset:C(e,n.anchor)};}setValue(e,n,o,r){let i=this.effectiveMarks(e,n);r===void 0?delete i[o]:i[o]=r,this.pending={marks:i,caretOffset:C(e,n.anchor)};}effectiveMarks(e,n){return this.pending?{...this.pending.marks}:We(be(e,n))}afterCommand(e,n,o,r){let i=this.pending?.marks;if(this.pending=null,e==="insertText"&&i){let s=Math.min(C(n,o.anchor),C(n,o.focus)),l=C(r.doc,r.range.focus),a=this.applyMarkSnapshot(r.doc,i,s,l),c=P(a,l);r={doc:a,range:{anchor:c,focus:c}};}return (e==="insertSoftBreak"||e==="insertParagraph")&&this.carryAcrossBreak(n,o,i,r),this.keepOfEmptiedDoc(n,r.doc),r}afterInput(e,n,o,r){this.keepOfEmptiedDoc(e,o),this.inheritOfEmptyRun(e,n);let i=o,s=r,l=false;if(!this.pending)return {doc:i,range:s,remarked:l};if(!r)return this.pending=null,{doc:i,range:s,remarked:l};let a=this.applyToTypedText(o,r,this.pending);return a.doc!==o&&(i=a.doc,s=a.range,l=true),this.pending={marks:this.pending.marks,caretOffset:C(i,a.range.anchor)},this.preserveSelectionChanges=dn,{doc:i,range:s,remarked:l}}onSelectionChange(e,n){this.preserveSelectionChanges>0?(this.preserveSelectionChanges-=1,this.pending&&n&&(this.pending={...this.pending,caretOffset:C(e,n.anchor)})):this.pending&&n&&C(e,n.anchor)!==this.pending.caretOffset&&(this.pending=null);}onGenuineCaretMove(){this.preserveSelectionChanges=0;}keepOfEmptiedDoc(e,n){A(e)===0||A(n)!==0||(this.pending={marks:this.pending?.marks??We(be(e,{anchor:we(),focus:P(e,1)})),caretOffset:0},this.preserveSelectionChanges=dn);}inheritOfEmptyRun(e,n){if(this.pending)return;let o;if(A(e)===0)o=we();else if(n&&z(n)&&A([e[n.anchor.path[0]]])===0)o=n.anchor;else return;let r=We(be(e,{anchor:o,focus:o}));Object.values(r).some(Boolean)&&(this.pending={marks:r,caretOffset:C(e,o)},this.preserveSelectionChanges=dn);}carryAcrossBreak(e,n,o,r){let i=o?{...o}:We(be(e,n));!o&&!Object.values(i).some(Boolean)||(this.pending={marks:i,caretOffset:C(r.doc,r.range.anchor)},this.preserveSelectionChanges=dn);}applyToTypedText(e,n,o){let r=o.caretOffset,i=C(e,n.anchor);if(i<=r)return {doc:e,range:n};let s=this.applyMarkSnapshot(e,o.marks,r,i),l=P(s,i);return {doc:s,range:{anchor:l,focus:l}}}applyMarkSnapshot(e,n,o,r){let i=e,s=()=>({anchor:P(i,o),focus:P(i,r)});for(let l of ["bold","italic","underline"]){let a=s(),c=!!n[l],d=!!be(i,a)[l];c!==d&&(i=en(i,a,l).doc);}for(let l of Kn){let a=s(),c=n[l],d=be(i,a)[l];d!==null&&(l==="color"||l==="backgroundColor"?b$a(c,d):c===d)||(i=tn(i,a,l,c).doc);}return i}};function Qr(t){return g(t)?[t]:R(t)||Z(t)?t.children:[]}function Jr(t){return t.some(e=>!!e.textAlign||e.children.some(n=>Qr(n).some(o=>!!o.fontFamily||!!o.fontSize)))}function ei(t,e,n){if(!Jr(t)&&!Jr(e))return t;let o=n.createElement("span"),r=(u,f)=>(o.style.removeProperty(Ki(u)),o.style[u]=f,o.style[u]),i={fontFamily:new Map,fontSize:new Map,textAlign:new Map},s=(u,f)=>{if(!f)return;let p=r(u,f);i[u].has(p)||i[u].set(p,f);};for(let u of e){s("textAlign",u.textAlign);for(let f of u.children)for(let p of Qr(f))s("fontFamily",p.fontFamily),s("fontSize",p.fontSize);}let l=(u,f)=>f===void 0?void 0:i[u].get(r(u,f))??f,a=u=>{let f={...u};for(let p of ["fontFamily","fontSize"]){let h=l(p,u[p]);h!==void 0&&(f[p]=h);}return f.fontFamily===u.fontFamily&&f.fontSize===u.fontSize?u:f},c=false,d=t.map(u=>{let f=l("textAlign",u.textAlign),p=u.children.map(h=>{if(g(h))return a(h);if(R(h)||Z(h)){let m=h.children.map(k=>a(k));return m.some((k,I)=>k!==h.children[I])?{...h,children:m}:h}return h});return f===u.textAlign&&p.every((h,m)=>h===u.children[m])?u:(c=true,{...u,...f===void 0?{}:{textAlign:f},children:p})});return c?d:t}var fs=1,ps=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function hs(t){return (t.key==="ArrowLeft"||t.key==="ArrowRight")&&!t.shiftKey&&(t.ctrlKey||t.altKey||t.metaKey)}function Yn(t){if(t!==void 0&&!(Number.isInteger(t)&&t>=0))throw new Error(`Editor: maxLength must be a finite integer >= 0, received ${String(t)}.`)}var Lt=class t{doc=xe();lastKnownHtml="";lastAppliedValue=null;lastAppliedDoc=null;selection;composing=false;enterHasShift=false;pendingMarks=new un;history=new cn;opts;el=null;pendingExternalRender=null;keyboardShortcutsOverride=void 0;constructor(e={}){this.opts=e,this.selection=new an(()=>this.el,()=>this.doc),this.lastKnownHtml=ie(this.doc);}setKeyboardShortcutsEnabled(e){this.keyboardShortcutsOverride=e;}attach(e){this.maxLength(),this.el=e,Ct(this.doc,e),this.selection.set(this.selection.range,"write");let n=this.handleBeforeInputBound,o=this.handleInputBound,r=this.handlePasteBound,i=this.handleCopyBound,s=this.handleCompositionStartBound,l=this.handleCompositionEndBound,a=this.handleSelectionChangeBound,c=this.handlePointerDownBound,d=this.handleFocusBound,u=this.handleKeyDownBound,f=this.handleDocumentKeyDownBound,p=e.ownerDocument;return e.addEventListener("beforeinput",n),e.addEventListener("input",o),e.addEventListener("paste",r),e.addEventListener("copy",i),e.addEventListener("cut",i),e.addEventListener("compositionstart",s),e.addEventListener("compositionend",l),e.addEventListener("pointerdown",c),e.addEventListener("focus",d),e.addEventListener("keydown",u),p.addEventListener("selectionchange",a),p.addEventListener("keydown",f),()=>{e.removeEventListener("beforeinput",n),e.removeEventListener("input",o),e.removeEventListener("paste",r),e.removeEventListener("copy",i),e.removeEventListener("cut",i),e.removeEventListener("compositionstart",s),e.removeEventListener("compositionend",l),e.removeEventListener("pointerdown",c),e.removeEventListener("focus",d),e.removeEventListener("keydown",u),p.removeEventListener("selectionchange",a),p.removeEventListener("keydown",f),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.selection.current(),this.handleBeforeInput(n);}};handleInputBound=e=>{j$2(e)===this.el&&(this.composing||this.syncFromDom());};isClipboardTargetInEditor(e,n=false){let o=j$2(e);return !o||!h(this.el,o)?false:!(o.nodeType===fs?o:o.parentElement)?.closest(n?"input":'input, [contenteditable="false"]')}handlePasteBound=e=>{let n=e;if(!this.isClipboardTargetInEditor(n)||(n.preventDefault(),this.opts.isReadOnly?.())||this.composing)return;this.selection.current();let o;try{o=this.opts.onPaste?.(n),o&&(o=L(o));}catch(r){o=null,queueMicrotask(()=>{throw r});}if(o!==null){if(o!==void 0){this.exec("insertFragment",o);return}this.insertPastedData(n.clipboardData);}};handleCopyBound=e=>{let n=e;if(!this.opts.onCopy||!this.isClipboardTargetInEditor(n,true))return;let o=this.selection.current(),r=o!==null&&!z(o),i=this.doc,s=r?Vn(i,o):xe();this.opts.onCopy(n,s)&&(n.preventDefault(),r&&n.type==="cut"&&!this.opts.isReadOnly?.()&&this.doc===i&&(this.select(o),this.exec("deleteRange")));};handleKeyDownBound=e=>{this.enterHasShift=e.key==="Enter"&&e.shiftKey,ps.has(e.key)&&this.pendingMarks.onGenuineCaretMove();};handleDocumentKeyDownBound=e=>{e.defaultPrevented||!this.el||!e.composedPath().includes(this.el)||!hs(e)||this.selection.collapseToFocus()&&this.emitSelectionChange();};handlePointerDownBound=()=>{this.pendingMarks.onGenuineCaretMove(),this.selection.onPointerDown();};handleFocusBound=()=>{this.selection.onFocus();};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();};getDoc(e){return e?Vn(this.doc,e):this.doc}getValue(){return ie(this.doc)}setValue(e,n={}){if(e===this.lastKnownHtml||e===this.lastAppliedValue)return;let o,r;try{o=L(Nn(e,this.allowedStyles())),r=ie(o);}catch(i){process.env.NODE_ENV!=="production"&&console.error("[Editor] setValue failed to parse value:",i);return}this.lastAppliedValue=e,this.lastAppliedDoc=null,this.replaceDoc(o,r,n);}setDoc(e,n={}){if(e===this.doc||e===this.lastAppliedDoc)return;let o=L(e);this.lastAppliedDoc=e,!fr(o,this.doc)&&(this.lastAppliedValue=null,this.replaceDoc(o,ie(o),n));}replaceDoc(e,n,o){let r=this.selection.range?C(this.doc,this.selection.range.anchor):null,i=null;if(r!==null){let s=P(e,Math.min(r,A(e)));i={anchor:s,focus:s};}this.history.clear(),this.commit(e,i,{type:"external",html:n,emit:!!o.emit});}static docHasMentionInput(e){return e.some(n=>n.children.some(o=>Z(o)))}exec(e,...n){let o=this.selection.current(),r=this.doc,i=o??this.collapsedAtDocEnd(),s={doc:r,range:o},l;try{let a=this.fitToCapacity(e,n,i);if(a===null)return;l=this.dispatchCommand(e,a);}catch(a){process.env.NODE_ENV!=="production"&&console.error(`[Editor] command "${e}" threw:`,a);return}if(e==="confirmMention"){let a=this.maxLength();a!==void 0&&A(l.doc)>Math.max(a,A(r))&&(l=qn(r,""));}if(l.doc===r){if(e==="toggleMark"&&z(i)){let[a]=n;this.pendingMarks.toggle(this.doc,i,a),this.emitSelectionChange();return}if(e==="setMarkValue"&&z(i)){let[a,c]=n;this.pendingMarks.setValue(this.doc,i,a,c),this.emitSelectionChange();return}this.pendingMarks.clear();return}l=this.pendingMarks.afterCommand(e,r,i,l),this.history.record(s,e),this.commit(l.doc,l.range,{type:"command"});}fitToCapacity(e,n,o){let r=this.capacity(o);if(r===void 0)return n;switch(e){case "insertText":{let[i]=n,s=Tt(i,r);return s===""?null:[s]}case "removeMentionInput":{let[i,s]=n;return [Tt(i,r),s]}case "insertFragment":{let[i]=n;if(r===0)return null;let s=Dn(i,r);return A(s)===0&&A(i)>0?null:[s]}case "insertSoftBreak":case "insertParagraph":return r===0?null:n;default:return n}}maxLength(){let e=this.opts.maxLength?.();return Yn(e),e}clampToMaxLength(e){let n=ut(this.el,e),o=this.maxLength(),r=o===void 0?void 0:Math.max(o,A(this.doc));if(r===void 0||A(e)<=r)return {doc:e,range:n,overflowed:false};let i=n?C(e,n.focus):this.insertionEnd(e),s=A(e)-r;if(i===void 0||i<s){let c=Dn(e,r);if(i===void 0)return {doc:c,range:n,overflowed:true};let d=P(c,Math.min(i,r));return {doc:c,range:{anchor:d,focus:d},overflowed:true}}let l=i-s;/[\uDC00-\uDFFF]/.test(zn(e)[l]??"")&&(l-=1);let a=$e(e,{anchor:P(e,l),focus:P(e,i)});return {doc:a.doc,range:a.range,overflowed:true}}insertionEnd(e){let n=this.selection.range;if(!n)return;let o=C(this.doc,n.anchor),r=C(this.doc,n.focus),i=A(this.doc)-Math.abs(o-r);return Math.min(o,r)+A(e)-i}capacity(e){let n=this.maxLength();if(n===void 0)return;let o=Math.abs(C(this.doc,e.anchor)-C(this.doc,e.focus)),r=A(this.doc);return Math.max(0,Math.max(n,r)-(r-o))}undo(){if(!this.history.canUndo)return;let e={doc:this.doc,range:this.selection.range},n=this.history.undo(e);n&&this.commit(n.doc,n.range,{type:"history"});}redo(){if(!this.history.canRedo)return;let e={doc:this.doc,range:this.selection.range},n=this.history.redo(e);n&&this.commit(n.doc,n.range,{type:"history"});}canUndo(){return this.history.canUndo}canRedo(){return this.history.canRedo}focus(){this.el?.focus();}setCaretPosition(e){if(!this.el)return;let n=P(this.doc,e);this.select({anchor:n,focus:n});}select(e,n){this.selection.select(e,n?.focus!==false)&&(this.pendingMarks.clear(),this.emitSelectionChange());}selectStart(){this.setCaretPosition(0);}selectEnd(){let e=Ae(this.doc);this.select({anchor:e,focus:e});}selectAll(e){this.select({anchor:we(this.doc),focus:Ae(this.doc)},e);}getSelectionState(){return this.buildSelectionState(this.selection.current())}buildSelectionState(e){let n=e?be(this.doc,e):{...dt},o=this.pendingMarks.merge(n),r=e?Ar(this.doc,e):null;return {marks:o,link:r,range:e}}notifyChange(e,n){let o;try{this.opts.onChange?.(n);}catch(r){o={error:r};}if(this.doc===e&&this.opts.onDocChange?.(e),o)throw o.error}emitSelectionChange(){this.selection.markEmitted(),this.opts.onSelectionChange&&this.opts.onSelectionChange(this.buildSelectionState(this.selection.range));}commit(e,n,o){let r=o.type==="external"?o.html:ie(e),i=o.type==="external"&&t.docHasMentionInput(this.doc);this.doc=e,this.lastKnownHtml=r,(o.type==="history"||o.type==="external")&&this.pendingMarks.clear(),this.selection.set(n,"remember"),o.type!=="external"&&(this.lastAppliedValue=null,this.lastAppliedDoc=null);let s=this.el;switch(o.type){case "command":case "history":{s&&!this.composing&&(Ct(e,s),this.selection.set(n,"place"));break}case "native":{s&&o.rerender&&(Ct(e,s),this.selection.set(n,"write"));break}case "external":{if(!s)break;let l=()=>{this.el&&(Ct(e,this.el),n&&!this.selection.set(n,"place")&&!o.emit&&this.emitSelectionChange());};this.composing?this.pendingExternalRender=l:l();break}}o.type==="external"&&(i&&!t.docHasMentionInput(e)&&this.opts.onMentionInputRemoved?.(),!o.emit)||((o.type!=="native"||o.contentChanged)&&this.notifyChange(e,r),this.emitSelectionChange());}insertOverflowingText(e){if(!e.data)return false;let n=this.capacity(this.selection.current()??this.collapsedAtDocEnd());if(n===void 0||e.data.length<=n)return false;e.preventDefault();let o=this.pendingMarks.marks;return o?this.exec("insertFragment",[{type:"p",children:[kt(e.data,o)]}]):this.exec("insertText",e.data),true}handleNativeInsert(e){return e.inputType==="insertText"?this.insertOverflowingText(e):e.inputType==="insertReplacementText"&&this.replaceTargetText(e)}replaceTargetText(e){let n=this.el,o=e.getTargetRanges?.()[0],r=e.data??e.dataTransfer?.getData("text/plain");if(!n||!o||!r)return false;let i=Ge(n,this.doc,o.startContainer,o.startOffset),s=Ge(n,this.doc,o.endContainer,o.endOffset);if(!i||!s)return false;e.preventDefault();let l=kt(r,We(be(this.doc,{anchor:i,focus:s}))),a=this.doc[i.path[0]]?.children[i.path[1]],c=R(a)&&i.path[0]===s.path[0]&&i.path[1]===s.path[1];return ft(n,this.doc,{anchor:i,focus:s}),this.exec("insertFragment",[{type:"p",children:[c?{...a,children:[l]}:l]}]),true}breakCommand(e){return e==="insertParagraph"&&!this.enterHasShift&&this.opts.enterInsertsParagraph?.()?"insertParagraph":"insertSoftBreak"}handleBeforeInput(e){let{inputType:n}=e;if(n==="insertParagraph"||n==="insertLineBreak"){e.preventDefault();let r=this.detectAutoLinkBeforeCaret(),i=this.doc;this.exec(this.breakCommand(n)),r&&this.applyAutoLink(r,i);return}if(n==="insertText"&&e.data===" "){let r=this.detectAutoLinkBeforeCaret();if(r){e.preventDefault();let i=this.doc;this.exec("insertText"," "),this.applyAutoLink(r,i);return}}if(this.handleNativeInsert(e))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.selection.range)return true;if(!z(this.selection.range))return false;let e=this.selection.range,[n,o]=e.anchor.path,r=e.anchor.offset,i=this.doc;if(n>=i.length)return true;let s=i[n];if(o>=s.children.length)return true;let l=s.children[o];if(r===0&&o===0)return true;let a=null;if(g(l)){let c=l.text;if(r>0)a=c[r-1];else if(o>0)a=this.lastCharOf(s.children[o-1]);else return true}else if(R(l)){let c=l.children.map(d=>d.text).join("");if(r>0)a=c[r-1]??null;else if(o>0)a=this.lastCharOf(s.children[o-1]);else return true}else if(r===0&&o>0)a=this.lastCharOf(s.children[o-1]);else return true;return a===null?true:/^[\s"']$/.test(a)}lastCharOf(e){if(g(e)){let n=e.text;return n.length>0?n.at(-1)??null:null}if(R(e)){let o=(e.children??[]).at(-1);return o&&o.text.length>0?o.text.at(-1)??null:null}if(oe(e)){let n=e.displayName??"";return n.length>0?n.at(-1)??null:null}return null}allowedStyles(){return this.opts.htmlStyles?.()??vt}autoLinkEnabled(){return this.opts.autoLink?.()??true}detectAutoLinkBeforeCaret(){return !this.autoLinkEnabled()||this.composing?null:this.findAutoLinkBeforeCaret()}findAutoLinkBeforeCaret(){let e=this.selection.range;if(!e||!z(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,s=n.path[1],l=n.offset;if(s>=i.length){s=i.length-1;let f=i[s];if(!f||!g(f))return null;l=f.text.length;}else {let f=i[s];g(f)&&l>f.text.length&&(l=f.text.length);}let a=i[s];if(g(a)&&l<a.text.length&&!/\s/.test(a.text[l]))return null;let c="";for(;;){let f=i[s];if(!f||!g(f))break;if(l>0){let p=f.text[l-1];if(/\s/.test(p))break;c=p+c,l-=1;}else {if(s===0)break;let p=i[s-1];if(!g(p))break;s-=1,l=p.text.length;}}if(c==="")return null;let d=Jt(c);if(!d)return null;let u=C(o,{path:[r,s],offset:l});return {startAbs:u+d.start,endAbs:u+d.end,url:d.url}}applyAutoLink(e,n){if(this.doc===n)return;let o=ye(e.url);if(o==="")return;let r=this.doc,i={anchor:P(r,e.startAbs),focus:P(r,e.endAbs)},s={doc:r,range:this.selection.range},l=Un(r,i,o);if(l.doc===r)return;let a=this.selection.range?C(r,this.selection.range.anchor):e.endAbs;this.history.record(s,"wrapLink");let c=P(l.doc,a);this.commit(l.doc,{anchor:c,focus:c},{type:"command"});}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(!oe(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.selection.range;if(i&&!z(i)&&i.anchor.path[0]===i.focus.path[0]){let s=Rr(o),l=s?ye(s):"";if(l&&!Ir(this.doc,i)){this.exec("wrapLink",l);return}}}let r=e.getData("text/html");if(r)try{let i=L(this.resolvePastedMentions(Nn(r)));n&&(i=L(On(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=Ue(o.replaceAll(`\r
22
+ `)&&o<e&&(r=t.length),Math.min(r,t.length)}function Xr(t,e,n,o,r,i,s,l=false){if(t==="")return {found:false};let a=t.split(`
23
+ `),c=n,d=0;for(let u=0;u<a.length;u++){let f=a[u],p=u===a.length-1;if(f.length>0&&c<e.length){let h$1=e[c],m=ln(h$1);if(m!==null){if(i===m){let R=Math.min(s,f.length);return {found:true,point:{path:[o,r],offset:d+R}}}if(pe(i)&&h(i,m))return {found:true,point:{path:[o,r],offset:d+(s===0?0:f.length)}}}d+=f.length,c++;}if(p){if(p&&l&&t.endsWith(`
24
+ `)&&f===""&&c<e.length){let h=e[c];if(pe(h)&&Ct(h,"br")&&i===h)return {found:true,point:{path:[o,r],offset:d}};c++;}}else if(c<e.length){let h=e[c];if(pe(h)&&Ct(h,"br")&&i===h)return {found:true,point:{path:[o,r],offset:d+(s===0?0:1)}};d++,c++;}}return {found:false}}function as(t,e,n,o,r,i){if(!pe(e))return {found:false};if(r===e){let c=e.childNodes,d=Math.min(i,c.length),u=0,f=0,p=0;for(let h of t.children){let m=Ge(h.text,false);if(p+m>=d){f=u+Yr(h.text,d-p);break}u+=h.text.length,p+=m;}return p>=t.children.reduce((h,m)=>h+Ge(m.text,false),0)&&(f=t.children.reduce((h,m)=>h+m.text.length,0)),{found:true,point:{path:[n,o],offset:f}}}if(!h(e,r))return {found:false};let s=e.childNodes,l=0,a=0;for(let c of t.children){let d=Xr(c.text,s,a,n,o,r,i);if(d.found)return {found:true,point:{path:[n,o],offset:l+d.point.offset}};l+=c.text.length,a+=Ge(c.text,false);}return {found:false}}function ln(t){if(rn(t))return t;if(pe(t)){let e=t;for(;pe(e)&&e.childNodes.length===1;){let n=e.childNodes[0];if(rn(n))return n;if(pe(n))e=n;else break}}return null}function $e(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 s=Math.min(i,e.length)-1,l=e[s];if(!l)return null;let a=l.children.length-1,c=l.children[a];if(!c)return null;let d=g(c)?c.text.length:v(c)?c.children.reduce((u,f)=>u+f.text.length,0):0;return {path:[s,a],offset:d}}let r=t.children;for(let i=0;i<e.length;i++){let s=r[i];if(!s)return null;let l=e[i];if(n!==s&&!h(s,n))continue;if(Gr(l))return {path:[i,0],offset:0};let a=ss(s,l,i,n,o);return a.found?a.point:null}return null}catch{return null}}function qr(t,e,n){try{let[o,r]=n.path,i=n.offset;if(o<0||o>=e.length)return null;let s=e[o];if(r<0||r>=s.children.length)return null;let l=s.children[r],a=t.children[o];if(!a)return null;if(Gr(s))return {node:a.firstChild??a,offset:0};let c=a.childNodes,d=0;for(let u=0;u<r;u++){let f=s.children[u];g(f)?d+=Ge(f.text,sn(s.children,u)):d++;}if(g(l))return Zr(l.text,i,c,d,a,sn(s.children,r));if(v(l)){if(d>=c.length)return null;let u=c[d];return !pe(u)||!Ct(u,"a")?null:cs(l,i,u)}else if(oe(l)||Z(l)){let u=d+1;if(u<c.length){let f=c[u];if(rn(f))return {node:f,offset:0}}return {node:a,offset:Math.min(u,a.childNodes.length)}}return null}catch{return null}}function Zr(t,e,n,o,r,i=false){if(t==="")return {node:r,offset:o};let s=t.split(`
25
+ `),l=o,a=0;for(let c=0;c<s.length;c++){let d=s[c],u=c===s.length-1;if(d.length>0&&l<n.length){let f=n[l];if(e>=a&&e<=a+d.length){let p=ln(f);return p!==null?{node:p,offset:e-a}:{node:r,offset:l}}a+=d.length,l++;}if(u){if(u&&t.endsWith(`
26
+ `)&&d===""&&l<=n.length){if(e===a)return {node:r,offset:Math.min(l,r.childNodes.length)};i&&l++;}}else if(l<n.length){if(e===a)return {node:r,offset:l};a++,l++;}}if(l>o&&l-1<n.length){let c=n[l-1],d=ln(c);return d!==null?{node:d,offset:d.length}:{node:r,offset:l}}return {node:r,offset:Math.min(l,r.childNodes.length)}}function cs(t,e,n){let o=n.childNodes,r=0,i=0;for(let s of t.children){let l=s.text.length;if(e<=r+l)return Zr(s.text,e-r,o,i,n);r+=l,i+=Ge(s.text,false);}if(o.length>0){let s=n.lastChild,l=s===null?null:ln(s);return l!==null?{node:l,offset:l.length}:{node:n,offset:o.length}}return {node:n,offset:0}}function ds(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 Xn(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($r(r)){let i=ds(e,r);if(i&&h(t,i.startContainer))return i}return o}function ut(t,e){try{let n=a$r(t);if(!n)return null;let{anchorNode:o,focusNode:r}=n;if(o&&r&&h(t,o)&&h(t,r)){let a=$e(t,e,o,n.anchorOffset),c=$e(t,e,r,n.focusOffset);if(a!==null&&c!==null)return {anchor:a,focus:c}}let i=Xn(t,n);if(!i)return null;let s=$e(t,e,i.startContainer,i.startOffset);if(s===null)return null;let l=$e(t,e,i.endContainer,i.endOffset);return l===null?null:{anchor:s,focus:l}}catch{return null}}function ft(t,e,n){try{let o=qr(t,e,n.anchor);if(o===null)return;let r=qr(t,e,n.focus);if(r===null)return;let i=t.ownerDocument;if(!i)return;let s=a$r(t);if(!s)return;if(J(n.anchor,n.focus)>0||$r(t.getRootNode())){s.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),s.removeAllRanges(),s.addRange(a);}catch{}}var cn=class{constructor(e,n){this.getEl=e;this.getDoc=n;}getEl;getDoc;remembered=null;lastEmitted=null;writeDeferred=null;focusFromPointer=false;get range(){return this.remembered}set(e,n){if(this.remembered=e,!e||n==="remember")return false;if(n==="place"&&!this.hasFocus())return this.writeDeferred="render",false;let o=this.getEl();return o?(ft(o,this.getDoc(),e),true):false}markEmitted(){this.lastEmitted=this.remembered;}hasFocus(){let e=this.getEl();return e?h(e,f$2(e)):false}select(e,n){let o=this.getEl();if(!o)return false;let r=!this.remembered||!an(this.remembered,e);return this.remembered=e,r&&(this.lastEmitted=e),this.writeDeferred="select",!n&&!this.hasFocus()||(o.focus(),this.writeDeferred=null,ft(o,this.getDoc(),e)),r}collapseToFocus(){if(!this.getEl())return false;let e=this.current();return !e||z(e)?false:this.select({anchor:e.focus,focus:e.focus},true)}onPointerDown(){this.writeDeferred=null,this.focusFromPointer=!this.hasFocus();}onFocus(){let e=this.focusFromPointer,n=this.writeDeferred;this.focusFromPointer=false,this.writeDeferred=null;let o=this.getEl();if(e||!o||!this.remembered)return;let r=this.getDoc(),i=n===null?ut(o,r):null;if(i&&!us(r,i)){this.remembered=i;return}ft(o,r,this.remembered);}current(){let e=this.getEl();if(!e)return this.remembered;let n=ut(e,this.getDoc());return n&&this.adoptsLiveSelection(n)&&(this.remembered=n),this.remembered}adoptsLiveSelection(e){return this.writeDeferred===null?true:this.writeDeferred==="select"||z(e)?false:(this.writeDeferred=null,true)}adopt(e){let n=this.remembered;return this.remembered=e,!n||!an(n,e)}follow(e){if(e&&!this.adoptsLiveSelection(e))return "ignored";if(e===null)return "silent";let n=this.remembered;return this.remembered=e,!n||!an(n,e)||!this.lastEmitted||!an(this.lastEmitted,e)?"changed":"silent"}};function us(t,e){let n=Ae();return J(e.anchor,n)===0&&J(e.focus,n)===0}function an(t,e){return t.anchor.path[0]===e.anchor.path[0]&&t.anchor.path[1]===e.anchor.path[1]&&t.anchor.offset===e.anchor.offset&&t.focus.path[0]===e.focus.path[0]&&t.focus.path[1]===e.focus.path[1]&&t.focus.offset===e.focus.offset}var Jr="typing";var dn=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===Jr&&this.lastKind===Jr&&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 un=10,fn=class{pending=null;preserveSelectionChanges=0;get marks(){return this.pending?.marks}get caretOffset(){return this.pending?.caretOffset}merge(e){return this.pending?.marks??e}clear(){this.pending=null;}toggle(e,n,o){let r=this.effectiveMarks(e,n);r[o]=!r[o],this.pending={marks:r,caretOffset:M(e,n.anchor)};}setValue(e,n,o,r){let i=this.effectiveMarks(e,n);r===void 0?delete i[o]:i[o]=r,this.pending={marks:i,caretOffset:M(e,n.anchor)};}effectiveMarks(e,n){return this.pending?{...this.pending.marks}:Ve(Ee(e,n))}afterCommand(e,n,o,r){let i=this.pending?.marks;if(this.pending=null,e==="insertText"&&i){let s=Math.min(M(n,o.anchor),M(n,o.focus)),l=M(r.doc,r.range.focus),a=this.applyMarkSnapshot(r.doc,i,s,l),c=P(a,l);r={doc:a,range:{anchor:c,focus:c}};}return (e==="insertSoftBreak"||e==="insertParagraph")&&this.carryAcrossBreak(n,o,i,r),this.keepOfEmptiedDoc(n,r.doc),r}afterInput(e,n,o,r){this.keepOfEmptiedDoc(e,o),this.inheritOfEmptyRun(e,n);let i=o,s=r,l=false;if(!this.pending)return {doc:i,range:s,remarked:l};if(!r)return this.pending=null,{doc:i,range:s,remarked:l};let a=this.applyToTypedText(o,r,this.pending);return a.doc!==o&&(i=a.doc,s=a.range,l=true),this.pending={marks:this.pending.marks,caretOffset:M(i,a.range.anchor)},this.preserveSelectionChanges=un,{doc:i,range:s,remarked:l}}onSelectionChange(e,n){this.preserveSelectionChanges>0?(this.preserveSelectionChanges-=1,this.pending&&n&&(this.pending={...this.pending,caretOffset:M(e,n.anchor)})):this.pending&&n&&M(e,n.anchor)!==this.pending.caretOffset&&(this.pending=null);}onGenuineCaretMove(){this.preserveSelectionChanges=0;}keepOfEmptiedDoc(e,n){A(e)===0||A(n)!==0||(this.pending={marks:this.pending?.marks??Ve(Ee(e,{anchor:Ae(),focus:P(e,1)})),caretOffset:0},this.preserveSelectionChanges=un);}inheritOfEmptyRun(e,n){if(this.pending)return;let o;if(A(e)===0)o=Ae();else if(n&&z(n)&&A([e[n.anchor.path[0]]])===0)o=n.anchor;else return;let r=Ve(Ee(e,{anchor:o,focus:o}));Object.values(r).some(Boolean)&&(this.pending={marks:r,caretOffset:M(e,o)},this.preserveSelectionChanges=un);}carryAcrossBreak(e,n,o,r){let i=o?{...o}:Ve(Ee(e,n));!o&&!Object.values(i).some(Boolean)||(this.pending={marks:i,caretOffset:M(r.doc,r.range.anchor)},this.preserveSelectionChanges=un);}applyToTypedText(e,n,o){let r=o.caretOffset,i=M(e,n.anchor);if(i<=r)return {doc:e,range:n};let s=this.applyMarkSnapshot(e,o.marks,r,i),l=P(s,i);return {doc:s,range:{anchor:l,focus:l}}}applyMarkSnapshot(e,n,o,r){let i=e,s=()=>({anchor:P(i,o),focus:P(i,r)});for(let l of ["bold","italic","underline"]){let a=s(),c=!!n[l],d=!!Ee(i,a)[l];c!==d&&(i=tn(i,a,l).doc);}for(let l of jn){let a=s(),c=n[l],d=Ee(i,a)[l];d!==null&&(l==="color"||l==="backgroundColor"?b$a(c,d):c===d)||(i=nn(i,a,l,c).doc);}return i}};function ei(t){return g(t)?[t]:v(t)||Z(t)?t.children:[]}function Qr(t){return t.some(e=>!!e.textAlign||e.children.some(n=>ei(n).some(o=>!!o.fontFamily||!!o.fontSize)))}function ti(t,e,n){if(!Qr(t)&&!Qr(e))return t;let o=n.createElement("span"),r=(u,f)=>(o.style.removeProperty(Hi(u)),o.style[u]=f,o.style[u]),i={fontFamily:new Map,fontSize:new Map,textAlign:new Map},s=(u,f)=>{if(!f)return;let p=r(u,f);i[u].has(p)||i[u].set(p,f);};for(let u of e){s("textAlign",u.textAlign);for(let f of u.children)for(let p of ei(f))s("fontFamily",p.fontFamily),s("fontSize",p.fontSize);}let l=(u,f)=>f===void 0?void 0:i[u].get(r(u,f))??f,a=u=>{let f={...u};for(let p of ["fontFamily","fontSize"]){let h=l(p,u[p]);h!==void 0&&(f[p]=h);}return f.fontFamily===u.fontFamily&&f.fontSize===u.fontSize?u:f},c=false,d=t.map(u=>{let f=l("textAlign",u.textAlign),p=u.children.map(h=>{if(g(h))return a(h);if(v(h)||Z(h)){let m=h.children.map(R=>a(R));return m.some((R,I)=>R!==h.children[I])?{...h,children:m}:h}return h});return f===u.textAlign&&p.every((h,m)=>h===u.children[m])?u:(c=true,{...u,...f===void 0?{}:{textAlign:f},children:p})});return c?d:t}var ps=1,hs=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function ms(t){return (t.key==="ArrowLeft"||t.key==="ArrowRight")&&!t.shiftKey&&(t.ctrlKey||t.altKey||t.metaKey)}function Zn(t){if(t!==void 0&&!(Number.isInteger(t)&&t>=0))throw new Error(`Editor: maxLength must be a finite integer >= 0, received ${String(t)}.`)}var St=class t{doc=ye();lastKnownHtml="";lastAppliedValue=null;lastAppliedDoc=null;selection;composing=false;enterHasShift=false;pendingMarks=new fn;history=new dn;opts;el=null;pendingExternalRender=null;keyboardShortcutsOverride=void 0;constructor(e={}){this.opts=e,this.selection=new cn(()=>this.el,()=>this.doc),this.lastKnownHtml=ie(this.doc);}setKeyboardShortcutsEnabled(e){this.keyboardShortcutsOverride=e;}attach(e){this.maxLength(),this.el=e,Mt(this.doc,e),this.selection.set(this.selection.range,"write");let n=this.handleBeforeInputBound,o=this.handleInputBound,r=this.handlePasteBound,i=this.handleCopyBound,s=this.handleCompositionStartBound,l=this.handleCompositionEndBound,a=this.handleSelectionChangeBound,c=this.handlePointerDownBound,d=this.handleFocusBound,u=this.handleKeyDownBound,f=this.handleDocumentKeyDownBound,p=e.ownerDocument;return e.addEventListener("beforeinput",n),e.addEventListener("input",o),e.addEventListener("paste",r),e.addEventListener("copy",i),e.addEventListener("cut",i),e.addEventListener("compositionstart",s),e.addEventListener("compositionend",l),e.addEventListener("pointerdown",c),e.addEventListener("focus",d),e.addEventListener("keydown",u),p.addEventListener("selectionchange",a),p.addEventListener("keydown",f),()=>{e.removeEventListener("beforeinput",n),e.removeEventListener("input",o),e.removeEventListener("paste",r),e.removeEventListener("copy",i),e.removeEventListener("cut",i),e.removeEventListener("compositionstart",s),e.removeEventListener("compositionend",l),e.removeEventListener("pointerdown",c),e.removeEventListener("focus",d),e.removeEventListener("keydown",u),p.removeEventListener("selectionchange",a),p.removeEventListener("keydown",f),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.selection.current(),this.handleBeforeInput(n);}};handleInputBound=e=>{j$2(e)===this.el&&(this.composing||this.syncFromDom());};isClipboardTargetInEditor(e,n=false){let o=j$2(e);return !o||!h(this.el,o)?false:!(o.nodeType===ps?o:o.parentElement)?.closest(n?"input":'input, [contenteditable="false"]')}handlePasteBound=e=>{let n=e;if(!this.isClipboardTargetInEditor(n)||(n.preventDefault(),this.opts.isReadOnly?.())||this.composing)return;this.selection.current();let o;try{o=this.opts.onPaste?.(n),o&&(o=L(o));}catch(r){o=null,queueMicrotask(()=>{throw r});}if(o!==null){if(o!==void 0){this.exec("insertFragment",o);return}this.insertPastedData(n.clipboardData);}};handleCopyBound=e=>{let n=e;if(!this.opts.onCopy||!this.isClipboardTargetInEditor(n,true))return;let o=this.selection.current(),r=o!==null&&!z(o),i=this.doc,s=r?qn(i,o):ye();this.opts.onCopy(n,s)&&(n.preventDefault(),r&&n.type==="cut"&&!this.opts.isReadOnly?.()&&this.doc===i&&(this.select(o),this.exec("deleteRange")));};handleKeyDownBound=e=>{this.enterHasShift=e.key==="Enter"&&e.shiftKey,hs.has(e.key)&&this.pendingMarks.onGenuineCaretMove();};handleDocumentKeyDownBound=e=>{e.defaultPrevented||!this.el||!e.composedPath().includes(this.el)||!ms(e)||this.selection.collapseToFocus()&&this.emitSelectionChange();};handlePointerDownBound=()=>{this.pendingMarks.onGenuineCaretMove(),this.selection.onPointerDown();};handleFocusBound=()=>{this.selection.onFocus();};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();};getDoc(e){return e?qn(this.doc,e):this.doc}getValue(){return ie(this.doc)}setValue(e,n={}){if(e===this.lastKnownHtml||e===this.lastAppliedValue)return;let o,r;try{o=L(Bn(e,this.allowedStyles())),r=ie(o);}catch(i){process.env.NODE_ENV!=="production"&&console.error("[Editor] setValue failed to parse value:",i);return}this.lastAppliedValue=e,this.lastAppliedDoc=null,this.replaceDoc(o,r,n);}setDoc(e,n={}){if(e===this.doc||e===this.lastAppliedDoc)return;let o=L(e);this.lastAppliedDoc=e,!pr(o,this.doc)&&(this.lastAppliedValue=null,this.replaceDoc(o,ie(o),n));}replaceDoc(e,n,o){let r=this.selection.range?M(this.doc,this.selection.range.anchor):null,i=null;if(r!==null){let s=P(e,Math.min(r,A(e)));i={anchor:s,focus:s};}this.history.clear(),this.commit(e,i,{type:"external",html:n,emit:!!o.emit});}static docHasMentionInput(e){return e.some(n=>n.children.some(o=>Z(o)))}exec(e,...n){let o=this.selection.current(),r=this.doc,i=o??this.collapsedAtDocEnd(),s={doc:r,range:o},l;try{let a=this.fitToCapacity(e,n,i);if(a===null)return;l=this.dispatchCommand(e,a);}catch(a){process.env.NODE_ENV!=="production"&&console.error(`[Editor] command "${e}" threw:`,a);return}if(e==="confirmMention"){let a=this.maxLength();a!==void 0&&A(l.doc)>Math.max(a,A(r))&&(l=Gn(r,""));}if(l.doc===r){if(e==="toggleMark"&&z(i)){let[a]=n;this.pendingMarks.toggle(this.doc,i,a),this.emitSelectionChange();return}if(e==="setMarkValue"&&z(i)){let[a,c]=n;this.pendingMarks.setValue(this.doc,i,a,c),this.emitSelectionChange();return}this.pendingMarks.clear();return}l=this.pendingMarks.afterCommand(e,r,i,l),this.history.record(s,e),this.commit(l.doc,l.range,{type:"command"});}fitToCapacity(e,n,o){let r=this.capacity(o);if(r===void 0)return n;switch(e){case "insertText":{let[i]=n,s=Et(i,r);return s===""?null:[s]}case "removeMentionInput":{let[i,s]=n;return [Et(i,r),s]}case "insertFragment":{let[i]=n;if(r===0)return null;let s=Pn(i,r);return A(s)===0&&A(i)>0?null:[s]}case "insertSoftBreak":case "insertParagraph":return r===0?null:n;default:return n}}maxLength(){let e=this.opts.maxLength?.();return Zn(e),e}clampToMaxLength(e){let n=ut(this.el,e),o=this.maxLength(),r=o===void 0?void 0:Math.max(o,A(this.doc));if(r===void 0||A(e)<=r)return {doc:e,range:n,overflowed:false};let i=n?M(e,n.focus):this.insertionEnd(e),s=A(e)-r;if(i===void 0||i<s){let c=Pn(e,r);if(i===void 0)return {doc:c,range:n,overflowed:true};let d=P(c,Math.min(i,r));return {doc:c,range:{anchor:d,focus:d},overflowed:true}}let l=i-s;/[\uDC00-\uDFFF]/.test(wn(e)[l]??"")&&(l-=1);let a=qe(e,{anchor:P(e,l),focus:P(e,i)});return {doc:a.doc,range:a.range,overflowed:true}}insertionEnd(e){let n=this.selection.range;if(!n)return;let o=M(this.doc,n.anchor),r=M(this.doc,n.focus),i=A(this.doc)-Math.abs(o-r);return Math.min(o,r)+A(e)-i}capacity(e){let n=this.maxLength();if(n===void 0)return;let o=Math.abs(M(this.doc,e.anchor)-M(this.doc,e.focus)),r=A(this.doc);return Math.max(0,Math.max(n,r)-(r-o))}undo(){if(!this.history.canUndo)return;let e={doc:this.doc,range:this.selection.range},n=this.history.undo(e);n&&this.commit(n.doc,n.range,{type:"history"});}redo(){if(!this.history.canRedo)return;let e={doc:this.doc,range:this.selection.range},n=this.history.redo(e);n&&this.commit(n.doc,n.range,{type:"history"});}canUndo(){return this.history.canUndo}canRedo(){return this.history.canRedo}focus(){this.el?.focus();}setCaretPosition(e){if(!this.el)return;let n=P(this.doc,e);this.select({anchor:n,focus:n});}select(e,n){this.selection.select(e,n?.focus!==false)&&(this.pendingMarks.clear(),this.emitSelectionChange());}selectStart(){this.setCaretPosition(0);}selectEnd(){let e=Ie(this.doc);this.select({anchor:e,focus:e});}selectAll(e){this.select({anchor:Ae(this.doc),focus:Ie(this.doc)},e);}getSelectionState(){return this.buildSelectionState(this.selection.current())}buildSelectionState(e){let n=e?Ee(this.doc,e):{...dt},o=this.pendingMarks.merge(n),r=e?Ir(this.doc,e):null;return {marks:o,link:r,range:e}}notifyChange(e,n){let o;try{this.opts.onChange?.(n);}catch(r){o={error:r};}if(this.doc===e&&this.opts.onDocChange?.(e),o)throw o.error}emitSelectionChange(){this.selection.markEmitted(),this.opts.onSelectionChange&&this.opts.onSelectionChange(this.buildSelectionState(this.selection.range));}commit(e,n,o){let r=o.type==="external"?o.html:ie(e),i=o.type==="external"&&t.docHasMentionInput(this.doc);this.doc=e,this.lastKnownHtml=r,(o.type==="history"||o.type==="external")&&this.pendingMarks.clear(),this.selection.set(n,"remember"),o.type!=="external"&&(this.lastAppliedValue=null,this.lastAppliedDoc=null);let s=this.el;switch(o.type){case "command":case "history":{s&&!this.composing&&(Mt(e,s),this.selection.set(n,"place"));break}case "native":{s&&o.rerender&&(Mt(e,s),this.selection.set(n,"write"));break}case "external":{if(!s)break;let l=()=>{this.el&&(Mt(e,this.el),n&&!this.selection.set(n,"place")&&!o.emit&&this.emitSelectionChange());};this.composing?this.pendingExternalRender=l:l();break}}o.type==="external"&&(i&&!t.docHasMentionInput(e)&&this.opts.onMentionInputRemoved?.(),!o.emit)||((o.type!=="native"||o.contentChanged)&&this.notifyChange(e,r),this.emitSelectionChange());}insertOverflowingText(e){if(!e.data)return false;let n=this.capacity(this.selection.current()??this.collapsedAtDocEnd());if(n===void 0||e.data.length<=n)return false;e.preventDefault();let o=this.pendingMarks.marks;return o?this.exec("insertFragment",[{type:"p",children:[Rt(e.data,o)]}]):this.exec("insertText",e.data),true}handleNativeInsert(e){return e.inputType==="insertText"?this.insertOverflowingText(e):e.inputType==="insertReplacementText"&&this.replaceTargetText(e)}replaceTargetText(e){let n=this.el,o=e.getTargetRanges?.()[0],r=e.data??e.dataTransfer?.getData("text/plain");if(!n||!o||!r)return false;let i=$e(n,this.doc,o.startContainer,o.startOffset),s=$e(n,this.doc,o.endContainer,o.endOffset);if(!i||!s)return false;e.preventDefault();let l=Rt(r,Ve(Ee(this.doc,{anchor:i,focus:s}))),a=this.doc[i.path[0]]?.children[i.path[1]],c=v(a)&&i.path[0]===s.path[0]&&i.path[1]===s.path[1];return ft(n,this.doc,{anchor:i,focus:s}),this.exec("insertFragment",[{type:"p",children:[c?{...a,children:[l]}:l]}]),true}breakCommand(e){return e==="insertParagraph"&&!this.enterHasShift&&this.opts.enterInsertsParagraph?.()?"insertParagraph":"insertSoftBreak"}handleBeforeInput(e){let{inputType:n}=e;if(n==="insertParagraph"||n==="insertLineBreak"){e.preventDefault();let r=this.detectAutoLinkBeforeCaret(),i=this.doc;this.exec(this.breakCommand(n)),r&&this.applyAutoLink(r,i);return}if(n==="insertText"&&e.data===" "){let r=this.detectAutoLinkBeforeCaret();if(r){e.preventDefault();let i=this.doc;this.exec("insertText"," "),this.applyAutoLink(r,i);return}}if(this.handleNativeInsert(e))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.selection.range)return true;if(!z(this.selection.range))return false;let e=this.selection.range,[n,o]=e.anchor.path,r=e.anchor.offset,i=this.doc;if(n>=i.length)return true;let s=i[n];if(o>=s.children.length)return true;let l=s.children[o];if(r===0&&o===0)return true;let a=null;if(g(l)){let c=l.text;if(r>0)a=c[r-1];else if(o>0)a=this.lastCharOf(s.children[o-1]);else return true}else if(v(l)){let c=l.children.map(d=>d.text).join("");if(r>0)a=c[r-1]??null;else if(o>0)a=this.lastCharOf(s.children[o-1]);else return true}else if(r===0&&o>0)a=this.lastCharOf(s.children[o-1]);else return true;return a===null?true:/^[\s"']$/.test(a)}lastCharOf(e){if(g(e)){let n=e.text;return n.length>0?n.at(-1)??null:null}if(v(e)){let o=(e.children??[]).at(-1);return o&&o.text.length>0?o.text.at(-1)??null:null}if(oe(e)){let n=e.displayName??"";return n.length>0?n.at(-1)??null:null}return null}allowedStyles(){return this.opts.htmlStyles?.()??Tt}autoLinkEnabled(){return this.opts.autoLink?.()??true}detectAutoLinkBeforeCaret(){return !this.autoLinkEnabled()||this.composing?null:this.findAutoLinkBeforeCaret()}findAutoLinkBeforeCaret(){let e=this.selection.range;if(!e||!z(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,s=n.path[1],l=n.offset;if(s>=i.length){s=i.length-1;let f=i[s];if(!f||!g(f))return null;l=f.text.length;}else {let f=i[s];g(f)&&l>f.text.length&&(l=f.text.length);}let a=i[s];if(g(a)&&l<a.text.length&&!/\s/.test(a.text[l]))return null;let c="";for(;;){let f=i[s];if(!f||!g(f))break;if(l>0){let p=f.text[l-1];if(/\s/.test(p))break;c=p+c,l-=1;}else {if(s===0)break;let p=i[s-1];if(!g(p))break;s-=1,l=p.text.length;}}if(c==="")return null;let d=Qt(c);if(!d)return null;let u=M(o,{path:[r,s],offset:l});return {startAbs:u+d.start,endAbs:u+d.end,url:d.url}}applyAutoLink(e,n){if(this.doc===n)return;let o=be(e.url);if(o==="")return;let r=this.doc,i={anchor:P(r,e.startAbs),focus:P(r,e.endAbs)},s={doc:r,range:this.selection.range},l=Wn(r,i,o);if(l.doc===r)return;let a=this.selection.range?M(r,this.selection.range.anchor):e.endAbs;this.history.record(s,"wrapLink");let c=P(l.doc,a);this.commit(l.doc,{anchor:c,focus:c},{type:"command"});}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(!oe(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.selection.range;if(i&&!z(i)&&i.anchor.path[0]===i.focus.path[0]){let s=kr(o),l=s?be(s):"";if(l&&!_r(this.doc,i)){this.exec("wrapLink",l);return}}}let r=e.getData("text/html");if(r)try{let i=L(this.resolvePastedMentions(Bn(r)));n&&(i=L(Fn(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=je(o.replaceAll(`\r
27
27
  `,`
28
28
  `).replaceAll("\r",`
29
- `)),s=L([{type:"p",children:[{text:i}]}]);n&&(s=L(On(s))),this.exec("insertFragment",s);}}syncFromDom(){if(!this.el||this.composing)return;let e=this.doc,n={doc:e,range:this.selection.range},{doc:o,range:r,overflowed:i}=this.clampToMaxLength(pr(ei(Zt(this.el,gr),e,this.el.ownerDocument),e)),l=ie(o)!==this.lastKnownHtml;if(!l&&!i){r&&this.selection.adopt(r)&&this.emitSelectionChange();return}l&&this.history.record(n,"typing");let a=o,c=r,d=i;if(!c&&n.range){let f=Math.max(A(o)-A(e),0),p=this.pendingMarks.caretOffset??C(e,n.range.anchor),h=P(o,p+f);c={anchor:h,focus:h};}let u=this.pendingMarks.afterInput(e,n.range,o,c);a=u.doc,c=u.range,u.remarked&&(d=true),this.commit(a,c,{type:"native",rerender:d,contentChanged:l});}handleSelectionChange(){if(!this.el)return;let e=a$r(this.el);if(!e)return;let n=Gn(this.el,e);if(!n||!h(this.el,n.startContainer))return;let o=ut(this.el,this.doc),r=this.selection.follow(o);r!=="ignored"&&(this.pendingMarks.onSelectionChange(this.doc,o),r==="changed"&&this.emitSelectionChange());}dispatchCommand(e,n){let o=this.doc,r=this.selection.range??this.collapsedAtDocEnd();switch(e){case "toggleMark":{let[i]=n;return en(o,r,i)}case "setMarkValue":{let[i,s]=n;return tn(o,r,i,s)}case "wrapLink":{let[i]=n;return Un(o,r,i)}case "updateLinkUrl":{let[i]=n;return _r(o,r,i)}case "unwrapLink":return Nr(o,r);case "deleteRange":return $e(o,r);case "insertText":{let[i]=n;if(!z(r)){let s=$e(o,r);return Mt(s.doc,s.range.focus,i)}return Mt(o,r.anchor,i)}case "insertFragment":{let[i]=n;return Wn(o,r,i)}case "insertSoftBreak":return Or(o,r);case "insertParagraph":return Br(o,r);case "insertMentionInput":return jr(o,r);case "confirmMention":{let[i]=n;return Ur(o,i)}case "removeMentionInput":{let[i,s]=n;return qn(o,i,s)}default:return {doc:o,range:r}}}collapsedAtDocEnd(){let e=Ae(this.doc);return {anchor:e,focus:e}}};var Dt=wt.createContext(null);function Se(){let t=wt.useContext(Dt);if(!t)throw new Error("useEditorContext must be used within an EditorProvider");return t}var fn=Object.freeze({marks:dt,link:null,range:null});function gs(t){let e=Ue(t.replaceAll(/<br\s*\/?>/gi,"").replaceAll(/<p\s[^>]*>/gi,"<p>"));return e==="<p></p>"||e===""||e==="<p> </p>"}function Xn(t={}){let{value:e,defaultValue:n,doc:o,defaultDoc:r,onChange:i,onDocChange:s,isDisabled:l,keyboardShortcuts:a,onSelectionChange:c,onMentionTrigger:d,onMentionInputRemoved:u,canStartMention:f,resolveMention:p,onPaste:h,onCopy:m,maxLength:k,htmlStyles:I,isReadOnly:$,autoLink:w,enterInsertsParagraph:j}=t;if(e!==void 0&&i===void 0&&a$d("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`."),(e!==void 0||n!==void 0)&&(o!==void 0||r!==void 0)||o!==void 0&&r!==void 0)throw new Error("useEditor: pass at most one of `doc` and `defaultDoc`, and not together with `value` or `defaultValue`.");o!==void 0&&s===void 0&&a$d("use-editor-doc-without-ondocchange","useEditor: `doc` without `onDocChange` is controlled but cannot reflect edits \u2014 they are discarded on the next render. Use `defaultDoc` for initial content, or add `onDocChange`."),Yn(k);let[D,Q]=useState(fn),U=o??r,[pe,x]=useState(()=>U?ie(L(U)):e??n??""),M=useMemo(()=>o===void 0?void 0:ie(L(o)),[o]),G=useRef(i);G.current=i;let E=useRef(s);E.current=s;let Te=useRef(c);Te.current=c;let he=useRef(d);he.current=d;let ve=useRef(u);ve.current=u;let Re=useRef(f);Re.current=f;let ee=useRef(p);ee.current=p;let V=useRef(h);V.current=h;let Le=useRef(m);Le.current=m;let De=useRef(k);De.current=k;let Ne=useRef(I);Ne.current=I;let Qe=useRef($);Qe.current=$;let Oe=useRef(l);Oe.current=l;let Be=useRef(a);Be.current=a;let le=useRef(w);le.current=w;let ze=useRef(j);ze.current=j;let y=useRef(null);if(y.current===null){y.current=new Lt({onChange:v=>{x(v),G.current?.(v);},onDocChange:v=>{E.current?.(v);},onSelectionChange:v=>{Q(v),Te.current?.(v);},onMentionTrigger:()=>{he.current?.();},onMentionInputRemoved:()=>{ve.current?.();},canStartMention:()=>Re.current?.()??false,get resolveMention(){return ee.current},get onPaste(){return V.current},get onCopy(){return Le.current},maxLength:()=>De.current,htmlStyles:()=>Ne.current,autoLink:()=>le.current!==false,isReadOnly:()=>Qe.current?.()??!!Oe.current,areKeyboardShortcutsEnabled:()=>Be.current!==false,enterInsertsParagraph:()=>!!ze.current});let b=e??n;U?y.current.setDoc(U):b&&typeof DOMParser<"u"&&y.current.setValue(b);}let S=y.current;a$i(()=>{o!==void 0?S.setDoc(o):e!==void 0&&S.setValue(e);}),useEffect(()=>{l&&Q(fn);},[l]);let me=M??e??pe,Pe=gs(me),ke=S.canUndo(),T=S.canRedo();return useMemo(()=>({core:S,selectionState:D,value:me,isEmpty:Pe,isDisabled:!!l,keyboardShortcuts:a!==false,canUndo:ke,canRedo:T,focus:()=>{S.focus();},selectStart:()=>{S.selectStart();},selectEnd:()=>{S.selectEnd();},setCaretPosition:b=>{S.setCaretPosition(b);},undo:()=>{S.undo();},redo:()=>{S.redo();},getValue:()=>S.getValue(),setValue:(b,v)=>{S.setValue(b,v);},getDoc:b=>S.getDoc(b),setDoc:(b,v)=>{S.setDoc(b,v);},selectAll:b=>{S.selectAll(b);},select:(b,v)=>{S.select(b,v);},getSelectionState:()=>S.getSelectionState(),exec:(b,...v)=>{S.exec(b,...v);},isMarkActive:b=>!!D.marks[b],toggleMark:b=>{S.exec("toggleMark",b);},setMark:(b,v)=>{S.exec("setMarkValue",b,v);}}),[S,D,me,Pe,l,a,ke,T])}function ii(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 Jn(t,e={}){let n=Ts(t),{ref:o,autoFocus:r,onKeyDown:i,keyboardShortcuts:s}=e,l=s??n.keyboardShortcuts,a=useId(),c=useRef(null),d=useRef(null),u=useCallback(m=>{d.current&&(d.current(),d.current=null),m&&(d.current=n.core.attach(m));},[n.core]),f$1=useMemo(()=>f(c,u,o??null),[u,o]);useEffect(()=>(n.core.setKeyboardShortcutsEnabled(s),()=>{n.core.setKeyboardShortcutsEnabled(void 0);}),[n.core,s]);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:h}=j({onKeyDown:m=>{i?.(m)||l&&ii(m,n)||m.continuePropagation();}});return {editableProps:{...h,id:a,ref:f$1,contentEditable:!n.isDisabled,suppressContentEditableWarning:true,role:"textbox","aria-multiline":true,"data-editor-root":"true"}}}function Ts(t){let e=useContext(Dt);if(t)return t;if(!e)throw new Error("useEditable must be passed an editor or used within an EditorProvider");return e}var Qn=({editor:t,children:e})=>jsx(Dt.Provider,{value:t,children:e});var pn=({markName:t,icon:e,ariaLabel:n,isDisabled:o})=>{let{core:r,selectionState:i}=Se(),s=!!i.marks[t];return jsx(a$h,{variant:"tertiary",isSelected:s,size:"sm",icon:e,"aria-label":n,"data-testid":`editor-${t}-button`,isDisabled:o,onPress:()=>{r.exec("toggleMark",t),r.focus();},preventFocusOnPress:true})},to=({colorKey:t,"aria-label":e,isDisabled:n})=>{let{core:o,selectionState:r}=Se(),i=t==="color"?r.marks.color:r.marks.backgroundColor,s=wt.useRef(null),l=useCallback(()=>{s.current=r.range;},[r.range]),a=useCallback(p=>{setTimeout(()=>{let h=o.getSelectionState().range??s.current;h&&o.select(h),o.exec("setMarkValue",t,p);},0);},[o,t]),c=useCallback(p=>{a(p);},[a]),d=useCallback(()=>{a();},[a]),u=useCallback(({ref:p,triggerProps:h})=>jsx(a$c,{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:it,preventFocusOnPress:true,...h,ref:p}),[t,e,n]),f=useCallback(p=>{p?c(p.toString("rgba")):d();},[d,c]);return jsx(b$3,{presets:Mn,allowRemoval:true,pickerMode:"lazy",placement:"top end",colorLabel:false,renderTriggerButton:u,onTriggerPress:l,value:i||"#000000",onChange:f,isDisabled:n})};var Xe={Add:"add",Edit:"edit",Show:"show"},li=({isDisabled:t,addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:s})=>{let{formatMessage:l}=b(),{core:a}=Se();return jsxs(b$4,{type:"dialog",children:[jsx(j$1,{children:jsx(a$c,{icon:LinkIcon,size:"sm",isDisabled:t,"aria-label":e??l(Ze.addLink),"data-testid":"editor-add-link-button",className:it,preventFocusOnPress:true})}),jsx(a$j,{className:sprinkles({boxShadow:"medium"}),placement:"top end",children:({close:c})=>jsx(a$k,{size:"content",style:{minWidth:240},children:jsx(Ls,{addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:s,close:()=>{c(),setTimeout(()=>{a.focus();},0);}})})})]})},Ls=({close:t,addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:s})=>{let{core:l,selectionState:a}=Se(),{formatMessage:c}=b(),d=a.link?.url,[u,f]=wt.useState(d?Xe.Show:Xe.Add),[p,h]=wt.useState(d||""),m=jsx(a$a,{padding:"lg",children:jsx(a$s,{label:r??c(Ze.link),value:p,autoFocus:true,onChange:h,placeholder:"https://yourdomain.com","data-testid":"editor-link-input"})});return jsxs(Fragment,{children:[u===Xe.Add&&jsxs(Fragment,{children:[m,jsx(a$a,{display:"flex",justifyContent:"flex-end",padding:"lg",className:qo,children:jsx(b$9,{isDisabled:!a$t(p,true)||ye(p)==="",label:e??c(Ze.addLink),"data-testid":"editor-link-add-button",size:"sm",onPress:()=>{l.exec("wrapLink",_n(p)),t?.();},preventFocusOnPress:true})})]}),u===Xe.Show&&jsxs(Fragment,{children:[jsx(a$a,{padding:"lg",children:jsx(a$p,{type:"subtitle",size:"sm",children:d})}),jsxs(a$a,{display:"flex",justifyContent:"flex-end",padding:"lg",gap:"lg",borderColor:"border.subtle",borderWidth:1,borderStyle:"solid",children:[jsx(b$9,{label:n??c(Ze.editLink),"data-testid":"editor-link-edit-button",size:"sm",variant:"secondary",onPress:()=>{f(Xe.Edit);},style:{flex:1,justifyContent:"center"}}),jsx(b$9,{label:o??c(Ze.removeLink),"data-testid":"editor-link-remove-button",size:"sm",onPress:()=>{l.exec("unwrapLink"),t?.();},preventFocusOnPress:true,style:{flex:1,justifyContent:"center"}})]})]}),u===Xe.Edit&&jsxs(Fragment,{children:[m,jsxs(a$a,{display:"flex",justifyContent:"flex-end",padding:"lg",gap:"lg",borderColor:"border.subtle",borderWidth:1,borderStyle:"solid",children:[jsx(b$9,{label:i??c(Ze.cancel),"data-testid":"editor-link-cancel-button",size:"sm",variant:"secondary",onPress:()=>{f(Xe.Show),t?.();}}),jsx(b$9,{label:s??c(Ze.save),"data-testid":"editor-link-save-button",size:"sm",isDisabled:!a$t(p,true)||ye(p)==="",onPress:()=>{l.exec("updateLinkUrl",_n(p)),t?.();}})]})]})]})},Ze=c({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 oo=wt.createContext({items:[],containerRef:{current:null},maxMentionableUsersSuggestions:10}),_s=({key:t,value:e},{isDisabled:n,optionProps:o,isFocused:r,_state:i},s)=>{let{hoverProps:l}=a$4({isDisabled:n}),{label:a,data:c}=e;return jsxs(Fragment,{children:[jsxs("li",{...g$1(o,l),className:Qo({isDisabled:n,isHovered:r}),"data-active":r||void 0,ref:s,children:[jsx(a$a,{elementType:"span",display:"flex","aria-hidden":true,children:jsx(a$g,{name:a,...c?.avatar})}),jsxs(a$a,{display:"flex",flexDirection:"column",children:[jsx(a$p,{type:"subtitle",size:"sm",children:a}),jsx(a$p,{type:"helper",size:"sm",children:c?.description})]})]}),t===i.collection.getLastKey()?null:jsx(a$b,{})]})};function no(t){return t.displayName?.trim()||t.name?.trim()||t.id}function ro(t){return t.displayName??no(t)}function io({anchor:t,onClose:e,mentionLabel:n}){let{core:o}=Se(),{containerRef:r,items:i,maxMentionableUsersSuggestions:s}=useContext(oo),[l,a]=useState(""),{contains:c}=a$l({sensitivity:"base"}),{formatMessage:d}=b(),u=useRef(false),f=useCallback(()=>{u.current=true,e();},[e]),p=useMemo(()=>{let x=i.filter(M=>l===""||c(no(M),l)).map(M=>({id:M.id,label:no(M),data:M}));return s?x.slice(0,s):x},[i,s,l,c]),h=useCallback(x=>jsx(a$m,{textValue:x.label,children:x.label},x.id),[]),m=useCallback(x=>{if(u.current||x==null)return;let M=i.find(G=>G.id===x);M&&(f(),o.exec("confirmMention",{id:M.id,displayName:ro(M)}),o.exec("insertText"," "),o.focus());},[f,o,i]),k=b$5({items:p,children:h,menuTrigger:"focus",onSelectionChange:m}),I=useCallback(x=>{if(u.current)return;f();let M=x==="backspace"?"":`@${k.inputValue}`;o.exec("removeMentionInput",M,x==="arrowStart"?"start":"end"),o.focus();},[f,o,k.inputValue]),$=useRef(null),w=useRef(null),j=useRef(null),N=useRef(null);a$n({ref:N,onInteractOutside:()=>{k.close();}});let{inputProps:D,listBoxProps:Q}=a$o({defaultItems:p,inputRef:w,buttonRef:$,listBoxRef:j,popoverRef:N,menuTrigger:"focus","aria-label":n??d(Ns.mention)},k);useLayoutEffect(()=>{w.current?.focus(),setTimeout(()=>{w.current?.focus();});},[]);let U=useCallback(x=>{let M=x.currentTarget,G=M.selectionStart===0&&M.selectionEnd===0,E=M.selectionStart===M.value.length&&M.selectionEnd===M.value.length;if(x.key==="Backspace"&&G)x.preventDefault(),I("backspace");else if(x.key==="Escape")I("escape");else if(x.key==="ArrowLeft"||x.key==="ArrowRight"){let ee=V=>x.key==="ArrowLeft"!=(b$1(V).getComputedStyle(V).direction==="rtl");(ee(M)?G:E)&&(x.preventDefault(),I(ee(t)?"arrowStart":"arrowEnd"));}let Te=x.metaKey||x.ctrlKey,he=x.key.toLowerCase(),ve=Te&&!x.shiftKey&&he==="z"&&o.canUndo(),Re=(Te&&x.shiftKey&&he==="z"||x.ctrlKey&&he==="y")&&o.canRedo();(ve||Re)&&(x.preventDefault(),ve?o.undo():o.redo(),f(),o.focus());},[t,I,f,o]),pe=useMemo(()=>{if(!CSS.supports("field-sizing","content")){let x=b$1(w.current),M=w.current?x?.getComputedStyle(w.current).font:void 0;return {width:M?b$6({text:k.inputValue,font:M,element:w.current}).width+10:"4ch"}}},[k.inputValue]);return jsxs(Fragment,{children:[createPortal(jsx("input",{...g$1(D,{onKeyDown:U,onBlur:()=>{I("blur");},onChange:x=>{a(x.target.value);}}),style:pe,dir:/\p{L}/u.test(k.inputValue)?"auto":void 0,className:Jo,ref:w}),t),jsx(b$7.Provider,{value:k,children:jsx(a$j,{triggerRef:r,isNonModal:true,ref:N,state:k,crossOffset:-2,children:jsx(c$1,{...Q,items:void 0,ref:j,"data-testid":"editor-mention-listbox",className:a$6(f$1,sprinkles({width:"full"})),renderOption:_s})})})]})}io.displayName="MentionInputOverlay";var Ns=c({mention:{defaultMessage:"Mention",id:"bui.editor.mention"}});var ao=wt.forwardRef(({value:t,defaultValue:e$1,onChange:n,style:o,spellCheck:r,placeholder:i,isInline:s,isDisabled:l,editableContentAriaLabel:a,containerRef:c,onHelpDialogOpenRequest:d,mentionableUsers:u,editorHandle:f,maxMentionableUsersSuggestions:p,autoFocus:h,editorRef:m,saveOnEnter:k,onSave:I,autoLink:$,mentionLabel:w,boldLabel:j,italicLabel:N,underlineLabel:D,fontColorLabel:Q,backgroundColorLabel:U,helpLabel:pe,addLinkLabel:x,editLinkLabel:M,removeLinkLabel:G,linkAnnotationLabel:E,linkCancelLabel:Te,linkSaveLabel:he},ve)=>{let Re=useRef(null),ee=useRef(null),{formatMessage:V}=b(),[Le,De]=useState(null),Ne=useRef(0),[Qe,Oe]=useState(false),Be=()=>{let T=ee.current?.querySelector("[data-mention-anchor]");T&&(Ne.current+=1,De({anchor:T,id:Ne.current}));},le=Xn({value:t,defaultValue:e$1,onChange:n,isDisabled:l,onMentionTrigger:Be,onMentionInputRemoved:()=>{De(null);},canStartMention:()=>(u?.length??0)>0,resolveMention:T=>{let b=u?.find(v=>v.id===T);return b&&ro(b)},autoLink:$}),ze=le.core;wt.useEffect(()=>{m&&(m.current=ze);},[ze,m]);let y=T=>a$2(T)?false:k&&T.key==="Enter"&&!T.shiftKey||(T.ctrlKey||T.metaKey)&&T.key==="Enter"?(T.preventDefault(),I(),true):T.altKey&&T.key==="F10"?(T.preventDefault(),Re.current?.querySelector("button")?.focus(),true):false,{editableProps:S}=Jn(le,{ref:ee,autoFocus:h,onKeyDown:y}),me=T=>{if(l)return;let{isLinkClick:b,url:v}=Tr(T.target,{metaKey:T.metaKey,ctrlKey:T.ctrlKey,mac:e()});b&&(T.preventDefault(),v&&b$1(T.currentTarget).open(v,"_blank","noopener,noreferrer"));};wt.useEffect(()=>{let T=ee.current;if(!T||l)return;let b=a$8(T),v=b$1(T),Fe=Ke=>{Oe(e()?Ke.metaKey:Ke.ctrlKey);},mt=()=>{Oe(false);};return b.addEventListener("keydown",Fe),b.addEventListener("keyup",Fe),v.addEventListener("blur",mt),()=>{b.removeEventListener("keydown",Fe),b.removeEventListener("keyup",Fe),v.removeEventListener("blur",mt),mt();}},[l]),useImperativeHandle(ve,()=>({startMention:()=>{u?.length&&(ee.current?.querySelector("input[role='combobox']")||(ze.exec("insertMentionInput"),Be()));}})),useImperativeHandle(f,()=>({setCaretPosition:T=>{le.setCaretPosition(T);},focus:()=>{le.focus();}}));let Pe=useMemo(()=>({items:u||[],containerRef:c,maxMentionableUsersSuggestions:p}),[u,c,p]),ke=le.isEmpty;return jsx(oo.Provider,{value:Pe,children:jsxs(Qn,{editor:le,children:[jsxs(a$9,{className:a$6(qt,"BaselineUI-Editor-RichEditorToolbar"),"aria-controls":S.id,ref:Re,children:[jsxs(a$a,{display:"flex",flexDirection:"row",role:"group",gap:"xs",paddingX:"sm",children:[jsx(pn,{markName:"bold",icon:BoldIcon,ariaLabel:j??V(ht.bold),isDisabled:l}),jsx(pn,{markName:"italic",icon:ItalicIcon,ariaLabel:N??V(ht.italic),isDisabled:l}),jsx(pn,{markName:"underline",icon:UnderlineIcon,ariaLabel:D??V(ht.underline),isDisabled:l})]}),jsx(a$b,{orientation:"vertical",className:yt}),jsx(to,{colorKey:"color","aria-label":Q??V(ht.fontColor),isDisabled:l}),jsx(a$b,{orientation:"vertical",className:yt}),jsx(to,{colorKey:"backgroundColor","aria-label":U??V(ht.backgroundColor),isDisabled:l}),jsx(a$b,{orientation:"vertical",className:yt}),jsx(li,{isDisabled:l,addLinkLabel:x,editLinkLabel:M,removeLinkLabel:G,linkAnnotationLabel:E,linkCancelLabel:Te,linkSaveLabel:he}),jsx(a$b,{orientation:"vertical",className:yt}),jsx(a$c,{className:it,icon:QuestionmarkCircleIcon,size:"sm","aria-label":pe??V(ht.help),"data-testid":"editor-help-button",onPress:d})]}),jsx(a$b,{variant:"secondary"}),jsxs("div",{style:{position:"relative"},children:[!!(i&&ke)&&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$6(xt({isDisabled:l}),Yo,"BaselineUI-Editor-RichEditorPlaceholder"),children:i}),jsx("div",{...S,onClick:me,"data-mod-held":Qe?"":void 0,"aria-label":a,"aria-placeholder":i,spellCheck:r,style:o,className:a$6(xt({isDisabled:l}),Wt({isInline:s}),"BaselineUI-Editor-RichEditorEditingArea")})]}),Le!==null&&jsx(io,{anchor:Le.anchor,mentionLabel:w,onClose:()=>{De(null);}},Le.id)]})})});ao.displayName="RichEditor";var ht=c({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 fi=wt.memo(wt.forwardRef(({className:t,style:e,"data-block-id":n,"data-block-class":o,enableRichText:r=false,onCancel:i,onSave:s,isInline:l=true,submitButtonIcon:a=ArrowUpCircleFilledIcon,submitButtonAriaLabel:c,cancelButtonAriaLabel:d,"aria-label":u,"aria-describedby":f$1,"aria-labelledby":p,"aria-details":h,editableContentAriaLabel:m="Editing Area",footerButtons:k,clearOnCancel:I,clearOnSave:$,mentionLabel:w,boldLabel:j$1,italicLabel:N,underlineLabel:D,fontColorLabel:Q,backgroundColorLabel:U,helpLabel:pe,closeLabel:x,actionLabel:M,shortcutLabel:G,toolbarFocusLabel:E,selectAllLabel:Te,cutLabel:he,copyLabel:ve,pasteLabel:Re,undoLabel:ee,redoLabel:V,openHelpDialogLabel:Le,submitLabel:De,addLinkLabel:Ne,editLinkLabel:Qe,removeLinkLabel:Oe,linkAnnotationLabel:Be,linkCancelLabel:le,linkSaveLabel:ze,...y},S)=>{let me=useRef(null),{formatMessage:Pe}=b(),ke=useRef(null),T=useRef(null),b$1=useRef(null),v=!r&&y.variant==="minimal",Fe=useRef(null),[mt,Ke]=wt.useState(y.value||y.defaultValue),xn=y.value!==void 0&&y.onChange!==void 0;r&&y.value!==void 0&&!y.onChange&&a$d("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 po=y.value!==void 0&&(!r||xn),yn=y.value;wt.useEffect(()=>{po&&yn!==void 0&&Ke(yn);},[po,yn]);let ho=!b$2(mt||""),bn=y.isDisabled||y.isSaveDisabled||ho,{fieldProps:pi}=a$e({"aria-label":u,"aria-labelledby":p,"aria-describedby":f$1,"aria-details":h,labelElementType:"div"});v&&!y.avatarName&&console.warn("Editor: When using the minimal `variant` and `enableRichText` is `false`, you should provide an `avatarName`.");let En=useCallback(()=>{Ke(""),r?me.current?.setValue("<p></p>",{emit:true}):T.current?.clear();},[r]),It=useCallback(()=>{bn||(s?.(r?me.current?.getValue()??"":ke.current.value),$&&En());},[En,$,r,s,bn]),hi=a$f(ho&&!y.isDisabled,()=>r?me.current?.focus():ke.current?.focus()),mo=jsx(a$c,{variant:"ghost","aria-label":c||Pe(uo.save),icon:a,isDisabled:bn,onFocusChange:hi,"data-testid":"editor-save-button",size:"md",excludeFromTabOrder:v,className:a$6({[er]:v},"BaselineUI-Editor-Save"),onPress:It,preventFocusOnPress:true}),[mi,Tn]=wt.useState(false),{keyboardProps:gi}=j({onKeyDown:W=>{(W.metaKey||W.ctrlKey)&&W.shiftKey&&W.key.toLowerCase()==="h"?(W.preventDefault(),Tn(true)):W.continuePropagation();}}),go=useCallback(W=>{Ke(W),y.onChange?.(W);},[y]);return jsxs("div",{...g$1(pi,r?gi:{}),role:"application",ref:f(b$1,S),style:e,"data-block-id":n,"data-block-class":o,className:a$6(Go({isInline:l,isMinimal:v}),"BaselineUI-Editor",t),"aria-disabled":y.isDisabled,children:[v?jsxs(Fragment,{children:[l?jsx(a$g,{className:$o,name:y.avatarName||""}):null,jsxs("div",{className:nr({isInline:l}),children:[jsx($t,{isMinimal:v,textBoxRef:ke,ref:T,isInline:l,editableContentAriaLabel:m,...y,onChange:go,onSave:It}),mo]})]}):jsxs(Fragment,{children:[r?jsx(ao,{containerRef:b$1,ref:Fe,editorRef:me,isInline:l,editableContentAriaLabel:m,onHelpDialogOpenRequest:()=>{Tn(true);},mentionLabel:w,boldLabel:j$1,italicLabel:N,underlineLabel:D,fontColorLabel:Q,backgroundColorLabel:U,helpLabel:pe,addLinkLabel:Ne,editLinkLabel:Qe,removeLinkLabel:Oe,linkAnnotationLabel:Be,linkCancelLabel:le,linkSaveLabel:ze,...y,value:xn?y.value:void 0,defaultValue:y.defaultValue??(xn?void 0:y.value),onChange:go,onSave:It}):jsxs(Fragment,{children:[!l&&jsx(a$b,{variant:"secondary"}),jsx($t,{onCancel:i,textBoxRef:ke,ref:T,isInline:l,editableContentAriaLabel:m,...y,onChange:W=>{Ke(W),y.onChange?.(W);},onSave:It})]}),jsx(a$b,{variant:"secondary"}),jsxs("div",{className:a$6(qt,sprinkles({justifyContent:"space-between"}),"BaselineUI-Editor-Footer"),children:[jsxs(a$a,{paddingX:"sm",gap:"sm",display:"flex",children:[r&&y.mentionableUsers?jsx(a$c,{icon:AtIcon,size:"sm","aria-label":w??Pe(uo.mention),"data-testid":"editor-mention-button",onPress:()=>Fe.current?.startMention(),preventFocusOnPress:true,className:"BaselineUI-Editor-Mention"}):null,k?.map(({type:W,props:_t},xo)=>W==="action"?jsx(a$c,{..._t,size:"sm",isDisabled:y.isDisabled||_t.isDisabled},xo):jsx(a$h,{..._t,size:"sm",variant:"tertiary",isDisabled:y.isDisabled||_t.isDisabled},xo))]}),jsxs(a$a,{children:[!!i&&jsx(a$c,{variant:"secondary",icon:XCircleFilledIcon,isDisabled:y.isDisabled,"data-testid":"editor-cancel-button",size:"md",onPress:()=>{i(),I&&En();},"aria-label":d||Pe(uo.cancel),className:"BaselineUI-Editor-Cancel"}),mo]})]})]}),jsx(cr,{isOpen:mi,onClose:()=>{Tn(false);},toolbarFocusLabel:E,helpLabel:pe,closeLabel:x,actionLabel:M,shortcutLabel:G,boldLabel:j$1,italicLabel:N,underlineLabel:D,selectAllLabel:Te,cutLabel:he,copyLabel:ve,pasteLabel:Re,undoLabel:ee,redoLabel:V,openHelpDialogLabel:Le,submitLabel:De})]})}));fi.displayName="Editor";var uo=c({cancel:{defaultMessage:"Cancel",id:"bui.editor.cancel"},save:{defaultMessage:"Save",id:"bui.editor.save"},mention:{defaultMessage:"Mention",id:"bui.editor.mention"}});
30
- export{zn as a,J as b,we as c,Ae as d,Lt as e,Se as f,fn as g,Xn as h,ii as i,Jn as j,Qn as k,fi as l};
29
+ `)),s=L([{type:"p",children:[{text:i}]}]);n&&(s=L(Fn(s))),this.exec("insertFragment",s);}}syncFromDom(){if(!this.el||this.composing)return;let e=this.doc,n={doc:e,range:this.selection.range},{doc:o,range:r,overflowed:i}=this.clampToMaxLength(hr(ti(Jt(this.el,xr),e,this.el.ownerDocument),e)),l=ie(o)!==this.lastKnownHtml;if(!l&&!i){r&&this.selection.adopt(r)&&this.emitSelectionChange();return}l&&this.history.record(n,"typing");let a=o,c=r,d=i;if(!c&&n.range){let f=Math.max(A(o)-A(e),0),p=this.pendingMarks.caretOffset??M(e,n.range.anchor),h=P(o,p+f);c={anchor:h,focus:h};}let u=this.pendingMarks.afterInput(e,n.range,o,c);a=u.doc,c=u.range,u.remarked&&(d=true),this.commit(a,c,{type:"native",rerender:d,contentChanged:l});}handleSelectionChange(){if(!this.el)return;let e=a$r(this.el);if(!e)return;let n=Xn(this.el,e);if(!n||!h(this.el,n.startContainer))return;let o=ut(this.el,this.doc),r=this.selection.follow(o);r!=="ignored"&&(this.pendingMarks.onSelectionChange(this.doc,o),r==="changed"&&this.emitSelectionChange());}dispatchCommand(e,n){let o=this.doc,r=this.selection.range??this.collapsedAtDocEnd();switch(e){case "toggleMark":{let[i]=n;return tn(o,r,i)}case "setMarkValue":{let[i,s]=n;return nn(o,r,i,s)}case "wrapLink":{let[i]=n;return Wn(o,r,i)}case "updateLinkUrl":{let[i]=n;return Nr(o,r,i)}case "unwrapLink":return Or(o,r);case "deleteRange":return qe(o,r);case "insertText":{let[i]=n;if(!z(r)){let s=qe(o,r);return kt(s.doc,s.range.focus,i)}return kt(o,r.anchor,i)}case "insertFragment":{let[i]=n;return $n(o,r,i)}case "insertSoftBreak":return Br(o,r);case "insertParagraph":return Fr(o,r);case "insertMentionInput":return Ur(o,r);case "confirmMention":{let[i]=n;return Vr(o,i)}case "removeMentionInput":{let[i,s]=n;return Gn(o,i,s)}default:return {doc:o,range:r}}}collapsedAtDocEnd(){let e=Ie(this.doc);return {anchor:e,focus:e}}};var Lt=Pt.createContext(null);function Le(){let t=Pt.useContext(Lt);if(!t)throw new Error("useEditorContext must be used within an EditorProvider");return t}var pn=Object.freeze({marks:dt,link:null,range:null});function xs(t){let e=je(t.replaceAll(/<br\s*\/?>/gi,"").replaceAll(/<p\s[^>]*>/gi,"<p>"));return e==="<p></p>"||e===""||e==="<p> </p>"}function Jn(t={}){let{value:e,defaultValue:n,doc:o,defaultDoc:r,onChange:i,onDocChange:s,isDisabled:l,keyboardShortcuts:a,onSelectionChange:c,onMentionTrigger:d,onMentionInputRemoved:u,canStartMention:f,resolveMention:p,onPaste:h,onCopy:m,maxLength:R,htmlStyles:I,isReadOnly:$,autoLink:w,enterInsertsParagraph:j}=t;if(e!==void 0&&i===void 0&&a$d("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`."),(e!==void 0||n!==void 0)&&(o!==void 0||r!==void 0)||o!==void 0&&r!==void 0)throw new Error("useEditor: pass at most one of `doc` and `defaultDoc`, and not together with `value` or `defaultValue`.");o!==void 0&&s===void 0&&a$d("use-editor-doc-without-ondocchange","useEditor: `doc` without `onDocChange` is controlled but cannot reflect edits \u2014 they are discarded on the next render. Use `defaultDoc` for initial content, or add `onDocChange`."),Zn(R);let[D,Q]=useState(pn),U=o??r,[he,x]=useState(()=>U?ie(L(U)):e??n??""),k=useMemo(()=>o===void 0?void 0:ie(L(o)),[o]),G=useRef(i);G.current=i;let T=useRef(s);T.current=s;let ve=useRef(c);ve.current=c;let me=useRef(d);me.current=d;let Re=useRef(u);Re.current=u;let ke=useRef(f);ke.current=f;let ee=useRef(p);ee.current=p;let V=useRef(h);V.current=h;let De=useRef(m);De.current=m;let ze=useRef(R);ze.current=R;let Oe=useRef(I);Oe.current=I;let Je=useRef($);Je.current=$;let Be=useRef(l);Be.current=l;let Fe=useRef(a);Fe.current=a;let le=useRef(w);le.current=w;let Pe=useRef(j);Pe.current=j;let y=useRef(null);if(y.current===null){y.current=new St({onChange:C=>{x(C),G.current?.(C);},onDocChange:C=>{T.current?.(C);},onSelectionChange:C=>{Q(C),ve.current?.(C);},onMentionTrigger:()=>{me.current?.();},onMentionInputRemoved:()=>{Re.current?.();},canStartMention:()=>ke.current?.()??false,get resolveMention(){return ee.current},get onPaste(){return V.current},get onCopy(){return De.current},maxLength:()=>ze.current,htmlStyles:()=>Oe.current,autoLink:()=>le.current!==false,isReadOnly:()=>Je.current?.()??!!Be.current,areKeyboardShortcutsEnabled:()=>Fe.current!==false,enterInsertsParagraph:()=>!!Pe.current});let b=e??n;U?y.current.setDoc(U):b&&typeof DOMParser<"u"&&y.current.setValue(b);}let S=y.current;a$i(()=>{o!==void 0?S.setDoc(o):e!==void 0&&S.setValue(e);}),useEffect(()=>{l&&Q(pn);},[l]);let ge=k??e??he,Me=xs(ge),we=S.canUndo(),E=S.canRedo();return useMemo(()=>({core:S,selectionState:D,value:ge,isEmpty:Me,isDisabled:!!l,keyboardShortcuts:a!==false,canUndo:we,canRedo:E,focus:()=>{S.focus();},selectStart:()=>{S.selectStart();},selectEnd:()=>{S.selectEnd();},setCaretPosition:b=>{S.setCaretPosition(b);},undo:()=>{S.undo();},redo:()=>{S.redo();},getValue:()=>S.getValue(),setValue:(b,C)=>{S.setValue(b,C);},getDoc:b=>S.getDoc(b),setDoc:(b,C)=>{S.setDoc(b,C);},selectAll:b=>{S.selectAll(b);},select:(b,C)=>{S.select(b,C);},getSelectionState:()=>S.getSelectionState(),exec:(b,...C)=>{S.exec(b,...C);},isMarkActive:b=>!!D.marks[b],toggleMark:b=>{S.exec("toggleMark",b);},setMark:(b,C)=>{S.exec("setMarkValue",b,C);}}),[S,D,ge,Me,l,a,we,E])}function si(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 eo(t,e={}){let n=vs(t),{ref:o,autoFocus:r,onKeyDown:i,keyboardShortcuts:s}=e,l=s??n.keyboardShortcuts,a=useId(),c=useRef(null),d=useRef(null),u=useCallback(m=>{d.current&&(d.current(),d.current=null),m&&(d.current=n.core.attach(m));},[n.core]),f$1=useMemo(()=>f(c,u,o??null),[u,o]);useEffect(()=>(n.core.setKeyboardShortcutsEnabled(s),()=>{n.core.setKeyboardShortcutsEnabled(void 0);}),[n.core,s]);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:h}=j({onKeyDown:m=>{i?.(m)||l&&si(m,n)||m.continuePropagation();}});return {editableProps:{...h,id:a,ref:f$1,contentEditable:!n.isDisabled,suppressContentEditableWarning:true,role:"textbox","aria-multiline":true,"data-editor-root":"true"}}}function vs(t){let e=useContext(Lt);if(t)return t;if(!e)throw new Error("useEditable must be passed an editor or used within an EditorProvider");return e}var to=({editor:t,children:e})=>jsx(Lt.Provider,{value:t,children:e});var hn=({markName:t,icon:e,ariaLabel:n,isDisabled:o})=>{let{core:r,selectionState:i}=Le(),s=!!i.marks[t];return jsx(a$h,{variant:"tertiary",isSelected:s,size:"sm",icon:e,"aria-label":n,"data-testid":`editor-${t}-button`,isDisabled:o,onPress:()=>{r.exec("toggleMark",t),r.focus();},preventFocusOnPress:true})},oo=({colorKey:t,"aria-label":e,isDisabled:n})=>{let{core:o,selectionState:r}=Le(),i=t==="color"?r.marks.color:r.marks.backgroundColor,s=Pt.useRef(null),l=useCallback(()=>{s.current=r.range;},[r.range]),a=useCallback(p=>{setTimeout(()=>{let h=o.getSelectionState().range??s.current;h&&o.select(h),o.exec("setMarkValue",t,p);},0);},[o,t]),c=useCallback(p=>{a(p);},[a]),d=useCallback(()=>{a();},[a]),u=useCallback(({ref:p,triggerProps:h})=>jsx(a$c,{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:it,preventFocusOnPress:true,...h,ref:p}),[t,e,n]),f=useCallback(p=>{p?c(p.toString("rgba")):d();},[d,c]);return jsx(b$3,{presets:Sn,allowRemoval:true,pickerMode:"lazy",placement:"top end",colorLabel:false,renderTriggerButton:u,onTriggerPress:l,value:i||"#000000",onChange:f,isDisabled:n})};var Ye={Add:"add",Edit:"edit",Show:"show"},ai=({isDisabled:t,addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:s})=>{let{formatMessage:l}=b(),{core:a}=Le();return jsxs(b$4,{type:"dialog",children:[jsx(j$1,{children:jsx(a$c,{icon:LinkIcon,size:"sm",isDisabled:t,"aria-label":e??l(Xe.addLink),"data-testid":"editor-add-link-button",className:it,preventFocusOnPress:true})}),jsx(a$j,{className:sprinkles({boxShadow:"medium"}),placement:"top end",children:({close:c})=>jsx(a$k,{size:"content",style:{minWidth:240},children:jsx(Ds,{addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:s,close:()=>{c(),setTimeout(()=>{a.focus();},0);}})})})]})},Ds=({close:t,addLinkLabel:e,editLinkLabel:n,removeLinkLabel:o,linkAnnotationLabel:r,linkCancelLabel:i,linkSaveLabel:s})=>{let{core:l,selectionState:a}=Le(),{formatMessage:c}=b(),d=a.link?.url,[u,f]=Pt.useState(d?Ye.Show:Ye.Add),[p,h]=Pt.useState(d||""),m=jsx(a$a,{padding:"lg",children:jsx(a$s,{label:r??c(Xe.link),value:p,autoFocus:true,onChange:h,placeholder:"https://yourdomain.com","data-testid":"editor-link-input"})});return jsxs(Fragment,{children:[u===Ye.Add&&jsxs(Fragment,{children:[m,jsx(a$a,{display:"flex",justifyContent:"flex-end",padding:"lg",className:$o,children:jsx(b$9,{isDisabled:!a$t(p,true)||be(p)==="",label:e??c(Xe.addLink),"data-testid":"editor-link-add-button",size:"sm",onPress:()=>{l.exec("wrapLink",On(p)),t?.();},preventFocusOnPress:true})})]}),u===Ye.Show&&jsxs(Fragment,{children:[jsx(a$a,{padding:"lg",children:jsx(a$p,{type:"subtitle",size:"sm",children:d})}),jsxs(a$a,{display:"flex",justifyContent:"flex-end",padding:"lg",gap:"lg",borderColor:"border.subtle",borderWidth:1,borderStyle:"solid",children:[jsx(b$9,{label:n??c(Xe.editLink),"data-testid":"editor-link-edit-button",size:"sm",variant:"secondary",onPress:()=>{f(Ye.Edit);},style:{flex:1,justifyContent:"center"}}),jsx(b$9,{label:o??c(Xe.removeLink),"data-testid":"editor-link-remove-button",size:"sm",onPress:()=>{l.exec("unwrapLink"),t?.();},preventFocusOnPress:true,style:{flex:1,justifyContent:"center"}})]})]}),u===Ye.Edit&&jsxs(Fragment,{children:[m,jsxs(a$a,{display:"flex",justifyContent:"flex-end",padding:"lg",gap:"lg",borderColor:"border.subtle",borderWidth:1,borderStyle:"solid",children:[jsx(b$9,{label:i??c(Xe.cancel),"data-testid":"editor-link-cancel-button",size:"sm",variant:"secondary",onPress:()=>{f(Ye.Show),t?.();}}),jsx(b$9,{label:s??c(Xe.save),"data-testid":"editor-link-save-button",size:"sm",isDisabled:!a$t(p,true)||be(p)==="",onPress:()=>{l.exec("updateLinkUrl",On(p)),t?.();}})]})]})]})},Xe=c({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 io=Pt.createContext({items:[],containerRef:{current:null},maxMentionableUsersSuggestions:10}),Ns=({key:t,value:e},{isDisabled:n,optionProps:o,isFocused:r,_state:i},s)=>{let{hoverProps:l}=a$4({isDisabled:n}),{label:a,data:c}=e;return jsxs(Fragment,{children:[jsxs("li",{...g$1(o,l),className:er({isDisabled:n,isHovered:r}),"data-active":r||void 0,ref:s,children:[jsx(a$a,{elementType:"span",display:"flex","aria-hidden":true,children:jsx(a$g,{name:a,...c?.avatar})}),jsxs(a$a,{display:"flex",flexDirection:"column",children:[jsx(a$p,{type:"subtitle",size:"sm",children:a}),jsx(a$p,{type:"helper",size:"sm",children:c?.description})]})]}),t===i.collection.getLastKey()?null:jsx(a$b,{})]})};function ro(t){return t.displayName?.trim()||t.name?.trim()||t.id}function so(t){return t.displayName??ro(t)}function lo({anchor:t,onClose:e,mentionLabel:n}){let{core:o}=Le(),{containerRef:r,items:i,maxMentionableUsersSuggestions:s}=useContext(io),[l,a]=useState(""),{contains:c}=a$l({sensitivity:"base"}),{formatMessage:d}=b(),u=useRef(false),f=useCallback(()=>{u.current=true,e();},[e]),p=useMemo(()=>{let x=i.filter(k=>l===""||c(ro(k),l)).map(k=>({id:k.id,label:ro(k),data:k}));return s?x.slice(0,s):x},[i,s,l,c]),h=useCallback(x=>jsx(a$m,{textValue:x.label,children:x.label},x.id),[]),m=useCallback(x=>{if(u.current||x==null)return;let k=i.find(G=>G.id===x);k&&(f(),o.exec("confirmMention",{id:k.id,displayName:so(k)}),o.exec("insertText"," "),o.focus());},[f,o,i]),R=b$5({items:p,children:h,menuTrigger:"focus",onSelectionChange:m}),I=useCallback(x=>{if(u.current)return;f();let k=x==="backspace"?"":`@${R.inputValue}`;o.exec("removeMentionInput",k,x==="arrowStart"?"start":"end"),o.focus();},[f,o,R.inputValue]),$=useRef(null),w=useRef(null),j=useRef(null),N=useRef(null);a$n({ref:N,onInteractOutside:()=>{R.close();}});let{inputProps:D,listBoxProps:Q}=a$o({defaultItems:p,inputRef:w,buttonRef:$,listBoxRef:j,popoverRef:N,menuTrigger:"focus","aria-label":n??d(Os.mention)},R);useLayoutEffect(()=>{w.current?.focus(),setTimeout(()=>{w.current?.focus();});},[]);let U=useCallback(x=>{let k=x.currentTarget,G=k.selectionStart===0&&k.selectionEnd===0,T=k.selectionStart===k.value.length&&k.selectionEnd===k.value.length;if(x.key==="Backspace"&&G)x.preventDefault(),I("backspace");else if(x.key==="Escape")I("escape");else if(x.key==="ArrowLeft"||x.key==="ArrowRight"){let ee=V=>x.key==="ArrowLeft"!=(b$1(V).getComputedStyle(V).direction==="rtl");(ee(k)?G:T)&&(x.preventDefault(),I(ee(t)?"arrowStart":"arrowEnd"));}let ve=x.metaKey||x.ctrlKey,me=x.key.toLowerCase(),Re=ve&&!x.shiftKey&&me==="z"&&o.canUndo(),ke=(ve&&x.shiftKey&&me==="z"||x.ctrlKey&&me==="y")&&o.canRedo();(Re||ke)&&(x.preventDefault(),Re?o.undo():o.redo(),f(),o.focus());},[t,I,f,o]),he=useMemo(()=>{if(!CSS.supports("field-sizing","content")){let x=b$1(w.current),k=w.current?x?.getComputedStyle(w.current).font:void 0;return {width:k?b$6({text:R.inputValue,font:k,element:w.current}).width+10:"4ch"}}},[R.inputValue]);return jsxs(Fragment,{children:[createPortal(jsx("input",{...g$1(D,{onKeyDown:U,onBlur:()=>{I("blur");},onChange:x=>{a(x.target.value);}}),style:he,dir:/\p{L}/u.test(R.inputValue)?"auto":void 0,className:Qo,ref:w}),t),jsx(b$7.Provider,{value:R,children:jsx(a$j,{triggerRef:r,isNonModal:true,ref:N,state:R,crossOffset:-2,children:jsx(c$1,{...Q,items:void 0,ref:j,"data-testid":"editor-mention-listbox",className:a$6(f$1,sprinkles({width:"full"})),renderOption:Ns})})})]})}lo.displayName="MentionInputOverlay";var Os=c({mention:{defaultMessage:"Mention",id:"bui.editor.mention"}});var uo=Pt.forwardRef(({value:t,defaultValue:e$1,onChange:n,style:o,spellCheck:r,placeholder:i,isInline:s,isDisabled:l,editableContentAriaLabel:a,containerRef:c,onHelpDialogOpenRequest:d,mentionableUsers:u,editorHandle:f,maxMentionableUsersSuggestions:p,autoFocus:h,editorRef:m,saveOnEnter:R,onSave:I,autoLink:$,mentionLabel:w,boldLabel:j,italicLabel:N,underlineLabel:D,fontColorLabel:Q,backgroundColorLabel:U,helpLabel:he,addLinkLabel:x,editLinkLabel:k,removeLinkLabel:G,linkAnnotationLabel:T,linkCancelLabel:ve,linkSaveLabel:me},Re)=>{let ke=useRef(null),ee=useRef(null),{formatMessage:V}=b(),[De,ze]=useState(null),Oe=useRef(0),[Je,Be]=useState(false),Fe=()=>{let E=ee.current?.querySelector("[data-mention-anchor]");E&&(Oe.current+=1,ze({anchor:E,id:Oe.current}));},le=Jn({value:t,defaultValue:e$1,onChange:n,isDisabled:l,onMentionTrigger:Fe,onMentionInputRemoved:()=>{ze(null);},canStartMention:()=>(u?.length??0)>0,resolveMention:E=>{let b=u?.find(C=>C.id===E);return b&&so(b)},autoLink:$}),Pe=le.core;Pt.useEffect(()=>{m&&(m.current=Pe);},[Pe,m]);let y=E=>a$2(E)?false:R&&E.key==="Enter"&&!E.shiftKey||(E.ctrlKey||E.metaKey)&&E.key==="Enter"?(E.preventDefault(),I(),true):E.altKey&&E.key==="F10"?(E.preventDefault(),ke.current?.querySelector("button")?.focus(),true):false,{editableProps:S}=eo(le,{ref:ee,autoFocus:h,onKeyDown:y}),ge=E=>{if(l)return;let{isLinkClick:b,url:C}=vr(E.target,{metaKey:E.metaKey,ctrlKey:E.ctrlKey,mac:e()});b&&(E.preventDefault(),C&&b$1(E.currentTarget).open(C,"_blank","noopener,noreferrer"));};Pt.useEffect(()=>{let E=ee.current;if(!E||l)return;let b=a$8(E),C=b$1(E),ae=At=>{Be(e()?At.metaKey:At.ctrlKey);},Qe=()=>{Be(false);};return b.addEventListener("keydown",ae),b.addEventListener("keyup",ae),C.addEventListener("blur",Qe),()=>{b.removeEventListener("keydown",ae),b.removeEventListener("keyup",ae),C.removeEventListener("blur",Qe),Qe();}},[l]),useImperativeHandle(Re,()=>({startMention:()=>{u?.length&&(ee.current?.querySelector("input[role='combobox']")||(Pe.exec("insertMentionInput"),Fe()));}})),useImperativeHandle(f,()=>({setCaretPosition:E=>{le.setCaretPosition(E);},focus:()=>{le.focus();}}));let Me=useMemo(()=>({items:u||[],containerRef:c,maxMentionableUsersSuggestions:p}),[u,c,p]),we=le.isEmpty;return jsx(io.Provider,{value:Me,children:jsxs(to,{editor:le,children:[jsxs(a$9,{className:a$6($t,"BaselineUI-Editor-RichEditorToolbar"),"aria-controls":S.id,ref:ke,children:[jsxs(a$a,{display:"flex",flexDirection:"row",role:"group",gap:"xs",paddingX:"sm",children:[jsx(hn,{markName:"bold",icon:BoldIcon,ariaLabel:j??V(ht.bold),isDisabled:l}),jsx(hn,{markName:"italic",icon:ItalicIcon,ariaLabel:N??V(ht.italic),isDisabled:l}),jsx(hn,{markName:"underline",icon:UnderlineIcon,ariaLabel:D??V(ht.underline),isDisabled:l})]}),jsx(a$b,{orientation:"vertical",className:xt}),jsx(oo,{colorKey:"color","aria-label":Q??V(ht.fontColor),isDisabled:l}),jsx(a$b,{orientation:"vertical",className:xt}),jsx(oo,{colorKey:"backgroundColor","aria-label":U??V(ht.backgroundColor),isDisabled:l}),jsx(a$b,{orientation:"vertical",className:xt}),jsx(ai,{isDisabled:l,addLinkLabel:x,editLinkLabel:k,removeLinkLabel:G,linkAnnotationLabel:T,linkCancelLabel:ve,linkSaveLabel:me}),jsx(a$b,{orientation:"vertical",className:xt}),jsx(a$c,{className:it,icon:QuestionmarkCircleIcon,size:"sm","aria-label":he??V(ht.help),"data-testid":"editor-help-button",onPress:d})]}),jsx(a$b,{variant:"secondary"}),jsxs("div",{style:{position:"relative"},children:[!!(i&&we)&&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$6(gt({isDisabled:l}),Xo,"BaselineUI-Editor-RichEditorPlaceholder"),children:i}),jsx("div",{...S,onClick:ge,"data-mod-held":Je?"":void 0,"aria-label":a,"aria-placeholder":i,spellCheck:r,style:o,className:a$6(gt({isDisabled:l}),qt({isInline:s}),"BaselineUI-Editor-RichEditorEditingArea")})]}),De!==null&&jsx(lo,{anchor:De.anchor,mentionLabel:w,onClose:()=>{ze(null);}},De.id)]})})});uo.displayName="RichEditor";var ht=c({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 pi=Pt.memo(Pt.forwardRef(({className:t,style:e,"data-block-id":n,"data-block-class":o,enableRichText:r=false,onCancel:i,onSave:s,isInline:l=true,submitButtonIcon:a=ArrowUpCircleFilledIcon,submitButtonAriaLabel:c,cancelButtonAriaLabel:d,"aria-label":u,"aria-describedby":f$1,"aria-labelledby":p,"aria-details":h,editableContentAriaLabel:m,footerButtons:R,clearOnCancel:I,clearOnSave:$,mentionLabel:w,boldLabel:j$1,italicLabel:N,underlineLabel:D,fontColorLabel:Q,backgroundColorLabel:U,helpLabel:he,closeLabel:x,actionLabel:k,shortcutLabel:G,toolbarFocusLabel:T,selectAllLabel:ve,cutLabel:me,copyLabel:Re,pasteLabel:ke,undoLabel:ee,redoLabel:V,openHelpDialogLabel:De,submitLabel:ze,addLinkLabel:Oe,editLinkLabel:Je,removeLinkLabel:Be,linkAnnotationLabel:Fe,linkCancelLabel:le,linkSaveLabel:Pe,...y},S)=>{let ge=useRef(null),{formatMessage:Me}=b(),we=m===void 0?Me(yn.editingArea):m,E=useRef(null),b$1=useRef(null),C=useRef(null),ae=!r&&y.variant==="minimal",Qe=useRef(null),[At,It]=Pt.useState(y.value||y.defaultValue),bn=y.value!==void 0&&y.onChange!==void 0;r&&y.value!==void 0&&!y.onChange&&a$d("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 ho=y.value!==void 0&&(!r||bn),En=y.value;Pt.useEffect(()=>{ho&&En!==void 0&&It(En);},[ho,En]);let mo=!b$2(At||""),Tn=y.isDisabled||y.isSaveDisabled||mo,{fieldProps:hi}=a$e({"aria-label":u,"aria-labelledby":p,"aria-describedby":f$1,"aria-details":h,labelElementType:"div"});ae&&!y.avatarName&&console.warn("Editor: When using the minimal `variant` and `enableRichText` is `false`, you should provide an `avatarName`.");let vn=useCallback(()=>{It(""),r?ge.current?.setValue("<p></p>",{emit:true}):b$1.current?.clear();},[r]),_t=useCallback(()=>{Tn||(s?.(r?ge.current?.getValue()??"":E.current.value),$&&vn());},[vn,$,r,s,Tn]),mi=a$f(mo&&!y.isDisabled,()=>r?ge.current?.focus():E.current?.focus()),go=jsx(a$c,{variant:"ghost","aria-label":c||Me(yn.save),icon:a,isDisabled:Tn,onFocusChange:mi,"data-testid":"editor-save-button",size:"md",excludeFromTabOrder:ae,className:a$6({[tr]:ae},"BaselineUI-Editor-Save"),onPress:_t,preventFocusOnPress:true}),[gi,Rn]=Pt.useState(false),{keyboardProps:xi}=j({onKeyDown:W=>{(W.metaKey||W.ctrlKey)&&W.shiftKey&&W.key.toLowerCase()==="h"?(W.preventDefault(),Rn(true)):W.continuePropagation();}}),xo=useCallback(W=>{It(W),y.onChange?.(W);},[y]);return jsxs("div",{...g$1(hi,r?xi:{}),role:"application",ref:f(C,S),style:e,"data-block-id":n,"data-block-class":o,className:a$6(Yo({isInline:l,isMinimal:ae}),"BaselineUI-Editor",t),"aria-disabled":y.isDisabled,children:[ae?jsxs(Fragment,{children:[l?jsx(a$g,{className:Go,name:y.avatarName||""}):null,jsxs("div",{className:or({isInline:l}),children:[jsx(Gt,{isMinimal:ae,textBoxRef:E,ref:b$1,isInline:l,editableContentAriaLabel:we,...y,onChange:xo,onSave:_t}),go]})]}):jsxs(Fragment,{children:[r?jsx(uo,{containerRef:C,ref:Qe,editorRef:ge,isInline:l,editableContentAriaLabel:we,onHelpDialogOpenRequest:()=>{Rn(true);},mentionLabel:w,boldLabel:j$1,italicLabel:N,underlineLabel:D,fontColorLabel:Q,backgroundColorLabel:U,helpLabel:he,addLinkLabel:Oe,editLinkLabel:Je,removeLinkLabel:Be,linkAnnotationLabel:Fe,linkCancelLabel:le,linkSaveLabel:Pe,...y,value:bn?y.value:void 0,defaultValue:y.defaultValue??(bn?void 0:y.value),onChange:xo,onSave:_t}):jsxs(Fragment,{children:[!l&&jsx(a$b,{variant:"secondary"}),jsx(Gt,{onCancel:i,textBoxRef:E,ref:b$1,isInline:l,editableContentAriaLabel:we,...y,onChange:W=>{It(W),y.onChange?.(W);},onSave:_t})]}),jsx(a$b,{variant:"secondary"}),jsxs("div",{className:a$6($t,sprinkles({justifyContent:"space-between"}),"BaselineUI-Editor-Footer"),children:[jsxs(a$a,{paddingX:"sm",gap:"sm",display:"flex",children:[r&&y.mentionableUsers?jsx(a$c,{icon:AtIcon,size:"sm","aria-label":w??Me(yn.mention),"data-testid":"editor-mention-button",onPress:()=>Qe.current?.startMention(),preventFocusOnPress:true,className:"BaselineUI-Editor-Mention"}):null,R?.map(({type:W,props:Nt},yo)=>W==="action"?jsx(a$c,{...Nt,size:"sm",isDisabled:y.isDisabled||Nt.isDisabled},yo):jsx(a$h,{...Nt,size:"sm",variant:"tertiary",isDisabled:y.isDisabled||Nt.isDisabled},yo))]}),jsxs(a$a,{children:[!!i&&jsx(a$c,{variant:"secondary",icon:XCircleFilledIcon,isDisabled:y.isDisabled,"data-testid":"editor-cancel-button",size:"md",onPress:()=>{i(),I&&vn();},"aria-label":d||Me(yn.cancel),className:"BaselineUI-Editor-Cancel"}),go]})]})]}),jsx(dr,{isOpen:gi,onClose:()=>{Rn(false);},toolbarFocusLabel:T,helpLabel:he,closeLabel:x,actionLabel:k,shortcutLabel:G,boldLabel:j$1,italicLabel:N,underlineLabel:D,selectAllLabel:ve,cutLabel:me,copyLabel:Re,pasteLabel:ke,undoLabel:ee,redoLabel:V,openHelpDialogLabel:De,submitLabel:ze})]})}));pi.displayName="Editor";var yn=c({editingArea:{defaultMessage:"Editing Area",id:"bui.editor.editingArea"},cancel:{defaultMessage:"Cancel",id:"bui.editor.cancel"},save:{defaultMessage:"Save",id:"bui.editor.save"},mention:{defaultMessage:"Mention",id:"bui.editor.mention"}});
30
+ export{wn as a,J as b,Ae as c,Ie as d,St as e,Le as f,pn as g,Jn as h,si as i,eo as j,to as k,pi as l};
@@ -0,0 +1,10 @@
1
+ import {a as a$m}from'./chunk-WDWBYTJG.mjs';import {a as a$a}from'./chunk-Q7BJGV4I.mjs';import {a as a$3}from'./chunk-SVV6DLJH.mjs';import {a as a$c,b as b$4}from'./chunk-BJHDL2HH.mjs';import {b as b$5,c as c$3}from'./chunk-OY57K37D.mjs';import {a as a$2}from'./chunk-KT4FTBJ2.mjs';import {a as a$7,b as b$3,g,d,e as e$1,f,h as h$2}from'./chunk-FFPJBDWH.mjs';import {a as a$g}from'./chunk-SL5Q4NLV.mjs';import {b as b$1}from'./chunk-I4F5NJUI.mjs';import {i,l,p,j,n,k,h as h$1,d as d$1,g as g$2,a as a$i}from'./chunk-4Y5IKZSW.mjs';import {a as a$n}from'./chunk-NHVS56EF.mjs';import {a as a$o}from'./chunk-QMP72J5L.mjs';import {c as c$2,b as b$7}from'./chunk-WBLMAN7U.mjs';import {a as a$k}from'./chunk-DIL5HL6K.mjs';import {a as a$l}from'./chunk-HN2XJOQL.mjs';import {a as a$6}from'./chunk-TZSRU3GG.mjs';import {a}from'./chunk-USMC34OO.mjs';import {b as b$6}from'./chunk-KG2EHFYA.mjs';import {b}from'./chunk-N2XGJKZG.mjs';import {a as a$b}from'./chunk-I5YPTKMM.mjs';import {a as a$d}from'./chunk-NQIZ3U7Q.mjs';import {e,c,h,b as b$2,a as a$e}from'./chunk-EKRT3PPK.mjs';import {k as k$1,l as l$1}from'./chunk-JANI446W.mjs';import {a as a$j}from'./chunk-BPXZ6J5G.mjs';import {a as a$1}from'./chunk-FPM5UJRF.mjs';import {a as a$4}from'./chunk-ELW6SXDM.mjs';import {a as a$9}from'./chunk-LRFFL765.mjs';import {a as a$8}from'./chunk-RT4LMB6X.mjs';import {g as g$1,c as c$1,f as f$1}from'./chunk-V2C4UDOC.mjs';import {a as a$5}from'./chunk-SVIYLH7R.mjs';import {a as a$f}from'./chunk-JQQGRJ5J.mjs';import {a as a$h}from'./chunk-4QEH5CGK.mjs';import Bt,{createContext,forwardRef,useRef,useEffect,useContext,useState,useMemo,useCallback,isValidElement}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {ChevronRightIcon}from'@baseline-ui/icons/8';import {DragIndicatorIcon}from'@baseline-ui/icons/12';import {themeVars,sprinkles}from'@baseline-ui/tokens';/**
2
+ * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
+ *
4
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
5
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
6
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
7
+ * This notice may not be removed from this file.
8
+ *
9
+ */
10
+ function he(r,o,e){let{gridProps:t}=b$5(r,o,e);return t.role="treegrid",{gridProps:t}}var xt={"ar-AE":{collapse:"\u0637\u064A",expand:"\u062A\u0645\u062F\u064A\u062F"},"bg-BG":{collapse:"\u0421\u0432\u0438\u0432\u0430\u043D\u0435",expand:"\u0420\u0430\u0437\u0448\u0438\u0440\u044F\u0432\u0430\u043D\u0435"},"cs-CZ":{collapse:"Sbalit",expand:"Rozt\xE1hnout"},"da-DK":{collapse:"Skjul",expand:"Udvid"},"de-DE":{collapse:"Reduzieren",expand:"Erweitern"},"el-GR":{collapse:"\u03A3\u03CD\u03BC\u03C0\u03C4\u03C5\u03BE\u03B7",expand:"\u0391\u03BD\u03AC\u03C0\u03C4\u03C5\u03BE\u03B7"},"en-US":{expand:"Expand",collapse:"Collapse"},"es-ES":{collapse:"Contraer",expand:"Expandir"},"et-EE":{collapse:"Ahenda",expand:"Laienda"},"fi-FI":{collapse:"Pienenn\xE4",expand:"Laajenna"},"fr-FR":{collapse:"R\xE9duire",expand:"D\xE9velopper"},"he-IL":{collapse:"\u05DB\u05D5\u05D5\u05E5",expand:"\u05D4\u05E8\u05D7\u05D1"},"hr-HR":{collapse:"Sa\u017Emi",expand:"Pro\u0161iri"},"hu-HU":{collapse:"\xD6sszecsuk\xE1s",expand:"Kibont\xE1s"},"it-IT":{collapse:"Comprimi",expand:"Espandi"},"ja-JP":{collapse:"\u6298\u308A\u305F\u305F\u3080",expand:"\u5C55\u958B"},"ko-KR":{collapse:"\uC811\uAE30",expand:"\uD3BC\uCE58\uAE30"},"lt-LT":{collapse:"Sutraukti",expand:"I\u0161skleisti"},"lv-LV":{collapse:"Sak\u013Caut",expand:"Izv\u0113rst"},"nb-NO":{collapse:"Skjul",expand:"Utvid"},"nl-NL":{collapse:"Samenvouwen",expand:"Uitvouwen"},"pl-PL":{collapse:"Zwi\u0144",expand:"Rozwi\u0144"},"pt-BR":{collapse:"Recolher",expand:"Expandir"},"pt-PT":{collapse:"Colapsar",expand:"Expandir"},"ro-RO":{collapse:"Restr\xE2nge\u021Bi",expand:"Extinde\u021Bi"},"ru-RU":{collapse:"\u0421\u0432\u0435\u0440\u043D\u0443\u0442\u044C",expand:"\u0420\u0430\u0437\u0432\u0435\u0440\u043D\u0443\u0442\u044C"},"sk-SK":{collapse:"Zbali\u0165",expand:"Rozbali\u0165"},"sl-SI":{collapse:"Strni",expand:"Raz\u0161iri"},"sr-SP":{collapse:" Skupi",expand:"Pro\u0161iri"},"sv-SE":{collapse:"D\xF6lj",expand:"Expandera"},"tr-TR":{collapse:"Daralt",expand:"Geni\u015Flet"},"uk-UA":{collapse:"\u0417\u0433\u043E\u0440\u043D\u0443\u0442\u0438",expand:"\u0420\u043E\u0437\u0433\u043E\u0440\u043D\u0443\u0442\u0438"},"zh-CN":{collapse:"\u6298\u53E0",expand:"\u6269\u5C55"},"zh-TW":{collapse:"\u6536\u5408",expand:"\u5C55\u958B"}};function ue(r,o,e){let{node:t}=r,n=c$3(r,o,e),i=n.rowProps["aria-expanded"]===true,s=b$6(xt,"@react-aria/tree"),u=a$j({"aria-label":i?s.format("collapse"):s.format("expand"),"aria-labelledby":n.rowProps.id}),p={onPress:()=>{n.isDisabled||(o.toggleKey(t.key),o.selectionManager.setFocused(true),o.selectionManager.setFocusedKey(t.key));},excludeFromTabOrder:true,preventFocusOnPress:true,"data-react-aria-prevent-focus":true,...u};return {...n,expandButtonProps:p}}var Pe=class r extends g$2{expandedKeys=new Set;withExpandedKeys(o,e){let t=this.clone();return t.expandedKeys=e,r.cloneAncestorSections(e,o,t),r.cloneAncestorSections(o,e,t),t.frozen=this.frozen,t}static cloneAncestorSections(o,e,t){for(let n of o)if(!e.has(n)){let i=n;for(;i!=null;){let s=t.getItem(i);if(s?.type==="section"){t.keyMap.set(i,s.clone());break}else i=s?.parentKey??null;}}}*[Symbol.iterator](){let o=this.getFirstKey(),e=o!=null?this.getItem(o):null;for(;e;)if(yield e,e.type==="section")e=e.nextKey!=null?this.getItem(e.nextKey):null;else {let t=this.getKeyAfter(e.key);e=t!=null?this.getItem(t):null;}}getLastKey(){let o=this.lastKey;if(o==null)return null;let e=this.getItem(o);for(;e?.lastChildKey!=null&&(e.type!=="item"||this.expandedKeys.has(e.key));)e=this.getItem(e.lastChildKey);return e?.key}getKeyAfter(o){let e=this.getItem(o);if(!e)return null;if((this.expandedKeys.has(e.key)||e.type!=="item")&&e.firstChildKey!=null)return e.firstChildKey;for(;e;){if(e.nextKey!=null)return e.nextKey;if(e.parentKey!=null)e=this.getItem(e.parentKey);else return null}return null}getKeyBefore(o){let e=this.getItem(o);if(!e)return null;if(e.prevKey!=null){for(e=this.getItem(e.prevKey);e&&(e.type!=="item"||this.expandedKeys.has(e.key))&&e.lastChildKey!=null;)e=this.getItem(e.lastChildKey);return e?.key??null}return e.parentKey}getChildren(o){let e=this;return {*[Symbol.iterator](){let t=e.getItem(o),n=t?.firstChildKey!=null?e.getItem(t.firstChildKey):null;if(t&&t.type==="section"&&n)for(;n&&n.key!==t.nextKey;){yield e.getItem(n.key);let i=e.getKeyAfter(n.key);n=i!=null?e.getItem(i):null;}else for(;n;)yield n,n=n.nextKey!=null?e.getItem(n.nextKey):null;}}}getTextValue(o){let e=this.getItem(o);return e?e.textValue:""}},ht=createContext(null),ge=createContext(null),Re=forwardRef(function(o,e$1){return [o,e$1]=e(o,e$1,ht),jsx(i,{content:jsx(l,{...o}),createCollection:()=>new Pe,children:t=>jsx(zt,{props:o,collection:t,treeRef:e$1})})}),bt={expand:{ltr:"ArrowRight",rtl:"ArrowLeft"},collapse:{ltr:"ArrowLeft",rtl:"ArrowRight"}};function zt({props:r,collection:o,treeRef:e}){let{dragAndDropHooks:t}=r,{direction:n}=b(),i=a({usage:"search",sensitivity:"base"}),s=!!t?.useDraggableCollectionState,u=!!t?.useDroppableCollectionState,p$1=useRef(s),x=useRef(u);useEffect(()=>{p$1.current!==s&&console.warn("Drag hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior."),x.current!==u&&console.warn("Drop hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.");},[s,u]);let{selectionMode:y="none",expandedKeys:L,defaultExpandedKeys:f,onExpandedChange:b$4,disabledBehavior:g$2="all"}=r,{CollectionRoot:D,isVirtualized:h$1,layoutDelegate:T,dropTargetDelegate:K}=useContext(p),[P,I]=a$1(L?new Set(L):void 0,f?new Set(f):new Set,b$4),[v,H]=useState(o),[C,w]=useState(P),[R,M]=useState(()=>o.withExpandedKeys(C,P));(!qt(C,P)||o!==v)&&(M(o.withExpandedKeys(C,P)),H(o),w(P));let l=a$2({...r,selectionMode:y,expandedKeys:P,onExpandedChange:I,collection:R,children:void 0,disabledBehavior:g$2}),{gridProps:N}=he({...r,isVirtualized:h$1,layoutDelegate:T},l,e),a$8,c$1,k,m=false,j=null,O=useRef(null);if(s&&t){a$8=t.useDraggableCollectionState({collection:l.collection,selectionManager:l.selectionManager,preview:t.renderDragPreview?O:void 0}),t.useDraggableCollection({},a$8,e);let re=t.DragPreview;j=t.renderDragPreview?jsx(re,{ref:O,children:t.renderDragPreview}):null;}let[J]=useState(()=>new a$3);if(u&&t){c$1=t.useDroppableCollectionState({collection:l.collection,selectionManager:l.selectionManager});let re=t.dropTargetDelegate||K||new t.ListDropTargetDelegate(l.collection,e,{direction:n});J.setup(re,l,n);let Te=new b$1({collection:l.collection,collator:i,ref:e,disabledKeys:l.selectionManager.disabledKeys,disabledBehavior:l.selectionManager.disabledBehavior,direction:n,layoutDelegate:T});k=t.useDroppableCollection({keyboardDelegate:Te,dropTargetDelegate:J,onDropActivate:V=>{if(V.target.type==="item"){let S=V.target.key,$=l.collection.getItem(S),Ot=P.has(S);$&&$.hasChildNodes&&(!Ot||t?.isVirtualDragging?.())&&l.toggleKey(S);}},onKeyDown:V=>{let S=c$1?.target;if(S&&S.type==="item"&&S.dropPosition==="on"){let $=l.collection.getItem(S.key);(V.key===bt.expand[n]&&$?.hasChildNodes&&!l.expandedKeys.has(S.key)||V.key===bt.collapse[n]&&$?.hasChildNodes&&l.expandedKeys.has(S.key))&&l.toggleKey(S.key);}}},c$1,e),m=c$1.isDropTarget({type:"root"});}let ee=!!(s&&!a$8?.isDisabled),{focusProps:te,isFocused:U,isFocusVisible:X}=a$4(),B={isEmpty:l.collection.size===0,isFocused:U,isFocusVisible:X,isDropTarget:m,selectionMode:l.selectionManager.selectionMode,allowsDragging:!!ee,state:l},Nt=c({...r,children:void 0,defaultClassName:"react-aria-Tree",values:B}),Ae=null;if(l.collection.size===0&&r.renderEmptyState){let{isEmpty:re,...Te}=B,V=r.renderEmptyState({...Te});Ae=jsx("div",{role:"row",style:{display:"contents"},...{"aria-level":1},children:jsx("div",{role:"gridcell",style:{display:"contents"},children:V})});}let _t=a$5(r,{global:true});return jsxs(Fragment,{children:[jsx(a$6,{children:jsxs(h.div,{...g$1(_t,Nt,N,te,k?.collectionProps),ref:e,slot:r.slot||void 0,"data-empty":l.collection.size===0||void 0,"data-focused":U||void 0,"data-drop-target":m||void 0,"data-focus-visible":X||void 0,"data-selection-mode":l.selectionManager.selectionMode==="none"?void 0:l.selectionManager.selectionMode,"data-allows-dragging":!!ee||void 0,children:[jsxs(b$2,{values:[[ge,l],[a$7,{dragAndDropHooks:t,dragState:a$8,dropState:c$1}],[b$3,{render:Gt}]],children:[u&&jsx(Wt,{}),jsx(g,{children:jsx(D,{collection:l.collection,persistedKeys:e$1(l.selectionManager,t,c$1),scrollRef:e,renderDropIndicator:d(t,c$1)})})]}),Ae]})}),j]})}var Ie=class extends a$i{static type="content"},Se=j(Ie,function(o){let e=useContext(Pt),t=c({children:o.children,values:e});return jsx(p.Provider,{value:n,children:t.children})}),Pt=createContext(null),Ce=class extends a$i{static type="item"},Ee=k(Ce,(r,o,e)=>{let t=useContext(ge);o=a$8(o);let{dragAndDropHooks:n,dragState:i,dropState:s}=useContext(a$7),u=i&&!(i.isDisabled||i.selectionManager.isDisabled(e.key)),{rowProps:p,gridCellProps:x,expandButtonProps:y,descriptionProps:L,...f$1}=ue({node:e,shouldSelectOnPressUp:!!i,focusMode:r.focusMode,allowsArrowNavigation:r.allowsArrowNavigation},t,o),b=p["aria-expanded"]===true,g=r.hasChildItems||[...t.collection.getChildren(e.key)].length>1,D=p["aria-level"]||1,{hoverProps:h$3,isHovered:T}=a$9({isDisabled:!f$1.allowsSelection&&!f$1.hasAction&&!u,onHoverStart:r.onHoverStart,onHoverChange:r.onHoverChange,onHoverEnd:r.onHoverEnd}),{isFocusVisible:K,focusProps:P}=a$4(),{isFocusVisible:I,focusProps:v}=a$4({within:true}),{checkboxProps:H}=a$a({key:e.key},t),C=null;i&&n&&(C=n.useDraggableItem({key:e.key,hasDragButton:true},i,o));let w=null,R=useRef(null),M=useRef(null),l=useRef(null),{visuallyHiddenProps:N}=a$b();s&&n&&(w=n.useDropIndicator({target:{type:"item",key:e.key,dropPosition:"on"},activateButtonRef:l},s,M));let a=i&&i.isDragging(e.key),c$2=w?.isDropTarget,k=t.selectionManager.selectionMode,m=t.selectionManager.selectionBehavior,j=Bt.useMemo(()=>({...f$1,isHovered:T,isFocusVisible:K,isExpanded:b,hasChildItems:g,level:D,selectionMode:k,selectionBehavior:m,isFocusVisibleWithin:I,state:t,id:e.key,allowsDragging:!!i,isDragging:a,isDropTarget:c$2}),[f$1,T,K,b,g,D,I,t,e.key,i,a,c$2,m,k]),O=c({...r,id:void 0,children:e.rendered,defaultClassName:"react-aria-TreeItem",defaultStyle:{"--tree-item-level":D},values:j});useEffect(()=>{!e.textValue&&process.env.NODE_ENV!=="production"&&console.warn("A `textValue` prop is required for <TreeItem> elements in order to support accessibility features such as type to select.");},[e.textValue]),useEffect(()=>{g&&!R.current&&process.env.NODE_ENV!=="production"&&console.warn("Expandable tree items must contain a expand button so screen reader users can expand/collapse the item.");},[]);let J=useRef(null);useEffect(()=>{i&&!J.current&&process.env.NODE_ENV!=="production"&&console.warn('Draggable items in a Tree must contain a <Button slot="drag"> element so that keyboard and screen reader users can drag them.');},[]);let ee=h$1({items:t.collection.getChildren(e.key),children:B=>{switch(B.type){case "content":return B.render(B);case "loader":case "item":return jsx(Fragment,{});default:throw new Error("Unsupported element type in TreeRow: "+B.type)}}}),te=c$1(),U=a$5(r,{global:true});delete U.id,delete U.onClick;let X=f(C,n,o);return jsxs(Fragment,{children:[w&&!w.isHidden&&jsx("div",{role:"row","aria-level":p["aria-level"],"aria-expanded":p["aria-expanded"],"aria-label":w.dropIndicatorProps["aria-label"],children:jsxs("div",{role:"gridcell","aria-colindex":1,style:{display:"contents"},children:[jsx("div",{role:"button",...N,...w.dropIndicatorProps,ref:M}),p["aria-expanded"]!=null?jsx("div",{role:"button",...N,id:te,"aria-label":y["aria-label"],"aria-labelledby":`${te} ${p.id}`,tabIndex:-1,ref:l}):null]})}),jsx(h.div,{...g$1(U,p,P,h$3,v,X.itemProps),...O,ref:o,"data-expanded":g&&b||void 0,"data-has-child-items":g||void 0,"data-level":D,"data-selected":f$1.isSelected||void 0,"data-disabled":f$1.isDisabled||void 0,"data-hovered":T||void 0,"data-focused":f$1.isFocused||void 0,"data-focus-visible":K||void 0,"data-pressed":f$1.isPressed||void 0,"data-selection-mode":t.selectionManager.selectionMode==="none"?void 0:t.selectionManager.selectionMode,"data-allows-dragging":!!i||void 0,"data-dragging":a||void 0,"data-drop-target":c$2||void 0,children:jsx("div",{...x,style:{display:"contents"},children:jsx(b$2,{values:[[a$c,{slots:{[a$e]:{},selection:H}}],[b$4,{slots:{[a$e]:{},selection:H}}],[a$d,{slots:{[a$e]:{},chevron:{...y,ref:R},drag:{...X.dragButtonProps,ref:J}}}],[Pt,{...j}],[h$2,{isSelected:f$1.isSelected}]],children:ee})})})]})});j(d$1,function(o,e,t){let{isVirtualized:n}=useContext(p),i=useContext(ge),{isLoading:s,onLoadMore:u,scrollOffset:p$1,...x}=o,y=useRef(null),L=useMemo(()=>({onLoadMore:u,collection:i?.collection,sentinelRef:y,scrollOffset:p$1}),[u,p$1,i?.collection]);k$1(L,y),e=a$8(e);let{rowProps:f,gridCellProps:b}=ue({node:t},i,e),g=f["aria-level"]||1,D={role:"row","aria-level":f["aria-level"]},h$1=c({...x,id:void 0,children:t.rendered,defaultClassName:"react-aria-TreeLoader",values:{level:g}}),T={};return n&&(T={display:"contents"}),jsxs(Fragment,{children:[jsx("div",{style:{position:"relative",width:0,height:0},inert:l$1(true),children:jsx("div",{"data-testid":"loadMoreSentinel",ref:y,style:{position:"absolute",height:1,width:1}})}),s&&h$1.children&&jsx(h.div,{ref:e,...g$1(a$5(o),D),...h$1,"data-level":g,children:jsx("div",{...b,style:T,children:h$1.children})})]})});function Gt(r,o){o=a$8(o);let{dragAndDropHooks:e,dropState:t}=useContext(a$7),n=useRef(null),{dropIndicatorProps:i,isHidden:s,isDropTarget:u}=e.useDropIndicator(r,t,n);if(s)return null;let p=t&&r.target.type==="item"?(t.collection.getItem(r.target.key)?.level||0)+1:1;return jsx(Ut,{...r,dropIndicatorProps:i,isDropTarget:u,ref:o,buttonRef:n,level:p})}function jt(r,o){let{dropIndicatorProps:e,isDropTarget:t,buttonRef:n,level:i,...s}=r,{visuallyHiddenProps:u}=a$b(),p=c({...s,defaultClassName:"react-aria-DropIndicator",defaultStyle:{position:"relative","--tree-item-level":i},values:{isDropTarget:t}});return jsx(h.div,{...p,role:"row","aria-level":i,ref:o,"data-drop-target":t||void 0,children:jsxs("div",{role:"gridcell",children:[jsx("div",{...u,role:"button",...e,ref:n}),p.children]})})}var Ut=forwardRef(jt);function Wt(){let{dragAndDropHooks:r,dropState:o}=useContext(a$7),e=useRef(null),{dropIndicatorProps:t}=r.useDropIndicator({target:{type:"root"}},o,e),n=o.isDropTarget({type:"root"}),{visuallyHiddenProps:i}=a$b();return !n&&t["aria-hidden"]?null:jsx("div",{role:"row","aria-hidden":t["aria-hidden"],style:{position:"absolute"},children:jsx("div",{role:"gridcell",children:jsx("div",{role:"button",...i,...t,ref:e})})})}function qt(r,o){if(r.size!==o.size)return false;for(let e of r)if(!o.has(e))return false;return true}var It=({actionsPosition:r,onPrimaryAction:o,onSecondaryAction:e,primaryActionIcon:t,secondaryActionIcon:n,primaryActionAriaLabel:i,secondaryActionAriaLabel:s,expandLabel:u,collapseLabel:p,onRename:x,renameLabel:y,renderItemTitle:L,renderItem:f})=>Object.values({actionsPosition:r,onPrimaryAction:o,onSecondaryAction:e,primaryActionIcon:t,secondaryActionIcon:n,primaryActionAriaLabel:i,secondaryActionAriaLabel:s,expandLabel:u,collapseLabel:p,onRename:x,renameLabel:y,renderItemTitle:L,renderItem:f});var Ct="_10dw1p98",wt="_10dw1p99",Rt="_10dw1p96",St=["_10dw1p9c","_10dw1p9d"],Et="_10dw1p97",Lt=a$f({defaultClassName:"_10dw1p90 _1yep5z63o _1yep5z63p _1yep5z63q _1yep5z61c _1yep5z61d _1yep5z61e _1yep5z6j8 _1yep5z6j9 _1yep5z6ja _1yep5z6jh _1yep5z6ji _1yep5z6jj _1yep5z69f _1yep5z69g _1yep5z69h _1yep5z6jz _1yep5z6k0 _1yep5z6k1 _1yep5z6m6 _1yep5z6lt _1yep5z6lq",variantClassNames:{isSelected:{true:"_1yep5z612u"},isHovered:{true:"_10dw1p92"},isRenaming:{true:"_10dw1p93"},isDropTarget:{true:"_1yep5z612t _1yep5z614w _1yep5z618s _1yep5z618q _1yep5z618t"},isFocusVisible:{true:"_1yep5z614w _1yep5z618s _1yep5z618q _1yep5z618t"}},defaultVariants:{},compoundVariants:[[{isHovered:true,isSelected:false,isRenaming:false},"_1yep5z61pc _1yep5z61rl _1yep5z61va _1yep5z61v9 _1yep5z61vd"]]}),Mt="_10dw1p9a";function At(r,o){let e=r;if(typeof r=="function"&&!r.prototype?.isReactComponent){let t=r(o);e=isValidElement(t)?r:t;}if(e)return "unselected"in e?e.unselected:e}var Me=({item:r,id:o,value:e,...t})=>{let{onPrimaryAction:n,onSecondaryAction:i,actionsPosition:s,primaryActionIcon:u,secondaryActionIcon:p,primaryActionAriaLabel:x,secondaryActionAriaLabel:y,expandLabel:L,collapseLabel:f,onRename:b$1,renameLabel:g,renderItemTitle:D,renderItem:h}=t,{formatMessage:T}=b$7(),{direction:K}=b(),{renamingKey:P,setRenamingKey:I}=useContext(ke),v=P===r.id,H=!!r.children?.length,C=r.icon,w=!!b$1,R=useRef(false),M=useMemo(()=>{let a=At(u,r.id),c=At(p,r.id),k=typeof x=="function"?x(r.id):x,m=typeof y=="function"?y(r.id):y;return a||c?jsxs(a$k,{display:"flex",flexDirection:"row",style:s==="end"?{marginInlineStart:"auto"}:void 0,children:[a?jsx(a$l,{icon:a,"aria-label":k,size:"sm",excludeFromTabOrder:true,variant:"secondary",onPress:()=>{n?.(r.id);},tooltip:true}):null,c?jsx(a$l,{icon:c,"aria-label":m,size:"sm",excludeFromTabOrder:true,variant:"secondary",onPress:()=>{i?.(r.id);},tooltip:true}):null]}):null},[s,u,r.id,p,x,y,n,i]),l$1=useCallback(a=>{a$m(a)||(a.key==="Enter"?(R.current=true,b$1?.({key:r.id,value:a.target.value}),I(null)):a.key==="Escape"&&(R.current=true,I(null)));},[r.id,b$1,I]),N=useCallback(()=>D?D(r):r.label,[D,r]);return jsxs(Ee,{id:r.id,value:r,textValue:r.label,"data-key":r.id,className:h?a$h(Rt,"BaselineUI-TreeView-Row"):a=>a$h(Et,Lt({isHovered:a.isHovered,isSelected:a.isSelected,isFocusVisible:a.isFocusVisible,isRenaming:v,isDropTarget:a.isDropTarget}),"BaselineUI-TreeView-Row"),children:[jsx(Se,{children:a=>{let c=a.allowsDragging?jsx(a$l,{slot:"drag",icon:DragIndicatorIcon,size:"xs",variant:"secondary",className:"BaselineUI-TreeView-DragHandle","data-testid":"tree-view-drag-handle"}):null;if(h){let m=h(r,{level:a.level,isExpanded:a.isExpanded,hasChildItems:a.hasChildItems,isSelected:a.isSelected,isFocusVisible:a.isFocusVisible,isFocusVisibleWithin:a.isFocusVisibleWithin,isHovered:a.isHovered,isPressed:a.isPressed,isDropTarget:!!a.isDropTarget,isDragging:!!a.isDragging,toggleExpanded:()=>{a.state.toggleKey(a.id);}});return c?jsxs(a$k,{display:"flex",flexDirection:"row",alignItems:"center",children:[c,jsx("div",{style:{flex:1,minWidth:0},children:m})]}):m}let k=a.level-1;return jsxs(Fragment,{children:[c,s==="start"?M:null,jsxs(a$k,{display:"flex",flexDirection:"row",alignItems:"center",children:[jsxs(a$k,{display:"flex",padding:"sm",flexDirection:"row",alignItems:"center",gap:"md",style:{marginInlineStart:`calc(${k*2} * ${themeVars.spacing.lg})`},children:[jsx(a$l,{icon:ChevronRightIcon,size:"xxs",variant:"secondary",onPress:()=>{a.state.toggleKey(a.id);},"aria-label":a.isExpanded?f??T(Le.collapse):L??T(Le.expand),style:{visibility:H?"visible":"hidden"},className:a$h(Ct,K==="rtl"&&wt,"BaselineUI-TreeView-ExpansionToggle")}),C?jsx(C,{size:16,style:{color:themeVars.color.icon.interactive.disabled}}):null]}),jsxs(a$k,{paddingLeft:"sm",paddingY:v?"none":"md",display:"flex",flexDirection:"column",gap:"xs",onDoubleClick:m=>{w&&(m.stopPropagation(),m.preventDefault(),I(r.id));},children:[v?jsx("div",{onClick:m=>{m.stopPropagation();},children:jsx(a$n,{defaultValue:r.label,autoFocus:true,onFocus:()=>{R.current=false;},onBlur:m=>{if(R.current){R.current=false;return}b$1?.({key:r.id,value:m.target.value}),I(null);},"aria-label":g??T(Le.rename),onKeyDown:l$1,className:"BaselineUI-TreeView-RenameInput"})}):jsx(a$o,{type:"label",size:"sm",className:a$h(sprinkles.compoundVariants({color:"text.primary"}),"BaselineUI-TreeView-Title"),children:N()}),r.description?jsx(a$o,{type:"helper",size:"sm",className:"BaselineUI-TreeView-Description",children:r.description}):null]})]}),s==="end"?M:null]})}}),jsx(l,{items:r.children,children:a=>jsx(Me,{item:a,...t})})]})},Le=c$2({expand:{id:"bui.treeView.expand",defaultMessage:"Expand"},collapse:{id:"bui.treeView.collapse",defaultMessage:"Collapse"},rename:{id:"bui.treeView.rename",defaultMessage:"Rename"}});var ke=createContext({renamingKey:null,setRenamingKey:()=>{}}),Ht=Bt.forwardRef(({className:r,style:o,"data-block-id":e,"data-block-class":t,items:n,onPrimaryAction:i,onSecondaryAction:s,primaryActionIcon:u,secondaryActionIcon:p,primaryActionAriaLabel:x,secondaryActionAriaLabel:y,actionsPosition:L="start",expandLabel:f,collapseLabel:b,onRename:g,renameLabel:D,onAction:h,renderItemTitle:T,dragAndDropHooks:K,keyboardNavigationBehavior:P,renderItem:I,...v},H)=>{let C=useRef(null);a$g({ref:C,isDisabled:!K});let[w,R]=useState(null),M=I!==void 0,l=L==="start"?[u,p].filter(Boolean).length:0;useEffect(()=>{let c=C.current;if(!c||!g||M)return;let k=m=>{if(m.key==="F2"){let O=c.querySelector("[data-focused='true']")?.dataset.key;O&&(m.preventDefault(),m.stopPropagation(),R(O));}};return c.addEventListener("keydown",k),()=>{c.removeEventListener("keydown",k);}},[g,M]);let N=useMemo(()=>({renamingKey:w,setRenamingKey:R}),[w]),a={actionsPosition:L,onPrimaryAction:i,onSecondaryAction:s,primaryActionIcon:u,secondaryActionIcon:p,primaryActionAriaLabel:x,secondaryActionAriaLabel:y,expandLabel:f,collapseLabel:b,onRename:g,renameLabel:D,renderItemTitle:T,renderItem:I};return jsx(ke.Provider,{value:N,children:jsx(Re,{ref:f$1(H,C),items:n.children||[],selectionMode:"multiple",expandedKeys:v.expandedKeys,defaultExpandedKeys:v.defaultExpandedKeys,onExpandedChange:v.onExpandedChange,selectedKeys:v.selectedKeys,disallowEmptySelection:v.disallowEmptySelection,onAction:h,dragAndDropHooks:K,keyboardNavigationBehavior:P,"aria-label":v["aria-label"],"aria-labelledby":v["aria-labelledby"],"data-block-id":e,"data-block-class":t,style:o,className:a$h(r,!M&&Mt,!M&&St[l-1],"BaselineUI-TreeView"),dependencies:It(a),children:c=>jsx(Me,{item:c,...a})})})});Ht.displayName="TreeView";export{Ht as a};